gpt4 book ai didi

angular - Ace 编辑器自动完成到 Angular 2?

转载 作者:太空狗 更新时间:2023-10-29 17:54:15 27 4
gpt4 key购买 nike

我正在使用 ace editor并尝试在编辑器中实现自动完成。我尝试了选项,但它不起作用,我收到警告。有什么想法吗?

Ace 编辑器组件

import {
Component, EventEmitter, Input, OnInit, Output, ViewChild
} from '@angular/core';

@Component({
selector: 'neon-ace-editor',
templateUrl: './ace-editor.component.html',
styleUrls: ['./ace-editor.component.scss']
})
export class AceEditorComponent implements OnInit {
@Input() mode = 'html';
@Input() autoUpdateContent = true;
@Input() content: string;
@Output() onContentChange: EventEmitter<string> = new EventEmitter();
@ViewChild('editor') editor;
options = {
enableBasicAutocompletion: true,
enableSnippets: true,
enableLiveAutocompletion: true
};
ngOnInit(): void {
this.editor._editor.$blockScrolling = Infinity;
}

onContentChanging(): void {
this.onContentChange.emit(this.content);
}
}

Ace 编辑器 Html

<ace-editor [(text)]="content"
#editor
(textChanged)="onContentChanging()"
[options]="options"
[autoUpdateContent]="autoUpdateContent"
style="min-height: 500px; width:100%; font-size:18px;overflow: auto;"
[mode]="mode"></ace-editor>

问题:

自动完成功能不起作用。

控制台中的警告消息

enter image description here

最佳答案

试试这个应用程序模块.ts

imports: [
...,
AceEditorModule // import AceEditorModule
]

应用程序组件.ts

import {Component, OnInit, ViewChild} from '@angular/core';

import 'brace';
import 'brace/ext/language_tools';
import 'ace-builds/src-min-noconflict/snippets/html';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
text = '';
@ViewChild('editor') editor;
options: any = {
enableBasicAutocompletion: true,
enableSnippets: true,
enableLiveAutocompletion: true,
};

ngOnInit() {
// disable Automatically scrolling cursor into view after selection change warning
this.editor.getEditor().$blockScrolling = Infinity;
}
}
app.component.html

<ace-editor
theme="monokai"
mode="html"
[options]="options"
#editor
style=" min-height: 600px; width:100%;overflow: auto;"
>
</ace-editor>
.angular-cli.json

"scripts": [],

更多discusstion

关于angular - Ace 编辑器自动完成到 Angular 2?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44968266/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com