【问题标题】:How to add options to ckeditor in backpack-for-laravel如何在背包换laravel中向ckeditor添加选项
【发布时间】:2025-12-03 08:25:02
【问题描述】:

我想在 Backpack for Laravel 的 ckeditor 中添加文本对齐。

我该怎么做?

我试过了,但是没有用。

        $this->crud->addField([
            'name' => 'content',
            'label' => 'Content',
            'type' => 'ckeditor',
            'options' => ['alignment'],
        ]);

【问题讨论】:

    标签: laravel-backpack


    【解决方案1】:

    docs 表明 options 应作为关联数组传递。

    背包(至少我的版本)使用 CKeditor 4.9,具体来说,ckeditor.blade.php 使用了CKeditor jQuery adapter

    Here is a list of all the possible options that you can set。我在文档中的任何地方都找不到“对齐”,但我怀疑您正在谈论工具栏中的对齐按钮,如果这是真的,您的选项可能如下所示:

    $this->crud->addField([
        'name' => 'content',
        'label' => 'Content',
        'type' => 'ckeditor',
        'options' => [
            'toolbar'=>
                [
                    [
                        'name'=>  'paragraph',
                        'items' =>  [
                            'JustifyLeft',
                            'JustifyCenter',
                            'JustifyRight',
                            'JustifyBlock',
                        ]
                    ],
                ]
        ],
    ]);
    

    不过,这可能会迫使您列出所需的所有工具栏选项,如果是这样,请参阅this section in the docs

    【讨论】: