You are here

class CKEditorAnchorLinkMatcher in CKEditor Anchor Link - For Drupal 8 and 9 3.0.x

Provides specific linkit matchers for Anchor links.

Plugin annotation


@Matcher(
  id = "ckeditor_anchor_link",
  label = @Translation("CKEditor Anchor link"),
)

Hierarchy

Expanded class hierarchy of CKEditorAnchorLinkMatcher

File

src/Plugin/Linkit/Matcher/CKEditorAnchorLinkMatcher.php, line 18

Namespace

Drupal\anchor_link\Plugin\Linkit\Matcher
View source
class CKEditorAnchorLinkMatcher extends MatcherBase {

  /**
   * {@inheritdoc}
   */
  public function execute($string) {
    $suggestions = new SuggestionCollection();
    $string = ltrim($string, '#');
    $suggestion = new DescriptionSuggestion();
    $suggestion
      ->setLabel($this
      ->t('#@anchor_link', [
      '@anchor_link' => $string,
    ]))
      ->setPath('#' . $string)
      ->setGroup($this
      ->t('Anchor links (within the same page)'));
    $suggestions
      ->addSuggestion($suggestion);
    return $suggestions;
  }

}

Members