diff --git a/packages/ui-default/backendlib/markdown.js b/packages/ui-default/backendlib/markdown.js index 04272214c..15e26fa3d 100644 --- a/packages/ui-default/backendlib/markdown.js +++ b/packages/ui-default/backendlib/markdown.js @@ -24,8 +24,6 @@ const Anchor = require('markdown-it-anchor'); const Media = require('./markdown-it-media'); const Katex = require('./markdown-it-katex'); -require('prismjs/components/index'); - class Markdown extends MarkdownIt { constructor() { super({ diff --git a/packages/ui-default/components/highlighter/highlighter.page.js b/packages/ui-default/components/highlighter/highlighter.page.js index 780ba9efc..3691193e6 100644 --- a/packages/ui-default/components/highlighter/highlighter.page.js +++ b/packages/ui-default/components/highlighter/highlighter.page.js @@ -23,11 +23,11 @@ const highlighterPage = new AutoloadPage('highlighterPage', async () => { const $output = $container.find(`pre.language-output${id}`); if ($output.length) { const $c = $(document.createElement('div')).addClass('row'); - $root.clone(true).prepend($(tpl`

${i18n('Sample Input')} ${id}

`)) + $root.after($c); + $root.prepend($(tpl`

${i18n('Sample Input')} ${id}

`)) .addClass('medium-6 columns sample').appendTo($c); $output.parent().prepend($(tpl`

${i18n('Sample Output')} ${id}

`)) .addClass('medium-6 columns sample').appendTo($c); - $root.replaceWith($c); } } } diff --git a/packages/ui-default/components/highlighter/prismjs.js b/packages/ui-default/components/highlighter/prismjs.js index ed1ad97de..09492b2c2 100644 --- a/packages/ui-default/components/highlighter/prismjs.js +++ b/packages/ui-default/components/highlighter/prismjs.js @@ -33,23 +33,19 @@ languageMeta.forEach((meta) => { }); // Copy to Clipboard -try { - Prism.plugins.toolbar.registerButton('copy-to-clipboard', (env) => { - const linkCopy = document.createElement('a'); - linkCopy.href = 'javascript:;'; // eslint-disable-line no-script-url - linkCopy.textContent = 'Copy'; - const clip = new Clipboard(linkCopy, { text: () => env.code }); - clip.on('success', () => { - Notification.success(i18n('Content copied to clipboard!'), 1000); - }); - clip.on('error', () => { - Notification.error(i18n('Copy failed :(')); - }); - return linkCopy; +Prism.plugins.toolbar.registerButton('copy-to-clipboard', (env) => { + const linkCopy = document.createElement('a'); + linkCopy.href = 'javascript:;'; // eslint-disable-line no-script-url + linkCopy.textContent = 'Copy'; + const clip = new Clipboard(linkCopy, { text: () => env.code }); + clip.on('success', () => { + Notification.success(i18n('Content copied to clipboard!'), 1000); }); -} catch (e) { - // snowpack -} + clip.on('error', () => { + Notification.error(i18n('Copy failed :(')); + }); + return linkCopy; +}); const invisibles = { tab: /\t/, @@ -90,7 +86,6 @@ function handlerInvisiblesToken(tokens, name) { } Prism.hooks.add('before-highlight', (env) => { - console.log(UserContext.showInvisibleChar); if (UserContext.showInvisibleChar) addInvisibles(env.grammar); }); diff --git a/packages/ui-default/package.json b/packages/ui-default/package.json index e63fa2c3e..d64481778 100644 --- a/packages/ui-default/package.json +++ b/packages/ui-default/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/ui-default", - "version": "4.6.30", + "version": "4.6.31", "author": "undefined ", "license": "AGPL-3.0", "main": "hydro.js", diff --git a/packages/ui-default/snowpack.config.js b/packages/ui-default/snowpack.config.js deleted file mode 100644 index e7c363e2b..000000000 --- a/packages/ui-default/snowpack.config.js +++ /dev/null @@ -1,43 +0,0 @@ -const httpProxy = require('http-proxy'); -const fs = require('fs'); - -const reactRefreshLoc = require.resolve('react-refresh/cjs/react-refresh-runtime.development.js'); -const reactRefreshCode = ` -function d(e,t){let u;return()=>{clearTimeout(u),u=setTimeout(e,t)}}; -{ const exports = {}; -exports.performReactRefresh=d(exports.performReactRefresh,30);\ -${fs.readFileSync(reactRefreshLoc, { encoding: 'utf-8' }) - .replace('process.env.NODE_ENV', JSON.stringify('development'))} -window.$RefreshRuntime$=exports;\ -window.$RefreshRuntime$.injectIntoGlobalHook(window);\ -window.$RefreshReg$=()=>{};\ -window.$RefreshSig$=()=>t=>t; }`; - -const proxy = httpProxy.createServer({ target: 'http://localhost:2333' }); -const dest = (req, res) => proxy.web(req, res, undefined, (e) => console.error(e.message)); -const refresh = (req, res) => { - res.write(reactRefreshCode); - res.end(); -}; -const hmr = async (req, res) => { - // eslint-disable-next-line no-multi-str - req.headers.hmr = Buffer.from('').toString('base64'); - proxy.web(req, res, undefined, (e) => console.error(e.message)); -}; - -module.exports = { - entry: 'hydro.js', - env: process.env, - plugins: [ - ['./build/plugins/require-context.snowpack', { input: ['misc/PageLoader.js'] }], - './build/plugins/provide.snowpack', - '@snowpack/plugin-react-refresh', - ], - alias: { vj: __dirname }, - routes: [ - ['/.*', 'routes', hmr], - ['/react-refresh\\.js', 'all', refresh], - ['.+\\.(png|css|json|woff2|woff|ttf)', 'all'], - ['(/ui-constants\\.js|/locale/.*)', 'all'], - ].map(([src, match, handle]) => ({ src, match, dest: handle || dest })), -};