Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Expose database primary key actions directly https://github.com/siyuan-note/siyuan/issues/18323

Daniel7d34a3cd455d
diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts
index 155ca4d135..1bc4918f4b 100644
--- a/app/src/protyle/render/av/action.ts
+++ b/app/src/protyle/render/av/action.ts
@@ -65,32 +65,18 @@ const openDatabaseRow = (protyle: IProtyle, target: HTMLElement, blockElement: H
});
};
-const openDatabaseRowMore = (protyle: IProtyle, target: HTMLElement) => {
+const updateDatabaseRow = (protyle: IProtyle, target: HTMLElement) => {
const cellElement = hasClosestByClassName(target, "av__cell") as HTMLElement;
if (!cellElement) {
return;
}
- const isDetached = isDetachedDatabaseCell(cellElement);
- const menu = new Menu("av-row-more");
- menu.addItem({
- icon: isDetached ? "iconLink" : "iconRefresh",
- label: isDetached ? window.siyuan.languages.bind : window.siyuan.languages.update,
- click() {
- const textElement = cellElement.querySelector<HTMLElement>(".av__celltext");
- protyle.toolbar.range = document.createRange();
- protyle.toolbar.range.selectNodeContents(textElement);
- focusByRange(protyle.toolbar.range);
- cellElement.classList.add("av__cell--select");
- addDragFill(cellElement);
- hintRef(textElement.textContent.trim(), protyle, "av");
- },
- });
- /// #if MOBILE
- menu.fullscreen("bottom");
- /// #else
- const rect = target.getBoundingClientRect();
- menu.open({x: rect.left, y: rect.bottom, h: rect.height});
- /// #endif
+ const textElement = cellElement.querySelector<HTMLElement>(".av__celltext");
+ protyle.toolbar.range = document.createRange();
+ protyle.toolbar.range.selectNodeContents(textElement);
+ focusByRange(protyle.toolbar.range);
+ cellElement.classList.add("av__cell--select");
+ addDragFill(cellElement);
+ hintRef(textElement.textContent.trim(), protyle, "av");
};
let foldTimeout: number;
@@ -174,8 +160,8 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
event.preventDefault();
event.stopPropagation();
return true;
- } else if (type === "av-row-more" && !protyle.disabled) {
- openDatabaseRowMore(protyle, target);
+ } else if (type === "av-row-update" && !protyle.disabled) {
+ updateDatabaseRow(protyle, target);
event.preventDefault();
event.stopPropagation();
return true;
diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts
index 23401ca07e..c27af126ea 100644
--- a/app/src/protyle/render/av/cell.ts
+++ b/app/src/protyle/render/av/cell.ts
@@ -972,7 +972,9 @@ export const renderCell = (cellValue: IAVCellValue, rowIndex = 0, showIcon = tru
} else {
text = `<span class="b3-menu__avemoji${showIcon ? "" : " fn__none"}" data-unicode="${cellValue.block.icon || ""}">${unicode2Emoji(cellValue.block.icon || window.siyuan.storage[Constants.LOCAL_IMAGES].file)}</span><span data-type="block-ref" data-id="${cellValue.block.id}" data-subtype="s" class="av__celltext av__celltext--ref">${Lute.EscapeHTMLStr(cellValue.block.content)}</span>`;
}
- text += `<span class="av__row-actions"><button class="av__row-action ariaLabel" type="button" data-position="4north" aria-label="${window.siyuan.languages.openBy}" data-type="av-row-open"><svg><use xlink:href="#iconOpen"></use></svg></button><button class="av__row-action ariaLabel" type="button" data-position="4north" aria-label="${window.siyuan.languages.more}" data-type="av-row-more"><svg><use xlink:href="#iconMore"></use></svg></button></span>`;
+ const updateLabel = cellValue?.isDetached ? window.siyuan.languages.bind : window.siyuan.languages.update;
+ const updateIcon = cellValue?.isDetached ? "iconLink" : "iconRefresh";
+ text += `<span class="av__row-actions"><button class="av__row-action ariaLabel" type="button" data-position="4north" aria-label="${window.siyuan.languages.openBy}" data-type="av-row-open"><svg><use xlink:href="#iconOpen"></use></svg></button><button class="av__row-action ariaLabel" type="button" data-position="4north" aria-label="${updateLabel}" data-type="av-row-update"><svg><use xlink:href="#${updateIcon}"></use></svg></button></span>`;
} else if (cellValue.type === "number") {
text = `<span class="av__celltext" data-content="${cellValue?.number.isNotEmpty ? cellValue?.number.content : ""}">${cellValue?.number.formattedContent || cellValue?.number.content || ""}</span>`;
} else if (cellValue.type === "mSelect" || cellValue.type === "select") {