ソースを参照

Adjust to changes in `EditorUI`.

Krzysztof Krztoń 7 年 前
コミット
bec6cc4246

+ 35 - 0
packages/ckeditor5-editor-balloon/src/ballooneditorui.js

@@ -17,6 +17,34 @@ import enableToolbarKeyboardFocus from '@ckeditor/ckeditor5-ui/src/toolbar/enabl
  */
 export default class BalloonEditorUI extends EditorUI {
 	/**
+	 * Creates an instance of the balloon 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 );
+
+		/**
+		 * The main (top–most) view of the editor UI.
+		 *
+		 * @private
+		 * @member {module:ui/editorui/editoruiview~EditorUIView} #_view
+		 */
+		this._view = view;
+	}
+
+	/**
+	 * 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() {
@@ -24,6 +52,13 @@ export default class BalloonEditorUI 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-balloon/tests/ballooneditorui.js

@@ -123,6 +123,20 @@ describe( 'BalloonEditorUI', () => {
 			} );
 		} );
 	} );
+
+	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;
+		} );
+	} );
 } );
 
 class VirtualBalloonTestEditor extends VirtualTestEditor {