Skip to content

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

:rotating_light:

Vanessaa8072882fc43
diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts
index fb7a9430c2..e9a1b7bf66 100644
--- a/app/src/layout/Wnd.ts
+++ b/app/src/layout/Wnd.ts
@@ -23,8 +23,6 @@ import {showMessage} from "../dialog/message";
import {openFileById, updatePanelByEditor} from "../editor/util";
import {scrollCenter} from "../util/highlightById";
import {getAllModels} from "./getAll";
-import {fetchPost} from "../util/fetch";
-import {onGet} from "../protyle/util/onGet";
import {countBlockWord} from "./status";
import {saveScroll} from "../protyle/scroll/saveScroll";
@@ -312,7 +310,7 @@ export class Wnd {
}
});
- const initData = currentTab.headElement.getAttribute("data-initdata")
+ const initData = currentTab.headElement.getAttribute("data-initdata");
if (initData) {
const json = JSON.parse(initData);
currentTab.addModel(new Editor({
diff --git a/app/src/layout/util.ts b/app/src/layout/util.ts
index 3f2756b306..a90ea5b7da 100644
--- a/app/src/layout/util.ts
+++ b/app/src/layout/util.ts
@@ -22,7 +22,6 @@ import {hideElements} from "../protyle/ui/hideElements";
import {fetchPost} from "../util/fetch";
import {hasClosestBlock} from "../protyle/util/hasClosest";
import {getContenteditableElement} from "../protyle/wysiwyg/getBlock";
-import {updatePanelByEditor} from "../editor/util";
import {Constants} from "../constants";
import {openSearch} from "../search/spread";
import {saveScroll} from "../protyle/scroll/saveScroll";
diff --git a/app/src/mobile/util/MobileOutline.ts b/app/src/mobile/util/MobileOutline.ts
index 0a1b7c3462..3dbae39293 100644
--- a/app/src/mobile/util/MobileOutline.ts
+++ b/app/src/mobile/util/MobileOutline.ts
@@ -3,7 +3,6 @@ import {fetchPost} from "../../util/fetch";
import {openMobileFileById} from "../editor";
import {Constants} from "../../constants";
import {getEventName} from "../../protyle/util/compatibility";
-import {focusBlock} from "../../protyle/util/selection";
export class MobileOutline {
private tree: Tree;
diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.ts
index 51e21e5b54..924abde00e 100644
--- a/app/src/protyle/header/Title.ts
+++ b/app/src/protyle/header/Title.ts
@@ -26,7 +26,6 @@ import {getNoContainerElement} from "../wysiwyg/getBlock";
import {commonHotkey} from "../wysiwyg/commonHotkey";
import {code160to32} from "../util/code160to32";
import {deleteFile} from "../../editor/deleteFile";
-import {restoreScroll} from "../scroll/saveScroll";
export class Title {
public element: HTMLElement;
diff --git a/app/src/protyle/scroll/saveScroll.ts b/app/src/protyle/scroll/saveScroll.ts
index e96fe3661d..1cec83abce 100644
--- a/app/src/protyle/scroll/saveScroll.ts
+++ b/app/src/protyle/scroll/saveScroll.ts
@@ -4,32 +4,36 @@ import {fetchPost} from "../../util/fetch";
import {zoomOut} from "../../menus/protyle";
import {preventScroll} from "./preventScroll";
import {pushBack} from "../../util/backForward";
+import {processRender} from "../util/processCode";
+import {highlightRender} from "../markdown/highlightRender";
+import {blockRender} from "../markdown/blockRender";
+import {disabledProtyle, enableProtyle} from "../util/onGet";
export const saveScroll = (protyle: IProtyle, getObject = false) => {
const attr: IScrollAttr = {
startId: protyle.wysiwyg.element.firstElementChild.getAttribute("data-node-id"),
endId: protyle.wysiwyg.element.lastElementChild.getAttribute("data-node-id"),
scrollTop: protyle.contentElement.scrollTop || parseInt(protyle.contentElement.getAttribute("data-scrolltop")) || 0,
- }
- let range: Range
+ };
+ let range: Range;
if (getSelection().rangeCount > 0) {
- range = getSelection().getRangeAt(0)
+ range = getSelection().getRangeAt(0);
}
if (!range || !protyle.wysiwyg.element.contains(range.startContainer)) {
- range = protyle.toolbar.range
+ range = protyle.toolbar.range;
}
if (range && protyle.wysiwyg.element.contains(range.startContainer)) {
const blockElement = hasClosestBlock(range.startContainer);
if (blockElement) {
const position = getSelectionOffset(blockElement, undefined, range);
attr.focusId = blockElement.getAttribute("data-node-id");
- attr.focusStart = position.start
- attr.focusEnd = position.end
+ attr.focusStart = position.start;
+ attr.focusEnd = position.end;
}
}
if (protyle.block.showAll) {
- attr.zoomInId = protyle.block.id
+ attr.zoomInId = protyle.block.id;
}
if (getObject) {
return attr;
@@ -38,7 +42,7 @@ export const saveScroll = (protyle: IProtyle, getObject = false) => {
fetchPost("/api/attr/setBlockAttrs", {id: protyle.block.rootID, attrs: {scroll: jsonAttr}}, () => {
protyle.wysiwyg.element.setAttribute("scroll", jsonAttr);
});
-}
+};
export const restoreScroll = (protyle: IProtyle, scrollAttr: IScrollAttr) => {
preventScroll(protyle);
@@ -67,7 +71,16 @@ export const restoreScroll = (protyle: IProtyle, scrollAttr: IScrollAttr) => {
startID: scrollAttr.startId,
endID: scrollAttr.endId,
}, getResponse => {
+ protyle.block.showAll = false;
protyle.wysiwyg.element.innerHTML = getResponse.data.content;
+ processRender(protyle.wysiwyg.element);
+ highlightRender(protyle.wysiwyg.element);
+ blockRender(protyle, protyle.wysiwyg.element);
+ if (protyle.disabled) {
+ disabledProtyle(protyle);
+ } else {
+ enableProtyle(protyle);
+ }
protyle.contentElement.scrollTop = scrollAttr.scrollTop;
if (scrollAttr.focusId) {
const range = focusByOffset(protyle.wysiwyg.element.querySelector(`[data-node-id="${scrollAttr.focusId}"]`), scrollAttr.focusStart, scrollAttr.focusEnd);
@@ -75,6 +88,6 @@ export const restoreScroll = (protyle: IProtyle, scrollAttr: IScrollAttr) => {
pushBack(protyle, range || undefined);
/// #endif
}
- })
+ });
}
-}
+};