bitwrench 2.0.13 → 2.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/bitwrench-code-edit.cjs.js +46 -46
- package/dist/bitwrench-code-edit.cjs.min.js +16 -0
- package/dist/bitwrench-code-edit.es5.js +8 -8
- package/dist/bitwrench-code-edit.es5.min.js +2 -2
- package/dist/bitwrench-code-edit.esm.js +46 -46
- package/dist/bitwrench-code-edit.esm.min.js +2 -2
- package/dist/bitwrench-code-edit.umd.js +46 -46
- package/dist/bitwrench-code-edit.umd.min.js +2 -2
- package/dist/bitwrench-lean.cjs.js +5011 -3419
- package/dist/bitwrench-lean.cjs.min.js +35 -6
- package/dist/bitwrench-lean.es5.js +6218 -4272
- package/dist/bitwrench-lean.es5.min.js +32 -3
- package/dist/bitwrench-lean.esm.js +5011 -3419
- package/dist/bitwrench-lean.esm.min.js +35 -6
- package/dist/bitwrench-lean.umd.js +5011 -3419
- package/dist/bitwrench-lean.umd.min.js +35 -6
- package/dist/bitwrench.cjs.js +6966 -4662
- package/dist/bitwrench.cjs.min.js +38 -8
- package/dist/bitwrench.css +2453 -4784
- package/dist/bitwrench.es5.js +9592 -6813
- package/dist/bitwrench.es5.min.js +34 -5
- package/dist/bitwrench.esm.js +6966 -4662
- package/dist/bitwrench.esm.min.js +38 -8
- package/dist/bitwrench.min.css +1 -0
- package/dist/bitwrench.umd.js +6966 -4662
- package/dist/bitwrench.umd.min.js +38 -8
- package/dist/builds.json +89 -67
- package/dist/sri.json +28 -26
- package/package.json +7 -5
- package/readme.html +14 -14
- package/src/{bitwrench-components-v2.js → bitwrench-bccl.js} +1311 -600
- package/src/bitwrench-code-edit.js +45 -45
- package/src/bitwrench-color-utils.js +154 -27
- package/src/bitwrench-components-stub.js +4 -1
- package/src/bitwrench-file-ops.js +180 -0
- package/src/bitwrench-lean.js +2 -2
- package/src/bitwrench-styles.js +1468 -3494
- package/src/bitwrench-utils.js +458 -0
- package/src/bitwrench.js +1795 -1349
- package/src/cli/layout-default.js +18 -18
- package/src/generate-css.js +73 -53
- package/src/version.js +3 -3
- package/src/bitwrench-component-base.js +0 -736
- package/src/bitwrench-components-inline.js +0 -374
- package/src/bitwrench-components.js +0 -610
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! bitwrench v2.0.
|
|
1
|
+
/*! bitwrench v2.0.15 | BSD-2-Clause | https://deftio.github.com/bitwrench/pages */
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
@@ -21,53 +21,53 @@
|
|
|
21
21
|
// -- CSS (injected once) ----------------------------------------------
|
|
22
22
|
var _cssInjected = false;
|
|
23
23
|
var CSS_TEXT =
|
|
24
|
-
'.
|
|
25
|
-
'.
|
|
26
|
-
'.
|
|
27
|
-
'.
|
|
28
|
-
'.
|
|
29
|
-
'.
|
|
30
|
-
'.
|
|
31
|
-
'.
|
|
32
|
-
'.
|
|
33
|
-
'.
|
|
34
|
-
'.
|
|
35
|
-
'.
|
|
36
|
-
'.
|
|
37
|
-
'.
|
|
38
|
-
'.
|
|
39
|
-
'.
|
|
40
|
-
'.
|
|
41
|
-
'.
|
|
42
|
-
'.
|
|
43
|
-
'.
|
|
44
|
-
'.
|
|
24
|
+
'.bw_ce{background:#1e293b;border-radius:6px;border:1px solid rgba(255,255,255,0.08);overflow:auto}' +
|
|
25
|
+
'.bw_ce pre{margin:0;padding:0}' +
|
|
26
|
+
'.bw_ce code{font-family:"SF Mono",Monaco,"Cascadia Code",Consolas,monospace;font-size:0.875rem;line-height:1.6;color:#e2e8f0;outline:none;white-space:pre-wrap;display:block;padding:0.75rem 1rem}' +
|
|
27
|
+
'.bw_ce code:empty::before{content:"\\200b"}' +
|
|
28
|
+
'.bw_ce .bw_ce_keyword{color:#c792ea}' +
|
|
29
|
+
'.bw_ce .bw_ce_string{color:#c3e88d}' +
|
|
30
|
+
'.bw_ce .bw_ce_comment{color:#546e7a;font-style:italic}' +
|
|
31
|
+
'.bw_ce .bw_ce_number{color:#f78c6c}' +
|
|
32
|
+
'.bw_ce .bw_ce_operator{color:#89ddff}' +
|
|
33
|
+
'.bw_ce .bw_ce_punctuation{color:#89ddff}' +
|
|
34
|
+
'.bw_ce .bw_ce_property{color:#82aaff}' +
|
|
35
|
+
'.bw_ce .bw_ce_function{color:#82aaff}' +
|
|
36
|
+
'.bw_ce .bw_ce_tag{color:#f07178}' +
|
|
37
|
+
'.bw_ce .bw_ce_attr_name{color:#ffcb6b}' +
|
|
38
|
+
'.bw_ce .bw_ce_attr_value{color:#c3e88d}' +
|
|
39
|
+
'.bw_ce .bw_ce_selector{color:#c792ea}' +
|
|
40
|
+
'.bw_ce .bw_ce_css_prop{color:#82aaff}' +
|
|
41
|
+
'.bw_ce .bw_ce_css_value{color:#f78c6c}' +
|
|
42
|
+
'.bw_ce .bw_ce_at_rule{color:#c792ea;font-style:italic}' +
|
|
43
|
+
'.bw_ce .bw_ce_color{color:#f78c6c}' +
|
|
44
|
+
'.bw_ce .bw_ce_template_interp{color:#89ddff}' +
|
|
45
45
|
// Light theme
|
|
46
|
-
'.
|
|
47
|
-
'.
|
|
48
|
-
'.
|
|
49
|
-
'.
|
|
50
|
-
'.
|
|
51
|
-
'.
|
|
52
|
-
'.
|
|
53
|
-
'.
|
|
54
|
-
'.
|
|
55
|
-
'.
|
|
56
|
-
'.
|
|
57
|
-
'.
|
|
58
|
-
'.
|
|
59
|
-
'.
|
|
60
|
-
'.
|
|
61
|
-
'.
|
|
62
|
-
'.
|
|
63
|
-
'.
|
|
64
|
-
'.
|
|
46
|
+
'.bw_ce_light.bw_ce{background:#fafafa;border-color:#d8d8d8}' +
|
|
47
|
+
'.bw_ce_light.bw_ce code{color:#1a1a1a}' +
|
|
48
|
+
'.bw_ce_light.bw_ce .bw_ce_keyword{color:#7c3aed}' +
|
|
49
|
+
'.bw_ce_light.bw_ce .bw_ce_string{color:#16a34a}' +
|
|
50
|
+
'.bw_ce_light.bw_ce .bw_ce_comment{color:#9ca3af;font-style:italic}' +
|
|
51
|
+
'.bw_ce_light.bw_ce .bw_ce_number{color:#ea580c}' +
|
|
52
|
+
'.bw_ce_light.bw_ce .bw_ce_operator{color:#0891b2}' +
|
|
53
|
+
'.bw_ce_light.bw_ce .bw_ce_punctuation{color:#6b7280}' +
|
|
54
|
+
'.bw_ce_light.bw_ce .bw_ce_property{color:#2563eb}' +
|
|
55
|
+
'.bw_ce_light.bw_ce .bw_ce_function{color:#2563eb}' +
|
|
56
|
+
'.bw_ce_light.bw_ce .bw_ce_tag{color:#dc2626}' +
|
|
57
|
+
'.bw_ce_light.bw_ce .bw_ce_attr_name{color:#d97706}' +
|
|
58
|
+
'.bw_ce_light.bw_ce .bw_ce_attr_value{color:#16a34a}' +
|
|
59
|
+
'.bw_ce_light.bw_ce .bw_ce_selector{color:#7c3aed}' +
|
|
60
|
+
'.bw_ce_light.bw_ce .bw_ce_css_prop{color:#2563eb}' +
|
|
61
|
+
'.bw_ce_light.bw_ce .bw_ce_css_value{color:#ea580c}' +
|
|
62
|
+
'.bw_ce_light.bw_ce .bw_ce_at_rule{color:#7c3aed}' +
|
|
63
|
+
'.bw_ce_light.bw_ce .bw_ce_color{color:#ea580c}' +
|
|
64
|
+
'.bw_ce_light.bw_ce .bw_ce_template_interp{color:#0891b2}';
|
|
65
65
|
|
|
66
66
|
function ensureCSS(bw) {
|
|
67
67
|
if (_cssInjected) return;
|
|
68
68
|
_cssInjected = true;
|
|
69
69
|
if (bw && bw.injectCSS) {
|
|
70
|
-
bw.injectCSS(CSS_TEXT, { id: '
|
|
70
|
+
bw.injectCSS(CSS_TEXT, { id: 'bw_code_edit_styles' });
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -490,7 +490,7 @@
|
|
|
490
490
|
if (tok.type === 'plain') {
|
|
491
491
|
result.push(tok.text);
|
|
492
492
|
} else {
|
|
493
|
-
result.push({ t: 'span', a: { class: '
|
|
493
|
+
result.push({ t: 'span', a: { class: 'bw_ce_' + tok.type }, c: tok.text });
|
|
494
494
|
}
|
|
495
495
|
}
|
|
496
496
|
return result;
|
|
@@ -544,13 +544,13 @@
|
|
|
544
544
|
var lang = opts.lang || 'js';
|
|
545
545
|
var height = opts.height || '180px';
|
|
546
546
|
var readOnly = !!opts.readOnly;
|
|
547
|
-
var className = '
|
|
547
|
+
var className = 'bw_ce' + (opts.className ? ' ' + opts.className : '');
|
|
548
548
|
|
|
549
549
|
var highlighted = highlight(code, lang);
|
|
550
550
|
|
|
551
551
|
var codeAttrs = {
|
|
552
552
|
spellcheck: 'false',
|
|
553
|
-
class: '
|
|
553
|
+
class: 'bw_ce_code'
|
|
554
554
|
};
|
|
555
555
|
if (!readOnly) {
|
|
556
556
|
codeAttrs.contenteditable = 'true';
|
|
@@ -564,7 +564,7 @@
|
|
|
564
564
|
],
|
|
565
565
|
o: {
|
|
566
566
|
mounted: function(el) {
|
|
567
|
-
var codeEl = el.querySelector('.
|
|
567
|
+
var codeEl = el.querySelector('.bw_ce_code');
|
|
568
568
|
if (!codeEl) return;
|
|
569
569
|
|
|
570
570
|
var currentCode = code;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! bitwrench v2.0.
|
|
1
|
+
/*! bitwrench v2.0.15 | BSD-2-Clause | https://deftio.github.com/bitwrench/pages */
|
|
2
2
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).bwCodeEdit={})}(this,function(e){"use strict";
|
|
3
3
|
/**
|
|
4
4
|
* bitwrench-code-edit.js - syntax-highlighted contenteditable code editor addon
|
|
@@ -11,5 +11,5 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @module bitwrench-code-edit
|
|
13
13
|
* @license BSD-2-Clause
|
|
14
|
-
*/var t=!1,o='.bw-ce{background:#1e293b;border-radius:6px;border:1px solid rgba(255,255,255,0.08);overflow:auto}.bw-ce pre{margin:0;padding:0}.bw-ce code{font-family:"SF Mono",Monaco,"Cascadia Code",Consolas,monospace;font-size:0.875rem;line-height:1.6;color:#e2e8f0;outline:none;white-space:pre-wrap;display:block;padding:0.75rem 1rem}.bw-ce code:empty::before{content:"\\200b"}.bw-ce .bw-ce-keyword{color:#c792ea}.bw-ce .bw-ce-string{color:#c3e88d}.bw-ce .bw-ce-comment{color:#546e7a;font-style:italic}.bw-ce .bw-ce-number{color:#f78c6c}.bw-ce .bw-ce-operator{color:#89ddff}.bw-ce .bw-ce-punctuation{color:#89ddff}.bw-ce .bw-ce-property{color:#82aaff}.bw-ce .bw-ce-function{color:#82aaff}.bw-ce .bw-ce-tag{color:#f07178}.bw-ce .bw-ce-attr-name{color:#ffcb6b}.bw-ce .bw-ce-attr-value{color:#c3e88d}.bw-ce .bw-ce-selector{color:#c792ea}.bw-ce .bw-ce-css-prop{color:#82aaff}.bw-ce .bw-ce-css-value{color:#f78c6c}.bw-ce .bw-ce-at-rule{color:#c792ea;font-style:italic}.bw-ce .bw-ce-color{color:#f78c6c}.bw-ce .bw-ce-template-interp{color:#89ddff}.bw-ce-light.bw-ce{background:#fafafa;border-color:#d8d8d8}.bw-ce-light.bw-ce code{color:#1a1a1a}.bw-ce-light.bw-ce .bw-ce-keyword{color:#7c3aed}.bw-ce-light.bw-ce .bw-ce-string{color:#16a34a}.bw-ce-light.bw-ce .bw-ce-comment{color:#9ca3af;font-style:italic}.bw-ce-light.bw-ce .bw-ce-number{color:#ea580c}.bw-ce-light.bw-ce .bw-ce-operator{color:#0891b2}.bw-ce-light.bw-ce .bw-ce-punctuation{color:#6b7280}.bw-ce-light.bw-ce .bw-ce-property{color:#2563eb}.bw-ce-light.bw-ce .bw-ce-function{color:#2563eb}.bw-ce-light.bw-ce .bw-ce-tag{color:#dc2626}.bw-ce-light.bw-ce .bw-ce-attr-name{color:#d97706}.bw-ce-light.bw-ce .bw-ce-attr-value{color:#16a34a}.bw-ce-light.bw-ce .bw-ce-selector{color:#7c3aed}.bw-ce-light.bw-ce .bw-ce-css-prop{color:#2563eb}.bw-ce-light.bw-ce .bw-ce-css-value{color:#ea580c}.bw-ce-light.bw-ce .bw-ce-at-rule{color:#7c3aed}.bw-ce-light.bw-ce .bw-ce-color{color:#ea580c}.bw-ce-light.bw-ce .bw-ce-template-interp{color:#0891b2}';var c={};function r(e){var t=[],o=0,n=e.length,a="";function l(e){a.length&&(t.push({type:e,text:a}),a="")}for(;o<n;){var i=e[o],s=e[o+1];if("/"!==i||"/"!==s)if("/"!==i||"*"!==s){if("/"===i&&"/"!==s&&"*"!==s){var p=t.length?t[t.length-1]:null,u=!1;if(a.trim().length||p&&"operator"!==p.type&&"punctuation"!==p.type&&"keyword"!==p.type||(u=!0),u){l("plain");for(var f="/",b=o+1,w=!1,d=!1;b<n;){var h=e[b];if(w)f+=h,w=!1,b++;else if("\\"!==h)if("["!==h)if("]"!==h){if("/"===h&&!d){f+=h,b++;break}if("\n"===h)break;f+=h,b++}else d=!1,f+=h,b++;else d=!0,f+=h,b++;else w=!0,f+=h,b++}for(;b<n&&/[gimsuvy]/.test(e[b]);)f+=e[b],b++;t.push({type:"string",text:f}),o=b;continue}}if('"'!==i&&"'"!==i&&"`"!==i)if(/[0-9]/.test(i)||"."===i&&s&&/[0-9]/.test(s)){l("plain");var g="";if("0"===i&&s&&/[xXbBoO]/.test(s))for(g=i+s,o+=2;o<n&&/[0-9a-fA-F_]/.test(e[o]);)g+=e[o],o++;else for(;o<n&&/[0-9._eE]/.test(e[o]);)"e"!==e[o]&&"E"!==e[o]||!e[o+1]||!/[+\-0-9]/.test(e[o+1])?(g+=e[o],o++):(g+=e[o]+e[o+1],o+=2);t.push({type:"number",text:g})}else if(/[a-zA-Z_$]/.test(i)){l("plain");for(var v="";o<n&&/[a-zA-Z0-9_$]/.test(e[o]);)v+=e[o],o++;for(var y=o;y<n&&(" "===e[y]||"\t"===e[y]);)y++;var x=t.length?t[t.length-1]:null,m=x&&"punctuation"===x.type&&"."===x.text;c[v]?t.push({type:"keyword",text:v}):m?y<n&&"("===e[y]?t.push({type:"function",text:v}):t.push({type:"property",text:v}):y<n&&"("===e[y]?t.push({type:"function",text:v}):t.push({type:"plain",text:v})}else if(-1==="=+-*/%!<>&|^~?:".indexOf(i))-1==="(){}[];,.".indexOf(i)?(a+=i,o++):(l("plain"),t.push({type:"punctuation",text:i}),o++);else{l("plain");var k=i;++o<n&&-1!=="=+-*/%!<>&|^~?:".indexOf(e[o])&&(k+=e[o],++o<n&&-1!=="=>&|".indexOf(e[o])&&(k+=e[o],o++)),t.push({type:"operator",text:k})}else{l("plain");var C=i,S=i,T=o+1;if("`"===C){for(;T<n;){var A=e[T];if("\\"!==A)if("$"!==A||"{"!==e[T+1]){if("`"===A){S+=A,T++;break}S+=A,T++}else{S.length&&t.push({type:"string",text:S}),S="",t.push({type:"template-interp",text:"${"}),T+=2;for(var E=1,O="";T<n&&E>0;){if("{"===e[T])E++;else if("}"===e[T]&&0===--E)break;O+=e[T],T++}var z=r(O);(t=t.concat(z)).push({type:"template-interp",text:"}"}),T++}else S+=A+(e[T+1]||""),T+=2}S.length&&t.push({type:"string",text:S})}else{for(;T<n;){var _=e[T];if("\\"!==_){if(_===C){S+=_,T++;break}if("\n"===_)break;S+=_,T++}else S+=_+(e[T+1]||""),T+=2}t.push({type:"string",text:S})}o=T}}else{l("plain");var R=e.indexOf("*/",o+2);-1===R&&(R=n-2),t.push({type:"comment",text:e.substring(o,R+2)}),o=R+2}else{l("plain");var Z=e.indexOf("\n",o);-1===Z&&(Z=n),t.push({type:"comment",text:e.substring(o,Z)}),o=Z}}return l("plain"),t}function n(e){var t=[],o=0,c=e.length,r="selector",n="";function a(e){n.length&&(t.push({type:e||"plain",text:n}),n="")}for(;o<c;){var l=e[o],i=e[o+1];if("/"!==l||"*"!==i)if('"'!==l&&"'"!==l||"value"!==r&&"selector"!==r)if("@"!==l||"selector"!==r)if("#"!==l||"value"!==r)if("value"===r&&/[0-9]/.test(l)){a("css-value");for(var s="";o<c&&/[0-9.]/.test(e[o]);)s+=e[o],o++;for(var p="";o<c&&/[a-zA-Z%]/.test(e[o]);)p+=e[o],o++;t.push({type:"number",text:s+p})}else"{"!==l?"}"!==l?":"!==l||"prop"!==r?";"!==l?","!==l?(n+=l,o++):(a("selector"===r?"selector":"value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),o++):(a("value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),r="prop",o++):(a("css-prop"),t.push({type:"punctuation",text:l}),r="value",o++):(a("prop"===r?"css-prop":"value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),r="selector",o++):(a("selector"===r?"selector":"plain"),t.push({type:"punctuation",text:l}),r="prop",o++);else{a("css-value");var u="#";for(o++;o<c&&/[0-9a-fA-F]/.test(e[o]);)u+=e[o],o++;t.push({type:"color",text:u})}else{a("selector");var f="@";for(o++;o<c&&/[a-zA-Z\-]/.test(e[o]);)f+=e[o],o++;t.push({type:"at-rule",text:f})}else{a("selector"===r?"selector":"css-value");var b=l,w=l;for(o++;o<c;)if("\\"!==e[o]){if(e[o]===b){w+=e[o],o++;break}w+=e[o],o++}else w+=e[o]+(e[o+1]||""),o+=2;t.push({type:"string",text:w})}else{a("selector"===r?"selector":"prop"===r?"css-prop":"css-value");var d=e.indexOf("*/",o+2);-1===d&&(d=c-2),t.push({type:"comment",text:e.substring(o,d+2)}),o=d+2}}return a("selector"===r?"selector":"prop"===r?"css-prop":"css-value"),t}function a(e){var t=[],o=0,c=e.length,r="";function n(e){r.length&&(t.push({type:e,text:r}),r="")}for(;o<c;){var a=e[o];if("<"!==a||"\x3c!--"!==e.substring(o,o+4))if("<"!==a)if("&"!==a)r+=a,o++;else{n("plain");var l="&";for(o++;o<c&&";"!==e[o]&&/[a-zA-Z0-9#]/.test(e[o]);)l+=e[o],o++;o<c&&";"===e[o]&&(l+=";",o++),t.push({type:"string",text:l})}else{n("plain");var i="<";for(++o<c&&"/"===e[o]&&(i+="/",o++);o<c&&/[a-zA-Z0-9\-]/.test(e[o]);)i+=e[o],o++;for(t.push({type:"tag",text:i});o<c&&">"!==e[o]&&("/"!==e[o]||">"!==e[o+1]);)if(/\s/.test(e[o])){for(var s="";o<c&&/\s/.test(e[o]);)s+=e[o],o++;t.push({type:"plain",text:s})}else if(/[a-zA-Z_\-@:]/.test(e[o])){for(var p="";o<c&&/[a-zA-Z0-9_\-@:]/.test(e[o]);)p+=e[o],o++;if(t.push({type:"attr-name",text:p}),o<c&&"="===e[o])if(t.push({type:"punctuation",text:"="}),++o<c&&('"'===e[o]||"'"===e[o])){var u=e[o],f=u;for(o++;o<c&&e[o]!==u;)f+=e[o],o++;o<c&&(f+=e[o],o++),t.push({type:"attr-value",text:f})}else{for(var b="";o<c&&!/[\s>]/.test(e[o]);)b+=e[o],o++;t.push({type:"attr-value",text:b})}}else r+=e[o],o++,n("plain");var w="";o<c&&"/"===e[o]&&(w+="/",o++),o<c&&">"===e[o]&&(w+=">",o++),w&&t.push({type:"tag",text:w})}else{n("plain");var d=e.indexOf("--\x3e",o+4);-1===d&&(d=c-3),t.push({type:"comment",text:e.substring(o,d+3)}),o=d+3}}return n("plain"),t}"var,const,let,function,return,if,else,for,while,do,switch,case,break,continue,new,typeof,instanceof,this,class,extends,import,export,default,from,true,false,null,undefined,try,catch,throw,finally,async,await,yield,of,in,delete,void,with,super,static,get,set,debugger".split(",").forEach(function(e){c[e]=!0});var l={js:r,javascript:r,css:n,html:a};function i(e,t){return function(e){for(var t=[],o=0;o<e.length;o++){var c=e[o];"plain"===c.type?t.push(c.text):t.push({t:"span",a:{class:"bw-ce-"+c.type},c:c.text})}return t}((l[t]||r)(e))}function s(e){var t=(e=e||{}).code||"",o=e.lang||"js",c=e.height||"180px",r=!!e.readOnly,n="bw-ce"+(e.className?" "+e.className:""),a=i(t,o),l={spellcheck:"false",class:"bw-ce-code"};return r||(l.contenteditable="true"),{t:"div",a:{class:n,style:"max-height:"+c+";overflow:auto"},c:[{t:"pre",c:{t:"code",a:l,c:a}}],o:{mounted:function(c){var n=c.querySelector(".bw-ce-code");if(n){var a=t,l=null,s="undefined"!=typeof window&&window.bw||{};c._bwCodeEdit={getValue:p,setValue:function(e){a=e;var t=i(e,o);s.html&&(n.innerHTML=s.html({t:"span",c:t}))}},r||(n.addEventListener("input",function(){clearTimeout(l),l=setTimeout(u,50)}),n.addEventListener("keydown",function(e){"Tab"===e.key&&(e.preventDefault(),document.execCommand("insertText",!1," "))}))}function p(){return n.textContent||""}function u(){var t=p();if(t!==a){a=t;var c=function(e){var t=window.getSelection();if(!t.rangeCount)return 0;var o=t.getRangeAt(0).cloneRange();return o.selectNodeContents(e),o.setEnd(t.getRangeAt(0).startContainer,t.getRangeAt(0).startOffset),o.toString().length}(n),r=i(t,o);s.html&&(n.innerHTML=s.html({t:"span",c:r})),function(e,t){for(var o,c=window.getSelection(),r=document.createRange(),n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null,!1),a=0;o=n.nextNode();){var l=o.textContent.length;if(a+l>=t)return r.setStart(o,t-a),r.collapse(!0),c.removeAllRanges(),void c.addRange(r);a+=l}r.selectNodeContents(e),r.collapse(!1),c.removeAllRanges(),c.addRange(r)}(n,c),e.onChange&&e.onChange(t)}}}}}}function p(e){e&&(e.highlight=i,e.codeEditor=function(c){return function(e){t||(t=!0,e&&e.injectCSS&&e.injectCSS(o,{id:"bw-code-edit-styles"}))}(e),s(c)})}"undefined"!=typeof window&&window.bw&&p(window.bw);var u={highlight:i,codeEditor:s,install:p,CSS_TEXT:o};e.CSS_TEXT=o,e.codeEditor=s,e.default=u,e.highlight=i,e.install=p,e.tokenizeCSS=n,e.tokenizeHTML=a,e.tokenizeJS=r,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
14
|
+
*/var t=!1,o='.bw_ce{background:#1e293b;border-radius:6px;border:1px solid rgba(255,255,255,0.08);overflow:auto}.bw_ce pre{margin:0;padding:0}.bw_ce code{font-family:"SF Mono",Monaco,"Cascadia Code",Consolas,monospace;font-size:0.875rem;line-height:1.6;color:#e2e8f0;outline:none;white-space:pre-wrap;display:block;padding:0.75rem 1rem}.bw_ce code:empty::before{content:"\\200b"}.bw_ce .bw_ce_keyword{color:#c792ea}.bw_ce .bw_ce_string{color:#c3e88d}.bw_ce .bw_ce_comment{color:#546e7a;font-style:italic}.bw_ce .bw_ce_number{color:#f78c6c}.bw_ce .bw_ce_operator{color:#89ddff}.bw_ce .bw_ce_punctuation{color:#89ddff}.bw_ce .bw_ce_property{color:#82aaff}.bw_ce .bw_ce_function{color:#82aaff}.bw_ce .bw_ce_tag{color:#f07178}.bw_ce .bw_ce_attr_name{color:#ffcb6b}.bw_ce .bw_ce_attr_value{color:#c3e88d}.bw_ce .bw_ce_selector{color:#c792ea}.bw_ce .bw_ce_css_prop{color:#82aaff}.bw_ce .bw_ce_css_value{color:#f78c6c}.bw_ce .bw_ce_at_rule{color:#c792ea;font-style:italic}.bw_ce .bw_ce_color{color:#f78c6c}.bw_ce .bw_ce_template_interp{color:#89ddff}.bw_ce_light.bw_ce{background:#fafafa;border-color:#d8d8d8}.bw_ce_light.bw_ce code{color:#1a1a1a}.bw_ce_light.bw_ce .bw_ce_keyword{color:#7c3aed}.bw_ce_light.bw_ce .bw_ce_string{color:#16a34a}.bw_ce_light.bw_ce .bw_ce_comment{color:#9ca3af;font-style:italic}.bw_ce_light.bw_ce .bw_ce_number{color:#ea580c}.bw_ce_light.bw_ce .bw_ce_operator{color:#0891b2}.bw_ce_light.bw_ce .bw_ce_punctuation{color:#6b7280}.bw_ce_light.bw_ce .bw_ce_property{color:#2563eb}.bw_ce_light.bw_ce .bw_ce_function{color:#2563eb}.bw_ce_light.bw_ce .bw_ce_tag{color:#dc2626}.bw_ce_light.bw_ce .bw_ce_attr_name{color:#d97706}.bw_ce_light.bw_ce .bw_ce_attr_value{color:#16a34a}.bw_ce_light.bw_ce .bw_ce_selector{color:#7c3aed}.bw_ce_light.bw_ce .bw_ce_css_prop{color:#2563eb}.bw_ce_light.bw_ce .bw_ce_css_value{color:#ea580c}.bw_ce_light.bw_ce .bw_ce_at_rule{color:#7c3aed}.bw_ce_light.bw_ce .bw_ce_color{color:#ea580c}.bw_ce_light.bw_ce .bw_ce_template_interp{color:#0891b2}';var c={};function r(e){var t=[],o=0,n=e.length,a="";function l(e){a.length&&(t.push({type:e,text:a}),a="")}for(;o<n;){var i=e[o],s=e[o+1];if("/"!==i||"/"!==s)if("/"!==i||"*"!==s){if("/"===i&&"/"!==s&&"*"!==s){var p=t.length?t[t.length-1]:null,_=!1;if(a.trim().length||p&&"operator"!==p.type&&"punctuation"!==p.type&&"keyword"!==p.type||(_=!0),_){l("plain");for(var u="/",f=o+1,b=!1,w=!1;f<n;){var d=e[f];if(b)u+=d,b=!1,f++;else if("\\"!==d)if("["!==d)if("]"!==d){if("/"===d&&!w){u+=d,f++;break}if("\n"===d)break;u+=d,f++}else w=!1,u+=d,f++;else w=!0,u+=d,f++;else b=!0,u+=d,f++}for(;f<n&&/[gimsuvy]/.test(e[f]);)u+=e[f],f++;t.push({type:"string",text:u}),o=f;continue}}if('"'!==i&&"'"!==i&&"`"!==i)if(/[0-9]/.test(i)||"."===i&&s&&/[0-9]/.test(s)){l("plain");var h="";if("0"===i&&s&&/[xXbBoO]/.test(s))for(h=i+s,o+=2;o<n&&/[0-9a-fA-F_]/.test(e[o]);)h+=e[o],o++;else for(;o<n&&/[0-9._eE]/.test(e[o]);)"e"!==e[o]&&"E"!==e[o]||!e[o+1]||!/[+\-0-9]/.test(e[o+1])?(h+=e[o],o++):(h+=e[o]+e[o+1],o+=2);t.push({type:"number",text:h})}else if(/[a-zA-Z_$]/.test(i)){l("plain");for(var g="";o<n&&/[a-zA-Z0-9_$]/.test(e[o]);)g+=e[o],o++;for(var v=o;v<n&&(" "===e[v]||"\t"===e[v]);)v++;var y=t.length?t[t.length-1]:null,x=y&&"punctuation"===y.type&&"."===y.text;c[g]?t.push({type:"keyword",text:g}):x?v<n&&"("===e[v]?t.push({type:"function",text:g}):t.push({type:"property",text:g}):v<n&&"("===e[v]?t.push({type:"function",text:g}):t.push({type:"plain",text:g})}else if(-1==="=+-*/%!<>&|^~?:".indexOf(i))-1==="(){}[];,.".indexOf(i)?(a+=i,o++):(l("plain"),t.push({type:"punctuation",text:i}),o++);else{l("plain");var m=i;++o<n&&-1!=="=+-*/%!<>&|^~?:".indexOf(e[o])&&(m+=e[o],++o<n&&-1!=="=>&|".indexOf(e[o])&&(m+=e[o],o++)),t.push({type:"operator",text:m})}else{l("plain");var k=i,C=i,S=o+1;if("`"===k){for(;S<n;){var T=e[S];if("\\"!==T)if("$"!==T||"{"!==e[S+1]){if("`"===T){C+=T,S++;break}C+=T,S++}else{C.length&&t.push({type:"string",text:C}),C="",t.push({type:"template-interp",text:"${"}),S+=2;for(var A=1,E="";S<n&&A>0;){if("{"===e[S])A++;else if("}"===e[S]&&0===--A)break;E+=e[S],S++}var O=r(E);(t=t.concat(O)).push({type:"template-interp",text:"}"}),S++}else C+=T+(e[S+1]||""),S+=2}C.length&&t.push({type:"string",text:C})}else{for(;S<n;){var z=e[S];if("\\"!==z){if(z===k){C+=z,S++;break}if("\n"===z)break;C+=z,S++}else C+=z+(e[S+1]||""),S+=2}t.push({type:"string",text:C})}o=S}}else{l("plain");var R=e.indexOf("*/",o+2);-1===R&&(R=n-2),t.push({type:"comment",text:e.substring(o,R+2)}),o=R+2}else{l("plain");var Z=e.indexOf("\n",o);-1===Z&&(Z=n),t.push({type:"comment",text:e.substring(o,Z)}),o=Z}}return l("plain"),t}function n(e){var t=[],o=0,c=e.length,r="selector",n="";function a(e){n.length&&(t.push({type:e||"plain",text:n}),n="")}for(;o<c;){var l=e[o],i=e[o+1];if("/"!==l||"*"!==i)if('"'!==l&&"'"!==l||"value"!==r&&"selector"!==r)if("@"!==l||"selector"!==r)if("#"!==l||"value"!==r)if("value"===r&&/[0-9]/.test(l)){a("css-value");for(var s="";o<c&&/[0-9.]/.test(e[o]);)s+=e[o],o++;for(var p="";o<c&&/[a-zA-Z%]/.test(e[o]);)p+=e[o],o++;t.push({type:"number",text:s+p})}else"{"!==l?"}"!==l?":"!==l||"prop"!==r?";"!==l?","!==l?(n+=l,o++):(a("selector"===r?"selector":"value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),o++):(a("value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),r="prop",o++):(a("css-prop"),t.push({type:"punctuation",text:l}),r="value",o++):(a("prop"===r?"css-prop":"value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),r="selector",o++):(a("selector"===r?"selector":"plain"),t.push({type:"punctuation",text:l}),r="prop",o++);else{a("css-value");var _="#";for(o++;o<c&&/[0-9a-fA-F]/.test(e[o]);)_+=e[o],o++;t.push({type:"color",text:_})}else{a("selector");var u="@";for(o++;o<c&&/[a-zA-Z\-]/.test(e[o]);)u+=e[o],o++;t.push({type:"at-rule",text:u})}else{a("selector"===r?"selector":"css-value");var f=l,b=l;for(o++;o<c;)if("\\"!==e[o]){if(e[o]===f){b+=e[o],o++;break}b+=e[o],o++}else b+=e[o]+(e[o+1]||""),o+=2;t.push({type:"string",text:b})}else{a("selector"===r?"selector":"prop"===r?"css-prop":"css-value");var w=e.indexOf("*/",o+2);-1===w&&(w=c-2),t.push({type:"comment",text:e.substring(o,w+2)}),o=w+2}}return a("selector"===r?"selector":"prop"===r?"css-prop":"css-value"),t}function a(e){var t=[],o=0,c=e.length,r="";function n(e){r.length&&(t.push({type:e,text:r}),r="")}for(;o<c;){var a=e[o];if("<"!==a||"\x3c!--"!==e.substring(o,o+4))if("<"!==a)if("&"!==a)r+=a,o++;else{n("plain");var l="&";for(o++;o<c&&";"!==e[o]&&/[a-zA-Z0-9#]/.test(e[o]);)l+=e[o],o++;o<c&&";"===e[o]&&(l+=";",o++),t.push({type:"string",text:l})}else{n("plain");var i="<";for(++o<c&&"/"===e[o]&&(i+="/",o++);o<c&&/[a-zA-Z0-9\-]/.test(e[o]);)i+=e[o],o++;for(t.push({type:"tag",text:i});o<c&&">"!==e[o]&&("/"!==e[o]||">"!==e[o+1]);)if(/\s/.test(e[o])){for(var s="";o<c&&/\s/.test(e[o]);)s+=e[o],o++;t.push({type:"plain",text:s})}else if(/[a-zA-Z_\-@:]/.test(e[o])){for(var p="";o<c&&/[a-zA-Z0-9_\-@:]/.test(e[o]);)p+=e[o],o++;if(t.push({type:"attr-name",text:p}),o<c&&"="===e[o])if(t.push({type:"punctuation",text:"="}),++o<c&&('"'===e[o]||"'"===e[o])){var _=e[o],u=_;for(o++;o<c&&e[o]!==_;)u+=e[o],o++;o<c&&(u+=e[o],o++),t.push({type:"attr-value",text:u})}else{for(var f="";o<c&&!/[\s>]/.test(e[o]);)f+=e[o],o++;t.push({type:"attr-value",text:f})}}else r+=e[o],o++,n("plain");var b="";o<c&&"/"===e[o]&&(b+="/",o++),o<c&&">"===e[o]&&(b+=">",o++),b&&t.push({type:"tag",text:b})}else{n("plain");var w=e.indexOf("--\x3e",o+4);-1===w&&(w=c-3),t.push({type:"comment",text:e.substring(o,w+3)}),o=w+3}}return n("plain"),t}"var,const,let,function,return,if,else,for,while,do,switch,case,break,continue,new,typeof,instanceof,this,class,extends,import,export,default,from,true,false,null,undefined,try,catch,throw,finally,async,await,yield,of,in,delete,void,with,super,static,get,set,debugger".split(",").forEach(function(e){c[e]=!0});var l={js:r,javascript:r,css:n,html:a};function i(e,t){return function(e){for(var t=[],o=0;o<e.length;o++){var c=e[o];"plain"===c.type?t.push(c.text):t.push({t:"span",a:{class:"bw_ce_"+c.type},c:c.text})}return t}((l[t]||r)(e))}function s(e){var t=(e=e||{}).code||"",o=e.lang||"js",c=e.height||"180px",r=!!e.readOnly,n="bw_ce"+(e.className?" "+e.className:""),a=i(t,o),l={spellcheck:"false",class:"bw_ce_code"};return r||(l.contenteditable="true"),{t:"div",a:{class:n,style:"max-height:"+c+";overflow:auto"},c:[{t:"pre",c:{t:"code",a:l,c:a}}],o:{mounted:function(c){var n=c.querySelector(".bw_ce_code");if(n){var a=t,l=null,s="undefined"!=typeof window&&window.bw||{};c._bwCodeEdit={getValue:p,setValue:function(e){a=e;var t=i(e,o);s.html&&(n.innerHTML=s.html({t:"span",c:t}))}},r||(n.addEventListener("input",function(){clearTimeout(l),l=setTimeout(_,50)}),n.addEventListener("keydown",function(e){"Tab"===e.key&&(e.preventDefault(),document.execCommand("insertText",!1," "))}))}function p(){return n.textContent||""}function _(){var t=p();if(t!==a){a=t;var c=function(e){var t=window.getSelection();if(!t.rangeCount)return 0;var o=t.getRangeAt(0).cloneRange();return o.selectNodeContents(e),o.setEnd(t.getRangeAt(0).startContainer,t.getRangeAt(0).startOffset),o.toString().length}(n),r=i(t,o);s.html&&(n.innerHTML=s.html({t:"span",c:r})),function(e,t){for(var o,c=window.getSelection(),r=document.createRange(),n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null,!1),a=0;o=n.nextNode();){var l=o.textContent.length;if(a+l>=t)return r.setStart(o,t-a),r.collapse(!0),c.removeAllRanges(),void c.addRange(r);a+=l}r.selectNodeContents(e),r.collapse(!1),c.removeAllRanges(),c.addRange(r)}(n,c),e.onChange&&e.onChange(t)}}}}}}function p(e){e&&(e.highlight=i,e.codeEditor=function(c){return function(e){t||(t=!0,e&&e.injectCSS&&e.injectCSS(o,{id:"bw_code_edit_styles"}))}(e),s(c)})}"undefined"!=typeof window&&window.bw&&p(window.bw);var _={highlight:i,codeEditor:s,install:p,CSS_TEXT:o};e.CSS_TEXT=o,e.codeEditor=s,e.default=_,e.highlight=i,e.install=p,e.tokenizeCSS=n,e.tokenizeHTML=a,e.tokenizeJS=r,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
15
15
|
//# sourceMappingURL=bitwrench-code-edit.umd.min.js.map
|