@@ -41,8 +41,7 @@ const $writeUpdates = (
41
41
instanceChildren : Instance [ "children" ] ,
42
42
instancesList : Instance [ ] ,
43
43
refs : Refs ,
44
- newLinkKeyToInstanceId : Refs ,
45
- isElement : boolean
44
+ newLinkKeyToInstanceId : Refs
46
45
) => {
47
46
const children = node . getChildren ( ) ;
48
47
for ( const child of children ) {
@@ -52,8 +51,7 @@ const $writeUpdates = (
52
51
instanceChildren ,
53
52
instancesList ,
54
53
refs ,
55
- newLinkKeyToInstanceId ,
56
- isElement
54
+ newLinkKeyToInstanceId
57
55
) ;
58
56
}
59
57
if ( $isLineBreakNode ( child ) ) {
@@ -73,25 +71,15 @@ const $writeUpdates = (
73
71
childChildren ,
74
72
instancesList ,
75
73
refs ,
76
- newLinkKeyToInstanceId ,
77
- isElement
74
+ newLinkKeyToInstanceId
78
75
) ;
79
- if ( isElement ) {
80
- instancesList . push ( {
81
- type : "instance" ,
82
- id,
83
- component : elementComponent ,
84
- tag : "a" ,
85
- children : childChildren ,
86
- } ) ;
87
- } else {
88
- instancesList . push ( {
89
- type : "instance" ,
90
- id,
91
- component : "RichTextLink" ,
92
- children : childChildren ,
93
- } ) ;
94
- }
76
+ instancesList . push ( {
77
+ type : "instance" ,
78
+ id,
79
+ component : elementComponent ,
80
+ tag : "a" ,
81
+ children : childChildren ,
82
+ } ) ;
95
83
}
96
84
if ( $isTextNode ( child ) ) {
97
85
// support nesting bold into italic and vice versa
@@ -105,60 +93,32 @@ const $writeUpdates = (
105
93
const id = refs . get ( key ) ?? nanoid ( ) ;
106
94
refs . set ( key , id ) ;
107
95
const childChildren : Instance [ "children" ] = [ ] ;
108
- if ( isElement ) {
109
- instancesList . push ( {
110
- type : "instance" ,
111
- id,
112
- component : elementComponent ,
113
- tag : "span" ,
114
- children : childChildren ,
115
- } ) ;
116
- } else {
117
- instancesList . push ( {
118
- type : "instance" ,
119
- id,
120
- component : "Span" ,
121
- children : childChildren ,
122
- } ) ;
123
- }
96
+ instancesList . push ( {
97
+ type : "instance" ,
98
+ id,
99
+ component : elementComponent ,
100
+ tag : "span" ,
101
+ children : childChildren ,
102
+ } ) ;
124
103
parentUpdates . push ( { type : "id" , value : id } ) ;
125
104
parentUpdates = childChildren ;
126
105
}
127
106
// convert all lexical formats
128
- if ( isElement ) {
129
- for ( const [ format , tag ] of elementLexicalFormats ) {
130
- if ( child . hasFormat ( format ) ) {
131
- const key = `${ child . getKey ( ) } :${ format } ` ;
132
- const id = refs . get ( key ) ?? nanoid ( ) ;
133
- refs . set ( key , id ) ;
134
- const childInstance : Instance = {
135
- type : "instance" ,
136
- id,
137
- component : elementComponent ,
138
- tag,
139
- children : [ ] ,
140
- } ;
141
- instancesList . push ( childInstance ) ;
142
- parentUpdates . push ( { type : "id" , value : id } ) ;
143
- parentUpdates = childInstance . children ;
144
- }
145
- }
146
- } else {
147
- for ( const [ format , component ] of legacyLexicalFormats ) {
148
- if ( child . hasFormat ( format ) ) {
149
- const key = `${ child . getKey ( ) } :${ format } ` ;
150
- const id = refs . get ( key ) ?? nanoid ( ) ;
151
- refs . set ( key , id ) ;
152
- const childInstance : Instance = {
153
- type : "instance" ,
154
- id,
155
- component,
156
- children : [ ] ,
157
- } ;
158
- instancesList . push ( childInstance ) ;
159
- parentUpdates . push ( { type : "id" , value : id } ) ;
160
- parentUpdates = childInstance . children ;
161
- }
107
+ for ( const [ format , tag ] of elementLexicalFormats ) {
108
+ if ( child . hasFormat ( format ) ) {
109
+ const key = `${ child . getKey ( ) } :${ format } ` ;
110
+ const id = refs . get ( key ) ?? nanoid ( ) ;
111
+ refs . set ( key , id ) ;
112
+ const childInstance : Instance = {
113
+ type : "instance" ,
114
+ id,
115
+ component : elementComponent ,
116
+ tag,
117
+ children : [ ] ,
118
+ } ;
119
+ instancesList . push ( childInstance ) ;
120
+ parentUpdates . push ( { type : "id" , value : id } ) ;
121
+ parentUpdates = childInstance . children ;
162
122
}
163
123
}
164
124
parentUpdates . push ( { type : "text" , value : text } ) ;
@@ -184,8 +144,7 @@ export const $convertToUpdates = (
184
144
treeRootInstanceChildren ,
185
145
instancesList ,
186
146
refs ,
187
- newLinkKeyToInstanceId ,
188
- treeRootInstance . component === elementComponent
147
+ newLinkKeyToInstanceId
189
148
) ;
190
149
return instancesList ;
191
150
} ;
0 commit comments