mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-10 04:24:14 +09:00
#1087 ckeditor 정리
- xeEditor plugin 제거 및 app로 변경 - ckeditor config를 app 파일로 이동 - 툴바 접기 설정이 잘못 반영된 문제 수정
This commit is contained in:
parent
a6c15ffb0e
commit
e1c6be4bf3
7 changed files with 109 additions and 119 deletions
Binary file not shown.
|
Before Width: | Height: | Size: 3.5 KiB |
|
|
@ -1,2 +1 @@
|
||||||
ckeditor/ckeditor.js
|
ckeditor/ckeditor.js
|
||||||
xeEditor.plugin.js
|
|
||||||
|
|
|
||||||
|
|
@ -1,76 +0,0 @@
|
||||||
(function($){
|
|
||||||
"use strict";
|
|
||||||
var App = window.xe.getApp('xeEditorApp')[0];
|
|
||||||
var CK = window.CKEDITOR;
|
|
||||||
|
|
||||||
var xeCKEditor = App.createPlugin("CKEditor", {
|
|
||||||
instance_prefix : 'ckeditor_instance_',
|
|
||||||
|
|
||||||
init : function() {
|
|
||||||
var self = this;
|
|
||||||
CKEDITOR.on('instanceCreated', function(evt){
|
|
||||||
self.cast('CKEDITOR_CREATED');
|
|
||||||
});
|
|
||||||
|
|
||||||
CKEDITOR.on('ready', function(evt){
|
|
||||||
self.cast('CKEDITOR_READY');
|
|
||||||
});
|
|
||||||
|
|
||||||
CKEDITOR.on('instanceReady', function(evt){
|
|
||||||
self.cast('CKEDITOR_INSTANCE_READY');
|
|
||||||
});
|
|
||||||
|
|
||||||
CKEDITOR.on('instanceLoaded', function(evt){
|
|
||||||
self.cast('CKEDITOR_LOADED');
|
|
||||||
});
|
|
||||||
},
|
|
||||||
editorInit : function(sequence, obj) {
|
|
||||||
var self = this;
|
|
||||||
var $editor_area = jQuery("#ckeditor_instance_"+sequence);
|
|
||||||
var $form = $editor_area.closest('form');
|
|
||||||
var $contentField = $('input[name=' + obj.content_key + ']');
|
|
||||||
var ckconfig = obj.ckconfig || {};
|
|
||||||
ckconfig.xe_editor_sequence = sequence;
|
|
||||||
|
|
||||||
$form.attr('editor_sequence', sequence);
|
|
||||||
|
|
||||||
var insance = CKEDITOR.appendTo(this.instance_prefix + sequence, ckconfig, obj.content);
|
|
||||||
$editor_area.data('cke_instance', insance);
|
|
||||||
|
|
||||||
insance.on('change', function(e){
|
|
||||||
if($contentField.length){
|
|
||||||
$contentField.val(e.editor.getData());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.sequence = sequence;
|
|
||||||
window.editorRelKeys[sequence] = {};
|
|
||||||
window.editorRelKeys[sequence].primary = $form.find('[name='+obj.primary_key+']')[0];
|
|
||||||
window.editorRelKeys[sequence].content = $form.find('[name='+obj.content_key+']')[0];
|
|
||||||
window.editorRelKeys[sequence].func = function(seq) {
|
|
||||||
return self.getContent.call(self, seq);
|
|
||||||
};
|
|
||||||
window.editorRelKeys[sequence].pasteHTML = function(text){
|
|
||||||
insance.insertHtml(text, 'html');
|
|
||||||
};
|
|
||||||
},
|
|
||||||
getContent : function(seq) {
|
|
||||||
var self = this;
|
|
||||||
var content = _getCkeInstance(seq).getData();
|
|
||||||
self.cast('GET_CONTENT', [content]);
|
|
||||||
|
|
||||||
return content;
|
|
||||||
},
|
|
||||||
API_ONREADY : function() {
|
|
||||||
},
|
|
||||||
API_GET_CONTENT: function() {
|
|
||||||
},
|
|
||||||
getInstance : function(name) {
|
|
||||||
return CKEDITOR.instances[name];
|
|
||||||
},
|
|
||||||
autosave: function(seq) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
App.registerPlugin(new xeCKEditor());
|
|
||||||
})(jQuery);
|
|
||||||
|
|
@ -208,6 +208,7 @@ class editorModel extends editor
|
||||||
if(!$colorset) $colorset = 'moono';
|
if(!$colorset) $colorset = 'moono';
|
||||||
Context::set('colorset', $colorset);
|
Context::set('colorset', $colorset);
|
||||||
Context::set('skin', $skin);
|
Context::set('skin', $skin);
|
||||||
|
Context::set('module_type', $option->module_type);
|
||||||
|
|
||||||
if($skin=='dreditor')
|
if($skin=='dreditor')
|
||||||
{
|
{
|
||||||
|
|
@ -332,6 +333,7 @@ class editorModel extends editor
|
||||||
$editor_config = $this->getEditorConfig($module_srl);
|
$editor_config = $this->getEditorConfig($module_srl);
|
||||||
|
|
||||||
$config = new stdClass();
|
$config = new stdClass();
|
||||||
|
$config->module_type = $type;
|
||||||
|
|
||||||
// Configurations listed according to a type
|
// Configurations listed according to a type
|
||||||
if($type == 'document')
|
if($type == 'document')
|
||||||
|
|
@ -374,6 +376,7 @@ class editorModel extends editor
|
||||||
}
|
}
|
||||||
// Pre-set option variables of editor
|
// Pre-set option variables of editor
|
||||||
$option = new stdClass();
|
$option = new stdClass();
|
||||||
|
$option->module_type = $config->module_type;
|
||||||
$option->skin = $config->editor_skin;
|
$option->skin = $config->editor_skin;
|
||||||
$option->content_style = $config->content_style;
|
$option->content_style = $config->content_style;
|
||||||
$option->content_font = $config->content_font;
|
$option->content_font = $config->content_font;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
.cke_button__xe_component_label {
|
||||||
|
display: inline !important;
|
||||||
|
}
|
||||||
|
.cke_button__xe_component_icon {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
{@ $css_content .= chr(125);}
|
{@ $css_content .= chr(125);}
|
||||||
<!--@endif-->
|
<!--@endif-->
|
||||||
|
|
||||||
<div id="ckeditor_instance_{$editor_sequence}"></div>
|
<div id="ckeditor_instance_{$editor_sequence}" data-editor-sequence="{$editor_sequence}" data-editor-primary-key-name="{$editor_primary_key_name}" data-editor-content-key-name="{$editor_content_key_name}" style="min-height:{$editor_height}px;"></div>
|
||||||
|
|
||||||
<!--%load_js_plugin("jquery.fileupload")-->
|
<!--%load_js_plugin("jquery.fileupload")-->
|
||||||
<div cond="$allow_fileupload" id="xe-uploader-container-{$editor_sequence}" class="xe-uploader-container clearfix" data-editor-sequence="{$editor_sequence}">
|
<div cond="$allow_fileupload" id="xe-uploader-container-{$editor_sequence}" class="xe-uploader-container clearfix" data-editor-sequence="{$editor_sequence}">
|
||||||
|
|
@ -58,37 +58,14 @@
|
||||||
<script>
|
<script>
|
||||||
(function($){
|
(function($){
|
||||||
"use strict";
|
"use strict";
|
||||||
var editor_primary_key_name = '{$editor_primary_key_name}';
|
|
||||||
var editor_content_key_name = '{$editor_content_key_name}';
|
|
||||||
|
|
||||||
// editor
|
// editor
|
||||||
$(function(){
|
$(function(){
|
||||||
var pl = xe.getApp('xeEditorApp')[0].getPlugin('ckeditor')[0];
|
|
||||||
var editor_id = 'ckeditor_instance_{$editor_sequence}';
|
|
||||||
|
|
||||||
var ckconfig = {
|
var ckconfig = {
|
||||||
height: '{$editor_height}',
|
height: '{$editor_height}',
|
||||||
bodyClass: 'xe_content editable',
|
|
||||||
toolbarCanCollapse: true,
|
|
||||||
toolbarGroups: [
|
|
||||||
{ name: 'clipboard', groups: [ 'undo', 'clipboard' ] },
|
|
||||||
{ name: 'editing', groups: [ 'find', 'selection' ] },
|
|
||||||
{ name: 'insert' },
|
|
||||||
{ name: 'tools' },
|
|
||||||
{ name: 'document', groups: [ 'mode' ] },
|
|
||||||
'/',
|
|
||||||
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
|
|
||||||
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },
|
|
||||||
{ name: 'links' },
|
|
||||||
{ name: 'styles' },
|
|
||||||
{ name: 'colors' },
|
|
||||||
{ name: 'others' }
|
|
||||||
],
|
|
||||||
skin: '{$colorset}',
|
skin: '{$colorset}',
|
||||||
allowedContent: true,
|
|
||||||
contentsCss: '{$content_style_path}/editor.css',
|
contentsCss: '{$content_style_path}/editor.css',
|
||||||
removePlugins: 'stylescombo,language',
|
xe_editor_sequence: {$editor_sequence}
|
||||||
removeButtons: 'Save,Preview,Print,Cut,Copy,Paste'
|
|
||||||
};
|
};
|
||||||
<!--@if($enable_component)-->
|
<!--@if($enable_component)-->
|
||||||
ckconfig.extraPlugins = 'xe_component';
|
ckconfig.extraPlugins = 'xe_component';
|
||||||
|
|
@ -104,19 +81,19 @@
|
||||||
|
|
||||||
<!--@if(!$enable_default_component)-->
|
<!--@if(!$enable_default_component)-->
|
||||||
ckconfig.toolbar = [];
|
ckconfig.toolbar = [];
|
||||||
ckconfig.toolbarCanCollapse = true;
|
ckconfig.toolbarCanCollapse = false;
|
||||||
|
<!--@endif-->
|
||||||
|
|
||||||
|
<!--@if($module_type === 'comment')-->
|
||||||
|
ckconfig.toolbarStartupExpanded = false;
|
||||||
<!--@endif-->
|
<!--@endif-->
|
||||||
|
|
||||||
<!--@if($css_content)-->CKEDITOR.addCss('{$css_content}');<!--@end-->
|
<!--@if($css_content)-->CKEDITOR.addCss('{$css_content}');<!--@end-->
|
||||||
|
|
||||||
pl.editorInit("{$editor_sequence}", {
|
$('#ckeditor_instance_{$editor_sequence}').XeCkEditor({
|
||||||
'ckconfig' : ckconfig,
|
ckeconfig : ckconfig,
|
||||||
'content': jQuery('[name='+editor_content_key_name+']').val(),
|
content_field: jQuery('[name={$editor_content_key_name}]')
|
||||||
'primary_key': editor_primary_key_name,
|
|
||||||
'content_key': editor_content_key_name
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var INS = pl.getInstance('{$editor_sequence}');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// uploader
|
// uploader
|
||||||
|
|
@ -131,6 +108,7 @@
|
||||||
<!--@endif-->
|
<!--@endif-->
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.clearfix:before, .clearfix:after {
|
.clearfix:before, .clearfix:after {
|
||||||
content: "";
|
content: "";
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,112 @@
|
||||||
(function($){
|
(function($){
|
||||||
"use strict";
|
"use strict";
|
||||||
var XeEditorApp = xe.createApp('xeEditorApp', {
|
var settings = {
|
||||||
|
bodyClass: 'xe_content editable',
|
||||||
|
toolbarCanCollapse: true,
|
||||||
|
toolbarGroups: [
|
||||||
|
{ name: 'clipboard', groups: [ 'undo', 'clipboard' ] },
|
||||||
|
{ name: 'editing', groups: [ 'find', 'selection' ] },
|
||||||
|
{ name: 'insert' },
|
||||||
|
{ name: 'tools' },
|
||||||
|
{ name: 'document', groups: [ 'mode' ] },
|
||||||
|
'/',
|
||||||
|
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
|
||||||
|
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },
|
||||||
|
{ name: 'links' },
|
||||||
|
{ name: 'styles' },
|
||||||
|
{ name: 'colors' },
|
||||||
|
{ name: 'others' },
|
||||||
|
],
|
||||||
|
allowedContent: true,
|
||||||
|
removePlugins: 'stylescombo,language',
|
||||||
|
removeButtons: 'Save,Preview,Print,Cut,Copy,Paste',
|
||||||
|
};
|
||||||
|
|
||||||
|
var XeCkEditor = xe.createApp('XeCkEditor', {
|
||||||
|
editor_sequence: null,
|
||||||
init : function() {
|
init : function() {
|
||||||
|
var self = this;
|
||||||
|
CKEDITOR.on('instanceCreated', function(evt){
|
||||||
|
self.cast('CKEDITOR_CREATED');
|
||||||
|
});
|
||||||
|
|
||||||
|
CKEDITOR.on('ready', function(evt){
|
||||||
|
self.cast('CKEDITOR_READY');
|
||||||
|
});
|
||||||
|
|
||||||
|
CKEDITOR.on('instanceReady', function(evt){
|
||||||
|
self.cast('CKEDITOR_INSTANCE_READY');
|
||||||
|
});
|
||||||
|
|
||||||
|
CKEDITOR.on('instanceLoaded', function(evt){
|
||||||
|
self.cast('CKEDITOR_LOADED');
|
||||||
|
});
|
||||||
},
|
},
|
||||||
API_ONREADY : function() {
|
API_ONREADY : function() {
|
||||||
},
|
},
|
||||||
|
editorInit : function(containerEl, opts) {
|
||||||
|
var self = this;
|
||||||
|
var $containerEl = containerEl;
|
||||||
|
var $form = $containerEl.closest('form');
|
||||||
|
var $contentField = opts.content_field;
|
||||||
|
var data = $containerEl.data();
|
||||||
|
var editor_sequence = $containerEl.data().editorSequence;
|
||||||
|
var ckeconfig = $.extend({}, settings, 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);
|
||||||
|
|
||||||
|
insance.on('change', function(e){
|
||||||
|
if($contentField.length){
|
||||||
|
$contentField.val(e.editor.getData());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
window.editorRelKeys[data.editorSequence] = {};
|
||||||
|
window.editorRelKeys[data.editorSequence].primary = $form.find('[name='+data.editorPrimaryKeyName+']')[0];
|
||||||
|
window.editorRelKeys[data.editorSequence].content = $form.find('[name='+data.editorContentKeyName+']')[0];
|
||||||
|
window.editorRelKeys[data.editorSequence].func = function(seq) {
|
||||||
|
return self.getContent.call(self, seq);
|
||||||
|
};
|
||||||
|
window.editorRelKeys[data.editorSequence].pasteHTML = function(text){
|
||||||
|
insance.insertHtml(text, 'html');
|
||||||
|
};
|
||||||
|
},
|
||||||
getContent : function(seq) {
|
getContent : function(seq) {
|
||||||
this.cast('GET_CONTENT');
|
var self = this;
|
||||||
|
var content = _getCkeInstance(seq).getData();
|
||||||
|
self.cast('GET_CONTENT', [content]);
|
||||||
|
|
||||||
|
return content;
|
||||||
|
},
|
||||||
|
getInstance : function(name) {
|
||||||
|
return CKEDITOR.instances[name];
|
||||||
},
|
},
|
||||||
API_EDITOR_CREATED : function(){
|
API_EDITOR_CREATED : function(){
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Shortcut function in jQuery
|
// Shortcut function in jQuery
|
||||||
$.fn.xeEditorApp = function(opts) {
|
$.fn.XeCkEditor = function(opts) {
|
||||||
var u = new XeEditorApp(this.eq(0), opts);
|
var u = new XeCkEditor(this.eq(0), opts);
|
||||||
if(u) xe.registerApp(u);
|
|
||||||
|
if(u) {
|
||||||
|
xe.registerApp(u);
|
||||||
|
u.editorInit(this.eq(0), opts);
|
||||||
|
}
|
||||||
|
|
||||||
return u;
|
return u;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Shortcut function in XE
|
// Shortcut function in XE
|
||||||
window.xe.createXeEditor = function() {
|
window.xe.XeCkEditor = function() {
|
||||||
var u = new XeEditorApp();
|
var u = new XeCkEditor();
|
||||||
|
|
||||||
return u;
|
return u;
|
||||||
};
|
};
|
||||||
var u = new XeEditorApp();
|
|
||||||
xe.registerApp(u);
|
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue