In order to to use HTML in tips, the sanitizeTip() method needs to be optional. I considered adding a config option, but I think it works better to move the sanitize and truncate into the theme so that themers can do what they need to do. This allows doing the cool stuff in the Tippy library. Also, it makes sense as a theme function because to make use of an HTML tip the twig templates need to be overriden and modified to use something like data-tippy-content="{{ tip }}" .

Issue fork glossify-3005964

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

awolfey created an issue. See original summary.

awolfey’s picture

StatusFileSize
new2.47 KB

Patch attached.

awolfey’s picture

Status: Active » Needs review
awolfey’s picture

StatusFileSize
new2.56 KB

This preserves the raw tip with html.

awolfey’s picture

StatusFileSize
new4.16 KB

Even better, just add the raw tip to the existing theme hook.

keesje’s picture

Thanks for the contribution. If someone can test/review this, please post results.

keesje’s picture

Status: Needs review » Needs work

patch probably needs rerolling agains current dev

awolfey’s picture

Status: Needs work » Needs review
StatusFileSize
new2.24 KB

Here's a patch against latest dev.

joum’s picture

Tried against dev and can't seem to even access the theme_glossify_tooltip(&$variables) hook.

I wanted to do so to add another element to the variables to be used in the template, but it isn't working as intended. I might be missing something, though, so any pointers are welcome.

I'm currently only trying to kint() in the hook function.
I'm getting the following error:

Warning: DOMNode::insertBefore(): Document Fragment is empty in Drupal\glossify\GlossifyBase->parseTooltipMatch() (line 149 of modules/contrib/glossify/src/GlossifyBase.php).

Drupal\glossify\GlossifyBase->parseTooltipMatch('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque varius sem vitae dolor sagittis, sed rutrum ex dignissim. Aenean dapibus orci sit amet felis dignissim, açúcares in lobortis enim volutpat. In sit amet tempor nisi. Praesent eu laoreet metus. Mauris id ex congue, tristique lectus ut, consectetur ex. Donec in dui ligula. Maecenas at magna suscipit mi vestibulum ullamcorper. Cras dapibus tincidunt tincidunt. Aliquam in laoreet sem. Etiam luctus hendrerit justo sed bibendum.', Array, '0', '0', 'tooltips', '/taxonomy/term/[id]') (Line: 152)
Drupal\glossify_taxonomy\Plugin\Filter\TaxonomyTooltip->process('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque varius sem vitae dolor sagittis, sed rutrum ex dignissim. Aenean dapibus orci sit amet felis dignissim, açúcares in lobortis enim volutpat. In sit amet tempor nisi. Praesent eu laoreet metus. Mauris id ex congue, tristique lectus ut, consectetur ex. Donec in dui ligula. Maecenas at magna suscipit mi vestibulum ullamcorper. Cras dapibus tincidunt tincidunt. Aliquam in laoreet sem. Etiam luctus hendrerit justo sed bibendum.', 'en') (Line: 118)
Drupal\filter\Element\ProcessedText::preRenderText(Array)
call_user_func(Array, Array) (Line: 378)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 501)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 102)
__TwigTemplate_4abe889888d8f9f582514f29a6d42c21e4865faf2fbed570494bebddd308e160->doDisplay(Array, Array) (Line: 443)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 414)
Twig\Template->display(Array) (Line: 422)
Twig\Template->render(Array) (Line: 64)
twig_render_template('themes/contrib/radix/templates/field/field.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('field', Array) (Line: 437)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 450)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 501)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 84)
__TwigTemplate_197faf10a2c3a209b64540d3ebe500bc2b1797d8d3ec576b96e72b1ed0d294dc->block_content(Array, Array) (Line: 216)
Twig\Template->displayBlock('content', Array, Array) (Line: 73)
__TwigTemplate_197faf10a2c3a209b64540d3ebe500bc2b1797d8d3ec576b96e72b1ed0d294dc->block_paragraph(Array, Array) (Line: 216)
Twig\Template->displayBlock('paragraph', Array, Array) (Line: 62)
__TwigTemplate_197faf10a2c3a209b64540d3ebe500bc2b1797d8d3ec576b96e72b1ed0d294dc->doDisplay(Array, Array) (Line: 443)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 414)
Twig\Template->display(Array) (Line: 422)
Twig\Template->render(Array) (Line: 64)
twig_render_template('modules/contrib/paragraphs/templates/paragraph.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('paragraph', Array) (Line: 437)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 501)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 82)
__TwigTemplate_4abe889888d8f9f582514f29a6d42c21e4865faf2fbed570494bebddd308e160->doDisplay(Array, Array) (Line: 443)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 414)
Twig\Template->display(Array) (Line: 422)
Twig\Template->render(Array) (Line: 64)
twig_render_template('themes/contrib/radix/templates/field/field.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('field', Array) (Line: 437)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 450)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 501)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 88)
__TwigTemplate_5590d390675c72c34a2c24c2bacbec002aa981f84eebc363fabf10434f122b65->block_content(Array, Array) (Line: 216)
Twig\Template->displayBlock('content', Array, Array) (Line: 77)
__TwigTemplate_5590d390675c72c34a2c24c2bacbec002aa981f84eebc363fabf10434f122b65->doDisplay(Array, Array) (Line: 443)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 414)
Twig\Template->display(Array, Array) (Line: 59)
__TwigTemplate_cbf29fcf11cdfda9204edfcda461b857c76a7cffa24a263e7d4841cc597df51d->doDisplay(Array, Array) (Line: 443)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 414)
Twig\Template->display(Array) (Line: 422)
Twig\Template->render(Array) (Line: 64)
twig_render_template('themes/custom/mytheme/templates/content/node.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('node', Array) (Line: 437)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 156)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
sanduhrs’s picture

Version: 8.x-1.x-dev » 2.0.x-dev

tim-diels made their first commit to this issue’s fork.

tim-diels’s picture

I've rewritten the patch against current dev.

But in my opinion the patch was not complete and:

  • I've included the variables in the templates.
  • I've added a sanitizeRawTip as this is needed for truncating the string to an amount of characters. However this needs work as it will break the HTML output.

It is not possible to create an interdiff as the patch needed a rewrite to work.

tim-diels’s picture

Version: 2.0.x-dev » 3.x-dev

Feature request should happen to the 3.x branch.

tim-diels’s picture

Rebased.

tim-diels’s picture

We're using this for over a year now without any complains. Could someone do a final review of this to get this committed?

tim-diels’s picture

StatusFileSize
new3.51 KB

For the people who still need this for the 2.x branch I created a patch from the MR.

tim-diels’s picture

StatusFileSize
new4.05 KB

And one for 3.x for composer usage.

sanduhrs’s picture

  • sanduhrs committed e577b77d on 3.x authored by tim-diels
    Issue #3005964 by tim-diels, awolfey: Move Glossify tip sanitizing to...
sanduhrs’s picture

Status: Needs review » Fixed

Merged, thanks!

awolfey’s picture

Thank you!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.