@noirmd/previewer 1.0.2 → 1.1.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/dist/NReditor.cjs +42 -39
- package/dist/NReditor.cjs.map +1 -1
- package/dist/NReditor.js +42 -39
- package/dist/NReditor.js.map +1 -1
- package/dist/core.cjs +464 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +118 -0
- package/dist/core.d.ts +118 -0
- package/dist/core.js +429 -0
- package/dist/core.js.map +1 -0
- package/dist/index.cjs +57 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +120 -73
- package/dist/index.d.ts +120 -73
- package/dist/index.js +49 -38
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +12044 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +225 -0
- package/dist/react.d.ts +225 -0
- package/dist/react.js +12018 -0
- package/dist/react.js.map +1 -0
- package/dist/vanilla.cjs +11844 -0
- package/dist/vanilla.cjs.map +1 -0
- package/dist/vanilla.css +677 -0
- package/dist/vanilla.d.cts +173 -0
- package/dist/vanilla.d.ts +173 -0
- package/dist/vanilla.js +11818 -0
- package/dist/vanilla.js.map +1 -0
- package/dist/vue.cjs +12218 -0
- package/dist/vue.cjs.map +1 -0
- package/dist/vue.d.cts +389 -0
- package/dist/vue.d.ts +389 -0
- package/dist/vue.js +12208 -0
- package/dist/vue.js.map +1 -0
- package/package.json +37 -6
package/dist/vue.d.ts
ADDED
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { PropType, VNode, Ref, Component } from 'vue';
|
|
3
|
+
|
|
4
|
+
declare const NRpreviewer: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
5
|
+
content: {
|
|
6
|
+
type: StringConstructor;
|
|
7
|
+
default: undefined;
|
|
8
|
+
};
|
|
9
|
+
html: {
|
|
10
|
+
type: StringConstructor;
|
|
11
|
+
default: undefined;
|
|
12
|
+
};
|
|
13
|
+
tailwindCDN: {
|
|
14
|
+
type: BooleanConstructor;
|
|
15
|
+
default: boolean;
|
|
16
|
+
};
|
|
17
|
+
className: {
|
|
18
|
+
type: StringConstructor;
|
|
19
|
+
default: undefined;
|
|
20
|
+
};
|
|
21
|
+
style: {
|
|
22
|
+
type: PropType<Record<string, string>>;
|
|
23
|
+
default: undefined;
|
|
24
|
+
};
|
|
25
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
}> | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
28
|
+
content: {
|
|
29
|
+
type: StringConstructor;
|
|
30
|
+
default: undefined;
|
|
31
|
+
};
|
|
32
|
+
html: {
|
|
33
|
+
type: StringConstructor;
|
|
34
|
+
default: undefined;
|
|
35
|
+
};
|
|
36
|
+
tailwindCDN: {
|
|
37
|
+
type: BooleanConstructor;
|
|
38
|
+
default: boolean;
|
|
39
|
+
};
|
|
40
|
+
className: {
|
|
41
|
+
type: StringConstructor;
|
|
42
|
+
default: undefined;
|
|
43
|
+
};
|
|
44
|
+
style: {
|
|
45
|
+
type: PropType<Record<string, string>>;
|
|
46
|
+
default: undefined;
|
|
47
|
+
};
|
|
48
|
+
}>> & Readonly<{}>, {
|
|
49
|
+
html: string;
|
|
50
|
+
style: Record<string, string>;
|
|
51
|
+
className: string;
|
|
52
|
+
content: string;
|
|
53
|
+
tailwindCDN: boolean;
|
|
54
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
55
|
+
|
|
56
|
+
declare const CustomMarkdownRenderer: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
57
|
+
content: {
|
|
58
|
+
type: StringConstructor;
|
|
59
|
+
required: true;
|
|
60
|
+
};
|
|
61
|
+
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
62
|
+
[key: string]: any;
|
|
63
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
64
|
+
content: {
|
|
65
|
+
type: StringConstructor;
|
|
66
|
+
required: true;
|
|
67
|
+
};
|
|
68
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Generic CSSProperties — framework-agnostic equivalent of React.CSSProperties.
|
|
72
|
+
* Used for inline styles on tokens (e.g. images).
|
|
73
|
+
*/
|
|
74
|
+
type CSSProperties = Record<string, string | number>;
|
|
75
|
+
interface HeaderToken {
|
|
76
|
+
type: 'header';
|
|
77
|
+
level: number;
|
|
78
|
+
text: string;
|
|
79
|
+
id: string;
|
|
80
|
+
classes?: string;
|
|
81
|
+
}
|
|
82
|
+
interface ParagraphToken {
|
|
83
|
+
type: 'paragraph';
|
|
84
|
+
content: string;
|
|
85
|
+
align?: 'center' | 'right';
|
|
86
|
+
classes?: string;
|
|
87
|
+
id?: string;
|
|
88
|
+
}
|
|
89
|
+
interface CodeblockToken {
|
|
90
|
+
type: 'codeblock';
|
|
91
|
+
language: string;
|
|
92
|
+
content: string;
|
|
93
|
+
title?: string;
|
|
94
|
+
}
|
|
95
|
+
interface DirectiveToken {
|
|
96
|
+
type: 'directive';
|
|
97
|
+
directiveType: string;
|
|
98
|
+
props: Record<string, string>;
|
|
99
|
+
slots: Record<string, string>;
|
|
100
|
+
scopeId: string;
|
|
101
|
+
}
|
|
102
|
+
interface HtmlToken {
|
|
103
|
+
type: 'html';
|
|
104
|
+
content: string;
|
|
105
|
+
scopeId: string;
|
|
106
|
+
}
|
|
107
|
+
interface HtmlBlockToken {
|
|
108
|
+
type: 'html-block';
|
|
109
|
+
tag: string;
|
|
110
|
+
attrs: string;
|
|
111
|
+
children: Token[];
|
|
112
|
+
}
|
|
113
|
+
interface ImageToken {
|
|
114
|
+
type: 'image';
|
|
115
|
+
alt: string;
|
|
116
|
+
src: string;
|
|
117
|
+
style: CSSProperties;
|
|
118
|
+
}
|
|
119
|
+
interface TableToken {
|
|
120
|
+
type: 'table';
|
|
121
|
+
content: string;
|
|
122
|
+
}
|
|
123
|
+
interface ListToken {
|
|
124
|
+
type: 'list';
|
|
125
|
+
content: string;
|
|
126
|
+
}
|
|
127
|
+
interface BlockquoteToken {
|
|
128
|
+
type: 'blockquote';
|
|
129
|
+
content: string;
|
|
130
|
+
classes?: string;
|
|
131
|
+
id?: string;
|
|
132
|
+
}
|
|
133
|
+
interface HrToken {
|
|
134
|
+
type: 'hr';
|
|
135
|
+
}
|
|
136
|
+
interface TocToken {
|
|
137
|
+
type: 'toc';
|
|
138
|
+
}
|
|
139
|
+
type Token = HeaderToken | ParagraphToken | CodeblockToken | DirectiveToken | HtmlToken | HtmlBlockToken | ImageToken | TableToken | ListToken | BlockquoteToken | HrToken | TocToken;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* V2 Markdown Parser — line-by-line state machine (framework-agnostic).
|
|
143
|
+
*/
|
|
144
|
+
declare function parseMarkdown(markdown: string): Token[];
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Extract all header tokens from an AST for TOC generation.
|
|
148
|
+
*/
|
|
149
|
+
declare function extractHeaders(elements: Token[]): Token[];
|
|
150
|
+
|
|
151
|
+
declare const IconRenderer: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
152
|
+
iconName: {
|
|
153
|
+
type: StringConstructor;
|
|
154
|
+
required: true;
|
|
155
|
+
};
|
|
156
|
+
extraClasses: {
|
|
157
|
+
type: StringConstructor;
|
|
158
|
+
default: string;
|
|
159
|
+
};
|
|
160
|
+
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
161
|
+
[key: string]: any;
|
|
162
|
+
}> | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
163
|
+
iconName: {
|
|
164
|
+
type: StringConstructor;
|
|
165
|
+
required: true;
|
|
166
|
+
};
|
|
167
|
+
extraClasses: {
|
|
168
|
+
type: StringConstructor;
|
|
169
|
+
default: string;
|
|
170
|
+
};
|
|
171
|
+
}>> & Readonly<{}>, {
|
|
172
|
+
extraClasses: string;
|
|
173
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
174
|
+
declare const CodeBlock: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
175
|
+
code: {
|
|
176
|
+
type: StringConstructor;
|
|
177
|
+
required: true;
|
|
178
|
+
};
|
|
179
|
+
language: {
|
|
180
|
+
type: StringConstructor;
|
|
181
|
+
default: string;
|
|
182
|
+
};
|
|
183
|
+
title: {
|
|
184
|
+
type: StringConstructor;
|
|
185
|
+
default: undefined;
|
|
186
|
+
};
|
|
187
|
+
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
188
|
+
[key: string]: any;
|
|
189
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
190
|
+
code: {
|
|
191
|
+
type: StringConstructor;
|
|
192
|
+
required: true;
|
|
193
|
+
};
|
|
194
|
+
language: {
|
|
195
|
+
type: StringConstructor;
|
|
196
|
+
default: string;
|
|
197
|
+
};
|
|
198
|
+
title: {
|
|
199
|
+
type: StringConstructor;
|
|
200
|
+
default: undefined;
|
|
201
|
+
};
|
|
202
|
+
}>> & Readonly<{}>, {
|
|
203
|
+
title: string;
|
|
204
|
+
language: string;
|
|
205
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
206
|
+
declare const Admonition: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
207
|
+
type: {
|
|
208
|
+
type: StringConstructor;
|
|
209
|
+
default: string;
|
|
210
|
+
};
|
|
211
|
+
title: {
|
|
212
|
+
type: StringConstructor;
|
|
213
|
+
default: undefined;
|
|
214
|
+
};
|
|
215
|
+
icon: {
|
|
216
|
+
type: StringConstructor;
|
|
217
|
+
default: undefined;
|
|
218
|
+
};
|
|
219
|
+
class: {
|
|
220
|
+
type: StringConstructor;
|
|
221
|
+
default: string;
|
|
222
|
+
};
|
|
223
|
+
style: {
|
|
224
|
+
type: PropType<CSSProperties>;
|
|
225
|
+
default: undefined;
|
|
226
|
+
};
|
|
227
|
+
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
228
|
+
[key: string]: any;
|
|
229
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
230
|
+
type: {
|
|
231
|
+
type: StringConstructor;
|
|
232
|
+
default: string;
|
|
233
|
+
};
|
|
234
|
+
title: {
|
|
235
|
+
type: StringConstructor;
|
|
236
|
+
default: undefined;
|
|
237
|
+
};
|
|
238
|
+
icon: {
|
|
239
|
+
type: StringConstructor;
|
|
240
|
+
default: undefined;
|
|
241
|
+
};
|
|
242
|
+
class: {
|
|
243
|
+
type: StringConstructor;
|
|
244
|
+
default: string;
|
|
245
|
+
};
|
|
246
|
+
style: {
|
|
247
|
+
type: PropType<CSSProperties>;
|
|
248
|
+
default: undefined;
|
|
249
|
+
};
|
|
250
|
+
}>> & Readonly<{}>, {
|
|
251
|
+
class: string;
|
|
252
|
+
style: CSSProperties;
|
|
253
|
+
title: string;
|
|
254
|
+
type: string;
|
|
255
|
+
icon: string;
|
|
256
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
257
|
+
declare const Details: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
258
|
+
title: {
|
|
259
|
+
type: StringConstructor;
|
|
260
|
+
required: true;
|
|
261
|
+
};
|
|
262
|
+
icon: {
|
|
263
|
+
type: StringConstructor;
|
|
264
|
+
default: undefined;
|
|
265
|
+
};
|
|
266
|
+
defaultOpen: {
|
|
267
|
+
type: BooleanConstructor;
|
|
268
|
+
default: boolean;
|
|
269
|
+
};
|
|
270
|
+
class: {
|
|
271
|
+
type: StringConstructor;
|
|
272
|
+
default: string;
|
|
273
|
+
};
|
|
274
|
+
style: {
|
|
275
|
+
type: PropType<CSSProperties>;
|
|
276
|
+
default: undefined;
|
|
277
|
+
};
|
|
278
|
+
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
279
|
+
[key: string]: any;
|
|
280
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
281
|
+
title: {
|
|
282
|
+
type: StringConstructor;
|
|
283
|
+
required: true;
|
|
284
|
+
};
|
|
285
|
+
icon: {
|
|
286
|
+
type: StringConstructor;
|
|
287
|
+
default: undefined;
|
|
288
|
+
};
|
|
289
|
+
defaultOpen: {
|
|
290
|
+
type: BooleanConstructor;
|
|
291
|
+
default: boolean;
|
|
292
|
+
};
|
|
293
|
+
class: {
|
|
294
|
+
type: StringConstructor;
|
|
295
|
+
default: string;
|
|
296
|
+
};
|
|
297
|
+
style: {
|
|
298
|
+
type: PropType<CSSProperties>;
|
|
299
|
+
default: undefined;
|
|
300
|
+
};
|
|
301
|
+
}>> & Readonly<{}>, {
|
|
302
|
+
class: string;
|
|
303
|
+
style: CSSProperties;
|
|
304
|
+
icon: string;
|
|
305
|
+
defaultOpen: boolean;
|
|
306
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
307
|
+
declare const Modal: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
308
|
+
title: {
|
|
309
|
+
type: StringConstructor;
|
|
310
|
+
required: true;
|
|
311
|
+
};
|
|
312
|
+
isOpen: {
|
|
313
|
+
type: BooleanConstructor;
|
|
314
|
+
required: true;
|
|
315
|
+
};
|
|
316
|
+
onClose: {
|
|
317
|
+
type: PropType<() => void>;
|
|
318
|
+
required: true;
|
|
319
|
+
};
|
|
320
|
+
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
321
|
+
[key: string]: any;
|
|
322
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
323
|
+
title: {
|
|
324
|
+
type: StringConstructor;
|
|
325
|
+
required: true;
|
|
326
|
+
};
|
|
327
|
+
isOpen: {
|
|
328
|
+
type: BooleanConstructor;
|
|
329
|
+
required: true;
|
|
330
|
+
};
|
|
331
|
+
onClose: {
|
|
332
|
+
type: PropType<() => void>;
|
|
333
|
+
required: true;
|
|
334
|
+
};
|
|
335
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
336
|
+
|
|
337
|
+
declare global {
|
|
338
|
+
interface Window {
|
|
339
|
+
__twCDNRefs?: number;
|
|
340
|
+
tailwind?: {
|
|
341
|
+
config: object;
|
|
342
|
+
scan?: () => void;
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Lazy CDN composable — only loads the Tailwind Browser CDN when `enabled` is true.
|
|
348
|
+
*/
|
|
349
|
+
declare function useLazyTailwindCDN(enabled: Ref<boolean> | boolean): void;
|
|
350
|
+
/**
|
|
351
|
+
* Trigger a Tailwind CDN re-scan (use after DOM mutations with new classes).
|
|
352
|
+
*/
|
|
353
|
+
declare function scanTailwindCDN(): void;
|
|
354
|
+
/**
|
|
355
|
+
* Preload the Tailwind Browser CDN right after page load.
|
|
356
|
+
*/
|
|
357
|
+
declare function preloadTailwindCDN(): void;
|
|
358
|
+
|
|
359
|
+
interface RenderContext {
|
|
360
|
+
modals: Ref<Record<string, boolean>>;
|
|
361
|
+
setModals: (value: Record<string, boolean> | ((prev: Record<string, boolean>) => Record<string, boolean>)) => void;
|
|
362
|
+
articleClass: string;
|
|
363
|
+
allElements: Token[];
|
|
364
|
+
parseMarkdown: (md: string) => Token[];
|
|
365
|
+
renderElement: (element: Token, index: number, depth?: number) => any;
|
|
366
|
+
renderInline: (text: string) => any[];
|
|
367
|
+
processAndRenderElements: (elements: Token[], depth?: number) => any[];
|
|
368
|
+
}
|
|
369
|
+
type DirectiveComponent = Component;
|
|
370
|
+
interface DirectiveComponentProps {
|
|
371
|
+
/** The directive type string, e.g. 'card', 'note', 'modal' */
|
|
372
|
+
directiveType: string;
|
|
373
|
+
/** Parsed key="value" attributes from the {props} block */
|
|
374
|
+
props: Record<string, string>;
|
|
375
|
+
/** Named slots → raw content strings (to be parsed recursively) */
|
|
376
|
+
slots: Record<string, string>;
|
|
377
|
+
/** Convenience: render a named slot as parsed markdown */
|
|
378
|
+
renderSlot: (name: string) => any[];
|
|
379
|
+
/** Full render context access */
|
|
380
|
+
context: RenderContext;
|
|
381
|
+
/** Position index in the parent element list */
|
|
382
|
+
index: string | number;
|
|
383
|
+
/** Full parsed AST */
|
|
384
|
+
allElements: Token[];
|
|
385
|
+
/** Extra flags from the orchestrator */
|
|
386
|
+
options?: Record<string, any>;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
export { Admonition, type CSSProperties, CodeBlock, CustomMarkdownRenderer, Details, type DirectiveComponent, type DirectiveComponentProps, IconRenderer, Modal, NRpreviewer, type RenderContext, type Token, extractHeaders, parseMarkdown, preloadTailwindCDN, scanTailwindCDN, useLazyTailwindCDN };
|