Skip to content
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

Desktop: preview mode fix #2576

Merged
merged 8 commits into from
Mar 6, 2020
Merged

Conversation

Runo-saduwa
Copy link
Contributor

@Runo-saduwa Runo-saduwa commented Feb 24, 2020

DESCRIPTION:
This patch is a fix for the issue #2467 . Previously before this solution, the Edit menu items were not disabled on PREVIEW, this caused users to be able to use short cuts such as CTRL+B, CTRL+` on PREVIEW mode which is an unwanted behavior.

HOW TO TEST
Use the following test cases to confirm this solution::

  • Add a note to a notebook and click the layout toggler to PREVIEW:
    EXPECTED RESULT: 'copy', 'paste', 'cut', 'select all', 'bold', 'italic', 'link', 'code', 'insert Date Time', 'Start External Editing', 'show Local Search' should be disabled
  • Add a note to a notebook and click the layout toggler to EDITOR:
    EXPECTED RESULT: 'copy', 'paste', 'cut', 'select all', 'bold', 'italic', 'link', 'code', 'insert Date Time', 'Start External Editing', 'show Local Search' should be enabled
  • Add a note to a notebook and click the layout toggler to EDITOR AND PREVIEW MODE:
    EXPECTED RESULT: 'copy', 'paste', 'cut', 'select all', 'bold', 'italic', 'link', 'code', 'insert Date Time', 'Start External Editing', 'show Local Search' should be enabled
  • Imported a HTML note and click the layout toggler to EDITOR/PREVIEW MODE/SPLIT:
    EXPECTED RESULT: 'copy', 'paste', 'cut', 'select all', 'bold', 'italic', 'link', 'code', 'insert Date Time', 'Start External Editing', 'show Local Search' should be disabled
  • CREATE an Empty Notebook (book without notes)
    EXPECTED RESULT: 'copy', 'paste', 'cut', 'select all', 'bold', 'italic', 'link', 'code', 'insert Date Time', 'Start External Editing', 'show Local Search' should be disabled

ElectronClient/app.js Outdated Show resolved Hide resolved
ElectronClient/app.js Outdated Show resolved Hide resolved
ElectronClient/app.js Outdated Show resolved Hide resolved
@miciasto
Copy link
Contributor

miciasto commented Feb 24, 2020

@Runo-saduwa nice work, didn't check the logic, just a few style comments.

Small images of the relevant part of the screen would be nice, in the PR description, maybe showing before and after. The words have all the details, but pictures are sometimes clearer.

Copy link
Collaborator

@tessus tessus left a comment

Choose a reason for hiding this comment

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

The problem with HTML notes is still not fixed.

HTML notes must not enable any of the menu items - no matter the viewing mode. You are very close. You almost got it.

@tessus tessus linked an issue Feb 25, 2020 that may be closed by this pull request
@Runo-saduwa
Copy link
Contributor Author

I am still trying to set up Web Clipper to test this. as soon as i successfully set up Web Clipper on my browser, this issue will be resolved

@tessus
Copy link
Collaborator

tessus commented Feb 26, 2020

Just use the "normal" web clipper with your production Joplin insgtance. Then create a HTML note as I explained earlier, export it (jex), and import it into your dev Joplin instance.

@tessus
Copy link
Collaborator

tessus commented Feb 26, 2020

Or use this one:

html-test.zip

@Runo-saduwa
Copy link
Contributor Author

Thank You, I will give updates shortly

@Runo-saduwa
Copy link
Contributor Author

Just use the "normal" web clipper with your production Joplin insgtance. Then create a HTML note as I explained earlier, export it (jex), and import it into your dev Joplin instance.

Special thanks to @tessus

@Runo-saduwa
Copy link
Contributor Author

@PackElend Please label me, thanks.

Copy link
Collaborator

@tessus tessus left a comment

Choose a reason for hiding this comment

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

Apart from the empty line @mic704b mentioned, the PR looks good now.

Please delete the empty line.

@tessus tessus added PR-tested desktop All desktop platforms labels Feb 27, 2020
Copy link
Collaborator

@tessus tessus left a comment

Choose a reason for hiding this comment

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

LGTM

@Runo-saduwa
Copy link
Contributor Author

Thanks for the quick review @tessus

ElectronClient/app.js Outdated Show resolved Hide resolved
ElectronClient/app.js Outdated Show resolved Hide resolved
ElectronClient/app.js Outdated Show resolved Hide resolved
ElectronClient/app.js Outdated Show resolved Hide resolved
ElectronClient/app.js Outdated Show resolved Hide resolved
@PackElend
Copy link
Collaborator

PackElend commented Feb 29, 2020

@Runo-saduwa can you summarize you changes?
Please also include the comments / reasons.
you can do directly in the commit
image

This PR has a lot of comments, so it is quite challenging to follow it.
thank you

@@ -1178,7 +1181,8 @@ class Application extends BaseApplication {
for (const itemId of ['copy', 'paste', 'cut', 'selectAll', 'bold', 'italic', 'link', 'code', 'insertDateTime', 'commandStartExternalEditing', 'showLocalSearch']) {
const menuItem = Menu.getApplicationMenu().getMenuItemById(`edit:${itemId}`);
if (!menuItem) continue;
menuItem.enabled = !!note && note.markup_language === MarkupToHtml.MARKUP_LANGUAGE_MARKDOWN;
const isHtmlNote = !!note && note.markup_language === MarkupToHtml.MARKUP_LANGUAGE_HTML;
Copy link
Contributor Author

@Runo-saduwa Runo-saduwa Feb 29, 2020

Choose a reason for hiding this comment

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

So full condition should be const isHtmlNote = !!note && note.markup_language === MarkupToHtml.MARKUP_LANGUAGE_HTML;

based on this comment by Laurent, i have changed the code to use this. which will return true if its a HTML note and false if its not.

const isHtmlNote = !!note && note.markup_language === MarkupToHtml.MARKUP_LANGUAGE_HTML

@@ -1178,7 +1181,8 @@ class Application extends BaseApplication {
for (const itemId of ['copy', 'paste', 'cut', 'selectAll', 'bold', 'italic', 'link', 'code', 'insertDateTime', 'commandStartExternalEditing', 'showLocalSearch']) {
const menuItem = Menu.getApplicationMenu().getMenuItemById(`edit:${itemId}`);
if (!menuItem) continue;
menuItem.enabled = !!note && note.markup_language === MarkupToHtml.MARKUP_LANGUAGE_MARKDOWN;
const isHtmlNote = !!note && note.markup_language === MarkupToHtml.MARKUP_LANGUAGE_HTML;
menuItem.enabled = !isHtmlNote && layout !== 'viewer' && !!note;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then i modified the logic for enabling and disabling the menuItem with this condition
!isHtmlNote && layout !== 'viewer' && !!note
which causes the same side-effects as this:

 if(isHtmlNote || layout === 'viewer' || !note){ 
        menuItem.enabled = false;
 } else {
	menuItem.enabled = true;
 }

Copy link
Collaborator

@tessus tessus left a comment

Choose a reason for hiding this comment

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

Thanks, I think it now includes all the changes Laurent requested.

@tessus
Copy link
Collaborator

tessus commented Mar 6, 2020

Anything left to do here or can we merge this?

@laurent22 laurent22 merged commit 0be982c into laurent22:master Mar 6, 2020
@laurent22
Copy link
Owner

We got there eventually! Thanks @Runo-saduwa for the fix and everyone for reviewing.

laurent22 added a commit that referenced this pull request Mar 21, 2020
…only mode (#2576)"

Some items still need to be enabled so implementation needs to be
reviewed. Reverting for now.

This reverts commit 0be982c.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
desktop All desktop platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

edit menu items and shortcuts not disabled in preview mode
5 participants