@burger-editor/client 4.0.0-alpha.72 → 4.0.0-alpha.73

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.
Files changed (85) hide show
  1. package/README.md +22 -9
  2. package/dist/__tests__/setup.d.ts +2 -0
  3. package/dist/__tests__/setup.d.ts.map +1 -0
  4. package/dist/burger-editor-root.d.ts +3 -7
  5. package/dist/burger-editor-root.d.ts.map +1 -1
  6. package/dist/client.js +323 -133
  7. package/dist/client.js.map +1 -1
  8. package/dist/commands/register-engine-commands.d.ts +2 -1
  9. package/dist/commands/register-engine-commands.d.ts.map +1 -1
  10. package/dist/components/block-catalog.d.ts +3 -5
  11. package/dist/components/block-catalog.d.ts.map +1 -1
  12. package/dist/components/block-menu-button.d.ts +1 -1
  13. package/dist/components/block-menu-view.d.ts +7 -3
  14. package/dist/components/block-menu-view.d.ts.map +1 -1
  15. package/dist/components/block-menu.d.ts +2 -5
  16. package/dist/components/block-menu.d.ts.map +1 -1
  17. package/dist/components/block-options.d.ts +4 -6
  18. package/dist/components/block-options.d.ts.map +1 -1
  19. package/dist/components/draft-switcher.d.ts +11 -10
  20. package/dist/components/draft-switcher.d.ts.map +1 -1
  21. package/dist/components/editable-area-view.d.ts +11 -14
  22. package/dist/components/editable-area-view.d.ts.map +1 -1
  23. package/dist/components/file-list.d.ts +9 -9
  24. package/dist/components/file-list.d.ts.map +1 -1
  25. package/dist/components/file-uploader.d.ts +6 -6
  26. package/dist/components/file-uploader.d.ts.map +1 -1
  27. package/dist/components/front-matter-editor.d.ts +43 -11
  28. package/dist/components/front-matter-editor.d.ts.map +1 -1
  29. package/dist/components/index.d.ts +2 -2
  30. package/dist/components/index.d.ts.map +1 -1
  31. package/dist/components/initial-insertion-button.d.ts +7 -2
  32. package/dist/components/initial-insertion-button.d.ts.map +1 -1
  33. package/dist/components/item-editor-host.d.ts +7 -6
  34. package/dist/components/item-editor-host.d.ts.map +1 -1
  35. package/dist/components/preview.d.ts +4 -7
  36. package/dist/components/preview.d.ts.map +1 -1
  37. package/dist/components/table-editor.d.ts.map +1 -1
  38. package/dist/components/wysiwyg-field.d.ts +11 -1
  39. package/dist/components/wysiwyg-field.d.ts.map +1 -1
  40. package/dist/editable-area-view-DssYcTqQ.js +2941 -0
  41. package/dist/editable-area-view-DssYcTqQ.js.map +1 -0
  42. package/dist/editor-dialog.d.ts +16 -7
  43. package/dist/editor-dialog.d.ts.map +1 -1
  44. package/dist/{editable-area-view-C00DSDVk.js → engine-context-gX6mWHke.js} +199 -1951
  45. package/dist/engine-context-gX6mWHke.js.map +1 -0
  46. package/dist/engine-context.d.ts +40 -0
  47. package/dist/engine-context.d.ts.map +1 -0
  48. package/dist/file-browser/store.d.ts +127 -0
  49. package/dist/file-browser/store.d.ts.map +1 -0
  50. package/dist/file-browser/use-external-file-selection.d.ts +39 -0
  51. package/dist/file-browser/use-external-file-selection.d.ts.map +1 -0
  52. package/dist/file-browser/use-file-browser.d.ts +17 -0
  53. package/dist/file-browser/use-file-browser.d.ts.map +1 -0
  54. package/dist/form/text-field.d.ts +3 -1
  55. package/dist/form/text-field.d.ts.map +1 -1
  56. package/dist/index.d.ts +4 -0
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/mount.d.ts +6 -1
  59. package/dist/mount.d.ts.map +1 -1
  60. package/dist/root-error-boundary.d.ts +34 -0
  61. package/dist/root-error-boundary.d.ts.map +1 -0
  62. package/dist/testing/create-mock-engine.d.ts +30 -0
  63. package/dist/testing/create-mock-engine.d.ts.map +1 -0
  64. package/dist/testing/index.d.ts +4 -0
  65. package/dist/testing/index.d.ts.map +1 -0
  66. package/dist/testing/render-with-engine.d.ts +20 -0
  67. package/dist/testing/render-with-engine.d.ts.map +1 -0
  68. package/dist/testing/suppress-console-error.d.ts +24 -0
  69. package/dist/testing/suppress-console-error.d.ts.map +1 -0
  70. package/dist/testing.js +119 -0
  71. package/dist/testing.js.map +1 -0
  72. package/dist/ui.d.ts +7 -1
  73. package/dist/ui.d.ts.map +1 -1
  74. package/dist/ui.js +1618 -537
  75. package/dist/ui.js.map +1 -1
  76. package/dist/use-command.d.ts +13 -4
  77. package/dist/use-command.d.ts.map +1 -1
  78. package/dist/use-engine.d.ts +16 -32
  79. package/dist/use-engine.d.ts.map +1 -1
  80. package/dist/use-mount-effect.d.ts +20 -0
  81. package/dist/use-mount-effect.d.ts.map +1 -0
  82. package/dist/view/create-react-view.d.ts +33 -9
  83. package/dist/view/create-react-view.d.ts.map +1 -1
  84. package/package.json +44 -17
  85. package/dist/editable-area-view-C00DSDVk.js.map +0 -1
@@ -1,7 +1,4 @@
1
- import { Fragment, createElement, forwardRef, useCallback, useEffect, useId, useMemo, useRef, useState, useSyncExternalStore } from "react";
2
- import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
3
- import { createRoot } from "react-dom/client";
4
- import { createPortal } from "react-dom";
1
+ import { createContext, createElement, use } from "react";
5
2
  //#region \0rolldown/runtime.js
6
3
  var __create = Object.create;
7
4
  var __defProp = Object.defineProperty;
@@ -396,25 +393,6 @@ function blinkOnce(el) {
396
393
  });
397
394
  }
398
395
  //#endregion
399
- //#region ../utils/dist/append-stylesheet-to.js
400
- /**
401
- * Append a `<link rel="stylesheet">` to a document's `<head>`.
402
- * @param doc - The target document
403
- * @param url - The stylesheet URL (often a blob URL)
404
- * @param id - A cache-busting fragment identifier appended to `url`
405
- * @example
406
- * ```ts
407
- * appendStylesheetTo(iframeDoc, blobUrl, 'block-menu-ui');
408
- * ```
409
- */
410
- function appendStylesheetTo(doc, url, id) {
411
- const link = doc.createElement("link");
412
- link.rel = "stylesheet";
413
- link.crossOrigin = "anonymous";
414
- link.href = `${url}#${id}`;
415
- doc.head.append(link);
416
- }
417
- //#endregion
418
396
  //#region ../utils/dist/camel-case.js
419
397
  var camelCaseCache = /* @__PURE__ */ new Map();
420
398
  /**
@@ -840,8 +818,8 @@ var w = class {
840
818
  `).split(`
841
819
  `), r = "", i = "", s = [];
842
820
  for (; n.length > 0;) {
843
- let a = !1, o = [], l;
844
- for (l = 0; l < n.length; l++) if (this.rules.other.blockquoteStart.test(n[l])) o.push(n[l]), a = !0;
821
+ let a = !1, o = [], l = 0;
822
+ for (; l < n.length; l++) if (this.rules.other.blockquoteStart.test(n[l])) o.push(n[l]), a = !0;
845
823
  else if (!a) o.push(n[l]);
846
824
  else break;
847
825
  n = n.slice(l);
@@ -3329,6 +3307,20 @@ var DANGEROUS_ELEMENTS = [
3329
3307
  "applet"
3330
3308
  ];
3331
3309
  /**
3310
+ * `data-*-list` の子要素で、DOM 順と配列データの index が逆になる要素。
3311
+ * `picture` は HTML 仕様上 `source` が先・`img` が最後だが、配列データでは
3312
+ * `img` が index 0(元画像)に対応する。抽出(getComponent)と適用
3313
+ * (setComponent)の両方でこの対応関係を共有する
3314
+ */
3315
+ var REVERSE_LIST_ELEMENTS = ["picture"];
3316
+ /**
3317
+ * 要素が逆順リスト({@link REVERSE_LIST_ELEMENTS})かどうかを判定する
3318
+ * @param el
3319
+ */
3320
+ function isReverseListElement(el) {
3321
+ return REVERSE_LIST_ELEMENTS.includes(el.localName);
3322
+ }
3323
+ /**
3332
3324
  *
3333
3325
  * @param kvs
3334
3326
  */
@@ -3516,7 +3508,6 @@ function propInElement(el, name) {
3516
3508
  }
3517
3509
  //#endregion
3518
3510
  //#region ../frozen-patty/dist/get-component.js
3519
- var reverseListElementSelectors = ["picture"];
3520
3511
  /**
3521
3512
  *
3522
3513
  * @param el
@@ -3526,7 +3517,7 @@ var reverseListElementSelectors = ["picture"];
3526
3517
  */
3527
3518
  function getComponent(el, attr, typeConvert, filter) {
3528
3519
  el = el.cloneNode(true);
3529
- const reverseListElements = el.querySelectorAll(`:is(${reverseListElementSelectors.join(",")})[data-${attr}-list]`);
3520
+ const reverseListElements = el.querySelectorAll(`:is(${REVERSE_LIST_ELEMENTS.join(",")})[data-${attr}-list]`);
3530
3521
  for (const reverseListElement of reverseListElements) {
3531
3522
  const children = [];
3532
3523
  while (reverseListElement.lastElementChild) {
@@ -3947,19 +3938,18 @@ function setComponent(el, data, attr, filter, xssSanitize = true) {
3947
3938
  for (const targetEl of targetList) setValue(targetEl, dataKeyName, datum, attr, filter, xssSanitize);
3948
3939
  }
3949
3940
  for (const listRoot of el.querySelectorAll(`[data-${attr}-list]`)) {
3941
+ const reverse = isReverseListElement(listRoot);
3950
3942
  const decendants = listRoot.querySelectorAll("*");
3951
3943
  const maxLength = maxLengthOf(data, [...new Set([...decendants].flatMap((el) => definedFields(el, attr)))]);
3952
- const listItem = listRoot.children[0]?.cloneNode(true);
3944
+ const listItem = (reverse ? listRoot.lastElementChild : listRoot.firstElementChild)?.cloneNode(true);
3953
3945
  if (!listItem) continue;
3954
3946
  while (listRoot.firstChild) listRoot.firstChild.remove();
3955
3947
  const usedPaths = /* @__PURE__ */ new Set();
3956
3948
  for (let i = 0; i < maxLength; i++) {
3957
3949
  let item = listItem.cloneNode(true);
3958
3950
  const itemData = flattenData(data, i);
3959
- let reverse = false;
3960
3951
  switch (listRoot.localName) {
3961
3952
  case "picture": {
3962
- reverse = true;
3963
3953
  const pathValue = itemData.path;
3964
3954
  if (pathValue != null && usedPaths.has(String(pathValue))) continue;
3965
3955
  if (pathValue != null) usedPaths.add(String(pathValue));
@@ -4624,19 +4614,24 @@ function asDisposableFn(fn) {
4624
4614
  //#endregion
4625
4615
  //#region ../core/dist/command/command-bus.js
4626
4616
  /**
4627
- * The id assigned to every command bus receiver element.
4617
+ * Prefix for the id assigned to every command bus receiver element.
4628
4618
  *
4629
- * Buttons address the engine with `commandfor="bge-command-bus"`. The id is
4630
- * unique per document, not per page: the engine installs one receiver in the
4631
- * main document and one in each EditableArea iframe, because `commandfor`
4632
- * can only reference an id within its own document and `CommandEvent` does
4633
- * not bubble.
4619
+ * Buttons address the engine with `commandfor={engine.commandBus.receiverId}`.
4620
+ * The receiver is unique per document, not per page: the engine installs one
4621
+ * in the main document and one in each EditableArea iframe, because
4622
+ * `commandfor` can only reference an id within its own document and
4623
+ * `CommandEvent` does not bubble.
4624
+ * @deprecated Use {@link CommandBus.receiverId} on the bus instance instead.
4625
+ * This constant is only the id's prefix — a fixed id would collide when two
4626
+ * engines share the same document, so each `CommandBus` appends its own
4627
+ * sequence number.
4634
4628
  * @example
4635
4629
  * ```tsx
4636
- * <button command="--remove-block" commandfor={COMMAND_BUS_ID}>削除</button>
4630
+ * <button command="--remove-block" commandfor={engine.commandBus.receiverId}>削除</button>
4637
4631
  * ```
4638
4632
  */
4639
4633
  var COMMAND_BUS_ID = "bge-command-bus";
4634
+ var receiverSequence = 0;
4640
4635
  /**
4641
4636
  * Centralized dispatcher for Invoker Commands API custom commands.
4642
4637
  *
@@ -4652,10 +4647,22 @@ var COMMAND_BUS_ID = "bge-command-bus";
4652
4647
  * // ...
4653
4648
  * });
4654
4649
  * bus.createReceiver(document.body);
4655
- * // <button command="--my-action" commandfor="bge-command-bus" value="x">
4650
+ * // <button command="--my-action" commandfor={bus.receiverId} value="x">
4656
4651
  * ```
4657
4652
  */
4658
4653
  var CommandBus = class {
4654
+ /**
4655
+ * Id of this bus's receiver element, unique within the page. Buttons
4656
+ * address this bus with `commandfor={bus.receiverId}` (or, from UI code,
4657
+ * `engine.commandBus.receiverId`).
4658
+ *
4659
+ * A monotonically increasing counter rather than a random value, so ids
4660
+ * stay stable and readable across a test run or a debugging session.
4661
+ * Uniqueness holds only within one loaded copy of this module — the same
4662
+ * caveat as the `BurgerBlock`/`Item` module-level registries documented
4663
+ * in ARCHITECTURE.md § 不変条件と否定的知識 applies here too.
4664
+ */
4665
+ receiverId = `${COMMAND_BUS_ID}-${++receiverSequence}`;
4659
4666
  #detachers = /* @__PURE__ */ new Map();
4660
4667
  #handlers = /* @__PURE__ */ new Map();
4661
4668
  [Symbol.dispose]() {
@@ -4669,7 +4676,7 @@ var CommandBus = class {
4669
4676
  */
4670
4677
  createReceiver(parent) {
4671
4678
  const receiver = parent.ownerDocument.createElement("div");
4672
- receiver.id = COMMAND_BUS_ID;
4679
+ receiver.id = this.receiverId;
4673
4680
  receiver.hidden = true;
4674
4681
  parent.append(receiver);
4675
4682
  this.listen(receiver);
@@ -4716,68 +4723,12 @@ var CommandBus = class {
4716
4723
  #destroy() {
4717
4724
  for (const [receiver, detach] of this.#detachers) {
4718
4725
  detach();
4719
- if (receiver.id === "bge-command-bus") receiver.remove();
4726
+ if (receiver.id === this.receiverId) receiver.remove();
4720
4727
  }
4721
4728
  this.#detachers.clear();
4722
4729
  }
4723
4730
  };
4724
4731
  //#endregion
4725
- //#region ../core/dist/component-observer.js
4726
- var instanceId = 0;
4727
- var ComponentObserver = class {
4728
- #instanceId;
4729
- #listeners = /* @__PURE__ */ new Map();
4730
- constructor() {
4731
- this.#instanceId = instanceId++;
4732
- }
4733
- [Symbol.dispose]() {
4734
- this.#off();
4735
- }
4736
- /**
4737
- * Dispatch a custom event on the window.
4738
- * @template A - The action type key
4739
- * @param name - The action name to dispatch
4740
- * @param payload - The event payload matching the action type
4741
- */
4742
- notify(name, payload) {
4743
- window.dispatchEvent(new CustomEvent(`bge:_${this.#instanceId}_:${name}`, { detail: payload }));
4744
- }
4745
- /**
4746
- * Remove all registered event listeners and clear the internal map.
4747
- * @deprecated Use a `using` declaration instead — this now only
4748
- * forwards to `[Symbol.dispose]`.
4749
- */
4750
- off() {
4751
- this[Symbol.dispose]();
4752
- }
4753
- /**
4754
- * Register an event listener. Each call creates a separate wrapper,
4755
- * so calling with the same listener multiple times will fire it
4756
- * multiple times per event.
4757
- * @template A - The action type key
4758
- * @param name - The action name to listen for
4759
- * @param listener - Callback receiving the typed payload
4760
- * @returns A function that removes this listener only, also `Disposable`
4761
- * so it can be held in a `using` declaration
4762
- */
4763
- on(name, listener) {
4764
- const wrapper = (e) => {
4765
- listener(e.detail);
4766
- };
4767
- this.#listeners.set(wrapper, name);
4768
- window.addEventListener(`bge:_${this.#instanceId}_:${name}`, wrapper);
4769
- const remove = () => {
4770
- window.removeEventListener(`bge:_${this.#instanceId}_:${name}`, wrapper);
4771
- this.#listeners.delete(wrapper);
4772
- };
4773
- return asDisposableFn(remove);
4774
- }
4775
- #off() {
4776
- for (const [wrapper, name] of this.#listeners) window.removeEventListener(`bge:_${this.#instanceId}_:${name}`, wrapper);
4777
- this.#listeners.clear();
4778
- }
4779
- };
4780
- //#endregion
4781
4732
  //#region ../core/dist/dom-helpers/create-stylesheet.js
4782
4733
  /**
4783
4734
  *
@@ -5051,7 +5002,7 @@ function getRepeatMinInlineSizeVariants(scope) {
5051
5002
  baseRef.value = value;
5052
5003
  baseRef.priority = newPriority;
5053
5004
  }
5054
- } else if (cssProperty.startsWith("--bge-repeat-min-inline-size--")) {
5005
+ } else if (cssProperty.startsWith(PREFIX + "--")) {
5055
5006
  const key = cssProperty.slice(30);
5056
5007
  const newProperty = {
5057
5008
  value,
@@ -5118,14 +5069,24 @@ var NoHTMLElementError = class extends Error {
5118
5069
  //#endregion
5119
5070
  //#region ../core/dist/dom-helpers/get-element.js
5120
5071
  /**
5072
+ * Resolve the engine's root element.
5121
5073
  *
5122
- * @param selector
5123
- */
5124
- function getElement(selector) {
5125
- const node = document.querySelector(selector);
5126
- if (node === null) throw new ElementNotFoundError(selector);
5074
+ * `target` is either a CSS selector (resolved via `document.querySelector`,
5075
+ * first match wins) or an element handed in directly. Passing an element is
5076
+ * how two engines share one document without fighting over the same
5077
+ * selector — pass distinct elements instead of a selector that would
5078
+ * resolve both engines to the same node.
5079
+ * @param target - A CSS selector or an `HTMLElement`
5080
+ */
5081
+ function getElement(target) {
5082
+ if (typeof target !== "string") {
5083
+ if (!target) throw new ElementNotFoundError("(root element)", { additionalMessage: "root was passed as an element reference but resolved to null/undefined" });
5084
+ return target;
5085
+ }
5086
+ const node = document.querySelector(target);
5087
+ if (node === null) throw new ElementNotFoundError(target);
5127
5088
  if (node instanceof HTMLElement) return node;
5128
- throw new NoHTMLElementError(selector);
5089
+ throw new NoHTMLElementError(target);
5129
5090
  }
5130
5091
  //#endregion
5131
5092
  //#region ../core/dist/engine/processing-scope.js
@@ -5682,12 +5643,17 @@ async function applyLiveBlockOp(engine, content, op, options = {}) {
5682
5643
  * returns an immutable state object that is replaced on every change.
5683
5644
  *
5684
5645
  * The engine owns the store and performs all transitions; the UI layer
5685
- * only subscribes and renders.
5646
+ * only subscribes and renders. `subscribe` / `getSnapshot` are arrow
5647
+ * class fields (not prototype methods) so each instance's copy has a
5648
+ * stable identity across calls — the UI layer can pass
5649
+ * `engine.uiState.subscribe` directly to `useSyncExternalStore` without
5650
+ * wrapping it in a new closure every render (which would otherwise
5651
+ * unsubscribe and resubscribe on every render for no reason).
5686
5652
  * @example
5687
5653
  * ```ts
5688
5654
  * const state = useSyncExternalStore(
5689
- * (cb) => engine.uiState.subscribe(cb),
5690
- * () => engine.uiState.getSnapshot(),
5655
+ * engine.uiState.subscribe,
5656
+ * engine.uiState.getSnapshot,
5691
5657
  * );
5692
5658
  * if (state.openDialog?.type === 'item-editor') {
5693
5659
  * // render the item editor for state.openDialog.item
@@ -5695,6 +5661,21 @@ async function applyLiveBlockOp(engine, content, op, options = {}) {
5695
5661
  * ```
5696
5662
  */
5697
5663
  var UIStateStore = class {
5664
+ /**
5665
+ * @returns The current immutable UI state
5666
+ */
5667
+ getSnapshot = () => this.#state;
5668
+ /**
5669
+ * Register a change listener.
5670
+ * @param listener - Invoked after every state transition
5671
+ * @returns A function that removes the listener
5672
+ */
5673
+ subscribe = (listener) => {
5674
+ this.#listeners.add(listener);
5675
+ return () => {
5676
+ this.#listeners.delete(listener);
5677
+ };
5678
+ };
5698
5679
  #listeners = /* @__PURE__ */ new Set();
5699
5680
  #state = {
5700
5681
  openDialog: null,
@@ -5702,7 +5683,9 @@ var UIStateStore = class {
5702
5683
  sourceMode: {
5703
5684
  main: false,
5704
5685
  draft: false
5705
- }
5686
+ },
5687
+ activeArea: "main",
5688
+ currentBlock: null
5706
5689
  };
5707
5690
  /**
5708
5691
  * Close the currently open dialog, if any.
@@ -5712,12 +5695,6 @@ var UIStateStore = class {
5712
5695
  this.#set({ openDialog: null });
5713
5696
  }
5714
5697
  /**
5715
- * @returns The current immutable UI state
5716
- */
5717
- getSnapshot() {
5718
- return this.#state;
5719
- }
5720
- /**
5721
5698
  * Present the block catalog dialog.
5722
5699
  */
5723
5700
  openBlockCatalog() {
@@ -5738,12 +5715,35 @@ var UIStateStore = class {
5738
5715
  * @param item - The content item being edited
5739
5716
  */
5740
5717
  openItemEditor(item) {
5718
+ const containerType = item.el.closest(BLOCK_OPTION_SCOPE_SELECTOR)?.dataset["bgeContainer"];
5741
5719
  this.#set({ openDialog: {
5742
5720
  type: "item-editor",
5743
- item
5721
+ item,
5722
+ containerType
5744
5723
  } });
5745
5724
  }
5746
5725
  /**
5726
+ * Record which editable area is currently shown. Called by
5727
+ * `engine.showMain()` / `engine.showDraft()` — not part of the public
5728
+ * UI-facing API (there is no reason for UI code to switch areas
5729
+ * without going through the engine).
5730
+ * @param area - The area now on screen
5731
+ */
5732
+ setActiveArea(area) {
5733
+ if (this.#state.activeArea === area) return;
5734
+ this.#set({ activeArea: area });
5735
+ }
5736
+ /**
5737
+ * Record the hover-selected block, or clear it. Called by
5738
+ * `engine.setCurrentBlock()` / `engine.clearCurrentBlock()`.
5739
+ * @param block - The newly selected block, or `null` to clear
5740
+ */
5741
+ setCurrentBlock(block) {
5742
+ if (this.#state.currentBlock === block) return;
5743
+ if (this.#state.currentBlock && block && this.#state.currentBlock.is(block)) return;
5744
+ this.#set({ currentBlock: block });
5745
+ }
5746
+ /**
5747
5747
  * Mark an engine mutation (block insertion, move, etc.) as in
5748
5748
  * progress or finished.
5749
5749
  * @param processing - Whether a mutation is in progress
@@ -5766,17 +5766,6 @@ var UIStateStore = class {
5766
5766
  } });
5767
5767
  }
5768
5768
  /**
5769
- * Register a change listener.
5770
- * @param listener - Invoked after every state transition
5771
- * @returns A function that removes the listener
5772
- */
5773
- subscribe(listener) {
5774
- this.#listeners.add(listener);
5775
- return () => {
5776
- this.#listeners.delete(listener);
5777
- };
5778
- }
5779
- /**
5780
5769
  * Toggle an editable area between visual and HTML source editing.
5781
5770
  * @param type - The editable area to toggle
5782
5771
  */
@@ -5796,7 +5785,6 @@ var UIStateStore = class {
5796
5785
  var BurgerEditorEngine = class BurgerEditorEngine {
5797
5786
  catalog;
5798
5787
  commandBus = new CommandBus();
5799
- componentObserver = new ComponentObserver();
5800
5788
  config;
5801
5789
  css;
5802
5790
  el;
@@ -5807,7 +5795,6 @@ var BurgerEditorEngine = class BurgerEditorEngine {
5807
5795
  viewArea;
5808
5796
  #contentStylesheetCache = null;
5809
5797
  #current;
5810
- #currentBlock = null;
5811
5798
  #disposables = new DisposableStack();
5812
5799
  #draft;
5813
5800
  #healthMonitor;
@@ -5845,7 +5832,6 @@ var BurgerEditorEngine = class BurgerEditorEngine {
5845
5832
  });
5846
5833
  this.#disposables.use(this.#healthMonitor);
5847
5834
  this.#disposables.use(this.commandBus);
5848
- this.#disposables.use(this.componentObserver);
5849
5835
  this.css = {
5850
5836
  stylesheets: options.config.stylesheets ?? [],
5851
5837
  classList: options.config.classList ?? [],
@@ -5867,9 +5853,6 @@ var BurgerEditorEngine = class BurgerEditorEngine {
5867
5853
  const { main, draft } = e.detail;
5868
5854
  options.onUpdated?.(main, draft);
5869
5855
  });
5870
- this.componentObserver.on("select-block", ({ block }) => {
5871
- this.setCurrentBlock(block);
5872
- });
5873
5856
  }
5874
5857
  [Symbol.dispose]() {
5875
5858
  this.#disposables.dispose();
@@ -5910,7 +5893,25 @@ var BurgerEditorEngine = class BurgerEditorEngine {
5910
5893
  this[Symbol.dispose]();
5911
5894
  }
5912
5895
  clearCurrentBlock() {
5913
- this.#currentBlock = null;
5896
+ this.uiState.setCurrentBlock(null);
5897
+ }
5898
+ /**
5899
+ * Replace an editable area's content with hand-edited HTML source and
5900
+ * save. Used when leaving HTML-source editing mode, or whenever the UI
5901
+ * layer wants to commit an in-progress edit (e.g. the source textarea
5902
+ * losing focus). A no-op when the area doesn't exist (e.g. no draft).
5903
+ * @param type - The editable area to commit into
5904
+ * @param html - The HTML source to replace the area's content with
5905
+ * @example
5906
+ * ```ts
5907
+ * await engine.commitSourceEdit('main', textarea.value);
5908
+ * ```
5909
+ */
5910
+ async commitSourceEdit(type, html) {
5911
+ const content = this.getEditableContent(type);
5912
+ if (!content) return;
5913
+ await content.replaceContents(html);
5914
+ this.save();
5914
5915
  }
5915
5916
  /**
5916
5917
  * ブロックマーカーを持たない生HTMLを、1つのwysiwygアイテムとして
@@ -5936,20 +5937,31 @@ var BurgerEditorEngine = class BurgerEditorEngine {
5936
5937
  /**
5937
5938
  * Resolve the CSS applied to the content (generalCSS plus non-layered
5938
5939
  * stylesheets), for injection into rich-text editors.
5940
+ *
5941
+ * Caches the in-flight promise itself, not just the resolved value —
5942
+ * concurrent callers (e.g. more than one `WysiwygField` mounted at
5943
+ * once) that call this before the first fetch settles share the same
5944
+ * promise instead of each issuing their own `fetch` calls.
5939
5945
  * @returns The concatenated stylesheet text
5940
5946
  */
5941
5947
  async getContentStylesheet() {
5942
5948
  if (this.#contentStylesheetCache) return this.#contentStylesheetCache;
5943
- const css = await Promise.all(this.css.stylesheets.filter((sheet) => sheet.layer == null).map(async (sheet) => {
5944
- return (await fetch(sheet.path)).text();
5945
- }));
5946
- const stylesheets = [this.css.generalCSS, ...css];
5947
- this.#contentStylesheetCache = stylesheets.join("\n");
5948
- return this.#contentStylesheetCache;
5949
+ const promise = (async () => {
5950
+ const css = await Promise.all(this.css.stylesheets.filter((sheet) => sheet.layer == null).map(async (sheet) => {
5951
+ return (await fetch(sheet.path)).text();
5952
+ }));
5953
+ return [this.css.generalCSS, ...css].join("\n");
5954
+ })();
5955
+ promise.catch(() => {
5956
+ this.#contentStylesheetCache = null;
5957
+ });
5958
+ this.#contentStylesheetCache = promise;
5959
+ return promise;
5949
5960
  }
5950
5961
  getCurrentBlock() {
5951
- if (!this.#currentBlock) console.warn("block is unselected.");
5952
- return this.#currentBlock;
5962
+ const currentBlock = this.uiState.getSnapshot().currentBlock;
5963
+ if (!currentBlock) console.warn("block is unselected.");
5964
+ return currentBlock;
5953
5965
  }
5954
5966
  getCustomProperties(containerType) {
5955
5967
  return getCustomProperties(this.#current.containerElement.ownerDocument, containerType);
@@ -6009,7 +6021,7 @@ var BurgerEditorEngine = class BurgerEditorEngine {
6009
6021
  return !!this.#draft;
6010
6022
  }
6011
6023
  isSetBlock() {
6012
- return !!this.#currentBlock;
6024
+ return !!this.uiState.getSnapshot().currentBlock;
6013
6025
  }
6014
6026
  async mainToDraft(confirm) {
6015
6027
  if (!this.#draft) return false;
@@ -6076,9 +6088,9 @@ var BurgerEditorEngine = class BurgerEditorEngine {
6076
6088
  }));
6077
6089
  }
6078
6090
  setCurrentBlock(block) {
6079
- let isChanged = true;
6080
- if (this.#currentBlock) isChanged = !this.#currentBlock.is(block);
6081
- this.#currentBlock = block;
6091
+ const previous = this.uiState.getSnapshot().currentBlock;
6092
+ const isChanged = !previous || !previous.is(block);
6093
+ this.uiState.setCurrentBlock(block);
6082
6094
  if (isChanged) this.el.dispatchEvent(createBgeEvent("bge:block-change", { block }));
6083
6095
  return isChanged;
6084
6096
  }
@@ -6122,6 +6134,7 @@ var BurgerEditorEngine = class BurgerEditorEngine {
6122
6134
  if (this.#current === to) return;
6123
6135
  this.#current = to;
6124
6136
  this.migrationCheck(to.containerElement);
6137
+ this.uiState.setActiveArea(this.#current.type);
6125
6138
  this.el.dispatchEvent(createBgeEvent("bge:switch-content", { content: this.#current.type }));
6126
6139
  }
6127
6140
  static BLOCK_ID_PREFIX = "bge-";
@@ -6203,51 +6216,6 @@ var BurgerEditorEngine = class BurgerEditorEngine {
6203
6216
  }
6204
6217
  };
6205
6218
  //#endregion
6206
- //#region ../core/dist/command/commands.js
6207
- /**
6208
- * The engine's command vocabulary — every custom command accepted by the
6209
- * central command bus. Buttons declare these with
6210
- * `commandfor={COMMAND_BUS_ID}`; the dispatch table is registered by the
6211
- * UI layer at engine setup.
6212
- *
6213
- * Parameters travel on the invoker button (`value` / `data-*` attributes)
6214
- * and are read from `CommandEvent.source`.
6215
- * @example
6216
- * ```tsx
6217
- * <button command={BGE_COMMAND.moveBlock} commandfor={COMMAND_BUS_ID} value="up">
6218
- * 上に移動
6219
- * </button>
6220
- * ```
6221
- */
6222
- var BGE_COMMAND = {
6223
- /** Append a new block from the catalog. `value`: catalog index. */
6224
- addBlock: "--add-block",
6225
- /** Paste the block currently held in the clipboard. */
6226
- pasteBlock: "--paste-block",
6227
- /** Move the current block. `value`: `up` | `down`. */
6228
- moveBlock: "--move-block",
6229
- /** Open the catalog to insert a block. `value`: `before` | `after`. */
6230
- insertBlock: "--insert-block",
6231
- /** Add or remove a grid item in the current block. `value`: `+1` | `-1`. */
6232
- updateGridItems: "--update-grid-items",
6233
- /** Open the options dialog for the current block. */
6234
- openBlockOptions: "--open-block-options",
6235
- /** Copy the current block to the clipboard. */
6236
- copyBlock: "--copy-block",
6237
- /** Remove the current block. */
6238
- removeBlock: "--remove-block",
6239
- /** Insert the first block into an empty editable area. */
6240
- insertInitialBlock: "--insert-initial-block",
6241
- /** Switch the visible content. `value`: `main` | `draft`. */
6242
- switchContent: "--switch-content",
6243
- /** Copy the main content over the draft. */
6244
- copyMainToDraft: "--copy-main-to-draft",
6245
- /** Copy the draft content over the main. */
6246
- copyDraftToMain: "--copy-draft-to-main",
6247
- /** Open the item editor for the item hosting the invoker button. */
6248
- openItemEditor: "--open-item-editor"
6249
- };
6250
- //#endregion
6251
6219
  //#region ../core/dist/dom-helpers/get-css-property-as-number.js
6252
6220
  var getCSSPropertyAsNumberCache = /* @__PURE__ */ new Map();
6253
6221
  /**
@@ -6545,8 +6513,8 @@ var require_common = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6545
6513
  return target;
6546
6514
  }
6547
6515
  function repeat(string, count) {
6548
- var result = "", cycle;
6549
- for (cycle = 0; cycle < count; cycle += 1) result += string;
6516
+ var result = "", cycle = 0;
6517
+ for (; cycle < count; cycle += 1) result += string;
6550
6518
  return result;
6551
6519
  }
6552
6520
  function isNegativeZero(number) {
@@ -7174,8 +7142,8 @@ var require_base64_js = /* @__PURE__ */ __commonJSMin(((exports) => {
7174
7142
  var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
7175
7143
  var curByte = 0;
7176
7144
  var len = placeHoldersLen > 0 ? validLen - 4 : validLen;
7177
- var i;
7178
- for (i = 0; i < len; i += 4) {
7145
+ var i = 0;
7146
+ for (; i < len; i += 4) {
7179
7147
  tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
7180
7148
  arr[curByte++] = tmp >> 16 & 255;
7181
7149
  arr[curByte++] = tmp >> 8 & 255;
@@ -14983,8 +14951,8 @@ var require_dumper = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14983
14951
  return "\n" + common.repeat(" ", state.indent * level);
14984
14952
  }
14985
14953
  function testImplicitResolving(state, str) {
14986
- var index, length, type;
14987
- for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
14954
+ var index = 0, length = state.implicitTypes.length, type;
14955
+ for (; index < length; index += 1) {
14988
14956
  type = state.implicitTypes[index];
14989
14957
  if (type.resolve(str)) return true;
14990
14958
  }
@@ -15133,8 +15101,8 @@ var require_dumper = /* @__PURE__ */ __commonJSMin(((exports, module) => {
15133
15101
  return result;
15134
15102
  }
15135
15103
  function writeFlowSequence(state, level, object) {
15136
- var _result = "", _tag = state.tag, index, length;
15137
- for (index = 0, length = object.length; index < length; index += 1) if (writeNode(state, level, object[index], false, false)) {
15104
+ var _result = "", _tag = state.tag, index = 0, length = object.length;
15105
+ for (; index < length; index += 1) if (writeNode(state, level, object[index], false, false)) {
15138
15106
  if (index !== 0) _result += "," + (!state.condenseFlow ? " " : "");
15139
15107
  _result += state.dump;
15140
15108
  }
@@ -15142,8 +15110,8 @@ var require_dumper = /* @__PURE__ */ __commonJSMin(((exports, module) => {
15142
15110
  state.dump = "[" + _result + "]";
15143
15111
  }
15144
15112
  function writeBlockSequence(state, level, object, compact) {
15145
- var _result = "", _tag = state.tag, index, length;
15146
- for (index = 0, length = object.length; index < length; index += 1) if (writeNode(state, level + 1, object[index], true, true)) {
15113
+ var _result = "", _tag = state.tag, index = 0, length = object.length;
15114
+ for (; index < length; index += 1) if (writeNode(state, level + 1, object[index], true, true)) {
15147
15115
  if (!compact || index !== 0) _result += generateNextLine(state, level);
15148
15116
  if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) _result += "-";
15149
15117
  else _result += "- ";
@@ -15153,8 +15121,8 @@ var require_dumper = /* @__PURE__ */ __commonJSMin(((exports, module) => {
15153
15121
  state.dump = _result || "[]";
15154
15122
  }
15155
15123
  function writeFlowMapping(state, level, object) {
15156
- var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
15157
- for (index = 0, length = objectKeyList.length; index < length; index += 1) {
15124
+ var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index = 0, length = objectKeyList.length, objectKey, objectValue, pairBuffer;
15125
+ for (; index < length; index += 1) {
15158
15126
  pairBuffer = "";
15159
15127
  if (index !== 0) pairBuffer += ", ";
15160
15128
  if (state.condenseFlow) pairBuffer += "\"";
@@ -15198,8 +15166,8 @@ var require_dumper = /* @__PURE__ */ __commonJSMin(((exports, module) => {
15198
15166
  state.dump = _result || "{}";
15199
15167
  }
15200
15168
  function detectType(state, object, explicit) {
15201
- var _result, typeList = explicit ? state.explicitTypes : state.implicitTypes, index, length, type, style;
15202
- for (index = 0, length = typeList.length; index < length; index += 1) {
15169
+ var _result, typeList = explicit ? state.explicitTypes : state.implicitTypes, index = 0, length = typeList.length, type, style;
15170
+ for (; index < length; index += 1) {
15203
15171
  type = typeList[index];
15204
15172
  if ((type.instanceOf || type.predicate) && (!type.instanceOf || typeof object === "object" && object instanceof type.instanceOf) && (!type.predicate || type.predicate(object))) {
15205
15173
  state.tag = explicit ? type.tag : "?";
@@ -15742,1769 +15710,49 @@ var require_gray_matter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
15742
15710
  //#region ../core/dist/document/front-matter.js
15743
15711
  var import_gray_matter = /* @__PURE__ */ __toESM(require_gray_matter(), 1);
15744
15712
  //#endregion
15745
- //#region ../../../node_modules/@tabler/icons-react/dist/esm/defaultAttributes.mjs
15746
- /**
15747
- * @license @tabler/icons-react v3.46.0 - MIT
15748
- *
15749
- * This source code is licensed under the MIT license.
15750
- * See the LICENSE file in the root directory of this source tree.
15751
- */
15752
- var defaultAttributes = {
15753
- outline: {
15754
- xmlns: "http://www.w3.org/2000/svg",
15755
- width: 24,
15756
- height: 24,
15757
- viewBox: "0 0 24 24",
15758
- fill: "none",
15759
- stroke: "currentColor",
15760
- strokeWidth: 2,
15761
- strokeLinecap: "round",
15762
- strokeLinejoin: "round"
15763
- },
15764
- filled: {
15765
- xmlns: "http://www.w3.org/2000/svg",
15766
- width: 24,
15767
- height: 24,
15768
- viewBox: "0 0 24 24",
15769
- fill: "currentColor",
15770
- stroke: "none"
15771
- }
15772
- };
15773
- //#endregion
15774
- //#region ../../../node_modules/@tabler/icons-react/dist/esm/createReactComponent.mjs
15775
- /**
15776
- * @license @tabler/icons-react v3.46.0 - MIT
15777
- *
15778
- * This source code is licensed under the MIT license.
15779
- * See the LICENSE file in the root directory of this source tree.
15780
- */
15781
- var createReactComponent = (type, iconName, iconNamePascal, iconNode) => {
15782
- const Component = forwardRef(({ color = "currentColor", size = 24, stroke = 2, title, className, children, ...rest }, ref) => createElement("svg", {
15783
- ref,
15784
- ...defaultAttributes[type],
15785
- width: size,
15786
- height: size,
15787
- className: [
15788
- `tabler-icon`,
15789
- `tabler-icon-${iconName}`,
15790
- className
15791
- ].join(" "),
15792
- ...type === "filled" ? { fill: color } : {
15793
- strokeWidth: stroke,
15794
- stroke: color
15795
- },
15796
- ...rest
15797
- }, [
15798
- title && createElement("title", { key: "svg-title" }, title),
15799
- ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
15800
- ...Array.isArray(children) ? children : [children]
15801
- ]));
15802
- Component.displayName = `${iconNamePascal}`;
15803
- return Component;
15804
- };
15805
- //#endregion
15806
- //#region ../../../node_modules/@tabler/icons-react/dist/esm/icons/IconArrowBigDownLine.mjs
15807
- /**
15808
- * @license @tabler/icons-react v3.46.0 - MIT
15809
- *
15810
- * This source code is licensed under the MIT license.
15811
- * See the LICENSE file in the root directory of this source tree.
15812
- */
15813
- var __iconNode$9 = [["path", {
15814
- "d": "M15 12h3.586a1 1 0 0 1 .707 1.707l-6.586 6.586a1 1 0 0 1 -1.414 0l-6.586 -6.586a1 1 0 0 1 .707 -1.707h3.586v-6h6v6",
15815
- "key": "svg-0"
15816
- }], ["path", {
15817
- "d": "M15 3h-6",
15818
- "key": "svg-1"
15819
- }]];
15820
- var IconArrowBigDownLine = createReactComponent("outline", "arrow-big-down-line", "ArrowBigDownLine", __iconNode$9);
15821
- //#endregion
15822
- //#region ../../../node_modules/@tabler/icons-react/dist/esm/icons/IconArrowBigUpLine.mjs
15823
- /**
15824
- * @license @tabler/icons-react v3.46.0 - MIT
15825
- *
15826
- * This source code is licensed under the MIT license.
15827
- * See the LICENSE file in the root directory of this source tree.
15828
- */
15829
- var __iconNode$8 = [["path", {
15830
- "d": "M9 12h-3.586a1 1 0 0 1 -.707 -1.707l6.586 -6.586a1 1 0 0 1 1.414 0l6.586 6.586a1 1 0 0 1 -.707 1.707h-3.586v6h-6v-6",
15831
- "key": "svg-0"
15832
- }], ["path", {
15833
- "d": "M9 21h6",
15834
- "key": "svg-1"
15835
- }]];
15836
- var IconArrowBigUpLine = createReactComponent("outline", "arrow-big-up-line", "ArrowBigUpLine", __iconNode$8);
15837
- //#endregion
15838
- //#region ../../../node_modules/@tabler/icons-react/dist/esm/icons/IconClipboardPlus.mjs
15839
- /**
15840
- * @license @tabler/icons-react v3.46.0 - MIT
15841
- *
15842
- * This source code is licensed under the MIT license.
15843
- * See the LICENSE file in the root directory of this source tree.
15844
- */
15845
- var __iconNode$7 = [
15846
- ["path", {
15847
- "d": "M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2",
15848
- "key": "svg-0"
15849
- }],
15850
- ["path", {
15851
- "d": "M9 5a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2",
15852
- "key": "svg-1"
15853
- }],
15854
- ["path", {
15855
- "d": "M10 14h4",
15856
- "key": "svg-2"
15857
- }],
15858
- ["path", {
15859
- "d": "M12 12v4",
15860
- "key": "svg-3"
15861
- }]
15862
- ];
15863
- var IconClipboardPlus = createReactComponent("outline", "clipboard-plus", "ClipboardPlus", __iconNode$7);
15864
- //#endregion
15865
- //#region ../../../node_modules/@tabler/icons-react/dist/esm/icons/IconClipboard.mjs
15866
- /**
15867
- * @license @tabler/icons-react v3.46.0 - MIT
15868
- *
15869
- * This source code is licensed under the MIT license.
15870
- * See the LICENSE file in the root directory of this source tree.
15871
- */
15872
- var __iconNode$6 = [["path", {
15873
- "d": "M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2",
15874
- "key": "svg-0"
15875
- }], ["path", {
15876
- "d": "M9 5a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2",
15877
- "key": "svg-1"
15878
- }]];
15879
- var IconClipboard = createReactComponent("outline", "clipboard", "Clipboard", __iconNode$6);
15880
- //#endregion
15881
- //#region ../../../node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutGridAdd.mjs
15882
- /**
15883
- * @license @tabler/icons-react v3.46.0 - MIT
15884
- *
15885
- * This source code is licensed under the MIT license.
15886
- * See the LICENSE file in the root directory of this source tree.
15887
- */
15888
- var __iconNode$5 = [
15889
- ["path", {
15890
- "d": "M4 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4",
15891
- "key": "svg-0"
15892
- }],
15893
- ["path", {
15894
- "d": "M14 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4",
15895
- "key": "svg-1"
15896
- }],
15897
- ["path", {
15898
- "d": "M4 15a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4",
15899
- "key": "svg-2"
15900
- }],
15901
- ["path", {
15902
- "d": "M14 17h6m-3 -3v6",
15903
- "key": "svg-3"
15904
- }]
15905
- ];
15906
- var IconLayoutGridAdd = createReactComponent("outline", "layout-grid-add", "LayoutGridAdd", __iconNode$5);
15907
- //#endregion
15908
- //#region ../../../node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutGridRemove.mjs
15909
- /**
15910
- * @license @tabler/icons-react v3.46.0 - MIT
15911
- *
15912
- * This source code is licensed under the MIT license.
15913
- * See the LICENSE file in the root directory of this source tree.
15914
- */
15915
- var __iconNode$4 = [
15916
- ["path", {
15917
- "d": "M4 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1v-4",
15918
- "key": "svg-0"
15919
- }],
15920
- ["path", {
15921
- "d": "M14 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1v-4",
15922
- "key": "svg-1"
15923
- }],
15924
- ["path", {
15925
- "d": "M4 15a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1v-4",
15926
- "key": "svg-2"
15927
- }],
15928
- ["path", {
15929
- "d": "M14 17h6",
15930
- "key": "svg-3"
15931
- }]
15932
- ];
15933
- var IconLayoutGridRemove = createReactComponent("outline", "layout-grid-remove", "LayoutGridRemove", __iconNode$4);
15934
- //#endregion
15935
- //#region ../../../node_modules/@tabler/icons-react/dist/esm/icons/IconRowInsertBottom.mjs
15936
- /**
15937
- * @license @tabler/icons-react v3.46.0 - MIT
15938
- *
15939
- * This source code is licensed under the MIT license.
15940
- * See the LICENSE file in the root directory of this source tree.
15941
- */
15942
- var __iconNode$3 = [
15943
- ["path", {
15944
- "d": "M20 6v4a1 1 0 0 1 -1 1h-14a1 1 0 0 1 -1 -1v-4a1 1 0 0 1 1 -1h14a1 1 0 0 1 1 1",
15945
- "key": "svg-0"
15946
- }],
15947
- ["path", {
15948
- "d": "M12 15l0 4",
15949
- "key": "svg-1"
15950
- }],
15951
- ["path", {
15952
- "d": "M14 17l-4 0",
15953
- "key": "svg-2"
15954
- }]
15955
- ];
15956
- var IconRowInsertBottom = createReactComponent("outline", "row-insert-bottom", "RowInsertBottom", __iconNode$3);
15957
- //#endregion
15958
- //#region ../../../node_modules/@tabler/icons-react/dist/esm/icons/IconRowInsertTop.mjs
15959
- /**
15960
- * @license @tabler/icons-react v3.46.0 - MIT
15961
- *
15962
- * This source code is licensed under the MIT license.
15963
- * See the LICENSE file in the root directory of this source tree.
15964
- */
15965
- var __iconNode$2 = [
15966
- ["path", {
15967
- "d": "M4 18v-4a1 1 0 0 1 1 -1h14a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-14a1 1 0 0 1 -1 -1",
15968
- "key": "svg-0"
15969
- }],
15970
- ["path", {
15971
- "d": "M12 9v-4",
15972
- "key": "svg-1"
15973
- }],
15974
- ["path", {
15975
- "d": "M10 7l4 0",
15976
- "key": "svg-2"
15977
- }]
15978
- ];
15979
- var IconRowInsertTop = createReactComponent("outline", "row-insert-top", "RowInsertTop", __iconNode$2);
15980
- //#endregion
15981
- //#region ../../../node_modules/@tabler/icons-react/dist/esm/icons/IconSettings.mjs
15982
- /**
15983
- * @license @tabler/icons-react v3.46.0 - MIT
15984
- *
15985
- * This source code is licensed under the MIT license.
15986
- * See the LICENSE file in the root directory of this source tree.
15987
- */
15988
- var __iconNode$1 = [["path", {
15989
- "d": "M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065",
15990
- "key": "svg-0"
15991
- }], ["path", {
15992
- "d": "M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0",
15993
- "key": "svg-1"
15994
- }]];
15995
- var IconSettings = createReactComponent("outline", "settings", "Settings", __iconNode$1);
15996
- //#endregion
15997
- //#region ../../../node_modules/@tabler/icons-react/dist/esm/icons/IconTrash.mjs
15998
- /**
15999
- * @license @tabler/icons-react v3.46.0 - MIT
16000
- *
16001
- * This source code is licensed under the MIT license.
16002
- * See the LICENSE file in the root directory of this source tree.
16003
- */
16004
- var __iconNode = [
16005
- ["path", {
16006
- "d": "M4 7l16 0",
16007
- "key": "svg-0"
16008
- }],
16009
- ["path", {
16010
- "d": "M10 11l0 6",
16011
- "key": "svg-1"
16012
- }],
16013
- ["path", {
16014
- "d": "M14 11l0 6",
16015
- "key": "svg-2"
16016
- }],
16017
- ["path", {
16018
- "d": "M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12",
16019
- "key": "svg-3"
16020
- }],
16021
- ["path", {
16022
- "d": "M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3",
16023
- "key": "svg-4"
16024
- }]
16025
- ];
16026
- var IconTrash = createReactComponent("outline", "trash", "Trash", __iconNode);
16027
- //#endregion
16028
- //#region src/components/block-catalog.module.css
16029
- var blockCatalog = "_blockCatalog_96ih6_1";
16030
- var figure = "_figure_96ih6_36";
16031
- var img = "_img_96ih6_42";
16032
- var figcaption = "_figcaption_96ih6_56";
16033
- var pasteSection = "_pasteSection_96ih6_66";
16034
- var pasteButton = "_pasteButton_96ih6_72";
16035
- var block_catalog_module_default = {
16036
- blockCatalog,
16037
- figure,
16038
- img,
16039
- figcaption,
16040
- pasteSection,
16041
- pasteButton
16042
- };
16043
- //#endregion
16044
- //#region src/components/block-catalog.tsx
16045
- /**
16046
- * Block catalog dialog content. Adding and pasting blocks are declared
16047
- * as engine commands; the catalog entry is identified by
16048
- * `data-category` / `data-index` on the invoker button.
16049
- * @param root0
16050
- * @param root0.engine
16051
- * @param root0.catalog
16052
- * @example
16053
- * ```tsx
16054
- * <EditorDialog name="catalog" open={open} onClose={close} buttons={{ close: 'キャンセル' }}>
16055
- * <BlockCatalog engine={engine} catalog={engine.catalog} />
16056
- * </EditorDialog>
16057
- * ```
16058
- */
16059
- function BlockCatalog({ engine, catalog }) {
16060
- const hasCopiedBlock = !!sessionStorage.getItem(engine.storageKey.blockClipboard);
16061
- return /* @__PURE__ */ jsxs("div", {
16062
- className: block_catalog_module_default["blockCatalog"],
16063
- children: [hasCopiedBlock ? /* @__PURE__ */ jsx("div", {
16064
- className: block_catalog_module_default["pasteSection"],
16065
- children: /* @__PURE__ */ jsxs("button", {
16066
- type: "button",
16067
- className: block_catalog_module_default["pasteButton"],
16068
- command: BGE_COMMAND.pasteBlock,
16069
- commandfor: COMMAND_BUS_ID,
16070
- children: [/* @__PURE__ */ jsx(IconClipboard, {}), /* @__PURE__ */ jsx("span", { children: "クリップボードから貼り付け" })]
16071
- })
16072
- }) : null, /* @__PURE__ */ jsx("dl", { children: Object.entries(catalog).map(([category, blocks]) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("dt", { children: category }), /* @__PURE__ */ jsx("div", { children: blocks.map((blockInfo, index) => /* @__PURE__ */ jsx("dd", { children: /* @__PURE__ */ jsx("button", {
16073
- type: "button",
16074
- command: BGE_COMMAND.addBlock,
16075
- commandfor: COMMAND_BUS_ID,
16076
- "data-category": category,
16077
- "data-index": index,
16078
- children: blockInfo.definition.img || blockInfo.definition.svg ? /* @__PURE__ */ jsxs("span", {
16079
- className: block_catalog_module_default["figure"],
16080
- children: [blockInfo.definition.img ? /* @__PURE__ */ jsx("span", {
16081
- className: block_catalog_module_default["img"],
16082
- children: /* @__PURE__ */ jsx("img", {
16083
- src: blockInfo.definition.img,
16084
- alt: "",
16085
- loading: "lazy"
16086
- })
16087
- }) : /* @__PURE__ */ jsx("span", {
16088
- className: block_catalog_module_default["img"],
16089
- dangerouslySetInnerHTML: { __html: blockInfo.definition.svg ?? "" }
16090
- }), /* @__PURE__ */ jsx("span", {
16091
- className: block_catalog_module_default["figcaption"],
16092
- children: blockInfo.label
16093
- })]
16094
- }) : blockInfo.label
16095
- }) }, category + blockInfo.label + blockInfo.definition.name)) })] }, category)) })]
16096
- });
16097
- }
16098
- //#endregion
16099
- //#region src/components/block-options.tsx
16100
- var containerTypeLabel = {
16101
- grid: "グリッド",
16102
- inline: "横並び",
16103
- float: "左右折り返し"
16104
- };
16105
- /**
16106
- * Block options dialog content. Values are read out of the dialog form
16107
- * on submit (uncontrolled, `name="bge-options-*"`); only the fields that
16108
- * drive conditional rendering are controlled.
16109
- * @param root0
16110
- * @param root0.engine
16111
- * @param root0.block
16112
- * @example
16113
- * ```tsx
16114
- * <EditorDialog
16115
- * name="options"
16116
- * open={block !== null}
16117
- * onClose={close}
16118
- * onComplete={(formData) => applyBlockOptions(block, formData)}
16119
- * buttons={{ close: 'キャンセル', complete: '決定' }}>
16120
- * {block ? <BlockOptions engine={engine} block={block} /> : null}
16121
- * </EditorDialog>
16122
- * ```
16123
- */
16124
- function BlockOptions({ engine, block }) {
16125
- const currentBlock = block;
16126
- const [options] = useState(() => currentBlock.exportOptions());
16127
- const cssProps = useMemo(() => engine.getCustomProperties(options.containerProps.type), [engine, options]);
16128
- const repeatMinInlineSizeVariants = useMemo(() => engine.getRepeatMinInlineSizeVariants(), [engine]);
16129
- const [currentColumns, setCurrentColumns] = useState(options.containerProps.columns ?? 1);
16130
- const [currentContainerType, setCurrentContainerType] = useState(options.containerProps.type);
16131
- const [currentFrameSemantics, setCurrentFrameSemantics] = useState(options.containerProps.frameSemantics);
16132
- const [currentAutoRepeat, setCurrentAutoRepeat] = useState(options.containerProps.autoRepeat ?? "fixed");
16133
- const itemCount = currentBlock.items.length;
16134
- const effectiveContainerType = options.containerProps.type === "float" ? options.containerProps.type : currentContainerType;
16135
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
16136
- /* @__PURE__ */ jsxs("fieldset", { children: [
16137
- /* @__PURE__ */ jsx("legend", { children: "コンテナ特性" }),
16138
- options.containerProps.immutable || options.containerProps.type === "float" ? /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("span", { children: "コンテナタイプ" }), /* @__PURE__ */ jsxs("output", { children: [
16139
- containerTypeLabel[options.containerProps.type ?? "inline"],
16140
- " (",
16141
- options.containerProps.type ?? "inline",
16142
- ")"
16143
- ] })] }) : /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("span", { children: "コンテナタイプ" }), /* @__PURE__ */ jsxs("select", {
16144
- name: "bge-options-container-type",
16145
- value: currentContainerType,
16146
- onChange: (e) => {
16147
- setCurrentContainerType(e.currentTarget.value);
16148
- },
16149
- children: [/* @__PURE__ */ jsx("option", {
16150
- value: "grid",
16151
- children: containerTypeLabel.grid
16152
- }), /* @__PURE__ */ jsx("option", {
16153
- value: "inline",
16154
- children: containerTypeLabel.inline
16155
- })]
16156
- })] }),
16157
- !options.containerProps.immutable && options.containerProps.type !== "float" ? /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("span", { children: "セマンティック要素" }), /* @__PURE__ */ jsxs("select", {
16158
- name: "bge-options-frame-semantics",
16159
- value: currentFrameSemantics,
16160
- onChange: (e) => {
16161
- setCurrentFrameSemantics(e.currentTarget.value);
16162
- },
16163
- children: [
16164
- /* @__PURE__ */ jsx("option", {
16165
- value: "div",
16166
- children: "div(汎用)"
16167
- }),
16168
- /* @__PURE__ */ jsx("option", {
16169
- value: "ul",
16170
- children: "ul(順序なしリスト)"
16171
- }),
16172
- /* @__PURE__ */ jsx("option", {
16173
- value: "ol",
16174
- children: "ol(順序ありリスト)"
16175
- })
16176
- ]
16177
- })] }) : null,
16178
- effectiveContainerType === "inline" && !(options.containerProps.immutable && itemCount === 1) ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("div", {
16179
- role: "radiogroup",
16180
- "aria-labelledby": "justify-group",
16181
- children: [/* @__PURE__ */ jsx("div", {
16182
- id: "justify-group",
16183
- children: "横方向配置"
16184
- }), [
16185
- ["center", "中央寄せ"],
16186
- ["start", "左寄せ"],
16187
- ["end", "右寄せ"],
16188
- ["between", "両端寄せ"],
16189
- ["around", "要素間余白均等"],
16190
- ["evenly", "要素間均等"]
16191
- ].map(([value, label]) => /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("input", {
16192
- type: "radio",
16193
- name: "bge-options-justify",
16194
- value,
16195
- defaultChecked: options.containerProps.justify === value
16196
- }), /* @__PURE__ */ jsx("span", { children: label })] }, value))]
16197
- }), /* @__PURE__ */ jsxs("div", {
16198
- role: "radiogroup",
16199
- "aria-labelledby": "align-group",
16200
- children: [/* @__PURE__ */ jsx("div", {
16201
- id: "align-group",
16202
- children: "縦向配置"
16203
- }), [
16204
- ["align-center", "垂直中央寄せ"],
16205
- ["align-start", "上寄せ"],
16206
- ["align-end", "下寄せ"],
16207
- ["align-stretch", "伸縮"],
16208
- ["align-baseline", "ベースライン"]
16209
- ].map(([value, label]) => /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("input", {
16210
- type: "radio",
16211
- name: "bge-options-align",
16212
- value,
16213
- defaultChecked: options.containerProps.align === value
16214
- }), /* @__PURE__ */ jsx("span", { children: label })] }, value))]
16215
- })] }) : null,
16216
- effectiveContainerType === "grid" ? options.containerProps.immutable || options.containerProps.type === "float" ? /* @__PURE__ */ jsx("p", { children: "このブロックはコンテナタイプを変更できません。" }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
16217
- /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("span", { children: "列の自動調整" }), /* @__PURE__ */ jsxs("select", {
16218
- name: "bge-options-auto-repeat",
16219
- value: currentAutoRepeat,
16220
- onChange: (e) => {
16221
- setCurrentAutoRepeat(e.currentTarget.value);
16222
- },
16223
- children: [
16224
- /* @__PURE__ */ jsx("option", {
16225
- value: "fixed",
16226
- children: "固定列数"
16227
- }),
16228
- /* @__PURE__ */ jsx("option", {
16229
- value: "auto-fill",
16230
- children: "auto-fill(空白保持)"
16231
- }),
16232
- /* @__PURE__ */ jsx("option", {
16233
- value: "auto-fit",
16234
- children: "auto-fit(空白最小)"
16235
- })
16236
- ]
16237
- })] }),
16238
- currentAutoRepeat === "fixed" ? /* @__PURE__ */ jsxs("label", { children: [
16239
- /* @__PURE__ */ jsx("span", { children: "基準列数" }),
16240
- /* @__PURE__ */ jsx("output", { children: currentColumns }),
16241
- /* @__PURE__ */ jsx("input", {
16242
- name: "bge-options-columns",
16243
- type: "range",
16244
- value: currentColumns,
16245
- onChange: (e) => {
16246
- setCurrentColumns(e.currentTarget.valueAsNumber);
16247
- },
16248
- min: "1",
16249
- max: "5"
16250
- })
16251
- ] }) : null,
16252
- currentAutoRepeat !== "fixed" && repeatMinInlineSizeVariants ? /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("span", { children: "折り返し基準幅" }), /* @__PURE__ */ jsx("select", {
16253
- name: "bge-options-repeat-min-inline-size",
16254
- defaultValue: [...repeatMinInlineSizeVariants.properties].find(([variantName, data]) => options.containerProps.repeatMinInlineSize == null ? data.isDefault : options.containerProps.repeatMinInlineSize === variantName)?.[0],
16255
- children: [...repeatMinInlineSizeVariants.properties].map(([variantName, data]) => /* @__PURE__ */ jsx("option", {
16256
- value: variantName,
16257
- children: `${variantName} (${data.value})`
16258
- }, variantName))
16259
- })] }) : null
16260
- ] }) : null,
16261
- effectiveContainerType === "float" ? /* @__PURE__ */ jsxs("div", {
16262
- role: "radiogroup",
16263
- "aria-labelledby": "float-group",
16264
- children: [/* @__PURE__ */ jsx("div", {
16265
- id: "float-group",
16266
- children: "回り込み"
16267
- }), [["start", "左寄せ"], ["end", "右寄せ"]].map(([value, label]) => /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("input", {
16268
- type: "radio",
16269
- name: "bge-options-float",
16270
- value,
16271
- defaultChecked: options.containerProps.float === value
16272
- }), /* @__PURE__ */ jsx("span", { children: label })] }, value))]
16273
- }) : null,
16274
- /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("input", {
16275
- type: "checkbox",
16276
- name: "bge-options-linkarea",
16277
- value: "true",
16278
- defaultChecked: options.containerProps.linkarea ?? false
16279
- }), /* @__PURE__ */ jsx("span", { children: "リンクエリア機能を有効にする" })] })
16280
- ] }),
16281
- cssProps.size > 0 ? /* @__PURE__ */ jsxs("fieldset", { children: [/* @__PURE__ */ jsx("legend", { children: "ブロックのスタイル拡張" }), [...cssProps].map(([, category]) => {
16282
- const selected = [...category.properties].find(([propName, data]) => options.style?.[category.id] == null ? data.isDefault : options.style[category.id] === propName);
16283
- return /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("span", { children: category.name }), /* @__PURE__ */ jsx("select", {
16284
- name: `bge-options-style-${category.id}`,
16285
- defaultValue: selected ? selected[1].isDefault ? "@@default" : selected[0] : void 0,
16286
- children: [...category.properties].map(([propName, data]) => /* @__PURE__ */ jsx("option", {
16287
- value: data.isDefault ? "@@default" : propName,
16288
- children: `${propName} (${data.value})`
16289
- }, propName))
16290
- })] }, `bge-options-style-${category.id}`);
16291
- })] }) : null,
16292
- /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("span", { children: "独自class設定" }), /* @__PURE__ */ jsx("input", {
16293
- type: "text",
16294
- name: "bge-options-classes",
16295
- defaultValue: options.classList?.join(" ") ?? "",
16296
- "aria-describedby": "block-option-classes-desc"
16297
- })] }),
16298
- /* @__PURE__ */ jsx("small", {
16299
- id: "block-option-classes-desc",
16300
- children: "複数指定する場合はスペース(空白文字)で区切ってください。"
16301
- }),
16302
- /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsxs("span", { children: ["ID設定: ", /* @__PURE__ */ jsx("code", { children: "bge-" })] }), /* @__PURE__ */ jsx("input", {
16303
- name: "bge-options-id",
16304
- type: "text",
16305
- defaultValue: options.id ?? "",
16306
- "aria-describedby": "block-option-id-desc"
16307
- })] }),
16308
- /* @__PURE__ */ jsxs("small", {
16309
- id: "block-option-id-desc",
16310
- children: [
16311
- "アンカーリンク用のID属性を設定します。実際のIDは",
16312
- /* @__PURE__ */ jsx("code", { children: "bge-" }),
16313
- "が自動的に先頭に付加されます。"
16314
- ]
16315
- })
16316
- ] });
16317
- }
16318
- //#endregion
16319
- //#region src/editor-dialog.tsx
16320
- /**
16321
- * Declarative `<dialog>` shell.
16322
- *
16323
- * The markup follows the `dialog.bge-dialog > div > form > div` + `footer`
16324
- * structure that `ui.css` styles. Opening/closing is driven by the `open`
16325
- * prop; the close button uses the built-in `close` command — no click
16326
- * handlers.
16327
- * @param root0
16328
- * @param root0.name
16329
- * @param root0.open
16330
- * @param root0.onClose
16331
- * @param root0.onComplete
16332
- * @param root0.buttons
16333
- * @param root0.buttons.close
16334
- * @param root0.buttons.complete
16335
- * @param root0.children
16336
- * @example
16337
- * ```tsx
16338
- * <EditorDialog
16339
- * name="options"
16340
- * open={block !== null}
16341
- * onClose={() => engine.uiState.closeDialog()}
16342
- * onComplete={(formData) => applyBlockOptions(block, formData)}
16343
- * buttons={{ close: 'キャンセル', complete: '決定' }}>
16344
- * {block ? <BlockOptions engine={engine} block={block} /> : null}
16345
- * </EditorDialog>
16346
- * ```
16347
- */
16348
- function EditorDialog({ name, open, onClose, onComplete, buttons, children }) {
16349
- const dialogRef = useRef(null);
16350
- const dialogId = `${name}-dialog`;
16351
- const formId = `${name}-dialog-form`;
16352
- useEffect(() => {
16353
- const dialog = dialogRef.current;
16354
- if (!dialog) return;
16355
- if (open && !dialog.open) dialog.showModal();
16356
- else if (!open && dialog.open) dialog.close();
16357
- }, [open]);
16358
- return /* @__PURE__ */ jsxs("dialog", {
16359
- ref: dialogRef,
16360
- id: dialogId,
16361
- className: "bge-dialog",
16362
- closedby: "any",
16363
- onClose,
16364
- children: [/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("form", {
16365
- id: formId,
16366
- method: "dialog",
16367
- noValidate: true,
16368
- autoComplete: "off",
16369
- autoCapitalize: "off",
16370
- onSubmit: (e) => {
16371
- e.preventDefault();
16372
- onComplete?.(new FormData(e.currentTarget));
16373
- },
16374
- children: /* @__PURE__ */ jsx("div", {
16375
- "data-bge-component": dialogId,
16376
- children: open ? children : null
16377
- })
16378
- }) }), /* @__PURE__ */ jsxs("footer", { children: [buttons?.close ? /* @__PURE__ */ jsx("button", {
16379
- type: "button",
16380
- command: "close",
16381
- commandfor: dialogId,
16382
- children: buttons.close
16383
- }) : null, buttons?.complete ? /* @__PURE__ */ jsx("button", {
16384
- type: "submit",
16385
- form: formId,
16386
- children: buttons.complete
16387
- }) : null] })]
16388
- });
16389
- }
16390
- //#endregion
16391
- //#region src/components/item-editor-host.tsx
16392
- /**
16393
- * Declarative item editor dialog. Renders the item's `Editor` component
16394
- * with editor state derived via `toEditorState`; on submit the state is
16395
- * converted back with `toItemData` and imported into the item.
16396
- * @param root0
16397
- * @param root0.engine
16398
- * @param root0.item
16399
- * @example
16400
- * ```tsx
16401
- * <ItemEditorHost
16402
- * engine={engine}
16403
- * item={open?.type === 'item-editor' ? open.item : null}
16404
- * />
16405
- * ```
16406
- */
16407
- function ItemEditorHost({ engine, item }) {
16408
- const submitRef = useRef(null);
16409
- return /* @__PURE__ */ jsx(EditorDialog, {
16410
- name: "item-editor",
16411
- open: !!item,
16412
- buttons: {
16413
- close: "キャンセル",
16414
- complete: "決定"
16415
- },
16416
- onClose: () => {
16417
- engine.uiState.closeDialog();
16418
- engine.save();
16419
- },
16420
- onComplete: () => {
16421
- (async () => {
16422
- await submitRef.current?.();
16423
- engine.uiState.closeDialog();
16424
- })();
16425
- },
16426
- children: item ? /* @__PURE__ */ jsx(ItemEditorBody, {
16427
- engine,
16428
- item,
16429
- submitRef
16430
- }) : null
16431
- });
16432
- }
16433
- /**
16434
- * The editor form body. Owns the editor state for the currently edited
16435
- * item.
16436
- * @param root0
16437
- * @param root0.engine
16438
- * @param root0.item
16439
- * @param root0.submitRef
16440
- */
16441
- function ItemEditorBody({ engine, item, submitRef }) {
16442
- const seed = item.seed;
16443
- const [state, setState] = useState(() => {
16444
- const data = item.export();
16445
- return seed.toEditorState ? seed.toEditorState(data, engine.config) : data;
16446
- });
16447
- const stateRef = useRef(state);
16448
- useEffect(() => {
16449
- stateRef.current = state;
16450
- });
16451
- useEffect(() => {
16452
- submitRef.current = async () => {
16453
- const data = seed.toItemData ? await seed.toItemData(stateRef.current, engine.config) : stateRef.current;
16454
- await item.import(data);
16455
- };
16456
- return () => {
16457
- submitRef.current = null;
16458
- };
16459
- }, [
16460
- engine,
16461
- item,
16462
- seed,
16463
- submitRef
16464
- ]);
16465
- const wrapperRef = useRef(null);
16466
- useEffect(() => {
16467
- const wysiwyg = wrapperRef.current?.querySelector("bge-wysiwyg-editor");
16468
- if (!wysiwyg) return;
16469
- let cancelled = false;
16470
- engine.getContentStylesheet().then((css) => {
16471
- if (cancelled) return;
16472
- wysiwyg.setStyle(css);
16473
- });
16474
- return () => {
16475
- cancelled = true;
16476
- };
16477
- }, [engine, item]);
16478
- const containerType = item.el.closest("[data-bge-container]")?.dataset["bgeContainer"];
16479
- const Editor = seed.Editor;
16480
- if (!Editor) return /* @__PURE__ */ jsxs("p", { children: [
16481
- "編集できないコンテンツです (Error: Editor not found: \"",
16482
- item.name,
16483
- "\")"
16484
- ] });
16485
- return /* @__PURE__ */ jsx("div", {
16486
- ref: wrapperRef,
16487
- "data-bge-container": containerType,
16488
- children: /* @__PURE__ */ jsx(Editor, {
16489
- state,
16490
- setState,
16491
- config: engine.config,
16492
- engine,
16493
- item
16494
- })
16495
- });
16496
- }
16497
- //#endregion
16498
- //#region src/use-engine.ts
16499
- function useUIState(engine, selector) {
16500
- return useSyncExternalStore((onStoreChange) => engine.uiState.subscribe(onStoreChange), () => {
16501
- const snapshot = engine.uiState.getSnapshot();
16502
- return selector ? selector(snapshot) : snapshot;
16503
- });
16504
- }
16505
- /**
16506
- * Subscribe to a component observer action for the lifetime of the
16507
- * component. The handler always sees the latest render's closure.
16508
- * @param engine - The engine instance
16509
- * @param action - The action name to listen for
16510
- * @param handler - Callback receiving the typed payload
16511
- * @example
16512
- * ```tsx
16513
- * useComponentEvent(engine, 'file-select', ({ path, isEmpty }) => {
16514
- * if (!isEmpty) {
16515
- * setState((prev) => ({ ...prev, path }));
16516
- * }
16517
- * });
16518
- * ```
16519
- */
16520
- function useComponentEvent(engine, action, handler) {
16521
- const handlerRef = useRef(handler);
16522
- useEffect(() => {
16523
- handlerRef.current = handler;
16524
- });
16525
- useEffect(() => {
16526
- return engine.componentObserver.on(action, (payload) => {
16527
- handlerRef.current(payload);
16528
- });
16529
- }, [engine, action]);
16530
- }
16531
- //#endregion
16532
- //#region src/replace-element.ts
16533
- /**
16534
- *
16535
- * @param elA
16536
- * @param elB
16537
- * @param duration
16538
- */
16539
- async function replaceElement(elA, elB, duration = 600) {
16540
- if (elA.parentElement !== elB.parentElement) throw new Error("The parent element of the two elements is different.");
16541
- const lockCSS = {
16542
- visibility: "hidden",
16543
- pointerEvents: "none"
16544
- };
16545
- const beforeStyleA = elA.style.cssText.trim();
16546
- const beforeStyleB = elB.style.cssText.trim();
16547
- const boxA = elA.getBoundingClientRect();
16548
- const boxB = elB.getBoundingClientRect();
16549
- const tmpContainer = elA.ownerDocument.createElement("div");
16550
- tmpContainer.style.position = "absolute";
16551
- tmpContainer.style.top = `0px`;
16552
- tmpContainer.style.left = `0px`;
16553
- tmpContainer.style.zIndex = "2147483647";
16554
- const tmpA = elA.cloneNode(true);
16555
- tmpA.style.position = "absolute";
16556
- tmpA.style.top = `${boxA.top}px`;
16557
- tmpA.style.left = `${boxA.left}px`;
16558
- tmpA.style.width = `${boxA.width}px`;
16559
- tmpA.style.height = `${boxA.height}px`;
16560
- tmpA.style.zIndex = "20";
16561
- const tmpB = elB.cloneNode(true);
16562
- tmpB.style.position = "absolute";
16563
- tmpB.style.top = `${boxB.top}px`;
16564
- tmpB.style.left = `${boxB.left}px`;
16565
- tmpB.style.width = `${boxB.width}px`;
16566
- tmpB.style.height = `${boxB.height}px`;
16567
- tmpB.style.zIndex = "10";
16568
- tmpContainer.append(tmpA, tmpB);
16569
- tmpContainer.ownerDocument.body.append(tmpContainer);
16570
- elB.remove();
16571
- elA.before(elB);
16572
- elA.style.visibility = lockCSS.visibility;
16573
- elA.style.pointerEvents = lockCSS.pointerEvents;
16574
- elB.style.visibility = lockCSS.visibility;
16575
- elB.style.pointerEvents = lockCSS.pointerEvents;
16576
- const animateA = tmpA.animate([{
16577
- top: tmpA.style.top,
16578
- left: tmpA.style.left
16579
- }, {
16580
- top: `${boxA.top + boxB.height}px`,
16581
- left: tmpB.style.left
16582
- }], { duration });
16583
- const animateB = tmpB.animate([{
16584
- top: tmpB.style.top,
16585
- left: tmpB.style.left
16586
- }, {
16587
- top: tmpA.style.top,
16588
- left: tmpA.style.left
16589
- }], { duration });
16590
- await Promise.all([animateA.finished, animateB.finished]);
16591
- tmpContainer.remove();
16592
- elA.removeAttribute("style");
16593
- elB.removeAttribute("style");
16594
- if (beforeStyleA) elA.style.cssText = beforeStyleA;
16595
- if (beforeStyleB) elB.style.cssText = beforeStyleB;
16596
- }
16597
- //#endregion
16598
- //#region src/commands/register-engine-commands.ts
16599
- /**
16600
- * Register the engine's central command dispatch table.
16601
- *
16602
- * This is the single place where engine-mutating UI commands are
16603
- * implemented; buttons anywhere (main document or EditableArea iframes)
16604
- * declare them with `commandfor={COMMAND_BUS_ID}`. Call once per engine.
16605
- * @param engine - The engine instance
16606
- * @param catalog - The block catalog used by `--add-block`
16607
- * @example
16608
- * ```ts
16609
- * const engine = await BurgerEditorEngine.new(options);
16610
- * registerEngineCommands(engine, options.catalog);
16611
- * ```
16612
- */
16613
- function registerEngineCommands(engine, catalog) {
16614
- const bus = engine.commandBus;
16615
- bus.define(BGE_COMMAND.moveBlock, async (e) => {
16616
- const currentBlock = engine.getCurrentBlock();
16617
- if (engine.isProcessed || !currentBlock) return;
16618
- const toTop = e.source?.value === "up";
16619
- let fromEl;
16620
- let toEl;
16621
- if (toTop) {
16622
- fromEl = currentBlock.el.previousElementSibling;
16623
- toEl = currentBlock.el;
16624
- } else {
16625
- fromEl = currentBlock.el;
16626
- toEl = currentBlock.el.nextElementSibling;
16627
- }
16628
- if (!fromEl || !toEl) return;
16629
- {
16630
- using _processing = beginProcessing(engine);
16631
- await replaceElement(fromEl, toEl);
16632
- }
16633
- engine.save();
16634
- });
16635
- bus.define(BGE_COMMAND.insertBlock, (e) => {
16636
- const currentBlock = engine.getCurrentBlock();
16637
- if (engine.isProcessed || !currentBlock) return;
16638
- const toTop = e.source?.value === "before";
16639
- engine.content.insertionPoint.set(currentBlock, toTop);
16640
- engine.uiState.openBlockCatalog();
16641
- });
16642
- bus.define(BGE_COMMAND.updateGridItems, (e) => {
16643
- const currentBlock = engine.getCurrentBlock();
16644
- if (engine.isProcessed || !currentBlock) return;
16645
- const addOrRemove = e.source?.value === "-1" ? -1 : 1;
16646
- if (addOrRemove === -1 && !confirm("ブロック内の最後の要素を削除します。\n削除した要素はもとに戻すことはできません。\n削除してもよろしいですか?")) return;
16647
- currentBlock.updateGridItems(addOrRemove, engine);
16648
- engine.save();
16649
- });
16650
- bus.define(BGE_COMMAND.openBlockOptions, () => {
16651
- const currentBlock = engine.getCurrentBlock();
16652
- if (engine.isProcessed || !currentBlock) return;
16653
- engine.uiState.openBlockOptions(currentBlock);
16654
- });
16655
- bus.define(BGE_COMMAND.copyBlock, () => {
16656
- const currentBlock = engine.getCurrentBlock();
16657
- if (engine.isProcessed || !currentBlock) return;
16658
- const json = currentBlock.toJSONStringify();
16659
- sessionStorage.setItem(engine.storageKey.blockClipboard, json);
16660
- alert("ブロックをコピーしました。\nブロックの追加ボタンからペースト(貼り付け)することができます。");
16661
- });
16662
- bus.define(BGE_COMMAND.removeBlock, async () => {
16663
- const currentBlock = engine.getCurrentBlock();
16664
- if (engine.isProcessed || !currentBlock) return;
16665
- if (!confirm("ブロックを削除します。\n削除したブロックはもとに戻すことはできません。\n削除してもよろしいですか?")) return;
16666
- {
16667
- using _processing = beginProcessing(engine);
16668
- await Promise.resolve();
16669
- currentBlock.remove();
16670
- engine.clearCurrentBlock();
16671
- }
16672
- engine.save();
16673
- });
16674
- bus.define(BGE_COMMAND.insertInitialBlock, () => {
16675
- if (engine.isProcessed) return;
16676
- engine.content.insertionPoint.set(null, false);
16677
- engine.uiState.openBlockCatalog();
16678
- });
16679
- bus.define(BGE_COMMAND.addBlock, async (e) => {
16680
- const source = e.source;
16681
- const category = source?.dataset["category"];
16682
- const index = Number(source?.dataset["index"]);
16683
- const definition = category ? catalog[category]?.[index]?.definition : void 0;
16684
- if (!definition) return;
16685
- engine.uiState.closeDialog();
16686
- await engine.addBlock(definition);
16687
- });
16688
- bus.define(BGE_COMMAND.switchContent, (e) => {
16689
- if (e.source?.value === "main") engine.showMain();
16690
- else engine.showDraft();
16691
- });
16692
- bus.define(BGE_COMMAND.copyMainToDraft, async () => {
16693
- if (await engine.mainToDraft(() => confirm("本稿内容を下書きへ上書きしてもよろしいですか?"))) engine.showDraft();
16694
- });
16695
- bus.define(BGE_COMMAND.copyDraftToMain, async () => {
16696
- if (await engine.draftToMain(() => confirm("下書き内容を本稿へ上書きしてもよろしいですか?"))) engine.showMain();
16697
- });
16698
- bus.define(BGE_COMMAND.pasteBlock, async () => {
16699
- const jsonString = sessionStorage.getItem(engine.storageKey.blockClipboard);
16700
- if (!jsonString) {
16701
- alert("クリップボードにブロックデータがありません。");
16702
- return;
16703
- }
16704
- let blockData;
16705
- try {
16706
- blockData = JSON.parse(jsonString);
16707
- } catch (error) {
16708
- console.error("Invalid JSON in clipboard:", error);
16709
- alert("ブロックの貼り付けに失敗しました。\nクリップボードのデータが破損している可能性があります。\nもう一度ブロックをコピーしてください。");
16710
- return;
16711
- }
16712
- engine.uiState.closeDialog();
16713
- await engine.addBlock(blockData);
16714
- sessionStorage.removeItem(engine.storageKey.blockClipboard);
16715
- });
16716
- }
16717
- //#endregion
16718
- //#region src/components/draft-switcher.module.css
16719
- var draftBtn = "_draftBtn_14xtl_1";
16720
- var draftTabBtn = "_draftTabBtn_14xtl_16";
16721
- var draftCopyBtn = "_draftCopyBtn_14xtl_47";
16722
- var draft_switcher_module_default = {
16723
- draftBtn,
16724
- draftTabBtn,
16725
- draftCopyBtn
16726
- };
16727
- //#endregion
16728
- //#region src/components/draft-switcher.tsx
15713
+ //#region src/engine-context.ts
15714
+ var EngineContext = createContext(null);
16729
15715
  /**
16730
- * Main/draft content switcher. Switching and copying are declared as
16731
- * engine commands; the pressed state follows the engine's
16732
- * `bge:switch-content` event and the source-view indicator follows
16733
- * `engine.uiState.sourceMode` — no state is duplicated locally.
16734
- *
16735
- * The alt+double-click source-view toggle is kept as a DOM event —
16736
- * double-click has no Invoker Commands equivalent (the no-click rule
16737
- * targets single-click activation).
15716
+ * Wrap a subtree with the engine instance it belongs to. Every component
15717
+ * rendered under a `BurgerEditorRoot` / editable-area tree reads the engine
15718
+ * through {@link useEngine} instead of taking it as a prop — this is the
15719
+ * single dependency-injection point for the whole client UI.
16738
15720
  * @param root0
16739
15721
  * @param root0.engine
16740
- * @example
16741
- * ```tsx
16742
- * const container = document.createElement('div');
16743
- * engine.viewArea.insertAdjacentElement('beforebegin', container);
16744
- * reactMount(<DraftSwitcher engine={engine} />, container);
16745
- * ```
16746
- */
16747
- function DraftSwitcher({ engine }) {
16748
- const sourceMode = useUIState(engine, (s) => s.sourceMode);
16749
- const [isMain, setIsMain] = useState(engine.content.type === "main");
16750
- useEffect(() => {
16751
- const update = () => {
16752
- setIsMain(engine.content.type === "main");
16753
- };
16754
- engine.el.addEventListener("bge:switch-content", update);
16755
- return () => {
16756
- engine.el.removeEventListener("bge:switch-content", update);
16757
- };
16758
- }, [engine]);
16759
- const isVisualMode = !sourceMode[isMain ? "main" : "draft"];
16760
- const toggleDisplayMode = () => {
16761
- engine.uiState.toggleSourceMode(engine.content.type);
16762
- };
16763
- const onDblClickMain = (e) => {
16764
- if (!e.altKey || !isMain) return;
16765
- engine.showMain();
16766
- toggleDisplayMode();
16767
- };
16768
- const onDblClickDraft = (e) => {
16769
- if (!e.altKey || isMain) return;
16770
- engine.showDraft();
16771
- toggleDisplayMode();
16772
- };
16773
- return /* @__PURE__ */ jsxs("div", {
16774
- className: draft_switcher_module_default["draftBtn"],
16775
- children: [/* @__PURE__ */ jsxs("div", {
16776
- className: draft_switcher_module_default["draftTabBtn"],
16777
- children: [/* @__PURE__ */ jsxs("button", {
16778
- type: "button",
16779
- "aria-pressed": isMain,
16780
- command: BGE_COMMAND.switchContent,
16781
- commandfor: COMMAND_BUS_ID,
16782
- value: "main",
16783
- onDoubleClick: onDblClickMain,
16784
- children: ["本稿モード", isMain && !isVisualMode ? /* @__PURE__ */ jsx("span", { children: "ソース表示" }) : null]
16785
- }), /* @__PURE__ */ jsxs("button", {
16786
- type: "button",
16787
- "aria-pressed": !isMain,
16788
- command: BGE_COMMAND.switchContent,
16789
- commandfor: COMMAND_BUS_ID,
16790
- value: "draft",
16791
- onDoubleClick: onDblClickDraft,
16792
- children: ["下書きモード", !isMain && !isVisualMode ? /* @__PURE__ */ jsx("span", { children: "ソース表示" }) : null]
16793
- })]
16794
- }), /* @__PURE__ */ jsx("div", {
16795
- className: draft_switcher_module_default["draftCopyBtn"],
16796
- children: isMain ? /* @__PURE__ */ jsx("button", {
16797
- type: "button",
16798
- command: BGE_COMMAND.copyMainToDraft,
16799
- commandfor: COMMAND_BUS_ID,
16800
- children: "本稿を下書きにコピー"
16801
- }) : /* @__PURE__ */ jsx("button", {
16802
- type: "button",
16803
- command: BGE_COMMAND.copyDraftToMain,
16804
- commandfor: COMMAND_BUS_ID,
16805
- children: "下書きを本稿にコピー"
16806
- })
16807
- })]
16808
- });
16809
- }
16810
- //#endregion
16811
- //#region src/mount.tsx
16812
- /**
16813
- * Mount a React node into a DOM container and return a `Disposable`
16814
- * teardown handle, matching the `UICreator` contract shape used across
16815
- * the engine.
16816
- * @param node - The React node to render
16817
- * @param target - The DOM container
16818
- * @returns A handle that unmounts the root, via `using` or `cleanUp()`
16819
- * @example
16820
- * ```tsx
16821
- * using mount = reactMount(<DraftSwitcher engine={engine} />, container);
16822
- * // Root is unmounted automatically when `mount` goes out of scope.
16823
- * ```
16824
- */
16825
- function reactMount(node, target) {
16826
- const root = createRoot(target);
16827
- root.render(node);
16828
- const teardown = () => {
16829
- root.unmount();
16830
- };
16831
- return {
16832
- cleanUp: teardown,
16833
- [Symbol.dispose]: teardown
16834
- };
16835
- }
16836
- //#endregion
16837
- //#region src/animate-insertion.ts
16838
- var INSERTION_ANIMATION_DURATION_MS = 400;
16839
- /**
16840
- * Expand the block-insertion marker from zero to its natural height.
16841
- *
16842
- * Implemented with `Element.animate()` because its `finished` promise
16843
- * settles regardless of the animation's duration — a CSS transition +
16844
- * `transitionend` never fires when the duration is 0 (e.g. under
16845
- * `prefers-reduced-motion: reduce`), which would leave the engine's
16846
- * processing flag stuck. Cancellation is also treated as completion.
16847
- * @param markerEl - The marker element wrapping the inserted block
16848
- * @example
16849
- * ```ts
16850
- * await animateInsertion(markerEl);
16851
- * // The marker is fully expanded (or the animation was skipped).
16852
- * ```
16853
- */
16854
- async function animateInsertion(markerEl) {
16855
- markerEl.style.height = "auto";
16856
- const targetHeight = markerEl.getBoundingClientRect().height;
16857
- markerEl.style.overflow = "hidden";
16858
- const reducedMotion = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
16859
- await markerEl.animate([{ height: "0px" }, { height: `${targetHeight}px` }], {
16860
- duration: reducedMotion ? 0 : INSERTION_ANIMATION_DURATION_MS,
16861
- easing: "ease"
16862
- }).finished.then(() => {}, () => {});
16863
- }
16864
- //#endregion
16865
- //#region src/use-command.ts
16866
- /**
16867
- * Receive Invoker Commands API `command` events on the element the returned
16868
- * ref is attached to. Buttons address the element with
16869
- * `commandfor={idOfElement}`; `CommandEvent` does not bubble, so the ref
16870
- * must be on the exact `commandfor` target.
16871
- * @param handlers - Map of custom command names to handlers
16872
- * @returns A ref to attach to the receiving element
16873
- * @example
16874
- * ```tsx
16875
- * const rootId = useId();
16876
- * const rootRef = useCommand<HTMLDivElement>({
16877
- * '--select-tab': (e) => {
16878
- * setCurrent(Number((e.source as HTMLButtonElement | null)?.value));
16879
- * },
16880
- * });
16881
- * return (
16882
- * <div ref={rootRef} id={rootId}>
16883
- * <button command="--select-tab" commandfor={rootId} value="1">タブ1</button>
16884
- * </div>
16885
- * );
16886
- * ```
16887
- */
16888
- function useCommand(handlers) {
16889
- const ref = useRef(null);
16890
- const handlersRef = useRef(handlers);
16891
- useEffect(() => {
16892
- handlersRef.current = handlers;
16893
- });
16894
- useEffect(() => {
16895
- const el = ref.current;
16896
- if (!el) return;
16897
- const onCommand = (event) => {
16898
- const handler = handlersRef.current[event.command];
16899
- handler?.(event);
16900
- };
16901
- el.addEventListener("command", onCommand);
16902
- return () => {
16903
- el.removeEventListener("command", onCommand);
16904
- };
16905
- }, []);
16906
- return ref;
16907
- }
16908
- //#endregion
16909
- //#region src/components/block-menu-button.module.css
16910
- var wrapper = "_wrapper_t7zhr_1";
16911
- var block_menu_button_module_default = { wrapper };
16912
- //#endregion
16913
- //#region src/components/block-menu-button.tsx
16914
- /**
16915
- * Icon button of the block menu with an anchored tooltip. The action is
16916
- * declared with the Invoker Commands API instead of a click handler.
16917
- * @param root0
16918
- * @param root0.label
16919
- * @param root0.command
16920
- * @param root0.commandfor
16921
- * @param root0.value
16922
15722
  * @param root0.children
16923
15723
  * @example
16924
15724
  * ```tsx
16925
- * <BlockMenuButton
16926
- * label="ブロックを削除"
16927
- * command={BGE_COMMAND.removeBlock}
16928
- * commandfor={COMMAND_BUS_ID}>
16929
- * <IconTrash />
16930
- * </BlockMenuButton>
15725
+ * <EngineProvider engine={engine}>
15726
+ * <BurgerEditorRoot />
15727
+ * </EngineProvider>
16931
15728
  * ```
16932
15729
  */
16933
- function BlockMenuButton({ label, command, commandfor, value, children }) {
16934
- const uid = useId();
16935
- return /* @__PURE__ */ jsxs("div", {
16936
- className: block_menu_button_module_default["wrapper"],
16937
- style: { "--name": `--anchor-${CSS.escape(uid)}` },
16938
- children: [/* @__PURE__ */ jsx("button", {
16939
- type: "button",
16940
- "aria-labelledby": uid,
16941
- command,
16942
- commandfor,
16943
- value,
16944
- children
16945
- }), /* @__PURE__ */ jsx("span", {
16946
- id: uid,
16947
- children: label
16948
- })]
16949
- });
15730
+ function EngineProvider({ engine, children }) {
15731
+ return createElement(EngineContext, { value: engine }, children);
16950
15732
  }
16951
- //#endregion
16952
- //#region src/components/block-menu.module.css
16953
- var bgeMenuBase = "_bgeMenuBase_2cydd_1";
16954
- var bgeMenuMargin = "_bgeMenuMargin_2cydd_10";
16955
- var bgeMenu = "_bgeMenu_2cydd_1";
16956
- var bgeItemOverlay = "_bgeItemOverlay_2cydd_68";
16957
- var bgeMoveGroup = "_bgeMoveGroup_2cydd_85";
16958
- var bgeStandardGroup = "_bgeStandardGroup_2cydd_86";
16959
- var block_menu_module_default = {
16960
- bgeMenuBase,
16961
- bgeMenuMargin,
16962
- bgeMenu,
16963
- bgeItemOverlay,
16964
- bgeMoveGroup,
16965
- bgeStandardGroup
16966
- };
16967
- //#endregion
16968
- //#region src/components/block-menu-view.tsx
16969
- /**
16970
- * `BlockMenu` の描画専用の中身。マウス追跡・`BurgerBlock` 解決・
16971
- * `engine` 接続は一切持たず、位置とアイテム矩形を props で受け取って
16972
- * 並べるだけの純粋なプレゼンテーションコンポーネント。
16973
- *
16974
- * `BurgerBlock` の実インスタンス生成なしに見た目だけ確認したい用途
16975
- * (Storybook)のために `BlockMenu` から切り出されている。
16976
- * @param root0
16977
- * @param root0.rootRef
16978
- * @param root0.menuId
16979
- * @param root0.visible
16980
- * @param root0.geometry
16981
- * @param root0.itemRects
16982
- * @param root0.isMutable
16983
- * @example
16984
- * ```tsx
16985
- * <BlockMenuView
16986
- * rootRef={rootRef}
16987
- * menuId="bge-block-menu"
16988
- * visible
16989
- * geometry={{ width: 100, height: 40, x: 0, y: 0, marginBlockEnd: 0, marginBlockEndValue: '0px' }}
16990
- * itemRects={[]}
16991
- * isMutable
16992
- * />
16993
- * ```
16994
- */
16995
- function BlockMenuView({ rootRef, menuId, visible, geometry, itemRects, isMutable }) {
16996
- return /* @__PURE__ */ jsxs("div", {
16997
- ref: rootRef,
16998
- id: menuId,
16999
- hidden: !visible,
17000
- className: block_menu_module_default["bgeMenuBase"],
17001
- style: {
17002
- "--width": `${geometry.width}px`,
17003
- "--height": `${geometry.height}px`,
17004
- "--x": `${geometry.x}px`,
17005
- "--y": `${geometry.y}px`,
17006
- "--margin-block-end": `${geometry.marginBlockEnd ?? "0"}px`
17007
- },
17008
- children: [
17009
- itemRects.map((rect, index) => /* @__PURE__ */ jsx("button", {
17010
- type: "button",
17011
- className: block_menu_module_default["bgeItemOverlay"],
17012
- "aria-label": "コンテンツを編集",
17013
- command: "--open-item-editor",
17014
- commandfor: menuId,
17015
- value: index,
17016
- style: {
17017
- insetInlineStart: `${rect.x}px`,
17018
- insetBlockStart: `${rect.y}px`,
17019
- inlineSize: `${rect.width}px`,
17020
- blockSize: `${rect.height}px`
17021
- }
17022
- }, index)),
17023
- /* @__PURE__ */ jsxs("div", {
17024
- className: block_menu_module_default["bgeMenu"],
17025
- children: [/* @__PURE__ */ jsxs("div", {
17026
- className: block_menu_module_default["bgeMoveGroup"],
17027
- children: [/* @__PURE__ */ jsx(BlockMenuButton, {
17028
- label: "ひとつ上へ移動",
17029
- command: BGE_COMMAND.moveBlock,
17030
- commandfor: COMMAND_BUS_ID,
17031
- value: "up",
17032
- children: /* @__PURE__ */ jsx(IconArrowBigUpLine, {})
17033
- }), /* @__PURE__ */ jsx(BlockMenuButton, {
17034
- label: "ひとつ下へ移動",
17035
- command: BGE_COMMAND.moveBlock,
17036
- commandfor: COMMAND_BUS_ID,
17037
- value: "down",
17038
- children: /* @__PURE__ */ jsx(IconArrowBigDownLine, {})
17039
- })]
17040
- }), /* @__PURE__ */ jsxs("div", {
17041
- className: block_menu_module_default["bgeStandardGroup"],
17042
- children: [
17043
- /* @__PURE__ */ jsx(BlockMenuButton, {
17044
- label: "上にブロックを追加",
17045
- command: BGE_COMMAND.insertBlock,
17046
- commandfor: COMMAND_BUS_ID,
17047
- value: "before",
17048
- children: /* @__PURE__ */ jsx(IconRowInsertTop, {})
17049
- }),
17050
- /* @__PURE__ */ jsx(BlockMenuButton, {
17051
- label: "下にブロックを追加",
17052
- command: BGE_COMMAND.insertBlock,
17053
- commandfor: COMMAND_BUS_ID,
17054
- value: "after",
17055
- children: /* @__PURE__ */ jsx(IconRowInsertBottom, {})
17056
- }),
17057
- isMutable ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(BlockMenuButton, {
17058
- label: "ブロック内に要素を追加",
17059
- command: BGE_COMMAND.updateGridItems,
17060
- commandfor: COMMAND_BUS_ID,
17061
- value: "+1",
17062
- children: /* @__PURE__ */ jsx(IconLayoutGridAdd, {})
17063
- }), /* @__PURE__ */ jsx(BlockMenuButton, {
17064
- label: "ブロック内の要素を削除",
17065
- command: BGE_COMMAND.updateGridItems,
17066
- commandfor: COMMAND_BUS_ID,
17067
- value: "-1",
17068
- children: /* @__PURE__ */ jsx(IconLayoutGridRemove, {})
17069
- })] }) : null,
17070
- /* @__PURE__ */ jsx(BlockMenuButton, {
17071
- label: "オプション設定",
17072
- command: BGE_COMMAND.openBlockOptions,
17073
- commandfor: COMMAND_BUS_ID,
17074
- children: /* @__PURE__ */ jsx(IconSettings, {})
17075
- }),
17076
- /* @__PURE__ */ jsx(BlockMenuButton, {
17077
- label: "ブロックをコピー",
17078
- command: BGE_COMMAND.copyBlock,
17079
- commandfor: COMMAND_BUS_ID,
17080
- children: /* @__PURE__ */ jsx(IconClipboardPlus, {})
17081
- }),
17082
- /* @__PURE__ */ jsx(BlockMenuButton, {
17083
- label: "ブロックを削除",
17084
- command: BGE_COMMAND.removeBlock,
17085
- commandfor: COMMAND_BUS_ID,
17086
- children: /* @__PURE__ */ jsx(IconTrash, {})
17087
- })
17088
- ]
17089
- })]
17090
- }),
17091
- /* @__PURE__ */ jsx("div", {
17092
- className: block_menu_module_default["bgeMenuMargin"],
17093
- children: /* @__PURE__ */ jsxs("span", { children: [
17094
- "余白: ",
17095
- geometry.marginBlockEndValue,
17096
- " (",
17097
- geometry.marginBlockEnd,
17098
- "px)"
17099
- ] })
17100
- })
17101
- ]
17102
- });
17103
- }
17104
- //#endregion
17105
- //#region src/components/block-menu.tsx
17106
15733
  /**
17107
- * Hover menu over the selected block inside the editable area iframe.
17108
- * Block operations are declared as engine commands; positioning and
17109
- * visibility are React state owned entirely by this component — the
17110
- * single source of truth. While `engine.uiState.processing` is true the
17111
- * menu hides itself by subscribing to the store; nothing outside React
17112
- * ever writes this component's `hidden` attribute (a direct DOM write
17113
- * would leave React's `visible` state out of sync and a later same-value
17114
- * `setVisible(true)` would be skipped, leaving the menu stuck hidden).
15734
+ * Read the engine instance from the nearest {@link EngineProvider}.
17115
15735
  *
17116
- * マウス追跡・`BurgerBlock` 解決・`engine` 接続を担うコンテナで、
17117
- * 実際の描画は {@link BlockMenuView} に委譲する。`BlockMenuView` は
17118
- * `BurgerBlock` の実インスタンスなしに見た目だけ確認できるため、
17119
- * Storybook 等では `BlockMenuView` を直接使う。
17120
- * @param root0
17121
- * @param root0.engine
17122
- * @param root0.container
15736
+ * Every root the client mounts (`BurgerEditorRoot`, the editable-area
15737
+ * tree, `DraftSwitcher`) wraps itself in an `EngineProvider`, so item
15738
+ * `Editor` components and every `@burger-editor/client/ui` component can
15739
+ * call this instead of taking `engine` as a prop.
15740
+ * @returns The engine instance
15741
+ * @throws {Error} When called outside an `EngineProvider`
17123
15742
  * @example
17124
15743
  * ```tsx
17125
- * <BlockMenu engine={engine} container={frameBody} />
17126
- * ```
17127
- */
17128
- function BlockMenu({ engine, container }) {
17129
- const menuId = useId();
17130
- const [currentBlock, setCurrentBlock] = useState(null);
17131
- const [visible, setVisible] = useState(false);
17132
- const [itemRects, setItemRects] = useState([]);
17133
- const itemsRef = useRef([]);
17134
- const [geometry, setGeometry] = useState({
17135
- width: 0,
17136
- height: 0,
17137
- x: 0,
17138
- y: 0,
17139
- marginBlockEnd: 0,
17140
- marginBlockEndValue: "0px"
17141
- });
17142
- const rootRef = useCommand({ "--open-item-editor": (e) => {
17143
- if (engine.isProcessed) return;
17144
- const index = Number(e.source?.value);
17145
- const item = itemsRef.current[index];
17146
- if (!item) throw new Error(`item overlay index ${index} does not resolve to an Item`);
17147
- engine.uiState.openItemEditor(item);
17148
- } });
17149
- const hide = useCallback(() => {
17150
- setVisible(false);
17151
- setCurrentBlock(null);
17152
- engine.clearCurrentBlock();
17153
- }, [engine]);
17154
- useEffect(() => {
17155
- return engine.uiState.subscribe(() => {
17156
- if (engine.uiState.getSnapshot().processing) hide();
17157
- });
17158
- }, [engine, hide]);
17159
- useEffect(() => {
17160
- const onBlockChange = (e) => {
17161
- setCurrentBlock(e.detail.block);
17162
- };
17163
- engine.el.addEventListener("bge:block-change", onBlockChange);
17164
- return () => {
17165
- engine.el.removeEventListener("bge:block-change", onBlockChange);
17166
- };
17167
- }, [engine]);
17168
- useEffect(() => {
17169
- const doc = container.ownerDocument;
17170
- const body = doc.body;
17171
- const win = doc.defaultView;
17172
- let mouseX = 0;
17173
- let mouseY = 0;
17174
- let raf = 0;
17175
- const updatePosition = () => {
17176
- const selected = getBlockAtPosition(doc, mouseX, mouseY);
17177
- if (!selected) {
17178
- hide();
17179
- return;
17180
- }
17181
- setVisible(true);
17182
- const { block, rect, marginBlockEnd } = selected;
17183
- setCurrentBlock(block);
17184
- setGeometry({
17185
- width: rect.width,
17186
- height: rect.height,
17187
- x: rect.left,
17188
- y: rect.top,
17189
- marginBlockEnd,
17190
- marginBlockEndValue: window.getComputedStyle(block.el).getPropertyValue("--bge-block-margin")
17191
- });
17192
- const itemEntries = [...block.el.querySelectorAll("[data-bgi]")].map((itemEl) => ({
17193
- el: itemEl,
17194
- item: Item.getInstance(itemEl)
17195
- })).filter((entry) => entry.item != null);
17196
- itemsRef.current = itemEntries.map((entry) => entry.item);
17197
- setItemRects(itemEntries.map(({ el: itemEl }) => {
17198
- const itemRect = itemEl.getBoundingClientRect();
17199
- return {
17200
- x: itemRect.left - rect.left,
17201
- y: itemRect.top - rect.top,
17202
- width: itemRect.width,
17203
- height: itemRect.height
17204
- };
17205
- }));
17206
- engine.componentObserver.notify("select-block", {
17207
- block,
17208
- width: rect.width,
17209
- height: rect.height,
17210
- x: rect.left,
17211
- y: rect.top,
17212
- marginBlockEnd
17213
- });
17214
- };
17215
- const scheduleUpdate = () => {
17216
- cancelAnimationFrame(raf);
17217
- if (engine.isProcessed) {
17218
- hide();
17219
- return;
17220
- }
17221
- raf = requestAnimationFrame(() => {
17222
- updatePosition();
17223
- });
17224
- };
17225
- const onMouseMove = (e) => {
17226
- mouseX = e.pageX;
17227
- mouseY = e.pageY;
17228
- scheduleUpdate();
17229
- };
17230
- const onHideEvent = () => hide();
17231
- body.addEventListener("mousemove", onMouseMove);
17232
- body.addEventListener("mouseleave", onHideEvent);
17233
- doc.addEventListener("mouseleave", onHideEvent);
17234
- win?.addEventListener("mouseleave", onHideEvent);
17235
- globalThis.addEventListener("resize", onHideEvent);
17236
- engine.el.addEventListener("bge:saved", scheduleUpdate);
17237
- const observer = new MutationObserver((mutations) => {
17238
- for (const mutation of mutations) for (const node of mutation.addedNodes) {
17239
- if (!(node instanceof HTMLElement)) continue;
17240
- const images = node.querySelectorAll("img");
17241
- for (const img of images) {
17242
- img.addEventListener("load", scheduleUpdate, { once: true });
17243
- img.addEventListener("error", scheduleUpdate, { once: true });
17244
- img.addEventListener("abort", scheduleUpdate, { once: true });
17245
- }
17246
- }
17247
- });
17248
- observer.observe(doc, {
17249
- childList: true,
17250
- subtree: true
17251
- });
17252
- return () => {
17253
- body.removeEventListener("mousemove", onMouseMove);
17254
- body.removeEventListener("mouseleave", onHideEvent);
17255
- doc.removeEventListener("mouseleave", onHideEvent);
17256
- win?.removeEventListener("mouseleave", onHideEvent);
17257
- globalThis.removeEventListener("resize", onHideEvent);
17258
- engine.el.removeEventListener("bge:saved", scheduleUpdate);
17259
- observer.disconnect();
17260
- cancelAnimationFrame(raf);
17261
- };
17262
- }, [
17263
- engine,
17264
- container,
17265
- hide
17266
- ]);
17267
- const isMutable = currentBlock?.isMutable() ?? false;
17268
- return /* @__PURE__ */ jsx(BlockMenuView, {
17269
- rootRef,
17270
- menuId,
17271
- visible,
17272
- geometry,
17273
- itemRects,
17274
- isMutable
17275
- });
17276
- }
17277
- //#endregion
17278
- //#region src/components/initial-insertion-button.tsx
17279
- /**
17280
- * Button shown in an empty editable area to insert the first block.
17281
- * Declares the engine command instead of taking a callback.
17282
- * @example
17283
- * ```tsx
17284
- * reactMount(<InitialInsertionButton />, container);
17285
- * ```
17286
- */
17287
- function InitialInsertionButton() {
17288
- return /* @__PURE__ */ jsx("button", {
17289
- className: "insert_after",
17290
- type: "button",
17291
- command: BGE_COMMAND.insertInitialBlock,
17292
- commandfor: COMMAND_BUS_ID,
17293
- children: "下に要素を追加"
17294
- });
17295
- }
17296
- //#endregion
17297
- //#region src/components/editable-area-view.tsx
17298
- var CONTAINER_PADDING = 10;
17299
- var CONTENT_ID = "bge-editable-area";
17300
- /**
17301
- *
17302
- * @param engine
17303
- * @param type
17304
- * @param value
17305
- * @param syncFromContent
17306
- */
17307
- function commitEditableAreaSource(engine, type, value, syncFromContent) {
17308
- const content = engine.getEditableContent(type);
17309
- if (!content) return;
17310
- content.replaceContents(value).then(() => {
17311
- engine.save();
17312
- syncFromContent(content);
17313
- });
17314
- }
17315
- /**
17316
- * The React shell of one editable area: the iframe hosting the edited
17317
- * content, the HTML source textarea, and the in-frame UI islands
17318
- * (block menu, initial insertion button) rendered through a portal.
17319
- *
17320
- * All presentation state is React state derived from `engine.uiState`
17321
- * and engine events — the engine never touches this component's DOM.
17322
- * The iframe is rendered unconditionally at a fixed position in the
17323
- * tree (visibility is `hidden` only) because unmounting an iframe
17324
- * destroys its document, and the engine owns the content inside it.
17325
- * @param root0
17326
- * @param root0.engine
17327
- * @param root0.type
17328
- * @param root0.initialContent
17329
- * @param root0.stylesheets
17330
- * @param root0.classList
17331
- * @param root0.onReady
17332
- * @example
17333
- * ```tsx
17334
- * root.render(
17335
- * <EditableAreaView
17336
- * engine={engine}
17337
- * type="main"
17338
- * initialContent={html}
17339
- * stylesheets={stylesheets}
17340
- * classList={classList}
17341
- * onReady={(host) => resolve(host)}
17342
- * />,
17343
- * );
15744
+ * function MyField() {
15745
+ * const engine = useEngine();
15746
+ * return <button onClick={() => engine.save()}>Save</button>;
15747
+ * }
17344
15748
  * ```
17345
15749
  */
17346
- function EditableAreaView({ engine, type, initialContent, stylesheets, classList, onReady }) {
17347
- const sourceMode = useUIState(engine, (s) => s.sourceMode[type]);
17348
- const processing = useUIState(engine, (s) => s.processing);
17349
- const dialogOpen = useUIState(engine, (s) => s.openDialog !== null);
17350
- const [active, setActive] = useState(type === "main");
17351
- const [sourceText, setSourceText] = useState(initialContent);
17352
- const [isEmpty, setIsEmpty] = useState(initialContent.trim() === "");
17353
- const [height, setHeight] = useState(0);
17354
- const [frameBody, setFrameBody] = useState(null);
17355
- const initializedRef = useRef(false);
17356
- const resizeObserverRef = useRef(null);
17357
- const initFrame = (iframe) => {
17358
- if (!iframe || initializedRef.current) return;
17359
- initializedRef.current = true;
17360
- const frameWindow = iframe.contentWindow;
17361
- if (!frameWindow) throw new Error("Impossible error: The contentWindow of created iframe is null.");
17362
- const frameDoc = frameWindow.document;
17363
- frameDoc.open();
17364
- frameDoc.write("<!doctype html><html><head></head><body></body></html>");
17365
- frameDoc.close();
17366
- for (const { path, id } of stylesheets) appendStylesheetTo(frameDoc, path, id);
17367
- const injectedUiStyle = frameDoc.createElement("style");
17368
- injectedUiStyle.textContent = `@layer ${CSS_LAYER.ui} {
17369
- [data-bge-component='block-menu'] {
17370
- position: absolute;
17371
- inset: 0;
17372
- z-index: 2147483647;
17373
- pointer-events: none;
17374
- }
17375
-
17376
- /* #0c7e9e はui.cssの--bge-ui-primary-colorと同じ値。iframe文書には
17377
- その:root変数定義が読み込まれない(このstyleタグがそもそも
17378
- その代替)ため、ここではvar()参照できずハードコードしている。
17379
- 将来テーマカラーを変更する際はこの値も揃えて更新すること */
17380
- @keyframes bge-highlight-blink {
17381
- 0%, 100% {
17382
- outline-color: transparent;
17383
- background-color: transparent;
17384
- }
17385
- 50% {
17386
- outline-color: #0c7e9e;
17387
- background-color: rgb(12 126 158 / 12%);
17388
- }
17389
- }
17390
-
17391
- [data-bge-highlight] {
17392
- outline: 3px solid transparent;
17393
- outline-offset: 2px;
17394
- animation: bge-highlight-blink 0.5s ease-in-out 2;
17395
- }
17396
- }`;
17397
- frameDoc.head.append(injectedUiStyle);
17398
- frameDoc.body.setAttribute("style", "margin: 0; border: 0;");
17399
- engine.commandBus.createReceiver(frameDoc.body);
17400
- const containerElement = frameDoc.createElement("div");
17401
- containerElement.id = CONTENT_ID;
17402
- containerElement.style.setProperty("padding", `${CONTAINER_PADDING}px`, "important");
17403
- containerElement.style.setProperty("overflow", "hidden", "important");
17404
- containerElement.style.setProperty("margin", "0", "important");
17405
- containerElement.style.setProperty("box-sizing", "border-box", "important");
17406
- containerElement.classList.add(...classList);
17407
- containerElement.dataset.bgeComponent = "editable-area";
17408
- frameDoc.body.append(containerElement);
17409
- if (typeof ResizeObserver !== "undefined") {
17410
- const observer = new ResizeObserver(() => {
17411
- requestAnimationFrame(() => {
17412
- setHeight(containerElement.getBoundingClientRect().height + 20);
17413
- });
17414
- });
17415
- observer.observe(containerElement);
17416
- resizeObserverRef.current = observer;
17417
- }
17418
- setFrameBody(frameDoc.body);
17419
- onReady({
17420
- containerElement,
17421
- animateInsertion
17422
- });
17423
- };
17424
- useEffect(() => {
17425
- return () => {
17426
- resizeObserverRef.current?.disconnect();
17427
- };
17428
- }, []);
17429
- useEffect(() => {
17430
- const onSwitch = (e) => {
17431
- setActive(e.detail.content === type);
17432
- };
17433
- const onSaved = (e) => {
17434
- const value = type === "main" ? e.detail.main : e.detail.draft ?? "";
17435
- setSourceText(value);
17436
- setIsEmpty(value.trim() === "");
17437
- };
17438
- engine.el.addEventListener("bge:switch-content", onSwitch);
17439
- engine.el.addEventListener("bge:saved", onSaved);
17440
- return () => {
17441
- engine.el.removeEventListener("bge:switch-content", onSwitch);
17442
- engine.el.removeEventListener("bge:saved", onSaved);
17443
- };
17444
- }, [engine, type]);
17445
- const sourceTextRef = useRef(sourceText);
17446
- useEffect(() => {
17447
- sourceTextRef.current = sourceText;
17448
- });
17449
- const syncFromContent = (content) => {
17450
- const value = content.getContentsAsString();
17451
- setSourceText(value);
17452
- setIsEmpty(value.trim() === "");
17453
- };
17454
- useEffect(() => {
17455
- let prevSourceMode = engine.uiState.getSnapshot().sourceMode[type];
17456
- return engine.uiState.subscribe(() => {
17457
- const nextSourceMode = engine.uiState.getSnapshot().sourceMode[type];
17458
- if (nextSourceMode === prevSourceMode) return;
17459
- prevSourceMode = nextSourceMode;
17460
- const content = engine.getEditableContent(type);
17461
- if (nextSourceMode) setSourceText(content?.getContentsAsString() ?? "");
17462
- else if (content) commitEditableAreaSource(engine, type, sourceTextRef.current, syncFromContent);
17463
- });
17464
- }, [engine, type]);
17465
- const commitSource = (value) => {
17466
- commitEditableAreaSource(engine, type, value, syncFromContent);
17467
- };
17468
- return /* @__PURE__ */ jsxs("div", {
17469
- "data-bge-component": `${type}-editable-area`,
17470
- "data-bge-component-mode": sourceMode ? "source" : "visual",
17471
- hidden: !active,
17472
- children: [
17473
- /* @__PURE__ */ jsx("textarea", {
17474
- "aria-label": "HTMLソース",
17475
- spellCheck: false,
17476
- hidden: !sourceMode,
17477
- disabled: !sourceMode,
17478
- value: sourceText,
17479
- onChange: (e) => setSourceText(e.currentTarget.value),
17480
- onBlur: (e) => commitSource(e.currentTarget.value)
17481
- }),
17482
- /* @__PURE__ */ jsx("iframe", {
17483
- title: type === "main" ? "本稿の編集エリア" : "下書きの編集エリア",
17484
- loading: "lazy",
17485
- style: {
17486
- inlineSize: "100%",
17487
- overflow: "hidden"
17488
- },
17489
- height,
17490
- hidden: sourceMode,
17491
- ref: initFrame
17492
- }),
17493
- frameBody ? createPortal(/* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
17494
- "data-bge-component": "block-menu",
17495
- children: /* @__PURE__ */ jsx(BlockMenu, {
17496
- engine,
17497
- container: frameBody
17498
- })
17499
- }), /* @__PURE__ */ jsx("div", {
17500
- "data-bge-component": "initial-insertion",
17501
- hidden: !(isEmpty && !processing && !dialogOpen),
17502
- children: /* @__PURE__ */ jsx(InitialInsertionButton, {})
17503
- })] }), frameBody) : null
17504
- ]
17505
- });
15750
+ function useEngine() {
15751
+ const engine = use(EngineContext);
15752
+ if (!engine) throw new Error("useEngine() must be called under an <EngineProvider>.");
15753
+ return engine;
17506
15754
  }
17507
15755
  //#endregion
17508
- export { IconRowInsertBottom as _, BlockMenuButton as a, formatByteSize as b, DraftSwitcher as c, useUIState as d, ItemEditorHost as f, IconTrash as g, BlockCatalog as h, BlockMenuView as i, registerEngineCommands as l, BlockOptions as m, InitialInsertionButton as n, useCommand as o, EditorDialog as p, BlockMenu as r, reactMount as s, EditableAreaView as t, useComponentEvent as u, createReactComponent as v, formatDate as x, BurgerEditorEngine as y };
15756
+ 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 };
17509
15757
 
17510
- //# sourceMappingURL=editable-area-view-C00DSDVk.js.map
15758
+ //# sourceMappingURL=engine-context-gX6mWHke.js.map