mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-21 14:13:36 +08:00
docs:更新文档
This commit is contained in:
59
node_modules/prismjs/plugins/line-highlight/prism-line-highlight.css
generated
vendored
Normal file
59
node_modules/prismjs/plugins/line-highlight/prism-line-highlight.css
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
pre[data-line] {
|
||||
position: relative;
|
||||
padding: 1em 0 1em 3em;
|
||||
}
|
||||
|
||||
.line-highlight {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding: inherit 0;
|
||||
margin-top: 1em; /* Same as .prism’s padding-top */
|
||||
|
||||
background: hsla(24, 20%, 50%,.08);
|
||||
background: linear-gradient(to right, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
|
||||
|
||||
pointer-events: none;
|
||||
|
||||
line-height: inherit;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.line-highlight:before,
|
||||
.line-highlight[data-end]:after {
|
||||
content: attr(data-start);
|
||||
position: absolute;
|
||||
top: .4em;
|
||||
left: .6em;
|
||||
min-width: 1em;
|
||||
padding: 0 .5em;
|
||||
background-color: hsla(24, 20%, 50%,.4);
|
||||
color: hsl(24, 20%, 95%);
|
||||
font: bold 65%/1.5 sans-serif;
|
||||
text-align: center;
|
||||
vertical-align: .3em;
|
||||
border-radius: 999px;
|
||||
text-shadow: none;
|
||||
box-shadow: 0 1px white;
|
||||
}
|
||||
|
||||
.line-highlight[data-end]:after {
|
||||
content: attr(data-end);
|
||||
top: auto;
|
||||
bottom: .4em;
|
||||
}
|
||||
|
||||
.line-numbers .line-highlight:before,
|
||||
.line-numbers .line-highlight:after {
|
||||
content: none;
|
||||
}
|
||||
|
||||
pre[id].linkable-line-numbers span.line-numbers-rows {
|
||||
pointer-events: all;
|
||||
}
|
||||
pre[id].linkable-line-numbers span.line-numbers-rows > span:before {
|
||||
cursor: pointer;
|
||||
}
|
||||
pre[id].linkable-line-numbers span.line-numbers-rows > span:hover:before {
|
||||
background-color: rgba(128, 128, 128, .2);
|
||||
}
|
||||
280
node_modules/prismjs/plugins/line-highlight/prism-line-highlight.js
generated
vendored
Normal file
280
node_modules/prismjs/plugins/line-highlight/prism-line-highlight.js
generated
vendored
Normal file
@@ -0,0 +1,280 @@
|
||||
(function () {
|
||||
|
||||
if (typeof self === 'undefined' || !self.Prism || !self.document || !document.querySelector) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} selector
|
||||
* @param {ParentNode} [container]
|
||||
* @returns {HTMLElement[]}
|
||||
*/
|
||||
function $$(selector, container) {
|
||||
return Array.prototype.slice.call((container || document).querySelectorAll(selector));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given element has the given class.
|
||||
*
|
||||
* @param {Element} element
|
||||
* @param {string} className
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function hasClass(element, className) {
|
||||
className = " " + className + " ";
|
||||
return (" " + element.className + " ").replace(/[\n\t]/g, " ").indexOf(className) > -1
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the given function.
|
||||
*
|
||||
* @param {() => any} func
|
||||
* @returns {void}
|
||||
*/
|
||||
function callFunction(func) {
|
||||
func();
|
||||
}
|
||||
|
||||
// Some browsers round the line-height, others don't.
|
||||
// We need to test for it to position the elements properly.
|
||||
var isLineHeightRounded = (function () {
|
||||
var res;
|
||||
return function () {
|
||||
if (typeof res === 'undefined') {
|
||||
var d = document.createElement('div');
|
||||
d.style.fontSize = '13px';
|
||||
d.style.lineHeight = '1.5';
|
||||
d.style.padding = '0';
|
||||
d.style.border = '0';
|
||||
d.innerHTML = ' <br /> ';
|
||||
document.body.appendChild(d);
|
||||
// Browsers that round the line-height should have offsetHeight === 38
|
||||
// The others should have 39.
|
||||
res = d.offsetHeight === 38;
|
||||
document.body.removeChild(d);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}());
|
||||
|
||||
/**
|
||||
* Highlights the lines of the given pre.
|
||||
*
|
||||
* This function is split into a DOM measuring and mutate phase to improve performance.
|
||||
* The returned function mutates the DOM when called.
|
||||
*
|
||||
* @param {HTMLElement} pre
|
||||
* @param {string} [lines]
|
||||
* @param {string} [classes='']
|
||||
* @returns {() => void}
|
||||
*/
|
||||
function highlightLines(pre, lines, classes) {
|
||||
lines = typeof lines === 'string' ? lines : pre.getAttribute('data-line');
|
||||
|
||||
var ranges = lines.replace(/\s+/g, '').split(',').filter(Boolean);
|
||||
var offset = +pre.getAttribute('data-line-offset') || 0;
|
||||
|
||||
var parseMethod = isLineHeightRounded() ? parseInt : parseFloat;
|
||||
var lineHeight = parseMethod(getComputedStyle(pre).lineHeight);
|
||||
var hasLineNumbers = hasClass(pre, 'line-numbers');
|
||||
var parentElement = hasLineNumbers ? pre : pre.querySelector('code') || pre;
|
||||
var mutateActions = /** @type {(() => void)[]} */ ([]);
|
||||
|
||||
ranges.forEach(function (currentRange) {
|
||||
var range = currentRange.split('-');
|
||||
|
||||
var start = +range[0];
|
||||
var end = +range[1] || start;
|
||||
|
||||
/** @type {HTMLElement} */
|
||||
var line = pre.querySelector('.line-highlight[data-range="' + currentRange + '"]') || document.createElement('div');
|
||||
|
||||
mutateActions.push(function () {
|
||||
line.setAttribute('aria-hidden', 'true');
|
||||
line.setAttribute('data-range', currentRange);
|
||||
line.className = (classes || '') + ' line-highlight';
|
||||
});
|
||||
|
||||
// if the line-numbers plugin is enabled, then there is no reason for this plugin to display the line numbers
|
||||
if (hasLineNumbers && Prism.plugins.lineNumbers) {
|
||||
var startNode = Prism.plugins.lineNumbers.getLine(pre, start);
|
||||
var endNode = Prism.plugins.lineNumbers.getLine(pre, end);
|
||||
|
||||
if (startNode) {
|
||||
var top = startNode.offsetTop + 'px';
|
||||
mutateActions.push(function () {
|
||||
line.style.top = top;
|
||||
});
|
||||
}
|
||||
|
||||
if (endNode) {
|
||||
var height = (endNode.offsetTop - startNode.offsetTop) + endNode.offsetHeight + 'px';
|
||||
mutateActions.push(function () {
|
||||
line.style.height = height;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
mutateActions.push(function () {
|
||||
line.setAttribute('data-start', start);
|
||||
|
||||
if (end > start) {
|
||||
line.setAttribute('data-end', end);
|
||||
}
|
||||
|
||||
line.style.top = (start - offset - 1) * lineHeight + 'px';
|
||||
|
||||
line.textContent = new Array(end - start + 2).join(' \n');
|
||||
});
|
||||
}
|
||||
|
||||
mutateActions.push(function () {
|
||||
// allow this to play nicely with the line-numbers plugin
|
||||
// need to attack to pre as when line-numbers is enabled, the code tag is relatively which screws up the positioning
|
||||
parentElement.appendChild(line);
|
||||
});
|
||||
});
|
||||
|
||||
var id = pre.id;
|
||||
if (hasLineNumbers && id) {
|
||||
// This implements linkable line numbers. Linkable line numbers use Line Highlight to create a link to a
|
||||
// specific line. For this to work, the pre element has to:
|
||||
// 1) have line numbers,
|
||||
// 2) have the `linkable-line-numbers` class or an ascendant that has that class, and
|
||||
// 3) have an id.
|
||||
|
||||
var linkableLineNumbersClass = 'linkable-line-numbers';
|
||||
var linkableLineNumbers = false;
|
||||
var node = pre;
|
||||
while (node) {
|
||||
if (hasClass(node, linkableLineNumbersClass)) {
|
||||
linkableLineNumbers = true;
|
||||
break;
|
||||
}
|
||||
node = node.parentElement;
|
||||
}
|
||||
|
||||
if (linkableLineNumbers) {
|
||||
if (!hasClass(pre, linkableLineNumbersClass)) {
|
||||
// add class to pre
|
||||
mutateActions.push(function () {
|
||||
pre.className = (pre.className + ' ' + linkableLineNumbersClass).trim();
|
||||
});
|
||||
}
|
||||
|
||||
var start = parseInt(pre.getAttribute('data-start') || '1');
|
||||
|
||||
// iterate all line number spans
|
||||
$$('.line-numbers-rows > span', pre).forEach(function (lineSpan, i) {
|
||||
var lineNumber = i + start;
|
||||
lineSpan.onclick = function () {
|
||||
var hash = id + '.' + lineNumber;
|
||||
|
||||
// this will prevent scrolling since the span is obviously in view
|
||||
scrollIntoView = false;
|
||||
location.hash = hash;
|
||||
setTimeout(function () {
|
||||
scrollIntoView = true;
|
||||
}, 1);
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return function () {
|
||||
mutateActions.forEach(callFunction);
|
||||
};
|
||||
}
|
||||
|
||||
var scrollIntoView = true;
|
||||
function applyHash() {
|
||||
var hash = location.hash.slice(1);
|
||||
|
||||
// Remove pre-existing temporary lines
|
||||
$$('.temporary.line-highlight').forEach(function (line) {
|
||||
line.parentNode.removeChild(line);
|
||||
});
|
||||
|
||||
var range = (hash.match(/\.([\d,-]+)$/) || [, ''])[1];
|
||||
|
||||
if (!range || document.getElementById(hash)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var id = hash.slice(0, hash.lastIndexOf('.')),
|
||||
pre = document.getElementById(id);
|
||||
|
||||
if (!pre) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pre.hasAttribute('data-line')) {
|
||||
pre.setAttribute('data-line', '');
|
||||
}
|
||||
|
||||
var mutateDom = highlightLines(pre, range, 'temporary ');
|
||||
mutateDom();
|
||||
|
||||
if (scrollIntoView) {
|
||||
document.querySelector('.temporary.line-highlight').scrollIntoView();
|
||||
}
|
||||
}
|
||||
|
||||
var fakeTimer = 0; // Hack to limit the number of times applyHash() runs
|
||||
|
||||
Prism.hooks.add('before-sanity-check', function (env) {
|
||||
var pre = env.element.parentNode;
|
||||
var lines = pre && pre.getAttribute('data-line');
|
||||
|
||||
if (!pre || !lines || !/pre/i.test(pre.nodeName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Cleanup for other plugins (e.g. autoloader).
|
||||
*
|
||||
* Sometimes <code> blocks are highlighted multiple times. It is necessary
|
||||
* to cleanup any left-over tags, because the whitespace inside of the <div>
|
||||
* tags change the content of the <code> tag.
|
||||
*/
|
||||
var num = 0;
|
||||
$$('.line-highlight', pre).forEach(function (line) {
|
||||
num += line.textContent.length;
|
||||
line.parentNode.removeChild(line);
|
||||
});
|
||||
// Remove extra whitespace
|
||||
if (num && /^( \n)+$/.test(env.code.slice(-num))) {
|
||||
env.code = env.code.slice(0, -num);
|
||||
}
|
||||
});
|
||||
|
||||
Prism.hooks.add('complete', function completeHook(env) {
|
||||
var pre = env.element.parentNode;
|
||||
var lines = pre && pre.getAttribute('data-line');
|
||||
|
||||
if (!pre || !lines || !/pre/i.test(pre.nodeName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
clearTimeout(fakeTimer);
|
||||
|
||||
var hasLineNumbers = Prism.plugins.lineNumbers;
|
||||
var isLineNumbersLoaded = env.plugins && env.plugins.lineNumbers;
|
||||
|
||||
if (hasClass(pre, 'line-numbers') && hasLineNumbers && !isLineNumbersLoaded) {
|
||||
Prism.hooks.add('line-numbers', completeHook);
|
||||
} else {
|
||||
var mutateDom = highlightLines(pre, lines);
|
||||
mutateDom();
|
||||
fakeTimer = setTimeout(applyHash, 1);
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('hashchange', applyHash);
|
||||
window.addEventListener('resize', function () {
|
||||
var actions = $$('pre[data-line]').map(function (pre) {
|
||||
return highlightLines(pre);
|
||||
});
|
||||
actions.forEach(callFunction);
|
||||
});
|
||||
|
||||
})();
|
||||
1
node_modules/prismjs/plugins/line-highlight/prism-line-highlight.min.js
generated
vendored
Normal file
1
node_modules/prismjs/plugins/line-highlight/prism-line-highlight.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(){if("undefined"!=typeof self&&self.Prism&&self.document&&document.querySelector){var t,s=function(){if(void 0===t){var e=document.createElement("div");e.style.fontSize="13px",e.style.lineHeight="1.5",e.style.padding="0",e.style.border="0",e.innerHTML=" <br /> ",document.body.appendChild(e),t=38===e.offsetHeight,document.body.removeChild(e)}return t},l=!0,a=0;Prism.hooks.add("before-sanity-check",function(e){var t=e.element.parentNode,n=t&&t.getAttribute("data-line");if(t&&n&&/pre/i.test(t.nodeName)){var i=0;g(".line-highlight",t).forEach(function(e){i+=e.textContent.length,e.parentNode.removeChild(e)}),i&&/^( \n)+$/.test(e.code.slice(-i))&&(e.code=e.code.slice(0,-i))}}),Prism.hooks.add("complete",function e(t){var n=t.element.parentNode,i=n&&n.getAttribute("data-line");if(n&&i&&/pre/i.test(n.nodeName)){clearTimeout(a);var r=Prism.plugins.lineNumbers,o=t.plugins&&t.plugins.lineNumbers;if(b(n,"line-numbers")&&r&&!o)Prism.hooks.add("line-numbers",e);else u(n,i)(),a=setTimeout(c,1)}}),window.addEventListener("hashchange",c),window.addEventListener("resize",function(){g("pre[data-line]").map(function(e){return u(e)}).forEach(v)})}function g(e,t){return Array.prototype.slice.call((t||document).querySelectorAll(e))}function b(e,t){return t=" "+t+" ",-1<(" "+e.className+" ").replace(/[\n\t]/g," ").indexOf(t)}function v(e){e()}function u(u,e,c){var t=(e="string"==typeof e?e:u.getAttribute("data-line")).replace(/\s+/g,"").split(",").filter(Boolean),d=+u.getAttribute("data-line-offset")||0,f=(s()?parseInt:parseFloat)(getComputedStyle(u).lineHeight),m=b(u,"line-numbers"),p=m?u:u.querySelector("code")||u,h=[];t.forEach(function(e){var t=e.split("-"),n=+t[0],i=+t[1]||n,r=u.querySelector('.line-highlight[data-range="'+e+'"]')||document.createElement("div");if(h.push(function(){r.setAttribute("aria-hidden","true"),r.setAttribute("data-range",e),r.className=(c||"")+" line-highlight"}),m&&Prism.plugins.lineNumbers){var o=Prism.plugins.lineNumbers.getLine(u,n),a=Prism.plugins.lineNumbers.getLine(u,i);if(o){var s=o.offsetTop+"px";h.push(function(){r.style.top=s})}if(a){var l=a.offsetTop-o.offsetTop+a.offsetHeight+"px";h.push(function(){r.style.height=l})}}else h.push(function(){r.setAttribute("data-start",n),n<i&&r.setAttribute("data-end",i),r.style.top=(n-d-1)*f+"px",r.textContent=new Array(i-n+2).join(" \n")});h.push(function(){p.appendChild(r)})});var i=u.id;if(m&&i){for(var n="linkable-line-numbers",r=!1,o=u;o;){if(b(o,n)){r=!0;break}o=o.parentElement}if(r){b(u,n)||h.push(function(){u.className=(u.className+" "+n).trim()});var a=parseInt(u.getAttribute("data-start")||"1");g(".line-numbers-rows > span",u).forEach(function(e,t){var n=t+a;e.onclick=function(){var e=i+"."+n;l=!1,location.hash=e,setTimeout(function(){l=!0},1)}})}}return function(){h.forEach(v)}}function c(){var e=location.hash.slice(1);g(".temporary.line-highlight").forEach(function(e){e.parentNode.removeChild(e)});var t=(e.match(/\.([\d,-]+)$/)||[,""])[1];if(t&&!document.getElementById(e)){var n=e.slice(0,e.lastIndexOf(".")),i=document.getElementById(n);if(i)i.hasAttribute("data-line")||i.setAttribute("data-line",""),u(i,t,"temporary ")(),l&&document.querySelector(".temporary.line-highlight").scrollIntoView()}}}();
|
||||
Reference in New Issue
Block a user