From 836155eb16e42538eed609578deee7ede49ba224 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 9 Apr 2021 17:34:56 +0200 Subject: [PATCH] Block the form submit if one or more editors are still in source code mode --- .../redactor2/plugins/WoltLabSource.js | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) 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 () { -- 2.20.1