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

Handle pasting from different sources #1442

Closed
mtias opened this issue Jun 26, 2017 · 9 comments
Closed

Handle pasting from different sources #1442

mtias opened this issue Jun 26, 2017 · 9 comments
Assignees
Labels
[Feature] Block API API that allows to express the block paradigm. [Feature] Parsing Related to efforts to improving the parsing of a string of data and converting it into a different f [Type] Task Issues or PRs that have been broken down into an individual action to take
Milestone

Comments

@mtias
Copy link
Member

mtias commented Jun 26, 2017

We are adding a paste.js to Block API files in @iseulde #1331.

This will be the place to centralize the handling of content being pasted from different sources (WordPress, markdown, google docs, word, pages, etc). The intention is to convert things that are pasted into proper blocks with proper attributes.

Related: #1180, #1423.

@mtias mtias added [Feature] Block API API that allows to express the block paradigm. [Feature] Parsing Related to efforts to improving the parsing of a string of data and converting it into a different f [Type] Task Issues or PRs that have been broken down into an individual action to take labels Jun 26, 2017
@mtias mtias added this to the Beta 3 milestone Jun 26, 2017
@mtias mtias changed the title Handling pasting from different sources Handle pasting from different sources Jun 26, 2017
@youknowriad
Copy link
Contributor

related #589 #590 since it could be used to convert existing posts?

@nic-bertino
Copy link

We discussed detection of embeddable content through paste in #1325. The simple idea being that if an Instagram URL is pasted in the editor of one block, the UI would suggest creating a new embed block with that content. Let me know if that's outside of the scope of this issue.

@jasmussen
Copy link
Contributor

Added @georgeh also, per his request, as he's worked on some pasting on WordPress.com in the past. George feel free to unassign yourself if this, up on closer inspection, isn't up your alley after all.

@jasmussen
Copy link
Contributor

We should also split this ticket up into one for pasting from Word, one for pasting from Google Docs.

@georgeh
Copy link
Contributor

georgeh commented Jul 6, 2017

This isn't really up my alley but I'm eager to go down new allies. I may try to rope @nosolosw into this too, since he worked on some paste-detection in Calypso.

It seems that #1524 went a long way toward improving pasting. In testing Google Docs and Pages, they both keep the structure but lose some formatting. I'm AFK for the next week but when I get back will dig into it more deeply. If there's a more urgent need or someone else wants to pick this up while I'm away, feel free. Otherwise I'll move from tinkering to a more earnest strategy the week of the 17th.

@mtias mtias modified the milestones: Beta 0.5.0, Beta 0.4.0 Jul 6, 2017
@mtias mtias modified the milestones: Beta 0.6.0, Beta 0.5.0 Jul 14, 2017
@ellatrix
Copy link
Member

Been talking to @georgeh a bit, and this seems like a good flow:

  • We'd have general processors and specific processors. Running a specific processor would rule out the others, e.g. we don't run both Google Docs and Word specific processors.
  • On the content, we run a test functions that the specific processors have. Here they look for clues to detect the paste source. Ideally this should just be some .test() or .indexOf().
  • We run the special processor (no others). They should prepare for the general processor. In other words, the should return a semantic structure from a strange source specific structure.
  • We run the general processors which will clean up attributes (strip IDs, classes, styles), and turn the semantic structure into blocks.

@ellatrix
Copy link
Member

Unassigning as @georgeh is working on the Google Docs part, and possibly the API part. Afterwards I'd be interested in making a MarkDown processor. I'm also willing to take over at any point.

@ellatrix ellatrix removed their assignment Jul 25, 2017
@georgeh
Copy link
Contributor

georgeh commented Jul 26, 2017

Many of the blocks I've tested with Google Docs have worked correctly. The exceptions are:

  1. <tbody> tags seems to break TinyMCE - I don't think this is G Docs specific but would be nice to fix
  2. Paragraph alignment is not showing up in the copied data
  3. Images are appearing in the copied data

So what does work? Paragraphs, headings, and lists create the blocks you would expect.

I have a pipeline system for processing transformations, and they provide a solid hook for future transformations such as markdown, stripping classes, etc. I'll get a PR in to deal with the basics and we can iterate from there.

@mtias
Copy link
Member Author

mtias commented Jul 28, 2017

Closing this one as a first pass. We can create individual issues from now on for remaining pieces and improvements.

@mtias mtias closed this as completed Jul 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Feature] Parsing Related to efforts to improving the parsing of a string of data and converting it into a different f [Type] Task Issues or PRs that have been broken down into an individual action to take
Projects
None yet
Development

No branches or pull requests

6 participants