@datarobot/design-system 28.3.1 → 28.3.3
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 +12 -1
- package/cjs/chat/hocs.js +4 -0
- package/esm/chat/chat-message-body.js +12 -1
- package/esm/chat/hocs.js +4 -0
- package/js/bundle/bundle.js +17 -1
- package/js/bundle/bundle.min.js +1 -1
- package/package.json +1 -1
- package/styles/index.css +47 -20
- package/styles/index.min.css +1 -1
|
@@ -146,7 +146,18 @@ function ChatMessageBodyBase({
|
|
|
146
146
|
,
|
|
147
147
|
renderElement: _renderers.renderElement,
|
|
148
148
|
onBlur: onBlur,
|
|
149
|
-
"aria-label": readOnly ? undefined : textBoxAriaLabel
|
|
149
|
+
"aria-label": readOnly ? undefined : textBoxAriaLabel,
|
|
150
|
+
onDOMBeforeInput: event => {
|
|
151
|
+
// we have logic to prevent entering text longer than maxLength in hocs.ts
|
|
152
|
+
// but there we prevent it only from updating slate inner state, html input still
|
|
153
|
+
// adds entered text to the DOM input field causing buggy behavior: https://datarobot.atlassian.net/browse/TESTLIO-2963
|
|
154
|
+
// preventing default from the onDOMBeforeInput won't add new character to the DOM input field.
|
|
155
|
+
// we still won't to leave logic in hocs.ts as a fallback + it also covers copy+paste logic which doesn't trigger onDOMBeforeInput
|
|
156
|
+
const existingMentionsCount = (0, _utils.getMentionsCount)(editor.children);
|
|
157
|
+
if (_slate.Editor.string(editor, []).length + existingMentionsCount + (event?.data?.length ?? 0) > maxLength) {
|
|
158
|
+
event.preventDefault();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
150
161
|
})
|
|
151
162
|
}), hasMentionsSupport && isFocused && /*#__PURE__*/(0, _jsxRuntime.jsx)(_dropdown.PopperDropdownWrapper, {
|
|
152
163
|
closeDropdown: closeMenu,
|
package/cjs/chat/hocs.js
CHANGED
|
@@ -11,6 +11,10 @@ const withMaxLength = maxLength => function Plugin(editor) {
|
|
|
11
11
|
insertText,
|
|
12
12
|
insertData
|
|
13
13
|
} = editor;
|
|
14
|
+
|
|
15
|
+
// we are preventing inserting text if it exceeds maxLength in onDOMBeforeInput event handler in Editor component
|
|
16
|
+
// but I'd leave it here as well for safety in case onDOMBeforeInput stops working for some reason + we still need
|
|
17
|
+
// insertData to handle copy+paste logic which doesn't trigger onDOMBeforeInput
|
|
14
18
|
editor.insertText = text => {
|
|
15
19
|
const existingMentionsCount = (0, _utils.getMentionsCount)(editor.children);
|
|
16
20
|
if (_slate.Editor.string(editor, []).length + existingMentionsCount < maxLength) {
|
|
@@ -138,7 +138,18 @@ function ChatMessageBodyBase({
|
|
|
138
138
|
,
|
|
139
139
|
renderElement: renderElement,
|
|
140
140
|
onBlur: onBlur,
|
|
141
|
-
"aria-label": readOnly ? undefined : textBoxAriaLabel
|
|
141
|
+
"aria-label": readOnly ? undefined : textBoxAriaLabel,
|
|
142
|
+
onDOMBeforeInput: event => {
|
|
143
|
+
// we have logic to prevent entering text longer than maxLength in hocs.ts
|
|
144
|
+
// but there we prevent it only from updating slate inner state, html input still
|
|
145
|
+
// adds entered text to the DOM input field causing buggy behavior: https://datarobot.atlassian.net/browse/TESTLIO-2963
|
|
146
|
+
// preventing default from the onDOMBeforeInput won't add new character to the DOM input field.
|
|
147
|
+
// we still won't to leave logic in hocs.ts as a fallback + it also covers copy+paste logic which doesn't trigger onDOMBeforeInput
|
|
148
|
+
const existingMentionsCount = getMentionsCount(editor.children);
|
|
149
|
+
if (Editor.string(editor, []).length + existingMentionsCount + (event?.data?.length ?? 0) > maxLength) {
|
|
150
|
+
event.preventDefault();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
142
153
|
})
|
|
143
154
|
}), hasMentionsSupport && isFocused && /*#__PURE__*/_jsx(PopperDropdownWrapper, {
|
|
144
155
|
closeDropdown: closeMenu,
|
package/esm/chat/hocs.js
CHANGED
|
@@ -5,6 +5,10 @@ export const withMaxLength = maxLength => function Plugin(editor) {
|
|
|
5
5
|
insertText,
|
|
6
6
|
insertData
|
|
7
7
|
} = editor;
|
|
8
|
+
|
|
9
|
+
// we are preventing inserting text if it exceeds maxLength in onDOMBeforeInput event handler in Editor component
|
|
10
|
+
// but I'd leave it here as well for safety in case onDOMBeforeInput stops working for some reason + we still need
|
|
11
|
+
// insertData to handle copy+paste logic which doesn't trigger onDOMBeforeInput
|
|
8
12
|
editor.insertText = text => {
|
|
9
13
|
const existingMentionsCount = getMentionsCount(editor.children);
|
|
10
14
|
if (Editor.string(editor, []).length + existingMentionsCount < maxLength) {
|
package/js/bundle/bundle.js
CHANGED
|
@@ -44134,7 +44134,19 @@ function ChatMessageBodyBase(_ref) {
|
|
|
44134
44134
|
,
|
|
44135
44135
|
renderElement: _renderers__WEBPACK_IMPORTED_MODULE_10__.renderElement,
|
|
44136
44136
|
onBlur: onBlur,
|
|
44137
|
-
"aria-label": readOnly ? undefined : textBoxAriaLabel
|
|
44137
|
+
"aria-label": readOnly ? undefined : textBoxAriaLabel,
|
|
44138
|
+
onDOMBeforeInput: function onDOMBeforeInput(event) {
|
|
44139
|
+
var _event$data$length, _event$data;
|
|
44140
|
+
// we have logic to prevent entering text longer than maxLength in hocs.ts
|
|
44141
|
+
// but there we prevent it only from updating slate inner state, html input still
|
|
44142
|
+
// adds entered text to the DOM input field causing buggy behavior: https://datarobot.atlassian.net/browse/TESTLIO-2963
|
|
44143
|
+
// preventing default from the onDOMBeforeInput won't add new character to the DOM input field.
|
|
44144
|
+
// we still won't to leave logic in hocs.ts as a fallback + it also covers copy+paste logic which doesn't trigger onDOMBeforeInput
|
|
44145
|
+
var existingMentionsCount = (0,_utils__WEBPACK_IMPORTED_MODULE_11__.getMentionsCount)(editor.children);
|
|
44146
|
+
if (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) {
|
|
44147
|
+
event.preventDefault();
|
|
44148
|
+
}
|
|
44149
|
+
}
|
|
44138
44150
|
})), hasMentionsSupport && isFocused && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_dropdown__WEBPACK_IMPORTED_MODULE_5__.PopperDropdownWrapper, {
|
|
44139
44151
|
closeDropdown: closeMenu,
|
|
44140
44152
|
anchorRef: anchorRef.current,
|
|
@@ -44552,6 +44564,10 @@ var withMaxLength = function withMaxLength(maxLength) {
|
|
|
44552
44564
|
return function Plugin(editor) {
|
|
44553
44565
|
var insertText = editor.insertText,
|
|
44554
44566
|
insertData = editor.insertData;
|
|
44567
|
+
|
|
44568
|
+
// we are preventing inserting text if it exceeds maxLength in onDOMBeforeInput event handler in Editor component
|
|
44569
|
+
// but I'd leave it here as well for safety in case onDOMBeforeInput stops working for some reason + we still need
|
|
44570
|
+
// insertData to handle copy+paste logic which doesn't trigger onDOMBeforeInput
|
|
44555
44571
|
editor.insertText = function (text) {
|
|
44556
44572
|
var existingMentionsCount = (0,_utils__WEBPACK_IMPORTED_MODULE_1__.getMentionsCount)(editor.children);
|
|
44557
44573
|
if (slate__WEBPACK_IMPORTED_MODULE_0__.Editor.string(editor, []).length + existingMentionsCount < maxLength) {
|