@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/index.d.cts
CHANGED
|
@@ -122,7 +122,7 @@ interface NRpreviewerProps {
|
|
|
122
122
|
content?: string;
|
|
123
123
|
/** Raw HTML string to render (used when content is not provided) */
|
|
124
124
|
html?: string;
|
|
125
|
-
/** Inject Tailwind v4 browser CDN at runtime for
|
|
125
|
+
/** Inject Tailwind v4 browser CDN at runtime for user-authored Tailwind classes. Default: false */
|
|
126
126
|
tailwindCDN?: boolean;
|
|
127
127
|
/** Additional CSS class on the wrapper element */
|
|
128
128
|
className?: string;
|
|
@@ -134,8 +134,8 @@ interface NRpreviewerProps {
|
|
|
134
134
|
*
|
|
135
135
|
* @example
|
|
136
136
|
* ```tsx
|
|
137
|
-
* import { NRpreviewer } from '@noirmd/previewer';
|
|
138
|
-
* import '@noirmd/previewer/
|
|
137
|
+
* import { NRpreviewer } from '@noirmd/previewer/react';
|
|
138
|
+
* import '@noirmd/previewer/vanilla/vanilla.css';
|
|
139
139
|
*
|
|
140
140
|
* <NRpreviewer content="# Hello **world**" />
|
|
141
141
|
* <NRpreviewer content=":::note Title\nContent\n:::" tailwindCDN />
|
|
@@ -148,22 +148,26 @@ interface CustomMarkdownRendererProps {
|
|
|
148
148
|
content: string;
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
151
|
-
*
|
|
151
|
+
* CustomMarkdownRenderer — thin React wrapper around the vanilla renderer.
|
|
152
152
|
*
|
|
153
153
|
* Pipeline:
|
|
154
|
-
* content (string)
|
|
155
|
-
* → parseMarkdown() → allElements (Token[])
|
|
156
|
-
* → processAndRenderElements() → React tree
|
|
154
|
+
* content (string) → renderMarkdownString() → HTMLElement → mounted
|
|
157
155
|
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
156
|
+
* The vanilla engine handles all rendering, directives and events;
|
|
157
|
+
* React only owns the mount point. Note: rendering happens on the
|
|
158
|
+
* client (useEffect); the server render is an empty placeholder.
|
|
160
159
|
*/
|
|
161
160
|
declare const CustomMarkdownRenderer: React.FC<CustomMarkdownRendererProps>;
|
|
162
161
|
|
|
162
|
+
interface RawHtmlRendererProps {
|
|
163
|
+
content: string;
|
|
164
|
+
wrapperClassName?: string;
|
|
165
|
+
}
|
|
163
166
|
/**
|
|
164
|
-
*
|
|
167
|
+
* RawHtmlRenderer — thin React wrapper around the vanilla raw-HTML renderer.
|
|
168
|
+
* Injects <style> blocks globally and force-executes <script> tags.
|
|
165
169
|
*/
|
|
166
|
-
declare
|
|
170
|
+
declare const RawHtmlRenderer: React.FC<RawHtmlRendererProps>;
|
|
167
171
|
|
|
168
172
|
/**
|
|
169
173
|
* useDebounce — delays updating a value until after a specified delay.
|
|
@@ -171,43 +175,6 @@ declare function extractHeaders(elements: Token[]): Token[];
|
|
|
171
175
|
*/
|
|
172
176
|
declare function useDebounce<T>(value: T, delay: number): T;
|
|
173
177
|
|
|
174
|
-
interface IconRendererProps {
|
|
175
|
-
iconName: string;
|
|
176
|
-
extraClasses?: string;
|
|
177
|
-
}
|
|
178
|
-
declare const IconRenderer: React.FC<IconRendererProps>;
|
|
179
|
-
interface CodeBlockProps {
|
|
180
|
-
code: string;
|
|
181
|
-
language: string;
|
|
182
|
-
title?: string;
|
|
183
|
-
}
|
|
184
|
-
declare const CodeBlock: React.FC<CodeBlockProps>;
|
|
185
|
-
interface AdmonitionProps {
|
|
186
|
-
type: string;
|
|
187
|
-
title?: string;
|
|
188
|
-
icon?: string;
|
|
189
|
-
className?: string;
|
|
190
|
-
style?: React.CSSProperties;
|
|
191
|
-
children: React.ReactNode;
|
|
192
|
-
}
|
|
193
|
-
declare const Admonition: React.FC<AdmonitionProps>;
|
|
194
|
-
interface DetailsProps {
|
|
195
|
-
title: string;
|
|
196
|
-
icon?: string;
|
|
197
|
-
defaultOpen?: boolean;
|
|
198
|
-
className?: string;
|
|
199
|
-
style?: React.CSSProperties;
|
|
200
|
-
children: React.ReactNode;
|
|
201
|
-
}
|
|
202
|
-
declare const Details: React.FC<DetailsProps>;
|
|
203
|
-
interface ModalProps {
|
|
204
|
-
title: string;
|
|
205
|
-
isOpen: boolean;
|
|
206
|
-
onClose: () => void;
|
|
207
|
-
children: React.ReactNode;
|
|
208
|
-
}
|
|
209
|
-
declare const Modal: React.FC<ModalProps>;
|
|
210
|
-
|
|
211
178
|
declare global {
|
|
212
179
|
interface Window {
|
|
213
180
|
__twCDNRefs?: number;
|
|
@@ -233,34 +200,38 @@ declare function scanTailwindCDN(): void;
|
|
|
233
200
|
*/
|
|
234
201
|
declare function preloadTailwindCDN(): void;
|
|
235
202
|
|
|
236
|
-
interface
|
|
237
|
-
|
|
238
|
-
setModals: React.Dispatch<React.SetStateAction<Record<string, boolean>>>;
|
|
239
|
-
articleClass: string;
|
|
240
|
-
allElements: Token[];
|
|
203
|
+
interface VanillaRenderContext {
|
|
204
|
+
/** Parse markdown string into tokens */
|
|
241
205
|
parseMarkdown: (md: string) => Token[];
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
206
|
+
/** Render tokens into an HTMLElement */
|
|
207
|
+
renderElements: (tokens: Token[]) => HTMLElement;
|
|
208
|
+
/** Render inline text into a DocumentFragment */
|
|
209
|
+
renderInline: (text: string) => DocumentFragment;
|
|
210
|
+
/** Parse markdown string and render into an HTMLElement */
|
|
211
|
+
renderMarkdown: (md: string) => HTMLElement;
|
|
212
|
+
}
|
|
213
|
+
interface DirectiveProps {
|
|
214
|
+
/** The directive type string */
|
|
249
215
|
directiveType: string;
|
|
250
|
-
/** Parsed key="value" attributes
|
|
216
|
+
/** Parsed key="value" attributes */
|
|
251
217
|
props: Record<string, string>;
|
|
252
|
-
/** Named slots → raw content strings
|
|
218
|
+
/** Named slots → raw content strings */
|
|
253
219
|
slots: Record<string, string>;
|
|
254
|
-
/**
|
|
255
|
-
renderSlot: (name: string) =>
|
|
256
|
-
/**
|
|
257
|
-
context:
|
|
258
|
-
/** Position index
|
|
259
|
-
index:
|
|
220
|
+
/** Render a named slot as parsed markdown */
|
|
221
|
+
renderSlot: (name: string) => DocumentFragment;
|
|
222
|
+
/** Render context */
|
|
223
|
+
context: VanillaRenderContext;
|
|
224
|
+
/** Position index */
|
|
225
|
+
index: number;
|
|
260
226
|
/** Full parsed AST */
|
|
261
227
|
allElements: Token[];
|
|
262
|
-
/** Extra flags
|
|
228
|
+
/** Extra flags */
|
|
263
229
|
options?: Record<string, any>;
|
|
230
|
+
/** Inline renderer shortcut */
|
|
231
|
+
renderInline: (text: string) => DocumentFragment;
|
|
232
|
+
/** Full markdown renderer shortcut (for complex directives like slide) */
|
|
233
|
+
renderMarkdown?: (md: string) => HTMLElement;
|
|
264
234
|
}
|
|
235
|
+
type DirectiveRendererFn = (props: DirectiveProps) => HTMLElement | DocumentFragment;
|
|
265
236
|
|
|
266
|
-
export {
|
|
237
|
+
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, extractAttributes, generateId, generateScopeId, parseCssString, parseHtmlAttrs, parseMarkdown, parseProps, preloadTailwindCDN, resetScopeCounter, scanTailwindCDN, scrollToId, useDebounce, useLazyTailwindCDN };
|
package/dist/index.d.ts
CHANGED
|
@@ -122,7 +122,7 @@ interface NRpreviewerProps {
|
|
|
122
122
|
content?: string;
|
|
123
123
|
/** Raw HTML string to render (used when content is not provided) */
|
|
124
124
|
html?: string;
|
|
125
|
-
/** Inject Tailwind v4 browser CDN at runtime for
|
|
125
|
+
/** Inject Tailwind v4 browser CDN at runtime for user-authored Tailwind classes. Default: false */
|
|
126
126
|
tailwindCDN?: boolean;
|
|
127
127
|
/** Additional CSS class on the wrapper element */
|
|
128
128
|
className?: string;
|
|
@@ -134,8 +134,8 @@ interface NRpreviewerProps {
|
|
|
134
134
|
*
|
|
135
135
|
* @example
|
|
136
136
|
* ```tsx
|
|
137
|
-
* import { NRpreviewer } from '@noirmd/previewer';
|
|
138
|
-
* import '@noirmd/previewer/
|
|
137
|
+
* import { NRpreviewer } from '@noirmd/previewer/react';
|
|
138
|
+
* import '@noirmd/previewer/vanilla/vanilla.css';
|
|
139
139
|
*
|
|
140
140
|
* <NRpreviewer content="# Hello **world**" />
|
|
141
141
|
* <NRpreviewer content=":::note Title\nContent\n:::" tailwindCDN />
|
|
@@ -148,22 +148,26 @@ interface CustomMarkdownRendererProps {
|
|
|
148
148
|
content: string;
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
151
|
-
*
|
|
151
|
+
* CustomMarkdownRenderer — thin React wrapper around the vanilla renderer.
|
|
152
152
|
*
|
|
153
153
|
* Pipeline:
|
|
154
|
-
* content (string)
|
|
155
|
-
* → parseMarkdown() → allElements (Token[])
|
|
156
|
-
* → processAndRenderElements() → React tree
|
|
154
|
+
* content (string) → renderMarkdownString() → HTMLElement → mounted
|
|
157
155
|
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
156
|
+
* The vanilla engine handles all rendering, directives and events;
|
|
157
|
+
* React only owns the mount point. Note: rendering happens on the
|
|
158
|
+
* client (useEffect); the server render is an empty placeholder.
|
|
160
159
|
*/
|
|
161
160
|
declare const CustomMarkdownRenderer: React.FC<CustomMarkdownRendererProps>;
|
|
162
161
|
|
|
162
|
+
interface RawHtmlRendererProps {
|
|
163
|
+
content: string;
|
|
164
|
+
wrapperClassName?: string;
|
|
165
|
+
}
|
|
163
166
|
/**
|
|
164
|
-
*
|
|
167
|
+
* RawHtmlRenderer — thin React wrapper around the vanilla raw-HTML renderer.
|
|
168
|
+
* Injects <style> blocks globally and force-executes <script> tags.
|
|
165
169
|
*/
|
|
166
|
-
declare
|
|
170
|
+
declare const RawHtmlRenderer: React.FC<RawHtmlRendererProps>;
|
|
167
171
|
|
|
168
172
|
/**
|
|
169
173
|
* useDebounce — delays updating a value until after a specified delay.
|
|
@@ -171,43 +175,6 @@ declare function extractHeaders(elements: Token[]): Token[];
|
|
|
171
175
|
*/
|
|
172
176
|
declare function useDebounce<T>(value: T, delay: number): T;
|
|
173
177
|
|
|
174
|
-
interface IconRendererProps {
|
|
175
|
-
iconName: string;
|
|
176
|
-
extraClasses?: string;
|
|
177
|
-
}
|
|
178
|
-
declare const IconRenderer: React.FC<IconRendererProps>;
|
|
179
|
-
interface CodeBlockProps {
|
|
180
|
-
code: string;
|
|
181
|
-
language: string;
|
|
182
|
-
title?: string;
|
|
183
|
-
}
|
|
184
|
-
declare const CodeBlock: React.FC<CodeBlockProps>;
|
|
185
|
-
interface AdmonitionProps {
|
|
186
|
-
type: string;
|
|
187
|
-
title?: string;
|
|
188
|
-
icon?: string;
|
|
189
|
-
className?: string;
|
|
190
|
-
style?: React.CSSProperties;
|
|
191
|
-
children: React.ReactNode;
|
|
192
|
-
}
|
|
193
|
-
declare const Admonition: React.FC<AdmonitionProps>;
|
|
194
|
-
interface DetailsProps {
|
|
195
|
-
title: string;
|
|
196
|
-
icon?: string;
|
|
197
|
-
defaultOpen?: boolean;
|
|
198
|
-
className?: string;
|
|
199
|
-
style?: React.CSSProperties;
|
|
200
|
-
children: React.ReactNode;
|
|
201
|
-
}
|
|
202
|
-
declare const Details: React.FC<DetailsProps>;
|
|
203
|
-
interface ModalProps {
|
|
204
|
-
title: string;
|
|
205
|
-
isOpen: boolean;
|
|
206
|
-
onClose: () => void;
|
|
207
|
-
children: React.ReactNode;
|
|
208
|
-
}
|
|
209
|
-
declare const Modal: React.FC<ModalProps>;
|
|
210
|
-
|
|
211
178
|
declare global {
|
|
212
179
|
interface Window {
|
|
213
180
|
__twCDNRefs?: number;
|
|
@@ -233,34 +200,38 @@ declare function scanTailwindCDN(): void;
|
|
|
233
200
|
*/
|
|
234
201
|
declare function preloadTailwindCDN(): void;
|
|
235
202
|
|
|
236
|
-
interface
|
|
237
|
-
|
|
238
|
-
setModals: React.Dispatch<React.SetStateAction<Record<string, boolean>>>;
|
|
239
|
-
articleClass: string;
|
|
240
|
-
allElements: Token[];
|
|
203
|
+
interface VanillaRenderContext {
|
|
204
|
+
/** Parse markdown string into tokens */
|
|
241
205
|
parseMarkdown: (md: string) => Token[];
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
206
|
+
/** Render tokens into an HTMLElement */
|
|
207
|
+
renderElements: (tokens: Token[]) => HTMLElement;
|
|
208
|
+
/** Render inline text into a DocumentFragment */
|
|
209
|
+
renderInline: (text: string) => DocumentFragment;
|
|
210
|
+
/** Parse markdown string and render into an HTMLElement */
|
|
211
|
+
renderMarkdown: (md: string) => HTMLElement;
|
|
212
|
+
}
|
|
213
|
+
interface DirectiveProps {
|
|
214
|
+
/** The directive type string */
|
|
249
215
|
directiveType: string;
|
|
250
|
-
/** Parsed key="value" attributes
|
|
216
|
+
/** Parsed key="value" attributes */
|
|
251
217
|
props: Record<string, string>;
|
|
252
|
-
/** Named slots → raw content strings
|
|
218
|
+
/** Named slots → raw content strings */
|
|
253
219
|
slots: Record<string, string>;
|
|
254
|
-
/**
|
|
255
|
-
renderSlot: (name: string) =>
|
|
256
|
-
/**
|
|
257
|
-
context:
|
|
258
|
-
/** Position index
|
|
259
|
-
index:
|
|
220
|
+
/** Render a named slot as parsed markdown */
|
|
221
|
+
renderSlot: (name: string) => DocumentFragment;
|
|
222
|
+
/** Render context */
|
|
223
|
+
context: VanillaRenderContext;
|
|
224
|
+
/** Position index */
|
|
225
|
+
index: number;
|
|
260
226
|
/** Full parsed AST */
|
|
261
227
|
allElements: Token[];
|
|
262
|
-
/** Extra flags
|
|
228
|
+
/** Extra flags */
|
|
263
229
|
options?: Record<string, any>;
|
|
230
|
+
/** Inline renderer shortcut */
|
|
231
|
+
renderInline: (text: string) => DocumentFragment;
|
|
232
|
+
/** Full markdown renderer shortcut (for complex directives like slide) */
|
|
233
|
+
renderMarkdown?: (md: string) => HTMLElement;
|
|
264
234
|
}
|
|
235
|
+
type DirectiveRendererFn = (props: DirectiveProps) => HTMLElement | DocumentFragment;
|
|
265
236
|
|
|
266
|
-
export {
|
|
237
|
+
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, extractAttributes, generateId, generateScopeId, parseCssString, parseHtmlAttrs, parseMarkdown, parseProps, preloadTailwindCDN, resetScopeCounter, scanTailwindCDN, scrollToId, useDebounce, useLazyTailwindCDN };
|