@prismicio/richtext
Advanced tools
Comparing version 2.1.3 to 2.1.4
@@ -0,0 +0,0 @@ import { RichTextField } from "@prismicio/types"; |
@@ -0,0 +0,0 @@ import { RTNode } from "@prismicio/types"; |
@@ -89,6 +89,17 @@ import { RichTextNodeType } from "@prismicio/types"; | ||
const siblingSpan = mutSpans[j]; | ||
if (siblingSpan !== span && siblingSpan.start >= span.start && siblingSpan.end <= span.end) { | ||
childSpans.push(siblingSpan); | ||
mutSpans.splice(j, 1); | ||
j--; | ||
if (siblingSpan !== span) { | ||
if (siblingSpan.start >= span.start && siblingSpan.end <= span.end) { | ||
childSpans.push(siblingSpan); | ||
mutSpans.splice(j, 1); | ||
j--; | ||
} else if (siblingSpan.start < span.end && siblingSpan.end > span.start) { | ||
childSpans.push({ | ||
...siblingSpan, | ||
end: span.end | ||
}); | ||
mutSpans[j] = { | ||
...siblingSpan, | ||
start: span.end | ||
}; | ||
} | ||
} | ||
@@ -95,0 +106,0 @@ } |
@@ -0,0 +0,0 @@ import { RichTextFunctionSerializer } from "./types"; |
@@ -0,0 +0,0 @@ export { asTree } from "./asTree"; |
@@ -0,0 +0,0 @@ import { RichTextField } from "@prismicio/types"; |
@@ -8,3 +8,3 @@ import { RichTextNodeType, RTAnyNode, RTEmbedNode, RTEmNode, RTHeading1Node, RTHeading2Node, RTHeading3Node, RTHeading4Node, RTHeading5Node, RTHeading6Node, RTImageNode, RTLabelNode, RTLinkNode, RTListItemNode, RTListNode, RTOListItemNode, RTOListNode, RTParagraphNode, RTPreformattedNode, RTSpanNode, RTStrongNode } from "@prismicio/types"; | ||
*/ | ||
export type RichTextFunctionSerializer<ReturnType> = (type: typeof RichTextNodeType[keyof typeof RichTextNodeType], node: RTAnyNode, text: string | undefined, children: ReturnType[], key: string) => ReturnType | null | undefined; | ||
export type RichTextFunctionSerializer<ReturnType> = (type: (typeof RichTextNodeType)[keyof typeof RichTextNodeType], node: RTAnyNode, text: string | undefined, children: ReturnType[], key: string) => ReturnType | null | undefined; | ||
/** | ||
@@ -59,3 +59,3 @@ * Map serializer's tag function serializer, can be helpful for typing those | ||
key: string; | ||
type: typeof RichTextNodeType[keyof typeof RichTextNodeType]; | ||
type: (typeof RichTextNodeType)[keyof typeof RichTextNodeType]; | ||
text?: string; | ||
@@ -62,0 +62,0 @@ node: RTAnyNode; |
@@ -0,0 +0,0 @@ import { RichTextFunctionSerializer, RichTextMapSerializer } from "./types"; |
@@ -7,6 +7,11 @@ import { RichTextReversedNodeType } from "./types.js"; | ||
return tagSerializer({ | ||
// @ts-expect-error cannot type check here | ||
type, | ||
// @ts-expect-error cannot type check here | ||
node, | ||
// @ts-expect-error cannot type check here | ||
text, | ||
// @ts-expect-error cannot type check here | ||
children, | ||
// @ts-expect-error cannot type check here | ||
key | ||
@@ -13,0 +18,0 @@ }); |
{ | ||
"name": "@prismicio/richtext", | ||
"version": "2.1.3", | ||
"version": "2.1.4", | ||
"description": "A parser and serializer for Prismic's Rich Text format", | ||
@@ -51,18 +51,18 @@ "keywords": [ | ||
"devDependencies": { | ||
"@size-limit/preset-small-lib": "^8.1.0", | ||
"@typescript-eslint/eslint-plugin": "^5.46.1", | ||
"@typescript-eslint/parser": "^5.46.1", | ||
"@vitest/coverage-c8": "^0.26.0", | ||
"eslint": "^8.30.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"@size-limit/preset-small-lib": "^8.1.1", | ||
"@typescript-eslint/eslint-plugin": "^5.48.1", | ||
"@typescript-eslint/parser": "^5.48.1", | ||
"@vitest/coverage-c8": "^0.27.1", | ||
"eslint": "^8.31.0", | ||
"eslint-config-prettier": "^8.6.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"eslint-plugin-tsdoc": "^0.2.17", | ||
"prettier": "^2.8.1", | ||
"prettier": "^2.8.2", | ||
"prettier-plugin-jsdoc": "^0.4.2", | ||
"size-limit": "^8.1.0", | ||
"size-limit": "^8.1.1", | ||
"standard-version": "^9.5.0", | ||
"typescript": "^4.9.4", | ||
"vite": "^4.0.2", | ||
"vite": "^4.0.4", | ||
"vite-plugin-sdk": "^0.1.0", | ||
"vitest": "^0.26.0" | ||
"vitest": "^0.27.1" | ||
}, | ||
@@ -69,0 +69,0 @@ "engines": { |
@@ -155,10 +155,20 @@ import { | ||
if ( | ||
siblingSpan !== span && | ||
siblingSpan.start >= span.start && | ||
siblingSpan.end <= span.end | ||
) { | ||
childSpans.push(siblingSpan); | ||
mutSpans.splice(j, 1); | ||
j--; | ||
if (siblingSpan !== span) { | ||
if (siblingSpan.start >= span.start && siblingSpan.end <= span.end) { | ||
childSpans.push(siblingSpan); | ||
mutSpans.splice(j, 1); | ||
j--; | ||
} else if ( | ||
siblingSpan.start < span.end && | ||
siblingSpan.end > span.start | ||
) { | ||
childSpans.push({ | ||
...siblingSpan, | ||
end: span.end, | ||
}); | ||
mutSpans[j] = { | ||
...siblingSpan, | ||
start: span.end, | ||
}; | ||
} | ||
} | ||
@@ -165,0 +175,0 @@ } |
@@ -34,3 +34,3 @@ import { | ||
export type RichTextFunctionSerializer<ReturnType> = ( | ||
type: typeof RichTextNodeType[keyof typeof RichTextNodeType], | ||
type: (typeof RichTextNodeType)[keyof typeof RichTextNodeType], | ||
node: RTAnyNode, | ||
@@ -139,3 +139,3 @@ text: string | undefined, | ||
key: string; | ||
type: typeof RichTextNodeType[keyof typeof RichTextNodeType]; | ||
type: (typeof RichTextNodeType)[keyof typeof RichTextNodeType]; | ||
text?: string; | ||
@@ -142,0 +142,0 @@ node: RTAnyNode; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
91348
1068