css-code-editor.ts

29 lines | 1005 B Blame History Raw Download
import { CodeEditor } from "./code-editor";
import * as monaco from 'monaco-editor';
import initCss from '!!raw-loader!./injects/editor-init.css';

import flexCss from '!!raw-loader!../../../shared/flex.less';

export class CssCodeEditor extends CodeEditor {
    setInitInput(): string {
        return initCss;
    }

    setInitSettings(): void {
        monaco.languages.registerCompletionItemProvider("css", {
            provideCompletionItems: (model, position, context, token) => {
                return {
                    suggestions: [
                        {
                            label: 'insert-flex',
                            kind: monaco.languages.CompletionItemKind.Snippet,
                            insertText: flexCss,
                            range: <any>null,
                            insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet
                        }
                    ]
                }
            }
        });
    }
}