第 7 步之后
将 ckeditor 代码添加到 package.json
“依赖”:{
...
"@ckeditor/ckeditor5-angular": "^1.1.2",
...
}
第 8 步:
npm 安装
第 9 步:
在 app.module.ts 文件中可以添加
import { CKEditorModule } from '@ckeditor/ckeditor5-angular';
import { FormsModule } from '@angular/forms';
import { ReactiveFormsModule } from '@angular/forms';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
FormsModule,
ReactiveFormsModule,
CKEditorModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
第 10 步:
在文件 tsconfig.json 中添加 allowJs: ture
"compilerOptions": {
"allowJs": true,
}
第 11 步:
将 CKEditor 导入到您的组件中:
import * as ClassicEditor from '../../assets/js/ck-editor-math-type/ckeditor.js';
...
export class CkeditComponent implements OnInit {
public Editor = ClassicEditor;
public model = {
editorData: '<p>Hello, world!</p>'
};
}
第 12 步:
将它也添加到你的 template.html
<ckeditor [(ngModel)]="model.editorData" [editor]="Editor"></ckeditor>