fix and simplify editDeleteText context menu
* enable it on inputs added by the user later * enable it in all of our pages
This commit is contained in:
parent
5253c863b9
commit
5529cbec2b
|
@ -32,7 +32,7 @@
|
|||
title: 'editDeleteText',
|
||||
type: 'normal',
|
||||
contexts: ['editable'],
|
||||
documentUrlPatterns: [URLS.ownOrigin + 'edit*'],
|
||||
documentUrlPatterns: [URLS.ownOrigin + '*'],
|
||||
click: (info, tab) => {
|
||||
msg.sendTab(tab.id, {method: 'editDeleteText'}, undefined, 'extension')
|
||||
.catch(msg.ignoreError);
|
||||
|
|
|
@ -79,9 +79,6 @@ msg.onExtension(request => {
|
|||
closeCurrentTab();
|
||||
}
|
||||
break;
|
||||
case 'editDeleteText':
|
||||
document.execCommand('delete');
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
/* global $ $$ $create $remove messageBoxProxy */// dom.js
|
||||
/* global $ $create $remove messageBoxProxy */// dom.js
|
||||
/* global API */// msg.js
|
||||
/* global CodeMirror */
|
||||
/* global FIREFOX RX_META debounce ignoreChromeError */// toolbox.js
|
||||
/* global RX_META debounce */// toolbox.js
|
||||
/* global MozDocMapper clipString helpPopup rerouteHotkeys showCodeMirrorPopup */// util.js
|
||||
/* global createSection */// sections-editor-section.js
|
||||
/* global editor */
|
||||
/* global linterMan */
|
||||
/* global prefs */
|
||||
/* global styleSectionsEqual */ // sections-util.js
|
||||
/* global t */// localization.js
|
||||
'use strict';
|
||||
|
@ -33,10 +32,6 @@ function SectionsEditor() {
|
|||
$('#from-mozilla').on('click', () => showMozillaFormatImport());
|
||||
document.on('wheel', scrollEntirePageOnCtrlShift, {passive: false});
|
||||
CodeMirror.defaults.extraKeys['Shift-Ctrl-Wheel'] = 'scrollWindow';
|
||||
if (!FIREFOX) {
|
||||
$$('input:not([type]), input[type=text], input[type=search], input[type=number]')
|
||||
.forEach(e => e.on('mousedown', toggleContextMenuDelete));
|
||||
}
|
||||
|
||||
/** @namespace Editor */
|
||||
Object.assign(editor, {
|
||||
|
@ -621,9 +616,6 @@ function SectionsEditor() {
|
|||
$('.move-section-down', el).onclick = () => moveSectionDown(section);
|
||||
$('.restore-section', el).onclick = () => restoreSection(section);
|
||||
cm.on('paste', maybeImportOnPaste);
|
||||
if (!FIREFOX) {
|
||||
cm.on('mousedown', (cm, event) => toggleContextMenuDelete.call(cm, event));
|
||||
}
|
||||
}
|
||||
|
||||
function maybeImportOnPaste(cm, event) {
|
||||
|
@ -668,15 +660,4 @@ function SectionsEditor() {
|
|||
linterMan.enableForEditor(cm);
|
||||
cm.refresh();
|
||||
}
|
||||
|
||||
function toggleContextMenuDelete(event) {
|
||||
if (chrome.contextMenus && event.button === 2 && prefs.get('editor.contextDelete')) {
|
||||
chrome.contextMenus.update('editor.contextDelete', {
|
||||
enabled: Boolean(
|
||||
this.selectionStart !== this.selectionEnd ||
|
||||
this.somethingSelected && this.somethingSelected()
|
||||
),
|
||||
}, ignoreChromeError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* global $$ $ $create focusAccessibility getEventKeyName moveFocus */// dom.js
|
||||
/* global clamp debounce */// toolbox.js
|
||||
/* global msg */
|
||||
/* global t */// localization.js
|
||||
'use strict';
|
||||
|
||||
|
@ -15,6 +16,11 @@
|
|||
window.on('wheel', changeFocusedInputOnWheel, {capture: true, passive: false});
|
||||
window.on('click', e => splitMenu(e) || showTooltipNote(e));
|
||||
window.on('resize', () => debounce(addTooltipsToEllipsized, 100));
|
||||
msg.onExtension(request => {
|
||||
if (request.method === 'editDeleteText') {
|
||||
document.execCommand('delete');
|
||||
}
|
||||
});
|
||||
// Removing transition-suppressor rule
|
||||
const {sheet} = $('link[href$="global.css"]');
|
||||
for (let i = 0, rule; (rule = sheet.cssRules[i]); i++) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user