overtype 2.3.1 → 2.3.2
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/dist/overtype-webcomponent.esm.js +2 -1
- package/dist/overtype-webcomponent.esm.js.map +2 -2
- package/dist/overtype-webcomponent.js +2 -1
- package/dist/overtype-webcomponent.js.map +2 -2
- package/dist/overtype-webcomponent.min.js +2 -2
- package/dist/overtype.cjs +2 -1
- package/dist/overtype.cjs.map +2 -2
- package/dist/overtype.esm.js +2 -1
- package/dist/overtype.esm.js.map +2 -2
- package/dist/overtype.js +2 -1
- package/dist/overtype.js.map +2 -2
- package/dist/overtype.min.js +50 -50
- package/package.json +1 -1
- package/src/overtype.js +4 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OverType v2.3.
|
|
2
|
+
* OverType v2.3.2
|
|
3
3
|
* A lightweight markdown editor library with perfect WYSIWYG alignment
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @author David Miranda
|
|
@@ -974,7 +974,7 @@ ${a}`:r;if(d){let k=i.value[i.selectionStart-1];i.selectionStart!==0&&k!=null&&!
|
|
|
974
974
|
<span>${n} chars, ${o} words, ${t.length} lines</span>
|
|
975
975
|
</div>
|
|
976
976
|
<div class="overtype-stat">Line ${c}, Col ${d}</div>
|
|
977
|
-
`}_setupAutoResize(){this.container.classList.add("overtype-auto-resize"),this.previousHeight=null,this._updateAutoHeight(),this.textarea.addEventListener("input",()=>this._updateAutoHeight()),window.addEventListener("resize",()=>this._updateAutoHeight())}_updateAutoHeight(){if(!this.options.autoResize)return;let e=this.textarea,t=this.preview,n=this.wrapper,o=window.getComputedStyle(e),r=parseFloat(o.paddingTop),s=parseFloat(o.paddingBottom),a=e.scrollTop;e.style.setProperty("height","auto","important");let c=e.scrollHeight;if(this.options.minHeight){let p=parseInt(this.options.minHeight);c=Math.max(c,p)}let d="hidden";if(this.options.maxHeight){let p=parseInt(this.options.maxHeight);c>p&&(c=p,d="auto")}let l=c+"px";e.style.setProperty("height",l,"important"),e.style.setProperty("overflow-y",d,"important"),t.style.setProperty("height",l,"important"),t.style.setProperty("overflow-y",d,"important"),n.style.setProperty("height",l,"important"),e.scrollTop=a,t.scrollTop=a,this.previousHeight!==c&&(this.previousHeight=c)}showStats(e){this.options.showStats=e,e&&!this.statsBar?(this.statsBar=document.createElement("div"),this.statsBar.className="overtype-stats",this.container.appendChild(this.statsBar),this._updateStats()):e&&this.statsBar?this._updateStats():!e&&this.statsBar&&(this.statsBar.remove(),this.statsBar=null)}showNormalEditMode(){return this.container.dataset.mode="normal",this.updatePreview(),requestAnimationFrame(()=>{this.textarea.scrollTop=this.preview.scrollTop,this.textarea.scrollLeft=this.preview.scrollLeft}),this}showPlainTextarea(){if(this.container.dataset.mode="plain",this.toolbar){let e=this.container.querySelector('[data-action="toggle-plain"]');e&&(e.classList.remove("active"),e.title="Show markdown preview")}return this}showPreviewMode(){return this.container.dataset.mode="preview",this.updatePreview(),this}destroy(){if(v._autoInstances.delete(this),v._stopAutoListener(),this.fileUploadInitialized&&this._destroyFileUpload(),this.element.overTypeInstance=null,v.instances.delete(this.element),this.shortcuts&&this.shortcuts.destroy(),this.wrapper){let e=this.getValue();this.wrapper.remove(),this.element.textContent=e}this.initialized=!1}static init(e,t={}){return new v(e,t)}static initFromData(e,t={}){let n=document.querySelectorAll(e);return Array.from(n).map(o=>{let r={...t};for(let s of o.attributes)if(s.name.startsWith("data-ot-")){let c=s.name.slice(8).replace(/-([a-z])/g,(d,l)=>l.toUpperCase());r[c]=v._parseDataValue(s.value)}return new v(o,r)[0]})}static _parseDataValue(e){return e==="true"?!0:e==="false"?!1:e==="null"?null:e!==""&&!isNaN(Number(e))?Number(e):e}static getInstance(e){return e.overTypeInstance||v.instances.get(e)||null}static destroyAll(){document.querySelectorAll("[data-overtype-instance]").forEach(t=>{let n=v.getInstance(t);n&&n.destroy()})}static injectStyles(e=!1){if(v.stylesInjected&&!e)return;let t=document.querySelector("style.overtype-styles");t&&t.remove();let n=v.currentTheme||B,o=ye({theme:n}),r=document.createElement("style");r.className="overtype-styles",r.textContent=o,document.head.appendChild(r),v.stylesInjected=!0}static setTheme(e,t=null){if(v._globalAutoTheme=!1,v._globalAutoCustomColors=null,e==="auto"){v._globalAutoTheme=!0,v._globalAutoCustomColors=t,v._startAutoListener(),v._applyGlobalTheme($e("auto"),t);return}v._stopAutoListener(),v._applyGlobalTheme(e,t)}static _applyGlobalTheme(e,t=null){let n=typeof e=="string"?$(e):e;t&&(n=Qe(n,t)),v.currentTheme=n,v.injectStyles(!0);let o=typeof n=="string"?n:n.name;document.querySelectorAll(".overtype-container").forEach(r=>{o&&r.setAttribute("data-theme",o)}),document.querySelectorAll(".overtype-wrapper").forEach(r=>{r.closest(".overtype-container")||o&&r.setAttribute("data-theme",o);let s=r._instance;s&&s.updatePreview()}),document.querySelectorAll("overtype-editor").forEach(r=>{o&&typeof r.setAttribute=="function"&&r.setAttribute("theme",o),typeof r.refreshTheme=="function"&&r.refreshTheme()})}static _startAutoListener(){v._autoMediaQuery||window.matchMedia&&(v._autoMediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),v._autoMediaListener=e=>{let t=e.matches?"cave":"solar";v._globalAutoTheme&&v._applyGlobalTheme(t,v._globalAutoCustomColors),v._autoInstances.forEach(n=>n._applyResolvedTheme(t))},v._autoMediaQuery.addEventListener("change",v._autoMediaListener))}static _stopAutoListener(){v._autoInstances.size>0||v._globalAutoTheme||v._autoMediaQuery&&(v._autoMediaQuery.removeEventListener("change",v._autoMediaListener),v._autoMediaQuery=null,v._autoMediaListener=null)}static setCodeHighlighter(e){C.setCodeHighlighter(e),document.querySelectorAll(".overtype-wrapper").forEach(t=>{let n=t._instance;n&&n.updatePreview&&n.updatePreview()}),document.querySelectorAll("overtype-editor").forEach(t=>{if(typeof t.getEditor=="function"){let n=t.getEditor();n&&n.updatePreview&&n.updatePreview()}})}static setCustomSyntax(e){C.setCustomSyntax(e),document.querySelectorAll(".overtype-wrapper").forEach(t=>{let n=t._instance;n&&n.updatePreview&&n.updatePreview()}),document.querySelectorAll("overtype-editor").forEach(t=>{if(typeof t.getEditor=="function"){let n=t.getEditor();n&&n.updatePreview&&n.updatePreview()}})}static initGlobalListeners(){v.globalListenersInitialized||(document.addEventListener("input",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let t=e.target.closest(".overtype-wrapper"),n=t==null?void 0:t._instance;n&&n.handleInput(e)}}),document.addEventListener("keydown",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let t=e.target.closest(".overtype-wrapper"),n=t==null?void 0:t._instance;n&&n.handleKeydown(e)}}),document.addEventListener("scroll",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let t=e.target.closest(".overtype-wrapper"),n=t==null?void 0:t._instance;n&&n.handleScroll(e)}},!0),document.addEventListener("selectionchange",e=>{let t=document.activeElement;if(t&&t.classList.contains("overtype-input")){let n=t.closest(".overtype-wrapper"),o=n==null?void 0:n._instance;o&&(o.options.showStats&&o.statsBar&&o._updateStats(),clearTimeout(o._selectionTimeout),o._selectionTimeout=setTimeout(()=>{o.updatePreview()},50))}}),v.globalListenersInitialized=!0)}};T(v,"instances",new WeakMap),T(v,"stylesInjected",!1),T(v,"globalListenersInitialized",!1),T(v,"instanceCount",0),T(v,"_autoMediaQuery",null),T(v,"_autoMediaListener",null),T(v,"_autoInstances",new Set),T(v,"_globalAutoTheme",!1),T(v,"_globalAutoCustomColors",null);var q=v;q.MarkdownParser=C;q.ShortcutsManager=oe;q.themes={solar:B,cave:$("cave")};q.getTheme=$;q.currentTheme=B;var li=q;var ci="overtype-webcomponent-container",cn="Start typing...",pn=["value","theme","toolbar","height","min-height","max-height","placeholder","font-size","line-height","padding","auto-resize","autofocus","show-stats","smart-lists","readonly","spellcheck"],Oe=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._editor=null,this._initialized=!1,this._pendingOptions={},this._styleVersion=0,this._baseStyleElement=null,this._selectionChangeHandler=null,this._isConnected=!1,this._handleChange=this._handleChange.bind(this),this._handleKeydown=this._handleKeydown.bind(this)}_decodeValue(e){return typeof e!="string"?"":e.replace(/\\r/g,"\r").replace(/\\n/g,`
|
|
977
|
+
`}_setupAutoResize(){this.container.classList.add("overtype-auto-resize"),this.previousHeight=null,this._updateAutoHeight(),this.textarea.addEventListener("input",()=>this._updateAutoHeight()),window.addEventListener("resize",()=>this._updateAutoHeight())}_updateAutoHeight(){if(!this.options.autoResize)return;let e=this.textarea,t=this.preview,n=this.wrapper,o=window.getComputedStyle(e),r=parseFloat(o.paddingTop),s=parseFloat(o.paddingBottom),a=e.scrollTop;n.style.setProperty("height","auto","important"),e.style.setProperty("height","auto","important");let c=e.scrollHeight;if(this.options.minHeight){let p=parseInt(this.options.minHeight);c=Math.max(c,p)}let d="hidden";if(this.options.maxHeight){let p=parseInt(this.options.maxHeight);c>p&&(c=p,d="auto")}let l=c+"px";e.style.setProperty("height",l,"important"),e.style.setProperty("overflow-y",d,"important"),t.style.setProperty("height",l,"important"),t.style.setProperty("overflow-y",d,"important"),n.style.setProperty("height",l,"important"),e.scrollTop=a,t.scrollTop=a,this.previousHeight!==c&&(this.previousHeight=c)}showStats(e){this.options.showStats=e,e&&!this.statsBar?(this.statsBar=document.createElement("div"),this.statsBar.className="overtype-stats",this.container.appendChild(this.statsBar),this._updateStats()):e&&this.statsBar?this._updateStats():!e&&this.statsBar&&(this.statsBar.remove(),this.statsBar=null)}showNormalEditMode(){return this.container.dataset.mode="normal",this.updatePreview(),requestAnimationFrame(()=>{this.textarea.scrollTop=this.preview.scrollTop,this.textarea.scrollLeft=this.preview.scrollLeft}),this}showPlainTextarea(){if(this.container.dataset.mode="plain",this.toolbar){let e=this.container.querySelector('[data-action="toggle-plain"]');e&&(e.classList.remove("active"),e.title="Show markdown preview")}return this}showPreviewMode(){return this.container.dataset.mode="preview",this.updatePreview(),this}destroy(){if(v._autoInstances.delete(this),v._stopAutoListener(),this.fileUploadInitialized&&this._destroyFileUpload(),this.element.overTypeInstance=null,v.instances.delete(this.element),this.shortcuts&&this.shortcuts.destroy(),this.wrapper){let e=this.getValue();this.wrapper.remove(),this.element.textContent=e}this.initialized=!1}static init(e,t={}){return new v(e,t)}static initFromData(e,t={}){let n=document.querySelectorAll(e);return Array.from(n).map(o=>{let r={...t};for(let s of o.attributes)if(s.name.startsWith("data-ot-")){let c=s.name.slice(8).replace(/-([a-z])/g,(d,l)=>l.toUpperCase());r[c]=v._parseDataValue(s.value)}return new v(o,r)[0]})}static _parseDataValue(e){return e==="true"?!0:e==="false"?!1:e==="null"?null:e!==""&&!isNaN(Number(e))?Number(e):e}static getInstance(e){return e.overTypeInstance||v.instances.get(e)||null}static destroyAll(){document.querySelectorAll("[data-overtype-instance]").forEach(t=>{let n=v.getInstance(t);n&&n.destroy()})}static injectStyles(e=!1){if(v.stylesInjected&&!e)return;let t=document.querySelector("style.overtype-styles");t&&t.remove();let n=v.currentTheme||B,o=ye({theme:n}),r=document.createElement("style");r.className="overtype-styles",r.textContent=o,document.head.appendChild(r),v.stylesInjected=!0}static setTheme(e,t=null){if(v._globalAutoTheme=!1,v._globalAutoCustomColors=null,e==="auto"){v._globalAutoTheme=!0,v._globalAutoCustomColors=t,v._startAutoListener(),v._applyGlobalTheme($e("auto"),t);return}v._stopAutoListener(),v._applyGlobalTheme(e,t)}static _applyGlobalTheme(e,t=null){let n=typeof e=="string"?$(e):e;t&&(n=Qe(n,t)),v.currentTheme=n,v.injectStyles(!0);let o=typeof n=="string"?n:n.name;document.querySelectorAll(".overtype-container").forEach(r=>{o&&r.setAttribute("data-theme",o)}),document.querySelectorAll(".overtype-wrapper").forEach(r=>{r.closest(".overtype-container")||o&&r.setAttribute("data-theme",o);let s=r._instance;s&&s.updatePreview()}),document.querySelectorAll("overtype-editor").forEach(r=>{o&&typeof r.setAttribute=="function"&&r.setAttribute("theme",o),typeof r.refreshTheme=="function"&&r.refreshTheme()})}static _startAutoListener(){v._autoMediaQuery||window.matchMedia&&(v._autoMediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),v._autoMediaListener=e=>{let t=e.matches?"cave":"solar";v._globalAutoTheme&&v._applyGlobalTheme(t,v._globalAutoCustomColors),v._autoInstances.forEach(n=>n._applyResolvedTheme(t))},v._autoMediaQuery.addEventListener("change",v._autoMediaListener))}static _stopAutoListener(){v._autoInstances.size>0||v._globalAutoTheme||v._autoMediaQuery&&(v._autoMediaQuery.removeEventListener("change",v._autoMediaListener),v._autoMediaQuery=null,v._autoMediaListener=null)}static setCodeHighlighter(e){C.setCodeHighlighter(e),document.querySelectorAll(".overtype-wrapper").forEach(t=>{let n=t._instance;n&&n.updatePreview&&n.updatePreview()}),document.querySelectorAll("overtype-editor").forEach(t=>{if(typeof t.getEditor=="function"){let n=t.getEditor();n&&n.updatePreview&&n.updatePreview()}})}static setCustomSyntax(e){C.setCustomSyntax(e),document.querySelectorAll(".overtype-wrapper").forEach(t=>{let n=t._instance;n&&n.updatePreview&&n.updatePreview()}),document.querySelectorAll("overtype-editor").forEach(t=>{if(typeof t.getEditor=="function"){let n=t.getEditor();n&&n.updatePreview&&n.updatePreview()}})}static initGlobalListeners(){v.globalListenersInitialized||(document.addEventListener("input",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let t=e.target.closest(".overtype-wrapper"),n=t==null?void 0:t._instance;n&&n.handleInput(e)}}),document.addEventListener("keydown",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let t=e.target.closest(".overtype-wrapper"),n=t==null?void 0:t._instance;n&&n.handleKeydown(e)}}),document.addEventListener("scroll",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let t=e.target.closest(".overtype-wrapper"),n=t==null?void 0:t._instance;n&&n.handleScroll(e)}},!0),document.addEventListener("selectionchange",e=>{let t=document.activeElement;if(t&&t.classList.contains("overtype-input")){let n=t.closest(".overtype-wrapper"),o=n==null?void 0:n._instance;o&&(o.options.showStats&&o.statsBar&&o._updateStats(),clearTimeout(o._selectionTimeout),o._selectionTimeout=setTimeout(()=>{o.updatePreview()},50))}}),v.globalListenersInitialized=!0)}};T(v,"instances",new WeakMap),T(v,"stylesInjected",!1),T(v,"globalListenersInitialized",!1),T(v,"instanceCount",0),T(v,"_autoMediaQuery",null),T(v,"_autoMediaListener",null),T(v,"_autoInstances",new Set),T(v,"_globalAutoTheme",!1),T(v,"_globalAutoCustomColors",null);var q=v;q.MarkdownParser=C;q.ShortcutsManager=oe;q.themes={solar:B,cave:$("cave")};q.getTheme=$;q.currentTheme=B;var li=q;var ci="overtype-webcomponent-container",cn="Start typing...",pn=["value","theme","toolbar","height","min-height","max-height","placeholder","font-size","line-height","padding","auto-resize","autofocus","show-stats","smart-lists","readonly","spellcheck"],Oe=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._editor=null,this._initialized=!1,this._pendingOptions={},this._styleVersion=0,this._baseStyleElement=null,this._selectionChangeHandler=null,this._isConnected=!1,this._handleChange=this._handleChange.bind(this),this._handleKeydown=this._handleKeydown.bind(this)}_decodeValue(e){return typeof e!="string"?"":e.replace(/\\r/g,"\r").replace(/\\n/g,`
|
|
978
978
|
`).replace(/\\t/g," ")}static get observedAttributes(){return pn}connectedCallback(){this._isConnected=!0,this._initializeEditor()}disconnectedCallback(){this._isConnected=!1,this._cleanup()}attributeChangedCallback(e,t,n){if(t!==n&&!this._silentUpdate){if(!this._initialized){this._pendingOptions[e]=n;return}this._updateOption(e,n)}}_initializeEditor(){if(!(this._initialized||!this._isConnected))try{let e=document.createElement("div");e.className=ci;let t=this.getAttribute("height"),n=this.getAttribute("min-height"),o=this.getAttribute("max-height");t&&(e.style.height=t),n&&(e.style.minHeight=n),o&&(e.style.maxHeight=o),this._injectStyles(),this.shadowRoot.appendChild(e);let r=this._getOptionsFromAttributes(),s=new li(e,r);this._editor=s[0],this._initialized=!0,this._editor&&this._editor.textarea&&(this._editor.textarea.addEventListener("scroll",()=>{this._editor&&this._editor.preview&&this._editor.textarea&&(this._editor.preview.scrollTop=this._editor.textarea.scrollTop,this._editor.preview.scrollLeft=this._editor.textarea.scrollLeft)}),this._editor.textarea.addEventListener("input",a=>{this._editor&&this._editor.handleInput&&this._editor.handleInput(a)}),this._editor.textarea.addEventListener("keydown",a=>{this._editor&&this._editor.handleKeydown&&this._editor.handleKeydown(a)}),this._selectionChangeHandler=()=>{if(document.activeElement===this){let a=this.shadowRoot.activeElement;a&&a===this._editor.textarea&&(this._editor.options.showStats&&this._editor.statsBar&&this._editor._updateStats(),this._editor.linkTooltip&&this._editor.linkTooltip.checkCursorPosition&&this._editor.linkTooltip.checkCursorPosition())}},document.addEventListener("selectionchange",this._selectionChangeHandler)),this._applyPendingOptions(),this._dispatchEvent("ready",{editor:this._editor})}catch(e){let t=e&&e.message?e.message:String(e);console.warn("OverType Web Component initialization failed:",t),this._dispatchEvent("error",{error:{message:t}})}}_injectStyles(){let e=document.createElement("style"),t=this.getAttribute("theme")||"solar",n=$(t),o=this._getOptionsFromAttributes(),r=ye({...o,theme:n}),s=`
|
|
979
979
|
/* Web Component Host Styles */
|
|
980
980
|
:host {
|
package/dist/overtype.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OverType v2.3.
|
|
2
|
+
* OverType v2.3.2
|
|
3
3
|
* A lightweight markdown editor library with perfect WYSIWYG alignment
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @author David Miranda
|
|
@@ -5614,6 +5614,7 @@ var _OverType = class _OverType {
|
|
|
5614
5614
|
const paddingTop = parseFloat(computed.paddingTop);
|
|
5615
5615
|
const paddingBottom = parseFloat(computed.paddingBottom);
|
|
5616
5616
|
const scrollTop = textarea.scrollTop;
|
|
5617
|
+
wrapper.style.setProperty("height", "auto", "important");
|
|
5617
5618
|
textarea.style.setProperty("height", "auto", "important");
|
|
5618
5619
|
let newHeight = textarea.scrollHeight;
|
|
5619
5620
|
if (this.options.minHeight) {
|