Skip to content
Snippets Groups Projects
Commit 77a053a1 authored by chris's avatar chris
Browse files

disable certain tools on notes

parent 8d265c90
No related branches found
No related tags found
3 merge requests!79Comment discussion,!78Tools on notes,!77Tools on notes
...@@ -21,8 +21,8 @@ const Button = styled.button` ...@@ -21,8 +21,8 @@ const Button = styled.button`
const LinkComponent = ({ mark, setPosition, position }) => { const LinkComponent = ({ mark, setPosition, position }) => {
const href = mark ? mark.attrs.href : null, const href = mark ? mark.attrs.href : null,
linkMark = mark ? mark : null, linkMark = mark ? mark : null,
{ view: { main } } = useContext(WaxContext), { view: { main }, activeView } = useContext(WaxContext),
{ state, dispatch } = main, { state, dispatch } = activeView,
ref = useRef(null), ref = useRef(null),
linkInput = useRef(null), linkInput = useRef(null),
[addButtonText, setButtonText] = useState("Create"), [addButtonText, setButtonText] = useState("Create"),
...@@ -46,12 +46,12 @@ const LinkComponent = ({ mark, setPosition, position }) => { ...@@ -46,12 +46,12 @@ const LinkComponent = ({ mark, setPosition, position }) => {
.removeMark(mark.from, mark.to, state.schema.marks.link) .removeMark(mark.from, mark.to, state.schema.marks.link)
.addMark(mark.from, mark.to, state.schema.marks.link.create({ href })) .addMark(mark.from, mark.to, state.schema.marks.link.create({ href }))
); );
main.focus(); activeView.focus();
}; };
const removeLink = () => { const removeLink = () => {
dispatch(state.tr.removeMark(mark.from, mark.to, state.schema.marks.link)); dispatch(state.tr.removeMark(mark.from, mark.to, state.schema.marks.link));
main.focus(); activeView.focus();
}; };
const handleKeyDown = event => { const handleKeyDown = event => {
......
...@@ -27,11 +27,9 @@ export default class Menu { ...@@ -27,11 +27,9 @@ export default class Menu {
render() { render() {
return () => { return () => {
const { const { view: { main }, activeView } = useContext(WaxContext);
view: { main }
} = useContext(WaxContext);
const Bar = useMemo(() => ( const Bar = useMemo(() => (
<MenuWrapper items={this.toolGroups} view={main || {}} /> <MenuWrapper items={this.toolGroups} view={activeView || {}} />
)); ));
return <>{Bar}</>; return <>{Bar}</>;
}; };
......
...@@ -59,6 +59,11 @@ export default ({ node, view }) => { ...@@ -59,6 +59,11 @@ export default ({ node, view }) => {
}, },
handleDOMEvents: { handleDOMEvents: {
mousedown: () => { mousedown: () => {
context.updateActiveView({
activeView: context.view[noteId],
activeViewId: noteId
});
// Kludge to prevent issues due to the fact that the whole // Kludge to prevent issues due to the fact that the whole
// footnote is node-selected (and thus DOM-selected) when // footnote is node-selected (and thus DOM-selected) when
// the parent editor is focused. // the parent editor is focused.
......
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