This repository has been archived by the owner on Jun 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #279 from ckeditor/t/277
Feature: `StickyToolbarView` now supports a configurable vertical offset from the top of the page. Closes #277. Also implemented the `normalizeToolbarConfig()` utility. BREAKING CHANGE: `StickyToolbarView#limiterOffset` has been renamed to `StickyToolbarView#limiterBottomOffset`.
- Loading branch information
Showing
7 changed files
with
285 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
/** | ||
* @module ui/toolbar/normalizetoolbarconfig | ||
*/ | ||
|
||
/** | ||
* Normalizes the toolbar configuration (`config.toolbar`), which may be defined as an `Array` | ||
* | ||
* toolbar: [ 'headings', 'bold', 'italic', 'link', 'unlink', ... ] | ||
* | ||
* or an `Object` | ||
* | ||
* toolbar: { | ||
* items: [ 'headings', 'bold', 'italic', 'link', 'unlink', ... ], | ||
* ... | ||
* } | ||
* | ||
* and returns it in the object form. | ||
* | ||
* @param {Array|Object} config The value of `config.toolbar`. | ||
* @returns {Object} A normalized toolbar config object. | ||
*/ | ||
export default function normalizeToolbarConfig( config ) { | ||
if ( Array.isArray( config ) ) { | ||
config = { | ||
items: config | ||
}; | ||
} | ||
|
||
return config; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
import normalizeToolbarConfig from '../../src/toolbar/normalizetoolbarconfig'; | ||
|
||
describe( 'normalizeToolbarConfig()', () => { | ||
it( 'normalizes the config specified as an Array', () => { | ||
const cfg = [ 'foo', 'bar' ]; | ||
const normalized = normalizeToolbarConfig( cfg ); | ||
|
||
expect( normalized ).to.be.an( 'object' ); | ||
expect( normalized.items ).to.equal( cfg ); | ||
} ); | ||
|
||
it( 'passes through an already normalized config', () => { | ||
const cfg = { | ||
items: [ 'foo', 'bar' ], | ||
foo: 'bar' | ||
}; | ||
const normalized = normalizeToolbarConfig( cfg ); | ||
|
||
expect( normalized ).to.equal( cfg ); | ||
expect( normalized.items ).to.equal( cfg.items ); | ||
expect( normalized.foo ).to.equal( cfg.foo ); | ||
} ); | ||
} ); |
Oops, something went wrong.