【问题标题】:adding Mathematical formulas plugin to the ckeditor将数学公式插件添加到 ckeditor
【发布时间】:2018-09-21 03:41:39
【问题描述】:

我目前正在使用 rails 制作测验应用程序 在这个我的要求是有一个像ckeditor这样的富文本编辑器,它具有文件处理和数学方程输入功能ckeditor gem很合适,但是如何向它添加数学公式插件。 一个例子将完成这项工作.. 提前谢谢

【问题讨论】:

    标签: ruby-on-rails gem ckeditor mathjax


    【解决方案1】:

    更新(2017 年 4 月 12 日):

    我已经使用新的 CDN 更新了示例,因为 MathJax 正在关闭他们的 CDN。查看彼得的评论了解更多详情。

    从以下位置下载 CKeditor 的数学公式插件:

    http://ckeditor.com/addon/mathjax

    此外,您还需要以下插件:

    lineutils
    widget
    

    把所有的插件都放进去

    app/assets/javascripts/ckeditor/plugins/
    

    编辑/创建以下文件

    app/assets/javascripts/ckeditor/config.js
    

    这些是我使用的设置:

    CKEDITOR.editorConfig = function( config )
    {
      // Define changes to default configuration here. For example:
      // config.language = 'fr';
      // config.uiColor = '#AADC6E';
      config.extraPlugins = 'lineutils,mathjax,widget';
    
      // MathJax config
      config.mathJaxLib = '//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML';
    
      /* Filebrowser routes */
      // The location of an external file browser, that should be launched when "Browse Server" button is pressed.
      config.filebrowserBrowseUrl = "/ckeditor/attachment_files";
    
      // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Flash dialog.
      config.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files";
    
      // The location of a script that handles file uploads in the Flash dialog.
      config.filebrowserFlashUploadUrl = "/ckeditor/attachment_files";
    
      // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Link tab of Image dialog.
      config.filebrowserImageBrowseLinkUrl = "/ckeditor/pictures";
    
      // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Image dialog.
      config.filebrowserImageBrowseUrl = "/ckeditor/pictures";
    
      // The location of a script that handles file uploads in the Image dialog.
      config.filebrowserImageUploadUrl = "/ckeditor/pictures";
    
      // The location of a script that handles file uploads.
      config.filebrowserUploadUrl = "/ckeditor/attachment_files";
    
      config.allowedContent = true;
    
      // Toolbar groups configuration.
      config.toolbar = [
        { name: 'document', groups: [ 'mode', 'document', 'doctools' ], items: [ 'Source'] },
        { name: 'clipboard', groups: [ 'clipboard', 'undo' ], items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] },
        { name: 'links', items: [ 'Link', 'Unlink', 'Anchor' ] },
        { name: 'insert', items: [ 'Image', 'Flash', 'Table', 'HorizontalRule', 'SpecialChar', 'Mathjax' ] },
        { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock' ] },
        '/',
        { name: 'styles', items: [ 'Styles', 'Format', 'Font', 'FontSize' ] },
        { name: 'colors', items: [ 'TextColor', 'BGColor' ] },
        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ] }
      ];
    };
    

    “Mathjax”是打开公式编辑器的按钮。

    我希望这会有所帮助。

    【讨论】:

    【解决方案2】:

    尝试使用 Wiris (www.wiris.com)。我认为它比ckeditor更强大。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-31
      • 2017-12-29
      • 2013-12-31
      • 2023-04-02
      相关资源
      最近更新 更多