gpt4 book ai didi

Angular-cli 和 Ckeditor4 自定义构建

转载 作者:行者123 更新时间:2023-12-04 14:19:33 25 4
gpt4 key购买 nike

我正在设置我自己的 CkEditor4 构建,我需要从我的 Angular-cli 应用程序访问它。我不知道如何访问我的 Angular 项目中的 ckeditor.js 文件。
我不想使用 CDN。

我查了CKEditor提供的文档:https://ckeditor.com/docs/ckeditor4/latest/guide/dev_angular.html

我知道我需要在我的项目中的某处写下这两行。

<script src="my-custom-build/ckeditor.js"></script>
<script src="your-app-bundle.js"></script>

我尝试了很多解决方案,但没有一个主题有效。
- 将 ckeditor.js 路径放在 angular.json 中的脚本中
- 将脚本标签放在 index.html 文件的标题中

包.Json
{
"name": "web2print",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^7.2.15",
"@angular/cdk": "^7.3.7",
"@angular/common": "~7.2.0",
"@angular/compiler": "~7.2.0",
"@angular/core": "~7.2.0",
"@angular/flex-layout": "^7.0.0-beta.24",
"@angular/forms": "~7.2.0",
"@angular/http": "^7.2.15",
"@angular/material": "^7.3.7",
"@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0",
"@angular/router": "~7.2.0",
"angular2-image-gallery": "^7.0.0",
"ckeditor4-angular": "^0.1.2",
"core-js": "^2.6.8",
"cors": "^2.8.5",
"express": "^4.17.0",
"hammerjs": "^2.0.8",
"ng2-ckeditor": "^1.2.2",
"ng2-file-upload": "^1.3.0",
"ngx-build-plus": "^7.8.3",
"rxjs": "~6.5.2",
"rxjs-compat": "^6.5.2",
"screenfull": "^4.2.0",
"tslib": "^1.9.0",
"webpack": "^4.32.2",
"webpack-cli": "^3.3.2",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.13.0",
"@angular/cli": "~7.3.9",
"@angular/compiler-cli": "~7.2.0",
"@angular/language-service": "~7.2.0",
"@types/node": "~8.9.4",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.2.2"
}
}

索引.html

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Web2print</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script src="ckeditor/ckeditor.js"></script>
</head>
<body>
<app-root></app-root>
</body>
</html>


editor.component.ts

import {AfterViewChecked, Component} from '@angular/core';
import { CKEditorModule, CKEditorComponent } from 'ng2-ckeditor';



@Component( {
selector: 'app-editor',
templateUrl: './editor.component.html',
styleUrls: [ './editor.component.css' ]
} )
export class EditorComponent {

}

错误信息:
GET http://localhost:4200/ckeditor/ckeditor.js net::ERR_ABORTED 404 (Not Found)

最佳答案

使用 build tool 配置 CKEditor 4 构建后,下载它,解压缩它,然后将它移动到“assets”文件夹中的一个目录中。我使用一个名为“供应商”的文件夹:

ckeditor file location

然后设置ckeditor组件的editorUrl参数:

<ckeditor [(ngModel)]="template"
editorUrl="/assets/vendor/ckeditor/ckeditor.js"
[config]="ckeditorConfig"
(ready)="onEditorReady()">
</ckeditor>

关于Angular-cli 和 Ckeditor4 自定义构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56342547/

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