Skip to content

Instantly share code, notes, and snippets.

View davidnus's full-sized avatar

David Sun davidnus

View GitHub Profile
import { TextNode } from 'lexical';
/***
* Example of custom warning node.
* This node adds the additional properties for rendering on top of
* a basic Lexical TextNode.
*/
export class WarningNode extends TextNode {
/**
* Assume you want to add the following attributes to an extended node
@davidnus
davidnus / WarningNodeExample.md
Last active March 26, 2025 13:15
Interoperability Between an Extended Lexical Node and Codox

Creating an extended TextNode to work with Codox

This guide explains how to extend a foundational Lexical node, i.e. nodes found under https://github.com/facebook/lexical/blob/main/packages/lexical/src/nodes/, to work with Codox for real-time collaboration.

The following key steps will be explained:

  1. Extension: The recipes are largely similar for most Lexical nodes extensions
  2. Serialization: Converting the extended Lexical node into a Codox-compatible JSON format.
  3. Deserialization: Converting a Codox JSON node back into a Lexical-compatible format.