@antdv-next/x-markdown 0.0.1 → 0.1.0-beta.1
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/LICENSE +21 -0
- package/README.md +15 -1
- package/dist/XMarkdown/components/AnimationText.js +5 -0
- package/dist/XMarkdown/components/AnimationText.vue.d.ts +0 -1
- package/dist/XMarkdown/components/AnimationText.vue_vue_type_script_setup_true_lang.js +42 -0
- package/dist/XMarkdown/components/DebugPanel.js +7 -0
- package/dist/XMarkdown/components/DebugPanel.vue.d.ts +0 -1
- package/dist/XMarkdown/components/DebugPanel.vue_vue_type_script_setup_true_lang.js +128 -0
- package/dist/XMarkdown/components/DebugPanel.vue_vue_type_style_index_0_scoped_d6923a13_lang.css +39 -0
- package/dist/XMarkdown/components/TailIndicator.js +7 -0
- package/dist/XMarkdown/components/TailIndicator.vue.d.ts +0 -1
- package/dist/XMarkdown/components/TailIndicator.vue_vue_type_script_setup_true_lang.js +14 -0
- package/dist/XMarkdown/components/TailIndicator.vue_vue_type_style_index_0_scoped_802ace82_lang.css +6 -0
- package/dist/XMarkdown/components/index.d.ts +0 -1
- package/dist/XMarkdown/components/index.js +4 -0
- package/dist/XMarkdown/composables/index.d.ts +4 -0
- package/dist/XMarkdown/composables/index.js +5 -0
- package/dist/XMarkdown/composables/useParser.d.ts +0 -1
- package/dist/XMarkdown/composables/useParser.js +24 -0
- package/dist/XMarkdown/composables/useRenderer.d.ts +0 -1
- package/dist/XMarkdown/composables/useRenderer.js +24 -0
- package/dist/XMarkdown/composables/useStreaming.d.ts +0 -1
- package/dist/XMarkdown/composables/useStreaming.js +215 -0
- package/dist/XMarkdown/composables/useTail.d.ts +0 -1
- package/dist/XMarkdown/composables/useTail.js +25 -0
- package/dist/XMarkdown/core/Parser.d.ts +5 -2
- package/dist/XMarkdown/core/Parser.js +162 -0
- package/dist/XMarkdown/core/VueRenderer.d.ts +0 -1
- package/dist/XMarkdown/core/VueRenderer.js +223 -0
- package/dist/XMarkdown/core/detectUnclosedComponentTags.d.ts +2 -2
- package/dist/XMarkdown/core/detectUnclosedComponentTags.js +141 -0
- package/dist/XMarkdown/core/index.d.ts +3 -0
- package/dist/XMarkdown/core/index.js +4 -0
- package/dist/XMarkdown/index.d.ts +14 -0
- package/dist/XMarkdown/index.js +13 -0
- package/dist/XMarkdown/index.vue.d.ts +0 -1
- package/dist/XMarkdown/index.vue_vue_type_script_setup_true_lang.js +135 -0
- package/dist/XMarkdown/index2.js +5 -0
- package/dist/XMarkdown/interface.d.ts +0 -1
- package/dist/XMarkdown/interface.js +14 -0
- package/dist/XMarkdown/utils/tail.d.ts +0 -1
- package/dist/XMarkdown/utils/tail.js +9 -0
- package/dist/_virtual/_plugin-vue_export-helper.js +8 -0
- package/dist/env.d.js +0 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +13 -740
- package/package.json +9 -7
- package/{dist/plugins → plugins}/Latex/index.d.ts +0 -1
- package/plugins/Latex/index.js +74 -0
- package/themes/index.css +206 -0
- package/dist/XMarkdown/components/AnimationText.vue.d.ts.map +0 -1
- package/dist/XMarkdown/components/DebugPanel.vue.d.ts.map +0 -1
- package/dist/XMarkdown/components/TailIndicator.vue.d.ts.map +0 -1
- package/dist/XMarkdown/components/index.d.ts.map +0 -1
- package/dist/XMarkdown/composables/useParser.d.ts.map +0 -1
- package/dist/XMarkdown/composables/useRenderer.d.ts.map +0 -1
- package/dist/XMarkdown/composables/useStreaming.d.ts.map +0 -1
- package/dist/XMarkdown/composables/useTail.d.ts.map +0 -1
- package/dist/XMarkdown/core/Parser.d.ts.map +0 -1
- package/dist/XMarkdown/core/VueRenderer.d.ts.map +0 -1
- package/dist/XMarkdown/core/detectUnclosedComponentTags.d.ts.map +0 -1
- package/dist/XMarkdown/index.vue.d.ts.map +0 -1
- package/dist/XMarkdown/interface.d.ts.map +0 -1
- package/dist/XMarkdown/utils/tail.d.ts.map +0 -1
- package/dist/index.css +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/plugins/Latex/index.d.ts.map +0 -1
- package/dist/plugins/Latex/index.js +0 -68
- /package/{dist/themes → themes}/dark.css +0 -0
- /package/{dist/themes → themes}/light.css +0 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import DebugPanel_default from "./components/DebugPanel.js";
|
|
2
|
+
import TailIndicator_default from "./components/TailIndicator.js";
|
|
3
|
+
import { useStreaming } from "./composables/useStreaming.js";
|
|
4
|
+
import { Parser } from "./core/Parser.js";
|
|
5
|
+
import { VueRenderer } from "./core/VueRenderer.js";
|
|
6
|
+
import { useTail } from "./composables/useTail.js";
|
|
7
|
+
import { computed, createBlock, createCommentVNode, createElementBlock, createVNode, defineComponent, h, normalizeClass, normalizeStyle, openBlock, ref, shallowRef, unref, watch } from "vue";
|
|
8
|
+
//#region src/XMarkdown/index.vue?vue&type=script&setup=true&lang.ts
|
|
9
|
+
var index_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
10
|
+
__name: "index",
|
|
11
|
+
props: {
|
|
12
|
+
content: { default: "" },
|
|
13
|
+
components: { default: () => ({}) },
|
|
14
|
+
streaming: { default: void 0 },
|
|
15
|
+
config: { default: () => ({ gfm: true }) },
|
|
16
|
+
debug: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: false
|
|
19
|
+
},
|
|
20
|
+
protectCustomTagNewlines: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: true
|
|
23
|
+
},
|
|
24
|
+
escapeRawHtml: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: false
|
|
27
|
+
},
|
|
28
|
+
className: {},
|
|
29
|
+
style: {},
|
|
30
|
+
openLinksInNewTab: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: true
|
|
33
|
+
},
|
|
34
|
+
paragraphTag: { default: "p" }
|
|
35
|
+
},
|
|
36
|
+
setup(__props) {
|
|
37
|
+
const props = __props;
|
|
38
|
+
const contentRef = computed(() => props.content || "");
|
|
39
|
+
const streamingRef = computed(() => props.streaming);
|
|
40
|
+
const { processedContent } = useStreaming(contentRef, streamingRef, computed(() => props.components));
|
|
41
|
+
const { tailContent, tailComponent, showTail } = useTail(streamingRef);
|
|
42
|
+
const mergedComponents = computed(() => {
|
|
43
|
+
const baseComponents = { ...props.components };
|
|
44
|
+
if (!showTail.value || !tailContent.value) return baseComponents;
|
|
45
|
+
const resolvedTailComponent = tailComponent.value || TailIndicator_default;
|
|
46
|
+
const content = tailContent.value;
|
|
47
|
+
const TailBridge = defineComponent({
|
|
48
|
+
name: "XmdTailBridge",
|
|
49
|
+
setup() {
|
|
50
|
+
return () => h(resolvedTailComponent, { content });
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return {
|
|
54
|
+
...baseComponents,
|
|
55
|
+
"xmd-tail": TailBridge
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
const VNodeRenderer = defineComponent({
|
|
59
|
+
name: "XmdVNodeRenderer",
|
|
60
|
+
props: { node: {
|
|
61
|
+
type: Object,
|
|
62
|
+
required: true
|
|
63
|
+
} },
|
|
64
|
+
setup(props) {
|
|
65
|
+
return () => props.node;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
const parser = shallowRef(new Parser({
|
|
69
|
+
openLinksInNewTab: props.openLinksInNewTab,
|
|
70
|
+
paragraphTag: props.paragraphTag,
|
|
71
|
+
protectCustomTags: props.protectCustomTagNewlines,
|
|
72
|
+
escapeRawHtml: props.escapeRawHtml,
|
|
73
|
+
config: props.config,
|
|
74
|
+
components: props.components
|
|
75
|
+
}));
|
|
76
|
+
const renderer = shallowRef(new VueRenderer({
|
|
77
|
+
components: mergedComponents.value,
|
|
78
|
+
enableAnimation: props.streaming?.enableAnimation ?? true,
|
|
79
|
+
animationConfig: props.streaming?.animationConfig
|
|
80
|
+
}));
|
|
81
|
+
const optionsVersion = ref(0);
|
|
82
|
+
const bumpOptionsVersion = () => {
|
|
83
|
+
optionsVersion.value += 1;
|
|
84
|
+
};
|
|
85
|
+
const htmlOutput = computed(() => {
|
|
86
|
+
optionsVersion.value;
|
|
87
|
+
return parser.value.parse(processedContent.value, { injectTail: showTail.value });
|
|
88
|
+
});
|
|
89
|
+
const vNode = computed(() => {
|
|
90
|
+
optionsVersion.value;
|
|
91
|
+
return renderer.value.render(htmlOutput.value);
|
|
92
|
+
});
|
|
93
|
+
watch(() => [
|
|
94
|
+
props.openLinksInNewTab,
|
|
95
|
+
props.paragraphTag,
|
|
96
|
+
props.protectCustomTagNewlines,
|
|
97
|
+
props.escapeRawHtml
|
|
98
|
+
], () => {
|
|
99
|
+
parser.value.setOptions({
|
|
100
|
+
openLinksInNewTab: props.openLinksInNewTab,
|
|
101
|
+
paragraphTag: props.paragraphTag,
|
|
102
|
+
protectCustomTags: props.protectCustomTagNewlines,
|
|
103
|
+
escapeRawHtml: props.escapeRawHtml
|
|
104
|
+
});
|
|
105
|
+
bumpOptionsVersion();
|
|
106
|
+
});
|
|
107
|
+
watch(() => props.config, (newConfig) => {
|
|
108
|
+
parser.value.setOptions({ config: newConfig });
|
|
109
|
+
bumpOptionsVersion();
|
|
110
|
+
}, { deep: true });
|
|
111
|
+
watch(() => props.components, (newComponents) => {
|
|
112
|
+
parser.value.setOptions({ components: newComponents });
|
|
113
|
+
bumpOptionsVersion();
|
|
114
|
+
}, { deep: true });
|
|
115
|
+
watch(mergedComponents, (newComponents) => {
|
|
116
|
+
renderer.value.setOptions({ components: newComponents });
|
|
117
|
+
bumpOptionsVersion();
|
|
118
|
+
}, { deep: true });
|
|
119
|
+
watch(() => props.streaming, (newStreaming) => {
|
|
120
|
+
renderer.value.setOptions({
|
|
121
|
+
enableAnimation: newStreaming?.enableAnimation ?? true,
|
|
122
|
+
animationConfig: newStreaming?.animationConfig
|
|
123
|
+
});
|
|
124
|
+
bumpOptionsVersion();
|
|
125
|
+
}, { deep: true });
|
|
126
|
+
return (_ctx, _cache) => {
|
|
127
|
+
return openBlock(), createElementBlock("div", {
|
|
128
|
+
class: normalizeClass(["x-markdown", __props.className]),
|
|
129
|
+
style: normalizeStyle(__props.style)
|
|
130
|
+
}, [createVNode(unref(VNodeRenderer), { node: vNode.value }, null, 8, ["node"]), __props.debug ? (openBlock(), createBlock(DebugPanel_default, { key: 0 })) : createCommentVNode("", true)], 6);
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
//#endregion
|
|
135
|
+
export { index_vue_vue_type_script_setup_true_lang_default as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import index_vue_vue_type_script_setup_true_lang_default from "./index.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
//#region src/XMarkdown/index.vue
|
|
3
|
+
var XMarkdown_default = index_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { XMarkdown_default as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/XMarkdown/interface.ts
|
|
2
|
+
var StreamCacheTokenType = /* @__PURE__ */ function(StreamCacheTokenType) {
|
|
3
|
+
StreamCacheTokenType["Text"] = "text";
|
|
4
|
+
StreamCacheTokenType["Link"] = "link";
|
|
5
|
+
StreamCacheTokenType["Image"] = "image";
|
|
6
|
+
StreamCacheTokenType["Html"] = "html";
|
|
7
|
+
StreamCacheTokenType["Emphasis"] = "emphasis";
|
|
8
|
+
StreamCacheTokenType["List"] = "list";
|
|
9
|
+
StreamCacheTokenType["Table"] = "table";
|
|
10
|
+
StreamCacheTokenType["InlineCode"] = "inline-code";
|
|
11
|
+
return StreamCacheTokenType;
|
|
12
|
+
}({});
|
|
13
|
+
//#endregion
|
|
14
|
+
export { StreamCacheTokenType };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/XMarkdown/utils/tail.ts
|
|
2
|
+
var DEFAULT_TAIL_CONTENT = "▋";
|
|
3
|
+
function resolveTailContent(tail) {
|
|
4
|
+
if (!tail) return null;
|
|
5
|
+
if (tail === true) return DEFAULT_TAIL_CONTENT;
|
|
6
|
+
return tail.content || DEFAULT_TAIL_CONTENT;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { resolveTailContent };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region \0plugin-vue:export-helper
|
|
2
|
+
var _plugin_vue_export_helper_default = (sfc, props) => {
|
|
3
|
+
const target = sfc.__vccOpts || sfc;
|
|
4
|
+
for (const [key, val] of props) target[key] = val;
|
|
5
|
+
return target;
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { _plugin_vue_export_helper_default as default };
|
package/dist/env.d.js
ADDED
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
@@ -12,4 +12,3 @@ export { useRenderer } from './XMarkdown/composables/useRenderer';
|
|
|
12
12
|
export { useTail } from './XMarkdown/composables/useTail';
|
|
13
13
|
export { AnimationText, DebugPanel, TailIndicator, } from './XMarkdown/components';
|
|
14
14
|
export { resolveTailContent } from './XMarkdown/utils/tail';
|
|
15
|
-
//# sourceMappingURL=index.d.ts.map
|