Closed (outdated)
Project:
CKEditor Anchor Link
Version:
3.0.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
4 Apr 2018 at 16:08 UTC
Updated:
27 Jun 2025 at 00:37 UTC
Jump to comment: Most recent, Most recent file


Comments
Comment #2
jonnyeom commentedIt has been a while but I agree with this.
Anchor Link is a very useful library and would be awesome if it worked with Linkit.
But it seems like such an implementation would almost require a rewrite of the module so that it extends the Drupal Link plugin rather than overwriting it?
Another option is working with the Linkit so that LInkit extends this anchor link button as well.
Thoughts?
Comment #3
rajab natshahThanks Jonny for your follow up comment
Have you had a look at Anchor link
8.x-2.0-alpha1
8.x-2.0-alpha2
You may do your custom integration over the library, with other patches, or your changes to the library.
extends is a good idea!
I hop that we have the anchor_link in Drupal core
Comment #4
pookmish commentedAttached is an attempt to accomplish this task. It attaches to the CKEditor plugin. Theres a need to replace some of the functions in the plugin. Otherwise, the linkit support is entirely managed internally. It uses the linkit libraries and the linkit autocomplete controller to discover suggestions. This patch should not require the linkit module to be enabled, as it does the check itself within the plugin.
Comment #5
pookmish commentedComment #6
ivrh commentedThe patch makes no difference to the Linkit dialogue. After adding an Anchor link, it does not come up in the Linkit dialogue.
Would be good to have some steps to enable the anchor link functionality within the Linkit module.
Comment #7
ivrh commentedComment #8
pookmish commentedCan you explain "After adding an Anchor link, it does not come up in the Linkit dialogue."
the patch adds the linkit autocomplete to the link url field. not the anchor link button.
Comment #9
jonraedeke commentedThe patch in #4 works for me.
It's hard for the user to tell that searching for content is a possibility here. It would be good to have an autocomplete spinner and help text "Start typing to find content" like Linkit.
Comment #10
jdearie commentedI installed the patch in #4, but it doesn't appear to be working. my URL field isn't working as an autocomplete - though as @jonraedeke points out, it's a little hard to tell.
I type the node title of an existing piece of content in the URL field, but then my link is just http://page-title
I cleared cache a few times. Am I missing something?
Comment #11
r_h-l commentedRe-rolled with a placeholder text of "Start typing to find content"
Tested with Linkit 6.0.0beta1. Make sure you have linkit configured for ALL text formats.
@jdearie: Make sure Linkit is configured. I had this same thing.
Comment #12
r_h-l commentedFixing typo in patch
Comment #13
smustgrave commentedSo far the patch in #12 works for me. Would this require coordinating with linkit developers to not use the duplicate link button they require?
Comment #14
rajab natshahBetter to work on Creating a custom LinkIt matcher plugin
Having a custom AnchorLinkMatcher extends MatcherBase
To be configured on selected linkIt profile
Comment #15
rajab natshahComment #16
rajab natshahLinkIt to content or ancher link in the same page
Comment #17
rajab natshahComment #18
rajab natshahComment #19
rajab natshahComment #20
rajab natshahComment #21
rajab natshahComment #22
rajab natshahComment #23
rajab natshahComment #24
rajab natshahComment #25
rajab natshahComment #26
rajab natshahComment #27
rajab natshahComment #28
rajab natshahComment #30
smustgrave commentedGave this a quick test and it appears to be working. Though I had to add the matcher manually.
One issue I was running into was
drupal/anchor_link 3.0.x-dev requires drupal-ckeditor-plugin/fakeobjects ~4.0 -> no matching package found.
We already had fakeobjects installed but under ckeditor/fakeobjects.
Comment #31
smustgrave commentedAnd this may be a linkit issue. But after I add a link and I go back to edit it. When I double click I get two popups now
Comment #32
rajab natshahThank you, Stephen for following up
We are targeting the 3.0.x branch
Which will be released after more testing
Planed to drop support for the 8.x-1.x and 8.x-2.x
For sure after we making sure that most sites had updated to the 3.0.x version
Comment #34
rajab natshahThank you, Mike, and Richard for the custom anchorLinkit plugin
It feels that your way is the easier option.
Tested to work with AnchorLinkMatcher fix for this,
But having conflicted options.
We may use your set on 8.x-1.x in 3.0.x.
Not to use the set of 8.x-2.x.
Comment #37
rajab natshahComment #38
johanvdr commentedRajabNatshah
Regarding your approach with the Linkit Matcher (suggestions for named anchors).
The ability to scan for named anchors does that not need to be fixed in the Linkit module itself. Or is the idea to add this functionality to the anchor link module. Now it does not scan for named anchors within the page. See screenshot (should produce
#foobaras ID/name).Comment #39
siramsay commentedAfter much trial and error, I managed to get this installed somewhat manually
https://www.drupal.org/project/anchor_link/releases/3.0.x-dev
composer install you get the below as @smustgrave points out
drupal/anchor_link 3.0.x-dev requires drupal-ckeditor-plugin/fakeobjects ~4.0 -> no matching package found.I wouldn't recommend installing this as it is a work in progress and it breaks the Text formats and editors page. i.e. the Linkit checkbox disappears so you need to make sure you check that first.
For the same functionality, you can install this https://www.drupal.org/project/linkit/issues/3209603 It adds the same matcher but Text formats and editors page remain functional.
code -> https://git.drupalcode.org/issue/linkit-3209603/-/commit/ccdf4855a399844...
Both solutions don't auto-complete.
I tried #12 but couldn't get that to work either. Same issue @jdearie autocomplete not working.
Comment #41
rajab natshah#3232190: CKEditor 5 readiness
Comment #42
rajab natshahComment #43
rajab natshahComment #44
schiavone commentedHere's a patch against the 2.5 release.
Comment #45
bkosborneTo test this, I need to be using CKEditor 5?
Comment #46
bwaindwain commentedComment #47
rajab natshahComment #48
egruel commentedHello
I recently updated my Drupal 9.5.11 to 10.2.3.
In this situation, I was forced to update Linkit to version 6.1.2.
So far, I have used patch #12 using Linkit version 5.0.0.
But following the Linkit update, it no longer worked because of drupal_get_path() which is deprecated in D10 and a JS error when you attach an element to linkit.autocompleteeteete.
I think there is a problem with linkit.autocomplete that applies this feature on fields with the class 'form-linkit-autocomplete' but this class is not added by linkit directly, and I find it rather strange that it is anchor link that adds this class via the patch.
In ckeditor5, it seems that Linkitaautomatically adds this class to the initialization of the autcomplete, but not to ckeditor4.
So I’ll reroll the patch. Maybe it will be useful to someone else, or reopen the discussion on this integration.
Comment #49
justcaldwellIt looks like #3022261: Add better support for linking to anchors in LinkIt's issue queue is getting close. Should this be closed as "won't fix" in favor of focusing efforts and testing there?
Comment #50
rajab natshahYes, Michael.
Thanks, for following up on the issue.
Comment #51
justcaldwellRetracting my comment #49. Sorry for the confusion.
The LinkIt issue I referenced is only about ensuring LinkIt will work correctly when a fragment is appended to a link to another node (e.g. /node/5#foo).
This issue is augmenting the LinkIt dialog with a list of on-page anchors via the custom CKEditor Anchor link matcher (which would be nice to have!).
Unfortunately, in a quick test it doesn't quite seem to be working. When I begin a link with #, the 'Anchor links (within the same page)' list appears, but no anchors appear — just a single blank entry. Screenshot below.
Comment #52
justcaldwellThe above is based on the patch from #48, LinkIt 6.1.4 and Drupal 10.3.2.
Comment #53
rajab natshahComment #54
rajab natshahClosing this issue.
Moving to #3460457: Rework the Suggestion for CKEditor Anchor Link Matcher class for LinkIt