Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Deprecate DecoupledEditorUIView#editableElement.
Browse files Browse the repository at this point in the history
  • Loading branch information
f1ames committed Jan 11, 2019
1 parent e8e28d0 commit 6040047
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/decouplededitorui.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ export default class DecoupledEditorUI extends EditorUI {
const editingRoot = editor.editing.view.document.getRoot();
view.editable.bind( 'isReadOnly' ).to( editingRoot );
view.editable.bind( 'isFocused' ).to( editor.editing.view.document );
editor.editing.view.attachDomRoot( view.editableElement );
editor.editing.view.attachDomRoot( view.editable.editableElement );
view.editable.name = editingRoot.rootName;

this.focusTracker.add( this.view.editableElement );
this.focusTracker.add( this.view.editable.editableElement );
this.view.toolbar.fillFromConfig( this._toolbarConfig.items, this.componentFactory );

enableToolbarKeyboardFocus( {
Expand Down
15 changes: 13 additions & 2 deletions src/decouplededitoruiview.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import InlineEditableUIView from '@ckeditor/ckeditor5-ui/src/editableui/inline/i
import ToolbarView from '@ckeditor/ckeditor5-ui/src/toolbar/toolbarview';
import Template from '@ckeditor/ckeditor5-ui/src/template';

import log from '@ckeditor/ckeditor5-utils/src/log';

/**
* The decoupled editor UI view. It is a virtual view providing an inline
* {@link module:editor-decoupled/decouplededitoruiview~DecoupledEditorUIView#editable} and a
Expand Down Expand Up @@ -72,9 +74,18 @@ export default class DecoupledEditorUIView extends EditorUIView {
}

/**
* @inheritDoc
* **Deprecated** since `v12.0.0`. The {@link module:ui/editableui/editableuiview~EditableUIView#editableElement
* `EditableUIView editableElement`} could be used instead.
*
* The element which is the main editable element (usually the one with `contentEditable="true"`).
*
* @deprecated v12.0.0 The {@link module:ui/editableui/editableuiview~EditableUIView#editableElement
* `EditableUIView editableElement`} could be used instead.
* @readonly
* @member {HTMLElement} #editableElement
*/
get editableElement() {
return this.editable.element;
log.warn( 'deprecated-ui-view-editableElement: The DecoupledEditorUIView#editableElement property is deprecated.' );
return this.editable.editableElement;
}
}
7 changes: 7 additions & 0 deletions tests/decouplededitoruiview.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ import ToolbarView from '@ckeditor/ckeditor5-ui/src/toolbar/toolbarview';
import InlineEditableUIView from '@ckeditor/ckeditor5-ui/src/editableui/inline/inlineeditableuiview';
import Locale from '@ckeditor/ckeditor5-utils/src/locale';

import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
import log from '@ckeditor/ckeditor5-utils/src/log';

describe( 'DecoupledEditorUIView', () => {
let locale, view;

testUtils.createSinonSandbox();

beforeEach( () => {
locale = new Locale( 'en' );
view = new DecoupledEditorUIView( locale );
Expand Down Expand Up @@ -124,6 +129,8 @@ describe( 'DecoupledEditorUIView', () => {

describe( 'editableElement', () => {
it( 'returns editable\'s view element', () => {
testUtils.sinon.stub( log, 'warn' ).callsFake( () => {} );

view.render();
expect( view.editableElement.getAttribute( 'contentEditable' ) ).to.equal( 'true' );
view.destroy();
Expand Down

0 comments on commit 6040047

Please sign in to comment.