@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.
Files changed (66) hide show
  1. package/dist/index.cjs +1806 -0
  2. package/dist/index.d.ts +23 -0
  3. package/dist/index.js +1774 -0
  4. package/dist/plugins/attachment.d.ts +7 -0
  5. package/dist/plugins/base-extensions.d.ts +8 -0
  6. package/dist/plugins/close-brackets.d.ts +8 -0
  7. package/dist/plugins/expand-text.d.ts +11 -0
  8. package/dist/plugins/fold.d.ts +8 -0
  9. package/dist/plugins/hanging-indent.d.ts +7 -0
  10. package/dist/plugins/indent-guide.d.ts +7 -0
  11. package/dist/plugins/index.d.ts +22 -0
  12. package/dist/plugins/keymap.d.ts +8 -0
  13. package/dist/plugins/line-numbers.d.ts +7 -0
  14. package/dist/plugins/link-handler.d.ts +8 -0
  15. package/dist/plugins/list-continuation.d.ts +8 -0
  16. package/dist/plugins/live-preview.d.ts +8 -0
  17. package/dist/plugins/markdown-language.d.ts +8 -0
  18. package/dist/plugins/on-change.d.ts +7 -0
  19. package/dist/plugins/suggest.d.ts +16 -0
  20. package/dist/plugins/table-continuation.d.ts +9 -0
  21. package/dist/plugins/table.d.ts +7 -0
  22. package/dist/plugins/theme.d.ts +8 -0
  23. package/dist/plugins/types.d.ts +29 -0
  24. package/dist/table/copy-widget.d.ts +17 -0
  25. package/dist/table/detect.d.ts +15 -0
  26. package/dist/table/format.d.ts +15 -0
  27. package/dist/table/index.d.ts +6 -0
  28. package/dist/table/theme.d.ts +8 -0
  29. package/package.json +57 -0
  30. package/vendor/app.css +15715 -0
  31. package/vendor/enhance.js +641 -0
  32. package/vendor/i18n/en.json +2144 -0
  33. package/vendor/i18n/zh.json +2144 -0
  34. package/vendor/lib/codemirror.js +14806 -0
  35. package/vendor/lib/i18next.min.js +2654 -0
  36. package/vendor/lib/markdown.js +1717 -0
  37. package/vendor/lib/mathjax/output/chtml/fonts/tex.js +1 -0
  38. package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_AMS-Regular.woff +0 -0
  39. package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Bold.woff +0 -0
  40. package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Regular.woff +0 -0
  41. package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Bold.woff +0 -0
  42. package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Regular.woff +0 -0
  43. package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Bold.woff +0 -0
  44. package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Italic.woff +0 -0
  45. package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Regular.woff +0 -0
  46. package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-BoldItalic.woff +0 -0
  47. package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-Italic.woff +0 -0
  48. package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-Regular.woff +0 -0
  49. package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Bold.woff +0 -0
  50. package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Italic.woff +0 -0
  51. package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Regular.woff +0 -0
  52. package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Script-Regular.woff +0 -0
  53. package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Size1-Regular.woff +0 -0
  54. package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Size2-Regular.woff +0 -0
  55. package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Size3-Regular.woff +0 -0
  56. package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Size4-Regular.woff +0 -0
  57. package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Typewriter-Regular.woff +0 -0
  58. package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Vector-Bold.woff +0 -0
  59. package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Vector-Regular.woff +0 -0
  60. package/vendor/lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Zero.woff +0 -0
  61. package/vendor/lib/mathjax/tex-chtml-full.js +36 -0
  62. package/vendor/lib/meta.min.js +1 -0
  63. package/vendor/lib/modes.min.js +236 -0
  64. package/vendor/lib/turndown.js +679 -0
  65. package/vendor/mock.js +28 -0
  66. package/vendor/obsidian-app.patched.js +161786 -0
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Attachment 插件
3
+ *
4
+ * 粘贴图片 / 拖拽文件 / HTML 粘贴转 Markdown。
5
+ */
6
+ import type { EditorPlugin } from '../types.js';
7
+ export declare const attachmentPlugin: EditorPlugin;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Base Extensions 插件
3
+ *
4
+ * 加载 Obsidian 的基础扩展集(通过 compartment),
5
+ * 以及核心 StateField(editor/owner)的注入。
6
+ */
7
+ import type { EditorPlugin } from '../types.js';
8
+ export declare const baseExtensionsPlugin: EditorPlugin;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Close Brackets 插件
3
+ *
4
+ * 自动配对括号和 Markdown 标记(基于 Obsidian 的 closeBrackets 扩展)。
5
+ * 支持 ()[]{}'"*_` 以及 ``` 的自动配对。
6
+ */
7
+ import type { EditorPlugin } from '../types.js';
8
+ export declare const closeBracketsPlugin: EditorPlugin;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Expand Text 插件
3
+ *
4
+ * 中文括号自动转换:
5
+ * - 【【 → [[
6
+ * - !【【 → ![[
7
+ * - 】】 → ]]
8
+ * - ··· → ```
9
+ */
10
+ import type { EditorPlugin } from '../types.js';
11
+ export declare const expandTextPlugin: EditorPlugin;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Fold 插件
3
+ *
4
+ * 标题折叠 + 缩进折叠 + 折叠 UI(gutter 按钮)。
5
+ * 根据 options.foldHeading / options.foldIndent 决定启用哪些折叠模式。
6
+ */
7
+ import type { EditorPlugin } from '../types.js';
8
+ export declare const foldPlugin: EditorPlugin;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Hanging Indent 插件
3
+ *
4
+ * 列表悬挂缩进:续行文本对齐到列表标记之后。
5
+ */
6
+ import type { EditorPlugin } from '../types.js';
7
+ export declare const hangingIndentPlugin: EditorPlugin;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Indent Guide 插件
3
+ *
4
+ * 显示缩进指引线。
5
+ */
6
+ import type { EditorPlugin } from '../types.js';
7
+ export declare const indentGuidePlugin: EditorPlugin;
@@ -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,8 @@
1
+ /**
2
+ * Keymap 插件
3
+ *
4
+ * 核心快捷键:Tab 缩进、Ctrl+S 保存。
5
+ * 注意:Enter 列表续行由 list-continuation 插件处理。
6
+ */
7
+ import type { EditorPlugin } from '../types.js';
8
+ export declare const keymapPlugin: EditorPlugin;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Line Numbers 插件
3
+ *
4
+ * 显示行号 + 活动行 gutter 高亮。
5
+ */
6
+ import type { EditorPlugin } from '../types.js';
7
+ export declare const lineNumbersPlugin: EditorPlugin;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Link Handler 插件
3
+ *
4
+ * 处理内部链接([[link]])和外部链接([text](url))的点击导航。
5
+ * 通过 options.onLinkClick / options.onExternalLinkClick 或 backend.openFile 处理。
6
+ */
7
+ import type { EditorPlugin } from '../types.js';
8
+ export declare const linkHandlerPlugin: EditorPlugin;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * List Continuation 插件
3
+ *
4
+ * 智能列表续行:Enter 时自动创建下一列表项,
5
+ * 空项时按 Enter 退出列表。支持有序/无序/checkbox 列表。
6
+ */
7
+ import type { EditorPlugin } from '../types.js';
8
+ export declare const listContinuationPlugin: EditorPlugin;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Live Preview 插件
3
+ *
4
+ * 封装 Obsidian 的 __kH 渲染引擎,实现 WYSIWYG 模式:
5
+ * 光标离开区域隐藏 markdown 语法符号,光标进入则显示原始符号。
6
+ */
7
+ import type { EditorPlugin } from '../types.js';
8
+ export declare const livePreviewPlugin: EditorPlugin;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Markdown Language 插件
3
+ *
4
+ * 注入 Obsidian 的自定义 Markdown 语法定义(parser + syntax highlighting),
5
+ * 支持 wiki-link、callout、tag、embed 等扩展语法节点。
6
+ */
7
+ import type { EditorPlugin } from '../types.js';
8
+ export declare const markdownLanguagePlugin: EditorPlugin;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * OnChange 插件
3
+ *
4
+ * 监听文档变更,触发 options.onChange 回调。
5
+ */
6
+ import type { EditorPlugin } from '../types.js';
7
+ export declare const onChangePlugin: EditorPlugin;
@@ -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,9 @@
1
+ /**
2
+ * Table Continuation 插件
3
+ *
4
+ * 类似列表续行,在表格行末尾按 Enter 时:
5
+ * - 非空数据行 / separator 行 → 插入一个列数匹配的空行,并格式化表格
6
+ * - 空行(所有单元格为空)→ 删除该行(退出表格)
7
+ */
8
+ import type { EditorPlugin } from '../types.js';
9
+ export declare const tableContinuationPlugin: EditorPlugin;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Table 插件
3
+ *
4
+ * 纯文本表格 Live Preview:自动格式化、行装饰、复制按钮。
5
+ */
6
+ import type { EditorPlugin } from '../types.js';
7
+ export declare const tablePlugin: EditorPlugin;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Theme 插件
3
+ *
4
+ * 管理编辑器容器的 CSS 类和 CSS 变量。
5
+ * 设置 dark/light 主题、readable-line-width 等外观属性。
6
+ */
7
+ import type { EditorPlugin } from '../types.js';
8
+ export declare const themePlugin: 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 };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 纯文本表格 Live Preview 扩展 — 入口
3
+ *
4
+ * 组合检测、格式化、复制按钮和主题,返回 CM6 Extension 数组
5
+ */
6
+ export declare function createTableExtension(): any[];
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 表格主题样式
3
+ *
4
+ * 无 border(避免内容跳动),仅使用背景色区分行
5
+ * 复制按钮样式与 Obsidian code-block-flair 统一
6
+ * 所有颜色使用全局 CSS 变量
7
+ */
8
+ export declare function createTableTheme(EditorView: any): any;
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
+ }