2022-05-26 15:18:53 +08:00
|
|
|
import {getAllModels} from "../layout/getAll";
|
|
|
|
|
import {setInlineStyle} from "../util/assets";
|
|
|
|
|
import {fetchPost} from "../util/fetch";
|
|
|
|
|
import {confirmDialog} from "../dialog/confirmDialog";
|
2022-06-30 22:44:50 +08:00
|
|
|
import {setPadding} from "../protyle/ui/initUI";
|
2022-08-31 12:57:38 +08:00
|
|
|
import {reloadProtyle} from "../protyle/util/reload";
|
2022-10-11 23:38:14 +08:00
|
|
|
import {disabledProtyle, enableProtyle} from "../protyle/util/onGet";
|
2022-10-28 20:13:37 +08:00
|
|
|
import {updateHotkeyTip} from "../protyle/util/compatibility";
|
2022-05-26 15:18:53 +08:00
|
|
|
|
|
|
|
|
export const editor = {
|
|
|
|
|
element: undefined as Element,
|
2022-10-11 23:38:14 +08:00
|
|
|
setMode: (readOnly?: boolean) => {
|
|
|
|
|
const target = document.querySelector("#barReadonly");
|
|
|
|
|
if (typeof readOnly === "undefined") {
|
2022-10-12 08:31:15 +08:00
|
|
|
readOnly = target.getAttribute("aria-label") === `${window.siyuan.languages.use} ${window.siyuan.languages.editReadonly}`;
|
2022-10-11 23:38:14 +08:00
|
|
|
}
|
|
|
|
|
window.siyuan.config.editor.readOnly = readOnly;
|
|
|
|
|
if (readOnly) {
|
|
|
|
|
target.setAttribute("aria-label", `${window.siyuan.languages.use} ${window.siyuan.languages.editMode}`);
|
2022-10-12 08:31:15 +08:00
|
|
|
target.querySelector("use").setAttribute("xlink:href", "#iconPreview");
|
2022-10-11 23:38:14 +08:00
|
|
|
} else {
|
|
|
|
|
target.setAttribute("aria-label", `${window.siyuan.languages.use} ${window.siyuan.languages.editReadonly}`);
|
2022-10-12 08:31:15 +08:00
|
|
|
target.querySelector("use").setAttribute("xlink:href", "#iconEdit");
|
2022-10-11 23:38:14 +08:00
|
|
|
}
|
|
|
|
|
fetchPost("/api/setting/setEditor", window.siyuan.config.editor, () => {
|
2022-10-12 08:31:15 +08:00
|
|
|
const allModels = getAllModels();
|
2022-10-11 23:38:14 +08:00
|
|
|
allModels.editor.forEach(editor => {
|
2022-10-11 23:41:27 +08:00
|
|
|
if (readOnly) {
|
|
|
|
|
disabledProtyle(editor.editor.protyle);
|
2022-10-11 23:38:14 +08:00
|
|
|
} else {
|
|
|
|
|
enableProtyle(editor.editor.protyle);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
allModels.backlink.forEach(backlink => {
|
|
|
|
|
backlink.editors.forEach(editor => {
|
|
|
|
|
if (readOnly) {
|
|
|
|
|
disabledProtyle(editor.protyle);
|
|
|
|
|
} else {
|
|
|
|
|
enableProtyle(editor.protyle);
|
|
|
|
|
}
|
2022-10-12 08:31:15 +08:00
|
|
|
});
|
2022-10-11 23:38:14 +08:00
|
|
|
});
|
2022-10-11 23:41:27 +08:00
|
|
|
allModels.search.forEach(search => {
|
|
|
|
|
if (readOnly) {
|
|
|
|
|
disabledProtyle(search.protyle.protyle);
|
|
|
|
|
} else {
|
|
|
|
|
enableProtyle(search.protyle.protyle);
|
|
|
|
|
}
|
|
|
|
|
});
|
2022-10-11 23:38:14 +08:00
|
|
|
window.siyuan.blockPanels.forEach(item => {
|
|
|
|
|
item.editors.forEach(editor => {
|
|
|
|
|
if (readOnly) {
|
|
|
|
|
disabledProtyle(editor.protyle);
|
|
|
|
|
} else {
|
|
|
|
|
enableProtyle(editor.protyle);
|
|
|
|
|
}
|
2022-10-12 08:31:15 +08:00
|
|
|
});
|
|
|
|
|
});
|
2022-10-11 23:38:14 +08:00
|
|
|
});
|
|
|
|
|
},
|
2022-05-26 15:18:53 +08:00
|
|
|
genHTML: () => {
|
|
|
|
|
let fontFamilyHTML = "";
|
|
|
|
|
fontFamilyHTML = '<select id="fontFamily" class="b3-select fn__flex-center fn__size200"></select>';
|
2022-06-30 22:44:50 +08:00
|
|
|
return `<label class="fn__flex b3-label">
|
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.fullWidth}
|
2022-06-30 23:46:49 +08:00
|
|
|
<div class="b3-label__text">${window.siyuan.languages.fullWidthTip}</div>
|
2022-06-30 22:44:50 +08:00
|
|
|
</div>
|
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
|
<input class="b3-switch fn__flex-center" id="fullWidth" type="checkbox"${window.siyuan.config.editor.fullWidth ? " checked" : ""}/>
|
|
|
|
|
</label>
|
2022-11-01 10:51:06 +08:00
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.justify}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.justifyTip}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
|
<input class="b3-switch fn__flex-center" id="justify" type="checkbox"${window.siyuan.config.editor.justify ? " checked" : ""}/>
|
|
|
|
|
</label>
|
|
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.rtl}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.rtlTip}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
|
<input class="b3-switch fn__flex-center" id="rtl" type="checkbox"${window.siyuan.config.editor.rtl ? " checked" : ""}/>
|
|
|
|
|
</label>
|
2022-10-11 22:09:15 +08:00
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.editReadonly}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.editReadonlyTip}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
|
<input class="b3-switch fn__flex-center" id="readOnly" type="checkbox"${window.siyuan.config.editor.readOnly ? " checked" : ""}/>
|
|
|
|
|
</label>
|
2022-05-26 15:18:53 +08:00
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.md12}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.md16}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
|
<input class="b3-switch fn__flex-center" id="displayBookmarkIcon" type="checkbox"${window.siyuan.config.editor.displayBookmarkIcon ? " checked" : ""}/>
|
|
|
|
|
</label>
|
|
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.md7}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.md8}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
|
<input class="b3-switch fn__flex-center" id="displayNetImgMark" type="checkbox"${window.siyuan.config.editor.displayNetImgMark ? " checked" : ""}/>
|
|
|
|
|
</label>
|
2022-10-24 11:24:59 +08:00
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.embedBlockBreadcrumb}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.embedBlockBreadcrumbTip}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
|
<input class="b3-switch fn__flex-center" id="embedBlockBreadcrumb" type="checkbox"${window.siyuan.config.editor.embedBlockBreadcrumb ? " checked" : ""}/>
|
|
|
|
|
</label>
|
2022-10-28 20:13:37 +08:00
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.floatWindowMode}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.floatWindowModeTip.replace("${hotkey}", updateHotkeyTip("⌘"))}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
|
<input class="b3-switch fn__flex-center" id="floatWindowMode" type="checkbox"${window.siyuan.config.editor.floatWindowMode === 0 ? " checked" : ""}/>
|
|
|
|
|
</label>
|
2022-10-24 11:24:59 +08:00
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
|
<div class="fn__flex-1">
|
2022-10-25 00:46:34 +08:00
|
|
|
${window.siyuan.languages.outlineOutdent}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.outlineOutdentTip}</div>
|
2022-10-24 11:24:59 +08:00
|
|
|
</div>
|
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
|
<input class="b3-switch fn__flex-center" id="listLogicalOutdent" type="checkbox"${window.siyuan.config.editor.listLogicalOutdent ? " checked" : ""}/>
|
|
|
|
|
</label>
|
2022-05-26 15:18:53 +08:00
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.md31}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.md32}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
|
<input class="b3-switch fn__flex-center" id="codeLineWrap" type="checkbox"${window.siyuan.config.editor.codeLineWrap ? " checked" : ""}/>
|
|
|
|
|
</label>
|
|
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.md2}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.md3}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
|
<input class="b3-switch fn__flex-center" id="codeLigatures" type="checkbox"${window.siyuan.config.editor.codeLigatures ? " checked" : ""}/>
|
|
|
|
|
</label>
|
|
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.md27}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.md28}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
|
<input class="b3-switch fn__flex-center" id="codeSyntaxHighlightLineNum" type="checkbox"${window.siyuan.config.editor.codeSyntaxHighlightLineNum ? " checked" : ""}/>
|
|
|
|
|
</label>
|
|
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.md33}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.md34}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
|
<input class="b3-switch fn__flex-center" id="virtualBlockRef" type="checkbox"${window.siyuan.config.editor.virtualBlockRef ? " checked" : ""}/>
|
|
|
|
|
</label>
|
2022-10-26 09:24:07 +08:00
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.md9}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.md36}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
|
<input class="b3-text-field fn__flex-center fn__size200" id="virtualBlockRefInclude" value="${window.siyuan.config.editor.virtualBlockRefInclude}" />
|
|
|
|
|
</label>
|
2022-05-26 15:18:53 +08:00
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.md35}
|
2022-08-12 12:08:16 +08:00
|
|
|
<div class="b3-label__text">${window.siyuan.languages.md36}</div>
|
2022-11-24 12:15:08 +08:00
|
|
|
<div class="b3-label__text">${window.siyuan.languages.md41}</div>
|
2022-05-26 15:18:53 +08:00
|
|
|
</div>
|
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
|
<input class="b3-text-field fn__flex-center fn__size200" id="virtualBlockRefExclude" value="${window.siyuan.config.editor.virtualBlockRefExclude}" />
|
|
|
|
|
</label>
|
|
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
|
<div class="fn__flex-1">
|
2022-08-27 22:58:13 +08:00
|
|
|
${window.siyuan.languages.md39}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.md40}</div>
|
2022-05-26 15:18:53 +08:00
|
|
|
</div>
|
|
|
|
|
<span class="fn__space"></span>
|
2022-08-27 22:58:13 +08:00
|
|
|
<input class="b3-text-field fn__flex-center fn__size200" id="plantUMLServePath" value="${window.siyuan.config.editor.plantUMLServePath}"/>
|
2022-05-26 15:18:53 +08:00
|
|
|
</label>
|
2022-10-30 23:07:43 +08:00
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.dynamicLoadBlocks}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.dynamicLoadBlocksTip}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="fn__space"></span>
|
2022-10-31 10:01:25 +08:00
|
|
|
<input class="b3-text-field fn__flex-center fn__size200" id="dynamicLoadBlocks" type="number" min="48" max="1024" value="${window.siyuan.config.editor.dynamicLoadBlocks}"/>
|
2022-10-30 23:07:43 +08:00
|
|
|
</label>
|
2022-05-26 15:18:53 +08:00
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
|
<div class="fn__flex-1">
|
2022-08-27 22:58:13 +08:00
|
|
|
${window.siyuan.languages.md37}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.md38}</div>
|
2022-05-26 15:18:53 +08:00
|
|
|
</div>
|
|
|
|
|
<span class="fn__space"></span>
|
2022-08-27 22:58:13 +08:00
|
|
|
<input class="b3-text-field fn__flex-center fn__size200" id="blockRefDynamicAnchorTextMaxLen" type="number" min="1" max="5120" value="${window.siyuan.config.editor.blockRefDynamicAnchorTextMaxLen}"/>
|
|
|
|
|
</label>
|
|
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.generateHistory}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.generateHistoryInterval}</div>
|
2022-05-26 15:18:53 +08:00
|
|
|
</div>
|
2022-08-27 22:58:13 +08:00
|
|
|
<span class="fn__space"></span>
|
|
|
|
|
<input class="b3-text-field fn__flex-center fn__size200" id="generateHistoryInterval" type="number" min="0" max="120" value="${window.siyuan.config.editor.generateHistoryInterval}"/>
|
2022-05-26 15:18:53 +08:00
|
|
|
</label>
|
|
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
|
<div class="fn__flex-1">
|
2022-08-27 22:58:13 +08:00
|
|
|
${window.siyuan.languages.historyRetentionDays}
|
|
|
|
|
<a href="javascript:void(0)" id="clearHistory">${window.siyuan.languages.clearHistory}</a>
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.historyRetentionDaysTip}</div>
|
2022-05-26 15:18:53 +08:00
|
|
|
</div>
|
|
|
|
|
<span class="fn__space"></span>
|
2022-08-27 22:58:13 +08:00
|
|
|
<input class="b3-text-field fn__flex-center fn__size200" id="historyRetentionDays" type="number" min="0" max="120" value="${window.siyuan.config.editor.historyRetentionDays}"/>
|
2022-05-26 15:18:53 +08:00
|
|
|
</label>
|
|
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
|
<div class="fn__flex-1">
|
2022-08-27 22:58:13 +08:00
|
|
|
${window.siyuan.languages.font}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.font1}</div>
|
2022-05-26 15:18:53 +08:00
|
|
|
</div>
|
|
|
|
|
<span class="fn__space"></span>
|
2022-08-27 22:58:13 +08:00
|
|
|
${fontFamilyHTML}
|
2022-05-26 15:18:53 +08:00
|
|
|
</label>
|
|
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
|
<div class="fn__flex-1">
|
2022-08-27 22:58:13 +08:00
|
|
|
${window.siyuan.languages.fontSize}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.fontSizeTip}</div>
|
2022-05-26 15:18:53 +08:00
|
|
|
</div>
|
|
|
|
|
<span class="fn__space"></span>
|
2022-08-27 22:58:13 +08:00
|
|
|
<div class="b3-tooltips b3-tooltips__n fn__flex-center" aria-label="${window.siyuan.config.editor.fontSize}">
|
|
|
|
|
<input class="b3-slider fn__size200" id="fontSize" max="72" min="9" step="1" type="range" value="${window.siyuan.config.editor.fontSize}">
|
|
|
|
|
</div>
|
2022-05-26 15:18:53 +08:00
|
|
|
</label>
|
|
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
|
<div class="fn__flex-1">
|
2022-08-27 22:58:13 +08:00
|
|
|
${window.siyuan.languages.md29}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.md30}</div>
|
2022-05-26 15:18:53 +08:00
|
|
|
</div>
|
|
|
|
|
<span class="fn__space"></span>
|
2022-08-27 22:58:13 +08:00
|
|
|
<div class="b3-tooltips b3-tooltips__n fn__flex-center" aria-label="${window.siyuan.config.editor.codeTabSpaces}">
|
|
|
|
|
<input class="b3-slider fn__size200" id="codeTabSpaces" max="8" min="0" step="2" type="range" value="${window.siyuan.config.editor.codeTabSpaces}">
|
|
|
|
|
</div>
|
|
|
|
|
</label>
|
2022-10-18 00:03:34 +08:00
|
|
|
<label class="b3-label fn__flex">
|
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.katexMacros}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.katexMacrosTip}</div>
|
|
|
|
|
<div class="fn__hr"></div>
|
|
|
|
|
<textarea class="b3-text-field fn__block" id="katexMacros">${window.siyuan.config.editor.katexMacros}</textarea>
|
|
|
|
|
</div>
|
|
|
|
|
</label>`;
|
2022-05-26 15:18:53 +08:00
|
|
|
},
|
|
|
|
|
bindEvent: () => {
|
|
|
|
|
const fontFamilyElement = editor.element.querySelector("#fontFamily") as HTMLSelectElement;
|
|
|
|
|
if (fontFamilyElement.tagName === "SELECT") {
|
|
|
|
|
let fontFamilyHTML = `<option value="">${window.siyuan.languages.default}</option>`;
|
|
|
|
|
fetchPost("/api/system/getSysFonts", {}, (response) => {
|
|
|
|
|
response.data.forEach((item: string) => {
|
|
|
|
|
fontFamilyHTML += `<option value="${item}"${window.siyuan.config.editor.fontFamily === item ? " selected" : ""}>${item}</option>`;
|
|
|
|
|
});
|
|
|
|
|
fontFamilyElement.innerHTML = fontFamilyHTML;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
editor.element.querySelector("#clearHistory").addEventListener("click", () => {
|
|
|
|
|
confirmDialog(window.siyuan.languages.clearHistory, window.siyuan.languages.confirmClearHistory, () => {
|
|
|
|
|
fetchPost("/api/history/clearWorkspaceHistory", {});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const setEditor = () => {
|
2022-10-31 00:02:45 +08:00
|
|
|
let dynamicLoadBlocks = parseInt((editor.element.querySelector("#dynamicLoadBlocks") as HTMLInputElement).value);
|
2022-10-31 10:01:25 +08:00
|
|
|
if (48 > dynamicLoadBlocks) {
|
|
|
|
|
dynamicLoadBlocks = 48;
|
|
|
|
|
(editor.element.querySelector("#dynamicLoadBlocks") as HTMLInputElement).value = "48";
|
2022-10-30 23:35:29 +08:00
|
|
|
}
|
|
|
|
|
if (1024 < dynamicLoadBlocks) {
|
|
|
|
|
dynamicLoadBlocks = 1024;
|
|
|
|
|
(editor.element.querySelector("#dynamicLoadBlocks") as HTMLInputElement).value = "1024";
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-26 15:18:53 +08:00
|
|
|
fetchPost("/api/setting/setEditor", {
|
2022-06-30 22:44:50 +08:00
|
|
|
fullWidth: (editor.element.querySelector("#fullWidth") as HTMLInputElement).checked,
|
2022-11-01 10:51:06 +08:00
|
|
|
justify: (editor.element.querySelector("#justify") as HTMLInputElement).checked,
|
|
|
|
|
rtl: (editor.element.querySelector("#rtl") as HTMLInputElement).checked,
|
2022-10-11 22:09:15 +08:00
|
|
|
readOnly: (editor.element.querySelector("#readOnly") as HTMLInputElement).checked,
|
2022-05-26 15:18:53 +08:00
|
|
|
displayBookmarkIcon: (editor.element.querySelector("#displayBookmarkIcon") as HTMLInputElement).checked,
|
|
|
|
|
displayNetImgMark: (editor.element.querySelector("#displayNetImgMark") as HTMLInputElement).checked,
|
|
|
|
|
codeSyntaxHighlightLineNum: (editor.element.querySelector("#codeSyntaxHighlightLineNum") as HTMLInputElement).checked,
|
2022-10-17 10:37:01 +08:00
|
|
|
embedBlockBreadcrumb: (editor.element.querySelector("#embedBlockBreadcrumb") as HTMLInputElement).checked,
|
2022-10-24 11:24:59 +08:00
|
|
|
listLogicalOutdent: (editor.element.querySelector("#listLogicalOutdent") as HTMLInputElement).checked,
|
2022-10-28 20:13:37 +08:00
|
|
|
floatWindowMode: (editor.element.querySelector("#floatWindowMode") as HTMLInputElement).checked ? 0 : 1,
|
2022-05-26 15:18:53 +08:00
|
|
|
plantUMLServePath: (editor.element.querySelector("#plantUMLServePath") as HTMLInputElement).value,
|
2022-08-27 22:58:13 +08:00
|
|
|
katexMacros: (editor.element.querySelector("#katexMacros") as HTMLTextAreaElement).value,
|
2022-05-26 15:18:53 +08:00
|
|
|
codeLineWrap: (editor.element.querySelector("#codeLineWrap") as HTMLInputElement).checked,
|
|
|
|
|
virtualBlockRef: (editor.element.querySelector("#virtualBlockRef") as HTMLInputElement).checked,
|
2022-10-26 09:24:07 +08:00
|
|
|
virtualBlockRefInclude: (editor.element.querySelector("#virtualBlockRefInclude") as HTMLInputElement).value,
|
2022-05-26 15:18:53 +08:00
|
|
|
virtualBlockRefExclude: (editor.element.querySelector("#virtualBlockRefExclude") as HTMLInputElement).value,
|
|
|
|
|
blockRefDynamicAnchorTextMaxLen: parseInt((editor.element.querySelector("#blockRefDynamicAnchorTextMaxLen") as HTMLInputElement).value),
|
2022-10-30 23:35:29 +08:00
|
|
|
dynamicLoadBlocks: dynamicLoadBlocks,
|
2022-05-26 15:18:53 +08:00
|
|
|
codeLigatures: (editor.element.querySelector("#codeLigatures") as HTMLInputElement).checked,
|
|
|
|
|
codeTabSpaces: parseInt((editor.element.querySelector("#codeTabSpaces") as HTMLInputElement).value),
|
|
|
|
|
fontSize: parseInt((editor.element.querySelector("#fontSize") as HTMLInputElement).value),
|
|
|
|
|
generateHistoryInterval: parseInt((editor.element.querySelector("#generateHistoryInterval") as HTMLInputElement).value),
|
|
|
|
|
historyRetentionDays: parseInt((editor.element.querySelector("#historyRetentionDays") as HTMLInputElement).value),
|
|
|
|
|
fontFamily: fontFamilyElement.value,
|
|
|
|
|
emoji: window.siyuan.config.editor.emoji
|
|
|
|
|
}, response => {
|
|
|
|
|
editor.onSetEditor(response.data);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
editor.element.querySelectorAll("input.b3-switch, select.b3-select, input.b3-slider").forEach((item) => {
|
|
|
|
|
item.addEventListener("change", () => {
|
|
|
|
|
setEditor();
|
|
|
|
|
});
|
|
|
|
|
});
|
2022-08-27 22:58:13 +08:00
|
|
|
editor.element.querySelectorAll("textarea.b3-text-field, input.b3-text-field, input.b3-slider").forEach((item) => {
|
2022-05-26 15:18:53 +08:00
|
|
|
item.addEventListener("blur", () => {
|
|
|
|
|
setEditor();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
editor.element.querySelectorAll("input.b3-slider").forEach((item) => {
|
|
|
|
|
item.addEventListener("input", (event) => {
|
|
|
|
|
const target = event.target as HTMLInputElement;
|
|
|
|
|
target.parentElement.setAttribute("aria-label", target.value);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
2022-10-11 23:38:14 +08:00
|
|
|
onSetEditor: (editorData: IEditor) => {
|
|
|
|
|
if (editorData.readOnly !== window.siyuan.config.editor.readOnly) {
|
|
|
|
|
editor.setMode(editorData.readOnly);
|
|
|
|
|
}
|
|
|
|
|
window.siyuan.config.editor = editorData;
|
2022-05-26 15:18:53 +08:00
|
|
|
getAllModels().editor.forEach((item) => {
|
2022-08-31 13:19:03 +08:00
|
|
|
reloadProtyle(item.editor.protyle);
|
2022-06-30 22:44:50 +08:00
|
|
|
setPadding(item.editor.protyle);
|
2022-07-21 10:03:54 +08:00
|
|
|
if (window.siyuan.config.editor.fullWidth) {
|
2022-07-28 21:36:18 +08:00
|
|
|
item.editor.protyle.contentElement.setAttribute("data-fullwidth", "true");
|
2022-07-21 10:03:54 +08:00
|
|
|
} else {
|
2022-07-28 21:36:18 +08:00
|
|
|
item.editor.protyle.contentElement.removeAttribute("data-fullwidth");
|
2022-07-21 10:03:54 +08:00
|
|
|
}
|
2022-05-26 15:18:53 +08:00
|
|
|
});
|
|
|
|
|
setInlineStyle();
|
|
|
|
|
}
|
|
|
|
|
};
|