/*! * tui-editor * @version 1.3.3 * @author NHN Ent. FE Development Lab (https://nhnent.github.io/tui.editor/) * @license MIT */ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("jquery"),require("tui-code-snippet"),function(){try{return require("tui-editor")}catch(e){}}(),function(){try{return require("tui-editor/dist/tui-editor-Viewer")}catch(e){}}());else if("function"==typeof define&&define.amd)define(["jquery","tui-code-snippet","tui-editor","tui-editor/dist/tui-editor-Viewer"],t);else{var i="object"==typeof exports?t(require("jquery"),require("tui-code-snippet"),function(){try{return require("tui-editor")}catch(e){}}(),function(){try{return require("tui-editor/dist/tui-editor-Viewer")}catch(e){}}()):t(e.$,e.tui&&e.tui.util,e.tui&&e.tui.Editor,e.tui&&e.tui.Editor);for(var n in i)("object"==typeof exports?exports:e)[n]=i[n]}}("undefined"!=typeof self?self:this,function(e,t,i,n){return function(e){function t(n){if(i[n])return i[n].exports;var o=i[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var i={};return t.m=e,t.c=i,t.d=function(e,i,n){t.o(e,i)||Object.defineProperty(e,i,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var i=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(i,"a",i),i},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="dist/",t(t.s=46)}({0:function(t,i){t.exports=e},1:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=void 0;try{n=i(4)}catch(e){}if(!n)try{n=i(5)}catch(e){}t.default=n},2:function(e,i){e.exports=t},4:function(e,t){if(void 0===i){var n=new Error('Cannot find module "undefined"');throw n.code="MODULE_NOT_FOUND",n}e.exports=i},46:function(e,t,i){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e){function t(){"vertical"===e.mdPreviewStyle&&"markdown"===e.currentMode?(d.$el.show(),h.show()):(d.$el.hide(),h.hide())}var i=e.i18n,n={active:i.get("Auto scroll enabled"),inactive:i.get("Auto scroll disabled")};if(!e.isViewer()){var o=e.getCodeMirror(),r=new f.default(o,e.preview),s=new u.default(r,o,e.preview.$el),l=!1,a=!0,d=void 0,h=void 0;if("default"===e.getUI().name){var v=e.getUI().getToolbar();v.addItem("divider"),v.addItem({type:"button",options:{className:"tui-scrollsync",command:"scrollSyncToggle",tooltip:n.active,$el:(0,c.default)('')}});var p=v.getItems();h=p[p.length-2].$el,d=p[p.length-1],t(),e.on("changeMode",t),e.on("changePreviewStyle",t),e.addCommand("markdown",{name:"scrollSyncToggle",exec:function(){a=!a,d._onOut(),a?(d.$el.addClass("active"),d.setTooltip(n.active)):(d.$el.removeClass("active"),d.setTooltip(n.inactive)),d._onOver()}})}o.on("change",function(){l=!1,r.makeSectionList()}),e.on("previewRenderAfter",function(){r.sectionMatch(),a&&s.syncPreviewScrollTopToMarkdown(),l=!0}),e.eventManager.listen("scroll",function(t){a&&(l&&e.preview.isVisible()?"markdown"!==t.source||s.isMarkdownScrollEventBlocked?"preview"!==t.source||s.isPreviewScrollEventBlocked||s.syncMarkdownScrollTopToPreview():s.syncPreviewScrollTopToMarkdown():s.saveScrollInfo())})}}Object.defineProperty(t,"__esModule",{value:!0});var r=i(0),c=n(r),s=i(1),l=n(s),a=i(47),u=n(a),d=i(48),f=n(d);l.default.defineExtension("scrollSync",o),t.default=o},47:function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var i=0;i0?e.start-1:0,"local")}},{key:"_getEditorLineHeightGapInSection",value:function(e,t){var i=this.cm.heightAtLine(t,"local");return i-=this.cm.heightAtLine(e.start>0?e.start-1:0,"local"),Math.max(i,0)}},{key:"_getEditorSectionScrollRatio",value:function(e,t){var i=e.end===e.start;return i?0:this._getEditorLineHeightGapInSection(e,t)/this._getEditorSectionHeight(e)}},{key:"_getScrollFactorsOfEditor",value:function(){var e=this.cm,t=e.getScrollInfo(),i=void 0,n=void 0,o=void 0,r=void 0;t=this._fallbackScrollInfoIfIncorrect(t);var c=t.height-t.top<=t.clientHeight;return c?r={isEditorBottom:c}:(i=e.coordsChar({left:t.left,top:t.top},"local").line,n=this.sectionManager.sectionByLine(i),o=this._getEditorSectionScrollRatio(n,i),r={section:n,sectionRatio:o}),r}},{key:"_getScrollInfoForMarkdown",value:function(){var e=this,t=this.sectionManager.getSectionList(),i=void 0;return c.default.forEachArray(t,function(t){var n=t.$previewSectionEl,o=n.parent().parent(),r=o[0].clientHeight-o.scrollTop()<=o[0].height,c=!0;return r?(i={isPreviewBottom:r},c=!1):e._isTopSection(o,n)&&(i={section:t,sectionRatio:e._getMarkdownEditorScrollRatio(o,n)},c=!1),c}),i}},{key:"_getMarkdownEditorScrollRatio",value:function(e,t){return(e.scrollTop()-t[0].offsetTop)/t.height()}},{key:"_getScrollTopForPreview",value:function(){var e=void 0,t=this._getScrollFactorsOfEditor(),i=t.section,n=t.sectionRatio;return t.isEditorBottom?e=this.$contents.height():i.$previewSectionEl&&(e=i.$previewSectionEl[0].offsetTop,e+=i.$previewSectionEl.height()*n-20),e=e&&Math.max(e,0)}},{key:"_getScrollTopForMarkdown",value:function(){var e=void 0,t=this._getScrollInfoForMarkdown(),i=t.sectionRatio;if(t.isPreviewBottom)e=this.cm.getScrollInfo().height;else if(t.section){var n=t.section,o=this.cm.charCoords({line:n.start,char:0},"local"),r=this.cm.charCoords({line:n.end,char:0},"local");e=o.top,e+=(r.top-o.top)*i}return e=e&&Math.max(e,0)}},{key:"syncPreviewScrollTopToMarkdown",value:function(){var e=this,t=this.$previewContainerEl,i=t.scrollTop(),n=this._getScrollTopForPreview();this.isPreviewScrollEventBlocked=!0,this._animateRun(i,n,function(i){clearTimeout(e.releaseTimer),t.scrollTop(i),e.releaseTimer=setTimeout(function(){e.isPreviewScrollEventBlocked=!1},15)})}},{key:"syncMarkdownScrollTopToPreview",value:function(){var e=this,t=this.cm,i=t.getScrollInfo(),n=i.top,o=this._getScrollTopForMarkdown();this.isMarkdownScrollEventBlocked=!0,this._animateRun(n,o,function(i){clearTimeout(e.releaseTimer),t.scrollTo(0,i),e.releaseTimer=setTimeout(function(){e.isMarkdownScrollEventBlocked=!1},15)})}},{key:"_animateRun",value:function(e,t,i){function n(){var s=Date.now(),l=(s-r)/200,a=void 0;l<1?(a=e+o*Math.cos((1-l)*Math.PI/2),i(Math.ceil(a)),c._currentTimeoutId=setTimeout(n,1)):(i(t),c._currentTimeoutId=null)}var o=t-e,r=Date.now(),c=this;this._currentTimeoutId&&clearTimeout(this._currentTimeoutId),n()}},{key:"_fallbackScrollInfoIfIncorrect",value:function(e){return e.height<0&&this._savedScrollInfo?this._savedScrollInfo:e}},{key:"saveScrollInfo",value:function(){this._savedScrollInfo=this.cm.getScrollInfo()}},{key:"_isTopSection",value:function(e,t){var i=e.scrollTop(),n=t[0].offsetTop,o=t.height(),r=i>=n-57,c=i>n+o;return r&&!c}}]),e}();t.default=s},48:function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(){return this.nodeType===Node.ELEMENT_NODE}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var i=0;i ?)+\s/,d=/^ {0,3}!\[([^[\]]*)]\(([^)]*)\)/,f=/^ *(?:={1,}|-{1,})\s*$/,h=/^ *(`{3,}|~{3,})[ ]*$/,v=/^ *(`{3,}|~{3,})[ .]*(\S+)? */,p=/\s/g,_=function(){function e(t,i){n(this,e),this.cm=t,this.preview=i,this.$previewContent=i.$el.find(".tui-editor-contents"),this._sectionList=null,this._currentSection=null}return r(e,[{key:"_addNewSection",value:function(e,t){var i=this._makeSectionData(e,t);this._sectionList.push(i),this._currentSection=i}},{key:"getSectionList",value:function(){return this._sectionList||this.makeSectionList(),this._sectionList}},{key:"_makeSectionData",value:function(e,t){return{start:e,end:t,$previewSectionEl:null}}},{key:"_updateCurrentSectionEnd",value:function(e){this._currentSection.end=e}},{key:"_eachLineState",value:function(e){var t=void 0,i=void 0,n=void 0,o=void 0,r=void 0,c=!0,s=!1,l=!1,a="",u=!1,d=!1,f=void 0,h=this.cm.getDoc().lineCount();for(i=0;i");n.$previewSectionEl=(0,s.default)(e).wrapAll(o).parent()}})}},{key:"_getPreviewSections",value:function(){var e=[],t=0,i=!1;return e[0]=[],this.$previewContent.contents().filter(o).each(function(n,o){var r="P"===o.tagName,c=o.tagName.match(/^(H1|H2|H3|H4|H5|H6)$/),s=r&&"IMG"===o.childNodes[0].nodeName;(c||s||i)&&e[t].length&&(e.push([]),t+=1,i=!1),s&&(i=!0),e[t].push(o)}),e}},{key:"sectionByLine",value:function(e){var t=void 0,i=this.getSectionList(),n=i.length;for(t=0;t