🎨 Clean code
This commit is contained in:
parent
215f37a072
commit
21823e11d8
12 changed files with 39 additions and 39 deletions
|
@ -231,9 +231,9 @@ const writeLog = (out) => {
|
|||
};
|
||||
|
||||
let openAsHidden = false;
|
||||
isOpenAsHidden = function () {
|
||||
const isOpenAsHidden = function () {
|
||||
return 1 === workspaces.length && openAsHidden;
|
||||
}
|
||||
};
|
||||
|
||||
const initMainWindow = () => {
|
||||
let windowStateInitialized = true;
|
||||
|
|
|
@ -19,7 +19,7 @@ import {Files} from "../../layout/dock/Files";
|
|||
/// #endif
|
||||
|
||||
export const commandPanel = (app: App) => {
|
||||
const range = getSelection().getRangeAt(0)
|
||||
const range = getSelection().getRangeAt(0);
|
||||
const dialog = new Dialog({
|
||||
width: isMobile() ? "92vw" : "80vw",
|
||||
height: isMobile() ? "80vh" : "70vh",
|
||||
|
@ -83,7 +83,7 @@ export const commandPanel = (app: App) => {
|
|||
inputElement.focus();
|
||||
/// #if !MOBILE
|
||||
listElement.addEventListener("click", (event: KeyboardEvent) => {
|
||||
const liElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item")
|
||||
const liElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item");
|
||||
if (liElement) {
|
||||
const command = liElement.getAttribute("data-command");
|
||||
if (command) {
|
||||
|
@ -93,7 +93,7 @@ export const commandPanel = (app: App) => {
|
|||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
/// #endif
|
||||
inputElement.addEventListener("keydown", (event: KeyboardEvent) => {
|
||||
event.stopPropagation();
|
||||
|
|
|
@ -34,7 +34,7 @@ const matchKeymap = (keymap: Config.IKeys, key1: "general" | "editor", key2?: "g
|
|||
if (!window.siyuan.config.keymap[key1]) {
|
||||
ipcRenderer.send(Constants.SIYUAN_CMD, {
|
||||
cmd: "writeLog",
|
||||
msg: 'window.siyuan.config.keymap.general is not found'
|
||||
msg: "window.siyuan.config.keymap.general is not found"
|
||||
});
|
||||
window.siyuan.config.keymap[key1] = keymap as Config.IKeymapGeneral;
|
||||
return false;
|
||||
|
@ -43,7 +43,7 @@ const matchKeymap = (keymap: Config.IKeys, key1: "general" | "editor", key2?: "g
|
|||
if (!window.siyuan.config.keymap[key1]) {
|
||||
ipcRenderer.send(Constants.SIYUAN_CMD, {
|
||||
cmd: "writeLog",
|
||||
msg: 'window.siyuan.config.keymap.editor is not found'
|
||||
msg: "window.siyuan.config.keymap.editor is not found"
|
||||
});
|
||||
window.siyuan.config.keymap[key1] = JSON.parse(JSON.stringify(Constants.SIYUAN_KEYMAP.editor));
|
||||
return false;
|
||||
|
|
|
@ -352,7 +352,7 @@ export const about = {
|
|||
/// #if !BROWSER
|
||||
const autoLaunchElement = about.element.querySelector("#autoLaunch") as HTMLInputElement;
|
||||
autoLaunchElement.addEventListener("change", () => {
|
||||
const autoLaunchMode = parseInt(autoLaunchElement.value)
|
||||
const autoLaunchMode = parseInt(autoLaunchElement.value);
|
||||
fetchPost("/api/system/setAutoLaunch", {autoLaunch: autoLaunchMode}, () => {
|
||||
window.siyuan.config.system.autoLaunch2 = autoLaunchMode;
|
||||
ipcRenderer.send(Constants.SIYUAN_AUTO_LAUNCH, {
|
||||
|
|
|
@ -336,7 +336,7 @@ export const editor = {
|
|||
(editor.element.querySelector("#dynamicLoadBlocks") as HTMLInputElement).value = "1024";
|
||||
}
|
||||
|
||||
let markdown = {
|
||||
const markdown = {
|
||||
inlineSup: (editor.element.querySelector("#editorMarkdownInlineSup") as HTMLInputElement).checked,
|
||||
inlineSub: (editor.element.querySelector("#editorMarkdownInlineSub") as HTMLInputElement).checked,
|
||||
inlineTag: (editor.element.querySelector("#editorMarkdownInlineTag") as HTMLInputElement).checked,
|
||||
|
|
|
@ -750,4 +750,4 @@ export const openLink = (protyle: IProtyle, aLink: string, event?: MouseEvent, c
|
|||
/// #endif
|
||||
}
|
||||
/// #endif
|
||||
}
|
||||
};
|
||||
|
|
|
@ -42,25 +42,25 @@ const renderDoc = (element: HTMLElement, currentPage: number) => {
|
|||
if (window.siyuan.storage[Constants.LOCAL_HISTORY].type !== 2) {
|
||||
opElement.value = "all";
|
||||
}
|
||||
opElement.querySelector('option[value="clean"]').classList.remove("fn__none")
|
||||
opElement.querySelector('option[value="update"]').classList.remove("fn__none")
|
||||
opElement.querySelector('option[value="delete"]').classList.add("fn__none")
|
||||
opElement.querySelector('option[value="format"]').classList.add("fn__none")
|
||||
opElement.querySelector('option[value="sync"]').classList.remove("fn__none")
|
||||
opElement.querySelector('option[value="replace"]').classList.add("fn__none")
|
||||
opElement.querySelector('option[value="outline"]').classList.add("fn__none")
|
||||
opElement.querySelector('option[value="clean"]').classList.remove("fn__none");
|
||||
opElement.querySelector('option[value="update"]').classList.remove("fn__none");
|
||||
opElement.querySelector('option[value="delete"]').classList.add("fn__none");
|
||||
opElement.querySelector('option[value="format"]').classList.add("fn__none");
|
||||
opElement.querySelector('option[value="sync"]').classList.remove("fn__none");
|
||||
opElement.querySelector('option[value="replace"]').classList.add("fn__none");
|
||||
opElement.querySelector('option[value="outline"]').classList.add("fn__none");
|
||||
} else {
|
||||
notebookElement.removeAttribute("disabled");
|
||||
if (window.siyuan.storage[Constants.LOCAL_HISTORY].type === 2) {
|
||||
opElement.value = "all";
|
||||
}
|
||||
opElement.querySelector('option[value="clean"]').classList.add("fn__none")
|
||||
opElement.querySelector('option[value="update"]').classList.remove("fn__none")
|
||||
opElement.querySelector('option[value="delete"]').classList.remove("fn__none")
|
||||
opElement.querySelector('option[value="format"]').classList.remove("fn__none")
|
||||
opElement.querySelector('option[value="sync"]').classList.remove("fn__none")
|
||||
opElement.querySelector('option[value="replace"]').classList.remove("fn__none")
|
||||
opElement.querySelector('option[value="outline"]').classList.remove("fn__none")
|
||||
opElement.querySelector('option[value="clean"]').classList.add("fn__none");
|
||||
opElement.querySelector('option[value="update"]').classList.remove("fn__none");
|
||||
opElement.querySelector('option[value="delete"]').classList.remove("fn__none");
|
||||
opElement.querySelector('option[value="format"]').classList.remove("fn__none");
|
||||
opElement.querySelector('option[value="sync"]').classList.remove("fn__none");
|
||||
opElement.querySelector('option[value="replace"]').classList.remove("fn__none");
|
||||
opElement.querySelector('option[value="outline"]').classList.remove("fn__none");
|
||||
}
|
||||
window.siyuan.storage[Constants.LOCAL_HISTORY] = {
|
||||
notebookId: notebookElement.value,
|
||||
|
|
|
@ -33,7 +33,7 @@ export const genNotebookOption = (id: string, notebookId?: string) => {
|
|||
html += `<option value="${item.id}" ${id === item.id ? "selected" : ""}>${item.name}</option>`;
|
||||
});
|
||||
return html;
|
||||
}
|
||||
};
|
||||
|
||||
export const onGetnotebookconf = (data: INotebookConf) => {
|
||||
const titleHTML = `<div class="fn__flex">${escapeHtml(data.name)}
|
||||
|
|
|
@ -452,20 +452,20 @@ export class Background {
|
|||
html += `<div class="b3-chip b3-chip--middle b3-chip--pointer b3-chip--${colors[index % 7]}" data-type="open-search">${item}<svg class="b3-chip__close" data-type="remove-tag"><use xlink:href="#iconCloseRound"></use></svg></div>`;
|
||||
});
|
||||
this.tagsElement.innerHTML = `${html}<span class="fn__space"></span>
|
||||
<button class="b3-button b3-button--cancel fn__flex-center" data-menu="true" data-type="tag"><svg><use xlink:href="#iconAdd"></use></svg>${window.siyuan.languages.addTag}</button>`
|
||||
this.tagsElement.classList.remove("fn__none")
|
||||
this.actionElements[0].classList.add("fn__none")
|
||||
<button class="b3-button b3-button--cancel fn__flex-center" data-menu="true" data-type="tag"><svg><use xlink:href="#iconAdd"></use></svg>${window.siyuan.languages.addTag}</button>`;
|
||||
this.tagsElement.classList.remove("fn__none");
|
||||
this.actionElements[0].classList.add("fn__none");
|
||||
} else {
|
||||
this.tagsElement.classList.add("fn__none")
|
||||
this.actionElements[0].classList.remove("fn__none")
|
||||
this.tagsElement.classList.add("fn__none");
|
||||
this.actionElements[0].classList.remove("fn__none");
|
||||
}
|
||||
|
||||
if (icon) {
|
||||
this.iconElement.classList.remove("fn__none");
|
||||
this.iconElement.innerHTML = unicode2Emoji(icon);
|
||||
this.actionElements[1].classList.add("fn__none")
|
||||
this.actionElements[1].classList.add("fn__none");
|
||||
} else {
|
||||
this.actionElements[1].classList.remove("fn__none")
|
||||
this.actionElements[1].classList.remove("fn__none");
|
||||
this.iconElement.classList.add("fn__none");
|
||||
}
|
||||
|
||||
|
@ -483,16 +483,16 @@ export class Background {
|
|||
this.imgElement.setAttribute("src", this.transparentData);
|
||||
this.element.querySelector('[data-type="position"]').classList.add("fn__none");
|
||||
}
|
||||
this.actionElements[2].classList.add("fn__none")
|
||||
this.actionElements[2].classList.add("fn__none");
|
||||
this.imgElement.parentElement.classList.remove("fn__none");
|
||||
this.iconElement.style.marginTop = "";
|
||||
/// #if MOBILE
|
||||
// 移动端键盘弹起和点击加号需保持滚动高度一致
|
||||
this.imgElement.style.height = "200px"
|
||||
this.imgElement.style.height = "200px";
|
||||
/// #endif
|
||||
} else {
|
||||
this.imgElement.parentElement.classList.add("fn__none");
|
||||
this.actionElements[2].classList.remove("fn__none")
|
||||
this.actionElements[2].classList.remove("fn__none");
|
||||
this.iconElement.style.marginTop = "8px";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import {lineNumberRender} from "../render/highlightRender";
|
|||
export const initUI = (protyle: IProtyle) => {
|
||||
protyle.contentElement = document.createElement("div");
|
||||
protyle.contentElement.className = "protyle-content";
|
||||
protyle.contentElement.innerHTML = `<div class="protyle-top"></div>`
|
||||
protyle.contentElement.innerHTML = "<div class=\"protyle-top\"></div>";
|
||||
if (protyle.options.render.background) {
|
||||
protyle.contentElement.firstElementChild.appendChild(protyle.background.element);
|
||||
}
|
||||
|
|
|
@ -48,9 +48,9 @@ const replaceDirect = (hotKey: string, keyCode: string) => {
|
|||
if (item === Constants.ZWSP) {
|
||||
hotKeys[index] = keyCode;
|
||||
}
|
||||
})
|
||||
});
|
||||
return hotKeys;
|
||||
}
|
||||
};
|
||||
|
||||
export const matchHotKey = (hotKey: string, event: KeyboardEvent) => {
|
||||
if (!hotKey) {
|
||||
|
|
|
@ -224,7 +224,7 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range:
|
|||
mathRender(realElement);
|
||||
if (index === tempElement.content.childElementCount - 1) {
|
||||
// https://github.com/siyuan-note/siyuan/issues/11156
|
||||
const currentWbrElement = blockElement.querySelector("wbr")
|
||||
const currentWbrElement = blockElement.querySelector("wbr");
|
||||
if (currentWbrElement && currentWbrElement.parentElement.tagName === "SPAN" && currentWbrElement.parentElement.innerHTML === "<wbr>") {
|
||||
const types = currentWbrElement.parentElement.getAttribute("data-type") || "";
|
||||
if (types.includes("sup") || types.includes("u") || types.includes("sub")) {
|
||||
|
|
Loading…
Add table
Reference in a new issue