mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-25 11:16:51 +00:00
When annotating, skip any branch nodes that are content
We don't have these yet, but when we do, we'll need this Change-Id: I1c2572f00fc0b9a144bb4092a44cd5af2bb752da
This commit is contained in:
parent
f8d81c66b6
commit
c77ffee98c
|
@ -208,20 +208,30 @@ ve.dm.Transaction.newFromAnnotation = function ( doc, range, method, annotation
|
||||||
data = doc.data,
|
data = doc.data,
|
||||||
i = range.start,
|
i = range.start,
|
||||||
span = i,
|
span = i,
|
||||||
on = false;
|
on = false,
|
||||||
|
insideContentNode = false;
|
||||||
// Iterate over all data in range, annotating where appropriate
|
// Iterate over all data in range, annotating where appropriate
|
||||||
while ( i < range.end ) {
|
while ( i < range.end ) {
|
||||||
type = data.getType( i );
|
type = data.getType( i );
|
||||||
if ( data.isElementData( i ) && !ve.dm.nodeFactory.isNodeContent( type ) ) {
|
if (
|
||||||
// Structural element opening or closing
|
( data.isElementData( i ) && !ve.dm.nodeFactory.isNodeContent( type ) ) ||
|
||||||
|
( insideContentNode && !data.isCloseElementData( i ) )
|
||||||
|
) {
|
||||||
|
// Structural element opening or closing, or entering a content node
|
||||||
if ( on ) {
|
if ( on ) {
|
||||||
tx.pushRetain( span );
|
tx.pushRetain( span );
|
||||||
tx.pushStopAnnotating( method, annotation );
|
tx.pushStopAnnotating( method, annotation );
|
||||||
span = 0;
|
span = 0;
|
||||||
on = false;
|
on = false;
|
||||||
}
|
}
|
||||||
} else if ( !data.isElementData( i ) || !data.isCloseElementData( i ) ) {
|
} else if (
|
||||||
|
( !data.isElementData( i ) || !data.isCloseElementData( i ) ) &&
|
||||||
|
!insideContentNode
|
||||||
|
) {
|
||||||
// Character or content element opening
|
// Character or content element opening
|
||||||
|
if ( data.isElementData( i ) ) {
|
||||||
|
insideContentNode = true;
|
||||||
|
}
|
||||||
covered = data.getAnnotationsFromOffset( i ).contains( annotation );
|
covered = data.getAnnotationsFromOffset( i ).contains( annotation );
|
||||||
if ( ( covered && method === 'set' ) || ( !covered && method === 'clear' ) ) {
|
if ( ( covered && method === 'set' ) || ( !covered && method === 'clear' ) ) {
|
||||||
// Skip annotated content
|
// Skip annotated content
|
||||||
|
@ -240,7 +250,10 @@ ve.dm.Transaction.newFromAnnotation = function ( doc, range, method, annotation
|
||||||
on = true;
|
on = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // otherwise it's a content closing, skip those
|
} else if ( data.isCloseElementData( i ) ) {
|
||||||
|
// Content closing, skip
|
||||||
|
insideContentNode = false;
|
||||||
|
}
|
||||||
span++;
|
span++;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue