Skip to content

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

:rotating_light:

Vanessa087826036141
diff --git a/app/src/card/openCard.ts b/app/src/card/openCard.ts
index 560739ce6b..ae023c2614 100644
--- a/app/src/card/openCard.ts
+++ b/app/src/card/openCard.ts
@@ -24,7 +24,7 @@ const genCardCount = (unreviewedNewCardCount: number, unreviewedOldCardCount: nu
<span class="ariaLabel ft__primary" aria-label="${window.siyuan.languages.flashcardNewCard}">${unreviewedNewCardCount}</span>
<span class="fn__space"></span>+<span class="fn__space"></span>
<span class="ariaLabel ft__success" aria-label="${window.siyuan.languages.flashcardReviewCard}">${unreviewedOldCardCount}</span>`;
-}
+};
export const genCardHTML = (options: {
id: string,
diff --git a/app/src/dialog/index.ts b/app/src/dialog/index.ts
index 9e43256f17..f18458f6e8 100644
--- a/app/src/dialog/index.ts
+++ b/app/src/dialog/index.ts
@@ -33,8 +33,8 @@ export class Dialog {
window.siyuan.dialogs.push(this);
this.destroyCallback = options.destroyCallback;
this.element = document.createElement("div") as HTMLElement;
- let left
- let top
+ let left;
+ let top;
if (!isMobile() && options.positionId) {
const dialogPosition = window.siyuan.storage[Constants.LOCAL_DIALOGPOSITION][options.positionId];
if (dialogPosition) {
diff --git a/app/src/dialog/moveResize.ts b/app/src/dialog/moveResize.ts
index fb50d06437..f89956bb63 100644
--- a/app/src/dialog/moveResize.ts
+++ b/app/src/dialog/moveResize.ts
@@ -133,8 +133,8 @@ export const moveResize = (element: HTMLElement, afterCB?: (type: string) => voi
documentSelf.ondragstart = null;
documentSelf.onselectstart = null;
documentSelf.onselect = null;
- hideAllElements(["gutter"])
- const dialogElement = hasClosestByClassName(element, "b3-dialog--open")
+ hideAllElements(["gutter"]);
+ const dialogElement = hasClosestByClassName(element, "b3-dialog--open");
if (dialogElement) {
const dialogId = dialogElement.dataset.key;
if (dialogId && element.offsetWidth) {
@@ -143,7 +143,7 @@ export const moveResize = (element: HTMLElement, afterCB?: (type: string) => voi
height: element.offsetHeight,
left: parseInt(element.style.left),
top: parseInt(element.style.top),
- }
+ };
setStorageVal(Constants.LOCAL_DIALOGPOSITION, window.siyuan.storage[Constants.LOCAL_DIALOGPOSITION]);
}
}
diff --git a/app/src/mobile/index.ts b/app/src/mobile/index.ts
index 8197c9dee2..302bbd0446 100644
--- a/app/src/mobile/index.ts
+++ b/app/src/mobile/index.ts
@@ -21,11 +21,10 @@ import {getSearch} from "../util/functions";
import {initRightMenu} from "./menu";
import {openChangelog} from "../boot/openChangelog";
import {registerServiceWorker} from "../util/serviceWorker";
-import {afterLoadPlugin, loadPlugins} from "../plugin/loader";
+import {loadPlugins} from "../plugin/loader";
import {saveScroll} from "../protyle/scroll/saveScroll";
import {removeBlock} from "../protyle/wysiwyg/remove";
import {isNotEditBlock} from "../protyle/wysiwyg/getBlock";
-import {Menu} from "../plugin/Menu";
class App {
public plugins: import("../plugin").Plugin[] = [];
diff --git a/app/src/mobile/util/initFramework.ts b/app/src/mobile/util/initFramework.ts
index efeac324b7..26b7de3aed 100644
--- a/app/src/mobile/util/initFramework.ts
+++ b/app/src/mobile/util/initFramework.ts
@@ -46,14 +46,14 @@ const openDockMenu = (app: App) => {
custom = plugin.docks[dockId].mobileModel(document.querySelector('#sidebar [data-type="sidebar-plugin"]'));
}
}
- })
+ });
});
});
menu.fullscreen("bottom");
if (menu.element.lastElementChild.innerHTML === "") {
showMessage(window.siyuan.languages._kernel[122]);
}
-}
+};
export const initFramework = (app: App, isStart: boolean) => {
setInlineStyle();
diff --git a/app/src/protyle/export/util.ts b/app/src/protyle/export/util.ts
index f7bb4beaef..a8e602a249 100644
--- a/app/src/protyle/export/util.ts
+++ b/app/src/protyle/export/util.ts
@@ -143,7 +143,7 @@ id="preview"></div>
if (item.src.endsWith(".svg")) {
fetchGet(item.src, (response: string) => {
item.src = `data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(response)))}`;
- })
+ });
}
});
btnsElement[0].removeAttribute("disabled");
diff --git a/app/src/protyle/render/av/blockAttr.ts b/app/src/protyle/render/av/blockAttr.ts
index 85c48c30a8..1dba14585f 100644
--- a/app/src/protyle/render/av/blockAttr.ts
+++ b/app/src/protyle/render/av/blockAttr.ts
@@ -1,7 +1,6 @@
import {fetchPost} from "../../../util/fetch";
import {getColIconByType} from "./col";
import {escapeAttr} from "../../../util/escape";
-import {hasClosestByAttribute} from "../../util/hasClosest";
import * as dayjs from "dayjs";
import {popTextCell} from "./cell";
@@ -129,27 +128,27 @@ class="fn__flex-1 fn__flex${["url", "text", "number", "email", "phone"].includes
popTextCell(protyle, [target], "date");
event.stopPropagation();
event.preventDefault();
- break
+ break;
} else if (type === "select" || type === "mSelect") {
popTextCell(protyle, [target], target.getAttribute("data-type") as TAVCol);
event.stopPropagation();
event.preventDefault();
- break
+ break;
} else if (type === "mAsset") {
popTextCell(protyle, [target], "mAsset");
event.stopPropagation();
event.preventDefault();
- break
+ break;
} else if (type === "checkbox") {
popTextCell(protyle, [target], "checkbox");
event.stopPropagation();
event.preventDefault();
- break
+ break;
} else if (type === "relation") {
popTextCell(protyle, [target], "relation");
event.stopPropagation();
event.preventDefault();
- break
+ break;
}
target = target.parentElement;
}
diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts
index c4a2229453..9d51c702d2 100644
--- a/app/src/protyle/render/av/cell.ts
+++ b/app/src/protyle/render/av/cell.ts
@@ -540,7 +540,7 @@ export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, va
if (!hasClosestByClassName(cellElements[0], "custom-attr")) {
updateAttrViewCellAnimation(item, cellValue);
} else {
- item.innerHTML = genAVValueHTML(cellValue)
+ item.innerHTML = genAVValueHTML(cellValue);
}
});
if (doOperations.length > 0) {
@@ -615,7 +615,7 @@ export const renderCell = (cellValue: IAVCellValue, wrap: boolean) => {
} else if (cellValue.type === "relation") {
cellValue?.relation?.contents?.forEach((item, index) => {
text += `<span class="av__celltext--ref" style="margin-right: 8px" data-id="${cellValue?.relation?.blockIDs[index]}">${item}</span>`;
- })
+ });
}
if (["text", "template", "url", "email", "phone", "number", "date", "created", "updated"].includes(cellValue.type) &&
cellValue && cellValue[cellValue.type as "url"].content) {
diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.ts
index 3ff9afd78a..6a59fe0200 100644
--- a/app/src/protyle/render/av/col.ts
+++ b/app/src/protyle/render/av/col.ts
@@ -8,7 +8,7 @@ import {getLabelByNumberFormat} from "./number";
import {removeAttrViewColAnimation, updateAttrViewCellAnimation} from "./action";
import {openEmojiPanel, unicode2Emoji} from "../../../emoji";
import {focusBlock} from "../../util/selection";
-import {openSearchAV, toggleUpdateRelationBtn} from "./relation";
+import {toggleUpdateRelationBtn} from "./relation";
export const duplicateCol = (options: {
protyle: IProtyle,
@@ -334,21 +334,21 @@ export const bindEditEvent = (options: {
toggleUpdateRelationBtn(options.menuElement, avID);
});
const goSearchElement = options.menuElement.querySelector('[data-type="goSearchAV"]') as HTMLElement;
- const oldValue = JSON.parse(goSearchElement.getAttribute("data-old-value"))
- const inputElement = options.menuElement.querySelector('[data-type="colName"]') as HTMLInputElement
+ const oldValue = JSON.parse(goSearchElement.getAttribute("data-old-value"));
+ const inputElement = options.menuElement.querySelector('[data-type="colName"]') as HTMLInputElement;
inputElement.addEventListener("input", () => {
toggleUpdateRelationBtn(options.menuElement, avID);
- })
+ });
if (oldValue.avID) {
fetchPost("/api/av/getAttributeView", {id: oldValue.avID}, (response) => {
- goSearchElement.querySelector(".b3-menu__accelerator").textContent = oldValue.avID === avID ? window.siyuan.languages.thisDatabase : (response.data.av.name || window.siyuan.languages.title)
+ goSearchElement.querySelector(".b3-menu__accelerator").textContent = oldValue.avID === avID ? window.siyuan.languages.thisDatabase : (response.data.av.name || window.siyuan.languages.title);
response.data.av.keyValues.find((item: { key: { id: string, name: string } }) => {
if (item.key.id === oldValue.backKeyID) {
inputElement.setAttribute("data-old-value", item.key.name || window.siyuan.languages.title);
inputElement.value = item.key.name || window.siyuan.languages.title;
return true;
}
- })
+ });
toggleUpdateRelationBtn(options.menuElement, avID);
});
} else {
diff --git a/app/src/protyle/render/av/filter.ts b/app/src/protyle/render/av/filter.ts
index ba25d9d3a4..a846f87d80 100644
--- a/app/src/protyle/render/av/filter.ts
+++ b/app/src/protyle/render/av/filter.ts
@@ -241,12 +241,12 @@ export const setFilter = (options: {
});
});
} else if (["text", "url", "block", "email", "phone", "template", "relation"].includes(colData.type)) {
- let value = ""
+ let value = "";
if (options.filter.value) {
if (colData.type === "relation") {
- value = options.filter.value.relation.contents[0] || ""
+ value = options.filter.value.relation.contents[0] || "";
} else {
- value = options.filter.value[colData.type as "text"].content || ""
+ value = options.filter.value[colData.type as "text"].content || "";
}
}
menu.addItem({
diff --git a/app/src/protyle/render/av/relation.ts b/app/src/protyle/render/av/relation.ts
index 92a394f7b8..b7afb79a29 100644
--- a/app/src/protyle/render/av/relation.ts
+++ b/app/src/protyle/render/av/relation.ts
@@ -25,24 +25,24 @@ const genSearchList = (element: Element, keyword: string, avId: string, cb?: ()
<div class="b3-list-item__meta b3-list-item__showall">${escapeHtml(item.hPath)}</div>
</div>
<svg aria-label="${window.siyuan.languages.thisDatabase}" style="margin: 0 0 0 4px" class="b3-list-item__hinticon ariaLabel${item.avID === avId ? "" : " fn__none"}"><use xlink:href="#iconInfo"></use></svg>
-</div>`
+</div>`;
});
element.innerHTML = html;
if (cb) {
- cb()
+ cb();
}
- })
-}
+ });
+};
const setDatabase = (avId: string, element: HTMLElement, item: HTMLElement) => {
element.dataset.avId = item.dataset.avId;
element.dataset.blockId = item.dataset.blockId;
- element.querySelector(".b3-menu__accelerator").textContent = item.querySelector(".b3-list-item__hinticon").classList.contains("fn__none") ? item.querySelector(".b3-list-item__text").textContent : window.siyuan.languages.thisDatabase
- const menuElement = hasClosestByClassName(element, "b3-menu__items")
+ element.querySelector(".b3-menu__accelerator").textContent = item.querySelector(".b3-list-item__hinticon").classList.contains("fn__none") ? item.querySelector(".b3-list-item__text").textContent : window.siyuan.languages.thisDatabase;
+ const menuElement = hasClosestByClassName(element, "b3-menu__items");
if (menuElement) {
toggleUpdateRelationBtn(menuElement, avId, true);
}
-}
+};
export const openSearchAV = (avId: string, target: HTMLElement) => {
window.siyuan.menus.menu.remove();
@@ -83,7 +83,7 @@ export const openSearchAV = (avId: string, target: HTMLElement) => {
const listItemElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item");
if (listItemElement) {
event.stopPropagation();
- setDatabase(avId, target, listItemElement)
+ setDatabase(avId, target, listItemElement);
window.siyuan.menus.menu.remove();
}
});
@@ -93,13 +93,13 @@ export const openSearchAV = (avId: string, target: HTMLElement) => {
x: rect.left,
y: rect.bottom,
h: rect.height,
- })
+ });
element.querySelector("input").focus();
});
}
});
menu.element.querySelector(".b3-menu__items").setAttribute("style", "overflow: initial");
-}
+};
export const updateRelation = (options: {
protyle: IProtyle,
@@ -110,18 +110,18 @@ export const updateRelation = (options: {
}) => {
const inputElement = options.avElement.querySelector('input[data-type="colName"]') as HTMLInputElement;
const goSearchAVElement = options.avElement.querySelector('.b3-menu__item[data-type="goSearchAV"]') as HTMLElement;
- const newAVId = goSearchAVElement.getAttribute("data-av-id")
- const colId = options.avElement.querySelector(".b3-menu__item").getAttribute("data-col-id")
+ const newAVId = goSearchAVElement.getAttribute("data-av-id");
+ const colId = options.avElement.querySelector(".b3-menu__item").getAttribute("data-col-id");
let colData: IAVColumn;
options.colsData.find(item => {
if (item.id === colId) {
if (!item.relation) {
- item.relation = {}
+ item.relation = {};
}
colData = item;
return true;
}
- })
+ });
const colNewName = (options.avElement.querySelector('[data-type="name"]') as HTMLInputElement).value;
transaction(options.protyle, [{
action: "updateAttrViewColRelation",
@@ -145,10 +145,10 @@ export const updateRelation = (options: {
options.avElement.remove();
updateAttrViewCellAnimation(options.blockElement.querySelector(`.av__row--header .av__cell[data-col-id="${colId}"]`), undefined, {name: colNewName});
focusBlock(options.blockElement);
-}
+};
export const toggleUpdateRelationBtn = (menuItemsElement: HTMLElement, avId: string, resetData = false) => {
- const searchElement = menuItemsElement.querySelector('.b3-menu__item[data-type="goSearchAV"]') as HTMLElement
+ const searchElement = menuItemsElement.querySelector('.b3-menu__item[data-type="goSearchAV"]') as HTMLElement;
const switchItemElement = searchElement.nextElementSibling;
const switchElement = switchItemElement.querySelector(".b3-switch") as HTMLInputElement;
const inputItemElement = switchItemElement.nextElementSibling;
@@ -161,7 +161,7 @@ export const toggleUpdateRelationBtn = (menuItemsElement: HTMLElement, avId: str
inputElement.value = "";
switchElement.checked = false;
} else {
- inputElement.value = inputElement.dataset.oldValue
+ inputElement.value = inputElement.dataset.oldValue;
switchElement.checked = oldValue.isTwoWay;
}
}
@@ -190,7 +190,7 @@ export const toggleUpdateRelationBtn = (menuItemsElement: HTMLElement, avId: str
}
btnElement.classList.remove("fn__none");
}
-}
+};
const genSelectItemHTML = (type: "selected" | "empty" | "unselect", id?: string, text?: string) => {
if (type === "selected") {
@@ -198,20 +198,20 @@ const genSelectItemHTML = (type: "selected" | "empty" | "unselect", id?: string,
<svg class="b3-menu__icon"><use xlink:href="#iconDrag"></use></svg>
<span class="b3-menu__label">${text}</span>
<svg class="b3-menu__action"><use xlink:href="#iconMin"></use></svg>
-</button>`
+</button>`;
}
if (type === "empty") {
return `<button class="b3-menu__item">
<span class="b3-menu__label">${window.siyuan.languages.emptyContent}</span>
-</button>`
+</button>`;
}
if (type == "unselect") {
return `<button data-id="${id}" class="b3-menu__item" data-type="setRelationCell">
<span class="b3-menu__label">${text}</span>
<svg class="b3-menu__action"><use xlink:href="#iconAdd"></use></svg>
-</button>`
+</button>`;
}
-}
+};
export const bindRelationEvent = (options: {
protyle: IProtyle,
@@ -224,59 +224,59 @@ export const bindRelationEvent = (options: {
id: options.menuElement.firstElementChild.getAttribute("data-av-id"),
}, response => {
const avData = response.data as IAV;
- let cellIndex = 0
+ let cellIndex = 0;
avData.view.columns.find((item, index) => {
if (item.type === "block") {
- cellIndex = index
+ cellIndex = index;
return true;
}
- })
- let html = ""
- let selectHTML = ""
+ });
+ let html = "";
+ let selectHTML = "";
hasIds.forEach(hasId => {
if (hasId) {
avData.view.rows.find((item) => {
if (item.id === hasId) {
- selectHTML += genSelectItemHTML("selected", item.id, item.cells[cellIndex].value.block.content || item.cells[cellIndex].value.block.id)
- return true
+ selectHTML += genSelectItemHTML("selected", item.id, item.cells[cellIndex].value.block.content || item.cells[cellIndex].value.block.id);
+ return true;
}
- })
+ });
}
- })
+ });
avData.view.rows.forEach((item) => {
if (!hasIds.includes(item.id)) {
- html += genSelectItemHTML("unselect", item.id, item.cells[cellIndex].value.block.content || item.cells[cellIndex].value.block.id)
+ html += genSelectItemHTML("unselect", item.id, item.cells[cellIndex].value.block.content || item.cells[cellIndex].value.block.id);
}
- })
+ });
options.menuElement.innerHTML = `<div class="b3-menu__items">${selectHTML || genSelectItemHTML("empty")}
<button class="b3-menu__separator"></button>
-${html || genSelectItemHTML("empty")}</div>`
- })
-}
+${html || genSelectItemHTML("empty")}</div>`;
+ });
+};
export const getRelationHTML = (data: IAV, cellElements?: HTMLElement[]) => {
- let colRelationData: IAVCellRelationValue
+ let colRelationData: IAVCellRelationValue;
data.view.columns.find(item => {
if (item.id === cellElements[0].dataset.colId) {
- colRelationData = item.relation
+ colRelationData = item.relation;
return true;
}
- })
+ });
if (colRelationData && colRelationData.avID) {
- let ids = ""
+ let ids = "";
cellElements[0].querySelectorAll("span").forEach((item) => {
ids += `${item.getAttribute("data-id")},`;
});
- return `<span data-av-id="${colRelationData.avID}">${ids}</span>`
+ return `<span data-av-id="${colRelationData.avID}">${ids}</span>`;
} else {
- return ""
+ return "";
}
-}
+};
export const setRelationCell = (protyle: IProtyle, nodeElement: HTMLElement, target: HTMLElement, cellElements: HTMLElement[]) => {
const menuElement = hasClosestByClassName(target, "b3-menu__items");
if (!menuElement) {
- return
+ return;
}
const newValue: {
blockIDs: string[]
@@ -284,16 +284,16 @@ export const setRelationCell = (protyle: IProtyle, nodeElement: HTMLElement, tar
} = {
blockIDs: [],
contents: []
- }
+ };
Array.from(menuElement.children).forEach((item) => {
- const id = item.getAttribute("data-id")
+ const id = item.getAttribute("data-id");
if (item.getAttribute("draggable") && id) {
newValue.blockIDs.push(id);
newValue.contents.push(item.textContent.trim());
}
- })
+ });
if (target.classList.contains("b3-menu__item")) {
- const targetId = target.getAttribute("data-id")
+ const targetId = target.getAttribute("data-id");
const separatorElement = menuElement.querySelector(".b3-menu__separator");
if (target.getAttribute("draggable")) {
if (!separatorElement.nextElementSibling.getAttribute("data-id")) {
diff --git a/app/src/protyle/wysiwyg/enter.ts b/app/src/protyle/wysiwyg/enter.ts
index addf90f8d6..d7c7cc49d2 100644
--- a/app/src/protyle/wysiwyg/enter.ts
+++ b/app/src/protyle/wysiwyg/enter.ts
@@ -392,12 +392,12 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle
action: "update",
data: blockElement.outerHTML,
id,
- })
+ });
undoOperation.push({
action: "update",
data: html,
id,
- })
+ });
mathRender(editableElement);
} else {
doOperation.push({
@@ -405,15 +405,15 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle
data: item.outerHTML,
id: item.dataset.nodeId,
nextID: id,
- })
+ });
blockElement.insertAdjacentElement("beforebegin", item);
undoOperation.push({
action: "delete",
id: item.dataset.nodeId,
- })
+ });
mathRender(item);
}
- })
+ });
let previousElement = blockElement;
Array.from(newElement.children).forEach((item: HTMLElement) => {