简体   繁体   English

如何将Quill.js应用于已经可编辑的元素?

[英]How to apply Quill.js to an already content editable element?

The problem: 问题:

I have to use the Delta and Event features of Quill.js to provide some contextual dropdowns on specific keywords within the Gmail Composer (on gmail.com) in a chrome extension. 我必须使用Quill.js的Delta和Event功能在chrome扩展程序中的Gmail Composer(在gmail.com上)中提供有关特定关键字的一些上下文下拉菜单。

The problem is that the Gmail Composer already has a content editable element. 问题在于Gmail Composer已经具有可编辑的内容元素。 When I apply Quill.js to it, I end up with another contenteditable element within the gmail composer element. 当我将Quill.js应用于它时,我最终在gmail composer元素中有了另一个contenteditable元素。 With a simple backspace the Quill.js editor actually gets deleted and the functionality of quill is pretty much broken in many other ways. 使用一个简单的退格键 ,实际上删除了Quill.js编辑器,并且在许多其他方式下,该Quill的功能也几乎被破坏了。

I can't remove the Gmail Composer's editor because then I remove basic Gmail functions like Attachments, Links, Emoticons etc. On the other hand I have to use Quill.js to implement some features. 我无法删除Gmail Composer的编辑器,因为这样一来,我将删除基本的Gmail功能(例如附件,链接,表情符号等)。另一方面,我必须使用Quill.js来实现某些功能。

Example

Here is a simplified example: http://jsfiddle.net/vdaqrsrw/1/ : 这是一个简化的示例: http : //jsfiddle.net/vdaqrsrw/1/

将Quill.js添加到已经可编辑的元素中

When initiating Quill on the #editor it creates the #ql-editor-1 element within the #editor element that already has contenteditable set - so now we have 2 contenteditable elements nested in each other that breaks the toolbar and general functionality of the editable area: #editor上启动Quill时,它会在#editor元素中已经具有contenteditable设置的#editor创建#ql-editor-1元素-因此,现在我们相互嵌套了2个contenteditable元素,这破坏了工具栏和可编辑区域的常规功能:

在此处输入图片说明

The Question 问题

Is there a way to apply Quill.js to an already content editable area without the nesting problems? 有没有一种方法可以将Quill.js应用于已经可编辑的区域而不会出现嵌套问题? Are there any other ways to do it? 还有其他方法吗?

不,Quill设计和构建为独立编辑器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM