This commit is contained in:
Vanessa 2023-12-09 10:57:53 +08:00
parent d2cf402c6a
commit 2d11266b31
8 changed files with 23 additions and 31 deletions

View file

@ -3,6 +3,7 @@ import {getSelectionOffset} from "../util/selection";
import {fetchPost} from "../../util/fetch";
import {onGet} from "../util/onGet";
import {Constants} from "../../constants";
import {setStorageVal} from "../util/compatibility";
export const saveScroll = (protyle: IProtyle, getObject = false) => {
if (!protyle.wysiwyg.element.firstElementChild || window.siyuan.config.readonly) {
@ -38,10 +39,8 @@ export const saveScroll = (protyle: IProtyle, getObject = false) => {
if (getObject) {
return attr;
}
const jsonAttr = JSON.stringify(attr);
fetchPost("/api/attr/setBlockAttrs", {id: protyle.block.rootID, attrs: {scroll: jsonAttr}}, () => {
protyle.wysiwyg.element.setAttribute("scroll", jsonAttr);
});
window.siyuan.storage[Constants.LOCAL_FILEPOSITION][protyle.block.rootID] = JSON.stringify(attr);
setStorageVal(Constants.LOCAL_FILEPOSITION, window.siyuan.storage[Constants.LOCAL_FILEPOSITION][protyle.block.rootID]);
};
export const getDocByScroll = (options: {

View file

@ -187,6 +187,7 @@ export const getLocalStorage = (cb: () => void) => {
defaultStorage[Constants.LOCAL_LAYOUTS] = []; // {name: "", layout:{}}
defaultStorage[Constants.LOCAL_AI] = []; // {name: "", memo: ""}
defaultStorage[Constants.LOCAL_PLUGINTOPUNPIN] = [];
defaultStorage[Constants.LOCAL_FILEPOSITION] = {}; // {id: IScrollAttr}
defaultStorage[Constants.LOCAL_FLASHCARD] = {
fullscreen: false
};
@ -244,7 +245,8 @@ export const getLocalStorage = (cb: () => void) => {
[Constants.LOCAL_EXPORTIMG, Constants.LOCAL_SEARCHKEYS, Constants.LOCAL_PDFTHEME, Constants.LOCAL_BAZAAR,
Constants.LOCAL_EXPORTWORD, Constants.LOCAL_EXPORTPDF, Constants.LOCAL_DOCINFO, Constants.LOCAL_FONTSTYLES,
Constants.LOCAL_SEARCHDATA, Constants.LOCAL_ZOOM, Constants.LOCAL_LAYOUTS, Constants.LOCAL_AI,
Constants.LOCAL_PLUGINTOPUNPIN, Constants.LOCAL_SEARCHASSET, Constants.LOCAL_FLASHCARD].forEach((key) => {
Constants.LOCAL_PLUGINTOPUNPIN, Constants.LOCAL_SEARCHASSET, Constants.LOCAL_FLASHCARD,
Constants.LOCAL_FILEPOSITION].forEach((key) => {
if (typeof response.data[key] === "string") {
try {
const parseData = JSON.parse(response.data[key]);
@ -262,14 +264,6 @@ export const getLocalStorage = (cb: () => void) => {
}
});
cb();
if (!window.siyuan.config.readonly) {
// 数据兼容移除历史数据3.8.4 移除
fetchPost("/api/storage/removeLocalStorageVals", {
app: Constants.SIYUAN_APPID,
keys: ["leftColumn", "local-searchkey", "local-searchedata", "local-searchekeys", "local-searchetabdata", "rightColumn", "topBar"]
});
}
});
};

View file

@ -124,7 +124,7 @@ export class WYSIWYG {
const ialKeys = Object.keys(ial);
for (let i = 0; i < this.element.attributes.length; i++) {
const oldKey = this.element.attributes[i].nodeName;
if (!["type", "class", "spellcheck", "contenteditable", "data-doc-type", "style", "scroll", "data-realwidth"].includes(oldKey) &&
if (!["type", "class", "spellcheck", "contenteditable", "data-doc-type", "style", "data-realwidth"].includes(oldKey) &&
!ialKeys.includes(oldKey)) {
this.element.removeAttribute(oldKey);
i--;