datocms-plugin-sdk 0.3.20 → 0.3.24-alpha.5
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 +20 -8
- package/dist/cjs/connect.js.map +1 -1
- package/dist/cjs/guards.js +2 -1
- package/dist/cjs/guards.js.map +1 -1
- package/dist/esm/connect.d.ts +45 -26
- package/dist/esm/connect.js +21 -9
- package/dist/esm/connect.js.map +1 -1
- package/dist/esm/guards.d.ts +4 -1
- package/dist/esm/guards.js +1 -0
- package/dist/esm/guards.js.map +1 -1
- package/dist/esm/types.d.ts +130 -7
- package/dist/types/connect.d.ts +45 -26
- package/dist/types/guards.d.ts +4 -1
- package/dist/types/types.d.ts +130 -7
- package/package.json +2 -2
- package/types.json +2787 -1586
package/dist/cjs/connect.js
CHANGED
|
@@ -111,11 +111,11 @@ var buildRenderUtils = function (parent) {
|
|
|
111
111
|
function connect(configuration) {
|
|
112
112
|
if (configuration === void 0) { configuration = {}; }
|
|
113
113
|
return __awaiter(this, void 0, void 0, function () {
|
|
114
|
-
var mainNavigationTabs, settingsAreaSidebarItemGroups, contentAreaSidebarItems, manualFieldExtensions, itemFormSidebarPanels, listener, penpalConnection, parent, initialSettings, render, render, renderUtils_1, render, renderUtils_2, render, renderUtils_3, render, renderUtils_4, render, renderUtils_5, render;
|
|
114
|
+
var assetSources, mainNavigationTabs, settingsAreaSidebarItemGroups, contentAreaSidebarItems, manualFieldExtensions, itemFormSidebarPanels, listener, penpalConnection, parent, initialSettings, render, render, renderUtils_1, render, renderUtils_2, render, renderUtils_3, render, renderUtils_4, render, renderUtils_5, render, renderUtils_6, render;
|
|
115
115
|
return __generator(this, function (_a) {
|
|
116
116
|
switch (_a.label) {
|
|
117
117
|
case 0:
|
|
118
|
-
mainNavigationTabs = configuration.mainNavigationTabs, settingsAreaSidebarItemGroups = configuration.settingsAreaSidebarItemGroups, contentAreaSidebarItems = configuration.contentAreaSidebarItems, manualFieldExtensions = configuration.manualFieldExtensions, itemFormSidebarPanels = configuration.itemFormSidebarPanels;
|
|
118
|
+
assetSources = configuration.assetSources, mainNavigationTabs = configuration.mainNavigationTabs, settingsAreaSidebarItemGroups = configuration.settingsAreaSidebarItemGroups, contentAreaSidebarItems = configuration.contentAreaSidebarItems, manualFieldExtensions = configuration.manualFieldExtensions, itemFormSidebarPanels = configuration.itemFormSidebarPanels;
|
|
119
119
|
listener = null;
|
|
120
120
|
penpalConnection = (0, connectToParent_1.default)({
|
|
121
121
|
methods: {
|
|
@@ -129,6 +129,7 @@ function connect(configuration) {
|
|
|
129
129
|
return [key, value];
|
|
130
130
|
}));
|
|
131
131
|
},
|
|
132
|
+
assetSources: assetSources,
|
|
132
133
|
mainNavigationTabs: mainNavigationTabs,
|
|
133
134
|
settingsAreaSidebarItemGroups: settingsAreaSidebarItemGroups,
|
|
134
135
|
contentAreaSidebarItems: contentAreaSidebarItems,
|
|
@@ -194,35 +195,46 @@ function connect(configuration) {
|
|
|
194
195
|
listener = render;
|
|
195
196
|
render(initialSettings);
|
|
196
197
|
}
|
|
197
|
-
if ((0, guards_1.
|
|
198
|
+
if ((0, guards_1.isRenderAssetSourceParent)(parent, initialSettings)) {
|
|
198
199
|
renderUtils_3 = buildRenderUtils(parent);
|
|
200
|
+
render = function (settings) {
|
|
201
|
+
if (!configuration.renderAssetSource) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
configuration.renderAssetSource(settings.assetSourceId, __assign(__assign(__assign({}, parent), settings), renderUtils_3));
|
|
205
|
+
};
|
|
206
|
+
listener = render;
|
|
207
|
+
render(initialSettings);
|
|
208
|
+
}
|
|
209
|
+
if ((0, guards_1.isRenderSidebarPaneParent)(parent, initialSettings)) {
|
|
210
|
+
renderUtils_4 = buildRenderUtils(parent);
|
|
199
211
|
render = function (settings) {
|
|
200
212
|
if (!configuration.renderItemFormSidebarPanel) {
|
|
201
213
|
return;
|
|
202
214
|
}
|
|
203
|
-
configuration.renderItemFormSidebarPanel(settings.sidebarPaneId, __assign(__assign(__assign({}, parent), settings),
|
|
215
|
+
configuration.renderItemFormSidebarPanel(settings.sidebarPaneId, __assign(__assign(__assign({}, parent), settings), renderUtils_4));
|
|
204
216
|
};
|
|
205
217
|
listener = render;
|
|
206
218
|
render(initialSettings);
|
|
207
219
|
}
|
|
208
220
|
if ((0, guards_1.isRenderFieldExtensionParent)(parent, initialSettings)) {
|
|
209
|
-
|
|
221
|
+
renderUtils_5 = buildRenderUtils(parent);
|
|
210
222
|
render = function (settings) {
|
|
211
223
|
if (!configuration.renderFieldExtension) {
|
|
212
224
|
return;
|
|
213
225
|
}
|
|
214
|
-
configuration.renderFieldExtension(settings.fieldExtensionId, __assign(__assign(__assign({}, parent), settings),
|
|
226
|
+
configuration.renderFieldExtension(settings.fieldExtensionId, __assign(__assign(__assign({}, parent), settings), renderUtils_5));
|
|
215
227
|
};
|
|
216
228
|
listener = render;
|
|
217
229
|
render(initialSettings);
|
|
218
230
|
}
|
|
219
231
|
if ((0, guards_1.isRenderManualFieldExtensionConfigScreenParent)(parent, initialSettings)) {
|
|
220
|
-
|
|
232
|
+
renderUtils_6 = buildRenderUtils(parent);
|
|
221
233
|
render = function (settings) {
|
|
222
234
|
if (!configuration.renderManualFieldExtensionConfigScreen) {
|
|
223
235
|
return;
|
|
224
236
|
}
|
|
225
|
-
configuration.renderManualFieldExtensionConfigScreen(settings.fieldExtensionId, __assign(__assign(__assign({}, parent), settings),
|
|
237
|
+
configuration.renderManualFieldExtensionConfigScreen(settings.fieldExtensionId, __assign(__assign(__assign({}, parent), settings), renderUtils_6));
|
|
226
238
|
};
|
|
227
239
|
listener = render;
|
|
228
240
|
render(initialSettings);
|
package/dist/cjs/connect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../src/connect.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AE,eAAe,CAAC,EAAE;wBAKrE,gBAAc,gBAAgB,CAAC,MAAM,CAAC,CAAC;wBAEvC,MAAM,GAAG,UAAC,QAAkB;4BAChC,IAAI,CAAC,aAAa,CAAC,sCAAsC,EAAE;gCACzD,OAAO;6BACR;4BAED,aAAa,CAAC,sCAAsC,CAClD,QAAQ,CAAC,gBAAgB,iCAEpB,MAAM,GACN,QAAQ,GACR,aAAW,EAEjB,CAAC;wBACJ,CAAC,CAAC;wBAEF,QAAQ,GAAG,MAAM,CAAC;wBAClB,MAAM,CAAC,eAA2B,CAAC,CAAC;qBACrC;;;;;CACF;AA5ND,0BA4NC"}
|
package/dist/cjs/guards.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isRenderManualFieldExtensionConfigScreenParent = exports.isRenderFieldExtensionParent = exports.isRenderSidebarPaneParent = exports.isRenderModalParent = exports.isRenderConfigScreenParent = exports.isRenderPageParent = exports.isOnBootParent = exports.isInitParent = void 0;
|
|
3
|
+
exports.isRenderAssetSourceParent = exports.isRenderManualFieldExtensionConfigScreenParent = exports.isRenderFieldExtensionParent = exports.isRenderSidebarPaneParent = exports.isRenderModalParent = exports.isRenderConfigScreenParent = exports.isRenderPageParent = exports.isOnBootParent = exports.isInitParent = void 0;
|
|
4
4
|
function buildGuard(mode) {
|
|
5
5
|
return function (parent, settings) {
|
|
6
6
|
return settings.mode === mode;
|
|
@@ -14,4 +14,5 @@ exports.isRenderModalParent = buildGuard('renderModal');
|
|
|
14
14
|
exports.isRenderSidebarPaneParent = buildGuard('renderItemFormSidebarPanel');
|
|
15
15
|
exports.isRenderFieldExtensionParent = buildGuard('renderFieldExtension');
|
|
16
16
|
exports.isRenderManualFieldExtensionConfigScreenParent = buildGuard('renderManualFieldExtensionConfigScreen');
|
|
17
|
+
exports.isRenderAssetSourceParent = buildGuard('renderAssetSource');
|
|
17
18
|
//# sourceMappingURL=guards.js.map
|
package/dist/cjs/guards.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../src/guards.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../src/guards.ts"],"names":[],"mappings":";;;AAcA,SAAS,UAAU,CAAmB,IAAY;IAChD,OAAO,UAAC,MAAc,EAAE,QAA0B;QAChD,OAAA,QAAQ,CAAC,IAAI,KAAK,IAAI;IAAtB,CAAsB,CAAC;AAC3B,CAAC;AAEY,QAAA,YAAY,GAAG,UAAU,CAAc,MAAM,CAAC,CAAC;AAE/C,QAAA,cAAc,GAAG,UAAU,CAAgB,QAAQ,CAAC,CAAC;AAErD,QAAA,kBAAkB,GAAG,UAAU,CAAoB,YAAY,CAAC,CAAC;AAEjE,QAAA,0BAA0B,GAAG,UAAU,CAClD,oBAAoB,CACrB,CAAC;AAEW,QAAA,mBAAmB,GAAG,UAAU,CAC3C,aAAa,CACd,CAAC;AAEW,QAAA,yBAAyB,GAAG,UAAU,CACjD,4BAA4B,CAC7B,CAAC;AAEW,QAAA,4BAA4B,GAAG,UAAU,CACpD,sBAAsB,CACvB,CAAC;AAEW,QAAA,8CAA8C,GAAG,UAAU,CACtE,wCAAwC,CACzC,CAAC;AAEW,QAAA,yBAAyB,GAAG,UAAU,CACjD,mBAAmB,CACpB,CAAC"}
|
package/dist/esm/connect.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { Field, ModelBlock } from './SiteApiSchema';
|
|
2
|
-
import { ContentAreaSidebarItem, FieldExtensionOverride, InitPropertiesAndMethods, ItemFormSidebarPanel, MainNavigationTab, ManualFieldExtension, OnBootPropertiesAndMethods, RenderConfigScreenPropertiesAndMethods, RenderFieldExtensionPropertiesAndMethods, RenderManualFieldExtensionConfigScreenPropertiesAndMethods, RenderModalPropertiesAndMethods, RenderPagePropertiesAndMethods, RenderSidebarPanePropertiesAndMethods, SettingsAreaSidebarItemGroup } from './types';
|
|
2
|
+
import { AssetSource, ContentAreaSidebarItem, FieldExtensionOverride, InitPropertiesAndMethods, ItemFormSidebarPanel, MainNavigationTab, ManualFieldExtension, OnBootPropertiesAndMethods, RenderAssetSourcePropertiesAndMethods, RenderConfigScreenPropertiesAndMethods, RenderFieldExtensionPropertiesAndMethods, RenderManualFieldExtensionConfigScreenPropertiesAndMethods, RenderModalPropertiesAndMethods, RenderPagePropertiesAndMethods, RenderSidebarPanePropertiesAndMethods, SettingsAreaSidebarItemGroup } from './types';
|
|
3
3
|
export declare type SizingUtilities = {
|
|
4
4
|
/**
|
|
5
|
-
* Listens for DOM changes and automatically calls `setHeight` when it detects
|
|
6
|
-
* If you're using `datocms-react-ui` package, the `<Canvas />`
|
|
7
|
-
* care of calling this method for you.
|
|
5
|
+
* Listens for DOM changes and automatically calls `setHeight` when it detects
|
|
6
|
+
* a change. If you're using `datocms-react-ui` package, the `<Canvas />`
|
|
7
|
+
* component already takes care of calling this method for you.
|
|
8
8
|
*/
|
|
9
9
|
startAutoResizer: () => void;
|
|
10
10
|
/** Stops resizing the iframe automatically */
|
|
11
11
|
stopAutoResizer: () => void;
|
|
12
12
|
/**
|
|
13
|
-
* Triggers a change in the size of the iframe. If you don't explicitely pass
|
|
14
|
-
* `newHeight` it will be automatically calculated using the iframe content
|
|
13
|
+
* Triggers a change in the size of the iframe. If you don't explicitely pass
|
|
14
|
+
* a `newHeight` it will be automatically calculated using the iframe content
|
|
15
|
+
* at the moment
|
|
15
16
|
*/
|
|
16
17
|
updateHeight: (newHeight?: number) => void;
|
|
17
18
|
};
|
|
@@ -23,6 +24,7 @@ export declare type FieldIntentCtx = InitPropertiesAndMethods & {
|
|
|
23
24
|
};
|
|
24
25
|
export declare type RenderPageCtx = RenderPagePropertiesAndMethods;
|
|
25
26
|
export declare type RenderModalCtx = RenderModalPropertiesAndMethods & SizingUtilities;
|
|
27
|
+
export declare type RenderAssetSourceCtx = RenderAssetSourcePropertiesAndMethods & SizingUtilities;
|
|
26
28
|
export declare type RenderItemFormSidebarPanelCtx = RenderSidebarPanePropertiesAndMethods & SizingUtilities;
|
|
27
29
|
export declare type RenderFieldExtensionCtx = RenderFieldExtensionPropertiesAndMethods & SizingUtilities;
|
|
28
30
|
export declare type RenderManualFieldExtensionConfigScreenCtx = RenderManualFieldExtensionConfigScreenPropertiesAndMethods & SizingUtilities;
|
|
@@ -30,8 +32,8 @@ export declare type RenderConfigScreenCtx = RenderConfigScreenPropertiesAndMetho
|
|
|
30
32
|
/** The full options you can pass to the `connect` function */
|
|
31
33
|
export declare type FullConnectParameters = {
|
|
32
34
|
/**
|
|
33
|
-
* This function will be called once at boot time and can be used to perform
|
|
34
|
-
* initial integrity checks on the configuration.
|
|
35
|
+
* This function will be called once at boot time and can be used to perform
|
|
36
|
+
* ie. some initial integrity checks on the configuration.
|
|
35
37
|
*
|
|
36
38
|
* @group boot
|
|
37
39
|
*/
|
|
@@ -55,69 +57,86 @@ export declare type FullConnectParameters = {
|
|
|
55
57
|
*/
|
|
56
58
|
contentAreaSidebarItems: (ctx: IntentCtx) => ContentAreaSidebarItem[];
|
|
57
59
|
/**
|
|
58
|
-
* Use this function to declare new field extensions that users will be able
|
|
59
|
-
* manually in some field
|
|
60
|
+
* Use this function to declare new field extensions that users will be able
|
|
61
|
+
* to install manually in some field
|
|
60
62
|
*
|
|
61
63
|
* @group manualFieldExtensions
|
|
62
64
|
*/
|
|
63
65
|
manualFieldExtensions: (ctx: IntentCtx) => ManualFieldExtension[];
|
|
64
66
|
/**
|
|
65
|
-
* Use this function to declare
|
|
66
|
-
*
|
|
67
|
+
* Use this function to declare additional sources to be shown when users want
|
|
68
|
+
* to upload new assets
|
|
69
|
+
*
|
|
70
|
+
* @group assetSources
|
|
71
|
+
*/
|
|
72
|
+
assetSources: (ctx: IntentCtx) => AssetSource[] | void;
|
|
73
|
+
/**
|
|
74
|
+
* Use this function to declare new sidebar panels to be shown when the user
|
|
75
|
+
* edits records of a particular model
|
|
67
76
|
*
|
|
68
77
|
* @group sidebarPanels
|
|
69
78
|
*/
|
|
70
79
|
itemFormSidebarPanels: (itemType: ModelBlock, ctx: IntentCtx) => ItemFormSidebarPanel[];
|
|
71
80
|
/**
|
|
72
|
-
* Use this function to automatically force one or more field extensions to a
|
|
81
|
+
* Use this function to automatically force one or more field extensions to a
|
|
82
|
+
* particular field
|
|
73
83
|
*
|
|
74
84
|
* @group forcedFieldExtensions
|
|
75
85
|
*/
|
|
76
86
|
overrideFieldExtensions: (field: Field, ctx: FieldIntentCtx) => FieldExtensionOverride | void;
|
|
77
87
|
/**
|
|
78
|
-
* This function will be called when the plugin needs to render the plugin's
|
|
88
|
+
* This function will be called when the plugin needs to render the plugin's
|
|
89
|
+
* configuration form
|
|
79
90
|
*
|
|
80
91
|
* @group configScreen
|
|
81
92
|
*/
|
|
82
93
|
renderConfigScreen: (ctx: RenderConfigScreenCtx) => void;
|
|
83
94
|
/**
|
|
84
|
-
* This function will be called when the plugin needs to render a specific
|
|
85
|
-
* `mainNavigationTabs`, `settingsAreaSidebarItemGroups` and
|
|
95
|
+
* This function will be called when the plugin needs to render a specific
|
|
96
|
+
* page (see the `mainNavigationTabs`, `settingsAreaSidebarItemGroups` and
|
|
97
|
+
* `contentAreaSidebarItems` functions)
|
|
86
98
|
*
|
|
87
99
|
* @group pages
|
|
88
100
|
*/
|
|
89
101
|
renderPage: (pageId: string, ctx: RenderPageCtx) => void;
|
|
90
102
|
/**
|
|
91
|
-
* This function will be called when the plugin requested to open a modal (see
|
|
92
|
-
* `openModal` function)
|
|
103
|
+
* This function will be called when the plugin requested to open a modal (see
|
|
104
|
+
* the `openModal` function)
|
|
93
105
|
*
|
|
94
106
|
* @group modals
|
|
95
107
|
*/
|
|
96
108
|
renderModal: (modalId: string, ctx: RenderModalCtx) => void;
|
|
97
109
|
/**
|
|
98
|
-
* This function will be called when the plugin needs to render a sidebar
|
|
99
|
-
* `itemFormSidebarPanels` function)
|
|
110
|
+
* This function will be called when the plugin needs to render a sidebar
|
|
111
|
+
* panel (see the `itemFormSidebarPanels` function)
|
|
100
112
|
*
|
|
101
113
|
* @group sidebarPanels
|
|
102
114
|
*/
|
|
103
115
|
renderItemFormSidebarPanel: (sidebarPaneId: string, ctx: RenderItemFormSidebarPanelCtx) => void;
|
|
104
116
|
/**
|
|
105
|
-
* This function will be called when the
|
|
106
|
-
*
|
|
117
|
+
* This function will be called when the user selects one of the plugin's
|
|
118
|
+
* asset sources to upload a new media file.
|
|
119
|
+
*
|
|
120
|
+
* @group assetSources
|
|
121
|
+
*/
|
|
122
|
+
renderAssetSource: (assetSourceId: string, ctx: RenderAssetSourceCtx) => void;
|
|
123
|
+
/**
|
|
124
|
+
* This function will be called when the plugin needs to render a field
|
|
125
|
+
* extension (see the `manualFieldExtensions` and `overrideFieldExtensions` functions)
|
|
107
126
|
*
|
|
108
127
|
* @group forcedFieldExtensions
|
|
109
128
|
*/
|
|
110
129
|
renderFieldExtension: (fieldExtensionId: string, ctx: RenderFieldExtensionCtx) => void;
|
|
111
130
|
/**
|
|
112
|
-
* This function will be called when the plugin needs to render the
|
|
113
|
-
* for installing a field extension inside a particular field
|
|
131
|
+
* This function will be called when the plugin needs to render the
|
|
132
|
+
* configuration form for installing a field extension inside a particular field
|
|
114
133
|
*
|
|
115
134
|
* @group manualFieldExtensions
|
|
116
135
|
*/
|
|
117
136
|
renderManualFieldExtensionConfigScreen: (fieldExtensionId: string, ctx: RenderManualFieldExtensionConfigScreenCtx) => void;
|
|
118
137
|
/**
|
|
119
|
-
* This function will be called each time the configuration object changes. It
|
|
120
|
-
* return an object containing possible validation errors
|
|
138
|
+
* This function will be called each time the configuration object changes. It
|
|
139
|
+
* must return an object containing possible validation errors
|
|
121
140
|
*
|
|
122
141
|
* @group manualFieldExtensions
|
|
123
142
|
*/
|
package/dist/esm/connect.js
CHANGED
|
@@ -46,7 +46,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
import connectToParent from 'penpal/lib/connectToParent';
|
|
49
|
-
import { isInitParent, isOnBootParent, isRenderConfigScreenParent, isRenderFieldExtensionParent, isRenderManualFieldExtensionConfigScreenParent, isRenderModalParent, isRenderPageParent, isRenderSidebarPaneParent, } from './guards';
|
|
49
|
+
import { isInitParent, isOnBootParent, isRenderAssetSourceParent, isRenderConfigScreenParent, isRenderFieldExtensionParent, isRenderManualFieldExtensionConfigScreenParent, isRenderModalParent, isRenderPageParent, isRenderSidebarPaneParent, } from './guards';
|
|
50
50
|
function toMultifield(fn) {
|
|
51
51
|
return function (fields, ctx) {
|
|
52
52
|
if (!fn) {
|
|
@@ -105,11 +105,11 @@ var buildRenderUtils = function (parent) {
|
|
|
105
105
|
export function connect(configuration) {
|
|
106
106
|
if (configuration === void 0) { configuration = {}; }
|
|
107
107
|
return __awaiter(this, void 0, void 0, function () {
|
|
108
|
-
var mainNavigationTabs, settingsAreaSidebarItemGroups, contentAreaSidebarItems, manualFieldExtensions, itemFormSidebarPanels, listener, penpalConnection, parent, initialSettings, render, render, renderUtils_1, render, renderUtils_2, render, renderUtils_3, render, renderUtils_4, render, renderUtils_5, render;
|
|
108
|
+
var assetSources, mainNavigationTabs, settingsAreaSidebarItemGroups, contentAreaSidebarItems, manualFieldExtensions, itemFormSidebarPanels, listener, penpalConnection, parent, initialSettings, render, render, renderUtils_1, render, renderUtils_2, render, renderUtils_3, render, renderUtils_4, render, renderUtils_5, render, renderUtils_6, render;
|
|
109
109
|
return __generator(this, function (_a) {
|
|
110
110
|
switch (_a.label) {
|
|
111
111
|
case 0:
|
|
112
|
-
mainNavigationTabs = configuration.mainNavigationTabs, settingsAreaSidebarItemGroups = configuration.settingsAreaSidebarItemGroups, contentAreaSidebarItems = configuration.contentAreaSidebarItems, manualFieldExtensions = configuration.manualFieldExtensions, itemFormSidebarPanels = configuration.itemFormSidebarPanels;
|
|
112
|
+
assetSources = configuration.assetSources, mainNavigationTabs = configuration.mainNavigationTabs, settingsAreaSidebarItemGroups = configuration.settingsAreaSidebarItemGroups, contentAreaSidebarItems = configuration.contentAreaSidebarItems, manualFieldExtensions = configuration.manualFieldExtensions, itemFormSidebarPanels = configuration.itemFormSidebarPanels;
|
|
113
113
|
listener = null;
|
|
114
114
|
penpalConnection = connectToParent({
|
|
115
115
|
methods: {
|
|
@@ -123,6 +123,7 @@ export function connect(configuration) {
|
|
|
123
123
|
return [key, value];
|
|
124
124
|
}));
|
|
125
125
|
},
|
|
126
|
+
assetSources: assetSources,
|
|
126
127
|
mainNavigationTabs: mainNavigationTabs,
|
|
127
128
|
settingsAreaSidebarItemGroups: settingsAreaSidebarItemGroups,
|
|
128
129
|
contentAreaSidebarItems: contentAreaSidebarItems,
|
|
@@ -188,35 +189,46 @@ export function connect(configuration) {
|
|
|
188
189
|
listener = render;
|
|
189
190
|
render(initialSettings);
|
|
190
191
|
}
|
|
191
|
-
if (
|
|
192
|
+
if (isRenderAssetSourceParent(parent, initialSettings)) {
|
|
192
193
|
renderUtils_3 = buildRenderUtils(parent);
|
|
194
|
+
render = function (settings) {
|
|
195
|
+
if (!configuration.renderAssetSource) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
configuration.renderAssetSource(settings.assetSourceId, __assign(__assign(__assign({}, parent), settings), renderUtils_3));
|
|
199
|
+
};
|
|
200
|
+
listener = render;
|
|
201
|
+
render(initialSettings);
|
|
202
|
+
}
|
|
203
|
+
if (isRenderSidebarPaneParent(parent, initialSettings)) {
|
|
204
|
+
renderUtils_4 = buildRenderUtils(parent);
|
|
193
205
|
render = function (settings) {
|
|
194
206
|
if (!configuration.renderItemFormSidebarPanel) {
|
|
195
207
|
return;
|
|
196
208
|
}
|
|
197
|
-
configuration.renderItemFormSidebarPanel(settings.sidebarPaneId, __assign(__assign(__assign({}, parent), settings),
|
|
209
|
+
configuration.renderItemFormSidebarPanel(settings.sidebarPaneId, __assign(__assign(__assign({}, parent), settings), renderUtils_4));
|
|
198
210
|
};
|
|
199
211
|
listener = render;
|
|
200
212
|
render(initialSettings);
|
|
201
213
|
}
|
|
202
214
|
if (isRenderFieldExtensionParent(parent, initialSettings)) {
|
|
203
|
-
|
|
215
|
+
renderUtils_5 = buildRenderUtils(parent);
|
|
204
216
|
render = function (settings) {
|
|
205
217
|
if (!configuration.renderFieldExtension) {
|
|
206
218
|
return;
|
|
207
219
|
}
|
|
208
|
-
configuration.renderFieldExtension(settings.fieldExtensionId, __assign(__assign(__assign({}, parent), settings),
|
|
220
|
+
configuration.renderFieldExtension(settings.fieldExtensionId, __assign(__assign(__assign({}, parent), settings), renderUtils_5));
|
|
209
221
|
};
|
|
210
222
|
listener = render;
|
|
211
223
|
render(initialSettings);
|
|
212
224
|
}
|
|
213
225
|
if (isRenderManualFieldExtensionConfigScreenParent(parent, initialSettings)) {
|
|
214
|
-
|
|
226
|
+
renderUtils_6 = buildRenderUtils(parent);
|
|
215
227
|
render = function (settings) {
|
|
216
228
|
if (!configuration.renderManualFieldExtensionConfigScreen) {
|
|
217
229
|
return;
|
|
218
230
|
}
|
|
219
|
-
configuration.renderManualFieldExtensionConfigScreen(settings.fieldExtensionId, __assign(__assign(__assign({}, parent), settings),
|
|
231
|
+
configuration.renderManualFieldExtensionConfigScreen(settings.fieldExtensionId, __assign(__assign(__assign({}, parent), settings), renderUtils_6));
|
|
220
232
|
};
|
|
221
233
|
listener = render;
|
|
222
234
|
render(initialSettings);
|
package/dist/esm/connect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../src/connect.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,eAAe,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../src/connect.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,O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gB,CAAC,MAAM,CAAC,CAAC;wBAEvC,MAAM,GAAG,UAAC,QAAkB;4BAChC,IAAI,CAAC,aAAa,CAAC,sCAAsC,EAAE;gCACzD,OAAO;6BACR;4BAED,aAAa,CAAC,sCAAsC,CAClD,QAAQ,CAAC,gBAAgB,iCAEpB,MAAM,GACN,QAAQ,GACR,aAAW,EAEjB,CAAC;wBACJ,CAAC,CAAC;wBAEF,QAAQ,GAAG,MAAM,CAAC;wBAClB,MAAM,CAAC,eAA2B,CAAC,CAAC;qBACrC;;;;;CACF"}
|
package/dist/esm/guards.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InitMethods, OnBootMethods, RenderPageMethods, RenderFieldExtensionMethods, RenderConfigScreenMethods, RenderManualFieldExtensionConfigScreenMethods, RenderSidebarPanelMethods, RenderModalMethods } from './types';
|
|
1
|
+
import { InitMethods, OnBootMethods, RenderPageMethods, RenderFieldExtensionMethods, RenderConfigScreenMethods, RenderManualFieldExtensionConfigScreenMethods, RenderSidebarPanelMethods, RenderModalMethods, RenderAssetSourceMethods } from './types';
|
|
2
2
|
export declare type Parent = {
|
|
3
3
|
getSettings: () => Promise<{
|
|
4
4
|
mode: string;
|
|
@@ -28,3 +28,6 @@ export declare const isRenderFieldExtensionParent: (parent: Parent, settings: {
|
|
|
28
28
|
export declare const isRenderManualFieldExtensionConfigScreenParent: (parent: Parent, settings: {
|
|
29
29
|
mode: string;
|
|
30
30
|
}) => parent is RenderManualFieldExtensionConfigScreenMethods;
|
|
31
|
+
export declare const isRenderAssetSourceParent: (parent: Parent, settings: {
|
|
32
|
+
mode: string;
|
|
33
|
+
}) => parent is RenderAssetSourceMethods;
|
package/dist/esm/guards.js
CHANGED
|
@@ -11,4 +11,5 @@ export var isRenderModalParent = buildGuard('renderModal');
|
|
|
11
11
|
export var isRenderSidebarPaneParent = buildGuard('renderItemFormSidebarPanel');
|
|
12
12
|
export var isRenderFieldExtensionParent = buildGuard('renderFieldExtension');
|
|
13
13
|
export var isRenderManualFieldExtensionConfigScreenParent = buildGuard('renderManualFieldExtensionConfigScreen');
|
|
14
|
+
export var isRenderAssetSourceParent = buildGuard('renderAssetSource');
|
|
14
15
|
//# sourceMappingURL=guards.js.map
|
package/dist/esm/guards.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../src/guards.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../src/guards.ts"],"names":[],"mappings":"AAcA,SAAS,UAAU,CAAmB,IAAY;IAChD,OAAO,UAAC,MAAc,EAAE,QAA0B;QAChD,OAAA,QAAQ,CAAC,IAAI,KAAK,IAAI;IAAtB,CAAsB,CAAC;AAC3B,CAAC;AAED,MAAM,CAAC,IAAM,YAAY,GAAG,UAAU,CAAc,MAAM,CAAC,CAAC;AAE5D,MAAM,CAAC,IAAM,cAAc,GAAG,UAAU,CAAgB,QAAQ,CAAC,CAAC;AAElE,MAAM,CAAC,IAAM,kBAAkB,GAAG,UAAU,CAAoB,YAAY,CAAC,CAAC;AAE9E,MAAM,CAAC,IAAM,0BAA0B,GAAG,UAAU,CAClD,oBAAoB,CACrB,CAAC;AAEF,MAAM,CAAC,IAAM,mBAAmB,GAAG,UAAU,CAC3C,aAAa,CACd,CAAC;AAEF,MAAM,CAAC,IAAM,yBAAyB,GAAG,UAAU,CACjD,4BAA4B,CAC7B,CAAC;AAEF,MAAM,CAAC,IAAM,4BAA4B,GAAG,UAAU,CACpD,sBAAsB,CACvB,CAAC;AAEF,MAAM,CAAC,IAAM,8CAA8C,GAAG,UAAU,CACtE,wCAAwC,CACzC,CAAC;AAEF,MAAM,CAAC,IAAM,yBAAyB,GAAG,UAAU,CACjD,mBAAmB,CACpB,CAAC"}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
import { Account, Field, Item, ModelBlock, Plugin, PluginAttributes, Role, Site, SsoUser, Upload, User } from './SiteApiSchema';
|
|
1
|
+
import { Account, Field, Item, ModelBlock, Plugin, PluginAttributes, Role, Site, SsoUser, Upload, UploadCreateSchema, User } from './SiteApiSchema';
|
|
2
|
+
export declare type Icon = string | {
|
|
3
|
+
type: 'svg';
|
|
4
|
+
viewBox: string;
|
|
5
|
+
content: string;
|
|
6
|
+
};
|
|
2
7
|
/** A tab to be displayed in the top-bar of the UI */
|
|
3
8
|
export declare type MainNavigationTab = {
|
|
4
9
|
/** Label to be shown. Must be unique. */
|
|
5
10
|
label: string;
|
|
6
|
-
/**
|
|
7
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Icon to be shown alongside the label. Can be a FontAwesome icon name (ie.
|
|
13
|
+
* `"address-book"`) or a custom SVG definition. To maintain visual
|
|
14
|
+
* consistency with the rest of the interface, try to use FontAwesome icons
|
|
15
|
+
* whenever possible.
|
|
16
|
+
*/
|
|
17
|
+
icon: Icon;
|
|
8
18
|
/** ID of the page linked to the tab */
|
|
9
19
|
pointsTo: {
|
|
10
20
|
pageId: string;
|
|
@@ -30,8 +40,13 @@ export declare type MainNavigationTab = {
|
|
|
30
40
|
export declare type SettingsAreaSidebarItem = {
|
|
31
41
|
/** Label to be shown. Must be unique. */
|
|
32
42
|
label: string;
|
|
33
|
-
/**
|
|
34
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Icon to be shown alongside the label. Can be a FontAwesome icon name (ie.
|
|
45
|
+
* `"address-book"`) or a custom SVG definition. To maintain visual
|
|
46
|
+
* consistency with the rest of the interface, try to use FontAwesome icons
|
|
47
|
+
* whenever possible.
|
|
48
|
+
*/
|
|
49
|
+
icon: Icon;
|
|
35
50
|
/** ID of the page linked to the item */
|
|
36
51
|
pointsTo: {
|
|
37
52
|
pageId: string;
|
|
@@ -72,8 +87,13 @@ export declare type SettingsAreaSidebarItemGroup = {
|
|
|
72
87
|
export declare type ContentAreaSidebarItem = {
|
|
73
88
|
/** Label to be shown. Must be unique. */
|
|
74
89
|
label: string;
|
|
75
|
-
/**
|
|
76
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Icon to be shown alongside the label. Can be a FontAwesome icon name (ie.
|
|
92
|
+
* `"address-book"`) or a custom SVG definition. To maintain visual
|
|
93
|
+
* consistency with the rest of the interface, try to use FontAwesome icons
|
|
94
|
+
* whenever possible.
|
|
95
|
+
*/
|
|
96
|
+
icon: Icon;
|
|
77
97
|
/** ID of the page linked to the item */
|
|
78
98
|
pointsTo: {
|
|
79
99
|
pageId: string;
|
|
@@ -276,6 +296,33 @@ export declare type Modal = {
|
|
|
276
296
|
/** The initial height to set for the iframe that will render the modal content */
|
|
277
297
|
initialHeight?: number;
|
|
278
298
|
};
|
|
299
|
+
/** An additional asset source */
|
|
300
|
+
export declare type AssetSource = {
|
|
301
|
+
/**
|
|
302
|
+
* ID of the asset source. Will be the first argument for the
|
|
303
|
+
* `renderAssetSource` function
|
|
304
|
+
*/
|
|
305
|
+
id: string;
|
|
306
|
+
/** Name of the asset that will be shown to the user */
|
|
307
|
+
name: string;
|
|
308
|
+
/**
|
|
309
|
+
* Icon to be shown alongside the name. Can be a FontAwesome icon name (ie.
|
|
310
|
+
* `"address-book"`) or a custom SVG definition. To maintain visual
|
|
311
|
+
* consistency with the rest of the interface, try to use FontAwesome icons
|
|
312
|
+
* whenever possible.
|
|
313
|
+
*/
|
|
314
|
+
icon: Icon;
|
|
315
|
+
/**
|
|
316
|
+
* Configuration options for the modal that will be opened to select a media
|
|
317
|
+
* file from this source
|
|
318
|
+
*/
|
|
319
|
+
modal?: {
|
|
320
|
+
/** Width of the modal. Can be a number, or one of the predefined sizes */
|
|
321
|
+
width?: 's' | 'm' | 'l' | 'xl' | number;
|
|
322
|
+
/** The initial height to set for the iframe that will render the modal content */
|
|
323
|
+
initialHeight?: number;
|
|
324
|
+
};
|
|
325
|
+
};
|
|
279
326
|
/** A toast notification to present to the user */
|
|
280
327
|
export declare type Toast<CtaValue = unknown> = {
|
|
281
328
|
/** Message of the notification */
|
|
@@ -1027,6 +1074,82 @@ export declare type RenderModalAdditionalMethods = {
|
|
|
1027
1074
|
};
|
|
1028
1075
|
export declare type RenderModalMethods = RenderMethods & IframeMethods & RenderModalAdditionalMethods;
|
|
1029
1076
|
export declare type RenderModalPropertiesAndMethods = RenderModalMethods & RenderModalProperties;
|
|
1077
|
+
/** Information regarding the specific asset source browser that you need to render */
|
|
1078
|
+
export declare type RenderAssetSourceAdditionalProperties = {
|
|
1079
|
+
mode: 'renderAssetSource';
|
|
1080
|
+
/** The ID of the assetSource that needs to be rendered */
|
|
1081
|
+
assetSourceId: string;
|
|
1082
|
+
};
|
|
1083
|
+
export declare type RenderAssetSourceProperties = RenderProperties & RenderAssetSourceAdditionalProperties;
|
|
1084
|
+
export declare type NewUploadResourceAsUrl = {
|
|
1085
|
+
/**
|
|
1086
|
+
* URL for the resource. The URL must respond with a
|
|
1087
|
+
* `Access-Control-Allow-Origin` header — for instance `*`, which will allow
|
|
1088
|
+
* all hosts — allowing the image to be read by DatoCMS
|
|
1089
|
+
*/
|
|
1090
|
+
url: string;
|
|
1091
|
+
/**
|
|
1092
|
+
* Optional filename to be used to generate the final DatoCMS URL. If not
|
|
1093
|
+
* passed, the URL will be used
|
|
1094
|
+
*/
|
|
1095
|
+
filename?: string;
|
|
1096
|
+
};
|
|
1097
|
+
export declare type NewUploadResourceAsBase64 = {
|
|
1098
|
+
/**
|
|
1099
|
+
* Base64 encoded data URI for the resource.
|
|
1100
|
+
*
|
|
1101
|
+
* Format:
|
|
1102
|
+
*
|
|
1103
|
+
* `data:[<mime type>][;charset=<charset>];base64,<encoded data>`
|
|
1104
|
+
*/
|
|
1105
|
+
base64: string;
|
|
1106
|
+
/** Filename to be used to generate the final DatoCMS URL */
|
|
1107
|
+
filename: string;
|
|
1108
|
+
};
|
|
1109
|
+
export declare type NewUpload = {
|
|
1110
|
+
/** The actual resource that will be uploaded */
|
|
1111
|
+
resource: NewUploadResourceAsUrl | NewUploadResourceAsBase64;
|
|
1112
|
+
/** Copyright to apply to the asset */
|
|
1113
|
+
copyright?: string;
|
|
1114
|
+
/** Author to apply to the asset */
|
|
1115
|
+
author?: string;
|
|
1116
|
+
/** Notes to apply to the asset */
|
|
1117
|
+
notes?: string;
|
|
1118
|
+
/** Tags to apply to the asset */
|
|
1119
|
+
tags?: string[];
|
|
1120
|
+
/**
|
|
1121
|
+
* An hash containing, for each locale of the project, the default metadata to
|
|
1122
|
+
* apply to the asset
|
|
1123
|
+
*/
|
|
1124
|
+
default_field_metadata?: UploadCreateSchema['data']['attributes']['default_field_metadata'];
|
|
1125
|
+
};
|
|
1126
|
+
/** Use these methods to confirm */
|
|
1127
|
+
export declare type RenderAssetSourceAdditionalMethods = {
|
|
1128
|
+
getSettings: () => Promise<RenderAssetSourceProperties>;
|
|
1129
|
+
/**
|
|
1130
|
+
* Function to be called when the user selects the asset: it will trigger the
|
|
1131
|
+
* creation of a new `Upload` that will be added in the Media Area.
|
|
1132
|
+
*
|
|
1133
|
+
* @example
|
|
1134
|
+
*
|
|
1135
|
+
* ```js
|
|
1136
|
+
* await ctx.select({
|
|
1137
|
+
* resource: {
|
|
1138
|
+
* url:
|
|
1139
|
+
* 'https://images.unsplash.com/photo-1416339306562-f3d12fefd36f',
|
|
1140
|
+
* filename: 'man-drinking-coffee.jpg',
|
|
1141
|
+
* },
|
|
1142
|
+
* copyright: 'Royalty free (Unsplash)',
|
|
1143
|
+
* author: 'Jeff Sheldon',
|
|
1144
|
+
* notes: 'A man drinking a coffee',
|
|
1145
|
+
* tags: ['man', 'coffee'],
|
|
1146
|
+
* });
|
|
1147
|
+
* ```
|
|
1148
|
+
*/
|
|
1149
|
+
select: (newUpload: NewUpload) => void;
|
|
1150
|
+
};
|
|
1151
|
+
export declare type RenderAssetSourceMethods = RenderMethods & IframeMethods & RenderAssetSourceAdditionalMethods;
|
|
1152
|
+
export declare type RenderAssetSourcePropertiesAndMethods = RenderAssetSourceMethods & RenderAssetSourceProperties;
|
|
1030
1153
|
/** Information regarding the specific page that you need to render */
|
|
1031
1154
|
export declare type RenderPageAdditionalProperties = {
|
|
1032
1155
|
mode: 'renderPage';
|