@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.
- package/README.md +22 -9
- package/dist/__tests__/setup.d.ts +2 -0
- package/dist/__tests__/setup.d.ts.map +1 -0
- package/dist/burger-editor-root.d.ts +3 -7
- package/dist/burger-editor-root.d.ts.map +1 -1
- package/dist/client.js +323 -133
- package/dist/client.js.map +1 -1
- package/dist/commands/register-engine-commands.d.ts +2 -1
- package/dist/commands/register-engine-commands.d.ts.map +1 -1
- package/dist/components/block-catalog.d.ts +3 -5
- package/dist/components/block-catalog.d.ts.map +1 -1
- package/dist/components/block-menu-button.d.ts +1 -1
- package/dist/components/block-menu-view.d.ts +7 -3
- package/dist/components/block-menu-view.d.ts.map +1 -1
- package/dist/components/block-menu.d.ts +2 -5
- package/dist/components/block-menu.d.ts.map +1 -1
- package/dist/components/block-options.d.ts +4 -6
- package/dist/components/block-options.d.ts.map +1 -1
- package/dist/components/draft-switcher.d.ts +11 -10
- package/dist/components/draft-switcher.d.ts.map +1 -1
- package/dist/components/editable-area-view.d.ts +11 -14
- package/dist/components/editable-area-view.d.ts.map +1 -1
- package/dist/components/file-list.d.ts +9 -9
- package/dist/components/file-list.d.ts.map +1 -1
- package/dist/components/file-uploader.d.ts +6 -6
- package/dist/components/file-uploader.d.ts.map +1 -1
- package/dist/components/front-matter-editor.d.ts +43 -11
- package/dist/components/front-matter-editor.d.ts.map +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/initial-insertion-button.d.ts +7 -2
- package/dist/components/initial-insertion-button.d.ts.map +1 -1
- package/dist/components/item-editor-host.d.ts +7 -6
- package/dist/components/item-editor-host.d.ts.map +1 -1
- package/dist/components/preview.d.ts +4 -7
- package/dist/components/preview.d.ts.map +1 -1
- package/dist/components/table-editor.d.ts.map +1 -1
- package/dist/components/wysiwyg-field.d.ts +11 -1
- package/dist/components/wysiwyg-field.d.ts.map +1 -1
- package/dist/editable-area-view-DssYcTqQ.js +2941 -0
- package/dist/editable-area-view-DssYcTqQ.js.map +1 -0
- package/dist/editor-dialog.d.ts +16 -7
- package/dist/editor-dialog.d.ts.map +1 -1
- package/dist/{editable-area-view-C00DSDVk.js → engine-context-gX6mWHke.js} +199 -1951
- package/dist/engine-context-gX6mWHke.js.map +1 -0
- package/dist/engine-context.d.ts +40 -0
- package/dist/engine-context.d.ts.map +1 -0
- package/dist/file-browser/store.d.ts +127 -0
- package/dist/file-browser/store.d.ts.map +1 -0
- package/dist/file-browser/use-external-file-selection.d.ts +39 -0
- package/dist/file-browser/use-external-file-selection.d.ts.map +1 -0
- package/dist/file-browser/use-file-browser.d.ts +17 -0
- package/dist/file-browser/use-file-browser.d.ts.map +1 -0
- package/dist/form/text-field.d.ts +3 -1
- package/dist/form/text-field.d.ts.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/mount.d.ts +6 -1
- package/dist/mount.d.ts.map +1 -1
- package/dist/root-error-boundary.d.ts +34 -0
- package/dist/root-error-boundary.d.ts.map +1 -0
- package/dist/testing/create-mock-engine.d.ts +30 -0
- package/dist/testing/create-mock-engine.d.ts.map +1 -0
- package/dist/testing/index.d.ts +4 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/render-with-engine.d.ts +20 -0
- package/dist/testing/render-with-engine.d.ts.map +1 -0
- package/dist/testing/suppress-console-error.d.ts +24 -0
- package/dist/testing/suppress-console-error.d.ts.map +1 -0
- package/dist/testing.js +119 -0
- package/dist/testing.js.map +1 -0
- package/dist/ui.d.ts +7 -1
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +1618 -537
- package/dist/ui.js.map +1 -1
- package/dist/use-command.d.ts +13 -4
- package/dist/use-command.d.ts.map +1 -1
- package/dist/use-engine.d.ts +16 -32
- package/dist/use-engine.d.ts.map +1 -1
- package/dist/use-mount-effect.d.ts +20 -0
- package/dist/use-mount-effect.d.ts.map +1 -0
- package/dist/view/create-react-view.d.ts +33 -9
- package/dist/view/create-react-view.d.ts.map +1 -1
- package/package.json +44 -17
- package/dist/editable-area-view-C00DSDVk.js.map +0 -1
package/dist/ui.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
4
|
+
import { Fragment, use, useDeferredValue, useEffect, useEffectEvent, useId, useRef, useState, useSyncExternalStore, useTransition } from "react";
|
|
3
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
6
|
import { createRoot } from "react-dom/client";
|
|
5
7
|
/**
|
|
@@ -208,6 +210,261 @@ var IconVideo = createReactComponent("outline", "video", "Video", [["path", {
|
|
|
208
210
|
"d": "M3 8a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2l0 -8",
|
|
209
211
|
"key": "svg-1"
|
|
210
212
|
}]]);
|
|
213
|
+
//#endregion
|
|
214
|
+
//#region src/file-browser/store.ts
|
|
215
|
+
/**
|
|
216
|
+
* A file currently selected for a given `FileType` inside a dialog — the
|
|
217
|
+
* path the item editor should apply, plus the byte size the old
|
|
218
|
+
* `file-select` component-observer payload used to carry.
|
|
219
|
+
*/
|
|
220
|
+
/**
|
|
221
|
+
* One upload in flight. Kept in the store (not local component state) so
|
|
222
|
+
* `FileList` and `Preview` — siblings under the same item editor — both
|
|
223
|
+
* see the same synthetic "uploading…" row / progress bar without a
|
|
224
|
+
* broadcast bus.
|
|
225
|
+
*/
|
|
226
|
+
var EMPTY_RESULT = {
|
|
227
|
+
error: false,
|
|
228
|
+
data: [],
|
|
229
|
+
pagination: {
|
|
230
|
+
current: 0,
|
|
231
|
+
total: 1
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* Cache key for a file-list query — used both to look up a cached
|
|
236
|
+
* promise and (via its `fileType` prefix) to find every cached page for
|
|
237
|
+
* a given file type on invalidation.
|
|
238
|
+
*
|
|
239
|
+
* `selectedPath` (present only on the very first read for a `fileType`,
|
|
240
|
+
* see {@link FileBrowserStore.read}) is folded into the key so that an
|
|
241
|
+
* initial read's response — which the server may have jumped to a
|
|
242
|
+
* different page than the one requested, to land on the selected file —
|
|
243
|
+
* never collides with a later, unrelated `{fileType, page, filter}`
|
|
244
|
+
* request for the *same nominal page* opened by a different item in the
|
|
245
|
+
* same engine session. Without this, a second item reusing page 0 would
|
|
246
|
+
* transparently receive the first item's page-jumped response instead of
|
|
247
|
+
* a real page 0.
|
|
248
|
+
* @param query - The query to key
|
|
249
|
+
* @param selectedPath - The `selected` path actually sent with this
|
|
250
|
+
* query, if any
|
|
251
|
+
*/
|
|
252
|
+
function queryKey(query, selectedPath) {
|
|
253
|
+
return `${query.fileType}:${query.page}:${query.filter}:${selectedPath ?? ""}`;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Per-engine file-browser state: paginated/filtered `getFileList` query
|
|
257
|
+
* results (cached by query, read through `use()`), the file currently
|
|
258
|
+
* selected per `FileType`, and in-flight upload progress.
|
|
259
|
+
*
|
|
260
|
+
* React-independent so it can be constructed once per engine and shared
|
|
261
|
+
* by every component that opens onto the same file browser (`FileList`,
|
|
262
|
+
* `FileUploader`, `Preview`, and the item's own `Editor`) without a
|
|
263
|
+
* window-level broadcast bus — see {@link getFileBrowserStore}.
|
|
264
|
+
* @example
|
|
265
|
+
* ```tsx
|
|
266
|
+
* const store = getFileBrowserStore(engine);
|
|
267
|
+
* const result = use(store.read({ fileType: 'image', page: 0, filter: '' }));
|
|
268
|
+
* const selected = useSyncExternalStore(store.subscribe, store.getSnapshot);
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
var FileBrowserStore = class {
|
|
272
|
+
getSnapshot = () => this.#state;
|
|
273
|
+
subscribe = (listener) => {
|
|
274
|
+
this.#listeners.add(listener);
|
|
275
|
+
return () => {
|
|
276
|
+
this.#listeners.delete(listener);
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
#engine;
|
|
280
|
+
#initialReadDone = /* @__PURE__ */ new Set();
|
|
281
|
+
#listeners = /* @__PURE__ */ new Set();
|
|
282
|
+
#queries = /* @__PURE__ */ new Map();
|
|
283
|
+
#state = {
|
|
284
|
+
selected: {},
|
|
285
|
+
uploads: []
|
|
286
|
+
};
|
|
287
|
+
/** Whether the engine's `serverAPI` supports deleting files. */
|
|
288
|
+
get canDelete() {
|
|
289
|
+
return !!this.#engine.serverAPI.deleteFile;
|
|
290
|
+
}
|
|
291
|
+
constructor(engine) {
|
|
292
|
+
this.#engine = engine;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Delete a file from the server and invalidate `fileType`'s cached
|
|
296
|
+
* pages so the list reflects the deletion on next read.
|
|
297
|
+
* @param fileType - The file type the file belongs to
|
|
298
|
+
* @param url - The file's URL
|
|
299
|
+
* @throws {Error} When the server reports the deletion failed
|
|
300
|
+
*/
|
|
301
|
+
async deleteFile(fileType, url) {
|
|
302
|
+
const deleteFile = this.#engine.serverAPI.deleteFile;
|
|
303
|
+
if (!deleteFile) return;
|
|
304
|
+
if ((await deleteFile(fileType, url)).error) throw new Error(`Failed to delete file: ${url}`);
|
|
305
|
+
this.invalidate(fileType);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Drop every cached page for `fileType` and notify subscribers, so the
|
|
309
|
+
* next `read()` for that type issues a fresh request (after an upload
|
|
310
|
+
* or a delete changes the underlying list).
|
|
311
|
+
* @param fileType - The file type whose cached pages should be dropped
|
|
312
|
+
*/
|
|
313
|
+
invalidate(fileType) {
|
|
314
|
+
const prefix = `${fileType}:`;
|
|
315
|
+
for (const key of this.#queries.keys()) if (key.startsWith(prefix)) this.#queries.delete(key);
|
|
316
|
+
this.#emit();
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Read (and cache) one page of the file list. The returned promise is
|
|
320
|
+
* stable per `{fileType, page, filter}` plus whether this particular
|
|
321
|
+
* read sent `selected` (see below) — safe to pass to `use()` directly
|
|
322
|
+
* from render, repeated calls with the same query return the same
|
|
323
|
+
* promise instead of re-suspending.
|
|
324
|
+
*
|
|
325
|
+
* The very first read for a given `fileType` also sends the currently
|
|
326
|
+
* selected file's path as `selected`, so the server can jump straight
|
|
327
|
+
* to the page that already contains it (e.g. re-opening an image item
|
|
328
|
+
* whose file isn't on page 0) instead of always starting at `page`.
|
|
329
|
+
* Later reads for that `fileType` (explicit pagination, search, or a
|
|
330
|
+
* post-upload/-delete refetch via {@link invalidate}) omit it — always
|
|
331
|
+
* including it would silently override the page the caller asked for.
|
|
332
|
+
*
|
|
333
|
+
* Because that jump means the response's actual page can differ from
|
|
334
|
+
* the requested one, `selected` is folded into the cache key (see
|
|
335
|
+
* {@link queryKey}): a later item opening the same `fileType` and
|
|
336
|
+
* nominal page never transparently receives the first item's
|
|
337
|
+
* page-jumped response — it misses the cache and gets a real page.
|
|
338
|
+
* @param query - The file type, page and filter to query
|
|
339
|
+
* @returns The (possibly still-pending, cached) file list page
|
|
340
|
+
*/
|
|
341
|
+
read(query) {
|
|
342
|
+
const selectedPath = !this.#initialReadDone.has(query.fileType) ? this.#state.selected[query.fileType]?.path : void 0;
|
|
343
|
+
const key = queryKey(query, selectedPath);
|
|
344
|
+
const cached = this.#queries.get(key);
|
|
345
|
+
if (cached) return cached;
|
|
346
|
+
this.#initialReadDone.add(query.fileType);
|
|
347
|
+
const getFileList = this.#engine.serverAPI.getFileList;
|
|
348
|
+
const options = {
|
|
349
|
+
page: query.page,
|
|
350
|
+
filter: query.filter,
|
|
351
|
+
selected: selectedPath
|
|
352
|
+
};
|
|
353
|
+
const promise = getFileList ? getFileList(query.fileType, options) : Promise.resolve(EMPTY_RESULT);
|
|
354
|
+
promise.catch(() => {
|
|
355
|
+
this.#queries.delete(key);
|
|
356
|
+
});
|
|
357
|
+
this.#queries.set(key, promise);
|
|
358
|
+
return promise;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Record the file currently selected for `fileType` — a no-op when the
|
|
362
|
+
* path is unchanged, so callers can call this unconditionally (e.g.
|
|
363
|
+
* every render) without causing redundant notifications.
|
|
364
|
+
* @param fileType - The file type being selected for
|
|
365
|
+
* @param path - The selected file's path, or `''` for "nothing selected"
|
|
366
|
+
* @param fileSize - The selected file's byte size, when known
|
|
367
|
+
*/
|
|
368
|
+
select(fileType, path, fileSize = 0) {
|
|
369
|
+
if (this.#state.selected[fileType]?.path === path) return;
|
|
370
|
+
this.#patch({ selected: {
|
|
371
|
+
...this.#state.selected,
|
|
372
|
+
[fileType]: {
|
|
373
|
+
path,
|
|
374
|
+
fileSize
|
|
375
|
+
}
|
|
376
|
+
} });
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Upload a file, tracking progress in `uploads` (so `FileList` and
|
|
380
|
+
* `Preview` can both show it) and selecting the resulting URL once the
|
|
381
|
+
* server responds — a blob URL is selected immediately so the UI has
|
|
382
|
+
* something to show while the upload is in flight.
|
|
383
|
+
* @param fileType - The file type to upload into
|
|
384
|
+
* @param file - The file to upload
|
|
385
|
+
* @throws {Error} When no `postFile` API is configured, or the server
|
|
386
|
+
* reports the upload failed
|
|
387
|
+
*/
|
|
388
|
+
async upload(fileType, file) {
|
|
389
|
+
const postFile = this.#engine.serverAPI.postFile;
|
|
390
|
+
const blob = URL.createObjectURL(file);
|
|
391
|
+
this.select(fileType, blob, file.size);
|
|
392
|
+
this.#patch({ uploads: [...this.#state.uploads, {
|
|
393
|
+
fileType,
|
|
394
|
+
blob,
|
|
395
|
+
uploaded: 0,
|
|
396
|
+
total: file.size || 1
|
|
397
|
+
}] });
|
|
398
|
+
try {
|
|
399
|
+
if (!postFile) throw new Error("postFile is not configured");
|
|
400
|
+
const res = await postFile(fileType, file, (uploaded, total) => {
|
|
401
|
+
this.#patch({ uploads: this.#state.uploads.map((u) => u.blob === blob ? {
|
|
402
|
+
...u,
|
|
403
|
+
uploaded,
|
|
404
|
+
total
|
|
405
|
+
} : u) });
|
|
406
|
+
});
|
|
407
|
+
if (res.error) throw new Error(`Failed to upload file: ${file.name}`);
|
|
408
|
+
this.invalidate(fileType);
|
|
409
|
+
this.select(fileType, res.uploaded.url, res.uploaded.size);
|
|
410
|
+
} finally {
|
|
411
|
+
this.#patch({ uploads: this.#state.uploads.filter((u) => u.blob !== blob) });
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
#emit() {
|
|
415
|
+
for (const listener of this.#listeners) listener();
|
|
416
|
+
}
|
|
417
|
+
#patch(patch) {
|
|
418
|
+
this.#state = {
|
|
419
|
+
...this.#state,
|
|
420
|
+
...patch
|
|
421
|
+
};
|
|
422
|
+
this.#emit();
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
var stores = /* @__PURE__ */ new WeakMap();
|
|
426
|
+
/**
|
|
427
|
+
* Get (creating on first access) the `FileBrowserStore` for `engine`. One
|
|
428
|
+
* store per engine, shared by every component under it — see
|
|
429
|
+
* {@link FileBrowserStore}.
|
|
430
|
+
* @param engine - The engine to get the store for
|
|
431
|
+
* @returns That engine's file-browser store
|
|
432
|
+
*/
|
|
433
|
+
function getFileBrowserStore(engine) {
|
|
434
|
+
let store = stores.get(engine);
|
|
435
|
+
if (!store) {
|
|
436
|
+
store = new FileBrowserStore(engine);
|
|
437
|
+
stores.set(engine, store);
|
|
438
|
+
}
|
|
439
|
+
return store;
|
|
440
|
+
}
|
|
441
|
+
//#endregion
|
|
442
|
+
//#region src/file-browser/use-file-browser.ts
|
|
443
|
+
/**
|
|
444
|
+
* Get the current engine's `FileBrowserStore` — file-list query cache,
|
|
445
|
+
* current selection and upload progress shared by `FileList`,
|
|
446
|
+
* `FileUploader`, `Preview` and the item's own `Editor`.
|
|
447
|
+
* @returns The engine's file-browser store
|
|
448
|
+
* @example
|
|
449
|
+
* ```tsx
|
|
450
|
+
* const fileBrowser = useFileBrowser();
|
|
451
|
+
* const selected = useSyncExternalStore(
|
|
452
|
+
* fileBrowser.subscribe,
|
|
453
|
+
* () => fileBrowser.getSnapshot().selected.image,
|
|
454
|
+
* );
|
|
455
|
+
* ```
|
|
456
|
+
*/
|
|
457
|
+
function useFileBrowser() {
|
|
458
|
+
const $ = c(2);
|
|
459
|
+
const engine = useEngine();
|
|
460
|
+
let t0;
|
|
461
|
+
if ($[0] !== engine) {
|
|
462
|
+
t0 = getFileBrowserStore(engine);
|
|
463
|
+
$[0] = engine;
|
|
464
|
+
$[1] = t0;
|
|
465
|
+
} else t0 = $[1];
|
|
466
|
+
return t0;
|
|
467
|
+
}
|
|
211
468
|
var file_list_module_default = {
|
|
212
469
|
ctrl: "_ctrl_1vnsv_1",
|
|
213
470
|
pagination: "_pagination_1vnsv_7",
|
|
@@ -271,14 +528,20 @@ var thumbnail_module_default = { thumbnail: "_thumbnail_bi2ve_1" };
|
|
|
271
528
|
* <Thumbnail src={file.url} />
|
|
272
529
|
* ```
|
|
273
530
|
*/
|
|
274
|
-
function Thumbnail(
|
|
531
|
+
function Thumbnail(t0) {
|
|
532
|
+
const $ = c(15);
|
|
533
|
+
const { src } = t0;
|
|
275
534
|
const [isLoaded, setIsLoaded] = useState(false);
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
535
|
+
let t1;
|
|
536
|
+
if ($[0] !== src) {
|
|
537
|
+
t1 = getExt(src);
|
|
538
|
+
$[0] = src;
|
|
539
|
+
$[1] = t1;
|
|
540
|
+
} else t1 = $[1];
|
|
541
|
+
const file = t1;
|
|
542
|
+
let t2;
|
|
543
|
+
if ($[2] !== file.ext || $[3] !== file.isAudio || $[4] !== file.isDoc || $[5] !== file.isImage || $[6] !== file.isPdf || $[7] !== file.isPpt || $[8] !== file.isVideo || $[9] !== file.isXls || $[10] !== src) {
|
|
544
|
+
t2 = file.isImage ? /* @__PURE__ */ jsx("img", {
|
|
282
545
|
src,
|
|
283
546
|
alt: "画像のプレビュー",
|
|
284
547
|
loading: "lazy",
|
|
@@ -297,127 +560,99 @@ function Thumbnail({ src }) {
|
|
|
297
560
|
}),
|
|
298
561
|
/* @__PURE__ */ jsx(IconVideo, {})
|
|
299
562
|
]
|
|
300
|
-
}) : file.isAudio ? /* @__PURE__ */ jsx(IconHeadphones, {}) : file.isDoc ? /* @__PURE__ */ jsx(IconFileTypeDoc, {}) : file.isPpt ? /* @__PURE__ */ jsx(IconFileTypePpt, {}) : file.isXls ? /* @__PURE__ */ jsx(IconFileTypeXls, {}) : file.isPdf ? /* @__PURE__ */ jsx(IconFileTypePdf, {}) : /* @__PURE__ */ jsx(IconFile, {})
|
|
301
|
-
|
|
563
|
+
}) : file.isAudio ? /* @__PURE__ */ jsx(IconHeadphones, {}) : file.isDoc ? /* @__PURE__ */ jsx(IconFileTypeDoc, {}) : file.isPpt ? /* @__PURE__ */ jsx(IconFileTypePpt, {}) : file.isXls ? /* @__PURE__ */ jsx(IconFileTypeXls, {}) : file.isPdf ? /* @__PURE__ */ jsx(IconFileTypePdf, {}) : /* @__PURE__ */ jsx(IconFile, {});
|
|
564
|
+
$[2] = file.ext;
|
|
565
|
+
$[3] = file.isAudio;
|
|
566
|
+
$[4] = file.isDoc;
|
|
567
|
+
$[5] = file.isImage;
|
|
568
|
+
$[6] = file.isPdf;
|
|
569
|
+
$[7] = file.isPpt;
|
|
570
|
+
$[8] = file.isVideo;
|
|
571
|
+
$[9] = file.isXls;
|
|
572
|
+
$[10] = src;
|
|
573
|
+
$[11] = t2;
|
|
574
|
+
} else t2 = $[11];
|
|
575
|
+
let t3;
|
|
576
|
+
if ($[12] !== isLoaded || $[13] !== t2) {
|
|
577
|
+
t3 = /* @__PURE__ */ jsx("span", {
|
|
578
|
+
className: thumbnail_module_default.thumbnail,
|
|
579
|
+
"data-bge-editor-ui-component": "thumbnail",
|
|
580
|
+
"data-loaded": isLoaded,
|
|
581
|
+
children: t2
|
|
582
|
+
});
|
|
583
|
+
$[12] = isLoaded;
|
|
584
|
+
$[13] = t2;
|
|
585
|
+
$[14] = t3;
|
|
586
|
+
} else t3 = $[14];
|
|
587
|
+
return t3;
|
|
302
588
|
}
|
|
303
589
|
//#endregion
|
|
304
590
|
//#region src/components/file-list.tsx
|
|
305
591
|
/**
|
|
306
|
-
* Paginated, searchable file list.
|
|
307
|
-
* engine
|
|
308
|
-
*
|
|
592
|
+
* Paginated, searchable file list. Reads its page through `use()` against
|
|
593
|
+
* the engine's `FileBrowserStore` (suspends into the dialog's Suspense
|
|
594
|
+
* boundary while loading); selection and in-flight uploads come from the
|
|
595
|
+
* same store, shared with `FileUploader` and the item's own `Editor`
|
|
596
|
+
* instead of a broadcast bus.
|
|
309
597
|
* @param root0
|
|
310
|
-
* @param root0.engine
|
|
311
598
|
* @param root0.fileType
|
|
312
599
|
* @example
|
|
313
600
|
* ```tsx
|
|
314
|
-
* <FileUploader
|
|
315
|
-
* <FileList
|
|
601
|
+
* <FileUploader fileType="image" />
|
|
602
|
+
* <FileList fileType="image" />
|
|
316
603
|
* ```
|
|
317
604
|
*/
|
|
318
|
-
function FileList({
|
|
605
|
+
function FileList({ fileType }) {
|
|
606
|
+
"use no memo";
|
|
607
|
+
const store = useFileBrowser();
|
|
319
608
|
const rootId = useId();
|
|
320
|
-
const
|
|
321
|
-
const deleteFile = engine.serverAPI.deleteFile;
|
|
322
|
-
const [fileList, setFileList] = useState([]);
|
|
323
|
-
const [selectedPath, setSelectedPath] = useState("");
|
|
609
|
+
const [page, setPage] = useState(0);
|
|
324
610
|
const [searchWord, setSearchWord] = useState("");
|
|
325
|
-
const
|
|
326
|
-
const [
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
url: path,
|
|
350
|
-
sizes: {}
|
|
351
|
-
}, ...prev.filter((file) => !file.url.startsWith("blob:"))]);
|
|
352
|
-
});
|
|
353
|
-
useComponentEvent(engine, "file-upload-progress", (p) => {
|
|
354
|
-
if (p.blob === selectedPath) setProgress({
|
|
355
|
-
uploaded: p.uploaded,
|
|
356
|
-
total: p.total
|
|
611
|
+
const deferredFilter = useDeferredValue(searchWord);
|
|
612
|
+
const [isPending, startTransition] = useTransition();
|
|
613
|
+
const selected = useSyncExternalStore(store.subscribe, () => store.getSnapshot().selected[fileType]);
|
|
614
|
+
const myUploads = useSyncExternalStore(store.subscribe, () => store.getSnapshot().uploads).filter((u) => u.fileType === fileType);
|
|
615
|
+
const result = use(store.read({
|
|
616
|
+
fileType,
|
|
617
|
+
page,
|
|
618
|
+
filter: deferredFilter
|
|
619
|
+
}));
|
|
620
|
+
const totalPage = result.pagination.total;
|
|
621
|
+
const currentPage = result.pagination.current;
|
|
622
|
+
const files = [...myUploads.map((u_0) => ({
|
|
623
|
+
fileId: "",
|
|
624
|
+
name: "",
|
|
625
|
+
size: 0,
|
|
626
|
+
timestamp: 0,
|
|
627
|
+
url: u_0.blob,
|
|
628
|
+
sizes: {}
|
|
629
|
+
})), ...result.data.filter((f) => !myUploads.some((u_1) => u_1.blob === f.url))];
|
|
630
|
+
const paginate = (nextPage) => {
|
|
631
|
+
nextPage = Number.isNaN(nextPage) ? 0 : Math.min(Math.max(0, nextPage), totalPage - 1);
|
|
632
|
+
if (nextPage === currentPage) return;
|
|
633
|
+
startTransition(() => {
|
|
634
|
+
setPage(nextPage);
|
|
357
635
|
});
|
|
358
|
-
});
|
|
359
|
-
useComponentEvent(engine, "file-listup", ({ data }) => {
|
|
360
|
-
setFileList(data);
|
|
361
|
-
});
|
|
362
|
-
const paginate = (page) => {
|
|
363
|
-
page = Number.isNaN(page) ? 0 : Math.min(Math.max(0, page), totalPage - 1);
|
|
364
|
-
if (currentPage === page) return;
|
|
365
|
-
setCurrentPage(page);
|
|
366
|
-
window.clearTimeout(requestDebounce.current);
|
|
367
|
-
requestDebounce.current = window.setTimeout(async () => {
|
|
368
|
-
const result = await getFileList?.(fileType, { page });
|
|
369
|
-
if (result) {
|
|
370
|
-
setFileList(result.data);
|
|
371
|
-
setCurrentPage(result.pagination.current);
|
|
372
|
-
setTotalPage(result.pagination.total);
|
|
373
|
-
}
|
|
374
|
-
}, 100);
|
|
375
|
-
};
|
|
376
|
-
const search = (value) => {
|
|
377
|
-
if (searchWord === value) return;
|
|
378
|
-
setSearchWord(value);
|
|
379
|
-
window.clearTimeout(requestDebounce.current);
|
|
380
|
-
requestDebounce.current = window.setTimeout(async () => {
|
|
381
|
-
const result = await getFileList?.(fileType, { filter: value });
|
|
382
|
-
if (result) {
|
|
383
|
-
setFileList(result.data);
|
|
384
|
-
setCurrentPage(result.pagination.current);
|
|
385
|
-
setTotalPage(result.pagination.total);
|
|
386
|
-
}
|
|
387
|
-
}, 300);
|
|
388
636
|
};
|
|
389
637
|
const rootRef = useCommand({
|
|
390
638
|
"--paginate": (e) => {
|
|
391
639
|
const direction = e.source?.value;
|
|
392
640
|
paginate(direction === "prev" ? currentPage - 1 : currentPage + 1);
|
|
393
641
|
},
|
|
394
|
-
"--select-file": (
|
|
395
|
-
const source =
|
|
642
|
+
"--select-file": (e_0) => {
|
|
643
|
+
const source = e_0.source;
|
|
396
644
|
if (!source) return;
|
|
397
|
-
|
|
398
|
-
path: source.value,
|
|
399
|
-
fileSize: Number(source.dataset["size"] ?? "0"),
|
|
400
|
-
isEmpty: false,
|
|
401
|
-
isMounted: true
|
|
402
|
-
});
|
|
645
|
+
store.select(fileType, source.value, Number(source.dataset["size"] ?? "0"));
|
|
403
646
|
},
|
|
404
|
-
"--delete-file": (
|
|
405
|
-
const url =
|
|
647
|
+
"--delete-file": (e_1) => {
|
|
648
|
+
const url = e_1.source?.value;
|
|
406
649
|
if (!url) return;
|
|
407
|
-
(async () => {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
filter: searchWord
|
|
413
|
-
});
|
|
414
|
-
if (result) {
|
|
415
|
-
setFileList(result.data);
|
|
416
|
-
setCurrentPage(result.pagination.current);
|
|
417
|
-
setTotalPage(result.pagination.total);
|
|
650
|
+
startTransition(async () => {
|
|
651
|
+
try {
|
|
652
|
+
await store.deleteFile(fileType, url);
|
|
653
|
+
} catch {
|
|
654
|
+
alert("ファイルの削除に失敗しました。");
|
|
418
655
|
}
|
|
419
|
-
})().catch(() => {
|
|
420
|
-
alert("ファイルの削除に失敗しました。");
|
|
421
656
|
});
|
|
422
657
|
}
|
|
423
658
|
});
|
|
@@ -428,6 +663,7 @@ function FileList({ engine, fileType }) {
|
|
|
428
663
|
return /* @__PURE__ */ jsxs("div", {
|
|
429
664
|
ref: rootRef,
|
|
430
665
|
id: rootId,
|
|
666
|
+
"aria-busy": isPending,
|
|
431
667
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
432
668
|
className: file_list_module_default["ctrl"],
|
|
433
669
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
@@ -449,7 +685,7 @@ function FileList({ engine, fileType }) {
|
|
|
449
685
|
value: currentPage + 1,
|
|
450
686
|
min: "1",
|
|
451
687
|
max: totalPage,
|
|
452
|
-
onChange: (
|
|
688
|
+
onChange: (e_2) => paginate(e_2.currentTarget.valueAsNumber - 1),
|
|
453
689
|
"aria-label": "ページ番号"
|
|
454
690
|
}) }),
|
|
455
691
|
/* @__PURE__ */ jsx("span", { children: "/" }),
|
|
@@ -469,47 +705,50 @@ function FileList({ engine, fileType }) {
|
|
|
469
705
|
type: "search",
|
|
470
706
|
placeholder: "検索",
|
|
471
707
|
value: searchWord,
|
|
472
|
-
onChange: (
|
|
708
|
+
onChange: (e_3) => setSearchWord(e_3.currentTarget.value)
|
|
473
709
|
})]
|
|
474
710
|
}), /* @__PURE__ */ jsx("ul", {
|
|
475
711
|
className: file_list_module_default["list"],
|
|
476
|
-
children:
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
children: /* @__PURE__ */ jsx(
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
712
|
+
children: files.map((file) => {
|
|
713
|
+
const upload = myUploads.find((u_2) => u_2.blob === file.url);
|
|
714
|
+
return /* @__PURE__ */ jsxs("li", { children: [/* @__PURE__ */ jsxs("button", {
|
|
715
|
+
ref: file.url === selected?.path ? scrollToSelected : void 0,
|
|
716
|
+
className: file_list_module_default["file"],
|
|
717
|
+
type: "button",
|
|
718
|
+
"aria-pressed": file.url === selected?.path,
|
|
719
|
+
command: "--select-file",
|
|
720
|
+
commandfor: rootId,
|
|
721
|
+
value: file.url,
|
|
722
|
+
"data-size": file.size,
|
|
723
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
724
|
+
className: file_list_module_default["thumbnail"],
|
|
725
|
+
children: /* @__PURE__ */ jsx(Thumbnail, { src: file.url })
|
|
726
|
+
}), upload ? /* @__PURE__ */ jsxs("span", { children: [
|
|
727
|
+
"アップロード中...",
|
|
728
|
+
" ",
|
|
729
|
+
/* @__PURE__ */ jsxs("span", { children: [Math.floor(upload.uploaded / upload.total * 100), "%"] })
|
|
730
|
+
] }) : /* @__PURE__ */ jsxs("span", {
|
|
731
|
+
className: file_list_module_default["attr"],
|
|
732
|
+
children: [
|
|
733
|
+
/* @__PURE__ */ jsx("span", { children: "ID" }),
|
|
734
|
+
/* @__PURE__ */ jsx("span", { children: marked(file.fileId) }),
|
|
735
|
+
/* @__PURE__ */ jsx("span", { children: "名称" }),
|
|
736
|
+
/* @__PURE__ */ jsx("span", { children: marked(file.name) }),
|
|
737
|
+
/* @__PURE__ */ jsx("span", { children: "更新" }),
|
|
738
|
+
/* @__PURE__ */ jsx("span", { children: formatDate(file.timestamp / 1e3, "YYYY-MM-DD HH:mm") }),
|
|
739
|
+
/* @__PURE__ */ jsx("span", { children: "サイズ" }),
|
|
740
|
+
/* @__PURE__ */ jsx("span", { children: formatByteSize(file.size) })
|
|
741
|
+
]
|
|
742
|
+
})]
|
|
743
|
+
}), !upload && store.canDelete ? /* @__PURE__ */ jsx("button", {
|
|
744
|
+
className: file_list_module_default["delete"],
|
|
745
|
+
type: "button",
|
|
746
|
+
command: "--delete-file",
|
|
747
|
+
commandfor: rootId,
|
|
748
|
+
value: file.url,
|
|
749
|
+
children: "削除"
|
|
750
|
+
}) : null] }, file.url);
|
|
751
|
+
})
|
|
513
752
|
})]
|
|
514
753
|
});
|
|
515
754
|
}
|
|
@@ -532,73 +771,141 @@ var file_uploader_module_default = { uploader: "_uploader_obiwu_1" };
|
|
|
532
771
|
/**
|
|
533
772
|
* File upload control. The trigger button declares a local command and
|
|
534
773
|
* the handler opens the picker via `showPicker()` — no click handlers,
|
|
535
|
-
* no programmatic `click()`.
|
|
774
|
+
* no programmatic `click()`. The upload itself goes through the engine's
|
|
775
|
+
* `FileBrowserStore`, shared with `FileList`/`Preview` so they see the
|
|
776
|
+
* same progress without a broadcast bus.
|
|
536
777
|
* @param root0
|
|
537
|
-
* @param root0.engine
|
|
538
778
|
* @param root0.fileType
|
|
539
779
|
* @example
|
|
540
780
|
* ```tsx
|
|
541
|
-
* <FileUploader
|
|
781
|
+
* <FileUploader fileType="image" />
|
|
542
782
|
* ```
|
|
543
783
|
*/
|
|
544
|
-
function FileUploader(
|
|
784
|
+
function FileUploader(t0) {
|
|
785
|
+
const $ = c(15);
|
|
786
|
+
const { fileType } = t0;
|
|
787
|
+
const store = useFileBrowser();
|
|
545
788
|
const rootId = useId();
|
|
546
789
|
const inputRef = useRef(null);
|
|
790
|
+
const [, startTransition] = useTransition();
|
|
547
791
|
const accept = fileType === "image" ? "image/*" : "*";
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
}
|
|
567
|
-
});
|
|
568
|
-
if (!res || res.error) throw new Error(`Failed to upload file: ${file.name}`);
|
|
569
|
-
engine.componentObserver.notify("file-listup", {
|
|
570
|
-
fileType,
|
|
571
|
-
data: [res.uploaded]
|
|
572
|
-
});
|
|
573
|
-
engine.componentObserver.notify("file-select", {
|
|
574
|
-
path: res.uploaded.url,
|
|
575
|
-
fileSize: res.uploaded.size,
|
|
576
|
-
isEmpty: false
|
|
792
|
+
let t1;
|
|
793
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
794
|
+
t1 = { "--open-file-picker": () => {
|
|
795
|
+
inputRef.current?.showPicker();
|
|
796
|
+
} };
|
|
797
|
+
$[0] = t1;
|
|
798
|
+
} else t1 = $[0];
|
|
799
|
+
const rootRef = useCommand(t1);
|
|
800
|
+
let t2;
|
|
801
|
+
if ($[1] !== fileType || $[2] !== startTransition || $[3] !== store) {
|
|
802
|
+
t2 = () => {
|
|
803
|
+
const file = inputRef.current?.files?.[0];
|
|
804
|
+
if (!file) return;
|
|
805
|
+
startTransition(async () => {
|
|
806
|
+
try {
|
|
807
|
+
await store.upload(fileType, file);
|
|
808
|
+
} catch {
|
|
809
|
+
alert(`ファイルのアップロードに失敗しました: ${file.name}`);
|
|
810
|
+
}
|
|
577
811
|
});
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
812
|
+
};
|
|
813
|
+
$[1] = fileType;
|
|
814
|
+
$[2] = startTransition;
|
|
815
|
+
$[3] = store;
|
|
816
|
+
$[4] = t2;
|
|
817
|
+
} else t2 = $[4];
|
|
818
|
+
const stageFile = t2;
|
|
819
|
+
let t3;
|
|
820
|
+
if ($[5] !== accept || $[6] !== stageFile) {
|
|
821
|
+
t3 = /* @__PURE__ */ jsx("input", {
|
|
587
822
|
type: "file",
|
|
588
823
|
ref: inputRef,
|
|
589
|
-
onChange:
|
|
824
|
+
onChange: stageFile,
|
|
590
825
|
accept
|
|
591
|
-
})
|
|
826
|
+
});
|
|
827
|
+
$[5] = accept;
|
|
828
|
+
$[6] = stageFile;
|
|
829
|
+
$[7] = t3;
|
|
830
|
+
} else t3 = $[7];
|
|
831
|
+
let t4;
|
|
832
|
+
if ($[8] !== rootId) {
|
|
833
|
+
t4 = /* @__PURE__ */ jsx("button", {
|
|
592
834
|
type: "button",
|
|
593
835
|
command: "--open-file-picker",
|
|
594
836
|
commandfor: rootId,
|
|
595
837
|
children: "ファイルを追加アップロードする"
|
|
596
|
-
})
|
|
597
|
-
|
|
838
|
+
});
|
|
839
|
+
$[8] = rootId;
|
|
840
|
+
$[9] = t4;
|
|
841
|
+
} else t4 = $[9];
|
|
842
|
+
let t5;
|
|
843
|
+
if ($[10] !== rootId || $[11] !== rootRef || $[12] !== t3 || $[13] !== t4) {
|
|
844
|
+
t5 = /* @__PURE__ */ jsxs("div", {
|
|
845
|
+
ref: rootRef,
|
|
846
|
+
id: rootId,
|
|
847
|
+
className: file_uploader_module_default.uploader,
|
|
848
|
+
children: [t3, t4]
|
|
849
|
+
});
|
|
850
|
+
$[10] = rootId;
|
|
851
|
+
$[11] = rootRef;
|
|
852
|
+
$[12] = t3;
|
|
853
|
+
$[13] = t4;
|
|
854
|
+
$[14] = t5;
|
|
855
|
+
} else t5 = $[14];
|
|
856
|
+
return t5;
|
|
598
857
|
}
|
|
599
858
|
//#endregion
|
|
600
859
|
//#region src/components/front-matter-editor.tsx
|
|
601
860
|
/**
|
|
861
|
+
* Supported field types for Front Matter editor
|
|
862
|
+
*/
|
|
863
|
+
/**
|
|
864
|
+
* Field definition for Front Matter
|
|
865
|
+
*/
|
|
866
|
+
/**
|
|
867
|
+
* Owns the Front Matter field list — the actual data, as opposed to the
|
|
868
|
+
* view's own UI-only state (collapsed, add-dialog-open, in-progress JSON
|
|
869
|
+
* drafts). `createFrontMatterEditor`'s handle reads `getData()`/
|
|
870
|
+
* `getSnapshot()` directly and subscribes to be notified of changes,
|
|
871
|
+
* instead of a mutable closure variable updated from inside a React
|
|
872
|
+
* callback — the handle has no other way to read React state from
|
|
873
|
+
* outside React.
|
|
874
|
+
* @example
|
|
875
|
+
* ```ts
|
|
876
|
+
* const store = new FrontMatterStore({ title: 'A' });
|
|
877
|
+
* store.subscribe(() => console.log(store.getData()));
|
|
878
|
+
* store.setFields([{ key: 'title', type: 'text', value: 'B' }]);
|
|
879
|
+
* ```
|
|
880
|
+
*/
|
|
881
|
+
var FrontMatterStore = class {
|
|
882
|
+
getSnapshot = () => this.#fields;
|
|
883
|
+
subscribe = (listener) => {
|
|
884
|
+
this.#listeners.add(listener);
|
|
885
|
+
return () => {
|
|
886
|
+
this.#listeners.delete(listener);
|
|
887
|
+
};
|
|
888
|
+
};
|
|
889
|
+
#fields;
|
|
890
|
+
#listeners = /* @__PURE__ */ new Set();
|
|
891
|
+
constructor(initialData) {
|
|
892
|
+
this.#fields = parseInitialData(initialData);
|
|
893
|
+
}
|
|
894
|
+
getData() {
|
|
895
|
+
return toData(this.#fields);
|
|
896
|
+
}
|
|
897
|
+
setFields(next) {
|
|
898
|
+
this.#fields = next;
|
|
899
|
+
for (const listener of this.#listeners) listener();
|
|
900
|
+
}
|
|
901
|
+
};
|
|
902
|
+
/**
|
|
903
|
+
* Options for the Front Matter editor
|
|
904
|
+
*/
|
|
905
|
+
/**
|
|
906
|
+
* Handle returned by {@link createFrontMatterEditor}.
|
|
907
|
+
*/
|
|
908
|
+
/**
|
|
602
909
|
* Mount the Front Matter editor (a React component) into the given
|
|
603
910
|
* container.
|
|
604
911
|
*
|
|
@@ -619,51 +926,45 @@ function FileUploader({ engine, fileType }) {
|
|
|
619
926
|
* ```
|
|
620
927
|
*/
|
|
621
928
|
function createFrontMatterEditor(options) {
|
|
622
|
-
|
|
929
|
+
const store = new FrontMatterStore(options.initialData);
|
|
623
930
|
const originalFrontMatter = options.hasFrontMatter ? JSON.stringify(options.initialData) : void 0;
|
|
931
|
+
const unsubscribe = store.subscribe(() => {
|
|
932
|
+
options.onUpdated?.(store.getData());
|
|
933
|
+
});
|
|
624
934
|
const root = createRoot(options.container);
|
|
625
|
-
root.render(/* @__PURE__ */ jsx(FrontMatterEditorView, {
|
|
626
|
-
initialData: options.initialData,
|
|
627
|
-
onDataChange: (data) => {
|
|
628
|
-
latest = data;
|
|
629
|
-
options.onUpdated?.(data);
|
|
630
|
-
}
|
|
631
|
-
}));
|
|
935
|
+
root.render(/* @__PURE__ */ jsx(FrontMatterEditorView, { store }));
|
|
632
936
|
const teardown = () => {
|
|
937
|
+
unsubscribe();
|
|
633
938
|
root.unmount();
|
|
634
939
|
};
|
|
635
940
|
return {
|
|
636
|
-
getData: () =>
|
|
941
|
+
getData: () => store.getData(),
|
|
637
942
|
getOriginalFrontMatter: () => originalFrontMatter,
|
|
638
943
|
unmount: teardown,
|
|
639
944
|
[Symbol.dispose]: teardown
|
|
640
945
|
};
|
|
641
946
|
}
|
|
642
947
|
/**
|
|
643
|
-
* Front Matter
|
|
644
|
-
*
|
|
948
|
+
* Front Matterの動的フォーム本体。フィールド一覧は`store`(唯一の
|
|
949
|
+
* データソース)から読み、折りたたみ・追加ダイアログ・JSON下書きは
|
|
950
|
+
* この見た目だけのUI状態としてローカルに持つ。操作は Invoker Commands
|
|
645
951
|
* (`--fm-toggle` / `--fm-add-field` / `--fm-delete-field`)で受ける
|
|
646
952
|
* @param root0
|
|
647
|
-
* @param root0.
|
|
648
|
-
* @param root0.onDataChange
|
|
953
|
+
* @param root0.store
|
|
649
954
|
* @example
|
|
650
955
|
* ```tsx
|
|
651
|
-
* <FrontMatterEditorView
|
|
652
|
-
* initialData={{ title: 'ページ' }}
|
|
653
|
-
* onDataChange={(data) => console.log(data)}
|
|
654
|
-
* />
|
|
956
|
+
* <FrontMatterEditorView store={new FrontMatterStore({ title: 'ページ' })} />
|
|
655
957
|
* ```
|
|
656
958
|
*/
|
|
657
|
-
function FrontMatterEditorView({
|
|
959
|
+
function FrontMatterEditorView({ store }) {
|
|
658
960
|
const rootId = useId();
|
|
659
961
|
const dialogId = useId();
|
|
660
|
-
const
|
|
962
|
+
const fields = useSyncExternalStore(store.subscribe, store.getSnapshot);
|
|
661
963
|
const [isCollapsed, setIsCollapsed] = useState(false);
|
|
662
964
|
const [addDialogOpen, setAddDialogOpen] = useState(false);
|
|
663
965
|
const [jsonDrafts, setJsonDrafts] = useState({});
|
|
664
966
|
const applyFields = (next) => {
|
|
665
|
-
setFields(next);
|
|
666
|
-
onDataChange(toData(next));
|
|
967
|
+
store.setFields(next);
|
|
667
968
|
};
|
|
668
969
|
const updateFieldValue = (key, value) => {
|
|
669
970
|
applyFields(fields.map((f) => f.key === key ? {
|
|
@@ -679,22 +980,22 @@ function FrontMatterEditorView({ initialData, onDataChange }) {
|
|
|
679
980
|
setAddDialogOpen(true);
|
|
680
981
|
},
|
|
681
982
|
"--fm-delete-field": (e) => {
|
|
682
|
-
const
|
|
683
|
-
if (
|
|
684
|
-
applyFields(fields.filter((
|
|
685
|
-
setJsonDrafts((
|
|
686
|
-
const { [
|
|
983
|
+
const key_0 = e.source?.value;
|
|
984
|
+
if (key_0 == null) return;
|
|
985
|
+
applyFields(fields.filter((f_0) => f_0.key !== key_0));
|
|
986
|
+
setJsonDrafts((prev_0) => {
|
|
987
|
+
const { [key_0]: _removed, ...rest } = prev_0;
|
|
687
988
|
return rest;
|
|
688
989
|
});
|
|
689
990
|
}
|
|
690
991
|
});
|
|
691
|
-
const onAddSubmit = (
|
|
692
|
-
|
|
693
|
-
const formData = new FormData(
|
|
694
|
-
const
|
|
992
|
+
const onAddSubmit = (e_0) => {
|
|
993
|
+
e_0.preventDefault();
|
|
994
|
+
const formData = new FormData(e_0.currentTarget);
|
|
995
|
+
const key_1 = String(formData.get("key") ?? "");
|
|
695
996
|
const type = formData.get("type");
|
|
696
|
-
if (
|
|
697
|
-
key,
|
|
997
|
+
if (key_1 && !fields.some((f_1) => f_1.key === key_1)) applyFields([...fields, {
|
|
998
|
+
key: key_1,
|
|
698
999
|
type,
|
|
699
1000
|
value: getDefaultValue(type)
|
|
700
1001
|
}]);
|
|
@@ -746,10 +1047,10 @@ function FrontMatterEditorView({ initialData, onDataChange }) {
|
|
|
746
1047
|
field,
|
|
747
1048
|
inputId: `${rootId}-field-${field.key}`,
|
|
748
1049
|
jsonDraft: jsonDrafts[field.key],
|
|
749
|
-
onValueChange: (
|
|
1050
|
+
onValueChange: (value_0) => updateFieldValue(field.key, value_0),
|
|
750
1051
|
onJsonDraftChange: (text) => {
|
|
751
|
-
setJsonDrafts((
|
|
752
|
-
...
|
|
1052
|
+
setJsonDrafts((prev_1) => ({
|
|
1053
|
+
...prev_1,
|
|
753
1054
|
[field.key]: text
|
|
754
1055
|
}));
|
|
755
1056
|
}
|
|
@@ -784,50 +1085,149 @@ function FrontMatterEditorView({ initialData, onDataChange }) {
|
|
|
784
1085
|
* @param root0.onValueChange
|
|
785
1086
|
* @param root0.onJsonDraftChange
|
|
786
1087
|
*/
|
|
787
|
-
function FieldInput(
|
|
1088
|
+
function FieldInput(t0) {
|
|
1089
|
+
const $ = c(37);
|
|
1090
|
+
const { field, inputId, jsonDraft, onValueChange, onJsonDraftChange } = t0;
|
|
788
1091
|
switch (field.type) {
|
|
789
|
-
case "boolean":
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
1092
|
+
case "boolean": {
|
|
1093
|
+
const t1 = Boolean(field.value);
|
|
1094
|
+
let t2;
|
|
1095
|
+
if ($[0] !== onValueChange) {
|
|
1096
|
+
t2 = (e_3) => onValueChange(e_3.currentTarget.checked);
|
|
1097
|
+
$[0] = onValueChange;
|
|
1098
|
+
$[1] = t2;
|
|
1099
|
+
} else t2 = $[1];
|
|
1100
|
+
let t3;
|
|
1101
|
+
if ($[2] !== inputId || $[3] !== t1 || $[4] !== t2) {
|
|
1102
|
+
t3 = /* @__PURE__ */ jsx("input", {
|
|
1103
|
+
id: inputId,
|
|
1104
|
+
type: "checkbox",
|
|
1105
|
+
checked: t1,
|
|
1106
|
+
onChange: t2
|
|
1107
|
+
});
|
|
1108
|
+
$[2] = inputId;
|
|
1109
|
+
$[3] = t1;
|
|
1110
|
+
$[4] = t2;
|
|
1111
|
+
$[5] = t3;
|
|
1112
|
+
} else t3 = $[5];
|
|
1113
|
+
return t3;
|
|
1114
|
+
}
|
|
1115
|
+
case "number": {
|
|
1116
|
+
const t1 = field.value == null ? "" : String(field.value);
|
|
1117
|
+
let t2;
|
|
1118
|
+
if ($[6] !== onValueChange) {
|
|
1119
|
+
t2 = (e_2) => {
|
|
1120
|
+
onValueChange(e_2.currentTarget.value === "" ? null : Number(e_2.currentTarget.value));
|
|
1121
|
+
};
|
|
1122
|
+
$[6] = onValueChange;
|
|
1123
|
+
$[7] = t2;
|
|
1124
|
+
} else t2 = $[7];
|
|
1125
|
+
let t3;
|
|
1126
|
+
if ($[8] !== inputId || $[9] !== t1 || $[10] !== t2) {
|
|
1127
|
+
t3 = /* @__PURE__ */ jsx("input", {
|
|
1128
|
+
id: inputId,
|
|
1129
|
+
type: "number",
|
|
1130
|
+
value: t1,
|
|
1131
|
+
onChange: t2
|
|
1132
|
+
});
|
|
1133
|
+
$[8] = inputId;
|
|
1134
|
+
$[9] = t1;
|
|
1135
|
+
$[10] = t2;
|
|
1136
|
+
$[11] = t3;
|
|
1137
|
+
} else t3 = $[11];
|
|
1138
|
+
return t3;
|
|
1139
|
+
}
|
|
1140
|
+
case "date": {
|
|
1141
|
+
let t1;
|
|
1142
|
+
if ($[12] !== field.value) {
|
|
1143
|
+
t1 = toDateInputValue(field.value);
|
|
1144
|
+
$[12] = field.value;
|
|
1145
|
+
$[13] = t1;
|
|
1146
|
+
} else t1 = $[13];
|
|
1147
|
+
let t2;
|
|
1148
|
+
if ($[14] !== onValueChange) {
|
|
1149
|
+
t2 = (e_1) => onValueChange(e_1.currentTarget.value);
|
|
1150
|
+
$[14] = onValueChange;
|
|
1151
|
+
$[15] = t2;
|
|
1152
|
+
} else t2 = $[15];
|
|
1153
|
+
let t3;
|
|
1154
|
+
if ($[16] !== inputId || $[17] !== t1 || $[18] !== t2) {
|
|
1155
|
+
t3 = /* @__PURE__ */ jsx("input", {
|
|
1156
|
+
id: inputId,
|
|
1157
|
+
type: "date",
|
|
1158
|
+
value: t1,
|
|
1159
|
+
onChange: t2
|
|
1160
|
+
});
|
|
1161
|
+
$[16] = inputId;
|
|
1162
|
+
$[17] = t1;
|
|
1163
|
+
$[18] = t2;
|
|
1164
|
+
$[19] = t3;
|
|
1165
|
+
} else t3 = $[19];
|
|
1166
|
+
return t3;
|
|
1167
|
+
}
|
|
809
1168
|
case "json": {
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
1169
|
+
let t1;
|
|
1170
|
+
if ($[20] !== field.value || $[21] !== jsonDraft) {
|
|
1171
|
+
t1 = jsonDraft ?? stringifyJson(field.value);
|
|
1172
|
+
$[20] = field.value;
|
|
1173
|
+
$[21] = jsonDraft;
|
|
1174
|
+
$[22] = t1;
|
|
1175
|
+
} else t1 = $[22];
|
|
1176
|
+
const text = t1;
|
|
1177
|
+
const t2 = isValidJson(text) ? void 0 : "fm-editor-error";
|
|
1178
|
+
let t3;
|
|
1179
|
+
if ($[23] !== onJsonDraftChange || $[24] !== onValueChange) {
|
|
1180
|
+
t3 = (e_0) => {
|
|
1181
|
+
const nextText = e_0.currentTarget.value;
|
|
818
1182
|
onJsonDraftChange(nextText);
|
|
819
1183
|
try {
|
|
820
1184
|
onValueChange(JSON.parse(nextText));
|
|
821
1185
|
} catch {}
|
|
822
|
-
}
|
|
823
|
-
|
|
1186
|
+
};
|
|
1187
|
+
$[23] = onJsonDraftChange;
|
|
1188
|
+
$[24] = onValueChange;
|
|
1189
|
+
$[25] = t3;
|
|
1190
|
+
} else t3 = $[25];
|
|
1191
|
+
let t4;
|
|
1192
|
+
if ($[26] !== inputId || $[27] !== t2 || $[28] !== t3 || $[29] !== text) {
|
|
1193
|
+
t4 = /* @__PURE__ */ jsx("textarea", {
|
|
1194
|
+
id: inputId,
|
|
1195
|
+
rows: 3,
|
|
1196
|
+
className: t2,
|
|
1197
|
+
value: text,
|
|
1198
|
+
onChange: t3
|
|
1199
|
+
});
|
|
1200
|
+
$[26] = inputId;
|
|
1201
|
+
$[27] = t2;
|
|
1202
|
+
$[28] = t3;
|
|
1203
|
+
$[29] = text;
|
|
1204
|
+
$[30] = t4;
|
|
1205
|
+
} else t4 = $[30];
|
|
1206
|
+
return t4;
|
|
1207
|
+
}
|
|
1208
|
+
default: {
|
|
1209
|
+
const t1 = String(field.value ?? "");
|
|
1210
|
+
let t2;
|
|
1211
|
+
if ($[31] !== onValueChange) {
|
|
1212
|
+
t2 = (e) => onValueChange(e.currentTarget.value);
|
|
1213
|
+
$[31] = onValueChange;
|
|
1214
|
+
$[32] = t2;
|
|
1215
|
+
} else t2 = $[32];
|
|
1216
|
+
let t3;
|
|
1217
|
+
if ($[33] !== inputId || $[34] !== t1 || $[35] !== t2) {
|
|
1218
|
+
t3 = /* @__PURE__ */ jsx("input", {
|
|
1219
|
+
id: inputId,
|
|
1220
|
+
type: "text",
|
|
1221
|
+
value: t1,
|
|
1222
|
+
onChange: t2
|
|
1223
|
+
});
|
|
1224
|
+
$[33] = inputId;
|
|
1225
|
+
$[34] = t1;
|
|
1226
|
+
$[35] = t2;
|
|
1227
|
+
$[36] = t3;
|
|
1228
|
+
} else t3 = $[36];
|
|
1229
|
+
return t3;
|
|
824
1230
|
}
|
|
825
|
-
default: return /* @__PURE__ */ jsx("input", {
|
|
826
|
-
id: inputId,
|
|
827
|
-
type: "text",
|
|
828
|
-
value: String(field.value ?? ""),
|
|
829
|
-
onChange: (e) => onValueChange(e.currentTarget.value)
|
|
830
|
-
});
|
|
831
1231
|
}
|
|
832
1232
|
}
|
|
833
1233
|
/**
|
|
@@ -838,83 +1238,200 @@ function FieldInput({ field, inputId, jsonDraft, onValueChange, onJsonDraftChang
|
|
|
838
1238
|
* @param root0.onSubmit
|
|
839
1239
|
* @param root0.onClose
|
|
840
1240
|
*/
|
|
841
|
-
function AddFieldDialog(
|
|
1241
|
+
function AddFieldDialog(t0) {
|
|
1242
|
+
const $ = c(36);
|
|
1243
|
+
const { dialogId, onSubmit, onClose } = t0;
|
|
842
1244
|
const dialogRef = useRef(null);
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
1245
|
+
let t1;
|
|
1246
|
+
let t2;
|
|
1247
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1248
|
+
t1 = () => {
|
|
1249
|
+
const dialog = dialogRef.current;
|
|
1250
|
+
if (dialog && !dialog.open) dialog.showModal();
|
|
1251
|
+
};
|
|
1252
|
+
t2 = [];
|
|
1253
|
+
$[0] = t1;
|
|
1254
|
+
$[1] = t2;
|
|
1255
|
+
} else {
|
|
1256
|
+
t1 = $[0];
|
|
1257
|
+
t2 = $[1];
|
|
1258
|
+
}
|
|
1259
|
+
useEffect(t1, t2);
|
|
1260
|
+
let t3;
|
|
1261
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1262
|
+
t3 = /* @__PURE__ */ jsx("h3", { children: "フィールドを追加" });
|
|
1263
|
+
$[2] = t3;
|
|
1264
|
+
} else t3 = $[2];
|
|
1265
|
+
const t4 = `${dialogId}-key`;
|
|
1266
|
+
let t5;
|
|
1267
|
+
if ($[3] !== t4) {
|
|
1268
|
+
t5 = /* @__PURE__ */ jsx("label", {
|
|
1269
|
+
htmlFor: t4,
|
|
1270
|
+
children: "キー名"
|
|
1271
|
+
});
|
|
1272
|
+
$[3] = t4;
|
|
1273
|
+
$[4] = t5;
|
|
1274
|
+
} else t5 = $[4];
|
|
1275
|
+
const t6 = `${dialogId}-key`;
|
|
1276
|
+
let t7;
|
|
1277
|
+
if ($[5] !== t6) {
|
|
1278
|
+
t7 = /* @__PURE__ */ jsx("input", {
|
|
1279
|
+
type: "text",
|
|
1280
|
+
id: t6,
|
|
1281
|
+
name: "key",
|
|
1282
|
+
required: true,
|
|
1283
|
+
placeholder: "例: title, author, date"
|
|
1284
|
+
});
|
|
1285
|
+
$[5] = t6;
|
|
1286
|
+
$[6] = t7;
|
|
1287
|
+
} else t7 = $[6];
|
|
1288
|
+
let t8;
|
|
1289
|
+
if ($[7] !== t5 || $[8] !== t7) {
|
|
1290
|
+
t8 = /* @__PURE__ */ jsxs("div", {
|
|
1291
|
+
className: "fm-editor-dialog-field",
|
|
1292
|
+
children: [t5, t7]
|
|
1293
|
+
});
|
|
1294
|
+
$[7] = t5;
|
|
1295
|
+
$[8] = t7;
|
|
1296
|
+
$[9] = t8;
|
|
1297
|
+
} else t8 = $[9];
|
|
1298
|
+
const t9 = `${dialogId}-type`;
|
|
1299
|
+
let t10;
|
|
1300
|
+
if ($[10] !== t9) {
|
|
1301
|
+
t10 = /* @__PURE__ */ jsx("label", {
|
|
1302
|
+
htmlFor: t9,
|
|
1303
|
+
children: "型"
|
|
1304
|
+
});
|
|
1305
|
+
$[10] = t9;
|
|
1306
|
+
$[11] = t10;
|
|
1307
|
+
} else t10 = $[11];
|
|
1308
|
+
const t11 = `${dialogId}-type`;
|
|
1309
|
+
let t12;
|
|
1310
|
+
let t13;
|
|
1311
|
+
let t14;
|
|
1312
|
+
let t15;
|
|
1313
|
+
let t16;
|
|
1314
|
+
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1315
|
+
t12 = /* @__PURE__ */ jsx("option", {
|
|
1316
|
+
value: "text",
|
|
1317
|
+
children: "テキスト"
|
|
1318
|
+
});
|
|
1319
|
+
t13 = /* @__PURE__ */ jsx("option", {
|
|
1320
|
+
value: "number",
|
|
1321
|
+
children: "数値"
|
|
1322
|
+
});
|
|
1323
|
+
t14 = /* @__PURE__ */ jsx("option", {
|
|
1324
|
+
value: "boolean",
|
|
1325
|
+
children: "真偽値"
|
|
1326
|
+
});
|
|
1327
|
+
t15 = /* @__PURE__ */ jsx("option", {
|
|
1328
|
+
value: "date",
|
|
1329
|
+
children: "日付"
|
|
1330
|
+
});
|
|
1331
|
+
t16 = /* @__PURE__ */ jsx("option", {
|
|
1332
|
+
value: "json",
|
|
1333
|
+
children: "JSON(配列/オブジェクト)"
|
|
1334
|
+
});
|
|
1335
|
+
$[12] = t12;
|
|
1336
|
+
$[13] = t13;
|
|
1337
|
+
$[14] = t14;
|
|
1338
|
+
$[15] = t15;
|
|
1339
|
+
$[16] = t16;
|
|
1340
|
+
} else {
|
|
1341
|
+
t12 = $[12];
|
|
1342
|
+
t13 = $[13];
|
|
1343
|
+
t14 = $[14];
|
|
1344
|
+
t15 = $[15];
|
|
1345
|
+
t16 = $[16];
|
|
1346
|
+
}
|
|
1347
|
+
let t17;
|
|
1348
|
+
if ($[17] !== t11) {
|
|
1349
|
+
t17 = /* @__PURE__ */ jsxs("select", {
|
|
1350
|
+
id: t11,
|
|
1351
|
+
name: "type",
|
|
1352
|
+
children: [
|
|
1353
|
+
t12,
|
|
1354
|
+
t13,
|
|
1355
|
+
t14,
|
|
1356
|
+
t15,
|
|
1357
|
+
t16
|
|
1358
|
+
]
|
|
1359
|
+
});
|
|
1360
|
+
$[17] = t11;
|
|
1361
|
+
$[18] = t17;
|
|
1362
|
+
} else t17 = $[18];
|
|
1363
|
+
let t18;
|
|
1364
|
+
if ($[19] !== t10 || $[20] !== t17) {
|
|
1365
|
+
t18 = /* @__PURE__ */ jsxs("div", {
|
|
1366
|
+
className: "fm-editor-dialog-field",
|
|
1367
|
+
children: [t10, t17]
|
|
1368
|
+
});
|
|
1369
|
+
$[19] = t10;
|
|
1370
|
+
$[20] = t17;
|
|
1371
|
+
$[21] = t18;
|
|
1372
|
+
} else t18 = $[21];
|
|
1373
|
+
let t19;
|
|
1374
|
+
if ($[22] !== dialogId) {
|
|
1375
|
+
t19 = /* @__PURE__ */ jsx("button", {
|
|
1376
|
+
type: "button",
|
|
1377
|
+
className: "fm-editor-dialog-cancel",
|
|
1378
|
+
command: "close",
|
|
1379
|
+
commandfor: dialogId,
|
|
1380
|
+
children: "キャンセル"
|
|
1381
|
+
});
|
|
1382
|
+
$[22] = dialogId;
|
|
1383
|
+
$[23] = t19;
|
|
1384
|
+
} else t19 = $[23];
|
|
1385
|
+
let t20;
|
|
1386
|
+
if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1387
|
+
t20 = /* @__PURE__ */ jsx("button", {
|
|
1388
|
+
type: "submit",
|
|
1389
|
+
className: "fm-editor-dialog-submit",
|
|
1390
|
+
children: "追加"
|
|
1391
|
+
});
|
|
1392
|
+
$[24] = t20;
|
|
1393
|
+
} else t20 = $[24];
|
|
1394
|
+
let t21;
|
|
1395
|
+
if ($[25] !== t19) {
|
|
1396
|
+
t21 = /* @__PURE__ */ jsxs("div", {
|
|
1397
|
+
className: "fm-editor-dialog-actions",
|
|
1398
|
+
children: [t19, t20]
|
|
1399
|
+
});
|
|
1400
|
+
$[25] = t19;
|
|
1401
|
+
$[26] = t21;
|
|
1402
|
+
} else t21 = $[26];
|
|
1403
|
+
let t22;
|
|
1404
|
+
if ($[27] !== onSubmit || $[28] !== t18 || $[29] !== t21 || $[30] !== t8) {
|
|
1405
|
+
t22 = /* @__PURE__ */ jsxs("form", {
|
|
853
1406
|
onSubmit,
|
|
854
1407
|
children: [
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
htmlFor: `${dialogId}-key`,
|
|
860
|
-
children: "キー名"
|
|
861
|
-
}), /* @__PURE__ */ jsx("input", {
|
|
862
|
-
type: "text",
|
|
863
|
-
id: `${dialogId}-key`,
|
|
864
|
-
name: "key",
|
|
865
|
-
required: true,
|
|
866
|
-
placeholder: "例: title, author, date"
|
|
867
|
-
})]
|
|
868
|
-
}),
|
|
869
|
-
/* @__PURE__ */ jsxs("div", {
|
|
870
|
-
className: "fm-editor-dialog-field",
|
|
871
|
-
children: [/* @__PURE__ */ jsx("label", {
|
|
872
|
-
htmlFor: `${dialogId}-type`,
|
|
873
|
-
children: "型"
|
|
874
|
-
}), /* @__PURE__ */ jsxs("select", {
|
|
875
|
-
id: `${dialogId}-type`,
|
|
876
|
-
name: "type",
|
|
877
|
-
children: [
|
|
878
|
-
/* @__PURE__ */ jsx("option", {
|
|
879
|
-
value: "text",
|
|
880
|
-
children: "テキスト"
|
|
881
|
-
}),
|
|
882
|
-
/* @__PURE__ */ jsx("option", {
|
|
883
|
-
value: "number",
|
|
884
|
-
children: "数値"
|
|
885
|
-
}),
|
|
886
|
-
/* @__PURE__ */ jsx("option", {
|
|
887
|
-
value: "boolean",
|
|
888
|
-
children: "真偽値"
|
|
889
|
-
}),
|
|
890
|
-
/* @__PURE__ */ jsx("option", {
|
|
891
|
-
value: "date",
|
|
892
|
-
children: "日付"
|
|
893
|
-
}),
|
|
894
|
-
/* @__PURE__ */ jsx("option", {
|
|
895
|
-
value: "json",
|
|
896
|
-
children: "JSON(配列/オブジェクト)"
|
|
897
|
-
})
|
|
898
|
-
]
|
|
899
|
-
})]
|
|
900
|
-
}),
|
|
901
|
-
/* @__PURE__ */ jsxs("div", {
|
|
902
|
-
className: "fm-editor-dialog-actions",
|
|
903
|
-
children: [/* @__PURE__ */ jsx("button", {
|
|
904
|
-
type: "button",
|
|
905
|
-
className: "fm-editor-dialog-cancel",
|
|
906
|
-
command: "close",
|
|
907
|
-
commandfor: dialogId,
|
|
908
|
-
children: "キャンセル"
|
|
909
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
910
|
-
type: "submit",
|
|
911
|
-
className: "fm-editor-dialog-submit",
|
|
912
|
-
children: "追加"
|
|
913
|
-
})]
|
|
914
|
-
})
|
|
1408
|
+
t3,
|
|
1409
|
+
t8,
|
|
1410
|
+
t18,
|
|
1411
|
+
t21
|
|
915
1412
|
]
|
|
916
|
-
})
|
|
917
|
-
|
|
1413
|
+
});
|
|
1414
|
+
$[27] = onSubmit;
|
|
1415
|
+
$[28] = t18;
|
|
1416
|
+
$[29] = t21;
|
|
1417
|
+
$[30] = t8;
|
|
1418
|
+
$[31] = t22;
|
|
1419
|
+
} else t22 = $[31];
|
|
1420
|
+
let t23;
|
|
1421
|
+
if ($[32] !== dialogId || $[33] !== onClose || $[34] !== t22) {
|
|
1422
|
+
t23 = /* @__PURE__ */ jsx("dialog", {
|
|
1423
|
+
ref: dialogRef,
|
|
1424
|
+
className: "fm-editor-dialog",
|
|
1425
|
+
id: dialogId,
|
|
1426
|
+
onClose,
|
|
1427
|
+
children: t22
|
|
1428
|
+
});
|
|
1429
|
+
$[32] = dialogId;
|
|
1430
|
+
$[33] = onClose;
|
|
1431
|
+
$[34] = t22;
|
|
1432
|
+
$[35] = t23;
|
|
1433
|
+
} else t23 = $[35];
|
|
1434
|
+
return t23;
|
|
918
1435
|
}
|
|
919
1436
|
/**
|
|
920
1437
|
* Parse initial data and detect field types
|
|
@@ -1012,64 +1529,105 @@ var preview_module_default = {
|
|
|
1012
1529
|
//#region src/components/preview.tsx
|
|
1013
1530
|
/**
|
|
1014
1531
|
* File preview pane. The previewed path comes from the parent (lifted
|
|
1015
|
-
* from the
|
|
1016
|
-
*
|
|
1532
|
+
* from the item's own state); upload progress is read from the engine's
|
|
1533
|
+
* `FileBrowserStore`, shared with `FileList`/`FileUploader`.
|
|
1017
1534
|
* @param root0
|
|
1018
|
-
* @param root0.engine
|
|
1019
1535
|
* @param root0.path
|
|
1020
1536
|
* @example
|
|
1021
1537
|
* ```tsx
|
|
1022
|
-
* <Preview
|
|
1538
|
+
* <Preview path={state.path ?? ''} />
|
|
1023
1539
|
* ```
|
|
1024
1540
|
*/
|
|
1025
|
-
function Preview(
|
|
1541
|
+
function Preview(t0) {
|
|
1542
|
+
const $ = c(36);
|
|
1543
|
+
const { path } = t0;
|
|
1544
|
+
const store = useFileBrowser();
|
|
1026
1545
|
const [dimension, setDimension] = useState(null);
|
|
1027
|
-
const [progress, setProgress] = useState({
|
|
1028
|
-
uploaded: 0,
|
|
1029
|
-
total: 100
|
|
1030
|
-
});
|
|
1031
1546
|
const [prevPath, setPrevPath] = useState(path);
|
|
1032
1547
|
if (prevPath !== path) {
|
|
1033
1548
|
setPrevPath(path);
|
|
1034
1549
|
setDimension(null);
|
|
1035
1550
|
}
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1551
|
+
let t1;
|
|
1552
|
+
if ($[0] !== path) {
|
|
1553
|
+
t1 = path ? getExt(path) : null;
|
|
1554
|
+
$[0] = path;
|
|
1555
|
+
$[1] = t1;
|
|
1556
|
+
} else t1 = $[1];
|
|
1557
|
+
const file = t1;
|
|
1558
|
+
let t2;
|
|
1559
|
+
if ($[2] !== path) {
|
|
1560
|
+
t2 = path.startsWith("blob:");
|
|
1561
|
+
$[2] = path;
|
|
1562
|
+
$[3] = t2;
|
|
1563
|
+
} else t2 = $[3];
|
|
1564
|
+
const isUploadingMode = t2;
|
|
1565
|
+
let t3;
|
|
1566
|
+
if ($[4] !== store) {
|
|
1567
|
+
t3 = () => store.getSnapshot().uploads;
|
|
1568
|
+
$[4] = store;
|
|
1569
|
+
$[5] = t3;
|
|
1570
|
+
} else t3 = $[5];
|
|
1571
|
+
const uploads = useSyncExternalStore(store.subscribe, t3);
|
|
1572
|
+
let t4;
|
|
1573
|
+
if ($[6] !== path || $[7] !== uploads) {
|
|
1574
|
+
t4 = uploads.find((u) => u.blob === path) ?? {
|
|
1575
|
+
uploaded: 0,
|
|
1576
|
+
total: 100
|
|
1577
|
+
};
|
|
1578
|
+
$[6] = path;
|
|
1579
|
+
$[7] = uploads;
|
|
1580
|
+
$[8] = t4;
|
|
1581
|
+
} else t4 = $[8];
|
|
1582
|
+
const progress = t4;
|
|
1583
|
+
let t5;
|
|
1584
|
+
let t6;
|
|
1585
|
+
if ($[9] !== path) {
|
|
1586
|
+
t5 = () => {
|
|
1587
|
+
const file_0 = path ? getExt(path) : null;
|
|
1588
|
+
let aborted = false;
|
|
1589
|
+
if (file_0?.isImage) {
|
|
1590
|
+
const image = new Image();
|
|
1591
|
+
image.src = path;
|
|
1592
|
+
image.addEventListener("load", () => {
|
|
1593
|
+
if (!aborted) setDimension({
|
|
1594
|
+
width: image.naturalWidth,
|
|
1595
|
+
height: image.naturalHeight
|
|
1596
|
+
});
|
|
1597
|
+
}, { once: true });
|
|
1598
|
+
} else if (file_0?.isVideo) {
|
|
1599
|
+
const video = document.createElement("video");
|
|
1600
|
+
video.src = path;
|
|
1601
|
+
video.addEventListener("loadedmetadata", () => {
|
|
1602
|
+
if (!aborted) setDimension({
|
|
1603
|
+
width: video.videoWidth,
|
|
1604
|
+
height: video.videoHeight
|
|
1605
|
+
});
|
|
1606
|
+
}, { once: true });
|
|
1607
|
+
}
|
|
1608
|
+
return () => {
|
|
1609
|
+
aborted = true;
|
|
1610
|
+
};
|
|
1068
1611
|
};
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1612
|
+
t6 = [path];
|
|
1613
|
+
$[9] = path;
|
|
1614
|
+
$[10] = t5;
|
|
1615
|
+
$[11] = t6;
|
|
1616
|
+
} else {
|
|
1617
|
+
t5 = $[10];
|
|
1618
|
+
t6 = $[11];
|
|
1619
|
+
}
|
|
1620
|
+
useEffect(t5, t6);
|
|
1621
|
+
const t7 = `${preview_module_default.img} ${isUploadingMode ? preview_module_default.uploading : ""}`;
|
|
1622
|
+
let t8;
|
|
1623
|
+
if ($[12] !== t7) {
|
|
1624
|
+
t8 = t7.trim();
|
|
1625
|
+
$[12] = t7;
|
|
1626
|
+
$[13] = t8;
|
|
1627
|
+
} else t8 = $[13];
|
|
1628
|
+
let t9;
|
|
1629
|
+
if ($[14] !== file || $[15] !== path) {
|
|
1630
|
+
t9 = file?.isImage ? /* @__PURE__ */ jsx("img", {
|
|
1073
1631
|
src: path,
|
|
1074
1632
|
alt: "画像プレビュー"
|
|
1075
1633
|
}) : file?.isVideo ? /* @__PURE__ */ jsxs("video", {
|
|
@@ -1096,16 +1654,38 @@ function Preview({ engine, path }) {
|
|
|
1096
1654
|
type: `application/${file.ext}`,
|
|
1097
1655
|
title: `${file.ext}ファイルのプレビュー`,
|
|
1098
1656
|
children: /* @__PURE__ */ jsx("p", { children: "プレビューできません" })
|
|
1099
|
-
}) : /* @__PURE__ */ jsx("p", { children: "プレビューできません" })
|
|
1100
|
-
|
|
1657
|
+
}) : /* @__PURE__ */ jsx("p", { children: "プレビューできません" });
|
|
1658
|
+
$[14] = file;
|
|
1659
|
+
$[15] = path;
|
|
1660
|
+
$[16] = t9;
|
|
1661
|
+
} else t9 = $[16];
|
|
1662
|
+
let t10;
|
|
1663
|
+
if ($[17] !== isUploadingMode || $[18] !== progress) {
|
|
1664
|
+
t10 = isUploadingMode ? /* @__PURE__ */ jsx("div", {
|
|
1665
|
+
className: preview_module_default.progress,
|
|
1101
1666
|
style: { translate: `${progress.uploaded / progress.total * 100}%` }
|
|
1102
|
-
}) : null
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1667
|
+
}) : null;
|
|
1668
|
+
$[17] = isUploadingMode;
|
|
1669
|
+
$[18] = progress;
|
|
1670
|
+
$[19] = t10;
|
|
1671
|
+
} else t10 = $[19];
|
|
1672
|
+
let t11;
|
|
1673
|
+
if ($[20] !== t10 || $[21] !== t8 || $[22] !== t9) {
|
|
1674
|
+
t11 = /* @__PURE__ */ jsxs("div", {
|
|
1675
|
+
className: t8,
|
|
1676
|
+
children: [t9, t10]
|
|
1677
|
+
});
|
|
1678
|
+
$[20] = t10;
|
|
1679
|
+
$[21] = t8;
|
|
1680
|
+
$[22] = t9;
|
|
1681
|
+
$[23] = t11;
|
|
1682
|
+
} else t11 = $[23];
|
|
1683
|
+
let t12;
|
|
1684
|
+
if ($[24] !== isUploadingMode || $[25] !== path || $[26] !== progress) {
|
|
1685
|
+
t12 = isUploadingMode ? /* @__PURE__ */ jsxs("li", {
|
|
1686
|
+
className: preview_module_default.upload,
|
|
1107
1687
|
children: [/* @__PURE__ */ jsx("span", { children: "アップロード..." }), /* @__PURE__ */ jsxs("span", {
|
|
1108
|
-
className: preview_module_default
|
|
1688
|
+
className: preview_module_default.progress,
|
|
1109
1689
|
children: [
|
|
1110
1690
|
Math.round(progress.uploaded / progress.total * 100),
|
|
1111
1691
|
"% (",
|
|
@@ -1116,21 +1696,49 @@ function Preview({ engine, path }) {
|
|
|
1116
1696
|
]
|
|
1117
1697
|
})]
|
|
1118
1698
|
}) : /* @__PURE__ */ jsx("li", {
|
|
1119
|
-
className: preview_module_default
|
|
1699
|
+
className: preview_module_default.path,
|
|
1120
1700
|
children: /* @__PURE__ */ jsx("a", {
|
|
1121
1701
|
href: path,
|
|
1122
1702
|
target: "_blank",
|
|
1123
1703
|
children: path
|
|
1124
1704
|
})
|
|
1125
|
-
})
|
|
1126
|
-
|
|
1705
|
+
});
|
|
1706
|
+
$[24] = isUploadingMode;
|
|
1707
|
+
$[25] = path;
|
|
1708
|
+
$[26] = progress;
|
|
1709
|
+
$[27] = t12;
|
|
1710
|
+
} else t12 = $[27];
|
|
1711
|
+
let t13;
|
|
1712
|
+
if ($[28] !== dimension) {
|
|
1713
|
+
t13 = dimension ? /* @__PURE__ */ jsxs("li", {
|
|
1714
|
+
className: preview_module_default.dimension,
|
|
1127
1715
|
children: [
|
|
1128
1716
|
dimension.width,
|
|
1129
1717
|
"x",
|
|
1130
1718
|
dimension.height
|
|
1131
1719
|
]
|
|
1132
|
-
}) : null
|
|
1133
|
-
|
|
1720
|
+
}) : null;
|
|
1721
|
+
$[28] = dimension;
|
|
1722
|
+
$[29] = t13;
|
|
1723
|
+
} else t13 = $[29];
|
|
1724
|
+
let t14;
|
|
1725
|
+
if ($[30] !== t12 || $[31] !== t13) {
|
|
1726
|
+
t14 = /* @__PURE__ */ jsxs("ul", {
|
|
1727
|
+
className: preview_module_default.meta,
|
|
1728
|
+
children: [t12, t13]
|
|
1729
|
+
});
|
|
1730
|
+
$[30] = t12;
|
|
1731
|
+
$[31] = t13;
|
|
1732
|
+
$[32] = t14;
|
|
1733
|
+
} else t14 = $[32];
|
|
1734
|
+
let t15;
|
|
1735
|
+
if ($[33] !== t11 || $[34] !== t14) {
|
|
1736
|
+
t15 = /* @__PURE__ */ jsxs("div", { children: [t11, t14] });
|
|
1737
|
+
$[33] = t11;
|
|
1738
|
+
$[34] = t14;
|
|
1739
|
+
$[35] = t15;
|
|
1740
|
+
} else t15 = $[35];
|
|
1741
|
+
return t15;
|
|
1134
1742
|
}
|
|
1135
1743
|
var table_editor_module_default = {
|
|
1136
1744
|
table: "_table_1qb61_1",
|
|
@@ -1140,6 +1748,11 @@ var table_editor_module_default = {
|
|
|
1140
1748
|
//#endregion
|
|
1141
1749
|
//#region src/components/table-editor.tsx
|
|
1142
1750
|
/**
|
|
1751
|
+
* Row-aligned table cell text: `th[i]` and `td[i]` form one row. In the
|
|
1752
|
+
* table item the `td` cells hold Markdown while editing (converted
|
|
1753
|
+
* to/from HTML via `toEditorState`/`toItemData`); `th` cells stay plain.
|
|
1754
|
+
*/
|
|
1755
|
+
/**
|
|
1143
1756
|
* Table row editor as a fully controlled component. The table item's
|
|
1144
1757
|
* editor owns the state; row operations are declared as local commands.
|
|
1145
1758
|
* @param root0
|
|
@@ -1153,26 +1766,57 @@ var table_editor_module_default = {
|
|
|
1153
1766
|
* />
|
|
1154
1767
|
* ```
|
|
1155
1768
|
*/
|
|
1156
|
-
function TableEditor(
|
|
1769
|
+
function TableEditor(t0) {
|
|
1770
|
+
const $ = c(12);
|
|
1771
|
+
const { value, onChange } = t0;
|
|
1157
1772
|
const rootId = useId();
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1773
|
+
let t1;
|
|
1774
|
+
if ($[0] !== value.th) {
|
|
1775
|
+
t1 = () => value.th.map(_temp$1);
|
|
1776
|
+
$[0] = value.th;
|
|
1777
|
+
$[1] = t1;
|
|
1778
|
+
} else t1 = $[1];
|
|
1779
|
+
const [rowIds, setRowIds] = useState(t1);
|
|
1780
|
+
let t2;
|
|
1781
|
+
if ($[2] !== rowIds || $[3] !== value.td) {
|
|
1782
|
+
t2 = (th, i) => ({
|
|
1783
|
+
id: rowIds[i] ?? String(i),
|
|
1784
|
+
th,
|
|
1785
|
+
td: value.td[i] ?? ""
|
|
1163
1786
|
});
|
|
1164
|
-
|
|
1787
|
+
$[2] = rowIds;
|
|
1788
|
+
$[3] = value.td;
|
|
1789
|
+
$[4] = t2;
|
|
1790
|
+
} else t2 = $[4];
|
|
1791
|
+
const rows = value.th.map(t2);
|
|
1792
|
+
let t3;
|
|
1793
|
+
if ($[5] !== onChange) {
|
|
1794
|
+
t3 = (next) => {
|
|
1795
|
+
setRowIds(next.map(_temp2));
|
|
1796
|
+
onChange({
|
|
1797
|
+
th: next.map(_temp3),
|
|
1798
|
+
td: next.map(_temp4)
|
|
1799
|
+
});
|
|
1800
|
+
};
|
|
1801
|
+
$[5] = onChange;
|
|
1802
|
+
$[6] = t3;
|
|
1803
|
+
} else t3 = $[6];
|
|
1804
|
+
const commit = t3;
|
|
1165
1805
|
const rootRef = useCommand({
|
|
1166
1806
|
"--add-row": (e) => {
|
|
1167
1807
|
const index = Number(e.source?.value);
|
|
1168
|
-
commit(rows.toSpliced(index + 1, 0,
|
|
1808
|
+
commit(rows.toSpliced(index + 1, 0, {
|
|
1809
|
+
id: crypto.randomUUID(),
|
|
1810
|
+
th: "",
|
|
1811
|
+
td: ""
|
|
1812
|
+
}));
|
|
1169
1813
|
},
|
|
1170
|
-
"--remove-row": (
|
|
1171
|
-
const
|
|
1172
|
-
commit(rows.toSpliced(
|
|
1814
|
+
"--remove-row": (e_0) => {
|
|
1815
|
+
const index_0 = Number(e_0.source?.value);
|
|
1816
|
+
commit(rows.toSpliced(index_0, 1));
|
|
1173
1817
|
},
|
|
1174
|
-
"--move-row-down": (
|
|
1175
|
-
const from = Number(
|
|
1818
|
+
"--move-row-down": (e_1) => {
|
|
1819
|
+
const from = Number(e_1.source?.value);
|
|
1176
1820
|
const to = from + 1;
|
|
1177
1821
|
const fromRow = rows[from];
|
|
1178
1822
|
const toRow = rows[to];
|
|
@@ -1180,44 +1824,51 @@ function TableEditor({ value, onChange }) {
|
|
|
1180
1824
|
commit(rows.toSpliced(from, 1, toRow).toSpliced(to, 1, fromRow));
|
|
1181
1825
|
}
|
|
1182
1826
|
});
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
className: table_editor_module_default["row"],
|
|
1827
|
+
const t4 = table_editor_module_default;
|
|
1828
|
+
const t6 = rows.map((t5, i_0) => {
|
|
1829
|
+
const { id, th: th_0, td } = t5;
|
|
1830
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1831
|
+
className: table_editor_module_default.row,
|
|
1189
1832
|
children: [
|
|
1190
1833
|
/* @__PURE__ */ jsx("div", {
|
|
1191
|
-
className: table_editor_module_default
|
|
1834
|
+
className: table_editor_module_default.th,
|
|
1192
1835
|
children: /* @__PURE__ */ jsx("textarea", {
|
|
1193
|
-
"aria-label": `${
|
|
1194
|
-
name: `bge-th-${
|
|
1195
|
-
value:
|
|
1196
|
-
onChange: (
|
|
1197
|
-
commit(rows.with(
|
|
1836
|
+
"aria-label": `${i_0}行目の見出しセル`,
|
|
1837
|
+
name: `bge-th-${i_0}`,
|
|
1838
|
+
value: th_0,
|
|
1839
|
+
onChange: (e_2) => {
|
|
1840
|
+
commit(rows.with(i_0, {
|
|
1841
|
+
id,
|
|
1842
|
+
th: e_2.currentTarget.value,
|
|
1843
|
+
td
|
|
1844
|
+
}));
|
|
1198
1845
|
}
|
|
1199
1846
|
})
|
|
1200
1847
|
}),
|
|
1201
1848
|
/* @__PURE__ */ jsx("div", {
|
|
1202
|
-
className: table_editor_module_default
|
|
1849
|
+
className: table_editor_module_default.td,
|
|
1203
1850
|
children: /* @__PURE__ */ jsx("textarea", {
|
|
1204
|
-
"aria-label": `${
|
|
1205
|
-
name: `bge-td-${
|
|
1851
|
+
"aria-label": `${i_0}行目の内容セル`,
|
|
1852
|
+
name: `bge-td-${i_0}`,
|
|
1206
1853
|
value: td,
|
|
1207
|
-
onChange: (
|
|
1208
|
-
commit(rows.with(
|
|
1854
|
+
onChange: (e_3) => {
|
|
1855
|
+
commit(rows.with(i_0, {
|
|
1856
|
+
id,
|
|
1857
|
+
th: th_0,
|
|
1858
|
+
td: e_3.currentTarget.value
|
|
1859
|
+
}));
|
|
1209
1860
|
}
|
|
1210
1861
|
})
|
|
1211
1862
|
}),
|
|
1212
1863
|
/* @__PURE__ */ jsx("div", {
|
|
1213
|
-
className: table_editor_module_default
|
|
1864
|
+
className: table_editor_module_default.btn,
|
|
1214
1865
|
children: /* @__PURE__ */ jsxs("ul", { children: [
|
|
1215
1866
|
/* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("button", {
|
|
1216
1867
|
type: "button",
|
|
1217
1868
|
title: "下に追加",
|
|
1218
1869
|
command: "--add-row",
|
|
1219
1870
|
commandfor: rootId,
|
|
1220
|
-
value:
|
|
1871
|
+
value: i_0,
|
|
1221
1872
|
children: /* @__PURE__ */ jsx(IconRowInsertBottom, {})
|
|
1222
1873
|
}) }),
|
|
1223
1874
|
/* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("button", {
|
|
@@ -1226,23 +1877,50 @@ function TableEditor({ value, onChange }) {
|
|
|
1226
1877
|
disabled: rows.length === 1,
|
|
1227
1878
|
command: "--remove-row",
|
|
1228
1879
|
commandfor: rootId,
|
|
1229
|
-
value:
|
|
1880
|
+
value: i_0,
|
|
1230
1881
|
children: /* @__PURE__ */ jsx(IconTrash, {})
|
|
1231
1882
|
}) }),
|
|
1232
1883
|
/* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("button", {
|
|
1233
1884
|
type: "button",
|
|
1234
1885
|
title: "下に移動",
|
|
1235
|
-
disabled:
|
|
1886
|
+
disabled: i_0 === rows.length - 1,
|
|
1236
1887
|
command: "--move-row-down",
|
|
1237
1888
|
commandfor: rootId,
|
|
1238
|
-
value:
|
|
1889
|
+
value: i_0,
|
|
1239
1890
|
children: /* @__PURE__ */ jsx(IconArrowsTransferDown, { className: "icon" })
|
|
1240
1891
|
}) })
|
|
1241
1892
|
] })
|
|
1242
1893
|
})
|
|
1243
1894
|
]
|
|
1244
|
-
},
|
|
1895
|
+
}, id);
|
|
1245
1896
|
});
|
|
1897
|
+
let t7;
|
|
1898
|
+
if ($[7] !== rootId || $[8] !== rootRef || $[9] !== t4.table || $[10] !== t6) {
|
|
1899
|
+
t7 = /* @__PURE__ */ jsx("div", {
|
|
1900
|
+
className: t4.table,
|
|
1901
|
+
ref: rootRef,
|
|
1902
|
+
id: rootId,
|
|
1903
|
+
children: t6
|
|
1904
|
+
});
|
|
1905
|
+
$[7] = rootId;
|
|
1906
|
+
$[8] = rootRef;
|
|
1907
|
+
$[9] = t4.table;
|
|
1908
|
+
$[10] = t6;
|
|
1909
|
+
$[11] = t7;
|
|
1910
|
+
} else t7 = $[11];
|
|
1911
|
+
return t7;
|
|
1912
|
+
}
|
|
1913
|
+
function _temp4(row_1) {
|
|
1914
|
+
return row_1.td;
|
|
1915
|
+
}
|
|
1916
|
+
function _temp3(row_0) {
|
|
1917
|
+
return row_0.th;
|
|
1918
|
+
}
|
|
1919
|
+
function _temp2(row) {
|
|
1920
|
+
return row.id;
|
|
1921
|
+
}
|
|
1922
|
+
function _temp$1() {
|
|
1923
|
+
return crypto.randomUUID();
|
|
1246
1924
|
}
|
|
1247
1925
|
var tabs_module_default = { tablist: "_tablist_1hyld_1" };
|
|
1248
1926
|
//#endregion
|
|
@@ -1269,9 +1947,9 @@ var tabs_module_default = { tablist: "_tablist_1hyld_1" };
|
|
|
1269
1947
|
function Tabs({ current, onChange, contentId, length = 2, createLabel = (index) => `画像${index + 1}` }) {
|
|
1270
1948
|
const listId = useId();
|
|
1271
1949
|
const refs = useRef([]);
|
|
1272
|
-
const update = (
|
|
1273
|
-
refs.current[
|
|
1274
|
-
onChange(
|
|
1950
|
+
const update = (index_0) => {
|
|
1951
|
+
refs.current[index_0]?.focus();
|
|
1952
|
+
onChange(index_0);
|
|
1275
1953
|
};
|
|
1276
1954
|
const rootRef = useCommand({ "--select-tab": (e) => {
|
|
1277
1955
|
const value = e.source?.value;
|
|
@@ -1286,30 +1964,64 @@ function Tabs({ current, onChange, contentId, length = 2, createLabel = (index)
|
|
|
1286
1964
|
ref: rootRef,
|
|
1287
1965
|
id: listId,
|
|
1288
1966
|
className: tabs_module_default["tablist"],
|
|
1289
|
-
children: Array.from({ length }, (_,
|
|
1967
|
+
children: Array.from({ length }, (_, index_1) => /* @__PURE__ */ jsx("button", {
|
|
1290
1968
|
ref: (el) => {
|
|
1291
|
-
refs.current[
|
|
1969
|
+
refs.current[index_1] = el;
|
|
1292
1970
|
},
|
|
1293
1971
|
type: "button",
|
|
1294
1972
|
role: "tab",
|
|
1295
1973
|
"aria-controls": contentId,
|
|
1296
|
-
"aria-selected": current ===
|
|
1297
|
-
tabIndex: current ===
|
|
1974
|
+
"aria-selected": current === index_1,
|
|
1975
|
+
tabIndex: current === index_1 ? 0 : -1,
|
|
1298
1976
|
command: "--select-tab",
|
|
1299
1977
|
commandfor: listId,
|
|
1300
|
-
value:
|
|
1978
|
+
value: index_1,
|
|
1301
1979
|
onKeyDown,
|
|
1302
|
-
children: createLabel(
|
|
1303
|
-
},
|
|
1980
|
+
children: createLabel(index_1)
|
|
1981
|
+
}, index_1))
|
|
1304
1982
|
});
|
|
1305
1983
|
}
|
|
1306
1984
|
//#endregion
|
|
1307
1985
|
//#region src/components/wysiwyg-field.tsx
|
|
1308
1986
|
/**
|
|
1987
|
+
* Wrap `promise` so a rejection resolves to `fallback` instead, without
|
|
1988
|
+
* breaking the `use()` cache contract (react.dev's `wrapPromise` pattern:
|
|
1989
|
+
* a thenable tagged with `.status`/`.value`/`.reason` lets `use()` read it
|
|
1990
|
+
* synchronously on the first render). `Promise.prototype.catch()` always
|
|
1991
|
+
* returns a fresh, untagged promise, so chaining it directly onto an
|
|
1992
|
+
* already-tagged thenable would silently drop that fast path. A tagged
|
|
1993
|
+
* `'fulfilled'` promise is returned as-is (nothing to fall back from); a
|
|
1994
|
+
* tagged `'rejected'` promise is converted synchronously; only a genuinely
|
|
1995
|
+
* untagged promise falls back to the real async `.catch()`.
|
|
1996
|
+
* @param promise - Source promise, optionally pre-tagged per the `use()`
|
|
1997
|
+
* cache contract
|
|
1998
|
+
* @param fallback - Value to resolve to when `promise` rejects
|
|
1999
|
+
*/
|
|
2000
|
+
function withFallback(promise, fallback) {
|
|
2001
|
+
const tagged = promise;
|
|
2002
|
+
if (tagged.status === "fulfilled") return promise;
|
|
2003
|
+
if (tagged.status === "rejected") {
|
|
2004
|
+
const resolved = Promise.resolve(fallback);
|
|
2005
|
+
resolved.status = "fulfilled";
|
|
2006
|
+
resolved.value = fallback;
|
|
2007
|
+
return resolved;
|
|
2008
|
+
}
|
|
2009
|
+
return promise.catch(() => fallback);
|
|
2010
|
+
}
|
|
2011
|
+
/**
|
|
1309
2012
|
* Rich text field backed by the `<bge-wysiwyg-editor>` custom element
|
|
1310
2013
|
* (TipTap). The element manages its own DOM; this wrapper feeds the
|
|
1311
2014
|
* initial value and lifts edits into the editor state via the
|
|
1312
|
-
* `transaction` event
|
|
2015
|
+
* `transaction` event — subscribed directly on the host element (the
|
|
2016
|
+
* event is dispatched with `bubbles: true` on the inner `<bge-wysiwyg>`,
|
|
2017
|
+
* so it reaches here without needing to query into it).
|
|
2018
|
+
*
|
|
2019
|
+
* Content CSS (so the WYSIWYG surface matches the published page's
|
|
2020
|
+
* styling) is fetched once per engine via `use()` — only an item whose
|
|
2021
|
+
* `Editor` actually renders `WysiwygField` pays for this fetch/suspend,
|
|
2022
|
+
* unlike hoisting it to the item-editor host for every item — and
|
|
2023
|
+
* passed as the `contentCss` property (React 19 sets it directly on the
|
|
2024
|
+
* element, replacing an imperative `el.setStyle()` call).
|
|
1313
2025
|
* @param root0
|
|
1314
2026
|
* @param root0.value
|
|
1315
2027
|
* @param root0.onChange
|
|
@@ -1325,34 +2037,184 @@ function Tabs({ current, onChange, contentId, length = 2, createLabel = (index)
|
|
|
1325
2037
|
* />
|
|
1326
2038
|
* ```
|
|
1327
2039
|
*/
|
|
1328
|
-
function WysiwygField(
|
|
2040
|
+
function WysiwygField(t0) {
|
|
2041
|
+
const $ = c(13);
|
|
2042
|
+
const { value, onChange, itemName, commands, label } = t0;
|
|
2043
|
+
const engine = useEngine();
|
|
2044
|
+
let t1;
|
|
2045
|
+
if ($[0] !== engine) {
|
|
2046
|
+
t1 = () => withFallback(engine.getContentStylesheet(), "");
|
|
2047
|
+
$[0] = engine;
|
|
2048
|
+
$[1] = t1;
|
|
2049
|
+
} else t1 = $[1];
|
|
2050
|
+
const [contentCssPromise] = useState(t1);
|
|
2051
|
+
const contentCss = use(contentCssPromise);
|
|
1329
2052
|
const ref = useRef(null);
|
|
1330
2053
|
const initialValue = useRef(value);
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
useEffect(() => {
|
|
1336
|
-
const el = ref.current;
|
|
1337
|
-
if (!el) return;
|
|
1338
|
-
el.innerHTML = initialValue.current;
|
|
1339
|
-
const inner = el.querySelector("bge-wysiwyg");
|
|
1340
|
-
const onTransaction = () => {
|
|
1341
|
-
onChangeRef.current(el.value);
|
|
2054
|
+
let t2;
|
|
2055
|
+
if ($[2] !== onChange) {
|
|
2056
|
+
t2 = (el) => {
|
|
2057
|
+
onChange(el.value);
|
|
1342
2058
|
};
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
2059
|
+
$[2] = onChange;
|
|
2060
|
+
$[3] = t2;
|
|
2061
|
+
} else t2 = $[3];
|
|
2062
|
+
const onTransaction = useEffectEvent(t2);
|
|
2063
|
+
let t3;
|
|
2064
|
+
if ($[4] !== onTransaction) {
|
|
2065
|
+
t3 = () => {
|
|
2066
|
+
const el_0 = ref.current;
|
|
2067
|
+
if (!el_0) return;
|
|
2068
|
+
el_0.innerHTML = initialValue.current;
|
|
2069
|
+
const listener = () => onTransaction(el_0);
|
|
2070
|
+
el_0.addEventListener("transaction", listener);
|
|
2071
|
+
return () => {
|
|
2072
|
+
el_0.removeEventListener("transaction", listener);
|
|
2073
|
+
};
|
|
1346
2074
|
};
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
2075
|
+
$[4] = onTransaction;
|
|
2076
|
+
$[5] = t3;
|
|
2077
|
+
} else t3 = $[5];
|
|
2078
|
+
let t4;
|
|
2079
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2080
|
+
t4 = [];
|
|
2081
|
+
$[6] = t4;
|
|
2082
|
+
} else t4 = $[6];
|
|
2083
|
+
useEffect(t3, t4);
|
|
2084
|
+
let t5;
|
|
2085
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2086
|
+
t5 = (el_1) => {
|
|
2087
|
+
ref.current = el_1;
|
|
2088
|
+
};
|
|
2089
|
+
$[7] = t5;
|
|
2090
|
+
} else t5 = $[7];
|
|
2091
|
+
let t6;
|
|
2092
|
+
if ($[8] !== commands || $[9] !== contentCss || $[10] !== itemName || $[11] !== label) {
|
|
2093
|
+
t6 = /* @__PURE__ */ jsx("bge-wysiwyg-editor", {
|
|
2094
|
+
ref: t5,
|
|
2095
|
+
contentCss,
|
|
2096
|
+
"item-name": itemName,
|
|
2097
|
+
commands,
|
|
2098
|
+
label
|
|
2099
|
+
});
|
|
2100
|
+
$[8] = commands;
|
|
2101
|
+
$[9] = contentCss;
|
|
2102
|
+
$[10] = itemName;
|
|
2103
|
+
$[11] = label;
|
|
2104
|
+
$[12] = t6;
|
|
2105
|
+
} else t6 = $[12];
|
|
2106
|
+
return t6;
|
|
2107
|
+
}
|
|
2108
|
+
//#endregion
|
|
2109
|
+
//#region src/use-mount-effect.ts
|
|
2110
|
+
/**
|
|
2111
|
+
* Run `fn` exactly once, when the component mounts, always reading `fn`'s
|
|
2112
|
+
* latest closure (via `useEffectEvent`) rather than the one captured at
|
|
2113
|
+
* mount time.
|
|
2114
|
+
*
|
|
2115
|
+
* Exists so a mount-only effect can honestly declare `useEffect(fn, [])`
|
|
2116
|
+
* without an `eslint-disable-next-line react-hooks/exhaustive-deps` — that
|
|
2117
|
+
* suppression is also a React Compiler bailout condition for the whole
|
|
2118
|
+
* component containing it (see ARCHITECTURE.md's negative-knowledge note
|
|
2119
|
+
* on React Compiler).
|
|
2120
|
+
* @param fn - Called once on mount
|
|
2121
|
+
* @example
|
|
2122
|
+
* ```tsx
|
|
2123
|
+
* useMountEffect(() => {
|
|
2124
|
+
* fileBrowser.select(fileType, state.path ?? '', size);
|
|
2125
|
+
* });
|
|
2126
|
+
* ```
|
|
2127
|
+
*/
|
|
2128
|
+
function useMountEffect(fn) {
|
|
2129
|
+
const $ = c(3);
|
|
2130
|
+
const onMount = useEffectEvent(fn);
|
|
2131
|
+
let t0;
|
|
2132
|
+
if ($[0] !== onMount) {
|
|
2133
|
+
t0 = () => {
|
|
2134
|
+
onMount();
|
|
2135
|
+
};
|
|
2136
|
+
$[0] = onMount;
|
|
2137
|
+
$[1] = t0;
|
|
2138
|
+
} else t0 = $[1];
|
|
2139
|
+
let t1;
|
|
2140
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2141
|
+
t1 = [];
|
|
2142
|
+
$[2] = t1;
|
|
2143
|
+
} else t1 = $[2];
|
|
2144
|
+
useEffect(t0, t1);
|
|
2145
|
+
}
|
|
2146
|
+
//#endregion
|
|
2147
|
+
//#region src/file-browser/use-external-file-selection.ts
|
|
2148
|
+
/**
|
|
2149
|
+
* React to a file becoming selected from outside the item's own `Editor`
|
|
2150
|
+
* (i.e. via `FileList`, in the same `FileBrowserStore` the item's own
|
|
2151
|
+
* `fileType` uses) — `onExternalChange` is called with the new selection.
|
|
2152
|
+
*
|
|
2153
|
+
* `selected` is shared per-engine across every item that opens onto the
|
|
2154
|
+
* same `fileType`, so it can still hold a *previous* item's selection at
|
|
2155
|
+
* the moment a new `Editor` instance mounts. This hook's first effect run
|
|
2156
|
+
* is always skipped for that reason — reacting to it would load that
|
|
2157
|
+
* stale, unrelated selection into the freshly-mounted item's own state,
|
|
2158
|
+
* racing the item's own mount-time `fileBrowser.select(fileType, ownPath)`
|
|
2159
|
+
* call (whichever one's async work — if any — finishes last wins,
|
|
2160
|
+
* corrupting the item with a different item's file). Callers still need
|
|
2161
|
+
* their own mount effect to register their own current path with the
|
|
2162
|
+
* store; this hook only covers reacting to *later* external changes.
|
|
2163
|
+
* @param selected - The `fileType`'s current selection (from
|
|
2164
|
+
* `useSyncExternalStore(fileBrowser.subscribe, () =>
|
|
2165
|
+
* fileBrowser.getSnapshot().selected[fileType])`)
|
|
2166
|
+
* @param getCurrentPath - Returns the item's own current path at call
|
|
2167
|
+
* time (a function, not a plain value, so the effect doesn't need it in
|
|
2168
|
+
* its dependency array and can stay `[selected]`-only)
|
|
2169
|
+
* @param onExternalChange - Called when `selected` changes to a path
|
|
2170
|
+
* different from `getCurrentPath()`, after the initial mount is skipped
|
|
2171
|
+
* @example
|
|
2172
|
+
* ```tsx
|
|
2173
|
+
* const selected = useSyncExternalStore(
|
|
2174
|
+
* fileBrowser.subscribe,
|
|
2175
|
+
* () => fileBrowser.getSnapshot().selected.image,
|
|
2176
|
+
* );
|
|
2177
|
+
* useExternalFileSelection(
|
|
2178
|
+
* selected,
|
|
2179
|
+
* () => state.path ?? '',
|
|
2180
|
+
* (next) => setState((prev) => ({ ...prev, path: next.path })),
|
|
2181
|
+
* );
|
|
2182
|
+
* ```
|
|
2183
|
+
*/
|
|
2184
|
+
function useExternalFileSelection(selected, getCurrentPath, onExternalChange) {
|
|
2185
|
+
const $ = c(8);
|
|
2186
|
+
const skipNextRun = useRef(true);
|
|
2187
|
+
let t0;
|
|
2188
|
+
if ($[0] !== getCurrentPath || $[1] !== onExternalChange || $[2] !== selected) {
|
|
2189
|
+
t0 = () => {
|
|
2190
|
+
if (skipNextRun.current) {
|
|
2191
|
+
skipNextRun.current = false;
|
|
2192
|
+
return;
|
|
2193
|
+
}
|
|
2194
|
+
if (!selected?.path || selected.path === getCurrentPath()) return;
|
|
2195
|
+
onExternalChange(selected);
|
|
2196
|
+
};
|
|
2197
|
+
$[0] = getCurrentPath;
|
|
2198
|
+
$[1] = onExternalChange;
|
|
2199
|
+
$[2] = selected;
|
|
2200
|
+
$[3] = t0;
|
|
2201
|
+
} else t0 = $[3];
|
|
2202
|
+
const handleSelectedChange = useEffectEvent(t0);
|
|
2203
|
+
let t1;
|
|
2204
|
+
if ($[4] !== handleSelectedChange) {
|
|
2205
|
+
t1 = () => {
|
|
2206
|
+
handleSelectedChange();
|
|
2207
|
+
};
|
|
2208
|
+
$[4] = handleSelectedChange;
|
|
2209
|
+
$[5] = t1;
|
|
2210
|
+
} else t1 = $[5];
|
|
2211
|
+
let t2;
|
|
2212
|
+
if ($[6] !== selected) {
|
|
2213
|
+
t2 = [selected];
|
|
2214
|
+
$[6] = selected;
|
|
2215
|
+
$[7] = t2;
|
|
2216
|
+
} else t2 = $[7];
|
|
2217
|
+
useEffect(t1, t2);
|
|
1356
2218
|
}
|
|
1357
2219
|
//#endregion
|
|
1358
2220
|
//#region src/form/checkbox.tsx
|
|
@@ -1380,15 +2242,40 @@ function WysiwygField({ value, onChange, itemName, commands, label }) {
|
|
|
1380
2242
|
* />
|
|
1381
2243
|
* ```
|
|
1382
2244
|
*/
|
|
1383
|
-
function Checkbox(
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
}
|
|
2245
|
+
function Checkbox(t0) {
|
|
2246
|
+
const $ = c(11);
|
|
2247
|
+
const { label, checked, onChange, name, disabled, describedBy } = t0;
|
|
2248
|
+
let t1;
|
|
2249
|
+
if ($[0] !== onChange) {
|
|
2250
|
+
t1 = (e) => onChange(e.currentTarget.checked);
|
|
2251
|
+
$[0] = onChange;
|
|
2252
|
+
$[1] = t1;
|
|
2253
|
+
} else t1 = $[1];
|
|
2254
|
+
let t2;
|
|
2255
|
+
if ($[2] !== checked || $[3] !== describedBy || $[4] !== disabled || $[5] !== name || $[6] !== t1) {
|
|
2256
|
+
t2 = /* @__PURE__ */ jsx("input", {
|
|
2257
|
+
type: "checkbox",
|
|
2258
|
+
name,
|
|
2259
|
+
checked,
|
|
2260
|
+
disabled,
|
|
2261
|
+
"aria-describedby": describedBy,
|
|
2262
|
+
onChange: t1
|
|
2263
|
+
});
|
|
2264
|
+
$[2] = checked;
|
|
2265
|
+
$[3] = describedBy;
|
|
2266
|
+
$[4] = disabled;
|
|
2267
|
+
$[5] = name;
|
|
2268
|
+
$[6] = t1;
|
|
2269
|
+
$[7] = t2;
|
|
2270
|
+
} else t2 = $[7];
|
|
2271
|
+
let t3;
|
|
2272
|
+
if ($[8] !== label || $[9] !== t2) {
|
|
2273
|
+
t3 = /* @__PURE__ */ jsxs("label", { children: [t2, label] });
|
|
2274
|
+
$[8] = label;
|
|
2275
|
+
$[9] = t2;
|
|
2276
|
+
$[10] = t3;
|
|
2277
|
+
} else t3 = $[10];
|
|
2278
|
+
return t3;
|
|
1392
2279
|
}
|
|
1393
2280
|
//#endregion
|
|
1394
2281
|
//#region src/form/fieldset.tsx
|
|
@@ -1415,12 +2302,29 @@ function Checkbox({ label, checked, onChange, name, disabled, describedBy }) {
|
|
|
1415
2302
|
* </Fieldset>
|
|
1416
2303
|
* ```
|
|
1417
2304
|
*/
|
|
1418
|
-
function Fieldset(
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
2305
|
+
function Fieldset(t0) {
|
|
2306
|
+
const $ = c(7);
|
|
2307
|
+
const { legend, id, disabled, children } = t0;
|
|
2308
|
+
let t1;
|
|
2309
|
+
if ($[0] !== legend) {
|
|
2310
|
+
t1 = /* @__PURE__ */ jsx("legend", { children: legend });
|
|
2311
|
+
$[0] = legend;
|
|
2312
|
+
$[1] = t1;
|
|
2313
|
+
} else t1 = $[1];
|
|
2314
|
+
let t2;
|
|
2315
|
+
if ($[2] !== children || $[3] !== disabled || $[4] !== id || $[5] !== t1) {
|
|
2316
|
+
t2 = /* @__PURE__ */ jsxs("fieldset", {
|
|
2317
|
+
id,
|
|
2318
|
+
disabled,
|
|
2319
|
+
children: [t1, children]
|
|
2320
|
+
});
|
|
2321
|
+
$[2] = children;
|
|
2322
|
+
$[3] = disabled;
|
|
2323
|
+
$[4] = id;
|
|
2324
|
+
$[5] = t1;
|
|
2325
|
+
$[6] = t2;
|
|
2326
|
+
} else t2 = $[6];
|
|
2327
|
+
return t2;
|
|
1424
2328
|
}
|
|
1425
2329
|
//#endregion
|
|
1426
2330
|
//#region src/form/number-field.tsx
|
|
@@ -1450,17 +2354,51 @@ function Fieldset({ legend, id, disabled, children }) {
|
|
|
1450
2354
|
* />
|
|
1451
2355
|
* ```
|
|
1452
2356
|
*/
|
|
1453
|
-
function NumberField(
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
2357
|
+
function NumberField(t0) {
|
|
2358
|
+
const $ = c(15);
|
|
2359
|
+
const { label, value, onChange, name, min, max, step, disabled } = t0;
|
|
2360
|
+
let t1;
|
|
2361
|
+
if ($[0] !== label) {
|
|
2362
|
+
t1 = /* @__PURE__ */ jsx("span", { children: label });
|
|
2363
|
+
$[0] = label;
|
|
2364
|
+
$[1] = t1;
|
|
2365
|
+
} else t1 = $[1];
|
|
2366
|
+
const t2 = Number.isFinite(value) ? value : "";
|
|
2367
|
+
let t3;
|
|
2368
|
+
if ($[2] !== onChange) {
|
|
2369
|
+
t3 = (e) => onChange(e.currentTarget.valueAsNumber);
|
|
2370
|
+
$[2] = onChange;
|
|
2371
|
+
$[3] = t3;
|
|
2372
|
+
} else t3 = $[3];
|
|
2373
|
+
let t4;
|
|
2374
|
+
if ($[4] !== disabled || $[5] !== max || $[6] !== min || $[7] !== name || $[8] !== step || $[9] !== t2 || $[10] !== t3) {
|
|
2375
|
+
t4 = /* @__PURE__ */ jsx("input", {
|
|
2376
|
+
type: "number",
|
|
2377
|
+
name,
|
|
2378
|
+
value: t2,
|
|
2379
|
+
min,
|
|
2380
|
+
max,
|
|
2381
|
+
step,
|
|
2382
|
+
disabled,
|
|
2383
|
+
onChange: t3
|
|
2384
|
+
});
|
|
2385
|
+
$[4] = disabled;
|
|
2386
|
+
$[5] = max;
|
|
2387
|
+
$[6] = min;
|
|
2388
|
+
$[7] = name;
|
|
2389
|
+
$[8] = step;
|
|
2390
|
+
$[9] = t2;
|
|
2391
|
+
$[10] = t3;
|
|
2392
|
+
$[11] = t4;
|
|
2393
|
+
} else t4 = $[11];
|
|
2394
|
+
let t5;
|
|
2395
|
+
if ($[12] !== t1 || $[13] !== t4) {
|
|
2396
|
+
t5 = /* @__PURE__ */ jsxs("label", { children: [t1, t4] });
|
|
2397
|
+
$[12] = t1;
|
|
2398
|
+
$[13] = t4;
|
|
2399
|
+
$[14] = t5;
|
|
2400
|
+
} else t5 = $[14];
|
|
2401
|
+
return t5;
|
|
1464
2402
|
}
|
|
1465
2403
|
//#endregion
|
|
1466
2404
|
//#region src/form/radio-group.tsx
|
|
@@ -1492,25 +2430,61 @@ function NumberField({ label, value, onChange, name, min, max, step, disabled })
|
|
|
1492
2430
|
* />
|
|
1493
2431
|
* ```
|
|
1494
2432
|
*/
|
|
1495
|
-
function RadioGroup(
|
|
2433
|
+
function RadioGroup(t0) {
|
|
2434
|
+
const $ = c(18);
|
|
2435
|
+
const { label, value, onChange, options, name, disabled } = t0;
|
|
1496
2436
|
const labelId = useId();
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
"
|
|
1500
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
2437
|
+
let t1;
|
|
2438
|
+
if ($[0] !== label || $[1] !== labelId) {
|
|
2439
|
+
t1 = /* @__PURE__ */ jsx("div", {
|
|
1501
2440
|
id: labelId,
|
|
1502
2441
|
children: label
|
|
1503
|
-
})
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
2442
|
+
});
|
|
2443
|
+
$[0] = label;
|
|
2444
|
+
$[1] = labelId;
|
|
2445
|
+
$[2] = t1;
|
|
2446
|
+
} else t1 = $[2];
|
|
2447
|
+
let t2;
|
|
2448
|
+
if ($[3] !== disabled || $[4] !== name || $[5] !== onChange || $[6] !== options || $[7] !== value) {
|
|
2449
|
+
let t3;
|
|
2450
|
+
if ($[9] !== disabled || $[10] !== name || $[11] !== onChange || $[12] !== value) {
|
|
2451
|
+
t3 = (option) => /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("input", {
|
|
2452
|
+
type: "radio",
|
|
2453
|
+
name,
|
|
2454
|
+
value: option.value,
|
|
2455
|
+
checked: value === option.value,
|
|
2456
|
+
disabled,
|
|
2457
|
+
onChange: (e) => {
|
|
2458
|
+
if (e.currentTarget.checked) onChange(option.value);
|
|
2459
|
+
}
|
|
2460
|
+
}), option.label] }, option.value);
|
|
2461
|
+
$[9] = disabled;
|
|
2462
|
+
$[10] = name;
|
|
2463
|
+
$[11] = onChange;
|
|
2464
|
+
$[12] = value;
|
|
2465
|
+
$[13] = t3;
|
|
2466
|
+
} else t3 = $[13];
|
|
2467
|
+
t2 = options.map(t3);
|
|
2468
|
+
$[3] = disabled;
|
|
2469
|
+
$[4] = name;
|
|
2470
|
+
$[5] = onChange;
|
|
2471
|
+
$[6] = options;
|
|
2472
|
+
$[7] = value;
|
|
2473
|
+
$[8] = t2;
|
|
2474
|
+
} else t2 = $[8];
|
|
2475
|
+
let t3;
|
|
2476
|
+
if ($[14] !== labelId || $[15] !== t1 || $[16] !== t2) {
|
|
2477
|
+
t3 = /* @__PURE__ */ jsxs("div", {
|
|
2478
|
+
role: "radiogroup",
|
|
2479
|
+
"aria-labelledby": labelId,
|
|
2480
|
+
children: [t1, t2]
|
|
2481
|
+
});
|
|
2482
|
+
$[14] = labelId;
|
|
2483
|
+
$[15] = t1;
|
|
2484
|
+
$[16] = t2;
|
|
2485
|
+
$[17] = t3;
|
|
2486
|
+
} else t3 = $[17];
|
|
2487
|
+
return t3;
|
|
1514
2488
|
}
|
|
1515
2489
|
//#endregion
|
|
1516
2490
|
//#region src/form/select-field.tsx
|
|
@@ -1542,17 +2516,57 @@ function RadioGroup({ label, value, onChange, options, name, disabled }) {
|
|
|
1542
2516
|
* />
|
|
1543
2517
|
* ```
|
|
1544
2518
|
*/
|
|
1545
|
-
function SelectField(
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
2519
|
+
function SelectField(t0) {
|
|
2520
|
+
const $ = c(15);
|
|
2521
|
+
const { label, value, onChange, options, name, disabled } = t0;
|
|
2522
|
+
let t1;
|
|
2523
|
+
if ($[0] !== label) {
|
|
2524
|
+
t1 = /* @__PURE__ */ jsx("span", { children: label });
|
|
2525
|
+
$[0] = label;
|
|
2526
|
+
$[1] = t1;
|
|
2527
|
+
} else t1 = $[1];
|
|
2528
|
+
let t2;
|
|
2529
|
+
if ($[2] !== onChange) {
|
|
2530
|
+
t2 = (e) => onChange(e.currentTarget.value);
|
|
2531
|
+
$[2] = onChange;
|
|
2532
|
+
$[3] = t2;
|
|
2533
|
+
} else t2 = $[3];
|
|
2534
|
+
let t3;
|
|
2535
|
+
if ($[4] !== options) {
|
|
2536
|
+
t3 = options.map(_temp);
|
|
2537
|
+
$[4] = options;
|
|
2538
|
+
$[5] = t3;
|
|
2539
|
+
} else t3 = $[5];
|
|
2540
|
+
let t4;
|
|
2541
|
+
if ($[6] !== disabled || $[7] !== name || $[8] !== t2 || $[9] !== t3 || $[10] !== value) {
|
|
2542
|
+
t4 = /* @__PURE__ */ jsx("select", {
|
|
2543
|
+
name,
|
|
2544
|
+
value,
|
|
2545
|
+
disabled,
|
|
2546
|
+
onChange: t2,
|
|
2547
|
+
children: t3
|
|
2548
|
+
});
|
|
2549
|
+
$[6] = disabled;
|
|
2550
|
+
$[7] = name;
|
|
2551
|
+
$[8] = t2;
|
|
2552
|
+
$[9] = t3;
|
|
2553
|
+
$[10] = value;
|
|
2554
|
+
$[11] = t4;
|
|
2555
|
+
} else t4 = $[11];
|
|
2556
|
+
let t5;
|
|
2557
|
+
if ($[12] !== t1 || $[13] !== t4) {
|
|
2558
|
+
t5 = /* @__PURE__ */ jsxs("label", { children: [t1, t4] });
|
|
2559
|
+
$[12] = t1;
|
|
2560
|
+
$[13] = t4;
|
|
2561
|
+
$[14] = t5;
|
|
2562
|
+
} else t5 = $[14];
|
|
2563
|
+
return t5;
|
|
2564
|
+
}
|
|
2565
|
+
function _temp(option) {
|
|
2566
|
+
return /* @__PURE__ */ jsx("option", {
|
|
2567
|
+
value: option.value,
|
|
2568
|
+
children: option.label
|
|
2569
|
+
}, option.value);
|
|
1556
2570
|
}
|
|
1557
2571
|
//#endregion
|
|
1558
2572
|
//#region src/form/text-area.tsx
|
|
@@ -1580,14 +2594,45 @@ function SelectField({ label, value, onChange, options, name, disabled }) {
|
|
|
1580
2594
|
* />
|
|
1581
2595
|
* ```
|
|
1582
2596
|
*/
|
|
1583
|
-
function TextArea(
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
2597
|
+
function TextArea(t0) {
|
|
2598
|
+
const $ = c(13);
|
|
2599
|
+
const { label, value, onChange, name, rows, disabled } = t0;
|
|
2600
|
+
let t1;
|
|
2601
|
+
if ($[0] !== label) {
|
|
2602
|
+
t1 = /* @__PURE__ */ jsx("span", { children: label });
|
|
2603
|
+
$[0] = label;
|
|
2604
|
+
$[1] = t1;
|
|
2605
|
+
} else t1 = $[1];
|
|
2606
|
+
let t2;
|
|
2607
|
+
if ($[2] !== onChange) {
|
|
2608
|
+
t2 = (e) => onChange(e.currentTarget.value);
|
|
2609
|
+
$[2] = onChange;
|
|
2610
|
+
$[3] = t2;
|
|
2611
|
+
} else t2 = $[3];
|
|
2612
|
+
let t3;
|
|
2613
|
+
if ($[4] !== disabled || $[5] !== name || $[6] !== rows || $[7] !== t2 || $[8] !== value) {
|
|
2614
|
+
t3 = /* @__PURE__ */ jsx("textarea", {
|
|
2615
|
+
name,
|
|
2616
|
+
value,
|
|
2617
|
+
rows,
|
|
2618
|
+
disabled,
|
|
2619
|
+
onChange: t2
|
|
2620
|
+
});
|
|
2621
|
+
$[4] = disabled;
|
|
2622
|
+
$[5] = name;
|
|
2623
|
+
$[6] = rows;
|
|
2624
|
+
$[7] = t2;
|
|
2625
|
+
$[8] = value;
|
|
2626
|
+
$[9] = t3;
|
|
2627
|
+
} else t3 = $[9];
|
|
2628
|
+
let t4;
|
|
2629
|
+
if ($[10] !== t1 || $[11] !== t3) {
|
|
2630
|
+
t4 = /* @__PURE__ */ jsxs("label", { children: [t1, t3] });
|
|
2631
|
+
$[10] = t1;
|
|
2632
|
+
$[11] = t3;
|
|
2633
|
+
$[12] = t4;
|
|
2634
|
+
} else t4 = $[12];
|
|
2635
|
+
return t4;
|
|
1591
2636
|
}
|
|
1592
2637
|
//#endregion
|
|
1593
2638
|
//#region src/form/text-field.tsx
|
|
@@ -1606,6 +2651,7 @@ function TextArea({ label, value, onChange, name, rows, disabled }) {
|
|
|
1606
2651
|
* @param root0.name
|
|
1607
2652
|
* @param root0.disabled
|
|
1608
2653
|
* @param root0.placeholder
|
|
2654
|
+
* @param root0.describedBy
|
|
1609
2655
|
* @example
|
|
1610
2656
|
* ```tsx
|
|
1611
2657
|
* <TextField
|
|
@@ -1616,17 +2662,52 @@ function TextArea({ label, value, onChange, name, rows, disabled }) {
|
|
|
1616
2662
|
* />
|
|
1617
2663
|
* ```
|
|
1618
2664
|
*/
|
|
1619
|
-
function TextField(
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
2665
|
+
function TextField(t0) {
|
|
2666
|
+
const $ = c(15);
|
|
2667
|
+
const { label, value, onChange, type: t1, name, disabled, placeholder, describedBy } = t0;
|
|
2668
|
+
const type = t1 === void 0 ? "text" : t1;
|
|
2669
|
+
let t2;
|
|
2670
|
+
if ($[0] !== label) {
|
|
2671
|
+
t2 = /* @__PURE__ */ jsx("span", { children: label });
|
|
2672
|
+
$[0] = label;
|
|
2673
|
+
$[1] = t2;
|
|
2674
|
+
} else t2 = $[1];
|
|
2675
|
+
let t3;
|
|
2676
|
+
if ($[2] !== onChange) {
|
|
2677
|
+
t3 = (e) => onChange(e.currentTarget.value);
|
|
2678
|
+
$[2] = onChange;
|
|
2679
|
+
$[3] = t3;
|
|
2680
|
+
} else t3 = $[3];
|
|
2681
|
+
let t4;
|
|
2682
|
+
if ($[4] !== describedBy || $[5] !== disabled || $[6] !== name || $[7] !== placeholder || $[8] !== t3 || $[9] !== type || $[10] !== value) {
|
|
2683
|
+
t4 = /* @__PURE__ */ jsx("input", {
|
|
2684
|
+
type,
|
|
2685
|
+
name,
|
|
2686
|
+
value,
|
|
2687
|
+
disabled,
|
|
2688
|
+
placeholder,
|
|
2689
|
+
"aria-describedby": describedBy,
|
|
2690
|
+
onChange: t3
|
|
2691
|
+
});
|
|
2692
|
+
$[4] = describedBy;
|
|
2693
|
+
$[5] = disabled;
|
|
2694
|
+
$[6] = name;
|
|
2695
|
+
$[7] = placeholder;
|
|
2696
|
+
$[8] = t3;
|
|
2697
|
+
$[9] = type;
|
|
2698
|
+
$[10] = value;
|
|
2699
|
+
$[11] = t4;
|
|
2700
|
+
} else t4 = $[11];
|
|
2701
|
+
let t5;
|
|
2702
|
+
if ($[12] !== t2 || $[13] !== t4) {
|
|
2703
|
+
t5 = /* @__PURE__ */ jsxs("label", { children: [t2, t4] });
|
|
2704
|
+
$[12] = t2;
|
|
2705
|
+
$[13] = t4;
|
|
2706
|
+
$[14] = t5;
|
|
2707
|
+
} else t5 = $[14];
|
|
2708
|
+
return t5;
|
|
1628
2709
|
}
|
|
1629
2710
|
//#endregion
|
|
1630
|
-
export { BlockCatalog, BlockMenu, BlockMenuButton, BlockMenuView, BlockOptions, Checkbox, DraftSwitcher, EditableAreaView, EditorDialog, Fieldset, FileList, FileUploader, FrontMatterEditorView, InitialInsertionButton, ItemEditorHost, NumberField, Preview, RadioGroup, SelectField, TableEditor, Tabs, TextArea, TextField, Thumbnail, WysiwygField, createFrontMatterEditor, reactMount, registerEngineCommands, useCommand,
|
|
2711
|
+
export { BlockCatalog, BlockMenu, BlockMenuButton, BlockMenuView, BlockOptions, Checkbox, DraftSwitcher, EditableAreaView, EditorDialog, EngineProvider, Fieldset, FileList, FileUploader, FrontMatterEditorView, FrontMatterStore, InitialInsertionButton, ItemEditorHost, NumberField, Preview, RadioGroup, RootErrorBoundary, SelectField, TableEditor, Tabs, TextArea, TextField, Thumbnail, WysiwygField, createFrontMatterEditor, reactMount, registerEngineCommands, reportRenderError, useCommand, useEngine, useExternalFileSelection, useFileBrowser, useMountEffect, useUIState };
|
|
1631
2712
|
|
|
1632
2713
|
//# sourceMappingURL=ui.js.map
|