-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Description
Hey,
I would like to know if it is possible to use the toggleCustomInlineStyle method on an entity (RawDraftEntity) ?
For example, I have an html code with custom tags
<var data-name="$test">
I use htmlToDraft method for convert this code with a customChunkRenderer
private static customChunkRenderer(nodeName: string, node: HTMLElement): RawDraftEntity | undefined {
let draftEntity: RawDraftEntity | undefined;
if (nodeName === 'var') {
const data = {
name: node.dataset.name
};
draftEntity = {
type: VariableType,
mutability: 'IMMUTABLE',
data: data
};
}
return draftEntity;
}
When I want to change the text size of my item, with the toggleCustomInlineStyle method, I get the following error message
TypeError: record is undefined
removeStyle
.../node_modules/draft-js/lib/CharacterMetadata.js:56
53 | };
54 |
55 | CharacterMetadata.removeStyle = function removeStyle(record, style) {
> 56 | var withoutStyle = record.set('style', record.getStyle().remove(style));
| ^ 57 | return CharacterMetadata.create(withoutStyle);
58 | };
59 |
Then I want to retrieve the HTML code with the style applied to my item, with draftToHtml and my method customEntityTransform
private static customEntityTransform(...args): any {
const entity = args[0] as RawDraftEntity;
let value: string | undefined;
if (entity.type === VariableType) {
value = '<var data-name="' + entity.data.name + '">';
}
return value;
}
Thank you very much
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels