mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: fix #131
This commit is contained in:
1 parent
455f0dc274
commit
a5e3cf2c9b
5 files changed
+15
-65
No files matched your search
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user