Quill 编辑器:检查 Angular 内容的变化? [英] Quill Editor : Check for change in content in Angular?

查看:32
本文介绍了Quill 编辑器:检查 Angular 内容的变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过创建 quill 的新实例和创建自定义工具栏在 Angular 中实现了 quill 编辑器.

I have implemented quill editor in Angular by creating new instance of quill and creating custom toolbar.

    this.quill = new Quill('#editor-container', {
        modules: {
            toolbar: '#toolbar-container'
        },
        theme: 'snow' // or 'bubble'
    });

我有一个更新"按钮将调用更新 API.我需要检查 Quill 编辑器的内容是否已更改.我知道 quill.on('text-change'):

I have a "update" button which would call the update API. I need to check if the contents of the Quill editor has changed. I am aware of quill.on('text-change'):

    this.quill.on('text-change', function(delta, oldDelta, source) {
        if (source == 'api') {
            console.log('An API call triggered this change.');
        } else if (source == 'user') {
            console.log('A user action triggered this change.');
        }
    });

但是,我不确定应该把它放在哪里?NgOnInit?NgAfterViewInit?我在 ngAfterViewInit 中创建了 quill 实例.我知道这可能是个愚蠢的问题.

However, I am not sure where do I place this? NgOnInit? NgAfterViewInit? I have created the quill instance in ngAfterViewInit. I know this could be a dumb question.

任何帮助表示赞赏!谢谢!:)

Any help appreciated! thanks! :)

推荐答案

可以放在模块/组件的构造函数中.

You can put it in the constructor of the module/component.

这篇关于Quill 编辑器:检查 Angular 内容的变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆