-
Notifications
You must be signed in to change notification settings - Fork 1
/
tinymce.api.php
102 lines (96 loc) · 3.14 KB
/
tinymce.api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
/**
* @file
* TinyMCE module API documentation.
*/
/**
* Implements hook_tinymce_external_plugins().
*/
function hook_tinymce_external_plugins($format) {
$module_url = base_path() . backdrop_get_path('module', 'mymodule');
$plugins = array(
// A simple plugin, just declare the path to it.
'myplugin' => array(
'plugin_path' => $module_url . '/js/plugins/myplugin/plugin.js',
),
// Another plugin, with a button and a custom icon.
'myfancyplugin' => array(
'plugin_path' => $module_url . '/js/plugins/myfancyplugin/plugin.js',
// Provide info for the builder tool about buttons, this plugin provides.
// Necessary to get a drag-and-drop handle for the toolbar builder.
'buttons' => array(
'mypluginbutton' => array(
'icon' => 'myfancyicon',
'tooltip' => 'My plugin button',
'required_tags' => array('span'),
),
),
// This plugin also ships with a custom icon. The icon name is the key,
// the icon filename is the value. This file has to be in a directory
// named "icons", next to the plugin's js file.
// Relevant for the builder and also for the actual editor appearance.
// Not necessary if you only use icons from default icon set.
'icons' => array(
'myfancyicon' => 'mysvgfile.svg',
),
),
// A plugin that needs a special variable (string).
'myotherplugin' => array(
'plugin_path' => $module_url . '/js/plugins/myotherplugin/plugin.js',
'variables' => array(
'myotherpluginSpecialVariable' => _callback_to_get_value_based_on_format($format),
),
),
);
return $plugins;
}
/**
* Themes can add CSS files for content display via info file.
*
* In mytheme.info add something like:
*
* @code
* tinymce_content_css[] = css/mystyle.css
* tinymce_content_css[] = css/morestyles.css
* @endcode
*
* TinyMCE will then apply these styles to editor content.
*/
/**
* Modify the raw TinyMCE options before they're passed to the editor.
*
* This runs for both, modules and themes, but for themes only if they're the
* currently active one. Not if the admin theme is set when editing content.
*
* @param array $options
* Complete options.
* @param stdClass $format
* Filter format.
*/
function hook_tinymce_options_alter(array &$options, $format) {
// Add CSS file based on special conditions.
if (_mymodule_special_check()) {
$options['tiny_options']['content_css'][] = '/path/to/dynamic/style.css';
}
// Switch toolbar language based on account preference setting.
global $user;
$options['tiny_options']['language'] = $user->language;
}
/**
* Not actually a hook.
*
* Editor profiles are config, so you can add your own by adding a JSON file to
* your active config directory.
* All files with the prefix 'tinymce.profiles' are available in the admin form
* in the "Editor profile" select list (admin/config/content/formats/FORMAT).
*
* Example: file tinymce.profile.yourown.json
* @code
*{
* "_config_name": "tinymce.profiles.yourown",
* "name": "yourown",
* "label": "Your own",
*
* ... rest of the profile settings
* @endcode
*/