Skip to content

Commit

Permalink
store and return current selection
Browse files Browse the repository at this point in the history
- fixing as per review suggestion
  • Loading branch information
ffd8 committed Jan 4, 2021
1 parent fca847a commit 93af8e8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions basil.js
Original file line number Diff line number Diff line change
Expand Up @@ -4052,6 +4052,9 @@ pub.pasteInto = function(source, destination) {
checkNull(source);
checkNull(destination);

// temp store previous selection
var tempSelection = app.selection;

// set source to app clipboard
app.selection = source;
app.copy();
Expand All @@ -4060,6 +4063,9 @@ pub.pasteInto = function(source, destination) {
app.selection = destination;
app.pasteInto();

// return selection
app.selection = tempSelection;

// return new pageItem inside destination
if(destination.pageItems[0].hasOwnProperty('texts')){
return destination.pageItems[0].texts[0];
Expand Down
6 changes: 6 additions & 0 deletions src/includes/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,9 @@ pub.pasteInto = function(source, destination) {
checkNull(source);
checkNull(destination);

// temp store previous selection
var tempSelection = app.selection;

// set source to app clipboard
app.selection = source;
app.copy();
Expand All @@ -1269,6 +1272,9 @@ pub.pasteInto = function(source, destination) {
app.selection = destination;
app.pasteInto();

// return selection
app.selection = tempSelection;

// return new pageItem inside destination
if(destination.pageItems[0].hasOwnProperty('texts')){
return destination.pageItems[0].texts[0];
Expand Down

0 comments on commit 93af8e8

Please sign in to comment.