Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#10358 Introducing a downcast helper elementToStructure with reconversion support #10466

Merged
merged 38 commits into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a7a0dfd
The elementToStructure downcast helper PoC extracted from other PoC b…
niegowski Aug 4, 2021
73af915
The elementToElement with a backward compatible reconversion support.
niegowski Aug 6, 2021
dbe5571
Simplified slot conversion.
niegowski Aug 6, 2021
0ad44b9
Reconversion could be triggered by some ancestor change.
niegowski Aug 9, 2021
490c302
Table downcast by reconversion.
niegowski Aug 9, 2021
280d2c5
Updated reconversion trigger conditions for table paragraph.
niegowski Aug 10, 2021
d0f0bd0
Removed support for legacy reconversion and simplified code for reins…
niegowski Aug 10, 2021
e8ab9b7
Cleaned DowncastDispatcher API.
niegowski Aug 12, 2021
cf242d5
Code cleanup.
niegowski Aug 12, 2021
daae0cf
Update html embed downcast conversion.
niegowski Aug 12, 2021
5bf5ad3
Merge branch 'master' into ck/10294-elementToStructure
niegowski Aug 12, 2021
34f06b3
Fixed marker double conversion.
niegowski Aug 12, 2021
4d90152
Code cleaning. Added JSDocs.
niegowski Aug 17, 2021
89d803a
Merge branch 'master' into ck/10294-elementToStructure
niegowski Aug 18, 2021
fa34826
Adding code comments.
niegowski Aug 19, 2021
614e1af
Adding JSDocs.
niegowski Aug 23, 2021
aa36632
Merge branch 'master' into ck/10294-elementToStructure
niegowski Aug 24, 2021
5a95106
Added docs.
niegowski Aug 31, 2021
01afbce
Merge branch 'master' into ck/10294-elementToStructure
niegowski Aug 31, 2021
29ac32b
API cleaning.
niegowski Aug 31, 2021
ba694cb
Removed some PoC changes.
niegowski Aug 31, 2021
b0d0b2d
Code cleaning. Added tests for DowncastDispatcher.
niegowski Aug 31, 2021
1a7e155
Ported tests for legacy "triggerBy" to test for elementToStructure.
niegowski Aug 31, 2021
bbc9e79
Added tests.
niegowski Sep 1, 2021
2e0f997
Added tests.
niegowski Sep 1, 2021
6c18937
Merge branch 'master' into ck/10358-elementToStructure
niegowski Sep 1, 2021
0053bd0
Reverted changes.
niegowski Sep 6, 2021
50bc5e5
Tuned slot conversion manual test.
niegowski Sep 6, 2021
edcdaa8
Fixed tests.
niegowski Sep 6, 2021
82f0176
Code cleanup.
niegowski Sep 7, 2021
818a93a
Code cleanup.
niegowski Sep 7, 2021
1f2df2b
Only items that need conversion should be added to ModelConsumable.
niegowski Sep 8, 2021
d6dfe5a
Merge branch 'master' into ck/10358-elementToStructure
Reinmar Sep 8, 2021
9563fb2
Fix the schema definition.
Reinmar Sep 8, 2021
f72e900
Improved errors documentation.
Reinmar Sep 8, 2021
ab03609
Wording.
Reinmar Sep 8, 2021
dadf715
Added tests for deferred unbinding.
niegowski Sep 8, 2021
6cc2c0c
Improved the docs.
Reinmar Sep 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 7 additions & 18 deletions packages/ckeditor5-engine/src/controller/datacontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,27 +241,16 @@ export default class DataController {

this.mapper.bindElements( modelElementOrFragment, viewDocumentFragment );

// Make additional options available during conversion process through `conversionApi`.
this.downcastDispatcher.conversionApi.options = options;

// We have no view controller and rendering to DOM in DataController so view.change() block is not used here.
this.downcastDispatcher.convertInsert( modelRange, viewWriter );

// Convert markers.
// Prepare list of markers.
// For document fragment, simply take the markers assigned to this document fragment.
// For model root, all markers in that root will be taken.
// For model element, we need to check which markers are intersecting with this element and relatively modify the markers' ranges.
// Collapsed markers at element boundary, although considered as not intersecting with the element, will also be returned.
const markers = modelElementOrFragment.is( 'documentFragment' ) ?
Array.from( modelElementOrFragment.markers ) :
modelElementOrFragment.markers :
_getMarkersRelativeToElement( modelElementOrFragment );

for ( const [ name, range ] of markers ) {
this.downcastDispatcher.convertMarkerAdd( name, range, viewWriter );
}

// Clean `conversionApi`.
delete this.downcastDispatcher.conversionApi.options;
this.downcastDispatcher.convert( modelRange, markers, viewWriter, options );

return viewDocumentFragment;
}
Expand Down Expand Up @@ -533,11 +522,11 @@ mix( DataController, ObservableMixin );
// at element boundary, it is considered as contained inside the element and marker range is returned. Otherwise, if the marker is
// intersecting with the element, the intersection is returned.
function _getMarkersRelativeToElement( element ) {
const result = [];
const result = new Map();
const doc = element.root.document;

if ( !doc ) {
return [];
return result;
}

const elementRange = ModelRange._createIn( element );
Expand All @@ -549,12 +538,12 @@ function _getMarkersRelativeToElement( element ) {
const isMarkerAtElementBoundary = markerRange.start.isEqual( elementRange.start ) || markerRange.end.isEqual( elementRange.end );

if ( isMarkerCollapsed && isMarkerAtElementBoundary ) {
result.push( [ marker.name, markerRange ] );
result.set( marker.name, markerRange );
} else {
const updatedMarkerRange = elementRange.getIntersection( markerRange );

if ( updatedMarkerRange ) {
result.push( [ marker.name, updatedMarkerRange ] );
result.set( marker.name, updatedMarkerRange );
}
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/ckeditor5-engine/src/conversion/conversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export default class Conversion {
* * downcast (model-to-view) conversion helpers:
*
* * {@link module:engine/conversion/downcasthelpers~DowncastHelpers#elementToElement `elementToElement()`},
* * {@link module:engine/conversion/downcasthelpers~DowncastHelpers#elementToStructure `elementToStructure()`},
* * {@link module:engine/conversion/downcasthelpers~DowncastHelpers#attributeToElement `attributeToElement()`},
* * {@link module:engine/conversion/downcasthelpers~DowncastHelpers#attributeToAttribute `attributeToAttribute()`}.
* * {@link module:engine/conversion/downcasthelpers~DowncastHelpers#markerToElement `markerToElement()`}.
Expand Down
Loading