Debian Codegraph @

extensions/VisualEditor/modules/ve-mw/ui/inspectors/ve.ui.MWCommentInspector.js

raw symbols SCIP
1 /*!
2 * VisualEditor UserInterface MWCommentInspector class.
3 *
4 * @copyright See AUTHORS.txt
5 * @license The MIT License (MIT); see LICENSE.txt
6 */
7
8 /**
9 * Inspector for editing MediaWiki comments.
10 *
11 * @class
12 * @extends ve.ui.CommentInspector
13 *
14 * @constructor
15 * @param {Object} [config] Configuration options
16 */
17 ve.ui.MWCommentInspector = function VeUiMWCommentInspector() {
18 // Parent constructor
19 ve.ui.MWCommentInspector.super.apply( this, arguments );
20 };
21
22 /* Inheritance */
23
24 OO.inheritClass( ve.ui.MWCommentInspector, ve.ui.CommentInspector );
25
26 /* Static properties */
27
28 ve.ui.MWCommentInspector.static.name = 'comment';
29
30 ve.ui.MWCommentInspector.static.modelClasses = [ ve.dm.CommentNode ];
31
32 /* Methods */
33
34 /**
35 * @inheritdoc
36 */
37 ve.ui.MWCommentInspector.prototype.initialize = function () {
38 // Parent method
39 ve.ui.MWCommentInspector.super.prototype.initialize.apply( this, arguments );
40
41 this.textWidget.$input.on( 'copy', this.onCopy.bind( this ) );
42 };
43
44 ve.ui.MWCommentInspector.prototype.onCopy = function ( e ) {
45 const clipboardData = e.originalEvent.clipboardData,
46 selection = ( e.target.value ).slice( e.target.selectionStart, e.target.selectionEnd );
47 if ( ve.isClipboardDataFormatsSupported( e, true ) ) {
48 // We are in an environment where setting text/x-wiki will work
49 e.preventDefault();
50
51 clipboardData.setData( 'text/x-wiki', selection );
52 clipboardData.setData( 'text/plain', selection ); // If you're pasting to not-VE
53 }
54 };
55
56 /* Registration */
57
58 ve.ui.windowFactory.register( ve.ui.MWCommentInspector );