azu*_*net 5 quill angular angular7 ngx-quill
更新:当我意识到 PrimeNg 有一个 quill 实现并且我已经在使用 PrimeNg 时,我放弃了。一开始无法正常工作,但升级到 angular 7 和 ngrx 7 beta 修复了问题。https://www.primefaces.org/primeng/#/editor
我正在尝试使用比默认工具栏更完整的工具栏在我的项目中设置 ngx-quill 文本编辑器。我只是从文档中复制了这个代码片段并且还没有调整(还没有!)。
如果我不包含 modules 属性,我不会收到任何浏览器错误,但我想知道是否存在仅在我尝试添加时才显示的导入问题?
说明.html
<quill-editor modules="editorOptions"></quill-editor>
Run Code Online (Sandbox Code Playgroud)
说明.ts
import { Component, Input, Output, EventEmitter } from '@angular/core';
import * as Quill from 'quill';
@Component({
selector: 'instructions',
templateUrl: '../admin/instructions.html'
})
export class Instructions {
public editorOptions = {
toolbar: [
['bold', 'italic', 'underline', 'strike'], // toggled buttons
['blockquote', 'code-block'],
[{ 'header': 1 }, { 'header': 2 }], // custom button values
[{ 'list': 'ordered' }, { 'list': 'bullet' }],
[{ 'script': 'sub' }, { 'script': 'super' }], // superscript/subscript
[{ 'indent': '-1' }, { 'indent': '+1' }], // outdent/indent
[{ 'direction': 'rtl' }], // text direction
[{ 'size': ['small', false, 'large', 'huge'] }], // custom dropdown
[{ 'header': [1, 2, 3, 4, 5, 6, false] }],
[{ 'color': [] }, { 'background': [] }], // dropdown with defaults from theme
[{ 'font': [] }],
[{ 'align': [] }],
['clean'], // remove formatting button
['link', 'image', 'video'] // link and image, video
]
};
Run Code Online (Sandbox Code Playgroud)
您好,您可能会收到此错误,因为modules是输入,应该用括号括起来
<quill-editor
theme="bubble"
[placeholder]="editorPlacehorder"
[modules]="moduleConfig"
[(ngModel)]="ngModelValue"
(onContentChanged)="onContentChanged($event)">
</quill-editor>
Run Code Online (Sandbox Code Playgroud)
并确保您已在模块中导入 QuillModule
import { QuillModule } from 'ngx-quill';
Run Code Online (Sandbox Code Playgroud)
还可以将此模块添加到模块文件中的导入数组中。应用程序模块
imports: [
QuillModule
]
Run Code Online (Sandbox Code Playgroud)
并确保您已导入angular.json所有文件以使 Quill 工作
"styles": [
"node_modules/quill/dist/quill.core.css",
"node_modules/quill/dist/quill.bubble.css",
"node_modules/quill/dist/quill.snow.css",
"node_modules/quill-emoji/dist/quill-emoji.css",
"node_modules/quill-mention/dist/quill.mention.min.css"
],
"scripts": [
"node_modules/quill/dist/quill.min.js",
"node_modules/quill-mention/dist/quill.mention.min.js"
]
Run Code Online (Sandbox Code Playgroud)
我希望这对您有用,如果您有任何问题,请随时询问他们!
| 归档时间: |
|
| 查看次数: |
7243 次 |
| 最近记录: |