ZNAXNOR

Payloadcms Dynamic Value Richtext Plugin

by ZNAXNOR
Rich text & editors
v3
^3.37.0
MIT

Overview

Summary generated from the README

Adds a Lexical feature that lets editors insert dynamic variables into rich text by typing a trigger character such as @. Variables are pulled from chosen collections and globals or from manually defined fields, and appear as non-editable badges. Frontend rendering needs the plugin's JSX converters or its wrapper component. Requires Payload 3.37 or later.

Features

  • Inline autocomplete popup triggered by @ or a custom character
  • Variables shown as non-editable badges that select and delete as a single unit
  • Fields resolved automatically from collections and globals or defined manually
  • Copy and paste of dynamic values between editors and documents
  • React wrapper component and JSX converters for frontend rendering
  • Matches the light and dark admin themes

Use cases

  • Reuse company contact details across pages without retyping them
  • Insert site settings values into rich text so content updates when the source field changes

From the author

Dynamic Value Rich Text Plugin for PayloadCMS

Installation

npm i @od-labs/payloadcms-dynamic-value-richtext

1

Stars

0

Forks

1

Open Issues

9 months ago

Last Updated

17

Weekly Downloads

v1.1.0

npm Version

112.9 KB

Unpacked Size

1

Dependencies

GitHub stars

10 since Sep 7

Show data
GitHub stars by day (UTC)
DateStars
Dec 6, 20261
Dec 5, 20261
Dec 4, 20261
Dec 3, 20261
Dec 2, 20261
Dec 1, 20261
Nov 30, 20261
Nov 29, 20261
Nov 28, 20261
Nov 27, 20261
Nov 26, 20261
Nov 25, 20261
Nov 24, 20261
Nov 23, 20261
Nov 22, 20261
Nov 21, 20261
Nov 20, 20261
Nov 19, 20261
Nov 18, 20261
Nov 17, 20261
Nov 16, 20261
Nov 15, 20261
Nov 14, 20261
Nov 13, 20261
Nov 12, 20261
Nov 11, 20261
Nov 10, 20261
Nov 9, 20261
Nov 8, 20261
Nov 7, 20261
Nov 6, 20261
Nov 5, 20261
Nov 4, 20261
Nov 3, 20261
Nov 2, 20261
Nov 1, 20261
Oct 31, 20261
Oct 30, 20261
Oct 29, 20261
Oct 28, 20261
Oct 27, 20261
Oct 26, 20261
Oct 25, 20261
Oct 24, 20261
Oct 23, 20261
Oct 22, 20261
Oct 21, 20261
Oct 20, 20261
Oct 19, 20261
Oct 18, 20261
Oct 17, 20261
Oct 16, 20261
Oct 15, 20261
Oct 14, 20261
Oct 13, 20261
Oct 12, 20261
Oct 11, 20261
Oct 10, 20261
Oct 9, 20261
Oct 8, 20261
Oct 7, 20261
Oct 6, 20261
Oct 5, 20261
Oct 4, 20261
Oct 3, 20261
Oct 2, 20261
Oct 1, 20261
Sep 30, 20261
Sep 29, 20261
Sep 28, 20261
Sep 27, 20261
Sep 26, 20261
Sep 25, 20261
Sep 24, 20261
Sep 23, 20261
Sep 22, 20261
Sep 21, 20261
Sep 20, 20261
Sep 19, 20261
Sep 18, 20261
Sep 17, 20261
Sep 16, 20261
Sep 15, 20261
Sep 14, 20261
Sep 13, 20261
Sep 12, 20261
Sep 11, 20261
Sep 10, 20261
Sep 9, 20261
Sep 8, 20261
Sep 7, 20261
npm weekly downloads

18+2 since Sep 7

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 202618
Dec 5, 20268
Dec 4, 202610
Dec 3, 202610
Dec 2, 20264
Dec 1, 202615
Nov 30, 202615
Nov 29, 202614
Nov 28, 202614
Nov 27, 202612
Nov 26, 202611
Nov 25, 202611
Nov 24, 20261
Nov 23, 20262
Nov 22, 20264
Nov 21, 20264
Nov 20, 20268
Nov 19, 20268
Nov 18, 20268
Nov 17, 20269
Nov 16, 202611
Nov 15, 202610
Nov 14, 202610
Nov 13, 202617
Nov 12, 202618
Nov 11, 202621
Nov 10, 202623
Nov 9, 202620
Nov 8, 202624
Nov 7, 202624
Nov 6, 202613
Nov 5, 202612
Nov 4, 202612
Nov 3, 20268
Nov 2, 202610
Nov 1, 20266
Oct 31, 20266
Oct 30, 20266
Oct 29, 20266
Oct 28, 20263
Oct 27, 20265
Oct 26, 20264
Oct 25, 20263
Oct 24, 20263
Oct 23, 20263
Oct 22, 20264
Oct 21, 20264
Oct 20, 20262
Oct 19, 20262
Oct 18, 20262
Oct 17, 20263
Oct 16, 20263
Oct 15, 20262
Oct 14, 20263
Oct 13, 20263
Oct 12, 20262
Oct 11, 20263
Oct 10, 20262
Oct 9, 20262
Oct 8, 20262
Oct 7, 20261
Oct 6, 20261
Oct 5, 20261
Oct 4, 20260
Oct 3, 20261
Oct 2, 20261
Oct 1, 20261
Sep 30, 20261
Sep 29, 20261
Sep 28, 20261
Sep 27, 20261
Sep 26, 20263
Sep 25, 20263
Sep 24, 20263
Sep 23, 20263
Sep 22, 20263
Sep 21, 20268
Sep 20, 20268
Sep 19, 20265
Sep 18, 20265
Sep 17, 20265
Sep 16, 20268
Sep 15, 20269
Sep 14, 20264
Sep 13, 20264
Sep 12, 20265
Sep 11, 202614
Sep 10, 202615
Sep 9, 202613
Sep 8, 202616
Sep 7, 202616

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

Health Score

33/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/1167287088-root.svg)](https://payloaddirectory.dev/plugins/1167287088-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1167287088-root"><img src="https://payloaddirectory.dev/badge/1167287088-root.svg" alt="Payload Directory"></a>
Updated Mar 2, 2026Created Feb 26, 2026Published Mar 2, 2026

README

Payload Dynamic Value Rich Text Plugin

A powerful Payload CMS plugin for the Lexical editor that allows you to designate field values as dynamic variables. These variables can be reused throughout your rich text content and are visually represented as interactive badges.

Features

  • Inline Autocomplete: Trigger a searchable list of available dynamic fields using @ (default) or a custom character (like #).
  • Visual Badges: Variables appear in the editor as clean, non-editable badges with a "VAR" prefix, making them distinct from regular text.
  • Automatic Field Resolution: Pull fields automatically from specified Collections and Globals, or provide manually defined fields.
  • Unit Tokenization: Variables are treated as single units—selecting or deleting them happens in a single action.
  • Clipboard Support: Copy and paste dynamic values between editors or documents while maintaining their data integrity.
  • Light & Dark Mode: Seamlessly integrates with Payload's admin UI theme.

Installation

pnpm add @od-labs/payloadcms-dynamic-value-richtext
# or
npm install @od-labs/payloadcms-dynamic-value-richtext

Basic Setup

Add the plugin to your payload.config.ts:

import { buildConfig } from 'payload'
import { dynamicValuePlugin } from '@od-labs/payloadcms-dynamic-value-richtext'

export default buildConfig({
  plugins: [
    dynamicValuePlugin({
      collections: ['company-settings', 'sites'],
      globals: ['contact-info'],
      trigger: '@',
    }),
  ],
  // ... rest of config
})

Configuration

In your Lexical editor configuration, add the DynamicValueFeature to your list of features:

import { DynamicValueFeature } from '@od-labs/payloadcms-dynamic-value-richtext'

// In your collection/global field definition:
{
  name: 'content',
  type: 'richText',
  editor: lexicalEditor({
    features: ({ defaultFeatures }) => [
      ...defaultFeatures,
      DynamicValueFeature(),
    ],
  }),
}

Plugin Options

OptionTypeDescription
collectionsCollectionSlug[]Automatically extract all text-based fields from these collections.
globalsGlobalSlug[]Automatically extract all text-based fields from these globals.
fieldsField[]Manually provide a list of Payload fields to be used as dynamic values.
triggerstringThe character that triggers the autocomplete popup. Defaults to @.

How it Works

  1. Resolution: The plugin recursively flattens the fields of your chosen collections and globals. For example, if you have a Global contact-info with a field email, it becomes available as contact-info.email.
  2. Injection: When you type the trigger character in the editor, a popup appears showing all available fields.
  3. Storage: The variable is stored as a custom DecoratorNode in Lexical, which holds a reference to the field path (value) and the display label.

Frontend Rendering (Important)

If you render Lexical content on your website with RichText, you must provide this plugin's JSX converters. Without this, Payload will show custom nodes as unknown node.

Use the plugin-provided wrapper component that injects converters for you:

import { DynamicValueRichText } from '@od-labs/payloadcms-dynamic-value-richtext/react'

<DynamicValueRichText data={page.content} payloadData={page} />

Option B: manual converters

import { RichText } from '@payloadcms/richtext-lexical/react'
import { DynamicValueJSXConverters } from '@od-labs/payloadcms-dynamic-value-richtext/jsx'

<RichText data={page.content} converters={DynamicValueJSXConverters} />

If you want to resolve the dynamic value from real document data at render time:

import { createDynamicValueJSXConverters } from '@od-labs/payloadcms-dynamic-value-richtext/jsx'

const converters = createDynamicValueJSXConverters({ data: page })

Development

To run the development environment:

  1. Clone the repository
  2. Install dependencies: pnpm install
  3. Create a .env in the dev folder (see .env.example)
  4. Run development: pnpm dev

Ownership

Created & Owned by OD LABS. This plugin is open and free for use to all under the MIT License.

Contributions

Contributions are welcome! If you have ideas for improvements or find any issues, feel free to open a Pull Request or create an Issue.

License

MIT

Similar plugins