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

fix: Issues when editor is non-editable #783

Merged
merged 3 commits into from
Jun 5, 2024
Merged

Conversation

matthewlipski
Copy link
Collaborator

@matthewlipski matthewlipski commented May 29, 2024

Closes #707
Closes #770
Closes #766

Copy link

vercel bot commented May 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview Jun 5, 2024 4:48pm
blocknote-website ✅ Ready (Inspect) Visit Preview Jun 5, 2024 4:48pm

this.prevWasEditable === this.editor.isEditable) &&
(composing || isSame)
) {
if (composing || isSame) {
Copy link
Collaborator

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?

Copy link
Collaborator Author

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) {
Copy link
Collaborator

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?

Copy link
Collaborator Author

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

Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

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?

Copy link
Collaborator

@YousefED YousefED left a 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) {
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants