@yuntijs/ui 1.0.0-beta.8 → 1.0.0-beta.80
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/es/Alert/index.d.ts +13 -0
- package/es/Alert/index.js +25 -0
- package/es/Alert/style.d.ts +4 -0
- package/es/Alert/style.js +13 -0
- package/es/App/index.d.ts +7 -0
- package/es/App/index.js +19 -0
- package/es/ButtonGroup/index.d.ts +24 -0
- package/es/ButtonGroup/index.js +66 -0
- package/es/Card/index.d.ts +1 -0
- package/es/Card/index.js +1 -0
- package/es/CardList/Item/index.d.ts +4 -0
- package/es/CardList/Item/index.js +43 -0
- package/es/CardList/Item/style.d.ts +0 -0
- package/es/CardList/Item/style.js +0 -0
- package/es/CardList/index.d.ts +2 -0
- package/es/CardList/index.js +39 -0
- package/es/ChatInputArea/desktop/ChatInputArea.d.ts +19 -0
- package/es/ChatInputArea/desktop/ChatInputArea.js +72 -0
- package/es/ChatInputArea/index.d.ts +6 -0
- package/es/ChatInputArea/index.js +6 -0
- package/es/ChatItem/components/MessageContent.d.ts +21 -0
- package/es/ChatItem/components/MessageContent.js +59 -0
- package/es/ChatItem/index.d.ts +4 -0
- package/es/ChatItem/index.js +120 -0
- package/es/ChatItem/style.d.ts +24 -0
- package/es/ChatItem/style.js +38 -0
- package/es/ChatItem/type.d.ts +82 -0
- package/es/ChatItem/type.js +1 -0
- package/es/CollapseGroup/index.d.ts +4 -0
- package/es/CollapseGroup/index.js +23 -0
- package/es/CollapseGroup/style.d.ts +3 -0
- package/es/CollapseGroup/style.js +11 -0
- package/es/ConfigProvider/index.d.ts +3 -0
- package/es/ConfigProvider/index.js +17 -11
- package/es/Descriptions/index.d.ts +14 -0
- package/es/Descriptions/index.js +31 -0
- package/es/Descriptions/style.d.ts +4 -0
- package/es/Descriptions/style.js +24 -0
- package/es/Divider/index.d.ts +38 -0
- package/es/Divider/index.js +66 -0
- package/es/Divider/style.d.ts +3 -0
- package/es/Divider/style.js +12 -0
- package/es/DragPanel/index.d.ts +10 -0
- package/es/DragPanel/index.js +97 -0
- package/es/DragPanel/style.d.ts +7 -0
- package/es/DragPanel/style.js +15 -0
- package/es/Drawer/index.d.ts +13 -0
- package/es/Drawer/index.js +20 -0
- package/es/Drawer/style.d.ts +4 -0
- package/es/Drawer/style.js +16 -0
- package/es/Dropdown/index.d.ts +14 -0
- package/es/Dropdown/index.js +59 -0
- package/es/Dropdown/style.d.ts +7 -0
- package/es/Dropdown/style.js +13 -0
- package/es/EditableMessage/index.d.ts +75 -0
- package/es/EditableMessage/index.js +99 -0
- package/es/Form/collapse-list/index.d.ts +40 -0
- package/es/Form/collapse-list/index.js +209 -0
- package/es/Form/collapse-list/style.d.ts +5 -0
- package/es/Form/collapse-list/style.js +13 -0
- package/es/Form/index.d.ts +8 -0
- package/es/Form/index.js +5 -0
- package/es/FormHelper/autoFocus.d.ts +10 -0
- package/es/FormHelper/autoFocus.js +38 -0
- package/es/FormHelper/index.d.ts +13 -0
- package/es/FormHelper/index.js +41 -0
- package/es/Highlighter/FullFeatured.d.ts +18 -0
- package/es/Highlighter/FullFeatured.js +102 -0
- package/es/Highlighter/SyntaxHighlighter/index.d.ts +7 -0
- package/es/Highlighter/SyntaxHighlighter/index.js +51 -0
- package/es/Highlighter/SyntaxHighlighter/style.d.ts +5 -0
- package/es/Highlighter/SyntaxHighlighter/style.js +16 -0
- package/es/Highlighter/index.d.ts +50 -0
- package/es/Highlighter/index.js +77 -0
- package/es/Highlighter/style.d.ts +9 -0
- package/es/Highlighter/style.js +23 -0
- package/es/Highlighter/theme.d.ts +1 -0
- package/es/Highlighter/theme.js +1661 -0
- package/es/LogViewer/index.d.ts +10 -0
- package/es/LogViewer/index.js +141 -0
- package/es/LogViewer/style.d.ts +6 -0
- package/es/LogViewer/style.js +16 -0
- package/es/LogViewer/types.d.ts +235 -0
- package/es/LogViewer/types.js +1 -0
- package/es/Mentions/constants.d.ts +6 -0
- package/es/Mentions/constants.js +28 -0
- package/es/Mentions/hooks.d.ts +20 -0
- package/es/Mentions/hooks.js +133 -0
- package/es/Mentions/index.d.ts +19 -0
- package/es/Mentions/index.js +136 -0
- package/es/Mentions/plugins/custom-text/node.d.ts +11 -0
- package/es/Mentions/plugins/custom-text/node.js +72 -0
- package/es/Mentions/plugins/mention-node/component.d.ts +6 -0
- package/es/Mentions/plugins/mention-node/component.js +64 -0
- package/es/Mentions/plugins/mention-node/index.d.ts +9 -0
- package/es/Mentions/plugins/mention-node/index.js +32 -0
- package/es/Mentions/plugins/mention-node/node.d.ts +23 -0
- package/es/Mentions/plugins/mention-node/node.js +97 -0
- package/es/Mentions/plugins/mention-node/replacement.d.ts +5 -0
- package/es/Mentions/plugins/mention-node/replacement.js +42 -0
- package/es/Mentions/plugins/mention-node/style.d.ts +8 -0
- package/es/Mentions/plugins/mention-node/style.js +47 -0
- package/es/Mentions/plugins/mention-node/utils.d.ts +4 -0
- package/es/Mentions/plugins/mention-node/utils.js +5 -0
- package/es/Mentions/plugins/mention-picker/hooks.d.ts +5 -0
- package/es/Mentions/plugins/mention-picker/hooks.js +39 -0
- package/es/Mentions/plugins/mention-picker/index.d.ts +36 -0
- package/es/Mentions/plugins/mention-picker/index.js +87 -0
- package/es/Mentions/plugins/mention-picker/menu-item.d.ts +11 -0
- package/es/Mentions/plugins/mention-picker/menu-item.js +71 -0
- package/es/Mentions/plugins/mention-picker/menu.d.ts +9 -0
- package/es/Mentions/plugins/mention-picker/menu.js +30 -0
- package/es/Mentions/plugins/mention-picker/style.d.ts +11 -0
- package/es/Mentions/plugins/mention-picker/style.js +19 -0
- package/es/Mentions/plugins/mention-picker/utils.d.ts +22 -0
- package/es/Mentions/plugins/mention-picker/utils.js +39 -0
- package/es/Mentions/plugins/on-blur-or-focus-block.d.ts +7 -0
- package/es/Mentions/plugins/on-blur-or-focus-block.js +36 -0
- package/es/Mentions/provider.d.ts +12 -0
- package/es/Mentions/provider.js +15 -0
- package/es/Mentions/style.d.ts +11 -0
- package/es/Mentions/style.js +22 -0
- package/es/Mentions/types.d.ts +17 -0
- package/es/Mentions/types.js +1 -0
- package/es/Mentions/utils.d.ts +9 -0
- package/es/Mentions/utils.js +95 -0
- package/es/Modal/index.d.ts +19 -0
- package/es/Modal/index.js +36 -0
- package/es/Modal/style.d.ts +4 -0
- package/es/Modal/style.js +17 -0
- package/es/MonacoEditor/base/controller.d.ts +17 -0
- package/es/MonacoEditor/base/controller.js +49 -0
- package/es/MonacoEditor/base/helper.d.ts +65 -0
- package/es/MonacoEditor/base/helper.js +324 -0
- package/es/MonacoEditor/base/index.d.ts +35 -0
- package/es/MonacoEditor/base/index.js +236 -0
- package/es/MonacoEditor/base/monaco.d.ts +6 -0
- package/es/MonacoEditor/base/monaco.js +64 -0
- package/es/MonacoEditor/base/style.d.ts +12 -0
- package/es/MonacoEditor/base/style.js +26 -0
- package/es/MonacoEditor/index.d.ts +2 -4
- package/es/MonacoEditor/index.js +26 -62
- package/es/MonacoEditor/style.js +3 -2
- package/es/Page/Breadcrumb/index.d.ts +9 -0
- package/es/Page/Breadcrumb/index.js +56 -0
- package/es/Page/Content/index.d.ts +4 -0
- package/es/Page/Content/index.js +59 -0
- package/es/Page/Content/style.d.ts +3 -0
- package/es/Page/Content/style.js +12 -0
- package/es/Page/Footer/index.d.ts +2 -0
- package/es/Page/Footer/index.js +6 -0
- package/es/Page/Header/Icon.d.ts +17 -0
- package/es/Page/Header/Icon.js +42 -0
- package/es/Page/Header/index.d.ts +43 -0
- package/es/Page/Header/index.js +202 -0
- package/es/Page/Header/style.d.ts +12 -0
- package/es/Page/Header/style.js +21 -0
- package/es/Page/Page.d.ts +9 -0
- package/es/Page/Page.js +49 -0
- package/es/Page/PageContext.d.ts +15 -0
- package/es/Page/PageContext.js +21 -0
- package/es/Page/Title/index.d.ts +5 -0
- package/es/Page/Title/index.js +18 -0
- package/es/Page/Title/style.d.ts +3 -0
- package/es/Page/Title/style.js +10 -0
- package/es/Page/index.d.ts +18 -0
- package/es/Page/index.js +15 -0
- package/es/Page/style.d.ts +3 -0
- package/es/Page/style.js +10 -0
- package/es/ProCard/Card/index.d.ts +6 -0
- package/es/ProCard/Card/index.js +25 -0
- package/es/ProCard/Card/style.d.ts +7 -0
- package/es/ProCard/Card/style.js +15 -0
- package/es/ProCard/Content/index.d.ts +4 -0
- package/es/ProCard/Content/index.js +24 -0
- package/es/ProCard/Content/style.d.ts +3 -0
- package/es/ProCard/Content/style.js +10 -0
- package/es/ProCard/Descriptions/index.d.ts +4 -0
- package/es/ProCard/Descriptions/index.js +28 -0
- package/es/ProCard/Descriptions/style.d.ts +3 -0
- package/es/ProCard/Descriptions/style.js +12 -0
- package/es/ProCard/Header/index.d.ts +15 -0
- package/es/ProCard/Header/index.js +86 -0
- package/es/ProCard/Header/style.d.ts +12 -0
- package/es/ProCard/Header/style.js +21 -0
- package/es/ProCard/index.d.ts +13 -0
- package/es/ProCard/index.js +8 -0
- package/es/Radio/index.d.ts +36 -0
- package/es/Radio/index.js +26 -0
- package/es/Radio/style.d.ts +4 -0
- package/es/Radio/style.js +66 -0
- package/es/SelectCard/index.d.ts +33 -0
- package/es/SelectCard/index.js +132 -0
- package/es/SelectCard/style.d.ts +10 -0
- package/es/SelectCard/style.js +42 -0
- package/es/SliderInput/index.js +2 -2
- package/es/Status/index.d.ts +7 -0
- package/es/Status/index.js +39 -0
- package/es/Status/style.d.ts +4 -0
- package/es/Status/style.js +14 -0
- package/es/Table/collapse/index.d.ts +8 -0
- package/es/Table/collapse/index.js +39 -0
- package/es/Table/collapse/style.d.ts +3 -0
- package/es/Table/collapse/style.js +11 -0
- package/es/Table/index.d.ts +20 -0
- package/es/Table/index.js +56 -0
- package/es/Typography/index.d.ts +32 -0
- package/es/Typography/index.js +77 -0
- package/es/WaveformIcon/index.d.ts +9 -0
- package/es/WaveformIcon/index.js +51 -0
- package/es/hooks/languageMap.d.ts +1 -0
- package/es/hooks/languageMap.js +1 -0
- package/es/hooks/useHighlight.d.ts +5 -0
- package/es/hooks/useHighlight.js +78 -0
- package/es/index.d.ts +38 -1
- package/es/index.js +52 -1
- package/es/notification/index.d.ts +24 -0
- package/es/notification/index.js +237 -0
- package/es/notification/style.d.ts +2 -0
- package/es/notification/style.js +28 -0
- package/es/styles/colors/colors.d.ts +39 -0
- package/es/styles/colors/colors.js +86 -0
- package/es/styles/colors/generateColorPalette.d.ts +11 -0
- package/es/styles/colors/generateColorPalette.js +31 -0
- package/es/styles/colors/neutralColors.d.ts +9 -0
- package/es/styles/colors/neutralColors.js +32 -0
- package/es/styles/index.d.ts +4 -0
- package/es/styles/index.js +4 -0
- package/es/useSpeechSynthes/const/polyfill.d.ts +3 -0
- package/es/useSpeechSynthes/const/polyfill.js +21 -0
- package/es/useSpeechSynthes/index.d.ts +13 -0
- package/es/useSpeechSynthes/index.js +69 -0
- package/es/utils/constants.d.ts +1 -0
- package/es/utils/constants.js +1 -0
- package/es/utils/tools.d.ts +1 -0
- package/es/utils/tools.js +1 -0
- package/package.json +30 -9
- package/umd/index.min.js +1 -1
- package/umd/index.min.js.map +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DivProps } from 'react-layout-kit';
|
|
3
|
+
import type { LazyLogProps } from './types';
|
|
4
|
+
export interface LogViewerProps extends Omit<LazyLogProps, 'iconFilterLines' | 'iconFindNext' | 'iconFindPrevious' | 'loadingComponent'>, Pick<DivProps, 'className' | 'id' | 'style'> {
|
|
5
|
+
/**
|
|
6
|
+
* Timed refresh, in ms, only takes effect when url is specified and not websocket
|
|
7
|
+
*/
|
|
8
|
+
refreshInterval?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const LogViewer: React.FC<LogViewerProps>;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["className", "id", "style", "height", "onScroll", "url", "websocket", "refreshInterval", "onLoad", "onError"];
|
|
5
|
+
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; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
+
import { Icon } from '@lobehub/ui';
|
|
8
|
+
import { LazyLog, ScrollFollow } from '@melloware/react-logviewer';
|
|
9
|
+
import { ArrowDown, ArrowUp, LoaderCircle, TextSearch } from 'lucide-react';
|
|
10
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
11
|
+
import { useStyles } from "./style";
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
export var LogViewer = function LogViewer(_ref) {
|
|
16
|
+
var className = _ref.className,
|
|
17
|
+
id = _ref.id,
|
|
18
|
+
style = _ref.style,
|
|
19
|
+
height = _ref.height,
|
|
20
|
+
_onScroll = _ref.onScroll,
|
|
21
|
+
urlFromProps = _ref.url,
|
|
22
|
+
websocket = _ref.websocket,
|
|
23
|
+
refreshInterval = _ref.refreshInterval,
|
|
24
|
+
onLoad = _ref.onLoad,
|
|
25
|
+
onError = _ref.onError,
|
|
26
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
27
|
+
var _useStyles = useStyles(),
|
|
28
|
+
cx = _useStyles.cx,
|
|
29
|
+
styles = _useStyles.styles;
|
|
30
|
+
var _useState = useState(0),
|
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
32
|
+
urlHash = _useState2[0],
|
|
33
|
+
setUrlHash = _useState2[1];
|
|
34
|
+
var _useState3 = useState(false),
|
|
35
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
36
|
+
loading = _useState4[0],
|
|
37
|
+
setLoading = _useState4[1];
|
|
38
|
+
var _useState5 = useState(false),
|
|
39
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
40
|
+
followAfterLoaded = _useState6[0],
|
|
41
|
+
setFollowAfterLoaded = _useState6[1];
|
|
42
|
+
var setLoadingTimeout = useRef();
|
|
43
|
+
var setFollowAfterLoadedTimeout = useRef();
|
|
44
|
+
useEffect(function () {
|
|
45
|
+
return function () {
|
|
46
|
+
clearTimeout(setLoadingTimeout.current);
|
|
47
|
+
clearTimeout(setFollowAfterLoadedTimeout.current);
|
|
48
|
+
};
|
|
49
|
+
}, []);
|
|
50
|
+
useEffect(function () {
|
|
51
|
+
var intervalTimeout;
|
|
52
|
+
if (urlFromProps && !websocket && refreshInterval) {
|
|
53
|
+
intervalTimeout = setInterval(function () {
|
|
54
|
+
setUrlHash(function (hash) {
|
|
55
|
+
return hash + 1;
|
|
56
|
+
});
|
|
57
|
+
}, refreshInterval);
|
|
58
|
+
}
|
|
59
|
+
return function () {
|
|
60
|
+
clearInterval(intervalTimeout);
|
|
61
|
+
};
|
|
62
|
+
}, [refreshInterval, urlFromProps, websocket]);
|
|
63
|
+
var url = useMemo(function () {
|
|
64
|
+
if (!urlFromProps) {
|
|
65
|
+
return urlFromProps;
|
|
66
|
+
}
|
|
67
|
+
// workaround for onLoad exec twice
|
|
68
|
+
setLoadingTimeout.current = setTimeout(function () {
|
|
69
|
+
setLoading(true);
|
|
70
|
+
setLoadingTimeout.current = undefined;
|
|
71
|
+
}, 50);
|
|
72
|
+
return "".concat(urlFromProps, "#").concat(urlHash);
|
|
73
|
+
}, [urlFromProps, urlHash]);
|
|
74
|
+
var handleOnLoad = useCallback(function () {
|
|
75
|
+
// if has log line clear setLoading timeout
|
|
76
|
+
if (document.querySelector('.react-lazylog .log-line')) {
|
|
77
|
+
clearTimeout(setLoadingTimeout.current);
|
|
78
|
+
}
|
|
79
|
+
setLoading(false);
|
|
80
|
+
|
|
81
|
+
// scroll to bottom
|
|
82
|
+
setFollowAfterLoaded(true);
|
|
83
|
+
setFollowAfterLoadedTimeout.current = setTimeout(function () {
|
|
84
|
+
return setFollowAfterLoaded(false);
|
|
85
|
+
}, 100);
|
|
86
|
+
onLoad === null || onLoad === void 0 || onLoad();
|
|
87
|
+
}, [onLoad]);
|
|
88
|
+
var handleOnError = useCallback(function (error) {
|
|
89
|
+
setLoading(false);
|
|
90
|
+
clearTimeout(setLoadingTimeout.current);
|
|
91
|
+
onError === null || onError === void 0 || onError(error);
|
|
92
|
+
}, [onError]);
|
|
93
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
94
|
+
className: cx(styles.root, className),
|
|
95
|
+
id: id,
|
|
96
|
+
style: _objectSpread({
|
|
97
|
+
height: height
|
|
98
|
+
}, style),
|
|
99
|
+
children: [/*#__PURE__*/_jsx(ScrollFollow, {
|
|
100
|
+
render: function render(_ref2) {
|
|
101
|
+
var follow = _ref2.follow,
|
|
102
|
+
onFollowScroll = _ref2.onScroll;
|
|
103
|
+
return /*#__PURE__*/_jsx(LazyLog, _objectSpread(_objectSpread({
|
|
104
|
+
url: url,
|
|
105
|
+
websocket: websocket
|
|
106
|
+
}, props), {}, {
|
|
107
|
+
follow: followAfterLoaded || follow,
|
|
108
|
+
height: height,
|
|
109
|
+
iconFilterLines: /*#__PURE__*/_jsx(Icon, {
|
|
110
|
+
className: styles.searchBarIcon,
|
|
111
|
+
icon: TextSearch
|
|
112
|
+
}),
|
|
113
|
+
iconFindNext: /*#__PURE__*/_jsx(Icon, {
|
|
114
|
+
className: styles.searchBarIcon,
|
|
115
|
+
icon: ArrowDown
|
|
116
|
+
}),
|
|
117
|
+
iconFindPrevious: /*#__PURE__*/_jsx(Icon, {
|
|
118
|
+
className: styles.searchBarIcon,
|
|
119
|
+
icon: ArrowUp
|
|
120
|
+
}),
|
|
121
|
+
onError: handleOnError,
|
|
122
|
+
onLoad: handleOnLoad,
|
|
123
|
+
onScroll: function onScroll(args) {
|
|
124
|
+
onFollowScroll(args);
|
|
125
|
+
_onScroll === null || _onScroll === void 0 || _onScroll(args);
|
|
126
|
+
}
|
|
127
|
+
}));
|
|
128
|
+
},
|
|
129
|
+
startFollowing: true
|
|
130
|
+
}), loading && /*#__PURE__*/_jsxs(_Fragment, {
|
|
131
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
132
|
+
className: styles.loaderText,
|
|
133
|
+
children: "loading ..."
|
|
134
|
+
}), /*#__PURE__*/_jsx(Icon, {
|
|
135
|
+
className: styles.loaderIcon,
|
|
136
|
+
icon: LoaderCircle,
|
|
137
|
+
spin: true
|
|
138
|
+
})]
|
|
139
|
+
})]
|
|
140
|
+
});
|
|
141
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
|
|
2
|
+
root: import("antd-style").SerializedStyles;
|
|
3
|
+
searchBarIcon: import("antd-style").SerializedStyles;
|
|
4
|
+
loaderText: import("antd-style").SerializedStyles;
|
|
5
|
+
loaderIcon: import("antd-style").SerializedStyles;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
3
|
+
import { createStyles } from 'antd-style';
|
|
4
|
+
export var useStyles = createStyles(function (_ref) {
|
|
5
|
+
var css = _ref.css,
|
|
6
|
+
token = _ref.token;
|
|
7
|
+
var bgColor = '#222222';
|
|
8
|
+
return {
|
|
9
|
+
root: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n background-color: ", ";\n border-radius: ", "px;\n\n .react-lazylog-searchbar {\n margin-bottom: ", "px;\n padding: ", "px;\n\n background-color: ", ";\n border-bottom: 1px solid #2d2d2d;\n border-top-left-radius: ", "px;\n border-top-right-radius: ", "px;\n & > input {\n border-radius: ", "px;\n }\n & > button {\n cursor: pointer;\n padding: 2px 6px;\n border-radius: ", "px;\n }\n &-up-arrow {\n margin-right: 0;\n }\n }\n .react-lazylog {\n scrollbar-color: rgba(255, 255, 255, 0.2) transparent;\n scrollbar-width: auto;\n background-color: ", ";\n border-radius: ", "px;\n\n .log-number {\n margin-right: 0;\n }\n .log-content {\n margin-left: 15px;\n font-family: ", ";\n }\n }\n "])), bgColor, token.borderRadiusLG, token.marginXXS, token.paddingXS, bgColor, token.borderRadiusLG, token.borderRadiusLG, token.borderRadius, token.borderRadius, bgColor, token.borderRadiusLG, token.fontFamilyCode),
|
|
10
|
+
searchBarIcon: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n font-size: 16px;\n "]))),
|
|
11
|
+
loaderText: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: absolute;\n top: 44px;\n left: 15px;\n\n font-family: ", ";\n font-size: 12px;\n color: #fff;\n "])), token.fontFamilyCode),
|
|
12
|
+
loaderIcon: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n position: absolute;\n right: ", "px;\n bottom: ", "px;\n\n font-size: 18px;\n color: #999;\n "])), token.marginSM, token.marginSM)
|
|
13
|
+
};
|
|
14
|
+
}, {
|
|
15
|
+
hashPriority: 'low'
|
|
16
|
+
});
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface WebsocketOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Callback when the socket is opened
|
|
5
|
+
*/
|
|
6
|
+
onOpen?: ((e: Event, socket: WebSocket) => void) | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Callback when the socket is closed
|
|
9
|
+
*/
|
|
10
|
+
onClose?: ((e: CloseEvent) => void) | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Callback when the socket has an error
|
|
13
|
+
*/
|
|
14
|
+
onError?: ((e: Event) => void) | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Callback allback which formats the websocket data stream.
|
|
17
|
+
*/
|
|
18
|
+
formatMessage?: ((message: any) => string) | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Set to true, to reconnect the WebSocket automatically.
|
|
21
|
+
*/
|
|
22
|
+
reconnect?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Set the time to wait between reconnects in seconds.
|
|
25
|
+
* Default is 1s
|
|
26
|
+
*/
|
|
27
|
+
reconnectWait?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface LineNumberClickEvent {
|
|
30
|
+
lineNumber: number;
|
|
31
|
+
highlightRange?: Immutable.Seq.Indexed<number>;
|
|
32
|
+
}
|
|
33
|
+
export interface LazyLogProps {
|
|
34
|
+
/**
|
|
35
|
+
* Flag to enable/disable case insensitive search
|
|
36
|
+
*/
|
|
37
|
+
caseInsensitive?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Optional custom inline style to attach to element which contains
|
|
40
|
+
* the interior scrolling container.
|
|
41
|
+
*/
|
|
42
|
+
containerStyle?: React.CSSProperties;
|
|
43
|
+
/**
|
|
44
|
+
* If true, capture system hotkeys for searching the page (Cmd-F, Ctrl-F,
|
|
45
|
+
* etc.)
|
|
46
|
+
*/
|
|
47
|
+
enableHotKeys?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Enable the line gutters to be displayed. Default is false
|
|
50
|
+
*/
|
|
51
|
+
enableGutters?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Enable the line numbers to be displayed. Default is true.
|
|
54
|
+
*/
|
|
55
|
+
enableLineNumbers?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Enable hyperlinks to be discovered in log text and made clickable links. Default is false.
|
|
58
|
+
*/
|
|
59
|
+
enableLinks?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Enable the search feature.
|
|
62
|
+
*/
|
|
63
|
+
enableSearch?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* If true, search like a browser search - enter jumps to the next line
|
|
66
|
+
* with the searched term, shift + enter goes backwards.
|
|
67
|
+
* Also adds up and down arrows to search bar to jump
|
|
68
|
+
* to the next and previous result.
|
|
69
|
+
* If false, enter toggles the filter instead.
|
|
70
|
+
* Defaults to true.
|
|
71
|
+
*/
|
|
72
|
+
enableSearchNavigation?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Enable the ability to select multiple lines using shift + click.
|
|
75
|
+
* Defaults to true.
|
|
76
|
+
*/
|
|
77
|
+
enableMultilineHighlight?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Number of extra lines to show at the bottom of the log.
|
|
80
|
+
* Set this to 1 so that Linux users can see the last line
|
|
81
|
+
* of the log output.
|
|
82
|
+
*/
|
|
83
|
+
extraLines?: number;
|
|
84
|
+
/**
|
|
85
|
+
* Options object which will be passed through to the `fetch` request.
|
|
86
|
+
* Defaults to `{ credentials: 'omit' }`.
|
|
87
|
+
*/
|
|
88
|
+
fetchOptions?: RequestInit;
|
|
89
|
+
/**
|
|
90
|
+
* Scroll to the end of the component after each update to the content.
|
|
91
|
+
* Cannot be used in combination with `scrollToLine`.
|
|
92
|
+
*/
|
|
93
|
+
follow?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Execute a function against each string part of a line,
|
|
96
|
+
* returning a new line part. Is passed a single argument which is
|
|
97
|
+
* the string part to manipulate, should return a new string
|
|
98
|
+
* with the manipulation completed.
|
|
99
|
+
*/
|
|
100
|
+
formatPart?: (text: string) => React.ReactNode;
|
|
101
|
+
/**
|
|
102
|
+
* The Line Gutter component
|
|
103
|
+
*/
|
|
104
|
+
gutter?: React.ReactNode[];
|
|
105
|
+
/**
|
|
106
|
+
* Set the height in pixels for the component.
|
|
107
|
+
* Defaults to `'auto'` if unspecified. When the `height` is `'auto'`,
|
|
108
|
+
* the component will expand vertically to fill its container.
|
|
109
|
+
*/
|
|
110
|
+
height?: string | number;
|
|
111
|
+
/**
|
|
112
|
+
* Line number (e.g. `highlight={10}`) or line number range to highlight
|
|
113
|
+
* inclusively (e.g. `highlight={[5, 10]}` highlights lines 5-10).
|
|
114
|
+
* This is 1-indexed, i.e. line numbers start at `1`.
|
|
115
|
+
*/
|
|
116
|
+
highlight?: number | number[];
|
|
117
|
+
/**
|
|
118
|
+
* Specify an additional className to append to highlighted lines.
|
|
119
|
+
*/
|
|
120
|
+
highlightLineClassName?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Icon for the Filter Lines button in the Search Bar. Defaults to FilterLineIcon SVG.
|
|
123
|
+
*/
|
|
124
|
+
iconFilterLines?: React.ReactNode;
|
|
125
|
+
/**
|
|
126
|
+
* Icon for the Find Next button in the Search Bar. Defaults to ArrowDownIcon SVG.
|
|
127
|
+
*/
|
|
128
|
+
iconFindNext?: React.ReactNode;
|
|
129
|
+
/**
|
|
130
|
+
* Icon for the Find Previous button in the Search Bar. Defaults to ArrowUpIcon SVG.
|
|
131
|
+
*/
|
|
132
|
+
iconFindPrevious?: React.ReactNode;
|
|
133
|
+
/**
|
|
134
|
+
* Specify an additional className to append to lines.
|
|
135
|
+
*/
|
|
136
|
+
lineClassName?: string;
|
|
137
|
+
/**
|
|
138
|
+
* Specify an alternate component to use when loading.
|
|
139
|
+
*/
|
|
140
|
+
loadingComponent?: React.ReactNode | ((props: any) => React.ReactNode);
|
|
141
|
+
/**
|
|
142
|
+
* Execute a function if the provided `url` has encountered an error
|
|
143
|
+
* during loading.
|
|
144
|
+
*/
|
|
145
|
+
onError?: (error: any) => any;
|
|
146
|
+
/**
|
|
147
|
+
* Execute a function when the highlighted range has changed.
|
|
148
|
+
* Is passed a single argument which is an `Immutable.Range`
|
|
149
|
+
* of the highlighted line numbers.
|
|
150
|
+
*/
|
|
151
|
+
onHighlight?: (range: Immutable.Seq.Indexed<number>) => any;
|
|
152
|
+
/**
|
|
153
|
+
* Execute a function if/when the provided `url` has completed loading.
|
|
154
|
+
*/
|
|
155
|
+
onLoad?: () => any;
|
|
156
|
+
/**
|
|
157
|
+
* Additional function called when a line number is clicked.
|
|
158
|
+
* On click, the line will always be highlighted.
|
|
159
|
+
* This function is to provide additional actions.
|
|
160
|
+
* Receives an object with lineNumber and highlightRange.
|
|
161
|
+
* Defaults to null.
|
|
162
|
+
*/
|
|
163
|
+
onLineNumberClick?: (event: LineNumberClickEvent) => any;
|
|
164
|
+
/**
|
|
165
|
+
* Callback to invoke on click of line contents.
|
|
166
|
+
* @param {React.MouseEvent<HTMLElement>} event - Browser event.
|
|
167
|
+
*/
|
|
168
|
+
onLineContentClick?(event: React.MouseEvent<HTMLSpanElement>): void;
|
|
169
|
+
/**
|
|
170
|
+
* Callback to invoke on user scroll. Args matches the ScrollFollow onScroll callback.
|
|
171
|
+
* @param args
|
|
172
|
+
*/
|
|
173
|
+
onScroll?(args: {
|
|
174
|
+
scrollTop: number;
|
|
175
|
+
scrollHeight: number;
|
|
176
|
+
clientHeight: number;
|
|
177
|
+
}): void;
|
|
178
|
+
/**
|
|
179
|
+
* Number of rows to render above/below the visible bounds of the list.
|
|
180
|
+
* This can help reduce flickering during scrolling on
|
|
181
|
+
* certain browsers/devices. Defaults to `100`.
|
|
182
|
+
*/
|
|
183
|
+
overscanRowCount?: number;
|
|
184
|
+
/**
|
|
185
|
+
* A fixed row height in pixels. Controls how tall a line is,
|
|
186
|
+
* as well as the `lineHeight` style of the line's text.
|
|
187
|
+
* Defaults to `19`.
|
|
188
|
+
*/
|
|
189
|
+
rowHeight?: number;
|
|
190
|
+
/**
|
|
191
|
+
* Scroll to a particular line number once it has loaded.
|
|
192
|
+
* This is 1-indexed, i.e. line numbers start at `1`.
|
|
193
|
+
* Cannot be used in combination with `follow`.
|
|
194
|
+
*/
|
|
195
|
+
scrollToLine?: number;
|
|
196
|
+
/**
|
|
197
|
+
* Make the text selectable, allowing to copy & paste. Defaults to `false`.
|
|
198
|
+
*/
|
|
199
|
+
selectableLines?: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* Set to `true` to specify remote URL will be streaming chunked data.
|
|
202
|
+
* Defaults to `false` to download data until completion.
|
|
203
|
+
*/
|
|
204
|
+
stream?: boolean;
|
|
205
|
+
/**
|
|
206
|
+
* Optional custom inline style to attach to root
|
|
207
|
+
* virtual `LazyList` element.
|
|
208
|
+
*/
|
|
209
|
+
style?: React.CSSProperties;
|
|
210
|
+
/**
|
|
211
|
+
* String containing text to display.
|
|
212
|
+
*/
|
|
213
|
+
text?: string;
|
|
214
|
+
/**
|
|
215
|
+
* The URL from which to fetch content. Subject to same-origin policy,
|
|
216
|
+
* so must be accessible via fetch on same domain or via CORS.
|
|
217
|
+
*/
|
|
218
|
+
url?: string;
|
|
219
|
+
/**
|
|
220
|
+
* Set to `true` to specify that url is a websocket URL.
|
|
221
|
+
* Defaults to `false` to download data until completion.
|
|
222
|
+
*/
|
|
223
|
+
websocket?: boolean;
|
|
224
|
+
/**
|
|
225
|
+
* Options object which will be passed through to websocket.
|
|
226
|
+
*/
|
|
227
|
+
websocketOptions?: WebsocketOptions;
|
|
228
|
+
/**
|
|
229
|
+
* Set the width in pixels for the component.
|
|
230
|
+
* Defaults to `'auto'` if unspecified.
|
|
231
|
+
* When the `width` is `'auto'`, the component will expand
|
|
232
|
+
* horizontally to fill its container.
|
|
233
|
+
*/
|
|
234
|
+
width?: string | number;
|
|
235
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const DEFAULT_PUNCTUATION = "\\.,\\*\\?\\$\\|#{}\\(\\)\\^\\[\\]\\\\/!%'\"~=<>_:;";
|
|
2
|
+
export declare const PRE_TRIGGER_CHARS = "\\(";
|
|
3
|
+
export declare const TRIGGERS: (triggers: string[]) => string;
|
|
4
|
+
export declare const VALID_CHARS: (triggers: string[], punctuation: string) => string;
|
|
5
|
+
export declare const VALID_JOINS: (punctuation: string) => string;
|
|
6
|
+
export declare const LENGTH_LIMIT = 75;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export var DEFAULT_PUNCTUATION = '\\.,\\*\\?\\$\\|#{}\\(\\)\\^\\[\\]\\\\/!%\'"~=<>_:;';
|
|
2
|
+
|
|
3
|
+
// Makes it possible to use brackets before the trigger: (@mention)
|
|
4
|
+
export var PRE_TRIGGER_CHARS = '\\(';
|
|
5
|
+
|
|
6
|
+
// Strings that can trigger the mention menu.
|
|
7
|
+
export var TRIGGERS = function TRIGGERS(triggers) {
|
|
8
|
+
return '(?:' + triggers.join('|') + ')';
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// Chars we expect to see in a mention (non-space, non-punctuation).
|
|
12
|
+
export var VALID_CHARS = function VALID_CHARS(triggers, punctuation) {
|
|
13
|
+
var lookahead = triggers.length === 0 ? '' : '(?!' + triggers.join('|') + ')';
|
|
14
|
+
return lookahead + '[^\\s' + punctuation + ']';
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// Non-standard series of chars. Each series must be preceded and followed by
|
|
18
|
+
// a valid char.
|
|
19
|
+
export var VALID_JOINS = function VALID_JOINS(punctuation) {
|
|
20
|
+
return '(?:' + '\\.[ |$]|' +
|
|
21
|
+
// E.g. "r. " in "Mr. Smith"
|
|
22
|
+
'\\s|' +
|
|
23
|
+
// E.g. " " in "Josh Duck"
|
|
24
|
+
'[' + punctuation + ']|' +
|
|
25
|
+
// E.g. "-' in "Salier-Hellendag"
|
|
26
|
+
')';
|
|
27
|
+
};
|
|
28
|
+
export var LENGTH_LIMIT = 75;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { MenuTextMatch } from '@lexical/react/LexicalTypeaheadMenuPlugin';
|
|
2
|
+
import type { LexicalCommand } from 'lexical';
|
|
3
|
+
import type { Dispatch, RefObject, SetStateAction } from 'react';
|
|
4
|
+
export type UseSelectOrDeleteHanlder = (nodeKey: string, command: LexicalCommand<undefined>) => [RefObject<HTMLDivElement>, boolean];
|
|
5
|
+
export declare const useSelectOrDelete: UseSelectOrDeleteHanlder;
|
|
6
|
+
export type UseTriggerHandler = () => [
|
|
7
|
+
RefObject<HTMLDivElement>,
|
|
8
|
+
boolean,
|
|
9
|
+
Dispatch<SetStateAction<boolean>>
|
|
10
|
+
];
|
|
11
|
+
export declare const useTrigger: UseTriggerHandler;
|
|
12
|
+
export declare function checkForMentions(text: string, triggers: string[], preTriggerChars: string, punctuation: string, allowSpaces: boolean): MenuTextMatch | null;
|
|
13
|
+
export declare const useCheckForMentionMatch: (triggers: string[], { punctuation, preTriggerChars, allowSpaces, }: {
|
|
14
|
+
punctuation: string;
|
|
15
|
+
preTriggerChars: string;
|
|
16
|
+
allowSpaces: boolean;
|
|
17
|
+
}) => {
|
|
18
|
+
trigger: string | null;
|
|
19
|
+
checkForMentionMatch: (text: string) => MenuTextMatch | null;
|
|
20
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
/* eslint-disable unicorn/no-useless-undefined */
|
|
3
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
4
|
+
import { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection';
|
|
5
|
+
import { mergeRegister } from '@lexical/utils';
|
|
6
|
+
import { $getNodeByKey, $getSelection, $isDecoratorNode, $isNodeSelection, COMMAND_PRIORITY_LOW, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND } from 'lexical';
|
|
7
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
8
|
+
import { LENGTH_LIMIT, TRIGGERS, VALID_CHARS, VALID_JOINS } from "./constants";
|
|
9
|
+
export var useSelectOrDelete = function useSelectOrDelete(nodeKey, command) {
|
|
10
|
+
var ref = useRef(null);
|
|
11
|
+
var _useLexicalComposerCo = useLexicalComposerContext(),
|
|
12
|
+
_useLexicalComposerCo2 = _slicedToArray(_useLexicalComposerCo, 1),
|
|
13
|
+
editor = _useLexicalComposerCo2[0];
|
|
14
|
+
var _useLexicalNodeSelect = useLexicalNodeSelection(nodeKey),
|
|
15
|
+
_useLexicalNodeSelect2 = _slicedToArray(_useLexicalNodeSelect, 3),
|
|
16
|
+
isSelected = _useLexicalNodeSelect2[0],
|
|
17
|
+
setSelected = _useLexicalNodeSelect2[1],
|
|
18
|
+
clearSelection = _useLexicalNodeSelect2[2];
|
|
19
|
+
var handleDelete = useCallback(function (event) {
|
|
20
|
+
var selection = $getSelection();
|
|
21
|
+
var nodes = selection === null || selection === void 0 ? void 0 : selection.getNodes();
|
|
22
|
+
if (!isSelected && (nodes === null || nodes === void 0 ? void 0 : nodes.length) === 1) {
|
|
23
|
+
editor.dispatchCommand(command, undefined);
|
|
24
|
+
}
|
|
25
|
+
if (isSelected && $isNodeSelection(selection)) {
|
|
26
|
+
event.preventDefault();
|
|
27
|
+
var node = $getNodeByKey(nodeKey);
|
|
28
|
+
if ($isDecoratorNode(node)) {
|
|
29
|
+
if (command) {
|
|
30
|
+
editor.dispatchCommand(command, undefined);
|
|
31
|
+
}
|
|
32
|
+
node.remove();
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}, [isSelected, nodeKey, command, editor]);
|
|
38
|
+
var handleSelect = useCallback(function (e) {
|
|
39
|
+
e.stopPropagation();
|
|
40
|
+
clearSelection();
|
|
41
|
+
setSelected(true);
|
|
42
|
+
}, [setSelected, clearSelection]);
|
|
43
|
+
useEffect(function () {
|
|
44
|
+
var ele = ref.current;
|
|
45
|
+
if (ele) ele.addEventListener('click', handleSelect);
|
|
46
|
+
return function () {
|
|
47
|
+
if (ele) ele.removeEventListener('click', handleSelect);
|
|
48
|
+
};
|
|
49
|
+
}, [handleSelect]);
|
|
50
|
+
useEffect(function () {
|
|
51
|
+
return mergeRegister(editor.registerCommand(KEY_DELETE_COMMAND, handleDelete, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_BACKSPACE_COMMAND, handleDelete, COMMAND_PRIORITY_LOW));
|
|
52
|
+
}, [editor, clearSelection, handleDelete]);
|
|
53
|
+
return [ref, isSelected];
|
|
54
|
+
};
|
|
55
|
+
export var useTrigger = function useTrigger() {
|
|
56
|
+
var triggerRef = useRef(null);
|
|
57
|
+
var _useState = useState(false),
|
|
58
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
59
|
+
open = _useState2[0],
|
|
60
|
+
setOpen = _useState2[1];
|
|
61
|
+
var handleOpen = useCallback(function (e) {
|
|
62
|
+
e.stopPropagation();
|
|
63
|
+
setOpen(function (v) {
|
|
64
|
+
return !v;
|
|
65
|
+
});
|
|
66
|
+
}, []);
|
|
67
|
+
useEffect(function () {
|
|
68
|
+
var trigger = triggerRef.current;
|
|
69
|
+
if (trigger) trigger.addEventListener('click', handleOpen);
|
|
70
|
+
return function () {
|
|
71
|
+
if (trigger) trigger.removeEventListener('click', handleOpen);
|
|
72
|
+
};
|
|
73
|
+
}, [handleOpen]);
|
|
74
|
+
return [triggerRef, open, setOpen];
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// Regex used to trigger the mention menu.
|
|
78
|
+
function createMentionsRegex(triggers, preTriggerChars, punctuation, allowSpaces) {
|
|
79
|
+
return new RegExp((preTriggerChars ? "(^|\\s|".concat(preTriggerChars, ")(") : '(^|\\s)(') + TRIGGERS(triggers) + '((?:' + VALID_CHARS(triggers, punctuation) + (allowSpaces ? VALID_JOINS(punctuation) : '') + '){0,' + LENGTH_LIMIT + '})' + ')$');
|
|
80
|
+
}
|
|
81
|
+
export function checkForMentions(text, triggers, preTriggerChars, punctuation, allowSpaces) {
|
|
82
|
+
var match = createMentionsRegex(triggers, preTriggerChars, punctuation, allowSpaces).exec(text);
|
|
83
|
+
if (match !== null) {
|
|
84
|
+
// The strategy ignores leading whitespace, but we need to know its
|
|
85
|
+
// length to add it to the leadOffset
|
|
86
|
+
var maybeLeadingWhitespace = match[1];
|
|
87
|
+
var matchingStringWithTrigger = match[2];
|
|
88
|
+
var matchingString = match[3];
|
|
89
|
+
if (matchingStringWithTrigger.length > 0) {
|
|
90
|
+
return {
|
|
91
|
+
leadOffset: match.index + maybeLeadingWhitespace.length,
|
|
92
|
+
matchingString: matchingString,
|
|
93
|
+
replaceableString: matchingStringWithTrigger
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
export var useCheckForMentionMatch = function useCheckForMentionMatch(triggers, _ref) {
|
|
100
|
+
var punctuation = _ref.punctuation,
|
|
101
|
+
preTriggerChars = _ref.preTriggerChars,
|
|
102
|
+
allowSpaces = _ref.allowSpaces;
|
|
103
|
+
var _useState3 = useState(null),
|
|
104
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
105
|
+
trigger = _useState4[0],
|
|
106
|
+
setTrigger = _useState4[1];
|
|
107
|
+
var checkForMentionMatch = useCallback(function (text) {
|
|
108
|
+
// Don't show the menu if the next character is a word character
|
|
109
|
+
// const selectionInfo = $getSelectionInfo(triggers, punctuation);
|
|
110
|
+
// if (selectionInfo?.isTextNode && selectionInfo.wordCharAfterCursor) {
|
|
111
|
+
// return null;
|
|
112
|
+
// }
|
|
113
|
+
|
|
114
|
+
var queryMatch = checkForMentions(text, triggers, preTriggerChars, punctuation, allowSpaces);
|
|
115
|
+
if (queryMatch) {
|
|
116
|
+
var replaceableString = queryMatch.replaceableString,
|
|
117
|
+
matchingString = queryMatch.matchingString;
|
|
118
|
+
var index = replaceableString.lastIndexOf(matchingString);
|
|
119
|
+
var _trigger = index === -1 ? replaceableString : replaceableString.slice(0, Math.max(0, index)) + replaceableString.slice(Math.max(0, index + matchingString.length));
|
|
120
|
+
setTrigger(_trigger || null);
|
|
121
|
+
if (queryMatch.replaceableString) {
|
|
122
|
+
return queryMatch;
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
setTrigger(null);
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
128
|
+
}, [preTriggerChars, allowSpaces, punctuation, triggers]);
|
|
129
|
+
return {
|
|
130
|
+
trigger: trigger,
|
|
131
|
+
checkForMentionMatch: checkForMentionMatch
|
|
132
|
+
};
|
|
133
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type MentionPickerPluginProps } from './plugins/mention-picker';
|
|
3
|
+
import type { AutoSize } from './types';
|
|
4
|
+
export interface MentionsProps extends MentionPickerPluginProps {
|
|
5
|
+
className?: string;
|
|
6
|
+
wrapperClassname?: string;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
value?: string;
|
|
10
|
+
defaultValue?: string;
|
|
11
|
+
readOnly?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
onChange?: (text: string) => void;
|
|
14
|
+
onBlur?: () => void;
|
|
15
|
+
onFocus?: () => void;
|
|
16
|
+
variant?: 'outlined' | 'filled' | 'borderless';
|
|
17
|
+
autoSize?: AutoSize;
|
|
18
|
+
}
|
|
19
|
+
export declare const Mentions: React.FC<MentionsProps>;
|