mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-17 09:30:48 +08:00
This commit is contained in:
parent
50156a0dc9
commit
bb151cc6fe
@ -41,10 +41,6 @@ export const duplicateCol = (options: {
|
|||||||
avID: options.avID,
|
avID: options.avID,
|
||||||
type: options.type,
|
type: options.type,
|
||||||
data: options.icon,
|
data: options.icon,
|
||||||
id
|
|
||||||
}, {
|
|
||||||
action: "sortAttrViewCol",
|
|
||||||
avID: options.avID,
|
|
||||||
previousID: options.colId,
|
previousID: options.colId,
|
||||||
id
|
id
|
||||||
}, {
|
}, {
|
||||||
@ -65,12 +61,8 @@ export const duplicateCol = (options: {
|
|||||||
avID: options.avID,
|
avID: options.avID,
|
||||||
type: options.type,
|
type: options.type,
|
||||||
data: options.icon,
|
data: options.icon,
|
||||||
id
|
id,
|
||||||
}, {
|
|
||||||
action: "sortAttrViewCol",
|
|
||||||
avID: options.avID,
|
|
||||||
previousID: options.colId,
|
previousID: options.colId,
|
||||||
id
|
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
@ -83,7 +75,7 @@ export const duplicateCol = (options: {
|
|||||||
type: options.type,
|
type: options.type,
|
||||||
name: options.newValue,
|
name: options.newValue,
|
||||||
icon: options.icon,
|
icon: options.icon,
|
||||||
previousId: options.colId,
|
previousID: options.colId,
|
||||||
id
|
id
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -427,17 +419,17 @@ const addAttrViewColAnimation = (options: {
|
|||||||
protyle: IProtyle,
|
protyle: IProtyle,
|
||||||
type: TAVCol,
|
type: TAVCol,
|
||||||
name: string,
|
name: string,
|
||||||
previousId?: string,
|
|
||||||
id: string,
|
id: string,
|
||||||
icon?: string
|
icon?: string,
|
||||||
|
previousID: string
|
||||||
}) => {
|
}) => {
|
||||||
if (!options.blockElement) {
|
if (!options.blockElement) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
options.blockElement.querySelectorAll(".av__row").forEach((item, index) => {
|
options.blockElement.querySelectorAll(".av__row").forEach((item, index) => {
|
||||||
let previousElement;
|
let previousElement;
|
||||||
if (options.previousId) {
|
if (options.previousID) {
|
||||||
previousElement = item.querySelector(`[data-col-id="${options.previousId}"]`);
|
previousElement = item.querySelector(`[data-col-id="${options.previousID}"]`);
|
||||||
} else {
|
} else {
|
||||||
previousElement = item.lastElementChild.previousElementSibling;
|
previousElement = item.lastElementChild.previousElementSibling;
|
||||||
}
|
}
|
||||||
@ -632,14 +624,26 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
|
|||||||
icon: "iconInsertLeft",
|
icon: "iconInsertLeft",
|
||||||
label: window.siyuan.languages.insertColumnLeft,
|
label: window.siyuan.languages.insertColumnLeft,
|
||||||
click() {
|
click() {
|
||||||
|
const addMenu = addCol(protyle, blockElement, cellElement.previousElementSibling?.getAttribute("data-col-id") || "");
|
||||||
|
const addRect = cellElement.getBoundingClientRect();
|
||||||
|
addMenu.open({
|
||||||
|
x: addRect.left,
|
||||||
|
y: addRect.bottom,
|
||||||
|
h: addRect.height
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menu.addItem({
|
menu.addItem({
|
||||||
icon: "iconInsertRight",
|
icon: "iconInsertRight",
|
||||||
label: window.siyuan.languages.insertColumnRight,
|
label: window.siyuan.languages.insertColumnRight,
|
||||||
click() {
|
click() {
|
||||||
|
const addMenu = addCol(protyle, blockElement, cellElement.nextElementSibling?.getAttribute("data-col-id") || "");
|
||||||
|
const addRect = cellElement.getBoundingClientRect();
|
||||||
|
addMenu.open({
|
||||||
|
x: addRect.left,
|
||||||
|
y: addRect.bottom,
|
||||||
|
h: addRect.height
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (type !== "block") {
|
if (type !== "block") {
|
||||||
@ -710,7 +714,8 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
|
|||||||
name: oldValue,
|
name: oldValue,
|
||||||
avID,
|
avID,
|
||||||
type: type,
|
type: type,
|
||||||
id: colId
|
id: colId,
|
||||||
|
previousID: cellElement.previousElementSibling?.getAttribute("data-col-id") || "",
|
||||||
}]);
|
}]);
|
||||||
removeAttrViewColAnimation(blockElement, colId);
|
removeAttrViewColAnimation(blockElement, colId);
|
||||||
}
|
}
|
||||||
@ -758,9 +763,12 @@ const genUpdateColItem = (type: TAVCol, oldType: TAVCol, name: string) => {
|
|||||||
</button>`;
|
</button>`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addCol = (protyle: IProtyle, blockElement: Element, previousId: string) => {
|
export const addCol = (protyle: IProtyle, blockElement: Element, previousID?: string) => {
|
||||||
const menu = new Menu("av-header-add");
|
const menu = new Menu("av-header-add");
|
||||||
const avID = blockElement.getAttribute("data-av-id");
|
const avID = blockElement.getAttribute("data-av-id");
|
||||||
|
if (typeof previousID === "undefined") {
|
||||||
|
previousID = blockElement.querySelector(".av__row--header .av__cell:last-child").getAttribute("data-col-id");
|
||||||
|
}
|
||||||
menu.addItem({
|
menu.addItem({
|
||||||
icon: "iconAlignLeft",
|
icon: "iconAlignLeft",
|
||||||
label: window.siyuan.languages.text,
|
label: window.siyuan.languages.text,
|
||||||
@ -771,7 +779,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
name: window.siyuan.languages.text,
|
name: window.siyuan.languages.text,
|
||||||
avID,
|
avID,
|
||||||
type: "text",
|
type: "text",
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
@ -782,7 +791,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
protyle: protyle,
|
protyle: protyle,
|
||||||
type: "text",
|
type: "text",
|
||||||
name: window.siyuan.languages.text,
|
name: window.siyuan.languages.text,
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -796,7 +806,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
name: window.siyuan.languages.number,
|
name: window.siyuan.languages.number,
|
||||||
avID,
|
avID,
|
||||||
type: "number",
|
type: "number",
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
@ -807,7 +818,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
protyle: protyle,
|
protyle: protyle,
|
||||||
type: "number",
|
type: "number",
|
||||||
name: window.siyuan.languages.number,
|
name: window.siyuan.languages.number,
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -821,7 +833,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
name: window.siyuan.languages.select,
|
name: window.siyuan.languages.select,
|
||||||
avID,
|
avID,
|
||||||
type: "select",
|
type: "select",
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
@ -832,7 +845,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
protyle: protyle,
|
protyle: protyle,
|
||||||
type: "select",
|
type: "select",
|
||||||
name: window.siyuan.languages.select,
|
name: window.siyuan.languages.select,
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -846,7 +860,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
name: window.siyuan.languages.multiSelect,
|
name: window.siyuan.languages.multiSelect,
|
||||||
avID,
|
avID,
|
||||||
type: "mSelect",
|
type: "mSelect",
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
@ -857,7 +872,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
protyle: protyle,
|
protyle: protyle,
|
||||||
type: "mSelect",
|
type: "mSelect",
|
||||||
name: window.siyuan.languages.multiSelect,
|
name: window.siyuan.languages.multiSelect,
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -871,7 +887,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
name: window.siyuan.languages.date,
|
name: window.siyuan.languages.date,
|
||||||
avID,
|
avID,
|
||||||
type: "date",
|
type: "date",
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
@ -882,7 +899,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
protyle: protyle,
|
protyle: protyle,
|
||||||
type: "date",
|
type: "date",
|
||||||
name: window.siyuan.languages.date,
|
name: window.siyuan.languages.date,
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -896,7 +914,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
name: window.siyuan.languages.assets,
|
name: window.siyuan.languages.assets,
|
||||||
avID,
|
avID,
|
||||||
type: "mAsset",
|
type: "mAsset",
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
@ -907,7 +926,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
protyle: protyle,
|
protyle: protyle,
|
||||||
type: "mAsset",
|
type: "mAsset",
|
||||||
name: window.siyuan.languages.assets,
|
name: window.siyuan.languages.assets,
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -921,7 +941,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
name: window.siyuan.languages.checkbox,
|
name: window.siyuan.languages.checkbox,
|
||||||
avID,
|
avID,
|
||||||
type: "checkbox",
|
type: "checkbox",
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
@ -932,7 +953,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
protyle: protyle,
|
protyle: protyle,
|
||||||
type: "checkbox",
|
type: "checkbox",
|
||||||
name: window.siyuan.languages.checkbox,
|
name: window.siyuan.languages.checkbox,
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -946,7 +968,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
name: window.siyuan.languages.link,
|
name: window.siyuan.languages.link,
|
||||||
avID,
|
avID,
|
||||||
type: "url",
|
type: "url",
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
@ -957,7 +980,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
protyle: protyle,
|
protyle: protyle,
|
||||||
type: "url",
|
type: "url",
|
||||||
name: window.siyuan.languages.link,
|
name: window.siyuan.languages.link,
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -971,7 +995,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
name: window.siyuan.languages.email,
|
name: window.siyuan.languages.email,
|
||||||
avID,
|
avID,
|
||||||
type: "email",
|
type: "email",
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
@ -982,7 +1007,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
protyle: protyle,
|
protyle: protyle,
|
||||||
type: "email",
|
type: "email",
|
||||||
name: window.siyuan.languages.email,
|
name: window.siyuan.languages.email,
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -996,7 +1022,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
name: window.siyuan.languages.phone,
|
name: window.siyuan.languages.phone,
|
||||||
avID,
|
avID,
|
||||||
type: "phone",
|
type: "phone",
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
@ -1007,7 +1034,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
protyle: protyle,
|
protyle: protyle,
|
||||||
type: "phone",
|
type: "phone",
|
||||||
name: window.siyuan.languages.phone,
|
name: window.siyuan.languages.phone,
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1021,7 +1049,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
name: window.siyuan.languages.template,
|
name: window.siyuan.languages.template,
|
||||||
avID,
|
avID,
|
||||||
type: "template",
|
type: "template",
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
@ -1032,7 +1061,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
protyle: protyle,
|
protyle: protyle,
|
||||||
type: "template",
|
type: "template",
|
||||||
name: window.siyuan.languages.template,
|
name: window.siyuan.languages.template,
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1046,7 +1076,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
name: window.siyuan.languages.relation,
|
name: window.siyuan.languages.relation,
|
||||||
avID,
|
avID,
|
||||||
type: "relation",
|
type: "relation",
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
@ -1057,7 +1088,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
protyle: protyle,
|
protyle: protyle,
|
||||||
type: "relation",
|
type: "relation",
|
||||||
name: window.siyuan.languages.relation,
|
name: window.siyuan.languages.relation,
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1071,7 +1103,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
name: window.siyuan.languages.rollup,
|
name: window.siyuan.languages.rollup,
|
||||||
avID,
|
avID,
|
||||||
type: "rollup",
|
type: "rollup",
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
@ -1082,7 +1115,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
protyle: protyle,
|
protyle: protyle,
|
||||||
type: "rollup",
|
type: "rollup",
|
||||||
name: window.siyuan.languages.rollup,
|
name: window.siyuan.languages.rollup,
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1096,7 +1130,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
name: window.siyuan.languages.createdTime,
|
name: window.siyuan.languages.createdTime,
|
||||||
avID,
|
avID,
|
||||||
type: "created",
|
type: "created",
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
@ -1107,7 +1142,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
protyle: protyle,
|
protyle: protyle,
|
||||||
type: "created",
|
type: "created",
|
||||||
name: window.siyuan.languages.createdTime,
|
name: window.siyuan.languages.createdTime,
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1121,7 +1157,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
name: window.siyuan.languages.updatedTime,
|
name: window.siyuan.languages.updatedTime,
|
||||||
avID,
|
avID,
|
||||||
type: "updated",
|
type: "updated",
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
@ -1132,7 +1169,8 @@ export const addCol = (protyle: IProtyle, blockElement: Element, previousId: str
|
|||||||
protyle: protyle,
|
protyle: protyle,
|
||||||
type: "updated",
|
type: "updated",
|
||||||
name: window.siyuan.languages.updatedTime,
|
name: window.siyuan.languages.updatedTime,
|
||||||
id
|
id,
|
||||||
|
previousID
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -859,7 +859,13 @@ export const openMenuPanel = (options: {
|
|||||||
break;
|
break;
|
||||||
} else if (type === "removeCol") {
|
} else if (type === "removeCol") {
|
||||||
const colId = menuElement.querySelector(".b3-menu__item").getAttribute("data-col-id");
|
const colId = menuElement.querySelector(".b3-menu__item").getAttribute("data-col-id");
|
||||||
const colData = data.view.columns.find((item: IAVColumn) => item.id === colId);
|
let previousID: string
|
||||||
|
const colData = data.view.columns.find((item: IAVColumn, index) => {
|
||||||
|
if (item.id === colId) {
|
||||||
|
previousID = data.view.columns[index - 1]?.id;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
transaction(options.protyle, [{
|
transaction(options.protyle, [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id: colId,
|
id: colId,
|
||||||
@ -869,7 +875,8 @@ export const openMenuPanel = (options: {
|
|||||||
name: colData.name,
|
name: colData.name,
|
||||||
avID,
|
avID,
|
||||||
type: colData.type,
|
type: colData.type,
|
||||||
id: colId
|
id: colId,
|
||||||
|
previousID
|
||||||
}]);
|
}]);
|
||||||
removeAttrViewColAnimation(options.blockElement, colId);
|
removeAttrViewColAnimation(options.blockElement, colId);
|
||||||
avPanelElement.remove();
|
avPanelElement.remove();
|
||||||
|
Loading…
Reference in New Issue
Block a user