An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:rotating_light:
Vanessa553891defb85
diff --git a/app/electron/main.js b/app/electron/main.jsindex c912e3b865..6f627a8e28 100644--- a/app/electron/main.js+++ b/app/electron/main.js@@ -1109,7 +1109,7 @@ app.whenReady().then(() => {if (index === 0) {globalShortcut.register(shortcut, () => {let currentWorkspace;- const currentWebContentsId = (latestActiveWindow && !latestActiveWindow.isDestroyed()) ? latestActiveWindow.webContents.id : undefined+ const currentWebContentsId = (latestActiveWindow && !latestActiveWindow.isDestroyed()) ? latestActiveWindow.webContents.id : undefined;workspaces.find(workspaceItem => {if ((currentWebContentsId || event.sender.id) === workspaceItem.browserWindow.webContents.id) {currentWorkspace = workspaceItem;diff --git a/app/src/asset/anno.ts b/app/src/asset/anno.tsindex e64498cf62..f0c7ce9777 100644--- a/app/src/asset/anno.ts+++ b/app/src/asset/anno.ts@@ -393,21 +393,21 @@ const showToolbar = (element: HTMLElement, range: Range, target?: HTMLElement) =};const getTextNode = (element: HTMLElement, isFirst: boolean) => {- const spans = element.querySelectorAll(".markedContent span")- let index = isFirst ? 0 : spans.length - 1+ const spans = element.querySelectorAll(".markedContent span");+ let index = isFirst ? 0 : spans.length - 1;while (spans[index]) {if (spans[index].textContent) {- break+ break;} else {if (isFirst) {- index+++ index++;} else {- index--+ index--;}}}- return spans[index]-}+ return spans[index];+};const getHightlightCoordsByRange = (pdf: any, color: string) => {const range = window.getSelection().getRangeAt(0);diff --git a/app/src/block/popover.ts b/app/src/block/popover.tsindex 55599cf707..73d97abffb 100644--- a/app/src/block/popover.ts+++ b/app/src/block/popover.ts@@ -31,7 +31,7 @@ export const initBlockPopover = (app: App) => {if (aElement.classList.contains("av__cell")) {if (aElement.classList.contains("av__cell--header")) {const textElement = aElement.querySelector(".av__celltext");- const desc = aElement.getAttribute("data-desc")+ const desc = aElement.getAttribute("data-desc");if (textElement.scrollWidth > textElement.clientWidth + 2 || desc) {if (desc) {tip = `${getCellText(aElement)}<div class='ft__on-surface'>${escapeAriaLabel(desc)}</div>`;@@ -56,7 +56,7 @@ export const initBlockPopover = (app: App) => {}} else if (aElement.parentElement.parentElement.classList.contains("av__views")) {const textElement = aElement.querySelector(".item__text");- const desc = aElement.getAttribute("data-desc")+ const desc = aElement.getAttribute("data-desc");if (textElement.scrollWidth > textElement.clientWidth + 2 || desc) {if (desc) {tip = `${textElement.textContent}<div class='ft__on-surface'>${escapeAriaLabel(desc)}</div>`;diff --git a/app/src/boot/globalEvent/keydown.ts b/app/src/boot/globalEvent/keydown.tsindex 78732583a3..89a6404bcd 100644--- a/app/src/boot/globalEvent/keydown.ts+++ b/app/src/boot/globalEvent/keydown.ts@@ -510,7 +510,7 @@ const editKeydown = (app: App, event: KeyboardEvent) => {} else {const ids = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select")).map(item => item.getAttribute("data-node-id"));if (ids.length === 0) {- ids.push(nodeElement.getAttribute("data-node-id"))+ ids.push(nodeElement.getAttribute("data-node-id"));}copyTextByType(ids, "ref");}diff --git a/app/src/history/history.ts b/app/src/history/history.tsindex 2edde5efec..ff5836ee35 100644--- a/app/src/history/history.ts+++ b/app/src/history/history.ts@@ -694,7 +694,7 @@ const bindEvent = (app: App, element: Element, dialog?: Dialog) => {assetElement.classList.remove("fn__none");assetElement.innerHTML = renderAssetsPreview(dataPath);} else if (type === "doc") {- const k = (firstPanelElement.querySelector(".b3-text-field") as HTMLInputElement).value+ const k = (firstPanelElement.querySelector(".b3-text-field") as HTMLInputElement).value;fetchPost("/api/history/getDocHistoryContent", {historyPath: dataPath,highlight: !isSupportCSSHL(),@@ -717,7 +717,7 @@ const bindEvent = (app: App, element: Element, dialog?: Dialog) => {}});}- titleElement.classList.remove("fn__none")+ titleElement.classList.remove("fn__none");titleElement.textContent = target.querySelector(".b3-list-item__text").textContent;let currentItem = hasClosestByClassName(target, "b3-list") as HTMLElement;if (currentItem) {diff --git a/app/src/layout/dock/Backlink.ts b/app/src/layout/dock/Backlink.tsindex 46edc0d5d3..fdf28ea383 100644--- a/app/src/layout/dock/Backlink.ts+++ b/app/src/layout/dock/Backlink.ts@@ -136,13 +136,13 @@ export class Backlink extends Model {item.addEventListener("blur", (event: KeyboardEvent) => {const inputElement = event.target as HTMLInputElement;inputElement.classList.add("fn__none");- const filterIconElement = inputElement.nextElementSibling+ const filterIconElement = inputElement.nextElementSibling;if (inputElement.value) {- filterIconElement.classList.add("block__icon--active")- filterIconElement.setAttribute("aria-label", window.siyuan.languages.filter + " " + inputElement.value)+ filterIconElement.classList.add("block__icon--active");+ filterIconElement.setAttribute("aria-label", window.siyuan.languages.filter + " " + inputElement.value);} else {- filterIconElement.classList.remove("block__icon--active")- filterIconElement.setAttribute("aria-label", window.siyuan.languages.filter)+ filterIconElement.classList.remove("block__icon--active");+ filterIconElement.setAttribute("aria-label", window.siyuan.languages.filter);}});item.addEventListener("keydown", (event: KeyboardEvent) => {@@ -442,7 +442,7 @@ export class Backlink extends Model {});svgElement.removeAttribute("disabled");} else {- const keyword = isMention ? this.inputsElement[1].value : this.inputsElement[0].value+ const keyword = isMention ? this.inputsElement[1].value : this.inputsElement[0].value;fetchPost(isMention ? "/api/ref/getBackmentionDoc" : "/api/ref/getBacklinkDoc", {defID: this.blockId,refTreeID: docId,diff --git a/app/src/protyle/header/Background.ts b/app/src/protyle/header/Background.tsindex eaa5945f2f..e5cba295bd 100644--- a/app/src/protyle/header/Background.ts+++ b/app/src/protyle/header/Background.ts@@ -542,7 +542,7 @@ export class Background {this.addTags(inputElement.value, protyle);}inputElement.value = "";- inputElement.dispatchEvent(new CustomEvent("input"))+ inputElement.dispatchEvent(new CustomEvent("input"));} else if (event.key === "Escape") {window.siyuan.menus.menu.remove();}diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.tsindex c5040c7dff..25fe7cd477 100644--- a/app/src/protyle/render/av/cell.ts+++ b/app/src/protyle/render/av/cell.ts@@ -385,7 +385,7 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], typeif (cellRect.bottom > contentRect.bottom) {height = contentRect.bottom - cellRect.top;}- const width = Math.min(Math.max(cellRect.width, 25), contentRect.width)+ const width = Math.min(Math.max(cellRect.width, 25), contentRect.width);style = `style="padding-top: 6.5px;position:absolute;left: ${(cellRect.left < contentRect.left || cellRect.left + width > contentRect.right) ? contentRect.left : cellRect.left}px;top: ${cellRect.top}px;width:${width}px;height: ${height}px"`;} else {style = `style="padding-top: 6.5px;position:absolute;left: ${cellRect.left}px;top: ${cellRect.top}px;width:${Math.max(cellRect.width, 25)}px;height: ${height}px"`;diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.tsindex 3fdd3e3e1b..41362b2106 100644--- a/app/src/protyle/render/av/col.ts+++ b/app/src/protyle/render/av/col.ts@@ -120,7 +120,7 @@ export const getEditHTML = (options: {colData.options = [];}colData.options.forEach(item => {- const airaLabel = item.desc ? `${escapeAriaLabel(item.name)}<div class='ft__on-surface'>${escapeAriaLabel(item.desc || "")}</div>` : ""+ const airaLabel = item.desc ? `${escapeAriaLabel(item.name)}<div class='ft__on-surface'>${escapeAriaLabel(item.desc || "")}</div>` : "";html += `<button class="b3-menu__item${html ? "" : " b3-menu__item--current"}" draggable="true" data-name="${escapeAttr(item.name)}" data-desc="${escapeAttr(item.desc || "")}" data-color="${item.color}"><svg class="b3-menu__icon fn__grab"><use xlink:href="#iconDrag"></use></svg><div class="fn__flex-1 ariaLabel" data-position="2parentW" aria-label="${airaLabel}">diff --git a/app/src/protyle/render/av/date.ts b/app/src/protyle/render/av/date.tsindex abe8afc63b..0c971ef1d2 100644--- a/app/src/protyle/render/av/date.ts+++ b/app/src/protyle/render/av/date.ts@@ -29,9 +29,9 @@ export const getDateHTML = (data: IAVTable, cellElements: HTMLElement[]) => {const currentDate = new Date().getTime();if (cellValue?.value?.date?.isNotEmpty) {value = dayjs(cellValue.value.date.content).format(isNotTime ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm");- const year = value.split("-")[0]+ const year = value.split("-")[0];if (year.length !== 4) {- value = new Array(4 - year.length).fill(0).join("") + value+ value = new Array(4 - year.length).fill(0).join("") + value;}} else {value = dayjs(currentDate).format(isNotTime ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm");@@ -39,9 +39,9 @@ export const getDateHTML = (data: IAVTable, cellElements: HTMLElement[]) => {let value2 = "";if (cellValue?.value?.date?.isNotEmpty2) {value2 = dayjs(cellValue.value.date.content2).format(isNotTime ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm");- const year = value.split("-")[0]+ const year = value.split("-")[0];if (year.length !== 4) {- value = new Array(4 - year.length).fill(0).join("") + value+ value = new Array(4 - year.length).fill(0).join("") + value;}} else if (hasEndDate) {value2 = dayjs(currentDate).format(isNotTime ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm");@@ -144,12 +144,12 @@ export const bindDateEvent = (options: {};const getFullYearTime = (dateStr: string) => {- const year = dateStr.split("-")[0]- const date = new Date(dateStr)+ const year = dateStr.split("-")[0];+ const date = new Date(dateStr);if (year.startsWith("00") || year.startsWith("000") || year.length < 3) {- date.setFullYear(parseInt(year))- return date.getTime()+ date.setFullYear(parseInt(year));+ return date.getTime();} else {- return date.getTime()+ return date.getTime();}-}+};diff --git a/app/src/protyle/render/av/select.ts b/app/src/protyle/render/av/select.tsindex dbc8ce3623..f2614ac3ca 100644--- a/app/src/protyle/render/av/select.ts+++ b/app/src/protyle/render/av/select.ts@@ -28,7 +28,7 @@ const filterSelectHTML = (key: string, options: {if (!key ||(key.toLowerCase().indexOf(item.name.toLowerCase()) > -1 ||item.name.toLowerCase().indexOf(key.toLowerCase()) > -1)) {- const airaLabel = item.desc ? `${escapeAriaLabel(item.name)}<div class='ft__on-surface'>${escapeAriaLabel(item.desc || "")}</div>` : ""+ const airaLabel = item.desc ? `${escapeAriaLabel(item.name)}<div class='ft__on-surface'>${escapeAriaLabel(item.desc || "")}</div>` : "";html += `<button data-type="addColOptionOrCell" class="b3-menu__item" data-name="${escapeAttr(item.name)}" data-desc="${escapeAttr(item.desc || "")}" draggable="true" data-color="${item.color}"><svg class="b3-menu__icon fn__grab"><use xlink:href="#iconDrag"></use></svg><div class="fn__flex-1 ariaLabel" data-position="2parentW" aria-label="${airaLabel}">diff --git a/app/src/protyle/render/searchMarkRender.ts b/app/src/protyle/render/searchMarkRender.tsindex e518cdf02a..59a12f8b6d 100644--- a/app/src/protyle/render/searchMarkRender.ts+++ b/app/src/protyle/render/searchMarkRender.ts@@ -19,7 +19,7 @@ export const searchMarkRender = (protyle: IProtyle, keys: string[], isHL: boolealet currentNode = treeWalker.nextNode();while (currentNode) {textNodes.push(currentNode);- currentSize += currentNode.textContent.length+ currentSize += currentNode.textContent.length;textNodesSize.push(currentSize);currentNode = treeWalker.nextNode();}@@ -45,9 +45,9 @@ export const searchMarkRender = (protyle: IProtyle, keys: string[], isHL: boolearange.setStart(currentTextNode, startIndex - (currentNodeIndex ? textNodesSize[currentNodeIndex - 1] : 0));while (currentNodeIndex < textNodes.length && textNodesSize[currentNodeIndex] < endIndex) {- currentNodeIndex+++ currentNodeIndex++;}- currentTextNode = textNodes[currentNodeIndex]+ currentTextNode = textNodes[currentNodeIndex];range.setEnd(currentTextNode, endIndex - (currentNodeIndex ? textNodesSize[currentNodeIndex - 1] : 0));rangeIndexes.push({range, startIndex});@@ -56,13 +56,13 @@ export const searchMarkRender = (protyle: IProtyle, keys: string[], isHL: boolea}startIndex = endIndex;}- })+ });rangeIndexes.sort((b, a) => {if (a.startIndex > b.startIndex) {- return -1+ return -1;} else {- return 0+ return 0;}}).forEach((item, index) => {if (index === protyle.highlight.rangeIndex && isHL) {@@ -84,4 +84,4 @@ export const searchMarkRender = (protyle: IProtyle, keys: string[], isHL: booleaexport const isSupportCSSHL = () => {return !!(CSS && CSS.highlights);-}+};diff --git a/app/src/protyle/util/insertHTML.ts b/app/src/protyle/util/insertHTML.tsindex e1271b5326..02228537c1 100644--- a/app/src/protyle/util/insertHTML.ts+++ b/app/src/protyle/util/insertHTML.ts@@ -415,7 +415,7 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,(insertBefore ? Array.from(tempElement.content.children) : Array.from(tempElement.content.children).reverse()).forEach((item) => {// https://github.com/siyuan-note/siyuan/issues/13232if (item.getAttribute("data-type") === "NodeHeading" && item.getAttribute("fold") === "1") {- item.removeAttribute("fold")+ item.removeAttribute("fold");}let addId = item.getAttribute("data-node-id");if (addId === id) {diff --git a/app/src/protyle/util/reload.ts b/app/src/protyle/util/reload.tsindex 21ee812d53..016df49394 100644--- a/app/src/protyle/util/reload.ts+++ b/app/src/protyle/util/reload.ts@@ -37,7 +37,7 @@ export const reloadProtyle = (protyle: IProtyle, focus: boolean, updateReadonly?const tabElement = hasClosestByClassName(protyle.element, "sy__backlink");if (tabElement) {const inputsElement = tabElement.querySelectorAll(".b3-text-field") as NodeListOf<HTMLInputElement>;- const keyword = isMention ? inputsElement[1].value : inputsElement[0].value+ const keyword = isMention ? inputsElement[1].value : inputsElement[0].value;fetchPost(isMention ? "/api/ref/getBackmentionDoc" : "/api/ref/getBacklinkDoc", {defID: protyle.element.getAttribute("data-defid"),refTreeID: protyle.block.rootID,diff --git a/app/src/protyle/util/table.ts b/app/src/protyle/util/table.tsindex 7d0d4b6fb3..57413373a9 100644--- a/app/src/protyle/util/table.ts+++ b/app/src/protyle/util/table.ts@@ -743,4 +743,4 @@ export const clearTableCell = (protyle: IProtyle, tableBlockElement: HTMLElementitem.innerHTML = "";});updateTransaction(protyle, tableBlockElement.getAttribute("data-node-id"), tableBlockElement.outerHTML, oldHTML);-}+};diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.tsindex 44c9f7b177..a604c5f83a 100644--- a/app/src/protyle/wysiwyg/index.ts+++ b/app/src/protyle/wysiwyg/index.ts@@ -1298,7 +1298,7 @@ export class WYSIWYG {icon: "iconTrashcan",accelerator: "⌦",click() {- clearTableCell(protyle, tableBlockElement as HTMLElement)+ clearTableCell(protyle, tableBlockElement as HTMLElement);}}).element);window.siyuan.menus.menu.append(new MenuItem({diff --git a/app/src/search/util.ts b/app/src/search/util.tsindex 60a18e9406..704bba26a4 100644--- a/app/src/search/util.ts+++ b/app/src/search/util.ts@@ -1200,7 +1200,7 @@ const renderNextSearchMark = (options: {}};-let articleId: string+let articleId: string;export const getArticle = (options: {id: string,@@ -1208,7 +1208,7 @@ export const getArticle = (options: {edit: Protylevalue?: string,}) => {- articleId = options.id+ articleId = options.id;checkFold(options.id, (zoomIn) => {if (articleId !== options.id) {return;