@datarobot/design-system 28.3.4 → 28.5.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.
- package/cjs/chat/chat-message-body.js +9 -4
- package/cjs/chat/hocs.d.ts +1 -1
- package/cjs/chat/hocs.js +21 -22
- package/cjs/chat/index.d.ts +2 -0
- package/cjs/chat/index.js +14 -0
- package/cjs/text-editor/inline-text-editor.d.ts +3 -1
- package/cjs/text-editor/inline-text-editor.js +6 -2
- package/cjs/text-editor/text-editor-constants.d.ts +0 -2
- package/cjs/text-editor/text-editor-constants.js +0 -8
- package/cjs/text-editor/text-editor-content.d.ts +2 -1
- package/cjs/text-editor/text-editor-content.js +22 -2
- package/cjs/text-editor/text-editor-header.js +2 -9
- package/cjs/text-editor/text-editor-helpers.d.ts +1 -0
- package/cjs/text-editor/text-editor-helpers.js +22 -17
- package/cjs/text-editor/text-editor.d.ts +5 -1
- package/cjs/text-editor/text-editor.js +31 -6
- package/esm/chat/chat-message-body.js +9 -4
- package/esm/chat/hocs.d.ts +1 -1
- package/esm/chat/hocs.js +21 -22
- package/esm/chat/index.d.ts +2 -0
- package/esm/chat/index.js +2 -0
- package/esm/text-editor/inline-text-editor.d.ts +3 -1
- package/esm/text-editor/inline-text-editor.js +6 -2
- package/esm/text-editor/text-editor-constants.d.ts +0 -2
- package/esm/text-editor/text-editor-constants.js +0 -6
- package/esm/text-editor/text-editor-content.d.ts +2 -1
- package/esm/text-editor/text-editor-content.js +22 -2
- package/esm/text-editor/text-editor-header.js +3 -10
- package/esm/text-editor/text-editor-helpers.d.ts +1 -0
- package/esm/text-editor/text-editor-helpers.js +22 -18
- package/esm/text-editor/text-editor.d.ts +5 -1
- package/esm/text-editor/text-editor.js +33 -8
- package/js/bundle/bundle.js +175 -127
- package/js/bundle/bundle.min.js +1 -1
- package/js/bundle/index.d.ts +22 -5
- package/package.json +1 -1
- package/styles/index.css +16 -0
- package/styles/index.min.css +1 -1
package/js/bundle/bundle.js
CHANGED
|
@@ -44136,15 +44136,20 @@ function ChatMessageBodyBase(_ref) {
|
|
|
44136
44136
|
onBlur: onBlur,
|
|
44137
44137
|
"aria-label": readOnly ? undefined : textBoxAriaLabel,
|
|
44138
44138
|
onDOMBeforeInput: function onDOMBeforeInput(event) {
|
|
44139
|
-
var _event$data$length, _event$data;
|
|
44140
44139
|
// we have logic to prevent entering text longer than maxLength in hocs.ts
|
|
44141
44140
|
// but there we prevent it only from updating slate inner state, html input still
|
|
44142
44141
|
// adds entered text to the DOM input field causing buggy behavior: https://datarobot.atlassian.net/browse/TESTLIO-2963
|
|
44143
44142
|
// preventing default from the onDOMBeforeInput won't add new character to the DOM input field.
|
|
44144
|
-
// we still
|
|
44145
|
-
|
|
44146
|
-
|
|
44147
|
-
|
|
44143
|
+
// we still want to leave logic in hocs.ts because it covers copy+paste case, as for some reason
|
|
44144
|
+
// under certain circumstances onDOMBeforeInput stops being triggering for copy+paste so having there is safer
|
|
44145
|
+
|
|
44146
|
+
// we want to always allow deleting text
|
|
44147
|
+
if (!event.inputType.startsWith('delete')) {
|
|
44148
|
+
var _event$data$length, _event$data;
|
|
44149
|
+
var existingMentionsCount = (0,_utils__WEBPACK_IMPORTED_MODULE_11__.getMentionsCount)(editor.children);
|
|
44150
|
+
if (!!event.data && slate__WEBPACK_IMPORTED_MODULE_2__.Editor.string(editor, []).length + existingMentionsCount + ((_event$data$length = event === null || event === void 0 || (_event$data = event.data) === null || _event$data === void 0 ? void 0 : _event$data.length) !== null && _event$data$length !== void 0 ? _event$data$length : 0) > maxLength) {
|
|
44151
|
+
event.preventDefault();
|
|
44152
|
+
}
|
|
44148
44153
|
}
|
|
44149
44154
|
}
|
|
44150
44155
|
})), hasMentionsSupport && isFocused && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_dropdown__WEBPACK_IMPORTED_MODULE_5__.PopperDropdownWrapper, {
|
|
@@ -44562,32 +44567,32 @@ var MENTION_SEARCH_FIELDS = [MENTION_SEARCH_FIELD];
|
|
|
44562
44567
|
|
|
44563
44568
|
var withMaxLength = function withMaxLength(maxLength) {
|
|
44564
44569
|
return function Plugin(editor) {
|
|
44565
|
-
var
|
|
44566
|
-
|
|
44567
|
-
|
|
44568
|
-
//
|
|
44569
|
-
//
|
|
44570
|
-
//
|
|
44571
|
-
|
|
44572
|
-
|
|
44573
|
-
|
|
44574
|
-
|
|
44575
|
-
|
|
44576
|
-
|
|
44577
|
-
|
|
44578
|
-
|
|
44579
|
-
|
|
44580
|
-
|
|
44581
|
-
|
|
44582
|
-
|
|
44583
|
-
|
|
44584
|
-
|
|
44585
|
-
|
|
44586
|
-
|
|
44587
|
-
|
|
44588
|
-
|
|
44589
|
-
}
|
|
44590
|
-
}
|
|
44570
|
+
var insertData = editor.insertData;
|
|
44571
|
+
|
|
44572
|
+
// usual text insertion prevention is handled in onDOMBeforeInput event on the Editable component
|
|
44573
|
+
// this case prevents copy-paste of text that would exceed the maxLength
|
|
44574
|
+
// copy-paste could have been also handled in onDOMBeforeInput, but for
|
|
44575
|
+
// some reason sometimes Slate stops triggering onDOMBeforeInput for copy-paste ¯\_(ツ)_/¯
|
|
44576
|
+
if (maxLength) {
|
|
44577
|
+
editor.insertData = function (data) {
|
|
44578
|
+
var _data$getData;
|
|
44579
|
+
var existingMentionsCount = (0,_utils__WEBPACK_IMPORTED_MODULE_1__.getMentionsCount)(editor.children);
|
|
44580
|
+
// other methods for inserting text does not take into account new lines, so when copy-pasting
|
|
44581
|
+
// we should also remove them, otherwise there is a bug when entered text cannot be cut and pasted
|
|
44582
|
+
// because on paste text length is considered longer due to \n characters
|
|
44583
|
+
var text = (_data$getData = data.getData('text/plain')) === null || _data$getData === void 0 ? void 0 : _data$getData.replace(/\n/g, '');
|
|
44584
|
+
var html = data.getData('text/html');
|
|
44585
|
+
var parsedHtml = new DOMParser().parseFromString(html, 'text/html');
|
|
44586
|
+
var mentionNodes = parsedHtml.querySelectorAll('.mention');
|
|
44587
|
+
var mentionsText = Array.from(mentionNodes).map(function (node) {
|
|
44588
|
+
return node.innerText;
|
|
44589
|
+
}).join('');
|
|
44590
|
+
var itemsLengthToBeInserted = mentionNodes.length ? text.length - mentionsText.length : text.length;
|
|
44591
|
+
if (slate__WEBPACK_IMPORTED_MODULE_0__.Editor.string(editor, []).length + itemsLengthToBeInserted + existingMentionsCount <= maxLength) {
|
|
44592
|
+
insertData(data);
|
|
44593
|
+
}
|
|
44594
|
+
};
|
|
44595
|
+
}
|
|
44591
44596
|
return editor;
|
|
44592
44597
|
};
|
|
44593
44598
|
};
|
|
@@ -44617,15 +44622,21 @@ var withMentions = function withMentions(editor) {
|
|
|
44617
44622
|
|
|
44618
44623
|
"use strict";
|
|
44619
44624
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
44625
|
+
/* harmony export */ CharactersCounter: () => (/* reexport safe */ _characters_counter__WEBPACK_IMPORTED_MODULE_1__.CharactersCounter),
|
|
44620
44626
|
/* harmony export */ Chat: () => (/* reexport safe */ _chat__WEBPACK_IMPORTED_MODULE_0__.Chat),
|
|
44621
|
-
/* harmony export */ DEFAULT_VALUE: () => (/* reexport safe */
|
|
44622
|
-
/* harmony export */ NEW_ITEM_KEY: () => (/* reexport safe */
|
|
44623
|
-
/* harmony export */ isMentionElement: () => (/* reexport safe */
|
|
44624
|
-
/* harmony export */ resetNodes: () => (/* reexport safe */
|
|
44627
|
+
/* harmony export */ DEFAULT_VALUE: () => (/* reexport safe */ _constants__WEBPACK_IMPORTED_MODULE_4__.DEFAULT_VALUE),
|
|
44628
|
+
/* harmony export */ NEW_ITEM_KEY: () => (/* reexport safe */ _constants__WEBPACK_IMPORTED_MODULE_4__.NEW_ITEM_KEY),
|
|
44629
|
+
/* harmony export */ isMentionElement: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_2__.isMentionElement),
|
|
44630
|
+
/* harmony export */ resetNodes: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_2__.resetNodes),
|
|
44631
|
+
/* harmony export */ withMaxLength: () => (/* reexport safe */ _hocs__WEBPACK_IMPORTED_MODULE_3__.withMaxLength)
|
|
44625
44632
|
/* harmony export */ });
|
|
44626
44633
|
/* harmony import */ var _chat__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./chat */ "./src/components/chat/chat.tsx");
|
|
44627
|
-
/* harmony import */ var
|
|
44628
|
-
/* harmony import */ var
|
|
44634
|
+
/* harmony import */ var _characters_counter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./characters-counter */ "./src/components/chat/characters-counter.tsx");
|
|
44635
|
+
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils */ "./src/components/chat/utils.ts");
|
|
44636
|
+
/* harmony import */ var _hocs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hocs */ "./src/components/chat/hocs.ts");
|
|
44637
|
+
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./constants */ "./src/components/chat/constants.ts");
|
|
44638
|
+
|
|
44639
|
+
|
|
44629
44640
|
|
|
44630
44641
|
|
|
44631
44642
|
|
|
@@ -63770,6 +63781,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
63770
63781
|
/* harmony export */ CardHeader: () => (/* reexport safe */ _custom_card__WEBPACK_IMPORTED_MODULE_22__.CardHeader),
|
|
63771
63782
|
/* harmony export */ CardLabel: () => (/* reexport safe */ _custom_card__WEBPACK_IMPORTED_MODULE_22__.CardLabel),
|
|
63772
63783
|
/* harmony export */ CardTitle: () => (/* reexport safe */ _custom_card__WEBPACK_IMPORTED_MODULE_22__.CardTitle),
|
|
63784
|
+
/* harmony export */ CharactersCounter: () => (/* reexport safe */ _chat__WEBPACK_IMPORTED_MODULE_13__.CharactersCounter),
|
|
63773
63785
|
/* harmony export */ ChartLegend: () => (/* reexport safe */ _chart_legend__WEBPACK_IMPORTED_MODULE_12__.ChartLegend),
|
|
63774
63786
|
/* harmony export */ ChartLegendItem: () => (/* reexport safe */ _chart_legend__WEBPACK_IMPORTED_MODULE_12__.ChartLegendItem),
|
|
63775
63787
|
/* harmony export */ ChartLegendItemGlyph: () => (/* reexport safe */ _chart_legend__WEBPACK_IMPORTED_MODULE_12__.ChartLegendItemGlyph),
|
|
@@ -64095,6 +64107,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
64095
64107
|
/* harmony export */ useTreeNavigation: () => (/* reexport safe */ _hooks__WEBPACK_IMPORTED_MODULE_45__.useTreeNavigation),
|
|
64096
64108
|
/* harmony export */ useTreeNodeNavigation: () => (/* reexport safe */ _hooks__WEBPACK_IMPORTED_MODULE_45__.useTreeNodeNavigation),
|
|
64097
64109
|
/* harmony export */ withExpandableContent: () => (/* reexport safe */ _table__WEBPACK_IMPORTED_MODULE_86__.withExpandableContent),
|
|
64110
|
+
/* harmony export */ withMaxLength: () => (/* reexport safe */ _chat__WEBPACK_IMPORTED_MODULE_13__.withMaxLength),
|
|
64098
64111
|
/* harmony export */ withTableCellCheckboxes: () => (/* reexport safe */ _table__WEBPACK_IMPORTED_MODULE_86__.withTableCellCheckboxes),
|
|
64099
64112
|
/* harmony export */ withTableDataSorting: () => (/* reexport safe */ _table__WEBPACK_IMPORTED_MODULE_86__.withTableDataSorting),
|
|
64100
64113
|
/* harmony export */ withTableRowSelection: () => (/* reexport safe */ _table__WEBPACK_IMPORTED_MODULE_86__.withTableRowSelection),
|
|
@@ -79649,7 +79662,9 @@ function InlineTextEditor(_ref) {
|
|
|
79649
79662
|
onSave = _ref.onSave,
|
|
79650
79663
|
_ref$autoFocus = _ref.autoFocus,
|
|
79651
79664
|
autoFocus = _ref$autoFocus === void 0 ? false : _ref$autoFocus,
|
|
79652
|
-
deleteEditorContentButtonAriaLabel = _ref.deleteEditorContentButtonAriaLabel
|
|
79665
|
+
deleteEditorContentButtonAriaLabel = _ref.deleteEditorContentButtonAriaLabel,
|
|
79666
|
+
maxLength = _ref.maxLength,
|
|
79667
|
+
getCharactersCounterString = _ref.getCharactersCounterString;
|
|
79653
79668
|
var _useTranslation = (0,_hooks_use_translation__WEBPACK_IMPORTED_MODULE_6__.useTranslation)(),
|
|
79654
79669
|
t = _useTranslation.t;
|
|
79655
79670
|
var initialTitle = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () {
|
|
@@ -79727,7 +79742,9 @@ function InlineTextEditor(_ref) {
|
|
|
79727
79742
|
height: height,
|
|
79728
79743
|
testId: "inline-text-editor-edit",
|
|
79729
79744
|
contentAriaLabel: ariaLabel || titleValue,
|
|
79730
|
-
deleteEditorContentButtonAriaLabel: deleteEditorContentButtonAriaLabel !== null && deleteEditorContentButtonAriaLabel !== void 0 ? deleteEditorContentButtonAriaLabel : t('Delete Editor Content')
|
|
79745
|
+
deleteEditorContentButtonAriaLabel: deleteEditorContentButtonAriaLabel !== null && deleteEditorContentButtonAriaLabel !== void 0 ? deleteEditorContentButtonAriaLabel : t('Delete Editor Content'),
|
|
79746
|
+
maxLength: maxLength,
|
|
79747
|
+
getCharactersCounterString: getCharactersCounterString
|
|
79731
79748
|
}) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", _extends({
|
|
79732
79749
|
"test-id": "inline-text-editor-view-container",
|
|
79733
79750
|
className: classnames__WEBPACK_IMPORTED_MODULE_1___default()('inline-text-editor-view-container', isFlex && 'is-flex')
|
|
@@ -79757,9 +79774,7 @@ function InlineTextEditor(_ref) {
|
|
|
79757
79774
|
/* harmony export */ TEXT_EDITOR_DEFAULT_TOOLS: () => (/* binding */ TEXT_EDITOR_DEFAULT_TOOLS),
|
|
79758
79775
|
/* harmony export */ TEXT_EDITOR_DEFAULT_VALUE: () => (/* binding */ TEXT_EDITOR_DEFAULT_VALUE),
|
|
79759
79776
|
/* harmony export */ TEXT_EDITOR_TOOLS: () => (/* binding */ TEXT_EDITOR_TOOLS),
|
|
79760
|
-
/* harmony export */ TOOLBAR_POSITION: () => (/* binding */ TOOLBAR_POSITION)
|
|
79761
|
-
/* harmony export */ instanceOfContent: () => (/* binding */ instanceOfContent),
|
|
79762
|
-
/* harmony export */ instanceOfContentChild: () => (/* binding */ instanceOfContentChild)
|
|
79777
|
+
/* harmony export */ TOOLBAR_POSITION: () => (/* binding */ TOOLBAR_POSITION)
|
|
79763
79778
|
/* harmony export */ });
|
|
79764
79779
|
var MARK_TYPES = {
|
|
79765
79780
|
BOLD: 'bold',
|
|
@@ -79794,12 +79809,6 @@ var TEXT_EDITOR_TOOLS = {
|
|
|
79794
79809
|
CODE: 'code',
|
|
79795
79810
|
CLEAR_FORMATTING: 'clear-formatting'
|
|
79796
79811
|
};
|
|
79797
|
-
function instanceOfContentChild(obj) {
|
|
79798
|
-
return 'text' in obj;
|
|
79799
|
-
}
|
|
79800
|
-
function instanceOfContent(obj) {
|
|
79801
|
-
return !('text' in obj);
|
|
79802
|
-
}
|
|
79803
79812
|
var TEXT_EDITOR_DEFAULT_VALUE = [{
|
|
79804
79813
|
type: BLOCK_TYPES.REGULAR_TEXT,
|
|
79805
79814
|
children: [{
|
|
@@ -79842,12 +79851,14 @@ var HEADER_TITLE_MAX_LENGTH = 50;
|
|
|
79842
79851
|
/* unused harmony export Placeholder */
|
|
79843
79852
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
79844
79853
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
79845
|
-
/* harmony import */ var
|
|
79846
|
-
/* harmony import */ var
|
|
79847
|
-
/* harmony import */ var
|
|
79848
|
-
/* harmony import */ var
|
|
79849
|
-
/* harmony import */ var
|
|
79850
|
-
/* harmony import */ var
|
|
79854
|
+
/* harmony import */ var slate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! slate */ "slate");
|
|
79855
|
+
/* harmony import */ var slate__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(slate__WEBPACK_IMPORTED_MODULE_1__);
|
|
79856
|
+
/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! classnames */ "./node_modules/classnames/index.js");
|
|
79857
|
+
/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_2__);
|
|
79858
|
+
/* harmony import */ var _text_editor_context__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./text-editor-context */ "./src/components/text-editor/text-editor-context.ts");
|
|
79859
|
+
/* harmony import */ var _text_editor_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./text-editor-constants */ "./src/components/text-editor/text-editor-constants.ts");
|
|
79860
|
+
/* harmony import */ var _text_editor_content_less__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./text-editor-content.less */ "./src/components/text-editor/text-editor-content.less");
|
|
79861
|
+
/* harmony import */ var _text_editor_content_less__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_text_editor_content_less__WEBPACK_IMPORTED_MODULE_5__);
|
|
79851
79862
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
79852
79863
|
var _excluded = ["opacity"];
|
|
79853
79864
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -79863,39 +79874,40 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
79863
79874
|
|
|
79864
79875
|
|
|
79865
79876
|
|
|
79877
|
+
|
|
79866
79878
|
var Element = function Element(_ref) {
|
|
79867
79879
|
var attributes = _ref.attributes,
|
|
79868
79880
|
children = _ref.children,
|
|
79869
79881
|
element = _ref.element;
|
|
79870
79882
|
switch (element.type) {
|
|
79871
|
-
case
|
|
79883
|
+
case _text_editor_constants__WEBPACK_IMPORTED_MODULE_4__.BLOCK_TYPES.HEADLINE_LARGE:
|
|
79872
79884
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", _extends({}, attributes, {
|
|
79873
79885
|
className: "large-text-header",
|
|
79874
79886
|
"test-id": "large-text"
|
|
79875
79887
|
}), children);
|
|
79876
|
-
case
|
|
79888
|
+
case _text_editor_constants__WEBPACK_IMPORTED_MODULE_4__.BLOCK_TYPES.HEADLINE_MEDIUM:
|
|
79877
79889
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", _extends({}, attributes, {
|
|
79878
79890
|
className: "medium-text-header",
|
|
79879
79891
|
"test-id": "medium-text"
|
|
79880
79892
|
}), children);
|
|
79881
|
-
case
|
|
79893
|
+
case _text_editor_constants__WEBPACK_IMPORTED_MODULE_4__.BLOCK_TYPES.HEADLINE_SMALL:
|
|
79882
79894
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", _extends({}, attributes, {
|
|
79883
79895
|
className: "small-text-header",
|
|
79884
79896
|
"test-id": "small-text"
|
|
79885
79897
|
}), children);
|
|
79886
|
-
case
|
|
79898
|
+
case _text_editor_constants__WEBPACK_IMPORTED_MODULE_4__.BLOCK_TYPES.BULLETED_LIST:
|
|
79887
79899
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("ul", _extends({}, attributes, {
|
|
79888
79900
|
className: "list",
|
|
79889
79901
|
"test-id": "bulleted-list"
|
|
79890
79902
|
}), children);
|
|
79891
|
-
case
|
|
79903
|
+
case _text_editor_constants__WEBPACK_IMPORTED_MODULE_4__.BLOCK_TYPES.NUMBERED_LIST:
|
|
79892
79904
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("ol", _extends({}, attributes, {
|
|
79893
79905
|
className: "list",
|
|
79894
79906
|
"test-id": "numbered-list"
|
|
79895
79907
|
}), children);
|
|
79896
|
-
case
|
|
79908
|
+
case _text_editor_constants__WEBPACK_IMPORTED_MODULE_4__.BLOCK_TYPES.LIST_ITEM:
|
|
79897
79909
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("li", attributes, children);
|
|
79898
|
-
case
|
|
79910
|
+
case _text_editor_constants__WEBPACK_IMPORTED_MODULE_4__.BLOCK_TYPES.LINK:
|
|
79899
79911
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", _extends({}, attributes, {
|
|
79900
79912
|
target: "_blank",
|
|
79901
79913
|
rel: "noreferrer",
|
|
@@ -79903,7 +79915,7 @@ var Element = function Element(_ref) {
|
|
|
79903
79915
|
href: element.url,
|
|
79904
79916
|
"test-id": "anchor-link"
|
|
79905
79917
|
}), children);
|
|
79906
|
-
case
|
|
79918
|
+
case _text_editor_constants__WEBPACK_IMPORTED_MODULE_4__.BLOCK_TYPES.CODE:
|
|
79907
79919
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", {
|
|
79908
79920
|
className: "code-block",
|
|
79909
79921
|
"test-id": "code-block"
|
|
@@ -79920,25 +79932,25 @@ var Leaf = function Leaf(_ref2) {
|
|
|
79920
79932
|
children = _ref2.children,
|
|
79921
79933
|
leaf = _ref2.leaf;
|
|
79922
79934
|
var node = children;
|
|
79923
|
-
if (leaf[
|
|
79935
|
+
if (leaf[_text_editor_constants__WEBPACK_IMPORTED_MODULE_4__.MARK_TYPES.BOLD]) {
|
|
79924
79936
|
node = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
|
|
79925
79937
|
className: "bold",
|
|
79926
79938
|
"test-id": "bold-text"
|
|
79927
79939
|
}, node);
|
|
79928
79940
|
}
|
|
79929
|
-
if (leaf[
|
|
79941
|
+
if (leaf[_text_editor_constants__WEBPACK_IMPORTED_MODULE_4__.MARK_TYPES.ITALIC]) {
|
|
79930
79942
|
node = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
|
|
79931
79943
|
className: "italic",
|
|
79932
79944
|
"test-id": "italic-text"
|
|
79933
79945
|
}, node);
|
|
79934
79946
|
}
|
|
79935
|
-
if (leaf[
|
|
79947
|
+
if (leaf[_text_editor_constants__WEBPACK_IMPORTED_MODULE_4__.MARK_TYPES.UNDERLINE]) {
|
|
79936
79948
|
node = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
|
|
79937
79949
|
className: "underlined",
|
|
79938
79950
|
"test-id": "underlined-text"
|
|
79939
79951
|
}, node);
|
|
79940
79952
|
}
|
|
79941
|
-
if (leaf[
|
|
79953
|
+
if (leaf[_text_editor_constants__WEBPACK_IMPORTED_MODULE_4__.MARK_TYPES.SUPERSCRIPT]) {
|
|
79942
79954
|
node = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
|
|
79943
79955
|
className: "superscript",
|
|
79944
79956
|
"test-id": "superscript-text"
|
|
@@ -79981,10 +79993,13 @@ function TextEditorContent(_ref4) {
|
|
|
79981
79993
|
_ref4$onBlur = _ref4.onBlur,
|
|
79982
79994
|
onBlur = _ref4$onBlur === void 0 ? function () {} : _ref4$onBlur,
|
|
79983
79995
|
_ref4$onFocus = _ref4.onFocus,
|
|
79984
|
-
onFocus = _ref4$onFocus === void 0 ? function () {} : _ref4$onFocus
|
|
79985
|
-
|
|
79996
|
+
onFocus = _ref4$onFocus === void 0 ? function () {} : _ref4$onFocus,
|
|
79997
|
+
maxLength = _ref4.maxLength;
|
|
79998
|
+
var _useContext = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_text_editor_context__WEBPACK_IMPORTED_MODULE_3__["default"]),
|
|
79986
79999
|
slateReact = _useContext.slateReact;
|
|
79987
|
-
var Editable = slateReact.Editable
|
|
80000
|
+
var Editable = slateReact.Editable,
|
|
80001
|
+
useSlate = slateReact.useSlate;
|
|
80002
|
+
var editor = useSlate();
|
|
79988
80003
|
/* eslint-disable-next-line testing-library/render-result-naming-convention */
|
|
79989
80004
|
var ElementNode = elementRender;
|
|
79990
80005
|
/* eslint-disable-next-line testing-library/render-result-naming-convention */
|
|
@@ -80007,7 +80022,7 @@ function TextEditorContent(_ref4) {
|
|
|
80007
80022
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Placeholder, props);
|
|
80008
80023
|
}, []);
|
|
80009
80024
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
80010
|
-
className:
|
|
80025
|
+
className: classnames__WEBPACK_IMPORTED_MODULE_2___default()('text-editor-content', {
|
|
80011
80026
|
'is-scrollable': isScrollable
|
|
80012
80027
|
}),
|
|
80013
80028
|
"test-id": testId
|
|
@@ -80020,7 +80035,23 @@ function TextEditorContent(_ref4) {
|
|
|
80020
80035
|
renderElement: renderElement,
|
|
80021
80036
|
renderLeaf: renderLeaf,
|
|
80022
80037
|
onBlur: onBlur,
|
|
80023
|
-
onFocus: onFocus
|
|
80038
|
+
onFocus: onFocus,
|
|
80039
|
+
onDOMBeforeInput: function onDOMBeforeInput(event) {
|
|
80040
|
+
// NOTE: copy-paste events handled in withMaxLength() plugin because Slate under some
|
|
80041
|
+
// circumstances stops triggering onDOMBeforeInput event for copy-paste ¯\_(ツ)_/¯
|
|
80042
|
+
|
|
80043
|
+
// no need to do any calculations if maxLength is not set or if it's a delete event
|
|
80044
|
+
if (maxLength && !event.inputType.startsWith('delete')) {
|
|
80045
|
+
var currentTextLength = slate__WEBPACK_IMPORTED_MODULE_1__.Editor.string(editor, []).length;
|
|
80046
|
+
var newText = '';
|
|
80047
|
+
if (!!event.data) {
|
|
80048
|
+
newText = event.data;
|
|
80049
|
+
}
|
|
80050
|
+
if (currentTextLength + newText.length > maxLength) {
|
|
80051
|
+
event.preventDefault();
|
|
80052
|
+
}
|
|
80053
|
+
}
|
|
80054
|
+
}
|
|
80024
80055
|
}, ariaAttrs)));
|
|
80025
80056
|
}
|
|
80026
80057
|
|
|
@@ -80076,12 +80107,6 @@ var TextEditorContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default(
|
|
|
80076
80107
|
/* harmony import */ var _text_editor_service__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./text-editor-service */ "./src/components/text-editor/text-editor-service.ts");
|
|
80077
80108
|
/* harmony import */ var _text_editor_header_less__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./text-editor-header.less */ "./src/components/text-editor/text-editor-header.less");
|
|
80078
80109
|
/* harmony import */ var _text_editor_header_less__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_text_editor_header_less__WEBPACK_IMPORTED_MODULE_8__);
|
|
80079
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
80080
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
80081
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
80082
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
80083
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
80084
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
80085
80110
|
|
|
80086
80111
|
|
|
80087
80112
|
|
|
@@ -80110,10 +80135,6 @@ function TextEditorHeader(_ref) {
|
|
|
80110
80135
|
inputAriaLabel = _ref.inputAriaLabel;
|
|
80111
80136
|
var _useTranslation = (0,_hooks_use_translation__WEBPACK_IMPORTED_MODULE_2__.useTranslation)(),
|
|
80112
80137
|
t = _useTranslation.t;
|
|
80113
|
-
var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),
|
|
80114
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
80115
|
-
isDelete = _useState2[0],
|
|
80116
|
-
setIsDelete = _useState2[1];
|
|
80117
80138
|
var _useContext = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_text_editor_context__WEBPACK_IMPORTED_MODULE_6__["default"]),
|
|
80118
80139
|
slate = _useContext.slate,
|
|
80119
80140
|
slateReact = _useContext.slateReact;
|
|
@@ -80122,13 +80143,6 @@ function TextEditorHeader(_ref) {
|
|
|
80122
80143
|
var editor = slateReact.useSlate();
|
|
80123
80144
|
var hasReadOnlyTitle = title && !isEditable;
|
|
80124
80145
|
var hasEditableTitle = isEditable && onChangeTitle;
|
|
80125
|
-
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
80126
|
-
if (isDelete) {
|
|
80127
|
-
onChangeTitle('');
|
|
80128
|
-
onDelete();
|
|
80129
|
-
setIsDelete(false);
|
|
80130
|
-
}
|
|
80131
|
-
}, [isDelete]);
|
|
80132
80146
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("header", {
|
|
80133
80147
|
className: "text-editor-header",
|
|
80134
80148
|
"test-id": "text-editor-header"
|
|
@@ -80151,7 +80165,8 @@ function TextEditorHeader(_ref) {
|
|
|
80151
80165
|
onClick: function onClick() {
|
|
80152
80166
|
textEditorService.deleteContent(editor);
|
|
80153
80167
|
ReactEditor.focus(editor);
|
|
80154
|
-
|
|
80168
|
+
onChangeTitle('');
|
|
80169
|
+
onDelete();
|
|
80155
80170
|
},
|
|
80156
80171
|
accentType: _button__WEBPACK_IMPORTED_MODULE_3__.ACCENT_TYPES.ROUND_ICON,
|
|
80157
80172
|
tooltipText: t('Delete'),
|
|
@@ -80174,6 +80189,7 @@ function TextEditorHeader(_ref) {
|
|
|
80174
80189
|
"use strict";
|
|
80175
80190
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
80176
80191
|
/* harmony export */ convertTextToTextEditorValue: () => (/* binding */ convertTextToTextEditorValue),
|
|
80192
|
+
/* harmony export */ getTextEditorValueLength: () => (/* binding */ getTextEditorValueLength),
|
|
80177
80193
|
/* harmony export */ hasGreaterTextEditorLinesThan: () => (/* binding */ hasGreaterTextEditorLinesThan),
|
|
80178
80194
|
/* harmony export */ isEmptyTextEditorValue: () => (/* binding */ isEmptyTextEditorValue),
|
|
80179
80195
|
/* harmony export */ isLongerTextEditorValueThan: () => (/* binding */ isLongerTextEditorValueThan)
|
|
@@ -80208,35 +80224,18 @@ function isLongerTextEditorValueThan(value) {
|
|
|
80208
80224
|
try {
|
|
80209
80225
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
80210
80226
|
var record = _step.value;
|
|
80211
|
-
if
|
|
80212
|
-
length += record.text.length;
|
|
80213
|
-
}
|
|
80214
|
-
if ((0,_text_editor_constants__WEBPACK_IMPORTED_MODULE_1__.instanceOfContent)(record) && !!record.children) {
|
|
80215
|
-
var _iterator2 = _createForOfIteratorHelper(record.children),
|
|
80216
|
-
_step2;
|
|
80217
|
-
try {
|
|
80218
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
80219
|
-
var childRecord = _step2.value;
|
|
80220
|
-
if (!!childRecord.text) {
|
|
80221
|
-
length += childRecord.text.length;
|
|
80222
|
-
}
|
|
80223
|
-
|
|
80224
|
-
// We already know the result
|
|
80225
|
-
if (length > maxLength) {
|
|
80226
|
-
break;
|
|
80227
|
-
}
|
|
80228
|
-
}
|
|
80229
|
-
} catch (err) {
|
|
80230
|
-
_iterator2.e(err);
|
|
80231
|
-
} finally {
|
|
80232
|
-
_iterator2.f();
|
|
80233
|
-
}
|
|
80234
|
-
}
|
|
80235
|
-
|
|
80236
|
-
// We already know the result
|
|
80227
|
+
// if we reached maxLength - no need to continue
|
|
80237
80228
|
if (length > maxLength) {
|
|
80238
80229
|
break;
|
|
80239
80230
|
}
|
|
80231
|
+
// if this is leaf node that has text - sum it up
|
|
80232
|
+
if (record.hasOwnProperty('text') && !!record.text) {
|
|
80233
|
+
var _text$length, _text;
|
|
80234
|
+
length += (_text$length = record === null || record === void 0 || (_text = record.text) === null || _text === void 0 ? void 0 : _text.length) !== null && _text$length !== void 0 ? _text$length : 0;
|
|
80235
|
+
} else if (record.hasOwnProperty('children') && !!record.children) {
|
|
80236
|
+
// if this is a node that has children - calculate length of children
|
|
80237
|
+
length += getTextEditorValueLength(record.children);
|
|
80238
|
+
}
|
|
80240
80239
|
}
|
|
80241
80240
|
} catch (err) {
|
|
80242
80241
|
_iterator.e(err);
|
|
@@ -80245,6 +80244,29 @@ function isLongerTextEditorValueThan(value) {
|
|
|
80245
80244
|
}
|
|
80246
80245
|
return length > maxLength;
|
|
80247
80246
|
}
|
|
80247
|
+
function getTextEditorValueLength(value) {
|
|
80248
|
+
var length = 0;
|
|
80249
|
+
var _iterator2 = _createForOfIteratorHelper(value),
|
|
80250
|
+
_step2;
|
|
80251
|
+
try {
|
|
80252
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
80253
|
+
var record = _step2.value;
|
|
80254
|
+
// if this is leaf node that has text - sum it up
|
|
80255
|
+
if (record.hasOwnProperty('text') && !!record.text) {
|
|
80256
|
+
var _text$length2, _text2;
|
|
80257
|
+
length += (_text$length2 = record === null || record === void 0 || (_text2 = record.text) === null || _text2 === void 0 ? void 0 : _text2.length) !== null && _text$length2 !== void 0 ? _text$length2 : 0;
|
|
80258
|
+
} else if (record.hasOwnProperty('children') && !!record.children) {
|
|
80259
|
+
// if this is a node that has children - iterate through them via recursion
|
|
80260
|
+
length += getTextEditorValueLength(record.children);
|
|
80261
|
+
}
|
|
80262
|
+
}
|
|
80263
|
+
} catch (err) {
|
|
80264
|
+
_iterator2.e(err);
|
|
80265
|
+
} finally {
|
|
80266
|
+
_iterator2.f();
|
|
80267
|
+
}
|
|
80268
|
+
return length;
|
|
80269
|
+
}
|
|
80248
80270
|
|
|
80249
80271
|
/**
|
|
80250
80272
|
* @param {Array} value - the type of value is defined with TextEditorValue
|
|
@@ -81450,7 +81472,7 @@ function TextEditorToolbar(_ref) {
|
|
|
81450
81472
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
81451
81473
|
/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! classnames */ "./node_modules/classnames/index.js");
|
|
81452
81474
|
/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_1__);
|
|
81453
|
-
/* harmony import */ var
|
|
81475
|
+
/* harmony import */ var lodash_es_isEqual__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! lodash-es/isEqual */ "../../node_modules/lodash-es/isEqual.js");
|
|
81454
81476
|
/* harmony import */ var slate_history__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! slate-history */ "slate-history");
|
|
81455
81477
|
/* harmony import */ var slate_history__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(slate_history__WEBPACK_IMPORTED_MODULE_2__);
|
|
81456
81478
|
/* harmony import */ var _form_field__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../form-field */ "./src/components/form-field/index.ts");
|
|
@@ -81463,8 +81485,10 @@ function TextEditorToolbar(_ref) {
|
|
|
81463
81485
|
/* harmony import */ var _text_editor_loader__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./text-editor-loader */ "./src/components/text-editor/text-editor-loader.tsx");
|
|
81464
81486
|
/* harmony import */ var _text_editor_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./text-editor-constants */ "./src/components/text-editor/text-editor-constants.ts");
|
|
81465
81487
|
/* harmony import */ var _text_editor_hooks__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./text-editor-hooks */ "./src/components/text-editor/text-editor-hooks.ts");
|
|
81466
|
-
/* harmony import */ var
|
|
81467
|
-
/* harmony import */ var
|
|
81488
|
+
/* harmony import */ var _text_editor_helpers__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./text-editor-helpers */ "./src/components/text-editor/text-editor-helpers.ts");
|
|
81489
|
+
/* harmony import */ var _hooks_use_translation__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../hooks/use-translation */ "./src/components/hooks/use-translation/index.ts");
|
|
81490
|
+
/* harmony import */ var _text_editor_less__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./text-editor.less */ "./src/components/text-editor/text-editor.less");
|
|
81491
|
+
/* harmony import */ var _text_editor_less__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(_text_editor_less__WEBPACK_IMPORTED_MODULE_15__);
|
|
81468
81492
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
81469
81493
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
81470
81494
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -81492,6 +81516,8 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
81492
81516
|
|
|
81493
81517
|
|
|
81494
81518
|
|
|
81519
|
+
|
|
81520
|
+
|
|
81495
81521
|
function TextEditorComponent(_ref) {
|
|
81496
81522
|
var name = _ref.name,
|
|
81497
81523
|
type = _ref.type,
|
|
@@ -81532,7 +81558,11 @@ function TextEditorComponent(_ref) {
|
|
|
81532
81558
|
_onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
|
|
81533
81559
|
deleteEditorContentButtonAriaLabel = _ref.deleteEditorContentButtonAriaLabel,
|
|
81534
81560
|
_ref$id = _ref.id,
|
|
81535
|
-
id = _ref$id === void 0 ? '' : _ref$id
|
|
81561
|
+
id = _ref$id === void 0 ? '' : _ref$id,
|
|
81562
|
+
maxLength = _ref.maxLength,
|
|
81563
|
+
getCharactersCounterString = _ref.getCharactersCounterString;
|
|
81564
|
+
var _useTranslation = (0,_hooks_use_translation__WEBPACK_IMPORTED_MODULE_14__.useTranslation)(),
|
|
81565
|
+
t = _useTranslation.t;
|
|
81536
81566
|
var _useContext = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_text_editor_context__WEBPACK_IMPORTED_MODULE_6__["default"]),
|
|
81537
81567
|
slate = _useContext.slate,
|
|
81538
81568
|
slateReact = _useContext.slateReact;
|
|
@@ -81542,13 +81572,21 @@ function TextEditorComponent(_ref) {
|
|
|
81542
81572
|
createEditor = slate.createEditor;
|
|
81543
81573
|
var withReact = slateReact.withReact,
|
|
81544
81574
|
Slate = slateReact.Slate;
|
|
81575
|
+
var getCharactersCounterStringText = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (count) {
|
|
81576
|
+
if (getCharactersCounterString) {
|
|
81577
|
+
return getCharactersCounterString(count);
|
|
81578
|
+
}
|
|
81579
|
+
return t('{{count}} characters remaining', {
|
|
81580
|
+
count: count
|
|
81581
|
+
});
|
|
81582
|
+
}, [getCharactersCounterString]);
|
|
81545
81583
|
var editor = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () {
|
|
81546
|
-
return (0,_hooks_with_links__WEBPACK_IMPORTED_MODULE_9__["default"])((0,slate_history__WEBPACK_IMPORTED_MODULE_2__.withHistory)(withReact(createEditor())));
|
|
81547
|
-
}, []);
|
|
81584
|
+
return (0,_chat__WEBPACK_IMPORTED_MODULE_4__.withMaxLength)(maxLength)((0,_hooks_with_links__WEBPACK_IMPORTED_MODULE_9__["default"])((0,slate_history__WEBPACK_IMPORTED_MODULE_2__.withHistory)(withReact(createEditor()))));
|
|
81585
|
+
}, [maxLength]);
|
|
81548
81586
|
var selection = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
|
|
81549
81587
|
var slateValue = value || initialValue || _text_editor_constants__WEBPACK_IMPORTED_MODULE_11__.TEXT_EDITOR_DEFAULT_VALUE;
|
|
81550
81588
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
81551
|
-
if (!(0,
|
|
81589
|
+
if (!(0,lodash_es_isEqual__WEBPACK_IMPORTED_MODULE_16__["default"])(editor.children, slateValue)) {
|
|
81552
81590
|
// Update the cached value inside the editor
|
|
81553
81591
|
(0,_chat__WEBPACK_IMPORTED_MODULE_4__.resetNodes)(editor, slateValue);
|
|
81554
81592
|
}
|
|
@@ -81612,7 +81650,8 @@ function TextEditorComponent(_ref) {
|
|
|
81612
81650
|
hasDeleteButton: header.hasDeleteButton,
|
|
81613
81651
|
onDelete: header.onDelete,
|
|
81614
81652
|
deleteEditorContentButtonAriaLabel: deleteEditorContentButtonAriaLabel,
|
|
81615
|
-
inputAriaLabel: header.inputAriaLabel
|
|
81653
|
+
inputAriaLabel: header.inputAriaLabel,
|
|
81654
|
+
maxLength: header.maxLength
|
|
81616
81655
|
}), toolbarPosition === _text_editor_constants__WEBPACK_IMPORTED_MODULE_11__.TOOLBAR_POSITION.TOP && toolbarMemo, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_text_editor_content__WEBPACK_IMPORTED_MODULE_8__["default"], {
|
|
81617
81656
|
placeholder: placeholder,
|
|
81618
81657
|
readOnly: readOnly,
|
|
@@ -81622,8 +81661,13 @@ function TextEditorComponent(_ref) {
|
|
|
81622
81661
|
leafRender: leafRender,
|
|
81623
81662
|
onBlur: saveSelection,
|
|
81624
81663
|
onFocus: recoverSelection,
|
|
81625
|
-
ariaAttrs: ariaAttrs
|
|
81626
|
-
|
|
81664
|
+
ariaAttrs: ariaAttrs,
|
|
81665
|
+
maxLength: maxLength
|
|
81666
|
+
}), toolbarPosition === _text_editor_constants__WEBPACK_IMPORTED_MODULE_11__.TOOLBAR_POSITION.BOTTOM && toolbarMemo)), maxLength && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_chat__WEBPACK_IMPORTED_MODULE_4__.CharactersCounter, {
|
|
81667
|
+
currLength: (0,_text_editor_helpers__WEBPACK_IMPORTED_MODULE_13__.getTextEditorValueLength)(slateValue),
|
|
81668
|
+
maxLength: maxLength,
|
|
81669
|
+
getCharactersCounterString: getCharactersCounterStringText
|
|
81670
|
+
}), validity && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_form_field__WEBPACK_IMPORTED_MODULE_3__.ValidityMessages, {
|
|
81627
81671
|
validity: validity,
|
|
81628
81672
|
validationTestId: "".concat(name, "-validity"),
|
|
81629
81673
|
fieldId: id
|
|
@@ -81693,7 +81737,9 @@ function TextEditor(_ref2) {
|
|
|
81693
81737
|
linkInputLabelText = _ref2.linkInputLabelText,
|
|
81694
81738
|
deleteEditorContentButtonAriaLabel = _ref2.deleteEditorContentButtonAriaLabel,
|
|
81695
81739
|
_ref2$id = _ref2.id,
|
|
81696
|
-
id = _ref2$id === void 0 ? '' : _ref2$id
|
|
81740
|
+
id = _ref2$id === void 0 ? '' : _ref2$id,
|
|
81741
|
+
maxLength = _ref2.maxLength,
|
|
81742
|
+
getCharactersCounterString = _ref2.getCharactersCounterString;
|
|
81697
81743
|
var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),
|
|
81698
81744
|
_useState2 = _slicedToArray(_useState, 2),
|
|
81699
81745
|
isFocused = _useState2[0],
|
|
@@ -81757,7 +81803,9 @@ function TextEditor(_ref2) {
|
|
|
81757
81803
|
leafRender: leafRender,
|
|
81758
81804
|
onChange: onChange,
|
|
81759
81805
|
deleteEditorContentButtonAriaLabel: deleteEditorContentButtonAriaLabel,
|
|
81760
|
-
id: id
|
|
81806
|
+
id: id,
|
|
81807
|
+
maxLength: maxLength,
|
|
81808
|
+
getCharactersCounterString: getCharactersCounterString
|
|
81761
81809
|
})));
|
|
81762
81810
|
}
|
|
81763
81811
|
|