From: Alexander Ebert Date: Wed, 24 Aug 2016 09:23:37 +0000 (+0200) Subject: Fixed some issues w/ code view X-Git-Tag: 3.0.0_Beta_1~538 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7025aa8fec712a6a93fea6419bda34a9d00a37fb;p=GitHub%2FWoltLab%2FWCF.git Fixed some issues w/ code view --- 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); + } + }; +};