mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 03:01:43 +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
|
||||
$(function(){
|
||||
var ckconfig = {
|
||||
height: '{$editor_height}',
|
||||
skin: '{$colorset}',
|
||||
contentsCss: '{$content_style_path}/editor.css',
|
||||
xe_editor_sequence: {$editor_sequence}
|
||||
var settings = {
|
||||
ckeconfig: {
|
||||
height: '{$editor_height}',
|
||||
skin: '{$colorset}',
|
||||
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(); }
|
||||
<!--@foreach($component_list as $component_name => $component)-->
|
||||
{@ $xe_component[] = $component_name . ":'" . htmlentities($component->title, ENT_QUOTES) . "'"; }
|
||||
<!--@endforeach-->
|
||||
{@ $xe_component = implode(',', $xe_component); }
|
||||
|
||||
ckconfig.xe_component_arrays = {{$xe_component}};
|
||||
settings.ckeconfig.xe_component_arrays = {{$xe_component}};
|
||||
<!--@endif-->
|
||||
|
||||
<!--@if(!$enable_default_component)-->
|
||||
ckconfig.toolbar = [];
|
||||
ckconfig.toolbarCanCollapse = false;
|
||||
settings.enableToolbar: false,
|
||||
settings.ckeconfig.toolbarCanCollapse = false;
|
||||
<!--@endif-->
|
||||
|
||||
<!--@if(!$enable_component)-->
|
||||
settings.loadXeComponent = false;
|
||||
<!--@endif-->
|
||||
|
||||
<!--@if($module_type === 'comment')-->
|
||||
ckconfig.toolbarStartupExpanded = false;
|
||||
settings.ckeconfig.toolbarStartupExpanded = false;
|
||||
<!--@endif-->
|
||||
|
||||
<!--@if($css_content)-->CKEDITOR.addCss('{$css_content}');<!--@end-->
|
||||
|
||||
$('#ckeditor_instance_{$editor_sequence}').XeCkEditor({
|
||||
ckeconfig : ckconfig,
|
||||
content_field: jQuery('[name={$editor_content_key_name}]')
|
||||
});
|
||||
var ckeApp = $('#ckeditor_instance_{$editor_sequence}').XeCkEditor(settings);
|
||||
|
||||
});
|
||||
})(jQuery);
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
(function($){
|
||||
"use strict";
|
||||
var settings = {
|
||||
var default_ckeconfig = {
|
||||
bodyClass: 'xe_content editable',
|
||||
toolbarCanCollapse: true,
|
||||
toolbarGroups: [
|
||||
|
|
@ -21,13 +21,22 @@
|
|||
],
|
||||
allowedContent: true,
|
||||
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', {
|
||||
ckeconfig: {},
|
||||
editor_sequence: null,
|
||||
init : function() {
|
||||
var self = this;
|
||||
|
||||
CKEDITOR.on('instanceCreated', function(evt){
|
||||
self.cast('CKEDITOR_CREATED');
|
||||
});
|
||||
|
|
@ -44,8 +53,6 @@
|
|||
self.cast('CKEDITOR_LOADED');
|
||||
});
|
||||
},
|
||||
API_ONREADY : function() {
|
||||
},
|
||||
editorInit : function(containerEl, opts) {
|
||||
var self = this;
|
||||
var $containerEl = containerEl;
|
||||
|
|
@ -53,14 +60,41 @@
|
|||
var $contentField = opts.content_field;
|
||||
var data = $containerEl.data();
|
||||
var editor_sequence = $containerEl.data().editorSequence;
|
||||
var ckeconfig = $.extend({}, settings, opts.ckeconfig || {});
|
||||
|
||||
this.ckeconfig = $.extend({}, default_ckeconfig, opts.ckeconfig || {});
|
||||
|
||||
this.editor_sequence = data.editorSequence;
|
||||
|
||||
$form.attr('editor_sequence', data.editorSequence);
|
||||
|
||||
var insance = CKEDITOR.appendTo($containerEl[0], ckeconfig, $contentField.val());
|
||||
$containerEl.data('cke_instance', insance);
|
||||
var instance = CKEDITOR.appendTo($containerEl[0], {}, $contentField.val());
|
||||
|
||||
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].primary = $form.find('[name='+data.editorPrimaryKeyName+']')[0];
|
||||
|
|
@ -69,7 +103,7 @@
|
|||
return self.getContent.call(self, seq);
|
||||
};
|
||||
window.editorRelKeys[data.editorSequence].pasteHTML = function(text){
|
||||
insance.insertHtml(text, 'html');
|
||||
instance.insertHtml(text, 'html');
|
||||
};
|
||||
},
|
||||
getContent : function(seq) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue