An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:recycle: https://github.com/siyuan-note/siyuan/pull/9300
Vanessadf3f444e4800
diff --git a/app/src/constants.ts b/app/src/constants.tsindex ad31f40186..cca6bc1ca7 100644--- a/app/src/constants.ts+++ b/app/src/constants.ts@@ -541,18 +541,11 @@ export abstract class Constants {public static readonly INLINE_TYPE: string[] = ["block-ref", "kbd", "text", "file-annotation-ref", "a", "strong", "em", "u", "s", "mark", "sup", "sub", "tag", "code", "inline-math", "inline-memo"];public static readonly BLOCK_HINT_KEYS: string[] = ["((", "[[", "((", "【【"];public static readonly BLOCK_HINT_CLOSE_KEYS: IObject = {"((": "))", "[[": "]]", "((": "))", "【【": "】】"};- public static readonly EXTRA_CODE_LANGUAGES: string[] = [- // 同名+ // common: "bash", "c", "csharp", "cpp", "css", "diff", "go", "xml", "json", "java", "javascript", "kotlin", "less", "lua", "makefile", "markdown", "objectivec", "php", "php-template", "perl", "plaintext", "python", "python-repl", "r", "ruby", "rust", "scss", "sql", "shell", "swift", "ini", "typescript", "vbnet", "yaml", "properties", "1c", "armasm", "avrasm", "actionscript", "ada", "angelscript", "accesslog", "apache", "applescript", "arcade", "arduino", "asciidoc", "aspectj", "abnf", "autohotkey", "autoit", "awk", "basic", "bnf", "dos", "brainfuck", "cal", "cmake", "csp", "cos", "capnproto", "ceylon", "clean", "clojure", "clojure-repl", "coffeescript", "coq", "crystal", "d", "dns", "dart", "delphi", "dts", "django", "dockerfile", "dust", "erb", "elixir", "elm", "erlang", "erlang-repl", "excel", "ebnf", "fsharp", "fix", "flix", "fortran", "gcode", "gams", "gauss", "glsl", "gml", "gherkin", "golo", "gradle", "groovy", "haml", "hsp", "http", "handlebars", "haskell", "haxe", "hy", "irpf90", "isbl", "inform7", "x86asm", "jboss-cli", "julia", "julia-repl", "ldif", "llvm", "lsl", "latex", "lasso", "leaf", "lisp", "livecodeserver", "livescript", "mel", "mipsasm", "matlab", "maxima", "mercury", "axapta", "routeros", "mizar", "mojolicious", "monkey", "moonscript", "n1ql", "nsis", "nestedtext", "nginx", "nim", "nix", "node-repl", "ocaml", "openscad", "ruleslanguage", "oxygene", "pf", "parser3", "pony", "pgsql", "powershell", "processing", "prolog", "protobuf", "puppet", "purebasic", "profile", "q", "qml", "reasonml", "rib", "rsl", "roboconf", "sas", "sml", "sqf", "step21", "scala", "scheme", "scilab", "smali", "smalltalk", "stan", "stata", "stylus", "subunit", "tp", "taggerscript", "tcl", "tap", "thrift", "twig", "vbscript", "vbscript-html", "vhdl", "vala", "verilog", "vim", "wasm", "mathematica", "wren", "xl", "xquery", "zephir", "crmsh", "dsconfig", "graphql",+ // third: "yul", "solidity", "abap", "hlsl"+ public static readonly ALIAS_CODE_LANGUAGES: string[] = ["js", "ts", "html", "toml", "c#", "bat",];- public static readonly CODE_LANGUAGES: string[] = [- // 附加- ...Constants.EXTRA_CODE_LANGUAGES,- // common- "bash", "c", "csharp", "cpp", "css", "diff", "go", "xml", "json", "java", "javascript", "kotlin", "less", "lua", "makefile", "markdown", "objectivec", "php", "php-template", "perl", "plaintext", "python", "python-repl", "r", "ruby", "rust", "scss", "sql", "shell", "swift", "ini", "typescript", "vbnet", "yaml", "properties", "1c", "armasm", "avrasm", "actionscript", "ada", "angelscript", "accesslog", "apache", "applescript", "arcade", "arduino", "asciidoc", "aspectj", "abnf", "autohotkey", "autoit", "awk", "basic", "bnf", "dos", "brainfuck", "cal", "cmake", "csp", "cos", "capnproto", "ceylon", "clean", "clojure", "clojure-repl", "coffeescript", "coq", "crystal", "d", "dns", "dart", "delphi", "dts", "django", "dockerfile", "dust", "erb", "elixir", "elm", "erlang", "erlang-repl", "excel", "ebnf", "fsharp", "fix", "flix", "fortran", "gcode", "gams", "gauss", "glsl", "gml", "gherkin", "golo", "gradle", "groovy", "haml", "hsp", "http", "handlebars", "haskell", "haxe", "hy", "irpf90", "isbl", "inform7", "x86asm", "jboss-cli", "julia", "julia-repl", "ldif", "llvm", "lsl", "latex", "lasso", "leaf", "lisp", "livecodeserver", "livescript", "mel", "mipsasm", "matlab", "maxima", "mercury", "axapta", "routeros", "mizar", "mojolicious", "monkey", "moonscript", "n1ql", "nsis", "nestedtext", "nginx", "nim", "nix", "node-repl", "ocaml", "openscad", "ruleslanguage", "oxygene", "pf", "parser3", "pony", "pgsql", "powershell", "processing", "prolog", "protobuf", "puppet", "purebasic", "profile", "q", "qml", "reasonml", "rib", "rsl", "roboconf", "sas", "sml", "sqf", "step21", "scala", "scheme", "scilab", "smali", "smalltalk", "stan", "stata", "stylus", "subunit", "tp", "taggerscript", "tcl", "tap", "thrift", "twig", "vbscript", "vbscript-html", "vhdl", "vala", "verilog", "vim", "wasm", "mathematica", "wren", "xl", "xquery", "zephir", "crmsh", "dsconfig", "graphql",- // third- "yul", "solidity", "abap", "hlsl"- ];// Google Analytics 事件public static readonly ANALYTICS_EVT_ON_GET_CONFIG: string = "siyuan.onGetConfig";diff --git a/app/src/protyle/preview/image.ts b/app/src/protyle/preview/image.tsindex 59b0f2409d..66447a3cf8 100644--- a/app/src/protyle/preview/image.ts+++ b/app/src/protyle/preview/image.ts@@ -6,7 +6,6 @@ export const previewImage = (src: string) => {addScript(`${Constants.PROTYLE_CDN}/js/viewerjs/viewer.js?v=1.10.4`, "protyleViewerScript").then(() => {const imagesElement = document.createElement("ul");imagesElement.innerHTML = `<li><img src="${src}"></li>`;- // @ts-ignorewindow.siyuan.viewer = new Viewer(imagesElement, {title: [1, (image: HTMLImageElement, imageData: IObject) => {let name = image.alt;@@ -57,8 +56,7 @@ export const previewDocImage = (src: string, id: string) => {}});imagesElement.innerHTML = html;- // @ts-ignore- window.siyuan.viewer = new window.Viewer(imagesElement, {+ window.siyuan.viewer = new Viewer(imagesElement, {title: [1, (image: HTMLImageElement, imageData: IObject) => {let name = image.alt;if (!name) {diff --git a/app/src/protyle/render/graphvizRender.ts b/app/src/protyle/render/graphvizRender.tsindex cfc8bfb7da..89f2fbc948 100644--- a/app/src/protyle/render/graphvizRender.ts+++ b/app/src/protyle/render/graphvizRender.ts@@ -28,7 +28,7 @@ export const graphvizRender = (element: Element, cdn = Constants.PROTYLE_CDN) =>const url = window.URL || window.webkitURL;const blobUrl = url.createObjectURL(blob);const worker = new Worker(blobUrl);- new window.Viz({worker})+ new Viz({worker}).renderSVGElement(Lute.UnEscapeHTMLStr(e.getAttribute("data-content"))).then((result: HTMLElement) => {renderElement.innerHTML = result.outerHTML;renderElement.classList.remove("ft__error");diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.tsindex c97b4d92ab..6695afb291 100644--- a/app/src/protyle/toolbar/index.ts+++ b/app/src/protyle/toolbar/index.ts@@ -1146,14 +1146,11 @@ export class Toolbar {const id = nodeElement.getAttribute("data-node-id");let oldHtml = nodeElement.outerHTML;- const languages = Array.from(new Set<string>([- ...Constants.EXTRA_CODE_LANGUAGES,- ...(window.hljs?.listLanguages() ?? []),- ])).sort();- const html = [- `<div class="b3-list-item b3-list-item--focus">${window.siyuan.languages.clear}</div>`,- ...languages.map(item => `<div class="b3-list-item">${item}</div>`),- ].join("\n");+ let html = `<div class="b3-list-item b3-list-item--focus">${window.siyuan.languages.clear}</div>`;+ const hljsLanguages = Constants.ALIAS_CODE_LANGUAGES.concat(window.hljs?.listLanguages() ?? []).sort();+ hljsLanguages.forEach((item) => {+ html += `<div class="b3-list-item">${item}</div>`;+ });this.subElement.style.width = "";this.subElement.style.padding = "";@@ -1196,7 +1193,7 @@ export class Toolbar {});inputElement.addEventListener("input", (event) => {const lowerCaseValue = inputElement.value.toLowerCase();- const matchLanguages = languages.filter(item => item.includes(lowerCaseValue));+ const matchLanguages = hljsLanguages.filter(item => item.includes(lowerCaseValue));let html = "";// sortlet matchInput = false;diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.tsindex 769d051cc8..3e3c6e3e9d 100644--- a/app/src/types/index.d.ts+++ b/app/src/types/index.d.ts@@ -81,17 +81,45 @@ type TAVFilterOperator =declare module "blueimp-md5"interface Window {- ABCJS?: IABCJS- Viewer?: Function- Viz?: IViz- echarts?: IECharts- hljs?: IHLJS- katex?: IKaTeX- mermaid?: IMermaid- plantumlEncoder?: IPlantumlEncoder-+ echarts: {+ init(element: HTMLElement, theme?: string, options?: { width: number }): {+ setOption(option: any): void;+ getZr(): any;+ on(name: string, event: (e: any) => void): any;+ containPixel(name: string, position: number[]): any;+ resize(): void;+ };+ dispose(element: Element): void;+ getInstanceById(id: string): { resize: () => void };+ }+ ABCJS: {+ renderAbc(element: Element, text: string, options: { responsive: string }): void;+ }+ hljs: {+ listLanguages(): string[];+ highlight(text: string, options: { language?: string, ignoreIllegals: boolean }): { value: string };+ getLanguage(text: string): { name: string };+ };+ katex: {+ renderToString(math: string, option: {+ displayMode: boolean;+ output: string;+ macros: IObject;+ trust: boolean;+ strict: (errorCode: string) => "ignore" | "warn";+ }): string;+ }+ mermaid: {+ initialize(options: any): void,+ init(options: any, element: Element): void+ };+ plantumlEncoder: {+ encode(options: string): string,+ };pdfjsLib: any+dataLayer: any[]+siyuan: ISiyuanwebkit: anyhtml2canvas: (element: Element, opitons: {@@ -353,11 +381,7 @@ interface ISiyuan {bookmarkLabel?: string[]blockPanels: import("../block/Panel").BlockPanel[],dialogs: import("../dialog").Dialog[],- viewer?: {- destroyed: boolean,- show: () => void,- destroy: () => void,- }+ viewer?: Viewer}interface IScrollAttr {diff --git a/app/src/types/protyle.d.ts b/app/src/types/protyle.d.tsindex 6720cfc45c..edbb710cbc 100644--- a/app/src/types/protyle.d.ts+++ b/app/src/types/protyle.d.ts@@ -1,55 +1,3 @@-interface IABCJS {- renderAbc(element: Element, text: string, options: { responsive: string }): void;-}--interface IViz {- new(worker: { worker: Worker }): IViz;- renderSVGElement: (code: string) => Promise<any>;-}--interface IEChartsInstance {- setOption(option: any): void;-- getZr(): any;-- on(name: string, event: (e: any) => void): any;-- containPixel(name: string, position: number[]): any;-- resize(): void;-}--interface IECharts {- init(element: HTMLElement, theme?: string, options?: { width: number }): IEChartsInstance;- dispose(element: Element): void;- getInstanceById(id: string): { resize: () => void };-}--interface IHLJS {- highlight(text: string, options: { language?: string, ignoreIllegals: boolean }): { value: string };- getLanguage(text: string): { name: string };- listLanguages(): string[];-}--interface IKaTeX {- renderToString(math: string, option: {- displayMode: boolean;- output: string;- macros: IObject;- trust: boolean;- strict: (errorCode: string) => "ignore" | "warn";- }): string;-}--interface IMermaid {- initialize(options: any): void;- init(options: any, element: Element): void;-}--interface IPlantumlEncoder {- encode(options: string): string;-}-interface ILuteNode {TokensStr: () => string;__internal_object__: {@@ -149,6 +97,42 @@ interface ILuteOptions extends IMarkdownConfig {lazyLoadImage?: string;}+declare class Viz {+ constructor(worker: { worker: Worker });++ renderSVGElement: (code: string) => Promise<any>;+}++declare class Viewer {+ public destroyed: boolean;++ constructor(element: Element, options: {+ title: [number, (image: HTMLImageElement, imageData: IObject) => string],+ button: boolean,+ initialViewIndex?: number,+ transition: boolean,+ hidden: () => void,+ toolbar: {+ zoomIn: boolean,+ zoomOut: boolean,+ oneToOne: boolean,+ reset: boolean,+ prev: boolean,+ play: boolean,+ next: boolean,+ rotateLeft: boolean,+ rotateRight: boolean,+ flipHorizontal: boolean,+ flipVertical: boolean,+ close: () => void+ }+ })++ public destroy(): void++ public show(): void+}+declare class Lute {public static WalkStop: number;public static WalkSkipChildren: number;