diff options
| author | Hsieh Chin Fan <pham@topo.tw> | 2024-10-09 15:06:11 +0800 |
|---|---|---|
| committer | Hsieh Chin Fan <pham@topo.tw> | 2024-10-09 15:06:11 +0800 |
| commit | 2d5f7ad47019b54fa1c2ef08cafb9b25f82a4ecc (patch) | |
| tree | 9d94e9813ab4d95e68bebb49aaecb4cc87892ebb /src | |
| parent | 9e62f0371f66cc4f2aa275f958f16a9443b108b7 (diff) | |
fix: proper timing to adjust scroll of HTML contents
Diffstat (limited to 'src')
| -rw-r--r-- | src/editor.mjs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/editor.mjs b/src/editor.mjs index 55c6267..e39d97c 100644 --- a/src/editor.mjs +++ b/src/editor.mjs | |||
| @@ -487,6 +487,8 @@ cm.on('focus', () => { | |||
| 487 | }) | 487 | }) |
| 488 | 488 | ||
| 489 | cm.on('beforeChange', (_, change) => { | 489 | cm.on('beforeChange', (_, change) => { |
| 490 | textArea.dataset.scrollLine = cm.getCursor().line | ||
| 491 | |||
| 490 | // Don't allow more content after YAML doc separator | 492 | // Don't allow more content after YAML doc separator |
| 491 | if (change.origin && change.origin.match(/^(\+input|paste)$/)) { | 493 | if (change.origin && change.origin.match(/^(\+input|paste)$/)) { |
| 492 | const line = change.to.line | 494 | const line = change.to.line |
| @@ -830,7 +832,6 @@ const addSuggestions = (anchor, suggestions) => { | |||
| 830 | cm.on('cursorActivity', _ => { | 832 | cm.on('cursorActivity', _ => { |
| 831 | menu.style.display = 'none' | 833 | menu.style.display = 'none' |
| 832 | const anchor = cm.getCursor() | 834 | const anchor = cm.getCursor() |
| 833 | textArea.dataset.scrollLine = anchor.line | ||
| 834 | 835 | ||
| 835 | if (insideCodeblockForMap(anchor)) { | 836 | if (insideCodeblockForMap(anchor)) { |
| 836 | handleTypingInCodeBlock(anchor) | 837 | handleTypingInCodeBlock(anchor) |