@yuntijs/ui 1.0.0-beta.86 → 1.0.0-beta.88
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/ChatItem/components/Actions.d.ts +10 -0
- package/es/ChatItem/components/Actions.js +23 -0
- package/es/ChatItem/index.js +1 -1
- package/es/Mentions/index.js +12 -5
- package/es/Mentions/plugins/OnBlurBlockPlugin.d.ts +7 -0
- package/es/Mentions/plugins/{on-blur-or-focus-block.js → OnBlurBlockPlugin.js} +2 -3
- package/es/Mentions/plugins/editable.d.ts +4 -0
- package/es/Mentions/plugins/editable.js +13 -0
- package/package.json +1 -1
- package/umd/index.min.js +1 -1
- package/umd/index.min.js.map +1 -1
- package/es/Mentions/plugins/on-blur-or-focus-block.d.ts +0 -7
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ChatItemProps } from '../type';
|
|
3
|
+
export interface ActionsProps {
|
|
4
|
+
actions: ChatItemProps['actions'];
|
|
5
|
+
editing?: boolean;
|
|
6
|
+
placement?: ChatItemProps['placement'];
|
|
7
|
+
type?: ChatItemProps['type'];
|
|
8
|
+
}
|
|
9
|
+
declare const Actions: import("react").NamedExoticComponent<ActionsProps>;
|
|
10
|
+
export default Actions;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { Flexbox } from 'react-layout-kit';
|
|
3
|
+
import { useStyles } from "../style";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
var Actions = /*#__PURE__*/memo(function (_ref) {
|
|
6
|
+
var actions = _ref.actions,
|
|
7
|
+
placement = _ref.placement,
|
|
8
|
+
type = _ref.type,
|
|
9
|
+
editing = _ref.editing;
|
|
10
|
+
var _useStyles = useStyles({
|
|
11
|
+
editing: editing,
|
|
12
|
+
placement: placement,
|
|
13
|
+
type: type
|
|
14
|
+
}),
|
|
15
|
+
styles = _useStyles.styles;
|
|
16
|
+
return /*#__PURE__*/_jsx(Flexbox, {
|
|
17
|
+
align: 'flex-start',
|
|
18
|
+
className: styles.actions,
|
|
19
|
+
role: "menubar",
|
|
20
|
+
children: actions
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
export default Actions;
|
package/es/ChatItem/index.js
CHANGED
|
@@ -5,7 +5,6 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
|
|
|
5
5
|
var _excluded = ["avatarAddon", "onAvatarClick", "avatarProps", "actions", "className", "primary", "loading", "message", "placement", "type", "avatar", "error", "showTitle", "time", "editing", "onChange", "onEditingChange", "messageExtra", "renderMessage", "text", "errorMessage", "onDoubleClick", "fontSize", "markdownProps", "markdownClassname", "isLatest"];
|
|
6
6
|
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; }
|
|
7
7
|
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; }
|
|
8
|
-
import Actions from '@lobehub/ui/es/chat/ChatItem/components/Actions';
|
|
9
8
|
import Avatar from '@lobehub/ui/es/chat/ChatItem/components/Avatar';
|
|
10
9
|
import BorderSpacing from '@lobehub/ui/es/chat/ChatItem/components/BorderSpacing';
|
|
11
10
|
import ErrorContent from '@lobehub/ui/es/chat/ChatItem/components/ErrorContent';
|
|
@@ -13,6 +12,7 @@ import Title from '@lobehub/ui/es/chat/ChatItem/components/Title';
|
|
|
13
12
|
import { useResponsive } from 'antd-style';
|
|
14
13
|
import { memo } from 'react';
|
|
15
14
|
import { Flexbox } from 'react-layout-kit';
|
|
15
|
+
import Actions from "./components/Actions";
|
|
16
16
|
import MessageContent from "./components/MessageContent";
|
|
17
17
|
import { useStyles } from "./style";
|
|
18
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
package/es/Mentions/index.js
CHANGED
|
@@ -11,10 +11,11 @@ import { ConfigProvider } from 'antd';
|
|
|
11
11
|
import { $getRoot, TextNode } from 'lexical';
|
|
12
12
|
import React, { useMemo } from 'react';
|
|
13
13
|
import { isBrowser } from "../utils/tools";
|
|
14
|
+
import { OnBlurBlockPlugin } from "./plugins/OnBlurBlockPlugin";
|
|
14
15
|
import { CustomTextNode } from "./plugins/custom-text/node";
|
|
16
|
+
import { EditablePlugin } from "./plugins/editable";
|
|
15
17
|
import { MentionNode, MentionNodePlugin, MentionNodePluginReplacement } from "./plugins/mention-node";
|
|
16
18
|
import { MentionPickerPlugin } from "./plugins/mention-picker";
|
|
17
|
-
import OnBlurBlock from "./plugins/on-blur-or-focus-block";
|
|
18
19
|
import { MentionsConfigProvider } from "./provider";
|
|
19
20
|
import { useStyles } from "./style";
|
|
20
21
|
import { textToEditorState } from "./utils";
|
|
@@ -51,8 +52,12 @@ export var Mentions = function Mentions(_ref) {
|
|
|
51
52
|
}),
|
|
52
53
|
styles = _useStyles.styles,
|
|
53
54
|
cx = _useStyles.cx;
|
|
54
|
-
var disabled =
|
|
55
|
-
|
|
55
|
+
var disabled = useMemo(function () {
|
|
56
|
+
return customDisabled !== null && customDisabled !== void 0 ? customDisabled : componentDisabled;
|
|
57
|
+
}, [componentDisabled, customDisabled]);
|
|
58
|
+
var editable = useMemo(function () {
|
|
59
|
+
return !readOnly && !disabled;
|
|
60
|
+
}, [disabled, readOnly]);
|
|
56
61
|
var initialConfig = useMemo(function () {
|
|
57
62
|
return {
|
|
58
63
|
namespace: 'mentions',
|
|
@@ -130,7 +135,7 @@ export var Mentions = function Mentions(_ref) {
|
|
|
130
135
|
className: styles.placeholder,
|
|
131
136
|
children: placeholder || "\u8F93\u5165 ".concat(triggers.join(' 或 '), " \u63D2\u5165\u5F15\u7528")
|
|
132
137
|
})
|
|
133
|
-
}), /*#__PURE__*/_jsx(MentionPickerPlugin, {
|
|
138
|
+
}), editable && /*#__PURE__*/_jsx(MentionPickerPlugin, {
|
|
134
139
|
allowSpaces: allowSpaces,
|
|
135
140
|
onSelect: onSelect,
|
|
136
141
|
options: options,
|
|
@@ -140,9 +145,11 @@ export var Mentions = function Mentions(_ref) {
|
|
|
140
145
|
triggers: triggers
|
|
141
146
|
}), /*#__PURE__*/_jsx(MentionNodePlugin, {}), /*#__PURE__*/_jsx(MentionNodePluginReplacement, {}), /*#__PURE__*/_jsx(HistoryPlugin, {}), /*#__PURE__*/_jsx(OnChangePlugin, {
|
|
142
147
|
onChange: handleEditorChange
|
|
143
|
-
}), /*#__PURE__*/_jsx(
|
|
148
|
+
}), /*#__PURE__*/_jsx(OnBlurBlockPlugin, {
|
|
144
149
|
onBlur: onBlur,
|
|
145
150
|
onFocus: onFocus
|
|
151
|
+
}), /*#__PURE__*/_jsx(EditablePlugin, {
|
|
152
|
+
editable: editable
|
|
146
153
|
})]
|
|
147
154
|
})
|
|
148
155
|
})
|
|
@@ -4,7 +4,7 @@ import { mergeRegister } from '@lexical/utils';
|
|
|
4
4
|
import { BLUR_COMMAND, COMMAND_PRIORITY_EDITOR, FOCUS_COMMAND, KEY_ESCAPE_COMMAND } from 'lexical';
|
|
5
5
|
import { useEffect, useRef } from 'react';
|
|
6
6
|
import { CLEAR_HIDE_MENU_TIMEOUT } from "./mention-node";
|
|
7
|
-
var
|
|
7
|
+
export var OnBlurBlockPlugin = function OnBlurBlockPlugin(_ref) {
|
|
8
8
|
var onBlur = _ref.onBlur,
|
|
9
9
|
onFocus = _ref.onFocus;
|
|
10
10
|
var _useLexicalComposerCo = useLexicalComposerContext(),
|
|
@@ -32,5 +32,4 @@ var OnBlurBlock = function OnBlurBlock(_ref) {
|
|
|
32
32
|
}, COMMAND_PRIORITY_EDITOR));
|
|
33
33
|
}, [editor, onBlur, onFocus]);
|
|
34
34
|
return null;
|
|
35
|
-
};
|
|
36
|
-
export default OnBlurBlock;
|
|
35
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
export var EditablePlugin = function EditablePlugin(_ref) {
|
|
5
|
+
var editable = _ref.editable;
|
|
6
|
+
var _useLexicalComposerCo = useLexicalComposerContext(),
|
|
7
|
+
_useLexicalComposerCo2 = _slicedToArray(_useLexicalComposerCo, 1),
|
|
8
|
+
editor = _useLexicalComposerCo2[0];
|
|
9
|
+
useEffect(function () {
|
|
10
|
+
editor.setEditable(editable);
|
|
11
|
+
}, [editable, editor]);
|
|
12
|
+
return null;
|
|
13
|
+
};
|