首页 > 解决方案 > 如何设置CKEDITOR的宽度

问题描述

async function TextEditor(element) {
  const newEditor = await ClassicEditor.create(element, {
    toolbar: [
      "heading",
      "bold",
      "italic",
      "bulletedList",
      "numberedList",
      "blockQuote",
    ],
  });

  return newEditor;
}

如何为CKEditor设置宽度和高度

async function TextEditor(element) {

const newEditor = await ClassicEditor.create(element, { toolbar: [ "heading", "bold", "italic", "bulletedList", "numberedList", "blockQuote", ], });

返回新编辑器;}

标签: javascripthtmlckeditor

解决方案


由于您没有指定 CkEditor 版本,我将假设为 v4。

编辑器高度默认设置为200 像素,宽度占其容器的100%

创建新编辑器时提供宽度或高度配置属性:

async function TextEditor(element) {
  const newEditor = await ClassicEditor.create(element, {
    toolbar: [
      "heading",
      "bold",
      "italic",
      "bulletedList",
      "numberedList",
      "blockQuote",
    ],
    width: 300,
    //resolves to 300px for fixed width
    // for percentage use '80%'
    height: 300,
  });

  return newEditor;
}

这应该让您按照CkEditor Doc For Sizing中的描述启动并运行


推荐阅读