0.19.0 • Published 7 months ago

@lexical/react v0.19.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months 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@fantufantu/beeeditorlexical-lib-demomessier-61scribo-markdownurdu-rich-editorlexical-toolbar-verbum@everything-registry/sub-chunk-545veridical@veridical/components@veridical/pluginshrconnect-uieditor-dsdsykpcomposersykecomposer2test-package-deploy-from-organizationworroierwritlytelco-wysiwygtest-sceyt-chat-react-uikittestpkg777vntrs-editorvc-editor@dossierhq/react-components@drcpythonmfe/lexical-playground@crystallize/design-system@communi/editor@contentmunch/muncher@corbit/rich-text-editor@cpchain-foundation/editor@bunstack/lexical@blocklet/prompt-editor@blocklet/discuss-kit-ux@blocklet/editor@rryando/editor@payloadcms/richtext-lexical@ticketz-oss/mdx-editorkalliopelanding-page-builderkoenig-lexical-experimentmirpayloadregere-iconssceyt-chat-react-uikit-npmtest-2-sceyt-chat-react-uikitsurveykruiui-rich-editortest-3-sceyt-chat-react-uikittest-4-sceyt-chat-react-uikitturbovision@amityco/ui-kit@amityco/ui-kit-open-source@amityco/ulta-ui-kit@anthaathi/components@arkitektbedriftene/fe-lib@anjy7/navbar-cms@astroshuttle/ui@attrybtech/attryb-ui@availabs/dms@asset-protocol/react@alkuip/forms@banx9x/react-editor@barscience/global-components@barsnes/lexical-twemoji@blackmann/react-chat-input@betty-blocks/mdxeditor@biblionexus-foundation/platform-editor@biblionexus-foundation/scribe-editor@capytale/capytale-rich-text-editor@brikl/design-dashboard@cc-apps/core@churchapps/apphelper@centreon/ui@21epub-ui/comments@21epub-ui/text-editor2ani-ui5htp-core@accelbyte/widgets-v2@coinvoice/lexical-playground@cmpsr/markdown-editor@bosheski/mdxeditor-editor@datalayer/jupyter-lexical@dcorp/web-editor@denindka/editor-dsd@difizen/ai-flow@did-comment/react@copus/editorverbumverbum-deploy-testverbum-refinedurdu-web-editor@firaslatrach/tam_editor_nodes@gtplan/react-components@hestudy/next-editor@huongda-group/lexical-file-manager@igloo-ui/text-editor@fluentui-copilot/react-text-editor@fluentai/react-text-editor@emergence-engineering/lexical-link-preview-plugin@emergence-engineering/lexical-slash-menu-plugin@ksense-tech/components
0.19.0

8 months ago

0.18.0

9 months ago

0.17.1

10 months ago

0.17.0

11 months ago

0.16.0

1 year ago

0.16.1

12 months ago

0.15.0

1 year ago

0.14.5

1 year ago

0.14.4

1 year ago

0.14.3

1 year ago

0.14.2

1 year ago

0.14.0

1 year ago

0.14.1

1 year ago

0.13.1

1 year ago

0.13.0

1 year ago

0.12.6

1 year ago

0.12.5

2 years ago

0.11.2

2 years ago

0.11.3

2 years ago

0.12.0

2 years ago

0.12.1

2 years ago

0.12.2

2 years ago

0.12.3

2 years ago

0.12.4

2 years ago

0.11.0

2 years ago

0.11.1

2 years ago

0.9.0

2 years ago

0.9.2

2 years ago

0.9.1

2 years ago

0.10.0

2 years ago

0.7.9

2 years ago

0.7.8

2 years ago

0.7.7

2 years ago

0.8.1

2 years ago

0.8.0

2 years ago

0.7.2

2 years ago

0.7.1

3 years ago

0.7.4

2 years ago

0.7.3

2 years ago

0.7.0

3 years ago

0.7.6

2 years ago

0.7.5

2 years ago

0.6.3

3 years ago

0.6.2

3 years ago

0.6.5

3 years ago

0.6.4

3 years ago

0.6.1-next.0

3 years ago

0.5.1-next.1

3 years ago

0.5.1-next.0

3 years ago

0.5.1-next.2

3 years ago

0.6.0

3 years ago

0.5.0

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.9

3 years ago

0.3.11

3 years ago

0.3.10

3 years ago

0.3.6

3 years ago

0.3.5

3 years ago

0.3.8

3 years ago

0.3.7

3 years ago

0.3.4

3 years ago

0.3.0

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.9

3 years ago

0.2.8

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.3

3 years ago

0.1.20

3 years ago

0.1.21

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.17

3 years ago

0.1.18

3 years ago

0.1.19

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.1.12

3 years ago

0.1.13

3 years ago

0.1.14

3 years ago

0.1.15

3 years ago

0.1.16

3 years ago

0.1.11

3 years ago

0.1.10

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago