Changing Rich Text Font

Hi everyone,

I want to create a data hook (after Query) that takes the text currently in a column called “description,” copies it to “descriptionUse” and changed the font size. Everything else should be the same and both fields are rich text. The code I am currently trying (borrowed from some other sources, so apologies if it doesn’t make sense) is as follows:

const modifyTextWithNewStyle = (text)=>‘

{text}

export function Opportunities_afterQuery(item, context) {

item.descriptionUse = item.description &&
modifyTextWithNewStyle(item.description);

return item;
}

I can’t get the field to populate the {text} element. Help is appreciated, thanks!

Bump. Thanks all

Hi,
You can simply change the HTML of the text element, however, you should do it from the frontend code and not where the hook code is written.

Best,
Tal.

Thanks, Tal. Being new to this, how do I do that? What do you mean from the text element - on the dynamic page itself? What would the code look like?

Yes, you should edit it from the page code itself. I recommend console.log the text element to check its HTML code. This way, you’ll know how exactly you should edit the text element HTML . It’s a similar scenario to this one , only that here you want to change the font size instead of underline the text and the event is different (onClick event I assume, it depends on your use case).

Thanks. Will this still work although it’s being linked to rich text?

Yes.

Sorry, I’m not sure I follow. How do you actually change the font/size of rich text?

Please add a new post rather than bumping up an old thread from 2018. Add a link to refer back to this one if needed.

Also, this is not a code related issue and you would be better suited going through Wix Support for more help with this.
https://support.wix.com/en/about-wix/contacting-wix-customer-care
https://support.wix.com/en/article/connecting-text-elements
https://www.wix.com/corvid/reference/$w.Text.html