An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:recycle:
Vanessa6806392b413e
diff --git a/app/src/boot/globalShortcut.ts b/app/src/boot/globalShortcut.tsindex b82bc7fc9d..84180092f7 100644--- a/app/src/boot/globalShortcut.ts+++ b/app/src/boot/globalShortcut.ts@@ -1071,7 +1071,7 @@ const editKeydown = (app: App, event: KeyboardEvent) => {selectElements = [nodeElement];}movePathTo((toPath) => {- hintMoveBlock(toPath[0], selectElements, protyle, app);+ hintMoveBlock(toPath[0], selectElements, protyle);});}event.preventDefault();@@ -1084,7 +1084,7 @@ const editKeydown = (app: App, event: KeyboardEvent) => {return false;}if (matchHotKey(window.siyuan.config.keymap.editor.general.refresh.custom, event)) {- reloadProtyle(protyle, app, true);+ reloadProtyle(protyle, true);event.preventDefault();return true;}@@ -1106,19 +1106,19 @@ const editKeydown = (app: App, event: KeyboardEvent) => {id: protyle.block.parentID,size: window.siyuan.config.editor.dynamicLoadBlocks,}, getResponse => {- onGet({data: getResponse, protyle, app});+ onGet({data: getResponse, protyle});});event.preventDefault();return true;}// 没有光标时,无法撤销 https://ld246.com/article/1624021111567if (matchHotKey(window.siyuan.config.keymap.editor.general.undo.custom, event)) {- protyle.undo.undo(app, protyle);+ protyle.undo.undo(protyle);event.preventDefault();return true;}if (matchHotKey(window.siyuan.config.keymap.editor.general.redo.custom, event)) {- protyle.undo.redo(app, protyle);+ protyle.undo.redo(protyle);event.preventDefault();return true;}diff --git a/app/src/card/openCard.ts b/app/src/card/openCard.tsindex a012c3b0f6..889eaf96c4 100644--- a/app/src/card/openCard.ts+++ b/app/src/card/openCard.ts@@ -147,7 +147,6 @@ export const bindCardEvent = (options: {data: response,protyle: editor.protyle,action: [Constants.CB_GET_ALL, Constants.CB_GET_HTML],- app: options.app});});}@@ -168,7 +167,6 @@ export const bindCardEvent = (options: {options.blocks = treeCards.data.cards;if (options.blocks.length > 0) {nextCard({- app: options.app,countElement,editor,actionElements,@@ -342,7 +340,6 @@ export const bindCardEvent = (options: {if (index > 0) {index--;nextCard({- app: options.app,countElement,editor,actionElements,@@ -386,7 +383,6 @@ export const bindCardEvent = (options: {}} else {nextCard({- app: options.app,countElement,editor,actionElements,@@ -398,7 +394,6 @@ export const bindCardEvent = (options: {return;}nextCard({- app: options.app,countElement,editor,actionElements,@@ -458,8 +453,11 @@ export const openCardByData = (app: App, cardsData: {};const nextCard = (options: {- app: App,- countElement: Element, editor: Protyle, actionElements: NodeListOf<Element>, index: number, blocks: ICard[]+ countElement: Element,+ editor: Protyle,+ actionElements: NodeListOf<Element>,+ index: number,+ blocks: ICard[]}) => {options.editor.protyle.element.classList.add("card__block--hide");if (window.siyuan.config.flashcard.superBlock) {@@ -491,7 +489,6 @@ const nextCard = (options: {data: response,protyle: options.editor.protyle,action: [Constants.CB_GET_ALL, Constants.CB_GET_HTML],- app: options.app});});};diff --git a/app/src/card/viewCards.ts b/app/src/card/viewCards.tsindex 60371a94a4..f2e503f66e 100644--- a/app/src/card/viewCards.ts+++ b/app/src/card/viewCards.ts@@ -68,7 +68,7 @@ export const viewCards = (app: App, deckID: string, title: string, deckType: "Trif (window.siyuan.config.editor.readOnly) {disabledProtyle(edit.protyle);}- getArticle(app, edit, dialog.element.querySelector(".b3-list-item--focus")?.getAttribute("data-id"));+ getArticle(edit, dialog.element.querySelector(".b3-list-item--focus")?.getAttribute("data-id"));}const previousElement = dialog.element.querySelector('[data-type="previous"]');const nextElement = dialog.element.querySelector('[data-type="next"]');@@ -93,7 +93,7 @@ export const viewCards = (app: App, deckID: string, title: string, deckType: "Trif (currentRect.top < parentRect.top || currentRect.bottom > parentRect.bottom) {currentElement.scrollIntoView(currentRect.top < parentRect.top);}- getArticle(app, edit, currentElement.getAttribute("data-id"));+ getArticle(edit, currentElement.getAttribute("data-id"));currentElement.classList.add("b3-list-item--focus");}event.stopPropagation();@@ -125,7 +125,7 @@ export const viewCards = (app: App, deckID: string, title: string, deckType: "TrnextElement.nextElementSibling.nextElementSibling.textContent = `${pageIndex}/${cardsResponse.data.pageCount || 1}`;listElement.innerHTML = renderViewItem(cardsResponse.data.blocks, title, deckType);listElement.scrollTop = 0;- getArticle(app, edit, dialog.element.querySelector(".b3-list-item--focus")?.getAttribute("data-id"));+ getArticle(edit, dialog.element.querySelector(".b3-list-item--focus")?.getAttribute("data-id"));});event.stopPropagation();event.preventDefault();@@ -145,13 +145,13 @@ export const viewCards = (app: App, deckID: string, title: string, deckType: "TrnextElement.nextElementSibling.nextElementSibling.textContent = `${pageIndex}/${cardsResponse.data.pageCount || 1}`;listElement.innerHTML = renderViewItem(cardsResponse.data.blocks, title, deckType);listElement.scrollTop = 0;- getArticle(app, edit, dialog.element.querySelector(".b3-list-item--focus")?.getAttribute("data-id"));+ getArticle(edit, dialog.element.querySelector(".b3-list-item--focus")?.getAttribute("data-id"));});event.stopPropagation();event.preventDefault();break;} else if (type === "card-item") {- getArticle(app, edit, target.getAttribute("data-id"));+ getArticle(edit, target.getAttribute("data-id"));listElement.querySelector(".b3-list-item--focus")?.classList.remove("b3-list-item--focus");target.classList.add("b3-list-item--focus");event.stopPropagation();@@ -171,10 +171,10 @@ export const viewCards = (app: App, deckID: string, title: string, deckType: "Tr}if (!nextElment) {- getArticle(app, edit, "");+ getArticle(edit, "");listElement.innerHTML = `<div class="b3-list--empty">${window.siyuan.languages.emptyContent}</div>`;} else {- getArticle(app, edit, nextElment.getAttribute("data-id"));+ getArticle(edit, nextElment.getAttribute("data-id"));listElement.querySelector(".b3-list-item--focus")?.classList.remove("b3-list-item--focus");nextElment.classList.add("b3-list-item--focus");target.parentElement.remove();@@ -240,7 +240,7 @@ ${unicode2Emoji(item.ial.icon, false, "b3-list-item__graphic", true)}};-const getArticle = (app: App, edit: Protyle, id: string) => {+const getArticle = (edit: Protyle, id: string) => {if (!id) {edit.protyle.element.classList.add("fn__none");edit.protyle.element.nextElementSibling.classList.remove("fn__none");@@ -256,7 +256,7 @@ const getArticle = (app: App, edit: Protyle, id: string) => {size: Constants.SIZE_GET_MAX,}, getResponse => {onGet({- data: getResponse, protyle: edit.protyle, action: [Constants.CB_GET_ALL, Constants.CB_GET_HTML], app+ data: getResponse, protyle: edit.protyle, action: [Constants.CB_GET_ALL, Constants.CB_GET_HTML]});});};diff --git a/app/src/config/editor.ts b/app/src/config/editor.tsindex cab6a27a2d..b39426a6c6 100644--- a/app/src/config/editor.ts+++ b/app/src/config/editor.ts@@ -5,7 +5,6 @@ import {confirmDialog} from "../dialog/confirmDialog";import {setPadding} from "../protyle/ui/initUI";import {reloadProtyle} from "../protyle/util/reload";import {updateHotkeyTip} from "../protyle/util/compatibility";-import {App} from "../index";export const editor = {element: undefined as Element,@@ -258,7 +257,7 @@ export const editor = {</div></label>`;},- bindEvent: (app: App) => {+ bindEvent: () => {const fontFamilyElement = editor.element.querySelector("#fontFamily") as HTMLSelectElement;if (fontFamilyElement.tagName === "SELECT") {let fontFamilyHTML = `<option value="">${window.siyuan.languages.default}</option>`;@@ -318,7 +317,7 @@ export const editor = {fontFamily: fontFamilyElement.value,emoji: window.siyuan.config.editor.emoji}, response => {- editor.onSetEditor(response.data, app);+ editor.onSetEditor(response.data);});};editor.element.querySelectorAll("input.b3-switch, select.b3-select, input.b3-slider").forEach((item) => {@@ -338,13 +337,13 @@ export const editor = {});});},- onSetEditor: (editorData: IEditor, app: App) => {+ onSetEditor: (editorData: IEditor) => {if (editorData.readOnly !== window.siyuan.config.editor.readOnly) {editor.setReadonly(editorData.readOnly);}window.siyuan.config.editor = editorData;getAllModels().editor.forEach((item) => {- reloadProtyle(item.editor.protyle, app, false);+ reloadProtyle(item.editor.protyle, false);setPadding(item.editor.protyle);if (window.siyuan.config.editor.fullWidth) {item.editor.protyle.contentElement.setAttribute("data-fullwidth", "true");diff --git a/app/src/config/index.ts b/app/src/config/index.tsindex 1fafd5dbfe..91e68ac52e 100644--- a/app/src/config/index.ts+++ b/app/src/config/index.ts@@ -146,6 +146,6 @@ export const openSetting = (app: App) => {});});editor.element = dialog.element.querySelector('.config__tab-container[data-name="editor"]');- editor.bindEvent(app);+ editor.bindEvent();return dialog;};diff --git a/app/src/config/keymap.ts b/app/src/config/keymap.tsindex cd492e5f02..196b99515a 100644--- a/app/src/config/keymap.ts+++ b/app/src/config/keymap.ts@@ -169,7 +169,7 @@ export const keymap = {const data: IKeymap = JSON.parse(JSON.stringify(Constants.SIYUAN_KEYMAP));keymap.element.querySelectorAll("label.b3-list-item input").forEach((item) => {const keys = item.getAttribute("data-key").split(Constants.ZWSP);- const newHotkey = item.getAttribute("data-value")+ const newHotkey = item.getAttribute("data-value");if (keys[0] === "plugin") {window.siyuan.config.keymap.plugin[keys[1]][keys[2]].custom = newHotkey;data.plugin = window.siyuan.config.keymap.plugin;@@ -179,9 +179,9 @@ export const keymap = {if (command.langKey === keys[2]) {command.customHotkey = newHotkey;}- })+ });}- })+ });} else if (keys[0] === "general") {data[keys[0]][keys[1]].custom = newHotkey;} else if (keys[0] === "editor" && (keys[1] === "general" || keys[1] === "insert" || keys[1] === "heading" || keys[1] === "list" || keys[1] === "table")) {diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.tsindex 4a91f11d3f..5a6b49b3d8 100644--- a/app/src/dialog/processSystem.ts+++ b/app/src/dialog/processSystem.ts@@ -37,7 +37,7 @@ export const reloadSync = (app: App, data: { upsertRootIDs: string[], removeRootif (data.removeRootIDs.includes(window.siyuan.mobile.popEditor.protyle.block.rootID)) {hideElements(["dialog"]);} else {- reloadProtyle(window.siyuan.mobile.popEditor.protyle, app, false);+ reloadProtyle(window.siyuan.mobile.popEditor.protyle, false);window.siyuan.mobile.popEditor.protyle.breadcrumb.render(window.siyuan.mobile.popEditor.protyle, true);}}@@ -45,7 +45,7 @@ export const reloadSync = (app: App, data: { upsertRootIDs: string[], removeRootif (data.removeRootIDs.includes(window.siyuan.mobile.editor.protyle.block.rootID)) {setEmpty(app);} else {- reloadProtyle(window.siyuan.mobile.editor.protyle, app, false);+ reloadProtyle(window.siyuan.mobile.editor.protyle, false);fetchPost("/api/block/getDocInfo", {id: window.siyuan.mobile.editor.protyle.block.rootID}, (response) => {@@ -60,7 +60,7 @@ export const reloadSync = (app: App, data: { upsertRootIDs: string[], removeRootconst allModels = getAllModels();allModels.editor.forEach(item => {if (data.upsertRootIDs.includes(item.editor.protyle.block.rootID)) {- reloadProtyle(item.editor.protyle, app, false);+ reloadProtyle(item.editor.protyle, false);updateTitle(item.editor.protyle.block.rootID, item.parent);} else if (data.removeRootIDs.includes(item.editor.protyle.block.rootID)) {item.parent.parent.removeTab(item.parent.id, false, false, false);diff --git a/app/src/editor/util.ts b/app/src/editor/util.tsindex 3d1516663e..b661c9e313 100644--- a/app/src/editor/util.ts+++ b/app/src/editor/util.ts@@ -277,13 +277,13 @@ export const openFile = (options: IOpenFileOptions) => {}}});- createdTab = newTab(options)+ createdTab = newTab(options);wnd.addTab(createdTab);if (unUpdateTab && options.removeCurrentTab) {wnd.removeTab(unUpdateTab.id, false, true, false);}} else {- createdTab = newTab(options)+ createdTab = newTab(options);wnd.addTab(createdTab);}wnd.showHeading();@@ -343,7 +343,7 @@ const switchEditor = (editor: Editor, options: IOpenFileOptions, allModels: IModreturn true;}if (options.zoomIn) {- zoomOut({app: options.app, protyle: editor.editor.protyle, id: options.id});+ zoomOut({protyle: editor.editor.protyle, id: options.id});return true;}let nodeElement = editor.editor.protyle.wysiwyg.element.querySelector(`[data-node-id="${options.id}"]`);@@ -353,7 +353,7 @@ const switchEditor = (editor: Editor, options: IOpenFileOptions, allModels: IModmode: (options.action && options.action.includes(Constants.CB_GET_CONTEXT)) ? 3 : 0,size: window.siyuan.config.editor.dynamicLoadBlocks,}, getResponse => {- onGet({data: getResponse, protyle: editor.editor.protyle, action: options.action, app: options.app});+ onGet({data: getResponse, protyle: editor.editor.protyle, action: options.action});// 大纲点击折叠标题下的内容时,需更新反链面板updateBacklinkGraph(allModels, editor.editor.protyle);});diff --git a/app/src/history/diff.ts b/app/src/history/diff.tsindex 6030c06aa8..abaea45bf8 100644--- a/app/src/history/diff.ts+++ b/app/src/history/diff.ts@@ -78,7 +78,6 @@ const renderCompare = (app: App, element: HTMLElement) => {data: response,protyle: leftEditor.protyle,action: [Constants.CB_GET_HISTORY, Constants.CB_GET_HTML],- app});}textElement.previousElementSibling.textContent = dayjs(response.data.updated).format("YYYY-MM-DD HH:mm");@@ -99,7 +98,6 @@ const renderCompare = (app: App, element: HTMLElement) => {data: response,protyle: rightEditor.protyle,action: [Constants.CB_GET_HISTORY, Constants.CB_GET_HTML],- app});}textElement.previousElementSibling.textContent = dayjs(response.data.updated).format("YYYY-MM-DD HH:mm");diff --git a/app/src/history/history.ts b/app/src/history/history.tsindex f6498ed46c..9a4d2f1eec 100644--- a/app/src/history/history.ts+++ b/app/src/history/history.ts@@ -615,7 +615,6 @@ const bindEvent = (app: App, element: Element, dialog?: Dialog) => {data: response,protyle: historyEditor.protyle,action: [Constants.CB_GET_HISTORY, Constants.CB_GET_HTML],- app});}});diff --git a/app/src/index.ts b/app/src/index.tsindex 503206771f..aad028677d 100644--- a/app/src/index.ts+++ b/app/src/index.ts@@ -181,7 +181,7 @@ export class App {});setNoteBook();initBlockPopover(this);- promiseTransactions(this);+ promiseTransactions();}}diff --git a/app/src/layout/dock/Outline.ts b/app/src/layout/dock/Outline.tsindex 5449fcdd37..539e704c68 100644--- a/app/src/layout/dock/Outline.ts+++ b/app/src/layout/dock/Outline.ts@@ -160,7 +160,6 @@ export class Outline extends Model {data: getResponse,protyle: item.editor.protyle,action: [Constants.CB_GET_FOCUS],- app: options.app});});}diff --git a/app/src/layout/dock/util.ts b/app/src/layout/dock/util.tsindex 8271fb5738..27f26c810c 100644--- a/app/src/layout/dock/util.ts+++ b/app/src/layout/dock/util.ts@@ -4,9 +4,8 @@ import {Graph} from "./Graph";import {Outline} from "./Outline";import {switchWnd} from "../util";import {Backlink} from "./Backlink";-import {App} from "../../index";-export const openBacklink = (app: App, protyle: IProtyle) => {+export const openBacklink = (protyle: IProtyle) => {const backlink = getAllModels().backlink.find(item => {if (item.blockId === protyle.block.id && item.type === "local") {item.parent.parent.removeTab(item.parent.id);@@ -22,7 +21,7 @@ export const openBacklink = (app: App, protyle: IProtyle) => {title: protyle.title.editElement.textContent || "Untitled",callback(tab: Tab) {tab.addModel(new Backlink({- app,+ app: protyle.app,type: "local",tab,// 通过搜索打开的包含上下文,但不是缩放,因此需要传 rootID https://ld246.com/article/1666786639708@@ -34,7 +33,7 @@ export const openBacklink = (app: App, protyle: IProtyle) => {newWnd.addTab(tab);};-export const openGraph = (app: App, protyle: IProtyle) => {+export const openGraph = (protyle: IProtyle) => {const graph = getAllModels().graph.find(item => {if (item.blockId === protyle.block.id && item.type === "local") {item.parent.parent.removeTab(item.parent.id);@@ -50,7 +49,7 @@ export const openGraph = (app: App, protyle: IProtyle) => {title: protyle.title.editElement.textContent || "Untitled",callback(tab: Tab) {tab.addModel(new Graph({- app,+ app: protyle.app,type: "local",tab,blockId: protyle.block.id,@@ -61,7 +60,7 @@ export const openGraph = (app: App, protyle: IProtyle) => {wnd.addTab(tab);};-export const openOutline = (app: App,protyle: IProtyle) => {+export const openOutline = (protyle: IProtyle) => {const outlinePanel = getAllModels().outline.find(item => {if (item.blockId === protyle.block.rootID && item.type === "local") {item.parent.parent.removeTab(item.parent.id);@@ -77,7 +76,7 @@ export const openOutline = (app: App,protyle: IProtyle) => {title: protyle.title.editElement.textContent || "Untitled",callback(tab: Tab) {tab.addModel(new Outline({- app,+ app: protyle.app,type: "local",tab,blockId: protyle.block.rootID,diff --git a/app/src/layout/topBar.ts b/app/src/layout/topBar.tsindex 74f72c31c7..c0684bbd5b 100644--- a/app/src/layout/topBar.ts+++ b/app/src/layout/topBar.ts@@ -85,7 +85,7 @@ export const initBar = (app: App) => {window.siyuan.menus.menu.element.setAttribute("data-name", "barmore");(target.getAttribute("data-hideids") || "").split(",").forEach((itemId) => {const hideElement = toolbarElement.querySelector("#" + itemId);- const useElement = hideElement.querySelector("use")+ const useElement = hideElement.querySelector("use");const menuOptions: IMenu = {label: itemId === "toolbarVIP" ? window.siyuan.languages.account : hideElement.getAttribute("aria-label"),icon: itemId === "toolbarVIP" ? "iconAccount" : (useElement ? useElement.getAttribute("xlink:href").substring(1) : undefined),@@ -98,7 +98,7 @@ export const initBar = (app: App) => {}};if (!useElement) {- const svgElement = hideElement.querySelector("svg")+ const svgElement = hideElement.querySelector("svg");svgElement.classList.add("b3-menu__icon");menuOptions.iconHTML = svgElement.outerHTML;}diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.tsindex 9341fec8ad..57bbd81eb5 100644--- a/app/src/menus/protyle.ts+++ b/app/src/menus/protyle.ts@@ -42,9 +42,8 @@ import {removeLink} from "../protyle/toolbar/Link";import {alignImgCenter, alignImgLeft} from "../protyle/wysiwyg/commonHotkey";import {renameTag} from "../util/noRelyPCFunction";import {hideElements} from "../protyle/ui/hideElements";-import {App} from "../index";-export const refMenu = (app: App, protyle: IProtyle, element: HTMLElement) => {+export const refMenu = (protyle: IProtyle, element: HTMLElement) => {const nodeElement = hasClosestBlock(element);if (!nodeElement) {return;@@ -89,7 +88,7 @@ export const refMenu = (app: App, protyle: IProtyle, element: HTMLElement) => {click() {fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => {openFileById({- app,+ app: protyle.app,id: refBlockId,action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],zoomIn: foldResponse.data@@ -103,7 +102,7 @@ export const refMenu = (app: App, protyle: IProtyle, element: HTMLElement) => {click() {fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => {openFileById({- app,+ app: protyle.app,id: refBlockId,action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT],keepCursor: true,@@ -119,7 +118,7 @@ export const refMenu = (app: App, protyle: IProtyle, element: HTMLElement) => {click() {fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => {openFileById({- app,+ app: protyle.app,id: refBlockId,position: "right",action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],@@ -135,7 +134,7 @@ export const refMenu = (app: App, protyle: IProtyle, element: HTMLElement) => {click() {fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => {openFileById({- app,+ app: protyle.app,id: refBlockId,position: "bottom",action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],@@ -435,7 +434,6 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {};export const zoomOut = (options: {- app: App,protyle: IProtyle,id: string,focusId?: string,@@ -488,14 +486,12 @@ export const zoomOut = (options: {data: getResponse,protyle: options.protyle,action: options.id === options.protyle.block.rootID ? [Constants.CB_GET_FOCUS, Constants.CB_GET_HTML] : [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS, Constants.CB_GET_HTML],- app: options.app});} else {onGet({data: getResponse,protyle: options.protyle,action: options.id === options.protyle.block.rootID ? [Constants.CB_GET_FOCUS, Constants.CB_GET_HTML, Constants.CB_GET_UNUNDO] : [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS, Constants.CB_GET_UNUNDO, Constants.CB_GET_HTML],- app: options.app});}// https://github.com/siyuan-note/siyuan/issues/4874@@ -514,7 +510,6 @@ export const zoomOut = (options: {data: getFocusResponse,protyle: options.protyle,action: options.isPushBack ? [Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS, Constants.CB_GET_UNUNDO],- app: options.app});});return;@@ -537,7 +532,7 @@ export const zoomOut = (options: {});};-export const imgMenu = (app: App, protyle: IProtyle, range: Range, assetElement: HTMLElement, position: {+export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLElement, position: {clientX: number,clientY: number}) => {@@ -739,7 +734,7 @@ export const imgMenu = (app: App, protyle: IProtyle, range: Range, assetElement:const imgSrc = imgElement.getAttribute("src");if (imgSrc) {window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);- openMenu(app, imgSrc, false, false);+ openMenu(protyle.app, imgSrc, false, false);}window.siyuan.menus.menu.popup({x: position.clientX, y: position.clientY});const textElements = window.siyuan.menus.menu.element.querySelectorAll("textarea");@@ -758,7 +753,7 @@ export const imgMenu = (app: App, protyle: IProtyle, range: Range, assetElement:};};-export const linkMenu = (app: App, protyle: IProtyle, linkElement: HTMLElement, focusText = false) => {+export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText = false) => {window.siyuan.menus.menu.remove();const nodeElement = hasClosestBlock(linkElement);if (!nodeElement) {@@ -851,7 +846,7 @@ export const linkMenu = (app: App, protyle: IProtyle, linkElement: HTMLElement,}}).element);if (linkAddress) {- openMenu(app, linkAddress, false, true);+ openMenu(protyle.app, linkAddress, false, true);}if (linkAddress?.startsWith("siyuan://blocks/")) {window.siyuan.menus.menu.append(new MenuItem({@@ -934,7 +929,7 @@ export const linkMenu = (app: App, protyle: IProtyle, linkElement: HTMLElement,};};-export const tagMenu = (app: App, protyle: IProtyle, tagElement: HTMLElement) => {+export const tagMenu = (protyle: IProtyle, tagElement: HTMLElement) => {window.siyuan.menus.menu.remove();const nodeElement = hasClosestBlock(tagElement);if (!nodeElement) {@@ -990,7 +985,7 @@ export const tagMenu = (app: App, protyle: IProtyle, tagElement: HTMLElement) =>accelerator: "Click",icon: "iconSearch",click() {- openGlobalSearch(app, `#${tagElement.textContent}#`, false);+ openGlobalSearch(protyle.app, `#${tagElement.textContent}#`, false);}}).element);/// #endif@@ -1054,7 +1049,7 @@ const genImageWidthMenu = (label: string, assetElement: HTMLElement, imgElement:};};-export const iframeMenu = (app: App, protyle: IProtyle, nodeElement: Element) => {+export const iframeMenu = (protyle: IProtyle, nodeElement: Element) => {const id = nodeElement.getAttribute("data-node-id");const iframeElement = nodeElement.querySelector("iframe");let html = nodeElement.outerHTML;@@ -1113,12 +1108,12 @@ export const iframeMenu = (app: App, protyle: IProtyle, nodeElement: Element) =>subMenus.push({type: "separator"});- return subMenus.concat(openMenu(app, iframeSrc, true, false) as IMenu[]);+ return subMenus.concat(openMenu(protyle.app, iframeSrc, true, false) as IMenu[]);}return subMenus;};-export const videoMenu = (app: App, protyle: IProtyle, nodeElement: Element, type: string) => {+export const videoMenu = (protyle: IProtyle, nodeElement: Element, type: string) => {const id = nodeElement.getAttribute("data-node-id");const videoElement = nodeElement.querySelector(type === "NodeVideo" ? "video" : "audio");let html = nodeElement.outerHTML;@@ -1150,7 +1145,7 @@ export const videoMenu = (app: App, protyle: IProtyle, nodeElement: Element, typ/// #endifconst VideoSrc = videoElement.getAttribute("src");if (VideoSrc) {- return subMenus.concat(openMenu(app, VideoSrc, true, false) as IMenu[]);+ return subMenus.concat(openMenu(protyle.app, VideoSrc, true, false) as IMenu[]);}return subMenus;};diff --git a/app/src/mobile/editor.ts b/app/src/mobile/editor.tsindex d263403c11..572c882a44 100644--- a/app/src/mobile/editor.ts+++ b/app/src/mobile/editor.ts@@ -58,7 +58,7 @@ export const openMobileFileById = (app: App, id: string, action = [Constants.CB_size: action.includes(Constants.CB_GET_ALL) ? Constants.SIZE_GET_MAX : window.siyuan.config.editor.dynamicLoadBlocks,mode: action.includes(Constants.CB_GET_CONTEXT) ? 3 : 0,}, getResponse => {- onGet({data: getResponse, protyle: window.siyuan.mobile.editor.protyle, action, app});+ onGet({data: getResponse, protyle: window.siyuan.mobile.editor.protyle, action});window.siyuan.mobile.editor.protyle.breadcrumb?.render(window.siyuan.mobile.editor.protyle);});window.siyuan.mobile.editor.protyle.undo.clear();diff --git a/app/src/mobile/index.ts b/app/src/mobile/index.tsindex 216b3658ff..13db8ce653 100644--- a/app/src/mobile/index.ts+++ b/app/src/mobile/index.ts@@ -93,16 +93,16 @@ class App {document.addEventListener("touchstart", handleTouchStart, false);document.addEventListener("touchmove", handleTouchMove, false);document.addEventListener("touchend", (event) => {- handleTouchEnd(this, event);+ handleTouchEnd(event);}, false);});- promiseTransactions(this);+ promiseTransactions();}}const siyuanApp = new App();-window.goBack = goBack.apply(siyuanApp);+window.goBack = goBack;window.showKeyboardToolbar = (height) => {document.getElementById("keyboardToolbar").setAttribute("data-keyboardheight", (height ? height : window.innerHeight / 2 - 42).toString());showKeyboardToolbar();diff --git a/app/src/mobile/menu/index.ts b/app/src/mobile/menu/index.tsindex abbc318b0d..2fab5b1d5f 100644--- a/app/src/mobile/menu/index.ts+++ b/app/src/mobile/menu/index.ts@@ -144,7 +144,7 @@ export const initRightMenu = (app: App) => {event.stopPropagation();break;} else if (target.id === "menuEditor") {- initEditor(app);+ initEditor();event.preventDefault();event.stopPropagation();break;diff --git a/app/src/mobile/menu/search.ts b/app/src/mobile/menu/search.tsindex cf5e4b6f7c..1d947b1d0f 100644--- a/app/src/mobile/menu/search.ts+++ b/app/src/mobile/menu/search.ts@@ -16,7 +16,7 @@ import {reloadProtyle} from "../../protyle/util/reload";import {activeBlur, hideKeyboardToolbar} from "../util/keyboardToolbar";import {App} from "../../index";-const replace = (app: App,element: Element, config: ISearchOption, isAll: boolean) => {+const replace = (element: Element, config: ISearchOption, isAll: boolean) => {if (config.method === 1 || config.method === 2) {showMessage(window.siyuan.languages._kernel[132]);return;@@ -60,7 +60,7 @@ const replace = (app: App,element: Element, config: ISearchOption, isAll: booleaif (ids.length > 1) {return;}- reloadProtyle(window.siyuan.mobile.editor.protyle, app, false);+ reloadProtyle(window.siyuan.mobile.editor.protyle, false);if (currentLiElement.nextElementSibling) {currentLiElement.nextElementSibling.classList.add("b3-list-item--focus");@@ -478,12 +478,12 @@ const initSearchEvent = (app: App, element: Element, config: ISearchOption) => {event.preventDefault();break;} else if (type === "replace-all") {- replace(app, element, config, true);+ replace(element, config, true);event.stopPropagation();event.preventDefault();break;} else if (type === "replace") {- replace(app, element, config, false);+ replace(element, config, false);event.stopPropagation();event.preventDefault();break;diff --git a/app/src/mobile/settings/editor.ts b/app/src/mobile/settings/editor.tsindex 0cb55853fe..89fa9968d1 100644--- a/app/src/mobile/settings/editor.ts+++ b/app/src/mobile/settings/editor.ts@@ -3,9 +3,8 @@ import {fetchPost} from "../../util/fetch";import {reloadProtyle} from "../../protyle/util/reload";import {setInlineStyle} from "../../util/assets";import {confirmDialog} from "../../dialog/confirmDialog";-import {App} from "../../index";-const setEditor = (app: App, modelMainElement: Element) => {+const setEditor = (modelMainElement: Element) => {let dynamicLoadBlocks = parseInt((modelMainElement.querySelector("#dynamicLoadBlocks") as HTMLInputElement).value);if (48 > dynamicLoadBlocks) {dynamicLoadBlocks = 48;@@ -41,12 +40,12 @@ const setEditor = (app: App, modelMainElement: Element) => {window.siyuan.config.editor.historyRetentionDays = parseInt((modelMainElement.querySelector("#historyRetentionDays") as HTMLInputElement).value);fetchPost("/api/setting/setEditor", window.siyuan.config.editor, response => {window.siyuan.config.editor = response.data;- reloadProtyle(window.siyuan.mobile.editor.protyle, app, false);+ reloadProtyle(window.siyuan.mobile.editor.protyle, false);setInlineStyle();});};-export const initEditor = (app: App) => {+export const initEditor = () => {openModel({title: window.siyuan.languages.editor,icon: "iconEdit",@@ -231,12 +230,12 @@ export const initEditor = (app: App) => {modelMainElement.querySelectorAll("input.b3-switch, select.b3-select, input.b3-slider").forEach((item) => {item.addEventListener("change", () => {- setEditor(app, modelMainElement);+ setEditor(modelMainElement);});});modelMainElement.querySelectorAll("textarea.b3-text-field, input.b3-text-field, input.b3-slider").forEach((item) => {item.addEventListener("blur", () => {- setEditor(app, modelMainElement);+ setEditor(modelMainElement);});});modelMainElement.querySelectorAll("input.b3-slider").forEach((item) => {diff --git a/app/src/mobile/util/MobileBackFoward.ts b/app/src/mobile/util/MobileBackFoward.tsindex 921d7918d4..ce57fa1b9e 100644--- a/app/src/mobile/util/MobileBackFoward.ts+++ b/app/src/mobile/util/MobileBackFoward.ts@@ -11,11 +11,10 @@ import {setStorageVal} from "../../protyle/util/compatibility";import {closePanel} from "./closePanel";import {showMessage} from "../../dialog/message";import {getCurrentEditor} from "../editor";-import {App} from "../../index";const forwardStack: IBackStack[] = [];-const focusStack = (backStack: IBackStack, app: App) => {+const focusStack = (backStack: IBackStack) => {const protyle = getCurrentEditor().protyle;window.siyuan.storage[Constants.LOCAL_DOCINFO] = {id: backStack.id,@@ -52,7 +51,6 @@ const focusStack = (backStack: IBackStack, app: App) => {fetchPost("/api/block/checkBlockExist", {id: backStack.id}, existResponse => {if (existResponse.data) {zoomOut({- app,protyle,id: backStack.id,isPushBack: false,@@ -111,29 +109,7 @@ export const pushBack = () => {});};-export const goForward = (app: App) => {- if (window.siyuan.menus.menu.element.classList.contains("b3-menu--fullscreen") &&- !window.siyuan.menus.menu.element.classList.contains("fn__none")) {- window.siyuan.menus.menu.element.dispatchEvent(new CustomEvent("click", {detail: "back"}));- return;- } else if (document.getElementById("model").style.transform === "translateY(0px)" ||- document.getElementById("menu").style.transform === "translateX(0px)" ||- document.getElementById("sidebar").style.transform === "translateX(0px)") {- closePanel();- return;- }- if (window.JSAndroid && forwardStack.length < 2) {- window.JSAndroid.returnDesktop();- return;- }- if (forwardStack.length < 2) {- return;- }- window.siyuan.backStack.push(forwardStack.pop());- focusStack(forwardStack[forwardStack.length - 1], app);-};--export const goBack = (app: App) => {+export const goBack = () => {const editor = getCurrentEditor();if (window.siyuan.menus.menu.element.classList.contains("b3-menu--fullscreen") &&!window.siyuan.menus.menu.element.classList.contains("fn__none")) {@@ -181,5 +157,5 @@ export const goBack = (app: App) => {}const item = window.siyuan.backStack.pop();forwardStack.push(item);- focusStack(item, app);+ focusStack(item);};diff --git a/app/src/mobile/util/initFramework.ts b/app/src/mobile/util/initFramework.tsindex f0cc14c05e..053aaad5cd 100644--- a/app/src/mobile/util/initFramework.ts+++ b/app/src/mobile/util/initFramework.ts@@ -23,7 +23,7 @@ import {App} from "../../index";export const initFramework = (app: App) => {setInlineStyle();renderSnippet();- initKeyboardToolbar(app);+ initKeyboardToolbar();const sidebarElement = document.getElementById("sidebar");let outline: MobileOutline;let backlink: MobileBacklinks;diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.tsindex e890920975..28e298c764 100644--- a/app/src/mobile/util/keyboardToolbar.ts+++ b/app/src/mobile/util/keyboardToolbar.ts@@ -4,7 +4,6 @@ import {moveToDown, moveToUp} from "../../protyle/wysiwyg/move";import {Constants} from "../../constants";import {focusByRange, getSelectionPosition} from "../../protyle/util/selection";import {getCurrentEditor} from "../editor";-import {App} from "../../index";let renderKeyboardToolbarTimeout: number;let showUtil = false;@@ -328,7 +327,7 @@ export const activeBlur = () => {(document.activeElement as HTMLElement).blur();};-export const initKeyboardToolbar = (app: App) => {+export const initKeyboardToolbar = () => {let preventRender = false;document.addEventListener("selectionchange", () => {if (!preventRender) {@@ -417,10 +416,10 @@ export const initKeyboardToolbar = (app: App) => {return;}if (type === "undo") {- protyle.undo.undo(app, protyle);+ protyle.undo.undo(protyle);return;} else if (type === "redo") {- protyle.undo.redo(app, protyle);+ protyle.undo.redo(protyle);return;}if (getSelection().rangeCount === 0) {@@ -476,7 +475,7 @@ export const initKeyboardToolbar = (app: App) => {}return;} else if (type === "more") {- protyle.breadcrumb.showMenu(app, protyle, {+ protyle.breadcrumb.showMenu(protyle, {x: 0,y: 0});diff --git a/app/src/mobile/util/touch.ts b/app/src/mobile/util/touch.tsindex b35b1deb37..7f51be478c 100644--- a/app/src/mobile/util/touch.ts+++ b/app/src/mobile/util/touch.ts@@ -4,7 +4,6 @@ import {popMenu} from "../menu";import {activeBlur, hideKeyboardToolbar} from "./keyboardToolbar";import {getCurrentEditor} from "../editor";import {linkMenu, refMenu, tagMenu} from "../../menus/protyle";-import {App} from "../../index";let clientX: number;let clientY: number;@@ -24,7 +23,7 @@ const popSide = (render = true) => {}};-export const handleTouchEnd = (app: App, event: TouchEvent) => {+export const handleTouchEnd = (event: TouchEvent) => {const editor = getCurrentEditor();if (editor) {document.querySelectorAll(".protyle-breadcrumb__bar--hide").forEach(item => {@@ -45,13 +44,13 @@ export const handleTouchEnd = (app: App, event: TouchEvent) => {return;}if (types.includes("block-ref")) {- refMenu(app, editor.protyle, target);+ refMenu(editor.protyle, target);} else if (types.includes("file-annotation-ref")) {editor.protyle.toolbar.showFileAnnotationRef(editor.protyle, target);} else if (types.includes("tag")) {- tagMenu(app, editor.protyle, target);+ tagMenu(editor.protyle, target);} else if (types.includes("a")) {- linkMenu(app, editor.protyle, target);+ linkMenu(editor.protyle, target);}return;}diff --git a/app/src/plugin/API.ts b/app/src/plugin/API.tsindex 7bbeb1146e..461b1d5e9c 100644--- a/app/src/plugin/API.ts+++ b/app/src/plugin/API.ts@@ -119,7 +119,7 @@ openTab = (options: {}}if (!options.doc.action) {- options.doc.action = []+ options.doc.action = [];}return openFileById({app: options.app,diff --git a/app/src/plugin/loader.ts b/app/src/plugin/loader.tsindex ca84827e85..1e8690c564 100644--- a/app/src/plugin/loader.ts+++ b/app/src/plugin/loader.ts@@ -148,7 +148,7 @@ export const afterLoadPlugin = (plugin: Plugin) => {/// #if !MOBILEmergePluginHotkey(plugin);plugin.statusBarIcons.forEach(element => {- const statusElement = document.getElementById("status")+ const statusElement = document.getElementById("status");if (element.getAttribute("data-position") === "right") {statusElement.insertAdjacentElement("beforeend", element);} else {diff --git a/app/src/protyle/breadcrumb/action.ts b/app/src/protyle/breadcrumb/action.tsindex dbec1e7e51..218d69c611 100644--- a/app/src/protyle/breadcrumb/action.ts+++ b/app/src/protyle/breadcrumb/action.ts@@ -7,9 +7,8 @@ import {Constants} from "../../constants";import {hideAllElements, hideElements} from "../ui/hideElements";import {hasClosestByClassName} from "../util/hasClosest";import {reloadProtyle} from "../util/reload";-import {App} from "../../index";-export const netImg2LocalAssets = (protyle: IProtyle, app: App) => {+export const netImg2LocalAssets = (protyle: IProtyle) => {if (protyle.element.querySelector(".wysiwygLoading")) {return;}@@ -19,11 +18,11 @@ export const netImg2LocalAssets = (protyle: IProtyle, app: App) => {id: protyle.block.rootID}, () => {/// #if MOBILE- reloadProtyle(protyle, app, false);+ reloadProtyle(protyle, false);/// #elsegetAllModels().editor.forEach(item => {if (item.editor.protyle.block.rootID === protyle.block.rootID) {- reloadProtyle(item.editor.protyle, app, item.editor.protyle.element.isSameNode(protyle.element));+ reloadProtyle(item.editor.protyle, item.editor.protyle.element.isSameNode(protyle.element));}});/// #endifdiff --git a/app/src/protyle/breadcrumb/index.ts b/app/src/protyle/breadcrumb/index.tsindex f983d8a3f5..bb385e9409 100644--- a/app/src/protyle/breadcrumb/index.ts+++ b/app/src/protyle/breadcrumb/index.ts@@ -25,7 +25,6 @@ import {hideElements} from "../ui/hideElements";import {confirmDialog} from "../../dialog/confirmDialog";import {reloadProtyle} from "../util/reload";import {deleteFile} from "../../editor/deleteFile";-import {App} from "../../index";export class Breadcrumb {public element: HTMLElement;@@ -33,7 +32,7 @@ export class Breadcrumb {private id: string;private messageId: string;- constructor(app: App, protyle: IProtyle) {+ constructor(protyle: IProtyle) {const element = document.createElement("div");element.className = "protyle-breadcrumb";const isFocus = protyle.options.action.includes(Constants.CB_GET_ALL) && !isMobile();@@ -51,31 +50,31 @@ export class Breadcrumb {if (protyle.options.render.breadcrumbDocName && window.siyuan.ctrlIsPressed) {/// #if !MOBILEopenFileById({- app,+ app:protyle.app,id,action: id === protyle.block.rootID ? [Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL]});/// #endif} else {- zoomOut({protyle, id, app});+ zoomOut({protyle, id});}event.preventDefault();break;} else if (target.getAttribute("data-menu") === "true") {- this.showMenu(app, protyle, {+ this.showMenu(protyle, {x: event.clientX,y: event.clientY});event.preventDefault();break;} else if (target.getAttribute("data-type") === "exit-focus") {- zoomOut({protyle, id: protyle.block.rootID, focusId: protyle.block.id, app});+ zoomOut({protyle, id: protyle.block.rootID, focusId: protyle.block.id});event.preventDefault();break;} else if (target.getAttribute("data-type") === "context") {event.preventDefault();if (target.classList.contains("block__icon--active")) {- zoomOut({protyle, id: protyle.options.blockId, app});+ zoomOut({protyle, id: protyle.options.blockId});target.classList.remove("block__icon--active");} else {fetchPost("/api/filetree/getDoc", {@@ -83,7 +82,7 @@ export class Breadcrumb {mode: 3,size: window.siyuan.config.editor.dynamicLoadBlocks,}, getResponse => {- onGet({data: getResponse, protyle, action: [Constants.CB_GET_HL], app});+ onGet({data: getResponse, protyle, action: [Constants.CB_GET_HL]});this.toggleExit(true);});target.classList.add("block__icon--active");@@ -158,7 +157,7 @@ export class Breadcrumb {}}- public showMenu(app: App, protyle: IProtyle, position: { x: number, y: number }) {+ public showMenu(protyle: IProtyle, position: { x: number, y: number }) {let id;const cursorNodeElement = hasClosestBlock(getEditorRange(protyle.element).startContainer);if (cursorNodeElement) {@@ -260,7 +259,7 @@ export class Breadcrumb {icon: "iconTransform",accelerator: window.siyuan.config.keymap.editor.general.netImg2LocalAsset.custom,click() {- netImg2LocalAssets(protyle, app);+ netImg2LocalAssets(protyle);}}).element);window.siyuan.menus.menu.append(new MenuItem({@@ -303,7 +302,7 @@ export class Breadcrumb {accelerator: window.siyuan.config.keymap.editor.general.refresh.custom,label: window.siyuan.languages.refresh,click: () => {- reloadProtyle(protyle, app, !isMobile());+ reloadProtyle(protyle, !isMobile());}}).element);window.siyuan.menus.menu.append(new MenuItem({diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.tsindex 3dd7dc7a12..f3f5a12c0e 100644--- a/app/src/protyle/gutter/index.ts+++ b/app/src/protyle/gutter/index.ts@@ -38,16 +38,13 @@ import {isMobile} from "../../util/functions";import {AIActions} from "../../ai/actions";import {activeBlur} from "../../mobile/util/keyboardToolbar";import {hideTooltip} from "../../dialog/tooltip";-import {App} from "../../index";import {appearanceMenu} from "../toolbar/Font";import {setPosition} from "../../util/setPosition";export class Gutter {public element: HTMLElement;- private app: App;- constructor(app: App, protyle: IProtyle) {- this.app = app;+ constructor(protyle: IProtyle) {this.element = document.createElement("div");this.element.className = "protyle-gutters";if (/Mac/.test(navigator.platform) || navigator.platform === "iPhone") {@@ -164,7 +161,7 @@ export class Gutter {return;}if (event.ctrlKey || event.metaKey) {- zoomOut({protyle, id, app});+ zoomOut({protyle, id});} else if (event.altKey) {let foldElement: Element;Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${id}"]`)).find(item => {@@ -648,7 +645,7 @@ export class Gutter {});writeText(protyle.lute.BlockDOM2StdMd(html).trimEnd());protyle.breadcrumb?.hide();- removeBlock(this.app, protyle, selectsElement[0], getEditorRange(selectsElement[0]));+ removeBlock(protyle, selectsElement[0], getEditorRange(selectsElement[0]));} else {focusByRange(getEditorRange(selectsElement[0]));document.execCommand("cut");@@ -661,7 +658,7 @@ export class Gutter {icon: "iconMove",click: () => {movePathTo((toPath) => {- hintMoveBlock(toPath[0], selectsElement, protyle, this.app);+ hintMoveBlock(toPath[0], selectsElement, protyle);});}}).element);@@ -671,7 +668,7 @@ export class Gutter {accelerator: "⌫",click: () => {protyle.breadcrumb?.hide();- removeBlock(this.app, protyle, selectsElement[0], getEditorRange(selectsElement[0]));+ removeBlock(protyle, selectsElement[0], getEditorRange(selectsElement[0]));}}).element);@@ -722,12 +719,12 @@ export class Gutter {}ids.push(item.getAttribute("data-node-id"));});- makeCard(this.app, ids);+ makeCard(protyle.app, ids);}}).element);}const pluginSubMenu = new subMenu();- this.app?.plugins?.forEach((plugin) => {+ protyle.app?.plugins?.forEach((plugin) => {plugin.eventBus.emit("click-blockicon", {protyle,menu: pluginSubMenu,@@ -1078,7 +1075,7 @@ export class Gutter {click: () => {if (isNotEditBlock(nodeElement)) {writeText(protyle.lute.BlockDOM2StdMd(removeEmbed(nodeElement)).trimEnd());- removeBlock(this.app, protyle, nodeElement, getEditorRange(nodeElement));+ removeBlock(protyle, nodeElement, getEditorRange(nodeElement));protyle.breadcrumb?.hide();} else {focusByRange(getEditorRange(nodeElement));@@ -1092,7 +1089,7 @@ export class Gutter {icon: "iconMove",click: () => {movePathTo((toPath) => {- hintMoveBlock(toPath[0], [nodeElement], protyle, this.app);+ hintMoveBlock(toPath[0], [nodeElement], protyle);});}}).element);@@ -1102,7 +1099,7 @@ export class Gutter {accelerator: "⌫",click: () => {protyle.breadcrumb?.hide();- removeBlock(this.app, protyle, nodeElement, getEditorRange(nodeElement));+ removeBlock(protyle, nodeElement, getEditorRange(nodeElement));}}).element);}@@ -1241,7 +1238,7 @@ export class Gutter {type: "submenu",icon: type === "NodeVideo" ? "iconVideo" : "iconRecord",label: window.siyuan.languages.assets,- submenu: videoMenu(this.app, protyle, nodeElement, type)+ submenu: videoMenu(protyle, nodeElement, type)}).element);} else if (type === "NodeIFrame" && !protyle.disabled) {window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);@@ -1250,7 +1247,7 @@ export class Gutter {type: "submenu",icon: "iconLanguage",label: window.siyuan.languages.assets,- submenu: iframeMenu(this.app, protyle, nodeElement)+ submenu: iframeMenu(protyle, nodeElement)}).element);} else if (type === "NodeHTMLBlock" && !protyle.disabled) {window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);@@ -1402,7 +1399,7 @@ export class Gutter {accelerator: `${updateHotkeyTip(window.siyuan.config.keymap.general.enter.custom)}/${updateHotkeyTip("⌘Click")}`,label: window.siyuan.languages.enter,click:()=> {- zoomOut({protyle, id, app: this.app});+ zoomOut({protyle, id});}}).element);window.siyuan.menus.menu.append(new MenuItem({@@ -1413,17 +1410,17 @@ export class Gutter {const ids = protyle.path.split("/");if (ids.length > 2) {/// #if MOBILE- openMobileFileById(this.app, ids[ids.length - 2], [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]);+ openMobileFileById(protyle.app, ids[ids.length - 2], [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]);/// #elseopenFileById({- app: this.app,+ app: protyle.app,id: ids[ids.length - 2],action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]});/// #endif}} else {- zoomOut({protyle, id:protyle.block.parent2ID, focusId:id, app: this.app});+ zoomOut({protyle, id:protyle.block.parent2ID, focusId:id});}}}).element);@@ -1536,14 +1533,14 @@ export class Gutter {label: window.siyuan.languages.addToDeck,icon: "iconRiffCard",click() {- makeCard(this.app, [nodeElement.getAttribute("data-node-id")]);+ makeCard(protyle.app, [nodeElement.getAttribute("data-node-id")]);}}).element);}window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);}const pluginSubMenu = new subMenu();- this.app?.plugins?.forEach((plugin) => {+ protyle.app?.plugins?.forEach((plugin) => {plugin.eventBus.emit("click-blockicon", {protyle,menu: pluginSubMenu,diff --git a/app/src/protyle/header/Background.ts b/app/src/protyle/header/Background.tsindex e8660fef65..df78474ea4 100644--- a/app/src/protyle/header/Background.ts+++ b/app/src/protyle/header/Background.ts@@ -13,7 +13,6 @@ import {popSearch} from "../../mobile/menu/search";import {getEventName} from "../util/compatibility";import {Dialog} from "../../dialog";import {Constants} from "../../constants";-import {App} from "../../index";export class Background {public element: HTMLElement;@@ -23,7 +22,7 @@ export class Background {private tagsElement: HTMLElement;private transparentData = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";- constructor(app: App, protyle: IProtyle) {+ constructor(protyle: IProtyle) {this.element = document.createElement("div");this.element.className = "protyle-background";this.element.innerHTML = `<div class="protyle-background__img">@@ -332,10 +331,10 @@ export class Background {break;} else if (type === "open-search") {/// #if !MOBILE- openGlobalSearch(app, `#${target.textContent}#`, !window.siyuan.ctrlIsPressed);+ openGlobalSearch(protyle.app, `#${target.textContent}#`, !window.siyuan.ctrlIsPressed);/// #elseconst searchOption = window.siyuan.storage[Constants.LOCAL_SEARCHDATA];- popSearch(app, {+ popSearch(protyle.app, {removed: searchOption.removed,sort: searchOption.sort,group: searchOption.group,diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.tsindex 649a099bea..9a55dc2a09 100644--- a/app/src/protyle/header/Title.ts+++ b/app/src/protyle/header/Title.ts@@ -36,16 +36,13 @@ import {makeCard, quickMakeCard} from "../../card/makeCard";import {viewCards} from "../../card/viewCards";import {getNotebookName, pathPosix} from "../../util/pathName";import {commonClick} from "../wysiwyg/commonClick";-import {App} from "../../index";export class Title {public element: HTMLElement;public editElement: HTMLElement;private timeout: number;- private app: App;- constructor(app: App, protyle: IProtyle) {- this.app = app;+ constructor(protyle: IProtyle) {this.element = document.createElement("div");this.element.className = "protyle-title";if (window.siyuan.config.editor.displayBookmarkIcon) {@@ -93,14 +90,14 @@ export class Title {return;}- if (commonHotkey(app, protyle, event)) {+ if (commonHotkey(protyle, event)) {return true;}if (matchHotKey(window.siyuan.config.keymap.general.enterBack.custom, event)) {const ids = protyle.path.split("/");if (ids.length > 2) {openFileById({- app,+ app: protyle.app,id: ids[ids.length - 2],action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]});@@ -268,7 +265,7 @@ export class Title {fetchPost("/api/block/getDocInfo", {id: protyle.block.rootID}, (response) => {- commonClick(app, event, protyle, response.data.ial);+ commonClick(event, protyle, response.data.ial);});});}@@ -334,7 +331,7 @@ export class Title {label: window.siyuan.languages.outline,accelerator: window.siyuan.config.keymap.editor.general.outline.custom,click: () => {- openOutline(this.app, protyle);+ openOutline(protyle);}}).element);window.siyuan.menus.menu.append(new MenuItem({@@ -342,7 +339,7 @@ export class Title {label: window.siyuan.languages.backlinks,accelerator: window.siyuan.config.keymap.editor.general.backlinks.custom,click: () => {- openBacklink(this.app, protyle);+ openBacklink(protyle);}}).element);window.siyuan.menus.menu.append(new MenuItem({@@ -350,7 +347,7 @@ export class Title {label: window.siyuan.languages.graphView,accelerator: window.siyuan.config.keymap.editor.general.graphView.custom,click: () => {- openGraph(this.app, protyle);+ openGraph(protyle);}}).element);window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);@@ -367,7 +364,7 @@ export class Title {accelerator: window.siyuan.config.keymap.editor.general.spaceRepetition.custom,click: () => {fetchPost("/api/riff/getTreeRiffDueCards", {rootID: protyle.block.rootID}, (response) => {- openCardByData(this.app, response.data, "doc", protyle.block.rootID, this.editElement.textContent || "Untitled");+ openCardByData(protyle.app, response.data, "doc", protyle.block.rootID, this.editElement.textContent || "Untitled");});}}, {@@ -377,7 +374,7 @@ export class Title {fetchPost("/api/filetree/getHPathByID", {id: protyle.block.rootID}, (response) => {- viewCards(this.app, protyle.block.rootID, pathPosix().join(getNotebookName(protyle.notebookId), (response.data)), "Tree");+ viewCards(protyle.app, protyle.block.rootID, pathPosix().join(getNotebookName(protyle.notebookId), (response.data)), "Tree");});}}, {@@ -393,7 +390,7 @@ export class Title {iconHTML: Constants.ZWSP,label: window.siyuan.languages.addToDeck,click: () => {- makeCard(this.app, [protyle.block.rootID]);+ makeCard(protyle.app, [protyle.block.rootID]);}});}@@ -411,7 +408,7 @@ export class Title {${window.siyuan.languages.createdAt} ${dayjs(response.data.ial.id.substr(0, 14)).format("YYYY-MM-DD HH:mm:ss")}`}).element);window.siyuan.menus.menu.popup(position);- this.app?.plugins?.forEach((plugin) => {+ protyle.app?.plugins?.forEach((plugin) => {plugin.eventBus.emit("click-editortitleicon", {protyle,menu: window.siyuan.menus.menu,diff --git a/app/src/protyle/hint/extend.ts b/app/src/protyle/hint/extend.tsindex 5e902a620c..1c7f4a637f 100644--- a/app/src/protyle/hint/extend.ts+++ b/app/src/protyle/hint/extend.ts@@ -19,7 +19,6 @@ import {zoomOut} from "../../menus/protyle";import {hideElements} from "../ui/hideElements";import {genAssetHTML} from "../../asset/renderAssets";import {unicode2Emoji} from "../../emoji";-import {App} from "../../index";export const hintSlash = (key: string, protyle: IProtyle) => {const allList: IHintData[] = [{@@ -462,7 +461,7 @@ export const hintRenderAssets = (value: string, protyle: IProtyle) => {hideElements(["util"], protyle);};-export const hintMoveBlock = (pathString: string, sourceElements: Element[], protyle: IProtyle, app: App) => {+export const hintMoveBlock = (pathString: string, sourceElements: Element[], protyle: IProtyle) => {if (pathString === "/") {return;}@@ -513,7 +512,7 @@ export const hintMoveBlock = (pathString: string, sourceElements: Element[], pro});} else if (protyle.block.showAll && parentElement.classList.contains("protyle-wysiwyg") && parentElement.childElementCount === 0) {setTimeout(() => {- zoomOut({app, protyle, id: protyle.block.parent2ID, focusId:protyle.block.parent2ID});+ zoomOut({protyle, id: protyle.block.parent2ID, focusId:protyle.block.parent2ID});}, Constants.TIMEOUT_INPUT * 2 + 100);} else if (parentElement.classList.contains("protyle-wysiwyg") && parentElement.innerHTML === "" &&!hasClosestByClassName(parentElement, "block__edit", true) &&diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.tsindex 19a5bb21fb..e4a9467418 100644--- a/app/src/protyle/hint/index.ts+++ b/app/src/protyle/hint/index.ts@@ -32,20 +32,17 @@ import {processRender} from "../util/processCode";import {AIChat} from "../../ai/chat";import {isMobile} from "../../util/functions";import {isCtrl} from "../util/compatibility";-import {App} from "../../index";export class Hint {public timeId: number;public element: HTMLDivElement;public enableSlash = true;private enableEmoji = true;- private app: App;public enableExtend = false;public splitChar = "";public lastIndex = -1;- constructor(app: App, protyle: IProtyle) {- this.app = app;+ constructor(protyle: IProtyle) {this.element = document.createElement("div");this.element.setAttribute("data-close", "false");// height 402 根据 .emojis max-height+8 得来@@ -580,10 +577,10 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;}, () => {insertHTML(`<span data-type="block-ref" data-id="${newSubDocId}" data-subtype="d">Untitled</span>`, protyle);/// #if MOBILE- openMobileFileById(this.app, newSubDocId, [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT]);+ openMobileFileById(protyle.app, newSubDocId, [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT]);/// #elseopenFileById({- app: this.app,+ app: protyle.app,id: newSubDocId,action: [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT]});@@ -649,7 +646,7 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;});}const rect = imgElement.getBoundingClientRect();- imgMenu(this.app, protyle, range, imgElement, {+ imgMenu(protyle, range, imgElement, {clientX: rect.left,clientY: rect.top});diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.tsindex 63d989fea0..336775c553 100644--- a/app/src/protyle/index.ts+++ b/app/src/protyle/index.ts@@ -34,19 +34,18 @@ export class Protyle {public readonly version: string;public protyle: IProtyle;- private app: App;/*** @param id 要挂载 Protyle 的元素或者元素 ID。* @param options Protyle 参数*/constructor(app: App, id: HTMLElement, options?: IOptions) {- this.app = app;this.version = Constants.SIYUAN_VERSION;const getOptions = new Options(options);const mergedOptions = getOptions.merge();this.protyle = {+ app,transactionTime: new Date().getTime(),id: genUUID(),disabled: false,@@ -56,17 +55,17 @@ export class Protyle {block: {},};- this.protyle.hint = new Hint(app, this.protyle);+ this.protyle.hint = new Hint(this.protyle);if (mergedOptions.render.breadcrumb) {- this.protyle.breadcrumb = new Breadcrumb(app, this.protyle);+ this.protyle.breadcrumb = new Breadcrumb(this.protyle);}/// #if !MOBILEif (mergedOptions.render.title) {- this.protyle.title = new Title(app, this.protyle);+ this.protyle.title = new Title(this.protyle);}/// #endifif (mergedOptions.render.background) {- this.protyle.background = new Background(app, this.protyle);+ this.protyle.background = new Background(this.protyle);}this.protyle.element.innerHTML = "";@@ -75,11 +74,11 @@ export class Protyle {this.protyle.element.appendChild(this.protyle.breadcrumb.element.parentElement);}this.protyle.undo = new Undo();- this.protyle.wysiwyg = new WYSIWYG(app, this.protyle);- this.protyle.toolbar = new Toolbar(app, this.protyle);- this.protyle.scroll = new Scroll(this.protyle, this.app); // 不能使用 render.scroll 来判读是否初始化,除非重构后面用到的相关变量+ this.protyle.wysiwyg = new WYSIWYG(this.protyle);+ this.protyle.toolbar = new Toolbar(this.protyle);+ this.protyle.scroll = new Scroll(this.protyle); // 不能使用 render.scroll 来判读是否初始化,除非重构后面用到的相关变量if (this.protyle.options.render.gutter) {- this.protyle.gutter = new Gutter(app, this.protyle);+ this.protyle.gutter = new Gutter(this.protyle);}if (mergedOptions.upload.url || mergedOptions.upload.handler) {this.protyle.upload = new Upload();@@ -95,7 +94,7 @@ export class Protyle {switch (data.cmd) {case "reload":if (data.data === this.protyle.block.rootID) {- reloadProtyle(this.protyle, app, false);+ reloadProtyle(this.protyle, false);}break;case "addLoading":@@ -105,7 +104,7 @@ export class Protyle {break;case "transactions":data.data[0].doOperations.forEach((item: IOperation) => {- onTransaction(app, this.protyle, item, false);+ onTransaction(this.protyle, item, false);});break;case "readonly":@@ -123,10 +122,10 @@ export class Protyle {id: this.protyle.block.rootID,size: window.siyuan.config.editor.dynamicLoadBlocks,}, getResponse => {- onGet({data: getResponse, protyle: this.protyle, app: this.app});+ onGet({data: getResponse, protyle: this.protyle});});} else {- reloadProtyle(this.protyle, app, false);+ reloadProtyle(this.protyle, false);}/// #if !MOBILEif (data.cmd === "heading2doc") {@@ -224,7 +223,6 @@ export class Protyle {if (scrollObj) {scrollObj.rootId = response.data.rootID;getDocByScroll({- app: this.app,protyle: this.protyle,scrollAttr: scrollObj,mergedOptions,@@ -238,7 +236,6 @@ export class Protyle {});} else {getDocByScroll({- app: this.app,protyle: this.protyle,scrollAttr: options.scrollAttr,mergedOptions,@@ -262,7 +259,7 @@ export class Protyle {mode: (mergedOptions.action && mergedOptions.action.includes(Constants.CB_GET_CONTEXT)) ? 3 : 0,size: mergedOptions.action?.includes(Constants.CB_GET_ALL) ? Constants.SIZE_GET_MAX : window.siyuan.config.editor.dynamicLoadBlocks,}, getResponse => {- onGet({data: getResponse, protyle: this.protyle, app: this.app, action: mergedOptions.action});+ onGet({data: getResponse, protyle: this.protyle, action: mergedOptions.action});this.afterOnGet(mergedOptions);});}@@ -330,9 +327,9 @@ export class Protyle {sanitize: this.protyle.options.preview.markdown.sanitize,});- this.protyle.preview = new Preview(this.app, this.protyle);+ this.protyle.preview = new Preview(this.protyle);- initUI(this.protyle, this.app);+ initUI(this.protyle);}/** 聚焦到编辑器 */diff --git a/app/src/protyle/preview/index.ts b/app/src/protyle/preview/index.tsindex ef3813978b..f51ff8050d 100644--- a/app/src/protyle/preview/index.ts+++ b/app/src/protyle/preview/index.ts@@ -17,14 +17,13 @@ import {fetchPost} from "../../util/fetch";import {processRender} from "../util/processCode";import {highlightRender} from "../markdown/highlightRender";import {speechRender} from "../markdown/speechRender";-import {App} from "../../index";export class Preview {public element: HTMLElement;public previewElement: HTMLElement;private mdTimeoutId: number;- constructor(app: App, protyle: IProtyle) {+ constructor(protyle: IProtyle) {this.element = document.createElement("div");this.element.className = "protyle-preview fn__none";@@ -56,7 +55,7 @@ export class Preview {if (isLocalPath(linkAddress)) {/// #if !MOBILEif (Constants.SIYUAN_ASSETS_EXTS.includes(pathPosix().extname((linkAddress.split("?page")[0])))) {- openAsset(app, linkAddress.split("?page")[0], parseInt(getSearch("page", linkAddress)));+ openAsset(protyle.app, linkAddress.split("?page")[0], parseInt(getSearch("page", linkAddress)));} else {/// #if !BROWSERopenBy(linkAddress, "folder");diff --git a/app/src/protyle/scroll/event.ts b/app/src/protyle/scroll/event.tsindex 163bc2a20d..4fb3e5cfb0 100644--- a/app/src/protyle/scroll/event.ts+++ b/app/src/protyle/scroll/event.ts@@ -4,10 +4,9 @@ import {fetchPost} from "../../util/fetch";import {onGet} from "../util/onGet";import {isMobile} from "../../util/functions";import {hasClosestBlock, hasClosestByClassName} from "../util/hasClosest";-import {App} from "../../index";let getIndexTimeout: number;-export const scrollEvent = (app: App, protyle: IProtyle, element: HTMLElement) => {+export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {let elementRect = element.getBoundingClientRect();element.addEventListener("scroll", () => {if (!protyle.toolbar.element.classList.contains("fn__none")) {@@ -75,7 +74,6 @@ export const scrollEvent = (app: App, protyle: IProtyle, element: HTMLElement) =data: getResponse,protyle,action: [Constants.CB_GET_BEFORE, Constants.CB_GET_UNCHANGEID],- app});});}@@ -92,7 +90,6 @@ export const scrollEvent = (app: App, protyle: IProtyle, element: HTMLElement) =data: getResponse,protyle,action: [Constants.CB_GET_APPEND, Constants.CB_GET_UNCHANGEID],- app});});}diff --git a/app/src/protyle/scroll/index.ts b/app/src/protyle/scroll/index.tsindex 87f7a77a29..5714b62798 100644--- a/app/src/protyle/scroll/index.ts+++ b/app/src/protyle/scroll/index.ts@@ -5,7 +5,6 @@ import {updateHotkeyTip} from "../util/compatibility";import {hasClosestByClassName} from "../util/hasClosest";import {goEnd, goHome} from "../wysiwyg/commonHotkey";import {isMobile} from "../../util/functions";-import {App} from "../../index";export class Scroll {public element: HTMLElement;@@ -14,7 +13,7 @@ export class Scroll {public lastScrollTop: number;public keepLazyLoad: boolean; // 保持加载内容- constructor(protyle: IProtyle, app: App) {+ constructor(protyle: IProtyle) {this.parentElement = document.createElement("div");this.parentElement.classList.add("protyle-scroll");if (!isMobile()) {@@ -42,25 +41,25 @@ export class Scroll {});/// #if BROWSERthis.inputElement.addEventListener("change", () => {- this.setIndex(protyle, app);+ this.setIndex(protyle);});this.inputElement.addEventListener("touchend", () => {- this.setIndex(protyle, app);+ this.setIndex(protyle);});/// #endifthis.parentElement.addEventListener("click", (event) => {const target = event.target as HTMLElement;if (hasClosestByClassName(target, "protyle-scroll__up")) {- goHome(protyle, app);+ goHome(protyle);} else if (hasClosestByClassName(target, "protyle-scroll__down")) {- goEnd(protyle, app);+ goEnd(protyle);} else if (target.classList.contains("b3-slider")) {- this.setIndex(protyle, app);+ this.setIndex(protyle);}});}- private setIndex(protyle: IProtyle, app: App) {+ private setIndex(protyle: IProtyle) {if (protyle.wysiwyg.element.getAttribute("data-top")) {return;}@@ -75,7 +74,6 @@ export class Scroll {data: getResponse,protyle,action: [Constants.CB_GET_FOCUSFIRST, Constants.CB_GET_UNCHANGEID],- app});});}diff --git a/app/src/protyle/scroll/saveScroll.ts b/app/src/protyle/scroll/saveScroll.tsindex 3d5f7c13db..ec0e00a38b 100644--- a/app/src/protyle/scroll/saveScroll.ts+++ b/app/src/protyle/scroll/saveScroll.ts@@ -3,7 +3,6 @@ import {getSelectionOffset} from "../util/selection";import {fetchPost} from "../../util/fetch";import {onGet} from "../util/onGet";import {Constants} from "../../constants";-import {App} from "../../index";export const saveScroll = (protyle: IProtyle, getObject = false) => {if (!protyle.wysiwyg.element.firstElementChild || window.siyuan.config.readonly) {@@ -46,7 +45,6 @@ export const saveScroll = (protyle: IProtyle, getObject = false) => {};export const getDocByScroll = (options: {- app: App,protyle: IProtyle,scrollAttr: IScrollAttr,mergedOptions?: IOptions,@@ -75,7 +73,6 @@ export const getDocByScroll = (options: {protyle: options.protyle,action: actions,scrollAttr: options.scrollAttr,- app: options.app});if (options.cb) {options.cb();@@ -94,7 +91,6 @@ export const getDocByScroll = (options: {protyle: options.protyle,action: actions,scrollAttr: options.scrollAttr,- app: options.app});if (options.cb) {options.cb();diff --git a/app/src/protyle/toolbar/Link.ts b/app/src/protyle/toolbar/Link.tsindex db3c3d1e64..8f13380b73 100644--- a/app/src/protyle/toolbar/Link.ts+++ b/app/src/protyle/toolbar/Link.ts@@ -4,12 +4,11 @@ import {hasClosestBlock, hasClosestByAttribute} from "../util/hasClosest";import {focusByRange, focusByWbr} from "../util/selection";import {readText} from "../util/compatibility";import {Constants} from "../../constants";-import {App} from "../../index";export class Link extends ToolbarItem {public element: HTMLElement;- constructor(app: App, protyle: IProtyle, menuItem: IMenuItem) {+ constructor(protyle: IProtyle, menuItem: IMenuItem) {super(protyle, menuItem);// 不能用 getEventName,否则会导致光标位置变动到点击的文档中this.element.addEventListener("click", async (event: MouseEvent & { changedTouches: MouseEvent[] }) => {@@ -23,7 +22,7 @@ export class Link extends ToolbarItem {}const aElement = hasClosestByAttribute(range.startContainer, "data-type", "a");if (aElement) {- linkMenu(app, protyle, aElement);+ linkMenu(protyle, aElement);return;}diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.tsindex f20e394d35..4c7f246e2f 100644--- a/app/src/protyle/toolbar/index.ts+++ b/app/src/protyle/toolbar/index.ts@@ -45,7 +45,6 @@ import {mathRender} from "../markdown/mathRender";import {linkMenu} from "../../menus/protyle";import {addScript} from "../util/addScript";import {confirmDialog} from "../../dialog/confirmDialog";-import {App} from "../../index";export class Toolbar {public element: HTMLElement;@@ -53,11 +52,9 @@ export class Toolbar {public subElementCloseCB: () => void;public range: Range;private toolbarHeight: number;- private app: App;- constructor(app: App, protyle: IProtyle) {+ constructor(protyle: IProtyle) {const options = protyle.options;- this.app = app;const element = document.createElement("div");element.className = "protyle-toolbar fn__none";this.element = element;@@ -229,7 +226,7 @@ export class Toolbar {menuItemObj = new Font(protyle, menuItem);break;case "a":- menuItemObj = new Link(this.app, protyle, menuItem);+ menuItemObj = new Link(protyle, menuItem);break;}if (!menuItemObj) {@@ -733,7 +730,7 @@ export class Toolbar {const aElement = newNodes[0] as HTMLElement;if (aElement.textContent.replace(Constants.ZWSP, "") === "" || !aElement.getAttribute("data-href")) {needFocus = false;- linkMenu(this.app, protyle, aElement, aElement.getAttribute("data-href") ? true : false);+ linkMenu(protyle, aElement, aElement.getAttribute("data-href") ? true : false);} else {this.range.collapse(false);}@@ -1199,7 +1196,7 @@ export class Toolbar {if (!protyle.disabled) {textElement.select();}- this.app.plugins.forEach(item => {+ protyle.app.plugins.forEach(item => {item.eventBus.emit("open-noneditableblock", {protyle,toolbar: thisdiff --git a/app/src/protyle/ui/initUI.ts b/app/src/protyle/ui/initUI.tsindex ed00f92350..9264ab5615 100644--- a/app/src/protyle/ui/initUI.ts+++ b/app/src/protyle/ui/initUI.ts@@ -7,9 +7,8 @@ import {hasClosestByAttribute, hasClosestByClassName} from "../util/hasClosest";import {isMac} from "../util/compatibility";import {setInlineStyle} from "../../util/assets";import {fetchPost} from "../../util/fetch";-import {App} from "../../index";-export const initUI = (protyle: IProtyle, app: App) => {+export const initUI = (protyle: IProtyle) => {protyle.contentElement = document.createElement("div");protyle.contentElement.className = "protyle-content";if (window.siyuan.config.editor.fullWidth) {@@ -25,7 +24,7 @@ export const initUI = (protyle: IProtyle, app: App) => {}protyle.contentElement.appendChild(protyle.wysiwyg.element);if (!protyle.options.action.includes(Constants.CB_GET_HISTORY)) {- scrollEvent(app, protyle, protyle.contentElement);+ scrollEvent(protyle, protyle.contentElement);}protyle.element.append(protyle.contentElement);protyle.element.appendChild(protyle.preview.element);diff --git a/app/src/protyle/undo/index.ts b/app/src/protyle/undo/index.tsindex 128016f4e6..8cda95be26 100644--- a/app/src/protyle/undo/index.ts+++ b/app/src/protyle/undo/index.ts@@ -7,7 +7,6 @@ import {scrollCenter} from "../../util/highlightById";import {getCurrentWindow} from "@electron/remote";/// #endifimport {matchHotKey} from "../util/hotKey";-import {App} from "../../index";interface IOperations {doOperations: IOperation[],@@ -24,7 +23,7 @@ export class Undo {this.undoStack = [];}- public undo(app: App, protyle: IProtyle) {+ public undo(protyle: IProtyle) {if (protyle.disabled) {return;}@@ -32,13 +31,13 @@ export class Undo {return;}const state = this.undoStack.pop();- this.render(app, protyle, state, false);+ this.render(protyle, state, false);this.hasUndo = true;this.redoStack.push(state);}- public redo(app: App, protyle: IProtyle) {+ public redo(protyle: IProtyle) {if (protyle.disabled) {return;}@@ -46,21 +45,21 @@ export class Undo {return;}const state = this.redoStack.pop();- this.render(app, protyle, state, true);+ this.render(protyle, state, true);this.undoStack.push(state);}- private render(app: App, protyle: IProtyle, state: IOperations, redo: boolean) {+ private render(protyle: IProtyle, state: IOperations, redo: boolean) {hideElements(["hint", "gutter"], protyle);protyle.wysiwyg.lastHTMLs = {};if (!redo) {state.undoOperations.forEach(item => {- onTransaction(app, protyle, item, true);+ onTransaction(protyle, item, true);});transaction(protyle, state.undoOperations);} else {state.doOperations.forEach(item => {- onTransaction(app, protyle, item, true);+ onTransaction(protyle, item, true);});transaction(protyle, state.doOperations);}diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.tsindex 06dd875f2b..f451d2c8e5 100644--- a/app/src/protyle/util/editorCommonEvent.ts+++ b/app/src/protyle/util/editorCommonEvent.ts@@ -19,7 +19,6 @@ import {uploadLocalFiles} from "../upload";import {insertHTML} from "./insertHTML";import {isBrowser} from "../../util/functions";import {hideElements} from "../ui/hideElements";-import {App} from "../../index";const moveToNew = (protyle: IProtyle, sourceElements: Element[], targetElement: Element, newSourceElement: Element,isSameDoc: boolean, isBottom: boolean, isCopy: boolean) => {@@ -696,7 +695,7 @@ const dragSame = async (protyle: IProtyle, sourceElements: Element[], targetElemfocusBlock(sourceElements[0]);};-export const dropEvent = (app: App, protyle: IProtyle, editorElement: HTMLElement) => {+export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {editorElement.addEventListener("dragstart", (event) => {const target = event.target as HTMLElement;if (target.tagName === "IMG") {@@ -853,7 +852,7 @@ export const dropEvent = (app: App, protyle: IProtyle, editorElement: HTMLElemenid: protyle.block.id,size: window.siyuan.config.editor.dynamicLoadBlocks,}, getResponse => {- onGet({data: getResponse, protyle, app});+ onGet({data: getResponse, protyle});/// #if !MOBILE// 文档标题互转后,需更新大纲updatePanelByEditor({diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.tsindex 348a9c5a68..906b1c2515 100644--- a/app/src/protyle/util/onGet.ts+++ b/app/src/protyle/util/onGet.ts@@ -16,14 +16,12 @@ import {removeLoading} from "../ui/initUI";import {isMobile} from "../../util/functions";import {foldPassiveType} from "../wysiwyg/renderBacklink";import {showMessage} from "../../dialog/message";-import {App} from "../../index";export const onGet = (options: {data: IWebSocketData,protyle: IProtyle,action?: string[],scrollAttr?: IScrollAttr- app: App}) => {if (!options.action) {options.action = [];@@ -79,7 +77,7 @@ export const onGet = (options: {action: options.action,scrollAttr: options.scrollAttr,isSyncing: options.data.data.isSyncing,- }, options.protyle, options.app);+ }, options.protyle);removeLoading(options.protyle);return;}@@ -101,7 +99,7 @@ export const onGet = (options: {action: options.action,scrollAttr: options.scrollAttr,isSyncing: options.data.data.isSyncing,- }, options.protyle, options.app);+ }, options.protyle);setTitle(response.data.ial.title);removeLoading(options.protyle);});@@ -113,7 +111,7 @@ const setHTML = (options: {isSyncing: boolean,expand: boolean,scrollAttr?: IScrollAttr-}, protyle: IProtyle, app: App) => {+}, protyle: IProtyle) => {if (protyle.contentElement.classList.contains("fn__none")) {return;}@@ -261,7 +259,7 @@ const setHTML = (options: {mode: 2,size: window.siyuan.config.editor.dynamicLoadBlocks,}, getResponse => {- onGet({data: getResponse, protyle, action: [Constants.CB_GET_APPEND, Constants.CB_GET_UNCHANGEID], app});+ onGet({data: getResponse, protyle, action: [Constants.CB_GET_APPEND, Constants.CB_GET_UNCHANGEID]});});}if (options.action.includes(Constants.CB_GET_APPEND) || options.action.includes(Constants.CB_GET_BEFORE)) {@@ -270,7 +268,7 @@ const setHTML = (options: {if (protyle.options.render.breadcrumb) {protyle.breadcrumb.render(protyle);}- app.plugins.forEach(item => {+ protyle.app.plugins.forEach(item => {item.eventBus.emit("loaded-protyle", protyle);});};diff --git a/app/src/protyle/util/reload.ts b/app/src/protyle/util/reload.tsindex 90c07bd44d..f1c3e4378b 100644--- a/app/src/protyle/util/reload.ts+++ b/app/src/protyle/util/reload.ts@@ -4,9 +4,8 @@ import {getDocByScroll, saveScroll} from "../scroll/saveScroll";import {renderBacklink} from "../wysiwyg/renderBacklink";import {hasClosestByClassName} from "./hasClosest";import {preventScroll} from "../scroll/preventScroll";-import {App} from "../../index";-export const reloadProtyle = (protyle: IProtyle, app: App, focus: boolean) => {+export const reloadProtyle = (protyle: IProtyle, focus: boolean) => {if (window.siyuan.config.editor.displayBookmarkIcon) {protyle.wysiwyg.element.classList.add("protyle-wysiwyg--attr");} else {@@ -40,7 +39,6 @@ export const reloadProtyle = (protyle: IProtyle, app: App, focus: boolean) => {} else {preventScroll(protyle);getDocByScroll({- app,protyle,focus,scrollAttr: saveScroll(protyle, true)diff --git a/app/src/protyle/wysiwyg/commonClick.ts b/app/src/protyle/wysiwyg/commonClick.tsindex b2849111eb..8110455e04 100644--- a/app/src/protyle/wysiwyg/commonClick.ts+++ b/app/src/protyle/wysiwyg/commonClick.ts@@ -4,17 +4,16 @@ import {openAttr, openFileAttr} from "../../menus/commonMenuItem";import {openGlobalSearch} from "../../search/util";/// #endifimport {isMobile} from "../../util/functions";-import {App} from "../../index";-export const commonClick = (app: App, event: MouseEvent & {+export const commonClick = (event: MouseEvent & {target: HTMLElement-}, protyle: IProtyle, data?:IObject) => {+}, protyle: IProtyle, data?: IObject) => {const isM = isMobile();const attrBookmarkElement = hasClosestByClassName(event.target, "protyle-attr--bookmark");if (attrBookmarkElement) {if (!isM && (event.ctrlKey || event.metaKey)) {/// #if !MOBILE- openGlobalSearch(app, attrBookmarkElement.textContent.trim(), true);+ openGlobalSearch(protyle.app, attrBookmarkElement.textContent.trim(), true);/// #endif} else {if (data) {@@ -31,10 +30,10 @@ export const commonClick = (app: App, event: MouseEvent & {if (attrNameElement) {if (!isM && (event.ctrlKey || event.metaKey)) {/// #if !MOBILE- openGlobalSearch(app, attrNameElement.textContent.trim(), true);+ openGlobalSearch(protyle.app, attrNameElement.textContent.trim(), true);/// #endif} else {- if (data ) {+ if (data) {openFileAttr(data, protyle.block.rootID, "name");} else {openAttr(attrNameElement.parentElement.parentElement, protyle, "name");@@ -48,7 +47,7 @@ export const commonClick = (app: App, event: MouseEvent & {if (attrAliasElement) {if (!isM && (event.ctrlKey || event.metaKey)) {/// #if !MOBILE- openGlobalSearch(app, attrAliasElement.textContent.trim(), true);+ openGlobalSearch(protyle.app, attrAliasElement.textContent.trim(), true);/// #endif} else {if (data) {@@ -65,7 +64,7 @@ export const commonClick = (app: App, event: MouseEvent & {if (attrMemoElement) {if (!isM && (event.ctrlKey || event.metaKey)) {/// #if !MOBILE- openGlobalSearch(app, attrMemoElement.getAttribute("aria-label").trim(), true);+ openGlobalSearch(protyle.app, attrMemoElement.getAttribute("aria-label").trim(), true);/// #endif} else {if (data) {diff --git a/app/src/protyle/wysiwyg/commonHotkey.ts b/app/src/protyle/wysiwyg/commonHotkey.tsindex f4f1806980..fb41cbffef 100644--- a/app/src/protyle/wysiwyg/commonHotkey.ts+++ b/app/src/protyle/wysiwyg/commonHotkey.ts@@ -20,9 +20,8 @@ import {transaction, updateTransaction} from "./transaction";import {onGet} from "../util/onGet";import {Constants} from "../../constants";import * as dayjs from "dayjs";-import {App} from "../../index";-export const commonHotkey = (app: App, protyle: IProtyle, event: KeyboardEvent) => {+export const commonHotkey = (protyle: IProtyle, event: KeyboardEvent) => {const target = event.target as HTMLElement;if (matchHotKey(window.siyuan.config.keymap.editor.general.copyHPath.custom, event)) {fetchPost("/api/filetree/getHPathByID", {@@ -36,7 +35,7 @@ export const commonHotkey = (app: App, protyle: IProtyle, event: KeyboardEvent)}if (matchHotKey(window.siyuan.config.keymap.editor.general.netImg2LocalAsset.custom, event)) {- netImg2LocalAssets(protyle, app);+ netImg2LocalAssets(protyle);event.preventDefault();event.stopPropagation();return true;@@ -53,20 +52,20 @@ export const commonHotkey = (app: App, protyle: IProtyle, event: KeyboardEvent)if (matchHotKey(window.siyuan.config.keymap.editor.general.backlinks.custom, event)) {event.preventDefault();event.stopPropagation();- openBacklink(app, protyle);+ openBacklink(protyle);return true;}if (matchHotKey(window.siyuan.config.keymap.editor.general.graphView.custom, event)) {event.preventDefault();event.stopPropagation();- openGraph(app, protyle);+ openGraph(protyle);return true;}if (matchHotKey(window.siyuan.config.keymap.editor.general.outline.custom, event)) {event.preventDefault();event.stopPropagation();const offset = getSelectionOffset(target);- openOutline(app, protyle);+ openOutline(protyle);// switchWnd 后,range会被清空,需要重新设置focusByOffset(target, offset.start, offset.end);return true;@@ -74,7 +73,7 @@ export const commonHotkey = (app: App, protyle: IProtyle, event: KeyboardEvent)}let matchCommand = false;- app.plugins.find(item => {+ protyle.app.plugins.find(item => {item.commands.find(command => {if (command.editorCallback && matchHotKey(command.customHotkey, event)) {matchCommand = true;@@ -228,7 +227,7 @@ export const duplicateBlock = (nodeElements: Element[], protyle: IProtyle) => {scrollCenter(protyle);};-export const goHome = (protyle: IProtyle, app: App) => {+export const goHome = (protyle: IProtyle) => {if (protyle.wysiwyg.element.firstElementChild.getAttribute("data-node-index") === "0" ||protyle.wysiwyg.element.firstElementChild.getAttribute("data-eof") === "1" ||protyle.options.backlinkData) {@@ -241,12 +240,12 @@ export const goHome = (protyle: IProtyle, app: App) => {mode: 0,size: window.siyuan.config.editor.dynamicLoadBlocks,}, getResponse => {- onGet({data: getResponse, protyle, action: [Constants.CB_GET_FOCUS], app});+ onGet({data: getResponse, protyle, action: [Constants.CB_GET_FOCUS]});});}};-export const goEnd = (protyle: IProtyle, app: App) => {+export const goEnd = (protyle: IProtyle) => {if (!protyle.scroll.element.classList.contains("fn__none") &&protyle.wysiwyg.element.lastElementChild.getAttribute("data-eof") !== "2") {fetchPost("/api/filetree/getDoc", {@@ -254,7 +253,7 @@ export const goEnd = (protyle: IProtyle, app: App) => {mode: 4,size: window.siyuan.config.editor.dynamicLoadBlocks,}, getResponse => {- onGet({data: getResponse, protyle, action: [Constants.CB_GET_FOCUS], app});+ onGet({data: getResponse, protyle, action: [Constants.CB_GET_FOCUS]});});} else {protyle.contentElement.scrollTop = protyle.contentElement.scrollHeight;diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.tsindex c81ab936e6..a974210851 100644--- a/app/src/protyle/wysiwyg/index.ts+++ b/app/src/protyle/wysiwyg/index.ts@@ -66,17 +66,14 @@ import {getBacklinkHeadingMore, loadBreadcrumb} from "./renderBacklink";import {removeSearchMark} from "../toolbar/util";import {activeBlur, hideKeyboardToolbar} from "../../mobile/util/keyboardToolbar";import {commonClick} from "./commonClick";-import {App} from "../../index";export class WYSIWYG {public lastHTMLs: { [key: string]: string } = {};public element: HTMLDivElement;public preventKeyup: boolean;- private app: App;- constructor(app: App, protyle: IProtyle) {- this.app = app;+ constructor(protyle: IProtyle) {this.element = document.createElement("div");this.element.className = "protyle-wysiwyg";this.element.setAttribute("spellcheck", "false");@@ -94,8 +91,8 @@ export class WYSIWYG {return;}this.bindEvent(protyle);- keydown(app, protyle, this.element);- dropEvent(app, protyle, this.element);+ keydown(protyle, this.element);+ dropEvent(protyle, this.element);}public renderCustom(ial: IObject) {@@ -1025,7 +1022,7 @@ export class WYSIWYG {}}const nextElement = getNextBlock(selectElements[selectElements.length - 1]);- removeBlock(this.app, protyle, nodeElement, range);+ removeBlock(protyle, nodeElement, range);if (nextElement) {// Ctrl+X 剪切后光标应跳到下一行行首 https://github.com/siyuan-note/siyuan/issues/5485focusBlock(nextElement);@@ -1212,7 +1209,7 @@ export class WYSIWYG {removeSearchMark(target);}if (types.includes("block-ref") && !protyle.disabled) {- refMenu(this.app, protyle, target);+ refMenu(protyle, target);// 阻止 popovertarget.setAttribute("prevent-popover", "true");setTimeout(() => {@@ -1223,13 +1220,13 @@ export class WYSIWYG {protyle.toolbar.showFileAnnotationRef(protyle, target);return false;} else if (types.includes("tag") && !protyle.disabled) {- tagMenu(this.app, protyle, target);+ tagMenu(protyle, target);return false;} else if (types.includes("inline-memo")) {protyle.toolbar.showRender(protyle, target);return false;} else if (types.includes("a") && !protyle.disabled) {- linkMenu(this.app, protyle, target);+ linkMenu(protyle, target);if (window.siyuan.config.editor.floatWindowMode === 0 &&target.getAttribute("data-href")?.startsWith("siyuan://blocks")) {// 阻止 popover@@ -1242,7 +1239,7 @@ export class WYSIWYG {}}if (!protyle.disabled && target.tagName === "IMG" && hasClosestByClassName(target, "img")) {- imgMenu(this.app, protyle, protyle.toolbar.range, target.parentElement.parentElement, {+ imgMenu(protyle, protyle.toolbar.range, target.parentElement.parentElement, {clientX: x + 4,clientY: y});@@ -1303,7 +1300,6 @@ export class WYSIWYG {data: getResponse,protyle,action: [Constants.CB_GET_BEFORE, Constants.CB_GET_UNCHANGEID],- app: this.app});});preventGetTopHTML = true;@@ -1498,7 +1494,7 @@ export class WYSIWYG {let shiftStartElement: HTMLElement;this.element.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {- this.app.plugins.forEach(item => {+ protyle.app.plugins.forEach(item => {item.eventBus.emit("click-editorcontent", {protyle,event@@ -1514,7 +1510,7 @@ export class WYSIWYG {if (ctrlIsPressed) {fetchPost("/api/block/checkBlockFold", {id: breadcrumbId}, (foldResponse) => {openFileById({- app: this.app,+ app: protyle.app,id: breadcrumbId,action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],zoomIn: foldResponse.data@@ -1572,7 +1568,7 @@ export class WYSIWYG {fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => {/// #if MOBILE- openMobileFileById(this.app, refBlockId, foldResponse.data ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT]);+ openMobileFileById(protyle.app, refBlockId, foldResponse.data ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT]);activeBlur();hideKeyboardToolbar();/// #else@@ -1582,7 +1578,7 @@ export class WYSIWYG {}if (event.shiftKey) {openFileById({- app: this.app,+ app: protyle.app,id: refBlockId,position: "bottom",action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],@@ -1590,7 +1586,7 @@ export class WYSIWYG {});} else if (event.altKey) {openFileById({- app: this.app,+ app: protyle.app,id: refBlockId,position: "right",action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],@@ -1598,7 +1594,7 @@ export class WYSIWYG {});} else if (ctrlIsPressed) {openFileById({- app: this.app,+ app: protyle.app,id: refBlockId,action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT],keepCursor: true,@@ -1606,7 +1602,7 @@ export class WYSIWYG {});} else {openFileById({- app: this.app,+ app: protyle.app,id: refBlockId,action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],zoomIn: foldResponse.data@@ -1645,7 +1641,7 @@ export class WYSIWYG {} else if (event.shiftKey) {openBy(linkAddress, "app");} else {- openAsset(this.app, linkAddress, fileIds[2], "right");+ openAsset(protyle.app, linkAddress, fileIds[2], "right");}/// #endifreturn;@@ -1669,7 +1665,7 @@ export class WYSIWYG {} else if (event.shiftKey) {openBy(linkAddress, "app");} else {- openAsset(this.app, linkPathname, parseInt(getSearch("page", linkAddress)), "right");+ openAsset(protyle.app, linkPathname, parseInt(getSearch("page", linkAddress)), "right");}} else {/// #if !BROWSER@@ -1698,11 +1694,11 @@ export class WYSIWYG {const tagElement = hasClosestByAttribute(event.target, "data-type", "tag");if (tagElement && !event.altKey) {/// #if !MOBILE- openGlobalSearch(this.app, `#${tagElement.textContent}#`, !ctrlIsPressed);+ openGlobalSearch(protyle.app, `#${tagElement.textContent}#`, !ctrlIsPressed);hideElements(["dialog"]);/// #elseconst searchOption = window.siyuan.storage[Constants.LOCAL_SEARCHDATA];- popSearch(this.app, {+ popSearch(protyle.app, {removed: searchOption.removed,sort: searchOption.sort,group: searchOption.group,@@ -1723,13 +1719,13 @@ export class WYSIWYG {if (embedItemElement) {const embedId = embedItemElement.getAttribute("data-id");/// #if MOBILE- openMobileFileById(this.app, embedId, [Constants.CB_GET_ALL]);+ openMobileFileById(protyle.app, embedId, [Constants.CB_GET_ALL]);activeBlur();hideKeyboardToolbar();/// #elseif (event.shiftKey) {openFileById({- app: this.app,+ app: protyle.app,id: embedId,position: "bottom",action: [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL],@@ -1737,7 +1733,7 @@ export class WYSIWYG {});} else if (event.altKey) {openFileById({- app: this.app,+ app: protyle.app,id: embedId,position: "right",action: [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL],@@ -1745,7 +1741,7 @@ export class WYSIWYG {});} else if (ctrlIsPressed) {openFileById({- app: this.app,+ app: protyle.app,id: embedId,action: [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL],keepCursor: true,@@ -1753,7 +1749,7 @@ export class WYSIWYG {});} else if (!protyle.disabled) {window.siyuan.blockPanels.push(new BlockPanel({- app: this.app,+ app: protyle.app,targetElement: embedItemElement,isBacklink: false,nodeIds: [embedId],@@ -1764,7 +1760,7 @@ export class WYSIWYG {return;}- if (commonClick(this.app, event, protyle)) {+ if (commonClick(event, protyle)) {return;}@@ -1829,7 +1825,7 @@ export class WYSIWYG {if (actionElement) {const type = actionElement.parentElement.parentElement.getAttribute("data-type");if (type === "img" && !protyle.disabled) {- imgMenu(this.app, protyle, range, actionElement.parentElement.parentElement, {+ imgMenu(protyle, range, actionElement.parentElement.parentElement, {clientX: event.clientX + 4,clientY: event.clientY});@@ -1865,7 +1861,7 @@ export class WYSIWYG {} else if (event.shiftKey) {openAttr(actionElement.parentElement, protyle);} else if (ctrlIsPressed) {- zoomOut({protyle, id: actionElement.parentElement.getAttribute("data-node-id"), app: this.app});+ zoomOut({protyle, id: actionElement.parentElement.getAttribute("data-node-id")});} else {if (actionElement.classList.contains("protyle-action--task")) {const html = actionElement.parentElement.outerHTML;diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.tsindex ba61804501..4852f48740 100644--- a/app/src/protyle/wysiwyg/keydown.ts+++ b/app/src/protyle/wysiwyg/keydown.ts@@ -71,9 +71,8 @@ import {escapeHtml} from "../../util/escape";import {insertHTML} from "../util/insertHTML";import {quickMakeCard} from "../../card/makeCard";import {removeSearchMark} from "../toolbar/util";-import {App} from "../../index";-export const keydown = (app: App, protyle: IProtyle, editorElement: HTMLElement) => {+export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {editorElement.addEventListener("keydown", (event: KeyboardEvent & { target: HTMLElement }) => {if (event.target.localName === "protyle-html") {event.stopPropagation();@@ -431,7 +430,7 @@ export const keydown = (app: App, protyle: IProtyle, editorElement: HTMLElement)topNodeElement.nextElementSibling?.classList.contains("list") && topNodeElement.previousElementSibling.classList.contains("protyle-action")) {topNodeElement = topNodeElement.parentElement;}- zoomOut({protyle, id:topNodeElement.getAttribute("data-node-id"), app});+ zoomOut({protyle, id: topNodeElement.getAttribute("data-node-id")});event.preventDefault();event.stopPropagation();return;@@ -442,13 +441,13 @@ export const keydown = (app: App, protyle: IProtyle, editorElement: HTMLElement)const ids = protyle.path.split("/");if (ids.length > 2) {openFileById({- app,+ app: protyle.app,id: ids[ids.length - 2],action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]});}} else {- zoomOut({protyle, id:protyle.block.parent2ID, focusId:nodeElement.getAttribute("data-node-id"), app});+ zoomOut({protyle, id: protyle.block.parent2ID, focusId: nodeElement.getAttribute("data-node-id")});}event.preventDefault();event.stopPropagation();@@ -477,14 +476,14 @@ export const keydown = (app: App, protyle: IProtyle, editorElement: HTMLElement)}// ctrl+home 光标移动到顶if (!event.altKey && !event.shiftKey && isCtrl(event) && event.key === "Home") {- goHome(protyle, app);+ goHome(protyle);event.stopPropagation();event.preventDefault();return;}// ctrl+end 光标移动到尾if (!event.altKey && !event.shiftKey && isCtrl(event) && event.key === "End") {- goEnd(protyle, app);+ goEnd(protyle);event.stopPropagation();event.preventDefault();return;@@ -532,7 +531,7 @@ export const keydown = (app: App, protyle: IProtyle, editorElement: HTMLElement)removeSearchMark(inlineElement);}if (types.includes("block-ref")) {- refMenu(app, protyle, inlineElement);+ refMenu(protyle, inlineElement);return;} else if (types.includes("inline-memo")) {protyle.toolbar.showRender(protyle, inlineElement);@@ -541,10 +540,10 @@ export const keydown = (app: App, protyle: IProtyle, editorElement: HTMLElement)protyle.toolbar.showFileAnnotationRef(protyle, inlineElement);return;} else if (types.includes("a")) {- linkMenu(app, protyle, inlineElement);+ linkMenu(protyle, inlineElement);return;} else if (types.includes("tag")) {- tagMenu(app, protyle, inlineElement);+ tagMenu(protyle, inlineElement);return;}}@@ -694,7 +693,7 @@ export const keydown = (app: App, protyle: IProtyle, editorElement: HTMLElement)// 不可使用 !event.shiftKey,否则 https://ld246.com/article/1666434796806if (!event.altKey && (event.key === "Backspace" || event.key === "Delete")) {if (protyle.wysiwyg.element.querySelector(".protyle-wysiwyg--select")) {- removeBlock(app, protyle, nodeElement, range);+ removeBlock(protyle, nodeElement, range);event.stopPropagation();event.preventDefault();return;@@ -736,7 +735,7 @@ export const keydown = (app: App, protyle: IProtyle, editorElement: HTMLElement)previousSibling.nodeType !== 3 && (previousSibling as HTMLElement).outerHTML === "<span>\\</span>" &&!hasPreviousSibling(previousSibling.parentElement)) {range.setStartBefore(previousSibling.parentElement);- removeBlock(app, protyle, nodeElement, range);+ removeBlock(protyle, nodeElement, range);event.stopPropagation();event.preventDefault();return;@@ -746,7 +745,7 @@ export const keydown = (app: App, protyle: IProtyle, editorElement: HTMLElement)range.startContainer.parentElement.getAttribute("data-type")?.indexOf("backslash") > -1 &&!hasPreviousSibling(range.startContainer.parentElement)) {range.setStartBefore(range.startContainer.parentElement);- removeBlock(app, protyle, nodeElement, range);+ removeBlock(protyle, nodeElement, range);event.stopPropagation();event.preventDefault();return;@@ -768,7 +767,7 @@ export const keydown = (app: App, protyle: IProtyle, editorElement: HTMLElement)const editElement = getContenteditableElement(nodeElement);if (!editElement) {nodeElement.classList.add("protyle-wysiwyg--select");- removeBlock(app, protyle, nodeElement, range);+ removeBlock(protyle, nodeElement, range);event.stopPropagation();event.preventDefault();return;@@ -783,7 +782,7 @@ export const keydown = (app: App, protyle: IProtyle, editorElement: HTMLElement)if (nextRange) {const nextBlockElement = hasClosestBlock(nextRange.startContainer);if (nextBlockElement) {- removeBlock(app, protyle, nextBlockElement, nextRange);+ removeBlock(protyle, nextBlockElement, nextRange);}}event.stopPropagation();@@ -801,7 +800,7 @@ export const keydown = (app: App, protyle: IProtyle, editorElement: HTMLElement)range.startOffset === 0 ||(currentNode && currentNode.nodeType === 3 && !hasPreviousSibling(currentNode) && currentNode.textContent === "") // https://ld246.com/article/1649251218696)) {- removeBlock(app, protyle, nodeElement, range);+ removeBlock(protyle, nodeElement, range);event.stopPropagation();event.preventDefault();return;@@ -810,7 +809,7 @@ export const keydown = (app: App, protyle: IProtyle, editorElement: HTMLElement)nodeElement.getAttribute("data-type") === "NodeTable" &&(range.startContainer as HTMLElement).children[range.startOffset - 1]?.tagName === "TABLE") {nodeElement.classList.add("protyle-wysiwyg--select");- removeBlock(app, protyle, nodeElement, range);+ removeBlock(protyle, nodeElement, range);event.stopPropagation();event.preventDefault();return;@@ -927,14 +926,14 @@ export const keydown = (app: App, protyle: IProtyle, editorElement: HTMLElement)}if (matchHotKey(window.siyuan.config.keymap.editor.general.undo.custom, event)) {- protyle.undo.undo(app, protyle);+ protyle.undo.undo(protyle);event.preventDefault();event.stopPropagation();return;}if (matchHotKey(window.siyuan.config.keymap.editor.general.redo.custom, event)) {- protyle.undo.redo(app, protyle);+ protyle.undo.redo(protyle);event.preventDefault();event.stopPropagation();return;@@ -954,7 +953,7 @@ export const keydown = (app: App, protyle: IProtyle, editorElement: HTMLElement)return true;}/// #if !MOBILE- if (commonHotkey(app, protyle, event)) {+ if (commonHotkey(protyle, event)) {return true;}/// #endif@@ -1446,7 +1445,7 @@ export const keydown = (app: App, protyle: IProtyle, editorElement: HTMLElement)});writeText(protyle.lute.BlockDOM2StdMd(html).trimEnd());const nextElement = getNextBlock(selectElements[selectElements.length - 1]);- removeBlock(app, protyle, nodeElement, range);+ removeBlock(protyle, nodeElement, range);if (nextElement) {focusBlock(nextElement);}@@ -1597,7 +1596,7 @@ export const keydown = (app: App, protyle: IProtyle, editorElement: HTMLElement)if (matchHotKey(window.siyuan.config.keymap.editor.general.openBy.custom, event)) {fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {openFileById({- app,+ app: protyle.app,id,action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],zoomIn: foldResponse.data@@ -1610,7 +1609,7 @@ export const keydown = (app: App, protyle: IProtyle, editorElement: HTMLElement)// 打开块引和编辑器中引用、反链、书签中点击事件需保持一致,都加载上下文fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {openFileById({- app,+ app: protyle.app,id,action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT],keepCursor: true,@@ -1623,7 +1622,7 @@ export const keydown = (app: App, protyle: IProtyle, editorElement: HTMLElement)} else if (matchHotKey(window.siyuan.config.keymap.editor.general.insertRight.custom, event)) {fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {openFileById({- app,+ app: protyle.app,id,position: "right",action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],@@ -1636,7 +1635,7 @@ export const keydown = (app: App, protyle: IProtyle, editorElement: HTMLElement)} else if (matchHotKey(window.siyuan.config.keymap.editor.general.insertBottom.custom, event)) {fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {openFileById({- app,+ app: protyle.app,id,position: "bottom",action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],@@ -1649,7 +1648,7 @@ export const keydown = (app: App, protyle: IProtyle, editorElement: HTMLElement)} else if (matchHotKey(window.siyuan.config.keymap.editor.general.refPopover.custom, event)) {// open popoverwindow.siyuan.blockPanels.push(new BlockPanel({- app,+ app: protyle.app,isBacklink: false,targetElement: refElement,nodeIds: [id],diff --git a/app/src/protyle/wysiwyg/remove.ts b/app/src/protyle/wysiwyg/remove.tsindex d204a8e6fc..0f58cb5d4d 100644--- a/app/src/protyle/wysiwyg/remove.ts+++ b/app/src/protyle/wysiwyg/remove.ts@@ -15,7 +15,6 @@ import {preventScroll} from "../scroll/preventScroll";import {hideElements} from "../ui/hideElements";import {Constants} from "../../constants";import {scrollCenter} from "../../util/highlightById";-import {App} from "../../index";const removeLi = (protyle: IProtyle, blockElement: Element, range: Range) => {if (!blockElement.parentElement.previousElementSibling && blockElement.parentElement.nextElementSibling && blockElement.parentElement.nextElementSibling.classList.contains("protyle-attr")) {@@ -178,7 +177,7 @@ const removeLi = (protyle: IProtyle, blockElement: Element, range: Range) => {focusByWbr(previousLastElement.parentElement, range);};-export const removeBlock = (app: App, protyle: IProtyle, blockElement: Element, range: Range) => {+export const removeBlock = (protyle: IProtyle, blockElement: Element, range: Range) => {// 删除后,防止滚动条滚动后调用 get 请求,因为返回的请求已查找不到内容块了preventScroll(protyle);const selectElements = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));@@ -242,7 +241,7 @@ export const removeBlock = (app: App, protyle: IProtyle, blockElement: Element,if (sideElement) {if (protyle.block.showAll && sideElement.classList.contains("protyle-wysiwyg") && protyle.wysiwyg.element.childElementCount === 0) {setTimeout(() => {- zoomOut({app, protyle, id:protyle.block.parent2ID, focusId:protyle.block.parent2ID});+ zoomOut({protyle, id:protyle.block.parent2ID, focusId:protyle.block.parent2ID});}, Constants.TIMEOUT_INPUT * 2 + 100);} else {if ((sideElement.classList.contains("protyle-wysiwyg") && protyle.wysiwyg.element.childElementCount === 0)) {@@ -295,7 +294,7 @@ export const removeBlock = (app: App, protyle: IProtyle, blockElement: Element,// 空代码块直接删除if (blockElement.getAttribute("data-type") === "NodeCodeBlock" && getContenteditableElement(blockElement).textContent.trim() === "") {blockElement.classList.add("protyle-wysiwyg--select");- removeBlock(app, protyle, blockElement, range);+ removeBlock(protyle, blockElement, range);return;}// 设置 bq 和代码块光标diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.tsindex 3b0938adbf..ae48d4847e 100644--- a/app/src/protyle/wysiwyg/transaction.ts+++ b/app/src/protyle/wysiwyg/transaction.ts@@ -17,7 +17,6 @@ import {hideElements} from "../ui/hideElements";import {reloadProtyle} from "../util/reload";import {countBlockWord} from "../../layout/status";import {needSubscribe} from "../../util/needSubscribe";-import {App} from "../../index";const removeTopElement = (updateElement: Element, protyle: IProtyle) => {// 移动到其他文档中,该块需移除@@ -49,7 +48,7 @@ const removeTopElement = (updateElement: Element, protyle: IProtyle) => {};// 用于执行操作,外加处理当前编辑器中引用块、嵌入块的更新-const promiseTransaction = (app: App) => {+const promiseTransaction = () => {const protyle = window.siyuan.transactions[0].protyle;const doOperations = window.siyuan.transactions[0].doOperations;const undoOperations = window.siyuan.transactions[0].undoOperations;@@ -65,9 +64,9 @@ const promiseTransaction = (app: App) => {}]}, (response) => {if (window.siyuan.transactions.length === 0) {- promiseTransactions(app);+ promiseTransactions();} else {- promiseTransaction(app);+ promiseTransaction();}countBlockWord([], protyle.block.rootID, true);@@ -140,7 +139,6 @@ const promiseTransaction = (app: App) => {data: getResponse,protyle,action: [Constants.CB_GET_APPEND, Constants.CB_GET_UNCHANGEID],- app});});}@@ -312,18 +310,18 @@ const updateEmbed = (protyle: IProtyle, operation: IOperation) => {}};-export const promiseTransactions = (app: App) => {+export const promiseTransactions = () => {window.siyuan.transactionsTimeout = window.setInterval(() => {if (window.siyuan.transactions.length === 0) {return;}window.clearInterval(window.siyuan.transactionsTimeout);- promiseTransaction(app);+ promiseTransaction();}, Constants.TIMEOUT_INPUT * 2);};// 用于推送和撤销-export const onTransaction = (app: App, protyle: IProtyle, operation: IOperation, focus: boolean) => {+export const onTransaction = (protyle: IProtyle, operation: IOperation, focus: boolean) => {const updateElements: Element[] = [];Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.id}"]`)).forEach(item => {if (!hasClosestByAttribute(item.parentElement, "data-type", "NodeBlockQueryEmbed")) {@@ -655,7 +653,7 @@ export const onTransaction = (app: App, protyle: IProtyle, operation: IOperationreturn;}if (operation.action === "append") {- reloadProtyle(protyle, app, false);+ reloadProtyle(protyle, false);}};diff --git a/app/src/search/util.ts b/app/src/search/util.tsindex 29e20b5bf0..129af206ba 100644--- a/app/src/search/util.ts+++ b/app/src/search/util.ts@@ -915,7 +915,6 @@ const getArticle = (options: {data: getResponse,protyle: options.edit.protyle,action: foldResponse.data ? [Constants.CB_GET_ALL, Constants.CB_GET_HTML] : [Constants.CB_GET_HL, Constants.CB_GET_HTML],- app: options.app});const matchElement = options.edit.protyle.wysiwyg.element.querySelector(`div[data-node-id="${options.id}"] span[data-type~="search-mark"]`);if (matchElement) {@@ -975,7 +974,7 @@ const replace = (element: Element, config: ISearchOption, edit: Protyle, app: Ap}getAllModels().editor.forEach(item => {if (rootIds[0] === item.editor.protyle.block.rootID) {- reloadProtyle(item.editor.protyle, app, false);+ reloadProtyle(item.editor.protyle, false);}});if (currentList.nextElementSibling) {diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.tsindex 8aa29f05f5..444d912579 100644--- a/app/src/types/index.d.ts+++ b/app/src/types/index.d.ts@@ -49,7 +49,7 @@ interface Window {Protyle: import("../protyle/method").default- goBack(app: import("../index").App): void+ goBack(): voidshowKeyboardToolbar(height: number): voiddiff --git a/app/src/types/protyle.d.ts b/app/src/types/protyle.d.tsindex 7a6c09235c..3888c57967 100644--- a/app/src/types/protyle.d.ts+++ b/app/src/types/protyle.d.ts@@ -407,6 +407,7 @@ interface IOptions {}interface IProtyle {+ app: import("../index").App,transactionTime: number,id: string,block: {diff --git a/app/src/util/backForward.ts b/app/src/util/backForward.tsindex 884eec68d9..ec631866f8 100644--- a/app/src/util/backForward.ts+++ b/app/src/util/backForward.ts@@ -153,7 +153,6 @@ const focusStack = async (app: App, stack: IBackStack) => {return false;}zoomOut({- app,protyle: stack.protyle,id: stack.zoomId || stack.protyle.block.rootID,isPushBack: false,diff --git a/app/src/util/functions.ts b/app/src/util/functions.tsindex b2c912c3d1..3733d5225d 100644--- a/app/src/util/functions.ts+++ b/app/src/util/functions.ts@@ -5,9 +5,9 @@ export const isMobile = () => {// "windows" | "linux" | "darwin" | "docker" | "android" | "ios"export const getBackend = () => {if (["docker", "ios", "android"].includes(window.siyuan.config.system.container)) {- return window.siyuan.config.system.container+ return window.siyuan.config.system.container;} else {- return window.siyuan.config.system.os+ return window.siyuan.config.system.os;}};diff --git a/app/src/window/index.ts b/app/src/window/index.tsindex 6195ea25a2..8d6b312b73 100644--- a/app/src/window/index.ts+++ b/app/src/window/index.ts@@ -145,7 +145,7 @@ class App {});setNoteBook();initBlockPopover(this);- promiseTransactions(this);+ promiseTransactions();}}