|
@@ -97,4 +97,35 @@ export const initializeMagicScript = () => {
|
|
|
}]
|
|
|
}
|
|
|
})
|
|
|
+ // 设置html闭合标签提示
|
|
|
+ monaco.languages.registerCompletionItemProvider('html', {
|
|
|
+ triggerCharacters: ['>'],
|
|
|
+ provideCompletionItems: (model, position) => {
|
|
|
+ const codePre = model.getValueInRange({
|
|
|
+ startLineNumber: position.lineNumber,
|
|
|
+ startColumn: 1,
|
|
|
+ endLineNumber: position.lineNumber,
|
|
|
+ endColumn: position.column,
|
|
|
+ })
|
|
|
+ const tag = codePre.match(/.*<(\w+)>$/)?.[1];
|
|
|
+ if (!tag) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const word = model.getWordUntilPosition(position);
|
|
|
+ return {
|
|
|
+ suggestions: [{
|
|
|
+ label: `</${tag}>`,
|
|
|
+ kind: monaco.languages.CompletionItemKind.EnumMember,
|
|
|
+ insertText: `$1</${tag}>`,
|
|
|
+ insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
|
+ range: {
|
|
|
+ startLineNumber: position.lineNumber,
|
|
|
+ endLineNumber: position.lineNumber,
|
|
|
+ startColumn: word.startColumn,
|
|
|
+ endColumn: word.endColumn,
|
|
|
+ }
|
|
|
+ }]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|