@yuntijs/ui 1.0.0-beta.87 → 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.
@@ -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 = customDisabled !== null && customDisabled !== void 0 ? customDisabled : componentDisabled;
55
- var editable = !readOnly && !disabled;
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(OnBlurBlock, {
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
  })
@@ -0,0 +1,7 @@
1
+ import type { FC } from 'react';
2
+ type OnBlurBlockPluginProps = {
3
+ onBlur?: () => void;
4
+ onFocus?: () => void;
5
+ };
6
+ export declare const OnBlurBlockPlugin: FC<OnBlurBlockPluginProps>;
7
+ export {};
@@ -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 OnBlurBlock = function OnBlurBlock(_ref) {
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,4 @@
1
+ import React from 'react';
2
+ export declare const EditablePlugin: React.FC<{
3
+ editable: boolean;
4
+ }>;
@@ -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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuntijs/ui",
3
- "version": "1.0.0-beta.87",
3
+ "version": "1.0.0-beta.88",
4
4
  "description": "☁️ Yunti UI - an open-source UI component library for building Cloud Native web apps",
5
5
  "keywords": [
6
6
  "yuntijs",