This commit is contained in:
Vanessa 2022-10-27 23:06:50 +08:00
parent ccef05208b
commit fae96fd141
4 changed files with 10 additions and 11 deletions

View file

@ -211,10 +211,10 @@ export const appearance = {
},
bindEvent: () => {
appearance.element.querySelector("#codeSnippet").addEventListener("click", () => {
openSnippets()
openSnippets();
});
appearance.element.querySelector("#appearanceCustomSetting").addEventListener("click", () => {
openColorPicker()
openColorPicker();
});
appearance.element.querySelector("#resetLayout").addEventListener("click", () => {
fetchPost("/api/system/setUILayout", {layout: {}}, () => {
@ -253,7 +253,6 @@ export const appearance = {
}
window.siyuan.config.appearance = data;
if (appearance.element) {
const theme = data.mode === 0 ? data.themeLight : data.themeDark;
const modeElement = appearance.element.querySelector("#mode") as HTMLSelectElement;
if (modeElement) {
if (data.modeOS) {

View file

@ -3,7 +3,7 @@ import {Dialog} from "../../dialog";
import * as Pickr from "@simonwep/pickr";
export const openColorPicker = () => {
const theme = window.siyuan.config.appearance.mode === 0 ? window.siyuan.config.appearance.themeLight : window.siyuan.config.appearance.themeDark
const theme = window.siyuan.config.appearance.mode === 0 ? window.siyuan.config.appearance.themeLight : window.siyuan.config.appearance.themeDark;
fetchPost("/api/setting/getCustomCSS", {
theme
}, response => {
@ -26,7 +26,7 @@ export const openColorPicker = () => {
<button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div>
<button class="b3-button b3-button--text">${window.siyuan.languages.confirm}</button>
</div>`
})
});
const pickrs: Record<string, Record<string, any>> = {};
dialog.element.querySelectorAll(".colorPicker").forEach((item: HTMLInputElement) => {
// @ts-ignore
@ -52,8 +52,8 @@ export const openColorPicker = () => {
pickrs[key][item.getAttribute("data-subkey")] = pickr;
});
dialog.element.querySelector(".b3-button--cancel").addEventListener("click", () => {
dialog.destroy()
})
dialog.destroy();
});
dialog.element.querySelector(".b3-button--text").addEventListener("click", () => {
const css: Record<string, Record<string, string>> = {};
Object.keys(pickrs).forEach((item) => {
@ -66,7 +66,7 @@ export const openColorPicker = () => {
theme,
css
});
dialog.destroy()
dialog.destroy();
});
});
}
};

View file

@ -106,7 +106,7 @@ export const openSnippets = () => {
type: item.getAttribute("data-type"),
content: item.querySelector("textarea").value,
enabled: (item.querySelector(".b3-switch") as HTMLInputElement).checked
})
});
});
fetchPost("/api/snippet/setSnippet", {snippets}, () => {
renderSnippet();

View file

@ -197,7 +197,7 @@ export class WYSIWYG {
}
event.stopPropagation();
event.preventDefault();
window.siyuan.ctrlIsPressed = false // https://github.com/siyuan-note/siyuan/issues/6373
window.siyuan.ctrlIsPressed = false; // https://github.com/siyuan-note/siyuan/issues/6373
const range = getEditorRange(protyle.wysiwyg.element);
const nodeElement = hasClosestBlock(range.startContainer);
if (!nodeElement) {