Open flippidippi opened 1 month ago
Hi @flippidippi,
We do not have handler support for rte.getFieldConfig()
, did you mean rte.getConfig
?
For rte.getConfig
we do not have type support added.
This is planned for the next release.
Let me know if you have any further questions.
This is the example I have. If we needed to be able to control the color of the highlight at a field level config.
const Highlight = RTE('highlight', rte => {
// Get the field config
// @ts-expect-error
const fieldConfig = rte.getFieldConfig()
return {
title: 'Highlight',
icon: <Icon style={{ padding: '0 6px' }} icon='Edit' size='original' />,
display: ['toolbar', 'hoveringToolbar'],
elementType: ['text'],
render: (props: any) => {
return (
<span style={{ background: fieldConfig?.color ?? 'rgba(251, 243, 219, 1)' }}>
{props.children}
</span>
)
}
}
})
Hi @flippidippi
Thanks for the snippet, but we do not have any handler support for rte. getFieldConfig
Its rte.getConfig
and we'll have a fix for type missing for rte.getConfig
handler in next release i.e. v2.0.3.
Let me know if there's anything I can help with.
So does rte.getConfig
get the config at the field level? Or is there a supported way to do that?
So does
rte.getConfig
get the config at the field level? Or is there a supported way to do that?
Yes, @flippidippi rte.getConfig
retrieves the values set in config UI location.
For Eg --> If you are saving any color i.e. fieldConfig.color
Similar to shown in above comments.
I actually don't see rte.getConfig
in the types either, neither seem to be on IRteParam
.
And this is a screenshot of the difference between the data I get back from each. I don't see the field config in the rte.getConfig
.
@flippidippi the type support for rte.getConfig
in IRteParam
would be a part of next release.
An example usage post-release for reference
const examplePlugin = RTE("testApp", async (rte) => {
const config = await (rte as IRteParam).getConfig();
}
Where IRteParams would have getConfig
as getConfig: <T>() => { [key: string]: T };
Will keep you posted once it is released.
It seems like
IRteParam
is missing types, likerte.getFieldConfig
and more. We are trying to create a custom RTE plugin and need to get the field config but need to use@ts-expect-error
to access.