Rework the Suggestion for CKEditor Anchor Link Matcher class for LinkIt

Created on 10 July 2024, 6 months ago
Updated 16 September 2024, 3 months ago

Problem and Motivation

I tried to use the current implementation of the AnchorLinkMatcher and wasn't really happy with the limitations to the current page and the behavior to just add a "#" to the search string, so I tried to make it usable from everywhere. The module is partially based on the existing EntityMatcher and NodeMatcher provided by Linkit.

The downside of my current solution is the amount and, in bigger systems, the complexity of the created database queries, especially when paragraphs are used. I added the configuration parameter "recursion_active" and "recursion_depth" to the config page of the matcher to mitigate this problem. My prefered solution would have been to add tracking for created and removed anchor links within the database to get rid of the flexible detection and thereby to make the complexity of the query foreseeable, but this kind of solution would have needed more changes to your module.

Manual

Configuration parameters

  • Metadata
    Adds metadata to the suggestions.
  • Bundle filter
    Add/Remove specific bundles to discovery.
  • Bundle grouping
    Groups results by bundle.
  • Limit
    Limit shown results to configured number.
  • Unpublished Nodes
    Add anchors on unpublished nodes to results. The user still needs
    to have the necessary permissions to see the nodes!
  • Recursion
    The SQL-Queries created by the anchor link detection add a JOIN-Statement for
    every textfield an anchor might be discoverable in. In combination with the module 'paragraphs'
    this can create very big SQL-Queries with a high count of JOINs. For this reason, the default configuration
    only takes 1 level of depth into account when analysing paragraphs. E.g.
      - Discovered: field_text (Textfield)
      - Discovered: field_content (Paragraph)
                    referencing field_text (Textfield)
      - NOT Discovered: field_content (Paragraph)
                        referencing field_structured_content (Paragraph)
                        referencing field_text (Textfield)
    
  • Activate recursion
    Activates recursive search, allowing in-depth analysis and high count of JOIN-Statements.
  • Limit recursion depth
    Shown when recursion is activated. If this is empty, the analysis of the depth is unlimited. In case
    of a number being configured, the depth is limited to this number, e.g.
        - Depth 1: field_text (Textfield)
        - Depth 1: field_content (Paragraph)
                   referencing field_text (Textfield)
        - Depth 2: field_content (Paragraph)
                   referencing field_structured_content (Paragraph)
                   referencing field_text (Textfield)
        - Depth 3: field_content (Paragraph)
                   referencing field_structured_content (Paragraph)
                   referencing field_more_structured_content (Paragraph)
                   referencing field_text (Textfield)
    

Usage

Within a textfield with enabled CKEditor and enabled LinkIt-Button.

  • Press LinkIt-Button
  • Either search by word, e.g. "my_anchor", or by anchor, e.g. "#my_anchor"
  • Select suggestion

Proposed resolution

I'll try to create a merge request containing my suggested rework. Either it is deemed to be suitable for your module - then it can be added - or you do not like the suggestion and reject the merge request.

Remaining tasks

  • ✅ File an issue
  • ➖ Addition/Change/Update/Fix
  • ➖ Testing to ensure no regression
  • ➖ Automated unit testing coverage
  • ➖ Automated functional testing coverage
  • ➖ UX/UI designer responsibilities
  • ➖ Readability
  • ➖ Accessibility
  • ➖ Performance
  • ➖ Security
  • ➖ Documentation
  • ➖ Code review by maintainers
  • ➖ Full testing and approval
  • ➖ Credit contributors
  • ➖ Review with the product owner
  • ➖ Release notes snippet
  • ❌ Release
Feature request
Status

Needs review

Version

3.0

Component

Code

Created by

🇩🇪Germany Styx1983

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024