Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/editor/editor.api.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
1 <?php | |
2 | |
3 /** | |
4 * @file | |
5 * Documentation for Text Editor API. | |
6 */ | |
7 | |
8 use Drupal\filter\FilterFormatInterface; | |
9 | |
10 /** | |
11 * @addtogroup hooks | |
12 * @{ | |
13 */ | |
14 | |
15 /** | |
16 * Performs alterations on text editor definitions. | |
17 * | |
18 * @param array $editors | |
19 * An array of metadata of text editors, as collected by the plugin annotation | |
20 * discovery mechanism. | |
21 * | |
22 * @see \Drupal\editor\Plugin\EditorBase | |
23 */ | |
24 function hook_editor_info_alter(array &$editors) { | |
25 $editors['some_other_editor']['label'] = t('A different name'); | |
26 $editors['some_other_editor']['library']['module'] = 'myeditoroverride'; | |
27 } | |
28 | |
29 /** | |
30 * Modifies JavaScript settings that are added for text editors. | |
31 * | |
32 * @param array $settings | |
33 * All the settings that will be added to the page for the text formats to | |
34 * which a user has access. | |
35 */ | |
36 function hook_editor_js_settings_alter(array &$settings) { | |
37 if (isset($settings['editor']['formats']['basic_html'])) { | |
38 $settings['editor']['formats']['basic_html']['editor'] = 'MyDifferentEditor'; | |
39 $settings['editor']['formats']['basic_html']['editorSettings']['buttons'] = ['strong', 'italic', 'underline']; | |
40 } | |
41 } | |
42 | |
43 /** | |
44 * Modifies the text editor XSS filter that will used for the given text format. | |
45 * | |
46 * Is only called when an EditorXssFilter will effectively be used; this hook | |
47 * does not allow one to alter that decision. | |
48 * | |
49 * @param string &$editor_xss_filter_class | |
50 * The text editor XSS filter class that will be used. | |
51 * @param \Drupal\filter\FilterFormatInterface $format | |
52 * The text format configuration entity. Provides context based upon which | |
53 * one may want to adjust the filtering. | |
54 * @param \Drupal\filter\FilterFormatInterface|null $original_format | |
55 * (optional) The original text format configuration entity (when switching | |
56 * text formats/editors). Also provides context based upon which one may want | |
57 * to adjust the filtering. | |
58 * | |
59 * @see \Drupal\editor\EditorXssFilterInterface | |
60 */ | |
61 function hook_editor_xss_filter_alter(&$editor_xss_filter_class, FilterFormatInterface $format, FilterFormatInterface $original_format = NULL) { | |
62 $filters = $format->filters()->getAll(); | |
63 if (isset($filters['filter_wysiwyg']) && $filters['filter_wysiwyg']->status) { | |
64 $editor_xss_filter_class = '\Drupal\filter_wysiwyg\EditorXssFilter\WysiwygFilter'; | |
65 } | |
66 } | |
67 | |
68 /** | |
69 * @} End of "addtogroup hooks". | |
70 */ |