@selfcommunity/react-ui 0.11.0-alpha.32 → 0.11.0-alpha.34

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,19 +11,19 @@ const system_1 = require("@mui/system");
11
11
  const nodes_1 = tslib_1.__importDefault(require("./nodes"));
12
12
  const LexicalComposer_1 = require("@lexical/react/LexicalComposer");
13
13
  const LexicalContentEditable_1 = require("@lexical/react/LexicalContentEditable");
14
- const LexicalHistoryPlugin_1 = require("@lexical/react/LexicalHistoryPlugin");
14
+ const ToolbarPlugin_1 = tslib_1.__importDefault(require("./plugins/ToolbarPlugin"));
15
+ const constants_1 = require("./constants");
16
+ const HorizontalRulePlugin_1 = require("./plugins/HorizontalRulePlugin");
15
17
  const LexicalRichTextPlugin_1 = require("./plugins/LexicalRichTextPlugin");
16
- const LexicalErrorBoundary_1 = tslib_1.__importDefault(require("@lexical/react/LexicalErrorBoundary"));
17
- const LexicalHorizontalRulePlugin_1 = require("@lexical/react/LexicalHorizontalRulePlugin");
18
+ const LexicalErrorBoundary_1 = require("@lexical/react/LexicalErrorBoundary");
18
19
  const plugins_1 = require("./plugins");
20
+ const OnBlurPlugin_1 = tslib_1.__importDefault(require("./plugins/OnBlurPlugin"));
21
+ const OnFocusPlugin_1 = tslib_1.__importDefault(require("./plugins/OnFocusPlugin"));
19
22
  const LexicalLinkPlugin_1 = require("@lexical/react/LexicalLinkPlugin");
23
+ const FloatingLinkPlugin_1 = tslib_1.__importDefault(require("./plugins/FloatingLinkPlugin"));
20
24
  const ApiPlugin_1 = tslib_1.__importDefault(require("./plugins/ApiPlugin"));
21
- const ToolbarPlugin_1 = tslib_1.__importDefault(require("./plugins/ToolbarPlugin"));
25
+ const LexicalHistoryPlugin_1 = require("@lexical/react/LexicalHistoryPlugin");
22
26
  const LexicalListPlugin_1 = require("@lexical/react/LexicalListPlugin");
23
- const FloatingLinkPlugin_1 = tslib_1.__importDefault(require("./plugins/FloatingLinkPlugin"));
24
- const OnBlurPlugin_1 = tslib_1.__importDefault(require("./plugins/OnBlurPlugin"));
25
- const OnFocusPlugin_1 = tslib_1.__importDefault(require("./plugins/OnFocusPlugin"));
26
- const constants_1 = require("./constants");
27
27
  const classes = {
28
28
  root: `${constants_1.PREFIX}-root`,
29
29
  focused: `${constants_1.PREFIX}-focused`,
@@ -145,6 +145,6 @@ const Editor = (inProps, ref) => {
145
145
  nodes: [...nodes_1.default],
146
146
  theme: editorTheme
147
147
  }), [editable]);
148
- return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className, { [classes.toolbar]: toolbar, [classes.focused]: focused }) }, { children: (0, jsx_runtime_1.jsxs)(LexicalComposer_1.LexicalComposer, Object.assign({ initialConfig: initialConfig }, { children: [toolbar ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ToolbarPlugin_1.default, { uploadImage: uploadImage }), (0, jsx_runtime_1.jsx)(LexicalListPlugin_1.ListPlugin, {}), (0, jsx_runtime_1.jsx)(LexicalHorizontalRulePlugin_1.HorizontalRulePlugin, {})] })) : ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.actions, direction: "row" }, { children: [uploadImage && (0, jsx_runtime_1.jsx)(plugins_1.ImagePlugin, {}), (0, jsx_runtime_1.jsx)(plugins_1.EmojiPlugin, {})] }))), (0, jsx_runtime_1.jsx)(LexicalRichTextPlugin_1.RichTextPlugin, { contentEditable: (0, jsx_runtime_1.jsx)(LexicalContentEditable_1.ContentEditable, { className: classes.content }), placeholder: (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.placeholder, onClick: handleFocus }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.editor.placeholder", defaultMessage: "ui.editor.placeholder" }) })), ErrorBoundary: LexicalErrorBoundary_1.default }), (0, jsx_runtime_1.jsx)(plugins_1.DefaultHtmlValuePlugin, { defaultValue: defaultValue }), (0, jsx_runtime_1.jsx)(LexicalHistoryPlugin_1.HistoryPlugin, {}), (0, jsx_runtime_1.jsx)(plugins_1.OnChangePlugin, { onChange: handleChange }), (0, jsx_runtime_1.jsx)(OnBlurPlugin_1.default, { onBlur: handleHasBlur }), (0, jsx_runtime_1.jsx)(OnFocusPlugin_1.default, { onFocus: handleHasFocus }), (0, jsx_runtime_1.jsx)(plugins_1.AutoLinkPlugin, {}), (0, jsx_runtime_1.jsx)(plugins_1.MentionsPlugin, {}), (0, jsx_runtime_1.jsx)(LexicalLinkPlugin_1.LinkPlugin, {}), (0, jsx_runtime_1.jsx)(FloatingLinkPlugin_1.default, {}), (0, jsx_runtime_1.jsx)(ApiPlugin_1.default, { ref: apiRef })] })) })));
148
+ return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className, { [classes.toolbar]: toolbar, [classes.focused]: focused }) }, { children: (0, jsx_runtime_1.jsxs)(LexicalComposer_1.LexicalComposer, Object.assign({ initialConfig: initialConfig }, { children: [toolbar ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ToolbarPlugin_1.default, { uploadImage: uploadImage }), (0, jsx_runtime_1.jsx)(LexicalListPlugin_1.ListPlugin, {}), (0, jsx_runtime_1.jsx)(HorizontalRulePlugin_1.HorizontalRulePlugin, {})] })) : ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.actions, direction: "row" }, { children: [uploadImage && (0, jsx_runtime_1.jsx)(plugins_1.ImagePlugin, {}), (0, jsx_runtime_1.jsx)(plugins_1.EmojiPlugin, {})] }))), (0, jsx_runtime_1.jsx)(LexicalRichTextPlugin_1.RichTextPlugin, { contentEditable: (0, jsx_runtime_1.jsx)(LexicalContentEditable_1.ContentEditable, { className: classes.content }), placeholder: (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.placeholder, onClick: handleFocus }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.editor.placeholder", defaultMessage: "ui.editor.placeholder" }) })), ErrorBoundary: LexicalErrorBoundary_1.LexicalErrorBoundary }), (0, jsx_runtime_1.jsx)(plugins_1.DefaultHtmlValuePlugin, { defaultValue: defaultValue }), (0, jsx_runtime_1.jsx)(LexicalHistoryPlugin_1.HistoryPlugin, {}), (0, jsx_runtime_1.jsx)(plugins_1.OnChangePlugin, { onChange: handleChange }), (0, jsx_runtime_1.jsx)(OnBlurPlugin_1.default, { onBlur: handleHasBlur }), (0, jsx_runtime_1.jsx)(OnFocusPlugin_1.default, { onFocus: handleHasFocus }), (0, jsx_runtime_1.jsx)(plugins_1.AutoLinkPlugin, {}), (0, jsx_runtime_1.jsx)(plugins_1.MentionsPlugin, {}), (0, jsx_runtime_1.jsx)(LexicalLinkPlugin_1.LinkPlugin, {}), (0, jsx_runtime_1.jsx)(FloatingLinkPlugin_1.default, {}), (0, jsx_runtime_1.jsx)(ApiPlugin_1.default, { ref: apiRef })] })) })));
149
149
  };
150
150
  exports.default = (0, react_1.forwardRef)(Editor);
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ export declare function HorizontalRulePlugin(): null;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.HorizontalRulePlugin = void 0;
11
+ const LexicalComposerContext_1 = require("@lexical/react/LexicalComposerContext");
12
+ const LexicalHorizontalRuleNode_1 = require("@lexical/react/LexicalHorizontalRuleNode");
13
+ const utils_1 = require("@lexical/utils");
14
+ const lexical_1 = require("lexical");
15
+ const react_1 = require("react");
16
+ function HorizontalRulePlugin() {
17
+ const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
18
+ (0, react_1.useEffect)(() => {
19
+ return editor.registerCommand(LexicalHorizontalRuleNode_1.INSERT_HORIZONTAL_RULE_COMMAND, (type) => {
20
+ const selection = (0, lexical_1.$getSelection)();
21
+ if (!(0, lexical_1.$isRangeSelection)(selection)) {
22
+ return false;
23
+ }
24
+ const focusNode = selection.focus.getNode();
25
+ if (focusNode !== null) {
26
+ const horizontalRuleNode = (0, LexicalHorizontalRuleNode_1.$createHorizontalRuleNode)();
27
+ (0, utils_1.$insertNodeToNearestRoot)(horizontalRuleNode);
28
+ }
29
+ return true;
30
+ }, lexical_1.COMMAND_PRIORITY_EDITOR);
31
+ }, [editor]);
32
+ return null;
33
+ }
34
+ exports.HorizontalRulePlugin = HorizontalRulePlugin;
@@ -1,6 +1,6 @@
1
1
  import { ErrorBoundaryType } from '../shared/useDecorators';
2
2
  export declare function RichTextPlugin({ contentEditable, placeholder, ErrorBoundary }: {
3
3
  contentEditable: JSX.Element;
4
- placeholder: ((isEditable: boolean) => null | JSX.Element) | null | JSX.Element;
5
- ErrorBoundary: ErrorBoundaryType;
4
+ placeholder?: ((isEditable: boolean) => null | JSX.Element) | null | JSX.Element;
5
+ ErrorBoundary?: ErrorBoundaryType;
6
6
  }): JSX.Element;
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RichTextPlugin = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const jsx_runtime_1 = require("react/jsx-runtime");
6
5
  const LexicalComposerContext_1 = require("@lexical/react/LexicalComposerContext");
7
- const useLexicalEditable_1 = tslib_1.__importDefault(require("@lexical/react/useLexicalEditable"));
6
+ const useLexicalEditable_1 = require("@lexical/react/useLexicalEditable");
8
7
  const useDecorators_1 = require("../shared/useDecorators");
9
8
  const useEditorFocus_1 = require("../shared/useEditorFocus");
10
9
  const useCanShowPlaceholder_1 = require("../shared/useCanShowPlaceholder");
@@ -19,7 +18,7 @@ exports.RichTextPlugin = RichTextPlugin;
19
18
  function Placeholder({ content }) {
20
19
  const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
21
20
  const showPlaceholder = (0, useCanShowPlaceholder_1.useCanShowPlaceholder)(editor);
22
- const editable = (0, useLexicalEditable_1.default)();
21
+ const editable = (0, useLexicalEditable_1.useLexicalEditable)();
23
22
  const hasFocus = (0, useEditorFocus_1.useEditorFocus)();
24
23
  if (!showPlaceholder || hasFocus) {
25
24
  return null;
@@ -8,19 +8,19 @@ import { useThemeProps } from '@mui/system';
8
8
  import nodes from './nodes';
9
9
  import { LexicalComposer } from '@lexical/react/LexicalComposer';
10
10
  import { ContentEditable } from '@lexical/react/LexicalContentEditable';
11
- import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
11
+ import ToolbarPlugin from './plugins/ToolbarPlugin';
12
+ import { PREFIX } from './constants';
13
+ import { HorizontalRulePlugin } from './plugins/HorizontalRulePlugin';
12
14
  import { RichTextPlugin } from './plugins/LexicalRichTextPlugin';
13
- import LexicalErrorBoundary from '@lexical/react/LexicalErrorBoundary';
14
- import { HorizontalRulePlugin } from '@lexical/react/LexicalHorizontalRulePlugin';
15
+ import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
15
16
  import { AutoLinkPlugin, DefaultHtmlValuePlugin, EmojiPlugin, ImagePlugin, MentionsPlugin, OnChangePlugin } from './plugins';
17
+ import OnBlurPlugin from './plugins/OnBlurPlugin';
18
+ import OnFocusPlugin from './plugins/OnFocusPlugin';
16
19
  import { LinkPlugin } from '@lexical/react/LexicalLinkPlugin';
20
+ import FloatingLinkPlugin from './plugins/FloatingLinkPlugin';
17
21
  import ApiPlugin from './plugins/ApiPlugin';
18
- import ToolbarPlugin from './plugins/ToolbarPlugin';
22
+ import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
19
23
  import { ListPlugin } from '@lexical/react/LexicalListPlugin';
20
- import FloatingLinkPlugin from './plugins/FloatingLinkPlugin';
21
- import OnBlurPlugin from './plugins/OnBlurPlugin';
22
- import OnFocusPlugin from './plugins/OnFocusPlugin';
23
- import { PREFIX } from './constants';
24
24
  const classes = {
25
25
  root: `${PREFIX}-root`,
26
26
  focused: `${PREFIX}-focused`,
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ export declare function HorizontalRulePlugin(): null;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
9
+ import { $createHorizontalRuleNode, INSERT_HORIZONTAL_RULE_COMMAND } from '@lexical/react/LexicalHorizontalRuleNode';
10
+ import { $insertNodeToNearestRoot } from '@lexical/utils';
11
+ import { $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR } from 'lexical';
12
+ import { useEffect } from 'react';
13
+ export function HorizontalRulePlugin() {
14
+ const [editor] = useLexicalComposerContext();
15
+ useEffect(() => {
16
+ return editor.registerCommand(INSERT_HORIZONTAL_RULE_COMMAND, (type) => {
17
+ const selection = $getSelection();
18
+ if (!$isRangeSelection(selection)) {
19
+ return false;
20
+ }
21
+ const focusNode = selection.focus.getNode();
22
+ if (focusNode !== null) {
23
+ const horizontalRuleNode = $createHorizontalRuleNode();
24
+ $insertNodeToNearestRoot(horizontalRuleNode);
25
+ }
26
+ return true;
27
+ }, COMMAND_PRIORITY_EDITOR);
28
+ }, [editor]);
29
+ return null;
30
+ }
@@ -1,6 +1,6 @@
1
1
  import { ErrorBoundaryType } from '../shared/useDecorators';
2
2
  export declare function RichTextPlugin({ contentEditable, placeholder, ErrorBoundary }: {
3
3
  contentEditable: JSX.Element;
4
- placeholder: ((isEditable: boolean) => null | JSX.Element) | null | JSX.Element;
5
- ErrorBoundary: ErrorBoundaryType;
4
+ placeholder?: ((isEditable: boolean) => null | JSX.Element) | null | JSX.Element;
5
+ ErrorBoundary?: ErrorBoundaryType;
6
6
  }): JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
3
- import useLexicalEditable from '@lexical/react/useLexicalEditable';
3
+ import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
4
4
  import { useDecorators } from '../shared/useDecorators';
5
5
  import { useEditorFocus } from '../shared/useEditorFocus';
6
6
  import { useCanShowPlaceholder } from '../shared/useCanShowPlaceholder';