From ddb2a8afa1eb1e41f7eac9f3e6e9f699596ddd97 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Thu, 8 Mar 2018 14:23:47 +0900 Subject: [PATCH] Fix CKEditor Korean line break issue in iOS #932 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - iOS에서는 divarea 플러그인과 @largeden 님의 ios_enterkey 플러그인을 사용 - iOS에서는 divarea 플러그인과 호환되지 않는 에디터 컴포넌트를 로딩하지 않음 - 추후 호환성 문제가 해결되면 다시 사용하도록 변경할 수 있음 - 기본 폰트 등의 스타일이 cke_wysiwyg_div 클래스에도 적용되도록 조치함 --- .../ckeditor/plugins/divarea/plugin.js | 38 +++++++++++++++++++ .../ckeditor/plugins/ios_enterkey/plugin.js | 24 ++++++++++++ modules/editor/skins/ckeditor/editor.html | 6 ++- 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 common/js/plugins/ckeditor/ckeditor/plugins/divarea/plugin.js create mode 100644 common/js/plugins/ckeditor/ckeditor/plugins/ios_enterkey/plugin.js diff --git a/common/js/plugins/ckeditor/ckeditor/plugins/divarea/plugin.js b/common/js/plugins/ckeditor/ckeditor/plugins/divarea/plugin.js new file mode 100644 index 000000000..572baebcc --- /dev/null +++ b/common/js/plugins/ckeditor/ckeditor/plugins/divarea/plugin.js @@ -0,0 +1,38 @@ +/** + * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. + * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license + */ + +/** + * @fileOverview The "divarea" plugin. It registers the "wysiwyg" editing + * mode using a DIV element. + */ + +CKEDITOR.plugins.add( 'divarea', { + afterInit: function( editor ) { + // Add the "wysiwyg" mode. + // Do that in the afterInit function, so it'll eventually overwrite + // the mode defined by the wysiwygarea plugin. + editor.addMode( 'wysiwyg', function( callback ) { + var editingBlock = CKEDITOR.dom.element.createFromHtml( + '
' + ); + + var contentSpace = editor.ui.space( 'contents' ); + contentSpace.append( editingBlock ); + + editingBlock = editor.editable( editingBlock ); + + editingBlock.detach = CKEDITOR.tools.override( editingBlock.detach, + function( org ) { + return function() { + org.apply( this, arguments ); + this.remove(); + }; + } ); + + editor.setData( editor.getData( 1 ), callback ); + editor.fire( 'contentDom' ); + } ); + } +} ); diff --git a/common/js/plugins/ckeditor/ckeditor/plugins/ios_enterkey/plugin.js b/common/js/plugins/ckeditor/ckeditor/plugins/ios_enterkey/plugin.js new file mode 100644 index 000000000..cb2921cf8 --- /dev/null +++ b/common/js/plugins/ckeditor/ckeditor/plugins/ios_enterkey/plugin.js @@ -0,0 +1,24 @@ +/** + * iOS enter key fix for IME + * + * https://github.com/rhymix/rhymix/issues/932 + */ +CKEDITOR.plugins.add( 'ios_enterkey', +{ + icons: 'ios_enterkey', + init: function(editor) + { + editor.on('contentDom', function() + { + var editable = editor.editable(); + editable.attachListener(editable, 'keyup', function(e) + { + if(e.data.getKey() === 13) + { + $(editor.document.$).find('.cke_wysiwyg_div').blur(); + $(editor.document.$).find('.cke_wysiwyg_div').focus(); + } + }); + }); + } +}); diff --git a/modules/editor/skins/ckeditor/editor.html b/modules/editor/skins/ckeditor/editor.html index abad83a45..c41290d99 100644 --- a/modules/editor/skins/ckeditor/editor.html +++ b/modules/editor/skins/ckeditor/editor.html @@ -145,8 +145,12 @@ var auto_saved_msg = "{$lang->msg_auto_saved}"; settings.ckeconfig.removePlugins = {json_encode(implode(',', $editor_remove_plugins))}; + // https://github.com/rhymix/rhymix/issues/932 if (CKEDITOR.env.iOS) { - settings.ckeconfig.removePlugins = settings.ckeconfig.removePlugins ? (settings.ckeconfig.removePlugins + ',enterkey') : ''; + settings.ckeconfig.extraPlugins = (settings.ckeconfig.extraPlugins ? (settings.ckeconfig.extraPlugins + ',') : '') + 'divarea,ios_enterkey'; + settings.loadXeComponent = false; + var additional_styles = '.cke_wysiwyg_div { padding: 8px !important; }'; + $('head').append('' + additional_styles + css_content.replace(/\.xe_content\.editable/g, '.cke_wysiwyg_div') + ''); }