首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ngx-quill工具栏自定义不起作用- quill无法导入模块

Ngx-quill工具栏自定义不起作用- quill无法导入模块
EN

Stack Overflow用户
提问于 2018-11-27 08:52:08
回答 3查看 7.7K关注 0票数 5

更新:当我意识到PrimeNg有一个羽毛笔实现,并且我已经在使用PrimeNg时,我放弃了。起初不能工作,但升级到angular 7和ngrx 7测试版修复了问题。https://www.primefaces.org/primeng/#/editor

我正在尝试用一个比默认工具栏更完整的工具栏在我的项目中设置ngx-quill文本编辑器。我只是个copying this code snippet from the documentation,还没有调整过!

如果我不包含模块属性,我不会得到任何浏览器错误,但我想知道我是否有一个导入问题,只有当我尝试添加它时才显示出来?

instructions.html

代码语言:javascript
复制
 <quill-editor modules="editorOptions"></quill-editor>

instructions.ts

代码语言:javascript
复制
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
        ]
    };

浏览器中的错误:

EN

回答 3

Stack Overflow用户

发布于 2019-03-29 02:03:47

您好,您可能会收到此错误,因为modules是一个输入,应该用括号括起来

代码语言:javascript
复制
 <quill-editor
    theme="bubble"
    [placeholder]="editorPlacehorder"
    [modules]="moduleConfig"
    [(ngModel)]="ngModelValue"
    (onContentChanged)="onContentChanged($event)">
  </quill-editor>

并确保已经在模块QuillModule中导入了

代码语言:javascript
复制
import { QuillModule } from 'ngx-quill';

还要将此模块添加到ex的模块文件中的imports数组中。AppModule

代码语言:javascript
复制
imports: [
    QuillModule
]

还要确保你已经在angular.json中导入了所有文件,以使羽毛笔工作

代码语言:javascript
复制
  "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"
        ]

我希望这对你有用,如果你有任何问题,请随时问他们!

票数 2
EN

Stack Overflow用户

发布于 2019-11-07 18:00:23

在这里我给出了"ngx-quill": "^5.1.0"版本的答案。

在app.module.ts文件中

代码语言:javascript
复制
import { QuillModule } from 'ngx-quill';

@NgModule({
  imports: [QuillModule]
})

在style.css文件中

代码语言:javascript
复制
@import "~quill/dist/quill.bubble.css";
@import "~quill/dist/quill.snow.css";

在您的html文件中

代码语言:javascript
复制
<quill-editor [modules]="modules" [(ngModel)]="model"></quill-editor>
{{model}}

在您的typescript文件中

代码语言:javascript
复制
model: string = '';

  modules: {
    toolbar: [
      ['bold', 'italic', 'underline', 'strike'],        // toggled buttons
      ['blockquote'],

      [{'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

    ]
  };
票数 1
EN

Stack Overflow用户

发布于 2020-01-23 23:39:14

即使你跳槽了,相信这只是你的html:

代码语言:javascript
复制
<quill-editor modules="editorOptions"></quill-editor>

应该是

代码语言:javascript
复制
<quill-editor [modules]="editorOptions"></quill-editor>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53491252

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档