0.14.5 • Published 17 days ago

@lexical/react v0.14.5

Weekly downloads
-
License
MIT
Repository
github
Last release
17 days ago

@lexical/react

This package provides a set of components and hooks for Lexical that allow for text editing in React applications.

Getting started

Install lexical and @lexical/react:

npm install --save lexical @lexical/react

Below is an example of a basic plain text editor using lexical and @lexical/react (try it yourself).

import {$getRoot, $getSelection} from 'lexical';
import {useEffect} from 'react';

import {LexicalComposer} from '@lexical/react/LexicalComposer';
import {PlainTextPlugin} from '@lexical/react/LexicalPlainTextPlugin';
import {ContentEditable} from '@lexical/react/LexicalContentEditable';
import {HistoryPlugin} from '@lexical/react/LexicalHistoryPlugin';
import {OnChangePlugin} from '@lexical/react/LexicalOnChangePlugin';
import {useLexicalComposerContext} from '@lexical/react/LexicalComposerContext';

const theme = {
  // Theme styling goes here
  ...
}

// When the editor changes, you can get notified via the
// LexicalOnChangePlugin!
function onChange(editorState) {
  editorState.read(() => {
    // Read the contents of the EditorState here.
    const root = $getRoot();
    const selection = $getSelection();

    console.log(root, selection);
  });
}

// Lexical React plugins are React components, which makes them
// highly composable. Furthermore, you can lazy load plugins if
// desired, so you don't pay the cost for plugins until you
// actually use them.
function MyCustomAutoFocusPlugin() {
  const [editor] = useLexicalComposerContext();

  

useEffect(() => {
    // Focus the editor when the effect fires!
    editor.focus();
  }, [editor]);

  return null;
}

// Catch any errors that occur during Lexical updates and log them
// or throw them as needed. If you don't throw them, Lexical will
// try to recover gracefully without losing user data.
function onError(error) {
  throw error;
}

function Editor() {
  const initialConfig = {
    namespace: 'MyEditor',
    theme,
    onError,
  };

return (
    <LexicalComposer initialConfig={initialConfig}>
      <PlainTextPlugin
        contentEditable={<ContentEditable />}
        placeholder={<div>Enter some text...</div>}
      />
      <OnChangePlugin onChange={onChange} />
      <HistoryPlugin />
      <MyCustomAutoFocusPlugin />
    </LexicalComposer>
  );
}
@paiondata/messier-61@centreon/ui@fantufantu/beeeditorlexical-lib-demomessier-61scribo-markdownurdu-rich-editorlexical-toolbar-verbum@everything-registry/sub-chunk-545veridical@veridical/components@veridical/plugins@barscience/global-components@barsnes/lexical-twemoji@based/ui@betty-blocks/mdxeditor@asset-protocol/react@biblionexus-foundation/platform-editor@blackmann/react-chat-input@blocklet/discuss-kit-ux@blocklet/editor@blocklet/prompt-editor@bunstack/lexical@brikl/design-dashboard@bosheski/mdxeditor-editor@attrybtech/attryb-ui@arkitektbedriftene/fe-lib@astroshuttle/ui@availabs/dms@churchapps/apphelper@communi/editor@cmpsr/markdown-editor@coinvoice/lexical-playground@cpchain-foundation/editor@contentmunch/muncher@crystallize/design-system@datalayer/jupyter-lexical@dossierhq/react-components@did-comment/react@dcorp/web-ui@emergence-engineering/lexical-link-preview-plugin@emergence-engineering/lexical-slash-menu-plugin@ecclesiasoft/components@ecclesiasoft/core@ecclesiasoft/redux@equinor/ioc-common-frontend@enlightngo/iwe@fluentui-copilot/react-text-editor@fluentai/react-text-editor@foxpage/foxpage-rich-text-editor@iserp/verbum@joshcena/lexical-editor@jpmorganchase/mosaic-content-editor-plugin@jitera/jitera-web-ui-librarygrep-componentseditor-dsdeditor-react-seventeenreact-slitehrconnect-uihaprog-editorreact-lexical-wysiwygreact-markdown-markosreact-comments-modulehp-markdown-editorlexical-rich-text-examplelexical-rtelexitorlexiwindlexical-playgroundlexical-playground-wllexical-react-rtelexical-wysiwygmirpayloadregere-iconssceyt-chat-react-uikit-npmtest-2-sceyt-chat-react-uikit@igloo-ui/text-editor@accelbyte/widgets-v2@21epub-ui/comments@21epub-ui/text-editor@alkuip/forms@anthaathi/components@ksense-tech/components@lexi-kit/utils@lexi-kit/floating-toolbar@lexi-kit/shared-context@lexi-kit/shell@lexi-kit/toolbar@lexp/ui@lexp/ui-t@losol/scribo-markdown@luna-ui-com/self-service-editors@locospec/react@lukaprsina/mdxeditor@idstory-idm/rich-text@malda/rich-text-editor@makasi/primitives@mdxeditor/editor@maticoapp/matico_components@roq/ui-react
0.14.5

17 days ago

0.14.4

17 days ago

0.14.3

1 month ago

0.14.2

2 months ago

0.14.0

2 months ago

0.14.1

2 months ago

0.13.1

3 months ago

0.13.0

3 months ago

0.12.6

4 months ago

0.12.5

5 months ago

0.11.2

10 months ago

0.11.3

10 months ago

0.12.0

9 months ago

0.12.1

8 months ago

0.12.2

8 months ago

0.12.3

6 months ago

0.12.4

6 months ago

0.11.0

12 months ago

0.11.1

11 months ago

0.9.0

1 year ago

0.9.2

1 year ago

0.9.1

1 year ago

0.10.0

1 year ago

0.7.9

1 year ago

0.7.8

1 year ago

0.7.7

1 year ago

0.8.1

1 year ago

0.8.0

1 year ago

0.7.2

1 year ago

0.7.1

1 year ago

0.7.4

1 year ago

0.7.3

1 year ago

0.7.0

1 year ago

0.7.6

1 year ago

0.7.5

1 year ago

0.6.3

1 year ago

0.6.2

1 year ago

0.6.5

1 year ago

0.6.4

1 year ago

0.6.1-next.0

1 year ago

0.5.1-next.1

2 years ago

0.5.1-next.0

2 years ago

0.5.1-next.2

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.9

2 years ago

0.3.11

2 years ago

0.3.10

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.8

2 years ago

0.3.7

2 years ago

0.3.4

2 years ago

0.3.0

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.3

2 years ago

0.1.20

2 years ago

0.1.21

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.17

2 years ago

0.1.18

2 years ago

0.1.19

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.1.12

2 years ago

0.1.13

2 years ago

0.1.14

2 years ago

0.1.15

2 years ago

0.1.16

2 years ago

0.1.11

2 years ago

0.1.10

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago