Skip to content

Commit

Permalink
Only apply select-all iOS kludge when the viewport doesn't cover the doc
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh committed Dec 14, 2023
1 parent a756561 commit 75855a7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/domchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ export class DOMChange {
? view.state.selection.main.anchor
: view.docView.posFromDOM(domSel.anchorNode!, domSel.anchorOffset)
// iOS will refuse to select the block gaps when doing select-all
if (browser.ios && view.state.selection.main.empty && head != anchor) {
let offFrom = view.viewport.from - Math.min(head, anchor), offTo = view.viewport.to - Math.max(head, anchor)
let vp = view.viewport
if (browser.ios && view.state.selection.main.empty && head != anchor &&
(vp.from > 0 || vp.to < view.state.doc.length)) {
let offFrom = vp.from - Math.min(head, anchor), offTo = vp.to - Math.max(head, anchor)
if ((offFrom == 0 || offFrom == 1) && (offTo == 0 || offTo == -1)) {
head = 0
anchor = view.state.doc.length
Expand Down

0 comments on commit 75855a7

Please sign in to comment.