From 006b15b467a5cd835a6eab1b49023100bdc8f2e6 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Fri, 13 Oct 2023 19:32:56 +0200 Subject: refactor(components): rewrite Code component and usePrism hook * move Prism styles to Sass placeholders to avoid repeats * let usePrism consumer define its plugins (remove default ones) * remove `plugins` prop from Code component * add new props to Code component to let consumer configure plugins (and handle plugin list from the given options) However there are some problems with Prism plugins: line-highlight and treeview does not seems to be loaded. I don't want to use Babel instead of SWC so I have no solution for now. --- public/prism/prism-graphql.min.js | 56 +++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'public/prism/prism-graphql.min.js') diff --git a/public/prism/prism-graphql.min.js b/public/prism/prism-graphql.min.js index be11b77..e265e1d 100644 --- a/public/prism/prism-graphql.min.js +++ b/public/prism/prism-graphql.min.js @@ -58,52 +58,52 @@ Prism.hooks.add('after-tokenize', function (n) { if ('graphql' === n.language) for ( - var o = n.tokens.filter(function (n) { + var t = n.tokens.filter(function (n) { return ( 'string' != typeof n && 'comment' !== n.type && 'scalar' !== n.type ); }), - s = 0; - s < o.length; + e = 0; + e < t.length; ) { - var t = o[s++]; - if ('keyword' === t.type && 'mutation' === t.content) { - var e = []; + var a = t[e++]; + if ('keyword' === a.type && 'mutation' === a.content) { + var r = []; if ( c(['definition-mutation', 'punctuation']) && '(' === l(1).content ) { - s += 2; - var a = f(/^\($/, /^\)$/); - if (-1 === a) continue; - for (; s < a; s++) { - var r = l(0); - 'variable' === r.type && - (b(r, 'variable-input'), e.push(r.content)); + e += 2; + var i = f(/^\($/, /^\)$/); + if (-1 === i) continue; + for (; e < i; e++) { + var o = l(0); + 'variable' === o.type && + (b(o, 'variable-input'), r.push(o.content)); } - s = a + 1; + e = i + 1; } if ( c(['punctuation', 'property-query']) && '{' === l(0).content && - (s++, b(l(0), 'property-mutation'), 0 < e.length) + (e++, b(l(0), 'property-mutation'), r.length > 0) ) { - var i = f(/^\{$/, /^\}$/); - if (-1 === i) continue; - for (var u = s; u < i; u++) { - var p = o[u]; + var s = f(/^\{$/, /^\}$/); + if (-1 === s) continue; + for (var u = e; u < s; u++) { + var p = t[u]; 'variable' === p.type && - 0 <= e.indexOf(p.content) && + r.indexOf(p.content) >= 0 && b(p, 'variable-input'); } } } } function l(n) { - return o[s + n]; + return t[e + n]; } function c(n, t) { t = t || 0; @@ -113,13 +113,13 @@ } return !0; } - function f(n, t) { - for (var e = 1, a = s; a < o.length; a++) { - var r = o[a], - i = r.content; - if ('punctuation' === r.type && 'string' == typeof i) - if (n.test(i)) e++; - else if (t.test(i) && 0 === --e) return a; + function f(n, a) { + for (var r = 1, i = e; i < t.length; i++) { + var o = t[i], + s = o.content; + if ('punctuation' === o.type && 'string' == typeof s) + if (n.test(s)) r++; + else if (a.test(s) && 0 == --r) return i; } return -1; } -- cgit v1.2.3