mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update components
This commit is contained in:
parent
59ea1c2f7d
commit
cf577ba8eb
1136 changed files with 59263 additions and 576 deletions
70
dashboard-ui/bower_components/prism/plugins/autolinker/prism-autolinker.js
vendored
Normal file
70
dashboard-ui/bower_components/prism/plugins/autolinker/prism-autolinker.js
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
(function(){
|
||||
|
||||
if (
|
||||
typeof self !== 'undefined' && !self.Prism ||
|
||||
typeof global !== 'undefined' && !global.Prism
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
var url = /\b([a-z]{3,7}:\/\/|tel:)[\w\-+%~/.:#=?&]+/,
|
||||
email = /\b\S+@[\w.]+[a-z]{2}/,
|
||||
linkMd = /\[([^\]]+)]\(([^)]+)\)/,
|
||||
|
||||
// Tokens that may contain URLs and emails
|
||||
candidates = ['comment', 'url', 'attr-value', 'string'];
|
||||
|
||||
Prism.hooks.add('before-highlight', function(env) {
|
||||
// Abort if grammar has already been processed
|
||||
if (!env.grammar || env.grammar['url-link']) {
|
||||
return;
|
||||
}
|
||||
Prism.languages.DFS(env.grammar, function (key, def, type) {
|
||||
if (candidates.indexOf(type) > -1 && Prism.util.type(def) !== 'Array') {
|
||||
if (!def.pattern) {
|
||||
def = this[key] = {
|
||||
pattern: def
|
||||
};
|
||||
}
|
||||
|
||||
def.inside = def.inside || {};
|
||||
|
||||
if (type == 'comment') {
|
||||
def.inside['md-link'] = linkMd;
|
||||
}
|
||||
if (type == 'attr-value') {
|
||||
Prism.languages.insertBefore('inside', 'punctuation', { 'url-link': url }, def);
|
||||
}
|
||||
else {
|
||||
def.inside['url-link'] = url;
|
||||
}
|
||||
|
||||
def.inside['email-link'] = email;
|
||||
}
|
||||
});
|
||||
env.grammar['url-link'] = url;
|
||||
env.grammar['email-link'] = email;
|
||||
});
|
||||
|
||||
Prism.hooks.add('wrap', function(env) {
|
||||
if (/-link$/.test(env.type)) {
|
||||
env.tag = 'a';
|
||||
|
||||
var href = env.content;
|
||||
|
||||
if (env.type == 'email-link' && href.indexOf('mailto:') != 0) {
|
||||
href = 'mailto:' + href;
|
||||
}
|
||||
else if (env.type == 'md-link') {
|
||||
// Markdown
|
||||
var match = env.content.match(linkMd);
|
||||
|
||||
href = match[2];
|
||||
env.content = match[1];
|
||||
}
|
||||
|
||||
env.attributes.href = href;
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue