From 5248cca58979bb8afbdae7f8e8d2f2c8d347cfe6 Mon Sep 17 00:00:00 2001 From: Mario Nebl Date: Wed, 23 May 2018 08:38:23 +0200 Subject: [PATCH] feat: paste inside current page root when nothing is selected --- src/store/view-store.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/store/view-store.ts b/src/store/view-store.ts index 48e12e764..f47067535 100644 --- a/src/store/view-store.ts +++ b/src/store/view-store.ts @@ -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 { @@ -794,6 +804,7 @@ export class ViewStore { } public setActivePageByIndex(index: number): void { + this.selectedElement = undefined; this.activePage = index; }