Fixed missing existence check
authorAlexander Ebert <ebert@woltlab.com>
Tue, 10 Jan 2017 19:21:03 +0000 (20:21 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 10 Jan 2017 19:21:03 +0000 (20:21 +0100)
com.woltlab.wcf/templates/wysiwyg.tpl
wcfsetup/install/files/acp/templates/wysiwyg.tpl
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabLine.js [new file with mode: 0644]

index c0f187b7ec263f2cbbd0ab3a369c283553f0cd87..34786632c3d9ba3af17c87876fb20859db62a6cc 100644 (file)
@@ -28,6 +28,7 @@
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabInlineCode.js?v={@LAST_UPDATE_TIME}',
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabInsert.js?v={@LAST_UPDATE_TIME}',
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabKeydown.js?v={@LAST_UPDATE_TIME}',
+                       '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabLine.js?v={@LAST_UPDATE_TIME}',
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabLink.js?v={@LAST_UPDATE_TIME}',
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabMedia.js?v={@LAST_UPDATE_TIME}',
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabMention.js?v={@LAST_UPDATE_TIME}',
                                        {if $__wcf->getBBCodeHandler()->isAvailableBBCode('img')}'WoltLabImage',{/if}
                                        'WoltLabInlineCode',
                                        'WoltLabInsert',
+                                       'WoltLabLine',
                                        {if $__wcf->getBBCodeHandler()->isAvailableBBCode('url')}'WoltLabLink',{/if}
                                        'WoltLabModal',
                                        'WoltLabObserve',
index c0f187b7ec263f2cbbd0ab3a369c283553f0cd87..34786632c3d9ba3af17c87876fb20859db62a6cc 100644 (file)
@@ -28,6 +28,7 @@
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabInlineCode.js?v={@LAST_UPDATE_TIME}',
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabInsert.js?v={@LAST_UPDATE_TIME}',
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabKeydown.js?v={@LAST_UPDATE_TIME}',
+                       '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabLine.js?v={@LAST_UPDATE_TIME}',
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabLink.js?v={@LAST_UPDATE_TIME}',
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabMedia.js?v={@LAST_UPDATE_TIME}',
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabMention.js?v={@LAST_UPDATE_TIME}',
                                        {if $__wcf->getBBCodeHandler()->isAvailableBBCode('img')}'WoltLabImage',{/if}
                                        'WoltLabInlineCode',
                                        'WoltLabInsert',
+                                       'WoltLabLine',
                                        {if $__wcf->getBBCodeHandler()->isAvailableBBCode('url')}'WoltLabLink',{/if}
                                        'WoltLabModal',
                                        'WoltLabObserve',
diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabLine.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabLine.js
new file mode 100644 (file)
index 0000000..0ed6403
--- /dev/null
@@ -0,0 +1,29 @@
+$.Redactor.prototype.WoltLabLine = function() {
+       "use strict";
+       
+       return {
+               init: function() {
+                       this.line.removeOnBackspace = (function () {
+                               if (!this.utils.isCollapsed())
+                               {
+                                       return;
+                               }
+                               
+                               var $block = $(this.selection.block());
+                               if ($block.length === 0 || !this.utils.isStartOfElement($block))
+                               {
+                                       return;
+                               }
+                               
+                               // if hr is previous element
+                               var $prev = $block.prev();
+                               // WoltLab modification: check was for `$prev` (always true) instead of `$prev.length`
+                               if ($prev.length && $prev[0].tagName === 'HR')
+                               {
+                                       e.preventDefault();
+                                       $prev.remove();
+                               }
+                       }).bind(this);
+               }
+       };
+};