| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
ve.ui.MWWikitextPasteContextItem = function VeUiMWWikitextPasteContextItem() { |
| 19 |
|
| 20 |
ve.ui.MWWikitextPasteContextItem.super.apply( this, arguments ); |
| 21 |
|
| 22 |
|
| 23 |
this.$element.addClass( 've-ui-mwWikitextPasteContextItem' ); |
| 24 |
}; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
OO.inheritClass( ve.ui.MWWikitextPasteContextItem, ve.ui.PersistentContextItem ); |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
ve.ui.MWWikitextPasteContextItem.static.name = 'wikitextPaste'; |
| 33 |
|
| 34 |
ve.ui.MWWikitextPasteContextItem.static.icon = 'wikiText'; |
| 35 |
|
| 36 |
ve.ui.MWWikitextPasteContextItem.static.label = OO.ui.deferMsg( 'visualeditor-wikitextconvert-title' ); |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
ve.ui.MWWikitextPasteContextItem.prototype.renderBody = function () { |
| 44 |
const fragment = this.data.fragment, |
| 45 |
doc = this.data.doc, |
| 46 |
contextRange = this.data.contextRange; |
| 47 |
|
| 48 |
const convertButton = new OO.ui.ButtonWidget( { |
| 49 |
label: ve.msg( 'visualeditor-wikitextconvert-convert' ), |
| 50 |
flags: [ 'progressive' ] |
| 51 |
} ).on( 'click', () => { |
| 52 |
fragment.insertDocument( doc, contextRange ).getPending().then( () => { |
| 53 |
fragment.collapseToEnd().select(); |
| 54 |
} ); |
| 55 |
|
| 56 |
} ); |
| 57 |
|
| 58 |
this.$body.append( |
| 59 |
$( '<p>' ).text( ve.msg( 'visualeditor-wikitextconvert-message' ) ) |
| 60 |
); |
| 61 |
|
| 62 |
if ( this.$foot ) { |
| 63 |
this.$foot.prepend( convertButton.$element ); |
| 64 |
} else { |
| 65 |
this.$body.append( convertButton.$element ); |
| 66 |
} |
| 67 |
}; |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
ve.ui.contextItemFactory.register( ve.ui.MWWikitextPasteContextItem ); |