File tree Expand file tree Collapse file tree
packages/editable-html-tip-tap/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -334,7 +334,7 @@ export const EditableHtml = (props) => {
334334 const nextMarkup = normalizeInitialMarkup ( props . markup ) ;
335335
336336 if ( nextMarkup !== editor . getHTML ( ) ) {
337- editor . commands . setContent ( nextMarkup , false ) ;
337+ editor . commands . setContent ( nextMarkup , { emitUpdate : false } ) ;
338338 }
339339 } , [ props . markup , editor ] ) ;
340340
Original file line number Diff line number Diff line change @@ -169,14 +169,27 @@ export const CSSMark = Mark.create({
169169 } ,
170170
171171 parseHTML ( ) {
172- // Any span with a class that matches one of allowed classes
172+ // Any span with a class that matches one of allowed classes any span that carries a class attribute
173+ // so that pre-existing spans are preserved when loading content
173174 return [
174175 {
175176 tag : 'span[class]' ,
176177 getAttrs : ( el ) => {
177178 const cls = el . getAttribute ( 'class' ) || '' ;
178- const match = this . options . classes . find ( ( name ) => cls . includes ( name ) ) ;
179- return match ? { class : match } : false ;
179+
180+ if ( ! cls ) {
181+ return false ;
182+ }
183+
184+ const allowedClasses = ( this . options && this . options . classes ) || [ ] ;
185+
186+ if ( allowedClasses . length > 0 ) {
187+ const match = this . options . classes . find ( ( name ) => cls . includes ( name ) ) ;
188+
189+ return match ? { class : match } : false ;
190+ }
191+
192+ return { class : cls } ;
180193 } ,
181194 } ,
182195 ] ;
You can’t perform that action at this time.
0 commit comments