File tree Expand file tree Collapse file tree 3 files changed +13
-19
lines changed
Expand file tree Collapse file tree 3 files changed +13
-19
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import { useSelectObject } from './use-select-object';
1919import { useInputAndSelection } from './use-input-and-selection' ;
2020import { useSelectionChangeCompat } from './use-selection-change-compat' ;
2121import { useDelete } from './use-delete' ;
22- import { RichTextString } from '../value' ;
22+ import { createRichTextString } from '../value' ;
2323
2424export function useRichText ( {
2525 value = '' ,
@@ -88,7 +88,7 @@ export function useRichText( {
8888 multilineTag === 'li' ? [ 'ul' , 'ol' ] : undefined ,
8989 preserveWhiteSpace,
9090 } )
91- : { ... value } ;
91+ : value . value ;
9292 if ( disableFormats ) {
9393 record . current . formats = Array ( value . length ) ;
9494 record . current . replacements = Array ( value . length ) ;
@@ -145,7 +145,7 @@ export function useRichText( {
145145 if ( disableFormats ) {
146146 _value . current = newRecord . text ;
147147 } else {
148- _value . current = new RichTextString ( {
148+ _value . current = createRichTextString ( {
149149 value : __unstableBeforeSerialize
150150 ? {
151151 ...newRecord ,
Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ import {
1414 OBJECT_REPLACEMENT_CHARACTER ,
1515 ZWNBSP ,
1616} from './special-characters' ;
17- import { RichTextString } from './value' ;
1817
1918/** @typedef {import('./types').RichTextValue } RichTextValue */
2019
@@ -170,7 +169,7 @@ export function create( {
170169 } ;
171170 }
172171
173- if ( html instanceof RichTextString ) {
172+ if ( html instanceof String ) {
174173 return html ;
175174 }
176175
Original file line number Diff line number Diff line change 22 * Internal dependencies
33 */
44import { toHTMLString } from './to-html-string' ;
5- export class RichTextString extends String {
6- constructor ( { value, ...settings } ) {
7- super ( toHTMLString ( { value, ...settings } ) ) ;
8- for ( const key in value ) {
9- Object . defineProperty ( this , key , {
10- value : value [ key ] ,
11- enumerable : true ,
12- } ) ;
13- }
145
15- for ( const key in settings ) {
16- Object . defineProperty ( this , key , {
17- value : settings [ key ] ,
18- } ) ;
19- }
6+ export function createRichTextString ( args ) {
7+ const string = new String ( toHTMLString ( args ) ) ;
8+
9+ for ( const key in args ) {
10+ Object . defineProperty ( string , key , {
11+ value : args [ key ] ,
12+ } ) ;
2013 }
14+
15+ return string ;
2116}
You can’t perform that action at this time.
0 commit comments