An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
interface ILuteNode {
TokensStr: () => string;
__internal_object__: {
Parent: {
Type: number,
},
HeadingLevel: string,
};
}
type THintSource = "search" | "av" | "hint";
type TTurnIntoOne =
"BlocksMergeSuperBlock"
| "Blocks2ULs"
| "Blocks2OLs"
| "Blocks2TLs"
| "Blocks2Blockquote"
| "Blocks2Callout"
type TTurnIntoOneSub = "row" | "col"
type TTurnInto = "Blocks2Ps" | "Blocks2Hs"
type TEditorMode = "preview" | "wysiwyg"
type ILuteRenderCallback = (node: ILuteNode, entering: boolean) => [string, number];
type TProtyleAction = "cb-get-append" | // 向下滚动加载
"cb-get-before" | // 向上滚动加载
"cb-get-unchangeid" | // 上下滚动,定位时不修改 blockid
"cb-get-hl" | // 高亮
"cb-get-focus" | // 光标定位
"cb-get-focusfirst" | // 动态定位到第一个块
"cb-get-setid" | // 无折叠大纲点击 重置 blockid
"cb-get-outline" | // 大纲点击
"cb-get-all" | // 获取所有块
"cb-get-backlink" | // 悬浮窗为传递型需展示上下文
"cb-get-unundo" | // 不需要记录历史
"cb-get-scroll" | // 滚动到指定位置,用于直接打开文档,必有 rootID
"cb-get-search" | // 使用搜索打开搜索
"cb-get-context" | // 包含上下文
"cb-get-rootscroll" | // 如果为 rootID 就滚动到指定位置,必有 rootID
"cb-get-html" | // 直接渲染,不需要再 /api/block/getDocInfo,否则搜索表格无法定位
"cb-get-history" | // 历史渲染
"cb-get-opennew" | // 编辑器只读后新建文件需为临时解锁状态 & https://github.com/siyuan-note/siyuan/issues/12197
"cb-get-av-no-create" // 属性视图不自动创建
/** @link https://ld246.com/article/1588412297062 */
interface ILuteRender {
renderDocument?: ILuteRenderCallback;
renderParagraph?: ILuteRenderCallback;
renderText?: ILuteRenderCallback;
renderCodeBlock?: ILuteRenderCallback;
renderCodeBlockOpenMarker?: ILuteRenderCallback;
renderCodeBlockInfoMarker?: ILuteRenderCallback;
renderCodeBlockCode?: ILuteRenderCallback;
renderCodeBlockCloseMarker?: ILuteRenderCallback;
renderMathBlock?: ILuteRenderCallback;
renderMathBlockOpenMarker?: ILuteRenderCallback;
renderMathBlockContent?: ILuteRenderCallback;
renderMathBlockCloseMarker?: ILuteRenderCallback;
renderBlockquote?: ILuteRenderCallback;
renderBlockquoteMarker?: ILuteRenderCallback;
renderHeading?: ILuteRenderCallback;
renderHeadingC8hMarker?: ILuteRenderCallback;
renderList?: ILuteRenderCallback;
renderListItem?: ILuteRenderCallback;
renderTaskListItemMarker?: ILuteRenderCallback;
renderThematicBreak?: ILuteRenderCallback;
renderHTML?: ILuteRenderCallback;
renderTable?: ILuteRenderCallback;
renderTableHead?: ILuteRenderCallback;
renderTableRow?: ILuteRenderCallback;
renderTableCell?: ILuteRenderCallback;
renderCodeSpan?: ILuteRenderCallback;
renderCodeSpanOpenMarker?: ILuteRenderCallback;
renderCodeSpanContent?: ILuteRenderCallback;
renderCodeSpanCloseMarker?: ILuteRenderCallback;
renderInlineMath?: ILuteRenderCallback;
renderInlineMathOpenMarker?: ILuteRenderCallback;
renderInlineMathContent?: ILuteRenderCallback;
renderInlineMathCloseMarker?: ILuteRenderCallback;
renderEmphasis?: ILuteRenderCallback;
renderEmAsteriskOpenMarker?: ILuteRenderCallback;
renderEmAsteriskCloseMarker?: ILuteRenderCallback;
renderEmUnderscoreOpenMarker?: ILuteRenderCallback;
renderEmUnderscoreCloseMarker?: ILuteRenderCallback;
renderStrong?: ILuteRenderCallback;
renderStrongA6kOpenMarker?: ILuteRenderCallback;
renderStrongA6kCloseMarker?: ILuteRenderCallback;
renderStrongU8eOpenMarker?: ILuteRenderCallback;
renderStrongU8eCloseMarker?: ILuteRenderCallback;
renderStrikethrough?: ILuteRenderCallback;
renderStrikethrough1OpenMarker?: ILuteRenderCallback;
renderStrikethrough1CloseMarker?: ILuteRenderCallback;
renderStrikethrough2OpenMarker?: ILuteRenderCallback;
renderStrikethrough2CloseMarker?: ILuteRenderCallback;
renderHardBreak?: ILuteRenderCallback;
renderSoftBreak?: ILuteRenderCallback;
renderInlineHTML?: ILuteRenderCallback;
renderLink?: ILuteRenderCallback;
renderOpenBracket?: ILuteRenderCallback;
renderCloseBracket?: ILuteRenderCallback;
renderOpenParen?: ILuteRenderCallback;
renderCloseParen?: ILuteRenderCallback;
renderLinkText?: ILuteRenderCallback;
renderLinkSpace?: ILuteRenderCallback;
renderLinkDest?: ILuteRenderCallback;
renderLinkTitle?: ILuteRenderCallback;
renderImage?: ILuteRenderCallback;
renderBang?: ILuteRenderCallback;
renderEmoji?: ILuteRenderCallback;
renderEmojiUnicode?: ILuteRenderCallback;
renderEmojiImg?: ILuteRenderCallback;
renderEmojiAlias?: ILuteRenderCallback;
renderBackslash?: ILuteRenderCallback;
renderBackslashContent?: ILuteRenderCallback;
}
interface IBreadcrumb {
id: string,
name: string,
documentTitle?: string,
type: string,
subType: string,
children: IBreadcrumb[],
hasChildren?: boolean
}
interface ILuteOptions extends IMarkdownConfig {
emojis: IObject;
emojiSite: string;
headingAnchor?: boolean;
lazyLoadImage?: string;
}
declare class Viz {
public static instance(): Promise<Viz>;
renderSVGElement: (code: string) => SVGElement;
}
declare class Viewer {
public viewer: HTMLElement;
public destroyed: boolean;
public image: HTMLImageElement;
public viewed: boolean;
public toolbar: HTMLElement;
constructor(element: Element, options: {
title: [number, (image: HTMLImageElement, imageData: IObject) => string],
button: boolean,
initialViewIndex?: number,
magnifier?: boolean,
navigation?: boolean,
transition: boolean,
hidden: () => void,
ready?: (this: HTMLElement, event: CustomEvent) => void,
view?: (this: HTMLElement, event: CustomEvent) => void,
viewed?: (this: HTMLElement, event: CustomEvent) => void,
toolbar: {
zoomIn: boolean,
zoomOut: boolean,
oneToOne: boolean,
reset: boolean,
prev: boolean,
play: boolean,
next: boolean,
rotateLeft: boolean,
rotateRight: boolean,
flipHorizontal: boolean,
flipVertical: boolean,
copy?: () => void,
copyFile?: () => void,
close?: () => void
}
})
public destroy(): void
public show(): void
public hide(): void
}
declare class Lute {
public static WalkStop: number;
public static WalkSkipChildren: number;
public static WalkContinue: number;
public static Version: string;
public static Caret: string;
public static New(): Lute;
public static NewNodeID(): string;
public static Sanitize(html: string): string;
public static EscapeHTMLStr(str: string): string;
public static UnEscapeHTMLStr(str: string): string;
public static GetHeadingID(node: ILuteNode): string;
public static BlockDOM2Content(html: string): string;
private constructor();
public BlockDOM2Content(text: string): string;
public BlockDOM2EscapeMarkerContent(text: string): string;
public SetSpin(enable: boolean): void;
public SetTextMark(enable: boolean): void;
public SetHTMLTag2TextMark(enable: boolean): void;
public SetHeadingID(enable: boolean): void;
public SetProtyleMarkNetImg(enable: boolean): void;
public SetSpellcheck(enable: boolean): void;
public SetFileAnnotationRef(enable: boolean): void;
public SetSetext(enable: boolean): void;
public SetYamlFrontMatter(enable: boolean): void;
public SetChineseParagraphBeginningSpace(enable: boolean): void;
public SetRenderListStyle(enable: boolean): void;
public SetImgPathAllowSpace(enable: boolean): void;
public SetKramdownIAL(enable: boolean): void;
public BlockDOM2Md(html: string): string;
public BlockDOM2StdMd(html: string): string;
public SetSuperBlock(enable: boolean): void;
public SetCallout(enable: boolean): void;
public SetTabs(enable: boolean): void;
public SetCustomBlock(enable: boolean): void;
public SetTag(enable: boolean): void;
public SetInlineMath(enable: boolean): void;
public SetLatexMath(enable: boolean): void;
public SetGFMStrikethrough(enable: boolean): void;
public SetGFMStrikethrough1(enable: boolean): void;
public SetFullWidthStrikethrough(enable: boolean): void;
public SetMark(enable: boolean): void;
public SetSub(enable: boolean): void;
public SetSup(enable: boolean): void;
public SetInlineAsterisk(enable: boolean): void;
public SetInlineUnderscore(enable: boolean): void;
public SetBlockRef(enable: boolean): void;
public SetSanitize(enable: boolean): void;
public SetHeadingAnchor(enable: boolean): void;
public SetImageLazyLoading(imagePath: string): void;
public SetInlineMathAllowDigitAfterOpenMarker(enable: boolean): void;
public SetToC(enable: boolean): void;
public SetIndentCodeBlock(enable: boolean): void;
public SetParagraphBeginningSpace(enable: boolean): void;
public SetFootnotes(enable: boolean): void;
public SetLinkRef(enable: boolean): void;
public SetEmojiSite(emojiSite: string): void;
public PutEmojis(emojis: IObject): void;
public SpinBlockDOM(html: string): string;
public Md2BlockDOM(html: string): string;
public Md2BlockDOMWithAutoLink(html: string): string;
public InlineMd2BlockDOM(markdown: string): string;
public SetProtyleWYSIWYG(wysiwyg: boolean): void;
public MarkdownStr(name: string, md: string): string;
public ProtylePreviewStr(name: string, md: string): string;
public GetLinkDest(text: string): string;
public BlockDOM2InlineBlockDOM(html: string): string;
public BlockDOM2HTML(html: string): string;
public BlockDOM2RichHTML(html: string): string;
public CancelListRecursively(html: string): string;
public ConvertListType(html: string, targetType: "u" | "o" | "t"): string;
public HTML2Md(html: string): string;
public HTML2BlockDOM(html: string): string;
public SetUnorderedListMarker(marker: string): void;
public SetDataTask(marker: boolean): void;
public SetExportNormalizeTaskListMarker(marker: boolean): void;
public SetArbitraryTaskListItemMarker(marker: boolean): void;
public SetEnsureListItemParagraph(enable: boolean): void;
}
declare const webkitAudioContext: {
prototype: AudioContext
new(contextOptions?: AudioContextOptions): AudioContext,
};
/** @link https://ld246.com/article/1549638745630#options-upload */
interface IUpload {
/** 上传 url */
url?: string;
/** 上传文件最大 Byte */
max?: number;
/** 剪切板中包含图片地址时,使用此 url 重新上传 */
linkToImgUrl?: string;
/** CORS 上传验证,头为 X-Upload-Token */
token?: string;
/** 文件上传类型,同 [input accept](https://www.w3schools.com/tags/att_input_accept.asp) */
accept?: string;
/** 跨站点访问控制。默认值: false */
withCredentials?: boolean;
/** 请求头设置 */
headers?: Record<string, string>;
/** 额外请求参数 */
extraData?: { [key: string]: string | Blob };
/** 上传字段名。默认值:file[] */
fieldName?: string;
/** 每次上传前都会重新设置请求头 */
setHeaders?(): IObject;
/** 上传成功回调 */
success?(editor: HTMLDivElement, msg: string): void;
/** 上传失败回调 */
error?(msg: string): void;
/** 文件名安全处理。 默认值: name => name.replace(/\W/g, '') */
filename?(name: string): string;
/** 校验,成功时返回 true 否则返回错误信息 */
validate?(files: File[]): string | boolean;
/** 自定义上传,返回 Promise 时将在其完成后报告上传结果,发生错误时返回错误信息,默认 120 秒超时并中止 signal */
handler?(files: File[], options?: { signal: AbortSignal }): string | null | PromiseLike<string | null>;
/** 对服务端返回的数据进行转换,以满足内置的数据结构 */
format?(files: File[], responseText: string): string;
/** 将上传的文件逐项处理后再返回;返回项必须保持原有逻辑顺序 */
file?(files: File[]): File[];
/** 图片地址上传后的回调 */
linkToImgCallback?(responseText: string): void;
}
interface IScrollAttr {
rootId: string,
startId?: string,
endId?: string
scrollTop?: number,
focusId?: string,
focusStart?: number
focusEnd?: number
zoomInId?: string
}
/** @link https://ld246.com/article/1549638745630#options-toolbar */
interface IMenuItem {
/** 唯一标示 */
name: string;
/** 提示 */
tip?: string;
/** 语言 key */
lang?: string;
/** svg 图标 */
icon?: string;
/** 快捷键 */
hotkey?: string;
/** 提示的位置 */
tipPosition?: string;
/** 是否在精简版中显示。默认值:false */
showInLite?: boolean;
click?(protyle: import("../protyle").Protyle): void;
}
/** @link https://ld246.com/article/1549638745630#options-preview-markdown */
interface IMarkdownConfig {
/** 段落开头是否空两格。默认值: false */
paragraphBeginningSpace?: boolean;
/** 是否启用过滤 XSS。默认值: true */
sanitize?: boolean;
/** 为列表添加标记,以便[自定义列表样式](https://github.com/Vanessa219/vditor/issues/390) 默认值:false */
listStyle?: boolean;
}
/** @link https://ld246.com/article/1549638745630#options-preview */
interface IPreview {
/** 预览 debounce 毫秒间隔。默认值: 1000 */
delay?: number;
/** 显示模式。默认值: 'both' */
mode?: "both" | "editor";
/** md 解析请求 */
url?: string;
/** @link https://ld246.com/article/1549638745630#options-preview-markdown */
markdown?: IMarkdownConfig;
/** @link https://ld246.com/article/1549638745630#options-preview-actions */
actions?: Array<IPreviewAction | IPreviewActionCustom>;
/** 渲染之前回调 */
transform?(html: string): string;
}
type IPreviewAction = "desktop" | "tablet" | "mobile" | "mp-wechat" | "zhihu" | "yuque";
interface IPreviewActionCustom {
/** 键名 */
key: string;
/** 按钮文本 */
text: string;
/** 按钮 className 值 */
className?: string;
/** 点击回调 */
click: (key: string) => void;
}
interface IHintData {
id?: string;
html: string;
value: string;
filter?: string[];
focus?: boolean;
}
interface IHintExtend {
key: string;
hint?(value: string, protyle: IProtyle, source: THintSource): IHintData[];
}
/** @link https://ld246.com/article/1549638745630#options-hint */
interface IHint {
/** 常用表情提示 HTML */
emojiTail?: string;
/** 提示 debounce 毫秒间隔。默认值: 200 */
delay?: number;
/** 默认表情,可从 [lute/emoji_map](https://github.com/88250/lute/blob/master/parse/emoji_map.go#L32) 中选取,也可自定义 */
emoji?: IObject;
emojiPath?: string;
extend?: IHintExtend[];
}
/** @link https://ld246.com/article/1549638745630#options */
interface IProtyleOptions {
databaseAttr?: boolean,
history?: {
created?: string
snapshot?: string
},
backlinkData?: {
referenceBlockID?: string,
id?: string,
revision?: string,
blockPaths: IBreadcrumb[],
dom: string
expand: boolean
}[],
action?: TProtyleAction[],
scrollPosition?: ScrollLogicalPosition,
scrollAttr?: IScrollAttr,
mode?: TEditorMode,
blockId?: string
rootId?: string
notebookId?: string
originalRefBlockIDs?: Record<string, string>
key?: string
defIds?: string[]
render?: {
background?: boolean
title?: boolean
titleShowTop?: boolean
gutter?: boolean
scroll?: boolean
breadcrumb?: boolean
breadcrumbDocName?: boolean
hideTitleOnZoom?: boolean
}
/** 内部调试时使用 */
_lutePath?: string;
/** 是否启用打字机模式。默认值: false */
typewriterMode?: boolean;
toolbar?: Array<string | IMenuItem>;
/** @link https://ld246.com/article/1549638745630#options-preview */
preview?: IPreview;
/** @link https://ld246.com/article/1549638745630#options-hint */
hint?: IHint;
/** @link https://ld246.com/article/1549638745630#options-upload */
upload?: IUpload;
/** @link https://ld246.com/article/1549638745630#options-classes */
classes?: {
preview?: string;
};
click?: {
/** 点击末尾是否阻止插入新块 */
preventInsetEmptyBlock?: boolean
}
handleEmptyContent?(): void
/** 编辑器异步渲染完成后的回调方法 */
after?(protyle: import("../protyle").Protyle): void;
/** 精简版本 */
lite?: boolean;
}
interface ITrackedRangeHandle {
readonly id: string;
}
interface ITrackRangeOptions {
/** 用于在插件卸载时自动释放句柄 */
owner: import("../plugin").Plugin;
/** 同一位置插入新内容时,锚点保留在新内容之前还是之后,默认为 before */
affinity?: "before" | "after";
}
type TTrackedRangeResult = {
status: "resolved";
range: Range;
} | {
status: "invalid";
};
interface IProtyle {
highlight: {
mark: Highlight
markHL: Highlight
ranges: Range[]
rangeIndex: number
styleElement: HTMLStyleElement
}
getInstance: () => import("../protyle").Protyle,
trackRange: (range: Range, options: ITrackRangeOptions) => ITrackedRangeHandle,
resolveTrackedRange: (handle: ITrackedRangeHandle) => TTrackedRangeResult,
releaseTrackedRange: (handle: ITrackedRangeHandle) => void,
observerLoad?: ResizeObserver,
observer?: ResizeObserver,
app: import("../index").App,
id: string,
query?: {
key: string,
method: number
types: Config.IUILayoutTabSearchConfigTypes
subTypes: Config.IUILayoutTabSearchConfigSubTypes
},
block: {
id?: string,
scroll?: boolean
parentID?: string,
parent2ID?: string,
rootID?: string,
showAll?: boolean
mode?: number
blockCount?: number
action?: TProtyleAction[]
headingNumbers?: Record<string, string>
headingNumberLevels?: Record<string, string>
},
disabled: boolean,
lite?: boolean,
selectElement?: HTMLElement,
ws?: import("../layout/Model").Model,
notebookId?: string
path?: string
model?: import("../../src/editor").Editor,
updated: boolean;
element: HTMLElement;
scroll?: import("../protyle/scroll").Scroll,
gutter?: import("../protyle/gutter").Gutter,
breadcrumb?: import("../protyle/breadcrumb").Breadcrumb,
title?: import("../protyle/header/Title").Title,
background?: import("../protyle/header/Background").Background,
databaseAttributePanel?: import("../protyle/render/av/attributePanel").AVAttributePanel,
contentElement?: HTMLElement,
options: IProtyleOptions;
lute?: Lute;
toolbar?: import("../protyle/toolbar").Toolbar,
preview?: import("../protyle/preview").Preview;
hint?: import("../protyle/hint").Hint;
upload?: import("../protyle/upload").Upload;
undo?: import("../protyle/undo").IUndo;
wysiwyg?: import("../protyle/wysiwyg").WYSIWYG
}