diff --git a/editors/demo/src/HHMI/MultipleChoiceQuestionService/plugins/testPlugin.js b/editors/demo/src/HHMI/MultipleChoiceQuestionService/plugins/testPlugin.js deleted file mode 100644 index 5f6a50afd45a313b608b9a29dd304e921dbdc39a..0000000000000000000000000000000000000000 --- a/editors/demo/src/HHMI/MultipleChoiceQuestionService/plugins/testPlugin.js +++ /dev/null @@ -1,38 +0,0 @@ -import { Plugin, PluginKey } from 'prosemirror-state'; -import { - createReactNodeView, - useReactNodeViewPortals, -} from 'wax-prosemirror-core/src/WaxContext'; -import TestComponent from '../components/TestComponent'; - -console.log(useReactNodeViewPortals); -const testPlugin = new PluginKey('testPlugin'); - -export default props => { - return new Plugin({ - key: testPlugin, - state: { - init: (_, state) => { - console.log('in init'); - }, - apply(tr, prev, _, newState) { - console.log('in apply'); - }, - }, - props: { - nodeViews: { - multiple_choice(node, view, getPos, decorations) { - console.log('rerenders for ever'); - return createReactNodeView({ - node, - view, - getPos, - decorations, - component: TestComponent, - onCreatePortal: handleCreatePortal, - }); - }, - }, - }, - }); -}; diff --git a/wax-prosemirror-core/index.js b/wax-prosemirror-core/index.js index 38fa2e8ac6d9499a576a66dd73769516dcbec616..84a7b8e50fa3ec0e9b7b77b968bbdab5ef1fc225 100644 --- a/wax-prosemirror-core/index.js +++ b/wax-prosemirror-core/index.js @@ -2,4 +2,3 @@ export { WaxContext, useInjection } from './src/WaxContext'; export { PortalContext } from './src/PortalContext'; export { default as ComponentPlugin } from './src/ComponentPlugin'; export { default as Wax } from './src/Wax'; -export { default as useReactNodeView } from './src/ReactNodeView'; diff --git a/wax-prosemirror-core/src/ReactNodeView.js b/wax-prosemirror-core/src/ReactNodeView.js deleted file mode 100644 index ab2d2e55e12d32c8c9e7ba3a2de719038de3f1d0..0000000000000000000000000000000000000000 --- a/wax-prosemirror-core/src/ReactNodeView.js +++ /dev/null @@ -1,95 +0,0 @@ -/* eslint-disable no-void */ -/* eslint-disable react/no-this-in-sfc */ -/* eslint-disable no-underscore-dangle */ -/* eslint-disable no-cond-assign */ -/* eslint-disable lines-between-class-members */ -import React, { useContext, useEffect, useRef } from 'react'; -import ReactDOM from 'react-dom'; -import { v4 as uuidv4 } from 'uuid'; - -let nodeViewTemp = null; -const ReactNodeViewContext = React.createContext({ - node: undefined, - view: undefined, - getPos: undefined, - decorations: undefined, -}); -class ReactNodeView { - constructor(node, view, getPos, decorations, component) { - this.node = node; - this.view = view; - this.getPos = getPos; - this.decorations = decorations; - this.component = component; - this.componentRef = React.createRef(); - } - init() { - this.dom = document.createElement('div'); - this.dom.classList.add('ProseMirror__dom'); - if (!this.node.isLeaf) { - this.contentDOM = document.createElement('div'); - this.contentDOM.classList.add('ProseMirror__contentDOM'); - this.dom.appendChild(this.contentDOM); - } - - return { - nodeView: this, - portal: this.renderPortal(this.dom), - }; - } - - renderPortal(container) { - const Component = props => { - const componentRef = useRef(null); - - return ( - <div ref={componentRef} className="ProseMirror__reactComponent"> - <ReactNodeViewContext.Provider - value={{ - node: this.node, - view: this.view, - getPos: this.getPos, - decorations: this.decorations, - }} - > - <this.component {...props} /> - </ReactNodeViewContext.Provider> - </div> - ); - }; - - return ReactDOM.createPortal(<Component />, container, uuidv4()); - } - - update(node) { - return true; - } - - destroy() { - this.dom = undefined; - this.contentDOM = undefined; - } -} -export const createReactNodeView = ({ - node, - view, - getPos, - decorations, - component, - onCreatePortal, -}) => { - const reactNodeView = new ReactNodeView( - node, - view, - getPos, - decorations, - component, - ); - const { nodeView, portal } = reactNodeView.init(); - onCreatePortal(portal); - nodeViewTemp = nodeView; - - return nodeViewTemp; -}; -export const useReactNodeView = () => useContext(ReactNodeViewContext); -export default ReactNodeView; diff --git a/wax-prosemirror-services/src/ShortCutsService/ShortCuts.js b/wax-prosemirror-services/src/ShortCutsService/ShortCuts.js index 17bd379c964ba6de391b01d28e149ce90e6161c2..5a9ea295a7f1bb666c115b976e6a440ad652144c 100644 --- a/wax-prosemirror-services/src/ShortCutsService/ShortCuts.js +++ b/wax-prosemirror-services/src/ShortCutsService/ShortCuts.js @@ -60,7 +60,6 @@ const backSpaceShortCut = (state, dispatch, view) => { }; const pressEnter = (state, dispatch) => { - console.log('enter'); if (state.selection.node && state.selection.node.type.name === 'image') { const { $from, to } = state.selection;