首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ckeditor + wiris MathType在编辑模式下不解析数学ml

ckeditor + wiris MathType在编辑模式下不解析数学ml
EN

Stack Overflow用户
提问于 2021-03-16 16:15:01
回答 1查看 1.1K关注 0票数 0

在春季MVC项目中,我已经将wiris MathType与数学和化学方程的ckeditor集成在一起。集成是顺利和快速完成的。

在创建数据时,我能够从ckeditor获取MathML xml并将其保存到数据库中。为了编辑数据,我从数据库中加载数据并将其绑定到textarea,以便用户可以修改公式。

问题是,当打开页面来编辑数据时,方程没有被解析,看起来ckeditor正在删除所有的MathML xml,并且只显示方程的数据。

我在里面。具有wiris插件的ckeditor如下所示:

代码语言:javascript
复制
CKEDITOR.plugins.addExternal('ckeditor_wiris', 'https://www.wiris.net/demo/plugins/ckeditor/', 'plugin.js');
  
CKEDITOR.editorConfig = function (config) 
{
    config.toolbar = [
             {name: 'wirisplugins', items: ['ckeditor_wiris_formulaEditor', 'ckeditor_wiris_formulaEditorChemistry']}
           ];
    config.allowedContent = true;
};
       
CKEDITOR.replace( 'mathml', {extraPlugins: 'ckeditor_wiris'} );

I还在这里创建了一个用来演示问题的

预期的输出是:分配给textarea的MathML应该被解析成数学方程。

我做错什么了?

EN

回答 1

Stack Overflow用户

发布于 2021-04-22 09:56:34

实际上,当方程被插入到

  • 中时,它只会保留MathML xml.

  • 您看到的图像是从SVG xml到SVG映像.

的热呈现。

  • 当您将数据保存到DB时,CKEditor只保存MathML XML.

  • 从DB检索数据时,应该检测到'MathML xml‘并使用以下URL将其呈现为SVG映像:

变量renderURL = "https://www.wiris.net/demo/editor/render";$.post(renderURL,{ format:" svg ",mml: mmlEquation },函数(rd) { var img = document.createElement("IMG");if ($.trim(rd)) { if (Rd)){if (rd.documentElement) { var svg= rd.documentElement;var svgImageXml =(新XMLSerializer).serializeToString(svg);var svgAsDataSrc = "data:image/svg+xml;base64 64,“XMLSerializer img.setAttribute”(“class”,“Wirisformula”);img.setAttribute(“对齐”,“中间”);Img.setAttribute(“数据-等式类型”,eqType);img.setAttribute("src",svgAsDataSrc);img.setAttribute("data-mathml",mmlEquation);img.setAttribute("alt","");} }

确保您无法在文本区域中显示该等式,但可以在(Div/Li...etc)或容器

  • 中显示它。
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66659122

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档