Skip to content

Commit 27964fe

Browse files
committed
BUGFIX: fix "Cannot have two HTML5 backends" error
1 parent 5586725 commit 27964fe

File tree

4 files changed

+74
-40
lines changed

4 files changed

+74
-40
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import HTML5Backend from 'react-dnd-html5-backend';
2+
import {DragDropContext} from 'react-dnd';
3+
4+
// This must be a singleton, in order to not run into "Cannot have two HTML5 backends" error
5+
let withDragDropContextGuest = null;
6+
7+
const makeWithDragDropContextGuest = guestWindow => {
8+
if (!withDragDropContextGuest) {
9+
withDragDropContextGuest = DragDropContext(HTML5Backend, guestWindow);
10+
}
11+
return withDragDropContextGuest;
12+
};
13+
export default makeWithDragDropContextGuest;

Resources/Private/StructuredEditing/src/manifest.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ import {selectors} from '@neos-project/neos-ui-redux-store';
66
import {DropDown, Icon} from '@neos-project/react-ui-components';
77
import {connect} from 'react-redux';
88
import {$transform, $get} from 'plow-js';
9-
import EditorEnvelope from '@neos-project/neos-ui-editors';
9+
import {EditorEnvelope} from '@neos-project/neos-ui-editors';
1010
import {NeosContext} from '@neos-project/neos-ui-decorators';
11-
import {DragDropContextProvider} from 'react-dnd';
12-
import HTML5Backend from 'react-dnd-html5-backend';
11+
import withDragDropContextGuest from './context';
1312

1413
@connect($transform({
1514
currentlyEditedPropertyName: selectors.UI.ContentCanvas.currentlyEditedPropertyName,
@@ -119,21 +118,20 @@ manifest('Flowpack.StructuredEditing:EditorEnvelope', {}, (globalRegistry, {rout
119118
const domNode = config.propertyDomNode;
120119
const guestWindow = domNode.ownerDocument.defaultView;
121120
const fusionPath = findParentFusionPath(domNode, config.contextPath);
121+
const InlineEditorEnvelopeWithDnd = withDragDropContextGuest(guestWindow)(InlineEditorEnvelope);
122122
ReactDOM.render(
123123
(
124-
<DragDropContextProvider backend={HTML5Backend} context={guestWindow}>
125-
<NeosContext.Provider value={{configuration, globalRegistry, routes}}>
126-
<InlineEditorEnvelope
127-
globalRegistry={globalRegistry}
128-
routes={routes}
129-
configuration={configuration}
130-
store={store}
131-
fusionPath={fusionPath}
132-
nodeTypesRegistry={nodeTypesRegistry}
133-
{...config}
134-
/>
135-
</NeosContext.Provider>
136-
</DragDropContextProvider>
124+
<NeosContext.Provider value={{configuration, globalRegistry, routes}}>
125+
<InlineEditorEnvelopeWithDnd
126+
globalRegistry={globalRegistry}
127+
routes={routes}
128+
configuration={configuration}
129+
store={store}
130+
fusionPath={fusionPath}
131+
nodeTypesRegistry={nodeTypesRegistry}
132+
{...config}
133+
/>
134+
</NeosContext.Provider>
137135
), domNode);
138136
},
139137
ToolbarComponent: () => null

Resources/Public/JavaScript/StructuredEditing/Plugin.js

Lines changed: 46 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Resources/Public/JavaScript/StructuredEditing/Plugin.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)