Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Clean code

Daniel21823e11d861
diff --git a/app/electron/main.js b/app/electron/main.js
index 203b864b21..66a1c18631 100644
--- a/app/electron/main.js
+++ b/app/electron/main.js
@@ -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;
diff --git a/app/src/boot/globalEvent/commandPanel.ts b/app/src/boot/globalEvent/commandPanel.ts
index 387340eb9c..db10848707 100644
--- a/app/src/boot/globalEvent/commandPanel.ts
+++ b/app/src/boot/globalEvent/commandPanel.ts
@@ -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();
diff --git a/app/src/boot/onGetConfig.ts b/app/src/boot/onGetConfig.ts
index 57e0cbad41..fbb3a1f82f 100644
--- a/app/src/boot/onGetConfig.ts
+++ b/app/src/boot/onGetConfig.ts
@@ -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;
diff --git a/app/src/config/about.ts b/app/src/config/about.ts
index cfe0444f08..67ed8a8079 100644
--- a/app/src/config/about.ts
+++ b/app/src/config/about.ts
@@ -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, {
diff --git a/app/src/config/editor.ts b/app/src/config/editor.ts
index 88e774ded1..2b0a9d29ba 100644
--- a/app/src/config/editor.ts
+++ b/app/src/config/editor.ts
@@ -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,
diff --git a/app/src/editor/util.ts b/app/src/editor/util.ts
index e4ab2f499e..4a1366371b 100644
--- a/app/src/editor/util.ts
+++ b/app/src/editor/util.ts
@@ -750,4 +750,4 @@ export const openLink = (protyle: IProtyle, aLink: string, event?: MouseEvent, c
/// #endif
}
/// #endif
-}
+};
diff --git a/app/src/history/history.ts b/app/src/history/history.ts
index f239b39ae2..0dff8cd62c 100644
--- a/app/src/history/history.ts
+++ b/app/src/history/history.ts
@@ -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,
diff --git a/app/src/menus/onGetnotebookconf.ts b/app/src/menus/onGetnotebookconf.ts
index a7de89d446..85d255f027 100644
--- a/app/src/menus/onGetnotebookconf.ts
+++ b/app/src/menus/onGetnotebookconf.ts
@@ -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)}
diff --git a/app/src/protyle/header/Background.ts b/app/src/protyle/header/Background.ts
index 34078c13f5..6ec8267d4c 100644
--- a/app/src/protyle/header/Background.ts
+++ b/app/src/protyle/header/Background.ts
@@ -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";
}
}
diff --git a/app/src/protyle/ui/initUI.ts b/app/src/protyle/ui/initUI.ts
index 91dfc907ab..ce3ad7a75b 100644
--- a/app/src/protyle/ui/initUI.ts
+++ b/app/src/protyle/ui/initUI.ts
@@ -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);
}
diff --git a/app/src/protyle/util/hotKey.ts b/app/src/protyle/util/hotKey.ts
index 8e020ee679..c4c38d24ab 100644
--- a/app/src/protyle/util/hotKey.ts
+++ b/app/src/protyle/util/hotKey.ts
@@ -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) {
diff --git a/app/src/protyle/wysiwyg/input.ts b/app/src/protyle/wysiwyg/input.ts
index 95927c6d7a..919a708f23 100644
--- a/app/src/protyle/wysiwyg/input.ts
+++ b/app/src/protyle/wysiwyg/input.ts
@@ -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")) {