wangeditor
Version:
wangEditor - 轻量级 web 富文本编辑器,配置方便,使用简单,开源免费
2,115 lines (1,644 loc) • 625 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["wangEditor"] = factory();
else
root["wangEditor"] = factory();
})(window, function() {
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 = 129);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
"default": obj
};
}
module.exports = _interopRequireDefault;
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(130);
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @description 封装 DOM 操作
* @wangfupeng
*/
var _interopRequireDefault = __webpack_require__(0);
var _bind = _interopRequireDefault(__webpack_require__(88));
var _includes = _interopRequireDefault(__webpack_require__(89));
var _filter = _interopRequireDefault(__webpack_require__(66));
var _splice = _interopRequireDefault(__webpack_require__(90));
var _indexOf = _interopRequireDefault(__webpack_require__(54));
var _map = _interopRequireDefault(__webpack_require__(114));
var _trim = _interopRequireDefault(__webpack_require__(19));
var _map2 = _interopRequireDefault(__webpack_require__(29));
var _forEach = _interopRequireDefault(__webpack_require__(5));
var _isArray = _interopRequireDefault(__webpack_require__(93));
var _defineProperty = _interopRequireDefault(__webpack_require__(1));
var __spreadArrays = void 0 && (void 0).__spreadArrays || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) {
s += arguments[i].length;
}
for (var r = Array(s), k = 0, i = 0; i < il; i++) {
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) {
r[k] = a[j];
}
}
return r;
};
(0, _defineProperty["default"])(exports, "__esModule", {
value: true
});
exports.DomElement = void 0;
var util_1 = __webpack_require__(7);
var AGENT_EVENTS = [];
/**
* 根据 html 字符串创建 elem
* @param {String} html html
*/
function _createElemByHTML(html) {
var div = document.createElement('div');
div.innerHTML = html;
var elems = div.children;
return util_1.toArray(elems);
}
/**
* 判断是否是 DOM List
* @param selector DOM 元素或列表
*/
function _isDOMList(selector) {
if (!selector) {
return false;
}
if (selector instanceof HTMLCollection || selector instanceof NodeList) {
return true;
}
return false;
}
/**
* 封装 querySelectorAll
* @param selector css 选择器
*/
function _querySelectorAll(selector) {
var elems = document.querySelectorAll(selector);
return util_1.toArray(elems);
}
/**
* 封装 _styleArrTrim
* @param styleArr css
*/
function _styleArrTrim(style) {
var styleArr = [];
var resultArr = [];
if (!(0, _isArray["default"])(style)) {
// 有 style,将 style 按照 `;` 拆分为数组
styleArr = style.split(';');
} else {
styleArr = style;
}
(0, _forEach["default"])(styleArr).call(styleArr, function (item) {
var _context;
// 对每项样式,按照 : 拆分为 key 和 value
var arr = (0, _map2["default"])(_context = item.split(':')).call(_context, function (i) {
return (0, _trim["default"])(i).call(i);
});
if (arr.length === 2) {
resultArr.push(arr[0] + ':' + arr[1]);
}
});
return resultArr;
} // 构造函数
var DomElement =
/** @class */
function () {
/**
* 构造函数
* @param selector 任一类型的选择器
*/
function DomElement(selector) {
// 初始化属性
this.elems = [];
this.length = this.elems.length;
this.dataSource = new _map["default"]();
if (!selector) {
return;
} // 原本就是 DomElement 实例,则直接返回
if (selector instanceof DomElement) {
return selector;
}
var selectorResult = []; // 存储查询结果
var nodeType = selector instanceof Node ? selector.nodeType : -1;
this.selector = selector;
if (nodeType === 1 || nodeType === 9) {
selectorResult = [selector];
} else if (_isDOMList(selector)) {
// DOM List
selectorResult = util_1.toArray(selector);
} else if (selector instanceof Array) {
// Element 数组(其他数据类型,暂时忽略)
selectorResult = selector;
} else if (typeof selector === 'string') {
var _context2;
// 字符串
var tmpSelector = (0, _trim["default"])(_context2 = selector.replace('/\n/mg', '')).call(_context2);
if ((0, _indexOf["default"])(tmpSelector).call(tmpSelector, '<') === 0) {
// 如 <div>
selectorResult = _createElemByHTML(tmpSelector);
} else {
// 如 #id .class
selectorResult = _querySelectorAll(tmpSelector);
}
}
var length = selectorResult.length;
if (!length) {
// 空数组
return this;
} // 加入 DOM 节点
var i = 0;
for (; i < length; i++) {
this.elems.push(selectorResult[i]);
}
this.length = length;
}
(0, _defineProperty["default"])(DomElement.prototype, "id", {
/**
* 获取元素 id
*/
get: function get() {
return this.elems[0].id;
},
enumerable: false,
configurable: true
});
/**
* 遍历所有元素,执行回调函数
* @param fn 回调函数
*/
DomElement.prototype.forEach = function (fn) {
for (var i = 0; i < this.length; i++) {
var elem = this.elems[i];
var result = fn.call(elem, elem, i);
if (result === false) {
break;
}
}
return this;
};
/**
* 克隆元素
* @param deep 是否深度克隆
*/
DomElement.prototype.clone = function (deep) {
var _context3;
if (deep === void 0) {
deep = false;
}
var cloneList = [];
(0, _forEach["default"])(_context3 = this.elems).call(_context3, function (elem) {
cloneList.push(elem.cloneNode(!!deep));
});
return $(cloneList);
};
/**
* 获取第几个元素
* @param index index
*/
DomElement.prototype.get = function (index) {
if (index === void 0) {
index = 0;
}
var length = this.length;
if (index >= length) {
index = index % length;
}
return $(this.elems[index]);
};
/**
* 获取第一个元素
*/
DomElement.prototype.first = function () {
return this.get(0);
};
/**
* 获取最后一个元素
*/
DomElement.prototype.last = function () {
var length = this.length;
return this.get(length - 1);
};
DomElement.prototype.on = function (type, selector, fn) {
var _context4;
if (!type) return this; // 没有 selector ,只有 type 和 fn
if (typeof selector === 'function') {
fn = selector;
selector = '';
}
return (0, _forEach["default"])(_context4 = this).call(_context4, function (elem) {
// 没有事件代理
if (!selector) {
// 无代理
elem.addEventListener(type, fn);
return;
} // 有事件代理
var agentFn = function agentFn(e) {
var target = e.target;
if (target.matches(selector)) {
;
fn.call(target, e);
}
};
elem.addEventListener(type, agentFn); // 缓存代理事件
AGENT_EVENTS.push({
elem: elem,
selector: selector,
fn: fn,
agentFn: agentFn
});
});
};
DomElement.prototype.off = function (type, selector, fn) {
var _context5;
if (!type) return this; // 没有 selector ,只有 type 和 fn
if (typeof selector === 'function') {
fn = selector;
selector = '';
}
return (0, _forEach["default"])(_context5 = this).call(_context5, function (elem) {
// 解绑事件代理
if (selector) {
var idx = -1;
for (var i = 0; i < AGENT_EVENTS.length; i++) {
var item = AGENT_EVENTS[i];
if (item.selector === selector && item.fn === fn && item.elem === elem) {
idx = i;
break;
}
}
if (idx !== -1) {
var agentFn = (0, _splice["default"])(AGENT_EVENTS).call(AGENT_EVENTS, idx, 1)[0].agentFn;
elem.removeEventListener(type, agentFn);
}
} else {
// @ts-ignore
elem.removeEventListener(type, fn);
}
});
};
DomElement.prototype.attr = function (key, val) {
var _context6;
if (val == null) {
// 获取数据
return this.elems[0].getAttribute(key) || '';
} // 否则,设置属性
return (0, _forEach["default"])(_context6 = this).call(_context6, function (elem) {
elem.setAttribute(key, val);
});
};
/**
* 删除 属性
* @param key key
*/
DomElement.prototype.removeAttr = function (key) {
var _context7;
(0, _forEach["default"])(_context7 = this).call(_context7, function (elem) {
elem.removeAttribute(key);
});
};
/**
* 添加 css class
* @param className css class
*/
DomElement.prototype.addClass = function (className) {
var _context8;
if (!className) {
return this;
}
return (0, _forEach["default"])(_context8 = this).call(_context8, function (elem) {
if (elem.className) {
// 当前有 class
var arr = elem.className.split(/\s/);
arr = (0, _filter["default"])(arr).call(arr, function (item) {
return !!(0, _trim["default"])(item).call(item);
}); // 添加 class
if ((0, _indexOf["default"])(arr).call(arr, className) < 0) {
arr.push(className);
} // 修改 elem.class
elem.className = arr.join(' ');
} else {
// 当前没有 class
elem.className = className;
}
});
};
/**
* 添加 css class
* @param className css class
*/
DomElement.prototype.removeClass = function (className) {
var _context9;
if (!className) {
return this;
}
return (0, _forEach["default"])(_context9 = this).call(_context9, function (elem) {
if (!elem.className) {
// 当前无 class
return;
}
var arr = elem.className.split(/\s/);
arr = (0, _filter["default"])(arr).call(arr, function (item) {
item = (0, _trim["default"])(item).call(item); // 删除 class
if (!item || item === className) {
return false;
}
return true;
}); // 修改 elem.class
elem.className = arr.join(' ');
});
};
/**
* 是否有传入的 css class
* @param className css class
*/
DomElement.prototype.hasClass = function (className) {
if (!className) {
return false;
}
var elem = this.elems[0];
if (!elem.className) {
// 当前无 class
return false;
}
var arr = elem.className.split(/\s/);
return (0, _includes["default"])(arr).call(arr, className); // 是否包含
};
/**
* 修改 css
* @param key css key
* @param val css value
*/
// css(key: string): string
DomElement.prototype.css = function (key, val) {
var _context10;
var currentStyle;
if (val == '') {
currentStyle = '';
} else {
currentStyle = key + ":" + val + ";";
}
return (0, _forEach["default"])(_context10 = this).call(_context10, function (elem) {
var _context11;
var style = (0, _trim["default"])(_context11 = elem.getAttribute('style') || '').call(_context11);
if (style) {
// 有 style,将 style 按照 `;` 拆分为数组
var resultArr = _styleArrTrim(style); // 替换现有的 style
resultArr = (0, _map2["default"])(resultArr).call(resultArr, function (item) {
if ((0, _indexOf["default"])(item).call(item, key) === 0) {
return currentStyle;
} else {
return item;
}
}); // 新增 style
if (currentStyle != '' && (0, _indexOf["default"])(resultArr).call(resultArr, currentStyle) < 0) {
resultArr.push(currentStyle);
} // 去掉 空白
if (currentStyle == '') {
resultArr = _styleArrTrim(resultArr);
} // 重新设置 style
elem.setAttribute('style', resultArr.join('; '));
} else {
// 当前没有 style
elem.setAttribute('style', currentStyle);
}
});
};
/**
* 封装 getBoundingClientRect
*/
DomElement.prototype.getBoundingClientRect = function () {
var elem = this.elems[0];
return elem.getBoundingClientRect();
};
/**
* 显示
*/
DomElement.prototype.show = function () {
return this.css('display', 'block');
};
/**
* 隐藏
*/
DomElement.prototype.hide = function () {
return this.css('display', 'none');
};
/**
* 获取子节点(只有 DOM 元素)
*/
DomElement.prototype.children = function () {
var elem = this.elems[0];
if (!elem) {
return null;
}
return $(elem.children);
};
/**
* 获取子节点(包括文本节点)
*/
DomElement.prototype.childNodes = function () {
var elem = this.elems[0];
if (!elem) {
return null;
}
return $(elem.childNodes);
};
/**
* 将子元素全部替换
* @param $children 新的child节点
*/
DomElement.prototype.replaceChildAll = function ($children) {
var parent = this.getNode();
var elem = this.elems[0];
while (elem.hasChildNodes()) {
parent.firstChild && elem.removeChild(parent.firstChild);
}
this.append($children);
};
/**
* 增加子节点
* @param $children 子节点
*/
DomElement.prototype.append = function ($children) {
var _context12;
return (0, _forEach["default"])(_context12 = this).call(_context12, function (elem) {
(0, _forEach["default"])($children).call($children, function (child) {
elem.appendChild(child);
});
});
};
/**
* 移除当前节点
*/
DomElement.prototype.remove = function () {
var _context13;
return (0, _forEach["default"])(_context13 = this).call(_context13, function (elem) {
if (elem.remove) {
elem.remove();
} else {
var parent_1 = elem.parentElement;
parent_1 && parent_1.removeChild(elem);
}
});
};
/**
* 当前元素,是否包含某个子元素
* @param $child 子元素
*/
DomElement.prototype.isContain = function ($child) {
var elem = this.elems[0];
var child = $child.elems[0];
return elem.contains(child);
};
/**
* 获取当前元素的尺寸和位置信息
*/
DomElement.prototype.getSizeData = function () {
var elem = this.elems[0]; // 可得到 bottom height left right top width 的数据
return elem.getBoundingClientRect();
};
/**
* 获取当前元素 nodeName
*/
DomElement.prototype.getNodeName = function () {
var elem = this.elems[0];
return elem.nodeName;
};
/**
* 根据元素位置获取元素节点(默认获取0位置的节点)
* @param n 元素节点位置
*/
DomElement.prototype.getNode = function (n) {
if (n === void 0) {
n = 0;
}
var elem;
elem = this.elems[n];
return elem;
};
/**
* 获取当前元素可视高度
*/
DomElement.prototype.getClientHeight = function () {
var elem = this.elems[0];
return elem.clientHeight;
};
/**
* 获取当前元素可视宽度
*/
// getClientWidth(): number {
// const elem = this.elems[0]
// return elem.clientWidth
// }
/**
* 查询
* @param selector css 选择器
*/
DomElement.prototype.find = function (selector) {
var elem = this.elems[0];
return $(elem.querySelectorAll(selector));
};
DomElement.prototype.text = function (val) {
if (!val) {
// 获取 text
var elem = this.elems[0];
return elem.innerHTML.replace(/<[^>]+>/g, function () {
return '';
});
} else {
var _context14;
// 设置 text
return (0, _forEach["default"])(_context14 = this).call(_context14, function (elem) {
elem.innerHTML = val;
});
}
};
DomElement.prototype.html = function (val) {
var elem = this.elems[0];
if (!val) {
// 获取 html
return elem.innerHTML;
} else {
// 设置 html
elem.innerHTML = val;
return this;
}
};
/**
* 获取元素 value
*/
DomElement.prototype.val = function () {
var _context15;
var elem = this.elems[0];
return (0, _trim["default"])(_context15 = elem.value).call(_context15); // 暂用 any
};
/**
* focus 到当前元素
*/
DomElement.prototype.focus = function () {
var _context16;
return (0, _forEach["default"])(_context16 = this).call(_context16, function (elem) {
elem.focus();
});
};
/**
* 当前元素前一个兄弟节点
*/
DomElement.prototype.prev = function () {
var elem = this.elems[0];
return $(elem.previousElementSibling);
};
/**
* 当前元素后一个兄弟节点
*/
DomElement.prototype.next = function () {
var elem = this.elems[0];
return $(elem.nextElementSibling);
};
/**
* 获取父元素
*/
DomElement.prototype.parent = function () {
var elem = this.elems[0];
return $(elem.parentElement);
};
/**
* 查找父元素,直到满足 selector 条件
* @param selector css 选择器
* @param curElem 从哪个元素开始查找,默认为当前元素
*/
DomElement.prototype.parentUntil = function (selector, curElem) {
var elem = curElem || this.elems[0];
if (elem.nodeName === 'BODY') {
return null;
}
var parent = elem.parentElement;
if (parent === null) {
return null;
}
if (parent.matches(selector)) {
// 找到,并返回
return $(parent);
} // 继续查找,递归
return this.parentUntil(selector, parent);
};
/**
* 查找父元素,直到满足 selector 条件,或者 到达 编辑区域容器以及菜单栏容器
* @param selector css 选择器
* @param curElem 从哪个元素开始查找,默认为当前元素
*/
DomElement.prototype.parentUntilEditor = function (selector, editor, curElem) {
var elem = curElem || this.elems[0];
if ($(elem).equal(editor.$textContainerElem) || $(elem).equal(editor.$toolbarElem)) {
return null;
}
var parent = elem.parentElement;
if (parent === null) {
return null;
}
if (parent.matches(selector)) {
// 找到,并返回
return $(parent);
} // 继续查找,递归
return this.parentUntilEditor(selector, editor, parent);
};
/**
* 判读是否相等
* @param $elem 元素
*/
DomElement.prototype.equal = function ($elem) {
if ($elem instanceof DomElement) {
return this.elems[0] === $elem.elems[0];
} else if ($elem instanceof HTMLElement) {
return this.elems[0] === $elem;
} else {
return false;
}
};
/**
* 将该元素插入到某个元素前面
* @param selector css 选择器
*/
DomElement.prototype.insertBefore = function (selector) {
var _context17;
var $referenceNode = $(selector);
var referenceNode = $referenceNode.elems[0];
if (!referenceNode) {
return this;
}
return (0, _forEach["default"])(_context17 = this).call(_context17, function (elem) {
var parent = referenceNode.parentNode;
parent.insertBefore(elem, referenceNode);
});
};
/**
* 将该元素插入到selector元素后面
* @param selector css 选择器
*/
DomElement.prototype.insertAfter = function (selector) {
var _context18;
var $referenceNode = $(selector);
var referenceNode = $referenceNode.elems[0];
var anchorNode = referenceNode && referenceNode.nextSibling;
if (!referenceNode) {
return this;
}
return (0, _forEach["default"])(_context18 = this).call(_context18, function (elem) {
var parent = referenceNode.parentNode;
if (anchorNode) {
parent.insertBefore(elem, anchorNode);
} else {
parent.appendChild(elem);
}
});
};
/**
* 设置/获取 数据
* @param key key
* @param value value
*/
DomElement.prototype.data = function (key, value) {
if (value != null) {
// 设置数据
this.dataSource.set(key, value);
} else {
// 获取数据
return this.dataSource.get(key);
}
};
/**
* 获取当前节点的顶级(段落)
* @param editor 富文本实例
*/
DomElement.prototype.getNodeTop = function (editor) {
if (this.length < 1) {
return this;
}
var $parent = this.parent();
if (editor.$textElem.equal($parent)) {
return this;
}
return $parent.getNodeTop(editor);
};
/**
* 获取当前 节点 基与上一个拥有相对或者解决定位的父容器的位置
* @param editor 富文本实例
*/
DomElement.prototype.getOffsetData = function () {
var $node = this.elems[0];
return {
top: $node.offsetTop,
left: $node.offsetLeft,
width: $node.offsetWidth,
height: $node.offsetHeight,
parent: $node.offsetParent
};
};
/**
* 从上至下进行滚动
* @param top 滚动的值
*/
DomElement.prototype.scrollTop = function (top) {
var $node = this.elems[0];
$node.scrollTo({
top: top
});
};
return DomElement;
}();
exports.DomElement = DomElement; // new 一个对象
function $() {
var arg = [];
for (var _i = 0; _i < arguments.length; _i++) {
arg[_i] = arguments[_i];
}
return new ((0, _bind["default"])(DomElement).apply(DomElement, __spreadArrays([void 0], arg)))();
}
exports["default"] = $;
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(134);
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var global = __webpack_require__(8);
var getOwnPropertyDescriptor = __webpack_require__(68).f;
var isForced = __webpack_require__(101);
var path = __webpack_require__(10);
var bind = __webpack_require__(47);
var createNonEnumerableProperty = __webpack_require__(17);
var has = __webpack_require__(15);
var wrapConstructor = function (NativeConstructor) {
var Wrapper = function (a, b, c) {
if (this instanceof NativeConstructor) {
switch (arguments.length) {
case 0: return new NativeConstructor();
case 1: return new NativeConstructor(a);
case 2: return new NativeConstructor(a, b);
} return new NativeConstructor(a, b, c);
} return NativeConstructor.apply(this, arguments);
};
Wrapper.prototype = NativeConstructor.prototype;
return Wrapper;
};
/*
options.target - name of the target object
options.global - target is the global object
options.stat - export as static methods of target
options.proto - export as prototype methods of target
options.real - real prototype method for the `pure` version
options.forced - export even if the native feature is available
options.bind - bind methods to the target, required for the `pure` version
options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
options.unsafe - use the simple assignment of property instead of delete + defineProperty
options.sham - add a flag to not completely full polyfills
options.enumerable - export as enumerable property
options.noTargetGet - prevent calling a getter on target
*/
module.exports = function (options, source) {
var TARGET = options.target;
var GLOBAL = options.global;
var STATIC = options.stat;
var PROTO = options.proto;
var nativeSource = GLOBAL ? global : STATIC ? global[TARGET] : (global[TARGET] || {}).prototype;
var target = GLOBAL ? path : path[TARGET] || (path[TARGET] = {});
var targetPrototype = target.prototype;
var FORCED, USE_NATIVE, VIRTUAL_PROTOTYPE;
var key, sourceProperty, targetProperty, nativeProperty, resultProperty, descriptor;
for (key in source) {
FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
// contains in native
USE_NATIVE = !FORCED && nativeSource && has(nativeSource, key);
targetProperty = target[key];
if (USE_NATIVE) if (options.noTargetGet) {
descriptor = getOwnPropertyDescriptor(nativeSource, key);
nativeProperty = descriptor && descriptor.value;
} else nativeProperty = nativeSource[key];
// export native or implementation
sourceProperty = (USE_NATIVE && nativeProperty) ? nativeProperty : source[key];
if (USE_NATIVE && typeof targetProperty === typeof sourceProperty) continue;
// bind timers to global for call from export context
if (options.bind && USE_NATIVE) resultProperty = bind(sourceProperty, global);
// wrap global constructors for prevent changs in this version
else if (options.wrap && USE_NATIVE) resultProperty = wrapConstructor(sourceProperty);
// make static versions for prototype methods
else if (PROTO && typeof sourceProperty == 'function') resultProperty = bind(Function.call, sourceProperty);
// default case
else resultProperty = sourceProperty;
// add a flag to not completely full polyfills
if (options.sham || (sourceProperty && sourceProperty.sham) || (targetProperty && targetProperty.sham)) {
createNonEnumerableProperty(resultProperty, 'sham', true);
}
target[key] = resultProperty;
if (PROTO) {
VIRTUAL_PROTOTYPE = TARGET + 'Prototype';
if (!has(path, VIRTUAL_PROTOTYPE)) {
createNonEnumerableProperty(path, VIRTUAL_PROTOTYPE, {});
}
// export virtual prototype methods
path[VIRTUAL_PROTOTYPE][key] = sourceProperty;
// export real prototype methods
if (options.real && targetPrototype && !targetPrototype[key]) {
createNonEnumerableProperty(targetPrototype, key, sourceProperty);
}
}
}
};
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(178);
/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(306);
/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @description 工具函数集合
* @author wangfupeng
*/
var _interopRequireDefault = __webpack_require__(0);
var _map = _interopRequireDefault(__webpack_require__(29));
var _isArray = _interopRequireDefault(__webpack_require__(93));
var _typeof2 = _interopRequireDefault(__webpack_require__(94));
var _setTimeout2 = _interopRequireDefault(__webpack_require__(121));
var _slice = _interopRequireDefault(__webpack_require__(43));
var _parseInt2 = _interopRequireDefault(__webpack_require__(261));
var _defineProperty = _interopRequireDefault(__webpack_require__(1));
var __spreadArrays = void 0 && (void 0).__spreadArrays || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) {
s += arguments[i].length;
}
for (var r = Array(s), k = 0, i = 0; i < il; i++) {
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) {
r[k] = a[j];
}
}
return r;
};
(0, _defineProperty["default"])(exports, "__esModule", {
value: true
});
exports.hexToRgb = exports.getRandomCode = exports.toArray = exports.deepClone = exports.isFunction = exports.debounce = exports.throttle = exports.arrForEach = exports.forEach = exports.replaceSpecialSymbol = exports.replaceHtmlSymbol = exports.getRandom = exports.UA = void 0;
var NavUA =
/** @class */
function () {
function NavUA() {
this._ua = navigator.userAgent;
var math = this._ua.match(/(Edge?)\/(\d+)/);
this.isOldEdge = math && math[1] == 'Edge' && (0, _parseInt2["default"])(math[2]) < 19 ? true : false;
this.isFirefox = /Firefox\/\d+/.test(this._ua) && !/Seamonkey\/\d+/.test(this._ua) ? true : false;
} // 是否为 IE
NavUA.prototype.isIE = function () {
return 'ActiveXObject' in window;
}; // 是否为 webkit
NavUA.prototype.isWebkit = function () {
return /webkit/i.test(this._ua);
};
return NavUA;
}(); // 和 UA 相关的属性
exports.UA = new NavUA();
/**
* 获取随机字符
* @param prefix 前缀
*/
function getRandom(prefix) {
var _context;
if (prefix === void 0) {
prefix = '';
}
return prefix + (0, _slice["default"])(_context = Math.random().toString()).call(_context, 2);
}
exports.getRandom = getRandom;
/**
* 替换 html 特殊字符
* @param html html 字符串
*/
function replaceHtmlSymbol(html) {
return html.replace(/</gm, '<').replace(/>/gm, '>').replace(/"/gm, '"').replace(/(\r\n|\r|\n)/g, '<br/>');
}
exports.replaceHtmlSymbol = replaceHtmlSymbol;
function replaceSpecialSymbol(value) {
return value.replace(/</gm, '<').replace(/>/gm, '>').replace(/"/gm, '"');
}
exports.replaceSpecialSymbol = replaceSpecialSymbol;
function forEach(obj, fn) {
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var result = fn(key, obj[key]);
if (result === false) {
// 提前终止循环
break;
}
}
}
}
exports.forEach = forEach;
/**
* 遍历类数组
* @param fakeArr 类数组
* @param fn 回调函数
*/
function arrForEach(fakeArr, fn) {
var i, item, result;
var length = fakeArr.length || 0;
for (i = 0; i < length; i++) {
item = fakeArr[i];
result = fn.call(fakeArr, item, i);
if (result === false) {
break;
}
}
}
exports.arrForEach = arrForEach;
/**
* 节流
* @param fn 函数
* @param interval 间隔时间,毫秒
*/
function throttle(fn, interval) {
if (interval === void 0) {
interval = 200;
}
var flag = false;
return function () {
var _this = this;
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (!flag) {
flag = true;
(0, _setTimeout2["default"])(function () {
flag = false;
fn.call.apply(fn, __spreadArrays([_this], args)); // this 报语法错误,先用 null
}, interval);
}
};
}
exports.throttle = throttle;
/**
* 防抖
* @param fn 函数
* @param delay 间隔时间,毫秒
*/
function debounce(fn, delay) {
if (delay === void 0) {
delay = 200;
}
var lastFn = 0;
return function () {
var _this = this;
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (lastFn) {
window.clearTimeout(lastFn);
}
lastFn = window.setTimeout(function () {
lastFn = 0;
fn.call.apply(fn, __spreadArrays([_this], args)); // this 报语法错误,先用 null
}, delay);
};
}
exports.debounce = debounce;
/**
* isFunction 是否是函数
* @param fn 函数
*/
function isFunction(fn) {
return typeof fn === 'function';
}
exports.isFunction = isFunction;
/**
* 引用与非引用值 深拷贝方法
* @param data
*/
function deepClone(data) {
if ((0, _typeof2["default"])(data) !== 'object' || typeof data == 'function' || data === null) {
return data;
}
var item;
if ((0, _isArray["default"])(data)) {
item = [];
}
if (!(0, _isArray["default"])(data)) {
item = {};
}
for (var i in data) {
if (Object.prototype.hasOwnProperty.call(data, i)) {
item[i] = deepClone(data[i]);
}
}
return item;
}
exports.deepClone = deepClone;
/**
* 将可遍历的对象转换为数组
* @param data 可遍历的对象
*/
function toArray(data) {
return (0, _slice["default"])(Array.prototype).call(data);
}
exports.toArray = toArray;
/**
* 唯一id生成
* @param length 随机数长度
*/
function getRandomCode() {
var _context2;
return (0, _slice["default"])(_context2 = Math.random().toString(36)).call(_context2, -5);
}
exports.getRandomCode = getRandomCode;
/**
* hex color 转换成 rgb
* @param hex string
*/
function hexToRgb(hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
if (result == null) return null;
var colors = (0, _map["default"])(result).call(result, function (i) {
return (0, _parseInt2["default"])(i, 16);
});
var r = colors[1];
var g = colors[2];
var b = colors[3];
return "rgb(" + r + ", " + g + ", " + b + ")";
}
exports.hexToRgb = hexToRgb;
/***/ }),
/* 8 */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(global) {var check = function (it) {
return it && it.Math == Math && it;
};
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
module.exports =
// eslint-disable-next-line no-undef
check(typeof globalThis == 'object' && globalThis) ||
check(typeof window == 'object' && window) ||
check(typeof self == 'object' && self) ||
check(typeof global == 'object' && global) ||
// eslint-disable-next-line no-new-func
(function () { return this; })() || Function('return this')();
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(133)))
/***/ }),
/* 9 */
/***/ (function(module, exports, __webpack_require__) {
var global = __webpack_require__(8);
var shared = __webpack_require__(74);
var has = __webpack_require__(15);
var uid = __webpack_require__(60);
var NATIVE_SYMBOL = __webpack_require__(78);
var USE_SYMBOL_AS_UID = __webpack_require__(104);
var WellKnownSymbolsStore = shared('wks');
var Symbol = global.Symbol;
var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : Symbol && Symbol.withoutSetter || uid;
module.exports = function (name) {
if (!has(WellKnownSymbolsStore, name)) {
if (NATIVE_SYMBOL && has(Symbol, name)) WellKnownSymbolsStore[name] = Symbol[name];
else WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);
} return WellKnownSymbolsStore[name];
};
/***/ }),
/* 10 */
/***/ (function(module, exports) {
module.exports = {};
/***/ }),
/* 11 */
/***/ (function(module, exports, __webpack_require__) {
var path = __webpack_require__(10);
var has = __webpack_require__(15);
var wrappedWellKnownSymbolModule = __webpack_require__(95);
var defineProperty = __webpack_require__(18).f;
module.exports = function (NAME) {
var Symbol = path.Symbol || (path.Symbol = {});
if (!has(Symbol, NAME)) defineProperty(Symbol, NAME, {
value: wrappedWellKnownSymbolModule.f(NAME)
});
};
/***/ }),
/* 12 */
/***/ (function(module, exports) {
module.exports = function (exec) {
try {
return !!exec();
} catch (error) {
return true;
}
};
/***/ }),
/* 13 */
/***/ (function(module, exports) {
module.exports = function (it) {
return typeof it === 'object' ? it !== null : typeof it === 'function';
};
/***/ }),
/* 14 */
/***/ (function(module, exports, __webpack_require__) {
var fails = __webpack_require__(12);
// Detect IE8's incomplete defineProperty implementation
module.exports = !fails(function () {
return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
});
/***/ }),
/* 15 */
/***/ (function(module, exports) {
var hasOwnProperty = {}.hasOwnProperty;
module.exports = function (it, key) {
return hasOwnProperty.call(it, key);
};
/***/ }),
/* 16 */
/***/ (function(module, exports, __webpack_require__) {
var path = __webpack_require__(10);
module.exports = function (CONSTRUCTOR) {
return path[CONSTRUCTOR + 'Prototype'];
};
/***/ }),
/* 17 */
/***/ (function(module, exports, __webpack_require__) {
var DESCRIPTORS = __webpack_require__(14);
var definePropertyModule = __webpack_require__(18);
var createPropertyDescriptor = __webpack_require__(35);
module.exports = DESCRIPTORS ? function (object, key, value) {
return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
} : function (object, key, value) {
object[key] = value;
return object;
};
/***/ }),
/* 18 */
/***/ (function(module, exports, __webpack_require__) {
var DESCRIPTORS = __webpack_require__(14);
var IE8_DOM_DEFINE = __webpack_require__(100);
var anObject = __webpack_require__(24);
var toPrimitive = __webpack_require__(56);
var nativeDefineProperty = Object.defineProperty;
// `Object.defineProperty` method
// https://tc39.es/ecma262/#sec-object.defineproperty
exports.f = DESCRIPTORS ? nativeDefineProperty : function defineProperty(O, P, Attributes) {
anObject(O);
P = toPrimitive(P, true);
anObject(Attributes);
if (IE8_DOM_DEFINE) try {
return nativeDefineProperty(O, P, Attributes);
} catch (error) { /* empty */ }
if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
if ('value' in Attributes) O[P] = Attributes.value;
return O;
};
/***/ }),
/* 19 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(213);
/***/ }),
/* 20 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var isOldIE = function isOldIE() {
var memo;
return function memorize() {
if (typeof memo === 'undefined') {
// Test for IE <= 9 as proposed by Browserhacks
// @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
// Tests for existence of standard globals is to allow style-loader
// to operate correctly into non-standard environments
// @see https://github.com/webpack-contrib/style-loader/issues/177
memo = Boolean(window && document && document.all && !window.atob);
}
return memo;
};
}();
var getTarget = function getTarget() {
var memo = {};
return function memorize(target) {
if (typeof memo[target] === 'undefined') {
var styleTarget = document.querySelector(target); // Special case to return head of iframe instead of iframe itself
if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
try {
// This will throw an exception if access to iframe is blocked
// due to cross-origin restrictions
styleTarget = styleTarget.contentDocument.head;
} catch (e) {
// istanbul ignore next
styleTarget = null;
}
}
memo[target] = styleTarget;
}
return memo[target];
};
}();
var stylesInDom = [];
function getIndexByIdentifier(identifier) {
var result = -1;
for (var i = 0; i < stylesInDom.length; i++) {
if (stylesInDom[i].identifier === identifier) {
result = i;
break;
}
}
return result;
}
function modulesToDom(list, options) {
var idCountMap = {};
var identifiers = [];
for (var i = 0; i < list.length; i++) {
var item = list[i];
var id = options.base ? item[0] + options.base : item[0];
var count = idCountMap[id] || 0;
var identifier = "".concat(id, " ").concat(count);
idCountMap[id] = count + 1;
var index = getIndexByIdentifier(identifier);
var obj = {
css: item[1],
media: item[2],
sourceMap: item[3]
};
if (index !== -1) {
stylesInDom[index].references++;
stylesInDom[index].updater(obj);
} else {
stylesInDom.push({
identifier: identifier,
updater: addStyle(obj, options),
references: 1
});
}
identifiers.push(identifier);
}
return identifiers;
}
function insertStyleElement(options) {
var style = document.createElement('style');
var attributes = options.attributes || {};
if (typeof attributes.nonce === 'undefined') {
var nonce = true ? __webpack_require__.nc : undefined;
if (nonce) {
attributes.nonce = nonce;
}
}
Object.keys(attributes).forEach(function (key) {
style.setAttribute(key, attributes[key]);
});
if (typeof options.insert === 'function') {
options.insert(style);
} else {
var target = getTarget(options.insert || 'head');
if (!target) {
throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
}
target.appendChild(style);
}
return style;
}
function removeStyleElement(style) {
// istanbul ignore if
if (style.parentNode === null) {
return false;
}
style.parentNode.removeChild(style);
}
/* istanbul ignore next */
var replaceText = function replaceText() {
var textStore = [];
return function replace(index, replacement) {
textStore[index] = replacement;
return textStore.filter(Boolean).join('\n');
};
}();
function applyToSingletonTag(style, index, remove, obj) {
var css = remove ? '' : obj.media ? "@media ".concat(obj.media, " {").concat(obj.css, "}") : obj.css; // For old IE
/* istanbul ignore if */
if (style.styleSheet) {
style.styleSheet.cssText = replaceText(index, css);
} else {
var cssNode = document.createTextNode(css);
var childNodes = style.childNodes;
if (childNodes[index]) {
style.removeChild(childNodes[index]);
}
if (childNodes.length) {
style.insertBefore(cssNode, childNodes[index]);
} else {
style.appendChild(cssNode);
}
}
}
function applyToTag(style, options, obj) {
var css = obj.css;
var media = obj.media;
var sourceMap = obj.sourceMap;
if (media) {
style.setAttribute('media', media);
} else {
style.removeAttribute('media');
}
if (sourceMap && typeof btoa !== 'undefined') {
css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
} // For old IE
/* istanbul ignore if */
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
while (style.firstChild) {
style.removeChild(style.firstChild);
}
style.appendChild(document.createTextNode(css));
}
}
var singleton = null;
var singletonCounter = 0;
function addStyle(obj, options) {
var style;
var update;
var remove;
if (options.singleton) {
var styleIndex = singletonCounter++;
style = singleton || (singleton = insertStyleElement(options));
update = applyToSingletonTag.bind(null, style, styleIndex, false);
remove = applyToSingletonTag.bind(null, style, styleIndex, true);
} else {
style = insertStyleElement(options);
update = applyToTag.bind(null, style, options);
remove = function remove() {
removeStyleElement(style);
};
}
update(obj);
return function updateStyle(newObj) {
if (newObj) {
if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap) {
return;
}
update(obj = newObj);
} else {
remove();
}
};
}
module.exports = function (list, options) {
options = options || {}; // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
// tags it will allow on a page
if (!options.singleton && typeof options.singleton !== 'boolean') {
options.singleton = isOldIE();
}
list = list || [];
var lastIdentifiers = modulesToDom(list, options);
return function update(newList) {
newList = newList || [];
if (Object.prototype.toString.call(newList) !== '[object Array]') {
return;
}
for (var i = 0; i < lastIdentifiers.length; i++) {
var identifier = lastIdentifiers[i];
var index = getIndexByIdentifier(identifier);
stylesInDom[index].references--;
}
var newLastIdentifiers = modulesToDom(newList, options);
for (var _i = 0; _i < lastIdentifiers.length; _i++) {
var _identifier = lastIdentifiers[_i];
var _index = getIndexByIdentifier(_identifier);
if (stylesInDom[_index].references === 0) {
stylesInDom[_index].updater();
stylesInDom.splice(_index, 1);
}
}
lastIdentifiers = newLastIdentifiers;
};
};
/***/ }),
/* 21 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
// css base code, injected by the css-loader
// eslint-disable-next-line func-names
module.exports = function (useSourceMap) {
var list = []; // return the list of modules as css string
list.toString = function toString() {
return this.map(function (item) {
var content = cssWithMappingToString(item, useSourceMap);
if (item[2]) {
return "@media ".concat(item[2], " {").concat(content, "}");
}
return content;
}).join('');
}; // import a list of modules into the list
// eslint-disable-next-line func-names
list.i = function (modules, mediaQuery, dedupe) {
if (typeof modules === 'string') {
// eslint-disable-next-line no-param-reassign
modules = [[null, modules, '']];
}
var alreadyImportedModules = {};
if (dedupe) {
for (var i = 0; i < this.length; i++) {
// eslint-disable-next-line prefer-destructuring
var id = this[i][0];
if (id != null) {
alreadyImportedModules[id] = true;
}
}
}
for (var _i = 0; _i < modules.length; _i++) {
var item = [].concat(modules[_i]);
if (dedupe && alreadyImportedModules[item[0]]) {
// eslint-disable-next-line no-continue
continue;
}
if (mediaQuery) {
if (!item[2]) {
item[2] = mediaQuery;
} else {
item[2] = "".concat(mediaQuery, " and ").concat(item[2]);
}
}
list.push(item);
}
};
return list;
};
function cssWithMappingToString(item, useSourceMap) {
var content = item[1] || ''; // eslint-disable-next-line prefer-destructuring
var cssMapping = item[3];
if (!cssMapping) {
return content;
}
if (useSourceMap && typeof btoa === 'function') {
var sourceMapping = toComment(cssMapping);
var sourceURLs = cssMapping.sources.map(function (source) {
return "/*# sourceURL=".concat(cssMapping.sourceRoot || '').concat(source, " */");
});
return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
}
return [content].join('\n');
} // Adapted from convert-source-map (MIT)
function toComment(sourceMap) {
// eslint-disable-next-line no-undef
var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
return "/*# ".concat(data, " */");
}
/***/ }),
/* 22 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @description 按钮菜单 Class
* @author wangfupeng
*/
var _interopRequireDefault = __webpack_require__(0);
var _defineProperty = _interopRequireDefault(__webpack_require__(1));
var _create = _interopRequireDefault(__webpack_require__(3));
var _setPrototypeOf = _interopRequireDefault(__webpack_require__(6));
var __extends = void 0 && (void 0).__extends || function () {
var _extendStatics = function extendStatics(d, b) {
_extendStatics = _setPrototypeOf["default"] || {
__proto__: []
} instanceof Array && function (d, b) {
d.__proto__ = b;
} || function (d, b) {
for (var p in b) {
if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? (0, _create["default"])(b) : (__.prototype = b.prototype, new __());
};
}();
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
return mod && mod.__esModule ? mod : {
"default": mod
};
};
(0, _defineProperty["default"])(exports, "__esModule", {
value: true
});
var Menu_1 = __importDefault(__webpack_require__(96));
var BtnMenu =
/** @class */
function (_super) {
__extends(BtnMenu, _super);
function BtnMenu($elem, editor) {
return _super.call(this, $elem, editor) || this;
}
return BtnMenu;
}(Menu_1["default"]);
exports["default"] = BtnMenu;
/***/ }),