@tiptap/core 3.20.1 → 3.20.2
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.cjs +11 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +11 -7
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/types.ts +6 -0
- package/src/utilities/markdown/renderNestedMarkdownContent.ts +9 -7
package/dist/index.d.cts
CHANGED
|
@@ -1729,6 +1729,8 @@ type MarkdownParseHelpers = {
|
|
|
1729
1729
|
parseInline: (tokens: MarkdownToken[]) => JSONContent[];
|
|
1730
1730
|
/** Parse an array of block-level tokens */
|
|
1731
1731
|
parseChildren: (tokens: MarkdownToken[]) => JSONContent[];
|
|
1732
|
+
/** Parse block-level tokens while preserving implicit empty paragraphs from blank lines */
|
|
1733
|
+
parseBlockChildren?: (tokens: MarkdownToken[]) => JSONContent[];
|
|
1732
1734
|
/** Create a text node with optional marks */
|
|
1733
1735
|
createTextNode: (text: string, marks?: Array<{
|
|
1734
1736
|
type: string;
|
|
@@ -1776,6 +1778,7 @@ type RenderContext = {
|
|
|
1776
1778
|
level: number;
|
|
1777
1779
|
meta?: Record<string, any>;
|
|
1778
1780
|
parentType?: string | null;
|
|
1781
|
+
previousNode?: JSONContent | null;
|
|
1779
1782
|
};
|
|
1780
1783
|
/** Extension contract for markdown parsing/serialization. */
|
|
1781
1784
|
interface MarkdownExtensionSpec {
|
|
@@ -1825,6 +1828,8 @@ type MarkdownRendererHelpers = {
|
|
|
1825
1828
|
* @returns The rendered markdown string
|
|
1826
1829
|
*/
|
|
1827
1830
|
renderChildren: (nodes: JSONContent | JSONContent[], separator?: string) => string;
|
|
1831
|
+
/** Render a single child node with its sibling index preserved */
|
|
1832
|
+
renderChild?: (node: JSONContent, index: number) => string;
|
|
1828
1833
|
/**
|
|
1829
1834
|
* Render a text token to a markdown string
|
|
1830
1835
|
* @param prefix The prefix to add before the content
|
|
@@ -4864,6 +4869,7 @@ declare function parseIndentedBlocks(src: string, config: BlockParserConfig, lex
|
|
|
4864
4869
|
*/
|
|
4865
4870
|
declare function renderNestedMarkdownContent(node: JSONContent, h: {
|
|
4866
4871
|
renderChildren: (nodes: JSONContent[]) => string;
|
|
4872
|
+
renderChild?: (node: JSONContent, index: number) => string;
|
|
4867
4873
|
indent: (text: string) => string;
|
|
4868
4874
|
}, prefixOrGenerator: string | ((ctx: any) => string), ctx?: any): string;
|
|
4869
4875
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1729,6 +1729,8 @@ type MarkdownParseHelpers = {
|
|
|
1729
1729
|
parseInline: (tokens: MarkdownToken[]) => JSONContent[];
|
|
1730
1730
|
/** Parse an array of block-level tokens */
|
|
1731
1731
|
parseChildren: (tokens: MarkdownToken[]) => JSONContent[];
|
|
1732
|
+
/** Parse block-level tokens while preserving implicit empty paragraphs from blank lines */
|
|
1733
|
+
parseBlockChildren?: (tokens: MarkdownToken[]) => JSONContent[];
|
|
1732
1734
|
/** Create a text node with optional marks */
|
|
1733
1735
|
createTextNode: (text: string, marks?: Array<{
|
|
1734
1736
|
type: string;
|
|
@@ -1776,6 +1778,7 @@ type RenderContext = {
|
|
|
1776
1778
|
level: number;
|
|
1777
1779
|
meta?: Record<string, any>;
|
|
1778
1780
|
parentType?: string | null;
|
|
1781
|
+
previousNode?: JSONContent | null;
|
|
1779
1782
|
};
|
|
1780
1783
|
/** Extension contract for markdown parsing/serialization. */
|
|
1781
1784
|
interface MarkdownExtensionSpec {
|
|
@@ -1825,6 +1828,8 @@ type MarkdownRendererHelpers = {
|
|
|
1825
1828
|
* @returns The rendered markdown string
|
|
1826
1829
|
*/
|
|
1827
1830
|
renderChildren: (nodes: JSONContent | JSONContent[], separator?: string) => string;
|
|
1831
|
+
/** Render a single child node with its sibling index preserved */
|
|
1832
|
+
renderChild?: (node: JSONContent, index: number) => string;
|
|
1828
1833
|
/**
|
|
1829
1834
|
* Render a text token to a markdown string
|
|
1830
1835
|
* @param prefix The prefix to add before the content
|
|
@@ -4864,6 +4869,7 @@ declare function parseIndentedBlocks(src: string, config: BlockParserConfig, lex
|
|
|
4864
4869
|
*/
|
|
4865
4870
|
declare function renderNestedMarkdownContent(node: JSONContent, h: {
|
|
4866
4871
|
renderChildren: (nodes: JSONContent[]) => string;
|
|
4872
|
+
renderChild?: (node: JSONContent, index: number) => string;
|
|
4867
4873
|
indent: (text: string) => string;
|
|
4868
4874
|
}, prefixOrGenerator: string | ((ctx: any) => string), ctx?: any): string;
|
|
4869
4875
|
|
package/dist/index.js
CHANGED
|
@@ -6428,17 +6428,21 @@ function renderNestedMarkdownContent(node, h2, prefixOrGenerator, ctx) {
|
|
|
6428
6428
|
const prefix = typeof prefixOrGenerator === "function" ? prefixOrGenerator(ctx) : prefixOrGenerator;
|
|
6429
6429
|
const [content, ...children] = node.content;
|
|
6430
6430
|
const mainContent = h2.renderChildren([content]);
|
|
6431
|
-
|
|
6431
|
+
let output = `${prefix}${mainContent}`;
|
|
6432
6432
|
if (children && children.length > 0) {
|
|
6433
|
-
children.forEach((child) => {
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6433
|
+
children.forEach((child, index) => {
|
|
6434
|
+
var _a, _b;
|
|
6435
|
+
const childContent = (_b = (_a = h2.renderChild) == null ? void 0 : _a.call(h2, child, index + 1)) != null ? _b : h2.renderChildren([child]);
|
|
6436
|
+
if (childContent !== void 0 && childContent !== null) {
|
|
6437
|
+
const indentedChild = childContent.split("\n").map((line) => line ? h2.indent(line) : h2.indent("")).join("\n");
|
|
6438
|
+
output += child.type === "paragraph" ? `
|
|
6439
|
+
|
|
6440
|
+
${indentedChild}` : `
|
|
6441
|
+
${indentedChild}`;
|
|
6438
6442
|
}
|
|
6439
6443
|
});
|
|
6440
6444
|
}
|
|
6441
|
-
return output
|
|
6445
|
+
return output;
|
|
6442
6446
|
}
|
|
6443
6447
|
|
|
6444
6448
|
// src/MarkView.ts
|