Skip to content
Snippets Groups Projects
Commit 2ecd6be9 authored by chris's avatar chris
Browse files

diable tool on feedback

parent 658a8289
No related branches found
No related tags found
1 merge request!430Hhmi issues
import React, { useContext, useRef, useState } from 'react';
import styled from 'styled-components';
import { TextSelection } from 'prosemirror-state';
import { WaxContext, DocumentHelpers } from 'wax-prosemirror-core';
const FeedBack = styled.div`
......@@ -31,6 +32,7 @@ export default ({ node, getPos, readOnly }) => {
const context = useContext(WaxContext);
const {
pmViews: { main },
activeView,
} = context;
const [feedBack, setFeedBack] = useState(node.attrs.feedback);
const feedBackRef = useRef(null);
......@@ -48,9 +50,23 @@ export default ({ node, getPos, readOnly }) => {
);
}
});
setNullSelection();
return false;
};
const setNullSelection = () => {
activeView.dispatch(
activeView.state.tr.setSelection(
TextSelection.create(activeView.state.tr.doc, null),
),
);
};
const onFocus = () => {
setTimeout(() => {
setNullSelection();
}, 50);
};
return (
<FeedBack>
<FeedBackLabel>Feedback</FeedBackLabel>
......@@ -58,6 +74,7 @@ export default ({ node, getPos, readOnly }) => {
autoFocus="autoFocus"
disabled={readOnly}
onChange={feedBackInput}
onFocus={onFocus}
placeholder="Insert feedback"
ref={feedBackRef}
type="text"
......
import React, { useContext, useRef, useState } from 'react';
import styled from 'styled-components';
import { TextSelection } from 'prosemirror-state';
import { WaxContext, DocumentHelpers } from 'wax-prosemirror-core';
const FeedBack = styled.div`
......@@ -30,6 +31,7 @@ export default ({ node, getPos, readOnly }) => {
const context = useContext(WaxContext);
const {
pmViews: { main },
activeView,
} = context;
const [feedBack, setFeedBack] = useState(node.attrs.feedback);
......@@ -48,15 +50,31 @@ export default ({ node, getPos, readOnly }) => {
);
}
});
setNullSelection();
return false;
};
const setNullSelection = () => {
activeView.dispatch(
activeView.state.tr.setSelection(
TextSelection.create(activeView.state.tr.doc, null),
),
);
};
const onFocus = () => {
setTimeout(() => {
setNullSelection();
}, 50);
};
return (
<FeedBack>
<FeedBackLabel>Feedback</FeedBackLabel>
<FeedBackInput
autoFocus="autoFocus"
onChange={feedBackInput}
onFocus={onFocus}
placeholder="Insert feedback"
readOnly={readOnly}
ref={feedBackRef}
......
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