bootstrap-markdown-editor
Advanced tools
Comparing version 2.0.5 to 2.2.0
@@ -1,1 +0,1 @@ | ||
"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_createClass=function(){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}}();function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}!function(o){var e=function(){function i(e){_classCallCheck(this,i);var t=e||{},n={container:"MarkdownEditor",fullscreenButtonTitle:"Enter/exit fullscreen mode",previewButtonTitle:"Toggle Preview Mode",markdownToHtmlConvertor:function(e){return e},additionalButtons:[],window:o};this.toolbar=[{name:"",buttons:[{title:"Bold",className:"glyphicon glyphicon-bold",action:l.bold},{title:"Italic",className:"glyphicon glyphicon-italic",action:l.italic},{title:"Heading",className:"glyphicon glyphicon-header",action:null}]},{name:"",buttons:[{title:"Link",className:"glyphicon glyphicon-link",action:l.link},{title:"Image",className:"glyphicon glyphicon-picture",action:l.image}]},{name:"",buttons:[{title:"Unordered List",className:"glyphicon glyphicon-list",action:l.ulist},{title:"Ordered List",className:"glyphicon glyphicon-th-list",action:l.olist},{title:"Blockquote",className:"glyphicon glyphicon-comment",action:l.quote},{title:"Code",className:"glyphicon glyphicon-asterisk",action:null}]}],this.settings={container:t.container||n.container,fullscreenButtonTitle:t.fullscreenButtonTitle||n.fullscreenButtonTitle,previewButtonTitle:t.previewButtonTitle||n.previewButtonTitle,markdownToHtmlConvertor:t.markdownToHtmlConvertor||n.markdownToHtmlConvertor,additionalButtons:t.additionalButtons||n.additionalButtons,window:t.window||n.window},this._elements={},"string"==typeof this.settings.container?this._elements.editor=this.settings.window.document.getElementById(this.settings.container):"object"===_typeof(this.settings.container)&&(this._elements.editor=this.settings.container)}return _createClass(i,null,[{key:"FULLSCREEN_CLASS",get:function(){return"markdown-editor-fullscreen"}}]),_createClass(i,[{key:"load",value:function(e){!function(e){var t=e.settings.window.document,n=t.createElement("div");n.setAttribute("class","markdown-editor-wrapper"),(e._elements.wrapper=n).innerHTML='<div class=\'markdown-editor-header btn-toolbar\'>\n <div class="btn-group markdown-editor-modes" data-toggle="buttons">\n <label class="btn btn-default active" data-me-mode="editor" title="Editor">\n <input type="radio" name="markdownEditorMode" value="Editor" checked>\n <span class="glyphicon glyphicon-pencil"></span>\n </label>\n <label class="btn btn-default" data-me-mode="preview" title="Preview">\n <input type="radio" name="markdownEditorMode" value="Preview">\n <span class="glyphicon glyphicon-eye-open"></span>\n </label>\n <label class="btn btn-default" data-me-mode="split" title="Split mode">\n <input type="radio" name="markdownEditorMode" value="Split">\n <span class="glyphicon glyphicon-adjust"></span>\n </label>\n </div>\n\n <div class=\'btn-group\'>\n <button type=\'button\' class=\'btn btn-primary markdowneditor-fullscreen-btn\' title=\''+e.settings.fullscreenButtonTitle+"'>\n <span class='glyphicon glyphicon-fullscreen'></span>\n </button>\n </div></div>";var i=t.createElement("div");i.setAttribute("class","markdown-editor-row");var o=t.createElement("div");o.setAttribute("class","markdown-editor-preview");var l=t.createElement("div");l.setAttribute("class","markdown-editor-preview-content"),o.appendChild(l),e._elements.preview=l;var r=e._elements.editor.parentNode,a=e._elements.editor.nextSibling;i.appendChild(e._elements.editor),i.appendChild(o),n.appendChild(i),a?r.insertBefore(n,a):r.appendChild(n);for(var s=n.getElementsByClassName("markdown-editor-header")[0],c=e._renderButtons(e.toolbar.concat(e.settings.additionalButtons||[])),d=0;d<c.length;d++)s.insertBefore(c[d],s.childNodes[s.childNodes.length-1])}(this),function(t){var e=t._elements.wrapper,n=t.settings.window;e.getElementsByClassName("markdowneditor-fullscreen-btn")[0].addEventListener("click",function(e){t.enterFullscreen()});for(var i,o=e.querySelectorAll(".markdown-editor-modes label.btn"),l=0;l<o.length;l++)o[l].addEventListener("click",function(e){t.changeMode(e.currentTarget.getAttribute("data-me-mode"))});t._elements.editor.addEventListener("input",function(){i&&n.clearTimeout(i);i=n.setTimeout(function(){t._updatePreview()},250)})}(this),(e=e||function(){}).call(this)}},{key:"changeMode",value:function(e){this._elements.wrapper.setAttribute("data-mode",e),this._updatePreview()}},{key:"enterFullscreen",value:function(){this.isFullscreenMode()?this.exitFullscreen():(this._elements.wrapper.classList.add(i.FULLSCREEN_CLASS),this.settings.window.document.body.classList.add(i.FULLSCREEN_CLASS))}},{key:"exitFullscreen",value:function(){this._elements.wrapper.classList.remove(i.FULLSCREEN_CLASS),this.settings.window.document.body.classList.remove(i.FULLSCREEN_CLASS)}},{key:"isFullscreenMode",value:function(){return this._elements.wrapper.classList.contains(i.FULLSCREEN_CLASS)}},{key:"getContent",value:function(){return this._elements.editor.value}},{key:"getSelection",value:function(){var e=this._elements.editor,t=e.selectionEnd-e.selectionStart;return{start:e.selectionStart,end:e.selectionEnd,length:t,text:e.value.substr(e.selectionStart,t)}}},{key:"setSelection",value:function(e,t){var n=this._elements.editor;n.selectionStart=e,n.selectionEnd=t}},{key:"replaceSelection",value:function(e){var t=this._elements.editor;t.value=t.value.substr(0,t.selectionStart)+e+t.value.substr(t.selectionEnd,t.value.length),t.selectionStart=t.value.length}},{key:"_updatePreview",value:function(){var e=this.getContent(),t=this.settings.markdownToHtmlConvertor(e);this._elements.preview.innerHTML=t}},{key:"_renderButtons",value:function(e){for(var t=[],n=0;n<e.length;n++){var i=e[n],o=this._renderButtonsGroup(i);t.push(o)}return t}},{key:"_renderButtonsGroup",value:function(e){var t=this.settings.window.document,n=t.createElement("div"),i=this;n.setAttribute("class","btn-group");for(var o=0;o<e.buttons.length;o++){var l=e.buttons[o],r=t.createElement("button");if(l.action){r.setAttribute("type","button"),r.setAttribute("class","btn btn-default"),r.setAttribute("title",l.title);var a=t.createElement("span");a.setAttribute("class",l.className),r.action=l.action;r.addEventListener("click",function(t){return function(e){t(i),i._updatePreview()}}(l.action)),r.appendChild(a),n.appendChild(r)}}return n}}]),i}(),l={decorate:function(e,t,n){var i,o,l=t.length,r=e.getSelection(),a=e.getContent();i=0===r.length?n:r.text,a.substr(r.start-l,l)===t&&a.substr(r.end,l)===t?(e.setSelection(r.start-l,r.end+l),e.replaceSelection(i),o=r.start-l):(e.replaceSelection(t+i+t),o=r.start+l),e.setSelection(o,o+i.length)},prependToSelection:function(e,n,t){var i,o=e.getSelection(),l=n.length;if(0===o.length)i=t,e.replaceSelection(n+i),o.start+l;else if(o.text.indexOf("\n")<0)i=o.text,e.replaceSelection(n+i),o.start+l;else{var r=[];i=(r=o.text.split("\n"))[0],r.forEach(function(e,t){r[t]=n+e}),e.replaceSelection("\n\n"+r.join("\n")),o.start+l+2}},bold:function(e){l.decorate(e,"**","Strong text")},italic:function(e){l.decorate(e,"_","Emphasized text")},heading:function(e){},link:function(e){var t,n,i,o=e.getSelection();if(t=0===o.length?"Enter link description here":o.text,i=e.settings.window.prompt("Insert Hyperlink","http://"),null!==i&&""!==i&&"http://"!==i&&"http"===i.substr(0,4)){var l=i;e.replaceSelection("["+t+"]("+l+")"),n=o.start+1,e.setSelection(n,n+t.length)}},image:function(e){var t,n,i,o=e.getSelection();if(t=0===o.length?"Enter image description here":o.text,null!==(i=e.settings.window.prompt("Insert Image Hyperlink","http://"))&&""!==i&&"http://"!==i){var l=i;e.replaceSelection("!["+t+"]("+l+' "Enter image title here")'),n=o.start+2,e.setSelection(n,n+t.length)}},ulist:function(e){l.prependToSelection(e,"- ","List text here")},olist:function(e){l.prependToSelection(e,"1. ","List text here")},quote:function(e){l.prependToSelection(e,"> ","Quote here")},code:function(e){}};o.MarkdownEditor=e}(window); | ||
"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_createClass=function(){function i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t}}();function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}!function(s){var t=function(){function i(t){_classCallCheck(this,i);var e=t||{},n={container:"MarkdownEditor",fullscreenButtonTitle:"Toggle fullscreen mode",previewButtonTitle:"Toggle preview mode",markdownToHtmlConvertor:function(t){return t},saveContentUrl:null,additionalButtons:[],window:s};this.toolbar=[{name:"",buttons:[{title:"Bold",className:"glyphicon glyphicon-bold",action:o.bold},{title:"Italic",className:"glyphicon glyphicon-italic",action:o.italic},{title:"Heading",className:"glyphicon glyphicon-header",action:null}]},{name:"",buttons:[{title:"Link",className:"glyphicon glyphicon-link",action:o.link},{title:"Image",className:"glyphicon glyphicon-picture",action:o.image}]},{name:"",buttons:[{title:"Unordered List",className:"glyphicon glyphicon-list",action:o.ulist},{title:"Ordered List",className:"glyphicon glyphicon-th-list",action:o.olist},{title:"Blockquote",className:"glyphicon glyphicon-comment",action:o.quote},{title:"Code",className:"glyphicon glyphicon-asterisk",action:o.code}]}],this.settings={container:e.container||n.container,fullscreenButtonTitle:e.fullscreenButtonTitle||n.fullscreenButtonTitle,previewButtonTitle:e.previewButtonTitle||n.previewButtonTitle,markdownToHtmlConvertor:e.markdownToHtmlConvertor||n.markdownToHtmlConvertor,additionalButtons:e.additionalButtons||n.additionalButtons,saveContentUrl:e.saveContentUrl||n.saveContentUrl,window:e.window||n.window},this._elements={},"string"==typeof this.settings.container?this._elements.editor=this.settings.window.document.getElementById(this.settings.container):"object"===_typeof(this.settings.container)&&(this._elements.editor=this.settings.container)}return _createClass(i,null,[{key:"FULLSCREEN_CLASS",get:function(){return"markdown-editor-fullscreen"}}]),_createClass(i,[{key:"load",value:function(t){!function(t){var e=t.settings.window.document,n=e.createElement("div");n.setAttribute("class","markdown-editor-wrapper"),(t._elements.wrapper=n).innerHTML='<div class=\'markdown-editor-header btn-toolbar\'>\n <div class="btn-group markdown-editor-modes" data-toggle="buttons">\n <label class="btn btn-default active" data-me-mode="editor" title="Editor">\n <input type="radio" name="markdownEditorMode" value="Editor" checked>\n <span class="glyphicon glyphicon-pencil"></span>\n </label>\n <label class="btn btn-default" data-me-mode="preview" title="Preview">\n <input type="radio" name="markdownEditorMode" value="Preview">\n <span class="glyphicon glyphicon-eye-open"></span>\n </label>\n <label class="btn btn-default" data-me-mode="split" title="Split mode">\n <input type="radio" name="markdownEditorMode" value="Split">\n <span class="glyphicon glyphicon-adjust"></span>\n </label>\n </div>\n\n <div class=\'btn-toolbar float-left markdown-toolbar-buttons\'>\n </div>\n\n <div class=\'btn-toolbar float-right\' style=\'margin-right:5px\'>\n <div class=\'btn-group\' style=\''+(t.settings.saveContentUrl?"":"display:none")+"'>\n <button type='button' class='btn btn-primary markdowneditor-save-btn' title='Save content'>\n <span class='glyphicon glyphicon-save'></span> Save\n </button>\n </div>\n\n <div class='btn-group'>\n <button type='button' class='btn markdowneditor-fullscreen-btn' title='"+t.settings.fullscreenButtonTitle+"'>\n <span class='glyphicon glyphicon-fullscreen'></span>\n </button>\n </div>\n </div>\n </div>";var i=e.createElement("div");i.setAttribute("class","markdown-editor-row");var o=e.createElement("div");o.setAttribute("class","markdown-editor-preview");var l=e.createElement("div");l.setAttribute("class","markdown-editor-preview-content"),o.appendChild(l),t._elements.preview=l;var s=t._elements.editor.parentNode,a=t._elements.editor.nextSibling;i.appendChild(t._elements.editor),i.appendChild(o),n.appendChild(i),a?s.insertBefore(n,a):s.appendChild(n);for(var r=n.getElementsByClassName("markdown-toolbar-buttons")[0],c=t._renderButtons(t.toolbar.concat(t.settings.additionalButtons||[])),d=0;d<c.length;d++)r.appendChild(c[d])}(this),function(n){var t=n._elements.wrapper,e=n.settings.window;t.getElementsByClassName("markdowneditor-fullscreen-btn")[0].addEventListener("click",function(t){n.enterFullscreen()}),n.settings.saveContentUrl&&(saveButton=t.getElementsByClassName("markdowneditor-save-btn")[0],saveButton.addEventListener("click",function(t){var e=new XMLHttpRequest;e.open("PATCH",n.settings.saveContentUrl,!0),e.setRequestHeader("Content-Type","text/plain"),e.onreadystatechange=function(){if(e.readyState===XMLHttpRequest.DONE){(function(t){if(!("Notification"in s))return alert(t);var e=function(){new Notification(t)};"granted"===Notification.permission?e():"denied"!==Notification.permission&&Notification.requestPermission(function(t){"granted"===t&&e()})})(200===e.status?"The post has been successfully saved.":"Error: "+e.responseText)}},e.send(n.getContent())}));for(var i,o=t.querySelectorAll(".markdown-editor-modes label.btn"),l=0;l<o.length;l++)o[l].addEventListener("click",function(t){n.changeMode(t.currentTarget.getAttribute("data-me-mode"))});n._elements.editor.addEventListener("input",function(){i&&e.clearTimeout(i);i=e.setTimeout(function(){n._updatePreview()},250)})}(this),(t=t||function(){}).call(this)}},{key:"changeMode",value:function(t){this._elements.wrapper.setAttribute("data-mode",t),this._updatePreview()}},{key:"enterFullscreen",value:function(){this.isFullscreenMode()?this.exitFullscreen():(this._elements.wrapper.classList.add(i.FULLSCREEN_CLASS),this.settings.window.document.body.classList.add(i.FULLSCREEN_CLASS))}},{key:"exitFullscreen",value:function(){this._elements.wrapper.classList.remove(i.FULLSCREEN_CLASS),this.settings.window.document.body.classList.remove(i.FULLSCREEN_CLASS)}},{key:"isFullscreenMode",value:function(){return this._elements.wrapper.classList.contains(i.FULLSCREEN_CLASS)}},{key:"getContent",value:function(){return this._elements.editor.value}},{key:"getSelection",value:function(){var t=this._elements.editor,e=t.selectionEnd-t.selectionStart;return{start:t.selectionStart,end:t.selectionEnd,length:e,text:t.value.substr(t.selectionStart,e)}}},{key:"setSelection",value:function(t,e){var n=this._elements.editor;n.selectionStart=t,n.selectionEnd=e}},{key:"replaceSelection",value:function(t){var e=this._elements.editor;e.value=e.value.substr(0,e.selectionStart)+t+e.value.substr(e.selectionEnd,e.value.length),e.selectionStart=e.value.length}},{key:"_updatePreview",value:function(){var t=this.getContent(),e=this.settings.markdownToHtmlConvertor(t);this._elements.preview.innerHTML=e}},{key:"_renderButtons",value:function(t){for(var e=[],n=0;n<t.length;n++){var i=t[n],o=this._renderButtonsGroup(i);e.push(o)}return e}},{key:"_renderButtonsGroup",value:function(t){var e=this.settings.window.document,n=e.createElement("div"),i=this;n.setAttribute("class","btn-group");for(var o=0;o<t.buttons.length;o++){var l=t.buttons[o],s=e.createElement("button");if(l.action){s.setAttribute("type","button"),s.setAttribute("class","btn btn-default"),s.setAttribute("title",l.title);var a=e.createElement("span");a.setAttribute("class",l.className),s.action=l.action;s.addEventListener("click",function(e){return function(t){e(i),i._updatePreview()}}(l.action)),s.appendChild(a),n.appendChild(s)}}return n}}]),i}(),o={decorate:function(t,e,n){var i,o,l=e.length,s=t.getSelection(),a=t.getContent();i=0===s.length?n:s.text,a.substr(s.start-l,l)===e&&a.substr(s.end,l)===e?(t.setSelection(s.start-l,s.end+l),t.replaceSelection(i),o=s.start-l):(t.replaceSelection(e+i+e),o=s.start+l),t.setSelection(o,o+i.length)},prependToSelection:function(t,n,e){var i,o=t.getSelection(),l=n.length;if(0===o.length)i=e,t.replaceSelection(n+i),o.start+l;else if(o.text.indexOf("\n")<0)i=o.text,t.replaceSelection(n+i),o.start+l;else{var s=[];i=(s=o.text.split("\n"))[0],s.forEach(function(t,e){s[e]=n+t}),t.replaceSelection("\n\n"+s.join("\n")),o.start+l+2}},bold:function(t){o.decorate(t,"**","Strong text")},italic:function(t){o.decorate(t,"_","Emphasized text")},heading:function(t){},link:function(t){var e,n,i,o=t.getSelection();if(e=0===o.length?"Enter link description here":o.text,i=t.settings.window.prompt("Insert Hyperlink","http://"),null!==i&&""!==i&&"http://"!==i&&"http"===i.substr(0,4)){var l=i;t.replaceSelection("["+e+"]("+l+")"),n=o.start+1,t.setSelection(n,n+e.length)}},image:function(t){var e,n,i,o=t.getSelection();if(e=0===o.length?"Enter image description here":o.text,null!==(i=t.settings.window.prompt("Insert Image Hyperlink","http://"))&&""!==i&&"http://"!==i){var l=i;t.replaceSelection("!["+e+"]("+l+' "Enter image title here")'),n=o.start+2,t.setSelection(n,n+e.length)}},ulist:function(t){o.prependToSelection(t,"- ","List text here")},olist:function(t){o.prependToSelection(t,"1. ","List text here")},quote:function(t){o.prependToSelection(t,"> ","Quote here")},code:function(t){o.decorate(t,"```","Code block")}};s.MarkdownEditor=t}(window); |
@@ -14,5 +14,6 @@ /* | ||
container: 'MarkdownEditor', | ||
fullscreenButtonTitle: "Enter/exit fullscreen mode", | ||
previewButtonTitle: "Toggle Preview Mode", | ||
fullscreenButtonTitle: "Toggle fullscreen mode", | ||
previewButtonTitle: "Toggle preview mode", | ||
markdownToHtmlConvertor: function (markdown) { return markdown; }, | ||
saveContentUrl: null, | ||
additionalButtons: [], | ||
@@ -44,3 +45,3 @@ window: window | ||
{ title: "Blockquote", className: "glyphicon glyphicon-comment", action: toolbarActions.quote }, | ||
{ title: "Code", className: "glyphicon glyphicon-asterisk", action: null } | ||
{ title: "Code", className: "glyphicon glyphicon-asterisk", action: toolbarActions.code } | ||
] | ||
@@ -56,2 +57,3 @@ } | ||
additionalButtons: opts.additionalButtons || defaultSettings.additionalButtons, | ||
saveContentUrl: opts.saveContentUrl || defaultSettings.saveContentUrl, | ||
window: opts.window || defaultSettings.window | ||
@@ -308,3 +310,3 @@ }; | ||
code: function (e) { | ||
toolbarActions.decorate(e, "```", "Code block"); | ||
} | ||
@@ -339,8 +341,20 @@ }; | ||
<div class='btn-group'> | ||
<button type='button' class='btn btn-primary markdowneditor-fullscreen-btn' title='${self.settings.fullscreenButtonTitle}'> | ||
<span class='glyphicon glyphicon-fullscreen'></span> | ||
</button> | ||
</div></div>`; | ||
<div class='btn-toolbar float-left markdown-toolbar-buttons'> | ||
</div> | ||
<div class='btn-toolbar float-right' style='margin-right:5px'> | ||
<div class='btn-group' style='${self.settings.saveContentUrl ? '' : 'display:none'}'> | ||
<button type='button' class='btn btn-primary markdowneditor-save-btn' title='Save content'> | ||
<span class='glyphicon glyphicon-save'></span> Save | ||
</button> | ||
</div> | ||
<div class='btn-group'> | ||
<button type='button' class='btn markdowneditor-fullscreen-btn' title='${self.settings.fullscreenButtonTitle}'> | ||
<span class='glyphicon glyphicon-fullscreen'></span> | ||
</button> | ||
</div> | ||
</div> | ||
</div>`; | ||
var rowElement = document.createElement("div"); | ||
@@ -371,6 +385,6 @@ rowElement.setAttribute("class", "markdown-editor-row"); | ||
// build toolbar | ||
var toolbarElement = wrapElement.getElementsByClassName("markdown-editor-header")[0]; | ||
var toolbarButtons = wrapElement.getElementsByClassName("markdown-toolbar-buttons")[0]; | ||
var buttonGroups = self._renderButtons(self.toolbar.concat(self.settings.additionalButtons || [])); | ||
for (var i = 0; i < buttonGroups.length; i++) { | ||
toolbarElement.insertBefore(buttonGroups[i], toolbarElement.childNodes[toolbarElement.childNodes.length - 1]); | ||
toolbarButtons.appendChild(buttonGroups[i]); | ||
} | ||
@@ -389,2 +403,26 @@ } | ||
if (self.settings.saveContentUrl) { | ||
saveButton = wrapElement.getElementsByClassName("markdowneditor-save-btn")[0]; | ||
saveButton.addEventListener('click', function (e) { | ||
var xhr = new XMLHttpRequest(); | ||
xhr.open("PATCH", self.settings.saveContentUrl, true); | ||
xhr.setRequestHeader("Content-Type", "text/plain"); | ||
xhr.onreadystatechange = function () { | ||
if(xhr.readyState === XMLHttpRequest.DONE) { | ||
var message = ""; | ||
if (xhr.status === 200) { | ||
message = "The post has been successfully saved."; | ||
} else { | ||
message = `Error: ${xhr.responseText}`; | ||
} | ||
notify(message); | ||
} | ||
}; | ||
xhr.send(self.getContent()); | ||
}); | ||
} | ||
var modeElements = wrapElement.querySelectorAll(".markdown-editor-modes label.btn"); | ||
@@ -410,3 +448,31 @@ for (var i = 0; i < modeElements.length; i++) { | ||
function notify(message) { | ||
if (!("Notification" in window)) { | ||
alert(message); | ||
return; | ||
} | ||
var showNotification = function () { | ||
var notification = new Notification(message); | ||
} | ||
if (Notification.permission === "granted") { | ||
// If it's okay let's create a notification | ||
showNotification(); | ||
} | ||
// Otherwise, we need to ask the user for permission | ||
else if (Notification.permission !== 'denied') { | ||
Notification.requestPermission(function (permission) { | ||
// If the user accepts, let's create a notification | ||
if (permission === "granted") { | ||
showNotification(); | ||
} | ||
}); | ||
} | ||
// Finally, if the user has denied notifications and you | ||
// want to be respectful there is no need to bother them any more. | ||
} | ||
window.MarkdownEditor = MarkdownEditor; | ||
})(window); |
{ | ||
"name": "bootstrap-markdown-editor", | ||
"version": "2.0.5", | ||
"version": "2.2.0", | ||
"description": "Client-side markdown editor with the compatibility of any markdown render engine.", | ||
@@ -5,0 +5,0 @@ "main": "js/markdown-editor.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
36703
389