Use new select[First|Last]SelectableContentOffset methods

* Make ve.ce.MWBlockImageNode autofocus=false, remove
  unused transition property
* Remove ignoreChildren from ve.dm.MWBlockImageNode
  based on new definition
* Remove tests which assert that deleting in a list next
  to a block image always de-indents. If this is desired
  behaviour it should be fixed without reference to
  ignoreChildren.

Bug: T295905
Depends-On: Idc0cccbe73d1b49d07b60c14a192a40f47d64608
Change-Id: Ib79a070f5d36dbe7742fa0760f8cdf55fe3046ed
This commit is contained in:
Ed Sanders 2021-11-27 00:38:54 +00:00 committed by Bartosz Dziewoński
parent cddd97023d
commit 5c0344aeda
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 = [
{