Problem/Motivation

When using this module with Linkit, I've noticed that the URL and Anchor fields do not leverage the autocomplete capability provided by Linkit.

I thought this would be a useful feature since if this is meant to improve the core CKEditor linking feature we should consider keeping it in sync with all the other contribs developed to enhance the link dialog box.

Proposed resolution

Remaining tasks

  • ☑ File an issue
  • ☐ Addition/Change/Update/Fix
  • ☐ Testing to ensure no regression
  • ☐ Automated unit/functional testing coverage
  • ☐ Documentation
  • ☐ Code review by maintainers
  • ☐ Full testing and approval
  • ☐ Credit contributors
  • ☐ Review with the product owner
  • ☐ Update Release Notes
  • ☐ Release

User interface changes

API changes

  • None

Data model changes

  • None

Comments

Velociraptor0880 created an issue. See original summary.

jonnyeom’s picture

It 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?

rajab natshah’s picture

Thanks 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

pookmish’s picture

StatusFileSize
new13.54 KB

Attached 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.

pookmish’s picture

Status: Active » Needs review
ivrh’s picture

The 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.

ivrh’s picture

Status: Needs review » Needs work
pookmish’s picture

Can 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.

jonraedeke’s picture

The 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.

jdearie’s picture

I 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?

r_h-l’s picture

StatusFileSize
new13.6 KB

Re-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.

r_h-l’s picture

StatusFileSize
new13.6 KB

Fixing typo in patch

smustgrave’s picture

So far the patch in #12 works for me. Would this require coordinating with linkit developers to not use the duplicate link button they require?

rajab natshah’s picture

Assigned: Unassigned » rajab natshah
Issue summary: View changes
Status: Needs work » Active
StatusFileSize
new250.16 KB
new113.29 KB

Better to work on Creating a custom LinkIt matcher plugin

Having a custom AnchorLinkMatcher extends MatcherBase
To be configured on selected linkIt profile

rajab natshah’s picture

rajab natshah’s picture

LinkIt to content or ancher link in the same page

LinkIt  to content  or ancher link in the same page

rajab natshah’s picture

Title: Integration with Linkit » Integration with Linkit using an Anchor Link Matcher plugin for LinkIt to use the same drupal link core for CKEditor
Issue summary: View changes
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

StatusFileSize
new2.21 KB
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Title: Integration with Linkit using an Anchor Link Matcher plugin for LinkIt to use the same drupal link core for CKEditor » Integration with LinkIt using an Anchor Link Matcher plugin for LinkIt to use the same drupal link core for CKEditor
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

StatusFileSize
new2.31 KB
rajab natshah’s picture

Version: 8.x-1.6 » 3.0.x-dev

  • RajabNatshah committed 1e948d6 on 3.0.x
    Issue #2958532: Integration with LinkIt using an Anchor Link Matcher...
smustgrave’s picture

Version: 3.0.x-dev » 8.x-1.6

Gave 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.

smustgrave’s picture

StatusFileSize
new82.65 KB

And 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

rajab natshah’s picture

Thank 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

  • RajabNatshah committed d4e8ce9 on 3.0.x
    Issue #2958532: Integration with LinkIt using an Anchor Link Matcher...
rajab natshah’s picture

Thank 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.

  • RajabNatshah committed d8a91ed on 3.0.x
    Issue #2958532: Integration with LinkIt using an Anchor Link Matcher...

  • RajabNatshah committed 94d5b9e on 3.0.x
    Issue #2958532: Integration with LinkIt using an Anchor Link Matcher...
rajab natshah’s picture

Version: 8.x-1.6 » 3.0.x-dev
johanvdr’s picture

RajabNatshah

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 #foobar as ID/name).

Only local images are allowed.

siramsay’s picture

After 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.

  • Rajab Natshah committed 98348f8 on 8.x-1.x
    Issue #2958532 by R_H-L, RajabNatshah, pookmish: Integration with LinkIt...
rajab natshah’s picture

rajab natshah’s picture

Issue summary: View changes
schiavone’s picture

Here's a patch against the 2.5 release.

bkosborne’s picture

To test this, I need to be using CKEditor 5?

bwaindwain’s picture

rajab natshah’s picture

Assigned: rajab natshah » Unassigned
egruel’s picture

Hello
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.

justcaldwell’s picture

It 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?

rajab natshah’s picture

Yes, Michael.
Thanks, for following up on the issue.

justcaldwell’s picture

StatusFileSize
new18.3 KB

Retracting 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.

No anchors appear in the list.

justcaldwell’s picture

The above is based on the patch from #48, LinkIt 6.1.4 and Drupal 10.3.2.

rajab natshah’s picture

rajab natshah’s picture

Status: Active » Closed (outdated)