From 2e7c219b0be015f345e1cec51acdbb173a79fed9 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 10 Jan 2017 20:21:03 +0100 Subject: [PATCH] Fixed missing existence check --- com.woltlab.wcf/templates/wysiwyg.tpl | 2 ++ .../install/files/acp/templates/wysiwyg.tpl | 2 ++ .../3rdParty/redactor2/plugins/WoltLabLine.js | 29 +++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabLine.js diff --git a/com.woltlab.wcf/templates/wysiwyg.tpl b/com.woltlab.wcf/templates/wysiwyg.tpl index c0f187b7ec..34786632c3 100644 --- a/com.woltlab.wcf/templates/wysiwyg.tpl +++ b/com.woltlab.wcf/templates/wysiwyg.tpl @@ -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}', @@ -202,6 +203,7 @@ {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/acp/templates/wysiwyg.tpl b/wcfsetup/install/files/acp/templates/wysiwyg.tpl index c0f187b7ec..34786632c3 100644 --- a/wcfsetup/install/files/acp/templates/wysiwyg.tpl +++ b/wcfsetup/install/files/acp/templates/wysiwyg.tpl @@ -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}', @@ -202,6 +203,7 @@ {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 index 0000000000..0ed6403283 --- /dev/null +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabLine.js @@ -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); + } + }; +}; -- 2.20.1