-
Notifications
You must be signed in to change notification settings - Fork 3
Add Edit commands #3
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following should be moved to the content script file at content/content.js
.
Also, the Edit menu is already handled by the content script, it’s just that opening a browser action popup menu defocuses any element in the page, which makes the Edit menu not work.
src/background.js
Outdated
range.selectNodeContents(document.documentElement); | ||
selection.removeAllRanges(); | ||
selection.addRange(range); | ||
})();` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
src/background.js
Outdated
} case "editPaste": { | ||
return browser.tabs.executeScript({ | ||
code: "document.execCommand('paste');" | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
src/background.js
Outdated
} case "editCopy": { | ||
return browser.tabs.executeScript({ | ||
code: "document.execCommand('copy');" | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
src/background.js
Outdated
} case "editCut": { | ||
return browser.tabs.executeScript({ | ||
code: "document.execCommand('cut');" | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be moved to the content script.
src/background.js
Outdated
browser.windows.update(browser.windows.WINDOW_ID_CURRENT, { | ||
state: win.state === "fullscreen" ? "normal" : "fullscreen" | ||
}) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we use await
here instead of Promise.then()
.
@ExE-Boss Thanks for reviewing and merging the other PR! I have a working version of edit commands locally that even works with inputs. I just have to fix selectAll to work more reliably, then everything should be fine :) |
@ExE-Boss Updated the PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, this still doesn’t work for me (I use the web-ext
command for testing).
@ExE-Boss Seems to work on macOS (I also use the web-ext command). Which commands have you tried ? |
@ExE-Boss I've updated the Pull request.
Let me know if you have issues with it. |
} case "editSelectAll": { | ||
return document.execCommand("selectAll"); | ||
// Select all doesn't work reliably on inputs yet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: This comment needs to updated, select all works properly on inputs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still some issues left to address (and updated to commit ad96f85
).
} else if (isFocusable) { | ||
result.enable.push("editCut", "editCopy", "editSelectAll"); | ||
} else { | ||
result.enable.push("editCopy", "editSelectAll"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy is still broken in this context on Windows. That’s why I implemented commit ad96f85
, so that this can be disabled on Windows and enabled on MacOS.
Do note that I only tested this on Stable and Developer Edition, but not on Nightly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use Nightly, which may have a different behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, actually, it doesn't work for me either in this context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it does work, it seems like your latest commit breaks this though.
@@ -44,13 +44,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
<div class="panel-section"> | |||
<i class="eb-icon-placeholder"/> | |||
<i class="panel-list-item text" data-i18n="popup_edit"/> | |||
<div class="panel-list-item icon" data-ipc-message="editCut" data-remain-open="true"> | |||
<div class="panel-list-item icon" data-ipc-message="editCut"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data-remain-open="true"
is needed here to accurately implement how the Application Menu worked in Firefox 4-28 and CTR for FF 29-56.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't work with data-remain-open=true
<i class="eb-icon-placeholder" data-icon="clipboard-cut"/> | ||
</div> | ||
<div class="panel-list-item icon" data-ipc-message="editCopy" data-remain-open="true"> | ||
<div class="panel-list-item icon" data-ipc-message="editCopy"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
<i class="eb-icon-placeholder" data-icon="clipboard-copy"/> | ||
</div> | ||
<div class="panel-list-item icon" data-ipc-message="editPaste" data-remain-open="true"> | ||
<div class="panel-list-item icon" data-ipc-message="editPaste"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
@@ -113,7 +113,6 @@ async function handlePopupMessage(message) { | |||
let result = { | |||
disable: [ | |||
"*", | |||
"edit*", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should stay here, because it ensures that the edit menu isn’t enabled when the content script can’t start (i.e. the page is privileged (about:
, chrome://
or resource://
)).
Yes, I do realize that this is contained in the *
selector above, but that one will be removed once the menu is fully implemented, while the edit*
selector and any other selector dependant on the content script will be kept.
@ExE-Boss Your latest commit about platform info breaks pretty much all content commands. Platform info is only passed for the init method, so the content script will throw for other commands |
@nt1m I have now pushed commit |
a26c7b2
to
7efa1d7
Compare
82a52cb
to
6d89fee
Compare
No description provided.