mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-09 03:32:00 +09:00
#1087 CK에디터 설정을 /common/js/plugins/ckeditor/ckeditor/config.js 통해 변경할 수 있도록 개선
This commit is contained in:
parent
3658d6ad2a
commit
1592ae6509
2 changed files with 65 additions and 24 deletions
|
|
@ -34,39 +34,46 @@
|
||||||
|
|
||||||
// editor
|
// editor
|
||||||
$(function(){
|
$(function(){
|
||||||
var ckconfig = {
|
var settings = {
|
||||||
height: '{$editor_height}',
|
ckeconfig: {
|
||||||
skin: '{$colorset}',
|
height: '{$editor_height}',
|
||||||
contentsCss: '{$content_style_path}/editor.css',
|
skin: '{$colorset}',
|
||||||
xe_editor_sequence: {$editor_sequence}
|
contentsCss: '{$content_style_path}/editor.css',
|
||||||
|
xe_editor_sequence: {$editor_sequence},
|
||||||
|
toolbarCanCollapse: true
|
||||||
|
},
|
||||||
|
loadXeComponent: true,
|
||||||
|
enableToolbar: true,
|
||||||
|
content_field: jQuery('[name={$editor_content_key_name}]')
|
||||||
};
|
};
|
||||||
<!--@if($enable_component)-->
|
|
||||||
ckconfig.extraPlugins = 'xe_component';
|
|
||||||
|
|
||||||
|
<!--@if($enable_component)-->
|
||||||
{@ $xe_component = array(); }
|
{@ $xe_component = array(); }
|
||||||
<!--@foreach($component_list as $component_name => $component)-->
|
<!--@foreach($component_list as $component_name => $component)-->
|
||||||
{@ $xe_component[] = $component_name . ":'" . htmlentities($component->title, ENT_QUOTES) . "'"; }
|
{@ $xe_component[] = $component_name . ":'" . htmlentities($component->title, ENT_QUOTES) . "'"; }
|
||||||
<!--@endforeach-->
|
<!--@endforeach-->
|
||||||
{@ $xe_component = implode(',', $xe_component); }
|
{@ $xe_component = implode(',', $xe_component); }
|
||||||
|
|
||||||
ckconfig.xe_component_arrays = {{$xe_component}};
|
settings.ckeconfig.xe_component_arrays = {{$xe_component}};
|
||||||
<!--@endif-->
|
<!--@endif-->
|
||||||
|
|
||||||
<!--@if(!$enable_default_component)-->
|
<!--@if(!$enable_default_component)-->
|
||||||
ckconfig.toolbar = [];
|
settings.enableToolbar: false,
|
||||||
ckconfig.toolbarCanCollapse = false;
|
settings.ckeconfig.toolbarCanCollapse = false;
|
||||||
|
<!--@endif-->
|
||||||
|
|
||||||
|
<!--@if(!$enable_component)-->
|
||||||
|
settings.loadXeComponent = false;
|
||||||
<!--@endif-->
|
<!--@endif-->
|
||||||
|
|
||||||
<!--@if($module_type === 'comment')-->
|
<!--@if($module_type === 'comment')-->
|
||||||
ckconfig.toolbarStartupExpanded = false;
|
settings.ckeconfig.toolbarStartupExpanded = false;
|
||||||
<!--@endif-->
|
<!--@endif-->
|
||||||
|
|
||||||
<!--@if($css_content)-->CKEDITOR.addCss('{$css_content}');<!--@end-->
|
<!--@if($css_content)-->CKEDITOR.addCss('{$css_content}');<!--@end-->
|
||||||
|
|
||||||
$('#ckeditor_instance_{$editor_sequence}').XeCkEditor({
|
var ckeApp = $('#ckeditor_instance_{$editor_sequence}').XeCkEditor(settings);
|
||||||
ckeconfig : ckconfig,
|
|
||||||
content_field: jQuery('[name={$editor_content_key_name}]')
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
(function($){
|
(function($){
|
||||||
"use strict";
|
"use strict";
|
||||||
var settings = {
|
var default_ckeconfig = {
|
||||||
bodyClass: 'xe_content editable',
|
bodyClass: 'xe_content editable',
|
||||||
toolbarCanCollapse: true,
|
toolbarCanCollapse: true,
|
||||||
toolbarGroups: [
|
toolbarGroups: [
|
||||||
|
|
@ -21,13 +21,22 @@
|
||||||
],
|
],
|
||||||
allowedContent: true,
|
allowedContent: true,
|
||||||
removePlugins: 'stylescombo,language,bidi,flash,pagebreak',
|
removePlugins: 'stylescombo,language,bidi,flash,pagebreak',
|
||||||
removeButtons: 'Save,Preview,Print,Cut,Copy,Paste'
|
removeButtons: 'Save,Preview,Print,Cut,Copy,Paste',
|
||||||
|
uiColor: '#EFF0F0'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function arrayUnique(data) {
|
||||||
|
return $.grep(data, function(v, k){
|
||||||
|
return (v.length && $.inArray(v, data) === k);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var XeCkEditor = xe.createApp('XeCkEditor', {
|
var XeCkEditor = xe.createApp('XeCkEditor', {
|
||||||
|
ckeconfig: {},
|
||||||
editor_sequence: null,
|
editor_sequence: null,
|
||||||
init : function() {
|
init : function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
CKEDITOR.on('instanceCreated', function(evt){
|
CKEDITOR.on('instanceCreated', function(evt){
|
||||||
self.cast('CKEDITOR_CREATED');
|
self.cast('CKEDITOR_CREATED');
|
||||||
});
|
});
|
||||||
|
|
@ -44,8 +53,6 @@
|
||||||
self.cast('CKEDITOR_LOADED');
|
self.cast('CKEDITOR_LOADED');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
API_ONREADY : function() {
|
|
||||||
},
|
|
||||||
editorInit : function(containerEl, opts) {
|
editorInit : function(containerEl, opts) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var $containerEl = containerEl;
|
var $containerEl = containerEl;
|
||||||
|
|
@ -53,14 +60,41 @@
|
||||||
var $contentField = opts.content_field;
|
var $contentField = opts.content_field;
|
||||||
var data = $containerEl.data();
|
var data = $containerEl.data();
|
||||||
var editor_sequence = $containerEl.data().editorSequence;
|
var editor_sequence = $containerEl.data().editorSequence;
|
||||||
var ckeconfig = $.extend({}, settings, opts.ckeconfig || {});
|
|
||||||
|
this.ckeconfig = $.extend({}, default_ckeconfig, opts.ckeconfig || {});
|
||||||
|
|
||||||
this.editor_sequence = data.editorSequence;
|
this.editor_sequence = data.editorSequence;
|
||||||
|
|
||||||
$form.attr('editor_sequence', data.editorSequence);
|
$form.attr('editor_sequence', data.editorSequence);
|
||||||
|
|
||||||
var insance = CKEDITOR.appendTo($containerEl[0], ckeconfig, $contentField.val());
|
var instance = CKEDITOR.appendTo($containerEl[0], {}, $contentField.val());
|
||||||
$containerEl.data('cke_instance', insance);
|
|
||||||
|
instance.on('customConfigLoaded', function(e) {
|
||||||
|
instance.config = $.extend({}, e.editor.config, self.ckeconfig);
|
||||||
|
|
||||||
|
if($.isFunction(CKEDITOR.editorConfig)) {
|
||||||
|
var customConfig = {};
|
||||||
|
CKEDITOR.editorConfig(customConfig);
|
||||||
|
|
||||||
|
$.each(customConfig, function(key, val) {
|
||||||
|
instance.config[key] = val;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var bodyClass = e.editor.config.bodyClass.split(' ');
|
||||||
|
bodyClass.push(default_ckeconfig.bodyClass);
|
||||||
|
bodyClass = arrayUnique(bodyClass);
|
||||||
|
instance.config.bodyClass = bodyClass.join(' ');
|
||||||
|
|
||||||
|
if(opts.loadXeComponent) {
|
||||||
|
var extraPlugins = e.editor.config.extraPlugins.split(',');
|
||||||
|
|
||||||
|
extraPlugins.push('xe_component');
|
||||||
|
extraPlugins = arrayUnique(extraPlugins);
|
||||||
|
instance.config.extraPlugins = extraPlugins.join(',');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$containerEl.data('cke_instance', instance);
|
||||||
|
|
||||||
window.editorRelKeys[data.editorSequence] = {};
|
window.editorRelKeys[data.editorSequence] = {};
|
||||||
window.editorRelKeys[data.editorSequence].primary = $form.find('[name='+data.editorPrimaryKeyName+']')[0];
|
window.editorRelKeys[data.editorSequence].primary = $form.find('[name='+data.editorPrimaryKeyName+']')[0];
|
||||||
|
|
@ -69,7 +103,7 @@
|
||||||
return self.getContent.call(self, seq);
|
return self.getContent.call(self, seq);
|
||||||
};
|
};
|
||||||
window.editorRelKeys[data.editorSequence].pasteHTML = function(text){
|
window.editorRelKeys[data.editorSequence].pasteHTML = function(text){
|
||||||
insance.insertHtml(text, 'html');
|
instance.insertHtml(text, 'html');
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
getContent : function(seq) {
|
getContent : function(seq) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue