8
0
فهرست منبع

Deprecate `InlineEditorUIView#editableElement`.

Krzysztof Krztoń 7 سال پیش
والد
کامیت
1518071648

+ 3 - 3
packages/ckeditor5-editor-inline/src/inlineeditorui.js

@@ -61,7 +61,7 @@ export default class InlineEditorUI extends EditorUI {
 			// showing up when there's no focus in the UI.
 			if ( view.panel.isVisible ) {
 				view.panel.pin( {
-					target: view.editableElement,
+					target: view.editable.editableElement,
 					positions: view.panelPositions
 				} );
 			}
@@ -74,10 +74,10 @@ export default class InlineEditorUI extends EditorUI {
 		// Bind to focusTracker instead of editor.editing.view because otherwise
 		// focused editable styles disappear when view#toolbar is focused.
 		view.editable.bind( 'isFocused' ).to( this.focusTracker );
-		editor.editing.view.attachDomRoot( view.editableElement );
+		editor.editing.view.attachDomRoot( view.editable.editableElement );
 		view.editable.name = editingRoot.rootName;
 
-		this.focusTracker.add( view.editableElement );
+		this.focusTracker.add( view.editable.editableElement );
 
 		view.toolbar.fillFromConfig( this._toolbarConfig.items, this.componentFactory );
 

+ 13 - 2
packages/ckeditor5-editor-inline/src/inlineeditoruiview.js

@@ -12,6 +12,8 @@ import InlineEditableUIView from '@ckeditor/ckeditor5-ui/src/editableui/inline/i
 import BalloonPanelView from '@ckeditor/ckeditor5-ui/src/panel/balloon/balloonpanelview';
 import ToolbarView from '@ckeditor/ckeditor5-ui/src/toolbar/toolbarview';
 
+import log from '@ckeditor/ckeditor5-utils/src/log';
+
 /**
  * Inline editor UI view. Uses an nline editable and a floating toolbar.
  *
@@ -144,10 +146,19 @@ export default class InlineEditorUIView 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 InlineEditorUIView#editableElement property is deprecated.' );
+		return this.editable.editableElement;
 	}
 
 	/**

+ 1 - 1
packages/ckeditor5-editor-inline/tests/inlineeditorui.js

@@ -93,7 +93,7 @@ describe( 'InlineEditorUI', () => {
 				editor.ui.fire( 'update' );
 				sinon.assert.calledOnce( spy );
 				sinon.assert.calledWithExactly( spy, {
-					target: view.editableElement,
+					target: view.editable.editableElement,
 					positions: sinon.match.array
 				} );
 			} );

+ 7 - 0
packages/ckeditor5-editor-inline/tests/inlineeditoruiview.js

@@ -9,9 +9,14 @@ import BalloonPanelView from '@ckeditor/ckeditor5-ui/src/panel/balloon/balloonpa
 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( 'InlineEditorUIView', () => {
 	let locale, view;
 
+	testUtils.createSinonSandbox();
+
 	beforeEach( () => {
 		locale = new Locale( 'en' );
 		view = new InlineEditorUIView( locale );
@@ -119,6 +124,8 @@ describe( 'InlineEditorUIView', () => {
 
 	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();