Skip to content
This repository has been archived by the owner on Aug 27, 2019. It is now read-only.

Add Edit commands #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add Edit commands #3

wants to merge 1 commit into from

Conversation

nt1m
Copy link
Contributor

@nt1m nt1m commented Aug 20, 2017

No description provided.

Copy link
Member

@ExE-Boss ExE-Boss left a 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.

range.selectNodeContents(document.documentElement);
selection.removeAllRanges();
selection.addRange(range);
})();`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

} case "editPaste": {
return browser.tabs.executeScript({
code: "document.execCommand('paste');"
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

} case "editCopy": {
return browser.tabs.executeScript({
code: "document.execCommand('copy');"
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

} case "editCut": {
return browser.tabs.executeScript({
code: "document.execCommand('cut');"
});
Copy link
Member

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.

browser.windows.update(browser.windows.WINDOW_ID_CURRENT, {
state: win.state === "fullscreen" ? "normal" : "fullscreen"
})
);
Copy link
Member

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 added a commit that referenced this pull request Aug 20, 2017
  Thanks to @nt1m for figuring out how to implement this using
the `browser.windows` API in pull request #3.

# TODO:
- Make the Fullscreen icon dynamic in the Photon theme.
@nt1m
Copy link
Contributor Author

nt1m commented Aug 20, 2017

@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 :)

@nt1m nt1m changed the title Add Edit and Fullscreen commands Add Edit commands Aug 20, 2017
@nt1m
Copy link
Contributor Author

nt1m commented Aug 20, 2017

@ExE-Boss Updated the PR

Copy link
Member

@ExE-Boss ExE-Boss left a 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).

@nt1m
Copy link
Contributor Author

nt1m commented Aug 20, 2017

@ExE-Boss Seems to work on macOS (I also use the web-ext command). Which commands have you tried ?

@nt1m
Copy link
Contributor Author

nt1m commented Aug 21, 2017

@ExE-Boss I've updated the Pull request.

  • Cut works on all inputs.
  • Copy works everywhere
  • Paste, Undo, Redo, Delete only work on contentEditable fields (Firefox limitation)
  • Select all works everywhere

Let me know if you have issues with it.

} case "editSelectAll": {
return document.execCommand("selectAll");
// Select all doesn't work reliably on inputs yet
Copy link
Contributor Author

@nt1m nt1m Aug 21, 2017

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.

Copy link
Member

@ExE-Boss ExE-Boss left a 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");
Copy link
Member

@ExE-Boss ExE-Boss Aug 21, 2017

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

@nt1m nt1m Aug 21, 2017

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.

Copy link
Contributor Author

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">
Copy link
Member

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.

Copy link
Contributor Author

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">
Copy link
Member

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">
Copy link
Member

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*",
Copy link
Member

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.

@nt1m
Copy link
Contributor Author

nt1m commented Aug 21, 2017

@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

@ExE-Boss
Copy link
Member

@nt1m I have now pushed commit c7f6d5a, which should resolve this.

@ExE-Boss ExE-Boss force-pushed the master branch 2 times, most recently from a26c7b2 to 7efa1d7 Compare September 16, 2017 22:15
@ExE-Boss ExE-Boss force-pushed the master branch 2 times, most recently from 82a52cb to 6d89fee Compare October 5, 2017 20:16
@ExE-Boss ExE-Boss added status: in progress 🐌 Pull requests that are not yet ready to be merged and issues that are being worked on. needs: rebase 🚧 This PR needs to resolve a merge conflict labels May 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: rebase 🚧 This PR needs to resolve a merge conflict status: in progress 🐌 Pull requests that are not yet ready to be merged and issues that are being worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants