-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Expose all conversion utilities #4428
Comments
Maybe?
|
Or just:
|
Note that this is because we still do not close https://github.com/ckeditor/ckeditor5-engine/issues/1306. |
I'm actually unsure now about hiding them :D With time, I got the feeling that most questions about conversion are questions about some odd cases. Like, extending existing converters, overriding some things, etc. I can't tell from my experience which of the functions we need, but if these helpers are used in our converters, there's a high chance that they can help in people's scenarios. |
It's not exactly this that, that we have helpers and then use them in converters. It is more like: we have converters and then part of these converters is exported besides these converters as the whole. It is not like |
I do not mean that these parts of converters will be useless, but they might be very hard to document them in a clear way. I think that you can more-less easily explain what converters and writer are, but it will be hard to tell how to use this "helpers" properly (btw we used to call them converters in the past). It was easier before the previous refactoring, but then we introduce one more level (called "converters" today). |
Hm, ok. I'll use your list from https://github.com/ckeditor/ckeditor5-engine/issues/1306#issuecomment-378870980. The public ones will be available via |
👍 You can also skip |
Hm... there's a problem with the naming. Look at the code I wrote in https://github.com/ckeditor/ckeditor5-table/issues/122#issuecomment-424100223. After the API change I'd write this: editor.conversion.upcast.attributeToAttribute( {
// ..
} ); And this wouldn't work as well ;| The inconsistency in this looks very bad: // You need to use for().add()...
editor.conversion.for( 'upcast' ).add(
editor.conversion.upcast.attributeToAttribute( {
// ...
} )
);
// But this time you don't...
editor.conversion.elementToElement( {
// ...
} ); Do you have any ideas how we could straighten this up? |
One thing would be to be careful in the documentation and always use editor.conversion.upcast.getAttributeToAttributeConverter()
// or...
editor.conversion.upcast.createAttributeToAttributeConverter() Which indicatest that this is a getter/factory. But this way we'll make the names awfully long so it'd be good to find a better option. The second problem I have is that |
One thing I'm sure is that we shouldn't mix those converter factories (which require to be used in Another thing that I didn't like in the code samples I show above is the length of them. This looks sad: editor.conversion.for( 'upcast' ).add(
editor.conversion.upcast.attributeToAttribute( {
// ...
} )
); What if... editor.conversion.for( 'upcast' ).attributeToAttribute( {
// ...
} ); This way:
|
What with I like the editor.conversion.for( 'upcast' ).add(
editor.conversion.upcast.attributeToAttribute( {
// ... too much and confusing :/
} )
); as it is consistent with So then we should also expose them: editor.conversion.downcast.elementToElement()
editor.conversion.downcast.data.elementToElement()
editor.conversion.downcast.editing.elementToElement()
// or
editor.conversion.downcast.elementToElement()
editor.conversion.dataDowncast.elementToElement()
editor.conversion.editingDowncast.elementToElement() |
All below proposition will take the simples custom converter for image - using 'dataDowncast' pipeline: import {
downcastElementToElement
} from '@ckeditor/ckeditor5-engine/src/conversion/downcast-converters';
editor.conversion.for( 'dataDowncast' ).add( downcastElementToElement( {
model: 'image',
view: ( modelElement, viewWriter ) => createImageViewElement( viewWriter )
} ) ); I: initial proposition (updated)// ver I a.
editor.conversion.for( 'dataDowncast' )
.add( editor.conversion.createDowncastElementToElement( {
model: 'image',
view: ( modelElement, viewWriter ) => createImageViewElement( viewWriter )
} ) );
// ver I b.
editor.conversion.for( 'dataDowncast' )
.add( editor.conversion.downcast.createElementToElement( {
model: 'image',
view: ( modelElement, viewWriter ) => createImageViewElement( viewWriter )
} ) ); Comments:
II: (PK's proposal) expose all converters in
|
I am for PKs proposal. Three things.
|
After F2F talks @pjasiun & @scofalik we agreed on PKs proposal with defining which helpers goes for which pipeline. Also due to fact of increased numbers of parameters the this.conversion.register( {
name: 'downcast',
dispatchers: [ this.editing.downcastDispatcher, this.data.downcastDispatcher ],
helpers: DowncastHelpers
} ); There will be two objects (interfaces) which will group proper helpers ( The chaining is not required. |
Agree with @jodator and @scofalik (and PK) that proposal II, with registering helpers for each pipeline, looks the best. I would go with: this.conversion.register( {
name: 'upcast',
dispatcher: this.data.upcastDispatcher, //acepts also array dispatcher: [ this.editing.downcastDispatcher, this.data.downcastDispatcher ]
helpers: UpcastHelpers // or upcastHelpers
); Then this.conversion.for( 'upcast' ).elementToElement |
🏆 first |
By the way it will be nice that you will be able to do:
And each of these will execute the proper method. |
Enhancement: Expose conversion utilities. Closes #1556. BREAKING CHANGE: The conversion.register() method now accepts single options object as a parameter. BREAKING CHANGE: The downcastElementToElement() helper was removed from public API. Use conversion.for( 'downcast' ).elementToElement() instead. BREAKING CHANGE: The downcastAttributeToElement() helper was removed from public API. Use conversion.for( 'downcast' ).attributeToElement() instead. BREAKING CHANGE: The downcastAttributeToAttribute() helper was removed from public API. Use conversion.for( 'downcast' ).attributeToAttribute() instead. BREAKING CHANGE: The downcastMarkerToElement() helper was removed from public API. Use conversion.for( 'downcast' ).markerToElement() instead. BREAKING CHANGE: The downcastMarkerToHighlight() helper was removed from public API. Use conversion.for( 'downcast' ).markerToHighlight() instead. BREAKING CHANGE: The upcastElementToElement() helper was removed from public API. Use conversion.for( 'upcast' ).elementToElement() instead. BREAKING CHANGE: The upcastElementToAttribute() helper was removed from public API. Use conversion.for( 'upcast' ).elementToAttribute() instead. BREAKING CHANGE: The upcastAttributeToAttribute() helper was removed from public API. Use conversion.for( 'upcast' ).attributeToAttribute() instead. BREAKING CHANGE: The upcastElementToMarker() helper was removed from public API. Use conversion.for( 'upcast' ).elementToMarker() instead. BREAKING CHANGE: The insertUIElement() and removeUIElement() downcast converters were removed from public API. Use conversion.for( 'downcast' ).markerToElement() instead. BREAKING CHANGE: The highlightText(), highlightElement() and removeHighlight() downcast converters were removed from public API. Use conversion.for( 'downcast' ).markerToHighlight() instead. BREAKING CHANGE: The insertElement() downcast converter was removed from public API. Use conversion.for( 'downcast' ).elementToElement() instead. BREAKING CHANGE: The changeAttribute() downcast converter was removed from public API. Use conversion.for( 'downcast' ).attributeToAttribute() instead.
A sibling ticket of https://github.com/ckeditor/ckeditor5-engine/issues/1555.
We exposed half of conversion utilities as
editor.conversion
's methods. What we miss are the methods from:downcast-converters
upcast-converters
Some of those functions are needed quite frequently which we experienced when answering to various questions. I think that in most questions about conversion we needed some of these lower-level functions rather than those big factories we already have exposed.
I can see that there are quite a lot of
downcast-converters
but I'd expose all of them anyway, without a research which of them are used and how often (half of them are used in quite advanced cases with markers, but we'll want to make markers more popular anyway).I'd expose this functions as e.g.:
The text was updated successfully, but these errors were encountered: