Skip to content

Commit

Permalink
fix: full document being selected when clicking scrollbar or main men…
Browse files Browse the repository at this point in the history
…u when there is no selection
  • Loading branch information
josdejong committed Apr 26, 2022
1 parent 282e31d commit 5109de1
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/lib/components/modes/treemode/TreeMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,6 @@
}
}
if (!selection && (text === '' || text === undefined)) {
// make sure there is a selection,
// else we cannot paste or insert in case of an empty document
selection = createDefaultSelection()
}
addHistoryItem({
previousJson,
previousState,
Expand Down Expand Up @@ -706,7 +700,7 @@
function handlePaste(event) {
event.preventDefault()
if (readOnly || !selection) {
if (readOnly) {
return
}
Expand Down Expand Up @@ -741,13 +735,15 @@
function doPaste(clipboardText) {
if (json !== undefined) {
const operations = insert(json, state, selection, clipboardText)
const selectionOrDefault = selection || createDefaultSelection()
const operations = insert(json, state, selectionOrDefault, clipboardText)
const expandAllRecursive = !isLargeContent(
{ text: clipboardText },
MAX_DOCUMENT_SIZE_EXPAND_ALL
)
debug('paste', { clipboardText, operations, selection, expandAllRecursive })
debug('paste', { clipboardText, operations, selectionOrDefault, expandAllRecursive })
handlePatch(operations)
Expand Down Expand Up @@ -1799,10 +1795,6 @@
if (!hasFocus && !isChildOfNodeName(event.target, 'BUTTON')) {
// for example when clicking on the empty area in the main menu
focus()
if (!selection) {
selection = createDefaultSelection()
}
}
})
})
Expand Down

0 comments on commit 5109de1

Please sign in to comment.