question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: Add a way to inject an anchor identifier in page content

See original GitHub issue

This is a followup to #1049 which took care of injecting an anchor link for the current page.

This issue is for the other part of the problem: injecting the anchor identifier, which is the target of the anchor link. In short, we need a way to inject an id on any selected content in the Draftail richtext component.

Quoting myself from https://github.com/wagtail/wagtail/issues/1049#issuecomment-504651173:

On the other hand there is the question of “Adding anchors to content in rich text”, and maybe it would help and make things clearer to open a new issue to discuss just that. I played with https://github.com/thibaudcolas/wagtail_draftail_experiments/tree/master/wagtail_draftail_anchors last week, it basically does what’s needed but is still missing a proper UI. That new issue could be about improving the work started by @thibaudcolas . Also I’d need guidance on what part of the existing client code could be re-used and extended (eg: there is a Tooltip component into the core, could that be re-used?) and I believe this would be better discussed in a separate issue.

These comments are also relevant: https://github.com/wagtail/wagtail/issues/1049#issuecomment-39595181 https://github.com/wagtail/wagtail/issues/1049#issuecomment-490854586

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:7
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

5reactions
dest81commented, Nov 30, 2021

@thibaudcolas recently I was playing with wagtail_draftail_anchors and made some changes:

  • anchor identifier is a span tag with id <span id="id"...
  • ability to edit id of the existing anchor identifier
  • ability to edit id of the header, it means that header can have auto id or custom id entered by user
  • all anchor identifiers have html class anchor - could be helpful to handle anchors on front-end

Here is the link to my fork https://github.com/dest81/wagtail_draftail_anchors Any feedback welcome! This is draft version so do not judge too strictly, this is my first real experience with Draft.js and I am not ReactJS developer 😃

https://user-images.githubusercontent.com/2307929/144108329-37aa9c46-70d7-4c14-84f7-014f0ddeafe0.mp4

2reactions
jcmundycommented, Apr 21, 2021

Has there been anything more on adding an anchor target?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating anchor links - Squarespace Help Center
To link to the top of the page, link to the header using code injection. Code injection is a premium feature. Add text...
Read more >
How to Create Anchor Links in WordPress (3 Easy Methods)
Highlight the header you want to link it up to. Then click on “Insert” from the button at the top and select “Anchor.”...
Read more >
How do I manually create anchor links in articles?
Select the text you want to use as the link, then, click the Insert/edit link icon. Select the Heading tab and find the...
Read more >
Insert and manage anchor links - HubSpot Knowledge Base
Create an anchor. Navigate to your content: Website Pages: In your HubSpot account, navigate to Marketing > Website > Website Pages. Landing ...
Read more >
Links in HTML documents - W3C
Syntax of anchor names; Nested links are illegal; Anchors with the id attribute ... However, authors may insert links in their documents that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found