Skip to content

Commit

Permalink
Merge pull request #10904 from ckeditor/ck/10877-list-properties-ui
Browse files Browse the repository at this point in the history
Feature (list): Implemented the numbered list properties UI. Closes #10877.

Other (ui): `FocusCycler` should skip elements that are invisible to the user (see #10877).

Feature (ui): Introduced the `InputView` class for other inputs such as `InputTextView` to inherit from (see #10877).

Feature (utils): Introduced the `isVisible()` helper to detect whether DOM elements are visible to the user in DOM (see #10877).
  • Loading branch information
arkflpc authored Dec 16, 2021
2 parents d080639 + d3bf610 commit 9be585f
Show file tree
Hide file tree
Showing 49 changed files with 3,201 additions and 546 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import {
FocusTracker,
KeystrokeHandler,
Collection,
Rect
Rect,
isVisible
} from 'ckeditor5/src/utils';

// See: #8833.
Expand Down Expand Up @@ -513,7 +514,7 @@ export default class FindAndReplaceFormView extends View {
const inputElement = this._findInputView.fieldView.element;

// Don't adjust the padding if the input (also: counter) were not rendered or not inserted into DOM yet.
if ( !inputElement || !inputElement.offsetParent ) {
if ( !inputElement || !isVisible( inputElement ) ) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ describe( 'FindAndReplaceFormView', () => {
beforeEach( () => {
view = new FindAndReplaceFormView( { t: val => val } );
view.render();
document.body.appendChild( view.element );
} );

afterEach( () => {
view.element.remove();
view.destroy();
} );

Expand Down Expand Up @@ -385,7 +387,7 @@ describe( 'FindAndReplaceFormView', () => {
} );

it( 'should register child views\' #element in #focusTracker', () => {
view = new FindAndReplaceFormView( { t: val => val } );
const view = new FindAndReplaceFormView( { t: val => val } );

const spy = testUtils.sinon.spy( view._focusTracker, 'add' );

Expand All @@ -399,16 +401,20 @@ describe( 'FindAndReplaceFormView', () => {
sinon.assert.calledWithExactly( spy.getCall( 5 ), view._optionsDropdown.element );
sinon.assert.calledWithExactly( spy.getCall( 6 ), view._replaceButtonView.element );
sinon.assert.calledWithExactly( spy.getCall( 7 ), view._replaceAllButtonView.element );

view.destroy();
} );

it( 'starts listening for #keystrokes coming from #element', () => {
view = new FindAndReplaceFormView( { t: val => val } );
const view = new FindAndReplaceFormView( { t: val => val } );

const spy = sinon.spy( view._keystrokes, 'listenTo' );

view.render();
sinon.assert.calledOnce( spy );
sinon.assert.calledWithExactly( spy, view.element );

view.destroy();
} );

describe( 'activates keyboard navigation in the form', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

/* globals Event */
/* globals document, Event */

import DropdownView from '@ckeditor/ckeditor5-ui/src/dropdown/dropdownview';
import LabeledFieldView from '@ckeditor/ckeditor5-ui/src/labeledfield/labeledfieldview';
Expand Down Expand Up @@ -33,9 +33,12 @@ describe( 'ImageUploadPanelView', () => {
'insertImageViaUrl': createLabeledInputView( { t: val => val } )
} );
view.render();
document.body.appendChild( view.element );
} );

afterEach( () => {
view.element.remove();
view.destroy();
sinon.restore();
} );

Expand Down Expand Up @@ -161,17 +164,19 @@ describe( 'ImageUploadPanelView', () => {
} );

it( 'should register child views\' #element in #focusTracker with no integrations', () => {
view = new ImageUploadPanelView( { t: () => {} } );
const view = new ImageUploadPanelView( { t: () => {} } );

const spy = testUtils.sinon.spy( view.focusTracker, 'add' );
view.render();

sinon.assert.calledWithExactly( spy.getCall( 0 ), view.insertButtonView.element );
sinon.assert.calledWithExactly( spy.getCall( 1 ), view.cancelButtonView.element );

view.destroy();
} );

it( 'should register child views\' #element in #focusTracker with "insertImageViaUrl" integration', () => {
view = new ImageUploadPanelView( { t: () => {} }, {
const view = new ImageUploadPanelView( { t: () => {} }, {
'insertImageViaUrl': createLabeledInputView( { t: val => val } )
} );

Expand All @@ -182,16 +187,20 @@ describe( 'ImageUploadPanelView', () => {
sinon.assert.calledWithExactly( spy.getCall( 0 ), view.getIntegration( 'insertImageViaUrl' ).element );
sinon.assert.calledWithExactly( spy.getCall( 1 ), view.insertButtonView.element );
sinon.assert.calledWithExactly( spy.getCall( 2 ), view.cancelButtonView.element );

view.destroy();
} );

it( 'starts listening for #keystrokes coming from #element', () => {
view = new ImageUploadPanelView( { t: () => {} } );
const view = new ImageUploadPanelView( { t: () => {} } );

const spy = sinon.spy( view.keystrokes, 'listenTo' );

view.render();
sinon.assert.calledOnce( spy );
sinon.assert.calledWithExactly( spy, view.element );

view.destroy();
} );

it( 'intercepts the arrow* events and overrides the default toolbar behavior', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

/* global Event */
/* global document, Event */

import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard';
import TextAlternativeFormView from '../../../src/imagetextalternative/ui/textalternativeformview';
Expand Down Expand Up @@ -106,6 +106,12 @@ describe( 'TextAlternativeFormView', () => {
describe( 'activates keyboard navigation in the form', () => {
beforeEach( () => {
view.render();
document.body.appendChild( view.element );
} );

afterEach( () => {
view.element.remove();
view.destroy();
} );

it( 'so "tab" focuses the next focusable item', () => {
Expand Down
16 changes: 14 additions & 2 deletions packages/ckeditor5-link/tests/ui/linkactionsview.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

/* globals document */

import LinkActionsView from '../../src/ui/linkactionsview';
import View from '@ckeditor/ckeditor5-ui/src/view';
import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard';
Expand All @@ -20,6 +22,12 @@ describe( 'LinkActionsView', () => {
beforeEach( () => {
view = new LinkActionsView( { t: val => val } );
view.render();
document.body.appendChild( view.element );
} );

afterEach( () => {
view.element.remove();
view.destroy();
} );

describe( 'constructor()', () => {
Expand Down Expand Up @@ -139,22 +147,26 @@ describe( 'LinkActionsView', () => {
it( 'should register child views\' #element in #focusTracker', () => {
const spy = testUtils.sinon.spy( FocusTracker.prototype, 'add' );

view = new LinkActionsView( { t: () => {} } );
const view = new LinkActionsView( { t: () => {} } );
view.render();

sinon.assert.calledWithExactly( spy.getCall( 0 ), view.previewButtonView.element );
sinon.assert.calledWithExactly( spy.getCall( 1 ), view.editButtonView.element );
sinon.assert.calledWithExactly( spy.getCall( 2 ), view.unlinkButtonView.element );

view.destroy();
} );

it( 'starts listening for #keystrokes coming from #element', () => {
view = new LinkActionsView( { t: () => {} } );
const view = new LinkActionsView( { t: () => {} } );

const spy = sinon.spy( view.keystrokes, 'listenTo' );

view.render();
sinon.assert.calledOnce( spy );
sinon.assert.calledWithExactly( spy, view.element );

view.destroy();
} );

describe( 'activates keyboard navigation for the toolbar', () => {
Expand Down
11 changes: 9 additions & 2 deletions packages/ckeditor5-link/tests/ui/linkformview.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ describe( 'LinkFormView', () => {
beforeEach( () => {
view = new LinkFormView( { t: val => val }, { manualDecorators: [] } );
view.render();
document.body.appendChild( view.element );
} );

afterEach( () => {
view.element.remove();
view.destroy();
} );

Expand Down Expand Up @@ -108,7 +110,7 @@ describe( 'LinkFormView', () => {
} );

it( 'should register child views\' #element in #focusTracker', () => {
view = new LinkFormView( { t: () => {} }, { manualDecorators: [] } );
const view = new LinkFormView( { t: () => {} }, { manualDecorators: [] } );

const spy = testUtils.sinon.spy( view.focusTracker, 'add' );

Expand All @@ -117,16 +119,20 @@ describe( 'LinkFormView', () => {
sinon.assert.calledWithExactly( spy.getCall( 0 ), view.urlInputView.element );
sinon.assert.calledWithExactly( spy.getCall( 1 ), view.saveButtonView.element );
sinon.assert.calledWithExactly( spy.getCall( 2 ), view.cancelButtonView.element );

view.destroy();
} );

it( 'starts listening for #keystrokes coming from #element', () => {
view = new LinkFormView( { t: () => {} }, { manualDecorators: [] } );
const view = new LinkFormView( { t: () => {} }, { manualDecorators: [] } );

const spy = sinon.spy( view.keystrokes, 'listenTo' );

view.render();
sinon.assert.calledOnce( spy );
sinon.assert.calledWithExactly( spy, view.element );

view.destroy();
} );

describe( 'activates keyboard navigation for the toolbar', () => {
Expand Down Expand Up @@ -214,6 +220,7 @@ describe( 'LinkFormView', () => {

describe( 'manual decorators', () => {
let view, collection, linkCommand;

beforeEach( () => {
collection = new Collection();
collection.add( new ManualDecorator( {
Expand Down
6 changes: 5 additions & 1 deletion packages/ckeditor5-list/lang/contexts.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@
"Lower–roman": "The tooltip text of the button that toggles the \"lower–roman\" list style.",
"Upper-roman": "The tooltip text of the button that toggles the \"upper–roman\" list style.",
"Lower-latin": "The tooltip text of the button that toggles the \"lower–latin\" list style.",
"Upper-latin": "The tooltip text of the button that toggles the \"upper–latin\" list style."
"Upper-latin": "The tooltip text of the button that toggles the \"upper–latin\" list style.",
"List properties": "The label of the button that toggles the visibility of additional numbered list property UI fields.",
"Start at": "The label of the input allowing to change the start index of a numbered list.",
"Start index must be greater than 0.": "The error message displayed when the numbered list start index input value is invalid.",
"Reversed order": "The label of the switch button that reverses the order of the numbered list."
}
4 changes: 2 additions & 2 deletions packages/ckeditor5-list/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
],
"main": "src/index.js",
"dependencies": {
"ckeditor5": "^31.1.0"
"ckeditor5": "^31.1.0",
"@ckeditor/ckeditor5-ui": "^31.1.0"
},
"devDependencies": {
"@ckeditor/ckeditor5-basic-styles": "^31.1.0",
Expand All @@ -34,7 +35,6 @@
"@ckeditor/ckeditor5-table": "^31.1.0",
"@ckeditor/ckeditor5-theme-lark": "^31.1.0",
"@ckeditor/ckeditor5-typing": "^31.1.0",
"@ckeditor/ckeditor5-ui": "^31.1.0",
"@ckeditor/ckeditor5-undo": "^31.1.0",
"@ckeditor/ckeditor5-utils": "^31.1.0",
"webpack": "^5.58.1",
Expand Down
Loading

1 comment on commit 9be585f

@Tyler-Washington888
Copy link
Contributor

@Tyler-Washington888 Tyler-Washington888 commented on 9be585f Dec 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you point me to docs on how to prefill CKEditor with data ?

Please sign in to comment.