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
A way to drag outside to iframe #1496
Comments
I found an easier solution to simplify this code, but I am not sure if this one is a better solution. Hope to help you to fix this issue.
|
@HsuTing It's easier and better. But still bound to HTML5Backend interface. If HTML5Backend changes addEventListeners => addListeners, our web would be broke down |
Really cool idea, I'll play around with it when I get back from the hike
…On Tue, Aug 6, 2019, 11:43 PM 晓爽 ***@***.***> wrote:
@HsuTing <https://github.com/HsuTing> It's easier and better. But still
bound to HTML5Backend interface. If HTML5Backend changes addEventListeners
=> addListeners, our web would be broke down
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#1496?email_source=notifications&email_token=AAA3XCDZJS3V5E7YISDRUC3QDJVJLA5CNFSM4IIMWOQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3XL66Y#issuecomment-518963067>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAA3XCGHNHO3M3CSL5VRUQTQDJVJLANCNFSM4IIMWOQQ>
.
|
It's a great approach and works for me. |
When trying with typescript I get an error is there any way to fix this in TS ? |
addEventListeners isn't exposed on the Backend interface; and I don't want to expose it because it's DOM/Browser specific. I think what we should probably do is something like: // detect if SSR mode
const DEFAULT_GLOBAL_CONTEXT = typeof window !== 'undefined' ? window : global
const DndFrame = ({ children, globalContext = DEFAULT_GLOBAL_CONTEXT}) => {
const { dragDropManager } = useContext(DndContext);
const { window } = useContext(FrameContext);
const backend = useMemo(() => dragDropManager.getBackend(), [dragDropManager])
useEffect(() => {
// This will required adding an initialize() method to the Backend interface.
// Backend constructors will have to thunk over to it. It could replace constructors, but that would be semver major.
backend.initialize(dragDropManager, globalContext)
backend.setup()
}, [globalContext]);
return children;
}; |
Create a repo for this. And resolve the style problem. |
In case anyone comes across this, I just added the |
For future visitors, there's a simple solution: https://react-dnd.github.io/react-dnd/examples/dustbin/iframe |
This solution doesn't work for me. The example shows dragging item within the iframe, not from outside to inside iframe. I tried this solution from @HsuTing and it still works. |
Is your feature request related to a problem? Please describe.
React limits that drag-and-drop within a single HTML document. Somehow we need drag something outside to iframe inside.
Describe the solution you'd like
I find that dnd HTML5backend just trigger drag callbacks in window. So if we can make the components inside iframe trigger those callback.And
React.createPortal
make components inside iframe have same DndProvider with outside.It works, luckily. But i worry about may some problem i didn't notice.And the code is not so convenient with HTML5Backend.Describe alternatives you've considered
May you can export some options with HTML5Backend.
The text was updated successfully, but these errors were encountered: