@burger-editor/client 4.0.0-alpha.71 → 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.css +1 -0
- package/dist/client.js +24180 -29905
- 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 +82 -0
- package/dist/components/block-menu-view.d.ts.map +1 -0
- package/dist/components/block-menu.d.ts +7 -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 +104 -0
- package/dist/components/front-matter-editor.d.ts.map +1 -0
- package/dist/components/index.d.ts +5 -0
- 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/engine-context-gX6mWHke.js +15758 -0
- 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 +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/mount.d.ts +14 -8
- 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 +2680 -956
- 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/initial-insertion-button-DMGBvuDE.js +0 -9147
- package/dist/initial-insertion-button-DMGBvuDE.js.map +0 -1
package/dist/ui.js
CHANGED
|
@@ -1,989 +1,2713 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { d as formatDate, n as useEngine, t as EngineProvider, u as formatByteSize } from "./engine-context-gX6mWHke.js";
|
|
2
|
+
import { _ as IconTrash, a as BlockMenuButton, c as reportRenderError, d as registerEngineCommands, f as useUIState, g as BlockCatalog, h as BlockOptions, i as BlockMenuView, l as reactMount, m as EditorDialog, n as InitialInsertionButton, o as useCommand, p as ItemEditorHost, r as BlockMenu, s as RootErrorBoundary, t as EditableAreaView, u as DraftSwitcher, v as IconRowInsertBottom, y as createReactComponent } from "./editable-area-view-DssYcTqQ.js";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
4
|
+
import { Fragment, use, useDeferredValue, useEffect, useEffectEvent, useId, useRef, useState, useSyncExternalStore, useTransition } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { createRoot } from "react-dom/client";
|
|
6
7
|
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
8
|
+
* @license @tabler/icons-react v3.46.0 - MIT
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the MIT license.
|
|
11
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/
|
|
13
|
+
var IconArrowsTransferDown = createReactComponent("outline", "arrows-transfer-down", "ArrowsTransferDown", [
|
|
14
|
+
["path", {
|
|
15
|
+
"d": "M17 3v6",
|
|
16
|
+
"key": "svg-0"
|
|
17
|
+
}],
|
|
18
|
+
["path", {
|
|
19
|
+
"d": "M10 18l-3 3l-3 -3",
|
|
20
|
+
"key": "svg-1"
|
|
21
|
+
}],
|
|
22
|
+
["path", {
|
|
23
|
+
"d": "M7 21v-18",
|
|
24
|
+
"key": "svg-2"
|
|
25
|
+
}],
|
|
26
|
+
["path", {
|
|
27
|
+
"d": "M20 6l-3 -3l-3 3",
|
|
28
|
+
"key": "svg-3"
|
|
29
|
+
}],
|
|
30
|
+
["path", {
|
|
31
|
+
"d": "M17 21v-2",
|
|
32
|
+
"key": "svg-4"
|
|
33
|
+
}],
|
|
34
|
+
["path", {
|
|
35
|
+
"d": "M17 15v-2",
|
|
36
|
+
"key": "svg-5"
|
|
37
|
+
}]
|
|
38
|
+
]);
|
|
40
39
|
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
* @license @tabler/icons-react v3.46.0 - MIT
|
|
41
|
+
*
|
|
42
|
+
* This source code is licensed under the MIT license.
|
|
43
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
44
|
+
*/
|
|
45
|
+
var IconFileTypeDoc = createReactComponent("outline", "file-type-doc", "FileTypeDoc", [
|
|
46
|
+
["path", {
|
|
47
|
+
"d": "M14 3v4a1 1 0 0 0 1 1h4",
|
|
48
|
+
"key": "svg-0"
|
|
49
|
+
}],
|
|
50
|
+
["path", {
|
|
51
|
+
"d": "M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4",
|
|
52
|
+
"key": "svg-1"
|
|
53
|
+
}],
|
|
54
|
+
["path", {
|
|
55
|
+
"d": "M5 15v6h1a2 2 0 0 0 2 -2v-2a2 2 0 0 0 -2 -2h-1",
|
|
56
|
+
"key": "svg-2"
|
|
57
|
+
}],
|
|
58
|
+
["path", {
|
|
59
|
+
"d": "M20 16.5a1.5 1.5 0 0 0 -3 0v3a1.5 1.5 0 0 0 3 0",
|
|
60
|
+
"key": "svg-3"
|
|
61
|
+
}],
|
|
62
|
+
["path", {
|
|
63
|
+
"d": "M12.5 15a1.5 1.5 0 0 1 1.5 1.5v3a1.5 1.5 0 0 1 -3 0v-3a1.5 1.5 0 0 1 1.5 -1.5",
|
|
64
|
+
"key": "svg-4"
|
|
65
|
+
}]
|
|
66
|
+
]);
|
|
51
67
|
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
68
|
+
* @license @tabler/icons-react v3.46.0 - MIT
|
|
69
|
+
*
|
|
70
|
+
* This source code is licensed under the MIT license.
|
|
71
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
72
|
+
*/
|
|
73
|
+
var IconFileTypePdf = createReactComponent("outline", "file-type-pdf", "FileTypePdf", [
|
|
74
|
+
["path", {
|
|
75
|
+
"d": "M14 3v4a1 1 0 0 0 1 1h4",
|
|
76
|
+
"key": "svg-0"
|
|
77
|
+
}],
|
|
78
|
+
["path", {
|
|
79
|
+
"d": "M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4",
|
|
80
|
+
"key": "svg-1"
|
|
81
|
+
}],
|
|
82
|
+
["path", {
|
|
83
|
+
"d": "M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6",
|
|
84
|
+
"key": "svg-2"
|
|
85
|
+
}],
|
|
86
|
+
["path", {
|
|
87
|
+
"d": "M17 18h2",
|
|
88
|
+
"key": "svg-3"
|
|
89
|
+
}],
|
|
90
|
+
["path", {
|
|
91
|
+
"d": "M20 15h-3v6",
|
|
92
|
+
"key": "svg-4"
|
|
93
|
+
}],
|
|
94
|
+
["path", {
|
|
95
|
+
"d": "M11 15v6h1a2 2 0 0 0 2 -2v-2a2 2 0 0 0 -2 -2h-1",
|
|
96
|
+
"key": "svg-5"
|
|
97
|
+
}]
|
|
98
|
+
]);
|
|
62
99
|
/**
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
100
|
+
* @license @tabler/icons-react v3.46.0 - MIT
|
|
101
|
+
*
|
|
102
|
+
* This source code is licensed under the MIT license.
|
|
103
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
104
|
+
*/
|
|
105
|
+
var IconFileTypePpt = createReactComponent("outline", "file-type-ppt", "FileTypePpt", [
|
|
106
|
+
["path", {
|
|
107
|
+
"d": "M14 3v4a1 1 0 0 0 1 1h4",
|
|
108
|
+
"key": "svg-0"
|
|
109
|
+
}],
|
|
110
|
+
["path", {
|
|
111
|
+
"d": "M14 3v4a1 1 0 0 0 1 1h4",
|
|
112
|
+
"key": "svg-1"
|
|
113
|
+
}],
|
|
114
|
+
["path", {
|
|
115
|
+
"d": "M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6",
|
|
116
|
+
"key": "svg-2"
|
|
117
|
+
}],
|
|
118
|
+
["path", {
|
|
119
|
+
"d": "M11 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6",
|
|
120
|
+
"key": "svg-3"
|
|
121
|
+
}],
|
|
122
|
+
["path", {
|
|
123
|
+
"d": "M16.5 15h3",
|
|
124
|
+
"key": "svg-4"
|
|
125
|
+
}],
|
|
126
|
+
["path", {
|
|
127
|
+
"d": "M18 15v6",
|
|
128
|
+
"key": "svg-5"
|
|
129
|
+
}],
|
|
130
|
+
["path", {
|
|
131
|
+
"d": "M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4",
|
|
132
|
+
"key": "svg-6"
|
|
133
|
+
}]
|
|
134
|
+
]);
|
|
73
135
|
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
136
|
+
* @license @tabler/icons-react v3.46.0 - MIT
|
|
137
|
+
*
|
|
138
|
+
* This source code is licensed under the MIT license.
|
|
139
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
140
|
+
*/
|
|
141
|
+
var IconFileTypeXls = createReactComponent("outline", "file-type-xls", "FileTypeXls", [
|
|
142
|
+
["path", {
|
|
143
|
+
"d": "M14 3v4a1 1 0 0 0 1 1h4",
|
|
144
|
+
"key": "svg-0"
|
|
145
|
+
}],
|
|
146
|
+
["path", {
|
|
147
|
+
"d": "M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4",
|
|
148
|
+
"key": "svg-1"
|
|
149
|
+
}],
|
|
150
|
+
["path", {
|
|
151
|
+
"d": "M4 15l4 6",
|
|
152
|
+
"key": "svg-2"
|
|
153
|
+
}],
|
|
154
|
+
["path", {
|
|
155
|
+
"d": "M4 21l4 -6",
|
|
156
|
+
"key": "svg-3"
|
|
157
|
+
}],
|
|
158
|
+
["path", {
|
|
159
|
+
"d": "M17 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75",
|
|
160
|
+
"key": "svg-4"
|
|
161
|
+
}],
|
|
162
|
+
["path", {
|
|
163
|
+
"d": "M11 15v6h3",
|
|
164
|
+
"key": "svg-5"
|
|
165
|
+
}]
|
|
166
|
+
]);
|
|
84
167
|
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
168
|
+
* @license @tabler/icons-react v3.46.0 - MIT
|
|
169
|
+
*
|
|
170
|
+
* This source code is licensed under the MIT license.
|
|
171
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
172
|
+
*/
|
|
173
|
+
var IconFile = createReactComponent("outline", "file", "File", [["path", {
|
|
174
|
+
"d": "M14 3v4a1 1 0 0 0 1 1h4",
|
|
175
|
+
"key": "svg-0"
|
|
176
|
+
}], ["path", {
|
|
177
|
+
"d": "M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2",
|
|
178
|
+
"key": "svg-1"
|
|
179
|
+
}]]);
|
|
95
180
|
/**
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
181
|
+
* @license @tabler/icons-react v3.46.0 - MIT
|
|
182
|
+
*
|
|
183
|
+
* This source code is licensed under the MIT license.
|
|
184
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
185
|
+
*/
|
|
186
|
+
var IconHeadphones = createReactComponent("outline", "headphones", "Headphones", [
|
|
187
|
+
["path", {
|
|
188
|
+
"d": "M4 15a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v3a2 2 0 0 1 -2 2h-1a2 2 0 0 1 -2 -2l0 -3",
|
|
189
|
+
"key": "svg-0"
|
|
190
|
+
}],
|
|
191
|
+
["path", {
|
|
192
|
+
"d": "M15 15a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v3a2 2 0 0 1 -2 2h-1a2 2 0 0 1 -2 -2l0 -3",
|
|
193
|
+
"key": "svg-1"
|
|
194
|
+
}],
|
|
195
|
+
["path", {
|
|
196
|
+
"d": "M4 15v-3a8 8 0 0 1 16 0v3",
|
|
197
|
+
"key": "svg-2"
|
|
198
|
+
}]
|
|
199
|
+
]);
|
|
106
200
|
/**
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
201
|
+
* @license @tabler/icons-react v3.46.0 - MIT
|
|
202
|
+
*
|
|
203
|
+
* This source code is licensed under the MIT license.
|
|
204
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
205
|
+
*/
|
|
206
|
+
var IconVideo = createReactComponent("outline", "video", "Video", [["path", {
|
|
207
|
+
"d": "M15 10l4.553 -2.276a1 1 0 0 1 1.447 .894v6.764a1 1 0 0 1 -1.447 .894l-4.553 -2.276v-4",
|
|
208
|
+
"key": "svg-0"
|
|
209
|
+
}], ["path", {
|
|
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",
|
|
211
|
+
"key": "svg-1"
|
|
212
|
+
}]]);
|
|
213
|
+
//#endregion
|
|
214
|
+
//#region src/file-browser/store.ts
|
|
117
215
|
/**
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
+
}
|
|
468
|
+
var file_list_module_default = {
|
|
469
|
+
ctrl: "_ctrl_1vnsv_1",
|
|
470
|
+
pagination: "_pagination_1vnsv_7",
|
|
471
|
+
page: "_page_1vnsv_19",
|
|
472
|
+
list: "_list_1vnsv_25",
|
|
140
473
|
"delete": "_delete_1vnsv_39",
|
|
141
|
-
file:
|
|
142
|
-
thumbnail:
|
|
143
|
-
attr:
|
|
474
|
+
file: "_file_1vnsv_44",
|
|
475
|
+
thumbnail: "_thumbnail_1vnsv_58",
|
|
476
|
+
attr: "_attr_1vnsv_65"
|
|
144
477
|
};
|
|
145
|
-
|
|
478
|
+
//#endregion
|
|
479
|
+
//#region src/get-ext.ts
|
|
480
|
+
/**
|
|
481
|
+
*
|
|
482
|
+
* @param src
|
|
483
|
+
*/
|
|
146
484
|
function getExt(src) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
485
|
+
const ext = src.split(".").pop()?.toLowerCase() ?? "";
|
|
486
|
+
return {
|
|
487
|
+
ext,
|
|
488
|
+
isImage: [
|
|
489
|
+
"jpg",
|
|
490
|
+
"jpeg",
|
|
491
|
+
"png",
|
|
492
|
+
"gif",
|
|
493
|
+
"webp",
|
|
494
|
+
"svg"
|
|
495
|
+
].includes(ext),
|
|
496
|
+
isVideo: [
|
|
497
|
+
"mp4",
|
|
498
|
+
"webm",
|
|
499
|
+
"mov",
|
|
500
|
+
"avi"
|
|
501
|
+
].includes(ext),
|
|
502
|
+
isAudio: [
|
|
503
|
+
"mp3",
|
|
504
|
+
"wav",
|
|
505
|
+
"m4a",
|
|
506
|
+
"ogg",
|
|
507
|
+
"flac"
|
|
508
|
+
].includes(ext),
|
|
509
|
+
isDoc: ["doc", "docx"].includes(ext),
|
|
510
|
+
isPpt: ["ppt", "pptx"].includes(ext),
|
|
511
|
+
isXls: ["xls", "xlsx"].includes(ext),
|
|
512
|
+
isPdf: ["pdf"].includes(ext)
|
|
513
|
+
};
|
|
165
514
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
515
|
+
var thumbnail_module_default = { thumbnail: "_thumbnail_bi2ve_1" };
|
|
516
|
+
//#endregion
|
|
517
|
+
//#region src/components/thumbnail.tsx
|
|
518
|
+
/**
|
|
519
|
+
* File thumbnail. Renders an image/video preview or a file-type icon.
|
|
520
|
+
*
|
|
521
|
+
* The file type is inferred from the URL's extension (`getExt`) — the
|
|
522
|
+
* URL is the only information available here, so the extension decides
|
|
523
|
+
* whether the file can be previewed inline or needs a type icon.
|
|
524
|
+
* @param root0
|
|
525
|
+
* @param root0.src
|
|
526
|
+
* @example
|
|
527
|
+
* ```tsx
|
|
528
|
+
* <Thumbnail src={file.url} />
|
|
529
|
+
* ```
|
|
530
|
+
*/
|
|
531
|
+
function Thumbnail(t0) {
|
|
532
|
+
const $ = c(15);
|
|
533
|
+
const { src } = t0;
|
|
534
|
+
const [isLoaded, setIsLoaded] = useState(false);
|
|
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", {
|
|
545
|
+
src,
|
|
546
|
+
alt: "画像のプレビュー",
|
|
547
|
+
loading: "lazy",
|
|
548
|
+
onLoad: () => setIsLoaded(true)
|
|
549
|
+
}) : file.isVideo ? /* @__PURE__ */ jsxs("video", {
|
|
550
|
+
controls: false,
|
|
551
|
+
playsInline: true,
|
|
552
|
+
children: [
|
|
553
|
+
/* @__PURE__ */ jsx("source", {
|
|
554
|
+
src,
|
|
555
|
+
type: `video/${file.ext}`
|
|
556
|
+
}),
|
|
557
|
+
/* @__PURE__ */ jsx("track", {
|
|
558
|
+
kind: "captions",
|
|
559
|
+
src: ""
|
|
560
|
+
}),
|
|
561
|
+
/* @__PURE__ */ jsx(IconVideo, {})
|
|
562
|
+
]
|
|
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;
|
|
196
588
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
disabled: currentPage === totalPage - 1,
|
|
363
|
-
command: "--paginate",
|
|
364
|
-
commandfor: rootId,
|
|
365
|
-
value: "next",
|
|
366
|
-
children: "次へ"
|
|
367
|
-
}
|
|
368
|
-
)
|
|
369
|
-
] }),
|
|
370
|
-
/* @__PURE__ */ jsx(
|
|
371
|
-
"input",
|
|
372
|
-
{
|
|
373
|
-
type: "search",
|
|
374
|
-
placeholder: "検索",
|
|
375
|
-
value: searchWord,
|
|
376
|
-
onChange: (e) => search(e.currentTarget.value)
|
|
377
|
-
}
|
|
378
|
-
)
|
|
379
|
-
] }),
|
|
380
|
-
/* @__PURE__ */ jsx("ul", { className: styles$5["list"], children: fileList.map((file) => /* @__PURE__ */ jsxs("li", { children: [
|
|
381
|
-
/* @__PURE__ */ jsxs(
|
|
382
|
-
"button",
|
|
383
|
-
{
|
|
384
|
-
ref: file.url === selectedPath ? scrollToSelected : void 0,
|
|
385
|
-
className: styles$5["file"],
|
|
386
|
-
type: "button",
|
|
387
|
-
"aria-pressed": file.url === selectedPath,
|
|
388
|
-
command: "--select-file",
|
|
389
|
-
commandfor: rootId,
|
|
390
|
-
value: file.url,
|
|
391
|
-
"data-size": file.size,
|
|
392
|
-
children: [
|
|
393
|
-
/* @__PURE__ */ jsx("span", { className: styles$5["thumbnail"], children: /* @__PURE__ */ jsx(Thumbnail, { src: file.url }) }),
|
|
394
|
-
file.url.startsWith("blob:") ? /* @__PURE__ */ jsxs("span", { children: [
|
|
395
|
-
"アップロード中...",
|
|
396
|
-
" ",
|
|
397
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
398
|
-
Math.floor(progress.uploaded / progress.total * 100),
|
|
399
|
-
"%"
|
|
400
|
-
] })
|
|
401
|
-
] }) : /* @__PURE__ */ jsxs("span", { className: styles$5["attr"], children: [
|
|
402
|
-
/* @__PURE__ */ jsx("span", { children: "ID" }),
|
|
403
|
-
/* @__PURE__ */ jsx("span", { children: marked(file.fileId) }),
|
|
404
|
-
/* @__PURE__ */ jsx("span", { children: "名称" }),
|
|
405
|
-
/* @__PURE__ */ jsx("span", { children: marked(file.name) }),
|
|
406
|
-
/* @__PURE__ */ jsx("span", { children: "更新" }),
|
|
407
|
-
/* @__PURE__ */ jsx("span", { children: formatDate(file.timestamp / 1e3, "YYYY-MM-DD HH:mm") }),
|
|
408
|
-
/* @__PURE__ */ jsx("span", { children: "サイズ" }),
|
|
409
|
-
/* @__PURE__ */ jsx("span", { children: formatByteSize(file.size) })
|
|
410
|
-
] })
|
|
411
|
-
]
|
|
412
|
-
}
|
|
413
|
-
),
|
|
414
|
-
!file.url.startsWith("blob:") && deleteFile ? /* @__PURE__ */ jsx(
|
|
415
|
-
"button",
|
|
416
|
-
{
|
|
417
|
-
className: styles$5["delete"],
|
|
418
|
-
type: "button",
|
|
419
|
-
command: "--delete-file",
|
|
420
|
-
commandfor: rootId,
|
|
421
|
-
value: file.url,
|
|
422
|
-
children: "削除"
|
|
423
|
-
}
|
|
424
|
-
) : null
|
|
425
|
-
] }, file.url)) })
|
|
426
|
-
] });
|
|
589
|
+
//#endregion
|
|
590
|
+
//#region src/components/file-list.tsx
|
|
591
|
+
/**
|
|
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.
|
|
597
|
+
* @param root0
|
|
598
|
+
* @param root0.fileType
|
|
599
|
+
* @example
|
|
600
|
+
* ```tsx
|
|
601
|
+
* <FileUploader fileType="image" />
|
|
602
|
+
* <FileList fileType="image" />
|
|
603
|
+
* ```
|
|
604
|
+
*/
|
|
605
|
+
function FileList({ fileType }) {
|
|
606
|
+
"use no memo";
|
|
607
|
+
const store = useFileBrowser();
|
|
608
|
+
const rootId = useId();
|
|
609
|
+
const [page, setPage] = useState(0);
|
|
610
|
+
const [searchWord, setSearchWord] = useState("");
|
|
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);
|
|
635
|
+
});
|
|
636
|
+
};
|
|
637
|
+
const rootRef = useCommand({
|
|
638
|
+
"--paginate": (e) => {
|
|
639
|
+
const direction = e.source?.value;
|
|
640
|
+
paginate(direction === "prev" ? currentPage - 1 : currentPage + 1);
|
|
641
|
+
},
|
|
642
|
+
"--select-file": (e_0) => {
|
|
643
|
+
const source = e_0.source;
|
|
644
|
+
if (!source) return;
|
|
645
|
+
store.select(fileType, source.value, Number(source.dataset["size"] ?? "0"));
|
|
646
|
+
},
|
|
647
|
+
"--delete-file": (e_1) => {
|
|
648
|
+
const url = e_1.source?.value;
|
|
649
|
+
if (!url) return;
|
|
650
|
+
startTransition(async () => {
|
|
651
|
+
try {
|
|
652
|
+
await store.deleteFile(fileType, url);
|
|
653
|
+
} catch {
|
|
654
|
+
alert("ファイルの削除に失敗しました。");
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
const marked = (text) => {
|
|
660
|
+
if (!searchWord) return text;
|
|
661
|
+
return text.split(searchWord).map((char, i) => /* @__PURE__ */ jsxs(Fragment, { children: [i === 0 ? null : /* @__PURE__ */ jsx("mark", { children: searchWord }), char] }, char + i));
|
|
662
|
+
};
|
|
663
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
664
|
+
ref: rootRef,
|
|
665
|
+
id: rootId,
|
|
666
|
+
"aria-busy": isPending,
|
|
667
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
668
|
+
className: file_list_module_default["ctrl"],
|
|
669
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
670
|
+
className: file_list_module_default["pagination"],
|
|
671
|
+
children: [
|
|
672
|
+
/* @__PURE__ */ jsx("button", {
|
|
673
|
+
type: "button",
|
|
674
|
+
disabled: currentPage === 0,
|
|
675
|
+
command: "--paginate",
|
|
676
|
+
commandfor: rootId,
|
|
677
|
+
value: "prev",
|
|
678
|
+
children: "前へ"
|
|
679
|
+
}),
|
|
680
|
+
/* @__PURE__ */ jsxs("div", {
|
|
681
|
+
className: file_list_module_default["page"],
|
|
682
|
+
children: [
|
|
683
|
+
/* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx("input", {
|
|
684
|
+
type: "number",
|
|
685
|
+
value: currentPage + 1,
|
|
686
|
+
min: "1",
|
|
687
|
+
max: totalPage,
|
|
688
|
+
onChange: (e_2) => paginate(e_2.currentTarget.valueAsNumber - 1),
|
|
689
|
+
"aria-label": "ページ番号"
|
|
690
|
+
}) }),
|
|
691
|
+
/* @__PURE__ */ jsx("span", { children: "/" }),
|
|
692
|
+
/* @__PURE__ */ jsx("span", { children: totalPage })
|
|
693
|
+
]
|
|
694
|
+
}),
|
|
695
|
+
/* @__PURE__ */ jsx("button", {
|
|
696
|
+
type: "button",
|
|
697
|
+
disabled: currentPage === totalPage - 1,
|
|
698
|
+
command: "--paginate",
|
|
699
|
+
commandfor: rootId,
|
|
700
|
+
value: "next",
|
|
701
|
+
children: "次へ"
|
|
702
|
+
})
|
|
703
|
+
]
|
|
704
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
705
|
+
type: "search",
|
|
706
|
+
placeholder: "検索",
|
|
707
|
+
value: searchWord,
|
|
708
|
+
onChange: (e_3) => setSearchWord(e_3.currentTarget.value)
|
|
709
|
+
})]
|
|
710
|
+
}), /* @__PURE__ */ jsx("ul", {
|
|
711
|
+
className: file_list_module_default["list"],
|
|
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
|
+
})
|
|
752
|
+
})]
|
|
753
|
+
});
|
|
427
754
|
}
|
|
755
|
+
/**
|
|
756
|
+
* Callback ref attached only to the currently selected file button, so the
|
|
757
|
+
* list scrolls to it when the selection mounts or changes. Kept at module
|
|
758
|
+
* scope for a stable identity — an inline arrow would re-attach (and
|
|
759
|
+
* re-scroll) on every unrelated re-render such as upload progress updates.
|
|
760
|
+
* @param el - The selected button, or null on detach
|
|
761
|
+
*/
|
|
428
762
|
function scrollToSelected(el) {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
763
|
+
el?.scrollIntoView({
|
|
764
|
+
behavior: "smooth",
|
|
765
|
+
block: "nearest"
|
|
766
|
+
});
|
|
433
767
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
768
|
+
var file_uploader_module_default = { uploader: "_uploader_obiwu_1" };
|
|
769
|
+
//#endregion
|
|
770
|
+
//#region src/components/file-uploader.tsx
|
|
771
|
+
/**
|
|
772
|
+
* File upload control. The trigger button declares a local command and
|
|
773
|
+
* the handler opens the picker via `showPicker()` — no click handlers,
|
|
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.
|
|
777
|
+
* @param root0
|
|
778
|
+
* @param root0.fileType
|
|
779
|
+
* @example
|
|
780
|
+
* ```tsx
|
|
781
|
+
* <FileUploader fileType="image" />
|
|
782
|
+
* ```
|
|
783
|
+
*/
|
|
784
|
+
function FileUploader(t0) {
|
|
785
|
+
const $ = c(15);
|
|
786
|
+
const { fileType } = t0;
|
|
787
|
+
const store = useFileBrowser();
|
|
788
|
+
const rootId = useId();
|
|
789
|
+
const inputRef = useRef(null);
|
|
790
|
+
const [, startTransition] = useTransition();
|
|
791
|
+
const accept = fileType === "image" ? "image/*" : "*";
|
|
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
|
+
}
|
|
811
|
+
});
|
|
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", {
|
|
822
|
+
type: "file",
|
|
823
|
+
ref: inputRef,
|
|
824
|
+
onChange: stageFile,
|
|
825
|
+
accept
|
|
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", {
|
|
834
|
+
type: "button",
|
|
835
|
+
command: "--open-file-picker",
|
|
836
|
+
commandfor: rootId,
|
|
837
|
+
children: "ファイルを追加アップロードする"
|
|
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;
|
|
500
857
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
858
|
+
//#endregion
|
|
859
|
+
//#region src/components/front-matter-editor.tsx
|
|
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
|
+
}
|
|
517
901
|
};
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
{ once: true }
|
|
563
|
-
);
|
|
564
|
-
}
|
|
565
|
-
return () => {
|
|
566
|
-
aborted = true;
|
|
567
|
-
};
|
|
568
|
-
}, [path]);
|
|
569
|
-
return /* @__PURE__ */ jsxs("div", { children: [
|
|
570
|
-
/* @__PURE__ */ jsxs(
|
|
571
|
-
"div",
|
|
572
|
-
{
|
|
573
|
-
className: `${styles$2["img"]} ${isUploadingMode ? styles$2["uploading"] : ""}`.trim(),
|
|
574
|
-
children: [
|
|
575
|
-
file?.isImage ? /* @__PURE__ */ jsx("img", { src: path, alt: "画像プレビュー" }) : file?.isVideo ? /* @__PURE__ */ jsxs("video", { controls: true, playsInline: true, children: [
|
|
576
|
-
/* @__PURE__ */ jsx("source", { src: path, type: `video/${file.ext}` }),
|
|
577
|
-
/* @__PURE__ */ jsx("track", { kind: "captions", src: "" })
|
|
578
|
-
] }) : file?.isAudio ? /* @__PURE__ */ jsxs("audio", { controls: true, children: [
|
|
579
|
-
/* @__PURE__ */ jsx("source", { src: path, type: `audio/${file.ext}` }),
|
|
580
|
-
/* @__PURE__ */ jsx("track", { kind: "metadata", src: "" })
|
|
581
|
-
] }) : file?.isDoc || file?.isPpt || file?.isXls || file?.isPdf ? /* @__PURE__ */ jsx(
|
|
582
|
-
"object",
|
|
583
|
-
{
|
|
584
|
-
data: path,
|
|
585
|
-
type: `application/${file.ext}`,
|
|
586
|
-
title: `${file.ext}ファイルのプレビュー`,
|
|
587
|
-
children: /* @__PURE__ */ jsx("p", { children: "プレビューできません" })
|
|
588
|
-
}
|
|
589
|
-
) : /* @__PURE__ */ jsx("p", { children: "プレビューできません" }),
|
|
590
|
-
isUploadingMode ? /* @__PURE__ */ jsx(
|
|
591
|
-
"div",
|
|
592
|
-
{
|
|
593
|
-
className: styles$2["progress"],
|
|
594
|
-
style: { translate: `${progress.uploaded / progress.total * 100}%` }
|
|
595
|
-
}
|
|
596
|
-
) : null
|
|
597
|
-
]
|
|
598
|
-
}
|
|
599
|
-
),
|
|
600
|
-
/* @__PURE__ */ jsxs("ul", { className: styles$2["meta"], children: [
|
|
601
|
-
isUploadingMode ? /* @__PURE__ */ jsxs("li", { className: styles$2["upload"], children: [
|
|
602
|
-
/* @__PURE__ */ jsx("span", { children: "アップロード..." }),
|
|
603
|
-
/* @__PURE__ */ jsxs("span", { className: styles$2["progress"], children: [
|
|
604
|
-
Math.round(progress.uploaded / progress.total * 100),
|
|
605
|
-
"% (",
|
|
606
|
-
progress.uploaded,
|
|
607
|
-
"/",
|
|
608
|
-
progress.total,
|
|
609
|
-
")"
|
|
610
|
-
] })
|
|
611
|
-
] }) : /* @__PURE__ */ jsx("li", { className: styles$2["path"], children: /* @__PURE__ */ jsx("a", { href: path, target: "_blank", children: path }) }),
|
|
612
|
-
dimension ? /* @__PURE__ */ jsxs("li", { className: styles$2["dimension"], children: [
|
|
613
|
-
dimension.width,
|
|
614
|
-
"x",
|
|
615
|
-
dimension.height
|
|
616
|
-
] }) : null
|
|
617
|
-
] })
|
|
618
|
-
] });
|
|
902
|
+
/**
|
|
903
|
+
* Options for the Front Matter editor
|
|
904
|
+
*/
|
|
905
|
+
/**
|
|
906
|
+
* Handle returned by {@link createFrontMatterEditor}.
|
|
907
|
+
*/
|
|
908
|
+
/**
|
|
909
|
+
* Mount the Front Matter editor (a React component) into the given
|
|
910
|
+
* container.
|
|
911
|
+
*
|
|
912
|
+
* The field list is rendered declaratively from React state, so
|
|
913
|
+
* toggling the panel or editing other fields never rebuilds the inputs
|
|
914
|
+
* — focus, caret position and IME composition survive re-renders.
|
|
915
|
+
* @param options - Mount target and initial data
|
|
916
|
+
* @returns A handle exposing the latest data and an unmount function
|
|
917
|
+
* @example
|
|
918
|
+
* ```ts
|
|
919
|
+
* const editor = createFrontMatterEditor({
|
|
920
|
+
* container: document.querySelector('.front-matter-editor')!,
|
|
921
|
+
* initialData: { title: 'ページ' },
|
|
922
|
+
* hasFrontMatter: true,
|
|
923
|
+
* onUpdated: (data) => debouncedSave(data),
|
|
924
|
+
* });
|
|
925
|
+
* editor.getData(); // => { title: 'ページ' }
|
|
926
|
+
* ```
|
|
927
|
+
*/
|
|
928
|
+
function createFrontMatterEditor(options) {
|
|
929
|
+
const store = new FrontMatterStore(options.initialData);
|
|
930
|
+
const originalFrontMatter = options.hasFrontMatter ? JSON.stringify(options.initialData) : void 0;
|
|
931
|
+
const unsubscribe = store.subscribe(() => {
|
|
932
|
+
options.onUpdated?.(store.getData());
|
|
933
|
+
});
|
|
934
|
+
const root = createRoot(options.container);
|
|
935
|
+
root.render(/* @__PURE__ */ jsx(FrontMatterEditorView, { store }));
|
|
936
|
+
const teardown = () => {
|
|
937
|
+
unsubscribe();
|
|
938
|
+
root.unmount();
|
|
939
|
+
};
|
|
940
|
+
return {
|
|
941
|
+
getData: () => store.getData(),
|
|
942
|
+
getOriginalFrontMatter: () => originalFrontMatter,
|
|
943
|
+
unmount: teardown,
|
|
944
|
+
[Symbol.dispose]: teardown
|
|
945
|
+
};
|
|
619
946
|
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
947
|
+
/**
|
|
948
|
+
* Front Matterの動的フォーム本体。フィールド一覧は`store`(唯一の
|
|
949
|
+
* データソース)から読み、折りたたみ・追加ダイアログ・JSON下書きは
|
|
950
|
+
* この見た目だけのUI状態としてローカルに持つ。操作は Invoker Commands
|
|
951
|
+
* (`--fm-toggle` / `--fm-add-field` / `--fm-delete-field`)で受ける
|
|
952
|
+
* @param root0
|
|
953
|
+
* @param root0.store
|
|
954
|
+
* @example
|
|
955
|
+
* ```tsx
|
|
956
|
+
* <FrontMatterEditorView store={new FrontMatterStore({ title: 'ページ' })} />
|
|
957
|
+
* ```
|
|
958
|
+
*/
|
|
959
|
+
function FrontMatterEditorView({ store }) {
|
|
960
|
+
const rootId = useId();
|
|
961
|
+
const dialogId = useId();
|
|
962
|
+
const fields = useSyncExternalStore(store.subscribe, store.getSnapshot);
|
|
963
|
+
const [isCollapsed, setIsCollapsed] = useState(false);
|
|
964
|
+
const [addDialogOpen, setAddDialogOpen] = useState(false);
|
|
965
|
+
const [jsonDrafts, setJsonDrafts] = useState({});
|
|
966
|
+
const applyFields = (next) => {
|
|
967
|
+
store.setFields(next);
|
|
968
|
+
};
|
|
969
|
+
const updateFieldValue = (key, value) => {
|
|
970
|
+
applyFields(fields.map((f) => f.key === key ? {
|
|
971
|
+
...f,
|
|
972
|
+
value
|
|
973
|
+
} : f));
|
|
974
|
+
};
|
|
975
|
+
const rootRef = useCommand({
|
|
976
|
+
"--fm-toggle": () => {
|
|
977
|
+
setIsCollapsed((prev) => !prev);
|
|
978
|
+
},
|
|
979
|
+
"--fm-add-field": () => {
|
|
980
|
+
setAddDialogOpen(true);
|
|
981
|
+
},
|
|
982
|
+
"--fm-delete-field": (e) => {
|
|
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;
|
|
988
|
+
return rest;
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
});
|
|
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") ?? "");
|
|
996
|
+
const type = formData.get("type");
|
|
997
|
+
if (key_1 && !fields.some((f_1) => f_1.key === key_1)) applyFields([...fields, {
|
|
998
|
+
key: key_1,
|
|
999
|
+
type,
|
|
1000
|
+
value: getDefaultValue(type)
|
|
1001
|
+
}]);
|
|
1002
|
+
setAddDialogOpen(false);
|
|
1003
|
+
};
|
|
1004
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1005
|
+
ref: rootRef,
|
|
1006
|
+
id: rootId,
|
|
1007
|
+
className: "fm-editor",
|
|
1008
|
+
children: [
|
|
1009
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1010
|
+
className: "fm-editor-header",
|
|
1011
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
1012
|
+
type: "button",
|
|
1013
|
+
className: "fm-editor-toggle",
|
|
1014
|
+
"aria-expanded": !isCollapsed,
|
|
1015
|
+
command: "--fm-toggle",
|
|
1016
|
+
commandfor: rootId,
|
|
1017
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1018
|
+
className: "fm-editor-toggle-icon",
|
|
1019
|
+
children: isCollapsed ? "▶" : "▼"
|
|
1020
|
+
}), /* @__PURE__ */ jsx("span", { children: "Front Matter" })]
|
|
1021
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
1022
|
+
type: "button",
|
|
1023
|
+
className: "fm-editor-add",
|
|
1024
|
+
title: "フィールドを追加",
|
|
1025
|
+
command: "--fm-add-field",
|
|
1026
|
+
commandfor: rootId,
|
|
1027
|
+
children: "+ 追加"
|
|
1028
|
+
})]
|
|
1029
|
+
}),
|
|
1030
|
+
isCollapsed ? null : /* @__PURE__ */ jsx("div", {
|
|
1031
|
+
className: "fm-editor-fields",
|
|
1032
|
+
children: fields.length === 0 ? /* @__PURE__ */ jsx("div", {
|
|
1033
|
+
className: "fm-editor-empty",
|
|
1034
|
+
children: "フィールドがありません。「+ 追加」ボタンでフィールドを追加してください。"
|
|
1035
|
+
}) : fields.map((field) => /* @__PURE__ */ jsxs("div", {
|
|
1036
|
+
className: "fm-editor-field",
|
|
1037
|
+
"data-type": field.type,
|
|
1038
|
+
children: [
|
|
1039
|
+
/* @__PURE__ */ jsx("label", {
|
|
1040
|
+
className: "fm-editor-field-label",
|
|
1041
|
+
htmlFor: `${rootId}-field-${field.key}`,
|
|
1042
|
+
children: field.key
|
|
1043
|
+
}),
|
|
1044
|
+
/* @__PURE__ */ jsx("div", {
|
|
1045
|
+
className: "fm-editor-field-input",
|
|
1046
|
+
children: /* @__PURE__ */ jsx(FieldInput, {
|
|
1047
|
+
field,
|
|
1048
|
+
inputId: `${rootId}-field-${field.key}`,
|
|
1049
|
+
jsonDraft: jsonDrafts[field.key],
|
|
1050
|
+
onValueChange: (value_0) => updateFieldValue(field.key, value_0),
|
|
1051
|
+
onJsonDraftChange: (text) => {
|
|
1052
|
+
setJsonDrafts((prev_1) => ({
|
|
1053
|
+
...prev_1,
|
|
1054
|
+
[field.key]: text
|
|
1055
|
+
}));
|
|
1056
|
+
}
|
|
1057
|
+
})
|
|
1058
|
+
}),
|
|
1059
|
+
/* @__PURE__ */ jsx("button", {
|
|
1060
|
+
type: "button",
|
|
1061
|
+
className: "fm-editor-field-delete",
|
|
1062
|
+
title: "フィールドを削除",
|
|
1063
|
+
command: "--fm-delete-field",
|
|
1064
|
+
commandfor: rootId,
|
|
1065
|
+
value: field.key,
|
|
1066
|
+
children: "×"
|
|
1067
|
+
})
|
|
1068
|
+
]
|
|
1069
|
+
}, field.key))
|
|
1070
|
+
}),
|
|
1071
|
+
addDialogOpen ? /* @__PURE__ */ jsx(AddFieldDialog, {
|
|
1072
|
+
dialogId,
|
|
1073
|
+
onSubmit: onAddSubmit,
|
|
1074
|
+
onClose: () => setAddDialogOpen(false)
|
|
1075
|
+
}) : null
|
|
1076
|
+
]
|
|
1077
|
+
});
|
|
1078
|
+
}
|
|
1079
|
+
/**
|
|
1080
|
+
* 型別のcontrolled input
|
|
1081
|
+
* @param root0
|
|
1082
|
+
* @param root0.field
|
|
1083
|
+
* @param root0.inputId
|
|
1084
|
+
* @param root0.jsonDraft
|
|
1085
|
+
* @param root0.onValueChange
|
|
1086
|
+
* @param root0.onJsonDraftChange
|
|
1087
|
+
*/
|
|
1088
|
+
function FieldInput(t0) {
|
|
1089
|
+
const $ = c(37);
|
|
1090
|
+
const { field, inputId, jsonDraft, onValueChange, onJsonDraftChange } = t0;
|
|
1091
|
+
switch (field.type) {
|
|
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
|
+
}
|
|
1168
|
+
case "json": {
|
|
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;
|
|
1182
|
+
onJsonDraftChange(nextText);
|
|
1183
|
+
try {
|
|
1184
|
+
onValueChange(JSON.parse(nextText));
|
|
1185
|
+
} catch {}
|
|
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;
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
/**
|
|
1234
|
+
* フィールド追加ダイアログ。マウント時にshowModalし、close(キャンセル
|
|
1235
|
+
* ボタンの組み込みcloseコマンド / Escキー)でアンマウントされる
|
|
1236
|
+
* @param root0
|
|
1237
|
+
* @param root0.dialogId
|
|
1238
|
+
* @param root0.onSubmit
|
|
1239
|
+
* @param root0.onClose
|
|
1240
|
+
*/
|
|
1241
|
+
function AddFieldDialog(t0) {
|
|
1242
|
+
const $ = c(36);
|
|
1243
|
+
const { dialogId, onSubmit, onClose } = t0;
|
|
1244
|
+
const dialogRef = useRef(null);
|
|
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", {
|
|
1406
|
+
onSubmit,
|
|
1407
|
+
children: [
|
|
1408
|
+
t3,
|
|
1409
|
+
t8,
|
|
1410
|
+
t18,
|
|
1411
|
+
t21
|
|
1412
|
+
]
|
|
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;
|
|
1435
|
+
}
|
|
1436
|
+
/**
|
|
1437
|
+
* Parse initial data and detect field types
|
|
1438
|
+
* @param data
|
|
1439
|
+
*/
|
|
1440
|
+
function parseInitialData(data) {
|
|
1441
|
+
return Object.entries(data).map(([key, value]) => ({
|
|
1442
|
+
key,
|
|
1443
|
+
type: detectType(value),
|
|
1444
|
+
value
|
|
1445
|
+
}));
|
|
1446
|
+
}
|
|
1447
|
+
/**
|
|
1448
|
+
* フィールド一覧をFront Matterデータへ畳み込む
|
|
1449
|
+
* @param fields
|
|
1450
|
+
*/
|
|
1451
|
+
function toData(fields) {
|
|
1452
|
+
const data = {};
|
|
1453
|
+
for (const field of fields) data[field.key] = field.value;
|
|
1454
|
+
return data;
|
|
1455
|
+
}
|
|
1456
|
+
/**
|
|
1457
|
+
* Detect the type of a value
|
|
1458
|
+
* @param value
|
|
1459
|
+
*/
|
|
1460
|
+
function detectType(value) {
|
|
1461
|
+
if (typeof value === "boolean") return "boolean";
|
|
1462
|
+
if (typeof value === "number") return "number";
|
|
1463
|
+
if (typeof value === "string") {
|
|
1464
|
+
if (/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2})?/.test(value)) {
|
|
1465
|
+
const parsed = Date.parse(value);
|
|
1466
|
+
if (!Number.isNaN(parsed)) return "date";
|
|
1467
|
+
}
|
|
1468
|
+
return "text";
|
|
1469
|
+
}
|
|
1470
|
+
if (value instanceof Date) return "date";
|
|
1471
|
+
if (typeof value === "object" && value !== null) return "json";
|
|
1472
|
+
return "text";
|
|
1473
|
+
}
|
|
1474
|
+
/**
|
|
1475
|
+
* Get default value for a type
|
|
1476
|
+
* @param type
|
|
1477
|
+
*/
|
|
1478
|
+
function getDefaultValue(type) {
|
|
1479
|
+
switch (type) {
|
|
1480
|
+
case "boolean": return false;
|
|
1481
|
+
case "number": return 0;
|
|
1482
|
+
case "date": return (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
1483
|
+
case "json": return [];
|
|
1484
|
+
default: return "";
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
/**
|
|
1488
|
+
* `<input type="date">` に渡せる `yyyy-mm-dd` へ正規化する。
|
|
1489
|
+
* 不正な日付は空文字(未入力)にする
|
|
1490
|
+
* @param value
|
|
1491
|
+
*/
|
|
1492
|
+
function toDateInputValue(value) {
|
|
1493
|
+
if (!value) return "";
|
|
1494
|
+
const dateValue = value instanceof Date ? value : new Date(String(value));
|
|
1495
|
+
if (Number.isNaN(dateValue.getTime())) return "";
|
|
1496
|
+
return dateValue.toISOString().split("T")[0] ?? "";
|
|
1497
|
+
}
|
|
1498
|
+
/**
|
|
1499
|
+
* @param value
|
|
1500
|
+
*/
|
|
1501
|
+
function stringifyJson(value) {
|
|
1502
|
+
try {
|
|
1503
|
+
return JSON.stringify(value, null, 2);
|
|
1504
|
+
} catch {
|
|
1505
|
+
return String(value);
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
/**
|
|
1509
|
+
* @param text
|
|
1510
|
+
*/
|
|
1511
|
+
function isValidJson(text) {
|
|
1512
|
+
try {
|
|
1513
|
+
JSON.parse(text);
|
|
1514
|
+
return true;
|
|
1515
|
+
} catch {
|
|
1516
|
+
return false;
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
var preview_module_default = {
|
|
1520
|
+
img: "_img_18j28_1",
|
|
1521
|
+
uploading: "_uploading_18j28_26",
|
|
1522
|
+
progress: "_progress_18j28_30",
|
|
1523
|
+
meta: "_meta_18j28_40",
|
|
1524
|
+
path: "_path_18j28_60",
|
|
1525
|
+
upload: "_upload_18j28_26",
|
|
1526
|
+
dimension: "_dimension_18j28_72"
|
|
628
1527
|
};
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
1528
|
+
//#endregion
|
|
1529
|
+
//#region src/components/preview.tsx
|
|
1530
|
+
/**
|
|
1531
|
+
* File preview pane. The previewed path comes from the parent (lifted
|
|
1532
|
+
* from the item's own state); upload progress is read from the engine's
|
|
1533
|
+
* `FileBrowserStore`, shared with `FileList`/`FileUploader`.
|
|
1534
|
+
* @param root0
|
|
1535
|
+
* @param root0.path
|
|
1536
|
+
* @example
|
|
1537
|
+
* ```tsx
|
|
1538
|
+
* <Preview path={state.path ?? ''} />
|
|
1539
|
+
* ```
|
|
1540
|
+
*/
|
|
1541
|
+
function Preview(t0) {
|
|
1542
|
+
const $ = c(36);
|
|
1543
|
+
const { path } = t0;
|
|
1544
|
+
const store = useFileBrowser();
|
|
1545
|
+
const [dimension, setDimension] = useState(null);
|
|
1546
|
+
const [prevPath, setPrevPath] = useState(path);
|
|
1547
|
+
if (prevPath !== path) {
|
|
1548
|
+
setPrevPath(path);
|
|
1549
|
+
setDimension(null);
|
|
1550
|
+
}
|
|
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
|
+
};
|
|
1611
|
+
};
|
|
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", {
|
|
1631
|
+
src: path,
|
|
1632
|
+
alt: "画像プレビュー"
|
|
1633
|
+
}) : file?.isVideo ? /* @__PURE__ */ jsxs("video", {
|
|
1634
|
+
controls: true,
|
|
1635
|
+
playsInline: true,
|
|
1636
|
+
children: [/* @__PURE__ */ jsx("source", {
|
|
1637
|
+
src: path,
|
|
1638
|
+
type: `video/${file.ext}`
|
|
1639
|
+
}), /* @__PURE__ */ jsx("track", {
|
|
1640
|
+
kind: "captions",
|
|
1641
|
+
src: ""
|
|
1642
|
+
})]
|
|
1643
|
+
}) : file?.isAudio ? /* @__PURE__ */ jsxs("audio", {
|
|
1644
|
+
controls: true,
|
|
1645
|
+
children: [/* @__PURE__ */ jsx("source", {
|
|
1646
|
+
src: path,
|
|
1647
|
+
type: `audio/${file.ext}`
|
|
1648
|
+
}), /* @__PURE__ */ jsx("track", {
|
|
1649
|
+
kind: "metadata",
|
|
1650
|
+
src: ""
|
|
1651
|
+
})]
|
|
1652
|
+
}) : file?.isDoc || file?.isPpt || file?.isXls || file?.isPdf ? /* @__PURE__ */ jsx("object", {
|
|
1653
|
+
data: path,
|
|
1654
|
+
type: `application/${file.ext}`,
|
|
1655
|
+
title: `${file.ext}ファイルのプレビュー`,
|
|
1656
|
+
children: /* @__PURE__ */ jsx("p", { children: "プレビューできません" })
|
|
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,
|
|
1666
|
+
style: { translate: `${progress.uploaded / progress.total * 100}%` }
|
|
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,
|
|
1687
|
+
children: [/* @__PURE__ */ jsx("span", { children: "アップロード..." }), /* @__PURE__ */ jsxs("span", {
|
|
1688
|
+
className: preview_module_default.progress,
|
|
1689
|
+
children: [
|
|
1690
|
+
Math.round(progress.uploaded / progress.total * 100),
|
|
1691
|
+
"% (",
|
|
1692
|
+
progress.uploaded,
|
|
1693
|
+
"/",
|
|
1694
|
+
progress.total,
|
|
1695
|
+
")"
|
|
1696
|
+
]
|
|
1697
|
+
})]
|
|
1698
|
+
}) : /* @__PURE__ */ jsx("li", {
|
|
1699
|
+
className: preview_module_default.path,
|
|
1700
|
+
children: /* @__PURE__ */ jsx("a", {
|
|
1701
|
+
href: path,
|
|
1702
|
+
target: "_blank",
|
|
1703
|
+
children: path
|
|
1704
|
+
})
|
|
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,
|
|
1715
|
+
children: [
|
|
1716
|
+
dimension.width,
|
|
1717
|
+
"x",
|
|
1718
|
+
dimension.height
|
|
1719
|
+
]
|
|
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;
|
|
726
1742
|
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
1743
|
+
var table_editor_module_default = {
|
|
1744
|
+
table: "_table_1qb61_1",
|
|
1745
|
+
row: "_row_1qb61_7",
|
|
1746
|
+
btn: "_btn_1qb61_19"
|
|
731
1747
|
};
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
1748
|
+
//#endregion
|
|
1749
|
+
//#region src/components/table-editor.tsx
|
|
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
|
+
/**
|
|
1756
|
+
* Table row editor as a fully controlled component. The table item's
|
|
1757
|
+
* editor owns the state; row operations are declared as local commands.
|
|
1758
|
+
* @param root0
|
|
1759
|
+
* @param root0.value
|
|
1760
|
+
* @param root0.onChange
|
|
1761
|
+
* @example
|
|
1762
|
+
* ```tsx
|
|
1763
|
+
* <TableEditor
|
|
1764
|
+
* value={{ th: state.th ?? [], td: state.td ?? [] }}
|
|
1765
|
+
* onChange={({ th, td }) => setState({ ...state, th: [...th], td: [...td] })}
|
|
1766
|
+
* />
|
|
1767
|
+
* ```
|
|
1768
|
+
*/
|
|
1769
|
+
function TableEditor(t0) {
|
|
1770
|
+
const $ = c(12);
|
|
1771
|
+
const { value, onChange } = t0;
|
|
1772
|
+
const rootId = useId();
|
|
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] ?? ""
|
|
1786
|
+
});
|
|
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;
|
|
1805
|
+
const rootRef = useCommand({
|
|
1806
|
+
"--add-row": (e) => {
|
|
1807
|
+
const index = Number(e.source?.value);
|
|
1808
|
+
commit(rows.toSpliced(index + 1, 0, {
|
|
1809
|
+
id: crypto.randomUUID(),
|
|
1810
|
+
th: "",
|
|
1811
|
+
td: ""
|
|
1812
|
+
}));
|
|
1813
|
+
},
|
|
1814
|
+
"--remove-row": (e_0) => {
|
|
1815
|
+
const index_0 = Number(e_0.source?.value);
|
|
1816
|
+
commit(rows.toSpliced(index_0, 1));
|
|
1817
|
+
},
|
|
1818
|
+
"--move-row-down": (e_1) => {
|
|
1819
|
+
const from = Number(e_1.source?.value);
|
|
1820
|
+
const to = from + 1;
|
|
1821
|
+
const fromRow = rows[from];
|
|
1822
|
+
const toRow = rows[to];
|
|
1823
|
+
if (!fromRow || !toRow) return;
|
|
1824
|
+
commit(rows.toSpliced(from, 1, toRow).toSpliced(to, 1, fromRow));
|
|
1825
|
+
}
|
|
1826
|
+
});
|
|
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,
|
|
1832
|
+
children: [
|
|
1833
|
+
/* @__PURE__ */ jsx("div", {
|
|
1834
|
+
className: table_editor_module_default.th,
|
|
1835
|
+
children: /* @__PURE__ */ jsx("textarea", {
|
|
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
|
+
}));
|
|
1845
|
+
}
|
|
1846
|
+
})
|
|
1847
|
+
}),
|
|
1848
|
+
/* @__PURE__ */ jsx("div", {
|
|
1849
|
+
className: table_editor_module_default.td,
|
|
1850
|
+
children: /* @__PURE__ */ jsx("textarea", {
|
|
1851
|
+
"aria-label": `${i_0}行目の内容セル`,
|
|
1852
|
+
name: `bge-td-${i_0}`,
|
|
1853
|
+
value: td,
|
|
1854
|
+
onChange: (e_3) => {
|
|
1855
|
+
commit(rows.with(i_0, {
|
|
1856
|
+
id,
|
|
1857
|
+
th: th_0,
|
|
1858
|
+
td: e_3.currentTarget.value
|
|
1859
|
+
}));
|
|
1860
|
+
}
|
|
1861
|
+
})
|
|
1862
|
+
}),
|
|
1863
|
+
/* @__PURE__ */ jsx("div", {
|
|
1864
|
+
className: table_editor_module_default.btn,
|
|
1865
|
+
children: /* @__PURE__ */ jsxs("ul", { children: [
|
|
1866
|
+
/* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("button", {
|
|
1867
|
+
type: "button",
|
|
1868
|
+
title: "下に追加",
|
|
1869
|
+
command: "--add-row",
|
|
1870
|
+
commandfor: rootId,
|
|
1871
|
+
value: i_0,
|
|
1872
|
+
children: /* @__PURE__ */ jsx(IconRowInsertBottom, {})
|
|
1873
|
+
}) }),
|
|
1874
|
+
/* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("button", {
|
|
1875
|
+
type: "button",
|
|
1876
|
+
title: "削除",
|
|
1877
|
+
disabled: rows.length === 1,
|
|
1878
|
+
command: "--remove-row",
|
|
1879
|
+
commandfor: rootId,
|
|
1880
|
+
value: i_0,
|
|
1881
|
+
children: /* @__PURE__ */ jsx(IconTrash, {})
|
|
1882
|
+
}) }),
|
|
1883
|
+
/* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("button", {
|
|
1884
|
+
type: "button",
|
|
1885
|
+
title: "下に移動",
|
|
1886
|
+
disabled: i_0 === rows.length - 1,
|
|
1887
|
+
command: "--move-row-down",
|
|
1888
|
+
commandfor: rootId,
|
|
1889
|
+
value: i_0,
|
|
1890
|
+
children: /* @__PURE__ */ jsx(IconArrowsTransferDown, { className: "icon" })
|
|
1891
|
+
}) })
|
|
1892
|
+
] })
|
|
1893
|
+
})
|
|
1894
|
+
]
|
|
1895
|
+
}, id);
|
|
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;
|
|
778
1912
|
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
value,
|
|
782
|
-
onChange,
|
|
783
|
-
itemName,
|
|
784
|
-
commands,
|
|
785
|
-
label
|
|
786
|
-
}) {
|
|
787
|
-
const ref = useRef(null);
|
|
788
|
-
const initialValue = useRef(value);
|
|
789
|
-
const onChangeRef = useRef(onChange);
|
|
790
|
-
useEffect(() => {
|
|
791
|
-
onChangeRef.current = onChange;
|
|
792
|
-
});
|
|
793
|
-
useEffect(() => {
|
|
794
|
-
const el = ref.current;
|
|
795
|
-
if (!el) {
|
|
796
|
-
return;
|
|
797
|
-
}
|
|
798
|
-
el.innerHTML = initialValue.current;
|
|
799
|
-
const inner = el.querySelector("bge-wysiwyg");
|
|
800
|
-
const onTransaction = () => {
|
|
801
|
-
onChangeRef.current(el.value);
|
|
802
|
-
};
|
|
803
|
-
inner?.addEventListener("transaction", onTransaction);
|
|
804
|
-
return () => {
|
|
805
|
-
inner?.removeEventListener("transaction", onTransaction);
|
|
806
|
-
};
|
|
807
|
-
}, []);
|
|
808
|
-
return /* @__PURE__ */ jsx(
|
|
809
|
-
"bge-wysiwyg-editor",
|
|
810
|
-
{
|
|
811
|
-
ref: (el) => {
|
|
812
|
-
ref.current = el;
|
|
813
|
-
},
|
|
814
|
-
"item-name": itemName,
|
|
815
|
-
commands,
|
|
816
|
-
label
|
|
817
|
-
}
|
|
818
|
-
);
|
|
1913
|
+
function _temp4(row_1) {
|
|
1914
|
+
return row_1.td;
|
|
819
1915
|
}
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
label,
|
|
823
|
-
checked,
|
|
824
|
-
onChange,
|
|
825
|
-
name,
|
|
826
|
-
disabled,
|
|
827
|
-
describedBy
|
|
828
|
-
}) {
|
|
829
|
-
return /* @__PURE__ */ jsxs("label", { children: [
|
|
830
|
-
/* @__PURE__ */ jsx(
|
|
831
|
-
"input",
|
|
832
|
-
{
|
|
833
|
-
type: "checkbox",
|
|
834
|
-
name,
|
|
835
|
-
checked,
|
|
836
|
-
disabled,
|
|
837
|
-
"aria-describedby": describedBy,
|
|
838
|
-
onChange: (e) => onChange(e.currentTarget.checked)
|
|
839
|
-
}
|
|
840
|
-
),
|
|
841
|
-
label
|
|
842
|
-
] });
|
|
1916
|
+
function _temp3(row_0) {
|
|
1917
|
+
return row_0.th;
|
|
843
1918
|
}
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
legend,
|
|
847
|
-
id,
|
|
848
|
-
disabled,
|
|
849
|
-
children
|
|
850
|
-
}) {
|
|
851
|
-
return /* @__PURE__ */ jsxs("fieldset", { id, disabled, children: [
|
|
852
|
-
/* @__PURE__ */ jsx("legend", { children: legend }),
|
|
853
|
-
children
|
|
854
|
-
] });
|
|
1919
|
+
function _temp2(row) {
|
|
1920
|
+
return row.id;
|
|
855
1921
|
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
label,
|
|
859
|
-
value,
|
|
860
|
-
onChange,
|
|
861
|
-
name,
|
|
862
|
-
min,
|
|
863
|
-
max,
|
|
864
|
-
step,
|
|
865
|
-
disabled
|
|
866
|
-
}) {
|
|
867
|
-
return /* @__PURE__ */ jsxs("label", { children: [
|
|
868
|
-
/* @__PURE__ */ jsx("span", { children: label }),
|
|
869
|
-
/* @__PURE__ */ jsx(
|
|
870
|
-
"input",
|
|
871
|
-
{
|
|
872
|
-
type: "number",
|
|
873
|
-
name,
|
|
874
|
-
value: Number.isFinite(value) ? value : "",
|
|
875
|
-
min,
|
|
876
|
-
max,
|
|
877
|
-
step,
|
|
878
|
-
disabled,
|
|
879
|
-
onChange: (e) => onChange(e.currentTarget.valueAsNumber)
|
|
880
|
-
}
|
|
881
|
-
)
|
|
882
|
-
] });
|
|
1922
|
+
function _temp$1() {
|
|
1923
|
+
return crypto.randomUUID();
|
|
883
1924
|
}
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
1925
|
+
var tabs_module_default = { tablist: "_tablist_1hyld_1" };
|
|
1926
|
+
//#endregion
|
|
1927
|
+
//#region src/components/tabs.tsx
|
|
1928
|
+
/**
|
|
1929
|
+
* Controlled tab list. Selection is lifted to the parent via
|
|
1930
|
+
* `current`/`onChange`; tab buttons declare a local command instead of a
|
|
1931
|
+
* click handler. Arrow keys move the selection. The tab panel itself is
|
|
1932
|
+
* rendered by the parent, which also owns its `aria-label`.
|
|
1933
|
+
* @param root0
|
|
1934
|
+
* @param root0.current
|
|
1935
|
+
* @param root0.onChange
|
|
1936
|
+
* @param root0.contentId
|
|
1937
|
+
* @param root0.length
|
|
1938
|
+
* @param root0.createLabel
|
|
1939
|
+
* @example
|
|
1940
|
+
* ```tsx
|
|
1941
|
+
* <Tabs current={currentIndex} onChange={setCurrentIndex} contentId="tab-content" />
|
|
1942
|
+
* <div id="tab-content" role="tabpanel" aria-label={`画像${currentIndex + 1}`}>
|
|
1943
|
+
* {currentIndex === 0 ? <PcForm /> : <SpForm />}
|
|
1944
|
+
* </div>
|
|
1945
|
+
* ```
|
|
1946
|
+
*/
|
|
1947
|
+
function Tabs({ current, onChange, contentId, length = 2, createLabel = (index) => `画像${index + 1}` }) {
|
|
1948
|
+
const listId = useId();
|
|
1949
|
+
const refs = useRef([]);
|
|
1950
|
+
const update = (index_0) => {
|
|
1951
|
+
refs.current[index_0]?.focus();
|
|
1952
|
+
onChange(index_0);
|
|
1953
|
+
};
|
|
1954
|
+
const rootRef = useCommand({ "--select-tab": (e) => {
|
|
1955
|
+
const value = e.source?.value;
|
|
1956
|
+
update(Number(value));
|
|
1957
|
+
} });
|
|
1958
|
+
const onKeyDown = (event) => {
|
|
1959
|
+
if (event.key === "ArrowLeft") update(Math.max(0, current - 1));
|
|
1960
|
+
else if (event.key === "ArrowRight") update(Math.min(length - 1, current + 1));
|
|
1961
|
+
};
|
|
1962
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1963
|
+
role: "tablist",
|
|
1964
|
+
ref: rootRef,
|
|
1965
|
+
id: listId,
|
|
1966
|
+
className: tabs_module_default["tablist"],
|
|
1967
|
+
children: Array.from({ length }, (_, index_1) => /* @__PURE__ */ jsx("button", {
|
|
1968
|
+
ref: (el) => {
|
|
1969
|
+
refs.current[index_1] = el;
|
|
1970
|
+
},
|
|
1971
|
+
type: "button",
|
|
1972
|
+
role: "tab",
|
|
1973
|
+
"aria-controls": contentId,
|
|
1974
|
+
"aria-selected": current === index_1,
|
|
1975
|
+
tabIndex: current === index_1 ? 0 : -1,
|
|
1976
|
+
command: "--select-tab",
|
|
1977
|
+
commandfor: listId,
|
|
1978
|
+
value: index_1,
|
|
1979
|
+
onKeyDown,
|
|
1980
|
+
children: createLabel(index_1)
|
|
1981
|
+
}, index_1))
|
|
1982
|
+
});
|
|
915
1983
|
}
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
1984
|
+
//#endregion
|
|
1985
|
+
//#region src/components/wysiwyg-field.tsx
|
|
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);
|
|
938
2010
|
}
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
2011
|
+
/**
|
|
2012
|
+
* Rich text field backed by the `<bge-wysiwyg-editor>` custom element
|
|
2013
|
+
* (TipTap). The element manages its own DOM; this wrapper feeds the
|
|
2014
|
+
* initial value and lifts edits into the editor state via the
|
|
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).
|
|
2025
|
+
* @param root0
|
|
2026
|
+
* @param root0.value
|
|
2027
|
+
* @param root0.onChange
|
|
2028
|
+
* @param root0.itemName
|
|
2029
|
+
* @param root0.commands
|
|
2030
|
+
* @param root0.label
|
|
2031
|
+
* @example
|
|
2032
|
+
* ```tsx
|
|
2033
|
+
* <WysiwygField
|
|
2034
|
+
* itemName="wysiwyg"
|
|
2035
|
+
* value={state.wysiwyg ?? ''}
|
|
2036
|
+
* onChange={(wysiwyg) => setState({ ...state, wysiwyg })}
|
|
2037
|
+
* />
|
|
2038
|
+
* ```
|
|
2039
|
+
*/
|
|
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);
|
|
2052
|
+
const ref = useRef(null);
|
|
2053
|
+
const initialValue = useRef(value);
|
|
2054
|
+
let t2;
|
|
2055
|
+
if ($[2] !== onChange) {
|
|
2056
|
+
t2 = (el) => {
|
|
2057
|
+
onChange(el.value);
|
|
2058
|
+
};
|
|
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
|
+
};
|
|
2074
|
+
};
|
|
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;
|
|
961
2107
|
}
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
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);
|
|
2218
|
+
}
|
|
2219
|
+
//#endregion
|
|
2220
|
+
//#region src/form/checkbox.tsx
|
|
2221
|
+
/**
|
|
2222
|
+
* Controlled checkbox following the editor form markup convention
|
|
2223
|
+
* (`label > input + text`).
|
|
2224
|
+
*
|
|
2225
|
+
* The structure is a styling contract: `ui.css` turns
|
|
2226
|
+
* `label:not([for]):has(input[type='checkbox'])` into a flex row, so it
|
|
2227
|
+
* must be preserved.
|
|
2228
|
+
* @param root0
|
|
2229
|
+
* @param root0.label
|
|
2230
|
+
* @param root0.checked
|
|
2231
|
+
* @param root0.onChange
|
|
2232
|
+
* @param root0.name
|
|
2233
|
+
* @param root0.disabled
|
|
2234
|
+
* @param root0.describedBy
|
|
2235
|
+
* @example
|
|
2236
|
+
* ```tsx
|
|
2237
|
+
* <Checkbox
|
|
2238
|
+
* label={<span>横スクロール可能</span>}
|
|
2239
|
+
* name="bge-scrollable"
|
|
2240
|
+
* checked={state.scrollable ?? false}
|
|
2241
|
+
* onChange={(scrollable) => setState({ ...state, scrollable })}
|
|
2242
|
+
* />
|
|
2243
|
+
* ```
|
|
2244
|
+
*/
|
|
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;
|
|
2279
|
+
}
|
|
2280
|
+
//#endregion
|
|
2281
|
+
//#region src/form/fieldset.tsx
|
|
2282
|
+
/**
|
|
2283
|
+
* Grouping fieldset following the editor form markup convention
|
|
2284
|
+
* (`fieldset > legend`).
|
|
2285
|
+
*
|
|
2286
|
+
* The structure is a styling contract: `ui.css` draws the group border
|
|
2287
|
+
* and spacing on the `fieldset` element itself, so it must be preserved.
|
|
2288
|
+
* @param root0
|
|
2289
|
+
* @param root0.legend
|
|
2290
|
+
* @param root0.id
|
|
2291
|
+
* @param root0.disabled
|
|
2292
|
+
* @param root0.children
|
|
2293
|
+
* @example
|
|
2294
|
+
* ```tsx
|
|
2295
|
+
* <Fieldset legend="リンク設定" disabled={!state.useLink}>
|
|
2296
|
+
* <TextField
|
|
2297
|
+
* label="URL"
|
|
2298
|
+
* name="bge-href"
|
|
2299
|
+
* value={state.href ?? ''}
|
|
2300
|
+
* onChange={(href) => setState({ ...state, href })}
|
|
2301
|
+
* />
|
|
2302
|
+
* </Fieldset>
|
|
2303
|
+
* ```
|
|
2304
|
+
*/
|
|
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;
|
|
2328
|
+
}
|
|
2329
|
+
//#endregion
|
|
2330
|
+
//#region src/form/number-field.tsx
|
|
2331
|
+
/**
|
|
2332
|
+
* Controlled numeric input following the editor form markup convention.
|
|
2333
|
+
*
|
|
2334
|
+
* The `label > span + input` structure is a styling contract: `ui.css`
|
|
2335
|
+
* lays out fields with structural selectors
|
|
2336
|
+
* (`label:not([for]) > span:has(+ input)`), so it must be preserved.
|
|
2337
|
+
* @param root0
|
|
2338
|
+
* @param root0.label
|
|
2339
|
+
* @param root0.value
|
|
2340
|
+
* @param root0.onChange
|
|
2341
|
+
* @param root0.name
|
|
2342
|
+
* @param root0.min
|
|
2343
|
+
* @param root0.max
|
|
2344
|
+
* @param root0.step
|
|
2345
|
+
* @param root0.disabled
|
|
2346
|
+
* @example
|
|
2347
|
+
* ```tsx
|
|
2348
|
+
* <NumberField
|
|
2349
|
+
* label="表示件数"
|
|
2350
|
+
* name="bge-count"
|
|
2351
|
+
* value={state.count ?? 1}
|
|
2352
|
+
* min={1}
|
|
2353
|
+
* onChange={(count) => setState({ ...state, count })}
|
|
2354
|
+
* />
|
|
2355
|
+
* ```
|
|
2356
|
+
*/
|
|
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;
|
|
2402
|
+
}
|
|
2403
|
+
//#endregion
|
|
2404
|
+
//#region src/form/radio-group.tsx
|
|
2405
|
+
/**
|
|
2406
|
+
* Controlled radio group following the editor form markup convention
|
|
2407
|
+
* (`div[role=radiogroup] > label > input + text`).
|
|
2408
|
+
*
|
|
2409
|
+
* The structure is a styling contract: `ui.css` lays out the group via
|
|
2410
|
+
* `[role='radiogroup'] > label` (and appends `:` to the group label), so
|
|
2411
|
+
* it must be preserved.
|
|
2412
|
+
* @param root0
|
|
2413
|
+
* @param root0.label
|
|
2414
|
+
* @param root0.value
|
|
2415
|
+
* @param root0.onChange
|
|
2416
|
+
* @param root0.options
|
|
2417
|
+
* @param root0.name
|
|
2418
|
+
* @param root0.disabled
|
|
2419
|
+
* @example
|
|
2420
|
+
* ```tsx
|
|
2421
|
+
* <RadioGroup
|
|
2422
|
+
* label="配置"
|
|
2423
|
+
* name="bge-align"
|
|
2424
|
+
* value={state.align ?? 'start'}
|
|
2425
|
+
* options={[
|
|
2426
|
+
* { value: 'start', label: '左寄せ' },
|
|
2427
|
+
* { value: 'end', label: '右寄せ' },
|
|
2428
|
+
* ]}
|
|
2429
|
+
* onChange={(align) => setState({ ...state, align })}
|
|
2430
|
+
* />
|
|
2431
|
+
* ```
|
|
2432
|
+
*/
|
|
2433
|
+
function RadioGroup(t0) {
|
|
2434
|
+
const $ = c(18);
|
|
2435
|
+
const { label, value, onChange, options, name, disabled } = t0;
|
|
2436
|
+
const labelId = useId();
|
|
2437
|
+
let t1;
|
|
2438
|
+
if ($[0] !== label || $[1] !== labelId) {
|
|
2439
|
+
t1 = /* @__PURE__ */ jsx("div", {
|
|
2440
|
+
id: labelId,
|
|
2441
|
+
children: label
|
|
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;
|
|
2488
|
+
}
|
|
2489
|
+
//#endregion
|
|
2490
|
+
//#region src/form/select-field.tsx
|
|
2491
|
+
/**
|
|
2492
|
+
* Controlled select following the editor form markup convention
|
|
2493
|
+
* (`label > span + select`).
|
|
2494
|
+
*
|
|
2495
|
+
* The structure is a styling contract: `ui.css` lays out fields with
|
|
2496
|
+
* structural selectors (`label:not([for]) > span:has(+ select)`), so it
|
|
2497
|
+
* must be preserved.
|
|
2498
|
+
* @param root0
|
|
2499
|
+
* @param root0.label
|
|
2500
|
+
* @param root0.value
|
|
2501
|
+
* @param root0.onChange
|
|
2502
|
+
* @param root0.options
|
|
2503
|
+
* @param root0.name
|
|
2504
|
+
* @param root0.disabled
|
|
2505
|
+
* @example
|
|
2506
|
+
* ```tsx
|
|
2507
|
+
* <SelectField
|
|
2508
|
+
* label="種類"
|
|
2509
|
+
* name="bge-kind"
|
|
2510
|
+
* value={state.kind ?? 'normal'}
|
|
2511
|
+
* options={[
|
|
2512
|
+
* { value: 'normal', label: '通常' },
|
|
2513
|
+
* { value: 'wide', label: 'ワイド' },
|
|
2514
|
+
* ]}
|
|
2515
|
+
* onChange={(kind) => setState({ ...state, kind })}
|
|
2516
|
+
* />
|
|
2517
|
+
* ```
|
|
2518
|
+
*/
|
|
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);
|
|
2570
|
+
}
|
|
2571
|
+
//#endregion
|
|
2572
|
+
//#region src/form/text-area.tsx
|
|
2573
|
+
/**
|
|
2574
|
+
* Controlled multi-line text input following the editor form markup
|
|
2575
|
+
* convention.
|
|
2576
|
+
*
|
|
2577
|
+
* The `label > span + textarea` structure is a styling contract: `ui.css`
|
|
2578
|
+
* lays out fields with structural selectors
|
|
2579
|
+
* (`label:not([for]) > span:has(+ textarea)`), so it must be preserved.
|
|
2580
|
+
* @param root0
|
|
2581
|
+
* @param root0.label
|
|
2582
|
+
* @param root0.value
|
|
2583
|
+
* @param root0.onChange
|
|
2584
|
+
* @param root0.name
|
|
2585
|
+
* @param root0.rows
|
|
2586
|
+
* @param root0.disabled
|
|
2587
|
+
* @example
|
|
2588
|
+
* ```tsx
|
|
2589
|
+
* <TextArea
|
|
2590
|
+
* label="説明文"
|
|
2591
|
+
* name="bge-text"
|
|
2592
|
+
* value={state.text ?? ''}
|
|
2593
|
+
* onChange={(text) => setState({ ...state, text })}
|
|
2594
|
+
* />
|
|
2595
|
+
* ```
|
|
2596
|
+
*/
|
|
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;
|
|
2636
|
+
}
|
|
2637
|
+
//#endregion
|
|
2638
|
+
//#region src/form/text-field.tsx
|
|
2639
|
+
/**
|
|
2640
|
+
* Controlled single-line text input following the editor form markup
|
|
2641
|
+
* convention (`label > span + input`).
|
|
2642
|
+
*
|
|
2643
|
+
* The structure is a styling contract: `ui.css` lays out fields with
|
|
2644
|
+
* structural selectors (`label:not([for]) > span:has(+ input)`) instead
|
|
2645
|
+
* of `for`/`id` wiring, so it must be preserved.
|
|
2646
|
+
* @param root0
|
|
2647
|
+
* @param root0.label
|
|
2648
|
+
* @param root0.value
|
|
2649
|
+
* @param root0.onChange
|
|
2650
|
+
* @param root0.type
|
|
2651
|
+
* @param root0.name
|
|
2652
|
+
* @param root0.disabled
|
|
2653
|
+
* @param root0.placeholder
|
|
2654
|
+
* @param root0.describedBy
|
|
2655
|
+
* @example
|
|
2656
|
+
* ```tsx
|
|
2657
|
+
* <TextField
|
|
2658
|
+
* label="URL"
|
|
2659
|
+
* name="bge-link"
|
|
2660
|
+
* value={state.href ?? ''}
|
|
2661
|
+
* onChange={(href) => setState({ ...state, href })}
|
|
2662
|
+
* />
|
|
2663
|
+
* ```
|
|
2664
|
+
*/
|
|
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;
|
|
986
2709
|
}
|
|
2710
|
+
//#endregion
|
|
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 };
|
|
987
2712
|
|
|
988
|
-
|
|
989
|
-
//# sourceMappingURL=ui.js.map
|
|
2713
|
+
//# sourceMappingURL=ui.js.map
|