@meowdown/core 0.64.0 → 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/dist/index.d.ts +320 -113
- package/dist/index.js +511 -278
- package/package.json +2 -2
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,7 +553,9 @@ 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 {
|
|
451
560
|
/**
|
|
452
561
|
* Claim `[label](url)` links as file attachments; see {@link FileLinkResolver}.
|
|
@@ -454,14 +563,22 @@ interface FileLinkOptions {
|
|
|
454
563
|
*/
|
|
455
564
|
resolveFileLink?: FileLinkResolver;
|
|
456
565
|
}
|
|
457
|
-
/**
|
|
566
|
+
/**
|
|
567
|
+
* Host options that influence source-backed inline atom parsing.
|
|
568
|
+
*/
|
|
458
569
|
type InlineMarkOptions = FileLinkOptions & WikiEmbedOptions;
|
|
459
570
|
interface InlineMarkContext {
|
|
460
|
-
/**
|
|
571
|
+
/**
|
|
572
|
+
* Effective document-wide definitions, keyed by normalized reference label.
|
|
573
|
+
*/
|
|
461
574
|
referenceDefinitions?: ReferenceDefinitions;
|
|
462
|
-
/**
|
|
575
|
+
/**
|
|
576
|
+
* Prevent this definition block's own label from resolving as a shortcut reference.
|
|
577
|
+
*/
|
|
463
578
|
isReferenceDefinition?: boolean;
|
|
464
|
-
/**
|
|
579
|
+
/**
|
|
580
|
+
* Receives every normalized key read by this block, including unresolved references.
|
|
581
|
+
*/
|
|
465
582
|
referencedKeys?: Set<string>;
|
|
466
583
|
}
|
|
467
584
|
/**
|
|
@@ -470,11 +587,17 @@ interface InlineMarkContext {
|
|
|
470
587
|
* Callers shift the chunks into the document's coordinate space.
|
|
471
588
|
*/
|
|
472
589
|
declare function inlineTextToMarkChunks(
|
|
473
|
-
/**
|
|
590
|
+
/**
|
|
591
|
+
* Typed mark builders bound to the target schema.
|
|
592
|
+
*/
|
|
474
593
|
marks: TypedMarkBuilders,
|
|
475
|
-
/**
|
|
594
|
+
/**
|
|
595
|
+
* The raw inline text of one textblock (no block prefix).
|
|
596
|
+
*/
|
|
476
597
|
text: string,
|
|
477
|
-
/**
|
|
598
|
+
/**
|
|
599
|
+
* Host options; omit for the default parse.
|
|
600
|
+
*/
|
|
478
601
|
options?: InlineMarkOptions): MarkChunk[];
|
|
479
602
|
declare function inlineTextToMarkChunksWithContext(marks: TypedMarkBuilders, text: string, options?: InlineMarkOptions, context?: InlineMarkContext): MarkChunk[];
|
|
480
603
|
//#endregion
|
|
@@ -685,15 +808,23 @@ type TypedEditor = Editor<EditorExtension>;
|
|
|
685
808
|
//#region src/extensions/schema.d.ts
|
|
686
809
|
type TypedNodeBuilders = ExtractNodeBuilders<EditorExtension>;
|
|
687
810
|
type TypedMarkBuilders = ExtractMarkBuilders<EditorExtension>;
|
|
688
|
-
/**
|
|
811
|
+
/**
|
|
812
|
+
* Typed mark builders bound to the shared schema.
|
|
813
|
+
*/
|
|
689
814
|
declare const getMarkBuilders: () => TypedMarkBuilders;
|
|
690
815
|
//#endregion
|
|
691
816
|
//#region src/converters/md-to-pm.d.ts
|
|
692
|
-
/**
|
|
817
|
+
/**
|
|
818
|
+
* Options for {@link markdownToDoc}.
|
|
819
|
+
*/
|
|
693
820
|
interface MarkdownToDocOptions {
|
|
694
|
-
/**
|
|
821
|
+
/**
|
|
822
|
+
* Node builders to build the document with. Defaults to the shared schema's builders.
|
|
823
|
+
*/
|
|
695
824
|
nodes?: TypedNodeBuilders;
|
|
696
|
-
/**
|
|
825
|
+
/**
|
|
826
|
+
* Whether to peel a leading `---` frontmatter block onto the doc's `frontmatter` attribute. Off by default.
|
|
827
|
+
*/
|
|
697
828
|
frontmatter?: boolean;
|
|
698
829
|
}
|
|
699
830
|
/**
|
|
@@ -713,9 +844,13 @@ interface MarkdownToDocOptions {
|
|
|
713
844
|
declare function markdownToDoc(markdown: string, options?: MarkdownToDocOptions): ProseMirrorNode;
|
|
714
845
|
//#endregion
|
|
715
846
|
//#region src/converters/pm-to-md.d.ts
|
|
716
|
-
/**
|
|
847
|
+
/**
|
|
848
|
+
* Options for {@link docToMarkdown}.
|
|
849
|
+
*/
|
|
717
850
|
interface DocToMarkdownOptions {
|
|
718
|
-
/**
|
|
851
|
+
/**
|
|
852
|
+
* Whether to serialize the doc's `frontmatter` attribute as a leading `---` block. Off by default.
|
|
853
|
+
*/
|
|
719
854
|
frontmatter?: boolean;
|
|
720
855
|
}
|
|
721
856
|
/**
|
|
@@ -751,7 +886,9 @@ declare function defineBulletAfterHeading(): PlainExtension;
|
|
|
751
886
|
* `tok-*` classes; the default theme colors them per color scheme.
|
|
752
887
|
*/
|
|
753
888
|
declare function defineCodeBlockSyntaxHighlight(): Extension;
|
|
754
|
-
/**
|
|
889
|
+
/**
|
|
890
|
+
* A highlighted span of code: `[from, to)` carries the `@lezer/highlight` classes.
|
|
891
|
+
*/
|
|
755
892
|
type CodeToken = readonly [from: number, to: number, classes: string];
|
|
756
893
|
/**
|
|
757
894
|
* Highlight `code` in `language` into `tok-*` token spans, the same classes the
|
|
@@ -794,17 +931,29 @@ interface EmbedDescriptor {
|
|
|
794
931
|
* keys the React element, so the embed never reloads.
|
|
795
932
|
*/
|
|
796
933
|
readonly key: string;
|
|
797
|
-
/**
|
|
934
|
+
/**
|
|
935
|
+
* The iframe `src`.
|
|
936
|
+
*/
|
|
798
937
|
readonly src: string;
|
|
799
|
-
/**
|
|
938
|
+
/**
|
|
939
|
+
* The iframe `title`.
|
|
940
|
+
*/
|
|
800
941
|
readonly title: string;
|
|
801
|
-
/**
|
|
942
|
+
/**
|
|
943
|
+
* The iframe `class`, e.g. `md-embed md-embed-tweet`.
|
|
944
|
+
*/
|
|
802
945
|
readonly className: string;
|
|
803
|
-
/**
|
|
946
|
+
/**
|
|
947
|
+
* The iframe `data-testid`.
|
|
948
|
+
*/
|
|
804
949
|
readonly testid: string;
|
|
805
|
-
/**
|
|
950
|
+
/**
|
|
951
|
+
* The iframe `allow` policy, when the embed needs one.
|
|
952
|
+
*/
|
|
806
953
|
readonly allow?: string;
|
|
807
|
-
/**
|
|
954
|
+
/**
|
|
955
|
+
* Whether the iframe is fullscreen-capable.
|
|
956
|
+
*/
|
|
808
957
|
readonly allowFullscreen?: boolean;
|
|
809
958
|
}
|
|
810
959
|
//#endregion
|
|
@@ -819,15 +968,23 @@ interface EmbedDescriptor {
|
|
|
819
968
|
declare function listenForTweetHeight(iframe: HTMLIFrameElement, onHeight?: (height: number) => void): () => void;
|
|
820
969
|
//#endregion
|
|
821
970
|
//#region src/extensions/embed.d.ts
|
|
822
|
-
/**
|
|
971
|
+
/**
|
|
972
|
+
* Detect a tweet/YouTube embed in an image `src`, or `undefined` for a plain image.
|
|
973
|
+
*/
|
|
823
974
|
declare function matchEmbed(src: string): EmbedDescriptor | undefined;
|
|
824
975
|
//#endregion
|
|
825
976
|
//#region src/extensions/exit-boundary.d.ts
|
|
826
|
-
/**
|
|
977
|
+
/**
|
|
978
|
+
* Payload for {@link ExitBoundaryHandler}.
|
|
979
|
+
*/
|
|
827
980
|
interface ExitBoundaryOptions {
|
|
828
|
-
/**
|
|
981
|
+
/**
|
|
982
|
+
* The boundary the caret would leave: `up` at the document start, `down` at the end.
|
|
983
|
+
*/
|
|
829
984
|
direction: 'up' | 'down';
|
|
830
|
-
/**
|
|
985
|
+
/**
|
|
986
|
+
* The originating arrow key press.
|
|
987
|
+
*/
|
|
831
988
|
event: KeyboardEvent;
|
|
832
989
|
}
|
|
833
990
|
/**
|
|
@@ -836,15 +993,23 @@ interface ExitBoundaryOptions {
|
|
|
836
993
|
* other return value consumes it.
|
|
837
994
|
*/
|
|
838
995
|
type ExitBoundaryHandler = (options: ExitBoundaryOptions) => boolean | void;
|
|
839
|
-
/**
|
|
996
|
+
/**
|
|
997
|
+
* Call `onExitBoundary` when an arrow key press would leave the document boundary.
|
|
998
|
+
*/
|
|
840
999
|
declare function defineExitBoundaryHandler(onExitBoundary: ExitBoundaryHandler): PlainExtension;
|
|
841
1000
|
//#endregion
|
|
842
1001
|
//#region src/extensions/file-click.d.ts
|
|
843
|
-
/**
|
|
1002
|
+
/**
|
|
1003
|
+
* Payload for {@link FileClickHandler}.
|
|
1004
|
+
*/
|
|
844
1005
|
interface FileClickPayload {
|
|
845
|
-
/**
|
|
1006
|
+
/**
|
|
1007
|
+
* The resolved destination from `[name](href)` or a claimed `![[target]]`.
|
|
1008
|
+
*/
|
|
846
1009
|
href: string;
|
|
847
|
-
/**
|
|
1010
|
+
/**
|
|
1011
|
+
* The file name shown on the pill.
|
|
1012
|
+
*/
|
|
848
1013
|
name: string;
|
|
849
1014
|
/**
|
|
850
1015
|
* The originating click, or the `Enter`/`Mod-Enter` key press that followed the
|
|
@@ -863,7 +1028,9 @@ declare function defineFileClickHandler(onClick: FileClickHandler): PlainExtensi
|
|
|
863
1028
|
//#region src/extensions/file-paste.d.ts
|
|
864
1029
|
type FilePasteHandler = (file: File) => string | undefined | Promise<string | undefined>;
|
|
865
1030
|
type FileSaveErrorHandler = (error: unknown, file: File) => void;
|
|
866
|
-
/**
|
|
1031
|
+
/**
|
|
1032
|
+
* Options for {@link defineFilePaste}.
|
|
1033
|
+
*/
|
|
867
1034
|
interface FilePasteOptions {
|
|
868
1035
|
/**
|
|
869
1036
|
* Persist a pasted/dropped file and return its markdown destination, or
|
|
@@ -872,7 +1039,9 @@ interface FilePasteOptions {
|
|
|
872
1039
|
* inserts ``; any other file inserts a `[name](src)` link.
|
|
873
1040
|
*/
|
|
874
1041
|
onFilePaste?: FilePasteHandler;
|
|
875
|
-
/**
|
|
1042
|
+
/**
|
|
1043
|
+
* Called when persisting a pasted/dropped file throws. Defaults to `console.error`.
|
|
1044
|
+
*/
|
|
876
1045
|
onFileSaveError?: FileSaveErrorHandler;
|
|
877
1046
|
}
|
|
878
1047
|
/**
|
|
@@ -894,9 +1063,13 @@ declare function buildFileMarkdown(file: {
|
|
|
894
1063
|
declare function defineFilePaste(options?: FilePasteOptions): PlainExtension;
|
|
895
1064
|
//#endregion
|
|
896
1065
|
//#region src/extensions/file-view.d.ts
|
|
897
|
-
/**
|
|
1066
|
+
/**
|
|
1067
|
+
* Metadata a host resolves for one file link, shown on its pill.
|
|
1068
|
+
*/
|
|
898
1069
|
interface FileInfo {
|
|
899
|
-
/**
|
|
1070
|
+
/**
|
|
1071
|
+
* File size in bytes, shown as a human-readable suffix (e.g. `1.4 MB`).
|
|
1072
|
+
*/
|
|
900
1073
|
size?: number;
|
|
901
1074
|
}
|
|
902
1075
|
/**
|
|
@@ -907,12 +1080,18 @@ interface FileInfo {
|
|
|
907
1080
|
* resolve repeatedly: cache in the host when resolving is expensive.
|
|
908
1081
|
*/
|
|
909
1082
|
type FileInfoResolver = (href: string) => FileInfo | undefined | Promise<FileInfo | undefined>;
|
|
910
|
-
/**
|
|
1083
|
+
/**
|
|
1084
|
+
* Options for {@link defineFileView}.
|
|
1085
|
+
*/
|
|
911
1086
|
interface FileViewOptions {
|
|
912
|
-
/**
|
|
1087
|
+
/**
|
|
1088
|
+
* Resolve the metadata (file size) shown on a pill. Omit to show none.
|
|
1089
|
+
*/
|
|
913
1090
|
resolveFileInfo?: FileInfoResolver;
|
|
914
1091
|
}
|
|
915
|
-
/**
|
|
1092
|
+
/**
|
|
1093
|
+
* Classify a file destination for the pill's `data-file-kind` attribute.
|
|
1094
|
+
*/
|
|
916
1095
|
declare function getFileKind(href: string): string;
|
|
917
1096
|
/**
|
|
918
1097
|
* Render a claimed file link or wiki embed (the `mdFile` mark) as an inline
|
|
@@ -925,7 +1104,9 @@ declare function defineFileView(options?: FileViewOptions): PlainExtension;
|
|
|
925
1104
|
//#region src/extensions/link-click.d.ts
|
|
926
1105
|
interface LinkClickPayload {
|
|
927
1106
|
href: string;
|
|
928
|
-
/**
|
|
1107
|
+
/**
|
|
1108
|
+
* The originating click, or the `Enter`/`Mod-Enter` key press that followed the link.
|
|
1109
|
+
*/
|
|
929
1110
|
event: MouseEvent | KeyboardEvent;
|
|
930
1111
|
}
|
|
931
1112
|
type LinkClickHandler = (payload: LinkClickPayload) => void;
|
|
@@ -942,7 +1123,9 @@ declare function defineLinkClickHandler(onClick: LinkClickHandler): PlainExtensi
|
|
|
942
1123
|
//#endregion
|
|
943
1124
|
//#region src/extensions/tag-click.d.ts
|
|
944
1125
|
interface TagClickPayload {
|
|
945
|
-
/**
|
|
1126
|
+
/**
|
|
1127
|
+
* The tag name, without the leading `#`.
|
|
1128
|
+
*/
|
|
946
1129
|
tag: string;
|
|
947
1130
|
/**
|
|
948
1131
|
* The originating click, or the `Enter`/`Mod-Enter` key press that followed the tag.
|
|
@@ -966,7 +1149,9 @@ interface WikilinkHit {
|
|
|
966
1149
|
}
|
|
967
1150
|
interface WikilinkClickPayload {
|
|
968
1151
|
target: string;
|
|
969
|
-
/**
|
|
1152
|
+
/**
|
|
1153
|
+
* The originating click, or the `Enter`/`Mod-Enter` key press that followed the link.
|
|
1154
|
+
*/
|
|
970
1155
|
event: MouseEvent | KeyboardEvent;
|
|
971
1156
|
}
|
|
972
1157
|
type WikilinkClickHandler = (payload: WikilinkClickPayload) => void;
|
|
@@ -995,11 +1180,17 @@ interface FollowLinkHandlers {
|
|
|
995
1180
|
declare function defineFollowLinkHandler(handlers: FollowLinkHandlers): PlainExtension;
|
|
996
1181
|
//#endregion
|
|
997
1182
|
//#region src/extensions/image-click.d.ts
|
|
998
|
-
/**
|
|
1183
|
+
/**
|
|
1184
|
+
* Payload for {@link ImageClickHandler}.
|
|
1185
|
+
*/
|
|
999
1186
|
interface ImageClickPayload {
|
|
1000
|
-
/**
|
|
1187
|
+
/**
|
|
1188
|
+
* The resolved source from `` or a claimed `![[target]]`.
|
|
1189
|
+
*/
|
|
1001
1190
|
src: string;
|
|
1002
|
-
/**
|
|
1191
|
+
/**
|
|
1192
|
+
* The image alt text.
|
|
1193
|
+
*/
|
|
1003
1194
|
alt: string;
|
|
1004
1195
|
/**
|
|
1005
1196
|
* The originating click or touch tap. Read the target or position a popover
|
|
@@ -1023,7 +1214,9 @@ declare function defineImageClickHandler(onClick: ImageClickHandler): PlainExten
|
|
|
1023
1214
|
//#endregion
|
|
1024
1215
|
//#region src/extensions/image.d.ts
|
|
1025
1216
|
type ImageUrlResolver = (src: string) => string | undefined;
|
|
1026
|
-
/**
|
|
1217
|
+
/**
|
|
1218
|
+
* Options for {@link defineImage}.
|
|
1219
|
+
*/
|
|
1027
1220
|
interface ImageOptions {
|
|
1028
1221
|
/**
|
|
1029
1222
|
* Map a markdown `src` to a displayable URL, or `undefined` to skip rendering
|
|
@@ -1038,7 +1231,9 @@ interface ImageOptions {
|
|
|
1038
1231
|
*/
|
|
1039
1232
|
persistTweetHeight?: boolean;
|
|
1040
1233
|
}
|
|
1041
|
-
/**
|
|
1234
|
+
/**
|
|
1235
|
+
* Show an `src` as-is when it is an http(s) URL, otherwise skip rendering it.
|
|
1236
|
+
*/
|
|
1042
1237
|
declare function defaultResolveImageUrl(src: string): string | undefined;
|
|
1043
1238
|
/**
|
|
1044
1239
|
* Inline image/embed rendering: a mark view on the `mdImage` mark. Images
|
|
@@ -1050,7 +1245,9 @@ declare function defaultResolveImageUrl(src: string): string | undefined;
|
|
|
1050
1245
|
declare function defineImage(options?: ImageOptions): PlainExtension;
|
|
1051
1246
|
//#endregion
|
|
1052
1247
|
//#region src/extensions/key-bindings.d.ts
|
|
1053
|
-
/**
|
|
1248
|
+
/**
|
|
1249
|
+
* Human-readable descriptions of the editor's formatting and heading shortcuts.
|
|
1250
|
+
*/
|
|
1054
1251
|
declare const EDITOR_KEY_BINDINGS: {
|
|
1055
1252
|
readonly 'Mod-b': "Bold";
|
|
1056
1253
|
readonly 'Mod-i': "Italic";
|
|
@@ -1112,7 +1309,9 @@ type MarkName = (typeof MARK_NAMES)[number];
|
|
|
1112
1309
|
declare function isMarkOfType(mark: Mark, name: MarkName): boolean;
|
|
1113
1310
|
//#endregion
|
|
1114
1311
|
//#region src/extensions/math.d.ts
|
|
1115
|
-
/**
|
|
1312
|
+
/**
|
|
1313
|
+
* Inline math rendering: a KaTeX preview on the `mdMath` mark.
|
|
1314
|
+
*/
|
|
1116
1315
|
declare function defineMath(): PlainExtension;
|
|
1117
1316
|
//#endregion
|
|
1118
1317
|
//#region src/extensions/node-names.d.ts
|
|
@@ -1127,7 +1326,9 @@ declare function isNodeOfType(node: ProseMirrorNode, name: NodeName): boolean;
|
|
|
1127
1326
|
declare function defineSpellCheckPlugin(spellCheck: boolean): PlainExtension;
|
|
1128
1327
|
//#endregion
|
|
1129
1328
|
//#region src/extensions/substitution.d.ts
|
|
1130
|
-
/**
|
|
1329
|
+
/**
|
|
1330
|
+
* Apply the editor's automatic plain-text substitutions.
|
|
1331
|
+
*/
|
|
1131
1332
|
declare function defineSubstitution(): PlainExtension;
|
|
1132
1333
|
//#endregion
|
|
1133
1334
|
//#region src/extensions/table.d.ts
|
|
@@ -1169,12 +1370,18 @@ declare function defineViewAttributes(attributes: {
|
|
|
1169
1370
|
declare function defineVirtualCaret(layer: HTMLElement): PlainExtension;
|
|
1170
1371
|
//#endregion
|
|
1171
1372
|
//#region src/extensions/wikilink-hover.d.ts
|
|
1172
|
-
/**
|
|
1373
|
+
/**
|
|
1374
|
+
* A wikilink currently under the pointer.
|
|
1375
|
+
*/
|
|
1173
1376
|
interface WikilinkHoverHit extends WikilinkHit {
|
|
1174
|
-
/**
|
|
1377
|
+
/**
|
|
1378
|
+
* The rendered wikilink label used as the popup anchor.
|
|
1379
|
+
*/
|
|
1175
1380
|
element: HTMLElement;
|
|
1176
1381
|
}
|
|
1177
|
-
/**
|
|
1382
|
+
/**
|
|
1383
|
+
* Called once on wikilink enter and with `undefined` on leave or invalidation.
|
|
1384
|
+
*/
|
|
1178
1385
|
type WikilinkHoverHandler = (hit: WikilinkHoverHit | undefined) => void;
|
|
1179
1386
|
/**
|
|
1180
1387
|
* Track the wikilink under the pointer without attaching per-link listeners.
|