Skip to content

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

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

Vanessae0e44f66773d
diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts
index 48c4c95f0f..2324ae265d 100644
--- a/app/src/protyle/render/av/action.ts
+++ b/app/src/protyle/render/av/action.ts
@@ -146,6 +146,24 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
return true;
}
+ const addTabElement = hasClosestByAttribute(event.target, "data-type", "av-add");
+ if (addTabElement) {
+ const id = Lute.NewNodeID();
+ const avID = blockElement.getAttribute("data-av-id");
+ transaction(protyle, [{
+ action: "addAttrViewView",
+ avID,
+ id
+ }], [{
+ action: "removeAttrViewView",
+ avID,
+ id
+ }]);
+ event.preventDefault();
+ event.stopPropagation();
+ return true;
+ }
+
const linkElement = hasClosestByClassName(event.target, "av__celltext--url");
if (linkElement) {
let linkAddress = linkElement.textContent.trim();
diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.ts
index fe04358529..bbbb5e5dd6 100644
--- a/app/src/protyle/render/av/render.ts
+++ b/app/src/protyle/render/av/render.ts
@@ -210,6 +210,10 @@ ${cell.color ? `color:${cell.color};` : ""}">${text}</div>`;
<div class="av__header">
<div class="layout-tab-bar fn__flex">
${tabHTML}
+ <div class="fn__space"></div>
+ <span data-type="av-add" class="block__icon block__icon--show">
+ <svg><use xlink:href="#iconAdd"></use></svg>
+ </span>
<div class="fn__flex-1"></div>
${response.data.isMirror ? ` <span class="block__icon block__icon--show b3-tooltips b3-tooltips__w" aria-label="${window.siyuan.languages.mirrorTip}">
<svg><use xlink:href="#iconSplitLR"></use></svg></span><div class="fn__space"></div>` : ""}
diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts
index b427f40c00..d35442743a 100644
--- a/app/src/protyle/wysiwyg/transaction.ts
+++ b/app/src/protyle/wysiwyg/transaction.ts
@@ -711,7 +711,8 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
"updateAttrViewColOption", "updateAttrViewCell", "sortAttrViewRow", "sortAttrViewCol", "setAttrViewColHidden",
"setAttrViewColWrap", "setAttrViewColWidth", "removeAttrViewColOption", "setAttrViewName", "setAttrViewFilters",
"setAttrViewSorts", "setAttrViewColCalc", "removeAttrViewCol", "updateAttrViewColNumberFormat", "removeAttrViewBlock",
- "replaceAttrViewBlock", "updateAttrViewColTemplate", "setAttrViewColIcon", "setAttrViewColPin"].includes(operation.action)) {
+ "replaceAttrViewBlock", "updateAttrViewColTemplate", "setAttrViewColIcon", "setAttrViewColPin", "addAttrViewView",
+ "removeAttrViewView"].includes(operation.action)) {
refreshAV(protyle, operation, isUndo);
} else if (operation.action === "doUpdateUpdated") {
updateElements.forEach(item => {
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index 53a924bd42..2231427f44 100644
--- a/app/src/types/index.d.ts
+++ b/app/src/types/index.d.ts
@@ -42,6 +42,8 @@ type TOperation =
| "setAttrViewColCalc"
| "updateAttrViewColNumberFormat"
| "replaceAttrViewBlock"
+ | "addAttrViewView"
+ | "removeAttrViewView"
type TBazaarType = "templates" | "icons" | "widgets" | "themes" | "plugins"
type TCardType = "doc" | "notebook" | "all"
type TEventBus = "ws-main" |