mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-23 14:06:52 +00:00
Merge "Allow multiple highlight fragments to be passed to an edit check"
This commit is contained in:
commit
dd56e0c226
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue