Add system try; refactored editor naming
This commit is contained in:
@@ -4,7 +4,7 @@ import { Subject, takeUntil } from 'rxjs';
|
||||
import { EditSession } from 'ace-builds';
|
||||
import { getModeForPath } from 'ace-builds/src-noconflict/ext-modelist';
|
||||
|
||||
import { AceEditorComponent } from "./ace/ace-editor.component";
|
||||
import { NewtonEditorComponent } from "./newton-editor/newton-editor.component";
|
||||
import { EditorsService } from '../common/services/editor/editors.service';
|
||||
import { TabsService } from '../common/services/editor/tabs/tabs.service';
|
||||
|
||||
@@ -31,7 +31,7 @@ export class EditorsComponent {
|
||||
private unsubscribe = new Subject<void>();
|
||||
|
||||
@ViewChild('containerRef', {read: ViewContainerRef}) containerRef!: ViewContainerRef;
|
||||
editors: Map<string, ComponentRef<AceEditorComponent>>;
|
||||
editors: Map<string, ComponentRef<NewtonEditorComponent>>;
|
||||
editorSettings: typeof EditorSettings;
|
||||
files: Map<string, NewtonFile>;
|
||||
activeEditor!: string;
|
||||
@@ -43,7 +43,7 @@ export class EditorsComponent {
|
||||
private tabsService: TabsService
|
||||
) {
|
||||
this.editorSettings = EditorSettings;
|
||||
this.editors = new Map<string, ComponentRef<AceEditorComponent>>();
|
||||
this.editors = new Map<string, ComponentRef<NewtonEditorComponent>>();
|
||||
this.files = new Map<string, NewtonFile>();
|
||||
}
|
||||
|
||||
@@ -141,6 +141,8 @@ export class EditorsComponent {
|
||||
case "zoom-out":
|
||||
editorComponent.zoomOut()
|
||||
break;
|
||||
case "open-settings":
|
||||
editor.showSettingsMenu();
|
||||
case "show-about":
|
||||
break;
|
||||
default:
|
||||
@@ -155,7 +157,7 @@ export class EditorsComponent {
|
||||
}
|
||||
|
||||
private createEditor() {
|
||||
const component = this.containerRef.createComponent(AceEditorComponent);
|
||||
const component = this.containerRef.createComponent(NewtonEditorComponent);
|
||||
component.instance.editorSettings = this.editorSettings;
|
||||
this.editors.set(component.instance.uuid, component)
|
||||
|
||||
|
@@ -7,7 +7,7 @@ import { NewtonFile } from '../../common/types/file.type';
|
||||
|
||||
|
||||
@Directive()
|
||||
export class AceEditorBase {
|
||||
export class NewtonEditorBase {
|
||||
@ViewChild('editor') editorElm!: ElementRef;
|
||||
@Input() editorSettings!: typeof EditorSettings;
|
||||
editor!: any;
|
||||
@@ -32,6 +32,10 @@ export class AceEditorBase {
|
||||
this.editorElm.nativeElement.classList.remove("active-editor")
|
||||
}
|
||||
|
||||
public commander() {
|
||||
this.editor.execCommand("openCommandPalette");
|
||||
}
|
||||
|
||||
protected search() {
|
||||
console.log(this.editor.session.getMode()["$id"]);
|
||||
}
|
@@ -2,30 +2,32 @@ import { Component } from "@angular/core";
|
||||
|
||||
// Import Ace and its modes/themes so that `ace` global is defined
|
||||
import * as ace from "ace-builds/src-noconflict/ace";
|
||||
import "ace-builds/src-noconflict/ext-settings_menu";
|
||||
import "ace-builds/src-noconflict/ext-command_bar";
|
||||
import "ace-builds/src-noconflict/ext-language_tools";
|
||||
import "ace-builds/src-noconflict/theme-one_dark";
|
||||
import "ace-builds/src-noconflict/theme-dracula";
|
||||
import "ace-builds/src-noconflict/ext-language_tools";
|
||||
|
||||
import { InfoBarService } from '../../common/services/editor/info-bar/info-bar.service';
|
||||
import { EditorsService } from '../../common/services/editor/editors.service';
|
||||
import { LSPService } from '../../common/services/lsp.service';
|
||||
|
||||
import { AceEditorBase } from './ace-editor.base';
|
||||
import { NewtonEditorBase } from './newton-editor.base';
|
||||
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'ace-editor',
|
||||
selector: 'newton-editor',
|
||||
standalone: true,
|
||||
imports: [
|
||||
],
|
||||
templateUrl: './ace-editor.component.html',
|
||||
styleUrl: './ace-editor.component.css',
|
||||
templateUrl: './newton-editor.component.html',
|
||||
styleUrl: './newton-editor.component.css',
|
||||
host: {
|
||||
'class': 'col'
|
||||
}
|
||||
})
|
||||
export class AceEditorComponent extends AceEditorBase {
|
||||
export class NewtonEditorComponent extends NewtonEditorBase {
|
||||
|
||||
|
||||
constructor(
|
||||
@@ -52,7 +54,14 @@ export class AceEditorComponent extends AceEditorBase {
|
||||
this.editor.setOptions( this.editorSettings.CONFIG );
|
||||
// this.editor.commands.addCommands( this.editorSettings.KEYBINDINGS );
|
||||
this.editor.commands.addCommands([
|
||||
{
|
||||
{
|
||||
name: "openCommandPalette2",
|
||||
bindKey: {linux: "Command-Shift-/|F1", win: "Ctrl-Shift-/|F1"},
|
||||
exec: () => {
|
||||
this.commander();
|
||||
},
|
||||
readOnly: false
|
||||
}, {
|
||||
name: "search",
|
||||
bindKey: {win: "ctrl-f", mac: "ctrl-f"},
|
||||
exec: () => {
|
||||
@@ -142,6 +151,10 @@ export class AceEditorComponent extends AceEditorBase {
|
||||
|
||||
|
||||
// Note: https://ajaxorg.github.io/ace-api-docs/interfaces/ace.Ace.EditorEvents.html
|
||||
this.editor.on("changeStatus", (e) => {
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
this.editor.on("click", () => {
|
||||
this.updateInfoBar();
|
||||
});
|
Reference in New Issue
Block a user