|
|
|
@ -1,12 +1,12 @@
|
|
|
|
|
import {Component, Input, ViewChild} from '@angular/core';
|
|
|
|
|
import {BackendService} from 'src/app/services/backendService.service';
|
|
|
|
|
import {Compartment, StateEffect} from '@codemirror/state';
|
|
|
|
|
import {CodeMirrorComponent} from '@sandkasten/codemirror6-editor';
|
|
|
|
|
import {LanguageDescription} from '@codemirror/language';
|
|
|
|
|
import {CODE_DEFAULTS, LANGUAGES} from '../languages';
|
|
|
|
|
import {SafeHTMLPipe} from '../../safe-html.pipe';
|
|
|
|
|
import {ReactiveFormsModule, FormsModule} from '@angular/forms';
|
|
|
|
|
import {Router} from '@angular/router';
|
|
|
|
|
import { Component, Input, ViewChild } from '@angular/core';
|
|
|
|
|
import { BackendService } from 'src/app/services/backendService.service';
|
|
|
|
|
import { Compartment, StateEffect } from '@codemirror/state';
|
|
|
|
|
import { CodeMirrorComponent } from '@sandkasten/codemirror6-editor';
|
|
|
|
|
import { LanguageDescription } from '@codemirror/language';
|
|
|
|
|
import { CODE_DEFAULTS, LANGUAGES } from '../languages';
|
|
|
|
|
import { SafeHTMLPipe } from '../../safe-html.pipe';
|
|
|
|
|
import { ReactiveFormsModule, FormsModule } from '@angular/forms';
|
|
|
|
|
import { Router } from '@angular/router';
|
|
|
|
|
import {
|
|
|
|
|
keymap,
|
|
|
|
|
highlightSpecialChars,
|
|
|
|
@ -19,7 +19,7 @@ import {
|
|
|
|
|
highlightActiveLineGutter,
|
|
|
|
|
gutter,
|
|
|
|
|
} from '@codemirror/view';
|
|
|
|
|
import {Extension, EditorState} from '@codemirror/state';
|
|
|
|
|
import { Extension, EditorState } from '@codemirror/state';
|
|
|
|
|
import {
|
|
|
|
|
defaultHighlightStyle,
|
|
|
|
|
syntaxHighlighting,
|
|
|
|
@ -28,21 +28,21 @@ import {
|
|
|
|
|
foldGutter,
|
|
|
|
|
foldKeymap,
|
|
|
|
|
} from '@codemirror/language';
|
|
|
|
|
import {defaultKeymap, history, historyKeymap} from '@codemirror/commands';
|
|
|
|
|
import {searchKeymap, highlightSelectionMatches} from '@codemirror/search';
|
|
|
|
|
import { defaultKeymap, history, historyKeymap } from '@codemirror/commands';
|
|
|
|
|
import { searchKeymap, highlightSelectionMatches } from '@codemirror/search';
|
|
|
|
|
import {
|
|
|
|
|
autocompletion,
|
|
|
|
|
completionKeymap,
|
|
|
|
|
closeBrackets,
|
|
|
|
|
closeBracketsKeymap,
|
|
|
|
|
} from '@codemirror/autocomplete';
|
|
|
|
|
import {lintKeymap} from '@codemirror/lint';
|
|
|
|
|
import { lintKeymap } from '@codemirror/lint';
|
|
|
|
|
import {
|
|
|
|
|
Connection,
|
|
|
|
|
getDocument,
|
|
|
|
|
peerExtension,
|
|
|
|
|
} from '../../services/connection.service';
|
|
|
|
|
import {environment} from "../../../environments/environment";
|
|
|
|
|
import { environment } from '../../../environments/environment';
|
|
|
|
|
|
|
|
|
|
const basicSetup: Extension = (() => [
|
|
|
|
|
highlightActiveLineGutter(),
|
|
|
|
@ -53,7 +53,7 @@ const basicSetup: Extension = (() => [
|
|
|
|
|
dropCursor(),
|
|
|
|
|
EditorState.allowMultipleSelections.of(true),
|
|
|
|
|
indentOnInput(),
|
|
|
|
|
syntaxHighlighting(defaultHighlightStyle, {fallback: true}),
|
|
|
|
|
syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
|
|
|
|
|
bracketMatching(),
|
|
|
|
|
closeBrackets(),
|
|
|
|
|
autocompletion(),
|
|
|
|
@ -153,7 +153,7 @@ export class EditorComponent {
|
|
|
|
|
this.client = new WebSocket(`${environment.webSocketUrl}/live/${idRoom}`);
|
|
|
|
|
this.client.addEventListener('open', async () => {
|
|
|
|
|
let conn = new Connection(this.client!);
|
|
|
|
|
let {version, doc} = await getDocument(conn);
|
|
|
|
|
let { version, doc } = await getDocument(conn);
|
|
|
|
|
|
|
|
|
|
this.codemirror.editor?.dispatch({
|
|
|
|
|
changes: {
|
|
|
|
@ -218,7 +218,7 @@ export class EditorComponent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
saveToFile() {
|
|
|
|
|
const blob = new Blob([this.editorContent], {type: 'text/plain'});
|
|
|
|
|
const blob = new Blob([this.editorContent], { type: 'text/plain' });
|
|
|
|
|
const a = document.createElement('a');
|
|
|
|
|
a.download = `code.${this.selectedLanguage.extensions![0]}`;
|
|
|
|
|
a.href = URL.createObjectURL(blob);
|
|
|
|
|