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:
Vanessa321ac0cf1960
diff --git a/app/src/layout/status.ts b/app/src/layout/status.tsindex abc0b0544c..d18a7a3605 100644--- a/app/src/layout/status.ts+++ b/app/src/layout/status.ts@@ -6,6 +6,7 @@ import {fetchPost} from "../util/fetch";import {mountHelp} from "../util/mount";/// #if !BROWSERimport {getCurrentWindow} from "@electron/remote";+import {isMobile} from "../util/functions";/// #endifexport const initStatus = () => {@@ -126,23 +127,29 @@ export const initStatus = () => {};export const countSelectWord = (range: Range) => {+ if (isMobile()) {+ return;+ }const selectText = range.toString();if (selectText) {fetchPost("/api/block/getContentWordCount", {"content": range.toString()}, (response) => {document.querySelector("#status .status__counter").innerHTML = `<span class="ft__on-surface">${window.siyuan.languages.blockRuneCount}</span> ${response.data.runeCount}<span class="ft__on-surface">${window.siyuan.languages.blockWordCount}</span> ${response.data.wordCount}`;- })+ });} else {document.querySelector("#status .status__counter").innerHTML = "";}-}+};export const countBlockWord = (ids: string[]) => {+ if (isMobile()) {+ return;+ }if (ids.length > 0) {fetchPost("/api/block/getBlocksWordCount", {ids}, (response) => {document.querySelector("#status .status__counter").innerHTML = `<span class="ft__on-surface">${window.siyuan.languages.blockRuneCount}</span> ${response.data.runeCount}<span class="ft__on-surface">${window.siyuan.languages.blockWordCount}</span> ${response.data.wordCount}`;- })+ });} else {document.querySelector("#status .status__counter").innerHTML = "";}-}+};diff --git a/app/src/layout/util.ts b/app/src/layout/util.tsindex 685e68af9d..dd785fbc0f 100644--- a/app/src/layout/util.ts+++ b/app/src/layout/util.ts@@ -414,7 +414,7 @@ export const resizeTabs = () => {setPadding(item.editor.protyle);if (typeof echarts !== "undefined") {item.editor.protyle.wysiwyg.element.querySelectorAll('[data-subtype="echarts"], [data-subtype="mindmap"]').forEach((chartItem: HTMLElement) => {- const chartInstance = echarts.getInstanceById(chartItem.firstElementChild.nextElementSibling.getAttribute("_echarts_instance_"))+ const chartInstance = echarts.getInstanceById(chartItem.firstElementChild.nextElementSibling.getAttribute("_echarts_instance_"));if (chartInstance) {chartInstance.resize();}diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.tsindex cf805726b7..f5e27b1fbe 100644--- a/app/src/protyle/index.ts+++ b/app/src/protyle/index.ts@@ -109,7 +109,7 @@ class Protyle {this.protyle.model.parent.updateTitle(data.data.title);}if (this.protyle.background) {- this.protyle.background.ial.title = data.data.title+ this.protyle.background.ial.title = data.data.title;}}if (this.protyle.options.render.title && this.protyle.block.parentID === data.data.id) {diff --git a/app/src/protyle/util/selection.ts b/app/src/protyle/util/selection.tsindex c45b035d33..342492aca9 100644--- a/app/src/protyle/util/selection.ts+++ b/app/src/protyle/util/selection.ts@@ -86,9 +86,9 @@ export const selectAll = (protyle: IProtyle, nodeElement: Element, range: Range)const ids: string [] = [];Array.from(protyle.wysiwyg.element.children).forEach(item => {item.classList.add("protyle-wysiwyg--select");- ids.push(item.getAttribute("data-node-id"))+ ids.push(item.getAttribute("data-node-id"));});- countBlockWord(ids)+ countBlockWord(ids);};export const getEditorRange = (element: Element) => {diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.tsindex f4af84b121..4780ea9f74 100644--- a/app/src/protyle/wysiwyg/index.ts+++ b/app/src/protyle/wysiwyg/index.ts@@ -204,7 +204,7 @@ export class WYSIWYG {if (selectElements.length === 0 && range.toString() === "" && !range.cloneContents().querySelector("img") &&!selectImgElement) {nodeElement.classList.add("protyle-wysiwyg--select");- countBlockWord([nodeElement.getAttribute("data-node-id")])+ countBlockWord([nodeElement.getAttribute("data-node-id")]);selectElements = [nodeElement];}let html = "";@@ -494,7 +494,7 @@ export class WYSIWYG {}});- let mousewheelTime = 0+ let mousewheelTime = 0;this.element.addEventListener("mousewheel", (event: WheelEvent) => {// https://ld246.com/article/1648865235549if (event.timeStamp - mousewheelTime > 6000 &&@@ -885,14 +885,14 @@ export class WYSIWYG {// 只有一个 p 时不选中protyle.selectElement.style.backgroundColor = "transparent";} else {- const ids: string[] = []+ const ids: string[] = [];selectElements.forEach(item => {if (!hasClosestByClassName(item, "protyle-wysiwyg__embed")) {item.classList.add("protyle-wysiwyg--select");- ids.push(item.getAttribute("data-node-id"))+ ids.push(item.getAttribute("data-node-id"));}});- countBlockWord(ids)+ countBlockWord(ids);protyle.selectElement.style.backgroundColor = "";}};@@ -1280,7 +1280,7 @@ export class WYSIWYG {if (nodeElement) {if (isNotEditBlock(nodeElement) && !this.element.querySelector(".protyle-wysiwyg--select")) {nodeElement.classList.add("protyle-wysiwyg--select");- countBlockWord([nodeElement.getAttribute("data-node-id")])+ countBlockWord([nodeElement.getAttribute("data-node-id")]);} else if (!nodeElement.classList.contains("protyle-wysiwyg--select")) {countSelectWord(range);}@@ -1791,10 +1791,10 @@ export class WYSIWYG {// 单个 p 不选中shiftStartElement = undefined;} else {- const ids: string[] = []+ const ids: string[] = [];selectElements.forEach(item => {item.classList.add("protyle-wysiwyg--select");- ids.push(item.getAttribute("data-node-id"))+ ids.push(item.getAttribute("data-node-id"));});countBlockWord(ids);if (toDown) {@@ -1828,9 +1828,9 @@ export class WYSIWYG {if (ctrlParentElement && !ctrlElement.isSameNode(ctrlParentElement)) {ctrlParentElement.classList.remove("protyle-wysiwyg--select");}- const ids: string[] = []+ const ids: string[] = [];protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select").forEach(item => {- ids.push(item.getAttribute("data-node-id"))+ ids.push(item.getAttribute("data-node-id"));});countBlockWord(ids);}diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.tsindex 354dc22bdf..aef4a3e12e 100644--- a/app/src/protyle/wysiwyg/keydown.ts+++ b/app/src/protyle/wysiwyg/keydown.ts@@ -153,7 +153,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {}nextElement.classList.add("protyle-wysiwyg--select");- countBlockWord([nextElement.getAttribute("data-node-id")])+ countBlockWord([nextElement.getAttribute("data-node-id")]);const bottom = nextElement.getBoundingClientRect().bottom - protyle.contentElement.getBoundingClientRect().bottom;if (bottom > 0) {protyle.contentElement.scrollTop = protyle.contentElement.scrollTop + bottom;@@ -190,7 +190,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {}if (previousElement) {previousElement.classList.add("protyle-wysiwyg--select");- countBlockWord([previousElement.getAttribute("data-node-id")])+ countBlockWord([previousElement.getAttribute("data-node-id")]);const top = previousElement.getBoundingClientRect().top - protyle.contentElement.getBoundingClientRect().top;if (top < 0) {protyle.contentElement.scrollTop = protyle.contentElement.scrollTop + top;@@ -315,10 +315,10 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {selectElements[0].parentElement.classList.add("protyle-wysiwyg--select");}}- const ids: string[] = []+ const ids: string[] = [];protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select").forEach(item => {- ids.push(item.getAttribute("data-node-id"))- })+ ids.push(item.getAttribute("data-node-id"));+ });countBlockWord(ids);event.stopPropagation();event.preventDefault();@@ -362,10 +362,10 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {selectLastElement.parentElement.classList.add("protyle-wysiwyg--select");}}- const ids: string[] = []+ const ids: string[] = [];protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select").forEach(item => {- ids.push(item.getAttribute("data-node-id"))- })+ ids.push(item.getAttribute("data-node-id"));+ });countBlockWord(ids);event.stopPropagation();event.preventDefault();@@ -966,7 +966,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {protyle.hint.enableEmoji = false;} else if (nodeElement.classList.contains("protyle-wysiwyg--select")) {hideElements(["select"], protyle);- countBlockWord([])+ countBlockWord([]);} else if (!window.siyuan.menus.menu.element.classList.contains("fn__none")) {// 防止 ESC 时选中当前块window.siyuan.menus.menu.remove();@@ -975,7 +975,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {item.classList.remove("protyle-wysiwyg--select");});nodeElement.classList.add("protyle-wysiwyg--select");- countBlockWord([nodeElement.getAttribute("data-node-id")])+ countBlockWord([nodeElement.getAttribute("data-node-id")]);}event.preventDefault();return;diff --git a/app/src/protyle/wysiwyg/remove.ts b/app/src/protyle/wysiwyg/remove.tsindex 5326b28d93..e8d0bc8b96 100644--- a/app/src/protyle/wysiwyg/remove.ts+++ b/app/src/protyle/wysiwyg/remove.ts@@ -413,7 +413,7 @@ export const removeBlock = (protyle: IProtyle, blockElement: Element, range: Ranreturn;}previousLastElement.classList.add("protyle-wysiwyg--select");- countBlockWord([previousId])+ countBlockWord([previousId]);if (previousLastElement.getAttribute("data-type") === "NodeBlockQueryEmbed" || editableElement.textContent !== "") {focusByRange(range);return;diff --git a/app/src/search/index.ts b/app/src/search/index.tsindex a938efe4a4..7f7d215c6d 100644--- a/app/src/search/index.ts+++ b/app/src/search/index.ts@@ -189,7 +189,7 @@ export class Search extends Model {size: foldResponse.data ? Constants.SIZE_GET_MAX : Constants.SIZE_GET,}, getResponse => {onGet(getResponse, this.protyle.protyle, foldResponse.data ? [Constants.CB_GET_ALL] : [Constants.CB_GET_HL]);- const matchElement = this.protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${id}"] span[data-type="search-mark"]`)+ const matchElement = this.protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${id}"] span[data-type="search-mark"]`);if (matchElement) {matchElement.scrollIntoView();}@@ -204,7 +204,7 @@ export class Search extends Model {breadcrumbDocName: true,},after: () => {- const matchElement = this.protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${id}"] span[data-type="search-mark"]`)+ const matchElement = this.protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${id}"] span[data-type="search-mark"]`);if (matchElement) {matchElement.scrollIntoView();}diff --git a/app/src/search/spread.ts b/app/src/search/spread.tsindex 1023370a67..d2dd5fa0ef 100644--- a/app/src/search/spread.ts+++ b/app/src/search/spread.ts@@ -648,7 +648,7 @@ const getArticle = (options: {breadcrumbDocName: true},after: () => {- const matchElement = protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${options.id}"] span[data-type="search-mark"]`)+ const matchElement = protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${options.id}"] span[data-type="search-mark"]`);if (matchElement) {matchElement.scrollIntoView();}@@ -664,7 +664,7 @@ const getArticle = (options: {size: foldResponse.data ? Constants.SIZE_GET_MAX : Constants.SIZE_GET,}, getResponse => {onGet(getResponse, protyle.protyle, foldResponse.data ? [Constants.CB_GET_ALL] : [Constants.CB_GET_HL]);- const matchElement = protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${options.id}"] span[data-type="search-mark"]`)+ const matchElement = protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${options.id}"] span[data-type="search-mark"]`);if (matchElement) {matchElement.scrollIntoView();}diff --git a/app/src/util/onGetConfig.ts b/app/src/util/onGetConfig.tsindex 0b68802da1..c422557e78 100644--- a/app/src/util/onGetConfig.ts+++ b/app/src/util/onGetConfig.ts@@ -1,5 +1,5 @@import {openSearch} from "../search/spread";-import {exportLayout, getDockByType, JSONToLayout, resizeDrag, resizeTabs} from "../layout/util";+import {exportLayout, JSONToLayout, resizeDrag, resizeTabs} from "../layout/util";import {hotKey2Electron, updateHotkeyTip} from "../protyle/util/compatibility";/// #if !BROWSERimport {ipcRenderer} from "electron";