mohamedsabil83 / filament-forms-tinyeditor

A TinyMce Editor component for filament
MIT License
174 stars 39 forks source link

Fix merge custom configs #43

Closed guilebc closed 1 year ago

guilebc commented 1 year ago

When there are several keys at the same level in the custom configuration (TinyMCE configuration is sometimes at the same level), the rtrim and ltrim functions break the JSON array. I fixed this by removing the functions and merging the custom config with spread syntax.

I created the Filament discord topic here for more information. Here: https://discord.com/channels/883083792112300104/922411184962035723/1042768313484316802

Example array

'custom_configs' => [
    'style_formats'=> [
        ['title' => 'Inline', 'items' => [
            [ 'title' => 'Bold', 'format' => 'bold' ],
            [ 'title' => 'Italic', 'format' => 'italic' ],
        ]],
        ['title'=> 'Headings', 'items'=> [
            [ 'title' => 'H1', 'format' => 'h1' ],
            [ 'title' => 'H2', 'format' => 'h2' ],
        ]],
        ['title' => 'Buttons', 'items' => [
            [ 'title' => 'Red', 'format' => 'btnPrimary' ],
        ]],
    ],
    'formats' => [
        'btnPrimary' => [ 'selector' => 'a', 'classes' => [ 'btn', 'btn-primary' ] ],
    ],
]

1 image

Thanks !

mohamedsabil83 commented 1 year ago

Thank you for contributing