Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
feat: paste inside current page root when nothing is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
marionebl committed May 24, 2018
1 parent e704609 commit 5248cca
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/store/view-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,12 +621,22 @@ export class ViewStore {

public pasteAfterSelectedElement(): Model.Element | undefined {
const selectedElement = this.getSelectedElement();
const page = this.getCurrentPage();
const rootElement = page ? page.getRoot() : undefined;

if (!selectedElement) {
if (!selectedElement && !rootElement) {
return;
}

return this.pasteAfterElement(selectedElement);
if (selectedElement) {
return this.pasteAfterElement(selectedElement);
}

if (rootElement) {
return this.pasteInsideElement(rootElement);
}

return;
}

public pasteInsideElement(element: Model.Element): Model.Element | undefined {
Expand Down Expand Up @@ -794,6 +804,7 @@ export class ViewStore {
}

public setActivePageByIndex(index: number): void {
this.selectedElement = undefined;
this.activePage = index;
}

Expand Down

0 comments on commit 5248cca

Please sign in to comment.