|
| 1 | + |
| 2 | +# The diff strategy |
| 3 | + |
| 4 | +## The simple strategy vs diff strategy |
| 5 | +It would be simple to make the change in our API, then change the related nodes |
| 6 | +in the DOM. But there is some problems that we need to address. |
| 7 | + |
| 8 | +So rather than 2 steps (direct strategy): |
| 9 | +1) apply in VDOC |
| 10 | +2) apply in DOM |
| 11 | + |
| 12 | +We do 4 steps (diff strategy): |
| 13 | +1) apply in DOM |
| 14 | +2) apply in VDOC |
| 15 | +3) diff DOM-VDOC |
| 16 | +4) apply in DOM |
| 17 | + |
| 18 | +### Problem 1: Dictionnary and spell checkers |
| 19 | +When preventing an event, if the dictionnary was saving data, it does not clear |
| 20 | +it's internal memory. So when another event happen, the dictionnary has wrong |
| 21 | +data and might create strange correction. |
| 22 | + |
| 23 | +[provide examples] |
| 24 | + |
| 25 | +### Problem 2: Mouvement between words |
| 26 | +When you have a word and you hit `ctrl + arrow`, you want to move from one word |
| 27 | +to the other. In some language like Lao, the words might not be separated by |
| 28 | +spaces. In order to know where is the delimitation of the word, we allow the |
| 29 | +browser to move the cursor and we reflect that navigation change in our VDOC. |
| 30 | + |
| 31 | +### Problem of the diff strategy |
| 32 | +Because we need the event to happen in the DOM it is possible that our VDOC will |
| 33 | +have a different rendering then what the browser registred. In such case, glitch |
| 34 | +can occurs. |
| 35 | + |
| 36 | +[Provide gif images to show a glitch] |
| 37 | + |
| 38 | +### Exceptions |
| 39 | +It is possible in some case to be sure that there is no dictionnary/spell cheker |
| 40 | +running or that we can predict the movement of the words. In such case, we |
| 41 | +can use the browser `event.preventDefault()` and therfore avoid any possible |
| 42 | +glitch. |
| 43 | + |
| 44 | +### Alternatives |
| 45 | +Ckeditor: deactivate the spellcheck alltogether and use third party plugins. |
| 46 | + |
| 47 | +Quilljs: ? |
| 48 | + |
| 49 | + |
0 commit comments