question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DraftJS is not actually stateless

See original GitHub issue

When 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:open
  • Created 7 years ago
  • Reactions:2
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
acusticommented, Nov 5, 2016

I have a PR in React that fixes SelectEventPlugin, ReactInputSelection, and ReactDOMSelection for cross-iframe compatibility: https://github.com/facebook/react/pull/7936

It 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

1reaction
gjulivancommented, Oct 9, 2018

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found