Skip to content
Snippets Groups Projects
Commit 416c64be authored by chris's avatar chris
Browse files

only save on changes

parent 07d18d8b
No related branches found
No related tags found
1 merge request!277Editoria fixes
......@@ -74,14 +74,16 @@ export default ({ comment, top, commentId, recalculateTops }) => {
allCommentsWithSameId.forEach(singleComment => {
dispatch(
tr.addMark(
singleComment.pos,
singleComment.pos + singleComment.nodeSize,
commentMark.create({
...((comment && comment.attrs) || {}),
conversation: comment.attrs.conversation,
}),
),
tr
.addMark(
singleComment.pos,
singleComment.pos + singleComment.nodeSize,
commentMark.create({
...((comment && comment.attrs) || {}),
conversation: comment.attrs.conversation,
}),
)
.setMeta('forceUpdate', true),
);
});
activeView.focus();
......
import React, { useRef, useContext, useCallback, useMemo } from 'react';
import React, {
useRef,
useContext,
useCallback,
useMemo,
useState,
} from 'react';
import applyDevTools from 'prosemirror-dev-tools';
import { EditorState } from 'prosemirror-state';
......@@ -10,12 +16,14 @@ import { trackedTransaction } from 'wax-prosemirror-services';
import { WaxContext } from './WaxContext';
import transformPasted from './helpers/TransformPasted';
let previousDoc;
export default props => {
const { readonly, onBlur, options, debug, autoFocus, user } = props;
const editorRef = useRef();
let view;
const context = useContext(WaxContext);
const [previousState, setPreviousState] = useState();
const setEditorRef = useCallback(
node => {
if (editorRef.current) {
......@@ -75,6 +83,7 @@ export default props => {
? trackedTransaction(transaction, view.state, user)
: transaction;
previousDoc = view.state.doc;
const state = view.state.apply(tr);
view.updateState(state);
......@@ -90,8 +99,8 @@ export default props => {
'main',
);
}
props.onChange(state.doc.content);
if (view.state.doc !== previousDoc || tr.getMeta('forceUpdate'))
props.onChange(state.doc.content);
};
const editor = <div ref={setEditorRef} />;
......
import { Plugin, PluginKey } from "prosemirror-state";
import { Decoration, DecorationSet } from "prosemirror-view";
import { Plugin, PluginKey } from 'prosemirror-state';
import { Decoration, DecorationSet } from 'prosemirror-view';
const placeHolderText = new PluginKey("placeHolderText");
const placeHolderText = new PluginKey('placeHolderText');
export default props => {
return new Plugin({
......@@ -17,16 +17,16 @@ export default props => {
) {
decorations.push(
Decoration.node(pos, pos + node.nodeSize, {
class: "empty-node",
"data-content": props.content
})
class: 'empty-node',
'data-content': props.content,
}),
);
}
};
state.doc.descendants(decorate);
return DecorationSet.create(state.doc, decorations);
}
}
},
},
});
};
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