An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/5735
Vanessa17270afff38a
diff --git a/app/src/block/popover.ts b/app/src/block/popover.tsindex c441215403..6d477d03f8 100644--- a/app/src/block/popover.ts+++ b/app/src/block/popover.ts@@ -8,7 +8,7 @@ export const initBlockPopover = () => {let timeoutHide: number;// 编辑器内容块引用/backlinks/tag/bookmark/套娃中使用document.addEventListener("mouseover", (event: MouseEvent & { target: HTMLElement }) => {- const aElement = hasClosestByAttribute(event.target, "data-type", "a", true)||+ const aElement = hasClosestByAttribute(event.target, "data-type", "a", true) ||hasClosestByAttribute(event.target, "data-type", "tab-header") ||hasClosestByClassName(event.target, "emojis__item") ||hasClosestByClassName(event.target, "emojis__type");@@ -98,6 +98,9 @@ export const initBlockPopover = () => {}}, 200);timeout = window.setTimeout(async () => {+ if (hasClosestByClassName(event.target, "history__repo", true)) {+ return;+ }let popoverTargetElement = hasClosestByAttribute(event.target, "data-type", "block-ref") as HTMLElement ||hasClosestByAttribute(event.target, "data-type", "virtual-block-ref") as HTMLElement;if (!popoverTargetElement) {diff --git a/app/src/constants.ts b/app/src/constants.tsindex 179a5033ae..e4e4b458c9 100644--- a/app/src/constants.ts+++ b/app/src/constants.ts@@ -53,6 +53,7 @@ export abstract class Constants {public static readonly CB_GET_SCROLL = "cb-get-scroll"; // 滚动到指定位置public static readonly CB_GET_CONTEXT = "cb-get-context"; // 包含上下文public static readonly CB_GET_HTML = "cb-get-html"; // 直接渲染,不需要再 /api/block/getDocInfo,否则搜索表格无法定位+ public static readonly CB_GET_HISTORY = "cb-get-history"; // 历史渲染// localstoragepublic static readonly LOCAL_SEARCHEDATA = "local-searchedata";diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.tsindex 73172316ba..bcff951672 100644--- a/app/src/menus/protyle.ts+++ b/app/src/menus/protyle.ts@@ -375,7 +375,7 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {};export const zoomOut = (protyle: IProtyle, id: string, focusId?: string, isPushBack = true, callback?: () => void) => {- const breadcrumbHLElement = protyle.breadcrumb.element.querySelector(".protyle-breadcrumb__item--active");+ const breadcrumbHLElement = protyle.breadcrumb?.element.querySelector(".protyle-breadcrumb__item--active");if (breadcrumbHLElement && breadcrumbHLElement.getAttribute("data-node-id") === id) {if (id === protyle.block.rootID) {return;diff --git a/app/src/mobile/editor.ts b/app/src/mobile/editor.tsindex 2b7e4d8d6a..a8e9352e2d 100644--- a/app/src/mobile/editor.ts+++ b/app/src/mobile/editor.ts@@ -51,7 +51,7 @@ export const openMobileFileById = (id: string, action = [Constants.CB_GET_HL]) =mode: action.includes(Constants.CB_GET_CONTEXT) ? 3 : 0,}, getResponse => {onGet(getResponse, window.siyuan.mobileEditor.protyle, action);- window.siyuan.mobileEditor.protyle.breadcrumb.render(window.siyuan.mobileEditor.protyle);+ window.siyuan.mobileEditor.protyle.breadcrumb?.render(window.siyuan.mobileEditor.protyle);});window.siyuan.mobileEditor.protyle.undo.clear();} else {diff --git a/app/src/mobile/util/MobileBackFoward.ts b/app/src/mobile/util/MobileBackFoward.tsindex 5dafcdfca2..3b18947c64 100644--- a/app/src/mobile/util/MobileBackFoward.ts+++ b/app/src/mobile/util/MobileBackFoward.ts@@ -67,7 +67,7 @@ const focusStack = (backStack: IBackStack) => {enableProtyle(protyle);}protyle.contentElement.scrollTop = backStack.scrollTop;- window.siyuan.mobileEditor.protyle.breadcrumb.render(protyle);+ window.siyuan.mobileEditor.protyle.breadcrumb?.render(protyle);});};diff --git a/app/src/mobile/util/touch.ts b/app/src/mobile/util/touch.tsindex 2d3127e808..e371f51da3 100644--- a/app/src/mobile/util/touch.ts+++ b/app/src/mobile/util/touch.ts@@ -7,7 +7,7 @@ let yDiff: number;export const handleTouchEnd = () => {if (window.siyuan.mobileEditor) {- window.siyuan.mobileEditor.protyle.breadcrumb.show();+ window.siyuan.mobileEditor.protyle.breadcrumb?.show();}if (!clientX || !clientY || navigator.userAgent.indexOf("iPhone") === -1) {diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.tsindex 358e477144..6a13a91bd4 100644--- a/app/src/protyle/gutter/index.ts+++ b/app/src/protyle/gutter/index.ts@@ -584,7 +584,7 @@ export class Gutter {html += removeEmbed(item);});writeText(protyle.lute.BlockDOM2StdMd(html).trimEnd());- protyle.breadcrumb.hide();+ protyle.breadcrumb?.hide();removeBlock(protyle, selectsElement[0], getEditorRange(selectsElement[0]));} else {focusByRange(getEditorRange(selectsElement[0]));@@ -605,7 +605,7 @@ export class Gutter {icon: "iconTrashcan",accelerator: "⌫",click: () => {- protyle.breadcrumb.hide();+ protyle.breadcrumb?.hide();removeBlock(protyle, selectsElement[0], getEditorRange(selectsElement[0]));}}).element);@@ -965,7 +965,7 @@ export class Gutter {if (isNotEditBlock(nodeElement)) {writeText(protyle.lute.BlockDOM2StdMd(removeEmbed(nodeElement)).trimEnd());removeBlock(protyle, nodeElement, getEditorRange(nodeElement));- protyle.breadcrumb.hide();+ protyle.breadcrumb?.hide();} else {focusByRange(getEditorRange(nodeElement));document.execCommand("cut");@@ -985,7 +985,7 @@ export class Gutter {icon: "iconTrashcan",accelerator: "⌫",click: () => {- protyle.breadcrumb.hide();+ protyle.breadcrumb?.hide();removeBlock(protyle, nodeElement, getEditorRange(nodeElement));}}).element);diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.tsindex 6ca93f4299..20d556065f 100644--- a/app/src/protyle/index.ts+++ b/app/src/protyle/index.ts@@ -50,7 +50,9 @@ class Protyle {};this.protyle.hint = new Hint(this.protyle);- this.protyle.breadcrumb = new Breadcrumb(this.protyle);+ if (mergedOptions.render.breadcrumb) {+ this.protyle.breadcrumb = new Breadcrumb(this.protyle);+ }/// #if !MOBILEif (mergedOptions.render.title) {this.protyle.title = new Title(this.protyle);@@ -62,8 +64,9 @@ class Protyle {this.protyle.element.innerHTML = "";this.protyle.element.classList.add("protyle");- this.protyle.element.appendChild(this.protyle.breadcrumb.element.parentElement);-+ if (mergedOptions.render.breadcrumb) {+ this.protyle.element.appendChild(this.protyle.breadcrumb.element.parentElement);+ }this.protyle.undo = new Undo();this.protyle.wysiwyg = new WYSIWYG(this.protyle);this.protyle.toolbar = new Toolbar(this.protyle);@@ -76,130 +79,131 @@ class Protyle {}this.init();- this.protyle.ws = new Model({- id: this.protyle.id,- type: "protyle",- msgCallback: (data) => {- switch (data.cmd) {- case "transactions":- data.data[0].doOperations.forEach((item: IOperation) => {- onTransaction(this.protyle, item, false);- });- break;- case "heading2doc":- case "li2doc":- if (this.protyle.block.rootID === data.data.srcRootBlockID) {- const scrollTop = this.protyle.contentElement.scrollTop;- fetchPost("/api/filetree/getDoc", {- id: this.protyle.block.id,- size: Constants.SIZE_GET,- }, getResponse => {- onGet(getResponse, this.protyle);- /// #if !MOBILE- if (data.cmd === "heading2doc") {- // 文档标题互转后,需更新大纲- updatePanelByEditor(this.protyle, false, false, true);- }- /// #endif- // 文档标题互转后,编辑区会跳转到开头 https://github.com/siyuan-note/siyuan/issues/2939- setTimeout(() => {- this.protyle.contentElement.scrollTop = scrollTop;- this.protyle.scroll.lastScrollTop = scrollTop - 1;- }, Constants.TIMEOUT_BLOCKLOAD);+ if (!options.action.includes(Constants.CB_GET_HISTORY)) {+ this.protyle.ws = new Model({+ id: this.protyle.id,+ type: "protyle",+ msgCallback: (data) => {+ switch (data.cmd) {+ case "transactions":+ data.data[0].doOperations.forEach((item: IOperation) => {+ onTransaction(this.protyle, item, false);});- }- break;- case "rename":- if (this.protyle.path === data.data.path) {- if (this.protyle.model) {- this.protyle.model.parent.updateTitle(data.data.title);+ break;+ case "heading2doc":+ case "li2doc":+ if (this.protyle.block.rootID === data.data.srcRootBlockID) {+ const scrollTop = this.protyle.contentElement.scrollTop;+ fetchPost("/api/filetree/getDoc", {+ id: this.protyle.block.id,+ size: Constants.SIZE_GET,+ }, getResponse => {+ onGet(getResponse, this.protyle);+ /// #if !MOBILE+ if (data.cmd === "heading2doc") {+ // 文档标题互转后,需更新大纲+ updatePanelByEditor(this.protyle, false, false, true);+ }+ /// #endif+ // 文档标题互转后,编辑区会跳转到开头 https://github.com/siyuan-note/siyuan/issues/2939+ setTimeout(() => {+ this.protyle.contentElement.scrollTop = scrollTop;+ this.protyle.scroll.lastScrollTop = scrollTop - 1;+ }, Constants.TIMEOUT_BLOCKLOAD);+ });}- if (this.protyle.background) {- this.protyle.background.ial.title = data.data.title;+ break;+ case "rename":+ if (this.protyle.path === data.data.path) {+ if (this.protyle.model) {+ this.protyle.model.parent.updateTitle(data.data.title);+ }+ if (this.protyle.background) {+ this.protyle.background.ial.title = data.data.title;+ }}- }- if (this.protyle.options.render.title && this.protyle.block.parentID === data.data.id) {- if (getSelection().rangeCount > 0 && this.protyle.element.contains(getSelection().getRangeAt(0).startContainer)) {- // 编辑中的不用更新- } else {- this.protyle.title.setTitle(data.data.title);+ if (this.protyle.options.render.title && this.protyle.block.parentID === data.data.id) {+ if (getSelection().rangeCount > 0 && this.protyle.element.contains(getSelection().getRangeAt(0).startContainer)) {+ // 编辑中的不用更新+ } else {+ this.protyle.title.setTitle(data.data.title);+ }}- }- // update ref- this.protyle.wysiwyg.element.querySelectorAll(`[data-type="block-ref"][data-id="${data.data.id}"]`).forEach(item => {- if (item.getAttribute("data-subtype") === "d") {- item.textContent = data.data.title;+ // update ref+ this.protyle.wysiwyg.element.querySelectorAll(`[data-type="block-ref"][data-id="${data.data.id}"]`).forEach(item => {+ if (item.getAttribute("data-subtype") === "d") {+ item.textContent = data.data.title;+ }+ });+ break;+ case "moveDoc":+ if (data.data.fromNotebook === this.protyle.notebookId && this.protyle.path === data.data.fromPath) {+ this.protyle.path = data.data.newPath;+ this.protyle.notebookId = data.data.toNotebook;}- });- break;- case "moveDoc":- if (data.data.fromNotebook === this.protyle.notebookId && this.protyle.path === data.data.fromPath) {- this.protyle.path = data.data.newPath;- this.protyle.notebookId = data.data.toNotebook;- }- break;- case "unmount":- if (this.protyle.model && this.protyle.notebookId === data.data.box) {- this.protyle.model.parent.parent.removeTab(this.protyle.model.parent.id, false, false);- }- break;- case "remove":- if (this.protyle.model && (this.protyle.notebookId === data.data.box &&- (!data.data.path || this.protyle.path.indexOf(getDisplayName(data.data.path, false, true)) === 0))) {- this.protyle.model.parent.parent.removeTab(this.protyle.model.parent.id, false, false);- }- break;+ break;+ case "unmount":+ if (this.protyle.model && this.protyle.notebookId === data.data.box) {+ this.protyle.model.parent.parent.removeTab(this.protyle.model.parent.id, false, false);+ }+ break;+ case "remove":+ if (this.protyle.model && (this.protyle.notebookId === data.data.box &&+ (!data.data.path || this.protyle.path.indexOf(getDisplayName(data.data.path, false, true)) === 0))) {+ this.protyle.model.parent.parent.removeTab(this.protyle.model.parent.id, false, false);+ }+ break;+ }}- }- });-- setPadding(this.protyle);- fetchPost("/api/filetree/getDoc", {- id: options.blockId,- k: options.key || "",- mode: (options.action && options.action.includes(Constants.CB_GET_CONTEXT)) ? 3 : 0, // 0: 仅当前 ID(默认值),1:向上 2:向下,3:上下都加载,4:加载最后- size: options.action?.includes(Constants.CB_GET_ALL) ? Constants.SIZE_GET_MAX : Constants.SIZE_GET,- }, getResponse => {- onGet(getResponse, this.protyle, options.action, options.scrollAttr);- if (this.protyle.model) {- /// #if !MOBILE- if (options.action?.includes(Constants.CB_GET_FOCUS)) {- setPanelFocus(this.protyle.model.element.parentElement.parentElement);+ });+ fetchPost("/api/filetree/getDoc", {+ id: options.blockId,+ k: options.key || "",+ mode: (options.action && options.action.includes(Constants.CB_GET_CONTEXT)) ? 3 : 0, // 0: 仅当前 ID(默认值),1:向上 2:向下,3:上下都加载,4:加载最后+ size: options.action?.includes(Constants.CB_GET_ALL) ? Constants.SIZE_GET_MAX : Constants.SIZE_GET,+ }, getResponse => {+ onGet(getResponse, this.protyle, options.action, options.scrollAttr);+ if (this.protyle.model) {+ /// #if !MOBILE+ if (options.action?.includes(Constants.CB_GET_FOCUS)) {+ setPanelFocus(this.protyle.model.element.parentElement.parentElement);+ }+ updatePanelByEditor(this.protyle, false);+ /// #endif}- updatePanelByEditor(this.protyle, false);- /// #endif- }- // 需等待 getDoc 完成后再执行,否则在无页签的时候 updatePanelByEditor 会执行2次- // 只能用 focusin,否则点击表格无法执行- /// #if !MOBILE- this.protyle.wysiwyg.element.addEventListener("focusin", () => {- if (this.protyle && this.protyle.model) {- let needUpdate = true;- if (this.protyle.model.element.parentElement.parentElement.classList.contains("layout__wnd--active") && this.protyle.model.headElement.classList.contains("item--focus")) {- needUpdate = false;- }- if (!needUpdate) {- return;+ // 需等待 getDoc 完成后再执行,否则在无页签的时候 updatePanelByEditor 会执行2次+ // 只能用 focusin,否则点击表格无法执行+ /// #if !MOBILE+ this.protyle.wysiwyg.element.addEventListener("focusin", () => {+ if (this.protyle && this.protyle.model) {+ let needUpdate = true;+ if (this.protyle.model.element.parentElement.parentElement.classList.contains("layout__wnd--active") && this.protyle.model.headElement.classList.contains("item--focus")) {+ needUpdate = false;+ }+ if (!needUpdate) {+ return;+ }+ setPanelFocus(this.protyle.model.element.parentElement.parentElement);+ updatePanelByEditor(this.protyle, false);+ } else {+ // 悬浮层应移除其余面板高亮,否则按键会被面板监听到+ document.querySelectorAll(".block__icons--active").forEach(item => {+ item.classList.remove("block__icons--active");+ });+ document.querySelectorAll(".layout__wnd--active").forEach(item => {+ item.classList.remove("layout__wnd--active");+ });}- setPanelFocus(this.protyle.model.element.parentElement.parentElement);- updatePanelByEditor(this.protyle, false);- } else {- // 悬浮层应移除其余面板高亮,否则按键会被面板监听到- document.querySelectorAll(".block__icons--active").forEach(item => {- item.classList.remove("block__icons--active");- });- document.querySelectorAll(".layout__wnd--active").forEach(item => {- item.classList.remove("layout__wnd--active");- });+ });+ /// #endif+ // 需等渲染完后再回调,用于定位搜索字段 https://github.com/siyuan-note/siyuan/issues/3171+ if (mergedOptions.after) {+ mergedOptions.after(this);}});- /// #endif- // 需等渲染完后再回调,用于定位搜索字段 https://github.com/siyuan-note/siyuan/issues/3171- if (mergedOptions.after) {- mergedOptions.after(this);- }- });+ setPadding(this.protyle);+ }}public reload() {diff --git a/app/src/protyle/scroll/event.ts b/app/src/protyle/scroll/event.tsindex 054670715d..35820ffb2c 100644--- a/app/src/protyle/scroll/event.ts+++ b/app/src/protyle/scroll/event.ts@@ -35,7 +35,7 @@ export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {showMessage(window.siyuan.languages.crossPageUse.replace("${}", updateHotkeyTip("⇧Click")), 9000);}- const panelContextElement = protyle.breadcrumb.element.parentElement.querySelector('[data-type="context"]');+ const panelContextElement = protyle.breadcrumb?.element.parentElement.querySelector('[data-type="context"]');if (panelContextElement && !panelContextElement.classList.contains("ft__primary")) {// 悬浮窗需展开上下文后才能进行滚动 https://github.com/siyuan-note/siyuan/issues/2311return;diff --git a/app/src/protyle/ui/initUI.ts b/app/src/protyle/ui/initUI.tsindex 27c6ec6fef..b4efe047b7 100644--- a/app/src/protyle/ui/initUI.ts+++ b/app/src/protyle/ui/initUI.ts@@ -19,7 +19,9 @@ export const initUI = (protyle: IProtyle) => {protyle.contentElement.appendChild(protyle.title.element);}protyle.contentElement.appendChild(protyle.wysiwyg.element);- scrollEvent(protyle, protyle.contentElement);+ if (!protyle.options.action.includes(Constants.CB_GET_HISTORY)) {+ scrollEvent(protyle, protyle.contentElement);+ }protyle.element.append(protyle.contentElement);protyle.element.appendChild(protyle.preview.element);if (protyle.upload) {@@ -59,6 +61,9 @@ export const removeLoading = (protyle: IProtyle) => {};export const setPadding = (protyle: IProtyle) => {+ if (protyle.options.action.includes(Constants.CB_GET_HISTORY)) {+ return;+ }let min16 = 16;let min24 = 24;if (!isMobile()) {diff --git a/app/src/protyle/util/Options.ts b/app/src/protyle/util/Options.tsindex 0695bc9cd6..9ab6c0ae0b 100644--- a/app/src/protyle/util/Options.ts+++ b/app/src/protyle/util/Options.ts@@ -13,6 +13,7 @@ export class Options {title: false,gutter: true,scroll: false,+ breadcrumb: true,breadcrumbDocName: false,breadcrumbContext: false},diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.tsindex fb5cf9de9b..7df5dc7cb0 100644--- a/app/src/protyle/util/onGet.ts+++ b/app/src/protyle/util/onGet.ts@@ -172,6 +172,10 @@ const setHTML = (options: { content: string, action?: string[], unScroll?: booleprocessRender(protyle.wysiwyg.element);highlightRender(protyle.wysiwyg.element);blockRender(protyle, protyle.wysiwyg.element);+ if (options.action.includes(Constants.CB_GET_HISTORY)) {+ disabledProtyle(protyle);+ return;+ }if (protyle.options.render.scroll) {protyle.scroll.update(protyle.block.blockCount, protyle);}@@ -265,7 +269,9 @@ const setHTML = (options: { content: string, action?: string[], unScroll?: booleif (options.action.includes(Constants.CB_GET_APPEND) || options.action.includes(Constants.CB_GET_BEFORE)) {return;}- protyle.breadcrumb.render(protyle);+ if (protyle.options.render.breadcrumb) {+ protyle.breadcrumb.render(protyle);+ }};/** 禁用编辑器 */diff --git a/app/src/protyle/util/setEditMode.ts b/app/src/protyle/util/setEditMode.tsindex 99971e7d12..4b89db52af 100644--- a/app/src/protyle/util/setEditMode.ts+++ b/app/src/protyle/util/setEditMode.ts@@ -9,7 +9,9 @@ export const setEditMode = (protyle: IProtyle, type: TEditorMode) => {protyle.preview.element.classList.remove("fn__none");protyle.contentElement.classList.add("fn__none");protyle.scroll?.element.classList.add("fn__none");- protyle.breadcrumb.element.classList.add("fn__none");+ if (protyle.options.render.breadcrumb) {+ protyle.breadcrumb?.element.classList.add("fn__none");+ }protyle.preview.render(protyle);} else if (type === "wysiwyg") {setPadding(protyle);@@ -22,7 +24,9 @@ export const setEditMode = (protyle: IProtyle, type: TEditorMode) => {if (protyle.options.render.scroll) {protyle.scroll?.element.classList.remove("fn__none");}- protyle.breadcrumb.element.classList.remove("fn__none");+ if (protyle.options.render.breadcrumb) {+ protyle.breadcrumb?.element.classList.remove("fn__none");+ }}hideElements( ["gutter", "toolbar", "select", "hint", "util"], protyle);};diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.tsindex ec7b638b0e..ac3b5a337b 100644--- a/app/src/protyle/wysiwyg/index.ts+++ b/app/src/protyle/wysiwyg/index.ts@@ -78,6 +78,9 @@ export class WYSIWYG {if (window.siyuan.config.editor.displayBookmarkIcon) {this.element.classList.add("protyle-wysiwyg--attr");}+ if (protyle.options.action.includes(Constants.CB_GET_HISTORY)) {+ return;+ }this.bindEvent(protyle);keydown(protyle, this.element);dropEvent(protyle, this.element);@@ -273,7 +276,9 @@ export class WYSIWYG {event.stopPropagation();event.preventDefault();- protyle.breadcrumb.hide();+ if (protyle.options.render.breadcrumb) {+ protyle.breadcrumb.hide();+ }const range = getEditorRange(protyle.wysiwyg.element);let nodeElement = hasClosestBlock(range.startContainer);if (!nodeElement) {@@ -727,7 +732,7 @@ export class WYSIWYG {} else if (event.clientX < mostLeft) {x = mostLeft;}- const mostTop = rect.top + protyle.breadcrumb.element.parentElement.clientHeight;+ const mostTop = rect.top + (protyle.options.render.breadcrumb?protyle.breadcrumb.element.parentElement.clientHeight:0);let mouseElement: Element;let moveCellElement: HTMLElement;@@ -1873,7 +1878,9 @@ export class WYSIWYG {}// 面包屑定位- protyle.breadcrumb.render(protyle);+ if (protyle.options.render.breadcrumb) {+ protyle.breadcrumb.render(protyle);+ }});}}diff --git a/app/src/types/protyle.d.ts b/app/src/types/protyle.d.tsindex afdbf7250f..799c607190 100644--- a/app/src/types/protyle.d.ts+++ b/app/src/types/protyle.d.ts@@ -355,6 +355,7 @@ interface IOptions {title?: booleangutter?: booleanscroll?: boolean+ breadcrumb?: booleanbreadcrumbDocName?: booleanbreadcrumbContext?: boolean}diff --git a/app/src/util/globalShortcut.ts b/app/src/util/globalShortcut.tsindex 243205ab38..1074c3c868 100644--- a/app/src/util/globalShortcut.ts+++ b/app/src/util/globalShortcut.ts@@ -91,7 +91,7 @@ export const globalShortcut = () => {}const eventPath0 = event.composedPath()[0] as HTMLElement;- if (eventPath0 && eventPath0.nodeType !== 3 && eventPath0.classList.contains("protyle-wysiwyg")) {+ if (eventPath0 && eventPath0.nodeType !== 3 && eventPath0.classList.contains("protyle-wysiwyg") && eventPath0.style.paddingLeft) {// 光标在编辑器右边也需要进行显示const mouseElement = document.elementFromPoint(eventPath0.getBoundingClientRect().left + parseInt(eventPath0.style.paddingLeft) + 13, event.clientY);const blockElement = hasClosestBlock(mouseElement);diff --git a/app/src/util/history.ts b/app/src/util/history.tsindex 349b87be18..561680ba37 100644--- a/app/src/util/history.ts+++ b/app/src/util/history.ts@@ -6,7 +6,10 @@ import {escapeHtml} from "./escape";import {isMobile} from "./functions";import {hasClosestByClassName} from "../protyle/util/hasClosest";import {renderAssetsPreview} from "../asset/renderAssets";+import Protyle from "../protyle";+import {onGet} from "../protyle/util/onGet";+let historyEditor: Protyleconst renderDoc = (element: HTMLElement, currentPage: number) => {const previousElement = element.querySelector('[data-type="docprevious"]');const nextElement = element.querySelector('[data-type="docnext"]');@@ -24,9 +27,13 @@ const renderDoc = (element: HTMLElement, currentPage: number) => {if (typeElement.value === "0") {opElement.removeAttribute("disabled")notebookElement.removeAttribute("disabled")+ element.lastElementChild.lastElementChild.previousElementSibling.classList.add("fn__none");+ element.lastElementChild.lastElementChild.classList.remove("fn__none");} else {opElement.setAttribute("disabled", "disabled")notebookElement.setAttribute("disabled", "disabled")+ element.lastElementChild.lastElementChild.previousElementSibling.classList.remove("fn__none");+ element.lastElementChild.lastElementChild.classList.add("fn__none");}fetchPost("/api/history/searchHistory", {notebook: notebookElement.value,@@ -41,7 +48,8 @@ const renderDoc = (element: HTMLElement, currentPage: number) => {nextElement.setAttribute("disabled", "disabled");}if (response.data.histories.length === 0) {- element.lastElementChild.lastElementChild.innerHTML = "";+ element.lastElementChild.lastElementChild.previousElementSibling.classList.add("fn__none");+ element.lastElementChild.lastElementChild.classList.add("fn__none");element.lastElementChild.firstElementChild.innerHTML = `<li class="b3-list--empty">${window.siyuan.languages.emptyContent}</li>`;return;}@@ -65,12 +73,12 @@ const renderDoc = (element: HTMLElement, currentPage: number) => {logsHTML += "</ul>";if (index === 0) {if (typeElement.value === "1") {- element.lastElementChild.lastElementChild.innerHTML = renderAssetsPreview(item.items[0].path);+ element.lastElementChild.lastElementChild.previousElementSibling.innerHTML = renderAssetsPreview(item.items[0].path);} else {fetchPost("/api/history/getDocHistoryContent", {historyPath: item.items[0].path}, (contentResponse) => {- element.lastElementChild.lastElementChild.innerHTML = contentResponse.data.content;+ onGet(contentResponse, historyEditor.protyle, [Constants.CB_GET_HISTORY]);});}}@@ -262,7 +270,8 @@ export const openHistory = () => {<ul style="width:200px;overflow: auto;" class="b3-list b3-list--background"><li class="b3-list--empty">${window.siyuan.languages.emptyContent}</li></ul>- <div class="fn__flex-1 history__text" readonly></div>+ <div class="fn__flex-1 history__text"></div>+ <div class="fn__flex-1 history__text"></div></div></div><ul data-type="notebook" style="background-color: var(--b3-theme-background);border-radius: 0 0 4px 4px" class="fn__none b3-list b3-list--background">@@ -310,6 +319,20 @@ export const openHistory = () => {renderDoc(firstPanelElement, 1);});renderDoc(firstPanelElement, 1);+ historyEditor = new Protyle(firstPanelElement.lastElementChild.lastElementChild as HTMLElement, {+ blockId: "",+ action: [Constants.CB_GET_HISTORY],+ render: {+ background: false,+ title: false,+ gutter: false,+ scroll: false,+ breadcrumb: false,+ breadcrumbDocName: false,+ breadcrumbContext: false,+ },+ typewriterMode: false,+ });const repoElement = dialog.element.querySelector('#historyContainer [data-type="repo"]');const selectElement = repoElement.querySelector(".b3-select") as HTMLSelectElement;selectElement.addEventListener("change", () => {@@ -376,12 +399,12 @@ export const openHistory = () => {} else if (target.classList.contains("b3-list-item") && (type === "assets" || type === "doc")) {const dataPath = target.getAttribute("data-path");if (type === "assets") {- firstPanelElement.lastElementChild.lastElementChild.innerHTML = renderAssetsPreview(dataPath);+ firstPanelElement.lastElementChild.lastElementChild.previousElementSibling.innerHTML = renderAssetsPreview(dataPath);} else if (type === "doc") {fetchPost("/api/history/getDocHistoryContent", {historyPath: dataPath}, (response) => {- firstPanelElement.lastElementChild.lastElementChild.innerHTML = response.data.content;+ onGet(response, historyEditor.protyle, [Constants.CB_GET_HISTORY]);});}let currentItem = hasClosestByClassName(target, "b3-list") as HTMLElement;