Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/blocks/rich-text/format-toolbar/index.js b/blocks/rich-text/format-toolbar/index.js
- index edc1c54a..b7750c82 100644
- --- a/blocks/rich-text/format-toolbar/index.js
- +++ b/blocks/rich-text/format-toolbar/index.js
- @@ -97,6 +97,7 @@ class FormatToolbar extends Component {
- }
- addLink() {
- + this.props.highlightSelection();
- this.setState( { isEditingLink: false, isAddingLink: true, newLinkValue: '' } );
- }
- diff --git a/blocks/rich-text/index.js b/blocks/rich-text/index.js
- index eeeebff9..85191057 100644
- --- a/blocks/rich-text/index.js
- +++ b/blocks/rich-text/index.js
- @@ -101,6 +101,7 @@ export default class RichText extends Component {
- this.maybePropagateUndo = this.maybePropagateUndo.bind( this );
- this.onPastePreProcess = this.onPastePreProcess.bind( this );
- this.onPaste = this.onPaste.bind( this );
- + this.highlightSelection = this.highlightSelection.bind( this );
- this.state = {
- formats: {},
- @@ -660,6 +661,9 @@ export default class RichText extends Component {
- if ( document.activeElement !== this.editor.getBody() ) {
- return;
- }
- + if ( this.editor.selection.getNode().hasAttribute( 'data-mce-bogus' ) ) {
- + return;
- + }
- const formatNames = this.props.formattingControls;
- const formats = this.editor.formatter.matchAll( formatNames ).reduce( ( accFormats, activeFormat ) => {
- accFormats[ activeFormat ] = {
- @@ -766,6 +770,17 @@ export default class RichText extends Component {
- this.editor.setDirty( true );
- }
- + highlightSelection() {
- + this.editor.undoManager.ignore( () => {
- + const id = this.editor.dom.uniqueId();
- + const content = this.editor.selection.getContent();
- + this.editor.selection.setContent(
- + `<span id="${ id }" style="background: rgba( 15, 155, 195, 0.2 )" data-mce-bogus="1">${ content }</span>`
- + );
- + this.editor.selection.select( this.editor.dom.get( id ) );
- + } );
- + }
- +
- render() {
- const {
- tagName: Tagname = 'div',
- @@ -800,6 +815,7 @@ export default class RichText extends Component {
- onChange={ this.changeFormats }
- enabledControls={ formattingControls }
- customControls={ formatters }
- + highlightSelection={ this.highlightSelection }
- />
- );
- diff --git a/blocks/url-input/index.js b/blocks/url-input/index.js
- index a98d0df1..b6f596f8 100644
- --- a/blocks/url-input/index.js
- +++ b/blocks/url-input/index.js
- @@ -181,7 +181,7 @@ class UrlInput extends Component {
- return (
- <div className="blocks-url-input">
- <input
- - autoFocus
- + // autoFocus
- type="text"
- aria-label={ __( 'URL' ) }
- required
Add Comment
Please, Sign In to add comment