pageflow 15.1.2 → 15.4.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 (205) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +160 -190
  3. data/README.md +3 -5
  4. data/admins/pageflow/accounts.rb +13 -35
  5. data/admins/pageflow/entry.rb +21 -1
  6. data/admins/pageflow/entry_templates.rb +140 -0
  7. data/admins/pageflow/membership.rb +12 -0
  8. data/admins/pageflow/user.rb +5 -3
  9. data/app/assets/javascripts/pageflow/admin/accounts.js +3 -3
  10. data/app/assets/javascripts/pageflow/admin/entries.js +65 -0
  11. data/app/assets/javascripts/pageflow/admin/users.js +1 -1
  12. data/app/assets/javascripts/pageflow/asset_urls.js.erb +1 -0
  13. data/app/assets/javascripts/pageflow/base.js +0 -12
  14. data/app/assets/javascripts/pageflow/components.js +2 -6
  15. data/app/assets/javascripts/pageflow/dist/ui.js +155 -46
  16. data/app/assets/javascripts/pageflow/vendor.js +12 -10
  17. data/app/assets/stylesheets/pageflow/base.scss +0 -7
  18. data/app/assets/stylesheets/pageflow/editor/base.scss +5 -2
  19. data/app/assets/stylesheets/pageflow/editor/composables.scss +5 -1
  20. data/app/assets/stylesheets/pageflow/editor/drop_down_button.scss +1 -1
  21. data/app/assets/stylesheets/pageflow/editor/emulation_mode_button.scss +44 -55
  22. data/app/assets/stylesheets/pageflow/editor/help.scss +2 -2
  23. data/app/assets/stylesheets/pageflow/editor/select_button.scss +1 -1
  24. data/app/assets/stylesheets/pageflow/editor/sidebar_footer.scss +1 -1
  25. data/app/assets/stylesheets/pageflow/entries.scss +1 -1
  26. data/app/assets/stylesheets/pageflow/loading_spinner.scss +4 -1
  27. data/app/assets/stylesheets/pageflow/navigation_mobile.scss +4 -4
  28. data/app/assets/stylesheets/pageflow/themes/default/anchors.scss +1 -1
  29. data/app/assets/stylesheets/pageflow/themes/default/logo/variant/background_image.scss +4 -0
  30. data/app/assets/stylesheets/pageflow/themes/default/logo/variant/watermark.scss +6 -1
  31. data/app/assets/stylesheets/pageflow/themes/default/page/anchors.scss +1 -1
  32. data/app/assets/stylesheets/pageflow/themes/default/player_controls/classic/control_bar.scss +1 -1
  33. data/app/assets/stylesheets/pageflow/themes/default/player_controls/classic/info_box.scss +1 -1
  34. data/app/assets/stylesheets/pageflow/themes/default/player_controls/shared/menu_bar.scss +2 -2
  35. data/app/assets/stylesheets/pageflow/themes/default/player_controls/slim/control_bar.scss +2 -2
  36. data/app/assets/stylesheets/pageflow/themes/default/player_controls/slim/info_box.scss +1 -1
  37. data/app/assets/stylesheets/pageflow/themes/default/player_controls/slim/quality_menu.scss +2 -2
  38. data/app/assets/stylesheets/pageflow/themes/default/player_controls/waveform/wave.scss +1 -1
  39. data/app/assets/stylesheets/pageflow/ui/forms.scss +9 -2
  40. data/app/assets/stylesheets/pageflow/ui/input/extended_select_input.scss +2 -2
  41. data/app/assets/stylesheets/pageflow/ui/tooltip.scss +17 -3
  42. data/app/controllers/pageflow/editor/widgets_controller.rb +1 -1
  43. data/app/helpers/pageflow/admin/entries_helper.rb +16 -0
  44. data/app/helpers/pageflow/pages_helper.rb +1 -0
  45. data/app/helpers/pageflow/structured_data_helper.rb +0 -2
  46. data/app/models/pageflow/account.rb +26 -0
  47. data/app/models/pageflow/account_role_query.rb +1 -1
  48. data/app/models/pageflow/entry.rb +16 -2
  49. data/app/models/pageflow/entry_duplicate.rb +1 -0
  50. data/app/models/pageflow/entry_template.rb +69 -0
  51. data/app/models/pageflow/managed_user_query.rb +1 -1
  52. data/app/models/pageflow/revision.rb +1 -1
  53. data/app/models/pageflow/theming.rb +8 -47
  54. data/app/policies/pageflow/account_policy.rb +10 -0
  55. data/app/policies/pageflow/entry_template_policy.rb +22 -0
  56. data/app/policies/pageflow/folder_policy.rb +2 -2
  57. data/app/policies/pageflow/membership_policy.rb +2 -2
  58. data/app/policies/pageflow/theming_policy.rb +2 -6
  59. data/app/policies/pageflow/user_policy.rb +1 -1
  60. data/app/views/admin/accounts/_configuration_label.html.erb +5 -0
  61. data/app/views/admin/accounts/_entry_template_details.html.arb +19 -0
  62. data/app/views/admin/accounts/_form.html.erb +5 -31
  63. data/app/views/admin/accounts/_share_providers_label.html.erb +5 -0
  64. data/app/views/admin/accounts/_theming_details.html.arb +0 -12
  65. data/app/views/admin/entries/_attributes_table.html.arb +5 -0
  66. data/app/views/admin/entries/_not_allowed_to_see_entry_types.json.jbuilder +2 -0
  67. data/app/views/admin/entries/entry_types.json.jbuilder +4 -0
  68. data/app/views/admin/entry_templates/_form.html.erb +58 -0
  69. data/app/views/admin/users/_not_allowed_to_see_user_quota.html.erb +3 -0
  70. data/app/views/components/pageflow/admin/entry_templates_tab.rb +48 -0
  71. data/app/views/pageflow/admin/users/_quota_exhausted.html.erb +1 -1
  72. data/app/views/pageflow/themes/_theme.json.jbuilder +1 -0
  73. data/app/views/pageflow/video_files/_video_file.json.jbuilder +8 -1
  74. data/config/initializers/admin_resource_tabs.rb +5 -0
  75. data/config/initializers/help_entries.rb +1 -5
  76. data/config/locales/de.yml +100 -162
  77. data/config/locales/en.yml +91 -150
  78. data/db/migrate/20200122115400_create_pageflow_entry_templates.rb +75 -0
  79. data/db/migrate/20200206134400_convert_legacy_scrolled_content_element_types.rb +48 -0
  80. data/db/migrate/20200515112500_add_constraints_to_entry_templates.rb +21 -0
  81. data/db/migrate/20200807135200_rename_pageflow_entry_template_entry_type_to_entry_type_name.rb +7 -0
  82. data/entry_types/paged/app/assets/javascripts/pageflow_paged/components.js +7 -0
  83. data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/editor.js +1541 -1357
  84. data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/frontend.js +9245 -0
  85. data/{app/assets/javascripts/pageflow → entry_types/paged/app/assets/javascripts/pageflow_paged}/dist/react-client.js +1 -1
  86. data/{app/assets/javascripts/pageflow → entry_types/paged/app/assets/javascripts/pageflow_paged}/dist/react-server.js +3 -3
  87. data/entry_types/paged/app/assets/javascripts/pageflow_paged/frontend.js +6 -0
  88. data/entry_types/paged/app/assets/javascripts/pageflow_paged/server_rendering.js +9 -0
  89. data/entry_types/paged/app/assets/javascripts/pageflow_paged/vendor.js +9 -0
  90. data/entry_types/paged/app/assets/javascripts/pageflow_paged/videojs.js +6 -0
  91. data/entry_types/paged/app/controllers/pageflow_paged/application_controller.rb +2 -2
  92. data/{app/helpers/pageflow → entry_types/paged/app/helpers/pageflow_paged}/page_background_asset_helper.rb +4 -3
  93. data/{app/helpers/pageflow → entry_types/paged/app/helpers/pageflow_paged}/react_server_side_rendering_helper.rb +23 -2
  94. data/entry_types/paged/app/views/layouts/pageflow_paged/_loading_spinner_inline_script.html.erb +1 -0
  95. data/entry_types/paged/app/views/layouts/pageflow_paged/application.html.erb +3 -3
  96. data/entry_types/paged/app/views/pageflow_paged/editor/entries/_head.html.erb +4 -2
  97. data/entry_types/paged/app/views/pageflow_paged/entries/_entry.html.erb +1 -1
  98. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/page_background_asset/_element.html.erb +0 -0
  99. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/react/_widget.html.erb +0 -0
  100. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/react/page.html.erb +0 -0
  101. data/entry_types/paged/config/initializers/features.rb +1 -1
  102. data/entry_types/paged/config/initializers/help_entries.rb +17 -0
  103. data/entry_types/paged/config/locales/new/help.de.yml +162 -0
  104. data/entry_types/paged/config/locales/new/help.en.yml +153 -0
  105. data/entry_types/paged/lib/pageflow_paged/engine.rb +13 -0
  106. data/entry_types/paged/lib/pageflow_paged/plugin.rb +5 -1
  107. data/entry_types/paged/lib/pageflow_paged/react.rb +12 -0
  108. data/{lib/pageflow → entry_types/paged/lib/pageflow_paged}/react/page_type.rb +2 -2
  109. data/{lib/pageflow → entry_types/paged/lib/pageflow_paged}/react/widget_type.rb +2 -2
  110. data/entry_types/paged/lib/tasks/pageflow_paged_tasks.rake +7 -0
  111. data/entry_types/paged/vendor/assets/javascripts/development/pageflow_paged/vendor/react-server.js +20613 -0
  112. data/entry_types/paged/vendor/assets/javascripts/development/pageflow_paged/vendor/react.js +21495 -0
  113. data/{vendor/assets/javascripts → entry_types/paged/vendor/assets/javascripts/pageflow_paged/vendor}/dash.all.min.js +0 -0
  114. data/{vendor/assets/javascripts → entry_types/paged/vendor/assets/javascripts/pageflow_paged/vendor}/videojs-dash.js +0 -0
  115. data/{vendor/assets/javascripts → entry_types/paged/vendor/assets/javascripts/pageflow_paged/vendor}/videojs.js +0 -0
  116. data/entry_types/paged/vendor/assets/javascripts/production/pageflow_paged/vendor/react-server.js +24 -0
  117. data/entry_types/paged/vendor/assets/javascripts/production/pageflow_paged/vendor/react.js +24 -0
  118. data/entry_types/scrolled/app/assets/javascripts/pageflow_scrolled/legacy.js +0 -0
  119. data/entry_types/scrolled/app/controllers/pageflow_scrolled/editor/chapters_controller.rb +2 -2
  120. data/entry_types/scrolled/app/controllers/pageflow_scrolled/editor/content_elements_controller.rb +15 -4
  121. data/entry_types/scrolled/app/controllers/pageflow_scrolled/editor/sections_controller.rb +2 -2
  122. data/entry_types/scrolled/app/controllers/pageflow_scrolled/entries_controller.rb +10 -0
  123. data/entry_types/scrolled/app/helpers/pageflow_scrolled/editor/seed_html_helper.rb +11 -1
  124. data/entry_types/scrolled/app/helpers/pageflow_scrolled/entry_json_seed_helper.rb +4 -1
  125. data/entry_types/scrolled/app/helpers/pageflow_scrolled/favicon_helper.rb +21 -0
  126. data/entry_types/scrolled/app/helpers/pageflow_scrolled/i18n_helper.rb +35 -0
  127. data/entry_types/scrolled/app/helpers/pageflow_scrolled/react_server_side_rendering_helper.rb +40 -0
  128. data/entry_types/scrolled/app/helpers/pageflow_scrolled/themes_helper.rb +8 -0
  129. data/entry_types/scrolled/app/models/pageflow_scrolled/content_element.rb +38 -0
  130. data/entry_types/scrolled/app/views/pageflow_scrolled/editor/content_elements/batch.json.jbuilder +2 -0
  131. data/entry_types/scrolled/app/views/pageflow_scrolled/editor/entries/_head.html.erb +1 -7
  132. data/entry_types/scrolled/app/views/pageflow_scrolled/editor/entries/_seed.json.jbuilder +1 -1
  133. data/entry_types/scrolled/app/views/pageflow_scrolled/entries/show.html.erb +36 -10
  134. data/entry_types/scrolled/app/views/pageflow_scrolled/entry_json_seed/_entry.json.jbuilder +13 -1
  135. data/entry_types/scrolled/app/views/pageflow_scrolled/entry_json_seed/_theme.json.jbuilder +8 -0
  136. data/entry_types/scrolled/app/views/pageflow_scrolled/favicons/_entry.html.erb +10 -0
  137. data/entry_types/scrolled/config/initializers/help_entries.rb +16 -0
  138. data/entry_types/scrolled/config/locales/de.yml +655 -0
  139. data/entry_types/scrolled/config/locales/en.yml +522 -0
  140. data/entry_types/scrolled/config/routes.rb +1 -0
  141. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/install_generator.rb +36 -0
  142. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/android-chrome-192x192.png +0 -0
  143. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/android-chrome-512x512.png +0 -0
  144. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/apple-touch-icon.png +0 -0
  145. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/browserconfig.xml +9 -0
  146. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/favicon-16x16.png +0 -0
  147. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/favicon-32x32.png +0 -0
  148. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/favicon.ico +0 -0
  149. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/mstile-150x150.png +0 -0
  150. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/safari-pinned-tab.svg +46 -0
  151. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/site.webmanifest +19 -0
  152. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/logoDesktop.svg +56 -0
  153. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/logoMobile.svg +22 -0
  154. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/unmute.mp3 +0 -0
  155. data/entry_types/scrolled/lib/pageflow_scrolled/engine.rb +4 -0
  156. data/entry_types/scrolled/lib/pageflow_scrolled/plugin.rb +3 -1
  157. data/entry_types/scrolled/lib/pageflow_scrolled/seeds.rb +93 -28
  158. data/entry_types/scrolled/lib/tasks/pageflow_scrolled_tasks.rake +134 -0
  159. data/entry_types/scrolled/package/contentElements-editor.js +482 -0
  160. data/entry_types/scrolled/package/contentElements-frontend.css +1 -0
  161. data/entry_types/scrolled/package/contentElements-frontend.js +1112 -0
  162. data/entry_types/scrolled/package/editor.js +3066 -2579
  163. data/entry_types/scrolled/package/frontend-server.js +228 -0
  164. data/entry_types/scrolled/package/frontend/EditableText-43c50894.js +2161 -0
  165. data/entry_types/scrolled/package/frontend/Wavesurfer-b88b02e0.js +375 -0
  166. data/entry_types/scrolled/package/frontend/components-3ead1b4a.js +2533 -0
  167. data/entry_types/scrolled/package/frontend/getPrototypeOf-63c7c8e8.js +86 -0
  168. data/entry_types/scrolled/package/frontend/index.css +9 -0
  169. data/entry_types/scrolled/package/frontend/index.js +5507 -0
  170. data/entry_types/scrolled/package/package.json +40 -7
  171. data/entry_types/scrolled/spec/fixtures/audio.m4a +0 -0
  172. data/entry_types/scrolled/spec/fixtures/video.mp4 +0 -0
  173. data/lib/generators/pageflow/initializer/templates/pageflow.rb +21 -9
  174. data/lib/pageflow/ability_mixin.rb +15 -2
  175. data/lib/pageflow/configuration.rb +6 -5
  176. data/lib/pageflow/entry_type_configuration.rb +1 -0
  177. data/lib/pageflow/global_config_api.rb +5 -4
  178. data/lib/pageflow/react.rb +4 -2
  179. data/lib/pageflow/seeds.rb +0 -2
  180. data/lib/pageflow/theme.rb +4 -0
  181. data/lib/pageflow/themes.rb +9 -1
  182. data/lib/pageflow/version.rb +1 -1
  183. data/{packages/pageflow → package}/config/jest/index.js +8 -3
  184. data/{packages/pageflow → package}/config/jest/transformers/jst.js +1 -1
  185. data/{packages/pageflow → package}/config/jest/transformers/upwardBabel.js +0 -0
  186. data/{packages/pageflow → package}/config/webpack.js +7 -1
  187. data/{packages/pageflow → package}/editor.js +493 -1122
  188. data/package/frontend.js +2542 -0
  189. data/{packages/pageflow → package}/package.json +5 -1
  190. data/package/testHelpers.js +732 -0
  191. data/{packages/pageflow → package}/ui.js +155 -46
  192. data/spec/factories/accounts.rb +9 -1
  193. data/spec/factories/entry_templates.rb +9 -0
  194. data/spec/factories/published_entries.rb +8 -1
  195. data/spec/factories/themings.rb +0 -1
  196. metadata +94 -33
  197. data/app/assets/javascripts/pageflow/dist/editor.js +0 -11890
  198. data/app/assets/javascripts/pageflow/dist/frontend.js +0 -5798
  199. data/app/assets/javascripts/pageflow/videojs.js +0 -6
  200. data/config/initializers/entry_types.rb +0 -4
  201. data/entry_types/scrolled/config/locales/new/de.yml +0 -46
  202. data/entry_types/scrolled/config/locales/new/en.yml +0 -46
  203. data/entry_types/scrolled/package/frontend.js +0 -3404
  204. data/packages/pageflow/config/jest/transformers/cssModules.js +0 -1
  205. data/packages/pageflow/testHelpers.js +0 -268
@@ -0,0 +1,375 @@
1
+ import React, { Component } from 'react';
2
+ import { b as _inherits, a as _classCallCheck, e as _assertThisInitialized, _ as _createClass, c as _getPrototypeOf, d as _possibleConstructorReturn } from './getPrototypeOf-63c7c8e8.js';
3
+ import Measure from 'react-measure';
4
+ import assign from 'deep-assign';
5
+ import WaveSurfer from 'wavesurfer.js';
6
+
7
+ function _createSuper(Derived) {
8
+ function isNativeReflectConstruct() {
9
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
10
+ if (Reflect.construct.sham) return false;
11
+ if (typeof Proxy === "function") return true;
12
+
13
+ try {
14
+ Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
15
+ return true;
16
+ } catch (e) {
17
+ return false;
18
+ }
19
+ }
20
+
21
+ return function () {
22
+ var Super = _getPrototypeOf(Derived),
23
+ result;
24
+
25
+ if (isNativeReflectConstruct()) {
26
+ var NewTarget = _getPrototypeOf(this).constructor;
27
+
28
+ result = Reflect.construct(Super, arguments, NewTarget);
29
+ } else {
30
+ result = Super.apply(this, arguments);
31
+ }
32
+
33
+ return _possibleConstructorReturn(this, result);
34
+ };
35
+ }
36
+ var EVENTS = ['audioprocess', 'error', 'finish', 'loading', 'mouseup', 'pause', 'play', 'ready', 'scroll', 'seek', 'zoom'];
37
+
38
+ function capitaliseFirstLetter(string) {
39
+ return string.split('-').map(function (part) {
40
+ return part.charAt(0).toUpperCase() + part.slice(1);
41
+ }).join('');
42
+ }
43
+
44
+ var Wavesurfer =
45
+ /*#__PURE__*/
46
+ function (_Component) {
47
+ _inherits(Wavesurfer, _Component);
48
+
49
+ var _super = _createSuper(Wavesurfer);
50
+
51
+ function Wavesurfer(props) {
52
+ var _this;
53
+
54
+ _classCallCheck(this, Wavesurfer);
55
+
56
+ _this = _super.call(this, props);
57
+ _this.state = {
58
+ isReady: false
59
+ };
60
+
61
+ if (typeof WaveSurfer === undefined) {
62
+ throw new Error('WaveSurfer is undefined!');
63
+ }
64
+
65
+ _this._wavesurfer = Object.create(WaveSurfer);
66
+ _this._loadMediaElt = _this._loadMediaElt.bind(_assertThisInitialized(_this));
67
+ _this._loadAudio = _this._loadAudio.bind(_assertThisInitialized(_this));
68
+ _this._seekTo = _this._seekTo.bind(_assertThisInitialized(_this));
69
+
70
+ _this._handleResize = function () {
71
+ if (_this.state.isReady) {
72
+ _this._wavesurfer.refresh();
73
+ }
74
+ };
75
+
76
+ return _this;
77
+ }
78
+
79
+ _createClass(Wavesurfer, [{
80
+ key: "componentDidMount",
81
+ value: function componentDidMount() {
82
+ var _this2 = this;
83
+
84
+ var options = assign({}, this.props.options, {
85
+ container: this.wavesurferEl
86
+ }); // media element loading is only supported by MediaElement backend
87
+
88
+ if (this.props.mediaElt) {
89
+ options.backend = 'MediaElement';
90
+ }
91
+
92
+ this._wavesurfer.init(options); // file was loaded, wave was drawn
93
+
94
+
95
+ this._wavesurfer.on('ready', function () {
96
+ _this2.setState({
97
+ isReady: true,
98
+ pos: _this2.props.pos
99
+ }); // set initial position
100
+
101
+
102
+ if (_this2.props.pos) {
103
+ _this2._seekTo(_this2.props.pos);
104
+ } // set initial volume
105
+
106
+
107
+ if (_this2.props.volume != null) {
108
+ _this2._wavesurfer.setVolume(_this2.props.volume);
109
+ } // set initial playing state
110
+
111
+
112
+ if (_this2.props.playing) {
113
+ _this2.wavesurfer.play();
114
+ } // set initial zoom
115
+
116
+
117
+ if (_this2.props.zoom) {
118
+ _this2._wavesurfer.zoom(_this2.props.zoom);
119
+ }
120
+ });
121
+
122
+ this._wavesurfer.on('audioprocess', function (pos) {
123
+ _this2.setState({
124
+ pos: pos
125
+ });
126
+
127
+ _this2.props.onPosChange({
128
+ wavesurfer: _this2._wavesurfer,
129
+ originalArgs: [pos]
130
+ });
131
+ }); // `audioprocess` is not fired when seeking, so we have to plug into the
132
+ // `seek` event and calculate the equivalent in seconds (seek event
133
+ // receives a position float 0-1) – See the README.md for explanation why we
134
+ // need this
135
+
136
+
137
+ this._wavesurfer.on('seek', function (pos) {
138
+ var formattedPos = _this2._posToSec(pos);
139
+
140
+ _this2.setState({
141
+ formattedPos: formattedPos
142
+ });
143
+
144
+ _this2.props.onPosChange({
145
+ wavesurfer: _this2._wavesurfer,
146
+ originalArgs: [formattedPos]
147
+ });
148
+ }); // hook up events to callback handlers passed in as props
149
+
150
+
151
+ EVENTS.forEach(function (e) {
152
+ var propCallback = _this2.props["on".concat(capitaliseFirstLetter(e))];
153
+
154
+ var wavesurfer = _this2._wavesurfer;
155
+
156
+ if (propCallback) {
157
+ _this2._wavesurfer.on(e, function () {
158
+ for (var _len = arguments.length, originalArgs = new Array(_len), _key = 0; _key < _len; _key++) {
159
+ originalArgs[_key] = arguments[_key];
160
+ }
161
+
162
+ propCallback({
163
+ wavesurfer: wavesurfer,
164
+ originalArgs: originalArgs
165
+ });
166
+ });
167
+ }
168
+ }); // if audioFile prop, load file
169
+
170
+ if (this.props.audioFile) {
171
+ this._loadAudio(this.props.audioFile, this.props.audioPeaks);
172
+ } // if mediaElt prop, load media Element
173
+
174
+
175
+ if (this.props.mediaElt) {
176
+ this._loadMediaElt(this.props.mediaElt, this.props.audioPeaks);
177
+ }
178
+ } // update wavesurfer rendering manually
179
+
180
+ }, {
181
+ key: "componentDidUpdate",
182
+ value: function componentDidUpdate(prevProps) {
183
+ // update audioFile
184
+ if (this.props.audioFile !== this.props.audioFile) {
185
+ this._loadAudio(this.props.audioFile, this.props.audioPeaks);
186
+ } // update mediaElt
187
+
188
+
189
+ if (prevProps.mediaElt !== this.props.mediaElt) {
190
+ this._loadMediaElt(this.props.mediaElt, this.props.audioPeaks);
191
+ } // update peaks
192
+
193
+
194
+ if (prevProps.audioPeaks !== this.props.audioPeaks) {
195
+ if (this.props.mediaElt) {
196
+ this._loadMediaElt(prevProps.mediaElt, this.props.audioPeaks);
197
+ } else {
198
+ this._loadAudio(this.props.audioFile, this.props.audioPeaks);
199
+ }
200
+ } // update position
201
+
202
+
203
+ if (this.props.pos && this.state.isReady && prevProps.pos !== this.props.pos && this.props.pos !== this.state.pos) {
204
+ this._seekTo(this.props.pos);
205
+ } // update playing state
206
+
207
+
208
+ if (this.props.playing !== prevProps.playing) {
209
+ if (this.props.playing) {
210
+ this._wavesurfer.play();
211
+ } else {
212
+ this._wavesurfer.pause();
213
+ }
214
+ } // update volume
215
+
216
+
217
+ if (this.props.volume !== prevProps.volume) {
218
+ this._wavesurfer.setVolume(this.props.volume);
219
+ } // update volume
220
+
221
+
222
+ if (this.props.zoom !== prevProps.zoom) {
223
+ this._wavesurfer.zoom(this.props.zoom);
224
+ } // update audioRate
225
+
226
+
227
+ if (this.props.options.audioRate !== prevProps.options.audioRate) {
228
+ this._wavesurfer.setPlaybackRate(this.props.options.audioRate);
229
+ }
230
+
231
+ if (prevProps.options.waveColor !== this.props.options.waveColor) {
232
+ this._wavesurfer.setWaveColor(this.props.options.waveColor);
233
+ }
234
+
235
+ if (prevProps.options.progressColor !== this.props.options.progressColor) {
236
+ this._wavesurfer.setProgressColor(this.props.options.progressColor);
237
+ }
238
+
239
+ if (prevProps.options.cursorColor !== this.props.options.cursorColor) {
240
+ this._wavesurfer.setCursorColor(this.props.options.cursorColor);
241
+ }
242
+
243
+ if (prevProps.options.height !== this.props.options.height) {
244
+ this._wavesurfer.setHeight(this.props.options.height);
245
+ }
246
+ }
247
+ }, {
248
+ key: "componentWillUnmount",
249
+ value: function componentWillUnmount() {
250
+ var _this3 = this;
251
+
252
+ // remove listeners
253
+ EVENTS.forEach(function (e) {
254
+ _this3._wavesurfer.un(e);
255
+ }); // destroy wavesurfer instance
256
+
257
+ this._wavesurfer.destroy();
258
+ } // receives seconds and transforms this to the position as a float 0-1
259
+
260
+ }, {
261
+ key: "_secToPos",
262
+ value: function _secToPos(sec) {
263
+ return 1 / this._wavesurfer.getDuration() * sec;
264
+ } // receives position as a float 0-1 and transforms this to seconds
265
+
266
+ }, {
267
+ key: "_posToSec",
268
+ value: function _posToSec(pos) {
269
+ return pos * this._wavesurfer.getDuration();
270
+ } // pos is in seconds, the 0-1 proportional position we calculate here …
271
+
272
+ }, {
273
+ key: "_seekTo",
274
+ value: function _seekTo(sec) {
275
+ var pos = this._secToPos(sec);
276
+
277
+ if (this.props.options.autoCenter) {
278
+ this._wavesurfer.seekAndCenter(pos);
279
+ } else {
280
+ this._wavesurfer.seekTo(pos);
281
+ }
282
+ } // load a media element selector or HTML element
283
+ // if selector, get the HTML element for it
284
+ // and pass to _loadAudio
285
+
286
+ }, {
287
+ key: "_loadMediaElt",
288
+ value: function _loadMediaElt(selectorOrElt, audioPeaks) {
289
+ if (selectorOrElt instanceof global.HTMLElement) {
290
+ this._loadAudio(selectorOrElt, audioPeaks);
291
+ } else {
292
+ // Ignore if media element cannot be found. There are edge cases
293
+ // where React already unmounted the corresponding media element,
294
+ // but the parent Waveform component still holds the old media
295
+ // element id.
296
+ if (global.document.querySelector(selectorOrElt)) {
297
+ this._loadAudio(global.document.querySelector(selectorOrElt), audioPeaks);
298
+ }
299
+ }
300
+ } // pass audio data to wavesurfer
301
+
302
+ }, {
303
+ key: "_loadAudio",
304
+ value: function _loadAudio(audioFileOrElt, audioPeaks) {
305
+ if (audioFileOrElt instanceof global.HTMLElement) {
306
+ // media element
307
+ this._wavesurfer.loadMediaElement(audioFileOrElt, audioPeaks);
308
+ } else if (typeof audioFileOrElt === 'string') {
309
+ // bog-standard string is handled by load method and ajax call
310
+ this._wavesurfer.load(audioFileOrElt, audioPeaks);
311
+ } else if (audioFileOrElt instanceof global.Blob || audioFileOrElt instanceof global.File) {
312
+ // blob or file is loaded with loadBlob method
313
+ this._wavesurfer.loadBlob(audioFileOrElt, audioPeaks);
314
+ } else {
315
+ throw new Error("Wavesurfer._loadAudio expects prop audioFile\n to be either HTMLElement, string or file/blob");
316
+ }
317
+ }
318
+ }, {
319
+ key: "_measureIfResponsive",
320
+ value: function _measureIfResponsive(children) {
321
+ if (this.props.responsive) {
322
+ return (
323
+ /*#__PURE__*/
324
+ React.createElement(Measure, {
325
+ client: true,
326
+ onResize: this._handleResize
327
+ }, function (_ref) {
328
+ var measureRef = _ref.measureRef;
329
+ return (
330
+ /*#__PURE__*/
331
+ React.createElement("div", {
332
+ ref: measureRef
333
+ }, children)
334
+ );
335
+ })
336
+ );
337
+ }
338
+
339
+ return children;
340
+ }
341
+ }, {
342
+ key: "render",
343
+ value: function render() {
344
+ var _this4 = this;
345
+
346
+ var childrenWithProps = this.props.children ? React.Children.map(this.props.children, function (child) {
347
+ return React.cloneElement(child, {
348
+ wavesurfer: _this4._wavesurfer,
349
+ isReady: _this4.state.isReady
350
+ });
351
+ }) : false;
352
+ return this._measureIfResponsive(
353
+ /*#__PURE__*/
354
+ React.createElement("div", null,
355
+ /*#__PURE__*/
356
+ React.createElement("div", {
357
+ ref: function ref(c) {
358
+ _this4.wavesurferEl = c;
359
+ }
360
+ }), childrenWithProps));
361
+ }
362
+ }]);
363
+
364
+ return Wavesurfer;
365
+ }(Component);
366
+
367
+ Wavesurfer.defaultProps = {
368
+ playing: false,
369
+ pos: 0,
370
+ options: WaveSurfer.defaultParams,
371
+ responsive: true,
372
+ onPosChange: function onPosChange() {}
373
+ };
374
+
375
+ export default Wavesurfer;
@@ -0,0 +1,2533 @@
1
+ import React, { useMemo, useState, useCallback, useContext, useRef, useEffect, createContext, useLayoutEffect, memo } from 'react';
2
+ import { _ as _slicedToArray, R as ContentElementEditorCommandEmitterContext, t as usePostMessageListener, A as useEntryStateDispatch, a as _defineProperty, b as _objectWithoutProperties, u as useI18n, U as MotifAreaVisibilityProvider, V as ForcePaddingContext, W as updateContentElementConfiguration, X as ContentElementConfigurationUpdateContext, Y as ContentElementEditorStateContext, G as api, J as useContentElementEditorState, Z as LayoutWithoutInlineEditing, $ as renderElement, a0 as renderLeaf, m as _objectSpread2, y as _toConsumableArray, I as useContentElementEditorCommandSubscription, T as Text$1, P as PhonePlatformContext } from './EditableText-43c50894.js';
3
+ import classNames from 'classnames';
4
+ import 'use-context-selector';
5
+ import 'reselect';
6
+ import 'i18n-js';
7
+ import 'slugify';
8
+ import './getPrototypeOf-63c7c8e8.js';
9
+ import BackboneEvents from 'backbone-events-standalone';
10
+ import { DndProvider, useDrop, useDrag } from 'react-dnd';
11
+ import { HTML5Backend } from 'react-dnd-html5-backend';
12
+ import { Range, Editor, Transforms, Text, Node, Path, createEditor } from 'slate';
13
+ import { useSlate, ReactEditor, withReact, Slate, Editable } from 'slate-react';
14
+ import debounce from 'debounce';
15
+
16
+ var Context = React.createContext({});
17
+ function EditorStateProvider(props) {
18
+ var _useState = useState(null),
19
+ _useState2 = _slicedToArray(_useState, 2),
20
+ selection = _useState2[0],
21
+ setSelectionState = _useState2[1];
22
+
23
+ var setSelection = useCallback(function (selection) {
24
+ if (window.parent !== window) {
25
+ window.parent.postMessage({
26
+ type: 'SELECTED',
27
+ payload: selection || {}
28
+ }, window.location.origin);
29
+ }
30
+
31
+ setSelectionState(selection);
32
+ }, []);
33
+ var value = useMemo(function () {
34
+ return {
35
+ selection: selection,
36
+ setSelection: setSelection
37
+ };
38
+ }, [setSelection, selection]);
39
+ return (
40
+ /*#__PURE__*/
41
+ React.createElement(Context.Provider, {
42
+ value: value
43
+ }, props.children)
44
+ );
45
+ }
46
+ function useEditorSelection(options) {
47
+ var _useContext = useContext(Context),
48
+ selection = _useContext.selection,
49
+ setSelection = _useContext.setSelection;
50
+
51
+ var resetSelection = useCallback(function () {
52
+ setSelection(null);
53
+ }, [setSelection]);
54
+ var select = useCallback(function (selection) {
55
+ setSelection(selection || options);
56
+ }, [setSelection, options]);
57
+ return useMemo(function () {
58
+ return setSelection ? {
59
+ isSelected: selection && options && selection.id === options.id && selection.type === options.type,
60
+ select: select,
61
+ resetSelection: resetSelection
62
+ } : {};
63
+ }, [options, selection, setSelection, select, resetSelection]);
64
+ }
65
+
66
+ function useContentElementEditorCommandEmitter() {
67
+ return useMemo(function () {
68
+ return Object.assign({}, BackboneEvents);
69
+ }, []);
70
+ }
71
+ function ContentElementEditorCommandSubscriptionProvider(_ref) {
72
+ var emitter = _ref.emitter,
73
+ children = _ref.children;
74
+ return (
75
+ /*#__PURE__*/
76
+ React.createElement(ContentElementEditorCommandEmitterContext.Provider, {
77
+ value: emitter
78
+ }, children)
79
+ );
80
+ }
81
+
82
+ // the editor phone preview. Each ContentElementDecorator renders a
83
+ // `data-scrollpoint` attribute with a unique value on its wrapper
84
+ // div. Before toggling the phone preview mode, the `EntryPreviewView`
85
+ // sends a `SAVE_SCROLL_POINT` message. `getCurrentScrollPoint` looks
86
+ // through all DOM elements with `data-scrollpoint` attributes and
87
+ // stores the unique id of the element with the smallest non-negative
88
+ // y coordinate in the viewport (i.e. the first content element inside
89
+ // the viewport). `ScrollPointMessageHandler` responds with a
90
+ // `SAVED_SCROLL_POINT` message which makes `EntryPreviewView` toggle
91
+ // the preview mode. Once the preview has been resized,
92
+ // `EntryPreviewView` sends a `RESTORE_SCROLL_POINT`
93
+ // message. `restoreScrollPoint` looks up the new position of the
94
+ // element with the saved scroll point and scrolls it into view.
95
+ //
96
+ // When a content element is selected, we want to keep that element
97
+ // in the viewport instead. The `SelectionRect` therefore renders a
98
+ // `data-scrollpoint=selection` attribute. If an element with such an
99
+ // attribute is present, `getCurrentScrollPoint` prefers it over all
100
+ // other scroll points. Since text block elements render a selection
101
+ // rect around the current paragraph, scroll position is also
102
+ // preserved correctly inside long text blocks.
103
+
104
+ function ScrollPointMessageHandler() {
105
+ var scrollPoint = useRef();
106
+ var receiveMessage = useCallback(function (data) {
107
+ if (data.type === 'SAVE_SCROLL_POINT') {
108
+ scrollPoint.current = getCurrentScrollPoint();
109
+ window.parent.postMessage({
110
+ type: 'SAVED_SCROLL_POINT'
111
+ }, window.location.origin);
112
+ } else if (data.type === 'RESTORE_SCROLL_POINT') {
113
+ if (scrollPoint.current) {
114
+ restoreScrollPoint(scrollPoint.current);
115
+ }
116
+ }
117
+ }, []);
118
+ usePostMessageListener(receiveMessage);
119
+ return null;
120
+ }
121
+
122
+ function getCurrentScrollPoint() {
123
+ var scrollPointElement = getSelectionScrollPointElement() || getScrollPointElementWithMinimumTopPositionInViewport();
124
+ return scrollPointElement === null || scrollPointElement === void 0 ? void 0 : scrollPointElement.getAttribute('data-scrollpoint');
125
+ }
126
+
127
+ function getSelectionScrollPointElement() {
128
+ return document.querySelector('[data-scrollpoint=selection]');
129
+ }
130
+
131
+ function getScrollPointElementWithMinimumTopPositionInViewport() {
132
+ var minTop = Infinity;
133
+ var scrollPointElement;
134
+ var scrollPoints = document.querySelectorAll('[data-scrollpoint]');
135
+
136
+ for (var i = 0; i < scrollPoints.length; i++) {
137
+ var rect = scrollPoints[i].getBoundingClientRect();
138
+
139
+ if (rect.top > 0 && rect.top < minTop) {
140
+ minTop = rect.top;
141
+ scrollPointElement = scrollPoints[i];
142
+ }
143
+ }
144
+
145
+ return scrollPointElement;
146
+ }
147
+
148
+ function restoreScrollPoint(name) {
149
+ var element = document.querySelector("[data-scrollpoint=\"".concat(name, "\"]"));
150
+
151
+ if (element) {
152
+ window.scrollTo({
153
+ top: element.getBoundingClientRect().top + window.scrollY - 100,
154
+ behavior: 'smooth'
155
+ });
156
+ }
157
+ }
158
+
159
+ function EntryDecorator(props) {
160
+ var contentElementEditorCommandEmitter = useContentElementEditorCommandEmitter();
161
+ return (
162
+ /*#__PURE__*/
163
+ React.createElement(EditorStateProvider, null,
164
+ /*#__PURE__*/
165
+ React.createElement(MessageHandler, {
166
+ contentElementEditorCommandEmitter: contentElementEditorCommandEmitter
167
+ }),
168
+ /*#__PURE__*/
169
+ React.createElement(ScrollPointMessageHandler, null),
170
+ /*#__PURE__*/
171
+ React.createElement(ContentElementEditorCommandSubscriptionProvider, {
172
+ emitter: contentElementEditorCommandEmitter
173
+ },
174
+ /*#__PURE__*/
175
+ React.createElement(DndProvider, {
176
+ backend: HTML5Backend
177
+ }, props.children)))
178
+ );
179
+ }
180
+
181
+ function MessageHandler(_ref) {
182
+ var contentElementEditorCommandEmitter = _ref.contentElementEditorCommandEmitter;
183
+
184
+ var _useEditorSelection = useEditorSelection(),
185
+ select = _useEditorSelection.select;
186
+
187
+ var dispatch = useEntryStateDispatch();
188
+ var receiveMessage = useCallback(function (data) {
189
+ if (data.type === 'ACTION') {
190
+ dispatch(data.payload);
191
+ } else if (data.type === 'SELECT') {
192
+ select(data.payload);
193
+ } else if (data.type === 'CONTENT_ELEMENT_EDITOR_COMMAND') {
194
+ contentElementEditorCommandEmitter.trigger("command:".concat(data.payload.contentElementId), data.payload.command);
195
+ }
196
+ }, [dispatch, select, contentElementEditorCommandEmitter]);
197
+ usePostMessageListener(receiveMessage);
198
+ useEffect(function () {
199
+ if (window.parent !== window) {
200
+ window.parent.postMessage({
201
+ type: 'READY'
202
+ }, window.location.origin);
203
+ }
204
+ }, []);
205
+ return null;
206
+ }
207
+
208
+ var styles = {"wrapper":"SectionDecorator-module_wrapper__3sTk3","selected":"SectionDecorator-module_selected__1gcmF","transitionSelected":"SectionDecorator-module_transitionSelected__Wklk6","controls":"SectionDecorator-module_controls__LVEJG","editToolbar":"SectionDecorator-module_editToolbar__18Kjq","toolbar":"SectionDecorator-module_toolbar__2Va1D","transitionToolbar-before":"SectionDecorator-module_transitionToolbar-before__KipOO SectionDecorator-module_toolbar__2Va1D","transitionToolbar-after":"SectionDecorator-module_transitionToolbar-after__2_DVO SectionDecorator-module_toolbar__2Va1D"};
209
+
210
+ var styles$1 = {"wrapper":"ContentElementDecorator-module_wrapper__NQgFN"};
211
+
212
+ var styles$2 = {"Toolbar":"Toolbar-module_Toolbar__1INSj","button":"Toolbar-module_button__de5BW","activeButton":"Toolbar-module_activeButton__2sOLP","collapsible":"Toolbar-module_collapsible__3sivb"};
213
+
214
+ function Toolbar(_ref) {
215
+ var buttons = _ref.buttons,
216
+ onButtonClick = _ref.onButtonClick,
217
+ iconSize = _ref.iconSize,
218
+ collapsible = _ref.collapsible;
219
+ return (
220
+ /*#__PURE__*/
221
+ React.createElement("div", {
222
+ className: classNames(styles$2.Toolbar, _defineProperty({}, styles$2.collapsible, collapsible)),
223
+ contentEditable: false
224
+ }, buttons.map(function (button) {
225
+ var Icon = button.icon;
226
+ return (
227
+ /*#__PURE__*/
228
+ React.createElement("button", {
229
+ key: button.name,
230
+ title: button.text,
231
+ className: classNames(styles$2.button, _defineProperty({}, styles$2.activeButton, button.active)),
232
+ onMouseDown: function onMouseDown(event) {
233
+ event.preventDefault();
234
+ event.stopPropagation();
235
+ onButtonClick(button.name);
236
+ }
237
+ },
238
+ /*#__PURE__*/
239
+ React.createElement(Icon, {
240
+ width: iconSize,
241
+ height: iconSize
242
+ }))
243
+ );
244
+ }))
245
+ );
246
+ }
247
+ Toolbar.defaultProps = {
248
+ iconSize: 15
249
+ };
250
+
251
+ function _extends() {
252
+ _extends = Object.assign || function (target) {
253
+ for (var i = 1; i < arguments.length; i++) {
254
+ var source = arguments[i];
255
+
256
+ for (var key in source) {
257
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
258
+ target[key] = source[key];
259
+ }
260
+ }
261
+ }
262
+
263
+ return target;
264
+ };
265
+
266
+ return _extends.apply(this, arguments);
267
+ }
268
+ var transitionIcon = (function (_ref) {
269
+ var _ref$styles = _ref.styles,
270
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
271
+ props = _objectWithoutProperties(_ref, ["styles"]);
272
+
273
+ return React.createElement("svg", _extends({
274
+ "aria-hidden": "true",
275
+ "data-prefix": "fas",
276
+ "data-icon": "random",
277
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-random"] || "fa-random") + " " + (styles["fa-w-16"] || "fa-w-16"),
278
+ xmlns: "http://www.w3.org/2000/svg",
279
+ viewBox: "0 0 512 512"
280
+ }, props), React.createElement("path", {
281
+ fill: "currentColor",
282
+ d: "M504.971 359.029c9.373 9.373 9.373 24.569 0 33.941l-80 79.984c-15.01 15.01-40.971 4.49-40.971-16.971V416h-58.785a12.004 12.004 0 01-8.773-3.812l-70.556-75.596 53.333-57.143L352 336h32v-39.981c0-21.438 25.943-31.998 40.971-16.971l80 79.981zM12 176h84l52.781 56.551 53.333-57.143-70.556-75.596A11.999 11.999 0 00122.785 96H12c-6.627 0-12 5.373-12 12v56c0 6.627 5.373 12 12 12zm372 0v39.984c0 21.46 25.961 31.98 40.971 16.971l80-79.984c9.373-9.373 9.373-24.569 0-33.941l-80-79.981C409.943 24.021 384 34.582 384 56.019V96h-58.785a12.004 12.004 0 00-8.773 3.812L96 336H12c-6.627 0-12 5.373-12 12v56c0 6.627 5.373 12 12 12h110.785c3.326 0 6.503-1.381 8.773-3.812L352 176h32z"
283
+ }));
284
+ });
285
+
286
+ function SectionDecorator(props) {
287
+ var _useI18n = useI18n({
288
+ locale: 'ui'
289
+ }),
290
+ t = _useI18n.t;
291
+
292
+ var _useEditorSelection = useEditorSelection({
293
+ id: props.id,
294
+ type: 'sectionSettings'
295
+ }),
296
+ isSelected = _useEditorSelection.isSelected,
297
+ select = _useEditorSelection.select,
298
+ resetSelection = _useEditorSelection.resetSelection;
299
+
300
+ var transitionSelection = useEditorSelection({
301
+ id: props.id,
302
+ type: 'sectionTransition'
303
+ });
304
+ var nextTransitionSelection = useEditorSelection({
305
+ id: props.nextSection && props.nextSection.id,
306
+ type: 'sectionTransition'
307
+ });
308
+ var lastContentElement = props.contentElements[props.contentElements.length - 1];
309
+
310
+ var _useEditorSelection2 = useEditorSelection({
311
+ id: lastContentElement && lastContentElement.id,
312
+ type: 'contentElement'
313
+ }),
314
+ isLastContentElementSelected = _useEditorSelection2.isSelected;
315
+
316
+ function selectIfOutsideContentItem(event) {
317
+ if (!event.target.closest(".".concat(styles$1.wrapper))) {
318
+ isSelected ? resetSelection() : select();
319
+ }
320
+ }
321
+
322
+ return (
323
+ /*#__PURE__*/
324
+ React.createElement("div", {
325
+ "aria-label": t('pageflow_scrolled.inline_editing.select_section'),
326
+ className: className(isSelected, transitionSelection),
327
+ onMouseDown: selectIfOutsideContentItem
328
+ },
329
+ /*#__PURE__*/
330
+ React.createElement("div", {
331
+ className: styles.controls
332
+ }, renderEditTransitionButton({
333
+ id: props.previousSection && props.id,
334
+ selection: transitionSelection,
335
+ position: 'before'
336
+ }), renderEditTransitionButton({
337
+ id: props.nextSection && props.nextSection.id,
338
+ selection: nextTransitionSelection,
339
+ position: 'after'
340
+ })),
341
+ /*#__PURE__*/
342
+ React.createElement(MotifAreaVisibilityProvider, {
343
+ visible: isSelected
344
+ },
345
+ /*#__PURE__*/
346
+ React.createElement(ForcePaddingContext.Provider, {
347
+ value: isLastContentElementSelected || isSelected
348
+ }, props.children)))
349
+ );
350
+ }
351
+
352
+ function className(isSectionSelected, transitionSelection) {
353
+ var _classNames;
354
+
355
+ return classNames(styles.wrapper, (_classNames = {}, _defineProperty(_classNames, styles.selected, isSectionSelected), _defineProperty(_classNames, styles.transitionSelected, transitionSelection.isSelected), _classNames));
356
+ }
357
+
358
+ function renderEditTransitionButton(_ref) {
359
+ var id = _ref.id,
360
+ position = _ref.position,
361
+ selection = _ref.selection;
362
+
363
+ if (!id) {
364
+ return null;
365
+ }
366
+
367
+ return (
368
+ /*#__PURE__*/
369
+ React.createElement("div", {
370
+ className: styles["transitionToolbar-".concat(position)]
371
+ },
372
+ /*#__PURE__*/
373
+ React.createElement(EditTransitionButton, {
374
+ id: id,
375
+ selection: selection,
376
+ position: position
377
+ }))
378
+ );
379
+ }
380
+
381
+ function EditTransitionButton(_ref2) {
382
+ var id = _ref2.id,
383
+ position = _ref2.position,
384
+ selection = _ref2.selection;
385
+
386
+ var _useI18n2 = useI18n({
387
+ locale: 'ui'
388
+ }),
389
+ t = _useI18n2.t;
390
+
391
+ return (
392
+ /*#__PURE__*/
393
+ React.createElement(EditSectionButton, {
394
+ id: id,
395
+ selection: selection,
396
+ text: t("pageflow_scrolled.inline_editing.edit_section_transition_".concat(position)),
397
+ icon: transitionIcon
398
+ })
399
+ );
400
+ }
401
+
402
+ function EditSectionButton(_ref3) {
403
+ var id = _ref3.id,
404
+ selection = _ref3.selection,
405
+ icon = _ref3.icon,
406
+ text = _ref3.text;
407
+ return (
408
+ /*#__PURE__*/
409
+ React.createElement(Toolbar, {
410
+ buttons: [{
411
+ name: 'button',
412
+ active: selection.isSelected,
413
+ icon: icon,
414
+ text: text
415
+ }],
416
+ iconSize: 20,
417
+ onButtonClick: function onButtonClick() {
418
+ return selection.select();
419
+ }
420
+ })
421
+ );
422
+ }
423
+
424
+ var styles$3 = {"selectionWidth":"1px","selectionPadding":"-6px","selectionPadding2":"-0.5em","main":"SelectionRect-module_main__3AOhG","draggable":"SelectionRect-module_draggable__3Qp53","full":"SelectionRect-module_full__3tsQF","selected":"SelectionRect-module_selected__1PhM6","toolbar":"SelectionRect-module_toolbar__3nPrd","insert":"SelectionRect-module_insert__w0Tl0","insertHovered":"SelectionRect-module_insertHovered__VTsDD","start":"SelectionRect-module_start__3_nAf","insert-before":"SelectionRect-module_insert-before__2Tyq5 SelectionRect-module_insert__w0Tl0","end":"SelectionRect-module_end__3qOoK","insert-after":"SelectionRect-module_insert-after__3FJ4R SelectionRect-module_insert__w0Tl0","insertButton":"SelectionRect-module_insertButton__1g-ZG","dragHandle":"SelectionRect-module_dragHandle__2vVhP"};
425
+
426
+ function _extends$1() {
427
+ _extends$1 = Object.assign || function (target) {
428
+ for (var i = 1; i < arguments.length; i++) {
429
+ var source = arguments[i];
430
+
431
+ for (var key in source) {
432
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
433
+ target[key] = source[key];
434
+ }
435
+ }
436
+ }
437
+
438
+ return target;
439
+ };
440
+
441
+ return _extends$1.apply(this, arguments);
442
+ }
443
+ var PlusIcon = (function (_ref) {
444
+ var _ref$styles = _ref.styles,
445
+ props = _objectWithoutProperties(_ref, ["styles"]);
446
+
447
+ return React.createElement("svg", _extends$1({
448
+ xmlns: "http://www.w3.org/2000/svg",
449
+ viewBox: "0 0 512 512"
450
+ }, props), React.createElement("path", {
451
+ d: "M256 0C114.844 0 0 114.839 0 256s114.844 256 256 256 256-114.839 256-256S397.156 0 256 0zm133.594 272.699H272.699v116.895c0 9.225-7.48 16.699-16.699 16.699-9.219 0-16.699-7.475-16.699-16.699V272.699H122.406c-9.219 0-16.699-7.475-16.699-16.699 0-9.225 7.48-16.699 16.699-16.699h116.895V122.406c0-9.225 7.48-16.699 16.699-16.699 9.219 0 16.699 7.475 16.699 16.699v116.895h116.895c9.219 0 16.699 7.475 16.699 16.699.001 9.225-7.48 16.699-16.699 16.699z"
452
+ }));
453
+ });
454
+
455
+ function _extends$2() {
456
+ _extends$2 = Object.assign || function (target) {
457
+ for (var i = 1; i < arguments.length; i++) {
458
+ var source = arguments[i];
459
+
460
+ for (var key in source) {
461
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
462
+ target[key] = source[key];
463
+ }
464
+ }
465
+ }
466
+
467
+ return target;
468
+ };
469
+
470
+ return _extends$2.apply(this, arguments);
471
+ }
472
+ var MoveIcon = (function (_ref) {
473
+ var _ref$styles = _ref.styles,
474
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
475
+ props = _objectWithoutProperties(_ref, ["styles"]);
476
+
477
+ return React.createElement("svg", _extends$2({
478
+ "aria-hidden": "true",
479
+ "data-prefix": "fas",
480
+ "data-icon": "arrows-alt",
481
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-arrows-alt"] || "fa-arrows-alt") + " " + (styles["fa-w-16"] || "fa-w-16"),
482
+ xmlns: "http://www.w3.org/2000/svg",
483
+ viewBox: "0 0 512 512"
484
+ }, props), React.createElement("path", {
485
+ fill: "currentColor",
486
+ d: "M352.201 425.775l-79.196 79.196c-9.373 9.373-24.568 9.373-33.941 0l-79.196-79.196c-15.119-15.119-4.411-40.971 16.971-40.97h51.162L228 284H127.196v51.162c0 21.382-25.851 32.09-40.971 16.971L7.029 272.937c-9.373-9.373-9.373-24.569 0-33.941L86.225 159.8c15.119-15.119 40.971-4.411 40.971 16.971V228H228V127.196h-51.23c-21.382 0-32.09-25.851-16.971-40.971l79.196-79.196c9.373-9.373 24.568-9.373 33.941 0l79.196 79.196c15.119 15.119 4.411 40.971-16.971 40.971h-51.162V228h100.804v-51.162c0-21.382 25.851-32.09 40.97-16.971l79.196 79.196c9.373 9.373 9.373 24.569 0 33.941L425.773 352.2c-15.119 15.119-40.971 4.411-40.97-16.971V284H284v100.804h51.23c21.382 0 32.09 25.851 16.971 40.971z"
487
+ }));
488
+ });
489
+
490
+ function SelectionRect(props) {
491
+ var _classNames;
492
+
493
+ return (
494
+ /*#__PURE__*/
495
+ React.createElement("div", {
496
+ className: classNames(styles$3.main, (_classNames = {}, _defineProperty(_classNames, styles$3.full, props.full), _defineProperty(_classNames, styles$3.selected, props.selected), _defineProperty(_classNames, styles$3.draggable, props.drag), _defineProperty(_classNames, styles$3.start, props.selected && props.start), _defineProperty(_classNames, styles$3.end, props.selected && props.end), _classNames)),
497
+ "aria-label": props.ariaLabel,
498
+ "data-scrollpoint": props.scrollPoint ? 'selection' : undefined,
499
+ onClick: props.onClick
500
+ }, renderDragHandle(props), renderToolbar(props),
501
+ /*#__PURE__*/
502
+ React.createElement(InsertButton, Object.assign({}, props, {
503
+ at: "before"
504
+ })), props.children,
505
+ /*#__PURE__*/
506
+ React.createElement(InsertButton, Object.assign({}, props, {
507
+ at: "after"
508
+ })))
509
+ );
510
+ }
511
+
512
+ function InsertButton(props) {
513
+ var _useState = useState(false),
514
+ _useState2 = _slicedToArray(_useState, 2),
515
+ insertHovered = _useState2[0],
516
+ setInsertHovered = _useState2[1];
517
+
518
+ return (
519
+ /*#__PURE__*/
520
+ React.createElement("div", {
521
+ className: classNames(styles$3["insert-".concat(props.at)], _defineProperty({}, styles$3.insertHovered, insertHovered)),
522
+ contentEditable: false
523
+ },
524
+ /*#__PURE__*/
525
+ React.createElement("button", {
526
+ className: styles$3.insertButton,
527
+ title: props.insertButtonTitles && props.insertButtonTitles[props.at],
528
+ onClick: function onClick() {
529
+ return props.onInsertButtonClick(props.at);
530
+ },
531
+ onMouseEnter: function onMouseEnter() {
532
+ return setInsertHovered(true);
533
+ },
534
+ onMouseLeave: function onMouseLeave() {
535
+ return setInsertHovered(false);
536
+ }
537
+ },
538
+ /*#__PURE__*/
539
+ React.createElement(PlusIcon, {
540
+ width: 15,
541
+ height: 15,
542
+ fill: "currentColor"
543
+ })))
544
+ );
545
+ }
546
+
547
+ function renderDragHandle(_ref) {
548
+ var drag = _ref.drag,
549
+ dragHandleTitle = _ref.dragHandleTitle;
550
+
551
+ if (!drag) {
552
+ return null;
553
+ }
554
+
555
+ return (
556
+ /*#__PURE__*/
557
+ React.createElement("div", {
558
+ ref: drag,
559
+ className: styles$3.dragHandle,
560
+ title: dragHandleTitle
561
+ },
562
+ /*#__PURE__*/
563
+ React.createElement(MoveIcon, null))
564
+ );
565
+ }
566
+
567
+ function renderToolbar(_ref2) {
568
+ var toolbarButtons = _ref2.toolbarButtons,
569
+ onToolbarButtonClick = _ref2.onToolbarButtonClick,
570
+ start = _ref2.start;
571
+
572
+ if (toolbarButtons && start) {
573
+ return (
574
+ /*#__PURE__*/
575
+ React.createElement("div", {
576
+ className: styles$3.toolbar
577
+ },
578
+ /*#__PURE__*/
579
+ React.createElement(Toolbar, {
580
+ buttons: toolbarButtons,
581
+ collapsible: true,
582
+ onButtonClick: onToolbarButtonClick
583
+ }))
584
+ );
585
+ }
586
+ }
587
+
588
+ SelectionRect.defaultProps = {
589
+ start: true,
590
+ end: true
591
+ };
592
+
593
+ var styles$4 = {"target":"DropTargets-module_target__Z2N2d","isOver":"DropTargets-module_isOver__3ksFy","before":"DropTargets-module_before__cAXo1 DropTargets-module_target__Z2N2d","after":"DropTargets-module_after__2Q8QU DropTargets-module_target__Z2N2d"};
594
+
595
+ function DropTargets(_ref) {
596
+ var accept = _ref.accept,
597
+ _canDrop = _ref.canDrop,
598
+ onDrop = _ref.onDrop;
599
+
600
+ var _useDrop = useDrop({
601
+ accept: accept,
602
+ canDrop: function canDrop(item) {
603
+ return _canDrop({
604
+ at: 'before',
605
+ id: item.id
606
+ });
607
+ },
608
+ collect: function collect(monitor) {
609
+ return {
610
+ canDropBefore: monitor.canDrop(),
611
+ isBefore: monitor.isOver() && monitor.canDrop()
612
+ };
613
+ },
614
+ drop: function drop(item) {
615
+ return onDrop({
616
+ at: 'before',
617
+ id: item.id
618
+ });
619
+ }
620
+ }),
621
+ _useDrop2 = _slicedToArray(_useDrop, 2),
622
+ _useDrop2$ = _useDrop2[0],
623
+ canDropBefore = _useDrop2$.canDropBefore,
624
+ isBefore = _useDrop2$.isBefore,
625
+ dropBefore = _useDrop2[1];
626
+
627
+ var _useDrop3 = useDrop({
628
+ accept: accept,
629
+ canDrop: function canDrop(item) {
630
+ return _canDrop({
631
+ at: 'after',
632
+ id: item.id
633
+ });
634
+ },
635
+ collect: function collect(monitor) {
636
+ return {
637
+ canDropAfter: monitor.canDrop(),
638
+ isAfter: monitor.isOver() && monitor.canDrop()
639
+ };
640
+ },
641
+ drop: function drop(item) {
642
+ return onDrop({
643
+ at: 'after',
644
+ id: item.id
645
+ });
646
+ }
647
+ }),
648
+ _useDrop4 = _slicedToArray(_useDrop3, 2),
649
+ _useDrop4$ = _useDrop4[0],
650
+ canDropAfter = _useDrop4$.canDropAfter,
651
+ isAfter = _useDrop4$.isAfter,
652
+ dropAfter = _useDrop4[1];
653
+
654
+ return (
655
+ /*#__PURE__*/
656
+ React.createElement(React.Fragment, null, canDropBefore &&
657
+ /*#__PURE__*/
658
+ React.createElement("div", {
659
+ ref: dropBefore,
660
+ "data-testid": "drop-before",
661
+ className: classNames(styles$4.before, _defineProperty({}, styles$4.isOver, isBefore))
662
+ }), canDropAfter &&
663
+ /*#__PURE__*/
664
+ React.createElement("div", {
665
+ ref: dropAfter,
666
+ "data-testid": "drop-after",
667
+ title: "bar",
668
+ className: classNames(styles$4.after, _defineProperty({}, styles$4.isOver, isAfter))
669
+ }))
670
+ );
671
+ }
672
+
673
+ function postInsertContentElementMessage(_ref) {
674
+ var id = _ref.id,
675
+ at = _ref.at,
676
+ splitPoint = _ref.splitPoint;
677
+ window.parent.postMessage({
678
+ type: 'INSERT_CONTENT_ELEMENT',
679
+ payload: {
680
+ id: id,
681
+ at: at,
682
+ splitPoint: splitPoint
683
+ }
684
+ }, window.location.origin);
685
+ }
686
+ function postMoveContentElementMessage(_ref2) {
687
+ var id = _ref2.id,
688
+ to = _ref2.to;
689
+ window.parent.postMessage({
690
+ type: 'MOVE_CONTENT_ELEMENT',
691
+ payload: {
692
+ id: id,
693
+ to: to
694
+ }
695
+ }, window.location.origin);
696
+ }
697
+ function postUpdateContentElementMessage(_ref3) {
698
+ var id = _ref3.id,
699
+ configuration = _ref3.configuration;
700
+ window.parent.postMessage({
701
+ type: 'UPDATE_CONTENT_ELEMENT',
702
+ payload: {
703
+ id: id,
704
+ configuration: configuration
705
+ }
706
+ }, window.location.origin);
707
+ }
708
+ function postUpdateTransientContentElementStateMessage(_ref4) {
709
+ var id = _ref4.id,
710
+ state = _ref4.state;
711
+ window.parent.postMessage({
712
+ type: 'UPDATE_TRANSIENT_CONTENT_ELEMENT_STATE',
713
+ payload: {
714
+ id: id,
715
+ state: state
716
+ }
717
+ }, window.location.origin);
718
+ }
719
+
720
+ function ContentElementConfigurationUpdateProvider(_ref) {
721
+ var id = _ref.id,
722
+ permaId = _ref.permaId,
723
+ children = _ref.children;
724
+ var dispatch = useEntryStateDispatch();
725
+ var update = useCallback(function (configuration) {
726
+ postUpdateContentElementMessage({
727
+ id: id,
728
+ configuration: configuration
729
+ });
730
+ updateContentElementConfiguration({
731
+ dispatch: dispatch,
732
+ permaId: permaId,
733
+ configuration: configuration
734
+ });
735
+ }, [dispatch, permaId, id]);
736
+ return (
737
+ /*#__PURE__*/
738
+ React.createElement(ContentElementConfigurationUpdateContext.Provider, {
739
+ value: update
740
+ }, children)
741
+ );
742
+ }
743
+
744
+ function ContentElementEditorStateProvider(_ref) {
745
+ var id = _ref.id,
746
+ children = _ref.children;
747
+
748
+ var _useEditorSelection = useEditorSelection({
749
+ id: id,
750
+ type: 'contentElement'
751
+ }),
752
+ isSelected = _useEditorSelection.isSelected,
753
+ select = _useEditorSelection.select;
754
+
755
+ var previousTransientState = useRef({});
756
+ var setTransientState = useCallback(function (state) {
757
+ if (!shallowEqual(state, previousTransientState.current)) {
758
+ postUpdateTransientContentElementStateMessage({
759
+ id: id,
760
+ state: state
761
+ });
762
+ previousTransientState.current = state;
763
+ }
764
+ }, [id]);
765
+ var value = useMemo(function () {
766
+ return {
767
+ isEditable: true,
768
+ select: select,
769
+ isSelected: isSelected,
770
+ setTransientState: setTransientState
771
+ };
772
+ }, [select, isSelected, setTransientState]);
773
+ return (
774
+ /*#__PURE__*/
775
+ React.createElement(ContentElementEditorStateContext.Provider, {
776
+ value: value
777
+ }, children)
778
+ );
779
+ }
780
+
781
+ function shallowEqual(obj1, obj2) {
782
+ return Object.keys(obj1).length === Object.keys(obj2).length && Object.keys(obj1).every(function (key) {
783
+ return Object.prototype.hasOwnProperty.call(obj2, key) && obj1[key] === obj2[key];
784
+ });
785
+ }
786
+
787
+ function ContentElementDecorator(props) {
788
+ return (
789
+ /*#__PURE__*/
790
+ React.createElement("div", {
791
+ className: styles$1.wrapper,
792
+ "data-scrollpoint": props.id
793
+ },
794
+ /*#__PURE__*/
795
+ React.createElement(ContentElementEditorStateProvider, {
796
+ id: props.id
797
+ },
798
+ /*#__PURE__*/
799
+ React.createElement(OptionalSelectionRect, props,
800
+ /*#__PURE__*/
801
+ React.createElement(ContentElementConfigurationUpdateProvider, {
802
+ id: props.id,
803
+ permaId: props.permaId
804
+ }, props.children))))
805
+ );
806
+ }
807
+
808
+ function OptionalSelectionRect(props) {
809
+ var _ref = api.contentElementTypes.getOptions(props.type) || {},
810
+ customSelectionRect = _ref.customSelectionRect;
811
+
812
+ if (customSelectionRect) {
813
+ return props.children;
814
+ } else {
815
+ return (
816
+ /*#__PURE__*/
817
+ React.createElement(DefaultSelectionRect, props, props.children)
818
+ );
819
+ }
820
+ }
821
+
822
+ function DefaultSelectionRect(props) {
823
+ var _useContentElementEdi = useContentElementEditorState(),
824
+ isSelected = _useContentElementEdi.isSelected,
825
+ select = _useContentElementEdi.select;
826
+
827
+ var _useI18n = useI18n({
828
+ locale: 'ui'
829
+ }),
830
+ t = _useI18n.t;
831
+
832
+ var _useDrag = useDrag({
833
+ item: {
834
+ type: 'contentElement',
835
+ id: props.id
836
+ }
837
+ }),
838
+ _useDrag2 = _slicedToArray(_useDrag, 3),
839
+ drag = _useDrag2[1],
840
+ preview = _useDrag2[2];
841
+
842
+ return (
843
+ /*#__PURE__*/
844
+ React.createElement(SelectionRect, {
845
+ selected: isSelected,
846
+ scrollPoint: isSelected,
847
+ drag: drag,
848
+ dragHandleTitle: t('pageflow_scrolled.inline_editing.drag_content_element'),
849
+ full: props.position === 'full',
850
+ ariaLabel: t('pageflow_scrolled.inline_editing.select_content_element'),
851
+ insertButtonTitles: t('pageflow_scrolled.inline_editing.insert_content_element'),
852
+ onClick: function onClick() {
853
+ return select();
854
+ },
855
+ onInsertButtonClick: function onInsertButtonClick(at) {
856
+ return postInsertContentElementMessage({
857
+ id: props.id,
858
+ at: at
859
+ });
860
+ }
861
+ },
862
+ /*#__PURE__*/
863
+ React.createElement("div", {
864
+ ref: preview
865
+ }, props.children),
866
+ /*#__PURE__*/
867
+ React.createElement(DropTargets, {
868
+ accept: "contentElement",
869
+ canDrop: function canDrop(_ref2) {
870
+ var id = _ref2.id;
871
+ return id !== props.id;
872
+ },
873
+ onDrop: function onDrop(_ref3) {
874
+ var id = _ref3.id,
875
+ at = _ref3.at;
876
+ return postMoveContentElementMessage({
877
+ id: id,
878
+ to: {
879
+ id: props.id,
880
+ at: at
881
+ }
882
+ });
883
+ }
884
+ }))
885
+ );
886
+ }
887
+
888
+ var styles$5 = {"container":"ContentElementInsertButton-module_container__3dvUS","hovered":"ContentElementInsertButton-module_hovered__3Pggi","button":"ContentElementInsertButton-module_button__2-eE2"};
889
+
890
+ function ContentElementInsertButton(_ref) {
891
+ var onClick = _ref.onClick;
892
+
893
+ var _useState = useState(),
894
+ _useState2 = _slicedToArray(_useState, 2),
895
+ hovered = _useState2[0],
896
+ setHovered = _useState2[1];
897
+
898
+ var _useI18n = useI18n({
899
+ locale: 'ui'
900
+ }),
901
+ t = _useI18n.t;
902
+
903
+ return (
904
+ /*#__PURE__*/
905
+ React.createElement("div", {
906
+ className: classNames(styles$5.container, _defineProperty({}, styles$5.hovered, hovered))
907
+ },
908
+ /*#__PURE__*/
909
+ React.createElement("button", {
910
+ className: styles$5.button,
911
+ title: t('pageflow_scrolled.inline_editing.add_content_element'),
912
+ onClick: onClick,
913
+ onMouseDown: function onMouseDown(event) {
914
+ return event.stopPropagation();
915
+ },
916
+ onMouseEnter: function onMouseEnter() {
917
+ return setHovered(true);
918
+ },
919
+ onMouseLeave: function onMouseLeave() {
920
+ return setHovered(false);
921
+ }
922
+ },
923
+ /*#__PURE__*/
924
+ React.createElement(PlusIcon, {
925
+ width: 15,
926
+ height: 15,
927
+ fill: "currentColor"
928
+ })))
929
+ );
930
+ }
931
+
932
+ function LayoutWithPlaceholder(props) {
933
+ var _useEditorSelection = useEditorSelection({
934
+ id: props.sectionId,
935
+ type: 'section'
936
+ }),
937
+ isSelected = _useEditorSelection.isSelected;
938
+
939
+ var _useEditorSelection2 = useEditorSelection({
940
+ id: props.sectionId,
941
+ type: 'sectionSettings'
942
+ }),
943
+ settingsSelected = _useEditorSelection2.isSelected;
944
+
945
+ var placeholder = isSelected || settingsSelected ?
946
+ /*#__PURE__*/
947
+ React.createElement(ContentElementInsertButton, {
948
+ onClick: function onClick() {
949
+ return postInsertContentElementMessage({
950
+ at: 'endOfSection',
951
+ id: props.sectionId
952
+ });
953
+ }
954
+ }) : null;
955
+ return (
956
+ /*#__PURE__*/
957
+ React.createElement(LayoutWithoutInlineEditing, Object.assign({}, props, {
958
+ placeholder: placeholder
959
+ }))
960
+ );
961
+ }
962
+
963
+ function useCachedValue(value) {
964
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
965
+ defaultValue = _ref.defaultValue,
966
+ onReset = _ref.onReset,
967
+ onDebouncedChange = _ref.onDebouncedChange,
968
+ _ref$delay = _ref.delay,
969
+ delay = _ref$delay === void 0 ? 2000 : _ref$delay;
970
+
971
+ var _useState = useState(value || defaultValue),
972
+ _useState2 = _slicedToArray(_useState, 2),
973
+ cachedValue = _useState2[0],
974
+ setCachedValue = _useState2[1];
975
+
976
+ var previousValue = useRef(value);
977
+ useEffect(function () {
978
+ if (previousValue.current !== value && value !== cachedValue) {
979
+ onReset && onReset(value);
980
+ setCachedValue(value);
981
+ }
982
+ }, [onReset, value, cachedValue]);
983
+ useEffect(function () {
984
+ previousValue.current = value;
985
+ });
986
+ var debouncedHandler = useDebouncedCallback(onDebouncedChange, delay);
987
+ var setValue = useCallback(function (value) {
988
+ setCachedValue(function (previousValue) {
989
+ if (previousValue !== value) {
990
+ debouncedHandler(value);
991
+ }
992
+
993
+ return value;
994
+ });
995
+ }, [debouncedHandler]);
996
+ return [cachedValue, setValue];
997
+ } // Debounce callback even if the callback function changes across renders.
998
+
999
+ function useDebouncedCallback(callback, delay) {
1000
+ var mostRecentCallback = useRef(null);
1001
+ var debouncedHandler = useRef(null);
1002
+ useEffect(function () {
1003
+ mostRecentCallback.current = callback;
1004
+ }, [callback]);
1005
+ useEffect(function () {
1006
+ debouncedHandler.current = debounce(function (value) {
1007
+ if (mostRecentCallback.current) {
1008
+ mostRecentCallback.current(value);
1009
+ }
1010
+ }, delay);
1011
+ return function () {
1012
+ debouncedHandler.current.flush();
1013
+ };
1014
+ }, [delay]);
1015
+ return useCallback(function () {
1016
+ return debouncedHandler.current.apply(debouncedHandler, arguments);
1017
+ }, []);
1018
+ }
1019
+
1020
+ var styles$6 = {"placeholder":"TextPlaceholder-module_placeholder__sgVwx"};
1021
+
1022
+ function TextPlaceholder(_ref) {
1023
+ var text = _ref.text,
1024
+ visible = _ref.visible;
1025
+
1026
+ if (!text || !visible) {
1027
+ return null;
1028
+ }
1029
+
1030
+ return (
1031
+ /*#__PURE__*/
1032
+ React.createElement("div", {
1033
+ className: styles$6.placeholder
1034
+ },
1035
+ /*#__PURE__*/
1036
+ React.createElement("div", null, text))
1037
+ );
1038
+ }
1039
+
1040
+ function withCustomInsertBreak(editor) {
1041
+ var insertBreak = editor.insertBreak;
1042
+
1043
+ editor.insertBreak = function () {
1044
+ var selection = editor.selection;
1045
+
1046
+ if (selection && Range.isCollapsed(selection)) {
1047
+ var match = Editor.above(editor, {
1048
+ match: function match(n) {
1049
+ return Editor.isBlock(editor, n);
1050
+ }
1051
+ });
1052
+
1053
+ if (match) {
1054
+ var _match = _slicedToArray(match, 2),
1055
+ block = _match[0],
1056
+ path = _match[1];
1057
+
1058
+ if (Editor.isEnd(editor, selection.anchor, path) && block.type === 'heading') {
1059
+ Transforms.insertNodes(editor, {
1060
+ type: 'paragraph',
1061
+ children: [{
1062
+ text: ''
1063
+ }]
1064
+ });
1065
+ return;
1066
+ }
1067
+ }
1068
+ }
1069
+
1070
+ insertBreak();
1071
+ };
1072
+
1073
+ return editor;
1074
+ }
1075
+
1076
+ var styles$7 = {"container":"index-module_container__3dD9z","hoveringToolbar":"index-module_hoveringToolbar__31Xpd","selection":"index-module_selection__3dUiD","linkTooltip":"index-module_linkTooltip__36m1K"};
1077
+
1078
+ function _extends$3() {
1079
+ _extends$3 = Object.assign || function (target) {
1080
+ for (var i = 1; i < arguments.length; i++) {
1081
+ var source = arguments[i];
1082
+
1083
+ for (var key in source) {
1084
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1085
+ target[key] = source[key];
1086
+ }
1087
+ }
1088
+ }
1089
+
1090
+ return target;
1091
+ };
1092
+
1093
+ return _extends$3.apply(this, arguments);
1094
+ }
1095
+ var ExternalLinkIcon = (function (_ref) {
1096
+ var _ref$styles = _ref.styles,
1097
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
1098
+ props = _objectWithoutProperties(_ref, ["styles"]);
1099
+
1100
+ return React.createElement("svg", _extends$3({
1101
+ "aria-hidden": "true",
1102
+ "data-prefix": "fas",
1103
+ "data-icon": "external-link-alt",
1104
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-external-link-alt"] || "fa-external-link-alt") + " " + (styles["fa-w-16"] || "fa-w-16"),
1105
+ xmlns: "http://www.w3.org/2000/svg",
1106
+ viewBox: "0 0 512 512"
1107
+ }, props), React.createElement("path", {
1108
+ fill: "currentColor",
1109
+ d: "M432 320h-32a16 16 0 00-16 16v112H64V128h144a16 16 0 0016-16V80a16 16 0 00-16-16H48a48 48 0 00-48 48v352a48 48 0 0048 48h352a48 48 0 0048-48V336a16 16 0 00-16-16zM488 0H360c-21.37 0-32.05 25.91-17 41l35.73 35.73L135 320.37a24 24 0 000 34L157.67 377a24 24 0 0034 0l243.61-243.68L471 169c15 15 41 4.5 41-17V24a24 24 0 00-24-24z"
1110
+ }));
1111
+ });
1112
+
1113
+ var DisabledContext = createContext();
1114
+ var StateContext = createContext();
1115
+ var UpdateContext = createContext();
1116
+ function LinkTooltipProvider(_ref) {
1117
+ var disabled = _ref.disabled,
1118
+ children = _ref.children;
1119
+
1120
+ var _useState = useState(),
1121
+ _useState2 = _slicedToArray(_useState, 2),
1122
+ state = _useState2[0],
1123
+ setState = _useState2[1];
1124
+
1125
+ var outerRef = useRef();
1126
+ var update = useMemo(function () {
1127
+ var timeout;
1128
+ return {
1129
+ activate: function activate(href, linkRef) {
1130
+ clearTimeout(timeout);
1131
+ timeout = null;
1132
+ var outerRect = outerRef.current.getBoundingClientRect();
1133
+ var linkRect = linkRef.current.getBoundingClientRect();
1134
+ setState({
1135
+ href: href,
1136
+ top: linkRect.bottom - outerRect.top + 10,
1137
+ left: linkRect.left - outerRect.left
1138
+ });
1139
+ },
1140
+ keep: function keep() {
1141
+ clearTimeout(timeout);
1142
+ timeout = null;
1143
+ },
1144
+ deactivate: function deactivate() {
1145
+ if (!timeout) {
1146
+ timeout = setTimeout(function () {
1147
+ timeout = null;
1148
+ setState(null);
1149
+ }, 200);
1150
+ }
1151
+ }
1152
+ };
1153
+ }, []);
1154
+ return (
1155
+ /*#__PURE__*/
1156
+ React.createElement(DisabledContext.Provider, {
1157
+ value: disabled
1158
+ },
1159
+ /*#__PURE__*/
1160
+ React.createElement(StateContext.Provider, {
1161
+ value: state
1162
+ },
1163
+ /*#__PURE__*/
1164
+ React.createElement(UpdateContext.Provider, {
1165
+ value: update
1166
+ },
1167
+ /*#__PURE__*/
1168
+ React.createElement("div", {
1169
+ ref: outerRef
1170
+ },
1171
+ /*#__PURE__*/
1172
+ React.createElement(LinkTooltip, null), children))))
1173
+ );
1174
+ }
1175
+ function LinkPreview(_ref2) {
1176
+ var href = _ref2.href,
1177
+ children = _ref2.children;
1178
+
1179
+ var _useContext = useContext(UpdateContext),
1180
+ activate = _useContext.activate,
1181
+ deactivate = _useContext.deactivate;
1182
+
1183
+ var ref = useRef();
1184
+ return (
1185
+ /*#__PURE__*/
1186
+ React.createElement("span", {
1187
+ ref: ref,
1188
+ onMouseEnter: function onMouseEnter() {
1189
+ return activate(href, ref);
1190
+ },
1191
+ onMouseLeave: deactivate,
1192
+ onMouseDown: deactivate
1193
+ }, children)
1194
+ );
1195
+ }
1196
+ function LinkTooltip() {
1197
+ var disabled = useContext(DisabledContext);
1198
+ var state = useContext(StateContext);
1199
+
1200
+ var _useContext2 = useContext(UpdateContext),
1201
+ keep = _useContext2.keep,
1202
+ deactivate = _useContext2.deactivate;
1203
+
1204
+ var editor = useSlate();
1205
+
1206
+ if (disabled || !state || editor.selection && !Range.isCollapsed(editor.selection)) {
1207
+ return null;
1208
+ }
1209
+
1210
+ return (
1211
+ /*#__PURE__*/
1212
+ React.createElement("div", {
1213
+ className: classNames(styles$7.linkTooltip, styles$7.hoveringToolbar),
1214
+ onMouseEnter: keep,
1215
+ onMouseLeave: deactivate,
1216
+ style: {
1217
+ top: state.top,
1218
+ left: state.left,
1219
+ opacity: 1
1220
+ }
1221
+ },
1222
+ /*#__PURE__*/
1223
+ React.createElement("a", {
1224
+ href: state.href,
1225
+ target: "_blank",
1226
+ rel: "noopener noreferrer"
1227
+ }, state.href,
1228
+ /*#__PURE__*/
1229
+ React.createElement(ExternalLinkIcon, {
1230
+ width: 10,
1231
+ height: 10
1232
+ })))
1233
+ );
1234
+ }
1235
+
1236
+ function withLinks(editor) {
1237
+ var isInline = editor.isInline;
1238
+
1239
+ editor.isInline = function (element) {
1240
+ return element.type === 'link' ? true : isInline(element);
1241
+ };
1242
+
1243
+ return editor;
1244
+ }
1245
+ function renderElementWithLinkPreview(options) {
1246
+ if (options.element.type === 'link') {
1247
+ return (
1248
+ /*#__PURE__*/
1249
+ React.createElement(LinkPreview, {
1250
+ href: options.element.href
1251
+ }, renderElement(options))
1252
+ );
1253
+ } else {
1254
+ return renderElement(options);
1255
+ }
1256
+ }
1257
+ function renderLeafWithLinkSelection(options) {
1258
+ if (options.leaf.linkSelection) {
1259
+ return (
1260
+ /*#__PURE__*/
1261
+ React.createElement("span", Object.assign({}, options.attributes, {
1262
+ style: {
1263
+ backgroundColor: '#aaa'
1264
+ }
1265
+ }), renderLeaf(options))
1266
+ );
1267
+ }
1268
+
1269
+ return renderLeaf(options);
1270
+ }
1271
+ function decorateLinkSelection(_ref, linkSelection) {
1272
+ var _ref2 = _slicedToArray(_ref, 2),
1273
+ node = _ref2[0],
1274
+ path = _ref2[1];
1275
+
1276
+ if (linkSelection && Text.isText(node)) {
1277
+ var nodeRange = {
1278
+ anchor: {
1279
+ path: path,
1280
+ offset: 0
1281
+ },
1282
+ focus: {
1283
+ path: path,
1284
+ offset: node.text.length
1285
+ }
1286
+ };
1287
+ var intersection = Range.intersection(nodeRange, linkSelection);
1288
+
1289
+ if (intersection) {
1290
+ return [_objectSpread2(_objectSpread2({}, intersection), {}, {
1291
+ linkSelection: true
1292
+ })];
1293
+ }
1294
+ }
1295
+
1296
+ return [];
1297
+ }
1298
+
1299
+ // element is currently being dragged over the element. `react-dnd`
1300
+ // causes "Update on unmounted component warning" when dropping an
1301
+ // element removes a drop target [1]. As a workaround, couple
1302
+ // rendering of drop targets to asynchronously updated state. That way
1303
+ // the drop target is only removed after element has been dropped.
1304
+ //
1305
+ // [1] https://github.com/react-dnd/react-dnd/issues/1573
1306
+
1307
+ function useDropTargetsActive() {
1308
+ var _useState = useState(false),
1309
+ _useState2 = _slicedToArray(_useState, 2),
1310
+ dropTargetsActive = _useState2[0],
1311
+ setDropTargetsActive = _useState2[1];
1312
+
1313
+ var _useDrop = useDrop({
1314
+ accept: 'contentElement',
1315
+ collect: function collect(monitor) {
1316
+ return {
1317
+ canDrop: monitor.canDrop() && monitor.isOver()
1318
+ };
1319
+ }
1320
+ }),
1321
+ _useDrop2 = _slicedToArray(_useDrop, 2),
1322
+ canDrop = _useDrop2[0].canDrop,
1323
+ drop = _useDrop2[1];
1324
+
1325
+ useEffect(function () {
1326
+ if (canDrop) {
1327
+ setDropTargetsActive(true);
1328
+ } else {
1329
+ var timeout = setTimeout(function () {
1330
+ setDropTargetsActive(false);
1331
+ }, 10);
1332
+ return function () {
1333
+ clearTimeout(timeout);
1334
+ };
1335
+ }
1336
+ }, [canDrop]);
1337
+ return [dropTargetsActive, drop];
1338
+ }
1339
+
1340
+ function _extends$4() {
1341
+ _extends$4 = Object.assign || function (target) {
1342
+ for (var i = 1; i < arguments.length; i++) {
1343
+ var source = arguments[i];
1344
+
1345
+ for (var key in source) {
1346
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1347
+ target[key] = source[key];
1348
+ }
1349
+ }
1350
+ }
1351
+
1352
+ return target;
1353
+ };
1354
+
1355
+ return _extends$4.apply(this, arguments);
1356
+ }
1357
+ var CancelIcon = (function (_ref) {
1358
+ var _ref$styles = _ref.styles,
1359
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
1360
+ props = _objectWithoutProperties(_ref, ["styles"]);
1361
+
1362
+ return React.createElement("svg", _extends$4({
1363
+ "aria-hidden": "true",
1364
+ "data-prefix": "fas",
1365
+ "data-icon": "times",
1366
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-times"] || "fa-times") + " " + (styles["fa-w-11"] || "fa-w-11"),
1367
+ xmlns: "http://www.w3.org/2000/svg",
1368
+ viewBox: "0 0 352 512"
1369
+ }, props), React.createElement("path", {
1370
+ fill: "currentColor",
1371
+ d: "M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"
1372
+ }));
1373
+ });
1374
+
1375
+ function LinkInput(_ref) {
1376
+ var onSubmit = _ref.onSubmit,
1377
+ onCancel = _ref.onCancel;
1378
+
1379
+ var _useI18n = useI18n({
1380
+ locale: 'ui'
1381
+ }),
1382
+ t = _useI18n.t;
1383
+
1384
+ var _useState = useState(''),
1385
+ _useState2 = _slicedToArray(_useState, 2),
1386
+ href = _useState2[0],
1387
+ setHref = _useState2[1];
1388
+
1389
+ var ref = useRef(); // With useEffect the deselect in HoveringToolbar/handleButtonClick breaks focusing.
1390
+
1391
+ useLayoutEffect(function () {
1392
+ ref.current.focus();
1393
+ }, []);
1394
+
1395
+ function handleKey(event) {
1396
+ if (event.key === 'Enter') {
1397
+ event.preventDefault();
1398
+ ref.current.blur();
1399
+ } else if (event.key === 'Escape') {
1400
+ event.preventDefault();
1401
+ onCancel();
1402
+ }
1403
+ }
1404
+
1405
+ function submit() {
1406
+ if (href) {
1407
+ onSubmit(href);
1408
+ } else {
1409
+ onCancel();
1410
+ }
1411
+ }
1412
+
1413
+ return (
1414
+ /*#__PURE__*/
1415
+ React.createElement("div", {
1416
+ className: styles$7.linkTooltip
1417
+ },
1418
+ /*#__PURE__*/
1419
+ React.createElement("input", {
1420
+ ref: ref,
1421
+ type: "text",
1422
+ value: href,
1423
+ placeholder: t('pageflow_scrolled.inline_editing.url_placeholder'),
1424
+ onBlur: submit,
1425
+ onChange: function onChange(e) {
1426
+ return setHref(e.target.value);
1427
+ },
1428
+ onKeyDown: handleKey
1429
+ }),
1430
+ /*#__PURE__*/
1431
+ React.createElement("button", {
1432
+ onMouseDown: function onMouseDown(e) {
1433
+ return e.preventDefault();
1434
+ },
1435
+ onClick: onCancel,
1436
+ title: t('pageflow_scrolled.inline_editing.cancel')
1437
+ },
1438
+ /*#__PURE__*/
1439
+ React.createElement(CancelIcon, {
1440
+ width: 10,
1441
+ height: 10
1442
+ })))
1443
+ );
1444
+ }
1445
+
1446
+ function _extends$5() {
1447
+ _extends$5 = Object.assign || function (target) {
1448
+ for (var i = 1; i < arguments.length; i++) {
1449
+ var source = arguments[i];
1450
+
1451
+ for (var key in source) {
1452
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1453
+ target[key] = source[key];
1454
+ }
1455
+ }
1456
+ }
1457
+
1458
+ return target;
1459
+ };
1460
+
1461
+ return _extends$5.apply(this, arguments);
1462
+ }
1463
+ var BoldIcon = (function (_ref) {
1464
+ var _ref$styles = _ref.styles,
1465
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
1466
+ props = _objectWithoutProperties(_ref, ["styles"]);
1467
+
1468
+ return React.createElement("svg", _extends$5({
1469
+ "aria-hidden": "true",
1470
+ "data-prefix": "fas",
1471
+ "data-icon": "bold",
1472
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-bold"] || "fa-bold") + " " + (styles["fa-w-12"] || "fa-w-12"),
1473
+ xmlns: "http://www.w3.org/2000/svg",
1474
+ viewBox: "0 0 384 512"
1475
+ }, props), React.createElement("path", {
1476
+ fill: "currentColor",
1477
+ d: "M333.49 238a122 122 0 0027-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 00-16 16v48a16 16 0 0016 16h31.87v288H34a16 16 0 00-16 16v48a16 16 0 0016 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 010 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 010 112z"
1478
+ }));
1479
+ });
1480
+
1481
+ function _extends$6() {
1482
+ _extends$6 = Object.assign || function (target) {
1483
+ for (var i = 1; i < arguments.length; i++) {
1484
+ var source = arguments[i];
1485
+
1486
+ for (var key in source) {
1487
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1488
+ target[key] = source[key];
1489
+ }
1490
+ }
1491
+ }
1492
+
1493
+ return target;
1494
+ };
1495
+
1496
+ return _extends$6.apply(this, arguments);
1497
+ }
1498
+ var UnderlineIcon = (function (_ref) {
1499
+ var _ref$styles = _ref.styles,
1500
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
1501
+ props = _objectWithoutProperties(_ref, ["styles"]);
1502
+
1503
+ return React.createElement("svg", _extends$6({
1504
+ "aria-hidden": "true",
1505
+ "data-prefix": "fas",
1506
+ "data-icon": "underline",
1507
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-underline"] || "fa-underline") + " " + (styles["fa-w-14"] || "fa-w-14"),
1508
+ xmlns: "http://www.w3.org/2000/svg",
1509
+ viewBox: "0 0 448 512"
1510
+ }, props), React.createElement("path", {
1511
+ fill: "currentColor",
1512
+ d: "M32 64h32v160c0 88.22 71.78 160 160 160s160-71.78 160-160V64h32a16 16 0 0016-16V16a16 16 0 00-16-16H272a16 16 0 00-16 16v32a16 16 0 0016 16h32v160a80 80 0 01-160 0V64h32a16 16 0 0016-16V16a16 16 0 00-16-16H32a16 16 0 00-16 16v32a16 16 0 0016 16zm400 384H16a16 16 0 00-16 16v32a16 16 0 0016 16h416a16 16 0 0016-16v-32a16 16 0 00-16-16z"
1513
+ }));
1514
+ });
1515
+
1516
+ function _extends$7() {
1517
+ _extends$7 = Object.assign || function (target) {
1518
+ for (var i = 1; i < arguments.length; i++) {
1519
+ var source = arguments[i];
1520
+
1521
+ for (var key in source) {
1522
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1523
+ target[key] = source[key];
1524
+ }
1525
+ }
1526
+ }
1527
+
1528
+ return target;
1529
+ };
1530
+
1531
+ return _extends$7.apply(this, arguments);
1532
+ }
1533
+ var ItalicIcon = (function (_ref) {
1534
+ var _ref$styles = _ref.styles,
1535
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
1536
+ props = _objectWithoutProperties(_ref, ["styles"]);
1537
+
1538
+ return React.createElement("svg", _extends$7({
1539
+ "aria-hidden": "true",
1540
+ "data-prefix": "fas",
1541
+ "data-icon": "italic",
1542
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-italic"] || "fa-italic") + " " + (styles["fa-w-10"] || "fa-w-10"),
1543
+ xmlns: "http://www.w3.org/2000/svg",
1544
+ viewBox: "0 0 320 512"
1545
+ }, props), React.createElement("path", {
1546
+ fill: "currentColor",
1547
+ d: "M320 48v32a16 16 0 01-16 16h-62.76l-80 320H208a16 16 0 0116 16v32a16 16 0 01-16 16H16a16 16 0 01-16-16v-32a16 16 0 0116-16h62.76l80-320H112a16 16 0 01-16-16V48a16 16 0 0116-16h192a16 16 0 0116 16z"
1548
+ }));
1549
+ });
1550
+
1551
+ function _extends$8() {
1552
+ _extends$8 = Object.assign || function (target) {
1553
+ for (var i = 1; i < arguments.length; i++) {
1554
+ var source = arguments[i];
1555
+
1556
+ for (var key in source) {
1557
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1558
+ target[key] = source[key];
1559
+ }
1560
+ }
1561
+ }
1562
+
1563
+ return target;
1564
+ };
1565
+
1566
+ return _extends$8.apply(this, arguments);
1567
+ }
1568
+ var StrikethroughIcon = (function (_ref) {
1569
+ var _ref$styles = _ref.styles,
1570
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
1571
+ props = _objectWithoutProperties(_ref, ["styles"]);
1572
+
1573
+ return React.createElement("svg", _extends$8({
1574
+ "aria-hidden": "true",
1575
+ "data-prefix": "fas",
1576
+ "data-icon": "strikethrough",
1577
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-strikethrough"] || "fa-strikethrough") + " " + (styles["fa-w-16"] || "fa-w-16"),
1578
+ xmlns: "http://www.w3.org/2000/svg",
1579
+ viewBox: "0 0 512 512"
1580
+ }, props), React.createElement("path", {
1581
+ fill: "currentColor",
1582
+ d: "M496 224H293.9l-87.17-26.83A43.55 43.55 0 01219.55 112h66.79A49.89 49.89 0 01331 139.58a16 16 0 0021.46 7.15l42.94-21.47a16 16 0 007.16-21.46l-.53-1A128 128 0 00287.51 32h-68a123.68 123.68 0 00-123 135.64c2 20.89 10.1 39.83 21.78 56.36H16a16 16 0 00-16 16v32a16 16 0 0016 16h480a16 16 0 0016-16v-32a16 16 0 00-16-16zm-180.24 96A43 43 0 01336 356.45 43.59 43.59 0 01292.45 400h-66.79A49.89 49.89 0 01181 372.42a16 16 0 00-21.46-7.15l-42.94 21.47a16 16 0 00-7.16 21.46l.53 1A128 128 0 00224.49 480h68a123.68 123.68 0 00123-135.64 114.25 114.25 0 00-5.34-24.36z"
1583
+ }));
1584
+ });
1585
+
1586
+ function _extends$9() {
1587
+ _extends$9 = Object.assign || function (target) {
1588
+ for (var i = 1; i < arguments.length; i++) {
1589
+ var source = arguments[i];
1590
+
1591
+ for (var key in source) {
1592
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1593
+ target[key] = source[key];
1594
+ }
1595
+ }
1596
+ }
1597
+
1598
+ return target;
1599
+ };
1600
+
1601
+ return _extends$9.apply(this, arguments);
1602
+ }
1603
+ var LinkIcon = (function (_ref) {
1604
+ var _ref$styles = _ref.styles,
1605
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
1606
+ props = _objectWithoutProperties(_ref, ["styles"]);
1607
+
1608
+ return React.createElement("svg", _extends$9({
1609
+ "aria-hidden": "true",
1610
+ "data-prefix": "fas",
1611
+ "data-icon": "link",
1612
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-link"] || "fa-link") + " " + (styles["fa-w-16"] || "fa-w-16"),
1613
+ xmlns: "http://www.w3.org/2000/svg",
1614
+ viewBox: "0 0 512 512"
1615
+ }, props), React.createElement("path", {
1616
+ fill: "currentColor",
1617
+ d: "M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 01-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0120.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0020.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 00-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"
1618
+ }));
1619
+ });
1620
+
1621
+ function HoveringToolbar(_ref) {
1622
+ var linkSelection = _ref.linkSelection,
1623
+ setLinkSelection = _ref.setLinkSelection;
1624
+ var ref = useRef();
1625
+ var outerRef = useRef();
1626
+ var editor = useSlate();
1627
+
1628
+ var _useI18n = useI18n({
1629
+ locale: 'ui'
1630
+ }),
1631
+ t = _useI18n.t;
1632
+
1633
+ useEffect(function () {
1634
+ var el = ref.current;
1635
+ var selection = editor.selection;
1636
+
1637
+ if (!el || !outerRef.current || linkSelection) {
1638
+ return;
1639
+ }
1640
+
1641
+ if (!selection || !ReactEditor.isFocused(editor) || Range.isCollapsed(selection) || Editor.string(editor, selection) === '') {
1642
+ el.removeAttribute('style');
1643
+ return;
1644
+ }
1645
+
1646
+ var domRange = ReactEditor.toDOMRange(editor, editor.selection);
1647
+ var rect = domRange.getBoundingClientRect();
1648
+ var outerRect = outerRef.current.getBoundingClientRect();
1649
+ el.style.opacity = 1;
1650
+ el.style.top = "".concat(rect.bottom - outerRect.top + 10, "px");
1651
+ el.style.left = "".concat(rect.left - outerRect.left, "px");
1652
+ });
1653
+ return (
1654
+ /*#__PURE__*/
1655
+ React.createElement("div", {
1656
+ ref: outerRef
1657
+ },
1658
+ /*#__PURE__*/
1659
+ React.createElement("div", {
1660
+ ref: ref,
1661
+ className: styles$7.hoveringToolbar
1662
+ }, !linkSelection && renderToolbar$1(editor, setLinkSelection, t), linkSelection && renderLinkInput(editor, linkSelection, setLinkSelection)))
1663
+ );
1664
+ }
1665
+
1666
+ function renderToolbar$1(editor, setLinkSelection, t) {
1667
+ var buttons = [{
1668
+ name: 'bold',
1669
+ text: t('pageflow_scrolled.inline_editing.formats.bold'),
1670
+ icon: BoldIcon
1671
+ }, {
1672
+ name: 'italic',
1673
+ text: t('pageflow_scrolled.inline_editing.formats.italic'),
1674
+ icon: ItalicIcon
1675
+ }, {
1676
+ name: 'underline',
1677
+ text: t('pageflow_scrolled.inline_editing.formats.underline'),
1678
+ icon: UnderlineIcon
1679
+ }, {
1680
+ name: 'strikethrough',
1681
+ text: t('pageflow_scrolled.inline_editing.formats.strikethrough'),
1682
+ icon: StrikethroughIcon
1683
+ }, {
1684
+ name: 'link',
1685
+ text: isButtonActive(editor, 'link') ? t('pageflow_scrolled.inline_editing.remove_link') : t('pageflow_scrolled.inline_editing.insert_link'),
1686
+ icon: LinkIcon
1687
+ }].map(function (button) {
1688
+ return _objectSpread2(_objectSpread2({}, button), {}, {
1689
+ active: isButtonActive(editor, button.name)
1690
+ });
1691
+ });
1692
+ return (
1693
+ /*#__PURE__*/
1694
+ React.createElement(Toolbar, {
1695
+ buttons: buttons,
1696
+ onButtonClick: function onButtonClick(name) {
1697
+ return handleButtonClick(editor, name, setLinkSelection);
1698
+ }
1699
+ })
1700
+ );
1701
+ }
1702
+
1703
+ function handleButtonClick(editor, format, setLinkSelection) {
1704
+ if (format === 'link') {
1705
+ if (isLinkActive(editor)) {
1706
+ unwrapLink(editor);
1707
+ } else {
1708
+ var selection = editor.selection; // Required to prevent slate from focusing the editor in Firefox
1709
+ // https://github.com/ianstormtaylor/slate/blob/44675c2080e3f6a2523170430bb92e426b7647e2/packages/slate-react/src/components/editable.tsx#L189
1710
+
1711
+ Transforms.deselect(editor);
1712
+ setLinkSelection(selection);
1713
+ }
1714
+ } else {
1715
+ toggleMark(editor, format);
1716
+ }
1717
+ }
1718
+
1719
+ function isButtonActive(editor, format) {
1720
+ if (format === 'link') {
1721
+ return isLinkActive(editor);
1722
+ } else {
1723
+ return isMarkActive(editor, format);
1724
+ }
1725
+ }
1726
+
1727
+ function renderLinkInput(editor, linkSelection, setLinkSelection) {
1728
+ function handleSubmit(href) {
1729
+ Transforms.select(editor, linkSelection);
1730
+ ReactEditor.focus(editor);
1731
+ wrapLink(editor, href);
1732
+ setLinkSelection(null);
1733
+ }
1734
+
1735
+ function handleCancel() {
1736
+ setLinkSelection(null);
1737
+ Transforms.select(editor, linkSelection);
1738
+ ReactEditor.focus(editor);
1739
+ }
1740
+
1741
+ return (
1742
+ /*#__PURE__*/
1743
+ React.createElement(LinkInput, {
1744
+ onSubmit: handleSubmit,
1745
+ onCancel: handleCancel
1746
+ })
1747
+ );
1748
+ }
1749
+
1750
+ function unwrapLink(editor) {
1751
+ Transforms.unwrapNodes(editor, {
1752
+ match: function match(n) {
1753
+ return n.type === 'link';
1754
+ }
1755
+ });
1756
+ }
1757
+
1758
+ function wrapLink(editor, href) {
1759
+ var link = {
1760
+ type: 'link',
1761
+ href: href,
1762
+ children: []
1763
+ };
1764
+ Transforms.wrapNodes(editor, link, {
1765
+ split: true
1766
+ });
1767
+ Transforms.collapse(editor, {
1768
+ edge: 'end'
1769
+ });
1770
+ }
1771
+
1772
+ function isLinkActive(editor) {
1773
+ var _Editor$nodes = Editor.nodes(editor, {
1774
+ match: function match(n) {
1775
+ return n.type === 'link';
1776
+ }
1777
+ }),
1778
+ _Editor$nodes2 = _slicedToArray(_Editor$nodes, 1),
1779
+ link = _Editor$nodes2[0];
1780
+
1781
+ return !!link;
1782
+ }
1783
+
1784
+ function toggleMark(editor, format) {
1785
+ var isActive = isMarkActive(editor, format);
1786
+
1787
+ if (isActive) {
1788
+ Editor.removeMark(editor, format);
1789
+ } else {
1790
+ Editor.addMark(editor, format, true);
1791
+ }
1792
+ }
1793
+
1794
+ function isMarkActive(editor, format) {
1795
+ var marks = Editor.marks(editor);
1796
+ return marks ? marks[format] === true : false;
1797
+ }
1798
+
1799
+ function _extends$a() {
1800
+ _extends$a = Object.assign || function (target) {
1801
+ for (var i = 1; i < arguments.length; i++) {
1802
+ var source = arguments[i];
1803
+
1804
+ for (var key in source) {
1805
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1806
+ target[key] = source[key];
1807
+ }
1808
+ }
1809
+ }
1810
+
1811
+ return target;
1812
+ };
1813
+
1814
+ return _extends$a.apply(this, arguments);
1815
+ }
1816
+ var TextIcon = (function (_ref) {
1817
+ var _ref$styles = _ref.styles,
1818
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
1819
+ props = _objectWithoutProperties(_ref, ["styles"]);
1820
+
1821
+ return React.createElement("svg", _extends$a({
1822
+ "aria-hidden": "true",
1823
+ "data-prefix": "fas",
1824
+ "data-icon": "align-justify",
1825
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-align-justify"] || "fa-align-justify") + " " + (styles["fa-w-14"] || "fa-w-14"),
1826
+ xmlns: "http://www.w3.org/2000/svg",
1827
+ viewBox: "0 0 448 512"
1828
+ }, props), React.createElement("path", {
1829
+ fill: "currentColor",
1830
+ d: "M432 416H16a16 16 0 00-16 16v32a16 16 0 0016 16h416a16 16 0 0016-16v-32a16 16 0 00-16-16zm0-128H16a16 16 0 00-16 16v32a16 16 0 0016 16h416a16 16 0 0016-16v-32a16 16 0 00-16-16zm0-128H16a16 16 0 00-16 16v32a16 16 0 0016 16h416a16 16 0 0016-16v-32a16 16 0 00-16-16zm0-128H16A16 16 0 000 48v32a16 16 0 0016 16h416a16 16 0 0016-16V48a16 16 0 00-16-16z"
1831
+ }));
1832
+ });
1833
+
1834
+ function _extends$b() {
1835
+ _extends$b = Object.assign || function (target) {
1836
+ for (var i = 1; i < arguments.length; i++) {
1837
+ var source = arguments[i];
1838
+
1839
+ for (var key in source) {
1840
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1841
+ target[key] = source[key];
1842
+ }
1843
+ }
1844
+ }
1845
+
1846
+ return target;
1847
+ };
1848
+
1849
+ return _extends$b.apply(this, arguments);
1850
+ }
1851
+ var HeadingIcon = (function (_ref) {
1852
+ var _ref$styles = _ref.styles,
1853
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
1854
+ props = _objectWithoutProperties(_ref, ["styles"]);
1855
+
1856
+ return React.createElement("svg", _extends$b({
1857
+ "aria-hidden": "true",
1858
+ "data-prefix": "fas",
1859
+ "data-icon": "heading",
1860
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-heading"] || "fa-heading") + " " + (styles["fa-w-16"] || "fa-w-16"),
1861
+ xmlns: "http://www.w3.org/2000/svg",
1862
+ viewBox: "0 0 512 512"
1863
+ }, props), React.createElement("path", {
1864
+ fill: "currentColor",
1865
+ d: "M448 96v320h32a16 16 0 0116 16v32a16 16 0 01-16 16H320a16 16 0 01-16-16v-32a16 16 0 0116-16h32V288H160v128h32a16 16 0 0116 16v32a16 16 0 01-16 16H32a16 16 0 01-16-16v-32a16 16 0 0116-16h32V96H32a16 16 0 01-16-16V48a16 16 0 0116-16h160a16 16 0 0116 16v32a16 16 0 01-16 16h-32v128h192V96h-32a16 16 0 01-16-16V48a16 16 0 0116-16h160a16 16 0 0116 16v32a16 16 0 01-16 16z"
1866
+ }));
1867
+ });
1868
+
1869
+ function _extends$c() {
1870
+ _extends$c = Object.assign || function (target) {
1871
+ for (var i = 1; i < arguments.length; i++) {
1872
+ var source = arguments[i];
1873
+
1874
+ for (var key in source) {
1875
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1876
+ target[key] = source[key];
1877
+ }
1878
+ }
1879
+ }
1880
+
1881
+ return target;
1882
+ };
1883
+
1884
+ return _extends$c.apply(this, arguments);
1885
+ }
1886
+ var OlIcon = (function (_ref) {
1887
+ var _ref$styles = _ref.styles,
1888
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
1889
+ props = _objectWithoutProperties(_ref, ["styles"]);
1890
+
1891
+ return React.createElement("svg", _extends$c({
1892
+ "aria-hidden": "true",
1893
+ "data-prefix": "fas",
1894
+ "data-icon": "list-ol",
1895
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-list-ol"] || "fa-list-ol") + " " + (styles["fa-w-16"] || "fa-w-16"),
1896
+ xmlns: "http://www.w3.org/2000/svg",
1897
+ viewBox: "0 0 512 512"
1898
+ }, props), React.createElement("path", {
1899
+ fill: "currentColor",
1900
+ d: "M61.77 401l17.5-20.15a19.92 19.92 0 005.07-14.19v-3.31C84.34 356 80.5 352 73 352H16a8 8 0 00-8 8v16a8 8 0 008 8h22.83a157.41 157.41 0 00-11 12.31l-5.61 7c-4 5.07-5.25 10.13-2.8 14.88l1.05 1.93c3 5.76 6.29 7.88 12.25 7.88h4.73c10.33 0 15.94 2.44 15.94 9.09 0 4.72-4.2 8.22-14.36 8.22a41.54 41.54 0 01-15.47-3.12c-6.49-3.88-11.74-3.5-15.6 3.12l-5.59 9.31c-3.72 6.13-3.19 11.72 2.63 15.94 7.71 4.69 20.38 9.44 37 9.44 34.16 0 48.5-22.75 48.5-44.12-.03-14.38-9.12-29.76-28.73-34.88zM496 224H176a16 16 0 00-16 16v32a16 16 0 0016 16h320a16 16 0 0016-16v-32a16 16 0 00-16-16zm0-160H176a16 16 0 00-16 16v32a16 16 0 0016 16h320a16 16 0 0016-16V80a16 16 0 00-16-16zm0 320H176a16 16 0 00-16 16v32a16 16 0 0016 16h320a16 16 0 0016-16v-32a16 16 0 00-16-16zM16 160h64a8 8 0 008-8v-16a8 8 0 00-8-8H64V40a8 8 0 00-8-8H32a8 8 0 00-7.14 4.42l-8 16A8 8 0 0024 64h8v64H16a8 8 0 00-8 8v16a8 8 0 008 8zm-3.91 160H80a8 8 0 008-8v-16a8 8 0 00-8-8H41.32c3.29-10.29 48.34-18.68 48.34-56.44 0-29.06-25-39.56-44.47-39.56-21.36 0-33.8 10-40.46 18.75-4.37 5.59-3 10.84 2.8 15.37l8.58 6.88c5.61 4.56 11 2.47 16.12-2.44a13.44 13.44 0 019.46-3.84c3.33 0 9.28 1.56 9.28 8.75C51 248.19 0 257.31 0 304.59v4C0 316 5.08 320 12.09 320z"
1901
+ }));
1902
+ });
1903
+
1904
+ function _extends$d() {
1905
+ _extends$d = Object.assign || function (target) {
1906
+ for (var i = 1; i < arguments.length; i++) {
1907
+ var source = arguments[i];
1908
+
1909
+ for (var key in source) {
1910
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1911
+ target[key] = source[key];
1912
+ }
1913
+ }
1914
+ }
1915
+
1916
+ return target;
1917
+ };
1918
+
1919
+ return _extends$d.apply(this, arguments);
1920
+ }
1921
+ var UlIcon = (function (_ref) {
1922
+ var _ref$styles = _ref.styles,
1923
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
1924
+ props = _objectWithoutProperties(_ref, ["styles"]);
1925
+
1926
+ return React.createElement("svg", _extends$d({
1927
+ "aria-hidden": "true",
1928
+ "data-prefix": "fas",
1929
+ "data-icon": "list-ul",
1930
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-list-ul"] || "fa-list-ul") + " " + (styles["fa-w-16"] || "fa-w-16"),
1931
+ xmlns: "http://www.w3.org/2000/svg",
1932
+ viewBox: "0 0 512 512"
1933
+ }, props), React.createElement("path", {
1934
+ fill: "currentColor",
1935
+ d: "M48 48a48 48 0 1048 48 48 48 0 00-48-48zm0 160a48 48 0 1048 48 48 48 0 00-48-48zm0 160a48 48 0 1048 48 48 48 0 00-48-48zm448 16H176a16 16 0 00-16 16v32a16 16 0 0016 16h320a16 16 0 0016-16v-32a16 16 0 00-16-16zm0-320H176a16 16 0 00-16 16v32a16 16 0 0016 16h320a16 16 0 0016-16V80a16 16 0 00-16-16zm0 160H176a16 16 0 00-16 16v32a16 16 0 0016 16h320a16 16 0 0016-16v-32a16 16 0 00-16-16z"
1936
+ }));
1937
+ });
1938
+
1939
+ function _extends$e() {
1940
+ _extends$e = Object.assign || function (target) {
1941
+ for (var i = 1; i < arguments.length; i++) {
1942
+ var source = arguments[i];
1943
+
1944
+ for (var key in source) {
1945
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1946
+ target[key] = source[key];
1947
+ }
1948
+ }
1949
+ }
1950
+
1951
+ return target;
1952
+ };
1953
+
1954
+ return _extends$e.apply(this, arguments);
1955
+ }
1956
+ var QuoteIcon = (function (_ref) {
1957
+ var _ref$styles = _ref.styles,
1958
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
1959
+ props = _objectWithoutProperties(_ref, ["styles"]);
1960
+
1961
+ return React.createElement("svg", _extends$e({
1962
+ "aria-hidden": "true",
1963
+ "data-prefix": "fas",
1964
+ "data-icon": "quote-right",
1965
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-quote-right"] || "fa-quote-right") + " " + (styles["fa-w-16"] || "fa-w-16"),
1966
+ xmlns: "http://www.w3.org/2000/svg",
1967
+ viewBox: "0 0 512 512"
1968
+ }, props), React.createElement("path", {
1969
+ fill: "currentColor",
1970
+ d: "M464 32H336c-26.5 0-48 21.5-48 48v128c0 26.5 21.5 48 48 48h80v64c0 35.3-28.7 64-64 64h-8c-13.3 0-24 10.7-24 24v48c0 13.3 10.7 24 24 24h8c88.4 0 160-71.6 160-160V80c0-26.5-21.5-48-48-48zm-288 0H48C21.5 32 0 53.5 0 80v128c0 26.5 21.5 48 48 48h80v64c0 35.3-28.7 64-64 64h-8c-13.3 0-24 10.7-24 24v48c0 13.3 10.7 24 24 24h8c88.4 0 160-71.6 160-160V80c0-26.5-21.5-48-48-48z"
1971
+ }));
1972
+ });
1973
+
1974
+ function Selection(props) {
1975
+ var editor = useSlate();
1976
+
1977
+ var _useI18n = useI18n({
1978
+ locale: 'ui'
1979
+ }),
1980
+ t = _useI18n.t;
1981
+
1982
+ var ref = useRef();
1983
+ var outerRef = useRef();
1984
+ var innerRef = useRef();
1985
+ var boundsRef = useRef();
1986
+
1987
+ var _useContentElementEdi = useContentElementEditorState(),
1988
+ setTransientState = _useContentElementEdi.setTransientState,
1989
+ select = _useContentElementEdi.select,
1990
+ isContentElementSelected = _useContentElementEdi.isSelected;
1991
+
1992
+ useEffect(function () {
1993
+ var selection = editor.selection;
1994
+
1995
+ if (!ref.current) {
1996
+ return;
1997
+ }
1998
+
1999
+ if (!selection) {
2000
+ if (boundsRef.current) {
2001
+ hideRect(ref.current);
2002
+ boundsRef.current = null;
2003
+ }
2004
+
2005
+ return;
2006
+ }
2007
+
2008
+ if (!isContentElementSelected && boundsRef.current) {
2009
+ hideRect(ref.current);
2010
+ return;
2011
+ }
2012
+
2013
+ if (!isContentElementSelected && !boundsRef.current) {
2014
+ select();
2015
+ }
2016
+
2017
+ var _computeBounds = computeBounds(editor),
2018
+ _computeBounds2 = _slicedToArray(_computeBounds, 2),
2019
+ start = _computeBounds2[0],
2020
+ end = _computeBounds2[1];
2021
+
2022
+ setTransientState({
2023
+ editableTextIsSingleBlock: editor.children.length <= 1
2024
+ });
2025
+ boundsRef.current = {
2026
+ start: start,
2027
+ end: end
2028
+ };
2029
+ updateRect(editor, start, end, outerRef.current, ref.current, innerRef.current);
2030
+ });
2031
+ return (
2032
+ /*#__PURE__*/
2033
+ React.createElement("div", {
2034
+ ref: outerRef
2035
+ },
2036
+ /*#__PURE__*/
2037
+ React.createElement("div", {
2038
+ ref: ref,
2039
+ className: styles$7.selection
2040
+ },
2041
+ /*#__PURE__*/
2042
+ React.createElement(SelectionRect, {
2043
+ selected: true,
2044
+ scrollPoint: isContentElementSelected,
2045
+ insertButtonTitles: t('pageflow_scrolled.inline_editing.insert_content_element'),
2046
+ onInsertButtonClick: function onInsertButtonClick(at) {
2047
+ if (at === 'before' && boundsRef.current.start === 0 || at === 'after' && !Node.has(editor, [boundsRef.current.end + 1])) {
2048
+ postInsertContentElementMessage({
2049
+ id: props.contentElementId,
2050
+ at: at
2051
+ });
2052
+ } else {
2053
+ postInsertContentElementMessage({
2054
+ id: props.contentElementId,
2055
+ at: 'split',
2056
+ splitPoint: at === 'before' ? boundsRef.current.start : boundsRef.current.end + 1
2057
+ });
2058
+ }
2059
+ },
2060
+ toolbarButtons: toolbarButtons(t).map(function (button) {
2061
+ return _objectSpread2(_objectSpread2({}, button), {}, {
2062
+ active: isBlockActive(editor, button.name)
2063
+ });
2064
+ }),
2065
+ onToolbarButtonClick: function onToolbarButtonClick(name) {
2066
+ return toggleBlock(editor, name);
2067
+ }
2068
+ },
2069
+ /*#__PURE__*/
2070
+ React.createElement("div", {
2071
+ ref: innerRef
2072
+ }))))
2073
+ );
2074
+ }
2075
+
2076
+ function computeBounds(editor) {
2077
+ var startPoint = Range.start(editor.selection);
2078
+ var endPoint = Range.end(editor.selection);
2079
+ var startPath = startPoint.path.slice(0, 1);
2080
+ var endPath = endPoint.path.slice(0, 1);
2081
+
2082
+ if (!Path.equals(startPath, endPath) && endPoint.offset === 0) {
2083
+ endPath = Path.previous(endPath);
2084
+ }
2085
+
2086
+ return [startPath[0], endPath[0]];
2087
+ }
2088
+
2089
+ function hideRect(el) {
2090
+ el.removeAttribute('style');
2091
+ }
2092
+
2093
+ function updateRect(editor, startIndex, endIndex, outer, el, inner) {
2094
+ var _getDOMNodes = getDOMNodes(editor, startIndex, endIndex),
2095
+ _getDOMNodes2 = _slicedToArray(_getDOMNodes, 2),
2096
+ startDOMNode = _getDOMNodes2[0],
2097
+ endDOMNode = _getDOMNodes2[1];
2098
+
2099
+ if (startDOMNode && endDOMNode) {
2100
+ var startRect = startDOMNode.getBoundingClientRect();
2101
+ var endRect = endDOMNode.getBoundingClientRect();
2102
+ var outerRect = outer.getBoundingClientRect();
2103
+ el.style.display = 'block';
2104
+ el.style.top = "".concat(startRect.top - outerRect.top, "px");
2105
+ inner.style.height = "".concat(endRect.bottom - startRect.top, "px");
2106
+ }
2107
+ }
2108
+
2109
+ function getDOMNodes(editor, startIndex, endIndex) {
2110
+ var startNode = Node.get(editor, [startIndex]);
2111
+ var endNode = Node.get(editor, [endIndex]);
2112
+
2113
+ try {
2114
+ var startDOMNode = ReactEditor.toDOMNode(editor, startNode);
2115
+ var endDOMNode = ReactEditor.toDOMNode(editor, endNode);
2116
+ return [startDOMNode, endDOMNode];
2117
+ } catch (e) {
2118
+ return [];
2119
+ }
2120
+ }
2121
+
2122
+ var listTypes = ['numbered-list', 'bulleted-list'];
2123
+
2124
+ function toggleBlock(editor, format) {
2125
+ var isActive = isBlockActive(editor, format);
2126
+ var isList = listTypes.includes(format);
2127
+ Transforms.unwrapNodes(editor, {
2128
+ match: function match(n) {
2129
+ return listTypes.includes(n.type);
2130
+ },
2131
+ split: true
2132
+ });
2133
+ Transforms.setNodes(editor, {
2134
+ type: isActive ? 'paragraph' : isList ? 'list-item' : format
2135
+ });
2136
+
2137
+ if (!isActive && isList) {
2138
+ var block = {
2139
+ type: format,
2140
+ children: []
2141
+ };
2142
+ Transforms.wrapNodes(editor, block);
2143
+ }
2144
+ }
2145
+
2146
+ function isBlockActive(editor, format) {
2147
+ var _Editor$nodes = Editor.nodes(editor, {
2148
+ match: function match(n) {
2149
+ return n.type === format;
2150
+ }
2151
+ }),
2152
+ _Editor$nodes2 = _slicedToArray(_Editor$nodes, 1),
2153
+ match = _Editor$nodes2[0];
2154
+
2155
+ return !!match;
2156
+ }
2157
+
2158
+ function toolbarButtons(t) {
2159
+ return [{
2160
+ name: 'paragraph',
2161
+ text: t('pageflow_scrolled.inline_editing.formats.paragraph'),
2162
+ icon: TextIcon
2163
+ }, {
2164
+ name: 'heading',
2165
+ text: t('pageflow_scrolled.inline_editing.formats.heading'),
2166
+ icon: HeadingIcon
2167
+ }, {
2168
+ name: 'numbered-list',
2169
+ text: t('pageflow_scrolled.inline_editing.formats.ordered_list'),
2170
+ icon: OlIcon
2171
+ }, {
2172
+ name: 'bulleted-list',
2173
+ text: t('pageflow_scrolled.inline_editing.formats.bulleted_list'),
2174
+ icon: UlIcon
2175
+ }, {
2176
+ name: 'block-quote',
2177
+ text: t('pageflow_scrolled.inline_editing.formats.block_quote'),
2178
+ icon: QuoteIcon
2179
+ }];
2180
+ }
2181
+
2182
+ var styles$8 = {"container":"DropTargets-module_container__3vudG","dropTarget":"DropTargets-module_dropTarget__3mmox","dropIndicator":"DropTargets-module_dropIndicator__2zu4d","isOver":"DropTargets-module_isOver__2usWn"};
2183
+
2184
+ function DropTargets$1(_ref) {
2185
+ var contentElementId = _ref.contentElementId;
2186
+ var editor = useSlate();
2187
+
2188
+ var _useState = useState(),
2189
+ _useState2 = _slicedToArray(_useState, 2),
2190
+ targets = _useState2[0],
2191
+ setTargets = _useState2[1];
2192
+
2193
+ var containerRef = useRef();
2194
+ useEffect(function () {
2195
+ if (!targets) {
2196
+ setTargets(measureHeights(editor, containerRef.current));
2197
+ }
2198
+ }, [targets, editor]);
2199
+ return (
2200
+ /*#__PURE__*/
2201
+ React.createElement("div", {
2202
+ ref: containerRef,
2203
+ className: styles$8.container
2204
+ }, renderDropTargets(targets || [], contentElementId))
2205
+ );
2206
+ }
2207
+
2208
+ function renderDropTargets(targets, contentElementId) {
2209
+ function handleDrop(itemId, index) {
2210
+ if (index === 0) {
2211
+ postMoveContentElementMessage({
2212
+ id: itemId,
2213
+ to: {
2214
+ at: 'before',
2215
+ id: contentElementId
2216
+ }
2217
+ });
2218
+ } else if (index === targets.length - 1) {
2219
+ postMoveContentElementMessage({
2220
+ id: itemId,
2221
+ to: {
2222
+ at: 'after',
2223
+ id: contentElementId
2224
+ }
2225
+ });
2226
+ } else {
2227
+ postMoveContentElementMessage({
2228
+ id: itemId,
2229
+ to: {
2230
+ at: 'split',
2231
+ id: contentElementId,
2232
+ splitPoint: index
2233
+ }
2234
+ });
2235
+ }
2236
+ }
2237
+
2238
+ return targets.map(function (target, index) {
2239
+ return (
2240
+ /*#__PURE__*/
2241
+ React.createElement(DropTarget, Object.assign({}, target, {
2242
+ key: index,
2243
+ onDrop: function onDrop(itemId) {
2244
+ return handleDrop(itemId, index);
2245
+ }
2246
+ }))
2247
+ );
2248
+ });
2249
+ }
2250
+
2251
+ function DropTarget(_ref2) {
2252
+ var top = _ref2.top,
2253
+ height = _ref2.height,
2254
+ indicatorTop = _ref2.indicatorTop,
2255
+ onDrop = _ref2.onDrop;
2256
+
2257
+ var _useDrop = useDrop({
2258
+ accept: 'contentElement',
2259
+ collect: function collect(monitor) {
2260
+ return {
2261
+ isOver: monitor.isOver()
2262
+ };
2263
+ },
2264
+ drop: function drop(item) {
2265
+ return onDrop(item.id);
2266
+ }
2267
+ }),
2268
+ _useDrop2 = _slicedToArray(_useDrop, 2),
2269
+ isOver = _useDrop2[0].isOver,
2270
+ drop = _useDrop2[1];
2271
+
2272
+ return (
2273
+ /*#__PURE__*/
2274
+ React.createElement("div", {
2275
+ ref: drop,
2276
+ className: classNames(styles$8.dropTarget, _defineProperty({}, styles$8.isOver, isOver)),
2277
+ style: {
2278
+ top: top,
2279
+ height: height
2280
+ }
2281
+ },
2282
+ /*#__PURE__*/
2283
+ React.createElement("div", {
2284
+ className: styles$8.dropIndicator,
2285
+ style: {
2286
+ top: indicatorTop
2287
+ }
2288
+ }))
2289
+ );
2290
+ }
2291
+
2292
+ function measureHeights(editor, container) {
2293
+ var containerRect = container.getBoundingClientRect();
2294
+ var lastTargetDimensions = {
2295
+ top: 0,
2296
+ height: 0
2297
+ };
2298
+ var lastRectBottom = 0;
2299
+ var targetDimensions = editor.children.map(function (child, index) {
2300
+ var node = Node.get(editor, [index]);
2301
+ var domNode = ReactEditor.toDOMNode(editor, node);
2302
+ var rect = domNode.getBoundingClientRect();
2303
+ var top = lastTargetDimensions.top + lastTargetDimensions.height;
2304
+ var bottom = rect.top + rect.height / 2 - containerRect.top;
2305
+ var targetDimensions = {
2306
+ top: top,
2307
+ height: bottom - top,
2308
+ indicatorTop: index > 0 ? lastRectBottom + (rect.top - lastRectBottom) / 2 - containerRect.top - top : 0
2309
+ };
2310
+ lastRectBottom = rect.bottom;
2311
+ lastTargetDimensions = targetDimensions;
2312
+ return targetDimensions;
2313
+ });
2314
+ return [].concat(_toConsumableArray(targetDimensions), [{
2315
+ top: lastTargetDimensions.top + lastTargetDimensions.height,
2316
+ height: containerRect.height - (lastTargetDimensions.top + lastTargetDimensions.height),
2317
+ indicatorTop: containerRect.height - (lastTargetDimensions.top + lastTargetDimensions.height)
2318
+ }]);
2319
+ }
2320
+
2321
+ var EditableText = React.memo(function EditableText(_ref) {
2322
+ var value = _ref.value,
2323
+ contentElementId = _ref.contentElementId,
2324
+ placeholder = _ref.placeholder,
2325
+ onChange = _ref.onChange;
2326
+ var editor = useMemo(function () {
2327
+ return withLinks(withCustomInsertBreak(withReact(createEditor())));
2328
+ }, []);
2329
+
2330
+ var _useState = useState(),
2331
+ _useState2 = _slicedToArray(_useState, 2),
2332
+ linkSelection = _useState2[0],
2333
+ setLinkSelection = _useState2[1];
2334
+
2335
+ var _useCachedValue = useCachedValue(value, {
2336
+ defaultValue: [{
2337
+ type: 'paragraph',
2338
+ children: [{
2339
+ text: ''
2340
+ }]
2341
+ }],
2342
+ onDebouncedChange: onChange,
2343
+ onReset: function onReset(nextValue) {
2344
+ return resetSelectionIfOutsideNextValue(editor, nextValue);
2345
+ }
2346
+ }),
2347
+ _useCachedValue2 = _slicedToArray(_useCachedValue, 2),
2348
+ cachedValue = _useCachedValue2[0],
2349
+ setCachedValue = _useCachedValue2[1];
2350
+
2351
+ useContentElementEditorCommandSubscription(function (command) {
2352
+ if (command.type === 'REMOVE') {
2353
+ Transforms.removeNodes(editor, {
2354
+ mode: 'highest'
2355
+ });
2356
+ }
2357
+ });
2358
+
2359
+ var _useDropTargetsActive = useDropTargetsActive(),
2360
+ _useDropTargetsActive2 = _slicedToArray(_useDropTargetsActive, 2),
2361
+ dropTargetsActive = _useDropTargetsActive2[0],
2362
+ ref = _useDropTargetsActive2[1];
2363
+
2364
+ var decorate = useCallback(function (nodeEntry) {
2365
+ return decorateLinkSelection(nodeEntry, linkSelection);
2366
+ }, [linkSelection]); // Ensure Slate rerenders when decorations change
2367
+ // https://github.com/ianstormtaylor/slate/issues/3447
2368
+
2369
+ var renderLeaf = useCallback(function (options) {
2370
+ return renderLeafWithLinkSelection(options);
2371
+ }, [linkSelection]); // eslint-disable-line react-hooks/exhaustive-deps
2372
+
2373
+ return (
2374
+ /*#__PURE__*/
2375
+ React.createElement(Text$1, {
2376
+ scaleCategory: "body"
2377
+ },
2378
+ /*#__PURE__*/
2379
+ React.createElement("div", {
2380
+ className: styles$7.container,
2381
+ ref: ref
2382
+ },
2383
+ /*#__PURE__*/
2384
+ React.createElement(Slate, {
2385
+ editor: editor,
2386
+ value: cachedValue,
2387
+ onChange: setCachedValue
2388
+ },
2389
+ /*#__PURE__*/
2390
+ React.createElement(LinkTooltipProvider, {
2391
+ disabled: !!linkSelection
2392
+ },
2393
+ /*#__PURE__*/
2394
+ React.createElement(Selection, {
2395
+ contentElementId: contentElementId
2396
+ }), dropTargetsActive &&
2397
+ /*#__PURE__*/
2398
+ React.createElement(DropTargets$1, {
2399
+ contentElementId: contentElementId
2400
+ }),
2401
+ /*#__PURE__*/
2402
+ React.createElement(HoveringToolbar, {
2403
+ linkSelection: linkSelection,
2404
+ setLinkSelection: setLinkSelection
2405
+ }),
2406
+ /*#__PURE__*/
2407
+ React.createElement(Editable, {
2408
+ decorate: decorate,
2409
+ renderElement: renderElementWithLinkPreview,
2410
+ renderLeaf: renderLeaf
2411
+ }))),
2412
+ /*#__PURE__*/
2413
+ React.createElement(TextPlaceholder, {
2414
+ text: placeholder,
2415
+ visible: isBlank(cachedValue)
2416
+ })))
2417
+ );
2418
+ });
2419
+
2420
+ function isBlank(value) {
2421
+ var _value$, _value$2, _value$2$children$;
2422
+
2423
+ return value.length <= 1 && ((_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.children.length) <= 1 && value[0].type === 'paragraph' && !((_value$2 = value[0]) === null || _value$2 === void 0 ? void 0 : (_value$2$children$ = _value$2.children[0]) === null || _value$2$children$ === void 0 ? void 0 : _value$2$children$.text);
2424
+ }
2425
+
2426
+ function resetSelectionIfOutsideNextValue(editor, nextValue) {
2427
+ var nextEditor = {
2428
+ children: nextValue
2429
+ };
2430
+
2431
+ if (editor.selection && (!Node.has(nextEditor, editor.selection.anchor.path) || !Node.has(nextEditor, editor.selection.focus.path))) {
2432
+ Transforms.deselect(editor);
2433
+ }
2434
+ }
2435
+
2436
+ var EditableInlineText = memo(function EditableInlineText(_ref) {
2437
+ var _cachedValue$, _cachedValue$$childre;
2438
+
2439
+ var value = _ref.value,
2440
+ _ref$defaultValue = _ref.defaultValue,
2441
+ defaultValue = _ref$defaultValue === void 0 ? '' : _ref$defaultValue,
2442
+ placeholder = _ref.placeholder,
2443
+ onChange = _ref.onChange;
2444
+ var editor = useMemo(function () {
2445
+ return withSingleLine(withReact(createEditor()));
2446
+ }, []);
2447
+
2448
+ var _useCachedValue = useCachedValue(value, {
2449
+ defaultValue: [{
2450
+ type: 'heading',
2451
+ children: [{
2452
+ text: defaultValue
2453
+ }]
2454
+ }],
2455
+ onDebouncedChange: onChange
2456
+ }),
2457
+ _useCachedValue2 = _slicedToArray(_useCachedValue, 2),
2458
+ cachedValue = _useCachedValue2[0],
2459
+ setCachedValue = _useCachedValue2[1];
2460
+
2461
+ return (
2462
+ /*#__PURE__*/
2463
+ React.createElement(React.Fragment, null,
2464
+ /*#__PURE__*/
2465
+ React.createElement(Slate, {
2466
+ editor: editor,
2467
+ value: cachedValue,
2468
+ onChange: setCachedValue
2469
+ },
2470
+ /*#__PURE__*/
2471
+ React.createElement(Editable, null)),
2472
+ /*#__PURE__*/
2473
+ React.createElement(TextPlaceholder, {
2474
+ text: placeholder,
2475
+ visible: !((_cachedValue$ = cachedValue[0]) === null || _cachedValue$ === void 0 ? void 0 : (_cachedValue$$childre = _cachedValue$.children[0]) === null || _cachedValue$$childre === void 0 ? void 0 : _cachedValue$$childre.text)
2476
+ }))
2477
+ );
2478
+ });
2479
+
2480
+ function withSingleLine(editor) {
2481
+ var normalizeNode = editor.normalizeNode;
2482
+
2483
+ editor.normalizeNode = function (_ref2) {
2484
+ var _ref3 = _slicedToArray(_ref2, 2),
2485
+ node = _ref3[0],
2486
+ path = _ref3[1];
2487
+
2488
+ if (path.length === 0) {
2489
+ if (editor.children.length > 1) {
2490
+ Transforms.mergeNodes(editor);
2491
+ }
2492
+ }
2493
+
2494
+ return normalizeNode([node, path]);
2495
+ };
2496
+
2497
+ return editor;
2498
+ }
2499
+
2500
+ function PhonePlatformProvider(_ref) {
2501
+ var children = _ref.children;
2502
+
2503
+ var _useState = useState(false),
2504
+ _useState2 = _slicedToArray(_useState, 2),
2505
+ phoneEmulationMode = _useState2[0],
2506
+ setPhoneEmulationMode = _useState2[1];
2507
+
2508
+ useEffect(function () {
2509
+ window.addEventListener('message', receive);
2510
+
2511
+ function receive(event) {
2512
+ if (event.data.type === 'CHANGE_EMULATION_MODE') {
2513
+ if (event.data['payload'] === 'phone') {
2514
+ setPhoneEmulationMode(true);
2515
+ } else {
2516
+ setPhoneEmulationMode(false);
2517
+ }
2518
+ }
2519
+ }
2520
+
2521
+ return function () {
2522
+ return window.removeEventListener('message', receive);
2523
+ };
2524
+ });
2525
+ return (
2526
+ /*#__PURE__*/
2527
+ React.createElement(PhonePlatformContext.Provider, {
2528
+ value: phoneEmulationMode
2529
+ }, children)
2530
+ );
2531
+ }
2532
+
2533
+ export { ContentElementDecorator, EditableInlineText, EditableText, EntryDecorator, LayoutWithPlaceholder, PhonePlatformProvider, SectionDecorator };