@entur-partner/rich-text-editor 6.2.3 → 6.2.4-alpha.0

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.
@@ -2,20 +2,20 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var expand = require('@entur/expand');
6
+ var form = require('@entur/form');
7
+ var common = require('@entur-partner/common');
5
8
  var React = require('react');
9
+ var typography = require('@entur/typography');
10
+ var cx = require('classnames');
6
11
  var draftJs = require('draft-js');
7
12
  var PropTypes = require('prop-types');
8
- var cx = require('classnames');
9
- var typography = require('@entur/typography');
10
- var dropdown = require('@entur/dropdown');
11
13
  var reactI18next = require('react-i18next');
12
- var form = require('@entur/form');
13
- var icons = require('@entur/icons');
14
- var common = require('@entur-partner/common');
15
14
  var button = require('@entur/button');
16
- var tooltip = require('@entur/tooltip');
15
+ var icons = require('@entur/icons');
16
+ var dropdown = require('@entur/dropdown');
17
17
  var menu = require('@entur/menu');
18
- var expand = require('@entur/expand');
18
+ var tooltip = require('@entur/tooltip');
19
19
  var markdownDraftJs = require('markdown-draft-js');
20
20
  var showdown = require('showdown');
21
21
  var draftConvert = require('draft-convert');
@@ -23,8 +23,8 @@ var draftConvert = require('draft-convert');
23
23
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
24
24
 
25
25
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
26
- var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
27
26
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
27
+ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
28
28
  var showdown__default = /*#__PURE__*/_interopDefaultLegacy(showdown);
29
29
 
30
30
  function _extends() {
@@ -66,12 +66,19 @@ function _objectWithoutPropertiesLoose(source, excluded) {
66
66
  return target;
67
67
  }
68
68
 
69
+ var Key = /*#__PURE__*/Object.freeze({
70
+ ENTER: 13
71
+ });
72
+ function getKey(event) {
73
+ return event.keyCode || event.which;
74
+ }
75
+
69
76
  function useI18N() {
70
77
  var _useTranslation = reactI18next.useTranslation(),
71
78
  t = _useTranslation.t,
72
79
  language = _useTranslation.i18n.language;
73
- if (language !== 'nb' && language !== 'en' && language !== 'nb-NO' && language !== 'en-GB') {
74
- throw Error('Language must be either nb or en.');
80
+ if (language !== "nb" && language !== "en" && language !== "nb-NO" && language !== "en-GB") {
81
+ throw Error("Language must be either nb or en.");
75
82
  }
76
83
  return t;
77
84
  }
@@ -84,107 +91,6 @@ function withI18n(Component) {
84
91
  };
85
92
  }
86
93
 
87
- var BlockTypeDropdown = /*#__PURE__*/function (_Component) {
88
- function BlockTypeDropdown() {
89
- var _this;
90
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
91
- args[_key] = arguments[_key];
92
- }
93
- _this = _Component.call.apply(_Component, [this].concat(args)) || this;
94
- _this.handleOnClick = function (selectedOption) {
95
- var onChange = _this.props.onChange;
96
- onChange(selectedOption);
97
- };
98
- return _this;
99
- }
100
- _inheritsLoose(BlockTypeDropdown, _Component);
101
- var _proto = BlockTypeDropdown.prototype;
102
- _proto.toItem = function toItem(option) {
103
- return {
104
- value: option.style,
105
- label: this.renderFormattedLabel(option.label)
106
- };
107
- };
108
- _proto.renderFormattedLabel = function renderFormattedLabel(label) {
109
- var formattedLabelText = this.props.i18n(label);
110
- switch (label) {
111
- case 'styles.p':
112
- return /*#__PURE__*/React__default["default"].createElement("div", {
113
- className: "default-p"
114
- }, formattedLabelText);
115
- case 'styles.h1':
116
- return /*#__PURE__*/React__default["default"].createElement("div", {
117
- className: "default-h1"
118
- }, formattedLabelText);
119
- case 'styles.h2':
120
- return /*#__PURE__*/React__default["default"].createElement("div", {
121
- className: "default-h2"
122
- }, formattedLabelText);
123
- case 'styles.h3':
124
- return /*#__PURE__*/React__default["default"].createElement("div", {
125
- className: "default-h3"
126
- }, formattedLabelText);
127
- case 'styles.h4':
128
- return /*#__PURE__*/React__default["default"].createElement("div", {
129
- className: "default-h4"
130
- }, formattedLabelText);
131
- case 'styles.h5':
132
- return /*#__PURE__*/React__default["default"].createElement("div", {
133
- className: "default-h5"
134
- }, formattedLabelText);
135
- case 'styles.h6':
136
- return /*#__PURE__*/React__default["default"].createElement("div", {
137
- className: "default-h6"
138
- }, formattedLabelText);
139
- default:
140
- return /*#__PURE__*/React__default["default"].createElement("p", null, formattedLabelText);
141
- }
142
- };
143
- _proto.render = function render() {
144
- var _this2 = this;
145
- var _this$props = this.props,
146
- options = _this$props.options,
147
- selected = _this$props.selected,
148
- i18n = _this$props.i18n;
149
- return /*#__PURE__*/React__default["default"].createElement(dropdown.Dropdown, {
150
- className: "block-type-dropdown",
151
- items: options.map(function (option) {
152
- return _this2.toItem(option);
153
- }),
154
- selectedItem: this.toItem(selected),
155
- label: i18n('styles.style'),
156
- onChange: function onChange(selectedItem) {
157
- return _this2.handleOnClick(selectedItem.value);
158
- }
159
- });
160
- };
161
- return BlockTypeDropdown;
162
- }(React.Component);
163
- var BlockTypeDropdown$1 = /*#__PURE__*/withI18n(BlockTypeDropdown);
164
-
165
- var BlockTypeControls = function BlockTypeControls(_ref) {
166
- var editorState = _ref.editorState,
167
- blockTypes = _ref.blockTypes,
168
- onToggle = _ref.onToggle;
169
- var selection = editorState.getSelection();
170
- var blockTypeStyle = editorState.getCurrentContent().getBlockForKey(selection.getStartKey()).getType();
171
- var selectedOption = blockTypes.find(function (option) {
172
- return option.style === blockTypeStyle;
173
- }) || blockTypes[0];
174
- return /*#__PURE__*/React__default["default"].createElement(BlockTypeDropdown$1, {
175
- options: blockTypes,
176
- selected: selectedOption,
177
- onChange: onToggle
178
- });
179
- };
180
-
181
- var Key = /*#__PURE__*/Object.freeze({
182
- ENTER: 13
183
- });
184
- function getKey(event) {
185
- return event.keyCode || event.which;
186
- }
187
-
188
94
  var StyleButton = /*#__PURE__*/function (_Component) {
189
95
  function StyleButton() {
190
96
  var _this;
@@ -217,20 +123,26 @@ var StyleButton = /*#__PURE__*/function (_Component) {
217
123
  label = _this$props3.label,
218
124
  title = _this$props3.title,
219
125
  hotKey = _this$props3.hotKey;
220
- var classNames = cx__default["default"]('editor-stylebutton', {
126
+ var classNames = cx__default["default"]("editor-stylebutton", {
221
127
  active: active
222
128
  });
223
- return /*#__PURE__*/React__default["default"].createElement("div", {
224
- className: classNames,
225
- onMouseDown: this.onToggle,
226
- title: i18n(title) + hotKey,
227
- tabIndex: 0,
228
- onKeyPress: function onKeyPress(event) {
229
- if (getKey(event) === Key.ENTER) {
230
- _this2.onToggleNoEvent();
129
+ return (
130
+ /*#__PURE__*/
131
+ // biome-ignore lint/a11y/noStaticElementInteractions: Ignore for now.
132
+ React__default["default"].createElement("div", {
133
+ className: classNames,
134
+ onMouseDown: this.onToggle,
135
+ title: i18n(title) + hotKey
136
+ // biome-ignore lint/a11y/noNoninteractiveTabindex: Ignore for now.
137
+ ,
138
+ tabIndex: 0,
139
+ onKeyPress: function onKeyPress(event) {
140
+ if (getKey(event) === Key.ENTER) {
141
+ _this2.onToggleNoEvent();
142
+ }
231
143
  }
232
- }
233
- }, label);
144
+ }, label)
145
+ );
234
146
  };
235
147
  return StyleButton;
236
148
  }(React.Component);
@@ -244,9 +156,9 @@ var BlockTypeButtonControls = function BlockTypeButtonControls(props) {
244
156
  var blockTypeStyle = editorState.getCurrentContent().getBlockForKey(selection.getStartKey()).getType();
245
157
  return /*#__PURE__*/React__default["default"].createElement("div", {
246
158
  className: "controls-group block-editor-controls"
247
- }, blockTypes.map(function (type, i) {
159
+ }, blockTypes.map(function (type) {
248
160
  return /*#__PURE__*/React__default["default"].createElement(StyleButton$1, {
249
- key: i,
161
+ key: type.style + type.label,
250
162
  active: type.style === blockTypeStyle,
251
163
  label: type.label,
252
164
  onToggle: onToggle,
@@ -264,7 +176,7 @@ var BlockTypeLinkControls = /*#__PURE__*/function (_Component) {
264
176
  }
265
177
  _this = _Component.call.apply(_Component, [this].concat(args)) || this;
266
178
  _this.state = {
267
- urlValue: '',
179
+ urlValue: "",
268
180
  showUrlInput: false,
269
181
  hasLink: false
270
182
  };
@@ -283,7 +195,7 @@ var BlockTypeLinkControls = /*#__PURE__*/function (_Component) {
283
195
  var startOffset = selection.getStartOffset();
284
196
  var blockWithLinkAtBeginning = currentContent.getBlockForKey(startKey);
285
197
  var linkKey = blockWithLinkAtBeginning.getEntityAt(startOffset);
286
- var url = '';
198
+ var url = "";
287
199
  if (linkKey) {
288
200
  var linkInstance = currentContent.getEntity(linkKey);
289
201
  url = linkInstance.getData().url;
@@ -302,7 +214,7 @@ var BlockTypeLinkControls = /*#__PURE__*/function (_Component) {
302
214
  editorState = _this$props.editorState,
303
215
  onToggle = _this$props.onToggle;
304
216
  var contentState = editorState.getCurrentContent();
305
- var contentStateWithEntity = contentState.createEntity('LINK', 'MUTABLE', {
217
+ var contentStateWithEntity = contentState.createEntity("LINK", "MUTABLE", {
306
218
  url: urlValue
307
219
  });
308
220
  var entityKey = contentStateWithEntity.getLastCreatedEntityKey();
@@ -312,14 +224,14 @@ var BlockTypeLinkControls = /*#__PURE__*/function (_Component) {
312
224
  onToggle(newEditorState, entityKey);
313
225
  _this.setState({
314
226
  showUrlInput: false,
315
- urlValue: ''
227
+ urlValue: ""
316
228
  });
317
229
  };
318
230
  _this.cancelLink = function (e) {
319
231
  e.preventDefault();
320
232
  _this.setState({
321
233
  showUrlInput: false,
322
- urlValue: ''
234
+ urlValue: ""
323
235
  });
324
236
  };
325
237
  _this.onLinkInputKeyDown = function (e) {
@@ -354,7 +266,7 @@ var BlockTypeLinkControls = /*#__PURE__*/function (_Component) {
354
266
  className: "controls-group block-editor-controls link-controls"
355
267
  }, /*#__PURE__*/React__default["default"].createElement("div", {
356
268
  className: "editor-stylebutton",
357
- title: i18n('styles.link'),
269
+ title: i18n("styles.link"),
358
270
  onClick: this.addLink,
359
271
  tabIndex: 0
360
272
  }, /*#__PURE__*/React__default["default"].createElement(icons.LinkIcon, null)), showUrlInput && /*#__PURE__*/React__default["default"].createElement("div", {
@@ -364,7 +276,7 @@ var BlockTypeLinkControls = /*#__PURE__*/function (_Component) {
364
276
  onMouseDown: this.cancelLink
365
277
  }, /*#__PURE__*/React__default["default"].createElement(icons.CloseIcon, null)), /*#__PURE__*/React__default["default"].createElement("div", {
366
278
  className: "link-label"
367
- }, i18n('common.from')), /*#__PURE__*/React__default["default"].createElement("div", {
279
+ }, i18n("common.from")), /*#__PURE__*/React__default["default"].createElement("div", {
368
280
  className: "url-input-form"
369
281
  }, /*#__PURE__*/React__default["default"].createElement(form.TextField, {
370
282
  style: {
@@ -384,8 +296,8 @@ var BlockTypeLinkControls = /*#__PURE__*/function (_Component) {
384
296
  className: "remove-link"
385
297
  }, /*#__PURE__*/React__default["default"].createElement(common.Unbutton, {
386
298
  onClick: this.removeLink,
387
- title: i18n('styles.unlink')
388
- }, /*#__PURE__*/React__default["default"].createElement(icons.UnlinkIcon, null), i18n('styles.unlink')))));
299
+ title: i18n("styles.unlink")
300
+ }, /*#__PURE__*/React__default["default"].createElement(icons.UnlinkIcon, null), i18n("styles.unlink")))));
389
301
  };
390
302
  return BlockTypeLinkControls;
391
303
  }(React.Component);
@@ -395,15 +307,109 @@ BlockTypeLinkControls.propTypes = {
395
307
  };
396
308
  var BlockTypeLinkControls$1 = /*#__PURE__*/withI18n(BlockTypeLinkControls);
397
309
 
310
+ var BlockTypeDropdown = /*#__PURE__*/function (_Component) {
311
+ function BlockTypeDropdown() {
312
+ var _this;
313
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
314
+ args[_key] = arguments[_key];
315
+ }
316
+ _this = _Component.call.apply(_Component, [this].concat(args)) || this;
317
+ _this.handleOnClick = function (selectedOption) {
318
+ var onChange = _this.props.onChange;
319
+ onChange(selectedOption);
320
+ };
321
+ return _this;
322
+ }
323
+ _inheritsLoose(BlockTypeDropdown, _Component);
324
+ var _proto = BlockTypeDropdown.prototype;
325
+ _proto.toItem = function toItem(option) {
326
+ return {
327
+ value: option.style,
328
+ label: this.renderFormattedLabel(option.label)
329
+ };
330
+ };
331
+ _proto.renderFormattedLabel = function renderFormattedLabel(label) {
332
+ var formattedLabelText = this.props.i18n(label);
333
+ switch (label) {
334
+ case "styles.p":
335
+ return /*#__PURE__*/React__default["default"].createElement("div", {
336
+ className: "default-p"
337
+ }, formattedLabelText);
338
+ case "styles.h1":
339
+ return /*#__PURE__*/React__default["default"].createElement("div", {
340
+ className: "default-h1"
341
+ }, formattedLabelText);
342
+ case "styles.h2":
343
+ return /*#__PURE__*/React__default["default"].createElement("div", {
344
+ className: "default-h2"
345
+ }, formattedLabelText);
346
+ case "styles.h3":
347
+ return /*#__PURE__*/React__default["default"].createElement("div", {
348
+ className: "default-h3"
349
+ }, formattedLabelText);
350
+ case "styles.h4":
351
+ return /*#__PURE__*/React__default["default"].createElement("div", {
352
+ className: "default-h4"
353
+ }, formattedLabelText);
354
+ case "styles.h5":
355
+ return /*#__PURE__*/React__default["default"].createElement("div", {
356
+ className: "default-h5"
357
+ }, formattedLabelText);
358
+ case "styles.h6":
359
+ return /*#__PURE__*/React__default["default"].createElement("div", {
360
+ className: "default-h6"
361
+ }, formattedLabelText);
362
+ default:
363
+ return /*#__PURE__*/React__default["default"].createElement("p", null, formattedLabelText);
364
+ }
365
+ };
366
+ _proto.render = function render() {
367
+ var _this2 = this;
368
+ var _this$props = this.props,
369
+ options = _this$props.options,
370
+ selected = _this$props.selected,
371
+ i18n = _this$props.i18n;
372
+ return /*#__PURE__*/React__default["default"].createElement(dropdown.Dropdown, {
373
+ className: "block-type-dropdown",
374
+ items: options.map(function (option) {
375
+ return _this2.toItem(option);
376
+ }),
377
+ selectedItem: this.toItem(selected),
378
+ label: i18n("styles.style"),
379
+ onChange: function onChange(selectedItem) {
380
+ return _this2.handleOnClick(selectedItem.value);
381
+ }
382
+ });
383
+ };
384
+ return BlockTypeDropdown;
385
+ }(React.Component);
386
+ var BlockTypeDropdown$1 = /*#__PURE__*/withI18n(BlockTypeDropdown);
387
+
388
+ var BlockTypeControls = function BlockTypeControls(_ref) {
389
+ var editorState = _ref.editorState,
390
+ blockTypes = _ref.blockTypes,
391
+ onToggle = _ref.onToggle;
392
+ var selection = editorState.getSelection();
393
+ var blockTypeStyle = editorState.getCurrentContent().getBlockForKey(selection.getStartKey()).getType();
394
+ var selectedOption = blockTypes.find(function (option) {
395
+ return option.style === blockTypeStyle;
396
+ }) || blockTypes[0];
397
+ return /*#__PURE__*/React__default["default"].createElement(BlockTypeDropdown$1, {
398
+ options: blockTypes,
399
+ selected: selectedOption,
400
+ onChange: onToggle
401
+ });
402
+ };
403
+
398
404
  var InlineStyleControls = function InlineStyleControls(props) {
399
405
  var editorState = props.editorState,
400
406
  inlineStyles = props.inlineStyles;
401
407
  var currentStyle = editorState.getCurrentInlineStyle();
402
408
  return /*#__PURE__*/React__default["default"].createElement("div", {
403
409
  className: "controls-group inline-editor-controls"
404
- }, inlineStyles.map(function (type, i) {
410
+ }, inlineStyles.map(function (type) {
405
411
  return /*#__PURE__*/React__default["default"].createElement(StyleButton$1, {
406
- key: i,
412
+ key: type.style + type.label,
407
413
  active: currentStyle.has(type.style),
408
414
  label: type.label,
409
415
  onToggle: props.onToggle,
@@ -426,7 +432,7 @@ var TagControls = /*#__PURE__*/function (_Component) {
426
432
  isOpen: false
427
433
  };
428
434
  _this.handleClickOutside = function (e) {
429
- if (_this.tagControlRef && _this.tagControlRef.current && !_this.tagControlRef.current.contains(e.target)) {
435
+ if (_this.tagControlRef.current && !_this.tagControlRef.current.contains(e.target)) {
430
436
  _this.setState({
431
437
  isOpen: false
432
438
  });
@@ -446,10 +452,10 @@ var TagControls = /*#__PURE__*/function (_Component) {
446
452
  _inheritsLoose(TagControls, _Component);
447
453
  var _proto = TagControls.prototype;
448
454
  _proto.componentDidMount = function componentDidMount() {
449
- document.addEventListener('mousedown', this.handleClickOutside);
455
+ document.addEventListener("mousedown", this.handleClickOutside);
450
456
  };
451
457
  _proto.componentWillUnmount = function componentWillUnmount() {
452
- document.removeEventListener('mousedown', this.handleClickOutside);
458
+ document.removeEventListener("mousedown", this.handleClickOutside);
453
459
  };
454
460
  _proto.render = function render() {
455
461
  var _this2 = this;
@@ -457,12 +463,12 @@ var TagControls = /*#__PURE__*/function (_Component) {
457
463
  i18n = _this$props2.i18n,
458
464
  tags = _this$props2.tags;
459
465
  var isOpen = this.state.isOpen;
460
- var menuItems = tags.map(function (tag, i) {
461
- var delimiter = tag.delimiter || '{}';
466
+ var menuItems = tags.map(function (tag) {
467
+ var delimiter = tag.delimiter || "{}";
462
468
  return /*#__PURE__*/React__default["default"].createElement(menu.OverflowMenuItem, {
463
- key: i,
469
+ key: tag.tag,
464
470
  className: "tag-control",
465
- id: 'tag-control-' + tag.tag,
471
+ id: "tag-control-" + tag.tag,
466
472
  onClick: function onClick() {
467
473
  return _this2.handleTagClick(tag.tag, delimiter);
468
474
  }
@@ -483,7 +489,7 @@ var TagControls = /*#__PURE__*/function (_Component) {
483
489
  };
484
490
  });
485
491
  }
486
- }, i18n('common.insert'), /*#__PURE__*/React__default["default"].createElement(icons.DownArrowIcon, {
492
+ }, i18n("common.insert"), /*#__PURE__*/React__default["default"].createElement(icons.DownArrowIcon, {
487
493
  className: "tag-control-chevron",
488
494
  inline: true
489
495
  })), /*#__PURE__*/React__default["default"].createElement(tooltip.Popover, {
@@ -519,101 +525,101 @@ var Link = function Link(props) {
519
525
  function findLinkEntities(contentBlock, callback, contentState) {
520
526
  contentBlock.findEntityRanges(function (character) {
521
527
  var entityKey = character.getEntity();
522
- return entityKey !== null && contentState.getEntity(entityKey).getType() === 'LINK';
528
+ return entityKey !== null && contentState.getEntity(entityKey).getType() === "LINK";
523
529
  }, callback);
524
530
  }
525
531
 
526
532
  var EditorConfigTypes = /*#__PURE__*/Object.freeze({
527
533
  FONT_LIST: {
528
- UNSTYLED: 'unstyled',
529
- HEADER_ONE: 'header-one',
530
- HEADER_TWO: 'header-two',
531
- HEADER_THREE: 'header-three',
532
- HEADER_FOUR: 'header-four',
533
- HEADER_FIVE: 'header-five',
534
- HEADER_SIX: 'header-six'
534
+ UNSTYLED: "unstyled",
535
+ HEADER_ONE: "header-one",
536
+ HEADER_TWO: "header-two",
537
+ HEADER_THREE: "header-three",
538
+ HEADER_FOUR: "header-four",
539
+ HEADER_FIVE: "header-five",
540
+ HEADER_SIX: "header-six"
535
541
  },
536
542
  BLOCK_TYPES: {
537
- UNORDERED_LIST: 'unordered-list',
538
- ORDERED_LIST: 'ordered-list'
543
+ UNORDERED_LIST: "unordered-list",
544
+ ORDERED_LIST: "ordered-list"
539
545
  },
540
546
  INLINE_STYLES: {
541
- BOLD: 'bold',
542
- ITALIC: 'italic',
543
- UNDERLINE: 'underline'
547
+ BOLD: "bold",
548
+ ITALIC: "italic",
549
+ UNDERLINE: "underline"
544
550
  }
545
551
  });
546
552
  var FontList = /*#__PURE__*/Object.freeze({
547
553
  unstyled: {
548
- label: 'styles.p',
549
- style: 'unstyled'
554
+ label: "styles.p",
555
+ style: "unstyled"
550
556
  },
551
- 'header-one': {
552
- label: 'styles.h1',
553
- style: 'header-one'
557
+ "header-one": {
558
+ label: "styles.h1",
559
+ style: "header-one"
554
560
  },
555
- 'header-two': {
556
- label: 'styles.h2',
557
- style: 'header-two'
561
+ "header-two": {
562
+ label: "styles.h2",
563
+ style: "header-two"
558
564
  },
559
- 'header-three': {
560
- label: 'styles.h3',
561
- style: 'header-three'
565
+ "header-three": {
566
+ label: "styles.h3",
567
+ style: "header-three"
562
568
  },
563
- 'header-four': {
564
- label: 'styles.h4',
565
- style: 'header-four'
569
+ "header-four": {
570
+ label: "styles.h4",
571
+ style: "header-four"
566
572
  },
567
- 'header-five': {
568
- label: 'styles.h5',
569
- style: 'header-five'
573
+ "header-five": {
574
+ label: "styles.h5",
575
+ style: "header-five"
570
576
  },
571
- 'header-six': {
572
- label: 'styles.h6',
573
- style: 'header-six'
577
+ "header-six": {
578
+ label: "styles.h6",
579
+ style: "header-six"
574
580
  }
575
581
  });
576
582
  var BlockTypeList = /*#__PURE__*/Object.freeze({
577
- 'unordered-list': {
583
+ "unordered-list": {
578
584
  label: /*#__PURE__*/React__default["default"].createElement(icons.BulletListIcon, null),
579
- style: 'unordered-list-item',
580
- tooltip: 'styles.unordered_list_item'
585
+ style: "unordered-list-item",
586
+ tooltip: "styles.unordered_list_item"
581
587
  },
582
- 'ordered-list': {
588
+ "ordered-list": {
583
589
  label: /*#__PURE__*/React__default["default"].createElement(icons.NumberListIcon, null),
584
- style: 'ordered-list-item',
585
- tooltip: 'styles.ordered_list_item'
590
+ style: "ordered-list-item",
591
+ tooltip: "styles.ordered_list_item"
586
592
  }
587
593
  });
588
594
  var InlineStylesList = /*#__PURE__*/Object.freeze({
589
595
  bold: {
590
596
  label: /*#__PURE__*/React__default["default"].createElement(icons.BoldIcon, null),
591
- style: 'BOLD',
592
- tooltip: 'styles.bold',
593
- hotKey: '(Ctrl+B)'
597
+ style: "BOLD",
598
+ tooltip: "styles.bold",
599
+ hotKey: "(Ctrl+B)"
594
600
  },
595
601
  italic: {
596
602
  label: /*#__PURE__*/React__default["default"].createElement(icons.ItalicIcon, null),
597
- style: 'ITALIC',
598
- tooltip: 'styles.italic',
599
- hotKey: '(Ctrl+I)'
603
+ style: "ITALIC",
604
+ tooltip: "styles.italic",
605
+ hotKey: "(Ctrl+I)"
600
606
  },
601
607
  underline: {
602
608
  label: /*#__PURE__*/React__default["default"].createElement(icons.UnderlineIcon, null),
603
- style: 'UNDERLINE',
604
- tooltip: 'styles.underline',
605
- hotKey: '(Ctrl+U)'
609
+ style: "UNDERLINE",
610
+ tooltip: "styles.underline",
611
+ hotKey: "(Ctrl+U)"
606
612
  }
607
613
  });
608
614
  var MinifiedConfigTypes = /*#__PURE__*/Object.freeze({
609
615
  fontList: [{
610
- type: 'unstyled',
611
- label: 'styles.p',
612
- style: 'unstyled'
616
+ type: "unstyled",
617
+ label: "styles.p",
618
+ style: "unstyled"
613
619
  }, {
614
- type: 'header-two',
615
- label: 'styles.h1',
616
- style: 'header-two'
620
+ type: "header-two",
621
+ label: "styles.h1",
622
+ style: "header-two"
617
623
  }],
618
624
  blockTypes: /*#__PURE__*/Object.values(EditorConfigTypes.BLOCK_TYPES),
619
625
  inlineStyles: [EditorConfigTypes.INLINE_STYLES.BOLD, EditorConfigTypes.INLINE_STYLES.ITALIC]
@@ -679,7 +685,7 @@ var RichTextEditor = /*#__PURE__*/function (_Component) {
679
685
  };
680
686
  _this.insertText = function (editorState, text) {
681
687
  var newContent = draftJs.Modifier.insertText(editorState.getCurrentContent(), editorState.getSelection(), text);
682
- _this.props.onChange(draftJs.EditorState.push(editorState, newContent, 'insert-characters'), function () {
688
+ _this.props.onChange(draftJs.EditorState.push(editorState, newContent, "insert-characters"), function () {
683
689
  return _this.focusEditor();
684
690
  });
685
691
  };
@@ -688,18 +694,18 @@ var RichTextEditor = /*#__PURE__*/function (_Component) {
688
694
  return controlConfig[panelType];
689
695
  };
690
696
  _this.getControlConfigBySet = function (config) {
691
- var fontList = (config && config.fontList || Object.keys(FontList)).filter(function (f) {
692
- return typeof f === 'object' ? FontList[f.type] : FontList[f];
697
+ var fontList = ((config == null ? void 0 : config.fontList) || Object.keys(FontList)).filter(function (f) {
698
+ return typeof f === "object" ? FontList[f.type] : FontList[f];
693
699
  }).map(function (f) {
694
700
  return f.label && f.style ? f : FontList[f];
695
701
  });
696
- var blockTypes = (config && config.blockTypes || Object.keys(BlockTypeList)).filter(function (f) {
697
- return typeof f === 'object' ? BlockTypeList[f.type] : BlockTypeList[f];
702
+ var blockTypes = ((config == null ? void 0 : config.blockTypes) || Object.keys(BlockTypeList)).filter(function (f) {
703
+ return typeof f === "object" ? BlockTypeList[f.type] : BlockTypeList[f];
698
704
  }).map(function (f) {
699
705
  return f.label && f.style ? f : BlockTypeList[f];
700
706
  });
701
- var inlineStyles = (config && config.inlineStyles || Object.keys(InlineStylesList)).filter(function (f) {
702
- return typeof f === 'object' ? InlineStylesList[f.type] : InlineStylesList[f];
707
+ var inlineStyles = ((config == null ? void 0 : config.inlineStyles) || Object.keys(InlineStylesList)).filter(function (f) {
708
+ return typeof f === "object" ? InlineStylesList[f.type] : InlineStylesList[f];
703
709
  }).map(function (f) {
704
710
  return f.label && f.style ? f : InlineStylesList[f];
705
711
  });
@@ -714,7 +720,8 @@ var RichTextEditor = /*#__PURE__*/function (_Component) {
714
720
  _inheritsLoose(RichTextEditor, _Component);
715
721
  var _proto = RichTextEditor.prototype;
716
722
  _proto.focusEditor = function focusEditor() {
717
- this.editor.current && this.editor.current.focus();
723
+ var _this$editor$current;
724
+ (_this$editor$current = this.editor.current) == null || _this$editor$current.focus();
718
725
  };
719
726
  _proto.render = function render() {
720
727
  var _this$props5 = this.props,
@@ -728,7 +735,7 @@ var RichTextEditor = /*#__PURE__*/function (_Component) {
728
735
  editorState = _this$props5.editorState,
729
736
  onChange = _this$props5.onChange,
730
737
  handleBeforeInput = _this$props5.handleBeforeInput;
731
- var classNames = cx__default["default"]('editor-root', className);
738
+ var classNames = cx__default["default"]("editor-root", className);
732
739
  return /*#__PURE__*/React__default["default"].createElement("div", {
733
740
  ref: this.wrapperRef
734
741
  }, label && /*#__PURE__*/React__default["default"].createElement(typography.Label, null, label), /*#__PURE__*/React__default["default"].createElement("div", {
@@ -738,15 +745,15 @@ var RichTextEditor = /*#__PURE__*/function (_Component) {
738
745
  }, showFontMenu && /*#__PURE__*/React__default["default"].createElement(BlockTypeControls, {
739
746
  editorState: editorState,
740
747
  onToggle: this.toggleSelectBlockType,
741
- blockTypes: this.getFontListConfigForPanelType('fontList')
748
+ blockTypes: this.getFontListConfigForPanelType("fontList")
742
749
  }), showInlineStyleMenu && /*#__PURE__*/React__default["default"].createElement(InlineStyleControls, {
743
750
  editorState: editorState,
744
751
  onToggle: this.toggleInlineStyle,
745
- inlineStyles: this.getFontListConfigForPanelType('inlineStyles')
752
+ inlineStyles: this.getFontListConfigForPanelType("inlineStyles")
746
753
  }), showTextFormatMenu && /*#__PURE__*/React__default["default"].createElement(BlockTypeButtonControls, {
747
754
  editorState: editorState,
748
755
  onToggle: this.toggleButtonBlockType,
749
- blockTypes: this.getFontListConfigForPanelType('blockTypes')
756
+ blockTypes: this.getFontListConfigForPanelType("blockTypes")
750
757
  }), showLinkMenu && /*#__PURE__*/React__default["default"].createElement(BlockTypeLinkControls$1, {
751
758
  editorState: editorState,
752
759
  onToggle: this.toggleLink
@@ -800,7 +807,7 @@ RichTextEditor.defaultProps = {
800
807
  showInlineStyleMenu: true,
801
808
  showTextFormatMenu: true,
802
809
  showLinkMenu: true,
803
- label: ''
810
+ label: ""
804
811
  };
805
812
 
806
813
  var editorStateToMarkdown = function editorStateToMarkdown(editorState) {
@@ -843,7 +850,7 @@ var RichTextEditorForLanguage = function RichTextEditorForLanguage(_ref) {
843
850
  var handleOnChange = function handleOnChange(changedState) {
844
851
  var newValues = _extends({}, values);
845
852
  var content = editorStateToMarkdown(changedState);
846
- if (values[langKey] && content === '\n') {
853
+ if (values[langKey] && content === "\n") {
847
854
  delete newValues[langKey];
848
855
  } else {
849
856
  newValues[langKey] = content;
@@ -851,16 +858,16 @@ var RichTextEditorForLanguage = function RichTextEditorForLanguage(_ref) {
851
858
  setEditorState(changedState);
852
859
  onChange(newValues);
853
860
  };
854
- var feedbackText = feedback && feedback(langKey);
861
+ var feedbackText = feedback == null ? void 0 : feedback(langKey);
855
862
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(RichTextEditor, {
856
- label: required ? label + '*' : label,
863
+ label: required ? label + "*" : label,
857
864
  editorState: editorState,
858
865
  onChange: function onChange(changedState) {
859
866
  return handleOnChange(changedState);
860
867
  },
861
868
  controlConfigSet: MinifiedConfigTypes,
862
869
  tags: tags
863
- }), variant && (feedbackText == null ? void 0 : feedbackText.length) > 0 && ( /*#__PURE__*/React__default["default"].createElement(form.FeedbackText, {
870
+ }), variant && feedbackText && feedbackText.length > 0 && ( /*#__PURE__*/React__default["default"].createElement(form.FeedbackText, {
864
871
  variant: variant(langKey)
865
872
  }, feedbackText)));
866
873
  };
@@ -873,9 +880,9 @@ var ExpandableMultiLanguageRichTextEditor = function ExpandableMultiLanguageRich
873
880
  title: title,
874
881
  defaultOpen: true,
875
882
  contentStyle: {
876
- padding: '4px 4px 4px 4px',
877
- marginTop: '16px',
878
- marginBottom: '16px'
883
+ padding: "4px 4px 4px 4px",
884
+ marginTop: "16px",
885
+ marginBottom: "16px"
879
886
  }
880
887
  }, /*#__PURE__*/React__default["default"].createElement(common.Stack, {
881
888
  space: "medium"
@@ -889,11 +896,9 @@ var ExpandableMultiLanguageRichTextEditor = function ExpandableMultiLanguageRich
889
896
  })));
890
897
  };
891
898
 
892
- /* eslint-disable react/display-name */
893
-
894
899
  var entityToHtml = {
895
900
  entityToHTML: function entityToHTML(entity, originalText) {
896
- if (entity.type === 'LINK') {
901
+ if (entity.type === "LINK") {
897
902
  return /*#__PURE__*/React__default["default"].createElement(HtmlLink, {
898
903
  url: entity.data.url
899
904
  }, originalText);
@@ -903,16 +908,13 @@ var entityToHtml = {
903
908
  };
904
909
  var htmlToEntity = {
905
910
  htmlToEntity: function htmlToEntity(nodeName, node, createEntity) {
906
- if (nodeName === 'a') {
907
- return createEntity('LINK', 'MUTABLE', {
911
+ if (nodeName === "a") {
912
+ return createEntity("LINK", "MUTABLE", {
908
913
  url: node.href
909
914
  });
910
915
  }
911
916
  }
912
917
  };
913
-
914
- /* eslint-disable react/display-name */
915
-
916
918
  var htmlToEditorState = function htmlToEditorState(html) {
917
919
  if (!html) {
918
920
  return draftJs.EditorState.createEmpty(decorator);