如何为ckeditor中的所有实例创建通用工具栏

问题描述 投票:0回答:1

我有多个ckeditor实例,每个实例都在创建一个工具栏。就我而言,我只希望为所有实例使用一个工具栏。

editor = CKEDITOR.replace("editor1")

我正在以这种方式创建ckeditor。

请给我一个解决方案。

javascript jquery ckeditor ckeditor4.x
1个回答
0
投票

您需要使用插件共享空间并添加两个div(顶部和底部):

<div id="top"></div>
<textarea name="editor1">Editor One </textarea>
<textarea name="editor2">Editor Two </textarea>
<div id="bottom"></div>

 CKEDITOR.replace(
  'editor1',
  {
    toolbar : [{name: 'Copy', items: ['Copy', 'Paste']}],
    extraPlugins:'sharedspace',
    removePlugins: 'maximize,resize',
    sharedSpaces: {
      top: 'top',
      bottom: 'bottom'
    },
  });


CKEDITOR.replace(
  'editor2',
  {
    toolbar : [{name: 'Format', items: ['Bold']}],
    extraPlugins:'sharedspace',
    removePlugins: 'maximize,resize',
    sharedSpaces: {
      top: 'top',
      bottom: 'bottom'
    },
  });

示例:

https://codepen.io/edsonperotoni/pen/YzzLgON

参考:

https://ckeditor.com/docs/ckeditor4/latest/examples/sharedspace.html

© www.soinside.com 2019 - 2024. All rights reserved.