@infonomic/payload-alternative-lexical-editor 1.1.5 → 1.1.6

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.
Files changed (2) hide show
  1. package/README.md +10 -8
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,21 +1,23 @@
1
- # Payload CMS 3.0 Alternative Lexical Rich Text Editor
1
+ # Payload CMS Alternative Lexical Rich Text Editor
2
2
 
3
- An alternative adapter-based Lexical Rich Text editor for Payload CMS.
3
+ An alternative adapter-based [Lexical rich text editor](https://lexical.dev/) for Payload CMS.
4
4
 
5
5
  > [!IMPORTANT]
6
6
  > Unless you have very specific needs, or a lot of experience with Lexical and custom Payload fields, you should almost certainly be using the official [Payload Lexical Rich Text editor](https://payloadcms.com/docs/lexical/overview).
7
7
  >
8
8
 
9
- Before we dive in, it's also worth mentioning that creating a generalized and extensible editor with a 'pluggable' feature system — such as the one currently being developed the team at Payload, is an order of magnitude more difficult than creating an 'opinionated' adapter with limited extensibility. The Payload team are doing amazing work - and this repo and our editor is in no way a criticism of the work being done at Payload.
10
-
11
9
  ## Our Lexical Editor
12
10
  <img style="width: 100%" alt="lexical-editor-screenshot" src="https://github.com/user-attachments/assets/a41060c9-6f28-4b64-a045-c3fdd411d9af" />
13
11
 
14
12
  ## Background
15
13
 
16
- We started working with [Lexical](https://lexical.dev/) in 2022 while searching for a replacement CMS for our agency. We then discovered [Payload CMS](https://payloadcms.com/) - which ticked nearly every box, with one notable exception - the use of Slate as their rich text editor. We'd worked with Slate and other editors previously and really wanted to use Lexical.
14
+ We started working with [Lexical](https://lexical.dev/) in 2022 while searching for a replacement CMS for our agency. We then discovered [Payload CMS](https://payloadcms.com/) - which was a pretty good fit for what we were looking for at the time, with one notable exception - the use of [Slate](https://github.com/ianstormtaylor/slate) as its rich text editor. We'd worked with Slate and other editors previously and really wanted to use Lexical.
15
+
16
+ We were also painfully aware of how difficult it is to work with Contenteditable-based editors - in particular for mobile support and especially on Android. Read this somewhat famous post from Jesse Jorgenson at [Prose Mirror](https://prosemirror.net/) - [Contenteditable on Android is the Absolute Worst](https://discuss.prosemirror.net/t/contenteditable-on-android-is-the-absolute-worst/3810). As an aside, [CKEditor](https://ckeditor.com/) has an excellent editing surface with very good mobile support (with solutions for most of Android's quirks) - it's just a shame that their model doesn't support structured content as its native serialization format (it expects HTML in and out - despite having quite a good internal model). Lexical's model and native serialization format is excellent - 'data in and data out', and mobile support is 'good enough'.
17
+
18
+ And so we started work on a Lexical-based rich text field for Payload.
17
19
 
18
- And so we started work on a Lexical-based rich text field for Payload. Early in 2023 we discovered [Alessio Gravili's Payload Lexical Plugin](https://github.com/AlessioGr/payload-plugin-lexical) which helped enormously in getting started with Payload and custom fields. We also attempted to 'give back' to the work Alessio was doing with contributions to his public repo.
20
+ Early in 2023 we discovered [Alessio Gravili's Payload Lexical Plugin](https://github.com/AlessioGr/payload-plugin-lexical) which helped enormously in getting started with Payload and custom fields. We also attempted to 'give back' to the work Alessio was doing with contributions to his public repo.
19
21
 
20
22
  Thanks largely to Alessio's efforts, Lexical has now been adopted by the Payload team and is the default editor for Payload, which is fantastic.
21
23
 
@@ -35,7 +37,7 @@ Here are the main drivers for us wanting to maintain our own editor:
35
37
 
36
38
  5. In Payload 3.0 - we wanted to experiment with client-only forms using the new field api and `RenderFields`. You can see an example here in our [Admonition plugin](https://github.com/infonomic/payload-alternative-lexical-editor/blob/main/packages/payload-alternative-lexical-editor/src/field/plugins/admonition-plugin/admonition-drawer.tsx). This is totally experimental. It works (as far as we can tell) and we're using this for all of our custom components that require modals or drawers with Payload fields.
37
39
 
38
- 6. We wanted to share our plugins - in particular our Inline Image plugin which was accepted into the Lexical playground and our Admonition plugin. In fact, our Inline Image plugin was one of the main reasons we chose Lexical as our preferred editor. Try creating a floated inline element that appears correctly in both the admin UI and the front end application - with any of the 'other editors', and you'll see why ;-). Most of the other plugins in this repo track Lexical Playground plugins and are updated from there.
40
+ 6. We wanted to share our plugins - in particular our Inline Image plugin which was accepted into the [Lexical playground](https://playground.lexical.dev/) and our Admonition plugin. In fact, our Inline Image plugin was one of the main reasons we chose Lexical as our preferred editor. Try creating a floated inline element that appears correctly in both the admin UI and the front end application - with any of the 'other editors', and you'll see why ;-). Most of the other plugins in this repo track Lexical Playground plugins and are updated from there.
39
41
 
40
42
  7. And lastly, we wanted to keep our editor lightweight and fast — in particular for longer documents.
41
43
 
@@ -94,7 +96,7 @@ The architecture of our editor is designed to solve the "two-way binding problem
94
96
 
95
97
  Rich text editors maintain their own complex internal state (the DOM/Virtual DOM). When you try to sync this with React state (props), you often get **infinite loops** (Editor changes $\rightarrow$ React updates $\rightarrow$ Prop changes $\rightarrow$ Editor updates $\rightarrow$ Editor changes...) or **cursor jumping** (re-rendering the editor while typing).
96
98
 
97
- In Payload - the adapter loads our editor via the `rsc-entry.tsx` stub and a component map entry in the [adapter](https://github.com/infonomic/payload-alternative-lexical-editor/blob/main/packages/payload-alternative-lexical-editor/src/adapter.ts). This follows the current adapter / component map strategy in Payload CMS itself. Note: Although the return shape of our editor is slightly different, the root of our editor document and SerializedEditorState is identical to the official Payload Lexical editor, and so migrating to or from the Payload version will depend primarily on what features or plugins have been used.
99
+ In Payload - the adapter loads our editor via the `rsc-entry.tsx` stub and a component map entry in the [adapter](https://github.com/infonomic/payload-alternative-lexical-editor/blob/main/packages/payload-alternative-lexical-editor/src/adapter.ts). This follows the current adapter / component map strategy in Payload CMS itself. Note: Although the return shape of our editor is slightly different, the root of our editor document and SerializedEditorState is identical to the official Payload Lexical editor, and so migrating to or from the Payload version will depend primarily on which features or plugins have been used.
98
100
 
99
101
  ### Component Hierarchy
100
102
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infonomic/payload-alternative-lexical-editor",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",