@yuntijs/ui 1.1.0-beta.14 → 1.1.0-beta.16
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/Mentions/index.d.ts +5 -0
- package/es/Mentions/index.js +9 -2
- package/es/Mentions/plugins/mention-picker/index.d.ts +2 -1
- package/es/Mentions/plugins/mention-picker/index.js +2 -0
- package/es/Mentions/plugins/shift-enter-key.js +14 -3
- package/package.json +1 -1
- package/umd/index.min.js +1 -1
- package/umd/index.min.js.map +1 -1
package/es/Mentions/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { type MentionPickerPluginProps } from './plugins/mention-picker';
|
|
|
3
3
|
import { AutoSize, MentionsEditor } from './types';
|
|
4
4
|
export * from './types';
|
|
5
5
|
export * from './utils';
|
|
6
|
+
export { CLEAR_EDITOR_COMMAND } from 'lexical';
|
|
6
7
|
export interface MentionsProps extends MentionPickerPluginProps {
|
|
7
8
|
className?: string;
|
|
8
9
|
classNames?: {
|
|
@@ -25,6 +26,10 @@ export interface MentionsProps extends MentionPickerPluginProps {
|
|
|
25
26
|
onPressEnter?: (value: string, { event }: {
|
|
26
27
|
event: KeyboardEvent | null;
|
|
27
28
|
}) => void;
|
|
29
|
+
/**
|
|
30
|
+
* 用户输入 trigger 后的回调
|
|
31
|
+
*/
|
|
32
|
+
onTrigger?: (trigger: string) => void;
|
|
28
33
|
variant?: 'outlined' | 'filled' | 'borderless';
|
|
29
34
|
autoSize?: AutoSize;
|
|
30
35
|
code?: boolean;
|
package/es/Mentions/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
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; }
|
|
3
3
|
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; }
|
|
4
|
+
import { ClearEditorPlugin } from '@lexical/react/LexicalClearEditorPlugin';
|
|
4
5
|
import { LexicalComposer } from '@lexical/react/LexicalComposer';
|
|
5
6
|
import { ContentEditable } from '@lexical/react/LexicalContentEditable';
|
|
6
7
|
import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
|
|
@@ -26,6 +27,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
26
27
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
27
28
|
export * from "./types";
|
|
28
29
|
export * from "./utils";
|
|
30
|
+
export { CLEAR_EDITOR_COMMAND } from 'lexical';
|
|
29
31
|
export var Mentions = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
30
32
|
var className = _ref.className,
|
|
31
33
|
classNames = _ref.classNames,
|
|
@@ -53,7 +55,8 @@ export var Mentions = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
53
55
|
_ref$code = _ref.code,
|
|
54
56
|
code = _ref$code === void 0 ? false : _ref$code,
|
|
55
57
|
getPopContainer = _ref.getPopContainer,
|
|
56
|
-
onPressEnter = _ref.onPressEnter
|
|
58
|
+
onPressEnter = _ref.onPressEnter,
|
|
59
|
+
onTrigger = _ref.onTrigger;
|
|
57
60
|
var _ConfigProvider$useCo = ConfigProvider.useConfig(),
|
|
58
61
|
componentDisabled = _ConfigProvider$useCo.componentDisabled;
|
|
59
62
|
var _useStyles = useStyles({
|
|
@@ -146,6 +149,10 @@ export var Mentions = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
146
149
|
})
|
|
147
150
|
}), editable && /*#__PURE__*/_jsx(MentionPickerPlugin, {
|
|
148
151
|
allowSpaces: allowSpaces,
|
|
152
|
+
onOpen: function onOpen(resolution) {
|
|
153
|
+
var _resolution$match$rep, _resolution$match;
|
|
154
|
+
return onTrigger === null || onTrigger === void 0 ? void 0 : onTrigger((_resolution$match$rep = (_resolution$match = resolution.match) === null || _resolution$match === void 0 ? void 0 : _resolution$match.replaceableString) !== null && _resolution$match$rep !== void 0 ? _resolution$match$rep : triggers[0]);
|
|
155
|
+
},
|
|
149
156
|
onSelect: onSelect,
|
|
150
157
|
options: options,
|
|
151
158
|
overlayClassName: classNames === null || classNames === void 0 ? void 0 : classNames.menuOverlay,
|
|
@@ -162,7 +169,7 @@ export var Mentions = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
162
169
|
editable: editable
|
|
163
170
|
}), /*#__PURE__*/_jsx(EditorRefPlugin, {
|
|
164
171
|
editorRef: ref
|
|
165
|
-
}), onPressEnter && /*#__PURE__*/_jsx(ShiftEnterKeyPlugin, {
|
|
172
|
+
}), /*#__PURE__*/_jsx(ClearEditorPlugin, {}), onPressEnter && /*#__PURE__*/_jsx(ShiftEnterKeyPlugin, {
|
|
166
173
|
onPressEnter: onPressEnter
|
|
167
174
|
})]
|
|
168
175
|
})
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { MenuOption, TypeaheadMenuPluginProps } from '@lexical/react/LexicalTypeaheadMenuPlugin';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import type { MentionOption } from '../../types';
|
|
3
4
|
import { type MentionMenuOption } from './utils';
|
|
4
|
-
export interface MentionPickerPluginProps {
|
|
5
|
+
export interface MentionPickerPluginProps extends Pick<TypeaheadMenuPluginProps<MenuOption>, 'onOpen'> {
|
|
5
6
|
/** The className of menu overlay */
|
|
6
7
|
overlayClassName?: string;
|
|
7
8
|
/** The options of menu */
|
|
@@ -27,6 +27,7 @@ export var MentionPickerPlugin = /*#__PURE__*/memo(function (_ref) {
|
|
|
27
27
|
_ref$preTriggerChars = _ref.preTriggerChars,
|
|
28
28
|
preTriggerChars = _ref$preTriggerChars === void 0 ? PRE_TRIGGER_CHARS : _ref$preTriggerChars,
|
|
29
29
|
onSelect = _ref.onSelect,
|
|
30
|
+
onOpen = _ref.onOpen,
|
|
30
31
|
parent = _ref.parent;
|
|
31
32
|
var _useStyles = useStyles({}),
|
|
32
33
|
cx = _useStyles.cx,
|
|
@@ -169,6 +170,7 @@ export var MentionPickerPlugin = /*#__PURE__*/memo(function (_ref) {
|
|
|
169
170
|
,
|
|
170
171
|
commandPriority: COMMAND_PRIORITY_NORMAL,
|
|
171
172
|
menuRenderFn: renderMenu,
|
|
173
|
+
onOpen: onOpen,
|
|
172
174
|
onQueryChange: setQueryString,
|
|
173
175
|
onSelectOption: onSelectOption,
|
|
174
176
|
options: flatOptions,
|
|
@@ -36,9 +36,20 @@ export var ShiftEnterKeyPlugin = function ShiftEnterKeyPlugin(_ref) {
|
|
|
36
36
|
return $getRoot().getTextContent();
|
|
37
37
|
});
|
|
38
38
|
var value = text.replaceAll('\n\n', '\n');
|
|
39
|
-
onPressEnter
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
// 这里把 onPressEnter 放在下一次事件循环中触发,是为了避免跟 Lexical 还未结束的输入等事务发生冲突
|
|
40
|
+
if (window.queueMicrotask === undefined) {
|
|
41
|
+
setTimeout(function () {
|
|
42
|
+
onPressEnter(value, {
|
|
43
|
+
event: event
|
|
44
|
+
});
|
|
45
|
+
}, 0);
|
|
46
|
+
} else {
|
|
47
|
+
queueMicrotask(function () {
|
|
48
|
+
onPressEnter(value, {
|
|
49
|
+
event: event
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
42
53
|
return true;
|
|
43
54
|
},
|
|
44
55
|
// 优先级要低于 MentionPickerPlugin
|