From 7025aa8fec712a6a93fea6419bda34a9d00a37fb Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 24 Aug 2016 11:23:37 +0200 Subject: [PATCH] Fixed some issues w/ code view --- com.woltlab.wcf/templates/wysiwyg.tpl | 2 ++ .../3rdParty/redactor2/plugins/WoltLabCode.js | 4 --- .../redactor2/plugins/WoltLabSource.js | 27 +++++++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSource.js diff --git a/com.woltlab.wcf/templates/wysiwyg.tpl b/com.woltlab.wcf/templates/wysiwyg.tpl index aa9bf0fda4..4abf9700cb 100644 --- a/com.woltlab.wcf/templates/wysiwyg.tpl +++ b/com.woltlab.wcf/templates/wysiwyg.tpl @@ -30,6 +30,7 @@ '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabQuote.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabSize.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabSmiley.js?v={@LAST_UPDATE_TIME}', + '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabSource.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabSpoiler.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabUtils.js?v={@LAST_UPDATE_TIME}' {else} @@ -176,6 +177,7 @@ 'WoltLabQuote', 'WoltLabSize', 'WoltLabSmiley', + 'WoltLabSource', 'WoltLabSpoiler', 'WoltLabUtils' ], diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCode.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCode.js index 3b708e084f..2a96ea4491 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCode.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCode.js @@ -3,10 +3,6 @@ $.Redactor.prototype.WoltLabCode = function() { return { init: function() { - // disable caret position in source mode - this.source.setCaretOnShow = function () {}; - this.source.setCaretOnHide = function (html) { return html; }; - require(['WoltLabSuite/Core/Ui/Redactor/Code'], (function (UiRedactorCode) { new UiRedactorCode(this); }).bind(this)); diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSource.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSource.js new file mode 100644 index 0000000000..dc80b44ec1 --- /dev/null +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSource.js @@ -0,0 +1,27 @@ +$.Redactor.prototype.WoltLabSource = function() { + "use strict"; + + return { + init: function () { + // disable caret position in source mode + this.source.setCaretOnShow = function () {}; + this.source.setCaretOnHide = function (html) { return html; }; + + var mpHide = this.source.hide; + this.source.hide = (function () { + mpHide.call(this); + + setTimeout(this.focus.end.bind(this), 100); + }).bind(this); + + var textarea = this.source.$textarea[0]; + + var mpShow = this.source.show; + this.source.show = (function () { + mpShow.call(this); + + textarea.selectionStart = textarea.selectionEnd = textarea.value.length; + }).bind(this); + } + }; +}; -- 2.20.1