-
Notifications
You must be signed in to change notification settings - Fork 281
Explain available copy/cut/paste options better #666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
humphd
left a comment
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've left some feedback. The entire thing needs to be fixed for indent issues: Brackets uses 4-space indents.
src/command/DefaultMenus.js
Outdated
| editor_cmenu.addMenuItem(Commands.TOGGLE_QUICK_EDIT); | ||
| editor_cmenu.addMenuItem(Commands.TOGGLE_QUICK_DOCS); | ||
| editor_cmenu.addMenuItem(Commands.EDIT_SELECT_ALL); | ||
| editor_cmenu.addMenuDivider(); |
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.
Indent issues here, please match surrounding code.
| "edit.paste": [ | ||
| "Ctrl-V" | ||
| ], | ||
| "edit.selectAll": [ |
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.
So you're thinking to leave this one in? Probably that's OK, but let's make sure it always works in all browsers.
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.
yup we will need to do some testing, see if it works on all operating systems
src/command/DefaultMenus.js
Outdated
| //e.pageY += 6; | ||
| } | ||
|
|
||
|
|
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.
Is this change from the original Adobe commit? It seems odd to just have this comment block hanging there.
src/editor/EditorCommandHandlers.js
Outdated
| Strings = require("strings"), | ||
| Editor = require("editor/Editor").Editor, | ||
| CommandManager = require("command/CommandManager"), | ||
| Dialogs = require("widgets/Dialogs"), |
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.
More indent issues here.
src/editor/EditorCommandHandlers.js
Outdated
| } else { | ||
| Dialogs.showModalDialogUsingTemplate(dialogTemplate); | ||
| return ignoreCommand; | ||
| } |
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 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();
};
}());
src/editor/EditorCommandHandlers.js
Outdated
| } | ||
| }()); | ||
|
|
||
| var _execCommandCopy = (function() { |
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.
Same issue here.
src/editor/EditorCommandHandlers.js
Outdated
| }()); | ||
|
|
||
| function _execCommandPaste(){ | ||
| Dialogs.showModalDialogUsingTemplate(dialogTemplate); |
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.
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> |
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.
You don't want to run a script in this dialog. Instead, you'll want to follow the pattern here:
Render variables into your template with Mustache.
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 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"> | |||
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.
Can you put a screenshot of this in your PR so @flukeout can review the UI as well?
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.

@flukeout it currently looks like this.
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.
@flukeout we need a UI review from you on this change.
src/editor/EditorCommandHandlers.js
Outdated
| Editor = require("editor/Editor").Editor, | ||
| CommandManager = require("command/CommandManager"), | ||
| Dialogs = require("widgets/Dialogs"), | ||
| Dialogs = require("widgets/Dialogs"), |
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 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
|
@mfainshtein4 can you make sure to run |
|
Looks like a missing semicolon: @Pomax is right, just like with our lab last week, you can do your testing with |
| "edit.paste": [ | ||
| "Ctrl-V" | ||
| ], | ||
| "edit.selectAll": [ |
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.
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> |
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 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?
src/editor/EditorCommandHandlers.js
Outdated
| if(true){ | ||
| if(navigator.platform.indexOf("Mac") !== -1;){ | ||
| commandKey = { | ||
| COMMAND_KEY: "⌘" |
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.
@humphd This was the code I mentioned in the email. Where the Unicode doesn't display the Command symbol.
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.
ignore the semicolon I will remove that..
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 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 |
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.
Try making these {{{COMMAND_KEY}}} (3 mustaches).
src/styles/bramble_overrides.css
Outdated
| } | ||
|
|
||
| table.guide { | ||
| width: 100%; |
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.
Your indents are all too far in this file. 4-space indent please, match to surrounding code.
src/command/DefaultMenus.js
Outdated
| editor_cmenu.addMenuItem(Commands.EDIT_COPY); | ||
| editor_cmenu.addMenuItem(Commands.EDIT_PASTE); | ||
| editor_cmenu.addMenuDivider(); | ||
| editor_cmenu.addMenuDivider(); |
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.
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
src/editor/EditorCommandHandlers.js
Outdated
|
|
||
| return result.promise(); | ||
| } | ||
| <<<<<<< HEAD |
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 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.
Pomax
left a comment
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.
and as uncommentable issue: was there a reason to update the path-utils submodule?
src/command/DefaultMenus.js
Outdated
| // editor_cmenu.addMenuItem(Commands.NAVIGATE_JUMPTO_DEFINITION); | ||
| editor_cmenu.addMenuItem(Commands.TOGGLE_QUICK_EDIT); | ||
| editor_cmenu.addMenuItem(Commands.TOGGLE_QUICK_DOCS); | ||
| editor_cmenu.addMenuDivider(); |
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.
please run npm test before you push changes, as that will tell you that your indentation here needs fixing.
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.
when I run npm test it doesn't say anything is wrong? why could this be?
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 don't think the Brackets code does much in the way of lint-format checks.
src/editor/EditorCommandHandlers.js
Outdated
|
|
||
| function _execCommand(cmd) { | ||
| window.document.execCommand(cmd); | ||
| } |
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.
indentation
humphd
left a comment
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 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.
src/editor/EditorCommandHandlers.js
Outdated
| _ = require("thirdparty/lodash"); | ||
|
|
||
|
|
||
| var commandKey = { |
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.
var commandKey;
if(brackets.platform === "mac") {
commandKey = ...;
} else {
commandKey = ...;
}| }; | ||
| }()); | ||
|
|
||
| function _execCommandPaste(){ |
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.
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"> | |||
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.
@flukeout we need a UI review from you on this change.
| position: relative; | ||
| } | ||
|
|
||
| .CodeMirror-foldgutter:after { |
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.
Why this change?
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.
During a merge conflict I just appended it under my stuff. I wasn't sure what its used for. So I kept it there.
|
Testing this out now. |
|
@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! |
|
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... |
|
@mfainshtein4 is this ready for review again? When it is, use @ and our names to make sure we see this. |
|
Code looks good. @flukeout this needs your UI review/suggestions/testing, then I think it's done. |
|
Checking in on the latest changes now. |
|
@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! 👍 |
|
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. |
|
@humphd Thanks. I appreciate the constant support and pokes in the right direction! |

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