mirror of
https://github.com/processwire/processwire.git
synced 2025-08-14 18:55:56 +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 $editor = $('#' + editorID);
|
||||||
var $parent = $editor.parent();
|
var $parent = $editor.parent();
|
||||||
|
|
||||||
|
|
||||||
if(typeof ProcessWire.config.InputfieldCKEditor.editors[editorID] != "undefined") {
|
if(typeof ProcessWire.config.InputfieldCKEditor.editors[editorID] != "undefined") {
|
||||||
var configName = ProcessWire.config.InputfieldCKEditor.editors[editorID];
|
var configName = ProcessWire.config.InputfieldCKEditor.editors[editorID];
|
||||||
} else {
|
} else {
|
||||||
@@ -283,10 +284,21 @@ function ckeInitNormal(editorID) {
|
|||||||
$parent.closest('.ui-tabs, .langTabs').on('tabsactivate', ckeInitTab);
|
$parent.closest('.ui-tabs, .langTabs').on('tabsactivate', ckeInitTab);
|
||||||
} else {
|
} else {
|
||||||
// visible CKEditor
|
// visible CKEditor
|
||||||
|
var editor;
|
||||||
|
if(typeof ProcessWire.config[configName] != "undefined") {
|
||||||
var editor = CKEDITOR.replace(editorID, ProcessWire.config[configName]);
|
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);
|
ckeInitEvents(editor);
|
||||||
$editor.addClass('InputfieldCKEditorLoaded');
|
$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>";
|
//$out = parent::___render() . "<script>CKEDITOR.replace('$this->id', config.$this->configName);</script>";
|
||||||
$this->addClass('InputfieldCKEditorNormal');
|
$this->addClass('InputfieldCKEditorNormal');
|
||||||
$this->attr('data-configName', $this->configName);
|
$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;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user