@burger-editor/client 4.0.0-alpha.76 → 4.0.0-alpha.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/burger-editor-root.d.ts +1 -1
- package/dist/client.js +10554 -10286
- package/dist/client.js.map +1 -1
- package/dist/components/block-catalog.d.ts +1 -1
- package/dist/components/block-menu-button.d.ts +1 -1
- package/dist/components/block-menu-view.d.ts +1 -1
- package/dist/components/block-menu.d.ts +1 -1
- package/dist/components/block-menu.d.ts.map +1 -1
- package/dist/components/block-options.d.ts +1 -1
- package/dist/components/draft-switcher.d.ts +1 -1
- package/dist/components/editable-area-view.d.ts +1 -1
- package/dist/components/editable-area-view.d.ts.map +1 -1
- package/dist/components/file-list.d.ts +1 -1
- package/dist/components/file-uploader.d.ts +1 -1
- package/dist/components/front-matter-editor.d.ts +1 -1
- package/dist/components/initial-insertion-button.d.ts +1 -1
- package/dist/components/item-editor-host.d.ts +1 -1
- package/dist/components/preview.d.ts +1 -1
- package/dist/components/table-editor.d.ts +1 -1
- package/dist/components/tabs.d.ts +1 -1
- package/dist/components/thumbnail.d.ts +1 -1
- package/dist/components/wysiwyg-field.d.ts +1 -1
- package/dist/{editable-area-view-S2Uz7pl8.js → editable-area-view-BRYT222Y.js} +174 -159
- package/dist/editable-area-view-BRYT222Y.js.map +1 -0
- package/dist/editor-dialog.d.ts +1 -1
- package/dist/{engine-context-D0zt6fhJ.js → engine-context-j4-LLPEh.js} +201 -74
- package/dist/engine-context-j4-LLPEh.js.map +1 -0
- package/dist/engine-context.d.ts +9 -6
- package/dist/engine-context.d.ts.map +1 -1
- package/dist/form/checkbox.d.ts +1 -1
- package/dist/form/fieldset.d.ts +1 -1
- package/dist/form/number-field.d.ts +1 -1
- package/dist/form/radio-group.d.ts +1 -1
- package/dist/form/select-field.d.ts +1 -1
- package/dist/form/text-area.d.ts +1 -1
- package/dist/form/text-field.d.ts +1 -1
- package/dist/root-error-boundary.d.ts +1 -1
- package/dist/testing/render-with-engine.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/ui.js +10 -10
- package/dist/ui.js.map +1 -1
- package/package.json +11 -11
- package/dist/editable-area-view-S2Uz7pl8.js.map +0 -1
- package/dist/engine-context-D0zt6fhJ.js.map +0 -1
|
@@ -62,6 +62,24 @@ var CSS_LAYER = {
|
|
|
62
62
|
};
|
|
63
63
|
var BLOCK_OPTION_CSS_CUSTOM_PROPERTY_PREFIX = "--bge-options-";
|
|
64
64
|
var BLOCK_OPTION_SCOPE_SELECTOR = `[data-bge-container]`;
|
|
65
|
+
/**
|
|
66
|
+
* Stand-in for an empty custom property value (`--x: ;`).
|
|
67
|
+
*
|
|
68
|
+
* Browsers keep such a declaration with the value `' '`, and project CSS
|
|
69
|
+
* relies on it to hide a built-in style option, but jsdom drops it while
|
|
70
|
+
* parsing, so a lower-priority declaration of the same property would win
|
|
71
|
+
* instead. Code that loads CSS into jsdom (file-io's
|
|
72
|
+
* `createStylesheetDocument()`) writes this value in its place, and
|
|
73
|
+
* `getCustomProperties` treats it the same as an empty value.
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* const css = '[data-bge-container] { --bge-options-margin--none: ; }'.replace(
|
|
77
|
+
* ': ;',
|
|
78
|
+
* `: ${EMPTY_CUSTOM_PROPERTY_VALUE};`,
|
|
79
|
+
* );
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
var EMPTY_CUSTOM_PROPERTY_VALUE = "--bge-empty-custom-property-value";
|
|
65
83
|
//#endregion
|
|
66
84
|
//#region ../core/dist/dom-helpers/sanitize-attrs.js
|
|
67
85
|
var removeAttrNameIgnoreList = /* @__PURE__ */ new Set([
|
|
@@ -274,21 +292,64 @@ function exportContainerProps(containerPropsQuery) {
|
|
|
274
292
|
};
|
|
275
293
|
}
|
|
276
294
|
//#endregion
|
|
295
|
+
//#region ../core/dist/block/parse-style-option-name.js
|
|
296
|
+
/**
|
|
297
|
+
* Split a style option custom property name into its category and key.
|
|
298
|
+
*
|
|
299
|
+
* `--bge-options-{category}` (the selected-value declaration) yields
|
|
300
|
+
* `key: null`; `--bge-options-{category}--{key}` (a choice) yields both.
|
|
301
|
+
* Option detection and the read-back of saved HTML both split through this
|
|
302
|
+
* function, so a name is offered as a choice exactly when it can be read
|
|
303
|
+
* back. Names that cannot be split unambiguously return `null`: an empty
|
|
304
|
+
* category or key, or more than one `--` after the prefix. Characters are
|
|
305
|
+
* otherwise not restricted.
|
|
306
|
+
* @param property - Custom property name, including the leading `--`
|
|
307
|
+
* @returns The category and key, or `null` when `property` is not a style
|
|
308
|
+
* option name
|
|
309
|
+
*/
|
|
310
|
+
function parseStyleOptionName(property) {
|
|
311
|
+
if (!property.startsWith("--bge-options-")) return null;
|
|
312
|
+
const segments = property.slice(BLOCK_OPTION_CSS_CUSTOM_PROPERTY_PREFIX.length).split("--");
|
|
313
|
+
const [category, key] = segments;
|
|
314
|
+
if (!category || segments.length > 2 || key === "") return null;
|
|
315
|
+
return {
|
|
316
|
+
category,
|
|
317
|
+
key: key ?? null
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
//#endregion
|
|
277
321
|
//#region ../core/dist/block/export-style-options.js
|
|
278
322
|
/**
|
|
323
|
+
* Read the selected style options back from a block container's inline
|
|
324
|
+
* `style`.
|
|
279
325
|
*
|
|
280
|
-
*
|
|
326
|
+
* Each `--bge-options-{category}: var(--bge-options-{category}--{key})`
|
|
327
|
+
* declaration becomes `{ [category]: key }`, which is the inverse of
|
|
328
|
+
* `importStyleOptions`. Names are split the same way the editor's option
|
|
329
|
+
* detection splits them, so any category and key the editor offers as a
|
|
330
|
+
* choice round-trips, whatever characters they use. Names containing `--`
|
|
331
|
+
* (or a category ending in `-`) cannot be split unambiguously and are
|
|
332
|
+
* ignored, as are declarations whose `var()` points at another category or
|
|
333
|
+
* that are not a single `var()` reference.
|
|
334
|
+
* @param el - Block container element whose inline `style` holds the options
|
|
335
|
+
* @returns Map of category to selected key
|
|
336
|
+
* @example
|
|
337
|
+
* ```ts
|
|
338
|
+
* el.setAttribute('style', '--bge-options-gap: var(--bge-options-gap--2x)');
|
|
339
|
+
* exportStyleOptions(el); // { gap: '2x' }
|
|
340
|
+
* ```
|
|
281
341
|
*/
|
|
282
342
|
function exportStyleOptions(el) {
|
|
283
343
|
const style = {};
|
|
284
344
|
const decl = el.style;
|
|
285
345
|
for (let i = 0; i < decl.length; i++) {
|
|
286
346
|
const property = decl.item(i);
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
347
|
+
const declared = parseStyleOptionName(property);
|
|
348
|
+
if (!declared || declared.key !== null) continue;
|
|
349
|
+
const reference = /^var\(\s*([^\s(),]+)\s*\)$/.exec(decl.getPropertyValue(property).trim())?.[1];
|
|
350
|
+
const referenced = reference ? parseStyleOptionName(reference) : null;
|
|
351
|
+
if (referenced?.key == null || referenced.category !== declared.category) continue;
|
|
352
|
+
style[declared.category] = referenced.key;
|
|
292
353
|
}
|
|
293
354
|
return style;
|
|
294
355
|
}
|
|
@@ -4707,7 +4768,7 @@ var CommandBus = class {
|
|
|
4707
4768
|
* stay stable and readable across a test run or a debugging session.
|
|
4708
4769
|
* Uniqueness holds only within one loaded copy of this module — the same
|
|
4709
4770
|
* caveat as the `BurgerBlock`/`Item` module-level registries documented
|
|
4710
|
-
* in ARCHITECTURE.md §
|
|
4771
|
+
* in ARCHITECTURE.md § 不変条件と負の知識 applies here too.
|
|
4711
4772
|
*/
|
|
4712
4773
|
receiverId = `${COMMAND_BUS_ID}-${++receiverSequence}`;
|
|
4713
4774
|
#detachers = /* @__PURE__ */ new Map();
|
|
@@ -4788,31 +4849,26 @@ function createStylesheet(cssContents, layer) {
|
|
|
4788
4849
|
return URL.createObjectURL(blob);
|
|
4789
4850
|
}
|
|
4790
4851
|
//#endregion
|
|
4791
|
-
//#region ../core/dist/dom-helpers/
|
|
4852
|
+
//#region ../core/dist/dom-helpers/editor-stylesheet-texts.js
|
|
4792
4853
|
/**
|
|
4793
|
-
*
|
|
4794
|
-
*
|
|
4795
|
-
*
|
|
4796
|
-
* @param
|
|
4854
|
+
* The first two texts of {@link editorStylesheetTexts}: the layer order
|
|
4855
|
+
* statement and the base layer. Separate so the engine can create them
|
|
4856
|
+
* before it fetches `config.stylesheets`.
|
|
4857
|
+
* @param items - Item seeds whose `style` is loaded
|
|
4858
|
+
* @param generalCSS - Shared block CSS
|
|
4797
4859
|
*/
|
|
4798
|
-
function
|
|
4799
|
-
|
|
4860
|
+
function editorBaseStylesheetTexts(items, generalCSS) {
|
|
4861
|
+
const itemStyles = Object.values(items).map((item) => item.style).filter(Boolean).join("\n");
|
|
4862
|
+
return [`@layer ${CSS_LAYER.base}, ${CSS_LAYER.components}, ${CSS_LAYER.ui};`, `@layer ${CSS_LAYER.base} {${itemStyles}\n${generalCSS}}`];
|
|
4800
4863
|
}
|
|
4801
|
-
//#endregion
|
|
4802
|
-
//#region ../core/dist/dom-helpers/create-stylesheet-from-url.js
|
|
4803
4864
|
/**
|
|
4804
|
-
*
|
|
4805
|
-
* @param
|
|
4806
|
-
* @param layer
|
|
4865
|
+
* One `config.stylesheets` entry as {@link editorStylesheetTexts} places it.
|
|
4866
|
+
* @param css - Stylesheet contents
|
|
4867
|
+
* @param layer - Cascade layer; the components layer when omitted, and no
|
|
4868
|
+
* layer at all for `''`
|
|
4807
4869
|
*/
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
const css = layer ? `@layer ${layer} {${cssContents}}` : cssContents;
|
|
4811
|
-
const blob = new Blob([css], { type: "text/css" });
|
|
4812
|
-
return {
|
|
4813
|
-
blob: URL.createObjectURL(blob),
|
|
4814
|
-
originalUrl: url
|
|
4815
|
-
};
|
|
4870
|
+
function editorProjectStylesheetText(css, layer = CSS_LAYER.components) {
|
|
4871
|
+
return layer ? `@layer ${layer} {${css}}` : css;
|
|
4816
4872
|
}
|
|
4817
4873
|
//#endregion
|
|
4818
4874
|
//#region ../core/dist/utils/compare-priority.js
|
|
@@ -4846,19 +4902,30 @@ function comparePriority(a, b) {
|
|
|
4846
4902
|
//#endregion
|
|
4847
4903
|
//#region ../core/dist/dom-helpers/get-custom-properties.js
|
|
4848
4904
|
/**
|
|
4849
|
-
* Get all custom properties from document
|
|
4905
|
+
* Get all `--bge-options-*` custom properties from document, grouped by
|
|
4906
|
+
* category. See the file-level comment for the detection rules.
|
|
4907
|
+
*
|
|
4908
|
+
* Inside the editor, call `engine.getCustomProperties()` instead; this
|
|
4909
|
+
* free function is for scanning a document the engine does not own, such
|
|
4910
|
+
* as stylesheets loaded into a jsdom document on Node.
|
|
4850
4911
|
* @param scope - Document to scan for CSS custom properties
|
|
4851
4912
|
* @param containerType - Container type to filter container-scoped properties (prefixed with `_`)
|
|
4852
4913
|
* @returns Categorized map of custom properties grouped by property name
|
|
4914
|
+
* @example
|
|
4915
|
+
* ```ts
|
|
4916
|
+
* for (const [id, category] of getCustomProperties(document, 'grid')) {
|
|
4917
|
+
* console.log(id, [...category.properties.keys()]); // 'margin' ['none', 'small', ...]
|
|
4918
|
+
* }
|
|
4919
|
+
* ```
|
|
4853
4920
|
*/
|
|
4854
4921
|
function getCustomProperties(scope, containerType) {
|
|
4855
4922
|
const categories = /* @__PURE__ */ new Map();
|
|
4856
4923
|
const defaultValues = /* @__PURE__ */ new Map();
|
|
4857
4924
|
const nestedDefaultValues = /* @__PURE__ */ new Map();
|
|
4858
4925
|
searchCustomProperty(scope, (cssProperty, value, layers, isNested) => {
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4926
|
+
const parsed = parseStyleOptionName(cssProperty);
|
|
4927
|
+
if (!parsed) return;
|
|
4928
|
+
const { category: propName, key } = parsed;
|
|
4862
4929
|
if (propName.startsWith("_") && !propName.startsWith(`_${containerType}_`)) return;
|
|
4863
4930
|
const currentMap = categories.get(propName) ?? {
|
|
4864
4931
|
id: propName,
|
|
@@ -4885,7 +4952,10 @@ function getCustomProperties(scope, containerType) {
|
|
|
4885
4952
|
targetMap.set(propName, currentDefaultValue ? compareCustomPropertyByLayerPriority(currentDefaultValue, newDefaultValue) : newDefaultValue);
|
|
4886
4953
|
}
|
|
4887
4954
|
});
|
|
4888
|
-
for (const propList of categories.values()) for (const [key, customProperty] of propList.properties.entries())
|
|
4955
|
+
for (const propList of categories.values()) for (const [key, customProperty] of propList.properties.entries()) {
|
|
4956
|
+
const value = customProperty.value.trim();
|
|
4957
|
+
if (value === "" || value === "--bge-empty-custom-property-value") propList.properties.delete(key);
|
|
4958
|
+
}
|
|
4889
4959
|
for (const [category, nestedProperty] of nestedDefaultValues.entries()) {
|
|
4890
4960
|
const directProperty = defaultValues.get(category);
|
|
4891
4961
|
if (directProperty) {
|
|
@@ -5019,9 +5089,11 @@ function searchCustomProperty(scope, found) {
|
|
|
5019
5089
|
const selector = rawSelector.replace(/^&/, "").trim();
|
|
5020
5090
|
if (selector === BLOCK_OPTION_SCOPE_SELECTOR || selector === ":scope" && cssRule.scopeRoot === BLOCK_OPTION_SCOPE_SELECTOR) {
|
|
5021
5091
|
const isNested = rawSelector !== selector;
|
|
5022
|
-
|
|
5092
|
+
const declarations = cssRule.rule.style;
|
|
5093
|
+
for (let i = 0; i < declarations.length; i++) {
|
|
5094
|
+
const cssProperty = declarations.item(i);
|
|
5023
5095
|
if (!cssProperty.startsWith("--")) continue;
|
|
5024
|
-
found(cssProperty,
|
|
5096
|
+
found(cssProperty, declarations.getPropertyValue(cssProperty), cssRule.layers, isNested);
|
|
5025
5097
|
}
|
|
5026
5098
|
}
|
|
5027
5099
|
}
|
|
@@ -5031,9 +5103,18 @@ function searchCustomProperty(scope, found) {
|
|
|
5031
5103
|
}
|
|
5032
5104
|
}
|
|
5033
5105
|
/**
|
|
5034
|
-
* Get repeat-min-inline-size variant definitions from document
|
|
5106
|
+
* Get repeat-min-inline-size variant definitions from document. Uses the
|
|
5107
|
+
* same detection rules as `getCustomProperties`, except that empty values
|
|
5108
|
+
* are not filtered out.
|
|
5109
|
+
*
|
|
5110
|
+
* Inside the editor, call `engine.getRepeatMinInlineSizeVariants()` instead.
|
|
5035
5111
|
* @param scope - Document to scan for `--bge-repeat-min-inline-size` variants
|
|
5036
5112
|
* @returns Category containing variant properties, or `null` if no variants found
|
|
5113
|
+
* @example
|
|
5114
|
+
* ```ts
|
|
5115
|
+
* const presets = getRepeatMinInlineSizeVariants(document);
|
|
5116
|
+
* const keys = presets ? [...presets.properties.keys()] : []; // ['small', 'medium', 'large']
|
|
5117
|
+
* ```
|
|
5037
5118
|
*/
|
|
5038
5119
|
function getRepeatMinInlineSizeVariants(scope) {
|
|
5039
5120
|
const PREFIX = "--bge-repeat-min-inline-size";
|
|
@@ -6010,6 +6091,29 @@ var BurgerEditorEngine = class BurgerEditorEngine {
|
|
|
6010
6091
|
if (!currentBlock) console.warn("block is unselected.");
|
|
6011
6092
|
return currentBlock;
|
|
6012
6093
|
}
|
|
6094
|
+
/**
|
|
6095
|
+
* List the block style options (`--bge-options-{category}--{key}`)
|
|
6096
|
+
* declared on `[data-bge-container]` in the stylesheets loaded into the
|
|
6097
|
+
* current editable area's document. This is what the block options
|
|
6098
|
+
* dialog renders as its style-option selects.
|
|
6099
|
+
*
|
|
6100
|
+
* The stylesheets are scanned on every call (no caching), so the result
|
|
6101
|
+
* reflects whatever is loaded at that moment. Detection rules (traversed
|
|
6102
|
+
* at-rules, layer priority, empty-value exclusion, default resolution)
|
|
6103
|
+
* are documented in
|
|
6104
|
+
* `dom-helpers/get-custom-properties.ts`.
|
|
6105
|
+
* @param containerType - Also include categories prefixed `_{containerType}_`
|
|
6106
|
+
* (e.g. `_grid_subgrid-gap` for `'grid'`); without it they are omitted
|
|
6107
|
+
* @returns Map keyed by category id; each category's `properties` maps
|
|
6108
|
+
* the key to its resolved `value` and whether it is the CSS default
|
|
6109
|
+
* @example
|
|
6110
|
+
* ```ts
|
|
6111
|
+
* for (const [id, category] of engine.getCustomProperties('grid')) {
|
|
6112
|
+
* const keys = [...category.properties.keys()];
|
|
6113
|
+
* console.log(id, category.name, keys); // '_grid_subgrid-gap' 'subgrid-gap' [...]
|
|
6114
|
+
* }
|
|
6115
|
+
* ```
|
|
6116
|
+
*/
|
|
6013
6117
|
getCustomProperties(containerType) {
|
|
6014
6118
|
return getCustomProperties(this.#current.containerElement.ownerDocument, containerType);
|
|
6015
6119
|
}
|
|
@@ -6061,6 +6165,27 @@ var BurgerEditorEngine = class BurgerEditorEngine {
|
|
|
6061
6165
|
getLiveBlocks() {
|
|
6062
6166
|
return listLiveBlocks(this.#current);
|
|
6063
6167
|
}
|
|
6168
|
+
/**
|
|
6169
|
+
* List the grid wrap-width presets (`--bge-repeat-min-inline-size--{key}`)
|
|
6170
|
+
* declared on `[data-bge-container]` in the current editable area's
|
|
6171
|
+
* document, used for the auto-fit / auto-fill "wrap width" select.
|
|
6172
|
+
*
|
|
6173
|
+
* Uses the same detection rules as {@link getCustomProperties}, except
|
|
6174
|
+
* that empty values are not filtered out. The default is the key
|
|
6175
|
+
* referenced by `--bge-repeat-min-inline-size: var(...)`. Each preset
|
|
6176
|
+
* also needs a selector rule in CSS that maps the container's
|
|
6177
|
+
* `--{key}` option to the variable; `general.css` ships it only for
|
|
6178
|
+
* `small` / `medium` / `large`.
|
|
6179
|
+
* @returns The preset category (id `'repeat-min-inline-size'`), or `null`
|
|
6180
|
+
* when no preset is declared
|
|
6181
|
+
* @example
|
|
6182
|
+
* ```ts
|
|
6183
|
+
* const presets = engine.getRepeatMinInlineSizeVariants();
|
|
6184
|
+
* const defaultKey = presets
|
|
6185
|
+
* ? [...presets.properties].find(([, p]) => p.isDefault)?.[0]
|
|
6186
|
+
* : undefined; // 'medium' with the bundled general.css
|
|
6187
|
+
* ```
|
|
6188
|
+
*/
|
|
6064
6189
|
getRepeatMinInlineSizeVariants() {
|
|
6065
6190
|
return getRepeatMinInlineSizeVariants(this.#current.containerElement.ownerDocument);
|
|
6066
6191
|
}
|
|
@@ -6196,34 +6321,23 @@ var BurgerEditorEngine = class BurgerEditorEngine {
|
|
|
6196
6321
|
}
|
|
6197
6322
|
}
|
|
6198
6323
|
static async #finishConstruction(engine, options) {
|
|
6199
|
-
const
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6324
|
+
const createDisposableStylesheet = (css, id) => {
|
|
6325
|
+
const path = createStylesheet(css);
|
|
6326
|
+
engine.#disposables.defer(() => {
|
|
6327
|
+
URL.revokeObjectURL(path);
|
|
6328
|
+
});
|
|
6329
|
+
return {
|
|
6330
|
+
path,
|
|
6331
|
+
id
|
|
6332
|
+
};
|
|
6333
|
+
};
|
|
6334
|
+
const [layerOrderCss, baseCss] = editorBaseStylesheetTexts(options.items, options.generalCSS);
|
|
6335
|
+
const baseStylesheets = [createDisposableStylesheet(layerOrderCss, "layers"), createDisposableStylesheet(baseCss, "base-stylesheet")];
|
|
6336
|
+
const cssContents = await Promise.all(options.config.stylesheets.map(async (stylesheet) => {
|
|
6337
|
+
return (await fetch(stylesheet.path)).text();
|
|
6209
6338
|
}));
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
});
|
|
6213
|
-
const stylesheets = [
|
|
6214
|
-
{
|
|
6215
|
-
path: layers,
|
|
6216
|
-
id: "layers"
|
|
6217
|
-
},
|
|
6218
|
-
{
|
|
6219
|
-
path: baseStylesheet,
|
|
6220
|
-
id: "base-stylesheet"
|
|
6221
|
-
},
|
|
6222
|
-
...componentStylesheets.map(({ blob, originalUrl }) => ({
|
|
6223
|
-
path: blob,
|
|
6224
|
-
id: originalUrl
|
|
6225
|
-
}))
|
|
6226
|
-
];
|
|
6339
|
+
const componentStylesheets = options.config.stylesheets.map((stylesheet, index) => createDisposableStylesheet(editorProjectStylesheetText(cssContents[index], stylesheet.layer), stylesheet.path));
|
|
6340
|
+
const stylesheets = [...baseStylesheets, ...componentStylesheets];
|
|
6227
6341
|
const mainInitialContent = typeof options.initialContents === "string" ? options.initialContents : options.initialContents.main;
|
|
6228
6342
|
engine.#view = options.view ?? createDefaultView();
|
|
6229
6343
|
engine.#disposables.use(engine.#view);
|
|
@@ -8511,7 +8625,7 @@ var require_omap = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
8511
8625
|
var _toString = Object.prototype.toString;
|
|
8512
8626
|
function resolveYamlOmap(data) {
|
|
8513
8627
|
if (data === null) return true;
|
|
8514
|
-
var objectKeys =
|
|
8628
|
+
var objectKeys = {}, index, length, pair, pairKey, pairHasKey, object = data;
|
|
8515
8629
|
for (index = 0, length = object.length; index < length; index += 1) {
|
|
8516
8630
|
pair = object[index];
|
|
8517
8631
|
pairHasKey = false;
|
|
@@ -8521,8 +8635,8 @@ var require_omap = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
8521
8635
|
else return false;
|
|
8522
8636
|
}
|
|
8523
8637
|
if (!pairHasKey) return false;
|
|
8524
|
-
if (
|
|
8525
|
-
|
|
8638
|
+
if (_hasOwnProperty.call(objectKeys, pairKey)) return false;
|
|
8639
|
+
Object.defineProperty(objectKeys, pairKey, { value: true });
|
|
8526
8640
|
}
|
|
8527
8641
|
return true;
|
|
8528
8642
|
}
|
|
@@ -14130,6 +14244,7 @@ var require_loader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
14130
14244
|
this.legacy = options["legacy"] || false;
|
|
14131
14245
|
this.json = options["json"] || false;
|
|
14132
14246
|
this.listener = options["listener"] || null;
|
|
14247
|
+
this.maxTotalMergeKeys = typeof options["maxTotalMergeKeys"] === "number" ? options["maxTotalMergeKeys"] : 1e4;
|
|
14133
14248
|
this.implicitTypes = this.schema.compiledImplicit;
|
|
14134
14249
|
this.typeMap = this.schema.compiledTypeMap;
|
|
14135
14250
|
this.length = input.length;
|
|
@@ -14137,6 +14252,7 @@ var require_loader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
14137
14252
|
this.line = 0;
|
|
14138
14253
|
this.lineStart = 0;
|
|
14139
14254
|
this.lineIndent = 0;
|
|
14255
|
+
this.totalMergeKeys = 0;
|
|
14140
14256
|
this.documents = [];
|
|
14141
14257
|
}
|
|
14142
14258
|
function generateError(state, message) {
|
|
@@ -14185,12 +14301,18 @@ var require_loader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
14185
14301
|
state.result += _result;
|
|
14186
14302
|
}
|
|
14187
14303
|
}
|
|
14304
|
+
function chargeMergeWork(state) {
|
|
14305
|
+
state.totalMergeKeys += 1;
|
|
14306
|
+
if (state.maxTotalMergeKeys !== -1 && state.totalMergeKeys > state.maxTotalMergeKeys) throwError(state, "merge keys exceeded maxTotalMergeKeys (" + state.maxTotalMergeKeys + ")");
|
|
14307
|
+
}
|
|
14188
14308
|
function mergeMappings(state, destination, source, overridableKeys) {
|
|
14189
14309
|
var sourceKeys, key, index, quantity;
|
|
14190
14310
|
if (!common.isObject(source)) throwError(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
14311
|
+
chargeMergeWork(state);
|
|
14191
14312
|
sourceKeys = Object.keys(source);
|
|
14192
14313
|
for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
|
|
14193
14314
|
key = sourceKeys[index];
|
|
14315
|
+
chargeMergeWork(state);
|
|
14194
14316
|
if (!_hasOwnProperty.call(destination, key)) {
|
|
14195
14317
|
setProperty(destination, key, source[key]);
|
|
14196
14318
|
overridableKeys[key] = true;
|
|
@@ -14210,8 +14332,10 @@ var require_loader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
14210
14332
|
keyNode = String(keyNode);
|
|
14211
14333
|
if (_result === null) _result = {};
|
|
14212
14334
|
if (keyTag === "tag:yaml.org,2002:merge") {
|
|
14213
|
-
if (Array.isArray(valueNode))
|
|
14214
|
-
|
|
14335
|
+
if (Array.isArray(valueNode)) {
|
|
14336
|
+
if (valueNode.length > 100) throwError(state, "abnormal merge sequence size");
|
|
14337
|
+
for (index = 0, quantity = valueNode.length; index < quantity; index += 1) mergeMappings(state, _result, valueNode[index], overridableKeys);
|
|
14338
|
+
} else mergeMappings(state, _result, valueNode, overridableKeys);
|
|
14215
14339
|
} else {
|
|
14216
14340
|
if (!state.json && !_hasOwnProperty.call(overridableKeys, keyNode) && _hasOwnProperty.call(_result, keyNode)) {
|
|
14217
14341
|
state.line = startLine || state.line;
|
|
@@ -15764,9 +15888,9 @@ var EngineContext = createContext(null);
|
|
|
15764
15888
|
* rendered under a `BurgerEditorRoot` / editable-area tree reads the engine
|
|
15765
15889
|
* through {@link useEngine} instead of taking it as a prop — this is the
|
|
15766
15890
|
* single dependency-injection point for the whole client UI.
|
|
15767
|
-
* @param root0
|
|
15768
|
-
* @param root0.engine
|
|
15769
|
-
* @param root0.children
|
|
15891
|
+
* @param root0 - Provider props
|
|
15892
|
+
* @param root0.engine - The engine instance to expose to the subtree
|
|
15893
|
+
* @param root0.children - The subtree that reads the engine
|
|
15770
15894
|
* @example
|
|
15771
15895
|
* ```tsx
|
|
15772
15896
|
* <EngineProvider engine={engine}>
|
|
@@ -15788,9 +15912,12 @@ function EngineProvider({ engine, children }) {
|
|
|
15788
15912
|
* @throws {Error} When called outside an `EngineProvider`
|
|
15789
15913
|
* @example
|
|
15790
15914
|
* ```tsx
|
|
15791
|
-
* function
|
|
15792
|
-
* const
|
|
15793
|
-
*
|
|
15915
|
+
* function SamplePreview() {
|
|
15916
|
+
* const { config } = useEngine();
|
|
15917
|
+
* if (!config.sampleImagePath) {
|
|
15918
|
+
* return null;
|
|
15919
|
+
* }
|
|
15920
|
+
* return <img src={config.sampleImagePath} alt="" />;
|
|
15794
15921
|
* }
|
|
15795
15922
|
* ```
|
|
15796
15923
|
*/
|
|
@@ -15802,4 +15929,4 @@ function useEngine() {
|
|
|
15802
15929
|
//#endregion
|
|
15803
15930
|
export { UIStateStore as a, CommandBus as c, formatDate as d, CSS_LAYER as f, BurgerEditorEngine as i, Item as l, useEngine as n, createBgeEvent as o, getBlockAtPosition as r, beginProcessing as s, EngineProvider as t, formatByteSize as u };
|
|
15804
15931
|
|
|
15805
|
-
//# sourceMappingURL=engine-context-
|
|
15932
|
+
//# sourceMappingURL=engine-context-j4-LLPEh.js.map
|