From 7d5b78b269466b62c6c7c9f90ee6f71476cc7fdb Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 26 Feb 2018 14:11:13 +0900 Subject: [PATCH 1/5] Move editor frame function to editorView::dispEditorFrame --- modules/editor/conf/module.xml | 1 + modules/editor/editor.view.php | 33 ++++++++++++++++++ .../tpl/editor_frame.html} | 0 modules/member/conf/module.xml | 1 - modules/member/member.admin.view.php | 34 ------------------- modules/member/tpl/js/config.js | 2 +- 6 files changed, 35 insertions(+), 36 deletions(-) rename modules/{member/tpl/agreements_edit.html => editor/tpl/editor_frame.html} (100%) diff --git a/modules/editor/conf/module.xml b/modules/editor/conf/module.xml index 10d074053..7a65b3342 100644 --- a/modules/editor/conf/module.xml +++ b/modules/editor/conf/module.xml @@ -3,6 +3,7 @@ + diff --git a/modules/editor/editor.view.php b/modules/editor/editor.view.php index 9255e17e1..660ab3828 100644 --- a/modules/editor/editor.view.php +++ b/modules/editor/editor.view.php @@ -15,6 +15,39 @@ class editorView extends editor { } + /** + * @brief Display editor in an iframe + */ + function dispEditorFrame() + { + // Check parent input ID + $parent_input_id = Context::get('parent_input_id'); + Context::addBodyClass('disable_debug_panel'); + + // Load editor + $oEditorModel = getModel('editor'); + $option = $oEditorModel->getEditorConfig(); + $option->editor_skin = 'ckeditor'; + $option->content_style = 'ckeditor_light'; + $option->sel_editor_colorset = 'moono-lisa'; + $option->primary_key_name = 'primary_key'; + $option->content_key_name = 'content'; + $option->allow_fileupload = FALSE; + $option->enable_autosave = FALSE; + $option->enable_default_component = TRUE; + $option->enable_component = FALSE; + $option->height = 300; + $option->editor_focus = 'Y'; + $editor = $oEditorModel->getEditor(0, $option); + Context::set('editor', $editor); + + // Set template + $this->setLayoutPath('./common/tpl/'); + $this->setLayoutFile("default_layout"); + $this->setTemplatePath($this->module_path . 'tpl'); + $this->setTemplateFile('editor_frame'); + } + /** * @brief Action to get a request to display compoenet pop-up */ diff --git a/modules/member/tpl/agreements_edit.html b/modules/editor/tpl/editor_frame.html similarity index 100% rename from modules/member/tpl/agreements_edit.html rename to modules/editor/tpl/editor_frame.html diff --git a/modules/member/conf/module.xml b/modules/member/conf/module.xml index b98506de8..fc326f3b6 100644 --- a/modules/member/conf/module.xml +++ b/modules/member/conf/module.xml @@ -63,7 +63,6 @@ - diff --git a/modules/member/member.admin.view.php b/modules/member/member.admin.view.php index 118d8bfae..360691fa2 100644 --- a/modules/member/member.admin.view.php +++ b/modules/member/member.admin.view.php @@ -157,40 +157,6 @@ class memberAdminView extends member $this->setTemplateFile('agreements_config'); } - /** - * Display the agreements edit form. - * - * @return void - */ - public function dispMemberAdminAgreementsEdit() - { - // Check parent input ID - $parent_input_id = Context::get('parent_input_id'); - Context::addBodyClass('disable_debug_panel'); - - // Load editor - $oEditorModel = getModel('editor'); - $option = $oEditorModel->getEditorConfig(); - $option->editor_skin = 'ckeditor'; - $option->content_style = 'ckeditor_light'; - $option->sel_editor_colorset = 'moono-lisa'; - $option->primary_key_name = 'primary_key'; - $option->content_key_name = 'content'; - $option->allow_fileupload = FALSE; - $option->enable_autosave = FALSE; - $option->enable_default_component = TRUE; - $option->enable_component = FALSE; - $option->height = 300; - $option->editor_focus = 'Y'; - $editor = $oEditorModel->getEditor(0, $option); - Context::set('editor', $editor); - - // Set template - $this->setLayoutPath('./common/tpl/'); - $this->setLayoutFile("default_layout"); - $this->setTemplateFile('agreements_edit'); - } - public function dispMemberAdminSignUpConfig() { $config = $this->memberConfig; diff --git a/modules/member/tpl/js/config.js b/modules/member/tpl/js/config.js index bbfd3ff3f..4d4b1ef3a 100644 --- a/modules/member/tpl/js/config.js +++ b/modules/member/tpl/js/config.js @@ -4,7 +4,7 @@ // Editor replacement callback function var editor_replace = function(input) { var iframe = $(''); - iframe.attr("src", current_url.setQuery("act", "dispMemberAdminAgreementsEdit").setQuery("parent_input_id", input.attr("id"))); + iframe.attr("src", current_url.setQuery("module", "editor").setQuery("act", "dispEditorFrame").setQuery("parent_input_id", input.attr("id"))); iframe.insertAfter(input); input.siblings(".editor_preview").hide(); if (input.attr("type") !== "hidden") { From a0ae7a2a30b325189afb0524697ef0f1bf7c1839 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 6 Mar 2018 21:39:04 +0900 Subject: [PATCH 2/5] Apply editor replacement to all .editable_preview elements --- common/css/rhymix.less | 26 ++++++++++++++++++++ common/js/common.js | 19 +++++++++++++++ modules/editor/editor.view.php | 1 + modules/editor/tpl/editor_frame.html | 18 ++------------ modules/editor/tpl/js/editor.app.js | 13 ++++++++++ modules/member/tpl/agreements_config.html | 4 ++-- modules/member/tpl/css/config.less | 26 -------------------- modules/member/tpl/header.html | 2 -- modules/member/tpl/js/config.js | 29 ----------------------- 9 files changed, 63 insertions(+), 75 deletions(-) delete mode 100644 modules/member/tpl/css/config.less diff --git a/common/css/rhymix.less b/common/css/rhymix.less index 7c8dbff14..4548b8bbd 100644 --- a/common/css/rhymix.less +++ b/common/css/rhymix.less @@ -107,6 +107,32 @@ a img { } } +/* Editable Preview */ +.editable_preview { + width: 100%; + min-height: 240px; + max-height: 440px; + box-sizing: border-box; + margin: 0; + padding: 6px; + border: 1px solid #ccc; + border-radius: 4px; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + overflow-y: auto; + cursor: text; + p { + margin-bottom: @default_paragraph_spacing !important; + } +} +.editable_preview_iframe { + width: 100%; + height: 440px; + box-sizing: border-box; + margin: 0 0 -4px 0; + padding: 0; + border: 0; +} + /* Message */ .message { position: relative; diff --git a/common/js/common.js b/common/js/common.js index b1ed8e432..62543c9c4 100644 --- a/common/js/common.js +++ b/common/js/common.js @@ -281,6 +281,25 @@ jQuery(function($) { } }); + /* Editor preview replacement */ + $(".editable_preview").addClass("xe_content").attr("tabindex", 0); + $(".editable_preview").on("click", function() { + var input = $(this).siblings(".editable_preview_content"); + if (input.size()) { + $(this).off("click").off("focus").remove(); + input = input.first(); + if (input.attr("type") !== "hidden") { + input.hide(); + } + var iframe = $(''); + iframe.attr("src", current_url.setQuery("module", "editor").setQuery("act", "dispEditorFrame").setQuery("parent_input_id", input.attr("id")).replace(/^https?:/, '')); + iframe.insertAfter(input); + } + }); + $(".editable_preview").on("focus", function() { + $(this).triggerHandler("click"); + }); + /* select - option의 disabled=disabled 속성을 IE에서도 체크하기 위한 함수 */ if(navigator.userAgent.match(/MSIE/)) { $('select').each(function(i, sels) { diff --git a/modules/editor/editor.view.php b/modules/editor/editor.view.php index 660ab3828..4cdd7b79a 100644 --- a/modules/editor/editor.view.php +++ b/modules/editor/editor.view.php @@ -22,6 +22,7 @@ class editorView extends editor { // Check parent input ID $parent_input_id = Context::get('parent_input_id'); + Context::set('parent_input_id', preg_replace('/[^a-z0-9_]/i', '', $parent_input_id)); Context::addBodyClass('disable_debug_panel'); // Load editor diff --git a/modules/editor/tpl/editor_frame.html b/modules/editor/tpl/editor_frame.html index 74805996f..3c96e7ca2 100644 --- a/modules/editor/tpl/editor_frame.html +++ b/modules/editor/tpl/editor_frame.html @@ -1,22 +1,8 @@ diff --git a/modules/editor/tpl/js/editor.app.js b/modules/editor/tpl/js/editor.app.js index 8e4fcaf87..619753685 100644 --- a/modules/editor/tpl/js/editor.app.js +++ b/modules/editor/tpl/js/editor.app.js @@ -145,6 +145,19 @@ function getAutoSavedSrl(ret_obj, response_tags, c) { instance.on('instanceReady', function(e) { $containerEl.css("min-height", 0); + if(window.editor_resize_iframe && window.editor_copy_input) + { + e.editor.setData(editor_copy_input.val()); + e.editor.on("resize", function(e){ + var height = e.data.outerHeight; + editor_resize_iframe.height(height); + }); + e.editor.on("change", function() { + var content = e.editor.getData(); + editor_copy_input.val(content); + }); + editor_resize_iframe.height($(".cke_chrome").parent().height()); + } }); instance.on('paste', function(e) { diff --git a/modules/member/tpl/agreements_config.html b/modules/member/tpl/agreements_config.html index 3864658a0..adf34abe4 100644 --- a/modules/member/tpl/agreements_config.html +++ b/modules/member/tpl/agreements_config.html @@ -18,8 +18,8 @@
{$lang->cmd_agreement_content}
- -
{$config->agreements[$i]->content}
+ +
{$config->agreements[$i]->content}
diff --git a/modules/member/tpl/css/config.less b/modules/member/tpl/css/config.less deleted file mode 100644 index d05f6b613..000000000 --- a/modules/member/tpl/css/config.less +++ /dev/null @@ -1,26 +0,0 @@ -.editor_preview { - width: 100%; - min-height: 240px; - max-height: 440px; - box-sizing: border-box; - margin: 0; - padding: 6px; - border: 1px solid #ccc; - border-radius: 4px; - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - overflow-y: auto; - cursor: text; -} - -.editor_preview p { - margin-bottom: @default_paragraph_spacing !important; -} - -.editor_iframe { - width: 100%; - height: 440px; - box-sizing: border-box; - margin: 0 0 -4px 0; - padding: 0; - border: 0; -} diff --git a/modules/member/tpl/header.html b/modules/member/tpl/header.html index 5ea8a6d69..ec5a73030 100644 --- a/modules/member/tpl/header.html +++ b/modules/member/tpl/header.html @@ -1,5 +1,3 @@ - -

{$lang->cmd_member_config} {$lang->help}

diff --git a/modules/member/tpl/js/config.js b/modules/member/tpl/js/config.js index 4d4b1ef3a..e69de29bb 100644 --- a/modules/member/tpl/js/config.js +++ b/modules/member/tpl/js/config.js @@ -1,29 +0,0 @@ - -(function($) { - - // Editor replacement callback function - var editor_replace = function(input) { - var iframe = $(''); - iframe.attr("src", current_url.setQuery("module", "editor").setQuery("act", "dispEditorFrame").setQuery("parent_input_id", input.attr("id"))); - iframe.insertAfter(input); - input.siblings(".editor_preview").hide(); - if (input.attr("type") !== "hidden") { - input.hide(); - } - }; - - // Editor replacement - $(function() { - $(".editor_preview").on("click", function() { - var input = $(this).siblings(".editor_content"); - if (input.size()) { - $(this).off("click").off("focus"); - editor_replace(input.first()); - } - }); - $(".editor_preview").on("focus", function() { - $(this).triggerHandler("click"); - }); - }); - -})(jQuery); From 499a7e4457217f8156b70a47b63ab90184fd8912 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 6 Mar 2018 21:57:59 +0900 Subject: [PATCH 3/5] Fix cursor selection after converting preview to editor --- common/js/common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/js/common.js b/common/js/common.js index 62543c9c4..402edbf09 100644 --- a/common/js/common.js +++ b/common/js/common.js @@ -286,7 +286,7 @@ jQuery(function($) { $(".editable_preview").on("click", function() { var input = $(this).siblings(".editable_preview_content"); if (input.size()) { - $(this).off("click").off("focus").remove(); + $(this).off("click").off("focus").hide(); input = input.first(); if (input.attr("type") !== "hidden") { input.hide(); From c4f3110291a807ad513b916a0915e7ce4c068e3d Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 6 Mar 2018 21:58:33 +0900 Subject: [PATCH 4/5] Enable textarea to be used as member agreement editor --- modules/editor/editor.view.php | 3 --- modules/editor/skins/textarea/js/textarea.js | 18 +++++++++++++++++- modules/member/member.admin.controller.php | 2 ++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/modules/editor/editor.view.php b/modules/editor/editor.view.php index 4cdd7b79a..4ac2d03bc 100644 --- a/modules/editor/editor.view.php +++ b/modules/editor/editor.view.php @@ -28,9 +28,6 @@ class editorView extends editor // Load editor $oEditorModel = getModel('editor'); $option = $oEditorModel->getEditorConfig(); - $option->editor_skin = 'ckeditor'; - $option->content_style = 'ckeditor_light'; - $option->sel_editor_colorset = 'moono-lisa'; $option->primary_key_name = 'primary_key'; $option->content_key_name = 'content'; $option->allow_fileupload = FALSE; diff --git a/modules/editor/skins/textarea/js/textarea.js b/modules/editor/skins/textarea/js/textarea.js index 1f624b4a2..1c477fa06 100644 --- a/modules/editor/skins/textarea/js/textarea.js +++ b/modules/editor/skins/textarea/js/textarea.js @@ -4,6 +4,7 @@ function editorTextarea(editor_sequence) { var primary_key = textarea.data("editor-primary-key-name"); var insert_form = textarea.closest("form"); var content_input = insert_form.find("input[name='" + content_key + "']"); + var content = ""; // Set editor keys editorRelKeys[editor_sequence] = {}; @@ -16,7 +17,7 @@ function editorTextarea(editor_sequence) { // Load existing content if (content_input.size()) { - var content = String(content_input.val()).stripTags(); + content = String(content_input.val()).stripTags(); content_input.val(content); textarea.val(content.unescape()); } @@ -25,4 +26,19 @@ function editorTextarea(editor_sequence) { textarea.on("change", function() { content_input.val(String(jQuery(this).val()).escape()); }); + + // Copy content to another input and resize iframe if configured + if (window.editor_resize_iframe && window.editor_copy_input) + { + content = String(editor_copy_input.val()).stripTags(); + editor_copy_input.val(content); + textarea.val(content.unescape()); + textarea.on("resize", function(e){ + editor_resize_iframe.height(textarea.height()); + }); + textarea.on("change", function() { + editor_copy_input.val(String(textarea.val()).escape()); + }); + editor_resize_iframe.height(textarea.height()); + } } \ No newline at end of file diff --git a/modules/member/member.admin.controller.php b/modules/member/member.admin.controller.php index 068a7b2b1..0d08a6ca1 100644 --- a/modules/member/member.admin.controller.php +++ b/modules/member/member.admin.controller.php @@ -262,6 +262,8 @@ class memberAdminController extends member $agreement = new stdClass; $agreement->title = escape(utf8_trim($args->{'agreement_' . $i . '_title'})); $agreement->content = $args->{'agreement_' . $i . '_content'}; + $agreement->use_editor = $args->use_editor; + getModel('editor')->converter($agreement, 'document'); $agreement->type = $args->{'agreement_' . $i . '_type'}; if (!in_array($agreement->type, array('required', 'optional', 'disabled'))) { From f42e1f7a4556485ec997ffc5b47e2cd3b57dac65 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 6 Mar 2018 22:04:25 +0900 Subject: [PATCH 5/5] Reapply CKEditor option to dispEditorFrame --- modules/editor/editor.view.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/editor/editor.view.php b/modules/editor/editor.view.php index 4ac2d03bc..4cdd7b79a 100644 --- a/modules/editor/editor.view.php +++ b/modules/editor/editor.view.php @@ -28,6 +28,9 @@ class editorView extends editor // Load editor $oEditorModel = getModel('editor'); $option = $oEditorModel->getEditorConfig(); + $option->editor_skin = 'ckeditor'; + $option->content_style = 'ckeditor_light'; + $option->sel_editor_colorset = 'moono-lisa'; $option->primary_key_name = 'primary_key'; $option->content_key_name = 'content'; $option->allow_fileupload = FALSE;