Always treat CKEditor as producing HTML content

This commit is contained in:
Kijin Sung 2017-06-29 19:42:52 +09:00
parent 24ab7dba9e
commit 2533db414b

View file

@ -45,10 +45,8 @@ var auto_saved_msg = "{$lang->msg_auto_saved}";
</block>
<script>
(function($){
"use strict";
// editor
$(function(){
"use strict";
<!--@if(!FileHandler::exists('common/js/plugins/ckeditor/ckeditor/config.js'))-->CKEDITOR.config.customConfig = '';<!--@endif-->
// Import CSS content from PHP.
@ -69,7 +67,9 @@ var auto_saved_msg = "{$lang->msg_auto_saved}";
}
}
var font_list = [];
<block loop="$lang->edit->fontlist => $fontname">font_list.push({json_encode($fontname)});</block>
<!--@foreach($lang->edit->fontlist as $fontname)-->
font_list.push({json_encode($fontname)});
<!--@endforeach-->
if (default_font_fullname !== null && !$.inArray(default_font_fullname, font_list)) {
font_list.push(default_font_fullname);
}
@ -89,6 +89,7 @@ var auto_saved_msg = "{$lang->msg_auto_saved}";
return val + "/" + val + "px";
}).join(";");
// Initialize CKEditor settings.
var settings = {
ckeconfig: {
height: '{$editor_height}',
@ -108,11 +109,13 @@ var auto_saved_msg = "{$lang->msg_auto_saved}";
content_field: jQuery('[name={$editor_content_key_name}]')
};
// Temporary workaround for line break bug in recent versions of iOS.
if (navigator.userAgent.match(/i(OS|Phone|Pad)/)) {
settings.ckeconfig.enterMode = CKEDITOR.ENTER_BR;
settings.ckeconfig.shiftEnterMode = CKEDITOR.ENTER_P;
}
// Prevent removal of icon fonts and Google code.
CKEDITOR.dtd.$removeEmpty.i = 0;
CKEDITOR.dtd.$removeEmpty.ins = 0;
@ -157,7 +160,22 @@ var auto_saved_msg = "{$lang->msg_auto_saved}";
CKEDITOR.addCss(css_content);
// Initialize CKEditor.
var ckeApp = $('#ckeditor_instance_{$editor_sequence}').XeCkEditor(settings);
// Add use_editor and use_html fields to parent form.
var parentform = $('#ckeditor_instance_{$editor_sequence}').parents('form');
var use_editor = parentform.find("input[name='use_editor']");
var use_html = parentform.find("input[name='use_html']");
if (use_editor.size()) {
use_editor.val("Y");
} else {
parentform.append('<input type="hidden" name="use_editor" value="Y" />');
}
if (use_html.size()) {
use_html.val("Y");
} else {
parentform.append('<input type="hidden" name="use_html" value="Y" />');
}
});
})(jQuery);
</script>