@tiptap/core 3.6.7 → 3.7.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.cts CHANGED
@@ -737,6 +737,38 @@ interface ExtendableConfig<Options = any, Storage = any, Config extends Extensio
737
737
  storage: Storage;
738
738
  parent: ParentConfig<Config>['addExtensions'];
739
739
  }) => Extensions;
740
+ /**
741
+ * The markdown token name
742
+ *
743
+ * This is the name of the token that this extension uses to parse and render markdown and comes from the Marked Lexer.
744
+ *
745
+ * @see https://github.com/markedjs/marked/blob/master/src/Tokens.ts
746
+ *
747
+ */
748
+ markdownTokenName?: string;
749
+ /**
750
+ * The parse function used by the markdown parser to convert markdown tokens to ProseMirror nodes.
751
+ */
752
+ parseMarkdown?: (token: MarkdownToken, helpers: MarkdownParseHelpers) => MarkdownParseResult;
753
+ /**
754
+ * The serializer function used by the markdown serializer to convert ProseMirror nodes to markdown tokens.
755
+ */
756
+ renderMarkdown?: (node: JSONContent, helpers: MarkdownRendererHelpers, ctx: RenderContext) => string;
757
+ /**
758
+ * The markdown tokenizer responsible for turning a markdown string into tokens
759
+ *
760
+ * Custom tokenizers are only needed when you want to parse non-standard markdown token.
761
+ */
762
+ markdownTokenizer?: MarkdownTokenizer;
763
+ /**
764
+ * Optional markdown options for indentation
765
+ */
766
+ markdownOptions?: {
767
+ /**
768
+ * Defines if this markdown element should indent it's child elements
769
+ */
770
+ indentsContent?: boolean;
771
+ };
740
772
  /**
741
773
  * This function extends the schema of the node.
742
774
  * @example
@@ -1529,6 +1561,144 @@ type ExtendedRegExpMatchArray = RegExpMatchArray & {
1529
1561
  data?: Record<string, any>;
1530
1562
  };
1531
1563
  type Dispatch = ((args?: any) => any) | undefined;
1564
+ /** Markdown related types */
1565
+ type MarkdownToken = {
1566
+ type?: string;
1567
+ raw?: string;
1568
+ text?: string;
1569
+ tokens?: MarkdownToken[];
1570
+ depth?: number;
1571
+ items?: MarkdownToken[];
1572
+ [key: string]: any;
1573
+ };
1574
+ type MarkdownHelpers = {
1575
+ parseInline: (tokens: MarkdownToken[]) => any[];
1576
+ /**
1577
+ * Render children. The second argument may be a legacy separator string
1578
+ * or a RenderContext (preferred).
1579
+ */
1580
+ renderChildren: (node: Node[] | Node, ctxOrSeparator?: RenderContext | string) => string;
1581
+ text: (token: MarkdownToken) => any;
1582
+ };
1583
+ /**
1584
+ * Helpers specifically for parsing markdown tokens into Tiptap JSON.
1585
+ * These are provided to extension parse handlers.
1586
+ */
1587
+ type MarkdownParseHelpers = {
1588
+ /** Parse an array of inline tokens into text nodes with marks */
1589
+ parseInline: (tokens: MarkdownToken[]) => JSONContent[];
1590
+ /** Parse an array of block-level tokens */
1591
+ parseChildren: (tokens: MarkdownToken[]) => JSONContent[];
1592
+ /** Create a text node with optional marks */
1593
+ createTextNode: (text: string, marks?: Array<{
1594
+ type: string;
1595
+ attrs?: any;
1596
+ }>) => JSONContent;
1597
+ /** Create any node type with attributes and content */
1598
+ createNode: (type: string, attrs?: any, content?: JSONContent[]) => JSONContent;
1599
+ /** Apply a mark to content (used for inline marks like bold, italic) */
1600
+ applyMark: (markType: string, content: JSONContent[], attrs?: any) => {
1601
+ mark: string;
1602
+ content: JSONContent[];
1603
+ attrs?: any;
1604
+ };
1605
+ };
1606
+ /**
1607
+ * Full runtime helpers object provided by MarkdownManager to handlers.
1608
+ * This includes the small author-facing helpers plus internal helpers
1609
+ * that can be useful for advanced handlers.
1610
+ */
1611
+ type FullMarkdownHelpers = MarkdownHelpers & {
1612
+ parseChildren: (tokens: MarkdownToken[]) => any[];
1613
+ getExtension: (name: string) => any;
1614
+ createNode: (type: string, attrs?: any, content?: any[]) => any;
1615
+ /** Current render context when calling renderers; undefined during parse. */
1616
+ currentContext?: RenderContext;
1617
+ /** Indent a multi-line string according to the provided RenderContext. */
1618
+ indent: (text: string, ctx?: RenderContext) => string;
1619
+ /** Return the indent string for a given level (e.g. ' ' or '\t'). */
1620
+ getIndentString: (level?: number) => string;
1621
+ };
1622
+
1623
+ /**
1624
+ * Return shape for parser-level `parse` handlers.
1625
+ * - a single JSON-like node
1626
+ * - an array of JSON-like nodes
1627
+ * - or a `{ mark: string, content: JSONLike[] }` shape to apply a mark
1628
+ */
1629
+ type MarkdownParseResult = JSONContent | JSONContent[] | {
1630
+ mark: string;
1631
+ content: JSONContent[];
1632
+ attrs?: any;
1633
+ };
1634
+ type RenderContext = {
1635
+ index: number;
1636
+ level: number;
1637
+ meta?: Record<string, any>;
1638
+ parentType?: string | null;
1639
+ };
1640
+ /** Extension contract for markdown parsing/serialization. */
1641
+ interface MarkdownExtensionSpec {
1642
+ /** Token name used for parsing (e.g., 'codespan', 'code', 'strong') */
1643
+ tokenName?: string;
1644
+ /** Node/mark name used for rendering (typically the extension name) */
1645
+ nodeName?: string;
1646
+ parseMarkdown?: (token: MarkdownToken, helpers: MarkdownParseHelpers) => MarkdownParseResult;
1647
+ renderMarkdown?: (node: any, helpers: MarkdownRendererHelpers, ctx: RenderContext) => string;
1648
+ isIndenting?: boolean;
1649
+ /** Custom tokenizer for marked.js to handle non-standard markdown syntax */
1650
+ tokenizer?: MarkdownTokenizer;
1651
+ }
1652
+ /**
1653
+ * Configuration object passed to custom marked.js tokenizers
1654
+ */
1655
+ type MarkdownLexerConfiguration = {
1656
+ /**
1657
+ * Can be used to transform source text into inline tokens - useful while tokenizing child tokens.
1658
+ * @param src
1659
+ * @returns Array of inline tokens
1660
+ */
1661
+ inlineTokens: (src: string) => MarkdownToken[];
1662
+ /**
1663
+ * Can be used to transform source text into block-level tokens - useful while tokenizing child tokens.
1664
+ * @param src
1665
+ * @returns Array of block-level tokens
1666
+ */
1667
+ blockTokens: (src: string) => MarkdownToken[];
1668
+ };
1669
+ /** Custom tokenizer function for marked.js extensions */
1670
+ type MarkdownTokenizer = {
1671
+ /** Token name this tokenizer creates */
1672
+ name: string;
1673
+ /** Priority level for tokenizer ordering (higher = earlier) */
1674
+ level?: 'block' | 'inline';
1675
+ /** A string to look for or a function that returns the start index of the token in the source string */
1676
+ start?: string | ((src: string) => number);
1677
+ /** Function that attempts to parse custom syntax from start of text */
1678
+ tokenize: (src: string, tokens: MarkdownToken[], lexer: MarkdownLexerConfiguration) => MarkdownToken | undefined | void;
1679
+ };
1680
+ type MarkdownRendererHelpers = {
1681
+ /**
1682
+ * Render children nodes to a markdown string, optionally separated by a string.
1683
+ * @param nodes The node or array of nodes to render
1684
+ * @param separator An optional separator string (legacy) or RenderContext
1685
+ * @returns The rendered markdown string
1686
+ */
1687
+ renderChildren: (nodes: JSONContent | JSONContent[], separator?: string) => string;
1688
+ /**
1689
+ * Render a text token to a markdown string
1690
+ * @param prefix The prefix to add before the content
1691
+ * @param content The content to wrap
1692
+ * @returns The wrapped content
1693
+ */
1694
+ wrapInBlock: (prefix: string, content: string) => string;
1695
+ /**
1696
+ * Indent a markdown string according to the provided RenderContext
1697
+ * @param content The content to indent
1698
+ * @returns The indented content
1699
+ */
1700
+ indent: (content: string) => string;
1701
+ };
1532
1702
 
1533
1703
  /**
1534
1704
  * Create a new Prosemirror document node from content.
@@ -1934,7 +2104,14 @@ declare function splitExtensions(extensions: Extensions): {
1934
2104
  declare class ExtensionManager {
1935
2105
  editor: Editor;
1936
2106
  schema: Schema;
2107
+ /**
2108
+ * A flattened and sorted array of all extensions
2109
+ */
1937
2110
  extensions: Extensions;
2111
+ /**
2112
+ * A non-flattened array of base extensions (no sub-extensions)
2113
+ */
2114
+ baseExtensions: Extensions;
1938
2115
  splittableMarks: string[];
1939
2116
  constructor(extensions: Extensions, editor: Editor);
1940
2117
  static resolve: typeof resolveExtensions;
@@ -2026,6 +2203,7 @@ declare module '@tiptap/core' {
2026
2203
  };
2027
2204
  }
2028
2205
  }
2206
+ declare const blur: RawCommands['blur'];
2029
2207
 
2030
2208
  declare module '@tiptap/core' {
2031
2209
  interface Commands<ReturnType> {
@@ -2043,6 +2221,7 @@ declare module '@tiptap/core' {
2043
2221
  };
2044
2222
  }
2045
2223
  }
2224
+ declare const clearContent: RawCommands['clearContent'];
2046
2225
 
2047
2226
  declare module '@tiptap/core' {
2048
2227
  interface Commands<ReturnType> {
@@ -2055,6 +2234,7 @@ declare module '@tiptap/core' {
2055
2234
  };
2056
2235
  }
2057
2236
  }
2237
+ declare const clearNodes: RawCommands['clearNodes'];
2058
2238
 
2059
2239
  declare module '@tiptap/core' {
2060
2240
  interface Commands<ReturnType> {
@@ -2072,6 +2252,7 @@ declare module '@tiptap/core' {
2072
2252
  };
2073
2253
  }
2074
2254
  }
2255
+ declare const command: RawCommands['command'];
2075
2256
 
2076
2257
  declare module '@tiptap/core' {
2077
2258
  interface Commands<ReturnType> {
@@ -2084,6 +2265,7 @@ declare module '@tiptap/core' {
2084
2265
  };
2085
2266
  }
2086
2267
  }
2268
+ declare const createParagraphNear: RawCommands['createParagraphNear'];
2087
2269
 
2088
2270
  declare module '@tiptap/core' {
2089
2271
  interface Commands<ReturnType> {
@@ -2103,6 +2285,7 @@ declare module '@tiptap/core' {
2103
2285
  };
2104
2286
  }
2105
2287
  }
2288
+ declare const cut: RawCommands['cut'];
2106
2289
 
2107
2290
  declare module '@tiptap/core' {
2108
2291
  interface Commands<ReturnType> {
@@ -2115,6 +2298,7 @@ declare module '@tiptap/core' {
2115
2298
  };
2116
2299
  }
2117
2300
  }
2301
+ declare const deleteCurrentNode: RawCommands['deleteCurrentNode'];
2118
2302
 
2119
2303
  declare module '@tiptap/core' {
2120
2304
  interface Commands<ReturnType> {
@@ -2128,6 +2312,7 @@ declare module '@tiptap/core' {
2128
2312
  };
2129
2313
  }
2130
2314
  }
2315
+ declare const deleteNode: RawCommands['deleteNode'];
2131
2316
 
2132
2317
  declare module '@tiptap/core' {
2133
2318
  interface Commands<ReturnType> {
@@ -2141,6 +2326,7 @@ declare module '@tiptap/core' {
2141
2326
  };
2142
2327
  }
2143
2328
  }
2329
+ declare const deleteRange: RawCommands['deleteRange'];
2144
2330
 
2145
2331
  declare module '@tiptap/core' {
2146
2332
  interface Commands<ReturnType> {
@@ -2153,6 +2339,7 @@ declare module '@tiptap/core' {
2153
2339
  };
2154
2340
  }
2155
2341
  }
2342
+ declare const deleteSelection: RawCommands['deleteSelection'];
2156
2343
 
2157
2344
  declare module '@tiptap/core' {
2158
2345
  interface Commands<ReturnType> {
@@ -2165,6 +2352,7 @@ declare module '@tiptap/core' {
2165
2352
  };
2166
2353
  }
2167
2354
  }
2355
+ declare const enter: RawCommands['enter'];
2168
2356
 
2169
2357
  declare module '@tiptap/core' {
2170
2358
  interface Commands<ReturnType> {
@@ -2177,6 +2365,7 @@ declare module '@tiptap/core' {
2177
2365
  };
2178
2366
  }
2179
2367
  }
2368
+ declare const exitCode: RawCommands['exitCode'];
2180
2369
 
2181
2370
  declare module '@tiptap/core' {
2182
2371
  interface Commands<ReturnType> {
@@ -2200,6 +2389,7 @@ declare module '@tiptap/core' {
2200
2389
  };
2201
2390
  }
2202
2391
  }
2392
+ declare const extendMarkRange: RawCommands['extendMarkRange'];
2203
2393
 
2204
2394
  declare module '@tiptap/core' {
2205
2395
  interface Commands<ReturnType> {
@@ -2213,6 +2403,7 @@ declare module '@tiptap/core' {
2213
2403
  };
2214
2404
  }
2215
2405
  }
2406
+ declare const first: RawCommands['first'];
2216
2407
 
2217
2408
  declare module '@tiptap/core' {
2218
2409
  interface Commands<ReturnType> {
@@ -2239,6 +2430,7 @@ declare module '@tiptap/core' {
2239
2430
  };
2240
2431
  }
2241
2432
  }
2433
+ declare const focus: RawCommands['focus'];
2242
2434
 
2243
2435
  declare module '@tiptap/core' {
2244
2436
  interface Commands<ReturnType> {
@@ -2252,7 +2444,20 @@ declare module '@tiptap/core' {
2252
2444
  };
2253
2445
  }
2254
2446
  }
2447
+ declare const forEach: RawCommands['forEach'];
2255
2448
 
2449
+ interface InsertContentOptions {
2450
+ /**
2451
+ * Options for parsing the content.
2452
+ */
2453
+ parseOptions?: ParseOptions;
2454
+ /**
2455
+ * Whether to update the selection after inserting the content.
2456
+ */
2457
+ updateSelection?: boolean;
2458
+ applyInputRules?: boolean;
2459
+ applyPasteRules?: boolean;
2460
+ }
2256
2461
  declare module '@tiptap/core' {
2257
2462
  interface Commands<ReturnType> {
2258
2463
  insertContent: {
@@ -2269,22 +2474,34 @@ declare module '@tiptap/core' {
2269
2474
  /**
2270
2475
  * Optional options
2271
2476
  */
2272
- options?: {
2273
- /**
2274
- * Options for parsing the content.
2275
- */
2276
- parseOptions?: ParseOptions;
2277
- /**
2278
- * Whether to update the selection after inserting the content.
2279
- */
2280
- updateSelection?: boolean;
2281
- applyInputRules?: boolean;
2282
- applyPasteRules?: boolean;
2283
- }) => ReturnType;
2477
+ options?: InsertContentOptions) => ReturnType;
2284
2478
  };
2285
2479
  }
2286
2480
  }
2481
+ declare const insertContent: RawCommands['insertContent'];
2287
2482
 
2483
+ interface InsertContentAtOptions {
2484
+ /**
2485
+ * Options for parsing the content.
2486
+ */
2487
+ parseOptions?: ParseOptions;
2488
+ /**
2489
+ * Whether to update the selection after inserting the content.
2490
+ */
2491
+ updateSelection?: boolean;
2492
+ /**
2493
+ * Whether to apply input rules after inserting the content.
2494
+ */
2495
+ applyInputRules?: boolean;
2496
+ /**
2497
+ * Whether to apply paste rules after inserting the content.
2498
+ */
2499
+ applyPasteRules?: boolean;
2500
+ /**
2501
+ * Whether to throw an error if the content is invalid.
2502
+ */
2503
+ errorOnInvalidContent?: boolean;
2504
+ }
2288
2505
  declare module '@tiptap/core' {
2289
2506
  interface Commands<ReturnType> {
2290
2507
  insertContentAt: {
@@ -2304,31 +2521,11 @@ declare module '@tiptap/core' {
2304
2521
  /**
2305
2522
  * Optional options
2306
2523
  */
2307
- options?: {
2308
- /**
2309
- * Options for parsing the content.
2310
- */
2311
- parseOptions?: ParseOptions;
2312
- /**
2313
- * Whether to update the selection after inserting the content.
2314
- */
2315
- updateSelection?: boolean;
2316
- /**
2317
- * Whether to apply input rules after inserting the content.
2318
- */
2319
- applyInputRules?: boolean;
2320
- /**
2321
- * Whether to apply paste rules after inserting the content.
2322
- */
2323
- applyPasteRules?: boolean;
2324
- /**
2325
- * Whether to throw an error if the content is invalid.
2326
- */
2327
- errorOnInvalidContent?: boolean;
2328
- }) => ReturnType;
2524
+ options?: InsertContentAtOptions) => ReturnType;
2329
2525
  };
2330
2526
  }
2331
2527
  }
2528
+ declare const insertContentAt: RawCommands['insertContentAt'];
2332
2529
 
2333
2530
  declare module '@tiptap/core' {
2334
2531
  interface Commands<ReturnType> {
@@ -2366,6 +2563,10 @@ declare module '@tiptap/core' {
2366
2563
  };
2367
2564
  }
2368
2565
  }
2566
+ declare const joinUp: RawCommands['joinUp'];
2567
+ declare const joinDown: RawCommands['joinDown'];
2568
+ declare const joinBackward: RawCommands['joinBackward'];
2569
+ declare const joinForward: RawCommands['joinForward'];
2369
2570
 
2370
2571
  declare module '@tiptap/core' {
2371
2572
  interface Commands<ReturnType> {
@@ -2378,6 +2579,7 @@ declare module '@tiptap/core' {
2378
2579
  };
2379
2580
  }
2380
2581
  }
2582
+ declare const joinItemBackward: RawCommands['joinItemBackward'];
2381
2583
 
2382
2584
  declare module '@tiptap/core' {
2383
2585
  interface Commands<ReturnType> {
@@ -2390,6 +2592,7 @@ declare module '@tiptap/core' {
2390
2592
  };
2391
2593
  }
2392
2594
  }
2595
+ declare const joinItemForward: RawCommands['joinItemForward'];
2393
2596
 
2394
2597
  declare module '@tiptap/core' {
2395
2598
  interface Commands<ReturnType> {
@@ -2401,6 +2604,7 @@ declare module '@tiptap/core' {
2401
2604
  };
2402
2605
  }
2403
2606
  }
2607
+ declare const joinTextblockBackward: RawCommands['joinTextblockBackward'];
2404
2608
 
2405
2609
  declare module '@tiptap/core' {
2406
2610
  interface Commands<ReturnType> {
@@ -2412,6 +2616,7 @@ declare module '@tiptap/core' {
2412
2616
  };
2413
2617
  }
2414
2618
  }
2619
+ declare const joinTextblockForward: RawCommands['joinTextblockForward'];
2415
2620
 
2416
2621
  declare module '@tiptap/core' {
2417
2622
  interface Commands<ReturnType> {
@@ -2425,6 +2630,7 @@ declare module '@tiptap/core' {
2425
2630
  };
2426
2631
  }
2427
2632
  }
2633
+ declare const keyboardShortcut: RawCommands['keyboardShortcut'];
2428
2634
 
2429
2635
  declare module '@tiptap/core' {
2430
2636
  interface Commands<ReturnType> {
@@ -2440,6 +2646,7 @@ declare module '@tiptap/core' {
2440
2646
  };
2441
2647
  }
2442
2648
  }
2649
+ declare const lift: RawCommands['lift'];
2443
2650
 
2444
2651
  declare module '@tiptap/core' {
2445
2652
  interface Commands<ReturnType> {
@@ -2452,6 +2659,7 @@ declare module '@tiptap/core' {
2452
2659
  };
2453
2660
  }
2454
2661
  }
2662
+ declare const liftEmptyBlock: RawCommands['liftEmptyBlock'];
2455
2663
 
2456
2664
  declare module '@tiptap/core' {
2457
2665
  interface Commands<ReturnType> {
@@ -2465,6 +2673,7 @@ declare module '@tiptap/core' {
2465
2673
  };
2466
2674
  }
2467
2675
  }
2676
+ declare const liftListItem: RawCommands['liftListItem'];
2468
2677
 
2469
2678
  declare module '@tiptap/core' {
2470
2679
  interface Commands<ReturnType> {
@@ -2477,6 +2686,7 @@ declare module '@tiptap/core' {
2477
2686
  };
2478
2687
  }
2479
2688
  }
2689
+ declare const newlineInCode: RawCommands['newlineInCode'];
2480
2690
 
2481
2691
  declare module '@tiptap/core' {
2482
2692
  interface Commands<ReturnType> {
@@ -2491,6 +2701,7 @@ declare module '@tiptap/core' {
2491
2701
  };
2492
2702
  }
2493
2703
  }
2704
+ declare const resetAttributes: RawCommands['resetAttributes'];
2494
2705
 
2495
2706
  declare module '@tiptap/core' {
2496
2707
  interface Commands<ReturnType> {
@@ -2503,6 +2714,7 @@ declare module '@tiptap/core' {
2503
2714
  };
2504
2715
  }
2505
2716
  }
2717
+ declare const scrollIntoView: RawCommands['scrollIntoView'];
2506
2718
 
2507
2719
  declare module '@tiptap/core' {
2508
2720
  interface Commands<ReturnType> {
@@ -2515,6 +2727,7 @@ declare module '@tiptap/core' {
2515
2727
  };
2516
2728
  }
2517
2729
  }
2730
+ declare const selectAll: RawCommands['selectAll'];
2518
2731
 
2519
2732
  declare module '@tiptap/core' {
2520
2733
  interface Commands<ReturnType> {
@@ -2527,6 +2740,7 @@ declare module '@tiptap/core' {
2527
2740
  };
2528
2741
  }
2529
2742
  }
2743
+ declare const selectNodeBackward: RawCommands['selectNodeBackward'];
2530
2744
 
2531
2745
  declare module '@tiptap/core' {
2532
2746
  interface Commands<ReturnType> {
@@ -2539,6 +2753,7 @@ declare module '@tiptap/core' {
2539
2753
  };
2540
2754
  }
2541
2755
  }
2756
+ declare const selectNodeForward: RawCommands['selectNodeForward'];
2542
2757
 
2543
2758
  declare module '@tiptap/core' {
2544
2759
  interface Commands<ReturnType> {
@@ -2551,6 +2766,7 @@ declare module '@tiptap/core' {
2551
2766
  };
2552
2767
  }
2553
2768
  }
2769
+ declare const selectParentNode: RawCommands['selectParentNode'];
2554
2770
 
2555
2771
  declare module '@tiptap/core' {
2556
2772
  interface Commands<ReturnType> {
@@ -2563,6 +2779,7 @@ declare module '@tiptap/core' {
2563
2779
  };
2564
2780
  }
2565
2781
  }
2782
+ declare const selectTextblockEnd: RawCommands['selectTextblockEnd'];
2566
2783
 
2567
2784
  declare module '@tiptap/core' {
2568
2785
  interface Commands<ReturnType> {
@@ -2575,7 +2792,24 @@ declare module '@tiptap/core' {
2575
2792
  };
2576
2793
  }
2577
2794
  }
2795
+ declare const selectTextblockStart: RawCommands['selectTextblockStart'];
2578
2796
 
2797
+ interface SetContentOptions {
2798
+ /**
2799
+ * Options for parsing the content.
2800
+ * @default {}
2801
+ */
2802
+ parseOptions?: ParseOptions;
2803
+ /**
2804
+ * Whether to throw an error if the content is invalid.
2805
+ */
2806
+ errorOnInvalidContent?: boolean;
2807
+ /**
2808
+ * Whether to emit an update event.
2809
+ * @default true
2810
+ */
2811
+ emitUpdate?: boolean;
2812
+ }
2579
2813
  declare module '@tiptap/core' {
2580
2814
  interface Commands<ReturnType> {
2581
2815
  setContent: {
@@ -2594,25 +2828,11 @@ declare module '@tiptap/core' {
2594
2828
  /**
2595
2829
  * Options for `setContent`.
2596
2830
  */
2597
- options?: {
2598
- /**
2599
- * Options for parsing the content.
2600
- * @default {}
2601
- */
2602
- parseOptions?: ParseOptions;
2603
- /**
2604
- * Whether to throw an error if the content is invalid.
2605
- */
2606
- errorOnInvalidContent?: boolean;
2607
- /**
2608
- * Whether to emit an update event.
2609
- * @default true
2610
- */
2611
- emitUpdate?: boolean;
2612
- }) => ReturnType;
2831
+ options?: SetContentOptions) => ReturnType;
2613
2832
  };
2614
2833
  }
2615
2834
  }
2835
+ declare const setContent: RawCommands['setContent'];
2616
2836
 
2617
2837
  declare module '@tiptap/core' {
2618
2838
  interface Commands<ReturnType> {
@@ -2626,6 +2846,7 @@ declare module '@tiptap/core' {
2626
2846
  };
2627
2847
  }
2628
2848
  }
2849
+ declare const setMark: RawCommands['setMark'];
2629
2850
 
2630
2851
  declare module '@tiptap/core' {
2631
2852
  interface Commands<ReturnType> {
@@ -2640,6 +2861,7 @@ declare module '@tiptap/core' {
2640
2861
  };
2641
2862
  }
2642
2863
  }
2864
+ declare const setMeta: RawCommands['setMeta'];
2643
2865
 
2644
2866
  declare module '@tiptap/core' {
2645
2867
  interface Commands<ReturnType> {
@@ -2654,6 +2876,7 @@ declare module '@tiptap/core' {
2654
2876
  };
2655
2877
  }
2656
2878
  }
2879
+ declare const setNode: RawCommands['setNode'];
2657
2880
 
2658
2881
  declare module '@tiptap/core' {
2659
2882
  interface Commands<ReturnType> {
@@ -2667,6 +2890,7 @@ declare module '@tiptap/core' {
2667
2890
  };
2668
2891
  }
2669
2892
  }
2893
+ declare const setNodeSelection: RawCommands['setNodeSelection'];
2670
2894
 
2671
2895
  declare module '@tiptap/core' {
2672
2896
  interface Commands<ReturnType> {
@@ -2680,6 +2904,7 @@ declare module '@tiptap/core' {
2680
2904
  };
2681
2905
  }
2682
2906
  }
2907
+ declare const setTextSelection: RawCommands['setTextSelection'];
2683
2908
 
2684
2909
  declare module '@tiptap/core' {
2685
2910
  interface Commands<ReturnType> {
@@ -2693,6 +2918,7 @@ declare module '@tiptap/core' {
2693
2918
  };
2694
2919
  }
2695
2920
  }
2921
+ declare const sinkListItem: RawCommands['sinkListItem'];
2696
2922
 
2697
2923
  declare module '@tiptap/core' {
2698
2924
  interface Commands<ReturnType> {
@@ -2709,6 +2935,7 @@ declare module '@tiptap/core' {
2709
2935
  };
2710
2936
  }
2711
2937
  }
2938
+ declare const splitBlock: RawCommands['splitBlock'];
2712
2939
 
2713
2940
  declare module '@tiptap/core' {
2714
2941
  interface Commands<ReturnType> {
@@ -2723,6 +2950,7 @@ declare module '@tiptap/core' {
2723
2950
  };
2724
2951
  }
2725
2952
  }
2953
+ declare const splitListItem: RawCommands['splitListItem'];
2726
2954
 
2727
2955
  declare module '@tiptap/core' {
2728
2956
  interface Commands<ReturnType> {
@@ -2739,6 +2967,7 @@ declare module '@tiptap/core' {
2739
2967
  };
2740
2968
  }
2741
2969
  }
2970
+ declare const toggleList: RawCommands['toggleList'];
2742
2971
 
2743
2972
  declare module '@tiptap/core' {
2744
2973
  interface Commands<ReturnType> {
@@ -2767,6 +2996,7 @@ declare module '@tiptap/core' {
2767
2996
  };
2768
2997
  }
2769
2998
  }
2999
+ declare const toggleMark: RawCommands['toggleMark'];
2770
3000
 
2771
3001
  declare module '@tiptap/core' {
2772
3002
  interface Commands<ReturnType> {
@@ -2782,6 +3012,7 @@ declare module '@tiptap/core' {
2782
3012
  };
2783
3013
  }
2784
3014
  }
3015
+ declare const toggleNode: RawCommands['toggleNode'];
2785
3016
 
2786
3017
  declare module '@tiptap/core' {
2787
3018
  interface Commands<ReturnType> {
@@ -2796,6 +3027,7 @@ declare module '@tiptap/core' {
2796
3027
  };
2797
3028
  }
2798
3029
  }
3030
+ declare const toggleWrap: RawCommands['toggleWrap'];
2799
3031
 
2800
3032
  declare module '@tiptap/core' {
2801
3033
  interface Commands<ReturnType> {
@@ -2808,6 +3040,7 @@ declare module '@tiptap/core' {
2808
3040
  };
2809
3041
  }
2810
3042
  }
3043
+ declare const undoInputRule: RawCommands['undoInputRule'];
2811
3044
 
2812
3045
  declare module '@tiptap/core' {
2813
3046
  interface Commands<ReturnType> {
@@ -2820,6 +3053,7 @@ declare module '@tiptap/core' {
2820
3053
  };
2821
3054
  }
2822
3055
  }
3056
+ declare const unsetAllMarks: RawCommands['unsetAllMarks'];
2823
3057
 
2824
3058
  declare module '@tiptap/core' {
2825
3059
  interface Commands<ReturnType> {
@@ -2843,6 +3077,7 @@ declare module '@tiptap/core' {
2843
3077
  };
2844
3078
  }
2845
3079
  }
3080
+ declare const unsetMark: RawCommands['unsetMark'];
2846
3081
 
2847
3082
  declare module '@tiptap/core' {
2848
3083
  interface Commands<ReturnType> {
@@ -2865,6 +3100,7 @@ declare module '@tiptap/core' {
2865
3100
  };
2866
3101
  }
2867
3102
  }
3103
+ declare const updateAttributes: RawCommands['updateAttributes'];
2868
3104
 
2869
3105
  declare module '@tiptap/core' {
2870
3106
  interface Commands<ReturnType> {
@@ -2879,6 +3115,7 @@ declare module '@tiptap/core' {
2879
3115
  };
2880
3116
  }
2881
3117
  }
3118
+ declare const wrapIn: RawCommands['wrapIn'];
2882
3119
 
2883
3120
  declare module '@tiptap/core' {
2884
3121
  interface Commands<ReturnType> {
@@ -2893,6 +3130,72 @@ declare module '@tiptap/core' {
2893
3130
  };
2894
3131
  }
2895
3132
  }
3133
+ declare const wrapInList: RawCommands['wrapInList'];
3134
+
3135
+ type index$2_InsertContentAtOptions = InsertContentAtOptions;
3136
+ type index$2_InsertContentOptions = InsertContentOptions;
3137
+ type index$2_SetContentOptions = SetContentOptions;
3138
+ declare const index$2_blur: typeof blur;
3139
+ declare const index$2_clearContent: typeof clearContent;
3140
+ declare const index$2_clearNodes: typeof clearNodes;
3141
+ declare const index$2_command: typeof command;
3142
+ declare const index$2_createParagraphNear: typeof createParagraphNear;
3143
+ declare const index$2_cut: typeof cut;
3144
+ declare const index$2_deleteCurrentNode: typeof deleteCurrentNode;
3145
+ declare const index$2_deleteNode: typeof deleteNode;
3146
+ declare const index$2_deleteRange: typeof deleteRange;
3147
+ declare const index$2_deleteSelection: typeof deleteSelection;
3148
+ declare const index$2_enter: typeof enter;
3149
+ declare const index$2_exitCode: typeof exitCode;
3150
+ declare const index$2_extendMarkRange: typeof extendMarkRange;
3151
+ declare const index$2_first: typeof first;
3152
+ declare const index$2_focus: typeof focus;
3153
+ declare const index$2_forEach: typeof forEach;
3154
+ declare const index$2_insertContent: typeof insertContent;
3155
+ declare const index$2_insertContentAt: typeof insertContentAt;
3156
+ declare const index$2_joinBackward: typeof joinBackward;
3157
+ declare const index$2_joinDown: typeof joinDown;
3158
+ declare const index$2_joinForward: typeof joinForward;
3159
+ declare const index$2_joinItemBackward: typeof joinItemBackward;
3160
+ declare const index$2_joinItemForward: typeof joinItemForward;
3161
+ declare const index$2_joinTextblockBackward: typeof joinTextblockBackward;
3162
+ declare const index$2_joinTextblockForward: typeof joinTextblockForward;
3163
+ declare const index$2_joinUp: typeof joinUp;
3164
+ declare const index$2_keyboardShortcut: typeof keyboardShortcut;
3165
+ declare const index$2_lift: typeof lift;
3166
+ declare const index$2_liftEmptyBlock: typeof liftEmptyBlock;
3167
+ declare const index$2_liftListItem: typeof liftListItem;
3168
+ declare const index$2_newlineInCode: typeof newlineInCode;
3169
+ declare const index$2_resetAttributes: typeof resetAttributes;
3170
+ declare const index$2_scrollIntoView: typeof scrollIntoView;
3171
+ declare const index$2_selectAll: typeof selectAll;
3172
+ declare const index$2_selectNodeBackward: typeof selectNodeBackward;
3173
+ declare const index$2_selectNodeForward: typeof selectNodeForward;
3174
+ declare const index$2_selectParentNode: typeof selectParentNode;
3175
+ declare const index$2_selectTextblockEnd: typeof selectTextblockEnd;
3176
+ declare const index$2_selectTextblockStart: typeof selectTextblockStart;
3177
+ declare const index$2_setContent: typeof setContent;
3178
+ declare const index$2_setMark: typeof setMark;
3179
+ declare const index$2_setMeta: typeof setMeta;
3180
+ declare const index$2_setNode: typeof setNode;
3181
+ declare const index$2_setNodeSelection: typeof setNodeSelection;
3182
+ declare const index$2_setTextSelection: typeof setTextSelection;
3183
+ declare const index$2_sinkListItem: typeof sinkListItem;
3184
+ declare const index$2_splitBlock: typeof splitBlock;
3185
+ declare const index$2_splitListItem: typeof splitListItem;
3186
+ declare const index$2_toggleList: typeof toggleList;
3187
+ declare const index$2_toggleMark: typeof toggleMark;
3188
+ declare const index$2_toggleNode: typeof toggleNode;
3189
+ declare const index$2_toggleWrap: typeof toggleWrap;
3190
+ declare const index$2_undoInputRule: typeof undoInputRule;
3191
+ declare const index$2_unsetAllMarks: typeof unsetAllMarks;
3192
+ declare const index$2_unsetMark: typeof unsetMark;
3193
+ declare const index$2_updateAttributes: typeof updateAttributes;
3194
+ declare const index$2_wrapIn: typeof wrapIn;
3195
+ declare const index$2_wrapInList: typeof wrapInList;
3196
+ declare namespace index$2 {
3197
+ export { type index$2_InsertContentAtOptions as InsertContentAtOptions, type index$2_InsertContentOptions as InsertContentOptions, type index$2_SetContentOptions as SetContentOptions, index$2_blur as blur, index$2_clearContent as clearContent, index$2_clearNodes as clearNodes, index$2_command as command, index$2_createParagraphNear as createParagraphNear, index$2_cut as cut, index$2_deleteCurrentNode as deleteCurrentNode, index$2_deleteNode as deleteNode, index$2_deleteRange as deleteRange, index$2_deleteSelection as deleteSelection, index$2_enter as enter, index$2_exitCode as exitCode, index$2_extendMarkRange as extendMarkRange, index$2_first as first, index$2_focus as focus, index$2_forEach as forEach, index$2_insertContent as insertContent, index$2_insertContentAt as insertContentAt, index$2_joinBackward as joinBackward, index$2_joinDown as joinDown, index$2_joinForward as joinForward, index$2_joinItemBackward as joinItemBackward, index$2_joinItemForward as joinItemForward, index$2_joinTextblockBackward as joinTextblockBackward, index$2_joinTextblockForward as joinTextblockForward, index$2_joinUp as joinUp, index$2_keyboardShortcut as keyboardShortcut, index$2_lift as lift, index$2_liftEmptyBlock as liftEmptyBlock, index$2_liftListItem as liftListItem, index$2_newlineInCode as newlineInCode, index$2_resetAttributes as resetAttributes, index$2_scrollIntoView as scrollIntoView, index$2_selectAll as selectAll, index$2_selectNodeBackward as selectNodeBackward, index$2_selectNodeForward as selectNodeForward, index$2_selectParentNode as selectParentNode, index$2_selectTextblockEnd as selectTextblockEnd, index$2_selectTextblockStart as selectTextblockStart, index$2_setContent as setContent, index$2_setMark as setMark, index$2_setMeta as setMeta, index$2_setNode as setNode, index$2_setNodeSelection as setNodeSelection, index$2_setTextSelection as setTextSelection, index$2_sinkListItem as sinkListItem, index$2_splitBlock as splitBlock, index$2_splitListItem as splitListItem, index$2_toggleList as toggleList, index$2_toggleMark as toggleMark, index$2_toggleNode as toggleNode, index$2_toggleWrap as toggleWrap, index$2_undoInputRule as undoInputRule, index$2_unsetAllMarks as unsetAllMarks, index$2_unsetMark as unsetMark, index$2_updateAttributes as updateAttributes, index$2_wrapIn as wrapIn, index$2_wrapInList as wrapInList };
3198
+ }
2896
3199
 
2897
3200
  declare const Commands$1: Extension<any, any>;
2898
3201
 
@@ -2914,17 +3217,17 @@ declare const Paste: Extension<any, any>;
2914
3217
 
2915
3218
  declare const Tabindex: Extension<any, any>;
2916
3219
 
2917
- declare const index_ClipboardTextSerializer: typeof ClipboardTextSerializer;
2918
- declare const index_Delete: typeof Delete;
2919
- declare const index_Drop: typeof Drop;
2920
- declare const index_Editable: typeof Editable;
2921
- declare const index_FocusEvents: typeof FocusEvents;
2922
- declare const index_Keymap: typeof Keymap;
2923
- declare const index_Paste: typeof Paste;
2924
- declare const index_Tabindex: typeof Tabindex;
2925
- declare const index_focusEventsPluginKey: typeof focusEventsPluginKey;
2926
- declare namespace index {
2927
- export { index_ClipboardTextSerializer as ClipboardTextSerializer, Commands$1 as Commands, index_Delete as Delete, index_Drop as Drop, index_Editable as Editable, index_FocusEvents as FocusEvents, index_Keymap as Keymap, index_Paste as Paste, index_Tabindex as Tabindex, index_focusEventsPluginKey as focusEventsPluginKey };
3220
+ declare const index$1_ClipboardTextSerializer: typeof ClipboardTextSerializer;
3221
+ declare const index$1_Delete: typeof Delete;
3222
+ declare const index$1_Drop: typeof Drop;
3223
+ declare const index$1_Editable: typeof Editable;
3224
+ declare const index$1_FocusEvents: typeof FocusEvents;
3225
+ declare const index$1_Keymap: typeof Keymap;
3226
+ declare const index$1_Paste: typeof Paste;
3227
+ declare const index$1_Tabindex: typeof Tabindex;
3228
+ declare const index$1_focusEventsPluginKey: typeof focusEventsPluginKey;
3229
+ declare namespace index$1 {
3230
+ export { index$1_ClipboardTextSerializer as ClipboardTextSerializer, Commands$1 as Commands, index$1_Delete as Delete, index$1_Drop as Drop, index$1_Editable as Editable, index$1_FocusEvents as FocusEvents, index$1_Keymap as Keymap, index$1_Paste as Paste, index$1_Tabindex as Tabindex, index$1_focusEventsPluginKey as focusEventsPluginKey };
2928
3231
  }
2929
3232
 
2930
3233
  interface TiptapEditorHTMLElement extends HTMLElement {
@@ -3290,7 +3593,7 @@ declare function markPasteRule(config: {
3290
3593
  /**
3291
3594
  * Build an paste rule that adds a node when the
3292
3595
  * matched text is pasted into it.
3293
- * @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#paste-rules
3596
+ * @see https://tiptap.dev/docs/editor/api/paste-rules
3294
3597
  */
3295
3598
  declare function nodePasteRule(config: {
3296
3599
  find: PasteRuleFinder;
@@ -3369,6 +3672,376 @@ declare function isRegExp(value: any): value is RegExp;
3369
3672
 
3370
3673
  declare function isString(value: any): value is string;
3371
3674
 
3675
+ /**
3676
+ * @fileoverview Utility functions for parsing and serializing markdown attributes.
3677
+ *
3678
+ * These utilities handle the common patterns for parsing attribute strings
3679
+ * in various markdown syntaxes like Pandoc attributes.
3680
+ */
3681
+ /**
3682
+ * Parses a Pandoc-style attribute string into an object.
3683
+ *
3684
+ * Supports the following patterns:
3685
+ * - Classes: `.className` → `{ class: 'className' }`
3686
+ * - IDs: `#myId` → `{ id: 'myId' }`
3687
+ * - Key-value pairs: `key="value"` → `{ key: 'value' }`
3688
+ * - Boolean attributes: `disabled` → `{ disabled: true }`
3689
+ *
3690
+ * @param attrString - The attribute string to parse
3691
+ * @returns Parsed attributes object
3692
+ *
3693
+ * @example
3694
+ * ```ts
3695
+ * parseAttributes('.btn #submit disabled type="button"')
3696
+ * // → { class: 'btn', id: 'submit', disabled: true, type: 'button' }
3697
+ * ```
3698
+ */
3699
+ declare function parseAttributes(attrString: string): Record<string, any>;
3700
+ /**
3701
+ * Serializes an attributes object back to a Pandoc-style attribute string.
3702
+ *
3703
+ * @param attributes - The attributes object to serialize
3704
+ * @returns Serialized attribute string
3705
+ *
3706
+ * @example
3707
+ * ```ts
3708
+ * serializeAttributes({ class: 'btn primary', id: 'submit', disabled: true, type: 'button' })
3709
+ * // → '.btn.primary #submit disabled type="button"'
3710
+ * ```
3711
+ */
3712
+ declare function serializeAttributes(attributes: Record<string, any>): string;
3713
+
3714
+ interface AtomBlockMarkdownSpecOptions {
3715
+ /** The Tiptap node name this spec is for */
3716
+ nodeName: string;
3717
+ /** The markdown syntax name (defaults to nodeName if not provided) */
3718
+ name?: string;
3719
+ /** Function to parse attributes from token attribute string */
3720
+ parseAttributes?: (attrString: string) => Record<string, any>;
3721
+ /** Function to serialize attributes back to string for rendering */
3722
+ serializeAttributes?: (attrs: Record<string, any>) => string;
3723
+ /** Default attributes to apply when parsing */
3724
+ defaultAttributes?: Record<string, any>;
3725
+ /** Required attributes that must be present for successful parsing */
3726
+ requiredAttributes?: string[];
3727
+ /** Attributes that are allowed to be rendered back to markdown (whitelist) */
3728
+ allowedAttributes?: string[];
3729
+ }
3730
+ /**
3731
+ * Creates a complete markdown spec for atomic block nodes using Pandoc syntax.
3732
+ *
3733
+ * The generated spec handles:
3734
+ * - Parsing self-closing blocks with `:::blockName {attributes}`
3735
+ * - Extracting and parsing attributes
3736
+ * - Validating required attributes
3737
+ * - Rendering blocks back to markdown
3738
+ *
3739
+ * @param options - Configuration for the atomic block markdown spec
3740
+ * @returns Complete markdown specification object
3741
+ *
3742
+ * @example
3743
+ * ```ts
3744
+ * const youtubeSpec = createAtomBlockMarkdownSpec({
3745
+ * nodeName: 'youtube',
3746
+ * requiredAttributes: ['src'],
3747
+ * defaultAttributes: { start: 0 },
3748
+ * allowedAttributes: ['src', 'start', 'width', 'height'] // Only these get rendered to markdown
3749
+ * })
3750
+ *
3751
+ * // Usage in extension:
3752
+ * export const Youtube = Node.create({
3753
+ * // ... other config
3754
+ * markdown: youtubeSpec
3755
+ * })
3756
+ * ```
3757
+ */
3758
+ declare function createAtomBlockMarkdownSpec(options: AtomBlockMarkdownSpecOptions): {
3759
+ parseMarkdown: (token: MarkdownToken, h: MarkdownParseHelpers) => MarkdownParseResult;
3760
+ markdownTokenizer: MarkdownTokenizer;
3761
+ renderMarkdown: (node: JSONContent) => string;
3762
+ };
3763
+
3764
+ interface BlockMarkdownSpecOptions {
3765
+ /** The Tiptap node name this spec is for */
3766
+ nodeName: string;
3767
+ /** The markdown syntax name (defaults to nodeName if not provided) */
3768
+ name?: string;
3769
+ /** Function to extract content from the node for serialization */
3770
+ getContent?: (token: MarkdownToken) => string;
3771
+ /** Function to parse attributes from the attribute string */
3772
+ parseAttributes?: (attrString: string) => Record<string, any>;
3773
+ /** Function to serialize attributes to string */
3774
+ serializeAttributes?: (attrs: Record<string, any>) => string;
3775
+ /** Default attributes to apply when parsing */
3776
+ defaultAttributes?: Record<string, any>;
3777
+ /** Content type: 'block' allows paragraphs/lists/etc, 'inline' only allows bold/italic/links/etc */
3778
+ content?: 'block' | 'inline';
3779
+ /** Allowlist of attributes to include in markdown (if not provided, all attributes are included) */
3780
+ allowedAttributes?: string[];
3781
+ }
3782
+ /**
3783
+ * Creates a complete markdown spec for block-level nodes using Pandoc syntax.
3784
+ *
3785
+ * The generated spec handles:
3786
+ * - Parsing blocks with `:::blockName {attributes}` syntax
3787
+ * - Extracting and parsing attributes
3788
+ * - Rendering blocks back to markdown with proper formatting
3789
+ * - Nested content support
3790
+ *
3791
+ * @param options - Configuration for the block markdown spec
3792
+ * @returns Complete markdown specification object
3793
+ *
3794
+ * @example
3795
+ * ```ts
3796
+ * const calloutSpec = createBlockMarkdownSpec({
3797
+ * nodeName: 'callout',
3798
+ * defaultAttributes: { type: 'info' },
3799
+ * allowedAttributes: ['type', 'title'] // Only these get rendered to markdown
3800
+ * })
3801
+ *
3802
+ * // Usage in extension:
3803
+ * export const Callout = Node.create({
3804
+ * // ... other config
3805
+ * markdown: calloutSpec
3806
+ * })
3807
+ * ```
3808
+ */
3809
+ declare function createBlockMarkdownSpec(options: BlockMarkdownSpecOptions): {
3810
+ parseMarkdown: (token: MarkdownToken, h: MarkdownParseHelpers) => MarkdownParseResult;
3811
+ markdownTokenizer: MarkdownTokenizer;
3812
+ renderMarkdown: (node: JSONContent, h: MarkdownRendererHelpers) => string;
3813
+ };
3814
+
3815
+ interface InlineMarkdownSpecOptions {
3816
+ /** The Tiptap node name this spec is for */
3817
+ nodeName: string;
3818
+ /** The shortcode name (defaults to nodeName if not provided) */
3819
+ name?: string;
3820
+ /** Function to extract content from the node for serialization */
3821
+ getContent?: (node: any) => string;
3822
+ /** Function to parse attributes from the attribute string */
3823
+ parseAttributes?: (attrString: string) => Record<string, any>;
3824
+ /** Function to serialize attributes to string */
3825
+ serializeAttributes?: (attrs: Record<string, any>) => string;
3826
+ /** Default attributes to apply when parsing */
3827
+ defaultAttributes?: Record<string, any>;
3828
+ /** Whether this is a self-closing shortcode (no content, like [emoji name=party]) */
3829
+ selfClosing?: boolean;
3830
+ /** Allowlist of attributes to include in markdown (if not provided, all attributes are included) */
3831
+ allowedAttributes?: string[];
3832
+ }
3833
+ /**
3834
+ * Creates a complete markdown spec for inline nodes using attribute syntax.
3835
+ *
3836
+ * The generated spec handles:
3837
+ * - Parsing shortcode syntax with `[nodeName attributes]content[/nodeName]` format
3838
+ * - Self-closing shortcodes like `[emoji name=party_popper]`
3839
+ * - Extracting and parsing attributes from the opening tag
3840
+ * - Rendering inline elements back to shortcode markdown
3841
+ * - Supporting both content-based and self-closing inline elements
3842
+ *
3843
+ * @param options - Configuration for the inline markdown spec
3844
+ * @returns Complete markdown specification object
3845
+ *
3846
+ * @example
3847
+ * ```ts
3848
+ * // Self-closing mention: [mention id="madonna" label="Madonna"]
3849
+ * const mentionSpec = createInlineMarkdownSpec({
3850
+ * nodeName: 'mention',
3851
+ * selfClosing: true,
3852
+ * defaultAttributes: { type: 'user' },
3853
+ * allowedAttributes: ['id', 'label'] // Only these get rendered to markdown
3854
+ * })
3855
+ *
3856
+ * // Self-closing emoji: [emoji name="party_popper"]
3857
+ * const emojiSpec = createInlineMarkdownSpec({
3858
+ * nodeName: 'emoji',
3859
+ * selfClosing: true,
3860
+ * allowedAttributes: ['name']
3861
+ * })
3862
+ *
3863
+ * // With content: [highlight color="yellow"]text[/highlight]
3864
+ * const highlightSpec = createInlineMarkdownSpec({
3865
+ * nodeName: 'highlight',
3866
+ * selfClosing: false,
3867
+ * allowedAttributes: ['color', 'style']
3868
+ * })
3869
+ *
3870
+ * // Usage in extension:
3871
+ * export const Mention = Node.create({
3872
+ * name: 'mention', // Must match nodeName
3873
+ * // ... other config
3874
+ * markdown: mentionSpec
3875
+ * })
3876
+ * ```
3877
+ */
3878
+ declare function createInlineMarkdownSpec(options: InlineMarkdownSpecOptions): {
3879
+ parseMarkdown: (token: MarkdownToken, h: MarkdownParseHelpers) => MarkdownParseResult;
3880
+ markdownTokenizer: MarkdownTokenizer;
3881
+ renderMarkdown: (node: JSONContent) => string;
3882
+ };
3883
+
3884
+ /**
3885
+ * @fileoverview Utility for parsing indented markdown blocks with hierarchical nesting.
3886
+ *
3887
+ * This utility handles the complex logic of parsing markdown blocks that can contain
3888
+ * nested content based on indentation levels, maintaining proper hierarchical structure
3889
+ * for lists, task lists, and other indented block types.
3890
+ */
3891
+ interface ParsedBlock {
3892
+ type: string;
3893
+ raw: string;
3894
+ mainContent: string;
3895
+ indentLevel: number;
3896
+ nestedContent?: string;
3897
+ nestedTokens?: any[];
3898
+ [key: string]: any;
3899
+ }
3900
+ interface BlockParserConfig {
3901
+ /** Regex pattern to match block items */
3902
+ itemPattern: RegExp;
3903
+ /** Function to extract data from regex match */
3904
+ extractItemData: (match: RegExpMatchArray) => {
3905
+ mainContent: string;
3906
+ indentLevel: number;
3907
+ [key: string]: any;
3908
+ };
3909
+ /** Function to create the final token */
3910
+ createToken: (data: any, nestedTokens?: any[]) => ParsedBlock;
3911
+ /** Base indentation to remove from nested content (default: 2 spaces) */
3912
+ baseIndentSize?: number;
3913
+ /**
3914
+ * Custom parser for nested content. If provided, this will be called instead
3915
+ * of the default lexer.blockTokens() for parsing nested content.
3916
+ * This allows recursive parsing of the same block type.
3917
+ */
3918
+ customNestedParser?: (dedentedContent: string) => any[] | undefined;
3919
+ }
3920
+ /**
3921
+ * Parses markdown text into hierarchical indented blocks with proper nesting.
3922
+ *
3923
+ * This utility handles:
3924
+ * - Line-by-line parsing with pattern matching
3925
+ * - Hierarchical nesting based on indentation levels
3926
+ * - Nested content collection and parsing
3927
+ * - Empty line handling
3928
+ * - Content dedenting for nested blocks
3929
+ *
3930
+ * The key difference from flat parsing is that this maintains the hierarchical
3931
+ * structure where nested items become `nestedTokens` of their parent items,
3932
+ * rather than being flattened into a single array.
3933
+ *
3934
+ * @param src - The markdown source text to parse
3935
+ * @param config - Configuration object defining how to parse and create tokens
3936
+ * @param lexer - Markdown lexer for parsing nested content
3937
+ * @returns Parsed result with hierarchical items, or undefined if no matches
3938
+ *
3939
+ * @example
3940
+ * ```ts
3941
+ * const result = parseIndentedBlocks(src, {
3942
+ * itemPattern: /^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,
3943
+ * extractItemData: (match) => ({
3944
+ * indentLevel: match[1].length,
3945
+ * mainContent: match[4],
3946
+ * checked: match[3].toLowerCase() === 'x'
3947
+ * }),
3948
+ * createToken: (data, nestedTokens) => ({
3949
+ * type: 'taskItem',
3950
+ * checked: data.checked,
3951
+ * text: data.mainContent,
3952
+ * nestedTokens
3953
+ * })
3954
+ * }, lexer)
3955
+ * ```
3956
+ */
3957
+ declare function parseIndentedBlocks(src: string, config: BlockParserConfig, lexer: {
3958
+ inlineTokens: (src: string) => any[];
3959
+ blockTokens: (src: string) => any[];
3960
+ }): {
3961
+ items: ParsedBlock[];
3962
+ raw: string;
3963
+ } | undefined;
3964
+
3965
+ /**
3966
+ * @fileoverview Utility functions for rendering nested content in markdown.
3967
+ *
3968
+ * This module provides reusable utilities for extensions that need to render
3969
+ * content with a prefix on the main line and properly indented nested content.
3970
+ */
3971
+ /**
3972
+ * Utility function for rendering content with a main line prefix and nested indented content.
3973
+ *
3974
+ * This function handles the common pattern of rendering content with:
3975
+ * 1. A main line with a prefix (like "- " for lists, "> " for blockquotes, etc.)
3976
+ * 2. Nested content that gets indented properly
3977
+ *
3978
+ * @param node - The ProseMirror node representing the content
3979
+ * @param h - The markdown renderer helper
3980
+ * @param prefixOrGenerator - Either a string prefix or a function that generates the prefix from context
3981
+ * @param ctx - Optional context object (used when prefixOrGenerator is a function)
3982
+ * @returns The rendered markdown string
3983
+ *
3984
+ * @example
3985
+ * ```ts
3986
+ * // For a bullet list item with static prefix
3987
+ * return renderNestedMarkdownContent(node, h, '- ')
3988
+ *
3989
+ * // For a task item with static prefix
3990
+ * const prefix = `- [${node.attrs?.checked ? 'x' : ' '}] `
3991
+ * return renderNestedMarkdownContent(node, h, prefix)
3992
+ *
3993
+ * // For a blockquote with static prefix
3994
+ * return renderNestedMarkdownContent(node, h, '> ')
3995
+ *
3996
+ * // For content with dynamic prefix based on context
3997
+ * return renderNestedMarkdownContent(node, h, ctx => {
3998
+ * if (ctx.parentType === 'orderedList') {
3999
+ * return `${ctx.index + 1}. `
4000
+ * }
4001
+ * return '- '
4002
+ * }, ctx)
4003
+ *
4004
+ * // Custom extension example
4005
+ * const CustomContainer = Node.create({
4006
+ * name: 'customContainer',
4007
+ * // ... other config
4008
+ * markdown: {
4009
+ * render: (node, h) => {
4010
+ * const type = node.attrs?.type || 'info'
4011
+ * return renderNestedMarkdownContent(node, h, `[${type}] `)
4012
+ * }
4013
+ * }
4014
+ * })
4015
+ * ```
4016
+ */
4017
+ declare function renderNestedMarkdownContent(node: JSONContent, h: {
4018
+ renderChildren: (nodes: JSONContent[]) => string;
4019
+ indent: (text: string) => string;
4020
+ }, prefixOrGenerator: string | ((ctx: any) => string), ctx?: any): string;
4021
+
4022
+ /**
4023
+ * @fileoverview Markdown utilities for creating standardized markdown specs.
4024
+ *
4025
+ * This module provides utilities for creating complete markdown specifications
4026
+ * for different types of nodes using unified syntax patterns.
4027
+ */
4028
+
4029
+ type index_AtomBlockMarkdownSpecOptions = AtomBlockMarkdownSpecOptions;
4030
+ type index_BlockMarkdownSpecOptions = BlockMarkdownSpecOptions;
4031
+ type index_BlockParserConfig = BlockParserConfig;
4032
+ type index_InlineMarkdownSpecOptions = InlineMarkdownSpecOptions;
4033
+ type index_ParsedBlock = ParsedBlock;
4034
+ declare const index_createAtomBlockMarkdownSpec: typeof createAtomBlockMarkdownSpec;
4035
+ declare const index_createBlockMarkdownSpec: typeof createBlockMarkdownSpec;
4036
+ declare const index_createInlineMarkdownSpec: typeof createInlineMarkdownSpec;
4037
+ declare const index_parseAttributes: typeof parseAttributes;
4038
+ declare const index_parseIndentedBlocks: typeof parseIndentedBlocks;
4039
+ declare const index_renderNestedMarkdownContent: typeof renderNestedMarkdownContent;
4040
+ declare const index_serializeAttributes: typeof serializeAttributes;
4041
+ declare namespace index {
4042
+ export { type index_AtomBlockMarkdownSpecOptions as AtomBlockMarkdownSpecOptions, type index_BlockMarkdownSpecOptions as BlockMarkdownSpecOptions, type index_BlockParserConfig as BlockParserConfig, type index_InlineMarkdownSpecOptions as InlineMarkdownSpecOptions, type index_ParsedBlock as ParsedBlock, index_createAtomBlockMarkdownSpec as createAtomBlockMarkdownSpec, index_createBlockMarkdownSpec as createBlockMarkdownSpec, index_createInlineMarkdownSpec as createInlineMarkdownSpec, index_parseAttributes as parseAttributes, index_parseIndentedBlocks as parseIndentedBlocks, index_renderNestedMarkdownContent as renderNestedMarkdownContent, index_serializeAttributes as serializeAttributes };
4043
+ }
4044
+
3372
4045
  declare function mergeAttributes(...objects: Record<string, any>[]): Record<string, any>;
3373
4046
 
3374
4047
  declare function mergeDeep(target: Record<string, any>, source: Record<string, any>): Record<string, any>;
@@ -3398,4 +4071,4 @@ interface Commands<ReturnType = any> {
3398
4071
  interface Storage {
3399
4072
  }
3400
4073
 
3401
- export { type AnyCommands, type AnyConfig, type AnyExtension, type Attribute, type Attributes$1 as Attributes, type CanCommands, type ChainedCommands, type ChangedRange, type Command, CommandManager, type CommandProps, type CommandSpec, type Commands, type Content, type CreateNodeFromContentOptions, type DOMNode, type DOMOutputSpecArray$1 as DOMOutputSpecArray, type DecorationType, type DecorationWithType, type Diff, type Dispatch, type DocumentType, Editor, type EditorEvents, type EditorOptions, type EnableRules, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type GlobalAttributes, type HTMLContent, InputRule, type InputRuleFinder, type InputRuleMatch, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MaybeReturnType, type MaybeThisParameterType, Node, type NodeConfig, NodePos, type NodeRange, type NodeType, NodeView, type NodeViewProps, type NodeViewRenderer, type NodeViewRendererOptions, type NodeViewRendererProps, type NodeWithPos, type Overwrite, type ParentConfig, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type SingleCommands, type Storage, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type ValuesOf, callOrReturn, canInsertNode, combineTransactionSteps, createChainableState, createDocument, h as createElement, createNodeFromContent, createStyleTag, defaultBlockAt, deleteProps, elementFromString, escapeForRegEx, index as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, flattenExtensions, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, h, injectExtensionAttributesToParseRule, inputRulesPlugin, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, markInputRule, markPasteRule, mergeAttributes, mergeDeep, minMax, nodeInputRule, nodePasteRule, objectIncludes, pasteRulesPlugin, posToDOMRect, removeDuplicates, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, selectionToInsertionEnd, sortExtensions, splitExtensions, textInputRule, textPasteRule, textblockTypeInputRule, updateMarkViewAttributes, wrappingInputRule };
4074
+ export { type AnyCommands, type AnyConfig, type AnyExtension, type AtomBlockMarkdownSpecOptions, type Attribute, type Attributes$1 as Attributes, type BlockMarkdownSpecOptions, type BlockParserConfig, type CanCommands, type ChainedCommands, type ChangedRange, type Command, CommandManager, type CommandProps, type CommandSpec, type Commands, type Content, type CreateNodeFromContentOptions, type DOMNode, type DOMOutputSpecArray$1 as DOMOutputSpecArray, type DecorationType, type DecorationWithType, type Diff, type Dispatch, type DocumentType, Editor, type EditorEvents, type EditorOptions, type EnableRules, Extendable, type ExtendableConfig, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type FullMarkdownHelpers, type GlobalAttributes, type HTMLContent, type InlineMarkdownSpecOptions, InputRule, type InputRuleFinder, type InputRuleMatch, type InsertContentAtOptions, type InsertContentOptions, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MarkdownExtensionSpec, type MarkdownHelpers, type MarkdownLexerConfiguration, type MarkdownParseHelpers, type MarkdownParseResult, type MarkdownRendererHelpers, type MarkdownToken, type MarkdownTokenizer, type MaybeReturnType, type MaybeThisParameterType, Node, type NodeConfig, NodePos, type NodeRange, type NodeType, NodeView, type NodeViewProps, type NodeViewRenderer, type NodeViewRendererOptions, type NodeViewRendererProps, type NodeWithPos, type Overwrite, type ParentConfig, type ParsedBlock, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type RenderContext, type SetContentOptions, type SingleCommands, type Storage, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type ValuesOf, blur, callOrReturn, canInsertNode, clearContent, clearNodes, combineTransactionSteps, command, index$2 as commands, createAtomBlockMarkdownSpec, createBlockMarkdownSpec, createChainableState, createDocument, h as createElement, createInlineMarkdownSpec, createNodeFromContent, createParagraphNear, createStyleTag, cut, defaultBlockAt, deleteCurrentNode, deleteNode, deleteProps, deleteRange, deleteSelection, elementFromString, enter, escapeForRegEx, exitCode, extendMarkRange, index$1 as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, first, flattenExtensions, focus, forEach, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, h, injectExtensionAttributesToParseRule, inputRulesPlugin, insertContent, insertContentAt, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, joinBackward, joinDown, joinForward, joinItemBackward, joinItemForward, joinTextblockBackward, joinTextblockForward, joinUp, keyboardShortcut, lift, liftEmptyBlock, liftListItem, markInputRule, markPasteRule, index as markdown, mergeAttributes, mergeDeep, minMax, newlineInCode, nodeInputRule, nodePasteRule, objectIncludes, parseAttributes, parseIndentedBlocks, pasteRulesPlugin, posToDOMRect, removeDuplicates, renderNestedMarkdownContent, resetAttributes, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, scrollIntoView, selectAll, selectNodeBackward, selectNodeForward, selectParentNode, selectTextblockEnd, selectTextblockStart, selectionToInsertionEnd, serializeAttributes, setContent, setMark, setMeta, setNode, setNodeSelection, setTextSelection, sinkListItem, sortExtensions, splitBlock, splitExtensions, splitListItem, textInputRule, textPasteRule, textblockTypeInputRule, toggleList, toggleMark, toggleNode, toggleWrap, undoInputRule, unsetAllMarks, unsetMark, updateAttributes, updateMarkViewAttributes, wrapIn, wrapInList, wrappingInputRule };