#Color text in WYSIWIG editor

38 messages · Page 1 of 1 (latest)

cursive sandal
#

hello everyone, please tell me, I need to add a color palette to the wysiwig payload cms editor to color plain text in different colors, tell me, please, how best to do this? through which tool? integrate slate js?

faint otter
#

I'm on my phone rn, but there is an open topic about this very thing

#

I'll link it when I'm back or @hot dagger maybe

hot dagger
#

they added a custom leaf to the richtext editor there which adds support for colors!

#

2nd option would be using my lexical richtext editor plugin, which has colors integrated by default.
Such a perfect timing to shill for it!

cursive sandal
#

wow great please give me a link to your plugin I'll try your solution

hot dagger
#

Sure! https://github.com/AlessioGr/payload-plugin-lexical (don't install via npm/yarn, you gotta copy the files manually as described in the readme)

keep in mind this is a completely new richtext editor. Completely separate from the default slate one. Meaning you can't transfer over your existing content.

if you want to stay with slate, you can check out how they added color as a custom leaf, that should be pretty simple too

GitHub

Extends payload CMS with Meta's lexical RichText editor - a much more advanced and customizable richtext editor - GitHub - AlessioGr/payload-plugin-lexical: Extends payload CMS with Meta&am...

rich bramble
#

@hot dagger Do I still need to copy it over or can i install it using yarn? as the readme has changed. Been getting this error Cannot update a component (Form) while rendering a different component (LexicalRichTextFieldComponent2). To locate the bad setState() call inside LexicalRichTextFieldComponent2

hot dagger
rich bramble
#

Oh Okay, I'll try it in production

#

This might be a stupid question but how did you setup a LexicalRichText Block

hot dagger
rich bramble
#

Cool thanks so much. Really love the work you're doing

#

Oh and congratulations on being mentioned as a potential Slate replacement

rich bramble
#

Still getting the same error in prod

proud fractal
#

@rich bramble What error are you getting?

#

You should be able to install it via yarn/npm now, in addition, it requires the latest version of Payload

rich bramble
#

@proud fractal Im getting this error TypeError: (0 , v.formatListDrawerSlug) is not a function at t.default (main.da1d14a4d95c8ef58142.js:81:107808) at oV (main.da1d14a4d95c8ef58142.js:440:63477) at l (main.da1d14a4d95c8ef58142.js:440:120107) at lu (main.da1d14a4d95c8ef58142.js:440:111552) at ls (main.da1d14a4d95c8ef58142.js:440:111480) at la (main.da1d14a4d95c8ef58142.js:440:111343) at s4 (main.da1d14a4d95c8ef58142.js:440:107713) at s3 (main.da1d14a4d95c8ef58142.js:440:106680) at x (main.da1d14a4d95c8ef58142.js:470:1373) at MessagePort.O (main.da1d14a4d95c8ef58142.js:470:1903)

proud fractal
#

And to confirm it's not working right?

#

(There should be one lingering error that is non-breaking)

#

But that list drawer issue sounds like a version issue

#

Can you check your package.json and tell us the version of Payload you're on

rich bramble
#

You're right

#

I just updated payload. Seems to be working. Thanks so much @proud fractal @hot dagger

proud fractal
#

Woot! Glad to hear it's working. @hot dagger did some great work getting this implemented

rich bramble
#

He really has

#

How would I go about getting this serialized and implemented on the frontend @proud fractal. My project is very similar to payloadcms/website

proud fractal
#

So have you worked with displaying the JSON data prior?

#

The rich text field will expose a bunch of data

#

That you can parse and display

rich bramble
proud fractal
#

Ah okay, the RTF will provide "leaves" or basically the content broken down into objects

#

If you copy the JSON from the RTF here, i can walk you through it

hot dagger
hot dagger
#

@rich bramble @proud fractal just fixed that "Cannot update a component (Form) while rendering a different component (LexicalRichTextFieldComponent2)." error FINALLY in v0.5.0 ^^
Also should come with better performance as the lexical field now does less unnecessary re-renders

proud fractal
#

Nice work my friend!