github facebook/lexical v0.36.1

10 hours ago

v0.36.1 is a major feature release with a new Lexical Extension API (#7706), some needed breaking changes to @lexical/yjs (#7816, #7818) and a bunch of bug fixes. We've also moved to React 19 (#7802) for all examples, tests, etc. although it should all still remain compatible with React 18 for now.

Breaking Changes

#7706 DecoratorNode

  • Removed type requirement & warning for DecoratorNode to implement decorate()
  • Widens type for decorate(): T to be decorate(): null | T as that's always how it worked in practice - the generic type here is unsafe and wrong anyway (e.g. $isDecoratorNode is a cast to any type T)

#7818 useCollaborationContext now requires that a context provider is used

Users of the CollaborationPlugin or useCollaborationContext must wrap the top-level LexicalComposer with a LexicalCollaboration component. For example:

<LexicalCollaboration>
  <LexicalComposer initialConfig={initialConfig}>
    <RichTextPlugin ... />
    <CollaborationPlugin id="lexical-editor" ... />
  </LexicalComposer>
<LexicalCollaboration>

The collaboration context is shared for nested editors, so the provider must only be used on the top-level editor.

#7818 useCollaborationContext no longer has clientID

clientID has been removed from the collaboration context. This ID was unreliable as it could be updated by nested collab editors. Consumers should retrieve the client ID by looking up the correct document in the context's yjsDocMap, or switch to using a different ID.

Highlights

Extension:

Core:

  • #7836 Fix cache coherency issue with RangeSelection#extract
  • #7854 Account for Apple WebView in setManagedLineBreak
  • 🧹 #7855 TabNode.setTextContent uses devInvariant instead of invariant for a warning in prod
  • 🧹 #7821 Improve error message when a node is registered from a foreign lexical module
  • 🧹 #7814 Consolidate ancestor lookup via findMatchingParent

Clipboard:

  • #7835 Update Lexical Clipboard with Empty Selection
  • #7822 Copy correct selection when editor in different window/document

List:

  • #7805 Clear li checklist attributes when inserting nested list

Markdown:

  • 🧹 #7832 Remove MarkdownShortcuts.ts dependency on index.ts

React:

  • ⚠️ #7816 Breaking change: remove clientID from collab context
  • ⚠️ #7818 Breaking change: enforce use of collab context provider
  • #7844 Add visibility margin to isTriggerVisibleInNearestScrollContainer to prevent popover from wrongfully closing
  • 🧹 #7802 #7803 Update from React 18 to React 19

Headless:

  • 🧪 #7833 @lexical/headless/dom module featuring withDOM function to make SSR easier

Playground:

  • #7786 DatetimeNode DOM updates
  • 🗑️ #7839 Remove mostly redundant InlineImageNode and InlineImageNodePlugin

Internal:

  • 🧹 #7766 #7810 Updated docusaurus and added local search index
  • 🧹 #7834 Relocate internal eslint plugin to packages/lexical-eslint-plugin-internal
  • 🧹 #7807 Port scripts unit tests to vitest and fix test include match pattern

What's Changed

  • v0.35.0 by @etrepum in #7797
  • [lexical-website] Chore: Update docusaurus-plugin-typedoc by @etrepum in #7766
  • [examples] Chore: Update examples for v0.35.0 by @etrepum in #7799
  • [lexical-playground] DatetimeNode DOM updates by @ivailop7 in #7786
  • [lexical-list] Fix: updating list type to/from check type updates child DOM elements by @james-atticus in #7800
  • [lexical-react] Fix: Use explicit key attr in NodeContextMenuPlugin by @etrepum in #7803
  • [lexical-list] Fix: clear li checklist attributes when inserting nested list by @james-atticus in #7805
  • [*] Chore: Port scripts unit tests to vitest and fix test include match pattern by @etrepum in #7807
  • [lexical-website] Bug Fix: Replace broken algolia search with @easyops-cn/docusaurus-search-local by @etrepum in #7810
  • [lexical-markdown] Update Flow types to match TypeScript by @takuyakanbr in #7813
  • [lexical][lexical-selection][lexical-utils] Refactor: Consolidate ancestor lookup via findMatchingParent by @cnaples79 in #7814
  • [lexical] Chore: Improve error message when a node is registered from a foreign lexical module by @etrepum in #7821
  • [lexical-clipboard] Fix: copy correct selection when editor in different window/document by @james-atticus in #7822
  • [lexical-yjs][lexical-playground] Breaking change: remove clientID from collab context by @james-atticus in #7816
  • [lexical-react] Breaking change: enforce use of collab context provider by @james-atticus in #7818
  • [lexical-markdown] Refactor: Remove MarkdownShortcuts.ts Dependency on index.ts by @jkjk822 in #7832
  • [lexical-clipboard] Bug Fix: Update Lexical Clipboard with Empty Selection by @jkjk822 in #7835
  • [*] Bug Fix: Relocate internal eslint plugin to packages/lexical-eslint-plugin-internal by @etrepum in #7834
  • [lexical] Bug Fix: Fix cache coherency issue with RangeSelection#extract by @jkjk822 in #7836
  • [lexical-playground] Chore: remove InlineImageNode and InlineImagePlugun by @etrepum in #7839
  • [lexical][lexical-react][lexical-playground] Chore: Update from React 18 to React 19 by @etrepum in #7802
  • [lexical-react] Bug Fix: Add visibility margin to isTriggerVisibleInNearestScrollContainer to prevent popover from wrongfully closing by @dwrth in #7844
  • [lexical-react] Bug Fix: Include react-error-boundary and @floating-ui/react in WWW bundle by @etrepum in #7852
  • [lexical][lexical-extension][*] Feature: Lexical Extension by @etrepum in #7706
  • [lexical-extension][docs] Chore: Add @experimental to extension functions by @etrepum in #7853
  • [lexical] Chore: Change TabNode.setTextContent invariant to devInvariant by @amanharwara in #7855
  • [lexical-headless] Feature: @lexical/headless/dom module for easier SSR by @etrepum in #7833
  • [*] Bug Fix: npmToWwwName ensures lexical prefix by @etrepum in #7857
  • [lexical-headless] Bug Fix: Replace happy-dom with jsdom in www and map react-dom/client by @etrepum in #7858
  • [lexical] Bug Fix: account for Apple WebView in setManagedLineBreak by @elpnt in #7854
  • v0.36.0 by @etrepum in #7861
  • Make ref optional in ContentEditable flow by @zurfyx in #7866
  • [*] Bug Fix: Update examples and fix package.json for v0.36.0 (will need a patch release) by @etrepum in #7867
  • Expose LexicalCollaboration Context to flow by @zurfyx in #7868

New Contributors

Full Changelog: v0.35.0...v0.36.1

Don't miss a new lexical release

NewReleases is sending notifications on new releases.