| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
ve.ui.CommandHelpRegistry = function VeUiCommandHelpRegistry() { |
| 15 |
|
| 16 |
OO.Registry.call( this ); |
| 17 |
}; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
OO.inheritClass( ve.ui.CommandHelpRegistry, OO.Registry ); |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
ve.ui.CommandHelpRegistry.prototype.register = function ( groupName, commandHelpName, details ) { |
| 38 |
const existingCommand = this.registry[ commandHelpName ]; |
| 39 |
if ( existingCommand ) { |
| 40 |
if ( details.sequences ) { |
| 41 |
details = ve.copy( details ); |
| 42 |
details.sequences = ( existingCommand.sequences || [] ).concat( details.sequences ); |
| 43 |
} |
| 44 |
details = ve.extendObject( existingCommand, details ); |
| 45 |
} |
| 46 |
|
| 47 |
const platform = ve.getSystemPlatform(), |
| 48 |
platformKey = platform === 'mac' ? 'mac' : 'pc'; |
| 49 |
|
| 50 |
if ( details.shortcuts ) { |
| 51 |
for ( let i = 0; i < details.shortcuts.length; i++ ) { |
| 52 |
const shortcut = details.shortcuts[ i ]; |
| 53 |
if ( ve.isPlainObject( shortcut ) ) { |
| 54 |
details.shortcuts[ i ] = shortcut[ platformKey ]; |
| 55 |
} |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
details.group = groupName; |
| 60 |
|
| 61 |
OO.Registry.prototype.register.call( this, commandHelpName, details ); |
| 62 |
}; |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
ve.ui.CommandHelpRegistry.prototype.lookupByGroup = function ( groupName ) { |
| 71 |
const matches = {}; |
| 72 |
for ( const commandHelpName in this.registry ) { |
| 73 |
if ( groupName === this.registry[ commandHelpName ].group ) { |
| 74 |
matches[ commandHelpName ] = this.registry[ commandHelpName ]; |
| 75 |
} |
| 76 |
} |
| 77 |
return matches; |
| 78 |
}; |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
ve.ui.commandHelpRegistry = new ve.ui.CommandHelpRegistry(); |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
ve.ui.commandHelpRegistry.register( 'textStyle', 'bold', { trigger: 'bold', label: OO.ui.deferMsg( 'visualeditor-annotationbutton-bold-tooltip' ) } ); |
| 88 |
ve.ui.commandHelpRegistry.register( 'textStyle', 'italic', { trigger: 'italic', label: OO.ui.deferMsg( 'visualeditor-annotationbutton-italic-tooltip' ) } ); |
| 89 |
ve.ui.commandHelpRegistry.register( 'textStyle', 'link', { trigger: 'link', label: OO.ui.deferMsg( 'visualeditor-annotationbutton-link-tooltip' ) } ); |
| 90 |
ve.ui.commandHelpRegistry.register( 'textStyle', 'superscript', { trigger: 'superscript', label: OO.ui.deferMsg( 'visualeditor-annotationbutton-superscript-tooltip' ) } ); |
| 91 |
ve.ui.commandHelpRegistry.register( 'textStyle', 'subscript', { trigger: 'subscript', label: OO.ui.deferMsg( 'visualeditor-annotationbutton-subscript-tooltip' ) } ); |
| 92 |
ve.ui.commandHelpRegistry.register( 'textStyle', 'underline', { trigger: 'underline', label: OO.ui.deferMsg( 'visualeditor-annotationbutton-underline-tooltip' ) } ); |
| 93 |
ve.ui.commandHelpRegistry.register( 'textStyle', 'code', { trigger: 'code', label: OO.ui.deferMsg( 'visualeditor-annotationbutton-code-tooltip' ) } ); |
| 94 |
ve.ui.commandHelpRegistry.register( 'textStyle', 'strikethrough', { trigger: 'strikethrough', label: OO.ui.deferMsg( 'visualeditor-annotationbutton-strikethrough-tooltip' ) } ); |
| 95 |
ve.ui.commandHelpRegistry.register( 'textStyle', 'clear', { trigger: 'clear', label: OO.ui.deferMsg( 'visualeditor-clearbutton-tooltip' ) } ); |
| 96 |
|
| 97 |
|
| 98 |
ve.ui.commandHelpRegistry.register( 'clipboard', 'cut', { |
| 99 |
trigger: 'cut', |
| 100 |
ignoreCommand: true, |
| 101 |
label: OO.ui.deferMsg( 'visualeditor-clipboard-cut' ) |
| 102 |
} ); |
| 103 |
ve.ui.commandHelpRegistry.register( 'clipboard', 'copy', { |
| 104 |
trigger: 'copy', |
| 105 |
ignoreCommand: true, |
| 106 |
label: OO.ui.deferMsg( 'visualeditor-clipboard-copy' ) |
| 107 |
} ); |
| 108 |
ve.ui.commandHelpRegistry.register( 'clipboard', 'paste', { |
| 109 |
trigger: 'paste', |
| 110 |
ignoreCommand: true, |
| 111 |
label: OO.ui.deferMsg( 'visualeditor-clipboard-paste' ) |
| 112 |
} ); |
| 113 |
ve.ui.commandHelpRegistry.register( 'clipboard', 'pasteSpecial', { trigger: 'pasteSpecial', label: OO.ui.deferMsg( 'visualeditor-clipboard-paste-special' ) } ); |
| 114 |
|
| 115 |
|
| 116 |
ve.ui.commandHelpRegistry.register( 'dialog', 'dialogCancel', { |
| 117 |
shortcuts: [ 'escape' ], |
| 118 |
label: OO.ui.deferMsg( 'visualeditor-command-dialog-cancel' ) |
| 119 |
} ); |
| 120 |
ve.ui.commandHelpRegistry.register( 'dialog', 'dialogConfirm', { |
| 121 |
shortcuts: [ { |
| 122 |
mac: 'cmd+enter', |
| 123 |
pc: 'ctrl+enter' |
| 124 |
} ], |
| 125 |
label: OO.ui.deferMsg( 'visualeditor-command-dialog-confirm' ) |
| 126 |
} ); |
| 127 |
ve.ui.commandHelpRegistry.register( 'dialog', 'focusContext', { |
| 128 |
trigger: 'focusContext', |
| 129 |
label: OO.ui.deferMsg( 'visualeditor-command-dialog-focus-context' ) |
| 130 |
} ); |
| 131 |
|
| 132 |
|
| 133 |
ve.ui.commandHelpRegistry.register( 'formatting', 'paragraph', { trigger: 'paragraph', label: OO.ui.deferMsg( 'visualeditor-formatdropdown-format-paragraph' ) } ); |
| 134 |
ve.ui.commandHelpRegistry.register( 'formatting', 'heading', { shortcuts: [ 'ctrl+1-6' ], checkCommand: 'heading1', label: OO.ui.deferMsg( 'visualeditor-formatdropdown-format-heading-label' ) } ); |
| 135 |
ve.ui.commandHelpRegistry.register( 'formatting', 'pre', { trigger: 'preformatted', label: OO.ui.deferMsg( 'visualeditor-formatdropdown-format-preformatted' ) } ); |
| 136 |
ve.ui.commandHelpRegistry.register( 'formatting', 'blockquote', { trigger: 'blockquote', label: OO.ui.deferMsg( 'visualeditor-formatdropdown-format-blockquote' ) } ); |
| 137 |
ve.ui.commandHelpRegistry.register( 'formatting', 'indentIn', { trigger: 'indent', label: OO.ui.deferMsg( 'visualeditor-indentationbutton-indent-tooltip' ) } ); |
| 138 |
ve.ui.commandHelpRegistry.register( 'formatting', 'indentOut', { trigger: 'outdent', label: OO.ui.deferMsg( 'visualeditor-indentationbutton-outdent-tooltip' ) } ); |
| 139 |
ve.ui.commandHelpRegistry.register( 'formatting', 'listBullet', { sequences: [ 'bulletStar' ], label: OO.ui.deferMsg( 'visualeditor-listbutton-bullet-tooltip' ) } ); |
| 140 |
ve.ui.commandHelpRegistry.register( 'formatting', 'listNumber', { sequences: [ 'numberDot' ], label: OO.ui.deferMsg( 'visualeditor-listbutton-number-tooltip' ) } ); |
| 141 |
|
| 142 |
|
| 143 |
ve.ui.commandHelpRegistry.register( 'history', 'undo', { trigger: 'undo', label: OO.ui.deferMsg( 'visualeditor-historybutton-undo-tooltip' ) } ); |
| 144 |
ve.ui.commandHelpRegistry.register( 'history', 'redo', { trigger: 'redo', label: OO.ui.deferMsg( 'visualeditor-historybutton-redo-tooltip' ) } ); |
| 145 |
|
| 146 |
|
| 147 |
ve.ui.commandHelpRegistry.register( 'other', 'findAndReplace', { trigger: 'findAndReplace', label: OO.ui.deferMsg( 'visualeditor-find-and-replace-title' ) } ); |
| 148 |
ve.ui.commandHelpRegistry.register( 'other', 'findNext', { trigger: 'findNext', label: OO.ui.deferMsg( 'visualeditor-find-and-replace-next-button' ) } ); |
| 149 |
ve.ui.commandHelpRegistry.register( 'other', 'findPrevious', { trigger: 'findPrevious', label: OO.ui.deferMsg( 'visualeditor-find-and-replace-previous-button' ) } ); |
| 150 |
ve.ui.commandHelpRegistry.register( 'other', 'selectAll', { trigger: 'selectAll', label: OO.ui.deferMsg( 'visualeditor-content-select-all' ) } ); |
| 151 |
ve.ui.commandHelpRegistry.register( 'other', 'changeDirectionality', { trigger: 'changeDirectionality', label: OO.ui.deferMsg( 'visualeditor-changedir' ) } ); |
| 152 |
ve.ui.commandHelpRegistry.register( 'other', 'commandHelp', { trigger: 'commandHelp', label: OO.ui.deferMsg( 'visualeditor-dialog-command-help-title' ) } ); |
| 153 |
|
| 154 |
|
| 155 |
ve.ui.commandHelpRegistry.register( 'insert', 'horizontalRule', { sequences: [ 'horizontalRule' ], label: OO.ui.deferMsg( 'visualeditor-horizontalrule-tooltip' ) } ); |