-
-
Notifications
You must be signed in to change notification settings - Fork 385
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
fix: Issues when editor is non-editable #783
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
this.prevWasEditable === this.editor.isEditable) && | ||
(composing || isSame) | ||
) { | ||
if (composing || isSame) { |
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 do we not need the editable checks here anymore?
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 just because the logic for checking that has been moved to the toolbar buttons, since the download file button, unlike all the others, needs to be rendered even when the editor isn't editable.
@@ -101,7 +101,7 @@ export const BasicTextStyleButton = <Style extends BasicTextStyle>(props: { | |||
return !!selectedBlocks.find((block) => block.content !== undefined); | |||
}, [basicTextStyleInSchema, selectedBlocks]); | |||
|
|||
if (!show) { | |||
if (!show || !editor.isEditable) { |
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 do we move the editable checks here? Doesn't it make more sense to make sure the entire formattingtoolbar is not shown?
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.
Unfortunately not for the tiny edge case of being able to download files while the editor is uneditable, which is done via the formatting toolbar
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.
Hmm, wouldn't it be cleaner then to make sure clicking the button downloads files in non-editable state? That saves a lot of logic in the buttons, as we can then just disable the formatting toolbar when non editable.
I also think that's semantically better, as for a "formatting toolbar" I'd expect I'd only be able to use it when I can actually edit / format the text.
wdyt?
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.
wouldn't it be cleaner then to make sure clicking the button downloads files in non-editable state?
Which button are you referring to, do you mean the default image preview? I would say that's a fair point but it complicates things for other types of file previews like images, videos, pdfs, etc. Especially with interactive previews, unless you have an in-built button to download the file, you can't really rely on just clicking the preview.
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.
Also r.e. semantics I agree, but I think the root issue of that is really having the download button in the formatting toolbar to begin with. I reckon at some point we will probably change to a file-specific menu for file blocks like Notion has.
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. I still don't really like it, but agree there's not a better solution without significantly more effort. Let's go for this option for now. Can you add the reasoning (that and why we allow the formatting toolbar to show even when the editor is not editable, and that we instead do a per-button check) as 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.
ok, one question then good to go
@@ -101,7 +101,7 @@ export const BasicTextStyleButton = <Style extends BasicTextStyle>(props: { | |||
return !!selectedBlocks.find((block) => block.content !== undefined); | |||
}, [basicTextStyleInSchema, selectedBlocks]); | |||
|
|||
if (!show) { | |||
if (!show || !editor.isEditable) { |
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. I still don't really like it, but agree there's not a better solution without significantly more effort. Let's go for this option for now. Can you add the reasoning (that and why we allow the formatting toolbar to show even when the editor is not editable, and that we instead do a per-button check) as a comment?
Closes #707
Closes #770
Closes #766