pageflow 15.2.2 → 15.3.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of pageflow might be problematic. Click here for more details.

Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +338 -85
  3. data/admins/pageflow/accounts.rb +1 -98
  4. data/admins/pageflow/entry.rb +21 -1
  5. data/admins/pageflow/entry_templates.rb +140 -0
  6. data/admins/pageflow/membership.rb +12 -0
  7. data/admins/pageflow/user.rb +5 -3
  8. data/app/assets/javascripts/pageflow/admin/entries.js +65 -0
  9. data/app/assets/javascripts/pageflow/admin/users.js +1 -1
  10. data/app/assets/javascripts/pageflow/asset_urls.js.erb +1 -0
  11. data/app/assets/javascripts/pageflow/base.js +0 -12
  12. data/app/assets/javascripts/pageflow/components.js +2 -6
  13. data/app/assets/javascripts/pageflow/dist/ui.js +47 -14
  14. data/app/assets/javascripts/pageflow/vendor.js +13 -10
  15. data/app/assets/stylesheets/pageflow/base.scss +0 -7
  16. data/app/assets/stylesheets/pageflow/editor/base.scss +2 -0
  17. data/app/assets/stylesheets/pageflow/editor/composables.scss +5 -1
  18. data/app/assets/stylesheets/pageflow/editor/emulation_mode_button.scss +44 -55
  19. data/app/assets/stylesheets/pageflow/editor/help.scss +2 -2
  20. data/app/assets/stylesheets/pageflow/ui/tooltip.scss +17 -3
  21. data/app/helpers/pageflow/admin/entries_helper.rb +16 -0
  22. data/app/helpers/pageflow/structured_data_helper.rb +0 -2
  23. data/app/models/pageflow/account.rb +21 -1
  24. data/app/models/pageflow/entry.rb +9 -2
  25. data/app/models/pageflow/entry_duplicate.rb +1 -0
  26. data/app/models/pageflow/entry_template.rb +16 -2
  27. data/app/policies/pageflow/account_policy.rb +10 -0
  28. data/app/policies/pageflow/entry_template_policy.rb +5 -1
  29. data/app/views/admin/accounts/_entry_template_details.html.arb +7 -5
  30. data/app/views/admin/accounts/_form.html.erb +3 -49
  31. data/app/views/admin/entries/_attributes_table.html.arb +5 -0
  32. data/app/views/admin/entries/_not_allowed_to_see_entry_types.json.jbuilder +2 -0
  33. data/app/views/admin/entries/entry_types.json.jbuilder +4 -0
  34. data/app/views/admin/entry_templates/_form.html.erb +58 -0
  35. data/app/views/admin/users/_not_allowed_to_see_user_quota.html.erb +3 -0
  36. data/app/views/components/pageflow/admin/entry_templates_tab.rb +48 -0
  37. data/app/views/pageflow/admin/users/_quota_exhausted.html.erb +1 -1
  38. data/config/initializers/admin_resource_tabs.rb +5 -0
  39. data/config/initializers/help_entries.rb +1 -5
  40. data/config/locales/de.yml +88 -155
  41. data/config/locales/en.yml +79 -143
  42. data/db/migrate/20200515112500_add_constraints_to_entry_templates.rb +21 -0
  43. data/db/migrate/20200807135200_rename_pageflow_entry_template_entry_type_to_entry_type_name.rb +7 -0
  44. data/entry_types/paged/app/assets/javascripts/pageflow_paged/components.js +7 -0
  45. data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/editor.js +1479 -1391
  46. data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/frontend.js +9218 -0
  47. data/{app/assets/javascripts/pageflow → entry_types/paged/app/assets/javascripts/pageflow_paged}/dist/react-client.js +1 -1
  48. data/{app/assets/javascripts/pageflow → entry_types/paged/app/assets/javascripts/pageflow_paged}/dist/react-server.js +3 -3
  49. data/entry_types/paged/app/assets/javascripts/pageflow_paged/frontend.js +6 -0
  50. data/entry_types/paged/app/assets/javascripts/pageflow_paged/server_rendering.js +9 -0
  51. data/entry_types/paged/app/assets/javascripts/pageflow_paged/vendor.js +8 -0
  52. data/entry_types/paged/app/controllers/pageflow_paged/application_controller.rb +2 -2
  53. data/{app/helpers/pageflow → entry_types/paged/app/helpers/pageflow_paged}/page_background_asset_helper.rb +4 -3
  54. data/{app/helpers/pageflow → entry_types/paged/app/helpers/pageflow_paged}/react_server_side_rendering_helper.rb +23 -2
  55. data/entry_types/paged/app/views/layouts/pageflow_paged/application.html.erb +2 -2
  56. data/entry_types/paged/app/views/pageflow_paged/editor/entries/_head.html.erb +2 -2
  57. data/entry_types/paged/app/views/pageflow_paged/entries/_entry.html.erb +1 -1
  58. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/page_background_asset/_element.html.erb +0 -0
  59. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/react/_widget.html.erb +0 -0
  60. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/react/page.html.erb +0 -0
  61. data/entry_types/paged/config/initializers/features.rb +1 -1
  62. data/entry_types/paged/config/initializers/help_entries.rb +17 -0
  63. data/entry_types/paged/config/locales/new/help.de.yml +162 -0
  64. data/entry_types/paged/config/locales/new/help.en.yml +153 -0
  65. data/entry_types/paged/lib/pageflow_paged/engine.rb +13 -0
  66. data/entry_types/paged/lib/pageflow_paged/plugin.rb +5 -1
  67. data/entry_types/paged/lib/pageflow_paged/react.rb +12 -0
  68. data/{lib/pageflow → entry_types/paged/lib/pageflow_paged}/react/page_type.rb +2 -2
  69. data/{lib/pageflow → entry_types/paged/lib/pageflow_paged}/react/widget_type.rb +2 -2
  70. data/entry_types/paged/vendor/assets/javascripts/development/pageflow_paged/vendor/react-server.js +20613 -0
  71. data/entry_types/paged/vendor/assets/javascripts/development/pageflow_paged/vendor/react.js +21495 -0
  72. data/entry_types/paged/vendor/assets/javascripts/production/pageflow_paged/vendor/react-server.js +24 -0
  73. data/entry_types/paged/vendor/assets/javascripts/production/pageflow_paged/vendor/react.js +24 -0
  74. data/entry_types/scrolled/app/assets/javascripts/pageflow_scrolled/legacy.js +0 -0
  75. data/entry_types/scrolled/app/controllers/pageflow_scrolled/editor/chapters_controller.rb +2 -2
  76. data/entry_types/scrolled/app/controllers/pageflow_scrolled/editor/content_elements_controller.rb +14 -4
  77. data/entry_types/scrolled/app/controllers/pageflow_scrolled/editor/sections_controller.rb +2 -2
  78. data/entry_types/scrolled/app/controllers/pageflow_scrolled/entries_controller.rb +8 -0
  79. data/entry_types/scrolled/app/helpers/pageflow_scrolled/editor/seed_html_helper.rb +6 -0
  80. data/entry_types/scrolled/app/helpers/pageflow_scrolled/entry_json_seed_helper.rb +2 -0
  81. data/entry_types/scrolled/app/helpers/pageflow_scrolled/react_server_side_rendering_helper.rb +33 -0
  82. data/entry_types/scrolled/app/helpers/pageflow_scrolled/themes_helper.rb +8 -0
  83. data/entry_types/scrolled/app/models/pageflow_scrolled/content_element.rb +38 -0
  84. data/entry_types/scrolled/app/views/pageflow_scrolled/editor/content_elements/batch.json.jbuilder +2 -0
  85. data/entry_types/scrolled/app/views/pageflow_scrolled/editor/entries/_head.html.erb +1 -7
  86. data/entry_types/scrolled/app/views/pageflow_scrolled/entries/show.html.erb +19 -3
  87. data/entry_types/scrolled/app/views/pageflow_scrolled/entry_json_seed/_entry.json.jbuilder +3 -0
  88. data/entry_types/scrolled/app/views/pageflow_scrolled/entry_json_seed/_theme.json.jbuilder +7 -0
  89. data/entry_types/scrolled/config/initializers/help_entries.rb +16 -0
  90. data/entry_types/scrolled/config/locales/new/de.yml +345 -13
  91. data/entry_types/scrolled/config/locales/new/en.yml +257 -14
  92. data/entry_types/scrolled/config/routes.rb +1 -0
  93. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/install_generator.rb +28 -0
  94. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/logoDesktop.svg +56 -0
  95. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/logoMobile.svg +22 -0
  96. data/entry_types/scrolled/lib/pageflow_scrolled/engine.rb +4 -0
  97. data/entry_types/scrolled/lib/pageflow_scrolled/plugin.rb +3 -1
  98. data/entry_types/scrolled/lib/pageflow_scrolled/seeds.rb +90 -30
  99. data/entry_types/scrolled/lib/tasks/pageflow_scrolled_tasks.rake +64 -27
  100. data/entry_types/scrolled/package/contentElements-editor.js +242 -183
  101. data/entry_types/scrolled/package/contentElements-frontend.css +1 -0
  102. data/entry_types/scrolled/package/contentElements-frontend.js +624 -279
  103. data/entry_types/scrolled/package/editor.js +2561 -363
  104. data/entry_types/scrolled/package/frontend-server.js +228 -0
  105. data/entry_types/scrolled/package/frontend/EditableText-4264c349.js +1993 -0
  106. data/entry_types/scrolled/package/frontend/Wavesurfer-c3c45324.js +378 -0
  107. data/entry_types/scrolled/package/frontend/components-cfe6a479.js +2115 -0
  108. data/entry_types/scrolled/package/frontend/getPrototypeOf-63c7c8e8.js +86 -0
  109. data/entry_types/scrolled/package/frontend/index.css +9 -0
  110. data/entry_types/scrolled/package/frontend/index.js +4425 -0
  111. data/entry_types/scrolled/package/package.json +17 -6
  112. data/entry_types/scrolled/spec/fixtures/audio.m4a +0 -0
  113. data/entry_types/scrolled/spec/fixtures/video.mp4 +0 -0
  114. data/lib/generators/pageflow/initializer/templates/pageflow.rb +20 -9
  115. data/lib/pageflow/ability_mixin.rb +14 -2
  116. data/lib/pageflow/configuration.rb +6 -5
  117. data/lib/pageflow/engine.rb +1 -0
  118. data/lib/pageflow/entry_type_configuration.rb +1 -0
  119. data/lib/pageflow/global_config_api.rb +5 -4
  120. data/lib/pageflow/react.rb +4 -2
  121. data/lib/pageflow/version.rb +1 -1
  122. data/{packages/pageflow → package}/config/jest/index.js +2 -1
  123. data/{packages/pageflow → package}/config/jest/transformers/jst.js +0 -0
  124. data/{packages/pageflow → package}/config/jest/transformers/upwardBabel.js +0 -0
  125. data/package/config/webpack.js +22 -0
  126. data/{packages/pageflow → package}/editor.js +480 -1129
  127. data/package/frontend.js +2525 -0
  128. data/{packages/pageflow → package}/package.json +3 -0
  129. data/{packages/pageflow → package}/testHelpers.js +114 -13
  130. data/{packages/pageflow → package}/ui.js +47 -14
  131. data/spec/factories/accounts.rb +3 -1
  132. data/spec/factories/entry_templates.rb +1 -0
  133. data/spec/factories/published_entries.rb +6 -1
  134. metadata +62 -26
  135. data/app/assets/javascripts/pageflow/dist/frontend.js +0 -5800
  136. data/config/initializers/entry_types.rb +0 -4
  137. data/entry_types/scrolled/package/frontend.js +0 -2879
  138. data/packages/pageflow/config/jest/transformers/cssModules.js +0 -1
  139. data/packages/pageflow/config/webpack.js +0 -14
@@ -0,0 +1,378 @@
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
+ * @description Capitalise the first letter of a string
39
+ */
40
+
41
+ function capitaliseFirstLetter(string) {
42
+ return string.split('-').map(function (part) {
43
+ return part.charAt(0).toUpperCase() + part.slice(1);
44
+ }).join('');
45
+ }
46
+
47
+ var Wavesurfer =
48
+ /*#__PURE__*/
49
+ function (_Component) {
50
+ _inherits(Wavesurfer, _Component);
51
+
52
+ var _super = _createSuper(Wavesurfer);
53
+
54
+ function Wavesurfer(props) {
55
+ var _this;
56
+
57
+ _classCallCheck(this, Wavesurfer);
58
+
59
+ _this = _super.call(this, props);
60
+ _this.state = {
61
+ isReady: false
62
+ };
63
+
64
+ if (typeof WaveSurfer === undefined) {
65
+ throw new Error('WaveSurfer is undefined!');
66
+ }
67
+
68
+ _this._wavesurfer = Object.create(WaveSurfer);
69
+ _this._loadMediaElt = _this._loadMediaElt.bind(_assertThisInitialized(_this));
70
+ _this._loadAudio = _this._loadAudio.bind(_assertThisInitialized(_this));
71
+ _this._seekTo = _this._seekTo.bind(_assertThisInitialized(_this));
72
+
73
+ _this._handleResize = function () {
74
+ if (_this.state.isReady) {
75
+ _this._wavesurfer.refresh();
76
+ }
77
+ };
78
+
79
+ return _this;
80
+ }
81
+
82
+ _createClass(Wavesurfer, [{
83
+ key: "componentDidMount",
84
+ value: function componentDidMount() {
85
+ var _this2 = this;
86
+
87
+ var options = assign({}, this.props.options, {
88
+ container: this.wavesurferEl
89
+ }); // media element loading is only supported by MediaElement backend
90
+
91
+ if (this.props.mediaElt) {
92
+ options.backend = 'MediaElement';
93
+ }
94
+
95
+ this._wavesurfer.init(options); // file was loaded, wave was drawn
96
+
97
+
98
+ this._wavesurfer.on('ready', function () {
99
+ _this2.setState({
100
+ isReady: true,
101
+ pos: _this2.props.pos
102
+ }); // set initial position
103
+
104
+
105
+ if (_this2.props.pos) {
106
+ _this2._seekTo(_this2.props.pos);
107
+ } // set initial volume
108
+
109
+
110
+ if (_this2.props.volume != null) {
111
+ _this2._wavesurfer.setVolume(_this2.props.volume);
112
+ } // set initial playing state
113
+
114
+
115
+ if (_this2.props.playing) {
116
+ _this2.wavesurfer.play();
117
+ } // set initial zoom
118
+
119
+
120
+ if (_this2.props.zoom) {
121
+ _this2._wavesurfer.zoom(_this2.props.zoom);
122
+ }
123
+ });
124
+
125
+ this._wavesurfer.on('audioprocess', function (pos) {
126
+ _this2.setState({
127
+ pos: pos
128
+ });
129
+
130
+ _this2.props.onPosChange({
131
+ wavesurfer: _this2._wavesurfer,
132
+ originalArgs: [pos]
133
+ });
134
+ }); // `audioprocess` is not fired when seeking, so we have to plug into the
135
+ // `seek` event and calculate the equivalent in seconds (seek event
136
+ // receives a position float 0-1) – See the README.md for explanation why we
137
+ // need this
138
+
139
+
140
+ this._wavesurfer.on('seek', function (pos) {
141
+ var formattedPos = _this2._posToSec(pos);
142
+
143
+ _this2.setState({
144
+ formattedPos: formattedPos
145
+ });
146
+
147
+ _this2.props.onPosChange({
148
+ wavesurfer: _this2._wavesurfer,
149
+ originalArgs: [formattedPos]
150
+ });
151
+ }); // hook up events to callback handlers passed in as props
152
+
153
+
154
+ EVENTS.forEach(function (e) {
155
+ var propCallback = _this2.props["on".concat(capitaliseFirstLetter(e))];
156
+
157
+ var wavesurfer = _this2._wavesurfer;
158
+
159
+ if (propCallback) {
160
+ _this2._wavesurfer.on(e, function () {
161
+ for (var _len = arguments.length, originalArgs = new Array(_len), _key = 0; _key < _len; _key++) {
162
+ originalArgs[_key] = arguments[_key];
163
+ }
164
+
165
+ propCallback({
166
+ wavesurfer: wavesurfer,
167
+ originalArgs: originalArgs
168
+ });
169
+ });
170
+ }
171
+ }); // if audioFile prop, load file
172
+
173
+ if (this.props.audioFile) {
174
+ this._loadAudio(this.props.audioFile, this.props.audioPeaks);
175
+ } // if mediaElt prop, load media Element
176
+
177
+
178
+ if (this.props.mediaElt) {
179
+ this._loadMediaElt(this.props.mediaElt, this.props.audioPeaks);
180
+ }
181
+ } // update wavesurfer rendering manually
182
+
183
+ }, {
184
+ key: "componentDidUpdate",
185
+ value: function componentDidUpdate(prevProps) {
186
+ // update audioFile
187
+ if (this.props.audioFile !== this.props.audioFile) {
188
+ this._loadAudio(this.props.audioFile, this.props.audioPeaks);
189
+ } // update mediaElt
190
+
191
+
192
+ if (prevProps.mediaElt !== this.props.mediaElt) {
193
+ this._loadMediaElt(this.props.mediaElt, this.props.audioPeaks);
194
+ } // update peaks
195
+
196
+
197
+ if (prevProps.audioPeaks !== this.props.audioPeaks) {
198
+ if (this.props.mediaElt) {
199
+ this._loadMediaElt(prevProps.mediaElt, this.props.audioPeaks);
200
+ } else {
201
+ this._loadAudio(this.props.audioFile, this.props.audioPeaks);
202
+ }
203
+ } // update position
204
+
205
+
206
+ if (this.props.pos && this.state.isReady && prevProps.pos !== this.props.pos && this.props.pos !== this.state.pos) {
207
+ this._seekTo(this.props.pos);
208
+ } // update playing state
209
+
210
+
211
+ if (this.props.playing !== prevProps.playing) {
212
+ if (this.props.playing) {
213
+ this._wavesurfer.play();
214
+ } else {
215
+ this._wavesurfer.pause();
216
+ }
217
+ } // update volume
218
+
219
+
220
+ if (this.props.volume !== prevProps.volume) {
221
+ this._wavesurfer.setVolume(this.props.volume);
222
+ } // update volume
223
+
224
+
225
+ if (this.props.zoom !== prevProps.zoom) {
226
+ this._wavesurfer.zoom(this.props.zoom);
227
+ } // update audioRate
228
+
229
+
230
+ if (this.props.options.audioRate !== prevProps.options.audioRate) {
231
+ this._wavesurfer.setPlaybackRate(this.props.options.audioRate);
232
+ }
233
+
234
+ if (prevProps.options.waveColor !== this.props.options.waveColor) {
235
+ this._wavesurfer.setWaveColor(this.props.options.waveColor);
236
+ }
237
+
238
+ if (prevProps.options.progressColor !== this.props.options.progressColor) {
239
+ this._wavesurfer.setProgressColor(this.props.options.progressColor);
240
+ }
241
+
242
+ if (prevProps.options.cursorColor !== this.props.options.cursorColor) {
243
+ this._wavesurfer.setCursorColor(this.props.options.cursorColor);
244
+ }
245
+
246
+ if (prevProps.options.height !== this.props.options.height) {
247
+ this._wavesurfer.setHeight(this.props.options.height);
248
+ }
249
+ }
250
+ }, {
251
+ key: "componentWillUnmount",
252
+ value: function componentWillUnmount() {
253
+ var _this3 = this;
254
+
255
+ // remove listeners
256
+ EVENTS.forEach(function (e) {
257
+ _this3._wavesurfer.un(e);
258
+ }); // destroy wavesurfer instance
259
+
260
+ this._wavesurfer.destroy();
261
+ } // receives seconds and transforms this to the position as a float 0-1
262
+
263
+ }, {
264
+ key: "_secToPos",
265
+ value: function _secToPos(sec) {
266
+ return 1 / this._wavesurfer.getDuration() * sec;
267
+ } // receives position as a float 0-1 and transforms this to seconds
268
+
269
+ }, {
270
+ key: "_posToSec",
271
+ value: function _posToSec(pos) {
272
+ return pos * this._wavesurfer.getDuration();
273
+ } // pos is in seconds, the 0-1 proportional position we calculate here …
274
+
275
+ }, {
276
+ key: "_seekTo",
277
+ value: function _seekTo(sec) {
278
+ var pos = this._secToPos(sec);
279
+
280
+ if (this.props.options.autoCenter) {
281
+ this._wavesurfer.seekAndCenter(pos);
282
+ } else {
283
+ this._wavesurfer.seekTo(pos);
284
+ }
285
+ } // load a media element selector or HTML element
286
+ // if selector, get the HTML element for it
287
+ // and pass to _loadAudio
288
+
289
+ }, {
290
+ key: "_loadMediaElt",
291
+ value: function _loadMediaElt(selectorOrElt, audioPeaks) {
292
+ if (selectorOrElt instanceof global.HTMLElement) {
293
+ this._loadAudio(selectorOrElt, audioPeaks);
294
+ } else {
295
+ // Ignore if media element cannot be found. There are edge cases
296
+ // where React already unmounted the corresponding media element,
297
+ // but the parent Waveform component still holds the old media
298
+ // element id.
299
+ if (global.document.querySelector(selectorOrElt)) {
300
+ this._loadAudio(global.document.querySelector(selectorOrElt), audioPeaks);
301
+ }
302
+ }
303
+ } // pass audio data to wavesurfer
304
+
305
+ }, {
306
+ key: "_loadAudio",
307
+ value: function _loadAudio(audioFileOrElt, audioPeaks) {
308
+ if (audioFileOrElt instanceof global.HTMLElement) {
309
+ // media element
310
+ this._wavesurfer.loadMediaElement(audioFileOrElt, audioPeaks);
311
+ } else if (typeof audioFileOrElt === 'string') {
312
+ // bog-standard string is handled by load method and ajax call
313
+ this._wavesurfer.load(audioFileOrElt, audioPeaks);
314
+ } else if (audioFileOrElt instanceof global.Blob || audioFileOrElt instanceof global.File) {
315
+ // blob or file is loaded with loadBlob method
316
+ this._wavesurfer.loadBlob(audioFileOrElt, audioPeaks);
317
+ } else {
318
+ throw new Error("Wavesurfer._loadAudio expects prop audioFile\n to be either HTMLElement, string or file/blob");
319
+ }
320
+ }
321
+ }, {
322
+ key: "_measureIfResponsive",
323
+ value: function _measureIfResponsive(children) {
324
+ if (this.props.responsive) {
325
+ return (
326
+ /*#__PURE__*/
327
+ React.createElement(Measure, {
328
+ client: true,
329
+ onResize: this._handleResize
330
+ }, function (_ref) {
331
+ var measureRef = _ref.measureRef;
332
+ return (
333
+ /*#__PURE__*/
334
+ React.createElement("div", {
335
+ ref: measureRef
336
+ }, children)
337
+ );
338
+ })
339
+ );
340
+ }
341
+
342
+ return children;
343
+ }
344
+ }, {
345
+ key: "render",
346
+ value: function render() {
347
+ var _this4 = this;
348
+
349
+ var childrenWithProps = this.props.children ? React.Children.map(this.props.children, function (child) {
350
+ return React.cloneElement(child, {
351
+ wavesurfer: _this4._wavesurfer,
352
+ isReady: _this4.state.isReady
353
+ });
354
+ }) : false;
355
+ return this._measureIfResponsive(
356
+ /*#__PURE__*/
357
+ React.createElement("div", null,
358
+ /*#__PURE__*/
359
+ React.createElement("div", {
360
+ ref: function ref(c) {
361
+ _this4.wavesurferEl = c;
362
+ }
363
+ }), childrenWithProps));
364
+ }
365
+ }]);
366
+
367
+ return Wavesurfer;
368
+ }(Component);
369
+
370
+ Wavesurfer.defaultProps = {
371
+ playing: false,
372
+ pos: 0,
373
+ options: WaveSurfer.defaultParams,
374
+ responsive: true,
375
+ onPosChange: function onPosChange() {}
376
+ };
377
+
378
+ export default Wavesurfer;
@@ -0,0 +1,2115 @@
1
+ import React, { useMemo, useState, useCallback, useContext, useEffect, useRef, createContext, useLayoutEffect, memo } from 'react';
2
+ import { h as _slicedToArray, M as ContentElementEditorCommandEmitterContext, x as useEntryStateDispatch, q as usePostMessageListener, _ as _defineProperty, a as _objectWithoutProperties, u as useI18n, N as ForcePaddingContext, O as updateContentElementConfiguration, Q as ContentElementConfigurationUpdateContext, R as ContentElementEditorStateContext, B as api, G as useContentElementEditorState, U as LayoutWithoutInlineEditing, V as renderElement, W as renderLeaf, l as _objectSpread2, D as useContentElementEditorCommandSubscription, T as Text$1, P as PhonePlatformContext } from './EditableText-4264c349.js';
3
+ import classNames from 'classnames';
4
+ import 'i18n-js';
5
+ import './getPrototypeOf-63c7c8e8.js';
6
+ import BackboneEvents from 'backbone-events-standalone';
7
+ import { Range, Editor, Transforms, Text, Node, Path, createEditor } from 'slate';
8
+ import { useSlate, ReactEditor, withReact, Slate, Editable } from 'slate-react';
9
+ import debounce from 'debounce';
10
+
11
+ var Context = React.createContext({});
12
+ function EditorStateProvider(props) {
13
+ var _useState = useState(null),
14
+ _useState2 = _slicedToArray(_useState, 2),
15
+ selection = _useState2[0],
16
+ setSelectionState = _useState2[1];
17
+
18
+ var setSelection = useCallback(function (selection) {
19
+ if (window.parent !== window) {
20
+ window.parent.postMessage({
21
+ type: 'SELECTED',
22
+ payload: selection || {}
23
+ }, window.location.origin);
24
+ }
25
+
26
+ setSelectionState(selection);
27
+ }, []);
28
+ var value = useMemo(function () {
29
+ return {
30
+ selection: selection,
31
+ setSelection: setSelection
32
+ };
33
+ }, [setSelection, selection]);
34
+ return (
35
+ /*#__PURE__*/
36
+ React.createElement(Context.Provider, {
37
+ value: value
38
+ }, props.children)
39
+ );
40
+ }
41
+ function useEditorSelection(options) {
42
+ var _useContext = useContext(Context),
43
+ selection = _useContext.selection,
44
+ setSelection = _useContext.setSelection;
45
+
46
+ var resetSelection = useCallback(function () {
47
+ setSelection(null);
48
+ }, [setSelection]);
49
+ var select = useCallback(function (selection) {
50
+ setSelection(selection || options);
51
+ }, [setSelection, options]);
52
+ return useMemo(function () {
53
+ return setSelection ? {
54
+ isSelected: selection && options && selection.id === options.id && selection.type === options.type,
55
+ select: select,
56
+ resetSelection: resetSelection
57
+ } : {};
58
+ }, [options, selection, setSelection, select, resetSelection]);
59
+ }
60
+
61
+ function useContentElementEditorCommandEmitter() {
62
+ return useMemo(function () {
63
+ return Object.assign({}, BackboneEvents);
64
+ }, []);
65
+ }
66
+ function ContentElementEditorCommandSubscriptionProvider(_ref) {
67
+ var emitter = _ref.emitter,
68
+ children = _ref.children;
69
+ return (
70
+ /*#__PURE__*/
71
+ React.createElement(ContentElementEditorCommandEmitterContext.Provider, {
72
+ value: emitter
73
+ }, children)
74
+ );
75
+ }
76
+
77
+ function EntryDecorator(props) {
78
+ var contentElementEditorCommandEmitter = useContentElementEditorCommandEmitter();
79
+ return (
80
+ /*#__PURE__*/
81
+ React.createElement(EditorStateProvider, null,
82
+ /*#__PURE__*/
83
+ React.createElement(MessageHandler, {
84
+ contentElementEditorCommandEmitter: contentElementEditorCommandEmitter
85
+ }),
86
+ /*#__PURE__*/
87
+ React.createElement(ContentElementEditorCommandSubscriptionProvider, {
88
+ emitter: contentElementEditorCommandEmitter
89
+ }, props.children))
90
+ );
91
+ }
92
+
93
+ function MessageHandler(_ref) {
94
+ var contentElementEditorCommandEmitter = _ref.contentElementEditorCommandEmitter;
95
+
96
+ var _useEditorSelection = useEditorSelection(),
97
+ select = _useEditorSelection.select;
98
+
99
+ var dispatch = useEntryStateDispatch();
100
+ var receiveMessage = useCallback(function (data) {
101
+ if (data.type === 'ACTION') {
102
+ dispatch(data.payload);
103
+ } else if (data.type === 'SELECT') {
104
+ select(data.payload);
105
+ } else if (data.type === 'CONTENT_ELEMENT_EDITOR_COMMAND') {
106
+ contentElementEditorCommandEmitter.trigger("command:".concat(data.payload.contentElementId), data.payload.command);
107
+ }
108
+ }, [dispatch, select, contentElementEditorCommandEmitter]);
109
+ usePostMessageListener(receiveMessage);
110
+ useEffect(function () {
111
+ if (window.parent !== window) {
112
+ window.parent.postMessage({
113
+ type: 'READY'
114
+ }, window.location.origin);
115
+ }
116
+ }, []);
117
+ return null;
118
+ }
119
+
120
+ 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 SectionDecorator-module_toolbar__2Va1D","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"};
121
+
122
+ var styles$1 = {"wrapper":"ContentElementDecorator-module_wrapper__NQgFN"};
123
+
124
+ var styles$2 = {"Toolbar":"Toolbar-module_Toolbar__1INSj","button":"Toolbar-module_button__de5BW","activeButton":"Toolbar-module_activeButton__2sOLP","collapsible":"Toolbar-module_collapsible__3sivb"};
125
+
126
+ function Toolbar(_ref) {
127
+ var buttons = _ref.buttons,
128
+ onButtonClick = _ref.onButtonClick,
129
+ iconSize = _ref.iconSize,
130
+ collapsible = _ref.collapsible;
131
+ return (
132
+ /*#__PURE__*/
133
+ React.createElement("div", {
134
+ className: classNames(styles$2.Toolbar, _defineProperty({}, styles$2.collapsible, collapsible)),
135
+ contentEditable: false
136
+ }, buttons.map(function (button) {
137
+ var Icon = button.icon;
138
+ return (
139
+ /*#__PURE__*/
140
+ React.createElement("button", {
141
+ key: button.name,
142
+ title: button.text,
143
+ className: classNames(styles$2.button, _defineProperty({}, styles$2.activeButton, button.active)),
144
+ onMouseDown: function onMouseDown(event) {
145
+ event.preventDefault();
146
+ event.stopPropagation();
147
+ onButtonClick(button.name);
148
+ }
149
+ },
150
+ /*#__PURE__*/
151
+ React.createElement(Icon, {
152
+ width: iconSize,
153
+ height: iconSize
154
+ }))
155
+ );
156
+ }))
157
+ );
158
+ }
159
+ Toolbar.defaultProps = {
160
+ iconSize: 15
161
+ };
162
+
163
+ function _extends() {
164
+ _extends = Object.assign || function (target) {
165
+ for (var i = 1; i < arguments.length; i++) {
166
+ var source = arguments[i];
167
+
168
+ for (var key in source) {
169
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
170
+ target[key] = source[key];
171
+ }
172
+ }
173
+ }
174
+
175
+ return target;
176
+ };
177
+
178
+ return _extends.apply(this, arguments);
179
+ }
180
+ var editIcon = (function (_ref) {
181
+ var _ref$styles = _ref.styles,
182
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
183
+ props = _objectWithoutProperties(_ref, ["styles"]);
184
+
185
+ return React.createElement("svg", _extends({
186
+ "aria-hidden": "true",
187
+ "data-prefix": "fas",
188
+ "data-icon": "pencil-alt",
189
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-pencil-alt"] || "fa-pencil-alt") + " " + (styles["fa-w-16"] || "fa-w-16"),
190
+ xmlns: "http://www.w3.org/2000/svg",
191
+ viewBox: "0 0 512 512"
192
+ }, props), React.createElement("path", {
193
+ fill: "currentColor",
194
+ d: "M497.9 142.1l-46.1 46.1c-4.7 4.7-12.3 4.7-17 0l-111-111c-4.7-4.7-4.7-12.3 0-17l46.1-46.1c18.7-18.7 49.1-18.7 67.9 0l60.1 60.1c18.8 18.7 18.8 49.1 0 67.9zM284.2 99.8L21.6 362.4.4 483.9c-2.9 16.4 11.4 30.6 27.8 27.8l121.5-21.3 262.6-262.6c4.7-4.7 4.7-12.3 0-17l-111-111c-4.8-4.7-12.4-4.7-17.1 0zM124.1 339.9c-5.5-5.5-5.5-14.3 0-19.8l154-154c5.5-5.5 14.3-5.5 19.8 0s5.5 14.3 0 19.8l-154 154c-5.5 5.5-14.3 5.5-19.8 0zM88 424h48v36.3l-64.5 11.3-31.1-31.1L51.7 376H88v48z"
195
+ }));
196
+ });
197
+
198
+ function _extends$1() {
199
+ _extends$1 = Object.assign || function (target) {
200
+ for (var i = 1; i < arguments.length; i++) {
201
+ var source = arguments[i];
202
+
203
+ for (var key in source) {
204
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
205
+ target[key] = source[key];
206
+ }
207
+ }
208
+ }
209
+
210
+ return target;
211
+ };
212
+
213
+ return _extends$1.apply(this, arguments);
214
+ }
215
+ var transitionIcon = (function (_ref) {
216
+ var _ref$styles = _ref.styles,
217
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
218
+ props = _objectWithoutProperties(_ref, ["styles"]);
219
+
220
+ return React.createElement("svg", _extends$1({
221
+ "aria-hidden": "true",
222
+ "data-prefix": "fas",
223
+ "data-icon": "random",
224
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-random"] || "fa-random") + " " + (styles["fa-w-16"] || "fa-w-16"),
225
+ xmlns: "http://www.w3.org/2000/svg",
226
+ viewBox: "0 0 512 512"
227
+ }, props), React.createElement("path", {
228
+ fill: "currentColor",
229
+ 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"
230
+ }));
231
+ });
232
+
233
+ function SectionDecorator(props) {
234
+ var _useI18n = useI18n({
235
+ locale: 'ui'
236
+ }),
237
+ t = _useI18n.t;
238
+
239
+ var _useEditorSelection = useEditorSelection({
240
+ id: props.id,
241
+ type: 'section'
242
+ }),
243
+ isSelected = _useEditorSelection.isSelected,
244
+ select = _useEditorSelection.select,
245
+ resetSelection = _useEditorSelection.resetSelection;
246
+
247
+ var settingsSelection = useEditorSelection({
248
+ id: props.id,
249
+ type: 'sectionSettings'
250
+ });
251
+ var transitionSelection = useEditorSelection({
252
+ id: props.id,
253
+ type: 'sectionTransition'
254
+ });
255
+ var nextTransitionSelection = useEditorSelection({
256
+ id: props.nextSection && props.nextSection.id,
257
+ type: 'sectionTransition'
258
+ });
259
+ var lastContentElement = props.foreground[props.foreground.length - 1];
260
+
261
+ var _useEditorSelection2 = useEditorSelection({
262
+ id: lastContentElement && lastContentElement.id,
263
+ type: 'contentElement'
264
+ }),
265
+ isLastContentElementSelected = _useEditorSelection2.isSelected;
266
+
267
+ var isSectionSelected = isSelected || settingsSelection.isSelected;
268
+
269
+ function selectIfOutsideContentItem(event) {
270
+ if (!event.target.closest(".".concat(styles$1.wrapper))) {
271
+ isSelected ? resetSelection() : select();
272
+ }
273
+ }
274
+
275
+ return (
276
+ /*#__PURE__*/
277
+ React.createElement("div", {
278
+ "aria-label": t('pageflow_scrolled.inline_editing.select_section'),
279
+ className: className(isSectionSelected, transitionSelection),
280
+ onMouseDown: selectIfOutsideContentItem
281
+ },
282
+ /*#__PURE__*/
283
+ React.createElement("div", {
284
+ className: styles.controls
285
+ }, renderEditTransitionButton({
286
+ id: props.previousSection && props.id,
287
+ selection: transitionSelection,
288
+ position: 'before'
289
+ }),
290
+ /*#__PURE__*/
291
+ React.createElement("div", {
292
+ className: styles.editToolbar
293
+ },
294
+ /*#__PURE__*/
295
+ React.createElement(EditSectionButton, {
296
+ id: props.id,
297
+ selection: settingsSelection,
298
+ text: t('pageflow_scrolled.inline_editing.edit_section_settings'),
299
+ icon: editIcon
300
+ })), renderEditTransitionButton({
301
+ id: props.nextSection && props.nextSection.id,
302
+ selection: nextTransitionSelection,
303
+ position: 'after'
304
+ })),
305
+ /*#__PURE__*/
306
+ React.createElement(ForcePaddingContext.Provider, {
307
+ value: isLastContentElementSelected || isSectionSelected
308
+ }, props.children))
309
+ );
310
+ }
311
+
312
+ function className(isSectionSelected, transitionSelection) {
313
+ var _classNames;
314
+
315
+ return classNames(styles.wrapper, (_classNames = {}, _defineProperty(_classNames, styles.selected, isSectionSelected), _defineProperty(_classNames, styles.transitionSelected, transitionSelection.isSelected), _classNames));
316
+ }
317
+
318
+ function renderEditTransitionButton(_ref) {
319
+ var id = _ref.id,
320
+ position = _ref.position,
321
+ selection = _ref.selection;
322
+
323
+ if (!id) {
324
+ return null;
325
+ }
326
+
327
+ return (
328
+ /*#__PURE__*/
329
+ React.createElement("div", {
330
+ className: styles["transitionToolbar-".concat(position)]
331
+ },
332
+ /*#__PURE__*/
333
+ React.createElement(EditTransitionButton, {
334
+ id: id,
335
+ selection: selection,
336
+ position: position
337
+ }))
338
+ );
339
+ }
340
+
341
+ function EditTransitionButton(_ref2) {
342
+ var id = _ref2.id,
343
+ position = _ref2.position,
344
+ selection = _ref2.selection;
345
+
346
+ var _useI18n2 = useI18n({
347
+ locale: 'ui'
348
+ }),
349
+ t = _useI18n2.t;
350
+
351
+ return (
352
+ /*#__PURE__*/
353
+ React.createElement(EditSectionButton, {
354
+ id: id,
355
+ selection: selection,
356
+ text: t("pageflow_scrolled.inline_editing.edit_section_transition_".concat(position)),
357
+ icon: transitionIcon
358
+ })
359
+ );
360
+ }
361
+
362
+ function EditSectionButton(_ref3) {
363
+ var id = _ref3.id,
364
+ selection = _ref3.selection,
365
+ icon = _ref3.icon,
366
+ text = _ref3.text;
367
+ return (
368
+ /*#__PURE__*/
369
+ React.createElement(Toolbar, {
370
+ buttons: [{
371
+ name: 'button',
372
+ active: selection.isSelected,
373
+ icon: icon,
374
+ text: text
375
+ }],
376
+ iconSize: 20,
377
+ onButtonClick: function onButtonClick() {
378
+ return selection.select();
379
+ }
380
+ })
381
+ );
382
+ }
383
+
384
+ var styles$3 = {"selectionWidth":"1px","selectionPadding":"-6px","selectionPadding2":"-0.5em","main":"SelectionRect-module_main__3AOhG","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"};
385
+
386
+ function _extends$2() {
387
+ _extends$2 = Object.assign || function (target) {
388
+ for (var i = 1; i < arguments.length; i++) {
389
+ var source = arguments[i];
390
+
391
+ for (var key in source) {
392
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
393
+ target[key] = source[key];
394
+ }
395
+ }
396
+ }
397
+
398
+ return target;
399
+ };
400
+
401
+ return _extends$2.apply(this, arguments);
402
+ }
403
+ var PlusIcon = (function (_ref) {
404
+ var _ref$styles = _ref.styles,
405
+ props = _objectWithoutProperties(_ref, ["styles"]);
406
+
407
+ return React.createElement("svg", _extends$2({
408
+ xmlns: "http://www.w3.org/2000/svg",
409
+ viewBox: "0 0 512 512"
410
+ }, props), React.createElement("path", {
411
+ 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"
412
+ }));
413
+ });
414
+
415
+ function SelectionRect(props) {
416
+ var _classNames;
417
+
418
+ return (
419
+ /*#__PURE__*/
420
+ React.createElement("div", {
421
+ className: classNames(styles$3.main, (_classNames = {}, _defineProperty(_classNames, styles$3.full, props.full), _defineProperty(_classNames, styles$3.selected, props.selected), _defineProperty(_classNames, styles$3.start, props.selected && props.start), _defineProperty(_classNames, styles$3.end, props.selected && props.end), _classNames)),
422
+ "aria-label": props.ariaLabel,
423
+ onClick: props.onClick
424
+ }, renderToolbar(props),
425
+ /*#__PURE__*/
426
+ React.createElement(InsertButton, Object.assign({}, props, {
427
+ at: "before"
428
+ })), props.children,
429
+ /*#__PURE__*/
430
+ React.createElement(InsertButton, Object.assign({}, props, {
431
+ at: "after"
432
+ })))
433
+ );
434
+ }
435
+
436
+ function InsertButton(props) {
437
+ var _useState = useState(false),
438
+ _useState2 = _slicedToArray(_useState, 2),
439
+ insertHovered = _useState2[0],
440
+ setInsertHovered = _useState2[1];
441
+
442
+ return (
443
+ /*#__PURE__*/
444
+ React.createElement("div", {
445
+ className: classNames(styles$3["insert-".concat(props.at)], _defineProperty({}, styles$3.insertHovered, insertHovered)),
446
+ contentEditable: false
447
+ },
448
+ /*#__PURE__*/
449
+ React.createElement("button", {
450
+ className: styles$3.insertButton,
451
+ title: props.insertButtonTitles && props.insertButtonTitles[props.at],
452
+ onClick: function onClick() {
453
+ return props.onInsertButtonClick(props.at);
454
+ },
455
+ onMouseEnter: function onMouseEnter() {
456
+ return setInsertHovered(true);
457
+ },
458
+ onMouseLeave: function onMouseLeave() {
459
+ return setInsertHovered(false);
460
+ }
461
+ },
462
+ /*#__PURE__*/
463
+ React.createElement(PlusIcon, {
464
+ width: 15,
465
+ height: 15,
466
+ fill: "currentColor"
467
+ })))
468
+ );
469
+ }
470
+
471
+ function renderToolbar(_ref) {
472
+ var toolbarButtons = _ref.toolbarButtons,
473
+ onToolbarButtonClick = _ref.onToolbarButtonClick,
474
+ start = _ref.start;
475
+
476
+ if (toolbarButtons && start) {
477
+ return (
478
+ /*#__PURE__*/
479
+ React.createElement("div", {
480
+ className: styles$3.toolbar
481
+ },
482
+ /*#__PURE__*/
483
+ React.createElement(Toolbar, {
484
+ buttons: toolbarButtons,
485
+ collapsible: true,
486
+ onButtonClick: onToolbarButtonClick
487
+ }))
488
+ );
489
+ }
490
+ }
491
+
492
+ SelectionRect.defaultProps = {
493
+ start: true,
494
+ end: true
495
+ };
496
+
497
+ function postInsertContentElementMessage(_ref) {
498
+ var id = _ref.id,
499
+ at = _ref.at,
500
+ splitPoint = _ref.splitPoint;
501
+ window.parent.postMessage({
502
+ type: 'INSERT_CONTENT_ELEMENT',
503
+ payload: {
504
+ id: id,
505
+ at: at,
506
+ splitPoint: splitPoint
507
+ }
508
+ }, window.location.origin);
509
+ }
510
+ function postUpdateContentElementMessage(_ref2) {
511
+ var id = _ref2.id,
512
+ configuration = _ref2.configuration;
513
+ window.parent.postMessage({
514
+ type: 'UPDATE_CONTENT_ELEMENT',
515
+ payload: {
516
+ id: id,
517
+ configuration: configuration
518
+ }
519
+ }, window.location.origin);
520
+ }
521
+ function postUpdateTransientContentElementStateMessage(_ref3) {
522
+ var id = _ref3.id,
523
+ state = _ref3.state;
524
+ window.parent.postMessage({
525
+ type: 'UPDATE_TRANSIENT_CONTENT_ELEMENT_STATE',
526
+ payload: {
527
+ id: id,
528
+ state: state
529
+ }
530
+ }, window.location.origin);
531
+ }
532
+
533
+ function ContentElementConfigurationUpdateProvider(_ref) {
534
+ var id = _ref.id,
535
+ permaId = _ref.permaId,
536
+ children = _ref.children;
537
+ var dispatch = useEntryStateDispatch();
538
+ var update = useCallback(function (configuration) {
539
+ postUpdateContentElementMessage({
540
+ id: id,
541
+ configuration: configuration
542
+ });
543
+ updateContentElementConfiguration({
544
+ dispatch: dispatch,
545
+ permaId: permaId,
546
+ configuration: configuration
547
+ });
548
+ }, [dispatch, permaId, id]);
549
+ return (
550
+ /*#__PURE__*/
551
+ React.createElement(ContentElementConfigurationUpdateContext.Provider, {
552
+ value: update
553
+ }, children)
554
+ );
555
+ }
556
+
557
+ function ContentElementEditorStateProvider(_ref) {
558
+ var id = _ref.id,
559
+ children = _ref.children;
560
+
561
+ var _useEditorSelection = useEditorSelection({
562
+ id: id,
563
+ type: 'contentElement'
564
+ }),
565
+ isSelected = _useEditorSelection.isSelected,
566
+ select = _useEditorSelection.select;
567
+
568
+ var previousTransientState = useRef({});
569
+ var setTransientState = useCallback(function (state) {
570
+ if (!shallowEqual(state, previousTransientState.current)) {
571
+ postUpdateTransientContentElementStateMessage({
572
+ id: id,
573
+ state: state
574
+ });
575
+ previousTransientState.current = state;
576
+ }
577
+ }, [id]);
578
+ var value = useMemo(function () {
579
+ return {
580
+ isEditable: true,
581
+ select: select,
582
+ isSelected: isSelected,
583
+ setTransientState: setTransientState
584
+ };
585
+ }, [select, isSelected, setTransientState]);
586
+ return (
587
+ /*#__PURE__*/
588
+ React.createElement(ContentElementEditorStateContext.Provider, {
589
+ value: value
590
+ }, children)
591
+ );
592
+ }
593
+
594
+ function shallowEqual(obj1, obj2) {
595
+ return Object.keys(obj1).length === Object.keys(obj2).length && Object.keys(obj1).every(function (key) {
596
+ return Object.prototype.hasOwnProperty.call(obj2, key) && obj1[key] === obj2[key];
597
+ });
598
+ }
599
+
600
+ function ContentElementDecorator(props) {
601
+ return (
602
+ /*#__PURE__*/
603
+ React.createElement("div", {
604
+ className: styles$1.wrapper
605
+ },
606
+ /*#__PURE__*/
607
+ React.createElement(ContentElementEditorStateProvider, {
608
+ id: props.id
609
+ },
610
+ /*#__PURE__*/
611
+ React.createElement(OptionalSelectionRect, props,
612
+ /*#__PURE__*/
613
+ React.createElement(ContentElementConfigurationUpdateProvider, {
614
+ id: props.id,
615
+ permaId: props.permaId
616
+ }, props.children))))
617
+ );
618
+ }
619
+
620
+ function OptionalSelectionRect(props) {
621
+ var _ref = api.contentElementTypes.getOptions(props.type) || {},
622
+ customSelectionRect = _ref.customSelectionRect;
623
+
624
+ if (customSelectionRect) {
625
+ return props.children;
626
+ } else {
627
+ return (
628
+ /*#__PURE__*/
629
+ React.createElement(DefaultSelectionRect, props, props.children)
630
+ );
631
+ }
632
+ }
633
+
634
+ function DefaultSelectionRect(props) {
635
+ var _useContentElementEdi = useContentElementEditorState(),
636
+ isSelected = _useContentElementEdi.isSelected,
637
+ select = _useContentElementEdi.select;
638
+
639
+ var _useI18n = useI18n({
640
+ locale: 'ui'
641
+ }),
642
+ t = _useI18n.t;
643
+
644
+ return (
645
+ /*#__PURE__*/
646
+ React.createElement(SelectionRect, {
647
+ selected: isSelected,
648
+ full: props.position === 'full',
649
+ ariaLabel: t('pageflow_scrolled.inline_editing.select_content_element'),
650
+ insertButtonTitles: t('pageflow_scrolled.inline_editing.insert_content_element'),
651
+ onClick: function onClick() {
652
+ return select();
653
+ },
654
+ onInsertButtonClick: function onInsertButtonClick(at) {
655
+ return postInsertContentElementMessage({
656
+ id: props.id,
657
+ at: at
658
+ });
659
+ }
660
+ }, props.children)
661
+ );
662
+ }
663
+
664
+ var styles$4 = {"container":"ContentElementInsertButton-module_container__3dvUS","hovered":"ContentElementInsertButton-module_hovered__3Pggi","button":"ContentElementInsertButton-module_button__2-eE2"};
665
+
666
+ function ContentElementInsertButton(_ref) {
667
+ var onClick = _ref.onClick;
668
+
669
+ var _useState = useState(),
670
+ _useState2 = _slicedToArray(_useState, 2),
671
+ hovered = _useState2[0],
672
+ setHovered = _useState2[1];
673
+
674
+ var _useI18n = useI18n({
675
+ locale: 'ui'
676
+ }),
677
+ t = _useI18n.t;
678
+
679
+ return (
680
+ /*#__PURE__*/
681
+ React.createElement("div", {
682
+ className: classNames(styles$4.container, _defineProperty({}, styles$4.hovered, hovered))
683
+ },
684
+ /*#__PURE__*/
685
+ React.createElement("button", {
686
+ className: styles$4.button,
687
+ title: t('pageflow_scrolled.inline_editing.add_content_element'),
688
+ onClick: onClick,
689
+ onMouseDown: function onMouseDown(event) {
690
+ return event.stopPropagation();
691
+ },
692
+ onMouseEnter: function onMouseEnter() {
693
+ return setHovered(true);
694
+ },
695
+ onMouseLeave: function onMouseLeave() {
696
+ return setHovered(false);
697
+ }
698
+ },
699
+ /*#__PURE__*/
700
+ React.createElement(PlusIcon, {
701
+ width: 15,
702
+ height: 15,
703
+ fill: "currentColor"
704
+ })))
705
+ );
706
+ }
707
+
708
+ function LayoutWithPlaceholder(props) {
709
+ var _useEditorSelection = useEditorSelection({
710
+ id: props.sectionId,
711
+ type: 'section'
712
+ }),
713
+ isSelected = _useEditorSelection.isSelected;
714
+
715
+ var _useEditorSelection2 = useEditorSelection({
716
+ id: props.sectionId,
717
+ type: 'sectionSettings'
718
+ }),
719
+ settingsSelected = _useEditorSelection2.isSelected;
720
+
721
+ var placeholder = isSelected || settingsSelected ?
722
+ /*#__PURE__*/
723
+ React.createElement(ContentElementInsertButton, {
724
+ onClick: function onClick() {
725
+ return postInsertContentElementMessage({
726
+ at: 'endOfSection',
727
+ id: props.sectionId
728
+ });
729
+ }
730
+ }) : null;
731
+ return (
732
+ /*#__PURE__*/
733
+ React.createElement(LayoutWithoutInlineEditing, Object.assign({}, props, {
734
+ placeholder: placeholder
735
+ }))
736
+ );
737
+ }
738
+
739
+ function useCachedValue(value) {
740
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
741
+ defaultValue = _ref.defaultValue,
742
+ onReset = _ref.onReset,
743
+ onDebouncedChange = _ref.onDebouncedChange,
744
+ _ref$delay = _ref.delay,
745
+ delay = _ref$delay === void 0 ? 2000 : _ref$delay;
746
+
747
+ var _useState = useState(value || defaultValue),
748
+ _useState2 = _slicedToArray(_useState, 2),
749
+ cachedValue = _useState2[0],
750
+ setCachedValue = _useState2[1];
751
+
752
+ var previousValue = useRef(value);
753
+ useEffect(function () {
754
+ if (previousValue.current !== value && value !== cachedValue) {
755
+ onReset && onReset(value);
756
+ setCachedValue(value);
757
+ }
758
+ }, [onReset, value, cachedValue]);
759
+ useEffect(function () {
760
+ previousValue.current = value;
761
+ });
762
+ var debouncedHandler = useDebouncedCallback(onDebouncedChange, delay);
763
+ var setValue = useCallback(function (value) {
764
+ setCachedValue(function (previousValue) {
765
+ if (previousValue !== value) {
766
+ debouncedHandler(value);
767
+ }
768
+
769
+ return value;
770
+ });
771
+ }, [debouncedHandler]);
772
+ return [cachedValue, setValue];
773
+ } // Debounce callback even if the callback function changes across renders.
774
+
775
+ function useDebouncedCallback(callback, delay) {
776
+ var mostRecentCallback = useRef(null);
777
+ var debouncedHandler = useRef(null);
778
+ useEffect(function () {
779
+ mostRecentCallback.current = callback;
780
+ }, [callback]);
781
+ useEffect(function () {
782
+ debouncedHandler.current = debounce(function (value) {
783
+ if (mostRecentCallback.current) {
784
+ mostRecentCallback.current(value);
785
+ }
786
+ }, delay);
787
+ return function () {
788
+ debouncedHandler.current.flush();
789
+ };
790
+ }, [delay]);
791
+ return useCallback(function () {
792
+ return debouncedHandler.current.apply(debouncedHandler, arguments);
793
+ }, []);
794
+ }
795
+
796
+ var styles$5 = {"placeholder":"TextPlaceholder-module_placeholder__sgVwx"};
797
+
798
+ function TextPlaceholder(_ref) {
799
+ var text = _ref.text,
800
+ visible = _ref.visible;
801
+
802
+ if (!text || !visible) {
803
+ return null;
804
+ }
805
+
806
+ return (
807
+ /*#__PURE__*/
808
+ React.createElement("div", {
809
+ className: styles$5.placeholder
810
+ }, text)
811
+ );
812
+ }
813
+
814
+ function withCustomInsertBreak(editor) {
815
+ var insertBreak = editor.insertBreak;
816
+
817
+ editor.insertBreak = function () {
818
+ var selection = editor.selection;
819
+
820
+ if (selection && Range.isCollapsed(selection)) {
821
+ var match = Editor.above(editor, {
822
+ match: function match(n) {
823
+ return Editor.isBlock(editor, n);
824
+ }
825
+ });
826
+
827
+ if (match) {
828
+ var _match = _slicedToArray(match, 2),
829
+ block = _match[0],
830
+ path = _match[1];
831
+
832
+ if (Editor.isEnd(editor, selection.anchor, path) && block.type === 'heading') {
833
+ Transforms.insertNodes(editor, {
834
+ type: 'paragraph',
835
+ children: [{
836
+ text: ''
837
+ }]
838
+ });
839
+ return;
840
+ }
841
+ }
842
+ }
843
+
844
+ insertBreak();
845
+ };
846
+
847
+ return editor;
848
+ }
849
+
850
+ var styles$6 = {"container":"index-module_container__3dD9z","hoveringToolbar":"index-module_hoveringToolbar__31Xpd","selection":"index-module_selection__3dUiD","linkTooltip":"index-module_linkTooltip__36m1K"};
851
+
852
+ function _extends$3() {
853
+ _extends$3 = Object.assign || function (target) {
854
+ for (var i = 1; i < arguments.length; i++) {
855
+ var source = arguments[i];
856
+
857
+ for (var key in source) {
858
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
859
+ target[key] = source[key];
860
+ }
861
+ }
862
+ }
863
+
864
+ return target;
865
+ };
866
+
867
+ return _extends$3.apply(this, arguments);
868
+ }
869
+ var ExternalLinkIcon = (function (_ref) {
870
+ var _ref$styles = _ref.styles,
871
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
872
+ props = _objectWithoutProperties(_ref, ["styles"]);
873
+
874
+ return React.createElement("svg", _extends$3({
875
+ "aria-hidden": "true",
876
+ "data-prefix": "fas",
877
+ "data-icon": "external-link-alt",
878
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-external-link-alt"] || "fa-external-link-alt") + " " + (styles["fa-w-16"] || "fa-w-16"),
879
+ xmlns: "http://www.w3.org/2000/svg",
880
+ viewBox: "0 0 512 512"
881
+ }, props), React.createElement("path", {
882
+ fill: "currentColor",
883
+ 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"
884
+ }));
885
+ });
886
+
887
+ var DisabledContext = createContext();
888
+ var StateContext = createContext();
889
+ var UpdateContext = createContext();
890
+ function LinkTooltipProvider(_ref) {
891
+ var disabled = _ref.disabled,
892
+ children = _ref.children;
893
+
894
+ var _useState = useState(),
895
+ _useState2 = _slicedToArray(_useState, 2),
896
+ state = _useState2[0],
897
+ setState = _useState2[1];
898
+
899
+ var outerRef = useRef();
900
+ var update = useMemo(function () {
901
+ var timeout;
902
+ return {
903
+ activate: function activate(href, linkRef) {
904
+ clearTimeout(timeout);
905
+ timeout = null;
906
+ var outerRect = outerRef.current.getBoundingClientRect();
907
+ var linkRect = linkRef.current.getBoundingClientRect();
908
+ setState({
909
+ href: href,
910
+ top: linkRect.bottom - outerRect.top + 10,
911
+ left: linkRect.left - outerRect.left
912
+ });
913
+ },
914
+ keep: function keep() {
915
+ clearTimeout(timeout);
916
+ timeout = null;
917
+ },
918
+ deactivate: function deactivate() {
919
+ if (!timeout) {
920
+ timeout = setTimeout(function () {
921
+ timeout = null;
922
+ setState(null);
923
+ }, 200);
924
+ }
925
+ }
926
+ };
927
+ }, []);
928
+ return (
929
+ /*#__PURE__*/
930
+ React.createElement(DisabledContext.Provider, {
931
+ value: disabled
932
+ },
933
+ /*#__PURE__*/
934
+ React.createElement(StateContext.Provider, {
935
+ value: state
936
+ },
937
+ /*#__PURE__*/
938
+ React.createElement(UpdateContext.Provider, {
939
+ value: update
940
+ },
941
+ /*#__PURE__*/
942
+ React.createElement("div", {
943
+ ref: outerRef
944
+ },
945
+ /*#__PURE__*/
946
+ React.createElement(LinkTooltip, null), children))))
947
+ );
948
+ }
949
+ function LinkPreview(_ref2) {
950
+ var href = _ref2.href,
951
+ children = _ref2.children;
952
+
953
+ var _useContext = useContext(UpdateContext),
954
+ activate = _useContext.activate,
955
+ deactivate = _useContext.deactivate;
956
+
957
+ var ref = useRef();
958
+ return (
959
+ /*#__PURE__*/
960
+ React.createElement("span", {
961
+ ref: ref,
962
+ onMouseEnter: function onMouseEnter() {
963
+ return activate(href, ref);
964
+ },
965
+ onMouseLeave: deactivate,
966
+ onMouseDown: deactivate
967
+ }, children)
968
+ );
969
+ }
970
+ function LinkTooltip() {
971
+ var disabled = useContext(DisabledContext);
972
+ var state = useContext(StateContext);
973
+
974
+ var _useContext2 = useContext(UpdateContext),
975
+ keep = _useContext2.keep,
976
+ deactivate = _useContext2.deactivate;
977
+
978
+ var editor = useSlate();
979
+
980
+ if (disabled || !state || editor.selection && !Range.isCollapsed(editor.selection)) {
981
+ return null;
982
+ }
983
+
984
+ return (
985
+ /*#__PURE__*/
986
+ React.createElement("div", {
987
+ className: classNames(styles$6.linkTooltip, styles$6.hoveringToolbar),
988
+ onMouseEnter: keep,
989
+ onMouseLeave: deactivate,
990
+ style: {
991
+ top: state.top,
992
+ left: state.left,
993
+ opacity: 1
994
+ }
995
+ },
996
+ /*#__PURE__*/
997
+ React.createElement("a", {
998
+ href: state.href,
999
+ target: "_blank",
1000
+ rel: "noopener noreferrer"
1001
+ }, state.href,
1002
+ /*#__PURE__*/
1003
+ React.createElement(ExternalLinkIcon, {
1004
+ width: 10,
1005
+ height: 10
1006
+ })))
1007
+ );
1008
+ }
1009
+
1010
+ function withLinks(editor) {
1011
+ var isInline = editor.isInline;
1012
+
1013
+ editor.isInline = function (element) {
1014
+ return element.type === 'link' ? true : isInline(element);
1015
+ };
1016
+
1017
+ return editor;
1018
+ }
1019
+ function renderElementWithLinkPreview(options) {
1020
+ if (options.element.type === 'link') {
1021
+ return (
1022
+ /*#__PURE__*/
1023
+ React.createElement(LinkPreview, {
1024
+ href: options.element.href
1025
+ }, renderElement(options))
1026
+ );
1027
+ } else {
1028
+ return renderElement(options);
1029
+ }
1030
+ }
1031
+ function renderLeafWithLinkSelection(options) {
1032
+ if (options.leaf.linkSelection) {
1033
+ return (
1034
+ /*#__PURE__*/
1035
+ React.createElement("span", Object.assign({}, options.attributes, {
1036
+ style: {
1037
+ backgroundColor: '#aaa'
1038
+ }
1039
+ }), renderLeaf(options))
1040
+ );
1041
+ }
1042
+
1043
+ return renderLeaf(options);
1044
+ }
1045
+ function decorateLinkSelection(_ref, linkSelection) {
1046
+ var _ref2 = _slicedToArray(_ref, 2),
1047
+ node = _ref2[0],
1048
+ path = _ref2[1];
1049
+
1050
+ if (linkSelection && Text.isText(node)) {
1051
+ var nodeRange = {
1052
+ anchor: {
1053
+ path: path,
1054
+ offset: 0
1055
+ },
1056
+ focus: {
1057
+ path: path,
1058
+ offset: node.text.length
1059
+ }
1060
+ };
1061
+ var intersection = Range.intersection(nodeRange, linkSelection);
1062
+
1063
+ if (intersection) {
1064
+ return [_objectSpread2(_objectSpread2({}, intersection), {}, {
1065
+ linkSelection: true
1066
+ })];
1067
+ }
1068
+ }
1069
+
1070
+ return [];
1071
+ }
1072
+
1073
+ function _extends$4() {
1074
+ _extends$4 = Object.assign || function (target) {
1075
+ for (var i = 1; i < arguments.length; i++) {
1076
+ var source = arguments[i];
1077
+
1078
+ for (var key in source) {
1079
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1080
+ target[key] = source[key];
1081
+ }
1082
+ }
1083
+ }
1084
+
1085
+ return target;
1086
+ };
1087
+
1088
+ return _extends$4.apply(this, arguments);
1089
+ }
1090
+ var CancelIcon = (function (_ref) {
1091
+ var _ref$styles = _ref.styles,
1092
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
1093
+ props = _objectWithoutProperties(_ref, ["styles"]);
1094
+
1095
+ return React.createElement("svg", _extends$4({
1096
+ "aria-hidden": "true",
1097
+ "data-prefix": "fas",
1098
+ "data-icon": "times",
1099
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-times"] || "fa-times") + " " + (styles["fa-w-11"] || "fa-w-11"),
1100
+ xmlns: "http://www.w3.org/2000/svg",
1101
+ viewBox: "0 0 352 512"
1102
+ }, props), React.createElement("path", {
1103
+ fill: "currentColor",
1104
+ 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"
1105
+ }));
1106
+ });
1107
+
1108
+ function LinkInput(_ref) {
1109
+ var onSubmit = _ref.onSubmit,
1110
+ onCancel = _ref.onCancel;
1111
+
1112
+ var _useI18n = useI18n({
1113
+ locale: 'ui'
1114
+ }),
1115
+ t = _useI18n.t;
1116
+
1117
+ var _useState = useState(''),
1118
+ _useState2 = _slicedToArray(_useState, 2),
1119
+ href = _useState2[0],
1120
+ setHref = _useState2[1];
1121
+
1122
+ var ref = useRef(); // With useEffect the deselect in HoveringToolbar/handleButtonClick breaks focusing.
1123
+
1124
+ useLayoutEffect(function () {
1125
+ ref.current.focus();
1126
+ }, []);
1127
+
1128
+ function handleKey(event) {
1129
+ if (event.key === 'Enter') {
1130
+ event.preventDefault();
1131
+ ref.current.blur();
1132
+ } else if (event.key === 'Escape') {
1133
+ event.preventDefault();
1134
+ onCancel();
1135
+ }
1136
+ }
1137
+
1138
+ function submit() {
1139
+ if (href) {
1140
+ onSubmit(href);
1141
+ } else {
1142
+ onCancel();
1143
+ }
1144
+ }
1145
+
1146
+ return (
1147
+ /*#__PURE__*/
1148
+ React.createElement("div", {
1149
+ className: styles$6.linkTooltip
1150
+ },
1151
+ /*#__PURE__*/
1152
+ React.createElement("input", {
1153
+ ref: ref,
1154
+ type: "text",
1155
+ value: href,
1156
+ placeholder: t('pageflow_scrolled.inline_editing.url_placeholder'),
1157
+ onBlur: submit,
1158
+ onChange: function onChange(e) {
1159
+ return setHref(e.target.value);
1160
+ },
1161
+ onKeyDown: handleKey
1162
+ }),
1163
+ /*#__PURE__*/
1164
+ React.createElement("button", {
1165
+ onMouseDown: function onMouseDown(e) {
1166
+ return e.preventDefault();
1167
+ },
1168
+ onClick: onCancel,
1169
+ title: t('pageflow_scrolled.inline_editing.cancel')
1170
+ },
1171
+ /*#__PURE__*/
1172
+ React.createElement(CancelIcon, {
1173
+ width: 10,
1174
+ height: 10
1175
+ })))
1176
+ );
1177
+ }
1178
+
1179
+ function _extends$5() {
1180
+ _extends$5 = Object.assign || function (target) {
1181
+ for (var i = 1; i < arguments.length; i++) {
1182
+ var source = arguments[i];
1183
+
1184
+ for (var key in source) {
1185
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1186
+ target[key] = source[key];
1187
+ }
1188
+ }
1189
+ }
1190
+
1191
+ return target;
1192
+ };
1193
+
1194
+ return _extends$5.apply(this, arguments);
1195
+ }
1196
+ var BoldIcon = (function (_ref) {
1197
+ var _ref$styles = _ref.styles,
1198
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
1199
+ props = _objectWithoutProperties(_ref, ["styles"]);
1200
+
1201
+ return React.createElement("svg", _extends$5({
1202
+ "aria-hidden": "true",
1203
+ "data-prefix": "fas",
1204
+ "data-icon": "bold",
1205
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-bold"] || "fa-bold") + " " + (styles["fa-w-12"] || "fa-w-12"),
1206
+ xmlns: "http://www.w3.org/2000/svg",
1207
+ viewBox: "0 0 384 512"
1208
+ }, props), React.createElement("path", {
1209
+ fill: "currentColor",
1210
+ 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"
1211
+ }));
1212
+ });
1213
+
1214
+ function _extends$6() {
1215
+ _extends$6 = Object.assign || function (target) {
1216
+ for (var i = 1; i < arguments.length; i++) {
1217
+ var source = arguments[i];
1218
+
1219
+ for (var key in source) {
1220
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1221
+ target[key] = source[key];
1222
+ }
1223
+ }
1224
+ }
1225
+
1226
+ return target;
1227
+ };
1228
+
1229
+ return _extends$6.apply(this, arguments);
1230
+ }
1231
+ var UnderlineIcon = (function (_ref) {
1232
+ var _ref$styles = _ref.styles,
1233
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
1234
+ props = _objectWithoutProperties(_ref, ["styles"]);
1235
+
1236
+ return React.createElement("svg", _extends$6({
1237
+ "aria-hidden": "true",
1238
+ "data-prefix": "fas",
1239
+ "data-icon": "underline",
1240
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-underline"] || "fa-underline") + " " + (styles["fa-w-14"] || "fa-w-14"),
1241
+ xmlns: "http://www.w3.org/2000/svg",
1242
+ viewBox: "0 0 448 512"
1243
+ }, props), React.createElement("path", {
1244
+ fill: "currentColor",
1245
+ 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"
1246
+ }));
1247
+ });
1248
+
1249
+ function _extends$7() {
1250
+ _extends$7 = Object.assign || function (target) {
1251
+ for (var i = 1; i < arguments.length; i++) {
1252
+ var source = arguments[i];
1253
+
1254
+ for (var key in source) {
1255
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1256
+ target[key] = source[key];
1257
+ }
1258
+ }
1259
+ }
1260
+
1261
+ return target;
1262
+ };
1263
+
1264
+ return _extends$7.apply(this, arguments);
1265
+ }
1266
+ var ItalicIcon = (function (_ref) {
1267
+ var _ref$styles = _ref.styles,
1268
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
1269
+ props = _objectWithoutProperties(_ref, ["styles"]);
1270
+
1271
+ return React.createElement("svg", _extends$7({
1272
+ "aria-hidden": "true",
1273
+ "data-prefix": "fas",
1274
+ "data-icon": "italic",
1275
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-italic"] || "fa-italic") + " " + (styles["fa-w-10"] || "fa-w-10"),
1276
+ xmlns: "http://www.w3.org/2000/svg",
1277
+ viewBox: "0 0 320 512"
1278
+ }, props), React.createElement("path", {
1279
+ fill: "currentColor",
1280
+ 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"
1281
+ }));
1282
+ });
1283
+
1284
+ function _extends$8() {
1285
+ _extends$8 = Object.assign || function (target) {
1286
+ for (var i = 1; i < arguments.length; i++) {
1287
+ var source = arguments[i];
1288
+
1289
+ for (var key in source) {
1290
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1291
+ target[key] = source[key];
1292
+ }
1293
+ }
1294
+ }
1295
+
1296
+ return target;
1297
+ };
1298
+
1299
+ return _extends$8.apply(this, arguments);
1300
+ }
1301
+ var StrikethroughIcon = (function (_ref) {
1302
+ var _ref$styles = _ref.styles,
1303
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
1304
+ props = _objectWithoutProperties(_ref, ["styles"]);
1305
+
1306
+ return React.createElement("svg", _extends$8({
1307
+ "aria-hidden": "true",
1308
+ "data-prefix": "fas",
1309
+ "data-icon": "strikethrough",
1310
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-strikethrough"] || "fa-strikethrough") + " " + (styles["fa-w-16"] || "fa-w-16"),
1311
+ xmlns: "http://www.w3.org/2000/svg",
1312
+ viewBox: "0 0 512 512"
1313
+ }, props), React.createElement("path", {
1314
+ fill: "currentColor",
1315
+ 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"
1316
+ }));
1317
+ });
1318
+
1319
+ function _extends$9() {
1320
+ _extends$9 = Object.assign || function (target) {
1321
+ for (var i = 1; i < arguments.length; i++) {
1322
+ var source = arguments[i];
1323
+
1324
+ for (var key in source) {
1325
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1326
+ target[key] = source[key];
1327
+ }
1328
+ }
1329
+ }
1330
+
1331
+ return target;
1332
+ };
1333
+
1334
+ return _extends$9.apply(this, arguments);
1335
+ }
1336
+ var LinkIcon = (function (_ref) {
1337
+ var _ref$styles = _ref.styles,
1338
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
1339
+ props = _objectWithoutProperties(_ref, ["styles"]);
1340
+
1341
+ return React.createElement("svg", _extends$9({
1342
+ "aria-hidden": "true",
1343
+ "data-prefix": "fas",
1344
+ "data-icon": "link",
1345
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-link"] || "fa-link") + " " + (styles["fa-w-16"] || "fa-w-16"),
1346
+ xmlns: "http://www.w3.org/2000/svg",
1347
+ viewBox: "0 0 512 512"
1348
+ }, props), React.createElement("path", {
1349
+ fill: "currentColor",
1350
+ 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"
1351
+ }));
1352
+ });
1353
+
1354
+ function HoveringToolbar(_ref) {
1355
+ var linkSelection = _ref.linkSelection,
1356
+ setLinkSelection = _ref.setLinkSelection;
1357
+ var ref = useRef();
1358
+ var outerRef = useRef();
1359
+ var editor = useSlate();
1360
+
1361
+ var _useI18n = useI18n({
1362
+ locale: 'ui'
1363
+ }),
1364
+ t = _useI18n.t;
1365
+
1366
+ useEffect(function () {
1367
+ var el = ref.current;
1368
+ var selection = editor.selection;
1369
+
1370
+ if (!el || !outerRef.current || linkSelection) {
1371
+ return;
1372
+ }
1373
+
1374
+ if (!selection || !ReactEditor.isFocused(editor) || Range.isCollapsed(selection) || Editor.string(editor, selection) === '') {
1375
+ el.removeAttribute('style');
1376
+ return;
1377
+ }
1378
+
1379
+ var domRange = ReactEditor.toDOMRange(editor, editor.selection);
1380
+ var rect = domRange.getBoundingClientRect();
1381
+ var outerRect = outerRef.current.getBoundingClientRect();
1382
+ el.style.opacity = 1;
1383
+ el.style.top = "".concat(rect.bottom - outerRect.top + 10, "px");
1384
+ el.style.left = "".concat(rect.left - outerRect.left, "px");
1385
+ });
1386
+ return (
1387
+ /*#__PURE__*/
1388
+ React.createElement("div", {
1389
+ ref: outerRef
1390
+ },
1391
+ /*#__PURE__*/
1392
+ React.createElement("div", {
1393
+ ref: ref,
1394
+ className: styles$6.hoveringToolbar
1395
+ }, !linkSelection && renderToolbar$1(editor, setLinkSelection, t), linkSelection && renderLinkInput(editor, linkSelection, setLinkSelection)))
1396
+ );
1397
+ }
1398
+
1399
+ function renderToolbar$1(editor, setLinkSelection, t) {
1400
+ var buttons = [{
1401
+ name: 'bold',
1402
+ text: t('pageflow_scrolled.inline_editing.formats.bold'),
1403
+ icon: BoldIcon
1404
+ }, {
1405
+ name: 'italic',
1406
+ text: t('pageflow_scrolled.inline_editing.formats.italic'),
1407
+ icon: ItalicIcon
1408
+ }, {
1409
+ name: 'underline',
1410
+ text: t('pageflow_scrolled.inline_editing.formats.underline'),
1411
+ icon: UnderlineIcon
1412
+ }, {
1413
+ name: 'strikethrough',
1414
+ text: t('pageflow_scrolled.inline_editing.formats.strikethrough'),
1415
+ icon: StrikethroughIcon
1416
+ }, {
1417
+ name: 'link',
1418
+ text: isButtonActive(editor, 'link') ? t('pageflow_scrolled.inline_editing.remove_link') : t('pageflow_scrolled.inline_editing.insert_link'),
1419
+ icon: LinkIcon
1420
+ }].map(function (button) {
1421
+ return _objectSpread2(_objectSpread2({}, button), {}, {
1422
+ active: isButtonActive(editor, button.name)
1423
+ });
1424
+ });
1425
+ return (
1426
+ /*#__PURE__*/
1427
+ React.createElement(Toolbar, {
1428
+ buttons: buttons,
1429
+ onButtonClick: function onButtonClick(name) {
1430
+ return handleButtonClick(editor, name, setLinkSelection);
1431
+ }
1432
+ })
1433
+ );
1434
+ }
1435
+
1436
+ function handleButtonClick(editor, format, setLinkSelection) {
1437
+ if (format === 'link') {
1438
+ if (isLinkActive(editor)) {
1439
+ unwrapLink(editor);
1440
+ } else {
1441
+ var selection = editor.selection; // Required to prevent slate from focusing the editor in Firefox
1442
+ // https://github.com/ianstormtaylor/slate/blob/44675c2080e3f6a2523170430bb92e426b7647e2/packages/slate-react/src/components/editable.tsx#L189
1443
+
1444
+ Transforms.deselect(editor);
1445
+ setLinkSelection(selection);
1446
+ }
1447
+ } else {
1448
+ toggleMark(editor, format);
1449
+ }
1450
+ }
1451
+
1452
+ function isButtonActive(editor, format) {
1453
+ if (format === 'link') {
1454
+ return isLinkActive(editor);
1455
+ } else {
1456
+ return isMarkActive(editor, format);
1457
+ }
1458
+ }
1459
+
1460
+ function renderLinkInput(editor, linkSelection, setLinkSelection) {
1461
+ function handleSubmit(href) {
1462
+ Transforms.select(editor, linkSelection);
1463
+ ReactEditor.focus(editor);
1464
+ wrapLink(editor, href);
1465
+ setLinkSelection(null);
1466
+ }
1467
+
1468
+ function handleCancel() {
1469
+ setLinkSelection(null);
1470
+ Transforms.select(editor, linkSelection);
1471
+ ReactEditor.focus(editor);
1472
+ }
1473
+
1474
+ return (
1475
+ /*#__PURE__*/
1476
+ React.createElement(LinkInput, {
1477
+ onSubmit: handleSubmit,
1478
+ onCancel: handleCancel
1479
+ })
1480
+ );
1481
+ }
1482
+
1483
+ function unwrapLink(editor) {
1484
+ Transforms.unwrapNodes(editor, {
1485
+ match: function match(n) {
1486
+ return n.type === 'link';
1487
+ }
1488
+ });
1489
+ }
1490
+
1491
+ function wrapLink(editor, href) {
1492
+ var link = {
1493
+ type: 'link',
1494
+ href: href,
1495
+ children: []
1496
+ };
1497
+ Transforms.wrapNodes(editor, link, {
1498
+ split: true
1499
+ });
1500
+ Transforms.collapse(editor, {
1501
+ edge: 'end'
1502
+ });
1503
+ }
1504
+
1505
+ function isLinkActive(editor) {
1506
+ var _Editor$nodes = Editor.nodes(editor, {
1507
+ match: function match(n) {
1508
+ return n.type === 'link';
1509
+ }
1510
+ }),
1511
+ _Editor$nodes2 = _slicedToArray(_Editor$nodes, 1),
1512
+ link = _Editor$nodes2[0];
1513
+
1514
+ return !!link;
1515
+ }
1516
+
1517
+ function toggleMark(editor, format) {
1518
+ var isActive = isMarkActive(editor, format);
1519
+
1520
+ if (isActive) {
1521
+ Editor.removeMark(editor, format);
1522
+ } else {
1523
+ Editor.addMark(editor, format, true);
1524
+ }
1525
+ }
1526
+
1527
+ function isMarkActive(editor, format) {
1528
+ var marks = Editor.marks(editor);
1529
+ return marks ? marks[format] === true : false;
1530
+ }
1531
+
1532
+ function _extends$a() {
1533
+ _extends$a = Object.assign || function (target) {
1534
+ for (var i = 1; i < arguments.length; i++) {
1535
+ var source = arguments[i];
1536
+
1537
+ for (var key in source) {
1538
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1539
+ target[key] = source[key];
1540
+ }
1541
+ }
1542
+ }
1543
+
1544
+ return target;
1545
+ };
1546
+
1547
+ return _extends$a.apply(this, arguments);
1548
+ }
1549
+ var TextIcon = (function (_ref) {
1550
+ var _ref$styles = _ref.styles,
1551
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
1552
+ props = _objectWithoutProperties(_ref, ["styles"]);
1553
+
1554
+ return React.createElement("svg", _extends$a({
1555
+ "aria-hidden": "true",
1556
+ "data-prefix": "fas",
1557
+ "data-icon": "align-justify",
1558
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-align-justify"] || "fa-align-justify") + " " + (styles["fa-w-14"] || "fa-w-14"),
1559
+ xmlns: "http://www.w3.org/2000/svg",
1560
+ viewBox: "0 0 448 512"
1561
+ }, props), React.createElement("path", {
1562
+ fill: "currentColor",
1563
+ 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"
1564
+ }));
1565
+ });
1566
+
1567
+ function _extends$b() {
1568
+ _extends$b = Object.assign || function (target) {
1569
+ for (var i = 1; i < arguments.length; i++) {
1570
+ var source = arguments[i];
1571
+
1572
+ for (var key in source) {
1573
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1574
+ target[key] = source[key];
1575
+ }
1576
+ }
1577
+ }
1578
+
1579
+ return target;
1580
+ };
1581
+
1582
+ return _extends$b.apply(this, arguments);
1583
+ }
1584
+ var HeadingIcon = (function (_ref) {
1585
+ var _ref$styles = _ref.styles,
1586
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
1587
+ props = _objectWithoutProperties(_ref, ["styles"]);
1588
+
1589
+ return React.createElement("svg", _extends$b({
1590
+ "aria-hidden": "true",
1591
+ "data-prefix": "fas",
1592
+ "data-icon": "heading",
1593
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-heading"] || "fa-heading") + " " + (styles["fa-w-16"] || "fa-w-16"),
1594
+ xmlns: "http://www.w3.org/2000/svg",
1595
+ viewBox: "0 0 512 512"
1596
+ }, props), React.createElement("path", {
1597
+ fill: "currentColor",
1598
+ 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"
1599
+ }));
1600
+ });
1601
+
1602
+ function _extends$c() {
1603
+ _extends$c = Object.assign || function (target) {
1604
+ for (var i = 1; i < arguments.length; i++) {
1605
+ var source = arguments[i];
1606
+
1607
+ for (var key in source) {
1608
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1609
+ target[key] = source[key];
1610
+ }
1611
+ }
1612
+ }
1613
+
1614
+ return target;
1615
+ };
1616
+
1617
+ return _extends$c.apply(this, arguments);
1618
+ }
1619
+ var OlIcon = (function (_ref) {
1620
+ var _ref$styles = _ref.styles,
1621
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
1622
+ props = _objectWithoutProperties(_ref, ["styles"]);
1623
+
1624
+ return React.createElement("svg", _extends$c({
1625
+ "aria-hidden": "true",
1626
+ "data-prefix": "fas",
1627
+ "data-icon": "list-ol",
1628
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-list-ol"] || "fa-list-ol") + " " + (styles["fa-w-16"] || "fa-w-16"),
1629
+ xmlns: "http://www.w3.org/2000/svg",
1630
+ viewBox: "0 0 512 512"
1631
+ }, props), React.createElement("path", {
1632
+ fill: "currentColor",
1633
+ 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"
1634
+ }));
1635
+ });
1636
+
1637
+ function _extends$d() {
1638
+ _extends$d = Object.assign || function (target) {
1639
+ for (var i = 1; i < arguments.length; i++) {
1640
+ var source = arguments[i];
1641
+
1642
+ for (var key in source) {
1643
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1644
+ target[key] = source[key];
1645
+ }
1646
+ }
1647
+ }
1648
+
1649
+ return target;
1650
+ };
1651
+
1652
+ return _extends$d.apply(this, arguments);
1653
+ }
1654
+ var UlIcon = (function (_ref) {
1655
+ var _ref$styles = _ref.styles,
1656
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
1657
+ props = _objectWithoutProperties(_ref, ["styles"]);
1658
+
1659
+ return React.createElement("svg", _extends$d({
1660
+ "aria-hidden": "true",
1661
+ "data-prefix": "fas",
1662
+ "data-icon": "list-ul",
1663
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-list-ul"] || "fa-list-ul") + " " + (styles["fa-w-16"] || "fa-w-16"),
1664
+ xmlns: "http://www.w3.org/2000/svg",
1665
+ viewBox: "0 0 512 512"
1666
+ }, props), React.createElement("path", {
1667
+ fill: "currentColor",
1668
+ 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"
1669
+ }));
1670
+ });
1671
+
1672
+ function _extends$e() {
1673
+ _extends$e = Object.assign || function (target) {
1674
+ for (var i = 1; i < arguments.length; i++) {
1675
+ var source = arguments[i];
1676
+
1677
+ for (var key in source) {
1678
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1679
+ target[key] = source[key];
1680
+ }
1681
+ }
1682
+ }
1683
+
1684
+ return target;
1685
+ };
1686
+
1687
+ return _extends$e.apply(this, arguments);
1688
+ }
1689
+ var QuoteIcon = (function (_ref) {
1690
+ var _ref$styles = _ref.styles,
1691
+ styles = _ref$styles === void 0 ? {} : _ref$styles,
1692
+ props = _objectWithoutProperties(_ref, ["styles"]);
1693
+
1694
+ return React.createElement("svg", _extends$e({
1695
+ "aria-hidden": "true",
1696
+ "data-prefix": "fas",
1697
+ "data-icon": "quote-right",
1698
+ className: (styles["svg-inline--fa"] || "svg-inline--fa") + " " + (styles["fa-quote-right"] || "fa-quote-right") + " " + (styles["fa-w-16"] || "fa-w-16"),
1699
+ xmlns: "http://www.w3.org/2000/svg",
1700
+ viewBox: "0 0 512 512"
1701
+ }, props), React.createElement("path", {
1702
+ fill: "currentColor",
1703
+ 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"
1704
+ }));
1705
+ });
1706
+
1707
+ function Selection(props) {
1708
+ var editor = useSlate();
1709
+
1710
+ var _useI18n = useI18n({
1711
+ locale: 'ui'
1712
+ }),
1713
+ t = _useI18n.t;
1714
+
1715
+ var ref = useRef();
1716
+ var outerRef = useRef();
1717
+ var innerRef = useRef();
1718
+ var boundsRef = useRef();
1719
+
1720
+ var _useContentElementEdi = useContentElementEditorState(),
1721
+ setTransientState = _useContentElementEdi.setTransientState,
1722
+ select = _useContentElementEdi.select,
1723
+ isContentElementSelected = _useContentElementEdi.isSelected;
1724
+
1725
+ useEffect(function () {
1726
+ var selection = editor.selection;
1727
+
1728
+ if (!ref.current) {
1729
+ return;
1730
+ }
1731
+
1732
+ if (!selection) {
1733
+ if (boundsRef.current) {
1734
+ hideRect(ref.current);
1735
+ boundsRef.current = null;
1736
+ }
1737
+
1738
+ return;
1739
+ }
1740
+
1741
+ if (!isContentElementSelected && boundsRef.current) {
1742
+ hideRect(ref.current);
1743
+ return;
1744
+ }
1745
+
1746
+ if (!isContentElementSelected && !boundsRef.current) {
1747
+ select();
1748
+ }
1749
+
1750
+ var _computeBounds = computeBounds(editor),
1751
+ _computeBounds2 = _slicedToArray(_computeBounds, 2),
1752
+ start = _computeBounds2[0],
1753
+ end = _computeBounds2[1];
1754
+
1755
+ setTransientState({
1756
+ editableTextIsSingleBlock: editor.children.length <= 1
1757
+ });
1758
+ boundsRef.current = {
1759
+ start: start,
1760
+ end: end
1761
+ };
1762
+ updateRect(editor, start, end, outerRef.current, ref.current, innerRef.current);
1763
+ });
1764
+ return (
1765
+ /*#__PURE__*/
1766
+ React.createElement("div", {
1767
+ ref: outerRef
1768
+ },
1769
+ /*#__PURE__*/
1770
+ React.createElement("div", {
1771
+ ref: ref,
1772
+ className: styles$6.selection
1773
+ },
1774
+ /*#__PURE__*/
1775
+ React.createElement(SelectionRect, {
1776
+ selected: true,
1777
+ insertButtonTitles: t('pageflow_scrolled.inline_editing.insert_content_element'),
1778
+ onInsertButtonClick: function onInsertButtonClick(at) {
1779
+ if (at === 'before' && boundsRef.current.start === 0 || at === 'after' && !Node.has(editor, [boundsRef.current.end + 1])) {
1780
+ postInsertContentElementMessage({
1781
+ id: props.contentElementId,
1782
+ at: at
1783
+ });
1784
+ } else {
1785
+ postInsertContentElementMessage({
1786
+ id: props.contentElementId,
1787
+ at: 'split',
1788
+ splitPoint: at === 'before' ? boundsRef.current.start : boundsRef.current.end + 1
1789
+ });
1790
+ }
1791
+ },
1792
+ toolbarButtons: toolbarButtons(t).map(function (button) {
1793
+ return _objectSpread2(_objectSpread2({}, button), {}, {
1794
+ active: isBlockActive(editor, button.name)
1795
+ });
1796
+ }),
1797
+ onToolbarButtonClick: function onToolbarButtonClick(name) {
1798
+ return toggleBlock(editor, name);
1799
+ }
1800
+ },
1801
+ /*#__PURE__*/
1802
+ React.createElement("div", {
1803
+ ref: innerRef
1804
+ }))))
1805
+ );
1806
+ }
1807
+
1808
+ function computeBounds(editor) {
1809
+ var startPoint = Range.start(editor.selection);
1810
+ var endPoint = Range.end(editor.selection);
1811
+ var startPath = startPoint.path.slice(0, 1);
1812
+ var endPath = endPoint.path.slice(0, 1);
1813
+
1814
+ if (!Path.equals(startPath, endPath) && endPoint.offset === 0) {
1815
+ endPath = Path.previous(endPath);
1816
+ }
1817
+
1818
+ return [startPath[0], endPath[0]];
1819
+ }
1820
+
1821
+ function hideRect(el) {
1822
+ el.removeAttribute('style');
1823
+ }
1824
+
1825
+ function updateRect(editor, startIndex, endIndex, outer, el, inner) {
1826
+ var _getDOMNodes = getDOMNodes(editor, startIndex, endIndex),
1827
+ _getDOMNodes2 = _slicedToArray(_getDOMNodes, 2),
1828
+ startDOMNode = _getDOMNodes2[0],
1829
+ endDOMNode = _getDOMNodes2[1];
1830
+
1831
+ if (startDOMNode && endDOMNode) {
1832
+ var startRect = startDOMNode.getBoundingClientRect();
1833
+ var endRect = endDOMNode.getBoundingClientRect();
1834
+ var outerRect = outer.getBoundingClientRect();
1835
+ el.style.display = 'block';
1836
+ el.style.top = "".concat(startRect.top - outerRect.top, "px");
1837
+ inner.style.height = "".concat(endRect.bottom - startRect.top, "px");
1838
+ }
1839
+ }
1840
+
1841
+ function getDOMNodes(editor, startIndex, endIndex) {
1842
+ var startNode = Node.get(editor, [startIndex]);
1843
+ var endNode = Node.get(editor, [endIndex]);
1844
+
1845
+ try {
1846
+ var startDOMNode = ReactEditor.toDOMNode(editor, startNode);
1847
+ var endDOMNode = ReactEditor.toDOMNode(editor, endNode);
1848
+ return [startDOMNode, endDOMNode];
1849
+ } catch (e) {
1850
+ return [];
1851
+ }
1852
+ }
1853
+
1854
+ var listTypes = ['numbered-list', 'bulleted-list'];
1855
+
1856
+ function toggleBlock(editor, format) {
1857
+ var isActive = isBlockActive(editor, format);
1858
+ var isList = listTypes.includes(format);
1859
+ Transforms.unwrapNodes(editor, {
1860
+ match: function match(n) {
1861
+ return listTypes.includes(n.type);
1862
+ },
1863
+ split: true
1864
+ });
1865
+ Transforms.setNodes(editor, {
1866
+ type: isActive ? 'paragraph' : isList ? 'list-item' : format
1867
+ });
1868
+
1869
+ if (!isActive && isList) {
1870
+ var block = {
1871
+ type: format,
1872
+ children: []
1873
+ };
1874
+ Transforms.wrapNodes(editor, block);
1875
+ }
1876
+ }
1877
+
1878
+ function isBlockActive(editor, format) {
1879
+ var _Editor$nodes = Editor.nodes(editor, {
1880
+ match: function match(n) {
1881
+ return n.type === format;
1882
+ }
1883
+ }),
1884
+ _Editor$nodes2 = _slicedToArray(_Editor$nodes, 1),
1885
+ match = _Editor$nodes2[0];
1886
+
1887
+ return !!match;
1888
+ }
1889
+
1890
+ function toolbarButtons(t) {
1891
+ return [{
1892
+ name: 'paragraph',
1893
+ text: t('pageflow_scrolled.inline_editing.formats.paragraph'),
1894
+ icon: TextIcon
1895
+ }, {
1896
+ name: 'heading',
1897
+ text: t('pageflow_scrolled.inline_editing.formats.heading'),
1898
+ icon: HeadingIcon
1899
+ }, {
1900
+ name: 'numbered-list',
1901
+ text: t('pageflow_scrolled.inline_editing.formats.ordered_list'),
1902
+ icon: OlIcon
1903
+ }, {
1904
+ name: 'bulleted-list',
1905
+ text: t('pageflow_scrolled.inline_editing.formats.bulleted_list'),
1906
+ icon: UlIcon
1907
+ }, {
1908
+ name: 'block-quote',
1909
+ text: t('pageflow_scrolled.inline_editing.formats.block_quote'),
1910
+ icon: QuoteIcon
1911
+ }];
1912
+ }
1913
+
1914
+ var EditableText = React.memo(function EditableText(_ref) {
1915
+ var value = _ref.value,
1916
+ contentElementId = _ref.contentElementId,
1917
+ placeholder = _ref.placeholder,
1918
+ onChange = _ref.onChange;
1919
+ var editor = useMemo(function () {
1920
+ return withLinks(withCustomInsertBreak(withReact(createEditor())));
1921
+ }, []);
1922
+
1923
+ var _useState = useState(),
1924
+ _useState2 = _slicedToArray(_useState, 2),
1925
+ linkSelection = _useState2[0],
1926
+ setLinkSelection = _useState2[1];
1927
+
1928
+ var _useCachedValue = useCachedValue(value, {
1929
+ defaultValue: [{
1930
+ type: 'paragraph',
1931
+ children: [{
1932
+ text: ''
1933
+ }]
1934
+ }],
1935
+ onDebouncedChange: onChange,
1936
+ onReset: function onReset(nextValue) {
1937
+ return resetSelectionIfOutsideNextValue(editor, nextValue);
1938
+ }
1939
+ }),
1940
+ _useCachedValue2 = _slicedToArray(_useCachedValue, 2),
1941
+ cachedValue = _useCachedValue2[0],
1942
+ setCachedValue = _useCachedValue2[1];
1943
+
1944
+ useContentElementEditorCommandSubscription(function (command) {
1945
+ if (command.type === 'REMOVE') {
1946
+ Transforms.removeNodes(editor, {
1947
+ mode: 'highest'
1948
+ });
1949
+ }
1950
+ });
1951
+ var decorate = useCallback(function (nodeEntry) {
1952
+ return decorateLinkSelection(nodeEntry, linkSelection);
1953
+ }, [linkSelection]); // Ensure Slate rerenders when decorations change
1954
+ // https://github.com/ianstormtaylor/slate/issues/3447
1955
+
1956
+ var renderLeaf = useCallback(function (options) {
1957
+ return renderLeafWithLinkSelection(options);
1958
+ }, [linkSelection]); // eslint-disable-line react-hooks/exhaustive-deps
1959
+
1960
+ return (
1961
+ /*#__PURE__*/
1962
+ React.createElement(Text$1, {
1963
+ scaleCategory: "body"
1964
+ },
1965
+ /*#__PURE__*/
1966
+ React.createElement("div", {
1967
+ className: styles$6.container
1968
+ },
1969
+ /*#__PURE__*/
1970
+ React.createElement(Slate, {
1971
+ editor: editor,
1972
+ value: cachedValue,
1973
+ onChange: setCachedValue
1974
+ },
1975
+ /*#__PURE__*/
1976
+ React.createElement(LinkTooltipProvider, {
1977
+ disabled: !!linkSelection
1978
+ },
1979
+ /*#__PURE__*/
1980
+ React.createElement(Selection, {
1981
+ contentElementId: contentElementId
1982
+ }),
1983
+ /*#__PURE__*/
1984
+ React.createElement(HoveringToolbar, {
1985
+ linkSelection: linkSelection,
1986
+ setLinkSelection: setLinkSelection
1987
+ }),
1988
+ /*#__PURE__*/
1989
+ React.createElement(Editable, {
1990
+ decorate: decorate,
1991
+ renderElement: renderElementWithLinkPreview,
1992
+ renderLeaf: renderLeaf
1993
+ }))),
1994
+ /*#__PURE__*/
1995
+ React.createElement(TextPlaceholder, {
1996
+ text: placeholder,
1997
+ visible: isBlank(cachedValue)
1998
+ })))
1999
+ );
2000
+ });
2001
+
2002
+ function isBlank(value) {
2003
+ var _value$, _value$2, _value$2$children$;
2004
+
2005
+ 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);
2006
+ }
2007
+
2008
+ function resetSelectionIfOutsideNextValue(editor, nextValue) {
2009
+ var nextEditor = {
2010
+ children: nextValue
2011
+ };
2012
+
2013
+ if (editor.selection && (!Node.has(nextEditor, editor.selection.anchor.path) || !Node.has(nextEditor, editor.selection.focus.path))) {
2014
+ Transforms.deselect(editor);
2015
+ }
2016
+ }
2017
+
2018
+ var EditableInlineText = memo(function EditableInlineText(_ref) {
2019
+ var _cachedValue$, _cachedValue$$childre;
2020
+
2021
+ var value = _ref.value,
2022
+ _ref$defaultValue = _ref.defaultValue,
2023
+ defaultValue = _ref$defaultValue === void 0 ? '' : _ref$defaultValue,
2024
+ placeholder = _ref.placeholder,
2025
+ onChange = _ref.onChange;
2026
+ var editor = useMemo(function () {
2027
+ return withSingleLine(withReact(createEditor()));
2028
+ }, []);
2029
+
2030
+ var _useCachedValue = useCachedValue(value, {
2031
+ defaultValue: [{
2032
+ type: 'heading',
2033
+ children: [{
2034
+ text: defaultValue
2035
+ }]
2036
+ }],
2037
+ onDebouncedChange: onChange
2038
+ }),
2039
+ _useCachedValue2 = _slicedToArray(_useCachedValue, 2),
2040
+ cachedValue = _useCachedValue2[0],
2041
+ setCachedValue = _useCachedValue2[1];
2042
+
2043
+ return (
2044
+ /*#__PURE__*/
2045
+ React.createElement(React.Fragment, null,
2046
+ /*#__PURE__*/
2047
+ React.createElement(Slate, {
2048
+ editor: editor,
2049
+ value: cachedValue,
2050
+ onChange: setCachedValue
2051
+ },
2052
+ /*#__PURE__*/
2053
+ React.createElement(Editable, null)),
2054
+ /*#__PURE__*/
2055
+ React.createElement(TextPlaceholder, {
2056
+ text: placeholder,
2057
+ 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)
2058
+ }))
2059
+ );
2060
+ });
2061
+
2062
+ function withSingleLine(editor) {
2063
+ var normalizeNode = editor.normalizeNode;
2064
+
2065
+ editor.normalizeNode = function (_ref2) {
2066
+ var _ref3 = _slicedToArray(_ref2, 2),
2067
+ node = _ref3[0],
2068
+ path = _ref3[1];
2069
+
2070
+ if (path.length === 0) {
2071
+ if (editor.children.length > 1) {
2072
+ Transforms.mergeNodes(editor);
2073
+ }
2074
+ }
2075
+
2076
+ return normalizeNode([node, path]);
2077
+ };
2078
+
2079
+ return editor;
2080
+ }
2081
+
2082
+ function PhonePlatformProvider(_ref) {
2083
+ var children = _ref.children;
2084
+
2085
+ var _useState = useState(false),
2086
+ _useState2 = _slicedToArray(_useState, 2),
2087
+ phoneEmulationMode = _useState2[0],
2088
+ setPhoneEmulationMode = _useState2[1];
2089
+
2090
+ useEffect(function () {
2091
+ window.addEventListener('message', receive);
2092
+
2093
+ function receive(event) {
2094
+ if (event.data.type === 'CHANGE_EMULATION_MODE') {
2095
+ if (event.data['payload'] === 'phone') {
2096
+ setPhoneEmulationMode(true);
2097
+ } else {
2098
+ setPhoneEmulationMode(false);
2099
+ }
2100
+ }
2101
+ }
2102
+
2103
+ return function () {
2104
+ return window.removeEventListener('message', receive);
2105
+ };
2106
+ });
2107
+ return (
2108
+ /*#__PURE__*/
2109
+ React.createElement(PhonePlatformContext.Provider, {
2110
+ value: phoneEmulationMode
2111
+ }, children)
2112
+ );
2113
+ }
2114
+
2115
+ export { ContentElementDecorator, EditableInlineText, EditableText, EntryDecorator, LayoutWithPlaceholder, PhonePlatformProvider, SectionDecorator };