ianstormtaylor / slate

A completely customizable framework for building rich text editors. (Currently in beta.)
http://slatejs.org
MIT License
30.03k stars 3.26k forks source link

Discussion: MIME-typing the Document / Document Fragment? #1024

Open danburzo opened 7 years ago

danburzo commented 7 years ago

Filed under Bigger Fish To Fry But:

Working on the copy-paste issues, it occurred to me that in a world dominated by Slate-based rich text editors, it would pose a problem to copy and paste between editors with incompatible schemas.

To that end, I'm opening a discussion on whether a Slate Editor should mark its identity in some way (as sort of MIME type), and that information can be serialized in data-slate-fragment.

ianstormtaylor commented 7 years ago

Sounds like a smart idea to me!

Paste/Drop being a backdoor for non-conforming documents to sneak in is probably the hardest issue for us to solve well—one of the big tradeoffs for having total flexibility. Open to any ideas that help make that simpler!

Having a simple mime type for the document sounds like a good way to test for it!

justinweiss commented 5 years ago

I've already seen some examples of this in the wild, so it might be time :-) I think this will be an even bigger problem when we use schema to decide between blocks and inlines, since node type won't match between editors.

Here's the strategy I'm considering:

Does that make sense? Anything seem to be missing?

ianstormtaylor commented 5 years ago

@justinweiss sounds awesome.

  • move getEventTransfer to editor.getEventTransfer and setEventTransfer to editor.setEventTransfer so they have access to editor props, specifically contentType. This also matches what happened with findDOMPoint, etc.

When we move these, let's rename them to getDOMEventTransfer I think, for clarity and symmetry with the other DOM helpers.

Nantris commented 3 years ago

Any news on this? Slate is a lot more popular these days.

justinweiss commented 3 years ago

This was something I had planned to take on after https://github.com/ianstormtaylor/slate/pull/2933, but then 0.50 landed. Since our main implementation is still pre-refactor, upstreaming work hasn't been a priority.

I haven't looked into the current state of copy / paste post-refactor, but I don't think this would be hard to layer on.