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

Commit

Permalink
Merge branch 'master' into origin_t/898
Browse files Browse the repository at this point in the history
  • Loading branch information
f1ames committed May 8, 2018
2 parents bfeabff + 86521df commit 6dfe173
Show file tree
Hide file tree
Showing 20 changed files with 1,526 additions and 412 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
Changelog
=========

## [10.0.0](https://github.com/ckeditor/ckeditor5-engine/compare/v1.0.0-beta.4...v10.0.0) (2018-04-25)

### Other changes

* 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))

### BREAKING CHANGES

* 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.


## [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)

### Bug fixes

* `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))
* `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))
* 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))


## [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)

### Features
Expand Down
14 changes: 1 addition & 13 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,13 @@ Software License Agreement
**CKEditor 5 Editing Engine**https://github.com/ckeditor/ckeditor5-engine <br>
Copyright (c) 2003-2018, [CKSource](http://cksource.com) Frederico Knabben. All rights reserved.

Licensed under the terms of any of the following licenses at your choice:

* [GNU General Public License Version 2 or later (the "GPL")](http://www.gnu.org/licenses/gpl.html)
* [GNU Lesser General Public License Version 2.1 or later (the "LGPL")](http://www.gnu.org/licenses/lgpl.html)
* [Mozilla Public License Version 1.1 or later (the "MPL")](http://www.mozilla.org/MPL/MPL-1.1.html)

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.
Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).

Sources of Intellectual Property Included in CKEditor
-----------------------------------------------------

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.

Third parties' software included:

* Lo-Dash (src/lib/lodash) <br>
Copyright 2012-2015 [The Dojo Foundation](http://dojofoundation.org/) <br>
Available under [MIT license](http://lodash.com/license)

Trademarks
----------

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ See the [`@ckeditor/ckeditor5-engine` package](https://docs.ckeditor.com/ckedito

## License

Licensed under the GPL, LGPL and MPL licenses, at your choice. For full details about the license, please check the `LICENSE.md` file.
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.
50 changes: 34 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,45 @@
{
"name": "@ckeditor/ckeditor5-engine",
"version": "1.0.0-beta.2",
"version": "10.0.0",
"description": "CKEditor 5 editing engine.",
"keywords": [
"ckeditor5-lib",
"CKEditor",
"ckeditor5",
"ckeditor5-lib"
"ckeditor 5",
"WYSIWYG",
"WYSIWYM",
"text",
"rich-text",
"richtext",
"editor",
"html",
"contentEditable",
"editing",
"operational transformation",
"ot",
"collaboration",
"collaborative",
"real-time",
"virtual dom",
"framework"
],
"dependencies": {
"@ckeditor/ckeditor5-utils": "^1.0.0-beta.2"
"@ckeditor/ckeditor5-utils": "^10.0.0"
},
"devDependencies": {
"@ckeditor/ckeditor5-basic-styles": "^1.0.0-beta.2",
"@ckeditor/ckeditor5-core": "^1.0.0-beta.2",
"@ckeditor/ckeditor5-editor-classic": "^1.0.0-beta.2",
"@ckeditor/ckeditor5-enter": "^1.0.0-beta.2",
"@ckeditor/ckeditor5-essentials": "^1.0.0-beta.2",
"@ckeditor/ckeditor5-heading": "^1.0.0-beta.2",
"@ckeditor/ckeditor5-list": "^1.0.0-beta.2",
"@ckeditor/ckeditor5-paragraph": "^1.0.0-beta.2",
"@ckeditor/ckeditor5-typing": "^1.0.0-beta.2",
"@ckeditor/ckeditor5-undo": "^1.0.0-beta.2",
"@ckeditor/ckeditor5-widget": "^1.0.0-beta.2",
"@ckeditor/ckeditor5-link": "^1.0.0-beta.2",
"@ckeditor/ckeditor5-basic-styles": "^10.0.0",
"@ckeditor/ckeditor5-core": "^10.0.0",
"@ckeditor/ckeditor5-editor-classic": "^10.0.0",
"@ckeditor/ckeditor5-enter": "^10.0.0",
"@ckeditor/ckeditor5-essentials": "^10.0.0",
"@ckeditor/ckeditor5-heading": "^10.0.0",
"@ckeditor/ckeditor5-list": "^10.0.0",
"@ckeditor/ckeditor5-paragraph": "^10.0.0",
"@ckeditor/ckeditor5-typing": "^10.0.0",
"@ckeditor/ckeditor5-undo": "^10.0.0",
"@ckeditor/ckeditor5-widget": "^10.0.0",
"@ckeditor/ckeditor5-link": "^10.0.0",
"eslint": "^4.15.0",
"eslint-config-ckeditor5": "^1.0.7",
"husky": "^0.14.3",
Expand All @@ -32,7 +50,7 @@
"npm": ">=3.0.0"
},
"author": "CKSource (http://cksource.com/)",
"license": "(GPL-2.0 OR LGPL-2.1 OR MPL-1.1)",
"license": "GPL-2.0-or-later",
"homepage": "https://ckeditor.com",
"bugs": "https://github.com/ckeditor/ckeditor5-engine/issues",
"repository": {
Expand Down
12 changes: 10 additions & 2 deletions src/dataprocessor/dataprocessor.jsdoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@

/**
* The data processor interface. It should be implemented by actual data processors.
* Each data processor implements a certain format of the data. For example, Markdown data processor will convert the data
* (a Markdown string) to a {@link module:engine/view/documentfragment~DocumentFragment document fragment} and back.
*
* Each data processor implements a certain format of the data. For example, {@glink features/markdown Markdown data processor}
* will convert the data (a Markdown string) to a {@link module:engine/view/documentfragment~DocumentFragment document fragment} and back.
*
* **Note:** While the CKEditor 5 architecture supports changing the data format, in most scenarios we do recommend sticking to
* the default format which is HTML (supported by the {@link module:engine/dataprocessor/htmldataprocessor~HtmlDataProcessor}).
* HTML remains [the best standard for rich-text data](https://medium.com/content-uneditable/a-standard-for-rich-text-data-4b3a507af552).
*
* And please do remember – using Markdown [does not automatically make your
* application/website secure](https://github.com/ckeditor/ckeditor5-markdown-gfm/issues/16#issuecomment-375752994).
*
* @interface DataProcessor
*/
Expand Down
6 changes: 3 additions & 3 deletions src/model/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export default class Document {
}

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

/**
* Returns the top-level root by its name.
* Returns a root by its name.
*
* @param {String} [name='main'] A unique root name.
* @returns {module:engine/model/rootelement~RootElement|null} The root registered under a given name or null when
* @returns {module:engine/model/rootelement~RootElement|null} The root registered under a given name or `null` when
* there is no root with the given name.
*/
getRoot( name = 'main' ) {
Expand Down
87 changes: 53 additions & 34 deletions src/model/documentselection.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import TextProxy from './textproxy';
import toMap from '@ckeditor/ckeditor5-utils/src/tomap';
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
import log from '@ckeditor/ckeditor5-utils/src/log';
import uid from '@ckeditor/ckeditor5-utils/src/uid';

const storePrefix = 'selection:';

Expand Down Expand Up @@ -399,31 +400,36 @@ export default class DocumentSelection {
}

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

/**
* Restores {@link ~DocumentSelection#_overrideGravity overridden gravity}.
* Restores the {@link ~DocumentSelection#_overrideGravity overridden gravity}.
*
* Note that gravity remains overridden as long as won't be restored the same number of times as was overridden.
* Restoring the gravity is only possible using the unique identifier returned by
* {@link ~DocumentSelection#_overrideGravity}. Note that the gravity remains overridden as long as won't be restored
* the same number of times it was overridden.
*
* @see module:engine/model/writer~Writer#restoreSelectionGravity
* @protected
* @param {String} uid The unique id returned by {@link #_overrideGravity}.
*/
_restoreGravity() {
this._selection.restoreGravity();
_restoreGravity( uid ) {
this._selection.restoreGravity( uid );
}

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

// Each overriding gravity increase the counter and each restoring decrease it.
// Gravity is overridden when counter is greater than 0. This is to prevent conflicts when
// gravity is overridden by more than one feature at the same time.
// Each overriding gravity adds an UID to the set and each removal removes it.
// Gravity is overridden when there's at least one UID in the set.
// Gravity is restored when the set is empty.
// This is to prevent conflicts when gravity is overridden by more than one feature at the same time.
// @private
// @type {Number}
this._overriddenGravityCounter = 0;
// @type {Set}
this._overriddenGravityRegister = new Set();

// Add events that will ensure selection correctness.
this.on( 'change:range', () => {
Expand Down Expand Up @@ -612,7 +619,7 @@ class LiveSelection extends Selection {
// @protected
// @type {Boolean}
get isGravityOverridden() {
return this._overriddenGravityCounter > 0;
return !!this._overriddenGravityRegister.size;
}

// Unbinds all events previously bound by live selection.
Expand Down Expand Up @@ -666,28 +673,40 @@ class LiveSelection extends Selection {
}
}

overrideGravity( customRestore ) {
this._overriddenGravityCounter++;
overrideGravity() {
const overrideUid = uid();

if ( this._overriddenGravityCounter == 1 ) {
if ( !customRestore ) {
this.on( 'change:range', ( evt, data ) => {
if ( data.directChange ) {
this.restoreGravity();
evt.off();
}
} );
}
// Remember that another overriding has been requested. It will need to be removed
// before the gravity is to be restored.
this._overriddenGravityRegister.add( overrideUid );

this._updateAttributes();
if ( this._overriddenGravityRegister.size === 1 ) {
this._refreshAttributes();
}

return overrideUid;
}

restoreGravity() {
this._overriddenGravityCounter--;
restoreGravity( uid ) {
if ( !this._overriddenGravityRegister.has( uid ) ) {
/**
* Restoring gravity for an unknown UID is not possible. Make sure you are using a correct
* UID obtained from the {@link module:engine/model/writer~Writer#overrideSelectionGravity} to restore.
*
* @error document-selection-gravity-wrong-restore
* @param {String} uid The unique identifier returned by {@link #overrideGravity}.
*/
throw new CKEditorError(
'document-selection-gravity-wrong-restore: Attempting to restore the selection gravity for an unknown UID.',
{ uid }
);
}

this._overriddenGravityRegister.delete( uid );

// Restore gravity only when all overriding have been restored.
if ( !this.isGravityOverridden ) {
this._updateAttributes();
this._refreshAttributes();
}
}

Expand Down
27 changes: 12 additions & 15 deletions src/model/writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1112,29 +1112,26 @@ export default class Writer {
* * Default gravity: selection will have the `bold` and `linkHref` attributes.
* * Overridden gravity: selection will have `bold` attribute.
*
* By default the selection's gravity is automatically restored just after a direct selection change (when user
* moved the caret) but you can pass `customRestore = true` in which case you will have to call
* {@link ~Writer#restoreSelectionGravity} manually.
* **Note**: It returns an unique identifier which is required to restore the gravity. It guarantees the symmetry
* of the process.
*
* When the selection's gravity is overridden more than once without being restored in the meantime then it needs
* to be restored the same number of times. This is to prevent conflicts when
* more than one feature want to independently override and restore the selection's gravity.
*
* @param {Boolean} [customRestore=false] When `true` then gravity won't be restored until
* {@link ~Writer#restoreSelectionGravity} will be called directly. When `false` then gravity is restored
* after selection is moved by user.
* @returns {String} The unique id which allows restoring the gravity.
*/
overrideSelectionGravity( customRestore ) {
this.model.document.selection._overrideGravity( customRestore );
overrideSelectionGravity() {
return this.model.document.selection._overrideGravity();
}

/**
* Restores {@link ~Writer#overrideSelectionGravity} gravity to default.
*
* Note that the gravity remains overridden as long as will not be restored the same number of times as it was overridden.
* Restoring the gravity is only possible using the unique identifier returned by
* {@link ~Writer#overrideSelectionGravity}. Note that the gravity remains overridden as long as won't be restored
* the same number of times it was overridden.
*
* @param {String} uid The unique id returned by {@link ~Writer#overrideSelectionGravity}.
*/
restoreSelectionGravity() {
this.model.document.selection._restoreGravity();
restoreSelectionGravity( uid ) {
this.model.document.selection._restoreGravity( uid );
}

/**
Expand Down
Loading

0 comments on commit 6dfe173

Please sign in to comment.