Skip to content
Snippets Groups Projects
Commit 713c56bd authored by chris's avatar chris
Browse files

remove unused service and cleanup WaxView

parent 20051684
No related branches found
No related tags found
1 merge request!61Develop
......@@ -44,12 +44,8 @@ export default {
ShortCutsService: {},
PmPlugins: [
columnResizing(),
tableEditing(),
// TrackChangePlugin({ options: {} }),
invisibles([hardBreak()])
],
PmPlugins: [columnResizing(), tableEditing(), invisibles([hardBreak()])],
services: [
new PlaceholderService(),
new ImageService(),
......
......@@ -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
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment