From 727d47d0213fae7bd87e92d974ef76a8aa14feff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Jablo=C3=B1ski?= <43938777+GermanJablo@users.noreply.github.com> Date: Tue, 10 Dec 2024 16:38:14 -0300 Subject: [PATCH] update docs --- .../docs/concepts/node-customization.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/lexical-website/docs/concepts/node-customization.md b/packages/lexical-website/docs/concepts/node-customization.md index 4185461bfdf..d157524d451 100644 --- a/packages/lexical-website/docs/concepts/node-customization.md +++ b/packages/lexical-website/docs/concepts/node-customization.md @@ -7,7 +7,7 @@ Originally the only way to customize nodes was using the node replacement API. R Most of the time when users want to customize a node they just want to add a property to it, which ends up being reflected as a class in the dom element. -To satisfy that need we have introduced two new methods to all nodes: `getClasses` and `mutateClasses`. +To satisfy that need we have introduced two new methods to all nodes: `getClasses` and `setClass`. ```ts export function CoolRedPlugin() { @@ -18,15 +18,13 @@ export function CoolRedPlugin() { onClick={() => { editor.update(() => { $forEachSelectedTextNode((textNode) => { - // Allows mutation of the classes object where the key-value pairs follow the - // format prefix-suffix for string values, or just prefix for true boolean values. - textNode.mutateClasses((classes) => { - classes.bg = 'red'; // adds the class bg-red - // Perhaps you don't want to allow the same node to have - // both text and background color defined at the same time... - delete classes.text; // ...so here you remove the class text-[color]. - classes.cool = true; // adds the class cool (true values don't add a suffix) - }); + // setClass mutates the classes object where the key-value pairs follow the + // format prefix-suffix for string values, or just prefix for boolean values. + textNode.setClass('bg', 'red'); // adds the class bg-red + // Perhaps you don't want to allow the same node to have + // both text and background color defined at the same time... + textNode.setClass('text', false); // ...so here you remove the class text-[color]. + textNode.setClass('cool', true); // adds the class cool (true values don't add a suffix) }); }); }}>