-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Rendering to IFrame #215
Comments
Hey @vleletko interesting use case! How do other editors like Draft and Prosemirror handle this case? It seems like an easy solution would be to render the iframe using a separate route in your application? |
Hi, thanks for fast reply. Draft has same problem. The goal is to make detached css context for editor itself, but still have single react component tree. So iframe is always part of the editor. I guess the best example is a page builder app. Consider having property sheet and palette in top level document, They will have own styles. This will guarantee that generated document will have same appearence as document in editor. I guess it is possible to keep all top level styles under some root css class. About separate route: Option 2Actually we can make it one abstraction level deeper & introduce some kind of factory/service for Slate components to access |
If we find appropriate solution, I can make PR. |
Interesting, great use case to try to solve for. I could see myself having a similar need. I'd be down for a PR that adds support for this! I think we'd either need to accept a |
Will do PR. About props vs context. I see that there is So I suggest to use React context. @ianstormtaylor, what do you think? |
@vleletko good point, that sounds good. I've only ever consumed context, so I'll need to research to review properly, but I like that direction :) thanks! |
I think we can close this now. |
There is a problem in current version of Slate related to IFrame rendering.
You can check it here: https://jsfiddle.net/tq6n2jf8/2/
Use case:
Problem
Since code is evaluated in parent document context, Slate is using wrong
document
instance.It directly references
window.document
incomponents/content.js
components/leaf.js
plugins/core.js
utils/find-dom-node.js
Options
1, 2 - We can use React context mechanism or direct property propogation (did not investigated property option) with fallback to
window.document
.3 - Could be solved by configuring
plugins/core
fromEditor
component props or by context value.4 - Add document as additional parameter. Maybe show console warning if parameter is not set (and use
window.document
as fallback).The text was updated successfully, but these errors were encountered: