笔管编辑器:粘贴时保持文本缩进

时间:2019-01-16 07:49:39

标签: quill

我最近开始使用Quill HTML编辑器来撰写电子邮件。这就是为什么我需要内联样式。输出与归因者一起使用时效果很好,添加文本缩进后,我得到以下输出:

<div>In</div><div style="text-indent: 1em;">den</div><div style="text-indent: 2em;">ta</div><div style="text-indent: 3em;">tion</div>

Quill的delta对象看起来与我期望的有所不同,但是只要HTML正确就可以了:

content: Delta = {
    ops: [
        { insert: "In\nden" },
        { insert: "\n", attributes: { indent: "1em" } },
        { insert: "ta" },
        { insert: "\n", attributes: { indent: "2em" } },
        { insert: "tion" },
        { insert: "\n", attributes: { indent: "3em" } },
    ]
}

当我将内容复制并粘贴到同一个鹅毛笔编辑器中时,没有得到预期的结果:

<div>In</div><div>  den</div><div>  ta</div><div>   tion</div><div><br></div>

具有以下Delta对象:

content: Delta = {
    ops: [
        { insert: "In\n\tden\n\tta\n\ttion\n\n" }
    ]
}

我在Quill的剪贴板模块中使用匹配器跟踪粘贴操作,在该模块中可以正确识别缩进:

<div>In</div>
{
    ops: [{ insert: "In\n" }]
}
<div style="text-indent: 1em;">den</div>
{
    ops: [
        { insert: "\t" },
        { insert: "den\n", attributes: { indent: "1em" } },
    ]
}
<div style="text-indent: 2em;">ta</div>
{
    ops: [
        { insert: "\t" },
        { insert: "ta\n", attributes: { indent: "2em" } },
    ]
}
<div style="text-indent: 3em;">tion</div>
{
    ops: [
        { insert: "\t" },
        { insert: "tion\n", attributes: { indent: "3em" } },
    ]
}

我如何确保剪贴板模块的增量(包括缩进属性)传递到主轴编辑器的内容?

0 个答案:

没有答案
相关问题