Skip to content
Snippets Groups Projects
Commit 422fa309 authored by chris's avatar chris
Browse files

ActiveCommentPlugin to CommentPlugin

parent 5cda1ba5
No related branches found
No related tags found
1 merge request!119Comment service
...@@ -40,8 +40,8 @@ export default ({ comment, view, top, dataBox }) => { ...@@ -40,8 +40,8 @@ export default ({ comment, view, top, dataBox }) => {
), ),
[animate, setAnimate] = useState(false), [animate, setAnimate] = useState(false),
{ attrs: { id } } = comment, { attrs: { id } } = comment,
activeCommentPlugin = app.PmPlugins.get("activeComment"), commentPlugin = app.PmPlugins.get("commentPlugin"),
activeComment = activeCommentPlugin.getState(activeView.state).comment; activeComment = commentPlugin.getState(activeView.state).comment;
let active = false; let active = false;
if (activeComment && id === activeComment.attrs.id) active = true; if (activeComment && id === activeComment.attrs.id) active = true;
......
...@@ -15,7 +15,7 @@ import { each, uniqBy, sortBy } from "lodash"; ...@@ -15,7 +15,7 @@ import { each, uniqBy, sortBy } from "lodash";
export default ({ area }) => { export default ({ area }) => {
const { view: { main }, app, activeView } = useContext(WaxContext); const { view: { main }, app, activeView } = useContext(WaxContext);
const activeCommentPlugin = app.PmPlugins.get("activeComment"); const commentPlugin = app.PmPlugins.get("commentPlugin");
const [marksNodes, setMarksNodes] = useState([]); const [marksNodes, setMarksNodes] = useState([]);
const [position, setPosition] = useState(); const [position, setPosition] = useState();
...@@ -32,8 +32,7 @@ export default ({ area }) => { ...@@ -32,8 +32,7 @@ export default ({ area }) => {
const id = const id =
markNode instanceof Mark ? markNode.attrs.id : markNode.node.attrs.id; markNode instanceof Mark ? markNode.attrs.id : markNode.node.attrs.id;
const activeComment = activeCommentPlugin.getState(activeView.state) const activeComment = commentPlugin.getState(activeView.state).comment;
.comment;
let isActive = false; let isActive = false;
if (activeComment && id === activeComment.attrs.id) isActive = true; if (activeComment && id === activeComment.attrs.id) isActive = true;
......
...@@ -39,12 +39,8 @@ export default ({ trackChange, view, top, dataBox }) => { ...@@ -39,12 +39,8 @@ export default ({ trackChange, view, top, dataBox }) => {
} else { } else {
action = `User demo changed paragraph to heading 1`; action = `User demo changed paragraph to heading 1`;
} }
// const { attrs: { id } } = comment;
// const activeCommentPlugin = app.PmPlugins.get("activeComment");
// const activeComment = activeCommentPlugin.getState(activeView.state).comment;
let active = false; let active = false;
// if (activeComment && id === activeComment.attrs.id) active = true;
useEffect(() => { useEffect(() => {
setAnimate(true); setAnimate(true);
}, []); }, []);
......
...@@ -2,5 +2,5 @@ export { ...@@ -2,5 +2,5 @@ export {
default as TrackChangePlugin default as TrackChangePlugin
} from "./src/trackChanges/TrackChangePlugin"; } from "./src/trackChanges/TrackChangePlugin";
export { default as ActiveComment } from "./src/comments/ActiveComment"; export { default as CommentPlugin } from "./src/comments/CommentPlugin";
export { default as WaxSelectionPlugin } from "./src/WaxSelectionPlugin"; export { default as WaxSelectionPlugin } from "./src/WaxSelectionPlugin";
...@@ -3,7 +3,7 @@ import { Plugin, PluginKey } from "prosemirror-state"; ...@@ -3,7 +3,7 @@ import { Plugin, PluginKey } from "prosemirror-state";
import { Decoration, DecorationSet } from "prosemirror-view"; import { Decoration, DecorationSet } from "prosemirror-view";
import { DocumentHelpers } from "wax-prosemirror-utilities"; import { DocumentHelpers } from "wax-prosemirror-utilities";
const activeComment = new PluginKey("activeComment"); const commentPlugin = new PluginKey("commentPlugin");
const getComment = state => { const getComment = state => {
const commentMark = state.schema.marks["comment"]; const commentMark = state.schema.marks["comment"];
...@@ -52,7 +52,7 @@ const getComment = state => { ...@@ -52,7 +52,7 @@ const getComment = state => {
export default props => { export default props => {
return new Plugin({ return new Plugin({
key: activeComment, key: commentPlugin,
state: { state: {
init: (_, state) => { init: (_, state) => {
return { comment: getComment(state) }; return { comment: getComment(state) };
...@@ -75,7 +75,7 @@ export default props => { ...@@ -75,7 +75,7 @@ export default props => {
}, },
props: { props: {
decorations: state => { decorations: state => {
const commentPluginState = state && activeComment.getState(state); const commentPluginState = state && commentPlugin.getState(state);
return commentPluginState.createDecoration; return commentPluginState.createDecoration;
} }
} }
......
import Service from "../Service"; import Service from "../Service";
import { commentMark } from "wax-prosemirror-schema"; import { commentMark } from "wax-prosemirror-schema";
import { RightArea, CommentBubbleComponent } from "wax-prosemirror-components"; import { RightArea, CommentBubbleComponent } from "wax-prosemirror-components";
import { ActiveComment } from "wax-prosemirror-plugins"; import { CommentPlugin } from "wax-prosemirror-plugins";
const PLUGIN_KEY = "activeComment"; const PLUGIN_KEY = "commentPlugin";
export default class CommentsService extends Service { export default class CommentsService extends Service {
name = "CommentsService"; name = "CommentsService";
boot() { boot() {
this.app.PmPlugins.add(PLUGIN_KEY, ActiveComment(PLUGIN_KEY)); this.app.PmPlugins.add(PLUGIN_KEY, CommentPlugin(PLUGIN_KEY));
const createOverlay = this.container.get("CreateOverlay"); const createOverlay = this.container.get("CreateOverlay");
const layout = this.container.get("Layout"); const layout = this.container.get("Layout");
createOverlay( createOverlay(
......
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