Open caribouflex opened 3 years ago
if you check the code, the second parameter to mdToDraftjs is a nested object and not an object from string to string, as the declaration type incorrectly states. You need to pass something like this:
{
inlineStyles: {
Strong: {
type: 'BOLD',
symbol: '**',
},
Emphasis: {
type: 'ITALIC',
symbol: '*',
},
Delete: {
type: 'UNDERLINE',
symbol: '__',
},
},
};
@michaelg9 how do you know these keys like Strong
, Emphasis
and Delete
. I'm trying to implement underline and strikethrough.
I was able to work it out the strikethrough with Delete
but what would be the one for underline?
I just looked at the implementation code @jpmsegurado, this is not documented. In my case I replaced Delete with underline since I didn't need strikethrough. Tbh I didn't find any library that would be quite flexible with adding / replacing these styles to your own liking. If you do I'd be interested to know!
@jpmsegurado here's a list of the accepted ASTNodeTypes
Document = "Document", DocumentExit = "Document:exit", Paragraph = "Paragraph", ParagraphExit = "Paragraph:exit", BlockQuote = "BlockQuote", BlockQuoteExit = "BlockQuote:exit", ListItem = "ListItem", ListItemExit = "ListItem:exit", List = "List", ListExit = "List:exit", Header = "Header", HeaderExit = "Header:exit", CodeBlock = "CodeBlock", CodeBlockExit = "CodeBlock:exit", HtmlBlock = "HtmlBlock", HtmlBlockExit = "HtmlBlock:exit", HorizontalRule = "HorizontalRule", HorizontalRuleExit = "HorizontalRule:exit", Comment = "Comment", CommentExit = "Comment:exit", ReferenceDef = "ReferenceDef", ReferenceDefExit = "ReferenceDef:exit", Str = "Str", StrExit = "Str:exit", Break = "Break", BreakExit = "Break:exit", Emphasis = "Emphasis", EmphasisExit = "Emphasis:exit", Strong = "Strong", StrongExit = "Strong:exit", Html = "Html", HtmlExit = "Html:exit", Link = "Link", LinkExit = "Link:exit", Image = "Image", ImageExit = "Image:exit", Code = "Code", CodeExit = "Code:exit", Delete = "Delete", DeleteExit = "Delete:exit"
Hi, I'm using the custom dictionary to handle the
strikethrough
option. The conversion from DraftJS to markdown works fine. However converting from markdown to DraftJS does not work, and theinlineStyleRanges
raw value doesn't contains the strikethrough style.Here is the dictionary:
Here is how I convert :
Thanks for the help ✌️