Skip to content

Commit

Permalink
Rich text: add HTML string methods to RichTextData (#57322)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix authored Jan 4, 2024
1 parent d362529 commit bccb344
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/rich-text/src/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,19 @@ export class RichTextData {
}
}

for ( const name of Object.getOwnPropertyNames( String.prototype ) ) {
if ( RichTextData.prototype.hasOwnProperty( name ) ) {
continue;
}

Object.defineProperty( RichTextData.prototype, name, {
value( ...args ) {
// Should we convert back to RichTextData?
return this.toHTMLString()[ name ]( ...args );
},
} );
}

/**
* Create a RichText value from an `Element` tree (DOM), an HTML string or a
* plain text string, with optionally a `Range` object to set the selection. If
Expand Down

0 comments on commit bccb344

Please sign in to comment.