This commit is contained in:
Raymond Hill 2018-03-27 19:10:31 -04:00
parent 222722caad
commit 782faf4f44
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
4 changed files with 33 additions and 0 deletions

View File

@ -42,6 +42,8 @@ var cmEditor = new CodeMirror(
}
);
uBlockDashboard.patchCodeMirrorEditor(cmEditor);
/******************************************************************************/
// This is to give a visual hint that the content of user blacklist has changed.

View File

@ -112,6 +112,33 @@ self.uBlockDashboard.dateNowToSensibleString = function() {
/******************************************************************************/
self.uBlockDashboard.patchCodeMirrorEditor = (function() {
// https://github.com/gorhill/uBlock/issues/3646
var patchSelectAll = function(cm, details) {
var vp = cm.getViewport();
if ( details.ranges.length !== 1 ) { return; }
var range = details.ranges[0],
lineFrom = range.anchor.line,
lineTo = range.head.line;
if ( range.head.ch !== 0 ) { lineTo += 1; }
if ( lineFrom !== vp.from || lineTo !== vp.to ) { return; }
details.update([
{
anchor: { line: 0, ch: 0 },
head: { line: cm.lineCount(), ch: 0 }
}
]);
};
return function(cm) {
if ( cm.options.inputStyle === 'contenteditable' ) {
cm.on('beforeSelectionChange', patchSelectAll);
}
};
})();
/******************************************************************************/
// Open links in the proper window
uDom('a').attr('target', '_blank');
uDom('a[href*="dashboard.html"]').attr('target', '_parent');

View File

@ -48,6 +48,8 @@ mergeView.editor().setOption('styleActiveLine', true);
mergeView.editor().setOption('lineNumbers', false);
mergeView.leftOriginal().setOption('readOnly', 'nocursor');
uBlockDashboard.patchCodeMirrorEditor(mergeView.editor());
var unfilteredRules = {
orig: { doc: mergeView.leftOriginal(), rules: [] },
edit: { doc: mergeView.editor(), rules: [] }

View File

@ -78,6 +78,8 @@ var cmEditor = new CodeMirror(
}
);
uBlockDashboard.patchCodeMirrorEditor(cmEditor);
/******************************************************************************/
var whitelistChanged = function() {