Add coexistence checks to all enqueue methods to prevent loading both React and Grid.js assets simultaneously. Changes: - ReactAdmin.php: Only enqueue React assets when ?react=1 - Init.php: Skip Grid.js when React active on admin pages - Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0 - Customer.php, Product.php, License.php: Add coexistence checks Now the toggle between Classic and React versions works correctly. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
58 lines
2.1 KiB
JavaScript
58 lines
2.1 KiB
JavaScript
"use strict";
|
|
|
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = inputFieldHasUncollapsedSelection;
|
|
var _isTextField = _interopRequireDefault(require("./is-text-field"));
|
|
var _isHtmlInputElement = _interopRequireDefault(require("./is-html-input-element"));
|
|
/**
|
|
* Internal dependencies
|
|
*/
|
|
|
|
/**
|
|
* Check whether the given input field or textarea contains a (uncollapsed)
|
|
* selection of text.
|
|
*
|
|
* CAVEAT: Only specific text-based HTML inputs support the selection APIs
|
|
* needed to determine whether they have a collapsed or uncollapsed selection.
|
|
* This function defaults to returning `true` when the selection cannot be
|
|
* inspected, such as with `<input type="time">`. The rationale is that this
|
|
* should cause the block editor to defer to the browser's native selection
|
|
* handling (e.g. copying and pasting), thereby reducing friction for the user.
|
|
*
|
|
* See: https://html.spec.whatwg.org/multipage/input.html#do-not-apply
|
|
*
|
|
* @param {Element} element The HTML element.
|
|
*
|
|
* @return {boolean} Whether the input/textareaa element has some "selection".
|
|
*/
|
|
function inputFieldHasUncollapsedSelection(element) {
|
|
if (!(0, _isHtmlInputElement.default)(element) && !(0, _isTextField.default)(element)) {
|
|
return false;
|
|
}
|
|
|
|
// Safari throws a type error when trying to get `selectionStart` and
|
|
// `selectionEnd` on non-text <input> elements, so a try/catch construct is
|
|
// necessary.
|
|
try {
|
|
const {
|
|
selectionStart,
|
|
selectionEnd
|
|
} = /** @type {HTMLInputElement | HTMLTextAreaElement} */element;
|
|
return (
|
|
// `null` means the input type doesn't implement selection, thus we
|
|
// cannot determine whether the selection is collapsed, so we
|
|
// default to true.
|
|
selectionStart === null ||
|
|
// when not null, compare the two points
|
|
selectionStart !== selectionEnd
|
|
);
|
|
} catch (error) {
|
|
// This is Safari's way of saying that the input type doesn't implement
|
|
// selection, so we default to true.
|
|
return true;
|
|
}
|
|
}
|
|
//# sourceMappingURL=input-field-has-uncollapsed-selection.js.map
|