mirror of
https://github.com/processwire/processwire.git
synced 2025-08-14 10:45:54 +02:00
Add option for InputfieldCKEditor JS to support option for configuration via data attribute, useful for some dynamic insertion cases like in repeaters
This commit is contained in:
@@ -269,6 +269,7 @@ function ckeInitNormal(editorID) {
|
||||
var $editor = $('#' + editorID);
|
||||
var $parent = $editor.parent();
|
||||
|
||||
|
||||
if(typeof ProcessWire.config.InputfieldCKEditor.editors[editorID] != "undefined") {
|
||||
var configName = ProcessWire.config.InputfieldCKEditor.editors[editorID];
|
||||
} else {
|
||||
@@ -283,9 +284,20 @@ function ckeInitNormal(editorID) {
|
||||
$parent.closest('.ui-tabs, .langTabs').on('tabsactivate', ckeInitTab);
|
||||
} else {
|
||||
// visible CKEditor
|
||||
var editor = CKEDITOR.replace(editorID, ProcessWire.config[configName]);
|
||||
ckeInitEvents(editor);
|
||||
$editor.addClass('InputfieldCKEditorLoaded');
|
||||
var editor;
|
||||
if(typeof ProcessWire.config[configName] != "undefined") {
|
||||
var editor = CKEDITOR.replace(editorID, ProcessWire.config[configName]);
|
||||
} else if(typeof $editor.attr('data-configdata') != "undefined") {
|
||||
// allow for alternate option of config data being passed through a data attribute
|
||||
// useful for some dynamic/ajax situations
|
||||
var configData = JSON.parse($editor.attr('data-configdata'));
|
||||
ProcessWire.config[configName] = configData;
|
||||
var editor = CKEDITOR.replace(editorID, configData);
|
||||
}
|
||||
if(editor) {
|
||||
ckeInitEvents(editor);
|
||||
$editor.addClass('InputfieldCKEditorLoaded');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@@ -514,7 +514,11 @@ class InputfieldCKEditor extends InputfieldTextarea {
|
||||
//$out = parent::___render() . "<script>CKEDITOR.replace('$this->id', config.$this->configName);</script>";
|
||||
$this->addClass('InputfieldCKEditorNormal');
|
||||
$this->attr('data-configName', $this->configName);
|
||||
$out = parent::___render() . "<script>config.InputfieldCKEditor.editors.$this->id = '$this->configName';</script>";
|
||||
$out = parent::___render() .
|
||||
"<script>" .
|
||||
"ProcessWire.config.InputfieldCKEditor.editors.$this->id = '$this->configName';" .
|
||||
"config.InputfieldCKEditor.editors.$this->id = '$this->configName';" .
|
||||
"</script>";
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user