mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-03 02:16:51 +00:00
(bug 42655) Fix - it might be not the long-term solution - but works for now.
Change-Id: I3165654afb4bf9203cd746ed8af241168d5946a0
This commit is contained in:
parent
4415aabe22
commit
9b70ffba9c
|
@ -166,7 +166,7 @@ ve.ce.Surface.prototype.handleInsertion = function () {
|
||||||
*/
|
*/
|
||||||
ve.ce.Surface.prototype.onContentChange = function ( node, previous, next ) {
|
ve.ce.Surface.prototype.onContentChange = function ( node, previous, next ) {
|
||||||
var data, range, len, annotations, offsetDiff, lengthDiff, sameLeadingAndTrailing,
|
var data, range, len, annotations, offsetDiff, lengthDiff, sameLeadingAndTrailing,
|
||||||
previousStart, nextStart,
|
previousStart, nextStart, newRange,
|
||||||
fromLeft = 0,
|
fromLeft = 0,
|
||||||
fromRight = 0,
|
fromRight = 0,
|
||||||
nodeOffset = node.getModel().getOffset();
|
nodeOffset = node.getModel().getOffset();
|
||||||
|
@ -259,12 +259,16 @@ ve.ce.Surface.prototype.onContentChange = function ( node, previous, next ) {
|
||||||
if ( annotations.getLength() ) {
|
if ( annotations.getLength() ) {
|
||||||
ve.dm.Document.addAnnotationsToData( data, annotations );
|
ve.dm.Document.addAnnotationsToData( data, annotations );
|
||||||
}
|
}
|
||||||
|
newRange = next.range;
|
||||||
|
if ( newRange.isCollapsed() ) {
|
||||||
|
newRange = new ve.Range( this.getNearestCorrectOffset( newRange.start, 1 ) );
|
||||||
|
}
|
||||||
if ( data.length > 0 ) {
|
if ( data.length > 0 ) {
|
||||||
this.model.change(
|
this.model.change(
|
||||||
ve.dm.Transaction.newFromInsertion(
|
ve.dm.Transaction.newFromInsertion(
|
||||||
this.documentView.model, nodeOffset + 1 + fromLeft, data
|
this.documentView.model, nodeOffset + 1 + fromLeft, data
|
||||||
),
|
),
|
||||||
next.range
|
newRange
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ( fromLeft + fromRight < previous.text.length ) {
|
if ( fromLeft + fromRight < previous.text.length ) {
|
||||||
|
@ -276,7 +280,7 @@ ve.ce.Surface.prototype.onContentChange = function ( node, previous, next ) {
|
||||||
data.length + nodeOffset + 1 + previous.text.length - fromRight
|
data.length + nodeOffset + 1 + previous.text.length - fromRight
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
next.range
|
newRange
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue