@yuntijs/ui 1.2.0-beta.2 → 1.2.0

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.
@@ -2,16 +2,12 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
3
3
  import { CAN_USE_BEFORE_INPUT, IS_APPLE_WEBKIT, IS_IOS, IS_SAFARI } from '@lexical/utils';
4
4
  import { $getRoot, $getSelection, $isRangeSelection, COMMAND_PRIORITY_LOW, INSERT_PARAGRAPH_COMMAND, KEY_ENTER_COMMAND } from 'lexical';
5
- import { useEffect, useRef } from 'react';
5
+ import { useEffect } from 'react';
6
6
  export var ShiftEnterKeyPlugin = function ShiftEnterKeyPlugin(_ref) {
7
7
  var onPressEnter = _ref.onPressEnter;
8
8
  var _useLexicalComposerCo = useLexicalComposerContext(),
9
9
  _useLexicalComposerCo2 = _slicedToArray(_useLexicalComposerCo, 1),
10
10
  editor = _useLexicalComposerCo2[0];
11
- var onPressEnterRef = useRef(onPressEnter);
12
- useEffect(function () {
13
- onPressEnterRef.current = onPressEnter;
14
- }, [onPressEnter]);
15
11
  useEffect(function () {
16
12
  // https://github.com/facebook/lexical/discussions/4464#discussioncomment-5833227
17
13
  editor.registerCommand(KEY_ENTER_COMMAND, function (event) {
@@ -43,13 +39,13 @@ export var ShiftEnterKeyPlugin = function ShiftEnterKeyPlugin(_ref) {
43
39
  // 这里把 onPressEnter 放在下一次事件循环中触发,是为了避免跟 Lexical 还未结束的输入等事务发生冲突
44
40
  if (window.queueMicrotask === undefined) {
45
41
  setTimeout(function () {
46
- onPressEnterRef.current(value, {
42
+ onPressEnter(value, {
47
43
  event: event
48
44
  });
49
45
  }, 0);
50
46
  } else {
51
47
  queueMicrotask(function () {
52
- onPressEnterRef.current(value, {
48
+ onPressEnter(value, {
53
49
  event: event
54
50
  });
55
51
  });
@@ -58,6 +54,6 @@ export var ShiftEnterKeyPlugin = function ShiftEnterKeyPlugin(_ref) {
58
54
  },
59
55
  // 优先级要低于 MentionPickerPlugin
60
56
  COMMAND_PRIORITY_LOW);
61
- }, [editor]);
57
+ }, [editor, onPressEnter]);
62
58
  return null;
63
59
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuntijs/ui",
3
- "version": "1.2.0-beta.2",
3
+ "version": "1.2.0",
4
4
  "description": "☁️ Yunti UI - an open-source UI component library for building Cloud Native web apps",
5
5
  "keywords": [
6
6
  "yuntijs",