mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 06:46:26 +00:00
Merge "Add getDomSubtreeFromModel to converter API"
This commit is contained in:
commit
aad149fa43
|
@ -701,9 +701,7 @@ ve.ce.Surface.prototype.onCopy = function ( e ) {
|
||||||
// Clone the elements in the slice
|
// Clone the elements in the slice
|
||||||
slice.data.cloneElements();
|
slice.data.cloneElements();
|
||||||
|
|
||||||
ve.dm.converter.store = slice.getStore();
|
ve.dm.converter.getDomSubtreeFromModel( slice, this.$pasteTarget[0] );
|
||||||
ve.dm.converter.internalList = slice.getInternalList();
|
|
||||||
ve.dm.converter.getDomSubtreeFromData( slice.getData(), this.$pasteTarget[0] );
|
|
||||||
|
|
||||||
// Some browsers strip out spans when they match the styling of the
|
// Some browsers strip out spans when they match the styling of the
|
||||||
// paste target (e.g. plain spans) so we must protect against this
|
// paste target (e.g. plain spans) so we must protect against this
|
||||||
|
@ -842,9 +840,13 @@ ve.ce.Surface.prototype.beforePaste = function ( e ) {
|
||||||
}
|
}
|
||||||
context.push( { 'type': '/' + context[0].type } );
|
context.push( { 'type': '/' + context[0].type } );
|
||||||
|
|
||||||
ve.dm.converter.store = doc.getStore();
|
ve.dm.converter.getDomSubtreeFromModel(
|
||||||
ve.dm.converter.internalList = doc.getInternalList();
|
new ve.dm.Document(
|
||||||
ve.dm.converter.getDomSubtreeFromData( context, this.$pasteTarget[0] );
|
new ve.dm.ElementLinearData( doc.getStore(), context ),
|
||||||
|
doc.getHtmlDocument(), undefined, doc.getInternalList()
|
||||||
|
),
|
||||||
|
this.$pasteTarget[0]
|
||||||
|
);
|
||||||
|
|
||||||
// Giving the paste target focus too late can cause problems in FF (!?)
|
// Giving the paste target focus too late can cause problems in FF (!?)
|
||||||
// so do it up here.
|
// so do it up here.
|
||||||
|
|
|
@ -1072,19 +1072,30 @@ ve.dm.Converter.prototype.isDomAllMetaOrWhitespace = function ( domElements, exc
|
||||||
ve.dm.Converter.prototype.getDomFromModel = function ( model ) {
|
ve.dm.Converter.prototype.getDomFromModel = function ( model ) {
|
||||||
var doc = ve.createDocumentFromHtml( '' );
|
var doc = ve.createDocumentFromHtml( '' );
|
||||||
|
|
||||||
|
this.getDomSubtreeFromModel( model, doc.body );
|
||||||
|
|
||||||
|
return doc;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert document model to an HTML DOM subtree and add it to a container element.
|
||||||
|
*
|
||||||
|
* @method
|
||||||
|
* @param {ve.dm.Document} model Document model
|
||||||
|
* @param {HTMLElement} container DOM element to add the generated elements to. Should be empty.
|
||||||
|
*/
|
||||||
|
ve.dm.Converter.prototype.getDomSubtreeFromModel = function ( model, container ) {
|
||||||
// Set up the converter state
|
// Set up the converter state
|
||||||
this.documentData = model.getFullData();
|
this.documentData = model.getFullData();
|
||||||
this.store = model.getStore();
|
this.store = model.getStore();
|
||||||
this.internalList = model.getInternalList();
|
this.internalList = model.getInternalList();
|
||||||
|
|
||||||
this.getDomSubtreeFromData( this.documentData, doc.body, model.getInnerWhitespace() );
|
this.getDomSubtreeFromData( this.documentData, container, model.getInnerWhitespace() );
|
||||||
|
|
||||||
// Clear the state
|
// Clear the state
|
||||||
this.documentData = null;
|
this.documentData = null;
|
||||||
this.store = null;
|
this.store = null;
|
||||||
this.internalList = null;
|
this.internalList = null;
|
||||||
|
|
||||||
return doc;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue