From: Alexander Ebert Date: Thu, 5 Jan 2017 12:43:18 +0000 (+0100) Subject: Fixed caret behavior for inserted tables X-Git-Tag: 3.0.0~46 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0c48ef6426aa8cc1f4685124d03c92704a21be99;p=GitHub%2FWoltLab%2FWCF.git Fixed caret behavior for inserted tables --- diff --git a/com.woltlab.wcf/templates/wysiwyg.tpl b/com.woltlab.wcf/templates/wysiwyg.tpl index 0e60cf9c78..e1b9aef229 100644 --- a/com.woltlab.wcf/templates/wysiwyg.tpl +++ b/com.woltlab.wcf/templates/wysiwyg.tpl @@ -40,6 +40,7 @@ '{@$__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/WoltLabTable.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabUtils.js?v={@LAST_UPDATE_TIME}' {else} '{@$__wcf->getPath()}js/3rdParty/redactor2/redactor.min.js?v={@LAST_UPDATE_TIME}', @@ -208,6 +209,7 @@ 'WoltLabSmiley', 'WoltLabSource', 'WoltLabSpoiler', + 'WoltLabTable', 'WoltLabUtils' ], toolbarFixed: false, diff --git a/wcfsetup/install/files/acp/templates/wysiwyg.tpl b/wcfsetup/install/files/acp/templates/wysiwyg.tpl index 0e60cf9c78..e1b9aef229 100644 --- a/wcfsetup/install/files/acp/templates/wysiwyg.tpl +++ b/wcfsetup/install/files/acp/templates/wysiwyg.tpl @@ -40,6 +40,7 @@ '{@$__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/WoltLabTable.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabUtils.js?v={@LAST_UPDATE_TIME}' {else} '{@$__wcf->getPath()}js/3rdParty/redactor2/redactor.min.js?v={@LAST_UPDATE_TIME}', @@ -208,6 +209,7 @@ 'WoltLabSmiley', 'WoltLabSource', 'WoltLabSpoiler', + 'WoltLabTable', 'WoltLabUtils' ], toolbarFixed: false, diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabBlock.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabBlock.js index 9a4e1feac4..e8afa1779f 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabBlock.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabBlock.js @@ -32,8 +32,8 @@ $.Redactor.prototype.WoltLabBlock = function() { var mpFormatCollapsed = this.block.formatCollapsed; this.block.formatCollapsed = (function(tag, attr, value, type) { var block = this.selection.block(); - if (block && block.nodeName === 'LI') { - // lists cannot contain other block elements + if (block && (block.nodeName === 'LI' || block.nodeName === 'TD')) { + // tables/lists cannot contain other block elements return; } diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabTable.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabTable.js new file mode 100644 index 0000000000..06fed1941e --- /dev/null +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabTable.js @@ -0,0 +1,20 @@ +$.Redactor.prototype.WoltLabTable = function() { + "use strict"; + + return { + init: function() { + this.WoltLabEvent.register('insertedTable', (function() { + window.setTimeout((function () { + var node = this.selection.block() || this.selection.current(); + if (node.nodeName === 'TBODY') { + // find first and set the caret inside it + var td = elBySel('td', node); + if (td) { + this.caret.end(td); + } + } + }).bind(this), 10); + }).bind(this)); + } + } +};