@xlxz/markdown-editor 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1806 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +1774 -0
- package/dist/plugins/attachment.d.ts +7 -0
- package/dist/plugins/base-extensions.d.ts +8 -0
- package/dist/plugins/close-brackets.d.ts +8 -0
- package/dist/plugins/expand-text.d.ts +11 -0
- package/dist/plugins/fold.d.ts +8 -0
- package/dist/plugins/hanging-indent.d.ts +7 -0
- package/dist/plugins/indent-guide.d.ts +7 -0
- package/dist/plugins/index.d.ts +22 -0
- package/dist/plugins/keymap.d.ts +8 -0
- package/dist/plugins/line-numbers.d.ts +7 -0
- package/dist/plugins/link-handler.d.ts +8 -0
- package/dist/plugins/list-continuation.d.ts +8 -0
- package/dist/plugins/live-preview.d.ts +8 -0
- package/dist/plugins/markdown-language.d.ts +8 -0
- package/dist/plugins/on-change.d.ts +7 -0
- package/dist/plugins/suggest.d.ts +16 -0
- package/dist/plugins/table-continuation.d.ts +9 -0
- package/dist/plugins/table.d.ts +7 -0
- package/dist/plugins/theme.d.ts +8 -0
- package/dist/plugins/types.d.ts +29 -0
- package/dist/table/copy-widget.d.ts +17 -0
- package/dist/table/detect.d.ts +15 -0
- package/dist/table/format.d.ts +15 -0
- package/dist/table/index.d.ts +6 -0
- package/dist/table/theme.d.ts +8 -0
- package/package.json +57 -0
- package/vendor/app.css +15715 -0
- package/vendor/enhance.js +641 -0
- package/vendor/i18n/en.json +2144 -0
- package/vendor/i18n/zh.json +2144 -0
- package/vendor/lib/codemirror.js +14806 -0
- package/vendor/lib/i18next.min.js +2654 -0
- package/vendor/lib/markdown.js +1717 -0
- package/vendor/lib/mathjax/output/chtml/fonts/tex.js +1 -0
- package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_AMS-Regular.woff +0 -0
- package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Bold.woff +0 -0
- package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Regular.woff +0 -0
- package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Bold.woff +0 -0
- package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Regular.woff +0 -0
- package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Bold.woff +0 -0
- package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Italic.woff +0 -0
- package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Regular.woff +0 -0
- package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-BoldItalic.woff +0 -0
- package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-Italic.woff +0 -0
- package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-Regular.woff +0 -0
- package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Bold.woff +0 -0
- package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Italic.woff +0 -0
- package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Regular.woff +0 -0
- package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Script-Regular.woff +0 -0
- package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Size1-Regular.woff +0 -0
- package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Size2-Regular.woff +0 -0
- package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Size3-Regular.woff +0 -0
- package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Size4-Regular.woff +0 -0
- package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Typewriter-Regular.woff +0 -0
- package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Vector-Bold.woff +0 -0
- package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Vector-Regular.woff +0 -0
- package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Zero.woff +0 -0
- package/vendor/lib/mathjax/tex-chtml-full.js +36 -0
- package/vendor/lib/meta.min.js +1 -0
- package/vendor/lib/modes.min.js +236 -0
- package/vendor/lib/turndown.js +679 -0
- package/vendor/mock.js +28 -0
- package/vendor/obsidian-app.patched.js +161786 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 插件集合 — 按功能分类导出所有内置插件
|
|
3
|
+
*/
|
|
4
|
+
export { livePreviewPlugin } from './live-preview.js';
|
|
5
|
+
export { markdownLanguagePlugin } from './markdown-language.js';
|
|
6
|
+
export { hangingIndentPlugin } from './hanging-indent.js';
|
|
7
|
+
export { listContinuationPlugin } from './list-continuation.js';
|
|
8
|
+
export { closeBracketsPlugin } from './close-brackets.js';
|
|
9
|
+
export { expandTextPlugin } from './expand-text.js';
|
|
10
|
+
export { foldPlugin } from './fold.js';
|
|
11
|
+
export { lineNumbersPlugin } from './line-numbers.js';
|
|
12
|
+
export { indentGuidePlugin } from './indent-guide.js';
|
|
13
|
+
export { suggestPlugin } from './suggest.js';
|
|
14
|
+
export { linkHandlerPlugin } from './link-handler.js';
|
|
15
|
+
export { attachmentPlugin } from './attachment.js';
|
|
16
|
+
export { tablePlugin } from './table.js';
|
|
17
|
+
export { tableContinuationPlugin } from './table-continuation.js';
|
|
18
|
+
export { themePlugin } from './theme.js';
|
|
19
|
+
export { baseExtensionsPlugin } from './base-extensions.js';
|
|
20
|
+
export { keymapPlugin } from './keymap.js';
|
|
21
|
+
export { onChangePlugin } from './on-change.js';
|
|
22
|
+
export type { CompletionProvider } from './types.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Suggest 插件 — Input Prompter
|
|
3
|
+
*
|
|
4
|
+
* 通用输入提示框架,支持多个 CompletionProvider 注册。
|
|
5
|
+
* 每个 provider 声明自己的 trigger 和补全逻辑,suggest 插件统一管理:
|
|
6
|
+
* - 弹窗 UI(位置计算、渲染、滚动)
|
|
7
|
+
* - 键盘导航(ArrowUp/Down/Enter/Tab/Escape)
|
|
8
|
+
* - 多 provider 优先级(先匹配先响应)
|
|
9
|
+
*
|
|
10
|
+
* 用法:
|
|
11
|
+
* editor.use(suggestPlugin);
|
|
12
|
+
* editor.registerSuggest({ trigger: /\[\[(.*)$/, getSuggestions, suffix: ']]' });
|
|
13
|
+
* editor.registerSuggest({ trigger: /#(.*)$/, getSuggestions });
|
|
14
|
+
*/
|
|
15
|
+
import type { EditorPlugin } from '../types.js';
|
|
16
|
+
export declare const suggestPlugin: EditorPlugin;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 插件系统内部类型
|
|
3
|
+
*
|
|
4
|
+
* 与 src/types.ts 中的公开类型互补,定义插件注册表内部使用的接口。
|
|
5
|
+
*/
|
|
6
|
+
export interface PluginRegistry {
|
|
7
|
+
register(plugin: import('../types.js').EditorPlugin): void;
|
|
8
|
+
unregister(pluginId: string): void;
|
|
9
|
+
get(pluginId: string): import('../types.js').EditorPlugin | undefined;
|
|
10
|
+
has(pluginId: string): boolean;
|
|
11
|
+
getAll(): import('../types.js').EditorPlugin[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* CompletionProvider — Input Prompter 的 provider 接口
|
|
15
|
+
*
|
|
16
|
+
* 每个 provider 声明触发条件和补全逻辑,suggest 插件统一管理 UI。
|
|
17
|
+
*/
|
|
18
|
+
export interface CompletionProvider {
|
|
19
|
+
/** Provider 唯一标识 */
|
|
20
|
+
id: string;
|
|
21
|
+
/** 触发正则(匹配光标前文本末尾) */
|
|
22
|
+
trigger: RegExp;
|
|
23
|
+
/** 根据匹配到的 query 返回建议列表 */
|
|
24
|
+
getSuggestions(query: string): import('../types.js').SuggestItem[] | Promise<import('../types.js').SuggestItem[]>;
|
|
25
|
+
/** 选中建议后的额外操作(可选) */
|
|
26
|
+
onAccept?(item: import('../types.js').SuggestItem): void;
|
|
27
|
+
/** 插入建议后追加的后缀,如 "]]" */
|
|
28
|
+
suffix?: string;
|
|
29
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 表格复制按钮 Widget
|
|
3
|
+
*
|
|
4
|
+
* 样式与 Obsidian 代码块复制按钮统一(copy-code-button 风格)
|
|
5
|
+
* 点击复制 Tab 分隔格式,可直接粘贴到 Excel/Google Sheets
|
|
6
|
+
*/
|
|
7
|
+
export declare function createCopyButtonWidgetClass(WidgetType: any): {
|
|
8
|
+
new (tableFrom: number, tableTo: number): {
|
|
9
|
+
[x: string]: any;
|
|
10
|
+
tableFrom: number;
|
|
11
|
+
tableTo: number;
|
|
12
|
+
toDOM(view: any): HTMLButtonElement;
|
|
13
|
+
eq(other: any): boolean;
|
|
14
|
+
ignoreEvent(): boolean;
|
|
15
|
+
};
|
|
16
|
+
[x: string]: any;
|
|
17
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 表格检测:识别文档中的 Markdown 表格区域
|
|
3
|
+
*
|
|
4
|
+
* 规则:连续的 | 开头/结尾行,且必须包含 separator 行(|---|)
|
|
5
|
+
*/
|
|
6
|
+
export interface TableRange {
|
|
7
|
+
from: number;
|
|
8
|
+
to: number;
|
|
9
|
+
firstLine: number;
|
|
10
|
+
lastLine: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function isTableLine(text: string): boolean;
|
|
13
|
+
export declare function isSeparatorLine(text: string): boolean;
|
|
14
|
+
export declare function findTableRanges(doc: any): TableRange[];
|
|
15
|
+
export declare function cursorInTable(state: any, table: TableRange): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 表格格式化:光标离开时自动对齐列宽
|
|
3
|
+
*
|
|
4
|
+
* 以各列最宽内容为基准补空格,保留对齐模式(:---, :---:, ---:)
|
|
5
|
+
*/
|
|
6
|
+
import { type TableRange } from './detect.js';
|
|
7
|
+
declare function parseCells(text: string): string[];
|
|
8
|
+
declare function cellContent(cell: string): string;
|
|
9
|
+
export declare function formatTable(doc: any, table: TableRange): {
|
|
10
|
+
from: number;
|
|
11
|
+
to: number;
|
|
12
|
+
insert: string;
|
|
13
|
+
} | null;
|
|
14
|
+
/** 导出给复制按钮用 */
|
|
15
|
+
export { parseCells, cellContent };
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xlxz/markdown-editor",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Obsidian-quality Markdown live preview editor — microkernel + plugin architecture. Internal use.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"publishConfig": { "access": "public" },
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"main": "./dist/index.cjs",
|
|
16
|
+
"module": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"vendor"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "bun build src/index.ts --outfile dist/index.js --format esm --target browser --external vue && bun build src/index.ts --outfile dist/index.cjs --format cjs --target browser --external vue && tsc -p tsconfig.json --emitDeclarationOnly --declaration && rm -f dist/kernel.d.ts dist/types.d.ts dist/defaults.d.ts dist/mocks.d.ts dist/auto-load.d.ts dist/plugin-defaults.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"vue": "^3.5.0"
|
|
27
|
+
},
|
|
28
|
+
"peerDependenciesMeta": {
|
|
29
|
+
"vue": {
|
|
30
|
+
"optional": true
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@babel/generator": "^7.29.1",
|
|
35
|
+
"@babel/parser": "^7.29.3",
|
|
36
|
+
"@babel/traverse": "^7.29.0",
|
|
37
|
+
"@babel/types": "^7.29.0",
|
|
38
|
+
"@codemirror/autocomplete": "^6.20.2",
|
|
39
|
+
"@codemirror/collab": "^6.1.1",
|
|
40
|
+
"@codemirror/commands": "^6.10.3",
|
|
41
|
+
"@codemirror/language": "^6.12.3",
|
|
42
|
+
"@codemirror/lint": "^6.9.6",
|
|
43
|
+
"@codemirror/search": "^6.7.0",
|
|
44
|
+
"@codemirror/state": "^6.6.0",
|
|
45
|
+
"@codemirror/view": "^6.43.0",
|
|
46
|
+
"@lezer/common": "^1.5.2",
|
|
47
|
+
"@lezer/highlight": "^1.2.3",
|
|
48
|
+
"@lezer/lr": "^1.4.10",
|
|
49
|
+
"@lezer/markdown": "^1.6.3",
|
|
50
|
+
"base64-js": "^1.5.1",
|
|
51
|
+
"puppeteer": "^25.0.4",
|
|
52
|
+
"ts-morph": "^28.0.0"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"string-width": "^8.2.1"
|
|
56
|
+
}
|
|
57
|
+
}
|