Merge "Allow multiple highlight fragments to be passed to an edit check"

This commit is contained in:
jenkins-bot 2024-11-06 05:28:42 +00:00 committed by Gerrit Code Review
commit dd56e0c226
7 changed files with 15 additions and 11 deletions

View file

@ -13,7 +13,7 @@ mw.editcheck.AddReferenceEditCheck.prototype.onBeforeSave = function ( surfaceMo
return this.findAddedContent( surfaceModel.getDocument() ).map( ( range ) => {
const fragment = surfaceModel.getLinearFragment( range );
return new mw.editcheck.EditCheckAction( {
highlight: fragment,
highlights: [ fragment ],
selection: this.adjustForPunctuation( fragment.collapseToEnd() ),
check: this
} );
@ -83,7 +83,7 @@ mw.editcheck.AddReferenceEditCheck.prototype.act = function ( choice, action, co
return windowAction.open(
'editCheckReferencesInspector',
{
fragment: action.highlight,
fragment: action.highlights[ 0 ],
callback: contextItem.data.callback,
saveProcessDeferred: contextItem.data.saveProcessDeferred
}

View file

@ -22,7 +22,7 @@ mw.editcheck.ConvertReferenceEditCheck.prototype.onDocumentChange = function ( s
if ( href ) {
const fragment = surfaceModel().getLinearFragment( node.getOuterRange() );
return new mw.editcheck.EditCheckAction( {
highlight: fragment,
highlights: [ fragment ],
selection: fragment,
message: ve.msg( 'citoid-referencecontextitem-convert-message' ),
check: this

View file

@ -1,6 +1,6 @@
mw.editcheck.EditCheckAction = function MWEditCheckAction( config ) {
this.check = config.check;
this.highlight = config.highlight;
this.highlights = config.highlights;
this.selection = config.selection;
this.message = config.message;
};

View file

@ -60,7 +60,9 @@ ve.ui.EditCheckDialog.prototype.update = function () {
label: check.message,
framed: false
} ).$element );
selections.push( ve.ce.Selection.static.newFromModel( check.highlight.getSelection(), surfaceView ) );
check.highlights.forEach( ( highlight ) => {
selections.push( ve.ce.Selection.static.newFromModel( highlight.getSelection(), surfaceView ) );
} );
} );
surfaceView.getSelectionManager().drawSelections( 'editCheckWarning', selections );
this.$body.empty().append( $checks );

View file

@ -66,7 +66,7 @@ mw.editcheck.EditCheckFactory.prototype.createAllByListener = function ( listene
}
} );
newChecks.sort(
( a, b ) => a.highlight.getSelection().getCoveringRange().start - b.highlight.getSelection().getCoveringRange().start
( a, b ) => a.highlights[ 0 ].getSelection().getCoveringRange().start - b.highlights[ 0 ].getSelection().getCoveringRange().start
);
return newChecks;
};

View file

@ -22,7 +22,7 @@ mw.editcheck.TextMatchEditCheck.prototype.onDocumentChange = function ( surfaceM
const fragment = surfaceModel.getLinearFragment( range );
actions.push(
new mw.editcheck.EditCheckAction( {
highlight: fragment,
highlights: [ fragment ],
selection: fragment,
message: replacer.message,
check: this

View file

@ -204,9 +204,11 @@ if ( mw.config.get( 'wgVisualEditorConfig' ).editCheck || mw.editcheck.ecenable
const highlightNodes = [];
const selections = [];
checks.forEach( ( check ) => {
highlightNodes.push.apply( highlightNodes, surfaceView.getDocument().selectNodes( check.highlight.getSelection().getCoveringRange(), 'branches' ).map( ( spec ) => spec.node ) );
const selection = ve.ce.Selection.static.newFromModel( check.highlight.getSelection(), surfaceView );
selections.push( selection );
check.highlights.forEach( ( highlight ) => {
highlightNodes.push.apply( highlightNodes, surfaceView.getDocument().selectNodes( highlight.getSelection().getCoveringRange(), 'branches' ).map( ( spec ) => spec.node ) );
const selection = ve.ce.Selection.static.newFromModel( highlight.getSelection(), surfaceView );
selections.push( selection );
} );
} );
// TODO: Make selections clickable when multicheck is enabled
surfaceView.getSelectionManager().drawSelections(
@ -250,7 +252,7 @@ if ( mw.config.get( 'wgVisualEditorConfig' ).editCheck || mw.editcheck.ecenable
// eslint-disable-next-line no-inner-declarations
function showCheckContext( check ) {
const fragment = check.highlight;
const fragment = check.highlights[ 0 ];
// Select the found content to correctly position the context on desktop
fragment.select();