From 5529cbec2bcc8148ef79d37e00ccaa800098c704 Mon Sep 17 00:00:00 2001
From: tophf
Date: Fri, 28 Jan 2022 03:11:25 +0300
Subject: [PATCH 1/2] fix and simplify editDeleteText context menu
* enable it on inputs added by the user later
* enable it in all of our pages
---
background/context-menus.js | 2 +-
edit/edit.js | 3 ---
edit/sections-editor.js | 23 ++---------------------
js/dom-on-load.js | 6 ++++++
4 files changed, 9 insertions(+), 25 deletions(-)
diff --git a/background/context-menus.js b/background/context-menus.js
index e0c50143..430f6216 100644
--- a/background/context-menus.js
+++ b/background/context-menus.js
@@ -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);
diff --git a/edit/edit.js b/edit/edit.js
index 3790da3b..64e5c0ea 100644
--- a/edit/edit.js
+++ b/edit/edit.js
@@ -79,9 +79,6 @@ msg.onExtension(request => {
closeCurrentTab();
}
break;
- case 'editDeleteText':
- document.execCommand('delete');
- break;
}
});
diff --git a/edit/sections-editor.js b/edit/sections-editor.js
index c77be6df..6a35782b 100644
--- a/edit/sections-editor.js
+++ b/edit/sections-editor.js
@@ -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);
- }
- }
}
diff --git a/js/dom-on-load.js b/js/dom-on-load.js
index 58778d8a..3ba84ca7 100644
--- a/js/dom-on-load.js
+++ b/js/dom-on-load.js
@@ -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++) {
From f9e11f5806470c6b0050c39488b0a41b107f7c59 Mon Sep 17 00:00:00 2001
From: tophf
Date: Fri, 28 Jan 2022 15:52:55 +0300
Subject: [PATCH 2/2] align 'Applies-to' and actions (#1392)
---
edit.html | 2 +-
edit/edit.css | 55 +++++++++++++++++++--------------
edit/sections-editor-section.js | 9 ++++--
edit/sections-editor.js | 1 -
edit/settings.css | 2 +-
global.css | 14 ++++++---
js/dlg/config-dialog.css | 4 +--
7 files changed, 51 insertions(+), 36 deletions(-)
diff --git a/edit.html b/edit.html
index 8907cd5b..4187c37f 100644
--- a/edit.html
+++ b/edit.html
@@ -102,7 +102,7 @@
-