mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-02 09:09:38 +02:00
fix #3646
This commit is contained in:
parent
222722caad
commit
782faf4f44
@ -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.
|
||||
|
@ -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');
|
||||
|
@ -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: [] }
|
||||
|
@ -78,6 +78,8 @@ var cmEditor = new CodeMirror(
|
||||
}
|
||||
);
|
||||
|
||||
uBlockDashboard.patchCodeMirrorEditor(cmEditor);
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
var whitelistChanged = function() {
|
||||
|
Loading…
Reference in New Issue
Block a user