瀏覽代碼

Adjust to changes in `EditorUI`.

Krzysztof Krztoń 7 年之前
父節點
當前提交
7dae6aa809

+ 30 - 2
packages/ckeditor5-editor-inline/src/inlineeditorui.js

@@ -18,10 +18,21 @@ import normalizeToolbarConfig from '@ckeditor/ckeditor5-ui/src/toolbar/normalize
  */
 export default class InlineEditorUI extends EditorUI {
 	/**
-	 * @inheritDoc
+	 * Creates an instance of the inline editor UI class.
+	 *
+	 * @param {module:core/editor/editor~Editor} editor The editor instance.
+	 * @param {module:ui/editorui/editoruiview~EditorUIView} view The view of the UI.
 	 */
 	constructor( editor, view ) {
-		super( editor, view );
+		super( editor );
+
+		/**
+		 * The main (top–most) view of the editor UI.
+		 *
+		 * @private
+		 * @member {module:ui/editorui/editoruiview~EditorUIView} #_view
+		 */
+		this._view = view;
 
 		/**
 		 * A normalized `config.toolbar` object.
@@ -33,6 +44,16 @@ export default class InlineEditorUI extends EditorUI {
 	}
 
 	/**
+	 * The main (top–most) view of the editor UI.
+	 *
+	 * @readonly
+	 * @member {module:ui/editorui/editoruiview~EditorUIView} #view
+	 */
+	get view() {
+		return this._view;
+	}
+
+	/**
 	 * @inheritDoc
 	 */
 	get element() {
@@ -40,6 +61,13 @@ export default class InlineEditorUI extends EditorUI {
 	}
 
 	/**
+	 * @inheritDoc
+	 */
+	getEditableElement( rootName = 'main' ) {
+		return this.view.editable.name === rootName ? this.view.editable : null;
+	}
+
+	/**
 	 * Initializes the UI.
 	 */
 	init() {

+ 14 - 0
packages/ckeditor5-editor-inline/tests/inlineeditorui.js

@@ -198,6 +198,20 @@ describe( 'InlineEditorUI', () => {
 				} );
 		} );
 	} );
+
+	describe( 'getEditableElement()', () => {
+		it( 'returns editable element (default)', () => {
+			expect( ui.getEditableElement() ).to.equal( view.editable );
+		} );
+
+		it( 'returns editable element (root name passed)', () => {
+			expect( ui.getEditableElement( 'main' ) ).to.equal( view.editable );
+		} );
+
+		it( 'returns null if editable with the given name is absent', () => {
+			expect( ui.getEditableElement( 'absent' ) ).to.null;
+		} );
+	} );
 } );
 
 function viewCreator( name ) {