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 t/ckeditor5/1684
Browse files Browse the repository at this point in the history
  • Loading branch information
jodator committed Aug 5, 2019
2 parents 89a5c88 + c057a94 commit b772835
Show file tree
Hide file tree
Showing 110 changed files with 1,461 additions and 953 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
Changelog
=========

## [13.2.1](https://github.com/ckeditor/ckeditor5-engine/compare/v13.2.0...v13.2.1) (2019-07-10)

Internal changes only (updated dependencies, documentation, etc.).


## [13.2.0](https://github.com/ckeditor/ckeditor5-engine/compare/v13.1.1...v13.2.0) (2019-07-04)

### Features

* Added `view.Document#event:beforeinput`. ([c74c3d6](https://github.com/ckeditor/ckeditor5-engine/commit/c74c3d6))
* Introduced the `type` parameter to the `model.createBatch()` method. ([389b72e](https://github.com/ckeditor/ckeditor5-engine/commit/389b72e))

### Bug fixes

* `model.Writer#insert()` will no longer crash when the data to set contains markers that are already in the editor content. Closes [#1721](https://github.com/ckeditor/ckeditor5-engine/issues/1721). ([4ff0656](https://github.com/ckeditor/ckeditor5-engine/commit/4ff0656))
* Selection will not change during forbidden copy-paste operation inside table cell. Closes [ckeditor/ckeditor5#1380](https://github.com/ckeditor/ckeditor5/issues/1380). ([ab15b17](https://github.com/ckeditor/ckeditor5-engine/commit/ab15b17))

### Other changes

* Changed how ` `s are generated on the view->DOM rendering. Closes [#1747](https://github.com/ckeditor/ckeditor5-engine/issues/1747). ([da5670a](https://github.com/ckeditor/ckeditor5-engine/commit/da5670a))


## [13.1.1](https://github.com/ckeditor/ckeditor5-engine/compare/v13.1.0...v13.1.1) (2019-06-05)

### Bug fixes
Expand Down
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ckeditor/ckeditor5-engine",
"version": "13.1.1",
"version": "13.2.1",
"description": "The editing engine of CKEditor 5 – the best browser-based rich text editor.",
"keywords": [
"wysiwyg",
Expand All @@ -21,26 +21,26 @@
"ckeditor 5"
],
"dependencies": {
"@ckeditor/ckeditor5-utils": "^12.1.1",
"@ckeditor/ckeditor5-utils": "^13.0.1",
"lodash-es": "^4.17.10"
},
"devDependencies": {
"@ckeditor/ckeditor5-basic-styles": "^11.1.1",
"@ckeditor/ckeditor5-block-quote": "^11.1.0",
"@ckeditor/ckeditor5-core": "^12.1.1",
"@ckeditor/ckeditor5-editor-classic": "^12.1.1",
"@ckeditor/ckeditor5-enter": "^11.0.2",
"@ckeditor/ckeditor5-essentials": "^11.0.2",
"@ckeditor/ckeditor5-heading": "^11.0.2",
"@ckeditor/ckeditor5-link": "^11.0.2",
"@ckeditor/ckeditor5-list": "^12.0.2",
"@ckeditor/ckeditor5-paragraph": "^11.0.2",
"@ckeditor/ckeditor5-theme-lark": "^14.0.0",
"@ckeditor/ckeditor5-typing": "^12.0.2",
"@ckeditor/ckeditor5-undo": "^11.0.2",
"@ckeditor/ckeditor5-widget": "^11.0.2",
"@ckeditor/ckeditor5-basic-styles": "^11.1.3",
"@ckeditor/ckeditor5-block-quote": "^11.1.2",
"@ckeditor/ckeditor5-core": "^12.2.1",
"@ckeditor/ckeditor5-editor-classic": "^12.1.3",
"@ckeditor/ckeditor5-enter": "^11.0.4",
"@ckeditor/ckeditor5-essentials": "^11.0.4",
"@ckeditor/ckeditor5-heading": "^11.0.4",
"@ckeditor/ckeditor5-link": "^11.1.1",
"@ckeditor/ckeditor5-list": "^12.0.4",
"@ckeditor/ckeditor5-paragraph": "^11.0.4",
"@ckeditor/ckeditor5-theme-lark": "^14.1.1",
"@ckeditor/ckeditor5-typing": "^12.1.1",
"@ckeditor/ckeditor5-undo": "^11.0.4",
"@ckeditor/ckeditor5-widget": "^11.0.4",
"eslint": "^5.5.0",
"eslint-config-ckeditor5": "^1.0.11",
"eslint-config-ckeditor5": "^2.0.0",
"husky": "^1.3.1",
"lint-staged": "^7.0.0"
},
Expand Down
8 changes: 4 additions & 4 deletions src/controller/datacontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export default class DataController {
*
* @error datacontroller-get-non-existent-root
*/
throw new CKEditorError( 'datacontroller-get-non-existent-root: Attempting to get data from a non-existing root.' );
throw new CKEditorError( 'datacontroller-get-non-existent-root: Attempting to get data from a non-existing root.', this );
}

const root = this.model.document.getRoot( rootName );
Expand Down Expand Up @@ -240,7 +240,7 @@ export default class DataController {
*
* @error datacontroller-init-document-not-empty
*/
throw new CKEditorError( 'datacontroller-init-document-not-empty: Trying to set initial data to not empty document.' );
throw new CKEditorError( 'datacontroller-init-document-not-empty: Trying to set initial data to not empty document.', this );
}

let initialData = {};
Expand All @@ -262,7 +262,7 @@ export default class DataController {
*
* @error datacontroller-init-non-existent-root
*/
throw new CKEditorError( 'datacontroller-init-non-existent-root: Attempting to init data on a non-existing root.' );
throw new CKEditorError( 'datacontroller-init-non-existent-root: Attempting to init data on a non-existing root.', this );
}

this.model.enqueueChange( 'transparent', writer => {
Expand Down Expand Up @@ -316,7 +316,7 @@ export default class DataController {
*
* @error datacontroller-set-non-existent-root
*/
throw new CKEditorError( 'datacontroller-set-non-existent-root: Attempting to set data on a non-existing root.' );
throw new CKEditorError( 'datacontroller-set-non-existent-root: Attempting to set data on a non-existing root.', this );
}

this.model.enqueueChange( 'transparent', writer => {
Expand Down
11 changes: 7 additions & 4 deletions src/conversion/conversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,11 @@ export default class Conversion {
*
* @error conversion-add-alias-dispatcher-not-registered
*/
throw new CKEditorError( 'conversion-add-alias-dispatcher-not-registered: ' +
'Trying to register and alias for a dispatcher that nas not been registered.' );
throw new CKEditorError(
'conversion-add-alias-dispatcher-not-registered: ' +
'Trying to register and alias for a dispatcher that nas not been registered.',
this
);
}

this._createConversionHelpers( { name: alias, dispatchers: [ dispatcher ], isDowncast } );
Expand Down Expand Up @@ -180,7 +183,7 @@ export default class Conversion {
*
* @error conversion-for-unknown-group
*/
throw new CKEditorError( 'conversion-for-unknown-group: Trying to add a converter to an unknown dispatchers group.' );
throw new CKEditorError( 'conversion-for-unknown-group: Trying to add a converter to an unknown dispatchers group.', this );
}

return this._helpers.get( groupName );
Expand Down Expand Up @@ -585,7 +588,7 @@ export default class Conversion {
*
* @error conversion-group-exists
*/
throw new CKEditorError( 'conversion-group-exists: Trying to register a group name that has already been registered.' );
throw new CKEditorError( 'conversion-group-exists: Trying to register a group name that has already been registered.', this );
}

const helpers = isDowncast ? new DowncastHelpers( dispatchers ) : new UpcastHelpers( dispatchers );
Expand Down
30 changes: 15 additions & 15 deletions src/conversion/downcasthelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

/**
* Contains downcast (model-to-view) converters for {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher}.
*
* @module engine/conversion/downcasthelpers
*/

import ModelRange from '../model/range';
import ModelSelection from '../model/selection';
import ModelElement from '../model/element';
Expand All @@ -11,14 +17,8 @@ import ViewAttributeElement from '../view/attributeelement';
import DocumentSelection from '../model/documentselection';
import ConversionHelpers from './conversionhelpers';

import log from '@ckeditor/ckeditor5-utils/src/log';
import { cloneDeep } from 'lodash-es';

/**
* Contains downcast (model-to-view) converters for {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher}.
*
* @module engine/conversion/downcasthelpers
*/
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';

/**
* Downcast conversion helper functions.
Expand Down Expand Up @@ -730,9 +730,8 @@ function removeUIElement() {
return;
}

conversionApi.mapper.unbindElementsFromMarkerName( data.markerName );

for ( const element of elements ) {
conversionApi.mapper.unbindElementFromMarkerName( element, data.markerName );
conversionApi.writer.clear( conversionApi.writer.createRangeOn( element ), element );
}

Expand Down Expand Up @@ -824,10 +823,11 @@ function changeAttribute( attributeCreator ) {
*
* @error conversion-attribute-to-attribute-on-text
*/
log.warn( 'conversion-attribute-to-attribute-on-text: ' +
'Trying to convert text node\'s attribute with attribute-to-attribute converter.' );

return;
throw new CKEditorError(
'conversion-attribute-to-attribute-on-text: ' +
'Trying to convert text node\'s attribute with attribute-to-attribute converter.',
[ data, conversionApi ]
);
}

// First remove the old attribute if there was one.
Expand Down Expand Up @@ -1030,9 +1030,9 @@ function removeHighlight( highlightDescriptor ) {
return;
}

conversionApi.mapper.unbindElementsFromMarkerName( data.markerName );

for ( const element of elements ) {
conversionApi.mapper.unbindElementFromMarkerName( element, data.markerName );

if ( element.is( 'attributeElement' ) ) {
conversionApi.writer.unwrap( conversionApi.writer.createRangeOn( element ), viewHighlightElement );
} else {
Expand Down
15 changes: 12 additions & 3 deletions src/conversion/mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,21 @@ export default class Mapper {
}

/**
* Unbinds all elements from given marker name.
* Unbinds an element from given marker name.
*
* @param {module:engine/view/element~Element} element Element to unbind.
* @param {String} name Marker name.
*/
unbindElementsFromMarkerName( name ) {
this._markerNameToElements.delete( name );
unbindElementFromMarkerName( element, name ) {
const elements = this._markerNameToElements.get( name );

if ( elements ) {
elements.delete( element );

if ( elements.size == 0 ) {
this._markerNameToElements.delete( name );
}
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/conversion/upcastdispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export default class UpcastDispatcher {
*
* @error view-conversion-dispatcher-incorrect-result
*/
throw new CKEditorError( 'view-conversion-dispatcher-incorrect-result: Incorrect conversion result was dropped.' );
throw new CKEditorError( 'view-conversion-dispatcher-incorrect-result: Incorrect conversion result was dropped.', this );
}

return { modelRange: data.modelRange, modelCursor: data.modelCursor };
Expand Down
2 changes: 1 addition & 1 deletion src/conversion/viewconsumable.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ class ViewElementConsumables {
*
* @error viewconsumable-invalid-attribute
*/
throw new CKEditorError( 'viewconsumable-invalid-attribute: Classes and styles should be handled separately.' );
throw new CKEditorError( 'viewconsumable-invalid-attribute: Classes and styles should be handled separately.', this );
}

consumables.set( name, true );
Expand Down
44 changes: 39 additions & 5 deletions src/model/differ.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,32 @@ export default class Differ {
return this._changesInElement.size == 0 && this._changedMarkers.size == 0;
}

/**
* Marks given `item` in differ to be "refreshed". It means that the item will be marked as removed and inserted in the differ changes
* set, so it will be effectively re-converted when differ changes will be handled by a dispatcher.
*
* @param {module:engine/model/item~Item} item Item to refresh.
*/
refreshItem( item ) {
if ( this._isInInsertedElement( item.parent ) ) {
return;
}

this._markRemove( item.parent, item.startOffset, item.offsetSize );
this._markInsert( item.parent, item.startOffset, item.offsetSize );

const range = Range._createOn( item );

for ( const marker of this._markerCollection.getMarkersIntersectingRange( range ) ) {
const markerRange = marker.getRange();

this.bufferMarkerChange( marker.name, markerRange, markerRange, marker.affectsData );
}

// Clear cache after each buffered operation as it is no longer valid.
this._cachedChanges = null;
}

/**
* Buffers the given operation. An operation has to be buffered before it is executed.
*
Expand All @@ -136,7 +162,7 @@ export default class Differ {
case 'addAttribute':
case 'removeAttribute':
case 'changeAttribute': {
for ( const item of operation.range.getItems() ) {
for ( const item of operation.range.getItems( { shallow: true } ) ) {
if ( this._isInInsertedElement( item.parent ) ) {
continue;
}
Expand Down Expand Up @@ -1086,19 +1112,25 @@ function _generateActionsFromChanges( oldChildrenLength, changes ) {
for ( const change of changes ) {
// First, fill "holes" between changes with "equal" actions.
if ( change.offset > offset ) {
actions.push( ...'e'.repeat( change.offset - offset ).split( '' ) );
for ( let i = 0; i < change.offset - offset; i++ ) {
actions.push( 'e' );
}

oldChildrenHandled += change.offset - offset;
}

// Then, fill up actions accordingly to change type.
if ( change.type == 'insert' ) {
actions.push( ...'i'.repeat( change.howMany ).split( '' ) );
for ( let i = 0; i < change.howMany; i++ ) {
actions.push( 'i' );
}

// The last handled offset is after inserted range.
offset = change.offset + change.howMany;
} else if ( change.type == 'remove' ) {
actions.push( ...'r'.repeat( change.howMany ).split( '' ) );
for ( let i = 0; i < change.howMany; i++ ) {
actions.push( 'r' );
}

// The last handled offset is at the position where the nodes were removed.
offset = change.offset;
Expand All @@ -1117,7 +1149,9 @@ function _generateActionsFromChanges( oldChildrenLength, changes ) {
// Fill "equal" actions at the end of actions set. Use `oldChildrenHandled` to see how many children
// has not been changed / removed at the end of their parent.
if ( oldChildrenHandled < oldChildrenLength ) {
actions.push( ...'e'.repeat( oldChildrenLength - oldChildrenHandled ).split( '' ) );
for ( let i = 0; i < oldChildrenLength - oldChildrenHandled - offset; i++ ) {
actions.push( 'e' );
}
}

return actions;
Expand Down
2 changes: 2 additions & 0 deletions src/model/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export default class Document {
*/
throw new CKEditorError(
'model-document-applyOperation-wrong-version: Only operations with matching versions can be applied.',
this,
{ operation }
);
}
Expand Down Expand Up @@ -201,6 +202,7 @@ export default class Document {
*/
throw new CKEditorError(
'model-document-createRoot-name-exists: Root with specified name already exists.',
this,
{ name: rootName }
);
}
Expand Down
10 changes: 3 additions & 7 deletions src/model/documentselection.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import TextProxy from './textproxy';
import toMap from '@ckeditor/ckeditor5-utils/src/tomap';
import Collection from '@ckeditor/ckeditor5-utils/src/collection';
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 @@ -639,6 +638,7 @@ class LiveSelection extends Selection {
*/
throw new CKEditorError(
'document-selection-wrong-position: Range from document selection starts or ends at incorrect position.',
this,
{ range }
);
}
Expand Down Expand Up @@ -767,6 +767,7 @@ class LiveSelection extends Selection {
*/
throw new CKEditorError(
'document-selection-gravity-wrong-restore: Attempting to restore the selection gravity for an unknown UID.',
this,
{ uid }
);
}
Expand Down Expand Up @@ -802,12 +803,7 @@ class LiveSelection extends Selection {
this._checkRange( range );

if ( range.root == this._document.graveyard ) {
/**
* Trying to add a Range that is in the graveyard root. Range rejected.
*
* @warning model-selection-range-in-graveyard
*/
log.warn( 'model-selection-range-in-graveyard: Trying to add a Range that is in the graveyard root. Range rejected.' );
// @if CK_DEBUG // console.warn( 'Trying to add a Range that is in the graveyard root. Range rejected.' );

return;
}
Expand Down
Loading

0 comments on commit b772835

Please sign in to comment.