@skbkontur/markdown 2.5.8-alpha.15 → 2.5.8-alpha.17
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/package.json +1 -1
- package/src/Markdown/MarkdownActions/AIActionsDropdown/AIActionsDropdown.js +9 -11
- package/src/Markdown/MarkdownActions/MarkdownDropdown/MarkdownDropdown.d.ts +1 -0
- package/src/Markdown/MarkdownActions/MarkdownDropdown/MarkdownDropdown.js +2 -2
- package/src/Markdown/MarkdownHelpers/MarkdownFormatButton.d.ts +1 -0
- package/src/Markdown/MarkdownHelpers/MarkdownFormatButton.js +2 -2
package/package.json
CHANGED
|
@@ -46,16 +46,16 @@ import { Guid } from '../../utils/guid';
|
|
|
46
46
|
import { RequestStatus } from '../../utils/requestStatus';
|
|
47
47
|
import { MarkdownDropdown } from '../MarkdownDropdown/MarkdownDropdown';
|
|
48
48
|
export var AIActionsDropdown = function (_a) {
|
|
49
|
-
var _b;
|
|
49
|
+
var _b, _c, _d, _e;
|
|
50
50
|
var textareaRef = _a.textareaRef, isPreviewMode = _a.isPreviewMode, showActionHint = _a.showActionHint, api = _a.api;
|
|
51
|
-
var
|
|
52
|
-
var
|
|
51
|
+
var _f = useState(), processedText = _f[0], setProcessedText = _f[1];
|
|
52
|
+
var _g = useState(RequestStatus.Default), requestStatus = _g[0], setRequestStatus = _g[1];
|
|
53
53
|
var tooltipRef = useRef(null);
|
|
54
54
|
var taskIdRef = useRef(new Guid());
|
|
55
55
|
var availableMethods = api.availableMethods, onSendMessage = api.onSendMessage;
|
|
56
|
-
var htmlTextArea = (_b = textareaRef.current) === null || _b === void 0 ? void 0 : _b.node;
|
|
57
|
-
var selectionStart = htmlTextArea === null || htmlTextArea === void 0 ? void 0 : htmlTextArea.selectionStart;
|
|
58
|
-
var selectionEnd = htmlTextArea === null || htmlTextArea === void 0 ? void 0 : htmlTextArea.selectionEnd;
|
|
56
|
+
var htmlTextArea = (_b = textareaRef === null || textareaRef === void 0 ? void 0 : textareaRef.current) === null || _b === void 0 ? void 0 : _b.node;
|
|
57
|
+
var selectionStart = (_c = htmlTextArea === null || htmlTextArea === void 0 ? void 0 : htmlTextArea.selectionStart) !== null && _c !== void 0 ? _c : 0;
|
|
58
|
+
var selectionEnd = (_d = htmlTextArea === null || htmlTextArea === void 0 ? void 0 : htmlTextArea.selectionEnd) !== null && _d !== void 0 ? _d : 0;
|
|
59
59
|
useEffect(function () {
|
|
60
60
|
handleCloseTooltip();
|
|
61
61
|
}, [selectionStart, selectionEnd]);
|
|
@@ -64,12 +64,10 @@ export var AIActionsDropdown = function (_a) {
|
|
|
64
64
|
if (processedText)
|
|
65
65
|
(_a = tooltipRef.current) === null || _a === void 0 ? void 0 : _a.show();
|
|
66
66
|
}, [processedText]);
|
|
67
|
-
|
|
68
|
-
return null;
|
|
69
|
-
var value = htmlTextArea.value.substring(Number(selectionStart), selectionEnd !== null && selectionEnd !== void 0 ? selectionEnd : undefined);
|
|
67
|
+
var value = (_e = htmlTextArea === null || htmlTextArea === void 0 ? void 0 : htmlTextArea.value.substring(Number(selectionStart), selectionEnd !== null && selectionEnd !== void 0 ? selectionEnd : undefined)) !== null && _e !== void 0 ? _e : '';
|
|
70
68
|
var isEmptySelected = selectionEnd === selectionStart;
|
|
71
69
|
return (React.createElement(Tooltip, { key: processedText, ref: tooltipRef, pos: "top right", allowedPositions: ['top right', 'right middle', 'bottom right', 'bottom left'], trigger: "manual", render: renderTooltipContent },
|
|
72
|
-
React.createElement(MarkdownDropdown, { dataTid: MarkdownTids.AI, hintPos: "top center", showActionHint: showActionHint, hintText: isEmptySelected ? 'Выдели текст' : 'ИИ-помощник', icon: React.createElement(NatureFxSparkleA2, null), caption: "\u0418\u0418", menuWidth: 180, disabled: isPreviewMode || isEmptySelected, onOpen: handleCloseTooltip }, availableMethods.map(function (_a) {
|
|
70
|
+
React.createElement(MarkdownDropdown, { dataTid: MarkdownTids.AI, hintPos: "top center", showActionHint: showActionHint, showHintWhenDisabled: !isPreviewMode, hintText: isEmptySelected ? 'Выдели текст' : 'ИИ-помощник', icon: React.createElement(NatureFxSparkleA2, null), caption: "\u0418\u0418", menuWidth: 180, disabled: isPreviewMode || isEmptySelected, onOpen: handleCloseTooltip }, availableMethods.map(function (_a) {
|
|
73
71
|
var method = _a.method, caption = _a.caption;
|
|
74
72
|
return (React.createElement(MarkdownMenuItem, { key: method, onClick: function () { return handleProcessText(method); } }, caption));
|
|
75
73
|
}))));
|
|
@@ -136,7 +134,7 @@ export var AIActionsDropdown = function (_a) {
|
|
|
136
134
|
var valueLength = value.length;
|
|
137
135
|
var spaceInStartCount = valueLength - value.trimStart().length;
|
|
138
136
|
var spaceInEndCount = valueLength - value.trimEnd().length;
|
|
139
|
-
htmlTextArea.setSelectionRange(selectionStart + spaceInStartCount, selectionEnd - spaceInEndCount);
|
|
137
|
+
htmlTextArea === null || htmlTextArea === void 0 ? void 0 : htmlTextArea.setSelectionRange(selectionStart + spaceInStartCount, selectionEnd - spaceInEndCount);
|
|
140
138
|
document.execCommand('insertText', false, processedText);
|
|
141
139
|
handleCloseTooltip();
|
|
142
140
|
}
|
|
@@ -3,10 +3,10 @@ import React from 'react';
|
|
|
3
3
|
import { Wrapper } from './MarkdownDropdown.styled';
|
|
4
4
|
import { MarkdownFormatButton } from '../../MarkdownHelpers/MarkdownFormatButton';
|
|
5
5
|
export var MarkdownDropdown = function (_a) {
|
|
6
|
-
var dataTid = _a.dataTid, icon = _a.icon, disabled = _a.disabled, children = _a.children, caption = _a.caption, onOpen = _a.onOpen, menuWidth = _a.menuWidth, hintText = _a.hintText, showActionHint = _a.showActionHint, hintPos = _a.hintPos;
|
|
6
|
+
var dataTid = _a.dataTid, icon = _a.icon, disabled = _a.disabled, children = _a.children, caption = _a.caption, onOpen = _a.onOpen, menuWidth = _a.menuWidth, hintText = _a.hintText, showActionHint = _a.showActionHint, showHintWhenDisabled = _a.showHintWhenDisabled, hintPos = _a.hintPos;
|
|
7
7
|
return (React.createElement(Wrapper, { onMouseDown: function (e) { return e.preventDefault(); } },
|
|
8
8
|
React.createElement(Dropdown, { disablePortal: true, disabled: disabled, caption: caption, menuWidth: menuWidth !== null && menuWidth !== void 0 ? menuWidth : 300, _renderButton: function (_a) {
|
|
9
9
|
var onClick = _a.onClick;
|
|
10
|
-
return (React.createElement(MarkdownFormatButton, { showText: true, dataTid: dataTid, hintPos: hintPos, showActionHint: showActionHint, disabled: disabled, hintText: hintText, icon: icon, text: caption, onClick: function () { return onClick(); } }));
|
|
10
|
+
return (React.createElement(MarkdownFormatButton, { showText: true, dataTid: dataTid, hintPos: hintPos, showActionHint: showActionHint, showHintWhenDisabled: showHintWhenDisabled, disabled: disabled, hintText: hintText, icon: icon, text: caption, onClick: function () { return onClick(); } }));
|
|
11
11
|
}, onOpen: onOpen }, children)));
|
|
12
12
|
};
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { MarkdownCombination } from '../../MarkdownCombination/MarkdownCombination';
|
|
4
4
|
import { MarkdownButtonContentWrapper, MarkdownButtonIcon, MarkdownButtonWrapper, VisuallyHidden, } from '../Markdown.styled';
|
|
5
5
|
export var MarkdownFormatButton = function (_a) {
|
|
6
|
-
var dataTid = _a.dataTid, icon = _a.icon, hintText = _a.hintText, onClick = _a.onClick, format = _a.format, disabled = _a.disabled, text = _a.text, href = _a.href, showActionHint = _a.showActionHint, showShortKey = _a.showShortKey, showText = _a.showText, hintPos = _a.hintPos;
|
|
6
|
+
var dataTid = _a.dataTid, icon = _a.icon, hintText = _a.hintText, onClick = _a.onClick, format = _a.format, disabled = _a.disabled, text = _a.text, href = _a.href, showActionHint = _a.showActionHint, showHintWhenDisabled = _a.showHintWhenDisabled, showShortKey = _a.showShortKey, showText = _a.showText, hintPos = _a.hintPos;
|
|
7
7
|
var button = (React.createElement(MarkdownButtonWrapper, { borderless: true, disabled: disabled, "data-tid": dataTid, onClick: onClick },
|
|
8
8
|
React.createElement(MarkdownButtonContentWrapper, { onMouseDown: function (e) { return e.preventDefault(); } },
|
|
9
9
|
!!icon && React.createElement(MarkdownButtonIcon, null, icon),
|
|
@@ -13,5 +13,5 @@ export var MarkdownFormatButton = function (_a) {
|
|
|
13
13
|
return content;
|
|
14
14
|
var actualHintText = showActionHint && hintText;
|
|
15
15
|
var hintComponent = format ? (React.createElement(MarkdownCombination, { format: format, text: actualHintText, showShortKey: showShortKey })) : (actualHintText);
|
|
16
|
-
return (React.createElement(Hint, { manual: disabled, text: hintComponent, pos: hintPos !== null && hintPos !== void 0 ? hintPos : 'top center', maxWidth: 360 }, content));
|
|
16
|
+
return (React.createElement(Hint, { manual: !showHintWhenDisabled && disabled, text: hintComponent, pos: hintPos !== null && hintPos !== void 0 ? hintPos : 'top center', maxWidth: 360 }, content));
|
|
17
17
|
};
|