decap-cms-core 3.6.3 → 3.7.1
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 +25 -25
- package/dist/decap-cms-core.js.LICENSE.txt +14 -8
- package/dist/decap-cms-core.js.map +1 -1
- package/dist/esm/actions/config.js +57 -49
- package/dist/esm/actions/editorialWorkflow.js +4 -4
- package/dist/esm/actions/entries.js +8 -14
- package/dist/esm/actions/mediaLibrary.js +6 -11
- package/dist/esm/actions/search.js +2 -2
- package/dist/esm/actions/status.js +2 -8
- package/dist/esm/backend.js +70 -79
- package/dist/esm/bootstrap.js +3 -2
- package/dist/esm/components/App/App.js +28 -34
- package/dist/esm/components/App/Header.js +32 -39
- package/dist/esm/components/Collection/Collection.js +45 -48
- package/dist/esm/components/Collection/CollectionSearch.js +76 -81
- package/dist/esm/components/Collection/CollectionTop.js +1 -2
- package/dist/esm/components/Collection/Entries/Entries.js +2 -4
- package/dist/esm/components/Collection/Entries/EntriesCollection.js +25 -29
- package/dist/esm/components/Collection/Entries/EntriesSearch.js +34 -38
- package/dist/esm/components/Collection/Entries/EntryCard.js +8 -13
- package/dist/esm/components/Collection/Entries/EntryListing.js +72 -76
- package/dist/esm/components/Collection/FilterControl.js +1 -1
- package/dist/esm/components/Collection/GroupControl.js +1 -1
- package/dist/esm/components/Collection/NestedCollection.js +50 -53
- package/dist/esm/components/Collection/Sidebar.js +35 -38
- package/dist/esm/components/Collection/SortControl.js +3 -3
- package/dist/esm/components/Collection/ViewStyleControl.js +1 -2
- package/dist/esm/components/Editor/Editor.js +197 -201
- package/dist/esm/components/Editor/EditorControlPane/EditorControl.js +79 -87
- package/dist/esm/components/Editor/EditorControlPane/EditorControlPane.js +75 -86
- package/dist/esm/components/Editor/EditorControlPane/Widget.js +226 -228
- package/dist/esm/components/Editor/EditorInterface.js +69 -80
- package/dist/esm/components/Editor/EditorPreviewPane/EditorPreview.js +1 -2
- package/dist/esm/components/Editor/EditorPreviewPane/EditorPreviewContent.js +20 -28
- package/dist/esm/components/Editor/EditorPreviewPane/EditorPreviewPane.js +163 -161
- package/dist/esm/components/Editor/EditorPreviewPane/PreviewHOC.js +4 -8
- package/dist/esm/components/Editor/EditorToolbar.js +335 -347
- package/dist/esm/components/Editor/withWorkflow.js +5 -6
- package/dist/esm/components/MediaLibrary/MediaLibrary.js +304 -294
- package/dist/esm/components/MediaLibrary/MediaLibraryButtons.js +40 -46
- package/dist/esm/components/MediaLibrary/MediaLibraryCard.js +1 -2
- package/dist/esm/components/MediaLibrary/MediaLibraryCardGrid.js +8 -13
- package/dist/esm/components/MediaLibrary/MediaLibraryModal.js +3 -3
- package/dist/esm/components/MediaLibrary/MediaLibrarySearch.js +1 -2
- package/dist/esm/components/MediaLibrary/MediaLibraryTop.js +3 -6
- package/dist/esm/components/UI/DragDrop.js +15 -23
- package/dist/esm/components/UI/ErrorBoundary.js +23 -25
- package/dist/esm/components/UI/Modal.js +10 -12
- package/dist/esm/components/UI/Notifications.js +4 -8
- package/dist/esm/components/UI/SettingsDropdown.js +4 -8
- package/dist/esm/components/Workflow/Workflow.js +19 -20
- package/dist/esm/components/Workflow/WorkflowCard.js +2 -4
- package/dist/esm/components/Workflow/WorkflowList.js +105 -113
- package/dist/esm/constants/configSchema.js +18 -16
- package/dist/esm/formats/formats.js +11 -12
- package/dist/esm/formats/frontmatter.js +17 -21
- package/dist/esm/formats/toml.js +2 -2
- package/dist/esm/formats/yaml.js +2 -6
- package/dist/esm/index.js +3 -7
- package/dist/esm/integrations/providers/algolia/implementation.js +12 -14
- package/dist/esm/integrations/providers/assetStore/implementation.js +10 -12
- package/dist/esm/lib/formatters.js +13 -17
- package/dist/esm/lib/i18n.js +35 -33
- package/dist/esm/lib/phrases.js +2 -2
- package/dist/esm/lib/polyfill.js +8 -0
- package/dist/esm/lib/registry.js +35 -35
- package/dist/esm/lib/serializeEntryValues.js +3 -3
- package/dist/esm/lib/stega.js +142 -0
- package/dist/esm/lib/urlHelper.js +16 -18
- package/dist/esm/mediaLibrary.js +3 -4
- package/dist/esm/reducers/collections.js +26 -42
- package/dist/esm/reducers/combinedReducer.js +3 -6
- package/dist/esm/reducers/config.js +3 -7
- package/dist/esm/reducers/editorialWorkflow.js +5 -9
- package/dist/esm/reducers/entries.js +33 -35
- package/dist/esm/reducers/entryDraft.js +2 -2
- package/dist/esm/reducers/integrations.js +8 -14
- package/dist/esm/reducers/mediaLibrary.js +18 -20
- package/dist/esm/reducers/notifications.js +4 -8
- package/dist/esm/types/immutable.js +7 -1
- package/dist/esm/valueObjects/AssetProxy.js +1 -9
- package/dist/esm/valueObjects/EditorComponent.js +18 -25
- package/dist/esm/valueObjects/Entry.js +2 -2
- package/index.d.ts +2 -0
- package/package.json +14 -11
- package/src/actions/__tests__/config.spec.js +3 -3
- package/src/actions/config.ts +3 -1
- package/src/actions/editorialWorkflow.ts +1 -1
- package/src/actions/entries.ts +1 -1
- package/src/actions/search.ts +1 -1
- package/src/backend.ts +8 -1
- package/src/bootstrap.js +1 -0
- package/src/components/App/App.js +5 -0
- package/src/components/App/Header.js +3 -0
- package/src/components/Collection/Collection.js +5 -0
- package/src/components/Collection/CollectionSearch.js +5 -0
- package/src/components/Collection/Entries/EntriesCollection.js +4 -1
- package/src/components/Collection/Entries/EntriesSearch.js +4 -1
- package/src/components/Collection/Entries/EntryListing.js +5 -0
- package/src/components/Collection/Entries/__tests__/__snapshots__/EntriesCollection.spec.js.snap +0 -4
- package/src/components/Collection/NestedCollection.js +6 -1
- package/src/components/Collection/Sidebar.js +5 -0
- package/src/components/Editor/Editor.js +4 -1
- package/src/components/Editor/EditorControlPane/EditorControl.js +7 -1
- package/src/components/Editor/EditorControlPane/Widget.js +5 -0
- package/src/components/Editor/EditorPreviewPane/EditorPreviewPane.js +1 -1
- package/src/components/Editor/EditorToolbar.js +3 -0
- package/src/components/Editor/__tests__/Editor.spec.js +3 -4
- package/src/components/Editor/__tests__/__snapshots__/Editor.spec.js.snap +5 -5
- package/src/components/Editor/__tests__/__snapshots__/EditorToolbar.spec.js.snap +708 -393
- package/src/components/MediaLibrary/MediaLibrary.js +5 -1
- package/src/components/MediaLibrary/MediaLibraryModal.js +1 -1
- package/src/components/UI/ErrorBoundary.js +6 -1
- package/src/components/UI/Modal.js +3 -0
- package/src/components/Workflow/Workflow.js +3 -0
- package/src/components/Workflow/WorkflowList.js +5 -0
- package/src/constants/__tests__/configSchema.spec.js +1 -1
- package/src/formats/formats.ts +1 -1
- package/src/formats/toml.ts +2 -2
- package/src/integrations/providers/algolia/implementation.js +2 -2
- package/src/integrations/providers/assetStore/implementation.js +2 -1
- package/src/lib/formatters.ts +4 -1
- package/src/lib/i18n.ts +3 -1
- package/src/lib/phrases.js +1 -1
- package/src/lib/polyfill.js +9 -0
- package/src/lib/serializeEntryValues.js +1 -1
- package/src/lib/stega.ts +145 -0
- package/src/lib/urlHelper.ts +4 -1
- package/src/mediaLibrary.ts +1 -1
- package/src/reducers/collections.ts +2 -1
- package/src/reducers/editorialWorkflow.ts +1 -1
- package/src/reducers/entries.ts +6 -1
- package/src/reducers/entryDraft.js +1 -1
- package/src/types/immutable.ts +10 -0
- package/src/types/redux.ts +2 -0
- package/src/valueObjects/EditorComponent.js +1 -1
- package/src/valueObjects/Entry.ts +1 -1
package/dist/esm/lib/registry.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
const _excluded = ["name", "controlComponent", "previewComponent", "schema", "allowMapValue", "globalStyles"];
|
|
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; }
|
|
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; }
|
|
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; }
|
|
5
|
-
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; }
|
|
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; }
|
|
7
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
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
1
|
import { Map } from 'immutable';
|
|
10
2
|
import { produce } from 'immer';
|
|
11
3
|
import { oneLine } from 'common-tags';
|
|
@@ -70,9 +62,10 @@ export default {
|
|
|
70
62
|
* - raw {boolean} if `true`, `style` value is expected to be a CSS string
|
|
71
63
|
*/
|
|
72
64
|
export function registerPreviewStyle(style, opts) {
|
|
73
|
-
registry.previewStyles.push(
|
|
65
|
+
registry.previewStyles.push({
|
|
66
|
+
...opts,
|
|
74
67
|
value: style
|
|
75
|
-
})
|
|
68
|
+
});
|
|
76
69
|
}
|
|
77
70
|
export function getPreviewStyles() {
|
|
78
71
|
return registry.previewStyles;
|
|
@@ -111,14 +104,14 @@ export function registerWidget(name, control, preview, schema = {}) {
|
|
|
111
104
|
};
|
|
112
105
|
} else if (typeof name === 'object') {
|
|
113
106
|
const {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
107
|
+
name: widgetName,
|
|
108
|
+
controlComponent: control,
|
|
109
|
+
previewComponent: preview,
|
|
110
|
+
schema = {},
|
|
111
|
+
allowMapValue,
|
|
112
|
+
globalStyles,
|
|
113
|
+
...options
|
|
114
|
+
} = name;
|
|
122
115
|
if (registry.widgets[widgetName]) {
|
|
123
116
|
console.warn(oneLine`
|
|
124
117
|
Multiple widgets registered with name "${widgetName}". Only the last widget registered with
|
|
@@ -128,13 +121,14 @@ export function registerWidget(name, control, preview, schema = {}) {
|
|
|
128
121
|
if (!control) {
|
|
129
122
|
throw Error(`Widget "${widgetName}" registered without \`controlComponent\`.`);
|
|
130
123
|
}
|
|
131
|
-
registry.widgets[widgetName] =
|
|
124
|
+
registry.widgets[widgetName] = {
|
|
132
125
|
control,
|
|
133
126
|
preview,
|
|
134
127
|
schema,
|
|
135
128
|
globalStyles,
|
|
136
|
-
allowMapValue
|
|
137
|
-
|
|
129
|
+
allowMapValue,
|
|
130
|
+
...options
|
|
131
|
+
};
|
|
138
132
|
} else {
|
|
139
133
|
console.error('`registerWidget` failed, called with incorrect arguments.');
|
|
140
134
|
}
|
|
@@ -144,9 +138,10 @@ export function getWidget(name) {
|
|
|
144
138
|
}
|
|
145
139
|
export function getWidgets() {
|
|
146
140
|
return produce(Object.entries(registry.widgets), draft => {
|
|
147
|
-
return draft.map(([key, value]) =>
|
|
148
|
-
name: key
|
|
149
|
-
|
|
141
|
+
return draft.map(([key, value]) => ({
|
|
142
|
+
name: key,
|
|
143
|
+
...value
|
|
144
|
+
}));
|
|
150
145
|
});
|
|
151
146
|
}
|
|
152
147
|
export function resolveWidget(name) {
|
|
@@ -222,9 +217,10 @@ export function registerMediaLibrary(mediaLibrary, options) {
|
|
|
222
217
|
if (registry.mediaLibraries.find(ml => mediaLibrary.name === ml.name)) {
|
|
223
218
|
throw new Error(`A media library named ${mediaLibrary.name} has already been registered.`);
|
|
224
219
|
}
|
|
225
|
-
registry.mediaLibraries.push(
|
|
220
|
+
registry.mediaLibraries.push({
|
|
221
|
+
...mediaLibrary,
|
|
226
222
|
options
|
|
227
|
-
})
|
|
223
|
+
});
|
|
228
224
|
}
|
|
229
225
|
export function getMediaLibrary(name) {
|
|
230
226
|
return registry.mediaLibraries.find(ml => ml.name === name);
|
|
@@ -254,7 +250,9 @@ export async function invokeEvent({
|
|
|
254
250
|
}) {
|
|
255
251
|
validateEventName(name);
|
|
256
252
|
const handlers = registry.eventHandlers[name];
|
|
257
|
-
let _data =
|
|
253
|
+
let _data = {
|
|
254
|
+
...data
|
|
255
|
+
};
|
|
258
256
|
for (const {
|
|
259
257
|
handler,
|
|
260
258
|
options
|
|
@@ -262,9 +260,10 @@ export async function invokeEvent({
|
|
|
262
260
|
const result = await handler(_data, options);
|
|
263
261
|
if (result !== undefined) {
|
|
264
262
|
const entry = _data.entry.set('data', result);
|
|
265
|
-
_data =
|
|
263
|
+
_data = {
|
|
264
|
+
...data,
|
|
266
265
|
entry
|
|
267
|
-
}
|
|
266
|
+
};
|
|
268
267
|
}
|
|
269
268
|
}
|
|
270
269
|
return _data.entry.get('data');
|
|
@@ -307,9 +306,10 @@ export function getCustomFormatsExtensions() {
|
|
|
307
306
|
return Object.entries(registry.formats).reduce(function (acc, [name, {
|
|
308
307
|
extension
|
|
309
308
|
}]) {
|
|
310
|
-
return
|
|
309
|
+
return {
|
|
310
|
+
...acc,
|
|
311
311
|
[name]: extension
|
|
312
|
-
}
|
|
312
|
+
};
|
|
313
313
|
}, {});
|
|
314
314
|
}
|
|
315
315
|
|
|
@@ -318,12 +318,12 @@ export function getCustomFormatsFormatters() {
|
|
|
318
318
|
return Object.entries(registry.formats).reduce(function (acc, [name, {
|
|
319
319
|
formatter
|
|
320
320
|
}]) {
|
|
321
|
-
return
|
|
321
|
+
return {
|
|
322
|
+
...acc,
|
|
322
323
|
[name]: formatter
|
|
323
|
-
}
|
|
324
|
+
};
|
|
324
325
|
}, {});
|
|
325
326
|
}
|
|
326
327
|
export function getFormatter(name) {
|
|
327
|
-
|
|
328
|
-
return (_registry$formats$nam = registry.formats[name]) === null || _registry$formats$nam === void 0 ? void 0 : _registry$formats$nam.formatter;
|
|
328
|
+
return registry.formats[name]?.formatter;
|
|
329
329
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import isNil from 'lodash/isNil';
|
|
2
2
|
import { Map, List } from 'immutable';
|
|
3
3
|
import { getWidgetValueSerializer } from './registry';
|
|
4
4
|
|
|
@@ -44,12 +44,12 @@ function runSerializer(values, fields, method) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
// Run serialization method on value if not null or undefined
|
|
47
|
-
if (serializer && !
|
|
47
|
+
if (serializer && !isNil(value)) {
|
|
48
48
|
return acc.set(fieldName, serializer[method](value));
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
// If no serializer is registered for the field's widget, use the field as is
|
|
52
|
-
if (!
|
|
52
|
+
if (!isNil(value)) {
|
|
53
53
|
return acc.set(fieldName, value);
|
|
54
54
|
}
|
|
55
55
|
return acc;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { vercelStegaEncode } from '@vercel/stega';
|
|
2
|
+
import { isImmutableMap, isImmutableList } from '../types/immutable';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Context passed to encode functions, containing the current state of the encoding process
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Get the fields that should be used for encoding nested values
|
|
10
|
+
*/
|
|
11
|
+
function getNestedFields(f) {
|
|
12
|
+
if (f) {
|
|
13
|
+
if ('types' in f) {
|
|
14
|
+
return f.types ?? [];
|
|
15
|
+
}
|
|
16
|
+
if ('fields' in f) {
|
|
17
|
+
return f.fields ?? [];
|
|
18
|
+
}
|
|
19
|
+
if ('field' in f) {
|
|
20
|
+
return f.field ? [f.field] : [];
|
|
21
|
+
}
|
|
22
|
+
return [f];
|
|
23
|
+
}
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Encode a string value by appending steganographic data
|
|
29
|
+
* For markdown fields, encode each paragraph separately
|
|
30
|
+
*/
|
|
31
|
+
function encodeString(value, {
|
|
32
|
+
fields,
|
|
33
|
+
path
|
|
34
|
+
}) {
|
|
35
|
+
const [field] = fields;
|
|
36
|
+
if (!field) return value;
|
|
37
|
+
const {
|
|
38
|
+
widget
|
|
39
|
+
} = field;
|
|
40
|
+
if (widget === 'string' || widget === 'text') {
|
|
41
|
+
if ('visualEditing' in field && field.visualEditing === false) return value;
|
|
42
|
+
const stega = vercelStegaEncode({
|
|
43
|
+
decap: path
|
|
44
|
+
});
|
|
45
|
+
return value + stega;
|
|
46
|
+
}
|
|
47
|
+
if (widget === 'markdown') {
|
|
48
|
+
const stega = vercelStegaEncode({
|
|
49
|
+
decap: path
|
|
50
|
+
});
|
|
51
|
+
const blocks = value.split(/(\n\n+)/);
|
|
52
|
+
return blocks.map(block => block.trim() ? block + stega : block).join('');
|
|
53
|
+
}
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Encode a list of values, handling both simple values and nested objects/lists
|
|
59
|
+
* For typed lists, use the type field to determine which fields to use
|
|
60
|
+
*/
|
|
61
|
+
function encodeList(list, ctx) {
|
|
62
|
+
let newList = list;
|
|
63
|
+
for (let i = 0; i < newList.size; i++) {
|
|
64
|
+
const item = newList.get(i);
|
|
65
|
+
if (isImmutableMap(item)) {
|
|
66
|
+
const itemType = item.get('type');
|
|
67
|
+
if (typeof itemType === 'string') {
|
|
68
|
+
// For typed items, look up fields based on type
|
|
69
|
+
const field = ctx.fields.find(f => f.name === itemType);
|
|
70
|
+
const newItem = ctx.visit(item, getNestedFields(field), `${ctx.path}.${i}`);
|
|
71
|
+
newList = newList.set(i, newItem);
|
|
72
|
+
} else {
|
|
73
|
+
// For untyped items, use current fields
|
|
74
|
+
const newItem = ctx.visit(item, ctx.fields, `${ctx.path}.${i}`);
|
|
75
|
+
newList = newList.set(i, newItem);
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
78
|
+
// For simple values, use first field if available
|
|
79
|
+
const field = ctx.fields[0];
|
|
80
|
+
const newItem = ctx.visit(item, field ? [field] : [], `${ctx.path}.${i}`);
|
|
81
|
+
if (newItem !== item) {
|
|
82
|
+
newList = newList.set(i, newItem);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return newList;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Encode a map of values, looking up the appropriate field for each key
|
|
91
|
+
* and recursively encoding nested values
|
|
92
|
+
*/
|
|
93
|
+
function encodeMap(map, ctx) {
|
|
94
|
+
let newMap = map;
|
|
95
|
+
for (const [key, val] of newMap.entrySeq().toArray()) {
|
|
96
|
+
const field = ctx.fields.find(f => f.name === key);
|
|
97
|
+
if (field) {
|
|
98
|
+
const fields = getNestedFields(field);
|
|
99
|
+
const newVal = ctx.visit(val, fields, ctx.path ? `${ctx.path}.${key}` : key);
|
|
100
|
+
if (newVal !== val) {
|
|
101
|
+
newMap = newMap.set(key, newVal);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return newMap;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Cache for encoded values to prevent re-encoding unchanged values
|
|
110
|
+
* across keystrokes. The cache is keyed by path.
|
|
111
|
+
*/
|
|
112
|
+
const encodingCache = new Map();
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Main entry point for encoding steganographic data into entry values
|
|
116
|
+
* Uses a visitor pattern with caching to handle recursive structures
|
|
117
|
+
*/
|
|
118
|
+
export function encodeEntry(value, fields) {
|
|
119
|
+
const plainFields = fields.toJS();
|
|
120
|
+
function visit(value, fields, path = '') {
|
|
121
|
+
const cached = encodingCache.get(path);
|
|
122
|
+
if (cached === value) return value;
|
|
123
|
+
const ctx = {
|
|
124
|
+
fields,
|
|
125
|
+
path,
|
|
126
|
+
visit
|
|
127
|
+
};
|
|
128
|
+
let result;
|
|
129
|
+
if (isImmutableList(value)) {
|
|
130
|
+
result = encodeList(value, ctx);
|
|
131
|
+
} else if (isImmutableMap(value)) {
|
|
132
|
+
result = encodeMap(value, ctx);
|
|
133
|
+
} else if (typeof value === 'string') {
|
|
134
|
+
result = encodeString(value, ctx);
|
|
135
|
+
} else {
|
|
136
|
+
result = value;
|
|
137
|
+
}
|
|
138
|
+
encodingCache.set(path, result);
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
return visit(value, plainFields);
|
|
142
|
+
}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import _partialRight from "lodash/partialRight";
|
|
2
|
-
import _flow from "lodash/flow";
|
|
3
|
-
import _escapeRegExp from "lodash/escapeRegExp";
|
|
4
|
-
import _isString from "lodash/isString";
|
|
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; }
|
|
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; }
|
|
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; }
|
|
8
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
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
1
|
import url from 'url';
|
|
11
2
|
import urlJoin from 'url-join';
|
|
12
3
|
import diacritics from 'diacritics';
|
|
13
4
|
import sanitizeFilename from 'sanitize-filename';
|
|
5
|
+
import isString from 'lodash/isString';
|
|
6
|
+
import escapeRegExp from 'lodash/escapeRegExp';
|
|
7
|
+
import flow from 'lodash/flow';
|
|
8
|
+
import partialRight from 'lodash/partialRight';
|
|
14
9
|
function getUrl(urlString, direct) {
|
|
15
10
|
return `${direct ? '/#' : ''}${urlString}`;
|
|
16
11
|
}
|
|
@@ -22,7 +17,10 @@ export function getNewEntryUrl(collectionName, direct) {
|
|
|
22
17
|
}
|
|
23
18
|
export function addParams(urlString, params) {
|
|
24
19
|
const parsedUrl = url.parse(urlString, true);
|
|
25
|
-
parsedUrl.query =
|
|
20
|
+
parsedUrl.query = {
|
|
21
|
+
...parsedUrl.query,
|
|
22
|
+
...params
|
|
23
|
+
};
|
|
26
24
|
return url.format(parsedUrl);
|
|
27
25
|
}
|
|
28
26
|
export function stripProtocol(urlString) {
|
|
@@ -67,10 +65,10 @@ export function sanitizeURI(str, options) {
|
|
|
67
65
|
replacement = '',
|
|
68
66
|
encoding = 'unicode'
|
|
69
67
|
} = options || {};
|
|
70
|
-
if (!
|
|
68
|
+
if (!isString(str)) {
|
|
71
69
|
throw new Error('The input slug must be a string.');
|
|
72
70
|
}
|
|
73
|
-
if (!
|
|
71
|
+
if (!isString(replacement)) {
|
|
74
72
|
throw new Error('`options.replacement` must be a string.');
|
|
75
73
|
}
|
|
76
74
|
|
|
@@ -86,7 +84,7 @@ export function sanitizeChar(char, options) {
|
|
|
86
84
|
return getCharReplacer(encoding, replacement)(char);
|
|
87
85
|
}
|
|
88
86
|
export function sanitizeSlug(str, options) {
|
|
89
|
-
if (!
|
|
87
|
+
if (!isString(str)) {
|
|
90
88
|
throw new Error('The input slug must be a string.');
|
|
91
89
|
}
|
|
92
90
|
const {
|
|
@@ -94,17 +92,17 @@ export function sanitizeSlug(str, options) {
|
|
|
94
92
|
clean_accents: stripDiacritics,
|
|
95
93
|
sanitize_replacement: replacement
|
|
96
94
|
} = options || {};
|
|
97
|
-
const sanitizedSlug =
|
|
95
|
+
const sanitizedSlug = flow([...(stripDiacritics ? [diacritics.remove] : []), partialRight(sanitizeURI, {
|
|
98
96
|
replacement,
|
|
99
97
|
encoding
|
|
100
|
-
}),
|
|
98
|
+
}), partialRight(sanitizeFilename, {
|
|
101
99
|
replacement
|
|
102
100
|
})])(str);
|
|
103
101
|
|
|
104
102
|
// Remove any doubled or leading/trailing replacement characters (that were added in the sanitizers).
|
|
105
|
-
const doubleReplacement = new RegExp(`(?:${
|
|
106
|
-
const trailingReplacement = new RegExp(`${
|
|
107
|
-
const leadingReplacement = new RegExp(`^${
|
|
103
|
+
const doubleReplacement = new RegExp(`(?:${escapeRegExp(replacement)})+`, 'g');
|
|
104
|
+
const trailingReplacement = new RegExp(`${escapeRegExp(replacement)}$`);
|
|
105
|
+
const leadingReplacement = new RegExp(`^${escapeRegExp(replacement)}`);
|
|
108
106
|
const normalizedSlug = sanitizedSlug.replace(doubleReplacement, replacement).replace(leadingReplacement, '').replace(trailingReplacement, '');
|
|
109
107
|
return normalizedSlug;
|
|
110
108
|
}
|
package/dist/esm/mediaLibrary.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import _once from "lodash/once";
|
|
2
1
|
/**
|
|
3
2
|
* This module is currently concerned only with external media libraries
|
|
4
3
|
* registered via `registerMediaLibrary`.
|
|
5
4
|
*/
|
|
5
|
+
import once from 'lodash/once';
|
|
6
6
|
import { getMediaLibrary } from './lib/registry';
|
|
7
7
|
import { store } from './redux';
|
|
8
8
|
import { configFailed } from './actions/config';
|
|
@@ -12,7 +12,7 @@ function handleInsert(url) {
|
|
|
12
12
|
// @ts-ignore
|
|
13
13
|
return store.dispatch(insertMedia(url, undefined));
|
|
14
14
|
}
|
|
15
|
-
const initializeMediaLibrary =
|
|
15
|
+
const initializeMediaLibrary = once(async function initializeMediaLibrary(name, options) {
|
|
16
16
|
const lib = getMediaLibrary(name);
|
|
17
17
|
if (!lib) {
|
|
18
18
|
const err = new Error(`Missing external media library '${name}'. Please use 'registerMediaLibrary' to register it.`);
|
|
@@ -28,8 +28,7 @@ const initializeMediaLibrary = _once(async function initializeMediaLibrary(name,
|
|
|
28
28
|
store.subscribe(() => {
|
|
29
29
|
const state = store.getState();
|
|
30
30
|
if (state) {
|
|
31
|
-
|
|
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;
|
|
31
|
+
const mediaLibraryName = state.config.media_library?.name;
|
|
33
32
|
if (mediaLibraryName && !state.mediaLibrary.get('externalLibrary')) {
|
|
34
33
|
const mediaLibraryConfig = state.config.media_library;
|
|
35
34
|
initializeMediaLibrary(mediaLibraryName, mediaLibraryConfig);
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import _escapeRegExp from "lodash/escapeRegExp";
|
|
2
|
-
import _get from "lodash/get";
|
|
3
|
-
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; }
|
|
4
|
-
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; }
|
|
5
|
-
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; }
|
|
6
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
7
|
-
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); }
|
|
8
1
|
import { List, Set, fromJS, OrderedMap } from 'immutable';
|
|
2
|
+
import get from 'lodash/get';
|
|
3
|
+
import escapeRegExp from 'lodash/escapeRegExp';
|
|
9
4
|
import { stringTemplate } from 'decap-cms-lib-widgets';
|
|
10
5
|
import consoleError from '../lib/consoleError';
|
|
11
6
|
import { CONFIG_SUCCESS } from '../actions/config';
|
|
@@ -37,7 +32,7 @@ function collections(state = defaultState, action) {
|
|
|
37
32
|
const selectors = {
|
|
38
33
|
[FOLDER]: {
|
|
39
34
|
entryExtension(collection) {
|
|
40
|
-
const ext = collection.get('extension') ||
|
|
35
|
+
const ext = collection.get('extension') || get(getFormatExtensions(), collection.get('format') || 'frontmatter');
|
|
41
36
|
if (!ext) {
|
|
42
37
|
throw new Error(`No extension found for format ${collection.get('format')}`);
|
|
43
38
|
}
|
|
@@ -51,9 +46,8 @@ const selectors = {
|
|
|
51
46
|
return `${folder}/${slug}.${this.entryExtension(collection)}`;
|
|
52
47
|
},
|
|
53
48
|
entrySlug(collection, path) {
|
|
54
|
-
var _path$split$pop;
|
|
55
49
|
const folder = collection.get('folder').replace(/\/$/, '');
|
|
56
|
-
const slug =
|
|
50
|
+
const slug = path.split(folder + '/').pop()?.replace(new RegExp(`\\.${escapeRegExp(this.entryExtension(collection))}$`), '');
|
|
57
51
|
return slug;
|
|
58
52
|
},
|
|
59
53
|
allowNewEntries(collection) {
|
|
@@ -69,7 +63,7 @@ const selectors = {
|
|
|
69
63
|
[FILES]: {
|
|
70
64
|
fileForEntry(collection, slug) {
|
|
71
65
|
const files = collection.get('files');
|
|
72
|
-
return files && files.filter(f =>
|
|
66
|
+
return files && files.filter(f => f?.get('name') === slug).get(0);
|
|
73
67
|
},
|
|
74
68
|
fields(collection, slug) {
|
|
75
69
|
const file = this.fileForEntry(collection, slug);
|
|
@@ -80,7 +74,7 @@ const selectors = {
|
|
|
80
74
|
return file && file.get('file');
|
|
81
75
|
},
|
|
82
76
|
entrySlug(collection, path) {
|
|
83
|
-
const file = collection.get('files').filter(f =>
|
|
77
|
+
const file = collection.get('files').filter(f => f?.get('file') === path).get(0);
|
|
84
78
|
return file && file.get('name');
|
|
85
79
|
},
|
|
86
80
|
entryLabel(collection, slug) {
|
|
@@ -104,15 +98,13 @@ function getFieldsWithMediaFolders(fields) {
|
|
|
104
98
|
acc = [...acc, f];
|
|
105
99
|
}
|
|
106
100
|
if (f.has('fields')) {
|
|
107
|
-
|
|
108
|
-
const fields = (_f$get = f.get('fields')) === null || _f$get === void 0 ? void 0 : _f$get.toArray();
|
|
101
|
+
const fields = f.get('fields')?.toArray();
|
|
109
102
|
acc = [...acc, ...getFieldsWithMediaFolders(fields)];
|
|
110
103
|
} else if (f.has('field')) {
|
|
111
104
|
const field = f.get('field');
|
|
112
105
|
acc = [...acc, ...getFieldsWithMediaFolders([field])];
|
|
113
106
|
} else if (f.has('types')) {
|
|
114
|
-
|
|
115
|
-
const types = (_f$get2 = f.get('types')) === null || _f$get2 === void 0 ? void 0 : _f$get2.toArray();
|
|
107
|
+
const types = f.get('types')?.toArray();
|
|
116
108
|
acc = [...acc, ...getFieldsWithMediaFolders(types)];
|
|
117
109
|
}
|
|
118
110
|
return acc;
|
|
@@ -120,16 +112,14 @@ function getFieldsWithMediaFolders(fields) {
|
|
|
120
112
|
return fieldsWithMediaFolders;
|
|
121
113
|
}
|
|
122
114
|
export function getFileFromSlug(collection, slug) {
|
|
123
|
-
|
|
124
|
-
return (_collection$get = collection.get('files')) === null || _collection$get === void 0 ? void 0 : _collection$get.toArray().find(f => f.get('name') === slug);
|
|
115
|
+
return collection.get('files')?.toArray().find(f => f.get('name') === slug);
|
|
125
116
|
}
|
|
126
117
|
export function selectFieldsWithMediaFolders(collection, slug) {
|
|
127
118
|
if (collection.has('folder')) {
|
|
128
119
|
const fields = collection.get('fields').toArray();
|
|
129
120
|
return getFieldsWithMediaFolders(fields);
|
|
130
121
|
} else if (collection.has('files')) {
|
|
131
|
-
|
|
132
|
-
const fields = ((_getFileFromSlug = getFileFromSlug(collection, slug)) === null || _getFileFromSlug === void 0 ? void 0 : _getFileFromSlug.get('fields').toArray()) || [];
|
|
122
|
+
const fields = getFileFromSlug(collection, slug)?.get('fields').toArray() || [];
|
|
133
123
|
return getFieldsWithMediaFolders(fields);
|
|
134
124
|
}
|
|
135
125
|
return [];
|
|
@@ -178,15 +168,13 @@ export function getFieldsNames(fields, prefix = '') {
|
|
|
178
168
|
let names = fields.map(f => `${prefix}${f.get('name')}`);
|
|
179
169
|
fields.forEach((f, index) => {
|
|
180
170
|
if (f.has('fields')) {
|
|
181
|
-
|
|
182
|
-
const fields = (_f$get3 = f.get('fields')) === null || _f$get3 === void 0 ? void 0 : _f$get3.toArray();
|
|
171
|
+
const fields = f.get('fields')?.toArray();
|
|
183
172
|
names = [...names, ...getFieldsNames(fields, `${names[index]}.`)];
|
|
184
173
|
} else if (f.has('field')) {
|
|
185
174
|
const field = f.get('field');
|
|
186
175
|
names = [...names, ...getFieldsNames([field], `${names[index]}.`)];
|
|
187
176
|
} else if (f.has('types')) {
|
|
188
|
-
|
|
189
|
-
const types = (_f$get4 = f.get('types')) === null || _f$get4 === void 0 ? void 0 : _f$get4.toArray();
|
|
177
|
+
const types = f.get('types')?.toArray();
|
|
190
178
|
names = [...names, ...getFieldsNames(types, `${names[index]}.`)];
|
|
191
179
|
}
|
|
192
180
|
});
|
|
@@ -198,17 +186,13 @@ export function selectField(collection, key) {
|
|
|
198
186
|
let field;
|
|
199
187
|
let fields = collection.get('fields', List()).toArray();
|
|
200
188
|
while ((name = array.shift()) && fields) {
|
|
201
|
-
var _field, _field3, _field5;
|
|
202
189
|
field = fields.find(f => f.get('name') === name);
|
|
203
|
-
if (
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
fields =
|
|
209
|
-
} else if ((_field5 = field) !== null && _field5 !== void 0 && _field5.has('types')) {
|
|
210
|
-
var _field6, _field6$get;
|
|
211
|
-
fields = (_field6 = field) === null || _field6 === void 0 ? void 0 : (_field6$get = _field6.get('types')) === null || _field6$get === void 0 ? void 0 : _field6$get.toArray();
|
|
190
|
+
if (field?.has('fields')) {
|
|
191
|
+
fields = field?.get('fields')?.toArray();
|
|
192
|
+
} else if (field?.has('field')) {
|
|
193
|
+
fields = [field?.get('field')];
|
|
194
|
+
} else if (field?.has('types')) {
|
|
195
|
+
fields = field?.get('types')?.toArray();
|
|
212
196
|
}
|
|
213
197
|
}
|
|
214
198
|
return field;
|
|
@@ -268,12 +252,12 @@ export function selectInferredField(collection, fieldName) {
|
|
|
268
252
|
// If collection has no fields or fieldName is not defined within inferables list, return null
|
|
269
253
|
if (!fields || !inferableField) return null;
|
|
270
254
|
// Try to return a field of the specified type with one of the synonyms
|
|
271
|
-
const mainTypeFields = fields.filter(f =>
|
|
255
|
+
const mainTypeFields = fields.filter(f => f?.get('widget', 'string') === inferableField.type).map(f => f?.get('name'));
|
|
272
256
|
field = mainTypeFields.filter(f => inferableField.synonyms.indexOf(f) !== -1);
|
|
273
257
|
if (field && field.size > 0) return field.first();
|
|
274
258
|
|
|
275
259
|
// Try to return a field for each of the specified secondary types
|
|
276
|
-
const secondaryTypeFields = fields.filter(f => inferableField.secondaryTypes.indexOf(f
|
|
260
|
+
const secondaryTypeFields = fields.filter(f => inferableField.secondaryTypes.indexOf(f?.get('widget', 'string')) !== -1).map(f => f?.get('name'));
|
|
277
261
|
field = secondaryTypeFields.filter(f => inferableField.synonyms.indexOf(f) !== -1);
|
|
278
262
|
if (field && field.size > 0) return field.first();
|
|
279
263
|
|
|
@@ -346,9 +330,10 @@ export function selectSortableFields(collection, t) {
|
|
|
346
330
|
}
|
|
347
331
|
return {
|
|
348
332
|
key,
|
|
349
|
-
field: field
|
|
333
|
+
field: field?.toJS()
|
|
350
334
|
};
|
|
351
|
-
}).filter(item => !!item.field).map(item =>
|
|
335
|
+
}).filter(item => !!item.field).map(item => ({
|
|
336
|
+
...item.field,
|
|
352
337
|
key: item.key
|
|
353
338
|
}));
|
|
354
339
|
return fields;
|
|
@@ -375,21 +360,20 @@ export function selectFieldsComments(collection, entryMap) {
|
|
|
375
360
|
if (collection.has('folder')) {
|
|
376
361
|
fields = collection.get('fields').toArray();
|
|
377
362
|
} else if (collection.has('files')) {
|
|
378
|
-
const file = collection.get('files').find(f =>
|
|
363
|
+
const file = collection.get('files').find(f => f?.get('name') === entryMap.get('slug'));
|
|
379
364
|
fields = file.get('fields').toArray();
|
|
380
365
|
}
|
|
381
366
|
const comments = {};
|
|
382
367
|
const names = getFieldsNames(fields);
|
|
383
368
|
names.forEach(name => {
|
|
384
369
|
const field = selectField(collection, name);
|
|
385
|
-
if (field
|
|
370
|
+
if (field?.has('comment')) {
|
|
386
371
|
comments[name] = field.get('comment');
|
|
387
372
|
}
|
|
388
373
|
});
|
|
389
374
|
return comments;
|
|
390
375
|
}
|
|
391
376
|
export function selectHasMetaPath(collection) {
|
|
392
|
-
|
|
393
|
-
return collection.has('folder') && collection.get('type') === FOLDER && collection.has('meta') && ((_collection$get2 = collection.get('meta')) === null || _collection$get2 === void 0 ? void 0 : _collection$get2.has('path'));
|
|
377
|
+
return collection.has('folder') && collection.get('type') === FOLDER && collection.has('meta') && collection.get('meta')?.has('path');
|
|
394
378
|
}
|
|
395
379
|
export default collections;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
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; }
|
|
2
|
-
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; }
|
|
3
|
-
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; }
|
|
4
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
5
|
-
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); }
|
|
6
1
|
import { combineReducers } from 'redux';
|
|
7
2
|
import reducers from './index';
|
|
8
3
|
function createRootReducer() {
|
|
9
|
-
return combineReducers(
|
|
4
|
+
return combineReducers({
|
|
5
|
+
...reducers
|
|
6
|
+
});
|
|
10
7
|
}
|
|
11
8
|
export default createRootReducer;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
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; }
|
|
2
|
-
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; }
|
|
3
|
-
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; }
|
|
4
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
5
|
-
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); }
|
|
6
1
|
import { produce } from 'immer';
|
|
7
2
|
import { CONFIG_REQUEST, CONFIG_SUCCESS, CONFIG_FAILURE } from '../actions/config';
|
|
8
3
|
import { EDITORIAL_WORKFLOW } from '../constants/publishModes';
|
|
@@ -15,10 +10,11 @@ const config = produce((state, action) => {
|
|
|
15
10
|
state.isFetching = true;
|
|
16
11
|
break;
|
|
17
12
|
case CONFIG_SUCCESS:
|
|
18
|
-
return
|
|
13
|
+
return {
|
|
14
|
+
...action.payload,
|
|
19
15
|
isFetching: false,
|
|
20
16
|
error: undefined
|
|
21
|
-
}
|
|
17
|
+
};
|
|
22
18
|
case CONFIG_FAILURE:
|
|
23
19
|
state.isFetching = false;
|
|
24
20
|
state.error = action.payload.toString();
|