Fixed some issues w/ code view
authorAlexander Ebert <ebert@woltlab.com>
Wed, 24 Aug 2016 09:23:37 +0000 (11:23 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 24 Aug 2016 09:24:49 +0000 (11:24 +0200)
com.woltlab.wcf/templates/wysiwyg.tpl
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCode.js
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSource.js [new file with mode: 0644]

index aa9bf0fda4c7b9b8456dfe11e354ab7765f7b660..4abf9700cb2016367dd8dbbd96005577c7f50796 100644 (file)
@@ -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}
                                        'WoltLabQuote',
                                        'WoltLabSize',
                                        'WoltLabSmiley',
+                                       'WoltLabSource',
                                        'WoltLabSpoiler',
                                        'WoltLabUtils'
                                ],
index 3b708e084f6a79bfc84af8dfe6d18a7d180fd0a2..2a96ea44911977795c5ace290af4e430c7fb49bb 100644 (file)
@@ -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 (file)
index 0000000..dc80b44
--- /dev/null
@@ -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);
+               }
+       };
+};