Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit 6dfe173

Browse files
committed
Merge branch 'master' into origin_t/898
2 parents bfeabff + 86521df commit 6dfe173

20 files changed

+1526
-412
lines changed

CHANGELOG.md

+20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
Changelog
22
=========
33

4+
## [10.0.0](https://github.com/ckeditor/ckeditor5-engine/compare/v1.0.0-beta.4...v10.0.0) (2018-04-25)
5+
6+
### Other changes
7+
8+
* Changed the license to GPL2+ only. See [ckeditor/ckeditor5#991](https://github.com/ckeditor/ckeditor5/issues/991). ([af46d16](https://github.com/ckeditor/ckeditor5-engine/commit/af46d16))
9+
10+
### BREAKING CHANGES
11+
12+
* The license under which CKEditor 5 is released has been changed from a triple GPL, LGPL and MPL license to a GPL2+ only. See [ckeditor/ckeditor5#991](https://github.com/ckeditor/ckeditor5/issues/991) for more information.
13+
14+
15+
## [1.0.0-beta.4](https://github.com/ckeditor/ckeditor5-engine/compare/v1.0.0-beta.2...v1.0.0-beta.4) (2018-04-19)
16+
17+
### Bug fixes
18+
19+
* `model.Differ` should handle attribute change transformation correctly. Closes [#1404](https://github.com/ckeditor/ckeditor5-engine/issues/1404). ([3769a02](https://github.com/ckeditor/ckeditor5-engine/commit/3769a02))
20+
* `view.Writer` should deeply add and remove `view.AttributeElement`s to/from their clone groups. Closes [#1401](https://github.com/ckeditor/ckeditor5-engine/issues/1401). ([e6bb59b](https://github.com/ckeditor/ckeditor5-engine/commit/e6bb59b))
21+
* The `bindTwoStepCaretToAttribute()` behavioral helper should not fail in more complex cases. Closes [#1301](https://github.com/ckeditor/ckeditor5-engine/issues/1301). Closes [#1346](https://github.com/ckeditor/ckeditor5-engine/issues/1346). Closes [ckeditor/ckeditor5#937](https://github.com/ckeditor/ckeditor5/issues/937). Closes [ckeditor/ckeditor5#922](https://github.com/ckeditor/ckeditor5/issues/922). Closes [ckeditor/ckeditor5#946](https://github.com/ckeditor/ckeditor5/issues/946). ([f0fd2d8](https://github.com/ckeditor/ckeditor5-engine/commit/f0fd2d8))
22+
23+
424
## [1.0.0-beta.2](https://github.com/ckeditor/ckeditor5-engine/compare/v1.0.0-beta.1...v1.0.0-beta.2) (2018-04-10)
525

626
### Features

LICENSE.md

+1-13
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,13 @@ Software License Agreement
44
**CKEditor 5 Editing Engine**https://github.com/ckeditor/ckeditor5-engine <br>
55
Copyright (c) 2003-2018, [CKSource](http://cksource.com) Frederico Knabben. All rights reserved.
66

7-
Licensed under the terms of any of the following licenses at your choice:
8-
9-
* [GNU General Public License Version 2 or later (the "GPL")](http://www.gnu.org/licenses/gpl.html)
10-
* [GNU Lesser General Public License Version 2.1 or later (the "LGPL")](http://www.gnu.org/licenses/lgpl.html)
11-
* [Mozilla Public License Version 1.1 or later (the "MPL")](http://www.mozilla.org/MPL/MPL-1.1.html)
12-
13-
You are not required to, but if you want to explicitly declare the license you have chosen to be bound to when using, reproducing, modifying and distributing this software, just include a text file titled "legal.txt" in your version of this software, indicating your license choice. In any case, your choice will not restrict any recipient of your version of this software to use, reproduce, modify and distribute this software under any of the above licenses.
7+
Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
148

159
Sources of Intellectual Property Included in CKEditor
1610
-----------------------------------------------------
1711

1812
Where not otherwise indicated, all CKEditor content is authored by CKSource engineers and consists of CKSource-owned intellectual property. In some specific instances, CKEditor will incorporate work done by developers outside of CKSource with their express permission.
1913

20-
Third parties' software included:
21-
22-
* Lo-Dash (src/lib/lodash) <br>
23-
Copyright 2012-2015 [The Dojo Foundation](http://dojofoundation.org/) <br>
24-
Available under [MIT license](http://lodash.com/license)
25-
2614
Trademarks
2715
----------
2816

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ See the [`@ckeditor/ckeditor5-engine` package](https://docs.ckeditor.com/ckedito
1818

1919
## License
2020

21-
Licensed under the GPL, LGPL and MPL licenses, at your choice. For full details about the license, please check the `LICENSE.md` file.
21+
Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html). For full details about the license, please check the `LICENSE.md` file.

package.json

+34-16
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,45 @@
11
{
22
"name": "@ckeditor/ckeditor5-engine",
3-
"version": "1.0.0-beta.2",
3+
"version": "10.0.0",
44
"description": "CKEditor 5 editing engine.",
55
"keywords": [
6+
"ckeditor5-lib",
7+
"CKEditor",
68
"ckeditor5",
7-
"ckeditor5-lib"
9+
"ckeditor 5",
10+
"WYSIWYG",
11+
"WYSIWYM",
12+
"text",
13+
"rich-text",
14+
"richtext",
15+
"editor",
16+
"html",
17+
"contentEditable",
18+
"editing",
19+
"operational transformation",
20+
"ot",
21+
"collaboration",
22+
"collaborative",
23+
"real-time",
24+
"virtual dom",
25+
"framework"
826
],
927
"dependencies": {
10-
"@ckeditor/ckeditor5-utils": "^1.0.0-beta.2"
28+
"@ckeditor/ckeditor5-utils": "^10.0.0"
1129
},
1230
"devDependencies": {
13-
"@ckeditor/ckeditor5-basic-styles": "^1.0.0-beta.2",
14-
"@ckeditor/ckeditor5-core": "^1.0.0-beta.2",
15-
"@ckeditor/ckeditor5-editor-classic": "^1.0.0-beta.2",
16-
"@ckeditor/ckeditor5-enter": "^1.0.0-beta.2",
17-
"@ckeditor/ckeditor5-essentials": "^1.0.0-beta.2",
18-
"@ckeditor/ckeditor5-heading": "^1.0.0-beta.2",
19-
"@ckeditor/ckeditor5-list": "^1.0.0-beta.2",
20-
"@ckeditor/ckeditor5-paragraph": "^1.0.0-beta.2",
21-
"@ckeditor/ckeditor5-typing": "^1.0.0-beta.2",
22-
"@ckeditor/ckeditor5-undo": "^1.0.0-beta.2",
23-
"@ckeditor/ckeditor5-widget": "^1.0.0-beta.2",
24-
"@ckeditor/ckeditor5-link": "^1.0.0-beta.2",
31+
"@ckeditor/ckeditor5-basic-styles": "^10.0.0",
32+
"@ckeditor/ckeditor5-core": "^10.0.0",
33+
"@ckeditor/ckeditor5-editor-classic": "^10.0.0",
34+
"@ckeditor/ckeditor5-enter": "^10.0.0",
35+
"@ckeditor/ckeditor5-essentials": "^10.0.0",
36+
"@ckeditor/ckeditor5-heading": "^10.0.0",
37+
"@ckeditor/ckeditor5-list": "^10.0.0",
38+
"@ckeditor/ckeditor5-paragraph": "^10.0.0",
39+
"@ckeditor/ckeditor5-typing": "^10.0.0",
40+
"@ckeditor/ckeditor5-undo": "^10.0.0",
41+
"@ckeditor/ckeditor5-widget": "^10.0.0",
42+
"@ckeditor/ckeditor5-link": "^10.0.0",
2543
"eslint": "^4.15.0",
2644
"eslint-config-ckeditor5": "^1.0.7",
2745
"husky": "^0.14.3",
@@ -32,7 +50,7 @@
3250
"npm": ">=3.0.0"
3351
},
3452
"author": "CKSource (http://cksource.com/)",
35-
"license": "(GPL-2.0 OR LGPL-2.1 OR MPL-1.1)",
53+
"license": "GPL-2.0-or-later",
3654
"homepage": "https://ckeditor.com",
3755
"bugs": "https://github.com/ckeditor/ckeditor5-engine/issues",
3856
"repository": {

src/dataprocessor/dataprocessor.jsdoc

+10-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,16 @@
99

1010
/**
1111
* The data processor interface. It should be implemented by actual data processors.
12-
* Each data processor implements a certain format of the data. For example, Markdown data processor will convert the data
13-
* (a Markdown string) to a {@link module:engine/view/documentfragment~DocumentFragment document fragment} and back.
12+
*
13+
* Each data processor implements a certain format of the data. For example, {@glink features/markdown Markdown data processor}
14+
* will convert the data (a Markdown string) to a {@link module:engine/view/documentfragment~DocumentFragment document fragment} and back.
15+
*
16+
* **Note:** While the CKEditor 5 architecture supports changing the data format, in most scenarios we do recommend sticking to
17+
* the default format which is HTML (supported by the {@link module:engine/dataprocessor/htmldataprocessor~HtmlDataProcessor}).
18+
* HTML remains [the best standard for rich-text data](https://medium.com/content-uneditable/a-standard-for-rich-text-data-4b3a507af552).
19+
*
20+
* And please do remember – using Markdown [does not automatically make your
21+
* application/website secure](https://github.com/ckeditor/ckeditor5-markdown-gfm/issues/16#issuecomment-375752994).
1422
*
1523
* @interface DataProcessor
1624
*/

src/model/document.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export default class Document {
185185
}
186186

187187
/**
188-
* Creates a new top-level root.
188+
* Creates a new root.
189189
*
190190
* @param {String} [elementName='$root'] The element name. Defaults to `'$root'` which also has some basic schema defined
191191
* (`$block`s are allowed inside the `$root`). Make sure to define a proper schema if you use a different name.
@@ -222,10 +222,10 @@ export default class Document {
222222
}
223223

224224
/**
225-
* Returns the top-level root by its name.
225+
* Returns a root by its name.
226226
*
227227
* @param {String} [name='main'] A unique root name.
228-
* @returns {module:engine/model/rootelement~RootElement|null} The root registered under a given name or null when
228+
* @returns {module:engine/model/rootelement~RootElement|null} The root registered under a given name or `null` when
229229
* there is no root with the given name.
230230
*/
231231
getRoot( name = 'main' ) {

src/model/documentselection.js

+53-34
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import TextProxy from './textproxy';
1818
import toMap from '@ckeditor/ckeditor5-utils/src/tomap';
1919
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
2020
import log from '@ckeditor/ckeditor5-utils/src/log';
21+
import uid from '@ckeditor/ckeditor5-utils/src/uid';
2122

2223
const storePrefix = 'selection:';
2324

@@ -399,31 +400,36 @@ export default class DocumentSelection {
399400
}
400401

401402
/**
402-
* Temporarily changes the gravity of the selection from left to right. The gravity defines from which direction
403-
* the selection inherits its attributes. If it's the default left gravity, the selection (after being moved by
404-
* the user) inherits attributes from its left hand side. This method allows to temporarily override this behavior
405-
* by forcing the gravity to the right.
403+
* Temporarily changes the gravity of the selection from the left to the right.
404+
*
405+
* The gravity defines from which direction the selection inherits its attributes. If it's the default left
406+
* gravity, the selection (after being moved by the the user) inherits attributes from its left hand side.
407+
* This method allows to temporarily override this behavior by forcing the gravity to the right.
408+
*
409+
* It returns an unique identifier which is required to restore the gravity. It guarantees the symmetry
410+
* of the process.
406411
*
407412
* @see module:engine/model/writer~Writer#overrideSelectionGravity
408413
* @protected
409-
* @param {Boolean} [customRestore=false] When `true` then gravity won't be restored until
410-
* {@link ~DocumentSelection#_restoreGravity} will be called directly. When `false` then gravity is restored
411-
* after selection is moved by user.
414+
* @returns {String} The unique id which allows restoring the gravity.
412415
*/
413-
_overrideGravity( customRestore ) {
414-
this._selection.overrideGravity( customRestore );
416+
_overrideGravity() {
417+
return this._selection.overrideGravity();
415418
}
416419

417420
/**
418-
* Restores {@link ~DocumentSelection#_overrideGravity overridden gravity}.
421+
* Restores the {@link ~DocumentSelection#_overrideGravity overridden gravity}.
419422
*
420-
* Note that gravity remains overridden as long as won't be restored the same number of times as was overridden.
423+
* Restoring the gravity is only possible using the unique identifier returned by
424+
* {@link ~DocumentSelection#_overrideGravity}. Note that the gravity remains overridden as long as won't be restored
425+
* the same number of times it was overridden.
421426
*
422427
* @see module:engine/model/writer~Writer#restoreSelectionGravity
423428
* @protected
429+
* @param {String} uid The unique id returned by {@link #_overrideGravity}.
424430
*/
425-
_restoreGravity() {
426-
this._selection.restoreGravity();
431+
_restoreGravity( uid ) {
432+
this._selection.restoreGravity( uid );
427433
}
428434

429435
/**
@@ -530,12 +536,13 @@ class LiveSelection extends Selection {
530536
// @member {Array} module:engine/model/liveselection~LiveSelection#_hasChangedRange
531537
this._hasChangedRange = false;
532538

533-
// Each overriding gravity increase the counter and each restoring decrease it.
534-
// Gravity is overridden when counter is greater than 0. This is to prevent conflicts when
535-
// gravity is overridden by more than one feature at the same time.
539+
// Each overriding gravity adds an UID to the set and each removal removes it.
540+
// Gravity is overridden when there's at least one UID in the set.
541+
// Gravity is restored when the set is empty.
542+
// This is to prevent conflicts when gravity is overridden by more than one feature at the same time.
536543
// @private
537-
// @type {Number}
538-
this._overriddenGravityCounter = 0;
544+
// @type {Set}
545+
this._overriddenGravityRegister = new Set();
539546

540547
// Add events that will ensure selection correctness.
541548
this.on( 'change:range', () => {
@@ -612,7 +619,7 @@ class LiveSelection extends Selection {
612619
// @protected
613620
// @type {Boolean}
614621
get isGravityOverridden() {
615-
return this._overriddenGravityCounter > 0;
622+
return !!this._overriddenGravityRegister.size;
616623
}
617624

618625
// Unbinds all events previously bound by live selection.
@@ -666,28 +673,40 @@ class LiveSelection extends Selection {
666673
}
667674
}
668675

669-
overrideGravity( customRestore ) {
670-
this._overriddenGravityCounter++;
676+
overrideGravity() {
677+
const overrideUid = uid();
671678

672-
if ( this._overriddenGravityCounter == 1 ) {
673-
if ( !customRestore ) {
674-
this.on( 'change:range', ( evt, data ) => {
675-
if ( data.directChange ) {
676-
this.restoreGravity();
677-
evt.off();
678-
}
679-
} );
680-
}
679+
// Remember that another overriding has been requested. It will need to be removed
680+
// before the gravity is to be restored.
681+
this._overriddenGravityRegister.add( overrideUid );
681682

682-
this._updateAttributes();
683+
if ( this._overriddenGravityRegister.size === 1 ) {
684+
this._refreshAttributes();
683685
}
686+
687+
return overrideUid;
684688
}
685689

686-
restoreGravity() {
687-
this._overriddenGravityCounter--;
690+
restoreGravity( uid ) {
691+
if ( !this._overriddenGravityRegister.has( uid ) ) {
692+
/**
693+
* Restoring gravity for an unknown UID is not possible. Make sure you are using a correct
694+
* UID obtained from the {@link module:engine/model/writer~Writer#overrideSelectionGravity} to restore.
695+
*
696+
* @error document-selection-gravity-wrong-restore
697+
* @param {String} uid The unique identifier returned by {@link #overrideGravity}.
698+
*/
699+
throw new CKEditorError(
700+
'document-selection-gravity-wrong-restore: Attempting to restore the selection gravity for an unknown UID.',
701+
{ uid }
702+
);
703+
}
704+
705+
this._overriddenGravityRegister.delete( uid );
688706

707+
// Restore gravity only when all overriding have been restored.
689708
if ( !this.isGravityOverridden ) {
690-
this._updateAttributes();
709+
this._refreshAttributes();
691710
}
692711
}
693712

src/model/writer.js

+12-15
Original file line numberDiff line numberDiff line change
@@ -1112,29 +1112,26 @@ export default class Writer {
11121112
* * Default gravity: selection will have the `bold` and `linkHref` attributes.
11131113
* * Overridden gravity: selection will have `bold` attribute.
11141114
*
1115-
* By default the selection's gravity is automatically restored just after a direct selection change (when user
1116-
* moved the caret) but you can pass `customRestore = true` in which case you will have to call
1117-
* {@link ~Writer#restoreSelectionGravity} manually.
1115+
* **Note**: It returns an unique identifier which is required to restore the gravity. It guarantees the symmetry
1116+
* of the process.
11181117
*
1119-
* When the selection's gravity is overridden more than once without being restored in the meantime then it needs
1120-
* to be restored the same number of times. This is to prevent conflicts when
1121-
* more than one feature want to independently override and restore the selection's gravity.
1122-
*
1123-
* @param {Boolean} [customRestore=false] When `true` then gravity won't be restored until
1124-
* {@link ~Writer#restoreSelectionGravity} will be called directly. When `false` then gravity is restored
1125-
* after selection is moved by user.
1118+
* @returns {String} The unique id which allows restoring the gravity.
11261119
*/
1127-
overrideSelectionGravity( customRestore ) {
1128-
this.model.document.selection._overrideGravity( customRestore );
1120+
overrideSelectionGravity() {
1121+
return this.model.document.selection._overrideGravity();
11291122
}
11301123

11311124
/**
11321125
* Restores {@link ~Writer#overrideSelectionGravity} gravity to default.
11331126
*
1134-
* Note that the gravity remains overridden as long as will not be restored the same number of times as it was overridden.
1127+
* Restoring the gravity is only possible using the unique identifier returned by
1128+
* {@link ~Writer#overrideSelectionGravity}. Note that the gravity remains overridden as long as won't be restored
1129+
* the same number of times it was overridden.
1130+
*
1131+
* @param {String} uid The unique id returned by {@link ~Writer#overrideSelectionGravity}.
11351132
*/
1136-
restoreSelectionGravity() {
1137-
this.model.document.selection._restoreGravity();
1133+
restoreSelectionGravity( uid ) {
1134+
this.model.document.selection._restoreGravity( uid );
11381135
}
11391136

11401137
/**

0 commit comments

Comments
 (0)