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>
61 lines
1.8 KiB
JavaScript
61 lines
1.8 KiB
JavaScript
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.updateFormats = updateFormats;
|
|
var _isFormatEqual = require("./is-format-equal");
|
|
/**
|
|
* Internal dependencies
|
|
*/
|
|
|
|
/** @typedef {import('./types').RichTextValue} RichTextValue */
|
|
|
|
/**
|
|
* Efficiently updates all the formats from `start` (including) until `end`
|
|
* (excluding) with the active formats. Mutates `value`.
|
|
*
|
|
* @param {Object} $1 Named paramentes.
|
|
* @param {RichTextValue} $1.value Value te update.
|
|
* @param {number} $1.start Index to update from.
|
|
* @param {number} $1.end Index to update until.
|
|
* @param {Array} $1.formats Replacement formats.
|
|
*
|
|
* @return {RichTextValue} Mutated value.
|
|
*/
|
|
function updateFormats({
|
|
value,
|
|
start,
|
|
end,
|
|
formats
|
|
}) {
|
|
// Start and end may be switched in case of delete.
|
|
const min = Math.min(start, end);
|
|
const max = Math.max(start, end);
|
|
const formatsBefore = value.formats[min - 1] || [];
|
|
const formatsAfter = value.formats[max] || [];
|
|
|
|
// First, fix the references. If any format right before or after are
|
|
// equal, the replacement format should use the same reference.
|
|
value.activeFormats = formats.map((format, index) => {
|
|
if (formatsBefore[index]) {
|
|
if ((0, _isFormatEqual.isFormatEqual)(format, formatsBefore[index])) {
|
|
return formatsBefore[index];
|
|
}
|
|
} else if (formatsAfter[index]) {
|
|
if ((0, _isFormatEqual.isFormatEqual)(format, formatsAfter[index])) {
|
|
return formatsAfter[index];
|
|
}
|
|
}
|
|
return format;
|
|
});
|
|
while (--end >= start) {
|
|
if (value.activeFormats.length > 0) {
|
|
value.formats[end] = value.activeFormats;
|
|
} else {
|
|
delete value.formats[end];
|
|
}
|
|
}
|
|
return value;
|
|
}
|
|
//# sourceMappingURL=update-formats.js.map
|