Просмотр исходного кода

:art: https://github.com/siyuan-note/siyuan/issues/11443

Vanessa 1 год назад
Родитель
Сommit
f6a4ccfc7d
2 измененных файлов с 14 добавлено и 12 удалено
  1. 9 7
      app/src/protyle/render/av/action.ts
  2. 5 5
      app/src/protyle/render/av/cell.ts

+ 9 - 7
app/src/protyle/render/av/action.ts

@@ -272,13 +272,6 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
             type: "submenu",
             submenu: copySubMenu(blockId)
         });
-        menu.addItem({
-            label: window.siyuan.languages.unbindBlock,
-            icon: "iconLinkOff",
-            click() {
-                updateCellsValue(protyle, blockElement, keyCellElement.querySelector(".av__celltext").textContent, [keyCellElement]);
-            }
-        });
     }
     if (!protyle.disabled) {
         menu.addItem({
@@ -366,6 +359,15 @@ ${window.siyuan.languages.insertRowAfter.replace("${x}", '<span class="fn__space
                 }
             });
             menu.addSeparator();
+            if (keyCellElement.getAttribute("data-detached") !== "true") {
+                menu.addItem({
+                    label: window.siyuan.languages.unbindBlock,
+                    icon: "iconLinkOff",
+                    click() {
+                        updateCellsValue(protyle, blockElement, keyCellElement.querySelector(".av__celltext").textContent, [keyCellElement]);
+                    }
+                });
+            }
         }
         menu.addItem({
             icon: "iconTrashcan",

+ 5 - 5
app/src/protyle/render/av/cell.ts

@@ -537,7 +537,7 @@ export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, va
             });
         }
     }
-    const isCustomAttr = !hasClosestByClassName(cellElements[0], "custom-attr");
+    const isCustomAttr = hasClosestByClassName(cellElements[0], "custom-attr");
     cellElements.forEach((item: HTMLElement, elementIndex) => {
         const rowElement = hasClosestByClassName(item, "av__row");
         if (!rowElement) {
@@ -588,7 +588,7 @@ export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, va
             (cellValue.type === "relation" && typeof cellValue.relation === "string")) {
             return;
         }
-        if (type === "select" || type === "mSelect") {
+        if (columns && (type === "select" || type === "mSelect")) {
             const operations = mergeAddOption(columns.find(e => e.id === colId), cellValue, avID);
             doOperations.push(...operations.doOperations);
             undoOperations.push(...operations.undoOperations);
@@ -624,10 +624,10 @@ export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, va
             rowID,
             data: oldValue
         });
-        if (!isCustomAttr) {
-            updateAttrViewCellAnimation(item, cellValue);
-        } else {
+        if (isCustomAttr) {
             item.innerHTML = genAVValueHTML(cellValue);
+        } else {
+            updateAttrViewCellAnimation(item, cellValue);
         }
     });
     if (doOperations.length > 0) {