markstream-vue2 0.0.44 → 0.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{cssMode-86e8d6e4.cjs → cssMode-58e68511.cjs} +1 -1
- package/dist/chunks/{cssMode-32774a06.js → cssMode-60d93f28.js} +1 -1
- package/dist/chunks/{htmlMode-f84c7583.cjs → htmlMode-87a75897.cjs} +1 -1
- package/dist/chunks/{htmlMode-076e483c.js → htmlMode-8d468223.js} +1 -1
- package/dist/chunks/{index.legacy-1c6de434.js → index.legacy-010f0006.js} +2318 -1507
- package/dist/chunks/index.legacy-e02dc92b.cjs +1 -0
- package/dist/chunks/{jsonMode-e60229b9.cjs → jsonMode-2a97b947.cjs} +1 -1
- package/dist/chunks/{jsonMode-186d141c.js → jsonMode-307a9a02.js} +1 -1
- package/dist/chunks/{tsMode-6444eb2b.js → tsMode-4f227d36.js} +1 -1
- package/dist/chunks/{tsMode-5b9a0ba1.cjs → tsMode-b1f6e7cb.cjs} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +23 -7
- package/dist/index.js +3973 -3634
- package/dist/index.px.css +1 -1
- package/dist/index.tailwind.css +1 -1
- package/dist/tailwind.ts +1 -1
- package/dist/types/components/CodeBlockNode/CodeBlockNode.vue.d.ts +27 -8
- package/dist/types/components/CodeBlockNode/HtmlPreviewFrame.vue.d.ts +2 -0
- package/dist/types/components/D2BlockNode/D2BlockNode.vue.d.ts +3 -3
- package/dist/types/components/D2BlockNode/d2.d.ts +13 -2
- package/dist/types/components/HeadingNode/HeadingNode.vue.d.ts +1 -1
- package/dist/types/components/HtmlBlockNode/HtmlBlockNode.vue.d.ts +19 -1
- package/dist/types/components/HtmlInlineNode/HtmlInlineNode.vue.d.ts +2 -0
- package/dist/types/components/ImageNode/ImageNode.vue.d.ts +2 -15
- package/dist/types/components/InfographicBlockNode/InfographicBlockNode.vue.d.ts +4 -3
- package/dist/types/components/InfographicBlockNode/infographic.d.ts +13 -1
- package/dist/types/components/MarkdownCodeBlockNode/MarkdownCodeBlockNode.vue.d.ts +8 -7
- package/dist/types/components/MathInlineNode/katex.d.ts +5 -2
- package/dist/types/components/MermaidBlockNode/MermaidBlockNode.vue.d.ts +4 -3
- package/dist/types/components/MermaidBlockNode/mermaid.d.ts +16 -2
- package/dist/types/components/NestedRenderer/NestedRenderer.vue.d.ts +1 -1
- package/dist/types/components/NodeRenderer/LegacyNodesRenderer.vue.d.ts +11 -8
- package/dist/types/components/NodeRenderer/NodeRenderer.vue.d.ts +16 -15
- package/dist/types/components/ParagraphNode/ParagraphNode.vue.d.ts +1 -0
- package/dist/types/components/TableNode/TableNode.vue.d.ts +3 -1
- package/dist/types/composables/useSafeI18n.d.ts +3 -3
- package/dist/types/composables/viewportPriority.d.ts +4 -3
- package/dist/types/exports.d.ts +23 -7
- package/dist/types/types/component-props.d.ts +20 -7
- package/dist/types/types/index.d.ts +2 -6
- package/dist/types/utils/diagramHeight.d.ts +11 -0
- package/dist/types/utils/htmlRenderer.d.ts +5 -27
- package/dist/types/utils/nestedHtml.d.ts +2 -1
- package/dist/types/utils/nestedNodes.d.ts +6 -1
- package/dist/types/utils/normalizeKaTeXRenderInput.d.ts +1 -0
- package/dist/workers/mermaidParser.worker.js +1 -1
- package/package.json +2 -2
- package/dist/chunks/index.legacy-70f0e155.cjs +0 -1
- package/dist/types/components/SoftBreakNode/SoftBreakNode.vue.d.ts +0 -17
- package/dist/types/components/SoftBreakNode/index.d.ts +0 -2
|
@@ -8,7 +8,7 @@ export interface CodeBlockMonacoThemeObject {
|
|
|
8
8
|
[key: string]: unknown;
|
|
9
9
|
}
|
|
10
10
|
export type CodeBlockMonacoTheme = string | CodeBlockMonacoThemeObject;
|
|
11
|
-
export type CodeBlockMonacoLanguage = string | ((...args:
|
|
11
|
+
export type CodeBlockMonacoLanguage = string | ((...args: unknown[]) => unknown);
|
|
12
12
|
export interface CodeBlockDiffHideUnchangedRegionsOptions {
|
|
13
13
|
enabled?: boolean;
|
|
14
14
|
contextLineCount?: number;
|
|
@@ -41,6 +41,7 @@ export interface CodeBlockMonacoOptions {
|
|
|
41
41
|
themes?: CodeBlockMonacoTheme[];
|
|
42
42
|
languages?: CodeBlockMonacoLanguage[];
|
|
43
43
|
renderSideBySide?: boolean;
|
|
44
|
+
useInlineViewWhenSpaceIsLimited?: boolean;
|
|
44
45
|
enableSplitViewResizing?: boolean;
|
|
45
46
|
ignoreTrimWhitespace?: boolean;
|
|
46
47
|
maxComputationTime?: number;
|
|
@@ -60,8 +61,8 @@ export interface CodeBlockMonacoOptions {
|
|
|
60
61
|
diffHunkActionsOnHover?: boolean;
|
|
61
62
|
diffHunkHoverHideDelayMs?: number;
|
|
62
63
|
onDiffHunkAction?: (context: CodeBlockDiffHunkActionContext) => void | boolean | Promise<void | boolean>;
|
|
63
|
-
scrollbar?: Record<string,
|
|
64
|
-
[key: string]:
|
|
64
|
+
scrollbar?: Record<string, unknown>;
|
|
65
|
+
[key: string]: unknown;
|
|
65
66
|
}
|
|
66
67
|
export interface CodeBlockNodeProps {
|
|
67
68
|
node: CodeBlockNode;
|
|
@@ -83,6 +84,8 @@ export interface CodeBlockNodeProps {
|
|
|
83
84
|
showCollapseButton?: boolean;
|
|
84
85
|
showFontSizeButtons?: boolean;
|
|
85
86
|
showTooltips?: boolean;
|
|
87
|
+
htmlPreviewAllowScripts?: boolean;
|
|
88
|
+
htmlPreviewSandbox?: string;
|
|
86
89
|
customId?: string;
|
|
87
90
|
}
|
|
88
91
|
export interface ImageNodeProps {
|
|
@@ -95,11 +98,8 @@ export interface ImageNodeProps {
|
|
|
95
98
|
loading?: boolean;
|
|
96
99
|
};
|
|
97
100
|
fallbackSrc?: string;
|
|
98
|
-
showCaption?: boolean;
|
|
99
101
|
lazy?: boolean;
|
|
100
|
-
svgMinHeight?: string;
|
|
101
102
|
usePlaceholder?: boolean;
|
|
102
|
-
inline?: boolean;
|
|
103
103
|
}
|
|
104
104
|
export interface LinkNodeProps {
|
|
105
105
|
node: {
|
|
@@ -132,6 +132,7 @@ export interface PreCodeNodeProps {
|
|
|
132
132
|
export interface MermaidBlockNodeProps {
|
|
133
133
|
node: CodeBlockNode;
|
|
134
134
|
maxHeight?: string | null;
|
|
135
|
+
estimatedPreviewHeightPx?: number;
|
|
135
136
|
loading?: boolean;
|
|
136
137
|
isDark?: boolean;
|
|
137
138
|
workerTimeoutMs?: number;
|
|
@@ -155,7 +156,18 @@ export interface MermaidBlockNodeProps {
|
|
|
155
156
|
showTooltips?: boolean;
|
|
156
157
|
onRenderError?: (error: unknown, code: string, container: HTMLElement) => boolean | void;
|
|
157
158
|
}
|
|
158
|
-
export interface
|
|
159
|
+
export interface CodeBlockPreviewPayload {
|
|
160
|
+
node: CodeBlockNode;
|
|
161
|
+
artifactType: 'text/html' | 'image/svg+xml';
|
|
162
|
+
artifactTitle: string;
|
|
163
|
+
id: string;
|
|
164
|
+
}
|
|
165
|
+
export interface MarkdownCodeBlockPreviewPayload {
|
|
166
|
+
type: 'text/html' | 'image/svg+xml';
|
|
167
|
+
content: string;
|
|
168
|
+
title: string;
|
|
169
|
+
}
|
|
170
|
+
export interface MermaidBlockEvent<TPayload = unknown> {
|
|
159
171
|
payload?: TPayload;
|
|
160
172
|
defaultPrevented: boolean;
|
|
161
173
|
preventDefault: () => void;
|
|
@@ -199,6 +211,7 @@ export interface MathInlineNodeProps {
|
|
|
199
211
|
export interface InfographicBlockNodeProps {
|
|
200
212
|
node: CodeBlockNode;
|
|
201
213
|
maxHeight?: string | null;
|
|
214
|
+
estimatedPreviewHeightPx?: number;
|
|
202
215
|
loading?: boolean;
|
|
203
216
|
isDark?: boolean;
|
|
204
217
|
showHeader?: boolean;
|
|
@@ -191,9 +191,6 @@ export interface EmojiNode extends BaseNode {
|
|
|
191
191
|
export interface HardBreakNode extends BaseNode {
|
|
192
192
|
type: 'hardbreak';
|
|
193
193
|
}
|
|
194
|
-
export interface SoftBreakNode extends BaseNode {
|
|
195
|
-
type: 'softbreak';
|
|
196
|
-
}
|
|
197
194
|
export interface MathInlineNode extends BaseNode {
|
|
198
195
|
type: 'math_inline';
|
|
199
196
|
content: string;
|
|
@@ -217,11 +214,11 @@ export interface MarkdownToken {
|
|
|
217
214
|
children?: MarkdownToken[];
|
|
218
215
|
attrs?: [string, string][];
|
|
219
216
|
markup?: string;
|
|
220
|
-
meta?:
|
|
217
|
+
meta?: unknown;
|
|
221
218
|
map?: [number, number];
|
|
222
219
|
raw?: string;
|
|
223
220
|
}
|
|
224
|
-
export type ParsedNode = TextNode | HeadingNode | ParagraphNode | ListNode | ListItemNode | CodeBlockNode | InlineCodeNode | LinkNode | ImageNode | HtmlInlineNode | CustomComponentNode | ThematicBreakNode | BlockquoteNode | TableNode | TableRowNode | TableCellNode | StrongNode | EmphasisNode | StrikethroughNode | HighlightNode | InsertNode | SubscriptNode | SuperscriptNode | CheckboxNode | CheckboxInputNode | EmojiNode | DefinitionListNode | DefinitionItemNode | FootnoteNode | FootnoteReferenceNode | AdmonitionNode | HardBreakNode |
|
|
221
|
+
export type ParsedNode = TextNode | HeadingNode | ParagraphNode | ListNode | ListItemNode | CodeBlockNode | InlineCodeNode | LinkNode | ImageNode | HtmlInlineNode | CustomComponentNode | ThematicBreakNode | BlockquoteNode | TableNode | TableRowNode | TableCellNode | StrongNode | EmphasisNode | StrikethroughNode | HighlightNode | InsertNode | SubscriptNode | SuperscriptNode | CheckboxNode | CheckboxInputNode | EmojiNode | DefinitionListNode | DefinitionItemNode | FootnoteNode | FootnoteReferenceNode | AdmonitionNode | HardBreakNode | MathInlineNode | MathBlockNode | ReferenceNode | UnknownNode;
|
|
225
222
|
export interface CustomComponents {
|
|
226
223
|
text?: Component;
|
|
227
224
|
paragraph?: Component;
|
|
@@ -237,7 +234,6 @@ export interface CustomComponents {
|
|
|
237
234
|
footnote_anchor?: Component;
|
|
238
235
|
admonition?: Component;
|
|
239
236
|
hardbreak?: Component;
|
|
240
|
-
softbreak?: Component;
|
|
241
237
|
link?: Component;
|
|
242
238
|
image?: Component;
|
|
243
239
|
thematic_break?: Component;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const MERMAID_PREVIEW_MIN_HEIGHT = 360;
|
|
2
|
+
export declare const MERMAID_PREVIEW_MAX_HEIGHT = 500;
|
|
3
|
+
export declare const INFOGRAPHIC_PREVIEW_MIN_HEIGHT = 360;
|
|
4
|
+
export declare const INFOGRAPHIC_PREVIEW_MAX_HEIGHT = 500;
|
|
5
|
+
export declare function parsePositiveNumber(value: unknown): number;
|
|
6
|
+
export declare function getMermaidDiagramKind(code: string): string;
|
|
7
|
+
export declare function estimateMermaidPreviewHeight(code: string): number;
|
|
8
|
+
export declare function estimateInfographicPreviewHeight(code: string): number;
|
|
9
|
+
export declare function clampPreviewHeight(height: number, minHeight?: number, maxHeight?: number | null): number;
|
|
10
|
+
export declare function clampMermaidPreviewHeight(height: number, minHeight?: number, maxHeight?: number | null): number;
|
|
11
|
+
export declare function clampInfographicPreviewHeight(height: number, minHeight?: number, maxHeight?: number | null): number;
|
|
@@ -1,37 +1,16 @@
|
|
|
1
|
+
import { HtmlPolicy, HtmlToken, getHtmlTagFromContent, hasCompleteHtmlTagContent, isHtmlTagBlocked, shouldRenderUnknownHtmlTagAsText, stripCustomHtmlWrapper, tokenizeHtml } from 'stream-markdown-parser';
|
|
1
2
|
import { Component } from 'vue-demi';
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
tagName?: string;
|
|
5
|
-
attrs?: Record<string, string>;
|
|
6
|
-
content?: string;
|
|
7
|
-
}
|
|
3
|
+
export { getHtmlTagFromContent, hasCompleteHtmlTagContent, isHtmlTagBlocked, shouldRenderUnknownHtmlTagAsText, stripCustomHtmlWrapper, tokenizeHtml, };
|
|
4
|
+
export type { HtmlPolicy, HtmlToken } from 'stream-markdown-parser';
|
|
8
5
|
type CreateElementLike = (tag: any, attrs?: Record<string, any>, children?: any[] | undefined) => any;
|
|
9
|
-
/**
|
|
10
|
-
* Check if a tag name is a custom Vue component
|
|
11
|
-
*/
|
|
12
6
|
export declare function isCustomComponent(tagName: string, customComponents: Record<string, Component>): boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Sanitize attributes to remove XSS-prone event handlers
|
|
15
|
-
*/
|
|
16
7
|
export declare function sanitizeAttrs(attrs: Record<string, string>): Record<string, string>;
|
|
17
|
-
/**
|
|
18
|
-
* Convert attribute value to appropriate type
|
|
19
|
-
*/
|
|
20
8
|
export declare function convertPropValue(value: string, key: string): any;
|
|
21
|
-
/**
|
|
22
|
-
* Convert all attribute values to appropriate types
|
|
23
|
-
*/
|
|
24
9
|
export declare function convertAttrsToProps(attrs: Record<string, string>): Record<string, any>;
|
|
25
|
-
/**
|
|
26
|
-
* Simple HTML tokenizer
|
|
27
|
-
* Note: This is a basic implementation. For production use with complex HTML,
|
|
28
|
-
* consider using a proper HTML parser library like htmlparser2.
|
|
29
|
-
*/
|
|
30
|
-
export declare function tokenizeHtml(html: string): HtmlToken[];
|
|
31
10
|
/**
|
|
32
11
|
* Build VNode tree from tokens
|
|
33
12
|
*/
|
|
34
|
-
export declare function buildVNodeTree(tokens: HtmlToken[], customComponents: Record<string, Component>, createElement?: CreateElementLike): any[];
|
|
13
|
+
export declare function buildVNodeTree(tokens: HtmlToken[], customComponents: Record<string, Component>, createElement?: CreateElementLike, htmlPolicy?: HtmlPolicy): any[];
|
|
35
14
|
/**
|
|
36
15
|
* Check if HTML content contains custom components
|
|
37
16
|
*/
|
|
@@ -39,5 +18,4 @@ export declare function hasCustomComponents(content: string, customComponents: R
|
|
|
39
18
|
/**
|
|
40
19
|
* Parse HTML content to VNodes
|
|
41
20
|
*/
|
|
42
|
-
export declare function parseHtmlToVNodes(content: string, customComponents: Record<string, Component>, createElement?: CreateElementLike): any[] | null;
|
|
43
|
-
export {};
|
|
21
|
+
export declare function parseHtmlToVNodes(content: string, customComponents: Record<string, Component>, createElement?: CreateElementLike, htmlPolicy?: HtmlPolicy): any[] | null;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { BaseNode, ParsedNode } from 'stream-markdown-parser';
|
|
1
|
+
import { BaseNode, HtmlPolicy, ParsedNode } from 'stream-markdown-parser';
|
|
2
2
|
export type NestedRenderableNode = (ParsedNode | BaseNode) & Record<string, unknown>;
|
|
3
3
|
type NestedClassValue = string | readonly string[] | null | undefined;
|
|
4
4
|
export interface NestedMarkdownHtmlOptions {
|
|
5
5
|
cacheKey?: string;
|
|
6
6
|
customHtmlTags?: readonly string[];
|
|
7
7
|
allowHtml?: boolean;
|
|
8
|
+
htmlPolicy?: HtmlPolicy;
|
|
8
9
|
customNodeTag?: string;
|
|
9
10
|
customNodeClass?: NestedClassValue | ((node: NestedRenderableNode) => NestedClassValue);
|
|
10
11
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { BaseNode, MarkdownIt, ParseOptions } from 'stream-markdown-parser';
|
|
2
|
+
type NestedMarkdownSourceNode = BaseNode & {
|
|
3
|
+
children?: BaseNode[];
|
|
4
|
+
content?: string;
|
|
5
|
+
};
|
|
2
6
|
export interface NestedMarkdownNodesInput {
|
|
3
|
-
node?:
|
|
7
|
+
node?: NestedMarkdownSourceNode | null;
|
|
4
8
|
nodes?: readonly BaseNode[] | null;
|
|
5
9
|
content?: string | null;
|
|
6
10
|
}
|
|
@@ -12,3 +16,4 @@ export interface NestedMarkdownNodesOptions {
|
|
|
12
16
|
customMarkdownIt?: (markdown: MarkdownIt) => MarkdownIt;
|
|
13
17
|
}
|
|
14
18
|
export declare function parseNestedMarkdownToNodes(input: NestedMarkdownNodesInput, options?: NestedMarkdownNodesOptions): BaseNode[];
|
|
19
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function normalizeKaTeXRenderInput(content: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=Object.getOwnPropertyNames,r=(t,r,e)=>new Promise((n,a)=>{var o=t=>{try{l(e.next(t))}catch(r){a(r)}},i=t=>{try{l(e.throw(t))}catch(r){a(r)}},l=t=>t.done?n(t.value):Promise.resolve(t.value).then(o,i);l((e=e.apply(t,r)).next())});import e from"mermaid";var n,a,o=(n={"workers/mermaidParser.worker.js"(t){function n(t,n){return r(this,null,function*(){var r;const a=function(t,r){const e=`%%{init: {"theme": "${"dark"===r?"dark":"default"}"}}%%\n`;return t.trimStart().startsWith("%%{")?t:e+t}(t,n),o=e;if("function"==typeof o.parse)return yield null==(r=o.parse)?void 0:r.call(o,a),!0;throw new Error("mermaid.parse not available in worker")})}e.initialize({startOnLoad:!1,securityLevel:"
|
|
1
|
+
var t=Object.getOwnPropertyNames,r=(t,r,e)=>new Promise((n,a)=>{var o=t=>{try{l(e.next(t))}catch(r){a(r)}},i=t=>{try{l(e.throw(t))}catch(r){a(r)}},l=t=>t.done?n(t.value):Promise.resolve(t.value).then(o,i);l((e=e.apply(t,r)).next())});import e from"mermaid";var n,a,o=(n={"workers/mermaidParser.worker.js"(t){function n(t,n){return r(this,null,function*(){var r;const a=function(t,r){const e=`%%{init: {"theme": "${"dark"===r?"dark":"default"}"}}%%\n`;return t.trimStart().startsWith("%%{")?t:e+t}(t,n),o=e;if("function"==typeof o.parse)return yield null==(r=o.parse)?void 0:r.call(o,a),!0;throw new Error("mermaid.parse not available in worker")})}e.initialize({startOnLoad:!1,securityLevel:"strict",flowchart:{htmlLabels:!1}}),self.onmessage=e=>r(t,null,function*(){var t;const a=e.data,o=t=>self.postMessage(t),i=a.id;try{if("canParse"===a.action)return void o({id:i,ok:!0,result:yield n(a.payload.code,a.payload.theme)});if("findPrefix"===a.action)return void o({id:i,ok:!0,result:yield function(t,e){return r(this,null,function*(){const r=t.split("\n"),a=function(t){const r=/^(?:graph|flowchart|flowchart\s+tb|flowchart\s+lr|sequenceDiagram|gantt|classDiagram|stateDiagram(?:-v2)?|erDiagram|journey|pie|quadrantChart|timeline|xychart(?:-beta)?)\b/;for(let e=0;e<t.length;e++){const n=t[e].trim();if(n&&!n.startsWith("%%")&&r.test(n))return e}return-1}(r);if(-1===a)return null;const o=r.slice(0,a+1);yield n(o.join("\n"),e);let i=a+1,l=r.length,s=a+1,c=0;for(;i<=l&&c<12;){const t=Math.floor((i+l)/2),d=[...o,...r.slice(a+1,t)].join("\n");c++;try{yield n(d,e),s=t,i=t+1}catch(u){l=t-1}}return[...o,...r.slice(a+1,s)].join("\n")})}(a.payload.code,a.payload.theme)});o({id:i,ok:!1,error:"Unknown action"})}catch(l){o({id:i,ok:!1,error:null!=(t=null==l?void 0:l.message)?t:String(l)})}})}},function(){return a||(0,n[t(n)[0]])((a={exports:{}}).exports,a),a.exports});export default o();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markstream-vue2",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.45",
|
|
5
5
|
"description": "Vue 2 Markdown renderer optimized for large documents with progressive Mermaid rendering, streaming diff code blocks, and fast real-time preview. Perfect for documentation sites, AI chat interfaces, and content management systems.",
|
|
6
6
|
"author": "Simon He",
|
|
7
7
|
"license": "MIT",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"dependencies": {
|
|
119
119
|
"@floating-ui/dom": "^1.7.6",
|
|
120
120
|
"vue-demi": "^0.14.10",
|
|
121
|
-
"stream-markdown-parser": "0.0.
|
|
121
|
+
"stream-markdown-parser": "0.0.93"
|
|
122
122
|
},
|
|
123
123
|
"devDependencies": {
|
|
124
124
|
"@vitejs/plugin-vue2": "^2.3.4",
|