From 5f57e9c5ca425964c21c720bbe3d410c44ab380e Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Wed, 16 Nov 2022 10:41:17 +0200 Subject: [PATCH] fix fill the gap focus --- editors/demo/src/HHMI/HHMI.js | 2 +- wax-prosemirror-components/src/components/Button.js | 2 +- .../FillTheGapQuestionService/CreateGapService/CreateGap.js | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/editors/demo/src/HHMI/HHMI.js b/editors/demo/src/HHMI/HHMI.js index a232017d2..2b562b313 100644 --- a/editors/demo/src/HHMI/HHMI.js +++ b/editors/demo/src/HHMI/HHMI.js @@ -170,7 +170,7 @@ const Hhmi = () => { value={content} readonly={readOnly} layout={HhmiLayout} - onChange={source => console.log(source)} + // onChange={source => console.log(source)} /> </> ); diff --git a/wax-prosemirror-components/src/components/Button.js b/wax-prosemirror-components/src/components/Button.js index 464a0ae13..f61f2b65c 100644 --- a/wax-prosemirror-components/src/components/Button.js +++ b/wax-prosemirror-components/src/components/Button.js @@ -20,7 +20,7 @@ const Button = ({ view = {}, item }) => { const handleMouseDown = e => { e.preventDefault(); - run(activeView.state, activeView.dispatch, activeView); + run(activeView.state, activeView.dispatch, activeView, context); }; const isActive = !!( diff --git a/wax-prosemirror-services/src/FillTheGapQuestionService/CreateGapService/CreateGap.js b/wax-prosemirror-services/src/FillTheGapQuestionService/CreateGapService/CreateGap.js index 93b7ddc3c..dbe6cfa2b 100644 --- a/wax-prosemirror-services/src/FillTheGapQuestionService/CreateGapService/CreateGap.js +++ b/wax-prosemirror-services/src/FillTheGapQuestionService/CreateGapService/CreateGap.js @@ -11,7 +11,7 @@ class CreateGap extends Tools { label = 'Create Gap'; get run() { - return (state, dispatch) => { + return (state, dispatch, activeView, context) => { const { empty, $from, $to } = state.selection; let content = Fragment.empty; if (!empty && $from.sameParent($to) && $from.parent.inlineContent) @@ -23,7 +23,11 @@ class CreateGap extends Tools { { id: uuidv4() }, content, ); + dispatch(state.tr.replaceSelectionWith(createGap)); + setTimeout(() => { + context.pmViews[createGap.attrs.id].focus(); + }, 100); }; } -- GitLab