pageflow 15.7.1 → 16.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +33 -243
- data/README.md +1 -9
- data/Rakefile +4 -1
- data/admins/pageflow/accounts.rb +12 -16
- data/admins/pageflow/entry.rb +57 -28
- data/admins/pageflow/entry_templates.rb +5 -7
- data/admins/pageflow/sites.rb +50 -0
- data/admins/pageflow/user.rb +7 -0
- data/app/assets/javascripts/pageflow/admin/entries.js +53 -4
- data/app/assets/stylesheets/pageflow/admin/permalink_input.scss +65 -0
- data/app/assets/stylesheets/pageflow/admin.scss +1 -0
- data/app/assets/stylesheets/pageflow/editor/base.scss +2 -6
- data/app/assets/stylesheets/pageflow/editor/dialogs.scss +2 -0
- data/app/assets/stylesheets/pageflow/editor/drop_down_button.scss +9 -0
- data/app/assets/stylesheets/pageflow/editor/info_box.scss +13 -3
- data/app/assets/stylesheets/pageflow/mixins/buttons.scss +1 -0
- data/app/assets/stylesheets/pageflow/page.scss +0 -2
- data/app/assets/stylesheets/pageflow/themes/default/page.scss +1 -1
- data/app/assets/stylesheets/pageflow/ui/forms.scss +4 -1
- data/app/controllers/pageflow/editor/file_import_controller.rb +32 -42
- data/app/controllers/pageflow/entries_controller.rb +27 -3
- data/app/helpers/pageflow/admin/permalinks_helper.rb +15 -0
- data/app/helpers/pageflow/common_entry_seed_helper.rb +1 -1
- data/app/helpers/pageflow/embed_code_helper.rb +1 -1
- data/app/helpers/pageflow/entries_helper.rb +25 -17
- data/app/helpers/pageflow/sites_helper.rb +11 -0
- data/app/helpers/pageflow/social_share_helper.rb +2 -2
- data/app/inputs/pageflow_permalink_input.rb +47 -0
- data/app/models/concerns/pageflow/permalinkable.rb +12 -0
- data/app/models/concerns/pageflow/reusable_file.rb +5 -0
- data/app/models/concerns/pageflow/uploadable_file.rb +4 -0
- data/app/models/pageflow/account.rb +7 -33
- data/app/models/pageflow/{cname_theming_request_scope.rb → cname_site_request_scope.rb} +3 -3
- data/app/models/pageflow/customized_theme.rb +5 -3
- data/app/models/pageflow/entry.rb +8 -4
- data/app/models/pageflow/entry_at_revision.rb +4 -3
- data/app/models/pageflow/entry_duplicate.rb +8 -1
- data/app/models/pageflow/entry_template.rb +4 -4
- data/app/models/pageflow/home_button.rb +7 -7
- data/app/models/pageflow/image_file_url_templates.rb +2 -2
- data/app/models/pageflow/permalink.rb +39 -0
- data/app/models/pageflow/permalink_directory.rb +10 -0
- data/app/models/pageflow/published_entry.rb +19 -2
- data/app/models/pageflow/revision.rb +1 -1
- data/app/models/pageflow/site.rb +59 -0
- data/app/models/pageflow/theme_customization.rb +1 -1
- data/app/models/pageflow/theme_customization_file.rb +6 -1
- data/app/policies/pageflow/account_policy.rb +2 -2
- data/app/policies/pageflow/entry_policy.rb +2 -2
- data/app/policies/pageflow/entry_template_policy.rb +1 -1
- data/app/policies/pageflow/{theming_policy.rb → site_policy.rb} +13 -11
- data/app/views/admin/accounts/_entry_template_details.html.arb +1 -1
- data/app/views/admin/accounts/_form.html.erb +4 -22
- data/app/views/admin/accounts/_site_defaults_inline_help.html.erb +5 -0
- data/app/views/admin/entries/_form.html.erb +11 -12
- data/app/views/admin/entries/_permalink_inputs.html.erb +6 -0
- data/app/views/admin/entries/_site_input.html.erb +15 -0
- data/app/views/admin/entries/{entry_type_name_input.html.erb → entry_site_and_type_name_input.html.erb} +3 -0
- data/app/views/admin/entries/permalink_inputs.html.erb +7 -0
- data/app/views/admin/entry_templates/_form.html.erb +5 -5
- data/app/views/admin/sites/_attributes_table.html.arb +9 -0
- data/app/views/admin/sites/_fields.html.erb +17 -0
- data/app/views/admin/sites/_form.html.erb +5 -0
- data/app/views/components/pageflow/admin/entries_tab.rb +1 -2
- data/app/views/components/pageflow/admin/entry_templates_tab.rb +10 -11
- data/app/views/components/pageflow/admin/features_tab.rb +1 -1
- data/app/views/components/pageflow/admin/sites_tab.rb +32 -0
- data/app/views/components/pageflow/admin/users_tab.rb +1 -2
- data/app/views/pageflow/editor/entries/seed.json.erb +1 -1
- data/app/views/pageflow/editor/file_import/start_import_job.json.jbuilder +10 -0
- data/app/views/pageflow/editor/sites/_site.json.jbuilder +1 -0
- data/app/views/pageflow/entries/{_theming.css.erb → _site.css.erb} +0 -0
- data/app/views/pageflow/entries/stylesheet.css.erb +1 -1
- data/app/views/pageflow/files/_file.json.jbuilder +1 -0
- data/app/views/pageflow/social_share/_entry_meta_tags.html.erb +1 -1
- data/app/views/pageflow/social_share/_page_meta_tags.html.erb +1 -1
- data/config/initializers/admin_resource_tabs.rb +29 -12
- data/config/initializers/mime_types.rb +1 -0
- data/config/locales/de.yml +19 -17
- data/config/locales/en.yml +19 -17
- data/config/routes.rb +8 -5
- data/db/migrate/20221024100724_create_pageflow_permalink_directories.rb +10 -0
- data/db/migrate/20221025074049_add_permalink_attributes_to_entries.rb +5 -0
- data/db/migrate/20221027065022_create_pageflow_permalinks.rb +12 -0
- data/db/migrate/20221215101134_rename_theming_to_site.rb +9 -0
- data/db/migrate/20221215120856_associate_entry_templates_with_sites.rb +34 -0
- data/db/migrate/20221219203023_add_name_to_sites.rb +5 -0
- data/db/migrate/20230103155934_associate_theme_customizations_with_sites.rb +27 -0
- data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/editor.js +176 -179
- data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/frontend.js +49 -7
- data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/react-client.js +5 -5
- data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/react-server.js +1 -1
- data/entry_types/paged/config/initializers/features.rb +2 -0
- data/entry_types/paged/config/locales/{new/help.de.yml → de.yml} +74 -65
- data/entry_types/paged/config/locales/{new/help.en.yml → en.yml} +66 -56
- data/entry_types/scrolled/app/helpers/pageflow_scrolled/favicon_helper.rb +39 -13
- data/entry_types/scrolled/app/helpers/pageflow_scrolled/generated_media_queries_helper.rb +55 -0
- data/entry_types/scrolled/app/helpers/pageflow_scrolled/themes_helper.rb +6 -2
- data/entry_types/scrolled/app/views/pageflow_scrolled/editor/entries/_head.html.erb +2 -0
- data/entry_types/scrolled/app/views/pageflow_scrolled/entries/_manifest.json.jbuilder +16 -0
- data/entry_types/scrolled/app/views/pageflow_scrolled/entries/show.html.erb +9 -3
- data/entry_types/scrolled/app/views/pageflow_scrolled/entry_json_seed/_entry.json.jbuilder +5 -5
- data/entry_types/scrolled/app/views/pageflow_scrolled/favicons/_entry.html.erb +16 -10
- data/entry_types/scrolled/config/locales/de.yml +265 -76
- data/entry_types/scrolled/config/locales/en.yml +266 -77
- data/entry_types/scrolled/lib/pageflow_scrolled/configuration.rb +3 -3
- data/entry_types/scrolled/lib/pageflow_scrolled/plugin.rb +14 -0
- data/entry_types/scrolled/lib/pageflow_scrolled/react_widget_type.rb +1 -1
- data/entry_types/scrolled/lib/pageflow_scrolled/seeds.rb +1 -1
- data/entry_types/scrolled/lib/pageflow_scrolled/web_app_manifest.rb +11 -0
- data/entry_types/scrolled/lib/pageflow_scrolled.rb +39 -1
- data/entry_types/scrolled/lib/tasks/pageflow_scrolled/storybook.rake +3 -2
- data/entry_types/scrolled/package/contentElements-editor.js +124 -38
- data/entry_types/scrolled/package/contentElements-frontend.css +1 -1
- data/entry_types/scrolled/package/contentElements-frontend.js +321 -27
- data/entry_types/scrolled/package/editor.js +1345 -739
- data/entry_types/scrolled/package/frontend/EditableInlineText.module-14c7b097.js +5314 -0
- data/entry_types/scrolled/package/frontend/{PhonePlatformContext-9fb97827.js → PhonePlatformContext-f6093cc6.js} +87 -223
- data/entry_types/scrolled/package/frontend/{Viewer-e2290ea0.js → Viewer-b6becc57.js} +6 -40
- data/entry_types/scrolled/package/frontend/arrowRight-78a7cee4.js +42 -0
- data/entry_types/scrolled/package/frontend/{components-6ab26015.js → components-b3160dd7.js} +546 -361
- data/entry_types/scrolled/package/frontend/index.css +1 -1
- data/entry_types/scrolled/package/frontend/index.js +398 -3692
- data/entry_types/scrolled/package/package.json +3 -2
- data/entry_types/scrolled/package/testHelpers.js +12 -2
- data/entry_types/scrolled/package/widgets/defaultNavigation.css +2 -2
- data/entry_types/scrolled/package/widgets/defaultNavigation.js +50 -40
- data/entry_types/scrolled/spec/fixtures/image.ico +0 -0
- data/lib/pageflow/ability_mixin.rb +16 -8
- data/lib/pageflow/admin/attributes_table_rows.rb +1 -1
- data/lib/pageflow/admin/form_inputs.rb +1 -1
- data/lib/pageflow/admin/tabs.rb +1 -1
- data/lib/pageflow/configuration/permissions.rb +3 -3
- data/lib/pageflow/configuration.rb +17 -17
- data/lib/pageflow/entry_export_import/entry_serialization.rb +1 -1
- data/lib/pageflow/entry_type.rb +6 -2
- data/lib/pageflow/primary_domain_entry_redirect.rb +7 -7
- data/lib/pageflow/seeds.rb +10 -10
- data/lib/pageflow/theme_customizations.rb +10 -10
- data/lib/pageflow/version.rb +1 -1
- data/package/editor.js +129 -156
- data/package/frontend.js +19 -2
- data/package/testHelpers.js +39 -6
- data/spec/factories/accounts.rb +5 -2
- data/spec/factories/draft_entries.rb +2 -2
- data/spec/factories/entries.rb +18 -1
- data/spec/factories/entry_templates.rb +1 -1
- data/spec/factories/permalink_directory.rb +6 -0
- data/spec/factories/permalinks.rb +4 -0
- data/spec/factories/published_entries.rb +4 -2
- data/spec/factories/sites.rb +9 -0
- metadata +50 -62
- data/app/assets/javascripts/pageflow/dist/editor.js +0 -11890
- data/app/assets/javascripts/pageflow/dist/frontend.js +0 -5800
- data/app/assets/javascripts/pageflow/dist/react-client.js +0 -22
- data/app/assets/javascripts/pageflow/dist/react-server.js +0 -19
- data/app/helpers/pageflow/themings_helper.rb +0 -11
- data/app/models/pageflow/theming.rb +0 -29
- data/app/views/admin/accounts/_theming_defaults_inline_help.html.erb +0 -5
- data/app/views/admin/accounts/_theming_details.html.arb +0 -5
- data/app/views/pageflow/editor/themings/_theming.json.jbuilder +0 -1
- data/entry_types/paged/config/locales/new/video_contain.de.yml +0 -7
- data/entry_types/paged/config/locales/new/video_contain.en.yml +0 -7
- data/entry_types/scrolled/config/locales/new/before_after_slider.de.yml +0 -8
- data/entry_types/scrolled/config/locales/new/before_after_slider.en.yml +0 -8
- data/entry_types/scrolled/config/locales/new/center_ragged.de.yml +0 -8
- data/entry_types/scrolled/config/locales/new/center_ragged.en.yml +0 -9
- data/entry_types/scrolled/config/locales/new/consent.de.yml +0 -25
- data/entry_types/scrolled/config/locales/new/consent.en.yml +0 -24
- data/entry_types/scrolled/config/locales/new/content_element_categories.de.yml +0 -39
- data/entry_types/scrolled/config/locales/new/content_element_categories.en.yml +0 -39
- data/entry_types/scrolled/config/locales/new/default_transition.de.yml +0 -14
- data/entry_types/scrolled/config/locales/new/default_transition.en.yml +0 -14
- data/entry_types/scrolled/config/locales/new/header_line_breaks.de.yml +0 -28
- data/entry_types/scrolled/config/locales/new/header_line_breaks.en.yml +0 -27
- data/entry_types/scrolled/config/locales/new/header_size.de.yml +0 -17
- data/entry_types/scrolled/config/locales/new/header_size.en.yml +0 -17
- data/entry_types/scrolled/config/locales/new/iframe_embed.de.yml +0 -39
- data/entry_types/scrolled/config/locales/new/iframe_embed.en.yml +0 -39
- data/entry_types/scrolled/config/locales/new/inline_loops.de.yml +0 -26
- data/entry_types/scrolled/config/locales/new/inline_loops.en.yml +0 -26
- data/entry_types/scrolled/config/locales/new/portrait_inline_image.de.yml +0 -9
- data/entry_types/scrolled/config/locales/new/portrait_inline_image.en.yml +0 -9
- data/entry_types/scrolled/config/locales/new/section_width.de.yml +0 -10
- data/entry_types/scrolled/config/locales/new/section_width.en.yml +0 -10
- data/entry_types/scrolled/config/locales/new/typography_variants.de.yml +0 -7
- data/entry_types/scrolled/config/locales/new/typography_variants.en.yml +0 -7
- data/entry_types/scrolled/config/locales/new/video_embed_poster.de.yml +0 -8
- data/entry_types/scrolled/config/locales/new/video_embed_poster.en.yml +0 -8
- data/entry_types/scrolled/config/locales/new/waveform_styles.de.yml +0 -11
- data/entry_types/scrolled/config/locales/new/waveform_styles.en.yml +0 -12
- data/entry_types/scrolled/config/locales/new/widgets.de.yml +0 -6
- data/entry_types/scrolled/config/locales/new/widgets.en.yml +0 -6
- data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/browserconfig.xml +0 -9
- data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/mstile-150x150.png +0 -0
- data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/safari-pinned-tab.svg +0 -46
- data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/site.webmanifest +0 -19
- data/entry_types/scrolled/package/frontend/EditableInlineText.module-b9923660.js +0 -993
- data/entry_types/scrolled/package/frontend/usePhonePlatform-2857c22b.js +0 -34
- data/spec/factories/themings.rb +0 -7
@@ -1,993 +0,0 @@
|
|
1
|
-
import React, { useState, useRef, useEffect, createContext, useContext, useMemo, useCallback } from 'react';
|
2
|
-
import { c as _slicedToArray, a as _objectSpread2, b as _defineProperty, f as useTheme, o as _toConsumableArray } from './PhonePlatformContext-9fb97827.js';
|
3
|
-
import classNames from 'classnames';
|
4
|
-
import { _ as _createClass, a as _classCallCheck, b as _inherits, c as _createSuper } from './createSuper-d0f30da3.js';
|
5
|
-
|
6
|
-
function useOnScreen(ref) {
|
7
|
-
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
8
|
-
rootMargin = _ref.rootMargin,
|
9
|
-
onIntersecting = _ref.onIntersecting,
|
10
|
-
skipIframeFix = _ref.skipIframeFix;
|
11
|
-
|
12
|
-
var _useState = useState(false),
|
13
|
-
_useState2 = _slicedToArray(_useState, 2),
|
14
|
-
isIntersecting = _useState2[0],
|
15
|
-
setIntersecting = _useState2[1];
|
16
|
-
|
17
|
-
var onIntersectingRef = useRef();
|
18
|
-
useEffect(function () {
|
19
|
-
onIntersectingRef.current = onIntersecting;
|
20
|
-
}, [onIntersecting]);
|
21
|
-
useEffect(function () {
|
22
|
-
var current = ref.current;
|
23
|
-
var observer = createIntersectionObserver(function (entries) {
|
24
|
-
// Even when observing only a single element, multiple entries
|
25
|
-
// may have queued up. In Chrome this can be observed when
|
26
|
-
// moving an observed element in the DOM: The callback is
|
27
|
-
// invoked once with two entries for the same target, one
|
28
|
-
// claiming the element no longer intersects and one - with a
|
29
|
-
// later timestamp - saying that is does intersect. Assuming
|
30
|
-
// entries are ordered according to time, we only consider the
|
31
|
-
// last entry.
|
32
|
-
var entry = entries[entries.length - 1];
|
33
|
-
setIntersecting(entry.isIntersecting);
|
34
|
-
|
35
|
-
if (entry.isIntersecting && onIntersectingRef.current) {
|
36
|
-
onIntersectingRef.current();
|
37
|
-
}
|
38
|
-
}, {
|
39
|
-
rootMargin: rootMargin
|
40
|
-
}, skipIframeFix);
|
41
|
-
|
42
|
-
if (ref.current) {
|
43
|
-
observer.observe(current);
|
44
|
-
}
|
45
|
-
|
46
|
-
return function () {
|
47
|
-
observer.unobserve(current);
|
48
|
-
};
|
49
|
-
}, [ref, rootMargin, skipIframeFix]);
|
50
|
-
return isIntersecting;
|
51
|
-
}
|
52
|
-
|
53
|
-
function createIntersectionObserver(callback, options, skipIframeFix) {
|
54
|
-
if (skipIframeFix) {
|
55
|
-
return new IntersectionObserver(callback, options);
|
56
|
-
} // Positive root margins are ignored in iframes [1] (i.e. in
|
57
|
-
// the Pageflow editor). To make it work, the iframe document
|
58
|
-
// needs to be passed as `root` [2].
|
59
|
-
// This leads to a `TypeError`, though, in browers that do not
|
60
|
-
// support this yet (e.g. Chrome 80). We catch the error and
|
61
|
-
// skip passing the `root` option.
|
62
|
-
//
|
63
|
-
// [1] https://github.com/w3c/IntersectionObserver/issues/283
|
64
|
-
// [2] https://github.com/w3c/IntersectionObserver/issues/372
|
65
|
-
|
66
|
-
|
67
|
-
try {
|
68
|
-
var optionsWithIframeFix = options;
|
69
|
-
|
70
|
-
if (options.rootMargin && window.parent !== window) {
|
71
|
-
optionsWithIframeFix = _objectSpread2(_objectSpread2({}, options), {}, {
|
72
|
-
root: window.document
|
73
|
-
});
|
74
|
-
}
|
75
|
-
|
76
|
-
return new IntersectionObserver(callback, optionsWithIframeFix);
|
77
|
-
} catch (e) {
|
78
|
-
// Normally we would check for TypeError here. Since the polyfill
|
79
|
-
// throws a generic error, we retry either way and trust that the
|
80
|
-
// error will happen again if it is not related to the `root`
|
81
|
-
// option.
|
82
|
-
return createIntersectionObserver(callback, options, true);
|
83
|
-
}
|
84
|
-
}
|
85
|
-
|
86
|
-
var styles = {"wrapper":"useScrollPositionLifecycle-module_wrapper__1a6Kr","isActiveProbe":"useScrollPositionLifecycle-module_isActiveProbe__3VKB5"};
|
87
|
-
|
88
|
-
var StaticPreviewContext = createContext(false);
|
89
|
-
function StaticPreview(_ref) {
|
90
|
-
var children = _ref.children;
|
91
|
-
return /*#__PURE__*/React.createElement(StaticPreviewContext.Provider, {
|
92
|
-
value: true
|
93
|
-
}, children);
|
94
|
-
}
|
95
|
-
/**
|
96
|
-
* Use inside a content element component to determine whether the
|
97
|
-
* component is being rendered in a static preview, e.g. editor
|
98
|
-
* thumbnails.
|
99
|
-
*
|
100
|
-
* @example
|
101
|
-
* const isStaticPreview = useIsStaticPreview();
|
102
|
-
*/
|
103
|
-
|
104
|
-
function useIsStaticPreview() {
|
105
|
-
return useContext(StaticPreviewContext);
|
106
|
-
}
|
107
|
-
function createScrollPositionLifecycleProvider(Context) {
|
108
|
-
return function ScrollPositionLifecycleProvider(_ref2) {
|
109
|
-
var children = _ref2.children,
|
110
|
-
onActivate = _ref2.onActivate;
|
111
|
-
var ref = useRef();
|
112
|
-
var isActiveProbeRef = useRef();
|
113
|
-
var isStaticPreview = useContext(StaticPreviewContext);
|
114
|
-
var shouldLoad = useOnScreen(ref, {
|
115
|
-
rootMargin: '200% 0px 200% 0px'
|
116
|
-
});
|
117
|
-
var shouldPrepare = useOnScreen(ref, {
|
118
|
-
rootMargin: '25% 0px 25% 0px'
|
119
|
-
}) && !isStaticPreview;
|
120
|
-
var isVisible = useOnScreen(ref) && !isStaticPreview;
|
121
|
-
var isActive = useOnScreen(isActiveProbeRef, {
|
122
|
-
rootMargin: '-50% 0px -50% 0px',
|
123
|
-
onIntersecting: onActivate
|
124
|
-
}) && !isStaticPreview;
|
125
|
-
var value = useMemo(function () {
|
126
|
-
return {
|
127
|
-
shouldLoad: shouldLoad,
|
128
|
-
shouldPrepare: shouldPrepare,
|
129
|
-
isVisible: isVisible,
|
130
|
-
isActive: isActive
|
131
|
-
};
|
132
|
-
}, [shouldLoad, shouldPrepare, isVisible, isActive]);
|
133
|
-
return /*#__PURE__*/React.createElement("div", {
|
134
|
-
ref: ref,
|
135
|
-
className: classNames(styles.wrapper)
|
136
|
-
}, /*#__PURE__*/React.createElement("div", {
|
137
|
-
ref: isActiveProbeRef,
|
138
|
-
className: styles.isActiveProbe
|
139
|
-
}), /*#__PURE__*/React.createElement(Context.Provider, {
|
140
|
-
value: value
|
141
|
-
}, children));
|
142
|
-
};
|
143
|
-
}
|
144
|
-
function createScrollPositionLifecycleHook(Context) {
|
145
|
-
return function useScrollPositionLifecycle() {
|
146
|
-
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
147
|
-
onActivate = _ref3.onActivate,
|
148
|
-
onDeactivate = _ref3.onDeactivate,
|
149
|
-
onVisible = _ref3.onVisible,
|
150
|
-
onInvisible = _ref3.onInvisible;
|
151
|
-
|
152
|
-
var result = useContext(Context);
|
153
|
-
var wasActive = useRef();
|
154
|
-
var wasVisible = useRef();
|
155
|
-
|
156
|
-
var _ref4 = result || {},
|
157
|
-
isActive = _ref4.isActive,
|
158
|
-
isVisible = _ref4.isVisible;
|
159
|
-
|
160
|
-
useEffect(function () {
|
161
|
-
if (!wasVisible.current && isVisible && onVisible) {
|
162
|
-
onVisible();
|
163
|
-
}
|
164
|
-
|
165
|
-
if (!wasActive.current && isActive && onActivate) {
|
166
|
-
onActivate();
|
167
|
-
} else if (wasActive.current && !isActive && onDeactivate) {
|
168
|
-
onDeactivate();
|
169
|
-
}
|
170
|
-
|
171
|
-
if (wasVisible.current && !isVisible && onInvisible) {
|
172
|
-
onInvisible();
|
173
|
-
}
|
174
|
-
|
175
|
-
wasActive.current = isActive;
|
176
|
-
wasVisible.current = isVisible;
|
177
|
-
});
|
178
|
-
return result;
|
179
|
-
};
|
180
|
-
}
|
181
|
-
|
182
|
-
var ContentElementEditorStateContext = createContext({
|
183
|
-
isSelected: false,
|
184
|
-
isEditable: false,
|
185
|
-
setTransientState: function setTransientState() {}
|
186
|
-
});
|
187
|
-
/**
|
188
|
-
* Use inside a content element component to determine whether the
|
189
|
-
* component is being rendered inside the editor iframe, and whether
|
190
|
-
* the content element is currently selected. This can be used to
|
191
|
-
* implement simple inline editing capabilities like displaying extra
|
192
|
-
* information when the content element is selected.
|
193
|
-
*
|
194
|
-
* @example
|
195
|
-
* const {isEditable, isSelected} = useContentElementEditorState();
|
196
|
-
*/
|
197
|
-
|
198
|
-
function useContentElementEditorState() {
|
199
|
-
return useContext(ContentElementEditorStateContext);
|
200
|
-
}
|
201
|
-
|
202
|
-
var styles$1 = {"root":"MotifArea-module_root__1_ACd","visible":"MotifArea-module_visible__18Kln"};
|
203
|
-
|
204
|
-
var VisibilityContext = React.createContext(false);
|
205
|
-
function MotifAreaVisibilityProvider(_ref) {
|
206
|
-
var visible = _ref.visible,
|
207
|
-
children = _ref.children;
|
208
|
-
return /*#__PURE__*/React.createElement(VisibilityContext.Provider, {
|
209
|
-
value: visible
|
210
|
-
}, children);
|
211
|
-
}
|
212
|
-
var MotifArea = function MotifArea(props) {
|
213
|
-
var _props$file;
|
214
|
-
|
215
|
-
var lastPosition = useRef();
|
216
|
-
var position = ((_props$file = props.file) === null || _props$file === void 0 ? void 0 : _props$file.isReady) && getPosition(props);
|
217
|
-
var visible = useContext(VisibilityContext);
|
218
|
-
var elementRef = useRef();
|
219
|
-
var onUpdate = props.onUpdate;
|
220
|
-
var setElementRef = useCallback(function (element) {
|
221
|
-
elementRef.current = element;
|
222
|
-
onUpdate(element);
|
223
|
-
}, [elementRef, onUpdate]);
|
224
|
-
useEffect(function () {
|
225
|
-
if (lastPosition.current && position && (lastPosition.current.top !== position.top || lastPosition.current.left !== position.left || lastPosition.current.width !== position.width || lastPosition.current.height !== position.height)) {
|
226
|
-
onUpdate(elementRef.current);
|
227
|
-
}
|
228
|
-
|
229
|
-
lastPosition.current = position;
|
230
|
-
});
|
231
|
-
|
232
|
-
if (!position) {
|
233
|
-
return null;
|
234
|
-
}
|
235
|
-
|
236
|
-
return /*#__PURE__*/React.createElement("div", {
|
237
|
-
ref: setElementRef,
|
238
|
-
className: classNames(styles$1.root, _defineProperty({}, styles$1.visible, visible)),
|
239
|
-
style: position,
|
240
|
-
onMouseEnter: props.onMouseEnter,
|
241
|
-
onMouseLeave: props.onMouseLeave
|
242
|
-
});
|
243
|
-
};
|
244
|
-
MotifArea.defaultProps = {
|
245
|
-
onUpdate: function onUpdate() {}
|
246
|
-
};
|
247
|
-
|
248
|
-
function getPosition(props) {
|
249
|
-
return props.file.motifAreaOffsetRect || {
|
250
|
-
top: 0,
|
251
|
-
left: 0,
|
252
|
-
width: 0,
|
253
|
-
height: 0
|
254
|
-
};
|
255
|
-
}
|
256
|
-
|
257
|
-
function useMediaQuery(query) {
|
258
|
-
var _useState = useState(false),
|
259
|
-
_useState2 = _slicedToArray(_useState, 2),
|
260
|
-
doesMatch = _useState2[0],
|
261
|
-
onSetDoesMatch = _useState2[1];
|
262
|
-
|
263
|
-
useEffect(function () {
|
264
|
-
var onUpdateMatch = function onUpdateMatch(_ref) {
|
265
|
-
var matches = _ref.matches;
|
266
|
-
onSetDoesMatch(matches);
|
267
|
-
};
|
268
|
-
|
269
|
-
var matcher = window.matchMedia(query);
|
270
|
-
var isModern = ('addEventListener' in matcher);
|
271
|
-
|
272
|
-
if (isModern) {
|
273
|
-
matcher.addEventListener('change', onUpdateMatch);
|
274
|
-
} else {
|
275
|
-
matcher.addListener(onUpdateMatch);
|
276
|
-
}
|
277
|
-
|
278
|
-
onUpdateMatch(matcher);
|
279
|
-
return function () {
|
280
|
-
if (isModern) {
|
281
|
-
matcher.removeEventListener('change', onUpdateMatch);
|
282
|
-
} else {
|
283
|
-
matcher.removeListener(onUpdateMatch);
|
284
|
-
}
|
285
|
-
};
|
286
|
-
}, [query, onSetDoesMatch]);
|
287
|
-
return doesMatch;
|
288
|
-
}
|
289
|
-
|
290
|
-
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"};
|
291
|
-
|
292
|
-
var ForcePaddingContext = createContext(false);
|
293
|
-
function Foreground(props) {
|
294
|
-
var forcePadding = useContext(ForcePaddingContext);
|
295
|
-
return /*#__PURE__*/React.createElement("div", {
|
296
|
-
className: className(props, forcePadding),
|
297
|
-
style: {
|
298
|
-
minHeight: props.minHeight
|
299
|
-
}
|
300
|
-
}, props.children);
|
301
|
-
}
|
302
|
-
|
303
|
-
function className(props, forcePadding) {
|
304
|
-
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")]);
|
305
|
-
}
|
306
|
-
|
307
|
-
/**
|
308
|
-
* Register new types of content elements.
|
309
|
-
* @name frontend_contentElementTypes
|
310
|
-
*/
|
311
|
-
var ContentElementTypeRegistry = /*#__PURE__*/function () {
|
312
|
-
function ContentElementTypeRegistry() {
|
313
|
-
_classCallCheck(this, ContentElementTypeRegistry);
|
314
|
-
|
315
|
-
this.types = {};
|
316
|
-
}
|
317
|
-
/**
|
318
|
-
* Register a new type of content element.
|
319
|
-
*
|
320
|
-
* @param {string} typeName - Name of the content element type.
|
321
|
-
* @param {Object} options
|
322
|
-
* @param {React.Component} options.component
|
323
|
-
* @param {boolean} [options.supportsWrappingAroundFloats] -
|
324
|
-
* In sections with centered layout, content elements can be
|
325
|
-
* floated to the left or right. By default all content
|
326
|
-
* elements are cleared to position them below floating
|
327
|
-
* elements. If a content element renders mainly text that
|
328
|
-
* can wrap around floating elements, clearing can be
|
329
|
-
* disabled via this option.
|
330
|
-
* @memberof frontend_contentElementTypes
|
331
|
-
*
|
332
|
-
* @example
|
333
|
-
*
|
334
|
-
* // frontend.js
|
335
|
-
*
|
336
|
-
* import {frontend} from 'pageflow-scrolled/frontend';
|
337
|
-
* import {InlineImage} from './InlineImage';
|
338
|
-
*
|
339
|
-
* frontend.contentElementTypes.register('inlineImage', {
|
340
|
-
* component: InlineImage
|
341
|
-
* });
|
342
|
-
*/
|
343
|
-
|
344
|
-
|
345
|
-
_createClass(ContentElementTypeRegistry, [{
|
346
|
-
key: "register",
|
347
|
-
value: function register(typeName, options) {
|
348
|
-
this.types[typeName] = options;
|
349
|
-
}
|
350
|
-
}, {
|
351
|
-
key: "getComponent",
|
352
|
-
value: function getComponent(typeName) {
|
353
|
-
return this.types[typeName] && this.types[typeName].component;
|
354
|
-
}
|
355
|
-
}, {
|
356
|
-
key: "getOptions",
|
357
|
-
value: function getOptions(typeName) {
|
358
|
-
return this.types[typeName];
|
359
|
-
}
|
360
|
-
}, {
|
361
|
-
key: "consentVendors",
|
362
|
-
value: function consentVendors(_ref) {
|
363
|
-
var _this = this;
|
364
|
-
|
365
|
-
var contentElements = _ref.contentElements,
|
366
|
-
t = _ref.t;
|
367
|
-
var vendorsByName = {};
|
368
|
-
contentElements.forEach(function (contentElement) {
|
369
|
-
var type = _this.types[contentElement.typeName];
|
370
|
-
var consentVendors = typeof type.consentVendors === 'function' ? type.consentVendors({
|
371
|
-
configuration: contentElement.configuration,
|
372
|
-
t: t
|
373
|
-
}) : type.consentVendors || [];
|
374
|
-
consentVendors.forEach(function (vendor) {
|
375
|
-
vendorsByName[vendor.name] = vendor;
|
376
|
-
});
|
377
|
-
});
|
378
|
-
return Object.values(vendorsByName);
|
379
|
-
}
|
380
|
-
}]);
|
381
|
-
|
382
|
-
return ContentElementTypeRegistry;
|
383
|
-
}();
|
384
|
-
|
385
|
-
/**
|
386
|
-
* Register new types of widgets.
|
387
|
-
* @name frontend_widgetTypes
|
388
|
-
*/
|
389
|
-
var WidgetTypeRegistry = /*#__PURE__*/function () {
|
390
|
-
function WidgetTypeRegistry() {
|
391
|
-
_classCallCheck(this, WidgetTypeRegistry);
|
392
|
-
|
393
|
-
this.types = {};
|
394
|
-
}
|
395
|
-
/**
|
396
|
-
* Register a new type of widget.
|
397
|
-
*
|
398
|
-
* @param {string} typeName - Name of the content element type.
|
399
|
-
* @param {Object} options
|
400
|
-
* @param {React.Component} options.component
|
401
|
-
* @memberof frontend_widgetTypes
|
402
|
-
*
|
403
|
-
* @example
|
404
|
-
*
|
405
|
-
* // frontend.js
|
406
|
-
*
|
407
|
-
* import {frontend} from 'pageflow-scrolled/frontend';
|
408
|
-
* import {CustomNavigationBar} from './CustomNavigationBar';
|
409
|
-
*
|
410
|
-
* frontend.contentElementTypes.register('customNavigationBar', {
|
411
|
-
* component: CustomNavigationBar
|
412
|
-
* });
|
413
|
-
*/
|
414
|
-
|
415
|
-
|
416
|
-
_createClass(WidgetTypeRegistry, [{
|
417
|
-
key: "register",
|
418
|
-
value: function register(typeName, options) {
|
419
|
-
if (!options.component) {
|
420
|
-
throw new Error("Missing required component option for widget type '".concat(typeName, "'."));
|
421
|
-
}
|
422
|
-
|
423
|
-
this.types[typeName] = options;
|
424
|
-
}
|
425
|
-
}, {
|
426
|
-
key: "getComponent",
|
427
|
-
value: function getComponent(typeName) {
|
428
|
-
if (!this.types[typeName]) {
|
429
|
-
throw new Error("Unknown widget type '".concat(typeName, "'. Consider calling frontent.widgetTypes.register."));
|
430
|
-
}
|
431
|
-
|
432
|
-
return this.types[typeName].component;
|
433
|
-
}
|
434
|
-
}]);
|
435
|
-
|
436
|
-
return WidgetTypeRegistry;
|
437
|
-
}();
|
438
|
-
|
439
|
-
var api = {
|
440
|
-
contentElementTypes: new ContentElementTypeRegistry(),
|
441
|
-
widgetTypes: new WidgetTypeRegistry()
|
442
|
-
};
|
443
|
-
|
444
|
-
// For reasons that are beyond me, Storybook's Webpack build fails
|
445
|
-
// with a "JavaScript heap out of memory" error if this import
|
446
|
-
// expression lives in inlineEditing/index.js directly. I originally
|
447
|
-
// intended to hide the import from Webpack by using
|
448
|
-
// file-replace-loader in Storybook's Webpack config to replace this
|
449
|
-
// file with an empty one, but found out that extracting the import
|
450
|
-
// to a separate file apparently is enough.
|
451
|
-
function importComponents() {
|
452
|
-
return import('./components-6ab26015.js');
|
453
|
-
}
|
454
|
-
|
455
|
-
var components = {};
|
456
|
-
function loadInlineEditingComponents() {
|
457
|
-
return importComponents().then(function (importedComponents) {
|
458
|
-
components = importedComponents;
|
459
|
-
});
|
460
|
-
}
|
461
|
-
function withInlineEditingDecorator(name, Component) {
|
462
|
-
return function InlineEditingDecorator(props) {
|
463
|
-
var Decorator = components[name];
|
464
|
-
|
465
|
-
if (Decorator) {
|
466
|
-
return /*#__PURE__*/React.createElement(Decorator, props, /*#__PURE__*/React.createElement(Component, props));
|
467
|
-
} else {
|
468
|
-
return /*#__PURE__*/React.createElement(Component, props);
|
469
|
-
}
|
470
|
-
};
|
471
|
-
}
|
472
|
-
function withInlineEditingAlternative(name, Component) {
|
473
|
-
return function InlineEditingDecorator(props) {
|
474
|
-
var Alternative = components[name];
|
475
|
-
|
476
|
-
if (Alternative) {
|
477
|
-
return /*#__PURE__*/React.createElement(Alternative, props);
|
478
|
-
} else {
|
479
|
-
return /*#__PURE__*/React.createElement(Component, props);
|
480
|
-
}
|
481
|
-
};
|
482
|
-
}
|
483
|
-
|
484
|
-
var ContentElementAttributesContext = createContext({});
|
485
|
-
function ContentElementAttributesProvider(_ref) {
|
486
|
-
var id = _ref.id,
|
487
|
-
children = _ref.children;
|
488
|
-
var attributes = useMemo(function () {
|
489
|
-
return {
|
490
|
-
contentElementId: id
|
491
|
-
};
|
492
|
-
}, [id]);
|
493
|
-
return /*#__PURE__*/React.createElement(ContentElementAttributesContext.Provider, {
|
494
|
-
value: attributes
|
495
|
-
}, children);
|
496
|
-
}
|
497
|
-
function useContentElementAttributes() {
|
498
|
-
return useContext(ContentElementAttributesContext);
|
499
|
-
}
|
500
|
-
|
501
|
-
var ContentElementLifecycleContext = createContext();
|
502
|
-
var LifecycleProvider = createScrollPositionLifecycleProvider(ContentElementLifecycleContext);
|
503
|
-
var useLifecycle = createScrollPositionLifecycleHook(ContentElementLifecycleContext);
|
504
|
-
function ContentElementLifecycleProvider(_ref) {
|
505
|
-
var type = _ref.type,
|
506
|
-
children = _ref.children;
|
507
|
-
|
508
|
-
var _api$contentElementTy = api.contentElementTypes.getOptions(type),
|
509
|
-
lifecycle = _api$contentElementTy.lifecycle;
|
510
|
-
|
511
|
-
if (lifecycle) {
|
512
|
-
return /*#__PURE__*/React.createElement(LifecycleProvider, null, children);
|
513
|
-
} else {
|
514
|
-
return children;
|
515
|
-
}
|
516
|
-
}
|
517
|
-
/**
|
518
|
-
* Returns an object containing information about the scroll position
|
519
|
-
* related lifecylce of the content element. Requires the `lifecycle`
|
520
|
-
* option to be set to true in the `frontend.contentElements.register`
|
521
|
-
* call for the content element's type.
|
522
|
-
*
|
523
|
-
* * `shouldLoad` is true if the content element should start lazy
|
524
|
-
* load. Becomes true before `shouldPrepare`.
|
525
|
-
*
|
526
|
-
* * `shouldPrepare` is true if the content element is about to enter
|
527
|
-
* the viewport.
|
528
|
-
*
|
529
|
-
* * `isActive` is true if the content element is completely in the
|
530
|
-
* viewport.
|
531
|
-
*
|
532
|
-
* @param {Function} onActivate -
|
533
|
-
* Invoked when content element has entered the viewport.
|
534
|
-
*
|
535
|
-
* @param {Function} onDeactivate -
|
536
|
-
* Invoked when content element has left the viewport.
|
537
|
-
*
|
538
|
-
* @example
|
539
|
-
*
|
540
|
-
* const {isActive, shouldPrepare} = useContentElementLifecycle();
|
541
|
-
*/
|
542
|
-
|
543
|
-
function useContentElementLifecycle(options) {
|
544
|
-
var result = useLifecycle(options);
|
545
|
-
|
546
|
-
if (!result) {
|
547
|
-
throw new Error('useContentElementLifecycle is only available in ' + 'content elements for which `lifecycle: true` has ' + 'been passed to frontend.contentElements.register');
|
548
|
-
}
|
549
|
-
|
550
|
-
return result;
|
551
|
-
}
|
552
|
-
|
553
|
-
var styles$3 = {"wrapper":"ContentElementMargin-module_wrapper__20kIk"};
|
554
|
-
|
555
|
-
function ContentElementMargin(_ref) {
|
556
|
-
var position = _ref.position,
|
557
|
-
children = _ref.children;
|
558
|
-
|
559
|
-
if (position === 'full') {
|
560
|
-
return children;
|
561
|
-
}
|
562
|
-
|
563
|
-
return /*#__PURE__*/React.createElement("div", {
|
564
|
-
className: styles$3.wrapper
|
565
|
-
}, children);
|
566
|
-
}
|
567
|
-
|
568
|
-
var styles$4 = {"missing":"ContentElement-module_missing__2_1j9"};
|
569
|
-
|
570
|
-
var ContentElementErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
571
|
-
_inherits(ContentElementErrorBoundary, _React$Component);
|
572
|
-
|
573
|
-
var _super = _createSuper(ContentElementErrorBoundary);
|
574
|
-
|
575
|
-
function ContentElementErrorBoundary(props) {
|
576
|
-
var _this;
|
577
|
-
|
578
|
-
_classCallCheck(this, ContentElementErrorBoundary);
|
579
|
-
|
580
|
-
_this = _super.call(this, props);
|
581
|
-
_this.state = {
|
582
|
-
hasError: false
|
583
|
-
};
|
584
|
-
return _this;
|
585
|
-
}
|
586
|
-
|
587
|
-
_createClass(ContentElementErrorBoundary, [{
|
588
|
-
key: "render",
|
589
|
-
value: function render() {
|
590
|
-
if (this.state.hasError) {
|
591
|
-
return /*#__PURE__*/React.createElement("div", {
|
592
|
-
className: styles$4.missing
|
593
|
-
}, "Error rendering element of type \"", this.props.type, "\"");
|
594
|
-
}
|
595
|
-
|
596
|
-
return this.props.children;
|
597
|
-
}
|
598
|
-
}], [{
|
599
|
-
key: "getDerivedStateFromError",
|
600
|
-
value: function getDerivedStateFromError(error) {
|
601
|
-
return {
|
602
|
-
hasError: true
|
603
|
-
};
|
604
|
-
}
|
605
|
-
}]);
|
606
|
-
|
607
|
-
return ContentElementErrorBoundary;
|
608
|
-
}(React.Component);
|
609
|
-
|
610
|
-
var ContentElement = withInlineEditingDecorator('ContentElementDecorator', function ContentElement(props) {
|
611
|
-
var Component = api.contentElementTypes.getComponent(props.type);
|
612
|
-
|
613
|
-
if (Component) {
|
614
|
-
return /*#__PURE__*/React.createElement(ContentElementAttributesProvider, {
|
615
|
-
id: props.id
|
616
|
-
}, /*#__PURE__*/React.createElement(ContentElementLifecycleProvider, {
|
617
|
-
type: props.type
|
618
|
-
}, /*#__PURE__*/React.createElement(ContentElementMargin, {
|
619
|
-
position: props.itemProps.position
|
620
|
-
}, /*#__PURE__*/React.createElement(ContentElementErrorBoundary, {
|
621
|
-
type: props.type
|
622
|
-
}, /*#__PURE__*/React.createElement(Component, {
|
623
|
-
sectionProps: props.sectionProps,
|
624
|
-
configuration: props.itemProps,
|
625
|
-
contentElementId: props.id
|
626
|
-
})))));
|
627
|
-
} else {
|
628
|
-
return /*#__PURE__*/React.createElement("div", {
|
629
|
-
className: styles$4.missing
|
630
|
-
}, "Element of unknown type \"", props.type, "\"");
|
631
|
-
}
|
632
|
-
});
|
633
|
-
ContentElement.defaultProps = {
|
634
|
-
itemProps: {}
|
635
|
-
};
|
636
|
-
|
637
|
-
function ContentElements(props) {
|
638
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, props.items.map(function (item, index) {
|
639
|
-
return props.children(item, /*#__PURE__*/React.createElement(MemoizedContentElement, {
|
640
|
-
key: item.id,
|
641
|
-
id: item.id,
|
642
|
-
permaId: item.permaId,
|
643
|
-
type: item.type,
|
644
|
-
first: index === 0,
|
645
|
-
position: item.position,
|
646
|
-
itemProps: item.props,
|
647
|
-
sectionProps: props.sectionProps
|
648
|
-
}), index);
|
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
|
-
var _theme$options$proper, _theme$options$proper2;
|
662
|
-
|
663
|
-
var theme = useTheme();
|
664
|
-
var maxWidth = ((_theme$options$proper = theme.options.properties) === null || _theme$options$proper === void 0 ? void 0 : (_theme$options$proper2 = _theme$options$proper.root) === null || _theme$options$proper2 === void 0 ? void 0 : _theme$options$proper2.narrowViewportBreakpoint) || '950px';
|
665
|
-
return useMediaQuery("(max-width: ".concat(maxWidth, ")"));
|
666
|
-
}
|
667
|
-
|
668
|
-
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","right":"TwoColumn-module_right__Fr52a","narrowViewport":"TwoColumn-module_narrowViewport__1x_NY","wideViewport":"TwoColumn-module_wideViewport___c_Zz"};
|
669
|
-
|
670
|
-
function availablePositions(narrow) {
|
671
|
-
if (narrow) {
|
672
|
-
return ['inline', 'wide', 'full'];
|
673
|
-
} else {
|
674
|
-
return ['inline', 'sticky', 'wide', 'full'];
|
675
|
-
}
|
676
|
-
}
|
677
|
-
|
678
|
-
function TwoColumn(props) {
|
679
|
-
var narrow = useNarrowViewport();
|
680
|
-
return /*#__PURE__*/React.createElement("div", {
|
681
|
-
className: classNames(styles$5.root, styles$5[props.align], narrow ? styles$5.narrowViewport : styles$5.wideViewport)
|
682
|
-
}, /*#__PURE__*/React.createElement("div", {
|
683
|
-
className: classNames(styles$5.group),
|
684
|
-
key: props.align
|
685
|
-
}, /*#__PURE__*/React.createElement("div", {
|
686
|
-
className: styles$5.inline,
|
687
|
-
ref: props.contentAreaRef
|
688
|
-
})), renderItems(props, narrow), renderPlaceholder(props.placeholder));
|
689
|
-
}
|
690
|
-
TwoColumn.defaultProps = {
|
691
|
-
align: 'left'
|
692
|
-
};
|
693
|
-
|
694
|
-
function renderItems(props, narrow) {
|
695
|
-
return groupItemsByPosition(props.items, availablePositions(narrow)).map(function (group, index) {
|
696
|
-
return /*#__PURE__*/React.createElement("div", {
|
697
|
-
key: index,
|
698
|
-
className: classNames(styles$5.group, styles$5["group-".concat(group.position)])
|
699
|
-
}, renderItemGroup(props, group, 'sticky'), renderItemGroup(props, group, 'inline'), renderItemGroup(props, group, 'wide'), renderItemGroup(props, group, 'full'));
|
700
|
-
});
|
701
|
-
}
|
702
|
-
|
703
|
-
function renderItemGroup(props, group, position) {
|
704
|
-
if (group[position].length) {
|
705
|
-
return /*#__PURE__*/React.createElement("div", {
|
706
|
-
className: styles$5[position]
|
707
|
-
}, props.children( /*#__PURE__*/React.createElement(ContentElements, {
|
708
|
-
sectionProps: props.sectionProps,
|
709
|
-
items: group[position]
|
710
|
-
}), {
|
711
|
-
position: position,
|
712
|
-
openStart: position === 'inline' && group.openStart,
|
713
|
-
openEnd: position === 'inline' && group.openEnd
|
714
|
-
}));
|
715
|
-
}
|
716
|
-
}
|
717
|
-
|
718
|
-
function groupItemsByPosition(items, availablePositions) {
|
719
|
-
var groups = [];
|
720
|
-
var currentGroup;
|
721
|
-
items.reduce(function (previousItemPosition, item, index) {
|
722
|
-
var position = availablePositions.indexOf(item.position) >= 0 ? item.position : 'inline';
|
723
|
-
|
724
|
-
if (!previousItemPosition || previousItemPosition !== position && !(previousItemPosition === 'sticky' && position === 'inline')) {
|
725
|
-
currentGroup = {
|
726
|
-
position: position,
|
727
|
-
sticky: [],
|
728
|
-
inline: [],
|
729
|
-
wide: [],
|
730
|
-
full: []
|
731
|
-
};
|
732
|
-
groups = [].concat(_toConsumableArray(groups), [currentGroup]);
|
733
|
-
}
|
734
|
-
|
735
|
-
currentGroup[position].push(item);
|
736
|
-
return position;
|
737
|
-
}, null);
|
738
|
-
groups.forEach(function (group, index) {
|
739
|
-
var previous = groups[index - 1];
|
740
|
-
var next = groups[index + 1];
|
741
|
-
group.openStart = previous && !(previous.full.length || previous.wide.length);
|
742
|
-
group.openEnd = next && next.inline.length > 0;
|
743
|
-
});
|
744
|
-
return groups;
|
745
|
-
}
|
746
|
-
|
747
|
-
function renderPlaceholder(placeholder) {
|
748
|
-
if (!placeholder) {
|
749
|
-
return null;
|
750
|
-
}
|
751
|
-
|
752
|
-
return /*#__PURE__*/React.createElement("div", {
|
753
|
-
className: classNames(styles$5.group)
|
754
|
-
}, /*#__PURE__*/React.createElement("div", {
|
755
|
-
className: styles$5.inline
|
756
|
-
}, placeholder));
|
757
|
-
}
|
758
|
-
|
759
|
-
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"};
|
760
|
-
|
761
|
-
function Center(props) {
|
762
|
-
return /*#__PURE__*/React.createElement("div", {
|
763
|
-
className: classNames(styles$6.root)
|
764
|
-
}, /*#__PURE__*/React.createElement("div", {
|
765
|
-
ref: props.contentAreaRef
|
766
|
-
}), /*#__PURE__*/React.createElement(ContentElements, {
|
767
|
-
sectionProps: props.sectionProps,
|
768
|
-
items: props.items
|
769
|
-
}, function (item, child, index) {
|
770
|
-
return /*#__PURE__*/React.createElement("div", {
|
771
|
-
key: item.id,
|
772
|
-
className: outerClassName(item)
|
773
|
-
}, /*#__PURE__*/React.createElement("div", {
|
774
|
-
className: classNames(styles$6.item, styles$6["item-".concat(item.position)])
|
775
|
-
}, props.children( /*#__PURE__*/React.createElement("div", {
|
776
|
-
className: styles$6["inner-".concat(item.position)]
|
777
|
-
}, child), boxProps(props.items, item, index))));
|
778
|
-
}), renderPlaceholder$1(props.placeholder));
|
779
|
-
}
|
780
|
-
|
781
|
-
function outerClassName(item) {
|
782
|
-
var _api$contentElementTy = api.contentElementTypes.getOptions(item.type),
|
783
|
-
supportsWrappingAroundFloats = _api$contentElementTy.supportsWrappingAroundFloats;
|
784
|
-
|
785
|
-
return classNames(styles$6.outer, styles$6["outer-".concat(item.position)], _defineProperty({}, styles$6.clear, !supportsWrappingAroundFloats));
|
786
|
-
}
|
787
|
-
|
788
|
-
function boxProps(items, item, index) {
|
789
|
-
var previous = items[index - 1];
|
790
|
-
var next = items[index + 1];
|
791
|
-
return {
|
792
|
-
position: item.position,
|
793
|
-
openStart: previous && item.position !== 'full' && previous.position !== 'full' && item.position !== 'wide' && previous.position !== 'wide',
|
794
|
-
openEnd: next && item.position !== 'full' && next.position !== 'full' && item.position !== 'wide' && next.position !== 'wide'
|
795
|
-
};
|
796
|
-
}
|
797
|
-
|
798
|
-
function renderPlaceholder$1(placeholder) {
|
799
|
-
if (!placeholder) {
|
800
|
-
return null;
|
801
|
-
}
|
802
|
-
|
803
|
-
return /*#__PURE__*/React.createElement("div", {
|
804
|
-
className: classNames(styles$6.outer)
|
805
|
-
}, /*#__PURE__*/React.createElement("div", {
|
806
|
-
className: classNames(styles$6.item)
|
807
|
-
}, placeholder));
|
808
|
-
}
|
809
|
-
|
810
|
-
var Layout = React.memo(withInlineEditingAlternative('LayoutWithPlaceholder', LayoutWithoutInlineEditing), function (prevProps, nextProps) {
|
811
|
-
return prevProps.sectionId === nextProps.sectionId && prevProps.items === nextProps.items && prevProps.appearance === nextProps.appearance && prevProps.contentAreaRef === nextProps.contentAreaRef && prevProps.sectionProps === nextProps.sectionProps;
|
812
|
-
});
|
813
|
-
function LayoutWithoutInlineEditing(props) {
|
814
|
-
if (props.sectionProps.layout === 'center' || props.sectionProps.layout === 'centerRagged') {
|
815
|
-
return /*#__PURE__*/React.createElement(Center, props);
|
816
|
-
} else if (props.sectionProps.layout === 'right') {
|
817
|
-
return /*#__PURE__*/React.createElement(TwoColumn, Object.assign({
|
818
|
-
align: "right"
|
819
|
-
}, props));
|
820
|
-
} else {
|
821
|
-
return /*#__PURE__*/React.createElement(TwoColumn, props);
|
822
|
-
}
|
823
|
-
}
|
824
|
-
Layout.defaultProps = {
|
825
|
-
layout: 'left'
|
826
|
-
};
|
827
|
-
|
828
|
-
function usePostMessageListener(receiveData) {
|
829
|
-
useEffect(function () {
|
830
|
-
if (window.parent !== window) {
|
831
|
-
window.addEventListener('message', receive);
|
832
|
-
}
|
833
|
-
|
834
|
-
return function () {
|
835
|
-
return window.removeEventListener('message', receive);
|
836
|
-
};
|
837
|
-
|
838
|
-
function receive(message) {
|
839
|
-
if (window.location.href.indexOf(message.origin) === 0) {
|
840
|
-
receiveData(message.data);
|
841
|
-
}
|
842
|
-
}
|
843
|
-
}, [receiveData]);
|
844
|
-
}
|
845
|
-
|
846
|
-
var textStyles = {"text-s":"20px","text-base":"22px","text-l":"40px","text-2l":"50px","text-xl":"66px","text-2xl":"88px","text-3xl":"110px","heading-lg":"Text-module_heading-lg__FKxzu typography-headingLg typography-heading","heading-md":"Text-module_heading-md__1q5Ss typography-headingMd typography-heading","heading-sm":"Text-module_heading-sm__2awaz typography-headingSm typography-heading","heading-xs":"Text-module_heading-xs__21nHy typography-headingXs typography-heading","body":"Text-module_body__4oWD- typography-body","caption":"Text-module_caption__3_6Au typography-caption"};
|
847
|
-
|
848
|
-
/**
|
849
|
-
* Render some text using the default typography scale.
|
850
|
-
*
|
851
|
-
* @param {Object} props
|
852
|
-
* @param {string} props.scaleCategory -
|
853
|
-
* One of the styles `'heading-lg'`, `'heading-md'`, `'heading-sm'`,
|
854
|
-
* `'heading-xs'`, `'body'`, `'caption'`.
|
855
|
-
* @param {string} [props.inline] - Render a span instread of a div.
|
856
|
-
* @param {string} props.children - Nodes to render with specified typography.
|
857
|
-
*/
|
858
|
-
|
859
|
-
function Text(_ref) {
|
860
|
-
var inline = _ref.inline,
|
861
|
-
scaleCategory = _ref.scaleCategory,
|
862
|
-
children = _ref.children;
|
863
|
-
return React.createElement(inline ? 'span' : 'div', {
|
864
|
-
className: textStyles[scaleCategory]
|
865
|
-
}, children);
|
866
|
-
}
|
867
|
-
|
868
|
-
var ContentElementConfigurationUpdateContext = React.createContext(function () {});
|
869
|
-
function useContentElementConfigurationUpdate() {
|
870
|
-
return useContext(ContentElementConfigurationUpdateContext);
|
871
|
-
}
|
872
|
-
|
873
|
-
var ContentElementEditorCommandEmitterContext = createContext({
|
874
|
-
on: function on() {},
|
875
|
-
off: function off() {}
|
876
|
-
});
|
877
|
-
function useContentElementEditorCommandSubscription(callback) {
|
878
|
-
var _useContentElementAtt = useContentElementAttributes(),
|
879
|
-
contentElementId = _useContentElementAtt.contentElementId;
|
880
|
-
|
881
|
-
var emitter = useContext(ContentElementEditorCommandEmitterContext);
|
882
|
-
useEffect(function () {
|
883
|
-
emitter.on("command:".concat(contentElementId), callback);
|
884
|
-
return function () {
|
885
|
-
return emitter.off("command:".concat(contentElementId), callback);
|
886
|
-
};
|
887
|
-
}, [emitter, callback, contentElementId]);
|
888
|
-
}
|
889
|
-
|
890
|
-
var EditableText = withInlineEditingAlternative('EditableText', function EditableText(_ref) {
|
891
|
-
var value = _ref.value;
|
892
|
-
return /*#__PURE__*/React.createElement(Text, {
|
893
|
-
scaleCategory: "body"
|
894
|
-
}, render(value));
|
895
|
-
});
|
896
|
-
|
897
|
-
function render() {
|
898
|
-
var children = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
899
|
-
return children.map(function (element, index) {
|
900
|
-
if (element.type) {
|
901
|
-
return renderElement({
|
902
|
-
attributes: {
|
903
|
-
key: index
|
904
|
-
},
|
905
|
-
element: element,
|
906
|
-
children: render(element.children)
|
907
|
-
});
|
908
|
-
} else {
|
909
|
-
return renderLeaf({
|
910
|
-
attributes: {
|
911
|
-
key: index
|
912
|
-
},
|
913
|
-
leaf: element,
|
914
|
-
children: element.text.trim() === '' ? "\uFEFF" : element.text
|
915
|
-
});
|
916
|
-
}
|
917
|
-
});
|
918
|
-
}
|
919
|
-
|
920
|
-
function renderElement(_ref2) {
|
921
|
-
var attributes = _ref2.attributes,
|
922
|
-
children = _ref2.children,
|
923
|
-
element = _ref2.element;
|
924
|
-
var variantClassName = element.variant && ['typography-textBlock', camelize(element.type), element.variant].join('-');
|
925
|
-
|
926
|
-
switch (element.type) {
|
927
|
-
case 'block-quote':
|
928
|
-
return /*#__PURE__*/React.createElement("blockquote", Object.assign({}, attributes, {
|
929
|
-
className: variantClassName
|
930
|
-
}), children);
|
931
|
-
|
932
|
-
case 'bulleted-list':
|
933
|
-
return /*#__PURE__*/React.createElement("ul", Object.assign({}, attributes, {
|
934
|
-
className: variantClassName
|
935
|
-
}), children);
|
936
|
-
|
937
|
-
case 'numbered-list':
|
938
|
-
return /*#__PURE__*/React.createElement("ol", Object.assign({}, attributes, {
|
939
|
-
className: variantClassName
|
940
|
-
}), children);
|
941
|
-
|
942
|
-
case 'list-item':
|
943
|
-
return /*#__PURE__*/React.createElement("li", attributes, children);
|
944
|
-
|
945
|
-
case 'heading':
|
946
|
-
return /*#__PURE__*/React.createElement("h2", Object.assign({}, attributes, {
|
947
|
-
className: classNames(variantClassName, textStyles['heading-xs'])
|
948
|
-
}), children);
|
949
|
-
|
950
|
-
case 'link':
|
951
|
-
return /*#__PURE__*/React.createElement("a", Object.assign({}, attributes, {
|
952
|
-
href: element.href
|
953
|
-
}), children);
|
954
|
-
|
955
|
-
default:
|
956
|
-
return /*#__PURE__*/React.createElement("p", Object.assign({}, attributes, {
|
957
|
-
className: variantClassName
|
958
|
-
}), children);
|
959
|
-
}
|
960
|
-
}
|
961
|
-
function renderLeaf(_ref3) {
|
962
|
-
var attributes = _ref3.attributes,
|
963
|
-
children = _ref3.children,
|
964
|
-
leaf = _ref3.leaf;
|
965
|
-
|
966
|
-
if (leaf.bold) {
|
967
|
-
children = /*#__PURE__*/React.createElement("strong", null, children);
|
968
|
-
}
|
969
|
-
|
970
|
-
if (leaf.italic) {
|
971
|
-
children = /*#__PURE__*/React.createElement("em", null, children);
|
972
|
-
}
|
973
|
-
|
974
|
-
if (leaf.underline) {
|
975
|
-
children = /*#__PURE__*/React.createElement("u", null, children);
|
976
|
-
}
|
977
|
-
|
978
|
-
if (leaf.strikethrough) {
|
979
|
-
children = /*#__PURE__*/React.createElement("s", null, children);
|
980
|
-
}
|
981
|
-
|
982
|
-
return /*#__PURE__*/React.createElement("span", attributes, children);
|
983
|
-
}
|
984
|
-
|
985
|
-
function camelize(snakeCase) {
|
986
|
-
return snakeCase.replace(/-[a-z]/g, function (match) {
|
987
|
-
return match[1].toUpperCase();
|
988
|
-
});
|
989
|
-
}
|
990
|
-
|
991
|
-
var frontendStyles = {"root":"EditableInlineText-module_root__3eA-J","manualHyphens":"EditableInlineText-module_manualHyphens__r4suO"};
|
992
|
-
|
993
|
-
export { ContentElementEditorCommandEmitterContext as C, EditableText as E, Foreground as F, Layout as L, MotifArea as M, StaticPreview as S, Text as T, useIsStaticPreview as a, createScrollPositionLifecycleHook as b, createScrollPositionLifecycleProvider as c, useMediaQuery as d, usePostMessageListener as e, api as f, withInlineEditingAlternative as g, frontendStyles as h, useContentElementConfigurationUpdate as i, useContentElementEditorCommandSubscription as j, useContentElementLifecycle as k, loadInlineEditingComponents as l, useOnScreen as m, MotifAreaVisibilityProvider as n, ForcePaddingContext as o, ContentElementConfigurationUpdateContext as p, ContentElementEditorStateContext as q, LayoutWithoutInlineEditing as r, renderElement as s, renderLeaf as t, useContentElementEditorState as u, withInlineEditingDecorator as w };
|