Skip to content

Commit 291b618

Browse files
authored
update Lexical v0.24.0 (#247)
- fix up nodes, see https://github.com/facebook/lexical/releases/tag/v0.23.0
1 parent b0d6e79 commit 291b618

28 files changed

+452
-401
lines changed

packages/perf-react/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
"react-dom": ">=18.3.1"
1313
},
1414
"dependencies": {
15-
"@lexical/headless": "^0.21.0",
16-
"@lexical/html": "^0.21.0",
17-
"@lexical/react": "^0.21.0",
18-
"@lexical/selection": "^0.21.0",
19-
"@lexical/utils": "^0.21.0",
15+
"@lexical/headless": "^0.24.0",
16+
"@lexical/html": "^0.24.0",
17+
"@lexical/react": "^0.24.0",
18+
"@lexical/selection": "^0.24.0",
19+
"@lexical/utils": "^0.24.0",
2020
"base-64": "^1.0.0",
2121
"epitelete-html": "^0.2.21-beta.2",
22-
"lexical": "^0.21.0",
22+
"lexical": "^0.24.0",
2323
"open-patcher": "1.0.0-beta.1",
2424
"pure-uuid": "^1.8.1"
2525
},

packages/perf-vanilla/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
"dev": "vite"
99
},
1010
"dependencies": {
11-
"@lexical/rich-text": "^0.21.0",
12-
"@lexical/utils": "^0.21.0",
13-
"lexical": "^0.21.0",
11+
"@lexical/rich-text": "^0.24.0",
12+
"@lexical/utils": "^0.24.0",
13+
"lexical": "^0.24.0",
1414
"open-patcher": "1.0.0-beta.1"
1515
},
1616
"devDependencies": {

packages/platform/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@
3232
},
3333
"dependencies": {
3434
"@biblionexus-foundation/scripture-utilities": "workspace:~",
35-
"@lexical/react": "^0.21.0",
36-
"@lexical/selection": "^0.21.0",
37-
"@lexical/text": "^0.21.0",
38-
"@lexical/utils": "^0.21.0",
39-
"@lexical/yjs": "^0.21.0",
35+
"@lexical/react": "^0.24.0",
36+
"@lexical/selection": "^0.24.0",
37+
"@lexical/text": "^0.24.0",
38+
"@lexical/utils": "^0.24.0",
39+
"@lexical/yjs": "^0.24.0",
4040
"@sillsdev/scripture": "^2.0.2",
4141
"fast-equals": "^5.2.2",
42-
"lexical": "^0.21.0",
42+
"lexical": "^0.24.0",
4343
"yjs": "^13.6.20"
4444
},
4545
"devDependencies": {

packages/scribe/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
},
3131
"dependencies": {
3232
"@biblionexus-foundation/scripture-utilities": "workspace:~",
33-
"@lexical/mark": "^0.21.0",
34-
"@lexical/react": "^0.21.0",
35-
"@lexical/selection": "^0.21.0",
36-
"@lexical/utils": "^0.21.0",
33+
"@lexical/mark": "^0.24.0",
34+
"@lexical/react": "^0.24.0",
35+
"@lexical/selection": "^0.24.0",
36+
"@lexical/utils": "^0.24.0",
3737
"fast-equals": "^5.2.2",
38-
"lexical": "^0.21.0"
38+
"lexical": "^0.24.0"
3939
},
4040
"devDependencies": {
4141
"@types/react": "^18.3.18",

packages/shared-react/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
},
1818
"dependencies": {
1919
"@floating-ui/dom": "^1.6.13",
20-
"@lexical/react": "^0.21.0",
21-
"@lexical/utils": "^0.21.0",
22-
"lexical": "^0.21.0"
20+
"@lexical/react": "^0.24.0",
21+
"@lexical/utils": "^0.24.0",
22+
"lexical": "^0.24.0"
2323
},
2424
"devDependencies": {
2525
"@types/react": "^18.3.18",

packages/shared/nodes/DivisionMarkNode.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,8 @@ export class DivisionMarkNode extends UsfmElementNode {
2020
}
2121

2222
static importJSON(serializedNode: SerializedDivisionMarkNode) {
23-
const { attributes, format, indent, direction, tag } = serializedNode;
24-
const node = $createDivisionMarkNode(attributes, tag ?? DEFAULT_TAG);
25-
node.setAttributes(attributes ?? {});
26-
node.setFormat(format);
27-
node.setIndent(indent);
28-
node.setDirection(direction);
29-
return node;
23+
const { attributes, tag } = serializedNode;
24+
return $createDivisionMarkNode(attributes, tag ?? DEFAULT_TAG).updateFromJSON(serializedNode);
3025
}
3126

3227
canBeEmpty(): boolean {

packages/shared/nodes/GraftNode.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,8 @@ export class GraftNode extends UsfmElementNode {
7474
}
7575

7676
static importJSON(serializedNode: SerializedGraftNode): GraftNode {
77-
const { attributes, props, format, indent, direction, tag } = serializedNode;
78-
const node = $createGraftNode(attributes, props, tag ?? DEFAULT_TAG);
79-
node.setFormat(format);
80-
node.setIndent(indent);
81-
node.setDirection(direction);
82-
return node;
77+
const { attributes, props, tag } = serializedNode;
78+
return $createGraftNode(attributes, props, tag ?? DEFAULT_TAG).updateFromJSON(serializedNode);
8379
}
8480

8581
exportJSON(): SerializedGraftNode {

packages/shared/nodes/InlineNode.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,8 @@ export class InlineNode extends UsfmElementNode {
3232
}
3333

3434
static importJSON(serializedNode: SerializedInlineNode): InlineNode {
35-
const { attributes, format, indent, direction } = serializedNode;
36-
const node = $createInlineNode(attributes);
37-
node.setFormat(format);
38-
node.setIndent(indent);
39-
node.setDirection(direction);
40-
return node;
35+
const { attributes } = serializedNode;
36+
return $createInlineNode(attributes).updateFromJSON(serializedNode);
4137
}
4238

4339
exportJSON(): SerializedInlineNode {

packages/shared/nodes/UsfmElementNode.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,31 @@ export class UsfmElementNode extends ElementNode {
3131
return this.getLatest().__attributes;
3232
}
3333

34-
setAttributes(attributes: Attributes) {
34+
setAttributes(attributes: Attributes): this {
3535
const writable = this.getWritable();
3636
writable.__attributes = attributes;
37+
return writable;
3738
}
3839

3940
getAttribute(key: string): string | undefined {
4041
return this.getLatest().__attributes[key];
4142
}
4243

43-
setAttribute(key: string, value: string) {
44+
setAttribute(key: string, value: string): this {
45+
if (this.__attributes[key] === value) return this;
46+
4447
const writable = this.getWritable();
4548
writable.__attributes[key] = value;
49+
return writable;
4650
}
4751

4852
removeAttribute(key: string) {
4953
const writable = this.getWritable();
5054
delete writable.__attributes[key];
5155
}
5256

53-
setUIAttribute(key: string, value: string) {
54-
this.setAttribute(`data-ui-${key}`, value);
57+
setUIAttribute(key: string, value: string): this {
58+
return this.setAttribute(`data-ui-${key}`, value);
5559
}
5660

5761
getUIAttribute(key: string): string | undefined {
@@ -79,9 +83,12 @@ export class UsfmElementNode extends ElementNode {
7983
return this.getLatest().__tag;
8084
}
8185

82-
setTag(tag: string | undefined) {
86+
setTag(tag: string | undefined): this {
87+
if (this.__tag === tag) return this;
88+
8389
const writable = this.getWritable();
8490
writable.__tag = tag;
91+
return writable;
8592
}
8693

8794
exportJSON(): SerializedUsfmElementNode {

packages/shared/nodes/UsfmParagraphNode.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,8 @@ export class UsfmParagraphNode extends UsfmElementNode {
2727
}
2828

2929
static importJSON(serializedNode: SerializedUsfmParagraphNode): UsfmParagraphNode {
30-
const { attributes, tag, format, indent, direction } = serializedNode;
31-
const node = $createUsfmParagraphNode(attributes, tag ?? DEFAULT_TAG);
32-
node.setFormat(format);
33-
node.setIndent(indent);
34-
node.setDirection(direction);
35-
return node;
30+
const { attributes, tag } = serializedNode;
31+
return $createUsfmParagraphNode(attributes, tag ?? DEFAULT_TAG).updateFromJSON(serializedNode);
3632
}
3733

3834
createDOM(config: EditorConfig): HTMLElement {

0 commit comments

Comments
 (0)