@@ -11,6 +11,16 @@ const plugin = {
11
11
* @param {Object } editor
12
12
*/
13
13
init ( editor ) {
14
+ function getActions ( ) {
15
+ // Fetch the actions whenever the fetch function is called.
16
+ return TinyMCEActionRegistrar . getSortedActions ( 'sslink' , editor . getParam ( 'editorIdentifier' ) , true )
17
+ . map ( action => Object . assign (
18
+ { } ,
19
+ action ,
20
+ { onAction : ( ) => action . onAction ( editor ) }
21
+ ) ) ;
22
+ }
23
+
14
24
const metaKey = navigator . platform . toUpperCase ( ) . includes ( 'MAC' ) ? '⌘' : 'Ctrl' ;
15
25
const title = i18n . _t ( 'Admin.INSERT_LINK' , 'Insert link' ) ;
16
26
const titleWithShortcut = i18n . inject (
@@ -33,33 +43,18 @@ const plugin = {
33
43
}
34
44
}
35
45
46
+ // Button in main toolbar
36
47
editor . ui . registry . addMenuButton ( 'sslink' , {
37
48
icon : 'link' ,
38
49
tooltip : titleWithShortcut ,
39
- fetch : ( callback ) => callback (
40
- // Fetch the actions whenever the fetch function is called.
41
- TinyMCEActionRegistrar . getSortedActions ( 'sslink' , editor . getParam ( 'editorIdentifier' ) , true )
42
- . map ( action => Object . assign (
43
- { } ,
44
- action ,
45
- { onAction : ( ) => action . onAction ( editor ) }
46
- ) )
47
- ) ,
50
+ fetch : ( callback ) => callback ( getActions ( ) ) ,
48
51
} ) ;
49
52
50
- editor . on ( 'preinit' , ( ) => {
51
- // Right click context menu item
52
- editor . ui . registry . addNestedMenuItem ( 'sslink' , {
53
- icon : 'link' ,
54
- text : title ,
55
- getSubmenuItems : ( ) => // Fetch the actions whenever the fetch function is called.
56
- TinyMCEActionRegistrar . getSortedActions ( 'sslink' , editor . getParam ( 'editorIdentifier' ) , true )
57
- . map ( action => Object . assign (
58
- { } ,
59
- action ,
60
- { onAction : ( ) => action . onAction ( editor ) }
61
- ) ) ,
62
- } ) ;
53
+ // Right click context menu item
54
+ editor . ui . registry . addNestedMenuItem ( 'sslink' , {
55
+ icon : 'link' ,
56
+ text : title ,
57
+ getSubmenuItems : getActions ,
63
58
} ) ;
64
59
65
60
// Context menu when a link is selected
0 commit comments