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

feat(editor): Add support for collapsible sections #6251

Merged
merged 2 commits into from
Aug 28, 2024
Merged

Conversation

mejo-
Copy link
Member

@mejo- mejo- commented Aug 23, 2024

πŸ“ Summary

Uses <details> and <summary> summary both for markdown and HTML serialization.

Fixes: #3646

πŸ–ΌοΈ Screenshots

Details expanded Details collapsed Option
grafik grafik grafik

🚧 TODO

  • Fix enter in summary (jump to details content, but don't add newline)
  • Discuss icon in menubar
  • Support marks in summary (markdown-it plugin supports it already, but toMarkdown() in Tiptap plugin not)
  • Do we want to persist expand/collapse state in document? If not, it will not be synchronized between view/edit mode in Collectives either
  • Jest tests for markdown through editor
  • Cypress tests

@nextcloud/designers for feedback

🏁 Checklist

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits
  • Tests (unit, integration and/or end-to-end) passing and the changes are covered with tests
  • Documentation (README or documentation) has been updated or is not required

@mejo- mejo- added feature: formatting Features related to text formatting and node types 2. developing labels Aug 23, 2024
@mejo- mejo- self-assigned this Aug 23, 2024
@juliusknorr
Copy link
Member

Very nice ❀️

Do we want to persist expand/collapse state in document? If not, it will not be synchronized between view/edit mode in Collectives either

Just a thought here, persisting would likely also mean that toggling would propagate to all people during collaboration with I would not expect.

@mejo-
Copy link
Member Author

mejo- commented Aug 26, 2024

Disallow nested details in Tiptap schema

After some more testing I managed to support nested details in the markdown-it plugin, and I don't see a reason any longer to not support nested details.

Copy link
Member

@jancborchardt jancborchardt left a comment

Choose a reason for hiding this comment

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

Very nice! :) Just some details:

@mejo-
Copy link
Member Author

mejo- commented Aug 26, 2024

Thanks for the feedback @jancborchardt ❀️

The code block does not have rounded corners here?

That's a separate issue unrelated to this PR.

@@ -322,6 +323,16 @@ export default [
},
priority: 17,
},
{
Copy link
Member

Choose a reason for hiding this comment

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

@jancborchardt Keeping #2836 into consideration should we take action for this one right now and instead of adding this as yet another menu bar entry try to group them in the callout menu as listed in the issue?

Blockquote and code block go into the callouts menu

In the end the details is just another "block style"

Copy link
Member

Choose a reason for hiding this comment

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

Though one argument against would be that you could still have a callout nested in a details block which is then not very obvious from the active indication in the menu bar

Copy link
Member

Choose a reason for hiding this comment

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

In the end the details is just another "block style"

Yeah, good point, makes sense to directly group it properly.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree, but then we probably should move block quote and code blocks into this submenu as well straight away, right? What icon should be used for the "block style" submenu?

@mejo-
Copy link
Member Author

mejo- commented Aug 26, 2024

@jancborchardt @nimishavijay do you have a good idea how to support nested details UX-wise? Usually the menu items toggle the feature on/off depending on whether it's currently active or not. If we just always make the menu item create a new details section, there would be no way to turn the details off.

I'm also fine with not supporting nested details in the UI for now as I don't expect this to be used this a lot. People who really need nested details will have to manually add it in their markdown source then.

@jancborchardt
Copy link
Member

I'm also fine with not supporting nested details in the UI for now as I don't expect this to be used this a lot. People who really need nested details will have to manually add it in their markdown source then.

@mejo- I agree it’s best to skip nested details for now. :)

@mejo- mejo- requested a review from juliusknorr August 26, 2024 22:54
@mejo- mejo- marked this pull request as ready for review August 26, 2024 22:55
@mejo- mejo- force-pushed the feat/details branch 2 times, most recently from 9d73c45 to a816980 Compare August 27, 2024 10:54
@juliusknorr
Copy link
Member

Very nice, code looks clean, has tests and works like a charm. πŸ‘

Small UI issue with content that seems to be artificially limited in width, but otherwise good to go from my side.

Screenshot 2024-08-27 at 15 09 08

Uses `<details>` and `<summary>` summary both for markdown and HTML
serialization.

Fixes: #3646

Signed-off-by: Jonas <jonas@freesources.org>
Signed-off-by: Jonas <jonas@freesources.org>
@mejo-
Copy link
Member Author

mejo- commented Aug 27, 2024

Small UI issue with content that seems to be artificially limited in width, but otherwise good to go from my side.

Good catch, fixed now.

@juliusknorr juliusknorr merged commit d91196c into main Aug 28, 2024
59 of 61 checks passed
@juliusknorr juliusknorr deleted the feat/details branch August 28, 2024 12:11
@bthnakkurt
Copy link

is it added now? can i use it by cloning?

@mejo-
Copy link
Member Author

mejo- commented Nov 13, 2024

is it added now? can i use it by cloning?

This will become available in Nextcloud 31 (currently in development).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review feature: formatting Features related to text formatting and node types
Projects
Status: β˜‘οΈ Done
Development

Successfully merging this pull request may close these issues.

Collapsible sections
4 participants