diff --git a/wax-questions-service/src/MultipleChoiceQuestionService/components/EditorComponent.js b/wax-questions-service/src/MultipleChoiceQuestionService/components/EditorComponent.js index 9a94fd2e19093c698f742953b63e5c46e3ce2303..303f6ff9343c5d4f99f856109a77e351b0e2c15d 100644 --- a/wax-questions-service/src/MultipleChoiceQuestionService/components/EditorComponent.js +++ b/wax-questions-service/src/MultipleChoiceQuestionService/components/EditorComponent.js @@ -209,6 +209,8 @@ const QuestionEditorComponent = ({ }, []); const dispatchTransaction = tr => { + console.log(tr.getMeta('addToHistoryFromOutside')); + const addToHistory = !tr.getMeta('exludeToHistoryFromOutside'); const { state, transactions } = questionView.state.applyTransaction(tr); questionView.updateState(state); context.updateView({}, questionId); @@ -222,7 +224,11 @@ const QuestionEditorComponent = ({ outerTr.step(steps[j].map(offsetMap)); } if (outerTr.docChanged) - view.dispatch(outerTr.setMeta('outsideView', questionId)); + view.dispatch( + outerTr + .setMeta('outsideView', questionId) + .setMeta('addToHistory', addToHistory), + ); } }; diff --git a/wax-questions-service/src/MultipleChoiceQuestionService/helpers/helpers.js b/wax-questions-service/src/MultipleChoiceQuestionService/helpers/helpers.js index 221982fc512a9a86c6452ebd95660a00d8ef7deb..60b6c87333da9a59cbfeafc11e356c80de92ef03 100644 --- a/wax-questions-service/src/MultipleChoiceQuestionService/helpers/helpers.js +++ b/wax-questions-service/src/MultipleChoiceQuestionService/helpers/helpers.js @@ -17,7 +17,9 @@ const createEmptyParagraph = (context, newAnswerId) => { if (context.pmViews[newAnswerId].dispatch) { const type = context.pmViews.main.state.schema.nodes.paragraph; context.pmViews[newAnswerId].dispatch( - context.pmViews[newAnswerId].state.tr.insert(0, type.create()), + context.pmViews[newAnswerId].state.tr + .insert(0, type.create()) + .setMeta('exludeToHistoryFromOutside', true), ); } context.pmViews[newAnswerId].dispatch( @@ -80,9 +82,9 @@ const createOptions = (main, context, parentType, questionType, answerType) => { dispatch(tr); setTimeout(() => { context.pmViews[question.attrs.id].focus(); - // createEmptyParagraph(context, firstOption.attrs.id); - // createEmptyParagraph(context, secondOption.attrs.id); - // createEmptyParagraph(context, question.attrs.id); + createEmptyParagraph(context, firstOption.attrs.id); + createEmptyParagraph(context, secondOption.attrs.id); + createEmptyParagraph(context, question.attrs.id); }, 50); return true;