@datarobot/design-system 30.7.0 → 30.8.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.
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.ChatMessageBody = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _isEqual = _interopRequireDefault(require("lodash-es/isEqual"));
9
+ var _cloneDeep = _interopRequireDefault(require("lodash-es/cloneDeep"));
9
10
  var _classnames = _interopRequireDefault(require("classnames"));
10
11
  var _slate = require("slate");
11
12
  var _slateReact = require("slate-react");
@@ -36,8 +37,9 @@ function ChatMessageBodyBase({
36
37
  editableContentClassName,
37
38
  mentionsPropmptText,
38
39
  autoFocus,
39
- value = _constants.DEFAULT_VALUE
40
+ value
40
41
  }) {
42
+ const slateValue = (0, _react.useMemo)(() => (0, _cloneDeep.default)(value ?? _constants.DEFAULT_VALUE), [value]);
41
43
  const anchorRef = (0, _react.useRef)(null);
42
44
  const [target, setTarget] = (0, _react.useState)();
43
45
  const [search, setSearch] = (0, _react.useState)('');
@@ -54,10 +56,10 @@ function ChatMessageBodyBase({
54
56
  event.preventDefault();
55
57
  onSubmit({
56
58
  key: itemKey,
57
- value
59
+ value: slateValue
58
60
  });
59
61
  }
60
- }, [mentions, target, value, itemKey, onSubmit]);
62
+ }, [mentions, target, slateValue, itemKey, onSubmit]);
61
63
  const handleChange = (0, _react.useCallback)(val => {
62
64
  onChange({
63
65
  key: itemKey,
@@ -124,14 +126,14 @@ function ChatMessageBodyBase({
124
126
  });
125
127
  }, [search]);
126
128
  (0, _react.useEffect)(() => {
127
- if (!(0, _isEqual.default)(editor.children, value)) {
128
- (0, _utils.resetNodes)(editor, value);
129
+ if (!(0, _isEqual.default)(editor.children, slateValue)) {
130
+ (0, _utils.resetNodes)(editor, slateValue);
129
131
  }
130
- }, [value, editor]);
132
+ }, [slateValue, editor]);
131
133
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
132
134
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_slateReact.Slate, {
133
135
  editor: editor,
134
- initialValue: value,
136
+ initialValue: slateValue,
135
137
  onChange: handleChange,
136
138
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
137
139
  "test-id": `chat-item-body-editable-content-${itemKey}`,
package/cjs/chat/utils.js CHANGED
@@ -7,7 +7,9 @@ exports.getMentionsCount = getMentionsCount;
7
7
  exports.isMentionElement = isMentionElement;
8
8
  exports.resetNodes = resetNodes;
9
9
  var _slate = require("slate");
10
+ var _cloneDeep = _interopRequireDefault(require("lodash-es/cloneDeep"));
10
11
  var _constants = require("./constants");
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
13
  function isMentionElement(type) {
12
14
  return type === _constants.CUSTOM_ELEMENT_TYPES.mention;
13
15
  }
@@ -34,10 +36,12 @@ function resetNodes(editor, nodes) {
34
36
  path: [0],
35
37
  node
36
38
  }));
39
+
40
+ // Clone nodes before inserting so multiple editors never share Slate node refs.
37
41
  nodes.forEach((node, i) => editor.apply({
38
42
  type: 'insert_node',
39
43
  path: [i],
40
- node
44
+ node: (0, _cloneDeep.default)(node)
41
45
  }));
42
46
  const point = _slate.Editor.end(editor, []);
43
47
  _slate.Transforms.select(editor, point);
@@ -7,6 +7,7 @@ exports.default = EditedText;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _classnames = _interopRequireDefault(require("classnames"));
9
9
  var _isEqual = _interopRequireDefault(require("lodash-es/isEqual"));
10
+ var _cloneDeep = _interopRequireDefault(require("lodash-es/cloneDeep"));
10
11
  var _slateHistory = require("slate-history");
11
12
  var _chat = require("../chat");
12
13
  var _textEditorContext = _interopRequireDefault(require("./text-editor-context"));
@@ -37,12 +38,19 @@ function EditedTextComponent({
37
38
  Slate
38
39
  } = slateReact;
39
40
  const editor = (0, _react.useMemo)(() => (0, _withLinks.default)((0, _slateHistory.withHistory)(withReact(createEditor()))), []);
41
+
42
+ // Clone the incoming value so this editor instance owns its own Slate node
43
+ // references. slate-dom 0.123+ keys internal WeakMaps by node identity, and
44
+ // sharing node references across editors (e.g. the same value bound to a
45
+ // form's TextEditor and a preview's EditedText at the same time) makes
46
+ // findPath throw "Unable to find the path for Slate node".
47
+ const slateValue = (0, _react.useMemo)(() => value ? (0, _cloneDeep.default)(value) : value, [value]);
40
48
  (0, _react.useEffect)(() => {
41
- if (value && !(0, _isEqual.default)(editor.children, value)) {
49
+ if (slateValue && !(0, _isEqual.default)(editor.children, slateValue)) {
42
50
  // Update the cached value inside the editor
43
- (0, _chat.resetNodes)(editor, value);
51
+ (0, _chat.resetNodes)(editor, slateValue);
44
52
  }
45
- }, [value, editor]);
53
+ }, [slateValue, editor]);
46
54
  const ariaAttrs = (0, _react.useMemo)(() => {
47
55
  return {
48
56
  'aria-label': ariaLabel
@@ -53,7 +61,7 @@ function EditedTextComponent({
53
61
  // Slate throws an error when no onChange is given, providing a noop func to avoid issues
54
62
  (0, _jsxRuntime.jsx)(Slate, {
55
63
  editor: editor,
56
- initialValue: value,
64
+ initialValue: slateValue,
57
65
  onChange: () => undefined,
58
66
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_textEditorContent.default, {
59
67
  placeholder: placeholder,
@@ -7,6 +7,7 @@ exports.default = TextEditor;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _classnames = _interopRequireDefault(require("classnames"));
9
9
  var _isEqual = _interopRequireDefault(require("lodash-es/isEqual"));
10
+ var _cloneDeep = _interopRequireDefault(require("lodash-es/cloneDeep"));
10
11
  var _slateHistory = require("slate-history");
11
12
  var _formField = require("../form-field");
12
13
  var _chat = require("../chat");
@@ -79,7 +80,13 @@ function TextEditorComponent({
79
80
  }, [getCharactersCounterString]);
80
81
  const editor = (0, _react.useMemo)(() => (0, _chat.withMaxLength)(maxLength)((0, _withLinks.default)((0, _slateHistory.withHistory)(withReact(createEditor())))), [maxLength]);
81
82
  const selection = (0, _react.useRef)(null);
82
- const slateValue = value || initialValue || _textEditorConstants.TEXT_EDITOR_DEFAULT_VALUE;
83
+ // Clone the incoming value so this editor instance owns its own Slate node
84
+ // references. slate-dom 0.123+ keys internal WeakMaps by node identity, and
85
+ // sharing the same node references across editors (e.g. several editors
86
+ // falling back to TEXT_EDITOR_DEFAULT_VALUE, or the same parent state being
87
+ // bound to multiple editors at once) makes findPath throw
88
+ // "Unable to find the path for Slate node".
89
+ const slateValue = (0, _react.useMemo)(() => (0, _cloneDeep.default)(value || initialValue || _textEditorConstants.TEXT_EDITOR_DEFAULT_VALUE), [value, initialValue]);
83
90
  (0, _react.useEffect)(() => {
84
91
  if (!(0, _isEqual.default)(editor.children, slateValue)) {
85
92
  // Update the cached value inside the editor
@@ -1,5 +1,6 @@
1
1
  import React, { useMemo, useState, useCallback, useRef, useEffect, memo } from 'react';
2
2
  import isEqual from 'lodash-es/isEqual';
3
+ import cloneDeep from 'lodash-es/cloneDeep';
3
4
  import classNames from 'classnames';
4
5
  import { Editor, createEditor, Transforms, Range } from 'slate';
5
6
  import { Slate, Editable, ReactEditor, withReact } from 'slate-react';
@@ -28,8 +29,9 @@ function ChatMessageBodyBase({
28
29
  editableContentClassName,
29
30
  mentionsPropmptText,
30
31
  autoFocus,
31
- value = DEFAULT_VALUE
32
+ value
32
33
  }) {
34
+ const slateValue = useMemo(() => cloneDeep(value ?? DEFAULT_VALUE), [value]);
33
35
  const anchorRef = useRef(null);
34
36
  const [target, setTarget] = useState();
35
37
  const [search, setSearch] = useState('');
@@ -46,10 +48,10 @@ function ChatMessageBodyBase({
46
48
  event.preventDefault();
47
49
  onSubmit({
48
50
  key: itemKey,
49
- value
51
+ value: slateValue
50
52
  });
51
53
  }
52
- }, [mentions, target, value, itemKey, onSubmit]);
54
+ }, [mentions, target, slateValue, itemKey, onSubmit]);
53
55
  const handleChange = useCallback(val => {
54
56
  onChange({
55
57
  key: itemKey,
@@ -116,14 +118,14 @@ function ChatMessageBodyBase({
116
118
  });
117
119
  }, [search]);
118
120
  useEffect(() => {
119
- if (!isEqual(editor.children, value)) {
120
- resetNodes(editor, value);
121
+ if (!isEqual(editor.children, slateValue)) {
122
+ resetNodes(editor, slateValue);
121
123
  }
122
- }, [value, editor]);
124
+ }, [slateValue, editor]);
123
125
  return /*#__PURE__*/_jsxs(_Fragment, {
124
126
  children: [/*#__PURE__*/_jsxs(Slate, {
125
127
  editor: editor,
126
- initialValue: value,
128
+ initialValue: slateValue,
127
129
  onChange: handleChange,
128
130
  children: [/*#__PURE__*/_jsx("div", {
129
131
  "test-id": `chat-item-body-editable-content-${itemKey}`,
package/esm/chat/utils.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Editor, Transforms } from 'slate';
2
+ import cloneDeep from 'lodash-es/cloneDeep';
2
3
  import { CUSTOM_ELEMENT_TYPES } from './constants';
3
4
  export function isMentionElement(type) {
4
5
  return type === CUSTOM_ELEMENT_TYPES.mention;
@@ -26,10 +27,12 @@ export function resetNodes(editor, nodes) {
26
27
  path: [0],
27
28
  node
28
29
  }));
30
+
31
+ // Clone nodes before inserting so multiple editors never share Slate node refs.
29
32
  nodes.forEach((node, i) => editor.apply({
30
33
  type: 'insert_node',
31
34
  path: [i],
32
- node
35
+ node: cloneDeep(node)
33
36
  }));
34
37
  const point = Editor.end(editor, []);
35
38
  Transforms.select(editor, point);
@@ -1,6 +1,7 @@
1
1
  import React, { useMemo, useContext, useEffect } from 'react';
2
2
  import classnames from 'classnames';
3
3
  import isEqual from 'lodash-es/isEqual';
4
+ import cloneDeep from 'lodash-es/cloneDeep';
4
5
  import { withHistory } from 'slate-history';
5
6
  import { resetNodes } from '../chat';
6
7
  import TextEditorContext from './text-editor-context';
@@ -29,12 +30,19 @@ function EditedTextComponent({
29
30
  Slate
30
31
  } = slateReact;
31
32
  const editor = useMemo(() => withLinks(withHistory(withReact(createEditor()))), []);
33
+
34
+ // Clone the incoming value so this editor instance owns its own Slate node
35
+ // references. slate-dom 0.123+ keys internal WeakMaps by node identity, and
36
+ // sharing node references across editors (e.g. the same value bound to a
37
+ // form's TextEditor and a preview's EditedText at the same time) makes
38
+ // findPath throw "Unable to find the path for Slate node".
39
+ const slateValue = useMemo(() => value ? cloneDeep(value) : value, [value]);
32
40
  useEffect(() => {
33
- if (value && !isEqual(editor.children, value)) {
41
+ if (slateValue && !isEqual(editor.children, slateValue)) {
34
42
  // Update the cached value inside the editor
35
- resetNodes(editor, value);
43
+ resetNodes(editor, slateValue);
36
44
  }
37
- }, [value, editor]);
45
+ }, [slateValue, editor]);
38
46
  const ariaAttrs = useMemo(() => {
39
47
  return {
40
48
  'aria-label': ariaLabel
@@ -45,7 +53,7 @@ function EditedTextComponent({
45
53
  // Slate throws an error when no onChange is given, providing a noop func to avoid issues
46
54
  _jsx(Slate, {
47
55
  editor: editor,
48
- initialValue: value,
56
+ initialValue: slateValue,
49
57
  onChange: () => undefined,
50
58
  children: /*#__PURE__*/_jsx(TextEditorContent, {
51
59
  placeholder: placeholder,
@@ -1,6 +1,7 @@
1
1
  import React, { useMemo, useRef, useContext, useState, useEffect, useCallback } from 'react';
2
2
  import classnames from 'classnames';
3
3
  import isEqual from 'lodash-es/isEqual';
4
+ import cloneDeep from 'lodash-es/cloneDeep';
4
5
  import { withHistory } from 'slate-history';
5
6
  import { ValidityMessages, getErrorAriaAttributes, useDefaultValidationValues } from '../form-field';
6
7
  import { resetNodes, CharactersCounter, withMaxLength } from '../chat';
@@ -71,7 +72,13 @@ function TextEditorComponent({
71
72
  }, [getCharactersCounterString]);
72
73
  const editor = useMemo(() => withMaxLength(maxLength)(withLinks(withHistory(withReact(createEditor())))), [maxLength]);
73
74
  const selection = useRef(null);
74
- const slateValue = value || initialValue || TEXT_EDITOR_DEFAULT_VALUE;
75
+ // Clone the incoming value so this editor instance owns its own Slate node
76
+ // references. slate-dom 0.123+ keys internal WeakMaps by node identity, and
77
+ // sharing the same node references across editors (e.g. several editors
78
+ // falling back to TEXT_EDITOR_DEFAULT_VALUE, or the same parent state being
79
+ // bound to multiple editors at once) makes findPath throw
80
+ // "Unable to find the path for Slate node".
81
+ const slateValue = useMemo(() => cloneDeep(value || initialValue || TEXT_EDITOR_DEFAULT_VALUE), [value, initialValue]);
75
82
  useEffect(() => {
76
83
  if (!isEqual(editor.children, slateValue)) {
77
84
  // Update the cached value inside the editor
@@ -15015,6 +15015,48 @@ function trimmedEndIndex(string) {
15015
15015
 
15016
15016
  /***/ }),
15017
15017
 
15018
+ /***/ "../../node_modules/lodash-es/cloneDeep.js":
15019
+ /*!*************************************************!*\
15020
+ !*** ../../node_modules/lodash-es/cloneDeep.js ***!
15021
+ \*************************************************/
15022
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
15023
+
15024
+ "use strict";
15025
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
15026
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
15027
+ /* harmony export */ });
15028
+ /* harmony import */ var _baseClone_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./_baseClone.js */ "../../node_modules/lodash-es/_baseClone.js");
15029
+
15030
+
15031
+ /** Used to compose bitmasks for cloning. */
15032
+ var CLONE_DEEP_FLAG = 1,
15033
+ CLONE_SYMBOLS_FLAG = 4;
15034
+
15035
+ /**
15036
+ * This method is like `_.clone` except that it recursively clones `value`.
15037
+ *
15038
+ * @static
15039
+ * @memberOf _
15040
+ * @since 1.0.0
15041
+ * @category Lang
15042
+ * @param {*} value The value to recursively clone.
15043
+ * @returns {*} Returns the deep cloned value.
15044
+ * @see _.clone
15045
+ * @example
15046
+ *
15047
+ * var objects = [{ 'a': 1 }, { 'b': 2 }];
15048
+ *
15049
+ * var deep = _.cloneDeep(objects);
15050
+ * console.log(deep[0] === objects[0]);
15051
+ * // => false
15052
+ */
15053
+ function cloneDeep(value) {
15054
+ return (0,_baseClone_js__WEBPACK_IMPORTED_MODULE_0__["default"])(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
15055
+ }
15056
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (cloneDeep);
15057
+
15058
+ /***/ }),
15059
+
15018
15060
  /***/ "../../node_modules/lodash-es/constant.js":
15019
15061
  /*!************************************************!*\
15020
15062
  !*** ../../node_modules/lodash-es/constant.js ***!
@@ -45651,7 +45693,8 @@ var CharactersCounter = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.memo)
45651
45693
  /* harmony export */ });
45652
45694
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
45653
45695
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
45654
- /* harmony import */ var lodash_es_isEqual__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! lodash-es/isEqual */ "../../node_modules/lodash-es/isEqual.js");
45696
+ /* harmony import */ var lodash_es_isEqual__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! lodash-es/isEqual */ "../../node_modules/lodash-es/isEqual.js");
45697
+ /* harmony import */ var lodash_es_cloneDeep__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! lodash-es/cloneDeep */ "../../node_modules/lodash-es/cloneDeep.js");
45655
45698
  /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! classnames */ "./node_modules/classnames/index.js");
45656
45699
  /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_1__);
45657
45700
  /* harmony import */ var slate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! slate */ "slate");
@@ -45685,6 +45728,7 @@ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
45685
45728
 
45686
45729
 
45687
45730
 
45731
+
45688
45732
  function ChatMessageBodyBase(_ref) {
45689
45733
  var itemKey = _ref.itemKey,
45690
45734
  textBoxAriaLabel = _ref.textBoxAriaLabel,
@@ -45702,8 +45746,10 @@ function ChatMessageBodyBase(_ref) {
45702
45746
  editableContentClassName = _ref.editableContentClassName,
45703
45747
  mentionsPropmptText = _ref.mentionsPropmptText,
45704
45748
  autoFocus = _ref.autoFocus,
45705
- _ref$value = _ref.value,
45706
- value = _ref$value === void 0 ? _constants__WEBPACK_IMPORTED_MODULE_9__.DEFAULT_VALUE : _ref$value;
45749
+ value = _ref.value;
45750
+ var slateValue = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () {
45751
+ return (0,lodash_es_cloneDeep__WEBPACK_IMPORTED_MODULE_12__["default"])(value !== null && value !== void 0 ? value : _constants__WEBPACK_IMPORTED_MODULE_9__.DEFAULT_VALUE);
45752
+ }, [value]);
45707
45753
  var anchorRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
45708
45754
  var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(),
45709
45755
  _useState2 = _slicedToArray(_useState, 2),
@@ -45734,10 +45780,10 @@ function ChatMessageBodyBase(_ref) {
45734
45780
  event.preventDefault();
45735
45781
  onSubmit({
45736
45782
  key: itemKey,
45737
- value: value
45783
+ value: slateValue
45738
45784
  });
45739
45785
  }
45740
- }, [mentions, target, value, itemKey, onSubmit]);
45786
+ }, [mentions, target, slateValue, itemKey, onSubmit]);
45741
45787
  var handleChange = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (val) {
45742
45788
  onChange({
45743
45789
  key: itemKey,
@@ -45807,13 +45853,13 @@ function ChatMessageBodyBase(_ref) {
45807
45853
  });
45808
45854
  }, [search]);
45809
45855
  (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
45810
- if (!(0,lodash_es_isEqual__WEBPACK_IMPORTED_MODULE_12__["default"])(editor.children, value)) {
45811
- (0,_utils__WEBPACK_IMPORTED_MODULE_11__.resetNodes)(editor, value);
45856
+ if (!(0,lodash_es_isEqual__WEBPACK_IMPORTED_MODULE_13__["default"])(editor.children, slateValue)) {
45857
+ (0,_utils__WEBPACK_IMPORTED_MODULE_11__.resetNodes)(editor, slateValue);
45812
45858
  }
45813
- }, [value, editor]);
45859
+ }, [slateValue, editor]);
45814
45860
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(slate_react__WEBPACK_IMPORTED_MODULE_3__.Slate, {
45815
45861
  editor: editor,
45816
- initialValue: value,
45862
+ initialValue: slateValue,
45817
45863
  onChange: handleChange
45818
45864
  }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
45819
45865
  "test-id": "chat-item-body-editable-content-".concat(itemKey),
@@ -46436,6 +46482,7 @@ var getOptionsTriggerIcon = function getOptionsTriggerIcon() {
46436
46482
  /* harmony export */ });
46437
46483
  /* harmony import */ var slate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! slate */ "slate");
46438
46484
  /* harmony import */ var slate__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(slate__WEBPACK_IMPORTED_MODULE_0__);
46485
+ /* harmony import */ var lodash_es_cloneDeep__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lodash-es/cloneDeep */ "../../node_modules/lodash-es/cloneDeep.js");
46439
46486
  /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants */ "./src/components/chat/constants.ts");
46440
46487
  function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
46441
46488
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -46445,6 +46492,7 @@ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(
46445
46492
  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; }
46446
46493
 
46447
46494
 
46495
+
46448
46496
  function isMentionElement(type) {
46449
46497
  return type === _constants__WEBPACK_IMPORTED_MODULE_1__.CUSTOM_ELEMENT_TYPES.mention;
46450
46498
  }
@@ -46471,11 +46519,13 @@ function resetNodes(editor, nodes) {
46471
46519
  node: node
46472
46520
  });
46473
46521
  });
46522
+
46523
+ // Clone nodes before inserting so multiple editors never share Slate node refs.
46474
46524
  nodes.forEach(function (node, i) {
46475
46525
  return editor.apply({
46476
46526
  type: 'insert_node',
46477
46527
  path: [i],
46478
- node: node
46528
+ node: (0,lodash_es_cloneDeep__WEBPACK_IMPORTED_MODULE_2__["default"])(node)
46479
46529
  });
46480
46530
  });
46481
46531
  var point = slate__WEBPACK_IMPORTED_MODULE_0__.Editor.end(editor, []);
@@ -83181,7 +83231,8 @@ function TabularDataTooltip(_ref) {
83181
83231
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
83182
83232
  /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! classnames */ "./node_modules/classnames/index.js");
83183
83233
  /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_1__);
83184
- /* harmony import */ var lodash_es_isEqual__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! lodash-es/isEqual */ "../../node_modules/lodash-es/isEqual.js");
83234
+ /* harmony import */ var lodash_es_isEqual__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! lodash-es/isEqual */ "../../node_modules/lodash-es/isEqual.js");
83235
+ /* harmony import */ var lodash_es_cloneDeep__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! lodash-es/cloneDeep */ "../../node_modules/lodash-es/cloneDeep.js");
83185
83236
  /* harmony import */ var slate_history__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! slate-history */ "slate-history");
83186
83237
  /* harmony import */ var slate_history__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(slate_history__WEBPACK_IMPORTED_MODULE_2__);
83187
83238
  /* harmony import */ var _chat__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../chat */ "./src/components/chat/index.ts");
@@ -83201,6 +83252,7 @@ function TabularDataTooltip(_ref) {
83201
83252
 
83202
83253
 
83203
83254
 
83255
+
83204
83256
  function EditedTextComponent(_ref) {
83205
83257
  var value = _ref.value,
83206
83258
  placeholder = _ref.placeholder,
@@ -83221,12 +83273,21 @@ function EditedTextComponent(_ref) {
83221
83273
  var editor = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () {
83222
83274
  return (0,_hooks_with_links__WEBPACK_IMPORTED_MODULE_6__["default"])((0,slate_history__WEBPACK_IMPORTED_MODULE_2__.withHistory)(withReact(createEditor())));
83223
83275
  }, []);
83276
+
83277
+ // Clone the incoming value so this editor instance owns its own Slate node
83278
+ // references. slate-dom 0.123+ keys internal WeakMaps by node identity, and
83279
+ // sharing node references across editors (e.g. the same value bound to a
83280
+ // form's TextEditor and a preview's EditedText at the same time) makes
83281
+ // findPath throw "Unable to find the path for Slate node".
83282
+ var slateValue = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () {
83283
+ return value ? (0,lodash_es_cloneDeep__WEBPACK_IMPORTED_MODULE_9__["default"])(value) : value;
83284
+ }, [value]);
83224
83285
  (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
83225
- if (value && !(0,lodash_es_isEqual__WEBPACK_IMPORTED_MODULE_9__["default"])(editor.children, value)) {
83286
+ if (slateValue && !(0,lodash_es_isEqual__WEBPACK_IMPORTED_MODULE_10__["default"])(editor.children, slateValue)) {
83226
83287
  // Update the cached value inside the editor
83227
- (0,_chat__WEBPACK_IMPORTED_MODULE_3__.resetNodes)(editor, value);
83288
+ (0,_chat__WEBPACK_IMPORTED_MODULE_3__.resetNodes)(editor, slateValue);
83228
83289
  }
83229
- }, [value, editor]);
83290
+ }, [slateValue, editor]);
83230
83291
  var ariaAttrs = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () {
83231
83292
  return {
83232
83293
  'aria-label': ariaLabel
@@ -83237,7 +83298,7 @@ function EditedTextComponent(_ref) {
83237
83298
  // Slate throws an error when no onChange is given, providing a noop func to avoid issues
83238
83299
  react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Slate, {
83239
83300
  editor: editor,
83240
- initialValue: value,
83301
+ initialValue: slateValue,
83241
83302
  onChange: function onChange() {
83242
83303
  return undefined;
83243
83304
  }
@@ -85225,7 +85286,8 @@ function TextEditorToolbar(_ref) {
85225
85286
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
85226
85287
  /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! classnames */ "./node_modules/classnames/index.js");
85227
85288
  /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_1__);
85228
- /* harmony import */ var lodash_es_isEqual__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! lodash-es/isEqual */ "../../node_modules/lodash-es/isEqual.js");
85289
+ /* harmony import */ var lodash_es_isEqual__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! lodash-es/isEqual */ "../../node_modules/lodash-es/isEqual.js");
85290
+ /* harmony import */ var lodash_es_cloneDeep__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! lodash-es/cloneDeep */ "../../node_modules/lodash-es/cloneDeep.js");
85229
85291
  /* harmony import */ var slate_history__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! slate-history */ "slate-history");
85230
85292
  /* harmony import */ var slate_history__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(slate_history__WEBPACK_IMPORTED_MODULE_2__);
85231
85293
  /* harmony import */ var _form_field__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../form-field */ "./src/components/form-field/index.ts");
@@ -85271,6 +85333,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
85271
85333
 
85272
85334
 
85273
85335
 
85336
+
85274
85337
  function TextEditorComponent(_ref) {
85275
85338
  var name = _ref.name,
85276
85339
  type = _ref.type,
@@ -85337,9 +85400,17 @@ function TextEditorComponent(_ref) {
85337
85400
  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()))));
85338
85401
  }, [maxLength]);
85339
85402
  var selection = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
85340
- var slateValue = value || initialValue || _text_editor_constants__WEBPACK_IMPORTED_MODULE_11__.TEXT_EDITOR_DEFAULT_VALUE;
85403
+ // Clone the incoming value so this editor instance owns its own Slate node
85404
+ // references. slate-dom 0.123+ keys internal WeakMaps by node identity, and
85405
+ // sharing the same node references across editors (e.g. several editors
85406
+ // falling back to TEXT_EDITOR_DEFAULT_VALUE, or the same parent state being
85407
+ // bound to multiple editors at once) makes findPath throw
85408
+ // "Unable to find the path for Slate node".
85409
+ var slateValue = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () {
85410
+ return (0,lodash_es_cloneDeep__WEBPACK_IMPORTED_MODULE_16__["default"])(value || initialValue || _text_editor_constants__WEBPACK_IMPORTED_MODULE_11__.TEXT_EDITOR_DEFAULT_VALUE);
85411
+ }, [value, initialValue]);
85341
85412
  (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
85342
- if (!(0,lodash_es_isEqual__WEBPACK_IMPORTED_MODULE_16__["default"])(editor.children, slateValue)) {
85413
+ if (!(0,lodash_es_isEqual__WEBPACK_IMPORTED_MODULE_17__["default"])(editor.children, slateValue)) {
85343
85414
  // Update the cached value inside the editor
85344
85415
  (0,_chat__WEBPACK_IMPORTED_MODULE_4__.resetNodes)(editor, slateValue);
85345
85416
  }