#Are there any good lexical richtext parsers out there?

22 messages · Page 1 of 1 (latest)

outer pivot
#

I'm struggling to find a good lexical to jsx parser.. the one I have works, but is missing a few bits.

marble pewterBOT
worthy chasm
#

To serialise it into react components?

outer pivot
worthy chasm
rocky swan
worthy chasm
#

Super nice. @rocky swan

#

Definitely a lot cleaner

rocky swan
#

Yep! And that way, it's extensible

#

Could use different converters for different richtext fields / different platforms for example

worthy chasm
#

Nice. Did you guys fix the bug with blocks and being able to add multiple blocks and use the editor

rocky swan
#

Which bug exactly?

worthy chasm
#

Looks like it's still an issue

outer pivot
frigid cloud
worthy chasm
#

@frigid cloud @outer pivot I'm pretty sure I can write an example of a block converter. Won't have a chance til tomorrow though

frigid cloud
outer pivot
# frigid cloud <@540179112053178368> did you find something to support blocks?

I already had a snippet to render the html and blocks but was looking for one that had a few more features.

The blocks part I use is below:
RenderBlocks.tsx

"use client";

import { components } from "../_lib/blocks";
import type { Block1Type} from "./Block1";
import type { Block2Type} from "./Block2";

export type Fields = Block1Props | Block2Props;

type Props = {
    fields: Fields;
};

const Block: React.FC<Props> = ({ fields }) => {
    const Block: React.FC<any> = components[fields.blockType!];

    if (Block) {
        return <Block key={fields.id} {...fields} />;
    }

    return null;
};

export default Block;

blocks.ts:

"use client";

import Block1 from "./Block1";
import Block2 from "./Block2";

export const components = {
    "block1": Block1,
    "block2": Block2,
};

inside lexical serializer:

if (_node.type === "block") {
    return <Block fields={_node["fields"]} key={index} />;
}

Hope that makes sense

worthy chasm
#

@outer pivot what type of features

outer pivot
#

@worthy chasm I forgot what all of them were off the top off my head, but one was centering text from lexical