@meowdown/core 0.63.1 → 0.64.1
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 +25 -68
- package/dist/index.d.ts +352 -114
- package/dist/index.js +8044 -39
- package/dist/katex-chunk-CfdGokmi.js +3 -0
- package/dist/style.css +2 -0
- package/package.json +4 -4
- package/dist/katex-chunk-Ch7kgbXr.js +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -21,12 +21,18 @@ import { VirtualElement } from "@floating-ui/dom";
|
|
|
21
21
|
* - `lossy`: content changed - a non-blank line differs, or the re-parsed doc does.
|
|
22
22
|
*/
|
|
23
23
|
type RoundTripFidelity = 'exact' | 'normalizing' | 'lossy';
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Options for {@link checkRoundTrip}.
|
|
26
|
+
*/
|
|
25
27
|
interface CheckRoundTripOptions {
|
|
26
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Whether to handle a leading `---` frontmatter block. Off by default.
|
|
30
|
+
*/
|
|
27
31
|
frontmatter?: boolean;
|
|
28
32
|
}
|
|
29
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Classify how `markdown` survives the editor's parse-then-serialize round trip.
|
|
35
|
+
*/
|
|
30
36
|
declare function checkRoundTrip(markdown: string, options?: CheckRoundTripOptions): RoundTripFidelity;
|
|
31
37
|
//#endregion
|
|
32
38
|
//#region src/extensions/frontmatter.d.ts
|
|
@@ -175,19 +181,33 @@ declare function defineHTMLComment(): HTMLCommentExtension;
|
|
|
175
181
|
* (plus an optional trailing size comment) or a resolved wiki image embed.
|
|
176
182
|
*/
|
|
177
183
|
interface MdImageAttrs {
|
|
178
|
-
/**
|
|
184
|
+
/**
|
|
185
|
+
* The image destination, exactly as written in the source.
|
|
186
|
+
*/
|
|
179
187
|
src: string;
|
|
180
|
-
/**
|
|
188
|
+
/**
|
|
189
|
+
* The image alt text.
|
|
190
|
+
*/
|
|
181
191
|
alt: string;
|
|
182
|
-
/**
|
|
192
|
+
/**
|
|
193
|
+
* The image title, or `''` when the source has none.
|
|
194
|
+
*/
|
|
183
195
|
title: string;
|
|
184
|
-
/**
|
|
196
|
+
/**
|
|
197
|
+
* Display width in CSS pixels from the trailing comment, or `null`.
|
|
198
|
+
*/
|
|
185
199
|
width: number | null;
|
|
186
|
-
/**
|
|
200
|
+
/**
|
|
201
|
+
* Display height in CSS pixels from the trailing comment, or `null`.
|
|
202
|
+
*/
|
|
187
203
|
height: number | null;
|
|
188
|
-
/**
|
|
204
|
+
/**
|
|
205
|
+
* `wikiEmbed` when the source is `![[target]]`; otherwise `null`.
|
|
206
|
+
*/
|
|
189
207
|
syntax: 'wikiEmbed' | null;
|
|
190
|
-
/**
|
|
208
|
+
/**
|
|
209
|
+
* Original wiki-embed target used when persisting a resized image, or `null`.
|
|
210
|
+
*/
|
|
191
211
|
wikiTarget: string | null;
|
|
192
212
|
}
|
|
193
213
|
interface MdLinkTextAttrs {
|
|
@@ -202,11 +222,17 @@ interface MdWikilinkAttrs {
|
|
|
202
222
|
* `resolveFileLink` claimed as a file attachment, rendered as a file pill.
|
|
203
223
|
*/
|
|
204
224
|
interface MdFileAttrs {
|
|
205
|
-
/**
|
|
225
|
+
/**
|
|
226
|
+
* The link destination, exactly as written in the source.
|
|
227
|
+
*/
|
|
206
228
|
href: string;
|
|
207
|
-
/**
|
|
229
|
+
/**
|
|
230
|
+
* The display name: the raw label slice, or the `href` basename when the label is empty.
|
|
231
|
+
*/
|
|
208
232
|
name: string;
|
|
209
|
-
/**
|
|
233
|
+
/**
|
|
234
|
+
* The link title, or `''` when the source has none.
|
|
235
|
+
*/
|
|
210
236
|
title: string;
|
|
211
237
|
}
|
|
212
238
|
/**
|
|
@@ -214,34 +240,37 @@ interface MdFileAttrs {
|
|
|
214
240
|
* math expression, rendered by `MathMarkView`.
|
|
215
241
|
*/
|
|
216
242
|
interface MdMathAttrs {
|
|
217
|
-
/**
|
|
243
|
+
/**
|
|
244
|
+
* The TeX source between the dollar delimiters.
|
|
245
|
+
*/
|
|
218
246
|
formula: string;
|
|
219
247
|
}
|
|
220
|
-
/**
|
|
221
|
-
|
|
248
|
+
/**
|
|
249
|
+
* mdPack keys for units that store no extra data; their own marks carry it.
|
|
250
|
+
*/
|
|
251
|
+
type MdPackSimpleKey = 'bold' | 'italic' | 'code' | 'strike' | 'highlight' | 'autolink' | 'math' | 'wikilink' | 'image' | 'file';
|
|
222
252
|
/**
|
|
223
253
|
* Content-derived identity of one inline syntax unit. Adjacent units of the
|
|
224
254
|
* same kind are kept apart by it (so they do not merge into one mark run), and
|
|
225
255
|
* it stays stable when unrelated text in the block is edited, so editing one
|
|
226
256
|
* unit never re-marks the others. `data` carries the unit's parsed payload (a
|
|
227
|
-
* link's `href`/`title
|
|
228
|
-
*
|
|
257
|
+
* link's `href`/`title`) so callers read it off the mark instead of re-parsing
|
|
258
|
+
* the text. The parser sets `slot: 1` on a unit whose pack would otherwise
|
|
259
|
+
* equal the pack of the unit ending exactly where it starts; equal packs would
|
|
260
|
+
* merge the two units into one mark run and one mark view.
|
|
229
261
|
*/
|
|
230
|
-
type MdPackAttrs = {
|
|
262
|
+
type MdPackAttrs = ({
|
|
231
263
|
key: 'link';
|
|
232
264
|
data: {
|
|
233
265
|
href: string;
|
|
234
266
|
title: string;
|
|
235
267
|
reference?: true;
|
|
236
268
|
};
|
|
237
|
-
} | {
|
|
238
|
-
key: 'image';
|
|
239
|
-
data: {
|
|
240
|
-
src: string;
|
|
241
|
-
};
|
|
242
269
|
} | {
|
|
243
270
|
key: MdPackSimpleKey;
|
|
244
271
|
data?: null;
|
|
272
|
+
}) & {
|
|
273
|
+
slot?: 1 | null;
|
|
245
274
|
};
|
|
246
275
|
//#endregion
|
|
247
276
|
//#region src/utils/range.d.ts
|
|
@@ -252,7 +281,9 @@ interface PositionRange {
|
|
|
252
281
|
//#endregion
|
|
253
282
|
//#region src/extensions/get-link-unit-at.d.ts
|
|
254
283
|
interface LinkUnit {
|
|
255
|
-
/**
|
|
284
|
+
/**
|
|
285
|
+
* Whole inline link, reference link, or autolink range.
|
|
286
|
+
*/
|
|
256
287
|
unit: PositionRange;
|
|
257
288
|
/**
|
|
258
289
|
* The visible text of the link: the `[ ]` interior for a full link, the URL
|
|
@@ -261,13 +292,21 @@ interface LinkUnit {
|
|
|
261
292
|
* whose collapsed glyphs measure at bogus coordinates.
|
|
262
293
|
*/
|
|
263
294
|
text: PositionRange;
|
|
264
|
-
/**
|
|
295
|
+
/**
|
|
296
|
+
* Interior of `[ ]`. Absent for an autolink.
|
|
297
|
+
*/
|
|
265
298
|
label?: PositionRange;
|
|
266
|
-
/**
|
|
299
|
+
/**
|
|
300
|
+
* Interior of `( )`. What `updateLink` rewrites. Absent for an autolink.
|
|
301
|
+
*/
|
|
267
302
|
dest?: PositionRange;
|
|
268
|
-
/**
|
|
303
|
+
/**
|
|
304
|
+
* The link URL. Could be an empty string.
|
|
305
|
+
*/
|
|
269
306
|
href: string;
|
|
270
|
-
/**
|
|
307
|
+
/**
|
|
308
|
+
* The link title, unquoted. Could be an empty string.
|
|
309
|
+
*/
|
|
271
310
|
title: string;
|
|
272
311
|
}
|
|
273
312
|
/**
|
|
@@ -292,9 +331,13 @@ interface InsertLinkOptions {
|
|
|
292
331
|
wrapText?: boolean;
|
|
293
332
|
}
|
|
294
333
|
declare function insertLink({ href, title, wrapText }?: InsertLinkOptions): Command;
|
|
295
|
-
/**
|
|
334
|
+
/**
|
|
335
|
+
* Rewrite the `( ... )` of the link at the caret/selection.
|
|
336
|
+
*/
|
|
296
337
|
declare function updateLink(attrs: LinkAttrs): Command;
|
|
297
|
-
/**
|
|
338
|
+
/**
|
|
339
|
+
* Unwrap the link at the caret: keep the label text, drop the syntax.
|
|
340
|
+
*/
|
|
298
341
|
declare function removeLink(): Command;
|
|
299
342
|
declare function defineLinkCommands(): Extension<{
|
|
300
343
|
Commands: {
|
|
@@ -312,9 +355,13 @@ type LinkEditHandler = (options: LinkEditOptions) => void;
|
|
|
312
355
|
declare function defineLinkEditKeymap(onLinkEdit: LinkEditHandler): PlainExtension;
|
|
313
356
|
//#endregion
|
|
314
357
|
//#region src/extensions/pending-replacement.d.ts
|
|
315
|
-
/**
|
|
358
|
+
/**
|
|
359
|
+
* Where an accepted replacement lands relative to the source range.
|
|
360
|
+
*/
|
|
316
361
|
type PendingReplacementMode = 'replace' | 'append';
|
|
317
|
-
/**
|
|
362
|
+
/**
|
|
363
|
+
* How a pending replacement ended.
|
|
364
|
+
*/
|
|
318
365
|
type PendingReplacementOutcome = 'accepted' | 'discarded';
|
|
319
366
|
/**
|
|
320
367
|
* A staged replacement: Markdown text accumulating over `[from, to]` that is
|
|
@@ -322,27 +369,45 @@ type PendingReplacementOutcome = 'accepted' | 'discarded';
|
|
|
322
369
|
* untouched; discarding is a no-op.
|
|
323
370
|
*/
|
|
324
371
|
interface PendingReplacement {
|
|
325
|
-
/**
|
|
372
|
+
/**
|
|
373
|
+
* Start of the source range the replacement targets.
|
|
374
|
+
*/
|
|
326
375
|
from: number;
|
|
327
|
-
/**
|
|
376
|
+
/**
|
|
377
|
+
* End of the source range the replacement targets.
|
|
378
|
+
*/
|
|
328
379
|
to: number;
|
|
329
|
-
/**
|
|
380
|
+
/**
|
|
381
|
+
* The Markdown accumulated so far (e.g. streamed from an AI provider).
|
|
382
|
+
*/
|
|
330
383
|
text: string;
|
|
331
|
-
/**
|
|
384
|
+
/**
|
|
385
|
+
* Whether accepting replaces the source range or inserts after its block.
|
|
386
|
+
*/
|
|
332
387
|
mode: PendingReplacementMode;
|
|
333
388
|
}
|
|
334
|
-
/**
|
|
389
|
+
/**
|
|
390
|
+
* The active pending replacement, or null when there is none.
|
|
391
|
+
*/
|
|
335
392
|
declare function getPendingReplacement(state: EditorState): PendingReplacement | null;
|
|
336
|
-
/**
|
|
393
|
+
/**
|
|
394
|
+
* Options for the `startPendingReplacement` command.
|
|
395
|
+
*/
|
|
337
396
|
interface StartPendingReplacementOptions extends PositionRange {
|
|
338
397
|
mode: PendingReplacementMode;
|
|
339
398
|
}
|
|
340
|
-
/**
|
|
399
|
+
/**
|
|
400
|
+
* Options for the `acceptPendingReplacement` command.
|
|
401
|
+
*/
|
|
341
402
|
interface AcceptPendingReplacementOptions {
|
|
342
|
-
/**
|
|
403
|
+
/**
|
|
404
|
+
* Overrides the staged mode for this accept (e.g. "Insert below" on a replace stage).
|
|
405
|
+
*/
|
|
343
406
|
mode?: PendingReplacementMode;
|
|
344
407
|
}
|
|
345
|
-
/**
|
|
408
|
+
/**
|
|
409
|
+
* A pending-replacement change: text/range updates, or how the stage ended.
|
|
410
|
+
*/
|
|
346
411
|
type PendingReplacementEvent = {
|
|
347
412
|
type: 'update';
|
|
348
413
|
pending: PendingReplacement;
|
|
@@ -378,37 +443,63 @@ interface ReferenceDefinitionIndex {
|
|
|
378
443
|
declare function collectReferenceDefinitions(doc: EditorNode): ReferenceDefinitionIndex;
|
|
379
444
|
//#endregion
|
|
380
445
|
//#region src/extensions/wiki-embed.d.ts
|
|
381
|
-
/**
|
|
446
|
+
/**
|
|
447
|
+
* The parsed source payload of an Obsidian-style `![[target]]` embed.
|
|
448
|
+
*/
|
|
382
449
|
interface ParsedWikiEmbed {
|
|
383
|
-
/**
|
|
450
|
+
/**
|
|
451
|
+
* Target before an optional alias or size suffix.
|
|
452
|
+
*/
|
|
384
453
|
target: string;
|
|
385
|
-
/**
|
|
454
|
+
/**
|
|
455
|
+
* Non-size suffix after `|`, or `''` when absent.
|
|
456
|
+
*/
|
|
386
457
|
display: string;
|
|
387
|
-
/**
|
|
458
|
+
/**
|
|
459
|
+
* Requested display width in CSS pixels, or `null`.
|
|
460
|
+
*/
|
|
388
461
|
width: number | null;
|
|
389
|
-
/**
|
|
462
|
+
/**
|
|
463
|
+
* Requested display height in CSS pixels, or `null`.
|
|
464
|
+
*/
|
|
390
465
|
height: number | null;
|
|
391
466
|
}
|
|
392
|
-
/**
|
|
467
|
+
/**
|
|
468
|
+
* A resolved wiki embed rendered through Meowdown's existing atom views.
|
|
469
|
+
*/
|
|
393
470
|
type WikiEmbedResolution = {
|
|
394
471
|
kind: 'image';
|
|
395
|
-
/**
|
|
472
|
+
/**
|
|
473
|
+
* Source passed to `resolveImageUrl` and image click handlers. Defaults to `target`.
|
|
474
|
+
*/
|
|
396
475
|
src?: string;
|
|
397
|
-
/**
|
|
476
|
+
/**
|
|
477
|
+
* Image alt text. Defaults to the alias or target basename.
|
|
478
|
+
*/
|
|
398
479
|
alt?: string;
|
|
399
480
|
} | {
|
|
400
481
|
kind: 'file';
|
|
401
|
-
/**
|
|
482
|
+
/**
|
|
483
|
+
* Destination passed to file metadata and click handlers. Defaults to `target`.
|
|
484
|
+
*/
|
|
402
485
|
href?: string;
|
|
403
|
-
/**
|
|
486
|
+
/**
|
|
487
|
+
* File pill label. Defaults to the alias or target basename.
|
|
488
|
+
*/
|
|
404
489
|
name?: string;
|
|
405
|
-
/**
|
|
490
|
+
/**
|
|
491
|
+
* Optional file title.
|
|
492
|
+
*/
|
|
406
493
|
title?: string;
|
|
407
494
|
} | {
|
|
408
495
|
kind: 'note';
|
|
409
|
-
/**
|
|
496
|
+
/**
|
|
497
|
+
* Target passed to wikilink click handlers. Defaults to the source target.
|
|
498
|
+
*/
|
|
410
499
|
target?: string;
|
|
411
|
-
/**
|
|
500
|
+
/**
|
|
501
|
+
* Chip label. Defaults to the source alias or resolved target.
|
|
502
|
+
*/
|
|
412
503
|
display?: string;
|
|
413
504
|
};
|
|
414
505
|
/**
|
|
@@ -417,25 +508,41 @@ type WikiEmbedResolution = {
|
|
|
417
508
|
* so it must be pure: the same payload must always return the same result.
|
|
418
509
|
*/
|
|
419
510
|
type WikiEmbedResolver = (embed: ParsedWikiEmbed) => WikiEmbedResolution | undefined;
|
|
420
|
-
/**
|
|
511
|
+
/**
|
|
512
|
+
* Host options for wiki-embed parsing.
|
|
513
|
+
*/
|
|
421
514
|
interface WikiEmbedOptions {
|
|
422
515
|
resolveWikiEmbed?: WikiEmbedResolver;
|
|
423
516
|
}
|
|
424
|
-
/**
|
|
517
|
+
/**
|
|
518
|
+
* Parse `![[target]]`, `![[target|alias]]`, `![[target|width]]`, or `![[target|widthxheight]]`.
|
|
519
|
+
*/
|
|
425
520
|
declare function parseWikiEmbed(source: string): ParsedWikiEmbed;
|
|
426
|
-
/**
|
|
521
|
+
/**
|
|
522
|
+
* Rewrite a wiki image embed with a persisted display size.
|
|
523
|
+
*/
|
|
427
524
|
declare function formatSizedWikiEmbed(target: string, width: number, height: number): string;
|
|
428
|
-
/**
|
|
525
|
+
/**
|
|
526
|
+
* Last path component of a target, with a note heading/block fragment removed.
|
|
527
|
+
*/
|
|
429
528
|
declare function wikiEmbedBasename(target: string): string;
|
|
430
529
|
//#endregion
|
|
431
530
|
//#region src/extensions/inline-text-to-mark-chunks.d.ts
|
|
432
|
-
/**
|
|
531
|
+
/**
|
|
532
|
+
* What {@link FileLinkResolver} sees for one `[label](url)` link.
|
|
533
|
+
*/
|
|
433
534
|
interface FileLinkPayload {
|
|
434
|
-
/**
|
|
535
|
+
/**
|
|
536
|
+
* The link destination, exactly as written in the source.
|
|
537
|
+
*/
|
|
435
538
|
href: string;
|
|
436
|
-
/**
|
|
539
|
+
/**
|
|
540
|
+
* The raw label slice between the brackets; may be empty or contain nested syntax.
|
|
541
|
+
*/
|
|
437
542
|
label: string;
|
|
438
|
-
/**
|
|
543
|
+
/**
|
|
544
|
+
* The link title, or `''` when the source has none.
|
|
545
|
+
*/
|
|
439
546
|
title: string;
|
|
440
547
|
}
|
|
441
548
|
/**
|
|
@@ -446,18 +553,32 @@ interface FileLinkPayload {
|
|
|
446
553
|
* so the same input must always produce the same answer.
|
|
447
554
|
*/
|
|
448
555
|
type FileLinkResolver = (link: FileLinkPayload) => boolean;
|
|
449
|
-
/**
|
|
556
|
+
/**
|
|
557
|
+
* Host options that influence inline parsing.
|
|
558
|
+
*/
|
|
450
559
|
interface FileLinkOptions {
|
|
560
|
+
/**
|
|
561
|
+
* Claim `[label](url)` links as file attachments; see {@link FileLinkResolver}.
|
|
562
|
+
* Read once when the editor is created.
|
|
563
|
+
*/
|
|
451
564
|
resolveFileLink?: FileLinkResolver;
|
|
452
565
|
}
|
|
453
|
-
/**
|
|
566
|
+
/**
|
|
567
|
+
* Host options that influence source-backed inline atom parsing.
|
|
568
|
+
*/
|
|
454
569
|
type InlineMarkOptions = FileLinkOptions & WikiEmbedOptions;
|
|
455
570
|
interface InlineMarkContext {
|
|
456
|
-
/**
|
|
571
|
+
/**
|
|
572
|
+
* Effective document-wide definitions, keyed by normalized reference label.
|
|
573
|
+
*/
|
|
457
574
|
referenceDefinitions?: ReferenceDefinitions;
|
|
458
|
-
/**
|
|
575
|
+
/**
|
|
576
|
+
* Prevent this definition block's own label from resolving as a shortcut reference.
|
|
577
|
+
*/
|
|
459
578
|
isReferenceDefinition?: boolean;
|
|
460
|
-
/**
|
|
579
|
+
/**
|
|
580
|
+
* Receives every normalized key read by this block, including unresolved references.
|
|
581
|
+
*/
|
|
461
582
|
referencedKeys?: Set<string>;
|
|
462
583
|
}
|
|
463
584
|
/**
|
|
@@ -466,11 +587,17 @@ interface InlineMarkContext {
|
|
|
466
587
|
* Callers shift the chunks into the document's coordinate space.
|
|
467
588
|
*/
|
|
468
589
|
declare function inlineTextToMarkChunks(
|
|
469
|
-
/**
|
|
590
|
+
/**
|
|
591
|
+
* Typed mark builders bound to the target schema.
|
|
592
|
+
*/
|
|
470
593
|
marks: TypedMarkBuilders,
|
|
471
|
-
/**
|
|
594
|
+
/**
|
|
595
|
+
* The raw inline text of one textblock (no block prefix).
|
|
596
|
+
*/
|
|
472
597
|
text: string,
|
|
473
|
-
/**
|
|
598
|
+
/**
|
|
599
|
+
* Host options; omit for the default parse.
|
|
600
|
+
*/
|
|
474
601
|
options?: InlineMarkOptions): MarkChunk[];
|
|
475
602
|
declare function inlineTextToMarkChunksWithContext(marks: TypedMarkBuilders, text: string, options?: InlineMarkOptions, context?: InlineMarkContext): MarkChunk[];
|
|
476
603
|
//#endregion
|
|
@@ -681,15 +808,23 @@ type TypedEditor = Editor<EditorExtension>;
|
|
|
681
808
|
//#region src/extensions/schema.d.ts
|
|
682
809
|
type TypedNodeBuilders = ExtractNodeBuilders<EditorExtension>;
|
|
683
810
|
type TypedMarkBuilders = ExtractMarkBuilders<EditorExtension>;
|
|
684
|
-
/**
|
|
811
|
+
/**
|
|
812
|
+
* Typed mark builders bound to the shared schema.
|
|
813
|
+
*/
|
|
685
814
|
declare const getMarkBuilders: () => TypedMarkBuilders;
|
|
686
815
|
//#endregion
|
|
687
816
|
//#region src/converters/md-to-pm.d.ts
|
|
688
|
-
/**
|
|
817
|
+
/**
|
|
818
|
+
* Options for {@link markdownToDoc}.
|
|
819
|
+
*/
|
|
689
820
|
interface MarkdownToDocOptions {
|
|
690
|
-
/**
|
|
821
|
+
/**
|
|
822
|
+
* Node builders to build the document with. Defaults to the shared schema's builders.
|
|
823
|
+
*/
|
|
691
824
|
nodes?: TypedNodeBuilders;
|
|
692
|
-
/**
|
|
825
|
+
/**
|
|
826
|
+
* Whether to peel a leading `---` frontmatter block onto the doc's `frontmatter` attribute. Off by default.
|
|
827
|
+
*/
|
|
693
828
|
frontmatter?: boolean;
|
|
694
829
|
}
|
|
695
830
|
/**
|
|
@@ -709,9 +844,13 @@ interface MarkdownToDocOptions {
|
|
|
709
844
|
declare function markdownToDoc(markdown: string, options?: MarkdownToDocOptions): ProseMirrorNode;
|
|
710
845
|
//#endregion
|
|
711
846
|
//#region src/converters/pm-to-md.d.ts
|
|
712
|
-
/**
|
|
847
|
+
/**
|
|
848
|
+
* Options for {@link docToMarkdown}.
|
|
849
|
+
*/
|
|
713
850
|
interface DocToMarkdownOptions {
|
|
714
|
-
/**
|
|
851
|
+
/**
|
|
852
|
+
* Whether to serialize the doc's `frontmatter` attribute as a leading `---` block. Off by default.
|
|
853
|
+
*/
|
|
715
854
|
frontmatter?: boolean;
|
|
716
855
|
}
|
|
717
856
|
/**
|
|
@@ -747,7 +886,9 @@ declare function defineBulletAfterHeading(): PlainExtension;
|
|
|
747
886
|
* `tok-*` classes; the default theme colors them per color scheme.
|
|
748
887
|
*/
|
|
749
888
|
declare function defineCodeBlockSyntaxHighlight(): Extension;
|
|
750
|
-
/**
|
|
889
|
+
/**
|
|
890
|
+
* A highlighted span of code: `[from, to)` carries the `@lezer/highlight` classes.
|
|
891
|
+
*/
|
|
751
892
|
type CodeToken = readonly [from: number, to: number, classes: string];
|
|
752
893
|
/**
|
|
753
894
|
* Highlight `code` in `language` into `tok-*` token spans, the same classes the
|
|
@@ -790,17 +931,29 @@ interface EmbedDescriptor {
|
|
|
790
931
|
* keys the React element, so the embed never reloads.
|
|
791
932
|
*/
|
|
792
933
|
readonly key: string;
|
|
793
|
-
/**
|
|
934
|
+
/**
|
|
935
|
+
* The iframe `src`.
|
|
936
|
+
*/
|
|
794
937
|
readonly src: string;
|
|
795
|
-
/**
|
|
938
|
+
/**
|
|
939
|
+
* The iframe `title`.
|
|
940
|
+
*/
|
|
796
941
|
readonly title: string;
|
|
797
|
-
/**
|
|
942
|
+
/**
|
|
943
|
+
* The iframe `class`, e.g. `md-embed md-embed-tweet`.
|
|
944
|
+
*/
|
|
798
945
|
readonly className: string;
|
|
799
|
-
/**
|
|
946
|
+
/**
|
|
947
|
+
* The iframe `data-testid`.
|
|
948
|
+
*/
|
|
800
949
|
readonly testid: string;
|
|
801
|
-
/**
|
|
950
|
+
/**
|
|
951
|
+
* The iframe `allow` policy, when the embed needs one.
|
|
952
|
+
*/
|
|
802
953
|
readonly allow?: string;
|
|
803
|
-
/**
|
|
954
|
+
/**
|
|
955
|
+
* Whether the iframe is fullscreen-capable.
|
|
956
|
+
*/
|
|
804
957
|
readonly allowFullscreen?: boolean;
|
|
805
958
|
}
|
|
806
959
|
//#endregion
|
|
@@ -815,15 +968,23 @@ interface EmbedDescriptor {
|
|
|
815
968
|
declare function listenForTweetHeight(iframe: HTMLIFrameElement, onHeight?: (height: number) => void): () => void;
|
|
816
969
|
//#endregion
|
|
817
970
|
//#region src/extensions/embed.d.ts
|
|
818
|
-
/**
|
|
971
|
+
/**
|
|
972
|
+
* Detect a tweet/YouTube embed in an image `src`, or `undefined` for a plain image.
|
|
973
|
+
*/
|
|
819
974
|
declare function matchEmbed(src: string): EmbedDescriptor | undefined;
|
|
820
975
|
//#endregion
|
|
821
976
|
//#region src/extensions/exit-boundary.d.ts
|
|
822
|
-
/**
|
|
977
|
+
/**
|
|
978
|
+
* Payload for {@link ExitBoundaryHandler}.
|
|
979
|
+
*/
|
|
823
980
|
interface ExitBoundaryOptions {
|
|
824
|
-
/**
|
|
981
|
+
/**
|
|
982
|
+
* The boundary the caret would leave: `up` at the document start, `down` at the end.
|
|
983
|
+
*/
|
|
825
984
|
direction: 'up' | 'down';
|
|
826
|
-
/**
|
|
985
|
+
/**
|
|
986
|
+
* The originating arrow key press.
|
|
987
|
+
*/
|
|
827
988
|
event: KeyboardEvent;
|
|
828
989
|
}
|
|
829
990
|
/**
|
|
@@ -832,15 +993,23 @@ interface ExitBoundaryOptions {
|
|
|
832
993
|
* other return value consumes it.
|
|
833
994
|
*/
|
|
834
995
|
type ExitBoundaryHandler = (options: ExitBoundaryOptions) => boolean | void;
|
|
835
|
-
/**
|
|
996
|
+
/**
|
|
997
|
+
* Call `onExitBoundary` when an arrow key press would leave the document boundary.
|
|
998
|
+
*/
|
|
836
999
|
declare function defineExitBoundaryHandler(onExitBoundary: ExitBoundaryHandler): PlainExtension;
|
|
837
1000
|
//#endregion
|
|
838
1001
|
//#region src/extensions/file-click.d.ts
|
|
839
|
-
/**
|
|
1002
|
+
/**
|
|
1003
|
+
* Payload for {@link FileClickHandler}.
|
|
1004
|
+
*/
|
|
840
1005
|
interface FileClickPayload {
|
|
841
|
-
/**
|
|
1006
|
+
/**
|
|
1007
|
+
* The resolved destination from `[name](href)` or a claimed `![[target]]`.
|
|
1008
|
+
*/
|
|
842
1009
|
href: string;
|
|
843
|
-
/**
|
|
1010
|
+
/**
|
|
1011
|
+
* The file name shown on the pill.
|
|
1012
|
+
*/
|
|
844
1013
|
name: string;
|
|
845
1014
|
/**
|
|
846
1015
|
* The originating click, or the `Enter`/`Mod-Enter` key press that followed the
|
|
@@ -859,7 +1028,9 @@ declare function defineFileClickHandler(onClick: FileClickHandler): PlainExtensi
|
|
|
859
1028
|
//#region src/extensions/file-paste.d.ts
|
|
860
1029
|
type FilePasteHandler = (file: File) => string | undefined | Promise<string | undefined>;
|
|
861
1030
|
type FileSaveErrorHandler = (error: unknown, file: File) => void;
|
|
862
|
-
/**
|
|
1031
|
+
/**
|
|
1032
|
+
* Options for {@link defineFilePaste}.
|
|
1033
|
+
*/
|
|
863
1034
|
interface FilePasteOptions {
|
|
864
1035
|
/**
|
|
865
1036
|
* Persist a pasted/dropped file and return its markdown destination, or
|
|
@@ -868,7 +1039,9 @@ interface FilePasteOptions {
|
|
|
868
1039
|
* inserts ``; any other file inserts a `[name](src)` link.
|
|
869
1040
|
*/
|
|
870
1041
|
onFilePaste?: FilePasteHandler;
|
|
871
|
-
/**
|
|
1042
|
+
/**
|
|
1043
|
+
* Called when persisting a pasted/dropped file throws. Defaults to `console.error`.
|
|
1044
|
+
*/
|
|
872
1045
|
onFileSaveError?: FileSaveErrorHandler;
|
|
873
1046
|
}
|
|
874
1047
|
/**
|
|
@@ -890,9 +1063,13 @@ declare function buildFileMarkdown(file: {
|
|
|
890
1063
|
declare function defineFilePaste(options?: FilePasteOptions): PlainExtension;
|
|
891
1064
|
//#endregion
|
|
892
1065
|
//#region src/extensions/file-view.d.ts
|
|
893
|
-
/**
|
|
1066
|
+
/**
|
|
1067
|
+
* Metadata a host resolves for one file link, shown on its pill.
|
|
1068
|
+
*/
|
|
894
1069
|
interface FileInfo {
|
|
895
|
-
/**
|
|
1070
|
+
/**
|
|
1071
|
+
* File size in bytes, shown as a human-readable suffix (e.g. `1.4 MB`).
|
|
1072
|
+
*/
|
|
896
1073
|
size?: number;
|
|
897
1074
|
}
|
|
898
1075
|
/**
|
|
@@ -903,12 +1080,18 @@ interface FileInfo {
|
|
|
903
1080
|
* resolve repeatedly: cache in the host when resolving is expensive.
|
|
904
1081
|
*/
|
|
905
1082
|
type FileInfoResolver = (href: string) => FileInfo | undefined | Promise<FileInfo | undefined>;
|
|
906
|
-
/**
|
|
1083
|
+
/**
|
|
1084
|
+
* Options for {@link defineFileView}.
|
|
1085
|
+
*/
|
|
907
1086
|
interface FileViewOptions {
|
|
908
|
-
/**
|
|
1087
|
+
/**
|
|
1088
|
+
* Resolve the metadata (file size) shown on a pill. Omit to show none.
|
|
1089
|
+
*/
|
|
909
1090
|
resolveFileInfo?: FileInfoResolver;
|
|
910
1091
|
}
|
|
911
|
-
/**
|
|
1092
|
+
/**
|
|
1093
|
+
* Classify a file destination for the pill's `data-file-kind` attribute.
|
|
1094
|
+
*/
|
|
912
1095
|
declare function getFileKind(href: string): string;
|
|
913
1096
|
/**
|
|
914
1097
|
* Render a claimed file link or wiki embed (the `mdFile` mark) as an inline
|
|
@@ -921,7 +1104,9 @@ declare function defineFileView(options?: FileViewOptions): PlainExtension;
|
|
|
921
1104
|
//#region src/extensions/link-click.d.ts
|
|
922
1105
|
interface LinkClickPayload {
|
|
923
1106
|
href: string;
|
|
924
|
-
/**
|
|
1107
|
+
/**
|
|
1108
|
+
* The originating click, or the `Enter`/`Mod-Enter` key press that followed the link.
|
|
1109
|
+
*/
|
|
925
1110
|
event: MouseEvent | KeyboardEvent;
|
|
926
1111
|
}
|
|
927
1112
|
type LinkClickHandler = (payload: LinkClickPayload) => void;
|
|
@@ -929,11 +1114,18 @@ interface LinkCopyPayload {
|
|
|
929
1114
|
href: string;
|
|
930
1115
|
}
|
|
931
1116
|
type LinkCopyHandler = (payload: LinkCopyPayload) => void;
|
|
1117
|
+
/**
|
|
1118
|
+
* Call `onClick` when the user clicks a rendered Markdown link
|
|
1119
|
+
* (`[text](url)`), or presses `Mod-Enter` with the caret on one. The `event`
|
|
1120
|
+
* is the originating `MouseEvent` or `KeyboardEvent`.
|
|
1121
|
+
*/
|
|
932
1122
|
declare function defineLinkClickHandler(onClick: LinkClickHandler): PlainExtension;
|
|
933
1123
|
//#endregion
|
|
934
1124
|
//#region src/extensions/tag-click.d.ts
|
|
935
1125
|
interface TagClickPayload {
|
|
936
|
-
/**
|
|
1126
|
+
/**
|
|
1127
|
+
* The tag name, without the leading `#`.
|
|
1128
|
+
*/
|
|
937
1129
|
tag: string;
|
|
938
1130
|
/**
|
|
939
1131
|
* The originating click, or the `Enter`/`Mod-Enter` key press that followed the tag.
|
|
@@ -942,6 +1134,11 @@ interface TagClickPayload {
|
|
|
942
1134
|
event: MouseEvent | KeyboardEvent;
|
|
943
1135
|
}
|
|
944
1136
|
type TagClickHandler = (payload: TagClickPayload) => void;
|
|
1137
|
+
/**
|
|
1138
|
+
* Call `onClick` when the user clicks a rendered `#tag`, or presses
|
|
1139
|
+
* `Mod-Enter` with the caret on one. The `tag` is read from the rendered text
|
|
1140
|
+
* without the leading `#`.
|
|
1141
|
+
*/
|
|
945
1142
|
declare function defineTagClickHandler(onClick: TagClickHandler): PlainExtension;
|
|
946
1143
|
//#endregion
|
|
947
1144
|
//#region src/extensions/wikilink-click.d.ts
|
|
@@ -952,10 +1149,17 @@ interface WikilinkHit {
|
|
|
952
1149
|
}
|
|
953
1150
|
interface WikilinkClickPayload {
|
|
954
1151
|
target: string;
|
|
955
|
-
/**
|
|
1152
|
+
/**
|
|
1153
|
+
* The originating click, or the `Enter`/`Mod-Enter` key press that followed the link.
|
|
1154
|
+
*/
|
|
956
1155
|
event: MouseEvent | KeyboardEvent;
|
|
957
1156
|
}
|
|
958
1157
|
type WikilinkClickHandler = (payload: WikilinkClickPayload) => void;
|
|
1158
|
+
/**
|
|
1159
|
+
* Call `onClick` when the user clicks a rendered wikilink label, or presses
|
|
1160
|
+
* `Mod-Enter` with the caret on one. The `event` is the originating
|
|
1161
|
+
* `MouseEvent` or `KeyboardEvent`.
|
|
1162
|
+
*/
|
|
959
1163
|
declare function defineWikilinkClickHandler(onClick: WikilinkClickHandler): PlainExtension;
|
|
960
1164
|
//#endregion
|
|
961
1165
|
//#region src/extensions/follow-link.d.ts
|
|
@@ -976,11 +1180,17 @@ interface FollowLinkHandlers {
|
|
|
976
1180
|
declare function defineFollowLinkHandler(handlers: FollowLinkHandlers): PlainExtension;
|
|
977
1181
|
//#endregion
|
|
978
1182
|
//#region src/extensions/image-click.d.ts
|
|
979
|
-
/**
|
|
1183
|
+
/**
|
|
1184
|
+
* Payload for {@link ImageClickHandler}.
|
|
1185
|
+
*/
|
|
980
1186
|
interface ImageClickPayload {
|
|
981
|
-
/**
|
|
1187
|
+
/**
|
|
1188
|
+
* The resolved source from `` or a claimed `![[target]]`.
|
|
1189
|
+
*/
|
|
982
1190
|
src: string;
|
|
983
|
-
/**
|
|
1191
|
+
/**
|
|
1192
|
+
* The image alt text.
|
|
1193
|
+
*/
|
|
984
1194
|
alt: string;
|
|
985
1195
|
/**
|
|
986
1196
|
* The originating click or touch tap. Read the target or position a popover
|
|
@@ -1004,7 +1214,9 @@ declare function defineImageClickHandler(onClick: ImageClickHandler): PlainExten
|
|
|
1004
1214
|
//#endregion
|
|
1005
1215
|
//#region src/extensions/image.d.ts
|
|
1006
1216
|
type ImageUrlResolver = (src: string) => string | undefined;
|
|
1007
|
-
/**
|
|
1217
|
+
/**
|
|
1218
|
+
* Options for {@link defineImage}.
|
|
1219
|
+
*/
|
|
1008
1220
|
interface ImageOptions {
|
|
1009
1221
|
/**
|
|
1010
1222
|
* Map a markdown `src` to a displayable URL, or `undefined` to skip rendering
|
|
@@ -1019,13 +1231,23 @@ interface ImageOptions {
|
|
|
1019
1231
|
*/
|
|
1020
1232
|
persistTweetHeight?: boolean;
|
|
1021
1233
|
}
|
|
1022
|
-
/**
|
|
1234
|
+
/**
|
|
1235
|
+
* Show an `src` as-is when it is an http(s) URL, otherwise skip rendering it.
|
|
1236
|
+
*/
|
|
1023
1237
|
declare function defaultResolveImageUrl(src: string): string | undefined;
|
|
1024
|
-
/**
|
|
1238
|
+
/**
|
|
1239
|
+
* Inline image/embed rendering: a mark view on the `mdImage` mark. Images
|
|
1240
|
+
* render in place from their literal Markdown source. Drag a rendered image's
|
|
1241
|
+
* corner handle to write the size back into the source as a trailing comment,
|
|
1242
|
+
* `<!-- {"width":320,"height":240} -->`, which round-trips as
|
|
1243
|
+
* plain Markdown.
|
|
1244
|
+
*/
|
|
1025
1245
|
declare function defineImage(options?: ImageOptions): PlainExtension;
|
|
1026
1246
|
//#endregion
|
|
1027
1247
|
//#region src/extensions/key-bindings.d.ts
|
|
1028
|
-
/**
|
|
1248
|
+
/**
|
|
1249
|
+
* Human-readable descriptions of the editor's formatting and heading shortcuts.
|
|
1250
|
+
*/
|
|
1029
1251
|
declare const EDITOR_KEY_BINDINGS: {
|
|
1030
1252
|
readonly 'Mod-b': "Bold";
|
|
1031
1253
|
readonly 'Mod-i': "Italic";
|
|
@@ -1087,7 +1309,9 @@ type MarkName = (typeof MARK_NAMES)[number];
|
|
|
1087
1309
|
declare function isMarkOfType(mark: Mark, name: MarkName): boolean;
|
|
1088
1310
|
//#endregion
|
|
1089
1311
|
//#region src/extensions/math.d.ts
|
|
1090
|
-
/**
|
|
1312
|
+
/**
|
|
1313
|
+
* Inline math rendering: a KaTeX preview on the `mdMath` mark.
|
|
1314
|
+
*/
|
|
1091
1315
|
declare function defineMath(): PlainExtension;
|
|
1092
1316
|
//#endregion
|
|
1093
1317
|
//#region src/extensions/node-names.d.ts
|
|
@@ -1102,7 +1326,9 @@ declare function isNodeOfType(node: ProseMirrorNode, name: NodeName): boolean;
|
|
|
1102
1326
|
declare function defineSpellCheckPlugin(spellCheck: boolean): PlainExtension;
|
|
1103
1327
|
//#endregion
|
|
1104
1328
|
//#region src/extensions/substitution.d.ts
|
|
1105
|
-
/**
|
|
1329
|
+
/**
|
|
1330
|
+
* Apply the editor's automatic plain-text substitutions.
|
|
1331
|
+
*/
|
|
1106
1332
|
declare function defineSubstitution(): PlainExtension;
|
|
1107
1333
|
//#endregion
|
|
1108
1334
|
//#region src/extensions/table.d.ts
|
|
@@ -1131,6 +1357,12 @@ declare function defineViewAttributes(attributes: {
|
|
|
1131
1357
|
* so IME, clicks, and typing keep their native behavior; only the caret pixels
|
|
1132
1358
|
* are ours. Applies to every mark mode.
|
|
1133
1359
|
*
|
|
1360
|
+
* On a touch screen, while the last input was a finger or pen
|
|
1361
|
+
* ({@link getIsTouchInput}), the roles flip: the native caret stays visible
|
|
1362
|
+
* (it carries the system touch affordances: the drag magnifier, the caret-drag
|
|
1363
|
+
* long-press mode) and the virtual caret draws only at positions where the
|
|
1364
|
+
* native caret has no geometry, such as beside hidden Markdown syntax.
|
|
1365
|
+
*
|
|
1134
1366
|
* `layer` is the element the caret draws into. The host owns its placement:
|
|
1135
1367
|
* it must live outside the contenteditable and scroll together with the
|
|
1136
1368
|
* content.
|
|
@@ -1138,12 +1370,18 @@ declare function defineViewAttributes(attributes: {
|
|
|
1138
1370
|
declare function defineVirtualCaret(layer: HTMLElement): PlainExtension;
|
|
1139
1371
|
//#endregion
|
|
1140
1372
|
//#region src/extensions/wikilink-hover.d.ts
|
|
1141
|
-
/**
|
|
1373
|
+
/**
|
|
1374
|
+
* A wikilink currently under the pointer.
|
|
1375
|
+
*/
|
|
1142
1376
|
interface WikilinkHoverHit extends WikilinkHit {
|
|
1143
|
-
/**
|
|
1377
|
+
/**
|
|
1378
|
+
* The rendered wikilink label used as the popup anchor.
|
|
1379
|
+
*/
|
|
1144
1380
|
element: HTMLElement;
|
|
1145
1381
|
}
|
|
1146
|
-
/**
|
|
1382
|
+
/**
|
|
1383
|
+
* Called once on wikilink enter and with `undefined` on leave or invalidation.
|
|
1384
|
+
*/
|
|
1147
1385
|
type WikilinkHoverHandler = (hit: WikilinkHoverHit | undefined) => void;
|
|
1148
1386
|
/**
|
|
1149
1387
|
* Track the wikilink under the pointer without attaching per-link listeners.
|