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>
81 lines
2.1 KiB
JavaScript
81 lines
2.1 KiB
JavaScript
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.split = split;
|
|
/**
|
|
* Internal dependencies
|
|
*/
|
|
|
|
/** @typedef {import('./types').RichTextValue} RichTextValue */
|
|
|
|
/**
|
|
* Split a Rich Text value in two at the given `startIndex` and `endIndex`, or
|
|
* split at the given separator. This is similar to `String.prototype.split`.
|
|
* Indices are retrieved from the selection if none are provided.
|
|
*
|
|
* @param {RichTextValue} value
|
|
* @param {number|string} [string] Start index, or string at which to split.
|
|
*
|
|
* @return {Array<RichTextValue>|undefined} An array of new values.
|
|
*/
|
|
function split({
|
|
formats,
|
|
replacements,
|
|
text,
|
|
start,
|
|
end
|
|
}, string) {
|
|
if (typeof string !== 'string') {
|
|
return splitAtSelection(...arguments);
|
|
}
|
|
let nextStart = 0;
|
|
return text.split(string).map(substring => {
|
|
const startIndex = nextStart;
|
|
const value = {
|
|
formats: formats.slice(startIndex, startIndex + substring.length),
|
|
replacements: replacements.slice(startIndex, startIndex + substring.length),
|
|
text: substring
|
|
};
|
|
nextStart += string.length + substring.length;
|
|
if (start !== undefined && end !== undefined) {
|
|
if (start >= startIndex && start < nextStart) {
|
|
value.start = start - startIndex;
|
|
} else if (start < startIndex && end > startIndex) {
|
|
value.start = 0;
|
|
}
|
|
if (end >= startIndex && end < nextStart) {
|
|
value.end = end - startIndex;
|
|
} else if (start < nextStart && end > nextStart) {
|
|
value.end = substring.length;
|
|
}
|
|
}
|
|
return value;
|
|
});
|
|
}
|
|
function splitAtSelection({
|
|
formats,
|
|
replacements,
|
|
text,
|
|
start,
|
|
end
|
|
}, startIndex = start, endIndex = end) {
|
|
if (start === undefined || end === undefined) {
|
|
return;
|
|
}
|
|
const before = {
|
|
formats: formats.slice(0, startIndex),
|
|
replacements: replacements.slice(0, startIndex),
|
|
text: text.slice(0, startIndex)
|
|
};
|
|
const after = {
|
|
formats: formats.slice(endIndex),
|
|
replacements: replacements.slice(endIndex),
|
|
text: text.slice(endIndex),
|
|
start: 0,
|
|
end: 0
|
|
};
|
|
return [before, after];
|
|
}
|
|
//# sourceMappingURL=split.js.map
|