pageflow 15.2.2 → 15.3.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.

Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +338 -85
  3. data/admins/pageflow/accounts.rb +1 -98
  4. data/admins/pageflow/entry.rb +21 -1
  5. data/admins/pageflow/entry_templates.rb +140 -0
  6. data/admins/pageflow/membership.rb +12 -0
  7. data/admins/pageflow/user.rb +5 -3
  8. data/app/assets/javascripts/pageflow/admin/entries.js +65 -0
  9. data/app/assets/javascripts/pageflow/admin/users.js +1 -1
  10. data/app/assets/javascripts/pageflow/asset_urls.js.erb +1 -0
  11. data/app/assets/javascripts/pageflow/base.js +0 -12
  12. data/app/assets/javascripts/pageflow/components.js +2 -6
  13. data/app/assets/javascripts/pageflow/dist/ui.js +47 -14
  14. data/app/assets/javascripts/pageflow/vendor.js +13 -10
  15. data/app/assets/stylesheets/pageflow/base.scss +0 -7
  16. data/app/assets/stylesheets/pageflow/editor/base.scss +2 -0
  17. data/app/assets/stylesheets/pageflow/editor/composables.scss +5 -1
  18. data/app/assets/stylesheets/pageflow/editor/emulation_mode_button.scss +44 -55
  19. data/app/assets/stylesheets/pageflow/editor/help.scss +2 -2
  20. data/app/assets/stylesheets/pageflow/ui/tooltip.scss +17 -3
  21. data/app/helpers/pageflow/admin/entries_helper.rb +16 -0
  22. data/app/helpers/pageflow/structured_data_helper.rb +0 -2
  23. data/app/models/pageflow/account.rb +21 -1
  24. data/app/models/pageflow/entry.rb +9 -2
  25. data/app/models/pageflow/entry_duplicate.rb +1 -0
  26. data/app/models/pageflow/entry_template.rb +16 -2
  27. data/app/policies/pageflow/account_policy.rb +10 -0
  28. data/app/policies/pageflow/entry_template_policy.rb +5 -1
  29. data/app/views/admin/accounts/_entry_template_details.html.arb +7 -5
  30. data/app/views/admin/accounts/_form.html.erb +3 -49
  31. data/app/views/admin/entries/_attributes_table.html.arb +5 -0
  32. data/app/views/admin/entries/_not_allowed_to_see_entry_types.json.jbuilder +2 -0
  33. data/app/views/admin/entries/entry_types.json.jbuilder +4 -0
  34. data/app/views/admin/entry_templates/_form.html.erb +58 -0
  35. data/app/views/admin/users/_not_allowed_to_see_user_quota.html.erb +3 -0
  36. data/app/views/components/pageflow/admin/entry_templates_tab.rb +48 -0
  37. data/app/views/pageflow/admin/users/_quota_exhausted.html.erb +1 -1
  38. data/config/initializers/admin_resource_tabs.rb +5 -0
  39. data/config/initializers/help_entries.rb +1 -5
  40. data/config/locales/de.yml +88 -155
  41. data/config/locales/en.yml +79 -143
  42. data/db/migrate/20200515112500_add_constraints_to_entry_templates.rb +21 -0
  43. data/db/migrate/20200807135200_rename_pageflow_entry_template_entry_type_to_entry_type_name.rb +7 -0
  44. data/entry_types/paged/app/assets/javascripts/pageflow_paged/components.js +7 -0
  45. data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/editor.js +1479 -1391
  46. data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/frontend.js +9218 -0
  47. data/{app/assets/javascripts/pageflow → entry_types/paged/app/assets/javascripts/pageflow_paged}/dist/react-client.js +1 -1
  48. data/{app/assets/javascripts/pageflow → entry_types/paged/app/assets/javascripts/pageflow_paged}/dist/react-server.js +3 -3
  49. data/entry_types/paged/app/assets/javascripts/pageflow_paged/frontend.js +6 -0
  50. data/entry_types/paged/app/assets/javascripts/pageflow_paged/server_rendering.js +9 -0
  51. data/entry_types/paged/app/assets/javascripts/pageflow_paged/vendor.js +8 -0
  52. data/entry_types/paged/app/controllers/pageflow_paged/application_controller.rb +2 -2
  53. data/{app/helpers/pageflow → entry_types/paged/app/helpers/pageflow_paged}/page_background_asset_helper.rb +4 -3
  54. data/{app/helpers/pageflow → entry_types/paged/app/helpers/pageflow_paged}/react_server_side_rendering_helper.rb +23 -2
  55. data/entry_types/paged/app/views/layouts/pageflow_paged/application.html.erb +2 -2
  56. data/entry_types/paged/app/views/pageflow_paged/editor/entries/_head.html.erb +2 -2
  57. data/entry_types/paged/app/views/pageflow_paged/entries/_entry.html.erb +1 -1
  58. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/page_background_asset/_element.html.erb +0 -0
  59. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/react/_widget.html.erb +0 -0
  60. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/react/page.html.erb +0 -0
  61. data/entry_types/paged/config/initializers/features.rb +1 -1
  62. data/entry_types/paged/config/initializers/help_entries.rb +17 -0
  63. data/entry_types/paged/config/locales/new/help.de.yml +162 -0
  64. data/entry_types/paged/config/locales/new/help.en.yml +153 -0
  65. data/entry_types/paged/lib/pageflow_paged/engine.rb +13 -0
  66. data/entry_types/paged/lib/pageflow_paged/plugin.rb +5 -1
  67. data/entry_types/paged/lib/pageflow_paged/react.rb +12 -0
  68. data/{lib/pageflow → entry_types/paged/lib/pageflow_paged}/react/page_type.rb +2 -2
  69. data/{lib/pageflow → entry_types/paged/lib/pageflow_paged}/react/widget_type.rb +2 -2
  70. data/entry_types/paged/vendor/assets/javascripts/development/pageflow_paged/vendor/react-server.js +20613 -0
  71. data/entry_types/paged/vendor/assets/javascripts/development/pageflow_paged/vendor/react.js +21495 -0
  72. data/entry_types/paged/vendor/assets/javascripts/production/pageflow_paged/vendor/react-server.js +24 -0
  73. data/entry_types/paged/vendor/assets/javascripts/production/pageflow_paged/vendor/react.js +24 -0
  74. data/entry_types/scrolled/app/assets/javascripts/pageflow_scrolled/legacy.js +0 -0
  75. data/entry_types/scrolled/app/controllers/pageflow_scrolled/editor/chapters_controller.rb +2 -2
  76. data/entry_types/scrolled/app/controllers/pageflow_scrolled/editor/content_elements_controller.rb +14 -4
  77. data/entry_types/scrolled/app/controllers/pageflow_scrolled/editor/sections_controller.rb +2 -2
  78. data/entry_types/scrolled/app/controllers/pageflow_scrolled/entries_controller.rb +8 -0
  79. data/entry_types/scrolled/app/helpers/pageflow_scrolled/editor/seed_html_helper.rb +6 -0
  80. data/entry_types/scrolled/app/helpers/pageflow_scrolled/entry_json_seed_helper.rb +2 -0
  81. data/entry_types/scrolled/app/helpers/pageflow_scrolled/react_server_side_rendering_helper.rb +33 -0
  82. data/entry_types/scrolled/app/helpers/pageflow_scrolled/themes_helper.rb +8 -0
  83. data/entry_types/scrolled/app/models/pageflow_scrolled/content_element.rb +38 -0
  84. data/entry_types/scrolled/app/views/pageflow_scrolled/editor/content_elements/batch.json.jbuilder +2 -0
  85. data/entry_types/scrolled/app/views/pageflow_scrolled/editor/entries/_head.html.erb +1 -7
  86. data/entry_types/scrolled/app/views/pageflow_scrolled/entries/show.html.erb +19 -3
  87. data/entry_types/scrolled/app/views/pageflow_scrolled/entry_json_seed/_entry.json.jbuilder +3 -0
  88. data/entry_types/scrolled/app/views/pageflow_scrolled/entry_json_seed/_theme.json.jbuilder +7 -0
  89. data/entry_types/scrolled/config/initializers/help_entries.rb +16 -0
  90. data/entry_types/scrolled/config/locales/new/de.yml +345 -13
  91. data/entry_types/scrolled/config/locales/new/en.yml +257 -14
  92. data/entry_types/scrolled/config/routes.rb +1 -0
  93. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/install_generator.rb +28 -0
  94. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/logoDesktop.svg +56 -0
  95. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/logoMobile.svg +22 -0
  96. data/entry_types/scrolled/lib/pageflow_scrolled/engine.rb +4 -0
  97. data/entry_types/scrolled/lib/pageflow_scrolled/plugin.rb +3 -1
  98. data/entry_types/scrolled/lib/pageflow_scrolled/seeds.rb +90 -30
  99. data/entry_types/scrolled/lib/tasks/pageflow_scrolled_tasks.rake +64 -27
  100. data/entry_types/scrolled/package/contentElements-editor.js +242 -183
  101. data/entry_types/scrolled/package/contentElements-frontend.css +1 -0
  102. data/entry_types/scrolled/package/contentElements-frontend.js +624 -279
  103. data/entry_types/scrolled/package/editor.js +2561 -363
  104. data/entry_types/scrolled/package/frontend-server.js +228 -0
  105. data/entry_types/scrolled/package/frontend/EditableText-4264c349.js +1993 -0
  106. data/entry_types/scrolled/package/frontend/Wavesurfer-c3c45324.js +378 -0
  107. data/entry_types/scrolled/package/frontend/components-cfe6a479.js +2115 -0
  108. data/entry_types/scrolled/package/frontend/getPrototypeOf-63c7c8e8.js +86 -0
  109. data/entry_types/scrolled/package/frontend/index.css +9 -0
  110. data/entry_types/scrolled/package/frontend/index.js +4425 -0
  111. data/entry_types/scrolled/package/package.json +17 -6
  112. data/entry_types/scrolled/spec/fixtures/audio.m4a +0 -0
  113. data/entry_types/scrolled/spec/fixtures/video.mp4 +0 -0
  114. data/lib/generators/pageflow/initializer/templates/pageflow.rb +20 -9
  115. data/lib/pageflow/ability_mixin.rb +14 -2
  116. data/lib/pageflow/configuration.rb +6 -5
  117. data/lib/pageflow/engine.rb +1 -0
  118. data/lib/pageflow/entry_type_configuration.rb +1 -0
  119. data/lib/pageflow/global_config_api.rb +5 -4
  120. data/lib/pageflow/react.rb +4 -2
  121. data/lib/pageflow/version.rb +1 -1
  122. data/{packages/pageflow → package}/config/jest/index.js +2 -1
  123. data/{packages/pageflow → package}/config/jest/transformers/jst.js +0 -0
  124. data/{packages/pageflow → package}/config/jest/transformers/upwardBabel.js +0 -0
  125. data/package/config/webpack.js +22 -0
  126. data/{packages/pageflow → package}/editor.js +480 -1129
  127. data/package/frontend.js +2525 -0
  128. data/{packages/pageflow → package}/package.json +3 -0
  129. data/{packages/pageflow → package}/testHelpers.js +114 -13
  130. data/{packages/pageflow → package}/ui.js +47 -14
  131. data/spec/factories/accounts.rb +3 -1
  132. data/spec/factories/entry_templates.rb +1 -0
  133. data/spec/factories/published_entries.rb +6 -1
  134. metadata +62 -26
  135. data/app/assets/javascripts/pageflow/dist/frontend.js +0 -5800
  136. data/config/initializers/entry_types.rb +0 -4
  137. data/entry_types/scrolled/package/frontend.js +0 -2879
  138. data/packages/pageflow/config/jest/transformers/cssModules.js +0 -1
  139. data/packages/pageflow/config/webpack.js +0 -14
@@ -0,0 +1 @@
1
+ .Heading-module_root__33TFw{margin-top:.2em;margin-bottom:0;padding-top:.3em}@media (orientation:landscape){.Heading-module_first__1PMJX{padding-top:25%}}.BeforeAfter-module_sliderStart__2C5cN{background-color:#fff;position:absolute;z-index:1}.BeforeAfter-module_container__2Lm06{--frame1pos:-8;--frame2pos:16;--frame3pos:-32;--frame4pos:32;--frame1px:calc(var(--frame1pos)*1px);--frame2px:calc(var(--frame2pos)*1px);--frame3px:calc(var(--frame3pos)*1px);--frame4px:calc(var(--frame4pos)*1px)}.BeforeAfter-module_container__2Lm06.BeforeAfter-module_wiggle__3nVSe div div:nth-child(3){-webkit-animation:BeforeAfter-module_SliderLeftRightShake__2mcn5 1.5s cubic-bezier(.36,.07,.19,.97) both;animation:BeforeAfter-module_SliderLeftRightShake__2mcn5 1.5s cubic-bezier(.36,.07,.19,.97) both}.BeforeAfter-module_container__2Lm06.BeforeAfter-module_wiggle__3nVSe div img:nth-child(2){-webkit-animation:BeforeAfter-module_BeforeImageLeftRightShake__38m9V 1.5s cubic-bezier(.36,.07,.19,.97) both;animation:BeforeAfter-module_BeforeImageLeftRightShake__38m9V 1.5s cubic-bezier(.36,.07,.19,.97) both}.BeforeAfter-module_container__2Lm06 div div:nth-child(4) div{transition:opacity .1s ease-out .3s!important}.BeforeAfter-module_container__2Lm06.BeforeAfter-module_wiggle__3nVSe div img:first-child{-webkit-animation:BeforeAfter-module_AfterImageLeftRightShake__3WMf1 1.5s cubic-bezier(.36,.07,.19,.97) both;animation:BeforeAfter-module_AfterImageLeftRightShake__3WMf1 1.5s cubic-bezier(.36,.07,.19,.97) both}.BeforeAfter-module_container__2Lm06 div div:nth-child(5) div{transition:opacity .1s ease-out .3s!important}@-webkit-keyframes BeforeAfter-module_BeforeImageLeftRightShake__38m9V{10%,90%{clip:rect(auto,calc(var(--initial-rect-width) + var(--frame1px)),auto,auto)}20%,80%{clip:rect(auto,calc(var(--initial-rect-width) + var(--frame2px)),auto,auto)}30%,50%,70%{clip:rect(auto,calc(var(--initial-rect-width) + var(--frame3px)),auto,auto)}40%,60%{clip:rect(auto,calc(var(--initial-rect-width) + var(--frame4px)),auto,auto)}}@keyframes BeforeAfter-module_BeforeImageLeftRightShake__38m9V{10%,90%{clip:rect(auto,calc(var(--initial-rect-width) + var(--frame1px)),auto,auto)}20%,80%{clip:rect(auto,calc(var(--initial-rect-width) + var(--frame2px)),auto,auto)}30%,50%,70%{clip:rect(auto,calc(var(--initial-rect-width) + var(--frame3px)),auto,auto)}40%,60%{clip:rect(auto,calc(var(--initial-rect-width) + var(--frame4px)),auto,auto)}}@-webkit-keyframes BeforeAfter-module_AfterImageLeftRightShake__3WMf1{10%,90%{clip:rect(auto,auto,auto,calc(var(--initial-rect-width) + var(--frame1px)))}20%,80%{clip:rect(auto,auto,auto,calc(var(--initial-rect-width) + var(--frame2px)))}30%,50%,70%{clip:rect(auto,auto,auto,calc(var(--initial-rect-width) + var(--frame3px)))}40%,60%{clip:rect(auto,auto,auto,calc(var(--initial-rect-width) + var(--frame4px)))}}@keyframes BeforeAfter-module_AfterImageLeftRightShake__3WMf1{10%,90%{clip:rect(auto,auto,auto,calc(var(--initial-rect-width) + var(--frame1px)))}20%,80%{clip:rect(auto,auto,auto,calc(var(--initial-rect-width) + var(--frame2px)))}30%,50%,70%{clip:rect(auto,auto,auto,calc(var(--initial-rect-width) + var(--frame3px)))}40%,60%{clip:rect(auto,auto,auto,calc(var(--initial-rect-width) + var(--frame4px)))}}@-webkit-keyframes BeforeAfter-module_SliderLeftRightShake__2mcn5{10%,90%{transform:translate3d(-20%,0,0)}20%,80%{transform:translate3d(40%,0,0)}30%,50%,70%{transform:translate3d(-80%,0,0)}40%,60%{transform:translate3d(80%,0,0)}}@keyframes BeforeAfter-module_SliderLeftRightShake__2mcn5{10%,90%{transform:translate3d(-20%,0,0)}20%,80%{transform:translate3d(40%,0,0)}30%,50%,70%{transform:translate3d(-80%,0,0)}40%,60%{transform:translate3d(80%,0,0)}}.SoundDisclaimer-module_soundDisclaimer__31hWh{text-align:center;border:1px solid;border-radius:4px;cursor:pointer;font-size:inherit}.SoundDisclaimer-module_soundDisclaimer__31hWh:hover{background:hsla(0,0%,100%,.25)}.TextBlock-module_text__21Hk4 h2,.TextBlock-module_text__21Hk4 li,.TextBlock-module_text__21Hk4 p{margin:1em 0 0}.TextBlock-module_text__21Hk4 a{color:currentColor;word-wrap:break-word}.TextBlock-module_text__21Hk4 ol,.TextBlock-module_text__21Hk4 ul{margin:0;padding-left:20px}.TextBlock-module_text__21Hk4 blockquote{padding:.5em 1em .5em 2em;margin:1em 0 0 .5em;position:relative}.TextBlock-module_text__21Hk4 blockquote:before{content:"\201C";font-size:3em;font-weight:700;color:#aaa;position:absolute;top:0;left:0;line-height:1em}.VideoEmbed-module_embedPlayer__54NKG{background-color:#000;position:absolute;top:0;left:0;bottom:0;right:0}.ExternalLink-module_hidden__3jer0{display:none}.ExternalLink-module_link_item__Blypv{width:45%;max-width:45%;vertical-align:top;margin:2% auto;background-color:#fff;color:#000;text-decoration:none;transition:transform .3s}.ExternalLink-module_link_item__Blypv.ExternalLink-module_invert__1zrgN{background-color:#222;color:#fff}.ExternalLink-module_link_item__Blypv.ExternalLink-module_layout_center__3NRpQ{width:29%;max-width:29%}.ExternalLink-module_link_item__Blypv:hover{transform:scale(1.05)}.ExternalLink-module_link_item__Blypv:hover .ExternalLink-module_link_title__FZJ-0{text-decoration:underline}.ExternalLink-module_link_thumbnail__2_BHq{width:auto;background-repeat:no-repeat;background-size:cover;padding-top:56.25%;position:relative}.ExternalLink-module_link_details__lRhKU{margin:20px}.ExternalLink-module_link_details__lRhKU>.ExternalLink-module_link_title__FZJ-0{font-size:1.2em;font-weight:700;margin-bottom:20px}.ExternalLink-module_link_details__lRhKU>p{width:100%;white-space:normal;line-height:1.3em}.ExternalLink-module_tooltip__18MpC{position:absolute;left:50%;top:80px;width:180px;padding:5px;margin-left:-95px;background-color:#444;color:#fff;border:1px solid #fff;opacity:.9;font-size:13px;text-align:center;white-space:normal}.ExternalLink-module_tooltip__18MpC>span{display:block;color:#fff;text-decoration:underline}.ExternalLinkList-module_ext_links_container__16IIo{display:flex;flex-wrap:wrap;border-collapse:separate;border-spacing:10px;min-height:240px;width:auto;height:auto;pointer-events:all;position:relative;transition:opacity .5s;transition-timing-function:cubic-bezier(.1,.57,.1,1);transition-duration:0ms}.DataWrapperChart-module_container__2eZ15{min-height:200px;background-color:rgba(0,0,0,.5)}.DataWrapperChart-module_container__2eZ15>iframe{width:100%;height:100%;position:relative;top:0}
@@ -1,7 +1,8 @@
1
- import { Text, frontend, useFile, useEditorSelection, useOnScreen, Image, InlineCaption, Video, useMediaSettings, useI18n } from 'pageflow-scrolled/frontend';
1
+ import { useContentElementConfigurationUpdate, useI18n, withShadowClassName, Text, EditableInlineText, frontend, useFile, useContentElementEditorState, ViewportDependentPillarBoxes, useContentElementLifecycle, Figure, Image, usePlayerState, MediaInteractionTracking, VideoPlayer, VideoPlayerControls, AudioPlayer, AudioPlayerControls, EditableText, useDarkBackground } from 'pageflow-scrolled/frontend';
2
2
  import React, { useRef, useState, useEffect } from 'react';
3
3
  import classNames from 'classnames';
4
4
  import ReactCompareImage from 'react-compare-image';
5
+ import { media } from 'pageflow/frontend';
5
6
  import ReactPlayer from 'react-player';
6
7
 
7
8
  function _defineProperty(obj, key, value) {
@@ -19,60 +20,89 @@ function _defineProperty(obj, key, value) {
19
20
  return obj;
20
21
  }
21
22
 
22
- function styleInject(css, ref) {
23
- if ( ref === void 0 ) ref = {};
24
- var insertAt = ref.insertAt;
23
+ var styles = {"root":"Heading-module_root__33TFw","first":"Heading-module_first__1PMJX"};
25
24
 
26
- if (!css || typeof document === 'undefined') { return; }
25
+ function Heading(_ref) {
26
+ var configuration = _ref.configuration,
27
+ sectionProps = _ref.sectionProps;
28
+ var level = configuration.level || sectionProps.sectionIndex;
29
+ var firstSectionInEntry = level === 0;
30
+ var updateConfiguration = useContentElementConfigurationUpdate();
31
+
32
+ var _useI18n = useI18n({
33
+ locale: 'ui'
34
+ }),
35
+ t = _useI18n.t;
27
36
 
28
- var head = document.head || document.getElementsByTagName('head')[0];
29
- var style = document.createElement('style');
30
- style.type = 'text/css';
37
+ var legacyValue = configuration.children;
38
+ return (
39
+ /*#__PURE__*/
40
+ React.createElement("h1", {
41
+ className: classNames(styles.root, _defineProperty({}, styles.first, firstSectionInEntry), _defineProperty({}, withShadowClassName, !sectionProps.invert))
42
+ },
43
+ /*#__PURE__*/
44
+ React.createElement(Text, {
45
+ scaleCategory: firstSectionInEntry ? 'h1' : 'h2',
46
+ inline: true
47
+ },
48
+ /*#__PURE__*/
49
+ React.createElement(EditableInlineText, {
50
+ value: configuration.value,
51
+ defaultValue: legacyValue,
52
+ placeholder: t('pageflow_scrolled.inline_editing.type_heading'),
53
+ onChange: function onChange(value) {
54
+ return updateConfiguration({
55
+ value: value
56
+ });
57
+ }
58
+ })))
59
+ );
60
+ }
31
61
 
32
- if (insertAt === 'top') {
33
- if (head.firstChild) {
34
- head.insertBefore(style, head.firstChild);
35
- } else {
36
- head.appendChild(style);
37
- }
38
- } else {
39
- head.appendChild(style);
40
- }
62
+ frontend.contentElementTypes.register('heading', {
63
+ component: Heading
64
+ });
41
65
 
42
- if (style.styleSheet) {
43
- style.styleSheet.cssText = css;
44
- } else {
45
- style.appendChild(document.createTextNode(css));
66
+ function ownKeys(object, enumerableOnly) {
67
+ var keys = Object.keys(object);
68
+
69
+ if (Object.getOwnPropertySymbols) {
70
+ var symbols = Object.getOwnPropertySymbols(object);
71
+ if (enumerableOnly) symbols = symbols.filter(function (sym) {
72
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
73
+ });
74
+ keys.push.apply(keys, symbols);
46
75
  }
76
+
77
+ return keys;
47
78
  }
48
79
 
49
- var css = ".Heading-module_root__33TFw {\n margin-top: 0.2em;\n margin-bottom: 0.5em;\n padding-top: 0.3em;\n}\n\n@media (orientation: landscape) {\n .Heading-module_first__1PMJX {\n padding-top: 25%;\n }\n}\n";
50
- var styles = {"root":"Heading-module_root__33TFw","first":"Heading-module_first__1PMJX"};
51
- styleInject(css);
80
+ function _objectSpread2(target) {
81
+ for (var i = 1; i < arguments.length; i++) {
82
+ var source = arguments[i] != null ? arguments[i] : {};
52
83
 
53
- function Heading(_ref) {
54
- var configuration = _ref.configuration;
55
- return React.createElement("h1", {
56
- className: classNames(styles.root, _defineProperty({}, styles.first, configuration.first))
57
- }, React.createElement(Text, {
58
- scaleCategory: configuration.first ? 'h1' : 'h2',
59
- inline: true
60
- }, configuration.children));
61
- }
84
+ if (i % 2) {
85
+ ownKeys(Object(source), true).forEach(function (key) {
86
+ _defineProperty(target, key, source[key]);
87
+ });
88
+ } else if (Object.getOwnPropertyDescriptors) {
89
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
90
+ } else {
91
+ ownKeys(Object(source)).forEach(function (key) {
92
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
93
+ });
94
+ }
95
+ }
62
96
 
63
- frontend.contentElementTypes.register('heading', {
64
- component: Heading
65
- });
97
+ return target;
98
+ }
66
99
 
67
100
  function _arrayWithHoles(arr) {
68
101
  if (Array.isArray(arr)) return arr;
69
102
  }
70
103
 
71
104
  function _iterableToArrayLimit(arr, i) {
72
- if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
73
- return;
74
- }
75
-
105
+ if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
76
106
  var _arr = [];
77
107
  var _n = true;
78
108
  var _d = false;
@@ -98,25 +128,47 @@ function _iterableToArrayLimit(arr, i) {
98
128
  return _arr;
99
129
  }
100
130
 
131
+ function _arrayLikeToArray(arr, len) {
132
+ if (len == null || len > arr.length) len = arr.length;
133
+
134
+ for (var i = 0, arr2 = new Array(len); i < len; i++) {
135
+ arr2[i] = arr[i];
136
+ }
137
+
138
+ return arr2;
139
+ }
140
+
141
+ function _unsupportedIterableToArray(o, minLen) {
142
+ if (!o) return;
143
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
144
+ var n = Object.prototype.toString.call(o).slice(8, -1);
145
+ if (n === "Object" && o.constructor) n = o.constructor.name;
146
+ if (n === "Map" || n === "Set") return Array.from(n);
147
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
148
+ }
149
+
101
150
  function _nonIterableRest() {
102
- throw new TypeError("Invalid attempt to destructure non-iterable instance");
151
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
103
152
  }
104
153
 
105
154
  function _slicedToArray(arr, i) {
106
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
155
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
107
156
  }
108
157
 
109
- var css$1 = ".BeforeAfter-module_sliderStart__2C5cN {\n background-color: white;\n position: absolute;\n z-index: 1;\n}\n\n.BeforeAfter-module_container__2Lm06 {\n /* slider default position: 50%, spacing around labels in\n react-compare-image: 5% each side, so default label max width\n should be 40%. This is only a fallback. We should receive widths\n from BeforeAfter.js */\n --default-label-max-width: 40%;\n /* label padding in react-compare-image is set to 20px left and right,\n so we need to subtract the sum from max width */\n --label-padding: 40px;\n --wiggle-animation: 1.5s cubic-bezier(.36,.07,.19,.97) both;\n --frame1pos: -8;\n --frame2pos: 16;\n --frame3pos: -32;\n --frame4pos: 32;\n --frame1px: calc(var(--frame1pos) * 1px);\n --frame2px: calc(var(--frame2pos) * 1px);\n --frame3px: calc(var(--frame3pos) * 1px);\n --frame4px: calc(var(--frame4pos) * 1px);\n --frame1percent: calc(var(--frame1pos) * 2.5%);\n --frame2percent: calc(var(--frame2pos) * 2.5%);\n --frame3percent: calc(var(--frame3pos) * 2.5%);\n --frame4percent: calc(var(--frame4pos) * 2.5%);\n /* in addition to the above variables, we receive --initial-rect-width\n from BeforeAfter.js, which has no sensible default value */\n}\n\n/* With react-compare-image 2.0.4 (commit 7410d14), this selects the\n slider */\n.BeforeAfter-module_container__2Lm06.BeforeAfter-module_wiggle__3nVSe div div:nth-child(3) {\n animation: BeforeAfter-module_SliderLeftRightShake__2mcn5 var(--wiggle-animation);\n}\n\n/* With react-compare-image 2.0.4 (commit 7410d14), this selects the\n before image */\n.BeforeAfter-module_container__2Lm06.BeforeAfter-module_wiggle__3nVSe div img:nth-child(2) {\n animation: BeforeAfter-module_BeforeImageLeftRightShake__38m9V var(--wiggle-animation);\n}\n\n/* With react-compare-image 2.0.4 (commit 7410d14), this selects the\n before label */\n.BeforeAfter-module_container__2Lm06 div div:nth-child(4) div {\n max-width: calc(var(--before-label-max-width, var(--default-label-max-width)) -\n var(--label-padding));\n}\n\n/* With react-compare-image 2.0.4 (commit 7410d14), this selects the\n after image */\n.BeforeAfter-module_container__2Lm06.BeforeAfter-module_wiggle__3nVSe div img:nth-child(1) {\n animation: BeforeAfter-module_AfterImageLeftRightShake__3WMf1 var(--wiggle-animation);\n}\n\n/* With react-compare-image 2.0.4 (commit 7410d14), this selects the\n after label */\n.BeforeAfter-module_container__2Lm06 div div:nth-child(5) div {\n max-width: calc(var(--after-label-max-width, var(--default-label-max-width)) -\n var(--label-padding));\n}\n\n@keyframes BeforeAfter-module_BeforeImageLeftRightShake__38m9V {\n 10%, 90% {\n clip: rect(auto, calc(var(--initial-rect-width) + var(--frame1px)), auto, auto);\n }\n\n 20%, 80% {\n clip: rect(auto, calc(var(--initial-rect-width) + var(--frame2px)), auto, auto);\n }\n\n 30%, 50%, 70% {\n clip: rect(auto, calc(var(--initial-rect-width) + var(--frame3px)), auto, auto);\n }\n\n 40%, 60% {\n clip: rect(auto, calc(var(--initial-rect-width) + var(--frame4px)), auto, auto);\n }\n}\n\n@keyframes BeforeAfter-module_AfterImageLeftRightShake__3WMf1 {\n 10%, 90% {\n clip: rect(auto, auto, auto, calc(var(--initial-rect-width) + var(--frame1px)));\n }\n\n 20%, 80% {\n clip: rect(auto, auto, auto, calc(var(--initial-rect-width) + var(--frame2px)));\n }\n\n 30%, 50%, 70% {\n clip: rect(auto, auto, auto, calc(var(--initial-rect-width) + var(--frame3px)));\n }\n\n 40%, 60% {\n clip: rect(auto, auto, auto, calc(var(--initial-rect-width) + var(--frame4px)));\n }\n}\n\n@keyframes BeforeAfter-module_SliderLeftRightShake__2mcn5 {\n 10%, 90% {\n transform: translate3d(var(--frame1percent), 0, 0);\n }\n\n 20%, 80% {\n transform: translate3d(var(--frame2percent), 0, 0);\n }\n\n 30%, 50%, 70% {\n transform: translate3d(var(--frame3percent), 0, 0);\n }\n\n 40%, 60% {\n transform: translate3d(var(--frame4percent), 0, 0);\n }\n}\n";
110
158
  var styles$1 = {"sliderStart":"BeforeAfter-module_sliderStart__2C5cN","container":"BeforeAfter-module_container__2Lm06","wiggle":"BeforeAfter-module_wiggle__3nVSe","SliderLeftRightShake":"BeforeAfter-module_SliderLeftRightShake__2mcn5","BeforeImageLeftRightShake":"BeforeAfter-module_BeforeImageLeftRightShake__38m9V","AfterImageLeftRightShake":"BeforeAfter-module_AfterImageLeftRightShake__3WMf1"};
111
- styleInject(css$1);
112
159
 
113
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
114
-
115
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
160
+ var placeholderForBeforeImage = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjQwIiBoZWlnaHQ9IjQwMyIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KIDwhLS0gQ3JlYXRlZCB3aXRoIE1ldGhvZCBEcmF3IC0gaHR0cDovL2dpdGh1Yi5jb20vZHVvcGl4ZWwvTWV0aG9kLURyYXcvIC0tPgogPGc+CiAgPHRpdGxlPmJhY2tncm91bmQ8L3RpdGxlPgogIDxyZWN0IGZpbGw9IiMzZDVhODAiIGlkPSJjYW52YXNfYmFja2dyb3VuZCIgaGVpZ2h0PSI0MDUiIHdpZHRoPSI2NDIiIHk9Ii0xIiB4PSItMSIvPgogIDxnIGRpc3BsYXk9Im5vbmUiIG92ZXJmbG93PSJ2aXNpYmxlIiB5PSIwIiB4PSIwIiBoZWlnaHQ9IjEwMCUiIHdpZHRoPSIxMDAlIiBpZD0iY2FudmFzR3JpZCI+CiAgIDxyZWN0IGZpbGw9InVybCgjZ3JpZHBhdHRlcm4pIiBzdHJva2Utd2lkdGg9IjAiIHk9IjAiIHg9IjAiIGhlaWdodD0iMTAwJSIgd2lkdGg9IjEwMCUiLz4KICA8L2c+CiA8L2c+CiA8Zz4KICA8dGl0bGU+TGF5ZXIgMTwvdGl0bGU+CiA8L2c+Cjwvc3ZnPg==';
161
+ var placeholderForAfterImage = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjQwIiBoZWlnaHQ9IjQwMyIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KIDwhLS0gQ3JlYXRlZCB3aXRoIE1ldGhvZCBEcmF3IC0gaHR0cDovL2dpdGh1Yi5jb20vZHVvcGl4ZWwvTWV0aG9kLURyYXcvIC0tPgogPGc+CiAgPHRpdGxlPmJhY2tncm91bmQ8L3RpdGxlPgogIDxyZWN0IGZpbGw9IiM5OGMxZDkiIGlkPSJjYW52YXNfYmFja2dyb3VuZCIgaGVpZ2h0PSI0MDUiIHdpZHRoPSI2NDIiIHk9Ii0xIiB4PSItMSIvPgogIDxnIGRpc3BsYXk9Im5vbmUiIG92ZXJmbG93PSJ2aXNpYmxlIiB5PSIwIiB4PSIwIiBoZWlnaHQ9IjEwMCUiIHdpZHRoPSIxMDAlIiBpZD0iY2FudmFzR3JpZCI+CiAgIDxyZWN0IGZpbGw9InVybCgjZ3JpZHBhdHRlcm4pIiBzdHJva2Utd2lkdGg9IjAiIHk9IjAiIHg9IjAiIGhlaWdodD0iMTAwJSIgd2lkdGg9IjEwMCUiLz4KICA8L2c+CiA8L2c+CiA8Zz4KICA8dGl0bGU+TGF5ZXIgMTwvdGl0bGU+CiA8L2c+Cjwvc3ZnPg==';
162
+ var placeholderFile = {
163
+ width: 640,
164
+ height: 403
165
+ };
116
166
  function BeforeAfter(_ref) {
117
167
  var _cx;
118
168
 
119
- var state = _ref.state,
169
+ var isActive = _ref.isActive,
170
+ isPrepared = _ref.isPrepared,
171
+ position = _ref.position,
120
172
  before_id = _ref.before_id,
121
173
  before_label = _ref.before_label,
122
174
  after_id = _ref.after_id,
@@ -124,8 +176,7 @@ function BeforeAfter(_ref) {
124
176
  initial_slider_position = _ref.initial_slider_position,
125
177
  slider = _ref.slider,
126
178
  slider_color = _ref.slider_color,
127
- slider_handle = _ref.slider_handle,
128
- contentElementId = _ref.contentElementId;
179
+ slider_handle = _ref.slider_handle;
129
180
  var beforeAfterRef = useRef();
130
181
  var current = beforeAfterRef.current;
131
182
 
@@ -145,13 +196,13 @@ function BeforeAfter(_ref) {
145
196
  if (node) {
146
197
  // Only wiggle once per element, when it is active for the first
147
198
  // time
148
- var shouldWiggle = !wiggled && state === 'active';
199
+ var shouldWiggle = !wiggled && isActive;
149
200
  setWiggle(shouldWiggle); // If wiggle was just set, mark this element as one that already
150
201
  // wiggled
151
202
 
152
203
  !wiggled && setWiggled(shouldWiggle);
153
204
  }
154
- }, [state, current]);
205
+ }, [isActive, current]);
155
206
  var beforeImage = useFile({
156
207
  collectionName: 'imageFiles',
157
208
  permaId: before_id
@@ -161,11 +212,8 @@ function BeforeAfter(_ref) {
161
212
  permaId: after_id
162
213
  });
163
214
 
164
- var _useEditorSelection = useEditorSelection({
165
- id: contentElementId,
166
- type: 'contentElement'
167
- }),
168
- isSelected = _useEditorSelection.isSelected;
215
+ var _useContentElementEdi = useContentElementEditorState(),
216
+ isSelected = _useContentElementEdi.isSelected;
169
217
 
170
218
  var beforeImageUrl = beforeImage && beforeImage.urls.large;
171
219
  var beforeImageAlt = beforeImage && beforeImage.configuration.alt;
@@ -176,59 +224,80 @@ function BeforeAfter(_ref) {
176
224
  // react-compare-image needs
177
225
 
178
226
  if (!slider) {
179
- opts = _objectSpread({}, opts, {
227
+ opts = _objectSpread2(_objectSpread2({}, opts), {}, {
180
228
  sliderLineWidth: 0,
181
- handle: React.createElement(React.Fragment, null)
229
+ handle:
230
+ /*#__PURE__*/
231
+ React.createElement(React.Fragment, null)
182
232
  });
183
233
  }
184
234
 
185
235
  if (slider) {
186
236
  if (!slider_handle) {
187
- opts = _objectSpread({}, opts, {
188
- handle: React.createElement(React.Fragment, null)
237
+ opts = _objectSpread2(_objectSpread2({}, opts), {}, {
238
+ handle:
239
+ /*#__PURE__*/
240
+ React.createElement(React.Fragment, null)
189
241
  });
190
242
  }
191
243
 
192
244
  if (slider_color) {
193
- opts = _objectSpread({}, opts, {
245
+ opts = _objectSpread2(_objectSpread2({}, opts), {}, {
194
246
  sliderLineColor: slider_color
195
247
  });
196
248
  }
197
- }
249
+ } //Since the slider wiggle only the first time, set the variable once for performance purpose.
198
250
 
199
- if (current) {
200
- // Size labels according to initial slider position. Unit is %,
201
- // left and right spacing is 5%, so we subtract 10. 90 = 100 - 10.
202
- var beforeLabelWidth = initial_slider_position - 10;
203
- var afterLabelWidth = 90 - initial_slider_position; // Compute initial slider coordinate and pass it as a CSS
204
- // variable, so that before/after images can wiggle together with
205
- // the slider
206
-
207
- var containerWidth = current.getBoundingClientRect().width;
208
- var initialRectWidth = initialSliderPos * containerWidth;
209
- current.style.setProperty('--before-label-max-width', beforeLabelWidth + '%');
210
- current.style.setProperty('--after-label-max-width', afterLabelWidth + '%');
211
- current.style.setProperty('--initial-rect-width', initialRectWidth + 'px');
212
- }
213
251
 
214
- return React.createElement("div", {
215
- ref: beforeAfterRef,
216
- className: classNames((_cx = {}, _defineProperty(_cx, styles$1.selected, isSelected), _defineProperty(_cx, styles$1.wiggle, wiggle), _cx), styles$1.container)
217
- }, React.createElement(InitialSliderPositionIndicator, {
218
- parentSelected: isSelected,
219
- position: initial_slider_position
220
- }), React.createElement(ReactCompareImage, Object.assign({
221
- leftImage: beforeImageUrl,
222
- rightImage: afterImageUrl,
223
- leftImageLabel: before_label,
224
- rightImageLabel: after_label,
225
- leftImageAlt: beforeImageAlt,
226
- rightImageAlt: afterImageAlt,
227
- sliderPositionPercentage: initialSliderPos,
228
- onSliderPositionChange: function onSliderPositionChange() {
229
- return setWiggle(false);
252
+ useEffect(function () {
253
+ if (beforeAfterRef.current) {
254
+ // Compute initial slider coordinate and pass it as a CSS
255
+ // variable, so that before/after images can wiggle together with
256
+ // the slider
257
+ var containerWidth = beforeAfterRef.current.getBoundingClientRect().width;
258
+ var initialRectWidth = initialSliderPos * containerWidth;
259
+ beforeAfterRef.current.style.setProperty('--initial-rect-width', initialRectWidth + 'px');
260
+ }
261
+ }, [wiggled, initialSliderPos]);
262
+ return (
263
+ /*#__PURE__*/
264
+ React.createElement(ViewportDependentPillarBoxes, {
265
+ file: beforeImage || afterImage || placeholderFile,
266
+ position: position
267
+ },
268
+ /*#__PURE__*/
269
+ React.createElement("div", {
270
+ ref: beforeAfterRef,
271
+ className: classNames((_cx = {}, _defineProperty(_cx, styles$1.selected, isSelected), _defineProperty(_cx, styles$1.wiggle, wiggle), _cx), styles$1.container)
272
+ },
273
+ /*#__PURE__*/
274
+ React.createElement(InitialSliderPositionIndicator, {
275
+ parentSelected: isSelected,
276
+ position: initial_slider_position
277
+ }), renderCompareImage()))
278
+ );
279
+
280
+ function renderCompareImage() {
281
+ if (!isPrepared) {
282
+ return null;
230
283
  }
231
- }, opts)));
284
+
285
+ return (
286
+ /*#__PURE__*/
287
+ React.createElement(ReactCompareImage, Object.assign({
288
+ leftImage: beforeImage ? beforeImageUrl : placeholderForBeforeImage,
289
+ rightImage: afterImage ? afterImageUrl : placeholderForAfterImage,
290
+ leftImageLabel: before_label,
291
+ rightImageLabel: after_label,
292
+ leftImageAlt: beforeImageAlt,
293
+ rightImageAlt: afterImageAlt,
294
+ sliderPositionPercentage: initialSliderPos,
295
+ onSliderPositionChange: function onSliderPositionChange() {
296
+ return setWiggle(false);
297
+ }
298
+ }, opts))
299
+ );
300
+ }
232
301
  }
233
302
 
234
303
  function InitialSliderPositionIndicator(_ref2) {
@@ -244,207 +313,395 @@ function InitialSliderPositionIndicator(_ref2) {
244
313
  }; // In case this element is selected, and its initial slider position
245
314
  // is not in the middle, we show InitialSliderPositionIndicator
246
315
 
247
- return parentSelected && position !== 50 ? React.createElement("div", {
316
+ return parentSelected && position !== 50 ?
317
+ /*#__PURE__*/
318
+ React.createElement("div", {
248
319
  className: styles$1.sliderStart,
249
320
  style: indicatorStyles
250
321
  }) : '';
251
322
  }
252
323
 
253
- var css$2 = ".InlineBeforeAfter-module_root__1f5oG {\n position: relative;\n margin: 0 auto;\n}\n";
254
- var styles$2 = {"root":"InlineBeforeAfter-module_root__1f5oG"};
255
- styleInject(css$2);
256
-
257
324
  function InlineBeforeAfter(props) {
258
- var ref = useRef();
259
- var onScreen = useOnScreen(ref, '-50% 0px -50% 0px');
260
- return React.createElement("div", {
261
- ref: ref,
262
- className: styles$2.root
263
- }, React.createElement(BeforeAfter, Object.assign({}, props.configuration, {
264
- state: onScreen ? 'active' : 'inactive',
265
- contentElementId: props.contentElementId
266
- })));
325
+ var _useContentElementLif = useContentElementLifecycle(),
326
+ isActive = _useContentElementLif.isActive,
327
+ isPrepared = _useContentElementLif.isPrepared;
328
+
329
+ return (
330
+ /*#__PURE__*/
331
+ React.createElement(BeforeAfter, Object.assign({}, props.configuration, {
332
+ isPrepared: isPrepared,
333
+ isActive: isActive
334
+ }))
335
+ );
267
336
  }
268
337
 
269
338
  frontend.contentElementTypes.register('inlineBeforeAfter', {
270
- component: InlineBeforeAfter
339
+ component: InlineBeforeAfter,
340
+ lifecycle: true
271
341
  });
272
342
 
273
- var css$3 = ".InlineImage-module_root__3edeH {\n position: relative;\n margin-top: 1em;\n}\n\n.InlineImage-module_container__30JBC {\n position: relative;\n margin-top: 1em;\n}\n\n.InlineImage-module_spacer__2yTJT {\n padding-top: 75%;\n}\n\n.InlineImage-module_inner__3WcPa {\n border: solid 2px #fff;\n position: absolute;\n top: 0;\n left: 0;\n bottom: 0;\n right: 0;\n}\n";
274
- var styles$3 = {"root":"InlineImage-module_root__3edeH","container":"InlineImage-module_container__30JBC","spacer":"InlineImage-module_spacer__2yTJT","inner":"InlineImage-module_inner__3WcPa"};
275
- styleInject(css$3);
276
-
277
343
  function InlineImage(_ref) {
278
344
  var configuration = _ref.configuration;
279
- return React.createElement("div", {
280
- className: classNames(styles$3.root)
281
- }, React.createElement("div", {
282
- className: styles$3.container
283
- }, React.createElement("div", {
284
- className: styles$3.spacer
285
- }, React.createElement("div", {
286
- className: styles$3.inner
287
- }, React.createElement(Image, configuration)))), React.createElement(InlineCaption, {
288
- text: configuration.caption
289
- }));
345
+
346
+ var _useContentElementLif = useContentElementLifecycle(),
347
+ isPrepared = _useContentElementLif.isPrepared;
348
+
349
+ var imageFile = useFile({
350
+ collectionName: 'imageFiles',
351
+ permaId: configuration.id
352
+ });
353
+ return (
354
+ /*#__PURE__*/
355
+ React.createElement(Figure, {
356
+ caption: configuration.caption
357
+ },
358
+ /*#__PURE__*/
359
+ React.createElement(ViewportDependentPillarBoxes, {
360
+ file: imageFile,
361
+ aspectRatio: imageFile ? undefined : 0.75,
362
+ position: configuration.position,
363
+ opaque: !!configuration.caption
364
+ },
365
+ /*#__PURE__*/
366
+ React.createElement(Image, Object.assign({}, configuration, {
367
+ isPrepared: isPrepared,
368
+ structuredData: true,
369
+ variant: configuration.position === 'full' ? 'large' : 'medium'
370
+ }))))
371
+ );
290
372
  }
291
373
 
292
374
  frontend.contentElementTypes.register('inlineImage', {
293
- component: InlineImage
375
+ component: InlineImage,
376
+ lifecycle: true
294
377
  });
295
378
 
296
- var css$4 = ".InlineVideo-module_root__26uiY {\n position: relative;\n max-height: 98vh;\n}\n\n.InlineVideo-module_inner__3n7y4 {\n position: absolute;\n top: 0;\n left: 0;\n bottom: 0;\n right: 0;\n}\n\n/* Timeline in native video controls is hidden in Storybook to prevent\n Percy from detecting different loading progress as visual\n change. See .storybook/preview-head.html file. */\n";
297
- var styles$4 = {"root":"InlineVideo-module_root__26uiY","inner":"InlineVideo-module_inner__3n7y4"};
298
- styleInject(css$4);
299
-
300
379
  function InlineVideo(_ref) {
301
- var configuration = _ref.configuration;
302
- var ref = useRef();
303
- var onScreen = useOnScreen(ref, '-50% 0px -50% 0px');
304
- return React.createElement("div", {
305
- ref: ref,
306
- className: classNames(styles$4.root)
307
- }, React.createElement("div", {
308
- style: {
309
- paddingTop: configuration.wideFormat ? '41.15%' : '56.25%'
380
+ var sectionProps = _ref.sectionProps,
381
+ configuration = _ref.configuration;
382
+
383
+ var _usePlayerState = usePlayerState(),
384
+ _usePlayerState2 = _slicedToArray(_usePlayerState, 2),
385
+ playerState = _usePlayerState2[0],
386
+ playerActions = _usePlayerState2[1];
387
+
388
+ var _useContentElementEdi = useContentElementEditorState(),
389
+ isEditable = _useContentElementEdi.isEditable,
390
+ isSelected = _useContentElementEdi.isSelected;
391
+
392
+ var _useContentElementLif = useContentElementLifecycle({
393
+ onActivate: function onActivate() {
394
+ if (configuration.autoplay) {
395
+ playerActions.play();
396
+ }
397
+ },
398
+ onDeactivate: function onDeactivate() {
399
+ playerActions.fadeOutAndPause(400);
400
+ }
401
+ }),
402
+ isPrepared = _useContentElementLif.isPrepared;
403
+
404
+ var onPlayerClick = function onPlayerClick() {
405
+ if (isEditable && !isSelected) {
406
+ return;
407
+ }
408
+
409
+ if (!playerState.shouldPlay || media.muted) {
410
+ playerActions.playBlessed();
411
+ } else {
412
+ playerActions.pause();
310
413
  }
311
- }, React.createElement("div", {
312
- className: styles$4.inner
313
- }, React.createElement(Video, Object.assign({}, configuration, {
314
- state: onScreen ? 'active' : 'inactive',
315
- interactive: true
316
- })))));
414
+ };
415
+
416
+ return (
417
+ /*#__PURE__*/
418
+ React.createElement(Figure, {
419
+ caption: configuration.caption
420
+ },
421
+ /*#__PURE__*/
422
+ React.createElement(MediaInteractionTracking, {
423
+ playerState: playerState,
424
+ playerActions: playerActions
425
+ },
426
+ /*#__PURE__*/
427
+ React.createElement(VideoPlayer, {
428
+ isPrepared: isPrepared,
429
+ position: configuration.position,
430
+ controls: configuration.controls,
431
+ playerState: playerState,
432
+ playerActions: playerActions,
433
+ id: configuration.id,
434
+ posterId: configuration.posterId,
435
+ defaultTextTrackFilePermaId: configuration.defaultTextTrackFileId,
436
+ quality: 'high',
437
+ playsInline: true,
438
+ atmoDuringPlayback: configuration.atmoDuringPlayback,
439
+ onClick: onPlayerClick
440
+ }),
441
+ /*#__PURE__*/
442
+ React.createElement(VideoPlayerControls, {
443
+ videoFilePermaId: configuration.id,
444
+ defaultTextTrackFilePermaId: configuration.defaultTextTrackFileId,
445
+ playerState: playerState,
446
+ playerActions: playerActions,
447
+ configuration: configuration,
448
+ sectionProps: sectionProps
449
+ })))
450
+ );
317
451
  }
318
452
 
319
453
  frontend.contentElementTypes.register('inlineVideo', {
320
- component: InlineVideo
454
+ component: InlineVideo,
455
+ lifecycle: true
321
456
  });
322
457
 
323
- var css$5 = ".SoundDisclaimer-module_soundDisclaimer__31hWh {\n text-align: center;\n border: 1px solid white;\n border-radius: 4px;\n cursor: pointer;\n font-size: inherit;\n}\n\n.SoundDisclaimer-module_soundDisclaimer__31hWh:hover {\n background: rgba(255, 255, 255, 0.25);\n}";
324
- var styles$5 = {"soundDisclaimer":"SoundDisclaimer-module_soundDisclaimer__31hWh"};
325
- styleInject(css$5);
458
+ function InlineAudio(_ref) {
459
+ var sectionProps = _ref.sectionProps,
460
+ configuration = _ref.configuration;
326
461
 
327
- function SoundDisclaimer() {
328
- var mediaSettings = useMediaSettings();
462
+ var _usePlayerState = usePlayerState(),
463
+ _usePlayerState2 = _slicedToArray(_usePlayerState, 2),
464
+ playerState = _usePlayerState2[0],
465
+ playerActions = _usePlayerState2[1];
329
466
 
330
- var _useI18n = useI18n(),
331
- t = _useI18n.t;
467
+ var _useContentElementEdi = useContentElementEditorState(),
468
+ isEditable = _useContentElementEdi.isEditable,
469
+ isSelected = _useContentElementEdi.isSelected;
332
470
 
333
- return React.createElement("div", {
334
- className: classNames(styles$5.soundDisclaimer),
335
- onClick: function onClick() {
336
- return mediaSettings.setMuted(false);
471
+ var _useContentElementLif = useContentElementLifecycle({
472
+ onActivate: function onActivate() {
473
+ if (configuration.autoplay && !media.muted) {
474
+ playerActions.play();
475
+ }
476
+ },
477
+ onDeactivate: function onDeactivate() {
478
+ playerActions.pause();
337
479
  }
338
- }, React.createElement("p", {
339
- dangerouslySetInnerHTML: {
340
- __html: t('pageflow_scrolled.public.sound_disclaimer.help_text')
480
+ }),
481
+ isPrepared = _useContentElementLif.isPrepared;
482
+
483
+ var onPlayerClick = function onPlayerClick() {
484
+ if (isEditable && !isSelected) {
485
+ return;
341
486
  }
342
- }));
487
+
488
+ if (playerState.shouldPlay) {
489
+ playerActions.pause();
490
+ } else {
491
+ playerActions.playBlessed();
492
+ }
493
+ };
494
+
495
+ return (
496
+ /*#__PURE__*/
497
+ React.createElement(Figure, {
498
+ caption: configuration.caption
499
+ },
500
+ /*#__PURE__*/
501
+ React.createElement(AudioPlayer, {
502
+ isPrepared: isPrepared,
503
+ position: configuration.position,
504
+ controls: configuration.controls,
505
+ playerState: playerState,
506
+ playerActions: playerActions,
507
+ id: configuration.id,
508
+ posterId: configuration.posterId,
509
+ defaultTextTrackFilePermaId: configuration.defaultTextTrackFileId,
510
+ quality: 'high',
511
+ playsInline: true,
512
+ atmoDuringPlayback: configuration.atmoDuringPlayback,
513
+ onClick: onPlayerClick
514
+ }),
515
+ /*#__PURE__*/
516
+ React.createElement(AudioPlayerControls, {
517
+ audioFilePermaId: configuration.id,
518
+ defaultTextTrackFilePermaId: configuration.defaultTextTrackFileId,
519
+ playerState: playerState,
520
+ playerActions: playerActions,
521
+ configuration: configuration,
522
+ sectionProps: sectionProps
523
+ }))
524
+ );
525
+ }
526
+
527
+ frontend.contentElementTypes.register('inlineAudio', {
528
+ component: InlineAudio,
529
+ lifecycle: true
530
+ });
531
+
532
+ var styles$2 = {"soundDisclaimer":"SoundDisclaimer-module_soundDisclaimer__31hWh"};
533
+
534
+ function SoundDisclaimer() {
535
+ var _useI18n = useI18n(),
536
+ t = _useI18n.t;
537
+
538
+ return (
539
+ /*#__PURE__*/
540
+ React.createElement("div", {
541
+ className: classNames(styles$2.soundDisclaimer),
542
+ onClick: function onClick() {
543
+ return media.mute(false);
544
+ }
545
+ },
546
+ /*#__PURE__*/
547
+ React.createElement("p", {
548
+ dangerouslySetInnerHTML: {
549
+ __html: t('pageflow_scrolled.public.sound_disclaimer.help_text')
550
+ }
551
+ }))
552
+ );
343
553
  }
344
554
 
345
555
  frontend.contentElementTypes.register('soundDisclaimer', {
346
556
  component: SoundDisclaimer
347
557
  });
348
558
 
349
- var css$6 = ".TextBlock-module_text__21Hk4 {\n padding: 0;\n margin: 1em 0;\n text-shadow: none;\n}\n\n.TextBlock-module_dummy__2KicI {\n opacity: 0.7;\n}\n\n.TextBlock-module_text__21Hk4 a {\n color: #fff;\n word-wrap: break-word;\n}\n\n.TextBlock-module_text__21Hk4 ol,\n.TextBlock-module_text__21Hk4 ul {\n padding-left: 20px;\n}\n";
350
- var styles$6 = {"text":"TextBlock-module_text__21Hk4","dummy":"TextBlock-module_dummy__2KicI"};
351
- styleInject(css$6);
559
+ var styles$3 = {"text":"TextBlock-module_text__21Hk4"};
352
560
 
353
- function TextBlock(_ref) {
354
- var configuration = _ref.configuration;
355
- return React.createElement(Text, {
356
- scaleCategory: "body"
357
- }, React.createElement("div", {
358
- className: classNames(styles$6.text, _defineProperty({}, styles$6.dummy, configuration.dummy)),
359
- dangerouslySetInnerHTML: {
360
- __html: configuration.children
361
- }
362
- }));
561
+ function TextBlock(props) {
562
+ var updateConfiguration = useContentElementConfigurationUpdate();
563
+
564
+ var _useI18n = useI18n({
565
+ locale: 'ui'
566
+ }),
567
+ t = _useI18n.t;
568
+
569
+ return (
570
+ /*#__PURE__*/
571
+ React.createElement("div", {
572
+ className: styles$3.text
573
+ },
574
+ /*#__PURE__*/
575
+ React.createElement(EditableText, {
576
+ value: props.configuration.value,
577
+ contentElementId: props.contentElementId,
578
+ placeholder: t('pageflow_scrolled.inline_editing.type_text'),
579
+ onChange: function onChange(value) {
580
+ return updateConfiguration({
581
+ value: value
582
+ });
583
+ }
584
+ }))
585
+ );
363
586
  }
364
587
 
365
588
  frontend.contentElementTypes.register('textBlock', {
366
- component: TextBlock
589
+ component: TextBlock,
590
+ customSelectionRect: true
367
591
  });
368
592
 
369
- var css$7 = ".VideoEmbed-module_VideoEmbed__3BUjc {\n margin-bottom: 15px;\n}\n\n.VideoEmbed-module_embedWrapper__1kG8A {\n overflow:hidden;\n position:relative;\n background: black;\n padding-top: 56.25%;\n}\n\n.VideoEmbed-module_wide__1IwOr {\n padding-top: 56.25%;\n}\n\n.VideoEmbed-module_narrow__2jLxH {\n padding-top: 75%;\n}\n\n.VideoEmbed-module_square__2ljo8 {\n padding-top: 100%;\n}\n\n.VideoEmbed-module_portrait__1ttPj {\n padding-top: 177.77%;\n}\n\n.VideoEmbed-module_embedPlayer__54NKG {\n position: absolute;\n top: 0;\n left: 0;\n bottom: 0;\n right: 0;\n}\n";
370
- var styles$7 = {"VideoEmbed":"VideoEmbed-module_VideoEmbed__3BUjc","embedWrapper":"VideoEmbed-module_embedWrapper__1kG8A","wide":"VideoEmbed-module_wide__1IwOr","narrow":"VideoEmbed-module_narrow__2jLxH","square":"VideoEmbed-module_square__2ljo8","portrait":"VideoEmbed-module_portrait__1ttPj","embedPlayer":"VideoEmbed-module_embedPlayer__54NKG"};
371
- styleInject(css$7);
593
+ var styles$4 = {"VideoEmbed":"VideoEmbed-module_VideoEmbed__3BUjc","embedPlayer":"VideoEmbed-module_embedPlayer__54NKG"};
372
594
 
595
+ var aspectRatios = {
596
+ wide: 0.5625,
597
+ narrow: 0.75,
598
+ square: 1,
599
+ portrait: 1.7777
600
+ };
373
601
  function VideoEmbed(_ref) {
374
602
  var configuration = _ref.configuration;
375
603
 
376
- // base64-encoded configuration
604
+ var _useContentElementLif = useContentElementLifecycle(),
605
+ isPrepared = _useContentElementLif.isPrepared;
606
+
607
+ var _useContentElementEdi = useContentElementEditorState(),
608
+ isEditable = _useContentElementEdi.isEditable,
609
+ isSelected = _useContentElementEdi.isSelected; // base64-encoded configuration
377
610
  // => make component re-render on configuration changes
611
+
612
+
378
613
  function keyFromConfiguration(config) {
379
614
  return btoa(JSON.stringify(config));
380
615
  }
381
616
 
382
- return React.createElement("div", {
383
- className: styles$7.VideoEmbed
384
- }, React.createElement("div", {
385
- className: classNames(styles$7.embedWrapper, styles$7[configuration.aspectRatio])
386
- }, React.createElement(ReactPlayer, {
387
- className: styles$7.embedPlayer,
388
- key: keyFromConfiguration(configuration),
389
- url: configuration.videoSource,
390
- playing: true,
391
- light: true,
392
- width: "100%",
393
- height: "100%",
394
- controls: !configuration.hideControls,
395
- config: {
396
- youtube: {
397
- playerVars: {
398
- showinfo: !configuration.hideInfo
399
- }
400
- },
401
- vimeo: {
402
- playerOptions: {
403
- byline: !configuration.hideInfo
617
+ function renderPlayer() {
618
+ if (!isPrepared) {
619
+ return null;
620
+ }
621
+
622
+ return (
623
+ /*#__PURE__*/
624
+ React.createElement(ReactPlayer, {
625
+ className: styles$4.embedPlayer,
626
+ key: keyFromConfiguration(configuration),
627
+ url: configuration.videoSource,
628
+ playing: true,
629
+ light: true,
630
+ width: "100%",
631
+ height: "100%",
632
+ controls: !configuration.hideControls,
633
+ config: {
634
+ youtube: {
635
+ playerVars: {
636
+ showinfo: !configuration.hideInfo
637
+ }
638
+ },
639
+ vimeo: {
640
+ playerOptions: {
641
+ byline: !configuration.hideInfo
642
+ }
643
+ }
404
644
  }
645
+ })
646
+ );
647
+ }
648
+
649
+ return (
650
+ /*#__PURE__*/
651
+ React.createElement("div", {
652
+ className: styles$4.VideoEmbed,
653
+ style: {
654
+ pointerEvents: isEditable && !isSelected ? 'none' : undefined
405
655
  }
406
- }
407
- })), React.createElement(InlineCaption, {
408
- text: configuration.caption
409
- }));
656
+ },
657
+ /*#__PURE__*/
658
+ React.createElement(Figure, {
659
+ caption: configuration.caption
660
+ },
661
+ /*#__PURE__*/
662
+ React.createElement(ViewportDependentPillarBoxes, {
663
+ aspectRatio: aspectRatios[configuration.aspectRatio || 'wide'],
664
+ position: configuration.position,
665
+ opaque: !!configuration.caption
666
+ }, renderPlayer())))
667
+ );
410
668
  }
411
669
 
412
670
  frontend.contentElementTypes.register('videoEmbed', {
413
- component: VideoEmbed
671
+ component: VideoEmbed,
672
+ lifecycle: true
414
673
  });
415
674
 
416
- var css$8 = "\n.ExternalLink-module_hidden__3jer0 {\n display: none;\n}\n\n.ExternalLink-module_link_item__Blypv {\n width: 45%;\n max-width: 45%;\n vertical-align: top;\n margin: 2% auto;\n background-color: #fff; \n color: rgba(20,20,20,0.8);\n text-decoration: none;\n transition: 0.3s;\n}\n\n\n.ExternalLink-module_link_item__Blypv.ExternalLink-module_invert__1zrgN {\n background-color: rgba(20,20,20,0.8);;\n color: #fff;\n}\n\n.ExternalLink-module_link_item__Blypv.ExternalLink-module_layout_center__3NRpQ {\n width: 29%;\n max-width: 29%;\n \n}\n\n.ExternalLink-module_link_item__Blypv:hover {\n background-color: #141414;\n color: #fff;\n -webkit-transform: scale(1.05);\n -moz-transform: scale(1.05);\n -ms-transform: scale(1.05);\n -o-transform: scale(1.05);\n transform: scale(1.05);\n}\n\n.ExternalLink-module_link_item__Blypv:hover .ExternalLink-module_link_title__FZJ-0 {\n text-decoration: underline;\n}\n\n.ExternalLink-module_link_thumbnail__2_BHq {\n width: auto;\n background-repeat: no-repeat;\n background-size: cover;\n padding-top: 56.25%;\n position: relative;\n\n}\n\n.ExternalLink-module_link_details__lRhKU {\n margin: 20px;\n}\n\n.ExternalLink-module_link_details__lRhKU > .ExternalLink-module_link_title__FZJ-0 {\n font-size: 1.2em;\n font-weight: bold;\n margin-bottom: 20px;\n}\n\n.ExternalLink-module_link_details__lRhKU > .ExternalLink-module_link_desc__3fSe1 {\n\n}\n\n.ExternalLink-module_link_details__lRhKU > p {\n width: 100%;\n white-space: normal;\n line-height: 1.3em;\n}\n\n.ExternalLink-module_tooltip__18MpC {\n position: absolute;\n left: 50%;\n top: 80px;\n width: 180px;\n padding: 5px;\n margin-left: -95px;\n background-color: #444;\n color: #fff;\n border: solid 1px #fff;\n opacity: 0.9;\n font-size: 13px;\n text-align: center;\n white-space: normal;\n}\n\n.ExternalLink-module_tooltip__18MpC > span {\n display: block;\n color: #fff;\n text-decoration: underline;\n}";
417
- var styles$8 = {"hidden":"ExternalLink-module_hidden__3jer0","link_item":"ExternalLink-module_link_item__Blypv","invert":"ExternalLink-module_invert__1zrgN","layout_center":"ExternalLink-module_layout_center__3NRpQ","link_title":"ExternalLink-module_link_title__FZJ-0","link_thumbnail":"ExternalLink-module_link_thumbnail__2_BHq","link_details":"ExternalLink-module_link_details__lRhKU","link_desc":"ExternalLink-module_link_desc__3fSe1","tooltip":"ExternalLink-module_tooltip__18MpC"};
418
- styleInject(css$8);
675
+ var styles$5 = {"hidden":"ExternalLink-module_hidden__3jer0","link_item":"ExternalLink-module_link_item__Blypv","invert":"ExternalLink-module_invert__1zrgN","layout_center":"ExternalLink-module_layout_center__3NRpQ","link_title":"ExternalLink-module_link_title__FZJ-0","link_thumbnail":"ExternalLink-module_link_thumbnail__2_BHq","link_details":"ExternalLink-module_link_details__lRhKU","link_desc":"ExternalLink-module_link_desc__3fSe1","tooltip":"ExternalLink-module_tooltip__18MpC"};
419
676
 
420
677
  function ExternalLink(props) {
421
- var _classNames;
678
+ var _classNames2;
422
679
 
423
680
  var _useState = useState(true),
424
681
  _useState2 = _slicedToArray(_useState, 2),
425
682
  hideTooltip = _useState2[0],
426
683
  setHideTooltip = _useState2[1];
427
684
 
428
- var _props$sectionProps = props.sectionProps,
429
- layout = _props$sectionProps.layout,
430
- invert = _props$sectionProps.invert;
685
+ var layout = props.sectionProps.layout;
431
686
 
432
- var _useI18n = useI18n(),
687
+ var _useI18n = useI18n({
688
+ locale: 'ui'
689
+ }),
433
690
  t = _useI18n.t;
434
691
 
435
- var isInEditor = function isInEditor() {
436
- return window.frameElement != undefined && window.location.pathname.includes('/editor/entries/');
437
- };
438
-
439
- var onTooltipClick = function onTooltipClick() {
440
- window.open(props.url, '_blank');
441
- setHideTooltip(true);
442
- };
692
+ var _useContentElementEdi = useContentElementEditorState(),
693
+ isEditable = _useContentElementEdi.isEditable,
694
+ isSelected = _useContentElementEdi.isSelected;
443
695
 
444
696
  var onClick = function onClick(event) {
445
- if (props.open_in_new_tab == false && isInEditor()) {
446
- setHideTooltip(false);
447
- event.preventDefault();
697
+ if (isEditable) {
698
+ if (!props.open_in_new_tab || !isSelected) {
699
+ event.preventDefault();
700
+ }
701
+
702
+ if (!props.open_in_new_tab && isSelected) {
703
+ setHideTooltip(false);
704
+ }
448
705
  }
449
706
  };
450
707
 
@@ -452,82 +709,170 @@ function ExternalLink(props) {
452
709
  setHideTooltip(true);
453
710
  };
454
711
 
455
- return React.createElement("a", {
456
- className: classNames(styles$8.link_item, (_classNames = {}, _defineProperty(_classNames, styles$8.invert, invert), _defineProperty(_classNames, styles$8.layout_center, layout == 'center'), _classNames)),
457
- href: props.url || '',
458
- onClick: onClick,
459
- onMouseLeave: onMouseLeave,
460
- target: props.open_in_new_tab == '1' ? '_blank' : '_self'
461
- }, React.createElement("div", {
462
- className: styles$8.link_thumbnail
463
- }, React.createElement(Image, {
464
- id: props.thumbnail
465
- })), React.createElement("div", {
466
- className: styles$8.link_details
467
- }, React.createElement("p", {
468
- className: styles$8.link_title
469
- }, props.title), React.createElement("p", {
470
- className: styles$8.link_desc,
471
- dangerouslySetInnerHTML: {
472
- __html: props.description
712
+ function renderNewTabTooltip() {
713
+ if (isEditable) {
714
+ var onTooltipClick = function onTooltipClick() {
715
+ window.open(props.url, '_blank');
716
+ setHideTooltip(true);
717
+ };
718
+
719
+ return (
720
+ /*#__PURE__*/
721
+ React.createElement("div", {
722
+ className: classNames(_defineProperty({}, styles$5.hidden, hideTooltip), styles$5.tooltip),
723
+ onClick: onTooltipClick
724
+ }, t('pageflow_scrolled.inline_editing.external_links.open_in_new_tab_message'),
725
+ /*#__PURE__*/
726
+ React.createElement("span", null, t('pageflow_scrolled.inline_editing.external_links.open_in_new_tab')))
727
+ );
473
728
  }
474
- })), React.createElement("div", {
475
- className: classNames(_defineProperty({}, styles$8.hidden, hideTooltip), styles$8.tooltip),
476
- onClick: onTooltipClick
477
- }, t('pageflow_scrolled.public.external_link.open_in_new_tab_message'), React.createElement("span", {
478
- target: "_blank"
479
- }, t('pageflow_scrolled.public.external_link.open_in_new_tab'))));
729
+ }
730
+
731
+ return (
732
+ /*#__PURE__*/
733
+ React.createElement("a", {
734
+ className: classNames(styles$5.link_item, (_classNames2 = {}, _defineProperty(_classNames2, styles$5.invert, props.invert), _defineProperty(_classNames2, styles$5.layout_center, layout === 'center'), _classNames2)),
735
+ href: props.url || 'about:blank',
736
+ onClick: onClick,
737
+ onMouseLeave: onMouseLeave,
738
+ target: props.open_in_new_tab ? '_blank' : '_self'
739
+ },
740
+ /*#__PURE__*/
741
+ React.createElement("div", {
742
+ className: styles$5.link_thumbnail
743
+ },
744
+ /*#__PURE__*/
745
+ React.createElement(Image, {
746
+ id: props.thumbnail,
747
+ isPrepared: props.isPrepared,
748
+ variant: "linkThumbnailLarge"
749
+ })),
750
+ /*#__PURE__*/
751
+ React.createElement("div", {
752
+ className: styles$5.link_details
753
+ },
754
+ /*#__PURE__*/
755
+ React.createElement("p", {
756
+ className: styles$5.link_title
757
+ }, props.title),
758
+ /*#__PURE__*/
759
+ React.createElement("p", {
760
+ className: styles$5.link_desc
761
+ }, props.description)), renderNewTabTooltip())
762
+ );
480
763
  }
481
764
 
482
- var css$9 = ".ExternalLinkList-module_ext_links_container__16IIo{\n display: flex;\n flex-wrap: wrap;\n border-collapse: separate;\n border-spacing: 10px;\n min-height: 240px;\n width: auto;\n height: auto;\n pointer-events: all;\n position: relative;\n -webkit-transition: opacity 0.5s;\n -moz-transition: opacity 0.5s;\n transition: opacity 0.5s;\n transition-timing-function: cubic-bezier(0.1, 0.57, 0.1, 1);\n transition-duration: 0ms;\n}\n";
483
- var styles$9 = {"ext_links_container":"ExternalLinkList-module_ext_links_container__16IIo"};
484
- styleInject(css$9);
765
+ var styles$6 = {"ext_links_container":"ExternalLinkList-module_ext_links_container__16IIo"};
485
766
 
486
767
  function ExternalLinkList(props) {
487
768
  var linkList = props.configuration.links || [];
488
- return React.createElement("div", {
489
- className: styles$9.ext_links_container
490
- }, linkList.map(function (link, index) {
491
- return React.createElement(ExternalLink, Object.assign({}, link, {
492
- key: link.id,
493
- sectionProps: props.sectionProps
494
- }));
495
- }));
769
+
770
+ var _useContentElementLif = useContentElementLifecycle(),
771
+ isPrepared = _useContentElementLif.isPrepared;
772
+
773
+ var darkBackground = useDarkBackground();
774
+ return (
775
+ /*#__PURE__*/
776
+ React.createElement("div", {
777
+ className: styles$6.ext_links_container
778
+ }, linkList.map(function (link, index) {
779
+ return (
780
+ /*#__PURE__*/
781
+ React.createElement(ExternalLink, Object.assign({}, link, {
782
+ key: link.id,
783
+ invert: !darkBackground,
784
+ sectionProps: props.sectionProps,
785
+ isPrepared: isPrepared
786
+ }))
787
+ );
788
+ }))
789
+ );
496
790
  }
497
791
 
498
792
  frontend.contentElementTypes.register('externalLinkList', {
499
- component: ExternalLinkList
793
+ component: ExternalLinkList,
794
+ lifecycle: true
500
795
  });
501
796
 
502
- var css$a = ".DataWrapperChart-module_container__2eZ15 {\n min-height: 200px;\n height: 400px;\n}\n\n.DataWrapperChart-module_container__2eZ15 > iframe {\n width: 100%;\n height: 100%;\n position: relative;\n top: 0;\n}";
503
- var styles$a = {"container":"DataWrapperChart-module_container__2eZ15"};
504
- styleInject(css$a);
797
+ function useIframeHeight(url) {
798
+ var _useState = useState('400px'),
799
+ _useState2 = _slicedToArray(_useState, 2),
800
+ height = _useState2[0],
801
+ setHeight = _useState2[1];
802
+
803
+ useEffect(function () {
804
+ window.addEventListener('message', receive);
805
+
806
+ function receive(event) {
807
+ if (typeof event.data['datawrapper-height'] !== 'undefined') {
808
+ for (var chartId in event.data['datawrapper-height']) {
809
+ if (url.indexOf(chartId) > -1) {
810
+ setHeight(event.data['datawrapper-height'][chartId] + 'px');
811
+ }
812
+ }
813
+ }
814
+ }
815
+
816
+ return function () {
817
+ return window.removeEventListener('message', receive);
818
+ };
819
+ }, [url]);
820
+ return height;
821
+ }
822
+
823
+ var styles$7 = {"container":"DataWrapperChart-module_container__2eZ15"};
505
824
 
506
825
  function DataWrapperChart(_ref) {
507
826
  var configuration = _ref.configuration;
508
- var ref = useRef();
509
- var onScreen = useOnScreen(ref, '25% 0px 25% 0px'); // remove url protocol, so that it is selected by the browser itself
827
+
828
+ var _useContentElementLif = useContentElementLifecycle(),
829
+ isPrepared = _useContentElementLif.isPrepared;
830
+
831
+ var _useContentElementEdi = useContentElementEditorState(),
832
+ isEditable = _useContentElementEdi.isEditable,
833
+ isSelected = _useContentElementEdi.isSelected;
834
+
835
+ var height = useIframeHeight(configuration.url); // remove url protocol, so that it is selected by the browser itself
510
836
 
511
837
  var srcURL = '';
512
838
 
513
- if (configuration.url && onScreen) {
839
+ if (configuration.url && isPrepared) {
514
840
  srcURL = configuration.url.replace(/http(s|):/, '');
515
841
  }
516
842
 
517
- return React.createElement("div", {
518
- ref: ref,
519
- className: styles$a.container
520
- }, React.createElement("iframe", {
521
- src: srcURL,
522
- scrolling: "auto",
523
- frameBorder: "0",
524
- align: "aus",
525
- allowFullScreen: true,
526
- mozallowfullscreen: "true",
527
- webkitallowfullscreen: "true"
528
- }));
843
+ return (
844
+ /*#__PURE__*/
845
+ React.createElement("div", {
846
+ className: styles$7.container,
847
+ style: {
848
+ pointerEvents: isEditable && !isSelected ? 'none' : undefined,
849
+ height: height
850
+ },
851
+ "data-percy": "hide"
852
+ }, renderIframe(srcURL))
853
+ );
854
+ }
855
+
856
+ function renderIframe(url) {
857
+ if (!url) {
858
+ return null;
859
+ }
860
+
861
+ return (
862
+ /*#__PURE__*/
863
+ React.createElement("iframe", {
864
+ src: url,
865
+ scrolling: "auto",
866
+ frameBorder: "0",
867
+ align: "aus",
868
+ allowFullScreen: true,
869
+ mozallowfullscreen: "true",
870
+ webkitallowfullscreen: "true"
871
+ })
872
+ );
529
873
  }
530
874
 
531
875
  frontend.contentElementTypes.register('dataWrapperChart', {
532
- component: DataWrapperChart
876
+ component: DataWrapperChart,
877
+ lifecycle: true
533
878
  });