\n `,o.appendChild(l);const p=document.querySelector(".code-block");function h(){window&&window.localStorage&&window.localStorage.setItem("code-block-state",JSON.stringify({open:"none"!==p.style.display,fileIndex:g}))}const u=document.querySelector(".code-text");let g=0;function f(o){const n=document.querySelector(".code-header-left > span.active");n&&n.classList.remove("active");const s=t.findIndex((e=>e===o));g=s;const c=i[s];u.textContent=c[0];const l=c[1];u.classList.remove("shj-lang-"+u.dataset.lang),u.classList.add("shj-lang-"+l),e(u);const p=r?r(u.textContent):u.textContent,f=document.querySelector(".code-header-right-2");f.querySelector("#codepen-form")&&f.querySelector("#codepen-form").remove(),"js"!==l&&"ts"!==l||(f.innerHTML+=function({html:e,css:o,js:n,...t}){e=e.trim(),o=o.trim(),n=n.trim();const s={title:document.title,description:"",html:e,html_pre_processor:"none",css:o,css_pre_processor:"none",css_starter:"neither",css_prefix_free:!1,js:n,js_pre_processor:"js",js_modernizr:!1,js_library:"",html_classes:"",css_external:"",js_external:"",editors:"101",template:!0,...t};return''}({html:d,js:p,js_pre_processor:"ts"===l?"typescript":"none",...a}));const m=document.querySelector(".code-header-left > span:nth-child("+(s+1)+")");m&&m.classList.add("active"),h()}document.querySelector(".code-header-left").addEventListener("click",(e=>{"SPAN"===e.target.tagName&&f(e.target.textContent)})),document.querySelector("#copy-btn").addEventListener("click",(e=>{navigator.clipboard&&navigator.clipboard.writeText(u.textContent).then((()=>{e.target.textContent="copied",setTimeout((()=>{e.target.textContent="copy"}),1e3)}))})),document.querySelector("#source-btn").addEventListener("click",(e=>{const o=g;o>=0&&o{p.style.display="none"===p.style.display?"block":"none",h()}));const m=window&&window.localStorage.getItem("code-block-state");let x=!1,y=g;if(m){const e=JSON.parse(m);void 0!==e.open&&(x=e.open),e.fileIndex&&e.fileIndex{h()})),{close:()=>{p.style.display="none",h()},open:()=>{p.style.display="block",h()}}}export{o as setupCodePreview};
8 | //# sourceMappingURL=index.js.map
9 |
--------------------------------------------------------------------------------
/dist/dependencies.txt:
--------------------------------------------------------------------------------
1 | Name: @speed-highlight/core
2 | Version: 1.1.11
3 | License: CC0-1.0
4 | Private: false
5 | Description: 🌈 Light, fast, and easy to use, dependencies free javascript syntax highlighter, with automatic language detection
6 | Repository: git://github.com/speed-highlight/core.git
7 | Homepage: https://github.com/speed-highlight/core#readme
8 | Author: matubu
9 | License Copyright:
10 | ===
11 |
12 | Creative Commons Legal Code
13 |
14 | CC0 1.0 Universal
15 |
16 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
17 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
18 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
19 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
20 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
21 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
22 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
23 | HEREUNDER.
24 |
25 | Statement of Purpose
26 |
27 | The laws of most jurisdictions throughout the world automatically confer
28 | exclusive Copyright and Related Rights (defined below) upon the creator
29 | and subsequent owner(s) (each and all, an "owner") of an original work of
30 | authorship and/or a database (each, a "Work").
31 |
32 | Certain owners wish to permanently relinquish those rights to a Work for
33 | the purpose of contributing to a commons of creative, cultural and
34 | scientific works ("Commons") that the public can reliably and without fear
35 | of later claims of infringement build upon, modify, incorporate in other
36 | works, reuse and redistribute as freely as possible in any form whatsoever
37 | and for any purposes, including without limitation commercial purposes.
38 | These owners may contribute to the Commons to promote the ideal of a free
39 | culture and the further production of creative, cultural and scientific
40 | works, or to gain reputation or greater distribution for their Work in
41 | part through the use and efforts of others.
42 |
43 | For these and/or other purposes and motivations, and without any
44 | expectation of additional consideration or compensation, the person
45 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she
46 | is an owner of Copyright and Related Rights in the Work, voluntarily
47 | elects to apply CC0 to the Work and publicly distribute the Work under its
48 | terms, with knowledge of his or her Copyright and Related Rights in the
49 | Work and the meaning and intended legal effect of CC0 on those rights.
50 |
51 | 1. Copyright and Related Rights. A Work made available under CC0 may be
52 | protected by copyright and related or neighboring rights ("Copyright and
53 | Related Rights"). Copyright and Related Rights include, but are not
54 | limited to, the following:
55 |
56 | i. the right to reproduce, adapt, distribute, perform, display,
57 | communicate, and translate a Work;
58 | ii. moral rights retained by the original author(s) and/or performer(s);
59 | iii. publicity and privacy rights pertaining to a person's image or
60 | likeness depicted in a Work;
61 | iv. rights protecting against unfair competition in regards to a Work,
62 | subject to the limitations in paragraph 4(a), below;
63 | v. rights protecting the extraction, dissemination, use and reuse of data
64 | in a Work;
65 | vi. database rights (such as those arising under Directive 96/9/EC of the
66 | European Parliament and of the Council of 11 March 1996 on the legal
67 | protection of databases, and under any national implementation
68 | thereof, including any amended or successor version of such
69 | directive); and
70 | vii. other similar, equivalent or corresponding rights throughout the
71 | world based on applicable law or treaty, and any national
72 | implementations thereof.
73 |
74 | 2. Waiver. To the greatest extent permitted by, but not in contravention
75 | of, applicable law, Affirmer hereby overtly, fully, permanently,
76 | irrevocably and unconditionally waives, abandons, and surrenders all of
77 | Affirmer's Copyright and Related Rights and associated claims and causes
78 | of action, whether now known or unknown (including existing as well as
79 | future claims and causes of action), in the Work (i) in all territories
80 | worldwide, (ii) for the maximum duration provided by applicable law or
81 | treaty (including future time extensions), (iii) in any current or future
82 | medium and for any number of copies, and (iv) for any purpose whatsoever,
83 | including without limitation commercial, advertising or promotional
84 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
85 | member of the public at large and to the detriment of Affirmer's heirs and
86 | successors, fully intending that such Waiver shall not be subject to
87 | revocation, rescission, cancellation, termination, or any other legal or
88 | equitable action to disrupt the quiet enjoyment of the Work by the public
89 | as contemplated by Affirmer's express Statement of Purpose.
90 |
91 | 3. Public License Fallback. Should any part of the Waiver for any reason
92 | be judged legally invalid or ineffective under applicable law, then the
93 | Waiver shall be preserved to the maximum extent permitted taking into
94 | account Affirmer's express Statement of Purpose. In addition, to the
95 | extent the Waiver is so judged Affirmer hereby grants to each affected
96 | person a royalty-free, non transferable, non sublicensable, non exclusive,
97 | irrevocable and unconditional license to exercise Affirmer's Copyright and
98 | Related Rights in the Work (i) in all territories worldwide, (ii) for the
99 | maximum duration provided by applicable law or treaty (including future
100 | time extensions), (iii) in any current or future medium and for any number
101 | of copies, and (iv) for any purpose whatsoever, including without
102 | limitation commercial, advertising or promotional purposes (the
103 | "License"). The License shall be deemed effective as of the date CC0 was
104 | applied by Affirmer to the Work. Should any part of the License for any
105 | reason be judged legally invalid or ineffective under applicable law, such
106 | partial invalidity or ineffectiveness shall not invalidate the remainder
107 | of the License, and in such case Affirmer hereby affirms that he or she
108 | will not (i) exercise any of his or her remaining Copyright and Related
109 | Rights in the Work or (ii) assert any associated claims and causes of
110 | action with respect to the Work, in either case contrary to Affirmer's
111 | express Statement of Purpose.
112 |
113 | 4. Limitations and Disclaimers.
114 |
115 | a. No trademark or patent rights held by Affirmer are waived, abandoned,
116 | surrendered, licensed or otherwise affected by this document.
117 | b. Affirmer offers the Work as-is and makes no representations or
118 | warranties of any kind concerning the Work, express, implied,
119 | statutory or otherwise, including without limitation warranties of
120 | title, merchantability, fitness for a particular purpose, non
121 | infringement, or the absence of latent or other defects, accuracy, or
122 | the present or absence of errors, whether or not discoverable, all to
123 | the greatest extent permissible under applicable law.
124 | c. Affirmer disclaims responsibility for clearing rights of other persons
125 | that may apply to the Work or any use thereof, including without
126 | limitation any person's Copyright and Related Rights in the Work.
127 | Further, Affirmer disclaims responsibility for obtaining any necessary
128 | consents, permissions or other rights required for any use of the
129 | Work.
130 | d. Affirmer understands and acknowledges that Creative Commons is not a
131 | party to this document and has no duty or obligation with respect to
132 | this CC0 or use of the Work.
--------------------------------------------------------------------------------
/dist/index.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"index.js","sources":["../src/index.js","../src/codepen.js"],"sourcesContent":["import {highlightElement} from 'https://unpkg.com/@speed-highlight/core/dist/index.js';\nimport themeStyles from './../node_modules/@speed-highlight/core/dist/themes/dark.css';\nimport indexStyles from \"./index.css\";\nimport {linkCodepen} from \"./codepen.js\";\n\nexport async function setupCodePreview(container, scripts, titles, sourcePrefix, processor, codepenOpts, appendHTML){\n const initHTML = container.outerHTML + '\\n' + (appendHTML || '');\n let sources = []\n if(!scripts){\n sources = [document.querySelector('#example-script').textContent, 'js'];\n }else {\n sources = await Promise.all(scripts.map(async src => [\n typeof src==='string' ? (await (await fetch(src)).text()).trim() : src.textContent.trimEnd(),\n typeof src==='string' ? src.split('?')[0].split('.').pop() : 'js']\n ));\n }\n const previewel = document.createElement('div')\n previewel.id = 'code-previewer';\n previewel.innerHTML = `\n \n \n