@antdv-next/x-markdown 0.0.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/README.md +154 -0
- package/dist/XMarkdown/components/AnimationText.vue.d.ts +12 -0
- package/dist/XMarkdown/components/AnimationText.vue.d.ts.map +1 -0
- package/dist/XMarkdown/components/DebugPanel.vue.d.ts +7 -0
- package/dist/XMarkdown/components/DebugPanel.vue.d.ts.map +1 -0
- package/dist/XMarkdown/components/TailIndicator.vue.d.ts +9 -0
- package/dist/XMarkdown/components/TailIndicator.vue.d.ts.map +1 -0
- package/dist/XMarkdown/components/index.d.ts +4 -0
- package/dist/XMarkdown/components/index.d.ts.map +1 -0
- package/dist/XMarkdown/composables/useParser.d.ts +9 -0
- package/dist/XMarkdown/composables/useParser.d.ts.map +1 -0
- package/dist/XMarkdown/composables/useRenderer.d.ts +9 -0
- package/dist/XMarkdown/composables/useRenderer.d.ts.map +1 -0
- package/dist/XMarkdown/composables/useStreaming.d.ts +7 -0
- package/dist/XMarkdown/composables/useStreaming.d.ts.map +1 -0
- package/dist/XMarkdown/composables/useTail.d.ts +8 -0
- package/dist/XMarkdown/composables/useTail.d.ts.map +1 -0
- package/dist/XMarkdown/core/Parser.d.ts +21 -0
- package/dist/XMarkdown/core/Parser.d.ts.map +1 -0
- package/dist/XMarkdown/core/VueRenderer.d.ts +15 -0
- package/dist/XMarkdown/core/VueRenderer.d.ts.map +1 -0
- package/dist/XMarkdown/core/detectUnclosedComponentTags.d.ts +2 -0
- package/dist/XMarkdown/core/detectUnclosedComponentTags.d.ts.map +1 -0
- package/dist/XMarkdown/index.vue.d.ts +16 -0
- package/dist/XMarkdown/index.vue.d.ts.map +1 -0
- package/dist/XMarkdown/interface.d.ts +87 -0
- package/dist/XMarkdown/interface.d.ts.map +1 -0
- package/dist/XMarkdown/utils/tail.d.ts +5 -0
- package/dist/XMarkdown/utils/tail.d.ts.map +1 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +740 -0
- package/dist/plugins/Latex/index.d.ts +9 -0
- package/dist/plugins/Latex/index.d.ts.map +1 -0
- package/dist/plugins/Latex/index.js +68 -0
- package/dist/themes/dark.css +204 -0
- package/dist/themes/light.css +204 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# @antdv-next/x-markdown
|
|
2
|
+
|
|
3
|
+
Vue 3 streaming-friendly, highly extensible, and high-performance Markdown renderer.
|
|
4
|
+
|
|
5
|
+
## ✨ Features
|
|
6
|
+
|
|
7
|
+
Built on [`marked`](https://github.com/markedjs/marked) as the base Markdown renderer.
|
|
8
|
+
|
|
9
|
+
- 🚀 Built for speed
|
|
10
|
+
- 🤖 Streaming-friendly, a Markdown rendering solution for LLM/AI
|
|
11
|
+
- ⬇️ Low-level compiler for parsing Markdown without long-term caching
|
|
12
|
+
- ⚖️ Lightweight while implementing all supported Markdown styles
|
|
13
|
+
- 🔐 Secure by default, no XSS attacks via DOMPurify
|
|
14
|
+
- 🎨 Customizable components - replace any Markdown element with your own Vue components
|
|
15
|
+
- 🔧 Rich plugin ecosystem
|
|
16
|
+
- 😊 Compatible - 100% CommonMark compliant, 100% GFM compliant
|
|
17
|
+
|
|
18
|
+
## Compatibility
|
|
19
|
+
|
|
20
|
+
| <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="Edge" width="24px" height="24px" /> Edge | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" /> Firefox | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" /> Chrome | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" /> Safari | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png" alt="Opera" width="24px" height="24px" /> Opera |
|
|
21
|
+
| --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
22
|
+
| >= 92 | >= 90 | >= 92 | >= 15.4 | >= 78 |
|
|
23
|
+
|
|
24
|
+
## Supported Markdown Specifications
|
|
25
|
+
|
|
26
|
+
- [Markdown 1.0.0](https://daringfireball.net/projects/markdown/)
|
|
27
|
+
- [CommonMark](https://github.com/commonmark/commonmark-spec/wiki/Markdown-Flavors)
|
|
28
|
+
- [GitHub Flavored Markdown (GFM)](https://github.github.com/gfm/)
|
|
29
|
+
|
|
30
|
+
## 📦 Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install @antdv-next/x-markdown
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
yarn add @antdv-next/x-markdown
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pnpm add @antdv-next/x-markdown
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Example
|
|
45
|
+
|
|
46
|
+
```vue
|
|
47
|
+
<script setup>
|
|
48
|
+
import { XMarkdown } from "@antdv-next/x-markdown";
|
|
49
|
+
|
|
50
|
+
const content = `
|
|
51
|
+
# Hello World
|
|
52
|
+
|
|
53
|
+
### Welcome to XMarkdown!
|
|
54
|
+
|
|
55
|
+
- Item 1
|
|
56
|
+
- Item 2
|
|
57
|
+
- Item 3
|
|
58
|
+
`;
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<template>
|
|
62
|
+
<XMarkdown :content="content" />
|
|
63
|
+
</template>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Streaming Example
|
|
67
|
+
|
|
68
|
+
```vue
|
|
69
|
+
<script setup>
|
|
70
|
+
import { ref } from "vue";
|
|
71
|
+
import { XMarkdown } from "@antdv-next/x-markdown";
|
|
72
|
+
|
|
73
|
+
const content = ref("");
|
|
74
|
+
const streaming = ref({
|
|
75
|
+
hasNextChunk: true,
|
|
76
|
+
enableAnimation: true,
|
|
77
|
+
tail: true,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Simulate streaming
|
|
81
|
+
function onChunk(chunk) {
|
|
82
|
+
content.value += chunk;
|
|
83
|
+
}
|
|
84
|
+
</script>
|
|
85
|
+
|
|
86
|
+
<template>
|
|
87
|
+
<XMarkdown :content="content" :streaming="streaming" />
|
|
88
|
+
</template>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## API
|
|
92
|
+
|
|
93
|
+
### Props
|
|
94
|
+
|
|
95
|
+
| Property | Description | Type | Default |
|
|
96
|
+
| ------------------------ | --------------------------------------- | --------------------------- | --------------- |
|
|
97
|
+
| content | Markdown content to render | `string` | - |
|
|
98
|
+
| components | Map HTML nodes to custom Vue components | `Record<string, Component>` | - |
|
|
99
|
+
| streaming | Streaming behavior config | `StreamingOption` | - |
|
|
100
|
+
| config | Marked parse config | `MarkedConfig` | `{ gfm: true }` |
|
|
101
|
+
| className | Extra CSS class for root container | `string` | - |
|
|
102
|
+
| style | Inline styles for root container | `Record<string, string>` | - |
|
|
103
|
+
| paragraphTag | HTML tag for paragraphs | `string` | `'p'` |
|
|
104
|
+
| openLinksInNewTab | Add `target="_blank"` to all links | `boolean` | `true` |
|
|
105
|
+
| protectCustomTagNewlines | Preserve newlines inside custom tags | `boolean` | `true` |
|
|
106
|
+
| escapeRawHtml | Escape raw HTML as plain text | `boolean` | `false` |
|
|
107
|
+
| debug | Enable debug mode | `boolean` | `false` |
|
|
108
|
+
|
|
109
|
+
### StreamingOption
|
|
110
|
+
|
|
111
|
+
| Field | Description | Type | Default |
|
|
112
|
+
| ------------------------------ | ---------------------------------------------- | ------------------------------------ | ------- |
|
|
113
|
+
| hasNextChunk | Whether more chunks are expected | `boolean` | `false` |
|
|
114
|
+
| enableAnimation | Enable fade-in animation | `boolean` | `true` |
|
|
115
|
+
| animationConfig | Animation options | `AnimationConfig` | - |
|
|
116
|
+
| tail | Enable tail indicator | `boolean \| TailConfig` | `false` |
|
|
117
|
+
| incompleteMarkdownComponentMap | Map incomplete fragments to loading components | `Partial<Record<TokenType, string>>` | - |
|
|
118
|
+
|
|
119
|
+
### AnimationConfig
|
|
120
|
+
|
|
121
|
+
| Property | Description | Type | Default |
|
|
122
|
+
| ------------ | ------------------- | -------- | ------------ |
|
|
123
|
+
| fadeDuration | Duration in ms | `number` | `300` |
|
|
124
|
+
| easing | CSS easing function | `string` | `'ease-out'` |
|
|
125
|
+
|
|
126
|
+
### TailConfig
|
|
127
|
+
|
|
128
|
+
| Property | Description | Type | Default |
|
|
129
|
+
| --------- | -------------------------- | ----------- | ------- |
|
|
130
|
+
| content | Content to display as tail | `string` | `'▋'` |
|
|
131
|
+
| component | Custom tail component | `Component` | - |
|
|
132
|
+
|
|
133
|
+
## Themes
|
|
134
|
+
|
|
135
|
+
Import theme styles and set the theme class on the root:
|
|
136
|
+
|
|
137
|
+
```vue
|
|
138
|
+
<script setup>
|
|
139
|
+
import "@antdv-next/x-markdown/themes/light.css";
|
|
140
|
+
</script>
|
|
141
|
+
|
|
142
|
+
<template>
|
|
143
|
+
<XMarkdown class="x-markdown-light" content="# Hello" />
|
|
144
|
+
</template>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Available themes:
|
|
148
|
+
|
|
149
|
+
- `light.css` - Light theme
|
|
150
|
+
- `dark.css` - Dark theme
|
|
151
|
+
|
|
152
|
+
## Plugins
|
|
153
|
+
|
|
154
|
+
Rich plugins available. See documentation for details.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
text: string;
|
|
3
|
+
fadeDuration?: number;
|
|
4
|
+
easing?: string;
|
|
5
|
+
}
|
|
6
|
+
declare const __VLS_export: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
7
|
+
fadeDuration: number;
|
|
8
|
+
easing: string;
|
|
9
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|
|
12
|
+
//# sourceMappingURL=AnimationText.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnimationText.vue.d.ts","sourceRoot":"","sources":["../../../src/XMarkdown/components/AnimationText.vue"],"names":[],"mappings":"AA0DA,UAAU,KAAK;IACb,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAsED,QAAA,MAAM,YAAY;kBAxED,MAAM;YACZ,MAAM;6EA0Ef,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
className?: string;
|
|
3
|
+
}
|
|
4
|
+
declare const __VLS_export: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
7
|
+
//# sourceMappingURL=DebugPanel.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DebugPanel.vue.d.ts","sourceRoot":"","sources":["../../../src/XMarkdown/components/DebugPanel.vue"],"names":[],"mappings":"AAgNA,UAAU,KAAK;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA+MD,QAAA,MAAM,YAAY,sRAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
content?: string;
|
|
3
|
+
}
|
|
4
|
+
declare const __VLS_export: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
5
|
+
content: string;
|
|
6
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
9
|
+
//# sourceMappingURL=TailIndicator.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TailIndicator.vue.d.ts","sourceRoot":"","sources":["../../../src/XMarkdown/components/TailIndicator.vue"],"names":[],"mappings":"AA0BA,UAAU,KAAK;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAkCD,QAAA,MAAM,YAAY;aAnCN,MAAM;6EAsChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/XMarkdown/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ShallowRef } from 'vue';
|
|
2
|
+
import { ParserOptions } from '../interface';
|
|
3
|
+
import { Parser } from '../core/Parser';
|
|
4
|
+
export declare function useParser(initialOptions?: ParserOptions): {
|
|
5
|
+
parser: ShallowRef<Parser | null>;
|
|
6
|
+
parse: (markdown: string, options?: ParserOptions) => string;
|
|
7
|
+
resetParser: (options?: ParserOptions) => void;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=useParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useParser.d.ts","sourceRoot":"","sources":["../../../src/XMarkdown/composables/useParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,KAAK,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,wBAAgB,SAAS,CAAC,cAAc,CAAC,EAAE,aAAa;;sBAO7B,MAAM,YAAY,aAAa,KAAG,MAAM;4BAYlC,aAAa,KAAG,IAAI;EASpD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { VNode, ShallowRef } from 'vue';
|
|
2
|
+
import { RendererOptions } from '../interface';
|
|
3
|
+
import { VueRenderer } from '../core/VueRenderer';
|
|
4
|
+
export declare function useRenderer(initialOptions?: RendererOptions): {
|
|
5
|
+
renderer: ShallowRef<VueRenderer | null>;
|
|
6
|
+
render: (html: string, options?: RendererOptions) => VNode;
|
|
7
|
+
resetRenderer: (options?: RendererOptions) => void;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=useRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRenderer.d.ts","sourceRoot":"","sources":["../../../src/XMarkdown/composables/useRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;AAEjC,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,KAAK,CAAC;AAElD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,wBAAgB,WAAW,CAAC,cAAc,CAAC,EAAE,eAAe;;mBAOpC,MAAM,YAAY,eAAe,KAAG,KAAK;8BAY9B,eAAe,KAAG,IAAI;EASxD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Component, Ref } from 'vue';
|
|
2
|
+
import { StreamingOption } from '../interface';
|
|
3
|
+
export declare function useStreaming(content: Ref<string>, streaming: Ref<StreamingOption | undefined>, components?: Ref<Record<string, Component> | undefined>): {
|
|
4
|
+
processedContent: Ref<string, string>;
|
|
5
|
+
reset: () => void;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=useStreaming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStreaming.d.ts","sourceRoot":"","sources":["../../../src/XMarkdown/composables/useStreaming.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAErC,OAAO,EAAc,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AAE3C,OAAO,KAAK,EAGV,eAAe,EAChB,MAAM,cAAc,CAAC;AAqNtB,wBAAgB,YAAY,CAC1B,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,EACpB,SAAS,EAAE,GAAG,CAAC,eAAe,GAAG,SAAS,CAAC,EAC3C,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,SAAS,CAAC;;iBAgGrC,IAAI;EA+BvB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { StreamingOption } from '../interface';
|
|
3
|
+
export declare function useTail(streaming: Ref<StreamingOption | undefined>): {
|
|
4
|
+
tailContent: import('vue').ComputedRef<string | null>;
|
|
5
|
+
tailComponent: import('vue').ComputedRef<import('vue').Component | null>;
|
|
6
|
+
showTail: import('vue').ComputedRef<boolean | undefined>;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=useTail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTail.d.ts","sourceRoot":"","sources":["../../../src/XMarkdown/composables/useTail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AAEzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,wBAAgB,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,eAAe,GAAG,SAAS,CAAC;;;;EAyBlE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ParserOptions } from '../interface';
|
|
2
|
+
export declare function escapeHtml(html: string): string;
|
|
3
|
+
export declare class Parser {
|
|
4
|
+
private options;
|
|
5
|
+
private markdownInstance;
|
|
6
|
+
private injectTail;
|
|
7
|
+
constructor(options?: ParserOptions);
|
|
8
|
+
private updateMarkedConfig;
|
|
9
|
+
private configureRenderers;
|
|
10
|
+
private getCodeBlockState;
|
|
11
|
+
parse(markdown: string, parseOptions?: {
|
|
12
|
+
injectTail?: boolean;
|
|
13
|
+
}): string;
|
|
14
|
+
private markedParse;
|
|
15
|
+
private sanitize;
|
|
16
|
+
private protectCustomTags;
|
|
17
|
+
private escapeRawHtml;
|
|
18
|
+
private injectTailMarker;
|
|
19
|
+
setOptions(options: Partial<ParserOptions>): void;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=Parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Parser.d.ts","sourceRoot":"","sources":["../../../src/XMarkdown/core/Parser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,aAAa,EAAE,MAAM,cAAc,CAAC;AAUhE,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK/C;AAED,qBAAa,MAAM;IACjB,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,UAAU,CAAS;gBAEf,OAAO,GAAE,aAAkB;IAoBvC,OAAO,CAAC,kBAAkB;IAS1B,OAAO,CAAC,kBAAkB;IA8C1B,OAAO,CAAC,iBAAiB;IAIzB,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM;IAsBxE,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,QAAQ;IAoBhB,OAAO,CAAC,iBAAiB;IAgBzB,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,gBAAgB;IAkDxB,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI;CAQlD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { VNode } from 'vue';
|
|
2
|
+
import { RendererOptions } from '../interface';
|
|
3
|
+
export declare class VueRenderer {
|
|
4
|
+
private options;
|
|
5
|
+
constructor(options?: RendererOptions);
|
|
6
|
+
render(html: string): VNode;
|
|
7
|
+
private sanitize;
|
|
8
|
+
private parseToVNodes;
|
|
9
|
+
private convertNode;
|
|
10
|
+
private convertNativeElement;
|
|
11
|
+
private extractComponentProps;
|
|
12
|
+
private wrapWithAnimation;
|
|
13
|
+
setOptions(options: Partial<RendererOptions>): void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=VueRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VueRenderer.d.ts","sourceRoot":"","sources":["../../../src/XMarkdown/core/VueRenderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAgD,KAAK,KAAK,EAAE,MAAM,KAAK,CAAC;AAE/E,OAAO,KAAK,EAAE,eAAe,EAAkB,MAAM,cAAc,CAAC;AAqDpE,qBAAa,WAAW;IACtB,OAAO,CAAC,OAAO,CAA4B;gBAE/B,OAAO,GAAE,eAAoB;IAYzC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK;IAgB3B,OAAO,CAAC,QAAQ;IAkEhB,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,WAAW;IA4DnB,OAAO,CAAC,oBAAoB;IAsB5B,OAAO,CAAC,qBAAqB;IAmB7B,OAAO,CAAC,iBAAiB;IAQzB,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI;CAiBpD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detectUnclosedComponentTags.d.ts","sourceRoot":"","sources":["../../../src/XMarkdown/core/detectUnclosedComponentTags.ts"],"names":[],"mappings":"AAmBA,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,EACZ,mBAAmB,EAAE,MAAM,EAAE,GAC5B,GAAG,CAAC,MAAM,CAAC,CAsDb"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
import { XMarkdownProps } from './interface';
|
|
3
|
+
declare const __VLS_export: import('vue').DefineComponent<XMarkdownProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<XMarkdownProps> & Readonly<{}>, {
|
|
4
|
+
content: string;
|
|
5
|
+
openLinksInNewTab: boolean;
|
|
6
|
+
paragraphTag: string;
|
|
7
|
+
escapeRawHtml: boolean;
|
|
8
|
+
config: import('./interface').MarkedConfig;
|
|
9
|
+
components: Record<string, Component>;
|
|
10
|
+
streaming: import('./interface').StreamingOption;
|
|
11
|
+
debug: boolean;
|
|
12
|
+
protectCustomTagNewlines: boolean;
|
|
13
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
14
|
+
declare const _default: typeof __VLS_export;
|
|
15
|
+
export default _default;
|
|
16
|
+
//# sourceMappingURL=index.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.vue.d.ts","sourceRoot":"","sources":["../../src/XMarkdown/index.vue"],"names":[],"mappings":"AAuLA,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,KAAK,CAAC;AAItD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAQlD,OAAO,aAAa,CAAC;AAyNrB,QAAA,MAAM,YAAY;;;;;;;;;;6EAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { TokenizerAndRendererExtension } from 'marked';
|
|
2
|
+
import { Component } from 'vue';
|
|
3
|
+
export declare enum StreamCacheTokenType {
|
|
4
|
+
Text = "text",
|
|
5
|
+
Link = "link",
|
|
6
|
+
Image = "image",
|
|
7
|
+
Html = "html",
|
|
8
|
+
Emphasis = "emphasis",
|
|
9
|
+
List = "list",
|
|
10
|
+
Table = "table",
|
|
11
|
+
InlineCode = "inline-code"
|
|
12
|
+
}
|
|
13
|
+
export interface StreamCache {
|
|
14
|
+
pending: string;
|
|
15
|
+
token: StreamCacheTokenType;
|
|
16
|
+
processedLength: number;
|
|
17
|
+
completeMarkdown: string;
|
|
18
|
+
}
|
|
19
|
+
export interface StreamingOption {
|
|
20
|
+
hasNextChunk: boolean;
|
|
21
|
+
enableAnimation?: boolean;
|
|
22
|
+
animationConfig?: {
|
|
23
|
+
fadeDuration?: number;
|
|
24
|
+
easing?: string;
|
|
25
|
+
};
|
|
26
|
+
tail?: boolean | {
|
|
27
|
+
content?: string;
|
|
28
|
+
component?: Component;
|
|
29
|
+
};
|
|
30
|
+
incompleteMarkdownComponentMap?: Partial<Record<StreamCacheTokenType, string>>;
|
|
31
|
+
}
|
|
32
|
+
export interface XMarkdownProps {
|
|
33
|
+
content?: string;
|
|
34
|
+
components?: Record<string, Component>;
|
|
35
|
+
streaming?: StreamingOption;
|
|
36
|
+
config?: MarkedConfig;
|
|
37
|
+
debug?: boolean;
|
|
38
|
+
protectCustomTagNewlines?: boolean;
|
|
39
|
+
escapeRawHtml?: boolean;
|
|
40
|
+
className?: string;
|
|
41
|
+
style?: Record<string, string>;
|
|
42
|
+
openLinksInNewTab?: boolean;
|
|
43
|
+
paragraphTag?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface MarkedConfig {
|
|
46
|
+
breaks?: boolean;
|
|
47
|
+
gfm?: boolean;
|
|
48
|
+
extensions?: TokenizerAndRendererExtension[] | null;
|
|
49
|
+
}
|
|
50
|
+
export interface ComponentProps {
|
|
51
|
+
domNode?: HTMLElement;
|
|
52
|
+
streamStatus?: "loading" | "done";
|
|
53
|
+
lang?: string;
|
|
54
|
+
block?: boolean;
|
|
55
|
+
[key: string]: unknown;
|
|
56
|
+
}
|
|
57
|
+
export interface AnimationTextProps {
|
|
58
|
+
text: string;
|
|
59
|
+
fadeDuration?: number;
|
|
60
|
+
easing?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface DebugPanelProps {
|
|
63
|
+
className?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface TailIndicatorProps {
|
|
66
|
+
content?: string;
|
|
67
|
+
}
|
|
68
|
+
export interface ParserOptions {
|
|
69
|
+
openLinksInNewTab?: boolean;
|
|
70
|
+
paragraphTag?: string;
|
|
71
|
+
injectTail?: boolean;
|
|
72
|
+
protectCustomTags?: boolean;
|
|
73
|
+
escapeRawHtml?: boolean;
|
|
74
|
+
config?: MarkedConfig;
|
|
75
|
+
components?: Record<string, Component>;
|
|
76
|
+
streamStatus?: "loading" | "done";
|
|
77
|
+
codeBlockStatus?: Record<string, "loading" | "done">;
|
|
78
|
+
}
|
|
79
|
+
export interface RendererOptions {
|
|
80
|
+
components?: Record<string, Component>;
|
|
81
|
+
enableAnimation?: boolean;
|
|
82
|
+
animationConfig?: {
|
|
83
|
+
fadeDuration?: number;
|
|
84
|
+
easing?: string;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/XMarkdown/interface.ts"],"names":[],"mappings":"AAAA,OAA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Ae;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACvC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,eAAe,CAAC,EAAE;QAChB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tail.d.ts","sourceRoot":"","sources":["../../../src/XMarkdown/utils/tail.ts"],"names":[],"mappings":"AAEA,wBAAgB,kBAAkB,CAChC,IAAI,CAAC,EAAE,OAAO,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GACzD,MAAM,GAAG,IAAI,CAIf"}
|
package/dist/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.xmd-debug-panel[data-v-d6923a13]{color:#fff;z-index:9999;-webkit-user-select:none;user-select:none;background:#000000d9;border-radius:8px;min-width:220px;padding:12px;font-size:12px;position:fixed;box-shadow:0 4px 12px #0000004d}.xmd-debug-header[data-v-d6923a13]{cursor:move;border-bottom:1px solid #fff3;margin-bottom:8px;padding-bottom:8px;font-weight:600}.xmd-debug-content[data-v-d6923a13]{flex-direction:column;gap:8px;display:flex}.xmd-debug-stat[data-v-d6923a13]{justify-content:space-between;display:flex}.xmd-debug-label[data-v-d6923a13]{color:#ffffffb3}.xmd-debug-chart[data-v-d6923a13]{background:#ffffff1a;border-radius:4px;width:100%;height:60px;margin-top:8px}.xmd-tail[data-v-802ace82]{color:inherit;font-size:inherit;line-height:inherit}@keyframes x-markdown-fade-in{0%{opacity:0}to{opacity:1}}.x-markdown{--text-color:inherit;--font-size:inherit;--margin-block:0 0 1em 0;--td-th-padding:.85em 1em;--pre-th-td-padding:2px 0;--border-font-weight:600;--padding-ul-ol:0 0 0 1em;--margin-ul-ol:0 0 1em 1.8em;--margin-li:.25em 0;--margin-pre:1em 0;--padding-code-inline:.2em .4em;--margin-code-inline:0 .2em;--code-inline-text:.85em;--small-border-radius:2px;--image-margin:.5em 0;--hr-margin:1.5em 0;--table-margin:1em 0;font-size:var(--font-size);width:100%;color:var(--text-color);line-height:1.57143}xmd-tail{display:inline}.xmd-tail{color:var(--xmd-tail-color,inherit);font-size:inherit;line-height:inherit}.x-markdown p,.x-markdown div,.x-markdown span,.x-markdown li{word-break:break-word;overflow-wrap:break-word}.x-markdown pre,.x-markdown code{word-break:break-word;overflow-wrap:break-word;white-space:pre-wrap}.x-markdown th,.x-markdown td{padding:var(--td-th-padding)}.x-markdown th{font-weight:var(--border-font-weight)}.x-markdown pre table{box-shadow:none}.x-markdown pre td,.x-markdown pre th{padding:var(--pre-th-td-padding);text-align:left;border:none}.x-markdown p{margin:var(--margin-block)}.x-markdown p:first-child{margin-top:0}.x-markdown p:last-child{margin-bottom:0}.x-markdown ul,.x-markdown ol{margin:var(--margin-ul-ol);padding:var(--padding-ul-ol)}.x-markdown ul:first-child,.x-markdown ol:first-child{margin-top:0}.x-markdown ul:last-child,.x-markdown ol:last-child{margin-bottom:0}.x-markdown ol>li{list-style:decimal}.x-markdown ul>li{list-style:outside}.x-markdown li{margin:var(--margin-li)}.x-markdown li:first-child{margin-top:0}.x-markdown li:last-child{margin-bottom:0}.x-markdown pre{margin:var(--margin-pre);overflow-x:auto}.x-markdown pre:first-child{margin-top:0}.x-markdown pre:last-child{margin-bottom:0}.x-markdown code{padding:var(--padding-code-inline);margin:var(--margin-code-inline);font-size:var(--code-inline-text);border-radius:var(--small-border-radius)}.x-markdown pre code{font-size:inherit;border-radius:0;margin:0;padding:0;line-height:2}.x-markdown img{max-width:100%;height:auto;margin:var(--image-margin)}.x-markdown hr{margin:var(--hr-margin)}.x-markdown table:not(pre){margin:var(--table-margin);border-collapse:collapse;width:max-content;max-width:100%;display:block;overflow:auto}.x-markdown table:not(pre):first-child{margin-top:0}.x-markdown table:not(pre):last-child{margin-bottom:0}.x-markdown .inline-katex .katex-display{text-align:initial;vertical-align:middle;margin:0;display:inline-block}.x-markdown .inline-katex .katex-display>.katex{text-align:initial;white-space:normal;display:inline-block}.x-markdown .inline-katex .katex-display>.katex>.katex-html{display:inline-block;position:static}.x-markdown .inline-katex .katex-display>.katex>.katex-html>.tag{position:static}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { default as XMarkdown } from './XMarkdown/index.vue';
|
|
2
|
+
export type { XMarkdownProps } from './XMarkdown/interface';
|
|
3
|
+
export type { StreamingOption } from './XMarkdown/interface';
|
|
4
|
+
export type { MarkedConfig } from './XMarkdown/interface';
|
|
5
|
+
export type { ComponentProps } from './XMarkdown/interface';
|
|
6
|
+
export { Parser } from './XMarkdown/core/Parser';
|
|
7
|
+
export { VueRenderer } from './XMarkdown/core/VueRenderer';
|
|
8
|
+
export { detectUnclosedComponentTags } from './XMarkdown/core/detectUnclosedComponentTags';
|
|
9
|
+
export { useStreaming } from './XMarkdown/composables/useStreaming';
|
|
10
|
+
export { useParser } from './XMarkdown/composables/useParser';
|
|
11
|
+
export { useRenderer } from './XMarkdown/composables/useRenderer';
|
|
12
|
+
export { useTail } from './XMarkdown/composables/useTail';
|
|
13
|
+
export { AnimationText, DebugPanel, TailIndicator, } from './XMarkdown/components';
|
|
14
|
+
export { resolveTailContent } from './XMarkdown/utils/tail';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAE7D,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAE3F,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAE1D,OAAO,EACL,aAAa,EACb,UAAU,EACV,aAAa,GACd,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC"}
|