Skip to content

Commit

Permalink
feat!(common): add context editor for code editor in plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Falcion committed Oct 22, 2024
1 parent 473591f commit 9e0f2df
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions source/components/contexts/contextEditor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

import * as monaco from 'monaco-editor';

import UNITADE_PLUGIN from './../../main';
import { genEditorSettings } from './../../utils/utils';

export class ContextEditor {
contentEl: HTMLElement;
value = "";
monacoEditor: monaco.editor.IStandaloneCodeEditor;
plugin: UNITADE_PLUGIN;

constructor(contentEl: HTMLElement, plugin: UNITADE_PLUGIN, code: string, language: string, miniMap: boolean = true, wordWrap: boolean = false) {
this.contentEl = contentEl;
this.plugin = plugin;
this.value = code;

const setting = genEditorSettings(this.plugin.settings, language, miniMap, wordWrap);

this.monacoEditor = monaco.editor.create(this.contentEl, setting);
this.monacoEditor.setValue(this.value);
}

getValue() {
return this.monacoEditor.getValue();
}
}

0 comments on commit 9e0f2df

Please sign in to comment.