Skip to content
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

paste-md plugin added #74

Merged
merged 1 commit into from Mar 9, 2020
Merged

paste-md plugin added #74

merged 1 commit into from Mar 9, 2020

Conversation

@horacioh
Copy link
Collaborator

horacioh commented Mar 2, 2020

Paste Markdown content and format it correctly:

  • tree-shakable plugin added
  • storybook example added
  • Tests (WIP)

Needs some improvements

In order to make it work, this plugin parse twice the content (MD -> HTML -> Slate). it's using marked to parse MD to HTML, and there is a way to parse to Slate directly. Would love some help from the community to achieve it.

@zbeyens zbeyens self-requested a review Mar 2, 2020
A: (el: any) => ({ type: 'link', url: el.getAttribute('href') }),
BLOCKQUOTE: () => ({ type: 'quote' }),
H1: () => ({ type: 'heading-one' }),
H2: () => ({ type: 'heading-two' }),
H3: () => ({ type: 'heading-three' }),
H4: () => ({ type: 'heading-four' }),
H5: () => ({ type: 'heading-five' }),
H6: () => ({ type: 'heading-six' }),
IMG: (el: any) => ({ type: 'image', url: el.getAttribute('src') }),
LI: () => ({ type: 'list-item' }),
OL: () => ({ type: 'numbered-list' }),
P: () => ({ type: 'paragraph' }),
PRE: () => ({ type: 'code' }),
UL: () => ({ type: 'bulleted-list' }),
Comment on lines +4 to +17

This comment has been minimized.

Copy link
@zbeyens

zbeyens Mar 2, 2020

Owner

Can you use the constant types? e.g. LINK

This comment has been minimized.

Copy link
@horacioh

horacioh Mar 2, 2020

Author Collaborator

of course! gonna check the constant types available :)

const { insertData, isInline, isVoid } = editor;

editor.isInline = element => {
return element.type === "link" ? true : isInline(element);

This comment has been minimized.

Copy link
@zbeyens

zbeyens Mar 2, 2020

Owner

Can you use the constant type LINK?

This comment has been minimized.

Copy link
@horacioh

horacioh Mar 2, 2020

Author Collaborator

yep!

};

editor.isVoid = element => {
return element.type === "image" ? true : isVoid(element);

This comment has been minimized.

Copy link
@zbeyens

zbeyens Mar 2, 2020

Owner

Can you use the constant type IMAGE?

This comment has been minimized.

Copy link
@horacioh

horacioh Mar 2, 2020

Author Collaborator

yep!

@horacioh horacioh self-assigned this Mar 2, 2020
@zbeyens

This comment has been minimized.

Copy link
Owner

zbeyens commented Mar 2, 2020

@horacioh I am creating issues for improvement and bug fixing #77

@zbeyens zbeyens merged commit cc7b4e1 into zbeyens:master Mar 9, 2020
2 of 6 checks passed
2 of 6 checks passed
ci ci
Details
Header rules - slate-plugins-next
Details
Mixed content - slate-plugins-next
Details
Pages changed - slate-plugins-next
Details
Redirect rules - slate-plugins-next
Details
netlify/slate-plugins-next/deploy-preview Deploy preview ready!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.