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, [{
|
transaction(protyle, [{
|
||||||
action: "removeAttrViewBlock",
|
action: "removeAttrViewBlock",
|
||||||
srcIDs: blockIds,
|
srcIDs: blockIds,
|
||||||
parentID: blockElement.getAttribute("data-av-id"),
|
avID: blockElement.getAttribute("data-av-id"),
|
||||||
}], [{
|
}], [{
|
||||||
action: "insertAttrViewBlock",
|
action: "insertAttrViewBlock",
|
||||||
parentID: blockElement.getAttribute("data-av-id"),
|
avID: blockElement.getAttribute("data-av-id"),
|
||||||
previousID: rowElement.previousElementSibling?.getAttribute("data-id") || "",
|
previousID: rowElement.previousElementSibling?.getAttribute("data-id") || "",
|
||||||
srcIDs: rowIds,
|
srcIDs: rowIds,
|
||||||
}]);
|
}]);
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ import {transaction} from "../../wysiwyg/transaction";
|
||||||
|
|
||||||
export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
|
export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
|
||||||
const menu = new Menu("av-header-add");
|
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({
|
menu.addItem({
|
||||||
icon: "iconAlignLeft",
|
icon: "iconAlignLeft",
|
||||||
label: window.siyuan.languages.text,
|
label: window.siyuan.languages.text,
|
||||||
|
|
@ -11,13 +13,15 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "addAttrViewCol",
|
action: "addAttrViewCol",
|
||||||
name: "Text",
|
name: "Text",
|
||||||
parentID: blockElement.getAttribute("data-av-id"),
|
avID,
|
||||||
|
viewID,
|
||||||
type: "text",
|
type: "text",
|
||||||
id
|
id
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
parentID: blockElement.getAttribute("data-av-id"),
|
avID,
|
||||||
|
viewID,
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -29,13 +33,15 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "addAttrViewCol",
|
action: "addAttrViewCol",
|
||||||
name: "Number",
|
name: "Number",
|
||||||
parentID: blockElement.getAttribute("data-av-id"),
|
avID,
|
||||||
|
viewID,
|
||||||
type: "number",
|
type: "number",
|
||||||
id
|
id
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
parentID: blockElement.getAttribute("data-av-id"),
|
avID,
|
||||||
|
viewID,
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -47,13 +53,15 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "addAttrViewCol",
|
action: "addAttrViewCol",
|
||||||
name: "Select",
|
name: "Select",
|
||||||
parentID: blockElement.getAttribute("data-av-id"),
|
avID,
|
||||||
|
viewID,
|
||||||
type: "select",
|
type: "select",
|
||||||
id
|
id
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
parentID: blockElement.getAttribute("data-av-id"),
|
avID,
|
||||||
|
viewID,
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -65,13 +73,15 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "addAttrViewCol",
|
action: "addAttrViewCol",
|
||||||
name: "Multi-select",
|
name: "Multi-select",
|
||||||
parentID: blockElement.getAttribute("data-av-id"),
|
avID,
|
||||||
|
viewID,
|
||||||
type: "mSelect",
|
type: "mSelect",
|
||||||
id
|
id
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
parentID: blockElement.getAttribute("data-av-id"),
|
avID,
|
||||||
|
viewID,
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -83,13 +93,15 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "addAttrViewCol",
|
action: "addAttrViewCol",
|
||||||
name: "Date",
|
name: "Date",
|
||||||
parentID: blockElement.getAttribute("data-av-id"),
|
avID,
|
||||||
|
viewID,
|
||||||
type: "date",
|
type: "date",
|
||||||
id
|
id
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id,
|
id,
|
||||||
parentID: blockElement.getAttribute("data-av-id"),
|
avID,
|
||||||
|
viewID,
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -75,13 +75,15 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "updateAttrViewCol",
|
action: "updateAttrViewCol",
|
||||||
id: colId,
|
id: colId,
|
||||||
parentID: avId,
|
avID: avId,
|
||||||
|
viewID: viewId,
|
||||||
name: newValue,
|
name: newValue,
|
||||||
type,
|
type,
|
||||||
}], [{
|
}], [{
|
||||||
action: "updateAttrViewCol",
|
action: "updateAttrViewCol",
|
||||||
id: colId,
|
id: colId,
|
||||||
parentID: avId,
|
avID: avId,
|
||||||
|
viewID: viewId,
|
||||||
name: cellElement.textContent.trim(),
|
name: cellElement.textContent.trim(),
|
||||||
type,
|
type,
|
||||||
}]);
|
}]);
|
||||||
|
|
@ -110,14 +112,14 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
|
||||||
avID: response.data.id,
|
avID: response.data.id,
|
||||||
viewID: response.data.viewID,
|
viewID: response.data.viewID,
|
||||||
data: [{
|
data: [{
|
||||||
column: colId,
|
column: colId,
|
||||||
order: "ASC"
|
order: "ASC"
|
||||||
}]
|
}]
|
||||||
}], [{
|
}], [{
|
||||||
action: "setAttrViewSorts",
|
action: "setAttrViewSorts",
|
||||||
avID: response.data.id,
|
avID: response.data.id,
|
||||||
viewID: response.data.viewID,
|
viewID: response.data.viewID,
|
||||||
data: response.data.view.sorts
|
data: response.data.view.sorts
|
||||||
}]);
|
}]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -131,10 +133,10 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
|
||||||
action: "setAttrViewSorts",
|
action: "setAttrViewSorts",
|
||||||
avID: response.data.id,
|
avID: response.data.id,
|
||||||
viewID: response.data.viewID,
|
viewID: response.data.viewID,
|
||||||
data: [{
|
data: [{
|
||||||
column: colId,
|
column: colId,
|
||||||
order: "DESC"
|
order: "DESC"
|
||||||
}]
|
}]
|
||||||
}], [{
|
}], [{
|
||||||
action: "setAttrViewSorts",
|
action: "setAttrViewSorts",
|
||||||
avID: response.data.id,
|
avID: response.data.id,
|
||||||
|
|
@ -168,7 +170,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
|
||||||
action: "setAttrViewFilters",
|
action: "setAttrViewFilters",
|
||||||
avID: avId,
|
avID: avId,
|
||||||
viewID: avData.viewID,
|
viewID: avData.viewID,
|
||||||
data: [filter]
|
data: [filter]
|
||||||
}], [{
|
}], [{
|
||||||
action: "setAttrViewFilters",
|
action: "setAttrViewFilters",
|
||||||
avID: avId,
|
avID: avId,
|
||||||
|
|
@ -220,11 +222,13 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "removeAttrViewCol",
|
action: "removeAttrViewCol",
|
||||||
id: colId,
|
id: colId,
|
||||||
parentID: avId,
|
avID: avId,
|
||||||
|
viewID: viewId,
|
||||||
}], [{
|
}], [{
|
||||||
action: "addAttrViewCol",
|
action: "addAttrViewCol",
|
||||||
name: cellElement.textContent.trim(),
|
name: cellElement.textContent.trim(),
|
||||||
parentID: avId,
|
avID: avId,
|
||||||
|
viewID: viewId,
|
||||||
type: type,
|
type: type,
|
||||||
id: colId
|
id: colId
|
||||||
}]);
|
}]);
|
||||||
|
|
|
||||||
|
|
@ -188,12 +188,14 @@ export const openMenuPanel = (protyle: IProtyle,
|
||||||
}
|
}
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "sortAttrViewCol",
|
action: "sortAttrViewCol",
|
||||||
parentID: avId,
|
avID: avId,
|
||||||
|
viewID: data.viewID,
|
||||||
previousID: (targetElement.classList.contains("dragover__top") ? targetElement.previousElementSibling?.getAttribute("data-id") : targetElement.getAttribute("data-id")) || "",
|
previousID: (targetElement.classList.contains("dragover__top") ? targetElement.previousElementSibling?.getAttribute("data-id") : targetElement.getAttribute("data-id")) || "",
|
||||||
id: sourceId,
|
id: sourceId,
|
||||||
}], [{
|
}], [{
|
||||||
action: "sortAttrViewCol",
|
action: "sortAttrViewCol",
|
||||||
parentID: avId,
|
avID: avId,
|
||||||
|
viewID: data.viewID,
|
||||||
previousID: sourceElement.previousElementSibling?.getAttribute("data-id") || "",
|
previousID: sourceElement.previousElementSibling?.getAttribute("data-id") || "",
|
||||||
id: sourceId,
|
id: sourceId,
|
||||||
}]);
|
}]);
|
||||||
|
|
|
||||||
|
|
@ -823,15 +823,18 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
if (!blockElement) {
|
if (!blockElement) {
|
||||||
return;
|
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, [{
|
transaction(protyle, [{
|
||||||
action: "sortAttrViewCol",
|
action: "sortAttrViewCol",
|
||||||
parentID: avId,
|
avID,
|
||||||
|
viewID,
|
||||||
previousID: (targetElement.classList.contains("dragover__left") ? targetElement.previousElementSibling?.getAttribute("data-id") : targetElement.getAttribute("data-id")) || "",
|
previousID: (targetElement.classList.contains("dragover__left") ? targetElement.previousElementSibling?.getAttribute("data-id") : targetElement.getAttribute("data-id")) || "",
|
||||||
id: gutterTypes[2],
|
id: gutterTypes[2],
|
||||||
}], [{
|
}], [{
|
||||||
action: "sortAttrViewCol",
|
action: "sortAttrViewCol",
|
||||||
parentID: avId,
|
avID,
|
||||||
|
viewID,
|
||||||
previousID: targetElement.parentElement.querySelector(`[data-id="${gutterTypes[2]}"`).previousElementSibling?.getAttribute("data-id") || "",
|
previousID: targetElement.parentElement.querySelector(`[data-id="${gutterTypes[2]}"`).previousElementSibling?.getAttribute("data-id") || "",
|
||||||
id: gutterTypes[2],
|
id: gutterTypes[2],
|
||||||
}]);
|
}]);
|
||||||
|
|
@ -849,7 +852,8 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
} else {
|
} else {
|
||||||
previousID = targetElement.previousElementSibling?.getAttribute("data-id") || "";
|
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") {
|
if (gutterTypes[0] === "nodeattributeview" && gutterTypes[1] === "row") {
|
||||||
// 行内拖拽
|
// 行内拖拽
|
||||||
const doOperations: IOperation[] = [];
|
const doOperations: IOperation[] = [];
|
||||||
|
|
@ -858,13 +862,15 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
selectedIds.reverse().forEach(item => {
|
selectedIds.reverse().forEach(item => {
|
||||||
doOperations.push({
|
doOperations.push({
|
||||||
action: "sortAttrViewRow",
|
action: "sortAttrViewRow",
|
||||||
parentID: avId,
|
avID,
|
||||||
|
viewID,
|
||||||
previousID,
|
previousID,
|
||||||
id: item,
|
id: item,
|
||||||
});
|
});
|
||||||
undoOperations.push({
|
undoOperations.push({
|
||||||
action: "sortAttrViewRow",
|
action: "sortAttrViewRow",
|
||||||
parentID: avId,
|
avID,
|
||||||
|
viewID,
|
||||||
previousID: undoPreviousId,
|
previousID: undoPreviousId,
|
||||||
id: item,
|
id: item,
|
||||||
});
|
});
|
||||||
|
|
@ -873,13 +879,13 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
} else {
|
} else {
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "insertAttrViewBlock",
|
action: "insertAttrViewBlock",
|
||||||
parentID: avId,
|
avID,
|
||||||
previousID,
|
previousID,
|
||||||
srcIDs: sourceIds,
|
srcIDs: sourceIds,
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewBlock",
|
action: "removeAttrViewBlock",
|
||||||
srcIDs: sourceIds,
|
srcIDs: sourceIds,
|
||||||
parentID: avId,
|
avID,
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
return;
|
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
|
avID?: string, // av
|
||||||
viewID?: string, // av
|
viewID?: string, // av
|
||||||
data?: any, // updateAttr 时为 { old: IObject, new: IObject }, updateAttrViewCell 时为 {TAVCol: {content: string}}
|
data?: any, // updateAttr 时为 { old: IObject, new: IObject }, updateAttrViewCell 时为 {TAVCol: {content: string}}
|
||||||
parentID?: string // 为 insertAttrViewBlock 传 avid
|
parentID?: string
|
||||||
previousID?: string
|
previousID?: string
|
||||||
retData?: any
|
retData?: any
|
||||||
nextID?: string // insert 专享
|
nextID?: string // insert 专享
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue