draftly 1.0.7 → 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/README.md +12 -0
- package/dist/chunk-3T55CBNZ.cjs +33 -0
- package/dist/chunk-3T55CBNZ.cjs.map +1 -0
- package/dist/chunk-5MC4T7JH.cjs +58 -0
- package/dist/chunk-5MC4T7JH.cjs.map +1 -0
- package/dist/{chunk-72ZYRGRT.cjs → chunk-BWJLMREN.cjs} +11 -9
- package/dist/chunk-BWJLMREN.cjs.map +1 -0
- package/dist/{chunk-KBQDZ5IW.cjs → chunk-CLW73JRX.cjs} +100 -75
- package/dist/chunk-CLW73JRX.cjs.map +1 -0
- package/dist/{chunk-DFQYXFOP.js → chunk-EEHILRG5.js} +26 -3
- package/dist/chunk-EEHILRG5.js.map +1 -0
- package/dist/{chunk-HPSMS2WB.js → chunk-I563H35S.js} +101 -75
- package/dist/chunk-I563H35S.js.map +1 -0
- package/dist/chunk-IAXF4SJL.js +55 -0
- package/dist/chunk-IAXF4SJL.js.map +1 -0
- package/dist/chunk-JF3WXXMJ.js +31 -0
- package/dist/chunk-JF3WXXMJ.js.map +1 -0
- package/dist/{chunk-N3WL3XPB.js → chunk-L2XSK57Y.js} +1761 -478
- package/dist/chunk-L2XSK57Y.js.map +1 -0
- package/dist/{chunk-KDEDLC3D.cjs → chunk-TBVZEK2H.cjs} +27 -2
- package/dist/chunk-TBVZEK2H.cjs.map +1 -0
- package/dist/{chunk-2B3A3VSQ.cjs → chunk-W5ALMXG2.cjs} +1808 -504
- package/dist/chunk-W5ALMXG2.cjs.map +1 -0
- package/dist/{chunk-CG4M4TC7.js → chunk-ZUI3GI3W.js} +7 -5
- package/dist/chunk-ZUI3GI3W.js.map +1 -0
- package/dist/{draftly-BLnx3uGX.d.cts → draftly-BBL-AdOl.d.cts} +5 -1
- package/dist/{draftly-BLnx3uGX.d.ts → draftly-BBL-AdOl.d.ts} +5 -1
- package/dist/editor/index.cjs +22 -14
- package/dist/editor/index.d.cts +2 -1
- package/dist/editor/index.d.ts +2 -1
- package/dist/editor/index.js +2 -2
- package/dist/index.cjs +65 -39
- package/dist/index.d.cts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +6 -4
- package/dist/lib/index.cjs +12 -0
- package/dist/lib/index.cjs.map +1 -0
- package/dist/lib/index.d.cts +16 -0
- package/dist/lib/index.d.ts +16 -0
- package/dist/lib/index.js +3 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/plugins/index.cjs +27 -17
- package/dist/plugins/index.d.cts +144 -9
- package/dist/plugins/index.d.ts +144 -9
- package/dist/plugins/index.js +5 -3
- package/dist/preview/index.cjs +16 -11
- package/dist/preview/index.d.cts +19 -4
- package/dist/preview/index.d.ts +19 -4
- package/dist/preview/index.js +3 -2
- package/package.json +8 -1
- package/src/editor/draftly.ts +1 -0
- package/src/editor/plugin.ts +5 -1
- package/src/editor/theme.ts +1 -0
- package/src/editor/utils.ts +31 -0
- package/src/index.ts +5 -4
- package/src/lib/index.ts +2 -0
- package/src/lib/input-handler.ts +45 -0
- package/src/plugins/code-plugin.theme.ts +426 -0
- package/src/plugins/code-plugin.ts +810 -561
- package/src/plugins/emoji-plugin.ts +140 -0
- package/src/plugins/index.ts +63 -57
- package/src/plugins/inline-plugin.ts +305 -291
- package/src/plugins/math-plugin.ts +12 -0
- package/src/plugins/table-plugin.ts +900 -0
- package/src/preview/context.ts +4 -1
- package/src/preview/css-generator.ts +14 -1
- package/src/preview/index.ts +9 -1
- package/src/preview/preview.ts +2 -1
- package/src/preview/renderer.ts +21 -20
- package/src/preview/syntax-theme.ts +110 -0
- package/src/preview/types.ts +14 -0
- package/dist/chunk-2B3A3VSQ.cjs.map +0 -1
- package/dist/chunk-72ZYRGRT.cjs.map +0 -1
- package/dist/chunk-CG4M4TC7.js.map +0 -1
- package/dist/chunk-DFQYXFOP.js.map +0 -1
- package/dist/chunk-HPSMS2WB.js.map +0 -1
- package/dist/chunk-KBQDZ5IW.cjs.map +0 -1
- package/dist/chunk-KDEDLC3D.cjs.map +0 -1
- package/dist/chunk-N3WL3XPB.js.map +0 -1
package/dist/plugins/index.cjs
CHANGED
|
@@ -1,66 +1,76 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
5
|
-
require('../chunk-
|
|
3
|
+
var chunkW5ALMXG2_cjs = require('../chunk-W5ALMXG2.cjs');
|
|
4
|
+
require('../chunk-BWJLMREN.cjs');
|
|
5
|
+
require('../chunk-3T55CBNZ.cjs');
|
|
6
|
+
require('../chunk-CLW73JRX.cjs');
|
|
7
|
+
require('../chunk-TBVZEK2H.cjs');
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
Object.defineProperty(exports, "CodePlugin", {
|
|
10
12
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkW5ALMXG2_cjs.CodePlugin; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "EmojiPlugin", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkW5ALMXG2_cjs.EmojiPlugin; }
|
|
12
18
|
});
|
|
13
19
|
Object.defineProperty(exports, "HRPlugin", {
|
|
14
20
|
enumerable: true,
|
|
15
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkW5ALMXG2_cjs.HRPlugin; }
|
|
16
22
|
});
|
|
17
23
|
Object.defineProperty(exports, "HTMLPlugin", {
|
|
18
24
|
enumerable: true,
|
|
19
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkW5ALMXG2_cjs.HTMLPlugin; }
|
|
20
26
|
});
|
|
21
27
|
Object.defineProperty(exports, "HeadingPlugin", {
|
|
22
28
|
enumerable: true,
|
|
23
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunkW5ALMXG2_cjs.HeadingPlugin; }
|
|
24
30
|
});
|
|
25
31
|
Object.defineProperty(exports, "ImagePlugin", {
|
|
26
32
|
enumerable: true,
|
|
27
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunkW5ALMXG2_cjs.ImagePlugin; }
|
|
28
34
|
});
|
|
29
35
|
Object.defineProperty(exports, "InlinePlugin", {
|
|
30
36
|
enumerable: true,
|
|
31
|
-
get: function () { return
|
|
37
|
+
get: function () { return chunkW5ALMXG2_cjs.InlinePlugin; }
|
|
32
38
|
});
|
|
33
39
|
Object.defineProperty(exports, "LinkPlugin", {
|
|
34
40
|
enumerable: true,
|
|
35
|
-
get: function () { return
|
|
41
|
+
get: function () { return chunkW5ALMXG2_cjs.LinkPlugin; }
|
|
36
42
|
});
|
|
37
43
|
Object.defineProperty(exports, "ListPlugin", {
|
|
38
44
|
enumerable: true,
|
|
39
|
-
get: function () { return
|
|
45
|
+
get: function () { return chunkW5ALMXG2_cjs.ListPlugin; }
|
|
40
46
|
});
|
|
41
47
|
Object.defineProperty(exports, "MathPlugin", {
|
|
42
48
|
enumerable: true,
|
|
43
|
-
get: function () { return
|
|
49
|
+
get: function () { return chunkW5ALMXG2_cjs.MathPlugin; }
|
|
44
50
|
});
|
|
45
51
|
Object.defineProperty(exports, "MermaidPlugin", {
|
|
46
52
|
enumerable: true,
|
|
47
|
-
get: function () { return
|
|
53
|
+
get: function () { return chunkW5ALMXG2_cjs.MermaidPlugin; }
|
|
48
54
|
});
|
|
49
55
|
Object.defineProperty(exports, "ParagraphPlugin", {
|
|
50
56
|
enumerable: true,
|
|
51
|
-
get: function () { return
|
|
57
|
+
get: function () { return chunkW5ALMXG2_cjs.ParagraphPlugin; }
|
|
52
58
|
});
|
|
53
59
|
Object.defineProperty(exports, "QuotePlugin", {
|
|
54
60
|
enumerable: true,
|
|
55
|
-
get: function () { return
|
|
61
|
+
get: function () { return chunkW5ALMXG2_cjs.QuotePlugin; }
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(exports, "TablePlugin", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
get: function () { return chunkW5ALMXG2_cjs.TablePlugin; }
|
|
56
66
|
});
|
|
57
67
|
Object.defineProperty(exports, "allPlugins", {
|
|
58
68
|
enumerable: true,
|
|
59
|
-
get: function () { return
|
|
69
|
+
get: function () { return chunkW5ALMXG2_cjs.allPlugins; }
|
|
60
70
|
});
|
|
61
71
|
Object.defineProperty(exports, "essentialPlugins", {
|
|
62
72
|
enumerable: true,
|
|
63
|
-
get: function () { return
|
|
73
|
+
get: function () { return chunkW5ALMXG2_cjs.essentialPlugins; }
|
|
64
74
|
});
|
|
65
75
|
//# sourceMappingURL=index.cjs.map
|
|
66
76
|
//# sourceMappingURL=index.cjs.map
|
package/dist/plugins/index.d.cts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { d as DraftlyPlugin, T as ThemeEnum, f as ThemeStyle, a as DecorationPlugin, D as DecorationContext } from '../draftly-
|
|
1
|
+
import { d as DraftlyPlugin, T as ThemeEnum, f as ThemeStyle, a as DecorationPlugin, D as DecorationContext, e as PluginContext } from '../draftly-BBL-AdOl.cjs';
|
|
2
2
|
import { SyntaxNode } from '@lezer/common';
|
|
3
|
+
import { Extension } from '@codemirror/state';
|
|
3
4
|
import { KeyBinding } from '@codemirror/view';
|
|
4
5
|
import { MarkdownConfig } from '@lezer/markdown';
|
|
5
|
-
import '@
|
|
6
|
+
import * as _lezer_highlight from '@lezer/highlight';
|
|
7
|
+
import { Highlighter } from '@lezer/highlight';
|
|
6
8
|
import 'style-mod';
|
|
7
9
|
|
|
8
10
|
/**
|
|
@@ -77,6 +79,15 @@ declare class InlinePlugin extends DecorationPlugin {
|
|
|
77
79
|
* Keyboard shortcuts for inline formatting
|
|
78
80
|
*/
|
|
79
81
|
getKeymap(): KeyBinding[];
|
|
82
|
+
/**
|
|
83
|
+
* Intercepts inline marker typing to wrap selected text.
|
|
84
|
+
*
|
|
85
|
+
* If user types inline markers while text is selected, wraps each selected
|
|
86
|
+
* range with the appropriate marker:
|
|
87
|
+
* - * _ ~ ^ -> marker + selected + marker
|
|
88
|
+
* - = -> ==selected==
|
|
89
|
+
*/
|
|
90
|
+
getExtensions(): Extension[];
|
|
80
91
|
/**
|
|
81
92
|
* Return markdown parser extensions for highlight syntax (==text==)
|
|
82
93
|
*/
|
|
@@ -180,6 +191,65 @@ declare class ListPlugin extends DecorationPlugin {
|
|
|
180
191
|
}): string | null;
|
|
181
192
|
}
|
|
182
193
|
|
|
194
|
+
type PreviewContextLike = {
|
|
195
|
+
sliceDoc(from: number, to: number): string;
|
|
196
|
+
sanitize(html: string): string;
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* TablePlugin — Renders GFM markdown tables as styled widgets.
|
|
200
|
+
*
|
|
201
|
+
* Features:
|
|
202
|
+
* - Rendered table widget with rounded borders, alternate row colors, cell borders
|
|
203
|
+
* - Alignment support (`:---:`, `----:`, `:---`)
|
|
204
|
+
* - Monospace raw markdown when cursor is inside the table
|
|
205
|
+
* - Keyboard shortcuts for table creation, adding rows/columns
|
|
206
|
+
* - Enter in last row/last cell: creates row, again removes it
|
|
207
|
+
* - Auto-formats table markdown to align pipes
|
|
208
|
+
*/
|
|
209
|
+
declare class TablePlugin extends DecorationPlugin {
|
|
210
|
+
readonly name = "table";
|
|
211
|
+
readonly version = "1.0.0";
|
|
212
|
+
decorationPriority: number;
|
|
213
|
+
readonly requiredNodes: readonly ["Table", "TableHeader", "TableDelimiter", "TableRow", "TableCell"];
|
|
214
|
+
/** Configuration stored from onRegister */
|
|
215
|
+
private draftlyConfig;
|
|
216
|
+
onRegister(context: PluginContext): void;
|
|
217
|
+
get theme(): (theme: ThemeEnum) => ThemeStyle;
|
|
218
|
+
getKeymap(): KeyBinding[];
|
|
219
|
+
buildDecorations(ctx: DecorationContext): void;
|
|
220
|
+
/**
|
|
221
|
+
* Insert a new 3×3 table at cursor position
|
|
222
|
+
*/
|
|
223
|
+
private insertTable;
|
|
224
|
+
/**
|
|
225
|
+
* Add a new row below the current row (Mod-Enter)
|
|
226
|
+
*/
|
|
227
|
+
private addRow;
|
|
228
|
+
/**
|
|
229
|
+
* Add a new column after the current column (Mod-Shift-Enter)
|
|
230
|
+
*/
|
|
231
|
+
private addColumn;
|
|
232
|
+
/**
|
|
233
|
+
* Handle Enter key inside a table.
|
|
234
|
+
* - Last cell of last row: create a new row
|
|
235
|
+
* - Empty last row: remove it and move cursor after table
|
|
236
|
+
*/
|
|
237
|
+
private handleEnter;
|
|
238
|
+
/**
|
|
239
|
+
* Handle Tab key inside a table — move to next/previous cell
|
|
240
|
+
*/
|
|
241
|
+
private handleTab;
|
|
242
|
+
/**
|
|
243
|
+
* Find the Table node at the cursor position
|
|
244
|
+
*/
|
|
245
|
+
private getTableAtCursor;
|
|
246
|
+
/**
|
|
247
|
+
* Split a table line into cells (keeping the whitespace around content)
|
|
248
|
+
*/
|
|
249
|
+
private splitLineToCells;
|
|
250
|
+
renderToHTML(node: SyntaxNode, _children: string, _ctx: PreviewContextLike): Promise<string | null>;
|
|
251
|
+
}
|
|
252
|
+
|
|
183
253
|
/**
|
|
184
254
|
* HTMLPlugin - Decorates and Renders HTML in markdown
|
|
185
255
|
*/
|
|
@@ -268,6 +338,13 @@ declare class MathPlugin extends DecorationPlugin {
|
|
|
268
338
|
* Plugin theme
|
|
269
339
|
*/
|
|
270
340
|
get theme(): (theme: ThemeEnum) => ThemeStyle;
|
|
341
|
+
/**
|
|
342
|
+
* Intercepts dollar typing to wrap selected text as inline math.
|
|
343
|
+
*
|
|
344
|
+
* If user types '$' while text is selected, wraps each selected range
|
|
345
|
+
* with single dollars (selected -> $selected$).
|
|
346
|
+
*/
|
|
347
|
+
getExtensions(): Extension[];
|
|
271
348
|
/**
|
|
272
349
|
* Return markdown parser extensions for math syntax
|
|
273
350
|
*/
|
|
@@ -328,6 +405,11 @@ declare class MermaidPlugin extends DecorationPlugin {
|
|
|
328
405
|
}): Promise<string | null>;
|
|
329
406
|
}
|
|
330
407
|
|
|
408
|
+
interface PreviewRenderContext {
|
|
409
|
+
sliceDoc(from: number, to: number): string;
|
|
410
|
+
sanitize(html: string): string;
|
|
411
|
+
syntaxHighlighters?: readonly Highlighter[];
|
|
412
|
+
}
|
|
331
413
|
/**
|
|
332
414
|
* Text highlight definition
|
|
333
415
|
* Matches text or regex patterns with optional instance selection
|
|
@@ -347,13 +429,15 @@ interface CodeBlockProperties {
|
|
|
347
429
|
/** Language identifier (first token) */
|
|
348
430
|
language: string;
|
|
349
431
|
/** Show line numbers, optionally starting from a specific number */
|
|
350
|
-
|
|
432
|
+
showLineNumbers?: number | boolean;
|
|
351
433
|
/** Title to display */
|
|
352
434
|
title?: string;
|
|
353
435
|
/** Caption to display */
|
|
354
436
|
caption?: string;
|
|
355
437
|
/** Show copy button */
|
|
356
438
|
copy?: boolean;
|
|
439
|
+
/** Enable diff preview mode */
|
|
440
|
+
diff?: boolean;
|
|
357
441
|
/** Lines to highlight (e.g., [2,3,4,5,9]) */
|
|
358
442
|
highlightLines?: number[];
|
|
359
443
|
/** Text patterns to highlight with optional instance selection */
|
|
@@ -379,6 +463,7 @@ declare class CodePlugin extends DecorationPlugin {
|
|
|
379
463
|
readonly version = "1.0.0";
|
|
380
464
|
decorationPriority: number;
|
|
381
465
|
readonly requiredNodes: readonly ["InlineCode", "FencedCode", "CodeMark", "CodeInfo", "CodeText"];
|
|
466
|
+
private readonly parserCache;
|
|
382
467
|
/**
|
|
383
468
|
* Plugin theme
|
|
384
469
|
*/
|
|
@@ -387,6 +472,13 @@ declare class CodePlugin extends DecorationPlugin {
|
|
|
387
472
|
* Keyboard shortcuts for code formatting
|
|
388
473
|
*/
|
|
389
474
|
getKeymap(): KeyBinding[];
|
|
475
|
+
/**
|
|
476
|
+
* Intercepts backtick typing to wrap selected text as inline code.
|
|
477
|
+
*
|
|
478
|
+
* If user types '`' while text is selected, wraps each selected range
|
|
479
|
+
* with backticks (selected -> `selected`).
|
|
480
|
+
*/
|
|
481
|
+
getExtensions(): Extension[];
|
|
390
482
|
/**
|
|
391
483
|
* Toggle code block on current line or selected lines
|
|
392
484
|
*/
|
|
@@ -409,6 +501,7 @@ declare class CodePlugin extends DecorationPlugin {
|
|
|
409
501
|
* lineNumbers: 5,
|
|
410
502
|
* title: "hello.tsx",
|
|
411
503
|
* copy: true,
|
|
504
|
+
* diff: false,
|
|
412
505
|
* highlightLines: [2,3,4,5],
|
|
413
506
|
* highlightText: [{ pattern: "Hello", instances: [3,4,5] }]
|
|
414
507
|
* }
|
|
@@ -420,19 +513,33 @@ declare class CodePlugin extends DecorationPlugin {
|
|
|
420
513
|
* Handles line numbers, highlights, header/caption widgets, and fence visibility.
|
|
421
514
|
*/
|
|
422
515
|
buildDecorations(ctx: DecorationContext): void;
|
|
516
|
+
private decorateInlineCode;
|
|
517
|
+
private decorateFencedCode;
|
|
518
|
+
private decorateFenceMarkers;
|
|
519
|
+
private decorateDiffLine;
|
|
520
|
+
private decorateTextHighlights;
|
|
423
521
|
/**
|
|
424
522
|
* Render code elements to HTML for static preview.
|
|
425
523
|
* Applies syntax highlighting using @lezer/highlight.
|
|
426
524
|
*/
|
|
427
|
-
renderToHTML(node: SyntaxNode,
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
}): string | null;
|
|
525
|
+
renderToHTML(node: SyntaxNode, _children: string, ctx: PreviewRenderContext): Promise<string | null>;
|
|
526
|
+
/** Parse comma-separated numbers and ranges (e.g. "1,3-5") into [1,3,4,5]. */
|
|
527
|
+
private parseNumberList;
|
|
431
528
|
/**
|
|
432
529
|
* Highlight a single line of code using the language's Lezer parser.
|
|
433
530
|
* Falls back to sanitized plain text if the language is not supported.
|
|
434
531
|
*/
|
|
435
|
-
private
|
|
532
|
+
private highlightCodeLines;
|
|
533
|
+
private resolveLanguageParser;
|
|
534
|
+
private normalizeLanguage;
|
|
535
|
+
private escapeHtml;
|
|
536
|
+
private escapeAttribute;
|
|
537
|
+
private analyzeDiffLines;
|
|
538
|
+
private computeDiffDisplayLineNumbers;
|
|
539
|
+
private parseDiffLineState;
|
|
540
|
+
private computeChangedRanges;
|
|
541
|
+
private renderDiffPreviewLine;
|
|
542
|
+
private applyRangesToHighlightedHTML;
|
|
436
543
|
/**
|
|
437
544
|
* Apply text highlights (regex patterns) to already syntax-highlighted HTML.
|
|
438
545
|
* Wraps matched patterns in `<mark>` elements.
|
|
@@ -499,6 +606,34 @@ declare class HRPlugin extends DecorationPlugin {
|
|
|
499
606
|
renderToHTML(node: SyntaxNode, _children: string): string | null;
|
|
500
607
|
}
|
|
501
608
|
|
|
609
|
+
/**
|
|
610
|
+
* EmojiPlugin - Decorates markdown emojis
|
|
611
|
+
*
|
|
612
|
+
* Parses and decorates emoji shortcodes like :smile:
|
|
613
|
+
* - Converts valid shortcodes to Unicode emoji when cursor is outside
|
|
614
|
+
* - Keeps raw shortcode visible while editing (cursor inside token)
|
|
615
|
+
*/
|
|
616
|
+
declare class EmojiPlugin extends DecorationPlugin {
|
|
617
|
+
readonly name = "emoji";
|
|
618
|
+
readonly version = "1.0.0";
|
|
619
|
+
decorationPriority: number;
|
|
620
|
+
readonly requiredNodes: readonly ["Emoji", "EmojiMark"];
|
|
621
|
+
constructor();
|
|
622
|
+
/**
|
|
623
|
+
* Plugin theme
|
|
624
|
+
*/
|
|
625
|
+
get theme(): (theme: ThemeEnum) => ThemeStyle;
|
|
626
|
+
/**
|
|
627
|
+
* Build emoji decorations by iterating the syntax tree
|
|
628
|
+
*/
|
|
629
|
+
buildDecorations(ctx: DecorationContext): void;
|
|
630
|
+
renderToHTML(node: SyntaxNode, children: string, ctx: {
|
|
631
|
+
sliceDoc(from: number, to: number): string;
|
|
632
|
+
sanitize(html: string): string;
|
|
633
|
+
syntaxHighlighters?: readonly _lezer_highlight.Highlighter[];
|
|
634
|
+
}): string | null;
|
|
635
|
+
}
|
|
636
|
+
|
|
502
637
|
/**
|
|
503
638
|
* Default plugins
|
|
504
639
|
*
|
|
@@ -512,4 +647,4 @@ declare const essentialPlugins: DraftlyPlugin[];
|
|
|
512
647
|
*/
|
|
513
648
|
declare const allPlugins: DraftlyPlugin[];
|
|
514
649
|
|
|
515
|
-
export { CodePlugin, HRPlugin, HTMLPlugin, HeadingPlugin, ImagePlugin, InlinePlugin, LinkPlugin, ListPlugin, MathPlugin, MermaidPlugin, ParagraphPlugin, QuotePlugin, allPlugins, essentialPlugins };
|
|
650
|
+
export { CodePlugin, EmojiPlugin, HRPlugin, HTMLPlugin, HeadingPlugin, ImagePlugin, InlinePlugin, LinkPlugin, ListPlugin, MathPlugin, MermaidPlugin, ParagraphPlugin, QuotePlugin, TablePlugin, allPlugins, essentialPlugins };
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { d as DraftlyPlugin, T as ThemeEnum, f as ThemeStyle, a as DecorationPlugin, D as DecorationContext } from '../draftly-
|
|
1
|
+
import { d as DraftlyPlugin, T as ThemeEnum, f as ThemeStyle, a as DecorationPlugin, D as DecorationContext, e as PluginContext } from '../draftly-BBL-AdOl.js';
|
|
2
2
|
import { SyntaxNode } from '@lezer/common';
|
|
3
|
+
import { Extension } from '@codemirror/state';
|
|
3
4
|
import { KeyBinding } from '@codemirror/view';
|
|
4
5
|
import { MarkdownConfig } from '@lezer/markdown';
|
|
5
|
-
import '@
|
|
6
|
+
import * as _lezer_highlight from '@lezer/highlight';
|
|
7
|
+
import { Highlighter } from '@lezer/highlight';
|
|
6
8
|
import 'style-mod';
|
|
7
9
|
|
|
8
10
|
/**
|
|
@@ -77,6 +79,15 @@ declare class InlinePlugin extends DecorationPlugin {
|
|
|
77
79
|
* Keyboard shortcuts for inline formatting
|
|
78
80
|
*/
|
|
79
81
|
getKeymap(): KeyBinding[];
|
|
82
|
+
/**
|
|
83
|
+
* Intercepts inline marker typing to wrap selected text.
|
|
84
|
+
*
|
|
85
|
+
* If user types inline markers while text is selected, wraps each selected
|
|
86
|
+
* range with the appropriate marker:
|
|
87
|
+
* - * _ ~ ^ -> marker + selected + marker
|
|
88
|
+
* - = -> ==selected==
|
|
89
|
+
*/
|
|
90
|
+
getExtensions(): Extension[];
|
|
80
91
|
/**
|
|
81
92
|
* Return markdown parser extensions for highlight syntax (==text==)
|
|
82
93
|
*/
|
|
@@ -180,6 +191,65 @@ declare class ListPlugin extends DecorationPlugin {
|
|
|
180
191
|
}): string | null;
|
|
181
192
|
}
|
|
182
193
|
|
|
194
|
+
type PreviewContextLike = {
|
|
195
|
+
sliceDoc(from: number, to: number): string;
|
|
196
|
+
sanitize(html: string): string;
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* TablePlugin — Renders GFM markdown tables as styled widgets.
|
|
200
|
+
*
|
|
201
|
+
* Features:
|
|
202
|
+
* - Rendered table widget with rounded borders, alternate row colors, cell borders
|
|
203
|
+
* - Alignment support (`:---:`, `----:`, `:---`)
|
|
204
|
+
* - Monospace raw markdown when cursor is inside the table
|
|
205
|
+
* - Keyboard shortcuts for table creation, adding rows/columns
|
|
206
|
+
* - Enter in last row/last cell: creates row, again removes it
|
|
207
|
+
* - Auto-formats table markdown to align pipes
|
|
208
|
+
*/
|
|
209
|
+
declare class TablePlugin extends DecorationPlugin {
|
|
210
|
+
readonly name = "table";
|
|
211
|
+
readonly version = "1.0.0";
|
|
212
|
+
decorationPriority: number;
|
|
213
|
+
readonly requiredNodes: readonly ["Table", "TableHeader", "TableDelimiter", "TableRow", "TableCell"];
|
|
214
|
+
/** Configuration stored from onRegister */
|
|
215
|
+
private draftlyConfig;
|
|
216
|
+
onRegister(context: PluginContext): void;
|
|
217
|
+
get theme(): (theme: ThemeEnum) => ThemeStyle;
|
|
218
|
+
getKeymap(): KeyBinding[];
|
|
219
|
+
buildDecorations(ctx: DecorationContext): void;
|
|
220
|
+
/**
|
|
221
|
+
* Insert a new 3×3 table at cursor position
|
|
222
|
+
*/
|
|
223
|
+
private insertTable;
|
|
224
|
+
/**
|
|
225
|
+
* Add a new row below the current row (Mod-Enter)
|
|
226
|
+
*/
|
|
227
|
+
private addRow;
|
|
228
|
+
/**
|
|
229
|
+
* Add a new column after the current column (Mod-Shift-Enter)
|
|
230
|
+
*/
|
|
231
|
+
private addColumn;
|
|
232
|
+
/**
|
|
233
|
+
* Handle Enter key inside a table.
|
|
234
|
+
* - Last cell of last row: create a new row
|
|
235
|
+
* - Empty last row: remove it and move cursor after table
|
|
236
|
+
*/
|
|
237
|
+
private handleEnter;
|
|
238
|
+
/**
|
|
239
|
+
* Handle Tab key inside a table — move to next/previous cell
|
|
240
|
+
*/
|
|
241
|
+
private handleTab;
|
|
242
|
+
/**
|
|
243
|
+
* Find the Table node at the cursor position
|
|
244
|
+
*/
|
|
245
|
+
private getTableAtCursor;
|
|
246
|
+
/**
|
|
247
|
+
* Split a table line into cells (keeping the whitespace around content)
|
|
248
|
+
*/
|
|
249
|
+
private splitLineToCells;
|
|
250
|
+
renderToHTML(node: SyntaxNode, _children: string, _ctx: PreviewContextLike): Promise<string | null>;
|
|
251
|
+
}
|
|
252
|
+
|
|
183
253
|
/**
|
|
184
254
|
* HTMLPlugin - Decorates and Renders HTML in markdown
|
|
185
255
|
*/
|
|
@@ -268,6 +338,13 @@ declare class MathPlugin extends DecorationPlugin {
|
|
|
268
338
|
* Plugin theme
|
|
269
339
|
*/
|
|
270
340
|
get theme(): (theme: ThemeEnum) => ThemeStyle;
|
|
341
|
+
/**
|
|
342
|
+
* Intercepts dollar typing to wrap selected text as inline math.
|
|
343
|
+
*
|
|
344
|
+
* If user types '$' while text is selected, wraps each selected range
|
|
345
|
+
* with single dollars (selected -> $selected$).
|
|
346
|
+
*/
|
|
347
|
+
getExtensions(): Extension[];
|
|
271
348
|
/**
|
|
272
349
|
* Return markdown parser extensions for math syntax
|
|
273
350
|
*/
|
|
@@ -328,6 +405,11 @@ declare class MermaidPlugin extends DecorationPlugin {
|
|
|
328
405
|
}): Promise<string | null>;
|
|
329
406
|
}
|
|
330
407
|
|
|
408
|
+
interface PreviewRenderContext {
|
|
409
|
+
sliceDoc(from: number, to: number): string;
|
|
410
|
+
sanitize(html: string): string;
|
|
411
|
+
syntaxHighlighters?: readonly Highlighter[];
|
|
412
|
+
}
|
|
331
413
|
/**
|
|
332
414
|
* Text highlight definition
|
|
333
415
|
* Matches text or regex patterns with optional instance selection
|
|
@@ -347,13 +429,15 @@ interface CodeBlockProperties {
|
|
|
347
429
|
/** Language identifier (first token) */
|
|
348
430
|
language: string;
|
|
349
431
|
/** Show line numbers, optionally starting from a specific number */
|
|
350
|
-
|
|
432
|
+
showLineNumbers?: number | boolean;
|
|
351
433
|
/** Title to display */
|
|
352
434
|
title?: string;
|
|
353
435
|
/** Caption to display */
|
|
354
436
|
caption?: string;
|
|
355
437
|
/** Show copy button */
|
|
356
438
|
copy?: boolean;
|
|
439
|
+
/** Enable diff preview mode */
|
|
440
|
+
diff?: boolean;
|
|
357
441
|
/** Lines to highlight (e.g., [2,3,4,5,9]) */
|
|
358
442
|
highlightLines?: number[];
|
|
359
443
|
/** Text patterns to highlight with optional instance selection */
|
|
@@ -379,6 +463,7 @@ declare class CodePlugin extends DecorationPlugin {
|
|
|
379
463
|
readonly version = "1.0.0";
|
|
380
464
|
decorationPriority: number;
|
|
381
465
|
readonly requiredNodes: readonly ["InlineCode", "FencedCode", "CodeMark", "CodeInfo", "CodeText"];
|
|
466
|
+
private readonly parserCache;
|
|
382
467
|
/**
|
|
383
468
|
* Plugin theme
|
|
384
469
|
*/
|
|
@@ -387,6 +472,13 @@ declare class CodePlugin extends DecorationPlugin {
|
|
|
387
472
|
* Keyboard shortcuts for code formatting
|
|
388
473
|
*/
|
|
389
474
|
getKeymap(): KeyBinding[];
|
|
475
|
+
/**
|
|
476
|
+
* Intercepts backtick typing to wrap selected text as inline code.
|
|
477
|
+
*
|
|
478
|
+
* If user types '`' while text is selected, wraps each selected range
|
|
479
|
+
* with backticks (selected -> `selected`).
|
|
480
|
+
*/
|
|
481
|
+
getExtensions(): Extension[];
|
|
390
482
|
/**
|
|
391
483
|
* Toggle code block on current line or selected lines
|
|
392
484
|
*/
|
|
@@ -409,6 +501,7 @@ declare class CodePlugin extends DecorationPlugin {
|
|
|
409
501
|
* lineNumbers: 5,
|
|
410
502
|
* title: "hello.tsx",
|
|
411
503
|
* copy: true,
|
|
504
|
+
* diff: false,
|
|
412
505
|
* highlightLines: [2,3,4,5],
|
|
413
506
|
* highlightText: [{ pattern: "Hello", instances: [3,4,5] }]
|
|
414
507
|
* }
|
|
@@ -420,19 +513,33 @@ declare class CodePlugin extends DecorationPlugin {
|
|
|
420
513
|
* Handles line numbers, highlights, header/caption widgets, and fence visibility.
|
|
421
514
|
*/
|
|
422
515
|
buildDecorations(ctx: DecorationContext): void;
|
|
516
|
+
private decorateInlineCode;
|
|
517
|
+
private decorateFencedCode;
|
|
518
|
+
private decorateFenceMarkers;
|
|
519
|
+
private decorateDiffLine;
|
|
520
|
+
private decorateTextHighlights;
|
|
423
521
|
/**
|
|
424
522
|
* Render code elements to HTML for static preview.
|
|
425
523
|
* Applies syntax highlighting using @lezer/highlight.
|
|
426
524
|
*/
|
|
427
|
-
renderToHTML(node: SyntaxNode,
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
}): string | null;
|
|
525
|
+
renderToHTML(node: SyntaxNode, _children: string, ctx: PreviewRenderContext): Promise<string | null>;
|
|
526
|
+
/** Parse comma-separated numbers and ranges (e.g. "1,3-5") into [1,3,4,5]. */
|
|
527
|
+
private parseNumberList;
|
|
431
528
|
/**
|
|
432
529
|
* Highlight a single line of code using the language's Lezer parser.
|
|
433
530
|
* Falls back to sanitized plain text if the language is not supported.
|
|
434
531
|
*/
|
|
435
|
-
private
|
|
532
|
+
private highlightCodeLines;
|
|
533
|
+
private resolveLanguageParser;
|
|
534
|
+
private normalizeLanguage;
|
|
535
|
+
private escapeHtml;
|
|
536
|
+
private escapeAttribute;
|
|
537
|
+
private analyzeDiffLines;
|
|
538
|
+
private computeDiffDisplayLineNumbers;
|
|
539
|
+
private parseDiffLineState;
|
|
540
|
+
private computeChangedRanges;
|
|
541
|
+
private renderDiffPreviewLine;
|
|
542
|
+
private applyRangesToHighlightedHTML;
|
|
436
543
|
/**
|
|
437
544
|
* Apply text highlights (regex patterns) to already syntax-highlighted HTML.
|
|
438
545
|
* Wraps matched patterns in `<mark>` elements.
|
|
@@ -499,6 +606,34 @@ declare class HRPlugin extends DecorationPlugin {
|
|
|
499
606
|
renderToHTML(node: SyntaxNode, _children: string): string | null;
|
|
500
607
|
}
|
|
501
608
|
|
|
609
|
+
/**
|
|
610
|
+
* EmojiPlugin - Decorates markdown emojis
|
|
611
|
+
*
|
|
612
|
+
* Parses and decorates emoji shortcodes like :smile:
|
|
613
|
+
* - Converts valid shortcodes to Unicode emoji when cursor is outside
|
|
614
|
+
* - Keeps raw shortcode visible while editing (cursor inside token)
|
|
615
|
+
*/
|
|
616
|
+
declare class EmojiPlugin extends DecorationPlugin {
|
|
617
|
+
readonly name = "emoji";
|
|
618
|
+
readonly version = "1.0.0";
|
|
619
|
+
decorationPriority: number;
|
|
620
|
+
readonly requiredNodes: readonly ["Emoji", "EmojiMark"];
|
|
621
|
+
constructor();
|
|
622
|
+
/**
|
|
623
|
+
* Plugin theme
|
|
624
|
+
*/
|
|
625
|
+
get theme(): (theme: ThemeEnum) => ThemeStyle;
|
|
626
|
+
/**
|
|
627
|
+
* Build emoji decorations by iterating the syntax tree
|
|
628
|
+
*/
|
|
629
|
+
buildDecorations(ctx: DecorationContext): void;
|
|
630
|
+
renderToHTML(node: SyntaxNode, children: string, ctx: {
|
|
631
|
+
sliceDoc(from: number, to: number): string;
|
|
632
|
+
sanitize(html: string): string;
|
|
633
|
+
syntaxHighlighters?: readonly _lezer_highlight.Highlighter[];
|
|
634
|
+
}): string | null;
|
|
635
|
+
}
|
|
636
|
+
|
|
502
637
|
/**
|
|
503
638
|
* Default plugins
|
|
504
639
|
*
|
|
@@ -512,4 +647,4 @@ declare const essentialPlugins: DraftlyPlugin[];
|
|
|
512
647
|
*/
|
|
513
648
|
declare const allPlugins: DraftlyPlugin[];
|
|
514
649
|
|
|
515
|
-
export { CodePlugin, HRPlugin, HTMLPlugin, HeadingPlugin, ImagePlugin, InlinePlugin, LinkPlugin, ListPlugin, MathPlugin, MermaidPlugin, ParagraphPlugin, QuotePlugin, allPlugins, essentialPlugins };
|
|
650
|
+
export { CodePlugin, EmojiPlugin, HRPlugin, HTMLPlugin, HeadingPlugin, ImagePlugin, InlinePlugin, LinkPlugin, ListPlugin, MathPlugin, MermaidPlugin, ParagraphPlugin, QuotePlugin, TablePlugin, allPlugins, essentialPlugins };
|
package/dist/plugins/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export { CodePlugin, HRPlugin, HTMLPlugin, HeadingPlugin, ImagePlugin, InlinePlugin, LinkPlugin, ListPlugin, MathPlugin, MermaidPlugin, ParagraphPlugin, QuotePlugin, allPlugins, essentialPlugins } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
export { CodePlugin, EmojiPlugin, HRPlugin, HTMLPlugin, HeadingPlugin, ImagePlugin, InlinePlugin, LinkPlugin, ListPlugin, MathPlugin, MermaidPlugin, ParagraphPlugin, QuotePlugin, TablePlugin, allPlugins, essentialPlugins } from '../chunk-L2XSK57Y.js';
|
|
2
|
+
import '../chunk-ZUI3GI3W.js';
|
|
3
|
+
import '../chunk-JF3WXXMJ.js';
|
|
4
|
+
import '../chunk-I563H35S.js';
|
|
5
|
+
import '../chunk-EEHILRG5.js';
|
|
4
6
|
//# sourceMappingURL=index.js.map
|
|
5
7
|
//# sourceMappingURL=index.js.map
|
package/dist/preview/index.cjs
CHANGED
|
@@ -1,29 +1,34 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var chunk5MC4T7JH_cjs = require('../chunk-5MC4T7JH.cjs');
|
|
4
|
+
var chunkCLW73JRX_cjs = require('../chunk-CLW73JRX.cjs');
|
|
5
|
+
require('../chunk-TBVZEK2H.cjs');
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
|
|
9
|
+
Object.defineProperty(exports, "generateCSS", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return chunk5MC4T7JH_cjs.generateCSS; }
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "preview", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return chunk5MC4T7JH_cjs.preview; }
|
|
16
|
+
});
|
|
8
17
|
Object.defineProperty(exports, "PreviewRenderer", {
|
|
9
18
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
19
|
+
get: function () { return chunkCLW73JRX_cjs.PreviewRenderer; }
|
|
11
20
|
});
|
|
12
21
|
Object.defineProperty(exports, "defaultRenderers", {
|
|
13
22
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
23
|
+
get: function () { return chunkCLW73JRX_cjs.defaultRenderers; }
|
|
15
24
|
});
|
|
16
25
|
Object.defineProperty(exports, "escapeHtml", {
|
|
17
26
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
27
|
+
get: function () { return chunkCLW73JRX_cjs.escapeHtml; }
|
|
19
28
|
});
|
|
20
|
-
Object.defineProperty(exports, "
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function () { return chunkKBQDZ5IW_cjs.generateCSS; }
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "preview", {
|
|
29
|
+
Object.defineProperty(exports, "generateSyntaxThemeCSS", {
|
|
25
30
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
31
|
+
get: function () { return chunkCLW73JRX_cjs.generateSyntaxThemeCSS; }
|
|
27
32
|
});
|
|
28
33
|
//# sourceMappingURL=index.cjs.map
|
|
29
34
|
//# sourceMappingURL=index.cjs.map
|