From bfd3be63858483f72f3ccb5b0128509fd0141f89 Mon Sep 17 00:00:00 2001 From: Jacob Benz <jacob.benz@h-da.de> Date: Mon, 19 Aug 2024 11:34:50 +0200 Subject: [PATCH] improve inserting lb with Shift+Enter --- .../src/js/tinymce/tinymceWrapper.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/cwrc-leafwriter/src/js/tinymce/tinymceWrapper.ts b/packages/cwrc-leafwriter/src/js/tinymce/tinymceWrapper.ts index 56a0b35c..f3460097 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) -- GitLab