| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
ve.init.mw.Target = function VeInitMwTarget( config ) { |
| 19 |
this.surfaceClasses = config.surfaceClasses || []; |
| 20 |
|
| 21 |
|
| 22 |
ve.init.mw.Target.super.call( this, config ); |
| 23 |
|
| 24 |
this.active = false; |
| 25 |
this.pageName = mw.config.get( 'wgRelevantPageName' ); |
| 26 |
this.recovered = false; |
| 27 |
this.fromEditedState = false; |
| 28 |
this.originalHtml = null; |
| 29 |
|
| 30 |
|
| 31 |
this.$element.addClass( 've-init-mw-target' ); |
| 32 |
}; |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
OO.inheritClass( ve.init.mw.Target, ve.init.Target ); |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
ve.init.mw.Target.static.name = null; |
| 48 |
|
| 49 |
ve.init.mw.Target.static.toolbarGroups = [ |
| 50 |
{ |
| 51 |
name: 'history', |
| 52 |
include: [ { group: 'history' } ] |
| 53 |
}, |
| 54 |
{ |
| 55 |
name: 'format', |
| 56 |
type: 'menu', |
| 57 |
title: OO.ui.deferMsg( 'visualeditor-toolbar-format-tooltip' ), |
| 58 |
include: [ { group: 'format' } ], |
| 59 |
promote: [ 'paragraph' ], |
| 60 |
demote: [ 'preformatted', 'blockquote', 'heading1' ] |
| 61 |
}, |
| 62 |
{ |
| 63 |
name: 'style', |
| 64 |
type: 'list', |
| 65 |
icon: 'textStyle', |
| 66 |
title: OO.ui.deferMsg( 'visualeditor-toolbar-style-tooltip' ), |
| 67 |
label: OO.ui.deferMsg( 'visualeditor-toolbar-style-tooltip' ), |
| 68 |
invisibleLabel: true, |
| 69 |
include: [ { group: 'textStyle' } ], |
| 70 |
forceExpand: [ 'bold', 'italic', 'clear' ], |
| 71 |
promote: [ 'bold', 'italic', 'superscript', 'subscript' ], |
| 72 |
demote: [ 'clear' ] |
| 73 |
}, |
| 74 |
{ |
| 75 |
name: 'link', |
| 76 |
include: [ 'link' ] |
| 77 |
}, |
| 78 |
|
| 79 |
{ |
| 80 |
name: 'reference' |
| 81 |
}, |
| 82 |
{ |
| 83 |
name: 'structure', |
| 84 |
type: 'list', |
| 85 |
icon: 'listBullet', |
| 86 |
title: OO.ui.deferMsg( 'visualeditor-toolbar-structure' ), |
| 87 |
label: OO.ui.deferMsg( 'visualeditor-toolbar-structure' ), |
| 88 |
invisibleLabel: true, |
| 89 |
include: [ { group: 'structure' } ], |
| 90 |
demote: [ 'outdent', 'indent' ] |
| 91 |
}, |
| 92 |
{ |
| 93 |
name: 'insert', |
| 94 |
label: OO.ui.deferMsg( 'visualeditor-toolbar-insert' ), |
| 95 |
title: OO.ui.deferMsg( 'visualeditor-toolbar-insert' ), |
| 96 |
narrowConfig: { |
| 97 |
invisibleLabel: true, |
| 98 |
icon: 'add' |
| 99 |
}, |
| 100 |
include: '*', |
| 101 |
forceExpand: [ 'media', 'transclusion', 'insertTable' ], |
| 102 |
promote: [ 'media', 'transclusion', 'insertTable' ] |
| 103 |
}, |
| 104 |
{ |
| 105 |
name: 'specialCharacter', |
| 106 |
include: [ 'specialCharacter' ] |
| 107 |
} |
| 108 |
]; |
| 109 |
|
| 110 |
ve.init.mw.Target.static.importRules = ve.copy( ve.init.mw.Target.static.importRules ); |
| 111 |
|
| 112 |
ve.init.mw.Target.static.importRules.external.removeOriginalDomElements = true; |
| 113 |
|
| 114 |
ve.init.mw.Target.static.importRules.external.blacklist = ve.extendObject( { |
| 115 |
|
| 116 |
'textStyle/underline': true, |
| 117 |
'meta/language': true, |
| 118 |
'textStyle/datetime': true, |
| 119 |
'link/mwExternal': !mw.config.get( 'wgVisualEditorConfig' ).allowExternalLinkPaste, |
| 120 |
|
| 121 |
article: true, |
| 122 |
section: true |
| 123 |
}, ve.init.mw.Target.static.importRules.external.blacklist ); |
| 124 |
|
| 125 |
ve.init.mw.Target.static.importRules.external.htmlBlacklist.remove = ve.extendObject( { |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
'sup.reference:not( [typeof] )': true, |
| 130 |
|
| 131 |
|
| 132 |
'a[ href *= "#cite_note" ]': true |
| 133 |
}, ve.init.mw.Target.static.importRules.external.htmlBlacklist.remove ); |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
ve.init.mw.Target.static.importRules.external.htmlBlacklist.unwrap = ve.extendObject( { |
| 141 |
'li h1, li h2, li h3, li h4, li h5, li h6': true, |
| 142 |
'blockquote h1, blockquote h2, blockquote h3, blockquote h4, blockquote h5, blockquote h6': true |
| 143 |
}, ve.init.mw.Target.static.importRules.external.htmlBlacklist.unwrap ); |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
ve.init.mw.Target.static.integrationType = null; |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
ve.init.mw.Target.static.platformType = null; |
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
ve.init.mw.Target.static.fixBase = function ( doc ) { |
| 174 |
ve.fixBase( doc, document, ve.resolveUrl( |
| 175 |
|
| 176 |
|
| 177 |
mw.config.get( 'wgArticlePath' ).replace( '$1', '' ), |
| 178 |
document |
| 179 |
) ); |
| 180 |
}; |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
ve.init.mw.Target.static.createModelFromDom = function ( doc, mode, options ) { |
| 186 |
const conf = mw.config.get( 'wgVisualEditor' ); |
| 187 |
|
| 188 |
options = ve.extendObject( { |
| 189 |
lang: conf.pageLanguageCode, |
| 190 |
dir: conf.pageLanguageDir |
| 191 |
}, options ); |
| 192 |
|
| 193 |
|
| 194 |
return ve.init.mw.Target.super.static.createModelFromDom.call( this, doc, mode, options ); |
| 195 |
}; |
| 196 |
|
| 197 |
|
| 198 |
ve.init.mw.Target.prototype.createModelFromDom = function () { |
| 199 |
return this.constructor.static.createModelFromDom.apply( this.constructor.static, arguments ); |
| 200 |
}; |
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
ve.init.mw.Target.static.parseDocument = function ( documentString, mode, section, onlySection ) { |
| 212 |
let doc; |
| 213 |
if ( mode === 'source' ) { |
| 214 |
|
| 215 |
doc = ve.init.mw.Target.super.static.parseDocument.call( this, documentString, mode ); |
| 216 |
} else { |
| 217 |
doc = ve.createDocumentFromHtml( documentString ); |
| 218 |
if ( section !== undefined ) { |
| 219 |
if ( onlySection ) { |
| 220 |
const sectionNode = doc.body.querySelector( '[data-mw-section-id="' + section + '"]' ); |
| 221 |
doc.body.innerHTML = ''; |
| 222 |
if ( sectionNode ) { |
| 223 |
doc.body.appendChild( sectionNode ); |
| 224 |
} |
| 225 |
} else { |
| 226 |
|
| 227 |
mw.libs.ve.unwrapParsoidSections( doc.body, section ); |
| 228 |
} |
| 229 |
} |
| 230 |
|
| 231 |
mw.libs.ve.stripParsoidFallbackIds( doc.body ); |
| 232 |
|
| 233 |
|
| 234 |
mw.libs.ve.reduplicateStyles( doc.body ); |
| 235 |
|
| 236 |
this.fixBase( doc ); |
| 237 |
|
| 238 |
Array.prototype.forEach.call( doc.querySelectorAll( 'script' ), ( element ) => { |
| 239 |
function truncate( text, l ) { |
| 240 |
return text.length > l ? text.slice( 0, l ) + '…' : text; |
| 241 |
} |
| 242 |
const errorMessage = 'DOM content matching deny list found during parse:\n' + truncate( element.outerHTML, 100 ) + |
| 243 |
'\nContext:\n' + truncate( element.parentNode.outerHTML, 200 ); |
| 244 |
mw.log.error( errorMessage ); |
| 245 |
const err = new Error( errorMessage ); |
| 246 |
err.name = 'VeDomDenyListWarning'; |
| 247 |
mw.errorLogger.logError( err, 'error.visualeditor' ); |
| 248 |
element.parentNode.removeChild( element ); |
| 249 |
} ); |
| 250 |
} |
| 251 |
|
| 252 |
return doc; |
| 253 |
}; |
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
ve.init.mw.Target.prototype.documentReady = function ( doc ) { |
| 263 |
this.setupSurface( doc ); |
| 264 |
}; |
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
ve.init.mw.Target.prototype.surfaceReady = function () { |
| 272 |
this.emit( 'surfaceReady' ); |
| 273 |
}; |
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
ve.init.mw.Target.prototype.getHtml = function ( newDoc, oldDoc ) { |
| 282 |
OO.ui.warnDeprecation( 've.init.mw.Target#getHtml is deprecated. Use mw.libs.ve.targetSaver.getHtml.' ); |
| 283 |
return mw.libs.ve.targetSaver.getHtml( newDoc, oldDoc ); |
| 284 |
}; |
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
ve.init.mw.Target.prototype.track = function () {}; |
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
ve.init.mw.Target.prototype.getSurfaceClasses = function () { |
| 299 |
return this.surfaceClasses; |
| 300 |
}; |
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
ve.init.mw.Target.prototype.createTargetWidget = function ( config ) { |
| 306 |
return new ve.ui.MWTargetWidget( ve.extendObject( { |
| 307 |
|
| 308 |
modes: [ 'visual' ], |
| 309 |
defaultMode: 'visual', |
| 310 |
toolbarGroups: this.toolbarGroups.filter( ( group ) => group.align !== 'after' ), |
| 311 |
surfaceClasses: this.getSurfaceClasses() |
| 312 |
}, config ) ); |
| 313 |
}; |
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
ve.init.mw.Target.prototype.createSurface = function ( dmDoc, config ) { |
| 319 |
if ( config && config.mode === 'source' ) { |
| 320 |
const importRules = ve.copy( this.constructor.static.importRules ); |
| 321 |
importRules.all = importRules.all || {}; |
| 322 |
|
| 323 |
importRules.all.keepEmptyContentBranches = true; |
| 324 |
config = this.getSurfaceConfig( ve.extendObject( {}, config, { |
| 325 |
importRules: importRules |
| 326 |
} ) ); |
| 327 |
return new ve.ui.MWWikitextSurface( this, dmDoc, config ); |
| 328 |
} |
| 329 |
|
| 330 |
return new ve.ui.MWSurface( this, dmDoc, this.getSurfaceConfig( config ) ); |
| 331 |
}; |
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
ve.init.mw.Target.prototype.getSurfaceConfig = function ( config ) { |
| 337 |
|
| 338 |
config = ve.extendObject( { mode: this.defaultMode }, config ); |
| 339 |
|
| 340 |
return ve.init.mw.Target.super.prototype.getSurfaceConfig.call( this, ve.extendObject( { |
| 341 |
|
| 342 |
commandRegistry: config.mode === 'source' ? ve.ui.wikitextCommandRegistry : ve.ui.commandRegistry, |
| 343 |
sequenceRegistry: config.mode === 'source' ? ve.ui.wikitextSequenceRegistry : ve.ui.sequenceRegistry, |
| 344 |
dataTransferHandlerFactory: config.mode === 'source' ? ve.ui.wikitextDataTransferHandlerFactory : ve.ui.dataTransferHandlerFactory, |
| 345 |
classes: this.getSurfaceClasses() |
| 346 |
}, config ) ); |
| 347 |
}; |
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
ve.init.mw.Target.prototype.setupSurface = function ( doc ) { |
| 355 |
setTimeout( () => { |
| 356 |
|
| 357 |
this.track( 'trace.convertModelFromDom.enter' ); |
| 358 |
const dmDoc = this.constructor.static.createModelFromDom( doc, this.getDefaultMode() ); |
| 359 |
this.track( 'trace.convertModelFromDom.exit' ); |
| 360 |
|
| 361 |
|
| 362 |
this.track( 'trace.buildModelTree.enter' ); |
| 363 |
dmDoc.buildNodeTree(); |
| 364 |
this.track( 'trace.buildModelTree.exit' ); |
| 365 |
|
| 366 |
setTimeout( () => { |
| 367 |
this.addSurface( dmDoc ); |
| 368 |
} ); |
| 369 |
} ); |
| 370 |
}; |
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
ve.init.mw.Target.prototype.addSurface = function () { |
| 376 |
|
| 377 |
|
| 378 |
this.clearSurfaces(); |
| 379 |
|
| 380 |
|
| 381 |
this.track( 'trace.createSurface.enter' ); |
| 382 |
|
| 383 |
const surface = ve.init.mw.Target.super.prototype.addSurface.apply( this, arguments ); |
| 384 |
|
| 385 |
|
| 386 |
if ( !surface.inTargetWidget ) { |
| 387 |
surface.$element.addClass( 've-init-mw-target-surface' ); |
| 388 |
} |
| 389 |
this.track( 'trace.createSurface.exit' ); |
| 390 |
|
| 391 |
this.setSurface( surface ); |
| 392 |
|
| 393 |
setTimeout( () => { |
| 394 |
|
| 395 |
this.track( 'trace.initializeSurface.enter' ); |
| 396 |
|
| 397 |
this.active = true; |
| 398 |
|
| 399 |
|
| 400 |
surface.initialize(); |
| 401 |
|
| 402 |
this.track( 'trace.initializeSurface.exit' ); |
| 403 |
this.surfaceReady(); |
| 404 |
} ); |
| 405 |
|
| 406 |
return surface; |
| 407 |
}; |
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
ve.init.mw.Target.prototype.setSurface = function ( surface ) { |
| 413 |
if ( !surface.$element.parent().length ) { |
| 414 |
this.$element.append( surface.$element ); |
| 415 |
} |
| 416 |
|
| 417 |
|
| 418 |
ve.init.mw.Target.super.prototype.setSurface.apply( this, arguments ); |
| 419 |
}; |
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
ve.init.mw.Target.prototype.initAutosave = function ( config ) { |
| 431 |
|
| 432 |
|
| 433 |
if ( typeof config === 'boolean' ) { |
| 434 |
config = { suppressNotification: config }; |
| 435 |
} else { |
| 436 |
config = config || {}; |
| 437 |
} |
| 438 |
|
| 439 |
const surfaceModel = this.getSurface().getModel(); |
| 440 |
|
| 441 |
if ( config.docId ) { |
| 442 |
surfaceModel.setAutosaveDocId( config.docId ); |
| 443 |
} |
| 444 |
|
| 445 |
if ( config.storage ) { |
| 446 |
surfaceModel.setStorage( config.storage, config.storageExpiry ); |
| 447 |
} |
| 448 |
|
| 449 |
if ( this.recovered ) { |
| 450 |
|
| 451 |
try { |
| 452 |
surfaceModel.restoreChanges(); |
| 453 |
if ( !config.suppressNotification ) { |
| 454 |
ve.init.platform.notify( |
| 455 |
ve.msg( 'visualeditor-autosave-recovered-text' ), |
| 456 |
ve.msg( 'visualeditor-autosave-recovered-title' ) |
| 457 |
); |
| 458 |
} |
| 459 |
} catch ( e ) { |
| 460 |
mw.log.warn( e ); |
| 461 |
ve.init.platform.notify( |
| 462 |
ve.msg( 'visualeditor-autosave-not-recovered-text' ), |
| 463 |
ve.msg( 'visualeditor-autosave-not-recovered-title' ), |
| 464 |
{ type: 'error' } |
| 465 |
); |
| 466 |
} |
| 467 |
} else { |
| 468 |
|
| 469 |
if ( this.fromEditedState ) { |
| 470 |
|
| 471 |
|
| 472 |
this.storeDocState( this.originalHtml ); |
| 473 |
} else { |
| 474 |
|
| 475 |
surfaceModel.once( 'undoStackChange', () => { |
| 476 |
|
| 477 |
if ( this.getSurface() ) { |
| 478 |
this.storeDocState( this.originalHtml ); |
| 479 |
} |
| 480 |
} ); |
| 481 |
} |
| 482 |
} |
| 483 |
|
| 484 |
surfaceModel.startStoringChanges(); |
| 485 |
|
| 486 |
}; |
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
ve.init.mw.Target.prototype.storeDocState = function ( html ) { |
| 494 |
const mode = this.getSurface().getMode(); |
| 495 |
this.getSurface().getModel().storeDocState( { mode: mode }, html ); |
| 496 |
}; |
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
ve.init.mw.Target.prototype.clearDocState = function () { |
| 502 |
if ( this.getSurface() ) { |
| 503 |
this.getSurface().getModel().removeDocStateAndChanges(); |
| 504 |
} |
| 505 |
}; |
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
ve.init.mw.Target.prototype.teardown = function () { |
| 511 |
|
| 512 |
this.clearDocState(); |
| 513 |
|
| 514 |
|
| 515 |
return ve.init.mw.Target.super.prototype.teardown.call( this ); |
| 516 |
}; |
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
ve.init.mw.Target.prototype.refreshUser = function ( doc ) { |
| 528 |
return this.getContentApi( doc ).get( { |
| 529 |
action: 'query', |
| 530 |
meta: 'userinfo' |
| 531 |
} ).then( ( data ) => { |
| 532 |
const userInfo = data.query && data.query.userinfo; |
| 533 |
|
| 534 |
if ( userInfo.anon !== undefined ) { |
| 535 |
|
| 536 |
mw.config.set( { |
| 537 |
|
| 538 |
wgUserId: undefined, |
| 539 |
|
| 540 |
|
| 541 |
wgUserName: null |
| 542 |
} ); |
| 543 |
|
| 544 |
|
| 545 |
return mw.user.acquireTempUserName(); |
| 546 |
} else { |
| 547 |
|
| 548 |
mw.config.set( { |
| 549 |
wgUserId: userInfo.id, |
| 550 |
wgUserName: userInfo.name |
| 551 |
} ); |
| 552 |
|
| 553 |
return mw.user.getName(); |
| 554 |
} |
| 555 |
} ); |
| 556 |
}; |
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
ve.init.mw.Target.prototype.getWikitextFragment = function ( doc, useRevision ) { |
| 566 |
|
| 567 |
if ( !doc.data.hasContent() ) { |
| 568 |
return ve.createDeferred().resolve( '' ); |
| 569 |
} |
| 570 |
|
| 571 |
const params = { |
| 572 |
action: 'visualeditoredit', |
| 573 |
paction: 'serialize', |
| 574 |
html: mw.libs.ve.targetSaver.getHtml( |
| 575 |
ve.dm.converter.getDomFromModel( doc ) |
| 576 |
), |
| 577 |
page: this.getPageName() |
| 578 |
}; |
| 579 |
|
| 580 |
if ( useRevision === undefined || useRevision ) { |
| 581 |
params.oldid = this.revid; |
| 582 |
params.etag = this.etag; |
| 583 |
} |
| 584 |
|
| 585 |
const xhr = this.getContentApi( doc ).postWithToken( 'csrf', |
| 586 |
params, |
| 587 |
{ contentType: 'multipart/form-data' } |
| 588 |
); |
| 589 |
|
| 590 |
return xhr.then( ( response ) => { |
| 591 |
if ( response.visualeditoredit ) { |
| 592 |
return response.visualeditoredit.content; |
| 593 |
} |
| 594 |
return ve.createDeferred().reject(); |
| 595 |
} ).promise( { abort: xhr.abort } ); |
| 596 |
}; |
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
ve.init.mw.Target.prototype.parseWikitextFragment = function ( wikitext, pst, doc ) { |
| 607 |
let abortable, aborted; |
| 608 |
const abortedPromise = ve.createDeferred().reject( 'http', |
| 609 |
{ textStatus: 'abort', exception: 'abort' } ).promise(); |
| 610 |
|
| 611 |
function abort() { |
| 612 |
aborted = true; |
| 613 |
if ( abortable && abortable.abort ) { |
| 614 |
abortable.abort(); |
| 615 |
} |
| 616 |
} |
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
let tempUserNamePromise; |
| 621 |
if ( pst ) { |
| 622 |
tempUserNamePromise = mw.user.acquireTempUserName(); |
| 623 |
} else { |
| 624 |
tempUserNamePromise = ve.createDeferred().resolve( null ); |
| 625 |
} |
| 626 |
|
| 627 |
return tempUserNamePromise |
| 628 |
.then( () => { |
| 629 |
if ( aborted ) { |
| 630 |
return abortedPromise; |
| 631 |
} |
| 632 |
return ( abortable = this.getContentApi( doc ).post( { |
| 633 |
action: 'visualeditor', |
| 634 |
paction: 'parsefragment', |
| 635 |
page: this.getPageName( doc ), |
| 636 |
wikitext: wikitext, |
| 637 |
pst: pst |
| 638 |
} ) ); |
| 639 |
} ) |
| 640 |
.promise( { abort: abort } ); |
| 641 |
}; |
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
ve.init.mw.Target.prototype.getPageName = function () { |
| 650 |
return this.pageName; |
| 651 |
}; |
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
ve.init.mw.Target.prototype.getContentApi = function ( doc, options ) { |
| 666 |
options = options || {}; |
| 667 |
options.parameters = ve.extendObject( { formatversion: 2 }, options.parameters ); |
| 668 |
return new mw.Api( options ); |
| 669 |
}; |
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
ve.init.mw.Target.prototype.getLocalApi = function ( options ) { |
| 681 |
options = options || {}; |
| 682 |
options.parameters = ve.extendObject( { formatversion: 2 }, options.parameters ); |
| 683 |
return new mw.Api( options ); |
| 684 |
}; |