@kangc/v-md-editor
Version:
A markdown editor built on Vue
1 lines • 5.05 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("VMdEditor",[],e):"object"==typeof exports?exports.VMdEditor=e():t.VMdEditor=e()}("undefined"!=typeof self?self:this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=112)}({112:function(t,e,n){"use strict";n.r(e);var r=function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"v-md-editor-preview",style:{tabSize:this.tabSize,"-moz-tab-size":this.tabSize,"-o-tab-size":this.tabSize},on:{click:this.handlePreviewClick}},[e("div",{class:[this.previewClass],domProps:{innerHTML:this._s(this.html)}})])};r._withStripped=!0;var o={name:"v-md-preview-html",mixins:[n(18).a],props:{html:{type:String,default:""},previewClass:String}},i=n(2),c=Object(i.a)(o,r,[],!1,null,null,null);c.options.__file="src/preview-html.vue";var l=c.exports;n(19);l.version="1.7.12",l.install=function(t){t.component(l.name,l)},l.use=function(t,e){return"function"==typeof t?t(l,e):t.install(l,e),l};e.default=l},18:function(t,e,n){"use strict";var r=n(6),o=n(8),i=n(3);e.a={props:{scrollContainer:{type:Function,default:function(){return window}},top:{type:Number,default:0},tabSize:{type:Number,default:2}},methods:{handlePreviewClick:function(t){var e=t.target;if("IMG"!==e.tagName){var n=e.getAttribute(i.a),r=this.$el.querySelector("["+i.b+'="'+n+'"]');r&&this.scrollToTarget({target:r})}else{if(!e.getAttribute("src"))return;var o=Array.from(this.$el.querySelectorAll("img")),c=o.map((function(t){return t.getAttribute("src")})).filter((function(t){return t})),l=o.indexOf(e);this.$emit("image-click",c,l)}},getOffsetTop:function(t,e){var n=t.getBoundingClientRect();return e===window||e===document.documentElement?n.top:n.top-e.getBoundingClientRect().top},scrollToTarget:function(t){var e=t.target,n=t.scrollContainer,i=void 0===n?this.scrollContainer():n,c=t.top,l=void 0===c?this.top:c,u=t.onScrollEnd,s=this.getOffsetTop(e,i),a=Object(r.a)(i)+s-l;Object(o.a)({scrollTarget:i,scrollToTop:a,onScrollEnd:u})},scrollToLine:function(t){var e=t.lineIndex,n=t.onScrollEnd;if(e){var r=this.$el.querySelector("["+i.c+'="'+e+'"]');r&&this.scrollToTarget({target:r,onScrollEnd:n})}}}}},19:function(t,e,n){},2:function(t,e,n){"use strict";function r(t,e,n,r,o,i,c,l){var u,s="function"==typeof t?t.options:t;if(e&&(s.render=e,s.staticRenderFns=n,s._compiled=!0),r&&(s.functional=!0),i&&(s._scopeId="data-v-"+i),c?(u=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),o&&o.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(c)},s._ssrRegister=u):o&&(u=l?function(){o.call(this,this.$root.$options.shadowRoot)}:o),u)if(s.functional){s._injectStyles=u;var a=s.render;s.render=function(t,e){return u.call(e),a(t,e)}}else{var d=s.beforeCreate;s.beforeCreate=d?[].concat(d,u):[u]}return{exports:t,options:s}}n.d(e,"a",(function(){return r}))},3:function(t,e,n){"use strict";n.d(e,"c",(function(){return r})),n.d(e,"b",(function(){return o})),n.d(e,"a",(function(){return i}));var r="data-v-md-line",o="data-v-md-heading",i="data-v-md-anchor"},6:function(t,e,n){"use strict";function r(t){var e=0;return t===window?e=t.pageYOffset:t&&(e=t.scrollTop),e}function o(t,e){t===window?window.scrollTo(window.pageYOffset,e):t&&(t.scrollTop=e)}n.d(e,"a",(function(){return r})),n.d(e,"b",(function(){return o}))},8:function(t,e,n){"use strict";n.d(e,"b",(function(){return o})),n.d(e,"a",(function(){return i}));var r=n(6);function o(t){var e=t.currentScrollTop,n=t.scrollToTop,r=t.scrollFn,o=t.percent,i=void 0===o?10:o,c=t.onScrollEnd,l=n>e?"down":"up",u=i/100*(n-e);window.requestAnimationFrame((function t(){e+=u,"down"===l&&e>=n||"up"===l&&e<=n?(r(n),window.cancelAnimationFrame(void 0),c&&window.requestAnimationFrame(c)):(r(e),window.requestAnimationFrame(t))}))}function i(t){var e=t.scrollTarget,n=t.scrollToTop,i=t.percent,c=void 0===i?10:i,l=t.onScrollEnd;o({currentScrollTop:Object(r.a)(e),scrollToTop:n,scrollFn:function(t){return Object(r.b)(e,t)},percent:c,onScrollEnd:l})}}}).default}));