Merge "Use new select[First|Last]SelectableContentOffset methods"

This commit is contained in:
jenkins-bot 2021-12-08 16:43:53 +00:00 committed by Gerrit Code Review
commit abc7a7d4b6
5 changed files with 4 additions and 63 deletions

View file

@ -118,7 +118,7 @@
}
target.once( 'surfaceReady', function () {
initPromise.then( function () {
surfaceModel.selectFirstContentOffset();
target.getSurface().getView().selectFirstSelectableContentOffset();
var isNewAuthor = !ve.init.platform.sessionStorage.get( 've-collab-author' );
// For new anon users, open the author list so they can set their name
if ( isNewAuthor && !username ) {

View file

@ -84,7 +84,7 @@ ve.ce.MWBlockImageNode.static.tagName = 'figure';
ve.ce.MWBlockImageNode.static.renderHtmlAttributes = false;
ve.ce.MWBlockImageNode.static.transition = false;
ve.ce.MWBlockImageNode.static.autoFocus = false;
ve.ce.MWBlockImageNode.static.cssClasses = {
default: {

View file

@ -48,8 +48,6 @@ ve.dm.MWBlockImageNode.static.preserveHtmlAttributes = function ( attribute ) {
ve.dm.MWBlockImageNode.static.handlesOwnChildren = true;
ve.dm.MWBlockImageNode.static.ignoreChildren = true;
ve.dm.MWBlockImageNode.static.childNodeTypes = [ 'mwImageCaption' ];
ve.dm.MWBlockImageNode.static.matchTagNames = [ 'figure' ];

View file

@ -302,9 +302,8 @@ ve.init.mw.MobileArticleTarget.prototype.surfaceReady = function () {
ve.init.mw.MobileArticleTarget.super.prototype.surfaceReady.apply( this, arguments );
// If no selection has been set yet, set it to the start of the document.
var surfaceModel = this.getSurface().getModel();
if ( surfaceModel.getSelection().isNull() ) {
surfaceModel.selectFirstContentOffset();
if ( this.getSurface().getModel().getSelection().isNull() ) {
this.getSurface().getView().selectFirstSelectableContentOffset();
}
this.events.trackActivationComplete();

View file

@ -9,62 +9,6 @@ QUnit.module( 've.ce.Surface (MW)', ve.test.utils.mwEnvironment );
/* Tests */
QUnit.test( 'handleLinearDelete', ( assert ) => {
const done = assert.async(),
blocklength = ve.dm.mwExample.MWBlockImage.data.length,
cases = [
// This asserts that getRelativeRange (via getRelativeOffset) doesn't try to
// enter a handleOwnChildren node
{
htmlOrDoc:
ve.dm.mwExample.MWBlockImage.html +
'<ul><li><p>Foo</p></li><li><p>Bar</p></li></ul>',
rangeOrSelection: new ve.Range( blocklength + 3 ),
keys: [ 'BACKSPACE' ],
expectedData: ( data ) => {
// remove the first list item, and replace its wrapped paragraph outside
// the start of the list
data.splice(
blocklength, 8,
{ type: 'paragraph' },
'F', 'o', 'o',
{ type: '/paragraph' },
{ type: 'list', attributes: { style: 'bullet' } }
);
},
expectedRangeOrSelection: new ve.Range( blocklength + 1 ),
msg: 'Backspace in a list next to a block image doesn\'t merge into the caption'
},
{
htmlOrDoc:
ve.dm.mwExample.MWBlockImage.html +
'<ul><li><p></p></li></ul>',
rangeOrSelection: new ve.Range( blocklength + 3 ),
keys: [ 'BACKSPACE' ],
expectedData: ( data ) => {
data.splice(
blocklength, 6,
{ type: 'paragraph' },
{ type: '/paragraph' }
);
},
expectedRangeOrSelection: new ve.Range( blocklength + 1 ),
msg: 'Backspace in an empty list next to a block image removes the list'
}
];
let promise = Promise.resolve();
cases.forEach( ( caseItem ) => {
promise = promise.then( () =>
ve.test.utils.runSurfaceHandleSpecialKeyTest( assert, caseItem )
);
} );
promise.finally( () => {
done();
} );
} );
QUnit.test( 'beforePaste/afterPaste', ( assert ) => {
const cases = [
{