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: Fixes #10025: Toggle external editing button overlaps with bold button. #10069
Desktop: Fixes #10025: Toggle external editing button overlaps with bold button. #10069
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.
Thank you for the pull request!
Based on the screen recording and this comment, it looks like there are still a few changes to be made — currently, the "toggle external editing" button has right padding when not external editing:
@@ -38,7 +39,7 @@ export default function styles(props: NoteBodyEditorProps) { | |||
}, | |||
leftExtraToolbarContainer: { | |||
...extraToolbarContainer, | |||
width: 80, | |||
width: { leftExtraToolbarContainerWidth }, |
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.
width: { leftExtraToolbarContainerWidth }, | |
width: leftExtraToolbarContainerWidth, |
Including the {
s sets width
to an object with content
{
leftExtraToolbarContainerWidth: leftExtraToolbarContainerWidth,
}
Setting width
directly to leftExtraToolbarContainerWidth
may make more sense here.
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, when we directly update leftExtraToolbarContainerWidth (width: leftExtraToolbarContainerWidth), it's only setting the value once and not updating the width when watchedNoteFiles changes. I've tried logging the value of leftExtraToolbarContainerWidth, which shows correctly. However, the problem is that the width of the container is not updating during changes in watchedNoteFiles. I've tried to figure it out, and I believe the issue is that the styles are initially loaded and not updating during changes in watchedNoteFiles
So in packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/TinyMCE.tsx we can do this which will load styles when watchedNoteFiles changes
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 tried to figure it out, and I believe the issue is that the styles are initially loaded and not updating during changes in watchedNoteFiles
It should be possible to fix this by updating the dependency array (cacheKey
) passed to buildStyles
. I think making this change in TinyMCE.tsx would also be fine, but making the change in styles/index.ts
should keep the styles in closer to the same place.
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.
Thank you for pointing that out.I wasn't aware of the (cacheKey
) concept before, but after your suggestion, I made the necessary changes in the styles/index.ts
.
padding-left: ${120 + styles.leftExtraToolbarContainer.padding * 2}px; | ||
padding-right: ${120 + styles.rightExtraToolbarContainer.padding * 2}px; |
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.
Currently, this always increases the size reserved for the toolbar button. Based on comment, I think it would make more sense to change the size conditionally. (This might require adding a dependency to the useEffect
).
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.
Screencast.from.07-03-24.12.47.12.PM.IST.webm
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.
Thank you for the updated video! (I had been looking at the video attached under "After" in the PR description :) )
@personalizedrefrigerator, what would be the status of this pull request? (whenever reviewing a pull request, please mark it as "approved" once the changes are made and are satisfactory) |
Thank you for the reminder! I plan to test this pull request locally later today. |
@@ -351,14 +351,15 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => { | |||
useEffect(() => { | |||
const theme = themeStyle(props.themeId); | |||
const backgroundColor = props.whiteBackgroundNoteRendering ? lightTheme.backgroundColor : theme.backgroundColor; | |||
const leftExtraToolbarContainerWidth = props.watchedNoteFiles.length > 0 ? 120 : 80; |
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.
Currently, this logic is present in both TinyMCE.tsx
and index.ts
. Please refactor this to avoid duplicate code.
Edit: The index.ts
logic might not be used anymore (see above 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.
Thank you for working on this!
I've tested the changes locally and left a few comments.
padding-left: ${styles.leftExtraToolbarContainer.width + styles.leftExtraToolbarContainer.padding * 2}px; | ||
padding-right: ${styles.rightExtraToolbarContainer.width + styles.rightExtraToolbarContainer.padding * 2}px; | ||
padding-left: ${leftExtraToolbarContainerWidth + styles.leftExtraToolbarContainer.padding * 2}px; | ||
padding-right: ${styles.rightExtraToolbarContainerWidth + styles.rightExtraToolbarContainer.padding * 2}px; |
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.
Currently, padding-right
is being set to NaNpx
. When I run
console.log(document.querySelector('#tinyMceStyle').innerText.substring(0, 100))
from Joplin's debug terminal, I get
.joplin-tinymce .tox-editor-header {
padding-left: 92px;
padding-right: NaNpx;
}
Please double-check that the property names are correct here!
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.
Apologies, all corrected now.
Please change the title to
We have a script that parses commit titles and converts them into release notes. When pull requests are sqashed and merged, the default commit title is the pull request title. |
…laps-with-bold-button
4017832
to
6d60843
Compare
@@ -547,7 +547,7 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => { | |||
// | |||
// tl;dr: editorReady is used here because the css needs to be re-applied after TinyMCE init | |||
// eslint-disable-next-line @seiyab/react-hooks/exhaustive-deps -- Old code before rule was applied | |||
}, [editorReady, props.themeId, lightTheme, props.whiteBackgroundNoteRendering]); | |||
}, [editorReady, props.themeId, lightTheme, props.whiteBackgroundNoteRendering, props.watchedNoteFiles]); |
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.
Because props.watchedNoteFiles
isn't used in the body of that hook, consider leaving a comment about why props.watchedNoteFiles
is included in the dependency array.
Alternatively, it could make more sense to depend on styles
instead of props.watchedNoteFiles
.
Other than that, this pull request looks good to me!
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 added Comment , additionally I want to know watchedNoteFiles
is used for checking if external editor is on or off but if there is anything which keeps track of each notes state If that note is open in external editor?
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 anything which keeps track of each notes state If that note is open in external editor?
ExternalEditWatcher.ts is responsible for watching for file updates. The note is updated here:
joplin/packages/lib/services/ExternalEditWatcher.ts
Lines 144 to 145 in 7638bdf
await Note.save(updatedNote); | |
this.eventEmitter_.emit('noteChange', { id: updatedNote.id, note: updatedNote }); |
The noteChange
event is handled here:
const externalEditWatcher_noteChange = useCallback((event: any) => { |
What I think then happens is props.content
is updated, which causes the rich text editor to update its content, near this comparison:
if (lastOnChangeEventInfo.current.content !== props.content || !resourcesEqual) { |
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.
Alternatively, it could make more sense to depend on
styles
instead ofprops.watchedNoteFiles
.
I think that would be the better fix - styles
is in use in this effect but not in the dependencies. This change may be a good opportunity to clean up this effect and remove the legacy eslint-disable-next-line @seiyab/react-hooks/exhaustive-deps
(which allows this new change to pass the linter even though it shouldn't). It will require extensive testing though @JanhaviAlekar
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.
@JanhaviAlekar please let me know if you're interested in completing this pull request. I assume that changing the dependency to styles
is not too complex.
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.
@JanhaviAlekar please let me know if you're interested in completing this pull request. I assume that changing the dependency to
styles
is not too complex.
Apologies for the delay. I was experiencing some laptop issues. I've made the required changes, and now only the testing part is left. I'll test it today.
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.
@JanhaviAlekar please let me know if you're interested in completing this pull request. I assume that changing the dependency to
styles
is not too complex.Apologies for the delay. I was experiencing some laptop issues. I've made the required changes, and now only the testing part is left. I'll test it today.
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/TinyMCE.tsx
[editorReady, props.themeId, lightTheme, props.whiteBackgroundNoteRendering, styles]);
I'd like to understand why lightTheme is included in the dependency array. When I removed the //eslint-disable-next-line @seiyab/react-hooks/exhaustive-deps
, the linter raised an error indicating that lightTheme
is a dependency not in use. I then removed it, and the code still worked fine. However, I'm uncertain about its purpose or necessity. Could you please provide clarification?
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.
Ok then I don't know, we're probably going to break something somewhere if we remove it so let's leave and go back to the original idea. Just include props.watchedNoteFiles
please and add a comment explaining why it's needed
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.
Ok then I don't know, we're probably going to break something somewhere if we remove it so let's leave and go back to the original idea. Just include
props.watchedNoteFiles
please and add a comment explaining why it's needed
Done! Included props.watchedNoteFiles and added a comment explaining why it's needed. Thank you for your help!
…laps-with-bold-button
9a5b2f3
to
c8112d7
Compare
Looks good now, thanks you @JanhaviAlekar ! |
Before :
Screencast from 05-03-24 03:47:55 PM IST.webm
After:
Screencast from 06-03-24 07:35:35 PM IST.webm
fixes #10025