javascript - 一个页面中的多个 CKEditor

标签 javascript jquery forms ckeditor

我试图将两个 CKEditor 放在同一个页面上。 这是我所做的: 首先是 ckeditor config.js

CKEDITOR.editorConfig = function( config ) {
    config.language = 'en';
    // config.uiColor = '#AADC6E';

    CKEDITOR.stylesSet.add('my_custom_style', [
        { name: 'Page Title', element: 'h2', attributes: {'class': 'general-title min'} }
    ]);

    //Config the KCFinder
    config.filebrowserImageBrowseUrl = "/laravel-filemanager?type=Images";
    config.filebrowserImageUploadUrl = "/laravel-filemanager/upload?type=Images&_token=";


    config.toolbarGroups = [
        { name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
        { name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
        { name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
        { name: 'forms', groups: [ 'forms' ] },
        '/',
        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
        { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
        { name: 'links', groups: [ 'links' ] },
        { name: 'insert', groups: [ 'insert' ] },
        '/',
        { name: 'styles', groups: [ 'styles' ] },
        { name: 'colors', groups: [ 'colors' ] },
        { name: 'tools', groups: [ 'tools' ] },
        { name: 'others', groups: [ 'others' ] },
        { name: 'about', groups: [ 'about' ] }
    ];

    config.removeButtons = 'Save,NewPage,Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField,Flash,Language,About';
}; 

然后我在具有 textarea 的同一页面上有这两个 form

<form>
    <div class="form-group">
       {!! Form::label('details', 'Details') !!}
       {!! Form::textarea('details', '', array('class'=>'form-control', 'placeholder'=>'Enter Details...', 'rows'=>3)) !!}
          <script>
              CKEDITOR.replace('details');
          </script>
  </div>
</form>

第二个

<form>
    <div class="form-group">
      {!! Form::label('intro', 'Intro') !!}
      {!! Form::textarea('intro', '', array('class'=>'form-control', 'placeholder'=>'Enter Details...', 'rows'=>3)) !!}
       <script>
          CKEDITOR.replace( 'intro');
       </script>
</div>
</form>

The first one seems to be working well but the second one didn't appear to work.

最佳答案

我发现这里出了什么问题

CKEDITOR.stylesSet.add('my_custom_style', [
        { name: 'Page Title', element: 'h2', attributes: {'class': 'general-title min'} }
    ]);

这是我的风格,它不应该在主 CKEDITOR.editorConfig 里面,它应该在外面并且工作正常

CKEDITOR.editorConfig = function( config ) {
    config.language = 'en';
    config.uiColor = '#AADC6E';
    ...........
    ...........
    ];

    config.removeButtons = 'Save,NewPage,Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField,Flash,Language,About';
}; 

现在在主函数之外是样式函数

CKEDITOR.stylesSet.add('my_custom_style', [
    { name: 'Page Title', element: 'h2', attributes: {'class': 'general-title min'} }
]);

关于javascript - 一个页面中的多个 CKEditor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43762769/

相关文章:

javascript - 如何提交焦点表单

javascript - jquery - 从回调函数(在后请求中)返回值到其内部的函数中?

javascript - 如何删除 JQuery 数据表中的列?

javascript - 处理页面上多个位置的相同 div 的最佳方法

jquery - 如何在 jQuery 中运行时和完成折叠切换时显示等待消息

javascript - 如何从 ASP.NET Web 表单中的超链接显示 ASP.NET MVC View

forms - 如何在 Magento 中获取商店安全 URL?

javascript - jQuery:影响相同深度的列表元素

javascript - 从另一个浏览器打开一个浏览器

javascript - Angular : ng-message validation on submit click