decap-cms-core 3.5.0 → 3.6.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/decap-cms-core.js +9 -9
- package/dist/decap-cms-core.js.map +1 -1
- package/dist/esm/actions/auth.js +22 -37
- package/dist/esm/actions/collections.js +9 -17
- package/dist/esm/actions/config.js +58 -74
- package/dist/esm/actions/deploys.js +10 -17
- package/dist/esm/actions/editorialWorkflow.js +87 -101
- package/dist/esm/actions/entries.js +161 -211
- package/dist/esm/actions/media.js +31 -46
- package/dist/esm/actions/mediaLibrary.js +94 -126
- package/dist/esm/actions/notifications.js +5 -13
- package/dist/esm/actions/search.js +30 -47
- package/dist/esm/actions/status.js +13 -23
- package/dist/esm/actions/waitUntil.js +4 -11
- package/dist/esm/backend.js +132 -148
- package/dist/esm/bootstrap.js +37 -44
- package/dist/esm/components/App/App.js +82 -89
- package/dist/esm/components/App/Header.js +46 -52
- package/dist/esm/components/App/NotFoundPage.js +11 -18
- package/dist/esm/components/Collection/Collection.js +55 -63
- package/dist/esm/components/Collection/CollectionControls.js +15 -22
- package/dist/esm/components/Collection/CollectionSearch.js +35 -42
- package/dist/esm/components/Collection/CollectionTop.js +23 -30
- package/dist/esm/components/Collection/ControlButton.js +10 -16
- package/dist/esm/components/Collection/Entries/Entries.js +24 -31
- package/dist/esm/components/Collection/Entries/EntriesCollection.js +52 -62
- package/dist/esm/components/Collection/Entries/EntriesSearch.js +26 -33
- package/dist/esm/components/Collection/Entries/EntryCard.js +38 -45
- package/dist/esm/components/Collection/Entries/EntryListing.js +24 -32
- package/dist/esm/components/Collection/FilterControl.js +9 -16
- package/dist/esm/components/Collection/GroupControl.js +9 -16
- package/dist/esm/components/Collection/NestedCollection.js +54 -65
- package/dist/esm/components/Collection/Sidebar.js +36 -43
- package/dist/esm/components/Collection/SortControl.js +19 -26
- package/dist/esm/components/Collection/ViewStyleControl.js +17 -24
- package/dist/esm/components/Editor/Editor.js +100 -108
- package/dist/esm/components/Editor/EditorControlPane/EditorControl.js +105 -112
- package/dist/esm/components/Editor/EditorControlPane/EditorControlPane.js +68 -62
- package/dist/esm/components/Editor/EditorControlPane/Widget.js +87 -73
- package/dist/esm/components/Editor/EditorInterface.js +95 -98
- package/dist/esm/components/Editor/EditorPreviewPane/EditorPreview.js +13 -21
- package/dist/esm/components/Editor/EditorPreviewPane/EditorPreviewContent.js +64 -23
- package/dist/esm/components/Editor/EditorPreviewPane/EditorPreviewPane.js +94 -78
- package/dist/esm/components/Editor/EditorPreviewPane/PreviewHOC.js +9 -16
- package/dist/esm/components/Editor/EditorToolbar.js +133 -140
- package/dist/esm/components/Editor/withWorkflow.js +15 -22
- package/dist/esm/components/EditorWidgets/Unknown/UnknownControl.js +9 -16
- package/dist/esm/components/EditorWidgets/Unknown/UnknownPreview.js +9 -16
- package/dist/esm/components/EditorWidgets/index.js +4 -7
- package/dist/esm/components/MediaLibrary/EmptyMessage.js +12 -19
- package/dist/esm/components/MediaLibrary/MediaLibrary.js +55 -62
- package/dist/esm/components/MediaLibrary/MediaLibraryButtons.js +28 -35
- package/dist/esm/components/MediaLibrary/MediaLibraryCard.js +36 -43
- package/dist/esm/components/MediaLibrary/MediaLibraryCardGrid.js +50 -57
- package/dist/esm/components/MediaLibrary/MediaLibraryHeader.js +16 -23
- package/dist/esm/components/MediaLibrary/MediaLibraryModal.js +59 -64
- package/dist/esm/components/MediaLibrary/MediaLibrarySearch.js +18 -25
- package/dist/esm/components/MediaLibrary/MediaLibraryTop.js +39 -46
- package/dist/esm/components/UI/DragDrop.js +21 -30
- package/dist/esm/components/UI/ErrorBoundary.js +35 -43
- package/dist/esm/components/UI/FileUploadButton.js +11 -18
- package/dist/esm/components/UI/Modal.js +19 -26
- package/dist/esm/components/UI/Notifications.js +21 -28
- package/dist/esm/components/UI/SettingsDropdown.js +28 -34
- package/dist/esm/components/UI/index.js +6 -60
- package/dist/esm/components/Workflow/Workflow.js +52 -61
- package/dist/esm/components/Workflow/WorkflowCard.js +45 -51
- package/dist/esm/components/Workflow/WorkflowList.js +43 -49
- package/dist/esm/constants/collectionTypes.js +2 -8
- package/dist/esm/constants/collectionViews.js +2 -8
- package/dist/esm/constants/commitProps.js +2 -8
- package/dist/esm/constants/configSchema.js +20 -27
- package/dist/esm/constants/fieldInference.js +8 -15
- package/dist/esm/constants/publishModes.js +6 -11
- package/dist/esm/constants/validationErrorTypes.js +1 -7
- package/dist/esm/formats/formats.js +32 -41
- package/dist/esm/formats/frontmatter.js +18 -30
- package/dist/esm/formats/helpers.js +1 -7
- package/dist/esm/formats/json.js +1 -7
- package/dist/esm/formats/toml.js +11 -18
- package/dist/esm/formats/yaml.js +7 -14
- package/dist/esm/index.js +5 -12
- package/dist/esm/integrations/index.js +8 -16
- package/dist/esm/integrations/providers/algolia/implementation.js +14 -22
- package/dist/esm/integrations/providers/assetStore/implementation.js +10 -18
- package/dist/esm/lib/consoleError.js +1 -7
- package/dist/esm/lib/formatters.js +34 -47
- package/dist/esm/lib/i18n.js +37 -66
- package/dist/esm/lib/phrases.js +4 -11
- package/dist/esm/lib/registry.js +40 -75
- package/dist/esm/lib/serializeEntryValues.js +11 -18
- package/dist/esm/lib/textHelper.js +1 -7
- package/dist/esm/lib/urlHelper.js +28 -43
- package/dist/esm/mediaLibrary.js +12 -16
- package/dist/esm/reducers/auth.js +10 -16
- package/dist/esm/reducers/collections.js +70 -102
- package/dist/esm/reducers/combinedReducer.js +4 -11
- package/dist/esm/reducers/config.js +11 -19
- package/dist/esm/reducers/cursors.js +12 -18
- package/dist/esm/reducers/deploys.js +8 -15
- package/dist/esm/reducers/editorialWorkflow.js +37 -47
- package/dist/esm/reducers/entries.js +107 -132
- package/dist/esm/reducers/entryDraft.js +64 -72
- package/dist/esm/reducers/globalUI.js +5 -11
- package/dist/esm/reducers/index.js +43 -64
- package/dist/esm/reducers/integrations.js +8 -16
- package/dist/esm/reducers/mediaLibrary.js +43 -52
- package/dist/esm/reducers/medias.js +11 -18
- package/dist/esm/reducers/notifications.js +9 -15
- package/dist/esm/reducers/search.js +12 -18
- package/dist/esm/reducers/status.js +7 -13
- package/dist/esm/redux/index.js +7 -13
- package/dist/esm/redux/middleware/waitUntilAction.js +3 -10
- package/dist/esm/routing/history.js +7 -15
- package/dist/esm/types/diacritics.d.js +0 -1
- package/dist/esm/types/global.d.js +1 -5
- package/dist/esm/types/immutable.js +1 -5
- package/dist/esm/types/redux.js +7 -8
- package/dist/esm/types/tomlify-j0.4.d.js +0 -1
- package/dist/esm/valueObjects/AssetProxy.js +2 -10
- package/dist/esm/valueObjects/EditorComponent.js +5 -12
- package/dist/esm/valueObjects/Entry.js +3 -10
- package/package.json +3 -2
- package/src/components/Collection/Entries/EntriesCollection.js +7 -8
- package/src/components/Collection/Entries/__tests__/EntriesCollection.spec.js +3 -5
- package/src/components/Collection/Entries/__tests__/__snapshots__/EntriesCollection.spec.js.snap +8 -8
- package/src/components/Collection/NestedCollection.js +2 -2
- package/src/components/Collection/__tests__/__snapshots__/NestedCollection.spec.js.snap +68 -0
- package/src/components/Editor/EditorControlPane/EditorControl.js +0 -3
- package/src/components/Editor/EditorControlPane/EditorControlPane.js +21 -8
- package/src/components/Editor/EditorControlPane/Widget.js +22 -1
- package/src/components/Editor/EditorInterface.js +6 -1
- package/src/components/Editor/EditorPreviewPane/EditorPreviewContent.js +51 -11
- package/src/components/Editor/EditorPreviewPane/EditorPreviewPane.js +33 -1
- package/dist/esm/actions/editorControl.js +0 -14
- package/dist/esm/reducers/editorComponent.js +0 -1
- package/dist/esm/reducers/editorControl.js +0 -17
package/dist/esm/lib/registry.js
CHANGED
|
@@ -1,44 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
exports.getBackend = getBackend;
|
|
8
|
-
exports.getCustomFormats = getCustomFormats;
|
|
9
|
-
exports.getCustomFormatsExtensions = getCustomFormatsExtensions;
|
|
10
|
-
exports.getCustomFormatsFormatters = getCustomFormatsFormatters;
|
|
11
|
-
exports.getEditorComponents = getEditorComponents;
|
|
12
|
-
exports.getEventListeners = getEventListeners;
|
|
13
|
-
exports.getFormatter = getFormatter;
|
|
14
|
-
exports.getLocale = getLocale;
|
|
15
|
-
exports.getMediaLibrary = getMediaLibrary;
|
|
16
|
-
exports.getPreviewStyles = getPreviewStyles;
|
|
17
|
-
exports.getPreviewTemplate = getPreviewTemplate;
|
|
18
|
-
exports.getRemarkPlugins = getRemarkPlugins;
|
|
19
|
-
exports.getWidget = getWidget;
|
|
20
|
-
exports.getWidgetValueSerializer = getWidgetValueSerializer;
|
|
21
|
-
exports.getWidgets = getWidgets;
|
|
22
|
-
exports.invokeEvent = invokeEvent;
|
|
23
|
-
exports.registerBackend = registerBackend;
|
|
24
|
-
exports.registerCustomFormat = registerCustomFormat;
|
|
25
|
-
exports.registerEditorComponent = registerEditorComponent;
|
|
26
|
-
exports.registerEventListener = registerEventListener;
|
|
27
|
-
exports.registerLocale = registerLocale;
|
|
28
|
-
exports.registerMediaLibrary = registerMediaLibrary;
|
|
29
|
-
exports.registerPreviewStyle = registerPreviewStyle;
|
|
30
|
-
exports.registerPreviewTemplate = registerPreviewTemplate;
|
|
31
|
-
exports.registerRemarkPlugin = registerRemarkPlugin;
|
|
32
|
-
exports.registerWidget = registerWidget;
|
|
33
|
-
exports.registerWidgetValueSerializer = registerWidgetValueSerializer;
|
|
34
|
-
exports.removeEventListener = removeEventListener;
|
|
35
|
-
exports.resolveWidget = resolveWidget;
|
|
36
|
-
var _immutable = require("immutable");
|
|
37
|
-
var _immer = require("immer");
|
|
38
|
-
var _commonTags = require("common-tags");
|
|
39
|
-
var _EditorComponent = _interopRequireDefault(require("../valueObjects/EditorComponent"));
|
|
40
1
|
const _excluded = ["name", "controlComponent", "previewComponent", "schema", "allowMapValue", "globalStyles"];
|
|
41
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
42
2
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
43
3
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
44
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -46,6 +6,10 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
46
6
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
47
7
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
48
8
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
|
+
import { Map } from 'immutable';
|
|
10
|
+
import { produce } from 'immer';
|
|
11
|
+
import { oneLine } from 'common-tags';
|
|
12
|
+
import EditorComponent from '../valueObjects/EditorComponent';
|
|
49
13
|
const allowedEvents = ['prePublish', 'postPublish', 'preUnpublish', 'postUnpublish', 'preSave', 'postSave'];
|
|
50
14
|
const eventHandlers = {};
|
|
51
15
|
allowedEvents.forEach(e => {
|
|
@@ -60,7 +24,7 @@ const registry = {
|
|
|
60
24
|
templates: {},
|
|
61
25
|
previewStyles: [],
|
|
62
26
|
widgets: {},
|
|
63
|
-
editorComponents:
|
|
27
|
+
editorComponents: Map(),
|
|
64
28
|
remarkPlugins: [],
|
|
65
29
|
widgetValueSerializers: {},
|
|
66
30
|
mediaLibraries: [],
|
|
@@ -68,7 +32,7 @@ const registry = {
|
|
|
68
32
|
eventHandlers,
|
|
69
33
|
formats: {}
|
|
70
34
|
};
|
|
71
|
-
|
|
35
|
+
export default {
|
|
72
36
|
registerPreviewStyle,
|
|
73
37
|
getPreviewStyles,
|
|
74
38
|
registerPreviewTemplate,
|
|
@@ -98,35 +62,36 @@ var _default = exports.default = {
|
|
|
98
62
|
getCustomFormatsExtensions,
|
|
99
63
|
getCustomFormatsFormatters
|
|
100
64
|
};
|
|
65
|
+
|
|
101
66
|
/**
|
|
102
67
|
* Preview Styles
|
|
103
68
|
*
|
|
104
69
|
* Valid options:
|
|
105
70
|
* - raw {boolean} if `true`, `style` value is expected to be a CSS string
|
|
106
71
|
*/
|
|
107
|
-
function registerPreviewStyle(style, opts) {
|
|
72
|
+
export function registerPreviewStyle(style, opts) {
|
|
108
73
|
registry.previewStyles.push(_objectSpread(_objectSpread({}, opts), {}, {
|
|
109
74
|
value: style
|
|
110
75
|
}));
|
|
111
76
|
}
|
|
112
|
-
function getPreviewStyles() {
|
|
77
|
+
export function getPreviewStyles() {
|
|
113
78
|
return registry.previewStyles;
|
|
114
79
|
}
|
|
115
80
|
|
|
116
81
|
/**
|
|
117
82
|
* Preview Templates
|
|
118
83
|
*/
|
|
119
|
-
function registerPreviewTemplate(name, component) {
|
|
84
|
+
export function registerPreviewTemplate(name, component) {
|
|
120
85
|
registry.templates[name] = component;
|
|
121
86
|
}
|
|
122
|
-
function getPreviewTemplate(name) {
|
|
87
|
+
export function getPreviewTemplate(name) {
|
|
123
88
|
return registry.templates[name];
|
|
124
89
|
}
|
|
125
90
|
|
|
126
91
|
/**
|
|
127
92
|
* Editor Widgets
|
|
128
93
|
*/
|
|
129
|
-
function registerWidget(name, control, preview, schema = {}) {
|
|
94
|
+
export function registerWidget(name, control, preview, schema = {}) {
|
|
130
95
|
if (Array.isArray(name)) {
|
|
131
96
|
name.forEach(widget => {
|
|
132
97
|
if (typeof widget !== 'object') {
|
|
@@ -155,7 +120,7 @@ function registerWidget(name, control, preview, schema = {}) {
|
|
|
155
120
|
} = name,
|
|
156
121
|
options = _objectWithoutProperties(name, _excluded);
|
|
157
122
|
if (registry.widgets[widgetName]) {
|
|
158
|
-
console.warn(
|
|
123
|
+
console.warn(oneLine`
|
|
159
124
|
Multiple widgets registered with name "${widgetName}". Only the last widget registered with
|
|
160
125
|
this name will be used.
|
|
161
126
|
`);
|
|
@@ -174,29 +139,29 @@ function registerWidget(name, control, preview, schema = {}) {
|
|
|
174
139
|
console.error('`registerWidget` failed, called with incorrect arguments.');
|
|
175
140
|
}
|
|
176
141
|
}
|
|
177
|
-
function getWidget(name) {
|
|
142
|
+
export function getWidget(name) {
|
|
178
143
|
return registry.widgets[name];
|
|
179
144
|
}
|
|
180
|
-
function getWidgets() {
|
|
181
|
-
return
|
|
145
|
+
export function getWidgets() {
|
|
146
|
+
return produce(Object.entries(registry.widgets), draft => {
|
|
182
147
|
return draft.map(([key, value]) => _objectSpread({
|
|
183
148
|
name: key
|
|
184
149
|
}, value));
|
|
185
150
|
});
|
|
186
151
|
}
|
|
187
|
-
function resolveWidget(name) {
|
|
152
|
+
export function resolveWidget(name) {
|
|
188
153
|
return getWidget(name || 'string') || getWidget('unknown');
|
|
189
154
|
}
|
|
190
155
|
|
|
191
156
|
/**
|
|
192
157
|
* Markdown Editor Custom Components
|
|
193
158
|
*/
|
|
194
|
-
function registerEditorComponent(component) {
|
|
195
|
-
const plugin = (
|
|
159
|
+
export function registerEditorComponent(component) {
|
|
160
|
+
const plugin = EditorComponent(component);
|
|
196
161
|
if (plugin.type === 'code-block') {
|
|
197
162
|
const codeBlock = registry.editorComponents.find(c => c.type === 'code-block');
|
|
198
163
|
if (codeBlock) {
|
|
199
|
-
console.warn(
|
|
164
|
+
console.warn(oneLine`
|
|
200
165
|
Only one editor component of type "code-block" may be registered. Previously registered code
|
|
201
166
|
block component(s) will be overwritten.
|
|
202
167
|
`);
|
|
@@ -205,7 +170,7 @@ function registerEditorComponent(component) {
|
|
|
205
170
|
}
|
|
206
171
|
registry.editorComponents = registry.editorComponents.set(plugin.id, plugin);
|
|
207
172
|
}
|
|
208
|
-
function getEditorComponents() {
|
|
173
|
+
export function getEditorComponents() {
|
|
209
174
|
return registry.editorComponents;
|
|
210
175
|
}
|
|
211
176
|
|
|
@@ -214,28 +179,28 @@ function getEditorComponents() {
|
|
|
214
179
|
*/
|
|
215
180
|
/** @typedef {import('unified').Pluggable} RemarkPlugin */
|
|
216
181
|
/** @type {(plugin: RemarkPlugin) => void} */
|
|
217
|
-
function registerRemarkPlugin(plugin) {
|
|
182
|
+
export function registerRemarkPlugin(plugin) {
|
|
218
183
|
registry.remarkPlugins.push(plugin);
|
|
219
184
|
}
|
|
220
185
|
/** @type {() => Array<RemarkPlugin>} */
|
|
221
|
-
function getRemarkPlugins() {
|
|
186
|
+
export function getRemarkPlugins() {
|
|
222
187
|
return registry.remarkPlugins;
|
|
223
188
|
}
|
|
224
189
|
|
|
225
190
|
/**
|
|
226
191
|
* Widget Serializers
|
|
227
192
|
*/
|
|
228
|
-
function registerWidgetValueSerializer(widgetName, serializer) {
|
|
193
|
+
export function registerWidgetValueSerializer(widgetName, serializer) {
|
|
229
194
|
registry.widgetValueSerializers[widgetName] = serializer;
|
|
230
195
|
}
|
|
231
|
-
function getWidgetValueSerializer(widgetName) {
|
|
196
|
+
export function getWidgetValueSerializer(widgetName) {
|
|
232
197
|
return registry.widgetValueSerializers[widgetName];
|
|
233
198
|
}
|
|
234
199
|
|
|
235
200
|
/**
|
|
236
201
|
* Backend API
|
|
237
202
|
*/
|
|
238
|
-
function registerBackend(name, BackendClass) {
|
|
203
|
+
export function registerBackend(name, BackendClass) {
|
|
239
204
|
if (!name || !BackendClass) {
|
|
240
205
|
console.error("Backend parameters invalid. example: CMS.registerBackend('myBackend', BackendClass)");
|
|
241
206
|
} else if (registry.backends[name]) {
|
|
@@ -246,14 +211,14 @@ function registerBackend(name, BackendClass) {
|
|
|
246
211
|
};
|
|
247
212
|
}
|
|
248
213
|
}
|
|
249
|
-
function getBackend(name) {
|
|
214
|
+
export function getBackend(name) {
|
|
250
215
|
return registry.backends[name];
|
|
251
216
|
}
|
|
252
217
|
|
|
253
218
|
/**
|
|
254
219
|
* Media Libraries
|
|
255
220
|
*/
|
|
256
|
-
function registerMediaLibrary(mediaLibrary, options) {
|
|
221
|
+
export function registerMediaLibrary(mediaLibrary, options) {
|
|
257
222
|
if (registry.mediaLibraries.find(ml => mediaLibrary.name === ml.name)) {
|
|
258
223
|
throw new Error(`A media library named ${mediaLibrary.name} has already been registered.`);
|
|
259
224
|
}
|
|
@@ -261,7 +226,7 @@ function registerMediaLibrary(mediaLibrary, options) {
|
|
|
261
226
|
options
|
|
262
227
|
}));
|
|
263
228
|
}
|
|
264
|
-
function getMediaLibrary(name) {
|
|
229
|
+
export function getMediaLibrary(name) {
|
|
265
230
|
return registry.mediaLibraries.find(ml => ml.name === name);
|
|
266
231
|
}
|
|
267
232
|
function validateEventName(name) {
|
|
@@ -269,11 +234,11 @@ function validateEventName(name) {
|
|
|
269
234
|
throw new Error(`Invalid event name '${name}'`);
|
|
270
235
|
}
|
|
271
236
|
}
|
|
272
|
-
function getEventListeners(name) {
|
|
237
|
+
export function getEventListeners(name) {
|
|
273
238
|
validateEventName(name);
|
|
274
239
|
return [...registry.eventHandlers[name]];
|
|
275
240
|
}
|
|
276
|
-
function registerEventListener({
|
|
241
|
+
export function registerEventListener({
|
|
277
242
|
name,
|
|
278
243
|
handler
|
|
279
244
|
}, options = {}) {
|
|
@@ -283,7 +248,7 @@ function registerEventListener({
|
|
|
283
248
|
options
|
|
284
249
|
});
|
|
285
250
|
}
|
|
286
|
-
async function invokeEvent({
|
|
251
|
+
export async function invokeEvent({
|
|
287
252
|
name,
|
|
288
253
|
data
|
|
289
254
|
}) {
|
|
@@ -304,7 +269,7 @@ async function invokeEvent({
|
|
|
304
269
|
}
|
|
305
270
|
return _data.entry.get('data');
|
|
306
271
|
}
|
|
307
|
-
function removeEventListener({
|
|
272
|
+
export function removeEventListener({
|
|
308
273
|
name,
|
|
309
274
|
handler
|
|
310
275
|
}) {
|
|
@@ -319,26 +284,26 @@ function removeEventListener({
|
|
|
319
284
|
/**
|
|
320
285
|
* Locales
|
|
321
286
|
*/
|
|
322
|
-
function registerLocale(locale, phrases) {
|
|
287
|
+
export function registerLocale(locale, phrases) {
|
|
323
288
|
if (!locale || !phrases) {
|
|
324
289
|
console.error("Locale parameters invalid. example: CMS.registerLocale('locale', phrases)");
|
|
325
290
|
} else {
|
|
326
291
|
registry.locales[locale] = phrases;
|
|
327
292
|
}
|
|
328
293
|
}
|
|
329
|
-
function getLocale(locale) {
|
|
294
|
+
export function getLocale(locale) {
|
|
330
295
|
return registry.locales[locale];
|
|
331
296
|
}
|
|
332
|
-
function registerCustomFormat(name, extension, formatter) {
|
|
297
|
+
export function registerCustomFormat(name, extension, formatter) {
|
|
333
298
|
registry.formats[name] = {
|
|
334
299
|
extension,
|
|
335
300
|
formatter
|
|
336
301
|
};
|
|
337
302
|
}
|
|
338
|
-
function getCustomFormats() {
|
|
303
|
+
export function getCustomFormats() {
|
|
339
304
|
return registry.formats;
|
|
340
305
|
}
|
|
341
|
-
function getCustomFormatsExtensions() {
|
|
306
|
+
export function getCustomFormatsExtensions() {
|
|
342
307
|
return Object.entries(registry.formats).reduce(function (acc, [name, {
|
|
343
308
|
extension
|
|
344
309
|
}]) {
|
|
@@ -349,7 +314,7 @@ function getCustomFormatsExtensions() {
|
|
|
349
314
|
}
|
|
350
315
|
|
|
351
316
|
/** @type {() => Record<string, unknown>} */
|
|
352
|
-
function getCustomFormatsFormatters() {
|
|
317
|
+
export function getCustomFormatsFormatters() {
|
|
353
318
|
return Object.entries(registry.formats).reduce(function (acc, [name, {
|
|
354
319
|
formatter
|
|
355
320
|
}]) {
|
|
@@ -358,7 +323,7 @@ function getCustomFormatsFormatters() {
|
|
|
358
323
|
});
|
|
359
324
|
}, {});
|
|
360
325
|
}
|
|
361
|
-
function getFormatter(name) {
|
|
326
|
+
export function getFormatter(name) {
|
|
362
327
|
var _registry$formats$nam;
|
|
363
328
|
return (_registry$formats$nam = registry.formats[name]) === null || _registry$formats$nam === void 0 ? void 0 : _registry$formats$nam.formatter;
|
|
364
329
|
}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import _isNil from "lodash/isNil";
|
|
2
|
+
import { Map, List } from 'immutable';
|
|
3
|
+
import { getWidgetValueSerializer } from './registry';
|
|
2
4
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.deserializeValues = deserializeValues;
|
|
7
|
-
exports.serializeValues = serializeValues;
|
|
8
|
-
var _isNil2 = _interopRequireDefault(require("lodash/isNil"));
|
|
9
|
-
var _immutable = require("immutable");
|
|
10
|
-
var _registry = require("./registry");
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
5
|
/**
|
|
13
6
|
* Methods for serializing/deserializing entry field values. Most widgets don't
|
|
14
7
|
* require this for their values, and those that do can typically serialize/
|
|
@@ -37,38 +30,38 @@ function runSerializer(values, fields, method) {
|
|
|
37
30
|
let serializedData = fields.reduce((acc, field) => {
|
|
38
31
|
const fieldName = field.get('name');
|
|
39
32
|
const value = values.get(fieldName);
|
|
40
|
-
const serializer =
|
|
33
|
+
const serializer = getWidgetValueSerializer(field.get('widget'));
|
|
41
34
|
const nestedFields = field.get('fields');
|
|
42
35
|
|
|
43
36
|
// Call recursively for fields within lists
|
|
44
|
-
if (nestedFields &&
|
|
37
|
+
if (nestedFields && List.isList(value)) {
|
|
45
38
|
return acc.set(fieldName, value.map(val => runSerializer(val, nestedFields, method)));
|
|
46
39
|
}
|
|
47
40
|
|
|
48
41
|
// Call recursively for fields within objects
|
|
49
|
-
if (nestedFields &&
|
|
42
|
+
if (nestedFields && Map.isMap(value)) {
|
|
50
43
|
return acc.set(fieldName, runSerializer(value, nestedFields, method));
|
|
51
44
|
}
|
|
52
45
|
|
|
53
46
|
// Run serialization method on value if not null or undefined
|
|
54
|
-
if (serializer && !(
|
|
47
|
+
if (serializer && !_isNil(value)) {
|
|
55
48
|
return acc.set(fieldName, serializer[method](value));
|
|
56
49
|
}
|
|
57
50
|
|
|
58
51
|
// If no serializer is registered for the field's widget, use the field as is
|
|
59
|
-
if (!(
|
|
52
|
+
if (!_isNil(value)) {
|
|
60
53
|
return acc.set(fieldName, value);
|
|
61
54
|
}
|
|
62
55
|
return acc;
|
|
63
|
-
},
|
|
56
|
+
}, Map());
|
|
64
57
|
|
|
65
58
|
//preserve unknown fields value
|
|
66
59
|
serializedData = values.mergeDeep(serializedData);
|
|
67
60
|
return serializedData;
|
|
68
61
|
}
|
|
69
|
-
function serializeValues(values, fields) {
|
|
62
|
+
export function serializeValues(values, fields) {
|
|
70
63
|
return runSerializer(values, fields, 'serialize');
|
|
71
64
|
}
|
|
72
|
-
function deserializeValues(values, fields) {
|
|
65
|
+
export function deserializeValues(values, fields) {
|
|
73
66
|
return runSerializer(values, fields, 'deserialize');
|
|
74
67
|
}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.stringToRGB = stringToRGB;
|
|
7
|
-
function stringToRGB(str) {
|
|
1
|
+
export function stringToRGB(str) {
|
|
8
2
|
if (!str) return '000000';
|
|
9
3
|
let hash = 0;
|
|
10
4
|
for (let i = 0; i < str.length; i++) {
|
|
@@ -1,46 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.addParams = addParams;
|
|
7
|
-
exports.getCharReplacer = getCharReplacer;
|
|
8
|
-
exports.getCollectionUrl = getCollectionUrl;
|
|
9
|
-
exports.getNewEntryUrl = getNewEntryUrl;
|
|
10
|
-
exports.joinUrlPath = joinUrlPath;
|
|
11
|
-
exports.sanitizeChar = sanitizeChar;
|
|
12
|
-
exports.sanitizeSlug = sanitizeSlug;
|
|
13
|
-
exports.sanitizeURI = sanitizeURI;
|
|
14
|
-
exports.stripProtocol = stripProtocol;
|
|
15
|
-
var _partialRight2 = _interopRequireDefault(require("lodash/partialRight"));
|
|
16
|
-
var _flow2 = _interopRequireDefault(require("lodash/flow"));
|
|
17
|
-
var _escapeRegExp2 = _interopRequireDefault(require("lodash/escapeRegExp"));
|
|
18
|
-
var _isString2 = _interopRequireDefault(require("lodash/isString"));
|
|
19
|
-
var _url = _interopRequireDefault(require("url"));
|
|
20
|
-
var _urlJoin = _interopRequireDefault(require("url-join"));
|
|
21
|
-
var _diacritics = _interopRequireDefault(require("diacritics"));
|
|
22
|
-
var _sanitizeFilename = _interopRequireDefault(require("sanitize-filename"));
|
|
23
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
|
+
import _partialRight from "lodash/partialRight";
|
|
2
|
+
import _flow from "lodash/flow";
|
|
3
|
+
import _escapeRegExp from "lodash/escapeRegExp";
|
|
4
|
+
import _isString from "lodash/isString";
|
|
24
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
25
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
26
7
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
27
8
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
28
9
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
+
import url from 'url';
|
|
11
|
+
import urlJoin from 'url-join';
|
|
12
|
+
import diacritics from 'diacritics';
|
|
13
|
+
import sanitizeFilename from 'sanitize-filename';
|
|
29
14
|
function getUrl(urlString, direct) {
|
|
30
15
|
return `${direct ? '/#' : ''}${urlString}`;
|
|
31
16
|
}
|
|
32
|
-
function getCollectionUrl(collectionName, direct) {
|
|
17
|
+
export function getCollectionUrl(collectionName, direct) {
|
|
33
18
|
return getUrl(`/collections/${collectionName}`, direct);
|
|
34
19
|
}
|
|
35
|
-
function getNewEntryUrl(collectionName, direct) {
|
|
20
|
+
export function getNewEntryUrl(collectionName, direct) {
|
|
36
21
|
return getUrl(`/collections/${collectionName}/new`, direct);
|
|
37
22
|
}
|
|
38
|
-
function addParams(urlString, params) {
|
|
39
|
-
const parsedUrl =
|
|
23
|
+
export function addParams(urlString, params) {
|
|
24
|
+
const parsedUrl = url.parse(urlString, true);
|
|
40
25
|
parsedUrl.query = _objectSpread(_objectSpread({}, parsedUrl.query), params);
|
|
41
|
-
return
|
|
26
|
+
return url.format(parsedUrl);
|
|
42
27
|
}
|
|
43
|
-
function stripProtocol(urlString) {
|
|
28
|
+
export function stripProtocol(urlString) {
|
|
44
29
|
const protocolEndIndex = urlString.indexOf('//');
|
|
45
30
|
return protocolEndIndex > -1 ? urlString.slice(protocolEndIndex + 2) : urlString;
|
|
46
31
|
}
|
|
@@ -60,7 +45,7 @@ function validURIChar(char) {
|
|
|
60
45
|
function validIRIChar(char) {
|
|
61
46
|
return uriChars.test(char) || ucsChars.test(char);
|
|
62
47
|
}
|
|
63
|
-
function getCharReplacer(encoding, replacement) {
|
|
48
|
+
export function getCharReplacer(encoding, replacement) {
|
|
64
49
|
let validChar;
|
|
65
50
|
if (encoding === 'unicode') {
|
|
66
51
|
validChar = validIRIChar;
|
|
@@ -77,15 +62,15 @@ function getCharReplacer(encoding, replacement) {
|
|
|
77
62
|
return char => validChar(char) ? char : replacement;
|
|
78
63
|
}
|
|
79
64
|
// `sanitizeURI` does not actually URI-encode the chars (that is the browser's and server's job), just removes the ones that are not allowed.
|
|
80
|
-
function sanitizeURI(str, options) {
|
|
65
|
+
export function sanitizeURI(str, options) {
|
|
81
66
|
const {
|
|
82
67
|
replacement = '',
|
|
83
68
|
encoding = 'unicode'
|
|
84
69
|
} = options || {};
|
|
85
|
-
if (!(
|
|
70
|
+
if (!_isString(str)) {
|
|
86
71
|
throw new Error('The input slug must be a string.');
|
|
87
72
|
}
|
|
88
|
-
if (!(
|
|
73
|
+
if (!_isString(replacement)) {
|
|
89
74
|
throw new Error('`options.replacement` must be a string.');
|
|
90
75
|
}
|
|
91
76
|
|
|
@@ -93,15 +78,15 @@ function sanitizeURI(str, options) {
|
|
|
93
78
|
// `split` converts things like emojis into UTF-16 surrogate pairs.
|
|
94
79
|
return Array.from(str).map(getCharReplacer(encoding, replacement)).join('');
|
|
95
80
|
}
|
|
96
|
-
function sanitizeChar(char, options) {
|
|
81
|
+
export function sanitizeChar(char, options) {
|
|
97
82
|
const {
|
|
98
83
|
encoding = 'unicode',
|
|
99
84
|
sanitize_replacement: replacement = ''
|
|
100
85
|
} = options || {};
|
|
101
86
|
return getCharReplacer(encoding, replacement)(char);
|
|
102
87
|
}
|
|
103
|
-
function sanitizeSlug(str, options) {
|
|
104
|
-
if (!(
|
|
88
|
+
export function sanitizeSlug(str, options) {
|
|
89
|
+
if (!_isString(str)) {
|
|
105
90
|
throw new Error('The input slug must be a string.');
|
|
106
91
|
}
|
|
107
92
|
const {
|
|
@@ -109,20 +94,20 @@ function sanitizeSlug(str, options) {
|
|
|
109
94
|
clean_accents: stripDiacritics,
|
|
110
95
|
sanitize_replacement: replacement
|
|
111
96
|
} = options || {};
|
|
112
|
-
const sanitizedSlug = (
|
|
97
|
+
const sanitizedSlug = _flow([...(stripDiacritics ? [diacritics.remove] : []), _partialRight(sanitizeURI, {
|
|
113
98
|
replacement,
|
|
114
99
|
encoding
|
|
115
|
-
}), (
|
|
100
|
+
}), _partialRight(sanitizeFilename, {
|
|
116
101
|
replacement
|
|
117
102
|
})])(str);
|
|
118
103
|
|
|
119
104
|
// Remove any doubled or leading/trailing replacement characters (that were added in the sanitizers).
|
|
120
|
-
const doubleReplacement = new RegExp(`(?:${(
|
|
121
|
-
const trailingReplacement = new RegExp(`${(
|
|
122
|
-
const leadingReplacement = new RegExp(`^${(
|
|
105
|
+
const doubleReplacement = new RegExp(`(?:${_escapeRegExp(replacement)})+`, 'g');
|
|
106
|
+
const trailingReplacement = new RegExp(`${_escapeRegExp(replacement)}$`);
|
|
107
|
+
const leadingReplacement = new RegExp(`^${_escapeRegExp(replacement)}`);
|
|
123
108
|
const normalizedSlug = sanitizedSlug.replace(doubleReplacement, replacement).replace(leadingReplacement, '').replace(trailingReplacement, '');
|
|
124
109
|
return normalizedSlug;
|
|
125
110
|
}
|
|
126
|
-
function joinUrlPath(base, ...path) {
|
|
127
|
-
return (
|
|
111
|
+
export function joinUrlPath(base, ...path) {
|
|
112
|
+
return urlJoin(base, ...path);
|
|
128
113
|
}
|
package/dist/esm/mediaLibrary.js
CHANGED
|
@@ -1,36 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _once2 = _interopRequireDefault(require("lodash/once"));
|
|
4
|
-
var _registry = require("./lib/registry");
|
|
5
|
-
var _redux = require("./redux");
|
|
6
|
-
var _config = require("./actions/config");
|
|
7
|
-
var _mediaLibrary = require("./actions/mediaLibrary");
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
|
+
import _once from "lodash/once";
|
|
9
2
|
/**
|
|
10
3
|
* This module is currently concerned only with external media libraries
|
|
11
4
|
* registered via `registerMediaLibrary`.
|
|
12
5
|
*/
|
|
13
|
-
|
|
6
|
+
import { getMediaLibrary } from './lib/registry';
|
|
7
|
+
import { store } from './redux';
|
|
8
|
+
import { configFailed } from './actions/config';
|
|
9
|
+
import { createMediaLibrary, insertMedia } from './actions/mediaLibrary';
|
|
14
10
|
function handleInsert(url) {
|
|
15
11
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
16
12
|
// @ts-ignore
|
|
17
|
-
return
|
|
13
|
+
return store.dispatch(insertMedia(url, undefined));
|
|
18
14
|
}
|
|
19
|
-
const initializeMediaLibrary = (
|
|
20
|
-
const lib =
|
|
15
|
+
const initializeMediaLibrary = _once(async function initializeMediaLibrary(name, options) {
|
|
16
|
+
const lib = getMediaLibrary(name);
|
|
21
17
|
if (!lib) {
|
|
22
18
|
const err = new Error(`Missing external media library '${name}'. Please use 'registerMediaLibrary' to register it.`);
|
|
23
|
-
|
|
19
|
+
store.dispatch(configFailed(err));
|
|
24
20
|
} else {
|
|
25
21
|
const instance = await lib.init({
|
|
26
22
|
options,
|
|
27
23
|
handleInsert
|
|
28
24
|
});
|
|
29
|
-
|
|
25
|
+
store.dispatch(createMediaLibrary(instance));
|
|
30
26
|
}
|
|
31
27
|
});
|
|
32
|
-
|
|
33
|
-
const state =
|
|
28
|
+
store.subscribe(() => {
|
|
29
|
+
const state = store.getState();
|
|
34
30
|
if (state) {
|
|
35
31
|
var _state$config$media_l;
|
|
36
32
|
const mediaLibraryName = (_state$config$media_l = state.config.media_library) === null || _state$config$media_l === void 0 ? void 0 : _state$config$media_l.name;
|
|
@@ -1,33 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.defaultState = exports.default = void 0;
|
|
7
|
-
var _immer = require("immer");
|
|
8
|
-
var _auth = require("../actions/auth");
|
|
9
|
-
const defaultState = exports.defaultState = {
|
|
1
|
+
import { produce } from 'immer';
|
|
2
|
+
import { AUTH_REQUEST, AUTH_SUCCESS, AUTH_FAILURE, AUTH_REQUEST_DONE, LOGOUT } from '../actions/auth';
|
|
3
|
+
export const defaultState = {
|
|
10
4
|
isFetching: false,
|
|
11
5
|
user: undefined,
|
|
12
6
|
error: undefined
|
|
13
7
|
};
|
|
14
|
-
const auth =
|
|
8
|
+
const auth = produce((state, action) => {
|
|
15
9
|
switch (action.type) {
|
|
16
|
-
case
|
|
10
|
+
case AUTH_REQUEST:
|
|
17
11
|
state.isFetching = true;
|
|
18
12
|
break;
|
|
19
|
-
case
|
|
13
|
+
case AUTH_SUCCESS:
|
|
20
14
|
state.user = action.payload;
|
|
21
15
|
break;
|
|
22
|
-
case
|
|
16
|
+
case AUTH_FAILURE:
|
|
23
17
|
state.error = action.payload && action.payload.toString();
|
|
24
18
|
break;
|
|
25
|
-
case
|
|
19
|
+
case AUTH_REQUEST_DONE:
|
|
26
20
|
state.isFetching = false;
|
|
27
21
|
break;
|
|
28
|
-
case
|
|
22
|
+
case LOGOUT:
|
|
29
23
|
state.user = undefined;
|
|
30
24
|
state.isFetching = false;
|
|
31
25
|
}
|
|
32
26
|
}, defaultState);
|
|
33
|
-
|
|
27
|
+
export default auth;
|