@entur-partner/rich-text-editor 4.0.12 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,26 +20,21 @@ function _extends() {
20
20
  _extends = Object.assign ? Object.assign.bind() : function (target) {
21
21
  for (var i = 1; i < arguments.length; i++) {
22
22
  var source = arguments[i];
23
-
24
23
  for (var key in source) {
25
24
  if (Object.prototype.hasOwnProperty.call(source, key)) {
26
25
  target[key] = source[key];
27
26
  }
28
27
  }
29
28
  }
30
-
31
29
  return target;
32
30
  };
33
31
  return _extends.apply(this, arguments);
34
32
  }
35
-
36
33
  function _inheritsLoose(subClass, superClass) {
37
34
  subClass.prototype = Object.create(superClass.prototype);
38
35
  subClass.prototype.constructor = subClass;
39
-
40
36
  _setPrototypeOf(subClass, superClass);
41
37
  }
42
-
43
38
  function _setPrototypeOf(o, p) {
44
39
  _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
45
40
  o.__proto__ = p;
@@ -47,34 +42,28 @@ function _setPrototypeOf(o, p) {
47
42
  };
48
43
  return _setPrototypeOf(o, p);
49
44
  }
50
-
51
45
  function _objectWithoutPropertiesLoose(source, excluded) {
52
46
  if (source == null) return {};
53
47
  var target = {};
54
48
  var sourceKeys = Object.keys(source);
55
49
  var key, i;
56
-
57
50
  for (i = 0; i < sourceKeys.length; i++) {
58
51
  key = sourceKeys[i];
59
52
  if (excluded.indexOf(key) >= 0) continue;
60
53
  target[key] = source[key];
61
54
  }
62
-
63
55
  return target;
64
56
  }
65
57
 
66
58
  function useI18N() {
67
59
  var _useTranslation = useTranslation(),
68
- t = _useTranslation.t,
69
- language = _useTranslation.i18n.language;
70
-
60
+ t = _useTranslation.t,
61
+ language = _useTranslation.i18n.language;
71
62
  if (language !== 'nb' && language !== 'en') {
72
63
  throw Error('Language must be either nb or en.');
73
64
  }
74
-
75
65
  return t;
76
66
  }
77
-
78
67
  function withI18n(Component) {
79
68
  return function WrappedComponent(props) {
80
69
  var t = useI18N();
@@ -86,84 +75,66 @@ function withI18n(Component) {
86
75
 
87
76
  var BlockTypeDropdown = /*#__PURE__*/function (_Component) {
88
77
  _inheritsLoose(BlockTypeDropdown, _Component);
89
-
90
78
  function BlockTypeDropdown() {
91
79
  var _this;
92
-
93
80
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
94
81
  args[_key] = arguments[_key];
95
82
  }
96
-
97
83
  _this = _Component.call.apply(_Component, [this].concat(args)) || this;
98
-
99
84
  _this.handleOnClick = function (selectedOption) {
100
85
  var onChange = _this.props.onChange;
101
86
  onChange(selectedOption);
102
87
  };
103
-
104
88
  return _this;
105
89
  }
106
-
107
90
  var _proto = BlockTypeDropdown.prototype;
108
-
109
91
  _proto.toItem = function toItem(option) {
110
92
  return {
111
93
  value: option.style,
112
94
  label: this.renderFormattedLabel(option.label)
113
95
  };
114
96
  };
115
-
116
97
  _proto.renderFormattedLabel = function renderFormattedLabel(label) {
117
98
  var formattedLabelText = this.props.i18n(label);
118
-
119
99
  switch (label) {
120
100
  case 'styles.p':
121
101
  return /*#__PURE__*/React.createElement("div", {
122
102
  className: "default-p"
123
103
  }, formattedLabelText);
124
-
125
104
  case 'styles.h1':
126
105
  return /*#__PURE__*/React.createElement("div", {
127
106
  className: "default-h1"
128
107
  }, formattedLabelText);
129
-
130
108
  case 'styles.h2':
131
109
  return /*#__PURE__*/React.createElement("div", {
132
110
  className: "default-h2"
133
111
  }, formattedLabelText);
134
-
135
112
  case 'styles.h3':
136
113
  return /*#__PURE__*/React.createElement("div", {
137
114
  className: "default-h3"
138
115
  }, formattedLabelText);
139
-
140
116
  case 'styles.h4':
141
117
  return /*#__PURE__*/React.createElement("div", {
142
118
  className: "default-h4"
143
119
  }, formattedLabelText);
144
-
145
120
  case 'styles.h5':
146
121
  return /*#__PURE__*/React.createElement("div", {
147
122
  className: "default-h5"
148
123
  }, formattedLabelText);
149
-
150
124
  case 'styles.h6':
151
125
  return /*#__PURE__*/React.createElement("div", {
152
126
  className: "default-h6"
153
127
  }, formattedLabelText);
154
-
155
128
  default:
156
129
  return /*#__PURE__*/React.createElement("p", null, formattedLabelText);
157
130
  }
158
131
  };
159
-
160
132
  _proto.render = function render() {
161
133
  var _this2 = this;
162
-
163
134
  var _this$props = this.props,
164
- options = _this$props.options,
165
- selected = _this$props.selected,
166
- i18n = _this$props.i18n;
135
+ options = _this$props.options,
136
+ selected = _this$props.selected,
137
+ i18n = _this$props.i18n;
167
138
  return /*#__PURE__*/React.createElement(Dropdown, {
168
139
  className: "block-type-dropdown",
169
140
  items: options.map(function (option) {
@@ -176,16 +147,14 @@ var BlockTypeDropdown = /*#__PURE__*/function (_Component) {
176
147
  }
177
148
  });
178
149
  };
179
-
180
150
  return BlockTypeDropdown;
181
151
  }(Component);
182
-
183
152
  var BlockTypeDropdown$1 = /*#__PURE__*/withI18n(BlockTypeDropdown);
184
153
 
185
154
  var BlockTypeControls = function BlockTypeControls(_ref) {
186
155
  var editorState = _ref.editorState,
187
- blockTypes = _ref.blockTypes,
188
- onToggle = _ref.onToggle;
156
+ blockTypes = _ref.blockTypes,
157
+ onToggle = _ref.onToggle;
189
158
  var selection = editorState.getSelection();
190
159
  var blockTypeStyle = editorState.getCurrentContent().getBlockForKey(selection.getStartKey()).getType();
191
160
  var selectedOption = blockTypes.find(function (option) {
@@ -207,45 +176,36 @@ function getKey(event) {
207
176
 
208
177
  var StyleButton = /*#__PURE__*/function (_Component) {
209
178
  _inheritsLoose(StyleButton, _Component);
210
-
211
179
  function StyleButton() {
212
180
  var _this;
213
-
214
181
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
215
182
  args[_key] = arguments[_key];
216
183
  }
217
-
218
184
  _this = _Component.call.apply(_Component, [this].concat(args)) || this;
219
-
220
185
  _this.onToggle = function (e) {
221
186
  var _this$props = _this.props,
222
- style = _this$props.style,
223
- onToggle = _this$props.onToggle;
187
+ style = _this$props.style,
188
+ onToggle = _this$props.onToggle;
224
189
  e.preventDefault();
225
190
  onToggle(style);
226
191
  };
227
-
228
192
  _this.onToggleNoEvent = function () {
229
193
  var _this$props2 = _this.props,
230
- style = _this$props2.style,
231
- onToggle = _this$props2.onToggle;
194
+ style = _this$props2.style,
195
+ onToggle = _this$props2.onToggle;
232
196
  onToggle(style);
233
197
  };
234
-
235
198
  return _this;
236
199
  }
237
-
238
200
  var _proto = StyleButton.prototype;
239
-
240
201
  _proto.render = function render() {
241
202
  var _this2 = this;
242
-
243
203
  var _this$props3 = this.props,
244
- i18n = _this$props3.i18n,
245
- active = _this$props3.active,
246
- label = _this$props3.label,
247
- title = _this$props3.title,
248
- hotKey = _this$props3.hotKey;
204
+ i18n = _this$props3.i18n,
205
+ active = _this$props3.active,
206
+ label = _this$props3.label,
207
+ title = _this$props3.title,
208
+ hotKey = _this$props3.hotKey;
249
209
  var classNames = cx('editor-stylebutton', {
250
210
  active: active
251
211
  });
@@ -261,16 +221,14 @@ var StyleButton = /*#__PURE__*/function (_Component) {
261
221
  }
262
222
  }, label);
263
223
  };
264
-
265
224
  return StyleButton;
266
225
  }(Component);
267
-
268
226
  var StyleButton$1 = /*#__PURE__*/withI18n(StyleButton);
269
227
 
270
228
  var BlockTypeButtonControls = function BlockTypeButtonControls(props) {
271
229
  var editorState = props.editorState,
272
- blockTypes = props.blockTypes,
273
- onToggle = props.onToggle;
230
+ blockTypes = props.blockTypes,
231
+ onToggle = props.onToggle;
274
232
  var selection = editorState.getSelection();
275
233
  var blockTypeStyle = editorState.getCurrentContent().getBlockForKey(selection.getStartKey()).getType();
276
234
  return /*#__PURE__*/React.createElement("div", {
@@ -289,32 +247,26 @@ var BlockTypeButtonControls = function BlockTypeButtonControls(props) {
289
247
 
290
248
  var BlockTypeLinkControls = /*#__PURE__*/function (_Component) {
291
249
  _inheritsLoose(BlockTypeLinkControls, _Component);
292
-
293
250
  function BlockTypeLinkControls() {
294
251
  var _this;
295
-
296
252
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
297
253
  args[_key] = arguments[_key];
298
254
  }
299
-
300
255
  _this = _Component.call.apply(_Component, [this].concat(args)) || this;
301
256
  _this.state = {
302
257
  urlValue: '',
303
258
  showUrlInput: false,
304
259
  hasLink: false
305
260
  };
306
-
307
261
  _this.onUrlChange = function (e) {
308
262
  _this.setState({
309
263
  urlValue: e.target.value
310
264
  });
311
265
  };
312
-
313
266
  _this.addLink = function (e) {
314
267
  e.preventDefault();
315
268
  var editorState = _this.props.editorState;
316
269
  var selection = editorState.getSelection();
317
-
318
270
  if (!selection.isCollapsed()) {
319
271
  var currentContent = editorState.getCurrentContent();
320
272
  var startKey = selection.getStartKey();
@@ -322,12 +274,10 @@ var BlockTypeLinkControls = /*#__PURE__*/function (_Component) {
322
274
  var blockWithLinkAtBeginning = currentContent.getBlockForKey(startKey);
323
275
  var linkKey = blockWithLinkAtBeginning.getEntityAt(startOffset);
324
276
  var url = '';
325
-
326
277
  if (linkKey) {
327
278
  var linkInstance = currentContent.getEntity(linkKey);
328
279
  url = linkInstance.getData().url;
329
280
  }
330
-
331
281
  _this.setState({
332
282
  showUrlInput: true,
333
283
  urlValue: url,
@@ -335,13 +285,12 @@ var BlockTypeLinkControls = /*#__PURE__*/function (_Component) {
335
285
  });
336
286
  }
337
287
  };
338
-
339
288
  _this.confirmLink = function (e) {
340
289
  e.preventDefault();
341
290
  var urlValue = _this.state.urlValue;
342
291
  var _this$props = _this.props,
343
- editorState = _this$props.editorState,
344
- onToggle = _this$props.onToggle;
292
+ editorState = _this$props.editorState,
293
+ onToggle = _this$props.onToggle;
345
294
  var contentState = editorState.getCurrentContent();
346
295
  var contentStateWithEntity = contentState.createEntity('LINK', 'MUTABLE', {
347
296
  url: urlValue
@@ -351,55 +300,45 @@ var BlockTypeLinkControls = /*#__PURE__*/function (_Component) {
351
300
  currentContent: contentStateWithEntity
352
301
  });
353
302
  onToggle(newEditorState, entityKey);
354
-
355
303
  _this.setState({
356
304
  showUrlInput: false,
357
305
  urlValue: ''
358
306
  });
359
307
  };
360
-
361
308
  _this.cancelLink = function (e) {
362
309
  e.preventDefault();
363
-
364
310
  _this.setState({
365
311
  showUrlInput: false,
366
312
  urlValue: ''
367
313
  });
368
314
  };
369
-
370
315
  _this.onLinkInputKeyDown = function (e) {
371
316
  if (getKey(e) === Key.ENTER) {
372
317
  _this.confirmLink(e);
373
318
  }
374
319
  };
375
-
376
320
  _this.removeLink = function (e) {
377
321
  e.preventDefault();
378
322
  var _this$props2 = _this.props,
379
- editorState = _this$props2.editorState,
380
- onToggle = _this$props2.onToggle;
323
+ editorState = _this$props2.editorState,
324
+ onToggle = _this$props2.onToggle;
381
325
  var hasLink = _this.state.hasLink;
382
326
  var selection = editorState.getSelection();
383
-
384
327
  if (!selection.isCollapsed() && hasLink) {
385
328
  onToggle(editorState, null);
386
-
387
329
  _this.setState({
388
330
  showUrlInput: false
389
331
  });
390
332
  }
391
333
  };
392
-
393
334
  return _this;
394
335
  }
395
-
396
336
  var _proto = BlockTypeLinkControls.prototype;
397
-
398
337
  _proto.render = function render() {
399
338
  var i18n = this.props.i18n;
400
339
  var _this$state = this.state,
401
- showUrlInput = _this$state.showUrlInput,
402
- hasLink = _this$state.hasLink;
340
+ showUrlInput = _this$state.showUrlInput,
341
+ hasLink = _this$state.hasLink;
403
342
  return /*#__PURE__*/React.createElement("div", {
404
343
  className: "controls-group block-editor-controls link-controls"
405
344
  }, /*#__PURE__*/React.createElement("div", {
@@ -437,10 +376,8 @@ var BlockTypeLinkControls = /*#__PURE__*/function (_Component) {
437
376
  title: i18n('styles.unlink')
438
377
  }, /*#__PURE__*/React.createElement(UnlinkIcon, null), i18n('styles.unlink')))));
439
378
  };
440
-
441
379
  return BlockTypeLinkControls;
442
380
  }(Component);
443
-
444
381
  BlockTypeLinkControls.propTypes = {
445
382
  editorState: PropTypes.object,
446
383
  onToggle: PropTypes.func
@@ -449,7 +386,7 @@ var BlockTypeLinkControls$1 = /*#__PURE__*/withI18n(BlockTypeLinkControls);
449
386
 
450
387
  var InlineStyleControls = function InlineStyleControls(props) {
451
388
  var editorState = props.editorState,
452
- inlineStyles = props.inlineStyles;
389
+ inlineStyles = props.inlineStyles;
453
390
  var currentStyle = editorState.getCurrentInlineStyle();
454
391
  return /*#__PURE__*/React.createElement("div", {
455
392
  className: "controls-group inline-editor-controls"
@@ -468,20 +405,16 @@ var InlineStyleControls = function InlineStyleControls(props) {
468
405
 
469
406
  var TagControls = /*#__PURE__*/function (_Component) {
470
407
  _inheritsLoose(TagControls, _Component);
471
-
472
408
  function TagControls() {
473
409
  var _this;
474
-
475
410
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
476
411
  args[_key] = arguments[_key];
477
412
  }
478
-
479
413
  _this = _Component.call.apply(_Component, [this].concat(args)) || this;
480
414
  _this.tagControlRef = /*#__PURE__*/createRef();
481
415
  _this.state = {
482
416
  isOpen: false
483
417
  };
484
-
485
418
  _this.handleClickOutside = function (e) {
486
419
  if (_this.tagControlRef && _this.tagControlRef.current && !_this.tagControlRef.current.contains(e.target)) {
487
420
  _this.setState({
@@ -489,36 +422,29 @@ var TagControls = /*#__PURE__*/function (_Component) {
489
422
  });
490
423
  }
491
424
  };
492
-
493
425
  _this.handleTagClick = function (tag, delimiter) {
494
426
  var _this$props = _this.props,
495
- editorState = _this$props.editorState,
496
- onInsertTag = _this$props.onInsertTag;
427
+ editorState = _this$props.editorState,
428
+ onInsertTag = _this$props.onInsertTag;
497
429
  var delimiterStart = delimiter[0];
498
430
  var delimiterEnd = delimiter[1];
499
431
  var fullTag = "" + delimiterStart + tag + delimiterEnd;
500
432
  onInsertTag(editorState, fullTag);
501
433
  };
502
-
503
434
  return _this;
504
435
  }
505
-
506
436
  var _proto = TagControls.prototype;
507
-
508
437
  _proto.componentDidMount = function componentDidMount() {
509
438
  document.addEventListener('mousedown', this.handleClickOutside);
510
439
  };
511
-
512
440
  _proto.componentWillUnmount = function componentWillUnmount() {
513
441
  document.removeEventListener('mousedown', this.handleClickOutside);
514
442
  };
515
-
516
443
  _proto.render = function render() {
517
444
  var _this2 = this;
518
-
519
445
  var _this$props2 = this.props,
520
- i18n = _this$props2.i18n,
521
- tags = _this$props2.tags;
446
+ i18n = _this$props2.i18n,
447
+ tags = _this$props2.tags;
522
448
  var isOpen = this.state.isOpen;
523
449
  var menuItems = tags.map(function (tag, i) {
524
450
  var delimiter = tag.delimiter || '{}';
@@ -556,10 +482,8 @@ var TagControls = /*#__PURE__*/function (_Component) {
556
482
  className: "action-menu"
557
483
  }, menuItems)));
558
484
  };
559
-
560
485
  return TagControls;
561
486
  }(Component);
562
-
563
487
  TagControls.propTypes = {
564
488
  editorState: PropTypes.object,
565
489
  tags: PropTypes.arrayOf(PropTypes.object).isRequired,
@@ -569,21 +493,18 @@ var TagControls$1 = /*#__PURE__*/withI18n(TagControls);
569
493
 
570
494
  var HtmlLink = function HtmlLink(_ref) {
571
495
  var url = _ref.url,
572
- children = _ref.children;
496
+ children = _ref.children;
573
497
  return /*#__PURE__*/React.createElement("a", {
574
498
  href: url
575
499
  }, children);
576
500
  };
577
-
578
501
  var Link = function Link(props) {
579
502
  var _props$contentState$g = props.contentState.getEntity(props.entityKey).getData(),
580
- url = _props$contentState$g.url;
581
-
503
+ url = _props$contentState$g.url;
582
504
  return /*#__PURE__*/React.createElement(HtmlLink, {
583
505
  url: url
584
506
  }, props.children);
585
507
  };
586
-
587
508
  function findLinkEntities(contentBlock, callback, contentState) {
588
509
  contentBlock.findEntityRanges(function (character) {
589
510
  var entityKey = character.getEntity();
@@ -693,88 +614,69 @@ var decorator = /*#__PURE__*/new CompositeDecorator([{
693
614
 
694
615
  var RichTextEditor = /*#__PURE__*/function (_Component) {
695
616
  _inheritsLoose(RichTextEditor, _Component);
696
-
697
617
  function RichTextEditor() {
698
618
  var _this;
699
-
700
619
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
701
620
  args[_key] = arguments[_key];
702
621
  }
703
-
704
622
  _this = _Component.call.apply(_Component, [this].concat(args)) || this;
705
623
  _this.wrapperRef = /*#__PURE__*/createRef();
706
624
  _this.editor = /*#__PURE__*/createRef();
707
-
708
625
  _this.handleKeyCommand = function (command, editorState) {
709
626
  var newState = RichUtils.handleKeyCommand(editorState, command);
710
-
711
627
  if (newState) {
712
628
  _this.props.onChange(newState);
713
-
714
629
  return true;
715
630
  }
716
-
717
631
  return false;
718
632
  };
719
-
720
633
  _this.keyBindingFn = function (evt) {
721
634
  switch (evt.keyCode) {
722
635
  case 9:
723
636
  return _this.onTab(evt);
724
-
725
637
  default:
726
638
  return getDefaultKeyBinding(evt);
727
639
  }
728
640
  };
729
-
730
641
  _this.onTab = function (evt) {
731
642
  evt.stopPropagation();
732
643
  var _this$props = _this.props,
733
- maxTabDepth = _this$props.maxTabDepth,
734
- editorState = _this$props.editorState,
735
- onChange = _this$props.onChange;
644
+ maxTabDepth = _this$props.maxTabDepth,
645
+ editorState = _this$props.editorState,
646
+ onChange = _this$props.onChange;
736
647
  onChange(RichUtils.onTab(evt, editorState, maxTabDepth));
737
648
  };
738
-
739
649
  _this.toggleButtonBlockType = function (blockType) {
740
650
  var _this$props2 = _this.props,
741
- editorState = _this$props2.editorState,
742
- onChange = _this$props2.onChange;
651
+ editorState = _this$props2.editorState,
652
+ onChange = _this$props2.onChange;
743
653
  onChange(RichUtils.toggleBlockType(editorState, blockType));
744
654
  };
745
-
746
655
  _this.toggleSelectBlockType = function (blockType) {
747
656
  var _this$props3 = _this.props,
748
- editorState = _this$props3.editorState,
749
- onChange = _this$props3.onChange;
657
+ editorState = _this$props3.editorState,
658
+ onChange = _this$props3.onChange;
750
659
  onChange(RichUtils.toggleBlockType(editorState, blockType));
751
660
  };
752
-
753
661
  _this.toggleInlineStyle = function (inlineStyle) {
754
662
  var _this$props4 = _this.props,
755
- editorState = _this$props4.editorState,
756
- onChange = _this$props4.onChange;
663
+ editorState = _this$props4.editorState,
664
+ onChange = _this$props4.onChange;
757
665
  onChange(RichUtils.toggleInlineStyle(editorState, inlineStyle));
758
666
  };
759
-
760
667
  _this.toggleLink = function (newEditorState, entityKey) {
761
668
  _this.props.onChange(RichUtils.toggleLink(newEditorState, newEditorState.getSelection(), entityKey));
762
669
  };
763
-
764
670
  _this.insertText = function (editorState, text) {
765
671
  var newContent = Modifier.insertText(editorState.getCurrentContent(), editorState.getSelection(), text);
766
-
767
672
  _this.props.onChange(EditorState.push(editorState, newContent, 'insert-characters'), function () {
768
673
  return _this.focusEditor();
769
674
  });
770
675
  };
771
-
772
676
  _this.getFontListConfigForPanelType = function (panelType) {
773
677
  var controlConfig = _this.getControlConfigBySet(_this.props.controlConfigSet);
774
-
775
678
  return controlConfig[panelType];
776
679
  };
777
-
778
680
  _this.getControlConfigBySet = function (config) {
779
681
  var fontList = (config && config.fontList || Object.keys(FontList)).filter(function (f) {
780
682
  return typeof f === 'object' ? FontList[f.type] : FontList[f];
@@ -797,28 +699,24 @@ var RichTextEditor = /*#__PURE__*/function (_Component) {
797
699
  inlineStyles: inlineStyles
798
700
  };
799
701
  };
800
-
801
702
  return _this;
802
703
  }
803
-
804
704
  var _proto = RichTextEditor.prototype;
805
-
806
705
  _proto.focusEditor = function focusEditor() {
807
706
  this.editor.current && this.editor.current.focus();
808
707
  };
809
-
810
708
  _proto.render = function render() {
811
709
  var _this$props5 = this.props,
812
- className = _this$props5.className,
813
- showFontMenu = _this$props5.showFontMenu,
814
- showInlineStyleMenu = _this$props5.showInlineStyleMenu,
815
- showTextFormatMenu = _this$props5.showTextFormatMenu,
816
- showLinkMenu = _this$props5.showLinkMenu,
817
- label = _this$props5.label,
818
- tags = _this$props5.tags,
819
- editorState = _this$props5.editorState,
820
- onChange = _this$props5.onChange,
821
- handleBeforeInput = _this$props5.handleBeforeInput;
710
+ className = _this$props5.className,
711
+ showFontMenu = _this$props5.showFontMenu,
712
+ showInlineStyleMenu = _this$props5.showInlineStyleMenu,
713
+ showTextFormatMenu = _this$props5.showTextFormatMenu,
714
+ showLinkMenu = _this$props5.showLinkMenu,
715
+ label = _this$props5.label,
716
+ tags = _this$props5.tags,
717
+ editorState = _this$props5.editorState,
718
+ onChange = _this$props5.onChange,
719
+ handleBeforeInput = _this$props5.handleBeforeInput;
822
720
  var classNames = cx('editor-root', className);
823
721
  return /*#__PURE__*/React.createElement("div", {
824
722
  ref: this.wrapperRef
@@ -857,12 +755,9 @@ var RichTextEditor = /*#__PURE__*/function (_Component) {
857
755
  spellCheck: true
858
756
  }))));
859
757
  };
860
-
861
758
  return RichTextEditor;
862
759
  }(Component);
863
-
864
760
  RichTextEditor.decorator = decorator;
865
-
866
761
  var styleShape = function styleShape(configList) {
867
762
  return PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOf([].concat(Object.values(configList)))), PropTypes.arrayOf(PropTypes.shape({
868
763
  type: PropTypes.oneOf([].concat(Object.values(configList))),
@@ -872,7 +767,6 @@ var styleShape = function styleShape(configList) {
872
767
  hotKey: PropTypes.string
873
768
  }))]);
874
769
  };
875
-
876
770
  RichTextEditor.propTypes = {
877
771
  editorState: PropTypes.object.isRequired,
878
772
  onChange: PropTypes.func.isRequired,
@@ -908,7 +802,6 @@ var markdownToEditorState = function markdownToEditorState(markdown) {
908
802
  if (!markdown) {
909
803
  return EditorState.createEmpty(decorator);
910
804
  }
911
-
912
805
  var rawState = markdownToDraft(markdown, {
913
806
  preserveNewlines: true
914
807
  });
@@ -923,37 +816,30 @@ var markdownToHtml = function markdownToHtml(markdown) {
923
816
  };
924
817
 
925
818
  var _excluded = ["name", "title", "languages"];
926
-
927
819
  var RichTextEditorForLanguage = function RichTextEditorForLanguage(_ref) {
928
820
  var _ref$language = _ref.language,
929
- langKey = _ref$language.value,
930
- label = _ref$language.label,
931
- required = _ref$language.required,
932
- values = _ref.values,
933
- onChange = _ref.onChange,
934
- variant = _ref.variant,
935
- feedback = _ref.feedback,
936
- tags = _ref.tags;
937
-
821
+ langKey = _ref$language.value,
822
+ label = _ref$language.label,
823
+ required = _ref$language.required,
824
+ values = _ref.values,
825
+ onChange = _ref.onChange,
826
+ variant = _ref.variant,
827
+ feedback = _ref.feedback,
828
+ tags = _ref.tags;
938
829
  var _useState = useState(markdownToEditorState(values[langKey])),
939
- editorState = _useState[0],
940
- setEditorState = _useState[1];
941
-
830
+ editorState = _useState[0],
831
+ setEditorState = _useState[1];
942
832
  var handleOnChange = function handleOnChange(changedState) {
943
833
  var newValues = _extends({}, values);
944
-
945
834
  var content = editorStateToMarkdown(changedState);
946
-
947
835
  if (values[langKey] && content === '\n') {
948
836
  delete newValues[langKey];
949
837
  } else {
950
838
  newValues[langKey] = content;
951
839
  }
952
-
953
840
  setEditorState(changedState);
954
841
  onChange(newValues);
955
842
  };
956
-
957
843
  var feedbackText = feedback && feedback(langKey);
958
844
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(RichTextEditor, {
959
845
  label: required ? label + '*' : label,
@@ -963,17 +849,15 @@ var RichTextEditorForLanguage = function RichTextEditorForLanguage(_ref) {
963
849
  },
964
850
  controlConfigSet: MinifiedConfigTypes,
965
851
  tags: tags
966
- }), variant && (feedbackText == null ? void 0 : feedbackText.length) > 0 && /*#__PURE__*/React.createElement(FeedbackText, {
852
+ }), variant && (feedbackText == null ? void 0 : feedbackText.length) > 0 && ( /*#__PURE__*/React.createElement(FeedbackText, {
967
853
  variant: variant(langKey)
968
- }, feedbackText));
854
+ }, feedbackText)));
969
855
  };
970
-
971
856
  var ExpandableMultiLanguageRichTextEditor = function ExpandableMultiLanguageRichTextEditor(_ref2) {
972
857
  var name = _ref2.name,
973
- title = _ref2.title,
974
- languages = _ref2.languages,
975
- rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
976
-
858
+ title = _ref2.title,
859
+ languages = _ref2.languages,
860
+ rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
977
861
  return /*#__PURE__*/React.createElement(ExpandablePanel, {
978
862
  title: title,
979
863
  defaultOpen: true,
@@ -1003,7 +887,6 @@ var entityToHtml = {
1003
887
  url: entity.data.url
1004
888
  }, originalText);
1005
889
  }
1006
-
1007
890
  return originalText;
1008
891
  }
1009
892
  };
@@ -1016,13 +899,13 @@ var htmlToEntity = {
1016
899
  }
1017
900
  }
1018
901
  };
902
+
1019
903
  /* eslint-disable react/display-name */
1020
904
 
1021
905
  var htmlToEditorState = function htmlToEditorState(html) {
1022
906
  if (!html) {
1023
907
  return EditorState.createEmpty(decorator);
1024
908
  }
1025
-
1026
909
  var rawState = convertFromHTML(htmlToEntity)(html);
1027
910
  return EditorState.createWithContent(rawState, decorator);
1028
911
  };