PHP code example of violet88 / silverstripe-tinymce-premium

1. Go to this page and download the library: Download violet88/silverstripe-tinymce-premium library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

violet88 / silverstripe-tinymce-premium example snippets


$editorConfig = HTMLEditorConfig::get('cms');

if ($editorConfig instanceof TinyMCEConfig) {
    $handler = TinyMCEPremiumHandler::create();

    $editorConfig->enablePlugins([
        'tinymcespellchecker' => $handler->getPluginUrl('tinymcespellchecker'),
        'advcode' => $handler->getPluginUrl('advcode'),
        'mentions' => $handler->getPluginUrl('mentions')
    ]);
}

$editorConfig = HTMLEditorConfig::get('cms');

if ($editorConfig instanceof TinyMCEConfig) {
    $handler = TinyMCEPremiumHandler::create();

    $editorConfig->enablePlugins([
        'mentions' => $handler->getPluginUrl('mentions')
    ]);

    $handler->setJsOptions([
        'mentions_fetch' => <<<JS
            function (query, success) {
                // Fetch your full user list from somewhere
                var users = [
                    { id: '1', name: 'wyatt', fullName: 'Wyatt Wilson' },
                    { id: '2', name: 'gabriel', fullName: 'Gabriel Brown' },
                    { id: '3', name: 'hazel', fullName: 'Hazel Lee' },
                    { id: '4', name: 'owen', fullName: 'Owen Johnson' },
                    { id: '5', name: 'lily', fullName: 'Lily Davis' },
                ];

                users = users.filter(function (user) {
                    return user.name.toLowerCase().indexOf(query.term.toLowerCase()) !== -1;
                });

                window.setTimeout(function () {
                    success(users);
                }, 0);
            }
            JS
    ]);
}