Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/11791

Vanessac0b0e3f03e81
diff --git a/app/src/ai/actions.ts b/app/src/ai/actions.ts
index 19622fdde7..a906cb0868 100644
--- a/app/src/ai/actions.ts
+++ b/app/src/ai/actions.ts
@@ -165,8 +165,8 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
focusByRange(protyle.toolbar.range);
});
let customHTML = "";
- window.siyuan.storage[Constants.LOCAL_AI].forEach((item: { name: string, memo: string }) => {
- customHTML += `<div data-action="${item.memo || item.name}" class="b3-list-item b3-list-item--narrow ariaLabel" aria-label="${escapeAriaLabel(item.memo)}">
+ window.siyuan.storage[Constants.LOCAL_AI].forEach((item: { name: string, memo: string }, index: number) => {
+ customHTML += `<div data-action="${item.memo || item.name}" data-index="${index}" class="b3-list-item b3-list-item--narrow ariaLabel" aria-label="${escapeAriaLabel(item.memo)}">
<span class="b3-list-item__text">${escapeHtml(item.name)}</span>
<span data-type="edit" class="b3-list-item__action"><svg><use xlink:href="#iconEdit"></use></svg></span>
</div>`;
@@ -251,7 +251,8 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
let target = event.target as HTMLElement;
while (target && !target.isSameNode(element)) {
if (target.classList.contains("b3-list-item__action")) {
- editDialog(target.previousElementSibling.textContent, target.parentElement.getAttribute("aria-label"));
+ const subItem = window.siyuan.storage[Constants.LOCAL_AI][target.parentElement.dataset.index]
+ editDialog(subItem.name, subItem.memo);
menu.close();
event.stopPropagation();
event.preventDefault();