Span标签和内容未在主轴编辑器中呈现

时间:2018-07-09 09:21:12

标签: quill

我最近开始探索羽毛笔来实施富文本编辑器。我想在羽毛笔编辑器中呈现以下html内容: 第二跨度

但是,在渲染时,会删除span标签,并将其内容包装在P标签内并进行渲染。我了解到,作为优化纤管的一部分,它删除了跨度标签。但是我真的想渲染span标签,所以我添加了SPAN印迹来扩展BlockEmbed。但是,在添加SPAN印迹后,编辑器中没有呈现任何内容。我不明白我在做什么错;这是SPAN印迹:

let quill = require("quill");
let BlockEmbed = quill.import("blots/block/embed");

class SpanBlot extends BlockEmbed {
    public static create(value: any): any {
        let node = super.create(value);
        node.setAttribute("data-embed-id", value);
        return node;
    } 

    public static value(node: any): any {
        return node;
    }

    public static formats(node: any): any {
        let format: any = {};
        if (node.hasAttribute("data-embed-id")) {
            format.height = node.getAttribute("data-embed-id");
        }
        return format;
    }

    public formats(): any {
        let formats = super.formats();
        formats["span"] = SpanBlot.formats(this.domNode);
        return formats;
    }
 }

SpanBlot.blotName = "Span";
SpanBlot.tagName = "SPAN";
SpanBlot.class = "social";

export { BlockEmbed, SpanBlot };

0 个答案:

没有答案