ckeditor4
ckeditor4 copied to clipboard
Initialize multiple widget editables by the same definition
Type of report
Feature request
Provide description of the new feature
ZIP: simplebox4.zip
The attached plugin is a modified version of a simplebox widget from our tutorial. The key differences are as follows:
- Widget uses multiple editing areas:
template:
'<div class="simplebox">' +
'<h2 class="simplebox-title-1">Title</h2>' +
'<div class="simplebox-content-1"><p>Content...</p></div>' +
'<h2 class="simplebox-title-2">Title</h2>' +
'<div class="simplebox-content-2"><p>Content...</p></div>' +
'</div>',
- Definitions for
editablesuse general selectors to capture more than one editable as the assumption is that eachtitleand eachcontenteditable will allow same set of tags:
editables: {
title: {
selector: '[class*=simplebox-title]',
allowedContent: 'br strong em'
},
content: {
selector: '[class*=simplebox-content]',
allowedContent: 'p br ul ol li strong em'
}
}
The problem:
Definition name works as a unique id to which only the first matching element is being assigned. As a result when we load our double-simple box into editor, only the first editable for title and content will work. Second ones don't become nested editables:
Current approach can be tedious for complex widgets which use many similar/same edibles e.g. accordion.
Posible Solution: We could introduce below structure and make editor know that whenever it meets something like that, it needs to find all matching elements and generate unique nested editable definition for each of those elements (names could be e.g. title-randomNumber or title-nextInSequence):
editables: {
title: {
selector: '[class*=simplebox-title]',
isMultiple: true,
allowedContent: 'br strong em'
}
}
Why should the editor generate definitions with unique names? So that only the match/find mechanism could be changed while everything else is compatible with how widgets work at the moment.
any progress on this one?