| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
ve.ui.MWPreviewElement = function VeUiMwPreviewElement() { |
| 21 |
|
| 22 |
ve.ui.MWPreviewElement.super.apply( this, arguments ); |
| 23 |
|
| 24 |
|
| 25 |
this.$element.addClass( 've-ui-mwPreviewElement mw-body-content mw-parser-output' ); |
| 26 |
}; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
OO.inheritClass( ve.ui.MWPreviewElement, ve.ui.PreviewElement ); |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
ve.ui.MWPreviewElement.prototype.beforeAppend = function ( element ) { |
| 38 |
|
| 39 |
ve.ui.MWPreviewElement.super.prototype.beforeAppend.apply( this, arguments ); |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
Array.prototype.forEach.call( element.querySelectorAll( 'style[data-mw-deduplicate]' ), ( style ) => { |
| 44 |
const key = style.getAttribute( 'data-mw-deduplicate' ); |
| 45 |
|
| 46 |
const duplicate = element.querySelector( 'style[data-mw-deduplicate="' + key + '"]' ); |
| 47 |
if ( duplicate ) { |
| 48 |
style.parentNode.removeChild( style ); |
| 49 |
} |
| 50 |
} ); |
| 51 |
}; |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
ve.ui.MWPreviewElement.prototype.setModel = function ( model ) { |
| 57 |
|
| 58 |
ve.ui.MWPreviewElement.super.prototype.setModel.call( this, model ); |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
this.$element.addClass( 'mw-content-' + this.model.getDocument().getDir() ); |
| 64 |
}; |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
ve.ui.MWPreviewElement.prototype.replaceWithModelDom = function () { |
| 70 |
|
| 71 |
ve.ui.MWPreviewElement.super.prototype.replaceWithModelDom.apply( this, arguments ); |
| 72 |
|
| 73 |
ve.init.platform.linkCache.styleParsoidElements( |
| 74 |
this.$element, |
| 75 |
|
| 76 |
this.model.getDocument() && this.model.getDocument().getHtmlDocument() |
| 77 |
); |
| 78 |
}; |