diff --git a/app/src/assets/scss/util/_function.scss b/app/src/assets/scss/util/_function.scss index bc410f810..426d75681 100644 --- a/app/src/assets/scss/util/_function.scss +++ b/app/src/assets/scss/util/_function.scss @@ -81,6 +81,10 @@ } } + &__displayblock { + display: block; + } + &__block { width: 100%; } diff --git a/app/src/mobile/settings/editor.ts b/app/src/mobile/settings/editor.ts index 40ca33a76..b35eb8004 100644 --- a/app/src/mobile/settings/editor.ts +++ b/app/src/mobile/settings/editor.ts @@ -2,6 +2,7 @@ import {openModel} from "../menu/model"; import {fetchPost} from "../../util/fetch"; import {reloadProtyle} from "../../protyle/util/reload"; import {setInlineStyle} from "../../util/assets"; +import {confirmDialog} from "../../dialog/confirmDialog"; const reloadEditor = (data: IEditor) => { window.siyuan.config.editor = data; @@ -9,37 +10,233 @@ const reloadEditor = (data: IEditor) => { setInlineStyle(); }; +const setEditor = (modelMainElement: Element) => { + let dynamicLoadBlocks = parseInt((modelMainElement.querySelector("#dynamicLoadBlocks") as HTMLInputElement).value); + if (48 > dynamicLoadBlocks) { + dynamicLoadBlocks = 48; + (modelMainElement.querySelector("#dynamicLoadBlocks") as HTMLInputElement).value = "48"; + } + if (1024 < dynamicLoadBlocks) { + dynamicLoadBlocks = 1024; + (modelMainElement.querySelector("#dynamicLoadBlocks") as HTMLInputElement).value = "1024"; + } + window.siyuan.config.editor.dynamicLoadBlocks = dynamicLoadBlocks; + window.siyuan.config.editor.justify = (modelMainElement.querySelector("#justify") as HTMLInputElement).checked; + window.siyuan.config.editor.rtl = (modelMainElement.querySelector("#rtl") as HTMLInputElement).checked; + window.siyuan.config.editor.displayBookmarkIcon = (modelMainElement.querySelector("#displayBookmarkIcon") as HTMLInputElement).checked; + window.siyuan.config.editor.displayNetImgMark = (modelMainElement.querySelector("#displayNetImgMark") as HTMLInputElement).checked; + window.siyuan.config.editor.codeSyntaxHighlightLineNum = (modelMainElement.querySelector("#codeSyntaxHighlightLineNum") as HTMLInputElement).checked; + window.siyuan.config.editor.embedBlockBreadcrumb = (modelMainElement.querySelector("#embedBlockBreadcrumb") as HTMLInputElement).checked; + window.siyuan.config.editor.listLogicalOutdent = (modelMainElement.querySelector("#listLogicalOutdent") as HTMLInputElement).checked; + window.siyuan.config.editor.spellcheck = (modelMainElement.querySelector("#spellcheck") as HTMLInputElement).checked; + window.siyuan.config.editor.plantUMLServePath = (modelMainElement.querySelector("#plantUMLServePath") as HTMLInputElement).value; + window.siyuan.config.editor.katexMacros = (modelMainElement.querySelector("#katexMacros") as HTMLTextAreaElement).value; + window.siyuan.config.editor.codeLineWrap = (modelMainElement.querySelector("#codeLineWrap") as HTMLInputElement).checked; + window.siyuan.config.editor.virtualBlockRef = (modelMainElement.querySelector("#virtualBlockRef") as HTMLInputElement).checked; + window.siyuan.config.editor.virtualBlockRefInclude = (modelMainElement.querySelector("#virtualBlockRefInclude") as HTMLInputElement).value; + window.siyuan.config.editor.virtualBlockRefExclude = (modelMainElement.querySelector("#virtualBlockRefExclude") as HTMLInputElement).value; + window.siyuan.config.editor.blockRefDynamicAnchorTextMaxLen = parseInt((modelMainElement.querySelector("#blockRefDynamicAnchorTextMaxLen") as HTMLInputElement).value); + window.siyuan.config.editor.backlinkExpandCount = parseInt((modelMainElement.querySelector("#backlinkExpandCount") as HTMLInputElement).value); + window.siyuan.config.editor.backmentionExpandCount = parseInt((modelMainElement.querySelector("#backmentionExpandCount") as HTMLInputElement).value); + window.siyuan.config.editor.codeLigatures = (modelMainElement.querySelector("#codeLigatures") as HTMLInputElement).checked; + window.siyuan.config.editor.codeTabSpaces = parseInt((modelMainElement.querySelector("#codeTabSpaces") as HTMLInputElement).value); + window.siyuan.config.editor.fontSize = parseInt((modelMainElement.querySelector("#fontSize") as HTMLInputElement).value); + window.siyuan.config.editor.generateHistoryInterval = parseInt((modelMainElement.querySelector("#generateHistoryInterval") as HTMLInputElement).value); + window.siyuan.config.editor.historyRetentionDays = parseInt((modelMainElement.querySelector("#historyRetentionDays") as HTMLInputElement).value); + fetchPost("/api/setting/setEditor", window.siyuan.config.editor, response => { + reloadEditor(response.data); + }); +}; + export const initEditor = () => { openModel({ title: window.siyuan.languages.editor, icon: "iconEdit", - html: `