Skip to content

Commit

Permalink
Update TODO items. Polishing. Updating tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dawidurbanski committed Aug 15, 2021
1 parent 39597fd commit 83b130c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 24 deletions.
18 changes: 11 additions & 7 deletions packages/ckeditor5-core/src/editor/editorui.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class EditorUI {
*
* @observable
*/
this.set( 'viewportOffset', this._viewportTopOffset );
this.set( 'viewportOffset', this._viewportOffset );

/**
* Stores all editable elements used by the editor instance.
Expand Down Expand Up @@ -179,12 +179,14 @@ export default class EditorUI {
}

/**
* TODO
* Returns viewport offsets object
* { top: Number, right: Number, bottom: Number, left: Number }
* Only top property is currently supported
*
* @private
* @return Object
* @return {Object}
*/
get _viewportTopOffset() {
get _viewportOffset() {
const editor = this.editor;
const viewportOffsetConfig = editor.config.get( 'ui.viewportOffset' );

Expand All @@ -197,12 +199,14 @@ export default class EditorUI {
// Fall back to deprecated toolbar config
if ( legacyOffsetConfig ) {
/**
* TODO
* The {@link module:core/editor/editorconfig~EditorConfig#toolbar `EditorConfig#toolbar.viewportTopOffset`}
* property has been deprecated and will be removed in the near future. Please use
* {@link module:core/editor/editorconfig~EditorConfig#ui `EditorConfig#ui.viewportOffset`} instead.
*
* @error todo-error-name
* @error editor-ui-deprecated-viewport-offset-config
*/
console.warn(
'todo-error-name: ' +
'editor-ui-deprecated-viewport-offset-config: ' +
'The `toolbar.vieportTopOffset` configuration option is deprecated. ' +
'It will be removed from future CKEditor versions. Use `ui.viewportOffset.top` instead.'
);
Expand Down
4 changes: 3 additions & 1 deletion packages/ckeditor5-editor-classic/tests/classiceditorui.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe( 'ClassicEditorUI', () => {
} );

it( 'sets view.stickyPanel#viewportTopOffset, if legacy toolbar.vierportTopOffset specified', () => {
sinon.stub( console, 'warn' );
const spy = sinon.stub( console, 'warn' );

return VirtualClassicTestEditor
.create( 'foo', {
Expand All @@ -95,7 +95,9 @@ describe( 'ClassicEditorUI', () => {
}
} )
.then( editor => {
expect( editor.ui.viewportOffset.top ).to.equal( 100 );
expect( editor.ui.view.stickyPanel.viewportTopOffset ).to.equal( 100 );
sinon.assert.calledOnce( spy );

return editor.destroy();
} );
Expand Down
7 changes: 4 additions & 3 deletions packages/ckeditor5-editor-inline/tests/inlineeditorui.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe( 'InlineEditorUI', () => {
} );

it( 'sets view#viewportTopOffset, if legacy toolbar.vierportTopOffset specified', () => {
sinon.stub( console, 'warn' );
const spy = sinon.stub( console, 'warn' );

return VirtualInlineTestEditor
.create( 'foo', {
Expand All @@ -95,9 +95,10 @@ describe( 'InlineEditorUI', () => {
} )
.then( editor => {
const ui = editor.ui;
const view = ui.view;

expect( view.viewportTopOffset ).to.equal( 100 );
expect( ui.viewportOffset.top ).to.equal( 100 );
expect( ui.view.viewportTopOffset ).to.equal( 100 );
sinon.assert.calledOnce( spy );

return editor.destroy();
} );
Expand Down
13 changes: 0 additions & 13 deletions packages/ckeditor5-ui/tests/toolbar/normalizetoolbarconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

/* globals console */

import normalizeToolbarConfig from '../../src/toolbar/normalizetoolbarconfig';

describe( 'normalizeToolbarConfig()', () => {
Expand Down Expand Up @@ -55,15 +53,4 @@ describe( 'normalizeToolbarConfig()', () => {
expect( normalized.items ).to.be.an( 'array' ).of.length( 0 );
expect( normalized.removeItems ).to.be.an( 'array' ).of.length( 0 );
} );

it( 'warns when deprecated viewportTopOffset config property is used', () => {
const spy = sinon.stub( console, 'warn' );

const cfg = {
viewportTopOffset: 100
};

normalizeToolbarConfig( cfg );
sinon.assert.calledOnce( spy );
} );
} );

0 comments on commit 83b130c

Please sign in to comment.