v-md-editor
Version:
A markdown editor built on Vue
1,519 lines (1,361 loc) • 946 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("vue"));
else if(typeof define === 'function' && define.amd)
define("VMdEditor", ["vue"], factory);
else if(typeof exports === 'object')
exports["VMdEditor"] = factory(require("vue"));
else
root["VMdEditor"] = factory(root["Vue"]);
})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE__0__) {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 132);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE__0__;
/***/ }),
/* 1 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return bold; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return clear; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return code; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return codeCpp; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return codePython; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return codeInline; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return fullscreen; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return h1; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return h2; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return h3; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return h4; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return h5; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return h6; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return hr; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return image; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "s", function() { return italic; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "t", function() { return link; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "v", function() { return ol; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "w", function() { return quote; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "x", function() { return redo; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "y", function() { return strikethrough; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "z", function() { return syncScroll; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "A", function() { return table; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "B", function() { return ul; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "C", function() { return undo; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "D", function() { return wrap; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return formula; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return inlineFormula; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "r", function() { return insert; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "u", function() { return more; });
var bold = 'bold';
var clear = 'clear';
var code = 'code';
var codeCpp = 'codeCpp';
var codePython = 'codePython';
var codeInline = 'codeInline';
var fullscreen = 'fullscreen';
var h1 = 'h1';
var h2 = 'h2';
var h3 = 'h3';
var h4 = 'h4';
var h5 = 'h5';
var h6 = 'h6';
var hr = 'hr';
var image = 'image';
var italic = 'italic';
var link = 'link';
var ol = 'ol';
var quote = 'quote';
var redo = 'redo';
var strikethrough = 'strikethrough';
var syncScroll = 'sync-scroll';
var table = 'table';
var ul = 'ul';
var undo = 'undo';
var wrap = 'wrap';
var formula = 'formula';
var inlineFormula = 'inlineFormula';
var insert = 'insert';
var more = 'more';
/***/ }),
/* 2 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return isObject; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return arraytoObject; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return importAll; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return inBrowser; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return isKorean; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return generatorText; });
var toString = Object.prototype.toString;
var isObject = function isObject(target) {
return toString.call(target) === '[object Object]';
};
function extend(to, _from) {
Object.keys(_from).forEach(function (key) {
to[key] = _from[key];
});
return to;
}
function arraytoObject(arr) {
var res = {};
for (var i = 0; i < arr.length; i++) {
if (arr[i]) {
extend(res, arr[i]);
}
}
return res;
}
function importAll(map, r) {
r.keys().forEach(function (filePath) {
map[filePath] = r(filePath);
});
}
var inBrowser = typeof window !== 'undefined';
function isKorean(text) {
var reg = /([(\uAC00-\uD7AF)|(\u3130-\u318F)])+/gi;
return reg.test(text);
}
function generatorText(_ref) {
var selected = _ref.selected,
InsertGetter = _ref.InsertGetter,
_ref$selectedGetter = _ref.selectedGetter,
selectedGetter = _ref$selectedGetter === void 0 ? function (selected) {
return selected;
} : _ref$selectedGetter,
_ref$ignoreEmptyLine = _ref.ignoreEmptyLine,
ignoreEmptyLine = _ref$ignoreEmptyLine === void 0 ? true : _ref$ignoreEmptyLine;
var insertContent;
var newSelected;
if (selected) {
newSelected = selectedGetter(selected);
insertContent = InsertGetter(selected, 1);
// 如果当前选中的文本包含换行 则插入后选中插入的所有文本
if (selected.indexOf('\n') !== -1) {
insertContent = selected.split('\n').map(function (rowText, index) {
var isEmptyLine = !rowText;
if (ignoreEmptyLine && isEmptyLine) return '';
return InsertGetter(rowText, index + 1).replace(selectedGetter(null), '');
}).join('\n');
newSelected = insertContent;
}
} else {
insertContent = InsertGetter(null, 1);
newSelected = selectedGetter(selected);
}
return {
insertContent: insertContent,
newSelected: newSelected
};
}
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// runtime helper for setting properties on components
// in a tree-shakable way
exports.default = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
};
/***/ }),
/* 4 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return LINE_MARKUP; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return HEADING_MARKUP; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ANCHOR_MARKUP; });
var LINE_MARKUP = 'data-v-md-line';
var HEADING_MARKUP = 'data-v-md-heading';
var ANCHOR_MARKUP = 'data-v-md-anchor';
/***/ }),
/* 5 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = ({
PREVIEW: 'preview',
EDITABLE: 'editable',
EDIT: 'edit'
});
/***/ }),
/* 6 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return addResizeListener; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return removeResizeListener; });
/* harmony import */ var resize_observer_polyfill__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(22);
// Modified from https://github.com/ElemeFE/element/blob/dev/src/utils/resize-event.js
/* eslint-disable no-underscore-dangle */
var isServer = typeof window === 'undefined';
/* istanbul ignore next */
var resizeHandler = function resizeHandler(entries) {
entries.forEach(function (entry) {
var listeners = entry.target.__resizeListeners__ || [];
if (listeners.length) {
listeners.forEach(function (fn) {
fn();
});
}
});
};
/* istanbul ignore next */
var addResizeListener = function addResizeListener(element, fn) {
if (isServer) return;
if (!element.__resizeListeners__) {
element.__resizeListeners__ = [];
element.__ro__ = new resize_observer_polyfill__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"](resizeHandler);
element.__ro__.observe(element);
}
element.__resizeListeners__.push(fn);
};
/* istanbul ignore next */
var removeResizeListener = function removeResizeListener(element, fn) {
if (!element || !element.__resizeListeners__) return;
element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1);
if (!element.__resizeListeners__.length) {
element.__ro__.disconnect();
}
};
/***/ }),
/* 7 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; });
function _extends() {
_extends = Object.assign ? Object.assign.bind() : function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
/***/ }),
/* 8 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return getScrollTop; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return scrollTo; });
function getScrollTop(target) {
var result = 0;
if (target === window) {
result = target.pageYOffset;
} else if (target) {
result = target.scrollTop;
}
return result;
}
function scrollTo(target, scrollTop) {
if (target === window) {
window.scrollTo(window.pageYOffset, scrollTop);
} else if (target) {
target.scrollTop = scrollTop;
}
}
/***/ }),
/* 9 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return smooth; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return smoothScroll; });
/* harmony import */ var _scroll_top__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
function smooth(_ref) {
var currentScrollTop = _ref.currentScrollTop,
scrollToTop = _ref.scrollToTop,
scrollFn = _ref.scrollFn,
_ref$percent = _ref.percent,
percent = _ref$percent === void 0 ? 10 : _ref$percent,
onScrollEnd = _ref.onScrollEnd;
var scrollWay = scrollToTop > currentScrollTop ? 'down' : 'up';
var step = (scrollToTop - currentScrollTop) * (percent / 100);
var id;
var scroll = function scroll() {
currentScrollTop += step;
if (scrollWay === 'down' && currentScrollTop >= scrollToTop || scrollWay === 'up' && currentScrollTop <= scrollToTop) {
scrollFn(scrollToTop);
window.cancelAnimationFrame(id);
if (onScrollEnd) window.requestAnimationFrame(onScrollEnd);
} else {
scrollFn(currentScrollTop);
window.requestAnimationFrame(scroll);
}
};
window.requestAnimationFrame(scroll);
}
function smoothScroll(_ref2) {
var scrollTarget = _ref2.scrollTarget,
scrollToTop = _ref2.scrollToTop,
_ref2$percent = _ref2.percent,
percent = _ref2$percent === void 0 ? 10 : _ref2$percent,
onScrollEnd = _ref2.onScrollEnd;
var currentScrollTop = Object(_scroll_top__WEBPACK_IMPORTED_MODULE_0__[/* getScrollTop */ "a"])(scrollTarget);
smooth({
currentScrollTop: currentScrollTop,
scrollToTop: scrollToTop,
scrollFn: function scrollFn(scrollTop) {
return Object(_scroll_top__WEBPACK_IMPORTED_MODULE_0__[/* scrollTo */ "b"])(scrollTarget, scrollTop);
},
percent: percent,
onScrollEnd: onScrollEnd
});
}
/***/ }),
/* 10 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// EXTERNAL MODULE: external {"root":"Vue","commonjs":"vue","commonjs2":"vue","amd":"vue"}
var external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_ = __webpack_require__(0);
// EXTERNAL MODULE: ./src/utils/resize-event.js
var resize_event = __webpack_require__(6);
// CONCATENATED MODULE: ./src/utils/scrollbar-width.js
// Modified from https://github.com/ElemeFE/element/blob/dev/src/utils/scrollbar-width.js
var scrollBarWidth;
var isServer = typeof window === 'undefined';
/* harmony default export */ var scrollbar_width = (function () {
if (isServer) return 0;
if (scrollBarWidth !== undefined) return scrollBarWidth;
var outer = document.createElement('div');
outer.className = 'scrollbar__wrap';
outer.style.visibility = 'hidden';
outer.style.width = '100px';
outer.style.position = 'absolute';
outer.style.top = '-9999px';
document.body.appendChild(outer);
var widthNoScroll = outer.offsetWidth;
outer.style.overflow = 'scroll';
var inner = document.createElement('div');
inner.style.width = '100%';
outer.appendChild(inner);
var widthWithScroll = inner.offsetWidth;
outer.parentNode.removeChild(outer);
scrollBarWidth = widthNoScroll - widthWithScroll;
return scrollBarWidth;
});
// EXTERNAL MODULE: ./src/utils/util.js
var util = __webpack_require__(2);
// CONCATENATED MODULE: ./src/components/scrollbar/util.js
// Modified from https://github.com/ElemeFE/element/tree/dev/packages/scrollbar
var BAR_MAP = {
vertical: {
offset: 'offsetHeight',
scroll: 'scrollTop',
scrollSize: 'scrollHeight',
size: 'height',
key: 'vertical',
axis: 'Y',
client: 'clientY',
direction: 'top'
},
horizontal: {
offset: 'offsetWidth',
scroll: 'scrollLeft',
scrollSize: 'scrollWidth',
size: 'width',
key: 'horizontal',
axis: 'X',
client: 'clientX',
direction: 'left'
}
};
function renderThumbStyle(_ref) {
var move = _ref.move,
size = _ref.size,
bar = _ref.bar;
var style = {};
var translate = "translate" + bar.axis + "(" + move + "%)";
style[bar.size] = size;
style.transform = translate;
style.msTransform = translate;
style.webkitTransform = translate;
return style;
}
// CONCATENATED MODULE: ./src/components/scrollbar/bar.js
// Modified from https://github.com/ElemeFE/element/tree/dev/packages/scrollbar
/* istanbul ignore next */
/* harmony default export */ var scrollbar_bar = ({
name: 'Bar',
props: {
vertical: Boolean,
size: String,
move: Number
},
computed: {
bar: function bar() {
return BAR_MAP[this.vertical ? 'vertical' : 'horizontal'];
},
wrap: function wrap() {
return this.$parent.wrap;
}
},
render: function render() {
var size = this.size,
move = this.move,
bar = this.bar;
return Object(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_["createVNode"])("div", {
"class": ['scrollbar__bar', 'is-' + bar.key],
"onMousedown": this.clickTrackHandler,
"onClick": function onClick(e) {
return e.stopPropagation();
}
}, [Object(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_["createVNode"])("div", {
"ref": "thumb",
"class": "scrollbar__thumb",
"onMousedown": this.clickThumbHandler,
"style": renderThumbStyle({
size: size,
move: move,
bar: bar
})
}, null)]);
},
methods: {
clickThumbHandler: function clickThumbHandler(e) {
// prevent click event of right button
if (e.ctrlKey || e.button === 2) {
return;
}
this.startDrag(e);
this[this.bar.axis] = e.currentTarget[this.bar.offset] - (e[this.bar.client] - e.currentTarget.getBoundingClientRect()[this.bar.direction]);
},
clickTrackHandler: function clickTrackHandler(e) {
var offset = Math.abs(e.target.getBoundingClientRect()[this.bar.direction] - e[this.bar.client]);
var thumbHalf = this.$refs.thumb[this.bar.offset] / 2;
var thumbPositionPercentage = (offset - thumbHalf) * 100 / this.$el[this.bar.offset];
this.wrap[this.bar.scroll] = thumbPositionPercentage * this.wrap[this.bar.scrollSize] / 100;
},
startDrag: function startDrag(e) {
e.stopImmediatePropagation();
this.cursorDown = true;
document.addEventListener('mousemove', this.mouseMoveDocumentHandler, false);
document.addEventListener('mouseup', this.mouseUpDocumentHandler, false);
document.onselectstart = function () {
return false;
};
},
mouseMoveDocumentHandler: function mouseMoveDocumentHandler(e) {
if (this.cursorDown === false) return;
var prevPage = this[this.bar.axis];
if (!prevPage) return;
var offset = (this.$el.getBoundingClientRect()[this.bar.direction] - e[this.bar.client]) * -1;
var thumbClickPosition = this.$refs.thumb[this.bar.offset] - prevPage;
var thumbPositionPercentage = (offset - thumbClickPosition) * 100 / this.$el[this.bar.offset];
this.wrap[this.bar.scroll] = thumbPositionPercentage * this.wrap[this.bar.scrollSize] / 100;
},
mouseUpDocumentHandler: function mouseUpDocumentHandler() {
this.cursorDown = false;
this[this.bar.axis] = 0;
document.removeEventListener('mousemove', this.mouseMoveDocumentHandler, false);
document.onselectstart = null;
}
},
unmounted: function unmounted() {
document.removeEventListener('mouseup', this.mouseUpDocumentHandler, false);
}
});
// EXTERNAL MODULE: ./src/utils/smooth-scroll.js
var smooth_scroll = __webpack_require__(9);
// CONCATENATED MODULE: ./node_modules/babel-loader/lib??ref--3!./node_modules/vue-loader/dist??ref--2-0!./src/components/scrollbar/index.vue?vue&type=script&lang=js
// Modified from https://github.com/ElemeFE/element/tree/dev/packages/scrollbar
/* harmony default export */ var scrollbarvue_type_script_lang_js = ({
name: 'scrollbar',
components: {
Bar: scrollbar_bar
},
props: {
native: Boolean,
disabled: Boolean,
wrapStyle: null,
wrapClass: null,
viewClass: null,
viewStyle: null,
noresize: Boolean,
// 如果 container 尺寸不会发生变化,最好设置它可以优化性能
tag: {
type: String,
default: 'div'
}
},
emits: ['scroll'],
data: function data() {
return {
sizeWidth: '0',
sizeHeight: '0',
moveX: 0,
moveY: 0
};
},
computed: {
wrap: function wrap() {
return this.$refs.wrap;
}
},
mounted: function mounted() {
if (this.native || this.disabled) return;
this.$nextTick(this.update);
!this.noresize && Object(resize_event["a" /* addResizeListener */])(this.$refs.resize, this.update);
},
beforeUnmount: function beforeUnmount() {
if (this.native || this.disabled) return;
!this.noresize && Object(resize_event["b" /* removeResizeListener */])(this.$refs.resize, this.update);
},
methods: {
getScrollInfo: function getScrollInfo() {
var wrap = this.wrap;
return {
left: wrap.scrollLeft,
top: wrap.scrollTop,
width: wrap.scrollWidth,
height: wrap.scrollHeight,
clientWidth: wrap.clientWidth,
clientHeight: wrap.clientHeight
};
},
scrollTo: function scrollTo(scrollTop) {
Object(smooth_scroll["a" /* default */])({
scrollTarget: this.wrap,
scrollToTop: scrollTop
});
},
handleScroll: function handleScroll() {
var wrap = this.wrap;
this.moveY = wrap.scrollTop * 100 / wrap.clientHeight;
this.moveX = wrap.scrollLeft * 100 / wrap.clientWidth;
this.$emit('scroll');
},
update: function update() {
var wrap = this.wrap;
if (!wrap) return;
var heightPercentage = wrap.clientHeight * 100 / wrap.scrollHeight;
var widthPercentage = wrap.clientWidth * 100 / wrap.scrollWidth;
this.sizeHeight = heightPercentage < 100 ? heightPercentage + '%' : '';
this.sizeWidth = widthPercentage < 100 ? widthPercentage + '%' : '';
}
},
render: function render() {
if (this.disabled) return this.$slots.default();
var gutter = scrollbar_width();
var style = this.wrapStyle;
if (gutter) {
var scrollView = this.$refs.resize;
var wrapper = this.$refs.wrap;
var scrollViewHeight = scrollView == null ? void 0 : scrollView.scrollHeight;
var scrollViewWidth = scrollView == null ? void 0 : scrollView.scrollWidth;
var wrapperHeight = wrapper == null ? void 0 : wrapper.clientHeight;
var wrapperWidth = wrapper == null ? void 0 : wrapper.clientWidth;
var gutterWith = "-" + gutter + "px";
var marginBottom = scrollViewWidth > wrapperWidth ? gutterWith : 0;
var marginRight = scrollViewHeight > wrapperHeight ? gutterWith : 0;
var gutterStyle = "margin-bottom: " + marginBottom + "; margin-right: " + marginRight + ";";
if (Array.isArray(this.wrapStyle)) {
style = Object(util["a" /* arraytoObject */])(this.wrapStyle);
style.marginRight = gutterWith;
style.marginBottom = gutterWith;
} else if (typeof this.wrapStyle === 'string') {
style += gutterStyle;
} else {
style = gutterStyle;
}
}
var view = Object(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_["h"])(this.tag, {
class: ['scrollbar__view', this.viewClass],
style: this.viewStyle,
ref: 'resize'
}, this.$slots.default());
var wrap = Object(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_["createVNode"])("div", {
"ref": "wrap",
"style": style,
"onScroll": this.handleScroll,
"class": [this.wrapClass, 'scrollbar__wrap', gutter ? '' : 'scrollbar__wrap--hidden-default']
}, [[view]]);
var nodes;
if (!this.native) {
nodes = [wrap, Object(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_["createVNode"])(scrollbar_bar, {
"move": this.moveX,
"size": this.sizeWidth
}, null), Object(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_["createVNode"])(scrollbar_bar, {
"vertical": true,
"move": this.moveY,
"size": this.sizeHeight
}, null)];
} else {
nodes = [Object(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_["createVNode"])("div", {
"ref": "wrap",
"class": [this.wrapClass, 'scrollbar__wrap'],
"style": style
}, [[view]])];
}
return Object(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_["h"])('div', {
class: 'scrollbar'
}, nodes);
}
});
// CONCATENATED MODULE: ./src/components/scrollbar/index.vue?vue&type=script&lang=js
// EXTERNAL MODULE: ./src/components/scrollbar/index.vue?vue&type=style&index=0&id=887b7bde&lang=scss
var scrollbarvue_type_style_index_0_id_887b7bde_lang_scss = __webpack_require__(32);
// CONCATENATED MODULE: ./src/components/scrollbar/index.vue
const __exports__ = scrollbarvue_type_script_lang_js;
/* harmony default export */ var scrollbar = __webpack_exports__["a"] = (__exports__);
/***/ }),
/* 11 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
var esm_extends = __webpack_require__(7);
// EXTERNAL MODULE: ./node_modules/xss/lib/index.js
var lib = __webpack_require__(14);
var lib_default = /*#__PURE__*/__webpack_require__.n(lib);
// CONCATENATED MODULE: ./src/utils/xss/svg.js
/* harmony default export */ var svg = ({
svg: [],
altGlyph: [],
altGlyphDef: [],
altGlyphItem: [],
animate: [],
animateColor: [],
animateMotion: [],
animateTransform: [],
circle: [],
clipPath: [],
'color-profile': [],
cursor: [],
'definition-src': [],
defs: [],
desc: [],
ellipse: [],
feBlend: [],
feColorMatrix: [],
feComponentTransfer: [],
feComposite: [],
feConvolveMatrix: [],
feDiffuseLighting: [],
feDisplacementMap: [],
feDistantLight: [],
feFlood: [],
feFuncA: [],
feFuncB: [],
feFuncG: [],
feFuncR: [],
feGaussianBlur: [],
feImage: [],
feMerge: [],
feMergeNode: [],
feMorphology: [],
feOffset: [],
fePointLight: [],
feSpecularLighting: [],
feSpotLight: [],
feTile: [],
feTurbulence: [],
filter: [],
font: [],
foreignObject: [],
g: [],
glyph: [],
glyphRef: [],
hkern: [],
image: [],
line: [],
linearGradient: [],
marker: [],
mask: [],
metadata: [],
'missing-glyph': [],
mpath: [],
path: [],
pattern: [],
polygon: [],
polyline: [],
radialGradient: [],
rect: [],
set: [],
stop: [],
style: [],
switch: [],
symbol: [],
text: [],
textPath: [],
title: [],
tref: [],
tspan: [],
use: [],
view: [],
vkern: []
});
// CONCATENATED MODULE: ./src/utils/xss/KaTex.js
/* harmony default export */ var KaTex = ({
math: [],
annotation: [],
semantics: [],
mtext: [],
mn: [],
mo: [],
mi: [],
mspace: [],
mover: [],
munder: [],
munderover: [],
msup: [],
msub: [],
msubsup: [],
mfrac: [],
mroot: [],
msqrt: [],
mtable: [],
mtr: [],
mtd: [],
mlabeledtr: [],
mrow: [],
menclose: [],
mstyle: [],
mpadded: [],
mphantom: [],
mglyph: []
});
// CONCATENATED MODULE: ./src/utils/xss/common.js
var attrWhiteList = ['style', 'align', 'class', 'id', 'title'];
var prefixAttrWhiteList = ['data-'];
var tags = {
input: ['type'],
ol: ['reversed', 'start', 'type'],
button: ['type'],
summary: []
};
// CONCATENATED MODULE: ./src/utils/xss/index.js
var tagWhiteList = Object(esm_extends["a" /* default */])({}, tags, KaTex, svg);
var options = {
whiteList: Object(esm_extends["a" /* default */])({}, lib_default.a.getDefaultWhiteList(), tagWhiteList),
onIgnoreTagAttr: function onIgnoreTagAttr(tag, name, value) {
if (svg[tag] || KaTex[tag] || attrWhiteList.find(function (attr) {
return attr === name;
}) || prefixAttrWhiteList.find(function (prefix) {
return name.startsWith(prefix);
})) {
return name + "=\"" + lib_default.a.escapeAttrValue(value) + "\"";
}
}
};
var xssFilterInstance = new lib_default.a.FilterXSS(options);
xssFilterInstance.extend = function (extendOptions) {
var instanceOptions = xssFilterInstance.options;
Object.keys(extendOptions).forEach(function (optionName) {
// extend whiteList
if (optionName === 'whiteList') {
Object.keys(extendOptions.whiteList).forEach(function (tagName) {
var tagAttrWhiteList = extendOptions.whiteList[tagName];
var instanceWhiteList = instanceOptions.whiteList;
if (instanceWhiteList[tagName]) {
instanceWhiteList[tagName] = [].concat(instanceWhiteList[tagName], tagAttrWhiteList);
} else {
instanceWhiteList[tagName] = tagAttrWhiteList;
}
});
} else if (optionName === 'onIgnoreTagAttr') {
var oldHandler = instanceOptions.onIgnoreTagAttr;
instanceOptions.onIgnoreTagAttr = function () {
var _extendOptions$onIgno;
for (var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++) {
arg[_key] = arguments[_key];
}
var oldReturnVal = oldHandler.call.apply(oldHandler, [this].concat(arg));
var newReturnVal = (_extendOptions$onIgno = extendOptions.onIgnoreTagAttr).call.apply(_extendOptions$onIgno, [this].concat(arg));
return oldReturnVal || newReturnVal;
};
} else {
instanceOptions[optionName] = extendOptions[optionName];
}
});
};
/* harmony default export */ var xss = __webpack_exports__["a"] = (xssFilterInstance);
/***/ }),
/* 12 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXTERNAL MODULE: external {"root":"Vue","commonjs":"vue","commonjs2":"vue","amd":"vue"}
var external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_ = __webpack_require__(0);
// CONCATENATED MODULE: ./node_modules/babel-loader/lib??ref--3!./node_modules/vue-loader/dist/templateLoader.js??ref--6!./node_modules/vue-loader/dist??ref--2-0!./src/preview.vue?vue&type=template&id=91b6d566
var _hoisted_1 = ["innerHTML"];
function render(_ctx, _cache, $props, $setup, $data, $options) {
var _component_scrollbar = Object(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_["resolveComponent"])("scrollbar");
return Object(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_["openBlock"])(), Object(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_["createElementBlock"])("div", {
class: "v-md-editor-preview",
style: Object(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_["normalizeStyle"])({
tabSize: _ctx.tabSize,
'-moz-tab-size': _ctx.tabSize,
'-o-tab-size': _ctx.tabSize
}),
onClick: _cache[0] || (_cache[0] = function () {
return _ctx.handlePreviewClick && _ctx.handlePreviewClick.apply(_ctx, arguments);
})
}, [Object(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_["createVNode"])(_component_scrollbar, null, {
default: Object(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_["withCtx"])(function () {
return [Object(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_["createElementVNode"])("div", {
class: Object(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_["normalizeClass"])([_ctx.previewClass]),
innerHTML: _ctx.html
}, null, 10 /* CLASS, PROPS */, _hoisted_1)];
}),
_: 1 /* STABLE */
})], 4 /* STYLE */);
}
// CONCATENATED MODULE: ./src/preview.vue?vue&type=template&id=91b6d566
// EXTERNAL MODULE: ./src/utils/xss/index.js + 3 modules
var xss = __webpack_require__(11);
// EXTERNAL MODULE: ./src/utils/lang.js + 1 modules
var lang = __webpack_require__(17);
// CONCATENATED MODULE: ./src/utils/v-md-parser.js
var v_md_parser_VMdParser = /*#__PURE__*/function () {
function VMdParser() {
this.lang = new lang["a" /* default */]();
}
var _proto = VMdParser.prototype;
_proto.defaultMarkdownLoader = function defaultMarkdownLoader(text) {
return text;
};
_proto.use = function use(optionsOrInstall, opt) {
if (typeof optionsOrInstall === 'function') {
optionsOrInstall(this, opt);
} else {
optionsOrInstall.install(this, opt);
}
return this;
};
_proto.theme = function theme(themeConfig) {
this.themeConfig = themeConfig;
};
_proto.extendMarkdown = function extendMarkdown(extender) {
if (!this.themeConfig) {
return console.error('Please use theme before using plugins');
}
var markdownParser = this.themeConfig.markdownParser;
extender(markdownParser);
};
_proto.parse = function parse(text) {
var _markdownParser$rende;
var markdownParser = this.themeConfig.markdownParser;
var markdownLoader = (markdownParser == null ? void 0 : (_markdownParser$rende = markdownParser.render) == null ? void 0 : _markdownParser$rende.bind(markdownParser)) || this.defaultMarkdownLoader;
if (typeof markdownLoader !== 'function' || markdownLoader === this.defaultMarkdownLoader) {
console.error('Please configure your markdown parser');
}
return markdownLoader(text);
};
return VMdParser;
}();
// EXTERNAL MODULE: ./src/mixins/preview.js
var preview = __webpack_require__(21);
// CONCATENATED MODULE: ./node_modules/babel-loader/lib??ref--3!./node_modules/vue-loader/dist??ref--2-0!./src/preview.vue?vue&type=script&lang=js
// mixins
var component = {
name: 'v-md-preview',
mixins: [preview["a" /* default */]],
props: {
text: {
type: String,
default: ''
},
theme: Object,
beforeChange: Function
},
emits: ['change'],
data: function data() {
return {
html: ''
};
},
watch: {
text: function text() {
this.handleTextChange();
},
langConfig: function langConfig() {
this.handleTextChange();
}
},
computed: {
vMdParser: function vMdParser() {
return this.$options.vMdParser;
},
previewClass: function previewClass() {
return this.vMdParser.themeConfig.previewClass;
},
langConfig: function langConfig() {
return this.vMdParser.lang.langConfig;
}
},
created: function created() {
this.handleTextChange();
},
methods: {
handleTextChange: function handleTextChange() {
var _this = this;
var next = function next(text) {
_this.html = xss["a" /* default */].process(_this.$options.vMdParser.parse(text));
_this.$emit('change', text, _this.html);
};
if (this.beforeChange) {
this.beforeChange(this.text, next);
} else {
next(this.text);
}
}
}
};
var vMdParser = new v_md_parser_VMdParser();
vMdParser.lang.config = Object(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_["reactive"])(vMdParser.lang.config);
component.vMdParser = new v_md_parser_VMdParser();
/* harmony default export */ var previewvue_type_script_lang_js = (component);
// CONCATENATED MODULE: ./src/preview.vue?vue&type=script&lang=js
// EXTERNAL MODULE: ./src/preview.vue?vue&type=style&index=0&id=91b6d566&lang=css
var previewvue_type_style_index_0_id_91b6d566_lang_css = __webpack_require__(38);
// EXTERNAL MODULE: ./node_modules/vue-loader/dist/exportHelper.js
var exportHelper = __webpack_require__(3);
var exportHelper_default = /*#__PURE__*/__webpack_require__.n(exportHelper);
// CONCATENATED MODULE: ./src/preview.vue
const __exports__ = /*#__PURE__*/exportHelper_default()(previewvue_type_script_lang_js, [['render',render]])
/* harmony default export */ var src_preview = (__exports__);
// EXTERNAL MODULE: ./src/assets/css/font.css
var font = __webpack_require__(24);
// CONCATENATED MODULE: ./src/preview.js
// This file is auto generated by build/build-entry.js
// font css
var version = '1.0.6';
var preview_install = function install(app) {
app.component(src_preview.name, src_preview);
};
src_preview.version = version;
src_preview.install = preview_install;
src_preview.xss = xss["a" /* default */];
src_preview.use = function (optionsOrInstall, opt) {
if (typeof optionsOrInstall === 'function') {
optionsOrInstall(src_preview, opt);
} else {
optionsOrInstall.install(src_preview, opt);
}
return src_preview;
};
/* harmony default export */ var src_preview_0 = __webpack_exports__["default"] = (src_preview);
/***/ }),
/* 13 */
/***/ (function(module, exports, __webpack_require__) {
// TODO(Babel 8): Remove this file.
var runtime = __webpack_require__(50)();
module.exports = runtime;
// Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
try {
regeneratorRuntime = runtime;
} catch (accidentalStrictMode) {
if (typeof globalThis === "object") {
globalThis.regeneratorRuntime = runtime;
} else {
Function("r", "regeneratorRuntime = r")(runtime);
}
}
/***/ }),
/* 14 */
/***/ (function(module, exports, __webpack_require__) {
/**
* xss
*
* @author Zongmin Lei<leizongmin@gmail.com>
*/
var DEFAULT = __webpack_require__(26);
var parser = __webpack_require__(29);
var FilterXSS = __webpack_require__(37);
/**
* filter xss function
*
* @param {String} html
* @param {Object} options { whiteList, onTag, onTagAttr, onIgnoreTag, onIgnoreTagAttr, safeAttrValue, escapeHtml }
* @return {String}
*/
function filterXSS(html, options) {
var xss = new FilterXSS(options);
return xss.process(html);
}
exports = module.exports = filterXSS;
exports.filterXSS = filterXSS;
exports.FilterXSS = FilterXSS;
(function () {
for (var i in DEFAULT) {
exports[i] = DEFAULT[i];
}
for (var j in parser) {
exports[j] = parser[j];
}
})();
// using `xss` on the browser, output `filterXSS` to the globals
if (typeof window !== "undefined") {
window.filterXSS = module.exports;
}
// using `xss` on the WebWorker, output `filterXSS` to the globals
function isWorkerEnv() {
return (
typeof self !== "undefined" &&
typeof DedicatedWorkerGlobalScope !== "undefined" &&
self instanceof DedicatedWorkerGlobalScope
);
}
if (isWorkerEnv()) {
self.filterXSS = module.exports;
}
/***/ }),
/* 15 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return filesFilter; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return getFilesFromClipboardData; });
// Modified from https://github.com/ElemeFE/element/blob/dev/packages/upload/src/upload-dragger.vue
function filesFilter(files, config) {
var accept = config.accept;
var filesKeys = Object.keys(files).filter(function (key) {
var file = files[key];
var type = file.type,
name = file.name;
var extension = name.indexOf('.') > -1 ? "." + name.split('.').pop() : '';
var baseType = type.replace(/\/.*$/, '');
return accept.split(',').map(function (type) {
return type.trim();
}).filter(function (type) {
return type;
}).some(function (acceptedType) {
if (/\..+$/.test(acceptedType)) {
return extension === acceptedType;
}
if (/\/\*$/.test(acceptedType)) {
return baseType === acceptedType.replace(/\/\*$/, '');
}
// eslint-disable-next-line no-useless-escape
if (/^[^\/]+\/[^\/]+$/.test(acceptedType)) {
return type === acceptedType;
}
return false;
});
});
return filesKeys.map(function (key) {
return files[key];
});
}
function getFilesFromClipboardData(clipboardData) {
var files = [];
Object.keys(clipboardData.items).forEach(function (key) {
var item = clipboardData.items[key];
if (item.kind === 'file') {
var file = item.getAsFile();
if (file) files.push(file);
}
});
return files;
}
/***/ }),
/* 16 */
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export set */
/* unused harmony export del */
/* unused harmony export Vue2 */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isVue2", function() { return isVue2; });
/* unused harmony export isVue3 */
/* unused harmony export install */
/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony reexport (checked) */ if(__webpack_require__.o(vue__WEBPACK_IMPORTED_MODULE_0__, "computed")) __webpack_require__.d(__webpack_exports__, "computed", function() { return vue__WEBPACK_IMPORTED_MODULE_0__["computed"]; });
/* harmony reexport (checked) */ if(__webpack_require__.o(vue__WEBPACK_IMPORTED_MODULE_0__, "defineComponent")) __webpack_require__.d(__webpack_exports__, "defineComponent", function() { return vue__WEBPACK_IMPORTED_MODULE_0__["defineComponent"]; });
/* harmony reexport (checked) */ if(__webpack_require__.o(vue__WEBPACK_IMPORTED_MODULE_0__, "h")) __webpack_require__.d(__webpack_exports__, "h", function() { return vue__WEBPACK_IMPORTED_MODULE_0__["h"]; });
var isVue2 = false
var isVue3 = true
var Vue2 = undefined
function install() {}
function set(target, key, val) {
if (Array.isArray(target)) {
target.length = Math.max(target.length, key)
target.splice(key, 1, val)
return val
}
target[key] = val
return val
}
function del(target, key) {
if (Array.isArray(target)) {
target.splice(key, 1)
return
}
delete target[key]
}
/***/ }),
/* 17 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// EXPORTS
__webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ lang_Lang; });
// EXTERNAL MODULE: ./src/utils/util.js
var util = __webpack_require__(2);
// CONCATENATED MODULE: ./src/utils/deep-assign.js
var deep_assign_hasOwnProperty = Object.prototype.hasOwnProperty;
function assignKey(to, from, key) {
var val = from[key];
if (val === undefined || val === null) {
return;
}
if (!deep_assign_hasOwnProperty.call(to, key) || !Object(util["f" /* isObject */])(val)) {
to[key] = val;
} else {
// eslint-disable-next-line
to[key] = deepAssign(Object(to[key]), from[key]);
}
}
function deepAssign(to, from) {
Object.keys(from).forEach(function (key) {
assignKey(to, from, key);
});
return to;
}
// CONCATENATED MODULE: ./src/utils/lang.js
var lang_Lang = /*#__PURE__*/function () {
function Lang(options) {
if (options === void 0) {
options = {};
}
this.config = {
lang: 'zh-CN',
langConfig: {
'zh-CN': {}
}
};
this.options = options;
}
var _proto = Lang.prototype;
_proto.use = function use(lang, config) {
var _this$add;
this.config.lang = lang;
this.add((_this$add = {}, _this$add[lang] = config, _this$add));
if (this.options.afterUse) this.options.afterUse(lang, config);
};
_proto.add = function add(config) {
if (config === void 0) {
config = {};
}
deepAssign(this.config.langConfig, config);
};
return Lang;
}();
/***/ }),
/* 18 */
/***/ (function(module, exports, __webpack_require__) {
/**
* cssfilter
*
* @author 老雷<leizongmin@gmail.com>
*/
var DEFAULT = __webpack_require__(27);
var FilterCSS = __webpack_require__(35);
/**
* XSS过滤
*
* @param {String} css 要过滤的CSS代码
* @param {Object} options 选项:whiteList, onAttr, onIgnoreAttr
* @return {String}
*/
function filterCSS (html, options) {
var xss = new FilterCSS(options);
return xss.process(html);
}
// 输出
exports = module.exports = filterCSS;
exports.FilterCSS = FilterCSS;
for (var i in DEFAULT) exports[i] = DEFAULT[i];
// 在浏览器端使用
if (typeof window !== 'undefined') {
window.filterCSS = module.exports;
}
/***/ }),
/* 19 */
/***/ (function(module, exports) {
module.exports = {
indexOf: function (arr, item) {
var i, j;
if (Array.prototype.indexOf) {
return arr.indexOf(item);
}
for (i = 0, j = arr.length; i < j; i++) {
if (arr[i] === item) {
return i;
}
}
return -1;
},
forEach: function (arr, fn, scope) {
var i, j;
if (Array.prototype.forEach) {
return arr.forEach(fn, scope);
}
for (i = 0, j = arr.length; i < j; i++) {
fn.call(scope, arr[i], i, arr);
}
},
trim: function (str) {
if (String.prototype.trim) {
return str.trim();
}
return str.replace(/(^\s*)|(\s*$)/g, "");
},
spaceIndex: function (str) {
var reg = /\s|\n|\t/;
var match = reg.exec(str);
return match ? match.index : -1;
},
};
/***/ }),
/* 20 */
/***/ (function(module, exports, __webpack_require__) {
// extracted by mini-css-extract-plugin
/***/ }),
/* 21 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _utils_scroll_top__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
/* harmony import */ var _utils_smooth_scroll__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9);
/* harmony import */ var _components_scrollbar_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(10);
/* harmony import */ var _utils_constants_markup__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4);
var _components;
/* harmony default export */ __webpack_exports__["a"] = ({
components: (_components = {}, _components[_components_scrollbar_index__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].name] = _components_scrollbar_index__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"], _components),
props: {
tabSize: {
type: Number,
default: 2
},
scrollContainer: {
type: Function,
default: function _default() {
return window;
}
},
top: {
type: Number,
default: 0
}
},
emits: ['image-click'],
methods: {
handlePreviewClick: function handlePreviewClick(e) {
var target = e.target;
// image preview
if (target.tagName === 'IMG') {
var src = target.getAttribute('src');
if (!src) return;
var imageEls = Array.from(this.$el.querySelectorAll('img'));
var images = imageEls.map(function (el) {
return el.getAttribute('src');
}).filter(function (src) {
return src;
});
var imagePreviewInitIndex = imageEls.indexOf(target);
this.$emit('image-click', images, imagePreviewInitIndex);
return;
}
var scrollToTargetId = target.getAttribute(_utils_constants_markup__WEBPACK_IMPORTED_MODULE_3__[/* ANCHOR_MARKUP */ "a"]);
var scrollToTarget = this.$el.querySelector("[" + _utils_constants_markup__WEBPACK_IMPORTED_MODULE_3__[/* HEADING_MARKUP */ "b"] + "=\"" + scrollToTargetId + "\"]");
if (scrollToTarget) {
this.scrollToTarget({
target: scrollToTarget
});
}
},
getOffsetTop: function getOffsetTop(target, container) {
var rect = target.getBoundingClientRect();
if (container === window || container === document.documentElement) {
return rect.top;
}
return rect.top - container.getBoundingClient