@uniformdev/richtext 19.23.1-alpha.12 → 19.24.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
@@ -1,13 +1,14 @@
1
- import { LinkParamValue, RichTextBuiltInElement, RichTextBuiltInFormat } from '@uniformdev/canvas';
1
+ import { LinkParamValue, RichTextParamValue, RichTextBuiltInElement, RichTextBuiltInFormat } from '@uniformdev/canvas';
2
2
 
3
3
  declare function purifyText(text: string): string;
4
4
  declare function isPureTextAlign(format?: string): format is string;
5
- declare function isPureDirection(direction?: string): direction is string;
5
+ declare function isPureDirection(direction?: string | null): direction is string;
6
6
  declare function renderHtmlElement(tag: string, attributes: Map<string, string> | null, children?: string): string;
7
7
 
8
8
  interface RichTextNode extends Record<string, unknown> {
9
9
  type: string;
10
10
  children?: RichTextNode[];
11
+ version: number;
11
12
  }
12
13
  type RichTextNodeWithChildren = RichTextNode & {
13
14
  children: RichTextNode[];
@@ -51,7 +52,7 @@ declare const listitemHtmlRenderer: NodeStringRenderer;
51
52
 
52
53
  interface ParagraphNode extends RichTextNode {
53
54
  format?: 'center' | 'end' | 'justify' | 'left' | 'match-parent' | 'right' | 'start';
54
- direction?: 'ltr' | 'rtl';
55
+ direction?: 'ltr' | 'rtl' | null;
55
56
  }
56
57
  declare const paragraphHtmlRenderer: NodeStringRenderer;
57
58
 
@@ -81,6 +82,7 @@ declare function getRichTextTagsFromTextFormat(format: number): string[];
81
82
 
82
83
  declare function isArrayWithLength<T>(arr: T[] | unknown | undefined): arr is T[];
83
84
  declare function isRichTextNode(node: unknown): node is RichTextNode;
85
+ declare function isRichTextValue(value: unknown): value is NonNullable<RichTextParamValue>;
84
86
  declare function isRichTextNodeType(node: unknown, type: 'heading'): node is HeadingNode;
85
87
  declare function isRichTextNodeType(node: unknown, type: 'paragraph'): node is ParagraphNode;
86
88
  declare function isRichTextNodeType(node: unknown, type: 'text'): node is TextNode;
@@ -88,6 +90,7 @@ declare function isRichTextNodeType(node: unknown, type: 'list'): node is ListNo
88
90
  declare function isRichTextNodeType(node: unknown, type: 'listitem'): node is ListItemNode;
89
91
  declare function isRichTextNodeType(node: unknown, type: 'link'): node is LinkNode;
90
92
  declare function isRichTextNodeType(node: unknown, type: string): node is RichTextNode;
93
+ declare function isRichTextValueConsideredEmpty(value: RichTextParamValue): boolean;
91
94
  declare function hasChildren<TRichTextNode extends RichTextNode>(node: TRichTextNode): node is TRichTextNode & {
92
95
  children: RichTextNode[];
93
96
  };
@@ -152,4 +155,4 @@ declare const richTextBuiltInFormats: {
152
155
  declare const getLabelForElement: (type: string) => string;
153
156
  declare const getLabelForFormat: (type: string) => string;
154
157
 
155
- 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 };
158
+ 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 };
package/dist/index.esm.js CHANGED
@@ -40,9 +40,28 @@ function isArrayWithLength(arr) {
40
40
  function isRichTextNode(node) {
41
41
  return !!node && typeof node === "object" && "type" in node;
42
42
  }
43
+ function isRichTextValue(value) {
44
+ return typeof value === "object" && value !== null && "root" in value && isRichTextNode(value.root);
45
+ }
43
46
  function isRichTextNodeType(node, type) {
44
47
  return isRichTextNode(node) && node.type === type;
45
48
  }
49
+ function isRichTextValueConsideredEmpty(value) {
50
+ if (!value) {
51
+ return true;
52
+ }
53
+ if (value.root.children.length === 0) {
54
+ return true;
55
+ }
56
+ if (value.root.children.length > 1) {
57
+ return false;
58
+ }
59
+ const child = value.root.children[0];
60
+ if (!isRichTextNodeType(child, "paragraph")) {
61
+ return false;
62
+ }
63
+ return child.children === void 0 || child.children.length === 0;
64
+ }
46
65
  function hasChildren(node) {
47
66
  return "children" in node && isArrayWithLength(node.children);
48
67
  }
@@ -420,6 +439,8 @@ export {
420
439
  isPureTextAlign,
421
440
  isRichTextNode,
422
441
  isRichTextNodeType,
442
+ isRichTextValue,
443
+ isRichTextValueConsideredEmpty,
423
444
  linkHtmlRenderer,
424
445
  linkParamValueToHref,
425
446
  listHtmlRenderer,
package/dist/index.js CHANGED
@@ -30,6 +30,8 @@ __export(src_exports, {
30
30
  isPureTextAlign: () => isPureTextAlign,
31
31
  isRichTextNode: () => isRichTextNode,
32
32
  isRichTextNodeType: () => isRichTextNodeType,
33
+ isRichTextValue: () => isRichTextValue,
34
+ isRichTextValueConsideredEmpty: () => isRichTextValueConsideredEmpty,
33
35
  linkHtmlRenderer: () => linkHtmlRenderer,
34
36
  linkParamValueToHref: () => linkParamValueToHref,
35
37
  listHtmlRenderer: () => listHtmlRenderer,
@@ -93,9 +95,28 @@ function isArrayWithLength(arr) {
93
95
  function isRichTextNode(node) {
94
96
  return !!node && typeof node === "object" && "type" in node;
95
97
  }
98
+ function isRichTextValue(value) {
99
+ return typeof value === "object" && value !== null && "root" in value && isRichTextNode(value.root);
100
+ }
96
101
  function isRichTextNodeType(node, type) {
97
102
  return isRichTextNode(node) && node.type === type;
98
103
  }
104
+ function isRichTextValueConsideredEmpty(value) {
105
+ if (!value) {
106
+ return true;
107
+ }
108
+ if (value.root.children.length === 0) {
109
+ return true;
110
+ }
111
+ if (value.root.children.length > 1) {
112
+ return false;
113
+ }
114
+ const child = value.root.children[0];
115
+ if (!isRichTextNodeType(child, "paragraph")) {
116
+ return false;
117
+ }
118
+ return child.children === void 0 || child.children.length === 0;
119
+ }
99
120
  function hasChildren(node) {
100
121
  return "children" in node && isArrayWithLength(node.children);
101
122
  }
@@ -474,6 +495,8 @@ var getLabelForFormat = (type) => {
474
495
  isPureTextAlign,
475
496
  isRichTextNode,
476
497
  isRichTextNodeType,
498
+ isRichTextValue,
499
+ isRichTextValueConsideredEmpty,
477
500
  linkHtmlRenderer,
478
501
  linkParamValueToHref,
479
502
  listHtmlRenderer,
package/dist/index.mjs CHANGED
@@ -40,9 +40,28 @@ function isArrayWithLength(arr) {
40
40
  function isRichTextNode(node) {
41
41
  return !!node && typeof node === "object" && "type" in node;
42
42
  }
43
+ function isRichTextValue(value) {
44
+ return typeof value === "object" && value !== null && "root" in value && isRichTextNode(value.root);
45
+ }
43
46
  function isRichTextNodeType(node, type) {
44
47
  return isRichTextNode(node) && node.type === type;
45
48
  }
49
+ function isRichTextValueConsideredEmpty(value) {
50
+ if (!value) {
51
+ return true;
52
+ }
53
+ if (value.root.children.length === 0) {
54
+ return true;
55
+ }
56
+ if (value.root.children.length > 1) {
57
+ return false;
58
+ }
59
+ const child = value.root.children[0];
60
+ if (!isRichTextNodeType(child, "paragraph")) {
61
+ return false;
62
+ }
63
+ return child.children === void 0 || child.children.length === 0;
64
+ }
46
65
  function hasChildren(node) {
47
66
  return "children" in node && isArrayWithLength(node.children);
48
67
  }
@@ -420,6 +439,8 @@ export {
420
439
  isPureTextAlign,
421
440
  isRichTextNode,
422
441
  isRichTextNodeType,
442
+ isRichTextValue,
443
+ isRichTextValueConsideredEmpty,
423
444
  linkHtmlRenderer,
424
445
  linkParamValueToHref,
425
446
  listHtmlRenderer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/richtext",
3
- "version": "19.23.1-alpha.12+669adf812",
3
+ "version": "19.24.0",
4
4
  "description": "Common functionality and types for Uniform Rich Text parameters",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -45,7 +45,7 @@
45
45
  "@lexical/link": "^0.11.0",
46
46
  "@lexical/list": "^0.11.0",
47
47
  "@lexical/rich-text": "^0.11.0",
48
- "@uniformdev/canvas": "^19.23.1-alpha.12+669adf812",
48
+ "@uniformdev/canvas": "^19.24.0",
49
49
  "lexical": "^0.11.0"
50
50
  },
51
51
  "files": [
@@ -54,5 +54,5 @@
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  },
57
- "gitHead": "669adf812df13a7856fb9bc5c4332c77e0697f3f"
57
+ "gitHead": "ca1c309ce7eed5bffa76130e2baa0f03b08377ac"
58
58
  }