-
Notifications
You must be signed in to change notification settings - Fork 150
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
Copy Paste #147
Copy Paste #147
Conversation
437d7bd
to
878b659
Compare
878b659
to
5039e8c
Compare
Many tests added for parsing google-docs-style copy/pasted HTML |
@@ -6,10 +6,17 @@ import { | |||
VALID_MARKUP_SECTION_TAGNAMES | |||
} from 'content-kit-editor/models/markup-section'; | |||
|
|||
function popMany(arr, count) { |
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.
seems like good use for splice
. These should be the same:
popMany(array, 5);
array.splice(-5, 5, []);
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.
👍 it's actually array.splice(-length, +length)
(no []
), but yeah. Changing this. I did that because I can never remember the arguments to splice
Lookin' pretty sweet @bantic :-) :-) :-) :-) :-) |
4b8be3b
to
d76ffe1
Compare
@mixonic Ready for 👓 when you can. |
If you're curious to see what the HTML result of copy/pasting something from Google docs looks like, you can use this tool to see it. |
const mobiledoc = this.post.cloneRange(range); | ||
const html = `<div data-mobiledoc='${JSON.stringify(mobiledoc)}'></div>`; | ||
clipboardData.setData('text/html', html); | ||
event.preventDefault(); |
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.
@bantic this logic means we cannot meaningfully copy out of Content-Kit to third parties?
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.
Yeah.
The preventDefault is necessary for the text/html that we set on the above line to be preserved.
Rendering the HTML with the HTML Renderer and inserting it in the div above would preserve copy-to-outside-world functionality.
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.
Or, honestly, just letting natural browser copy do its thing for now would work prety well. We'll reparse the HTML on the way back in rather than using the already-serialized mobiledoc, but that doesn't seem to be a problem. Eventually we will want to keep that serialized mobiledoc so that cards can be preserved and copy/pasted around.
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.
Aw man that would be cool. Opened a followup #180
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.
Or, honestly, just letting natural browser copy do its thing for now would work prety well. We'll reparse the HTML on the way back in rather than using the already-serialized mobiledoc, but that doesn't seem to be a problem. Eventually we will want to keep that serialized mobiledoc so that cards can be preserved and copy/pasted around.
Ah, per another comment here I was surprised not to see cards being copied. I think both these things need followups if they are not in scope here. Copying mobiledocs cards should be pretty trivial.
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.
Cool, after this merges I'll add a follow-up PR to address #180.
d76ffe1
to
a5c9b46
Compare
needs to handle "cut" in addition to "copy" event |
* Rename PostParser -> DOMParser, remove old DOMParser * Add many fixtures with example HTML from copying in a google doc document * Add postEditor#insertPost. It returns a Position used to position the cursor after inserting content * Only allow certain attributes from parsed content * filter markup attributes at instantiation * when copying, override the native HTML and text copied to display a link to copy-paste issue #180 * copy/paste cards and lists * Handle cut event fixes #111
facceee
to
c2bbafe
Compare
ready to merge
This adds support for copy-pasting content from one Content Kit to another, and from Google Docs to Content-Kit.
VALID_ATTRIBUTES
)For a separate PR:
For later:
fixes #111