diff options
| author | Hsieh Chin Fan <pham@topo.tw> | 2024-10-10 16:13:41 +0800 |
|---|---|---|
| committer | Hsieh Chin Fan <pham@topo.tw> | 2024-10-10 16:13:41 +0800 |
| commit | 01b8f687f10646d56754daea76e73c6668bf2797 (patch) | |
| tree | f1b9f2c991ee5ef741d376360ac3b498a0e3a224 /src | |
| parent | f740ae0e4001778d35439c45b2d473d752373ba1 (diff) | |
fix: the way check scroll line is clear
Diffstat (limited to 'src')
| -rw-r--r-- | src/editor.mjs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/editor.mjs b/src/editor.mjs index 5c65af4..0b3f23e 100644 --- a/src/editor.mjs +++ b/src/editor.mjs | |||
| @@ -344,9 +344,9 @@ new window.MutationObserver(() => { | |||
| 344 | if (line) { | 344 | if (line) { |
| 345 | const [lineNumber, offset] = line.split('/') | 345 | const [lineNumber, offset] = line.split('/') |
| 346 | 346 | ||
| 347 | if (!isNaN(lineNumber)) { | 347 | if (!lineNumber || isNaN(lineNumber)) return |
| 348 | cm.scrollIntoView({ line: lineNumber, ch: 0 }, offset) | 348 | |
| 349 | } | 349 | cm.scrollIntoView({ line: lineNumber, ch: 0 }, offset) |
| 350 | } | 350 | } |
| 351 | }).observe(dumbyContainer, { | 351 | }).observe(dumbyContainer, { |
| 352 | attributes: true, | 352 | attributes: true, |
| @@ -379,7 +379,7 @@ new window.MutationObserver(() => { | |||
| 379 | const line = textArea.dataset.scrollLine | 379 | const line = textArea.dataset.scrollLine |
| 380 | let lineNumber = Number(line) | 380 | let lineNumber = Number(line) |
| 381 | let p | 381 | let p |
| 382 | if (isNaN(lineNumber)) return | 382 | if (!line || isNaN(lineNumber)) return |
| 383 | 383 | ||
| 384 | const paragraphs = Array.from(dumbymap.htmlHolder.querySelectorAll('p')) | 384 | const paragraphs = Array.from(dumbymap.htmlHolder.querySelectorAll('p')) |
| 385 | do { | 385 | do { |