mardora 1.2.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.
Files changed (138) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +113 -0
  3. package/dist/chunk-3OCUX4OO.js +7690 -0
  4. package/dist/chunk-3OCUX4OO.js.map +1 -0
  5. package/dist/chunk-3ZOCCFDL.cjs +74 -0
  6. package/dist/chunk-3ZOCCFDL.cjs.map +1 -0
  7. package/dist/chunk-7JOEPNEV.cjs +7740 -0
  8. package/dist/chunk-7JOEPNEV.cjs.map +1 -0
  9. package/dist/chunk-BIKZQZ6W.js +33 -0
  10. package/dist/chunk-BIKZQZ6W.js.map +1 -0
  11. package/dist/chunk-EQJESPP2.js +234 -0
  12. package/dist/chunk-EQJESPP2.js.map +1 -0
  13. package/dist/chunk-G4SE26YY.js +70 -0
  14. package/dist/chunk-G4SE26YY.js.map +1 -0
  15. package/dist/chunk-KNDWF2DP.cjs +35 -0
  16. package/dist/chunk-KNDWF2DP.cjs.map +1 -0
  17. package/dist/chunk-MLBEBFHB.cjs +2971 -0
  18. package/dist/chunk-MLBEBFHB.cjs.map +1 -0
  19. package/dist/chunk-P7JFCYU3.js +905 -0
  20. package/dist/chunk-P7JFCYU3.js.map +1 -0
  21. package/dist/chunk-SWFUKJDO.cjs +243 -0
  22. package/dist/chunk-SWFUKJDO.cjs.map +1 -0
  23. package/dist/chunk-WFVCG4LD.cjs +926 -0
  24. package/dist/chunk-WFVCG4LD.cjs.map +1 -0
  25. package/dist/chunk-XL6WFGJT.js +2901 -0
  26. package/dist/chunk-XL6WFGJT.js.map +1 -0
  27. package/dist/editor/index.cjs +277 -0
  28. package/dist/editor/index.cjs.map +1 -0
  29. package/dist/editor/index.d.cts +186 -0
  30. package/dist/editor/index.d.ts +186 -0
  31. package/dist/editor/index.js +4 -0
  32. package/dist/editor/index.js.map +1 -0
  33. package/dist/index.cjs +405 -0
  34. package/dist/index.cjs.map +1 -0
  35. package/dist/index.d.cts +13 -0
  36. package/dist/index.d.ts +13 -0
  37. package/dist/index.js +8 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/lib/index.cjs +12 -0
  40. package/dist/lib/index.cjs.map +1 -0
  41. package/dist/lib/index.d.cts +16 -0
  42. package/dist/lib/index.d.ts +16 -0
  43. package/dist/lib/index.js +3 -0
  44. package/dist/lib/index.js.map +1 -0
  45. package/dist/mardora-DCwjomil.d.cts +640 -0
  46. package/dist/mardora-DCwjomil.d.ts +640 -0
  47. package/dist/plugins/index.cjs +104 -0
  48. package/dist/plugins/index.cjs.map +1 -0
  49. package/dist/plugins/index.d.cts +740 -0
  50. package/dist/plugins/index.d.ts +740 -0
  51. package/dist/plugins/index.js +7 -0
  52. package/dist/plugins/index.js.map +1 -0
  53. package/dist/preview/index.cjs +38 -0
  54. package/dist/preview/index.cjs.map +1 -0
  55. package/dist/preview/index.d.cts +101 -0
  56. package/dist/preview/index.d.ts +101 -0
  57. package/dist/preview/index.js +5 -0
  58. package/dist/preview/index.js.map +1 -0
  59. package/dist/types-NBsaxl4d.d.cts +71 -0
  60. package/dist/types-Pw2SWWAR.d.ts +71 -0
  61. package/package.json +92 -0
  62. package/src/editor/attachments/extension.ts +181 -0
  63. package/src/editor/attachments/format.ts +63 -0
  64. package/src/editor/attachments/index.ts +3 -0
  65. package/src/editor/attachments/types.ts +37 -0
  66. package/src/editor/heading-fold/config.ts +25 -0
  67. package/src/editor/heading-fold/extension.ts +268 -0
  68. package/src/editor/heading-fold/extract.ts +88 -0
  69. package/src/editor/heading-fold/index.ts +5 -0
  70. package/src/editor/heading-fold/theme.ts +85 -0
  71. package/src/editor/heading-fold/types.ts +24 -0
  72. package/src/editor/i18n.ts +13 -0
  73. package/src/editor/icons/index.ts +367 -0
  74. package/src/editor/index.ts +16 -0
  75. package/src/editor/mardora.ts +257 -0
  76. package/src/editor/media-lightbox-theme.ts +146 -0
  77. package/src/editor/media-lightbox.ts +125 -0
  78. package/src/editor/plugin.ts +294 -0
  79. package/src/editor/selection-toolbar/activation.ts +123 -0
  80. package/src/editor/selection-toolbar/commands.ts +279 -0
  81. package/src/editor/selection-toolbar/extension.ts +564 -0
  82. package/src/editor/selection-toolbar/i18n.ts +164 -0
  83. package/src/editor/selection-toolbar/index.ts +7 -0
  84. package/src/editor/selection-toolbar/menu.ts +252 -0
  85. package/src/editor/selection-toolbar/position.ts +43 -0
  86. package/src/editor/selection-toolbar/theme.ts +195 -0
  87. package/src/editor/selection-toolbar/types.ts +155 -0
  88. package/src/editor/slash/default-commands.ts +190 -0
  89. package/src/editor/slash/extension.ts +319 -0
  90. package/src/editor/slash/index.ts +7 -0
  91. package/src/editor/slash/insertions.ts +26 -0
  92. package/src/editor/slash/menu.ts +123 -0
  93. package/src/editor/slash/position.ts +61 -0
  94. package/src/editor/slash/query.ts +33 -0
  95. package/src/editor/slash/theme.ts +113 -0
  96. package/src/editor/slash/types.ts +40 -0
  97. package/src/editor/table-of-contents/extension.ts +202 -0
  98. package/src/editor/table-of-contents/extract.ts +53 -0
  99. package/src/editor/table-of-contents/index.ts +7 -0
  100. package/src/editor/table-of-contents/panel.ts +83 -0
  101. package/src/editor/table-of-contents/slug.ts +50 -0
  102. package/src/editor/table-of-contents/storage.ts +35 -0
  103. package/src/editor/table-of-contents/theme.ts +153 -0
  104. package/src/editor/table-of-contents/types.ts +44 -0
  105. package/src/editor/theme.ts +72 -0
  106. package/src/editor/utils.ts +176 -0
  107. package/src/editor/view-plugin.ts +189 -0
  108. package/src/index.ts +5 -0
  109. package/src/lib/index.ts +2 -0
  110. package/src/lib/input-handler.ts +47 -0
  111. package/src/plugins/code-plugin.theme.ts +545 -0
  112. package/src/plugins/code-plugin.ts +1892 -0
  113. package/src/plugins/emoji-plugin.ts +140 -0
  114. package/src/plugins/heading-plugin.ts +194 -0
  115. package/src/plugins/hr-plugin.ts +102 -0
  116. package/src/plugins/html-plugin.ts +353 -0
  117. package/src/plugins/image-plugin.ts +806 -0
  118. package/src/plugins/index.ts +71 -0
  119. package/src/plugins/inline-plugin.ts +311 -0
  120. package/src/plugins/link-plugin.ts +509 -0
  121. package/src/plugins/list-plugin.ts +492 -0
  122. package/src/plugins/math-plugin.ts +526 -0
  123. package/src/plugins/mermaid-plugin.ts +513 -0
  124. package/src/plugins/paragraph-plugin.ts +38 -0
  125. package/src/plugins/quote-plugin.ts +733 -0
  126. package/src/plugins/table-controls-theme.ts +126 -0
  127. package/src/plugins/table-controls.ts +423 -0
  128. package/src/plugins/table-model.ts +661 -0
  129. package/src/plugins/table-plugin.ts +2111 -0
  130. package/src/preview/context.ts +45 -0
  131. package/src/preview/css-generator.ts +64 -0
  132. package/src/preview/default-renderers.ts +29 -0
  133. package/src/preview/index.ts +29 -0
  134. package/src/preview/preview.ts +41 -0
  135. package/src/preview/renderer.ts +184 -0
  136. package/src/preview/syntax-theme.ts +112 -0
  137. package/src/preview/toc.ts +23 -0
  138. package/src/preview/types.ts +89 -0
@@ -0,0 +1,740 @@
1
+ import { q as MardoraPlugin, a3 as ThemeEnum, a4 as ThemeStyle, a as DecorationPlugin, D as DecorationContext, C as PluginContext } from '../mardora-DCwjomil.js';
2
+ import { SyntaxNode } from '@lezer/common';
3
+ import { b as PreviewContext } from '../types-Pw2SWWAR.js';
4
+ import { Extension, EditorState } from '@codemirror/state';
5
+ import * as _codemirror_view from '@codemirror/view';
6
+ import { KeyBinding, EditorView } from '@codemirror/view';
7
+ import { MarkdownConfig } from '@lezer/markdown';
8
+ import * as style_mod from 'style-mod';
9
+ import * as _lezer_highlight from '@lezer/highlight';
10
+ import { Highlighter } from '@lezer/highlight';
11
+ import '@codemirror/language';
12
+
13
+ /**
14
+ * ParagraphPlugin - Adds top and bottom padding to paragraphs in preview
15
+ *
16
+ * Applies visual spacing to markdown paragraphs for better readability
17
+ */
18
+ declare class ParagraphPlugin extends MardoraPlugin {
19
+ readonly name = "paragraph";
20
+ readonly version = "1.0.0";
21
+ readonly requiredNodes: readonly ["Paragraph"];
22
+ /**
23
+ * Plugin theme for preview styling
24
+ */
25
+ get theme(): (theme: ThemeEnum) => ThemeStyle;
26
+ renderToHTML(node: SyntaxNode, children: string): string | null;
27
+ }
28
+
29
+ /**
30
+ * HeadingPlugin - Decorates markdown headings
31
+ *
32
+ * Adds visual styling to ATX headings (# through ######)
33
+ * - Line decorations for the entire heading line
34
+ * - Mark decorations for heading content
35
+ * - Hides # markers when cursor is not in the heading
36
+ */
37
+ declare class HeadingPlugin extends DecorationPlugin {
38
+ readonly name = "heading";
39
+ readonly version = "1.0.0";
40
+ decorationPriority: number;
41
+ readonly requiredNodes: readonly ["ATXHeading1", "ATXHeading2", "ATXHeading3", "ATXHeading4", "ATXHeading5", "ATXHeading6", "HeaderMark"];
42
+ /**
43
+ * Constructor - calls super constructor
44
+ */
45
+ constructor();
46
+ /**
47
+ * Plugin theme
48
+ */
49
+ get theme(): (theme: ThemeEnum) => ThemeStyle;
50
+ /**
51
+ * Build heading decorations by iterating the syntax tree
52
+ */
53
+ buildDecorations(ctx: DecorationContext): void;
54
+ renderToHTML(node: SyntaxNode, children: string, ctx: PreviewContext): string | null;
55
+ }
56
+
57
+ /**
58
+ * InlinePlugin - Decorates inline markdown formatting
59
+ *
60
+ * Adds visual styling to inline elements:
61
+ * - Emphasis (italic) - *text* or _text_
62
+ * - Strong (bold) - **text** or __text__
63
+ * - Strikethrough - ~~text~~
64
+ * - Subscript - ~text~
65
+ * - Superscript - ^text^
66
+ * - Highlight - ==text==
67
+ *
68
+ * Hides formatting markers when cursor is not in the element
69
+ */
70
+ declare class InlinePlugin extends DecorationPlugin {
71
+ readonly name = "inline";
72
+ readonly version = "1.0.0";
73
+ decorationPriority: number;
74
+ readonly requiredNodes: readonly ["Emphasis", "StrongEmphasis", "Strikethrough", "Subscript", "Superscript", "Highlight", "EmphasisMark", "StrikethroughMark", "SubscriptMark", "SuperscriptMark", "HighlightMark", "Escape"];
75
+ marks: string[];
76
+ constructor();
77
+ /**
78
+ * Plugin theme
79
+ */
80
+ get theme(): (theme: ThemeEnum) => ThemeStyle;
81
+ /**
82
+ * Keyboard shortcuts for inline formatting
83
+ */
84
+ getKeymap(): KeyBinding[];
85
+ /**
86
+ * Intercepts inline marker typing to wrap selected text.
87
+ *
88
+ * If user types inline markers while text is selected, wraps each selected
89
+ * range with the appropriate marker:
90
+ * - * _ ~ ^ -> marker + selected + marker
91
+ * - = -> ==selected==
92
+ */
93
+ getExtensions(): Extension[];
94
+ /**
95
+ * Return markdown parser extensions for highlight syntax (==text==)
96
+ */
97
+ getMarkdownConfig(): MarkdownConfig;
98
+ /**
99
+ * Build inline decorations by iterating the syntax tree
100
+ */
101
+ buildDecorations(ctx: DecorationContext): void;
102
+ /**
103
+ * Get the marker node names for a given inline type
104
+ */
105
+ private getMarkerNames;
106
+ renderToHTML(node: SyntaxNode, children: string): string | null;
107
+ }
108
+
109
+ /**
110
+ * LinkPlugin - Decorates and provides interactivity for markdown links
111
+ *
112
+ * Supports the full link syntax: [text](url) and [text](url "title")
113
+ * - Click: reveals raw markdown (selects/focuses the link syntax)
114
+ * - Ctrl+Click: opens the link URL in a new browser tab
115
+ * - Hover: shows tooltip with the link URL
116
+ * - Hides the markdown syntax when cursor is not in range
117
+ * - Shows raw markdown when cursor is within the link range
118
+ */
119
+ declare class LinkPlugin extends DecorationPlugin {
120
+ readonly name = "link";
121
+ readonly version = "1.0.0";
122
+ decorationPriority: number;
123
+ readonly requiredNodes: readonly ["Link"];
124
+ constructor();
125
+ /**
126
+ * Plugin theme
127
+ */
128
+ get theme(): (theme: ThemeEnum) => ThemeStyle;
129
+ /**
130
+ * Keyboard shortcuts for link formatting
131
+ */
132
+ getKeymap(): KeyBinding[];
133
+ /**
134
+ * URL regex pattern
135
+ */
136
+ private readonly urlPattern;
137
+ /**
138
+ * Toggle link on selection
139
+ * - If text is selected and is a URL: [](url) with cursor in brackets
140
+ * - If text is selected (not URL): [text]() with cursor in parentheses
141
+ * - If nothing selected: []() with cursor in brackets
142
+ * - If already a link: remove syntax, leave plain text
143
+ */
144
+ private toggleLink;
145
+ buildDecorations(ctx: DecorationContext): void;
146
+ /**
147
+ * Decorate raw link markdown when cursor is in range
148
+ */
149
+ private decorateRawLink;
150
+ /**
151
+ * Render link to HTML for preview mode
152
+ */
153
+ renderToHTML(node: SyntaxNode, _children: string, ctx: {
154
+ sliceDoc(from: number, to: number): string;
155
+ sanitize(html: string): string;
156
+ }): string | null;
157
+ }
158
+
159
+ /**
160
+ * Decorates markdown lists with custom styling.
161
+ *
162
+ * Supports:
163
+ * - **Unordered lists** — Replaces `*`, `-`, `+` markers with styled bullets
164
+ * - **Ordered lists** — Styles numbered markers (`1.`, `2.`, etc.)
165
+ * - **Task lists** — Renders `[ ]`/`[x]` as interactive checkboxes
166
+ */
167
+ declare class ListPlugin extends DecorationPlugin {
168
+ readonly name = "list";
169
+ readonly version = "1.0.0";
170
+ decorationPriority: number;
171
+ readonly requiredNodes: readonly ["BulletList", "OrderedList", "ListItem", "ListMark", "Task", "TaskMarker"];
172
+ get theme(): (theme: ThemeEnum) => ThemeStyle;
173
+ /**
174
+ * Keyboard shortcuts for list formatting
175
+ */
176
+ getKeymap(): KeyBinding[];
177
+ /**
178
+ * Toggle list marker on current line or selected lines
179
+ */
180
+ private toggleListOnLines;
181
+ buildDecorations(ctx: DecorationContext): void;
182
+ /** Add line decoration for list items with nesting depth */
183
+ private decorateListItem;
184
+ /** Check if a ListItem node has a Task child */
185
+ private hasTaskChild;
186
+ /** Decorate list markers (bullets for UL, numbers for OL) */
187
+ private decorateListMark;
188
+ /** Decorate task markers - show checkbox widget or raw text based on cursor */
189
+ private decorateTaskMarker;
190
+ /** Render list nodes to HTML */
191
+ renderToHTML(node: SyntaxNode, children: string, ctx: {
192
+ sliceDoc(from: number, to: number): string;
193
+ sanitize(html: string): string;
194
+ }): string | null;
195
+ }
196
+
197
+ interface PreviewContextLike {
198
+ sliceDoc(from: number, to: number): string;
199
+ sanitize(html: string): string;
200
+ }
201
+ declare class TablePlugin extends DecorationPlugin {
202
+ readonly name = "table";
203
+ readonly version = "2.0.0";
204
+ decorationPriority: number;
205
+ readonly requiredNodes: readonly ["Table", "TableHeader", "TableDelimiter", "TableRow", "TableCell"];
206
+ private mardoraConfig;
207
+ private pendingNormalizationView;
208
+ private pendingPaddingView;
209
+ private pendingSelectionRepairView;
210
+ /** Stores the editor config for preview rendering and shared behavior. */
211
+ onRegister(context: PluginContext): void;
212
+ /** Exposes the plugin theme used for editor and preview styling. */
213
+ get theme(): (themeEnum: ThemeEnum) => ThemeStyle;
214
+ /** Enables GFM table parsing for the editor and preview renderer. */
215
+ getMarkdownConfig(): MarkdownConfig;
216
+ /** Registers block wrappers and atomic ranges for the table UI. */
217
+ getExtensions(): Extension[];
218
+ /** Provides the table-specific keyboard shortcuts and navigation. */
219
+ getKeymap(): KeyBinding[];
220
+ /** Builds the high-priority key bindings used inside tables. */
221
+ private buildTableKeymap;
222
+ /** Schedules an initial normalization pass once the view is ready. */
223
+ onViewReady(view: EditorView): void;
224
+ /** Re-schedules normalization after user-driven document changes. */
225
+ onViewUpdate(update: _codemirror_view.ViewUpdate): void;
226
+ /** Intercepts table-specific DOM key handling before browser defaults run. */
227
+ private handleDomKeydown;
228
+ /** Maps a single pointer-down on rendered table cells back to the editable markdown cell content. */
229
+ private handleTableMouseDown;
230
+ /** Builds the visual table decorations for every parsed table block. */
231
+ buildDecorations(ctx: DecorationContext): void;
232
+ /** Renders the full table node to semantic preview HTML. */
233
+ renderToHTML(node: SyntaxNode, _children: string, ctx: PreviewContextLike): Promise<string | null>;
234
+ /** Computes the block wrapper ranges used to group table lines. */
235
+ private computeBlockWrappers;
236
+ /** Computes atomic ranges for delimiters and inline break tags. */
237
+ private computeAtomicRanges;
238
+ /** Applies row, cell, and control decorations for a single table. */
239
+ private decorateTable;
240
+ /** Draws an explicit caret inside table cells because table layout can hide CodeMirror's native cursor. */
241
+ private decorateTableCaret;
242
+ /** Applies the visual cell decorations for a single table row line. */
243
+ private decorateLine;
244
+ /** Normalizes every parsed table block back into canonical markdown. */
245
+ private normalizeTables;
246
+ /** Defers table normalization until the current update cycle is finished. */
247
+ private scheduleNormalization;
248
+ /** Adds missing spacer lines above and below tables after edits. */
249
+ private ensureTablePadding;
250
+ /** Schedules a padding-only pass after the current update cycle finishes. */
251
+ private schedulePadding;
252
+ /** Repairs carets that land in hidden table markup instead of editable cell content. */
253
+ private ensureTableSelection;
254
+ /** Schedules table selection repair after the current update finishes. */
255
+ private scheduleSelectionRepair;
256
+ /** Rewrites a table block and restores the caret to a target cell position. */
257
+ private replaceTable;
258
+ /** Runs a row or column control action by rewriting the active markdown table. */
259
+ private runTableControlAction;
260
+ /** Inserts an empty body row below the given logical row index. */
261
+ private insertRowBelow;
262
+ /** Inserts a starter table near the current cursor line. */
263
+ private insertTable;
264
+ /** Adds a new empty body row to the active table. */
265
+ private addRow;
266
+ /** Appends a row and keeps the caret in the requested column. */
267
+ private appendRow;
268
+ /** Inserts a new column after the current column. */
269
+ private addColumn;
270
+ /** Appends a new column at the far right of the table. */
271
+ private appendColumn;
272
+ /** Removes the current body row or clears the last remaining row. */
273
+ private removeRow;
274
+ /** Removes the current column when the table has more than one column. */
275
+ private removeColumn;
276
+ /** Moves to the next or previous logical cell with Tab navigation. */
277
+ private handleTab;
278
+ /** Moves horizontally between adjacent cells when the caret hits an edge. */
279
+ private handleArrowHorizontal;
280
+ /** Moves vertically between rows while keeping the current column. */
281
+ private handleArrowVertical;
282
+ /** Advances downward on Enter and manages the trailing empty row behavior. */
283
+ private handleEnter;
284
+ /** Inserts a canonical `<br />` token inside the current table cell. */
285
+ private insertBreakTag;
286
+ /** Deletes a whole `<br />` token when backspace or delete hits it. */
287
+ private handleBreakDeletion;
288
+ /** Moves the current selection anchor into a target cell. */
289
+ private moveSelectionToCell;
290
+ /** Returns the table currently containing the editor cursor. */
291
+ private getTableAtCursor;
292
+ /** Returns the active cell under the current selection head. */
293
+ private getCurrentCell;
294
+ }
295
+
296
+ /**
297
+ * HTMLPlugin - Decorates and Renders HTML in markdown
298
+ */
299
+ declare class HTMLPlugin extends DecorationPlugin {
300
+ readonly name = "html";
301
+ readonly version = "1.0.0";
302
+ decorationPriority: number;
303
+ constructor();
304
+ /**
305
+ * Plugin theme
306
+ */
307
+ get theme(): (theme: ThemeEnum) => ThemeStyle;
308
+ buildDecorations(ctx: DecorationContext): void;
309
+ }
310
+
311
+ /**
312
+ * ImagePlugin - Decorates and renders images in markdown
313
+ *
314
+ * Supports the full image syntax: ![alt text](url "optional title")
315
+ * - Shows image widget below the node when cursor is not in range
316
+ * - Hides the markdown syntax when cursor is not in range
317
+ * - Shows raw markdown when cursor is in the image syntax
318
+ * - Uses figure/figcaption for semantic HTML with accessibility attributes
319
+ */
320
+ declare class ImagePlugin extends DecorationPlugin {
321
+ readonly name = "image";
322
+ readonly version = "1.0.0";
323
+ decorationPriority: number;
324
+ readonly requiredNodes: readonly ["Image"];
325
+ constructor();
326
+ /**
327
+ * Plugin theme
328
+ */
329
+ get theme(): (theme: Parameters<typeof imageTheme>[0]) => {
330
+ [x: string]: style_mod.StyleSpec;
331
+ };
332
+ /**
333
+ * Keyboard shortcuts for image formatting
334
+ */
335
+ getKeymap(): KeyBinding[];
336
+ /**
337
+ * URL regex pattern
338
+ */
339
+ private readonly urlPattern;
340
+ /**
341
+ * Toggle image on selection
342
+ * - If text selected and is a URL: ![Alt Text](url) with cursor in brackets
343
+ * - If text selected (not URL): ![text]() with cursor in parentheses
344
+ * - If nothing selected: ![Alt Text]() with cursor in parentheses
345
+ * - If already an image: remove syntax, leave just the URL
346
+ */
347
+ private toggleImage;
348
+ buildDecorations(ctx: DecorationContext): void;
349
+ /**
350
+ * Decorate raw image markdown when cursor is in range
351
+ */
352
+ private decorateRawImage;
353
+ /**
354
+ * Render image to HTML for preview mode using figure/figcaption
355
+ */
356
+ renderToHTML(node: SyntaxNode, _children: string, ctx: PreviewContext): string | null;
357
+ getPreviewConsumedTo(node: SyntaxNode, ctx: {
358
+ doc: string;
359
+ }): number | null;
360
+ }
361
+ /**
362
+ * Theme for image styling
363
+ */
364
+ declare const imageTheme: (theme: ThemeEnum) => ThemeStyle;
365
+
366
+ /**
367
+ * MathPlugin - Renders LaTeX math expressions using KaTeX
368
+ *
369
+ * Supports:
370
+ * - Inline math: $E = mc^2$
371
+ * - Block math (display mode):
372
+ * $$
373
+ * \int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
374
+ * $$
375
+ *
376
+ * Behavior:
377
+ * - Inline math: Show rendered output when cursor outside, raw LaTeX when inside
378
+ * - Block math: Always show rendered output below, hide raw when cursor outside (like ImagePlugin)
379
+ */
380
+ declare class MathPlugin extends DecorationPlugin {
381
+ readonly name = "math";
382
+ readonly version = "1.0.0";
383
+ decorationPriority: number;
384
+ readonly requiredNodes: readonly ["InlineMath", "MathBlock", "InlineMathMark", "MathBlockMark"];
385
+ constructor();
386
+ /**
387
+ * Plugin theme
388
+ */
389
+ get theme(): (theme: ThemeEnum) => ThemeStyle;
390
+ /**
391
+ * Intercepts dollar typing to wrap selected text as inline math.
392
+ *
393
+ * If user types '$' while text is selected, wraps each selected range
394
+ * with single dollars (selected -> $selected$).
395
+ */
396
+ getExtensions(): Extension[];
397
+ /**
398
+ * Return markdown parser extensions for math syntax
399
+ */
400
+ getMarkdownConfig(): MarkdownConfig;
401
+ /**
402
+ * Build decorations for math expressions
403
+ */
404
+ buildDecorations(ctx: DecorationContext): void;
405
+ /**
406
+ * Render math to HTML for preview mode
407
+ */
408
+ renderToHTML(node: SyntaxNode, _children: string, ctx: {
409
+ sliceDoc(from: number, to: number): string;
410
+ sanitize(html: string): string;
411
+ }): string | null;
412
+ }
413
+
414
+ /**
415
+ * MermaidPlugin - Renders mermaid diagrams in the editor
416
+ *
417
+ * Supports block mermaid syntax:
418
+ * ```mermaid
419
+ * graph TD
420
+ * A --> B
421
+ * ```
422
+ *
423
+ * Behavior:
424
+ * - Always show rendered diagram below the block
425
+ * - Hide raw definition when cursor is outside the block
426
+ * - Show raw definition with styled markers when cursor is inside
427
+ */
428
+ declare class MermaidPlugin extends DecorationPlugin {
429
+ readonly name = "mermaid";
430
+ readonly version = "1.0.0";
431
+ decorationPriority: number;
432
+ readonly requiredNodes: readonly ["MermaidBlock", "MermaidBlockMark"];
433
+ constructor();
434
+ /**
435
+ * Plugin theme
436
+ */
437
+ get theme(): (theme: Parameters<typeof mermaidTheme>[0]) => {
438
+ [x: string]: style_mod.StyleSpec;
439
+ };
440
+ /**
441
+ * Return markdown parser extensions for mermaid syntax
442
+ */
443
+ getMarkdownConfig(): MarkdownConfig;
444
+ /**
445
+ * Build decorations for mermaid blocks
446
+ */
447
+ buildDecorations(ctx: DecorationContext): void;
448
+ /**
449
+ * Render mermaid to HTML for preview mode
450
+ *
451
+ * Renders the actual mermaid diagram to SVG HTML
452
+ */
453
+ renderToHTML(node: SyntaxNode, _children: string, ctx: {
454
+ sliceDoc(from: number, to: number): string;
455
+ sanitize(html: string): string;
456
+ }): Promise<string | null>;
457
+ }
458
+ /**
459
+ * Theme for mermaid styling
460
+ */
461
+ declare const mermaidTheme: (theme: ThemeEnum) => ThemeStyle;
462
+
463
+ /** Checkmark icon SVG (success state) */
464
+ declare const CODE_COPY_SUCCESS_ICON = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-check-icon lucide-check\"><path d=\"M20 6 9 17l-5-5\"></path></svg>";
465
+ declare function encodeCodeCopyPayload(code: string): string;
466
+ declare function decodeCodeCopyPayload(payload: string): string;
467
+ declare function copyCodeTextToClipboard(text: string, documentRef?: Document | undefined): Promise<void>;
468
+ declare function bindCodeCopyButtons(root: HTMLElement | Document): () => void;
469
+ interface PreviewRenderContext {
470
+ sliceDoc(from: number, to: number): string;
471
+ sanitize(html: string): string;
472
+ syntaxHighlighters?: readonly Highlighter[];
473
+ }
474
+ /**
475
+ * Text highlight definition
476
+ * Matches text or regex patterns with optional instance selection
477
+ */
478
+ interface TextHighlight {
479
+ /** The pattern to match (regex without slashes) */
480
+ pattern: string;
481
+ /** Specific instances to highlight (e.g., [3,5] or range [3,4,5]) */
482
+ instances?: number[];
483
+ }
484
+ /**
485
+ * Properties extracted from CodeInfo string
486
+ *
487
+ * Example: ```tsx line-numbers{5} title="hello.tsx" caption="Example" copy {2-4,5} /Hello/3-5
488
+ */
489
+ interface CodeBlockProperties {
490
+ /** Language identifier (first token) */
491
+ language: string;
492
+ /** Show line numbers, optionally starting from a specific number */
493
+ showLineNumbers?: number | boolean;
494
+ /** Title to display */
495
+ title?: string;
496
+ /** Caption to display */
497
+ caption?: string;
498
+ /** Show copy button */
499
+ copy?: boolean;
500
+ /** Enable diff preview mode */
501
+ diff?: boolean;
502
+ /** Lines to highlight (e.g., [2,3,4,5,9]) */
503
+ highlightLines?: number[];
504
+ /** Text patterns to highlight with optional instance selection */
505
+ highlightText?: TextHighlight[];
506
+ }
507
+ /**
508
+ * CodePlugin - Handles inline code and fenced code blocks.
509
+ *
510
+ * **Inline code:** `code`
511
+ * Hides backticks when cursor is not in range.
512
+ *
513
+ * **Fenced code blocks:**
514
+ * Supports syntax highlighting, line numbers, line/text highlighting,
515
+ * title, caption, and copy button via CodeInfo properties.
516
+ *
517
+ * @example
518
+ * ```tsx line-numbers{5} title="example.tsx" {2-4} /pattern/
519
+ * const x = 1;
520
+ * ```
521
+ */
522
+ declare class CodePlugin extends DecorationPlugin {
523
+ readonly name = "code";
524
+ readonly version = "1.0.0";
525
+ decorationPriority: number;
526
+ readonly requiredNodes: readonly ["InlineCode", "FencedCode", "CodeMark", "CodeInfo", "CodeText"];
527
+ private readonly parserCache;
528
+ /**
529
+ * Plugin theme
530
+ */
531
+ get theme(): (theme: ThemeEnum) => ThemeStyle;
532
+ /**
533
+ * Keyboard shortcuts for code formatting
534
+ */
535
+ getKeymap(): KeyBinding[];
536
+ /**
537
+ * Intercepts backtick typing to wrap selected text as inline code.
538
+ *
539
+ * If user types '`' while text is selected, wraps each selected range
540
+ * with backticks (selected -> `selected`).
541
+ */
542
+ getExtensions(): Extension[];
543
+ /**
544
+ * Toggle code block on current line or selected lines
545
+ */
546
+ private toggleCodeBlock;
547
+ /**
548
+ * Parse CodeInfo string into structured properties
549
+ *
550
+ * @param codeInfo - The raw CodeInfo string (e.g., "tsx line-numbers{5} title=\"hello.tsx\" copy {2-4,5} /Hello/3-5")
551
+ * @returns Parsed CodeBlockProperties object
552
+ *
553
+ * @example
554
+ * ```typescript
555
+ * parseCodeInfo("tsx line-numbers{5} title=\"hello.tsx\" copy {2-4,5} /Hello/3-5")
556
+ * ```
557
+ *
558
+ * Returns:
559
+ * ```json
560
+ * {
561
+ * language: "tsx",
562
+ * lineNumbers: 5,
563
+ * title: "hello.tsx",
564
+ * copy: true,
565
+ * diff: false,
566
+ * highlightLines: [2,3,4,5],
567
+ * highlightText: [{ pattern: "Hello", instances: [3,4,5] }]
568
+ * }
569
+ * ```
570
+ */
571
+ parseCodeInfo(codeInfo: string): CodeBlockProperties;
572
+ /**
573
+ * Build decorations for inline code and fenced code blocks.
574
+ * Handles line numbers, highlights, header/caption widgets, and fence visibility.
575
+ */
576
+ buildDecorations(ctx: DecorationContext): void;
577
+ private decorateInlineCode;
578
+ private decorateFencedCode;
579
+ private decorateFenceMarkers;
580
+ private decorateDiffLine;
581
+ private decorateTextHighlights;
582
+ /**
583
+ * Render code elements to HTML for static preview.
584
+ * Applies syntax highlighting using @lezer/highlight.
585
+ */
586
+ renderToHTML(node: SyntaxNode, _children: string, ctx: PreviewRenderContext): Promise<string | null>;
587
+ /** Parse comma-separated numbers and ranges (e.g. "1,3-5") into [1,3,4,5]. */
588
+ private parseNumberList;
589
+ /**
590
+ * Highlight a single line of code using the language's Lezer parser.
591
+ * Falls back to sanitized plain text if the language is not supported.
592
+ */
593
+ private highlightCodeLines;
594
+ private resolveLanguageParser;
595
+ private normalizeLanguage;
596
+ private escapeHtml;
597
+ private escapeAttribute;
598
+ private analyzeDiffLines;
599
+ private computeDiffDisplayLineNumbers;
600
+ private parseDiffLineState;
601
+ private computeChangedRanges;
602
+ private renderDiffPreviewLine;
603
+ private applyRangesToHighlightedHTML;
604
+ /**
605
+ * Apply text highlights (regex patterns) to already syntax-highlighted HTML.
606
+ * Wraps matched patterns in `<mark>` elements.
607
+ */
608
+ private applyTextHighlights;
609
+ }
610
+
611
+ type CalloutLabel = "NOTE" | "TIP" | "IMPORTANT" | "WARNING" | "CAUTION";
612
+ type CalloutTitleInputTarget = {
613
+ anchor: number;
614
+ changes?: {
615
+ from: number;
616
+ insert: string;
617
+ };
618
+ };
619
+ type CalloutTypeChange = {
620
+ from: number;
621
+ to: number;
622
+ insert: CalloutLabel;
623
+ };
624
+ declare function resolveCalloutTitleInputTarget(state: EditorState, pos: number): CalloutTitleInputTarget | null;
625
+ declare function resolveCalloutTypeChange(state: EditorState, pos: number, nextLabel: CalloutLabel): CalloutTypeChange | null;
626
+ /**
627
+ * QuotePlugin - Decorates markdown blockquotes
628
+ *
629
+ * Adds visual styling to blockquotes (> prefixed lines)
630
+ * - Line decorations for indicating quote blocks with a left border
631
+ * - Mark decorations for quote content
632
+ * - Hides > markers when cursor is not in the blockquote
633
+ */
634
+ declare class QuotePlugin extends DecorationPlugin {
635
+ readonly name = "quote";
636
+ readonly version = "1.0.0";
637
+ decorationPriority: number;
638
+ readonly requiredNodes: readonly ["Blockquote", "QuoteMark"];
639
+ private calloutTypeMenu;
640
+ private calloutTypeMenuDocument;
641
+ /**
642
+ * Constructor - calls super constructor
643
+ */
644
+ constructor();
645
+ /**
646
+ * Plugin theme
647
+ */
648
+ get theme(): (theme: ThemeEnum) => ThemeStyle;
649
+ getExtensions(): Extension[];
650
+ onViewUpdate(update: _codemirror_view.ViewUpdate): void;
651
+ onUnregister(): void;
652
+ private handleKeyDown;
653
+ private handleCalloutTitleMouseDown;
654
+ private openCalloutTypeMenu;
655
+ private positionCalloutTypeMenu;
656
+ private readonly handleDocumentMouseDown;
657
+ private closeCalloutTypeMenu;
658
+ /**
659
+ * Build blockquote decorations by iterating the syntax tree
660
+ */
661
+ buildDecorations(ctx: DecorationContext): void;
662
+ private hideCalloutMarker;
663
+ /**
664
+ * Find and hide quote marks in every quoted line.
665
+ */
666
+ private hideQuoteMarks;
667
+ renderToHTML(node: SyntaxNode, children: string, ctx: {
668
+ sliceDoc(from: number, to: number): string;
669
+ }): string | null;
670
+ }
671
+
672
+ /**
673
+ * HRPlugin - Decorates markdown horizontal rules
674
+ *
675
+ * Adds visual styling to thematic breaks (---, ***, ___)
676
+ * - Line decoration that renders a centered horizontal line
677
+ * - Hides raw marker characters when the cursor is not on the line
678
+ */
679
+ declare class HRPlugin extends DecorationPlugin {
680
+ readonly name = "hr";
681
+ readonly version = "1.0.0";
682
+ decorationPriority: number;
683
+ readonly requiredNodes: readonly ["HorizontalRule"];
684
+ /**
685
+ * Constructor - calls super constructor
686
+ */
687
+ constructor();
688
+ /**
689
+ * Plugin theme
690
+ */
691
+ get theme(): (theme: ThemeEnum) => ThemeStyle;
692
+ /**
693
+ * Build horizontal rule decorations by iterating the syntax tree
694
+ */
695
+ buildDecorations(ctx: DecorationContext): void;
696
+ renderToHTML(node: SyntaxNode, _children: string): string | null;
697
+ }
698
+
699
+ /**
700
+ * EmojiPlugin - Decorates markdown emojis
701
+ *
702
+ * Parses and decorates emoji shortcodes like :smile:
703
+ * - Converts valid shortcodes to Unicode emoji when cursor is outside
704
+ * - Keeps raw shortcode visible while editing (cursor inside token)
705
+ */
706
+ declare class EmojiPlugin extends DecorationPlugin {
707
+ readonly name = "emoji";
708
+ readonly version = "1.0.0";
709
+ decorationPriority: number;
710
+ readonly requiredNodes: readonly ["Emoji", "EmojiMark"];
711
+ constructor();
712
+ /**
713
+ * Plugin theme
714
+ */
715
+ get theme(): (theme: ThemeEnum) => ThemeStyle;
716
+ /**
717
+ * Build emoji decorations by iterating the syntax tree
718
+ */
719
+ buildDecorations(ctx: DecorationContext): void;
720
+ renderToHTML(node: SyntaxNode, children: string, ctx: {
721
+ sliceDoc(from: number, to: number): string;
722
+ sanitize(html: string): string;
723
+ syntaxHighlighters?: readonly _lezer_highlight.Highlighter[];
724
+ }): string | null;
725
+ }
726
+
727
+ /**
728
+ * Default plugins
729
+ *
730
+ * This is the set of essential plugins
731
+ */
732
+ declare const essentialPlugins: MardoraPlugin[];
733
+ /**
734
+ * All plugins
735
+ *
736
+ * This is the set of all plugins available with mardora
737
+ */
738
+ declare const allPlugins: MardoraPlugin[];
739
+
740
+ export { CODE_COPY_SUCCESS_ICON, type CalloutLabel, type CalloutTitleInputTarget, type CalloutTypeChange, CodePlugin, EmojiPlugin, HRPlugin, HTMLPlugin, HeadingPlugin, ImagePlugin, InlinePlugin, LinkPlugin, ListPlugin, MathPlugin, MermaidPlugin, ParagraphPlugin, QuotePlugin, TablePlugin, allPlugins, bindCodeCopyButtons, copyCodeTextToClipboard, decodeCodeCopyPayload, encodeCodeCopyPayload, essentialPlugins, resolveCalloutTitleInputTarget, resolveCalloutTypeChange };