@portabletext/markdown 2.0.0 → 2.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.
package/dist/index.d.ts CHANGED
@@ -282,7 +282,9 @@ interface PortableTextRendererOptions<T> {
282
282
  */
283
283
  isInline: boolean;
284
284
  /**
285
- * Serialized Markdown of child nodes of this block/type
285
+ * Serialized Markdown of child nodes of this block/type: nested marks
286
+ * rendered, markdown-significant punctuation in plain text
287
+ * backslash-escaped. Safe to embed in markdown output as-is.
286
288
  */
287
289
  children?: string;
288
290
  /**
@@ -309,7 +311,12 @@ interface PortableTextMarkRendererOptions<M extends TypedObject = ArbitraryTyped
309
311
  */
310
312
  value?: M;
311
313
  /**
312
- * Text content of this mark
314
+ * The raw text content of this mark: the span text exactly as stored in
315
+ * the Portable Text, unescaped, with no nested mark rendering. Read this
316
+ * when your renderer emits its own delimiters or non-markdown output
317
+ * (code fences, HTML tags), where backslash escapes would appear
318
+ * literally. The built-in `code` decorator renderer works from this
319
+ * field.
313
320
  */
314
321
  text: string;
315
322
  /**
@@ -321,7 +328,11 @@ interface PortableTextMarkRendererOptions<M extends TypedObject = ArbitraryTyped
321
328
  */
322
329
  markType: string;
323
330
  /**
324
- * Serialized Markdown of child nodes of this mark
331
+ * Serialized Markdown of this mark's child nodes: nested marks are
332
+ * rendered and markdown-significant punctuation in plain text is
333
+ * backslash-escaped. Safe to embed in markdown output as-is; wrapping
334
+ * renderers (`**${children}**`) should always use this. For the raw,
335
+ * unescaped text, read `text` instead.
325
336
  */
326
337
  children: string;
327
338
  /**
@@ -348,11 +359,442 @@ interface Serializable<T> {
348
359
  }
349
360
  type Options$1 = Partial<PortableTextRenderers> & {
350
361
  blockSpacing?: BlockSpacingRenderer;
362
+ /**
363
+ * Compiled schema that gates the built-in type renderers; it never
364
+ * validates the value. A default renderer runs only when the schema
365
+ * declares its type (`blockObjects` for block position, `inlineObjects`
366
+ * for inline); undeclared types render through `unknownType`, whose
367
+ * default output reparses back to the same value. The gate checks the
368
+ * type name only, so declare the type's fields too:
369
+ * `markdownToPortableText` cannot rebuild a value from a fieldless
370
+ * declaration. Renderers passed in `types` are never gated. Pass the
371
+ * same schema to `markdownToPortableText` to keep the round trip
372
+ * consistent. Omitted, all default renderers stay active.
373
+ */
374
+ schema?: Schema;
351
375
  };
352
376
  /**
353
377
  * @public
354
378
  */
355
379
  declare function portableTextToMarkdown<Block extends TypedObject = PortableTextBlock$1 | ArbitraryTypedObject>(blocks: Array<Block>, options?: Options$1): string;
380
+ /**
381
+ * Matcher function for mapping markdown elements to Portable Text block styles.
382
+ *
383
+ * @public
384
+ */
385
+ type StyleMatcher = ({ context }: {
386
+ context: {
387
+ schema: Schema;
388
+ };
389
+ }) => string | undefined;
390
+ /**
391
+ * Matcher function for mapping markdown list items to Portable Text list types.
392
+ *
393
+ * @public
394
+ */
395
+ type ListItemMatcher = ({ context }: {
396
+ context: {
397
+ schema: Schema;
398
+ };
399
+ }) => string | undefined;
400
+ /**
401
+ * Matcher function for mapping markdown inline formatting to Portable Text decorators.
402
+ *
403
+ * @public
404
+ */
405
+ type DecoratorMatcher = ({ context }: {
406
+ context: {
407
+ schema: Schema;
408
+ };
409
+ }) => string | undefined;
410
+ /**
411
+ * Matcher function for mapping markdown links to Portable Text annotations.
412
+ *
413
+ * @public
414
+ */
415
+ type AnnotationMatcher<TValue extends Record<string, unknown> = Record<string, never>> = ({ context, value }: {
416
+ context: {
417
+ schema: Schema;
418
+ keyGenerator: () => string;
419
+ };
420
+ value: TValue;
421
+ }) => PortableTextObject | undefined;
422
+ /**
423
+ * Matcher function for mapping markdown objects to Portable Text block or inline objects.
424
+ *
425
+ * @public
426
+ */
427
+ type ObjectMatcher<TValue extends Record<string, unknown> = Record<string, never>> = ({ context, value, isInline }: {
428
+ context: {
429
+ schema: Schema;
430
+ keyGenerator: () => string;
431
+ };
432
+ value: TValue;
433
+ isInline: boolean;
434
+ }) => PortableTextObject | undefined;
435
+ /**
436
+ * The classification of a lossy conversion encountered while converting
437
+ * markdown to Portable Text: a markdown construct the conversion couldn't
438
+ * carry through losslessly, whether because the target schema (or the
439
+ * active matchers) doesn't represent it, or because the surrounding
440
+ * structure (a table cell, for instance) can't hold the shape markdown
441
+ * expressed, so the conversion fell back to a lossier representation
442
+ * instead of failing.
443
+ *
444
+ * @public
445
+ */
446
+ type DegradationType = 'decorator-dropped' | 'annotation-dropped' | 'style-fallback' | 'list-flattened' | 'task-checkbox-stripped' | 'table-flattened' | 'code-block-to-text' | 'horizontal-rule-to-text' | 'html-block-to-text' | 'inline-html-dropped' | 'image-block-to-inline' | 'image-inline-to-block' | 'image-to-text' | 'callout-fallback' | 'fields-dropped' | 'object-carrier-invalid';
447
+ /**
448
+ * Reports a single lossy conversion, in encounter order: as the conversion
449
+ * walks the markdown, that's the order nested constructs close in, not
450
+ * necessarily top-to-bottom document order. `line` is the 1-based markdown
451
+ * source line: usually the line of the token that degraded, but for a
452
+ * token without its own line (an inline construct inside a table cell, for
453
+ * instance) the enclosing construct's line instead; absent when no token
454
+ * carries a usable line at all. `snippet` is the offending construct's
455
+ * text, truncated to 40 characters with an ellipsis, present whenever the
456
+ * degradation has a specific piece of source text to quote (a dropped
457
+ * decorator's span, an unsupported image's alt text) and absent when the
458
+ * construct has nothing to quote (a table with no `table` block object, a
459
+ * callout whose type isn't in the schema). `message` is human-readable and
460
+ * may change between releases; match on `type`, not `message`. The set of
461
+ * `type` values grows in minor releases as new degradation sites report, so
462
+ * compare against the values you handle rather than switching exhaustively.
463
+ *
464
+ * @public
465
+ */
466
+ type Degradation = {
467
+ type: DegradationType;
468
+ message: string;
469
+ line?: number;
470
+ snippet?: string;
471
+ };
472
+ type Options = {
473
+ /**
474
+ * Compiled schema deciding which Portable Text constructs the
475
+ * conversion may build; pairs with the same option on
476
+ * `portableTextToMarkdown` to keep the round trip consistent.
477
+ */
478
+ schema?: Schema;
479
+ keyGenerator?: () => string;
480
+ /**
481
+ * Called at most once, after the conversion has walked the whole
482
+ * document, only when at least one construct degraded. Left unset, the
483
+ * conversion stays silent and returns the lossiest representation it can
484
+ * build. Passed a function, observe every degradation via
485
+ * `report.degradations`, in encounter order. Enforce against lossy output by
486
+ * throwing your own error from inside the callback, using
487
+ * `report.message` (the canonical grouped text) as its message; the
488
+ * throw propagates out of `markdownToPortableText`.
489
+ *
490
+ * ```ts
491
+ * markdownToPortableText(markdown, {onDegradation: ({message}) => { throw new Error(message) }})
492
+ * ```
493
+ *
494
+ * `report` is a single object, not positional parameters, so it can gain
495
+ * fields later without a breaking change.
496
+ */
497
+ onDegradation?: (report: {
498
+ degradations: Array<Degradation>;
499
+ message: string;
500
+ }) => void;
501
+ marks?: {
502
+ strong?: DecoratorMatcher;
503
+ em?: DecoratorMatcher;
504
+ code?: DecoratorMatcher;
505
+ strikeThrough?: DecoratorMatcher;
506
+ link?: AnnotationMatcher<{
507
+ href: string;
508
+ title: string | undefined;
509
+ }>;
510
+ };
511
+ block?: {
512
+ normal?: StyleMatcher;
513
+ blockquote?: StyleMatcher;
514
+ h1?: StyleMatcher;
515
+ h2?: StyleMatcher;
516
+ h3?: StyleMatcher;
517
+ h4?: StyleMatcher;
518
+ h5?: StyleMatcher;
519
+ h6?: StyleMatcher;
520
+ };
521
+ listItem?: {
522
+ number?: ListItemMatcher;
523
+ bullet?: ListItemMatcher;
524
+ task?: ListItemMatcher;
525
+ };
526
+ types?: {
527
+ code?: ObjectMatcher<{
528
+ language: string | undefined;
529
+ code: string;
530
+ }>;
531
+ horizontalRule?: ObjectMatcher;
532
+ html?: ObjectMatcher<{
533
+ html: string;
534
+ }>;
535
+ table?: ObjectMatcher<{
536
+ headerRows: number | undefined;
537
+ alignment: Array<'left' | 'center' | 'right' | null> | undefined;
538
+ rows: Array<{
539
+ _key: string;
540
+ _type: 'row';
541
+ cells: Array<{
542
+ _type: 'cell';
543
+ _key: string;
544
+ value: Array<PortableTextBlock>;
545
+ }>;
546
+ }>;
547
+ }>;
548
+ image?: ObjectMatcher<{
549
+ src: string;
550
+ alt: string;
551
+ title: string | undefined;
552
+ }>;
553
+ callout?: ObjectMatcher<{
554
+ tone: string;
555
+ content: Array<PortableTextBlock>;
556
+ }>;
557
+ blockquote?: ObjectMatcher<{
558
+ content: Array<PortableTextBlock>;
559
+ }>;
560
+ list?: ObjectMatcher<{
561
+ kind: 'bullet' | 'number' | 'task';
562
+ items: Array<{
563
+ _type: 'list-item';
564
+ _key: string;
565
+ checked?: boolean;
566
+ content: Array<PortableTextBlock | PortableTextObject>;
567
+ }>;
568
+ }>;
569
+ };
570
+ html?: {
571
+ /**
572
+ * How to handle inline HTML.
573
+ * - 'skip': Ignore inline HTML (default)
574
+ * - 'text': Convert inline HTML to plain text
575
+ *
576
+ * @defaultValue 'skip'
577
+ */
578
+ inline?: 'skip' | 'text';
579
+ };
580
+ };
581
+ /**
582
+ * Converts a markdown string to an array of Portable Text blocks.
583
+ *
584
+ * @public
585
+ */
586
+ declare function markdownToPortableText(markdown: string, options?: Options): Array<PortableTextBlock>;
587
+ /**
588
+ * @public
589
+ */
590
+ type ApplyMarkdownEditOptions = {
591
+ /**
592
+ * One compiled schema governing both conversion directions, the same
593
+ * object the standalone converters accept. Taking it once is what
594
+ * keeps the internal canonical dialect consistent: serializing and
595
+ * reparsing under different schemas would change node counts or
596
+ * types, refuse the origin trace, and reset keys document-wide.
597
+ */
598
+ schema?: Schema;
599
+ /**
600
+ * Options for the markdown → Portable Text conversion of
601
+ * `editedMarkdown` (matchers, `keyGenerator`). The same options
602
+ * also govern the internal canonicalization of `storedPortableText`
603
+ * used to align the two documents, except `onDegradation`, which is
604
+ * scoped to `editedMarkdown` alone: `keyGenerator` supplies every
605
+ * fresh key the function mints, both for new content and for the
606
+ * sibling-uniqueness key-rename sweep.
607
+ */
608
+ deserialize?: Omit<NonNullable<Parameters<typeof markdownToPortableText>[1]>, 'schema'>;
609
+ /**
610
+ * Options for the Portable Text → markdown conversion. Pass the same
611
+ * options that produced the markdown that was edited: key
612
+ * resolution aligns the edit against a fresh canonical serialization
613
+ * of `storedPortableText`, so the two serializations must agree for
614
+ * that alignment to be meaningful.
615
+ */
616
+ serialize?: Omit<NonNullable<Parameters<typeof portableTextToMarkdown>[1]>, 'schema'>;
617
+ /**
618
+ * Reports how stored `_key`s were reconciled onto the converted
619
+ * value. Reconciliation here is key restoration against the exact
620
+ * snapshot that produced the markdown, never a merge of concurrent
621
+ * edits: those are the caller's job (see the README's Concurrent
622
+ * edits section). Called at most once, and exactly once whenever the
623
+ * option is set and `applyMarkdownEdit` returns (a conversion that
624
+ * throws never reports), synchronously, immediately before the
625
+ * return, including when key matching is skipped outright: that is
626
+ * when a caller needs the report most. A node absent from a performed report's
627
+ * `preservedKeys` was not preserved from the stored value, whether
628
+ * it is a fresh key or a `json:object` payload key that carried its
629
+ * own; the report does not distinguish the two. Which keys
630
+ * survived, every `key` and `path`, and `renamedKeys` are facts of
631
+ * that invocation, safe to branch on for that invocation; a skipped
632
+ * report's `reason` is advisory only, since near the evidence caps
633
+ * it can vary with machine speed, and should never drive behavior.
634
+ *
635
+ * @beta
636
+ */
637
+ onReconciliation?: (report: ReconciliationReport) => void;
638
+ };
639
+ /**
640
+ * A path segment into the value `applyMarkdownEdit` returns: a string
641
+ * field name for container nesting (`rows`, `cells`, `value`, and the
642
+ * like), `{_key}` wherever the path lands on a keyed array element,
643
+ * and a number wherever it lands on a keyless one instead. A block's
644
+ * own path is a single `{_key}` segment, or a single number for a
645
+ * keyless top-level block; a child's path is
646
+ * `[{_key: <block key>}, 'children', {_key: <child key>}]`. A keyless
647
+ * node (a `json:object` payload without a `_key` of its own, at the
648
+ * top level or wrapping keyed content in a nested array) contributes
649
+ * its index as a number segment instead of a `{_key}` segment.
650
+ *
651
+ * @beta
652
+ */
653
+ type ReconciliationKeyPath = Array<{
654
+ _key: string;
655
+ } | string | number>;
656
+ /**
657
+ * What `applyMarkdownEdit` did with every key, delivered through
658
+ * `onReconciliation`. `keyMatching: 'skipped'` means key matching gave
659
+ * up on the whole document rather than at some local point: the
660
+ * returned value is the plain markdown→Portable Text conversion, so
661
+ * every key in it is fresh except a `json:object` payload key carried
662
+ * through the markdown verbatim, and no preserved key or local key
663
+ * fallback can have happened. `preservedKeys` and `renamedKeys` list
664
+ * their entries in document order, each block before its children and
665
+ * its mark definitions after them; `keyFallbacks` groups by kind
666
+ * instead: `ambiguous-region-too-large` entries in the order their
667
+ * gaps were resolved, then `annotation-key-conflict` entries. `basis`
668
+ * names the matching method that preserved a key, not the edit's
669
+ * semantics: a swap reports one block `content-moved` and its partner
670
+ * `content-unchanged`. The report carries no edit intent: a deleted
671
+ * stored node is not listed at all, so derive deletions as stored
672
+ * keys minus the keys `applyMarkdownEdit` returned.
673
+ *
674
+ * @beta
675
+ */
676
+ type ReconciliationReport = {
677
+ keyMatching: 'performed';
678
+ /**
679
+ * One entry per node whose stored `_key` key resolution
680
+ * preserved, at every depth (blocks, spans and other inline
681
+ * children, and mark definitions). A node absent from this list
682
+ * did not have its key preserved from the stored value: that
683
+ * covers both a freshly generated key and a `json:object`
684
+ * payload key carried through the markdown verbatim, which the
685
+ * report does not distinguish. `basis` names the tier that
686
+ * matched: `content-unchanged` for an exact content match (a
687
+ * block-level anchor, a uniquely matched child, a preserved
688
+ * empty-block run, or a mark definition uniquely matched by
689
+ * content); `content-moved` for a unique leftover matched
690
+ * across gaps; `content-split` for a fragment that kept its
691
+ * source block's key; `content-merged` for a merge that kept
692
+ * its first contributor's key; `same-position` for an
693
+ * equal-count in-order pairing (also a same-content
694
+ * mark-definition tie, or a single leftover mark definition
695
+ * paired positionally); `similar-content` for a mutual-best
696
+ * match under an unequal count.
697
+ */
698
+ preservedKeys: Array<{
699
+ basis: 'content-unchanged' | 'content-moved' | 'content-split' | 'content-merged' | 'same-position' | 'similar-content';
700
+ key: string;
701
+ path: ReconciliationKeyPath;
702
+ }>;
703
+ /**
704
+ * One entry per local point where key resolution gave up rather
705
+ * than adopt, while the rest of the document still resolves
706
+ * keys: `ambiguous-region-too-large` when a gap's residual
707
+ * similarity pairing crossed the evidence pair cap, listing the
708
+ * affected result block keys that fell back to fresh;
709
+ * `annotation-key-conflict` when an adopted mark definition key
710
+ * would have collided with a sibling. The span-merge pair cap,
711
+ * the per-diff similarity timeout, and the gap's earlier
712
+ * concatenation-search cap degrade the same way but are not
713
+ * reported: `ambiguous-region-too-large` covers the residual
714
+ * similarity tier only (a gap that trips the concatenation cap
715
+ * trips it too).
716
+ */
717
+ keyFallbacks: Array<{
718
+ type: 'ambiguous-region-too-large';
719
+ keys: Array<string>;
720
+ } | {
721
+ type: 'annotation-key-conflict';
722
+ path: ReconciliationKeyPath;
723
+ }>;
724
+ /**
725
+ * One entry per key `applyMarkdownEdit` rewrote to keep
726
+ * siblings unique, most commonly a `json:object` payload
727
+ * duplicating a key already present elsewhere in the document.
728
+ */
729
+ renamedKeys: Array<{
730
+ previousKey: string;
731
+ key: string;
732
+ path: ReconciliationKeyPath;
733
+ }>;
734
+ } | {
735
+ keyMatching: 'skipped';
736
+ /**
737
+ * `round-trip-mismatch` when the stored value's own
738
+ * canonicalization changed its node count, type sequence, or
739
+ * per-position text; `document-too-large` when the document
740
+ * holds more distinct block forms than alignment can token.
741
+ * Advisory only, since near the evidence caps it can vary with
742
+ * machine speed, and should never drive behavior.
743
+ */
744
+ reason: 'round-trip-mismatch' | 'document-too-large';
745
+ /**
746
+ * One entry per key `applyMarkdownEdit` rewrote to keep
747
+ * siblings unique, most commonly a `json:object` payload
748
+ * duplicating a key already present elsewhere in the document.
749
+ * The sibling-uniqueness pass still runs on a skipped document:
750
+ * a pasted duplicate `json:object` fence key still gets
751
+ * renamed even though nothing else adopted.
752
+ */
753
+ renamedKeys: Array<{
754
+ previousKey: string;
755
+ key: string;
756
+ path: ReconciliationKeyPath;
757
+ }>;
758
+ };
759
+ /**
760
+ * Converts edited markdown to Portable Text, restores stored keys, and
761
+ * restores fields the markdown dialect cannot express (dropped by
762
+ * serialization, so the edit could not have touched them); a field
763
+ * markdown does express follows the edit. The same rule covers a
764
+ * custom style or decorator markdown has no syntax for, coerced to a
765
+ * built-in on the round trip. An empty or whitespace-only text block
766
+ * is the same case taken to the whole block: markdown has no form for
767
+ * either, so it is restored next to its surviving neighbor and
768
+ * dropped along with that neighbor if the neighbor does not survive.
769
+ * Keys aim for what the
770
+ * same edit would have produced in an editor:
771
+ * unchanged, moved, and rewritten-in-place content keeps its keys
772
+ * (rewriting a paragraph in place keeps its identity, like typing over
773
+ * it), a split keeps the key on its first non-empty fragment, a merge
774
+ * keeps the first source block's key, and a `json:object` payload keeps
775
+ * the key it carries, unless reconciliation matches it to stored
776
+ * content, which takes the stored key even over a differing key in the
777
+ * payload. When an insertion or deletion makes positions ambiguous,
778
+ * only clear similarity evidence adopts a key and everything else gets
779
+ * a new one; gathering that evidence is time-capped, so on very large
780
+ * ambiguous edits the set of adopted keys can differ across machine
781
+ * speeds, degrading toward fresh keys.
782
+ * Output keys are unique among siblings. The function does not mutate
783
+ * `storedPortableText` and returns a value, not patches. The `schema`
784
+ * is taken once and governs both directions; pass the same `serialize`
785
+ * options that produced the markdown that was edited. A throwing or
786
+ * stateful custom matcher or renderer propagates or degrades matching
787
+ * respectively.
788
+ * Reconciliation never merges concurrent edits: compare the stored
789
+ * field against the live document before writing the result back.
790
+ * The trades in one line: same-position replacement inherits identity,
791
+ * a count-preserving rewrite pairs positionally (block-level and
792
+ * sibling-level alike), and evidence gathering is capped, degrading to
793
+ * fresh keys.
794
+ *
795
+ * @public
796
+ */
797
+ declare function applyMarkdownEdit(storedPortableText: ReadonlyArray<PortableTextBlock>, editedMarkdown: string, options?: ApplyMarkdownEditOptions): Array<PortableTextBlock>;
356
798
  /**
357
799
  * @public
358
800
  */
@@ -403,6 +845,20 @@ declare const DefaultEmRenderer: PortableTextMarkRenderer;
403
845
  */
404
846
  declare const DefaultStrongRenderer: PortableTextMarkRenderer;
405
847
  /**
848
+ * Renders a `code` decorator from the raw span text, bypassing the escaped
849
+ * `children`: code content is verbatim, never markdown syntax. The
850
+ * backtick fence is widened past the longest run of backticks already in
851
+ * the text (CommonMark: the fence must be longer than any run it encloses).
852
+ *
853
+ * A space is padded on each side when the content starts or ends with a
854
+ * backtick, so the fence and the content's own backtick never merge into
855
+ * one run, and also when the content starts and ends with a space and
856
+ * isn't all whitespace (`text.trim() !== ''`; an all-space code span has
857
+ * nothing else for CommonMark's strip rule to leave behind, so padding it
858
+ * would only add visible spaces), because CommonMark itself would
859
+ * otherwise strip one such space per side on reparse; the padding
860
+ * pre-compensates for that strip.
861
+ *
406
862
  * @public
407
863
  */
408
864
  declare const DefaultCodeRenderer: PortableTextMarkRenderer;
@@ -524,149 +980,5 @@ declare const DefaultListRenderer: PortableTextTypeRenderer<{
524
980
  content: Array<PortableTextBlock$1 | TypedObject>;
525
981
  }>;
526
982
  }>;
527
- /**
528
- * Matcher function for mapping markdown elements to Portable Text block styles.
529
- *
530
- * @public
531
- */
532
- type StyleMatcher = ({ context }: {
533
- context: {
534
- schema: Schema;
535
- };
536
- }) => string | undefined;
537
- /**
538
- * Matcher function for mapping markdown list items to Portable Text list types.
539
- *
540
- * @public
541
- */
542
- type ListItemMatcher = ({ context }: {
543
- context: {
544
- schema: Schema;
545
- };
546
- }) => string | undefined;
547
- /**
548
- * Matcher function for mapping markdown inline formatting to Portable Text decorators.
549
- *
550
- * @public
551
- */
552
- type DecoratorMatcher = ({ context }: {
553
- context: {
554
- schema: Schema;
555
- };
556
- }) => string | undefined;
557
- /**
558
- * Matcher function for mapping markdown links to Portable Text annotations.
559
- *
560
- * @public
561
- */
562
- type AnnotationMatcher<TValue extends Record<string, unknown> = Record<string, never>> = ({ context, value }: {
563
- context: {
564
- schema: Schema;
565
- keyGenerator: () => string;
566
- };
567
- value: TValue;
568
- }) => PortableTextObject | undefined;
569
- /**
570
- * Matcher function for mapping markdown objects to Portable Text block or inline objects.
571
- *
572
- * @public
573
- */
574
- type ObjectMatcher<TValue extends Record<string, unknown> = Record<string, never>> = ({ context, value, isInline }: {
575
- context: {
576
- schema: Schema;
577
- keyGenerator: () => string;
578
- };
579
- value: TValue;
580
- isInline: boolean;
581
- }) => PortableTextObject | undefined;
582
- type Options = {
583
- schema?: Schema;
584
- keyGenerator?: () => string;
585
- marks?: {
586
- strong?: DecoratorMatcher;
587
- em?: DecoratorMatcher;
588
- code?: DecoratorMatcher;
589
- strikeThrough?: DecoratorMatcher;
590
- link?: AnnotationMatcher<{
591
- href: string;
592
- title: string | undefined;
593
- }>;
594
- };
595
- block?: {
596
- normal?: StyleMatcher;
597
- blockquote?: StyleMatcher;
598
- h1?: StyleMatcher;
599
- h2?: StyleMatcher;
600
- h3?: StyleMatcher;
601
- h4?: StyleMatcher;
602
- h5?: StyleMatcher;
603
- h6?: StyleMatcher;
604
- };
605
- listItem?: {
606
- number?: ListItemMatcher;
607
- bullet?: ListItemMatcher;
608
- task?: ListItemMatcher;
609
- };
610
- types?: {
611
- code?: ObjectMatcher<{
612
- language: string | undefined;
613
- code: string;
614
- }>;
615
- horizontalRule?: ObjectMatcher;
616
- html?: ObjectMatcher<{
617
- html: string;
618
- }>;
619
- table?: ObjectMatcher<{
620
- headerRows: number | undefined;
621
- alignment: Array<'left' | 'center' | 'right' | null> | undefined;
622
- rows: Array<{
623
- _key: string;
624
- _type: 'row';
625
- cells: Array<{
626
- _type: 'cell';
627
- _key: string;
628
- value: Array<PortableTextBlock>;
629
- }>;
630
- }>;
631
- }>;
632
- image?: ObjectMatcher<{
633
- src: string;
634
- alt: string;
635
- title: string | undefined;
636
- }>;
637
- callout?: ObjectMatcher<{
638
- tone: string;
639
- content: Array<PortableTextBlock>;
640
- }>;
641
- blockquote?: ObjectMatcher<{
642
- content: Array<PortableTextBlock>;
643
- }>;
644
- list?: ObjectMatcher<{
645
- kind: 'bullet' | 'number' | 'task';
646
- items: Array<{
647
- _type: 'list-item';
648
- _key: string;
649
- checked?: boolean;
650
- content: Array<PortableTextBlock | PortableTextObject>;
651
- }>;
652
- }>;
653
- };
654
- html?: {
655
- /**
656
- * How to handle inline HTML.
657
- * - 'skip': Ignore inline HTML (default)
658
- * - 'text': Convert inline HTML to plain text
659
- *
660
- * @defaultValue 'skip'
661
- */
662
- inline?: 'skip' | 'text';
663
- };
664
- };
665
- /**
666
- * Converts a markdown string to an array of Portable Text blocks.
667
- *
668
- * @public
669
- */
670
- declare function markdownToPortableText(markdown: string, options?: Options): Array<PortableTextBlock>;
671
- export { type AnnotationMatcher, type BlockSpacingRenderer, type DecoratorMatcher, DefaultBlockSpacingRenderer, DefaultBlockquoteObjectRenderer, DefaultBlockquoteRenderer, DefaultCalloutRenderer, DefaultCodeBlockRenderer, DefaultCodeRenderer, DefaultEmRenderer, DefaultH1Renderer, DefaultH2Renderer, DefaultH3Renderer, DefaultH4Renderer, DefaultH5Renderer, DefaultH6Renderer, DefaultHardBreakRenderer, DefaultHorizontalRuleRenderer, DefaultHtmlRenderer, DefaultImageRenderer, DefaultLinkRenderer, DefaultListItemRenderer, DefaultListRenderer, DefaultNormalRenderer, DefaultStrikeThroughRenderer, DefaultStrongRenderer, DefaultTableRenderer, DefaultUnderlineRenderer, type ListItemMatcher, type ObjectMatcher, type PortableTextBlockRenderer, type PortableTextListItemRenderer, type PortableTextMarkRenderer, type PortableTextMarkRendererOptions, type PortableTextRenderer, type PortableTextRendererOptions, type PortableTextRenderers, type PortableTextTypeRenderer, type PortableTextTypeRendererOptions, type StyleMatcher, markdownToPortableText, portableTextToMarkdown };
983
+ export { type AnnotationMatcher, type ApplyMarkdownEditOptions, type BlockSpacingRenderer, type DecoratorMatcher, DefaultBlockSpacingRenderer, DefaultBlockquoteObjectRenderer, DefaultBlockquoteRenderer, DefaultCalloutRenderer, DefaultCodeBlockRenderer, DefaultCodeRenderer, DefaultEmRenderer, DefaultH1Renderer, DefaultH2Renderer, DefaultH3Renderer, DefaultH4Renderer, DefaultH5Renderer, DefaultH6Renderer, DefaultHardBreakRenderer, DefaultHorizontalRuleRenderer, DefaultHtmlRenderer, DefaultImageRenderer, DefaultLinkRenderer, DefaultListItemRenderer, DefaultListRenderer, DefaultNormalRenderer, DefaultStrikeThroughRenderer, DefaultStrongRenderer, DefaultTableRenderer, DefaultUnderlineRenderer, type Degradation, type ListItemMatcher, type ObjectMatcher, type PortableTextBlockRenderer, type PortableTextListItemRenderer, type PortableTextMarkRenderer, type PortableTextMarkRendererOptions, type PortableTextRenderer, type PortableTextRendererOptions, type PortableTextRenderers, type PortableTextTypeRenderer, type PortableTextTypeRendererOptions, type ReconciliationKeyPath, type ReconciliationReport, type StyleMatcher, applyMarkdownEdit, markdownToPortableText, portableTextToMarkdown };
672
984
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../node_modules/.pnpm/@portabletext+types@4.0.2/node_modules/@portabletext/types/dist/index.d.ts","../src/from-portable-text/renderers/block-spacing.ts","../src/from-portable-text/types.ts","../src/from-portable-text/portable-text-to-markdown.ts","../src/from-portable-text/renderers/hard-break.ts","../src/from-portable-text/renderers/list-item.ts","../src/from-portable-text/renderers/style.ts","../src/from-portable-text/renderers/marks.ts","../src/from-portable-text/renderers/type.ts","../src/to-portable-text/matchers.ts","../src/to-portable-text/markdown-to-portable-text.ts"],"x_google_ignoreList":[0],"mappings":";;;;;;UAKU;;;;;EAKR;;;;;EAKA;;;;;;KAMG,uBAAuB;GACzB;;;;;;;;;;;;;UAaO,oBAAkB,UAAU,6BAA6B,4BAA4B,UAAU,cAAc,uBAAuB,kBAAkB,mBAAmB,wBAAwB,mBAAmB,kCAAkC;;;;;;;EAO9P;;;;;;EAMA;;;;;EAKA,UAAU;;;;;;EAMV,WAAW;;;;;EAKX,QAAQ;;;;;EAKR,WAAW;;;;EAIX;;;;;;;;;;;UAWQ,0BAA0B,UAAU,6BAA6B,4BAA4B,UAAU,cAAc,kBAAkB,mBAAmB,wBAAwB,mBAAmB,kCAAkC,KAAK,oBAAkB,GAAG,GAAG,GAAG;EAC/Q,UAAU;;;;;;KAMP;;;;;KAKA;;;;;;;UAOK;;;;G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S;IACT,SAAS;IACT,OAAO;;EAET;IACE,OAAO;MAAe;MAA8B;;IACpD,iBAAiB;IACjB,OAAO;MAAe;;IACtB,QAAQ;MACN;MACA,WAAW;MACX,MAAM;QACJ;QACA;QACA,OAAO;UACL;UACA;UACA,OAAO,MAAM;;;;IAInB,QAAQ;MAAe;MAAa;MAAa;;IACjD,UAAU;MAAe;MAAc,SAAS,MAAM;;IACtD,aAAa;MAAe,SAAS,MAAM;;IAC3C,OAAO;MACL;MACA,OAAO;QACL;QACA;QACA;QACA,SAAS,MAAM,oBAAoB;;;;EAIzC;;;;;;;;IAQE;;;;;;;;iBAuKY,uBACd,kBACA,UAAU,UACT,MAAM"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../node_modules/.pnpm/@portabletext+types@4.0.2/node_modules/@portabletext/types/dist/index.d.ts","../src/from-portable-text/renderers/block-spacing.ts","../src/from-portable-text/types.ts","../src/from-portable-text/portable-text-to-markdown.ts","../src/to-portable-text/matchers.ts","../src/to-portable-text/markdown-to-portable-text.ts","../src/apply-markdown-edit.ts","../src/from-portable-text/renderers/hard-break.ts","../src/from-portable-text/renderers/list-item.ts","../src/from-portable-text/renderers/style.ts","../src/from-portable-text/renderers/marks.ts","../src/from-portable-text/renderers/type.ts"],"x_google_ignoreList":[0],"mappings":";;;;;;UAKU;;;;;EAKR;;;;;EAKA;;;;;;KAMG,uBAAuB;GACzB;;;;;;;;;;;;;UAaO,oBAAkB,UAAU,6BAA6B,4BAA4B,UAAU,cAAc,uBAAuB,kBAAkB,mBAAmB,wBAAwB,mBAAmB,kCAAkC;;;;;;;EAO9P;;;;;;EAMA;;;;;EAKA,UAAU;;;;;;EAMV,WAAW;;;;;EAKX,QAAQ;;;;;EAKR,WAAW;;;;EAIX;;;;;;;;;;;UAWQ,0BAA0B,UAAU,6BAA6B,4BAA4B,UAAU,cAAc,kBAAkB,mBAAmB,wBAAwB,mBAAmB,kCAAkC,KAAK,oBAAkB,GAAG,GAAG,GAAG;EAC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