From ef56b8c84b5ea1e829bcbf6627df00aa33f88c9a Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Sun, 15 Jun 2025 00:43:33 -0500 Subject: [PATCH] Added preliminary files modal; fixed tabs scroll issue; fixed missing build deps --- newton/main.js | 4 +- package.json | 5 +- .../editor/modals/files-modal.service.ts | 34 ++++++++ src/app/editor/editors.component.html | 2 + src/app/editor/editors.component.ts | 4 +- .../editor/modals/files-modal.component.css | 16 ++++ .../editor/modals/files-modal.component.html | 52 ++++++++++++ .../editor/modals/files-modal.component.ts | 85 +++++++++++++++++++ .../newton-editor/newton-editor.component.ts | 13 ++- src/app/editor/tabs/tabs.component.css | 5 +- src/app/editor/tabs/tabs.component.html | 1 + src/app/editor/tabs/tabs.component.ts | 5 +- src/assets/css/styles.css | 2 + src/index.html | 2 +- 14 files changed, 218 insertions(+), 12 deletions(-) create mode 100644 src/app/common/services/editor/modals/files-modal.service.ts create mode 100644 src/app/editor/modals/files-modal.component.css create mode 100644 src/app/editor/modals/files-modal.component.html create mode 100644 src/app/editor/modals/files-modal.component.ts diff --git a/newton/main.js b/newton/main.js index 54e120f..3e4e7b9 100644 --- a/newton/main.js +++ b/newton/main.js @@ -50,7 +50,7 @@ app.whenReady().then(async () => { createWindow(); newton.fs.setWindow(window); - newton.fs.ipc.setWindow(window); + newton.ipc.setWindow(window); }); @@ -86,4 +86,4 @@ process.on('unhandledRejection', function(error = {}) { if (error.stack != null) { console.log(error.stack); } -}); \ No newline at end of file +}); diff --git a/package.json b/package.json index 9f7660c..086a8bd 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,7 @@ "icon": "./icos/", "files": [ "newton/", - "build/", - "!node_modules/" + "build/" ], "mac": { "category": "public.app-category.developer-tools" @@ -83,4 +82,4 @@ "karma-jasmine-html-reporter": "2.1.0", "typescript": "5.7.2" } -} \ No newline at end of file +} diff --git a/src/app/common/services/editor/modals/files-modal.service.ts b/src/app/common/services/editor/modals/files-modal.service.ts new file mode 100644 index 0000000..d25db9c --- /dev/null +++ b/src/app/common/services/editor/modals/files-modal.service.ts @@ -0,0 +1,34 @@ +import { Injectable } from '@angular/core'; +import { ReplaySubject, Observable } from 'rxjs'; + + + +@Injectable({ + providedIn: 'root' +}) +export class FilesModalService { + private showFilesModalSubject: ReplaySubject = new ReplaySubject(1); + private addFileSubject: ReplaySubject = new ReplaySubject(1); + + + constructor() { + } + + + showFilesModal(): void { + this.showFilesModalSubject.next(null); + } + + showFilesModalRequested$(): Observable { + return this.showFilesModalSubject.asObservable(); + } + + addFileToModal(data: string): void { + this.addFileSubject.next(data); + } + + addFileToModalRequested$(): Observable { + return this.addFileSubject.asObservable(); + } + +} \ No newline at end of file diff --git a/src/app/editor/editors.component.html b/src/app/editor/editors.component.html index 18e4111..5af5104 100644 --- a/src/app/editor/editors.component.html +++ b/src/app/editor/editors.component.html @@ -35,4 +35,6 @@ + +
\ No newline at end of file diff --git a/src/app/editor/editors.component.ts b/src/app/editor/editors.component.ts index 3e2cf8d..fccfb3c 100644 --- a/src/app/editor/editors.component.ts +++ b/src/app/editor/editors.component.ts @@ -2,6 +2,7 @@ import { Component, ElementRef, ViewChild, TemplateRef, ComponentRef, ViewContai import { Subject, takeUntil } from 'rxjs'; import { NewtonEditorComponent } from "./newton-editor/newton-editor.component"; +import { FilesModalComponent } from "./modals/files-modal.component"; import { EditorsService } from '../common/services/editor/editors.service'; import { FilesService } from '../common/services/editor/files.service'; @@ -15,7 +16,8 @@ import { ServiceMessage } from '../common/types/service-message.type'; selector: 'editors', standalone: true, imports: [ - DndDirective + DndDirective, + FilesModalComponent ], templateUrl: './editors.component.html', styleUrl: './editors.component.css', diff --git a/src/app/editor/modals/files-modal.component.css b/src/app/editor/modals/files-modal.component.css new file mode 100644 index 0000000..0f2a2b5 --- /dev/null +++ b/src/app/editor/modals/files-modal.component.css @@ -0,0 +1,16 @@ +.modal-column { + min-height: 24em; + max-height: 24em; + overflow: auto; +} + +.close-button { + background: rgba(116, 0, 0, 0.64); + border-style: solid; + border-color: rgba(0, 0, 0, 0.64); + border-width: 1px; +} + +.close-button:hover { + background: rgba(256, 0, 0, 0.64); +} \ No newline at end of file diff --git a/src/app/editor/modals/files-modal.component.html b/src/app/editor/modals/files-modal.component.html new file mode 100644 index 0000000..5fb50d2 --- /dev/null +++ b/src/app/editor/modals/files-modal.component.html @@ -0,0 +1,52 @@ + \ No newline at end of file diff --git a/src/app/editor/modals/files-modal.component.ts b/src/app/editor/modals/files-modal.component.ts new file mode 100644 index 0000000..358aa10 --- /dev/null +++ b/src/app/editor/modals/files-modal.component.ts @@ -0,0 +1,85 @@ +import { Component } from "@angular/core"; +import { CommonModule } from "@angular/common"; + +import { Subject, takeUntil } from 'rxjs'; + +import * as bootstrap from "bootstrap"; + +import { FilesModalService } from "../../common/services/editor/modals/files-modal.service"; +import { TabsService } from '../../common/services/editor/tabs/tabs.service'; + +import { ServiceMessage } from '../../common/types/service-message.type'; + + + +@Component({ + selector: 'files-modal', + standalone: true, + imports: [ + CommonModule + ], + templateUrl: './files-modal.component.html', + styleUrl: './files-modal.component.css', + host: { + 'class': '' + } +}) +export class FilesModalComponent { + private unsubscribe = new Subject(); + + filesModal!: bootstrap.Modal; + files: any[] = []; + + + constructor( + private filesModalService: FilesModalService, + private tabsService: TabsService + ) { + } + + + public ngAfterViewInit(): void { + this.loadSubscribers(); + } + + loadSubscribers() { + this.tabsService.getData$().pipe( + takeUntil(this.unsubscribe) + ).subscribe((data: ServiceMessage) => { + if (data.action === "create-tab") { + this.createFileRow(data.message, data.uuid, data.data); + } + }); + + this.filesModalService.showFilesModalRequested$().pipe( + takeUntil(this.unsubscribe) + ).subscribe(() => { + if (!this.filesModal) { + this.createModal(); + } + + this.showModal(); + }); + + this.filesModalService.addFileToModalRequested$().pipe( + takeUntil(this.unsubscribe) + ).subscribe((uuid: string) => { + if (!this.filesModal) { + this.createModal(); + } + }); + } + + private createFileRow(title: string, uuid: string, path: string): void { + this.files.push({title: title, path: path, uuid: uuid}) + } + + createModal() { + this.filesModal = new bootstrap.Modal("#filesModal", {}); + } + + showModal() { + this.filesModal?.toggle(); + } + +} \ No newline at end of file diff --git a/src/app/editor/newton-editor/newton-editor.component.ts b/src/app/editor/newton-editor/newton-editor.component.ts index 9992b56..4635a72 100644 --- a/src/app/editor/newton-editor/newton-editor.component.ts +++ b/src/app/editor/newton-editor/newton-editor.component.ts @@ -9,8 +9,9 @@ import "ace-builds/src-noconflict/theme-one_dark"; import "ace-builds/src-noconflict/theme-dracula"; import { InfoBarService } from '../../common/services/editor/info-bar/info-bar.service'; -import { EditorsService } from '../../common/services/editor/editors.service'; +import { FilesModalService } from '../../common/services/editor/modals/files-modal.service'; import { LSPService } from '../../common/services/lsp.service'; +import { EditorsService } from '../../common/services/editor/editors.service'; import { NewtonEditorBase } from './newton-editor.base'; @@ -33,7 +34,8 @@ export class NewtonEditorComponent extends NewtonEditorBase { constructor( private infoBarService: InfoBarService, private editorsService: EditorsService, - private lspService: LSPService + private lspService: LSPService, + private filesModalService: FilesModalService ) { super(); } @@ -174,6 +176,13 @@ export class NewtonEditorComponent extends NewtonEditorBase { this.saveFileAs(); }, readOnly: false + }, { + name: "showModal", + bindKey: {win: "ctrl-b", mac: "ctrl-b"}, + exec: () => { + this.filesModalService.showFilesModal(); + }, + readOnly: false } ]); diff --git a/src/app/editor/tabs/tabs.component.css b/src/app/editor/tabs/tabs.component.css index 6622d33..3a10c2a 100644 --- a/src/app/editor/tabs/tabs.component.css +++ b/src/app/editor/tabs/tabs.component.css @@ -1,6 +1,9 @@ +.display-contents { + display: contents; +} + .tab { display: flex; - overflow: auto; float: left; margin-right: 2em; font-size: 0.2em; diff --git a/src/app/editor/tabs/tabs.component.html b/src/app/editor/tabs/tabs.component.html index abbb25c..52998c7 100644 --- a/src/app/editor/tabs/tabs.component.html +++ b/src/app/editor/tabs/tabs.component.html @@ -4,6 +4,7 @@ cdkDropListOrientation="horizontal" (cdkDropListDropped)="dropped($event)" (click)="handleAction($event)" + class="display-contents" >
{ - if (data.action === "create-tab") + if (data.action === "create-tab") { this.createTab(data.message, data.uuid, data.data); + } }); } diff --git a/src/assets/css/styles.css b/src/assets/css/styles.css index 2162975..fb14ed2 100644 --- a/src/assets/css/styles.css +++ b/src/assets/css/styles.css @@ -32,6 +32,8 @@ body { padding-bottom: 0.4em; padding-top: 0.4em; color: rgba(255, 255, 255, 0.64); + margin-left: 0.2em; + margin-right: 0.2em; } diff --git a/src/index.html b/src/index.html index 8714d3d..d0f0031 100644 --- a/src/index.html +++ b/src/index.html @@ -1,5 +1,5 @@ - + Newton