diff --git a/editors/editoria/src/config/config.js b/editors/editoria/src/config/config.js index 5d1065cecf97aa10711b78e3b25389bec9d4f56c..79d766a1a3a94f5ba16ac98f6805ad15fb95f912 100644 --- a/editors/editoria/src/config/config.js +++ b/editors/editoria/src/config/config.js @@ -44,12 +44,8 @@ export default { ShortCutsService: {}, - PmPlugins: [ - columnResizing(), - tableEditing(), - // TrackChangePlugin({ options: {} }), - invisibles([hardBreak()]) - ], + PmPlugins: [columnResizing(), tableEditing(), invisibles([hardBreak()])], + services: [ new PlaceholderService(), new ImageService(), diff --git a/wax-prosemirror-core/src/WaxView.js b/wax-prosemirror-core/src/WaxView.js index 667bf8c54ce6062d8df900ebb3f45f8fab964bc9..e82f5b24eaffce864ecba9b8abc98aa51bbc49d1 100644 --- a/wax-prosemirror-core/src/WaxView.js +++ b/wax-prosemirror-core/src/WaxView.js @@ -15,30 +15,28 @@ import { trackedTransaction } from "wax-prosemirror-services"; import { WaxContext } from "./ioc-react"; export default props => { - const { readonly, onBlur, options, debug, autoFocus, user } = props; - const editorRef = useRef(); + const { + readonly, + onBlur, + options, + debug, + autoFocus, + TrackChange, + user + } = props; + const editorRef = useRef(); + let view; const context = useContext(WaxContext); useEffect(() => { - const view = new EditorView( + view = new EditorView( { mount: editorRef.current }, { editable: () => !readonly, state: EditorState.create(options), - dispatchTransaction: transaction => { - const { TrackChange } = props; - const tr = TrackChange - ? trackedTransaction(transaction, view.state, user) - : transaction; - - const state = view.state.apply(tr); - view.updateState(state); - context.updateView({ main: view }); - - props.onChange(state.doc.content); - }, - handleDOMEvents: { + dispatchTransaction, + leDOMEvents: { blur: onBlur ? view => { onBlur(view.state.doc.content); @@ -48,11 +46,24 @@ export default props => { } ); context.updateView({ main: view }); - + console.log("test"); if (debug) applyDevTools(view); if (autoFocus) view.focus(); }, []); + const dispatchTransaction = transaction => { + const { TrackChange } = props; + const tr = TrackChange + ? trackedTransaction(transaction, view.state, user) + : transaction; + + const state = view.state.apply(tr); + view.updateState(state); + context.updateView({ main: view }); + + props.onChange(state.doc.content); + }; + const editor = <div ref={editorRef} />; return props.children({ editor