diff --git a/dist/quikchat.cjs.js b/dist/quikchat.cjs.js
index cfc1e97..c309d1e 100644
--- a/dist/quikchat.cjs.js
+++ b/dist/quikchat.cjs.js
@@ -57,7 +57,8 @@ var quikchat = /*#__PURE__*/function () {
function quikchat(parentElement) {
var meta = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
theme: 'quikchat-theme-light',
- onSend: function onSend() {}
+ onSend: function onSend() {},
+ trackHistory: true
};
_classCallCheck(this, quikchat);
if (typeof parentElement === 'string') {
@@ -77,6 +78,7 @@ var quikchat = /*#__PURE__*/function () {
}
}
this._attachEventListeners();
+ this._history = [];
}
return _createClass(quikchat, [{
key: "_createWidget",
diff --git a/dist/quikchat.cjs.js.map b/dist/quikchat.cjs.js.map
index 7add86c..74dab11 100644
--- a/dist/quikchat.cjs.js.map
+++ b/dist/quikchat.cjs.js.map
@@ -1 +1 @@
-{"version":3,"file":"quikchat.cjs.js","sources":["../src/quikchat.js"],"sourcesContent":["\nclass quikchat {\n constructor(parentElement, meta = { theme: 'quikchat-theme-light', onSend: () => { } }) {\n if (typeof parentElement === 'string') {\n parentElement = document.querySelector(parentElement);\n }\n this._parentElement = parentElement;\n this._theme = meta.theme;\n this._onSend = meta.onSend ? meta.onSend : () => { };\n this._createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this._attachEventListeners();\n }\n\n _createWidget() {\n const widgetHTML =\n `\n
\n
\n Title Area\n
\n
\n
\n \n \n
\n
\n `;\n\n this._parentElement.innerHTML = widgetHTML;\n this._chatWidget = this._parentElement.querySelector('.quikchat-base');\n this._titleArea = this._chatWidget.querySelector('.quikchat-title-area');\n this._messagesArea = this._chatWidget.querySelector('.quikchat-messages-area');\n this._inputArea = this._chatWidget.querySelector('.quikchat-input-area');\n this._textEntry = this._inputArea.querySelector('.quikchat-input-textbox');\n this._sendButton = this._inputArea.querySelector('.quikchat-input-send-btn');\n this.msgid = 0;\n }\n $() {\n }\n _attachEventListeners() {\n this._sendButton.addEventListener('click', () => this._onSend(this, this._textEntry.value.trim()));\n window.addEventListener('resize', () => this._handleContainerResize());\n this._chatWidget.addEventListener('resize', () => this._handleContainerResize());\n this._textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this._onSend(this, this._textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this._titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this._titleArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this._titleArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaSetContents(title, align = 'center') {\n this._titleArea.innerHTML = title;\n this._titleArea.style.textAlign = align;\n }\n\n titleAreaGetContents() {\n return this._titleArea.innerHTML;\n }\n\n inputAreaToggle() {\n this._inputArea.classList.toggle('hidden');\n this._inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this._inputArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this._inputArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n _adjustMessagesAreaHeight() {\n const hiddenElements = [...this._chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this._chatWidget.offsetHeight;\n this._messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n _handleContainerResize() {\n this._adjustMessagesAreaHeight();\n this._adjustSendButtonWidth();\n //console.log('Container resized');\n }\n\n _adjustSendButtonWidth() {\n const sendButtonText = this._sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this._sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this._sendButton.style.minWidth = `${minWidth}px`;\n }\n\n messageAddNew(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n const msgid = this.msgid;\n const msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');\n messageDiv.classList.add('quikchat-message', msgidClass);\n this.msgid++;\n messageDiv.classList.add(this._messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.innerHTML = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.innerHTML = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n this._messagesArea.lastChild.scrollIntoView();\n\n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n return {msgid};\n }\n\n messageRemove(n) {\n // use css selector to remove the message\n let sucess = false;\n try {\n this._messagesArea.removeChild(this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`));\n sucess = true;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n /* returns the message html object from the DOM\n */\n messageGetDOMObject(n) {\n let msg = null;\n // now use css selector to get the message \n try {\n msg = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`);\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return msg; \n }\n /* returns the message content only\n */\n messageGetContent(n) {\n let content = \"\"\n // now use css selector to get the message \n try {\n content = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.textContent;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return content; \n }\n\n /* append message to the message content\n */\n messageAppendContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML += content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n } \n }\n /* replace message content\n */\n messageReplaceContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML = content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n\n changeTheme(newTheme) {\n this._chatWidget.classList.remove(this._theme);\n this._chatWidget.classList.add(newTheme);\n this._theme = newTheme;\n }\n\n get theme() {\n return this._theme;\n }\n\n static getVersion() {\n return {\"version\" : \"1.0.2\"}\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","_classCallCheck","document","querySelector","_parentElement","_theme","_onSend","_createWidget","titleArea","titleAreaSetContents","title","align","show","titleAreaShow","titleAreaHide","_attachEventListeners","_createClass","key","value","widgetHTML","concat","innerHTML","_chatWidget","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","$","_this","addEventListener","trim","window","_handleContainerResize","event","shiftKey","keyCode","preventDefault","titleAreaToggle","style","display","_adjustMessagesAreaHeight","textAlign","titleAreaGetContents","inputAreaToggle","classList","toggle","inputAreaShow","inputAreaHide","hiddenElements","_toConsumableArray","children","filter","child","contains","totalHiddenHeight","reduce","sum","offsetHeight","containerHeight","height","_adjustSendButtonWidth","sendButtonText","textContent","fontSize","parseFloat","getComputedStyle","minWidth","messageAddNew","message","user","messageDiv","createElement","msgidClass","String","padStart","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","messageRemove","n","sucess","removeChild","error","console","log","messageGetDOMObject","msg","messageGetContent","content","messageAppendContent","messageReplaceContent","changeTheme","newTheme","remove","get","getVersion"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACMA,QAAQ,gBAAA,YAAA;EACV,SAAAA,QAA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ACoB,QAAQ,CAAC,CAAA;MACxC,IAAI,CAAC5F,MAAM,GAAG4F,QAAQ,CAAA;AAC1B,KAAA;AAAC,GAAA,EAAA;IAAAhF,GAAA,EAAA,OAAA;IAAAkF,GAAA,EAED,SAAAA,GAAAA,GAAY;MACR,OAAO,IAAI,CAAC9F,MAAM,CAAA;AACtB,KAAA;AAAC,GAAA,CAAA,EAAA,CAAA;IAAAY,GAAA,EAAA,YAAA;IAAAC,KAAA,EAED,SAAAkF,UAAAA,GAAoB;MAChB,OAAO;AAAC,QAAA,SAAS,EAAG,OAAA;OAAQ,CAAA;AAChC,KAAA;AAAC,GAAA,CAAA,CAAA,CAAA;AAAA,CAAA;;;;"}
\ No newline at end of file
+{"version":3,"file":"quikchat.cjs.js","sources":["../src/quikchat.js"],"sourcesContent":["\nclass quikchat {\n constructor(parentElement, \n meta = { \n theme: 'quikchat-theme-light', \n onSend: () => { },\n trackHistory: true,\n }) {\n if (typeof parentElement === 'string') {\n parentElement = document.querySelector(parentElement);\n }\n this._parentElement = parentElement;\n this._theme = meta.theme;\n this._onSend = meta.onSend ? meta.onSend : () => { };\n this._createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this._attachEventListeners();\n this._history = [];\n }\n\n _createWidget() {\n const widgetHTML =\n `\n \n
\n Title Area\n
\n
\n
\n \n \n
\n
\n `;\n\n this._parentElement.innerHTML = widgetHTML;\n this._chatWidget = this._parentElement.querySelector('.quikchat-base');\n this._titleArea = this._chatWidget.querySelector('.quikchat-title-area');\n this._messagesArea = this._chatWidget.querySelector('.quikchat-messages-area');\n this._inputArea = this._chatWidget.querySelector('.quikchat-input-area');\n this._textEntry = this._inputArea.querySelector('.quikchat-input-textbox');\n this._sendButton = this._inputArea.querySelector('.quikchat-input-send-btn');\n this.msgid = 0;\n }\n $() {\n }\n _attachEventListeners() {\n this._sendButton.addEventListener('click', () => this._onSend(this, this._textEntry.value.trim()));\n window.addEventListener('resize', () => this._handleContainerResize());\n this._chatWidget.addEventListener('resize', () => this._handleContainerResize());\n this._textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this._onSend(this, this._textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this._titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this._titleArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this._titleArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaSetContents(title, align = 'center') {\n this._titleArea.innerHTML = title;\n this._titleArea.style.textAlign = align;\n }\n\n titleAreaGetContents() {\n return this._titleArea.innerHTML;\n }\n\n inputAreaToggle() {\n this._inputArea.classList.toggle('hidden');\n this._inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this._inputArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this._inputArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n _adjustMessagesAreaHeight() {\n const hiddenElements = [...this._chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this._chatWidget.offsetHeight;\n this._messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n _handleContainerResize() {\n this._adjustMessagesAreaHeight();\n this._adjustSendButtonWidth();\n //console.log('Container resized');\n }\n\n _adjustSendButtonWidth() {\n const sendButtonText = this._sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this._sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this._sendButton.style.minWidth = `${minWidth}px`;\n }\n\n messageAddNew(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n const msgid = this.msgid;\n const msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');\n messageDiv.classList.add('quikchat-message', msgidClass);\n this.msgid++;\n messageDiv.classList.add(this._messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.innerHTML = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.innerHTML = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n this._messagesArea.lastChild.scrollIntoView();\n\n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n return {msgid};\n }\n\n messageRemove(n) {\n // use css selector to remove the message\n let sucess = false;\n try {\n this._messagesArea.removeChild(this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`));\n sucess = true;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n /* returns the message html object from the DOM\n */\n messageGetDOMObject(n) {\n let msg = null;\n // now use css selector to get the message \n try {\n msg = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`);\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return msg; \n }\n /* returns the message content only\n */\n messageGetContent(n) {\n let content = \"\"\n // now use css selector to get the message \n try {\n content = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.textContent;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return content; \n }\n\n /* append message to the message content\n */\n messageAppendContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML += content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n } \n }\n /* replace message content\n */\n messageReplaceContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML = content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n\n changeTheme(newTheme) {\n this._chatWidget.classList.remove(this._theme);\n this._chatWidget.classList.add(newTheme);\n this._theme = newTheme;\n }\n\n get theme() {\n return this._theme;\n }\n\n static getVersion() {\n return {\"version\" : \"1.0.2\"}\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","trackHistory","_classCallCheck","document","querySelector","_parentElement","_theme","_onSend","_createWidget","titleArea","titleAreaSetContents","title","align","show","titleAreaShow","titleAreaHide","_attachEventListeners","_history","_createClass","key","value","widgetHTML","concat","innerHTML","_chatWidget","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","$","_this","addEventListener","trim","window","_handleContainerResize","event","shiftKey","keyCode","preventDefault","titleAreaToggle","style","display","_adjustMessagesAreaHeight","textAlign","titleAreaGetContents","inputAreaToggle","classList","toggle","inputAreaShow","inputAreaHide","hiddenElements","_toConsumableArray","children","filter","child","contains","totalHiddenHeight","reduce","sum","offsetHeight","containerHeight","height","_adjustSendButtonWidth","sendButtonText","textContent","fontSize","parseFloat","getComputedStyle","minWidth","messageAddNew","message","user","messageDiv","createElement","msgidClass","String","padStart","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","messageRemove","n","sucess","removeChild","error","console","log","messageGetDOMObject","msg","messageGetContent","content","messageAppendContent","messageReplaceContent","changeTheme","newTheme","remove","get","getVersion"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACMA,QAAQ,gBAAA,YAAA;EACV,SAAAA,QAAAA,CAAYC,aAAa,EAKlB;IAAA,IAJHC,IAAI,GAAAC,SAAA,CAAA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SAAS,CAAC+B,GAAG,CAACoB,QAAQ,CAAC,CAAA;MACxC,IAAI,CAAC7F,MAAM,GAAG6F,QAAQ,CAAA;AAC1B,KAAA;AAAC,GAAA,EAAA;IAAAhF,GAAA,EAAA,OAAA;IAAAkF,GAAA,EAED,SAAAA,GAAAA,GAAY;MACR,OAAO,IAAI,CAAC/F,MAAM,CAAA;AACtB,KAAA;AAAC,GAAA,CAAA,EAAA,CAAA;IAAAa,GAAA,EAAA,YAAA;IAAAC,KAAA,EAED,SAAAkF,UAAAA,GAAoB;MAChB,OAAO;AAAC,QAAA,SAAS,EAAG,OAAA;OAAQ,CAAA;AAChC,KAAA;AAAC,GAAA,CAAA,CAAA,CAAA;AAAA,CAAA;;;;"}
\ No newline at end of file
diff --git a/dist/quikchat.cjs.min.js b/dist/quikchat.cjs.min.js
index 6f892da..d5dccd9 100644
--- a/dist/quikchat.cjs.min.js
+++ b/dist/quikchat.cjs.min.js
@@ -1,2 +1,2 @@
-"use strict";function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n1&&void 0!==arguments[1]?arguments[1]:{theme:"quikchat-theme-light",onSend:function(){}};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),"string"==typeof e&&(e=document.querySelector(e)),this._parentElement=e,this._theme=n.theme,this._onSend=n.onSend?n.onSend:function(){},this._createWidget(),n.titleArea&&(this.titleAreaSetContents(n.titleArea.title,n.titleArea.align),n.titleArea.show?this.titleAreaShow():this.titleAreaHide()),this._attachEventListeners()},i=[{key:"_createWidget",value:function(){var t='\n \n
\n Title Area\n
\n
\n
\n \n \n
\n
\n ');this._parentElement.innerHTML=t,this._chatWidget=this._parentElement.querySelector(".quikchat-base"),this._titleArea=this._chatWidget.querySelector(".quikchat-title-area"),this._messagesArea=this._chatWidget.querySelector(".quikchat-messages-area"),this._inputArea=this._chatWidget.querySelector(".quikchat-input-area"),this._textEntry=this._inputArea.querySelector(".quikchat-input-textbox"),this._sendButton=this._inputArea.querySelector(".quikchat-input-send-btn"),this.msgid=0}},{key:"$",value:function(){}},{key:"_attachEventListeners",value:function(){var t=this;this._sendButton.addEventListener("click",(function(){return t._onSend(t,t._textEntry.value.trim())})),window.addEventListener("resize",(function(){return t._handleContainerResize()})),this._chatWidget.addEventListener("resize",(function(){return t._handleContainerResize()})),this._textEntry.addEventListener("keydown",(function(e){e.shiftKey&&13===e.keyCode&&(e.preventDefault(),t._onSend(t,t._textEntry.value.trim()))}))}},{key:"titleAreaToggle",value:function(){"none"===this._titleArea.style.display?this.titleAreaShow():this.titleAreaHide()}},{key:"titleAreaShow",value:function(){this._titleArea.style.display="",this._adjustMessagesAreaHeight()}},{key:"titleAreaHide",value:function(){this._titleArea.style.display="none",this._adjustMessagesAreaHeight()}},{key:"titleAreaSetContents",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"center";this._titleArea.innerHTML=t,this._titleArea.style.textAlign=e}},{key:"titleAreaGetContents",value:function(){return this._titleArea.innerHTML}},{key:"inputAreaToggle",value:function(){this._inputArea.classList.toggle("hidden"),"none"===this._inputArea.style.display?this.inputAreaShow():this.inputAreaHide()}},{key:"inputAreaShow",value:function(){this._inputArea.style.display="",this._adjustMessagesAreaHeight()}},{key:"inputAreaHide",value:function(){this._inputArea.style.display="none",this._adjustMessagesAreaHeight()}},{key:"_adjustMessagesAreaHeight",value:function(){var t=n(this._chatWidget.children).filter((function(t){return t.classList.contains("hidden")})).reduce((function(t,e){return t+e.offsetHeight}),0),e=this._chatWidget.offsetHeight;this._messagesArea.style.height="calc(100% - ".concat(e-t,"px)")}},{key:"_handleContainerResize",value:function(){this._adjustMessagesAreaHeight(),this._adjustSendButtonWidth()}},{key:"_adjustSendButtonWidth",value:function(){var t=this._sendButton.textContent.trim(),e=parseFloat(getComputedStyle(this._sendButton).fontSize)*t.length+16;this._sendButton.style.minWidth="".concat(e,"px")}},{key:"messageAddNew",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"foo",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"left",i=document.createElement("div"),a=this.msgid,s="quikchat-msgid-"+String(a).padStart(10,"0");i.classList.add("quikchat-message",s),this.msgid++,i.classList.add(this._messagesArea.children.length%2==1?"quikchat-message-1":"quikchat-message-2");var r=document.createElement("div");r.innerHTML=e,r.style="width: 100%; text-align: ".concat(n,"; font-size: 1em; font-weight:700; color: #444;");var o=document.createElement("div");return o.style="width: 100%; text-align: ".concat(n,";"),o.innerHTML=t,i.appendChild(r),i.appendChild(o),this._messagesArea.appendChild(i),this._messagesArea.lastChild.scrollIntoView(),this._textEntry.value="",this._adjustMessagesAreaHeight(),{msgid:a}}},{key:"messageRemove",value:function(t){var e=!1;try{this._messagesArea.removeChild(this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0")))),e=!0}catch(t){console.log("{String(n)} : Message ID not found")}return e}},{key:"messageGetDOMObject",value:function(t){var e=null;try{e=this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0")))}catch(t){console.log("{String(n)} : Message ID not found")}return e}},{key:"messageGetContent",value:function(t){var e="";try{e=this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0"))).lastChild.textContent}catch(t){console.log("{String(n)} : Message ID not found")}return e}},{key:"messageAppendContent",value:function(t,e){try{this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0"))).lastChild.innerHTML+=e}catch(t){console.log("{String(n)} : Message ID not found")}}},{key:"messageReplaceContent",value:function(t,e){var n=!1;try{this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0"))).lastChild.innerHTML=e,n=!0}catch(t){console.log("{String(n)} : Message ID not found")}return n}},{key:"changeTheme",value:function(t){this._chatWidget.classList.remove(this._theme),this._chatWidget.classList.add(t),this._theme=t}},{key:"theme",get:function(){return this._theme}}],a=[{key:"getVersion",value:function(){return{version:"1.0.2"}}}],i&&e(t.prototype,i),a&&e(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,i,a}();module.exports=a;
+"use strict";function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n1&&void 0!==arguments[1]?arguments[1]:{theme:"quikchat-theme-light",onSend:function(){},trackHistory:!0};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),"string"==typeof e&&(e=document.querySelector(e)),this._parentElement=e,this._theme=n.theme,this._onSend=n.onSend?n.onSend:function(){},this._createWidget(),n.titleArea&&(this.titleAreaSetContents(n.titleArea.title,n.titleArea.align),n.titleArea.show?this.titleAreaShow():this.titleAreaHide()),this._attachEventListeners(),this._history=[]},i=[{key:"_createWidget",value:function(){var t='\n \n
\n Title Area\n
\n
\n
\n \n \n
\n
\n ');this._parentElement.innerHTML=t,this._chatWidget=this._parentElement.querySelector(".quikchat-base"),this._titleArea=this._chatWidget.querySelector(".quikchat-title-area"),this._messagesArea=this._chatWidget.querySelector(".quikchat-messages-area"),this._inputArea=this._chatWidget.querySelector(".quikchat-input-area"),this._textEntry=this._inputArea.querySelector(".quikchat-input-textbox"),this._sendButton=this._inputArea.querySelector(".quikchat-input-send-btn"),this.msgid=0}},{key:"$",value:function(){}},{key:"_attachEventListeners",value:function(){var t=this;this._sendButton.addEventListener("click",(function(){return t._onSend(t,t._textEntry.value.trim())})),window.addEventListener("resize",(function(){return t._handleContainerResize()})),this._chatWidget.addEventListener("resize",(function(){return t._handleContainerResize()})),this._textEntry.addEventListener("keydown",(function(e){e.shiftKey&&13===e.keyCode&&(e.preventDefault(),t._onSend(t,t._textEntry.value.trim()))}))}},{key:"titleAreaToggle",value:function(){"none"===this._titleArea.style.display?this.titleAreaShow():this.titleAreaHide()}},{key:"titleAreaShow",value:function(){this._titleArea.style.display="",this._adjustMessagesAreaHeight()}},{key:"titleAreaHide",value:function(){this._titleArea.style.display="none",this._adjustMessagesAreaHeight()}},{key:"titleAreaSetContents",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"center";this._titleArea.innerHTML=t,this._titleArea.style.textAlign=e}},{key:"titleAreaGetContents",value:function(){return this._titleArea.innerHTML}},{key:"inputAreaToggle",value:function(){this._inputArea.classList.toggle("hidden"),"none"===this._inputArea.style.display?this.inputAreaShow():this.inputAreaHide()}},{key:"inputAreaShow",value:function(){this._inputArea.style.display="",this._adjustMessagesAreaHeight()}},{key:"inputAreaHide",value:function(){this._inputArea.style.display="none",this._adjustMessagesAreaHeight()}},{key:"_adjustMessagesAreaHeight",value:function(){var t=n(this._chatWidget.children).filter((function(t){return t.classList.contains("hidden")})).reduce((function(t,e){return t+e.offsetHeight}),0),e=this._chatWidget.offsetHeight;this._messagesArea.style.height="calc(100% - ".concat(e-t,"px)")}},{key:"_handleContainerResize",value:function(){this._adjustMessagesAreaHeight(),this._adjustSendButtonWidth()}},{key:"_adjustSendButtonWidth",value:function(){var t=this._sendButton.textContent.trim(),e=parseFloat(getComputedStyle(this._sendButton).fontSize)*t.length+16;this._sendButton.style.minWidth="".concat(e,"px")}},{key:"messageAddNew",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"foo",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"left",i=document.createElement("div"),a=this.msgid,s="quikchat-msgid-"+String(a).padStart(10,"0");i.classList.add("quikchat-message",s),this.msgid++,i.classList.add(this._messagesArea.children.length%2==1?"quikchat-message-1":"quikchat-message-2");var r=document.createElement("div");r.innerHTML=e,r.style="width: 100%; text-align: ".concat(n,"; font-size: 1em; font-weight:700; color: #444;");var o=document.createElement("div");return o.style="width: 100%; text-align: ".concat(n,";"),o.innerHTML=t,i.appendChild(r),i.appendChild(o),this._messagesArea.appendChild(i),this._messagesArea.lastChild.scrollIntoView(),this._textEntry.value="",this._adjustMessagesAreaHeight(),{msgid:a}}},{key:"messageRemove",value:function(t){var e=!1;try{this._messagesArea.removeChild(this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0")))),e=!0}catch(t){console.log("{String(n)} : Message ID not found")}return e}},{key:"messageGetDOMObject",value:function(t){var e=null;try{e=this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0")))}catch(t){console.log("{String(n)} : Message ID not found")}return e}},{key:"messageGetContent",value:function(t){var e="";try{e=this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0"))).lastChild.textContent}catch(t){console.log("{String(n)} : Message ID not found")}return e}},{key:"messageAppendContent",value:function(t,e){try{this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0"))).lastChild.innerHTML+=e}catch(t){console.log("{String(n)} : Message ID not found")}}},{key:"messageReplaceContent",value:function(t,e){var n=!1;try{this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0"))).lastChild.innerHTML=e,n=!0}catch(t){console.log("{String(n)} : Message ID not found")}return n}},{key:"changeTheme",value:function(t){this._chatWidget.classList.remove(this._theme),this._chatWidget.classList.add(t),this._theme=t}},{key:"theme",get:function(){return this._theme}}],a=[{key:"getVersion",value:function(){return{version:"1.0.2"}}}],i&&e(t.prototype,i),a&&e(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,i,a}();module.exports=a;
//# sourceMappingURL=quikchat.cjs.min.js.map
diff --git a/dist/quikchat.cjs.min.js.map b/dist/quikchat.cjs.min.js.map
index 111b69e..dbc9349 100644
--- a/dist/quikchat.cjs.min.js.map
+++ b/dist/quikchat.cjs.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"quikchat.cjs.min.js","sources":["../src/quikchat.js"],"sourcesContent":["\nclass quikchat {\n constructor(parentElement, meta = { theme: 'quikchat-theme-light', onSend: () => { } }) {\n if (typeof parentElement === 'string') {\n parentElement = document.querySelector(parentElement);\n }\n this._parentElement = parentElement;\n this._theme = meta.theme;\n this._onSend = meta.onSend ? meta.onSend : () => { };\n this._createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this._attachEventListeners();\n }\n\n _createWidget() {\n const widgetHTML =\n `\n \n
\n Title Area\n
\n
\n
\n \n \n
\n
\n `;\n\n this._parentElement.innerHTML = widgetHTML;\n this._chatWidget = this._parentElement.querySelector('.quikchat-base');\n this._titleArea = this._chatWidget.querySelector('.quikchat-title-area');\n this._messagesArea = this._chatWidget.querySelector('.quikchat-messages-area');\n this._inputArea = this._chatWidget.querySelector('.quikchat-input-area');\n this._textEntry = this._inputArea.querySelector('.quikchat-input-textbox');\n this._sendButton = this._inputArea.querySelector('.quikchat-input-send-btn');\n this.msgid = 0;\n }\n $() {\n }\n _attachEventListeners() {\n this._sendButton.addEventListener('click', () => this._onSend(this, this._textEntry.value.trim()));\n window.addEventListener('resize', () => this._handleContainerResize());\n this._chatWidget.addEventListener('resize', () => this._handleContainerResize());\n this._textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this._onSend(this, this._textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this._titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this._titleArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this._titleArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaSetContents(title, align = 'center') {\n this._titleArea.innerHTML = title;\n this._titleArea.style.textAlign = align;\n }\n\n titleAreaGetContents() {\n return this._titleArea.innerHTML;\n }\n\n inputAreaToggle() {\n this._inputArea.classList.toggle('hidden');\n this._inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this._inputArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this._inputArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n _adjustMessagesAreaHeight() {\n const hiddenElements = [...this._chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this._chatWidget.offsetHeight;\n this._messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n _handleContainerResize() {\n this._adjustMessagesAreaHeight();\n this._adjustSendButtonWidth();\n //console.log('Container resized');\n }\n\n _adjustSendButtonWidth() {\n const sendButtonText = this._sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this._sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this._sendButton.style.minWidth = `${minWidth}px`;\n }\n\n messageAddNew(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n const msgid = this.msgid;\n const msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');\n messageDiv.classList.add('quikchat-message', msgidClass);\n this.msgid++;\n messageDiv.classList.add(this._messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.innerHTML = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.innerHTML = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n this._messagesArea.lastChild.scrollIntoView();\n\n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n return {msgid};\n }\n\n messageRemove(n) {\n // use css selector to remove the message\n let sucess = false;\n try {\n this._messagesArea.removeChild(this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`));\n sucess = true;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n /* returns the message html object from the DOM\n */\n messageGetDOMObject(n) {\n let msg = null;\n // now use css selector to get the message \n try {\n msg = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`);\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return msg; \n }\n /* returns the message content only\n */\n messageGetContent(n) {\n let content = \"\"\n // now use css selector to get the message \n try {\n content = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.textContent;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return content; \n }\n\n /* append message to the message content\n */\n messageAppendContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML += content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n } \n }\n /* replace message content\n */\n messageReplaceContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML = content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n\n changeTheme(newTheme) {\n this._chatWidget.classList.remove(this._theme);\n this._chatWidget.classList.add(newTheme);\n this._theme = newTheme;\n }\n\n get theme() {\n return this._theme;\n }\n\n static getVersion() {\n return {\"version\" : \"1.0.2\"}\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","_classCallCheck","document","querySelector","this","_parentElement","_theme","_onSend","_createWidget","titleArea","titleAreaSetContents","title","align","show","titleAreaShow","titleAreaHide","_attachEventListeners","key","value","widgetHTML","concat","innerHTML","_chatWidget","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","_this","addEventListener","trim","window","_handleContainerResize","event","shiftKey","keyCode","preventDefault","style","display","_adjustMessagesAreaHeight","textAlign","classList","toggle","inputAreaShow","inputAreaHide","totalHiddenHeight","_toConsumableArray","children","filter","child","contains","reduce","sum","offsetHeight","containerHeight","height","_adjustSendButtonWidth","sendButtonText","textContent","minWidth","parseFloat","getComputedStyle","fontSize","message","user","messageDiv","createElement","msgidClass","String","padStart","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","n","sucess","removeChild","error","console","log","msg","content","newTheme","remove","get","version"],"mappings":"2rCACMA,EAAQ,WAmBT,SAlBD,SAAAA,EAAYC,GAA4E,IAA7DC,EAAIC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAG,GAAA,CAAEG,MAAO,uBAAwBC,OAAQ,WAAQ,gGAAGC,MAAAR,GACrD,iBAAlBC,IACPA,EAAgBQ,SAASC,cAAcT,IAE3CU,KAAKC,eAAiBX,EACtBU,KAAKE,OAASX,EAAKI,MACnBK,KAAKG,QAAUZ,EAAKK,OAASL,EAAKK,OAAS,aAC3CI,KAAKI,gBAEDb,EAAKc,YACLL,KAAKM,qBAAqBf,EAAKc,UAAUE,MAAOhB,EAAKc,UAAUG,OAC3DjB,EAAKc,UAAUI,KACfT,KAAKU,gBAELV,KAAKW,iBAGbX,KAAKY,uBACT,IAAC,CAAA,CAAAC,IAAA,gBAAAC,MAED,WACI,IAAMC,EAAUC,2CAAAA,OAEgBhB,KAAKL,MAUhC,weAELK,KAAKC,eAAegB,UAAYF,EAChCf,KAAKkB,YAAclB,KAAKC,eAAeF,cAAc,kBACrDC,KAAKmB,WAAanB,KAAKkB,YAAYnB,cAAc,wBACjDC,KAAKoB,cAAgBpB,KAAKkB,YAAYnB,cAAc,2BACpDC,KAAKqB,WAAarB,KAAKkB,YAAYnB,cAAc,wBACjDC,KAAKsB,WAAatB,KAAKqB,WAAWtB,cAAc,2BAChDC,KAAKuB,YAAcvB,KAAKqB,WAAWtB,cAAc,4BACjDC,KAAKwB,MAAQ,CACjB,GAAC,CAAAX,IAAA,IAAAC,MACD,WACA,GAAC,CAAAD,IAAA,wBAAAC,MACD,WAAwB,IAAAW,EAAAzB,KACpBA,KAAKuB,YAAYG,iBAAiB,SAAS,WAAA,OAAMD,EAAKtB,QAAQsB,EAAMA,EAAKH,WAAWR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D,EACzGN,GAAS,CACZ,CACD,MAAOE,GAEHC,QAAQC,IAAG,qCACf,CACA,OAAOJ,CACX,GAAC,CAAA7D,IAAA,cAAAC,MAED,SAAYmE,GACRjF,KAAKkB,YAAYoB,UAAU4C,OAAOlF,KAAKE,QACvCF,KAAKkB,YAAYoB,UAAU6B,IAAIc,GAC/BjF,KAAKE,OAAS+E,CAClB,GAAC,CAAApE,IAAA,QAAAsE,IAED,WACI,OAAOnF,KAAKE,MAChB,MAAC,CAAA,CAAAW,IAAA,aAAAC,MAED,WACI,MAAO,CAACsE,QAAY,QACxB,gGAAC,CAlOS"}
\ No newline at end of file
+{"version":3,"file":"quikchat.cjs.min.js","sources":["../src/quikchat.js"],"sourcesContent":["\nclass quikchat {\n constructor(parentElement, \n meta = { \n theme: 'quikchat-theme-light', \n onSend: () => { },\n trackHistory: true,\n }) {\n if (typeof parentElement === 'string') {\n parentElement = document.querySelector(parentElement);\n }\n this._parentElement = parentElement;\n this._theme = meta.theme;\n this._onSend = meta.onSend ? meta.onSend : () => { };\n this._createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this._attachEventListeners();\n this._history = [];\n }\n\n _createWidget() {\n const widgetHTML =\n `\n \n
\n Title Area\n
\n
\n
\n \n \n
\n
\n `;\n\n this._parentElement.innerHTML = widgetHTML;\n this._chatWidget = this._parentElement.querySelector('.quikchat-base');\n this._titleArea = this._chatWidget.querySelector('.quikchat-title-area');\n this._messagesArea = this._chatWidget.querySelector('.quikchat-messages-area');\n this._inputArea = this._chatWidget.querySelector('.quikchat-input-area');\n this._textEntry = this._inputArea.querySelector('.quikchat-input-textbox');\n this._sendButton = this._inputArea.querySelector('.quikchat-input-send-btn');\n this.msgid = 0;\n }\n $() {\n }\n _attachEventListeners() {\n this._sendButton.addEventListener('click', () => this._onSend(this, this._textEntry.value.trim()));\n window.addEventListener('resize', () => this._handleContainerResize());\n this._chatWidget.addEventListener('resize', () => this._handleContainerResize());\n this._textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this._onSend(this, this._textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this._titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this._titleArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this._titleArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaSetContents(title, align = 'center') {\n this._titleArea.innerHTML = title;\n this._titleArea.style.textAlign = align;\n }\n\n titleAreaGetContents() {\n return this._titleArea.innerHTML;\n }\n\n inputAreaToggle() {\n this._inputArea.classList.toggle('hidden');\n this._inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this._inputArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this._inputArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n _adjustMessagesAreaHeight() {\n const hiddenElements = [...this._chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this._chatWidget.offsetHeight;\n this._messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n _handleContainerResize() {\n this._adjustMessagesAreaHeight();\n this._adjustSendButtonWidth();\n //console.log('Container resized');\n }\n\n _adjustSendButtonWidth() {\n const sendButtonText = this._sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this._sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this._sendButton.style.minWidth = `${minWidth}px`;\n }\n\n messageAddNew(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n const msgid = this.msgid;\n const msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');\n messageDiv.classList.add('quikchat-message', msgidClass);\n this.msgid++;\n messageDiv.classList.add(this._messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.innerHTML = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.innerHTML = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n this._messagesArea.lastChild.scrollIntoView();\n\n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n return {msgid};\n }\n\n messageRemove(n) {\n // use css selector to remove the message\n let sucess = false;\n try {\n this._messagesArea.removeChild(this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`));\n sucess = true;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n /* returns the message html object from the DOM\n */\n messageGetDOMObject(n) {\n let msg = null;\n // now use css selector to get the message \n try {\n msg = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`);\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return msg; \n }\n /* returns the message content only\n */\n messageGetContent(n) {\n let content = \"\"\n // now use css selector to get the message \n try {\n content = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.textContent;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return content; \n }\n\n /* append message to the message content\n */\n messageAppendContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML += content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n } \n }\n /* replace message content\n */\n messageReplaceContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML = content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n\n changeTheme(newTheme) {\n this._chatWidget.classList.remove(this._theme);\n this._chatWidget.classList.add(newTheme);\n this._theme = newTheme;\n }\n\n get theme() {\n return this._theme;\n }\n\n static getVersion() {\n return {\"version\" : \"1.0.2\"}\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","trackHistory","_classCallCheck","document","querySelector","this","_parentElement","_theme","_onSend","_createWidget","titleArea","titleAreaSetContents","title","align","show","titleAreaShow","titleAreaHide","_attachEventListeners","_history","key","value","widgetHTML","concat","innerHTML","_chatWidget","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","_this","addEventListener","trim","window","_handleContainerResize","event","shiftKey","keyCode","preventDefault","style","display","_adjustMessagesAreaHeight","textAlign","classList","toggle","inputAreaShow","inputAreaHide","totalHiddenHeight","_toConsumableArray","children","filter","child","contains","reduce","sum","offsetHeight","containerHeight","height","_adjustSendButtonWidth","sendButtonText","textContent","minWidth","parseFloat","getComputedStyle","fontSize","message","user","messageDiv","createElement","msgidClass","String","padStart","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","n","sucess","removeChild","error","console","log","msg","content","newTheme","remove","get","version"],"mappings":"2rCACMA,EAAQ,WAyBT,SAxBD,SAAAA,EAAYC,GAKL,IAJHC,EAAIC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAG,GAAA,CACHG,MAAO,uBACPC,OAAQ,WAAS,EACjBC,cAAc,gGACjBC,MAAAT,GAC4B,iBAAlBC,IACPA,EAAgBS,SAASC,cAAcV,IAE3CW,KAAKC,eAAiBZ,EACtBW,KAAKE,OAASZ,EAAKI,MACnBM,KAAKG,QAAUb,EAAKK,OAASL,EAAKK,OAAS,aAC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a 100644
--- a/dist/quikchat.css
+++ b/dist/quikchat.css
@@ -13,6 +13,7 @@
margin-right: 8px;
padding-left : 2px;
padding-right : 2px;
+ padding: 8px;
font-weight: 600;
font-size: 1.3em;
}
@@ -61,7 +62,6 @@
.quikchat-theme-debug {
border: 1px solid black;
border-radius: 10px;
- padding: 5px;
background-color: mediumorchid;
}
@@ -90,6 +90,8 @@
.quikchat-theme-debug .quikchat-input-area {
background-color: lightgreen;
+ border-bottom-left-radius : 10px;
+ border-bottom-right-radius : 10px;
}
.quikchat-theme-debug .quikchat-input-textbox {
@@ -111,7 +113,6 @@
.quikchat-theme-dark {
border: 1px solid #555555;
border-radius: 8px;
- padding: 5px;
background-color: #212121;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}
@@ -147,6 +148,9 @@
.quikchat-theme-dark .quikchat-input-area {
padding: 8px;
background-color: #263238;
+
+ border-bottom-left-radius : 10px;
+ border-bottom-right-radius : 10px;
}
.quikchat-theme-dark .quikchat-input-textbox {
@@ -175,11 +179,11 @@
.quikchat-theme-light {
border: 1px solid #cccccc;
border-radius: 10px;
- padding: 5px;
background-color: #f9f9f9;
}
.quikchat-theme-light .quikchat-title-area {
+ padding: 8px;
color: #333;
}
@@ -200,7 +204,9 @@
.quikchat-theme-light .quikchat-input-area {
background-color: #f9f9f9;
- }
+ border-bottom-left-radius : 10px;
+ border-bottom-right-radius : 10px;
+}
.quikchat-theme-light .quikchat-input-textbox {
background-color: #ffffff;
diff --git a/dist/quikchat.esm.js b/dist/quikchat.esm.js
index d0d4585..67ebabb 100644
--- a/dist/quikchat.esm.js
+++ b/dist/quikchat.esm.js
@@ -55,7 +55,8 @@ var quikchat = /*#__PURE__*/function () {
function quikchat(parentElement) {
var meta = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
theme: 'quikchat-theme-light',
- onSend: function onSend() {}
+ onSend: function onSend() {},
+ trackHistory: true
};
_classCallCheck(this, quikchat);
if (typeof parentElement === 'string') {
@@ -75,6 +76,7 @@ var quikchat = /*#__PURE__*/function () {
}
}
this._attachEventListeners();
+ this._history = [];
}
return _createClass(quikchat, [{
key: "_createWidget",
diff --git a/dist/quikchat.esm.js.map b/dist/quikchat.esm.js.map
index 96cf002..46d2ce3 100644
--- a/dist/quikchat.esm.js.map
+++ b/dist/quikchat.esm.js.map
@@ -1 +1 @@
-{"version":3,"file":"quikchat.esm.js","sources":["../src/quikchat.js"],"sourcesContent":["\nclass quikchat {\n constructor(parentElement, meta = { theme: 'quikchat-theme-light', onSend: () => { } }) {\n if (typeof parentElement === 'string') {\n parentElement = document.querySelector(parentElement);\n }\n this._parentElement = parentElement;\n this._theme = meta.theme;\n this._onSend = meta.onSend ? meta.onSend : () => { };\n this._createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this._attachEventListeners();\n }\n\n _createWidget() {\n const widgetHTML =\n `\n \n
\n Title Area\n
\n
\n
\n \n \n
\n
\n `;\n\n this._parentElement.innerHTML = widgetHTML;\n this._chatWidget = this._parentElement.querySelector('.quikchat-base');\n this._titleArea = this._chatWidget.querySelector('.quikchat-title-area');\n this._messagesArea = this._chatWidget.querySelector('.quikchat-messages-area');\n this._inputArea = this._chatWidget.querySelector('.quikchat-input-area');\n this._textEntry = this._inputArea.querySelector('.quikchat-input-textbox');\n this._sendButton = this._inputArea.querySelector('.quikchat-input-send-btn');\n this.msgid = 0;\n }\n $() {\n }\n _attachEventListeners() {\n this._sendButton.addEventListener('click', () => this._onSend(this, this._textEntry.value.trim()));\n window.addEventListener('resize', () => this._handleContainerResize());\n this._chatWidget.addEventListener('resize', () => this._handleContainerResize());\n this._textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this._onSend(this, this._textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this._titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this._titleArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this._titleArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaSetContents(title, align = 'center') {\n this._titleArea.innerHTML = title;\n this._titleArea.style.textAlign = align;\n }\n\n titleAreaGetContents() {\n return this._titleArea.innerHTML;\n }\n\n inputAreaToggle() {\n this._inputArea.classList.toggle('hidden');\n this._inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this._inputArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this._inputArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n _adjustMessagesAreaHeight() {\n const hiddenElements = [...this._chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this._chatWidget.offsetHeight;\n this._messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n _handleContainerResize() {\n this._adjustMessagesAreaHeight();\n this._adjustSendButtonWidth();\n //console.log('Container resized');\n }\n\n _adjustSendButtonWidth() {\n const sendButtonText = this._sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this._sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this._sendButton.style.minWidth = `${minWidth}px`;\n }\n\n messageAddNew(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n const msgid = this.msgid;\n const msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');\n messageDiv.classList.add('quikchat-message', msgidClass);\n this.msgid++;\n messageDiv.classList.add(this._messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.innerHTML = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.innerHTML = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n this._messagesArea.lastChild.scrollIntoView();\n\n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n return {msgid};\n }\n\n messageRemove(n) {\n // use css selector to remove the message\n let sucess = false;\n try {\n this._messagesArea.removeChild(this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`));\n sucess = true;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n /* returns the message html object from the DOM\n */\n messageGetDOMObject(n) {\n let msg = null;\n // now use css selector to get the message \n try {\n msg = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`);\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return msg; \n }\n /* returns the message content only\n */\n messageGetContent(n) {\n let content = \"\"\n // now use css selector to get the message \n try {\n content = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.textContent;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return content; \n }\n\n /* append message to the message content\n */\n messageAppendContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML += content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n } \n }\n /* replace message content\n */\n messageReplaceContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML = content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n\n changeTheme(newTheme) {\n this._chatWidget.classList.remove(this._theme);\n this._chatWidget.classList.add(newTheme);\n this._theme = newTheme;\n }\n\n get theme() {\n return this._theme;\n }\n\n static getVersion() {\n return {\"version\" : \"1.0.2\"}\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","_classCallCheck","document","querySelector","_parentElement","_theme","_onSend","_createWidget","titleArea","titleAreaSetContents","title","align","show","titleAreaShow","titleAreaHide","_attachEventListeners","_createClass","key","value","widgetHTML","concat","innerHTML","_chatWidget","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","$","_this","addEventListener","trim","window","_handleContainerResize","event","shiftKey","keyCode","preventDefault","titleAreaToggle","style","display","_adjustMessagesAreaHeight","textAlign","titleAreaGetContents","inputAreaToggle","classList","toggle","inputAreaShow","inputAreaHide","hiddenElements","_toConsumableArray","children","filter","child","contains","totalHiddenHeight","reduce","sum","offsetHeight","containerHeight","height","_adjustSendButtonWidth","sendButtonText","textContent","fontSize","parseFloat","getComputedStyle","minWidth","messageAddNew","message","user","messageDiv","createElement","msgidClass","String","padStart","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","messageRemove","n","sucess","removeChild","error","console","log","messageGetDOMObject","msg","messageGetContent","content","messageAppendContent","messageReplaceContent","changeTheme","newTheme","remove","get","getVersion"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACMA,QAAQ,gBAAA,YAAA;EACV,SAAAA,QAAAA,CAAYC,aAAa,EAA+D;IAAA,IAA7DC,IAAI,GAAAC,SAAA,CAAAC,MAAA,GAAAD,CAAAA,IAAAA,SAAA,CAAAE,CAAAA,CAAAA,KAAAA,SAAA,GAAAF,SAAA,CAAG,CAAA,CAAA,GAAA;AAAEG,MAAAA,KAAK,EAAE,sBAAsB;AAAEC,MAAAA,MAAM,EAAE,SAAAA,MAAA,GAAM,EAAE;KAAG,CAAA;AAAAC,IAAAA,eAAA,OAAAR,QAAA,CAAA,CAAA;AAClF,IAAA,IAAI,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QAAA,SAAS,EAAG,OAAA;OAAQ,CAAA;AAChC,KAAA;AAAC,GAAA,CAAA,CAAA,CAAA;AAAA,CAAA;;;;"}
\ No newline at end of file
+{"version":3,"file":"quikchat.esm.js","sources":["../src/quikchat.js"],"sourcesContent":["\nclass quikchat {\n constructor(parentElement, \n meta = { \n theme: 'quikchat-theme-light', \n onSend: () => { },\n trackHistory: true,\n }) {\n if (typeof parentElement === 'string') {\n parentElement = document.querySelector(parentElement);\n }\n this._parentElement = parentElement;\n this._theme = meta.theme;\n this._onSend = meta.onSend ? meta.onSend : () => { };\n this._createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this._attachEventListeners();\n this._history = [];\n }\n\n _createWidget() {\n const widgetHTML =\n `\n \n
\n Title Area\n
\n
\n
\n \n \n
\n
\n `;\n\n this._parentElement.innerHTML = widgetHTML;\n this._chatWidget = this._parentElement.querySelector('.quikchat-base');\n this._titleArea = this._chatWidget.querySelector('.quikchat-title-area');\n this._messagesArea = this._chatWidget.querySelector('.quikchat-messages-area');\n this._inputArea = this._chatWidget.querySelector('.quikchat-input-area');\n this._textEntry = this._inputArea.querySelector('.quikchat-input-textbox');\n this._sendButton = this._inputArea.querySelector('.quikchat-input-send-btn');\n this.msgid = 0;\n }\n $() {\n }\n _attachEventListeners() {\n this._sendButton.addEventListener('click', () => this._onSend(this, this._textEntry.value.trim()));\n window.addEventListener('resize', () => this._handleContainerResize());\n this._chatWidget.addEventListener('resize', () => this._handleContainerResize());\n this._textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this._onSend(this, this._textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this._titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this._titleArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this._titleArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaSetContents(title, align = 'center') {\n this._titleArea.innerHTML = title;\n this._titleArea.style.textAlign = align;\n }\n\n titleAreaGetContents() {\n return this._titleArea.innerHTML;\n }\n\n inputAreaToggle() {\n this._inputArea.classList.toggle('hidden');\n this._inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this._inputArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this._inputArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n _adjustMessagesAreaHeight() {\n const hiddenElements = [...this._chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this._chatWidget.offsetHeight;\n this._messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n _handleContainerResize() {\n this._adjustMessagesAreaHeight();\n this._adjustSendButtonWidth();\n //console.log('Container resized');\n }\n\n _adjustSendButtonWidth() {\n const sendButtonText = this._sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this._sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this._sendButton.style.minWidth = `${minWidth}px`;\n }\n\n messageAddNew(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n const msgid = this.msgid;\n const msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');\n messageDiv.classList.add('quikchat-message', msgidClass);\n this.msgid++;\n messageDiv.classList.add(this._messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.innerHTML = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.innerHTML = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n this._messagesArea.lastChild.scrollIntoView();\n\n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n return {msgid};\n }\n\n messageRemove(n) {\n // use css selector to remove the message\n let sucess = false;\n try {\n this._messagesArea.removeChild(this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`));\n sucess = true;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n /* returns the message html object from the DOM\n */\n messageGetDOMObject(n) {\n let msg = null;\n // now use css selector to get the message \n try {\n msg = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`);\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return msg; \n }\n /* returns the message content only\n */\n messageGetContent(n) {\n let content = \"\"\n // now use css selector to get the message \n try {\n content = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.textContent;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return content; \n }\n\n /* append message to the message content\n */\n messageAppendContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML += content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n } \n }\n /* replace message content\n */\n messageReplaceContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML = content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n\n changeTheme(newTheme) {\n this._chatWidget.classList.remove(this._theme);\n this._chatWidget.classList.add(newTheme);\n this._theme = newTheme;\n }\n\n get theme() {\n return this._theme;\n }\n\n static getVersion() {\n return {\"version\" : \"1.0.2\"}\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","trackHistory","_classCallCheck","document","querySelector","_parentElement","_theme","_onSend","_createWidget","titleArea","titleAreaSetContents","title","align","show","titleAreaShow","titleAreaHide","_attachEventListeners","_history","_createClass","key","value","widgetHTML","concat","innerHTML","_chatWidget","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","$","_this","addEventListener","trim","window","_handleContainerResize","event","shiftKey","keyCode","preventDefault","titleAreaToggle","style","display","_adjustMessagesAreaHeight","textAlign","titleAreaGetContents","inputAreaToggle","classList","toggle","inputAreaShow","inputAreaHide","hiddenElements","_toConsumableArray","children","filter","child","contains","totalHiddenHeight","reduce","sum","offsetHeight","containerHeight","height","_adjustSendButtonWidth","sendButtonText","textContent","fontSize","parseFloat","getComputedStyle","minWidth","messageAddNew","message","user","messageDiv","createElement","msgidClass","String","padStart","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","messageRemove","n","sucess","removeChild","error","console","log","messageGetDOMObject","msg","messageGetContent","content","messageAppendContent","messageReplaceContent","changeTheme","newTheme","remove","get","getVersion"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACMA,QAAQ,gBAAA,YAAA;EACV,SAAAA,QAAAA,CAAYC,aAAa,EAKlB;IAAA,IAJHC,IAAI,GAAAC,SAAA,CAAAC,MAAA,GAAAD,CAAAA,IAAAA,SAAA,CAAAE,CAAAA,CAAAA,KAAAA,SAAA,GAAAF,SAAA,CAAG,CAAA,CAAA,GAAA;AACHG,MAAAA,KAAK,EAAE,sBAAsB;AAC7BC,MAAAA,MAAM,EAAE,SAAAA,MAAA,GAAM,EAAG;AACjBC,MAAAA,YAAY,EAAE,IAAA;KACjB,CAAA;AAAAC,IAAAA,eAAA,OAAAT,QAAA,CAAA,CAAA;AACD,IAAA,IAAI,OAAOC,aAAa,KAAK,QAAQ,EAAE;AAC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;MAChB,OAAO;AAAC,QAAA,SAAS,EAAG,OAAA;OAAQ,CAAA;AAChC,KAAA;AAAC,GAAA,CAAA,CAAA,CAAA;AAAA,CAAA;;;;"}
\ No newline at end of file
diff --git a/dist/quikchat.esm.min.js b/dist/quikchat.esm.min.js
index 3a29d1c..eb60234 100644
--- a/dist/quikchat.esm.min.js
+++ b/dist/quikchat.esm.min.js
@@ -1,2 +1,2 @@
-function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n1&&void 0!==arguments[1]?arguments[1]:{theme:"quikchat-theme-light",onSend:function(){}};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),"string"==typeof e&&(e=document.querySelector(e)),this._parentElement=e,this._theme=n.theme,this._onSend=n.onSend?n.onSend:function(){},this._createWidget(),n.titleArea&&(this.titleAreaSetContents(n.titleArea.title,n.titleArea.align),n.titleArea.show?this.titleAreaShow():this.titleAreaHide()),this._attachEventListeners()},i=[{key:"_createWidget",value:function(){var t='\n \n
\n Title Area\n
\n
\n
\n \n \n
\n
\n ');this._parentElement.innerHTML=t,this._chatWidget=this._parentElement.querySelector(".quikchat-base"),this._titleArea=this._chatWidget.querySelector(".quikchat-title-area"),this._messagesArea=this._chatWidget.querySelector(".quikchat-messages-area"),this._inputArea=this._chatWidget.querySelector(".quikchat-input-area"),this._textEntry=this._inputArea.querySelector(".quikchat-input-textbox"),this._sendButton=this._inputArea.querySelector(".quikchat-input-send-btn"),this.msgid=0}},{key:"$",value:function(){}},{key:"_attachEventListeners",value:function(){var t=this;this._sendButton.addEventListener("click",(function(){return t._onSend(t,t._textEntry.value.trim())})),window.addEventListener("resize",(function(){return t._handleContainerResize()})),this._chatWidget.addEventListener("resize",(function(){return t._handleContainerResize()})),this._textEntry.addEventListener("keydown",(function(e){e.shiftKey&&13===e.keyCode&&(e.preventDefault(),t._onSend(t,t._textEntry.value.trim()))}))}},{key:"titleAreaToggle",value:function(){"none"===this._titleArea.style.display?this.titleAreaShow():this.titleAreaHide()}},{key:"titleAreaShow",value:function(){this._titleArea.style.display="",this._adjustMessagesAreaHeight()}},{key:"titleAreaHide",value:function(){this._titleArea.style.display="none",this._adjustMessagesAreaHeight()}},{key:"titleAreaSetContents",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"center";this._titleArea.innerHTML=t,this._titleArea.style.textAlign=e}},{key:"titleAreaGetContents",value:function(){return this._titleArea.innerHTML}},{key:"inputAreaToggle",value:function(){this._inputArea.classList.toggle("hidden"),"none"===this._inputArea.style.display?this.inputAreaShow():this.inputAreaHide()}},{key:"inputAreaShow",value:function(){this._inputArea.style.display="",this._adjustMessagesAreaHeight()}},{key:"inputAreaHide",value:function(){this._inputArea.style.display="none",this._adjustMessagesAreaHeight()}},{key:"_adjustMessagesAreaHeight",value:function(){var t=n(this._chatWidget.children).filter((function(t){return t.classList.contains("hidden")})).reduce((function(t,e){return t+e.offsetHeight}),0),e=this._chatWidget.offsetHeight;this._messagesArea.style.height="calc(100% - ".concat(e-t,"px)")}},{key:"_handleContainerResize",value:function(){this._adjustMessagesAreaHeight(),this._adjustSendButtonWidth()}},{key:"_adjustSendButtonWidth",value:function(){var t=this._sendButton.textContent.trim(),e=parseFloat(getComputedStyle(this._sendButton).fontSize)*t.length+16;this._sendButton.style.minWidth="".concat(e,"px")}},{key:"messageAddNew",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"foo",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"left",i=document.createElement("div"),a=this.msgid,s="quikchat-msgid-"+String(a).padStart(10,"0");i.classList.add("quikchat-message",s),this.msgid++,i.classList.add(this._messagesArea.children.length%2==1?"quikchat-message-1":"quikchat-message-2");var r=document.createElement("div");r.innerHTML=e,r.style="width: 100%; text-align: ".concat(n,"; font-size: 1em; font-weight:700; color: #444;");var o=document.createElement("div");return o.style="width: 100%; text-align: ".concat(n,";"),o.innerHTML=t,i.appendChild(r),i.appendChild(o),this._messagesArea.appendChild(i),this._messagesArea.lastChild.scrollIntoView(),this._textEntry.value="",this._adjustMessagesAreaHeight(),{msgid:a}}},{key:"messageRemove",value:function(t){var e=!1;try{this._messagesArea.removeChild(this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0")))),e=!0}catch(t){console.log("{String(n)} : Message ID not found")}return e}},{key:"messageGetDOMObject",value:function(t){var e=null;try{e=this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0")))}catch(t){console.log("{String(n)} : Message ID not found")}return e}},{key:"messageGetContent",value:function(t){var e="";try{e=this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0"))).lastChild.textContent}catch(t){console.log("{String(n)} : Message ID not found")}return e}},{key:"messageAppendContent",value:function(t,e){try{this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0"))).lastChild.innerHTML+=e}catch(t){console.log("{String(n)} : Message ID not found")}}},{key:"messageReplaceContent",value:function(t,e){var n=!1;try{this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0"))).lastChild.innerHTML=e,n=!0}catch(t){console.log("{String(n)} : Message ID not found")}return n}},{key:"changeTheme",value:function(t){this._chatWidget.classList.remove(this._theme),this._chatWidget.classList.add(t),this._theme=t}},{key:"theme",get:function(){return this._theme}}],a=[{key:"getVersion",value:function(){return{version:"1.0.2"}}}],i&&e(t.prototype,i),a&&e(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,i,a}();export{a as default};
+function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n1&&void 0!==arguments[1]?arguments[1]:{theme:"quikchat-theme-light",onSend:function(){},trackHistory:!0};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),"string"==typeof e&&(e=document.querySelector(e)),this._parentElement=e,this._theme=n.theme,this._onSend=n.onSend?n.onSend:function(){},this._createWidget(),n.titleArea&&(this.titleAreaSetContents(n.titleArea.title,n.titleArea.align),n.titleArea.show?this.titleAreaShow():this.titleAreaHide()),this._attachEventListeners(),this._history=[]},i=[{key:"_createWidget",value:function(){var t='\n \n
\n Title Area\n
\n
\n
\n \n \n
\n
\n ');this._parentElement.innerHTML=t,this._chatWidget=this._parentElement.querySelector(".quikchat-base"),this._titleArea=this._chatWidget.querySelector(".quikchat-title-area"),this._messagesArea=this._chatWidget.querySelector(".quikchat-messages-area"),this._inputArea=this._chatWidget.querySelector(".quikchat-input-area"),this._textEntry=this._inputArea.querySelector(".quikchat-input-textbox"),this._sendButton=this._inputArea.querySelector(".quikchat-input-send-btn"),this.msgid=0}},{key:"$",value:function(){}},{key:"_attachEventListeners",value:function(){var t=this;this._sendButton.addEventListener("click",(function(){return t._onSend(t,t._textEntry.value.trim())})),window.addEventListener("resize",(function(){return t._handleContainerResize()})),this._chatWidget.addEventListener("resize",(function(){return t._handleContainerResize()})),this._textEntry.addEventListener("keydown",(function(e){e.shiftKey&&13===e.keyCode&&(e.preventDefault(),t._onSend(t,t._textEntry.value.trim()))}))}},{key:"titleAreaToggle",value:function(){"none"===this._titleArea.style.display?this.titleAreaShow():this.titleAreaHide()}},{key:"titleAreaShow",value:function(){this._titleArea.style.display="",this._adjustMessagesAreaHeight()}},{key:"titleAreaHide",value:function(){this._titleArea.style.display="none",this._adjustMessagesAreaHeight()}},{key:"titleAreaSetContents",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"center";this._titleArea.innerHTML=t,this._titleArea.style.textAlign=e}},{key:"titleAreaGetContents",value:function(){return this._titleArea.innerHTML}},{key:"inputAreaToggle",value:function(){this._inputArea.classList.toggle("hidden"),"none"===this._inputArea.style.display?this.inputAreaShow():this.inputAreaHide()}},{key:"inputAreaShow",value:function(){this._inputArea.style.display="",this._adjustMessagesAreaHeight()}},{key:"inputAreaHide",value:function(){this._inputArea.style.display="none",this._adjustMessagesAreaHeight()}},{key:"_adjustMessagesAreaHeight",value:function(){var t=n(this._chatWidget.children).filter((function(t){return t.classList.contains("hidden")})).reduce((function(t,e){return t+e.offsetHeight}),0),e=this._chatWidget.offsetHeight;this._messagesArea.style.height="calc(100% - ".concat(e-t,"px)")}},{key:"_handleContainerResize",value:function(){this._adjustMessagesAreaHeight(),this._adjustSendButtonWidth()}},{key:"_adjustSendButtonWidth",value:function(){var t=this._sendButton.textContent.trim(),e=parseFloat(getComputedStyle(this._sendButton).fontSize)*t.length+16;this._sendButton.style.minWidth="".concat(e,"px")}},{key:"messageAddNew",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"foo",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"left",i=document.createElement("div"),a=this.msgid,s="quikchat-msgid-"+String(a).padStart(10,"0");i.classList.add("quikchat-message",s),this.msgid++,i.classList.add(this._messagesArea.children.length%2==1?"quikchat-message-1":"quikchat-message-2");var r=document.createElement("div");r.innerHTML=e,r.style="width: 100%; text-align: ".concat(n,"; font-size: 1em; font-weight:700; color: #444;");var o=document.createElement("div");return o.style="width: 100%; text-align: ".concat(n,";"),o.innerHTML=t,i.appendChild(r),i.appendChild(o),this._messagesArea.appendChild(i),this._messagesArea.lastChild.scrollIntoView(),this._textEntry.value="",this._adjustMessagesAreaHeight(),{msgid:a}}},{key:"messageRemove",value:function(t){var e=!1;try{this._messagesArea.removeChild(this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0")))),e=!0}catch(t){console.log("{String(n)} : Message ID not found")}return e}},{key:"messageGetDOMObject",value:function(t){var e=null;try{e=this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0")))}catch(t){console.log("{String(n)} : Message ID not found")}return e}},{key:"messageGetContent",value:function(t){var e="";try{e=this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0"))).lastChild.textContent}catch(t){console.log("{String(n)} : Message ID not found")}return e}},{key:"messageAppendContent",value:function(t,e){try{this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0"))).lastChild.innerHTML+=e}catch(t){console.log("{String(n)} : Message ID not found")}}},{key:"messageReplaceContent",value:function(t,e){var n=!1;try{this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0"))).lastChild.innerHTML=e,n=!0}catch(t){console.log("{String(n)} : Message ID not found")}return n}},{key:"changeTheme",value:function(t){this._chatWidget.classList.remove(this._theme),this._chatWidget.classList.add(t),this._theme=t}},{key:"theme",get:function(){return this._theme}}],a=[{key:"getVersion",value:function(){return{version:"1.0.2"}}}],i&&e(t.prototype,i),a&&e(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,i,a}();export{a as default};
//# sourceMappingURL=quikchat.esm.min.js.map
diff --git a/dist/quikchat.esm.min.js.map b/dist/quikchat.esm.min.js.map
index 97ff531..198a15d 100644
--- a/dist/quikchat.esm.min.js.map
+++ b/dist/quikchat.esm.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"quikchat.esm.min.js","sources":["../src/quikchat.js"],"sourcesContent":["\nclass quikchat {\n constructor(parentElement, meta = { theme: 'quikchat-theme-light', onSend: () => { } }) {\n if (typeof parentElement === 'string') {\n parentElement = document.querySelector(parentElement);\n }\n this._parentElement = parentElement;\n this._theme = meta.theme;\n this._onSend = meta.onSend ? meta.onSend : () => { };\n this._createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this._attachEventListeners();\n }\n\n _createWidget() {\n const widgetHTML =\n `\n \n
\n Title Area\n
\n
\n
\n \n \n
\n
\n `;\n\n this._parentElement.innerHTML = widgetHTML;\n this._chatWidget = this._parentElement.querySelector('.quikchat-base');\n this._titleArea = this._chatWidget.querySelector('.quikchat-title-area');\n this._messagesArea = this._chatWidget.querySelector('.quikchat-messages-area');\n this._inputArea = this._chatWidget.querySelector('.quikchat-input-area');\n this._textEntry = this._inputArea.querySelector('.quikchat-input-textbox');\n this._sendButton = this._inputArea.querySelector('.quikchat-input-send-btn');\n this.msgid = 0;\n }\n $() {\n }\n _attachEventListeners() {\n this._sendButton.addEventListener('click', () => this._onSend(this, this._textEntry.value.trim()));\n window.addEventListener('resize', () => this._handleContainerResize());\n this._chatWidget.addEventListener('resize', () => this._handleContainerResize());\n this._textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this._onSend(this, this._textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this._titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this._titleArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this._titleArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaSetContents(title, align = 'center') {\n this._titleArea.innerHTML = title;\n this._titleArea.style.textAlign = align;\n }\n\n titleAreaGetContents() {\n return this._titleArea.innerHTML;\n }\n\n inputAreaToggle() {\n this._inputArea.classList.toggle('hidden');\n this._inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this._inputArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this._inputArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n _adjustMessagesAreaHeight() {\n const hiddenElements = [...this._chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this._chatWidget.offsetHeight;\n this._messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n _handleContainerResize() {\n this._adjustMessagesAreaHeight();\n this._adjustSendButtonWidth();\n //console.log('Container resized');\n }\n\n _adjustSendButtonWidth() {\n const sendButtonText = this._sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this._sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this._sendButton.style.minWidth = `${minWidth}px`;\n }\n\n messageAddNew(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n const msgid = this.msgid;\n const msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');\n messageDiv.classList.add('quikchat-message', msgidClass);\n this.msgid++;\n messageDiv.classList.add(this._messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.innerHTML = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.innerHTML = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n this._messagesArea.lastChild.scrollIntoView();\n\n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n return {msgid};\n }\n\n messageRemove(n) {\n // use css selector to remove the message\n let sucess = false;\n try {\n this._messagesArea.removeChild(this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`));\n sucess = true;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n /* returns the message html object from the DOM\n */\n messageGetDOMObject(n) {\n let msg = null;\n // now use css selector to get the message \n try {\n msg = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`);\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return msg; \n }\n /* returns the message content only\n */\n messageGetContent(n) {\n let content = \"\"\n // now use css selector to get the message \n try {\n content = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.textContent;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return content; \n }\n\n /* append message to the message content\n */\n messageAppendContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML += content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n } \n }\n /* replace message content\n */\n messageReplaceContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML = content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n\n changeTheme(newTheme) {\n this._chatWidget.classList.remove(this._theme);\n this._chatWidget.classList.add(newTheme);\n this._theme = newTheme;\n }\n\n get theme() {\n return this._theme;\n }\n\n static getVersion() {\n return {\"version\" : \"1.0.2\"}\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","_classCallCheck","document","querySelector","this","_parentElement","_theme","_onSend","_createWidget","titleArea","titleAreaSetContents","title","align","show","titleAreaShow","titleAreaHide","_attachEventListeners","key","value","widgetHTML","concat","innerHTML","_chatWidget","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","_this","addEventListener","trim","window","_handleContainerResize","event","shiftKey","keyCode","preventDefault","style","display","_adjustMessagesAreaHeight","textAlign","classList","toggle","inputAreaShow","inputAreaHide","totalHiddenHeight","_toConsumableArray","children","filter","child","contains","reduce","sum","offsetHeight","containerHeight","height","_adjustSendButtonWidth","sendButtonText","textContent","minWidth","parseFloat","getComputedStyle","fontSize","message","user","messageDiv","createElement","msgidClass","String","padStart","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","n","sucess","removeChild","error","console","log","msg","content","newTheme","remove","get","version"],"mappings":"8qCACMA,EAAQ,WAmBT,SAlBD,SAAAA,EAAYC,GAA4E,IAA7DC,EAAIC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAG,GAAA,CAAEG,MAAO,uBAAwBC,OAAQ,WAAQ,gGAAGC,MAAAR,GACrD,iBAAlBC,IACPA,EAAgBQ,SAASC,cAAcT,IAE3CU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gGAAC,CAlOS"}
\ No newline at end of file
+{"version":3,"file":"quikchat.esm.min.js","sources":["../src/quikchat.js"],"sourcesContent":["\nclass quikchat {\n constructor(parentElement, \n meta = { \n theme: 'quikchat-theme-light', \n onSend: () => { },\n trackHistory: true,\n }) {\n if (typeof parentElement === 'string') {\n parentElement = document.querySelector(parentElement);\n }\n this._parentElement = parentElement;\n this._theme = meta.theme;\n this._onSend = meta.onSend ? meta.onSend : () => { };\n this._createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this._attachEventListeners();\n this._history = [];\n }\n\n _createWidget() {\n const widgetHTML =\n `\n \n
\n Title Area\n
\n
\n
\n \n \n
\n
\n `;\n\n this._parentElement.innerHTML = widgetHTML;\n this._chatWidget = this._parentElement.querySelector('.quikchat-base');\n this._titleArea = this._chatWidget.querySelector('.quikchat-title-area');\n this._messagesArea = this._chatWidget.querySelector('.quikchat-messages-area');\n this._inputArea = this._chatWidget.querySelector('.quikchat-input-area');\n this._textEntry = this._inputArea.querySelector('.quikchat-input-textbox');\n this._sendButton = this._inputArea.querySelector('.quikchat-input-send-btn');\n this.msgid = 0;\n }\n $() {\n }\n _attachEventListeners() {\n this._sendButton.addEventListener('click', () => this._onSend(this, this._textEntry.value.trim()));\n window.addEventListener('resize', () => this._handleContainerResize());\n this._chatWidget.addEventListener('resize', () => this._handleContainerResize());\n this._textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this._onSend(this, this._textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this._titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this._titleArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this._titleArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaSetContents(title, align = 'center') {\n this._titleArea.innerHTML = title;\n this._titleArea.style.textAlign = align;\n }\n\n titleAreaGetContents() {\n return this._titleArea.innerHTML;\n }\n\n inputAreaToggle() {\n this._inputArea.classList.toggle('hidden');\n this._inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this._inputArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this._inputArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n _adjustMessagesAreaHeight() {\n const hiddenElements = [...this._chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this._chatWidget.offsetHeight;\n this._messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n _handleContainerResize() {\n this._adjustMessagesAreaHeight();\n this._adjustSendButtonWidth();\n //console.log('Container resized');\n }\n\n _adjustSendButtonWidth() {\n const sendButtonText = this._sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this._sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this._sendButton.style.minWidth = `${minWidth}px`;\n }\n\n messageAddNew(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n const msgid = this.msgid;\n const msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');\n messageDiv.classList.add('quikchat-message', msgidClass);\n this.msgid++;\n messageDiv.classList.add(this._messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.innerHTML = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.innerHTML = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n this._messagesArea.lastChild.scrollIntoView();\n\n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n return {msgid};\n }\n\n messageRemove(n) {\n // use css selector to remove the message\n let sucess = false;\n try {\n this._messagesArea.removeChild(this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`));\n sucess = true;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n /* returns the message html object from the DOM\n */\n messageGetDOMObject(n) {\n let msg = null;\n // now use css selector to get the message \n try {\n msg = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`);\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return msg; \n }\n /* returns the message content only\n */\n messageGetContent(n) {\n let content = \"\"\n // now use css selector to get the message \n try {\n content = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.textContent;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return content; \n }\n\n /* append message to the message content\n */\n messageAppendContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML += content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n } \n }\n /* replace message content\n */\n messageReplaceContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML = content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n\n changeTheme(newTheme) {\n this._chatWidget.classList.remove(this._theme);\n this._chatWidget.classList.add(newTheme);\n this._theme = newTheme;\n }\n\n get theme() {\n return this._theme;\n }\n\n static getVersion() {\n return {\"version\" : \"1.0.2\"}\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","trackHistory","_classCallCheck","document","querySelector","this","_parentElement","_theme","_onSend","_createWidget","titleArea","titleAreaSetContents","title","align","show","titleAreaShow","titleAreaHide","_attachEventListeners","_history","key","value","widgetHTML","concat","innerHTML","_chatWidget","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","_this","addEventListener","trim","window","_handleContainerResize","event","shiftKey","keyCode","preventDefault","style","display","_adjustMessagesAreaHeight","textAlign","classList","toggle","inputAreaShow","inputAreaHide","totalHiddenHeight","_toConsumableArray","children","filter","child","contains","reduce","sum","offsetHeight","containerHeight","height","_adjustSendButtonWidth","sendButtonText","textContent","minWidth","parseFloat","getComputedStyle","fontSize","message","user","messageDiv","createElement","msgidClass","String","padStart","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","n","sucess","removeChild","error","console","log","msg","content","newTheme","remove","get","version"],"mappings":"8qCACMA,EAAQ,WAyBT,SAxBD,SAAAA,EAAYC,GAKL,IAJHC,EAAIC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAG,GAAA,CACHG,MAAO,uBACPC,OAAQ,WAAS,EACjBC,cAAc,gGACjBC,MAAAT,GAC4B,iBAAlBC,IACPA,EAAgBS,SAASC,cAAcV,IAE3CW,KAAKC,eAAiBZ,EACtBW,KAAKE,OAASZ,EAAKI,MACnBM,KAAKG,QAAUb,EAAKK,OAASL,EAAKK,OAAS,aAC3CK,KAAKI,gBAEDd,EAAKe,YACLL,KAAKM,qBAAqBhB,EAAKe,UAAUE,MAAOjB,EAAKe,UAAUG,OAC3DlB,EAAKe,UAAUI,KACfT,KAAKU,gBAELV,KAAKW,iBAGbX,KAAKY,wBACLZ,KAAKa,SAAW,EACpB,IAAC,CAAA,CAAAC,IAAA,gBAAAC,MAED,WACI,IAAMC,EAAUC,2CAAAA,OAEgBjB,KAAKN,MAUhC,weAELM,KAAKC,eAAeiB,UAAYF,EAChChB,KAAKmB,YAAcnB,KAAKC,eAAeF,cAAc,kBACrDC,KAAKoB,W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B,GAEHC,QAAQC,IAAG,qCACf,CACA,OAAOE,CACX,GAEA,CAAAnE,IAAA,uBAAAC,MAEA,SAAqB2D,EAAGO,GAEpB,IACIjF,KAAKqB,cAActB,cAAa,mBAAAkB,OAAoBiD,OAAOQ,GAAGP,SAAS,GAAI,OAAQK,UAAUtD,WAAa+D,CAE7G,CACD,MAAOJ,GAEHC,QAAQC,IAAG,qCACf,CACJ,GACA,CAAAjE,IAAA,wBAAAC,MAEA,SAAsB2D,EAAGO,GACrB,IAAIN,GAAS,EACb,IACI3E,KAAKqB,cAActB,cAAa,mBAAAkB,OAAoBiD,OAAOQ,GAAGP,SAAS,GAAI,OAAQK,UAAUtD,UAAY+D,EACzGN,GAAS,CACZ,CACD,MAAOE,GAEHC,QAAQC,IAAG,qCACf,CACA,OAAOJ,CACX,GAAC,CAAA7D,IAAA,cAAAC,MAED,SAAYmE,GACRlF,KAAKmB,YAAYoB,UAAU4C,OAAOnF,KAAKE,QACvCF,KAAKmB,YAAYoB,UAAU6B,IAAIc,GAC/BlF,KAAKE,OAASgF,CAClB,GAAC,CAAApE,IAAA,QAAAsE,IAED,WACI,OAAOpF,KAAKE,MAChB,MAAC,CAAA,CAAAY,IAAA,aAAAC,MAED,WACI,MAAO,CAACsE,QAAY,QACxB,gGAAC,CAxOS"}
\ No newline at end of file
diff --git a/dist/quikchat.umd.js b/dist/quikchat.umd.js
index 93213ee..9f6600e 100644
--- a/dist/quikchat.umd.js
+++ b/dist/quikchat.umd.js
@@ -61,7 +61,8 @@
function quikchat(parentElement) {
var meta = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
theme: 'quikchat-theme-light',
- onSend: function onSend() {}
+ onSend: function onSend() {},
+ trackHistory: true
};
_classCallCheck(this, quikchat);
if (typeof parentElement === 'string') {
@@ -81,6 +82,7 @@
}
}
this._attachEventListeners();
+ this._history = [];
}
return _createClass(quikchat, [{
key: "_createWidget",
diff --git a/dist/quikchat.umd.js.map b/dist/quikchat.umd.js.map
index 39690ea..21ba6e7 100644
--- a/dist/quikchat.umd.js.map
+++ b/dist/quikchat.umd.js.map
@@ -1 +1 @@
-{"version":3,"file":"quikchat.umd.js","sources":["../src/quikchat.js"],"sourcesContent":["\nclass quikchat {\n constructor(parentElement, meta = { theme: 'quikchat-theme-light', onSend: () => { } }) {\n if (typeof parentElement === 'string') {\n parentElement = document.querySelector(parentElement);\n }\n this._parentElement = parentElement;\n this._theme = meta.theme;\n this._onSend = meta.onSend ? meta.onSend : () => { };\n this._createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this._attachEventListeners();\n }\n\n _createWidget() {\n const widgetHTML =\n `\n \n
\n Title Area\n
\n
\n
\n \n \n
\n
\n `;\n\n this._parentElement.innerHTML = widgetHTML;\n this._chatWidget = this._parentElement.querySelector('.quikchat-base');\n this._titleArea = this._chatWidget.querySelector('.quikchat-title-area');\n this._messagesArea = this._chatWidget.querySelector('.quikchat-messages-area');\n this._inputArea = this._chatWidget.querySelector('.quikchat-input-area');\n this._textEntry = this._inputArea.querySelector('.quikchat-input-textbox');\n this._sendButton = this._inputArea.querySelector('.quikchat-input-send-btn');\n this.msgid = 0;\n }\n $() {\n }\n _attachEventListeners() {\n this._sendButton.addEventListener('click', () => this._onSend(this, this._textEntry.value.trim()));\n window.addEventListener('resize', () => this._handleContainerResize());\n this._chatWidget.addEventListener('resize', () => this._handleContainerResize());\n this._textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this._onSend(this, this._textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this._titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this._titleArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this._titleArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaSetContents(title, align = 'center') {\n this._titleArea.innerHTML = title;\n this._titleArea.style.textAlign = align;\n }\n\n titleAreaGetContents() {\n return this._titleArea.innerHTML;\n }\n\n inputAreaToggle() {\n this._inputArea.classList.toggle('hidden');\n this._inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this._inputArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this._inputArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n _adjustMessagesAreaHeight() {\n const hiddenElements = [...this._chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this._chatWidget.offsetHeight;\n this._messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n _handleContainerResize() {\n this._adjustMessagesAreaHeight();\n this._adjustSendButtonWidth();\n //console.log('Container resized');\n }\n\n _adjustSendButtonWidth() {\n const sendButtonText = this._sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this._sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this._sendButton.style.minWidth = `${minWidth}px`;\n }\n\n messageAddNew(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n const msgid = this.msgid;\n const msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');\n messageDiv.classList.add('quikchat-message', msgidClass);\n this.msgid++;\n messageDiv.classList.add(this._messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.innerHTML = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.innerHTML = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n this._messagesArea.lastChild.scrollIntoView();\n\n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n return {msgid};\n }\n\n messageRemove(n) {\n // use css selector to remove the message\n let sucess = false;\n try {\n this._messagesArea.removeChild(this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`));\n sucess = true;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n /* returns the message html object from the DOM\n */\n messageGetDOMObject(n) {\n let msg = null;\n // now use css selector to get the message \n try {\n msg = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`);\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return msg; \n }\n /* returns the message content only\n */\n messageGetContent(n) {\n let content = \"\"\n // now use css selector to get the message \n try {\n content = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.textContent;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return content; \n }\n\n /* append message to the message content\n */\n messageAppendContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML += content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n } \n }\n /* replace message content\n */\n messageReplaceContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML = content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n\n changeTheme(newTheme) {\n this._chatWidget.classList.remove(this._theme);\n this._chatWidget.classList.add(newTheme);\n this._theme = newTheme;\n }\n\n get theme() {\n return this._theme;\n }\n\n static getVersion() {\n return {\"version\" : \"1.0.2\"}\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","_classCallCheck","document","querySelector","_parentElement","_theme","_onSend","_createWidget","titleArea","titleAreaSetContents","title","align","show","titleAreaShow","titleAreaHide","_attachEventListeners","_createClass","key","value","widgetHTML","concat","innerHTML","_chatWidget","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","$","_this","addEventListener","trim","window","_handleContainerResize","event","shiftKey","keyCode","preventDefault","titleAreaToggle","style","display","_adjustMessagesAreaHeight","textAlign","titleAreaGetContents","inputAreaToggle","classList","toggle","inputAreaShow","inputAreaHide","hiddenElements","_toConsumableArray","children","filter","child","contains","totalHiddenHeight","reduce","sum","offsetHeight","containerHeight","height","_adjustSendButtonWidth","sendButtonText","textContent","fontSize","parseFloat","getComputedStyle","minWidth","messageAddNew","message","user","messageDiv","createElement","msgidClass","String","padStart","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","messageRemove","n","sucess","removeChild","error","console","log","messageGetDOMObject","msg","messageGetContent","content","messageAppendContent","messageReplaceContent","changeTheme","newTheme","remove","get","getVersion"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MACMA,QAAQ,gBAAA,YAAA;IACV,SAAAA,QAAAA,CAAYC,aAAa,EAA+D;MAAA,IAA7DC,IAAI,GAAAC,SAAA,CAAAC,MAAA,GAAAD,CAAAA,IAAAA,SAAA,CAAAE,CAAAA,CAAAA,KAAAA,SAAA,GAAAF,SAAA,CAAG,CAAA,CAAA,GAAA;EAAEG,MAAAA,KAAK,EAAE,sBAAsB;EAAEC,MAAAA,MAAM,EAAE,SAAAA,MAAA,GAAM,EAAE;OAAG,CAAA;EAAAC,IAAAA,eAAA,OAAAR,QAAA,CAAA,CAAA;EAClF,IAAA,IAAI,OAAOC,aAAa,KAAK,QAAQ,EAAE;EACnCA,MAAAA,aAAa,GAAGQ,QAAQ,CAACC,aAAa,CAACT,aAAa,CAAC,CAAA;EACzD,KAAA;MACA,IAAI,CAACU,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.umd.js","sources":["../src/quikchat.js"],"sourcesContent":["\nclass quikchat {\n constructor(parentElement, \n meta = { \n theme: 'quikchat-theme-light', \n onSend: () => { },\n trackHistory: true,\n }) {\n if (typeof parentElement === 'string') {\n parentElement = document.querySelector(parentElement);\n }\n this._parentElement = parentElement;\n this._theme = meta.theme;\n this._onSend = meta.onSend ? meta.onSend : () => { };\n this._createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this._attachEventListeners();\n this._history = [];\n }\n\n _createWidget() {\n const widgetHTML =\n `\n \n
\n Title Area\n
\n
\n
\n \n \n
\n
\n `;\n\n this._parentElement.innerHTML = widgetHTML;\n this._chatWidget = this._parentElement.querySelector('.quikchat-base');\n this._titleArea = this._chatWidget.querySelector('.quikchat-title-area');\n this._messagesArea = this._chatWidget.querySelector('.quikchat-messages-area');\n this._inputArea = this._chatWidget.querySelector('.quikchat-input-area');\n this._textEntry = this._inputArea.querySelector('.quikchat-input-textbox');\n this._sendButton = this._inputArea.querySelector('.quikchat-input-send-btn');\n this.msgid = 0;\n }\n $() {\n }\n _attachEventListeners() {\n this._sendButton.addEventListener('click', () => this._onSend(this, this._textEntry.value.trim()));\n window.addEventListener('resize', () => this._handleContainerResize());\n this._chatWidget.addEventListener('resize', () => this._handleContainerResize());\n this._textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this._onSend(this, this._textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this._titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this._titleArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this._titleArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaSetContents(title, align = 'center') {\n this._titleArea.innerHTML = title;\n this._titleArea.style.textAlign = align;\n }\n\n titleAreaGetContents() {\n return this._titleArea.innerHTML;\n }\n\n inputAreaToggle() {\n this._inputArea.classList.toggle('hidden');\n this._inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this._inputArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this._inputArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n _adjustMessagesAreaHeight() {\n const hiddenElements = [...this._chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this._chatWidget.offsetHeight;\n this._messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n _handleContainerResize() {\n this._adjustMessagesAreaHeight();\n this._adjustSendButtonWidth();\n //console.log('Container resized');\n }\n\n _adjustSendButtonWidth() {\n const sendButtonText = this._sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this._sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this._sendButton.style.minWidth = `${minWidth}px`;\n }\n\n messageAddNew(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n const msgid = this.msgid;\n const msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');\n messageDiv.classList.add('quikchat-message', msgidClass);\n this.msgid++;\n messageDiv.classList.add(this._messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.innerHTML = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.innerHTML = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n this._messagesArea.lastChild.scrollIntoView();\n\n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n return {msgid};\n }\n\n messageRemove(n) {\n // use css selector to remove the message\n let sucess = false;\n try {\n this._messagesArea.removeChild(this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`));\n sucess = true;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n /* returns the message html object from the DOM\n */\n messageGetDOMObject(n) {\n let msg = null;\n // now use css selector to get the message \n try {\n msg = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`);\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return msg; \n }\n /* returns the message content only\n */\n messageGetContent(n) {\n let content = \"\"\n // now use css selector to get the message \n try {\n content = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.textContent;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return content; \n }\n\n /* append message to the message content\n */\n messageAppendContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML += content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n } \n }\n /* replace message content\n */\n messageReplaceContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML = content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n\n changeTheme(newTheme) {\n this._chatWidget.classList.remove(this._theme);\n this._chatWidget.classList.add(newTheme);\n this._theme = newTheme;\n }\n\n get theme() {\n return this._theme;\n }\n\n static getVersion() {\n return {\"version\" : \"1.0.2\"}\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","trackHistory","_classCallCheck","document","querySelector","_parentElement","_theme","_onSend","_createWidget","titleArea","titleAreaSetContents","title","align","show","titleAreaShow","titleAreaHide","_attachEventListeners","_history","_createClass","key","value","widgetHTML","concat","innerHTML","_chatWidget","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","$","_this","addEventListener","trim","window","_handleContainerResize","event","shiftKey","keyCode","preventDefault","titleAreaToggle","style","display","_adjustMessagesAreaHeight","textAlign","titleAreaGetContents","inputAreaToggle","classList","toggle","inputAreaShow","inputAreaHide","hiddenElements","_toConsumableArray","children","filter","child","contains","totalHiddenHeight","reduce","sum","offsetHeight","containerHeight","height","_adjustSendButtonWidth","sendButtonText","textContent","fontSize","parseFloat","getComputedStyle","minWidth","messageAddNew","message","user","messageDiv","createElement","msgidClass","String","padStart","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","messageRemove","n","sucess","removeChild","error","console","log","messageGetDOMObject","msg","messageGetContent","content","messageAppendContent","messageReplaceContent","changeTheme","newTheme","remove","get","getVersion"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MACMA,QAAQ,gBAAA,YAAA;IACV,SAAAA,QAAAA,CAAYC,aAAa,EAKlB;MAAA,IAJHC,IAAI,GAAAC,SAAA,CAAAC,MAAA,GAAAD,CAAAA,IAAAA,SAAA,CAAAE,CAAAA,CAAAA,KAAAA,SAAA,GAAAF,SAAA,CAAG,CAAA,CAAA,GAAA;EACHG,MAAAA,KAAK,EAAE,sBAAsB;EAC7BC,MAAAA,MAAM,EAAE,SAAAA,MAAA,GAAM,EAAG;EACjBC,MAAAA,YAAY,EAAE,IAAA;OACjB,CAAA;EAAAC,IAAAA,eAAA,OAAAT,QAAA,CAAA,CAAA;EACD,IAAA,IAAI,OAAOC,aAAa,KAAK,QAAQ,EAAE;EACnCA,MAAAA,aAAa,GAAGS,QAAQ,CAACC,aAAa,CAACV,aAAa,CAAC,CAAA;EACzD,KAAA;MACA,IAAI,CAACW,cAAc,GAAGX,aAAa,CAAA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
\ No newline at end of file
diff --git a/dist/quikchat.umd.min.js b/dist/quikchat.umd.min.js
index 7427c9d..d514a41 100644
--- a/dist/quikchat.umd.min.js
+++ b/dist/quikchat.umd.min.js
@@ -1,2 +1,2 @@
-!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).quikchat=t()}(this,(function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n1&&void 0!==arguments[1]?arguments[1]:{theme:"quikchat-theme-light",onSend:function(){}};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),"string"==typeof t&&(t=document.querySelector(t)),this._parentElement=t,this._theme=n.theme,this._onSend=n.onSend?n.onSend:function(){},this._createWidget(),n.titleArea&&(this.titleAreaSetContents(n.titleArea.title,n.titleArea.align),n.titleArea.show?this.titleAreaShow():this.titleAreaHide()),this._attachEventListeners()},i=[{key:"_createWidget",value:function(){var e='\n \n
\n Title Area\n
\n
\n
\n \n \n
\n
\n ');this._parentElement.innerHTML=e,this._chatWidget=this._parentElement.querySelector(".quikchat-base"),this._titleArea=this._chatWidget.querySelector(".quikchat-title-area"),this._messagesArea=this._chatWidget.querySelector(".quikchat-messages-area"),this._inputArea=this._chatWidget.querySelector(".quikchat-input-area"),this._textEntry=this._inputArea.querySelector(".quikchat-input-textbox"),this._sendButton=this._inputArea.querySelector(".quikchat-input-send-btn"),this.msgid=0}},{key:"$",value:function(){}},{key:"_attachEventListeners",value:function(){var e=this;this._sendButton.addEventListener("click",(function(){return e._onSend(e,e._textEntry.value.trim())})),window.addEventListener("resize",(function(){return e._handleContainerResize()})),this._chatWidget.addEventListener("resize",(function(){return e._handleContainerResize()})),this._textEntry.addEventListener("keydown",(function(t){t.shiftKey&&13===t.keyCode&&(t.preventDefault(),e._onSend(e,e._textEntry.value.trim()))}))}},{key:"titleAreaToggle",value:function(){"none"===this._titleArea.style.display?this.titleAreaShow():this.titleAreaHide()}},{key:"titleAreaShow",value:function(){this._titleArea.style.display="",this._adjustMessagesAreaHeight()}},{key:"titleAreaHide",value:function(){this._titleArea.style.display="none",this._adjustMessagesAreaHeight()}},{key:"titleAreaSetContents",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"center";this._titleArea.innerHTML=e,this._titleArea.style.textAlign=t}},{key:"titleAreaGetContents",value:function(){return this._titleArea.innerHTML}},{key:"inputAreaToggle",value:function(){this._inputArea.classList.toggle("hidden"),"none"===this._inputArea.style.display?this.inputAreaShow():this.inputAreaHide()}},{key:"inputAreaShow",value:function(){this._inputArea.style.display="",this._adjustMessagesAreaHeight()}},{key:"inputAreaHide",value:function(){this._inputArea.style.display="none",this._adjustMessagesAreaHeight()}},{key:"_adjustMessagesAreaHeight",value:function(){var e=n(this._chatWidget.children).filter((function(e){return e.classList.contains("hidden")})).reduce((function(e,t){return e+t.offsetHeight}),0),t=this._chatWidget.offsetHeight;this._messagesArea.style.height="calc(100% - ".concat(t-e,"px)")}},{key:"_handleContainerResize",value:function(){this._adjustMessagesAreaHeight(),this._adjustSendButtonWidth()}},{key:"_adjustSendButtonWidth",value:function(){var e=this._sendButton.textContent.trim(),t=parseFloat(getComputedStyle(this._sendButton).fontSize)*e.length+16;this._sendButton.style.minWidth="".concat(t,"px")}},{key:"messageAddNew",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"foo",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"left",i=document.createElement("div"),a=this.msgid,s="quikchat-msgid-"+String(a).padStart(10,"0");i.classList.add("quikchat-message",s),this.msgid++,i.classList.add(this._messagesArea.children.length%2==1?"quikchat-message-1":"quikchat-message-2");var r=document.createElement("div");r.innerHTML=t,r.style="width: 100%; text-align: ".concat(n,"; font-size: 1em; font-weight:700; color: #444;");var o=document.createElement("div");return o.style="width: 100%; text-align: ".concat(n,";"),o.innerHTML=e,i.appendChild(r),i.appendChild(o),this._messagesArea.appendChild(i),this._messagesArea.lastChild.scrollIntoView(),this._textEntry.value="",this._adjustMessagesAreaHeight(),{msgid:a}}},{key:"messageRemove",value:function(e){var t=!1;try{this._messagesArea.removeChild(this._messagesArea.querySelector(".quikchat-msgid-".concat(String(e).padStart(10,"0")))),t=!0}catch(e){console.log("{String(n)} : Message ID not found")}return t}},{key:"messageGetDOMObject",value:function(e){var t=null;try{t=this._messagesArea.querySelector(".quikchat-msgid-".concat(String(e).padStart(10,"0")))}catch(e){console.log("{String(n)} : Message ID not found")}return t}},{key:"messageGetContent",value:function(e){var t="";try{t=this._messagesArea.querySelector(".quikchat-msgid-".concat(String(e).padStart(10,"0"))).lastChild.textContent}catch(e){console.log("{String(n)} : Message ID not found")}return t}},{key:"messageAppendContent",value:function(e,t){try{this._messagesArea.querySelector(".quikchat-msgid-".concat(String(e).padStart(10,"0"))).lastChild.innerHTML+=t}catch(e){console.log("{String(n)} : Message ID not found")}}},{key:"messageReplaceContent",value:function(e,t){var n=!1;try{this._messagesArea.querySelector(".quikchat-msgid-".concat(String(e).padStart(10,"0"))).lastChild.innerHTML=t,n=!0}catch(e){console.log("{String(n)} : Message ID not found")}return n}},{key:"changeTheme",value:function(e){this._chatWidget.classList.remove(this._theme),this._chatWidget.classList.add(e),this._theme=e}},{key:"theme",get:function(){return this._theme}}],a=[{key:"getVersion",value:function(){return{version:"1.0.2"}}}],i&&t(e.prototype,i),a&&t(e,a),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,i,a}();return a}));
+!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).quikchat=e()}(this,(function(){"use strict";function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n1&&void 0!==arguments[1]?arguments[1]:{theme:"quikchat-theme-light",onSend:function(){},trackHistory:!0};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),"string"==typeof e&&(e=document.querySelector(e)),this._parentElement=e,this._theme=n.theme,this._onSend=n.onSend?n.onSend:function(){},this._createWidget(),n.titleArea&&(this.titleAreaSetContents(n.titleArea.title,n.titleArea.align),n.titleArea.show?this.titleAreaShow():this.titleAreaHide()),this._attachEventListeners(),this._history=[]},i=[{key:"_createWidget",value:function(){var t='\n \n
\n Title Area\n
\n
\n
\n \n \n
\n
\n ');this._parentElement.innerHTML=t,this._chatWidget=this._parentElement.querySelector(".quikchat-base"),this._titleArea=this._chatWidget.querySelector(".quikchat-title-area"),this._messagesArea=this._chatWidget.querySelector(".quikchat-messages-area"),this._inputArea=this._chatWidget.querySelector(".quikchat-input-area"),this._textEntry=this._inputArea.querySelector(".quikchat-input-textbox"),this._sendButton=this._inputArea.querySelector(".quikchat-input-send-btn"),this.msgid=0}},{key:"$",value:function(){}},{key:"_attachEventListeners",value:function(){var t=this;this._sendButton.addEventListener("click",(function(){return t._onSend(t,t._textEntry.value.trim())})),window.addEventListener("resize",(function(){return t._handleContainerResize()})),this._chatWidget.addEventListener("resize",(function(){return t._handleContainerResize()})),this._textEntry.addEventListener("keydown",(function(e){e.shiftKey&&13===e.keyCode&&(e.preventDefault(),t._onSend(t,t._textEntry.value.trim()))}))}},{key:"titleAreaToggle",value:function(){"none"===this._titleArea.style.display?this.titleAreaShow():this.titleAreaHide()}},{key:"titleAreaShow",value:function(){this._titleArea.style.display="",this._adjustMessagesAreaHeight()}},{key:"titleAreaHide",value:function(){this._titleArea.style.display="none",this._adjustMessagesAreaHeight()}},{key:"titleAreaSetContents",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"center";this._titleArea.innerHTML=t,this._titleArea.style.textAlign=e}},{key:"titleAreaGetContents",value:function(){return this._titleArea.innerHTML}},{key:"inputAreaToggle",value:function(){this._inputArea.classList.toggle("hidden"),"none"===this._inputArea.style.display?this.inputAreaShow():this.inputAreaHide()}},{key:"inputAreaShow",value:function(){this._inputArea.style.display="",this._adjustMessagesAreaHeight()}},{key:"inputAreaHide",value:function(){this._inputArea.style.display="none",this._adjustMessagesAreaHeight()}},{key:"_adjustMessagesAreaHeight",value:function(){var t=n(this._chatWidget.children).filter((function(t){return t.classList.contains("hidden")})).reduce((function(t,e){return t+e.offsetHeight}),0),e=this._chatWidget.offsetHeight;this._messagesArea.style.height="calc(100% - ".concat(e-t,"px)")}},{key:"_handleContainerResize",value:function(){this._adjustMessagesAreaHeight(),this._adjustSendButtonWidth()}},{key:"_adjustSendButtonWidth",value:function(){var t=this._sendButton.textContent.trim(),e=parseFloat(getComputedStyle(this._sendButton).fontSize)*t.length+16;this._sendButton.style.minWidth="".concat(e,"px")}},{key:"messageAddNew",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"foo",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"left",i=document.createElement("div"),a=this.msgid,s="quikchat-msgid-"+String(a).padStart(10,"0");i.classList.add("quikchat-message",s),this.msgid++,i.classList.add(this._messagesArea.children.length%2==1?"quikchat-message-1":"quikchat-message-2");var r=document.createElement("div");r.innerHTML=e,r.style="width: 100%; text-align: ".concat(n,"; font-size: 1em; font-weight:700; color: #444;");var o=document.createElement("div");return o.style="width: 100%; text-align: ".concat(n,";"),o.innerHTML=t,i.appendChild(r),i.appendChild(o),this._messagesArea.appendChild(i),this._messagesArea.lastChild.scrollIntoView(),this._textEntry.value="",this._adjustMessagesAreaHeight(),{msgid:a}}},{key:"messageRemove",value:function(t){var e=!1;try{this._messagesArea.removeChild(this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0")))),e=!0}catch(t){console.log("{String(n)} : Message ID not found")}return e}},{key:"messageGetDOMObject",value:function(t){var e=null;try{e=this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0")))}catch(t){console.log("{String(n)} : Message ID not found")}return e}},{key:"messageGetContent",value:function(t){var e="";try{e=this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0"))).lastChild.textContent}catch(t){console.log("{String(n)} : Message ID not found")}return e}},{key:"messageAppendContent",value:function(t,e){try{this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0"))).lastChild.innerHTML+=e}catch(t){console.log("{String(n)} : Message ID not found")}}},{key:"messageReplaceContent",value:function(t,e){var n=!1;try{this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0"))).lastChild.innerHTML=e,n=!0}catch(t){console.log("{String(n)} : Message ID not found")}return n}},{key:"changeTheme",value:function(t){this._chatWidget.classList.remove(this._theme),this._chatWidget.classList.add(t),this._theme=t}},{key:"theme",get:function(){return this._theme}}],a=[{key:"getVersion",value:function(){return{version:"1.0.2"}}}],i&&e(t.prototype,i),a&&e(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,i,a}();return a}));
//# sourceMappingURL=quikchat.umd.min.js.map
diff --git a/dist/quikchat.umd.min.js.map b/dist/quikchat.umd.min.js.map
index bba6c6a..97c3f18 100644
--- a/dist/quikchat.umd.min.js.map
+++ b/dist/quikchat.umd.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"quikchat.umd.min.js","sources":["../src/quikchat.js"],"sourcesContent":["\nclass quikchat {\n constructor(parentElement, meta = { theme: 'quikchat-theme-light', onSend: () => { } }) {\n if (typeof parentElement === 'string') {\n parentElement = document.querySelector(parentElement);\n }\n this._parentElement = parentElement;\n this._theme = meta.theme;\n this._onSend = meta.onSend ? meta.onSend : () => { };\n this._createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this._attachEventListeners();\n }\n\n _createWidget() {\n const widgetHTML =\n `\n \n
\n Title Area\n
\n
\n
\n \n \n
\n
\n `;\n\n this._parentElement.innerHTML = widgetHTML;\n this._chatWidget = this._parentElement.querySelector('.quikchat-base');\n this._titleArea = this._chatWidget.querySelector('.quikchat-title-area');\n this._messagesArea = this._chatWidget.querySelector('.quikchat-messages-area');\n this._inputArea = this._chatWidget.querySelector('.quikchat-input-area');\n this._textEntry = this._inputArea.querySelector('.quikchat-input-textbox');\n this._sendButton = this._inputArea.querySelector('.quikchat-input-send-btn');\n this.msgid = 0;\n }\n $() {\n }\n _attachEventListeners() {\n this._sendButton.addEventListener('click', () => this._onSend(this, this._textEntry.value.trim()));\n window.addEventListener('resize', () => this._handleContainerResize());\n this._chatWidget.addEventListener('resize', () => this._handleContainerResize());\n this._textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this._onSend(this, this._textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this._titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this._titleArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this._titleArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaSetContents(title, align = 'center') {\n this._titleArea.innerHTML = title;\n this._titleArea.style.textAlign = align;\n }\n\n titleAreaGetContents() {\n return this._titleArea.innerHTML;\n }\n\n inputAreaToggle() {\n this._inputArea.classList.toggle('hidden');\n this._inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this._inputArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this._inputArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n _adjustMessagesAreaHeight() {\n const hiddenElements = [...this._chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this._chatWidget.offsetHeight;\n this._messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n _handleContainerResize() {\n this._adjustMessagesAreaHeight();\n this._adjustSendButtonWidth();\n //console.log('Container resized');\n }\n\n _adjustSendButtonWidth() {\n const sendButtonText = this._sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this._sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this._sendButton.style.minWidth = `${minWidth}px`;\n }\n\n messageAddNew(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n const msgid = this.msgid;\n const msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');\n messageDiv.classList.add('quikchat-message', msgidClass);\n this.msgid++;\n messageDiv.classList.add(this._messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.innerHTML = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.innerHTML = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n this._messagesArea.lastChild.scrollIntoView();\n\n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n return {msgid};\n }\n\n messageRemove(n) {\n // use css selector to remove the message\n let sucess = false;\n try {\n this._messagesArea.removeChild(this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`));\n sucess = true;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n /* returns the message html object from the DOM\n */\n messageGetDOMObject(n) {\n let msg = null;\n // now use css selector to get the message \n try {\n msg = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`);\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return msg; \n }\n /* returns the message content only\n */\n messageGetContent(n) {\n let content = \"\"\n // now use css selector to get the message \n try {\n content = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.textContent;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return content; \n }\n\n /* append message to the message content\n */\n messageAppendContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML += content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n } \n }\n /* replace message content\n */\n messageReplaceContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML = content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n\n changeTheme(newTheme) {\n this._chatWidget.classList.remove(this._theme);\n this._chatWidget.classList.add(newTheme);\n this._theme = newTheme;\n }\n\n get theme() {\n return this._theme;\n }\n\n static getVersion() {\n return {\"version\" : \"1.0.2\"}\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","_classCallCheck","document","querySelector","this","_parentElement","_theme","_onSend","_createWidget","titleArea","titleAreaSetContents","title","align","show","titleAreaShow","titleAreaHide","_attachEventListeners","key","value","widgetHTML","concat","innerHTML","_chatWidget","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","_this","addEventListener","trim","window","_handleContainerResize","event","shiftKey","keyCode","preventDefault","style","display","_adjustMessagesAreaHeight","textAlign","classList","toggle","inputAreaShow","inputAreaHide","totalHiddenHeight","_toConsumableArray","children","filter","child","contains","reduce","sum","offsetHeight","containerHeight","height","_adjustSendButtonWidth","sendButtonText","textContent","minWidth","parseFloat","getComputedStyle","fontSize","message","user","messageDiv","createElement","msgidClass","String","padStart","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","n","sucess","removeChild","error","console","log","msg","content","newTheme","remove","get","version"],"mappings":"m5CACMA,IAAAA,EAAQ,WAmBT,SAlBD,SAAAA,EAAYC,GAA4E,IAA7DC,EAAIC,UAAAC,OAAAD,QAAAE,IAAAF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CAClB,GAAC,CAAApE,IAAA,QAAAsE,IAED,WACI,OAAOnF,KAAKE,MAChB,MAAC,CAAA,CAAAW,IAAA,aAAAC,MAED,WACI,MAAO,CAACsE,QAAY,QACxB,gGAAC,CAlOS"}
\ No newline at end of file
+{"version":3,"file":"quikchat.umd.min.js","sources":["../src/quikchat.js"],"sourcesContent":["\nclass quikchat {\n constructor(parentElement, \n meta = { \n theme: 'quikchat-theme-light', \n onSend: () => { },\n trackHistory: true,\n }) {\n if (typeof parentElement === 'string') {\n parentElement = document.querySelector(parentElement);\n }\n this._parentElement = parentElement;\n this._theme = meta.theme;\n this._onSend = meta.onSend ? meta.onSend : () => { };\n this._createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this._attachEventListeners();\n this._history = [];\n }\n\n _createWidget() {\n const widgetHTML =\n `\n \n
\n Title Area\n
\n
\n
\n \n \n
\n
\n `;\n\n this._parentElement.innerHTML = widgetHTML;\n this._chatWidget = this._parentElement.querySelector('.quikchat-base');\n this._titleArea = this._chatWidget.querySelector('.quikchat-title-area');\n this._messagesArea = this._chatWidget.querySelector('.quikchat-messages-area');\n this._inputArea = this._chatWidget.querySelector('.quikchat-input-area');\n this._textEntry = this._inputArea.querySelector('.quikchat-input-textbox');\n this._sendButton = this._inputArea.querySelector('.quikchat-input-send-btn');\n this.msgid = 0;\n }\n $() {\n }\n _attachEventListeners() {\n this._sendButton.addEventListener('click', () => this._onSend(this, this._textEntry.value.trim()));\n window.addEventListener('resize', () => this._handleContainerResize());\n this._chatWidget.addEventListener('resize', () => this._handleContainerResize());\n this._textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this._onSend(this, this._textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this._titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this._titleArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this._titleArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaSetContents(title, align = 'center') {\n this._titleArea.innerHTML = title;\n this._titleArea.style.textAlign = align;\n }\n\n titleAreaGetContents() {\n return this._titleArea.innerHTML;\n }\n\n inputAreaToggle() {\n this._inputArea.classList.toggle('hidden');\n this._inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this._inputArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this._inputArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n _adjustMessagesAreaHeight() {\n const hiddenElements = [...this._chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this._chatWidget.offsetHeight;\n this._messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n _handleContainerResize() {\n this._adjustMessagesAreaHeight();\n this._adjustSendButtonWidth();\n //console.log('Container resized');\n }\n\n _adjustSendButtonWidth() {\n const sendButtonText = this._sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this._sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this._sendButton.style.minWidth = `${minWidth}px`;\n }\n\n messageAddNew(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n const msgid = this.msgid;\n const msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');\n messageDiv.classList.add('quikchat-message', msgidClass);\n this.msgid++;\n messageDiv.classList.add(this._messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.innerHTML = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.innerHTML = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n this._messagesArea.lastChild.scrollIntoView();\n\n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n return {msgid};\n }\n\n messageRemove(n) {\n // use css selector to remove the message\n let sucess = false;\n try {\n this._messagesArea.removeChild(this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`));\n sucess = true;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n /* returns the message html object from the DOM\n */\n messageGetDOMObject(n) {\n let msg = null;\n // now use css selector to get the message \n try {\n msg = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`);\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return msg; \n }\n /* returns the message content only\n */\n messageGetContent(n) {\n let content = \"\"\n // now use css selector to get the message \n try {\n content = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.textContent;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return content; \n }\n\n /* append message to the message content\n */\n messageAppendContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML += content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n } \n }\n /* replace message content\n */\n messageReplaceContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML = content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n\n changeTheme(newTheme) {\n this._chatWidget.classList.remove(this._theme);\n this._chatWidget.classList.add(newTheme);\n this._theme = newTheme;\n }\n\n get theme() {\n return this._theme;\n }\n\n static getVersion() {\n return {\"version\" : \"1.0.2\"}\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","trackHistory","_classCallCheck","document","querySelector","this","_parentElement","_theme","_onSend","_createWidget","titleArea","titleAreaSetContents","title","align","show","titleAreaShow","titleAreaHide","_attachEventListeners","_history","key","value","widgetHTML","concat","innerHTML","_chatWidget","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","_this","addEventListener","trim","window","_handleContainerResize","event","shiftKey","keyCode","preventDefault","style","display","_adjustMessagesAreaHeight","textAlign","classList","toggle","inputAreaShow","inputAreaHide","totalHiddenHeight","_toConsumableArray","children","filter","child","contains","reduce","sum","offsetHeight","containerHeight","height","_adjustSendButtonWidth","sendButtonText","textContent","minWidth","parseFloat","getComputedStyle","fontSize","message","user","messageDiv","createElement","msgidClass","String","padStart","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","n","sucess","removeChild","error","console","log","msg","content","newTheme","remove","get","version"],"mappings":"m5CACMA,IAAAA,EAAQ,WAyBT,SAxBD,SAAAA,EAAYC,GAKL,IAJHC,EAAIC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAG,GAAA,CACHG,MAAO,uBACPC,OAAQ,WAAS,EACjBC,cAAc,gGACjBC,MAAAT,GAC4B,iBAAlBC,IACPA,EAAgBS,SAASC,cAAcV,IAE3CW,KAAKC,eAAiBZ,EACtBW,KAAKE,OAASZ,EAAKI,MACnBM,KAAKG,QAAUb,EAAKK,OAASL,EAAKK,OAAS,aAC3CK,KAAKI,gBAEDd,EAAKe,YACLL,KAAKM,qBAAqBhB,EAAKe,UAAUE,MAAOjB,EAAKe,UAAUG,OAC3DlB,EAAKe,UAAUI,KACfT,KAAKU,gBAELV,KAAKW,iBAGbX,KAAKY,wBACLZ,KAAKa,SAAW,EACpB,IAAC,CAAA,CAAAC,IAAA,gBAAAC,MAED,WACI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GACd,IAAIO,EAAU,GAEd,IACIA,EAAWjF,KAAKqB,cAActB,cAAakB,mBAAAA,OAAoBiD,OAAOQ,GAAGP,SAAS,GAAI,OAAQK,UAAUhB,WAC3G,CACD,MAAOqB,GAEHC,QAAQC,IAAG,qCACf,CACA,OAAOE,CACX,GAEA,CAAAnE,IAAA,uBAAAC,MAEA,SAAqB2D,EAAGO,GAEpB,IACIjF,KAAKqB,cAActB,cAAa,mBAAAkB,OAAoBiD,OAAOQ,GAAGP,SAAS,GAAI,OAAQK,UAAUtD,WAAa+D,CAE7G,CACD,MAAOJ,GAEHC,QAAQC,IAAG,qCACf,CACJ,GACA,CAAAjE,IAAA,wBAAAC,MAEA,SAAsB2D,EAAGO,GACrB,IAAIN,GAAS,EACb,IACI3E,KAAKqB,cAActB,cAAa,mBAAAkB,OAAoBiD,OAAOQ,GAAGP,SAAS,GAAI,OAAQK,UAAUtD,UAAY+D,EACzGN,GAAS,CACZ,CACD,MAAOE,GAEHC,QAAQC,IAAG,qCACf,CACA,OAAOJ,CACX,GAAC,CAAA7D,IAAA,cAAAC,MAED,SAAYmE,GACRlF,KAAKmB,YAAYoB,UAAU4C,OAAOnF,KAAKE,QACvCF,KAAKmB,YAAYoB,UAAU6B,IAAIc,GAC/BlF,KAAKE,OAASgF,CAClB,GAAC,CAAApE,IAAA,QAAAsE,IAED,WACI,OAAOpF,KAAKE,MAChB,MAAC,CAAA,CAAAY,IAAA,aAAAC,MAED,WACI,MAAO,CAACsE,QAAY,QACxB,gGAAC,CAxOS"}
\ No newline at end of file
diff --git a/example.html b/example.html
deleted file mode 100644
index 63675c7..0000000
--- a/example.html
+++ /dev/null
@@ -1,100 +0,0 @@
-
-
-
-
-
-
- QuikChatJS
-
-
-
-
-
-
-
-
-
-
-
- Quikchatjs Component Styles and Resize Example
- This is a test of a themeable chat widget with a title area, messages area, and input area. The title area and
- input area can be hidden.
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/quikchat.js b/src/quikchat.js
index a2215c1..13e3156 100644
--- a/src/quikchat.js
+++ b/src/quikchat.js
@@ -1,6 +1,11 @@
class quikchat {
- constructor(parentElement, meta = { theme: 'quikchat-theme-light', onSend: () => { } }) {
+ constructor(parentElement,
+ meta = {
+ theme: 'quikchat-theme-light',
+ onSend: () => { },
+ trackHistory: true,
+ }) {
if (typeof parentElement === 'string') {
parentElement = document.querySelector(parentElement);
}
@@ -18,6 +23,7 @@ class quikchat {
}
}
this._attachEventListeners();
+ this._history = [];
}
_createWidget() {