mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Merge "Use new select[First|Last]SelectableContentOffset methods"
This commit is contained in:
commit
abc7a7d4b6
|
@ -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 ) {
|
||||
|
|
|
@ -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: {
|
||||
|
|
|
@ -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' ];
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 = [
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue