ckeditor4 icon indicating copy to clipboard operation
ckeditor4 copied to clipboard

Initialize multiple widget editables by the same definition

Open jswiderski opened this issue 5 years ago • 1 comments

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:

  1. 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>',
  1. Definitions for editables use general selectors to capture more than one editable as the assumption is that each title and each content editable 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: obraz 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.

jswiderski avatar Jan 09 '20 13:01 jswiderski

any progress on this one?

cimenta avatar Aug 08 '22 12:08 cimenta