@king-design/vue 3.7.0 → 3.8.0-beta.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/__tests__/__snapshots__/Vue Next Demos.md +399 -0
- package/components/bubble/bubble.d.ts +61 -0
- package/components/bubble/bubble.js +81 -0
- package/components/bubble/bubble.vdt.js +85 -0
- package/components/bubble/index.d.ts +1 -0
- package/components/bubble/index.js +1 -0
- package/components/bubble/index.spec.d.ts +1 -0
- package/components/bubble/index.spec.js +771 -0
- package/components/bubble/styles.d.ts +5 -0
- package/components/bubble/styles.js +53 -0
- package/components/bubble/useBubbleDisplay.d.ts +18 -0
- package/components/bubble/useBubbleDisplay.js +300 -0
- package/components/bubbleList/bubbleList.d.ts +87 -0
- package/components/bubbleList/bubbleList.js +75 -0
- package/components/bubbleList/bubbleList.vdt.js +143 -0
- package/components/bubbleList/index.d.ts +1 -0
- package/components/bubbleList/index.js +1 -0
- package/components/bubbleList/index.spec.d.ts +1 -0
- package/components/bubbleList/index.spec.js +1268 -0
- package/components/bubbleList/item.d.ts +16 -0
- package/components/bubbleList/item.js +27 -0
- package/components/bubbleList/item.vdt.js +36 -0
- package/components/bubbleList/styles.d.ts +5 -0
- package/components/bubbleList/styles.js +33 -0
- package/components/bubbleList/useBubbleList.d.ts +28 -0
- package/components/bubbleList/useBubbleList.js +455 -0
- package/components/checkbox/index.d.ts +3 -3
- package/components/fileCard/fileCard.d.ts +65 -0
- package/components/fileCard/fileCard.js +72 -0
- package/components/fileCard/fileCard.vdt.js +161 -0
- package/components/fileCard/fileCardAssets.d.ts +1 -0
- package/components/fileCard/fileCardAssets.js +54 -0
- package/components/fileCard/fileCardUtils.d.ts +14 -0
- package/components/fileCard/fileCardUtils.js +94 -0
- package/components/fileCard/index.d.ts +2 -0
- package/components/fileCard/index.js +2 -0
- package/components/fileCard/index.spec.d.ts +1 -0
- package/components/fileCard/index.spec.js +1096 -0
- package/components/fileCard/list.d.ts +29 -0
- package/components/fileCard/list.js +46 -0
- package/components/fileCard/list.vdt.js +71 -0
- package/components/fileCard/styles.d.ts +5 -0
- package/components/fileCard/styles.js +83 -0
- package/components/fileCard/useFileCard.d.ts +45 -0
- package/components/fileCard/useFileCard.js +330 -0
- package/components/fileCard/useFileCardList.d.ts +14 -0
- package/components/fileCard/useFileCardList.js +49 -0
- package/components/form/form.js +2 -1
- package/components/media/context.d.ts +6 -0
- package/components/media/context.js +2 -0
- package/components/media/group.d.ts +12 -0
- package/components/media/group.js +32 -0
- package/components/media/group.vdt.js +50 -0
- package/components/media/index.d.ts +2 -0
- package/components/media/index.js +2 -0
- package/components/media/index.spec.d.ts +1 -0
- package/components/media/index.spec.js +1691 -0
- package/components/media/media.d.ts +37 -0
- package/components/media/media.js +67 -0
- package/components/media/media.vdt.js +202 -0
- package/components/media/mediaAssets.d.ts +4 -0
- package/components/media/mediaAssets.js +9 -0
- package/components/media/mediaUtils.d.ts +6 -0
- package/components/media/mediaUtils.js +66 -0
- package/components/media/styles.d.ts +13 -0
- package/components/media/styles.js +52 -0
- package/components/media/types.d.ts +37 -0
- package/components/media/types.js +1 -0
- package/components/media/useMedia.d.ts +70 -0
- package/components/media/useMedia.js +471 -0
- package/components/media/useMediaGroup.d.ts +15 -0
- package/components/media/useMediaGroup.js +136 -0
- package/components/media/useMediaViewer.d.ts +14 -0
- package/components/media/useMediaViewer.js +129 -0
- package/components/media/viewer.d.ts +24 -0
- package/components/media/viewer.js +54 -0
- package/components/media/viewer.vdt.js +100 -0
- package/components/radio/index.d.ts +3 -3
- package/components/sender/icons.d.ts +3 -0
- package/components/sender/icons.js +17 -0
- package/components/sender/index.d.ts +1 -0
- package/components/sender/index.js +1 -0
- package/components/sender/index.spec.d.ts +1 -0
- package/components/sender/index.spec.js +1597 -0
- package/components/sender/sender.d.ts +104 -0
- package/components/sender/sender.js +111 -0
- package/components/sender/sender.vdt.js +230 -0
- package/components/sender/styles.d.ts +5 -0
- package/components/sender/styles.js +56 -0
- package/components/sender/useAutoResize.d.ts +4 -0
- package/components/sender/useAutoResize.js +99 -0
- package/components/sender/useSenderDrag.d.ts +6 -0
- package/components/sender/useSenderDrag.js +320 -0
- package/components/sender/useSenderInput.d.ts +16 -0
- package/components/sender/useSenderInput.js +101 -0
- package/components/sender/useSenderPaste.d.ts +5 -0
- package/components/sender/useSenderPaste.js +36 -0
- package/components/sender/useSenderUpload.d.ts +11 -0
- package/components/sender/useSenderUpload.js +395 -0
- package/components/skeleton/skeleton.d.ts +2 -1
- package/components/skeleton/skeleton.js +1 -1
- package/components/think/index.d.ts +1 -0
- package/components/think/index.js +1 -0
- package/components/think/index.spec.d.ts +1 -0
- package/components/think/index.spec.js +345 -0
- package/components/think/index.vdt.js +82 -0
- package/components/think/styles.d.ts +5 -0
- package/components/think/styles.js +25 -0
- package/components/think/think.d.ts +28 -0
- package/components/think/think.js +48 -0
- package/components/think/useThinkExpand.d.ts +10 -0
- package/components/think/useThinkExpand.js +56 -0
- package/components/types.d.ts +4 -2
- package/components/upload/ajaxUploader.d.ts +1 -0
- package/components/upload/ajaxUploader.js +6 -0
- package/components/xmarkdown/index.d.ts +2 -0
- package/components/xmarkdown/index.js +1 -0
- package/components/xmarkdown/index.spec.d.ts +1 -0
- package/components/xmarkdown/index.spec.js +1666 -0
- package/components/xmarkdown/markdown/codeBlockRenderer.d.ts +8 -0
- package/components/xmarkdown/markdown/codeBlockRenderer.js +52 -0
- package/components/xmarkdown/markdown/codeblock.d.ts +8 -0
- package/components/xmarkdown/markdown/codeblock.js +74 -0
- package/components/xmarkdown/markdown/highlight.d.ts +17 -0
- package/components/xmarkdown/markdown/highlight.js +83 -0
- package/components/xmarkdown/markdown/index.d.ts +14 -0
- package/components/xmarkdown/markdown/index.js +14 -0
- package/components/xmarkdown/markdown/mermaid.d.ts +8 -0
- package/components/xmarkdown/markdown/mermaid.js +104 -0
- package/components/xmarkdown/markdown/renderTree.d.ts +54 -0
- package/components/xmarkdown/markdown/renderTree.js +386 -0
- package/components/xmarkdown/markdown/renderer.d.ts +18 -0
- package/components/xmarkdown/markdown/renderer.js +461 -0
- package/components/xmarkdown/markdown/streaming.d.ts +24 -0
- package/components/xmarkdown/markdown/streaming.js +513 -0
- package/components/xmarkdown/markdown/types.d.ts +124 -0
- package/components/xmarkdown/markdown/types.js +6 -0
- package/components/xmarkdown/markdown/utils.d.ts +7 -0
- package/components/xmarkdown/markdown/utils.js +9 -0
- package/components/xmarkdown/markdown.d.ts +1 -0
- package/components/xmarkdown/markdown.js +1 -0
- package/components/xmarkdown/styles.d.ts +5 -0
- package/components/xmarkdown/styles.js +50 -0
- package/components/xmarkdown/useMermaid.d.ts +27 -0
- package/components/xmarkdown/useMermaid.js +745 -0
- package/components/xmarkdown/useXMarkdownContent.d.ts +14 -0
- package/components/xmarkdown/useXMarkdownContent.js +218 -0
- package/components/xmarkdown/useXMarkdownDisplay.d.ts +26 -0
- package/components/xmarkdown/useXMarkdownDisplay.js +569 -0
- package/components/xmarkdown/xmarkdown.d.ts +61 -0
- package/components/xmarkdown/xmarkdown.js +109 -0
- package/components/xmarkdown/xmarkdown.vdt.js +43 -0
- package/dist/fonts/KaTeX_AMS-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_AMS-Regular.woff +0 -0
- package/dist/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.woff +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Italic.woff +0 -0
- package/dist/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/dist/fonts/KaTeX_Math-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_Math-Italic.woff +0 -0
- package/dist/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Script-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Script-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/dist/i18n/en-US.js +29 -1
- package/dist/i18n/en-US.js.map +1 -1
- package/dist/i18n/en-US.min.js +1 -1
- package/dist/index.js +100506 -37457
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1569 -1
- package/dist/kpc.css +4 -0
- package/dist/ksyun.css +4 -0
- package/i18n/en-US.d.ts +27 -0
- package/i18n/en-US.js +29 -1
- package/index.d.ts +9 -2
- package/index.js +9 -2
- package/package.json +8 -2
- package/styles/global.js +12 -6
- package/yarn-error.log +0 -1012
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
import _Array$from from "@babel/runtime-corejs3/core-js/array/from";
|
|
2
|
+
import _Symbol from "@babel/runtime-corejs3/core-js/symbol";
|
|
3
|
+
import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-method";
|
|
4
|
+
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
5
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
+
function _unsupportedIterableToArray(o, minLen) { var _context12; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context12 = Object.prototype.toString.call(o)).call(_context12, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js/instance/includes";
|
|
9
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/slice";
|
|
10
|
+
import _startsWithInstanceProperty from "@babel/runtime-corejs3/core-js/instance/starts-with";
|
|
11
|
+
import _trimInstanceProperty from "@babel/runtime-corejs3/core-js/instance/trim";
|
|
12
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js/instance/filter";
|
|
13
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
|
|
14
|
+
import _endsWithInstanceProperty from "@babel/runtime-corejs3/core-js/instance/ends-with";
|
|
15
|
+
/**
|
|
16
|
+
* 流式渲染
|
|
17
|
+
*/
|
|
18
|
+
import { _$ } from '../../../i18n';
|
|
19
|
+
import { escapeHtml } from './utils';
|
|
20
|
+
import { createElementNode, createKeyGenerator, createTextNode, renderTreeNodes } from './renderTree';
|
|
21
|
+
var STREAM_INCOMPLETE_REGEX = {
|
|
22
|
+
image: [/^!\[[^\]\r\n]{0,1000}$/, /^!\[[^\r\n]{0,1000}\]\(*[^)\r\n]{0,1000}$/],
|
|
23
|
+
link: [/^\[[^\]\r\n]{0,1000}$/, /^\[[^\r\n]{0,1000}\]\(*[^)\r\n]{0,1000}$/],
|
|
24
|
+
html: [/^<\/$/, /^<\/?[a-zA-Z][a-zA-Z0-9-]{0,100}[^>\r\n]{0,1000}$/],
|
|
25
|
+
emphasis: [/^(\*{1,3}|_{1,3})(?!\s)(?!.*\1$)[^\r\n]{0,1000}$/],
|
|
26
|
+
list: [/^[-+*]\s{0,3}$/, /^[-+*]\s{1,3}(\*{1,3}|_{1,3})(?!\s)(?!.*\1$)[^\r\n]{0,1000}$/],
|
|
27
|
+
'inline-code': [/^`[^`\r\n]{0,300}$/]
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* 创建流式尾部缓存
|
|
31
|
+
*/
|
|
32
|
+
export function createStreamingTailCache() {
|
|
33
|
+
return {
|
|
34
|
+
processedLength: 0,
|
|
35
|
+
completeMarkdown: '',
|
|
36
|
+
pending: '',
|
|
37
|
+
token: 'text'
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 判断源码中是否包含公式语法
|
|
42
|
+
*/
|
|
43
|
+
export function containsFormulaSyntax(source, delimiters) {
|
|
44
|
+
if (!source) return false;
|
|
45
|
+
var activeDelimiters = Array.isArray(delimiters) ? delimiters : delimiters ? [delimiters] : ['dollars', 'beg_end'];
|
|
46
|
+
if (_includesInstanceProperty(activeDelimiters).call(activeDelimiters, 'dollars') && /(^|[^\\])\${1,2}[\s\S]+?(^|[^\\])\${1,2}/.test(source)) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
if (_includesInstanceProperty(activeDelimiters).call(activeDelimiters, 'beg_end') && /\\begin\{[\s\S]+?\\end\{/.test(source)) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
if (_includesInstanceProperty(activeDelimiters).call(activeDelimiters, 'brackets') && /\\\[[\s\S]+?\\\]/.test(source)) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 将流式 Markdown 拆分为 stable 和 tail 两段
|
|
59
|
+
*/
|
|
60
|
+
export function splitMarkdownForStreaming(source, cache) {
|
|
61
|
+
var normalized = (source || '').replace(/\r\n?/g, '\n');
|
|
62
|
+
if (!normalized) {
|
|
63
|
+
resetCache(cache);
|
|
64
|
+
return {
|
|
65
|
+
stableSource: '',
|
|
66
|
+
tailText: '',
|
|
67
|
+
openFence: null
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
var openFence = findOpenFence(normalized);
|
|
71
|
+
if (openFence) {
|
|
72
|
+
resetCache(cache);
|
|
73
|
+
var tailText = _sliceInstanceProperty(normalized).call(normalized, openFence.start);
|
|
74
|
+
var language = extractLanguageFromFence(tailText);
|
|
75
|
+
return {
|
|
76
|
+
stableSource: _sliceInstanceProperty(normalized).call(normalized, 0, openFence.start),
|
|
77
|
+
tailText: tailText,
|
|
78
|
+
openFence: _extends({}, openFence, {
|
|
79
|
+
language: language
|
|
80
|
+
})
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
var openMathBlock = findOpenMathBlock(normalized);
|
|
84
|
+
if (openMathBlock) {
|
|
85
|
+
resetCache(cache);
|
|
86
|
+
return {
|
|
87
|
+
stableSource: _sliceInstanceProperty(normalized).call(normalized, 0, openMathBlock.start),
|
|
88
|
+
tailText: _sliceInstanceProperty(normalized).call(normalized, openMathBlock.start),
|
|
89
|
+
openFence: null
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
var inlineTail = resolveInlineStreamingTail(normalized, cache);
|
|
93
|
+
if (inlineTail.tailText) {
|
|
94
|
+
return {
|
|
95
|
+
stableSource: inlineTail.stableSource,
|
|
96
|
+
tailText: inlineTail.tailText,
|
|
97
|
+
openFence: null
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
var trailingBlock = findTrailingIncompleteBlock(normalized);
|
|
101
|
+
if (trailingBlock) {
|
|
102
|
+
resetCache(cache);
|
|
103
|
+
return {
|
|
104
|
+
stableSource: _sliceInstanceProperty(normalized).call(normalized, 0, trailingBlock.start),
|
|
105
|
+
tailText: _sliceInstanceProperty(normalized).call(normalized, trailingBlock.start),
|
|
106
|
+
openFence: null
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
stableSource: normalized,
|
|
111
|
+
tailText: '',
|
|
112
|
+
openFence: null
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* 渲染尚未进入 stable 区的尾部内容
|
|
117
|
+
*/
|
|
118
|
+
export function renderMarkdownTail(tailText, openFence, options) {
|
|
119
|
+
if (openFence === void 0) {
|
|
120
|
+
openFence = null;
|
|
121
|
+
}
|
|
122
|
+
if (options === void 0) {
|
|
123
|
+
options = {};
|
|
124
|
+
}
|
|
125
|
+
if (!tailText) return [];
|
|
126
|
+
var nextKey = createKeyGenerator('xmarkdown-tail');
|
|
127
|
+
var prefixCls = options.prefixCls || 'k';
|
|
128
|
+
if (openFence) {
|
|
129
|
+
return renderTreeNodes([renderOpenCodeBlock(tailText, openFence, prefixCls, nextKey)], options);
|
|
130
|
+
}
|
|
131
|
+
var children = [];
|
|
132
|
+
tailText.split('\n').forEach(function (line, index, lines) {
|
|
133
|
+
children.push(createTextNode(line));
|
|
134
|
+
if (index < lines.length - 1) {
|
|
135
|
+
children.push(createElementNode('br', {}, [], nextKey('br')));
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
return renderTreeNodes([createElementNode('span', {
|
|
139
|
+
'data-kpc-xmarkdown-tail': 'true'
|
|
140
|
+
}, children, nextKey('tail'))], options);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* 转义 tail 中的 HTML 文本
|
|
144
|
+
*/
|
|
145
|
+
export function escapeMarkdownHtml(text) {
|
|
146
|
+
return escapeHtml(text);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* 识别 inline 级别的未完成 token
|
|
150
|
+
*/
|
|
151
|
+
function resolveInlineStreamingTail(source, cache) {
|
|
152
|
+
if (cache === void 0) {
|
|
153
|
+
cache = createStreamingTailCache();
|
|
154
|
+
}
|
|
155
|
+
var expectedPrefix = cache.completeMarkdown + cache.pending;
|
|
156
|
+
if (!_startsWithInstanceProperty(source).call(source, expectedPrefix)) {
|
|
157
|
+
resetCache(cache);
|
|
158
|
+
}
|
|
159
|
+
var chunk = _sliceInstanceProperty(source).call(source, cache.processedLength);
|
|
160
|
+
if (chunk) {
|
|
161
|
+
cache.processedLength += chunk.length;
|
|
162
|
+
for (var _iterator = _createForOfIteratorHelperLoose(chunk), _step; !(_step = _iterator()).done;) {
|
|
163
|
+
var char = _step.value;
|
|
164
|
+
cache.pending += char;
|
|
165
|
+
recognizeToken(cache);
|
|
166
|
+
if (cache.token === 'text') {
|
|
167
|
+
commitCache(cache);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
var tailText = getPendingTail(cache);
|
|
172
|
+
return {
|
|
173
|
+
stableSource: cache.completeMarkdown,
|
|
174
|
+
tailText: tailText
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* 更新当前缓存中的 token 状态
|
|
179
|
+
*/
|
|
180
|
+
function recognizeToken(cache) {
|
|
181
|
+
if (cache.token === 'text') {
|
|
182
|
+
var _context, _context2, _context3, _context4, _context5, _context6, _context7;
|
|
183
|
+
if (_startsWithInstanceProperty(_context = cache.pending).call(_context, '!')) {
|
|
184
|
+
cache.token = 'image';
|
|
185
|
+
if (!isStreamingValid(cache.token, cache.pending)) {
|
|
186
|
+
cache.token = 'text';
|
|
187
|
+
}
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (_startsWithInstanceProperty(_context2 = cache.pending).call(_context2, '[')) {
|
|
191
|
+
cache.token = 'link';
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (_startsWithInstanceProperty(_context3 = cache.pending).call(_context3, '<')) {
|
|
195
|
+
cache.token = 'html';
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
if (_startsWithInstanceProperty(_context4 = cache.pending).call(_context4, '*') || _startsWithInstanceProperty(_context5 = cache.pending).call(_context5, '_')) {
|
|
199
|
+
cache.token = 'emphasis';
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (/^[-+*]/.test(cache.pending)) {
|
|
203
|
+
cache.token = 'list';
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (_startsWithInstanceProperty(_context6 = cache.pending).call(_context6, '|')) {
|
|
207
|
+
cache.token = 'table';
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (_startsWithInstanceProperty(_context7 = cache.pending).call(_context7, '`')) {
|
|
211
|
+
cache.token = 'inline-code';
|
|
212
|
+
}
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (cache.token === 'list') {
|
|
216
|
+
var commitPrefix = getListCommitPrefix(cache.pending);
|
|
217
|
+
if (commitPrefix) {
|
|
218
|
+
var _context8;
|
|
219
|
+
cache.completeMarkdown += commitPrefix;
|
|
220
|
+
cache.pending = _sliceInstanceProperty(_context8 = cache.pending).call(_context8, commitPrefix.length);
|
|
221
|
+
cache.token = 'text';
|
|
222
|
+
recognizeToken(cache);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (!isStreamingValid(cache.token, cache.pending)) {
|
|
227
|
+
cache.token = 'text';
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* 提交当前已确认稳定的缓存内容
|
|
232
|
+
*/
|
|
233
|
+
function commitCache(cache) {
|
|
234
|
+
if (cache.pending) {
|
|
235
|
+
cache.completeMarkdown += cache.pending;
|
|
236
|
+
cache.pending = '';
|
|
237
|
+
}
|
|
238
|
+
cache.token = 'text';
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* 获取仍需保留在 tail 中的内容
|
|
242
|
+
*/
|
|
243
|
+
function getPendingTail(cache) {
|
|
244
|
+
if (!cache.pending || cache.token === 'text') {
|
|
245
|
+
return '';
|
|
246
|
+
}
|
|
247
|
+
if (cache.token === 'image' && cache.pending === '!') {
|
|
248
|
+
return '';
|
|
249
|
+
}
|
|
250
|
+
if (cache.token === 'table' && cache.pending.split('\n').length > 2) {
|
|
251
|
+
commitCache(cache);
|
|
252
|
+
return '';
|
|
253
|
+
}
|
|
254
|
+
return cache.pending;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* 重置流式尾部缓存
|
|
258
|
+
*/
|
|
259
|
+
function resetCache(cache) {
|
|
260
|
+
if (!cache) return;
|
|
261
|
+
cache.processedLength = 0;
|
|
262
|
+
cache.completeMarkdown = '';
|
|
263
|
+
cache.pending = '';
|
|
264
|
+
cache.token = 'text';
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* 判断 pending 内容是否仍是未完成 token
|
|
268
|
+
*/
|
|
269
|
+
function isStreamingValid(token, pending) {
|
|
270
|
+
switch (token) {
|
|
271
|
+
case 'link':
|
|
272
|
+
return STREAM_INCOMPLETE_REGEX.link.some(function (re) {
|
|
273
|
+
return re.test(pending);
|
|
274
|
+
});
|
|
275
|
+
case 'image':
|
|
276
|
+
return STREAM_INCOMPLETE_REGEX.image.some(function (re) {
|
|
277
|
+
return re.test(pending);
|
|
278
|
+
});
|
|
279
|
+
case 'html':
|
|
280
|
+
return STREAM_INCOMPLETE_REGEX.html.some(function (re) {
|
|
281
|
+
return re.test(pending);
|
|
282
|
+
});
|
|
283
|
+
case 'emphasis':
|
|
284
|
+
return STREAM_INCOMPLETE_REGEX.emphasis.some(function (re) {
|
|
285
|
+
return re.test(pending);
|
|
286
|
+
});
|
|
287
|
+
case 'list':
|
|
288
|
+
return STREAM_INCOMPLETE_REGEX.list.some(function (re) {
|
|
289
|
+
return re.test(pending);
|
|
290
|
+
});
|
|
291
|
+
case 'table':
|
|
292
|
+
return isTableIncomplete(pending);
|
|
293
|
+
case 'inline-code':
|
|
294
|
+
return STREAM_INCOMPLETE_REGEX['inline-code'].some(function (re) {
|
|
295
|
+
return re.test(pending);
|
|
296
|
+
});
|
|
297
|
+
default:
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* 判断当前表格片段是否仍未闭合
|
|
303
|
+
*/
|
|
304
|
+
function isTableIncomplete(markdown) {
|
|
305
|
+
var _context9, _context10;
|
|
306
|
+
if (_includesInstanceProperty(markdown).call(markdown, '\n\n')) return false;
|
|
307
|
+
var lines = markdown.split('\n');
|
|
308
|
+
if (lines.length <= 1) return true;
|
|
309
|
+
var header = lines[0],
|
|
310
|
+
separator = lines[1];
|
|
311
|
+
if (!/^\|.*\|$/.test(_trimInstanceProperty(header).call(header))) return false;
|
|
312
|
+
var columns = _filterInstanceProperty(_context9 = _mapInstanceProperty(_context10 = _trimInstanceProperty(separator).call(separator).split('|')).call(_context10, function (column) {
|
|
313
|
+
return _trimInstanceProperty(column).call(column);
|
|
314
|
+
})).call(_context9, Boolean);
|
|
315
|
+
var separatorRegex = /^:?-+:?$/;
|
|
316
|
+
return columns.every(function (column, index) {
|
|
317
|
+
return index === columns.length - 1 ? column === ':' || separatorRegex.test(column) : separatorRegex.test(column);
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* 识别列表前缀中可提前提交的部分
|
|
322
|
+
*/
|
|
323
|
+
function getListCommitPrefix(pending) {
|
|
324
|
+
var _pending$match;
|
|
325
|
+
var listPrefix = (_pending$match = pending.match(/^([-+*]\s{0,3})/)) == null ? void 0 : _pending$match[1];
|
|
326
|
+
var rest = listPrefix ? _sliceInstanceProperty(pending).call(pending, listPrefix.length) : '';
|
|
327
|
+
return listPrefix && _startsWithInstanceProperty(rest).call(rest, '`') ? listPrefix : null;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* 查找未闭合的代码围栏
|
|
331
|
+
*/
|
|
332
|
+
function findOpenFence(source) {
|
|
333
|
+
var lineStart = 0;
|
|
334
|
+
var openFence = null;
|
|
335
|
+
while (lineStart <= source.length) {
|
|
336
|
+
var lineEnd = source.indexOf('\n', lineStart);
|
|
337
|
+
var nextLineStart = lineEnd === -1 ? source.length + 1 : lineEnd + 1;
|
|
338
|
+
var line = lineEnd === -1 ? _sliceInstanceProperty(source).call(source, lineStart) : _sliceInstanceProperty(source).call(source, lineStart, lineEnd);
|
|
339
|
+
var match = line.match(/^ {0,3}(`{3,}|~{3,})/);
|
|
340
|
+
if (match) {
|
|
341
|
+
var marker = match[1].charAt(0);
|
|
342
|
+
var size = match[1].length;
|
|
343
|
+
if (!openFence) {
|
|
344
|
+
openFence = {
|
|
345
|
+
marker: marker,
|
|
346
|
+
size: size,
|
|
347
|
+
start: lineStart
|
|
348
|
+
};
|
|
349
|
+
} else if (openFence.marker === marker && size >= openFence.size) {
|
|
350
|
+
openFence = null;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (lineEnd === -1) break;
|
|
354
|
+
lineStart = nextLineStart;
|
|
355
|
+
}
|
|
356
|
+
return openFence;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* 查找未闭合的块级公式
|
|
360
|
+
*/
|
|
361
|
+
function findOpenMathBlock(source) {
|
|
362
|
+
var lines = source.split('\n');
|
|
363
|
+
var inMathBlock = false;
|
|
364
|
+
var mathBlockStart = -1;
|
|
365
|
+
var currentPos = 0;
|
|
366
|
+
for (var i = 0; i < lines.length; i++) {
|
|
367
|
+
var line = lines[i];
|
|
368
|
+
var lineTrimmed = _trimInstanceProperty(line).call(line);
|
|
369
|
+
if (lineTrimmed === '$$') {
|
|
370
|
+
if (!inMathBlock) {
|
|
371
|
+
inMathBlock = true;
|
|
372
|
+
mathBlockStart = currentPos + line.indexOf('$$');
|
|
373
|
+
} else {
|
|
374
|
+
inMathBlock = false;
|
|
375
|
+
mathBlockStart = -1;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
currentPos += line.length + 1;
|
|
379
|
+
}
|
|
380
|
+
if (inMathBlock && mathBlockStart >= 0) {
|
|
381
|
+
return {
|
|
382
|
+
start: mathBlockStart
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
return null;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* 提取未闭合代码围栏的语言标记
|
|
389
|
+
*/
|
|
390
|
+
function extractLanguageFromFence(tailText) {
|
|
391
|
+
var _context11;
|
|
392
|
+
var firstLineEnd = tailText.indexOf('\n');
|
|
393
|
+
var firstLine = firstLineEnd === -1 ? tailText : _sliceInstanceProperty(tailText).call(tailText, 0, firstLineEnd);
|
|
394
|
+
var match = firstLine.match(/^ {0,3}`{3,}(\S*)/);
|
|
395
|
+
return match && match[1] ? _trimInstanceProperty(_context11 = match[1]).call(_context11).toLowerCase() : undefined;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* 渲染未闭合的代码围栏
|
|
399
|
+
*/
|
|
400
|
+
function renderOpenCodeBlock(tailText, openFence, prefixCls, nextKey) {
|
|
401
|
+
var lines = tailText.split('\n');
|
|
402
|
+
var language = openFence.language || '';
|
|
403
|
+
var languageClass = language ? "hljs language-" + language : 'hljs';
|
|
404
|
+
var languageLabel = language || _$('代码');
|
|
405
|
+
var codeLines = _sliceInstanceProperty(lines).call(lines, 1).join('\n');
|
|
406
|
+
return createElementNode('div', {
|
|
407
|
+
className: prefixCls + "-xmarkdown-code-block",
|
|
408
|
+
'data-kpc-code-block': 'true',
|
|
409
|
+
'data-kpc-language': languageLabel,
|
|
410
|
+
'data-kpc-open-fence': 'true'
|
|
411
|
+
}, [createElementNode('div', {
|
|
412
|
+
className: prefixCls + "-xmarkdown-code-toolbar"
|
|
413
|
+
}, [createElementNode('span', {
|
|
414
|
+
className: prefixCls + "-xmarkdown-code-language"
|
|
415
|
+
}, [createTextNode(languageLabel)], nextKey('code-language'))], nextKey('code-toolbar')), createElementNode('div', {
|
|
416
|
+
className: prefixCls + "-xmarkdown-code-body"
|
|
417
|
+
}, [createElementNode('pre', {
|
|
418
|
+
className: 'hljs'
|
|
419
|
+
}, [createElementNode('code', {
|
|
420
|
+
className: languageClass
|
|
421
|
+
}, [createTextNode(codeLines)], nextKey('open-code'))], nextKey('open-pre'))], nextKey('code-body'))], nextKey('open-block'));
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* 查找行尾可能尚未完成的块级内容
|
|
425
|
+
*/
|
|
426
|
+
function findTrailingIncompleteBlock(source) {
|
|
427
|
+
if (!source || _endsWithInstanceProperty(source).call(source, '\n')) return null;
|
|
428
|
+
var lastNewLineIndex = source.lastIndexOf('\n');
|
|
429
|
+
var start = lastNewLineIndex === -1 ? 0 : lastNewLineIndex + 1;
|
|
430
|
+
var line = _sliceInstanceProperty(source).call(source, start);
|
|
431
|
+
if (/^ {0,3}#{1,6}(?:\s|$)/.test(line)) {
|
|
432
|
+
return {
|
|
433
|
+
start: start
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
if (hasUnmatchedInlineCode(line)) {
|
|
437
|
+
return {
|
|
438
|
+
start: start
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
if (hasUnmatchedEmphasis(line)) {
|
|
442
|
+
return {
|
|
443
|
+
start: start
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
if (hasUnmatchedMath(line)) {
|
|
447
|
+
return {
|
|
448
|
+
start: start
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
return null;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* 判断行内代码是否未闭合
|
|
455
|
+
*/
|
|
456
|
+
function hasUnmatchedInlineCode(line) {
|
|
457
|
+
var matches = line.match(/`+/g);
|
|
458
|
+
if (!matches) return false;
|
|
459
|
+
return matches.reduce(function (count, value) {
|
|
460
|
+
return count + value.length;
|
|
461
|
+
}, 0) % 2 === 1;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* 判断强调语法是否未闭合
|
|
465
|
+
*/
|
|
466
|
+
function hasUnmatchedEmphasis(line) {
|
|
467
|
+
if (countUnescapedMarkers(line, '**') % 2 === 1) return true;
|
|
468
|
+
if (countUnescapedMarkers(line, '*') % 2 === 1) return true;
|
|
469
|
+
if (countUnescapedMarkers(line, '__') % 2 === 1) return true;
|
|
470
|
+
if (countUnescapedMarkers(line, '_') % 2 === 1) return true;
|
|
471
|
+
return false;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* 判断行内数学公式是否未闭合
|
|
475
|
+
*/
|
|
476
|
+
function hasUnmatchedMath(line) {
|
|
477
|
+
var count = 0;
|
|
478
|
+
for (var i = 0; i < line.length; i++) {
|
|
479
|
+
if (line.charAt(i) !== '$') continue;
|
|
480
|
+
if (isEscaped(line, i)) continue;
|
|
481
|
+
count++;
|
|
482
|
+
while (i + 1 < line.length && line.charAt(i + 1) === '$') {
|
|
483
|
+
i++;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
return count % 2 === 1;
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* 统计未转义标记的出现次数
|
|
490
|
+
*/
|
|
491
|
+
function countUnescapedMarkers(line, marker) {
|
|
492
|
+
var count = 0;
|
|
493
|
+
var markerLength = marker.length;
|
|
494
|
+
for (var i = 0; i <= line.length - markerLength; i++) {
|
|
495
|
+
if (_sliceInstanceProperty(line).call(line, i, i + markerLength) !== marker) continue;
|
|
496
|
+
if (isEscaped(line, i)) continue;
|
|
497
|
+
if (markerLength === 1 && line.charAt(i + 1) === marker) continue;
|
|
498
|
+
if (marker === '__' && line.charAt(i + markerLength) === '_') continue;
|
|
499
|
+
count++;
|
|
500
|
+
i += markerLength - 1;
|
|
501
|
+
}
|
|
502
|
+
return count;
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* 判断当前位置是否被转义
|
|
506
|
+
*/
|
|
507
|
+
function isEscaped(line, index) {
|
|
508
|
+
var backslashCount = 0;
|
|
509
|
+
for (var i = index - 1; i >= 0 && line.charAt(i) === '\\'; i--) {
|
|
510
|
+
backslashCount++;
|
|
511
|
+
}
|
|
512
|
+
return backslashCount % 2 === 1;
|
|
513
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 类型定义
|
|
3
|
+
*
|
|
4
|
+
* 集中定义 Markdown 渲染相关的所有类型。
|
|
5
|
+
*/
|
|
6
|
+
import type { XMarkdownRenderTreeNode } from './renderTree';
|
|
7
|
+
/** 数学公式分隔符类型 */
|
|
8
|
+
export type XMarkdownFormulaDelimiter = 'dollars' | 'brackets' | 'doxygen' | 'gitlab' | 'julia' | 'kramdown' | 'beg_end';
|
|
9
|
+
/** Markdown 渲染配置 */
|
|
10
|
+
export interface XMarkdownRenderOptions {
|
|
11
|
+
prefixCls?: string;
|
|
12
|
+
allowHtml?: boolean;
|
|
13
|
+
showCodeHeader?: boolean;
|
|
14
|
+
enableMermaid?: boolean;
|
|
15
|
+
enableFormula?: boolean;
|
|
16
|
+
formulaDelimiters?: XMarkdownFormulaDelimiter | XMarkdownFormulaDelimiter[];
|
|
17
|
+
formulaMacros?: Record<string, string>;
|
|
18
|
+
sanitizeOptions?: Record<string, any>;
|
|
19
|
+
plugins?: XMarkdownPlugin[];
|
|
20
|
+
tagAttrs?: XMarkdownTagAttrs;
|
|
21
|
+
tagRenderers?: XMarkdownTagRenderers;
|
|
22
|
+
codeBlockRenderers?: XMarkdownCodeBlockRenderers;
|
|
23
|
+
streaming?: boolean;
|
|
24
|
+
typing?: boolean;
|
|
25
|
+
formulaRuntime?: XMarkdownFormulaRuntime | null;
|
|
26
|
+
normalizeRendererOutput?: (value: any) => any;
|
|
27
|
+
}
|
|
28
|
+
/** 数学公式运行时(KaTeX + texmath) */
|
|
29
|
+
export interface XMarkdownFormulaRuntime {
|
|
30
|
+
katex: any;
|
|
31
|
+
texmath: any;
|
|
32
|
+
}
|
|
33
|
+
/** 标签属性上下文 */
|
|
34
|
+
export interface XMarkdownTagAttrsContext {
|
|
35
|
+
tag: string;
|
|
36
|
+
attrs: Record<string, any>;
|
|
37
|
+
html: string;
|
|
38
|
+
textContent: string;
|
|
39
|
+
}
|
|
40
|
+
/** 标签属性获取器 */
|
|
41
|
+
export type XMarkdownTagAttrsGetter = (context: XMarkdownTagAttrsContext) => Record<string, any> | undefined;
|
|
42
|
+
export type XMarkdownTagAttrs = Record<string, Record<string, any> | XMarkdownTagAttrsGetter>;
|
|
43
|
+
/** 标签渲染上下文 */
|
|
44
|
+
export interface XMarkdownTagRenderContext extends XMarkdownTagAttrsContext {
|
|
45
|
+
innerHTML: string;
|
|
46
|
+
streaming: boolean;
|
|
47
|
+
typing: boolean;
|
|
48
|
+
}
|
|
49
|
+
/** 标签渲染器 */
|
|
50
|
+
export type XMarkdownTagRenderer = (context: XMarkdownTagRenderContext) => any;
|
|
51
|
+
export type XMarkdownTagRenderers = Record<string, XMarkdownTagRenderer>;
|
|
52
|
+
/** 代码块渲染上下文 */
|
|
53
|
+
export interface XMarkdownCodeBlockRenderContext {
|
|
54
|
+
source: string;
|
|
55
|
+
info: string;
|
|
56
|
+
language: string;
|
|
57
|
+
normalizedLanguage: string;
|
|
58
|
+
blockType: XMarkdownRenderedBlockType;
|
|
59
|
+
prefixCls: string;
|
|
60
|
+
streaming: boolean;
|
|
61
|
+
typing: boolean;
|
|
62
|
+
}
|
|
63
|
+
/** 代码块渲染器 */
|
|
64
|
+
export type XMarkdownCodeBlockRenderer = (context: XMarkdownCodeBlockRenderContext) => any;
|
|
65
|
+
export type XMarkdownCodeBlockRenderers = Record<string, XMarkdownCodeBlockRenderer>;
|
|
66
|
+
/** 渲染树转换上下文 */
|
|
67
|
+
export interface XMarkdownRenderTreeTransformContext {
|
|
68
|
+
source: string;
|
|
69
|
+
options: XMarkdownRenderOptions;
|
|
70
|
+
}
|
|
71
|
+
/** 渲染树转换器 */
|
|
72
|
+
export type XMarkdownRenderTreeTransform = (nodes: XMarkdownRenderTreeNode[], context: XMarkdownRenderTreeTransformContext) => XMarkdownRenderTreeNode[] | void;
|
|
73
|
+
/** Markdown 扩展插件 */
|
|
74
|
+
export interface XMarkdownPlugin {
|
|
75
|
+
extendMarkdown?: (markdown: any) => void;
|
|
76
|
+
transformRenderTree?: XMarkdownRenderTreeTransform;
|
|
77
|
+
}
|
|
78
|
+
/** 渲染后的岛屿(用于自定义标签渲染) */
|
|
79
|
+
export interface XMarkdownRenderedIsland {
|
|
80
|
+
id: string;
|
|
81
|
+
value: any;
|
|
82
|
+
}
|
|
83
|
+
/** 代码块类型 */
|
|
84
|
+
export type XMarkdownRenderedBlockType = 'code' | 'mermaid';
|
|
85
|
+
/** 渲染后的代码块信息 */
|
|
86
|
+
export interface XMarkdownRenderedBlock {
|
|
87
|
+
id: string;
|
|
88
|
+
type: XMarkdownRenderedBlockType;
|
|
89
|
+
source: string;
|
|
90
|
+
language: string;
|
|
91
|
+
}
|
|
92
|
+
export type XMarkdownRegisterRenderedBlock = (type: XMarkdownRenderedBlockType, source: string, language: string) => string;
|
|
93
|
+
/** Markdown 渲染结果 */
|
|
94
|
+
export interface XMarkdownRenderResult {
|
|
95
|
+
nodes: any[];
|
|
96
|
+
blocks: Record<string, XMarkdownRenderedBlock>;
|
|
97
|
+
}
|
|
98
|
+
export interface XMarkdownSourceBlock {
|
|
99
|
+
key: string;
|
|
100
|
+
source: string;
|
|
101
|
+
}
|
|
102
|
+
export interface XMarkdownRenderedStableBlock extends XMarkdownSourceBlock {
|
|
103
|
+
nodes: any[];
|
|
104
|
+
blocks: Record<string, XMarkdownRenderedBlock>;
|
|
105
|
+
}
|
|
106
|
+
/** 未闭合代码块围栏信息 */
|
|
107
|
+
export interface OpenFenceInfo {
|
|
108
|
+
marker: string;
|
|
109
|
+
size: number;
|
|
110
|
+
start: number;
|
|
111
|
+
language?: string;
|
|
112
|
+
}
|
|
113
|
+
/** 流式渲染分段结果 */
|
|
114
|
+
export interface StreamingMarkdownSegments {
|
|
115
|
+
stableSource: string;
|
|
116
|
+
tailText: string;
|
|
117
|
+
openFence: OpenFenceInfo | null;
|
|
118
|
+
}
|
|
119
|
+
export interface XMarkdownStreamingTailCache {
|
|
120
|
+
processedLength: number;
|
|
121
|
+
completeMarkdown: string;
|
|
122
|
+
pending: string;
|
|
123
|
+
token: 'text' | 'link' | 'image' | 'html' | 'emphasis' | 'list' | 'table' | 'inline-code';
|
|
124
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './markdown/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './markdown/index';
|