@crystallize/design-system 1.24.13 → 1.24.14
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @crystallize/design-system
|
|
2
2
|
|
|
3
|
+
## 1.24.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a0aa5b7: It was found that when adding a content to richtext component via the API, the content transformer can turn the resulting `json` into an array of array of nodes, which we do not expect in the UI. In the UI we always work with flat list of block nodes as the nested array does not have any semantic meaning. To fix it now we check if the root element is an array and then we flat it.
|
|
8
|
+
|
|
3
9
|
## 1.24.13
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -7702,7 +7702,10 @@ var init_i18n = __esm({
|
|
|
7702
7702
|
// src/rich-text-editor/model/parse-initial-state.ts
|
|
7703
7703
|
function parseInitialState({ richText }) {
|
|
7704
7704
|
let richTextArray = Array.isArray(richText) ? richText : [richText];
|
|
7705
|
-
|
|
7705
|
+
const ensureRootBlockElements = (richTextArray2) => richTextArray2.flatMap((rootNode) => {
|
|
7706
|
+
if (Array.isArray(rootNode)) {
|
|
7707
|
+
return ensureRootBlockElements(rootNode);
|
|
7708
|
+
}
|
|
7706
7709
|
if (!rootNode?.kind || rootNode.kind === "inline") {
|
|
7707
7710
|
return {
|
|
7708
7711
|
type: "paragraph",
|
|
@@ -7712,6 +7715,7 @@ function parseInitialState({ richText }) {
|
|
|
7712
7715
|
}
|
|
7713
7716
|
return rootNode;
|
|
7714
7717
|
});
|
|
7718
|
+
richTextArray = ensureRootBlockElements(richTextArray);
|
|
7715
7719
|
return richTextArray;
|
|
7716
7720
|
}
|
|
7717
7721
|
var init_parse_initial_state = __esm({
|
package/dist/index.mjs
CHANGED
|
@@ -480,7 +480,7 @@ function Tag({
|
|
|
480
480
|
// src/rich-text-editor/index.tsx
|
|
481
481
|
import { lazy, Suspense } from "react";
|
|
482
482
|
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
483
|
-
var LazyRichTextEditor = lazy(() => import("./rich-text-editor-
|
|
483
|
+
var LazyRichTextEditor = lazy(() => import("./rich-text-editor-4KH7E76T.mjs"));
|
|
484
484
|
var RichTextEditor = (props) => {
|
|
485
485
|
return /* @__PURE__ */ jsx15(Suspense, {
|
|
486
486
|
fallback: null,
|
|
@@ -159,7 +159,10 @@ import { $createTableCellNode, $createTableNode, $createTableRowNode } from "@le
|
|
|
159
159
|
// src/rich-text-editor/model/parse-initial-state.ts
|
|
160
160
|
function parseInitialState({ richText }) {
|
|
161
161
|
let richTextArray = Array.isArray(richText) ? richText : [richText];
|
|
162
|
-
|
|
162
|
+
const ensureRootBlockElements = (richTextArray2) => richTextArray2.flatMap((rootNode) => {
|
|
163
|
+
if (Array.isArray(rootNode)) {
|
|
164
|
+
return ensureRootBlockElements(rootNode);
|
|
165
|
+
}
|
|
163
166
|
if (!rootNode?.kind || rootNode.kind === "inline") {
|
|
164
167
|
return {
|
|
165
168
|
type: "paragraph",
|
|
@@ -169,6 +172,7 @@ function parseInitialState({ richText }) {
|
|
|
169
172
|
}
|
|
170
173
|
return rootNode;
|
|
171
174
|
});
|
|
175
|
+
richTextArray = ensureRootBlockElements(richTextArray);
|
|
172
176
|
return richTextArray;
|
|
173
177
|
}
|
|
174
178
|
|
package/package.json
CHANGED
|
@@ -3,18 +3,25 @@ import type { CrystallizeRichText, CrystallizeRichTextNode } from '../types/crys
|
|
|
3
3
|
export function parseInitialState({ richText }: { richText: CrystallizeRichText }): CrystallizeRichTextNode[] {
|
|
4
4
|
let richTextArray = Array.isArray(richText) ? richText : [richText];
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
const ensureRootBlockElements = (richTextArray: CrystallizeRichText): CrystallizeRichText =>
|
|
7
|
+
richTextArray.flatMap(rootNode => {
|
|
8
|
+
if (Array.isArray(rootNode)) {
|
|
9
|
+
return ensureRootBlockElements(rootNode);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (!rootNode?.kind || rootNode.kind === 'inline') {
|
|
13
|
+
return {
|
|
14
|
+
type: 'paragraph',
|
|
15
|
+
kind: 'block',
|
|
16
|
+
children: [rootNode],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
return rootNode;
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Ensure all root items are block elements
|
|
24
|
+
richTextArray = ensureRootBlockElements(richTextArray);
|
|
18
25
|
|
|
19
26
|
return richTextArray;
|
|
20
27
|
}
|