Opened 5 years ago

Last modified 4 years ago

#12524 confirmed New Feature

[Widgets] Support multiple nested editables of the same name

Reported by: Piotrek Koszuliński Owned by:
Priority: Normal Milestone:
Component: UI : Widgets Version: 4.3 Beta
Keywords: Cc:

Description

It would be useful if it was possible to initialise many nested editables using just one name:

editables: {
    label: {
        selector: '.someClass'
    },
},

More details about the current behaviour and reasons: http://ckeditor.com/forums/Support/Editable-fields-in-widget#comment-134623

Workaround - using widget.initEditable with dynamically generated names and selectors.

Change History (3)

comment:1 Changed 5 years ago by Piotrek Koszuliński

Status: newconfirmed

comment:2 Changed 5 years ago by Piotrek Koszuliński

Type: BugNew Feature

comment:3 Changed 4 years ago by Piotrek Koszuliński

Motivated by PR#195 I started thinking how this feature could be now added to the editor.

First thing to notice is that any changes here cannot blow up existing implementations. Therefore, this feature should be opt-in:

editables: {
    label: {
        selector: '.someClass',
        // Enables multiple editables mode.
        multi: true
    },
},

This will make sure that existing implementations are safe.

The next thing is how editables should be stored in widget.editables. I think that the most natural way is that in an array. However, we must remember that we must not break existing implementations. So singular editables should not be wrapped in an array.

Finally, how to find an instance of editable from DOM. I think that the way proposed in PR#195 is ok, so in case of a multi-editable we need additional attribute. I would call it data-cke-editable-index, because proposed "id" conflicts with existing concept of editable names.

These changes mean that we need a new methods and changes in existing ones:

  • new method - widget.getEditable( CKEDITOR.dom.element ) - because the logic got more complicated. This method should be now used everywhere - setFocusedEditable, setupWidgetLifecycleEnd, etc.
  • new method - initMultiEditables() - to not pack too much logic into initEditable(). initMultiEditable() should reuse initEditable(). The decision which method to use should be made in setupEditables().
  • I would do the same with destroyEditable(). Lets add destroyMultiEditable().
Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy