This commit is contained in:
Vanessa 2023-06-01 20:50:49 +08:00
parent fd0893d8d8
commit 6806392b41
57 changed files with 271 additions and 360 deletions

View file

@ -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");

View file

@ -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;
};

View file

@ -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")) {