Skip to content

Commit

Permalink
Remove unstableGetSettings and unstableOnSetup
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Nov 6, 2018
1 parent eedb9b3 commit ad64fcc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 70 deletions.
32 changes: 0 additions & 32 deletions packages/editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export class RichText extends Component {
}

this.onInit = this.onInit.bind( this );
this.getSettings = this.getSettings.bind( this );
this.onSetup = this.onSetup.bind( this );
this.onFocus = this.onFocus.bind( this );
this.onChange = this.onChange.bind( this );
Expand Down Expand Up @@ -132,31 +131,6 @@ export class RichText extends Component {
return this.editableRef === document.activeElement;
}

/**
* Retrieves the settings for this block.
*
* Allows passing in settings which will be overwritten.
*
* @param {Object} settings The settings to overwrite.
* @return {Object} The settings for this block.
*/
getSettings( settings ) {
settings = {
...settings,
forced_root_block: this.multilineTag || false,
// Allow TinyMCE to keep one undo level for comparing changes.
// Prevent it otherwise from accumulating any history.
custom_undo_redo_levels: 1,
};

const { unstableGetSettings } = this.props;
if ( unstableGetSettings ) {
settings = unstableGetSettings( settings );
}

return settings;
}

/**
* Handles the onSetup event for the TinyMCE component.
*
Expand All @@ -173,11 +147,6 @@ export class RichText extends Component {
editor.on( 'BeforeExecCommand', this.onPropagateUndo );
// The change event in TinyMCE fires every time an undo level is added.
editor.on( 'change', this.onCreateUndoLevel );

const { unstableOnSetup } = this.props;
if ( unstableOnSetup ) {
unstableOnSetup( editor );
}
}

setFocusedElement() {
Expand Down Expand Up @@ -891,7 +860,6 @@ export class RichText extends Component {
<Fragment>
<TinyMCE
tagName={ Tagname }
getSettings={ this.getSettings }
onSetup={ this.onSetup }
style={ style }
defaultValue={ value }
Expand Down
35 changes: 0 additions & 35 deletions packages/editor/src/components/rich-text/test/index.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,9 @@
/**
* External dependencies
*/
import { shallow } from 'enzyme';

/**
* WordPress dependencies
*/
import { create } from '@wordpress/rich-text';

/**
* Internal dependencies
*/
import { RichText } from '../';
import { diffAriaProps, pickAriaProps } from '../aria';

describe( 'RichText', () => {
describe( 'Component', () => {
describe( '.getSettings', () => {
const value = create();
const settings = {
setting: 'hi',
};

test( 'should return expected settings', () => {
const wrapper = shallow( <RichText value={ value } /> );
expect( wrapper.instance().getSettings( settings ) ).toEqual( {
setting: 'hi',
forced_root_block: false,
custom_undo_redo_levels: 1,
} );
} );

test( 'should be overriden', () => {
const mock = jest.fn().mockImplementation( () => 'mocked' );

expect( shallow( <RichText value={ value } unstableGetSettings={ mock } /> ).instance().getSettings( settings ) ).toEqual( 'mocked' );
} );
} );
} );

describe( 'pickAriaProps()', () => {
it( 'should should filter all properties to only those begining with "aria-"', () => {
expect( pickAriaProps( {
Expand Down
11 changes: 8 additions & 3 deletions packages/editor/src/components/rich-text/tinymce.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ export default class TinyMCE extends Component {
}

initialize() {
const settings = this.props.getSettings( {
const { multilineTag } = this.props;
const settings = {
theme: false,
inline: true,
toolbar: false,
Expand All @@ -191,9 +192,13 @@ export default class TinyMCE extends Component {
verify_html: false,
inline_boundaries_selector: 'a[href],code,b,i,strong,em,del,ins,sup,sub',
plugins: [],
} );
forced_root_block: multilineTag || false,
// Allow TinyMCE to keep one undo level for comparing changes.
// Prevent it otherwise from accumulating any history.
custom_undo_redo_levels: 1,
};

if ( this.props.multilineTag === 'li' ) {
if ( multilineTag === 'li' ) {
settings.plugins.push( 'lists' );
settings.lists_indent_on_tab = true;
}
Expand Down

0 comments on commit ad64fcc

Please sign in to comment.