在按钮上插入数据点击ckeditor

问题描述 投票:2回答:2

我必须使用ckeditor编辑textarea。编辑器后面放置一个按钮。如果单击该按钮,我需要向编辑器添加html代码。加载CK编辑器的代码是:

CKEDITOR.replace('mail_content');
CKEDITOR.config.toolbar = [
                ['Styles','Format','Font','FontSize'],
                // '/',
                ['Bold','Italic','Underline','StrikeThrough','-','Undo','Redo','-','Cut','Copy','Paste','Find','Replace','-','Outdent','Indent','-','Print'],
                // '/',
                ['NumberedList','BulletedList','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
                ['Flash','TextColor','BGColor']
            ] ;

按钮是

<button name="edit" id="edit" >edit</button>
jquery ckeditor
2个回答
1
投票

我不完全明白你需要什么,但如果你需要例子看看这个

<textarea name="mail_content" id="mail_content" rows="10" cols="80">
  This is a test
</textarea>
<button name="edit" id="edit" >edit</button>
<script>
$('#edit').click(function(){
  CKEDITOR.editorConfig = function (config) {
      config.language = 'es';
      config.uiColor = '#F7B42C';
      config.height = 300;
      config.toolbarCanCollapse = true;
            config.toolbar = [
                ['Styles','Format','Font','FontSize'],
                // '/',
                ['Bold','Italic','Underline','StrikeThrough','-','Undo','Redo','-','Cut','Copy','Paste','Find','Replace','-','Outdent','Indent','-','Print'],
                // '/',
                ['NumberedList','BulletedList','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
                ['Flash','TextColor','BGColor']
            ] ;

  };
  CKEDITOR.replace('mail_content');
});
</script>

https://jsfiddle.net/reoh7j74/527


0
投票

使用insertHtml

CKEDITOR.instances.mail_content.insertHtml('<p>dsfds</p>');
© www.soinside.com 2019 - 2024. All rights reserved.