Skip to content

Commit

Permalink
Temporary disable hightlight on large page (due to performance issue)
Browse files Browse the repository at this point in the history
  • Loading branch information
loicsapone committed May 2, 2024
1 parent 04420fb commit 2143df4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/Twig/HighlightExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class HighlightExtension extends AbstractExtension
public function getFilters(): array
{
return [
new TwigFilter('iq2i_storia_highlight', [$this, 'highlight']),
new TwigFilter('iq2i_storia_highlight', [$this, 'highlight'], ['is_safe' => ['html']]),
];
}

Expand Down
28 changes: 13 additions & 15 deletions templates/view.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,9 @@

<div>
<div id="twig" class="group" data-controller="copy-to-clipboard" data-copy-to-clipboard-content-value="{{ view.currentVariant.twigContent }}" data-tab-target="tabPanel">
<div class="code">
<pre>
{{- view.currentVariant.twigContent|iq2i_storia_highlight('twig')|raw -}}
</pre>
</div>
<div class="code"><pre>
{{- view.currentVariant.twigContent|iq2i_storia_highlight('twig') -}}
</pre></div>

<button type="button" class="copy--link" data-action="copy-to-clipboard#copy">
<svg data-copy-to-clipboard-target="svg" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="#ffffff" viewBox="0 0 256 256"><path d="M216,34H88a6,6,0,0,0-6,6V82H40a6,6,0,0,0-6,6V216a6,6,0,0,0,6,6H168a6,6,0,0,0,6-6V174h42a6,6,0,0,0,6-6V40A6,6,0,0,0,216,34ZM162,210H46V94H162Zm48-48H174V88a6,6,0,0,0-6-6H94V46H210Z"></path></svg>
Expand All @@ -153,11 +151,13 @@
</div>

<div id="html" class="group hidden" data-controller="copy-to-clipboard" data-copy-to-clipboard-content-value="{{ view.currentVariant.htmlContent }}" data-tab-target="tabPanel">
<div class="code">
<pre>
{{- view.currentVariant.htmlContent|iq2i_storia_highlight('html')|raw -}}
</pre>
</div>
<div class="code"><pre>
{% if view.currentVariant.htmlContent|length <= 5000 %}
{{- view.currentVariant.htmlContent|iq2i_storia_highlight('html') -}}
{% else %}
{{- view.currentVariant.htmlContent -}}
{% endif %}
</pre></div>

<button type="button" class="copy--link" data-action="copy-to-clipboard#copy">
<svg data-copy-to-clipboard-target="svg" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="#ffffff" viewBox="0 0 256 256"><path d="M216,34H88a6,6,0,0,0-6,6V82H40a6,6,0,0,0-6,6V216a6,6,0,0,0,6,6H168a6,6,0,0,0,6-6V174h42a6,6,0,0,0,6-6V40A6,6,0,0,0,216,34ZM162,210H46V94H162Zm48-48H174V88a6,6,0,0,0-6-6H94V46H210Z"></path></svg>
Expand All @@ -167,11 +167,9 @@

{% if view.currentVariant.includeContent is not null %}
<div id="include" class="group" data-controller="copy-to-clipboard" data-copy-to-clipboard-content-value="{{ view.currentVariant.includeContent }}" data-tab-target="tabPanel">
<div class="code">
<pre>
{{- view.currentVariant.includeContent|iq2i_storia_highlight('twig')|raw -}}
</pre>
</div>
<div class="code"><pre>
{{- view.currentVariant.includeContent|iq2i_storia_highlight('twig')|raw -}}
</pre></div>

<button type="button" class="copy--link" data-action="copy-to-clipboard#copy">
<svg data-copy-to-clipboard-target="svg" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="#ffffff" viewBox="0 0 256 256"><path d="M216,34H88a6,6,0,0,0-6,6V82H40a6,6,0,0,0-6,6V216a6,6,0,0,0,6,6H168a6,6,0,0,0,6-6V174h42a6,6,0,0,0,6-6V40A6,6,0,0,0,216,34ZM162,210H46V94H162Zm48-48H174V88a6,6,0,0,0-6-6H94V46H210Z"></path></svg>
Expand Down

0 comments on commit 2143df4

Please sign in to comment.