@entur-partner/rich-text-editor 6.2.3 → 6.2.4-alpha.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.
- package/dist/ExpandableMultiLanguageRichTextEditor.d.ts +21 -21
- package/dist/index.d.ts +5 -5
- package/dist/rich-text-editor.cjs.development.js +313 -330
- package/dist/rich-text-editor.cjs.development.js.map +1 -1
- package/dist/rich-text-editor.cjs.production.min.js +1 -1
- package/dist/rich-text-editor.cjs.production.min.js.map +1 -1
- package/dist/rich-text-editor.esm.js +247 -257
- package/dist/rich-text-editor.esm.js.map +1 -1
- package/dist/styles.css +14 -14
- package/package.json +60 -60
- package/dist/RichTextEditor/BlockTypeDropdown/index.d.ts +0 -3
- package/dist/RichTextEditor/Controls/BlockTypeButtonControls.d.ts +0 -3
- package/dist/RichTextEditor/Controls/BlockTypeLinkControls.d.ts +0 -3
- package/dist/RichTextEditor/Controls/BlockTypeSelectControls.d.ts +0 -7
- package/dist/RichTextEditor/Controls/InlineStyleControls.d.ts +0 -3
- package/dist/RichTextEditor/Controls/TagControls.d.ts +0 -3
- package/dist/RichTextEditor/Link/index.d.ts +0 -8
- package/dist/RichTextEditor/StyleButton/index.d.ts +0 -3
- package/dist/RichTextEditor/constants.d.ts +0 -94
- package/dist/RichTextEditor/htmlConvertion.d.ts +0 -9
- package/dist/RichTextEditor/index.d.ts +0 -58
- package/dist/RichTextEditor/markdownConvertion.d.ts +0 -4
- package/dist/events.d.ts +0 -4
- package/dist/withI18n.d.ts +0 -2
|
@@ -2,189 +2,76 @@
|
|
|
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
|
|
15
|
+
var icons = require('@entur/icons');
|
|
16
|
+
var dropdown = require('@entur/dropdown');
|
|
17
17
|
var menu = require('@entur/menu');
|
|
18
|
-
var
|
|
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');
|
|
22
22
|
|
|
23
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
24
|
-
|
|
25
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
26
|
-
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
27
|
-
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
28
|
-
var showdown__default = /*#__PURE__*/_interopDefaultLegacy(showdown);
|
|
29
|
-
|
|
30
23
|
function _extends() {
|
|
31
|
-
_extends = Object.assign ? Object.assign.bind() : function (
|
|
32
|
-
for (var
|
|
33
|
-
var
|
|
34
|
-
for (var
|
|
35
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
36
|
-
target[key] = source[key];
|
|
37
|
-
}
|
|
38
|
-
}
|
|
24
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
25
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
26
|
+
var t = arguments[e];
|
|
27
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
39
28
|
}
|
|
40
|
-
return
|
|
41
|
-
};
|
|
42
|
-
return _extends.apply(this, arguments);
|
|
43
|
-
}
|
|
44
|
-
function _inheritsLoose(subClass, superClass) {
|
|
45
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
46
|
-
subClass.prototype.constructor = subClass;
|
|
47
|
-
_setPrototypeOf(subClass, superClass);
|
|
29
|
+
return n;
|
|
30
|
+
}, _extends.apply(null, arguments);
|
|
48
31
|
}
|
|
49
|
-
function
|
|
50
|
-
|
|
51
|
-
o.__proto__ = p;
|
|
52
|
-
return o;
|
|
53
|
-
};
|
|
54
|
-
return _setPrototypeOf(o, p);
|
|
32
|
+
function _inheritsLoose(t, o) {
|
|
33
|
+
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
|
|
55
34
|
}
|
|
56
|
-
function _objectWithoutPropertiesLoose(
|
|
57
|
-
if (
|
|
58
|
-
var
|
|
59
|
-
var
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
key = sourceKeys[i];
|
|
63
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
64
|
-
target[key] = source[key];
|
|
35
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
36
|
+
if (null == r) return {};
|
|
37
|
+
var t = {};
|
|
38
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
39
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
40
|
+
t[n] = r[n];
|
|
65
41
|
}
|
|
66
|
-
return
|
|
42
|
+
return t;
|
|
43
|
+
}
|
|
44
|
+
function _setPrototypeOf(t, e) {
|
|
45
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
46
|
+
return t.__proto__ = e, t;
|
|
47
|
+
}, _setPrototypeOf(t, e);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
var Key = /*#__PURE__*/Object.freeze({
|
|
51
|
+
ENTER: 13
|
|
52
|
+
});
|
|
53
|
+
function getKey(event) {
|
|
54
|
+
return event.keyCode || event.which;
|
|
67
55
|
}
|
|
68
56
|
|
|
69
57
|
function useI18N() {
|
|
70
58
|
var _useTranslation = reactI18next.useTranslation(),
|
|
71
59
|
t = _useTranslation.t,
|
|
72
60
|
language = _useTranslation.i18n.language;
|
|
73
|
-
if (language !==
|
|
74
|
-
throw Error(
|
|
61
|
+
if (language !== "nb" && language !== "en" && language !== "nb-NO" && language !== "en-GB") {
|
|
62
|
+
throw Error("Language must be either nb or en.");
|
|
75
63
|
}
|
|
76
64
|
return t;
|
|
77
65
|
}
|
|
78
66
|
function withI18n(Component) {
|
|
79
67
|
return function WrappedComponent(props) {
|
|
80
68
|
var t = useI18N();
|
|
81
|
-
return /*#__PURE__*/
|
|
69
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
82
70
|
i18n: t
|
|
83
71
|
}));
|
|
84
72
|
};
|
|
85
73
|
}
|
|
86
74
|
|
|
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
75
|
var StyleButton = /*#__PURE__*/function (_Component) {
|
|
189
76
|
function StyleButton() {
|
|
190
77
|
var _this;
|
|
@@ -217,20 +104,26 @@ var StyleButton = /*#__PURE__*/function (_Component) {
|
|
|
217
104
|
label = _this$props3.label,
|
|
218
105
|
title = _this$props3.title,
|
|
219
106
|
hotKey = _this$props3.hotKey;
|
|
220
|
-
var classNames =
|
|
107
|
+
var classNames = cx("editor-stylebutton", {
|
|
221
108
|
active: active
|
|
222
109
|
});
|
|
223
|
-
return
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
110
|
+
return (
|
|
111
|
+
/*#__PURE__*/
|
|
112
|
+
// biome-ignore lint/a11y/noStaticElementInteractions: Ignore for now.
|
|
113
|
+
React.createElement("div", {
|
|
114
|
+
className: classNames,
|
|
115
|
+
onMouseDown: this.onToggle,
|
|
116
|
+
title: i18n(title) + hotKey
|
|
117
|
+
// biome-ignore lint/a11y/noNoninteractiveTabindex: Ignore for now.
|
|
118
|
+
,
|
|
119
|
+
tabIndex: 0,
|
|
120
|
+
onKeyPress: function onKeyPress(event) {
|
|
121
|
+
if (getKey(event) === Key.ENTER) {
|
|
122
|
+
_this2.onToggleNoEvent();
|
|
123
|
+
}
|
|
231
124
|
}
|
|
232
|
-
}
|
|
233
|
-
|
|
125
|
+
}, label)
|
|
126
|
+
);
|
|
234
127
|
};
|
|
235
128
|
return StyleButton;
|
|
236
129
|
}(React.Component);
|
|
@@ -242,11 +135,11 @@ var BlockTypeButtonControls = function BlockTypeButtonControls(props) {
|
|
|
242
135
|
onToggle = props.onToggle;
|
|
243
136
|
var selection = editorState.getSelection();
|
|
244
137
|
var blockTypeStyle = editorState.getCurrentContent().getBlockForKey(selection.getStartKey()).getType();
|
|
245
|
-
return /*#__PURE__*/
|
|
138
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
246
139
|
className: "controls-group block-editor-controls"
|
|
247
|
-
}, blockTypes.map(function (type
|
|
248
|
-
return /*#__PURE__*/
|
|
249
|
-
key:
|
|
140
|
+
}, blockTypes.map(function (type) {
|
|
141
|
+
return /*#__PURE__*/React.createElement(StyleButton$1, {
|
|
142
|
+
key: type.style + type.label,
|
|
250
143
|
active: type.style === blockTypeStyle,
|
|
251
144
|
label: type.label,
|
|
252
145
|
onToggle: onToggle,
|
|
@@ -264,7 +157,7 @@ var BlockTypeLinkControls = /*#__PURE__*/function (_Component) {
|
|
|
264
157
|
}
|
|
265
158
|
_this = _Component.call.apply(_Component, [this].concat(args)) || this;
|
|
266
159
|
_this.state = {
|
|
267
|
-
urlValue:
|
|
160
|
+
urlValue: "",
|
|
268
161
|
showUrlInput: false,
|
|
269
162
|
hasLink: false
|
|
270
163
|
};
|
|
@@ -283,7 +176,7 @@ var BlockTypeLinkControls = /*#__PURE__*/function (_Component) {
|
|
|
283
176
|
var startOffset = selection.getStartOffset();
|
|
284
177
|
var blockWithLinkAtBeginning = currentContent.getBlockForKey(startKey);
|
|
285
178
|
var linkKey = blockWithLinkAtBeginning.getEntityAt(startOffset);
|
|
286
|
-
var url =
|
|
179
|
+
var url = "";
|
|
287
180
|
if (linkKey) {
|
|
288
181
|
var linkInstance = currentContent.getEntity(linkKey);
|
|
289
182
|
url = linkInstance.getData().url;
|
|
@@ -302,7 +195,7 @@ var BlockTypeLinkControls = /*#__PURE__*/function (_Component) {
|
|
|
302
195
|
editorState = _this$props.editorState,
|
|
303
196
|
onToggle = _this$props.onToggle;
|
|
304
197
|
var contentState = editorState.getCurrentContent();
|
|
305
|
-
var contentStateWithEntity = contentState.createEntity(
|
|
198
|
+
var contentStateWithEntity = contentState.createEntity("LINK", "MUTABLE", {
|
|
306
199
|
url: urlValue
|
|
307
200
|
});
|
|
308
201
|
var entityKey = contentStateWithEntity.getLastCreatedEntityKey();
|
|
@@ -312,14 +205,14 @@ var BlockTypeLinkControls = /*#__PURE__*/function (_Component) {
|
|
|
312
205
|
onToggle(newEditorState, entityKey);
|
|
313
206
|
_this.setState({
|
|
314
207
|
showUrlInput: false,
|
|
315
|
-
urlValue:
|
|
208
|
+
urlValue: ""
|
|
316
209
|
});
|
|
317
210
|
};
|
|
318
211
|
_this.cancelLink = function (e) {
|
|
319
212
|
e.preventDefault();
|
|
320
213
|
_this.setState({
|
|
321
214
|
showUrlInput: false,
|
|
322
|
-
urlValue:
|
|
215
|
+
urlValue: ""
|
|
323
216
|
});
|
|
324
217
|
};
|
|
325
218
|
_this.onLinkInputKeyDown = function (e) {
|
|
@@ -350,23 +243,23 @@ var BlockTypeLinkControls = /*#__PURE__*/function (_Component) {
|
|
|
350
243
|
var _this$state = this.state,
|
|
351
244
|
showUrlInput = _this$state.showUrlInput,
|
|
352
245
|
hasLink = _this$state.hasLink;
|
|
353
|
-
return /*#__PURE__*/
|
|
246
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
354
247
|
className: "controls-group block-editor-controls link-controls"
|
|
355
|
-
}, /*#__PURE__*/
|
|
248
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
356
249
|
className: "editor-stylebutton",
|
|
357
|
-
title: i18n(
|
|
250
|
+
title: i18n("styles.link"),
|
|
358
251
|
onClick: this.addLink,
|
|
359
252
|
tabIndex: 0
|
|
360
|
-
}, /*#__PURE__*/
|
|
253
|
+
}, /*#__PURE__*/React.createElement(icons.LinkIcon, null)), showUrlInput && /*#__PURE__*/React.createElement("div", {
|
|
361
254
|
className: "url-input-container"
|
|
362
|
-
}, /*#__PURE__*/
|
|
255
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
363
256
|
className: "exit-button",
|
|
364
257
|
onMouseDown: this.cancelLink
|
|
365
|
-
}, /*#__PURE__*/
|
|
258
|
+
}, /*#__PURE__*/React.createElement(icons.CloseIcon, null)), /*#__PURE__*/React.createElement("div", {
|
|
366
259
|
className: "link-label"
|
|
367
|
-
}, i18n(
|
|
260
|
+
}, i18n("common.from")), /*#__PURE__*/React.createElement("div", {
|
|
368
261
|
className: "url-input-form"
|
|
369
|
-
}, /*#__PURE__*/
|
|
262
|
+
}, /*#__PURE__*/React.createElement(form.TextField, {
|
|
370
263
|
style: {
|
|
371
264
|
width: 250,
|
|
372
265
|
margin: 5
|
|
@@ -375,35 +268,129 @@ var BlockTypeLinkControls = /*#__PURE__*/function (_Component) {
|
|
|
375
268
|
value: this.state.urlValue,
|
|
376
269
|
onKeyDown: this.onLinkInputKeyDown,
|
|
377
270
|
placeholder: "https://example.com"
|
|
378
|
-
}), /*#__PURE__*/
|
|
271
|
+
}), /*#__PURE__*/React.createElement(button.SecondarySquareButton, {
|
|
379
272
|
onMouseDown: this.confirmLink
|
|
380
|
-
}, /*#__PURE__*/
|
|
273
|
+
}, /*#__PURE__*/React.createElement(icons.CheckIcon, {
|
|
381
274
|
width: 15,
|
|
382
275
|
height: 15
|
|
383
|
-
}))), hasLink && /*#__PURE__*/
|
|
276
|
+
}))), hasLink && /*#__PURE__*/React.createElement("div", {
|
|
384
277
|
className: "remove-link"
|
|
385
|
-
}, /*#__PURE__*/
|
|
278
|
+
}, /*#__PURE__*/React.createElement(common.Unbutton, {
|
|
386
279
|
onClick: this.removeLink,
|
|
387
|
-
title: i18n(
|
|
388
|
-
}, /*#__PURE__*/
|
|
280
|
+
title: i18n("styles.unlink")
|
|
281
|
+
}, /*#__PURE__*/React.createElement(icons.UnlinkIcon, null), i18n("styles.unlink")))));
|
|
389
282
|
};
|
|
390
283
|
return BlockTypeLinkControls;
|
|
391
284
|
}(React.Component);
|
|
392
285
|
BlockTypeLinkControls.propTypes = {
|
|
393
|
-
editorState:
|
|
394
|
-
onToggle:
|
|
286
|
+
editorState: PropTypes.object,
|
|
287
|
+
onToggle: PropTypes.func
|
|
395
288
|
};
|
|
396
289
|
var BlockTypeLinkControls$1 = /*#__PURE__*/withI18n(BlockTypeLinkControls);
|
|
397
290
|
|
|
291
|
+
var BlockTypeDropdown = /*#__PURE__*/function (_Component) {
|
|
292
|
+
function BlockTypeDropdown() {
|
|
293
|
+
var _this;
|
|
294
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
295
|
+
args[_key] = arguments[_key];
|
|
296
|
+
}
|
|
297
|
+
_this = _Component.call.apply(_Component, [this].concat(args)) || this;
|
|
298
|
+
_this.handleOnClick = function (selectedOption) {
|
|
299
|
+
var onChange = _this.props.onChange;
|
|
300
|
+
onChange(selectedOption);
|
|
301
|
+
};
|
|
302
|
+
return _this;
|
|
303
|
+
}
|
|
304
|
+
_inheritsLoose(BlockTypeDropdown, _Component);
|
|
305
|
+
var _proto = BlockTypeDropdown.prototype;
|
|
306
|
+
_proto.toItem = function toItem(option) {
|
|
307
|
+
return {
|
|
308
|
+
value: option.style,
|
|
309
|
+
label: this.renderFormattedLabel(option.label)
|
|
310
|
+
};
|
|
311
|
+
};
|
|
312
|
+
_proto.renderFormattedLabel = function renderFormattedLabel(label) {
|
|
313
|
+
var formattedLabelText = this.props.i18n(label);
|
|
314
|
+
switch (label) {
|
|
315
|
+
case "styles.p":
|
|
316
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
317
|
+
className: "default-p"
|
|
318
|
+
}, formattedLabelText);
|
|
319
|
+
case "styles.h1":
|
|
320
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
321
|
+
className: "default-h1"
|
|
322
|
+
}, formattedLabelText);
|
|
323
|
+
case "styles.h2":
|
|
324
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
325
|
+
className: "default-h2"
|
|
326
|
+
}, formattedLabelText);
|
|
327
|
+
case "styles.h3":
|
|
328
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
329
|
+
className: "default-h3"
|
|
330
|
+
}, formattedLabelText);
|
|
331
|
+
case "styles.h4":
|
|
332
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
333
|
+
className: "default-h4"
|
|
334
|
+
}, formattedLabelText);
|
|
335
|
+
case "styles.h5":
|
|
336
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
337
|
+
className: "default-h5"
|
|
338
|
+
}, formattedLabelText);
|
|
339
|
+
case "styles.h6":
|
|
340
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
341
|
+
className: "default-h6"
|
|
342
|
+
}, formattedLabelText);
|
|
343
|
+
default:
|
|
344
|
+
return /*#__PURE__*/React.createElement("p", null, formattedLabelText);
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
_proto.render = function render() {
|
|
348
|
+
var _this2 = this;
|
|
349
|
+
var _this$props = this.props,
|
|
350
|
+
options = _this$props.options,
|
|
351
|
+
selected = _this$props.selected,
|
|
352
|
+
i18n = _this$props.i18n;
|
|
353
|
+
return /*#__PURE__*/React.createElement(dropdown.Dropdown, {
|
|
354
|
+
className: "block-type-dropdown",
|
|
355
|
+
items: options.map(function (option) {
|
|
356
|
+
return _this2.toItem(option);
|
|
357
|
+
}),
|
|
358
|
+
selectedItem: this.toItem(selected),
|
|
359
|
+
label: i18n("styles.style"),
|
|
360
|
+
onChange: function onChange(selectedItem) {
|
|
361
|
+
return _this2.handleOnClick(selectedItem.value);
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
};
|
|
365
|
+
return BlockTypeDropdown;
|
|
366
|
+
}(React.Component);
|
|
367
|
+
var BlockTypeDropdown$1 = /*#__PURE__*/withI18n(BlockTypeDropdown);
|
|
368
|
+
|
|
369
|
+
var BlockTypeControls = function BlockTypeControls(_ref) {
|
|
370
|
+
var editorState = _ref.editorState,
|
|
371
|
+
blockTypes = _ref.blockTypes,
|
|
372
|
+
onToggle = _ref.onToggle;
|
|
373
|
+
var selection = editorState.getSelection();
|
|
374
|
+
var blockTypeStyle = editorState.getCurrentContent().getBlockForKey(selection.getStartKey()).getType();
|
|
375
|
+
var selectedOption = blockTypes.find(function (option) {
|
|
376
|
+
return option.style === blockTypeStyle;
|
|
377
|
+
}) || blockTypes[0];
|
|
378
|
+
return /*#__PURE__*/React.createElement(BlockTypeDropdown$1, {
|
|
379
|
+
options: blockTypes,
|
|
380
|
+
selected: selectedOption,
|
|
381
|
+
onChange: onToggle
|
|
382
|
+
});
|
|
383
|
+
};
|
|
384
|
+
|
|
398
385
|
var InlineStyleControls = function InlineStyleControls(props) {
|
|
399
386
|
var editorState = props.editorState,
|
|
400
387
|
inlineStyles = props.inlineStyles;
|
|
401
388
|
var currentStyle = editorState.getCurrentInlineStyle();
|
|
402
|
-
return /*#__PURE__*/
|
|
389
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
403
390
|
className: "controls-group inline-editor-controls"
|
|
404
|
-
}, inlineStyles.map(function (type
|
|
405
|
-
return /*#__PURE__*/
|
|
406
|
-
key:
|
|
391
|
+
}, inlineStyles.map(function (type) {
|
|
392
|
+
return /*#__PURE__*/React.createElement(StyleButton$1, {
|
|
393
|
+
key: type.style + type.label,
|
|
407
394
|
active: currentStyle.has(type.style),
|
|
408
395
|
label: type.label,
|
|
409
396
|
onToggle: props.onToggle,
|
|
@@ -426,7 +413,7 @@ var TagControls = /*#__PURE__*/function (_Component) {
|
|
|
426
413
|
isOpen: false
|
|
427
414
|
};
|
|
428
415
|
_this.handleClickOutside = function (e) {
|
|
429
|
-
if (_this.tagControlRef
|
|
416
|
+
if (_this.tagControlRef.current && !_this.tagControlRef.current.contains(e.target)) {
|
|
430
417
|
_this.setState({
|
|
431
418
|
isOpen: false
|
|
432
419
|
});
|
|
@@ -446,10 +433,10 @@ var TagControls = /*#__PURE__*/function (_Component) {
|
|
|
446
433
|
_inheritsLoose(TagControls, _Component);
|
|
447
434
|
var _proto = TagControls.prototype;
|
|
448
435
|
_proto.componentDidMount = function componentDidMount() {
|
|
449
|
-
document.addEventListener(
|
|
436
|
+
document.addEventListener("mousedown", this.handleClickOutside);
|
|
450
437
|
};
|
|
451
438
|
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
452
|
-
document.removeEventListener(
|
|
439
|
+
document.removeEventListener("mousedown", this.handleClickOutside);
|
|
453
440
|
};
|
|
454
441
|
_proto.render = function render() {
|
|
455
442
|
var _this2 = this;
|
|
@@ -457,23 +444,23 @@ var TagControls = /*#__PURE__*/function (_Component) {
|
|
|
457
444
|
i18n = _this$props2.i18n,
|
|
458
445
|
tags = _this$props2.tags;
|
|
459
446
|
var isOpen = this.state.isOpen;
|
|
460
|
-
var menuItems = tags.map(function (tag
|
|
461
|
-
var delimiter = tag.delimiter ||
|
|
462
|
-
return /*#__PURE__*/
|
|
463
|
-
key:
|
|
447
|
+
var menuItems = tags.map(function (tag) {
|
|
448
|
+
var delimiter = tag.delimiter || "{}";
|
|
449
|
+
return /*#__PURE__*/React.createElement(menu.OverflowMenuItem, {
|
|
450
|
+
key: tag.tag,
|
|
464
451
|
className: "tag-control",
|
|
465
|
-
id:
|
|
452
|
+
id: "tag-control-" + tag.tag,
|
|
466
453
|
onClick: function onClick() {
|
|
467
454
|
return _this2.handleTagClick(tag.tag, delimiter);
|
|
468
455
|
}
|
|
469
|
-
}, tag.icon, /*#__PURE__*/
|
|
456
|
+
}, tag.icon, /*#__PURE__*/React.createElement("span", {
|
|
470
457
|
className: "tag-control-text"
|
|
471
458
|
}, tag.label));
|
|
472
459
|
});
|
|
473
|
-
return /*#__PURE__*/
|
|
460
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
474
461
|
className: "tag-control-dropdown",
|
|
475
462
|
ref: this.tagControlRef
|
|
476
|
-
}, /*#__PURE__*/
|
|
463
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
477
464
|
className: "tag-control-header",
|
|
478
465
|
onClick: function onClick() {
|
|
479
466
|
return _this2.setState(function (_ref) {
|
|
@@ -483,137 +470,137 @@ var TagControls = /*#__PURE__*/function (_Component) {
|
|
|
483
470
|
};
|
|
484
471
|
});
|
|
485
472
|
}
|
|
486
|
-
}, i18n(
|
|
473
|
+
}, i18n("common.insert"), /*#__PURE__*/React.createElement(icons.DownArrowIcon, {
|
|
487
474
|
className: "tag-control-chevron",
|
|
488
475
|
inline: true
|
|
489
|
-
})), /*#__PURE__*/
|
|
476
|
+
})), /*#__PURE__*/React.createElement(tooltip.Popover, {
|
|
490
477
|
open: isOpen,
|
|
491
478
|
className: "tag-control-content"
|
|
492
|
-
}, /*#__PURE__*/
|
|
479
|
+
}, /*#__PURE__*/React.createElement(menu.OverflowMenu, {
|
|
493
480
|
className: "action-menu"
|
|
494
481
|
}, menuItems)));
|
|
495
482
|
};
|
|
496
483
|
return TagControls;
|
|
497
484
|
}(React.Component);
|
|
498
485
|
TagControls.propTypes = {
|
|
499
|
-
editorState:
|
|
500
|
-
tags:
|
|
501
|
-
onInsertTag:
|
|
486
|
+
editorState: PropTypes.object,
|
|
487
|
+
tags: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
488
|
+
onInsertTag: PropTypes.func.isRequired
|
|
502
489
|
};
|
|
503
490
|
var TagControls$1 = /*#__PURE__*/withI18n(TagControls);
|
|
504
491
|
|
|
505
492
|
var HtmlLink = function HtmlLink(_ref) {
|
|
506
493
|
var url = _ref.url,
|
|
507
494
|
children = _ref.children;
|
|
508
|
-
return /*#__PURE__*/
|
|
495
|
+
return /*#__PURE__*/React.createElement("a", {
|
|
509
496
|
href: url
|
|
510
497
|
}, children);
|
|
511
498
|
};
|
|
512
499
|
var Link = function Link(props) {
|
|
513
500
|
var _props$contentState$g = props.contentState.getEntity(props.entityKey).getData(),
|
|
514
501
|
url = _props$contentState$g.url;
|
|
515
|
-
return /*#__PURE__*/
|
|
502
|
+
return /*#__PURE__*/React.createElement(HtmlLink, {
|
|
516
503
|
url: url
|
|
517
504
|
}, props.children);
|
|
518
505
|
};
|
|
519
506
|
function findLinkEntities(contentBlock, callback, contentState) {
|
|
520
507
|
contentBlock.findEntityRanges(function (character) {
|
|
521
508
|
var entityKey = character.getEntity();
|
|
522
|
-
return entityKey !== null && contentState.getEntity(entityKey).getType() ===
|
|
509
|
+
return entityKey !== null && contentState.getEntity(entityKey).getType() === "LINK";
|
|
523
510
|
}, callback);
|
|
524
511
|
}
|
|
525
512
|
|
|
526
513
|
var EditorConfigTypes = /*#__PURE__*/Object.freeze({
|
|
527
514
|
FONT_LIST: {
|
|
528
|
-
UNSTYLED:
|
|
529
|
-
HEADER_ONE:
|
|
530
|
-
HEADER_TWO:
|
|
531
|
-
HEADER_THREE:
|
|
532
|
-
HEADER_FOUR:
|
|
533
|
-
HEADER_FIVE:
|
|
534
|
-
HEADER_SIX:
|
|
515
|
+
UNSTYLED: "unstyled",
|
|
516
|
+
HEADER_ONE: "header-one",
|
|
517
|
+
HEADER_TWO: "header-two",
|
|
518
|
+
HEADER_THREE: "header-three",
|
|
519
|
+
HEADER_FOUR: "header-four",
|
|
520
|
+
HEADER_FIVE: "header-five",
|
|
521
|
+
HEADER_SIX: "header-six"
|
|
535
522
|
},
|
|
536
523
|
BLOCK_TYPES: {
|
|
537
|
-
UNORDERED_LIST:
|
|
538
|
-
ORDERED_LIST:
|
|
524
|
+
UNORDERED_LIST: "unordered-list",
|
|
525
|
+
ORDERED_LIST: "ordered-list"
|
|
539
526
|
},
|
|
540
527
|
INLINE_STYLES: {
|
|
541
|
-
BOLD:
|
|
542
|
-
ITALIC:
|
|
543
|
-
UNDERLINE:
|
|
528
|
+
BOLD: "bold",
|
|
529
|
+
ITALIC: "italic",
|
|
530
|
+
UNDERLINE: "underline"
|
|
544
531
|
}
|
|
545
532
|
});
|
|
546
533
|
var FontList = /*#__PURE__*/Object.freeze({
|
|
547
534
|
unstyled: {
|
|
548
|
-
label:
|
|
549
|
-
style:
|
|
535
|
+
label: "styles.p",
|
|
536
|
+
style: "unstyled"
|
|
550
537
|
},
|
|
551
|
-
|
|
552
|
-
label:
|
|
553
|
-
style:
|
|
538
|
+
"header-one": {
|
|
539
|
+
label: "styles.h1",
|
|
540
|
+
style: "header-one"
|
|
554
541
|
},
|
|
555
|
-
|
|
556
|
-
label:
|
|
557
|
-
style:
|
|
542
|
+
"header-two": {
|
|
543
|
+
label: "styles.h2",
|
|
544
|
+
style: "header-two"
|
|
558
545
|
},
|
|
559
|
-
|
|
560
|
-
label:
|
|
561
|
-
style:
|
|
546
|
+
"header-three": {
|
|
547
|
+
label: "styles.h3",
|
|
548
|
+
style: "header-three"
|
|
562
549
|
},
|
|
563
|
-
|
|
564
|
-
label:
|
|
565
|
-
style:
|
|
550
|
+
"header-four": {
|
|
551
|
+
label: "styles.h4",
|
|
552
|
+
style: "header-four"
|
|
566
553
|
},
|
|
567
|
-
|
|
568
|
-
label:
|
|
569
|
-
style:
|
|
554
|
+
"header-five": {
|
|
555
|
+
label: "styles.h5",
|
|
556
|
+
style: "header-five"
|
|
570
557
|
},
|
|
571
|
-
|
|
572
|
-
label:
|
|
573
|
-
style:
|
|
558
|
+
"header-six": {
|
|
559
|
+
label: "styles.h6",
|
|
560
|
+
style: "header-six"
|
|
574
561
|
}
|
|
575
562
|
});
|
|
576
563
|
var BlockTypeList = /*#__PURE__*/Object.freeze({
|
|
577
|
-
|
|
578
|
-
label: /*#__PURE__*/
|
|
579
|
-
style:
|
|
580
|
-
tooltip:
|
|
564
|
+
"unordered-list": {
|
|
565
|
+
label: /*#__PURE__*/React.createElement(icons.BulletListIcon, null),
|
|
566
|
+
style: "unordered-list-item",
|
|
567
|
+
tooltip: "styles.unordered_list_item"
|
|
581
568
|
},
|
|
582
|
-
|
|
583
|
-
label: /*#__PURE__*/
|
|
584
|
-
style:
|
|
585
|
-
tooltip:
|
|
569
|
+
"ordered-list": {
|
|
570
|
+
label: /*#__PURE__*/React.createElement(icons.NumberListIcon, null),
|
|
571
|
+
style: "ordered-list-item",
|
|
572
|
+
tooltip: "styles.ordered_list_item"
|
|
586
573
|
}
|
|
587
574
|
});
|
|
588
575
|
var InlineStylesList = /*#__PURE__*/Object.freeze({
|
|
589
576
|
bold: {
|
|
590
|
-
label: /*#__PURE__*/
|
|
591
|
-
style:
|
|
592
|
-
tooltip:
|
|
593
|
-
hotKey:
|
|
577
|
+
label: /*#__PURE__*/React.createElement(icons.BoldIcon, null),
|
|
578
|
+
style: "BOLD",
|
|
579
|
+
tooltip: "styles.bold",
|
|
580
|
+
hotKey: "(Ctrl+B)"
|
|
594
581
|
},
|
|
595
582
|
italic: {
|
|
596
|
-
label: /*#__PURE__*/
|
|
597
|
-
style:
|
|
598
|
-
tooltip:
|
|
599
|
-
hotKey:
|
|
583
|
+
label: /*#__PURE__*/React.createElement(icons.ItalicIcon, null),
|
|
584
|
+
style: "ITALIC",
|
|
585
|
+
tooltip: "styles.italic",
|
|
586
|
+
hotKey: "(Ctrl+I)"
|
|
600
587
|
},
|
|
601
588
|
underline: {
|
|
602
|
-
label: /*#__PURE__*/
|
|
603
|
-
style:
|
|
604
|
-
tooltip:
|
|
605
|
-
hotKey:
|
|
589
|
+
label: /*#__PURE__*/React.createElement(icons.UnderlineIcon, null),
|
|
590
|
+
style: "UNDERLINE",
|
|
591
|
+
tooltip: "styles.underline",
|
|
592
|
+
hotKey: "(Ctrl+U)"
|
|
606
593
|
}
|
|
607
594
|
});
|
|
608
595
|
var MinifiedConfigTypes = /*#__PURE__*/Object.freeze({
|
|
609
596
|
fontList: [{
|
|
610
|
-
type:
|
|
611
|
-
label:
|
|
612
|
-
style:
|
|
597
|
+
type: "unstyled",
|
|
598
|
+
label: "styles.p",
|
|
599
|
+
style: "unstyled"
|
|
613
600
|
}, {
|
|
614
|
-
type:
|
|
615
|
-
label:
|
|
616
|
-
style:
|
|
601
|
+
type: "header-two",
|
|
602
|
+
label: "styles.h1",
|
|
603
|
+
style: "header-two"
|
|
617
604
|
}],
|
|
618
605
|
blockTypes: /*#__PURE__*/Object.values(EditorConfigTypes.BLOCK_TYPES),
|
|
619
606
|
inlineStyles: [EditorConfigTypes.INLINE_STYLES.BOLD, EditorConfigTypes.INLINE_STYLES.ITALIC]
|
|
@@ -679,7 +666,7 @@ var RichTextEditor = /*#__PURE__*/function (_Component) {
|
|
|
679
666
|
};
|
|
680
667
|
_this.insertText = function (editorState, text) {
|
|
681
668
|
var newContent = draftJs.Modifier.insertText(editorState.getCurrentContent(), editorState.getSelection(), text);
|
|
682
|
-
_this.props.onChange(draftJs.EditorState.push(editorState, newContent,
|
|
669
|
+
_this.props.onChange(draftJs.EditorState.push(editorState, newContent, "insert-characters"), function () {
|
|
683
670
|
return _this.focusEditor();
|
|
684
671
|
});
|
|
685
672
|
};
|
|
@@ -688,18 +675,18 @@ var RichTextEditor = /*#__PURE__*/function (_Component) {
|
|
|
688
675
|
return controlConfig[panelType];
|
|
689
676
|
};
|
|
690
677
|
_this.getControlConfigBySet = function (config) {
|
|
691
|
-
var fontList = (config
|
|
692
|
-
return typeof f ===
|
|
678
|
+
var fontList = ((config == null ? void 0 : config.fontList) || Object.keys(FontList)).filter(function (f) {
|
|
679
|
+
return typeof f === "object" ? FontList[f.type] : FontList[f];
|
|
693
680
|
}).map(function (f) {
|
|
694
681
|
return f.label && f.style ? f : FontList[f];
|
|
695
682
|
});
|
|
696
|
-
var blockTypes = (config
|
|
697
|
-
return typeof f ===
|
|
683
|
+
var blockTypes = ((config == null ? void 0 : config.blockTypes) || Object.keys(BlockTypeList)).filter(function (f) {
|
|
684
|
+
return typeof f === "object" ? BlockTypeList[f.type] : BlockTypeList[f];
|
|
698
685
|
}).map(function (f) {
|
|
699
686
|
return f.label && f.style ? f : BlockTypeList[f];
|
|
700
687
|
});
|
|
701
|
-
var inlineStyles = (config
|
|
702
|
-
return typeof f ===
|
|
688
|
+
var inlineStyles = ((config == null ? void 0 : config.inlineStyles) || Object.keys(InlineStylesList)).filter(function (f) {
|
|
689
|
+
return typeof f === "object" ? InlineStylesList[f.type] : InlineStylesList[f];
|
|
703
690
|
}).map(function (f) {
|
|
704
691
|
return f.label && f.style ? f : InlineStylesList[f];
|
|
705
692
|
});
|
|
@@ -714,7 +701,8 @@ var RichTextEditor = /*#__PURE__*/function (_Component) {
|
|
|
714
701
|
_inheritsLoose(RichTextEditor, _Component);
|
|
715
702
|
var _proto = RichTextEditor.prototype;
|
|
716
703
|
_proto.focusEditor = function focusEditor() {
|
|
717
|
-
|
|
704
|
+
var _this$editor$current;
|
|
705
|
+
(_this$editor$current = this.editor.current) == null || _this$editor$current.focus();
|
|
718
706
|
};
|
|
719
707
|
_proto.render = function render() {
|
|
720
708
|
var _this$props5 = this.props,
|
|
@@ -728,35 +716,35 @@ var RichTextEditor = /*#__PURE__*/function (_Component) {
|
|
|
728
716
|
editorState = _this$props5.editorState,
|
|
729
717
|
onChange = _this$props5.onChange,
|
|
730
718
|
handleBeforeInput = _this$props5.handleBeforeInput;
|
|
731
|
-
var classNames =
|
|
732
|
-
return /*#__PURE__*/
|
|
719
|
+
var classNames = cx("editor-root", className);
|
|
720
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
733
721
|
ref: this.wrapperRef
|
|
734
|
-
}, label && /*#__PURE__*/
|
|
722
|
+
}, label && /*#__PURE__*/React.createElement(typography.Label, null, label), /*#__PURE__*/React.createElement("div", {
|
|
735
723
|
className: classNames
|
|
736
|
-
}, /*#__PURE__*/
|
|
724
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
737
725
|
className: "controls-wrapper"
|
|
738
|
-
}, showFontMenu && /*#__PURE__*/
|
|
726
|
+
}, showFontMenu && /*#__PURE__*/React.createElement(BlockTypeControls, {
|
|
739
727
|
editorState: editorState,
|
|
740
728
|
onToggle: this.toggleSelectBlockType,
|
|
741
|
-
blockTypes: this.getFontListConfigForPanelType(
|
|
742
|
-
}), showInlineStyleMenu && /*#__PURE__*/
|
|
729
|
+
blockTypes: this.getFontListConfigForPanelType("fontList")
|
|
730
|
+
}), showInlineStyleMenu && /*#__PURE__*/React.createElement(InlineStyleControls, {
|
|
743
731
|
editorState: editorState,
|
|
744
732
|
onToggle: this.toggleInlineStyle,
|
|
745
|
-
inlineStyles: this.getFontListConfigForPanelType(
|
|
746
|
-
}), showTextFormatMenu && /*#__PURE__*/
|
|
733
|
+
inlineStyles: this.getFontListConfigForPanelType("inlineStyles")
|
|
734
|
+
}), showTextFormatMenu && /*#__PURE__*/React.createElement(BlockTypeButtonControls, {
|
|
747
735
|
editorState: editorState,
|
|
748
736
|
onToggle: this.toggleButtonBlockType,
|
|
749
|
-
blockTypes: this.getFontListConfigForPanelType(
|
|
750
|
-
}), showLinkMenu && /*#__PURE__*/
|
|
737
|
+
blockTypes: this.getFontListConfigForPanelType("blockTypes")
|
|
738
|
+
}), showLinkMenu && /*#__PURE__*/React.createElement(BlockTypeLinkControls$1, {
|
|
751
739
|
editorState: editorState,
|
|
752
740
|
onToggle: this.toggleLink
|
|
753
|
-
}), tags && tags.length > 0 && /*#__PURE__*/
|
|
741
|
+
}), tags && tags.length > 0 && /*#__PURE__*/React.createElement(TagControls$1, {
|
|
754
742
|
editorState: editorState,
|
|
755
743
|
tags: tags,
|
|
756
744
|
onInsertTag: this.insertText
|
|
757
|
-
})), /*#__PURE__*/
|
|
745
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
758
746
|
className: "editor-wrapper"
|
|
759
|
-
}, /*#__PURE__*/
|
|
747
|
+
}, /*#__PURE__*/React.createElement(draftJs.Editor, {
|
|
760
748
|
ref: this.editor,
|
|
761
749
|
editorState: editorState,
|
|
762
750
|
handleKeyCommand: this.handleKeyCommand,
|
|
@@ -770,25 +758,25 @@ var RichTextEditor = /*#__PURE__*/function (_Component) {
|
|
|
770
758
|
}(React.Component);
|
|
771
759
|
RichTextEditor.decorator = decorator;
|
|
772
760
|
var styleShape = function styleShape(configList) {
|
|
773
|
-
return
|
|
774
|
-
type:
|
|
775
|
-
label:
|
|
776
|
-
style:
|
|
777
|
-
tooltip:
|
|
778
|
-
hotKey:
|
|
761
|
+
return PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOf([].concat(Object.values(configList)))), PropTypes.arrayOf(PropTypes.shape({
|
|
762
|
+
type: PropTypes.oneOf([].concat(Object.values(configList))),
|
|
763
|
+
label: PropTypes.string,
|
|
764
|
+
style: PropTypes.string,
|
|
765
|
+
tooltip: PropTypes.string,
|
|
766
|
+
hotKey: PropTypes.string
|
|
779
767
|
}))]);
|
|
780
768
|
};
|
|
781
769
|
RichTextEditor.propTypes = {
|
|
782
|
-
editorState:
|
|
783
|
-
onChange:
|
|
784
|
-
maxTabDepth:
|
|
785
|
-
showFontMenu:
|
|
786
|
-
showInlineStyleMenu:
|
|
787
|
-
showTextFormatMenu:
|
|
788
|
-
showLinkMenu:
|
|
789
|
-
label:
|
|
790
|
-
tags: /*#__PURE__*/
|
|
791
|
-
controlConfigSet: /*#__PURE__*/
|
|
770
|
+
editorState: PropTypes.object.isRequired,
|
|
771
|
+
onChange: PropTypes.func.isRequired,
|
|
772
|
+
maxTabDepth: PropTypes.number,
|
|
773
|
+
showFontMenu: PropTypes.bool,
|
|
774
|
+
showInlineStyleMenu: PropTypes.bool,
|
|
775
|
+
showTextFormatMenu: PropTypes.bool,
|
|
776
|
+
showLinkMenu: PropTypes.bool,
|
|
777
|
+
label: PropTypes.string,
|
|
778
|
+
tags: /*#__PURE__*/PropTypes.arrayOf(PropTypes.object),
|
|
779
|
+
controlConfigSet: /*#__PURE__*/PropTypes.shape({
|
|
792
780
|
fontList: /*#__PURE__*/styleShape(EditorConfigTypes.FONT_LIST),
|
|
793
781
|
blockTypes: /*#__PURE__*/styleShape(EditorConfigTypes.BLOCK_TYPES),
|
|
794
782
|
inlineStyles: /*#__PURE__*/styleShape(EditorConfigTypes.INLINE_STYLES)
|
|
@@ -800,7 +788,7 @@ RichTextEditor.defaultProps = {
|
|
|
800
788
|
showInlineStyleMenu: true,
|
|
801
789
|
showTextFormatMenu: true,
|
|
802
790
|
showLinkMenu: true,
|
|
803
|
-
label:
|
|
791
|
+
label: ""
|
|
804
792
|
};
|
|
805
793
|
|
|
806
794
|
var editorStateToMarkdown = function editorStateToMarkdown(editorState) {
|
|
@@ -819,7 +807,7 @@ var markdownToEditorState = function markdownToEditorState(markdown) {
|
|
|
819
807
|
var contentState = draftJs.convertFromRaw(rawState);
|
|
820
808
|
return draftJs.EditorState.createWithContent(contentState, decorator);
|
|
821
809
|
};
|
|
822
|
-
var converter = /*#__PURE__*/new
|
|
810
|
+
var converter = /*#__PURE__*/new showdown.Converter({
|
|
823
811
|
underline: true
|
|
824
812
|
});
|
|
825
813
|
var markdownToHtml = function markdownToHtml(markdown) {
|
|
@@ -843,7 +831,7 @@ var RichTextEditorForLanguage = function RichTextEditorForLanguage(_ref) {
|
|
|
843
831
|
var handleOnChange = function handleOnChange(changedState) {
|
|
844
832
|
var newValues = _extends({}, values);
|
|
845
833
|
var content = editorStateToMarkdown(changedState);
|
|
846
|
-
if (values[langKey] && content ===
|
|
834
|
+
if (values[langKey] && content === "\n") {
|
|
847
835
|
delete newValues[langKey];
|
|
848
836
|
} else {
|
|
849
837
|
newValues[langKey] = content;
|
|
@@ -851,16 +839,16 @@ var RichTextEditorForLanguage = function RichTextEditorForLanguage(_ref) {
|
|
|
851
839
|
setEditorState(changedState);
|
|
852
840
|
onChange(newValues);
|
|
853
841
|
};
|
|
854
|
-
var feedbackText = feedback
|
|
855
|
-
return /*#__PURE__*/
|
|
856
|
-
label: required ? label +
|
|
842
|
+
var feedbackText = feedback == null ? void 0 : feedback(langKey);
|
|
843
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(RichTextEditor, {
|
|
844
|
+
label: required ? label + "*" : label,
|
|
857
845
|
editorState: editorState,
|
|
858
846
|
onChange: function onChange(changedState) {
|
|
859
847
|
return handleOnChange(changedState);
|
|
860
848
|
},
|
|
861
849
|
controlConfigSet: MinifiedConfigTypes,
|
|
862
850
|
tags: tags
|
|
863
|
-
}), variant &&
|
|
851
|
+
}), variant && feedbackText && feedbackText.length > 0 && (/*#__PURE__*/React.createElement(form.FeedbackText, {
|
|
864
852
|
variant: variant(langKey)
|
|
865
853
|
}, feedbackText)));
|
|
866
854
|
};
|
|
@@ -869,32 +857,30 @@ var ExpandableMultiLanguageRichTextEditor = function ExpandableMultiLanguageRich
|
|
|
869
857
|
title = _ref2.title,
|
|
870
858
|
languages = _ref2.languages,
|
|
871
859
|
rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
872
|
-
return /*#__PURE__*/
|
|
860
|
+
return /*#__PURE__*/React.createElement(expand.ExpandablePanel, {
|
|
873
861
|
title: title,
|
|
874
862
|
defaultOpen: true,
|
|
875
863
|
contentStyle: {
|
|
876
|
-
padding:
|
|
877
|
-
marginTop:
|
|
878
|
-
marginBottom:
|
|
864
|
+
padding: "4px 4px 4px 4px",
|
|
865
|
+
marginTop: "16px",
|
|
866
|
+
marginBottom: "16px"
|
|
879
867
|
}
|
|
880
|
-
}, /*#__PURE__*/
|
|
868
|
+
}, /*#__PURE__*/React.createElement(common.Stack, {
|
|
881
869
|
space: "medium"
|
|
882
870
|
}, languages.map(function (lang) {
|
|
883
|
-
return /*#__PURE__*/
|
|
871
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
884
872
|
key: name + lang.value,
|
|
885
873
|
"data-testid": "multi-lang-rich-text-" + name + "-" + lang.value
|
|
886
|
-
}, /*#__PURE__*/
|
|
874
|
+
}, /*#__PURE__*/React.createElement(RichTextEditorForLanguage, _extends({
|
|
887
875
|
language: lang
|
|
888
876
|
}, rest)));
|
|
889
877
|
})));
|
|
890
878
|
};
|
|
891
879
|
|
|
892
|
-
/* eslint-disable react/display-name */
|
|
893
|
-
|
|
894
880
|
var entityToHtml = {
|
|
895
881
|
entityToHTML: function entityToHTML(entity, originalText) {
|
|
896
|
-
if (entity.type ===
|
|
897
|
-
return /*#__PURE__*/
|
|
882
|
+
if (entity.type === "LINK") {
|
|
883
|
+
return /*#__PURE__*/React.createElement(HtmlLink, {
|
|
898
884
|
url: entity.data.url
|
|
899
885
|
}, originalText);
|
|
900
886
|
}
|
|
@@ -903,16 +889,13 @@ var entityToHtml = {
|
|
|
903
889
|
};
|
|
904
890
|
var htmlToEntity = {
|
|
905
891
|
htmlToEntity: function htmlToEntity(nodeName, node, createEntity) {
|
|
906
|
-
if (nodeName ===
|
|
907
|
-
return createEntity(
|
|
892
|
+
if (nodeName === "a") {
|
|
893
|
+
return createEntity("LINK", "MUTABLE", {
|
|
908
894
|
url: node.href
|
|
909
895
|
});
|
|
910
896
|
}
|
|
911
897
|
}
|
|
912
898
|
};
|
|
913
|
-
|
|
914
|
-
/* eslint-disable react/display-name */
|
|
915
|
-
|
|
916
899
|
var htmlToEditorState = function htmlToEditorState(html) {
|
|
917
900
|
if (!html) {
|
|
918
901
|
return draftJs.EditorState.createEmpty(decorator);
|