diff --git a/packages/cwrc-leafwriter/src/js/tinymce/tinymceWrapper.ts b/packages/cwrc-leafwriter/src/js/tinymce/tinymceWrapper.ts index 56a0b35c436d0c8dd64d6cc67fe9b2acf705388c..f3460097eeba1cc09dcd0ddeda016f2a948ad79b 100644 --- a/packages/cwrc-leafwriter/src/js/tinymce/tinymceWrapper.ts +++ b/packages/cwrc-leafwriter/src/js/tinymce/tinymceWrapper.ts @@ -454,11 +454,17 @@ export const tinymceWrapperInit = function ({ const request: PossibleNodesAtTarget = { xpath, index, selection }; // console.log(request); - const tags = await overmindActions.validator.getPossibleNodesAt(request); // get possible nodes from validator for current xpath-locattion and inside this location - if (!tags) { // If we did not get anythin back from the validator-worker, we have to end, since we can't check if lb is allowed. - node.normalize(); - writer.event('writerKeyup').publish(event); - return + var tags = await overmindActions.validator.getPossibleNodesAt(request); // get possible nodes from validator for current xpath-locattion and inside this location + if (!tags) { // If we did not get anything back from the validator-worker, we have to end, since we can't check if lb is allowed. However, we first have to explicitly run the validator-worker, since + // it may not yet have caught up with changes in the document + await writer.overmindActions.validator.validate() //force re-run validator + //re-run check + tags = await overmindActions.validator.getPossibleNodesAt(request); // get possible nodes from validator for current xpath-locattion and inside this location + if (!tags) { // Still no tags, we have to end + node.normalize(); + writer.event('writerKeyup').publish(event); + return + } } //console.log(tags)