diff --git a/blocks/components/editable/index.js b/blocks/components/editable/index.js
index 1018bfac28975..91aec065bfa2c 100644
--- a/blocks/components/editable/index.js
+++ b/blocks/components/editable/index.js
@@ -12,6 +12,7 @@ import 'element-closest';
*/
import './style.scss';
import FormatToolbar from './format-toolbar';
+import TinyMCE from './tinymce';
// TODO: We mustn't import by relative path traversing from blocks to editor
// as we're doing here; instead, we should consider a common components path.
import Toolbar from '../../../editor/components/toolbar';
@@ -65,7 +66,6 @@ export default class Editable extends wp.element.Component {
this.onSetup = this.onSetup.bind( this );
this.onChange = this.onChange.bind( this );
this.onNewBlock = this.onNewBlock.bind( this );
- this.bindEditorNode = this.bindEditorNode.bind( this );
this.onFocus = this.onFocus.bind( this );
this.onNodeChange = this.onNodeChange.bind( this );
this.onKeyDown = this.onKeyDown.bind( this );
@@ -77,28 +77,6 @@ export default class Editable extends wp.element.Component {
};
}
- componentDidMount() {
- this.initialize();
- }
-
- initialize() {
- const config = {
- target: this.editorNode,
- theme: false,
- inline: true,
- toolbar: false,
- browser_spellcheck: true,
- entity_encoding: 'raw',
- convert_urls: false,
- setup: this.onSetup,
- formats: {
- strikethrough: { inline: 'del' }
- }
- };
-
- tinymce.init( config );
- }
-
onSetup( editor ) {
this.editor = editor;
editor.on( 'init', this.onInit );
@@ -110,7 +88,6 @@ export default class Editable extends wp.element.Component {
}
onInit() {
- this.setContent( this.props.value );
this.focus();
}
@@ -134,7 +111,7 @@ export default class Editable extends wp.element.Component {
}
getRelativePosition( node ) {
- const editorPosition = this.editorNode.closest( '.editor-visual-editor__block' ).getBoundingClientRect();
+ const editorPosition = this.editor.getBody().closest( '.editor-visual-editor__block' ).getBoundingClientRect();
const position = node.getBoundingClientRect();
return {
top: position.top - editorPosition.top + 40 + ( position.height ),
@@ -211,13 +188,10 @@ export default class Editable extends wp.element.Component {
// Splitting into two blocks
this.setContent( this.props.value );
- // The setTimeout fixes the focus jump to the original block
- setTimeout( () => {
- this.props.onSplit(
- nodeListToReact( before, createElement ),
- nodeListToReact( after, createElement )
- );
- } );
+ this.props.onSplit(
+ nodeListToReact( before, createElement ),
+ nodeListToReact( after, createElement )
+ );
}
onNodeChange( { element, parents } ) {
@@ -242,10 +216,6 @@ export default class Editable extends wp.element.Component {
this.setState( { alignment, bookmark, formats, focusPosition } );
}
- bindEditorNode( ref ) {
- this.editorNode = ref;
- }
-
updateContent() {
const bookmark = this.editor.selection.getBookmark( 2, true );
this.savedContent = this.props.value;
@@ -267,7 +237,7 @@ export default class Editable extends wp.element.Component {
}
getContent() {
- return nodeListToReact( this.editorNode.childNodes || [], createElement );
+ return nodeListToReact( this.editor.getBody().childNodes || [], createElement );
}
focus() {
@@ -366,14 +336,16 @@ export default class Editable extends wp.element.Component {
}
render() {
- const { tagName: Tag = 'div', style, focus, className, showAlignments = false, formattingControls } = this.props;
+ const { tagName, style, value, focus, className, showAlignments = false, formattingControls } = this.props;
const classes = classnames( 'blocks-editable', className );
let element = (
-