From: Alexander Ebert Date: Fri, 9 Apr 2021 15:34:56 +0000 (+0200) Subject: Block the form submit if one or more editors are still in source code mode X-Git-Tag: 5.3.6~22 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=836155eb16e42538eed609578deee7ede49ba224;p=GitHub%2FWoltLab%2FWCF.git Block the form submit if one or more editors are still in source code mode --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSource.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSource.js index eb52b63a2b..eab7d7ba3d 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSource.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSource.js @@ -114,6 +114,40 @@ $.Redactor.prototype.WoltLabSource = function() { data.valid = false; } }).bind(this)); + + var box = this.core.box()[0]; + var form = box.closest("form"); + if (form) { + var dl = box.closest("dl"); + + form.addEventListener("submit", (function (event) { + var message = ''; + if (this.WoltLabSource.isActive()) { + event.preventDefault(); + + message = WCF.Language.get('wcf.editor.source.error.active'); + + // Enable the submit button again to override the FormGuard's behavior. + var submitButton = form.querySelector(".formSubmit input[type=submit]"); + if (submitButton) { + submitButton.disabled = false; + } + + require(['WoltLabSuite/Core/Ui/TabMenu'], function(UiTabMenu) { + UiTabMenu._selectErroneousTabs(); + }); + } + + elInnerError(box, message); + + if (message) { + dl.classList.add("formError"); + } + else { + dl.classList.remove("formError"); + } + }).bind(this)); + } }, isActive: function () {