-
Notifications
You must be signed in to change notification settings - Fork 40
Introduced UpcastConversionApi#getSplitParts #1704
Conversation
…onverting from any view element if `config.view` is not passed.
I've also added integration tests for the issue: ckeditor/ckeditor5-block-quote#34. I wasn't sure where really to put them though :S. I hope this place is fine with you. |
src/conversion/upcastdispatcher.js
Outdated
* @param {module:engine/model/element~Element} original The original element. | ||
* @param {module:engine/model/element~Element} split The split part element. | ||
*/ | ||
_registerSplitPair( original, split ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_registerSplitPair( original, split ) { | |
_registerSplitPair( original, copy ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a huge fan of split
name but I think it is better than copy
. This is not a copy of that element, they are both split parts. If not split
, I'd go with originalPart
+ newPart
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or originalPart
and splitPart
.
src/conversion/upcastdispatcher.js
Outdated
* | ||
* @private | ||
* @param {module:engine/model/element~Element} original The original element. | ||
* @param {module:engine/model/element~Element} split The split part element. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param {module:engine/model/element~Element} split The split part element. | |
* @param {module:engine/model/element~Element} copy The copy of the original element which was created as the result of split. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
src/conversion/upcastdispatcher.js
Outdated
} else { | ||
// There should not be any text nodes after the element is split, so the only other value is `elementStart`. | ||
const originalElement = stack.pop(); | ||
const splitElement = treeWalkerValue.item; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure about the make splitElement
. I think copyElement
is much better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
partElement
, partialElement
or splitPartElement
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above, I can agree for originalPart
and splitPart
or newPart
.
src/conversion/upcastdispatcher.js
Outdated
parts = this._splitParts.get( element ); | ||
} | ||
|
||
parts.last = parts[ parts.length - 1 ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I am not sure if we should do it. We do not do it for any other array, even considering that in many cases it could be useful. If we will do it now, we may do it more often and end up in the situation where half of arrays has property last
and the other half do not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was your idea :P But, yeah, I am not sure about it either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!Array.prototype.last) { Object.defineProperty...
😈 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested merge commit message (convention)
Feature: Introduced
UpcastConversionApi#getSplitParts
. Also, provided a way to set upcast conversion helper fired for every view element. Closes ckeditor/ckeditor5#1580. Closes ckeditor/ckeditor5#1581.Additional information
I added a possibility to specify conversion from any view element to model element by not setting
view
property in upcast helper configuration:Will convert any non-converted element to a
paragraph
model element.