File: ve.ui.MWWikitextPlainTextStringTransferHandler.js

package info (click to toggle)
mediawiki 1%3A1.43.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 417,464 kB
  • sloc: php: 1,062,949; javascript: 664,290; sql: 9,714; python: 5,458; xml: 3,489; sh: 1,131; makefile: 64
file content (57 lines) | stat: -rw-r--r-- 2,041 bytes parent folder | download | duplicates (2)
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
/*!
 * VisualEditor UserInterface MWWikitextPlainTextStringTransferHandler.
 *
 * @copyright See AUTHORS.txt
 */

/**
 * Detect an attempt to paste plain text or wikitext, and allow it to be directly pasted without escaping it.
 *
 * This handler is only registered in source mode, as that's the mode where users are interacting
 * with the plain-text equivalent of the content already. Without this handler, a paste with `text/plain`
 * and `text/html` content would take the html content, run it through the normal paste flow, then convert
 * the resultant HTML into wikitext via parsoid. This would have the side-effect of escaping any wikitext
 * content that's in the paste with nowiki, which probably isn't what the paster actually wants.
 *
 * We also catch anything which has `text/x-wiki`, since it has explicitly come from a source-mode part
 * of VE, and contains something that's definitely wikitext.
 *
 * @class
 * @extends ve.ui.PlainTextStringTransferHandler
 *
 * @constructor
 * @param {ve.ui.Surface} surface
 * @param {ve.ui.DataTransferItem} item
 */
ve.ui.MWWikitextPlainTextStringTransferHandler = function VeUiMWWikitextPlainTextStringTransferHandler() {
	// Parent constructor
	ve.ui.MWWikitextPlainTextStringTransferHandler.super.apply( this, arguments );
};

/* Inheritance */

OO.inheritClass( ve.ui.MWWikitextPlainTextStringTransferHandler, ve.ui.PlainTextStringTransferHandler );

/* Static properties */

ve.ui.MWWikitextPlainTextStringTransferHandler.static.name = 'wikitextPlainTextString';

ve.ui.MWWikitextPlainTextStringTransferHandler.static.types = [
	...ve.ui.MWWikitextPlainTextStringTransferHandler.super.static.types,
	'text/x-wiki'
];

ve.ui.MWWikitextPlainTextStringTransferHandler.static.handlesPaste = true;

/* Methods */

/**
 * @inheritdoc
 */
ve.ui.MWWikitextPlainTextStringTransferHandler.prototype.process = function () {
	this.resolve( this.item.getAsString() );
};

/* Registration */

ve.ui.wikitextDataTransferHandlerFactory.register( ve.ui.MWWikitextPlainTextStringTransferHandler );