mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 06:24:08 +00:00
Update VE core submodule to master (984b57a)
New changes: 6bbcd6a Localisation updates from https://translatewiki.net. b8d8a5b [BREAKING CHANGE] The Great Selection Rewrite of 2014 Local changes: Update to use new selection/range API Change-Id: I5480d5c77d599c93c2d374fac88bb2fdb68b0024
This commit is contained in:
parent
e1806defb5
commit
1af18c3c12
|
@ -58,6 +58,7 @@
|
|||
"ve.dm.NodeFactory",
|
||||
"ve.dm.Surface",
|
||||
"ve.dm.SurfaceFragment",
|
||||
"ve.dm.*Selection",
|
||||
"ve.dm.Transaction",
|
||||
"ve.dm.TransactionProcessor",
|
||||
"ve.dm.TransactionProcessor.processors",
|
||||
|
|
|
@ -135,6 +135,9 @@
|
|||
<script src="lib/ve/src/dm/ve.dm.MetaList.js"></script>
|
||||
<script src="lib/ve/src/dm/ve.dm.TransactionProcessor.js"></script>
|
||||
<script src="lib/ve/src/dm/ve.dm.Transaction.js"></script>
|
||||
<script src="lib/ve/src/dm/ve.dm.Selection.js"></script>
|
||||
<script src="lib/ve/src/dm/ve.dm.LinearSelection.js"></script>
|
||||
<script src="lib/ve/src/dm/ve.dm.NullSelection.js"></script>
|
||||
<script src="lib/ve/src/dm/ve.dm.Surface.js"></script>
|
||||
<script src="lib/ve/src/dm/ve.dm.SurfaceFragment.js"></script>
|
||||
<script src="lib/ve/src/dm/ve.dm.DataString.js"></script>
|
||||
|
|
|
@ -345,6 +345,9 @@ $wgResourceModules += array(
|
|||
'lib/ve/src/dm/ve.dm.MetaList.js',
|
||||
'lib/ve/src/dm/ve.dm.TransactionProcessor.js',
|
||||
'lib/ve/src/dm/ve.dm.Transaction.js',
|
||||
'lib/ve/src/dm/ve.dm.Selection.js',
|
||||
'lib/ve/src/dm/ve.dm.LinearSelection.js',
|
||||
'lib/ve/src/dm/ve.dm.NullSelection.js',
|
||||
'lib/ve/src/dm/ve.dm.Surface.js',
|
||||
'lib/ve/src/dm/ve.dm.SurfaceFragment.js',
|
||||
'lib/ve/src/dm/ve.dm.DataString.js',
|
||||
|
|
2
lib/ve
2
lib/ve
|
@ -1 +1 @@
|
|||
Subproject commit cfd855ed06ce6e6214f467fd1d52f04d22e7d119
|
||||
Subproject commit 984b57ae32e72d11e529c374f6009278e6941685
|
|
@ -359,8 +359,8 @@ ve.dm.MWImageModel.prototype.updateImageNode = function ( node, surfaceModel ) {
|
|||
if ( !captionNode ) {
|
||||
// There was no caption before, so insert one now
|
||||
surfaceModel.getFragment()
|
||||
.adjustRange( 1 )
|
||||
.collapseRangeToStart()
|
||||
.adjustLinearSelection( 1 )
|
||||
.collapseToStart()
|
||||
.insertContent( [ { type: 'mwImageCaption' }, { type: '/mwImageCaption' } ] );
|
||||
// Update the caption node
|
||||
captionNode = node.getCaptionNode();
|
||||
|
@ -414,6 +414,10 @@ ve.dm.MWImageModel.prototype.insertImageNode = function ( fragment ) {
|
|||
originalAttrs = ve.copy( this.getOriginalImageAttributes() ),
|
||||
surfaceModel = fragment.getSurface();
|
||||
|
||||
if ( !( fragment.getSelection() instanceof ve.dm.LinearSelection ) ) {
|
||||
return fragment;
|
||||
}
|
||||
|
||||
editAttributes = $.extend( originalAttrs, this.getUpdatedAttributes() );
|
||||
|
||||
// Remove old classes
|
||||
|
@ -431,9 +435,9 @@ ve.dm.MWImageModel.prototype.insertImageNode = function ( fragment ) {
|
|||
switch ( nodeType ) {
|
||||
case 'mwInlineImage':
|
||||
// Try to put the image inside the nearest content node
|
||||
offset = fragment.getDocument().data.getNearestContentOffset( fragment.getRange().start );
|
||||
offset = fragment.getDocument().data.getNearestContentOffset( fragment.getSelection().getRange().start );
|
||||
if ( offset > -1 ) {
|
||||
fragment = fragment.clone( new ve.Range( offset ) );
|
||||
fragment = fragment.clone( new ve.dm.LinearSelection( fragment.getDocument(), new ve.Range( offset ) ) );
|
||||
}
|
||||
fragment.insertContent( contentToInsert );
|
||||
return fragment;
|
||||
|
@ -441,9 +445,9 @@ ve.dm.MWImageModel.prototype.insertImageNode = function ( fragment ) {
|
|||
case 'mwBlockImage':
|
||||
contentToInsert.splice( 1, 0, { type: 'mwImageCaption' }, { type: '/mwImageCaption' } );
|
||||
// Try to put the image in front of the structural node
|
||||
offset = fragment.getDocument().data.getNearestStructuralOffset( fragment.getRange().start, -1 );
|
||||
offset = fragment.getDocument().data.getNearestStructuralOffset( fragment.getSelection().getRange().start, -1 );
|
||||
if ( offset > -1 ) {
|
||||
fragment = fragment.clone( new ve.Range( offset ) );
|
||||
fragment = fragment.clone( new ve.dm.LinearSelection( fragment.getDocument(), new ve.Range( offset ) ) );
|
||||
}
|
||||
fragment.insertContent( contentToInsert );
|
||||
// Check if there is caption document and insert it
|
||||
|
@ -453,7 +457,7 @@ ve.dm.MWImageModel.prototype.insertImageNode = function ( fragment ) {
|
|||
surfaceModel.change(
|
||||
ve.dm.Transaction.newFromDocumentInsertion(
|
||||
surfaceModel.getDocument(),
|
||||
fragment.getRange().start + 2,
|
||||
fragment.getSelection().getRange().start + 2,
|
||||
this.getCaptionDocument()
|
||||
)
|
||||
);
|
||||
|
|
|
@ -73,10 +73,10 @@
|
|||
var obj = this.getPlainObject();
|
||||
|
||||
if ( obj !== null ) {
|
||||
surfaceModel.getFragment( node.getOuterRange(), true )
|
||||
surfaceModel.getLinearFragment( node.getOuterRange(), true )
|
||||
.changeAttributes( { mw: obj } );
|
||||
} else {
|
||||
surfaceModel.getFragment( node.getOuterRange(), true )
|
||||
surfaceModel.getLinearFragment( node.getOuterRange(), true )
|
||||
.removeContent();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1491,7 +1491,7 @@ ve.init.mw.Target.prototype.goToHeading = function ( headingNode ) {
|
|||
// onDocumentFocus is debounced, so wait for that to happen before setting
|
||||
// the model selection, otherwise it will get reset
|
||||
this.surface.getView().once( 'focus', function () {
|
||||
surfaceModel.setSelection( new ve.Range( offset ) );
|
||||
surfaceModel.setLinearSelection( new ve.Range( offset ) );
|
||||
target.scrollToHeading( headingNode );
|
||||
} );
|
||||
};
|
||||
|
|
|
@ -16,7 +16,7 @@ QUnit.test( 'convert (MW-specific types)', function ( assert ) {
|
|||
range: new ve.Range( 14, 16 ),
|
||||
type: 'mwHeading',
|
||||
attributes: { level: 2 },
|
||||
expectedSelection: new ve.Range( 14, 16 ),
|
||||
expectedRange: new ve.Range( 14, 16 ),
|
||||
expectedData: function ( data ) {
|
||||
data.splice( 11, 2, { type: '/list' }, { type: 'mwHeading', attributes: { level: 2 } } );
|
||||
data.splice( 19, 2, { type: '/mwHeading' }, { type: 'list', attributes: { style: 'bullet' } } );
|
||||
|
@ -27,7 +27,7 @@ QUnit.test( 'convert (MW-specific types)', function ( assert ) {
|
|||
range: new ve.Range( 15, 50 ),
|
||||
type: 'mwHeading',
|
||||
attributes: { level: 3 },
|
||||
expectedSelection: new ve.Range( 15, 44 ),
|
||||
expectedRange: new ve.Range( 15, 44 ),
|
||||
expectedData: function ( data ) {
|
||||
data.splice( 11, 2, { type: '/list' }, { type: 'mwHeading', attributes: { level: 3 } } );
|
||||
data.splice( 19, 4, { type: '/mwHeading' }, { type: 'mwHeading', attributes: { level: 3 } } );
|
||||
|
@ -41,7 +41,7 @@ QUnit.test( 'convert (MW-specific types)', function ( assert ) {
|
|||
range: new ve.Range( 4, 28 ),
|
||||
type: 'mwHeading',
|
||||
attributes: { level: 1 },
|
||||
expectedSelection: new ve.Range( 2, 22 ),
|
||||
expectedRange: new ve.Range( 2, 22 ),
|
||||
expectedData: function ( data ) {
|
||||
data.splice( 0, 3, { type: 'mwHeading', attributes: { level: 1 } } );
|
||||
data.splice( 7, 4, { type: '/mwHeading' }, { type: 'mwHeading', attributes: { level: 1 } } );
|
||||
|
@ -54,7 +54,7 @@ QUnit.test( 'convert (MW-specific types)', function ( assert ) {
|
|||
range: new ve.Range( 5, 26 ),
|
||||
type: 'mwPreformatted',
|
||||
attributes: undefined,
|
||||
expectedSelection: new ve.Range( 3, 20 ),
|
||||
expectedRange: new ve.Range( 3, 20 ),
|
||||
expectedData: function ( data ) {
|
||||
data.splice( 0, 3, { type: 'mwPreformatted' } );
|
||||
data.splice( 7, 4, { type: '/mwPreformatted' }, { type: 'mwPreformatted' } );
|
||||
|
@ -67,6 +67,6 @@ QUnit.test( 'convert (MW-specific types)', function ( assert ) {
|
|||
|
||||
QUnit.expect( cases.length * 4 );
|
||||
for ( i = 0; i < cases.length; i++ ) {
|
||||
ve.test.utils.runFormatConverterTest( assert, cases[i].range, cases[i].type, cases[i].attributes, cases[i].expectedSelection, cases[i].expectedData, cases[i].msg );
|
||||
ve.test.utils.runFormatConverterTest( assert, cases[i].range, cases[i].type, cases[i].attributes, cases[i].expectedRange, cases[i].expectedData, cases[i].msg );
|
||||
}
|
||||
} );
|
||||
|
|
|
@ -171,7 +171,7 @@ ve.ui.MWCitationDialog.prototype.getActionProcess = function ( action ) {
|
|||
|
||||
if ( !this.referenceModel ) {
|
||||
// Collapse returns a new fragment, so update this.fragment
|
||||
this.fragment = this.getFragment().collapseRangeToEnd();
|
||||
this.fragment = this.getFragment().collapseToEnd();
|
||||
this.referenceModel = new ve.dm.MWReferenceModel();
|
||||
this.referenceModel.insertInternalItem( surfaceModel );
|
||||
this.referenceModel.insertReferenceNode( this.getFragment() );
|
||||
|
|
|
@ -351,7 +351,7 @@ ve.ui.MWReferenceDialog.prototype.getActionProcess = function ( action ) {
|
|||
this.referenceModel.insertInternalItem( surfaceModel );
|
||||
}
|
||||
// Collapse returns a new fragment, so update this.fragment
|
||||
this.fragment = this.getFragment().collapseRangeToEnd();
|
||||
this.fragment = this.getFragment().collapseToEnd();
|
||||
this.referenceModel.insertReferenceNode( this.getFragment() );
|
||||
}
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ ve.ui.MWReferencesListDialog.prototype.getActionProcess = function ( action ) {
|
|||
}
|
||||
} else {
|
||||
// Collapse returns a new fragment, so update this.fragment
|
||||
this.fragment = this.getFragment().collapseRangeToEnd().insertContent( [
|
||||
this.fragment = this.getFragment().collapseToEnd().insertContent( [
|
||||
{
|
||||
type: 'mwReferencesList',
|
||||
attributes: {
|
||||
|
|
|
@ -398,7 +398,7 @@ ve.ui.MWTemplateDialog.prototype.getActionProcess = function ( action ) {
|
|||
this.transclusionModel.updateTransclusionNode( surfaceModel, this.selectedNode );
|
||||
} else if ( obj !== null ) {
|
||||
// Collapse returns a new fragment, so update this.fragment
|
||||
this.fragment = this.getFragment().collapseRangeToEnd();
|
||||
this.fragment = this.getFragment().collapseToEnd();
|
||||
this.transclusionModel.insertTransclusionNode( this.getFragment() );
|
||||
}
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ ve.ui.MWExtensionInspector.prototype.insertOrUpdateNode = function () {
|
|||
};
|
||||
this.updateMwData( mwData );
|
||||
// Collapse returns a new fragment, so update this.fragment
|
||||
this.fragment = this.getFragment().collapseRangeToEnd();
|
||||
this.fragment = this.getFragment().collapseToEnd();
|
||||
this.getFragment().insertContent( [
|
||||
{
|
||||
type: this.constructor.static.nodeModel.static.name,
|
||||
|
|
|
@ -65,8 +65,8 @@ ve.ui.MWLiveExtensionInspector.prototype.getSetupProcess = function ( data ) {
|
|||
|
||||
if ( !this.node ) {
|
||||
// Create a new node
|
||||
// collapseRangeToEnd returns a new fragment
|
||||
this.fragment = this.getFragment().collapseRangeToEnd().insertContent( [
|
||||
// collapseToEnd returns a new fragment
|
||||
this.fragment = this.getFragment().collapseToEnd().insertContent( [
|
||||
{
|
||||
type: this.constructor.static.nodeModel.static.name,
|
||||
attributes: { mw: this.getNewMwData() }
|
||||
|
@ -74,8 +74,8 @@ ve.ui.MWLiveExtensionInspector.prototype.getSetupProcess = function ( data ) {
|
|||
{ type: '/' + this.constructor.static.nodeModel.static.name }
|
||||
] );
|
||||
// Check if the node was inserted at a structural offset and wrapped in a paragraph
|
||||
if ( this.getFragment().getRange().getLength() === 4 ) {
|
||||
this.fragment = this.getFragment().adjustRange( 1, -1 );
|
||||
if ( this.getFragment().getSelection().getRange().getLength() === 4 ) {
|
||||
this.fragment = this.getFragment().adjustLinearSelection( 1, -1 );
|
||||
}
|
||||
this.getFragment().select();
|
||||
this.node = this.getFragment().getSelectedNode();
|
||||
|
|
|
@ -70,7 +70,7 @@ ve.ui.MWUseExistingReferenceDialogTool.prototype.onUpdateState = function ( frag
|
|||
return false;
|
||||
}
|
||||
} );
|
||||
this.setDisabled( ( this.constructor.static.requiresRange && !fragment.getRange() ) || empty );
|
||||
this.setDisabled( ( this.constructor.static.requiresRange && fragment.isNull() ) || empty );
|
||||
};
|
||||
ve.ui.toolFactory.register( ve.ui.MWUseExistingReferenceDialogTool );
|
||||
|
||||
|
|
Loading…
Reference in a new issue