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>
43 lines
1.5 KiB
JavaScript
43 lines
1.5 KiB
JavaScript
/**
|
|
* Internal dependencies
|
|
*/
|
|
|
|
import { create } from './create';
|
|
import { normaliseFormats } from './normalise-formats';
|
|
|
|
/** @typedef {import('./types').RichTextValue} RichTextValue */
|
|
|
|
/**
|
|
* Insert a Rich Text value, an HTML string, or a plain text string, into a
|
|
* Rich Text value at the given `startIndex`. Any content between `startIndex`
|
|
* and `endIndex` will be removed. Indices are retrieved from the selection if
|
|
* none are provided.
|
|
*
|
|
* @param {RichTextValue} value Value to modify.
|
|
* @param {RichTextValue|string} valueToInsert Value to insert.
|
|
* @param {number} [startIndex] Start index.
|
|
* @param {number} [endIndex] End index.
|
|
*
|
|
* @return {RichTextValue} A new value with the value inserted.
|
|
*/
|
|
export function insert(value, valueToInsert, startIndex = value.start, endIndex = value.end) {
|
|
const {
|
|
formats,
|
|
replacements,
|
|
text
|
|
} = value;
|
|
if (typeof valueToInsert === 'string') {
|
|
valueToInsert = create({
|
|
text: valueToInsert
|
|
});
|
|
}
|
|
const index = startIndex + valueToInsert.text.length;
|
|
return normaliseFormats({
|
|
formats: formats.slice(0, startIndex).concat(valueToInsert.formats, formats.slice(endIndex)),
|
|
replacements: replacements.slice(0, startIndex).concat(valueToInsert.replacements, replacements.slice(endIndex)),
|
|
text: text.slice(0, startIndex) + valueToInsert.text + text.slice(endIndex),
|
|
start: index,
|
|
end: index
|
|
});
|
|
}
|
|
//# sourceMappingURL=insert.js.map
|