mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
7cec9ae04a
Allow pasting of rich (HTML) content. ve.ce.Surface * Use a sliced document clone for converting to DM HTML (copy) * Add full context to pasteTarget before copying * Add ve-pasteProtect class to spans to prevent them being dropped * Implement external paste by converting HTML to data and inserting with newFromDocumentInsertion * Remove clipboard key placeholder after read so they aren't picked up by rich paste. Hash no longer includes the placeholder. * Detect the corruption of important spans and fallback to clipboard data HTML if available. ve.dm.LinearData * Add clone method for copy ve.dm.ElementLinearData * Add compareUnannotated for use by context diffing. * Add sanitize method for cleaning data according to a set of rules. ve.dm.Transaction * Add range parameter for inserting a range of a document only, e.g. stripping the paste context. ve.dm.Document * Implement sliced document clone creation so that DM HTML is generated correctly in onCopy ve.dm.DocumentSlice * Replaces LinearDataSlice. Now has two ranges for balanced data and data with a full context. ve.init.Target.js * Define default, loose, paste rules (just remove aliens). ve.init.mw.ViewPageTarget * Define strict MW paste rules: + no links, spans, underlines + no images, divs, aliens + strip extra HTML attribues ve.init.sa.Target, ve.init.mw.ViewPageTarget, ve.ui.Surface * Pass through and store paste rules. Bug: 41193 Bug: 48170 Bug: 50128 Bug: 53828 Change-Id: I38d63e31ee3e3ee11707e3fffed5174e1d633b42
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
/*!
|
|
* VisualEditor DataModel DocumentSlice class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* DataModel document slice
|
|
*
|
|
* @class
|
|
* @extends ve.dm.Document
|
|
* @constructor
|
|
* @param {HTMLDocument|Array|ve.dm.ElementLinearData|ve.dm.FlatLinearData} data
|
|
* @param {HTMLDocument} [htmlDocument]
|
|
* @param {ve.dm.Document} [parentDocument]
|
|
* @param {ve.dm.InternalList} [internalList]
|
|
* @param {ve.Range} [originalRange] Range of original data
|
|
* @param {ve.Range} [balancedRange] Range of balanced data
|
|
*/
|
|
ve.dm.DocumentSlice = function VeDmDocumentSlice( data, htmlDocument, parentDocument, internalList, originalRange, balancedRange ) {
|
|
// Parent constructor
|
|
ve.dm.Document.call( this, data, htmlDocument, parentDocument, internalList );
|
|
|
|
this.originalRange = originalRange;
|
|
this.balancedRange = balancedRange;
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.dm.DocumentSlice, ve.dm.Document );
|
|
|
|
/* Methods */
|
|
|
|
ve.dm.DocumentSlice.prototype.getOriginalData = function () {
|
|
return this.getData( this.originalRange );
|
|
};
|
|
|
|
ve.dm.DocumentSlice.prototype.getBalancedData = function () {
|
|
return this.getData( this.balancedRange );
|
|
}; |