Skip to content
Snippets Groups Projects
Commit 6d72ebf3 authored by Kushal Pandya's avatar Kushal Pandya
Browse files

Merge branch '333514-math-diagrams' into 'master'

Uplift limit on Math diagrams on wiki pages

See merge request gitlab-org/gitlab!88375
parents 0a0c6cb9 eaa38ab9
No related branches found
No related tags found
No related merge requests found
import { spriteIcon } from '~/lib/utils/common_utils';
import { differenceInMilliseconds } from '~/lib/utils/datetime_utility';
import { s__ } from '~/locale';
import { unrestrictedPages } from './constants';
 
// Renders math using KaTeX in any element with the
// `js-render-math` class
Loading
Loading
@@ -48,6 +49,7 @@ class SafeMathRenderer {
this.renderElement = this.renderElement.bind(this);
this.render = this.render.bind(this);
this.attachEvents = this.attachEvents.bind(this);
this.pageName = document.querySelector('body').dataset.page;
}
 
renderElement(chosenEl) {
Loading
Loading
@@ -56,7 +58,7 @@ class SafeMathRenderer {
}
 
const el = chosenEl || this.queue.shift();
const forceRender = Boolean(chosenEl);
const forceRender = Boolean(chosenEl) || unrestrictedPages.includes(this.pageName);
const text = el.textContent;
 
el.removeAttribute('style');
Loading
Loading
Loading
Loading
@@ -67,4 +67,24 @@
expect(page).to have_selector('.js-lazy-render-math')
end
end
it 'renders without any limits on wiki page', :js do
description = <<~MATH
```math
\Huge \sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sq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}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
```
MATH
wiki_page = build(:wiki_page, { container: project, content: description })
wiki_page.create message: 'math test commit' # rubocop:disable Rails/SaveBang
wiki_page = project.wiki.find_page(wiki_page.slug)
visit project_wiki_path(project, wiki_page)
wait_for_requests
page.within '.js-wiki-page-content' do
expect(page).not_to have_selector('.js-lazy-render-math')
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment