Skip to content

Conversation

@mfainshtein4
Copy link

@mfainshtein4 mfainshtein4 commented Mar 27, 2017

implemented a check to see if browser supports these commands via queryCommandSupported if not display dialog which prompts users to use the native functionality for cut, copy, paste. The functionality also includes a check to see if the system is a mac and if so display command+c ..etc and if its not a mac, display Ctrl+c..etc.

fixes #451

Copy link

@humphd humphd left a comment

Choose a reason for hiding this comment

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

I've left some feedback. The entire thing needs to be fixed for indent issues: Brackets uses 4-space indents.

editor_cmenu.addMenuItem(Commands.TOGGLE_QUICK_EDIT);
editor_cmenu.addMenuItem(Commands.TOGGLE_QUICK_DOCS);
editor_cmenu.addMenuItem(Commands.EDIT_SELECT_ALL);
editor_cmenu.addMenuDivider();
Copy link

Choose a reason for hiding this comment

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

Indent issues here, please match surrounding code.

"edit.paste": [
"Ctrl-V"
],
"edit.selectAll": [
Copy link

Choose a reason for hiding this comment

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

So you're thinking to leave this one in? Probably that's OK, but let's make sure it always works in all browsers.

Copy link
Author

Choose a reason for hiding this comment

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

yup we will need to do some testing, see if it works on all operating systems

//e.pageY += 6;
}


Copy link

Choose a reason for hiding this comment

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

Is this change from the original Adobe commit? It seems odd to just have this comment block hanging there.

Strings = require("strings"),
Editor = require("editor/Editor").Editor,
CommandManager = require("command/CommandManager"),
Dialogs = require("widgets/Dialogs"),
Copy link

Choose a reason for hiding this comment

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

More indent issues here.

} else {
Dialogs.showModalDialogUsingTemplate(dialogTemplate);
return ignoreCommand;
}
Copy link

Choose a reason for hiding this comment

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

This pattern is wrong, here, and also in the code below. You need to always return a function from the anonymous function being run on line 1150. Basically, you are making _execCommandCut a function, but you won't know which one of the two possible options until run time when you check on the value of document.queryCommandSupported("cut").

It should be something like this:

var _execCommandCut = (function() {
    if(document.queryCommandSupported("cut")) {
        return function() {
            _execCommand("cut");
        };
    }

    return function() {
        Dialogs.showModalDialogUsingTemplate(dialogTemplate);
        return ignoreCommand();
    };
}());

}
}());

var _execCommandCopy = (function() {
Copy link

Choose a reason for hiding this comment

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

Same issue here.

}());

function _execCommandPaste(){
Dialogs.showModalDialogUsingTemplate(dialogTemplate);
Copy link

Choose a reason for hiding this comment

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

Indent issue.

Also, you need to add return ignoreCommand(); as well.

These actions are unavailable via the Edit menu, but you can still use:
</p>
<table class= "guide">
<script>
Copy link

Choose a reason for hiding this comment

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

You don't want to run a script in this dialog. Instead, you'll want to follow the pattern here:

https://github.com/adobe/brackets/blob/f028b3ecdf2017498196f39ddbbe4a2364366c92/src/help/HelpCommandHandlers.js#L81

Render variables into your template with Mustache.

Copy link
Author

Choose a reason for hiding this comment

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

I made the changes to implement mustache to pass the variables in, but when I pass in the unicode for the Command key it displays the code rather than the character. Is there a word around for this or do I change it to Command+C for example?

@@ -0,0 +1,51 @@
<div id="myModal" class="modal">
Copy link

Choose a reason for hiding this comment

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

Can you put a screenshot of this in your PR so @flukeout can review the UI as well?

Copy link
Author

Choose a reason for hiding this comment

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

current
@flukeout it currently looks like this.

Copy link

Choose a reason for hiding this comment

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

@flukeout we need a UI review from you on this change.

@Pomax Pomax changed the title Issue 451 Explain available copy/cut/paste options better Mar 27, 2017
Editor = require("editor/Editor").Editor,
CommandManager = require("command/CommandManager"),
Dialogs = require("widgets/Dialogs"),
Dialogs = require("widgets/Dialogs"),
Copy link

Choose a reason for hiding this comment

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

this still uses a tab. Please set your code editor to use spaces for tabs in this file. If you do a text selection on any of the lines above/below you'll see that it's indentation that purely uses spaces, unlike your line here, which uses a tab

@Pomax
Copy link

Pomax commented Mar 28, 2017

@mfainshtein4 can you make sure to run npm test before you push up a commit? Right now your code has some linting issues that makes the automated-tester fail, which you can catch by running npm test on your own machine and making sure that your code does not fail that, before pushing it up.

@humphd
Copy link

humphd commented Mar 29, 2017

Looks like a missing semicolon:

Running "eslint:src" (eslint) task
/home/travis/build/mozilla/brackets/src/editor/EditorCommandHandlers.js

  1173:10  error  Missing semicolon  semi

✖ 1 problem (1 error, 0 warnings)

@Pomax is right, just like with our lab last week, you can do your testing with eslint locally using npm test without having to actually push broken commits. It's good to get things passing locally so you don't waste cycles on travis, or spam people with github notifications for broken builds.

"edit.paste": [
"Ctrl-V"
],
"edit.selectAll": [
Copy link
Author

Choose a reason for hiding this comment

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

yup we will need to do some testing, see if it works on all operating systems

These actions are unavailable via the Edit menu, but you can still use:
</p>
<table class= "guide">
<script>
Copy link
Author

Choose a reason for hiding this comment

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

I made the changes to implement mustache to pass the variables in, but when I pass in the unicode for the Command key it displays the code rather than the character. Is there a word around for this or do I change it to Command+C for example?

if(true){
if(navigator.platform.indexOf("Mac") !== -1;){
commandKey = {
COMMAND_KEY: "&#8984"
Copy link
Author

Choose a reason for hiding this comment

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

@humphd This was the code I mentioned in the email. Where the Unicode doesn't display the Command symbol.

Copy link
Author

Choose a reason for hiding this comment

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

ignore the semicolon I will remove that..

Copy link

Choose a reason for hiding this comment

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

I see in the Mustache docs the following: "All variables are HTML-escaped by default. If you want to render unescaped HTML, use the triple mustache: {{{name}}}. You can also use & to unescape a variable."

<table class= "guide">
<tr>
<th>
{{COMMAND_KEY}}+X
Copy link

Choose a reason for hiding this comment

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

Try making these {{{COMMAND_KEY}}} (3 mustaches).

}

table.guide {
width: 100%;
Copy link

Choose a reason for hiding this comment

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

Your indents are all too far in this file. 4-space indent please, match to surrounding code.

editor_cmenu.addMenuItem(Commands.EDIT_COPY);
editor_cmenu.addMenuItem(Commands.EDIT_PASTE);
editor_cmenu.addMenuDivider();
editor_cmenu.addMenuDivider();
Copy link

Choose a reason for hiding this comment

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

Please use the correct indentation, and please make sure to run npm test before committing code, because npm test will inform you of these easy to catch errors. They should not show up in a pushed commit


return result.promise();
}
<<<<<<< HEAD
Copy link

Choose a reason for hiding this comment

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

this is a file with merge conflict code in. Please fix your commits first, and verify that your npm test and npm run build work. There is no way this file works.

Copy link

@Pomax Pomax left a comment

Choose a reason for hiding this comment

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

and as uncommentable issue: was there a reason to update the path-utils submodule?

// editor_cmenu.addMenuItem(Commands.NAVIGATE_JUMPTO_DEFINITION);
editor_cmenu.addMenuItem(Commands.TOGGLE_QUICK_EDIT);
editor_cmenu.addMenuItem(Commands.TOGGLE_QUICK_DOCS);
editor_cmenu.addMenuDivider();
Copy link

Choose a reason for hiding this comment

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

please run npm test before you push changes, as that will tell you that your indentation here needs fixing.

Copy link
Author

Choose a reason for hiding this comment

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

when I run npm test it doesn't say anything is wrong? why could this be?

Copy link

Choose a reason for hiding this comment

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

I don't think the Brackets code does much in the way of lint-format checks.


function _execCommand(cmd) {
window.document.execCommand(cmd);
}
Copy link

Choose a reason for hiding this comment

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

indentation

Copy link

@humphd humphd left a comment

Choose a reason for hiding this comment

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

This is looking really close to me. Let's get the last bits of what I suggested fixed, and we need to deal with any UI reviews from @flukeout. Also, you have some changes in here that are unrelated to your patch (e.g., path-utils), and probably need to git submodule update --init to revert.

_ = require("thirdparty/lodash");


var commandKey = {
Copy link

Choose a reason for hiding this comment

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

var commandKey;
if(brackets.platform === "mac") {
    commandKey = ...;
} else {
    commandKey = ...;
}

};
}());

function _execCommandPaste(){
Copy link

Choose a reason for hiding this comment

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

Add a comment above this indicating that we ignore the value of document.queryCommandSupported("paste"), because browsers don't honour it due to security concerns.

@@ -0,0 +1,51 @@
<div id="myModal" class="modal">
Copy link

Choose a reason for hiding this comment

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

@flukeout we need a UI review from you on this change.

position: relative;
}

.CodeMirror-foldgutter:after {
Copy link

Choose a reason for hiding this comment

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

Why this change?

Copy link
Author

Choose a reason for hiding this comment

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

During a merge conflict I just appended it under my stuff. I wasn't sure what its used for. So I kept it there.

@Pomax Pomax requested a review from flukeout April 6, 2017 20:43
@flukeout
Copy link

flukeout commented Apr 6, 2017

Testing this out now.

@flukeout
Copy link

flukeout commented Apr 7, 2017

@mfainshtein4 how do I get this UI to show up in my local environment? I guess my browsers support the operation, but is there something I can change to preview the popup? Let me know, thanks!

@flukeout
Copy link

flukeout commented Apr 7, 2017

Nevermind @mfainshtein4 - I got it to show up when I use the "Paste" action. However, on my mac, it looks like the key type (Command) is missing from the instructions...

image

@humphd
Copy link

humphd commented Apr 8, 2017

@mfainshtein4 is this ready for review again? When it is, use @ and our names to make sure we see this.

@mfainshtein4
Copy link
Author

mfainshtein4 commented Apr 8, 2017

@Pomax , @humphd , @flukeout I am ready for another review.

@humphd
Copy link

humphd commented Apr 10, 2017

Code looks good. @flukeout this needs your UI review/suggestions/testing, then I think it's done.

@flukeout
Copy link

Checking in on the latest changes now.

@flukeout
Copy link

@humphd Please merge it! I have some minor suggestions but I'll make those as a separate PR.

@mfainshtein4 - thank you so much for this work! 👍

@humphd humphd merged commit 1dcac9a into mozilla:master Apr 10, 2017
@humphd
Copy link

humphd commented Apr 10, 2017

A long road, but we finally made it. I've tested locally, and this is working great. Thanks for sticking it out, @mfainshtein4, this is a good fix.

@mfainshtein4
Copy link
Author

@humphd Thanks. I appreciate the constant support and pokes in the right direction!

@humphd humphd mentioned this pull request Apr 10, 2017
timmoy pushed a commit to timmoy/brackets that referenced this pull request Apr 19, 2017
timmoy pushed a commit to timmoy/brackets that referenced this pull request Apr 20, 2017
Rajat-dhyani pushed a commit to Rajat-dhyani/brackets that referenced this pull request Apr 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

can't "copy", "cut", or "paste" via the context menu

4 participants