@uniformdev/richtext
Advanced tools
Comparing version 19.23.1-alpha.12 to 19.24.0
@@ -33,2 +33,4 @@ "use strict"; | ||
isRichTextNodeType: () => isRichTextNodeType, | ||
isRichTextValue: () => isRichTextValue, | ||
isRichTextValueConsideredEmpty: () => isRichTextValueConsideredEmpty, | ||
linkHtmlRenderer: () => linkHtmlRenderer, | ||
@@ -97,5 +99,24 @@ linkParamValueToHref: () => linkParamValueToHref, | ||
} | ||
function isRichTextValue(value) { | ||
return typeof value === "object" && value !== null && "root" in value && isRichTextNode(value.root); | ||
} | ||
function isRichTextNodeType(node, type) { | ||
return isRichTextNode(node) && node.type === type; | ||
} | ||
function isRichTextValueConsideredEmpty(value) { | ||
if (!value) { | ||
return true; | ||
} | ||
if (value.root.children.length === 0) { | ||
return true; | ||
} | ||
if (value.root.children.length > 1) { | ||
return false; | ||
} | ||
const child = value.root.children[0]; | ||
if (!isRichTextNodeType(child, "paragraph")) { | ||
return false; | ||
} | ||
return child.children === void 0 || child.children.length === 0; | ||
} | ||
function hasChildren(node) { | ||
@@ -479,2 +500,4 @@ return "children" in node && isArrayWithLength(node.children); | ||
isRichTextNodeType, | ||
isRichTextValue, | ||
isRichTextValueConsideredEmpty, | ||
linkHtmlRenderer, | ||
@@ -481,0 +504,0 @@ linkParamValueToHref, |
@@ -1,6 +0,6 @@ | ||
import { LinkParamValue, RichTextBuiltInElement, RichTextBuiltInFormat } from '@uniformdev/canvas'; | ||
import { LinkParamValue, RichTextParamValue, RichTextBuiltInElement, RichTextBuiltInFormat } from '@uniformdev/canvas'; | ||
declare function purifyText(text: string): string; | ||
declare function isPureTextAlign(format?: string): format is string; | ||
declare function isPureDirection(direction?: string): direction is string; | ||
declare function isPureDirection(direction?: string | null): direction is string; | ||
declare function renderHtmlElement(tag: string, attributes: Map<string, string> | null, children?: string): string; | ||
@@ -11,2 +11,3 @@ | ||
children?: RichTextNode[]; | ||
version: number; | ||
} | ||
@@ -55,3 +56,3 @@ type RichTextNodeWithChildren = RichTextNode & { | ||
format?: 'center' | 'end' | 'justify' | 'left' | 'match-parent' | 'right' | 'start'; | ||
direction?: 'ltr' | 'rtl'; | ||
direction?: 'ltr' | 'rtl' | null; | ||
} | ||
@@ -86,2 +87,3 @@ declare const paragraphHtmlRenderer: NodeStringRenderer; | ||
declare function isRichTextNode(node: unknown): node is RichTextNode; | ||
declare function isRichTextValue(value: unknown): value is NonNullable<RichTextParamValue>; | ||
declare function isRichTextNodeType(node: unknown, type: 'heading'): node is HeadingNode; | ||
@@ -94,2 +96,3 @@ declare function isRichTextNodeType(node: unknown, type: 'paragraph'): node is ParagraphNode; | ||
declare function isRichTextNodeType(node: unknown, type: string): node is RichTextNode; | ||
declare function isRichTextValueConsideredEmpty(value: RichTextParamValue): boolean; | ||
declare function hasChildren<TRichTextNode extends RichTextNode>(node: TRichTextNode): node is TRichTextNode & { | ||
@@ -159,2 +162,2 @@ children: RichTextNode[]; | ||
export { HeadingNode, LinkNode, ListItemNode, ListNode, NodeStringRenderer, NodeStringRendererProps, ParagraphNode, ParameterRichTextValue, ResolveStringRenderer, RichTextNode, RichTextNodeWithChildren, StringRenderContext, TextNode, getLabelForElement, getLabelForFormat, getRichTextTagsFromTextFormat, hasChildren, headingHtmlRenderer, isArrayWithLength, isPureDirection, isPureTextAlign, isRichTextNode, isRichTextNodeType, linkHtmlRenderer, linkParamValueToHref, listHtmlRenderer, listitemHtmlRenderer, paragraphHtmlRenderer, purifyText, renderChildrenToHtml, renderChildrenToText, renderHtmlElement, renderToHtml, renderToText, resolveDefaultRenderer$1 as resolveDefaultHtmlRenderer, resolveDefaultRenderer as resolveDefaultTextRenderer, richTextBuiltInElements, richTextBuiltInFormats, rootHtmlRenderer, textHtmlRenderer, walkRichTextTree }; | ||
export { HeadingNode, LinkNode, ListItemNode, ListNode, NodeStringRenderer, NodeStringRendererProps, ParagraphNode, ParameterRichTextValue, ResolveStringRenderer, RichTextNode, RichTextNodeWithChildren, StringRenderContext, TextNode, getLabelForElement, getLabelForFormat, getRichTextTagsFromTextFormat, hasChildren, headingHtmlRenderer, isArrayWithLength, isPureDirection, isPureTextAlign, isRichTextNode, isRichTextNodeType, isRichTextValue, isRichTextValueConsideredEmpty, linkHtmlRenderer, linkParamValueToHref, listHtmlRenderer, listitemHtmlRenderer, paragraphHtmlRenderer, purifyText, renderChildrenToHtml, renderChildrenToText, renderHtmlElement, renderToHtml, renderToText, resolveDefaultRenderer$1 as resolveDefaultHtmlRenderer, resolveDefaultRenderer as resolveDefaultTextRenderer, richTextBuiltInElements, richTextBuiltInFormats, rootHtmlRenderer, textHtmlRenderer, walkRichTextTree }; |
@@ -43,5 +43,24 @@ // src/elements.ts | ||
} | ||
function isRichTextValue(value) { | ||
return typeof value === "object" && value !== null && "root" in value && isRichTextNode(value.root); | ||
} | ||
function isRichTextNodeType(node, type) { | ||
return isRichTextNode(node) && node.type === type; | ||
} | ||
function isRichTextValueConsideredEmpty(value) { | ||
if (!value) { | ||
return true; | ||
} | ||
if (value.root.children.length === 0) { | ||
return true; | ||
} | ||
if (value.root.children.length > 1) { | ||
return false; | ||
} | ||
const child = value.root.children[0]; | ||
if (!isRichTextNodeType(child, "paragraph")) { | ||
return false; | ||
} | ||
return child.children === void 0 || child.children.length === 0; | ||
} | ||
function hasChildren(node) { | ||
@@ -424,2 +443,4 @@ return "children" in node && isArrayWithLength(node.children); | ||
isRichTextNodeType, | ||
isRichTextValue, | ||
isRichTextValueConsideredEmpty, | ||
linkHtmlRenderer, | ||
@@ -426,0 +447,0 @@ linkParamValueToHref, |
@@ -33,2 +33,4 @@ "use strict"; | ||
isRichTextNodeType: () => isRichTextNodeType, | ||
isRichTextValue: () => isRichTextValue, | ||
isRichTextValueConsideredEmpty: () => isRichTextValueConsideredEmpty, | ||
linkHtmlRenderer: () => linkHtmlRenderer, | ||
@@ -97,5 +99,24 @@ linkParamValueToHref: () => linkParamValueToHref, | ||
} | ||
function isRichTextValue(value) { | ||
return typeof value === "object" && value !== null && "root" in value && isRichTextNode(value.root); | ||
} | ||
function isRichTextNodeType(node, type) { | ||
return isRichTextNode(node) && node.type === type; | ||
} | ||
function isRichTextValueConsideredEmpty(value) { | ||
if (!value) { | ||
return true; | ||
} | ||
if (value.root.children.length === 0) { | ||
return true; | ||
} | ||
if (value.root.children.length > 1) { | ||
return false; | ||
} | ||
const child = value.root.children[0]; | ||
if (!isRichTextNodeType(child, "paragraph")) { | ||
return false; | ||
} | ||
return child.children === void 0 || child.children.length === 0; | ||
} | ||
function hasChildren(node) { | ||
@@ -479,2 +500,4 @@ return "children" in node && isArrayWithLength(node.children); | ||
isRichTextNodeType, | ||
isRichTextValue, | ||
isRichTextValueConsideredEmpty, | ||
linkHtmlRenderer, | ||
@@ -481,0 +504,0 @@ linkParamValueToHref, |
{ | ||
"name": "@uniformdev/richtext", | ||
"version": "19.23.1-alpha.12+669adf812", | ||
"version": "19.24.0", | ||
"description": "Common functionality and types for Uniform Rich Text parameters", | ||
@@ -48,3 +48,3 @@ "license": "SEE LICENSE IN LICENSE.txt", | ||
"@lexical/rich-text": "^0.11.0", | ||
"@uniformdev/canvas": "^19.23.1-alpha.12+669adf812", | ||
"@uniformdev/canvas": "^19.24.0", | ||
"lexical": "^0.11.0" | ||
@@ -58,3 +58,3 @@ }, | ||
}, | ||
"gitHead": "669adf812df13a7856fb9bc5c4332c77e0697f3f" | ||
"gitHead": "ca1c309ce7eed5bffa76130e2baa0f03b08377ac" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
64516
2051
1
0