mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-25 11:16:51 +00:00
Update VE core submodule to master (363adf2)
New changes: 63c5f67 [BREAKING CHANGE] GeneratedContentNode: Introduce new hash for rendering 6dd1cb2 Add ve.dm.Surface#selectLastContentOffset Local changes: * Use new getHashForRendering in GeneratedContentNode users As we no longer have a model hash, remove the originalIndex check and just rely on the deep comparison of mwData (trading a deep copy for a hash computation should result in similar performance). Bug: T114689 Change-Id: Ida0ee0234418408b735232c633d41908a424a9ff
This commit is contained in:
parent
b83511ac54
commit
9fb6977e52
2
lib/ve
2
lib/ve
|
@ -1 +1 @@
|
|||
Subproject commit 737a235cf0270c63705d5e433ff7a4068322a06e
|
||||
Subproject commit 363adf28cdc2b71311099ce240fd519d2b3b82a5
|
|
@ -60,7 +60,7 @@ ve.dm.MWExtensionNode.static.getMatchRdfaTypes = function () {
|
|||
};
|
||||
|
||||
ve.dm.MWExtensionNode.static.toDataElement = function ( domElements, converter ) {
|
||||
var dataElement, index,
|
||||
var dataElement,
|
||||
mwDataJSON = domElements[ 0 ].getAttribute( 'data-mw' ),
|
||||
mwData = mwDataJSON ? JSON.parse( mwDataJSON ) : {};
|
||||
|
||||
|
@ -72,30 +72,32 @@ ve.dm.MWExtensionNode.static.toDataElement = function ( domElements, converter )
|
|||
}
|
||||
};
|
||||
|
||||
index = this.storeGeneratedContents( dataElement, domElements, converter.getStore() );
|
||||
dataElement.attributes.originalIndex = index;
|
||||
this.storeGeneratedContents( dataElement, domElements, converter.getStore() );
|
||||
|
||||
return dataElement;
|
||||
};
|
||||
|
||||
ve.dm.MWExtensionNode.static.toDomElements = function ( dataElement, doc, converter ) {
|
||||
var el, els,
|
||||
index = converter.getStore().indexOfHash( OO.getHash( [ this.getHashObject( dataElement ), undefined ] ) ),
|
||||
var el, els, index,
|
||||
store = converter.getStore(),
|
||||
originalMw = dataElement.attributes.originalMw;
|
||||
|
||||
// If the transclusion is unchanged just send back the
|
||||
// original DOM elements so selser can skip over it
|
||||
if (
|
||||
index === dataElement.attributes.originalIndex ||
|
||||
( originalMw && ve.compare( dataElement.attributes.mw, JSON.parse( originalMw ) ) )
|
||||
) {
|
||||
// The object in the store is also used for CE rendering so return a copy
|
||||
// originalDomElements is also used for CE rendering so return a copy
|
||||
els = ve.copyDomElements( dataElement.originalDomElements, doc );
|
||||
} else {
|
||||
if ( converter.isForClipboard() && index !== null ) {
|
||||
if (
|
||||
converter.isForClipboard() &&
|
||||
// Use getHashObjectForRendering to get the rendering from the store
|
||||
( index = store.indexOfHash( OO.getHash( [ this.getHashObjectForRendering( dataElement ), undefined ] ) ) ) !== null
|
||||
) {
|
||||
// For the clipboard use the current DOM contents so the user has something
|
||||
// meaningful to paste into external applications
|
||||
els = ve.copyDomElements( converter.getStore().value( index ), doc );
|
||||
els = ve.copyDomElements( store.value( index ), doc );
|
||||
} else {
|
||||
el = doc.createElement( this.tagName );
|
||||
el.setAttribute( 'typeof', 'mw:Extension/' + this.getExtensionName( dataElement ) );
|
||||
|
|
|
@ -90,7 +90,7 @@ ve.dm.MWTransclusionNode.static.inlineType = 'mwTransclusionInline';
|
|||
ve.dm.MWTransclusionNode.static.blockType = 'mwTransclusionBlock';
|
||||
|
||||
ve.dm.MWTransclusionNode.static.toDataElement = function ( domElements, converter ) {
|
||||
var dataElement, index,
|
||||
var dataElement,
|
||||
mwDataJSON = domElements[ 0 ].getAttribute( 'data-mw' ),
|
||||
mwData = mwDataJSON ? JSON.parse( mwDataJSON ) : {},
|
||||
isInline = this.isHybridInline( domElements, converter ),
|
||||
|
@ -110,16 +110,15 @@ ve.dm.MWTransclusionNode.static.toDataElement = function ( domElements, converte
|
|||
}
|
||||
|
||||
if ( !domElements[ 0 ].getAttribute( 'data-ve-no-generated-contents' ) ) {
|
||||
index = this.storeGeneratedContents( dataElement, domElements, converter.getStore() );
|
||||
dataElement.attributes.originalIndex = index;
|
||||
this.storeGeneratedContents( dataElement, domElements, converter.getStore() );
|
||||
}
|
||||
|
||||
return dataElement;
|
||||
};
|
||||
|
||||
ve.dm.MWTransclusionNode.static.toDomElements = function ( dataElement, doc, converter ) {
|
||||
var els, i, len, span,
|
||||
index = converter.getStore().indexOfHash( OO.getHash( [ this.getHashObject( dataElement ), undefined ] ) ),
|
||||
var els, i, len, span, index,
|
||||
store = converter.getStore(),
|
||||
originalMw = dataElement.attributes.originalMw;
|
||||
|
||||
function wrapTextNode( node ) {
|
||||
|
@ -135,18 +134,20 @@ ve.dm.MWTransclusionNode.static.toDomElements = function ( dataElement, doc, con
|
|||
// If the transclusion is unchanged just send back the
|
||||
// original DOM elements so selser can skip over it
|
||||
if (
|
||||
dataElement.originalDomElements && (
|
||||
index === dataElement.attributes.originalIndex ||
|
||||
( originalMw && ve.compare( dataElement.attributes.mw, JSON.parse( originalMw ) ) )
|
||||
)
|
||||
dataElement.originalDomElements &&
|
||||
originalMw && ve.compare( dataElement.attributes.mw, JSON.parse( originalMw ) )
|
||||
) {
|
||||
// The object in the store is also used for CE rendering so return a copy
|
||||
// originalDomElements is also used for CE rendering so return a copy
|
||||
els = ve.copyDomElements( dataElement.originalDomElements, doc );
|
||||
} else {
|
||||
if ( converter.isForClipboard() && index !== null ) {
|
||||
if (
|
||||
converter.isForClipboard() &&
|
||||
// Use getHashObjectForRendering to get the rendering from the store
|
||||
( index = store.indexOfHash( OO.getHash( [ this.getHashObjectForRendering( dataElement ), undefined ] ) ) ) !== null
|
||||
) {
|
||||
// For the clipboard use the current DOM contents so the user has something
|
||||
// meaningful to paste into external applications
|
||||
els = ve.copyDomElements( converter.getStore().value( index ), doc );
|
||||
els = ve.copyDomElements( store.value( index ), doc );
|
||||
els[ 0 ] = wrapTextNode( els[ 0 ] );
|
||||
} else if ( dataElement.originalDomElements ) {
|
||||
els = [ doc.createElement( dataElement.originalDomElements[ 0 ].nodeName ) ];
|
||||
|
|
|
@ -150,8 +150,7 @@ ve.dm.mwExample.MWTransclusion.blockData = {
|
|||
}
|
||||
]
|
||||
},
|
||||
originalMw: '{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"Hello, world!"}},"i":0}}]}',
|
||||
originalIndex: 0
|
||||
originalMw: '{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"Hello, world!"}},"i":0}}]}'
|
||||
}
|
||||
};
|
||||
ve.dm.mwExample.MWTransclusion.inlineData = {
|
||||
|
@ -175,8 +174,7 @@ ve.dm.mwExample.MWTransclusion.inlineData = {
|
|||
}
|
||||
]
|
||||
},
|
||||
originalMw: '{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"1,234"}},"i":0}}]}',
|
||||
originalIndex: 0
|
||||
originalMw: '{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"1,234"}},"i":0}}]}'
|
||||
}
|
||||
};
|
||||
ve.dm.mwExample.MWTransclusion.mixedDataOpen = {
|
||||
|
@ -200,8 +198,7 @@ ve.dm.mwExample.MWTransclusion.mixedDataOpen = {
|
|||
}
|
||||
]
|
||||
},
|
||||
originalMw: '{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"5,678"}},"i":0}}]}',
|
||||
originalIndex: 0
|
||||
originalMw: '{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"5,678"}},"i":0}}]}'
|
||||
}
|
||||
};
|
||||
ve.dm.mwExample.MWTransclusion.mixedDataClose = { type: '/mwTransclusionInline' };
|
||||
|
@ -974,8 +971,7 @@ ve.dm.mwExample.domToDataCases = {
|
|||
}
|
||||
]
|
||||
},
|
||||
originalMw: '{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}',
|
||||
originalIndex: 0
|
||||
originalMw: '{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'
|
||||
}
|
||||
},
|
||||
{ type: '/mwTransclusionBlock' },
|
||||
|
@ -1000,8 +996,7 @@ ve.dm.mwExample.domToDataCases = {
|
|||
}
|
||||
]
|
||||
},
|
||||
originalMw: '{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}',
|
||||
originalIndex: 0
|
||||
originalMw: '{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'
|
||||
}
|
||||
},
|
||||
{ type: '/mwTransclusionBlock' },
|
||||
|
@ -1041,7 +1036,6 @@ ve.dm.mwExample.domToDataCases = {
|
|||
}
|
||||
} ]
|
||||
},
|
||||
originalIndex: 0,
|
||||
originalMw: '{\"parts\":[{\"template\":{\"target\":{\"wt\":\"Template:Echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"[[Category:Page]]\\n[[Category:Book]]\"}},\"i\":0}}]}'
|
||||
}
|
||||
},
|
||||
|
@ -1059,7 +1053,6 @@ ve.dm.mwExample.domToDataCases = {
|
|||
type: 'mwTransclusionInline',
|
||||
attributes: {
|
||||
mw: {},
|
||||
originalIndex: 0,
|
||||
originalMw: '{}'
|
||||
},
|
||||
originalDomElements: $( '<span dir="ltr" about="#mwt1" typeof="mw:Transclusion" data-mw="{}">content</span>' ).toArray()
|
||||
|
@ -1098,7 +1091,6 @@ ve.dm.mwExample.domToDataCases = {
|
|||
extsrc: '\n$foo = bar;\n'
|
||||
}
|
||||
},
|
||||
originalIndex: 0,
|
||||
originalMw: '{"name":"syntaxhighlight","attrs":{"lang":"php"},"body":{"extsrc":"\\n$foo = bar;\\n"}}'
|
||||
},
|
||||
originalDomElements: $( '<div about="#mwt1" data-parsoid="1"></div>' ).toArray()
|
||||
|
@ -1136,7 +1128,6 @@ ve.dm.mwExample.domToDataCases = {
|
|||
extsrc: '\\relative c\' { e d c d e e e }'
|
||||
}
|
||||
},
|
||||
originalIndex: 0,
|
||||
originalMw: '{"name":"score","attrs":{},"body":{"extsrc":"\\\\relative c\' { e d c d e e e }"}}'
|
||||
},
|
||||
originalDomElements: $( '<img src="Foo" width="100" height="20" alt="Bar" about="#mwt1" data-parsoid="1"></img>' ).toArray()
|
||||
|
|
Loading…
Reference in a new issue