-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
API to get dialog's subject of change / model #2423
Comments
Let's start the discussion first to understand what's the best direction here. I came up with this proposition while reviewing #2277 - as we need an information whether the dialog is editing something or adding. |
I'm wondering if we need a function returning model. Could't be just However, we already have a request for putting a widget into dialog events (#1044) so it looks like this feature may not be redundant. It may play nice with #2277 where the new feature will be enabled if plugin or widget is adapted to it, ie. implements Can we assume that model existence is synonymous with |
The function for returning the model is needed anyway so it make sense to add it. What's more is that if you implement |
I'm wondering if we could also enable definition name with this feature. It seems like the name is hidden under dialog internals, but editor.on( 'dialogHide', function( evt ) {
var dialog = evt.data;
// Plugin name hidden under private object,
// we could make it accessible from `dialog.name`
if ( dialog._.name === 'link' ) {
var link = dialog.getModel();
link.data( 'tracking-id', generateTrackingId( link.getAttribute( 'href' ) );
}
} ); Similar feature request was already asked here: #2669 |
Are you reporting a feature request or a bug?
Feature request
Provide detailed reproduction steps (if any)
Currently there's no common way to access a subject of change for a dialog, instead each dialog implements this in a custom way.
Having this unified would allow us to add a method like
dialog.isEditing()
that tells whether a new entity is currently created or an existing one is created. We often need this kind of information.Note that since the dialogs are static,
isEditing
method would need to accepteditor
instance as an argument.Proposal
Add a new interface that might be implemented in dialogDefinition, let's call it
ModeledDialog
.It features a single method:
getModel( editor ) : [Object/null]
table
/link
it would simply return aCKEDITOR.dom.element
if there's a related element to it. For widget plugins (image2
,placeholder
) it would return widget instance that is a subject of this dialog.null
if there's no related model (about
,help
dialogs).If the dialog does not implement
getModel()
it is assumed to be always in editing mode (backward compatible).Compatibility
Compatibility is a priority here. In case we have some workarounds in published plugins, like:
CKEDITOR.dialog.definition.uiElement#setup()
method.The text was updated successfully, but these errors were encountered: