@kubohiroya/turbowarp-extension-data-editor 0.2.1 → 0.2.2
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 +2 -2
- package/dist/build-info.json +4 -4
- package/dist/react.css +126 -0
- package/dist/react.d.ts +5 -0
- package/dist/react.js +10 -2
- package/dist/rjsf-templates.d.ts +11 -0
- package/dist/rjsf-templates.js +129 -0
- package/dist/rjsf.js +13 -1
- package/dist/turbowarp/bridge.js +3 -0
- package/dist/webpack4/metafile.json +39 -15
- package/dist/webpack4/react.js +12 -6
- package/dist/webpack4/react.js.map +2 -2
- package/dist/webpack4/rjsf.js +205 -30
- package/dist/webpack4/rjsf.js.map +4 -4
- package/dist/webpack4/turbowarp.js +3 -0
- package/dist/webpack4/turbowarp.js.map +2 -2
- package/docs/api.md +7 -0
- package/docs/package-distribution.md +5 -0
- package/package.json +1 -7
package/README.md
CHANGED
|
@@ -103,10 +103,10 @@ pnpm test
|
|
|
103
103
|
`pnpm test` は型宣言を含むビルド後、コアと標準フォームのテストを実行します。
|
|
104
104
|
パッケージは ESM です。ブラウザには ES2022 の組み込み API が必要です。
|
|
105
105
|
標準フォームの React / ReactDOM peer は 16.14 / 17 / 18。GUI は既存の 16.14 を共有します。
|
|
106
|
-
初回の実験版は `@kubohiroya/turbowarp-extension-data-editor@0.1.0` です。固定SchemaのSource/Form編集は `0.2.0
|
|
106
|
+
初回の実験版は `@kubohiroya/turbowarp-extension-data-editor@0.1.0` です。固定SchemaのSource/Form編集は `0.2.0`、既定OFFの固定入力契約・標準field transaction・固定フォームとGUI接続は `0.2.1` で追加しました。配布版 `0.2.2` は、編集見出しのブロック名・アイコン、項目の削除メニュー・追加ボタン、key-valueの2行表示を含みます。
|
|
107
107
|
|
|
108
108
|
```sh
|
|
109
|
-
npm install --save-exact @kubohiroya/turbowarp-extension-data-editor@0.2.
|
|
109
|
+
npm install --save-exact @kubohiroya/turbowarp-extension-data-editor@0.2.2
|
|
110
110
|
```
|
|
111
111
|
|
|
112
112
|
配布物・改名時の互換性・公開手順は[パッケージ配布](docs/package-distribution.md)を参照してください。
|
package/dist/build-info.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubohiroya/turbowarp-extension-data-editor",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"repository": "https://github.com/kubohiroya/turbowarp-extension-data-editor",
|
|
5
|
-
"revision": "
|
|
6
|
-
"sourceState": "
|
|
7
|
-
"sourceSha256": "
|
|
5
|
+
"revision": "7ba760f829a37e2cce39b81668f8c44ea615991e",
|
|
6
|
+
"sourceState": "commit",
|
|
7
|
+
"sourceSha256": "e53c39a3499c78df960a7d38514ed8adbad9258c65655b8a01f6fe553e2d7191",
|
|
8
8
|
"capabilities": {
|
|
9
9
|
"preparedSource": 1
|
|
10
10
|
}
|
package/dist/react.css
CHANGED
|
@@ -8,6 +8,31 @@
|
|
|
8
8
|
width: min(900px, calc(100vw - 32px));
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
.modal-content .header {
|
|
12
|
+
height: auto;
|
|
13
|
+
min-height: 3.5rem;
|
|
14
|
+
align-items: center;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.modal-content .header > div:first-child {
|
|
18
|
+
flex: 1 1 0;
|
|
19
|
+
min-width: 0;
|
|
20
|
+
margin: 0;
|
|
21
|
+
overflow-wrap: anywhere;
|
|
22
|
+
text-align: center;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.modal-content .header > div:last-child {
|
|
26
|
+
flex: 0 0 auto;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.modal-content .header img {
|
|
30
|
+
flex-shrink: 0;
|
|
31
|
+
width: 1.75rem;
|
|
32
|
+
height: 1.75rem;
|
|
33
|
+
object-fit: contain;
|
|
34
|
+
}
|
|
35
|
+
|
|
11
36
|
.tree {
|
|
12
37
|
min-width: 0;
|
|
13
38
|
}
|
|
@@ -152,6 +177,107 @@
|
|
|
152
177
|
margin-bottom: 1rem;
|
|
153
178
|
}
|
|
154
179
|
|
|
180
|
+
.body :global([data-block-editor-item]) {
|
|
181
|
+
box-sizing: border-box;
|
|
182
|
+
min-width: 0;
|
|
183
|
+
margin: 0.75rem 0;
|
|
184
|
+
padding: 1rem;
|
|
185
|
+
border: 1px solid var(--block-editor-border, rgba(0, 0, 0, 0.15));
|
|
186
|
+
border-radius: var(--block-editor-radius, 0.5rem);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.body :global([data-block-editor-item-heading]),
|
|
190
|
+
.body :global([data-block-editor-item-actions]) {
|
|
191
|
+
display: flex;
|
|
192
|
+
align-items: center;
|
|
193
|
+
gap: 0.5rem;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.body :global([data-block-editor-item-heading]) {
|
|
197
|
+
justify-content: space-between;
|
|
198
|
+
margin-bottom: 0.75rem;
|
|
199
|
+
font-weight: bold;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.body :global([data-block-editor-item]) input,
|
|
203
|
+
.body :global([data-block-editor-item]) select,
|
|
204
|
+
.body :global([data-block-editor-item]) textarea {
|
|
205
|
+
box-sizing: border-box;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.body :global([data-block-editor-pair-row]) {
|
|
209
|
+
display: grid;
|
|
210
|
+
grid-template-columns: 3rem minmax(0, 1fr);
|
|
211
|
+
align-items: center;
|
|
212
|
+
gap: 0.5rem 0.75rem;
|
|
213
|
+
margin-top: 0.5rem;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.body :global([data-block-editor-pair-row]) > label {
|
|
217
|
+
grid-column: 1;
|
|
218
|
+
margin: 0;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.body :global([data-block-editor-pair-row]) > :not(label) {
|
|
222
|
+
grid-column: 2;
|
|
223
|
+
min-width: 0;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.body :global([data-block-editor-pair-row]) input:not([type="checkbox"]):not([type="radio"]),
|
|
227
|
+
.body :global([data-block-editor-pair-row]) select,
|
|
228
|
+
.body :global([data-block-editor-pair-row]) textarea {
|
|
229
|
+
margin-top: 0;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.body :global([data-block-editor-item-actions]) button,
|
|
233
|
+
.body :global([data-block-editor-item-menu]) button,
|
|
234
|
+
.body :global([data-block-editor-add-item]) {
|
|
235
|
+
min-height: 2.25rem;
|
|
236
|
+
padding: 0.5rem 0.75rem;
|
|
237
|
+
border: 1px solid var(--block-editor-border, rgba(0, 0, 0, 0.15));
|
|
238
|
+
border-radius: var(--block-editor-radius, 0.5rem);
|
|
239
|
+
color: var(--block-editor-text, #333);
|
|
240
|
+
background: var(--block-editor-button, white);
|
|
241
|
+
cursor: pointer;
|
|
242
|
+
font: inherit;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.body :global([data-block-editor-item-menu]) {
|
|
246
|
+
position: relative;
|
|
247
|
+
flex-shrink: 0;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.body :global([data-block-editor-item-menu]) :global([role="menu"]) {
|
|
251
|
+
position: absolute;
|
|
252
|
+
inset-inline-end: 0;
|
|
253
|
+
top: 100%;
|
|
254
|
+
z-index: 1;
|
|
255
|
+
min-width: max-content;
|
|
256
|
+
padding: 0.25rem;
|
|
257
|
+
background: var(--block-editor-background, white);
|
|
258
|
+
border: 1px solid var(--block-editor-border, rgba(0, 0, 0, 0.15));
|
|
259
|
+
border-radius: var(--block-editor-radius, 0.5rem);
|
|
260
|
+
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.body :global([data-block-editor-item-menu]) :global([role="menuitem"]) {
|
|
264
|
+
width: 100%;
|
|
265
|
+
border: 0;
|
|
266
|
+
text-align: start;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.body :global([data-block-editor-item-actions]) button:disabled,
|
|
270
|
+
.body :global([data-block-editor-add-item]):disabled {
|
|
271
|
+
opacity: 0.5;
|
|
272
|
+
cursor: default;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.body :global([data-block-editor-item-menu]) button:focus-visible,
|
|
276
|
+
.body :global([data-block-editor-add-item]):focus-visible {
|
|
277
|
+
outline: 2px solid currentColor;
|
|
278
|
+
outline-offset: 2px;
|
|
279
|
+
}
|
|
280
|
+
|
|
155
281
|
/* The adapter marks only controls belonging to the field's own RJSF errors. */
|
|
156
282
|
.body :global(.rjsf) input:global([data-block-editor-invalid="true"]),
|
|
157
283
|
.body :global(.rjsf) select:global([data-block-editor-invalid="true"]),
|
package/dist/react.d.ts
CHANGED
|
@@ -10,6 +10,9 @@ export interface DialogSessionState {
|
|
|
10
10
|
readonly error: unknown;
|
|
11
11
|
}
|
|
12
12
|
export interface DialogSession {
|
|
13
|
+
readonly reference?: {
|
|
14
|
+
readonly blockId: string;
|
|
15
|
+
};
|
|
13
16
|
getState(): DialogSessionState;
|
|
14
17
|
getFixedInputView?(): unknown;
|
|
15
18
|
subscribe(listener: () => void): () => void;
|
|
@@ -43,6 +46,8 @@ export interface EditorModalProps {
|
|
|
43
46
|
readonly id: string;
|
|
44
47
|
readonly className: string;
|
|
45
48
|
readonly contentLabel: string;
|
|
49
|
+
readonly headerImage?: string;
|
|
50
|
+
readonly headerClassName?: string | undefined;
|
|
46
51
|
readonly onRequestClose: () => void;
|
|
47
52
|
readonly children?: React.ReactNode;
|
|
48
53
|
}
|
package/dist/react.js
CHANGED
|
@@ -203,6 +203,7 @@ export class BlockEditorDialog extends React.Component {
|
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
render() {
|
|
206
|
+
var _a, _b, _c, _d;
|
|
206
207
|
const { styles, messages, ModalComponent, session } = this.props;
|
|
207
208
|
const saving = this.state.status === 'saving';
|
|
208
209
|
const hierarchy = typeof session.getNodes === 'function';
|
|
@@ -211,11 +212,18 @@ export class BlockEditorDialog extends React.Component {
|
|
|
211
212
|
try {
|
|
212
213
|
fixed = Boolean(session.getFixedInputView());
|
|
213
214
|
}
|
|
214
|
-
catch (
|
|
215
|
+
catch (_e) {
|
|
215
216
|
fixed = true;
|
|
216
217
|
}
|
|
217
218
|
}
|
|
218
|
-
|
|
219
|
+
const root = (_a = session.getNodes) === null || _a === void 0 ? void 0 : _a.call(session).find(node => node.inputPath.length === 0);
|
|
220
|
+
const rootId = ((_b = session.reference) === null || _b === void 0 ? void 0 : _b.blockId) || (root === null || root === void 0 ? void 0 : root.reference.blockId);
|
|
221
|
+
const appearance = rootId ? (_c = this.props.nodeAppearances) === null || _c === void 0 ? void 0 : _c[rootId] : undefined;
|
|
222
|
+
const name = (appearance === null || appearance === void 0 ? void 0 : appearance.name) || (rootId ? (_d = this.props.nodeLabels) === null || _d === void 0 ? void 0 : _d[rootId] : undefined) || (root === null || root === void 0 ? void 0 : root.opcode);
|
|
223
|
+
const title = name ? messages.title.includes('{name}') ? messages.title.replace('{name}', () => name) :
|
|
224
|
+
/ブロック|block/i.test(messages.title) ? messages.title.replace(/ブロック|block/i, () => name) :
|
|
225
|
+
`${name}: ${messages.title}` : messages.title;
|
|
226
|
+
return React.createElement(ModalComponent, { className: `${styles.modalContent || ''} ${hierarchy ? styles.hierarchyModal : ''} ${this.props.className || ''}`, contentLabel: title, ...((appearance === null || appearance === void 0 ? void 0 : appearance.iconURI) ? { headerImage: appearance.iconURI } : {}), headerClassName: styles.header, id: "blockEditorModal", onRequestClose: this.handleClose },
|
|
219
227
|
React.createElement("div", { "aria-busy": saving, className: styles.body, onCompositionStart: () => { this.composing = true; }, onCompositionEnd: () => { this.composing = false; }, onKeyDownCapture: event => {
|
|
220
228
|
if (this.composing || event.nativeEvent.isComposing || event.keyCode === 229)
|
|
221
229
|
event.stopPropagation();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { ArrayFieldTemplateItemType, FieldTemplateProps, IconButtonProps, ObjectFieldTemplateProps, WrapIfAdditionalTemplateProps } from '@rjsf/utils';
|
|
3
|
+
/** Keep the property key out of the value's visible label. */
|
|
4
|
+
export declare function valueFieldTemplate(DefaultTemplate: React.ComponentType<FieldTemplateProps>, flag: string): (props: FieldTemplateProps) => React.ReactElement;
|
|
5
|
+
/** Keep RJSF's object layout while numbering each editable additional property. */
|
|
6
|
+
export declare function numberedObjectTemplate(DefaultTemplate: React.ComponentType<ObjectFieldTemplateProps>, flag: string): (props: ObjectFieldTemplateProps) => React.ReactElement;
|
|
7
|
+
export declare function additionalItemTemplate(flag: string): (props: WrapIfAdditionalTemplateProps) => React.ReactElement;
|
|
8
|
+
/** Deletion is available only after explicitly opening the item's menu. */
|
|
9
|
+
export declare function ItemMenu({ disabled, onClick }: Pick<IconButtonProps, 'disabled' | 'onClick'>): React.ReactElement;
|
|
10
|
+
export declare function AddItemButton({ disabled, onClick, className }: IconButtonProps): React.ReactElement;
|
|
11
|
+
export declare function ArrayItem(props: ArrayFieldTemplateItemType): React.ReactElement;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
const ItemNumber = React.createContext(1);
|
|
3
|
+
const PropertyKey = React.createContext(undefined);
|
|
4
|
+
/** Keep the property key out of the value's visible label. */
|
|
5
|
+
export function valueFieldTemplate(DefaultTemplate, flag) {
|
|
6
|
+
return function ValueField(props) {
|
|
7
|
+
if (!(flag in props.schema))
|
|
8
|
+
return React.createElement(DefaultTemplate, { ...props });
|
|
9
|
+
return React.createElement(PropertyKey.Provider, { value: props.label },
|
|
10
|
+
React.createElement(DefaultTemplate, { ...props, label: "\u5024" }));
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/** Keep RJSF's object layout while numbering each editable additional property. */
|
|
14
|
+
export function numberedObjectTemplate(DefaultTemplate, flag) {
|
|
15
|
+
return function ObjectItems(props) {
|
|
16
|
+
let number = 0;
|
|
17
|
+
const properties = props.properties.map(property => {
|
|
18
|
+
var _a;
|
|
19
|
+
const schema = (_a = props.schema.properties) === null || _a === void 0 ? void 0 : _a[property.name];
|
|
20
|
+
if (!schema || typeof schema !== 'object' || !(flag in schema) || property.hidden)
|
|
21
|
+
return property;
|
|
22
|
+
return { ...property, content: React.createElement(ItemNumber.Provider, { key: property.name, value: ++number }, property.content) };
|
|
23
|
+
});
|
|
24
|
+
return React.createElement(DefaultTemplate, { ...props, properties: properties });
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function additionalItemTemplate(flag) {
|
|
28
|
+
return function AdditionalItem(props) {
|
|
29
|
+
const number = React.useContext(ItemNumber);
|
|
30
|
+
const propertyKey = React.useContext(PropertyKey);
|
|
31
|
+
const { id, classNames, style, children, schema, label, disabled, readonly, onKeyChange, onDropPropertyClick } = props;
|
|
32
|
+
if (!(flag in schema))
|
|
33
|
+
return React.createElement("div", { className: classNames, style: style }, children);
|
|
34
|
+
const key = propertyKey !== null && propertyKey !== void 0 ? propertyKey : label;
|
|
35
|
+
return React.createElement("div", { className: classNames, style: style, "data-block-editor-item": "" },
|
|
36
|
+
React.createElement("div", { "data-block-editor-item-heading": "" },
|
|
37
|
+
React.createElement("span", null,
|
|
38
|
+
"\u30FB\u9805\u76EE",
|
|
39
|
+
number),
|
|
40
|
+
React.createElement(ItemMenu, { disabled: disabled || readonly, onClick: onDropPropertyClick(key) })),
|
|
41
|
+
React.createElement("div", { "data-block-editor-pair-row": "" },
|
|
42
|
+
React.createElement("label", { htmlFor: `${id}-key` }, "\u30AD\u30FC"),
|
|
43
|
+
React.createElement("input", { id: `${id}-key`, type: "text", defaultValue: key, disabled: disabled, readOnly: readonly, onBlur: event => onKeyChange(event.target.value) })),
|
|
44
|
+
React.createElement("div", { "data-block-editor-pair-row": "" }, children));
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** Deletion is available only after explicitly opening the item's menu. */
|
|
48
|
+
export function ItemMenu({ disabled, onClick }) {
|
|
49
|
+
const [open, setOpen] = React.useState(false);
|
|
50
|
+
const container = React.useRef(null);
|
|
51
|
+
const trigger = React.useRef(null);
|
|
52
|
+
const item = React.useRef(null);
|
|
53
|
+
React.useEffect(() => {
|
|
54
|
+
var _a;
|
|
55
|
+
if (!open)
|
|
56
|
+
return;
|
|
57
|
+
(_a = item.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
58
|
+
const closeOutside = (event) => {
|
|
59
|
+
var _a;
|
|
60
|
+
if (!((_a = container.current) === null || _a === void 0 ? void 0 : _a.contains(event.target)))
|
|
61
|
+
setOpen(false);
|
|
62
|
+
};
|
|
63
|
+
// RJSF and its host modal have separate React roots. Stop Escape before either root delegates it.
|
|
64
|
+
const keepEscapeInMenu = (event) => {
|
|
65
|
+
var _a;
|
|
66
|
+
if (event.key !== 'Escape' || event.isComposing || event.keyCode === 229)
|
|
67
|
+
return;
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
event.stopPropagation();
|
|
70
|
+
setOpen(false);
|
|
71
|
+
(_a = trigger.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
72
|
+
};
|
|
73
|
+
const menu = container.current;
|
|
74
|
+
menu === null || menu === void 0 ? void 0 : menu.addEventListener('keydown', keepEscapeInMenu);
|
|
75
|
+
document.addEventListener('mousedown', closeOutside);
|
|
76
|
+
return () => {
|
|
77
|
+
menu === null || menu === void 0 ? void 0 : menu.removeEventListener('keydown', keepEscapeInMenu);
|
|
78
|
+
document.removeEventListener('mousedown', closeOutside);
|
|
79
|
+
};
|
|
80
|
+
}, [open]);
|
|
81
|
+
React.useEffect(() => { if (disabled)
|
|
82
|
+
setOpen(false); }, [disabled]);
|
|
83
|
+
return React.createElement("div", { "data-block-editor-item-menu": "", ref: container, onBlur: event => {
|
|
84
|
+
if (!event.currentTarget.contains(event.relatedTarget))
|
|
85
|
+
setOpen(false);
|
|
86
|
+
}, onKeyDown: event => {
|
|
87
|
+
var _a, _b;
|
|
88
|
+
if (event.key === 'Escape' && open && !event.nativeEvent.isComposing && event.keyCode !== 229) {
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
event.stopPropagation();
|
|
91
|
+
setOpen(false);
|
|
92
|
+
(_a = trigger.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
93
|
+
}
|
|
94
|
+
else if (['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(event.key)) {
|
|
95
|
+
event.preventDefault();
|
|
96
|
+
if (open)
|
|
97
|
+
(_b = item.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
98
|
+
else if (!disabled)
|
|
99
|
+
setOpen(true);
|
|
100
|
+
}
|
|
101
|
+
} },
|
|
102
|
+
React.createElement("button", { "aria-label": "\u9805\u76EE\u306E\u30E1\u30CB\u30E5\u30FC", "aria-haspopup": "menu", "aria-expanded": open && !disabled, disabled: disabled, ref: trigger, type: "button", onClick: () => setOpen(!open) }, "\u2026"),
|
|
103
|
+
open && !disabled ? React.createElement("div", { role: "menu", "aria-label": "\u9805\u76EE\u306E\u64CD\u4F5C" },
|
|
104
|
+
React.createElement("button", { ref: item, role: "menuitem", type: "button", onClick: event => {
|
|
105
|
+
var _a;
|
|
106
|
+
setOpen(false);
|
|
107
|
+
(_a = trigger.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
108
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
109
|
+
} }, "\uD83D\uDDD1\uFE0F\u3053\u306E\u9805\u76EE\u3092\u524A\u9664")) : null);
|
|
110
|
+
}
|
|
111
|
+
export function AddItemButton({ disabled, onClick, className }) {
|
|
112
|
+
return React.createElement("button", { className: className, "data-block-editor-add-item": "", disabled: disabled, type: "button", onClick: onClick }, "\u2795\u9805\u76EE\u3092\u8FFD\u52A0");
|
|
113
|
+
}
|
|
114
|
+
export function ArrayItem(props) {
|
|
115
|
+
const { children, className, disabled, readonly, index, hasMoveUp, hasMoveDown, hasCopy, hasRemove, onReorderClick, onCopyIndexClick, onDropIndexClick } = props;
|
|
116
|
+
const locked = disabled || readonly;
|
|
117
|
+
return React.createElement("div", { className: className, "data-block-editor-item": "" },
|
|
118
|
+
React.createElement("div", { "data-block-editor-item-heading": "" },
|
|
119
|
+
React.createElement("span", null,
|
|
120
|
+
"\u30FB\u9805\u76EE",
|
|
121
|
+
index + 1),
|
|
122
|
+
React.createElement("div", { "data-block-editor-item-actions": "" },
|
|
123
|
+
hasMoveUp || hasMoveDown ? React.createElement(React.Fragment, null,
|
|
124
|
+
React.createElement("button", { "aria-label": "\u9805\u76EE\u3092\u4E0A\u3078\u79FB\u52D5", disabled: locked || !hasMoveUp, type: "button", onClick: onReorderClick(index, index - 1) }, "\u2191"),
|
|
125
|
+
React.createElement("button", { "aria-label": "\u9805\u76EE\u3092\u4E0B\u3078\u79FB\u52D5", disabled: locked || !hasMoveDown, type: "button", onClick: onReorderClick(index, index + 1) }, "\u2193")) : null,
|
|
126
|
+
hasCopy ? React.createElement("button", { disabled: locked, type: "button", onClick: onCopyIndexClick(index) }, "\u9805\u76EE\u3092\u8907\u88FD") : null,
|
|
127
|
+
hasRemove ? React.createElement(ItemMenu, { disabled: locked, onClick: onDropIndexClick(index) }) : null)),
|
|
128
|
+
children);
|
|
129
|
+
}
|
package/dist/rjsf.js
CHANGED
|
@@ -16,6 +16,7 @@ import { cloneJson } from './data.js';
|
|
|
16
16
|
import { decodeSource, encodeSource, sameData } from './codec.js';
|
|
17
17
|
import { EditorRegistry } from './registry.js';
|
|
18
18
|
import { EDITOR_API_VERSION } from './types.js';
|
|
19
|
+
import { AddItemButton, ArrayItem, ItemMenu, additionalItemTemplate, numberedObjectTemplate, valueFieldTemplate } from './rjsf-templates.js';
|
|
19
20
|
// RJSF v5 exposes CommonJS to Node and ESM to browser bundlers.
|
|
20
21
|
function moduleExports(namespace) {
|
|
21
22
|
const fallback = namespace.default;
|
|
@@ -23,8 +24,12 @@ function moduleExports(namespace) {
|
|
|
23
24
|
? fallback : namespace;
|
|
24
25
|
}
|
|
25
26
|
const Form = moduleExports(RjsfCore).default;
|
|
26
|
-
const { getDefaultFormState } = moduleExports(RjsfUtils);
|
|
27
|
+
const { getDefaultFormState, ADDITIONAL_PROPERTY_FLAG } = moduleExports(RjsfUtils);
|
|
27
28
|
const { customizeValidator } = moduleExports(RjsfAjv);
|
|
29
|
+
const defaultTemplates = moduleExports(RjsfCore).getDefaultRegistry().templates;
|
|
30
|
+
const ObjectItems = numberedObjectTemplate(defaultTemplates.ObjectFieldTemplate, ADDITIONAL_PROPERTY_FLAG);
|
|
31
|
+
const AdditionalItem = additionalItemTemplate(ADDITIONAL_PROPERTY_FLAG);
|
|
32
|
+
const ValueField = valueFieldTemplate(defaultTemplates.FieldTemplate, ADDITIONAL_PROPERTY_FLAG);
|
|
28
33
|
let nextViewId = 0;
|
|
29
34
|
export function createSchemaBundleEditor(options) {
|
|
30
35
|
const { schemaBundle, validationContext: provider, ownerValidate, apiVersion, extensionId, editorId, opcodes, argument, format, uiSchema, validateData } = options;
|
|
@@ -209,6 +214,13 @@ function createSchemaEditorImpl(options, bundle) {
|
|
|
209
214
|
const state = context.getState();
|
|
210
215
|
const props = {
|
|
211
216
|
schema, uiSchema, validator, idPrefix,
|
|
217
|
+
templates: {
|
|
218
|
+
ArrayFieldItemTemplate: ArrayItem,
|
|
219
|
+
ObjectFieldTemplate: ObjectItems,
|
|
220
|
+
WrapIfAdditionalTemplate: AdditionalItem,
|
|
221
|
+
FieldTemplate: ValueField,
|
|
222
|
+
ButtonTemplates: { AddButton: AddItemButton, RemoveButton: ItemMenu }
|
|
223
|
+
},
|
|
212
224
|
formData: dataFor(context.getDraft()),
|
|
213
225
|
// Defaults belong to read(), not subsequent renders or remounts.
|
|
214
226
|
experimental_defaultFormStateBehavior: {
|
package/dist/turbowarp/bridge.js
CHANGED
|
@@ -95,6 +95,9 @@ const createBlockEditorBridge = ({ ScratchBlocks, workspace, vm, service, label,
|
|
|
95
95
|
openingFixedDeclaration = fixedDeclaration(service.registry, openingSnapshot) || null;
|
|
96
96
|
const labels = {};
|
|
97
97
|
const appearances = Object.create(null);
|
|
98
|
+
const rootAppearance = readBlockEditorAppearance(block, ScratchBlocks);
|
|
99
|
+
appearances[reference.blockId] = rootAppearance;
|
|
100
|
+
labels[reference.blockId] = rootAppearance.name || block.type;
|
|
98
101
|
if (typeof session.getNodes === 'function') {
|
|
99
102
|
for (const node of session.getNodes()) {
|
|
100
103
|
const source = workspace.getBlockById(node.reference.blockId);
|
|
@@ -13961,8 +13961,19 @@
|
|
|
13961
13961
|
],
|
|
13962
13962
|
"format": "esm"
|
|
13963
13963
|
},
|
|
13964
|
+
"dist/rjsf-templates.js": {
|
|
13965
|
+
"bytes": 7933,
|
|
13966
|
+
"imports": [
|
|
13967
|
+
{
|
|
13968
|
+
"path": "react",
|
|
13969
|
+
"kind": "import-statement",
|
|
13970
|
+
"external": true
|
|
13971
|
+
}
|
|
13972
|
+
],
|
|
13973
|
+
"format": "esm"
|
|
13974
|
+
},
|
|
13964
13975
|
"dist/rjsf.js": {
|
|
13965
|
-
"bytes":
|
|
13976
|
+
"bytes": 13852,
|
|
13966
13977
|
"imports": [
|
|
13967
13978
|
{
|
|
13968
13979
|
"path": "react",
|
|
@@ -14053,6 +14064,11 @@
|
|
|
14053
14064
|
"path": "dist/types.js",
|
|
14054
14065
|
"kind": "import-statement",
|
|
14055
14066
|
"original": "./types.js"
|
|
14067
|
+
},
|
|
14068
|
+
{
|
|
14069
|
+
"path": "dist/rjsf-templates.js",
|
|
14070
|
+
"kind": "import-statement",
|
|
14071
|
+
"original": "./rjsf-templates.js"
|
|
14056
14072
|
}
|
|
14057
14073
|
],
|
|
14058
14074
|
"format": "esm"
|
|
@@ -14063,7 +14079,7 @@
|
|
|
14063
14079
|
"format": "esm"
|
|
14064
14080
|
},
|
|
14065
14081
|
"dist/react.js": {
|
|
14066
|
-
"bytes":
|
|
14082
|
+
"bytes": 14377,
|
|
14067
14083
|
"imports": [
|
|
14068
14084
|
{
|
|
14069
14085
|
"path": "dist/field-errors.js",
|
|
@@ -14177,7 +14193,7 @@
|
|
|
14177
14193
|
"format": "esm"
|
|
14178
14194
|
},
|
|
14179
14195
|
"dist/turbowarp/bridge.js": {
|
|
14180
|
-
"bytes":
|
|
14196
|
+
"bytes": 8940,
|
|
14181
14197
|
"imports": [
|
|
14182
14198
|
{
|
|
14183
14199
|
"path": "dist/turbowarp/host.js",
|
|
@@ -14297,7 +14313,7 @@
|
|
|
14297
14313
|
"imports": [],
|
|
14298
14314
|
"exports": [],
|
|
14299
14315
|
"inputs": {},
|
|
14300
|
-
"bytes":
|
|
14316
|
+
"bytes": 1863920
|
|
14301
14317
|
},
|
|
14302
14318
|
"dist/webpack4/rjsf.js": {
|
|
14303
14319
|
"imports": [
|
|
@@ -14681,6 +14697,11 @@
|
|
|
14681
14697
|
"kind": "import-statement",
|
|
14682
14698
|
"external": true
|
|
14683
14699
|
},
|
|
14700
|
+
{
|
|
14701
|
+
"path": "react",
|
|
14702
|
+
"kind": "import-statement",
|
|
14703
|
+
"external": true
|
|
14704
|
+
},
|
|
14684
14705
|
{
|
|
14685
14706
|
"path": "react",
|
|
14686
14707
|
"kind": "import-statement",
|
|
@@ -15360,7 +15381,7 @@
|
|
|
15360
15381
|
"bytesInOutput": 275
|
|
15361
15382
|
},
|
|
15362
15383
|
"dist/rjsf.js": {
|
|
15363
|
-
"bytesInOutput":
|
|
15384
|
+
"bytesInOutput": 10851
|
|
15364
15385
|
},
|
|
15365
15386
|
"node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/browser/dist/nodes/identity.js": {
|
|
15366
15387
|
"bytesInOutput": 1376
|
|
@@ -15579,16 +15600,16 @@
|
|
|
15579
15600
|
"bytesInOutput": 2134
|
|
15580
15601
|
},
|
|
15581
15602
|
"dist/source-document.js": {
|
|
15582
|
-
"bytesInOutput":
|
|
15603
|
+
"bytesInOutput": 16050
|
|
15583
15604
|
},
|
|
15584
15605
|
"dist/source-schema-hints.js": {
|
|
15585
15606
|
"bytesInOutput": 449
|
|
15586
15607
|
},
|
|
15587
15608
|
"dist/source-view.js": {
|
|
15588
|
-
"bytesInOutput":
|
|
15609
|
+
"bytesInOutput": 18076
|
|
15589
15610
|
},
|
|
15590
15611
|
"dist/source-editor.js": {
|
|
15591
|
-
"bytesInOutput":
|
|
15612
|
+
"bytesInOutput": 10758
|
|
15592
15613
|
},
|
|
15593
15614
|
"dist/fixed-input-view.js": {
|
|
15594
15615
|
"bytesInOutput": 10479
|
|
@@ -16666,15 +16687,18 @@
|
|
|
16666
16687
|
},
|
|
16667
16688
|
"dist/schema-view.js": {
|
|
16668
16689
|
"bytesInOutput": 4302
|
|
16690
|
+
},
|
|
16691
|
+
"dist/rjsf-templates.js": {
|
|
16692
|
+
"bytesInOutput": 7182
|
|
16669
16693
|
}
|
|
16670
16694
|
},
|
|
16671
|
-
"bytes":
|
|
16695
|
+
"bytes": 858517
|
|
16672
16696
|
},
|
|
16673
16697
|
"dist/webpack4/react.js.map": {
|
|
16674
16698
|
"imports": [],
|
|
16675
16699
|
"exports": [],
|
|
16676
16700
|
"inputs": {},
|
|
16677
|
-
"bytes":
|
|
16701
|
+
"bytes": 30867
|
|
16678
16702
|
},
|
|
16679
16703
|
"dist/webpack4/react.js": {
|
|
16680
16704
|
"imports": [
|
|
@@ -16702,16 +16726,16 @@
|
|
|
16702
16726
|
"bytesInOutput": 3769
|
|
16703
16727
|
},
|
|
16704
16728
|
"dist/react.js": {
|
|
16705
|
-
"bytesInOutput":
|
|
16729
|
+
"bytesInOutput": 13029
|
|
16706
16730
|
}
|
|
16707
16731
|
},
|
|
16708
|
-
"bytes":
|
|
16732
|
+
"bytes": 17088
|
|
16709
16733
|
},
|
|
16710
16734
|
"dist/webpack4/turbowarp.js.map": {
|
|
16711
16735
|
"imports": [],
|
|
16712
16736
|
"exports": [],
|
|
16713
16737
|
"inputs": {},
|
|
16714
|
-
"bytes":
|
|
16738
|
+
"bytes": 116509
|
|
16715
16739
|
},
|
|
16716
16740
|
"dist/webpack4/turbowarp.js": {
|
|
16717
16741
|
"imports": [
|
|
@@ -16768,13 +16792,13 @@
|
|
|
16768
16792
|
"bytesInOutput": 835
|
|
16769
16793
|
},
|
|
16770
16794
|
"dist/turbowarp/bridge.js": {
|
|
16771
|
-
"bytesInOutput":
|
|
16795
|
+
"bytesInOutput": 6970
|
|
16772
16796
|
},
|
|
16773
16797
|
"dist/turbowarp.js": {
|
|
16774
16798
|
"bytesInOutput": 1096
|
|
16775
16799
|
}
|
|
16776
16800
|
},
|
|
16777
|
-
"bytes":
|
|
16801
|
+
"bytes": 62617
|
|
16778
16802
|
},
|
|
16779
16803
|
"dist/webpack4/shared-FYUILHED.js.map": {
|
|
16780
16804
|
"imports": [],
|
package/dist/webpack4/react.js
CHANGED
|
@@ -314,6 +314,7 @@ var BlockEditorDialog = class extends React.Component {
|
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
316
|
render() {
|
|
317
|
+
var _a, _b, _c, _d;
|
|
317
318
|
const { styles, messages, ModalComponent, session } = this.props;
|
|
318
319
|
const saving = this.state.status === "saving";
|
|
319
320
|
const hierarchy = typeof session.getNodes === "function";
|
|
@@ -321,13 +322,18 @@ var BlockEditorDialog = class extends React.Component {
|
|
|
321
322
|
if (session.getFixedInputView && (this.state.status === "editing" || saving)) {
|
|
322
323
|
try {
|
|
323
324
|
fixed = Boolean(session.getFixedInputView());
|
|
324
|
-
} catch (
|
|
325
|
+
} catch (_e) {
|
|
325
326
|
fixed = true;
|
|
326
327
|
}
|
|
327
328
|
}
|
|
329
|
+
const root = (_a = session.getNodes) === null || _a === void 0 ? void 0 : _a.call(session).find((node) => node.inputPath.length === 0);
|
|
330
|
+
const rootId = ((_b = session.reference) === null || _b === void 0 ? void 0 : _b.blockId) || (root === null || root === void 0 ? void 0 : root.reference.blockId);
|
|
331
|
+
const appearance = rootId ? (_c = this.props.nodeAppearances) === null || _c === void 0 ? void 0 : _c[rootId] : void 0;
|
|
332
|
+
const name = (appearance === null || appearance === void 0 ? void 0 : appearance.name) || (rootId ? (_d = this.props.nodeLabels) === null || _d === void 0 ? void 0 : _d[rootId] : void 0) || (root === null || root === void 0 ? void 0 : root.opcode);
|
|
333
|
+
const title = name ? messages.title.includes("{name}") ? messages.title.replace("{name}", () => name) : /ブロック|block/i.test(messages.title) ? messages.title.replace(/ブロック|block/i, () => name) : `${name}: ${messages.title}` : messages.title;
|
|
328
334
|
return React.createElement(
|
|
329
335
|
ModalComponent,
|
|
330
|
-
{ className: `${styles.modalContent || ""} ${hierarchy ? styles.hierarchyModal : ""} ${this.props.className || ""}`, contentLabel:
|
|
336
|
+
{ className: `${styles.modalContent || ""} ${hierarchy ? styles.hierarchyModal : ""} ${this.props.className || ""}`, contentLabel: title, ...(appearance === null || appearance === void 0 ? void 0 : appearance.iconURI) ? { headerImage: appearance.iconURI } : {}, headerClassName: styles.header, id: "blockEditorModal", onRequestClose: this.handleClose },
|
|
331
337
|
React.createElement(
|
|
332
338
|
"div",
|
|
333
339
|
{ "aria-busy": saving, className: styles.body, onCompositionStart: () => {
|
|
@@ -349,14 +355,14 @@ var BlockEditorDialog = class extends React.Component {
|
|
|
349
355
|
{ "aria-live": "polite", className: styles.errors, role: "status" },
|
|
350
356
|
saving ? messages.saving : null,
|
|
351
357
|
fixed && this.state.issues.length ? React.createElement("p", null, messages.invalidInput || messages.failed) : this.state.issues.map((issue, index) => {
|
|
352
|
-
var
|
|
358
|
+
var _a2;
|
|
353
359
|
return hierarchy && "reference" in issue ? React.createElement(
|
|
354
360
|
"button",
|
|
355
361
|
{ className: styles.nodeError, "data-block-editor-issue": index, disabled: saving, key: index, type: "button", onClick: () => {
|
|
356
|
-
var
|
|
357
|
-
return (
|
|
362
|
+
var _a3;
|
|
363
|
+
return (_a3 = this.tree) === null || _a3 === void 0 ? void 0 : _a3.reveal(issue);
|
|
358
364
|
} },
|
|
359
|
-
((
|
|
365
|
+
((_a2 = this.props.nodeLabels) === null || _a2 === void 0 ? void 0 : _a2[issue.reference.blockId]) || issue.reference.blockId,
|
|
360
366
|
": ",
|
|
361
367
|
issue.message
|
|
362
368
|
) : React.createElement("p", { key: index }, issue.message);
|