diff --git a/packages/editor/src/components/rich-text/index.js b/packages/editor/src/components/rich-text/index.js index 6b5decb63331d..38bbb4e6e47ab 100644 --- a/packages/editor/src/components/rich-text/index.js +++ b/packages/editor/src/components/rich-text/index.js @@ -445,7 +445,8 @@ export class RichText extends Component { return; } - const { start, end, formats } = this.createRecord(); + const value = this.createRecord(); + const { start, end, formats } = value; if ( start !== this.state.start || end !== this.state.end ) { const isCaretWithinFormattedText = this.props.isCaretWithinFormattedText; @@ -456,6 +457,7 @@ export class RichText extends Component { } this.setState( { start, end } ); + this.applyRecord( value ); } } @@ -468,9 +470,9 @@ export class RichText extends Component { * the live DOM. */ onChange( record, _withoutApply ) { - if ( ! _withoutApply ) { + // if ( ! _withoutApply ) { this.applyRecord( record ); - } + // } const { start, end } = record; diff --git a/packages/editor/src/components/rich-text/tinymce.js b/packages/editor/src/components/rich-text/tinymce.js index c589dde327075..c40255ae32a06 100644 --- a/packages/editor/src/components/rich-text/tinymce.js +++ b/packages/editor/src/components/rich-text/tinymce.js @@ -164,7 +164,7 @@ export default class TinyMCE extends Component { // already with dangerouslySetInnerHTML, we don't need this to be // verified. verify_html: false, - inline_boundaries_selector: 'a[href],code,b,i,strong,em,del,ins,sup,sub', + // inline_boundaries_selector: 'a[href],code,b,i,strong,em,del,ins,sup,sub', plugins: [], } ); diff --git a/packages/rich-text/src/to-tree.js b/packages/rich-text/src/to-tree.js index 893b331c44a37..00fb3990078f9 100644 --- a/packages/rich-text/src/to-tree.js +++ b/packages/rich-text/src/to-tree.js @@ -3,6 +3,7 @@ */ import { getFormatType } from './get-format-type'; +import { getActiveFormat } from './get-active-format'; import { LINE_SEPARATOR, OBJECT_REPLACEMENT_CHARACTER, @@ -26,7 +27,7 @@ function fromFormat( { type, attributes, object } ) { const elementAttributes = {}; for ( const name in attributes ) { - const key = formatType.attributes[ name ]; + const key = formatType.attributes ? formatType.attributes[ name ] : false; if ( key ) { elementAttributes[ key ] = attributes[ name ]; @@ -145,7 +146,13 @@ export function toTree( { return; } - const { type, attributes, object } = format; + const { type, attributes = {}, object } = format; + const activeFormat = getActiveFormat( value, type ); + + if ( format === activeFormat ) { + attributes[ 'data-mce-selected' ] = 'inline-boundary'; + } + const parent = getParent( pointer ); const newNode = append( parent, fromFormat( { type, attributes, object } ) );