@atlaskit/editor-plugin-extension 1.5.2 → 1.5.3
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/.eslintrc.js +12 -12
- package/CHANGELOG.md +219 -214
- package/LICENSE.md +6 -8
- package/dist/cjs/ui/ConfigPanel/ErrorMessage/ErrorImage.js +12 -4
- package/dist/cjs/ui/ConfigPanel/Fields/ColorPicker.js +1 -1
- package/dist/cjs/ui/ConfigPanel/FormContent.js +4 -1
- package/dist/cjs/ui/ConfigPanel/Header.js +1 -0
- package/dist/cjs/ui/ConfigPanel/NestedForms/RemovableField.js +3 -1
- package/dist/es2019/ui/ConfigPanel/ErrorMessage/ErrorImage.js +12 -4
- package/dist/es2019/ui/ConfigPanel/Fields/ColorPicker.js +1 -1
- package/dist/es2019/ui/ConfigPanel/FormContent.js +4 -1
- package/dist/es2019/ui/ConfigPanel/Header.js +1 -0
- package/dist/es2019/ui/ConfigPanel/NestedForms/RemovableField.js +3 -1
- package/dist/esm/ui/ConfigPanel/ErrorMessage/ErrorImage.js +12 -4
- package/dist/esm/ui/ConfigPanel/Fields/ColorPicker.js +1 -1
- package/dist/esm/ui/ConfigPanel/FormContent.js +4 -1
- package/dist/esm/ui/ConfigPanel/Header.js +1 -0
- package/dist/esm/ui/ConfigPanel/NestedForms/RemovableField.js +3 -1
- package/dist/types/ui/ConfigPanel/Fields/UnhandledType.d.ts +1 -1
- package/dist/types/ui/SaveIndicator/SaveIndicator.d.ts +1 -1
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/UnhandledType.d.ts +1 -1
- package/dist/types-ts4.5/ui/SaveIndicator/SaveIndicator.d.ts +1 -1
- package/example-utils/config-panel/ConfigPanelWithExtensionPicker.tsx +158 -172
- package/example-utils/config-panel/ConfigPanelWithProviders.tsx +37 -37
- package/example-utils/config-panel/ExtensionNodePicker.tsx +110 -121
- package/example-utils/config-panel/FieldTypePicker.tsx +49 -47
- package/example-utils/config-panel/example-manifest-all-fields.ts +63 -63
- package/example-utils/config-panel/example-manifest-individual-fields.ts +64 -64
- package/example-utils/config-panel/fields.ts +617 -619
- package/package.json +8 -10
- package/report.api.md +42 -47
|
@@ -8,9 +8,9 @@ import { IntlProvider } from 'react-intl-next';
|
|
|
8
8
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
9
9
|
import { CodeBlock } from '@atlaskit/code';
|
|
10
10
|
import type {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
ExtensionModule,
|
|
12
|
+
ExtensionProvider,
|
|
13
|
+
Parameters,
|
|
14
14
|
} from '@atlaskit/editor-common/extensions';
|
|
15
15
|
import { getExtensionKeyAndNodeKey } from '@atlaskit/editor-common/extensions';
|
|
16
16
|
import { Box, xcss } from '@atlaskit/primitives';
|
|
@@ -30,189 +30,175 @@ const exampleWrapperStyles = css({ display: 'flex', flexDirection: 'row' });
|
|
|
30
30
|
|
|
31
31
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
32
32
|
const column = (width: number | string) =>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
css({
|
|
34
|
+
width: `${width}px`,
|
|
35
|
+
margin: token('space.200', '16px'),
|
|
36
|
+
h3: {
|
|
37
|
+
borderBottom: `1px solid ${colors.N50}`,
|
|
38
|
+
marginBottom: token('space.200', '16px'),
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
41
|
|
|
42
42
|
const codeWrapperStyles = css({
|
|
43
|
-
|
|
43
|
+
marginTop: token('space.200', '16px'),
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
function ExtensionConfigPanel({
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
extension,
|
|
48
|
+
node,
|
|
49
|
+
nodeKey,
|
|
50
|
+
extensionProvider,
|
|
51
|
+
parameters: initialParameters = {},
|
|
52
|
+
item,
|
|
53
53
|
}: { extensionProvider: ExtensionProvider; nodeKey: string } & CallbackParams) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
<div css={column(500)} key="fields-definition">
|
|
134
|
-
<h3>Fields definition:</h3>
|
|
135
|
-
<div css={codeWrapperStyles}>
|
|
136
|
-
<CodeBlock
|
|
137
|
-
language="json"
|
|
138
|
-
text={JSON.stringify(fields, null, 4)}
|
|
139
|
-
showLineNumbers={false}
|
|
140
|
-
/>
|
|
141
|
-
</div>
|
|
142
|
-
</div>
|
|
143
|
-
</div>
|
|
144
|
-
);
|
|
54
|
+
const [fields] = useStateFromPromise(
|
|
55
|
+
function getFields() {
|
|
56
|
+
if (node && typeof node.getFieldsDefinition === 'function') {
|
|
57
|
+
return node.getFieldsDefinition({});
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
[node],
|
|
61
|
+
[],
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const [parametersJson, setParametersJson] = useState(() => JSON.stringify(initialParameters));
|
|
65
|
+
|
|
66
|
+
const [parameters, setParameters] = useState(initialParameters);
|
|
67
|
+
|
|
68
|
+
const onChangeParametersJson: React.ChangeEventHandler<HTMLTextAreaElement> = (event) => {
|
|
69
|
+
setParametersJson(event.target.value);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
try {
|
|
74
|
+
setParameters({
|
|
75
|
+
...parameters,
|
|
76
|
+
...JSON.parse(parametersJson),
|
|
77
|
+
});
|
|
78
|
+
} catch (e) {
|
|
79
|
+
// eslint-disable-next-line no-console
|
|
80
|
+
console.error('Invalid JSON Parameters', e instanceof Error ? e.message : String(e));
|
|
81
|
+
}
|
|
82
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
83
|
+
}, [parametersJson]);
|
|
84
|
+
|
|
85
|
+
if (!extension || !node || !item) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<div css={exampleWrapperStyles}>
|
|
91
|
+
{/* eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage */}
|
|
92
|
+
<div css={column(400)} key="config-panel">
|
|
93
|
+
<h3>Config panel:</h3>
|
|
94
|
+
<ConfigPanelWithProviders
|
|
95
|
+
extensionType={extension.type}
|
|
96
|
+
extensionKey={extension.key}
|
|
97
|
+
nodeKey={nodeKey}
|
|
98
|
+
extensionProvider={extensionProvider}
|
|
99
|
+
parameters={parameters}
|
|
100
|
+
onChange={setParameters}
|
|
101
|
+
/>
|
|
102
|
+
</div>
|
|
103
|
+
{/* eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage */}
|
|
104
|
+
<div css={column(500)} key="parameters">
|
|
105
|
+
<h3>Initial Parameters:</h3>
|
|
106
|
+
<div css={codeWrapperStyles}>
|
|
107
|
+
{parameters && <TextArea onChange={onChangeParametersJson} value={parametersJson} />}
|
|
108
|
+
</div>
|
|
109
|
+
<h3>State:</h3>
|
|
110
|
+
<div css={codeWrapperStyles}>
|
|
111
|
+
{parameters && (
|
|
112
|
+
<CodeBlock
|
|
113
|
+
language="json"
|
|
114
|
+
text={JSON.stringify(parameters, null, 4)}
|
|
115
|
+
showLineNumbers={false}
|
|
116
|
+
/>
|
|
117
|
+
)}
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
{/* eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage */}
|
|
121
|
+
<div css={column(500)} key="fields-definition">
|
|
122
|
+
<h3>Fields definition:</h3>
|
|
123
|
+
<div css={codeWrapperStyles}>
|
|
124
|
+
<CodeBlock
|
|
125
|
+
language="json"
|
|
126
|
+
text={JSON.stringify(fields, null, 4)}
|
|
127
|
+
showLineNumbers={false}
|
|
128
|
+
/>
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
);
|
|
145
133
|
}
|
|
146
134
|
|
|
147
135
|
const addHashToTheUrl = (extensionPath: string): void => {
|
|
148
|
-
|
|
149
|
-
|
|
136
|
+
// @ts-expect-error
|
|
137
|
+
window.top.location.hash = extensionPath;
|
|
150
138
|
};
|
|
151
139
|
|
|
152
140
|
const getHashFromUrl = (): string =>
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
141
|
+
// @ts-expect-error
|
|
142
|
+
window.top.location.hash &&
|
|
143
|
+
// @ts-expect-error
|
|
144
|
+
decodeURIComponent(window.top.location.hash.slice(1));
|
|
157
145
|
|
|
158
146
|
export default function ConfigPanelWithExtensionPicker({
|
|
159
|
-
|
|
160
|
-
|
|
147
|
+
extensionProvider,
|
|
148
|
+
parameters = {},
|
|
161
149
|
}: {
|
|
162
|
-
|
|
163
|
-
|
|
150
|
+
extensionProvider: ExtensionProvider;
|
|
151
|
+
parameters?: Parameters;
|
|
164
152
|
}) {
|
|
165
|
-
|
|
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
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
</IntlProvider>
|
|
217
|
-
);
|
|
153
|
+
const [hash, setHash] = useState<string>(getHashFromUrl());
|
|
154
|
+
const [extensionNode, setNodeAndParameters] = useState<CallbackParams>();
|
|
155
|
+
const [item, setItem] = useState<ExtensionModule>();
|
|
156
|
+
const [extensionKey, nodeKey] = getExtensionKeyAndNodeKey(
|
|
157
|
+
hash,
|
|
158
|
+
extensionNode && extensionNode.extension ? extensionNode.extension.type : '',
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
const actualParameters =
|
|
162
|
+
extensionNode && extensionNode.parameters && Object.keys(extensionNode.parameters).length > 0
|
|
163
|
+
? extensionNode.parameters
|
|
164
|
+
: parameters;
|
|
165
|
+
|
|
166
|
+
return (
|
|
167
|
+
<IntlProvider locale="en-AU">
|
|
168
|
+
<Box xcss={wrapperStyles}>
|
|
169
|
+
{/* eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766 */}
|
|
170
|
+
<div style={{ float: 'left' }} key="panel">
|
|
171
|
+
{extensionNode?.node && item && (
|
|
172
|
+
<ExtensionConfigPanel
|
|
173
|
+
key={hash}
|
|
174
|
+
extension={extensionNode.extension}
|
|
175
|
+
extensionProvider={extensionProvider}
|
|
176
|
+
nodeKey={nodeKey}
|
|
177
|
+
node={extensionNode.node}
|
|
178
|
+
item={item}
|
|
179
|
+
parameters={actualParameters}
|
|
180
|
+
/>
|
|
181
|
+
)}
|
|
182
|
+
</div>
|
|
183
|
+
{/* eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766 */}
|
|
184
|
+
<div style={{ float: 'right' }} key="picker">
|
|
185
|
+
<ExtensionNodePicker
|
|
186
|
+
selectedExtension={extensionKey}
|
|
187
|
+
selectedNode={nodeKey}
|
|
188
|
+
extensionProvider={extensionProvider}
|
|
189
|
+
onSelect={(params) => {
|
|
190
|
+
setNodeAndParameters(params);
|
|
191
|
+
setItem(params.item);
|
|
192
|
+
|
|
193
|
+
if (params.extension) {
|
|
194
|
+
const hash = `${params.extension.key}:${params.nodeKey}`;
|
|
195
|
+
addHashToTheUrl(hash);
|
|
196
|
+
setHash(hash);
|
|
197
|
+
}
|
|
198
|
+
}}
|
|
199
|
+
/>
|
|
200
|
+
</div>
|
|
201
|
+
</Box>
|
|
202
|
+
</IntlProvider>
|
|
203
|
+
);
|
|
218
204
|
}
|
|
@@ -3,49 +3,49 @@ import React from 'react';
|
|
|
3
3
|
import { IntlProvider } from 'react-intl-next';
|
|
4
4
|
|
|
5
5
|
import type {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
ExtensionKey,
|
|
7
|
+
ExtensionProvider,
|
|
8
|
+
ExtensionType,
|
|
9
|
+
Parameters,
|
|
10
10
|
} from '@atlaskit/editor-common/extensions';
|
|
11
11
|
|
|
12
12
|
import ConfigPanel from '../../src/ui/ConfigPanel';
|
|
13
13
|
|
|
14
14
|
export default function ConfigPanelWithProviders({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
extensionType,
|
|
16
|
+
extensionKey,
|
|
17
|
+
nodeKey,
|
|
18
|
+
extensionProvider,
|
|
19
|
+
parameters,
|
|
20
|
+
onChange,
|
|
21
21
|
}: {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
extensionType: ExtensionType;
|
|
23
|
+
extensionKey: ExtensionKey;
|
|
24
|
+
nodeKey: string;
|
|
25
|
+
extensionProvider: ExtensionProvider;
|
|
26
|
+
parameters: Parameters;
|
|
27
|
+
onChange?: (parameters: Parameters) => void;
|
|
28
28
|
}) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
function _onChange(data: Parameters) {
|
|
30
|
+
if (onChange) {
|
|
31
|
+
onChange(data);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
35
|
+
return (
|
|
36
|
+
<IntlProvider locale="en">
|
|
37
|
+
<ConfigPanel
|
|
38
|
+
api={undefined}
|
|
39
|
+
extensionType={extensionType}
|
|
40
|
+
extensionKey={extensionKey}
|
|
41
|
+
nodeKey={nodeKey}
|
|
42
|
+
extensionProvider={extensionProvider}
|
|
43
|
+
parameters={parameters}
|
|
44
|
+
showHeader
|
|
45
|
+
onChange={_onChange}
|
|
46
|
+
// eslint-disable-next-line no-console
|
|
47
|
+
onCancel={() => console.log('onCancel')}
|
|
48
|
+
/>
|
|
49
|
+
</IntlProvider>
|
|
50
|
+
);
|
|
51
51
|
}
|