22 * External dependencies
33 */
44import classnames from 'classnames' ;
5- import { last , isEqual , capitalize , omitBy , forEach , merge , identity , find } from 'lodash' ;
5+ import { last , isEqual , omitBy , forEach , merge , identity , find } from 'lodash' ;
66import { nodeListToReact } from 'dom-react' ;
77import { Fill } from 'react-slot-fill' ;
88import 'element-closest' ;
99
1010/**
1111 * WordPress dependencies
1212 */
13- import { Toolbar } from 'components' ;
1413import { BACKSPACE , DELETE } from 'utils/keycodes' ;
1514
1615/**
@@ -20,30 +19,6 @@ import './style.scss';
2019import FormatToolbar from './format-toolbar' ;
2120import TinyMCE from './tinymce' ;
2221
23- const alignmentMap = {
24- alignleft : 'left' ,
25- alignright : 'right' ,
26- aligncenter : 'center' ,
27- } ;
28-
29- const ALIGNMENT_CONTROLS = [
30- {
31- icon : 'editor-alignleft' ,
32- title : wp . i18n . __ ( 'Align left' ) ,
33- align : 'left' ,
34- } ,
35- {
36- icon : 'editor-aligncenter' ,
37- title : wp . i18n . __ ( 'Align center' ) ,
38- align : 'center' ,
39- } ,
40- {
41- icon : 'editor-alignright' ,
42- title : wp . i18n . __ ( 'Align right' ) ,
43- align : 'right' ,
44- } ,
45- ] ;
46-
4722function createElement ( type , props , ...children ) {
4823 if ( props [ 'data-mce-bogus' ] === 'all' ) {
4924 return null ;
@@ -78,7 +53,6 @@ export default class Editable extends wp.element.Component {
7853
7954 this . state = {
8055 formats : { } ,
81- alignment : null ,
8256 bookmark : null ,
8357 empty : ! props . value || ! props . value . length ,
8458 } ;
@@ -296,12 +270,10 @@ export default class Editable extends wp.element.Component {
296270 }
297271 const activeFormats = this . editor . formatter . matchAll ( [ 'bold' , 'italic' , 'strikethrough' ] ) ;
298272 activeFormats . forEach ( ( activeFormat ) => formats [ activeFormat ] = true ) ;
299- const alignments = this . editor . formatter . matchAll ( [ 'alignleft' , 'aligncenter' , 'alignright' ] ) ;
300- const alignment = alignments . length > 0 ? alignmentMap [ alignments [ 0 ] ] : null ;
301273
302274 const focusPosition = this . getRelativePosition ( element ) ;
303275 const bookmark = this . editor . selection . getBookmark ( 2 , true ) ;
304- this . setState ( { alignment , bookmark, formats, focusPosition } ) ;
276+ this . setState ( { bookmark, formats, focusPosition } ) ;
305277 }
306278
307279 updateContent ( ) {
@@ -400,28 +372,13 @@ export default class Editable extends wp.element.Component {
400372 this . editor . setDirty ( true ) ;
401373 }
402374
403- isAlignmentActive ( align ) {
404- return this . state . alignment === align ;
405- }
406-
407- toggleAlignment ( align ) {
408- this . editor . focus ( ) ;
409-
410- if ( this . isAlignmentActive ( align ) ) {
411- this . editor . execCommand ( 'JustifyNone' ) ;
412- } else {
413- this . editor . execCommand ( 'Justify' + capitalize ( align ) ) ;
414- }
415- }
416-
417375 render ( ) {
418376 const {
419377 tagName,
420378 style,
421379 value,
422380 focus,
423381 className,
424- showAlignments = false ,
425382 inlineToolbar = false ,
426383 formattingControls,
427384 placeholder,
@@ -446,15 +403,6 @@ export default class Editable extends wp.element.Component {
446403 < div className = { classes } >
447404 { focus &&
448405 < Fill name = "Formatting.Toolbar" >
449- { showAlignments &&
450- < Toolbar
451- controls = { ALIGNMENT_CONTROLS . map ( ( control ) => ( {
452- ...control ,
453- onClick : ( ) => this . toggleAlignment ( control . align ) ,
454- isActive : this . isAlignmentActive ( control . align ) ,
455- } ) ) }
456- />
457- }
458406 { ! inlineToolbar && formatToolbar }
459407 </ Fill >
460408 }
0 commit comments