Get a11y lint script paths from rails helper (#13912)
* retrieve paths from rails helper * move assets to vendor folder, precompile in assets config * drop coverage on lines * remove unneeded line
This commit is contained in:
parent
727aba3054
commit
8358571b29
7 changed files with 14 additions and 6 deletions
|
|
@ -200,17 +200,22 @@ export class ArticleForm extends Component {
|
|||
|
||||
fetchMarkdownLint = async () => {
|
||||
if (!window.markdownlint) {
|
||||
const pathDataElement = document.getElementById('markdown-lint-js-path');
|
||||
if (!pathDataElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Retrieve the correct fingerprinted URL for the scripts
|
||||
const { markdownItJsPath, markdownLintJsPath } = pathDataElement.dataset;
|
||||
|
||||
const markdownItScript = document.createElement('script');
|
||||
markdownItScript.setAttribute('src', '/assets/markdown-it.min.js');
|
||||
markdownItScript.setAttribute('src', markdownItJsPath);
|
||||
document.body.appendChild(markdownItScript);
|
||||
|
||||
// The markdownlint script needs the first script to have finished loading first
|
||||
markdownItScript.addEventListener('load', () => {
|
||||
const markdownLintScript = document.createElement('script');
|
||||
markdownLintScript.setAttribute(
|
||||
'src',
|
||||
'/assets/markdownlint-browser.min.js',
|
||||
);
|
||||
markdownLintScript.setAttribute('src', markdownLintJsPath);
|
||||
document.body.appendChild(markdownLintScript);
|
||||
|
||||
markdownLintScript.addEventListener('load', this.lintMarkdown);
|
||||
|
|
|
|||
|
|
@ -31,3 +31,4 @@
|
|||
<%= render "articles/v2_form", article: @article, organizations: @organizations, version: @version %>
|
||||
|
||||
<%= javascript_packs_with_chunks_tag "clipboardCopy", "articleForm", defer: true %>
|
||||
<div id="markdown-lint-js-path" class="hidden" data-markdown-it-js-path="<%= asset_path("markdown-it.min.js") %>" data-markdown-lint-js-path="<%= asset_path("markdownlint-browser.min.js") %>">
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
<%= render "shared/webcomponents_loader_script" %>
|
||||
<%= render "articles/v2_form", article: @article, organizations: @organizations, version: @version %>
|
||||
<%= javascript_packs_with_chunks_tag "clipboardCopy", "articleForm", defer: true %>
|
||||
<div id="markdown-lint-js-path" class="hidden" data-markdown-it-js-path="<%= asset_path("markdown-it.min.js") %>" data-markdown-lint-js-path="<%= asset_path("markdownlint-browser.min.js") %>">
|
||||
<% else %>
|
||||
<% @new_article_not_logged_in = true %>
|
||||
<%= render "devise/registrations/registration_form" %>
|
||||
|
|
|
|||
|
|
@ -14,4 +14,5 @@ Rails.application.config.assets.paths << Rails.root.join("app/assets/xml")
|
|||
# Precompile additional assets.
|
||||
# application.js, application.css, and all non-JS/CSS in the app/assets
|
||||
# folder are already added.
|
||||
Rails.application.config.assets.precompile += %w[markdown-it.min.js markdownlint-browser.min.js]
|
||||
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ module.exports = {
|
|||
statements: 42,
|
||||
branches: 38,
|
||||
functions: 41,
|
||||
lines: 43,
|
||||
lines: 42,
|
||||
},
|
||||
},
|
||||
moduleNameMapper: {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue