From 45a6a190d0f8e71b4db33cd166037bc23719b798 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sun, 7 Sep 2025 18:14:46 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/15185 --- app/src/protyle/render/av/col.ts | 152 ++++++++++++++++++------------- 1 file changed, 87 insertions(+), 65 deletions(-) diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.ts index 048dae6b5..26889dcfc 100644 --- a/app/src/protyle/render/av/col.ts +++ b/app/src/protyle/render/av/col.ts @@ -192,11 +192,7 @@ export const getEditHTML = (options: { `; if (colData.type !== "block") { - html += ` - @@ -877,8 +873,88 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen }); } }); - menu.addSeparator({id: "separator_2"}); } + const isPin = cellElement.dataset.pin === "true"; + menu.addItem({ + id: isPin ? "unfreezeCol" : "freezeCol", + icon: isPin ? "iconUnpin" : "iconPin", + label: isPin ? window.siyuan.languages.unfreezeCol : window.siyuan.languages.freezeCol, + click() { + transaction(protyle, [{ + action: "setAttrViewColPin", + id: colId, + avID, + data: !isPin, + blockID + }], [{ + action: "setAttrViewColPin", + id: colId, + avID, + data: isPin, + blockID + }]); + updateAttrViewCellAnimation(blockElement.querySelector(`.av__row--header .av__cell[data-col-id="${colId}"]`), undefined, {pin: !isPin}); + } + }); + if (type !== "block") { + menu.addItem({ + id: "hide", + icon: "iconEyeoff", + label: window.siyuan.languages.hide, + click() { + transaction(protyle, [{ + action: "setAttrViewColHidden", + id: colId, + avID, + data: true, + blockID + }], [{ + action: "setAttrViewColHidden", + id: colId, + avID, + data: false, + blockID + }]); + } + }); + } + menu.addItem({ + icon: "iconRefresh", + label: window.siyuan.languages.syncColWidth, + click() { + transaction(protyle, [{ + action: "syncAttrViewTableColWidth", + keyID: colId, + avID, + id: blockElement.getAttribute(Constants.CUSTOM_SY_AV_VIEW), + }]); + } + }); + menu.addItem({ + icon: "iconSoftWrap", + label: ``, + bind(element) { + const wrapElement = element.querySelector(".b3-switch") as HTMLInputElement; + wrapElement.addEventListener("change", () => { + transaction(protyle, [{ + action: "setAttrViewColWrap", + id: colId, + avID, + data: wrapElement.checked, + blockID + }], [{ + action: "setAttrViewColWrap", + id: colId, + avID, + data: !wrapElement.checked, + blockID + }]); + menu.close(); + }); + } + }); + menu.addSeparator({id: "separator_2"}); menu.addItem({ id: "insertColumnLeft", icon: "iconInsertLeft", @@ -913,62 +989,6 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen }); } }); - if (type !== "block") { - menu.addItem({ - id: "hide", - icon: "iconEyeoff", - label: window.siyuan.languages.hide, - click() { - transaction(protyle, [{ - action: "setAttrViewColHidden", - id: colId, - avID, - data: true, - blockID - }], [{ - action: "setAttrViewColHidden", - id: colId, - avID, - data: false, - blockID - }]); - } - }); - } - const isPin = cellElement.dataset.pin === "true"; - menu.addItem({ - id: isPin ? "unfreezeCol" : "freezeCol", - icon: isPin ? "iconUnpin" : "iconPin", - label: isPin ? window.siyuan.languages.unfreezeCol : window.siyuan.languages.freezeCol, - click() { - transaction(protyle, [{ - action: "setAttrViewColPin", - id: colId, - avID, - data: !isPin, - blockID - }], [{ - action: "setAttrViewColPin", - id: colId, - avID, - data: isPin, - blockID - }]); - updateAttrViewCellAnimation(blockElement.querySelector(`.av__row--header .av__cell[data-col-id="${colId}"]`), undefined, {pin: !isPin}); - } - }); - menu.addItem({ - icon: "iconRefresh", - label: window.siyuan.languages.syncColWidth, - click() { - transaction(protyle, [{ - action: "syncAttrViewTableColWidth", - keyID: colId, - avID, - id: blockElement.getAttribute(Constants.CUSTOM_SY_AV_VIEW), - }]); - } - }); if (type !== "block") { if (type !== "relation") { menu.addItem({ @@ -1006,9 +1026,11 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen title: window.siyuan.languages.removeColConfirm, content: `
${window.siyuan.languages.confirmRemoveRelationField - .replace("${x}", colData.key.name || window.siyuan.languages._kernel[272]) - .replace("${y}", relResponse.data.av.name || window.siyuan.languages._kernel[267]) - .replace("${z}", relResponse.data.av.keyValues.find((item: {key: {id: string}}) => item.key.id === colData.key.relation.backKeyID).key.name || window.siyuan.languages._kernel[272])} + .replace("${x}", colData.key.name || window.siyuan.languages._kernel[272]) + .replace("${y}", relResponse.data.av.name || window.siyuan.languages._kernel[267]) + .replace("${z}", relResponse.data.av.keyValues.find((item: { + key: { id: string } + }) => item.key.id === colData.key.relation.backKeyID).key.name || window.siyuan.languages._kernel[272])}