pageflow 15.4.0 → 15.5.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of pageflow might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +94 -166
- data/admins/pageflow/user.rb +0 -2
- data/app/assets/javascripts/pageflow/dist/ui.js +32 -9
- data/app/assets/javascripts/pageflow/editor/vendor.js +1 -0
- data/app/assets/stylesheets/pageflow/themes/default/page.scss +7 -0
- data/app/models/pageflow/chapter.rb +3 -9
- data/app/models/pageflow/page.rb +1 -4
- data/app/models/pageflow/revision.rb +0 -4
- data/app/models/pageflow/storyline.rb +2 -9
- data/app/views/pageflow/admin/initial_passwords/edit.html.erb +2 -1
- data/app/views/pageflow/themes/_theme.json.jbuilder +1 -1
- data/config/initializers/revision_components.rb +5 -0
- data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/editor.js +37 -13
- data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/frontend.js +19 -6
- data/entry_types/scrolled/app/helpers/pageflow_scrolled/themes_helper.rb +28 -0
- data/entry_types/scrolled/app/models/pageflow_scrolled/chapter.rb +3 -9
- data/entry_types/scrolled/app/models/pageflow_scrolled/content_element.rb +1 -4
- data/entry_types/scrolled/app/models/pageflow_scrolled/section.rb +3 -9
- data/entry_types/scrolled/app/models/pageflow_scrolled/storyline.rb +1 -9
- data/entry_types/scrolled/app/views/pageflow_scrolled/entries/_global_notices.html.erb +10 -0
- data/entry_types/scrolled/app/views/pageflow_scrolled/entries/show.html.erb +6 -3
- data/entry_types/scrolled/config/locales/de.yml +14 -0
- data/entry_types/scrolled/config/locales/en.yml +15 -49
- data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/install_generator.rb +43 -6
- data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/themes_plugin.rb.tt +26 -0
- data/entry_types/scrolled/lib/tasks/pageflow_scrolled/create_bundle_symlinks_for_yarn.rake +32 -0
- data/entry_types/scrolled/lib/tasks/pageflow_scrolled/dummy.rake +8 -0
- data/entry_types/scrolled/lib/tasks/{pageflow_scrolled_tasks.rake → pageflow_scrolled/storybook.rake} +53 -14
- data/entry_types/scrolled/package/contentElements-editor.js +66 -7
- data/entry_types/scrolled/package/contentElements-frontend.css +1 -1
- data/entry_types/scrolled/package/contentElements-frontend.js +109 -52
- data/entry_types/scrolled/package/editor.js +34 -25
- data/entry_types/scrolled/package/frontend/EditableText-7093fd0e.js +1071 -0
- data/entry_types/scrolled/package/frontend/Viewer-e49e7807.js +387 -0
- data/entry_types/scrolled/package/frontend/{Wavesurfer-b88b02e0.js → Wavesurfer-0adf5667.js} +1 -1
- data/entry_types/scrolled/package/frontend/{components-3ead1b4a.js → components-6a6793ca.js} +2 -1
- data/entry_types/scrolled/package/frontend/i18n-4dc6c377.js +1092 -0
- data/entry_types/scrolled/package/frontend/index.css +2 -2
- data/entry_types/scrolled/package/frontend/index.js +358 -179
- data/entry_types/scrolled/package/frontend/useBrowserFeature-91a4c29d.js +33 -0
- data/entry_types/scrolled/package/package.json +3 -5
- data/lib/generators/pageflow/initializer/templates/pageflow.rb +0 -7
- data/lib/pageflow/entry_export_import/revision_serialization.rb +15 -13
- data/lib/pageflow/entry_export_import/revision_serialization/import.rb +18 -26
- data/lib/pageflow/entry_type_configuration.rb +1 -0
- data/lib/pageflow/nested_revision_component.rb +49 -0
- data/lib/pageflow/revision_component.rb +6 -2
- data/lib/pageflow/user_mixin.rb +2 -1
- data/lib/pageflow/version.rb +1 -1
- data/package/editor.js +2 -1
- data/package/frontend.js +13 -2
- data/package/ui.js +32 -9
- data/spec/factories/test_revision_components.rb +4 -0
- metadata +18 -10
- data/entry_types/scrolled/package/frontend/EditableText-43c50894.js +0 -2161
@@ -319,7 +319,8 @@ var Chapter = Backbone$1.Model.extend({
|
|
319
319
|
parent: options.sections,
|
320
320
|
parentModel: this,
|
321
321
|
foreignKeyAttribute: 'chapterId',
|
322
|
-
parentReferenceAttribute: 'chapter'
|
322
|
+
parentReferenceAttribute: 'chapter',
|
323
|
+
autoConsolidatePositions: false
|
323
324
|
});
|
324
325
|
this.entry = options.entry;
|
325
326
|
},
|
@@ -364,9 +365,9 @@ var SectionConfiguration = Configuration.extend({
|
|
364
365
|
},
|
365
366
|
initialize: function initialize() {
|
366
367
|
Configuration.prototype.initialize.apply(this, arguments);
|
367
|
-
this.attributes = _objectSpread2(_objectSpread2({}, this.
|
368
|
+
this.attributes = _objectSpread2(_objectSpread2({}, this.getAttributesFromBackdropAttribute()), this.attributes);
|
368
369
|
},
|
369
|
-
|
370
|
+
getAttributesFromBackdropAttribute: function getAttributesFromBackdropAttribute() {
|
370
371
|
var backdrop = this.attributes.backdrop || {};
|
371
372
|
|
372
373
|
if (backdrop.image && backdrop.image.toString().startsWith('#')) {
|
@@ -393,32 +394,34 @@ var SectionConfiguration = Configuration.extend({
|
|
393
394
|
}
|
394
395
|
},
|
395
396
|
set: function set(name, value) {
|
396
|
-
Configuration.prototype.set.apply(this, arguments);
|
397
|
-
|
398
397
|
if (name !== 'backdrop' && name.startsWith && name.startsWith('backdrop')) {
|
399
|
-
|
398
|
+
Configuration.prototype.set.call(this, _defineProperty({
|
399
|
+
backdrop: this.getBackdropAttribute(_objectSpread2(_objectSpread2({}, this.attributes), {}, _defineProperty({}, name, value)))
|
400
|
+
}, name, value));
|
401
|
+
} else {
|
402
|
+
Configuration.prototype.set.apply(this, arguments);
|
400
403
|
}
|
401
404
|
},
|
402
|
-
|
403
|
-
switch (
|
405
|
+
getBackdropAttribute: function getBackdropAttribute(nextAttributes) {
|
406
|
+
switch (nextAttributes.backdropType) {
|
404
407
|
case 'color':
|
405
|
-
return
|
406
|
-
color:
|
407
|
-
}
|
408
|
+
return {
|
409
|
+
color: nextAttributes.backdropColor
|
410
|
+
};
|
408
411
|
|
409
412
|
case 'video':
|
410
|
-
return
|
411
|
-
video:
|
412
|
-
videoMotifArea:
|
413
|
-
}
|
413
|
+
return {
|
414
|
+
video: nextAttributes.backdropVideo,
|
415
|
+
videoMotifArea: nextAttributes.backdropVideoMotifArea
|
416
|
+
};
|
414
417
|
|
415
418
|
default:
|
416
|
-
return
|
417
|
-
image:
|
418
|
-
imageMotifArea:
|
419
|
-
imageMobile:
|
420
|
-
imageMobileMotifArea:
|
421
|
-
}
|
419
|
+
return {
|
420
|
+
image: nextAttributes.backdropImage,
|
421
|
+
imageMotifArea: nextAttributes.backdropImageMotifArea,
|
422
|
+
imageMobile: nextAttributes.backdropImageMobile,
|
423
|
+
imageMobileMotifArea: nextAttributes.backdropImageMobileMotifArea
|
424
|
+
};
|
422
425
|
}
|
423
426
|
}
|
424
427
|
});
|
@@ -498,15 +501,21 @@ var ContentElement = Backbone$1.Model.extend({
|
|
498
501
|
return [section.contentElements.at(index - 1), section.contentElements.at(index + 1)];
|
499
502
|
},
|
500
503
|
applyDefaultConfiguration: function applyDefaultConfiguration(sibling) {
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
+
var defaultConfig = _objectSpread2({}, this.getType().defaultConfig);
|
505
|
+
|
506
|
+
var defaultPosition = sibling === null || sibling === void 0 ? void 0 : sibling.getDefaultSiblingPosition();
|
507
|
+
|
508
|
+
if (defaultPosition && defaultPosition !== 'inline') {
|
509
|
+
defaultConfig.position = defaultPosition;
|
510
|
+
}
|
511
|
+
|
512
|
+
this.configuration.set(defaultConfig);
|
504
513
|
},
|
505
514
|
getPosition: function getPosition() {
|
506
515
|
return this.configuration.get('position') || 'inline';
|
507
516
|
},
|
508
517
|
getAvailablePositions: function getAvailablePositions() {
|
509
|
-
var supportedByLayout = this.section.configuration.get('layout') === 'center' ? ['inline', 'left', 'right', 'full'] : ['inline', 'sticky', 'full'];
|
518
|
+
var supportedByLayout = this.section.configuration.get('layout') === 'center' ? ['inline', 'left', 'right', 'wide', 'full'] : ['inline', 'sticky', 'wide', 'full'];
|
510
519
|
var supportedByType = this.getType().supportedPositions;
|
511
520
|
|
512
521
|
if (supportedByType) {
|
@@ -0,0 +1,1071 @@
|
|
1
|
+
import React, { useState, useEffect, createContext, useContext, useRef, useMemo, useCallback } from 'react';
|
2
|
+
import { _ as _slicedToArray, k as _objectSpread2, a as _defineProperty, p as _toConsumableArray } from './i18n-4dc6c377.js';
|
3
|
+
import classNames from 'classnames';
|
4
|
+
import { _ as _createClass, a as _classCallCheck, b as _inherits, c as _getPrototypeOf, d as _possibleConstructorReturn } from './getPrototypeOf-63c7c8e8.js';
|
5
|
+
|
6
|
+
var PhonePlatformContext = React.createContext(false);
|
7
|
+
|
8
|
+
function useOnScreen(ref) {
|
9
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
10
|
+
rootMargin = _ref.rootMargin,
|
11
|
+
onIntersecting = _ref.onIntersecting,
|
12
|
+
skipIframeFix = _ref.skipIframeFix;
|
13
|
+
|
14
|
+
var _useState = useState(false),
|
15
|
+
_useState2 = _slicedToArray(_useState, 2),
|
16
|
+
isIntersecting = _useState2[0],
|
17
|
+
setIntersecting = _useState2[1];
|
18
|
+
|
19
|
+
useEffect(function () {
|
20
|
+
var current = ref.current;
|
21
|
+
var observer = createIntersectionObserver(function (entries) {
|
22
|
+
// Even when observing only a single element, multiple entries
|
23
|
+
// may have queued up. In Chrome this can be observed when
|
24
|
+
// moving an observed element in the DOM: The callback is
|
25
|
+
// invoked once with two entries for the same target, one
|
26
|
+
// claiming the element no longer intersects and one - with a
|
27
|
+
// later timestamp - saying that is does intersect. Assuming
|
28
|
+
// entries are ordered according to time, we only consider the
|
29
|
+
// last entry.
|
30
|
+
var entry = entries[entries.length - 1];
|
31
|
+
setIntersecting(entry.isIntersecting);
|
32
|
+
|
33
|
+
if (entry.isIntersecting && onIntersecting) {
|
34
|
+
onIntersecting();
|
35
|
+
}
|
36
|
+
}, {
|
37
|
+
rootMargin: rootMargin
|
38
|
+
}, skipIframeFix);
|
39
|
+
|
40
|
+
if (ref.current) {
|
41
|
+
observer.observe(current);
|
42
|
+
}
|
43
|
+
|
44
|
+
return function () {
|
45
|
+
observer.unobserve(current);
|
46
|
+
};
|
47
|
+
}, [ref, rootMargin, onIntersecting, skipIframeFix]);
|
48
|
+
return isIntersecting;
|
49
|
+
}
|
50
|
+
|
51
|
+
function createIntersectionObserver(callback, options, skipIframeFix) {
|
52
|
+
if (skipIframeFix) {
|
53
|
+
return new IntersectionObserver(callback, options);
|
54
|
+
} // Positive root margins are ignored in iframes [1] (i.e. in
|
55
|
+
// the Pageflow editor). To make it work, the iframe document
|
56
|
+
// needs to be passed as `root` [2].
|
57
|
+
// This leads to a `TypeError`, though, in browers that do not
|
58
|
+
// support this yet (e.g. Chrome 80). We catch the error and
|
59
|
+
// skip passing the `root` option.
|
60
|
+
//
|
61
|
+
// [1] https://github.com/w3c/IntersectionObserver/issues/283
|
62
|
+
// [2] https://github.com/w3c/IntersectionObserver/issues/372
|
63
|
+
|
64
|
+
|
65
|
+
try {
|
66
|
+
var optionsWithIframeFix = options;
|
67
|
+
|
68
|
+
if (options.rootMargin && window.parent !== window) {
|
69
|
+
optionsWithIframeFix = _objectSpread2(_objectSpread2({}, options), {}, {
|
70
|
+
root: window.document
|
71
|
+
});
|
72
|
+
}
|
73
|
+
|
74
|
+
return new IntersectionObserver(callback, optionsWithIframeFix);
|
75
|
+
} catch (e) {
|
76
|
+
// Normally we would check for TypeError here. Since the polyfill
|
77
|
+
// throws a generic error, we retry either way and trust that the
|
78
|
+
// error will happen again if it is not related to the `root`
|
79
|
+
// option.
|
80
|
+
return createIntersectionObserver(callback, options, true);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
var styles = {"wrapper":"useScrollPositionLifecycle-module_wrapper__1a6Kr","isActiveProbe":"useScrollPositionLifecycle-module_isActiveProbe__3VKB5"};
|
85
|
+
|
86
|
+
var StaticPreviewContext = createContext(false);
|
87
|
+
function StaticPreview(_ref) {
|
88
|
+
var children = _ref.children;
|
89
|
+
return (
|
90
|
+
/*#__PURE__*/
|
91
|
+
React.createElement(StaticPreviewContext.Provider, {
|
92
|
+
value: true
|
93
|
+
}, children)
|
94
|
+
);
|
95
|
+
}
|
96
|
+
/**
|
97
|
+
* Use inside a content element component to determine whether the
|
98
|
+
* component is being rendered in a static preview, e.g. editor
|
99
|
+
* thumbnails.
|
100
|
+
*
|
101
|
+
* @example
|
102
|
+
* const isStaticPreview = useIsStaticPreview();
|
103
|
+
*/
|
104
|
+
|
105
|
+
function useIsStaticPreview() {
|
106
|
+
return useContext(StaticPreviewContext);
|
107
|
+
}
|
108
|
+
function createScrollPositionLifecycleProvider(Context) {
|
109
|
+
return function ScrollPositionLifecycleProvider(_ref2) {
|
110
|
+
var children = _ref2.children,
|
111
|
+
onActivate = _ref2.onActivate;
|
112
|
+
var ref = useRef();
|
113
|
+
var isActiveProbeRef = useRef();
|
114
|
+
var isStaticPreview = useContext(StaticPreviewContext);
|
115
|
+
var shouldLoad = useOnScreen(ref, {
|
116
|
+
rootMargin: '200% 0px 200% 0px'
|
117
|
+
});
|
118
|
+
var shouldPrepare = useOnScreen(ref, {
|
119
|
+
rootMargin: '25% 0px 25% 0px'
|
120
|
+
}) && !isStaticPreview;
|
121
|
+
var isVisible = useOnScreen(ref) && !isStaticPreview;
|
122
|
+
var isActive = useOnScreen(isActiveProbeRef, {
|
123
|
+
rootMargin: '-50% 0px -50% 0px',
|
124
|
+
onIntersecting: onActivate
|
125
|
+
}) && !isStaticPreview;
|
126
|
+
var value = useMemo(function () {
|
127
|
+
return {
|
128
|
+
shouldLoad: shouldLoad,
|
129
|
+
shouldPrepare: shouldPrepare,
|
130
|
+
isVisible: isVisible,
|
131
|
+
isActive: isActive
|
132
|
+
};
|
133
|
+
}, [shouldLoad, shouldPrepare, isVisible, isActive]);
|
134
|
+
return (
|
135
|
+
/*#__PURE__*/
|
136
|
+
React.createElement("div", {
|
137
|
+
ref: ref,
|
138
|
+
className: classNames(styles.wrapper)
|
139
|
+
},
|
140
|
+
/*#__PURE__*/
|
141
|
+
React.createElement("div", {
|
142
|
+
ref: isActiveProbeRef,
|
143
|
+
className: styles.isActiveProbe
|
144
|
+
}),
|
145
|
+
/*#__PURE__*/
|
146
|
+
React.createElement(Context.Provider, {
|
147
|
+
value: value
|
148
|
+
}, children))
|
149
|
+
);
|
150
|
+
};
|
151
|
+
}
|
152
|
+
function createScrollPositionLifecycleHook(Context) {
|
153
|
+
return function useScrollPositionLifecycle() {
|
154
|
+
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
155
|
+
onActivate = _ref3.onActivate,
|
156
|
+
onDeactivate = _ref3.onDeactivate,
|
157
|
+
onVisible = _ref3.onVisible,
|
158
|
+
onInvisible = _ref3.onInvisible;
|
159
|
+
|
160
|
+
var result = useContext(Context);
|
161
|
+
var wasActive = useRef();
|
162
|
+
var wasVisible = useRef();
|
163
|
+
|
164
|
+
var _ref4 = result || {},
|
165
|
+
isActive = _ref4.isActive,
|
166
|
+
isVisible = _ref4.isVisible;
|
167
|
+
|
168
|
+
useEffect(function () {
|
169
|
+
if (!wasVisible.current && isVisible && onVisible) {
|
170
|
+
onVisible();
|
171
|
+
}
|
172
|
+
|
173
|
+
if (!wasActive.current && isActive && onActivate) {
|
174
|
+
onActivate();
|
175
|
+
} else if (wasActive.current && !isActive && onDeactivate) {
|
176
|
+
onDeactivate();
|
177
|
+
}
|
178
|
+
|
179
|
+
if (wasVisible.current && !isVisible && onInvisible) {
|
180
|
+
onInvisible();
|
181
|
+
}
|
182
|
+
|
183
|
+
wasActive.current = isActive;
|
184
|
+
wasVisible.current = isVisible;
|
185
|
+
});
|
186
|
+
return result;
|
187
|
+
};
|
188
|
+
}
|
189
|
+
|
190
|
+
var styles$1 = {"root":"MotifArea-module_root__1_ACd","visible":"MotifArea-module_visible__18Kln"};
|
191
|
+
|
192
|
+
var VisibilityContext = React.createContext(false);
|
193
|
+
function MotifAreaVisibilityProvider(_ref) {
|
194
|
+
var visible = _ref.visible,
|
195
|
+
children = _ref.children;
|
196
|
+
return (
|
197
|
+
/*#__PURE__*/
|
198
|
+
React.createElement(VisibilityContext.Provider, {
|
199
|
+
value: visible
|
200
|
+
}, children)
|
201
|
+
);
|
202
|
+
}
|
203
|
+
var MotifArea = function MotifArea(props) {
|
204
|
+
var _props$file;
|
205
|
+
|
206
|
+
var lastPosition = useRef();
|
207
|
+
var position = ((_props$file = props.file) === null || _props$file === void 0 ? void 0 : _props$file.isReady) && getPosition(props);
|
208
|
+
var visible = useContext(VisibilityContext);
|
209
|
+
var elementRef = useRef();
|
210
|
+
var onUpdate = props.onUpdate;
|
211
|
+
var setElementRef = useCallback(function (element) {
|
212
|
+
elementRef.current = element;
|
213
|
+
onUpdate(element);
|
214
|
+
}, [elementRef, onUpdate]);
|
215
|
+
useEffect(function () {
|
216
|
+
if (lastPosition.current && position && (lastPosition.current.top !== position.top || lastPosition.current.left !== position.left || lastPosition.current.width !== position.width || lastPosition.current.height !== position.height)) {
|
217
|
+
onUpdate(elementRef.current);
|
218
|
+
}
|
219
|
+
|
220
|
+
lastPosition.current = position;
|
221
|
+
});
|
222
|
+
|
223
|
+
if (!position) {
|
224
|
+
return null;
|
225
|
+
}
|
226
|
+
|
227
|
+
return (
|
228
|
+
/*#__PURE__*/
|
229
|
+
React.createElement("div", {
|
230
|
+
ref: setElementRef,
|
231
|
+
className: classNames(styles$1.root, _defineProperty({}, styles$1.visible, visible)),
|
232
|
+
style: position,
|
233
|
+
onMouseEnter: props.onMouseEnter,
|
234
|
+
onMouseLeave: props.onMouseLeave
|
235
|
+
})
|
236
|
+
);
|
237
|
+
};
|
238
|
+
MotifArea.defaultProps = {
|
239
|
+
onUpdate: function onUpdate() {}
|
240
|
+
};
|
241
|
+
|
242
|
+
function getPosition(props) {
|
243
|
+
return props.file.motifAreaOffsetRect || {
|
244
|
+
top: 0,
|
245
|
+
left: 0,
|
246
|
+
width: 0,
|
247
|
+
height: 0
|
248
|
+
};
|
249
|
+
}
|
250
|
+
|
251
|
+
function useMediaQuery(query) {
|
252
|
+
var _useState = useState(false),
|
253
|
+
_useState2 = _slicedToArray(_useState, 2),
|
254
|
+
doesMatch = _useState2[0],
|
255
|
+
onSetDoesMatch = _useState2[1];
|
256
|
+
|
257
|
+
useEffect(function () {
|
258
|
+
var onUpdateMatch = function onUpdateMatch(_ref) {
|
259
|
+
var matches = _ref.matches;
|
260
|
+
onSetDoesMatch(matches);
|
261
|
+
};
|
262
|
+
|
263
|
+
var matcher = window.matchMedia(query);
|
264
|
+
var isModern = 'addEventListener' in matcher;
|
265
|
+
|
266
|
+
if (isModern) {
|
267
|
+
matcher.addEventListener('change', onUpdateMatch);
|
268
|
+
} else {
|
269
|
+
matcher.addListener(onUpdateMatch);
|
270
|
+
}
|
271
|
+
|
272
|
+
onUpdateMatch(matcher);
|
273
|
+
return function () {
|
274
|
+
if (isModern) {
|
275
|
+
matcher.removeEventListener('change', onUpdateMatch);
|
276
|
+
} else {
|
277
|
+
matcher.removeListener(onUpdateMatch);
|
278
|
+
}
|
279
|
+
};
|
280
|
+
}, [query, onSetDoesMatch]);
|
281
|
+
return doesMatch;
|
282
|
+
}
|
283
|
+
|
284
|
+
var styles$2 = {"Foreground":"Foreground-module_Foreground__13ODU","fullFadeHeight":"Foreground-module_fullFadeHeight__2p9dx","fullHeight":"Foreground-module_fullHeight__1vMXb","inFirstSection":"Foreground-module_inFirstSection__1r-_i","paddingBottom":"Foreground-module_paddingBottom__3OtY4"};
|
285
|
+
|
286
|
+
var ForcePaddingContext = createContext(false);
|
287
|
+
function Foreground(props) {
|
288
|
+
var forcePadding = useContext(ForcePaddingContext);
|
289
|
+
return (
|
290
|
+
/*#__PURE__*/
|
291
|
+
React.createElement("div", {
|
292
|
+
className: className(props, forcePadding),
|
293
|
+
style: {
|
294
|
+
minHeight: props.minHeight
|
295
|
+
}
|
296
|
+
}, props.children)
|
297
|
+
);
|
298
|
+
}
|
299
|
+
|
300
|
+
function className(props, forcePadding) {
|
301
|
+
return classNames(styles$2.Foreground, props.transitionStyles.foreground, props.transitionStyles["foreground-".concat(props.state)], _defineProperty({}, styles$2.paddingBottom, props.paddingBottom || forcePadding), _defineProperty({}, styles$2.inFirstSection, props.inFirstSection), styles$2["".concat(props.heightMode, "Height")]);
|
302
|
+
}
|
303
|
+
|
304
|
+
/**
|
305
|
+
* Register new types of content elements.
|
306
|
+
* @name frontend_contentElementTypes
|
307
|
+
*/
|
308
|
+
var ContentElementTypeRegistry =
|
309
|
+
/*#__PURE__*/
|
310
|
+
function () {
|
311
|
+
function ContentElementTypeRegistry() {
|
312
|
+
_classCallCheck(this, ContentElementTypeRegistry);
|
313
|
+
|
314
|
+
this.types = {};
|
315
|
+
}
|
316
|
+
/**
|
317
|
+
* Register a new type of content element.
|
318
|
+
*
|
319
|
+
* @param {string} typeName - Name of the content element type.
|
320
|
+
* @param {Object} options
|
321
|
+
* @param {React.Component} options.component
|
322
|
+
* @param {boolean} [options.supportsWrappingAroundFloats] -
|
323
|
+
* In sections with centered layout, content elements can be
|
324
|
+
* floated to the left or right. By default all content
|
325
|
+
* elements are cleared to position them below floating
|
326
|
+
* elements. If a content element renders mainly text that
|
327
|
+
* can wrap around floating elements, clearing can be
|
328
|
+
* disabled via this option.
|
329
|
+
* @memberof frontend_contentElementTypes
|
330
|
+
*
|
331
|
+
* @example
|
332
|
+
*
|
333
|
+
* // frontend.js
|
334
|
+
*
|
335
|
+
* import {frontend} from 'pageflow-scrolled/frontend';
|
336
|
+
* import {InlineImage} from './InlineImage';
|
337
|
+
*
|
338
|
+
* frontend.contentElementTypes.register('inlineImage', {
|
339
|
+
* component: InlineImage
|
340
|
+
* });
|
341
|
+
*/
|
342
|
+
|
343
|
+
|
344
|
+
_createClass(ContentElementTypeRegistry, [{
|
345
|
+
key: "register",
|
346
|
+
value: function register(typeName, options) {
|
347
|
+
this.types[typeName] = options;
|
348
|
+
}
|
349
|
+
}, {
|
350
|
+
key: "getComponent",
|
351
|
+
value: function getComponent(typeName) {
|
352
|
+
return this.types[typeName] && this.types[typeName].component;
|
353
|
+
}
|
354
|
+
}, {
|
355
|
+
key: "getOptions",
|
356
|
+
value: function getOptions(typeName) {
|
357
|
+
return this.types[typeName];
|
358
|
+
}
|
359
|
+
}]);
|
360
|
+
|
361
|
+
return ContentElementTypeRegistry;
|
362
|
+
}();
|
363
|
+
|
364
|
+
var api = {
|
365
|
+
contentElementTypes: new ContentElementTypeRegistry()
|
366
|
+
};
|
367
|
+
|
368
|
+
// For reasons that are beyond me, Storybook's Webpack build fails
|
369
|
+
// with a "JavaScript heap out of memory" error if this import
|
370
|
+
// expression lives in inlineEditing/index.js directly. I originally
|
371
|
+
// intended to hide the import from Webpack by using
|
372
|
+
// file-replace-loader in Storybook's Webpack config to replace this
|
373
|
+
// file with an empty one, but found out that extracting the import
|
374
|
+
// to a separate file apparently is enough.
|
375
|
+
function importComponents() {
|
376
|
+
return import('./components-6a6793ca.js');
|
377
|
+
}
|
378
|
+
|
379
|
+
var components = {};
|
380
|
+
function loadInlineEditingComponents() {
|
381
|
+
return importComponents().then(function (importedComponents) {
|
382
|
+
components = importedComponents;
|
383
|
+
});
|
384
|
+
}
|
385
|
+
function withInlineEditingDecorator(name, Component) {
|
386
|
+
return function InlineEditingDecorator(props) {
|
387
|
+
var Decorator = components[name];
|
388
|
+
|
389
|
+
if (Decorator) {
|
390
|
+
return (
|
391
|
+
/*#__PURE__*/
|
392
|
+
React.createElement(Decorator, props,
|
393
|
+
/*#__PURE__*/
|
394
|
+
React.createElement(Component, props))
|
395
|
+
);
|
396
|
+
} else {
|
397
|
+
return (
|
398
|
+
/*#__PURE__*/
|
399
|
+
React.createElement(Component, props)
|
400
|
+
);
|
401
|
+
}
|
402
|
+
};
|
403
|
+
}
|
404
|
+
function withInlineEditingAlternative(name, Component) {
|
405
|
+
return function InlineEditingDecorator(props) {
|
406
|
+
var Alternative = components[name];
|
407
|
+
|
408
|
+
if (Alternative) {
|
409
|
+
return (
|
410
|
+
/*#__PURE__*/
|
411
|
+
React.createElement(Alternative, props)
|
412
|
+
);
|
413
|
+
} else {
|
414
|
+
return (
|
415
|
+
/*#__PURE__*/
|
416
|
+
React.createElement(Component, props)
|
417
|
+
);
|
418
|
+
}
|
419
|
+
};
|
420
|
+
}
|
421
|
+
|
422
|
+
var ContentElementAttributesContext = createContext({});
|
423
|
+
function ContentElementAttributesProvider(_ref) {
|
424
|
+
var id = _ref.id,
|
425
|
+
children = _ref.children;
|
426
|
+
var attributes = useMemo(function () {
|
427
|
+
return {
|
428
|
+
contentElementId: id
|
429
|
+
};
|
430
|
+
}, [id]);
|
431
|
+
return (
|
432
|
+
/*#__PURE__*/
|
433
|
+
React.createElement(ContentElementAttributesContext.Provider, {
|
434
|
+
value: attributes
|
435
|
+
}, children)
|
436
|
+
);
|
437
|
+
}
|
438
|
+
function useContentElementAttributes() {
|
439
|
+
return useContext(ContentElementAttributesContext);
|
440
|
+
}
|
441
|
+
|
442
|
+
var ContentElementLifecycleContext = createContext();
|
443
|
+
var LifecycleProvider = createScrollPositionLifecycleProvider(ContentElementLifecycleContext);
|
444
|
+
var useLifecycle = createScrollPositionLifecycleHook(ContentElementLifecycleContext);
|
445
|
+
function ContentElementLifecycleProvider(_ref) {
|
446
|
+
var type = _ref.type,
|
447
|
+
children = _ref.children;
|
448
|
+
|
449
|
+
var _api$contentElementTy = api.contentElementTypes.getOptions(type),
|
450
|
+
lifecycle = _api$contentElementTy.lifecycle;
|
451
|
+
|
452
|
+
if (lifecycle) {
|
453
|
+
return (
|
454
|
+
/*#__PURE__*/
|
455
|
+
React.createElement(LifecycleProvider, null, children)
|
456
|
+
);
|
457
|
+
} else {
|
458
|
+
return children;
|
459
|
+
}
|
460
|
+
}
|
461
|
+
/**
|
462
|
+
* Returns an object containing information about the scroll position
|
463
|
+
* related lifecylce of the content element. Requires the `lifecycle`
|
464
|
+
* option to be set to true in the `frontend.contentElements.register`
|
465
|
+
* call for the content element's type.
|
466
|
+
*
|
467
|
+
* * `shouldLoad` is true if the content element should start lazy
|
468
|
+
* load. Becomes true before `shouldPrepare`.
|
469
|
+
*
|
470
|
+
* * `shouldPrepare` is true if the content element is about to enter
|
471
|
+
* the viewport.
|
472
|
+
*
|
473
|
+
* * `isActive` is true if the content element is completely in the
|
474
|
+
* viewport.
|
475
|
+
*
|
476
|
+
* @param {Function} onActivate -
|
477
|
+
* Invoked when content element has entered the viewport.
|
478
|
+
*
|
479
|
+
* @param {Function} onDeactivate -
|
480
|
+
* Invoked when content element has left the viewport.
|
481
|
+
*
|
482
|
+
* @example
|
483
|
+
*
|
484
|
+
* const {isActive, shouldPrepare} = useContentElementLifecycle();
|
485
|
+
*/
|
486
|
+
|
487
|
+
function useContentElementLifecycle(options) {
|
488
|
+
var result = useLifecycle(options);
|
489
|
+
|
490
|
+
if (!result) {
|
491
|
+
throw new Error('useContentElementLifecycle is only available in ' + 'content elements for which `lifecycle: true` has ' + 'been passed to frontend.contentElements.register');
|
492
|
+
}
|
493
|
+
|
494
|
+
return result;
|
495
|
+
}
|
496
|
+
|
497
|
+
var styles$3 = {"wrapper":"ContentElementMargin-module_wrapper__20kIk"};
|
498
|
+
|
499
|
+
function ContentElementMargin(_ref) {
|
500
|
+
var position = _ref.position,
|
501
|
+
children = _ref.children;
|
502
|
+
|
503
|
+
if (position === 'full') {
|
504
|
+
return children;
|
505
|
+
}
|
506
|
+
|
507
|
+
return (
|
508
|
+
/*#__PURE__*/
|
509
|
+
React.createElement("div", {
|
510
|
+
className: styles$3.wrapper
|
511
|
+
}, children)
|
512
|
+
);
|
513
|
+
}
|
514
|
+
|
515
|
+
var styles$4 = {"missing":"ContentElement-module_missing__2_1j9"};
|
516
|
+
|
517
|
+
function _createSuper(Derived) {
|
518
|
+
function isNativeReflectConstruct() {
|
519
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
520
|
+
if (Reflect.construct.sham) return false;
|
521
|
+
if (typeof Proxy === "function") return true;
|
522
|
+
|
523
|
+
try {
|
524
|
+
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
|
525
|
+
return true;
|
526
|
+
} catch (e) {
|
527
|
+
return false;
|
528
|
+
}
|
529
|
+
}
|
530
|
+
|
531
|
+
return function () {
|
532
|
+
var Super = _getPrototypeOf(Derived),
|
533
|
+
result;
|
534
|
+
|
535
|
+
if (isNativeReflectConstruct()) {
|
536
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
537
|
+
|
538
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
539
|
+
} else {
|
540
|
+
result = Super.apply(this, arguments);
|
541
|
+
}
|
542
|
+
|
543
|
+
return _possibleConstructorReturn(this, result);
|
544
|
+
};
|
545
|
+
}
|
546
|
+
var ContentElementErrorBoundary =
|
547
|
+
/*#__PURE__*/
|
548
|
+
function (_React$Component) {
|
549
|
+
_inherits(ContentElementErrorBoundary, _React$Component);
|
550
|
+
|
551
|
+
var _super = _createSuper(ContentElementErrorBoundary);
|
552
|
+
|
553
|
+
function ContentElementErrorBoundary(props) {
|
554
|
+
var _this;
|
555
|
+
|
556
|
+
_classCallCheck(this, ContentElementErrorBoundary);
|
557
|
+
|
558
|
+
_this = _super.call(this, props);
|
559
|
+
_this.state = {
|
560
|
+
hasError: false
|
561
|
+
};
|
562
|
+
return _this;
|
563
|
+
}
|
564
|
+
|
565
|
+
_createClass(ContentElementErrorBoundary, [{
|
566
|
+
key: "render",
|
567
|
+
value: function render() {
|
568
|
+
if (this.state.hasError) {
|
569
|
+
return (
|
570
|
+
/*#__PURE__*/
|
571
|
+
React.createElement("div", {
|
572
|
+
className: styles$4.missing
|
573
|
+
}, "Error rendering element of type \"", this.props.type, "\"")
|
574
|
+
);
|
575
|
+
}
|
576
|
+
|
577
|
+
return this.props.children;
|
578
|
+
}
|
579
|
+
}], [{
|
580
|
+
key: "getDerivedStateFromError",
|
581
|
+
value: function getDerivedStateFromError(error) {
|
582
|
+
return {
|
583
|
+
hasError: true
|
584
|
+
};
|
585
|
+
}
|
586
|
+
}]);
|
587
|
+
|
588
|
+
return ContentElementErrorBoundary;
|
589
|
+
}(React.Component);
|
590
|
+
|
591
|
+
var ContentElement = withInlineEditingDecorator('ContentElementDecorator', function ContentElement(props) {
|
592
|
+
var Component = api.contentElementTypes.getComponent(props.type);
|
593
|
+
|
594
|
+
if (Component) {
|
595
|
+
return (
|
596
|
+
/*#__PURE__*/
|
597
|
+
React.createElement(ContentElementAttributesProvider, {
|
598
|
+
id: props.id
|
599
|
+
},
|
600
|
+
/*#__PURE__*/
|
601
|
+
React.createElement(ContentElementLifecycleProvider, {
|
602
|
+
type: props.type
|
603
|
+
},
|
604
|
+
/*#__PURE__*/
|
605
|
+
React.createElement(ContentElementMargin, {
|
606
|
+
position: props.itemProps.position
|
607
|
+
},
|
608
|
+
/*#__PURE__*/
|
609
|
+
React.createElement(ContentElementErrorBoundary, {
|
610
|
+
type: props.type
|
611
|
+
},
|
612
|
+
/*#__PURE__*/
|
613
|
+
React.createElement(Component, {
|
614
|
+
sectionProps: props.sectionProps,
|
615
|
+
configuration: props.itemProps,
|
616
|
+
contentElementId: props.id
|
617
|
+
})))))
|
618
|
+
);
|
619
|
+
} else {
|
620
|
+
return (
|
621
|
+
/*#__PURE__*/
|
622
|
+
React.createElement("div", {
|
623
|
+
className: styles$4.missing
|
624
|
+
}, "Element of unknown type \"", props.type, "\"")
|
625
|
+
);
|
626
|
+
}
|
627
|
+
});
|
628
|
+
ContentElement.defaultProps = {
|
629
|
+
itemProps: {}
|
630
|
+
};
|
631
|
+
|
632
|
+
function ContentElements(props) {
|
633
|
+
return (
|
634
|
+
/*#__PURE__*/
|
635
|
+
React.createElement(React.Fragment, null, props.items.map(function (item, index) {
|
636
|
+
return props.children(item,
|
637
|
+
/*#__PURE__*/
|
638
|
+
React.createElement(MemoizedContentElement, {
|
639
|
+
key: item.id,
|
640
|
+
id: item.id,
|
641
|
+
permaId: item.permaId,
|
642
|
+
type: item.type,
|
643
|
+
first: index === 0,
|
644
|
+
position: item.position,
|
645
|
+
itemProps: item.props,
|
646
|
+
sectionProps: props.sectionProps
|
647
|
+
}), index);
|
648
|
+
}))
|
649
|
+
);
|
650
|
+
}
|
651
|
+
var MemoizedContentElement = React.memo(ContentElement, function (prevProps, nextProps) {
|
652
|
+
return prevProps.id === nextProps.id && prevProps.permaId === nextProps.permaId && prevProps.type === nextProps.type && prevProps.position === nextProps.position && prevProps.itemProps === nextProps.itemProps && prevProps.sectionProps === nextProps.sectionProps;
|
653
|
+
});
|
654
|
+
ContentElements.defaultProps = {
|
655
|
+
children: function children(item, child) {
|
656
|
+
return child;
|
657
|
+
}
|
658
|
+
};
|
659
|
+
|
660
|
+
function useNarrowViewport() {
|
661
|
+
return useMediaQuery('(max-width: 950px)');
|
662
|
+
}
|
663
|
+
|
664
|
+
var styles$5 = {"root":"TwoColumn-module_root__37EqL","group":"TwoColumn-module_group__3Hg2y","group-full":"TwoColumn-module_group-full__2OT4o","sticky":"TwoColumn-module_sticky__4LCDO","inline":"TwoColumn-module_inline__1fPfM","wide":"TwoColumn-module_wide__xdF_t","wideViewport":"TwoColumn-module_wideViewport___c_Zz","right":"TwoColumn-module_right__Fr52a","narrowViewport":"TwoColumn-module_narrowViewport__1x_NY"};
|
665
|
+
|
666
|
+
function availablePositions(narrow) {
|
667
|
+
if (narrow) {
|
668
|
+
return ['inline', 'wide', 'full'];
|
669
|
+
} else {
|
670
|
+
return ['inline', 'sticky', 'wide', 'full'];
|
671
|
+
}
|
672
|
+
}
|
673
|
+
|
674
|
+
function TwoColumn(props) {
|
675
|
+
var narrow = useNarrowViewport();
|
676
|
+
return (
|
677
|
+
/*#__PURE__*/
|
678
|
+
React.createElement("div", {
|
679
|
+
className: classNames(styles$5.root, styles$5[props.align], narrow ? styles$5.narrowViewport : styles$5.wideViewport)
|
680
|
+
},
|
681
|
+
/*#__PURE__*/
|
682
|
+
React.createElement("div", {
|
683
|
+
className: classNames(styles$5.group),
|
684
|
+
key: props.align
|
685
|
+
},
|
686
|
+
/*#__PURE__*/
|
687
|
+
React.createElement("div", {
|
688
|
+
className: styles$5.inline,
|
689
|
+
ref: props.contentAreaRef
|
690
|
+
})), renderItems(props, narrow), renderPlaceholder(props.placeholder))
|
691
|
+
);
|
692
|
+
}
|
693
|
+
TwoColumn.defaultProps = {
|
694
|
+
align: 'left'
|
695
|
+
};
|
696
|
+
|
697
|
+
function renderItems(props, narrow) {
|
698
|
+
return groupItemsByPosition(props.items, availablePositions(narrow)).map(function (group, index) {
|
699
|
+
return (
|
700
|
+
/*#__PURE__*/
|
701
|
+
React.createElement("div", {
|
702
|
+
key: index,
|
703
|
+
className: classNames(styles$5.group, styles$5["group-".concat(group.position)])
|
704
|
+
}, renderItemGroup(props, group, 'sticky'), renderItemGroup(props, group, 'inline'), renderItemGroup(props, group, 'wide'), renderItemGroup(props, group, 'full'))
|
705
|
+
);
|
706
|
+
});
|
707
|
+
}
|
708
|
+
|
709
|
+
function renderItemGroup(props, group, position) {
|
710
|
+
if (group[position].length) {
|
711
|
+
return (
|
712
|
+
/*#__PURE__*/
|
713
|
+
React.createElement("div", {
|
714
|
+
className: styles$5[position]
|
715
|
+
}, props.children(
|
716
|
+
/*#__PURE__*/
|
717
|
+
React.createElement(ContentElements, {
|
718
|
+
sectionProps: props.sectionProps,
|
719
|
+
items: group[position]
|
720
|
+
}), {
|
721
|
+
position: position,
|
722
|
+
openStart: position === 'inline' && group.openStart,
|
723
|
+
openEnd: position === 'inline' && group.openEnd
|
724
|
+
}))
|
725
|
+
);
|
726
|
+
}
|
727
|
+
}
|
728
|
+
|
729
|
+
function groupItemsByPosition(items, availablePositions) {
|
730
|
+
var groups = [];
|
731
|
+
var currentGroup;
|
732
|
+
items.reduce(function (previousItemPosition, item, index) {
|
733
|
+
var position = availablePositions.indexOf(item.position) >= 0 ? item.position : 'inline';
|
734
|
+
|
735
|
+
if (!previousItemPosition || previousItemPosition !== position && !(previousItemPosition === 'sticky' && position === 'inline')) {
|
736
|
+
currentGroup = {
|
737
|
+
position: position,
|
738
|
+
sticky: [],
|
739
|
+
inline: [],
|
740
|
+
wide: [],
|
741
|
+
full: []
|
742
|
+
};
|
743
|
+
groups = [].concat(_toConsumableArray(groups), [currentGroup]);
|
744
|
+
}
|
745
|
+
|
746
|
+
currentGroup[position].push(item);
|
747
|
+
return position;
|
748
|
+
}, null);
|
749
|
+
groups.forEach(function (group, index) {
|
750
|
+
var previous = groups[index - 1];
|
751
|
+
var next = groups[index + 1];
|
752
|
+
group.openStart = previous && !(previous.full.length || previous.wide.length);
|
753
|
+
group.openEnd = next && next.inline.length > 0;
|
754
|
+
});
|
755
|
+
return groups;
|
756
|
+
}
|
757
|
+
|
758
|
+
function renderPlaceholder(placeholder) {
|
759
|
+
if (!placeholder) {
|
760
|
+
return null;
|
761
|
+
}
|
762
|
+
|
763
|
+
return (
|
764
|
+
/*#__PURE__*/
|
765
|
+
React.createElement("div", {
|
766
|
+
className: classNames(styles$5.group)
|
767
|
+
},
|
768
|
+
/*#__PURE__*/
|
769
|
+
React.createElement("div", {
|
770
|
+
className: styles$5.inline
|
771
|
+
}, placeholder))
|
772
|
+
);
|
773
|
+
}
|
774
|
+
|
775
|
+
var styles$6 = {"outer":"Center-module_outer__3Rr0H","outer-full":"Center-module_outer-full__3dknO","item":"Center-module_item__1KSs3","item-wide":"Center-module_item-wide__2shH7","item-full":"Center-module_item-full__1cEuv","clear":"Center-module_clear__jJEap","inner-left":"Center-module_inner-left__2z9Ea","inner-right":"Center-module_inner-right__KBkVt"};
|
776
|
+
|
777
|
+
function Center(props) {
|
778
|
+
return (
|
779
|
+
/*#__PURE__*/
|
780
|
+
React.createElement("div", {
|
781
|
+
className: classNames(styles$6.root)
|
782
|
+
},
|
783
|
+
/*#__PURE__*/
|
784
|
+
React.createElement("div", {
|
785
|
+
ref: props.contentAreaRef
|
786
|
+
}),
|
787
|
+
/*#__PURE__*/
|
788
|
+
React.createElement(ContentElements, {
|
789
|
+
sectionProps: props.sectionProps,
|
790
|
+
items: props.items
|
791
|
+
}, function (item, child, index) {
|
792
|
+
return (
|
793
|
+
/*#__PURE__*/
|
794
|
+
React.createElement("div", {
|
795
|
+
key: item.id,
|
796
|
+
className: outerClassName(item)
|
797
|
+
},
|
798
|
+
/*#__PURE__*/
|
799
|
+
React.createElement("div", {
|
800
|
+
className: classNames(styles$6.item, styles$6["item-".concat(item.position)])
|
801
|
+
}, props.children(
|
802
|
+
/*#__PURE__*/
|
803
|
+
React.createElement("div", {
|
804
|
+
className: styles$6["inner-".concat(item.position)]
|
805
|
+
}, child), boxProps(props.items, item, index))))
|
806
|
+
);
|
807
|
+
}), renderPlaceholder$1(props.placeholder))
|
808
|
+
);
|
809
|
+
}
|
810
|
+
|
811
|
+
function outerClassName(item) {
|
812
|
+
var _api$contentElementTy = api.contentElementTypes.getOptions(item.type),
|
813
|
+
supportsWrappingAroundFloats = _api$contentElementTy.supportsWrappingAroundFloats;
|
814
|
+
|
815
|
+
return classNames(styles$6.outer, styles$6["outer-".concat(item.position)], _defineProperty({}, styles$6.clear, !supportsWrappingAroundFloats));
|
816
|
+
}
|
817
|
+
|
818
|
+
function boxProps(items, item, index) {
|
819
|
+
var previous = items[index - 1];
|
820
|
+
var next = items[index + 1];
|
821
|
+
return {
|
822
|
+
position: item.position,
|
823
|
+
openStart: previous && item.position !== 'full' && previous.position !== 'full' && item.position !== 'wide' && previous.position !== 'wide',
|
824
|
+
openEnd: next && item.position !== 'full' && next.position !== 'full' && item.position !== 'wide' && next.position !== 'wide'
|
825
|
+
};
|
826
|
+
}
|
827
|
+
|
828
|
+
function renderPlaceholder$1(placeholder) {
|
829
|
+
if (!placeholder) {
|
830
|
+
return null;
|
831
|
+
}
|
832
|
+
|
833
|
+
return (
|
834
|
+
/*#__PURE__*/
|
835
|
+
React.createElement("div", {
|
836
|
+
className: classNames(styles$6.outer)
|
837
|
+
},
|
838
|
+
/*#__PURE__*/
|
839
|
+
React.createElement("div", {
|
840
|
+
className: classNames(styles$6.item)
|
841
|
+
}, placeholder))
|
842
|
+
);
|
843
|
+
}
|
844
|
+
|
845
|
+
var Layout = React.memo(withInlineEditingAlternative('LayoutWithPlaceholder', LayoutWithoutInlineEditing), function (prevProps, nextProps) {
|
846
|
+
return prevProps.sectionId === nextProps.sectionId && prevProps.items === nextProps.items && prevProps.appearance === nextProps.appearance && prevProps.contentAreaRef === nextProps.contentAreaRef && prevProps.sectionProps === nextProps.sectionProps;
|
847
|
+
});
|
848
|
+
function LayoutWithoutInlineEditing(props) {
|
849
|
+
if (props.sectionProps.layout === 'center') {
|
850
|
+
return (
|
851
|
+
/*#__PURE__*/
|
852
|
+
React.createElement(Center, props)
|
853
|
+
);
|
854
|
+
} else if (props.sectionProps.layout === 'right') {
|
855
|
+
return (
|
856
|
+
/*#__PURE__*/
|
857
|
+
React.createElement(TwoColumn, Object.assign({
|
858
|
+
align: "right"
|
859
|
+
}, props))
|
860
|
+
);
|
861
|
+
} else {
|
862
|
+
return (
|
863
|
+
/*#__PURE__*/
|
864
|
+
React.createElement(TwoColumn, props)
|
865
|
+
);
|
866
|
+
}
|
867
|
+
}
|
868
|
+
Layout.defaultProps = {
|
869
|
+
layout: 'left'
|
870
|
+
};
|
871
|
+
|
872
|
+
function usePostMessageListener(receiveData) {
|
873
|
+
useEffect(function () {
|
874
|
+
if (window.parent !== window) {
|
875
|
+
window.addEventListener('message', receive);
|
876
|
+
}
|
877
|
+
|
878
|
+
return function () {
|
879
|
+
return window.removeEventListener('message', receive);
|
880
|
+
};
|
881
|
+
|
882
|
+
function receive(message) {
|
883
|
+
if (window.location.href.indexOf(message.origin) === 0) {
|
884
|
+
receiveData(message.data);
|
885
|
+
}
|
886
|
+
}
|
887
|
+
}, [receiveData]);
|
888
|
+
}
|
889
|
+
|
890
|
+
var styles$7 = {"text-s":"20px","text-base":"22px","text-l":"40px","text-xl":"66px","text-2xl":"110px","h2":"Text-module_h2__34chJ","h1":"Text-module_h1__2_5kX","body":"Text-module_body__4oWD-","caption":"Text-module_caption__3_6Au"};
|
891
|
+
|
892
|
+
/**
|
893
|
+
* Render some text using the default typography scale.
|
894
|
+
*
|
895
|
+
* @param {Object} props
|
896
|
+
* @param {string} props.scaleCategory - One of the styles `'h1'`, `'h2'`, `'body'`, `'caption'`.
|
897
|
+
* @param {string} [props.inline] - Render a span instread of a div.
|
898
|
+
* @param {string} props.children - Nodes to render with specified typography.
|
899
|
+
*/
|
900
|
+
|
901
|
+
function Text(_ref) {
|
902
|
+
var inline = _ref.inline,
|
903
|
+
scaleCategory = _ref.scaleCategory,
|
904
|
+
children = _ref.children;
|
905
|
+
return React.createElement(inline ? 'span' : 'div', {
|
906
|
+
className: styles$7[scaleCategory]
|
907
|
+
}, children);
|
908
|
+
}
|
909
|
+
|
910
|
+
var ContentElementConfigurationUpdateContext = React.createContext(function () {});
|
911
|
+
function useContentElementConfigurationUpdate() {
|
912
|
+
return useContext(ContentElementConfigurationUpdateContext);
|
913
|
+
}
|
914
|
+
|
915
|
+
var ContentElementEditorCommandEmitterContext = createContext({
|
916
|
+
on: function on() {},
|
917
|
+
off: function off() {}
|
918
|
+
});
|
919
|
+
function useContentElementEditorCommandSubscription(callback) {
|
920
|
+
var _useContentElementAtt = useContentElementAttributes(),
|
921
|
+
contentElementId = _useContentElementAtt.contentElementId;
|
922
|
+
|
923
|
+
var emitter = useContext(ContentElementEditorCommandEmitterContext);
|
924
|
+
useEffect(function () {
|
925
|
+
emitter.on("command:".concat(contentElementId), callback);
|
926
|
+
return function () {
|
927
|
+
return emitter.off("command:".concat(contentElementId), callback);
|
928
|
+
};
|
929
|
+
}, [emitter, callback, contentElementId]);
|
930
|
+
}
|
931
|
+
|
932
|
+
var ContentElementEditorStateContext = createContext({
|
933
|
+
isSelected: false,
|
934
|
+
isEditable: false,
|
935
|
+
setTransientState: function setTransientState() {}
|
936
|
+
});
|
937
|
+
/**
|
938
|
+
* Use inside a content element component to determine whether the
|
939
|
+
* component is being rendered inside the editor iframe, and whether
|
940
|
+
* the content element is currently selected. This can be used to
|
941
|
+
* implement simple inline editing capabilities like displaying extra
|
942
|
+
* information when the content element is selected.
|
943
|
+
*
|
944
|
+
* @example
|
945
|
+
* const {isEditable, isSelected} = useContentElementEditorState();
|
946
|
+
*/
|
947
|
+
|
948
|
+
function useContentElementEditorState() {
|
949
|
+
return useContext(ContentElementEditorStateContext);
|
950
|
+
}
|
951
|
+
|
952
|
+
var EditableText = withInlineEditingAlternative('EditableText', function EditableText(_ref) {
|
953
|
+
var value = _ref.value;
|
954
|
+
return (
|
955
|
+
/*#__PURE__*/
|
956
|
+
React.createElement(Text, {
|
957
|
+
scaleCategory: "body"
|
958
|
+
}, render(value))
|
959
|
+
);
|
960
|
+
});
|
961
|
+
|
962
|
+
function render() {
|
963
|
+
var children = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
964
|
+
return children.map(function (element, index) {
|
965
|
+
if (element.type) {
|
966
|
+
return renderElement({
|
967
|
+
attributes: {
|
968
|
+
key: index
|
969
|
+
},
|
970
|
+
element: element,
|
971
|
+
children: render(element.children)
|
972
|
+
});
|
973
|
+
} else {
|
974
|
+
return renderLeaf({
|
975
|
+
attributes: {
|
976
|
+
key: index
|
977
|
+
},
|
978
|
+
leaf: element,
|
979
|
+
children: element.text.trim() === '' ? "\uFEFF" : element.text
|
980
|
+
});
|
981
|
+
}
|
982
|
+
});
|
983
|
+
}
|
984
|
+
|
985
|
+
function renderElement(_ref2) {
|
986
|
+
var attributes = _ref2.attributes,
|
987
|
+
children = _ref2.children,
|
988
|
+
element = _ref2.element;
|
989
|
+
|
990
|
+
switch (element.type) {
|
991
|
+
case 'block-quote':
|
992
|
+
return (
|
993
|
+
/*#__PURE__*/
|
994
|
+
React.createElement("blockquote", attributes, children)
|
995
|
+
);
|
996
|
+
|
997
|
+
case 'bulleted-list':
|
998
|
+
return (
|
999
|
+
/*#__PURE__*/
|
1000
|
+
React.createElement("ul", attributes, children)
|
1001
|
+
);
|
1002
|
+
|
1003
|
+
case 'numbered-list':
|
1004
|
+
return (
|
1005
|
+
/*#__PURE__*/
|
1006
|
+
React.createElement("ol", attributes, children)
|
1007
|
+
);
|
1008
|
+
|
1009
|
+
case 'list-item':
|
1010
|
+
return (
|
1011
|
+
/*#__PURE__*/
|
1012
|
+
React.createElement("li", attributes, children)
|
1013
|
+
);
|
1014
|
+
|
1015
|
+
case 'heading':
|
1016
|
+
return (
|
1017
|
+
/*#__PURE__*/
|
1018
|
+
React.createElement("h2", attributes, children)
|
1019
|
+
);
|
1020
|
+
|
1021
|
+
case 'link':
|
1022
|
+
return (
|
1023
|
+
/*#__PURE__*/
|
1024
|
+
React.createElement("a", Object.assign({}, attributes, {
|
1025
|
+
href: element.href
|
1026
|
+
}), children)
|
1027
|
+
);
|
1028
|
+
|
1029
|
+
default:
|
1030
|
+
return (
|
1031
|
+
/*#__PURE__*/
|
1032
|
+
React.createElement("p", attributes, children)
|
1033
|
+
);
|
1034
|
+
}
|
1035
|
+
}
|
1036
|
+
function renderLeaf(_ref3) {
|
1037
|
+
var attributes = _ref3.attributes,
|
1038
|
+
children = _ref3.children,
|
1039
|
+
leaf = _ref3.leaf;
|
1040
|
+
|
1041
|
+
if (leaf.bold) {
|
1042
|
+
children =
|
1043
|
+
/*#__PURE__*/
|
1044
|
+
React.createElement("strong", null, children);
|
1045
|
+
}
|
1046
|
+
|
1047
|
+
if (leaf.italic) {
|
1048
|
+
children =
|
1049
|
+
/*#__PURE__*/
|
1050
|
+
React.createElement("em", null, children);
|
1051
|
+
}
|
1052
|
+
|
1053
|
+
if (leaf.underline) {
|
1054
|
+
children =
|
1055
|
+
/*#__PURE__*/
|
1056
|
+
React.createElement("u", null, children);
|
1057
|
+
}
|
1058
|
+
|
1059
|
+
if (leaf.strikethrough) {
|
1060
|
+
children =
|
1061
|
+
/*#__PURE__*/
|
1062
|
+
React.createElement("s", null, children);
|
1063
|
+
}
|
1064
|
+
|
1065
|
+
return (
|
1066
|
+
/*#__PURE__*/
|
1067
|
+
React.createElement("span", attributes, children)
|
1068
|
+
);
|
1069
|
+
}
|
1070
|
+
|
1071
|
+
export { ContentElementEditorCommandEmitterContext as C, EditableText as E, Foreground as F, Layout as L, MotifArea as M, PhonePlatformContext as P, StaticPreview as S, Text as T, createScrollPositionLifecycleHook as a, useMediaQuery as b, createScrollPositionLifecycleProvider as c, usePostMessageListener as d, withInlineEditingAlternative as e, api as f, useContentElementConfigurationUpdate as g, useContentElementEditorCommandSubscription as h, useContentElementEditorState as i, useContentElementLifecycle as j, useOnScreen as k, loadInlineEditingComponents as l, MotifAreaVisibilityProvider as m, ForcePaddingContext as n, ContentElementConfigurationUpdateContext as o, ContentElementEditorStateContext as p, LayoutWithoutInlineEditing as q, renderElement as r, renderLeaf as s, useIsStaticPreview as u, withInlineEditingDecorator as w };
|