@burger-editor/client 4.0.0-alpha.74 → 4.0.0-alpha.76

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.
@@ -108,6 +108,11 @@ export declare class FileBrowserStore {
108
108
  * `Preview` can both show it) and selecting the resulting URL once the
109
109
  * server responds — a blob URL is selected immediately so the UI has
110
110
  * something to show while the upload is in flight.
111
+ *
112
+ * The blob URL is revoked once the upload settles. On failure the
113
+ * selection is restored to what it was before the upload (empty path if
114
+ * nothing was selected), so a revoked blob URL is never left selected
115
+ * for the dialog to confirm.
111
116
  * @param fileType - The file type to upload into
112
117
  * @param file - The file to upload
113
118
  * @throws {Error} When no `postFile` API is configured, or the server
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/file-browser/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,kBAAkB,EAClB,cAAc,EACd,QAAQ,EAER,MAAM,qBAAqB,CAAC;AAE7B;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,gBAAgB;IACzB,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,EAAE,CAAC,IAAI,QAAQ,C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Ac,CAAC;IA4BtD;;;;;;;OAOG;IACH,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,SAAI,GAAG,IAAI;IAU5D;;;;;;;;;;;;;;OAcG;IACG,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAkD3D;AAID;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,kBAAkB,GAAG,gBAAgB,CAOhF"}
package/dist/index.d.ts CHANGED
@@ -32,13 +32,14 @@ export declare function attachDraftSwitcher(engine: BurgerEditorEngine): (Dispos
32
32
  * @example
33
33
  * ```ts
34
34
  * import { createBurgerEditorClient, attachDraftSwitcher } from '@burger-editor/client';
35
- * import itemSeeds from '@burger-editor/blocks';
35
+ * import { generalCSS } from '@burger-editor/blocks';
36
+ * import { items } from '@burger-editor/blocks/editor';
36
37
  *
37
38
  * const { engine } = await createBurgerEditorClient({
38
39
  * root: '#editor',
39
40
  * config,
40
41
  * catalog,
41
- * items: itemSeeds,
42
+ * items,
42
43
  * initialContents: { main, draft },
43
44
  * generalCSS,
44
45
  * fileIO: serverAPI,
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAWzD,OAAO,gBAAgB,CAAC;AAExB,eAAO,MAAM,OAAO,QAAc,CAAC;AAEnC;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,kBAAkB;;UAgB7D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,wBAAwB,CAC7C,OAAO,EAAE,IAAI,CAAC,yBAAyB,EAAE,MAAM,CAAC;;GAsChD;AAED,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAWzD,OAAO,gBAAgB,CAAC;AAExB,eAAO,MAAM,OAAO,QAAc,CAAC;AAEnC;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,kBAAkB;;UAgB7D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,wBAAwB,CAC7C,OAAO,EAAE,IAAI,CAAC,yBAAyB,EAAE,MAAM,CAAC;;GAsChD;AAED,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/testing.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as UIStateStore, c as CommandBus, t as EngineProvider } from "./engine-context-gX6mWHke.js";
1
+ import { a as UIStateStore, c as CommandBus, t as EngineProvider } from "./engine-context-D0zt6fhJ.js";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { render } from "@testing-library/react";
4
4
  import { afterEach, beforeEach, vi } from "vitest";
package/dist/ui.js CHANGED
@@ -1,5 +1,5 @@
1
- import { d as formatDate, n as useEngine, t as EngineProvider, u as formatByteSize } from "./engine-context-gX6mWHke.js";
2
- import { _ as IconTrash, a as BlockMenuButton, c as reportRenderError, d as registerEngineCommands, f as useUIState, g as BlockCatalog, h as BlockOptions, i as BlockMenuView, l as reactMount, m as EditorDialog, n as InitialInsertionButton, o as useCommand, p as ItemEditorHost, r as BlockMenu, s as RootErrorBoundary, t as EditableAreaView, u as DraftSwitcher, v as IconRowInsertBottom, y as createReactComponent } from "./editable-area-view-DssYcTqQ.js";
1
+ import { d as formatDate, n as useEngine, t as EngineProvider, u as formatByteSize } from "./engine-context-D0zt6fhJ.js";
2
+ import { _ as IconTrash, a as BlockMenuButton, c as reportRenderError, d as registerEngineCommands, f as useUIState, g as BlockCatalog, h as BlockOptions, i as BlockMenuView, l as reactMount, m as EditorDialog, n as InitialInsertionButton, o as useCommand, p as ItemEditorHost, r as BlockMenu, s as RootErrorBoundary, t as EditableAreaView, u as DraftSwitcher, v as IconRowInsertBottom, y as createReactComponent } from "./editable-area-view-S2Uz7pl8.js";
3
3
  import { c } from "react/compiler-runtime";
4
4
  import { Fragment, use, useDeferredValue, useEffect, useEffectEvent, useId, useRef, useState, useSyncExternalStore, useTransition } from "react";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -380,6 +380,11 @@ var FileBrowserStore = class {
380
380
  * `Preview` can both show it) and selecting the resulting URL once the
381
381
  * server responds — a blob URL is selected immediately so the UI has
382
382
  * something to show while the upload is in flight.
383
+ *
384
+ * The blob URL is revoked once the upload settles. On failure the
385
+ * selection is restored to what it was before the upload (empty path if
386
+ * nothing was selected), so a revoked blob URL is never left selected
387
+ * for the dialog to confirm.
383
388
  * @param fileType - The file type to upload into
384
389
  * @param file - The file to upload
385
390
  * @throws {Error} When no `postFile` API is configured, or the server
@@ -388,6 +393,7 @@ var FileBrowserStore = class {
388
393
  async upload(fileType, file) {
389
394
  const postFile = this.#engine.serverAPI.postFile;
390
395
  const blob = URL.createObjectURL(file);
396
+ const previous = this.#state.selected[fileType];
391
397
  this.select(fileType, blob, file.size);
392
398
  this.#patch({ uploads: [...this.#state.uploads, {
393
399
  fileType,
@@ -407,8 +413,12 @@ var FileBrowserStore = class {
407
413
  if (res.error) throw new Error(`Failed to upload file: ${file.name}`);
408
414
  this.invalidate(fileType);
409
415
  this.select(fileType, res.uploaded.url, res.uploaded.size);
416
+ } catch (error) {
417
+ this.select(fileType, previous?.path ?? "", previous?.fileSize);
418
+ throw error;
410
419
  } finally {
411
420
  this.#patch({ uploads: this.#state.uploads.filter((u) => u.blob !== blob) });
421
+ URL.revokeObjectURL(blob);
412
422
  }
413
423
  }
414
424
  #emit() {