【发布时间】:2017-02-26 17:51:07
【问题描述】:
尝试在 quill 中使用公式模块时出现错误。
错误是:
"[Parchment] Unable to create formula blot"
按照 chrome web 开发工具中的错误信息会导致registry.ts(webpack:///./~/parchment/src/registry.ts)中的以下行
function create(input, value) {
var match = query(input);
if (match == null) {
throw new ParchmentError("Unable to create " + input + " blot");
}
var BlotClass = match;
var node = input instanceof Node ? input : BlotClass.create(value);
return new BlotClass(node, value);
}
当我尝试插入公式时会发生这种情况。
当我使用 quill-rails5 但不使用 gem 时会发生这种情况。我删除了 gem 以简化问题。这是我的代码:
var quill = new Quill('#editor', {
modules: {
formula: true,
toolbar: [
[{ header: [1, 2, false] }],
['bold', 'italic', 'underline'],
['image', 'code-block'],
['formula'],
]
},
placeholder: 'Compose a solution...',
theme: 'snow' // or 'bubble'
});
我的编辑器容器
<div id="editor">
<%= raw sanitize @post.description, tags: %w(strong em div a p br ul ol li), attributes: %w(href) %>
</div>
【问题讨论】:
-
那么你有没有 Minimal, Complete, and Verifiable example 的地方,可能只是静态 HTML+JS,在 codepen、JSFiddle 或类似的东西上没有 ruby 后端?没有这样的例子,很难猜出你和 Ben 提供的工作例子有什么区别。
-
用示例更新了答案。还删除了 gem 以简化和重现问题。认为它可能与 sanitize 功能有关?
-
实际上它现在可以工作了。所以问题可能出在宝石上!
-
很抱歉,但我认为您提供的内容并不是一个很好的例子。这可能就是它现在起作用的原因。我认为有意义的是分析您由 Ruby 生成的真实 HTML,并尝试将其一点一点地复制粘贴到静态文件中,直到它中断。然后您或我们可以找出 Ruby 生成的 HTML/JS 有什么问题。
标签: ruby-on-rails ruby-on-rails-5 quill parchment