DraftJS is not actually stateless
See original GitHub issueWhen I tried to render DraftJS into an iframe window, for example:
ReactDOM.render(<DraftEditor .../>,
document
.getElementById('some_iframe')
.contentWindow
.document
.getElementById('some_inner_element'))
inside the DraftJS functions, there were window
, global
, document
variables, which were global variables, still referenced to the parent window (the window that run the above snippet).
So, global.getSelection
, node !== document.documentElement
didn’t work.
Render components inside iframe is important for isolating CSS especially rem
unit.
Looking forward to having a discussion around this. Thank you all!
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Issues and Pitfalls - Draft.js
This article addresses some known issues with the Draft editor framework, as well as some common pitfalls that we have encountered while ...
Read more >Draft.js And Why You Should Contribute | by rajaraodv - Medium
One of the biggest reasons is how elegant it's rich text editor is — it looks so simple yet it's so powerful. I...
Read more >What is Slate.js, and will it replace Quill and Draft.js?
The Slate editor is stateless, utilizing immutable data structures via React and Immutable.js, making it much easier to reason about code ...
Read more >Draft-js and Redux - the perfect couple - React Rocket
and we possibly also like redux, the go to state management system for react. The two of them are actually a really good...
Read more >Draft.js – Rich Text Editor Framework for React - Hacker News
Note that it's not "flat WYSIWYG" where each character/line has a style; a sub-list is actually inside the parent list, not just a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have a PR in React that fixes
SelectEventPlugin
,ReactInputSelection
, andReactDOMSelection
for cross-iframe compatibility: https://github.com/facebook/react/pull/7936It depends on a PR in fbjs to make some of those utilities iframe compatible: https://github.com/facebook/fbjs/pull/188
Next up is a PR specifically for this issue, but it, of course, will depend on those other two PRs. I’m hopeful that the final result will be a version of draft that can be rendered into an iframe (like what react-frame-component does) and still have all events and functionality fully preserved. This will also make it easy to have multiple selections, which makes linking a section of text, for example, much nicer. I made a demo of a textarea where you can link portions of it to demonstrate that use case.
Without the changes in the React + fbjs PRs: http://codepen.io/acusti/pen/EgQxJG?editors=0011 With the changes in the React + fbjs PRs: http://codepen.io/acusti/pen/qaxBby?editors=0011
@acusti Thanks! It works on my side now. I was using react-dom 16.4, upgraded to 16.5 and managed to alter the instanceOf validations. you are really helpful.