datocms-plugin-sdk 0.3.34 → 0.5.0-alpha.0
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/dist/cjs/connect.js +19 -6
- package/dist/cjs/connect.js.map +1 -1
- package/dist/cjs/guards.js +3 -2
- package/dist/cjs/guards.js.map +1 -1
- package/dist/esm/connect.d.ts +32 -2
- package/dist/esm/connect.js +20 -7
- package/dist/esm/connect.js.map +1 -1
- package/dist/esm/guards.d.ts +5 -1
- package/dist/esm/guards.js +2 -1
- package/dist/esm/guards.js.map +1 -1
- package/dist/esm/types.d.ts +94 -7
- package/dist/types/connect.d.ts +32 -2
- package/dist/types/guards.d.ts +5 -1
- package/dist/types/types.d.ts +94 -7
- package/package.json +4 -2
- package/src/connect.ts +83 -4
- package/src/guards.ts +6 -1
- package/src/types.ts +106 -7
- package/types.json +3189 -2052
package/dist/types/types.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BlockNodeTypeWithCustomStyle } from 'datocms-structured-text-utils';
|
|
1
3
|
import { Account, Field, Fieldset, Item, ModelBlock, Plugin, Role, Site, SsoUser, Upload, User } from './SiteApiSchema';
|
|
2
4
|
export declare type Icon = string | {
|
|
3
5
|
type: 'svg';
|
|
@@ -32,7 +34,7 @@ export declare type MainNavigationTab = {
|
|
|
32
34
|
* be displayed by ascending `rank`. If you want to specify an explicit value
|
|
33
35
|
* for `rank`, make sure to offer a way for final users to customize it inside
|
|
34
36
|
* the plugin's settings form, otherwise the hardcoded value you choose might
|
|
35
|
-
* clash with the one of another plugin!
|
|
37
|
+
* clash with the one of another plugin!
|
|
36
38
|
*/
|
|
37
39
|
rank?: number;
|
|
38
40
|
};
|
|
@@ -76,7 +78,7 @@ export declare type SettingsAreaSidebarItemGroup = {
|
|
|
76
78
|
* will be displayed by ascending `rank`. If you want to specify an explicit
|
|
77
79
|
* value for `rank`, make sure to offer a way for final users to customize it
|
|
78
80
|
* inside the plugin's settings form, otherwise the hardcoded value you choose
|
|
79
|
-
* might clash with the one of another plugin!
|
|
81
|
+
* might clash with the one of another plugin!
|
|
80
82
|
*/
|
|
81
83
|
rank?: number;
|
|
82
84
|
};
|
|
@@ -109,7 +111,7 @@ export declare type ContentAreaSidebarItem = {
|
|
|
109
111
|
* will be displayed by ascending `rank`. If you want to specify an explicit
|
|
110
112
|
* value for `rank`, make sure to offer a way for final users to customize it
|
|
111
113
|
* inside the plugin's settings form, otherwise the hardcoded value you choose
|
|
112
|
-
* might clash with the one of another plugin!
|
|
114
|
+
* might clash with the one of another plugin!
|
|
113
115
|
*/
|
|
114
116
|
rank?: number;
|
|
115
117
|
};
|
|
@@ -190,7 +192,21 @@ export declare type ItemFormSidebarPanel = {
|
|
|
190
192
|
* sorted by ascending `rank`. If you want to specify an explicit value for
|
|
191
193
|
* `rank`, make sure to offer a way for final users to customize it inside the
|
|
192
194
|
* plugin's settings form, otherwise the hardcoded value you choose might
|
|
193
|
-
* clash with the one of another plugin!
|
|
195
|
+
* clash with the one of another plugin!
|
|
196
|
+
*/
|
|
197
|
+
rank?: number;
|
|
198
|
+
/** The initial height to set for the iframe that will render the sidebar panel */
|
|
199
|
+
initialHeight?: number;
|
|
200
|
+
};
|
|
201
|
+
/** An outlet to be shown at the top of a record's editing page */
|
|
202
|
+
export declare type ItemFormOutlet = {
|
|
203
|
+
/** ID of the outlet. Will be the first argument for the `renderItemFormOutlet` function */
|
|
204
|
+
id: string;
|
|
205
|
+
/**
|
|
206
|
+
* Multiple outlets will be sorted by ascending `rank`. If you want to specify
|
|
207
|
+
* an explicit value for `rank`, make sure to offer a way for final users to
|
|
208
|
+
* customize it inside the plugin's settings form, otherwise the hardcoded
|
|
209
|
+
* value you choose might clash with the one of another plugin!
|
|
194
210
|
*/
|
|
195
211
|
rank?: number;
|
|
196
212
|
/** The initial height to set for the iframe that will render the sidebar panel */
|
|
@@ -218,7 +234,7 @@ export declare type EditorOverride = {
|
|
|
218
234
|
* win. If you want to specify an explicit value for `rank`, make sure to
|
|
219
235
|
* offer a way for final users to customize it inside the plugin's settings
|
|
220
236
|
* form, otherwise the hardcoded value you choose might clash with the one of
|
|
221
|
-
* another plugin!
|
|
237
|
+
* another plugin!
|
|
222
238
|
*/
|
|
223
239
|
rank?: number;
|
|
224
240
|
/** The initial height to set for the iframe that will render the field extension */
|
|
@@ -241,12 +257,69 @@ export declare type AddonOverride = {
|
|
|
241
257
|
* ascending `rank`. If you want to specify an explicit value for `rank`, make
|
|
242
258
|
* sure to offer a way for final users to customize it inside the plugin's
|
|
243
259
|
* settings form, otherwise the hardcoded value you choose might clash with
|
|
244
|
-
* the one of another plugin!
|
|
260
|
+
* the one of another plugin!
|
|
245
261
|
*/
|
|
246
262
|
rank?: number;
|
|
247
263
|
/** The initial height to set for the iframe that will render the field extension */
|
|
248
264
|
initialHeight?: number;
|
|
249
265
|
};
|
|
266
|
+
export declare type StructuredTextCustomMarkPlacement = [
|
|
267
|
+
'before' | 'after',
|
|
268
|
+
'strong' | 'emphasis' | 'underline' | 'code' | 'highlight' | 'strikethrough'
|
|
269
|
+
];
|
|
270
|
+
/** An object expressing a custom mark for a Structured Text field */
|
|
271
|
+
export declare type StructuredTextCustomMark = {
|
|
272
|
+
/** ID of mark */
|
|
273
|
+
id: string;
|
|
274
|
+
/** Label representing the custom mark */
|
|
275
|
+
label: string;
|
|
276
|
+
/**
|
|
277
|
+
* Icon to be shown alongside the label. Can be a FontAwesome icon name (ie.
|
|
278
|
+
* `"address-book"`) or a custom SVG definition. To maintain visual
|
|
279
|
+
* consistency with the rest of the interface, try to use FontAwesome icons
|
|
280
|
+
* whenever possible
|
|
281
|
+
*/
|
|
282
|
+
icon: Icon;
|
|
283
|
+
/**
|
|
284
|
+
* Expresses where you want the custom mark button to be placed inside the
|
|
285
|
+
* toolbar. If not specified, the item will be placed after the standard marks
|
|
286
|
+
* provided by DatoCMS itself.
|
|
287
|
+
*/
|
|
288
|
+
placement?: StructuredTextCustomMarkPlacement;
|
|
289
|
+
/**
|
|
290
|
+
* If multiple custom marks specify the same `placement` for their toolbar
|
|
291
|
+
* button, they will be sorted by ascending `rank`. If you want to specify an
|
|
292
|
+
* explicit value for `rank`, make sure to offer a way for final users to
|
|
293
|
+
* customize it inside the plugin's settings form, otherwise the hardcoded
|
|
294
|
+
* value you choose might clash with the one of another plugin!
|
|
295
|
+
*/
|
|
296
|
+
rank?: number;
|
|
297
|
+
/**
|
|
298
|
+
* Keyboard shortcut associated with the custom mark, expressed using the
|
|
299
|
+
* https://github.com/ianstormtaylor/is-hotkey syntax (ie. `mod+shift+x`)
|
|
300
|
+
*/
|
|
301
|
+
keyboardShortcut?: string;
|
|
302
|
+
/** How the custom mark will be styled inside the editor */
|
|
303
|
+
appliedStyle: React.CSSProperties;
|
|
304
|
+
};
|
|
305
|
+
/** An object expressing a custom block style for a Structured Text field */
|
|
306
|
+
export declare type StructuredTextCustomBlockStyle = {
|
|
307
|
+
/** ID of custom block style */
|
|
308
|
+
id: string;
|
|
309
|
+
/** The block node that can apply this style */
|
|
310
|
+
node: BlockNodeTypeWithCustomStyle;
|
|
311
|
+
/** ID of custom block style */
|
|
312
|
+
label: string;
|
|
313
|
+
/** How the block will be styled inside the editor to represent the style */
|
|
314
|
+
appliedStyle: React.CSSProperties;
|
|
315
|
+
/**
|
|
316
|
+
* Custom styles for a block node will be sorted by ascending `rank`. If you
|
|
317
|
+
* want to specify an explicit value for `rank`, make sure to offer a way for
|
|
318
|
+
* final users to customize it inside the plugin's settings form, otherwise
|
|
319
|
+
* the hardcoded value you choose might clash with the one of another plugin!
|
|
320
|
+
*/
|
|
321
|
+
rank?: number;
|
|
322
|
+
};
|
|
250
323
|
/** An object expressing some field extensions you want to force on a particular field */
|
|
251
324
|
export declare type FieldExtensionOverride = {
|
|
252
325
|
/** Force a field editor/sidebar extension on a field */
|
|
@@ -1043,7 +1116,21 @@ export declare type RenderSidebarPanelAdditionalMethods = {
|
|
|
1043
1116
|
getSettings: () => Promise<RenderSidebarPanelProperties>;
|
|
1044
1117
|
};
|
|
1045
1118
|
export declare type RenderSidebarPanelMethods = ItemFormMethods & RenderSidebarPanelAdditionalMethods;
|
|
1046
|
-
export declare type
|
|
1119
|
+
export declare type RenderSidebarPanelPropertiesAndMethods = RenderSidebarPanelMethods & RenderSidebarPanelProperties;
|
|
1120
|
+
/** Information regarding the specific outlet that you need to render */
|
|
1121
|
+
export declare type RenderItemFormOutletAdditionalProperties = {
|
|
1122
|
+
mode: 'renderItemFormItemFormOutlet';
|
|
1123
|
+
/** The ID of the outlet that needs to be rendered */
|
|
1124
|
+
itemFormOutletId: string;
|
|
1125
|
+
/** The arbitrary `parameters` of the panel declared in the `itemFormOutlets` function */
|
|
1126
|
+
parameters: Record<string, unknown>;
|
|
1127
|
+
};
|
|
1128
|
+
export declare type RenderItemFormOutletProperties = ItemFormProperties & RenderItemFormOutletAdditionalProperties;
|
|
1129
|
+
export declare type RenderItemFormOutletAdditionalMethods = {
|
|
1130
|
+
getSettings: () => Promise<RenderItemFormOutletProperties>;
|
|
1131
|
+
};
|
|
1132
|
+
export declare type RenderItemFormOutletMethods = ItemFormMethods & RenderItemFormOutletAdditionalMethods;
|
|
1133
|
+
export declare type RenderItemFormOutletPropertiesAndMethods = RenderItemFormOutletMethods & RenderItemFormOutletProperties;
|
|
1047
1134
|
/**
|
|
1048
1135
|
* Information regarding the state of a specific field where you need to render
|
|
1049
1136
|
* the field extension
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "datocms-plugin-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-alpha.0",
|
|
4
4
|
"description": "DatoCMS Plugin SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datocms",
|
|
@@ -36,10 +36,12 @@
|
|
|
36
36
|
"url": "https://github.com/datocms/plugins-sdk/issues"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
+
"@types/react": "^17.0.3",
|
|
40
|
+
"datocms-structured-text-utils": "^2.0.0",
|
|
39
41
|
"penpal": "^4.1.1"
|
|
40
42
|
},
|
|
41
43
|
"devDependencies": {
|
|
42
44
|
"typedoc": "^0.22.8"
|
|
43
45
|
},
|
|
44
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "cbc2c3c6a3ce9438460435746cdd27e636ad261a"
|
|
45
47
|
}
|
package/src/connect.ts
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
RenderPageMethods,
|
|
24
24
|
RenderPagePropertiesAndMethods,
|
|
25
25
|
RenderSidebarPanelMethods,
|
|
26
|
-
|
|
26
|
+
RenderSidebarPanelPropertiesAndMethods,
|
|
27
27
|
SettingsAreaSidebarItemGroup,
|
|
28
28
|
} from './types';
|
|
29
29
|
import {
|
|
@@ -32,12 +32,20 @@ import {
|
|
|
32
32
|
isRenderAssetSourceParent,
|
|
33
33
|
isRenderConfigScreenParent,
|
|
34
34
|
isRenderFieldExtensionParent,
|
|
35
|
+
isRenderItemFormOutletParent,
|
|
35
36
|
isRenderManualFieldExtensionConfigScreenParent,
|
|
36
37
|
isRenderModalParent,
|
|
37
38
|
isRenderPageParent,
|
|
38
|
-
|
|
39
|
+
isRenderSidebarPanelParent,
|
|
39
40
|
Parent,
|
|
40
41
|
} from './guards';
|
|
42
|
+
import {
|
|
43
|
+
ItemFormOutlet,
|
|
44
|
+
RenderItemFormOutletMethods,
|
|
45
|
+
RenderItemFormOutletPropertiesAndMethods,
|
|
46
|
+
StructuredTextCustomBlockStyle,
|
|
47
|
+
StructuredTextCustomMark,
|
|
48
|
+
} from '.';
|
|
41
49
|
|
|
42
50
|
export type SizingUtilities = {
|
|
43
51
|
/**
|
|
@@ -67,7 +75,9 @@ export type RenderPageCtx = RenderPagePropertiesAndMethods;
|
|
|
67
75
|
export type RenderModalCtx = RenderModalPropertiesAndMethods & SizingUtilities;
|
|
68
76
|
export type RenderAssetSourceCtx = RenderAssetSourcePropertiesAndMethods &
|
|
69
77
|
SizingUtilities;
|
|
70
|
-
export type RenderItemFormSidebarPanelCtx =
|
|
78
|
+
export type RenderItemFormSidebarPanelCtx = RenderSidebarPanelPropertiesAndMethods &
|
|
79
|
+
SizingUtilities;
|
|
80
|
+
export type RenderItemFormOutletCtx = RenderItemFormOutletPropertiesAndMethods &
|
|
71
81
|
SizingUtilities;
|
|
72
82
|
export type RenderFieldExtensionCtx = RenderFieldExtensionPropertiesAndMethods &
|
|
73
83
|
SizingUtilities;
|
|
@@ -129,6 +139,15 @@ export type FullConnectParameters = {
|
|
|
129
139
|
itemType: ModelBlock,
|
|
130
140
|
ctx: IntentCtx,
|
|
131
141
|
) => ItemFormSidebarPanel[];
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Use this function to declare custom outlets to be shown at the top of the
|
|
145
|
+
* record's editing page
|
|
146
|
+
*
|
|
147
|
+
* @group sidebarPanels
|
|
148
|
+
*/
|
|
149
|
+
itemFormOutlets: (itemType: ModelBlock, ctx: IntentCtx) => ItemFormOutlet[];
|
|
150
|
+
|
|
132
151
|
/**
|
|
133
152
|
* Use this function to automatically force one or more field extensions to a
|
|
134
153
|
* particular field
|
|
@@ -139,6 +158,29 @@ export type FullConnectParameters = {
|
|
|
139
158
|
field: Field,
|
|
140
159
|
ctx: FieldIntentCtx,
|
|
141
160
|
) => FieldExtensionOverride | void;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Use this function to define a number of custom marks for a specific
|
|
164
|
+
* Structured Text field
|
|
165
|
+
*
|
|
166
|
+
* @group structuredText
|
|
167
|
+
*/
|
|
168
|
+
customMarksForStructuredTextField: (
|
|
169
|
+
field: Field,
|
|
170
|
+
ctx: FieldIntentCtx,
|
|
171
|
+
) => StructuredTextCustomMark[] | void;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Use this function to define a number of custom block styles for a specific
|
|
175
|
+
* Structured Text field
|
|
176
|
+
*
|
|
177
|
+
* @group structuredText
|
|
178
|
+
*/
|
|
179
|
+
customBlockStylesForStructuredTextField: (
|
|
180
|
+
field: Field,
|
|
181
|
+
ctx: FieldIntentCtx,
|
|
182
|
+
) => StructuredTextCustomBlockStyle[] | void;
|
|
183
|
+
|
|
142
184
|
/**
|
|
143
185
|
* This function will be called when the plugin needs to render the plugin's
|
|
144
186
|
* configuration form
|
|
@@ -171,6 +213,16 @@ export type FullConnectParameters = {
|
|
|
171
213
|
sidebarPaneId: string,
|
|
172
214
|
ctx: RenderItemFormSidebarPanelCtx,
|
|
173
215
|
) => void;
|
|
216
|
+
/**
|
|
217
|
+
* This function will be called when the plugin needs to render an outlet (see
|
|
218
|
+
* the `itemFormOutlets` function)
|
|
219
|
+
*
|
|
220
|
+
* @group sidebarPanels
|
|
221
|
+
*/
|
|
222
|
+
renderItemFormOutlet: (
|
|
223
|
+
itemFormOutletId: string,
|
|
224
|
+
ctx: RenderItemFormOutletCtx,
|
|
225
|
+
) => void;
|
|
174
226
|
/**
|
|
175
227
|
* This function will be called when the user selects one of the plugin's
|
|
176
228
|
* asset sources to upload a new media file.
|
|
@@ -341,6 +393,12 @@ export async function connect(
|
|
|
341
393
|
overrideFieldExtensions: toMultifield(
|
|
342
394
|
configuration.overrideFieldExtensions,
|
|
343
395
|
),
|
|
396
|
+
customMarksForStructuredTextField: toMultifield(
|
|
397
|
+
configuration.customMarksForStructuredTextField,
|
|
398
|
+
),
|
|
399
|
+
customBlockStylesForStructuredTextField: toMultifield(
|
|
400
|
+
configuration.customBlockStylesForStructuredTextField,
|
|
401
|
+
),
|
|
344
402
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
345
403
|
onChange(newSettings: any) {
|
|
346
404
|
if (listener) {
|
|
@@ -457,7 +515,7 @@ export async function connect(
|
|
|
457
515
|
render(initialSettings as Settings);
|
|
458
516
|
}
|
|
459
517
|
|
|
460
|
-
if (
|
|
518
|
+
if (isRenderSidebarPanelParent(parent, initialSettings)) {
|
|
461
519
|
type Settings = AsyncReturnType<RenderSidebarPanelMethods['getSettings']>;
|
|
462
520
|
|
|
463
521
|
const renderUtils = buildRenderUtils(parent);
|
|
@@ -478,6 +536,27 @@ export async function connect(
|
|
|
478
536
|
render(initialSettings as Settings);
|
|
479
537
|
}
|
|
480
538
|
|
|
539
|
+
if (isRenderItemFormOutletParent(parent, initialSettings)) {
|
|
540
|
+
type Settings = AsyncReturnType<RenderItemFormOutletMethods['getSettings']>;
|
|
541
|
+
|
|
542
|
+
const renderUtils = buildRenderUtils(parent);
|
|
543
|
+
|
|
544
|
+
const render = (settings: Settings) => {
|
|
545
|
+
if (!configuration.renderItemFormOutlet) {
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
configuration.renderItemFormOutlet(settings.itemFormOutletId, {
|
|
550
|
+
...parent,
|
|
551
|
+
...settings,
|
|
552
|
+
...renderUtils,
|
|
553
|
+
});
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
listener = render;
|
|
557
|
+
render(initialSettings as Settings);
|
|
558
|
+
}
|
|
559
|
+
|
|
481
560
|
if (isRenderFieldExtensionParent(parent, initialSettings)) {
|
|
482
561
|
type Settings = AsyncReturnType<RenderFieldExtensionMethods['getSettings']>;
|
|
483
562
|
|
package/src/guards.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RenderItemFormOutletMethods } from '.';
|
|
1
2
|
import {
|
|
2
3
|
InitMethods,
|
|
3
4
|
OnBootMethods,
|
|
@@ -31,10 +32,14 @@ export const isRenderModalParent = buildGuard<RenderModalMethods>(
|
|
|
31
32
|
'renderModal',
|
|
32
33
|
);
|
|
33
34
|
|
|
34
|
-
export const
|
|
35
|
+
export const isRenderSidebarPanelParent = buildGuard<RenderSidebarPanelMethods>(
|
|
35
36
|
'renderItemFormSidebarPanel',
|
|
36
37
|
);
|
|
37
38
|
|
|
39
|
+
export const isRenderItemFormOutletParent = buildGuard<RenderItemFormOutletMethods>(
|
|
40
|
+
'renderItemFormOutlet',
|
|
41
|
+
);
|
|
42
|
+
|
|
38
43
|
export const isRenderFieldExtensionParent = buildGuard<RenderFieldExtensionMethods>(
|
|
39
44
|
'renderFieldExtension',
|
|
40
45
|
);
|
package/src/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { BlockNodeTypeWithCustomStyle } from 'datocms-structured-text-utils';
|
|
2
|
+
|
|
1
3
|
import {
|
|
2
4
|
Account,
|
|
3
5
|
Field,
|
|
@@ -42,7 +44,7 @@ export type MainNavigationTab = {
|
|
|
42
44
|
* be displayed by ascending `rank`. If you want to specify an explicit value
|
|
43
45
|
* for `rank`, make sure to offer a way for final users to customize it inside
|
|
44
46
|
* the plugin's settings form, otherwise the hardcoded value you choose might
|
|
45
|
-
* clash with the one of another plugin!
|
|
47
|
+
* clash with the one of another plugin!
|
|
46
48
|
*/
|
|
47
49
|
rank?: number;
|
|
48
50
|
};
|
|
@@ -97,7 +99,7 @@ export type SettingsAreaSidebarItemGroup = {
|
|
|
97
99
|
* will be displayed by ascending `rank`. If you want to specify an explicit
|
|
98
100
|
* value for `rank`, make sure to offer a way for final users to customize it
|
|
99
101
|
* inside the plugin's settings form, otherwise the hardcoded value you choose
|
|
100
|
-
* might clash with the one of another plugin!
|
|
102
|
+
* might clash with the one of another plugin!
|
|
101
103
|
*/
|
|
102
104
|
rank?: number;
|
|
103
105
|
};
|
|
@@ -131,7 +133,7 @@ export type ContentAreaSidebarItem = {
|
|
|
131
133
|
* will be displayed by ascending `rank`. If you want to specify an explicit
|
|
132
134
|
* value for `rank`, make sure to offer a way for final users to customize it
|
|
133
135
|
* inside the plugin's settings form, otherwise the hardcoded value you choose
|
|
134
|
-
* might clash with the one of another plugin!
|
|
136
|
+
* might clash with the one of another plugin!
|
|
135
137
|
*/
|
|
136
138
|
rank?: number;
|
|
137
139
|
};
|
|
@@ -232,7 +234,22 @@ export type ItemFormSidebarPanel = {
|
|
|
232
234
|
* sorted by ascending `rank`. If you want to specify an explicit value for
|
|
233
235
|
* `rank`, make sure to offer a way for final users to customize it inside the
|
|
234
236
|
* plugin's settings form, otherwise the hardcoded value you choose might
|
|
235
|
-
* clash with the one of another plugin!
|
|
237
|
+
* clash with the one of another plugin!
|
|
238
|
+
*/
|
|
239
|
+
rank?: number;
|
|
240
|
+
/** The initial height to set for the iframe that will render the sidebar panel */
|
|
241
|
+
initialHeight?: number;
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
/** An outlet to be shown at the top of a record's editing page */
|
|
245
|
+
export type ItemFormOutlet = {
|
|
246
|
+
/** ID of the outlet. Will be the first argument for the `renderItemFormOutlet` function */
|
|
247
|
+
id: string;
|
|
248
|
+
/**
|
|
249
|
+
* Multiple outlets will be sorted by ascending `rank`. If you want to specify
|
|
250
|
+
* an explicit value for `rank`, make sure to offer a way for final users to
|
|
251
|
+
* customize it inside the plugin's settings form, otherwise the hardcoded
|
|
252
|
+
* value you choose might clash with the one of another plugin!
|
|
236
253
|
*/
|
|
237
254
|
rank?: number;
|
|
238
255
|
/** The initial height to set for the iframe that will render the sidebar panel */
|
|
@@ -260,7 +277,7 @@ export type EditorOverride = {
|
|
|
260
277
|
* win. If you want to specify an explicit value for `rank`, make sure to
|
|
261
278
|
* offer a way for final users to customize it inside the plugin's settings
|
|
262
279
|
* form, otherwise the hardcoded value you choose might clash with the one of
|
|
263
|
-
* another plugin!
|
|
280
|
+
* another plugin!
|
|
264
281
|
*/
|
|
265
282
|
rank?: number;
|
|
266
283
|
/** The initial height to set for the iframe that will render the field extension */
|
|
@@ -284,13 +301,73 @@ export type AddonOverride = {
|
|
|
284
301
|
* ascending `rank`. If you want to specify an explicit value for `rank`, make
|
|
285
302
|
* sure to offer a way for final users to customize it inside the plugin's
|
|
286
303
|
* settings form, otherwise the hardcoded value you choose might clash with
|
|
287
|
-
* the one of another plugin!
|
|
304
|
+
* the one of another plugin!
|
|
288
305
|
*/
|
|
289
306
|
rank?: number;
|
|
290
307
|
/** The initial height to set for the iframe that will render the field extension */
|
|
291
308
|
initialHeight?: number;
|
|
292
309
|
};
|
|
293
310
|
|
|
311
|
+
export type StructuredTextCustomMarkPlacement = [
|
|
312
|
+
'before' | 'after',
|
|
313
|
+
'strong' | 'emphasis' | 'underline' | 'code' | 'highlight' | 'strikethrough',
|
|
314
|
+
];
|
|
315
|
+
|
|
316
|
+
/** An object expressing a custom mark for a Structured Text field */
|
|
317
|
+
export type StructuredTextCustomMark = {
|
|
318
|
+
/** ID of mark */
|
|
319
|
+
id: string;
|
|
320
|
+
/** Label representing the custom mark */
|
|
321
|
+
label: string;
|
|
322
|
+
/**
|
|
323
|
+
* Icon to be shown alongside the label. Can be a FontAwesome icon name (ie.
|
|
324
|
+
* `"address-book"`) or a custom SVG definition. To maintain visual
|
|
325
|
+
* consistency with the rest of the interface, try to use FontAwesome icons
|
|
326
|
+
* whenever possible
|
|
327
|
+
*/
|
|
328
|
+
icon: Icon;
|
|
329
|
+
/**
|
|
330
|
+
* Expresses where you want the custom mark button to be placed inside the
|
|
331
|
+
* toolbar. If not specified, the item will be placed after the standard marks
|
|
332
|
+
* provided by DatoCMS itself.
|
|
333
|
+
*/
|
|
334
|
+
placement?: StructuredTextCustomMarkPlacement;
|
|
335
|
+
/**
|
|
336
|
+
* If multiple custom marks specify the same `placement` for their toolbar
|
|
337
|
+
* button, they will be sorted by ascending `rank`. If you want to specify an
|
|
338
|
+
* explicit value for `rank`, make sure to offer a way for final users to
|
|
339
|
+
* customize it inside the plugin's settings form, otherwise the hardcoded
|
|
340
|
+
* value you choose might clash with the one of another plugin!
|
|
341
|
+
*/
|
|
342
|
+
rank?: number;
|
|
343
|
+
/**
|
|
344
|
+
* Keyboard shortcut associated with the custom mark, expressed using the
|
|
345
|
+
* https://github.com/ianstormtaylor/is-hotkey syntax (ie. `mod+shift+x`)
|
|
346
|
+
*/
|
|
347
|
+
keyboardShortcut?: string;
|
|
348
|
+
/** How the custom mark will be styled inside the editor */
|
|
349
|
+
appliedStyle: React.CSSProperties;
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
/** An object expressing a custom block style for a Structured Text field */
|
|
353
|
+
export type StructuredTextCustomBlockStyle = {
|
|
354
|
+
/** ID of custom block style */
|
|
355
|
+
id: string;
|
|
356
|
+
/** The block node that can apply this style */
|
|
357
|
+
node: BlockNodeTypeWithCustomStyle;
|
|
358
|
+
/** ID of custom block style */
|
|
359
|
+
label: string;
|
|
360
|
+
/** How the block will be styled inside the editor to represent the style */
|
|
361
|
+
appliedStyle: React.CSSProperties;
|
|
362
|
+
/**
|
|
363
|
+
* Custom styles for a block node will be sorted by ascending `rank`. If you
|
|
364
|
+
* want to specify an explicit value for `rank`, make sure to offer a way for
|
|
365
|
+
* final users to customize it inside the plugin's settings form, otherwise
|
|
366
|
+
* the hardcoded value you choose might clash with the one of another plugin!
|
|
367
|
+
*/
|
|
368
|
+
rank?: number;
|
|
369
|
+
};
|
|
370
|
+
|
|
294
371
|
/** An object expressing some field extensions you want to force on a particular field */
|
|
295
372
|
export type FieldExtensionOverride = {
|
|
296
373
|
/** Force a field editor/sidebar extension on a field */
|
|
@@ -1140,9 +1217,31 @@ export type RenderSidebarPanelAdditionalMethods = {
|
|
|
1140
1217
|
export type RenderSidebarPanelMethods = ItemFormMethods &
|
|
1141
1218
|
RenderSidebarPanelAdditionalMethods;
|
|
1142
1219
|
|
|
1143
|
-
export type
|
|
1220
|
+
export type RenderSidebarPanelPropertiesAndMethods = RenderSidebarPanelMethods &
|
|
1144
1221
|
RenderSidebarPanelProperties;
|
|
1145
1222
|
|
|
1223
|
+
/** Information regarding the specific outlet that you need to render */
|
|
1224
|
+
export type RenderItemFormOutletAdditionalProperties = {
|
|
1225
|
+
mode: 'renderItemFormItemFormOutlet';
|
|
1226
|
+
/** The ID of the outlet that needs to be rendered */
|
|
1227
|
+
itemFormOutletId: string;
|
|
1228
|
+
/** The arbitrary `parameters` of the panel declared in the `itemFormOutlets` function */
|
|
1229
|
+
parameters: Record<string, unknown>;
|
|
1230
|
+
};
|
|
1231
|
+
|
|
1232
|
+
export type RenderItemFormOutletProperties = ItemFormProperties &
|
|
1233
|
+
RenderItemFormOutletAdditionalProperties;
|
|
1234
|
+
|
|
1235
|
+
export type RenderItemFormOutletAdditionalMethods = {
|
|
1236
|
+
getSettings: () => Promise<RenderItemFormOutletProperties>;
|
|
1237
|
+
};
|
|
1238
|
+
|
|
1239
|
+
export type RenderItemFormOutletMethods = ItemFormMethods &
|
|
1240
|
+
RenderItemFormOutletAdditionalMethods;
|
|
1241
|
+
|
|
1242
|
+
export type RenderItemFormOutletPropertiesAndMethods = RenderItemFormOutletMethods &
|
|
1243
|
+
RenderItemFormOutletProperties;
|
|
1244
|
+
|
|
1146
1245
|
/**
|
|
1147
1246
|
* Information regarding the state of a specific field where you need to render
|
|
1148
1247
|
* the field extension
|