mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-21 21:23:30 +02:00
move highlight.js to npm/webpack (#10011)
- introduced window.config to help with js-based lazy-loading - adjusted webpack chunk naming to avoid 'vendors~name.js' that webpack defaults to for vendor chunks. - added theme class to html and prefixed all selectors. this is neccesary so that the theme styles win over the lazy-loaded ones. Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
1 parent
d879353632
commit
b9690d7c0b
16 files changed
+53
-254
No files matched your search
@@ -19,7 +19,6 @@ globals:
|
||||
CodeMirror: false
|
||||
Dropzone: false
|
||||
emojify: false
|
||||
hljs: false
|
||||
SimpleMDE: false
|
||||
u2fApi: false
|
||||
Vue: false
|
||||
|
||||
Generated
+5
@@ -7341,6 +7341,11 @@
|
||||
"integrity": "sha512-l9sfDFsuqtOqKDsQdqrMRk0U85RZc0RtOR9yPI7mRVOa4FsR/BVnZ0shmQRM96Ji99kYZP/7hn1cedc1+ApsTQ==",
|
||||
"dev": true
|
||||
},
|
||||
"highlight.js": {
|
||||
"version": "9.18.0",
|
||||
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.18.0.tgz",
|
||||
"integrity": "sha512-A97kI1KAUzKoAiEoaGcf2O9YPS8nbDTCRFokaaeBhnqjQTvbAuAJrQMm21zw8s8xzaMtCQBtgbyGXLGxdxQyqQ=="
|
||||
},
|
||||
"hmac-drbg": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz",
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"fomantic-ui": "2.8.3",
|
||||
"highlight.js": "9.18.0",
|
||||
"jquery": "3.4.1",
|
||||
"jquery-migrate": "3.1.0",
|
||||
"swagger-ui": "3.24.3",
|
||||
|
||||
Vendored
+2
-2
@@ -26,8 +26,8 @@ Version: 1.1.0
|
||||
File(s): /vendor/plugins/dropzone/dropzone.js
|
||||
Version: 4.2.0
|
||||
|
||||
File(s): /vendor/plugins/highlight/highlight.pack.js
|
||||
Version: 2b46620c9d62e9becf5f25969b5ccc41fa1da470
|
||||
File(s): /js/highlight.js
|
||||
Version: 9.18.0
|
||||
|
||||
File(s): /vendor/plugins/jquery.datetimepicker/jquery.datetimepicker.js
|
||||
Version: 2.4.5
|
||||
|
||||
Vendored
+2
-2
@@ -66,9 +66,9 @@
|
||||
<td><a href="https://github.com/enyo/dropzone/archive/v4.2.0.tar.gz">dropzone.js-4.2.0.tar.gz</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./plugins/highlight/highlight.pack.js">highlight.pack.js</a></td>
|
||||
<td><a href="./highlight.js">highlight.js</a></td>
|
||||
<td><a href="https://github.com/highlightjs/highlight.js/blob/master/LICENSE">BSD 3-Clause</a></td>
|
||||
<td><a href="https://github.com/highlightjs/highlight.js/archive/2b46620c.tar.gz">highlight.js-2b46620c.tar.gz</a></td>
|
||||
<td><a href="https://github.com/highlightjs/highlight.js/archive/9.18.0.tar.gz">highlight.js.tar.gz</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./plugins/jquery.datetimepicker/jquery.datetimepicker.js">jquery.datetimepicker.js</a></td>
|
||||
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
Copyright (c) 2006, Ivan Sagalaev
|
||||
All rights reserved.
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of highlight.js nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
-99
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
|
||||
Original highlight.js style (c) Ivan Sagalaev <maniac@softwaremaniacs.org>
|
||||
|
||||
*/
|
||||
|
||||
.hljs {
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
padding: 0.5em;
|
||||
background: #F0F0F0;
|
||||
}
|
||||
|
||||
|
||||
/* Base color: saturation 0; */
|
||||
|
||||
.hljs,
|
||||
.hljs-subst {
|
||||
color: #444;
|
||||
}
|
||||
|
||||
.hljs-comment {
|
||||
color: #888888;
|
||||
}
|
||||
|
||||
.hljs-keyword,
|
||||
.hljs-attribute,
|
||||
.hljs-selector-tag,
|
||||
.hljs-meta-keyword,
|
||||
.hljs-doctag,
|
||||
.hljs-name {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
||||
/* User color: hue: 0 */
|
||||
|
||||
.hljs-type,
|
||||
.hljs-string,
|
||||
.hljs-number,
|
||||
.hljs-selector-id,
|
||||
.hljs-selector-class,
|
||||
.hljs-quote,
|
||||
.hljs-template-tag,
|
||||
.hljs-deletion {
|
||||
color: #880000;
|
||||
}
|
||||
|
||||
.hljs-title,
|
||||
.hljs-section {
|
||||
color: #880000;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.hljs-regexp,
|
||||
.hljs-symbol,
|
||||
.hljs-variable,
|
||||
.hljs-template-variable,
|
||||
.hljs-link,
|
||||
.hljs-selector-attr,
|
||||
.hljs-selector-pseudo {
|
||||
color: #BC6060;
|
||||
}
|
||||
|
||||
|
||||
/* Language color: hue: 90; */
|
||||
|
||||
.hljs-literal {
|
||||
color: #78A960;
|
||||
}
|
||||
|
||||
.hljs-built_in,
|
||||
.hljs-bullet,
|
||||
.hljs-code,
|
||||
.hljs-addition {
|
||||
color: #397300;
|
||||
}
|
||||
|
||||
|
||||
/* Meta color: hue: 200 */
|
||||
|
||||
.hljs-meta {
|
||||
color: #1f7199;
|
||||
}
|
||||
|
||||
.hljs-meta-string {
|
||||
color: #4d99bf;
|
||||
}
|
||||
|
||||
|
||||
/* Misc effects */
|
||||
|
||||
.hljs-emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.hljs-strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
-99
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
|
||||
github.com style (c) Vasily Polovnyov <vast@whiteants.net>
|
||||
|
||||
*/
|
||||
|
||||
.hljs {
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
padding: 0.5em;
|
||||
color: #333;
|
||||
background: #f8f8f8;
|
||||
}
|
||||
|
||||
.hljs-comment,
|
||||
.hljs-quote {
|
||||
color: #998;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.hljs-keyword,
|
||||
.hljs-selector-tag,
|
||||
.hljs-subst {
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.hljs-number,
|
||||
.hljs-literal,
|
||||
.hljs-variable,
|
||||
.hljs-template-variable,
|
||||
.hljs-tag .hljs-attr {
|
||||
color: #008080;
|
||||
}
|
||||
|
||||
.hljs-string,
|
||||
.hljs-doctag {
|
||||
color: #d14;
|
||||
}
|
||||
|
||||
.hljs-title,
|
||||
.hljs-section,
|
||||
.hljs-selector-id {
|
||||
color: #900;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.hljs-subst {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.hljs-type,
|
||||
.hljs-class .hljs-title {
|
||||
color: #458;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.hljs-tag,
|
||||
.hljs-name,
|
||||
.hljs-attribute {
|
||||
color: #000080;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.hljs-regexp,
|
||||
.hljs-link {
|
||||
color: #009926;
|
||||
}
|
||||
|
||||
.hljs-symbol,
|
||||
.hljs-bullet {
|
||||
color: #990073;
|
||||
}
|
||||
|
||||
.hljs-built_in,
|
||||
.hljs-builtin-name {
|
||||
color: #0086b3;
|
||||
}
|
||||
|
||||
.hljs-meta {
|
||||
color: #999;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.hljs-deletion {
|
||||
background: #fdd;
|
||||
}
|
||||
|
||||
.hljs-addition {
|
||||
background: #dfd;
|
||||
}
|
||||
|
||||
.hljs-emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.hljs-strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
/*! highlight.js v9.15.6 | BSD3 License | git.io/hljslicense */
|
||||
!function(e){var t="object"==typeof window&&window||"object"==typeof self&&self;"undefined"!=typeof exports?e(exports):t&&(t.hljs=e({}),"function"==typeof define&&define.amd&&define([],function(){return t.hljs}))}(function(i){var p=[],l=Object.keys,b={},m={},t=/^(no-?highlight|plain|text)$/i,u=/\blang(?:uage)?-([\w-]+)\b/i,r=/((^(<[^>]+>|\t|)+|(?:\n)))/gm,a={case_insensitive:"cI",lexemes:"l",contains:"c",keywords:"k",subLanguage:"sL",className:"cN",begin:"b",beginKeywords:"bK",end:"e",endsWithParent:"eW",illegal:"i",excludeBegin:"eB",excludeEnd:"eE",returnBegin:"rB",returnEnd:"rE",relevance:"r",variants:"v",IDENT_RE:"IR",UNDERSCORE_IDENT_RE:"UIR",NUMBER_RE:"NR",C_NUMBER_RE:"CNR",BINARY_NUMBER_RE:"BNR",RE_STARTERS_RE:"RSR",BACKSLASH_ESCAPE:"BE",APOS_STRING_MODE:"ASM",QUOTE_STRING_MODE:"QSM",PHRASAL_WORDS_MODE:"PWM",C_LINE_COMMENT_MODE:"CLCM",C_BLOCK_COMMENT_MODE:"CBCM",HASH_COMMENT_MODE:"HCM",NUMBER_MODE:"NM",C_NUMBER_MODE:"CNM",BINARY_NUMBER_MODE:"BNM",CSS_NUMBER_MODE:"CSSNM",REGEXP_MODE:"RM",TITLE_MODE:"TM",UNDERSCORE_TITLE_MODE:"UTM",COMMENT:"C",beginRe:"bR",endRe:"eR",illegalRe:"iR",lexemesRe:"lR",terminators:"t",terminator_end:"tE"},T="</span>",C={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0};function f(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function S(e){return e.nodeName.toLowerCase()}function R(e,t){var r=e&&e.exec(t);return r&&0===r.index}function E(e){return t.test(e)}function c(e){var t,r={},a=Array.prototype.slice.call(arguments,1);for(t in e)r[t]=e[t];return a.forEach(function(e){for(t in e)r[t]=e[t]}),r}function g(e){var i=[];return function e(t,r){for(var a=t.firstChild;a;a=a.nextSibling)3===a.nodeType?r+=a.nodeValue.length:1===a.nodeType&&(i.push({event:"start",offset:r,node:a}),r=e(a,r),S(a).match(/br|hr|img|input/)||i.push({event:"stop",offset:r,node:a}));return r}(e,0),i}function o(e){if(a&&!e.langApiRestored){for(var t in e.langApiRestored=!0,a)e[t]&&(e[a[t]]=e[t]);(e.c||[]).concat(e.v||[]).forEach(o)}}function N(n){function _(e){return e&&e.source||e}function s(e,t){return new RegExp(_(e),"m"+(n.cI?"i":"")+(t?"g":""))}!function t(r,e){if(!r.compiled){if(r.compiled=!0,r.k=r.k||r.bK,r.k){var a={},i=function(r,e){n.cI&&(e=e.toLowerCase()),e.split(" ").forEach(function(e){var t=e.split("|");a[t[0]]=[r,t[1]?Number(t[1]):1]})};"string"==typeof r.k?i("keyword",r.k):l(r.k).forEach(function(e){i(e,r.k[e])}),r.k=a}r.lR=s(r.l||/\w+/,!0),e&&(r.bK&&(r.b="\\b("+r.bK.split(" ").join("|")+")\\b"),r.b||(r.b=/\B|\b/),r.bR=s(r.b),r.endSameAsBegin&&(r.e=r.b),r.e||r.eW||(r.e=/\B|\b/),r.e&&(r.eR=s(r.e)),r.tE=_(r.e)||"",r.eW&&e.tE&&(r.tE+=(r.e?"|":"")+e.tE)),r.i&&(r.iR=s(r.i)),null==r.r&&(r.r=1),r.c||(r.c=[]),r.c=Array.prototype.concat.apply([],r.c.map(function(e){return(t="self"===e?r:e).v&&!t.cached_variants&&(t.cached_variants=t.v.map(function(e){return c(t,{v:null},e)})),t.cached_variants||t.eW&&[c(t)]||[t];var t})),r.c.forEach(function(e){t(e,r)}),r.starts&&t(r.starts,e);var o=r.c.map(function(e){return e.bK?"\\.?(?:"+e.b+")\\.?":e.b}).concat([r.tE,r.i]).map(_).filter(Boolean);r.t=o.length?s(function(e,t){for(var r=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./,a=0,i="",o=0;o<e.length;o++){var n=a,s=_(e[o]);for(0<o&&(i+=t);0<s.length;){var l=r.exec(s);if(null==l){i+=s;break}i+=s.substring(0,l.index),s=s.substring(l.index+l[0].length),"\\"==l[0][0]&&l[1]?i+="\\"+String(Number(l[1])+n):(i+=l[0],"("==l[0]&&a++)}}return i}(o,"|"),!0):{exec:function(){return null}}}}(n)}function I(e,t,s,r){function l(e,t,r,a){var i='<span class="'+(a?"":C.classPrefix);return(i+=e+'">')+t+(r?"":T)}function _(){m+=null!=p.sL?function(){var e="string"==typeof p.sL;if(e&&!b[p.sL])return f(u);var t=e?I(p.sL,u,!0,o[p.sL]):O(u,p.sL.length?p.sL:void 0);return 0<p.r&&(S+=t.r),e&&(o[p.sL]=t.top),l(t.language,t.value,!1,!0)}():function(){var e,t,r,a,i,o,n;if(!p.k)return f(u);for(a="",t=0,p.lR.lastIndex=0,r=p.lR.exec(u);r;)a+=f(u.substring(t,r.index)),i=p,o=r,n=d.cI?o[0].toLowerCase():o[0],(e=i.k.hasOwnProperty(n)&&i.k[n])?(S+=e[1],a+=l(e[0],f(r[0]))):a+=f(r[0]),t=p.lR.lastIndex,r=p.lR.exec(u);return a+f(u.substr(t))}(),u=""}function c(e){m+=e.cN?l(e.cN,"",!0):"",p=Object.create(e,{parent:{value:p}})}function a(e,t){if(u+=e,null==t)return _(),0;var r=function(e,t){var r,a,i;for(r=0,a=t.c.length;r<a;r++)if(R(t.c[r].bR,e))return t.c[r].endSameAsBegin&&(t.c[r].eR=(i=t.c[r].bR.exec(e)[0],new RegExp(i.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"m"))),t.c[r]}(t,p);if(r)return r.skip?u+=t:(r.eB&&(u+=t),_(),r.rB||r.eB||(u=t)),c(r),r.rB?0:t.length;var a,i,o=function e(t,r){if(R(t.eR,r)){for(;t.endsParent&&t.parent;)t=t.parent;return t}if(t.eW)return e(t.parent,r)}(p,t);if(o){var n=p;for(n.skip?u+=t:(n.rE||n.eE||(u+=t),_(),n.eE&&(u=t));p.cN&&(m+=T),p.skip||p.sL||(S+=p.r),(p=p.parent)!==o.parent;);return o.starts&&(o.endSameAsBegin&&(o.starts.eR=o.eR),c(o.starts)),n.rE?0:t.length}if(a=t,i=p,!s&&R(i.iR,a))throw new Error('Illegal lexeme "'+t+'" for mode "'+(p.cN||"<unnamed>")+'"');return u+=t,t.lLine truncated
|
||||
@@ -24,9 +24,6 @@
|
||||
{{end}}
|
||||
|
||||
<!-- Third-party libraries -->
|
||||
{{if .RequireHighlightJS}}
|
||||
<script src="{{StaticUrlPrefix}}/vendor/plugins/highlight/highlight.pack.js"></script>
|
||||
{{end}}
|
||||
{{if .RequireMinicolors}}
|
||||
<script src="{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.min.js"></script>
|
||||
{{end}}
|
||||
|
||||
@@ -83,6 +83,17 @@
|
||||
for the JavaScript code in this page.
|
||||
*/`}}
|
||||
</script>
|
||||
<script>
|
||||
window.config = {
|
||||
Datetimepicker: {{if .RequireDatetimepicker}}true{{else}}false{{end}},
|
||||
Dropzone: {{if .RequireDropzone}}true{{else}}false{{end}},
|
||||
HighlightJS: {{if .RequireHighlightJS}}true{{else}}false{{end}},
|
||||
Minicolors: {{if .RequireMinicolors}}true{{else}}false{{end}},
|
||||
SimpleMDE: {{if .RequireSimpleMDE}}true{{else}}false{{end}},
|
||||
Tribute: {{if .RequireTribute}}true{{else}}false{{end}},
|
||||
U2F: {{if .RequireU2F}}true{{else}}false{{end}},
|
||||
};
|
||||
</script>
|
||||
<link rel="shortcut icon" href="{{StaticUrlPrefix}}/img/favicon.png">
|
||||
<link rel="apple-touch-icon" href="{{StaticUrlPrefix}}/img/favicon.png">
|
||||
<link rel="mask-icon" href="{{StaticUrlPrefix}}/img/gitea-safari.svg" color="#609926">
|
||||
@@ -106,10 +117,6 @@
|
||||
.ui.secondary.menu .dropdown.item > .menu { margin-top: 0; }
|
||||
</style>
|
||||
</noscript>
|
||||
|
||||
{{if .RequireHighlightJS}}
|
||||
<link rel="stylesheet" href="{{StaticUrlPrefix}}/vendor/plugins/highlight/github.css">
|
||||
{{end}}
|
||||
{{if .RequireMinicolors}}
|
||||
<link rel="stylesheet" href="{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.css">
|
||||
{{end}}
|
||||
|
||||
@@ -3,6 +3,7 @@ var urlsToCache = [
|
||||
// js
|
||||
'{{StaticUrlPrefix}}/fomantic/semantic.min.js?v={{MD5 AppVer}}',
|
||||
'{{StaticUrlPrefix}}/js/gitgraph.js',
|
||||
'{{StaticUrlPrefix}}/js/highlight.js',
|
||||
'{{StaticUrlPrefix}}/js/index.js?v={{MD5 AppVer}}',
|
||||
'{{StaticUrlPrefix}}/js/jquery.js?v={{MD5 AppVer}}',
|
||||
'{{StaticUrlPrefix}}/js/swagger.js?v={{MD5 AppVer}}',
|
||||
@@ -11,7 +12,6 @@ var urlsToCache = [
|
||||
'{{StaticUrlPrefix}}/vendor/plugins/codemirror/mode/meta.js',
|
||||
'{{StaticUrlPrefix}}/vendor/plugins/dropzone/dropzone.js',
|
||||
'{{StaticUrlPrefix}}/vendor/plugins/emojify/emojify.custom.js',
|
||||
'{{StaticUrlPrefix}}/vendor/plugins/highlight/highlight.pack.js',
|
||||
'{{StaticUrlPrefix}}/vendor/plugins/jquery.areyousure/jquery.are-you-sure.js',
|
||||
'{{StaticUrlPrefix}}/vendor/plugins/jquery.datetimepicker/jquery.datetimepicker.js',
|
||||
'{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.min.js',
|
||||
@@ -20,13 +20,13 @@ var urlsToCache = [
|
||||
|
||||
// css
|
||||
'{{StaticUrlPrefix}}/css/gitgraph.css',
|
||||
'{{StaticUrlPrefix}}/css/highlight.css',
|
||||
'{{StaticUrlPrefix}}/css/index.css?v={{MD5 AppVer}}',
|
||||
'{{StaticUrlPrefix}}/css/swagger.css?v={{MD5 AppVer}}',
|
||||
'{{StaticUrlPrefix}}/fomantic/semantic.min.css?v={{MD5 AppVer}}',
|
||||
'{{StaticUrlPrefix}}/vendor/assets/font-awesome/css/font-awesome.min.css',
|
||||
'{{StaticUrlPrefix}}/vendor/assets/octicons/octicons.min.css',
|
||||
'{{StaticUrlPrefix}}/vendor/plugins/dropzone/dropzone.css',
|
||||
'{{StaticUrlPrefix}}/vendor/plugins/highlight/github.css',
|
||||
'{{StaticUrlPrefix}}/vendor/plugins/jquery.datetimepicker/jquery.datetimepicker.css',
|
||||
'{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.css',
|
||||
'{{StaticUrlPrefix}}/vendor/plugins/simplemde/simplemde.min.css',
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
export default async function initHighlight() {
|
||||
if (!window.config || !window.config.HighlightJS) return;
|
||||
|
||||
const hljs = await import(/* webpackChunkName: "highlight" */'highlight.js');
|
||||
|
||||
const nodes = [].slice.call(document.querySelectorAll('pre code') || []);
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
hljs.highlightBlock(nodes[i]);
|
||||
}
|
||||
|
||||
return hljs;
|
||||
}
|
||||
+8
-10
@@ -6,7 +6,8 @@ import './publicPath.js';
|
||||
import './polyfills.js';
|
||||
import './gitGraphLoader.js';
|
||||
import './semanticDropdown.js';
|
||||
import initContextPopups from './features/contextPopup';
|
||||
import initContextPopups from './features/contextPopup.js';
|
||||
import initHighlight from './features/highlight.js';
|
||||
|
||||
import ActivityTopAuthors from './components/ActivityTopAuthors.vue';
|
||||
|
||||
@@ -20,6 +21,7 @@ let previewFileModes;
|
||||
let simpleMDEditor;
|
||||
const commentMDEditors = {};
|
||||
let codeMirrorEditor;
|
||||
let hljs;
|
||||
|
||||
// Disable Dropzone auto-discover because it's manually initialized
|
||||
if (typeof (Dropzone) !== 'undefined') {
|
||||
@@ -2318,7 +2320,7 @@ function initTemplateSearch() {
|
||||
changeOwner();
|
||||
}
|
||||
|
||||
$(document).ready(() => {
|
||||
$(document).ready(async () => {
|
||||
csrf = $('meta[name=_csrf]').attr('content');
|
||||
suburl = $('meta[name=_suburl]').attr('content');
|
||||
|
||||
@@ -2370,14 +2372,6 @@ $(document).ready(() => {
|
||||
window.location = $(this).data('href');
|
||||
});
|
||||
|
||||
// Highlight JS
|
||||
if (typeof hljs !== 'undefined') {
|
||||
const nodes = [].slice.call(document.querySelectorAll('pre code') || []);
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
hljs.highlightBlock(nodes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Dropzone
|
||||
const $dropzone = $('#dropzone');
|
||||
if ($dropzone.length > 0) {
|
||||
@@ -2591,6 +2585,10 @@ $(document).ready(() => {
|
||||
$repoName.val($cloneAddr.val().match(/^(.*\/)?((.+?)(\.git)?)$/)[3]);
|
||||
}
|
||||
});
|
||||
|
||||
[hljs] = await Promise.all([
|
||||
initHighlight(),
|
||||
]);
|
||||
});
|
||||
|
||||
function changeHash(hash) {
|
||||
|
||||
@@ -13,3 +13,4 @@
|
||||
@import "_admin";
|
||||
@import "_explore";
|
||||
@import "_review";
|
||||
@import "~highlight.js/styles/github.css";
|
||||
+9
-5
@@ -65,6 +65,10 @@ module.exports = {
|
||||
},
|
||||
}),
|
||||
],
|
||||
splitChunks: {
|
||||
chunks: 'async',
|
||||
name: (_, chunks) => chunks.map((item) => item.name).join('-'),
|
||||
}
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
@@ -142,10 +146,8 @@ module.exports = {
|
||||
}),
|
||||
new SourceMapDevToolPlugin({
|
||||
filename: 'js/[name].js.map',
|
||||
exclude: [
|
||||
'js/gitgraph.js',
|
||||
'js/jquery.js',
|
||||
'js/swagger.js',
|
||||
include: [
|
||||
'js/index.js',
|
||||
],
|
||||
}),
|
||||
],
|
||||
@@ -153,7 +155,9 @@ module.exports = {
|
||||
maxEntrypointSize: 512000,
|
||||
maxAssetSize: 512000,
|
||||
assetFilter: (filename) => {
|
||||
return !filename.endsWith('.map') && filename !== 'js/swagger.js';
|
||||
if (filename.endsWith('.map')) return false;
|
||||
if (['js/swagger.js', 'js/highlight.js'].includes(filename)) return false;
|
||||
return true;
|
||||
},
|
||||
},
|
||||
resolve: {
|
||||
|
||||
Reference in new issue
Block a user