rubn-g

payloadcms lexical ext

by rubn-g
Rich text & editors
v?
MIT

Overview

Summary generated from the README

Adds extra features to the Payload CMS Lexical rich text editor. Each feature is imported and added to the lexicalEditor features array, and can be used alone or together. JSX and HTML converters are provided for rendering the content on the frontend, and a CSS file must be imported for the color features.

Features

  • Text color feature with configurable color buttons
  • Text highlight feature for background color on selected text
  • Block background color for entire content blocks
  • YouTube and Vimeo video embeds inside the editor
  • JSX converters for rendering content in React
  • HTML converters for use with convertLexicalToHTML

Use cases

  • Style article text with colors and highlights directly in the Payload editor
  • Embed YouTube or Vimeo videos within rich text content
  • Render colored and embedded Lexical content on a frontend via JSX or HTML converters

From the author

Extended lexical editor features for Payload CMS

Installation

npm i payloadcms-lexical-ext

73

Stars

19

Forks

14

Open Issues

1 years ago

Last Updated

0

Weekly Downloads

v0.5.3

npm Version

171.0 KB

Unpacked Size

2

Dependencies

GitHub stars

Trends appear after 7 days of data. Daily snapshots have not started yet.

npm weekly downloads

Trends appear after 7 days of data. Daily snapshots have not started yet.

Each point is npm's rolling 7-day download count.

Health Score

31/100Fair

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/907855621-root.svg)](https://payloaddirectory.dev/plugins/907855621-root)
HTML
<a href="https://payloaddirectory.dev/plugins/907855621-root"><img src="https://payloaddirectory.dev/badge/907855621-root.svg" alt="Payload Directory"></a>
Updated Jan 27, 2025Created Dec 24, 2024Published Jan 27, 2025

README

Payload CMS lexical editor extend

🚀 Overview

Ideal for content creators and developers who want to enrich their text content with more visual appeal.

This plugin adds new features to the Payload CMS lexical editor. You can use any of the features on its own or all of them togehter:

  • Text Color – Customize the color of selected text.
  • Text Highlight – Highlight text with a background color.
  • Block Background Color – Apply background colors to entire blocks of content.
  • Embed videos - Add embedded youtube or vimeo videos to the content of the editor

New features will be added - Create issues for new features or create them yourself and create a PR to share it with the community

📸 Screenshots

Text Color Feature

Text Color Example

Text Highlight Feature

Text Highlight Example

Block Background Feature

Block Background Example

Embed Video Feature

Embed Video Example

📦 Installation

npm install payloadcms-lexical-ext

or

yarn add payloadcms-lexical-ext

🛠️ Usage

  1. Import the features you want to use:
import { BgColorFeature, HighlightColorFeature, TextColorFeature, YoutubeFeature, VimeoFeature } from 'payloadcms-lexical-ext';
  1. If you're using any of the color features, import required css
import 'payloadcms-lexical-ext/client/client.css'
  1. Add features to your lexical editor configuration:
lexicalEditor({
	features: [
		...defaultEditorFeatures,
		...YourFeatures...
		TextColorFeature(),
		HighlightColorFeature(),
		BgColorFeature(),
		YoutubeFeature(),
		VimeoFeature()
	]
});
  1. Add JSX or HTML converters

    4.1 JSX Converters

    components/RichText/index.tsx

    import { JSXConverters } from 'payloadcms-lexical-ext'
    
    const jsxConverters: JSXConvertersFunction<NodeTypes> = ({ defaultConverters }) => ({
    	...defaultConverters,
    	...JSXConverters
    })
    

    4.2 HTML Converters

    import { consolidateHTMLConverters, convertLexicalToHTML, sanitizeServerEditorConfig } from '@payloadcms/richtext-lexical'
    import { HTMLConverters } from 'payloadcms-lexical-ext'
    
    ...
    
    const sanitizedEditorConfig = await sanitizeServerEditorConfig(editorConfig, req.payload.config)
    
    await convertLexicalToHTML({
    	converters: [
    		...HTMLConverters,
    		...consolidateHTMLConverters({ editorConfig: sanitizedEditorConfig })
    	],
    	data: jsonEditorContent,
    	req,
    })
    

⚙️ Configuration Options

The plugin comes with several customizable options:

TextColorFeature({
	colors: [{
		type: 'button',
		label: 'Custom color',
		color: '#1155aa'
	}]
});

🧑‍💻 Contributing

Contributions are welcome! To get started:

  1. Fork the repository.
  2. Create a new branch for your feature.
  3. Submit a pull request.

📝 License

This project is licensed under the MIT License.

📬 Contact

For questions or suggestions, feel free to open an issue or reach out to the Payload CMS community.

Similar plugins