@gelight/sml-editor
Advanced tools
Comparing version
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).sml_editor=e()}(this,(function(){"use strict";function t(){}function e(t,e){for(const n in e)t[n]=e[n];return t}function n(t){return t()}function o(){return Object.create(null)}function r(t){t.forEach(n)}function s(t){return"function"==typeof t}function i(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function l(t){const e={};for(const n in t)"$"!==n[0]&&(e[n]=t[n]);return e}function a(t,e,n){t.insertBefore(e,n||null)}function c(t){t.parentNode.removeChild(t)}function u(t,e,n,o){return t.addEventListener(e,n,o),()=>t.removeEventListener(e,n,o)}function d(t,e){t.value=null==e?"":e}function f(t){const e={};for(const n of t)e[n.name]=n.value;return e}let h;function m(t){h=t}const p=[],g=[],$=[],v=[],b=Promise.resolve();let y=!1;function x(t){$.push(t)}let _=!1;const E=new Set;function w(){if(!_){_=!0;do{for(let t=0;t<p.length;t+=1){const e=p[t];m(e),k(e.$$)}for(m(null),p.length=0;g.length;)g.pop()();for(let t=0;t<$.length;t+=1){const e=$[t];E.has(e)||(E.add(e),e())}$.length=0}while(p.length);for(;v.length;)v.pop()();y=!1,_=!1,E.clear()}}function k(t){if(null!==t.fragment){t.update(),r(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(x)}}const C=new Set;function T(t,e){-1===t.$$.dirty[0]&&(p.push(t),y||(y=!0,b.then(w)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function z(e,i,l,a,u,d,f=[-1]){const p=h;m(e);const g=e.$$={fragment:null,ctx:null,props:d,update:t,not_equal:u,bound:o(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(p?p.$$.context:[]),callbacks:o(),dirty:f,skip_bound:!1};let $=!1;if(g.ctx=l?l(e,i.props||{},((t,n,...o)=>{const r=o.length?o[0]:n;return g.ctx&&u(g.ctx[t],g.ctx[t]=r)&&(!g.skip_bound&&g.bound[t]&&g.bound[t](r),$&&T(e,t)),n})):[],g.update(),$=!0,r(g.before_update),g.fragment=!!a&&a(g.ctx),i.target){if(i.hydrate){const t=function(t){return Array.from(t.childNodes)}(i.target);g.fragment&&g.fragment.l(t),t.forEach(c)}else g.fragment&&g.fragment.c();i.intro&&((v=e.$$.fragment)&&v.i&&(C.delete(v),v.i(b))),function(t,e,o,i){const{fragment:l,on_mount:a,on_destroy:c,after_update:u}=t.$$;l&&l.m(e,o),i||x((()=>{const e=a.map(n).filter(s);c?c.push(...e):r(e),t.$$.on_mount=[]})),u.forEach(x)}(e,i.target,i.anchor,i.customElement),w()}var v,b;m(p)}let S;function H(e){let n,o,s;return{c(){var e;e="textarea",n=document.createElement(e),this.c=t},m(t,r){a(t,n,r),e[3](n),d(n,e[0]),o||(s=[u(n,"keyup",e[2]),u(n,"input",e[4])],o=!0)},p(t,[e]){1&e&&d(n,t[0])},i:t,o:t,d(t){t&&c(n),e[3](null),o=!1,r(s)}}}function j(t,n,o){let r,s=function(){if(!h)throw new Error("Function called outside component initialization");return h}(),{value:i=""}=n;const a=()=>{"auto-resize"in n&&setTimeout((()=>{o(1,r.style.height="auto",r),o(1,r.style.height=r.scrollHeight+"px",r)}),0)},c=t=>{t.ctrlKey&&86===t.keyCode&&o(1,r.scrollTop=r.scrollHeight,r)},u=t=>{let e=t.selectionEnd,n=t.value,o=0;for(let t=e-1;t>=0;t--)if("\n"==n[t]){o=t+1;break}let r=0;for(let t=o;t<n.length&&(" "==n[t]||"\t"==n[t]||" "==n[t]);t++)r++;return n.substring(o,o+r)};return t.$$set=t=>{o(9,n=e(e({},n),l(t))),"value"in t&&o(0,i=t.value)},n=l(n),[i,r,t=>{const e=t.target;if(9===t.keyCode||"Tab"===t.key){t.preventDefault();let n=e.selectionStart,o=e.selectionEnd;e.value=e.value.substring(0,n)+"\t"+e.value.substring(o);let r=n+1;e.selectionStart=r,e.selectionEnd=r}else if(13===t.keyCode||"Enter"===t.key){t.preventDefault();let n=u(e),o=e.selectionStart,r=e.selectionEnd;e.value=e.value.substring(0,o)+"\n"+n+e.value.substring(r);let s=o+1+n.length;e.selectionStart=s,e.selectionEnd=s}"auto-resize"in n&&setTimeout((()=>{o(1,r.style.height="auto",r),o(1,r.style.height=r.scrollHeight+"px",r)}),0),a(),c(t),s.dispatchEvent(new CustomEvent("change",{detail:{value:i},composed:!0}))},function(t){g[t?"unshift":"push"]((()=>{r=t,o(1,r)}))},function(){i=this.value,o(0,i)}]}"function"==typeof HTMLElement&&(S=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){const{on_mount:t}=this.$$;this.$$.on_disconnect=t.map(n).filter(s);for(const t in this.$$.slotted)this.appendChild(this.$$.slotted[t])}attributeChangedCallback(t,e,n){this[t]=n}disconnectedCallback(){r(this.$$.on_disconnect)}$destroy(){!function(t,e){const n=t.$$;null!==n.fragment&&(r(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}(this,1),this.$destroy=t}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}});class L extends S{constructor(t){super(),this.shadowRoot.innerHTML="<style>:host{display:flex;justify-content:stretch;align-items:stretch}textarea{box-sizing:border-box;white-space:pre-wrap;outline:none;tab-size:var(--sml-editor-tab-size);width:100%;max-height:var(--sml-editor-max-height);height:var(--sml-editor-height);overflow:auto;color:var(--sml-editor-color);background:var(--sml-editor-bg);border:var(--sml-editor-border);padding:var(--sml-editor-padding);box-shadow:var(--sml-editor-box-shadow);text-shadow:var(--sml-editor-text-shadow);font-family:var(--sml-editor-font-family);font-size:var(--sml-editor-font-size);line-height:var(--sml-editor-line-height);font-weight:var(--sml-editor-font-weight);font-style:var(--sml-editor-font-style);font-stretch:var(--sml-editor-font-stretch);letter-spacing:var(--sml-editor-letter-spacing);text-transform:var(--sml-editor-text-transform)}</style>",z(this,{target:this.shadowRoot,props:f(this.attributes),customElement:!0},j,H,i,{value:0}),t&&(t.target&&a(t.target,this,t.anchor),t.props&&(this.$set(t.props),w()))}static get observedAttributes(){return["value"]}get value(){return this.$$.ctx[0]}set value(t){this.$set({value:t}),w()}}return customElements.define("sml-editor",L),L})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).sml_editor=e()}(this,(function(){"use strict";function t(){}function e(t,e){for(const n in e)t[n]=e[n];return t}function n(t){return t()}function o(){return Object.create(null)}function r(t){t.forEach(n)}function s(t){return"function"==typeof t}function i(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function l(t){const e={};for(const n in t)"$"!==n[0]&&(e[n]=t[n]);return e}function a(t,e,n){t.insertBefore(e,n||null)}function c(t){t.parentNode.removeChild(t)}function u(t,e,n,o){return t.addEventListener(e,n,o),()=>t.removeEventListener(e,n,o)}function d(t,e){t.value=null==e?"":e}function f(t){const e={};for(const n of t)e[n.name]=n.value;return e}let h;function m(t){h=t}const p=[],g=[],$=[],v=[],b=Promise.resolve();let y=!1;function x(t){$.push(t)}let _=!1;const w=new Set;function E(){if(!_){_=!0;do{for(let t=0;t<p.length;t+=1){const e=p[t];m(e),k(e.$$)}for(m(null),p.length=0;g.length;)g.pop()();for(let t=0;t<$.length;t+=1){const e=$[t];w.has(e)||(w.add(e),e())}$.length=0}while(p.length);for(;v.length;)v.pop()();y=!1,_=!1,w.clear()}}function k(t){if(null!==t.fragment){t.update(),r(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(x)}}const C=new Set;function T(t,e){-1===t.$$.dirty[0]&&(p.push(t),y||(y=!0,b.then(E)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function z(e,i,l,a,u,d,f=[-1]){const p=h;m(e);const g=e.$$={fragment:null,ctx:null,props:d,update:t,not_equal:u,bound:o(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(p?p.$$.context:[]),callbacks:o(),dirty:f,skip_bound:!1};let $=!1;if(g.ctx=l?l(e,i.props||{},((t,n,...o)=>{const r=o.length?o[0]:n;return g.ctx&&u(g.ctx[t],g.ctx[t]=r)&&(!g.skip_bound&&g.bound[t]&&g.bound[t](r),$&&T(e,t)),n})):[],g.update(),$=!0,r(g.before_update),g.fragment=!!a&&a(g.ctx),i.target){if(i.hydrate){const t=function(t){return Array.from(t.childNodes)}(i.target);g.fragment&&g.fragment.l(t),t.forEach(c)}else g.fragment&&g.fragment.c();i.intro&&((v=e.$$.fragment)&&v.i&&(C.delete(v),v.i(b))),function(t,e,o,i){const{fragment:l,on_mount:a,on_destroy:c,after_update:u}=t.$$;l&&l.m(e,o),i||x((()=>{const e=a.map(n).filter(s);c?c.push(...e):r(e),t.$$.on_mount=[]})),u.forEach(x)}(e,i.target,i.anchor,i.customElement),E()}var v,b;m(p)}let S;function j(e){let n,o,s;return{c(){var e;e="textarea",n=document.createElement(e),this.c=t},m(t,r){a(t,n,r),e[4](n),d(n,e[0]),o||(s=[u(n,"keydown",e[2]),u(n,"keyup",e[3]),u(n,"input",e[5])],o=!0)},p(t,[e]){1&e&&d(n,t[0])},i:t,o:t,d(t){t&&c(n),e[4](null),o=!1,r(s)}}}function H(t,n,o){let r,s=function(){if(!h)throw new Error("Function called outside component initialization");return h}(),{value:i=""}=n;const a=()=>{"auto-resize"in n&&setTimeout((()=>{o(1,r.style.height="auto",r),o(1,r.style.height=r.scrollHeight+"px",r)}),0)},c=t=>{t.ctrlKey&&86===t.keyCode&&o(1,r.scrollTop=r.scrollHeight,r)},u=t=>{let e=t.selectionEnd,n=t.value,o=0;for(let t=e-1;t>=0;t--)if("\n"==n[t]){o=t+1;break}let r=0;for(let t=o;t<n.length&&(" "==n[t]||"\t"==n[t]||" "==n[t]);t++)r++;return n.substring(o,o+r)};return t.$$set=t=>{o(10,n=e(e({},n),l(t))),"value"in t&&o(0,i=t.value)},n=l(n),[i,r,t=>{const e=t.target;if(9===t.keyCode||"Tab"===t.key){t.preventDefault();let n=e.selectionStart,o=e.selectionEnd;e.value=e.value.substring(0,n)+"\t"+e.value.substring(o);let r=n+1;e.selectionStart=r,e.selectionEnd=r}else if(13===t.keyCode||"Enter"===t.key){t.preventDefault();let n=u(e),o=e.selectionStart,r=e.selectionEnd;e.value=e.value.substring(0,o)+"\n"+n+e.value.substring(r);let s=o+1+n.length;e.selectionStart=s,e.selectionEnd=s}},t=>{a(),c(t),s.dispatchEvent(new CustomEvent("change",{detail:{value:i},composed:!0}))},function(t){g[t?"unshift":"push"]((()=>{r=t,o(1,r)}))},function(){i=this.value,o(0,i)}]}"function"==typeof HTMLElement&&(S=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){const{on_mount:t}=this.$$;this.$$.on_disconnect=t.map(n).filter(s);for(const t in this.$$.slotted)this.appendChild(this.$$.slotted[t])}attributeChangedCallback(t,e,n){this[t]=n}disconnectedCallback(){r(this.$$.on_disconnect)}$destroy(){!function(t,e){const n=t.$$;null!==n.fragment&&(r(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}(this,1),this.$destroy=t}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}});class L extends S{constructor(t){super(),this.shadowRoot.innerHTML="<style>:host{display:flex;justify-content:stretch;align-items:stretch}textarea{box-sizing:border-box;white-space:pre-wrap;outline:none;tab-size:var(--sml-editor-tab-size);width:100%;max-height:var(--sml-editor-max-height);height:var(--sml-editor-height);overflow:auto;color:var(--sml-editor-color);background:var(--sml-editor-bg);border:var(--sml-editor-border);padding:var(--sml-editor-padding);box-shadow:var(--sml-editor-box-shadow);text-shadow:var(--sml-editor-text-shadow);font-family:var(--sml-editor-font-family);font-size:var(--sml-editor-font-size);line-height:var(--sml-editor-line-height);font-weight:var(--sml-editor-font-weight);font-style:var(--sml-editor-font-style);font-stretch:var(--sml-editor-font-stretch);letter-spacing:var(--sml-editor-letter-spacing);text-transform:var(--sml-editor-text-transform)}</style>",z(this,{target:this.shadowRoot,props:f(this.attributes),customElement:!0},H,j,i,{value:0}),t&&(t.target&&a(t.target,this,t.anchor),t.props&&(this.$set(t.props),E()))}static get observedAttributes(){return["value"]}get value(){return this.$$.ctx[0]}set value(t){this.$set({value:t}),E()}}return customElements.define("sml-editor",L),L})); | ||
//# sourceMappingURL=sml-editor.min.js.map |
{ | ||
"name": "@gelight/sml-editor", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Web component for a simple SML editor", | ||
@@ -5,0 +5,0 @@ "unpkg": "dist/sml-editor.min.js", |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).sml_editor=e()}(this,(function(){"use strict";function t(){}function e(t,e){for(const n in e)t[n]=e[n];return t}function n(t){return t()}function o(){return Object.create(null)}function r(t){t.forEach(n)}function s(t){return"function"==typeof t}function i(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function l(t){const e={};for(const n in t)"$"!==n[0]&&(e[n]=t[n]);return e}function a(t,e,n){t.insertBefore(e,n||null)}function c(t){t.parentNode.removeChild(t)}function u(t,e,n,o){return t.addEventListener(e,n,o),()=>t.removeEventListener(e,n,o)}function d(t,e){t.value=null==e?"":e}function f(t){const e={};for(const n of t)e[n.name]=n.value;return e}let h;function m(t){h=t}const p=[],g=[],$=[],v=[],b=Promise.resolve();let y=!1;function x(t){$.push(t)}let _=!1;const E=new Set;function w(){if(!_){_=!0;do{for(let t=0;t<p.length;t+=1){const e=p[t];m(e),k(e.$$)}for(m(null),p.length=0;g.length;)g.pop()();for(let t=0;t<$.length;t+=1){const e=$[t];E.has(e)||(E.add(e),e())}$.length=0}while(p.length);for(;v.length;)v.pop()();y=!1,_=!1,E.clear()}}function k(t){if(null!==t.fragment){t.update(),r(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(x)}}const C=new Set;function T(t,e){-1===t.$$.dirty[0]&&(p.push(t),y||(y=!0,b.then(w)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function z(e,i,l,a,u,d,f=[-1]){const p=h;m(e);const g=e.$$={fragment:null,ctx:null,props:d,update:t,not_equal:u,bound:o(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(p?p.$$.context:[]),callbacks:o(),dirty:f,skip_bound:!1};let $=!1;if(g.ctx=l?l(e,i.props||{},((t,n,...o)=>{const r=o.length?o[0]:n;return g.ctx&&u(g.ctx[t],g.ctx[t]=r)&&(!g.skip_bound&&g.bound[t]&&g.bound[t](r),$&&T(e,t)),n})):[],g.update(),$=!0,r(g.before_update),g.fragment=!!a&&a(g.ctx),i.target){if(i.hydrate){const t=function(t){return Array.from(t.childNodes)}(i.target);g.fragment&&g.fragment.l(t),t.forEach(c)}else g.fragment&&g.fragment.c();i.intro&&((v=e.$$.fragment)&&v.i&&(C.delete(v),v.i(b))),function(t,e,o,i){const{fragment:l,on_mount:a,on_destroy:c,after_update:u}=t.$$;l&&l.m(e,o),i||x((()=>{const e=a.map(n).filter(s);c?c.push(...e):r(e),t.$$.on_mount=[]})),u.forEach(x)}(e,i.target,i.anchor,i.customElement),w()}var v,b;m(p)}let S;function H(e){let n,o,s;return{c(){var e;e="textarea",n=document.createElement(e),this.c=t},m(t,r){a(t,n,r),e[3](n),d(n,e[0]),o||(s=[u(n,"keyup",e[2]),u(n,"input",e[4])],o=!0)},p(t,[e]){1&e&&d(n,t[0])},i:t,o:t,d(t){t&&c(n),e[3](null),o=!1,r(s)}}}function j(t,n,o){let r,s=function(){if(!h)throw new Error("Function called outside component initialization");return h}(),{value:i=""}=n;const a=()=>{"auto-resize"in n&&setTimeout((()=>{o(1,r.style.height="auto",r),o(1,r.style.height=r.scrollHeight+"px",r)}),0)},c=t=>{t.ctrlKey&&86===t.keyCode&&o(1,r.scrollTop=r.scrollHeight,r)},u=t=>{let e=t.selectionEnd,n=t.value,o=0;for(let t=e-1;t>=0;t--)if("\n"==n[t]){o=t+1;break}let r=0;for(let t=o;t<n.length&&(" "==n[t]||"\t"==n[t]||" "==n[t]);t++)r++;return n.substring(o,o+r)};return t.$$set=t=>{o(9,n=e(e({},n),l(t))),"value"in t&&o(0,i=t.value)},n=l(n),[i,r,t=>{const e=t.target;if(9===t.keyCode||"Tab"===t.key){t.preventDefault();let n=e.selectionStart,o=e.selectionEnd;e.value=e.value.substring(0,n)+"\t"+e.value.substring(o);let r=n+1;e.selectionStart=r,e.selectionEnd=r}else if(13===t.keyCode||"Enter"===t.key){t.preventDefault();let n=u(e),o=e.selectionStart,r=e.selectionEnd;e.value=e.value.substring(0,o)+"\n"+n+e.value.substring(r);let s=o+1+n.length;e.selectionStart=s,e.selectionEnd=s}"auto-resize"in n&&setTimeout((()=>{o(1,r.style.height="auto",r),o(1,r.style.height=r.scrollHeight+"px",r)}),0),a(),c(t),s.dispatchEvent(new CustomEvent("change",{detail:{value:i},composed:!0}))},function(t){g[t?"unshift":"push"]((()=>{r=t,o(1,r)}))},function(){i=this.value,o(0,i)}]}"function"==typeof HTMLElement&&(S=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){const{on_mount:t}=this.$$;this.$$.on_disconnect=t.map(n).filter(s);for(const t in this.$$.slotted)this.appendChild(this.$$.slotted[t])}attributeChangedCallback(t,e,n){this[t]=n}disconnectedCallback(){r(this.$$.on_disconnect)}$destroy(){!function(t,e){const n=t.$$;null!==n.fragment&&(r(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}(this,1),this.$destroy=t}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}});class L extends S{constructor(t){super(),this.shadowRoot.innerHTML="<style>:host{display:flex;justify-content:stretch;align-items:stretch}textarea{box-sizing:border-box;white-space:pre-wrap;outline:none;tab-size:var(--sml-editor-tab-size);width:100%;max-height:var(--sml-editor-max-height);height:var(--sml-editor-height);overflow:auto;color:var(--sml-editor-color);background:var(--sml-editor-bg);border:var(--sml-editor-border);padding:var(--sml-editor-padding);box-shadow:var(--sml-editor-box-shadow);text-shadow:var(--sml-editor-text-shadow);font-family:var(--sml-editor-font-family);font-size:var(--sml-editor-font-size);line-height:var(--sml-editor-line-height);font-weight:var(--sml-editor-font-weight);font-style:var(--sml-editor-font-style);font-stretch:var(--sml-editor-font-stretch);letter-spacing:var(--sml-editor-letter-spacing);text-transform:var(--sml-editor-text-transform)}</style>",z(this,{target:this.shadowRoot,props:f(this.attributes),customElement:!0},j,H,i,{value:0}),t&&(t.target&&a(t.target,this,t.anchor),t.props&&(this.$set(t.props),w()))}static get observedAttributes(){return["value"]}get value(){return this.$$.ctx[0]}set value(t){this.$set({value:t}),w()}}return customElements.define("sml-editor",L),L})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).sml_editor=e()}(this,(function(){"use strict";function t(){}function e(t,e){for(const n in e)t[n]=e[n];return t}function n(t){return t()}function o(){return Object.create(null)}function r(t){t.forEach(n)}function s(t){return"function"==typeof t}function i(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function l(t){const e={};for(const n in t)"$"!==n[0]&&(e[n]=t[n]);return e}function a(t,e,n){t.insertBefore(e,n||null)}function c(t){t.parentNode.removeChild(t)}function u(t,e,n,o){return t.addEventListener(e,n,o),()=>t.removeEventListener(e,n,o)}function d(t,e){t.value=null==e?"":e}function f(t){const e={};for(const n of t)e[n.name]=n.value;return e}let h;function m(t){h=t}const p=[],g=[],$=[],v=[],b=Promise.resolve();let y=!1;function x(t){$.push(t)}let _=!1;const w=new Set;function E(){if(!_){_=!0;do{for(let t=0;t<p.length;t+=1){const e=p[t];m(e),k(e.$$)}for(m(null),p.length=0;g.length;)g.pop()();for(let t=0;t<$.length;t+=1){const e=$[t];w.has(e)||(w.add(e),e())}$.length=0}while(p.length);for(;v.length;)v.pop()();y=!1,_=!1,w.clear()}}function k(t){if(null!==t.fragment){t.update(),r(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(x)}}const C=new Set;function T(t,e){-1===t.$$.dirty[0]&&(p.push(t),y||(y=!0,b.then(E)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function z(e,i,l,a,u,d,f=[-1]){const p=h;m(e);const g=e.$$={fragment:null,ctx:null,props:d,update:t,not_equal:u,bound:o(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(p?p.$$.context:[]),callbacks:o(),dirty:f,skip_bound:!1};let $=!1;if(g.ctx=l?l(e,i.props||{},((t,n,...o)=>{const r=o.length?o[0]:n;return g.ctx&&u(g.ctx[t],g.ctx[t]=r)&&(!g.skip_bound&&g.bound[t]&&g.bound[t](r),$&&T(e,t)),n})):[],g.update(),$=!0,r(g.before_update),g.fragment=!!a&&a(g.ctx),i.target){if(i.hydrate){const t=function(t){return Array.from(t.childNodes)}(i.target);g.fragment&&g.fragment.l(t),t.forEach(c)}else g.fragment&&g.fragment.c();i.intro&&((v=e.$$.fragment)&&v.i&&(C.delete(v),v.i(b))),function(t,e,o,i){const{fragment:l,on_mount:a,on_destroy:c,after_update:u}=t.$$;l&&l.m(e,o),i||x((()=>{const e=a.map(n).filter(s);c?c.push(...e):r(e),t.$$.on_mount=[]})),u.forEach(x)}(e,i.target,i.anchor,i.customElement),E()}var v,b;m(p)}let S;function j(e){let n,o,s;return{c(){var e;e="textarea",n=document.createElement(e),this.c=t},m(t,r){a(t,n,r),e[4](n),d(n,e[0]),o||(s=[u(n,"keydown",e[2]),u(n,"keyup",e[3]),u(n,"input",e[5])],o=!0)},p(t,[e]){1&e&&d(n,t[0])},i:t,o:t,d(t){t&&c(n),e[4](null),o=!1,r(s)}}}function H(t,n,o){let r,s=function(){if(!h)throw new Error("Function called outside component initialization");return h}(),{value:i=""}=n;const a=()=>{"auto-resize"in n&&setTimeout((()=>{o(1,r.style.height="auto",r),o(1,r.style.height=r.scrollHeight+"px",r)}),0)},c=t=>{t.ctrlKey&&86===t.keyCode&&o(1,r.scrollTop=r.scrollHeight,r)},u=t=>{let e=t.selectionEnd,n=t.value,o=0;for(let t=e-1;t>=0;t--)if("\n"==n[t]){o=t+1;break}let r=0;for(let t=o;t<n.length&&(" "==n[t]||"\t"==n[t]||" "==n[t]);t++)r++;return n.substring(o,o+r)};return t.$$set=t=>{o(10,n=e(e({},n),l(t))),"value"in t&&o(0,i=t.value)},n=l(n),[i,r,t=>{const e=t.target;if(9===t.keyCode||"Tab"===t.key){t.preventDefault();let n=e.selectionStart,o=e.selectionEnd;e.value=e.value.substring(0,n)+"\t"+e.value.substring(o);let r=n+1;e.selectionStart=r,e.selectionEnd=r}else if(13===t.keyCode||"Enter"===t.key){t.preventDefault();let n=u(e),o=e.selectionStart,r=e.selectionEnd;e.value=e.value.substring(0,o)+"\n"+n+e.value.substring(r);let s=o+1+n.length;e.selectionStart=s,e.selectionEnd=s}},t=>{a(),c(t),s.dispatchEvent(new CustomEvent("change",{detail:{value:i},composed:!0}))},function(t){g[t?"unshift":"push"]((()=>{r=t,o(1,r)}))},function(){i=this.value,o(0,i)}]}"function"==typeof HTMLElement&&(S=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){const{on_mount:t}=this.$$;this.$$.on_disconnect=t.map(n).filter(s);for(const t in this.$$.slotted)this.appendChild(this.$$.slotted[t])}attributeChangedCallback(t,e,n){this[t]=n}disconnectedCallback(){r(this.$$.on_disconnect)}$destroy(){!function(t,e){const n=t.$$;null!==n.fragment&&(r(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}(this,1),this.$destroy=t}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}});class L extends S{constructor(t){super(),this.shadowRoot.innerHTML="<style>:host{display:flex;justify-content:stretch;align-items:stretch}textarea{box-sizing:border-box;white-space:pre-wrap;outline:none;tab-size:var(--sml-editor-tab-size);width:100%;max-height:var(--sml-editor-max-height);height:var(--sml-editor-height);overflow:auto;color:var(--sml-editor-color);background:var(--sml-editor-bg);border:var(--sml-editor-border);padding:var(--sml-editor-padding);box-shadow:var(--sml-editor-box-shadow);text-shadow:var(--sml-editor-text-shadow);font-family:var(--sml-editor-font-family);font-size:var(--sml-editor-font-size);line-height:var(--sml-editor-line-height);font-weight:var(--sml-editor-font-weight);font-style:var(--sml-editor-font-style);font-stretch:var(--sml-editor-font-stretch);letter-spacing:var(--sml-editor-letter-spacing);text-transform:var(--sml-editor-text-transform)}</style>",z(this,{target:this.shadowRoot,props:f(this.attributes),customElement:!0},H,j,i,{value:0}),t&&(t.target&&a(t.target,this,t.anchor),t.props&&(this.$set(t.props),E()))}static get observedAttributes(){return["value"]}get value(){return this.$$.ctx[0]}set value(t){this.$set({value:t}),E()}}return customElements.define("sml-editor",L),L})); | ||
//# sourceMappingURL=sml-editor.min.js.map |
@@ -42,20 +42,20 @@ # SLM Editor | ||
| CSS Variables | | ||
| ----------------------------- | | ||
| --sml-editor-tab-size | | ||
| --sml-editor-color | | ||
| --sml-editor-bg | | ||
| --sml-editor-border | | ||
| --sml-editor-padding | | ||
| --sml-editor-max-height | | ||
| --sml-editor-height | | ||
| --sml-editor-box-shadow | | ||
| --sml-editor-text-shadow | | ||
| --sml-editor-font-family | | ||
| --sml-editor-font-size | | ||
| --sml-editor-line-height | | ||
| --sml-editor-font-weight | | ||
| --sml-editor-font-style | | ||
| --sml-editor-font-stretch | | ||
| --sml-editor-letter-spacing | | ||
| --sml-editor-text-transform | | ||
```css | ||
--sml-editor-tab-size: 2; | ||
--sml-editor-color: #8e9fcd; | ||
--sml-editor-bg: linear-gradient(161deg, #333a47 0%, #1c1d24 100%); | ||
--sml-editor-border: 2px solid #4f5b70; | ||
--sml-editor-padding: .8rem; | ||
--sml-editor-max-height: auto; | ||
--sml-editor-height: auto; | ||
--sml-editor-box-shadow: 0 0 .8rem .8rem rgba(0,0,0,0.75); | ||
--sml-editor-text-shadow: 0px 4px 4px rgba(0,0,0,0.85); | ||
--sml-editor-font-family: monospace; | ||
--sml-editor-font-size: 14px; | ||
--sml-editor-line-height: 1.4rem; | ||
--sml-editor-font-weight: 400; | ||
--sml-editor-font-style: initial; | ||
--sml-editor-font-stretch: initial; | ||
--sml-editor-letter-spacing: .1rem; | ||
--sml-editor-text-transform: initial; | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
164087
-0.43%