From 8cf3621324214ce85187e932127377aa6d161339 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 3 Jul 2023 11:32:19 +0200 Subject: [PATCH] Remove the legacy `interactWithRedactor()` wrapper --- ts/WoltLabSuite/Core/Core.ts | 35 ------------------- .../files/js/WoltLabSuite/Core/Core.js | 28 +-------------- 2 files changed, 1 insertion(+), 62 deletions(-) diff --git a/ts/WoltLabSuite/Core/Core.ts b/ts/WoltLabSuite/Core/Core.ts index e873e8fe29..247fe203f1 100644 --- a/ts/WoltLabSuite/Core/Core.ts +++ b/ts/WoltLabSuite/Core/Core.ts @@ -31,17 +31,6 @@ const _cloneObject = function (obj: object | any[]): object | any[] | null { const _prefix = "wsc" + window.WCF_PATH.hashCode() + "-"; -let _blockFocusIn = false; -document.addEventListener( - "focusin", - (event) => { - if (_blockFocusIn) { - event.stopImmediatePropagation(); - } - }, - true, -); - /** * Deep clones an object. */ @@ -302,27 +291,3 @@ export function getXsrfToken(): string { return decodeURIComponent(value.trim()); } - -/** - * Permits the interaction with Redactor, that usually requires - * changes to the selection, without interfering with an active - * focus trap. - * - * It is strongly recommended to close a dialog before interacting - * with Redactor. This helper is designed for cases where this - * is not possible. - */ -export function interactWithRedactor(callback: () => void | Promise): void { - _blockFocusIn = true; - - const activeElement = document.activeElement; - - void callback(); - - // Shift the focus back to preserve the behavior of the focus trap. - if (activeElement instanceof HTMLElement) { - activeElement.focus(); - } - - _blockFocusIn = false; -} diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Core.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Core.js index c2a3f0576c..8c55a237ba 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Core.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Core.js @@ -8,7 +8,7 @@ define(["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.interactWithRedactor = exports.getXsrfToken = exports.enableLegacyInheritance = exports.debounce = exports.stringToBool = exports.getStoragePrefix = exports.triggerEvent = exports.serialize = exports.getUuid = exports.getType = exports.isPlainObject = exports.inherit = exports.extend = exports.convertLegacyUrl = exports.clone = void 0; + exports.getXsrfToken = exports.enableLegacyInheritance = exports.debounce = exports.stringToBool = exports.getStoragePrefix = exports.triggerEvent = exports.serialize = exports.getUuid = exports.getType = exports.isPlainObject = exports.inherit = exports.extend = exports.convertLegacyUrl = exports.clone = void 0; const _clone = function (variable) { if (typeof variable === "object" && (Array.isArray(variable) || isPlainObject(variable))) { return _cloneObject(variable); @@ -27,12 +27,6 @@ define(["require", "exports"], function (require, exports) { return newObj; }; const _prefix = "wsc" + window.WCF_PATH.hashCode() + "-"; - let _blockFocusIn = false; - document.addEventListener("focusin", (event) => { - if (_blockFocusIn) { - event.stopImmediatePropagation(); - } - }, true); /** * Deep clones an object. */ @@ -260,24 +254,4 @@ define(["require", "exports"], function (require, exports) { return decodeURIComponent(value.trim()); } exports.getXsrfToken = getXsrfToken; - /** - * Permits the interaction with Redactor, that usually requires - * changes to the selection, without interfering with an active - * focus trap. - * - * It is strongly recommended to close a dialog before interacting - * with Redactor. This helper is designed for cases where this - * is not possible. - */ - function interactWithRedactor(callback) { - _blockFocusIn = true; - const activeElement = document.activeElement; - void callback(); - // Shift the focus back to preserve the behavior of the focus trap. - if (activeElement instanceof HTMLElement) { - activeElement.focus(); - } - _blockFocusIn = false; - } - exports.interactWithRedactor = interactWithRedactor; }); -- 2.20.1