From cd80bcb3a77576fde3270da01cbaf2e58755976a Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sun, 18 Dec 2016 00:24:59 +0900 Subject: [PATCH] Fix #494 add option to control auto-insertion of images in editor --- common/js/plugins/jquery.fileupload/js/main.js | 8 +++++--- modules/editor/editor.admin.controller.php | 2 ++ modules/editor/editor.model.php | 8 ++++++++ modules/editor/lang/en.php | 4 ++++ modules/editor/lang/ko.php | 4 ++++ modules/editor/skins/ckeditor/editor.html | 2 +- modules/editor/skins/ckeditor/file_upload.html | 3 ++- modules/editor/tpl/admin_index.html | 14 ++++++++++++++ 8 files changed, 40 insertions(+), 5 deletions(-) diff --git a/common/js/plugins/jquery.fileupload/js/main.js b/common/js/plugins/jquery.fileupload/js/main.js index 21b6e38dd..780cc28d5 100644 --- a/common/js/plugins/jquery.fileupload/js/main.js +++ b/common/js/plugins/jquery.fileupload/js/main.js @@ -144,10 +144,12 @@ if(result.error == 0) { if(/\.(jpe?g|png|gif)$/i.test(result.source_filename)) { temp_code += '' + result.source_filename + ''; - temp_code += "\r\n


\r\n"; + if (opt.autoinsertImage === 'paragraph') { + _getCkeInstance(settings.formData.editor_sequence).insertHtml("

" + temp_code + "

\n", "unfiltered_html"); + } else if (opt.autoinsertImage === 'inline') { + _getCkeInstance(settings.formData.editor_sequence).insertHtml(temp_code, "unfiltered_html"); + } } - - _getCkeInstance(settings.formData.editor_sequence).insertHtml(temp_code, "unfiltered_html"); } else if (result.message) { alert(result.message); return false; diff --git a/modules/editor/editor.admin.controller.php b/modules/editor/editor.admin.controller.php index 5aa6b712b..ea8b9edee 100644 --- a/modules/editor/editor.admin.controller.php +++ b/modules/editor/editor.admin.controller.php @@ -184,6 +184,8 @@ class editorAdminController extends editor $config->content_paragraph_spacing = ctype_digit($config->content_paragraph_spacing) ? ($config->content_paragraph_spacing . '%') : $config->content_paragraph_spacing; $config->content_word_break = $configVars->content_word_break; $config->content_word_break = in_array($config->content_word_break, array('normal', 'keep-all', 'break-all', 'none')) ? $config->content_word_break : 'normal'; + $config->autoinsert_image = $configVars->autoinsert_image; + $config->autoinsert_image = in_array($config->autoinsert_image, array('paragraph', 'inline', 'none')) ? $config->autoinsert_image : 'paragraph'; $oModuleController->insertModuleConfig('editor', $config); $this->setRedirectUrl(Context::get('error_return_url')); diff --git a/modules/editor/editor.model.php b/modules/editor/editor.model.php index 7fccc8440..da4783bc0 100644 --- a/modules/editor/editor.model.php +++ b/modules/editor/editor.model.php @@ -95,6 +95,10 @@ class editorModel extends editor { $editor_config->content_word_break = $editor_default_config->content_word_break; } + if((!$editor_config->autoinsert_image && $editor_default_config->autoinsert_image) || $editor_config->default_editor_settings === 'Y') + { + $editor_config->autoinsert_image = $editor_default_config->autoinsert_image; + } if((!$editor_config->sel_editor_colorset && $editor_default_config->sel_editor_colorset) || $editor_config->default_editor_settings === 'Y') { $editor_config->sel_editor_colorset = $editor_default_config->sel_editor_colorset; @@ -239,6 +243,7 @@ class editorModel extends editor Context::set('content_line_height', $option->content_line_height); Context::set('content_paragraph_spacing', $option->content_paragraph_spacing); Context::set('content_word_break', $option->content_word_break); + Context::set('editor_autoinsert_image', $option->autoinsert_image); Context::set('editor_additional_css', $option->additional_css); // Option setting to allow auto-save @@ -430,6 +435,7 @@ class editorModel extends editor $config->content_line_height = $editor_config->content_line_height; $config->content_paragraph_spacing = $editor_config->content_paragraph_spacing; $config->content_word_break = $editor_config->content_word_break; + $config->autoinsert_image = $editor_config->autoinsert_image; $config->sel_editor_colorset = $editor_config->sel_editor_colorset; $config->upload_file_grant = $editor_config->upload_file_grant; $config->enable_default_component_grant = $editor_config->enable_default_component_grant; @@ -448,6 +454,7 @@ class editorModel extends editor $config->content_line_height = $editor_config->content_line_height; $config->content_paragraph_spacing = $editor_config->content_paragraph_spacing; $config->content_word_break = $editor_config->content_word_break; + $config->autoinsert_image = $editor_config->autoinsert_image; $config->sel_editor_colorset = $editor_config->sel_comment_editor_colorset; $config->upload_file_grant = $editor_config->comment_upload_file_grant; $config->enable_default_component_grant = $editor_config->enable_comment_default_component_grant; @@ -477,6 +484,7 @@ class editorModel extends editor $option->content_line_height = $config->content_line_height; $option->content_paragraph_spacing = $config->content_paragraph_spacing; $option->content_word_break = $config->content_word_break; + $option->autoinsert_image = $config->autoinsert_image; $option->additional_css = $config->additional_css; $option->colorset = $config->sel_editor_colorset; // Permission check for file upload diff --git a/modules/editor/lang/en.php b/modules/editor/lang/en.php index 8d3f34e7d..ee9ffc2d4 100644 --- a/modules/editor/lang/en.php +++ b/modules/editor/lang/en.php @@ -20,6 +20,10 @@ $lang->word_break_normal = 'Wrap Asian scripts at character boundary and Latin s $lang->word_break_keep_all = 'Wrap at word boundary'; $lang->word_break_break_all = 'Wrap at character boundary'; $lang->word_break_none = 'Do not wrap long lines'; +$lang->guide_choose_autoinsert_image = 'Auto-insert images'; +$lang->autoinsert_image_paragraph = 'Automatically insert images into editor (after line break at cursor position)'; +$lang->autoinsert_image_inline = 'Automatically insert images into editor (directly at cursor position)'; +$lang->autoinsert_image_none = 'Do not auto-insert images into editor'; $lang->about_unit_default_px = 'The unit is px unless otherwise specified.'; $lang->about_unit_default_percent = 'The unit is % unless otherwise specified.'; $lang->font_preview = 'The quick brown fox jumps over the lazy dog. diff --git a/modules/editor/lang/ko.php b/modules/editor/lang/ko.php index 1895b882e..a1e6c3990 100644 --- a/modules/editor/lang/ko.php +++ b/modules/editor/lang/ko.php @@ -21,6 +21,10 @@ $lang->word_break_normal = '한글은 글자 단위로 줄바꿈, 영문은 단 $lang->word_break_keep_all = '모든 언어를 단어 단위로 줄바꿈'; $lang->word_break_break_all = '모든 언어를 글자 단위로 줄바꿈'; $lang->word_break_none = '줄을 바꾸지 않음'; +$lang->guide_choose_autoinsert_image = '이미지 자동 삽입'; +$lang->autoinsert_image_paragraph = '이미지 첨부시 본문에 자동 삽입 (커서 위치에서 줄을 바꾸고 삽입)'; +$lang->autoinsert_image_inline = '이미지 첨부시 본문에 자동 삽입 (커서 위치에 직접 삽입)'; +$lang->autoinsert_image_none = '이미지 첨부시 본문에 자동 삽입하지 않음'; $lang->about_unit_default_px = '단위를 지정하지 않을 경우 px 단위를 사용합니다.'; $lang->about_unit_default_percent = '단위를 지정하지 않을 경우 % 단위를 사용합니다.'; $lang->font_preview = 'The quick brown fox jumps over the lazy dog. diff --git a/modules/editor/skins/ckeditor/editor.html b/modules/editor/skins/ckeditor/editor.html index a597faef5..82c7fcb4e 100644 --- a/modules/editor/skins/ckeditor/editor.html +++ b/modules/editor/skins/ckeditor/editor.html @@ -126,7 +126,7 @@ var auto_saved_msg = "{$lang->msg_auto_saved}"; settings.loadXeComponent = false; - + settings.ckeconfig.toolbarStartupExpanded = false; diff --git a/modules/editor/skins/ckeditor/file_upload.html b/modules/editor/skins/ckeditor/file_upload.html index 9adadffce..49390c1c2 100644 --- a/modules/editor/skins/ckeditor/file_upload.html +++ b/modules/editor/skins/ckeditor/file_upload.html @@ -56,7 +56,8 @@ // uploader var setting = { maxFileSize: {$logged_info->is_admin === 'Y' ? 0 : $file_config->allowed_filesize}, - maxChunkSize: {$file_config->allowed_chunk_size}, + maxChunkSize: {$file_config->allowed_chunk_size ?: 0}, + autoinsertImage: {json_encode($editor_autoinsert_image ?: 'paragraph')}, singleFileUploads: true }; $container = $('#xefu-container-{$editor_sequence}'); diff --git a/modules/editor/tpl/admin_index.html b/modules/editor/tpl/admin_index.html index e06ba1b38..f7fd2ee02 100644 --- a/modules/editor/tpl/admin_index.html +++ b/modules/editor/tpl/admin_index.html @@ -158,6 +158,20 @@ +
+ +
+ + + +
+