Page MenuHomePhabricator

Make Linter edit helper compatible with VisualEditor
Closed, ResolvedPublic1 Estimated Story Points

Description

Right now Linter has some very basic code to highlight the spot of specific errors: https://phabricator.wikimedia.org/source/mediawiki-extensions-Linter/browse/master/modules/ext.linter.edit.js however this isn't compatible with VisualEditor.

Somehow we should have the &lintId= parameter always force the new source editor (or old source editor) instead of VE and then have our highlighting system work.

Event Timeline

@Esanders any ideas/suggestions on how to make this work for NWE?

ve.init.target.getSurface().getModel().setLinearSelection( new ve.Range( start, end ) )

sets a selection in NWE. The indices are a bit different, though, as the document starts with a <p> tag that counts as 1, and each linebreak is represented by </p><p> increasing the index by 2 instead of 1.

Yeah, for now you would just have to count newlines up to an offset to convert indicies:

function getModelOffsetFromWikitextOffset( offset ) {
    return ( ve.init.target.getSurface().getDom().slice( 0, offset ).match( /\n/g ) || [] ).length   1   offset;
}

I'm not aware of other users' need for this so I couldn't say if it's worth us coming up with a better solution yet.

Change 342279 had a related patch set uploaded (by Legoktm):
[mediawiki/extensions/Linter] Support new wikitext editor for edit helper

https://gerrit.wikimedia.org/r/342279

Thanks for the help so far - I got most of it working except the highlight flashes and then immediately goes away. :(

Change 342915 had a related patch set uploaded (by Jforrester):
[mediawiki/extensions/VisualEditor] Don't load VE or NWE on lint-targetted pages (until that works)

https://gerrit.wikimedia.org/r/342915

Change 342915 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor] Don't load VE or NWE on lint-targetted pages (until that works)

https://gerrit.wikimedia.org/r/342915

Change 342279 merged by jenkins-bot:
[mediawiki/extensions/Linter@master] Support new wikitext editor for edit helper

https://gerrit.wikimedia.org/r/342279

I guess this is just a first attempt but you could easily load all the lint errors for a particular page instead of just one, and let the user scroll through them like findAndReplace results.

Change 350313 had a related patch set uploaded (by Jforrester; owner: Jforrester):
[mediawiki/extensions/VisualEditor@master] Un-blacklist the lintid parameter

https://gerrit.wikimedia.org/r/350313

Change 350313 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] Un-blacklist the lintid parameter

https://gerrit.wikimedia.org/r/350313

Jdforrester-WMF claimed this task.
Jdforrester-WMF set the point value for this task to 1.