diff --git a/src/app/edit/edit-chapter/edit-chapter.component.ts b/src/app/edit/edit-chapter/edit-chapter.component.ts index 877ec34..58f8386 100644 --- a/src/app/edit/edit-chapter/edit-chapter.component.ts +++ b/src/app/edit/edit-chapter/edit-chapter.component.ts @@ -114,9 +114,15 @@ export class EditChapterComponent { @HostListener('document:keydown.control.alt.a', ['$event']) addPage(): void { - this.chapter.Pages.push(new Page('', '', '')); - this.currentPage = this.chapter.Pages.length - 1; + //this.chapter.Pages.push(new Page('', '', '')); + if (this.currentPage + 1 >= this.chapter.Pages.length) { + this.chapter.Pages.push(new Page('', '', '')); + } else { + this.chapter.Pages.splice(this.currentPage + 1, 0, new Page('', '', '')); + } + this.currentPage++; this.pageInput = this.currentPage + 1; + window.scrollTo({ top: 0 }); this.changes = true; } diff --git a/src/app/services/irisinterface.service.ts b/src/app/services/irisinterface.service.ts index 1ee4540..282fbd4 100644 --- a/src/app/services/irisinterface.service.ts +++ b/src/app/services/irisinterface.service.ts @@ -245,6 +245,7 @@ export class IrisinterfaceService { } uploadImage(name: string, content: any): Observable { + name = name.replace(/ /g, '_'); return this.http .post( 'http://' + @@ -264,6 +265,7 @@ export class IrisinterfaceService { } uploadFile(name: string, content: any): Observable { + name = name.replace(/ /g, '_'); return this.http .post( 'http://' + diff --git a/src/utils/classes.ts b/src/utils/classes.ts index 9b07447..6b5aa78 100644 --- a/src/utils/classes.ts +++ b/src/utils/classes.ts @@ -63,6 +63,14 @@ export class Chapter { } return -1; } + + addPageAt(page: Page, index: number) { + if (index >= this.Pages.length) { + this.Pages.push(page); + return; + } + this.Pages = this.Pages.splice(index, 0, page); + } } export class Page {