-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve markdown transformers #3886
Improve markdown transformers #3886
Conversation
Hi @Godefroy! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI integrity is failing for some reason - looks like prettier
packages/lexical-playground/src/plugins/MarkdownTransformers/index.ts
Outdated
Show resolved
Hide resolved
packages/lexical-playground/src/plugins/MarkdownTransformers/index.ts
Outdated
Show resolved
Hide resolved
Thanks @acywatson for the code review! I adapted my code. Also, I took the liberty to remove |
} | ||
|
||
return output.join('\n'); | ||
}, | ||
regExp: TABLE_ROW_REG_EXP, | ||
replace: (parentNode, _1, match) => { | ||
// Header row | ||
if (TABLE_ROW_DIVIDER_REG_EXP.test(match[0])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zurfyx will this be a problem for the tables works you're currently doing? I doubt it, but wanted to check.
@@ -95,7 +95,7 @@ export default function EmojiPickerPlugin() { | |||
|
|||
useEffect(() => { | |||
// @ts-ignore | |||
import('./emoji-list.ts').then((file) => setEmojis(file.default)); | |||
import('../../utils/emoji-list.ts').then((file) => setEmojis(file.default)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for this
@@ -41,16 +42,16 @@ type TextFormatTransformersIndex = Readonly<{ | |||
|
|||
export function createMarkdownImport( | |||
transformers: Array<Transformer>, | |||
): (markdownString: string) => void { | |||
): (markdownString: string, node?: ElementNode) => void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with this - maybe a nit to call it targetNode or something that indicates that it's the parent of whatever the import creates.
Separately, why shouldn't markdown work more like HTML, where you just get back some nodes and then insert them wherever you want?
I'm ok with this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separately, why shouldn't markdown work more like HTML, where you just get back some nodes and then insert them wherever you want?
Yep, should be changed to work that way
Does Lexical/Playground support working with elements like this (Toggle elements mixed with Markdown) and importing/exporting them from/to markdown?
|
I need to import a markdown document with tables containing markdown in each cell.
Problem:
$convertFromMarkdownString
is currently not called inside of table cells and doesn't take a target node as a parameter, it uses root node only.The
TABLE
transformer needs to be adapted, as well ascreateMarkdownImport
(which is used by$convertFromMarkdownString
) andcreateMarkdownExport
.This pull request adds:
You can test with this markdown example: