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 **MarkDown** #2531

Merged
merged 2 commits into from Sep 28, 2017
Merged

# Paste **MarkDown** #2531

merged 2 commits into from Sep 28, 2017

Conversation

ellatrix
Copy link
Member

@ellatrix ellatrix commented Aug 24, 2017

This adds MarkDown parsing to the paste handling if the posted content is plain text. It won't parse anything if you don't paste from a plain text editor.

This is a WIP... Still need to have a look how to handle inline text better and at the parsers available. Any suggestions? Showdown is is used by Ghost so I picked that for now.

@ellatrix ellatrix added [Feature] Raw Handling Related to the ability to convert content to blocks, paste handling, etc [Type] Enhancement A suggestion for improvement. labels Aug 24, 2017
@ellatrix ellatrix requested a review from mtias August 24, 2017 22:21
@aduth
Copy link
Member

aduth commented Aug 25, 2017

What's the impact on bundle size by pulling in showdown ? Also curious if this is something best left for plugin territory...

@ellatrix
Copy link
Member Author

ellatrix commented Aug 25, 2017

10.7 kb gzipped... I'm fine either way, I think this is a nice surprise enhancement. I mainly want to show here that it's easily possible to add, and that not everything would run through the parser, only plain text.

Also this may be a place then where we would want to add a filter for plugins.

@dmsnell
Copy link
Contributor

dmsnell commented Sep 16, 2017

@codecov
Copy link

codecov bot commented Sep 22, 2017

Codecov Report

Merging #2531 into master will decrease coverage by 0.03%.
The diff coverage is 22.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2531      +/-   ##
==========================================
- Coverage   33.69%   33.65%   -0.04%     
==========================================
  Files         185      185              
  Lines        5594     5615      +21     
  Branches      976      980       +4     
==========================================
+ Hits         1885     1890       +5     
- Misses       3141     3155      +14     
- Partials      568      570       +2
Impacted Files Coverage Δ
blocks/library/code/index.js 57.14% <ø> (ø) ⬆️
blocks/library/preformatted/index.js 50% <ø> (ø) ⬆️
blocks/api/paste/utils.js 82.97% <0%> (-14.53%) ⬇️
blocks/api/paste/test/integration/index.js 100% <100%> (ø) ⬆️
blocks/editable/index.js 10.5% <20%> (+0.18%) ⬆️
blocks/api/paste/index.js 79.31% <40%> (-8.69%) ⬇️
components/form-file-upload/index.js 66.66% <0%> (-4.77%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a93c553...aa73265. Read the comment docs.

@ellatrix
Copy link
Member Author

Okay, so this will now do two things.

  1. We're going to look at the plain text the clipboard API is giving us if the HTML is plain. If the source (editor) is plain text, this will be more reliable than any HTML made up by the browser.
  2. If we have some reliable plain text, then we convert any markdown in it. If the user pastes HTML, this will never run.

The PR uses showdown, but we can easily use anything else later of course.

@ellatrix ellatrix requested a review from aduth September 22, 2017 13:53
@ellatrix ellatrix merged commit 410caac into master Sep 28, 2017
@ellatrix
Copy link
Member Author

Merged after 👍 form @mtias and @dmsnell.

@ellatrix ellatrix deleted the try/paste-markdown branch September 28, 2017 13:49
@aduth
Copy link
Member

aduth commented Sep 28, 2017

We should have updated package-lock.json here from the added dependency. npm install in a clean clone while running npm 5+ will introduce changes.

@aduth
Copy link
Member

aduth commented Sep 28, 2017

Updated in ff1ef2b

@ellatrix
Copy link
Member Author

Thanks @aduth! Sorry about that, wasn't aware of package-lock.

@aduth
Copy link
Member

aduth commented Sep 28, 2017

No worries, since we don't explicitly target the version of Node that comes bundled with npm5+ (until LTS release in October), we maybe shouldn't have the package-lock.json at all, but the niceties of 5+ are enough for me to want to run it anyways 😄

@youknowriad
Copy link
Contributor

@aduth The package-lock.json locks only the dependencies of the dependencies since 5.1.0 which makes it useless IMO. (it's not the same as shrinkwrap or yarn.lock)

@aduth
Copy link
Member

aduth commented Sep 29, 2017

package-lock.json locks only the dependencies of the dependencies since 5.1.0 which makes it useless IMO

That still seems like a pretty good benefit on its own, if you ask me.

Part of it is that it's automatic, so it becomes a nuisance to be merely running npm install and having changes introduced. If we really didn't care, I'd want to find a way to turn that off.

But then, I saw what you'd referred to come past, but I'd have to think it still provides some benefit; surely they wouldn't make the thing useless? 😄 I'll have to do some reading over the weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Raw Handling Related to the ability to convert content to blocks, paste handling, etc [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants