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

Slug based linked headlines in volto-slate #4298

Closed
4 of 8 tasks
nileshgulia1 opened this issue Jan 22, 2023 · 13 comments
Closed
4 of 8 tasks

Slug based linked headlines in volto-slate #4298

nileshgulia1 opened this issue Jan 22, 2023 · 13 comments

Comments

@nileshgulia1
Copy link
Member

nileshgulia1 commented Jan 22, 2023

PLIP (Plone Improvement Proposal)

Responsible Persons

Proposer: Nilesh Gulia @nileshgulia1

Seconder: Tiberiu Ichim @tiberiuichim

Abstract

Add a anchor link target to headings(h1,h2,h3,h4) in volto-slate.

Motivation

We often came across situations where we might want to direct a user to specific section/heading(h1,h2,h3,h4) in a page. We need an ability to create those anchors links within headings written in volto-slate.

Assumptions

For every new widget/block, UniversalLink component should be used for rendering links.

Proposal & Implementation

Proposal is to display a link button when hovering on a specific heading in volto-slate hitting which creates an anchor based on slugiffied heading title and stored as an id attribute on an element. IMO, this is a most useful basic feature missing in a modern day CMS and quite a common solution on many sites.

Example: https://learn.microsoft.com/en-us/power-platform/alm/overview-alm#what-is-alm
<h2 id="introduction-to-everything">Introduction to everything</h2>

Deliverables

  • link svg on hover headings
  • sluggified anchors based on heading title
  • github-slugger npm package
  • Existing blocks toc, links?
  • What about the title block?
  • Css and animations on scroll
  • UniversalLink component now uses react-router-hash-link
  • Cypress tests

Risks

  • Using sluggified anchors can break existing blocks such as TOC and other widgets which are based on block uids.
  • What will happen to slug if headings are modified? and/or existing headings?
  • Could be a potential breaking change?
  • opt-in feature?

Participants

To be discussed in next @plone/volto-team meeting.

@stevepiercy
Copy link
Collaborator

How would you handle hover states on mobile devices without a mouse? Tap and hold?

@tiberiuichim
Copy link
Contributor

@stevepiercy on mobile, the headline links should be visible directly (not hidden), similar to the way github does it.

@nileshgulia1
Copy link
Member Author

For the record, this is how the current implementation looks

mobile:
Screenshot 2023-01-23 at 3 05 02 PM

Desktop:
Screenshot 2023-01-23 at 6 21 56 PM

The title block isn't a part of this feature yet as it doesn't support rich text editing. We might also need to modify https://github.com/plone/volto/blob/linkedHeadlinesRefactor/src/components/manage/Blocks/Title/Edit.jsx#L146

@akshatgarg12
Copy link
Member

Planning to propose a solution to this as contributor in GSOC'23.

My views regarding the risks , based on the current implementation in #3540 and #4287,

What will happen to slug if headings are modified? and/or existing headings?

As the slug is based on the content of the LinkedHeadings , the slug will be dynamic and will be generated based on the headings text, so the id will change accordingly ( as implemented here )

Using sluggified anchors can break existing blocks such as TOC and other widgets which are based on block uids.

In #4287 , the TOC component renderListItems has a slug generated by the plaintext of the block which should be able to maintain consistency and not break the TOC

Could be a potential breaking change?

This will be a breaking change for projects which have used component shadowing for components like title, TOC, TextBlockView

opt-in feature

Making it an opt-in feature at component level will again be a breaking change for the above components, and will we use conditional rendering in this case?

Please correct me if I'm wrong in these assumptions
cc : @tiberiuichim @nileshgulia1

@rakshith6404
Copy link

I would like and am planning to contribute to this project/idea as a contributor and an aspirant of GSoC'23,

Looking forward for the solution needed and making a detailed proposal for the same is what i am planning to get going to this project,I have started to work on this issue and have some deliverables from my side which i have stated in the proposal.

As in the part of Risks @nileshgulia1 haas stated ;

Using sluggified anchors can break existing blocks such as TOC and other widgets which are based on block uids.

I have a solution to this issue and have started writing my proposal regarding the same.

I am looking forward for the mentors cc: @tiberiuichim @nileshgulia1 and the mentor of this Project/idea to guide me through it and also could the CCs Please guide me how to start contributing to this issue.Should i just submit the proposal when the timeline for the submission for the project starts??

@sneridagh
Copy link
Member

@plone/volto-team This is how Confluence is implementing it, and I kind of like it:

Screen.Recording.2023-04-02.at.09.29.28.mov

@tiberiuichim
Copy link
Contributor

@sneridagh can you do a test with a multiline headline? I wonder how they treat this case, if the link icon is inline with the end of the text, or at the side.

@sneridagh
Copy link
Member

At the end of the text:

Screen.Recording.2023-04-02.at.10.05.05.mov

@nileshgulia1
Copy link
Member Author

After adding some animations and css it finally took the shape.

Screen.Recording.2023-04-18.at.5.03.30.PM.mov

@sneridagh sneridagh added this to the Plone 6.1 milestone Jun 6, 2023
@sneridagh
Copy link
Member

Closing as completed in #3540

@tisto
Copy link
Member

tisto commented Feb 12, 2024

@nileshgulia1 @tiberiuichim @avoinea @sneridagh I am currently writing the roadmap for Plone 6.x and I try to include links to the documentation of a new feature. So far I only found:

https://6.docs.plone.org/volto/configuration/volto-slate/index.html
https://6.docs.plone.org/volto/configuration/volto-slate/configuration-settings.html#slate-uselinkedheadings

Is this everything we got/need?

@nileshgulia1
Copy link
Member Author

@tisto That's only what I found. It would be nice to mention it in the user manual as well.

@tisto
Copy link
Member

tisto commented Feb 12, 2024

@nileshgulia1 could you imagine working on some user docs for this feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

7 participants