draftly 1.0.7 → 2.1.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-KBQDZ5IW.cjs → chunk-CLW73JRX.cjs} +100 -75
- package/dist/chunk-CLW73JRX.cjs.map +1 -0
- package/dist/{chunk-72ZYRGRT.cjs → chunk-EQUQHE2E.cjs} +30 -26
- package/dist/chunk-EQUQHE2E.cjs.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-NRPI5O6Y.js} +2603 -604
- package/dist/chunk-NRPI5O6Y.js.map +1 -0
- package/dist/{chunk-2B3A3VSQ.cjs → chunk-OMFUE4AQ.cjs} +2642 -622
- package/dist/chunk-OMFUE4AQ.cjs.map +1 -0
- package/dist/{chunk-DFQYXFOP.js → chunk-TD3L5C45.js} +28 -3
- package/dist/chunk-TD3L5C45.js.map +1 -0
- package/dist/{chunk-CG4M4TC7.js → chunk-UCHBDJ4R.js} +26 -22
- package/dist/chunk-UCHBDJ4R.js.map +1 -0
- package/dist/{chunk-KDEDLC3D.cjs → chunk-W75QUUQC.cjs} +29 -2
- package/dist/chunk-W75QUUQC.cjs.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 +180 -10
- package/dist/plugins/index.d.ts +180 -10
- 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 +30 -27
- package/src/editor/plugin.ts +5 -1
- package/src/editor/theme.ts +1 -0
- package/src/editor/utils.ts +33 -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 +1759 -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.d.cts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
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 {
|
|
3
|
+
import { Extension } from '@codemirror/state';
|
|
4
|
+
import * as _codemirror_view from '@codemirror/view';
|
|
5
|
+
import { KeyBinding, EditorView } from '@codemirror/view';
|
|
4
6
|
import { MarkdownConfig } from '@lezer/markdown';
|
|
5
|
-
import '@
|
|
7
|
+
import * as _lezer_highlight from '@lezer/highlight';
|
|
8
|
+
import { Highlighter } from '@lezer/highlight';
|
|
6
9
|
import 'style-mod';
|
|
7
10
|
|
|
8
11
|
/**
|
|
@@ -77,6 +80,15 @@ declare class InlinePlugin extends DecorationPlugin {
|
|
|
77
80
|
* Keyboard shortcuts for inline formatting
|
|
78
81
|
*/
|
|
79
82
|
getKeymap(): KeyBinding[];
|
|
83
|
+
/**
|
|
84
|
+
* Intercepts inline marker typing to wrap selected text.
|
|
85
|
+
*
|
|
86
|
+
* If user types inline markers while text is selected, wraps each selected
|
|
87
|
+
* range with the appropriate marker:
|
|
88
|
+
* - * _ ~ ^ -> marker + selected + marker
|
|
89
|
+
* - = -> ==selected==
|
|
90
|
+
*/
|
|
91
|
+
getExtensions(): Extension[];
|
|
80
92
|
/**
|
|
81
93
|
* Return markdown parser extensions for highlight syntax (==text==)
|
|
82
94
|
*/
|
|
@@ -180,6 +192,99 @@ declare class ListPlugin extends DecorationPlugin {
|
|
|
180
192
|
}): string | null;
|
|
181
193
|
}
|
|
182
194
|
|
|
195
|
+
interface PreviewContextLike {
|
|
196
|
+
sliceDoc(from: number, to: number): string;
|
|
197
|
+
sanitize(html: string): string;
|
|
198
|
+
}
|
|
199
|
+
declare class TablePlugin extends DecorationPlugin {
|
|
200
|
+
readonly name = "table";
|
|
201
|
+
readonly version = "2.0.0";
|
|
202
|
+
decorationPriority: number;
|
|
203
|
+
readonly requiredNodes: readonly ["Table", "TableHeader", "TableDelimiter", "TableRow", "TableCell"];
|
|
204
|
+
private draftlyConfig;
|
|
205
|
+
private pendingNormalizationView;
|
|
206
|
+
private pendingPaddingView;
|
|
207
|
+
private pendingSelectionRepairView;
|
|
208
|
+
/** Stores the editor config for preview rendering and shared behavior. */
|
|
209
|
+
onRegister(context: PluginContext): void;
|
|
210
|
+
/** Exposes the plugin theme used for editor and preview styling. */
|
|
211
|
+
get theme(): (theme: ThemeEnum) => ThemeStyle;
|
|
212
|
+
/** Enables GFM table parsing for the editor and preview renderer. */
|
|
213
|
+
getMarkdownConfig(): MarkdownConfig;
|
|
214
|
+
/** Registers block wrappers and atomic ranges for the table UI. */
|
|
215
|
+
getExtensions(): Extension[];
|
|
216
|
+
/** Provides the table-specific keyboard shortcuts and navigation. */
|
|
217
|
+
getKeymap(): KeyBinding[];
|
|
218
|
+
/** Builds the high-priority key bindings used inside tables. */
|
|
219
|
+
private buildTableKeymap;
|
|
220
|
+
/** Schedules an initial normalization pass once the view is ready. */
|
|
221
|
+
onViewReady(view: EditorView): void;
|
|
222
|
+
/** Re-schedules normalization after user-driven document changes. */
|
|
223
|
+
onViewUpdate(update: _codemirror_view.ViewUpdate): void;
|
|
224
|
+
/** Intercepts table-specific DOM key handling before browser defaults run. */
|
|
225
|
+
private handleDomKeydown;
|
|
226
|
+
/** Builds the visual table decorations for every parsed table block. */
|
|
227
|
+
buildDecorations(ctx: DecorationContext): void;
|
|
228
|
+
/** Renders the full table node to semantic preview HTML. */
|
|
229
|
+
renderToHTML(node: SyntaxNode, _children: string, ctx: PreviewContextLike): Promise<string | null>;
|
|
230
|
+
/** Computes the block wrapper ranges used to group table lines. */
|
|
231
|
+
private computeBlockWrappers;
|
|
232
|
+
/** Computes atomic ranges for delimiters and inline break tags. */
|
|
233
|
+
private computeAtomicRanges;
|
|
234
|
+
/** Applies row, cell, and control decorations for a single table. */
|
|
235
|
+
private decorateTable;
|
|
236
|
+
/** Applies the visual cell decorations for a single table row line. */
|
|
237
|
+
private decorateLine;
|
|
238
|
+
/** Normalizes every parsed table block back into canonical markdown. */
|
|
239
|
+
private normalizeTables;
|
|
240
|
+
/** Defers table normalization until the current update cycle is finished. */
|
|
241
|
+
private scheduleNormalization;
|
|
242
|
+
/** Adds missing spacer lines above and below tables after edits. */
|
|
243
|
+
private ensureTablePadding;
|
|
244
|
+
/** Schedules a padding-only pass after the current update cycle finishes. */
|
|
245
|
+
private schedulePadding;
|
|
246
|
+
/** Repairs carets that land in hidden table markup instead of editable cell content. */
|
|
247
|
+
private ensureTableSelection;
|
|
248
|
+
/** Schedules table selection repair after the current update finishes. */
|
|
249
|
+
private scheduleSelectionRepair;
|
|
250
|
+
/** Rewrites a table block and restores the caret to a target cell position. */
|
|
251
|
+
private replaceTable;
|
|
252
|
+
/** Inserts an empty body row below the given logical row index. */
|
|
253
|
+
private insertRowBelow;
|
|
254
|
+
/** Inserts a starter table near the current cursor line. */
|
|
255
|
+
private insertTable;
|
|
256
|
+
/** Adds a new empty body row to the active table. */
|
|
257
|
+
private addRow;
|
|
258
|
+
/** Appends a row and keeps the caret in the requested column. */
|
|
259
|
+
private appendRow;
|
|
260
|
+
/** Inserts a new column after the current column. */
|
|
261
|
+
private addColumn;
|
|
262
|
+
/** Appends a new column at the far right of the table. */
|
|
263
|
+
private appendColumn;
|
|
264
|
+
/** Removes the current body row or clears the last remaining row. */
|
|
265
|
+
private removeRow;
|
|
266
|
+
/** Removes the current column when the table has more than one column. */
|
|
267
|
+
private removeColumn;
|
|
268
|
+
/** Moves to the next or previous logical cell with Tab navigation. */
|
|
269
|
+
private handleTab;
|
|
270
|
+
/** Moves horizontally between adjacent cells when the caret hits an edge. */
|
|
271
|
+
private handleArrowHorizontal;
|
|
272
|
+
/** Moves vertically between rows while keeping the current column. */
|
|
273
|
+
private handleArrowVertical;
|
|
274
|
+
/** Advances downward on Enter and manages the trailing empty row behavior. */
|
|
275
|
+
private handleEnter;
|
|
276
|
+
/** Inserts a canonical `<br />` token inside the current table cell. */
|
|
277
|
+
private insertBreakTag;
|
|
278
|
+
/** Deletes a whole `<br />` token when backspace or delete hits it. */
|
|
279
|
+
private handleBreakDeletion;
|
|
280
|
+
/** Moves the current selection anchor into a target cell. */
|
|
281
|
+
private moveSelectionToCell;
|
|
282
|
+
/** Returns the table currently containing the editor cursor. */
|
|
283
|
+
private getTableAtCursor;
|
|
284
|
+
/** Returns the active cell under the current selection head. */
|
|
285
|
+
private getCurrentCell;
|
|
286
|
+
}
|
|
287
|
+
|
|
183
288
|
/**
|
|
184
289
|
* HTMLPlugin - Decorates and Renders HTML in markdown
|
|
185
290
|
*/
|
|
@@ -268,6 +373,13 @@ declare class MathPlugin extends DecorationPlugin {
|
|
|
268
373
|
* Plugin theme
|
|
269
374
|
*/
|
|
270
375
|
get theme(): (theme: ThemeEnum) => ThemeStyle;
|
|
376
|
+
/**
|
|
377
|
+
* Intercepts dollar typing to wrap selected text as inline math.
|
|
378
|
+
*
|
|
379
|
+
* If user types '$' while text is selected, wraps each selected range
|
|
380
|
+
* with single dollars (selected -> $selected$).
|
|
381
|
+
*/
|
|
382
|
+
getExtensions(): Extension[];
|
|
271
383
|
/**
|
|
272
384
|
* Return markdown parser extensions for math syntax
|
|
273
385
|
*/
|
|
@@ -328,6 +440,11 @@ declare class MermaidPlugin extends DecorationPlugin {
|
|
|
328
440
|
}): Promise<string | null>;
|
|
329
441
|
}
|
|
330
442
|
|
|
443
|
+
interface PreviewRenderContext {
|
|
444
|
+
sliceDoc(from: number, to: number): string;
|
|
445
|
+
sanitize(html: string): string;
|
|
446
|
+
syntaxHighlighters?: readonly Highlighter[];
|
|
447
|
+
}
|
|
331
448
|
/**
|
|
332
449
|
* Text highlight definition
|
|
333
450
|
* Matches text or regex patterns with optional instance selection
|
|
@@ -347,13 +464,15 @@ interface CodeBlockProperties {
|
|
|
347
464
|
/** Language identifier (first token) */
|
|
348
465
|
language: string;
|
|
349
466
|
/** Show line numbers, optionally starting from a specific number */
|
|
350
|
-
|
|
467
|
+
showLineNumbers?: number | boolean;
|
|
351
468
|
/** Title to display */
|
|
352
469
|
title?: string;
|
|
353
470
|
/** Caption to display */
|
|
354
471
|
caption?: string;
|
|
355
472
|
/** Show copy button */
|
|
356
473
|
copy?: boolean;
|
|
474
|
+
/** Enable diff preview mode */
|
|
475
|
+
diff?: boolean;
|
|
357
476
|
/** Lines to highlight (e.g., [2,3,4,5,9]) */
|
|
358
477
|
highlightLines?: number[];
|
|
359
478
|
/** Text patterns to highlight with optional instance selection */
|
|
@@ -379,6 +498,7 @@ declare class CodePlugin extends DecorationPlugin {
|
|
|
379
498
|
readonly version = "1.0.0";
|
|
380
499
|
decorationPriority: number;
|
|
381
500
|
readonly requiredNodes: readonly ["InlineCode", "FencedCode", "CodeMark", "CodeInfo", "CodeText"];
|
|
501
|
+
private readonly parserCache;
|
|
382
502
|
/**
|
|
383
503
|
* Plugin theme
|
|
384
504
|
*/
|
|
@@ -387,6 +507,13 @@ declare class CodePlugin extends DecorationPlugin {
|
|
|
387
507
|
* Keyboard shortcuts for code formatting
|
|
388
508
|
*/
|
|
389
509
|
getKeymap(): KeyBinding[];
|
|
510
|
+
/**
|
|
511
|
+
* Intercepts backtick typing to wrap selected text as inline code.
|
|
512
|
+
*
|
|
513
|
+
* If user types '`' while text is selected, wraps each selected range
|
|
514
|
+
* with backticks (selected -> `selected`).
|
|
515
|
+
*/
|
|
516
|
+
getExtensions(): Extension[];
|
|
390
517
|
/**
|
|
391
518
|
* Toggle code block on current line or selected lines
|
|
392
519
|
*/
|
|
@@ -409,6 +536,7 @@ declare class CodePlugin extends DecorationPlugin {
|
|
|
409
536
|
* lineNumbers: 5,
|
|
410
537
|
* title: "hello.tsx",
|
|
411
538
|
* copy: true,
|
|
539
|
+
* diff: false,
|
|
412
540
|
* highlightLines: [2,3,4,5],
|
|
413
541
|
* highlightText: [{ pattern: "Hello", instances: [3,4,5] }]
|
|
414
542
|
* }
|
|
@@ -420,19 +548,33 @@ declare class CodePlugin extends DecorationPlugin {
|
|
|
420
548
|
* Handles line numbers, highlights, header/caption widgets, and fence visibility.
|
|
421
549
|
*/
|
|
422
550
|
buildDecorations(ctx: DecorationContext): void;
|
|
551
|
+
private decorateInlineCode;
|
|
552
|
+
private decorateFencedCode;
|
|
553
|
+
private decorateFenceMarkers;
|
|
554
|
+
private decorateDiffLine;
|
|
555
|
+
private decorateTextHighlights;
|
|
423
556
|
/**
|
|
424
557
|
* Render code elements to HTML for static preview.
|
|
425
558
|
* Applies syntax highlighting using @lezer/highlight.
|
|
426
559
|
*/
|
|
427
|
-
renderToHTML(node: SyntaxNode,
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
}): string | null;
|
|
560
|
+
renderToHTML(node: SyntaxNode, _children: string, ctx: PreviewRenderContext): Promise<string | null>;
|
|
561
|
+
/** Parse comma-separated numbers and ranges (e.g. "1,3-5") into [1,3,4,5]. */
|
|
562
|
+
private parseNumberList;
|
|
431
563
|
/**
|
|
432
564
|
* Highlight a single line of code using the language's Lezer parser.
|
|
433
565
|
* Falls back to sanitized plain text if the language is not supported.
|
|
434
566
|
*/
|
|
435
|
-
private
|
|
567
|
+
private highlightCodeLines;
|
|
568
|
+
private resolveLanguageParser;
|
|
569
|
+
private normalizeLanguage;
|
|
570
|
+
private escapeHtml;
|
|
571
|
+
private escapeAttribute;
|
|
572
|
+
private analyzeDiffLines;
|
|
573
|
+
private computeDiffDisplayLineNumbers;
|
|
574
|
+
private parseDiffLineState;
|
|
575
|
+
private computeChangedRanges;
|
|
576
|
+
private renderDiffPreviewLine;
|
|
577
|
+
private applyRangesToHighlightedHTML;
|
|
436
578
|
/**
|
|
437
579
|
* Apply text highlights (regex patterns) to already syntax-highlighted HTML.
|
|
438
580
|
* Wraps matched patterns in `<mark>` elements.
|
|
@@ -499,6 +641,34 @@ declare class HRPlugin extends DecorationPlugin {
|
|
|
499
641
|
renderToHTML(node: SyntaxNode, _children: string): string | null;
|
|
500
642
|
}
|
|
501
643
|
|
|
644
|
+
/**
|
|
645
|
+
* EmojiPlugin - Decorates markdown emojis
|
|
646
|
+
*
|
|
647
|
+
* Parses and decorates emoji shortcodes like :smile:
|
|
648
|
+
* - Converts valid shortcodes to Unicode emoji when cursor is outside
|
|
649
|
+
* - Keeps raw shortcode visible while editing (cursor inside token)
|
|
650
|
+
*/
|
|
651
|
+
declare class EmojiPlugin extends DecorationPlugin {
|
|
652
|
+
readonly name = "emoji";
|
|
653
|
+
readonly version = "1.0.0";
|
|
654
|
+
decorationPriority: number;
|
|
655
|
+
readonly requiredNodes: readonly ["Emoji", "EmojiMark"];
|
|
656
|
+
constructor();
|
|
657
|
+
/**
|
|
658
|
+
* Plugin theme
|
|
659
|
+
*/
|
|
660
|
+
get theme(): (theme: ThemeEnum) => ThemeStyle;
|
|
661
|
+
/**
|
|
662
|
+
* Build emoji decorations by iterating the syntax tree
|
|
663
|
+
*/
|
|
664
|
+
buildDecorations(ctx: DecorationContext): void;
|
|
665
|
+
renderToHTML(node: SyntaxNode, children: string, ctx: {
|
|
666
|
+
sliceDoc(from: number, to: number): string;
|
|
667
|
+
sanitize(html: string): string;
|
|
668
|
+
syntaxHighlighters?: readonly _lezer_highlight.Highlighter[];
|
|
669
|
+
}): string | null;
|
|
670
|
+
}
|
|
671
|
+
|
|
502
672
|
/**
|
|
503
673
|
* Default plugins
|
|
504
674
|
*
|
|
@@ -512,4 +682,4 @@ declare const essentialPlugins: DraftlyPlugin[];
|
|
|
512
682
|
*/
|
|
513
683
|
declare const allPlugins: DraftlyPlugin[];
|
|
514
684
|
|
|
515
|
-
export { CodePlugin, HRPlugin, HTMLPlugin, HeadingPlugin, ImagePlugin, InlinePlugin, LinkPlugin, ListPlugin, MathPlugin, MermaidPlugin, ParagraphPlugin, QuotePlugin, allPlugins, essentialPlugins };
|
|
685
|
+
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,11 @@
|
|
|
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 {
|
|
3
|
+
import { Extension } from '@codemirror/state';
|
|
4
|
+
import * as _codemirror_view from '@codemirror/view';
|
|
5
|
+
import { KeyBinding, EditorView } from '@codemirror/view';
|
|
4
6
|
import { MarkdownConfig } from '@lezer/markdown';
|
|
5
|
-
import '@
|
|
7
|
+
import * as _lezer_highlight from '@lezer/highlight';
|
|
8
|
+
import { Highlighter } from '@lezer/highlight';
|
|
6
9
|
import 'style-mod';
|
|
7
10
|
|
|
8
11
|
/**
|
|
@@ -77,6 +80,15 @@ declare class InlinePlugin extends DecorationPlugin {
|
|
|
77
80
|
* Keyboard shortcuts for inline formatting
|
|
78
81
|
*/
|
|
79
82
|
getKeymap(): KeyBinding[];
|
|
83
|
+
/**
|
|
84
|
+
* Intercepts inline marker typing to wrap selected text.
|
|
85
|
+
*
|
|
86
|
+
* If user types inline markers while text is selected, wraps each selected
|
|
87
|
+
* range with the appropriate marker:
|
|
88
|
+
* - * _ ~ ^ -> marker + selected + marker
|
|
89
|
+
* - = -> ==selected==
|
|
90
|
+
*/
|
|
91
|
+
getExtensions(): Extension[];
|
|
80
92
|
/**
|
|
81
93
|
* Return markdown parser extensions for highlight syntax (==text==)
|
|
82
94
|
*/
|
|
@@ -180,6 +192,99 @@ declare class ListPlugin extends DecorationPlugin {
|
|
|
180
192
|
}): string | null;
|
|
181
193
|
}
|
|
182
194
|
|
|
195
|
+
interface PreviewContextLike {
|
|
196
|
+
sliceDoc(from: number, to: number): string;
|
|
197
|
+
sanitize(html: string): string;
|
|
198
|
+
}
|
|
199
|
+
declare class TablePlugin extends DecorationPlugin {
|
|
200
|
+
readonly name = "table";
|
|
201
|
+
readonly version = "2.0.0";
|
|
202
|
+
decorationPriority: number;
|
|
203
|
+
readonly requiredNodes: readonly ["Table", "TableHeader", "TableDelimiter", "TableRow", "TableCell"];
|
|
204
|
+
private draftlyConfig;
|
|
205
|
+
private pendingNormalizationView;
|
|
206
|
+
private pendingPaddingView;
|
|
207
|
+
private pendingSelectionRepairView;
|
|
208
|
+
/** Stores the editor config for preview rendering and shared behavior. */
|
|
209
|
+
onRegister(context: PluginContext): void;
|
|
210
|
+
/** Exposes the plugin theme used for editor and preview styling. */
|
|
211
|
+
get theme(): (theme: ThemeEnum) => ThemeStyle;
|
|
212
|
+
/** Enables GFM table parsing for the editor and preview renderer. */
|
|
213
|
+
getMarkdownConfig(): MarkdownConfig;
|
|
214
|
+
/** Registers block wrappers and atomic ranges for the table UI. */
|
|
215
|
+
getExtensions(): Extension[];
|
|
216
|
+
/** Provides the table-specific keyboard shortcuts and navigation. */
|
|
217
|
+
getKeymap(): KeyBinding[];
|
|
218
|
+
/** Builds the high-priority key bindings used inside tables. */
|
|
219
|
+
private buildTableKeymap;
|
|
220
|
+
/** Schedules an initial normalization pass once the view is ready. */
|
|
221
|
+
onViewReady(view: EditorView): void;
|
|
222
|
+
/** Re-schedules normalization after user-driven document changes. */
|
|
223
|
+
onViewUpdate(update: _codemirror_view.ViewUpdate): void;
|
|
224
|
+
/** Intercepts table-specific DOM key handling before browser defaults run. */
|
|
225
|
+
private handleDomKeydown;
|
|
226
|
+
/** Builds the visual table decorations for every parsed table block. */
|
|
227
|
+
buildDecorations(ctx: DecorationContext): void;
|
|
228
|
+
/** Renders the full table node to semantic preview HTML. */
|
|
229
|
+
renderToHTML(node: SyntaxNode, _children: string, ctx: PreviewContextLike): Promise<string | null>;
|
|
230
|
+
/** Computes the block wrapper ranges used to group table lines. */
|
|
231
|
+
private computeBlockWrappers;
|
|
232
|
+
/** Computes atomic ranges for delimiters and inline break tags. */
|
|
233
|
+
private computeAtomicRanges;
|
|
234
|
+
/** Applies row, cell, and control decorations for a single table. */
|
|
235
|
+
private decorateTable;
|
|
236
|
+
/** Applies the visual cell decorations for a single table row line. */
|
|
237
|
+
private decorateLine;
|
|
238
|
+
/** Normalizes every parsed table block back into canonical markdown. */
|
|
239
|
+
private normalizeTables;
|
|
240
|
+
/** Defers table normalization until the current update cycle is finished. */
|
|
241
|
+
private scheduleNormalization;
|
|
242
|
+
/** Adds missing spacer lines above and below tables after edits. */
|
|
243
|
+
private ensureTablePadding;
|
|
244
|
+
/** Schedules a padding-only pass after the current update cycle finishes. */
|
|
245
|
+
private schedulePadding;
|
|
246
|
+
/** Repairs carets that land in hidden table markup instead of editable cell content. */
|
|
247
|
+
private ensureTableSelection;
|
|
248
|
+
/** Schedules table selection repair after the current update finishes. */
|
|
249
|
+
private scheduleSelectionRepair;
|
|
250
|
+
/** Rewrites a table block and restores the caret to a target cell position. */
|
|
251
|
+
private replaceTable;
|
|
252
|
+
/** Inserts an empty body row below the given logical row index. */
|
|
253
|
+
private insertRowBelow;
|
|
254
|
+
/** Inserts a starter table near the current cursor line. */
|
|
255
|
+
private insertTable;
|
|
256
|
+
/** Adds a new empty body row to the active table. */
|
|
257
|
+
private addRow;
|
|
258
|
+
/** Appends a row and keeps the caret in the requested column. */
|
|
259
|
+
private appendRow;
|
|
260
|
+
/** Inserts a new column after the current column. */
|
|
261
|
+
private addColumn;
|
|
262
|
+
/** Appends a new column at the far right of the table. */
|
|
263
|
+
private appendColumn;
|
|
264
|
+
/** Removes the current body row or clears the last remaining row. */
|
|
265
|
+
private removeRow;
|
|
266
|
+
/** Removes the current column when the table has more than one column. */
|
|
267
|
+
private removeColumn;
|
|
268
|
+
/** Moves to the next or previous logical cell with Tab navigation. */
|
|
269
|
+
private handleTab;
|
|
270
|
+
/** Moves horizontally between adjacent cells when the caret hits an edge. */
|
|
271
|
+
private handleArrowHorizontal;
|
|
272
|
+
/** Moves vertically between rows while keeping the current column. */
|
|
273
|
+
private handleArrowVertical;
|
|
274
|
+
/** Advances downward on Enter and manages the trailing empty row behavior. */
|
|
275
|
+
private handleEnter;
|
|
276
|
+
/** Inserts a canonical `<br />` token inside the current table cell. */
|
|
277
|
+
private insertBreakTag;
|
|
278
|
+
/** Deletes a whole `<br />` token when backspace or delete hits it. */
|
|
279
|
+
private handleBreakDeletion;
|
|
280
|
+
/** Moves the current selection anchor into a target cell. */
|
|
281
|
+
private moveSelectionToCell;
|
|
282
|
+
/** Returns the table currently containing the editor cursor. */
|
|
283
|
+
private getTableAtCursor;
|
|
284
|
+
/** Returns the active cell under the current selection head. */
|
|
285
|
+
private getCurrentCell;
|
|
286
|
+
}
|
|
287
|
+
|
|
183
288
|
/**
|
|
184
289
|
* HTMLPlugin - Decorates and Renders HTML in markdown
|
|
185
290
|
*/
|
|
@@ -268,6 +373,13 @@ declare class MathPlugin extends DecorationPlugin {
|
|
|
268
373
|
* Plugin theme
|
|
269
374
|
*/
|
|
270
375
|
get theme(): (theme: ThemeEnum) => ThemeStyle;
|
|
376
|
+
/**
|
|
377
|
+
* Intercepts dollar typing to wrap selected text as inline math.
|
|
378
|
+
*
|
|
379
|
+
* If user types '$' while text is selected, wraps each selected range
|
|
380
|
+
* with single dollars (selected -> $selected$).
|
|
381
|
+
*/
|
|
382
|
+
getExtensions(): Extension[];
|
|
271
383
|
/**
|
|
272
384
|
* Return markdown parser extensions for math syntax
|
|
273
385
|
*/
|
|
@@ -328,6 +440,11 @@ declare class MermaidPlugin extends DecorationPlugin {
|
|
|
328
440
|
}): Promise<string | null>;
|
|
329
441
|
}
|
|
330
442
|
|
|
443
|
+
interface PreviewRenderContext {
|
|
444
|
+
sliceDoc(from: number, to: number): string;
|
|
445
|
+
sanitize(html: string): string;
|
|
446
|
+
syntaxHighlighters?: readonly Highlighter[];
|
|
447
|
+
}
|
|
331
448
|
/**
|
|
332
449
|
* Text highlight definition
|
|
333
450
|
* Matches text or regex patterns with optional instance selection
|
|
@@ -347,13 +464,15 @@ interface CodeBlockProperties {
|
|
|
347
464
|
/** Language identifier (first token) */
|
|
348
465
|
language: string;
|
|
349
466
|
/** Show line numbers, optionally starting from a specific number */
|
|
350
|
-
|
|
467
|
+
showLineNumbers?: number | boolean;
|
|
351
468
|
/** Title to display */
|
|
352
469
|
title?: string;
|
|
353
470
|
/** Caption to display */
|
|
354
471
|
caption?: string;
|
|
355
472
|
/** Show copy button */
|
|
356
473
|
copy?: boolean;
|
|
474
|
+
/** Enable diff preview mode */
|
|
475
|
+
diff?: boolean;
|
|
357
476
|
/** Lines to highlight (e.g., [2,3,4,5,9]) */
|
|
358
477
|
highlightLines?: number[];
|
|
359
478
|
/** Text patterns to highlight with optional instance selection */
|
|
@@ -379,6 +498,7 @@ declare class CodePlugin extends DecorationPlugin {
|
|
|
379
498
|
readonly version = "1.0.0";
|
|
380
499
|
decorationPriority: number;
|
|
381
500
|
readonly requiredNodes: readonly ["InlineCode", "FencedCode", "CodeMark", "CodeInfo", "CodeText"];
|
|
501
|
+
private readonly parserCache;
|
|
382
502
|
/**
|
|
383
503
|
* Plugin theme
|
|
384
504
|
*/
|
|
@@ -387,6 +507,13 @@ declare class CodePlugin extends DecorationPlugin {
|
|
|
387
507
|
* Keyboard shortcuts for code formatting
|
|
388
508
|
*/
|
|
389
509
|
getKeymap(): KeyBinding[];
|
|
510
|
+
/**
|
|
511
|
+
* Intercepts backtick typing to wrap selected text as inline code.
|
|
512
|
+
*
|
|
513
|
+
* If user types '`' while text is selected, wraps each selected range
|
|
514
|
+
* with backticks (selected -> `selected`).
|
|
515
|
+
*/
|
|
516
|
+
getExtensions(): Extension[];
|
|
390
517
|
/**
|
|
391
518
|
* Toggle code block on current line or selected lines
|
|
392
519
|
*/
|
|
@@ -409,6 +536,7 @@ declare class CodePlugin extends DecorationPlugin {
|
|
|
409
536
|
* lineNumbers: 5,
|
|
410
537
|
* title: "hello.tsx",
|
|
411
538
|
* copy: true,
|
|
539
|
+
* diff: false,
|
|
412
540
|
* highlightLines: [2,3,4,5],
|
|
413
541
|
* highlightText: [{ pattern: "Hello", instances: [3,4,5] }]
|
|
414
542
|
* }
|
|
@@ -420,19 +548,33 @@ declare class CodePlugin extends DecorationPlugin {
|
|
|
420
548
|
* Handles line numbers, highlights, header/caption widgets, and fence visibility.
|
|
421
549
|
*/
|
|
422
550
|
buildDecorations(ctx: DecorationContext): void;
|
|
551
|
+
private decorateInlineCode;
|
|
552
|
+
private decorateFencedCode;
|
|
553
|
+
private decorateFenceMarkers;
|
|
554
|
+
private decorateDiffLine;
|
|
555
|
+
private decorateTextHighlights;
|
|
423
556
|
/**
|
|
424
557
|
* Render code elements to HTML for static preview.
|
|
425
558
|
* Applies syntax highlighting using @lezer/highlight.
|
|
426
559
|
*/
|
|
427
|
-
renderToHTML(node: SyntaxNode,
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
}): string | null;
|
|
560
|
+
renderToHTML(node: SyntaxNode, _children: string, ctx: PreviewRenderContext): Promise<string | null>;
|
|
561
|
+
/** Parse comma-separated numbers and ranges (e.g. "1,3-5") into [1,3,4,5]. */
|
|
562
|
+
private parseNumberList;
|
|
431
563
|
/**
|
|
432
564
|
* Highlight a single line of code using the language's Lezer parser.
|
|
433
565
|
* Falls back to sanitized plain text if the language is not supported.
|
|
434
566
|
*/
|
|
435
|
-
private
|
|
567
|
+
private highlightCodeLines;
|
|
568
|
+
private resolveLanguageParser;
|
|
569
|
+
private normalizeLanguage;
|
|
570
|
+
private escapeHtml;
|
|
571
|
+
private escapeAttribute;
|
|
572
|
+
private analyzeDiffLines;
|
|
573
|
+
private computeDiffDisplayLineNumbers;
|
|
574
|
+
private parseDiffLineState;
|
|
575
|
+
private computeChangedRanges;
|
|
576
|
+
private renderDiffPreviewLine;
|
|
577
|
+
private applyRangesToHighlightedHTML;
|
|
436
578
|
/**
|
|
437
579
|
* Apply text highlights (regex patterns) to already syntax-highlighted HTML.
|
|
438
580
|
* Wraps matched patterns in `<mark>` elements.
|
|
@@ -499,6 +641,34 @@ declare class HRPlugin extends DecorationPlugin {
|
|
|
499
641
|
renderToHTML(node: SyntaxNode, _children: string): string | null;
|
|
500
642
|
}
|
|
501
643
|
|
|
644
|
+
/**
|
|
645
|
+
* EmojiPlugin - Decorates markdown emojis
|
|
646
|
+
*
|
|
647
|
+
* Parses and decorates emoji shortcodes like :smile:
|
|
648
|
+
* - Converts valid shortcodes to Unicode emoji when cursor is outside
|
|
649
|
+
* - Keeps raw shortcode visible while editing (cursor inside token)
|
|
650
|
+
*/
|
|
651
|
+
declare class EmojiPlugin extends DecorationPlugin {
|
|
652
|
+
readonly name = "emoji";
|
|
653
|
+
readonly version = "1.0.0";
|
|
654
|
+
decorationPriority: number;
|
|
655
|
+
readonly requiredNodes: readonly ["Emoji", "EmojiMark"];
|
|
656
|
+
constructor();
|
|
657
|
+
/**
|
|
658
|
+
* Plugin theme
|
|
659
|
+
*/
|
|
660
|
+
get theme(): (theme: ThemeEnum) => ThemeStyle;
|
|
661
|
+
/**
|
|
662
|
+
* Build emoji decorations by iterating the syntax tree
|
|
663
|
+
*/
|
|
664
|
+
buildDecorations(ctx: DecorationContext): void;
|
|
665
|
+
renderToHTML(node: SyntaxNode, children: string, ctx: {
|
|
666
|
+
sliceDoc(from: number, to: number): string;
|
|
667
|
+
sanitize(html: string): string;
|
|
668
|
+
syntaxHighlighters?: readonly _lezer_highlight.Highlighter[];
|
|
669
|
+
}): string | null;
|
|
670
|
+
}
|
|
671
|
+
|
|
502
672
|
/**
|
|
503
673
|
* Default plugins
|
|
504
674
|
*
|
|
@@ -512,4 +682,4 @@ declare const essentialPlugins: DraftlyPlugin[];
|
|
|
512
682
|
*/
|
|
513
683
|
declare const allPlugins: DraftlyPlugin[];
|
|
514
684
|
|
|
515
|
-
export { CodePlugin, HRPlugin, HTMLPlugin, HeadingPlugin, ImagePlugin, InlinePlugin, LinkPlugin, ListPlugin, MathPlugin, MermaidPlugin, ParagraphPlugin, QuotePlugin, allPlugins, essentialPlugins };
|
|
685
|
+
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-NRPI5O6Y.js';
|
|
2
|
+
import '../chunk-UCHBDJ4R.js';
|
|
3
|
+
import '../chunk-JF3WXXMJ.js';
|
|
4
|
+
import '../chunk-I563H35S.js';
|
|
5
|
+
import '../chunk-TD3L5C45.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-W75QUUQC.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
|