mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
This commit is contained in:
parent
c6cbb15ed4
commit
65e1a32268
6 changed files with 60 additions and 36 deletions
|
|
@ -162,10 +162,10 @@ export const avContextmenu = (protyle: IProtyle, event: MouseEvent & { detail: a
|
|||
transaction(protyle, [{
|
||||
action: "removeAttrViewBlock",
|
||||
srcIDs: blockIds,
|
||||
parentID: blockElement.getAttribute("data-av-id"),
|
||||
avID: blockElement.getAttribute("data-av-id"),
|
||||
}], [{
|
||||
action: "insertAttrViewBlock",
|
||||
parentID: blockElement.getAttribute("data-av-id"),
|
||||
avID: blockElement.getAttribute("data-av-id"),
|
||||
previousID: rowElement.previousElementSibling?.getAttribute("data-id") || "",
|
||||
srcIDs: rowIds,
|
||||
}]);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ import {transaction} from "../../wysiwyg/transaction";
|
|||
|
||||
export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
|
||||
const menu = new Menu("av-header-add");
|
||||
const avID = blockElement.getAttribute("data-av-id");
|
||||
const viewID = blockElement.querySelector(".item--focus").getAttribute("data-id");
|
||||
menu.addItem({
|
||||
icon: "iconAlignLeft",
|
||||
label: window.siyuan.languages.text,
|
||||
|
|
@ -11,13 +13,15 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
|
|||
transaction(protyle, [{
|
||||
action: "addAttrViewCol",
|
||||
name: "Text",
|
||||
parentID: blockElement.getAttribute("data-av-id"),
|
||||
avID,
|
||||
viewID,
|
||||
type: "text",
|
||||
id
|
||||
}], [{
|
||||
action: "removeAttrViewCol",
|
||||
id,
|
||||
parentID: blockElement.getAttribute("data-av-id"),
|
||||
avID,
|
||||
viewID,
|
||||
}]);
|
||||
}
|
||||
});
|
||||
|
|
@ -29,13 +33,15 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
|
|||
transaction(protyle, [{
|
||||
action: "addAttrViewCol",
|
||||
name: "Number",
|
||||
parentID: blockElement.getAttribute("data-av-id"),
|
||||
avID,
|
||||
viewID,
|
||||
type: "number",
|
||||
id
|
||||
}], [{
|
||||
action: "removeAttrViewCol",
|
||||
id,
|
||||
parentID: blockElement.getAttribute("data-av-id"),
|
||||
avID,
|
||||
viewID,
|
||||
}]);
|
||||
}
|
||||
});
|
||||
|
|
@ -47,13 +53,15 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
|
|||
transaction(protyle, [{
|
||||
action: "addAttrViewCol",
|
||||
name: "Select",
|
||||
parentID: blockElement.getAttribute("data-av-id"),
|
||||
avID,
|
||||
viewID,
|
||||
type: "select",
|
||||
id
|
||||
}], [{
|
||||
action: "removeAttrViewCol",
|
||||
id,
|
||||
parentID: blockElement.getAttribute("data-av-id"),
|
||||
avID,
|
||||
viewID,
|
||||
}]);
|
||||
}
|
||||
});
|
||||
|
|
@ -65,13 +73,15 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
|
|||
transaction(protyle, [{
|
||||
action: "addAttrViewCol",
|
||||
name: "Multi-select",
|
||||
parentID: blockElement.getAttribute("data-av-id"),
|
||||
avID,
|
||||
viewID,
|
||||
type: "mSelect",
|
||||
id
|
||||
}], [{
|
||||
action: "removeAttrViewCol",
|
||||
id,
|
||||
parentID: blockElement.getAttribute("data-av-id"),
|
||||
avID,
|
||||
viewID,
|
||||
}]);
|
||||
}
|
||||
});
|
||||
|
|
@ -83,13 +93,15 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
|
|||
transaction(protyle, [{
|
||||
action: "addAttrViewCol",
|
||||
name: "Date",
|
||||
parentID: blockElement.getAttribute("data-av-id"),
|
||||
avID,
|
||||
viewID,
|
||||
type: "date",
|
||||
id
|
||||
}], [{
|
||||
action: "removeAttrViewCol",
|
||||
id,
|
||||
parentID: blockElement.getAttribute("data-av-id"),
|
||||
avID,
|
||||
viewID,
|
||||
}]);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -75,13 +75,15 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
|
|||
transaction(protyle, [{
|
||||
action: "updateAttrViewCol",
|
||||
id: colId,
|
||||
parentID: avId,
|
||||
avID: avId,
|
||||
viewID: viewId,
|
||||
name: newValue,
|
||||
type,
|
||||
}], [{
|
||||
action: "updateAttrViewCol",
|
||||
id: colId,
|
||||
parentID: avId,
|
||||
avID: avId,
|
||||
viewID: viewId,
|
||||
name: cellElement.textContent.trim(),
|
||||
type,
|
||||
}]);
|
||||
|
|
@ -220,11 +222,13 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
|
|||
transaction(protyle, [{
|
||||
action: "removeAttrViewCol",
|
||||
id: colId,
|
||||
parentID: avId,
|
||||
avID: avId,
|
||||
viewID: viewId,
|
||||
}], [{
|
||||
action: "addAttrViewCol",
|
||||
name: cellElement.textContent.trim(),
|
||||
parentID: avId,
|
||||
avID: avId,
|
||||
viewID: viewId,
|
||||
type: type,
|
||||
id: colId
|
||||
}]);
|
||||
|
|
|
|||
|
|
@ -188,12 +188,14 @@ export const openMenuPanel = (protyle: IProtyle,
|
|||
}
|
||||
transaction(protyle, [{
|
||||
action: "sortAttrViewCol",
|
||||
parentID: avId,
|
||||
avID: avId,
|
||||
viewID: data.viewID,
|
||||
previousID: (targetElement.classList.contains("dragover__top") ? targetElement.previousElementSibling?.getAttribute("data-id") : targetElement.getAttribute("data-id")) || "",
|
||||
id: sourceId,
|
||||
}], [{
|
||||
action: "sortAttrViewCol",
|
||||
parentID: avId,
|
||||
avID: avId,
|
||||
viewID: data.viewID,
|
||||
previousID: sourceElement.previousElementSibling?.getAttribute("data-id") || "",
|
||||
id: sourceId,
|
||||
}]);
|
||||
|
|
|
|||
|
|
@ -823,15 +823,18 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
if (!blockElement) {
|
||||
return;
|
||||
}
|
||||
const avId = blockElement.getAttribute("data-av-id");
|
||||
const avID = blockElement.getAttribute("data-av-id");
|
||||
const viewID = blockElement.querySelector(".item--focus").getAttribute("data-av-id");
|
||||
transaction(protyle, [{
|
||||
action: "sortAttrViewCol",
|
||||
parentID: avId,
|
||||
avID,
|
||||
viewID,
|
||||
previousID: (targetElement.classList.contains("dragover__left") ? targetElement.previousElementSibling?.getAttribute("data-id") : targetElement.getAttribute("data-id")) || "",
|
||||
id: gutterTypes[2],
|
||||
}], [{
|
||||
action: "sortAttrViewCol",
|
||||
parentID: avId,
|
||||
avID,
|
||||
viewID,
|
||||
previousID: targetElement.parentElement.querySelector(`[data-id="${gutterTypes[2]}"`).previousElementSibling?.getAttribute("data-id") || "",
|
||||
id: gutterTypes[2],
|
||||
}]);
|
||||
|
|
@ -849,7 +852,8 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
} else {
|
||||
previousID = targetElement.previousElementSibling?.getAttribute("data-id") || "";
|
||||
}
|
||||
const avId = blockElement.getAttribute("data-av-id");
|
||||
const avID = blockElement.getAttribute("data-av-id");
|
||||
const viewID = blockElement.querySelector(".item--focus").getAttribute("data-id");
|
||||
if (gutterTypes[0] === "nodeattributeview" && gutterTypes[1] === "row") {
|
||||
// 行内拖拽
|
||||
const doOperations: IOperation[] = [];
|
||||
|
|
@ -858,13 +862,15 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
selectedIds.reverse().forEach(item => {
|
||||
doOperations.push({
|
||||
action: "sortAttrViewRow",
|
||||
parentID: avId,
|
||||
avID,
|
||||
viewID,
|
||||
previousID,
|
||||
id: item,
|
||||
});
|
||||
undoOperations.push({
|
||||
action: "sortAttrViewRow",
|
||||
parentID: avId,
|
||||
avID,
|
||||
viewID,
|
||||
previousID: undoPreviousId,
|
||||
id: item,
|
||||
});
|
||||
|
|
@ -873,13 +879,13 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
} else {
|
||||
transaction(protyle, [{
|
||||
action: "insertAttrViewBlock",
|
||||
parentID: avId,
|
||||
avID,
|
||||
previousID,
|
||||
srcIDs: sourceIds,
|
||||
}], [{
|
||||
action: "removeAttrViewBlock",
|
||||
srcIDs: sourceIds,
|
||||
parentID: avId,
|
||||
avID,
|
||||
}]);
|
||||
}
|
||||
return;
|
||||
|
|
|
|||
2
app/src/types/index.d.ts
vendored
2
app/src/types/index.d.ts
vendored
|
|
@ -309,7 +309,7 @@ interface IOperation {
|
|||
avID?: string, // av
|
||||
viewID?: string, // av
|
||||
data?: any, // updateAttr 时为 { old: IObject, new: IObject }, updateAttrViewCell 时为 {TAVCol: {content: string}}
|
||||
parentID?: string // 为 insertAttrViewBlock 传 avid
|
||||
parentID?: string
|
||||
previousID?: string
|
||||
retData?: any
|
||||
nextID?: string // insert 专享
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue