html-code-editor.ts

27 lines | 1.005 kB Blame History Raw Download
import { CodeEditor } from "./code-editor";
import * as monaco from 'monaco-editor';
import initHtml from '!!raw-loader!./injects/editor-init.html';

export class HtmlCodeEditor extends CodeEditor {
    setInitInput(): string {
        return initHtml;
    }

    setInitSettings(): void {
        monaco.languages.registerCompletionItemProvider("html", {
            provideCompletionItems: (model, position, context, token) => {
                return {
                    suggestions: [
                        {
                            label: 'jqueryCDN',
                            kind: monaco.languages.CompletionItemKind.Snippet,
                            insertText: "<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js'></script>",
                            range: <any>null,
                            insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet
                        }
                    ]
                }
            }
        });
    }
}