-
-
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
Remove Conversion#register() #4467
Comments
So the The Conversion on its own requires that "upcast" and "downcast" groups are defined (used in two-way-converters like const builder= new ConversionBuilder();
builder.addDispatcher( 'downcast', this.data.downcastDispatcher, 'dataDowncast' );
builder.addDispatcher( 'downcast', this.editing.downcastDispatcher, 'editingDowncast' );
builder.addDispatcher( 'upcast', this.data.upcastDispatcher );
// This could check for required 'upcast'/'downcast'
this.conversion = builder.build(); but this too Java-ish probably. Note: in above methods you only define dispatcher once with optional alias (ie for The other thing is we could leave this as is and refactor logic a bit: const conversion = new Conversion();
conversion.addDispatcher( 'downcast', this.data.downcastDispatcher, 'dataDowncast' );
conversion.addDispatcher( 'downcast', this.editing.downcastDispatcher, 'editingDowncast' );
conversion.addDispatcher( 'upcast', this.data.upcastDispatcher ); or even more in line with the requirement for conversion.addDowncastDispatcher( this.data.downcastDispatcher, 'dataDowncast' );
conversion.addDowncastDispatcher( this.editing.downcastDispatcher, 'editingDowncast' );
conversion.addUpcastDispatcher( this.data.upcastDispatcher ); as we require Another solution would be pass everyghint to the constructor: conversion = new Conversion( {
upcast: this.data.upcastDispatcher,
downcast: {
dataDowncast: this.data.downcastDispatcher,
editingDowncast: this.editing.dataDowncast
}
} ); but is also ugly. tl;dr - we cannot just remove const conversion = new Conversion();
conversion.addDowncastDispatcher( this.data.downcastDispatcher, 'dataDowncast' );
conversion.addDowncastDispatcher( this.editing.downcastDispatcher, 'editingDowncast' );
conversion.addUpcastDispatcher( this.data.upcastDispatcher ); |
Well... for me what we have now ( But some more ideas we had together with @jodator: Simple names - values object: this.conversion = new Conversion( {
'downcast': new DowncastHelpers( [ this.editing.downcastDispatcher, this.data.downcastDispatcher ] ),
'editingDowncast': new DowncastHelpers( this.editing.downcastDispatcher ),
'dataDowncast', new DowncastHelpers( this.data.downcastDispatcher ),
'upcast': new UpcastHelpers( this.data.upcastDispatcher )
} ); 2 parameters downcast helpers and then upcast helpers ( this.conversion = new Conversion( {
'downcast': [ this.editing.downcastDispatcher, this.data.downcastDispatcher ],
'editingDowncast': this.editing.downcastDispatcher,
'dataDowncast', this.data.downcastDispatcher
}, {
'upcast': this.data.upcastDispatcher
} );
this.conversion = new Conversion( {
'editingDowncast': this.editing.downcastDispatcher,
'dataDowncast', this.data.downcastDispatcher
}, this.data.upcastDispatcher ); Downcast, upcast, then aliases: this.conversion = new Conversion( [ this.editing.downcastDispatcher, this.data.downcastDispatcher ], this.data.upcastDispatcher, {
'editingDowncast': this.editing.downcastDispatcher,
'dataDowncast', this.data.downcastDispatcher
} );
this.conversion = new Conversion( [ this.editing.downcastDispatcher, this.data.downcastDispatcher ], this.data.upcastDispatcher );
this.conversion.addAlias( 'editingDowncast', this.editing.downcastDispatcher );
this.conversion.addAlias( 'dataDowncast', this.data.downcastDispatcher ); |
And I think that the last proposal ( |
Other: Change `Conversion` class API. Closes #1640. BREAKING CHANGE: The `Conversion#register()` method was removed from the public API. Use constructor parameters to pass dispatchers and `Conversion#addAlias()` to register an alternative conversion group for registered upcast or downcast dispatchers.
Extracted from ckeditor/ckeditor5-engine#1639.
What's the point of
Conversion#register()
iffor()
returns onlyUpcastConversionsHelpers
orDowncastConversionHelpers
(according to its docs)? In fact, I'd love if we could somehow removeregister()
because realistically speaking it can be used together withnew Conversion()
only (just like it currently is). You can't register your own conversion helpers. We could make it possible to pass all helpers directly tonew Conversion()
. It's not critical, but I found it a bit weird and confusing how it's documented right now.The text was updated successfully, but these errors were encountered: