@noirmd/previewer 1.2.0 → 2.0.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/dist/NReditor.cjs +851 -895
- package/dist/NReditor.cjs.map +1 -1
- package/dist/NReditor.d.cts +1 -1
- package/dist/NReditor.d.ts +1 -1
- package/dist/NReditor.js +852 -896
- package/dist/NReditor.js.map +1 -1
- package/dist/admonition.css +55 -0
- package/dist/{markdown.css → base.css} +96 -126
- package/dist/blockquote.css +16 -0
- package/dist/button.css +32 -0
- package/dist/card.css +143 -0
- package/dist/codeblock.css +59 -0
- package/dist/core.cjs +9 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +9 -1
- package/dist/core.js.map +1 -1
- package/dist/details.css +45 -0
- package/dist/editor.css +56 -9
- package/dist/fonts/material-icons-round.woff2 +0 -0
- package/dist/index.cjs +852 -883
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -70
- package/dist/index.d.ts +41 -70
- package/dist/index.js +851 -877
- package/dist/index.js.map +1 -1
- package/dist/list.css +18 -0
- package/dist/modal.css +82 -0
- package/dist/react.cjs +852 -886
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +44 -73
- package/dist/react.d.ts +44 -73
- package/dist/react.js +851 -880
- package/dist/react.js.map +1 -1
- package/dist/slide.css +21 -0
- package/dist/table.css +36 -0
- package/dist/toc.css +45 -0
- package/dist/vanilla.cjs +42 -28
- package/dist/vanilla.cjs.map +1 -1
- package/dist/vanilla.css +32 -677
- package/dist/vanilla.d.cts +8 -2
- package/dist/vanilla.d.ts +8 -2
- package/dist/vanilla.js +41 -28
- package/dist/vanilla.js.map +1 -1
- package/dist/variables.css +53 -0
- package/dist/vue.cjs +931 -1121
- package/dist/vue.cjs.map +1 -1
- package/dist/vue.d.cts +63 -214
- package/dist/vue.d.ts +63 -214
- package/dist/vue.js +930 -1120
- package/dist/vue.js.map +1 -1
- package/editor.css +56 -9
- package/package.json +5 -10
- package/markdown.css +0 -344
package/dist/react.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ interface NRpreviewerProps {
|
|
|
5
5
|
content?: string;
|
|
6
6
|
/** Raw HTML string to render (used when content is not provided) */
|
|
7
7
|
html?: string;
|
|
8
|
-
/** Inject Tailwind v4 browser CDN at runtime for
|
|
8
|
+
/** Inject Tailwind v4 browser CDN at runtime for user-authored Tailwind classes. Default: false */
|
|
9
9
|
tailwindCDN?: boolean;
|
|
10
10
|
/** Additional CSS class on the wrapper element */
|
|
11
11
|
className?: string;
|
|
@@ -17,8 +17,8 @@ interface NRpreviewerProps {
|
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* ```tsx
|
|
20
|
-
* import { NRpreviewer } from '@noirmd/previewer';
|
|
21
|
-
* import '@noirmd/previewer/
|
|
20
|
+
* import { NRpreviewer } from '@noirmd/previewer/react';
|
|
21
|
+
* import '@noirmd/previewer/vanilla/vanilla.css';
|
|
22
22
|
*
|
|
23
23
|
* <NRpreviewer content="# Hello **world**" />
|
|
24
24
|
* <NRpreviewer content=":::note Title\nContent\n:::" tailwindCDN />
|
|
@@ -31,18 +31,27 @@ interface CustomMarkdownRendererProps {
|
|
|
31
31
|
content: string;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* CustomMarkdownRenderer — thin React wrapper around the vanilla renderer.
|
|
35
35
|
*
|
|
36
36
|
* Pipeline:
|
|
37
|
-
* content (string)
|
|
38
|
-
* → parseMarkdown() → allElements (Token[])
|
|
39
|
-
* → processAndRenderElements() → React tree
|
|
37
|
+
* content (string) → renderMarkdownString() → HTMLElement → mounted
|
|
40
38
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
39
|
+
* The vanilla engine handles all rendering, directives and events;
|
|
40
|
+
* React only owns the mount point. Note: rendering happens on the
|
|
41
|
+
* client (useEffect); the server render is an empty placeholder.
|
|
43
42
|
*/
|
|
44
43
|
declare const CustomMarkdownRenderer: React.FC<CustomMarkdownRendererProps>;
|
|
45
44
|
|
|
45
|
+
interface RawHtmlRendererProps {
|
|
46
|
+
content: string;
|
|
47
|
+
wrapperClassName?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* RawHtmlRenderer — thin React wrapper around the vanilla raw-HTML renderer.
|
|
51
|
+
* Injects <style> blocks globally and force-executes <script> tags.
|
|
52
|
+
*/
|
|
53
|
+
declare const RawHtmlRenderer: React.FC<RawHtmlRendererProps>;
|
|
54
|
+
|
|
46
55
|
/**
|
|
47
56
|
* Generic CSSProperties — framework-agnostic equivalent of React.CSSProperties.
|
|
48
57
|
* Used for inline styles on tokens (e.g. images).
|
|
@@ -119,54 +128,12 @@ type Token = HeaderToken | ParagraphToken | CodeblockToken | DirectiveToken | Ht
|
|
|
119
128
|
*/
|
|
120
129
|
declare function parseMarkdown(markdown: string): Token[];
|
|
121
130
|
|
|
122
|
-
/**
|
|
123
|
-
* Extract all header tokens from an AST for TOC generation.
|
|
124
|
-
*/
|
|
125
|
-
declare function extractHeaders(elements: Token[]): Token[];
|
|
126
|
-
|
|
127
131
|
/**
|
|
128
132
|
* useDebounce — delays updating a value until after a specified delay.
|
|
129
133
|
* Useful for reducing expensive operations (like preview rendering) during rapid input.
|
|
130
134
|
*/
|
|
131
135
|
declare function useDebounce<T>(value: T, delay: number): T;
|
|
132
136
|
|
|
133
|
-
interface IconRendererProps {
|
|
134
|
-
iconName: string;
|
|
135
|
-
extraClasses?: string;
|
|
136
|
-
}
|
|
137
|
-
declare const IconRenderer: React.FC<IconRendererProps>;
|
|
138
|
-
interface CodeBlockProps {
|
|
139
|
-
code: string;
|
|
140
|
-
language: string;
|
|
141
|
-
title?: string;
|
|
142
|
-
}
|
|
143
|
-
declare const CodeBlock: React.FC<CodeBlockProps>;
|
|
144
|
-
interface AdmonitionProps {
|
|
145
|
-
type: string;
|
|
146
|
-
title?: string;
|
|
147
|
-
icon?: string;
|
|
148
|
-
className?: string;
|
|
149
|
-
style?: React.CSSProperties;
|
|
150
|
-
children: React.ReactNode;
|
|
151
|
-
}
|
|
152
|
-
declare const Admonition: React.FC<AdmonitionProps>;
|
|
153
|
-
interface DetailsProps {
|
|
154
|
-
title: string;
|
|
155
|
-
icon?: string;
|
|
156
|
-
defaultOpen?: boolean;
|
|
157
|
-
className?: string;
|
|
158
|
-
style?: React.CSSProperties;
|
|
159
|
-
children: React.ReactNode;
|
|
160
|
-
}
|
|
161
|
-
declare const Details: React.FC<DetailsProps>;
|
|
162
|
-
interface ModalProps {
|
|
163
|
-
title: string;
|
|
164
|
-
isOpen: boolean;
|
|
165
|
-
onClose: () => void;
|
|
166
|
-
children: React.ReactNode;
|
|
167
|
-
}
|
|
168
|
-
declare const Modal: React.FC<ModalProps>;
|
|
169
|
-
|
|
170
137
|
declare global {
|
|
171
138
|
interface Window {
|
|
172
139
|
__twCDNRefs?: number;
|
|
@@ -192,34 +159,38 @@ declare function scanTailwindCDN(): void;
|
|
|
192
159
|
*/
|
|
193
160
|
declare function preloadTailwindCDN(): void;
|
|
194
161
|
|
|
195
|
-
interface
|
|
196
|
-
|
|
197
|
-
setModals: React.Dispatch<React.SetStateAction<Record<string, boolean>>>;
|
|
198
|
-
articleClass: string;
|
|
199
|
-
allElements: Token[];
|
|
162
|
+
interface VanillaRenderContext {
|
|
163
|
+
/** Parse markdown string into tokens */
|
|
200
164
|
parseMarkdown: (md: string) => Token[];
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
165
|
+
/** Render tokens into an HTMLElement */
|
|
166
|
+
renderElements: (tokens: Token[]) => HTMLElement;
|
|
167
|
+
/** Render inline text into a DocumentFragment */
|
|
168
|
+
renderInline: (text: string) => DocumentFragment;
|
|
169
|
+
/** Parse markdown string and render into an HTMLElement */
|
|
170
|
+
renderMarkdown: (md: string) => HTMLElement;
|
|
171
|
+
}
|
|
172
|
+
interface DirectiveProps {
|
|
173
|
+
/** The directive type string */
|
|
208
174
|
directiveType: string;
|
|
209
|
-
/** Parsed key="value" attributes
|
|
175
|
+
/** Parsed key="value" attributes */
|
|
210
176
|
props: Record<string, string>;
|
|
211
|
-
/** Named slots → raw content strings
|
|
177
|
+
/** Named slots → raw content strings */
|
|
212
178
|
slots: Record<string, string>;
|
|
213
|
-
/**
|
|
214
|
-
renderSlot: (name: string) =>
|
|
215
|
-
/**
|
|
216
|
-
context:
|
|
217
|
-
/** Position index
|
|
218
|
-
index:
|
|
179
|
+
/** Render a named slot as parsed markdown */
|
|
180
|
+
renderSlot: (name: string) => DocumentFragment;
|
|
181
|
+
/** Render context */
|
|
182
|
+
context: VanillaRenderContext;
|
|
183
|
+
/** Position index */
|
|
184
|
+
index: number;
|
|
219
185
|
/** Full parsed AST */
|
|
220
186
|
allElements: Token[];
|
|
221
|
-
/** Extra flags
|
|
187
|
+
/** Extra flags */
|
|
222
188
|
options?: Record<string, any>;
|
|
189
|
+
/** Inline renderer shortcut */
|
|
190
|
+
renderInline: (text: string) => DocumentFragment;
|
|
191
|
+
/** Full markdown renderer shortcut (for complex directives like slide) */
|
|
192
|
+
renderMarkdown?: (md: string) => HTMLElement;
|
|
223
193
|
}
|
|
194
|
+
type DirectiveRendererFn = (props: DirectiveProps) => HTMLElement | DocumentFragment;
|
|
224
195
|
|
|
225
|
-
export {
|
|
196
|
+
export { type BlockquoteToken, type CSSProperties, type CodeblockToken, CustomMarkdownRenderer, type DirectiveProps, type DirectiveRendererFn, type DirectiveToken, type HeaderToken, type HrToken, type HtmlBlockToken, type HtmlToken, type ImageToken, type ListToken, NRpreviewer, type NRpreviewerProps, type ParagraphToken, RawHtmlRenderer, type TableToken, type TocToken, type Token, type VanillaRenderContext, parseMarkdown, preloadTailwindCDN, scanTailwindCDN, useDebounce, useLazyTailwindCDN };
|
package/dist/react.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ interface NRpreviewerProps {
|
|
|
5
5
|
content?: string;
|
|
6
6
|
/** Raw HTML string to render (used when content is not provided) */
|
|
7
7
|
html?: string;
|
|
8
|
-
/** Inject Tailwind v4 browser CDN at runtime for
|
|
8
|
+
/** Inject Tailwind v4 browser CDN at runtime for user-authored Tailwind classes. Default: false */
|
|
9
9
|
tailwindCDN?: boolean;
|
|
10
10
|
/** Additional CSS class on the wrapper element */
|
|
11
11
|
className?: string;
|
|
@@ -17,8 +17,8 @@ interface NRpreviewerProps {
|
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* ```tsx
|
|
20
|
-
* import { NRpreviewer } from '@noirmd/previewer';
|
|
21
|
-
* import '@noirmd/previewer/
|
|
20
|
+
* import { NRpreviewer } from '@noirmd/previewer/react';
|
|
21
|
+
* import '@noirmd/previewer/vanilla/vanilla.css';
|
|
22
22
|
*
|
|
23
23
|
* <NRpreviewer content="# Hello **world**" />
|
|
24
24
|
* <NRpreviewer content=":::note Title\nContent\n:::" tailwindCDN />
|
|
@@ -31,18 +31,27 @@ interface CustomMarkdownRendererProps {
|
|
|
31
31
|
content: string;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* CustomMarkdownRenderer — thin React wrapper around the vanilla renderer.
|
|
35
35
|
*
|
|
36
36
|
* Pipeline:
|
|
37
|
-
* content (string)
|
|
38
|
-
* → parseMarkdown() → allElements (Token[])
|
|
39
|
-
* → processAndRenderElements() → React tree
|
|
37
|
+
* content (string) → renderMarkdownString() → HTMLElement → mounted
|
|
40
38
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
39
|
+
* The vanilla engine handles all rendering, directives and events;
|
|
40
|
+
* React only owns the mount point. Note: rendering happens on the
|
|
41
|
+
* client (useEffect); the server render is an empty placeholder.
|
|
43
42
|
*/
|
|
44
43
|
declare const CustomMarkdownRenderer: React.FC<CustomMarkdownRendererProps>;
|
|
45
44
|
|
|
45
|
+
interface RawHtmlRendererProps {
|
|
46
|
+
content: string;
|
|
47
|
+
wrapperClassName?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* RawHtmlRenderer — thin React wrapper around the vanilla raw-HTML renderer.
|
|
51
|
+
* Injects <style> blocks globally and force-executes <script> tags.
|
|
52
|
+
*/
|
|
53
|
+
declare const RawHtmlRenderer: React.FC<RawHtmlRendererProps>;
|
|
54
|
+
|
|
46
55
|
/**
|
|
47
56
|
* Generic CSSProperties — framework-agnostic equivalent of React.CSSProperties.
|
|
48
57
|
* Used for inline styles on tokens (e.g. images).
|
|
@@ -119,54 +128,12 @@ type Token = HeaderToken | ParagraphToken | CodeblockToken | DirectiveToken | Ht
|
|
|
119
128
|
*/
|
|
120
129
|
declare function parseMarkdown(markdown: string): Token[];
|
|
121
130
|
|
|
122
|
-
/**
|
|
123
|
-
* Extract all header tokens from an AST for TOC generation.
|
|
124
|
-
*/
|
|
125
|
-
declare function extractHeaders(elements: Token[]): Token[];
|
|
126
|
-
|
|
127
131
|
/**
|
|
128
132
|
* useDebounce — delays updating a value until after a specified delay.
|
|
129
133
|
* Useful for reducing expensive operations (like preview rendering) during rapid input.
|
|
130
134
|
*/
|
|
131
135
|
declare function useDebounce<T>(value: T, delay: number): T;
|
|
132
136
|
|
|
133
|
-
interface IconRendererProps {
|
|
134
|
-
iconName: string;
|
|
135
|
-
extraClasses?: string;
|
|
136
|
-
}
|
|
137
|
-
declare const IconRenderer: React.FC<IconRendererProps>;
|
|
138
|
-
interface CodeBlockProps {
|
|
139
|
-
code: string;
|
|
140
|
-
language: string;
|
|
141
|
-
title?: string;
|
|
142
|
-
}
|
|
143
|
-
declare const CodeBlock: React.FC<CodeBlockProps>;
|
|
144
|
-
interface AdmonitionProps {
|
|
145
|
-
type: string;
|
|
146
|
-
title?: string;
|
|
147
|
-
icon?: string;
|
|
148
|
-
className?: string;
|
|
149
|
-
style?: React.CSSProperties;
|
|
150
|
-
children: React.ReactNode;
|
|
151
|
-
}
|
|
152
|
-
declare const Admonition: React.FC<AdmonitionProps>;
|
|
153
|
-
interface DetailsProps {
|
|
154
|
-
title: string;
|
|
155
|
-
icon?: string;
|
|
156
|
-
defaultOpen?: boolean;
|
|
157
|
-
className?: string;
|
|
158
|
-
style?: React.CSSProperties;
|
|
159
|
-
children: React.ReactNode;
|
|
160
|
-
}
|
|
161
|
-
declare const Details: React.FC<DetailsProps>;
|
|
162
|
-
interface ModalProps {
|
|
163
|
-
title: string;
|
|
164
|
-
isOpen: boolean;
|
|
165
|
-
onClose: () => void;
|
|
166
|
-
children: React.ReactNode;
|
|
167
|
-
}
|
|
168
|
-
declare const Modal: React.FC<ModalProps>;
|
|
169
|
-
|
|
170
137
|
declare global {
|
|
171
138
|
interface Window {
|
|
172
139
|
__twCDNRefs?: number;
|
|
@@ -192,34 +159,38 @@ declare function scanTailwindCDN(): void;
|
|
|
192
159
|
*/
|
|
193
160
|
declare function preloadTailwindCDN(): void;
|
|
194
161
|
|
|
195
|
-
interface
|
|
196
|
-
|
|
197
|
-
setModals: React.Dispatch<React.SetStateAction<Record<string, boolean>>>;
|
|
198
|
-
articleClass: string;
|
|
199
|
-
allElements: Token[];
|
|
162
|
+
interface VanillaRenderContext {
|
|
163
|
+
/** Parse markdown string into tokens */
|
|
200
164
|
parseMarkdown: (md: string) => Token[];
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
165
|
+
/** Render tokens into an HTMLElement */
|
|
166
|
+
renderElements: (tokens: Token[]) => HTMLElement;
|
|
167
|
+
/** Render inline text into a DocumentFragment */
|
|
168
|
+
renderInline: (text: string) => DocumentFragment;
|
|
169
|
+
/** Parse markdown string and render into an HTMLElement */
|
|
170
|
+
renderMarkdown: (md: string) => HTMLElement;
|
|
171
|
+
}
|
|
172
|
+
interface DirectiveProps {
|
|
173
|
+
/** The directive type string */
|
|
208
174
|
directiveType: string;
|
|
209
|
-
/** Parsed key="value" attributes
|
|
175
|
+
/** Parsed key="value" attributes */
|
|
210
176
|
props: Record<string, string>;
|
|
211
|
-
/** Named slots → raw content strings
|
|
177
|
+
/** Named slots → raw content strings */
|
|
212
178
|
slots: Record<string, string>;
|
|
213
|
-
/**
|
|
214
|
-
renderSlot: (name: string) =>
|
|
215
|
-
/**
|
|
216
|
-
context:
|
|
217
|
-
/** Position index
|
|
218
|
-
index:
|
|
179
|
+
/** Render a named slot as parsed markdown */
|
|
180
|
+
renderSlot: (name: string) => DocumentFragment;
|
|
181
|
+
/** Render context */
|
|
182
|
+
context: VanillaRenderContext;
|
|
183
|
+
/** Position index */
|
|
184
|
+
index: number;
|
|
219
185
|
/** Full parsed AST */
|
|
220
186
|
allElements: Token[];
|
|
221
|
-
/** Extra flags
|
|
187
|
+
/** Extra flags */
|
|
222
188
|
options?: Record<string, any>;
|
|
189
|
+
/** Inline renderer shortcut */
|
|
190
|
+
renderInline: (text: string) => DocumentFragment;
|
|
191
|
+
/** Full markdown renderer shortcut (for complex directives like slide) */
|
|
192
|
+
renderMarkdown?: (md: string) => HTMLElement;
|
|
223
193
|
}
|
|
194
|
+
type DirectiveRendererFn = (props: DirectiveProps) => HTMLElement | DocumentFragment;
|
|
224
195
|
|
|
225
|
-
export {
|
|
196
|
+
export { type BlockquoteToken, type CSSProperties, type CodeblockToken, CustomMarkdownRenderer, type DirectiveProps, type DirectiveRendererFn, type DirectiveToken, type HeaderToken, type HrToken, type HtmlBlockToken, type HtmlToken, type ImageToken, type ListToken, NRpreviewer, type NRpreviewerProps, type ParagraphToken, RawHtmlRenderer, type TableToken, type TocToken, type Token, type VanillaRenderContext, parseMarkdown, preloadTailwindCDN, scanTailwindCDN, useDebounce, useLazyTailwindCDN };
|