| 1 |
require( './CommentTarget.js' ); |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
function CommentTargetWidget( replyWidget, config ) { |
| 14 |
const excludeCommands = [ |
| 15 |
'blockquoteWrap', |
| 16 |
|
| 17 |
'indent', |
| 18 |
'outdent', |
| 19 |
|
| 20 |
|
| 21 |
'showSave', |
| 22 |
'showChanges', |
| 23 |
'showPreview', |
| 24 |
'saveMinoredit', |
| 25 |
'saveWatchthis' |
| 26 |
]; |
| 27 |
|
| 28 |
if ( !replyWidget.isNewTopic ) { |
| 29 |
excludeCommands.push( |
| 30 |
|
| 31 |
'heading1', |
| 32 |
'heading2', |
| 33 |
'heading3', |
| 34 |
'heading4', |
| 35 |
'heading5', |
| 36 |
'heading6', |
| 37 |
'insertTable', |
| 38 |
'transclusionFromSequence', |
| 39 |
'preformatted' |
| 40 |
); |
| 41 |
} |
| 42 |
|
| 43 |
config = Object.assign( { |
| 44 |
excludeCommands: excludeCommands |
| 45 |
}, config ); |
| 46 |
|
| 47 |
this.replyWidget = replyWidget; |
| 48 |
this.authors = config.authors; |
| 49 |
|
| 50 |
|
| 51 |
CommentTargetWidget.super.call( this, config ); |
| 52 |
|
| 53 |
|
| 54 |
this.$element.addClass( 'ext-discussiontools-ui-targetWidget' ); |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
OO.inheritClass( CommentTargetWidget, ve.ui.MWTargetWidget ); |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
CommentTargetWidget.prototype.createTarget = function () { |
| 65 |
return ve.init.mw.targetFactory.create( 'discussionTools', this.replyWidget, { |
| 66 |
|
| 67 |
register: true, |
| 68 |
toolbarGroups: this.toolbarGroups, |
| 69 |
modes: this.modes, |
| 70 |
defaultMode: this.defaultMode |
| 71 |
} ); |
| 72 |
}; |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
CommentTargetWidget.prototype.setDocument = function ( docOrHtml ) { |
| 78 |
const mode = this.target.getDefaultMode(), |
| 79 |
doc = ( mode === 'visual' && typeof docOrHtml === 'string' ) ? |
| 80 |
this.target.parseDocument( docOrHtml ) : |
| 81 |
docOrHtml, |
| 82 |
|
| 83 |
dmDoc = this.target.constructor.static.createModelFromDom( doc, mode ); |
| 84 |
|
| 85 |
|
| 86 |
CommentTargetWidget.super.prototype.setDocument.call( this, dmDoc ); |
| 87 |
|
| 88 |
|
| 89 |
this.getSurface().getView().$element.removeClass( 'mw-body-content' ); |
| 90 |
this.getSurface().$placeholder.removeClass( 'mw-body-content' ); |
| 91 |
|
| 92 |
|
| 93 |
this.getSurface().getView().getDocument().getDocumentNode().$element.addClass( 'ime-position-inside' ); |
| 94 |
|
| 95 |
|
| 96 |
this.getSurface().authors = this.authors; |
| 97 |
}; |
| 98 |
|
| 99 |
module.exports = CommentTargetWidget; |