mirror of https://github.com/kcal-app/kcal.git
31973 lines
1.0 MiB
31973 lines
1.0 MiB
/******/ (() => { // webpackBootstrap
|
|
/******/ var __webpack_modules__ = ({
|
|
|
|
/***/ "./node_modules/@shopify/draggable/lib/draggable.bundle.js":
|
|
/*!*****************************************************************!*\
|
|
!*** ./node_modules/@shopify/draggable/lib/draggable.bundle.js ***!
|
|
\*****************************************************************/
|
|
/***/ ((module) => {
|
|
|
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
if(true)
|
|
module.exports = factory();
|
|
else {}
|
|
})(window, function() {
|
|
return /******/ (function(modules) { // webpackBootstrap
|
|
/******/ // The module cache
|
|
/******/ var installedModules = {};
|
|
/******/
|
|
/******/ // The require function
|
|
/******/ function __nested_webpack_require_556__(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, __nested_webpack_require_556__);
|
|
/******/
|
|
/******/ // Flag the module as loaded
|
|
/******/ module.l = true;
|
|
/******/
|
|
/******/ // Return the exports of the module
|
|
/******/ return module.exports;
|
|
/******/ }
|
|
/******/
|
|
/******/
|
|
/******/ // expose the modules object (__webpack_modules__)
|
|
/******/ __nested_webpack_require_556__.m = modules;
|
|
/******/
|
|
/******/ // expose the module cache
|
|
/******/ __nested_webpack_require_556__.c = installedModules;
|
|
/******/
|
|
/******/ // define getter function for harmony exports
|
|
/******/ __nested_webpack_require_556__.d = function(exports, name, getter) {
|
|
/******/ if(!__nested_webpack_require_556__.o(exports, name)) {
|
|
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
/******/ }
|
|
/******/ };
|
|
/******/
|
|
/******/ // define __esModule on exports
|
|
/******/ __nested_webpack_require_556__.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
|
|
/******/ __nested_webpack_require_556__.t = function(value, mode) {
|
|
/******/ if(mode & 1) value = __nested_webpack_require_556__(value);
|
|
/******/ if(mode & 8) return value;
|
|
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
/******/ var ns = Object.create(null);
|
|
/******/ __nested_webpack_require_556__.r(ns);
|
|
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __nested_webpack_require_556__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
/******/ return ns;
|
|
/******/ };
|
|
/******/
|
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
/******/ __nested_webpack_require_556__.n = function(module) {
|
|
/******/ var getter = module && module.__esModule ?
|
|
/******/ function getDefault() { return module['default']; } :
|
|
/******/ function getModuleExports() { return module; };
|
|
/******/ __nested_webpack_require_556__.d(getter, 'a', getter);
|
|
/******/ return getter;
|
|
/******/ };
|
|
/******/
|
|
/******/ // Object.prototype.hasOwnProperty.call
|
|
/******/ __nested_webpack_require_556__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
/******/
|
|
/******/ // __webpack_public_path__
|
|
/******/ __nested_webpack_require_556__.p = "";
|
|
/******/
|
|
/******/
|
|
/******/ // Load entry module and return exports
|
|
/******/ return __nested_webpack_require_556__(__nested_webpack_require_556__.s = 72);
|
|
/******/ })
|
|
/************************************************************************/
|
|
/******/ ([
|
|
/* 0 */
|
|
/***/ (function(module, exports, __nested_webpack_require_4021__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _AbstractPlugin = __nested_webpack_require_4021__(66);
|
|
|
|
var _AbstractPlugin2 = _interopRequireDefault(_AbstractPlugin);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _AbstractPlugin2.default;
|
|
|
|
/***/ }),
|
|
/* 1 */
|
|
/***/ (function(module, exports, __nested_webpack_require_4433__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _AbstractEvent = __nested_webpack_require_4433__(70);
|
|
|
|
var _AbstractEvent2 = _interopRequireDefault(_AbstractEvent);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _AbstractEvent2.default;
|
|
|
|
/***/ }),
|
|
/* 2 */
|
|
/***/ (function(module, exports, __nested_webpack_require_4841__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _closest = __nested_webpack_require_4841__(57);
|
|
|
|
Object.defineProperty(exports, 'closest', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _interopRequireDefault(_closest).default;
|
|
}
|
|
});
|
|
|
|
var _requestNextAnimationFrame = __nested_webpack_require_4841__(55);
|
|
|
|
Object.defineProperty(exports, 'requestNextAnimationFrame', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _interopRequireDefault(_requestNextAnimationFrame).default;
|
|
}
|
|
});
|
|
|
|
var _distance = __nested_webpack_require_4841__(53);
|
|
|
|
Object.defineProperty(exports, 'distance', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _interopRequireDefault(_distance).default;
|
|
}
|
|
});
|
|
|
|
var _touchCoords = __nested_webpack_require_4841__(51);
|
|
|
|
Object.defineProperty(exports, 'touchCoords', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _interopRequireDefault(_touchCoords).default;
|
|
}
|
|
});
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
/***/ }),
|
|
/* 3 */
|
|
/***/ (function(module, exports, __nested_webpack_require_5916__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _SensorEvent = __nested_webpack_require_5916__(46);
|
|
|
|
Object.keys(_SensorEvent).forEach(function (key) {
|
|
if (key === "default" || key === "__esModule") return;
|
|
Object.defineProperty(exports, key, {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _SensorEvent[key];
|
|
}
|
|
});
|
|
});
|
|
|
|
/***/ }),
|
|
/* 4 */
|
|
/***/ (function(module, exports, __nested_webpack_require_6360__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _Sensor = __nested_webpack_require_6360__(49);
|
|
|
|
var _Sensor2 = _interopRequireDefault(_Sensor);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _Sensor2.default;
|
|
|
|
/***/ }),
|
|
/* 5 */
|
|
/***/ (function(module, exports, __nested_webpack_require_6740__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _DragEvent = __nested_webpack_require_6740__(14);
|
|
|
|
Object.keys(_DragEvent).forEach(function (key) {
|
|
if (key === "default" || key === "__esModule") return;
|
|
Object.defineProperty(exports, key, {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _DragEvent[key];
|
|
}
|
|
});
|
|
});
|
|
|
|
var _DraggableEvent = __nested_webpack_require_6740__(13);
|
|
|
|
Object.keys(_DraggableEvent).forEach(function (key) {
|
|
if (key === "default" || key === "__esModule") return;
|
|
Object.defineProperty(exports, key, {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _DraggableEvent[key];
|
|
}
|
|
});
|
|
});
|
|
|
|
var _Plugins = __nested_webpack_require_6740__(12);
|
|
|
|
Object.keys(_Plugins).forEach(function (key) {
|
|
if (key === "default" || key === "__esModule") return;
|
|
Object.defineProperty(exports, key, {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _Plugins[key];
|
|
}
|
|
});
|
|
});
|
|
|
|
var _Sensors = __nested_webpack_require_6740__(6);
|
|
|
|
Object.keys(_Sensors).forEach(function (key) {
|
|
if (key === "default" || key === "__esModule") return;
|
|
Object.defineProperty(exports, key, {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _Sensors[key];
|
|
}
|
|
});
|
|
});
|
|
|
|
var _Draggable = __nested_webpack_require_6740__(39);
|
|
|
|
var _Draggable2 = _interopRequireDefault(_Draggable);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _Draggable2.default;
|
|
|
|
/***/ }),
|
|
/* 6 */
|
|
/***/ (function(module, exports, __nested_webpack_require_8258__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _Sensor = __nested_webpack_require_8258__(4);
|
|
|
|
Object.defineProperty(exports, 'Sensor', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _interopRequireDefault(_Sensor).default;
|
|
}
|
|
});
|
|
|
|
var _MouseSensor = __nested_webpack_require_8258__(48);
|
|
|
|
Object.defineProperty(exports, 'MouseSensor', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _interopRequireDefault(_MouseSensor).default;
|
|
}
|
|
});
|
|
|
|
var _TouchSensor = __nested_webpack_require_8258__(45);
|
|
|
|
Object.defineProperty(exports, 'TouchSensor', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _interopRequireDefault(_TouchSensor).default;
|
|
}
|
|
});
|
|
|
|
var _DragSensor = __nested_webpack_require_8258__(43);
|
|
|
|
Object.defineProperty(exports, 'DragSensor', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _interopRequireDefault(_DragSensor).default;
|
|
}
|
|
});
|
|
|
|
var _ForceTouchSensor = __nested_webpack_require_8258__(41);
|
|
|
|
Object.defineProperty(exports, 'ForceTouchSensor', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _interopRequireDefault(_ForceTouchSensor).default;
|
|
}
|
|
});
|
|
|
|
var _SensorEvent = __nested_webpack_require_8258__(3);
|
|
|
|
Object.keys(_SensorEvent).forEach(function (key) {
|
|
if (key === "default" || key === "__esModule") return;
|
|
Object.defineProperty(exports, key, {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _SensorEvent[key];
|
|
}
|
|
});
|
|
});
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
/***/ }),
|
|
/* 7 */
|
|
/***/ (function(module, exports, __nested_webpack_require_9794__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _SnappableEvent = __nested_webpack_require_9794__(20);
|
|
|
|
Object.keys(_SnappableEvent).forEach(function (key) {
|
|
if (key === "default" || key === "__esModule") return;
|
|
Object.defineProperty(exports, key, {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _SnappableEvent[key];
|
|
}
|
|
});
|
|
});
|
|
|
|
/***/ }),
|
|
/* 8 */
|
|
/***/ (function(module, exports, __nested_webpack_require_10247__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _CollidableEvent = __nested_webpack_require_10247__(25);
|
|
|
|
Object.keys(_CollidableEvent).forEach(function (key) {
|
|
if (key === "default" || key === "__esModule") return;
|
|
Object.defineProperty(exports, key, {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _CollidableEvent[key];
|
|
}
|
|
});
|
|
});
|
|
|
|
/***/ }),
|
|
/* 9 */
|
|
/***/ (function(module, exports, __nested_webpack_require_10703__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _SortableEvent = __nested_webpack_require_10703__(29);
|
|
|
|
Object.keys(_SortableEvent).forEach(function (key) {
|
|
if (key === "default" || key === "__esModule") return;
|
|
Object.defineProperty(exports, key, {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _SortableEvent[key];
|
|
}
|
|
});
|
|
});
|
|
|
|
/***/ }),
|
|
/* 10 */
|
|
/***/ (function(module, exports, __nested_webpack_require_11154__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _SwappableEvent = __nested_webpack_require_11154__(32);
|
|
|
|
Object.keys(_SwappableEvent).forEach(function (key) {
|
|
if (key === "default" || key === "__esModule") return;
|
|
Object.defineProperty(exports, key, {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _SwappableEvent[key];
|
|
}
|
|
});
|
|
});
|
|
|
|
/***/ }),
|
|
/* 11 */
|
|
/***/ (function(module, exports, __nested_webpack_require_11608__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _DroppableEvent = __nested_webpack_require_11608__(35);
|
|
|
|
Object.keys(_DroppableEvent).forEach(function (key) {
|
|
if (key === "default" || key === "__esModule") return;
|
|
Object.defineProperty(exports, key, {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _DroppableEvent[key];
|
|
}
|
|
});
|
|
});
|
|
|
|
/***/ }),
|
|
/* 12 */
|
|
/***/ (function(module, exports, __nested_webpack_require_12062__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _Announcement = __nested_webpack_require_12062__(68);
|
|
|
|
Object.defineProperty(exports, 'Announcement', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _interopRequireDefault(_Announcement).default;
|
|
}
|
|
});
|
|
Object.defineProperty(exports, 'defaultAnnouncementOptions', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _Announcement.defaultOptions;
|
|
}
|
|
});
|
|
|
|
var _Focusable = __nested_webpack_require_12062__(65);
|
|
|
|
Object.defineProperty(exports, 'Focusable', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _interopRequireDefault(_Focusable).default;
|
|
}
|
|
});
|
|
|
|
var _Mirror = __nested_webpack_require_12062__(63);
|
|
|
|
Object.defineProperty(exports, 'Mirror', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _interopRequireDefault(_Mirror).default;
|
|
}
|
|
});
|
|
Object.defineProperty(exports, 'defaultMirrorOptions', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _Mirror.defaultOptions;
|
|
}
|
|
});
|
|
|
|
var _Scrollable = __nested_webpack_require_12062__(59);
|
|
|
|
Object.defineProperty(exports, 'Scrollable', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _interopRequireDefault(_Scrollable).default;
|
|
}
|
|
});
|
|
Object.defineProperty(exports, 'defaultScrollableOptions', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _Scrollable.defaultOptions;
|
|
}
|
|
});
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
/***/ }),
|
|
/* 13 */
|
|
/***/ (function(module, exports, __nested_webpack_require_13539__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _DraggableEvent = __nested_webpack_require_13539__(69);
|
|
|
|
Object.keys(_DraggableEvent).forEach(function (key) {
|
|
if (key === "default" || key === "__esModule") return;
|
|
Object.defineProperty(exports, key, {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _DraggableEvent[key];
|
|
}
|
|
});
|
|
});
|
|
|
|
/***/ }),
|
|
/* 14 */
|
|
/***/ (function(module, exports, __nested_webpack_require_13993__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _DragEvent = __nested_webpack_require_13993__(71);
|
|
|
|
Object.keys(_DragEvent).forEach(function (key) {
|
|
if (key === "default" || key === "__esModule") return;
|
|
Object.defineProperty(exports, key, {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _DragEvent[key];
|
|
}
|
|
});
|
|
});
|
|
|
|
/***/ }),
|
|
/* 15 */
|
|
/***/ (function(module, exports, __nested_webpack_require_14432__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.defaultOptions = undefined;
|
|
|
|
var _extends = Object.assign || 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; };
|
|
|
|
var _AbstractPlugin = __nested_webpack_require_14432__(0);
|
|
|
|
var _AbstractPlugin2 = _interopRequireDefault(_AbstractPlugin);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
const onSortableSorted = Symbol('onSortableSorted');
|
|
const onSortableSort = Symbol('onSortableSort');
|
|
|
|
/**
|
|
* SortAnimation default options
|
|
* @property {Object} defaultOptions
|
|
* @property {Number} defaultOptions.duration
|
|
* @property {String} defaultOptions.easingFunction
|
|
* @type {Object}
|
|
*/
|
|
const defaultOptions = exports.defaultOptions = {
|
|
duration: 150,
|
|
easingFunction: 'ease-in-out'
|
|
};
|
|
|
|
/**
|
|
* SortAnimation plugin adds sort animation for sortable
|
|
* @class SortAnimation
|
|
* @module SortAnimation
|
|
* @extends AbstractPlugin
|
|
*/
|
|
class SortAnimation extends _AbstractPlugin2.default {
|
|
/**
|
|
* SortAnimation constructor.
|
|
* @constructs SortAnimation
|
|
* @param {Draggable} draggable - Draggable instance
|
|
*/
|
|
constructor(draggable) {
|
|
super(draggable);
|
|
|
|
/**
|
|
* SortAnimation options
|
|
* @property {Object} options
|
|
* @property {Number} defaultOptions.duration
|
|
* @property {String} defaultOptions.easingFunction
|
|
* @type {Object}
|
|
*/
|
|
this.options = _extends({}, defaultOptions, this.getOptions());
|
|
|
|
/**
|
|
* Last animation frame
|
|
* @property {Number} lastAnimationFrame
|
|
* @type {Number}
|
|
*/
|
|
this.lastAnimationFrame = null;
|
|
this.lastElements = [];
|
|
|
|
this[onSortableSorted] = this[onSortableSorted].bind(this);
|
|
this[onSortableSort] = this[onSortableSort].bind(this);
|
|
}
|
|
|
|
/**
|
|
* Attaches plugins event listeners
|
|
*/
|
|
attach() {
|
|
this.draggable.on('sortable:sort', this[onSortableSort]);
|
|
this.draggable.on('sortable:sorted', this[onSortableSorted]);
|
|
}
|
|
|
|
/**
|
|
* Detaches plugins event listeners
|
|
*/
|
|
detach() {
|
|
this.draggable.off('sortable:sort', this[onSortableSort]);
|
|
this.draggable.off('sortable:sorted', this[onSortableSorted]);
|
|
}
|
|
|
|
/**
|
|
* Returns options passed through draggable
|
|
* @return {Object}
|
|
*/
|
|
getOptions() {
|
|
return this.draggable.options.sortAnimation || {};
|
|
}
|
|
|
|
/**
|
|
* Sortable sort handler
|
|
* @param {SortableSortEvent} sortableEvent
|
|
* @private
|
|
*/
|
|
[onSortableSort]({ dragEvent }) {
|
|
const { sourceContainer } = dragEvent;
|
|
const elements = this.draggable.getDraggableElementsForContainer(sourceContainer);
|
|
this.lastElements = Array.from(elements).map(el => {
|
|
return {
|
|
domEl: el,
|
|
offsetTop: el.offsetTop,
|
|
offsetLeft: el.offsetLeft
|
|
};
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Sortable sorted handler
|
|
* @param {SortableSortedEvent} sortableEvent
|
|
* @private
|
|
*/
|
|
[onSortableSorted]({ oldIndex, newIndex }) {
|
|
if (oldIndex === newIndex) {
|
|
return;
|
|
}
|
|
|
|
const effectedElements = [];
|
|
let start;
|
|
let end;
|
|
let num;
|
|
if (oldIndex > newIndex) {
|
|
start = newIndex;
|
|
end = oldIndex - 1;
|
|
num = 1;
|
|
} else {
|
|
start = oldIndex + 1;
|
|
end = newIndex;
|
|
num = -1;
|
|
}
|
|
|
|
for (let i = start; i <= end; i++) {
|
|
const from = this.lastElements[i];
|
|
const to = this.lastElements[i + num];
|
|
effectedElements.push({ from, to });
|
|
}
|
|
cancelAnimationFrame(this.lastAnimationFrame);
|
|
|
|
// Can be done in a separate frame
|
|
this.lastAnimationFrame = requestAnimationFrame(() => {
|
|
effectedElements.forEach(element => animate(element, this.options));
|
|
});
|
|
}
|
|
}
|
|
|
|
exports.default = SortAnimation; /**
|
|
* Animates two elements
|
|
* @param {Object} element
|
|
* @param {Object} element.from
|
|
* @param {Object} element.to
|
|
* @param {Object} options
|
|
* @param {Number} options.duration
|
|
* @param {String} options.easingFunction
|
|
* @private
|
|
*/
|
|
|
|
function animate({ from, to }, { duration, easingFunction }) {
|
|
const domEl = from.domEl;
|
|
const x = from.offsetLeft - to.offsetLeft;
|
|
const y = from.offsetTop - to.offsetTop;
|
|
|
|
domEl.style.pointerEvents = 'none';
|
|
domEl.style.transform = `translate3d(${x}px, ${y}px, 0)`;
|
|
|
|
requestAnimationFrame(() => {
|
|
domEl.addEventListener('transitionend', resetElementOnTransitionEnd);
|
|
domEl.style.transition = `transform ${duration}ms ${easingFunction}`;
|
|
domEl.style.transform = '';
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Resets animation style properties after animation has completed
|
|
* @param {Event} event
|
|
* @private
|
|
*/
|
|
function resetElementOnTransitionEnd(event) {
|
|
event.target.style.transition = '';
|
|
event.target.style.pointerEvents = '';
|
|
event.target.removeEventListener('transitionend', resetElementOnTransitionEnd);
|
|
}
|
|
|
|
/***/ }),
|
|
/* 16 */
|
|
/***/ (function(module, exports, __nested_webpack_require_19715__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.defaultOptions = undefined;
|
|
|
|
var _SortAnimation = __nested_webpack_require_19715__(15);
|
|
|
|
var _SortAnimation2 = _interopRequireDefault(_SortAnimation);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _SortAnimation2.default;
|
|
exports.defaultOptions = _SortAnimation.defaultOptions;
|
|
|
|
/***/ }),
|
|
/* 17 */
|
|
/***/ (function(module, exports, __nested_webpack_require_20216__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.defaultOptions = undefined;
|
|
|
|
var _extends = Object.assign || 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; };
|
|
|
|
var _AbstractPlugin = __nested_webpack_require_20216__(0);
|
|
|
|
var _AbstractPlugin2 = _interopRequireDefault(_AbstractPlugin);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
const onSortableSorted = Symbol('onSortableSorted');
|
|
|
|
/**
|
|
* SwapAnimation default options
|
|
* @property {Object} defaultOptions
|
|
* @property {Number} defaultOptions.duration
|
|
* @property {String} defaultOptions.easingFunction
|
|
* @property {Boolean} defaultOptions.horizontal
|
|
* @type {Object}
|
|
*/
|
|
const defaultOptions = exports.defaultOptions = {
|
|
duration: 150,
|
|
easingFunction: 'ease-in-out',
|
|
horizontal: false
|
|
};
|
|
|
|
/**
|
|
* SwapAnimation plugin adds swap animations for sortable
|
|
* @class SwapAnimation
|
|
* @module SwapAnimation
|
|
* @extends AbstractPlugin
|
|
*/
|
|
class SwapAnimation extends _AbstractPlugin2.default {
|
|
/**
|
|
* SwapAnimation constructor.
|
|
* @constructs SwapAnimation
|
|
* @param {Draggable} draggable - Draggable instance
|
|
*/
|
|
constructor(draggable) {
|
|
super(draggable);
|
|
|
|
/**
|
|
* SwapAnimation options
|
|
* @property {Object} options
|
|
* @property {Number} defaultOptions.duration
|
|
* @property {String} defaultOptions.easingFunction
|
|
* @type {Object}
|
|
*/
|
|
this.options = _extends({}, defaultOptions, this.getOptions());
|
|
|
|
/**
|
|
* Last animation frame
|
|
* @property {Number} lastAnimationFrame
|
|
* @type {Number}
|
|
*/
|
|
this.lastAnimationFrame = null;
|
|
|
|
this[onSortableSorted] = this[onSortableSorted].bind(this);
|
|
}
|
|
|
|
/**
|
|
* Attaches plugins event listeners
|
|
*/
|
|
attach() {
|
|
this.draggable.on('sortable:sorted', this[onSortableSorted]);
|
|
}
|
|
|
|
/**
|
|
* Detaches plugins event listeners
|
|
*/
|
|
detach() {
|
|
this.draggable.off('sortable:sorted', this[onSortableSorted]);
|
|
}
|
|
|
|
/**
|
|
* Returns options passed through draggable
|
|
* @return {Object}
|
|
*/
|
|
getOptions() {
|
|
return this.draggable.options.swapAnimation || {};
|
|
}
|
|
|
|
/**
|
|
* Sortable sorted handler
|
|
* @param {SortableSortedEvent} sortableEvent
|
|
* @private
|
|
*/
|
|
[onSortableSorted]({ oldIndex, newIndex, dragEvent }) {
|
|
const { source, over } = dragEvent;
|
|
|
|
cancelAnimationFrame(this.lastAnimationFrame);
|
|
|
|
// Can be done in a separate frame
|
|
this.lastAnimationFrame = requestAnimationFrame(() => {
|
|
if (oldIndex >= newIndex) {
|
|
animate(source, over, this.options);
|
|
} else {
|
|
animate(over, source, this.options);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
exports.default = SwapAnimation; /**
|
|
* Animates two elements
|
|
* @param {HTMLElement} from
|
|
* @param {HTMLElement} to
|
|
* @param {Object} options
|
|
* @param {Number} options.duration
|
|
* @param {String} options.easingFunction
|
|
* @param {String} options.horizontal
|
|
* @private
|
|
*/
|
|
|
|
function animate(from, to, { duration, easingFunction, horizontal }) {
|
|
for (const element of [from, to]) {
|
|
element.style.pointerEvents = 'none';
|
|
}
|
|
|
|
if (horizontal) {
|
|
const width = from.offsetWidth;
|
|
from.style.transform = `translate3d(${width}px, 0, 0)`;
|
|
to.style.transform = `translate3d(-${width}px, 0, 0)`;
|
|
} else {
|
|
const height = from.offsetHeight;
|
|
from.style.transform = `translate3d(0, ${height}px, 0)`;
|
|
to.style.transform = `translate3d(0, -${height}px, 0)`;
|
|
}
|
|
|
|
requestAnimationFrame(() => {
|
|
for (const element of [from, to]) {
|
|
element.addEventListener('transitionend', resetElementOnTransitionEnd);
|
|
element.style.transition = `transform ${duration}ms ${easingFunction}`;
|
|
element.style.transform = '';
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Resets animation style properties after animation has completed
|
|
* @param {Event} event
|
|
* @private
|
|
*/
|
|
function resetElementOnTransitionEnd(event) {
|
|
event.target.style.transition = '';
|
|
event.target.style.pointerEvents = '';
|
|
event.target.removeEventListener('transitionend', resetElementOnTransitionEnd);
|
|
}
|
|
|
|
/***/ }),
|
|
/* 18 */
|
|
/***/ (function(module, exports, __nested_webpack_require_24791__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.defaultOptions = undefined;
|
|
|
|
var _SwapAnimation = __nested_webpack_require_24791__(17);
|
|
|
|
var _SwapAnimation2 = _interopRequireDefault(_SwapAnimation);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _SwapAnimation2.default;
|
|
exports.defaultOptions = _SwapAnimation.defaultOptions;
|
|
|
|
/***/ }),
|
|
/* 19 */
|
|
/***/ (function(module, exports, __nested_webpack_require_25292__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _AbstractPlugin = __nested_webpack_require_25292__(0);
|
|
|
|
var _AbstractPlugin2 = _interopRequireDefault(_AbstractPlugin);
|
|
|
|
var _SnappableEvent = __nested_webpack_require_25292__(7);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
const onDragStart = Symbol('onDragStart');
|
|
const onDragStop = Symbol('onDragStop');
|
|
const onDragOver = Symbol('onDragOver');
|
|
const onDragOut = Symbol('onDragOut');
|
|
const onMirrorCreated = Symbol('onMirrorCreated');
|
|
const onMirrorDestroy = Symbol('onMirrorDestroy');
|
|
|
|
/**
|
|
* Snappable plugin which snaps draggable elements into place
|
|
* @class Snappable
|
|
* @module Snappable
|
|
* @extends AbstractPlugin
|
|
*/
|
|
class Snappable extends _AbstractPlugin2.default {
|
|
/**
|
|
* Snappable constructor.
|
|
* @constructs Snappable
|
|
* @param {Draggable} draggable - Draggable instance
|
|
*/
|
|
constructor(draggable) {
|
|
super(draggable);
|
|
|
|
/**
|
|
* Keeps track of the first source element
|
|
* @property {HTMLElement|null} firstSource
|
|
*/
|
|
this.firstSource = null;
|
|
|
|
/**
|
|
* Keeps track of the mirror element
|
|
* @property {HTMLElement} mirror
|
|
*/
|
|
this.mirror = null;
|
|
|
|
this[onDragStart] = this[onDragStart].bind(this);
|
|
this[onDragStop] = this[onDragStop].bind(this);
|
|
this[onDragOver] = this[onDragOver].bind(this);
|
|
this[onDragOut] = this[onDragOut].bind(this);
|
|
this[onMirrorCreated] = this[onMirrorCreated].bind(this);
|
|
this[onMirrorDestroy] = this[onMirrorDestroy].bind(this);
|
|
}
|
|
|
|
/**
|
|
* Attaches plugins event listeners
|
|
*/
|
|
attach() {
|
|
this.draggable.on('drag:start', this[onDragStart]).on('drag:stop', this[onDragStop]).on('drag:over', this[onDragOver]).on('drag:out', this[onDragOut]).on('droppable:over', this[onDragOver]).on('droppable:out', this[onDragOut]).on('mirror:created', this[onMirrorCreated]).on('mirror:destroy', this[onMirrorDestroy]);
|
|
}
|
|
|
|
/**
|
|
* Detaches plugins event listeners
|
|
*/
|
|
detach() {
|
|
this.draggable.off('drag:start', this[onDragStart]).off('drag:stop', this[onDragStop]).off('drag:over', this[onDragOver]).off('drag:out', this[onDragOut]).off('droppable:over', this[onDragOver]).off('droppable:out', this[onDragOut]).off('mirror:created', this[onMirrorCreated]).off('mirror:destroy', this[onMirrorDestroy]);
|
|
}
|
|
|
|
/**
|
|
* Drag start handler
|
|
* @private
|
|
* @param {DragStartEvent} event - Drag start event
|
|
*/
|
|
[onDragStart](event) {
|
|
if (event.canceled()) {
|
|
return;
|
|
}
|
|
|
|
this.firstSource = event.source;
|
|
}
|
|
|
|
/**
|
|
* Drag stop handler
|
|
* @private
|
|
* @param {DragStopEvent} event - Drag stop event
|
|
*/
|
|
[onDragStop]() {
|
|
this.firstSource = null;
|
|
}
|
|
|
|
/**
|
|
* Drag over handler
|
|
* @private
|
|
* @param {DragOverEvent|DroppableOverEvent} event - Drag over event
|
|
*/
|
|
[onDragOver](event) {
|
|
if (event.canceled()) {
|
|
return;
|
|
}
|
|
|
|
const source = event.source || event.dragEvent.source;
|
|
|
|
if (source === this.firstSource) {
|
|
this.firstSource = null;
|
|
return;
|
|
}
|
|
|
|
const snapInEvent = new _SnappableEvent.SnapInEvent({
|
|
dragEvent: event,
|
|
snappable: event.over || event.droppable
|
|
});
|
|
|
|
this.draggable.trigger(snapInEvent);
|
|
|
|
if (snapInEvent.canceled()) {
|
|
return;
|
|
}
|
|
|
|
if (this.mirror) {
|
|
this.mirror.style.display = 'none';
|
|
}
|
|
|
|
source.classList.remove(...this.draggable.getClassNamesFor('source:dragging'));
|
|
source.classList.add(...this.draggable.getClassNamesFor('source:placed'));
|
|
|
|
// Need to cancel this in drag out
|
|
setTimeout(() => {
|
|
source.classList.remove(...this.draggable.getClassNamesFor('source:placed'));
|
|
}, this.draggable.options.placedTimeout);
|
|
}
|
|
|
|
/**
|
|
* Drag out handler
|
|
* @private
|
|
* @param {DragOutEvent|DroppableOutEvent} event - Drag out event
|
|
*/
|
|
[onDragOut](event) {
|
|
if (event.canceled()) {
|
|
return;
|
|
}
|
|
|
|
const source = event.source || event.dragEvent.source;
|
|
|
|
const snapOutEvent = new _SnappableEvent.SnapOutEvent({
|
|
dragEvent: event,
|
|
snappable: event.over || event.droppable
|
|
});
|
|
|
|
this.draggable.trigger(snapOutEvent);
|
|
|
|
if (snapOutEvent.canceled()) {
|
|
return;
|
|
}
|
|
|
|
if (this.mirror) {
|
|
this.mirror.style.display = '';
|
|
}
|
|
|
|
source.classList.add(...this.draggable.getClassNamesFor('source:dragging'));
|
|
}
|
|
|
|
/**
|
|
* Mirror created handler
|
|
* @param {MirrorCreatedEvent} mirrorEvent
|
|
* @private
|
|
*/
|
|
[onMirrorCreated]({ mirror }) {
|
|
this.mirror = mirror;
|
|
}
|
|
|
|
/**
|
|
* Mirror destroy handler
|
|
* @param {MirrorDestroyEvent} mirrorEvent
|
|
* @private
|
|
*/
|
|
[onMirrorDestroy]() {
|
|
this.mirror = null;
|
|
}
|
|
}
|
|
exports.default = Snappable;
|
|
|
|
/***/ }),
|
|
/* 20 */
|
|
/***/ (function(module, exports, __nested_webpack_require_30090__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.SnapOutEvent = exports.SnapInEvent = exports.SnapEvent = undefined;
|
|
|
|
var _AbstractEvent = __nested_webpack_require_30090__(1);
|
|
|
|
var _AbstractEvent2 = _interopRequireDefault(_AbstractEvent);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
/**
|
|
* Base snap event
|
|
* @class SnapEvent
|
|
* @module SnapEvent
|
|
* @extends AbstractEvent
|
|
*/
|
|
class SnapEvent extends _AbstractEvent2.default {
|
|
|
|
/**
|
|
* Drag event that triggered this snap event
|
|
* @property dragEvent
|
|
* @type {DragEvent}
|
|
* @readonly
|
|
*/
|
|
get dragEvent() {
|
|
return this.data.dragEvent;
|
|
}
|
|
|
|
/**
|
|
* Snappable element
|
|
* @property snappable
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get snappable() {
|
|
return this.data.snappable;
|
|
}
|
|
}
|
|
|
|
exports.SnapEvent = SnapEvent; /**
|
|
* Snap in event
|
|
* @class SnapInEvent
|
|
* @module SnapInEvent
|
|
* @extends SnapEvent
|
|
*/
|
|
|
|
SnapEvent.type = 'snap';
|
|
class SnapInEvent extends SnapEvent {}
|
|
|
|
exports.SnapInEvent = SnapInEvent; /**
|
|
* Snap out event
|
|
* @class SnapOutEvent
|
|
* @module SnapOutEvent
|
|
* @extends SnapEvent
|
|
*/
|
|
|
|
SnapInEvent.type = 'snap:in';
|
|
SnapInEvent.cancelable = true;
|
|
class SnapOutEvent extends SnapEvent {}
|
|
exports.SnapOutEvent = SnapOutEvent;
|
|
SnapOutEvent.type = 'snap:out';
|
|
SnapOutEvent.cancelable = true;
|
|
|
|
/***/ }),
|
|
/* 21 */
|
|
/***/ (function(module, exports, __nested_webpack_require_31866__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _SnappableEvent = __nested_webpack_require_31866__(7);
|
|
|
|
Object.keys(_SnappableEvent).forEach(function (key) {
|
|
if (key === "default" || key === "__esModule") return;
|
|
Object.defineProperty(exports, key, {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _SnappableEvent[key];
|
|
}
|
|
});
|
|
});
|
|
|
|
var _Snappable = __nested_webpack_require_31866__(19);
|
|
|
|
var _Snappable2 = _interopRequireDefault(_Snappable);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _Snappable2.default;
|
|
|
|
/***/ }),
|
|
/* 22 */
|
|
/***/ (function(module, exports, __nested_webpack_require_32554__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.defaultOptions = undefined;
|
|
|
|
var _extends = Object.assign || 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; };
|
|
|
|
var _AbstractPlugin = __nested_webpack_require_32554__(0);
|
|
|
|
var _AbstractPlugin2 = _interopRequireDefault(_AbstractPlugin);
|
|
|
|
var _utils = __nested_webpack_require_32554__(2);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
const onMirrorCreated = Symbol('onMirrorCreated');
|
|
const onMirrorDestroy = Symbol('onMirrorDestroy');
|
|
const onDragOver = Symbol('onDragOver');
|
|
const resize = Symbol('resize');
|
|
|
|
/**
|
|
* ResizeMirror default options
|
|
* @property {Object} defaultOptions
|
|
* @type {Object}
|
|
*/
|
|
const defaultOptions = exports.defaultOptions = {};
|
|
|
|
/**
|
|
* The ResizeMirror plugin resizes the mirror element to the dimensions of the draggable element that the mirror is hovering over
|
|
* @class ResizeMirror
|
|
* @module ResizeMirror
|
|
* @extends AbstractPlugin
|
|
*/
|
|
class ResizeMirror extends _AbstractPlugin2.default {
|
|
/**
|
|
* ResizeMirror constructor.
|
|
* @constructs ResizeMirror
|
|
* @param {Draggable} draggable - Draggable instance
|
|
*/
|
|
constructor(draggable) {
|
|
super(draggable);
|
|
|
|
/**
|
|
* ResizeMirror options
|
|
* @property {Object} options
|
|
* @type {Object}
|
|
*/
|
|
this.options = _extends({}, defaultOptions, this.getOptions());
|
|
|
|
/**
|
|
* ResizeMirror remembers the last width when resizing the mirror
|
|
* to avoid additional writes to the DOM
|
|
* @property {number} lastWidth
|
|
*/
|
|
this.lastWidth = 0;
|
|
|
|
/**
|
|
* ResizeMirror remembers the last height when resizing the mirror
|
|
* to avoid additional writes to the DOM
|
|
* @property {number} lastHeight
|
|
*/
|
|
this.lastHeight = 0;
|
|
|
|
/**
|
|
* Keeps track of the mirror element
|
|
* @property {HTMLElement} mirror
|
|
*/
|
|
this.mirror = null;
|
|
|
|
this[onMirrorCreated] = this[onMirrorCreated].bind(this);
|
|
this[onMirrorDestroy] = this[onMirrorDestroy].bind(this);
|
|
this[onDragOver] = this[onDragOver].bind(this);
|
|
}
|
|
|
|
/**
|
|
* Attaches plugins event listeners
|
|
*/
|
|
attach() {
|
|
this.draggable.on('mirror:created', this[onMirrorCreated]).on('drag:over', this[onDragOver]).on('drag:over:container', this[onDragOver]);
|
|
}
|
|
|
|
/**
|
|
* Detaches plugins event listeners
|
|
*/
|
|
detach() {
|
|
this.draggable.off('mirror:created', this[onMirrorCreated]).off('mirror:destroy', this[onMirrorDestroy]).off('drag:over', this[onDragOver]).off('drag:over:container', this[onDragOver]);
|
|
}
|
|
|
|
/**
|
|
* Returns options passed through draggable
|
|
* @return {Object}
|
|
*/
|
|
getOptions() {
|
|
return this.draggable.options.resizeMirror || {};
|
|
}
|
|
|
|
/**
|
|
* Mirror created handler
|
|
* @param {MirrorCreatedEvent} mirrorEvent
|
|
* @private
|
|
*/
|
|
[onMirrorCreated]({ mirror }) {
|
|
this.mirror = mirror;
|
|
}
|
|
|
|
/**
|
|
* Mirror destroy handler
|
|
* @param {MirrorDestroyEvent} mirrorEvent
|
|
* @private
|
|
*/
|
|
[onMirrorDestroy]() {
|
|
this.mirror = null;
|
|
}
|
|
|
|
/**
|
|
* Drag over handler
|
|
* @param {DragOverEvent | DragOverContainer} dragEvent
|
|
* @private
|
|
*/
|
|
[onDragOver](dragEvent) {
|
|
this[resize](dragEvent);
|
|
}
|
|
|
|
/**
|
|
* Resize function for
|
|
* @param {DragOverEvent | DragOverContainer} dragEvent
|
|
* @private
|
|
*/
|
|
[resize]({ overContainer, over }) {
|
|
requestAnimationFrame(() => {
|
|
if (!this.mirror.parentNode) {
|
|
return;
|
|
}
|
|
|
|
if (this.mirror.parentNode !== overContainer) {
|
|
overContainer.appendChild(this.mirror);
|
|
}
|
|
|
|
const overElement = over || this.draggable.getDraggableElementsForContainer(overContainer)[0];
|
|
|
|
if (!overElement) {
|
|
return;
|
|
}
|
|
|
|
(0, _utils.requestNextAnimationFrame)(() => {
|
|
const overRect = overElement.getBoundingClientRect();
|
|
|
|
if (this.lastHeight === overRect.height && this.lastWidth === overRect.width) {
|
|
return;
|
|
}
|
|
|
|
this.mirror.style.width = `${overRect.width}px`;
|
|
this.mirror.style.height = `${overRect.height}px`;
|
|
|
|
this.lastWidth = overRect.width;
|
|
this.lastHeight = overRect.height;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
exports.default = ResizeMirror;
|
|
|
|
/***/ }),
|
|
/* 23 */
|
|
/***/ (function(module, exports, __nested_webpack_require_36986__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.defaultOptions = undefined;
|
|
|
|
var _ResizeMirror = __nested_webpack_require_36986__(22);
|
|
|
|
var _ResizeMirror2 = _interopRequireDefault(_ResizeMirror);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _ResizeMirror2.default;
|
|
exports.defaultOptions = _ResizeMirror.defaultOptions;
|
|
|
|
/***/ }),
|
|
/* 24 */
|
|
/***/ (function(module, exports, __nested_webpack_require_37482__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _AbstractPlugin = __nested_webpack_require_37482__(0);
|
|
|
|
var _AbstractPlugin2 = _interopRequireDefault(_AbstractPlugin);
|
|
|
|
var _utils = __nested_webpack_require_37482__(2);
|
|
|
|
var _CollidableEvent = __nested_webpack_require_37482__(8);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
const onDragMove = Symbol('onDragMove');
|
|
const onDragStop = Symbol('onDragStop');
|
|
const onRequestAnimationFrame = Symbol('onRequestAnimationFrame');
|
|
|
|
/**
|
|
* Collidable plugin which detects colliding elements while dragging
|
|
* @class Collidable
|
|
* @module Collidable
|
|
* @extends AbstractPlugin
|
|
*/
|
|
class Collidable extends _AbstractPlugin2.default {
|
|
/**
|
|
* Collidable constructor.
|
|
* @constructs Collidable
|
|
* @param {Draggable} draggable - Draggable instance
|
|
*/
|
|
constructor(draggable) {
|
|
super(draggable);
|
|
|
|
/**
|
|
* Keeps track of currently colliding elements
|
|
* @property {HTMLElement|null} currentlyCollidingElement
|
|
* @type {HTMLElement|null}
|
|
*/
|
|
this.currentlyCollidingElement = null;
|
|
|
|
/**
|
|
* Keeps track of currently colliding elements
|
|
* @property {HTMLElement|null} lastCollidingElement
|
|
* @type {HTMLElement|null}
|
|
*/
|
|
this.lastCollidingElement = null;
|
|
|
|
/**
|
|
* Animation frame for finding colliding elements
|
|
* @property {Number|null} currentAnimationFrame
|
|
* @type {Number|null}
|
|
*/
|
|
this.currentAnimationFrame = null;
|
|
|
|
this[onDragMove] = this[onDragMove].bind(this);
|
|
this[onDragStop] = this[onDragStop].bind(this);
|
|
this[onRequestAnimationFrame] = this[onRequestAnimationFrame].bind(this);
|
|
}
|
|
|
|
/**
|
|
* Attaches plugins event listeners
|
|
*/
|
|
attach() {
|
|
this.draggable.on('drag:move', this[onDragMove]).on('drag:stop', this[onDragStop]);
|
|
}
|
|
|
|
/**
|
|
* Detaches plugins event listeners
|
|
*/
|
|
detach() {
|
|
this.draggable.off('drag:move', this[onDragMove]).off('drag:stop', this[onDragStop]);
|
|
}
|
|
|
|
/**
|
|
* Returns current collidables based on `collidables` option
|
|
* @return {HTMLElement[]}
|
|
*/
|
|
getCollidables() {
|
|
const collidables = this.draggable.options.collidables;
|
|
|
|
if (typeof collidables === 'string') {
|
|
return Array.prototype.slice.call(document.querySelectorAll(collidables));
|
|
} else if (collidables instanceof NodeList || collidables instanceof Array) {
|
|
return Array.prototype.slice.call(collidables);
|
|
} else if (collidables instanceof HTMLElement) {
|
|
return [collidables];
|
|
} else if (typeof collidables === 'function') {
|
|
return collidables();
|
|
} else {
|
|
return [];
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Drag move handler
|
|
* @private
|
|
* @param {DragMoveEvent} event - Drag move event
|
|
*/
|
|
[onDragMove](event) {
|
|
const target = event.sensorEvent.target;
|
|
|
|
this.currentAnimationFrame = requestAnimationFrame(this[onRequestAnimationFrame](target));
|
|
|
|
if (this.currentlyCollidingElement) {
|
|
event.cancel();
|
|
}
|
|
|
|
const collidableInEvent = new _CollidableEvent.CollidableInEvent({
|
|
dragEvent: event,
|
|
collidingElement: this.currentlyCollidingElement
|
|
});
|
|
|
|
const collidableOutEvent = new _CollidableEvent.CollidableOutEvent({
|
|
dragEvent: event,
|
|
collidingElement: this.lastCollidingElement
|
|
});
|
|
|
|
const enteringCollidable = Boolean(this.currentlyCollidingElement && this.lastCollidingElement !== this.currentlyCollidingElement);
|
|
const leavingCollidable = Boolean(!this.currentlyCollidingElement && this.lastCollidingElement);
|
|
|
|
if (enteringCollidable) {
|
|
if (this.lastCollidingElement) {
|
|
this.draggable.trigger(collidableOutEvent);
|
|
}
|
|
|
|
this.draggable.trigger(collidableInEvent);
|
|
} else if (leavingCollidable) {
|
|
this.draggable.trigger(collidableOutEvent);
|
|
}
|
|
|
|
this.lastCollidingElement = this.currentlyCollidingElement;
|
|
}
|
|
|
|
/**
|
|
* Drag stop handler
|
|
* @private
|
|
* @param {DragStopEvent} event - Drag stop event
|
|
*/
|
|
[onDragStop](event) {
|
|
const lastCollidingElement = this.currentlyCollidingElement || this.lastCollidingElement;
|
|
const collidableOutEvent = new _CollidableEvent.CollidableOutEvent({
|
|
dragEvent: event,
|
|
collidingElement: lastCollidingElement
|
|
});
|
|
|
|
if (lastCollidingElement) {
|
|
this.draggable.trigger(collidableOutEvent);
|
|
}
|
|
|
|
this.lastCollidingElement = null;
|
|
this.currentlyCollidingElement = null;
|
|
}
|
|
|
|
/**
|
|
* Animation frame function
|
|
* @private
|
|
* @param {HTMLElement} target - Current move target
|
|
* @return {Function}
|
|
*/
|
|
[onRequestAnimationFrame](target) {
|
|
return () => {
|
|
const collidables = this.getCollidables();
|
|
this.currentlyCollidingElement = (0, _utils.closest)(target, element => collidables.includes(element));
|
|
};
|
|
}
|
|
}
|
|
exports.default = Collidable;
|
|
|
|
/***/ }),
|
|
/* 25 */
|
|
/***/ (function(module, exports, __nested_webpack_require_42369__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.CollidableOutEvent = exports.CollidableInEvent = exports.CollidableEvent = undefined;
|
|
|
|
var _AbstractEvent = __nested_webpack_require_42369__(1);
|
|
|
|
var _AbstractEvent2 = _interopRequireDefault(_AbstractEvent);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
/**
|
|
* Base collidable event
|
|
* @class CollidableEvent
|
|
* @module CollidableEvent
|
|
* @extends AbstractEvent
|
|
*/
|
|
class CollidableEvent extends _AbstractEvent2.default {
|
|
|
|
/**
|
|
* Drag event that triggered this colliable event
|
|
* @property dragEvent
|
|
* @type {DragEvent}
|
|
* @readonly
|
|
*/
|
|
get dragEvent() {
|
|
return this.data.dragEvent;
|
|
}
|
|
}
|
|
|
|
exports.CollidableEvent = CollidableEvent; /**
|
|
* Collidable in event
|
|
* @class CollidableInEvent
|
|
* @module CollidableInEvent
|
|
* @extends CollidableEvent
|
|
*/
|
|
|
|
CollidableEvent.type = 'collidable';
|
|
class CollidableInEvent extends CollidableEvent {
|
|
|
|
/**
|
|
* Element you are currently colliding with
|
|
* @property collidingElement
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get collidingElement() {
|
|
return this.data.collidingElement;
|
|
}
|
|
}
|
|
|
|
exports.CollidableInEvent = CollidableInEvent; /**
|
|
* Collidable out event
|
|
* @class CollidableOutEvent
|
|
* @module CollidableOutEvent
|
|
* @extends CollidableEvent
|
|
*/
|
|
|
|
CollidableInEvent.type = 'collidable:in';
|
|
class CollidableOutEvent extends CollidableEvent {
|
|
|
|
/**
|
|
* Element you were previously colliding with
|
|
* @property collidingElement
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get collidingElement() {
|
|
return this.data.collidingElement;
|
|
}
|
|
}
|
|
exports.CollidableOutEvent = CollidableOutEvent;
|
|
CollidableOutEvent.type = 'collidable:out';
|
|
|
|
/***/ }),
|
|
/* 26 */
|
|
/***/ (function(module, exports, __nested_webpack_require_44642__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _CollidableEvent = __nested_webpack_require_44642__(8);
|
|
|
|
Object.keys(_CollidableEvent).forEach(function (key) {
|
|
if (key === "default" || key === "__esModule") return;
|
|
Object.defineProperty(exports, key, {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _CollidableEvent[key];
|
|
}
|
|
});
|
|
});
|
|
|
|
var _Collidable = __nested_webpack_require_44642__(24);
|
|
|
|
var _Collidable2 = _interopRequireDefault(_Collidable);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _Collidable2.default;
|
|
|
|
/***/ }),
|
|
/* 27 */
|
|
/***/ (function(module, exports, __nested_webpack_require_45337__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _Collidable = __nested_webpack_require_45337__(26);
|
|
|
|
Object.defineProperty(exports, 'Collidable', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _interopRequireDefault(_Collidable).default;
|
|
}
|
|
});
|
|
|
|
var _ResizeMirror = __nested_webpack_require_45337__(23);
|
|
|
|
Object.defineProperty(exports, 'ResizeMirror', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _interopRequireDefault(_ResizeMirror).default;
|
|
}
|
|
});
|
|
Object.defineProperty(exports, 'defaultResizeMirrorOptions', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _ResizeMirror.defaultOptions;
|
|
}
|
|
});
|
|
|
|
var _Snappable = __nested_webpack_require_45337__(21);
|
|
|
|
Object.defineProperty(exports, 'Snappable', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _interopRequireDefault(_Snappable).default;
|
|
}
|
|
});
|
|
|
|
var _SwapAnimation = __nested_webpack_require_45337__(18);
|
|
|
|
Object.defineProperty(exports, 'SwapAnimation', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _interopRequireDefault(_SwapAnimation).default;
|
|
}
|
|
});
|
|
Object.defineProperty(exports, 'defaultSwapAnimationOptions', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _SwapAnimation.defaultOptions;
|
|
}
|
|
});
|
|
|
|
var _SortAnimation = __nested_webpack_require_45337__(16);
|
|
|
|
Object.defineProperty(exports, 'SortAnimation', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _interopRequireDefault(_SortAnimation).default;
|
|
}
|
|
});
|
|
Object.defineProperty(exports, 'defaultSortAnimationOptions', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _SortAnimation.defaultOptions;
|
|
}
|
|
});
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
/***/ }),
|
|
/* 28 */
|
|
/***/ (function(module, exports, __nested_webpack_require_47061__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _extends = Object.assign || 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; };
|
|
|
|
var _Draggable = __nested_webpack_require_47061__(5);
|
|
|
|
var _Draggable2 = _interopRequireDefault(_Draggable);
|
|
|
|
var _SortableEvent = __nested_webpack_require_47061__(9);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
const onDragStart = Symbol('onDragStart');
|
|
const onDragOverContainer = Symbol('onDragOverContainer');
|
|
const onDragOver = Symbol('onDragOver');
|
|
const onDragStop = Symbol('onDragStop');
|
|
|
|
/**
|
|
* Returns announcement message when a Draggable element has been sorted with another Draggable element
|
|
* or moved into a new container
|
|
* @param {SortableSortedEvent} sortableEvent
|
|
* @return {String}
|
|
*/
|
|
function onSortableSortedDefaultAnnouncement({ dragEvent }) {
|
|
const sourceText = dragEvent.source.textContent.trim() || dragEvent.source.id || 'sortable element';
|
|
|
|
if (dragEvent.over) {
|
|
const overText = dragEvent.over.textContent.trim() || dragEvent.over.id || 'sortable element';
|
|
const isFollowing = dragEvent.source.compareDocumentPosition(dragEvent.over) & Node.DOCUMENT_POSITION_FOLLOWING;
|
|
|
|
if (isFollowing) {
|
|
return `Placed ${sourceText} after ${overText}`;
|
|
} else {
|
|
return `Placed ${sourceText} before ${overText}`;
|
|
}
|
|
} else {
|
|
// need to figure out how to compute container name
|
|
return `Placed ${sourceText} into a different container`;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @const {Object} defaultAnnouncements
|
|
* @const {Function} defaultAnnouncements['sortable:sorted']
|
|
*/
|
|
const defaultAnnouncements = {
|
|
'sortable:sorted': onSortableSortedDefaultAnnouncement
|
|
};
|
|
|
|
/**
|
|
* Sortable is built on top of Draggable and allows sorting of draggable elements. Sortable will keep
|
|
* track of the original index and emits the new index as you drag over draggable elements.
|
|
* @class Sortable
|
|
* @module Sortable
|
|
* @extends Draggable
|
|
*/
|
|
class Sortable extends _Draggable2.default {
|
|
/**
|
|
* Sortable constructor.
|
|
* @constructs Sortable
|
|
* @param {HTMLElement[]|NodeList|HTMLElement} containers - Sortable containers
|
|
* @param {Object} options - Options for Sortable
|
|
*/
|
|
constructor(containers = [], options = {}) {
|
|
super(containers, _extends({}, options, {
|
|
announcements: _extends({}, defaultAnnouncements, options.announcements || {})
|
|
}));
|
|
|
|
/**
|
|
* start index of source on drag start
|
|
* @property startIndex
|
|
* @type {Number}
|
|
*/
|
|
this.startIndex = null;
|
|
|
|
/**
|
|
* start container on drag start
|
|
* @property startContainer
|
|
* @type {HTMLElement}
|
|
* @default null
|
|
*/
|
|
this.startContainer = null;
|
|
|
|
this[onDragStart] = this[onDragStart].bind(this);
|
|
this[onDragOverContainer] = this[onDragOverContainer].bind(this);
|
|
this[onDragOver] = this[onDragOver].bind(this);
|
|
this[onDragStop] = this[onDragStop].bind(this);
|
|
|
|
this.on('drag:start', this[onDragStart]).on('drag:over:container', this[onDragOverContainer]).on('drag:over', this[onDragOver]).on('drag:stop', this[onDragStop]);
|
|
}
|
|
|
|
/**
|
|
* Destroys Sortable instance.
|
|
*/
|
|
destroy() {
|
|
super.destroy();
|
|
|
|
this.off('drag:start', this[onDragStart]).off('drag:over:container', this[onDragOverContainer]).off('drag:over', this[onDragOver]).off('drag:stop', this[onDragStop]);
|
|
}
|
|
|
|
/**
|
|
* Returns true index of element within its container during drag operation, i.e. excluding mirror and original source
|
|
* @param {HTMLElement} element - An element
|
|
* @return {Number}
|
|
*/
|
|
index(element) {
|
|
return this.getSortableElementsForContainer(element.parentNode).indexOf(element);
|
|
}
|
|
|
|
/**
|
|
* Returns sortable elements for a given container, excluding the mirror and
|
|
* original source element if present
|
|
* @param {HTMLElement} container
|
|
* @return {HTMLElement[]}
|
|
*/
|
|
getSortableElementsForContainer(container) {
|
|
const allSortableElements = container.querySelectorAll(this.options.draggable);
|
|
|
|
return [...allSortableElements].filter(childElement => {
|
|
return childElement !== this.originalSource && childElement !== this.mirror && childElement.parentNode === container;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Drag start handler
|
|
* @private
|
|
* @param {DragStartEvent} event - Drag start event
|
|
*/
|
|
[onDragStart](event) {
|
|
this.startContainer = event.source.parentNode;
|
|
this.startIndex = this.index(event.source);
|
|
|
|
const sortableStartEvent = new _SortableEvent.SortableStartEvent({
|
|
dragEvent: event,
|
|
startIndex: this.startIndex,
|
|
startContainer: this.startContainer
|
|
});
|
|
|
|
this.trigger(sortableStartEvent);
|
|
|
|
if (sortableStartEvent.canceled()) {
|
|
event.cancel();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Drag over container handler
|
|
* @private
|
|
* @param {DragOverContainerEvent} event - Drag over container event
|
|
*/
|
|
[onDragOverContainer](event) {
|
|
if (event.canceled()) {
|
|
return;
|
|
}
|
|
|
|
const { source, over, overContainer } = event;
|
|
const oldIndex = this.index(source);
|
|
|
|
const sortableSortEvent = new _SortableEvent.SortableSortEvent({
|
|
dragEvent: event,
|
|
currentIndex: oldIndex,
|
|
source,
|
|
over
|
|
});
|
|
|
|
this.trigger(sortableSortEvent);
|
|
|
|
if (sortableSortEvent.canceled()) {
|
|
return;
|
|
}
|
|
|
|
const children = this.getSortableElementsForContainer(overContainer);
|
|
const moves = move({ source, over, overContainer, children });
|
|
|
|
if (!moves) {
|
|
return;
|
|
}
|
|
|
|
const { oldContainer, newContainer } = moves;
|
|
const newIndex = this.index(event.source);
|
|
|
|
const sortableSortedEvent = new _SortableEvent.SortableSortedEvent({
|
|
dragEvent: event,
|
|
oldIndex,
|
|
newIndex,
|
|
oldContainer,
|
|
newContainer
|
|
});
|
|
|
|
this.trigger(sortableSortedEvent);
|
|
}
|
|
|
|
/**
|
|
* Drag over handler
|
|
* @private
|
|
* @param {DragOverEvent} event - Drag over event
|
|
*/
|
|
[onDragOver](event) {
|
|
if (event.over === event.originalSource || event.over === event.source) {
|
|
return;
|
|
}
|
|
|
|
const { source, over, overContainer } = event;
|
|
const oldIndex = this.index(source);
|
|
|
|
const sortableSortEvent = new _SortableEvent.SortableSortEvent({
|
|
dragEvent: event,
|
|
currentIndex: oldIndex,
|
|
source,
|
|
over
|
|
});
|
|
|
|
this.trigger(sortableSortEvent);
|
|
|
|
if (sortableSortEvent.canceled()) {
|
|
return;
|
|
}
|
|
|
|
const children = this.getDraggableElementsForContainer(overContainer);
|
|
const moves = move({ source, over, overContainer, children });
|
|
|
|
if (!moves) {
|
|
return;
|
|
}
|
|
|
|
const { oldContainer, newContainer } = moves;
|
|
const newIndex = this.index(source);
|
|
|
|
const sortableSortedEvent = new _SortableEvent.SortableSortedEvent({
|
|
dragEvent: event,
|
|
oldIndex,
|
|
newIndex,
|
|
oldContainer,
|
|
newContainer
|
|
});
|
|
|
|
this.trigger(sortableSortedEvent);
|
|
}
|
|
|
|
/**
|
|
* Drag stop handler
|
|
* @private
|
|
* @param {DragStopEvent} event - Drag stop event
|
|
*/
|
|
[onDragStop](event) {
|
|
const sortableStopEvent = new _SortableEvent.SortableStopEvent({
|
|
dragEvent: event,
|
|
oldIndex: this.startIndex,
|
|
newIndex: this.index(event.source),
|
|
oldContainer: this.startContainer,
|
|
newContainer: event.source.parentNode
|
|
});
|
|
|
|
this.trigger(sortableStopEvent);
|
|
|
|
this.startIndex = null;
|
|
this.startContainer = null;
|
|
}
|
|
}
|
|
|
|
exports.default = Sortable;
|
|
function index(element) {
|
|
return Array.prototype.indexOf.call(element.parentNode.children, element);
|
|
}
|
|
|
|
function move({ source, over, overContainer, children }) {
|
|
const emptyOverContainer = !children.length;
|
|
const differentContainer = source.parentNode !== overContainer;
|
|
const sameContainer = over && source.parentNode === over.parentNode;
|
|
|
|
if (emptyOverContainer) {
|
|
return moveInsideEmptyContainer(source, overContainer);
|
|
} else if (sameContainer) {
|
|
return moveWithinContainer(source, over);
|
|
} else if (differentContainer) {
|
|
return moveOutsideContainer(source, over, overContainer);
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
function moveInsideEmptyContainer(source, overContainer) {
|
|
const oldContainer = source.parentNode;
|
|
|
|
overContainer.appendChild(source);
|
|
|
|
return { oldContainer, newContainer: overContainer };
|
|
}
|
|
|
|
function moveWithinContainer(source, over) {
|
|
const oldIndex = index(source);
|
|
const newIndex = index(over);
|
|
|
|
if (oldIndex < newIndex) {
|
|
source.parentNode.insertBefore(source, over.nextElementSibling);
|
|
} else {
|
|
source.parentNode.insertBefore(source, over);
|
|
}
|
|
|
|
return { oldContainer: source.parentNode, newContainer: source.parentNode };
|
|
}
|
|
|
|
function moveOutsideContainer(source, over, overContainer) {
|
|
const oldContainer = source.parentNode;
|
|
|
|
if (over) {
|
|
over.parentNode.insertBefore(source, over);
|
|
} else {
|
|
// need to figure out proper position
|
|
overContainer.appendChild(source);
|
|
}
|
|
|
|
return { oldContainer, newContainer: source.parentNode };
|
|
}
|
|
|
|
/***/ }),
|
|
/* 29 */
|
|
/***/ (function(module, exports, __nested_webpack_require_56207__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.SortableStopEvent = exports.SortableSortedEvent = exports.SortableSortEvent = exports.SortableStartEvent = exports.SortableEvent = undefined;
|
|
|
|
var _AbstractEvent = __nested_webpack_require_56207__(1);
|
|
|
|
var _AbstractEvent2 = _interopRequireDefault(_AbstractEvent);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
/**
|
|
* Base sortable event
|
|
* @class SortableEvent
|
|
* @module SortableEvent
|
|
* @extends AbstractEvent
|
|
*/
|
|
class SortableEvent extends _AbstractEvent2.default {
|
|
|
|
/**
|
|
* Original drag event that triggered this sortable event
|
|
* @property dragEvent
|
|
* @type {DragEvent}
|
|
* @readonly
|
|
*/
|
|
get dragEvent() {
|
|
return this.data.dragEvent;
|
|
}
|
|
}
|
|
|
|
exports.SortableEvent = SortableEvent; /**
|
|
* Sortable start event
|
|
* @class SortableStartEvent
|
|
* @module SortableStartEvent
|
|
* @extends SortableEvent
|
|
*/
|
|
|
|
SortableEvent.type = 'sortable';
|
|
class SortableStartEvent extends SortableEvent {
|
|
|
|
/**
|
|
* Start index of source on sortable start
|
|
* @property startIndex
|
|
* @type {Number}
|
|
* @readonly
|
|
*/
|
|
get startIndex() {
|
|
return this.data.startIndex;
|
|
}
|
|
|
|
/**
|
|
* Start container on sortable start
|
|
* @property startContainer
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get startContainer() {
|
|
return this.data.startContainer;
|
|
}
|
|
}
|
|
|
|
exports.SortableStartEvent = SortableStartEvent; /**
|
|
* Sortable sort event
|
|
* @class SortableSortEvent
|
|
* @module SortableSortEvent
|
|
* @extends SortableEvent
|
|
*/
|
|
|
|
SortableStartEvent.type = 'sortable:start';
|
|
SortableStartEvent.cancelable = true;
|
|
class SortableSortEvent extends SortableEvent {
|
|
|
|
/**
|
|
* Index of current draggable element
|
|
* @property currentIndex
|
|
* @type {Number}
|
|
* @readonly
|
|
*/
|
|
get currentIndex() {
|
|
return this.data.currentIndex;
|
|
}
|
|
|
|
/**
|
|
* Draggable element you are hovering over
|
|
* @property over
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get over() {
|
|
return this.data.over;
|
|
}
|
|
|
|
/**
|
|
* Draggable container element you are hovering over
|
|
* @property overContainer
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get overContainer() {
|
|
return this.data.dragEvent.overContainer;
|
|
}
|
|
}
|
|
|
|
exports.SortableSortEvent = SortableSortEvent; /**
|
|
* Sortable sorted event
|
|
* @class SortableSortedEvent
|
|
* @module SortableSortedEvent
|
|
* @extends SortableEvent
|
|
*/
|
|
|
|
SortableSortEvent.type = 'sortable:sort';
|
|
SortableSortEvent.cancelable = true;
|
|
class SortableSortedEvent extends SortableEvent {
|
|
|
|
/**
|
|
* Index of last sorted event
|
|
* @property oldIndex
|
|
* @type {Number}
|
|
* @readonly
|
|
*/
|
|
get oldIndex() {
|
|
return this.data.oldIndex;
|
|
}
|
|
|
|
/**
|
|
* New index of this sorted event
|
|
* @property newIndex
|
|
* @type {Number}
|
|
* @readonly
|
|
*/
|
|
get newIndex() {
|
|
return this.data.newIndex;
|
|
}
|
|
|
|
/**
|
|
* Old container of draggable element
|
|
* @property oldContainer
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get oldContainer() {
|
|
return this.data.oldContainer;
|
|
}
|
|
|
|
/**
|
|
* New container of draggable element
|
|
* @property newContainer
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get newContainer() {
|
|
return this.data.newContainer;
|
|
}
|
|
}
|
|
|
|
exports.SortableSortedEvent = SortableSortedEvent; /**
|
|
* Sortable stop event
|
|
* @class SortableStopEvent
|
|
* @module SortableStopEvent
|
|
* @extends SortableEvent
|
|
*/
|
|
|
|
SortableSortedEvent.type = 'sortable:sorted';
|
|
class SortableStopEvent extends SortableEvent {
|
|
|
|
/**
|
|
* Original index on sortable start
|
|
* @property oldIndex
|
|
* @type {Number}
|
|
* @readonly
|
|
*/
|
|
get oldIndex() {
|
|
return this.data.oldIndex;
|
|
}
|
|
|
|
/**
|
|
* New index of draggable element
|
|
* @property newIndex
|
|
* @type {Number}
|
|
* @readonly
|
|
*/
|
|
get newIndex() {
|
|
return this.data.newIndex;
|
|
}
|
|
|
|
/**
|
|
* Original container of draggable element
|
|
* @property oldContainer
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get oldContainer() {
|
|
return this.data.oldContainer;
|
|
}
|
|
|
|
/**
|
|
* New container of draggable element
|
|
* @property newContainer
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get newContainer() {
|
|
return this.data.newContainer;
|
|
}
|
|
}
|
|
exports.SortableStopEvent = SortableStopEvent;
|
|
SortableStopEvent.type = 'sortable:stop';
|
|
|
|
/***/ }),
|
|
/* 30 */
|
|
/***/ (function(module, exports, __nested_webpack_require_61498__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _SortableEvent = __nested_webpack_require_61498__(9);
|
|
|
|
Object.keys(_SortableEvent).forEach(function (key) {
|
|
if (key === "default" || key === "__esModule") return;
|
|
Object.defineProperty(exports, key, {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _SortableEvent[key];
|
|
}
|
|
});
|
|
});
|
|
|
|
var _Sortable = __nested_webpack_require_61498__(28);
|
|
|
|
var _Sortable2 = _interopRequireDefault(_Sortable);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _Sortable2.default;
|
|
|
|
/***/ }),
|
|
/* 31 */
|
|
/***/ (function(module, exports, __nested_webpack_require_62179__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _extends = Object.assign || 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; };
|
|
|
|
var _Draggable = __nested_webpack_require_62179__(5);
|
|
|
|
var _Draggable2 = _interopRequireDefault(_Draggable);
|
|
|
|
var _SwappableEvent = __nested_webpack_require_62179__(10);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
const onDragStart = Symbol('onDragStart');
|
|
const onDragOver = Symbol('onDragOver');
|
|
const onDragStop = Symbol('onDragStop');
|
|
|
|
/**
|
|
* Returns an announcement message when the Draggable element is swapped with another draggable element
|
|
* @param {SwappableSwappedEvent} swappableEvent
|
|
* @return {String}
|
|
*/
|
|
function onSwappableSwappedDefaultAnnouncement({ dragEvent, swappedElement }) {
|
|
const sourceText = dragEvent.source.textContent.trim() || dragEvent.source.id || 'swappable element';
|
|
const overText = swappedElement.textContent.trim() || swappedElement.id || 'swappable element';
|
|
|
|
return `Swapped ${sourceText} with ${overText}`;
|
|
}
|
|
|
|
/**
|
|
* @const {Object} defaultAnnouncements
|
|
* @const {Function} defaultAnnouncements['swappabled:swapped']
|
|
*/
|
|
const defaultAnnouncements = {
|
|
'swappabled:swapped': onSwappableSwappedDefaultAnnouncement
|
|
};
|
|
|
|
/**
|
|
* Swappable is built on top of Draggable and allows swapping of draggable elements.
|
|
* Order is irrelevant to Swappable.
|
|
* @class Swappable
|
|
* @module Swappable
|
|
* @extends Draggable
|
|
*/
|
|
class Swappable extends _Draggable2.default {
|
|
/**
|
|
* Swappable constructor.
|
|
* @constructs Swappable
|
|
* @param {HTMLElement[]|NodeList|HTMLElement} containers - Swappable containers
|
|
* @param {Object} options - Options for Swappable
|
|
*/
|
|
constructor(containers = [], options = {}) {
|
|
super(containers, _extends({}, options, {
|
|
announcements: _extends({}, defaultAnnouncements, options.announcements || {})
|
|
}));
|
|
|
|
/**
|
|
* Last draggable element that was dragged over
|
|
* @property lastOver
|
|
* @type {HTMLElement}
|
|
*/
|
|
this.lastOver = null;
|
|
|
|
this[onDragStart] = this[onDragStart].bind(this);
|
|
this[onDragOver] = this[onDragOver].bind(this);
|
|
this[onDragStop] = this[onDragStop].bind(this);
|
|
|
|
this.on('drag:start', this[onDragStart]).on('drag:over', this[onDragOver]).on('drag:stop', this[onDragStop]);
|
|
}
|
|
|
|
/**
|
|
* Destroys Swappable instance.
|
|
*/
|
|
destroy() {
|
|
super.destroy();
|
|
|
|
this.off('drag:start', this._onDragStart).off('drag:over', this._onDragOver).off('drag:stop', this._onDragStop);
|
|
}
|
|
|
|
/**
|
|
* Drag start handler
|
|
* @private
|
|
* @param {DragStartEvent} event - Drag start event
|
|
*/
|
|
[onDragStart](event) {
|
|
const swappableStartEvent = new _SwappableEvent.SwappableStartEvent({
|
|
dragEvent: event
|
|
});
|
|
|
|
this.trigger(swappableStartEvent);
|
|
|
|
if (swappableStartEvent.canceled()) {
|
|
event.cancel();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Drag over handler
|
|
* @private
|
|
* @param {DragOverEvent} event - Drag over event
|
|
*/
|
|
[onDragOver](event) {
|
|
if (event.over === event.originalSource || event.over === event.source || event.canceled()) {
|
|
return;
|
|
}
|
|
|
|
const swappableSwapEvent = new _SwappableEvent.SwappableSwapEvent({
|
|
dragEvent: event,
|
|
over: event.over,
|
|
overContainer: event.overContainer
|
|
});
|
|
|
|
this.trigger(swappableSwapEvent);
|
|
|
|
if (swappableSwapEvent.canceled()) {
|
|
return;
|
|
}
|
|
|
|
// swap originally swapped element back
|
|
if (this.lastOver && this.lastOver !== event.over) {
|
|
swap(this.lastOver, event.source);
|
|
}
|
|
|
|
if (this.lastOver === event.over) {
|
|
this.lastOver = null;
|
|
} else {
|
|
this.lastOver = event.over;
|
|
}
|
|
|
|
swap(event.source, event.over);
|
|
|
|
const swappableSwappedEvent = new _SwappableEvent.SwappableSwappedEvent({
|
|
dragEvent: event,
|
|
swappedElement: event.over
|
|
});
|
|
|
|
this.trigger(swappableSwappedEvent);
|
|
}
|
|
|
|
/**
|
|
* Drag stop handler
|
|
* @private
|
|
* @param {DragStopEvent} event - Drag stop event
|
|
*/
|
|
[onDragStop](event) {
|
|
const swappableStopEvent = new _SwappableEvent.SwappableStopEvent({
|
|
dragEvent: event
|
|
});
|
|
|
|
this.trigger(swappableStopEvent);
|
|
this.lastOver = null;
|
|
}
|
|
}
|
|
|
|
exports.default = Swappable;
|
|
function withTempElement(callback) {
|
|
const tmpElement = document.createElement('div');
|
|
callback(tmpElement);
|
|
tmpElement.parentNode.removeChild(tmpElement);
|
|
}
|
|
|
|
function swap(source, over) {
|
|
const overParent = over.parentNode;
|
|
const sourceParent = source.parentNode;
|
|
|
|
withTempElement(tmpElement => {
|
|
sourceParent.insertBefore(tmpElement, source);
|
|
overParent.insertBefore(source, over);
|
|
sourceParent.insertBefore(over, tmpElement);
|
|
});
|
|
}
|
|
|
|
/***/ }),
|
|
/* 32 */
|
|
/***/ (function(module, exports, __nested_webpack_require_67105__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.SwappableStopEvent = exports.SwappableSwappedEvent = exports.SwappableSwapEvent = exports.SwappableStartEvent = exports.SwappableEvent = undefined;
|
|
|
|
var _AbstractEvent = __nested_webpack_require_67105__(1);
|
|
|
|
var _AbstractEvent2 = _interopRequireDefault(_AbstractEvent);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
/**
|
|
* Base swappable event
|
|
* @class SwappableEvent
|
|
* @module SwappableEvent
|
|
* @extends AbstractEvent
|
|
*/
|
|
class SwappableEvent extends _AbstractEvent2.default {
|
|
|
|
/**
|
|
* Original drag event that triggered this swappable event
|
|
* @property dragEvent
|
|
* @type {DragEvent}
|
|
* @readonly
|
|
*/
|
|
get dragEvent() {
|
|
return this.data.dragEvent;
|
|
}
|
|
}
|
|
|
|
exports.SwappableEvent = SwappableEvent; /**
|
|
* Swappable start event
|
|
* @class SwappableStartEvent
|
|
* @module SwappableStartEvent
|
|
* @extends SwappableEvent
|
|
*/
|
|
|
|
SwappableEvent.type = 'swappable';
|
|
class SwappableStartEvent extends SwappableEvent {}
|
|
|
|
exports.SwappableStartEvent = SwappableStartEvent; /**
|
|
* Swappable swap event
|
|
* @class SwappableSwapEvent
|
|
* @module SwappableSwapEvent
|
|
* @extends SwappableEvent
|
|
*/
|
|
|
|
SwappableStartEvent.type = 'swappable:start';
|
|
SwappableStartEvent.cancelable = true;
|
|
class SwappableSwapEvent extends SwappableEvent {
|
|
|
|
/**
|
|
* Draggable element you are over
|
|
* @property over
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get over() {
|
|
return this.data.over;
|
|
}
|
|
|
|
/**
|
|
* Draggable container you are over
|
|
* @property overContainer
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get overContainer() {
|
|
return this.data.overContainer;
|
|
}
|
|
}
|
|
|
|
exports.SwappableSwapEvent = SwappableSwapEvent; /**
|
|
* Swappable swapped event
|
|
* @class SwappableSwappedEvent
|
|
* @module SwappableSwappedEvent
|
|
* @extends SwappableEvent
|
|
*/
|
|
|
|
SwappableSwapEvent.type = 'swappable:swap';
|
|
SwappableSwapEvent.cancelable = true;
|
|
class SwappableSwappedEvent extends SwappableEvent {
|
|
|
|
/**
|
|
* The draggable element that you swapped with
|
|
* @property swappedElement
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get swappedElement() {
|
|
return this.data.swappedElement;
|
|
}
|
|
}
|
|
|
|
exports.SwappableSwappedEvent = SwappableSwappedEvent; /**
|
|
* Swappable stop event
|
|
* @class SwappableStopEvent
|
|
* @module SwappableStopEvent
|
|
* @extends SwappableEvent
|
|
*/
|
|
|
|
SwappableSwappedEvent.type = 'swappable:swapped';
|
|
class SwappableStopEvent extends SwappableEvent {}
|
|
exports.SwappableStopEvent = SwappableStopEvent;
|
|
SwappableStopEvent.type = 'swappable:stop';
|
|
|
|
/***/ }),
|
|
/* 33 */
|
|
/***/ (function(module, exports, __nested_webpack_require_70745__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _SwappableEvent = __nested_webpack_require_70745__(10);
|
|
|
|
Object.keys(_SwappableEvent).forEach(function (key) {
|
|
if (key === "default" || key === "__esModule") return;
|
|
Object.defineProperty(exports, key, {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _SwappableEvent[key];
|
|
}
|
|
});
|
|
});
|
|
|
|
var _Swappable = __nested_webpack_require_70745__(31);
|
|
|
|
var _Swappable2 = _interopRequireDefault(_Swappable);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _Swappable2.default;
|
|
|
|
/***/ }),
|
|
/* 34 */
|
|
/***/ (function(module, exports, __nested_webpack_require_71434__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _extends = Object.assign || 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; };
|
|
|
|
var _utils = __nested_webpack_require_71434__(2);
|
|
|
|
var _Draggable = __nested_webpack_require_71434__(5);
|
|
|
|
var _Draggable2 = _interopRequireDefault(_Draggable);
|
|
|
|
var _DroppableEvent = __nested_webpack_require_71434__(11);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
const onDragStart = Symbol('onDragStart');
|
|
const onDragMove = Symbol('onDragMove');
|
|
const onDragStop = Symbol('onDragStop');
|
|
const dropInDropzone = Symbol('dropInDropZone');
|
|
const returnToOriginalDropzone = Symbol('returnToOriginalDropzone');
|
|
const closestDropzone = Symbol('closestDropzone');
|
|
const getDropzones = Symbol('getDropzones');
|
|
|
|
/**
|
|
* Returns an announcement message when the Draggable element is dropped into a dropzone element
|
|
* @param {DroppableDroppedEvent} droppableEvent
|
|
* @return {String}
|
|
*/
|
|
function onDroppableDroppedDefaultAnnouncement({ dragEvent, dropzone }) {
|
|
const sourceText = dragEvent.source.textContent.trim() || dragEvent.source.id || 'draggable element';
|
|
const dropzoneText = dropzone.textContent.trim() || dropzone.id || 'droppable element';
|
|
|
|
return `Dropped ${sourceText} into ${dropzoneText}`;
|
|
}
|
|
|
|
/**
|
|
* Returns an announcement message when the Draggable element has returned to its original dropzone element
|
|
* @param {DroppableReturnedEvent} droppableEvent
|
|
* @return {String}
|
|
*/
|
|
function onDroppableReturnedDefaultAnnouncement({ dragEvent, dropzone }) {
|
|
const sourceText = dragEvent.source.textContent.trim() || dragEvent.source.id || 'draggable element';
|
|
const dropzoneText = dropzone.textContent.trim() || dropzone.id || 'droppable element';
|
|
|
|
return `Returned ${sourceText} from ${dropzoneText}`;
|
|
}
|
|
|
|
/**
|
|
* @const {Object} defaultAnnouncements
|
|
* @const {Function} defaultAnnouncements['droppable:dropped']
|
|
* @const {Function} defaultAnnouncements['droppable:returned']
|
|
*/
|
|
const defaultAnnouncements = {
|
|
'droppable:dropped': onDroppableDroppedDefaultAnnouncement,
|
|
'droppable:returned': onDroppableReturnedDefaultAnnouncement
|
|
};
|
|
|
|
const defaultClasses = {
|
|
'droppable:active': 'draggable-dropzone--active',
|
|
'droppable:occupied': 'draggable-dropzone--occupied'
|
|
};
|
|
|
|
const defaultOptions = {
|
|
dropzone: '.draggable-droppable'
|
|
};
|
|
|
|
/**
|
|
* Droppable is built on top of Draggable and allows dropping draggable elements
|
|
* into dropzone element
|
|
* @class Droppable
|
|
* @module Droppable
|
|
* @extends Draggable
|
|
*/
|
|
class Droppable extends _Draggable2.default {
|
|
/**
|
|
* Droppable constructor.
|
|
* @constructs Droppable
|
|
* @param {HTMLElement[]|NodeList|HTMLElement} containers - Droppable containers
|
|
* @param {Object} options - Options for Droppable
|
|
*/
|
|
constructor(containers = [], options = {}) {
|
|
super(containers, _extends({}, defaultOptions, options, {
|
|
classes: _extends({}, defaultClasses, options.classes || {}),
|
|
announcements: _extends({}, defaultAnnouncements, options.announcements || {})
|
|
}));
|
|
|
|
/**
|
|
* All dropzone elements on drag start
|
|
* @property dropzones
|
|
* @type {HTMLElement[]}
|
|
*/
|
|
this.dropzones = null;
|
|
|
|
/**
|
|
* Last dropzone element that the source was dropped into
|
|
* @property lastDropzone
|
|
* @type {HTMLElement}
|
|
*/
|
|
this.lastDropzone = null;
|
|
|
|
/**
|
|
* Initial dropzone element that the source was drag from
|
|
* @property initialDropzone
|
|
* @type {HTMLElement}
|
|
*/
|
|
this.initialDropzone = null;
|
|
|
|
this[onDragStart] = this[onDragStart].bind(this);
|
|
this[onDragMove] = this[onDragMove].bind(this);
|
|
this[onDragStop] = this[onDragStop].bind(this);
|
|
|
|
this.on('drag:start', this[onDragStart]).on('drag:move', this[onDragMove]).on('drag:stop', this[onDragStop]);
|
|
}
|
|
|
|
/**
|
|
* Destroys Droppable instance.
|
|
*/
|
|
destroy() {
|
|
super.destroy();
|
|
|
|
this.off('drag:start', this[onDragStart]).off('drag:move', this[onDragMove]).off('drag:stop', this[onDragStop]);
|
|
}
|
|
|
|
/**
|
|
* Drag start handler
|
|
* @private
|
|
* @param {DragStartEvent} event - Drag start event
|
|
*/
|
|
[onDragStart](event) {
|
|
if (event.canceled()) {
|
|
return;
|
|
}
|
|
|
|
this.dropzones = [...this[getDropzones]()];
|
|
const dropzone = (0, _utils.closest)(event.sensorEvent.target, this.options.dropzone);
|
|
|
|
if (!dropzone) {
|
|
event.cancel();
|
|
return;
|
|
}
|
|
|
|
const droppableStartEvent = new _DroppableEvent.DroppableStartEvent({
|
|
dragEvent: event,
|
|
dropzone
|
|
});
|
|
|
|
this.trigger(droppableStartEvent);
|
|
|
|
if (droppableStartEvent.canceled()) {
|
|
event.cancel();
|
|
return;
|
|
}
|
|
|
|
this.initialDropzone = dropzone;
|
|
|
|
for (const dropzoneElement of this.dropzones) {
|
|
if (dropzoneElement.classList.contains(this.getClassNameFor('droppable:occupied'))) {
|
|
continue;
|
|
}
|
|
|
|
dropzoneElement.classList.add(...this.getClassNamesFor('droppable:active'));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Drag move handler
|
|
* @private
|
|
* @param {DragMoveEvent} event - Drag move event
|
|
*/
|
|
[onDragMove](event) {
|
|
if (event.canceled()) {
|
|
return;
|
|
}
|
|
|
|
const dropzone = this[closestDropzone](event.sensorEvent.target);
|
|
const overEmptyDropzone = dropzone && !dropzone.classList.contains(this.getClassNameFor('droppable:occupied'));
|
|
|
|
if (overEmptyDropzone && this[dropInDropzone](event, dropzone)) {
|
|
this.lastDropzone = dropzone;
|
|
} else if ((!dropzone || dropzone === this.initialDropzone) && this.lastDropzone) {
|
|
this[returnToOriginalDropzone](event);
|
|
this.lastDropzone = null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Drag stop handler
|
|
* @private
|
|
* @param {DragStopEvent} event - Drag stop event
|
|
*/
|
|
[onDragStop](event) {
|
|
const droppableStopEvent = new _DroppableEvent.DroppableStopEvent({
|
|
dragEvent: event,
|
|
dropzone: this.lastDropzone || this.initialDropzone
|
|
});
|
|
|
|
this.trigger(droppableStopEvent);
|
|
|
|
const occupiedClasses = this.getClassNamesFor('droppable:occupied');
|
|
|
|
for (const dropzone of this.dropzones) {
|
|
dropzone.classList.remove(...this.getClassNamesFor('droppable:active'));
|
|
}
|
|
|
|
if (this.lastDropzone && this.lastDropzone !== this.initialDropzone) {
|
|
this.initialDropzone.classList.remove(...occupiedClasses);
|
|
}
|
|
|
|
this.dropzones = null;
|
|
this.lastDropzone = null;
|
|
this.initialDropzone = null;
|
|
}
|
|
|
|
/**
|
|
* Drops a draggable element into a dropzone element
|
|
* @private
|
|
* @param {DragMoveEvent} event - Drag move event
|
|
* @param {HTMLElement} dropzone - Dropzone element to drop draggable into
|
|
*/
|
|
[dropInDropzone](event, dropzone) {
|
|
const droppableDroppedEvent = new _DroppableEvent.DroppableDroppedEvent({
|
|
dragEvent: event,
|
|
dropzone
|
|
});
|
|
|
|
this.trigger(droppableDroppedEvent);
|
|
|
|
if (droppableDroppedEvent.canceled()) {
|
|
return false;
|
|
}
|
|
|
|
const occupiedClasses = this.getClassNamesFor('droppable:occupied');
|
|
|
|
if (this.lastDropzone) {
|
|
this.lastDropzone.classList.remove(...occupiedClasses);
|
|
}
|
|
|
|
dropzone.appendChild(event.source);
|
|
dropzone.classList.add(...occupiedClasses);
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Moves the previously dropped element back into its original dropzone
|
|
* @private
|
|
* @param {DragMoveEvent} event - Drag move event
|
|
*/
|
|
[returnToOriginalDropzone](event) {
|
|
const droppableReturnedEvent = new _DroppableEvent.DroppableReturnedEvent({
|
|
dragEvent: event,
|
|
dropzone: this.lastDropzone
|
|
});
|
|
|
|
this.trigger(droppableReturnedEvent);
|
|
|
|
if (droppableReturnedEvent.canceled()) {
|
|
return;
|
|
}
|
|
|
|
this.initialDropzone.appendChild(event.source);
|
|
this.lastDropzone.classList.remove(...this.getClassNamesFor('droppable:occupied'));
|
|
}
|
|
|
|
/**
|
|
* Returns closest dropzone element for even target
|
|
* @private
|
|
* @param {HTMLElement} target - Event target
|
|
* @return {HTMLElement|null}
|
|
*/
|
|
[closestDropzone](target) {
|
|
if (!this.dropzones) {
|
|
return null;
|
|
}
|
|
|
|
return (0, _utils.closest)(target, this.dropzones);
|
|
}
|
|
|
|
/**
|
|
* Returns all current dropzone elements for this draggable instance
|
|
* @private
|
|
* @return {NodeList|HTMLElement[]|Array}
|
|
*/
|
|
[getDropzones]() {
|
|
const dropzone = this.options.dropzone;
|
|
|
|
if (typeof dropzone === 'string') {
|
|
return document.querySelectorAll(dropzone);
|
|
} else if (dropzone instanceof NodeList || dropzone instanceof Array) {
|
|
return dropzone;
|
|
} else if (typeof dropzone === 'function') {
|
|
return dropzone();
|
|
} else {
|
|
return [];
|
|
}
|
|
}
|
|
}
|
|
exports.default = Droppable;
|
|
|
|
/***/ }),
|
|
/* 35 */
|
|
/***/ (function(module, exports, __nested_webpack_require_80239__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.DroppableStopEvent = exports.DroppableReturnedEvent = exports.DroppableDroppedEvent = exports.DroppableStartEvent = exports.DroppableEvent = undefined;
|
|
|
|
var _AbstractEvent = __nested_webpack_require_80239__(1);
|
|
|
|
var _AbstractEvent2 = _interopRequireDefault(_AbstractEvent);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
/**
|
|
* Base droppable event
|
|
* @class DroppableEvent
|
|
* @module DroppableEvent
|
|
* @extends AbstractEvent
|
|
*/
|
|
class DroppableEvent extends _AbstractEvent2.default {
|
|
|
|
/**
|
|
* Original drag event that triggered this droppable event
|
|
* @property dragEvent
|
|
* @type {DragEvent}
|
|
* @readonly
|
|
*/
|
|
get dragEvent() {
|
|
return this.data.dragEvent;
|
|
}
|
|
}
|
|
|
|
exports.DroppableEvent = DroppableEvent; /**
|
|
* Droppable start event
|
|
* @class DroppableStartEvent
|
|
* @module DroppableStartEvent
|
|
* @extends DroppableEvent
|
|
*/
|
|
|
|
DroppableEvent.type = 'droppable';
|
|
class DroppableStartEvent extends DroppableEvent {
|
|
|
|
/**
|
|
* The initial dropzone element of the currently dragging draggable element
|
|
* @property dropzone
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get dropzone() {
|
|
return this.data.dropzone;
|
|
}
|
|
}
|
|
|
|
exports.DroppableStartEvent = DroppableStartEvent; /**
|
|
* Droppable dropped event
|
|
* @class DroppableDroppedEvent
|
|
* @module DroppableDroppedEvent
|
|
* @extends DroppableEvent
|
|
*/
|
|
|
|
DroppableStartEvent.type = 'droppable:start';
|
|
DroppableStartEvent.cancelable = true;
|
|
class DroppableDroppedEvent extends DroppableEvent {
|
|
|
|
/**
|
|
* The dropzone element you dropped the draggable element into
|
|
* @property dropzone
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get dropzone() {
|
|
return this.data.dropzone;
|
|
}
|
|
}
|
|
|
|
exports.DroppableDroppedEvent = DroppableDroppedEvent; /**
|
|
* Droppable returned event
|
|
* @class DroppableReturnedEvent
|
|
* @module DroppableReturnedEvent
|
|
* @extends DroppableEvent
|
|
*/
|
|
|
|
DroppableDroppedEvent.type = 'droppable:dropped';
|
|
DroppableDroppedEvent.cancelable = true;
|
|
class DroppableReturnedEvent extends DroppableEvent {
|
|
|
|
/**
|
|
* The dropzone element you dragged away from
|
|
* @property dropzone
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get dropzone() {
|
|
return this.data.dropzone;
|
|
}
|
|
}
|
|
|
|
exports.DroppableReturnedEvent = DroppableReturnedEvent; /**
|
|
* Droppable stop event
|
|
* @class DroppableStopEvent
|
|
* @module DroppableStopEvent
|
|
* @extends DroppableEvent
|
|
*/
|
|
|
|
DroppableReturnedEvent.type = 'droppable:returned';
|
|
DroppableReturnedEvent.cancelable = true;
|
|
class DroppableStopEvent extends DroppableEvent {
|
|
|
|
/**
|
|
* The final dropzone element of the draggable element
|
|
* @property dropzone
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get dropzone() {
|
|
return this.data.dropzone;
|
|
}
|
|
}
|
|
exports.DroppableStopEvent = DroppableStopEvent;
|
|
DroppableStopEvent.type = 'droppable:stop';
|
|
DroppableStopEvent.cancelable = true;
|
|
|
|
/***/ }),
|
|
/* 36 */
|
|
/***/ (function(module, exports, __nested_webpack_require_84275__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _DroppableEvent = __nested_webpack_require_84275__(11);
|
|
|
|
Object.keys(_DroppableEvent).forEach(function (key) {
|
|
if (key === "default" || key === "__esModule") return;
|
|
Object.defineProperty(exports, key, {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _DroppableEvent[key];
|
|
}
|
|
});
|
|
});
|
|
|
|
var _Droppable = __nested_webpack_require_84275__(34);
|
|
|
|
var _Droppable2 = _interopRequireDefault(_Droppable);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _Droppable2.default;
|
|
|
|
/***/ }),
|
|
/* 37 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
/**
|
|
* The Emitter is a simple emitter class that provides you with `on()`, `off()` and `trigger()` methods
|
|
* @class Emitter
|
|
* @module Emitter
|
|
*/
|
|
class Emitter {
|
|
constructor() {
|
|
this.callbacks = {};
|
|
}
|
|
|
|
/**
|
|
* Registers callbacks by event name
|
|
* @param {String} type
|
|
* @param {...Function} callbacks
|
|
*/
|
|
on(type, ...callbacks) {
|
|
if (!this.callbacks[type]) {
|
|
this.callbacks[type] = [];
|
|
}
|
|
|
|
this.callbacks[type].push(...callbacks);
|
|
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Unregisters callbacks by event name
|
|
* @param {String} type
|
|
* @param {Function} callback
|
|
*/
|
|
off(type, callback) {
|
|
if (!this.callbacks[type]) {
|
|
return null;
|
|
}
|
|
|
|
const copy = this.callbacks[type].slice(0);
|
|
|
|
for (let i = 0; i < copy.length; i++) {
|
|
if (callback === copy[i]) {
|
|
this.callbacks[type].splice(i, 1);
|
|
}
|
|
}
|
|
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Triggers event callbacks by event object
|
|
* @param {AbstractEvent} event
|
|
*/
|
|
trigger(event) {
|
|
if (!this.callbacks[event.type]) {
|
|
return null;
|
|
}
|
|
|
|
const callbacks = [...this.callbacks[event.type]];
|
|
const caughtErrors = [];
|
|
|
|
for (let i = callbacks.length - 1; i >= 0; i--) {
|
|
const callback = callbacks[i];
|
|
|
|
try {
|
|
callback(event);
|
|
} catch (error) {
|
|
caughtErrors.push(error);
|
|
}
|
|
}
|
|
|
|
if (caughtErrors.length) {
|
|
/* eslint-disable no-console */
|
|
console.error(`Draggable caught errors while triggering '${event.type}'`, caughtErrors);
|
|
/* eslint-disable no-console */
|
|
}
|
|
|
|
return this;
|
|
}
|
|
}
|
|
exports.default = Emitter;
|
|
|
|
/***/ }),
|
|
/* 38 */
|
|
/***/ (function(module, exports, __nested_webpack_require_86739__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _Emitter = __nested_webpack_require_86739__(37);
|
|
|
|
var _Emitter2 = _interopRequireDefault(_Emitter);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _Emitter2.default;
|
|
|
|
/***/ }),
|
|
/* 39 */
|
|
/***/ (function(module, exports, __nested_webpack_require_87124__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.defaultOptions = undefined;
|
|
|
|
var _extends = Object.assign || 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; };
|
|
|
|
var _utils = __nested_webpack_require_87124__(2);
|
|
|
|
var _Plugins = __nested_webpack_require_87124__(12);
|
|
|
|
var _Emitter = __nested_webpack_require_87124__(38);
|
|
|
|
var _Emitter2 = _interopRequireDefault(_Emitter);
|
|
|
|
var _Sensors = __nested_webpack_require_87124__(6);
|
|
|
|
var _DraggableEvent = __nested_webpack_require_87124__(13);
|
|
|
|
var _DragEvent = __nested_webpack_require_87124__(14);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
const onDragStart = Symbol('onDragStart');
|
|
const onDragMove = Symbol('onDragMove');
|
|
const onDragStop = Symbol('onDragStop');
|
|
const onDragPressure = Symbol('onDragPressure');
|
|
|
|
/**
|
|
* @const {Object} defaultAnnouncements
|
|
* @const {Function} defaultAnnouncements['drag:start']
|
|
* @const {Function} defaultAnnouncements['drag:stop']
|
|
*/
|
|
const defaultAnnouncements = {
|
|
'drag:start': event => `Picked up ${event.source.textContent.trim() || event.source.id || 'draggable element'}`,
|
|
'drag:stop': event => `Released ${event.source.textContent.trim() || event.source.id || 'draggable element'}`
|
|
};
|
|
|
|
const defaultClasses = {
|
|
'container:dragging': 'draggable-container--is-dragging',
|
|
'source:dragging': 'draggable-source--is-dragging',
|
|
'source:placed': 'draggable-source--placed',
|
|
'container:placed': 'draggable-container--placed',
|
|
'body:dragging': 'draggable--is-dragging',
|
|
'draggable:over': 'draggable--over',
|
|
'container:over': 'draggable-container--over',
|
|
'source:original': 'draggable--original',
|
|
mirror: 'draggable-mirror'
|
|
};
|
|
|
|
const defaultOptions = exports.defaultOptions = {
|
|
draggable: '.draggable-source',
|
|
handle: null,
|
|
delay: {},
|
|
distance: 0,
|
|
placedTimeout: 800,
|
|
plugins: [],
|
|
sensors: [],
|
|
exclude: {
|
|
plugins: [],
|
|
sensors: []
|
|
}
|
|
};
|
|
|
|
/**
|
|
* This is the core draggable library that does the heavy lifting
|
|
* @class Draggable
|
|
* @module Draggable
|
|
*/
|
|
class Draggable {
|
|
|
|
/**
|
|
* Draggable constructor.
|
|
* @constructs Draggable
|
|
* @param {HTMLElement[]|NodeList|HTMLElement} containers - Draggable containers
|
|
* @param {Object} options - Options for draggable
|
|
*/
|
|
|
|
/**
|
|
* Default plugins draggable uses
|
|
* @static
|
|
* @property {Object} Plugins
|
|
* @property {Announcement} Plugins.Announcement
|
|
* @property {Focusable} Plugins.Focusable
|
|
* @property {Mirror} Plugins.Mirror
|
|
* @property {Scrollable} Plugins.Scrollable
|
|
* @type {Object}
|
|
*/
|
|
constructor(containers = [document.body], options = {}) {
|
|
/**
|
|
* Draggable containers
|
|
* @property containers
|
|
* @type {HTMLElement[]}
|
|
*/
|
|
if (containers instanceof NodeList || containers instanceof Array) {
|
|
this.containers = [...containers];
|
|
} else if (containers instanceof HTMLElement) {
|
|
this.containers = [containers];
|
|
} else {
|
|
throw new Error('Draggable containers are expected to be of type `NodeList`, `HTMLElement[]` or `HTMLElement`');
|
|
}
|
|
|
|
this.options = _extends({}, defaultOptions, options, {
|
|
classes: _extends({}, defaultClasses, options.classes || {}),
|
|
announcements: _extends({}, defaultAnnouncements, options.announcements || {}),
|
|
exclude: {
|
|
plugins: options.exclude && options.exclude.plugins || [],
|
|
sensors: options.exclude && options.exclude.sensors || []
|
|
}
|
|
});
|
|
|
|
/**
|
|
* Draggables event emitter
|
|
* @property emitter
|
|
* @type {Emitter}
|
|
*/
|
|
this.emitter = new _Emitter2.default();
|
|
|
|
/**
|
|
* Current drag state
|
|
* @property dragging
|
|
* @type {Boolean}
|
|
*/
|
|
this.dragging = false;
|
|
|
|
/**
|
|
* Active plugins
|
|
* @property plugins
|
|
* @type {Plugin[]}
|
|
*/
|
|
this.plugins = [];
|
|
|
|
/**
|
|
* Active sensors
|
|
* @property sensors
|
|
* @type {Sensor[]}
|
|
*/
|
|
this.sensors = [];
|
|
|
|
this[onDragStart] = this[onDragStart].bind(this);
|
|
this[onDragMove] = this[onDragMove].bind(this);
|
|
this[onDragStop] = this[onDragStop].bind(this);
|
|
this[onDragPressure] = this[onDragPressure].bind(this);
|
|
|
|
document.addEventListener('drag:start', this[onDragStart], true);
|
|
document.addEventListener('drag:move', this[onDragMove], true);
|
|
document.addEventListener('drag:stop', this[onDragStop], true);
|
|
document.addEventListener('drag:pressure', this[onDragPressure], true);
|
|
|
|
const defaultPlugins = Object.values(Draggable.Plugins).filter(Plugin => !this.options.exclude.plugins.includes(Plugin));
|
|
const defaultSensors = Object.values(Draggable.Sensors).filter(sensor => !this.options.exclude.sensors.includes(sensor));
|
|
|
|
this.addPlugin(...[...defaultPlugins, ...this.options.plugins]);
|
|
this.addSensor(...[...defaultSensors, ...this.options.sensors]);
|
|
|
|
const draggableInitializedEvent = new _DraggableEvent.DraggableInitializedEvent({
|
|
draggable: this
|
|
});
|
|
|
|
this.on('mirror:created', ({ mirror }) => this.mirror = mirror);
|
|
this.on('mirror:destroy', () => this.mirror = null);
|
|
|
|
this.trigger(draggableInitializedEvent);
|
|
}
|
|
|
|
/**
|
|
* Destroys Draggable instance. This removes all internal event listeners and
|
|
* deactivates sensors and plugins
|
|
*/
|
|
|
|
|
|
/**
|
|
* Default sensors draggable uses
|
|
* @static
|
|
* @property {Object} Sensors
|
|
* @property {MouseSensor} Sensors.MouseSensor
|
|
* @property {TouchSensor} Sensors.TouchSensor
|
|
* @type {Object}
|
|
*/
|
|
destroy() {
|
|
document.removeEventListener('drag:start', this[onDragStart], true);
|
|
document.removeEventListener('drag:move', this[onDragMove], true);
|
|
document.removeEventListener('drag:stop', this[onDragStop], true);
|
|
document.removeEventListener('drag:pressure', this[onDragPressure], true);
|
|
|
|
const draggableDestroyEvent = new _DraggableEvent.DraggableDestroyEvent({
|
|
draggable: this
|
|
});
|
|
|
|
this.trigger(draggableDestroyEvent);
|
|
|
|
this.removePlugin(...this.plugins.map(plugin => plugin.constructor));
|
|
this.removeSensor(...this.sensors.map(sensor => sensor.constructor));
|
|
}
|
|
|
|
/**
|
|
* Adds plugin to this draggable instance. This will end up calling the attach method of the plugin
|
|
* @param {...typeof Plugin} plugins - Plugins that you want attached to draggable
|
|
* @return {Draggable}
|
|
* @example draggable.addPlugin(CustomA11yPlugin, CustomMirrorPlugin)
|
|
*/
|
|
addPlugin(...plugins) {
|
|
const activePlugins = plugins.map(Plugin => new Plugin(this));
|
|
|
|
activePlugins.forEach(plugin => plugin.attach());
|
|
this.plugins = [...this.plugins, ...activePlugins];
|
|
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Removes plugins that are already attached to this draggable instance. This will end up calling
|
|
* the detach method of the plugin
|
|
* @param {...typeof Plugin} plugins - Plugins that you want detached from draggable
|
|
* @return {Draggable}
|
|
* @example draggable.removePlugin(MirrorPlugin, CustomMirrorPlugin)
|
|
*/
|
|
removePlugin(...plugins) {
|
|
const removedPlugins = this.plugins.filter(plugin => plugins.includes(plugin.constructor));
|
|
|
|
removedPlugins.forEach(plugin => plugin.detach());
|
|
this.plugins = this.plugins.filter(plugin => !plugins.includes(plugin.constructor));
|
|
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Adds sensors to this draggable instance. This will end up calling the attach method of the sensor
|
|
* @param {...typeof Sensor} sensors - Sensors that you want attached to draggable
|
|
* @return {Draggable}
|
|
* @example draggable.addSensor(ForceTouchSensor, CustomSensor)
|
|
*/
|
|
addSensor(...sensors) {
|
|
const activeSensors = sensors.map(Sensor => new Sensor(this.containers, this.options));
|
|
|
|
activeSensors.forEach(sensor => sensor.attach());
|
|
this.sensors = [...this.sensors, ...activeSensors];
|
|
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Removes sensors that are already attached to this draggable instance. This will end up calling
|
|
* the detach method of the sensor
|
|
* @param {...typeof Sensor} sensors - Sensors that you want attached to draggable
|
|
* @return {Draggable}
|
|
* @example draggable.removeSensor(TouchSensor, DragSensor)
|
|
*/
|
|
removeSensor(...sensors) {
|
|
const removedSensors = this.sensors.filter(sensor => sensors.includes(sensor.constructor));
|
|
|
|
removedSensors.forEach(sensor => sensor.detach());
|
|
this.sensors = this.sensors.filter(sensor => !sensors.includes(sensor.constructor));
|
|
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Adds container to this draggable instance
|
|
* @param {...HTMLElement} containers - Containers you want to add to draggable
|
|
* @return {Draggable}
|
|
* @example draggable.addContainer(document.body)
|
|
*/
|
|
addContainer(...containers) {
|
|
this.containers = [...this.containers, ...containers];
|
|
this.sensors.forEach(sensor => sensor.addContainer(...containers));
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Removes container from this draggable instance
|
|
* @param {...HTMLElement} containers - Containers you want to remove from draggable
|
|
* @return {Draggable}
|
|
* @example draggable.removeContainer(document.body)
|
|
*/
|
|
removeContainer(...containers) {
|
|
this.containers = this.containers.filter(container => !containers.includes(container));
|
|
this.sensors.forEach(sensor => sensor.removeContainer(...containers));
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Adds listener for draggable events
|
|
* @param {String} type - Event name
|
|
* @param {...Function} callbacks - Event callbacks
|
|
* @return {Draggable}
|
|
* @example draggable.on('drag:start', (dragEvent) => dragEvent.cancel());
|
|
*/
|
|
on(type, ...callbacks) {
|
|
this.emitter.on(type, ...callbacks);
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Removes listener from draggable
|
|
* @param {String} type - Event name
|
|
* @param {Function} callback - Event callback
|
|
* @return {Draggable}
|
|
* @example draggable.off('drag:start', handlerFunction);
|
|
*/
|
|
off(type, callback) {
|
|
this.emitter.off(type, callback);
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Triggers draggable event
|
|
* @param {AbstractEvent} event - Event instance
|
|
* @return {Draggable}
|
|
* @example draggable.trigger(event);
|
|
*/
|
|
trigger(event) {
|
|
this.emitter.trigger(event);
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Returns class name for class identifier
|
|
* @param {String} name - Name of class identifier
|
|
* @return {String|null}
|
|
*/
|
|
getClassNameFor(name) {
|
|
return this.getClassNamesFor(name)[0];
|
|
}
|
|
|
|
/**
|
|
* Returns class names for class identifier
|
|
* @return {String[]}
|
|
*/
|
|
getClassNamesFor(name) {
|
|
const classNames = this.options.classes[name];
|
|
|
|
if (classNames instanceof Array) {
|
|
return classNames;
|
|
} else if (typeof classNames === 'string' || classNames instanceof String) {
|
|
return [classNames];
|
|
} else {
|
|
return [];
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Returns true if this draggable instance is currently dragging
|
|
* @return {Boolean}
|
|
*/
|
|
isDragging() {
|
|
return Boolean(this.dragging);
|
|
}
|
|
|
|
/**
|
|
* Returns all draggable elements
|
|
* @return {HTMLElement[]}
|
|
*/
|
|
getDraggableElements() {
|
|
return this.containers.reduce((current, container) => {
|
|
return [...current, ...this.getDraggableElementsForContainer(container)];
|
|
}, []);
|
|
}
|
|
|
|
/**
|
|
* Returns draggable elements for a given container, excluding the mirror and
|
|
* original source element if present
|
|
* @param {HTMLElement} container
|
|
* @return {HTMLElement[]}
|
|
*/
|
|
getDraggableElementsForContainer(container) {
|
|
const allDraggableElements = container.querySelectorAll(this.options.draggable);
|
|
|
|
return [...allDraggableElements].filter(childElement => {
|
|
return childElement !== this.originalSource && childElement !== this.mirror;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Drag start handler
|
|
* @private
|
|
* @param {Event} event - DOM Drag event
|
|
*/
|
|
[onDragStart](event) {
|
|
const sensorEvent = getSensorEvent(event);
|
|
const { target, container } = sensorEvent;
|
|
|
|
if (!this.containers.includes(container)) {
|
|
return;
|
|
}
|
|
|
|
if (this.options.handle && target && !(0, _utils.closest)(target, this.options.handle)) {
|
|
sensorEvent.cancel();
|
|
return;
|
|
}
|
|
|
|
// Find draggable source element
|
|
this.originalSource = (0, _utils.closest)(target, this.options.draggable);
|
|
this.sourceContainer = container;
|
|
|
|
if (!this.originalSource) {
|
|
sensorEvent.cancel();
|
|
return;
|
|
}
|
|
|
|
if (this.lastPlacedSource && this.lastPlacedContainer) {
|
|
clearTimeout(this.placedTimeoutID);
|
|
this.lastPlacedSource.classList.remove(...this.getClassNamesFor('source:placed'));
|
|
this.lastPlacedContainer.classList.remove(...this.getClassNamesFor('container:placed'));
|
|
}
|
|
|
|
this.source = this.originalSource.cloneNode(true);
|
|
this.originalSource.parentNode.insertBefore(this.source, this.originalSource);
|
|
this.originalSource.style.display = 'none';
|
|
|
|
const dragEvent = new _DragEvent.DragStartEvent({
|
|
source: this.source,
|
|
originalSource: this.originalSource,
|
|
sourceContainer: container,
|
|
sensorEvent
|
|
});
|
|
|
|
this.trigger(dragEvent);
|
|
|
|
this.dragging = !dragEvent.canceled();
|
|
|
|
if (dragEvent.canceled()) {
|
|
this.source.parentNode.removeChild(this.source);
|
|
this.originalSource.style.display = null;
|
|
return;
|
|
}
|
|
|
|
this.originalSource.classList.add(...this.getClassNamesFor('source:original'));
|
|
this.source.classList.add(...this.getClassNamesFor('source:dragging'));
|
|
this.sourceContainer.classList.add(...this.getClassNamesFor('container:dragging'));
|
|
document.body.classList.add(...this.getClassNamesFor('body:dragging'));
|
|
applyUserSelect(document.body, 'none');
|
|
|
|
requestAnimationFrame(() => {
|
|
const oldSensorEvent = getSensorEvent(event);
|
|
const newSensorEvent = oldSensorEvent.clone({ target: this.source });
|
|
|
|
this[onDragMove](_extends({}, event, {
|
|
detail: newSensorEvent
|
|
}));
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Drag move handler
|
|
* @private
|
|
* @param {Event} event - DOM Drag event
|
|
*/
|
|
[onDragMove](event) {
|
|
if (!this.dragging) {
|
|
return;
|
|
}
|
|
|
|
const sensorEvent = getSensorEvent(event);
|
|
const { container } = sensorEvent;
|
|
let target = sensorEvent.target;
|
|
|
|
const dragMoveEvent = new _DragEvent.DragMoveEvent({
|
|
source: this.source,
|
|
originalSource: this.originalSource,
|
|
sourceContainer: container,
|
|
sensorEvent
|
|
});
|
|
|
|
this.trigger(dragMoveEvent);
|
|
|
|
if (dragMoveEvent.canceled()) {
|
|
sensorEvent.cancel();
|
|
}
|
|
|
|
target = (0, _utils.closest)(target, this.options.draggable);
|
|
const withinCorrectContainer = (0, _utils.closest)(sensorEvent.target, this.containers);
|
|
const overContainer = sensorEvent.overContainer || withinCorrectContainer;
|
|
const isLeavingContainer = this.currentOverContainer && overContainer !== this.currentOverContainer;
|
|
const isLeavingDraggable = this.currentOver && target !== this.currentOver;
|
|
const isOverContainer = overContainer && this.currentOverContainer !== overContainer;
|
|
const isOverDraggable = withinCorrectContainer && target && this.currentOver !== target;
|
|
|
|
if (isLeavingDraggable) {
|
|
const dragOutEvent = new _DragEvent.DragOutEvent({
|
|
source: this.source,
|
|
originalSource: this.originalSource,
|
|
sourceContainer: container,
|
|
sensorEvent,
|
|
over: this.currentOver,
|
|
overContainer: this.currentOverContainer
|
|
});
|
|
|
|
this.currentOver.classList.remove(...this.getClassNamesFor('draggable:over'));
|
|
this.currentOver = null;
|
|
|
|
this.trigger(dragOutEvent);
|
|
}
|
|
|
|
if (isLeavingContainer) {
|
|
const dragOutContainerEvent = new _DragEvent.DragOutContainerEvent({
|
|
source: this.source,
|
|
originalSource: this.originalSource,
|
|
sourceContainer: container,
|
|
sensorEvent,
|
|
overContainer: this.currentOverContainer
|
|
});
|
|
|
|
this.currentOverContainer.classList.remove(...this.getClassNamesFor('container:over'));
|
|
this.currentOverContainer = null;
|
|
|
|
this.trigger(dragOutContainerEvent);
|
|
}
|
|
|
|
if (isOverContainer) {
|
|
overContainer.classList.add(...this.getClassNamesFor('container:over'));
|
|
|
|
const dragOverContainerEvent = new _DragEvent.DragOverContainerEvent({
|
|
source: this.source,
|
|
originalSource: this.originalSource,
|
|
sourceContainer: container,
|
|
sensorEvent,
|
|
overContainer
|
|
});
|
|
|
|
this.currentOverContainer = overContainer;
|
|
|
|
this.trigger(dragOverContainerEvent);
|
|
}
|
|
|
|
if (isOverDraggable) {
|
|
target.classList.add(...this.getClassNamesFor('draggable:over'));
|
|
|
|
const dragOverEvent = new _DragEvent.DragOverEvent({
|
|
source: this.source,
|
|
originalSource: this.originalSource,
|
|
sourceContainer: container,
|
|
sensorEvent,
|
|
overContainer,
|
|
over: target
|
|
});
|
|
|
|
this.currentOver = target;
|
|
|
|
this.trigger(dragOverEvent);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Drag stop handler
|
|
* @private
|
|
* @param {Event} event - DOM Drag event
|
|
*/
|
|
[onDragStop](event) {
|
|
if (!this.dragging) {
|
|
return;
|
|
}
|
|
|
|
this.dragging = false;
|
|
|
|
const dragStopEvent = new _DragEvent.DragStopEvent({
|
|
source: this.source,
|
|
originalSource: this.originalSource,
|
|
sensorEvent: event.sensorEvent,
|
|
sourceContainer: this.sourceContainer
|
|
});
|
|
|
|
this.trigger(dragStopEvent);
|
|
|
|
this.source.parentNode.insertBefore(this.originalSource, this.source);
|
|
this.source.parentNode.removeChild(this.source);
|
|
this.originalSource.style.display = '';
|
|
|
|
this.source.classList.remove(...this.getClassNamesFor('source:dragging'));
|
|
this.originalSource.classList.remove(...this.getClassNamesFor('source:original'));
|
|
this.originalSource.classList.add(...this.getClassNamesFor('source:placed'));
|
|
this.sourceContainer.classList.add(...this.getClassNamesFor('container:placed'));
|
|
this.sourceContainer.classList.remove(...this.getClassNamesFor('container:dragging'));
|
|
document.body.classList.remove(...this.getClassNamesFor('body:dragging'));
|
|
applyUserSelect(document.body, '');
|
|
|
|
if (this.currentOver) {
|
|
this.currentOver.classList.remove(...this.getClassNamesFor('draggable:over'));
|
|
}
|
|
|
|
if (this.currentOverContainer) {
|
|
this.currentOverContainer.classList.remove(...this.getClassNamesFor('container:over'));
|
|
}
|
|
|
|
this.lastPlacedSource = this.originalSource;
|
|
this.lastPlacedContainer = this.sourceContainer;
|
|
|
|
this.placedTimeoutID = setTimeout(() => {
|
|
if (this.lastPlacedSource) {
|
|
this.lastPlacedSource.classList.remove(...this.getClassNamesFor('source:placed'));
|
|
}
|
|
|
|
if (this.lastPlacedContainer) {
|
|
this.lastPlacedContainer.classList.remove(...this.getClassNamesFor('container:placed'));
|
|
}
|
|
|
|
this.lastPlacedSource = null;
|
|
this.lastPlacedContainer = null;
|
|
}, this.options.placedTimeout);
|
|
|
|
const dragStoppedEvent = new _DragEvent.DragStoppedEvent({
|
|
source: this.source,
|
|
originalSource: this.originalSource,
|
|
sensorEvent: event.sensorEvent,
|
|
sourceContainer: this.sourceContainer
|
|
});
|
|
|
|
this.trigger(dragStoppedEvent);
|
|
|
|
this.source = null;
|
|
this.originalSource = null;
|
|
this.currentOverContainer = null;
|
|
this.currentOver = null;
|
|
this.sourceContainer = null;
|
|
}
|
|
|
|
/**
|
|
* Drag pressure handler
|
|
* @private
|
|
* @param {Event} event - DOM Drag event
|
|
*/
|
|
[onDragPressure](event) {
|
|
if (!this.dragging) {
|
|
return;
|
|
}
|
|
|
|
const sensorEvent = getSensorEvent(event);
|
|
const source = this.source || (0, _utils.closest)(sensorEvent.originalEvent.target, this.options.draggable);
|
|
|
|
const dragPressureEvent = new _DragEvent.DragPressureEvent({
|
|
sensorEvent,
|
|
source,
|
|
pressure: sensorEvent.pressure
|
|
});
|
|
|
|
this.trigger(dragPressureEvent);
|
|
}
|
|
}
|
|
|
|
exports.default = Draggable;
|
|
Draggable.Plugins = { Announcement: _Plugins.Announcement, Focusable: _Plugins.Focusable, Mirror: _Plugins.Mirror, Scrollable: _Plugins.Scrollable };
|
|
Draggable.Sensors = { MouseSensor: _Sensors.MouseSensor, TouchSensor: _Sensors.TouchSensor };
|
|
function getSensorEvent(event) {
|
|
return event.detail;
|
|
}
|
|
|
|
function applyUserSelect(element, value) {
|
|
element.style.webkitUserSelect = value;
|
|
element.style.mozUserSelect = value;
|
|
element.style.msUserSelect = value;
|
|
element.style.oUserSelect = value;
|
|
element.style.userSelect = value;
|
|
}
|
|
|
|
/***/ }),
|
|
/* 40 */
|
|
/***/ (function(module, exports, __nested_webpack_require_107599__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _Sensor = __nested_webpack_require_107599__(4);
|
|
|
|
var _Sensor2 = _interopRequireDefault(_Sensor);
|
|
|
|
var _SensorEvent = __nested_webpack_require_107599__(3);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
const onMouseForceWillBegin = Symbol('onMouseForceWillBegin');
|
|
const onMouseForceDown = Symbol('onMouseForceDown');
|
|
const onMouseDown = Symbol('onMouseDown');
|
|
const onMouseForceChange = Symbol('onMouseForceChange');
|
|
const onMouseMove = Symbol('onMouseMove');
|
|
const onMouseUp = Symbol('onMouseUp');
|
|
const onMouseForceGlobalChange = Symbol('onMouseForceGlobalChange');
|
|
|
|
/**
|
|
* This sensor picks up native force touch events and dictates drag operations
|
|
* @class ForceTouchSensor
|
|
* @module ForceTouchSensor
|
|
* @extends Sensor
|
|
*/
|
|
class ForceTouchSensor extends _Sensor2.default {
|
|
/**
|
|
* ForceTouchSensor constructor.
|
|
* @constructs ForceTouchSensor
|
|
* @param {HTMLElement[]|NodeList|HTMLElement} containers - Containers
|
|
* @param {Object} options - Options
|
|
*/
|
|
constructor(containers = [], options = {}) {
|
|
super(containers, options);
|
|
|
|
/**
|
|
* Draggable element needs to be remembered to unset the draggable attribute after drag operation has completed
|
|
* @property mightDrag
|
|
* @type {Boolean}
|
|
*/
|
|
this.mightDrag = false;
|
|
|
|
this[onMouseForceWillBegin] = this[onMouseForceWillBegin].bind(this);
|
|
this[onMouseForceDown] = this[onMouseForceDown].bind(this);
|
|
this[onMouseDown] = this[onMouseDown].bind(this);
|
|
this[onMouseForceChange] = this[onMouseForceChange].bind(this);
|
|
this[onMouseMove] = this[onMouseMove].bind(this);
|
|
this[onMouseUp] = this[onMouseUp].bind(this);
|
|
}
|
|
|
|
/**
|
|
* Attaches sensors event listeners to the DOM
|
|
*/
|
|
attach() {
|
|
for (const container of this.containers) {
|
|
container.addEventListener('webkitmouseforcewillbegin', this[onMouseForceWillBegin], false);
|
|
container.addEventListener('webkitmouseforcedown', this[onMouseForceDown], false);
|
|
container.addEventListener('mousedown', this[onMouseDown], true);
|
|
container.addEventListener('webkitmouseforcechanged', this[onMouseForceChange], false);
|
|
}
|
|
|
|
document.addEventListener('mousemove', this[onMouseMove]);
|
|
document.addEventListener('mouseup', this[onMouseUp]);
|
|
}
|
|
|
|
/**
|
|
* Detaches sensors event listeners to the DOM
|
|
*/
|
|
detach() {
|
|
for (const container of this.containers) {
|
|
container.removeEventListener('webkitmouseforcewillbegin', this[onMouseForceWillBegin], false);
|
|
container.removeEventListener('webkitmouseforcedown', this[onMouseForceDown], false);
|
|
container.removeEventListener('mousedown', this[onMouseDown], true);
|
|
container.removeEventListener('webkitmouseforcechanged', this[onMouseForceChange], false);
|
|
}
|
|
|
|
document.removeEventListener('mousemove', this[onMouseMove]);
|
|
document.removeEventListener('mouseup', this[onMouseUp]);
|
|
}
|
|
|
|
/**
|
|
* Mouse force will begin handler
|
|
* @private
|
|
* @param {Event} event - Mouse force will begin event
|
|
*/
|
|
[onMouseForceWillBegin](event) {
|
|
event.preventDefault();
|
|
this.mightDrag = true;
|
|
}
|
|
|
|
/**
|
|
* Mouse force down handler
|
|
* @private
|
|
* @param {Event} event - Mouse force down event
|
|
*/
|
|
[onMouseForceDown](event) {
|
|
if (this.dragging) {
|
|
return;
|
|
}
|
|
|
|
const target = document.elementFromPoint(event.clientX, event.clientY);
|
|
const container = event.currentTarget;
|
|
|
|
const dragStartEvent = new _SensorEvent.DragStartSensorEvent({
|
|
clientX: event.clientX,
|
|
clientY: event.clientY,
|
|
target,
|
|
container,
|
|
originalEvent: event
|
|
});
|
|
|
|
this.trigger(container, dragStartEvent);
|
|
|
|
this.currentContainer = container;
|
|
this.dragging = !dragStartEvent.canceled();
|
|
this.mightDrag = false;
|
|
}
|
|
|
|
/**
|
|
* Mouse up handler
|
|
* @private
|
|
* @param {Event} event - Mouse up event
|
|
*/
|
|
[onMouseUp](event) {
|
|
if (!this.dragging) {
|
|
return;
|
|
}
|
|
|
|
const dragStopEvent = new _SensorEvent.DragStopSensorEvent({
|
|
clientX: event.clientX,
|
|
clientY: event.clientY,
|
|
target: null,
|
|
container: this.currentContainer,
|
|
originalEvent: event
|
|
});
|
|
|
|
this.trigger(this.currentContainer, dragStopEvent);
|
|
|
|
this.currentContainer = null;
|
|
this.dragging = false;
|
|
this.mightDrag = false;
|
|
}
|
|
|
|
/**
|
|
* Mouse down handler
|
|
* @private
|
|
* @param {Event} event - Mouse down event
|
|
*/
|
|
[onMouseDown](event) {
|
|
if (!this.mightDrag) {
|
|
return;
|
|
}
|
|
|
|
// Need workaround for real click
|
|
// Cancel potential drag events
|
|
event.stopPropagation();
|
|
event.stopImmediatePropagation();
|
|
event.preventDefault();
|
|
}
|
|
|
|
/**
|
|
* Mouse move handler
|
|
* @private
|
|
* @param {Event} event - Mouse force will begin event
|
|
*/
|
|
[onMouseMove](event) {
|
|
if (!this.dragging) {
|
|
return;
|
|
}
|
|
|
|
const target = document.elementFromPoint(event.clientX, event.clientY);
|
|
|
|
const dragMoveEvent = new _SensorEvent.DragMoveSensorEvent({
|
|
clientX: event.clientX,
|
|
clientY: event.clientY,
|
|
target,
|
|
container: this.currentContainer,
|
|
originalEvent: event
|
|
});
|
|
|
|
this.trigger(this.currentContainer, dragMoveEvent);
|
|
}
|
|
|
|
/**
|
|
* Mouse force change handler
|
|
* @private
|
|
* @param {Event} event - Mouse force change event
|
|
*/
|
|
[onMouseForceChange](event) {
|
|
if (this.dragging) {
|
|
return;
|
|
}
|
|
|
|
const target = event.target;
|
|
const container = event.currentTarget;
|
|
|
|
const dragPressureEvent = new _SensorEvent.DragPressureSensorEvent({
|
|
pressure: event.webkitForce,
|
|
clientX: event.clientX,
|
|
clientY: event.clientY,
|
|
target,
|
|
container,
|
|
originalEvent: event
|
|
});
|
|
|
|
this.trigger(container, dragPressureEvent);
|
|
}
|
|
|
|
/**
|
|
* Mouse force global change handler
|
|
* @private
|
|
* @param {Event} event - Mouse force global change event
|
|
*/
|
|
[onMouseForceGlobalChange](event) {
|
|
if (!this.dragging) {
|
|
return;
|
|
}
|
|
|
|
const target = event.target;
|
|
|
|
const dragPressureEvent = new _SensorEvent.DragPressureSensorEvent({
|
|
pressure: event.webkitForce,
|
|
clientX: event.clientX,
|
|
clientY: event.clientY,
|
|
target,
|
|
container: this.currentContainer,
|
|
originalEvent: event
|
|
});
|
|
|
|
this.trigger(this.currentContainer, dragPressureEvent);
|
|
}
|
|
}
|
|
exports.default = ForceTouchSensor;
|
|
|
|
/***/ }),
|
|
/* 41 */
|
|
/***/ (function(module, exports, __nested_webpack_require_114097__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _ForceTouchSensor = __nested_webpack_require_114097__(40);
|
|
|
|
var _ForceTouchSensor2 = _interopRequireDefault(_ForceTouchSensor);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _ForceTouchSensor2.default;
|
|
|
|
/***/ }),
|
|
/* 42 */
|
|
/***/ (function(module, exports, __nested_webpack_require_114518__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _utils = __nested_webpack_require_114518__(2);
|
|
|
|
var _Sensor = __nested_webpack_require_114518__(4);
|
|
|
|
var _Sensor2 = _interopRequireDefault(_Sensor);
|
|
|
|
var _SensorEvent = __nested_webpack_require_114518__(3);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
const onMouseDown = Symbol('onMouseDown');
|
|
const onMouseUp = Symbol('onMouseUp');
|
|
const onDragStart = Symbol('onDragStart');
|
|
const onDragOver = Symbol('onDragOver');
|
|
const onDragEnd = Symbol('onDragEnd');
|
|
const onDrop = Symbol('onDrop');
|
|
const reset = Symbol('reset');
|
|
|
|
/**
|
|
* This sensor picks up native browser drag events and dictates drag operations
|
|
* @class DragSensor
|
|
* @module DragSensor
|
|
* @extends Sensor
|
|
*/
|
|
class DragSensor extends _Sensor2.default {
|
|
/**
|
|
* DragSensor constructor.
|
|
* @constructs DragSensor
|
|
* @param {HTMLElement[]|NodeList|HTMLElement} containers - Containers
|
|
* @param {Object} options - Options
|
|
*/
|
|
constructor(containers = [], options = {}) {
|
|
super(containers, options);
|
|
|
|
/**
|
|
* Mouse down timer which will end up setting the draggable attribute, unless canceled
|
|
* @property mouseDownTimeout
|
|
* @type {Number}
|
|
*/
|
|
this.mouseDownTimeout = null;
|
|
|
|
/**
|
|
* Draggable element needs to be remembered to unset the draggable attribute after drag operation has completed
|
|
* @property draggableElement
|
|
* @type {HTMLElement}
|
|
*/
|
|
this.draggableElement = null;
|
|
|
|
/**
|
|
* Native draggable element could be links or images, their draggable state will be disabled during drag operation
|
|
* @property nativeDraggableElement
|
|
* @type {HTMLElement}
|
|
*/
|
|
this.nativeDraggableElement = null;
|
|
|
|
this[onMouseDown] = this[onMouseDown].bind(this);
|
|
this[onMouseUp] = this[onMouseUp].bind(this);
|
|
this[onDragStart] = this[onDragStart].bind(this);
|
|
this[onDragOver] = this[onDragOver].bind(this);
|
|
this[onDragEnd] = this[onDragEnd].bind(this);
|
|
this[onDrop] = this[onDrop].bind(this);
|
|
}
|
|
|
|
/**
|
|
* Attaches sensors event listeners to the DOM
|
|
*/
|
|
attach() {
|
|
document.addEventListener('mousedown', this[onMouseDown], true);
|
|
}
|
|
|
|
/**
|
|
* Detaches sensors event listeners to the DOM
|
|
*/
|
|
detach() {
|
|
document.removeEventListener('mousedown', this[onMouseDown], true);
|
|
}
|
|
|
|
/**
|
|
* Drag start handler
|
|
* @private
|
|
* @param {Event} event - Drag start event
|
|
*/
|
|
[onDragStart](event) {
|
|
// Need for firefox. "text" key is needed for IE
|
|
event.dataTransfer.setData('text', '');
|
|
event.dataTransfer.effectAllowed = this.options.type;
|
|
|
|
const target = document.elementFromPoint(event.clientX, event.clientY);
|
|
this.currentContainer = (0, _utils.closest)(event.target, this.containers);
|
|
|
|
if (!this.currentContainer) {
|
|
return;
|
|
}
|
|
|
|
const dragStartEvent = new _SensorEvent.DragStartSensorEvent({
|
|
clientX: event.clientX,
|
|
clientY: event.clientY,
|
|
target,
|
|
container: this.currentContainer,
|
|
originalEvent: event
|
|
});
|
|
|
|
// Workaround
|
|
setTimeout(() => {
|
|
this.trigger(this.currentContainer, dragStartEvent);
|
|
|
|
if (dragStartEvent.canceled()) {
|
|
this.dragging = false;
|
|
} else {
|
|
this.dragging = true;
|
|
}
|
|
}, 0);
|
|
}
|
|
|
|
/**
|
|
* Drag over handler
|
|
* @private
|
|
* @param {Event} event - Drag over event
|
|
*/
|
|
[onDragOver](event) {
|
|
if (!this.dragging) {
|
|
return;
|
|
}
|
|
|
|
const target = document.elementFromPoint(event.clientX, event.clientY);
|
|
const container = this.currentContainer;
|
|
|
|
const dragMoveEvent = new _SensorEvent.DragMoveSensorEvent({
|
|
clientX: event.clientX,
|
|
clientY: event.clientY,
|
|
target,
|
|
container,
|
|
originalEvent: event
|
|
});
|
|
|
|
this.trigger(container, dragMoveEvent);
|
|
|
|
if (!dragMoveEvent.canceled()) {
|
|
event.preventDefault();
|
|
event.dataTransfer.dropEffect = this.options.type;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Drag end handler
|
|
* @private
|
|
* @param {Event} event - Drag end event
|
|
*/
|
|
[onDragEnd](event) {
|
|
if (!this.dragging) {
|
|
return;
|
|
}
|
|
|
|
document.removeEventListener('mouseup', this[onMouseUp], true);
|
|
|
|
const target = document.elementFromPoint(event.clientX, event.clientY);
|
|
const container = this.currentContainer;
|
|
|
|
const dragStopEvent = new _SensorEvent.DragStopSensorEvent({
|
|
clientX: event.clientX,
|
|
clientY: event.clientY,
|
|
target,
|
|
container,
|
|
originalEvent: event
|
|
});
|
|
|
|
this.trigger(container, dragStopEvent);
|
|
|
|
this.dragging = false;
|
|
this.startEvent = null;
|
|
|
|
this[reset]();
|
|
}
|
|
|
|
/**
|
|
* Drop handler
|
|
* @private
|
|
* @param {Event} event - Drop event
|
|
*/
|
|
[onDrop](event) {
|
|
// eslint-disable-line class-methods-use-this
|
|
event.preventDefault();
|
|
}
|
|
|
|
/**
|
|
* Mouse down handler
|
|
* @private
|
|
* @param {Event} event - Mouse down event
|
|
*/
|
|
[onMouseDown](event) {
|
|
// Firefox bug for inputs within draggables https://bugzilla.mozilla.org/show_bug.cgi?id=739071
|
|
if (event.target && (event.target.form || event.target.contenteditable)) {
|
|
return;
|
|
}
|
|
|
|
const nativeDraggableElement = (0, _utils.closest)(event.target, element => element.draggable);
|
|
|
|
if (nativeDraggableElement) {
|
|
nativeDraggableElement.draggable = false;
|
|
this.nativeDraggableElement = nativeDraggableElement;
|
|
}
|
|
|
|
document.addEventListener('mouseup', this[onMouseUp], true);
|
|
document.addEventListener('dragstart', this[onDragStart], false);
|
|
document.addEventListener('dragover', this[onDragOver], false);
|
|
document.addEventListener('dragend', this[onDragEnd], false);
|
|
document.addEventListener('drop', this[onDrop], false);
|
|
|
|
const target = (0, _utils.closest)(event.target, this.options.draggable);
|
|
|
|
if (!target) {
|
|
return;
|
|
}
|
|
|
|
this.startEvent = event;
|
|
|
|
this.mouseDownTimeout = setTimeout(() => {
|
|
target.draggable = true;
|
|
this.draggableElement = target;
|
|
}, this.delay.drag);
|
|
}
|
|
|
|
/**
|
|
* Mouse up handler
|
|
* @private
|
|
* @param {Event} event - Mouse up event
|
|
*/
|
|
[onMouseUp]() {
|
|
this[reset]();
|
|
}
|
|
|
|
/**
|
|
* Mouse up handler
|
|
* @private
|
|
* @param {Event} event - Mouse up event
|
|
*/
|
|
[reset]() {
|
|
clearTimeout(this.mouseDownTimeout);
|
|
|
|
document.removeEventListener('mouseup', this[onMouseUp], true);
|
|
document.removeEventListener('dragstart', this[onDragStart], false);
|
|
document.removeEventListener('dragover', this[onDragOver], false);
|
|
document.removeEventListener('dragend', this[onDragEnd], false);
|
|
document.removeEventListener('drop', this[onDrop], false);
|
|
|
|
if (this.nativeDraggableElement) {
|
|
this.nativeDraggableElement.draggable = true;
|
|
this.nativeDraggableElement = null;
|
|
}
|
|
|
|
if (this.draggableElement) {
|
|
this.draggableElement.draggable = false;
|
|
this.draggableElement = null;
|
|
}
|
|
}
|
|
}
|
|
exports.default = DragSensor;
|
|
|
|
/***/ }),
|
|
/* 43 */
|
|
/***/ (function(module, exports, __nested_webpack_require_121522__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _DragSensor = __nested_webpack_require_121522__(42);
|
|
|
|
var _DragSensor2 = _interopRequireDefault(_DragSensor);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _DragSensor2.default;
|
|
|
|
/***/ }),
|
|
/* 44 */
|
|
/***/ (function(module, exports, __nested_webpack_require_121919__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _utils = __nested_webpack_require_121919__(2);
|
|
|
|
var _Sensor = __nested_webpack_require_121919__(4);
|
|
|
|
var _Sensor2 = _interopRequireDefault(_Sensor);
|
|
|
|
var _SensorEvent = __nested_webpack_require_121919__(3);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
const onTouchStart = Symbol('onTouchStart');
|
|
const onTouchEnd = Symbol('onTouchEnd');
|
|
const onTouchMove = Symbol('onTouchMove');
|
|
const startDrag = Symbol('startDrag');
|
|
const onDistanceChange = Symbol('onDistanceChange');
|
|
|
|
/**
|
|
* Prevents scrolling when set to true
|
|
* @var {Boolean} preventScrolling
|
|
*/
|
|
let preventScrolling = false;
|
|
|
|
// WebKit requires cancelable `touchmove` events to be added as early as possible
|
|
window.addEventListener('touchmove', event => {
|
|
if (!preventScrolling) {
|
|
return;
|
|
}
|
|
|
|
// Prevent scrolling
|
|
event.preventDefault();
|
|
}, { passive: false });
|
|
|
|
/**
|
|
* This sensor picks up native browser touch events and dictates drag operations
|
|
* @class TouchSensor
|
|
* @module TouchSensor
|
|
* @extends Sensor
|
|
*/
|
|
class TouchSensor extends _Sensor2.default {
|
|
/**
|
|
* TouchSensor constructor.
|
|
* @constructs TouchSensor
|
|
* @param {HTMLElement[]|NodeList|HTMLElement} containers - Containers
|
|
* @param {Object} options - Options
|
|
*/
|
|
constructor(containers = [], options = {}) {
|
|
super(containers, options);
|
|
|
|
/**
|
|
* Closest scrollable container so accidental scroll can cancel long touch
|
|
* @property currentScrollableParent
|
|
* @type {HTMLElement}
|
|
*/
|
|
this.currentScrollableParent = null;
|
|
|
|
/**
|
|
* TimeoutID for managing delay
|
|
* @property tapTimeout
|
|
* @type {Number}
|
|
*/
|
|
this.tapTimeout = null;
|
|
|
|
/**
|
|
* touchMoved indicates if touch has moved during tapTimeout
|
|
* @property touchMoved
|
|
* @type {Boolean}
|
|
*/
|
|
this.touchMoved = false;
|
|
|
|
/**
|
|
* Save pageX coordinates for delay drag
|
|
* @property {Numbre} pageX
|
|
* @private
|
|
*/
|
|
this.pageX = null;
|
|
|
|
/**
|
|
* Save pageY coordinates for delay drag
|
|
* @property {Numbre} pageY
|
|
* @private
|
|
*/
|
|
this.pageY = null;
|
|
|
|
this[onTouchStart] = this[onTouchStart].bind(this);
|
|
this[onTouchEnd] = this[onTouchEnd].bind(this);
|
|
this[onTouchMove] = this[onTouchMove].bind(this);
|
|
this[startDrag] = this[startDrag].bind(this);
|
|
this[onDistanceChange] = this[onDistanceChange].bind(this);
|
|
}
|
|
|
|
/**
|
|
* Attaches sensors event listeners to the DOM
|
|
*/
|
|
attach() {
|
|
document.addEventListener('touchstart', this[onTouchStart]);
|
|
}
|
|
|
|
/**
|
|
* Detaches sensors event listeners to the DOM
|
|
*/
|
|
detach() {
|
|
document.removeEventListener('touchstart', this[onTouchStart]);
|
|
}
|
|
|
|
/**
|
|
* Touch start handler
|
|
* @private
|
|
* @param {Event} event - Touch start event
|
|
*/
|
|
[onTouchStart](event) {
|
|
const container = (0, _utils.closest)(event.target, this.containers);
|
|
|
|
if (!container) {
|
|
return;
|
|
}
|
|
const { distance = 0 } = this.options;
|
|
const { delay } = this;
|
|
const { pageX, pageY } = (0, _utils.touchCoords)(event);
|
|
|
|
Object.assign(this, { pageX, pageY });
|
|
this.onTouchStartAt = Date.now();
|
|
this.startEvent = event;
|
|
this.currentContainer = container;
|
|
|
|
document.addEventListener('touchend', this[onTouchEnd]);
|
|
document.addEventListener('touchcancel', this[onTouchEnd]);
|
|
document.addEventListener('touchmove', this[onDistanceChange]);
|
|
container.addEventListener('contextmenu', onContextMenu);
|
|
|
|
if (distance) {
|
|
preventScrolling = true;
|
|
}
|
|
|
|
this.tapTimeout = window.setTimeout(() => {
|
|
this[onDistanceChange]({ touches: [{ pageX: this.pageX, pageY: this.pageY }] });
|
|
}, delay.touch);
|
|
}
|
|
|
|
/**
|
|
* Start the drag
|
|
* @private
|
|
*/
|
|
[startDrag]() {
|
|
const startEvent = this.startEvent;
|
|
const container = this.currentContainer;
|
|
const touch = (0, _utils.touchCoords)(startEvent);
|
|
|
|
const dragStartEvent = new _SensorEvent.DragStartSensorEvent({
|
|
clientX: touch.pageX,
|
|
clientY: touch.pageY,
|
|
target: startEvent.target,
|
|
container,
|
|
originalEvent: startEvent
|
|
});
|
|
|
|
this.trigger(this.currentContainer, dragStartEvent);
|
|
|
|
this.dragging = !dragStartEvent.canceled();
|
|
|
|
if (this.dragging) {
|
|
document.addEventListener('touchmove', this[onTouchMove]);
|
|
}
|
|
preventScrolling = this.dragging;
|
|
}
|
|
|
|
/**
|
|
* Touch move handler prior to drag start.
|
|
* @private
|
|
* @param {Event} event - Touch move event
|
|
*/
|
|
[onDistanceChange](event) {
|
|
const { distance } = this.options;
|
|
const { startEvent, delay } = this;
|
|
const start = (0, _utils.touchCoords)(startEvent);
|
|
const current = (0, _utils.touchCoords)(event);
|
|
const timeElapsed = Date.now() - this.onTouchStartAt;
|
|
const distanceTravelled = (0, _utils.distance)(start.pageX, start.pageY, current.pageX, current.pageY);
|
|
|
|
Object.assign(this, current);
|
|
|
|
clearTimeout(this.tapTimeout);
|
|
|
|
if (timeElapsed < delay.touch) {
|
|
// moved during delay
|
|
document.removeEventListener('touchmove', this[onDistanceChange]);
|
|
} else if (distanceTravelled >= distance) {
|
|
document.removeEventListener('touchmove', this[onDistanceChange]);
|
|
this[startDrag]();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Mouse move handler while dragging
|
|
* @private
|
|
* @param {Event} event - Touch move event
|
|
*/
|
|
[onTouchMove](event) {
|
|
if (!this.dragging) {
|
|
return;
|
|
}
|
|
const { pageX, pageY } = (0, _utils.touchCoords)(event);
|
|
const target = document.elementFromPoint(pageX - window.scrollX, pageY - window.scrollY);
|
|
|
|
const dragMoveEvent = new _SensorEvent.DragMoveSensorEvent({
|
|
clientX: pageX,
|
|
clientY: pageY,
|
|
target,
|
|
container: this.currentContainer,
|
|
originalEvent: event
|
|
});
|
|
|
|
this.trigger(this.currentContainer, dragMoveEvent);
|
|
}
|
|
|
|
/**
|
|
* Touch end handler
|
|
* @private
|
|
* @param {Event} event - Touch end event
|
|
*/
|
|
[onTouchEnd](event) {
|
|
clearTimeout(this.tapTimeout);
|
|
preventScrolling = false;
|
|
|
|
document.removeEventListener('touchend', this[onTouchEnd]);
|
|
document.removeEventListener('touchcancel', this[onTouchEnd]);
|
|
document.removeEventListener('touchmove', this[onDistanceChange]);
|
|
|
|
if (this.currentContainer) {
|
|
this.currentContainer.removeEventListener('contextmenu', onContextMenu);
|
|
}
|
|
|
|
if (!this.dragging) {
|
|
return;
|
|
}
|
|
|
|
document.removeEventListener('touchmove', this[onTouchMove]);
|
|
|
|
const { pageX, pageY } = (0, _utils.touchCoords)(event);
|
|
const target = document.elementFromPoint(pageX - window.scrollX, pageY - window.scrollY);
|
|
|
|
event.preventDefault();
|
|
|
|
const dragStopEvent = new _SensorEvent.DragStopSensorEvent({
|
|
clientX: pageX,
|
|
clientY: pageY,
|
|
target,
|
|
container: this.currentContainer,
|
|
originalEvent: event
|
|
});
|
|
|
|
this.trigger(this.currentContainer, dragStopEvent);
|
|
|
|
this.currentContainer = null;
|
|
this.dragging = false;
|
|
this.startEvent = null;
|
|
}
|
|
}
|
|
|
|
exports.default = TouchSensor;
|
|
function onContextMenu(event) {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
}
|
|
|
|
/***/ }),
|
|
/* 45 */
|
|
/***/ (function(module, exports, __nested_webpack_require_129124__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _TouchSensor = __nested_webpack_require_129124__(44);
|
|
|
|
var _TouchSensor2 = _interopRequireDefault(_TouchSensor);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _TouchSensor2.default;
|
|
|
|
/***/ }),
|
|
/* 46 */
|
|
/***/ (function(module, exports, __nested_webpack_require_129525__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.DragPressureSensorEvent = exports.DragStopSensorEvent = exports.DragMoveSensorEvent = exports.DragStartSensorEvent = exports.SensorEvent = undefined;
|
|
|
|
var _AbstractEvent = __nested_webpack_require_129525__(1);
|
|
|
|
var _AbstractEvent2 = _interopRequireDefault(_AbstractEvent);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
/**
|
|
* Base sensor event
|
|
* @class SensorEvent
|
|
* @module SensorEvent
|
|
* @extends AbstractEvent
|
|
*/
|
|
class SensorEvent extends _AbstractEvent2.default {
|
|
/**
|
|
* Original browser event that triggered a sensor
|
|
* @property originalEvent
|
|
* @type {Event}
|
|
* @readonly
|
|
*/
|
|
get originalEvent() {
|
|
return this.data.originalEvent;
|
|
}
|
|
|
|
/**
|
|
* Normalized clientX for both touch and mouse events
|
|
* @property clientX
|
|
* @type {Number}
|
|
* @readonly
|
|
*/
|
|
get clientX() {
|
|
return this.data.clientX;
|
|
}
|
|
|
|
/**
|
|
* Normalized clientY for both touch and mouse events
|
|
* @property clientY
|
|
* @type {Number}
|
|
* @readonly
|
|
*/
|
|
get clientY() {
|
|
return this.data.clientY;
|
|
}
|
|
|
|
/**
|
|
* Normalized target for both touch and mouse events
|
|
* Returns the element that is behind cursor or touch pointer
|
|
* @property target
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get target() {
|
|
return this.data.target;
|
|
}
|
|
|
|
/**
|
|
* Container that initiated the sensor
|
|
* @property container
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get container() {
|
|
return this.data.container;
|
|
}
|
|
|
|
/**
|
|
* Trackpad pressure
|
|
* @property pressure
|
|
* @type {Number}
|
|
* @readonly
|
|
*/
|
|
get pressure() {
|
|
return this.data.pressure;
|
|
}
|
|
}
|
|
|
|
exports.SensorEvent = SensorEvent; /**
|
|
* Drag start sensor event
|
|
* @class DragStartSensorEvent
|
|
* @module DragStartSensorEvent
|
|
* @extends SensorEvent
|
|
*/
|
|
|
|
class DragStartSensorEvent extends SensorEvent {}
|
|
|
|
exports.DragStartSensorEvent = DragStartSensorEvent; /**
|
|
* Drag move sensor event
|
|
* @class DragMoveSensorEvent
|
|
* @module DragMoveSensorEvent
|
|
* @extends SensorEvent
|
|
*/
|
|
|
|
DragStartSensorEvent.type = 'drag:start';
|
|
class DragMoveSensorEvent extends SensorEvent {}
|
|
|
|
exports.DragMoveSensorEvent = DragMoveSensorEvent; /**
|
|
* Drag stop sensor event
|
|
* @class DragStopSensorEvent
|
|
* @module DragStopSensorEvent
|
|
* @extends SensorEvent
|
|
*/
|
|
|
|
DragMoveSensorEvent.type = 'drag:move';
|
|
class DragStopSensorEvent extends SensorEvent {}
|
|
|
|
exports.DragStopSensorEvent = DragStopSensorEvent; /**
|
|
* Drag pressure sensor event
|
|
* @class DragPressureSensorEvent
|
|
* @module DragPressureSensorEvent
|
|
* @extends SensorEvent
|
|
*/
|
|
|
|
DragStopSensorEvent.type = 'drag:stop';
|
|
class DragPressureSensorEvent extends SensorEvent {}
|
|
exports.DragPressureSensorEvent = DragPressureSensorEvent;
|
|
DragPressureSensorEvent.type = 'drag:pressure';
|
|
|
|
/***/ }),
|
|
/* 47 */
|
|
/***/ (function(module, exports, __nested_webpack_require_133388__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _utils = __nested_webpack_require_133388__(2);
|
|
|
|
var _Sensor = __nested_webpack_require_133388__(4);
|
|
|
|
var _Sensor2 = _interopRequireDefault(_Sensor);
|
|
|
|
var _SensorEvent = __nested_webpack_require_133388__(3);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
const onContextMenuWhileDragging = Symbol('onContextMenuWhileDragging');
|
|
const onMouseDown = Symbol('onMouseDown');
|
|
const onMouseMove = Symbol('onMouseMove');
|
|
const onMouseUp = Symbol('onMouseUp');
|
|
const startDrag = Symbol('startDrag');
|
|
const onDistanceChange = Symbol('onDistanceChange');
|
|
|
|
/**
|
|
* This sensor picks up native browser mouse events and dictates drag operations
|
|
* @class MouseSensor
|
|
* @module MouseSensor
|
|
* @extends Sensor
|
|
*/
|
|
class MouseSensor extends _Sensor2.default {
|
|
/**
|
|
* MouseSensor constructor.
|
|
* @constructs MouseSensor
|
|
* @param {HTMLElement[]|NodeList|HTMLElement} containers - Containers
|
|
* @param {Object} options - Options
|
|
*/
|
|
constructor(containers = [], options = {}) {
|
|
super(containers, options);
|
|
|
|
/**
|
|
* Mouse down timer which will end up triggering the drag start operation
|
|
* @property mouseDownTimeout
|
|
* @type {Number}
|
|
*/
|
|
this.mouseDownTimeout = null;
|
|
|
|
/**
|
|
* Save pageX coordinates for delay drag
|
|
* @property {Numbre} pageX
|
|
* @private
|
|
*/
|
|
this.pageX = null;
|
|
|
|
/**
|
|
* Save pageY coordinates for delay drag
|
|
* @property {Numbre} pageY
|
|
* @private
|
|
*/
|
|
this.pageY = null;
|
|
|
|
this[onContextMenuWhileDragging] = this[onContextMenuWhileDragging].bind(this);
|
|
this[onMouseDown] = this[onMouseDown].bind(this);
|
|
this[onMouseMove] = this[onMouseMove].bind(this);
|
|
this[onMouseUp] = this[onMouseUp].bind(this);
|
|
this[startDrag] = this[startDrag].bind(this);
|
|
this[onDistanceChange] = this[onDistanceChange].bind(this);
|
|
}
|
|
|
|
/**
|
|
* Attaches sensors event listeners to the DOM
|
|
*/
|
|
attach() {
|
|
document.addEventListener('mousedown', this[onMouseDown], true);
|
|
}
|
|
|
|
/**
|
|
* Detaches sensors event listeners to the DOM
|
|
*/
|
|
detach() {
|
|
document.removeEventListener('mousedown', this[onMouseDown], true);
|
|
}
|
|
|
|
/**
|
|
* Mouse down handler
|
|
* @private
|
|
* @param {Event} event - Mouse down event
|
|
*/
|
|
[onMouseDown](event) {
|
|
if (event.button !== 0 || event.ctrlKey || event.metaKey) {
|
|
return;
|
|
}
|
|
const container = (0, _utils.closest)(event.target, this.containers);
|
|
|
|
if (!container) {
|
|
return;
|
|
}
|
|
|
|
const { delay } = this;
|
|
const { pageX, pageY } = event;
|
|
|
|
Object.assign(this, { pageX, pageY });
|
|
this.onMouseDownAt = Date.now();
|
|
this.startEvent = event;
|
|
|
|
this.currentContainer = container;
|
|
document.addEventListener('mouseup', this[onMouseUp]);
|
|
document.addEventListener('dragstart', preventNativeDragStart);
|
|
document.addEventListener('mousemove', this[onDistanceChange]);
|
|
|
|
this.mouseDownTimeout = window.setTimeout(() => {
|
|
this[onDistanceChange]({ pageX: this.pageX, pageY: this.pageY });
|
|
}, delay.mouse);
|
|
}
|
|
|
|
/**
|
|
* Start the drag
|
|
* @private
|
|
*/
|
|
[startDrag]() {
|
|
const startEvent = this.startEvent;
|
|
const container = this.currentContainer;
|
|
|
|
const dragStartEvent = new _SensorEvent.DragStartSensorEvent({
|
|
clientX: startEvent.clientX,
|
|
clientY: startEvent.clientY,
|
|
target: startEvent.target,
|
|
container,
|
|
originalEvent: startEvent
|
|
});
|
|
|
|
this.trigger(this.currentContainer, dragStartEvent);
|
|
|
|
this.dragging = !dragStartEvent.canceled();
|
|
|
|
if (this.dragging) {
|
|
document.addEventListener('contextmenu', this[onContextMenuWhileDragging], true);
|
|
document.addEventListener('mousemove', this[onMouseMove]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Detect change in distance, starting drag when both
|
|
* delay and distance requirements are met
|
|
* @private
|
|
* @param {Event} event - Mouse move event
|
|
*/
|
|
[onDistanceChange](event) {
|
|
const { pageX, pageY } = event;
|
|
const { distance } = this.options;
|
|
const { startEvent, delay } = this;
|
|
|
|
Object.assign(this, { pageX, pageY });
|
|
|
|
if (!this.currentContainer) {
|
|
return;
|
|
}
|
|
|
|
const timeElapsed = Date.now() - this.onMouseDownAt;
|
|
const distanceTravelled = (0, _utils.distance)(startEvent.pageX, startEvent.pageY, pageX, pageY) || 0;
|
|
|
|
clearTimeout(this.mouseDownTimeout);
|
|
|
|
if (timeElapsed < delay.mouse) {
|
|
// moved during delay
|
|
document.removeEventListener('mousemove', this[onDistanceChange]);
|
|
} else if (distanceTravelled >= distance) {
|
|
document.removeEventListener('mousemove', this[onDistanceChange]);
|
|
this[startDrag]();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Mouse move handler
|
|
* @private
|
|
* @param {Event} event - Mouse move event
|
|
*/
|
|
[onMouseMove](event) {
|
|
if (!this.dragging) {
|
|
return;
|
|
}
|
|
|
|
const target = document.elementFromPoint(event.clientX, event.clientY);
|
|
|
|
const dragMoveEvent = new _SensorEvent.DragMoveSensorEvent({
|
|
clientX: event.clientX,
|
|
clientY: event.clientY,
|
|
target,
|
|
container: this.currentContainer,
|
|
originalEvent: event
|
|
});
|
|
|
|
this.trigger(this.currentContainer, dragMoveEvent);
|
|
}
|
|
|
|
/**
|
|
* Mouse up handler
|
|
* @private
|
|
* @param {Event} event - Mouse up event
|
|
*/
|
|
[onMouseUp](event) {
|
|
clearTimeout(this.mouseDownTimeout);
|
|
|
|
if (event.button !== 0) {
|
|
return;
|
|
}
|
|
|
|
document.removeEventListener('mouseup', this[onMouseUp]);
|
|
document.removeEventListener('dragstart', preventNativeDragStart);
|
|
document.removeEventListener('mousemove', this[onDistanceChange]);
|
|
|
|
if (!this.dragging) {
|
|
return;
|
|
}
|
|
|
|
const target = document.elementFromPoint(event.clientX, event.clientY);
|
|
|
|
const dragStopEvent = new _SensorEvent.DragStopSensorEvent({
|
|
clientX: event.clientX,
|
|
clientY: event.clientY,
|
|
target,
|
|
container: this.currentContainer,
|
|
originalEvent: event
|
|
});
|
|
|
|
this.trigger(this.currentContainer, dragStopEvent);
|
|
|
|
document.removeEventListener('contextmenu', this[onContextMenuWhileDragging], true);
|
|
document.removeEventListener('mousemove', this[onMouseMove]);
|
|
|
|
this.currentContainer = null;
|
|
this.dragging = false;
|
|
this.startEvent = null;
|
|
}
|
|
|
|
/**
|
|
* Context menu handler
|
|
* @private
|
|
* @param {Event} event - Context menu event
|
|
*/
|
|
[onContextMenuWhileDragging](event) {
|
|
event.preventDefault();
|
|
}
|
|
}
|
|
|
|
exports.default = MouseSensor;
|
|
function preventNativeDragStart(event) {
|
|
event.preventDefault();
|
|
}
|
|
|
|
/***/ }),
|
|
/* 48 */
|
|
/***/ (function(module, exports, __nested_webpack_require_140006__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _MouseSensor = __nested_webpack_require_140006__(47);
|
|
|
|
var _MouseSensor2 = _interopRequireDefault(_MouseSensor);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _MouseSensor2.default;
|
|
|
|
/***/ }),
|
|
/* 49 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _extends = Object.assign || 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; };
|
|
|
|
const defaultDealy = {
|
|
mouse: 0,
|
|
drag: 0,
|
|
touch: 100
|
|
};
|
|
|
|
/**
|
|
* Base sensor class. Extend from this class to create a new or custom sensor
|
|
* @class Sensor
|
|
* @module Sensor
|
|
*/
|
|
class Sensor {
|
|
/**
|
|
* Sensor constructor.
|
|
* @constructs Sensor
|
|
* @param {HTMLElement[]|NodeList|HTMLElement} containers - Containers
|
|
* @param {Object} options - Options
|
|
*/
|
|
constructor(containers = [], options = {}) {
|
|
/**
|
|
* Current containers
|
|
* @property containers
|
|
* @type {HTMLElement[]}
|
|
*/
|
|
this.containers = [...containers];
|
|
|
|
/**
|
|
* Current options
|
|
* @property options
|
|
* @type {Object}
|
|
*/
|
|
this.options = _extends({}, options);
|
|
|
|
/**
|
|
* Current drag state
|
|
* @property dragging
|
|
* @type {Boolean}
|
|
*/
|
|
this.dragging = false;
|
|
|
|
/**
|
|
* Current container
|
|
* @property currentContainer
|
|
* @type {HTMLElement}
|
|
*/
|
|
this.currentContainer = null;
|
|
|
|
/**
|
|
* The event of the initial sensor down
|
|
* @property startEvent
|
|
* @type {Event}
|
|
*/
|
|
this.startEvent = null;
|
|
|
|
/**
|
|
* The delay of each sensor
|
|
* @property delay
|
|
* @type {Object}
|
|
*/
|
|
this.delay = calcDelay(options.delay);
|
|
}
|
|
|
|
/**
|
|
* Attaches sensors event listeners to the DOM
|
|
* @return {Sensor}
|
|
*/
|
|
attach() {
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Detaches sensors event listeners to the DOM
|
|
* @return {Sensor}
|
|
*/
|
|
detach() {
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Adds container to this sensor instance
|
|
* @param {...HTMLElement} containers - Containers you want to add to this sensor
|
|
* @example draggable.addContainer(document.body)
|
|
*/
|
|
addContainer(...containers) {
|
|
this.containers = [...this.containers, ...containers];
|
|
}
|
|
|
|
/**
|
|
* Removes container from this sensor instance
|
|
* @param {...HTMLElement} containers - Containers you want to remove from this sensor
|
|
* @example draggable.removeContainer(document.body)
|
|
*/
|
|
removeContainer(...containers) {
|
|
this.containers = this.containers.filter(container => !containers.includes(container));
|
|
}
|
|
|
|
/**
|
|
* Triggers event on target element
|
|
* @param {HTMLElement} element - Element to trigger event on
|
|
* @param {SensorEvent} sensorEvent - Sensor event to trigger
|
|
*/
|
|
trigger(element, sensorEvent) {
|
|
const event = document.createEvent('Event');
|
|
event.detail = sensorEvent;
|
|
event.initEvent(sensorEvent.type, true, true);
|
|
element.dispatchEvent(event);
|
|
this.lastEvent = sensorEvent;
|
|
|
|
return sensorEvent;
|
|
}
|
|
}
|
|
|
|
exports.default = Sensor; /**
|
|
* Calculate the delay of each sensor through the delay in the options
|
|
* @param {undefined|Number|Object} optionsDelay - the delay in the options
|
|
* @return {Object}
|
|
*/
|
|
|
|
function calcDelay(optionsDelay) {
|
|
const delay = {};
|
|
|
|
if (optionsDelay === undefined) {
|
|
return _extends({}, defaultDealy);
|
|
}
|
|
|
|
if (typeof optionsDelay === 'number') {
|
|
for (const key in defaultDealy) {
|
|
if (defaultDealy.hasOwnProperty(key)) {
|
|
delay[key] = optionsDelay;
|
|
}
|
|
}
|
|
return delay;
|
|
}
|
|
|
|
for (const key in defaultDealy) {
|
|
if (defaultDealy.hasOwnProperty(key)) {
|
|
if (optionsDelay[key] === undefined) {
|
|
delay[key] = defaultDealy[key];
|
|
} else {
|
|
delay[key] = optionsDelay[key];
|
|
}
|
|
}
|
|
}
|
|
|
|
return delay;
|
|
}
|
|
|
|
/***/ }),
|
|
/* 50 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = touchCoords;
|
|
/**
|
|
* Returns the first touch event found in touches or changedTouches of a touch events.
|
|
* @param {TouchEvent} event a touch event
|
|
* @return {Touch} a touch object
|
|
*/
|
|
function touchCoords(event = {}) {
|
|
const { touches, changedTouches } = event;
|
|
return touches && touches[0] || changedTouches && changedTouches[0];
|
|
}
|
|
|
|
/***/ }),
|
|
/* 51 */
|
|
/***/ (function(module, exports, __nested_webpack_require_144763__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _touchCoords = __nested_webpack_require_144763__(50);
|
|
|
|
var _touchCoords2 = _interopRequireDefault(_touchCoords);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _touchCoords2.default;
|
|
|
|
/***/ }),
|
|
/* 52 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = distance;
|
|
/**
|
|
* Returns the distance between two points
|
|
* @param {Number} x1 The X position of the first point
|
|
* @param {Number} y1 The Y position of the first point
|
|
* @param {Number} x2 The X position of the second point
|
|
* @param {Number} y2 The Y position of the second point
|
|
* @return {Number}
|
|
*/
|
|
function distance(x1, y1, x2, y2) {
|
|
return Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);
|
|
}
|
|
|
|
/***/ }),
|
|
/* 53 */
|
|
/***/ (function(module, exports, __nested_webpack_require_145742__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _distance = __nested_webpack_require_145742__(52);
|
|
|
|
var _distance2 = _interopRequireDefault(_distance);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _distance2.default;
|
|
|
|
/***/ }),
|
|
/* 54 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = requestNextAnimationFrame;
|
|
function requestNextAnimationFrame(callback) {
|
|
return requestAnimationFrame(() => {
|
|
requestAnimationFrame(callback);
|
|
});
|
|
}
|
|
|
|
/***/ }),
|
|
/* 55 */
|
|
/***/ (function(module, exports, __nested_webpack_require_146465__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _requestNextAnimationFrame = __nested_webpack_require_146465__(54);
|
|
|
|
var _requestNextAnimationFrame2 = _interopRequireDefault(_requestNextAnimationFrame);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _requestNextAnimationFrame2.default;
|
|
|
|
/***/ }),
|
|
/* 56 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = closest;
|
|
const matchFunction = Element.prototype.matches || Element.prototype.webkitMatchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector;
|
|
|
|
/**
|
|
* Get the closest parent element of a given element that matches the given
|
|
* selector string or matching function
|
|
*
|
|
* @param {Element} element The child element to find a parent of
|
|
* @param {String|Function} selector The string or function to use to match
|
|
* the parent element
|
|
* @return {Element|null}
|
|
*/
|
|
function closest(element, value) {
|
|
if (!element) {
|
|
return null;
|
|
}
|
|
|
|
const selector = value;
|
|
const callback = value;
|
|
const nodeList = value;
|
|
const singleElement = value;
|
|
|
|
const isSelector = Boolean(typeof value === 'string');
|
|
const isFunction = Boolean(typeof value === 'function');
|
|
const isNodeList = Boolean(value instanceof NodeList || value instanceof Array);
|
|
const isElement = Boolean(value instanceof HTMLElement);
|
|
|
|
function conditionFn(currentElement) {
|
|
if (!currentElement) {
|
|
return currentElement;
|
|
} else if (isSelector) {
|
|
return matchFunction.call(currentElement, selector);
|
|
} else if (isNodeList) {
|
|
return [...nodeList].includes(currentElement);
|
|
} else if (isElement) {
|
|
return singleElement === currentElement;
|
|
} else if (isFunction) {
|
|
return callback(currentElement);
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
let current = element;
|
|
|
|
do {
|
|
current = current.correspondingUseElement || current.correspondingElement || current;
|
|
|
|
if (conditionFn(current)) {
|
|
return current;
|
|
}
|
|
|
|
current = current.parentNode;
|
|
} while (current && current !== document.body && current !== document);
|
|
|
|
return null;
|
|
}
|
|
|
|
/***/ }),
|
|
/* 57 */
|
|
/***/ (function(module, exports, __nested_webpack_require_148808__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _closest = __nested_webpack_require_148808__(56);
|
|
|
|
var _closest2 = _interopRequireDefault(_closest);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _closest2.default;
|
|
|
|
/***/ }),
|
|
/* 58 */
|
|
/***/ (function(module, exports, __nested_webpack_require_149193__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.defaultOptions = exports.scroll = exports.onDragStop = exports.onDragMove = exports.onDragStart = undefined;
|
|
|
|
var _extends = Object.assign || 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; };
|
|
|
|
var _AbstractPlugin = __nested_webpack_require_149193__(0);
|
|
|
|
var _AbstractPlugin2 = _interopRequireDefault(_AbstractPlugin);
|
|
|
|
var _utils = __nested_webpack_require_149193__(2);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
const onDragStart = exports.onDragStart = Symbol('onDragStart');
|
|
const onDragMove = exports.onDragMove = Symbol('onDragMove');
|
|
const onDragStop = exports.onDragStop = Symbol('onDragStop');
|
|
const scroll = exports.scroll = Symbol('scroll');
|
|
|
|
/**
|
|
* Scrollable default options
|
|
* @property {Object} defaultOptions
|
|
* @property {Number} defaultOptions.speed
|
|
* @property {Number} defaultOptions.sensitivity
|
|
* @property {HTMLElement[]} defaultOptions.scrollableElements
|
|
* @type {Object}
|
|
*/
|
|
const defaultOptions = exports.defaultOptions = {
|
|
speed: 6,
|
|
sensitivity: 50,
|
|
scrollableElements: []
|
|
};
|
|
|
|
/**
|
|
* Scrollable plugin which scrolls the closest scrollable parent
|
|
* @class Scrollable
|
|
* @module Scrollable
|
|
* @extends AbstractPlugin
|
|
*/
|
|
class Scrollable extends _AbstractPlugin2.default {
|
|
/**
|
|
* Scrollable constructor.
|
|
* @constructs Scrollable
|
|
* @param {Draggable} draggable - Draggable instance
|
|
*/
|
|
constructor(draggable) {
|
|
super(draggable);
|
|
|
|
/**
|
|
* Scrollable options
|
|
* @property {Object} options
|
|
* @property {Number} options.speed
|
|
* @property {Number} options.sensitivity
|
|
* @property {HTMLElement[]} options.scrollableElements
|
|
* @type {Object}
|
|
*/
|
|
this.options = _extends({}, defaultOptions, this.getOptions());
|
|
|
|
/**
|
|
* Keeps current mouse position
|
|
* @property {Object} currentMousePosition
|
|
* @property {Number} currentMousePosition.clientX
|
|
* @property {Number} currentMousePosition.clientY
|
|
* @type {Object|null}
|
|
*/
|
|
this.currentMousePosition = null;
|
|
|
|
/**
|
|
* Scroll animation frame
|
|
* @property scrollAnimationFrame
|
|
* @type {Number|null}
|
|
*/
|
|
this.scrollAnimationFrame = null;
|
|
|
|
/**
|
|
* Closest scrollable element
|
|
* @property scrollableElement
|
|
* @type {HTMLElement|null}
|
|
*/
|
|
this.scrollableElement = null;
|
|
|
|
/**
|
|
* Animation frame looking for the closest scrollable element
|
|
* @property findScrollableElementFrame
|
|
* @type {Number|null}
|
|
*/
|
|
this.findScrollableElementFrame = null;
|
|
|
|
this[onDragStart] = this[onDragStart].bind(this);
|
|
this[onDragMove] = this[onDragMove].bind(this);
|
|
this[onDragStop] = this[onDragStop].bind(this);
|
|
this[scroll] = this[scroll].bind(this);
|
|
}
|
|
|
|
/**
|
|
* Attaches plugins event listeners
|
|
*/
|
|
attach() {
|
|
this.draggable.on('drag:start', this[onDragStart]).on('drag:move', this[onDragMove]).on('drag:stop', this[onDragStop]);
|
|
}
|
|
|
|
/**
|
|
* Detaches plugins event listeners
|
|
*/
|
|
detach() {
|
|
this.draggable.off('drag:start', this[onDragStart]).off('drag:move', this[onDragMove]).off('drag:stop', this[onDragStop]);
|
|
}
|
|
|
|
/**
|
|
* Returns options passed through draggable
|
|
* @return {Object}
|
|
*/
|
|
getOptions() {
|
|
return this.draggable.options.scrollable || {};
|
|
}
|
|
|
|
/**
|
|
* Returns closest scrollable elements by element
|
|
* @param {HTMLElement} target
|
|
* @return {HTMLElement}
|
|
*/
|
|
getScrollableElement(target) {
|
|
if (this.hasDefinedScrollableElements()) {
|
|
return (0, _utils.closest)(target, this.options.scrollableElements) || document.documentElement;
|
|
} else {
|
|
return closestScrollableElement(target);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Returns true if at least one scrollable element have been defined via options
|
|
* @param {HTMLElement} target
|
|
* @return {Boolean}
|
|
*/
|
|
hasDefinedScrollableElements() {
|
|
return Boolean(this.options.scrollableElements.length !== 0);
|
|
}
|
|
|
|
/**
|
|
* Drag start handler. Finds closest scrollable parent in separate frame
|
|
* @param {DragStartEvent} dragEvent
|
|
* @private
|
|
*/
|
|
[onDragStart](dragEvent) {
|
|
this.findScrollableElementFrame = requestAnimationFrame(() => {
|
|
this.scrollableElement = this.getScrollableElement(dragEvent.source);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Drag move handler. Remembers mouse position and initiates scrolling
|
|
* @param {DragMoveEvent} dragEvent
|
|
* @private
|
|
*/
|
|
[onDragMove](dragEvent) {
|
|
this.findScrollableElementFrame = requestAnimationFrame(() => {
|
|
this.scrollableElement = this.getScrollableElement(dragEvent.sensorEvent.target);
|
|
});
|
|
|
|
if (!this.scrollableElement) {
|
|
return;
|
|
}
|
|
|
|
const sensorEvent = dragEvent.sensorEvent;
|
|
const scrollOffset = { x: 0, y: 0 };
|
|
|
|
if ('ontouchstart' in window) {
|
|
scrollOffset.y = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
|
|
scrollOffset.x = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
|
|
}
|
|
|
|
this.currentMousePosition = {
|
|
clientX: sensorEvent.clientX - scrollOffset.x,
|
|
clientY: sensorEvent.clientY - scrollOffset.y
|
|
};
|
|
|
|
this.scrollAnimationFrame = requestAnimationFrame(this[scroll]);
|
|
}
|
|
|
|
/**
|
|
* Drag stop handler. Cancels scroll animations and resets state
|
|
* @private
|
|
*/
|
|
[onDragStop]() {
|
|
cancelAnimationFrame(this.scrollAnimationFrame);
|
|
cancelAnimationFrame(this.findScrollableElementFrame);
|
|
|
|
this.scrollableElement = null;
|
|
this.scrollAnimationFrame = null;
|
|
this.findScrollableElementFrame = null;
|
|
this.currentMousePosition = null;
|
|
}
|
|
|
|
/**
|
|
* Scroll function that does the heavylifting
|
|
* @private
|
|
*/
|
|
[scroll]() {
|
|
if (!this.scrollableElement || !this.currentMousePosition) {
|
|
return;
|
|
}
|
|
|
|
cancelAnimationFrame(this.scrollAnimationFrame);
|
|
|
|
const { speed, sensitivity } = this.options;
|
|
|
|
const rect = this.scrollableElement.getBoundingClientRect();
|
|
const bottomCutOff = rect.bottom > window.innerHeight;
|
|
const topCutOff = rect.top < 0;
|
|
const cutOff = topCutOff || bottomCutOff;
|
|
|
|
const documentScrollingElement = getDocumentScrollingElement();
|
|
const scrollableElement = this.scrollableElement;
|
|
const clientX = this.currentMousePosition.clientX;
|
|
const clientY = this.currentMousePosition.clientY;
|
|
|
|
if (scrollableElement !== document.body && scrollableElement !== document.documentElement && !cutOff) {
|
|
const { offsetHeight, offsetWidth } = scrollableElement;
|
|
|
|
if (rect.top + offsetHeight - clientY < sensitivity) {
|
|
scrollableElement.scrollTop += speed;
|
|
} else if (clientY - rect.top < sensitivity) {
|
|
scrollableElement.scrollTop -= speed;
|
|
}
|
|
|
|
if (rect.left + offsetWidth - clientX < sensitivity) {
|
|
scrollableElement.scrollLeft += speed;
|
|
} else if (clientX - rect.left < sensitivity) {
|
|
scrollableElement.scrollLeft -= speed;
|
|
}
|
|
} else {
|
|
const { innerHeight, innerWidth } = window;
|
|
|
|
if (clientY < sensitivity) {
|
|
documentScrollingElement.scrollTop -= speed;
|
|
} else if (innerHeight - clientY < sensitivity) {
|
|
documentScrollingElement.scrollTop += speed;
|
|
}
|
|
|
|
if (clientX < sensitivity) {
|
|
documentScrollingElement.scrollLeft -= speed;
|
|
} else if (innerWidth - clientX < sensitivity) {
|
|
documentScrollingElement.scrollLeft += speed;
|
|
}
|
|
}
|
|
|
|
this.scrollAnimationFrame = requestAnimationFrame(this[scroll]);
|
|
}
|
|
}
|
|
|
|
exports.default = Scrollable; /**
|
|
* Returns true if the passed element has overflow
|
|
* @param {HTMLElement} element
|
|
* @return {Boolean}
|
|
* @private
|
|
*/
|
|
|
|
function hasOverflow(element) {
|
|
const overflowRegex = /(auto|scroll)/;
|
|
const computedStyles = getComputedStyle(element, null);
|
|
|
|
const overflow = computedStyles.getPropertyValue('overflow') + computedStyles.getPropertyValue('overflow-y') + computedStyles.getPropertyValue('overflow-x');
|
|
|
|
return overflowRegex.test(overflow);
|
|
}
|
|
|
|
/**
|
|
* Returns true if the passed element is statically positioned
|
|
* @param {HTMLElement} element
|
|
* @return {Boolean}
|
|
* @private
|
|
*/
|
|
function isStaticallyPositioned(element) {
|
|
const position = getComputedStyle(element).getPropertyValue('position');
|
|
return position === 'static';
|
|
}
|
|
|
|
/**
|
|
* Finds closest scrollable element
|
|
* @param {HTMLElement} element
|
|
* @return {HTMLElement}
|
|
* @private
|
|
*/
|
|
function closestScrollableElement(element) {
|
|
if (!element) {
|
|
return getDocumentScrollingElement();
|
|
}
|
|
|
|
const position = getComputedStyle(element).getPropertyValue('position');
|
|
const excludeStaticParents = position === 'absolute';
|
|
|
|
const scrollableElement = (0, _utils.closest)(element, parent => {
|
|
if (excludeStaticParents && isStaticallyPositioned(parent)) {
|
|
return false;
|
|
}
|
|
return hasOverflow(parent);
|
|
});
|
|
|
|
if (position === 'fixed' || !scrollableElement) {
|
|
return getDocumentScrollingElement();
|
|
} else {
|
|
return scrollableElement;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Returns element that scrolls document
|
|
* @return {HTMLElement}
|
|
* @private
|
|
*/
|
|
function getDocumentScrollingElement() {
|
|
return document.scrollingElement || document.documentElement;
|
|
}
|
|
|
|
/***/ }),
|
|
/* 59 */
|
|
/***/ (function(module, exports, __nested_webpack_require_158793__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.defaultOptions = undefined;
|
|
|
|
var _Scrollable = __nested_webpack_require_158793__(58);
|
|
|
|
var _Scrollable2 = _interopRequireDefault(_Scrollable);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _Scrollable2.default;
|
|
exports.defaultOptions = _Scrollable.defaultOptions;
|
|
|
|
/***/ }),
|
|
/* 60 */
|
|
/***/ (function(module, exports, __nested_webpack_require_159279__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.MirrorDestroyEvent = exports.MirrorMoveEvent = exports.MirrorAttachedEvent = exports.MirrorCreatedEvent = exports.MirrorCreateEvent = exports.MirrorEvent = undefined;
|
|
|
|
var _AbstractEvent = __nested_webpack_require_159279__(1);
|
|
|
|
var _AbstractEvent2 = _interopRequireDefault(_AbstractEvent);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
/**
|
|
* Base mirror event
|
|
* @class MirrorEvent
|
|
* @module MirrorEvent
|
|
* @extends AbstractEvent
|
|
*/
|
|
class MirrorEvent extends _AbstractEvent2.default {
|
|
/**
|
|
* Draggables source element
|
|
* @property source
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get source() {
|
|
return this.data.source;
|
|
}
|
|
|
|
/**
|
|
* Draggables original source element
|
|
* @property originalSource
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get originalSource() {
|
|
return this.data.originalSource;
|
|
}
|
|
|
|
/**
|
|
* Draggables source container element
|
|
* @property sourceContainer
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get sourceContainer() {
|
|
return this.data.sourceContainer;
|
|
}
|
|
|
|
/**
|
|
* Sensor event
|
|
* @property sensorEvent
|
|
* @type {SensorEvent}
|
|
* @readonly
|
|
*/
|
|
get sensorEvent() {
|
|
return this.data.sensorEvent;
|
|
}
|
|
|
|
/**
|
|
* Drag event
|
|
* @property dragEvent
|
|
* @type {DragEvent}
|
|
* @readonly
|
|
*/
|
|
get dragEvent() {
|
|
return this.data.dragEvent;
|
|
}
|
|
|
|
/**
|
|
* Original event that triggered sensor event
|
|
* @property originalEvent
|
|
* @type {Event}
|
|
* @readonly
|
|
*/
|
|
get originalEvent() {
|
|
if (this.sensorEvent) {
|
|
return this.sensorEvent.originalEvent;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
|
|
exports.MirrorEvent = MirrorEvent; /**
|
|
* Mirror create event
|
|
* @class MirrorCreateEvent
|
|
* @module MirrorCreateEvent
|
|
* @extends MirrorEvent
|
|
*/
|
|
|
|
class MirrorCreateEvent extends MirrorEvent {}
|
|
|
|
exports.MirrorCreateEvent = MirrorCreateEvent; /**
|
|
* Mirror created event
|
|
* @class MirrorCreatedEvent
|
|
* @module MirrorCreatedEvent
|
|
* @extends MirrorEvent
|
|
*/
|
|
|
|
MirrorCreateEvent.type = 'mirror:create';
|
|
class MirrorCreatedEvent extends MirrorEvent {
|
|
|
|
/**
|
|
* Draggables mirror element
|
|
* @property mirror
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get mirror() {
|
|
return this.data.mirror;
|
|
}
|
|
}
|
|
|
|
exports.MirrorCreatedEvent = MirrorCreatedEvent; /**
|
|
* Mirror attached event
|
|
* @class MirrorAttachedEvent
|
|
* @module MirrorAttachedEvent
|
|
* @extends MirrorEvent
|
|
*/
|
|
|
|
MirrorCreatedEvent.type = 'mirror:created';
|
|
class MirrorAttachedEvent extends MirrorEvent {
|
|
|
|
/**
|
|
* Draggables mirror element
|
|
* @property mirror
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get mirror() {
|
|
return this.data.mirror;
|
|
}
|
|
}
|
|
|
|
exports.MirrorAttachedEvent = MirrorAttachedEvent; /**
|
|
* Mirror move event
|
|
* @class MirrorMoveEvent
|
|
* @module MirrorMoveEvent
|
|
* @extends MirrorEvent
|
|
*/
|
|
|
|
MirrorAttachedEvent.type = 'mirror:attached';
|
|
class MirrorMoveEvent extends MirrorEvent {
|
|
|
|
/**
|
|
* Draggables mirror element
|
|
* @property mirror
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get mirror() {
|
|
return this.data.mirror;
|
|
}
|
|
|
|
/**
|
|
* Sensor has exceeded mirror's threshold on x axis
|
|
* @type {Boolean}
|
|
* @readonly
|
|
*/
|
|
get passedThreshX() {
|
|
return this.data.passedThreshX;
|
|
}
|
|
|
|
/**
|
|
* Sensor has exceeded mirror's threshold on y axis
|
|
* @type {Boolean}
|
|
* @readonly
|
|
*/
|
|
get passedThreshY() {
|
|
return this.data.passedThreshY;
|
|
}
|
|
}
|
|
|
|
exports.MirrorMoveEvent = MirrorMoveEvent; /**
|
|
* Mirror destroy event
|
|
* @class MirrorDestroyEvent
|
|
* @module MirrorDestroyEvent
|
|
* @extends MirrorEvent
|
|
*/
|
|
|
|
MirrorMoveEvent.type = 'mirror:move';
|
|
MirrorMoveEvent.cancelable = true;
|
|
class MirrorDestroyEvent extends MirrorEvent {
|
|
|
|
/**
|
|
* Draggables mirror element
|
|
* @property mirror
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get mirror() {
|
|
return this.data.mirror;
|
|
}
|
|
}
|
|
exports.MirrorDestroyEvent = MirrorDestroyEvent;
|
|
MirrorDestroyEvent.type = 'mirror:destroy';
|
|
MirrorDestroyEvent.cancelable = true;
|
|
|
|
/***/ }),
|
|
/* 61 */
|
|
/***/ (function(module, exports, __nested_webpack_require_164526__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _MirrorEvent = __nested_webpack_require_164526__(60);
|
|
|
|
Object.keys(_MirrorEvent).forEach(function (key) {
|
|
if (key === "default" || key === "__esModule") return;
|
|
Object.defineProperty(exports, key, {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _MirrorEvent[key];
|
|
}
|
|
});
|
|
});
|
|
|
|
/***/ }),
|
|
/* 62 */
|
|
/***/ (function(module, exports, __nested_webpack_require_164971__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.defaultOptions = exports.getAppendableContainer = exports.onScroll = exports.onMirrorMove = exports.onMirrorCreated = exports.onDragStop = exports.onDragMove = exports.onDragStart = undefined;
|
|
|
|
var _extends = Object.assign || 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; };
|
|
|
|
var _AbstractPlugin = __nested_webpack_require_164971__(0);
|
|
|
|
var _AbstractPlugin2 = _interopRequireDefault(_AbstractPlugin);
|
|
|
|
var _MirrorEvent = __nested_webpack_require_164971__(61);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
|
|
|
|
const onDragStart = exports.onDragStart = Symbol('onDragStart');
|
|
const onDragMove = exports.onDragMove = Symbol('onDragMove');
|
|
const onDragStop = exports.onDragStop = Symbol('onDragStop');
|
|
const onMirrorCreated = exports.onMirrorCreated = Symbol('onMirrorCreated');
|
|
const onMirrorMove = exports.onMirrorMove = Symbol('onMirrorMove');
|
|
const onScroll = exports.onScroll = Symbol('onScroll');
|
|
const getAppendableContainer = exports.getAppendableContainer = Symbol('getAppendableContainer');
|
|
|
|
/**
|
|
* Mirror default options
|
|
* @property {Object} defaultOptions
|
|
* @property {Boolean} defaultOptions.constrainDimensions
|
|
* @property {Boolean} defaultOptions.xAxis
|
|
* @property {Boolean} defaultOptions.yAxis
|
|
* @property {null} defaultOptions.cursorOffsetX
|
|
* @property {null} defaultOptions.cursorOffsetY
|
|
* @type {Object}
|
|
*/
|
|
const defaultOptions = exports.defaultOptions = {
|
|
constrainDimensions: false,
|
|
xAxis: true,
|
|
yAxis: true,
|
|
cursorOffsetX: null,
|
|
cursorOffsetY: null,
|
|
thresholdX: null,
|
|
thresholdY: null
|
|
};
|
|
|
|
/**
|
|
* Mirror plugin which controls the mirror positioning while dragging
|
|
* @class Mirror
|
|
* @module Mirror
|
|
* @extends AbstractPlugin
|
|
*/
|
|
class Mirror extends _AbstractPlugin2.default {
|
|
/**
|
|
* Mirror constructor.
|
|
* @constructs Mirror
|
|
* @param {Draggable} draggable - Draggable instance
|
|
*/
|
|
constructor(draggable) {
|
|
super(draggable);
|
|
|
|
/**
|
|
* Mirror options
|
|
* @property {Object} options
|
|
* @property {Boolean} options.constrainDimensions
|
|
* @property {Boolean} options.xAxis
|
|
* @property {Boolean} options.yAxis
|
|
* @property {Number|null} options.cursorOffsetX
|
|
* @property {Number|null} options.cursorOffsetY
|
|
* @property {String|HTMLElement|Function} options.appendTo
|
|
* @type {Object}
|
|
*/
|
|
this.options = _extends({}, defaultOptions, this.getOptions());
|
|
|
|
/**
|
|
* Scroll offset for touch devices because the mirror is positioned fixed
|
|
* @property {Object} scrollOffset
|
|
* @property {Number} scrollOffset.x
|
|
* @property {Number} scrollOffset.y
|
|
*/
|
|
this.scrollOffset = { x: 0, y: 0 };
|
|
|
|
/**
|
|
* Initial scroll offset for touch devices because the mirror is positioned fixed
|
|
* @property {Object} scrollOffset
|
|
* @property {Number} scrollOffset.x
|
|
* @property {Number} scrollOffset.y
|
|
*/
|
|
this.initialScrollOffset = {
|
|
x: window.scrollX,
|
|
y: window.scrollY
|
|
};
|
|
|
|
this[onDragStart] = this[onDragStart].bind(this);
|
|
this[onDragMove] = this[onDragMove].bind(this);
|
|
this[onDragStop] = this[onDragStop].bind(this);
|
|
this[onMirrorCreated] = this[onMirrorCreated].bind(this);
|
|
this[onMirrorMove] = this[onMirrorMove].bind(this);
|
|
this[onScroll] = this[onScroll].bind(this);
|
|
}
|
|
|
|
/**
|
|
* Attaches plugins event listeners
|
|
*/
|
|
attach() {
|
|
this.draggable.on('drag:start', this[onDragStart]).on('drag:move', this[onDragMove]).on('drag:stop', this[onDragStop]).on('mirror:created', this[onMirrorCreated]).on('mirror:move', this[onMirrorMove]);
|
|
}
|
|
|
|
/**
|
|
* Detaches plugins event listeners
|
|
*/
|
|
detach() {
|
|
this.draggable.off('drag:start', this[onDragStart]).off('drag:move', this[onDragMove]).off('drag:stop', this[onDragStop]).off('mirror:created', this[onMirrorCreated]).off('mirror:move', this[onMirrorMove]);
|
|
}
|
|
|
|
/**
|
|
* Returns options passed through draggable
|
|
* @return {Object}
|
|
*/
|
|
getOptions() {
|
|
return this.draggable.options.mirror || {};
|
|
}
|
|
|
|
[onDragStart](dragEvent) {
|
|
if (dragEvent.canceled()) {
|
|
return;
|
|
}
|
|
|
|
if ('ontouchstart' in window) {
|
|
document.addEventListener('scroll', this[onScroll], true);
|
|
}
|
|
|
|
this.initialScrollOffset = {
|
|
x: window.scrollX,
|
|
y: window.scrollY
|
|
};
|
|
|
|
const { source, originalSource, sourceContainer, sensorEvent } = dragEvent;
|
|
|
|
// Last sensor position of mirror move
|
|
this.lastMirrorMovedClient = {
|
|
x: sensorEvent.clientX,
|
|
y: sensorEvent.clientY
|
|
};
|
|
|
|
const mirrorCreateEvent = new _MirrorEvent.MirrorCreateEvent({
|
|
source,
|
|
originalSource,
|
|
sourceContainer,
|
|
sensorEvent,
|
|
dragEvent
|
|
});
|
|
|
|
this.draggable.trigger(mirrorCreateEvent);
|
|
|
|
if (isNativeDragEvent(sensorEvent) || mirrorCreateEvent.canceled()) {
|
|
return;
|
|
}
|
|
|
|
const appendableContainer = this[getAppendableContainer](source) || sourceContainer;
|
|
this.mirror = source.cloneNode(true);
|
|
|
|
const mirrorCreatedEvent = new _MirrorEvent.MirrorCreatedEvent({
|
|
source,
|
|
originalSource,
|
|
sourceContainer,
|
|
sensorEvent,
|
|
dragEvent,
|
|
mirror: this.mirror
|
|
});
|
|
|
|
const mirrorAttachedEvent = new _MirrorEvent.MirrorAttachedEvent({
|
|
source,
|
|
originalSource,
|
|
sourceContainer,
|
|
sensorEvent,
|
|
dragEvent,
|
|
mirror: this.mirror
|
|
});
|
|
|
|
this.draggable.trigger(mirrorCreatedEvent);
|
|
appendableContainer.appendChild(this.mirror);
|
|
this.draggable.trigger(mirrorAttachedEvent);
|
|
}
|
|
|
|
[onDragMove](dragEvent) {
|
|
if (!this.mirror || dragEvent.canceled()) {
|
|
return;
|
|
}
|
|
|
|
const { source, originalSource, sourceContainer, sensorEvent } = dragEvent;
|
|
|
|
let passedThreshX = true;
|
|
let passedThreshY = true;
|
|
|
|
if (this.options.thresholdX || this.options.thresholdY) {
|
|
const { x: lastX, y: lastY } = this.lastMirrorMovedClient;
|
|
|
|
if (Math.abs(lastX - sensorEvent.clientX) < this.options.thresholdX) {
|
|
passedThreshX = false;
|
|
} else {
|
|
this.lastMirrorMovedClient.x = sensorEvent.clientX;
|
|
}
|
|
|
|
if (Math.abs(lastY - sensorEvent.clientY) < this.options.thresholdY) {
|
|
passedThreshY = false;
|
|
} else {
|
|
this.lastMirrorMovedClient.y = sensorEvent.clientY;
|
|
}
|
|
|
|
if (!passedThreshX && !passedThreshY) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
const mirrorMoveEvent = new _MirrorEvent.MirrorMoveEvent({
|
|
source,
|
|
originalSource,
|
|
sourceContainer,
|
|
sensorEvent,
|
|
dragEvent,
|
|
mirror: this.mirror,
|
|
passedThreshX,
|
|
passedThreshY
|
|
});
|
|
|
|
this.draggable.trigger(mirrorMoveEvent);
|
|
}
|
|
|
|
[onDragStop](dragEvent) {
|
|
if ('ontouchstart' in window) {
|
|
document.removeEventListener('scroll', this[onScroll], true);
|
|
}
|
|
|
|
this.initialScrollOffset = { x: 0, y: 0 };
|
|
this.scrollOffset = { x: 0, y: 0 };
|
|
|
|
if (!this.mirror) {
|
|
return;
|
|
}
|
|
|
|
const { source, sourceContainer, sensorEvent } = dragEvent;
|
|
|
|
const mirrorDestroyEvent = new _MirrorEvent.MirrorDestroyEvent({
|
|
source,
|
|
mirror: this.mirror,
|
|
sourceContainer,
|
|
sensorEvent,
|
|
dragEvent
|
|
});
|
|
|
|
this.draggable.trigger(mirrorDestroyEvent);
|
|
|
|
if (!mirrorDestroyEvent.canceled()) {
|
|
this.mirror.parentNode.removeChild(this.mirror);
|
|
}
|
|
}
|
|
|
|
[onScroll]() {
|
|
this.scrollOffset = {
|
|
x: window.scrollX - this.initialScrollOffset.x,
|
|
y: window.scrollY - this.initialScrollOffset.y
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Mirror created handler
|
|
* @param {MirrorCreatedEvent} mirrorEvent
|
|
* @return {Promise}
|
|
* @private
|
|
*/
|
|
[onMirrorCreated]({ mirror, source, sensorEvent }) {
|
|
const mirrorClasses = this.draggable.getClassNamesFor('mirror');
|
|
|
|
const setState = (_ref) => {
|
|
let { mirrorOffset, initialX, initialY } = _ref,
|
|
args = _objectWithoutProperties(_ref, ['mirrorOffset', 'initialX', 'initialY']);
|
|
|
|
this.mirrorOffset = mirrorOffset;
|
|
this.initialX = initialX;
|
|
this.initialY = initialY;
|
|
this.lastMovedX = initialX;
|
|
this.lastMovedY = initialY;
|
|
return _extends({ mirrorOffset, initialX, initialY }, args);
|
|
};
|
|
|
|
mirror.style.display = 'none';
|
|
|
|
const initialState = {
|
|
mirror,
|
|
source,
|
|
sensorEvent,
|
|
mirrorClasses,
|
|
scrollOffset: this.scrollOffset,
|
|
options: this.options,
|
|
passedThreshX: true,
|
|
passedThreshY: true
|
|
};
|
|
|
|
return Promise.resolve(initialState)
|
|
// Fix reflow here
|
|
.then(computeMirrorDimensions).then(calculateMirrorOffset).then(resetMirror).then(addMirrorClasses).then(positionMirror({ initial: true })).then(removeMirrorID).then(setState);
|
|
}
|
|
|
|
/**
|
|
* Mirror move handler
|
|
* @param {MirrorMoveEvent} mirrorEvent
|
|
* @return {Promise|null}
|
|
* @private
|
|
*/
|
|
[onMirrorMove](mirrorEvent) {
|
|
if (mirrorEvent.canceled()) {
|
|
return null;
|
|
}
|
|
|
|
const setState = (_ref2) => {
|
|
let { lastMovedX, lastMovedY } = _ref2,
|
|
args = _objectWithoutProperties(_ref2, ['lastMovedX', 'lastMovedY']);
|
|
|
|
this.lastMovedX = lastMovedX;
|
|
this.lastMovedY = lastMovedY;
|
|
|
|
return _extends({ lastMovedX, lastMovedY }, args);
|
|
};
|
|
|
|
const initialState = {
|
|
mirror: mirrorEvent.mirror,
|
|
sensorEvent: mirrorEvent.sensorEvent,
|
|
mirrorOffset: this.mirrorOffset,
|
|
options: this.options,
|
|
initialX: this.initialX,
|
|
initialY: this.initialY,
|
|
scrollOffset: this.scrollOffset,
|
|
passedThreshX: mirrorEvent.passedThreshX,
|
|
passedThreshY: mirrorEvent.passedThreshY,
|
|
lastMovedX: this.lastMovedX,
|
|
lastMovedY: this.lastMovedY
|
|
};
|
|
|
|
return Promise.resolve(initialState).then(positionMirror({ raf: true })).then(setState);
|
|
}
|
|
|
|
/**
|
|
* Returns appendable container for mirror based on the appendTo option
|
|
* @private
|
|
* @param {Object} options
|
|
* @param {HTMLElement} options.source - Current source
|
|
* @return {HTMLElement}
|
|
*/
|
|
[getAppendableContainer](source) {
|
|
const appendTo = this.options.appendTo;
|
|
|
|
if (typeof appendTo === 'string') {
|
|
return document.querySelector(appendTo);
|
|
} else if (appendTo instanceof HTMLElement) {
|
|
return appendTo;
|
|
} else if (typeof appendTo === 'function') {
|
|
return appendTo(source);
|
|
} else {
|
|
return source.parentNode;
|
|
}
|
|
}
|
|
}
|
|
|
|
exports.default = Mirror; /**
|
|
* Computes mirror dimensions based on the source element
|
|
* Adds sourceRect to state
|
|
* @param {Object} state
|
|
* @param {HTMLElement} state.source
|
|
* @return {Promise}
|
|
* @private
|
|
*/
|
|
|
|
function computeMirrorDimensions(_ref3) {
|
|
let { source } = _ref3,
|
|
args = _objectWithoutProperties(_ref3, ['source']);
|
|
|
|
return withPromise(resolve => {
|
|
const sourceRect = source.getBoundingClientRect();
|
|
resolve(_extends({ source, sourceRect }, args));
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Calculates mirror offset
|
|
* Adds mirrorOffset to state
|
|
* @param {Object} state
|
|
* @param {SensorEvent} state.sensorEvent
|
|
* @param {DOMRect} state.sourceRect
|
|
* @return {Promise}
|
|
* @private
|
|
*/
|
|
function calculateMirrorOffset(_ref4) {
|
|
let { sensorEvent, sourceRect, options } = _ref4,
|
|
args = _objectWithoutProperties(_ref4, ['sensorEvent', 'sourceRect', 'options']);
|
|
|
|
return withPromise(resolve => {
|
|
const top = options.cursorOffsetY === null ? sensorEvent.clientY - sourceRect.top : options.cursorOffsetY;
|
|
const left = options.cursorOffsetX === null ? sensorEvent.clientX - sourceRect.left : options.cursorOffsetX;
|
|
|
|
const mirrorOffset = { top, left };
|
|
|
|
resolve(_extends({ sensorEvent, sourceRect, mirrorOffset, options }, args));
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Applys mirror styles
|
|
* @param {Object} state
|
|
* @param {HTMLElement} state.mirror
|
|
* @param {HTMLElement} state.source
|
|
* @param {Object} state.options
|
|
* @return {Promise}
|
|
* @private
|
|
*/
|
|
function resetMirror(_ref5) {
|
|
let { mirror, source, options } = _ref5,
|
|
args = _objectWithoutProperties(_ref5, ['mirror', 'source', 'options']);
|
|
|
|
return withPromise(resolve => {
|
|
let offsetHeight;
|
|
let offsetWidth;
|
|
|
|
if (options.constrainDimensions) {
|
|
const computedSourceStyles = getComputedStyle(source);
|
|
offsetHeight = computedSourceStyles.getPropertyValue('height');
|
|
offsetWidth = computedSourceStyles.getPropertyValue('width');
|
|
}
|
|
|
|
mirror.style.display = null;
|
|
mirror.style.position = 'fixed';
|
|
mirror.style.pointerEvents = 'none';
|
|
mirror.style.top = 0;
|
|
mirror.style.left = 0;
|
|
mirror.style.margin = 0;
|
|
|
|
if (options.constrainDimensions) {
|
|
mirror.style.height = offsetHeight;
|
|
mirror.style.width = offsetWidth;
|
|
}
|
|
|
|
resolve(_extends({ mirror, source, options }, args));
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Applys mirror class on mirror element
|
|
* @param {Object} state
|
|
* @param {HTMLElement} state.mirror
|
|
* @param {String[]} state.mirrorClasses
|
|
* @return {Promise}
|
|
* @private
|
|
*/
|
|
function addMirrorClasses(_ref6) {
|
|
let { mirror, mirrorClasses } = _ref6,
|
|
args = _objectWithoutProperties(_ref6, ['mirror', 'mirrorClasses']);
|
|
|
|
return withPromise(resolve => {
|
|
mirror.classList.add(...mirrorClasses);
|
|
resolve(_extends({ mirror, mirrorClasses }, args));
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Removes source ID from cloned mirror element
|
|
* @param {Object} state
|
|
* @param {HTMLElement} state.mirror
|
|
* @return {Promise}
|
|
* @private
|
|
*/
|
|
function removeMirrorID(_ref7) {
|
|
let { mirror } = _ref7,
|
|
args = _objectWithoutProperties(_ref7, ['mirror']);
|
|
|
|
return withPromise(resolve => {
|
|
mirror.removeAttribute('id');
|
|
delete mirror.id;
|
|
resolve(_extends({ mirror }, args));
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Positions mirror with translate3d
|
|
* @param {Object} state
|
|
* @param {HTMLElement} state.mirror
|
|
* @param {SensorEvent} state.sensorEvent
|
|
* @param {Object} state.mirrorOffset
|
|
* @param {Number} state.initialY
|
|
* @param {Number} state.initialX
|
|
* @param {Object} state.options
|
|
* @return {Promise}
|
|
* @private
|
|
*/
|
|
function positionMirror({ withFrame = false, initial = false } = {}) {
|
|
return (_ref8) => {
|
|
let {
|
|
mirror,
|
|
sensorEvent,
|
|
mirrorOffset,
|
|
initialY,
|
|
initialX,
|
|
scrollOffset,
|
|
options,
|
|
passedThreshX,
|
|
passedThreshY,
|
|
lastMovedX,
|
|
lastMovedY
|
|
} = _ref8,
|
|
args = _objectWithoutProperties(_ref8, ['mirror', 'sensorEvent', 'mirrorOffset', 'initialY', 'initialX', 'scrollOffset', 'options', 'passedThreshX', 'passedThreshY', 'lastMovedX', 'lastMovedY']);
|
|
|
|
return withPromise(resolve => {
|
|
const result = _extends({
|
|
mirror,
|
|
sensorEvent,
|
|
mirrorOffset,
|
|
options
|
|
}, args);
|
|
|
|
if (mirrorOffset) {
|
|
const x = passedThreshX ? Math.round((sensorEvent.clientX - mirrorOffset.left - scrollOffset.x) / (options.thresholdX || 1)) * (options.thresholdX || 1) : Math.round(lastMovedX);
|
|
const y = passedThreshY ? Math.round((sensorEvent.clientY - mirrorOffset.top - scrollOffset.y) / (options.thresholdY || 1)) * (options.thresholdY || 1) : Math.round(lastMovedY);
|
|
|
|
if (options.xAxis && options.yAxis || initial) {
|
|
mirror.style.transform = `translate3d(${x}px, ${y}px, 0)`;
|
|
} else if (options.xAxis && !options.yAxis) {
|
|
mirror.style.transform = `translate3d(${x}px, ${initialY}px, 0)`;
|
|
} else if (options.yAxis && !options.xAxis) {
|
|
mirror.style.transform = `translate3d(${initialX}px, ${y}px, 0)`;
|
|
}
|
|
|
|
if (initial) {
|
|
result.initialX = x;
|
|
result.initialY = y;
|
|
}
|
|
|
|
result.lastMovedX = x;
|
|
result.lastMovedY = y;
|
|
}
|
|
|
|
resolve(result);
|
|
}, { frame: withFrame });
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Wraps functions in promise with potential animation frame option
|
|
* @param {Function} callback
|
|
* @param {Object} options
|
|
* @param {Boolean} options.raf
|
|
* @return {Promise}
|
|
* @private
|
|
*/
|
|
function withPromise(callback, { raf = false } = {}) {
|
|
return new Promise((resolve, reject) => {
|
|
if (raf) {
|
|
requestAnimationFrame(() => {
|
|
callback(resolve, reject);
|
|
});
|
|
} else {
|
|
callback(resolve, reject);
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Returns true if the sensor event was triggered by a native browser drag event
|
|
* @param {SensorEvent} sensorEvent
|
|
*/
|
|
function isNativeDragEvent(sensorEvent) {
|
|
return (/^drag/.test(sensorEvent.originalEvent.type)
|
|
);
|
|
}
|
|
|
|
/***/ }),
|
|
/* 63 */
|
|
/***/ (function(module, exports, __nested_webpack_require_181906__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.defaultOptions = undefined;
|
|
|
|
var _Mirror = __nested_webpack_require_181906__(62);
|
|
|
|
var _Mirror2 = _interopRequireDefault(_Mirror);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _Mirror2.default;
|
|
exports.defaultOptions = _Mirror.defaultOptions;
|
|
|
|
/***/ }),
|
|
/* 64 */
|
|
/***/ (function(module, exports, __nested_webpack_require_182372__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _extends = Object.assign || 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; };
|
|
|
|
var _AbstractPlugin = __nested_webpack_require_182372__(0);
|
|
|
|
var _AbstractPlugin2 = _interopRequireDefault(_AbstractPlugin);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
const onInitialize = Symbol('onInitialize');
|
|
const onDestroy = Symbol('onDestroy');
|
|
|
|
/**
|
|
* Focusable default options
|
|
* @property {Object} defaultOptions
|
|
* @type {Object}
|
|
*/
|
|
const defaultOptions = {};
|
|
|
|
/**
|
|
* Focusable plugin
|
|
* @class Focusable
|
|
* @module Focusable
|
|
* @extends AbstractPlugin
|
|
*/
|
|
class Focusable extends _AbstractPlugin2.default {
|
|
/**
|
|
* Focusable constructor.
|
|
* @constructs Focusable
|
|
* @param {Draggable} draggable - Draggable instance
|
|
*/
|
|
constructor(draggable) {
|
|
super(draggable);
|
|
|
|
/**
|
|
* Focusable options
|
|
* @property {Object} options
|
|
* @type {Object}
|
|
*/
|
|
this.options = _extends({}, defaultOptions, this.getOptions());
|
|
|
|
this[onInitialize] = this[onInitialize].bind(this);
|
|
this[onDestroy] = this[onDestroy].bind(this);
|
|
}
|
|
|
|
/**
|
|
* Attaches listeners to draggable
|
|
*/
|
|
attach() {
|
|
this.draggable.on('draggable:initialize', this[onInitialize]).on('draggable:destroy', this[onDestroy]);
|
|
}
|
|
|
|
/**
|
|
* Detaches listeners from draggable
|
|
*/
|
|
detach() {
|
|
this.draggable.off('draggable:initialize', this[onInitialize]).off('draggable:destroy', this[onDestroy]);
|
|
|
|
// Remove modified elements when detach
|
|
this[onDestroy]();
|
|
}
|
|
|
|
/**
|
|
* Returns options passed through draggable
|
|
* @return {Object}
|
|
*/
|
|
getOptions() {
|
|
return this.draggable.options.focusable || {};
|
|
}
|
|
|
|
/**
|
|
* Returns draggable containers and elements
|
|
* @return {HTMLElement[]}
|
|
*/
|
|
getElements() {
|
|
return [...this.draggable.containers, ...this.draggable.getDraggableElements()];
|
|
}
|
|
|
|
/**
|
|
* Intialize handler
|
|
* @private
|
|
*/
|
|
[onInitialize]() {
|
|
// Can wait until the next best frame is available
|
|
requestAnimationFrame(() => {
|
|
this.getElements().forEach(element => decorateElement(element));
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Destroy handler
|
|
* @private
|
|
*/
|
|
[onDestroy]() {
|
|
// Can wait until the next best frame is available
|
|
requestAnimationFrame(() => {
|
|
this.getElements().forEach(element => stripElement(element));
|
|
});
|
|
}
|
|
}
|
|
|
|
exports.default = Focusable; /**
|
|
* Keeps track of all the elements that are missing tabindex attributes
|
|
* so they can be reset when draggable gets destroyed
|
|
* @const {HTMLElement[]} elementsWithMissingTabIndex
|
|
*/
|
|
|
|
const elementsWithMissingTabIndex = [];
|
|
|
|
/**
|
|
* Decorates element with tabindex attributes
|
|
* @param {HTMLElement} element
|
|
* @return {Object}
|
|
* @private
|
|
*/
|
|
function decorateElement(element) {
|
|
const hasMissingTabIndex = Boolean(!element.getAttribute('tabindex') && element.tabIndex === -1);
|
|
|
|
if (hasMissingTabIndex) {
|
|
elementsWithMissingTabIndex.push(element);
|
|
element.tabIndex = 0;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Removes elements tabindex attributes
|
|
* @param {HTMLElement} element
|
|
* @private
|
|
*/
|
|
function stripElement(element) {
|
|
const tabIndexElementPosition = elementsWithMissingTabIndex.indexOf(element);
|
|
|
|
if (tabIndexElementPosition !== -1) {
|
|
element.tabIndex = -1;
|
|
elementsWithMissingTabIndex.splice(tabIndexElementPosition, 1);
|
|
}
|
|
}
|
|
|
|
/***/ }),
|
|
/* 65 */
|
|
/***/ (function(module, exports, __nested_webpack_require_186136__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _Focusable = __nested_webpack_require_186136__(64);
|
|
|
|
var _Focusable2 = _interopRequireDefault(_Focusable);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _Focusable2.default;
|
|
|
|
/***/ }),
|
|
/* 66 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
/**
|
|
* All draggable plugins inherit from this class.
|
|
* @abstract
|
|
* @class AbstractPlugin
|
|
* @module AbstractPlugin
|
|
*/
|
|
class AbstractPlugin {
|
|
/**
|
|
* AbstractPlugin constructor.
|
|
* @constructs AbstractPlugin
|
|
* @param {Draggable} draggable - Draggable instance
|
|
*/
|
|
constructor(draggable) {
|
|
/**
|
|
* Draggable instance
|
|
* @property draggable
|
|
* @type {Draggable}
|
|
*/
|
|
this.draggable = draggable;
|
|
}
|
|
|
|
/**
|
|
* Override to add listeners
|
|
* @abstract
|
|
*/
|
|
attach() {
|
|
throw new Error('Not Implemented');
|
|
}
|
|
|
|
/**
|
|
* Override to remove listeners
|
|
* @abstract
|
|
*/
|
|
detach() {
|
|
throw new Error('Not Implemented');
|
|
}
|
|
}
|
|
exports.default = AbstractPlugin;
|
|
|
|
/***/ }),
|
|
/* 67 */
|
|
/***/ (function(module, exports, __nested_webpack_require_187392__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.defaultOptions = undefined;
|
|
|
|
var _extends = Object.assign || 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; };
|
|
|
|
var _AbstractPlugin = __nested_webpack_require_187392__(0);
|
|
|
|
var _AbstractPlugin2 = _interopRequireDefault(_AbstractPlugin);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
const onInitialize = Symbol('onInitialize');
|
|
const onDestroy = Symbol('onDestroy');
|
|
const announceEvent = Symbol('announceEvent');
|
|
const announceMessage = Symbol('announceMessage');
|
|
|
|
const ARIA_RELEVANT = 'aria-relevant';
|
|
const ARIA_ATOMIC = 'aria-atomic';
|
|
const ARIA_LIVE = 'aria-live';
|
|
const ROLE = 'role';
|
|
|
|
/**
|
|
* Announcement default options
|
|
* @property {Object} defaultOptions
|
|
* @property {Number} defaultOptions.expire
|
|
* @type {Object}
|
|
*/
|
|
const defaultOptions = exports.defaultOptions = {
|
|
expire: 7000
|
|
};
|
|
|
|
/**
|
|
* Announcement plugin
|
|
* @class Announcement
|
|
* @module Announcement
|
|
* @extends AbstractPlugin
|
|
*/
|
|
class Announcement extends _AbstractPlugin2.default {
|
|
/**
|
|
* Announcement constructor.
|
|
* @constructs Announcement
|
|
* @param {Draggable} draggable - Draggable instance
|
|
*/
|
|
constructor(draggable) {
|
|
super(draggable);
|
|
|
|
/**
|
|
* Plugin options
|
|
* @property options
|
|
* @type {Object}
|
|
*/
|
|
this.options = _extends({}, defaultOptions, this.getOptions());
|
|
|
|
/**
|
|
* Original draggable trigger method. Hack until we have onAll or on('all')
|
|
* @property originalTriggerMethod
|
|
* @type {Function}
|
|
*/
|
|
this.originalTriggerMethod = this.draggable.trigger;
|
|
|
|
this[onInitialize] = this[onInitialize].bind(this);
|
|
this[onDestroy] = this[onDestroy].bind(this);
|
|
}
|
|
|
|
/**
|
|
* Attaches listeners to draggable
|
|
*/
|
|
attach() {
|
|
this.draggable.on('draggable:initialize', this[onInitialize]);
|
|
}
|
|
|
|
/**
|
|
* Detaches listeners from draggable
|
|
*/
|
|
detach() {
|
|
this.draggable.off('draggable:destroy', this[onDestroy]);
|
|
}
|
|
|
|
/**
|
|
* Returns passed in options
|
|
*/
|
|
getOptions() {
|
|
return this.draggable.options.announcements || {};
|
|
}
|
|
|
|
/**
|
|
* Announces event
|
|
* @private
|
|
* @param {AbstractEvent} event
|
|
*/
|
|
[announceEvent](event) {
|
|
const message = this.options[event.type];
|
|
|
|
if (message && typeof message === 'string') {
|
|
this[announceMessage](message);
|
|
}
|
|
|
|
if (message && typeof message === 'function') {
|
|
this[announceMessage](message(event));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Announces message to screen reader
|
|
* @private
|
|
* @param {String} message
|
|
*/
|
|
[announceMessage](message) {
|
|
announce(message, { expire: this.options.expire });
|
|
}
|
|
|
|
/**
|
|
* Initialize hander
|
|
* @private
|
|
*/
|
|
[onInitialize]() {
|
|
// Hack until there is an api for listening for all events
|
|
this.draggable.trigger = event => {
|
|
try {
|
|
this[announceEvent](event);
|
|
} finally {
|
|
// Ensure that original trigger is called
|
|
this.originalTriggerMethod.call(this.draggable, event);
|
|
}
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Destroy hander
|
|
* @private
|
|
*/
|
|
[onDestroy]() {
|
|
this.draggable.trigger = this.originalTriggerMethod;
|
|
}
|
|
}
|
|
|
|
exports.default = Announcement; /**
|
|
* @const {HTMLElement} liveRegion
|
|
*/
|
|
|
|
const liveRegion = createRegion();
|
|
|
|
/**
|
|
* Announces message via live region
|
|
* @param {String} message
|
|
* @param {Object} options
|
|
* @param {Number} options.expire
|
|
*/
|
|
function announce(message, { expire }) {
|
|
const element = document.createElement('div');
|
|
|
|
element.textContent = message;
|
|
liveRegion.appendChild(element);
|
|
|
|
return setTimeout(() => {
|
|
liveRegion.removeChild(element);
|
|
}, expire);
|
|
}
|
|
|
|
/**
|
|
* Creates region element
|
|
* @return {HTMLElement}
|
|
*/
|
|
function createRegion() {
|
|
const element = document.createElement('div');
|
|
|
|
element.setAttribute('id', 'draggable-live-region');
|
|
element.setAttribute(ARIA_RELEVANT, 'additions');
|
|
element.setAttribute(ARIA_ATOMIC, 'true');
|
|
element.setAttribute(ARIA_LIVE, 'assertive');
|
|
element.setAttribute(ROLE, 'log');
|
|
|
|
element.style.position = 'fixed';
|
|
element.style.width = '1px';
|
|
element.style.height = '1px';
|
|
element.style.top = '-1px';
|
|
element.style.overflow = 'hidden';
|
|
|
|
return element;
|
|
}
|
|
|
|
// Append live region element as early as possible
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
document.body.appendChild(liveRegion);
|
|
});
|
|
|
|
/***/ }),
|
|
/* 68 */
|
|
/***/ (function(module, exports, __nested_webpack_require_192085__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.defaultOptions = undefined;
|
|
|
|
var _Announcement = __nested_webpack_require_192085__(67);
|
|
|
|
var _Announcement2 = _interopRequireDefault(_Announcement);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = _Announcement2.default;
|
|
exports.defaultOptions = _Announcement.defaultOptions;
|
|
|
|
/***/ }),
|
|
/* 69 */
|
|
/***/ (function(module, exports, __nested_webpack_require_192581__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.DraggableDestroyEvent = exports.DraggableInitializedEvent = exports.DraggableEvent = undefined;
|
|
|
|
var _AbstractEvent = __nested_webpack_require_192581__(1);
|
|
|
|
var _AbstractEvent2 = _interopRequireDefault(_AbstractEvent);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
/**
|
|
* Base draggable event
|
|
* @class DraggableEvent
|
|
* @module DraggableEvent
|
|
* @extends AbstractEvent
|
|
*/
|
|
class DraggableEvent extends _AbstractEvent2.default {
|
|
|
|
/**
|
|
* Draggable instance
|
|
* @property draggable
|
|
* @type {Draggable}
|
|
* @readonly
|
|
*/
|
|
get draggable() {
|
|
return this.data.draggable;
|
|
}
|
|
}
|
|
|
|
exports.DraggableEvent = DraggableEvent; /**
|
|
* Draggable initialized event
|
|
* @class DraggableInitializedEvent
|
|
* @module DraggableInitializedEvent
|
|
* @extends DraggableEvent
|
|
*/
|
|
|
|
DraggableEvent.type = 'draggable';
|
|
class DraggableInitializedEvent extends DraggableEvent {}
|
|
|
|
exports.DraggableInitializedEvent = DraggableInitializedEvent; /**
|
|
* Draggable destory event
|
|
* @class DraggableInitializedEvent
|
|
* @module DraggableDestroyEvent
|
|
* @extends DraggableDestroyEvent
|
|
*/
|
|
|
|
DraggableInitializedEvent.type = 'draggable:initialize';
|
|
class DraggableDestroyEvent extends DraggableEvent {}
|
|
exports.DraggableDestroyEvent = DraggableDestroyEvent;
|
|
DraggableDestroyEvent.type = 'draggable:destroy';
|
|
|
|
/***/ }),
|
|
/* 70 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _extends = Object.assign || 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; };
|
|
|
|
const canceled = Symbol('canceled');
|
|
|
|
/**
|
|
* All events fired by draggable inherit this class. You can call `cancel()` to
|
|
* cancel a specific event or you can check if an event has been canceled by
|
|
* calling `canceled()`.
|
|
* @abstract
|
|
* @class AbstractEvent
|
|
* @module AbstractEvent
|
|
*/
|
|
class AbstractEvent {
|
|
|
|
/**
|
|
* AbstractEvent constructor.
|
|
* @constructs AbstractEvent
|
|
* @param {object} data - Event data
|
|
*/
|
|
|
|
/**
|
|
* Event type
|
|
* @static
|
|
* @abstract
|
|
* @property type
|
|
* @type {String}
|
|
*/
|
|
constructor(data) {
|
|
this[canceled] = false;
|
|
this.data = data;
|
|
}
|
|
|
|
/**
|
|
* Read-only type
|
|
* @abstract
|
|
* @return {String}
|
|
*/
|
|
|
|
|
|
/**
|
|
* Event cancelable
|
|
* @static
|
|
* @abstract
|
|
* @property cancelable
|
|
* @type {Boolean}
|
|
*/
|
|
get type() {
|
|
return this.constructor.type;
|
|
}
|
|
|
|
/**
|
|
* Read-only cancelable
|
|
* @abstract
|
|
* @return {Boolean}
|
|
*/
|
|
get cancelable() {
|
|
return this.constructor.cancelable;
|
|
}
|
|
|
|
/**
|
|
* Cancels the event instance
|
|
* @abstract
|
|
*/
|
|
cancel() {
|
|
this[canceled] = true;
|
|
}
|
|
|
|
/**
|
|
* Check if event has been canceled
|
|
* @abstract
|
|
* @return {Boolean}
|
|
*/
|
|
canceled() {
|
|
return Boolean(this[canceled]);
|
|
}
|
|
|
|
/**
|
|
* Returns new event instance with existing event data.
|
|
* This method allows for overriding of event data.
|
|
* @param {Object} data
|
|
* @return {AbstractEvent}
|
|
*/
|
|
clone(data) {
|
|
return new this.constructor(_extends({}, this.data, data));
|
|
}
|
|
}
|
|
exports.default = AbstractEvent;
|
|
AbstractEvent.type = 'event';
|
|
AbstractEvent.cancelable = false;
|
|
|
|
/***/ }),
|
|
/* 71 */
|
|
/***/ (function(module, exports, __nested_webpack_require_196591__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.DragStoppedEvent = exports.DragStopEvent = exports.DragPressureEvent = exports.DragOutContainerEvent = exports.DragOverContainerEvent = exports.DragOutEvent = exports.DragOverEvent = exports.DragMoveEvent = exports.DragStartEvent = exports.DragEvent = undefined;
|
|
|
|
var _AbstractEvent = __nested_webpack_require_196591__(1);
|
|
|
|
var _AbstractEvent2 = _interopRequireDefault(_AbstractEvent);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
/**
|
|
* Base drag event
|
|
* @class DragEvent
|
|
* @module DragEvent
|
|
* @extends AbstractEvent
|
|
*/
|
|
class DragEvent extends _AbstractEvent2.default {
|
|
|
|
/**
|
|
* Draggables source element
|
|
* @property source
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get source() {
|
|
return this.data.source;
|
|
}
|
|
|
|
/**
|
|
* Draggables original source element
|
|
* @property originalSource
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get originalSource() {
|
|
return this.data.originalSource;
|
|
}
|
|
|
|
/**
|
|
* Draggables mirror element
|
|
* @property mirror
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get mirror() {
|
|
return this.data.mirror;
|
|
}
|
|
|
|
/**
|
|
* Draggables source container element
|
|
* @property sourceContainer
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get sourceContainer() {
|
|
return this.data.sourceContainer;
|
|
}
|
|
|
|
/**
|
|
* Sensor event
|
|
* @property sensorEvent
|
|
* @type {SensorEvent}
|
|
* @readonly
|
|
*/
|
|
get sensorEvent() {
|
|
return this.data.sensorEvent;
|
|
}
|
|
|
|
/**
|
|
* Original event that triggered sensor event
|
|
* @property originalEvent
|
|
* @type {Event}
|
|
* @readonly
|
|
*/
|
|
get originalEvent() {
|
|
if (this.sensorEvent) {
|
|
return this.sensorEvent.originalEvent;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
|
|
exports.DragEvent = DragEvent; /**
|
|
* Drag start event
|
|
* @class DragStartEvent
|
|
* @module DragStartEvent
|
|
* @extends DragEvent
|
|
*/
|
|
|
|
DragEvent.type = 'drag';
|
|
class DragStartEvent extends DragEvent {}
|
|
|
|
exports.DragStartEvent = DragStartEvent; /**
|
|
* Drag move event
|
|
* @class DragMoveEvent
|
|
* @module DragMoveEvent
|
|
* @extends DragEvent
|
|
*/
|
|
|
|
DragStartEvent.type = 'drag:start';
|
|
DragStartEvent.cancelable = true;
|
|
class DragMoveEvent extends DragEvent {}
|
|
|
|
exports.DragMoveEvent = DragMoveEvent; /**
|
|
* Drag over event
|
|
* @class DragOverEvent
|
|
* @module DragOverEvent
|
|
* @extends DragEvent
|
|
*/
|
|
|
|
DragMoveEvent.type = 'drag:move';
|
|
class DragOverEvent extends DragEvent {
|
|
|
|
/**
|
|
* Draggable container you are over
|
|
* @property overContainer
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get overContainer() {
|
|
return this.data.overContainer;
|
|
}
|
|
|
|
/**
|
|
* Draggable element you are over
|
|
* @property over
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get over() {
|
|
return this.data.over;
|
|
}
|
|
}
|
|
|
|
exports.DragOverEvent = DragOverEvent; /**
|
|
* Drag out event
|
|
* @class DragOutEvent
|
|
* @module DragOutEvent
|
|
* @extends DragEvent
|
|
*/
|
|
|
|
DragOverEvent.type = 'drag:over';
|
|
DragOverEvent.cancelable = true;
|
|
class DragOutEvent extends DragEvent {
|
|
|
|
/**
|
|
* Draggable container you are over
|
|
* @property overContainer
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get overContainer() {
|
|
return this.data.overContainer;
|
|
}
|
|
|
|
/**
|
|
* Draggable element you left
|
|
* @property over
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get over() {
|
|
return this.data.over;
|
|
}
|
|
}
|
|
|
|
exports.DragOutEvent = DragOutEvent; /**
|
|
* Drag over container event
|
|
* @class DragOverContainerEvent
|
|
* @module DragOverContainerEvent
|
|
* @extends DragEvent
|
|
*/
|
|
|
|
DragOutEvent.type = 'drag:out';
|
|
class DragOverContainerEvent extends DragEvent {
|
|
|
|
/**
|
|
* Draggable container you are over
|
|
* @property overContainer
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get overContainer() {
|
|
return this.data.overContainer;
|
|
}
|
|
}
|
|
|
|
exports.DragOverContainerEvent = DragOverContainerEvent; /**
|
|
* Drag out container event
|
|
* @class DragOutContainerEvent
|
|
* @module DragOutContainerEvent
|
|
* @extends DragEvent
|
|
*/
|
|
|
|
DragOverContainerEvent.type = 'drag:over:container';
|
|
class DragOutContainerEvent extends DragEvent {
|
|
|
|
/**
|
|
* Draggable container you left
|
|
* @property overContainer
|
|
* @type {HTMLElement}
|
|
* @readonly
|
|
*/
|
|
get overContainer() {
|
|
return this.data.overContainer;
|
|
}
|
|
}
|
|
|
|
exports.DragOutContainerEvent = DragOutContainerEvent; /**
|
|
* Drag pressure event
|
|
* @class DragPressureEvent
|
|
* @module DragPressureEvent
|
|
* @extends DragEvent
|
|
*/
|
|
|
|
DragOutContainerEvent.type = 'drag:out:container';
|
|
class DragPressureEvent extends DragEvent {
|
|
|
|
/**
|
|
* Pressure applied on draggable element
|
|
* @property pressure
|
|
* @type {Number}
|
|
* @readonly
|
|
*/
|
|
get pressure() {
|
|
return this.data.pressure;
|
|
}
|
|
}
|
|
|
|
exports.DragPressureEvent = DragPressureEvent; /**
|
|
* Drag stop event
|
|
* @class DragStopEvent
|
|
* @module DragStopEvent
|
|
* @extends DragEvent
|
|
*/
|
|
|
|
DragPressureEvent.type = 'drag:pressure';
|
|
class DragStopEvent extends DragEvent {}
|
|
|
|
exports.DragStopEvent = DragStopEvent; /**
|
|
* Drag stopped event
|
|
* @class DragStoppedEvent
|
|
* @module DragStoppedEvent
|
|
* @extends DragEvent
|
|
*/
|
|
|
|
DragStopEvent.type = 'drag:stop';
|
|
class DragStoppedEvent extends DragEvent {}
|
|
exports.DragStoppedEvent = DragStoppedEvent;
|
|
DragStoppedEvent.type = 'drag:stopped';
|
|
|
|
/***/ }),
|
|
/* 72 */
|
|
/***/ (function(module, exports, __nested_webpack_require_203856__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.Plugins = exports.Sensors = exports.Sortable = exports.Swappable = exports.Droppable = exports.Draggable = exports.BasePlugin = exports.BaseEvent = undefined;
|
|
|
|
var _Draggable = __nested_webpack_require_203856__(5);
|
|
|
|
Object.defineProperty(exports, 'Draggable', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _interopRequireDefault(_Draggable).default;
|
|
}
|
|
});
|
|
|
|
var _Droppable = __nested_webpack_require_203856__(36);
|
|
|
|
Object.defineProperty(exports, 'Droppable', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _interopRequireDefault(_Droppable).default;
|
|
}
|
|
});
|
|
|
|
var _Swappable = __nested_webpack_require_203856__(33);
|
|
|
|
Object.defineProperty(exports, 'Swappable', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _interopRequireDefault(_Swappable).default;
|
|
}
|
|
});
|
|
|
|
var _Sortable = __nested_webpack_require_203856__(30);
|
|
|
|
Object.defineProperty(exports, 'Sortable', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return _interopRequireDefault(_Sortable).default;
|
|
}
|
|
});
|
|
|
|
var _AbstractEvent = __nested_webpack_require_203856__(1);
|
|
|
|
var _AbstractEvent2 = _interopRequireDefault(_AbstractEvent);
|
|
|
|
var _AbstractPlugin = __nested_webpack_require_203856__(0);
|
|
|
|
var _AbstractPlugin2 = _interopRequireDefault(_AbstractPlugin);
|
|
|
|
var _Sensors = __nested_webpack_require_203856__(6);
|
|
|
|
var Sensors = _interopRequireWildcard(_Sensors);
|
|
|
|
var _Plugins = __nested_webpack_require_203856__(27);
|
|
|
|
var Plugins = _interopRequireWildcard(_Plugins);
|
|
|
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.BaseEvent = _AbstractEvent2.default;
|
|
exports.BasePlugin = _AbstractPlugin2.default;
|
|
exports.Sensors = Sensors;
|
|
exports.Plugins = Plugins;
|
|
|
|
/***/ })
|
|
/******/ ]);
|
|
});
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./resources/js/quill.js":
|
|
/*!*******************************!*\
|
|
!*** ./resources/js/quill.js ***!
|
|
\*******************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony import */ var quill_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! quill/core */ "./node_modules/quill/core.js");
|
|
/* harmony import */ var quill_modules_toolbar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! quill/modules/toolbar */ "./node_modules/quill/modules/toolbar.js");
|
|
/* harmony import */ var quill_themes_snow__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! quill/themes/snow */ "./node_modules/quill/themes/snow.js");
|
|
|
|
|
|
|
|
quill_core__WEBPACK_IMPORTED_MODULE_0__.default.register({
|
|
'modules/toolbar': quill_modules_toolbar__WEBPACK_IMPORTED_MODULE_1__.default,
|
|
'themes/snow': quill_themes_snow__WEBPACK_IMPORTED_MODULE_2__.default
|
|
});
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (quill_core__WEBPACK_IMPORTED_MODULE_0__.default);
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/base64-js/index.js":
|
|
/*!*****************************************!*\
|
|
!*** ./node_modules/base64-js/index.js ***!
|
|
\*****************************************/
|
|
/***/ ((__unused_webpack_module, exports) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
exports.byteLength = byteLength
|
|
exports.toByteArray = toByteArray
|
|
exports.fromByteArray = fromByteArray
|
|
|
|
var lookup = []
|
|
var revLookup = []
|
|
var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
|
|
|
|
var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
|
for (var i = 0, len = code.length; i < len; ++i) {
|
|
lookup[i] = code[i]
|
|
revLookup[code.charCodeAt(i)] = i
|
|
}
|
|
|
|
// Support decoding URL-safe base64 strings, as Node.js does.
|
|
// See: https://en.wikipedia.org/wiki/Base64#URL_applications
|
|
revLookup['-'.charCodeAt(0)] = 62
|
|
revLookup['_'.charCodeAt(0)] = 63
|
|
|
|
function getLens (b64) {
|
|
var len = b64.length
|
|
|
|
if (len % 4 > 0) {
|
|
throw new Error('Invalid string. Length must be a multiple of 4')
|
|
}
|
|
|
|
// Trim off extra bytes after placeholder bytes are found
|
|
// See: https://github.com/beatgammit/base64-js/issues/42
|
|
var validLen = b64.indexOf('=')
|
|
if (validLen === -1) validLen = len
|
|
|
|
var placeHoldersLen = validLen === len
|
|
? 0
|
|
: 4 - (validLen % 4)
|
|
|
|
return [validLen, placeHoldersLen]
|
|
}
|
|
|
|
// base64 is 4/3 + up to two characters of the original data
|
|
function byteLength (b64) {
|
|
var lens = getLens(b64)
|
|
var validLen = lens[0]
|
|
var placeHoldersLen = lens[1]
|
|
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
|
}
|
|
|
|
function _byteLength (b64, validLen, placeHoldersLen) {
|
|
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
|
}
|
|
|
|
function toByteArray (b64) {
|
|
var tmp
|
|
var lens = getLens(b64)
|
|
var validLen = lens[0]
|
|
var placeHoldersLen = lens[1]
|
|
|
|
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
|
|
|
|
var curByte = 0
|
|
|
|
// if there are placeholders, only get up to the last complete 4 chars
|
|
var len = placeHoldersLen > 0
|
|
? validLen - 4
|
|
: validLen
|
|
|
|
var i
|
|
for (i = 0; i < len; i += 4) {
|
|
tmp =
|
|
(revLookup[b64.charCodeAt(i)] << 18) |
|
|
(revLookup[b64.charCodeAt(i + 1)] << 12) |
|
|
(revLookup[b64.charCodeAt(i + 2)] << 6) |
|
|
revLookup[b64.charCodeAt(i + 3)]
|
|
arr[curByte++] = (tmp >> 16) & 0xFF
|
|
arr[curByte++] = (tmp >> 8) & 0xFF
|
|
arr[curByte++] = tmp & 0xFF
|
|
}
|
|
|
|
if (placeHoldersLen === 2) {
|
|
tmp =
|
|
(revLookup[b64.charCodeAt(i)] << 2) |
|
|
(revLookup[b64.charCodeAt(i + 1)] >> 4)
|
|
arr[curByte++] = tmp & 0xFF
|
|
}
|
|
|
|
if (placeHoldersLen === 1) {
|
|
tmp =
|
|
(revLookup[b64.charCodeAt(i)] << 10) |
|
|
(revLookup[b64.charCodeAt(i + 1)] << 4) |
|
|
(revLookup[b64.charCodeAt(i + 2)] >> 2)
|
|
arr[curByte++] = (tmp >> 8) & 0xFF
|
|
arr[curByte++] = tmp & 0xFF
|
|
}
|
|
|
|
return arr
|
|
}
|
|
|
|
function tripletToBase64 (num) {
|
|
return lookup[num >> 18 & 0x3F] +
|
|
lookup[num >> 12 & 0x3F] +
|
|
lookup[num >> 6 & 0x3F] +
|
|
lookup[num & 0x3F]
|
|
}
|
|
|
|
function encodeChunk (uint8, start, end) {
|
|
var tmp
|
|
var output = []
|
|
for (var i = start; i < end; i += 3) {
|
|
tmp =
|
|
((uint8[i] << 16) & 0xFF0000) +
|
|
((uint8[i + 1] << 8) & 0xFF00) +
|
|
(uint8[i + 2] & 0xFF)
|
|
output.push(tripletToBase64(tmp))
|
|
}
|
|
return output.join('')
|
|
}
|
|
|
|
function fromByteArray (uint8) {
|
|
var tmp
|
|
var len = uint8.length
|
|
var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
|
|
var parts = []
|
|
var maxChunkLength = 16383 // must be multiple of 3
|
|
|
|
// go through the array every three bytes, we'll deal with trailing stuff later
|
|
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
|
|
parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
|
|
}
|
|
|
|
// pad the end with zeros, but make sure to not forget the extra bytes
|
|
if (extraBytes === 1) {
|
|
tmp = uint8[len - 1]
|
|
parts.push(
|
|
lookup[tmp >> 2] +
|
|
lookup[(tmp << 4) & 0x3F] +
|
|
'=='
|
|
)
|
|
} else if (extraBytes === 2) {
|
|
tmp = (uint8[len - 2] << 8) + uint8[len - 1]
|
|
parts.push(
|
|
lookup[tmp >> 10] +
|
|
lookup[(tmp >> 4) & 0x3F] +
|
|
lookup[(tmp << 2) & 0x3F] +
|
|
'='
|
|
)
|
|
}
|
|
|
|
return parts.join('')
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/buffer/index.js":
|
|
/*!**************************************!*\
|
|
!*** ./node_modules/buffer/index.js ***!
|
|
\**************************************/
|
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
/*!
|
|
* The buffer module from node.js, for the browser.
|
|
*
|
|
* @author Feross Aboukhadijeh <http://feross.org>
|
|
* @license MIT
|
|
*/
|
|
/* eslint-disable no-proto */
|
|
|
|
|
|
|
|
var base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js")
|
|
var ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js")
|
|
var isArray = __webpack_require__(/*! isarray */ "./node_modules/isarray/index.js")
|
|
|
|
exports.Buffer = Buffer
|
|
exports.SlowBuffer = SlowBuffer
|
|
exports.INSPECT_MAX_BYTES = 50
|
|
|
|
/**
|
|
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
|
* === true Use Uint8Array implementation (fastest)
|
|
* === false Use Object implementation (most compatible, even IE6)
|
|
*
|
|
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
|
|
* Opera 11.6+, iOS 4.2+.
|
|
*
|
|
* Due to various browser bugs, sometimes the Object implementation will be used even
|
|
* when the browser supports typed arrays.
|
|
*
|
|
* Note:
|
|
*
|
|
* - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
|
|
* See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
|
|
*
|
|
* - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
|
|
*
|
|
* - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
|
|
* incorrect length in some situations.
|
|
|
|
* We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
|
|
* get the Object implementation, which is slower but behaves correctly.
|
|
*/
|
|
Buffer.TYPED_ARRAY_SUPPORT = __webpack_require__.g.TYPED_ARRAY_SUPPORT !== undefined
|
|
? __webpack_require__.g.TYPED_ARRAY_SUPPORT
|
|
: typedArraySupport()
|
|
|
|
/*
|
|
* Export kMaxLength after typed array support is determined.
|
|
*/
|
|
exports.kMaxLength = kMaxLength()
|
|
|
|
function typedArraySupport () {
|
|
try {
|
|
var arr = new Uint8Array(1)
|
|
arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
|
|
return arr.foo() === 42 && // typed array instances can be augmented
|
|
typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
|
|
arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
|
|
} catch (e) {
|
|
return false
|
|
}
|
|
}
|
|
|
|
function kMaxLength () {
|
|
return Buffer.TYPED_ARRAY_SUPPORT
|
|
? 0x7fffffff
|
|
: 0x3fffffff
|
|
}
|
|
|
|
function createBuffer (that, length) {
|
|
if (kMaxLength() < length) {
|
|
throw new RangeError('Invalid typed array length')
|
|
}
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
// Return an augmented `Uint8Array` instance, for best performance
|
|
that = new Uint8Array(length)
|
|
that.__proto__ = Buffer.prototype
|
|
} else {
|
|
// Fallback: Return an object instance of the Buffer class
|
|
if (that === null) {
|
|
that = new Buffer(length)
|
|
}
|
|
that.length = length
|
|
}
|
|
|
|
return that
|
|
}
|
|
|
|
/**
|
|
* The Buffer constructor returns instances of `Uint8Array` that have their
|
|
* prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
|
|
* `Uint8Array`, so the returned instances will have all the node `Buffer` methods
|
|
* and the `Uint8Array` methods. Square bracket notation works as expected -- it
|
|
* returns a single octet.
|
|
*
|
|
* The `Uint8Array` prototype remains unmodified.
|
|
*/
|
|
|
|
function Buffer (arg, encodingOrOffset, length) {
|
|
if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
|
|
return new Buffer(arg, encodingOrOffset, length)
|
|
}
|
|
|
|
// Common case.
|
|
if (typeof arg === 'number') {
|
|
if (typeof encodingOrOffset === 'string') {
|
|
throw new Error(
|
|
'If encoding is specified then the first argument must be a string'
|
|
)
|
|
}
|
|
return allocUnsafe(this, arg)
|
|
}
|
|
return from(this, arg, encodingOrOffset, length)
|
|
}
|
|
|
|
Buffer.poolSize = 8192 // not used by this implementation
|
|
|
|
// TODO: Legacy, not needed anymore. Remove in next major version.
|
|
Buffer._augment = function (arr) {
|
|
arr.__proto__ = Buffer.prototype
|
|
return arr
|
|
}
|
|
|
|
function from (that, value, encodingOrOffset, length) {
|
|
if (typeof value === 'number') {
|
|
throw new TypeError('"value" argument must not be a number')
|
|
}
|
|
|
|
if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
|
|
return fromArrayBuffer(that, value, encodingOrOffset, length)
|
|
}
|
|
|
|
if (typeof value === 'string') {
|
|
return fromString(that, value, encodingOrOffset)
|
|
}
|
|
|
|
return fromObject(that, value)
|
|
}
|
|
|
|
/**
|
|
* Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
|
|
* if value is a number.
|
|
* Buffer.from(str[, encoding])
|
|
* Buffer.from(array)
|
|
* Buffer.from(buffer)
|
|
* Buffer.from(arrayBuffer[, byteOffset[, length]])
|
|
**/
|
|
Buffer.from = function (value, encodingOrOffset, length) {
|
|
return from(null, value, encodingOrOffset, length)
|
|
}
|
|
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
Buffer.prototype.__proto__ = Uint8Array.prototype
|
|
Buffer.__proto__ = Uint8Array
|
|
if (typeof Symbol !== 'undefined' && Symbol.species &&
|
|
Buffer[Symbol.species] === Buffer) {
|
|
// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
|
|
Object.defineProperty(Buffer, Symbol.species, {
|
|
value: null,
|
|
configurable: true
|
|
})
|
|
}
|
|
}
|
|
|
|
function assertSize (size) {
|
|
if (typeof size !== 'number') {
|
|
throw new TypeError('"size" argument must be a number')
|
|
} else if (size < 0) {
|
|
throw new RangeError('"size" argument must not be negative')
|
|
}
|
|
}
|
|
|
|
function alloc (that, size, fill, encoding) {
|
|
assertSize(size)
|
|
if (size <= 0) {
|
|
return createBuffer(that, size)
|
|
}
|
|
if (fill !== undefined) {
|
|
// Only pay attention to encoding if it's a string. This
|
|
// prevents accidentally sending in a number that would
|
|
// be interpretted as a start offset.
|
|
return typeof encoding === 'string'
|
|
? createBuffer(that, size).fill(fill, encoding)
|
|
: createBuffer(that, size).fill(fill)
|
|
}
|
|
return createBuffer(that, size)
|
|
}
|
|
|
|
/**
|
|
* Creates a new filled Buffer instance.
|
|
* alloc(size[, fill[, encoding]])
|
|
**/
|
|
Buffer.alloc = function (size, fill, encoding) {
|
|
return alloc(null, size, fill, encoding)
|
|
}
|
|
|
|
function allocUnsafe (that, size) {
|
|
assertSize(size)
|
|
that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
|
|
if (!Buffer.TYPED_ARRAY_SUPPORT) {
|
|
for (var i = 0; i < size; ++i) {
|
|
that[i] = 0
|
|
}
|
|
}
|
|
return that
|
|
}
|
|
|
|
/**
|
|
* Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
|
|
* */
|
|
Buffer.allocUnsafe = function (size) {
|
|
return allocUnsafe(null, size)
|
|
}
|
|
/**
|
|
* Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
|
*/
|
|
Buffer.allocUnsafeSlow = function (size) {
|
|
return allocUnsafe(null, size)
|
|
}
|
|
|
|
function fromString (that, string, encoding) {
|
|
if (typeof encoding !== 'string' || encoding === '') {
|
|
encoding = 'utf8'
|
|
}
|
|
|
|
if (!Buffer.isEncoding(encoding)) {
|
|
throw new TypeError('"encoding" must be a valid string encoding')
|
|
}
|
|
|
|
var length = byteLength(string, encoding) | 0
|
|
that = createBuffer(that, length)
|
|
|
|
var actual = that.write(string, encoding)
|
|
|
|
if (actual !== length) {
|
|
// Writing a hex string, for example, that contains invalid characters will
|
|
// cause everything after the first invalid character to be ignored. (e.g.
|
|
// 'abxxcd' will be treated as 'ab')
|
|
that = that.slice(0, actual)
|
|
}
|
|
|
|
return that
|
|
}
|
|
|
|
function fromArrayLike (that, array) {
|
|
var length = array.length < 0 ? 0 : checked(array.length) | 0
|
|
that = createBuffer(that, length)
|
|
for (var i = 0; i < length; i += 1) {
|
|
that[i] = array[i] & 255
|
|
}
|
|
return that
|
|
}
|
|
|
|
function fromArrayBuffer (that, array, byteOffset, length) {
|
|
array.byteLength // this throws if `array` is not a valid ArrayBuffer
|
|
|
|
if (byteOffset < 0 || array.byteLength < byteOffset) {
|
|
throw new RangeError('\'offset\' is out of bounds')
|
|
}
|
|
|
|
if (array.byteLength < byteOffset + (length || 0)) {
|
|
throw new RangeError('\'length\' is out of bounds')
|
|
}
|
|
|
|
if (byteOffset === undefined && length === undefined) {
|
|
array = new Uint8Array(array)
|
|
} else if (length === undefined) {
|
|
array = new Uint8Array(array, byteOffset)
|
|
} else {
|
|
array = new Uint8Array(array, byteOffset, length)
|
|
}
|
|
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
// Return an augmented `Uint8Array` instance, for best performance
|
|
that = array
|
|
that.__proto__ = Buffer.prototype
|
|
} else {
|
|
// Fallback: Return an object instance of the Buffer class
|
|
that = fromArrayLike(that, array)
|
|
}
|
|
return that
|
|
}
|
|
|
|
function fromObject (that, obj) {
|
|
if (Buffer.isBuffer(obj)) {
|
|
var len = checked(obj.length) | 0
|
|
that = createBuffer(that, len)
|
|
|
|
if (that.length === 0) {
|
|
return that
|
|
}
|
|
|
|
obj.copy(that, 0, 0, len)
|
|
return that
|
|
}
|
|
|
|
if (obj) {
|
|
if ((typeof ArrayBuffer !== 'undefined' &&
|
|
obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
|
|
if (typeof obj.length !== 'number' || isnan(obj.length)) {
|
|
return createBuffer(that, 0)
|
|
}
|
|
return fromArrayLike(that, obj)
|
|
}
|
|
|
|
if (obj.type === 'Buffer' && isArray(obj.data)) {
|
|
return fromArrayLike(that, obj.data)
|
|
}
|
|
}
|
|
|
|
throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
|
|
}
|
|
|
|
function checked (length) {
|
|
// Note: cannot use `length < kMaxLength()` here because that fails when
|
|
// length is NaN (which is otherwise coerced to zero.)
|
|
if (length >= kMaxLength()) {
|
|
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
|
|
'size: 0x' + kMaxLength().toString(16) + ' bytes')
|
|
}
|
|
return length | 0
|
|
}
|
|
|
|
function SlowBuffer (length) {
|
|
if (+length != length) { // eslint-disable-line eqeqeq
|
|
length = 0
|
|
}
|
|
return Buffer.alloc(+length)
|
|
}
|
|
|
|
Buffer.isBuffer = function isBuffer (b) {
|
|
return !!(b != null && b._isBuffer)
|
|
}
|
|
|
|
Buffer.compare = function compare (a, b) {
|
|
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
|
throw new TypeError('Arguments must be Buffers')
|
|
}
|
|
|
|
if (a === b) return 0
|
|
|
|
var x = a.length
|
|
var y = b.length
|
|
|
|
for (var i = 0, len = Math.min(x, y); i < len; ++i) {
|
|
if (a[i] !== b[i]) {
|
|
x = a[i]
|
|
y = b[i]
|
|
break
|
|
}
|
|
}
|
|
|
|
if (x < y) return -1
|
|
if (y < x) return 1
|
|
return 0
|
|
}
|
|
|
|
Buffer.isEncoding = function isEncoding (encoding) {
|
|
switch (String(encoding).toLowerCase()) {
|
|
case 'hex':
|
|
case 'utf8':
|
|
case 'utf-8':
|
|
case 'ascii':
|
|
case 'latin1':
|
|
case 'binary':
|
|
case 'base64':
|
|
case 'ucs2':
|
|
case 'ucs-2':
|
|
case 'utf16le':
|
|
case 'utf-16le':
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
Buffer.concat = function concat (list, length) {
|
|
if (!isArray(list)) {
|
|
throw new TypeError('"list" argument must be an Array of Buffers')
|
|
}
|
|
|
|
if (list.length === 0) {
|
|
return Buffer.alloc(0)
|
|
}
|
|
|
|
var i
|
|
if (length === undefined) {
|
|
length = 0
|
|
for (i = 0; i < list.length; ++i) {
|
|
length += list[i].length
|
|
}
|
|
}
|
|
|
|
var buffer = Buffer.allocUnsafe(length)
|
|
var pos = 0
|
|
for (i = 0; i < list.length; ++i) {
|
|
var buf = list[i]
|
|
if (!Buffer.isBuffer(buf)) {
|
|
throw new TypeError('"list" argument must be an Array of Buffers')
|
|
}
|
|
buf.copy(buffer, pos)
|
|
pos += buf.length
|
|
}
|
|
return buffer
|
|
}
|
|
|
|
function byteLength (string, encoding) {
|
|
if (Buffer.isBuffer(string)) {
|
|
return string.length
|
|
}
|
|
if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
|
|
(ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
|
|
return string.byteLength
|
|
}
|
|
if (typeof string !== 'string') {
|
|
string = '' + string
|
|
}
|
|
|
|
var len = string.length
|
|
if (len === 0) return 0
|
|
|
|
// Use a for loop to avoid recursion
|
|
var loweredCase = false
|
|
for (;;) {
|
|
switch (encoding) {
|
|
case 'ascii':
|
|
case 'latin1':
|
|
case 'binary':
|
|
return len
|
|
case 'utf8':
|
|
case 'utf-8':
|
|
case undefined:
|
|
return utf8ToBytes(string).length
|
|
case 'ucs2':
|
|
case 'ucs-2':
|
|
case 'utf16le':
|
|
case 'utf-16le':
|
|
return len * 2
|
|
case 'hex':
|
|
return len >>> 1
|
|
case 'base64':
|
|
return base64ToBytes(string).length
|
|
default:
|
|
if (loweredCase) return utf8ToBytes(string).length // assume utf8
|
|
encoding = ('' + encoding).toLowerCase()
|
|
loweredCase = true
|
|
}
|
|
}
|
|
}
|
|
Buffer.byteLength = byteLength
|
|
|
|
function slowToString (encoding, start, end) {
|
|
var loweredCase = false
|
|
|
|
// No need to verify that "this.length <= MAX_UINT32" since it's a read-only
|
|
// property of a typed array.
|
|
|
|
// This behaves neither like String nor Uint8Array in that we set start/end
|
|
// to their upper/lower bounds if the value passed is out of range.
|
|
// undefined is handled specially as per ECMA-262 6th Edition,
|
|
// Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
|
|
if (start === undefined || start < 0) {
|
|
start = 0
|
|
}
|
|
// Return early if start > this.length. Done here to prevent potential uint32
|
|
// coercion fail below.
|
|
if (start > this.length) {
|
|
return ''
|
|
}
|
|
|
|
if (end === undefined || end > this.length) {
|
|
end = this.length
|
|
}
|
|
|
|
if (end <= 0) {
|
|
return ''
|
|
}
|
|
|
|
// Force coersion to uint32. This will also coerce falsey/NaN values to 0.
|
|
end >>>= 0
|
|
start >>>= 0
|
|
|
|
if (end <= start) {
|
|
return ''
|
|
}
|
|
|
|
if (!encoding) encoding = 'utf8'
|
|
|
|
while (true) {
|
|
switch (encoding) {
|
|
case 'hex':
|
|
return hexSlice(this, start, end)
|
|
|
|
case 'utf8':
|
|
case 'utf-8':
|
|
return utf8Slice(this, start, end)
|
|
|
|
case 'ascii':
|
|
return asciiSlice(this, start, end)
|
|
|
|
case 'latin1':
|
|
case 'binary':
|
|
return latin1Slice(this, start, end)
|
|
|
|
case 'base64':
|
|
return base64Slice(this, start, end)
|
|
|
|
case 'ucs2':
|
|
case 'ucs-2':
|
|
case 'utf16le':
|
|
case 'utf-16le':
|
|
return utf16leSlice(this, start, end)
|
|
|
|
default:
|
|
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
|
encoding = (encoding + '').toLowerCase()
|
|
loweredCase = true
|
|
}
|
|
}
|
|
}
|
|
|
|
// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
|
|
// Buffer instances.
|
|
Buffer.prototype._isBuffer = true
|
|
|
|
function swap (b, n, m) {
|
|
var i = b[n]
|
|
b[n] = b[m]
|
|
b[m] = i
|
|
}
|
|
|
|
Buffer.prototype.swap16 = function swap16 () {
|
|
var len = this.length
|
|
if (len % 2 !== 0) {
|
|
throw new RangeError('Buffer size must be a multiple of 16-bits')
|
|
}
|
|
for (var i = 0; i < len; i += 2) {
|
|
swap(this, i, i + 1)
|
|
}
|
|
return this
|
|
}
|
|
|
|
Buffer.prototype.swap32 = function swap32 () {
|
|
var len = this.length
|
|
if (len % 4 !== 0) {
|
|
throw new RangeError('Buffer size must be a multiple of 32-bits')
|
|
}
|
|
for (var i = 0; i < len; i += 4) {
|
|
swap(this, i, i + 3)
|
|
swap(this, i + 1, i + 2)
|
|
}
|
|
return this
|
|
}
|
|
|
|
Buffer.prototype.swap64 = function swap64 () {
|
|
var len = this.length
|
|
if (len % 8 !== 0) {
|
|
throw new RangeError('Buffer size must be a multiple of 64-bits')
|
|
}
|
|
for (var i = 0; i < len; i += 8) {
|
|
swap(this, i, i + 7)
|
|
swap(this, i + 1, i + 6)
|
|
swap(this, i + 2, i + 5)
|
|
swap(this, i + 3, i + 4)
|
|
}
|
|
return this
|
|
}
|
|
|
|
Buffer.prototype.toString = function toString () {
|
|
var length = this.length | 0
|
|
if (length === 0) return ''
|
|
if (arguments.length === 0) return utf8Slice(this, 0, length)
|
|
return slowToString.apply(this, arguments)
|
|
}
|
|
|
|
Buffer.prototype.equals = function equals (b) {
|
|
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
|
if (this === b) return true
|
|
return Buffer.compare(this, b) === 0
|
|
}
|
|
|
|
Buffer.prototype.inspect = function inspect () {
|
|
var str = ''
|
|
var max = exports.INSPECT_MAX_BYTES
|
|
if (this.length > 0) {
|
|
str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
|
|
if (this.length > max) str += ' ... '
|
|
}
|
|
return '<Buffer ' + str + '>'
|
|
}
|
|
|
|
Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
|
|
if (!Buffer.isBuffer(target)) {
|
|
throw new TypeError('Argument must be a Buffer')
|
|
}
|
|
|
|
if (start === undefined) {
|
|
start = 0
|
|
}
|
|
if (end === undefined) {
|
|
end = target ? target.length : 0
|
|
}
|
|
if (thisStart === undefined) {
|
|
thisStart = 0
|
|
}
|
|
if (thisEnd === undefined) {
|
|
thisEnd = this.length
|
|
}
|
|
|
|
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
|
|
throw new RangeError('out of range index')
|
|
}
|
|
|
|
if (thisStart >= thisEnd && start >= end) {
|
|
return 0
|
|
}
|
|
if (thisStart >= thisEnd) {
|
|
return -1
|
|
}
|
|
if (start >= end) {
|
|
return 1
|
|
}
|
|
|
|
start >>>= 0
|
|
end >>>= 0
|
|
thisStart >>>= 0
|
|
thisEnd >>>= 0
|
|
|
|
if (this === target) return 0
|
|
|
|
var x = thisEnd - thisStart
|
|
var y = end - start
|
|
var len = Math.min(x, y)
|
|
|
|
var thisCopy = this.slice(thisStart, thisEnd)
|
|
var targetCopy = target.slice(start, end)
|
|
|
|
for (var i = 0; i < len; ++i) {
|
|
if (thisCopy[i] !== targetCopy[i]) {
|
|
x = thisCopy[i]
|
|
y = targetCopy[i]
|
|
break
|
|
}
|
|
}
|
|
|
|
if (x < y) return -1
|
|
if (y < x) return 1
|
|
return 0
|
|
}
|
|
|
|
// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
|
|
// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
|
|
//
|
|
// Arguments:
|
|
// - buffer - a Buffer to search
|
|
// - val - a string, Buffer, or number
|
|
// - byteOffset - an index into `buffer`; will be clamped to an int32
|
|
// - encoding - an optional encoding, relevant is val is a string
|
|
// - dir - true for indexOf, false for lastIndexOf
|
|
function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
|
|
// Empty buffer means no match
|
|
if (buffer.length === 0) return -1
|
|
|
|
// Normalize byteOffset
|
|
if (typeof byteOffset === 'string') {
|
|
encoding = byteOffset
|
|
byteOffset = 0
|
|
} else if (byteOffset > 0x7fffffff) {
|
|
byteOffset = 0x7fffffff
|
|
} else if (byteOffset < -0x80000000) {
|
|
byteOffset = -0x80000000
|
|
}
|
|
byteOffset = +byteOffset // Coerce to Number.
|
|
if (isNaN(byteOffset)) {
|
|
// byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
|
|
byteOffset = dir ? 0 : (buffer.length - 1)
|
|
}
|
|
|
|
// Normalize byteOffset: negative offsets start from the end of the buffer
|
|
if (byteOffset < 0) byteOffset = buffer.length + byteOffset
|
|
if (byteOffset >= buffer.length) {
|
|
if (dir) return -1
|
|
else byteOffset = buffer.length - 1
|
|
} else if (byteOffset < 0) {
|
|
if (dir) byteOffset = 0
|
|
else return -1
|
|
}
|
|
|
|
// Normalize val
|
|
if (typeof val === 'string') {
|
|
val = Buffer.from(val, encoding)
|
|
}
|
|
|
|
// Finally, search either indexOf (if dir is true) or lastIndexOf
|
|
if (Buffer.isBuffer(val)) {
|
|
// Special case: looking for empty string/buffer always fails
|
|
if (val.length === 0) {
|
|
return -1
|
|
}
|
|
return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
|
|
} else if (typeof val === 'number') {
|
|
val = val & 0xFF // Search for a byte value [0-255]
|
|
if (Buffer.TYPED_ARRAY_SUPPORT &&
|
|
typeof Uint8Array.prototype.indexOf === 'function') {
|
|
if (dir) {
|
|
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
|
|
} else {
|
|
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
|
|
}
|
|
}
|
|
return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
|
|
}
|
|
|
|
throw new TypeError('val must be string, number or Buffer')
|
|
}
|
|
|
|
function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
|
|
var indexSize = 1
|
|
var arrLength = arr.length
|
|
var valLength = val.length
|
|
|
|
if (encoding !== undefined) {
|
|
encoding = String(encoding).toLowerCase()
|
|
if (encoding === 'ucs2' || encoding === 'ucs-2' ||
|
|
encoding === 'utf16le' || encoding === 'utf-16le') {
|
|
if (arr.length < 2 || val.length < 2) {
|
|
return -1
|
|
}
|
|
indexSize = 2
|
|
arrLength /= 2
|
|
valLength /= 2
|
|
byteOffset /= 2
|
|
}
|
|
}
|
|
|
|
function read (buf, i) {
|
|
if (indexSize === 1) {
|
|
return buf[i]
|
|
} else {
|
|
return buf.readUInt16BE(i * indexSize)
|
|
}
|
|
}
|
|
|
|
var i
|
|
if (dir) {
|
|
var foundIndex = -1
|
|
for (i = byteOffset; i < arrLength; i++) {
|
|
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
|
if (foundIndex === -1) foundIndex = i
|
|
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
|
|
} else {
|
|
if (foundIndex !== -1) i -= i - foundIndex
|
|
foundIndex = -1
|
|
}
|
|
}
|
|
} else {
|
|
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
|
|
for (i = byteOffset; i >= 0; i--) {
|
|
var found = true
|
|
for (var j = 0; j < valLength; j++) {
|
|
if (read(arr, i + j) !== read(val, j)) {
|
|
found = false
|
|
break
|
|
}
|
|
}
|
|
if (found) return i
|
|
}
|
|
}
|
|
|
|
return -1
|
|
}
|
|
|
|
Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
|
|
return this.indexOf(val, byteOffset, encoding) !== -1
|
|
}
|
|
|
|
Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
|
|
return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
|
|
}
|
|
|
|
Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
|
|
return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
|
|
}
|
|
|
|
function hexWrite (buf, string, offset, length) {
|
|
offset = Number(offset) || 0
|
|
var remaining = buf.length - offset
|
|
if (!length) {
|
|
length = remaining
|
|
} else {
|
|
length = Number(length)
|
|
if (length > remaining) {
|
|
length = remaining
|
|
}
|
|
}
|
|
|
|
// must be an even number of digits
|
|
var strLen = string.length
|
|
if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
|
|
|
|
if (length > strLen / 2) {
|
|
length = strLen / 2
|
|
}
|
|
for (var i = 0; i < length; ++i) {
|
|
var parsed = parseInt(string.substr(i * 2, 2), 16)
|
|
if (isNaN(parsed)) return i
|
|
buf[offset + i] = parsed
|
|
}
|
|
return i
|
|
}
|
|
|
|
function utf8Write (buf, string, offset, length) {
|
|
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
|
|
}
|
|
|
|
function asciiWrite (buf, string, offset, length) {
|
|
return blitBuffer(asciiToBytes(string), buf, offset, length)
|
|
}
|
|
|
|
function latin1Write (buf, string, offset, length) {
|
|
return asciiWrite(buf, string, offset, length)
|
|
}
|
|
|
|
function base64Write (buf, string, offset, length) {
|
|
return blitBuffer(base64ToBytes(string), buf, offset, length)
|
|
}
|
|
|
|
function ucs2Write (buf, string, offset, length) {
|
|
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
|
|
}
|
|
|
|
Buffer.prototype.write = function write (string, offset, length, encoding) {
|
|
// Buffer#write(string)
|
|
if (offset === undefined) {
|
|
encoding = 'utf8'
|
|
length = this.length
|
|
offset = 0
|
|
// Buffer#write(string, encoding)
|
|
} else if (length === undefined && typeof offset === 'string') {
|
|
encoding = offset
|
|
length = this.length
|
|
offset = 0
|
|
// Buffer#write(string, offset[, length][, encoding])
|
|
} else if (isFinite(offset)) {
|
|
offset = offset | 0
|
|
if (isFinite(length)) {
|
|
length = length | 0
|
|
if (encoding === undefined) encoding = 'utf8'
|
|
} else {
|
|
encoding = length
|
|
length = undefined
|
|
}
|
|
// legacy write(string, encoding, offset, length) - remove in v0.13
|
|
} else {
|
|
throw new Error(
|
|
'Buffer.write(string, encoding, offset[, length]) is no longer supported'
|
|
)
|
|
}
|
|
|
|
var remaining = this.length - offset
|
|
if (length === undefined || length > remaining) length = remaining
|
|
|
|
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
|
|
throw new RangeError('Attempt to write outside buffer bounds')
|
|
}
|
|
|
|
if (!encoding) encoding = 'utf8'
|
|
|
|
var loweredCase = false
|
|
for (;;) {
|
|
switch (encoding) {
|
|
case 'hex':
|
|
return hexWrite(this, string, offset, length)
|
|
|
|
case 'utf8':
|
|
case 'utf-8':
|
|
return utf8Write(this, string, offset, length)
|
|
|
|
case 'ascii':
|
|
return asciiWrite(this, string, offset, length)
|
|
|
|
case 'latin1':
|
|
case 'binary':
|
|
return latin1Write(this, string, offset, length)
|
|
|
|
case 'base64':
|
|
// Warning: maxLength not taken into account in base64Write
|
|
return base64Write(this, string, offset, length)
|
|
|
|
case 'ucs2':
|
|
case 'ucs-2':
|
|
case 'utf16le':
|
|
case 'utf-16le':
|
|
return ucs2Write(this, string, offset, length)
|
|
|
|
default:
|
|
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
|
encoding = ('' + encoding).toLowerCase()
|
|
loweredCase = true
|
|
}
|
|
}
|
|
}
|
|
|
|
Buffer.prototype.toJSON = function toJSON () {
|
|
return {
|
|
type: 'Buffer',
|
|
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
}
|
|
}
|
|
|
|
function base64Slice (buf, start, end) {
|
|
if (start === 0 && end === buf.length) {
|
|
return base64.fromByteArray(buf)
|
|
} else {
|
|
return base64.fromByteArray(buf.slice(start, end))
|
|
}
|
|
}
|
|
|
|
function utf8Slice (buf, start, end) {
|
|
end = Math.min(buf.length, end)
|
|
var res = []
|
|
|
|
var i = start
|
|
while (i < end) {
|
|
var firstByte = buf[i]
|
|
var codePoint = null
|
|
var bytesPerSequence = (firstByte > 0xEF) ? 4
|
|
: (firstByte > 0xDF) ? 3
|
|
: (firstByte > 0xBF) ? 2
|
|
: 1
|
|
|
|
if (i + bytesPerSequence <= end) {
|
|
var secondByte, thirdByte, fourthByte, tempCodePoint
|
|
|
|
switch (bytesPerSequence) {
|
|
case 1:
|
|
if (firstByte < 0x80) {
|
|
codePoint = firstByte
|
|
}
|
|
break
|
|
case 2:
|
|
secondByte = buf[i + 1]
|
|
if ((secondByte & 0xC0) === 0x80) {
|
|
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
|
|
if (tempCodePoint > 0x7F) {
|
|
codePoint = tempCodePoint
|
|
}
|
|
}
|
|
break
|
|
case 3:
|
|
secondByte = buf[i + 1]
|
|
thirdByte = buf[i + 2]
|
|
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
|
|
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
|
|
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
|
|
codePoint = tempCodePoint
|
|
}
|
|
}
|
|
break
|
|
case 4:
|
|
secondByte = buf[i + 1]
|
|
thirdByte = buf[i + 2]
|
|
fourthByte = buf[i + 3]
|
|
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
|
|
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
|
|
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
|
|
codePoint = tempCodePoint
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (codePoint === null) {
|
|
// we did not generate a valid codePoint so insert a
|
|
// replacement char (U+FFFD) and advance only 1 byte
|
|
codePoint = 0xFFFD
|
|
bytesPerSequence = 1
|
|
} else if (codePoint > 0xFFFF) {
|
|
// encode to utf16 (surrogate pair dance)
|
|
codePoint -= 0x10000
|
|
res.push(codePoint >>> 10 & 0x3FF | 0xD800)
|
|
codePoint = 0xDC00 | codePoint & 0x3FF
|
|
}
|
|
|
|
res.push(codePoint)
|
|
i += bytesPerSequence
|
|
}
|
|
|
|
return decodeCodePointsArray(res)
|
|
}
|
|
|
|
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
|
|
// the lowest limit is Chrome, with 0x10000 args.
|
|
// We go 1 magnitude less, for safety
|
|
var MAX_ARGUMENTS_LENGTH = 0x1000
|
|
|
|
function decodeCodePointsArray (codePoints) {
|
|
var len = codePoints.length
|
|
if (len <= MAX_ARGUMENTS_LENGTH) {
|
|
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
|
|
}
|
|
|
|
// Decode in chunks to avoid "call stack size exceeded".
|
|
var res = ''
|
|
var i = 0
|
|
while (i < len) {
|
|
res += String.fromCharCode.apply(
|
|
String,
|
|
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
|
)
|
|
}
|
|
return res
|
|
}
|
|
|
|
function asciiSlice (buf, start, end) {
|
|
var ret = ''
|
|
end = Math.min(buf.length, end)
|
|
|
|
for (var i = start; i < end; ++i) {
|
|
ret += String.fromCharCode(buf[i] & 0x7F)
|
|
}
|
|
return ret
|
|
}
|
|
|
|
function latin1Slice (buf, start, end) {
|
|
var ret = ''
|
|
end = Math.min(buf.length, end)
|
|
|
|
for (var i = start; i < end; ++i) {
|
|
ret += String.fromCharCode(buf[i])
|
|
}
|
|
return ret
|
|
}
|
|
|
|
function hexSlice (buf, start, end) {
|
|
var len = buf.length
|
|
|
|
if (!start || start < 0) start = 0
|
|
if (!end || end < 0 || end > len) end = len
|
|
|
|
var out = ''
|
|
for (var i = start; i < end; ++i) {
|
|
out += toHex(buf[i])
|
|
}
|
|
return out
|
|
}
|
|
|
|
function utf16leSlice (buf, start, end) {
|
|
var bytes = buf.slice(start, end)
|
|
var res = ''
|
|
for (var i = 0; i < bytes.length; i += 2) {
|
|
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
|
|
}
|
|
return res
|
|
}
|
|
|
|
Buffer.prototype.slice = function slice (start, end) {
|
|
var len = this.length
|
|
start = ~~start
|
|
end = end === undefined ? len : ~~end
|
|
|
|
if (start < 0) {
|
|
start += len
|
|
if (start < 0) start = 0
|
|
} else if (start > len) {
|
|
start = len
|
|
}
|
|
|
|
if (end < 0) {
|
|
end += len
|
|
if (end < 0) end = 0
|
|
} else if (end > len) {
|
|
end = len
|
|
}
|
|
|
|
if (end < start) end = start
|
|
|
|
var newBuf
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
newBuf = this.subarray(start, end)
|
|
newBuf.__proto__ = Buffer.prototype
|
|
} else {
|
|
var sliceLen = end - start
|
|
newBuf = new Buffer(sliceLen, undefined)
|
|
for (var i = 0; i < sliceLen; ++i) {
|
|
newBuf[i] = this[i + start]
|
|
}
|
|
}
|
|
|
|
return newBuf
|
|
}
|
|
|
|
/*
|
|
* Need to make sure that buffer isn't trying to write out of bounds.
|
|
*/
|
|
function checkOffset (offset, ext, length) {
|
|
if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
|
|
if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
|
|
}
|
|
|
|
Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
|
|
offset = offset | 0
|
|
byteLength = byteLength | 0
|
|
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
|
|
|
var val = this[offset]
|
|
var mul = 1
|
|
var i = 0
|
|
while (++i < byteLength && (mul *= 0x100)) {
|
|
val += this[offset + i] * mul
|
|
}
|
|
|
|
return val
|
|
}
|
|
|
|
Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
|
|
offset = offset | 0
|
|
byteLength = byteLength | 0
|
|
if (!noAssert) {
|
|
checkOffset(offset, byteLength, this.length)
|
|
}
|
|
|
|
var val = this[offset + --byteLength]
|
|
var mul = 1
|
|
while (byteLength > 0 && (mul *= 0x100)) {
|
|
val += this[offset + --byteLength] * mul
|
|
}
|
|
|
|
return val
|
|
}
|
|
|
|
Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
|
|
if (!noAssert) checkOffset(offset, 1, this.length)
|
|
return this[offset]
|
|
}
|
|
|
|
Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
|
|
if (!noAssert) checkOffset(offset, 2, this.length)
|
|
return this[offset] | (this[offset + 1] << 8)
|
|
}
|
|
|
|
Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
|
|
if (!noAssert) checkOffset(offset, 2, this.length)
|
|
return (this[offset] << 8) | this[offset + 1]
|
|
}
|
|
|
|
Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
|
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
|
|
return ((this[offset]) |
|
|
(this[offset + 1] << 8) |
|
|
(this[offset + 2] << 16)) +
|
|
(this[offset + 3] * 0x1000000)
|
|
}
|
|
|
|
Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
|
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
|
|
return (this[offset] * 0x1000000) +
|
|
((this[offset + 1] << 16) |
|
|
(this[offset + 2] << 8) |
|
|
this[offset + 3])
|
|
}
|
|
|
|
Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
|
|
offset = offset | 0
|
|
byteLength = byteLength | 0
|
|
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
|
|
|
var val = this[offset]
|
|
var mul = 1
|
|
var i = 0
|
|
while (++i < byteLength && (mul *= 0x100)) {
|
|
val += this[offset + i] * mul
|
|
}
|
|
mul *= 0x80
|
|
|
|
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
|
|
|
return val
|
|
}
|
|
|
|
Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
|
|
offset = offset | 0
|
|
byteLength = byteLength | 0
|
|
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
|
|
|
var i = byteLength
|
|
var mul = 1
|
|
var val = this[offset + --i]
|
|
while (i > 0 && (mul *= 0x100)) {
|
|
val += this[offset + --i] * mul
|
|
}
|
|
mul *= 0x80
|
|
|
|
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
|
|
|
return val
|
|
}
|
|
|
|
Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
|
|
if (!noAssert) checkOffset(offset, 1, this.length)
|
|
if (!(this[offset] & 0x80)) return (this[offset])
|
|
return ((0xff - this[offset] + 1) * -1)
|
|
}
|
|
|
|
Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
|
|
if (!noAssert) checkOffset(offset, 2, this.length)
|
|
var val = this[offset] | (this[offset + 1] << 8)
|
|
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
}
|
|
|
|
Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
|
|
if (!noAssert) checkOffset(offset, 2, this.length)
|
|
var val = this[offset + 1] | (this[offset] << 8)
|
|
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
}
|
|
|
|
Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
|
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
|
|
return (this[offset]) |
|
|
(this[offset + 1] << 8) |
|
|
(this[offset + 2] << 16) |
|
|
(this[offset + 3] << 24)
|
|
}
|
|
|
|
Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
|
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
|
|
return (this[offset] << 24) |
|
|
(this[offset + 1] << 16) |
|
|
(this[offset + 2] << 8) |
|
|
(this[offset + 3])
|
|
}
|
|
|
|
Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
|
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
return ieee754.read(this, offset, true, 23, 4)
|
|
}
|
|
|
|
Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
|
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
return ieee754.read(this, offset, false, 23, 4)
|
|
}
|
|
|
|
Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
|
|
if (!noAssert) checkOffset(offset, 8, this.length)
|
|
return ieee754.read(this, offset, true, 52, 8)
|
|
}
|
|
|
|
Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
|
|
if (!noAssert) checkOffset(offset, 8, this.length)
|
|
return ieee754.read(this, offset, false, 52, 8)
|
|
}
|
|
|
|
function checkInt (buf, value, offset, ext, max, min) {
|
|
if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
|
|
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
|
|
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
|
}
|
|
|
|
Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
|
|
value = +value
|
|
offset = offset | 0
|
|
byteLength = byteLength | 0
|
|
if (!noAssert) {
|
|
var maxBytes = Math.pow(2, 8 * byteLength) - 1
|
|
checkInt(this, value, offset, byteLength, maxBytes, 0)
|
|
}
|
|
|
|
var mul = 1
|
|
var i = 0
|
|
this[offset] = value & 0xFF
|
|
while (++i < byteLength && (mul *= 0x100)) {
|
|
this[offset + i] = (value / mul) & 0xFF
|
|
}
|
|
|
|
return offset + byteLength
|
|
}
|
|
|
|
Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
|
|
value = +value
|
|
offset = offset | 0
|
|
byteLength = byteLength | 0
|
|
if (!noAssert) {
|
|
var maxBytes = Math.pow(2, 8 * byteLength) - 1
|
|
checkInt(this, value, offset, byteLength, maxBytes, 0)
|
|
}
|
|
|
|
var i = byteLength - 1
|
|
var mul = 1
|
|
this[offset + i] = value & 0xFF
|
|
while (--i >= 0 && (mul *= 0x100)) {
|
|
this[offset + i] = (value / mul) & 0xFF
|
|
}
|
|
|
|
return offset + byteLength
|
|
}
|
|
|
|
Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
|
|
value = +value
|
|
offset = offset | 0
|
|
if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
|
|
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
|
this[offset] = (value & 0xff)
|
|
return offset + 1
|
|
}
|
|
|
|
function objectWriteUInt16 (buf, value, offset, littleEndian) {
|
|
if (value < 0) value = 0xffff + value + 1
|
|
for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
|
|
buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
|
|
(littleEndian ? i : 1 - i) * 8
|
|
}
|
|
}
|
|
|
|
Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
|
|
value = +value
|
|
offset = offset | 0
|
|
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
this[offset] = (value & 0xff)
|
|
this[offset + 1] = (value >>> 8)
|
|
} else {
|
|
objectWriteUInt16(this, value, offset, true)
|
|
}
|
|
return offset + 2
|
|
}
|
|
|
|
Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
|
|
value = +value
|
|
offset = offset | 0
|
|
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
this[offset] = (value >>> 8)
|
|
this[offset + 1] = (value & 0xff)
|
|
} else {
|
|
objectWriteUInt16(this, value, offset, false)
|
|
}
|
|
return offset + 2
|
|
}
|
|
|
|
function objectWriteUInt32 (buf, value, offset, littleEndian) {
|
|
if (value < 0) value = 0xffffffff + value + 1
|
|
for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
|
|
buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
|
|
}
|
|
}
|
|
|
|
Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
|
|
value = +value
|
|
offset = offset | 0
|
|
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
this[offset + 3] = (value >>> 24)
|
|
this[offset + 2] = (value >>> 16)
|
|
this[offset + 1] = (value >>> 8)
|
|
this[offset] = (value & 0xff)
|
|
} else {
|
|
objectWriteUInt32(this, value, offset, true)
|
|
}
|
|
return offset + 4
|
|
}
|
|
|
|
Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
|
|
value = +value
|
|
offset = offset | 0
|
|
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
this[offset] = (value >>> 24)
|
|
this[offset + 1] = (value >>> 16)
|
|
this[offset + 2] = (value >>> 8)
|
|
this[offset + 3] = (value & 0xff)
|
|
} else {
|
|
objectWriteUInt32(this, value, offset, false)
|
|
}
|
|
return offset + 4
|
|
}
|
|
|
|
Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
|
|
value = +value
|
|
offset = offset | 0
|
|
if (!noAssert) {
|
|
var limit = Math.pow(2, 8 * byteLength - 1)
|
|
|
|
checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
|
}
|
|
|
|
var i = 0
|
|
var mul = 1
|
|
var sub = 0
|
|
this[offset] = value & 0xFF
|
|
while (++i < byteLength && (mul *= 0x100)) {
|
|
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
|
sub = 1
|
|
}
|
|
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
|
}
|
|
|
|
return offset + byteLength
|
|
}
|
|
|
|
Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
|
|
value = +value
|
|
offset = offset | 0
|
|
if (!noAssert) {
|
|
var limit = Math.pow(2, 8 * byteLength - 1)
|
|
|
|
checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
|
}
|
|
|
|
var i = byteLength - 1
|
|
var mul = 1
|
|
var sub = 0
|
|
this[offset + i] = value & 0xFF
|
|
while (--i >= 0 && (mul *= 0x100)) {
|
|
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
|
sub = 1
|
|
}
|
|
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
|
}
|
|
|
|
return offset + byteLength
|
|
}
|
|
|
|
Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
|
|
value = +value
|
|
offset = offset | 0
|
|
if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
|
|
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
|
if (value < 0) value = 0xff + value + 1
|
|
this[offset] = (value & 0xff)
|
|
return offset + 1
|
|
}
|
|
|
|
Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
|
|
value = +value
|
|
offset = offset | 0
|
|
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
this[offset] = (value & 0xff)
|
|
this[offset + 1] = (value >>> 8)
|
|
} else {
|
|
objectWriteUInt16(this, value, offset, true)
|
|
}
|
|
return offset + 2
|
|
}
|
|
|
|
Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
|
|
value = +value
|
|
offset = offset | 0
|
|
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
this[offset] = (value >>> 8)
|
|
this[offset + 1] = (value & 0xff)
|
|
} else {
|
|
objectWriteUInt16(this, value, offset, false)
|
|
}
|
|
return offset + 2
|
|
}
|
|
|
|
Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
|
|
value = +value
|
|
offset = offset | 0
|
|
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
this[offset] = (value & 0xff)
|
|
this[offset + 1] = (value >>> 8)
|
|
this[offset + 2] = (value >>> 16)
|
|
this[offset + 3] = (value >>> 24)
|
|
} else {
|
|
objectWriteUInt32(this, value, offset, true)
|
|
}
|
|
return offset + 4
|
|
}
|
|
|
|
Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
|
|
value = +value
|
|
offset = offset | 0
|
|
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
|
if (value < 0) value = 0xffffffff + value + 1
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
this[offset] = (value >>> 24)
|
|
this[offset + 1] = (value >>> 16)
|
|
this[offset + 2] = (value >>> 8)
|
|
this[offset + 3] = (value & 0xff)
|
|
} else {
|
|
objectWriteUInt32(this, value, offset, false)
|
|
}
|
|
return offset + 4
|
|
}
|
|
|
|
function checkIEEE754 (buf, value, offset, ext, max, min) {
|
|
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
|
if (offset < 0) throw new RangeError('Index out of range')
|
|
}
|
|
|
|
function writeFloat (buf, value, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
|
|
}
|
|
ieee754.write(buf, value, offset, littleEndian, 23, 4)
|
|
return offset + 4
|
|
}
|
|
|
|
Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
|
|
return writeFloat(this, value, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
|
|
return writeFloat(this, value, offset, false, noAssert)
|
|
}
|
|
|
|
function writeDouble (buf, value, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
|
|
}
|
|
ieee754.write(buf, value, offset, littleEndian, 52, 8)
|
|
return offset + 8
|
|
}
|
|
|
|
Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
|
|
return writeDouble(this, value, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
|
|
return writeDouble(this, value, offset, false, noAssert)
|
|
}
|
|
|
|
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
|
|
Buffer.prototype.copy = function copy (target, targetStart, start, end) {
|
|
if (!start) start = 0
|
|
if (!end && end !== 0) end = this.length
|
|
if (targetStart >= target.length) targetStart = target.length
|
|
if (!targetStart) targetStart = 0
|
|
if (end > 0 && end < start) end = start
|
|
|
|
// Copy 0 bytes; we're done
|
|
if (end === start) return 0
|
|
if (target.length === 0 || this.length === 0) return 0
|
|
|
|
// Fatal error conditions
|
|
if (targetStart < 0) {
|
|
throw new RangeError('targetStart out of bounds')
|
|
}
|
|
if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
|
|
if (end < 0) throw new RangeError('sourceEnd out of bounds')
|
|
|
|
// Are we oob?
|
|
if (end > this.length) end = this.length
|
|
if (target.length - targetStart < end - start) {
|
|
end = target.length - targetStart + start
|
|
}
|
|
|
|
var len = end - start
|
|
var i
|
|
|
|
if (this === target && start < targetStart && targetStart < end) {
|
|
// descending copy from end
|
|
for (i = len - 1; i >= 0; --i) {
|
|
target[i + targetStart] = this[i + start]
|
|
}
|
|
} else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
|
|
// ascending copy from start
|
|
for (i = 0; i < len; ++i) {
|
|
target[i + targetStart] = this[i + start]
|
|
}
|
|
} else {
|
|
Uint8Array.prototype.set.call(
|
|
target,
|
|
this.subarray(start, start + len),
|
|
targetStart
|
|
)
|
|
}
|
|
|
|
return len
|
|
}
|
|
|
|
// Usage:
|
|
// buffer.fill(number[, offset[, end]])
|
|
// buffer.fill(buffer[, offset[, end]])
|
|
// buffer.fill(string[, offset[, end]][, encoding])
|
|
Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
|
// Handle string cases:
|
|
if (typeof val === 'string') {
|
|
if (typeof start === 'string') {
|
|
encoding = start
|
|
start = 0
|
|
end = this.length
|
|
} else if (typeof end === 'string') {
|
|
encoding = end
|
|
end = this.length
|
|
}
|
|
if (val.length === 1) {
|
|
var code = val.charCodeAt(0)
|
|
if (code < 256) {
|
|
val = code
|
|
}
|
|
}
|
|
if (encoding !== undefined && typeof encoding !== 'string') {
|
|
throw new TypeError('encoding must be a string')
|
|
}
|
|
if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
|
|
throw new TypeError('Unknown encoding: ' + encoding)
|
|
}
|
|
} else if (typeof val === 'number') {
|
|
val = val & 255
|
|
}
|
|
|
|
// Invalid ranges are not set to a default, so can range check early.
|
|
if (start < 0 || this.length < start || this.length < end) {
|
|
throw new RangeError('Out of range index')
|
|
}
|
|
|
|
if (end <= start) {
|
|
return this
|
|
}
|
|
|
|
start = start >>> 0
|
|
end = end === undefined ? this.length : end >>> 0
|
|
|
|
if (!val) val = 0
|
|
|
|
var i
|
|
if (typeof val === 'number') {
|
|
for (i = start; i < end; ++i) {
|
|
this[i] = val
|
|
}
|
|
} else {
|
|
var bytes = Buffer.isBuffer(val)
|
|
? val
|
|
: utf8ToBytes(new Buffer(val, encoding).toString())
|
|
var len = bytes.length
|
|
for (i = 0; i < end - start; ++i) {
|
|
this[i + start] = bytes[i % len]
|
|
}
|
|
}
|
|
|
|
return this
|
|
}
|
|
|
|
// HELPER FUNCTIONS
|
|
// ================
|
|
|
|
var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
|
|
|
|
function base64clean (str) {
|
|
// Node strips out invalid characters like \n and \t from the string, base64-js does not
|
|
str = stringtrim(str).replace(INVALID_BASE64_RE, '')
|
|
// Node converts strings with length < 2 to ''
|
|
if (str.length < 2) return ''
|
|
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
|
|
while (str.length % 4 !== 0) {
|
|
str = str + '='
|
|
}
|
|
return str
|
|
}
|
|
|
|
function stringtrim (str) {
|
|
if (str.trim) return str.trim()
|
|
return str.replace(/^\s+|\s+$/g, '')
|
|
}
|
|
|
|
function toHex (n) {
|
|
if (n < 16) return '0' + n.toString(16)
|
|
return n.toString(16)
|
|
}
|
|
|
|
function utf8ToBytes (string, units) {
|
|
units = units || Infinity
|
|
var codePoint
|
|
var length = string.length
|
|
var leadSurrogate = null
|
|
var bytes = []
|
|
|
|
for (var i = 0; i < length; ++i) {
|
|
codePoint = string.charCodeAt(i)
|
|
|
|
// is surrogate component
|
|
if (codePoint > 0xD7FF && codePoint < 0xE000) {
|
|
// last char was a lead
|
|
if (!leadSurrogate) {
|
|
// no lead yet
|
|
if (codePoint > 0xDBFF) {
|
|
// unexpected trail
|
|
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
|
continue
|
|
} else if (i + 1 === length) {
|
|
// unpaired lead
|
|
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
|
continue
|
|
}
|
|
|
|
// valid lead
|
|
leadSurrogate = codePoint
|
|
|
|
continue
|
|
}
|
|
|
|
// 2 leads in a row
|
|
if (codePoint < 0xDC00) {
|
|
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
|
leadSurrogate = codePoint
|
|
continue
|
|
}
|
|
|
|
// valid surrogate pair
|
|
codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
|
|
} else if (leadSurrogate) {
|
|
// valid bmp char, but last char was a lead
|
|
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
|
}
|
|
|
|
leadSurrogate = null
|
|
|
|
// encode utf8
|
|
if (codePoint < 0x80) {
|
|
if ((units -= 1) < 0) break
|
|
bytes.push(codePoint)
|
|
} else if (codePoint < 0x800) {
|
|
if ((units -= 2) < 0) break
|
|
bytes.push(
|
|
codePoint >> 0x6 | 0xC0,
|
|
codePoint & 0x3F | 0x80
|
|
)
|
|
} else if (codePoint < 0x10000) {
|
|
if ((units -= 3) < 0) break
|
|
bytes.push(
|
|
codePoint >> 0xC | 0xE0,
|
|
codePoint >> 0x6 & 0x3F | 0x80,
|
|
codePoint & 0x3F | 0x80
|
|
)
|
|
} else if (codePoint < 0x110000) {
|
|
if ((units -= 4) < 0) break
|
|
bytes.push(
|
|
codePoint >> 0x12 | 0xF0,
|
|
codePoint >> 0xC & 0x3F | 0x80,
|
|
codePoint >> 0x6 & 0x3F | 0x80,
|
|
codePoint & 0x3F | 0x80
|
|
)
|
|
} else {
|
|
throw new Error('Invalid code point')
|
|
}
|
|
}
|
|
|
|
return bytes
|
|
}
|
|
|
|
function asciiToBytes (str) {
|
|
var byteArray = []
|
|
for (var i = 0; i < str.length; ++i) {
|
|
// Node's code seems to be doing this and not & 0x7F..
|
|
byteArray.push(str.charCodeAt(i) & 0xFF)
|
|
}
|
|
return byteArray
|
|
}
|
|
|
|
function utf16leToBytes (str, units) {
|
|
var c, hi, lo
|
|
var byteArray = []
|
|
for (var i = 0; i < str.length; ++i) {
|
|
if ((units -= 2) < 0) break
|
|
|
|
c = str.charCodeAt(i)
|
|
hi = c >> 8
|
|
lo = c % 256
|
|
byteArray.push(lo)
|
|
byteArray.push(hi)
|
|
}
|
|
|
|
return byteArray
|
|
}
|
|
|
|
function base64ToBytes (str) {
|
|
return base64.toByteArray(base64clean(str))
|
|
}
|
|
|
|
function blitBuffer (src, dst, offset, length) {
|
|
for (var i = 0; i < length; ++i) {
|
|
if ((i + offset >= dst.length) || (i >= src.length)) break
|
|
dst[i + offset] = src[i]
|
|
}
|
|
return i
|
|
}
|
|
|
|
function isnan (val) {
|
|
return val !== val // eslint-disable-line no-self-compare
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/call-bind/callBound.js":
|
|
/*!*********************************************!*\
|
|
!*** ./node_modules/call-bind/callBound.js ***!
|
|
\*********************************************/
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var GetIntrinsic = __webpack_require__(/*! get-intrinsic */ "./node_modules/get-intrinsic/index.js");
|
|
|
|
var callBind = __webpack_require__(/*! ./ */ "./node_modules/call-bind/index.js");
|
|
|
|
var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf'));
|
|
|
|
module.exports = function callBoundIntrinsic(name, allowMissing) {
|
|
var intrinsic = GetIntrinsic(name, !!allowMissing);
|
|
if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) {
|
|
return callBind(intrinsic);
|
|
}
|
|
return intrinsic;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/call-bind/index.js":
|
|
/*!*****************************************!*\
|
|
!*** ./node_modules/call-bind/index.js ***!
|
|
\*****************************************/
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var bind = __webpack_require__(/*! function-bind */ "./node_modules/function-bind/index.js");
|
|
var GetIntrinsic = __webpack_require__(/*! get-intrinsic */ "./node_modules/get-intrinsic/index.js");
|
|
|
|
var $apply = GetIntrinsic('%Function.prototype.apply%');
|
|
var $call = GetIntrinsic('%Function.prototype.call%');
|
|
var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply);
|
|
|
|
var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true);
|
|
var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
|
|
var $max = GetIntrinsic('%Math.max%');
|
|
|
|
if ($defineProperty) {
|
|
try {
|
|
$defineProperty({}, 'a', { value: 1 });
|
|
} catch (e) {
|
|
// IE 8 has a broken defineProperty
|
|
$defineProperty = null;
|
|
}
|
|
}
|
|
|
|
module.exports = function callBind(originalFunction) {
|
|
var func = $reflectApply(bind, $call, arguments);
|
|
if ($gOPD && $defineProperty) {
|
|
var desc = $gOPD(func, 'length');
|
|
if (desc.configurable) {
|
|
// original length, plus the receiver, minus any additional arguments (after the receiver)
|
|
$defineProperty(
|
|
func,
|
|
'length',
|
|
{ value: 1 + $max(0, originalFunction.length - (arguments.length - 1)) }
|
|
);
|
|
}
|
|
}
|
|
return func;
|
|
};
|
|
|
|
var applyBind = function applyBind() {
|
|
return $reflectApply(bind, $apply, arguments);
|
|
};
|
|
|
|
if ($defineProperty) {
|
|
$defineProperty(module.exports, 'apply', { value: applyBind });
|
|
} else {
|
|
module.exports.apply = applyBind;
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/clone/clone.js":
|
|
/*!*************************************!*\
|
|
!*** ./node_modules/clone/clone.js ***!
|
|
\*************************************/
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
/* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "./node_modules/buffer/index.js")["Buffer"];
|
|
var clone = (function() {
|
|
'use strict';
|
|
|
|
function _instanceof(obj, type) {
|
|
return type != null && obj instanceof type;
|
|
}
|
|
|
|
var nativeMap;
|
|
try {
|
|
nativeMap = Map;
|
|
} catch(_) {
|
|
// maybe a reference error because no `Map`. Give it a dummy value that no
|
|
// value will ever be an instanceof.
|
|
nativeMap = function() {};
|
|
}
|
|
|
|
var nativeSet;
|
|
try {
|
|
nativeSet = Set;
|
|
} catch(_) {
|
|
nativeSet = function() {};
|
|
}
|
|
|
|
var nativePromise;
|
|
try {
|
|
nativePromise = Promise;
|
|
} catch(_) {
|
|
nativePromise = function() {};
|
|
}
|
|
|
|
/**
|
|
* Clones (copies) an Object using deep copying.
|
|
*
|
|
* This function supports circular references by default, but if you are certain
|
|
* there are no circular references in your object, you can save some CPU time
|
|
* by calling clone(obj, false).
|
|
*
|
|
* Caution: if `circular` is false and `parent` contains circular references,
|
|
* your program may enter an infinite loop and crash.
|
|
*
|
|
* @param `parent` - the object to be cloned
|
|
* @param `circular` - set to true if the object to be cloned may contain
|
|
* circular references. (optional - true by default)
|
|
* @param `depth` - set to a number if the object is only to be cloned to
|
|
* a particular depth. (optional - defaults to Infinity)
|
|
* @param `prototype` - sets the prototype to be used when cloning an object.
|
|
* (optional - defaults to parent prototype).
|
|
* @param `includeNonEnumerable` - set to true if the non-enumerable properties
|
|
* should be cloned as well. Non-enumerable properties on the prototype
|
|
* chain will be ignored. (optional - false by default)
|
|
*/
|
|
function clone(parent, circular, depth, prototype, includeNonEnumerable) {
|
|
if (typeof circular === 'object') {
|
|
depth = circular.depth;
|
|
prototype = circular.prototype;
|
|
includeNonEnumerable = circular.includeNonEnumerable;
|
|
circular = circular.circular;
|
|
}
|
|
// maintain two arrays for circular references, where corresponding parents
|
|
// and children have the same index
|
|
var allParents = [];
|
|
var allChildren = [];
|
|
|
|
var useBuffer = typeof Buffer != 'undefined';
|
|
|
|
if (typeof circular == 'undefined')
|
|
circular = true;
|
|
|
|
if (typeof depth == 'undefined')
|
|
depth = Infinity;
|
|
|
|
// recurse this function so we don't reset allParents and allChildren
|
|
function _clone(parent, depth) {
|
|
// cloning null always returns null
|
|
if (parent === null)
|
|
return null;
|
|
|
|
if (depth === 0)
|
|
return parent;
|
|
|
|
var child;
|
|
var proto;
|
|
if (typeof parent != 'object') {
|
|
return parent;
|
|
}
|
|
|
|
if (_instanceof(parent, nativeMap)) {
|
|
child = new nativeMap();
|
|
} else if (_instanceof(parent, nativeSet)) {
|
|
child = new nativeSet();
|
|
} else if (_instanceof(parent, nativePromise)) {
|
|
child = new nativePromise(function (resolve, reject) {
|
|
parent.then(function(value) {
|
|
resolve(_clone(value, depth - 1));
|
|
}, function(err) {
|
|
reject(_clone(err, depth - 1));
|
|
});
|
|
});
|
|
} else if (clone.__isArray(parent)) {
|
|
child = [];
|
|
} else if (clone.__isRegExp(parent)) {
|
|
child = new RegExp(parent.source, __getRegExpFlags(parent));
|
|
if (parent.lastIndex) child.lastIndex = parent.lastIndex;
|
|
} else if (clone.__isDate(parent)) {
|
|
child = new Date(parent.getTime());
|
|
} else if (useBuffer && Buffer.isBuffer(parent)) {
|
|
if (Buffer.allocUnsafe) {
|
|
// Node.js >= 4.5.0
|
|
child = Buffer.allocUnsafe(parent.length);
|
|
} else {
|
|
// Older Node.js versions
|
|
child = new Buffer(parent.length);
|
|
}
|
|
parent.copy(child);
|
|
return child;
|
|
} else if (_instanceof(parent, Error)) {
|
|
child = Object.create(parent);
|
|
} else {
|
|
if (typeof prototype == 'undefined') {
|
|
proto = Object.getPrototypeOf(parent);
|
|
child = Object.create(proto);
|
|
}
|
|
else {
|
|
child = Object.create(prototype);
|
|
proto = prototype;
|
|
}
|
|
}
|
|
|
|
if (circular) {
|
|
var index = allParents.indexOf(parent);
|
|
|
|
if (index != -1) {
|
|
return allChildren[index];
|
|
}
|
|
allParents.push(parent);
|
|
allChildren.push(child);
|
|
}
|
|
|
|
if (_instanceof(parent, nativeMap)) {
|
|
parent.forEach(function(value, key) {
|
|
var keyChild = _clone(key, depth - 1);
|
|
var valueChild = _clone(value, depth - 1);
|
|
child.set(keyChild, valueChild);
|
|
});
|
|
}
|
|
if (_instanceof(parent, nativeSet)) {
|
|
parent.forEach(function(value) {
|
|
var entryChild = _clone(value, depth - 1);
|
|
child.add(entryChild);
|
|
});
|
|
}
|
|
|
|
for (var i in parent) {
|
|
var attrs;
|
|
if (proto) {
|
|
attrs = Object.getOwnPropertyDescriptor(proto, i);
|
|
}
|
|
|
|
if (attrs && attrs.set == null) {
|
|
continue;
|
|
}
|
|
child[i] = _clone(parent[i], depth - 1);
|
|
}
|
|
|
|
if (Object.getOwnPropertySymbols) {
|
|
var symbols = Object.getOwnPropertySymbols(parent);
|
|
for (var i = 0; i < symbols.length; i++) {
|
|
// Don't need to worry about cloning a symbol because it is a primitive,
|
|
// like a number or string.
|
|
var symbol = symbols[i];
|
|
var descriptor = Object.getOwnPropertyDescriptor(parent, symbol);
|
|
if (descriptor && !descriptor.enumerable && !includeNonEnumerable) {
|
|
continue;
|
|
}
|
|
child[symbol] = _clone(parent[symbol], depth - 1);
|
|
if (!descriptor.enumerable) {
|
|
Object.defineProperty(child, symbol, {
|
|
enumerable: false
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
if (includeNonEnumerable) {
|
|
var allPropertyNames = Object.getOwnPropertyNames(parent);
|
|
for (var i = 0; i < allPropertyNames.length; i++) {
|
|
var propertyName = allPropertyNames[i];
|
|
var descriptor = Object.getOwnPropertyDescriptor(parent, propertyName);
|
|
if (descriptor && descriptor.enumerable) {
|
|
continue;
|
|
}
|
|
child[propertyName] = _clone(parent[propertyName], depth - 1);
|
|
Object.defineProperty(child, propertyName, {
|
|
enumerable: false
|
|
});
|
|
}
|
|
}
|
|
|
|
return child;
|
|
}
|
|
|
|
return _clone(parent, depth);
|
|
}
|
|
|
|
/**
|
|
* Simple flat clone using prototype, accepts only objects, usefull for property
|
|
* override on FLAT configuration object (no nested props).
|
|
*
|
|
* USE WITH CAUTION! This may not behave as you wish if you do not know how this
|
|
* works.
|
|
*/
|
|
clone.clonePrototype = function clonePrototype(parent) {
|
|
if (parent === null)
|
|
return null;
|
|
|
|
var c = function () {};
|
|
c.prototype = parent;
|
|
return new c();
|
|
};
|
|
|
|
// private utility functions
|
|
|
|
function __objToStr(o) {
|
|
return Object.prototype.toString.call(o);
|
|
}
|
|
clone.__objToStr = __objToStr;
|
|
|
|
function __isDate(o) {
|
|
return typeof o === 'object' && __objToStr(o) === '[object Date]';
|
|
}
|
|
clone.__isDate = __isDate;
|
|
|
|
function __isArray(o) {
|
|
return typeof o === 'object' && __objToStr(o) === '[object Array]';
|
|
}
|
|
clone.__isArray = __isArray;
|
|
|
|
function __isRegExp(o) {
|
|
return typeof o === 'object' && __objToStr(o) === '[object RegExp]';
|
|
}
|
|
clone.__isRegExp = __isRegExp;
|
|
|
|
function __getRegExpFlags(re) {
|
|
var flags = '';
|
|
if (re.global) flags += 'g';
|
|
if (re.ignoreCase) flags += 'i';
|
|
if (re.multiline) flags += 'm';
|
|
return flags;
|
|
}
|
|
clone.__getRegExpFlags = __getRegExpFlags;
|
|
|
|
return clone;
|
|
})();
|
|
|
|
if ( true && module.exports) {
|
|
module.exports = clone;
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/deep-equal/index.js":
|
|
/*!******************************************!*\
|
|
!*** ./node_modules/deep-equal/index.js ***!
|
|
\******************************************/
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
var objectKeys = __webpack_require__(/*! object-keys */ "./node_modules/object-keys/index.js");
|
|
var isArguments = __webpack_require__(/*! is-arguments */ "./node_modules/is-arguments/index.js");
|
|
var is = __webpack_require__(/*! object-is */ "./node_modules/object-is/index.js");
|
|
var isRegex = __webpack_require__(/*! is-regex */ "./node_modules/is-regex/index.js");
|
|
var flags = __webpack_require__(/*! regexp.prototype.flags */ "./node_modules/regexp.prototype.flags/index.js");
|
|
var isDate = __webpack_require__(/*! is-date-object */ "./node_modules/is-date-object/index.js");
|
|
|
|
var getTime = Date.prototype.getTime;
|
|
|
|
function deepEqual(actual, expected, options) {
|
|
var opts = options || {};
|
|
|
|
// 7.1. All identical values are equivalent, as determined by ===.
|
|
if (opts.strict ? is(actual, expected) : actual === expected) {
|
|
return true;
|
|
}
|
|
|
|
// 7.3. Other pairs that do not both pass typeof value == 'object', equivalence is determined by ==.
|
|
if (!actual || !expected || (typeof actual !== 'object' && typeof expected !== 'object')) {
|
|
return opts.strict ? is(actual, expected) : actual == expected;
|
|
}
|
|
|
|
/*
|
|
* 7.4. For all other Object pairs, including Array objects, equivalence is
|
|
* determined by having the same number of owned properties (as verified
|
|
* with Object.prototype.hasOwnProperty.call), the same set of keys
|
|
* (although not necessarily the same order), equivalent values for every
|
|
* corresponding key, and an identical 'prototype' property. Note: this
|
|
* accounts for both named and indexed properties on Arrays.
|
|
*/
|
|
// eslint-disable-next-line no-use-before-define
|
|
return objEquiv(actual, expected, opts);
|
|
}
|
|
|
|
function isUndefinedOrNull(value) {
|
|
return value === null || value === undefined;
|
|
}
|
|
|
|
function isBuffer(x) {
|
|
if (!x || typeof x !== 'object' || typeof x.length !== 'number') {
|
|
return false;
|
|
}
|
|
if (typeof x.copy !== 'function' || typeof x.slice !== 'function') {
|
|
return false;
|
|
}
|
|
if (x.length > 0 && typeof x[0] !== 'number') {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
function objEquiv(a, b, opts) {
|
|
/* eslint max-statements: [2, 50] */
|
|
var i, key;
|
|
if (typeof a !== typeof b) { return false; }
|
|
if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) { return false; }
|
|
|
|
// an identical 'prototype' property.
|
|
if (a.prototype !== b.prototype) { return false; }
|
|
|
|
if (isArguments(a) !== isArguments(b)) { return false; }
|
|
|
|
var aIsRegex = isRegex(a);
|
|
var bIsRegex = isRegex(b);
|
|
if (aIsRegex !== bIsRegex) { return false; }
|
|
if (aIsRegex || bIsRegex) {
|
|
return a.source === b.source && flags(a) === flags(b);
|
|
}
|
|
|
|
if (isDate(a) && isDate(b)) {
|
|
return getTime.call(a) === getTime.call(b);
|
|
}
|
|
|
|
var aIsBuffer = isBuffer(a);
|
|
var bIsBuffer = isBuffer(b);
|
|
if (aIsBuffer !== bIsBuffer) { return false; }
|
|
if (aIsBuffer || bIsBuffer) { // && would work too, because both are true or both false here
|
|
if (a.length !== b.length) { return false; }
|
|
for (i = 0; i < a.length; i++) {
|
|
if (a[i] !== b[i]) { return false; }
|
|
}
|
|
return true;
|
|
}
|
|
|
|
if (typeof a !== typeof b) { return false; }
|
|
|
|
try {
|
|
var ka = objectKeys(a);
|
|
var kb = objectKeys(b);
|
|
} catch (e) { // happens when one is a string literal and the other isn't
|
|
return false;
|
|
}
|
|
// having the same number of owned properties (keys incorporates hasOwnProperty)
|
|
if (ka.length !== kb.length) { return false; }
|
|
|
|
// the same set of keys (although not necessarily the same order),
|
|
ka.sort();
|
|
kb.sort();
|
|
// ~~~cheap key test
|
|
for (i = ka.length - 1; i >= 0; i--) {
|
|
if (ka[i] != kb[i]) { return false; }
|
|
}
|
|
// equivalent values for every corresponding key, and ~~~possibly expensive deep test
|
|
for (i = ka.length - 1; i >= 0; i--) {
|
|
key = ka[i];
|
|
if (!deepEqual(a[key], b[key], opts)) { return false; }
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
module.exports = deepEqual;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/define-properties/index.js":
|
|
/*!*************************************************!*\
|
|
!*** ./node_modules/define-properties/index.js ***!
|
|
\*************************************************/
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var keys = __webpack_require__(/*! object-keys */ "./node_modules/object-keys/index.js");
|
|
var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol';
|
|
|
|
var toStr = Object.prototype.toString;
|
|
var concat = Array.prototype.concat;
|
|
var origDefineProperty = Object.defineProperty;
|
|
|
|
var isFunction = function (fn) {
|
|
return typeof fn === 'function' && toStr.call(fn) === '[object Function]';
|
|
};
|
|
|
|
var arePropertyDescriptorsSupported = function () {
|
|
var obj = {};
|
|
try {
|
|
origDefineProperty(obj, 'x', { enumerable: false, value: obj });
|
|
// eslint-disable-next-line no-unused-vars, no-restricted-syntax
|
|
for (var _ in obj) { // jscs:ignore disallowUnusedVariables
|
|
return false;
|
|
}
|
|
return obj.x === obj;
|
|
} catch (e) { /* this is IE 8. */
|
|
return false;
|
|
}
|
|
};
|
|
var supportsDescriptors = origDefineProperty && arePropertyDescriptorsSupported();
|
|
|
|
var defineProperty = function (object, name, value, predicate) {
|
|
if (name in object && (!isFunction(predicate) || !predicate())) {
|
|
return;
|
|
}
|
|
if (supportsDescriptors) {
|
|
origDefineProperty(object, name, {
|
|
configurable: true,
|
|
enumerable: false,
|
|
value: value,
|
|
writable: true
|
|
});
|
|
} else {
|
|
object[name] = value;
|
|
}
|
|
};
|
|
|
|
var defineProperties = function (object, map) {
|
|
var predicates = arguments.length > 2 ? arguments[2] : {};
|
|
var props = keys(map);
|
|
if (hasSymbols) {
|
|
props = concat.call(props, Object.getOwnPropertySymbols(map));
|
|
}
|
|
for (var i = 0; i < props.length; i += 1) {
|
|
defineProperty(object, props[i], map[props[i]], predicates[props[i]]);
|
|
}
|
|
};
|
|
|
|
defineProperties.supportsDescriptors = !!supportsDescriptors;
|
|
|
|
module.exports = defineProperties;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/es-abstract/helpers/callBind.js":
|
|
/*!******************************************************!*\
|
|
!*** ./node_modules/es-abstract/helpers/callBind.js ***!
|
|
\******************************************************/
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
// TODO; semver-major: remove
|
|
|
|
module.exports = __webpack_require__(/*! call-bind */ "./node_modules/call-bind/index.js");
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/extend/index.js":
|
|
/*!**************************************!*\
|
|
!*** ./node_modules/extend/index.js ***!
|
|
\**************************************/
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
var toStr = Object.prototype.toString;
|
|
var defineProperty = Object.defineProperty;
|
|
var gOPD = Object.getOwnPropertyDescriptor;
|
|
|
|
var isArray = function isArray(arr) {
|
|
if (typeof Array.isArray === 'function') {
|
|
return Array.isArray(arr);
|
|
}
|
|
|
|
return toStr.call(arr) === '[object Array]';
|
|
};
|
|
|
|
var isPlainObject = function isPlainObject(obj) {
|
|
if (!obj || toStr.call(obj) !== '[object Object]') {
|
|
return false;
|
|
}
|
|
|
|
var hasOwnConstructor = hasOwn.call(obj, 'constructor');
|
|
var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf');
|
|
// Not own constructor property must be Object
|
|
if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
|
|
return false;
|
|
}
|
|
|
|
// Own properties are enumerated firstly, so to speed up,
|
|
// if last one is own, then all properties are own.
|
|
var key;
|
|
for (key in obj) { /**/ }
|
|
|
|
return typeof key === 'undefined' || hasOwn.call(obj, key);
|
|
};
|
|
|
|
// If name is '__proto__', and Object.defineProperty is available, define __proto__ as an own property on target
|
|
var setProperty = function setProperty(target, options) {
|
|
if (defineProperty && options.name === '__proto__') {
|
|
defineProperty(target, options.name, {
|
|
enumerable: true,
|
|
configurable: true,
|
|
value: options.newValue,
|
|
writable: true
|
|
});
|
|
} else {
|
|
target[options.name] = options.newValue;
|
|
}
|
|
};
|
|
|
|
// Return undefined instead of __proto__ if '__proto__' is not an own property
|
|
var getProperty = function getProperty(obj, name) {
|
|
if (name === '__proto__') {
|
|
if (!hasOwn.call(obj, name)) {
|
|
return void 0;
|
|
} else if (gOPD) {
|
|
// In early versions of node, obj['__proto__'] is buggy when obj has
|
|
// __proto__ as an own property. Object.getOwnPropertyDescriptor() works.
|
|
return gOPD(obj, name).value;
|
|
}
|
|
}
|
|
|
|
return obj[name];
|
|
};
|
|
|
|
module.exports = function extend() {
|
|
var options, name, src, copy, copyIsArray, clone;
|
|
var target = arguments[0];
|
|
var i = 1;
|
|
var length = arguments.length;
|
|
var deep = false;
|
|
|
|
// Handle a deep copy situation
|
|
if (typeof target === 'boolean') {
|
|
deep = target;
|
|
target = arguments[1] || {};
|
|
// skip the boolean and the target
|
|
i = 2;
|
|
}
|
|
if (target == null || (typeof target !== 'object' && typeof target !== 'function')) {
|
|
target = {};
|
|
}
|
|
|
|
for (; i < length; ++i) {
|
|
options = arguments[i];
|
|
// Only deal with non-null/undefined values
|
|
if (options != null) {
|
|
// Extend the base object
|
|
for (name in options) {
|
|
src = getProperty(target, name);
|
|
copy = getProperty(options, name);
|
|
|
|
// Prevent never-ending loop
|
|
if (target !== copy) {
|
|
// Recurse if we're merging plain objects or arrays
|
|
if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
|
|
if (copyIsArray) {
|
|
copyIsArray = false;
|
|
clone = src && isArray(src) ? src : [];
|
|
} else {
|
|
clone = src && isPlainObject(src) ? src : {};
|
|
}
|
|
|
|
// Never move original objects, clone them
|
|
setProperty(target, { name: name, newValue: extend(deep, clone, copy) });
|
|
|
|
// Don't bring in undefined values
|
|
} else if (typeof copy !== 'undefined') {
|
|
setProperty(target, { name: name, newValue: copy });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Return the modified object
|
|
return target;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/fast-diff/diff.js":
|
|
/*!****************************************!*\
|
|
!*** ./node_modules/fast-diff/diff.js ***!
|
|
\****************************************/
|
|
/***/ ((module) => {
|
|
|
|
/**
|
|
* This library modifies the diff-patch-match library by Neil Fraser
|
|
* by removing the patch and match functionality and certain advanced
|
|
* options in the diff function. The original license is as follows:
|
|
*
|
|
* ===
|
|
*
|
|
* Diff Match and Patch
|
|
*
|
|
* Copyright 2006 Google Inc.
|
|
* http://code.google.com/p/google-diff-match-patch/
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
|
|
/**
|
|
* The data structure representing a diff is an array of tuples:
|
|
* [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
|
|
* which means: delete 'Hello', add 'Goodbye' and keep ' world.'
|
|
*/
|
|
var DIFF_DELETE = -1;
|
|
var DIFF_INSERT = 1;
|
|
var DIFF_EQUAL = 0;
|
|
|
|
|
|
/**
|
|
* Find the differences between two texts. Simplifies the problem by stripping
|
|
* any common prefix or suffix off the texts before diffing.
|
|
* @param {string} text1 Old string to be diffed.
|
|
* @param {string} text2 New string to be diffed.
|
|
* @param {Int} cursor_pos Expected edit position in text1 (optional)
|
|
* @return {Array} Array of diff tuples.
|
|
*/
|
|
function diff_main(text1, text2, cursor_pos) {
|
|
// Check for equality (speedup).
|
|
if (text1 == text2) {
|
|
if (text1) {
|
|
return [[DIFF_EQUAL, text1]];
|
|
}
|
|
return [];
|
|
}
|
|
|
|
// Check cursor_pos within bounds
|
|
if (cursor_pos < 0 || text1.length < cursor_pos) {
|
|
cursor_pos = null;
|
|
}
|
|
|
|
// Trim off common prefix (speedup).
|
|
var commonlength = diff_commonPrefix(text1, text2);
|
|
var commonprefix = text1.substring(0, commonlength);
|
|
text1 = text1.substring(commonlength);
|
|
text2 = text2.substring(commonlength);
|
|
|
|
// Trim off common suffix (speedup).
|
|
commonlength = diff_commonSuffix(text1, text2);
|
|
var commonsuffix = text1.substring(text1.length - commonlength);
|
|
text1 = text1.substring(0, text1.length - commonlength);
|
|
text2 = text2.substring(0, text2.length - commonlength);
|
|
|
|
// Compute the diff on the middle block.
|
|
var diffs = diff_compute_(text1, text2);
|
|
|
|
// Restore the prefix and suffix.
|
|
if (commonprefix) {
|
|
diffs.unshift([DIFF_EQUAL, commonprefix]);
|
|
}
|
|
if (commonsuffix) {
|
|
diffs.push([DIFF_EQUAL, commonsuffix]);
|
|
}
|
|
diff_cleanupMerge(diffs);
|
|
if (cursor_pos != null) {
|
|
diffs = fix_cursor(diffs, cursor_pos);
|
|
}
|
|
diffs = fix_emoji(diffs);
|
|
return diffs;
|
|
};
|
|
|
|
|
|
/**
|
|
* Find the differences between two texts. Assumes that the texts do not
|
|
* have any common prefix or suffix.
|
|
* @param {string} text1 Old string to be diffed.
|
|
* @param {string} text2 New string to be diffed.
|
|
* @return {Array} Array of diff tuples.
|
|
*/
|
|
function diff_compute_(text1, text2) {
|
|
var diffs;
|
|
|
|
if (!text1) {
|
|
// Just add some text (speedup).
|
|
return [[DIFF_INSERT, text2]];
|
|
}
|
|
|
|
if (!text2) {
|
|
// Just delete some text (speedup).
|
|
return [[DIFF_DELETE, text1]];
|
|
}
|
|
|
|
var longtext = text1.length > text2.length ? text1 : text2;
|
|
var shorttext = text1.length > text2.length ? text2 : text1;
|
|
var i = longtext.indexOf(shorttext);
|
|
if (i != -1) {
|
|
// Shorter text is inside the longer text (speedup).
|
|
diffs = [[DIFF_INSERT, longtext.substring(0, i)],
|
|
[DIFF_EQUAL, shorttext],
|
|
[DIFF_INSERT, longtext.substring(i + shorttext.length)]];
|
|
// Swap insertions for deletions if diff is reversed.
|
|
if (text1.length > text2.length) {
|
|
diffs[0][0] = diffs[2][0] = DIFF_DELETE;
|
|
}
|
|
return diffs;
|
|
}
|
|
|
|
if (shorttext.length == 1) {
|
|
// Single character string.
|
|
// After the previous speedup, the character can't be an equality.
|
|
return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
|
|
}
|
|
|
|
// Check to see if the problem can be split in two.
|
|
var hm = diff_halfMatch_(text1, text2);
|
|
if (hm) {
|
|
// A half-match was found, sort out the return data.
|
|
var text1_a = hm[0];
|
|
var text1_b = hm[1];
|
|
var text2_a = hm[2];
|
|
var text2_b = hm[3];
|
|
var mid_common = hm[4];
|
|
// Send both pairs off for separate processing.
|
|
var diffs_a = diff_main(text1_a, text2_a);
|
|
var diffs_b = diff_main(text1_b, text2_b);
|
|
// Merge the results.
|
|
return diffs_a.concat([[DIFF_EQUAL, mid_common]], diffs_b);
|
|
}
|
|
|
|
return diff_bisect_(text1, text2);
|
|
};
|
|
|
|
|
|
/**
|
|
* Find the 'middle snake' of a diff, split the problem in two
|
|
* and return the recursively constructed diff.
|
|
* See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.
|
|
* @param {string} text1 Old string to be diffed.
|
|
* @param {string} text2 New string to be diffed.
|
|
* @return {Array} Array of diff tuples.
|
|
* @private
|
|
*/
|
|
function diff_bisect_(text1, text2) {
|
|
// Cache the text lengths to prevent multiple calls.
|
|
var text1_length = text1.length;
|
|
var text2_length = text2.length;
|
|
var max_d = Math.ceil((text1_length + text2_length) / 2);
|
|
var v_offset = max_d;
|
|
var v_length = 2 * max_d;
|
|
var v1 = new Array(v_length);
|
|
var v2 = new Array(v_length);
|
|
// Setting all elements to -1 is faster in Chrome & Firefox than mixing
|
|
// integers and undefined.
|
|
for (var x = 0; x < v_length; x++) {
|
|
v1[x] = -1;
|
|
v2[x] = -1;
|
|
}
|
|
v1[v_offset + 1] = 0;
|
|
v2[v_offset + 1] = 0;
|
|
var delta = text1_length - text2_length;
|
|
// If the total number of characters is odd, then the front path will collide
|
|
// with the reverse path.
|
|
var front = (delta % 2 != 0);
|
|
// Offsets for start and end of k loop.
|
|
// Prevents mapping of space beyond the grid.
|
|
var k1start = 0;
|
|
var k1end = 0;
|
|
var k2start = 0;
|
|
var k2end = 0;
|
|
for (var d = 0; d < max_d; d++) {
|
|
// Walk the front path one step.
|
|
for (var k1 = -d + k1start; k1 <= d - k1end; k1 += 2) {
|
|
var k1_offset = v_offset + k1;
|
|
var x1;
|
|
if (k1 == -d || (k1 != d && v1[k1_offset - 1] < v1[k1_offset + 1])) {
|
|
x1 = v1[k1_offset + 1];
|
|
} else {
|
|
x1 = v1[k1_offset - 1] + 1;
|
|
}
|
|
var y1 = x1 - k1;
|
|
while (x1 < text1_length && y1 < text2_length &&
|
|
text1.charAt(x1) == text2.charAt(y1)) {
|
|
x1++;
|
|
y1++;
|
|
}
|
|
v1[k1_offset] = x1;
|
|
if (x1 > text1_length) {
|
|
// Ran off the right of the graph.
|
|
k1end += 2;
|
|
} else if (y1 > text2_length) {
|
|
// Ran off the bottom of the graph.
|
|
k1start += 2;
|
|
} else if (front) {
|
|
var k2_offset = v_offset + delta - k1;
|
|
if (k2_offset >= 0 && k2_offset < v_length && v2[k2_offset] != -1) {
|
|
// Mirror x2 onto top-left coordinate system.
|
|
var x2 = text1_length - v2[k2_offset];
|
|
if (x1 >= x2) {
|
|
// Overlap detected.
|
|
return diff_bisectSplit_(text1, text2, x1, y1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Walk the reverse path one step.
|
|
for (var k2 = -d + k2start; k2 <= d - k2end; k2 += 2) {
|
|
var k2_offset = v_offset + k2;
|
|
var x2;
|
|
if (k2 == -d || (k2 != d && v2[k2_offset - 1] < v2[k2_offset + 1])) {
|
|
x2 = v2[k2_offset + 1];
|
|
} else {
|
|
x2 = v2[k2_offset - 1] + 1;
|
|
}
|
|
var y2 = x2 - k2;
|
|
while (x2 < text1_length && y2 < text2_length &&
|
|
text1.charAt(text1_length - x2 - 1) ==
|
|
text2.charAt(text2_length - y2 - 1)) {
|
|
x2++;
|
|
y2++;
|
|
}
|
|
v2[k2_offset] = x2;
|
|
if (x2 > text1_length) {
|
|
// Ran off the left of the graph.
|
|
k2end += 2;
|
|
} else if (y2 > text2_length) {
|
|
// Ran off the top of the graph.
|
|
k2start += 2;
|
|
} else if (!front) {
|
|
var k1_offset = v_offset + delta - k2;
|
|
if (k1_offset >= 0 && k1_offset < v_length && v1[k1_offset] != -1) {
|
|
var x1 = v1[k1_offset];
|
|
var y1 = v_offset + x1 - k1_offset;
|
|
// Mirror x2 onto top-left coordinate system.
|
|
x2 = text1_length - x2;
|
|
if (x1 >= x2) {
|
|
// Overlap detected.
|
|
return diff_bisectSplit_(text1, text2, x1, y1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// Diff took too long and hit the deadline or
|
|
// number of diffs equals number of characters, no commonality at all.
|
|
return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
|
|
};
|
|
|
|
|
|
/**
|
|
* Given the location of the 'middle snake', split the diff in two parts
|
|
* and recurse.
|
|
* @param {string} text1 Old string to be diffed.
|
|
* @param {string} text2 New string to be diffed.
|
|
* @param {number} x Index of split point in text1.
|
|
* @param {number} y Index of split point in text2.
|
|
* @return {Array} Array of diff tuples.
|
|
*/
|
|
function diff_bisectSplit_(text1, text2, x, y) {
|
|
var text1a = text1.substring(0, x);
|
|
var text2a = text2.substring(0, y);
|
|
var text1b = text1.substring(x);
|
|
var text2b = text2.substring(y);
|
|
|
|
// Compute both diffs serially.
|
|
var diffs = diff_main(text1a, text2a);
|
|
var diffsb = diff_main(text1b, text2b);
|
|
|
|
return diffs.concat(diffsb);
|
|
};
|
|
|
|
|
|
/**
|
|
* Determine the common prefix of two strings.
|
|
* @param {string} text1 First string.
|
|
* @param {string} text2 Second string.
|
|
* @return {number} The number of characters common to the start of each
|
|
* string.
|
|
*/
|
|
function diff_commonPrefix(text1, text2) {
|
|
// Quick check for common null cases.
|
|
if (!text1 || !text2 || text1.charAt(0) != text2.charAt(0)) {
|
|
return 0;
|
|
}
|
|
// Binary search.
|
|
// Performance analysis: http://neil.fraser.name/news/2007/10/09/
|
|
var pointermin = 0;
|
|
var pointermax = Math.min(text1.length, text2.length);
|
|
var pointermid = pointermax;
|
|
var pointerstart = 0;
|
|
while (pointermin < pointermid) {
|
|
if (text1.substring(pointerstart, pointermid) ==
|
|
text2.substring(pointerstart, pointermid)) {
|
|
pointermin = pointermid;
|
|
pointerstart = pointermin;
|
|
} else {
|
|
pointermax = pointermid;
|
|
}
|
|
pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
|
|
}
|
|
return pointermid;
|
|
};
|
|
|
|
|
|
/**
|
|
* Determine the common suffix of two strings.
|
|
* @param {string} text1 First string.
|
|
* @param {string} text2 Second string.
|
|
* @return {number} The number of characters common to the end of each string.
|
|
*/
|
|
function diff_commonSuffix(text1, text2) {
|
|
// Quick check for common null cases.
|
|
if (!text1 || !text2 ||
|
|
text1.charAt(text1.length - 1) != text2.charAt(text2.length - 1)) {
|
|
return 0;
|
|
}
|
|
// Binary search.
|
|
// Performance analysis: http://neil.fraser.name/news/2007/10/09/
|
|
var pointermin = 0;
|
|
var pointermax = Math.min(text1.length, text2.length);
|
|
var pointermid = pointermax;
|
|
var pointerend = 0;
|
|
while (pointermin < pointermid) {
|
|
if (text1.substring(text1.length - pointermid, text1.length - pointerend) ==
|
|
text2.substring(text2.length - pointermid, text2.length - pointerend)) {
|
|
pointermin = pointermid;
|
|
pointerend = pointermin;
|
|
} else {
|
|
pointermax = pointermid;
|
|
}
|
|
pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
|
|
}
|
|
return pointermid;
|
|
};
|
|
|
|
|
|
/**
|
|
* Do the two texts share a substring which is at least half the length of the
|
|
* longer text?
|
|
* This speedup can produce non-minimal diffs.
|
|
* @param {string} text1 First string.
|
|
* @param {string} text2 Second string.
|
|
* @return {Array.<string>} Five element Array, containing the prefix of
|
|
* text1, the suffix of text1, the prefix of text2, the suffix of
|
|
* text2 and the common middle. Or null if there was no match.
|
|
*/
|
|
function diff_halfMatch_(text1, text2) {
|
|
var longtext = text1.length > text2.length ? text1 : text2;
|
|
var shorttext = text1.length > text2.length ? text2 : text1;
|
|
if (longtext.length < 4 || shorttext.length * 2 < longtext.length) {
|
|
return null; // Pointless.
|
|
}
|
|
|
|
/**
|
|
* Does a substring of shorttext exist within longtext such that the substring
|
|
* is at least half the length of longtext?
|
|
* Closure, but does not reference any external variables.
|
|
* @param {string} longtext Longer string.
|
|
* @param {string} shorttext Shorter string.
|
|
* @param {number} i Start index of quarter length substring within longtext.
|
|
* @return {Array.<string>} Five element Array, containing the prefix of
|
|
* longtext, the suffix of longtext, the prefix of shorttext, the suffix
|
|
* of shorttext and the common middle. Or null if there was no match.
|
|
* @private
|
|
*/
|
|
function diff_halfMatchI_(longtext, shorttext, i) {
|
|
// Start with a 1/4 length substring at position i as a seed.
|
|
var seed = longtext.substring(i, i + Math.floor(longtext.length / 4));
|
|
var j = -1;
|
|
var best_common = '';
|
|
var best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b;
|
|
while ((j = shorttext.indexOf(seed, j + 1)) != -1) {
|
|
var prefixLength = diff_commonPrefix(longtext.substring(i),
|
|
shorttext.substring(j));
|
|
var suffixLength = diff_commonSuffix(longtext.substring(0, i),
|
|
shorttext.substring(0, j));
|
|
if (best_common.length < suffixLength + prefixLength) {
|
|
best_common = shorttext.substring(j - suffixLength, j) +
|
|
shorttext.substring(j, j + prefixLength);
|
|
best_longtext_a = longtext.substring(0, i - suffixLength);
|
|
best_longtext_b = longtext.substring(i + prefixLength);
|
|
best_shorttext_a = shorttext.substring(0, j - suffixLength);
|
|
best_shorttext_b = shorttext.substring(j + prefixLength);
|
|
}
|
|
}
|
|
if (best_common.length * 2 >= longtext.length) {
|
|
return [best_longtext_a, best_longtext_b,
|
|
best_shorttext_a, best_shorttext_b, best_common];
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
// First check if the second quarter is the seed for a half-match.
|
|
var hm1 = diff_halfMatchI_(longtext, shorttext,
|
|
Math.ceil(longtext.length / 4));
|
|
// Check again based on the third quarter.
|
|
var hm2 = diff_halfMatchI_(longtext, shorttext,
|
|
Math.ceil(longtext.length / 2));
|
|
var hm;
|
|
if (!hm1 && !hm2) {
|
|
return null;
|
|
} else if (!hm2) {
|
|
hm = hm1;
|
|
} else if (!hm1) {
|
|
hm = hm2;
|
|
} else {
|
|
// Both matched. Select the longest.
|
|
hm = hm1[4].length > hm2[4].length ? hm1 : hm2;
|
|
}
|
|
|
|
// A half-match was found, sort out the return data.
|
|
var text1_a, text1_b, text2_a, text2_b;
|
|
if (text1.length > text2.length) {
|
|
text1_a = hm[0];
|
|
text1_b = hm[1];
|
|
text2_a = hm[2];
|
|
text2_b = hm[3];
|
|
} else {
|
|
text2_a = hm[0];
|
|
text2_b = hm[1];
|
|
text1_a = hm[2];
|
|
text1_b = hm[3];
|
|
}
|
|
var mid_common = hm[4];
|
|
return [text1_a, text1_b, text2_a, text2_b, mid_common];
|
|
};
|
|
|
|
|
|
/**
|
|
* Reorder and merge like edit sections. Merge equalities.
|
|
* Any edit section can move as long as it doesn't cross an equality.
|
|
* @param {Array} diffs Array of diff tuples.
|
|
*/
|
|
function diff_cleanupMerge(diffs) {
|
|
diffs.push([DIFF_EQUAL, '']); // Add a dummy entry at the end.
|
|
var pointer = 0;
|
|
var count_delete = 0;
|
|
var count_insert = 0;
|
|
var text_delete = '';
|
|
var text_insert = '';
|
|
var commonlength;
|
|
while (pointer < diffs.length) {
|
|
switch (diffs[pointer][0]) {
|
|
case DIFF_INSERT:
|
|
count_insert++;
|
|
text_insert += diffs[pointer][1];
|
|
pointer++;
|
|
break;
|
|
case DIFF_DELETE:
|
|
count_delete++;
|
|
text_delete += diffs[pointer][1];
|
|
pointer++;
|
|
break;
|
|
case DIFF_EQUAL:
|
|
// Upon reaching an equality, check for prior redundancies.
|
|
if (count_delete + count_insert > 1) {
|
|
if (count_delete !== 0 && count_insert !== 0) {
|
|
// Factor out any common prefixies.
|
|
commonlength = diff_commonPrefix(text_insert, text_delete);
|
|
if (commonlength !== 0) {
|
|
if ((pointer - count_delete - count_insert) > 0 &&
|
|
diffs[pointer - count_delete - count_insert - 1][0] ==
|
|
DIFF_EQUAL) {
|
|
diffs[pointer - count_delete - count_insert - 1][1] +=
|
|
text_insert.substring(0, commonlength);
|
|
} else {
|
|
diffs.splice(0, 0, [DIFF_EQUAL,
|
|
text_insert.substring(0, commonlength)]);
|
|
pointer++;
|
|
}
|
|
text_insert = text_insert.substring(commonlength);
|
|
text_delete = text_delete.substring(commonlength);
|
|
}
|
|
// Factor out any common suffixies.
|
|
commonlength = diff_commonSuffix(text_insert, text_delete);
|
|
if (commonlength !== 0) {
|
|
diffs[pointer][1] = text_insert.substring(text_insert.length -
|
|
commonlength) + diffs[pointer][1];
|
|
text_insert = text_insert.substring(0, text_insert.length -
|
|
commonlength);
|
|
text_delete = text_delete.substring(0, text_delete.length -
|
|
commonlength);
|
|
}
|
|
}
|
|
// Delete the offending records and add the merged ones.
|
|
if (count_delete === 0) {
|
|
diffs.splice(pointer - count_insert,
|
|
count_delete + count_insert, [DIFF_INSERT, text_insert]);
|
|
} else if (count_insert === 0) {
|
|
diffs.splice(pointer - count_delete,
|
|
count_delete + count_insert, [DIFF_DELETE, text_delete]);
|
|
} else {
|
|
diffs.splice(pointer - count_delete - count_insert,
|
|
count_delete + count_insert, [DIFF_DELETE, text_delete],
|
|
[DIFF_INSERT, text_insert]);
|
|
}
|
|
pointer = pointer - count_delete - count_insert +
|
|
(count_delete ? 1 : 0) + (count_insert ? 1 : 0) + 1;
|
|
} else if (pointer !== 0 && diffs[pointer - 1][0] == DIFF_EQUAL) {
|
|
// Merge this equality with the previous one.
|
|
diffs[pointer - 1][1] += diffs[pointer][1];
|
|
diffs.splice(pointer, 1);
|
|
} else {
|
|
pointer++;
|
|
}
|
|
count_insert = 0;
|
|
count_delete = 0;
|
|
text_delete = '';
|
|
text_insert = '';
|
|
break;
|
|
}
|
|
}
|
|
if (diffs[diffs.length - 1][1] === '') {
|
|
diffs.pop(); // Remove the dummy entry at the end.
|
|
}
|
|
|
|
// Second pass: look for single edits surrounded on both sides by equalities
|
|
// which can be shifted sideways to eliminate an equality.
|
|
// e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC
|
|
var changes = false;
|
|
pointer = 1;
|
|
// Intentionally ignore the first and last element (don't need checking).
|
|
while (pointer < diffs.length - 1) {
|
|
if (diffs[pointer - 1][0] == DIFF_EQUAL &&
|
|
diffs[pointer + 1][0] == DIFF_EQUAL) {
|
|
// This is a single edit surrounded by equalities.
|
|
if (diffs[pointer][1].substring(diffs[pointer][1].length -
|
|
diffs[pointer - 1][1].length) == diffs[pointer - 1][1]) {
|
|
// Shift the edit over the previous equality.
|
|
diffs[pointer][1] = diffs[pointer - 1][1] +
|
|
diffs[pointer][1].substring(0, diffs[pointer][1].length -
|
|
diffs[pointer - 1][1].length);
|
|
diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1];
|
|
diffs.splice(pointer - 1, 1);
|
|
changes = true;
|
|
} else if (diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) ==
|
|
diffs[pointer + 1][1]) {
|
|
// Shift the edit over the next equality.
|
|
diffs[pointer - 1][1] += diffs[pointer + 1][1];
|
|
diffs[pointer][1] =
|
|
diffs[pointer][1].substring(diffs[pointer + 1][1].length) +
|
|
diffs[pointer + 1][1];
|
|
diffs.splice(pointer + 1, 1);
|
|
changes = true;
|
|
}
|
|
}
|
|
pointer++;
|
|
}
|
|
// If shifts were made, the diff needs reordering and another shift sweep.
|
|
if (changes) {
|
|
diff_cleanupMerge(diffs);
|
|
}
|
|
};
|
|
|
|
|
|
var diff = diff_main;
|
|
diff.INSERT = DIFF_INSERT;
|
|
diff.DELETE = DIFF_DELETE;
|
|
diff.EQUAL = DIFF_EQUAL;
|
|
|
|
module.exports = diff;
|
|
|
|
/*
|
|
* Modify a diff such that the cursor position points to the start of a change:
|
|
* E.g.
|
|
* cursor_normalize_diff([[DIFF_EQUAL, 'abc']], 1)
|
|
* => [1, [[DIFF_EQUAL, 'a'], [DIFF_EQUAL, 'bc']]]
|
|
* cursor_normalize_diff([[DIFF_INSERT, 'new'], [DIFF_DELETE, 'xyz']], 2)
|
|
* => [2, [[DIFF_INSERT, 'new'], [DIFF_DELETE, 'xy'], [DIFF_DELETE, 'z']]]
|
|
*
|
|
* @param {Array} diffs Array of diff tuples
|
|
* @param {Int} cursor_pos Suggested edit position. Must not be out of bounds!
|
|
* @return {Array} A tuple [cursor location in the modified diff, modified diff]
|
|
*/
|
|
function cursor_normalize_diff (diffs, cursor_pos) {
|
|
if (cursor_pos === 0) {
|
|
return [DIFF_EQUAL, diffs];
|
|
}
|
|
for (var current_pos = 0, i = 0; i < diffs.length; i++) {
|
|
var d = diffs[i];
|
|
if (d[0] === DIFF_DELETE || d[0] === DIFF_EQUAL) {
|
|
var next_pos = current_pos + d[1].length;
|
|
if (cursor_pos === next_pos) {
|
|
return [i + 1, diffs];
|
|
} else if (cursor_pos < next_pos) {
|
|
// copy to prevent side effects
|
|
diffs = diffs.slice();
|
|
// split d into two diff changes
|
|
var split_pos = cursor_pos - current_pos;
|
|
var d_left = [d[0], d[1].slice(0, split_pos)];
|
|
var d_right = [d[0], d[1].slice(split_pos)];
|
|
diffs.splice(i, 1, d_left, d_right);
|
|
return [i + 1, diffs];
|
|
} else {
|
|
current_pos = next_pos;
|
|
}
|
|
}
|
|
}
|
|
throw new Error('cursor_pos is out of bounds!')
|
|
}
|
|
|
|
/*
|
|
* Modify a diff such that the edit position is "shifted" to the proposed edit location (cursor_position).
|
|
*
|
|
* Case 1)
|
|
* Check if a naive shift is possible:
|
|
* [0, X], [ 1, Y] -> [ 1, Y], [0, X] (if X + Y === Y + X)
|
|
* [0, X], [-1, Y] -> [-1, Y], [0, X] (if X + Y === Y + X) - holds same result
|
|
* Case 2)
|
|
* Check if the following shifts are possible:
|
|
* [0, 'pre'], [ 1, 'prefix'] -> [ 1, 'pre'], [0, 'pre'], [ 1, 'fix']
|
|
* [0, 'pre'], [-1, 'prefix'] -> [-1, 'pre'], [0, 'pre'], [-1, 'fix']
|
|
* ^ ^
|
|
* d d_next
|
|
*
|
|
* @param {Array} diffs Array of diff tuples
|
|
* @param {Int} cursor_pos Suggested edit position. Must not be out of bounds!
|
|
* @return {Array} Array of diff tuples
|
|
*/
|
|
function fix_cursor (diffs, cursor_pos) {
|
|
var norm = cursor_normalize_diff(diffs, cursor_pos);
|
|
var ndiffs = norm[1];
|
|
var cursor_pointer = norm[0];
|
|
var d = ndiffs[cursor_pointer];
|
|
var d_next = ndiffs[cursor_pointer + 1];
|
|
|
|
if (d == null) {
|
|
// Text was deleted from end of original string,
|
|
// cursor is now out of bounds in new string
|
|
return diffs;
|
|
} else if (d[0] !== DIFF_EQUAL) {
|
|
// A modification happened at the cursor location.
|
|
// This is the expected outcome, so we can return the original diff.
|
|
return diffs;
|
|
} else {
|
|
if (d_next != null && d[1] + d_next[1] === d_next[1] + d[1]) {
|
|
// Case 1)
|
|
// It is possible to perform a naive shift
|
|
ndiffs.splice(cursor_pointer, 2, d_next, d)
|
|
return merge_tuples(ndiffs, cursor_pointer, 2)
|
|
} else if (d_next != null && d_next[1].indexOf(d[1]) === 0) {
|
|
// Case 2)
|
|
// d[1] is a prefix of d_next[1]
|
|
// We can assume that d_next[0] !== 0, since d[0] === 0
|
|
// Shift edit locations..
|
|
ndiffs.splice(cursor_pointer, 2, [d_next[0], d[1]], [0, d[1]]);
|
|
var suffix = d_next[1].slice(d[1].length);
|
|
if (suffix.length > 0) {
|
|
ndiffs.splice(cursor_pointer + 2, 0, [d_next[0], suffix]);
|
|
}
|
|
return merge_tuples(ndiffs, cursor_pointer, 3)
|
|
} else {
|
|
// Not possible to perform any modification
|
|
return diffs;
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Check diff did not split surrogate pairs.
|
|
* Ex. [0, '\uD83D'], [-1, '\uDC36'], [1, '\uDC2F'] -> [-1, '\uD83D\uDC36'], [1, '\uD83D\uDC2F']
|
|
* '\uD83D\uDC36' === '🐶', '\uD83D\uDC2F' === '🐯'
|
|
*
|
|
* @param {Array} diffs Array of diff tuples
|
|
* @return {Array} Array of diff tuples
|
|
*/
|
|
function fix_emoji (diffs) {
|
|
var compact = false;
|
|
var starts_with_pair_end = function(str) {
|
|
return str.charCodeAt(0) >= 0xDC00 && str.charCodeAt(0) <= 0xDFFF;
|
|
}
|
|
var ends_with_pair_start = function(str) {
|
|
return str.charCodeAt(str.length-1) >= 0xD800 && str.charCodeAt(str.length-1) <= 0xDBFF;
|
|
}
|
|
for (var i = 2; i < diffs.length; i += 1) {
|
|
if (diffs[i-2][0] === DIFF_EQUAL && ends_with_pair_start(diffs[i-2][1]) &&
|
|
diffs[i-1][0] === DIFF_DELETE && starts_with_pair_end(diffs[i-1][1]) &&
|
|
diffs[i][0] === DIFF_INSERT && starts_with_pair_end(diffs[i][1])) {
|
|
compact = true;
|
|
|
|
diffs[i-1][1] = diffs[i-2][1].slice(-1) + diffs[i-1][1];
|
|
diffs[i][1] = diffs[i-2][1].slice(-1) + diffs[i][1];
|
|
|
|
diffs[i-2][1] = diffs[i-2][1].slice(0, -1);
|
|
}
|
|
}
|
|
if (!compact) {
|
|
return diffs;
|
|
}
|
|
var fixed_diffs = [];
|
|
for (var i = 0; i < diffs.length; i += 1) {
|
|
if (diffs[i][1].length > 0) {
|
|
fixed_diffs.push(diffs[i]);
|
|
}
|
|
}
|
|
return fixed_diffs;
|
|
}
|
|
|
|
/*
|
|
* Try to merge tuples with their neigbors in a given range.
|
|
* E.g. [0, 'a'], [0, 'b'] -> [0, 'ab']
|
|
*
|
|
* @param {Array} diffs Array of diff tuples.
|
|
* @param {Int} start Position of the first element to merge (diffs[start] is also merged with diffs[start - 1]).
|
|
* @param {Int} length Number of consecutive elements to check.
|
|
* @return {Array} Array of merged diff tuples.
|
|
*/
|
|
function merge_tuples (diffs, start, length) {
|
|
// Check from (start-1) to (start+length).
|
|
for (var i = start + length - 1; i >= 0 && i >= start - 1; i--) {
|
|
if (i + 1 < diffs.length) {
|
|
var left_d = diffs[i];
|
|
var right_d = diffs[i+1];
|
|
if (left_d[0] === right_d[1]) {
|
|
diffs.splice(i, 2, [left_d[0], left_d[1] + right_d[1]]);
|
|
}
|
|
}
|
|
}
|
|
return diffs;
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/align-center.svg":
|
|
/*!**********************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/align-center.svg ***!
|
|
\**********************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/align-center.svg?f9afebbb6ae4c2964aa7cb35a8eb0d9d");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/align-justify.svg":
|
|
/*!***********************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/align-justify.svg ***!
|
|
\***********************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/align-justify.svg?90285f1f11db1912e9645c4a5e525344");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/align-left.svg":
|
|
/*!********************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/align-left.svg ***!
|
|
\********************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/align-left.svg?0f8ad7994ca19d6495042555af243eef");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/align-right.svg":
|
|
/*!*********************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/align-right.svg ***!
|
|
\*********************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/align-right.svg?626a3d25131f64ad41bfff6ad1ef10f5");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/background.svg":
|
|
/*!********************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/background.svg ***!
|
|
\********************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/background.svg?82e25f0bd823d4d4fb1e7f4ab0a78ff8");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/blockquote.svg":
|
|
/*!********************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/blockquote.svg ***!
|
|
\********************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/blockquote.svg?928aa5af401fb29fa07515a942ddd4d4");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/bold.svg":
|
|
/*!**************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/bold.svg ***!
|
|
\**************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/bold.svg?7781b6114a3fb65a98f0b178c0d67578");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/clean.svg":
|
|
/*!***************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/clean.svg ***!
|
|
\***************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/clean.svg?d59691df45537ae1a2637d373cdb3c90");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/code.svg":
|
|
/*!**************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/code.svg ***!
|
|
\**************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/code.svg?ea85b5c2863ee647d7bf543564349f8d");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/color.svg":
|
|
/*!***************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/color.svg ***!
|
|
\***************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/color.svg?6c2b4048a0fa0cd5f2c5d920eb95ee48");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/direction-ltr.svg":
|
|
/*!***********************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/direction-ltr.svg ***!
|
|
\***********************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/direction-ltr.svg?d8052e6399cfca6a8a71de21b82bad55");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/direction-rtl.svg":
|
|
/*!***********************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/direction-rtl.svg ***!
|
|
\***********************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/direction-rtl.svg?1375883b2f1e6de4a4621aca550cbd1d");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/dropdown.svg":
|
|
/*!******************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/dropdown.svg ***!
|
|
\******************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/dropdown.svg?c6cd8197101656eb7be9a80dcc6fea48");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/float-center.svg":
|
|
/*!**********************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/float-center.svg ***!
|
|
\**********************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/float-center.svg?5793f183d1a93dc6f65ee9872c887088");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/float-full.svg":
|
|
/*!********************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/float-full.svg ***!
|
|
\********************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/float-full.svg?928ea0b8deb9e17786f2bbcd77324de2");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/float-left.svg":
|
|
/*!********************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/float-left.svg ***!
|
|
\********************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/float-left.svg?917812e3f874fe7614bdc5302f157012");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/float-right.svg":
|
|
/*!*********************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/float-right.svg ***!
|
|
\*********************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/float-right.svg?a595de253808219158737e11e9172a1a");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/formula.svg":
|
|
/*!*****************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/formula.svg ***!
|
|
\*****************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/formula.svg?513e689177d9c7b25d1f232b2497570c");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/header-2.svg":
|
|
/*!******************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/header-2.svg ***!
|
|
\******************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/header-2.svg?34914793e4453a1d65d78b933b421fce");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/header.svg":
|
|
/*!****************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/header.svg ***!
|
|
\****************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/header.svg?8c2dc93d4be101f76bae77761ec90c8e");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/image.svg":
|
|
/*!***************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/image.svg ***!
|
|
\***************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/image.svg?bffb79ce0fc8b41e9e6ce90bea00618b");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/indent.svg":
|
|
/*!****************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/indent.svg ***!
|
|
\****************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/indent.svg?b5fc7f81a004c4855833c500b0c538db");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/italic.svg":
|
|
/*!****************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/italic.svg ***!
|
|
\****************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/italic.svg?ff0ddc3f7d3244531d0a87389f6e151a");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/link.svg":
|
|
/*!**************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/link.svg ***!
|
|
\**************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/link.svg?5c302e73950bc52c1afb8cf4f3ceb707");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/list-bullet.svg":
|
|
/*!*********************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/list-bullet.svg ***!
|
|
\*********************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/list-bullet.svg?cb92933c891e9914f1ac99ea79305cd4");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/list-check.svg":
|
|
/*!********************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/list-check.svg ***!
|
|
\********************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/list-check.svg?b70fb56c61cdc4dfdacbc1d7914368a6");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/list-ordered.svg":
|
|
/*!**********************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/list-ordered.svg ***!
|
|
\**********************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/list-ordered.svg?3e184f964f06cafa0ae283d1ad5b6cd8");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/outdent.svg":
|
|
/*!*****************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/outdent.svg ***!
|
|
\*****************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/outdent.svg?dd7145d26d6ba4aed3ebd11dc181d507");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/strike.svg":
|
|
/*!****************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/strike.svg ***!
|
|
\****************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/strike.svg?248ad333a3ad0b651e533dfadb12dde0");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/subscript.svg":
|
|
/*!*******************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/subscript.svg ***!
|
|
\*******************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/subscript.svg?9d8ea7c3c97df4bc024f7dab9248f7ce");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/superscript.svg":
|
|
/*!*********************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/superscript.svg ***!
|
|
\*********************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/superscript.svg?3bed5966c174cea3f1047990c82290a3");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/underline.svg":
|
|
/*!*******************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/underline.svg ***!
|
|
\*******************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/underline.svg?585c47324c8f9d8c076d8d7bb452efaa");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/assets/icons/video.svg":
|
|
/*!***************************************************!*\
|
|
!*** ./node_modules/quill/assets/icons/video.svg ***!
|
|
\***************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("/images/vendor/quill/icons/video.svg?eaeee04ce09d795ae77deaff36281c80");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/function-bind/implementation.js":
|
|
/*!******************************************************!*\
|
|
!*** ./node_modules/function-bind/implementation.js ***!
|
|
\******************************************************/
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
/* eslint no-invalid-this: 1 */
|
|
|
|
var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
|
|
var slice = Array.prototype.slice;
|
|
var toStr = Object.prototype.toString;
|
|
var funcType = '[object Function]';
|
|
|
|
module.exports = function bind(that) {
|
|
var target = this;
|
|
if (typeof target !== 'function' || toStr.call(target) !== funcType) {
|
|
throw new TypeError(ERROR_MESSAGE + target);
|
|
}
|
|
var args = slice.call(arguments, 1);
|
|
|
|
var bound;
|
|
var binder = function () {
|
|
if (this instanceof bound) {
|
|
var result = target.apply(
|
|
this,
|
|
args.concat(slice.call(arguments))
|
|
);
|
|
if (Object(result) === result) {
|
|
return result;
|
|
}
|
|
return this;
|
|
} else {
|
|
return target.apply(
|
|
that,
|
|
args.concat(slice.call(arguments))
|
|
);
|
|
}
|
|
};
|
|
|
|
var boundLength = Math.max(0, target.length - args.length);
|
|
var boundArgs = [];
|
|
for (var i = 0; i < boundLength; i++) {
|
|
boundArgs.push('$' + i);
|
|
}
|
|
|
|
bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
|
|
|
|
if (target.prototype) {
|
|
var Empty = function Empty() {};
|
|
Empty.prototype = target.prototype;
|
|
bound.prototype = new Empty();
|
|
Empty.prototype = null;
|
|
}
|
|
|
|
return bound;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/function-bind/index.js":
|
|
/*!*********************************************!*\
|
|
!*** ./node_modules/function-bind/index.js ***!
|
|
\*********************************************/
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var implementation = __webpack_require__(/*! ./implementation */ "./node_modules/function-bind/implementation.js");
|
|
|
|
module.exports = Function.prototype.bind || implementation;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/get-intrinsic/index.js":
|
|
/*!*********************************************!*\
|
|
!*** ./node_modules/get-intrinsic/index.js ***!
|
|
\*********************************************/
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var undefined;
|
|
|
|
var $SyntaxError = SyntaxError;
|
|
var $Function = Function;
|
|
var $TypeError = TypeError;
|
|
|
|
// eslint-disable-next-line consistent-return
|
|
var getEvalledConstructor = function (expressionSyntax) {
|
|
try {
|
|
return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
|
|
} catch (e) {}
|
|
};
|
|
|
|
var $gOPD = Object.getOwnPropertyDescriptor;
|
|
if ($gOPD) {
|
|
try {
|
|
$gOPD({}, '');
|
|
} catch (e) {
|
|
$gOPD = null; // this is IE 8, which has a broken gOPD
|
|
}
|
|
}
|
|
|
|
var throwTypeError = function () {
|
|
throw new $TypeError();
|
|
};
|
|
var ThrowTypeError = $gOPD
|
|
? (function () {
|
|
try {
|
|
// eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties
|
|
arguments.callee; // IE 8 does not throw here
|
|
return throwTypeError;
|
|
} catch (calleeThrows) {
|
|
try {
|
|
// IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '')
|
|
return $gOPD(arguments, 'callee').get;
|
|
} catch (gOPDthrows) {
|
|
return throwTypeError;
|
|
}
|
|
}
|
|
}())
|
|
: throwTypeError;
|
|
|
|
var hasSymbols = __webpack_require__(/*! has-symbols */ "./node_modules/has-symbols/index.js")();
|
|
|
|
var getProto = Object.getPrototypeOf || function (x) { return x.__proto__; }; // eslint-disable-line no-proto
|
|
|
|
var needsEval = {};
|
|
|
|
var TypedArray = typeof Uint8Array === 'undefined' ? undefined : getProto(Uint8Array);
|
|
|
|
var INTRINSICS = {
|
|
'%AggregateError%': typeof AggregateError === 'undefined' ? undefined : AggregateError,
|
|
'%Array%': Array,
|
|
'%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer,
|
|
'%ArrayIteratorPrototype%': hasSymbols ? getProto([][Symbol.iterator]()) : undefined,
|
|
'%AsyncFromSyncIteratorPrototype%': undefined,
|
|
'%AsyncFunction%': needsEval,
|
|
'%AsyncGenerator%': needsEval,
|
|
'%AsyncGeneratorFunction%': needsEval,
|
|
'%AsyncIteratorPrototype%': needsEval,
|
|
'%Atomics%': typeof Atomics === 'undefined' ? undefined : Atomics,
|
|
'%BigInt%': typeof BigInt === 'undefined' ? undefined : BigInt,
|
|
'%Boolean%': Boolean,
|
|
'%DataView%': typeof DataView === 'undefined' ? undefined : DataView,
|
|
'%Date%': Date,
|
|
'%decodeURI%': decodeURI,
|
|
'%decodeURIComponent%': decodeURIComponent,
|
|
'%encodeURI%': encodeURI,
|
|
'%encodeURIComponent%': encodeURIComponent,
|
|
'%Error%': Error,
|
|
'%eval%': eval, // eslint-disable-line no-eval
|
|
'%EvalError%': EvalError,
|
|
'%Float32Array%': typeof Float32Array === 'undefined' ? undefined : Float32Array,
|
|
'%Float64Array%': typeof Float64Array === 'undefined' ? undefined : Float64Array,
|
|
'%FinalizationRegistry%': typeof FinalizationRegistry === 'undefined' ? undefined : FinalizationRegistry,
|
|
'%Function%': $Function,
|
|
'%GeneratorFunction%': needsEval,
|
|
'%Int8Array%': typeof Int8Array === 'undefined' ? undefined : Int8Array,
|
|
'%Int16Array%': typeof Int16Array === 'undefined' ? undefined : Int16Array,
|
|
'%Int32Array%': typeof Int32Array === 'undefined' ? undefined : Int32Array,
|
|
'%isFinite%': isFinite,
|
|
'%isNaN%': isNaN,
|
|
'%IteratorPrototype%': hasSymbols ? getProto(getProto([][Symbol.iterator]())) : undefined,
|
|
'%JSON%': typeof JSON === 'object' ? JSON : undefined,
|
|
'%Map%': typeof Map === 'undefined' ? undefined : Map,
|
|
'%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols ? undefined : getProto(new Map()[Symbol.iterator]()),
|
|
'%Math%': Math,
|
|
'%Number%': Number,
|
|
'%Object%': Object,
|
|
'%parseFloat%': parseFloat,
|
|
'%parseInt%': parseInt,
|
|
'%Promise%': typeof Promise === 'undefined' ? undefined : Promise,
|
|
'%Proxy%': typeof Proxy === 'undefined' ? undefined : Proxy,
|
|
'%RangeError%': RangeError,
|
|
'%ReferenceError%': ReferenceError,
|
|
'%Reflect%': typeof Reflect === 'undefined' ? undefined : Reflect,
|
|
'%RegExp%': RegExp,
|
|
'%Set%': typeof Set === 'undefined' ? undefined : Set,
|
|
'%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols ? undefined : getProto(new Set()[Symbol.iterator]()),
|
|
'%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer,
|
|
'%String%': String,
|
|
'%StringIteratorPrototype%': hasSymbols ? getProto(''[Symbol.iterator]()) : undefined,
|
|
'%Symbol%': hasSymbols ? Symbol : undefined,
|
|
'%SyntaxError%': $SyntaxError,
|
|
'%ThrowTypeError%': ThrowTypeError,
|
|
'%TypedArray%': TypedArray,
|
|
'%TypeError%': $TypeError,
|
|
'%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array,
|
|
'%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray,
|
|
'%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array,
|
|
'%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array,
|
|
'%URIError%': URIError,
|
|
'%WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap,
|
|
'%WeakRef%': typeof WeakRef === 'undefined' ? undefined : WeakRef,
|
|
'%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet
|
|
};
|
|
|
|
var doEval = function doEval(name) {
|
|
var value;
|
|
if (name === '%AsyncFunction%') {
|
|
value = getEvalledConstructor('async function () {}');
|
|
} else if (name === '%GeneratorFunction%') {
|
|
value = getEvalledConstructor('function* () {}');
|
|
} else if (name === '%AsyncGeneratorFunction%') {
|
|
value = getEvalledConstructor('async function* () {}');
|
|
} else if (name === '%AsyncGenerator%') {
|
|
var fn = doEval('%AsyncGeneratorFunction%');
|
|
if (fn) {
|
|
value = fn.prototype;
|
|
}
|
|
} else if (name === '%AsyncIteratorPrototype%') {
|
|
var gen = doEval('%AsyncGenerator%');
|
|
if (gen) {
|
|
value = getProto(gen.prototype);
|
|
}
|
|
}
|
|
|
|
INTRINSICS[name] = value;
|
|
|
|
return value;
|
|
};
|
|
|
|
var LEGACY_ALIASES = {
|
|
'%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'],
|
|
'%ArrayPrototype%': ['Array', 'prototype'],
|
|
'%ArrayProto_entries%': ['Array', 'prototype', 'entries'],
|
|
'%ArrayProto_forEach%': ['Array', 'prototype', 'forEach'],
|
|
'%ArrayProto_keys%': ['Array', 'prototype', 'keys'],
|
|
'%ArrayProto_values%': ['Array', 'prototype', 'values'],
|
|
'%AsyncFunctionPrototype%': ['AsyncFunction', 'prototype'],
|
|
'%AsyncGenerator%': ['AsyncGeneratorFunction', 'prototype'],
|
|
'%AsyncGeneratorPrototype%': ['AsyncGeneratorFunction', 'prototype', 'prototype'],
|
|
'%BooleanPrototype%': ['Boolean', 'prototype'],
|
|
'%DataViewPrototype%': ['DataView', 'prototype'],
|
|
'%DatePrototype%': ['Date', 'prototype'],
|
|
'%ErrorPrototype%': ['Error', 'prototype'],
|
|
'%EvalErrorPrototype%': ['EvalError', 'prototype'],
|
|
'%Float32ArrayPrototype%': ['Float32Array', 'prototype'],
|
|
'%Float64ArrayPrototype%': ['Float64Array', 'prototype'],
|
|
'%FunctionPrototype%': ['Function', 'prototype'],
|
|
'%Generator%': ['GeneratorFunction', 'prototype'],
|
|
'%GeneratorPrototype%': ['GeneratorFunction', 'prototype', 'prototype'],
|
|
'%Int8ArrayPrototype%': ['Int8Array', 'prototype'],
|
|
'%Int16ArrayPrototype%': ['Int16Array', 'prototype'],
|
|
'%Int32ArrayPrototype%': ['Int32Array', 'prototype'],
|
|
'%JSONParse%': ['JSON', 'parse'],
|
|
'%JSONStringify%': ['JSON', 'stringify'],
|
|
'%MapPrototype%': ['Map', 'prototype'],
|
|
'%NumberPrototype%': ['Number', 'prototype'],
|
|
'%ObjectPrototype%': ['Object', 'prototype'],
|
|
'%ObjProto_toString%': ['Object', 'prototype', 'toString'],
|
|
'%ObjProto_valueOf%': ['Object', 'prototype', 'valueOf'],
|
|
'%PromisePrototype%': ['Promise', 'prototype'],
|
|
'%PromiseProto_then%': ['Promise', 'prototype', 'then'],
|
|
'%Promise_all%': ['Promise', 'all'],
|
|
'%Promise_reject%': ['Promise', 'reject'],
|
|
'%Promise_resolve%': ['Promise', 'resolve'],
|
|
'%RangeErrorPrototype%': ['RangeError', 'prototype'],
|
|
'%ReferenceErrorPrototype%': ['ReferenceError', 'prototype'],
|
|
'%RegExpPrototype%': ['RegExp', 'prototype'],
|
|
'%SetPrototype%': ['Set', 'prototype'],
|
|
'%SharedArrayBufferPrototype%': ['SharedArrayBuffer', 'prototype'],
|
|
'%StringPrototype%': ['String', 'prototype'],
|
|
'%SymbolPrototype%': ['Symbol', 'prototype'],
|
|
'%SyntaxErrorPrototype%': ['SyntaxError', 'prototype'],
|
|
'%TypedArrayPrototype%': ['TypedArray', 'prototype'],
|
|
'%TypeErrorPrototype%': ['TypeError', 'prototype'],
|
|
'%Uint8ArrayPrototype%': ['Uint8Array', 'prototype'],
|
|
'%Uint8ClampedArrayPrototype%': ['Uint8ClampedArray', 'prototype'],
|
|
'%Uint16ArrayPrototype%': ['Uint16Array', 'prototype'],
|
|
'%Uint32ArrayPrototype%': ['Uint32Array', 'prototype'],
|
|
'%URIErrorPrototype%': ['URIError', 'prototype'],
|
|
'%WeakMapPrototype%': ['WeakMap', 'prototype'],
|
|
'%WeakSetPrototype%': ['WeakSet', 'prototype']
|
|
};
|
|
|
|
var bind = __webpack_require__(/*! function-bind */ "./node_modules/function-bind/index.js");
|
|
var hasOwn = __webpack_require__(/*! has */ "./node_modules/has/src/index.js");
|
|
var $concat = bind.call(Function.call, Array.prototype.concat);
|
|
var $spliceApply = bind.call(Function.apply, Array.prototype.splice);
|
|
var $replace = bind.call(Function.call, String.prototype.replace);
|
|
var $strSlice = bind.call(Function.call, String.prototype.slice);
|
|
|
|
/* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */
|
|
var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
|
|
var reEscapeChar = /\\(\\)?/g; /** Used to match backslashes in property paths. */
|
|
var stringToPath = function stringToPath(string) {
|
|
var first = $strSlice(string, 0, 1);
|
|
var last = $strSlice(string, -1);
|
|
if (first === '%' && last !== '%') {
|
|
throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`');
|
|
} else if (last === '%' && first !== '%') {
|
|
throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`');
|
|
}
|
|
var result = [];
|
|
$replace(string, rePropName, function (match, number, quote, subString) {
|
|
result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : number || match;
|
|
});
|
|
return result;
|
|
};
|
|
/* end adaptation */
|
|
|
|
var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
|
|
var intrinsicName = name;
|
|
var alias;
|
|
if (hasOwn(LEGACY_ALIASES, intrinsicName)) {
|
|
alias = LEGACY_ALIASES[intrinsicName];
|
|
intrinsicName = '%' + alias[0] + '%';
|
|
}
|
|
|
|
if (hasOwn(INTRINSICS, intrinsicName)) {
|
|
var value = INTRINSICS[intrinsicName];
|
|
if (value === needsEval) {
|
|
value = doEval(intrinsicName);
|
|
}
|
|
if (typeof value === 'undefined' && !allowMissing) {
|
|
throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
|
|
}
|
|
|
|
return {
|
|
alias: alias,
|
|
name: intrinsicName,
|
|
value: value
|
|
};
|
|
}
|
|
|
|
throw new $SyntaxError('intrinsic ' + name + ' does not exist!');
|
|
};
|
|
|
|
module.exports = function GetIntrinsic(name, allowMissing) {
|
|
if (typeof name !== 'string' || name.length === 0) {
|
|
throw new $TypeError('intrinsic name must be a non-empty string');
|
|
}
|
|
if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
|
|
throw new $TypeError('"allowMissing" argument must be a boolean');
|
|
}
|
|
|
|
var parts = stringToPath(name);
|
|
var intrinsicBaseName = parts.length > 0 ? parts[0] : '';
|
|
|
|
var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing);
|
|
var intrinsicRealName = intrinsic.name;
|
|
var value = intrinsic.value;
|
|
var skipFurtherCaching = false;
|
|
|
|
var alias = intrinsic.alias;
|
|
if (alias) {
|
|
intrinsicBaseName = alias[0];
|
|
$spliceApply(parts, $concat([0, 1], alias));
|
|
}
|
|
|
|
for (var i = 1, isOwn = true; i < parts.length; i += 1) {
|
|
var part = parts[i];
|
|
var first = $strSlice(part, 0, 1);
|
|
var last = $strSlice(part, -1);
|
|
if (
|
|
(
|
|
(first === '"' || first === "'" || first === '`')
|
|
|| (last === '"' || last === "'" || last === '`')
|
|
)
|
|
&& first !== last
|
|
) {
|
|
throw new $SyntaxError('property names with quotes must have matching quotes');
|
|
}
|
|
if (part === 'constructor' || !isOwn) {
|
|
skipFurtherCaching = true;
|
|
}
|
|
|
|
intrinsicBaseName += '.' + part;
|
|
intrinsicRealName = '%' + intrinsicBaseName + '%';
|
|
|
|
if (hasOwn(INTRINSICS, intrinsicRealName)) {
|
|
value = INTRINSICS[intrinsicRealName];
|
|
} else if (value != null) {
|
|
if (!(part in value)) {
|
|
if (!allowMissing) {
|
|
throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.');
|
|
}
|
|
return void undefined;
|
|
}
|
|
if ($gOPD && (i + 1) >= parts.length) {
|
|
var desc = $gOPD(value, part);
|
|
isOwn = !!desc;
|
|
|
|
// By convention, when a data property is converted to an accessor
|
|
// property to emulate a data property that does not suffer from
|
|
// the override mistake, that accessor's getter is marked with
|
|
// an `originalValue` property. Here, when we detect this, we
|
|
// uphold the illusion by pretending to see that original data
|
|
// property, i.e., returning the value rather than the getter
|
|
// itself.
|
|
if (isOwn && 'get' in desc && !('originalValue' in desc.get)) {
|
|
value = desc.get;
|
|
} else {
|
|
value = value[part];
|
|
}
|
|
} else {
|
|
isOwn = hasOwn(value, part);
|
|
value = value[part];
|
|
}
|
|
|
|
if (isOwn && !skipFurtherCaching) {
|
|
INTRINSICS[intrinsicRealName] = value;
|
|
}
|
|
}
|
|
}
|
|
return value;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/has-symbols/index.js":
|
|
/*!*******************************************!*\
|
|
!*** ./node_modules/has-symbols/index.js ***!
|
|
\*******************************************/
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var origSymbol = typeof Symbol !== 'undefined' && Symbol;
|
|
var hasSymbolSham = __webpack_require__(/*! ./shams */ "./node_modules/has-symbols/shams.js");
|
|
|
|
module.exports = function hasNativeSymbols() {
|
|
if (typeof origSymbol !== 'function') { return false; }
|
|
if (typeof Symbol !== 'function') { return false; }
|
|
if (typeof origSymbol('foo') !== 'symbol') { return false; }
|
|
if (typeof Symbol('bar') !== 'symbol') { return false; }
|
|
|
|
return hasSymbolSham();
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/has-symbols/shams.js":
|
|
/*!*******************************************!*\
|
|
!*** ./node_modules/has-symbols/shams.js ***!
|
|
\*******************************************/
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
/* eslint complexity: [2, 18], max-statements: [2, 33] */
|
|
module.exports = function hasSymbols() {
|
|
if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
|
|
if (typeof Symbol.iterator === 'symbol') { return true; }
|
|
|
|
var obj = {};
|
|
var sym = Symbol('test');
|
|
var symObj = Object(sym);
|
|
if (typeof sym === 'string') { return false; }
|
|
|
|
if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
|
|
if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
|
|
|
|
// temp disabled per https://github.com/ljharb/object.assign/issues/17
|
|
// if (sym instanceof Symbol) { return false; }
|
|
// temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
|
|
// if (!(symObj instanceof Symbol)) { return false; }
|
|
|
|
// if (typeof Symbol.prototype.toString !== 'function') { return false; }
|
|
// if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
|
|
|
|
var symVal = 42;
|
|
obj[sym] = symVal;
|
|
for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop
|
|
if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
|
|
|
|
if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
|
|
|
|
var syms = Object.getOwnPropertySymbols(obj);
|
|
if (syms.length !== 1 || syms[0] !== sym) { return false; }
|
|
|
|
if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
|
|
|
|
if (typeof Object.getOwnPropertyDescriptor === 'function') {
|
|
var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
|
|
if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/has/src/index.js":
|
|
/*!***************************************!*\
|
|
!*** ./node_modules/has/src/index.js ***!
|
|
\***************************************/
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var bind = __webpack_require__(/*! function-bind */ "./node_modules/function-bind/index.js");
|
|
|
|
module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/ieee754/index.js":
|
|
/*!***************************************!*\
|
|
!*** ./node_modules/ieee754/index.js ***!
|
|
\***************************************/
|
|
/***/ ((__unused_webpack_module, exports) => {
|
|
|
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
|
|
var e, m
|
|
var eLen = (nBytes * 8) - mLen - 1
|
|
var eMax = (1 << eLen) - 1
|
|
var eBias = eMax >> 1
|
|
var nBits = -7
|
|
var i = isLE ? (nBytes - 1) : 0
|
|
var d = isLE ? -1 : 1
|
|
var s = buffer[offset + i]
|
|
|
|
i += d
|
|
|
|
e = s & ((1 << (-nBits)) - 1)
|
|
s >>= (-nBits)
|
|
nBits += eLen
|
|
for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
|
|
|
m = e & ((1 << (-nBits)) - 1)
|
|
e >>= (-nBits)
|
|
nBits += mLen
|
|
for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
|
|
|
if (e === 0) {
|
|
e = 1 - eBias
|
|
} else if (e === eMax) {
|
|
return m ? NaN : ((s ? -1 : 1) * Infinity)
|
|
} else {
|
|
m = m + Math.pow(2, mLen)
|
|
e = e - eBias
|
|
}
|
|
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
|
}
|
|
|
|
exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
|
var e, m, c
|
|
var eLen = (nBytes * 8) - mLen - 1
|
|
var eMax = (1 << eLen) - 1
|
|
var eBias = eMax >> 1
|
|
var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
|
|
var i = isLE ? 0 : (nBytes - 1)
|
|
var d = isLE ? 1 : -1
|
|
var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
|
|
|
|
value = Math.abs(value)
|
|
|
|
if (isNaN(value) || value === Infinity) {
|
|
m = isNaN(value) ? 1 : 0
|
|
e = eMax
|
|
} else {
|
|
e = Math.floor(Math.log(value) / Math.LN2)
|
|
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
e--
|
|
c *= 2
|
|
}
|
|
if (e + eBias >= 1) {
|
|
value += rt / c
|
|
} else {
|
|
value += rt * Math.pow(2, 1 - eBias)
|
|
}
|
|
if (value * c >= 2) {
|
|
e++
|
|
c /= 2
|
|
}
|
|
|
|
if (e + eBias >= eMax) {
|
|
m = 0
|
|
e = eMax
|
|
} else if (e + eBias >= 1) {
|
|
m = ((value * c) - 1) * Math.pow(2, mLen)
|
|
e = e + eBias
|
|
} else {
|
|
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
|
|
e = 0
|
|
}
|
|
}
|
|
|
|
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
|
|
|
|
e = (e << mLen) | m
|
|
eLen += mLen
|
|
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
|
|
|
|
buffer[offset + i - d] |= s * 128
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/is-arguments/index.js":
|
|
/*!********************************************!*\
|
|
!*** ./node_modules/is-arguments/index.js ***!
|
|
\********************************************/
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
|
|
var callBound = __webpack_require__(/*! call-bind/callBound */ "./node_modules/call-bind/callBound.js");
|
|
|
|
var $toString = callBound('Object.prototype.toString');
|
|
|
|
var isStandardArguments = function isArguments(value) {
|
|
if (hasToStringTag && value && typeof value === 'object' && Symbol.toStringTag in value) {
|
|
return false;
|
|
}
|
|
return $toString(value) === '[object Arguments]';
|
|
};
|
|
|
|
var isLegacyArguments = function isArguments(value) {
|
|
if (isStandardArguments(value)) {
|
|
return true;
|
|
}
|
|
return value !== null &&
|
|
typeof value === 'object' &&
|
|
typeof value.length === 'number' &&
|
|
value.length >= 0 &&
|
|
$toString(value) !== '[object Array]' &&
|
|
$toString(value.callee) === '[object Function]';
|
|
};
|
|
|
|
var supportsStandardArguments = (function () {
|
|
return isStandardArguments(arguments);
|
|
}());
|
|
|
|
isStandardArguments.isLegacyArguments = isLegacyArguments; // for tests
|
|
|
|
module.exports = supportsStandardArguments ? isStandardArguments : isLegacyArguments;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/is-date-object/index.js":
|
|
/*!**********************************************!*\
|
|
!*** ./node_modules/is-date-object/index.js ***!
|
|
\**********************************************/
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var getDay = Date.prototype.getDay;
|
|
var tryDateObject = function tryDateGetDayCall(value) {
|
|
try {
|
|
getDay.call(value);
|
|
return true;
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
};
|
|
|
|
var toStr = Object.prototype.toString;
|
|
var dateClass = '[object Date]';
|
|
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
|
|
|
|
module.exports = function isDateObject(value) {
|
|
if (typeof value !== 'object' || value === null) {
|
|
return false;
|
|
}
|
|
return hasToStringTag ? tryDateObject(value) : toStr.call(value) === dateClass;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/is-regex/index.js":
|
|
/*!****************************************!*\
|
|
!*** ./node_modules/is-regex/index.js ***!
|
|
\****************************************/
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var callBound = __webpack_require__(/*! call-bind/callBound */ "./node_modules/call-bind/callBound.js");
|
|
var hasSymbols = __webpack_require__(/*! has-symbols */ "./node_modules/has-symbols/index.js")();
|
|
var hasToStringTag = hasSymbols && typeof Symbol.toStringTag === 'symbol';
|
|
var has;
|
|
var $exec;
|
|
var isRegexMarker;
|
|
var badStringifier;
|
|
|
|
if (hasToStringTag) {
|
|
has = callBound('Object.prototype.hasOwnProperty');
|
|
$exec = callBound('RegExp.prototype.exec');
|
|
isRegexMarker = {};
|
|
|
|
var throwRegexMarker = function () {
|
|
throw isRegexMarker;
|
|
};
|
|
badStringifier = {
|
|
toString: throwRegexMarker,
|
|
valueOf: throwRegexMarker
|
|
};
|
|
|
|
if (typeof Symbol.toPrimitive === 'symbol') {
|
|
badStringifier[Symbol.toPrimitive] = throwRegexMarker;
|
|
}
|
|
}
|
|
|
|
var $toString = callBound('Object.prototype.toString');
|
|
var gOPD = Object.getOwnPropertyDescriptor;
|
|
var regexClass = '[object RegExp]';
|
|
|
|
module.exports = hasToStringTag
|
|
// eslint-disable-next-line consistent-return
|
|
? function isRegex(value) {
|
|
if (!value || typeof value !== 'object') {
|
|
return false;
|
|
}
|
|
|
|
var descriptor = gOPD(value, 'lastIndex');
|
|
var hasLastIndexDataProperty = descriptor && has(descriptor, 'value');
|
|
if (!hasLastIndexDataProperty) {
|
|
return false;
|
|
}
|
|
|
|
try {
|
|
$exec(value, badStringifier);
|
|
} catch (e) {
|
|
return e === isRegexMarker;
|
|
}
|
|
}
|
|
: function isRegex(value) {
|
|
// In older browsers, typeof regex incorrectly returns 'function'
|
|
if (!value || (typeof value !== 'object' && typeof value !== 'function')) {
|
|
return false;
|
|
}
|
|
|
|
return $toString(value) === regexClass;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/isarray/index.js":
|
|
/*!***************************************!*\
|
|
!*** ./node_modules/isarray/index.js ***!
|
|
\***************************************/
|
|
/***/ ((module) => {
|
|
|
|
var toString = {}.toString;
|
|
|
|
module.exports = Array.isArray || function (arr) {
|
|
return toString.call(arr) == '[object Array]';
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/object-is/implementation.js":
|
|
/*!**************************************************!*\
|
|
!*** ./node_modules/object-is/implementation.js ***!
|
|
\**************************************************/
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var numberIsNaN = function (value) {
|
|
return value !== value;
|
|
};
|
|
|
|
module.exports = function is(a, b) {
|
|
if (a === 0 && b === 0) {
|
|
return 1 / a === 1 / b;
|
|
}
|
|
if (a === b) {
|
|
return true;
|
|
}
|
|
if (numberIsNaN(a) && numberIsNaN(b)) {
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/object-is/index.js":
|
|
/*!*****************************************!*\
|
|
!*** ./node_modules/object-is/index.js ***!
|
|
\*****************************************/
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var define = __webpack_require__(/*! define-properties */ "./node_modules/define-properties/index.js");
|
|
var callBind = __webpack_require__(/*! call-bind */ "./node_modules/call-bind/index.js");
|
|
|
|
var implementation = __webpack_require__(/*! ./implementation */ "./node_modules/object-is/implementation.js");
|
|
var getPolyfill = __webpack_require__(/*! ./polyfill */ "./node_modules/object-is/polyfill.js");
|
|
var shim = __webpack_require__(/*! ./shim */ "./node_modules/object-is/shim.js");
|
|
|
|
var polyfill = callBind(getPolyfill(), Object);
|
|
|
|
define(polyfill, {
|
|
getPolyfill: getPolyfill,
|
|
implementation: implementation,
|
|
shim: shim
|
|
});
|
|
|
|
module.exports = polyfill;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/object-is/polyfill.js":
|
|
/*!********************************************!*\
|
|
!*** ./node_modules/object-is/polyfill.js ***!
|
|
\********************************************/
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var implementation = __webpack_require__(/*! ./implementation */ "./node_modules/object-is/implementation.js");
|
|
|
|
module.exports = function getPolyfill() {
|
|
return typeof Object.is === 'function' ? Object.is : implementation;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/object-is/shim.js":
|
|
/*!****************************************!*\
|
|
!*** ./node_modules/object-is/shim.js ***!
|
|
\****************************************/
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var getPolyfill = __webpack_require__(/*! ./polyfill */ "./node_modules/object-is/polyfill.js");
|
|
var define = __webpack_require__(/*! define-properties */ "./node_modules/define-properties/index.js");
|
|
|
|
module.exports = function shimObjectIs() {
|
|
var polyfill = getPolyfill();
|
|
define(Object, { is: polyfill }, {
|
|
is: function testObjectIs() {
|
|
return Object.is !== polyfill;
|
|
}
|
|
});
|
|
return polyfill;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/object-keys/implementation.js":
|
|
/*!****************************************************!*\
|
|
!*** ./node_modules/object-keys/implementation.js ***!
|
|
\****************************************************/
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var keysShim;
|
|
if (!Object.keys) {
|
|
// modified from https://github.com/es-shims/es5-shim
|
|
var has = Object.prototype.hasOwnProperty;
|
|
var toStr = Object.prototype.toString;
|
|
var isArgs = __webpack_require__(/*! ./isArguments */ "./node_modules/object-keys/isArguments.js"); // eslint-disable-line global-require
|
|
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
|
var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
|
|
var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
|
|
var dontEnums = [
|
|
'toString',
|
|
'toLocaleString',
|
|
'valueOf',
|
|
'hasOwnProperty',
|
|
'isPrototypeOf',
|
|
'propertyIsEnumerable',
|
|
'constructor'
|
|
];
|
|
var equalsConstructorPrototype = function (o) {
|
|
var ctor = o.constructor;
|
|
return ctor && ctor.prototype === o;
|
|
};
|
|
var excludedKeys = {
|
|
$applicationCache: true,
|
|
$console: true,
|
|
$external: true,
|
|
$frame: true,
|
|
$frameElement: true,
|
|
$frames: true,
|
|
$innerHeight: true,
|
|
$innerWidth: true,
|
|
$onmozfullscreenchange: true,
|
|
$onmozfullscreenerror: true,
|
|
$outerHeight: true,
|
|
$outerWidth: true,
|
|
$pageXOffset: true,
|
|
$pageYOffset: true,
|
|
$parent: true,
|
|
$scrollLeft: true,
|
|
$scrollTop: true,
|
|
$scrollX: true,
|
|
$scrollY: true,
|
|
$self: true,
|
|
$webkitIndexedDB: true,
|
|
$webkitStorageInfo: true,
|
|
$window: true
|
|
};
|
|
var hasAutomationEqualityBug = (function () {
|
|
/* global window */
|
|
if (typeof window === 'undefined') { return false; }
|
|
for (var k in window) {
|
|
try {
|
|
if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
|
|
try {
|
|
equalsConstructorPrototype(window[k]);
|
|
} catch (e) {
|
|
return true;
|
|
}
|
|
}
|
|
} catch (e) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}());
|
|
var equalsConstructorPrototypeIfNotBuggy = function (o) {
|
|
/* global window */
|
|
if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
|
|
return equalsConstructorPrototype(o);
|
|
}
|
|
try {
|
|
return equalsConstructorPrototype(o);
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
};
|
|
|
|
keysShim = function keys(object) {
|
|
var isObject = object !== null && typeof object === 'object';
|
|
var isFunction = toStr.call(object) === '[object Function]';
|
|
var isArguments = isArgs(object);
|
|
var isString = isObject && toStr.call(object) === '[object String]';
|
|
var theKeys = [];
|
|
|
|
if (!isObject && !isFunction && !isArguments) {
|
|
throw new TypeError('Object.keys called on a non-object');
|
|
}
|
|
|
|
var skipProto = hasProtoEnumBug && isFunction;
|
|
if (isString && object.length > 0 && !has.call(object, 0)) {
|
|
for (var i = 0; i < object.length; ++i) {
|
|
theKeys.push(String(i));
|
|
}
|
|
}
|
|
|
|
if (isArguments && object.length > 0) {
|
|
for (var j = 0; j < object.length; ++j) {
|
|
theKeys.push(String(j));
|
|
}
|
|
} else {
|
|
for (var name in object) {
|
|
if (!(skipProto && name === 'prototype') && has.call(object, name)) {
|
|
theKeys.push(String(name));
|
|
}
|
|
}
|
|
}
|
|
|
|
if (hasDontEnumBug) {
|
|
var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
|
|
|
|
for (var k = 0; k < dontEnums.length; ++k) {
|
|
if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
|
|
theKeys.push(dontEnums[k]);
|
|
}
|
|
}
|
|
}
|
|
return theKeys;
|
|
};
|
|
}
|
|
module.exports = keysShim;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/object-keys/index.js":
|
|
/*!*******************************************!*\
|
|
!*** ./node_modules/object-keys/index.js ***!
|
|
\*******************************************/
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var slice = Array.prototype.slice;
|
|
var isArgs = __webpack_require__(/*! ./isArguments */ "./node_modules/object-keys/isArguments.js");
|
|
|
|
var origKeys = Object.keys;
|
|
var keysShim = origKeys ? function keys(o) { return origKeys(o); } : __webpack_require__(/*! ./implementation */ "./node_modules/object-keys/implementation.js");
|
|
|
|
var originalKeys = Object.keys;
|
|
|
|
keysShim.shim = function shimObjectKeys() {
|
|
if (Object.keys) {
|
|
var keysWorksWithArguments = (function () {
|
|
// Safari 5.0 bug
|
|
var args = Object.keys(arguments);
|
|
return args && args.length === arguments.length;
|
|
}(1, 2));
|
|
if (!keysWorksWithArguments) {
|
|
Object.keys = function keys(object) { // eslint-disable-line func-name-matching
|
|
if (isArgs(object)) {
|
|
return originalKeys(slice.call(object));
|
|
}
|
|
return originalKeys(object);
|
|
};
|
|
}
|
|
} else {
|
|
Object.keys = keysShim;
|
|
}
|
|
return Object.keys || keysShim;
|
|
};
|
|
|
|
module.exports = keysShim;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/object-keys/isArguments.js":
|
|
/*!*************************************************!*\
|
|
!*** ./node_modules/object-keys/isArguments.js ***!
|
|
\*************************************************/
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var toStr = Object.prototype.toString;
|
|
|
|
module.exports = function isArguments(value) {
|
|
var str = toStr.call(value);
|
|
var isArgs = str === '[object Arguments]';
|
|
if (!isArgs) {
|
|
isArgs = str !== '[object Array]' &&
|
|
value !== null &&
|
|
typeof value === 'object' &&
|
|
typeof value.length === 'number' &&
|
|
value.length >= 0 &&
|
|
toStr.call(value.callee) === '[object Function]';
|
|
}
|
|
return isArgs;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/parchment/dist/parchment.js":
|
|
/*!**************************************************!*\
|
|
!*** ./node_modules/parchment/dist/parchment.js ***!
|
|
\**************************************************/
|
|
/***/ (function(module) {
|
|
|
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
if(true)
|
|
module.exports = factory();
|
|
else {}
|
|
})(typeof self !== 'undefined' ? self : this, function() {
|
|
return /******/ (function(modules) { // webpackBootstrap
|
|
/******/ // The module cache
|
|
/******/ var installedModules = {};
|
|
/******/
|
|
/******/ // The require function
|
|
/******/ function __nested_webpack_require_578__(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, __nested_webpack_require_578__);
|
|
/******/
|
|
/******/ // Flag the module as loaded
|
|
/******/ module.l = true;
|
|
/******/
|
|
/******/ // Return the exports of the module
|
|
/******/ return module.exports;
|
|
/******/ }
|
|
/******/
|
|
/******/
|
|
/******/ // expose the modules object (__webpack_modules__)
|
|
/******/ __nested_webpack_require_578__.m = modules;
|
|
/******/
|
|
/******/ // expose the module cache
|
|
/******/ __nested_webpack_require_578__.c = installedModules;
|
|
/******/
|
|
/******/ // define getter function for harmony exports
|
|
/******/ __nested_webpack_require_578__.d = function(exports, name, getter) {
|
|
/******/ if(!__nested_webpack_require_578__.o(exports, name)) {
|
|
/******/ Object.defineProperty(exports, name, {
|
|
/******/ configurable: false,
|
|
/******/ enumerable: true,
|
|
/******/ get: getter
|
|
/******/ });
|
|
/******/ }
|
|
/******/ };
|
|
/******/
|
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
/******/ __nested_webpack_require_578__.n = function(module) {
|
|
/******/ var getter = module && module.__esModule ?
|
|
/******/ function getDefault() { return module['default']; } :
|
|
/******/ function getModuleExports() { return module; };
|
|
/******/ __nested_webpack_require_578__.d(getter, 'a', getter);
|
|
/******/ return getter;
|
|
/******/ };
|
|
/******/
|
|
/******/ // Object.prototype.hasOwnProperty.call
|
|
/******/ __nested_webpack_require_578__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
/******/
|
|
/******/ // __webpack_public_path__
|
|
/******/ __nested_webpack_require_578__.p = "";
|
|
/******/
|
|
/******/ // Load entry module and return exports
|
|
/******/ return __nested_webpack_require_578__(__nested_webpack_require_578__.s = 9);
|
|
/******/ })
|
|
/************************************************************************/
|
|
/******/ ([
|
|
/* 0 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var ParchmentError = /** @class */ (function (_super) {
|
|
__extends(ParchmentError, _super);
|
|
function ParchmentError(message) {
|
|
var _this = this;
|
|
message = '[Parchment] ' + message;
|
|
_this = _super.call(this, message) || this;
|
|
_this.message = message;
|
|
_this.name = _this.constructor.name;
|
|
return _this;
|
|
}
|
|
return ParchmentError;
|
|
}(Error));
|
|
exports.ParchmentError = ParchmentError;
|
|
var attributes = {};
|
|
var classes = {};
|
|
var tags = {};
|
|
var types = {};
|
|
exports.DATA_KEY = '__blot';
|
|
var Scope;
|
|
(function (Scope) {
|
|
Scope[Scope["TYPE"] = 3] = "TYPE";
|
|
Scope[Scope["LEVEL"] = 12] = "LEVEL";
|
|
Scope[Scope["ATTRIBUTE"] = 13] = "ATTRIBUTE";
|
|
Scope[Scope["BLOT"] = 14] = "BLOT";
|
|
Scope[Scope["INLINE"] = 7] = "INLINE";
|
|
Scope[Scope["BLOCK"] = 11] = "BLOCK";
|
|
Scope[Scope["BLOCK_BLOT"] = 10] = "BLOCK_BLOT";
|
|
Scope[Scope["INLINE_BLOT"] = 6] = "INLINE_BLOT";
|
|
Scope[Scope["BLOCK_ATTRIBUTE"] = 9] = "BLOCK_ATTRIBUTE";
|
|
Scope[Scope["INLINE_ATTRIBUTE"] = 5] = "INLINE_ATTRIBUTE";
|
|
Scope[Scope["ANY"] = 15] = "ANY";
|
|
})(Scope = exports.Scope || (exports.Scope = {}));
|
|
function create(input, value) {
|
|
var match = query(input);
|
|
if (match == null) {
|
|
throw new ParchmentError("Unable to create " + input + " blot");
|
|
}
|
|
var BlotClass = match;
|
|
var node =
|
|
// @ts-ignore
|
|
input instanceof Node || input['nodeType'] === Node.TEXT_NODE ? input : BlotClass.create(value);
|
|
return new BlotClass(node, value);
|
|
}
|
|
exports.create = create;
|
|
function find(node, bubble) {
|
|
if (bubble === void 0) { bubble = false; }
|
|
if (node == null)
|
|
return null;
|
|
// @ts-ignore
|
|
if (node[exports.DATA_KEY] != null)
|
|
return node[exports.DATA_KEY].blot;
|
|
if (bubble)
|
|
return find(node.parentNode, bubble);
|
|
return null;
|
|
}
|
|
exports.find = find;
|
|
function query(query, scope) {
|
|
if (scope === void 0) { scope = Scope.ANY; }
|
|
var match;
|
|
if (typeof query === 'string') {
|
|
match = types[query] || attributes[query];
|
|
// @ts-ignore
|
|
}
|
|
else if (query instanceof Text || query['nodeType'] === Node.TEXT_NODE) {
|
|
match = types['text'];
|
|
}
|
|
else if (typeof query === 'number') {
|
|
if (query & Scope.LEVEL & Scope.BLOCK) {
|
|
match = types['block'];
|
|
}
|
|
else if (query & Scope.LEVEL & Scope.INLINE) {
|
|
match = types['inline'];
|
|
}
|
|
}
|
|
else if (query instanceof HTMLElement) {
|
|
var names = (query.getAttribute('class') || '').split(/\s+/);
|
|
for (var i in names) {
|
|
match = classes[names[i]];
|
|
if (match)
|
|
break;
|
|
}
|
|
match = match || tags[query.tagName];
|
|
}
|
|
if (match == null)
|
|
return null;
|
|
// @ts-ignore
|
|
if (scope & Scope.LEVEL & match.scope && scope & Scope.TYPE & match.scope)
|
|
return match;
|
|
return null;
|
|
}
|
|
exports.query = query;
|
|
function register() {
|
|
var Definitions = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
Definitions[_i] = arguments[_i];
|
|
}
|
|
if (Definitions.length > 1) {
|
|
return Definitions.map(function (d) {
|
|
return register(d);
|
|
});
|
|
}
|
|
var Definition = Definitions[0];
|
|
if (typeof Definition.blotName !== 'string' && typeof Definition.attrName !== 'string') {
|
|
throw new ParchmentError('Invalid definition');
|
|
}
|
|
else if (Definition.blotName === 'abstract') {
|
|
throw new ParchmentError('Cannot register abstract class');
|
|
}
|
|
types[Definition.blotName || Definition.attrName] = Definition;
|
|
if (typeof Definition.keyName === 'string') {
|
|
attributes[Definition.keyName] = Definition;
|
|
}
|
|
else {
|
|
if (Definition.className != null) {
|
|
classes[Definition.className] = Definition;
|
|
}
|
|
if (Definition.tagName != null) {
|
|
if (Array.isArray(Definition.tagName)) {
|
|
Definition.tagName = Definition.tagName.map(function (tagName) {
|
|
return tagName.toUpperCase();
|
|
});
|
|
}
|
|
else {
|
|
Definition.tagName = Definition.tagName.toUpperCase();
|
|
}
|
|
var tagNames = Array.isArray(Definition.tagName) ? Definition.tagName : [Definition.tagName];
|
|
tagNames.forEach(function (tag) {
|
|
if (tags[tag] == null || Definition.className == null) {
|
|
tags[tag] = Definition;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
return Definition;
|
|
}
|
|
exports.register = register;
|
|
|
|
|
|
/***/ }),
|
|
/* 1 */
|
|
/***/ (function(module, exports, __nested_webpack_require_8065__) {
|
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var Registry = __nested_webpack_require_8065__(0);
|
|
var Attributor = /** @class */ (function () {
|
|
function Attributor(attrName, keyName, options) {
|
|
if (options === void 0) { options = {}; }
|
|
this.attrName = attrName;
|
|
this.keyName = keyName;
|
|
var attributeBit = Registry.Scope.TYPE & Registry.Scope.ATTRIBUTE;
|
|
if (options.scope != null) {
|
|
// Ignore type bits, force attribute bit
|
|
this.scope = (options.scope & Registry.Scope.LEVEL) | attributeBit;
|
|
}
|
|
else {
|
|
this.scope = Registry.Scope.ATTRIBUTE;
|
|
}
|
|
if (options.whitelist != null)
|
|
this.whitelist = options.whitelist;
|
|
}
|
|
Attributor.keys = function (node) {
|
|
return [].map.call(node.attributes, function (item) {
|
|
return item.name;
|
|
});
|
|
};
|
|
Attributor.prototype.add = function (node, value) {
|
|
if (!this.canAdd(node, value))
|
|
return false;
|
|
node.setAttribute(this.keyName, value);
|
|
return true;
|
|
};
|
|
Attributor.prototype.canAdd = function (node, value) {
|
|
var match = Registry.query(node, Registry.Scope.BLOT & (this.scope | Registry.Scope.TYPE));
|
|
if (match == null)
|
|
return false;
|
|
if (this.whitelist == null)
|
|
return true;
|
|
if (typeof value === 'string') {
|
|
return this.whitelist.indexOf(value.replace(/["']/g, '')) > -1;
|
|
}
|
|
else {
|
|
return this.whitelist.indexOf(value) > -1;
|
|
}
|
|
};
|
|
Attributor.prototype.remove = function (node) {
|
|
node.removeAttribute(this.keyName);
|
|
};
|
|
Attributor.prototype.value = function (node) {
|
|
var value = node.getAttribute(this.keyName);
|
|
if (this.canAdd(node, value) && value) {
|
|
return value;
|
|
}
|
|
return '';
|
|
};
|
|
return Attributor;
|
|
}());
|
|
exports.default = Attributor;
|
|
|
|
|
|
/***/ }),
|
|
/* 2 */
|
|
/***/ (function(module, exports, __nested_webpack_require_10111__) {
|
|
|
|
"use strict";
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var linked_list_1 = __nested_webpack_require_10111__(11);
|
|
var shadow_1 = __nested_webpack_require_10111__(5);
|
|
var Registry = __nested_webpack_require_10111__(0);
|
|
var ContainerBlot = /** @class */ (function (_super) {
|
|
__extends(ContainerBlot, _super);
|
|
function ContainerBlot(domNode) {
|
|
var _this = _super.call(this, domNode) || this;
|
|
_this.build();
|
|
return _this;
|
|
}
|
|
ContainerBlot.prototype.appendChild = function (other) {
|
|
this.insertBefore(other);
|
|
};
|
|
ContainerBlot.prototype.attach = function () {
|
|
_super.prototype.attach.call(this);
|
|
this.children.forEach(function (child) {
|
|
child.attach();
|
|
});
|
|
};
|
|
ContainerBlot.prototype.build = function () {
|
|
var _this = this;
|
|
this.children = new linked_list_1.default();
|
|
// Need to be reversed for if DOM nodes already in order
|
|
[].slice
|
|
.call(this.domNode.childNodes)
|
|
.reverse()
|
|
.forEach(function (node) {
|
|
try {
|
|
var child = makeBlot(node);
|
|
_this.insertBefore(child, _this.children.head || undefined);
|
|
}
|
|
catch (err) {
|
|
if (err instanceof Registry.ParchmentError)
|
|
return;
|
|
else
|
|
throw err;
|
|
}
|
|
});
|
|
};
|
|
ContainerBlot.prototype.deleteAt = function (index, length) {
|
|
if (index === 0 && length === this.length()) {
|
|
return this.remove();
|
|
}
|
|
this.children.forEachAt(index, length, function (child, offset, length) {
|
|
child.deleteAt(offset, length);
|
|
});
|
|
};
|
|
ContainerBlot.prototype.descendant = function (criteria, index) {
|
|
var _a = this.children.find(index), child = _a[0], offset = _a[1];
|
|
if ((criteria.blotName == null && criteria(child)) ||
|
|
(criteria.blotName != null && child instanceof criteria)) {
|
|
return [child, offset];
|
|
}
|
|
else if (child instanceof ContainerBlot) {
|
|
return child.descendant(criteria, offset);
|
|
}
|
|
else {
|
|
return [null, -1];
|
|
}
|
|
};
|
|
ContainerBlot.prototype.descendants = function (criteria, index, length) {
|
|
if (index === void 0) { index = 0; }
|
|
if (length === void 0) { length = Number.MAX_VALUE; }
|
|
var descendants = [];
|
|
var lengthLeft = length;
|
|
this.children.forEachAt(index, length, function (child, index, length) {
|
|
if ((criteria.blotName == null && criteria(child)) ||
|
|
(criteria.blotName != null && child instanceof criteria)) {
|
|
descendants.push(child);
|
|
}
|
|
if (child instanceof ContainerBlot) {
|
|
descendants = descendants.concat(child.descendants(criteria, index, lengthLeft));
|
|
}
|
|
lengthLeft -= length;
|
|
});
|
|
return descendants;
|
|
};
|
|
ContainerBlot.prototype.detach = function () {
|
|
this.children.forEach(function (child) {
|
|
child.detach();
|
|
});
|
|
_super.prototype.detach.call(this);
|
|
};
|
|
ContainerBlot.prototype.formatAt = function (index, length, name, value) {
|
|
this.children.forEachAt(index, length, function (child, offset, length) {
|
|
child.formatAt(offset, length, name, value);
|
|
});
|
|
};
|
|
ContainerBlot.prototype.insertAt = function (index, value, def) {
|
|
var _a = this.children.find(index), child = _a[0], offset = _a[1];
|
|
if (child) {
|
|
child.insertAt(offset, value, def);
|
|
}
|
|
else {
|
|
var blot = def == null ? Registry.create('text', value) : Registry.create(value, def);
|
|
this.appendChild(blot);
|
|
}
|
|
};
|
|
ContainerBlot.prototype.insertBefore = function (childBlot, refBlot) {
|
|
if (this.statics.allowedChildren != null &&
|
|
!this.statics.allowedChildren.some(function (child) {
|
|
return childBlot instanceof child;
|
|
})) {
|
|
throw new Registry.ParchmentError("Cannot insert " + childBlot.statics.blotName + " into " + this.statics.blotName);
|
|
}
|
|
childBlot.insertInto(this, refBlot);
|
|
};
|
|
ContainerBlot.prototype.length = function () {
|
|
return this.children.reduce(function (memo, child) {
|
|
return memo + child.length();
|
|
}, 0);
|
|
};
|
|
ContainerBlot.prototype.moveChildren = function (targetParent, refNode) {
|
|
this.children.forEach(function (child) {
|
|
targetParent.insertBefore(child, refNode);
|
|
});
|
|
};
|
|
ContainerBlot.prototype.optimize = function (context) {
|
|
_super.prototype.optimize.call(this, context);
|
|
if (this.children.length === 0) {
|
|
if (this.statics.defaultChild != null) {
|
|
var child = Registry.create(this.statics.defaultChild);
|
|
this.appendChild(child);
|
|
child.optimize(context);
|
|
}
|
|
else {
|
|
this.remove();
|
|
}
|
|
}
|
|
};
|
|
ContainerBlot.prototype.path = function (index, inclusive) {
|
|
if (inclusive === void 0) { inclusive = false; }
|
|
var _a = this.children.find(index, inclusive), child = _a[0], offset = _a[1];
|
|
var position = [[this, index]];
|
|
if (child instanceof ContainerBlot) {
|
|
return position.concat(child.path(offset, inclusive));
|
|
}
|
|
else if (child != null) {
|
|
position.push([child, offset]);
|
|
}
|
|
return position;
|
|
};
|
|
ContainerBlot.prototype.removeChild = function (child) {
|
|
this.children.remove(child);
|
|
};
|
|
ContainerBlot.prototype.replace = function (target) {
|
|
if (target instanceof ContainerBlot) {
|
|
target.moveChildren(this);
|
|
}
|
|
_super.prototype.replace.call(this, target);
|
|
};
|
|
ContainerBlot.prototype.split = function (index, force) {
|
|
if (force === void 0) { force = false; }
|
|
if (!force) {
|
|
if (index === 0)
|
|
return this;
|
|
if (index === this.length())
|
|
return this.next;
|
|
}
|
|
var after = this.clone();
|
|
this.parent.insertBefore(after, this.next);
|
|
this.children.forEachAt(index, this.length(), function (child, offset, length) {
|
|
child = child.split(offset, force);
|
|
after.appendChild(child);
|
|
});
|
|
return after;
|
|
};
|
|
ContainerBlot.prototype.unwrap = function () {
|
|
this.moveChildren(this.parent, this.next);
|
|
this.remove();
|
|
};
|
|
ContainerBlot.prototype.update = function (mutations, context) {
|
|
var _this = this;
|
|
var addedNodes = [];
|
|
var removedNodes = [];
|
|
mutations.forEach(function (mutation) {
|
|
if (mutation.target === _this.domNode && mutation.type === 'childList') {
|
|
addedNodes.push.apply(addedNodes, mutation.addedNodes);
|
|
removedNodes.push.apply(removedNodes, mutation.removedNodes);
|
|
}
|
|
});
|
|
removedNodes.forEach(function (node) {
|
|
// Check node has actually been removed
|
|
// One exception is Chrome does not immediately remove IFRAMEs
|
|
// from DOM but MutationRecord is correct in its reported removal
|
|
if (node.parentNode != null &&
|
|
// @ts-ignore
|
|
node.tagName !== 'IFRAME' &&
|
|
document.body.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_CONTAINED_BY) {
|
|
return;
|
|
}
|
|
var blot = Registry.find(node);
|
|
if (blot == null)
|
|
return;
|
|
if (blot.domNode.parentNode == null || blot.domNode.parentNode === _this.domNode) {
|
|
blot.detach();
|
|
}
|
|
});
|
|
addedNodes
|
|
.filter(function (node) {
|
|
return node.parentNode == _this.domNode;
|
|
})
|
|
.sort(function (a, b) {
|
|
if (a === b)
|
|
return 0;
|
|
if (a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING) {
|
|
return 1;
|
|
}
|
|
return -1;
|
|
})
|
|
.forEach(function (node) {
|
|
var refBlot = null;
|
|
if (node.nextSibling != null) {
|
|
refBlot = Registry.find(node.nextSibling);
|
|
}
|
|
var blot = makeBlot(node);
|
|
if (blot.next != refBlot || blot.next == null) {
|
|
if (blot.parent != null) {
|
|
blot.parent.removeChild(_this);
|
|
}
|
|
_this.insertBefore(blot, refBlot || undefined);
|
|
}
|
|
});
|
|
};
|
|
return ContainerBlot;
|
|
}(shadow_1.default));
|
|
function makeBlot(node) {
|
|
var blot = Registry.find(node);
|
|
if (blot == null) {
|
|
try {
|
|
blot = Registry.create(node);
|
|
}
|
|
catch (e) {
|
|
blot = Registry.create(Registry.Scope.INLINE);
|
|
[].slice.call(node.childNodes).forEach(function (child) {
|
|
// @ts-ignore
|
|
blot.domNode.appendChild(child);
|
|
});
|
|
if (node.parentNode) {
|
|
node.parentNode.replaceChild(blot.domNode, node);
|
|
}
|
|
blot.attach();
|
|
}
|
|
}
|
|
return blot;
|
|
}
|
|
exports.default = ContainerBlot;
|
|
|
|
|
|
/***/ }),
|
|
/* 3 */
|
|
/***/ (function(module, exports, __nested_webpack_require_20035__) {
|
|
|
|
"use strict";
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var attributor_1 = __nested_webpack_require_20035__(1);
|
|
var store_1 = __nested_webpack_require_20035__(6);
|
|
var container_1 = __nested_webpack_require_20035__(2);
|
|
var Registry = __nested_webpack_require_20035__(0);
|
|
var FormatBlot = /** @class */ (function (_super) {
|
|
__extends(FormatBlot, _super);
|
|
function FormatBlot(domNode) {
|
|
var _this = _super.call(this, domNode) || this;
|
|
_this.attributes = new store_1.default(_this.domNode);
|
|
return _this;
|
|
}
|
|
FormatBlot.formats = function (domNode) {
|
|
if (typeof this.tagName === 'string') {
|
|
return true;
|
|
}
|
|
else if (Array.isArray(this.tagName)) {
|
|
return domNode.tagName.toLowerCase();
|
|
}
|
|
return undefined;
|
|
};
|
|
FormatBlot.prototype.format = function (name, value) {
|
|
var format = Registry.query(name);
|
|
if (format instanceof attributor_1.default) {
|
|
this.attributes.attribute(format, value);
|
|
}
|
|
else if (value) {
|
|
if (format != null && (name !== this.statics.blotName || this.formats()[name] !== value)) {
|
|
this.replaceWith(name, value);
|
|
}
|
|
}
|
|
};
|
|
FormatBlot.prototype.formats = function () {
|
|
var formats = this.attributes.values();
|
|
var format = this.statics.formats(this.domNode);
|
|
if (format != null) {
|
|
formats[this.statics.blotName] = format;
|
|
}
|
|
return formats;
|
|
};
|
|
FormatBlot.prototype.replaceWith = function (name, value) {
|
|
var replacement = _super.prototype.replaceWith.call(this, name, value);
|
|
this.attributes.copy(replacement);
|
|
return replacement;
|
|
};
|
|
FormatBlot.prototype.update = function (mutations, context) {
|
|
var _this = this;
|
|
_super.prototype.update.call(this, mutations, context);
|
|
if (mutations.some(function (mutation) {
|
|
return mutation.target === _this.domNode && mutation.type === 'attributes';
|
|
})) {
|
|
this.attributes.build();
|
|
}
|
|
};
|
|
FormatBlot.prototype.wrap = function (name, value) {
|
|
var wrapper = _super.prototype.wrap.call(this, name, value);
|
|
if (wrapper instanceof FormatBlot && wrapper.statics.scope === this.statics.scope) {
|
|
this.attributes.move(wrapper);
|
|
}
|
|
return wrapper;
|
|
};
|
|
return FormatBlot;
|
|
}(container_1.default));
|
|
exports.default = FormatBlot;
|
|
|
|
|
|
/***/ }),
|
|
/* 4 */
|
|
/***/ (function(module, exports, __nested_webpack_require_23054__) {
|
|
|
|
"use strict";
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var shadow_1 = __nested_webpack_require_23054__(5);
|
|
var Registry = __nested_webpack_require_23054__(0);
|
|
var LeafBlot = /** @class */ (function (_super) {
|
|
__extends(LeafBlot, _super);
|
|
function LeafBlot() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
LeafBlot.value = function (domNode) {
|
|
return true;
|
|
};
|
|
LeafBlot.prototype.index = function (node, offset) {
|
|
if (this.domNode === node ||
|
|
this.domNode.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_CONTAINED_BY) {
|
|
return Math.min(offset, 1);
|
|
}
|
|
return -1;
|
|
};
|
|
LeafBlot.prototype.position = function (index, inclusive) {
|
|
var offset = [].indexOf.call(this.parent.domNode.childNodes, this.domNode);
|
|
if (index > 0)
|
|
offset += 1;
|
|
return [this.parent.domNode, offset];
|
|
};
|
|
LeafBlot.prototype.value = function () {
|
|
return _a = {}, _a[this.statics.blotName] = this.statics.value(this.domNode) || true, _a;
|
|
var _a;
|
|
};
|
|
LeafBlot.scope = Registry.Scope.INLINE_BLOT;
|
|
return LeafBlot;
|
|
}(shadow_1.default));
|
|
exports.default = LeafBlot;
|
|
|
|
|
|
/***/ }),
|
|
/* 5 */
|
|
/***/ (function(module, exports, __nested_webpack_require_24839__) {
|
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var Registry = __nested_webpack_require_24839__(0);
|
|
var ShadowBlot = /** @class */ (function () {
|
|
function ShadowBlot(domNode) {
|
|
this.domNode = domNode;
|
|
// @ts-ignore
|
|
this.domNode[Registry.DATA_KEY] = { blot: this };
|
|
}
|
|
Object.defineProperty(ShadowBlot.prototype, "statics", {
|
|
// Hack for accessing inherited static methods
|
|
get: function () {
|
|
return this.constructor;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
ShadowBlot.create = function (value) {
|
|
if (this.tagName == null) {
|
|
throw new Registry.ParchmentError('Blot definition missing tagName');
|
|
}
|
|
var node;
|
|
if (Array.isArray(this.tagName)) {
|
|
if (typeof value === 'string') {
|
|
value = value.toUpperCase();
|
|
if (parseInt(value).toString() === value) {
|
|
value = parseInt(value);
|
|
}
|
|
}
|
|
if (typeof value === 'number') {
|
|
node = document.createElement(this.tagName[value - 1]);
|
|
}
|
|
else if (this.tagName.indexOf(value) > -1) {
|
|
node = document.createElement(value);
|
|
}
|
|
else {
|
|
node = document.createElement(this.tagName[0]);
|
|
}
|
|
}
|
|
else {
|
|
node = document.createElement(this.tagName);
|
|
}
|
|
if (this.className) {
|
|
node.classList.add(this.className);
|
|
}
|
|
return node;
|
|
};
|
|
ShadowBlot.prototype.attach = function () {
|
|
if (this.parent != null) {
|
|
this.scroll = this.parent.scroll;
|
|
}
|
|
};
|
|
ShadowBlot.prototype.clone = function () {
|
|
var domNode = this.domNode.cloneNode(false);
|
|
return Registry.create(domNode);
|
|
};
|
|
ShadowBlot.prototype.detach = function () {
|
|
if (this.parent != null)
|
|
this.parent.removeChild(this);
|
|
// @ts-ignore
|
|
delete this.domNode[Registry.DATA_KEY];
|
|
};
|
|
ShadowBlot.prototype.deleteAt = function (index, length) {
|
|
var blot = this.isolate(index, length);
|
|
blot.remove();
|
|
};
|
|
ShadowBlot.prototype.formatAt = function (index, length, name, value) {
|
|
var blot = this.isolate(index, length);
|
|
if (Registry.query(name, Registry.Scope.BLOT) != null && value) {
|
|
blot.wrap(name, value);
|
|
}
|
|
else if (Registry.query(name, Registry.Scope.ATTRIBUTE) != null) {
|
|
var parent_1 = Registry.create(this.statics.scope);
|
|
blot.wrap(parent_1);
|
|
parent_1.format(name, value);
|
|
}
|
|
};
|
|
ShadowBlot.prototype.insertAt = function (index, value, def) {
|
|
var blot = def == null ? Registry.create('text', value) : Registry.create(value, def);
|
|
var ref = this.split(index);
|
|
this.parent.insertBefore(blot, ref);
|
|
};
|
|
ShadowBlot.prototype.insertInto = function (parentBlot, refBlot) {
|
|
if (refBlot === void 0) { refBlot = null; }
|
|
if (this.parent != null) {
|
|
this.parent.children.remove(this);
|
|
}
|
|
var refDomNode = null;
|
|
parentBlot.children.insertBefore(this, refBlot);
|
|
if (refBlot != null) {
|
|
refDomNode = refBlot.domNode;
|
|
}
|
|
if (this.domNode.parentNode != parentBlot.domNode ||
|
|
this.domNode.nextSibling != refDomNode) {
|
|
parentBlot.domNode.insertBefore(this.domNode, refDomNode);
|
|
}
|
|
this.parent = parentBlot;
|
|
this.attach();
|
|
};
|
|
ShadowBlot.prototype.isolate = function (index, length) {
|
|
var target = this.split(index);
|
|
target.split(length);
|
|
return target;
|
|
};
|
|
ShadowBlot.prototype.length = function () {
|
|
return 1;
|
|
};
|
|
ShadowBlot.prototype.offset = function (root) {
|
|
if (root === void 0) { root = this.parent; }
|
|
if (this.parent == null || this == root)
|
|
return 0;
|
|
return this.parent.children.offset(this) + this.parent.offset(root);
|
|
};
|
|
ShadowBlot.prototype.optimize = function (context) {
|
|
// TODO clean up once we use WeakMap
|
|
// @ts-ignore
|
|
if (this.domNode[Registry.DATA_KEY] != null) {
|
|
// @ts-ignore
|
|
delete this.domNode[Registry.DATA_KEY].mutations;
|
|
}
|
|
};
|
|
ShadowBlot.prototype.remove = function () {
|
|
if (this.domNode.parentNode != null) {
|
|
this.domNode.parentNode.removeChild(this.domNode);
|
|
}
|
|
this.detach();
|
|
};
|
|
ShadowBlot.prototype.replace = function (target) {
|
|
if (target.parent == null)
|
|
return;
|
|
target.parent.insertBefore(this, target.next);
|
|
target.remove();
|
|
};
|
|
ShadowBlot.prototype.replaceWith = function (name, value) {
|
|
var replacement = typeof name === 'string' ? Registry.create(name, value) : name;
|
|
replacement.replace(this);
|
|
return replacement;
|
|
};
|
|
ShadowBlot.prototype.split = function (index, force) {
|
|
return index === 0 ? this : this.next;
|
|
};
|
|
ShadowBlot.prototype.update = function (mutations, context) {
|
|
// Nothing to do by default
|
|
};
|
|
ShadowBlot.prototype.wrap = function (name, value) {
|
|
var wrapper = typeof name === 'string' ? Registry.create(name, value) : name;
|
|
if (this.parent != null) {
|
|
this.parent.insertBefore(wrapper, this.next);
|
|
}
|
|
wrapper.appendChild(this);
|
|
return wrapper;
|
|
};
|
|
ShadowBlot.blotName = 'abstract';
|
|
return ShadowBlot;
|
|
}());
|
|
exports.default = ShadowBlot;
|
|
|
|
|
|
/***/ }),
|
|
/* 6 */
|
|
/***/ (function(module, exports, __nested_webpack_require_30541__) {
|
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var attributor_1 = __nested_webpack_require_30541__(1);
|
|
var class_1 = __nested_webpack_require_30541__(7);
|
|
var style_1 = __nested_webpack_require_30541__(8);
|
|
var Registry = __nested_webpack_require_30541__(0);
|
|
var AttributorStore = /** @class */ (function () {
|
|
function AttributorStore(domNode) {
|
|
this.attributes = {};
|
|
this.domNode = domNode;
|
|
this.build();
|
|
}
|
|
AttributorStore.prototype.attribute = function (attribute, value) {
|
|
// verb
|
|
if (value) {
|
|
if (attribute.add(this.domNode, value)) {
|
|
if (attribute.value(this.domNode) != null) {
|
|
this.attributes[attribute.attrName] = attribute;
|
|
}
|
|
else {
|
|
delete this.attributes[attribute.attrName];
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
attribute.remove(this.domNode);
|
|
delete this.attributes[attribute.attrName];
|
|
}
|
|
};
|
|
AttributorStore.prototype.build = function () {
|
|
var _this = this;
|
|
this.attributes = {};
|
|
var attributes = attributor_1.default.keys(this.domNode);
|
|
var classes = class_1.default.keys(this.domNode);
|
|
var styles = style_1.default.keys(this.domNode);
|
|
attributes
|
|
.concat(classes)
|
|
.concat(styles)
|
|
.forEach(function (name) {
|
|
var attr = Registry.query(name, Registry.Scope.ATTRIBUTE);
|
|
if (attr instanceof attributor_1.default) {
|
|
_this.attributes[attr.attrName] = attr;
|
|
}
|
|
});
|
|
};
|
|
AttributorStore.prototype.copy = function (target) {
|
|
var _this = this;
|
|
Object.keys(this.attributes).forEach(function (key) {
|
|
var value = _this.attributes[key].value(_this.domNode);
|
|
target.format(key, value);
|
|
});
|
|
};
|
|
AttributorStore.prototype.move = function (target) {
|
|
var _this = this;
|
|
this.copy(target);
|
|
Object.keys(this.attributes).forEach(function (key) {
|
|
_this.attributes[key].remove(_this.domNode);
|
|
});
|
|
this.attributes = {};
|
|
};
|
|
AttributorStore.prototype.values = function () {
|
|
var _this = this;
|
|
return Object.keys(this.attributes).reduce(function (attributes, name) {
|
|
attributes[name] = _this.attributes[name].value(_this.domNode);
|
|
return attributes;
|
|
}, {});
|
|
};
|
|
return AttributorStore;
|
|
}());
|
|
exports.default = AttributorStore;
|
|
|
|
|
|
/***/ }),
|
|
/* 7 */
|
|
/***/ (function(module, exports, __nested_webpack_require_33135__) {
|
|
|
|
"use strict";
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var attributor_1 = __nested_webpack_require_33135__(1);
|
|
function match(node, prefix) {
|
|
var className = node.getAttribute('class') || '';
|
|
return className.split(/\s+/).filter(function (name) {
|
|
return name.indexOf(prefix + "-") === 0;
|
|
});
|
|
}
|
|
var ClassAttributor = /** @class */ (function (_super) {
|
|
__extends(ClassAttributor, _super);
|
|
function ClassAttributor() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
ClassAttributor.keys = function (node) {
|
|
return (node.getAttribute('class') || '').split(/\s+/).map(function (name) {
|
|
return name
|
|
.split('-')
|
|
.slice(0, -1)
|
|
.join('-');
|
|
});
|
|
};
|
|
ClassAttributor.prototype.add = function (node, value) {
|
|
if (!this.canAdd(node, value))
|
|
return false;
|
|
this.remove(node);
|
|
node.classList.add(this.keyName + "-" + value);
|
|
return true;
|
|
};
|
|
ClassAttributor.prototype.remove = function (node) {
|
|
var matches = match(node, this.keyName);
|
|
matches.forEach(function (name) {
|
|
node.classList.remove(name);
|
|
});
|
|
if (node.classList.length === 0) {
|
|
node.removeAttribute('class');
|
|
}
|
|
};
|
|
ClassAttributor.prototype.value = function (node) {
|
|
var result = match(node, this.keyName)[0] || '';
|
|
var value = result.slice(this.keyName.length + 1); // +1 for hyphen
|
|
return this.canAdd(node, value) ? value : '';
|
|
};
|
|
return ClassAttributor;
|
|
}(attributor_1.default));
|
|
exports.default = ClassAttributor;
|
|
|
|
|
|
/***/ }),
|
|
/* 8 */
|
|
/***/ (function(module, exports, __nested_webpack_require_35377__) {
|
|
|
|
"use strict";
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var attributor_1 = __nested_webpack_require_35377__(1);
|
|
function camelize(name) {
|
|
var parts = name.split('-');
|
|
var rest = parts
|
|
.slice(1)
|
|
.map(function (part) {
|
|
return part[0].toUpperCase() + part.slice(1);
|
|
})
|
|
.join('');
|
|
return parts[0] + rest;
|
|
}
|
|
var StyleAttributor = /** @class */ (function (_super) {
|
|
__extends(StyleAttributor, _super);
|
|
function StyleAttributor() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
StyleAttributor.keys = function (node) {
|
|
return (node.getAttribute('style') || '').split(';').map(function (value) {
|
|
var arr = value.split(':');
|
|
return arr[0].trim();
|
|
});
|
|
};
|
|
StyleAttributor.prototype.add = function (node, value) {
|
|
if (!this.canAdd(node, value))
|
|
return false;
|
|
// @ts-ignore
|
|
node.style[camelize(this.keyName)] = value;
|
|
return true;
|
|
};
|
|
StyleAttributor.prototype.remove = function (node) {
|
|
// @ts-ignore
|
|
node.style[camelize(this.keyName)] = '';
|
|
if (!node.getAttribute('style')) {
|
|
node.removeAttribute('style');
|
|
}
|
|
};
|
|
StyleAttributor.prototype.value = function (node) {
|
|
// @ts-ignore
|
|
var value = node.style[camelize(this.keyName)];
|
|
return this.canAdd(node, value) ? value : '';
|
|
};
|
|
return StyleAttributor;
|
|
}(attributor_1.default));
|
|
exports.default = StyleAttributor;
|
|
|
|
|
|
/***/ }),
|
|
/* 9 */
|
|
/***/ (function(module, exports, __nested_webpack_require_37481__) {
|
|
|
|
module.exports = __nested_webpack_require_37481__(10);
|
|
|
|
|
|
/***/ }),
|
|
/* 10 */
|
|
/***/ (function(module, exports, __nested_webpack_require_37601__) {
|
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var container_1 = __nested_webpack_require_37601__(2);
|
|
var format_1 = __nested_webpack_require_37601__(3);
|
|
var leaf_1 = __nested_webpack_require_37601__(4);
|
|
var scroll_1 = __nested_webpack_require_37601__(12);
|
|
var inline_1 = __nested_webpack_require_37601__(13);
|
|
var block_1 = __nested_webpack_require_37601__(14);
|
|
var embed_1 = __nested_webpack_require_37601__(15);
|
|
var text_1 = __nested_webpack_require_37601__(16);
|
|
var attributor_1 = __nested_webpack_require_37601__(1);
|
|
var class_1 = __nested_webpack_require_37601__(7);
|
|
var style_1 = __nested_webpack_require_37601__(8);
|
|
var store_1 = __nested_webpack_require_37601__(6);
|
|
var Registry = __nested_webpack_require_37601__(0);
|
|
var Parchment = {
|
|
Scope: Registry.Scope,
|
|
create: Registry.create,
|
|
find: Registry.find,
|
|
query: Registry.query,
|
|
register: Registry.register,
|
|
Container: container_1.default,
|
|
Format: format_1.default,
|
|
Leaf: leaf_1.default,
|
|
Embed: embed_1.default,
|
|
Scroll: scroll_1.default,
|
|
Block: block_1.default,
|
|
Inline: inline_1.default,
|
|
Text: text_1.default,
|
|
Attributor: {
|
|
Attribute: attributor_1.default,
|
|
Class: class_1.default,
|
|
Style: style_1.default,
|
|
Store: store_1.default,
|
|
},
|
|
};
|
|
exports.default = Parchment;
|
|
|
|
|
|
/***/ }),
|
|
/* 11 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var LinkedList = /** @class */ (function () {
|
|
function LinkedList() {
|
|
this.head = this.tail = null;
|
|
this.length = 0;
|
|
}
|
|
LinkedList.prototype.append = function () {
|
|
var nodes = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
nodes[_i] = arguments[_i];
|
|
}
|
|
this.insertBefore(nodes[0], null);
|
|
if (nodes.length > 1) {
|
|
this.append.apply(this, nodes.slice(1));
|
|
}
|
|
};
|
|
LinkedList.prototype.contains = function (node) {
|
|
var cur, next = this.iterator();
|
|
while ((cur = next())) {
|
|
if (cur === node)
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
LinkedList.prototype.insertBefore = function (node, refNode) {
|
|
if (!node)
|
|
return;
|
|
node.next = refNode;
|
|
if (refNode != null) {
|
|
node.prev = refNode.prev;
|
|
if (refNode.prev != null) {
|
|
refNode.prev.next = node;
|
|
}
|
|
refNode.prev = node;
|
|
if (refNode === this.head) {
|
|
this.head = node;
|
|
}
|
|
}
|
|
else if (this.tail != null) {
|
|
this.tail.next = node;
|
|
node.prev = this.tail;
|
|
this.tail = node;
|
|
}
|
|
else {
|
|
node.prev = null;
|
|
this.head = this.tail = node;
|
|
}
|
|
this.length += 1;
|
|
};
|
|
LinkedList.prototype.offset = function (target) {
|
|
var index = 0, cur = this.head;
|
|
while (cur != null) {
|
|
if (cur === target)
|
|
return index;
|
|
index += cur.length();
|
|
cur = cur.next;
|
|
}
|
|
return -1;
|
|
};
|
|
LinkedList.prototype.remove = function (node) {
|
|
if (!this.contains(node))
|
|
return;
|
|
if (node.prev != null)
|
|
node.prev.next = node.next;
|
|
if (node.next != null)
|
|
node.next.prev = node.prev;
|
|
if (node === this.head)
|
|
this.head = node.next;
|
|
if (node === this.tail)
|
|
this.tail = node.prev;
|
|
this.length -= 1;
|
|
};
|
|
LinkedList.prototype.iterator = function (curNode) {
|
|
if (curNode === void 0) { curNode = this.head; }
|
|
// TODO use yield when we can
|
|
return function () {
|
|
var ret = curNode;
|
|
if (curNode != null)
|
|
curNode = curNode.next;
|
|
return ret;
|
|
};
|
|
};
|
|
LinkedList.prototype.find = function (index, inclusive) {
|
|
if (inclusive === void 0) { inclusive = false; }
|
|
var cur, next = this.iterator();
|
|
while ((cur = next())) {
|
|
var length_1 = cur.length();
|
|
if (index < length_1 ||
|
|
(inclusive && index === length_1 && (cur.next == null || cur.next.length() !== 0))) {
|
|
return [cur, index];
|
|
}
|
|
index -= length_1;
|
|
}
|
|
return [null, 0];
|
|
};
|
|
LinkedList.prototype.forEach = function (callback) {
|
|
var cur, next = this.iterator();
|
|
while ((cur = next())) {
|
|
callback(cur);
|
|
}
|
|
};
|
|
LinkedList.prototype.forEachAt = function (index, length, callback) {
|
|
if (length <= 0)
|
|
return;
|
|
var _a = this.find(index), startNode = _a[0], offset = _a[1];
|
|
var cur, curIndex = index - offset, next = this.iterator(startNode);
|
|
while ((cur = next()) && curIndex < index + length) {
|
|
var curLength = cur.length();
|
|
if (index > curIndex) {
|
|
callback(cur, index - curIndex, Math.min(length, curIndex + curLength - index));
|
|
}
|
|
else {
|
|
callback(cur, 0, Math.min(curLength, index + length - curIndex));
|
|
}
|
|
curIndex += curLength;
|
|
}
|
|
};
|
|
LinkedList.prototype.map = function (callback) {
|
|
return this.reduce(function (memo, cur) {
|
|
memo.push(callback(cur));
|
|
return memo;
|
|
}, []);
|
|
};
|
|
LinkedList.prototype.reduce = function (callback, memo) {
|
|
var cur, next = this.iterator();
|
|
while ((cur = next())) {
|
|
memo = callback(memo, cur);
|
|
}
|
|
return memo;
|
|
};
|
|
return LinkedList;
|
|
}());
|
|
exports.default = LinkedList;
|
|
|
|
|
|
/***/ }),
|
|
/* 12 */
|
|
/***/ (function(module, exports, __nested_webpack_require_43256__) {
|
|
|
|
"use strict";
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var container_1 = __nested_webpack_require_43256__(2);
|
|
var Registry = __nested_webpack_require_43256__(0);
|
|
var OBSERVER_CONFIG = {
|
|
attributes: true,
|
|
characterData: true,
|
|
characterDataOldValue: true,
|
|
childList: true,
|
|
subtree: true,
|
|
};
|
|
var MAX_OPTIMIZE_ITERATIONS = 100;
|
|
var ScrollBlot = /** @class */ (function (_super) {
|
|
__extends(ScrollBlot, _super);
|
|
function ScrollBlot(node) {
|
|
var _this = _super.call(this, node) || this;
|
|
_this.scroll = _this;
|
|
_this.observer = new MutationObserver(function (mutations) {
|
|
_this.update(mutations);
|
|
});
|
|
_this.observer.observe(_this.domNode, OBSERVER_CONFIG);
|
|
_this.attach();
|
|
return _this;
|
|
}
|
|
ScrollBlot.prototype.detach = function () {
|
|
_super.prototype.detach.call(this);
|
|
this.observer.disconnect();
|
|
};
|
|
ScrollBlot.prototype.deleteAt = function (index, length) {
|
|
this.update();
|
|
if (index === 0 && length === this.length()) {
|
|
this.children.forEach(function (child) {
|
|
child.remove();
|
|
});
|
|
}
|
|
else {
|
|
_super.prototype.deleteAt.call(this, index, length);
|
|
}
|
|
};
|
|
ScrollBlot.prototype.formatAt = function (index, length, name, value) {
|
|
this.update();
|
|
_super.prototype.formatAt.call(this, index, length, name, value);
|
|
};
|
|
ScrollBlot.prototype.insertAt = function (index, value, def) {
|
|
this.update();
|
|
_super.prototype.insertAt.call(this, index, value, def);
|
|
};
|
|
ScrollBlot.prototype.optimize = function (mutations, context) {
|
|
var _this = this;
|
|
if (mutations === void 0) { mutations = []; }
|
|
if (context === void 0) { context = {}; }
|
|
_super.prototype.optimize.call(this, context);
|
|
// We must modify mutations directly, cannot make copy and then modify
|
|
var records = [].slice.call(this.observer.takeRecords());
|
|
// Array.push currently seems to be implemented by a non-tail recursive function
|
|
// so we cannot just mutations.push.apply(mutations, this.observer.takeRecords());
|
|
while (records.length > 0)
|
|
mutations.push(records.pop());
|
|
// TODO use WeakMap
|
|
var mark = function (blot, markParent) {
|
|
if (markParent === void 0) { markParent = true; }
|
|
if (blot == null || blot === _this)
|
|
return;
|
|
if (blot.domNode.parentNode == null)
|
|
return;
|
|
// @ts-ignore
|
|
if (blot.domNode[Registry.DATA_KEY].mutations == null) {
|
|
// @ts-ignore
|
|
blot.domNode[Registry.DATA_KEY].mutations = [];
|
|
}
|
|
if (markParent)
|
|
mark(blot.parent);
|
|
};
|
|
var optimize = function (blot) {
|
|
// Post-order traversal
|
|
if (
|
|
// @ts-ignore
|
|
blot.domNode[Registry.DATA_KEY] == null ||
|
|
// @ts-ignore
|
|
blot.domNode[Registry.DATA_KEY].mutations == null) {
|
|
return;
|
|
}
|
|
if (blot instanceof container_1.default) {
|
|
blot.children.forEach(optimize);
|
|
}
|
|
blot.optimize(context);
|
|
};
|
|
var remaining = mutations;
|
|
for (var i = 0; remaining.length > 0; i += 1) {
|
|
if (i >= MAX_OPTIMIZE_ITERATIONS) {
|
|
throw new Error('[Parchment] Maximum optimize iterations reached');
|
|
}
|
|
remaining.forEach(function (mutation) {
|
|
var blot = Registry.find(mutation.target, true);
|
|
if (blot == null)
|
|
return;
|
|
if (blot.domNode === mutation.target) {
|
|
if (mutation.type === 'childList') {
|
|
mark(Registry.find(mutation.previousSibling, false));
|
|
[].forEach.call(mutation.addedNodes, function (node) {
|
|
var child = Registry.find(node, false);
|
|
mark(child, false);
|
|
if (child instanceof container_1.default) {
|
|
child.children.forEach(function (grandChild) {
|
|
mark(grandChild, false);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
else if (mutation.type === 'attributes') {
|
|
mark(blot.prev);
|
|
}
|
|
}
|
|
mark(blot);
|
|
});
|
|
this.children.forEach(optimize);
|
|
remaining = [].slice.call(this.observer.takeRecords());
|
|
records = remaining.slice();
|
|
while (records.length > 0)
|
|
mutations.push(records.pop());
|
|
}
|
|
};
|
|
ScrollBlot.prototype.update = function (mutations, context) {
|
|
var _this = this;
|
|
if (context === void 0) { context = {}; }
|
|
mutations = mutations || this.observer.takeRecords();
|
|
// TODO use WeakMap
|
|
mutations
|
|
.map(function (mutation) {
|
|
var blot = Registry.find(mutation.target, true);
|
|
if (blot == null)
|
|
return null;
|
|
// @ts-ignore
|
|
if (blot.domNode[Registry.DATA_KEY].mutations == null) {
|
|
// @ts-ignore
|
|
blot.domNode[Registry.DATA_KEY].mutations = [mutation];
|
|
return blot;
|
|
}
|
|
else {
|
|
// @ts-ignore
|
|
blot.domNode[Registry.DATA_KEY].mutations.push(mutation);
|
|
return null;
|
|
}
|
|
})
|
|
.forEach(function (blot) {
|
|
if (blot == null ||
|
|
blot === _this ||
|
|
//@ts-ignore
|
|
blot.domNode[Registry.DATA_KEY] == null)
|
|
return;
|
|
// @ts-ignore
|
|
blot.update(blot.domNode[Registry.DATA_KEY].mutations || [], context);
|
|
});
|
|
// @ts-ignore
|
|
if (this.domNode[Registry.DATA_KEY].mutations != null) {
|
|
// @ts-ignore
|
|
_super.prototype.update.call(this, this.domNode[Registry.DATA_KEY].mutations, context);
|
|
}
|
|
this.optimize(mutations, context);
|
|
};
|
|
ScrollBlot.blotName = 'scroll';
|
|
ScrollBlot.defaultChild = 'block';
|
|
ScrollBlot.scope = Registry.Scope.BLOCK_BLOT;
|
|
ScrollBlot.tagName = 'DIV';
|
|
return ScrollBlot;
|
|
}(container_1.default));
|
|
exports.default = ScrollBlot;
|
|
|
|
|
|
/***/ }),
|
|
/* 13 */
|
|
/***/ (function(module, exports, __nested_webpack_require_50369__) {
|
|
|
|
"use strict";
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var format_1 = __nested_webpack_require_50369__(3);
|
|
var Registry = __nested_webpack_require_50369__(0);
|
|
// Shallow object comparison
|
|
function isEqual(obj1, obj2) {
|
|
if (Object.keys(obj1).length !== Object.keys(obj2).length)
|
|
return false;
|
|
// @ts-ignore
|
|
for (var prop in obj1) {
|
|
// @ts-ignore
|
|
if (obj1[prop] !== obj2[prop])
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
var InlineBlot = /** @class */ (function (_super) {
|
|
__extends(InlineBlot, _super);
|
|
function InlineBlot() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
InlineBlot.formats = function (domNode) {
|
|
if (domNode.tagName === InlineBlot.tagName)
|
|
return undefined;
|
|
return _super.formats.call(this, domNode);
|
|
};
|
|
InlineBlot.prototype.format = function (name, value) {
|
|
var _this = this;
|
|
if (name === this.statics.blotName && !value) {
|
|
this.children.forEach(function (child) {
|
|
if (!(child instanceof format_1.default)) {
|
|
child = child.wrap(InlineBlot.blotName, true);
|
|
}
|
|
_this.attributes.copy(child);
|
|
});
|
|
this.unwrap();
|
|
}
|
|
else {
|
|
_super.prototype.format.call(this, name, value);
|
|
}
|
|
};
|
|
InlineBlot.prototype.formatAt = function (index, length, name, value) {
|
|
if (this.formats()[name] != null || Registry.query(name, Registry.Scope.ATTRIBUTE)) {
|
|
var blot = this.isolate(index, length);
|
|
blot.format(name, value);
|
|
}
|
|
else {
|
|
_super.prototype.formatAt.call(this, index, length, name, value);
|
|
}
|
|
};
|
|
InlineBlot.prototype.optimize = function (context) {
|
|
_super.prototype.optimize.call(this, context);
|
|
var formats = this.formats();
|
|
if (Object.keys(formats).length === 0) {
|
|
return this.unwrap(); // unformatted span
|
|
}
|
|
var next = this.next;
|
|
if (next instanceof InlineBlot && next.prev === this && isEqual(formats, next.formats())) {
|
|
next.moveChildren(this);
|
|
next.remove();
|
|
}
|
|
};
|
|
InlineBlot.blotName = 'inline';
|
|
InlineBlot.scope = Registry.Scope.INLINE_BLOT;
|
|
InlineBlot.tagName = 'SPAN';
|
|
return InlineBlot;
|
|
}(format_1.default));
|
|
exports.default = InlineBlot;
|
|
|
|
|
|
/***/ }),
|
|
/* 14 */
|
|
/***/ (function(module, exports, __nested_webpack_require_53360__) {
|
|
|
|
"use strict";
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var format_1 = __nested_webpack_require_53360__(3);
|
|
var Registry = __nested_webpack_require_53360__(0);
|
|
var BlockBlot = /** @class */ (function (_super) {
|
|
__extends(BlockBlot, _super);
|
|
function BlockBlot() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
BlockBlot.formats = function (domNode) {
|
|
var tagName = Registry.query(BlockBlot.blotName).tagName;
|
|
if (domNode.tagName === tagName)
|
|
return undefined;
|
|
return _super.formats.call(this, domNode);
|
|
};
|
|
BlockBlot.prototype.format = function (name, value) {
|
|
if (Registry.query(name, Registry.Scope.BLOCK) == null) {
|
|
return;
|
|
}
|
|
else if (name === this.statics.blotName && !value) {
|
|
this.replaceWith(BlockBlot.blotName);
|
|
}
|
|
else {
|
|
_super.prototype.format.call(this, name, value);
|
|
}
|
|
};
|
|
BlockBlot.prototype.formatAt = function (index, length, name, value) {
|
|
if (Registry.query(name, Registry.Scope.BLOCK) != null) {
|
|
this.format(name, value);
|
|
}
|
|
else {
|
|
_super.prototype.formatAt.call(this, index, length, name, value);
|
|
}
|
|
};
|
|
BlockBlot.prototype.insertAt = function (index, value, def) {
|
|
if (def == null || Registry.query(value, Registry.Scope.INLINE) != null) {
|
|
// Insert text or inline
|
|
_super.prototype.insertAt.call(this, index, value, def);
|
|
}
|
|
else {
|
|
var after = this.split(index);
|
|
var blot = Registry.create(value, def);
|
|
after.parent.insertBefore(blot, after);
|
|
}
|
|
};
|
|
BlockBlot.prototype.update = function (mutations, context) {
|
|
if (navigator.userAgent.match(/Trident/)) {
|
|
this.build();
|
|
}
|
|
else {
|
|
_super.prototype.update.call(this, mutations, context);
|
|
}
|
|
};
|
|
BlockBlot.blotName = 'block';
|
|
BlockBlot.scope = Registry.Scope.BLOCK_BLOT;
|
|
BlockBlot.tagName = 'P';
|
|
return BlockBlot;
|
|
}(format_1.default));
|
|
exports.default = BlockBlot;
|
|
|
|
|
|
/***/ }),
|
|
/* 15 */
|
|
/***/ (function(module, exports, __nested_webpack_require_56067__) {
|
|
|
|
"use strict";
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var leaf_1 = __nested_webpack_require_56067__(4);
|
|
var EmbedBlot = /** @class */ (function (_super) {
|
|
__extends(EmbedBlot, _super);
|
|
function EmbedBlot() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
EmbedBlot.formats = function (domNode) {
|
|
return undefined;
|
|
};
|
|
EmbedBlot.prototype.format = function (name, value) {
|
|
// super.formatAt wraps, which is what we want in general,
|
|
// but this allows subclasses to overwrite for formats
|
|
// that just apply to particular embeds
|
|
_super.prototype.formatAt.call(this, 0, this.length(), name, value);
|
|
};
|
|
EmbedBlot.prototype.formatAt = function (index, length, name, value) {
|
|
if (index === 0 && length === this.length()) {
|
|
this.format(name, value);
|
|
}
|
|
else {
|
|
_super.prototype.formatAt.call(this, index, length, name, value);
|
|
}
|
|
};
|
|
EmbedBlot.prototype.formats = function () {
|
|
return this.statics.formats(this.domNode);
|
|
};
|
|
return EmbedBlot;
|
|
}(leaf_1.default));
|
|
exports.default = EmbedBlot;
|
|
|
|
|
|
/***/ }),
|
|
/* 16 */
|
|
/***/ (function(module, exports, __nested_webpack_require_57807__) {
|
|
|
|
"use strict";
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var leaf_1 = __nested_webpack_require_57807__(4);
|
|
var Registry = __nested_webpack_require_57807__(0);
|
|
var TextBlot = /** @class */ (function (_super) {
|
|
__extends(TextBlot, _super);
|
|
function TextBlot(node) {
|
|
var _this = _super.call(this, node) || this;
|
|
_this.text = _this.statics.value(_this.domNode);
|
|
return _this;
|
|
}
|
|
TextBlot.create = function (value) {
|
|
return document.createTextNode(value);
|
|
};
|
|
TextBlot.value = function (domNode) {
|
|
var text = domNode.data;
|
|
// @ts-ignore
|
|
if (text['normalize'])
|
|
text = text['normalize']();
|
|
return text;
|
|
};
|
|
TextBlot.prototype.deleteAt = function (index, length) {
|
|
this.domNode.data = this.text = this.text.slice(0, index) + this.text.slice(index + length);
|
|
};
|
|
TextBlot.prototype.index = function (node, offset) {
|
|
if (this.domNode === node) {
|
|
return offset;
|
|
}
|
|
return -1;
|
|
};
|
|
TextBlot.prototype.insertAt = function (index, value, def) {
|
|
if (def == null) {
|
|
this.text = this.text.slice(0, index) + value + this.text.slice(index);
|
|
this.domNode.data = this.text;
|
|
}
|
|
else {
|
|
_super.prototype.insertAt.call(this, index, value, def);
|
|
}
|
|
};
|
|
TextBlot.prototype.length = function () {
|
|
return this.text.length;
|
|
};
|
|
TextBlot.prototype.optimize = function (context) {
|
|
_super.prototype.optimize.call(this, context);
|
|
this.text = this.statics.value(this.domNode);
|
|
if (this.text.length === 0) {
|
|
this.remove();
|
|
}
|
|
else if (this.next instanceof TextBlot && this.next.prev === this) {
|
|
this.insertAt(this.length(), this.next.value());
|
|
this.next.remove();
|
|
}
|
|
};
|
|
TextBlot.prototype.position = function (index, inclusive) {
|
|
if (inclusive === void 0) { inclusive = false; }
|
|
return [this.domNode, index];
|
|
};
|
|
TextBlot.prototype.split = function (index, force) {
|
|
if (force === void 0) { force = false; }
|
|
if (!force) {
|
|
if (index === 0)
|
|
return this;
|
|
if (index === this.length())
|
|
return this.next;
|
|
}
|
|
var after = Registry.create(this.domNode.splitText(index));
|
|
this.parent.insertBefore(after, this.next);
|
|
this.text = this.statics.value(this.domNode);
|
|
return after;
|
|
};
|
|
TextBlot.prototype.update = function (mutations, context) {
|
|
var _this = this;
|
|
if (mutations.some(function (mutation) {
|
|
return mutation.type === 'characterData' && mutation.target === _this.domNode;
|
|
})) {
|
|
this.text = this.statics.value(this.domNode);
|
|
}
|
|
};
|
|
TextBlot.prototype.value = function () {
|
|
return this.text;
|
|
};
|
|
TextBlot.blotName = 'text';
|
|
TextBlot.scope = Registry.Scope.INLINE_BLOT;
|
|
return TextBlot;
|
|
}(leaf_1.default));
|
|
exports.default = TextBlot;
|
|
|
|
|
|
/***/ })
|
|
/******/ ]);
|
|
});
|
|
//# sourceMappingURL=parchment.js.map
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill-delta/lib/delta.js":
|
|
/*!***********************************************!*\
|
|
!*** ./node_modules/quill-delta/lib/delta.js ***!
|
|
\***********************************************/
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
var diff = __webpack_require__(/*! fast-diff */ "./node_modules/fast-diff/diff.js");
|
|
var equal = __webpack_require__(/*! deep-equal */ "./node_modules/deep-equal/index.js");
|
|
var extend = __webpack_require__(/*! extend */ "./node_modules/extend/index.js");
|
|
var op = __webpack_require__(/*! ./op */ "./node_modules/quill-delta/lib/op.js");
|
|
|
|
|
|
var NULL_CHARACTER = String.fromCharCode(0); // Placeholder char for embed in diff()
|
|
|
|
|
|
var Delta = function (ops) {
|
|
// Assume we are given a well formed ops
|
|
if (Array.isArray(ops)) {
|
|
this.ops = ops;
|
|
} else if (ops != null && Array.isArray(ops.ops)) {
|
|
this.ops = ops.ops;
|
|
} else {
|
|
this.ops = [];
|
|
}
|
|
};
|
|
|
|
|
|
Delta.prototype.insert = function (text, attributes) {
|
|
var newOp = {};
|
|
if (text.length === 0) return this;
|
|
newOp.insert = text;
|
|
if (attributes != null && typeof attributes === 'object' && Object.keys(attributes).length > 0) {
|
|
newOp.attributes = attributes;
|
|
}
|
|
return this.push(newOp);
|
|
};
|
|
|
|
Delta.prototype['delete'] = function (length) {
|
|
if (length <= 0) return this;
|
|
return this.push({ 'delete': length });
|
|
};
|
|
|
|
Delta.prototype.retain = function (length, attributes) {
|
|
if (length <= 0) return this;
|
|
var newOp = { retain: length };
|
|
if (attributes != null && typeof attributes === 'object' && Object.keys(attributes).length > 0) {
|
|
newOp.attributes = attributes;
|
|
}
|
|
return this.push(newOp);
|
|
};
|
|
|
|
Delta.prototype.push = function (newOp) {
|
|
var index = this.ops.length;
|
|
var lastOp = this.ops[index - 1];
|
|
newOp = extend(true, {}, newOp);
|
|
if (typeof lastOp === 'object') {
|
|
if (typeof newOp['delete'] === 'number' && typeof lastOp['delete'] === 'number') {
|
|
this.ops[index - 1] = { 'delete': lastOp['delete'] + newOp['delete'] };
|
|
return this;
|
|
}
|
|
// Since it does not matter if we insert before or after deleting at the same index,
|
|
// always prefer to insert first
|
|
if (typeof lastOp['delete'] === 'number' && newOp.insert != null) {
|
|
index -= 1;
|
|
lastOp = this.ops[index - 1];
|
|
if (typeof lastOp !== 'object') {
|
|
this.ops.unshift(newOp);
|
|
return this;
|
|
}
|
|
}
|
|
if (equal(newOp.attributes, lastOp.attributes)) {
|
|
if (typeof newOp.insert === 'string' && typeof lastOp.insert === 'string') {
|
|
this.ops[index - 1] = { insert: lastOp.insert + newOp.insert };
|
|
if (typeof newOp.attributes === 'object') this.ops[index - 1].attributes = newOp.attributes
|
|
return this;
|
|
} else if (typeof newOp.retain === 'number' && typeof lastOp.retain === 'number') {
|
|
this.ops[index - 1] = { retain: lastOp.retain + newOp.retain };
|
|
if (typeof newOp.attributes === 'object') this.ops[index - 1].attributes = newOp.attributes
|
|
return this;
|
|
}
|
|
}
|
|
}
|
|
if (index === this.ops.length) {
|
|
this.ops.push(newOp);
|
|
} else {
|
|
this.ops.splice(index, 0, newOp);
|
|
}
|
|
return this;
|
|
};
|
|
|
|
Delta.prototype.chop = function () {
|
|
var lastOp = this.ops[this.ops.length - 1];
|
|
if (lastOp && lastOp.retain && !lastOp.attributes) {
|
|
this.ops.pop();
|
|
}
|
|
return this;
|
|
};
|
|
|
|
Delta.prototype.filter = function (predicate) {
|
|
return this.ops.filter(predicate);
|
|
};
|
|
|
|
Delta.prototype.forEach = function (predicate) {
|
|
this.ops.forEach(predicate);
|
|
};
|
|
|
|
Delta.prototype.map = function (predicate) {
|
|
return this.ops.map(predicate);
|
|
};
|
|
|
|
Delta.prototype.partition = function (predicate) {
|
|
var passed = [], failed = [];
|
|
this.forEach(function(op) {
|
|
var target = predicate(op) ? passed : failed;
|
|
target.push(op);
|
|
});
|
|
return [passed, failed];
|
|
};
|
|
|
|
Delta.prototype.reduce = function (predicate, initial) {
|
|
return this.ops.reduce(predicate, initial);
|
|
};
|
|
|
|
Delta.prototype.changeLength = function () {
|
|
return this.reduce(function (length, elem) {
|
|
if (elem.insert) {
|
|
return length + op.length(elem);
|
|
} else if (elem.delete) {
|
|
return length - elem.delete;
|
|
}
|
|
return length;
|
|
}, 0);
|
|
};
|
|
|
|
Delta.prototype.length = function () {
|
|
return this.reduce(function (length, elem) {
|
|
return length + op.length(elem);
|
|
}, 0);
|
|
};
|
|
|
|
Delta.prototype.slice = function (start, end) {
|
|
start = start || 0;
|
|
if (typeof end !== 'number') end = Infinity;
|
|
var ops = [];
|
|
var iter = op.iterator(this.ops);
|
|
var index = 0;
|
|
while (index < end && iter.hasNext()) {
|
|
var nextOp;
|
|
if (index < start) {
|
|
nextOp = iter.next(start - index);
|
|
} else {
|
|
nextOp = iter.next(end - index);
|
|
ops.push(nextOp);
|
|
}
|
|
index += op.length(nextOp);
|
|
}
|
|
return new Delta(ops);
|
|
};
|
|
|
|
|
|
Delta.prototype.compose = function (other) {
|
|
var thisIter = op.iterator(this.ops);
|
|
var otherIter = op.iterator(other.ops);
|
|
var ops = [];
|
|
var firstOther = otherIter.peek();
|
|
if (firstOther != null && typeof firstOther.retain === 'number' && firstOther.attributes == null) {
|
|
var firstLeft = firstOther.retain;
|
|
while (thisIter.peekType() === 'insert' && thisIter.peekLength() <= firstLeft) {
|
|
firstLeft -= thisIter.peekLength();
|
|
ops.push(thisIter.next());
|
|
}
|
|
if (firstOther.retain - firstLeft > 0) {
|
|
otherIter.next(firstOther.retain - firstLeft);
|
|
}
|
|
}
|
|
var delta = new Delta(ops);
|
|
while (thisIter.hasNext() || otherIter.hasNext()) {
|
|
if (otherIter.peekType() === 'insert') {
|
|
delta.push(otherIter.next());
|
|
} else if (thisIter.peekType() === 'delete') {
|
|
delta.push(thisIter.next());
|
|
} else {
|
|
var length = Math.min(thisIter.peekLength(), otherIter.peekLength());
|
|
var thisOp = thisIter.next(length);
|
|
var otherOp = otherIter.next(length);
|
|
if (typeof otherOp.retain === 'number') {
|
|
var newOp = {};
|
|
if (typeof thisOp.retain === 'number') {
|
|
newOp.retain = length;
|
|
} else {
|
|
newOp.insert = thisOp.insert;
|
|
}
|
|
// Preserve null when composing with a retain, otherwise remove it for inserts
|
|
var attributes = op.attributes.compose(thisOp.attributes, otherOp.attributes, typeof thisOp.retain === 'number');
|
|
if (attributes) newOp.attributes = attributes;
|
|
delta.push(newOp);
|
|
|
|
// Optimization if rest of other is just retain
|
|
if (!otherIter.hasNext() && equal(delta.ops[delta.ops.length - 1], newOp)) {
|
|
var rest = new Delta(thisIter.rest());
|
|
return delta.concat(rest).chop();
|
|
}
|
|
|
|
// Other op should be delete, we could be an insert or retain
|
|
// Insert + delete cancels out
|
|
} else if (typeof otherOp['delete'] === 'number' && typeof thisOp.retain === 'number') {
|
|
delta.push(otherOp);
|
|
}
|
|
}
|
|
}
|
|
return delta.chop();
|
|
};
|
|
|
|
Delta.prototype.concat = function (other) {
|
|
var delta = new Delta(this.ops.slice());
|
|
if (other.ops.length > 0) {
|
|
delta.push(other.ops[0]);
|
|
delta.ops = delta.ops.concat(other.ops.slice(1));
|
|
}
|
|
return delta;
|
|
};
|
|
|
|
Delta.prototype.diff = function (other, index) {
|
|
if (this.ops === other.ops) {
|
|
return new Delta();
|
|
}
|
|
var strings = [this, other].map(function (delta) {
|
|
return delta.map(function (op) {
|
|
if (op.insert != null) {
|
|
return typeof op.insert === 'string' ? op.insert : NULL_CHARACTER;
|
|
}
|
|
var prep = (delta === other) ? 'on' : 'with';
|
|
throw new Error('diff() called ' + prep + ' non-document');
|
|
}).join('');
|
|
});
|
|
var delta = new Delta();
|
|
var diffResult = diff(strings[0], strings[1], index);
|
|
var thisIter = op.iterator(this.ops);
|
|
var otherIter = op.iterator(other.ops);
|
|
diffResult.forEach(function (component) {
|
|
var length = component[1].length;
|
|
while (length > 0) {
|
|
var opLength = 0;
|
|
switch (component[0]) {
|
|
case diff.INSERT:
|
|
opLength = Math.min(otherIter.peekLength(), length);
|
|
delta.push(otherIter.next(opLength));
|
|
break;
|
|
case diff.DELETE:
|
|
opLength = Math.min(length, thisIter.peekLength());
|
|
thisIter.next(opLength);
|
|
delta['delete'](opLength);
|
|
break;
|
|
case diff.EQUAL:
|
|
opLength = Math.min(thisIter.peekLength(), otherIter.peekLength(), length);
|
|
var thisOp = thisIter.next(opLength);
|
|
var otherOp = otherIter.next(opLength);
|
|
if (equal(thisOp.insert, otherOp.insert)) {
|
|
delta.retain(opLength, op.attributes.diff(thisOp.attributes, otherOp.attributes));
|
|
} else {
|
|
delta.push(otherOp)['delete'](opLength);
|
|
}
|
|
break;
|
|
}
|
|
length -= opLength;
|
|
}
|
|
});
|
|
return delta.chop();
|
|
};
|
|
|
|
Delta.prototype.eachLine = function (predicate, newline) {
|
|
newline = newline || '\n';
|
|
var iter = op.iterator(this.ops);
|
|
var line = new Delta();
|
|
var i = 0;
|
|
while (iter.hasNext()) {
|
|
if (iter.peekType() !== 'insert') return;
|
|
var thisOp = iter.peek();
|
|
var start = op.length(thisOp) - iter.peekLength();
|
|
var index = typeof thisOp.insert === 'string' ?
|
|
thisOp.insert.indexOf(newline, start) - start : -1;
|
|
if (index < 0) {
|
|
line.push(iter.next());
|
|
} else if (index > 0) {
|
|
line.push(iter.next(index));
|
|
} else {
|
|
if (predicate(line, iter.next(1).attributes || {}, i) === false) {
|
|
return;
|
|
}
|
|
i += 1;
|
|
line = new Delta();
|
|
}
|
|
}
|
|
if (line.length() > 0) {
|
|
predicate(line, {}, i);
|
|
}
|
|
};
|
|
|
|
Delta.prototype.transform = function (other, priority) {
|
|
priority = !!priority;
|
|
if (typeof other === 'number') {
|
|
return this.transformPosition(other, priority);
|
|
}
|
|
var thisIter = op.iterator(this.ops);
|
|
var otherIter = op.iterator(other.ops);
|
|
var delta = new Delta();
|
|
while (thisIter.hasNext() || otherIter.hasNext()) {
|
|
if (thisIter.peekType() === 'insert' && (priority || otherIter.peekType() !== 'insert')) {
|
|
delta.retain(op.length(thisIter.next()));
|
|
} else if (otherIter.peekType() === 'insert') {
|
|
delta.push(otherIter.next());
|
|
} else {
|
|
var length = Math.min(thisIter.peekLength(), otherIter.peekLength());
|
|
var thisOp = thisIter.next(length);
|
|
var otherOp = otherIter.next(length);
|
|
if (thisOp['delete']) {
|
|
// Our delete either makes their delete redundant or removes their retain
|
|
continue;
|
|
} else if (otherOp['delete']) {
|
|
delta.push(otherOp);
|
|
} else {
|
|
// We retain either their retain or insert
|
|
delta.retain(length, op.attributes.transform(thisOp.attributes, otherOp.attributes, priority));
|
|
}
|
|
}
|
|
}
|
|
return delta.chop();
|
|
};
|
|
|
|
Delta.prototype.transformPosition = function (index, priority) {
|
|
priority = !!priority;
|
|
var thisIter = op.iterator(this.ops);
|
|
var offset = 0;
|
|
while (thisIter.hasNext() && offset <= index) {
|
|
var length = thisIter.peekLength();
|
|
var nextType = thisIter.peekType();
|
|
thisIter.next();
|
|
if (nextType === 'delete') {
|
|
index -= Math.min(length, index - offset);
|
|
continue;
|
|
} else if (nextType === 'insert' && (offset < index || !priority)) {
|
|
index += length;
|
|
}
|
|
offset += length;
|
|
}
|
|
return index;
|
|
};
|
|
|
|
|
|
module.exports = Delta;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill-delta/lib/op.js":
|
|
/*!********************************************!*\
|
|
!*** ./node_modules/quill-delta/lib/op.js ***!
|
|
\********************************************/
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
var equal = __webpack_require__(/*! deep-equal */ "./node_modules/deep-equal/index.js");
|
|
var extend = __webpack_require__(/*! extend */ "./node_modules/extend/index.js");
|
|
|
|
|
|
var lib = {
|
|
attributes: {
|
|
compose: function (a, b, keepNull) {
|
|
if (typeof a !== 'object') a = {};
|
|
if (typeof b !== 'object') b = {};
|
|
var attributes = extend(true, {}, b);
|
|
if (!keepNull) {
|
|
attributes = Object.keys(attributes).reduce(function (copy, key) {
|
|
if (attributes[key] != null) {
|
|
copy[key] = attributes[key];
|
|
}
|
|
return copy;
|
|
}, {});
|
|
}
|
|
for (var key in a) {
|
|
if (a[key] !== undefined && b[key] === undefined) {
|
|
attributes[key] = a[key];
|
|
}
|
|
}
|
|
return Object.keys(attributes).length > 0 ? attributes : undefined;
|
|
},
|
|
|
|
diff: function(a, b) {
|
|
if (typeof a !== 'object') a = {};
|
|
if (typeof b !== 'object') b = {};
|
|
var attributes = Object.keys(a).concat(Object.keys(b)).reduce(function (attributes, key) {
|
|
if (!equal(a[key], b[key])) {
|
|
attributes[key] = b[key] === undefined ? null : b[key];
|
|
}
|
|
return attributes;
|
|
}, {});
|
|
return Object.keys(attributes).length > 0 ? attributes : undefined;
|
|
},
|
|
|
|
transform: function (a, b, priority) {
|
|
if (typeof a !== 'object') return b;
|
|
if (typeof b !== 'object') return undefined;
|
|
if (!priority) return b; // b simply overwrites us without priority
|
|
var attributes = Object.keys(b).reduce(function (attributes, key) {
|
|
if (a[key] === undefined) attributes[key] = b[key]; // null is a valid value
|
|
return attributes;
|
|
}, {});
|
|
return Object.keys(attributes).length > 0 ? attributes : undefined;
|
|
}
|
|
},
|
|
|
|
iterator: function (ops) {
|
|
return new Iterator(ops);
|
|
},
|
|
|
|
length: function (op) {
|
|
if (typeof op['delete'] === 'number') {
|
|
return op['delete'];
|
|
} else if (typeof op.retain === 'number') {
|
|
return op.retain;
|
|
} else {
|
|
return typeof op.insert === 'string' ? op.insert.length : 1;
|
|
}
|
|
}
|
|
};
|
|
|
|
|
|
function Iterator(ops) {
|
|
this.ops = ops;
|
|
this.index = 0;
|
|
this.offset = 0;
|
|
};
|
|
|
|
Iterator.prototype.hasNext = function () {
|
|
return this.peekLength() < Infinity;
|
|
};
|
|
|
|
Iterator.prototype.next = function (length) {
|
|
if (!length) length = Infinity;
|
|
var nextOp = this.ops[this.index];
|
|
if (nextOp) {
|
|
var offset = this.offset;
|
|
var opLength = lib.length(nextOp)
|
|
if (length >= opLength - offset) {
|
|
length = opLength - offset;
|
|
this.index += 1;
|
|
this.offset = 0;
|
|
} else {
|
|
this.offset += length;
|
|
}
|
|
if (typeof nextOp['delete'] === 'number') {
|
|
return { 'delete': length };
|
|
} else {
|
|
var retOp = {};
|
|
if (nextOp.attributes) {
|
|
retOp.attributes = nextOp.attributes;
|
|
}
|
|
if (typeof nextOp.retain === 'number') {
|
|
retOp.retain = length;
|
|
} else if (typeof nextOp.insert === 'string') {
|
|
retOp.insert = nextOp.insert.substr(offset, length);
|
|
} else {
|
|
// offset should === 0, length should === 1
|
|
retOp.insert = nextOp.insert;
|
|
}
|
|
return retOp;
|
|
}
|
|
} else {
|
|
return { retain: Infinity };
|
|
}
|
|
};
|
|
|
|
Iterator.prototype.peek = function () {
|
|
return this.ops[this.index];
|
|
};
|
|
|
|
Iterator.prototype.peekLength = function () {
|
|
if (this.ops[this.index]) {
|
|
// Should never return 0 if our index is being managed correctly
|
|
return lib.length(this.ops[this.index]) - this.offset;
|
|
} else {
|
|
return Infinity;
|
|
}
|
|
};
|
|
|
|
Iterator.prototype.peekType = function () {
|
|
if (this.ops[this.index]) {
|
|
if (typeof this.ops[this.index]['delete'] === 'number') {
|
|
return 'delete';
|
|
} else if (typeof this.ops[this.index].retain === 'number') {
|
|
return 'retain';
|
|
} else {
|
|
return 'insert';
|
|
}
|
|
}
|
|
return 'retain';
|
|
};
|
|
|
|
Iterator.prototype.rest = function () {
|
|
if (!this.hasNext()) {
|
|
return [];
|
|
} else if (this.offset === 0) {
|
|
return this.ops.slice(this.index);
|
|
} else {
|
|
var offset = this.offset;
|
|
var index = this.index;
|
|
var next = this.next();
|
|
var rest = this.ops.slice(this.index);
|
|
this.offset = offset;
|
|
this.index = index;
|
|
return [next].concat(rest);
|
|
}
|
|
};
|
|
|
|
|
|
module.exports = lib;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/blots/block.js":
|
|
/*!*******************************************!*\
|
|
!*** ./node_modules/quill/blots/block.js ***!
|
|
\*******************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "bubbleFormats": () => (/* binding */ bubbleFormats),
|
|
/* harmony export */ "BlockEmbed": () => (/* binding */ BlockEmbed),
|
|
/* harmony export */ "default": () => (/* binding */ Block)
|
|
/* harmony export */ });
|
|
/* harmony import */ var extend__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! extend */ "./node_modules/extend/index.js");
|
|
/* harmony import */ var extend__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(extend__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var quill_delta__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! quill-delta */ "./node_modules/quill-delta/lib/delta.js");
|
|
/* harmony import */ var quill_delta__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(quill_delta__WEBPACK_IMPORTED_MODULE_1__);
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! parchment */ "./node_modules/parchment/dist/parchment.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(parchment__WEBPACK_IMPORTED_MODULE_2__);
|
|
/* harmony import */ var _break__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./break */ "./node_modules/quill/blots/break.js");
|
|
/* harmony import */ var _inline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./inline */ "./node_modules/quill/blots/inline.js");
|
|
/* harmony import */ var _text__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./text */ "./node_modules/quill/blots/text.js");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const NEWLINE_LENGTH = 1;
|
|
|
|
|
|
class BlockEmbed extends (parchment__WEBPACK_IMPORTED_MODULE_2___default().Embed) {
|
|
attach() {
|
|
super.attach();
|
|
this.attributes = new (parchment__WEBPACK_IMPORTED_MODULE_2___default().Attributor.Store)(this.domNode);
|
|
}
|
|
|
|
delta() {
|
|
return new (quill_delta__WEBPACK_IMPORTED_MODULE_1___default())().insert(this.value(), extend__WEBPACK_IMPORTED_MODULE_0___default()(this.formats(), this.attributes.values()));
|
|
}
|
|
|
|
format(name, value) {
|
|
let attribute = parchment__WEBPACK_IMPORTED_MODULE_2___default().query(name, (parchment__WEBPACK_IMPORTED_MODULE_2___default().Scope.BLOCK_ATTRIBUTE));
|
|
if (attribute != null) {
|
|
this.attributes.attribute(attribute, value);
|
|
}
|
|
}
|
|
|
|
formatAt(index, length, name, value) {
|
|
this.format(name, value);
|
|
}
|
|
|
|
insertAt(index, value, def) {
|
|
if (typeof value === 'string' && value.endsWith('\n')) {
|
|
let block = parchment__WEBPACK_IMPORTED_MODULE_2___default().create(Block.blotName);
|
|
this.parent.insertBefore(block, index === 0 ? this : this.next);
|
|
block.insertAt(0, value.slice(0, -1));
|
|
} else {
|
|
super.insertAt(index, value, def);
|
|
}
|
|
}
|
|
}
|
|
BlockEmbed.scope = (parchment__WEBPACK_IMPORTED_MODULE_2___default().Scope.BLOCK_BLOT);
|
|
// It is important for cursor behavior BlockEmbeds use tags that are block level elements
|
|
|
|
|
|
class Block extends (parchment__WEBPACK_IMPORTED_MODULE_2___default().Block) {
|
|
constructor(domNode) {
|
|
super(domNode);
|
|
this.cache = {};
|
|
}
|
|
|
|
delta() {
|
|
if (this.cache.delta == null) {
|
|
this.cache.delta = this.descendants((parchment__WEBPACK_IMPORTED_MODULE_2___default().Leaf)).reduce((delta, leaf) => {
|
|
if (leaf.length() === 0) {
|
|
return delta;
|
|
} else {
|
|
return delta.insert(leaf.value(), bubbleFormats(leaf));
|
|
}
|
|
}, new (quill_delta__WEBPACK_IMPORTED_MODULE_1___default())()).insert('\n', bubbleFormats(this));
|
|
}
|
|
return this.cache.delta;
|
|
}
|
|
|
|
deleteAt(index, length) {
|
|
super.deleteAt(index, length);
|
|
this.cache = {};
|
|
}
|
|
|
|
formatAt(index, length, name, value) {
|
|
if (length <= 0) return;
|
|
if (parchment__WEBPACK_IMPORTED_MODULE_2___default().query(name, (parchment__WEBPACK_IMPORTED_MODULE_2___default().Scope.BLOCK))) {
|
|
if (index + length === this.length()) {
|
|
this.format(name, value);
|
|
}
|
|
} else {
|
|
super.formatAt(index, Math.min(length, this.length() - index - 1), name, value);
|
|
}
|
|
this.cache = {};
|
|
}
|
|
|
|
insertAt(index, value, def) {
|
|
if (def != null) return super.insertAt(index, value, def);
|
|
if (value.length === 0) return;
|
|
let lines = value.split('\n');
|
|
let text = lines.shift();
|
|
if (text.length > 0) {
|
|
if (index < this.length() - 1 || this.children.tail == null) {
|
|
super.insertAt(Math.min(index, this.length() - 1), text);
|
|
} else {
|
|
this.children.tail.insertAt(this.children.tail.length(), text);
|
|
}
|
|
this.cache = {};
|
|
}
|
|
let block = this;
|
|
lines.reduce(function(index, line) {
|
|
block = block.split(index, true);
|
|
block.insertAt(0, line);
|
|
return line.length;
|
|
}, index + text.length);
|
|
}
|
|
|
|
insertBefore(blot, ref) {
|
|
let head = this.children.head;
|
|
super.insertBefore(blot, ref);
|
|
if (head instanceof _break__WEBPACK_IMPORTED_MODULE_3__.default) {
|
|
head.remove();
|
|
}
|
|
this.cache = {};
|
|
}
|
|
|
|
length() {
|
|
if (this.cache.length == null) {
|
|
this.cache.length = super.length() + NEWLINE_LENGTH;
|
|
}
|
|
return this.cache.length;
|
|
}
|
|
|
|
moveChildren(target, ref) {
|
|
super.moveChildren(target, ref);
|
|
this.cache = {};
|
|
}
|
|
|
|
optimize(context) {
|
|
super.optimize(context);
|
|
this.cache = {};
|
|
}
|
|
|
|
path(index) {
|
|
return super.path(index, true);
|
|
}
|
|
|
|
removeChild(child) {
|
|
super.removeChild(child);
|
|
this.cache = {};
|
|
}
|
|
|
|
split(index, force = false) {
|
|
if (force && (index === 0 || index >= this.length() - NEWLINE_LENGTH)) {
|
|
let clone = this.clone();
|
|
if (index === 0) {
|
|
this.parent.insertBefore(clone, this);
|
|
return this;
|
|
} else {
|
|
this.parent.insertBefore(clone, this.next);
|
|
return clone;
|
|
}
|
|
} else {
|
|
let next = super.split(index, force);
|
|
this.cache = {};
|
|
return next;
|
|
}
|
|
}
|
|
}
|
|
Block.blotName = 'block';
|
|
Block.tagName = 'P';
|
|
Block.defaultChild = 'break';
|
|
Block.allowedChildren = [_inline__WEBPACK_IMPORTED_MODULE_4__.default, (parchment__WEBPACK_IMPORTED_MODULE_2___default().Embed), _text__WEBPACK_IMPORTED_MODULE_5__.default];
|
|
|
|
|
|
function bubbleFormats(blot, formats = {}) {
|
|
if (blot == null) return formats;
|
|
if (typeof blot.formats === 'function') {
|
|
formats = extend__WEBPACK_IMPORTED_MODULE_0___default()(formats, blot.formats());
|
|
}
|
|
if (blot.parent == null || blot.parent.blotName == 'scroll' || blot.parent.statics.scope !== blot.statics.scope) {
|
|
return formats;
|
|
}
|
|
return bubbleFormats(blot.parent, formats);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/blots/break.js":
|
|
/*!*******************************************!*\
|
|
!*** ./node_modules/quill/blots/break.js ***!
|
|
\*******************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! parchment */ "./node_modules/parchment/dist/parchment.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(parchment__WEBPACK_IMPORTED_MODULE_0__);
|
|
|
|
|
|
|
|
class Break extends (parchment__WEBPACK_IMPORTED_MODULE_0___default().Embed) {
|
|
static value() {
|
|
return undefined;
|
|
}
|
|
|
|
insertInto(parent, ref) {
|
|
if (parent.children.length === 0) {
|
|
super.insertInto(parent, ref);
|
|
} else {
|
|
this.remove();
|
|
}
|
|
}
|
|
|
|
length() {
|
|
return 0;
|
|
}
|
|
|
|
value() {
|
|
return '';
|
|
}
|
|
}
|
|
Break.blotName = 'break';
|
|
Break.tagName = 'BR';
|
|
|
|
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Break);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/blots/container.js":
|
|
/*!***********************************************!*\
|
|
!*** ./node_modules/quill/blots/container.js ***!
|
|
\***********************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! parchment */ "./node_modules/parchment/dist/parchment.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(parchment__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var _block__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./block */ "./node_modules/quill/blots/block.js");
|
|
|
|
|
|
|
|
|
|
class Container extends (parchment__WEBPACK_IMPORTED_MODULE_0___default().Container) { }
|
|
Container.allowedChildren = [_block__WEBPACK_IMPORTED_MODULE_1__.default, _block__WEBPACK_IMPORTED_MODULE_1__.BlockEmbed, Container];
|
|
|
|
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Container);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/blots/cursor.js":
|
|
/*!********************************************!*\
|
|
!*** ./node_modules/quill/blots/cursor.js ***!
|
|
\********************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! parchment */ "./node_modules/parchment/dist/parchment.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(parchment__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var _text__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./text */ "./node_modules/quill/blots/text.js");
|
|
|
|
|
|
|
|
|
|
class Cursor extends (parchment__WEBPACK_IMPORTED_MODULE_0___default().Embed) {
|
|
static value() {
|
|
return undefined;
|
|
}
|
|
|
|
constructor(domNode, selection) {
|
|
super(domNode);
|
|
this.selection = selection;
|
|
this.textNode = document.createTextNode(Cursor.CONTENTS);
|
|
this.domNode.appendChild(this.textNode);
|
|
this._length = 0;
|
|
}
|
|
|
|
detach() {
|
|
// super.detach() will also clear domNode.__blot
|
|
if (this.parent != null) this.parent.removeChild(this);
|
|
}
|
|
|
|
format(name, value) {
|
|
if (this._length !== 0) {
|
|
return super.format(name, value);
|
|
}
|
|
let target = this, index = 0;
|
|
while (target != null && target.statics.scope !== (parchment__WEBPACK_IMPORTED_MODULE_0___default().Scope.BLOCK_BLOT)) {
|
|
index += target.offset(target.parent);
|
|
target = target.parent;
|
|
}
|
|
if (target != null) {
|
|
this._length = Cursor.CONTENTS.length;
|
|
target.optimize();
|
|
target.formatAt(index, Cursor.CONTENTS.length, name, value);
|
|
this._length = 0;
|
|
}
|
|
}
|
|
|
|
index(node, offset) {
|
|
if (node === this.textNode) return 0;
|
|
return super.index(node, offset);
|
|
}
|
|
|
|
length() {
|
|
return this._length;
|
|
}
|
|
|
|
position() {
|
|
return [this.textNode, this.textNode.data.length];
|
|
}
|
|
|
|
remove() {
|
|
super.remove();
|
|
this.parent = null;
|
|
}
|
|
|
|
restore() {
|
|
if (this.selection.composing || this.parent == null) return;
|
|
let textNode = this.textNode;
|
|
let range = this.selection.getNativeRange();
|
|
let restoreText, start, end;
|
|
if (range != null && range.start.node === textNode && range.end.node === textNode) {
|
|
[restoreText, start, end] = [textNode, range.start.offset, range.end.offset];
|
|
}
|
|
// Link format will insert text outside of anchor tag
|
|
while (this.domNode.lastChild != null && this.domNode.lastChild !== this.textNode) {
|
|
this.domNode.parentNode.insertBefore(this.domNode.lastChild, this.domNode);
|
|
}
|
|
if (this.textNode.data !== Cursor.CONTENTS) {
|
|
let text = this.textNode.data.split(Cursor.CONTENTS).join('');
|
|
if (this.next instanceof _text__WEBPACK_IMPORTED_MODULE_1__.default) {
|
|
restoreText = this.next.domNode;
|
|
this.next.insertAt(0, text);
|
|
this.textNode.data = Cursor.CONTENTS;
|
|
} else {
|
|
this.textNode.data = text;
|
|
this.parent.insertBefore(parchment__WEBPACK_IMPORTED_MODULE_0___default().create(this.textNode), this);
|
|
this.textNode = document.createTextNode(Cursor.CONTENTS);
|
|
this.domNode.appendChild(this.textNode);
|
|
}
|
|
}
|
|
this.remove();
|
|
if (start != null) {
|
|
[start, end] = [start, end].map(function(offset) {
|
|
return Math.max(0, Math.min(restoreText.data.length, offset - 1));
|
|
});
|
|
return {
|
|
startNode: restoreText,
|
|
startOffset: start,
|
|
endNode: restoreText,
|
|
endOffset: end
|
|
};
|
|
}
|
|
}
|
|
|
|
update(mutations, context) {
|
|
if (mutations.some((mutation) => {
|
|
return mutation.type === 'characterData' && mutation.target === this.textNode;
|
|
})) {
|
|
let range = this.restore();
|
|
if (range) context.range = range;
|
|
}
|
|
}
|
|
|
|
value() {
|
|
return '';
|
|
}
|
|
}
|
|
Cursor.blotName = 'cursor';
|
|
Cursor.className = 'ql-cursor';
|
|
Cursor.tagName = 'span';
|
|
Cursor.CONTENTS = "\uFEFF"; // Zero width no break space
|
|
|
|
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Cursor);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/blots/embed.js":
|
|
/*!*******************************************!*\
|
|
!*** ./node_modules/quill/blots/embed.js ***!
|
|
\*******************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! parchment */ "./node_modules/parchment/dist/parchment.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(parchment__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var _text__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./text */ "./node_modules/quill/blots/text.js");
|
|
|
|
|
|
|
|
const GUARD_TEXT = "\uFEFF";
|
|
|
|
|
|
class Embed extends (parchment__WEBPACK_IMPORTED_MODULE_0___default().Embed) {
|
|
constructor(node) {
|
|
super(node);
|
|
this.contentNode = document.createElement('span');
|
|
this.contentNode.setAttribute('contenteditable', false);
|
|
[].slice.call(this.domNode.childNodes).forEach((childNode) => {
|
|
this.contentNode.appendChild(childNode);
|
|
});
|
|
this.leftGuard = document.createTextNode(GUARD_TEXT);
|
|
this.rightGuard = document.createTextNode(GUARD_TEXT);
|
|
this.domNode.appendChild(this.leftGuard);
|
|
this.domNode.appendChild(this.contentNode);
|
|
this.domNode.appendChild(this.rightGuard);
|
|
}
|
|
|
|
index(node, offset) {
|
|
if (node === this.leftGuard) return 0;
|
|
if (node === this.rightGuard) return 1;
|
|
return super.index(node, offset);
|
|
}
|
|
|
|
restore(node) {
|
|
let range, textNode;
|
|
let text = node.data.split(GUARD_TEXT).join('');
|
|
if (node === this.leftGuard) {
|
|
if (this.prev instanceof _text__WEBPACK_IMPORTED_MODULE_1__.default) {
|
|
let prevLength = this.prev.length();
|
|
this.prev.insertAt(prevLength, text);
|
|
range = {
|
|
startNode: this.prev.domNode,
|
|
startOffset: prevLength + text.length
|
|
};
|
|
} else {
|
|
textNode = document.createTextNode(text);
|
|
this.parent.insertBefore(parchment__WEBPACK_IMPORTED_MODULE_0___default().create(textNode), this);
|
|
range = {
|
|
startNode: textNode,
|
|
startOffset: text.length
|
|
};
|
|
}
|
|
} else if (node === this.rightGuard) {
|
|
if (this.next instanceof _text__WEBPACK_IMPORTED_MODULE_1__.default) {
|
|
this.next.insertAt(0, text);
|
|
range = {
|
|
startNode: this.next.domNode,
|
|
startOffset: text.length
|
|
}
|
|
} else {
|
|
textNode = document.createTextNode(text);
|
|
this.parent.insertBefore(parchment__WEBPACK_IMPORTED_MODULE_0___default().create(textNode), this.next);
|
|
range = {
|
|
startNode: textNode,
|
|
startOffset: text.length
|
|
};
|
|
}
|
|
}
|
|
node.data = GUARD_TEXT;
|
|
return range;
|
|
}
|
|
|
|
update(mutations, context) {
|
|
mutations.forEach((mutation) => {
|
|
if (mutation.type === 'characterData' &&
|
|
(mutation.target === this.leftGuard || mutation.target === this.rightGuard)) {
|
|
let range = this.restore(mutation.target);
|
|
if (range) context.range = range;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Embed);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/blots/inline.js":
|
|
/*!********************************************!*\
|
|
!*** ./node_modules/quill/blots/inline.js ***!
|
|
\********************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony import */ var _text__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./text */ "./node_modules/quill/blots/text.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! parchment */ "./node_modules/parchment/dist/parchment.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(parchment__WEBPACK_IMPORTED_MODULE_1__);
|
|
|
|
|
|
|
|
|
|
class Inline extends (parchment__WEBPACK_IMPORTED_MODULE_1___default().Inline) {
|
|
static compare(self, other) {
|
|
let selfIndex = Inline.order.indexOf(self);
|
|
let otherIndex = Inline.order.indexOf(other);
|
|
if (selfIndex >= 0 || otherIndex >= 0) {
|
|
return selfIndex - otherIndex;
|
|
} else if (self === other) {
|
|
return 0;
|
|
} else if (self < other) {
|
|
return -1;
|
|
} else {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
formatAt(index, length, name, value) {
|
|
if (Inline.compare(this.statics.blotName, name) < 0 && parchment__WEBPACK_IMPORTED_MODULE_1___default().query(name, (parchment__WEBPACK_IMPORTED_MODULE_1___default().Scope.BLOT))) {
|
|
let blot = this.isolate(index, length);
|
|
if (value) {
|
|
blot.wrap(name, value);
|
|
}
|
|
} else {
|
|
super.formatAt(index, length, name, value);
|
|
}
|
|
}
|
|
|
|
optimize(context) {
|
|
super.optimize(context);
|
|
if (this.parent instanceof Inline &&
|
|
Inline.compare(this.statics.blotName, this.parent.statics.blotName) > 0) {
|
|
let parent = this.parent.isolate(this.offset(), this.length());
|
|
this.moveChildren(parent);
|
|
parent.wrap(this);
|
|
}
|
|
}
|
|
}
|
|
Inline.allowedChildren = [Inline, (parchment__WEBPACK_IMPORTED_MODULE_1___default().Embed), _text__WEBPACK_IMPORTED_MODULE_0__.default];
|
|
// Lower index means deeper in the DOM tree, since not found (-1) is for embeds
|
|
Inline.order = [
|
|
'cursor', 'inline', // Must be lower
|
|
'underline', 'strike', 'italic', 'bold', 'script',
|
|
'link', 'code' // Must be higher
|
|
];
|
|
|
|
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Inline);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/blots/scroll.js":
|
|
/*!********************************************!*\
|
|
!*** ./node_modules/quill/blots/scroll.js ***!
|
|
\********************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! parchment */ "./node_modules/parchment/dist/parchment.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(parchment__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var _core_emitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../core/emitter */ "./node_modules/quill/core/emitter.js");
|
|
/* harmony import */ var _block__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./block */ "./node_modules/quill/blots/block.js");
|
|
/* harmony import */ var _break__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./break */ "./node_modules/quill/blots/break.js");
|
|
/* harmony import */ var _formats_code__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../formats/code */ "./node_modules/quill/formats/code.js");
|
|
/* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./container */ "./node_modules/quill/blots/container.js");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function isLine(blot) {
|
|
return (blot instanceof _block__WEBPACK_IMPORTED_MODULE_2__.default || blot instanceof _block__WEBPACK_IMPORTED_MODULE_2__.BlockEmbed);
|
|
}
|
|
|
|
|
|
class Scroll extends (parchment__WEBPACK_IMPORTED_MODULE_0___default().Scroll) {
|
|
constructor(domNode, config) {
|
|
super(domNode);
|
|
this.emitter = config.emitter;
|
|
if (Array.isArray(config.whitelist)) {
|
|
this.whitelist = config.whitelist.reduce(function(whitelist, format) {
|
|
whitelist[format] = true;
|
|
return whitelist;
|
|
}, {});
|
|
}
|
|
// Some reason fixes composition issues with character languages in Windows/Chrome, Safari
|
|
this.domNode.addEventListener('DOMNodeInserted', function() {});
|
|
this.optimize();
|
|
this.enable();
|
|
}
|
|
|
|
batchStart() {
|
|
this.batch = true;
|
|
}
|
|
|
|
batchEnd() {
|
|
this.batch = false;
|
|
this.optimize();
|
|
}
|
|
|
|
deleteAt(index, length) {
|
|
let [first, offset] = this.line(index);
|
|
let [last, ] = this.line(index + length);
|
|
super.deleteAt(index, length);
|
|
if (last != null && first !== last && offset > 0) {
|
|
if (first instanceof _block__WEBPACK_IMPORTED_MODULE_2__.BlockEmbed || last instanceof _block__WEBPACK_IMPORTED_MODULE_2__.BlockEmbed) {
|
|
this.optimize();
|
|
return;
|
|
}
|
|
if (first instanceof _formats_code__WEBPACK_IMPORTED_MODULE_4__.default) {
|
|
let newlineIndex = first.newlineIndex(first.length(), true);
|
|
if (newlineIndex > -1) {
|
|
first = first.split(newlineIndex + 1);
|
|
if (first === last) {
|
|
this.optimize();
|
|
return;
|
|
}
|
|
}
|
|
} else if (last instanceof _formats_code__WEBPACK_IMPORTED_MODULE_4__.default) {
|
|
let newlineIndex = last.newlineIndex(0);
|
|
if (newlineIndex > -1) {
|
|
last.split(newlineIndex + 1);
|
|
}
|
|
}
|
|
let ref = last.children.head instanceof _break__WEBPACK_IMPORTED_MODULE_3__.default ? null : last.children.head;
|
|
first.moveChildren(last, ref);
|
|
first.remove();
|
|
}
|
|
this.optimize();
|
|
}
|
|
|
|
enable(enabled = true) {
|
|
this.domNode.setAttribute('contenteditable', enabled);
|
|
}
|
|
|
|
formatAt(index, length, format, value) {
|
|
if (this.whitelist != null && !this.whitelist[format]) return;
|
|
super.formatAt(index, length, format, value);
|
|
this.optimize();
|
|
}
|
|
|
|
insertAt(index, value, def) {
|
|
if (def != null && this.whitelist != null && !this.whitelist[value]) return;
|
|
if (index >= this.length()) {
|
|
if (def == null || parchment__WEBPACK_IMPORTED_MODULE_0___default().query(value, (parchment__WEBPACK_IMPORTED_MODULE_0___default().Scope.BLOCK)) == null) {
|
|
let blot = parchment__WEBPACK_IMPORTED_MODULE_0___default().create(this.statics.defaultChild);
|
|
this.appendChild(blot);
|
|
if (def == null && value.endsWith('\n')) {
|
|
value = value.slice(0, -1);
|
|
}
|
|
blot.insertAt(0, value, def);
|
|
} else {
|
|
let embed = parchment__WEBPACK_IMPORTED_MODULE_0___default().create(value, def);
|
|
this.appendChild(embed);
|
|
}
|
|
} else {
|
|
super.insertAt(index, value, def);
|
|
}
|
|
this.optimize();
|
|
}
|
|
|
|
insertBefore(blot, ref) {
|
|
if (blot.statics.scope === (parchment__WEBPACK_IMPORTED_MODULE_0___default().Scope.INLINE_BLOT)) {
|
|
let wrapper = parchment__WEBPACK_IMPORTED_MODULE_0___default().create(this.statics.defaultChild);
|
|
wrapper.appendChild(blot);
|
|
blot = wrapper;
|
|
}
|
|
super.insertBefore(blot, ref);
|
|
}
|
|
|
|
leaf(index) {
|
|
return this.path(index).pop() || [null, -1];
|
|
}
|
|
|
|
line(index) {
|
|
if (index === this.length()) {
|
|
return this.line(index - 1);
|
|
}
|
|
return this.descendant(isLine, index);
|
|
}
|
|
|
|
lines(index = 0, length = Number.MAX_VALUE) {
|
|
let getLines = (blot, index, length) => {
|
|
let lines = [], lengthLeft = length;
|
|
blot.children.forEachAt(index, length, function(child, index, length) {
|
|
if (isLine(child)) {
|
|
lines.push(child);
|
|
} else if (child instanceof (parchment__WEBPACK_IMPORTED_MODULE_0___default().Container)) {
|
|
lines = lines.concat(getLines(child, index, lengthLeft));
|
|
}
|
|
lengthLeft -= length;
|
|
});
|
|
return lines;
|
|
};
|
|
return getLines(this, index, length);
|
|
}
|
|
|
|
optimize(mutations = [], context = {}) {
|
|
if (this.batch === true) return;
|
|
super.optimize(mutations, context);
|
|
if (mutations.length > 0) {
|
|
this.emitter.emit(_core_emitter__WEBPACK_IMPORTED_MODULE_1__.default.events.SCROLL_OPTIMIZE, mutations, context);
|
|
}
|
|
}
|
|
|
|
path(index) {
|
|
return super.path(index).slice(1); // Exclude self
|
|
}
|
|
|
|
update(mutations) {
|
|
if (this.batch === true) return;
|
|
let source = _core_emitter__WEBPACK_IMPORTED_MODULE_1__.default.sources.USER;
|
|
if (typeof mutations === 'string') {
|
|
source = mutations;
|
|
}
|
|
if (!Array.isArray(mutations)) {
|
|
mutations = this.observer.takeRecords();
|
|
}
|
|
if (mutations.length > 0) {
|
|
this.emitter.emit(_core_emitter__WEBPACK_IMPORTED_MODULE_1__.default.events.SCROLL_BEFORE_UPDATE, source, mutations);
|
|
}
|
|
super.update(mutations.concat([])); // pass copy
|
|
if (mutations.length > 0) {
|
|
this.emitter.emit(_core_emitter__WEBPACK_IMPORTED_MODULE_1__.default.events.SCROLL_UPDATE, source, mutations);
|
|
}
|
|
}
|
|
}
|
|
Scroll.blotName = 'scroll';
|
|
Scroll.className = 'ql-editor';
|
|
Scroll.tagName = 'DIV';
|
|
Scroll.defaultChild = 'block';
|
|
Scroll.allowedChildren = [_block__WEBPACK_IMPORTED_MODULE_2__.default, _block__WEBPACK_IMPORTED_MODULE_2__.BlockEmbed, _container__WEBPACK_IMPORTED_MODULE_5__.default];
|
|
|
|
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Scroll);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/blots/text.js":
|
|
/*!******************************************!*\
|
|
!*** ./node_modules/quill/blots/text.js ***!
|
|
\******************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! parchment */ "./node_modules/parchment/dist/parchment.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(parchment__WEBPACK_IMPORTED_MODULE_0__);
|
|
|
|
|
|
class TextBlot extends (parchment__WEBPACK_IMPORTED_MODULE_0___default().Text) { }
|
|
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (TextBlot);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/core.js":
|
|
/*!************************************!*\
|
|
!*** ./node_modules/quill/core.js ***!
|
|
\************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! parchment */ "./node_modules/parchment/dist/parchment.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(parchment__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var _core_quill__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./core/quill */ "./node_modules/quill/core/quill.js");
|
|
/* harmony import */ var _blots_block__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./blots/block */ "./node_modules/quill/blots/block.js");
|
|
/* harmony import */ var _blots_break__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./blots/break */ "./node_modules/quill/blots/break.js");
|
|
/* harmony import */ var _blots_container__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./blots/container */ "./node_modules/quill/blots/container.js");
|
|
/* harmony import */ var _blots_cursor__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./blots/cursor */ "./node_modules/quill/blots/cursor.js");
|
|
/* harmony import */ var _blots_embed__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./blots/embed */ "./node_modules/quill/blots/embed.js");
|
|
/* harmony import */ var _blots_inline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./blots/inline */ "./node_modules/quill/blots/inline.js");
|
|
/* harmony import */ var _blots_scroll__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./blots/scroll */ "./node_modules/quill/blots/scroll.js");
|
|
/* harmony import */ var _blots_text__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./blots/text */ "./node_modules/quill/blots/text.js");
|
|
/* harmony import */ var _modules_clipboard__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./modules/clipboard */ "./node_modules/quill/modules/clipboard.js");
|
|
/* harmony import */ var _modules_history__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./modules/history */ "./node_modules/quill/modules/history.js");
|
|
/* harmony import */ var _modules_keyboard__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./modules/keyboard */ "./node_modules/quill/modules/keyboard.js");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_core_quill__WEBPACK_IMPORTED_MODULE_1__.default.register({
|
|
'blots/block' : _blots_block__WEBPACK_IMPORTED_MODULE_2__.default,
|
|
'blots/block/embed' : _blots_block__WEBPACK_IMPORTED_MODULE_2__.BlockEmbed,
|
|
'blots/break' : _blots_break__WEBPACK_IMPORTED_MODULE_3__.default,
|
|
'blots/container' : _blots_container__WEBPACK_IMPORTED_MODULE_4__.default,
|
|
'blots/cursor' : _blots_cursor__WEBPACK_IMPORTED_MODULE_5__.default,
|
|
'blots/embed' : _blots_embed__WEBPACK_IMPORTED_MODULE_6__.default,
|
|
'blots/inline' : _blots_inline__WEBPACK_IMPORTED_MODULE_7__.default,
|
|
'blots/scroll' : _blots_scroll__WEBPACK_IMPORTED_MODULE_8__.default,
|
|
'blots/text' : _blots_text__WEBPACK_IMPORTED_MODULE_9__.default,
|
|
|
|
'modules/clipboard' : _modules_clipboard__WEBPACK_IMPORTED_MODULE_10__.default,
|
|
'modules/history' : _modules_history__WEBPACK_IMPORTED_MODULE_11__.default,
|
|
'modules/keyboard' : _modules_keyboard__WEBPACK_IMPORTED_MODULE_12__.default
|
|
});
|
|
|
|
parchment__WEBPACK_IMPORTED_MODULE_0___default().register(_blots_block__WEBPACK_IMPORTED_MODULE_2__.default, _blots_break__WEBPACK_IMPORTED_MODULE_3__.default, _blots_cursor__WEBPACK_IMPORTED_MODULE_5__.default, _blots_inline__WEBPACK_IMPORTED_MODULE_7__.default, _blots_scroll__WEBPACK_IMPORTED_MODULE_8__.default, _blots_text__WEBPACK_IMPORTED_MODULE_9__.default);
|
|
|
|
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_core_quill__WEBPACK_IMPORTED_MODULE_1__.default);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/core/editor.js":
|
|
/*!*******************************************!*\
|
|
!*** ./node_modules/quill/core/editor.js ***!
|
|
\*******************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony import */ var quill_delta__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! quill-delta */ "./node_modules/quill-delta/lib/delta.js");
|
|
/* harmony import */ var quill_delta__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(quill_delta__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var quill_delta_lib_op__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! quill-delta/lib/op */ "./node_modules/quill-delta/lib/op.js");
|
|
/* harmony import */ var quill_delta_lib_op__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(quill_delta_lib_op__WEBPACK_IMPORTED_MODULE_1__);
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! parchment */ "./node_modules/parchment/dist/parchment.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(parchment__WEBPACK_IMPORTED_MODULE_2__);
|
|
/* harmony import */ var _formats_code__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../formats/code */ "./node_modules/quill/formats/code.js");
|
|
/* harmony import */ var _blots_cursor__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../blots/cursor */ "./node_modules/quill/blots/cursor.js");
|
|
/* harmony import */ var _blots_block__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../blots/block */ "./node_modules/quill/blots/block.js");
|
|
/* harmony import */ var _blots_break__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../blots/break */ "./node_modules/quill/blots/break.js");
|
|
/* harmony import */ var clone__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! clone */ "./node_modules/clone/clone.js");
|
|
/* harmony import */ var clone__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(clone__WEBPACK_IMPORTED_MODULE_7__);
|
|
/* harmony import */ var deep_equal__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! deep-equal */ "./node_modules/deep-equal/index.js");
|
|
/* harmony import */ var deep_equal__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(deep_equal__WEBPACK_IMPORTED_MODULE_8__);
|
|
/* harmony import */ var extend__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! extend */ "./node_modules/extend/index.js");
|
|
/* harmony import */ var extend__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(extend__WEBPACK_IMPORTED_MODULE_9__);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ASCII = /^[ -~]*$/;
|
|
|
|
|
|
class Editor {
|
|
constructor(scroll) {
|
|
this.scroll = scroll;
|
|
this.delta = this.getDelta();
|
|
}
|
|
|
|
applyDelta(delta) {
|
|
let consumeNextNewline = false;
|
|
this.scroll.update();
|
|
let scrollLength = this.scroll.length();
|
|
this.scroll.batchStart();
|
|
delta = normalizeDelta(delta);
|
|
delta.reduce((index, op) => {
|
|
let length = op.retain || op.delete || op.insert.length || 1;
|
|
let attributes = op.attributes || {};
|
|
if (op.insert != null) {
|
|
if (typeof op.insert === 'string') {
|
|
let text = op.insert;
|
|
if (text.endsWith('\n') && consumeNextNewline) {
|
|
consumeNextNewline = false;
|
|
text = text.slice(0, -1);
|
|
}
|
|
if (index >= scrollLength && !text.endsWith('\n')) {
|
|
consumeNextNewline = true;
|
|
}
|
|
this.scroll.insertAt(index, text);
|
|
let [line, offset] = this.scroll.line(index);
|
|
let formats = extend__WEBPACK_IMPORTED_MODULE_9___default()({}, (0,_blots_block__WEBPACK_IMPORTED_MODULE_5__.bubbleFormats)(line));
|
|
if (line instanceof _blots_block__WEBPACK_IMPORTED_MODULE_5__.default) {
|
|
let [leaf, ] = line.descendant((parchment__WEBPACK_IMPORTED_MODULE_2___default().Leaf), offset);
|
|
formats = extend__WEBPACK_IMPORTED_MODULE_9___default()(formats, (0,_blots_block__WEBPACK_IMPORTED_MODULE_5__.bubbleFormats)(leaf));
|
|
}
|
|
attributes = quill_delta_lib_op__WEBPACK_IMPORTED_MODULE_1___default().attributes.diff(formats, attributes) || {};
|
|
} else if (typeof op.insert === 'object') {
|
|
let key = Object.keys(op.insert)[0]; // There should only be one key
|
|
if (key == null) return index;
|
|
this.scroll.insertAt(index, key, op.insert[key]);
|
|
}
|
|
scrollLength += length;
|
|
}
|
|
Object.keys(attributes).forEach((name) => {
|
|
this.scroll.formatAt(index, length, name, attributes[name]);
|
|
});
|
|
return index + length;
|
|
}, 0);
|
|
delta.reduce((index, op) => {
|
|
if (typeof op.delete === 'number') {
|
|
this.scroll.deleteAt(index, op.delete);
|
|
return index;
|
|
}
|
|
return index + (op.retain || op.insert.length || 1);
|
|
}, 0);
|
|
this.scroll.batchEnd();
|
|
return this.update(delta);
|
|
}
|
|
|
|
deleteText(index, length) {
|
|
this.scroll.deleteAt(index, length);
|
|
return this.update(new (quill_delta__WEBPACK_IMPORTED_MODULE_0___default())().retain(index).delete(length));
|
|
}
|
|
|
|
formatLine(index, length, formats = {}) {
|
|
this.scroll.update();
|
|
Object.keys(formats).forEach((format) => {
|
|
if (this.scroll.whitelist != null && !this.scroll.whitelist[format]) return;
|
|
let lines = this.scroll.lines(index, Math.max(length, 1));
|
|
let lengthRemaining = length;
|
|
lines.forEach((line) => {
|
|
let lineLength = line.length();
|
|
if (!(line instanceof _formats_code__WEBPACK_IMPORTED_MODULE_3__.default)) {
|
|
line.format(format, formats[format]);
|
|
} else {
|
|
let codeIndex = index - line.offset(this.scroll);
|
|
let codeLength = line.newlineIndex(codeIndex + lengthRemaining) - codeIndex + 1;
|
|
line.formatAt(codeIndex, codeLength, format, formats[format]);
|
|
}
|
|
lengthRemaining -= lineLength;
|
|
});
|
|
});
|
|
this.scroll.optimize();
|
|
return this.update(new (quill_delta__WEBPACK_IMPORTED_MODULE_0___default())().retain(index).retain(length, clone__WEBPACK_IMPORTED_MODULE_7___default()(formats)));
|
|
}
|
|
|
|
formatText(index, length, formats = {}) {
|
|
Object.keys(formats).forEach((format) => {
|
|
this.scroll.formatAt(index, length, format, formats[format]);
|
|
});
|
|
return this.update(new (quill_delta__WEBPACK_IMPORTED_MODULE_0___default())().retain(index).retain(length, clone__WEBPACK_IMPORTED_MODULE_7___default()(formats)));
|
|
}
|
|
|
|
getContents(index, length) {
|
|
return this.delta.slice(index, index + length);
|
|
}
|
|
|
|
getDelta() {
|
|
return this.scroll.lines().reduce((delta, line) => {
|
|
return delta.concat(line.delta());
|
|
}, new (quill_delta__WEBPACK_IMPORTED_MODULE_0___default())());
|
|
}
|
|
|
|
getFormat(index, length = 0) {
|
|
let lines = [], leaves = [];
|
|
if (length === 0) {
|
|
this.scroll.path(index).forEach(function(path) {
|
|
let [blot, ] = path;
|
|
if (blot instanceof _blots_block__WEBPACK_IMPORTED_MODULE_5__.default) {
|
|
lines.push(blot);
|
|
} else if (blot instanceof (parchment__WEBPACK_IMPORTED_MODULE_2___default().Leaf)) {
|
|
leaves.push(blot);
|
|
}
|
|
});
|
|
} else {
|
|
lines = this.scroll.lines(index, length);
|
|
leaves = this.scroll.descendants((parchment__WEBPACK_IMPORTED_MODULE_2___default().Leaf), index, length);
|
|
}
|
|
let formatsArr = [lines, leaves].map(function(blots) {
|
|
if (blots.length === 0) return {};
|
|
let formats = (0,_blots_block__WEBPACK_IMPORTED_MODULE_5__.bubbleFormats)(blots.shift());
|
|
while (Object.keys(formats).length > 0) {
|
|
let blot = blots.shift();
|
|
if (blot == null) return formats;
|
|
formats = combineFormats((0,_blots_block__WEBPACK_IMPORTED_MODULE_5__.bubbleFormats)(blot), formats);
|
|
}
|
|
return formats;
|
|
});
|
|
return extend__WEBPACK_IMPORTED_MODULE_9___default().apply((extend__WEBPACK_IMPORTED_MODULE_9___default()), formatsArr);
|
|
}
|
|
|
|
getText(index, length) {
|
|
return this.getContents(index, length).filter(function(op) {
|
|
return typeof op.insert === 'string';
|
|
}).map(function(op) {
|
|
return op.insert;
|
|
}).join('');
|
|
}
|
|
|
|
insertEmbed(index, embed, value) {
|
|
this.scroll.insertAt(index, embed, value);
|
|
return this.update(new (quill_delta__WEBPACK_IMPORTED_MODULE_0___default())().retain(index).insert({ [embed]: value }));
|
|
}
|
|
|
|
insertText(index, text, formats = {}) {
|
|
text = text.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
this.scroll.insertAt(index, text);
|
|
Object.keys(formats).forEach((format) => {
|
|
this.scroll.formatAt(index, text.length, format, formats[format]);
|
|
});
|
|
return this.update(new (quill_delta__WEBPACK_IMPORTED_MODULE_0___default())().retain(index).insert(text, clone__WEBPACK_IMPORTED_MODULE_7___default()(formats)));
|
|
}
|
|
|
|
isBlank() {
|
|
if (this.scroll.children.length == 0) return true;
|
|
if (this.scroll.children.length > 1) return false;
|
|
let block = this.scroll.children.head;
|
|
if (block.statics.blotName !== _blots_block__WEBPACK_IMPORTED_MODULE_5__.default.blotName) return false;
|
|
if (block.children.length > 1) return false;
|
|
return block.children.head instanceof _blots_break__WEBPACK_IMPORTED_MODULE_6__.default;
|
|
}
|
|
|
|
removeFormat(index, length) {
|
|
let text = this.getText(index, length);
|
|
let [line, offset] = this.scroll.line(index + length);
|
|
let suffixLength = 0, suffix = new (quill_delta__WEBPACK_IMPORTED_MODULE_0___default())();
|
|
if (line != null) {
|
|
if (!(line instanceof _formats_code__WEBPACK_IMPORTED_MODULE_3__.default)) {
|
|
suffixLength = line.length() - offset;
|
|
} else {
|
|
suffixLength = line.newlineIndex(offset) - offset + 1;
|
|
}
|
|
suffix = line.delta().slice(offset, offset + suffixLength - 1).insert('\n');
|
|
}
|
|
let contents = this.getContents(index, length + suffixLength);
|
|
let diff = contents.diff(new (quill_delta__WEBPACK_IMPORTED_MODULE_0___default())().insert(text).concat(suffix));
|
|
let delta = new (quill_delta__WEBPACK_IMPORTED_MODULE_0___default())().retain(index).concat(diff);
|
|
return this.applyDelta(delta);
|
|
}
|
|
|
|
update(change, mutations = [], cursorIndex = undefined) {
|
|
let oldDelta = this.delta;
|
|
if (mutations.length === 1 &&
|
|
mutations[0].type === 'characterData' &&
|
|
mutations[0].target.data.match(ASCII) &&
|
|
parchment__WEBPACK_IMPORTED_MODULE_2___default().find(mutations[0].target)) {
|
|
// Optimization for character changes
|
|
let textBlot = parchment__WEBPACK_IMPORTED_MODULE_2___default().find(mutations[0].target);
|
|
let formats = (0,_blots_block__WEBPACK_IMPORTED_MODULE_5__.bubbleFormats)(textBlot);
|
|
let index = textBlot.offset(this.scroll);
|
|
let oldValue = mutations[0].oldValue.replace(_blots_cursor__WEBPACK_IMPORTED_MODULE_4__.default.CONTENTS, '');
|
|
let oldText = new (quill_delta__WEBPACK_IMPORTED_MODULE_0___default())().insert(oldValue);
|
|
let newText = new (quill_delta__WEBPACK_IMPORTED_MODULE_0___default())().insert(textBlot.value());
|
|
let diffDelta = new (quill_delta__WEBPACK_IMPORTED_MODULE_0___default())().retain(index).concat(oldText.diff(newText, cursorIndex));
|
|
change = diffDelta.reduce(function(delta, op) {
|
|
if (op.insert) {
|
|
return delta.insert(op.insert, formats);
|
|
} else {
|
|
return delta.push(op);
|
|
}
|
|
}, new (quill_delta__WEBPACK_IMPORTED_MODULE_0___default())());
|
|
this.delta = oldDelta.compose(change);
|
|
} else {
|
|
this.delta = this.getDelta();
|
|
if (!change || !deep_equal__WEBPACK_IMPORTED_MODULE_8___default()(oldDelta.compose(change), this.delta)) {
|
|
change = oldDelta.diff(this.delta, cursorIndex);
|
|
}
|
|
}
|
|
return change;
|
|
}
|
|
}
|
|
|
|
|
|
function combineFormats(formats, combined) {
|
|
return Object.keys(combined).reduce(function(merged, name) {
|
|
if (formats[name] == null) return merged;
|
|
if (combined[name] === formats[name]) {
|
|
merged[name] = combined[name];
|
|
} else if (Array.isArray(combined[name])) {
|
|
if (combined[name].indexOf(formats[name]) < 0) {
|
|
merged[name] = combined[name].concat([formats[name]]);
|
|
}
|
|
} else {
|
|
merged[name] = [combined[name], formats[name]];
|
|
}
|
|
return merged;
|
|
}, {});
|
|
}
|
|
|
|
function normalizeDelta(delta) {
|
|
return delta.reduce(function(delta, op) {
|
|
if (op.insert === 1) {
|
|
let attributes = clone__WEBPACK_IMPORTED_MODULE_7___default()(op.attributes);
|
|
delete attributes['image'];
|
|
return delta.insert({ image: op.attributes.image }, attributes);
|
|
}
|
|
if (op.attributes != null && (op.attributes.list === true || op.attributes.bullet === true)) {
|
|
op = clone__WEBPACK_IMPORTED_MODULE_7___default()(op);
|
|
if (op.attributes.list) {
|
|
op.attributes.list = 'ordered';
|
|
} else {
|
|
op.attributes.list = 'bullet';
|
|
delete op.attributes.bullet;
|
|
}
|
|
}
|
|
if (typeof op.insert === 'string') {
|
|
let text = op.insert.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
return delta.insert(text, op.attributes);
|
|
}
|
|
return delta.push(op);
|
|
}, new (quill_delta__WEBPACK_IMPORTED_MODULE_0___default())());
|
|
}
|
|
|
|
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Editor);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/core/emitter.js":
|
|
/*!********************************************!*\
|
|
!*** ./node_modules/quill/core/emitter.js ***!
|
|
\********************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony import */ var eventemitter3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! eventemitter3 */ "./node_modules/quill/node_modules/eventemitter3/index.js");
|
|
/* harmony import */ var eventemitter3__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(eventemitter3__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./logger */ "./node_modules/quill/core/logger.js");
|
|
|
|
|
|
|
|
let debug = (0,_logger__WEBPACK_IMPORTED_MODULE_1__.default)('quill:events');
|
|
|
|
const EVENTS = ['selectionchange', 'mousedown', 'mouseup', 'click'];
|
|
|
|
EVENTS.forEach(function(eventName) {
|
|
document.addEventListener(eventName, (...args) => {
|
|
[].slice.call(document.querySelectorAll('.ql-container')).forEach((node) => {
|
|
// TODO use WeakMap
|
|
if (node.__quill && node.__quill.emitter) {
|
|
node.__quill.emitter.handleDOM(...args);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
|
|
class Emitter extends (eventemitter3__WEBPACK_IMPORTED_MODULE_0___default()) {
|
|
constructor() {
|
|
super();
|
|
this.listeners = {};
|
|
this.on('error', debug.error);
|
|
}
|
|
|
|
emit() {
|
|
debug.log.apply(debug, arguments);
|
|
super.emit.apply(this, arguments);
|
|
}
|
|
|
|
handleDOM(event, ...args) {
|
|
(this.listeners[event.type] || []).forEach(function({ node, handler }) {
|
|
if (event.target === node || node.contains(event.target)) {
|
|
handler(event, ...args);
|
|
}
|
|
});
|
|
}
|
|
|
|
listenDOM(eventName, node, handler) {
|
|
if (!this.listeners[eventName]) {
|
|
this.listeners[eventName] = [];
|
|
}
|
|
this.listeners[eventName].push({ node, handler })
|
|
}
|
|
}
|
|
|
|
Emitter.events = {
|
|
EDITOR_CHANGE : 'editor-change',
|
|
SCROLL_BEFORE_UPDATE : 'scroll-before-update',
|
|
SCROLL_OPTIMIZE : 'scroll-optimize',
|
|
SCROLL_UPDATE : 'scroll-update',
|
|
SELECTION_CHANGE : 'selection-change',
|
|
TEXT_CHANGE : 'text-change'
|
|
};
|
|
Emitter.sources = {
|
|
API : 'api',
|
|
SILENT : 'silent',
|
|
USER : 'user'
|
|
};
|
|
|
|
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Emitter);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/core/logger.js":
|
|
/*!*******************************************!*\
|
|
!*** ./node_modules/quill/core/logger.js ***!
|
|
\*******************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
let levels = ['error', 'warn', 'log', 'info'];
|
|
let level = 'warn';
|
|
|
|
function debug(method, ...args) {
|
|
if (levels.indexOf(method) <= levels.indexOf(level)) {
|
|
console[method](...args); // eslint-disable-line no-console
|
|
}
|
|
}
|
|
|
|
function namespace(ns) {
|
|
return levels.reduce(function(logger, method) {
|
|
logger[method] = debug.bind(console, method, ns);
|
|
return logger;
|
|
}, {});
|
|
}
|
|
|
|
debug.level = namespace.level = function(newLevel) {
|
|
level = newLevel;
|
|
};
|
|
|
|
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (namespace);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/core/module.js":
|
|
/*!*******************************************!*\
|
|
!*** ./node_modules/quill/core/module.js ***!
|
|
\*******************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
class Module {
|
|
constructor(quill, options = {}) {
|
|
this.quill = quill;
|
|
this.options = options;
|
|
}
|
|
}
|
|
Module.DEFAULTS = {};
|
|
|
|
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Module);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/core/polyfill.js":
|
|
/*!*********************************************!*\
|
|
!*** ./node_modules/quill/core/polyfill.js ***!
|
|
\*********************************************/
|
|
/***/ (() => {
|
|
|
|
let elem = document.createElement('div');
|
|
elem.classList.toggle('test-class', false);
|
|
if (elem.classList.contains('test-class')) {
|
|
let _toggle = DOMTokenList.prototype.toggle;
|
|
DOMTokenList.prototype.toggle = function(token, force) {
|
|
if (arguments.length > 1 && !this.contains(token) === !force) {
|
|
return force;
|
|
} else {
|
|
return _toggle.call(this, token);
|
|
}
|
|
};
|
|
}
|
|
|
|
if (!String.prototype.startsWith) {
|
|
String.prototype.startsWith = function(searchString, position){
|
|
position = position || 0;
|
|
return this.substr(position, searchString.length) === searchString;
|
|
};
|
|
}
|
|
|
|
if (!String.prototype.endsWith) {
|
|
String.prototype.endsWith = function(searchString, position) {
|
|
var subjectString = this.toString();
|
|
if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
|
|
position = subjectString.length;
|
|
}
|
|
position -= searchString.length;
|
|
var lastIndex = subjectString.indexOf(searchString, position);
|
|
return lastIndex !== -1 && lastIndex === position;
|
|
};
|
|
}
|
|
|
|
if (!Array.prototype.find) {
|
|
Object.defineProperty(Array.prototype, "find", {
|
|
value: function(predicate) {
|
|
if (this === null) {
|
|
throw new TypeError('Array.prototype.find called on null or undefined');
|
|
}
|
|
if (typeof predicate !== 'function') {
|
|
throw new TypeError('predicate must be a function');
|
|
}
|
|
var list = Object(this);
|
|
var length = list.length >>> 0;
|
|
var thisArg = arguments[1];
|
|
var value;
|
|
|
|
for (var i = 0; i < length; i++) {
|
|
value = list[i];
|
|
if (predicate.call(thisArg, value, i, list)) {
|
|
return value;
|
|
}
|
|
}
|
|
return undefined;
|
|
}
|
|
});
|
|
}
|
|
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
// Disable resizing in Firefox
|
|
document.execCommand("enableObjectResizing", false, false);
|
|
// Disable automatic linkifying in IE11
|
|
document.execCommand("autoUrlDetect", false, false);
|
|
});
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/core/quill.js":
|
|
/*!******************************************!*\
|
|
!*** ./node_modules/quill/core/quill.js ***!
|
|
\******************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "expandConfig": () => (/* binding */ expandConfig),
|
|
/* harmony export */ "overload": () => (/* binding */ overload),
|
|
/* harmony export */ "default": () => (/* binding */ Quill)
|
|
/* harmony export */ });
|
|
/* harmony import */ var _polyfill__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./polyfill */ "./node_modules/quill/core/polyfill.js");
|
|
/* harmony import */ var _polyfill__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_polyfill__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var quill_delta__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! quill-delta */ "./node_modules/quill-delta/lib/delta.js");
|
|
/* harmony import */ var quill_delta__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(quill_delta__WEBPACK_IMPORTED_MODULE_1__);
|
|
/* harmony import */ var _editor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./editor */ "./node_modules/quill/core/editor.js");
|
|
/* harmony import */ var _emitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./emitter */ "./node_modules/quill/core/emitter.js");
|
|
/* harmony import */ var _module__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./module */ "./node_modules/quill/core/module.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! parchment */ "./node_modules/parchment/dist/parchment.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(parchment__WEBPACK_IMPORTED_MODULE_5__);
|
|
/* harmony import */ var _selection__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./selection */ "./node_modules/quill/core/selection.js");
|
|
/* harmony import */ var extend__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! extend */ "./node_modules/extend/index.js");
|
|
/* harmony import */ var extend__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(extend__WEBPACK_IMPORTED_MODULE_7__);
|
|
/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./logger */ "./node_modules/quill/core/logger.js");
|
|
/* harmony import */ var _theme__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./theme */ "./node_modules/quill/core/theme.js");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let debug = (0,_logger__WEBPACK_IMPORTED_MODULE_8__.default)('quill');
|
|
|
|
|
|
class Quill {
|
|
static debug(limit) {
|
|
if (limit === true) {
|
|
limit = 'log';
|
|
}
|
|
_logger__WEBPACK_IMPORTED_MODULE_8__.default.level(limit);
|
|
}
|
|
|
|
static find(node) {
|
|
return node.__quill || parchment__WEBPACK_IMPORTED_MODULE_5___default().find(node);
|
|
}
|
|
|
|
static import(name) {
|
|
if (this.imports[name] == null) {
|
|
debug.error(`Cannot import ${name}. Are you sure it was registered?`);
|
|
}
|
|
return this.imports[name];
|
|
}
|
|
|
|
static register(path, target, overwrite = false) {
|
|
if (typeof path !== 'string') {
|
|
let name = path.attrName || path.blotName;
|
|
if (typeof name === 'string') {
|
|
// register(Blot | Attributor, overwrite)
|
|
this.register('formats/' + name, path, target);
|
|
} else {
|
|
Object.keys(path).forEach((key) => {
|
|
this.register(key, path[key], target);
|
|
});
|
|
}
|
|
} else {
|
|
if (this.imports[path] != null && !overwrite) {
|
|
debug.warn(`Overwriting ${path} with`, target);
|
|
}
|
|
this.imports[path] = target;
|
|
if ((path.startsWith('blots/') || path.startsWith('formats/')) &&
|
|
target.blotName !== 'abstract') {
|
|
parchment__WEBPACK_IMPORTED_MODULE_5___default().register(target);
|
|
} else if (path.startsWith('modules') && typeof target.register === 'function') {
|
|
target.register();
|
|
}
|
|
}
|
|
}
|
|
|
|
constructor(container, options = {}) {
|
|
this.options = expandConfig(container, options);
|
|
this.container = this.options.container;
|
|
if (this.container == null) {
|
|
return debug.error('Invalid Quill container', container);
|
|
}
|
|
if (this.options.debug) {
|
|
Quill.debug(this.options.debug);
|
|
}
|
|
let html = this.container.innerHTML.trim();
|
|
this.container.classList.add('ql-container');
|
|
this.container.innerHTML = '';
|
|
this.container.__quill = this;
|
|
this.root = this.addContainer('ql-editor');
|
|
this.root.classList.add('ql-blank');
|
|
this.root.setAttribute('data-gramm', false);
|
|
this.scrollingContainer = this.options.scrollingContainer || this.root;
|
|
this.emitter = new _emitter__WEBPACK_IMPORTED_MODULE_3__.default();
|
|
this.scroll = parchment__WEBPACK_IMPORTED_MODULE_5___default().create(this.root, {
|
|
emitter: this.emitter,
|
|
whitelist: this.options.formats
|
|
});
|
|
this.editor = new _editor__WEBPACK_IMPORTED_MODULE_2__.default(this.scroll);
|
|
this.selection = new _selection__WEBPACK_IMPORTED_MODULE_6__.default(this.scroll, this.emitter);
|
|
this.theme = new this.options.theme(this, this.options);
|
|
this.keyboard = this.theme.addModule('keyboard');
|
|
this.clipboard = this.theme.addModule('clipboard');
|
|
this.history = this.theme.addModule('history');
|
|
this.theme.init();
|
|
this.emitter.on(_emitter__WEBPACK_IMPORTED_MODULE_3__.default.events.EDITOR_CHANGE, (type) => {
|
|
if (type === _emitter__WEBPACK_IMPORTED_MODULE_3__.default.events.TEXT_CHANGE) {
|
|
this.root.classList.toggle('ql-blank', this.editor.isBlank());
|
|
}
|
|
});
|
|
this.emitter.on(_emitter__WEBPACK_IMPORTED_MODULE_3__.default.events.SCROLL_UPDATE, (source, mutations) => {
|
|
let range = this.selection.lastRange;
|
|
let index = range && range.length === 0 ? range.index : undefined;
|
|
modify.call(this, () => {
|
|
return this.editor.update(null, mutations, index);
|
|
}, source);
|
|
});
|
|
let contents = this.clipboard.convert(`<div class='ql-editor' style="white-space: normal;">${html}<p><br></p></div>`);
|
|
this.setContents(contents);
|
|
this.history.clear();
|
|
if (this.options.placeholder) {
|
|
this.root.setAttribute('data-placeholder', this.options.placeholder);
|
|
}
|
|
if (this.options.readOnly) {
|
|
this.disable();
|
|
}
|
|
}
|
|
|
|
addContainer(container, refNode = null) {
|
|
if (typeof container === 'string') {
|
|
let className = container;
|
|
container = document.createElement('div');
|
|
container.classList.add(className);
|
|
}
|
|
this.container.insertBefore(container, refNode);
|
|
return container;
|
|
}
|
|
|
|
blur() {
|
|
this.selection.setRange(null);
|
|
}
|
|
|
|
deleteText(index, length, source) {
|
|
[index, length, , source] = overload(index, length, source);
|
|
return modify.call(this, () => {
|
|
return this.editor.deleteText(index, length);
|
|
}, source, index, -1*length);
|
|
}
|
|
|
|
disable() {
|
|
this.enable(false);
|
|
}
|
|
|
|
enable(enabled = true) {
|
|
this.scroll.enable(enabled);
|
|
this.container.classList.toggle('ql-disabled', !enabled);
|
|
}
|
|
|
|
focus() {
|
|
let scrollTop = this.scrollingContainer.scrollTop;
|
|
this.selection.focus();
|
|
this.scrollingContainer.scrollTop = scrollTop;
|
|
this.scrollIntoView();
|
|
}
|
|
|
|
format(name, value, source = _emitter__WEBPACK_IMPORTED_MODULE_3__.default.sources.API) {
|
|
return modify.call(this, () => {
|
|
let range = this.getSelection(true);
|
|
let change = new (quill_delta__WEBPACK_IMPORTED_MODULE_1___default())();
|
|
if (range == null) {
|
|
return change;
|
|
} else if (parchment__WEBPACK_IMPORTED_MODULE_5___default().query(name, (parchment__WEBPACK_IMPORTED_MODULE_5___default().Scope.BLOCK))) {
|
|
change = this.editor.formatLine(range.index, range.length, { [name]: value });
|
|
} else if (range.length === 0) {
|
|
this.selection.format(name, value);
|
|
return change;
|
|
} else {
|
|
change = this.editor.formatText(range.index, range.length, { [name]: value });
|
|
}
|
|
this.setSelection(range, _emitter__WEBPACK_IMPORTED_MODULE_3__.default.sources.SILENT);
|
|
return change;
|
|
}, source);
|
|
}
|
|
|
|
formatLine(index, length, name, value, source) {
|
|
let formats;
|
|
[index, length, formats, source] = overload(index, length, name, value, source);
|
|
return modify.call(this, () => {
|
|
return this.editor.formatLine(index, length, formats);
|
|
}, source, index, 0);
|
|
}
|
|
|
|
formatText(index, length, name, value, source) {
|
|
let formats;
|
|
[index, length, formats, source] = overload(index, length, name, value, source);
|
|
return modify.call(this, () => {
|
|
return this.editor.formatText(index, length, formats);
|
|
}, source, index, 0);
|
|
}
|
|
|
|
getBounds(index, length = 0) {
|
|
let bounds;
|
|
if (typeof index === 'number') {
|
|
bounds = this.selection.getBounds(index, length);
|
|
} else {
|
|
bounds = this.selection.getBounds(index.index, index.length);
|
|
}
|
|
let containerBounds = this.container.getBoundingClientRect();
|
|
return {
|
|
bottom: bounds.bottom - containerBounds.top,
|
|
height: bounds.height,
|
|
left: bounds.left - containerBounds.left,
|
|
right: bounds.right - containerBounds.left,
|
|
top: bounds.top - containerBounds.top,
|
|
width: bounds.width
|
|
};
|
|
}
|
|
|
|
getContents(index = 0, length = this.getLength() - index) {
|
|
[index, length] = overload(index, length);
|
|
return this.editor.getContents(index, length);
|
|
}
|
|
|
|
getFormat(index = this.getSelection(true), length = 0) {
|
|
if (typeof index === 'number') {
|
|
return this.editor.getFormat(index, length);
|
|
} else {
|
|
return this.editor.getFormat(index.index, index.length);
|
|
}
|
|
}
|
|
|
|
getIndex(blot) {
|
|
return blot.offset(this.scroll);
|
|
}
|
|
|
|
getLength() {
|
|
return this.scroll.length();
|
|
}
|
|
|
|
getLeaf(index) {
|
|
return this.scroll.leaf(index);
|
|
}
|
|
|
|
getLine(index) {
|
|
return this.scroll.line(index);
|
|
}
|
|
|
|
getLines(index = 0, length = Number.MAX_VALUE) {
|
|
if (typeof index !== 'number') {
|
|
return this.scroll.lines(index.index, index.length);
|
|
} else {
|
|
return this.scroll.lines(index, length);
|
|
}
|
|
}
|
|
|
|
getModule(name) {
|
|
return this.theme.modules[name];
|
|
}
|
|
|
|
getSelection(focus = false) {
|
|
if (focus) this.focus();
|
|
this.update(); // Make sure we access getRange with editor in consistent state
|
|
return this.selection.getRange()[0];
|
|
}
|
|
|
|
getText(index = 0, length = this.getLength() - index) {
|
|
[index, length] = overload(index, length);
|
|
return this.editor.getText(index, length);
|
|
}
|
|
|
|
hasFocus() {
|
|
return this.selection.hasFocus();
|
|
}
|
|
|
|
insertEmbed(index, embed, value, source = Quill.sources.API) {
|
|
return modify.call(this, () => {
|
|
return this.editor.insertEmbed(index, embed, value);
|
|
}, source, index);
|
|
}
|
|
|
|
insertText(index, text, name, value, source) {
|
|
let formats;
|
|
[index, , formats, source] = overload(index, 0, name, value, source);
|
|
return modify.call(this, () => {
|
|
return this.editor.insertText(index, text, formats);
|
|
}, source, index, text.length);
|
|
}
|
|
|
|
isEnabled() {
|
|
return !this.container.classList.contains('ql-disabled');
|
|
}
|
|
|
|
off() {
|
|
return this.emitter.off.apply(this.emitter, arguments);
|
|
}
|
|
|
|
on() {
|
|
return this.emitter.on.apply(this.emitter, arguments);
|
|
}
|
|
|
|
once() {
|
|
return this.emitter.once.apply(this.emitter, arguments);
|
|
}
|
|
|
|
pasteHTML(index, html, source) {
|
|
this.clipboard.dangerouslyPasteHTML(index, html, source);
|
|
}
|
|
|
|
removeFormat(index, length, source) {
|
|
[index, length, , source] = overload(index, length, source);
|
|
return modify.call(this, () => {
|
|
return this.editor.removeFormat(index, length);
|
|
}, source, index);
|
|
}
|
|
|
|
scrollIntoView() {
|
|
this.selection.scrollIntoView(this.scrollingContainer);
|
|
}
|
|
|
|
setContents(delta, source = _emitter__WEBPACK_IMPORTED_MODULE_3__.default.sources.API) {
|
|
return modify.call(this, () => {
|
|
delta = new (quill_delta__WEBPACK_IMPORTED_MODULE_1___default())(delta);
|
|
let length = this.getLength();
|
|
let deleted = this.editor.deleteText(0, length);
|
|
let applied = this.editor.applyDelta(delta);
|
|
let lastOp = applied.ops[applied.ops.length - 1];
|
|
if (lastOp != null && typeof(lastOp.insert) === 'string' && lastOp.insert[lastOp.insert.length-1] === '\n') {
|
|
this.editor.deleteText(this.getLength() - 1, 1);
|
|
applied.delete(1);
|
|
}
|
|
let ret = deleted.compose(applied);
|
|
return ret;
|
|
}, source);
|
|
}
|
|
|
|
setSelection(index, length, source) {
|
|
if (index == null) {
|
|
this.selection.setRange(null, length || Quill.sources.API);
|
|
} else {
|
|
[index, length, , source] = overload(index, length, source);
|
|
this.selection.setRange(new _selection__WEBPACK_IMPORTED_MODULE_6__.Range(index, length), source);
|
|
if (source !== _emitter__WEBPACK_IMPORTED_MODULE_3__.default.sources.SILENT) {
|
|
this.selection.scrollIntoView(this.scrollingContainer);
|
|
}
|
|
}
|
|
}
|
|
|
|
setText(text, source = _emitter__WEBPACK_IMPORTED_MODULE_3__.default.sources.API) {
|
|
let delta = new (quill_delta__WEBPACK_IMPORTED_MODULE_1___default())().insert(text);
|
|
return this.setContents(delta, source);
|
|
}
|
|
|
|
update(source = _emitter__WEBPACK_IMPORTED_MODULE_3__.default.sources.USER) {
|
|
let change = this.scroll.update(source); // Will update selection before selection.update() does if text changes
|
|
this.selection.update(source);
|
|
return change;
|
|
}
|
|
|
|
updateContents(delta, source = _emitter__WEBPACK_IMPORTED_MODULE_3__.default.sources.API) {
|
|
return modify.call(this, () => {
|
|
delta = new (quill_delta__WEBPACK_IMPORTED_MODULE_1___default())(delta);
|
|
return this.editor.applyDelta(delta, source);
|
|
}, source, true);
|
|
}
|
|
}
|
|
Quill.DEFAULTS = {
|
|
bounds: null,
|
|
formats: null,
|
|
modules: {},
|
|
placeholder: '',
|
|
readOnly: false,
|
|
scrollingContainer: null,
|
|
strict: true,
|
|
theme: 'default'
|
|
};
|
|
Quill.events = _emitter__WEBPACK_IMPORTED_MODULE_3__.default.events;
|
|
Quill.sources = _emitter__WEBPACK_IMPORTED_MODULE_3__.default.sources;
|
|
// eslint-disable-next-line no-undef
|
|
Quill.version = typeof(QUILL_VERSION) === 'undefined' ? 'dev' : QUILL_VERSION;
|
|
|
|
Quill.imports = {
|
|
'delta' : (quill_delta__WEBPACK_IMPORTED_MODULE_1___default()),
|
|
'parchment' : (parchment__WEBPACK_IMPORTED_MODULE_5___default()),
|
|
'core/module' : _module__WEBPACK_IMPORTED_MODULE_4__.default,
|
|
'core/theme' : _theme__WEBPACK_IMPORTED_MODULE_9__.default
|
|
};
|
|
|
|
|
|
function expandConfig(container, userConfig) {
|
|
userConfig = extend__WEBPACK_IMPORTED_MODULE_7___default()(true, {
|
|
container: container,
|
|
modules: {
|
|
clipboard: true,
|
|
keyboard: true,
|
|
history: true
|
|
}
|
|
}, userConfig);
|
|
if (!userConfig.theme || userConfig.theme === Quill.DEFAULTS.theme) {
|
|
userConfig.theme = _theme__WEBPACK_IMPORTED_MODULE_9__.default;
|
|
} else {
|
|
userConfig.theme = Quill.import(`themes/${userConfig.theme}`);
|
|
if (userConfig.theme == null) {
|
|
throw new Error(`Invalid theme ${userConfig.theme}. Did you register it?`);
|
|
}
|
|
}
|
|
let themeConfig = extend__WEBPACK_IMPORTED_MODULE_7___default()(true, {}, userConfig.theme.DEFAULTS);
|
|
[themeConfig, userConfig].forEach(function(config) {
|
|
config.modules = config.modules || {};
|
|
Object.keys(config.modules).forEach(function(module) {
|
|
if (config.modules[module] === true) {
|
|
config.modules[module] = {};
|
|
}
|
|
});
|
|
});
|
|
let moduleNames = Object.keys(themeConfig.modules).concat(Object.keys(userConfig.modules));
|
|
let moduleConfig = moduleNames.reduce(function(config, name) {
|
|
let moduleClass = Quill.import(`modules/${name}`);
|
|
if (moduleClass == null) {
|
|
debug.error(`Cannot load ${name} module. Are you sure you registered it?`);
|
|
} else {
|
|
config[name] = moduleClass.DEFAULTS || {};
|
|
}
|
|
return config;
|
|
}, {});
|
|
// Special case toolbar shorthand
|
|
if (userConfig.modules != null && userConfig.modules.toolbar &&
|
|
userConfig.modules.toolbar.constructor !== Object) {
|
|
userConfig.modules.toolbar = {
|
|
container: userConfig.modules.toolbar
|
|
};
|
|
}
|
|
userConfig = extend__WEBPACK_IMPORTED_MODULE_7___default()(true, {}, Quill.DEFAULTS, { modules: moduleConfig }, themeConfig, userConfig);
|
|
['bounds', 'container', 'scrollingContainer'].forEach(function(key) {
|
|
if (typeof userConfig[key] === 'string') {
|
|
userConfig[key] = document.querySelector(userConfig[key]);
|
|
}
|
|
});
|
|
userConfig.modules = Object.keys(userConfig.modules).reduce(function(config, name) {
|
|
if (userConfig.modules[name]) {
|
|
config[name] = userConfig.modules[name];
|
|
}
|
|
return config;
|
|
}, {});
|
|
return userConfig;
|
|
}
|
|
|
|
// Handle selection preservation and TEXT_CHANGE emission
|
|
// common to modification APIs
|
|
function modify(modifier, source, index, shift) {
|
|
if (this.options.strict && !this.isEnabled() && source === _emitter__WEBPACK_IMPORTED_MODULE_3__.default.sources.USER) {
|
|
return new (quill_delta__WEBPACK_IMPORTED_MODULE_1___default())();
|
|
}
|
|
let range = index == null ? null : this.getSelection();
|
|
let oldDelta = this.editor.delta;
|
|
let change = modifier();
|
|
if (range != null) {
|
|
if (index === true) index = range.index;
|
|
if (shift == null) {
|
|
range = shiftRange(range, change, source);
|
|
} else if (shift !== 0) {
|
|
range = shiftRange(range, index, shift, source);
|
|
}
|
|
this.setSelection(range, _emitter__WEBPACK_IMPORTED_MODULE_3__.default.sources.SILENT);
|
|
}
|
|
if (change.length() > 0) {
|
|
let args = [_emitter__WEBPACK_IMPORTED_MODULE_3__.default.events.TEXT_CHANGE, change, oldDelta, source];
|
|
this.emitter.emit(_emitter__WEBPACK_IMPORTED_MODULE_3__.default.events.EDITOR_CHANGE, ...args);
|
|
if (source !== _emitter__WEBPACK_IMPORTED_MODULE_3__.default.sources.SILENT) {
|
|
this.emitter.emit(...args);
|
|
}
|
|
}
|
|
return change;
|
|
}
|
|
|
|
function overload(index, length, name, value, source) {
|
|
let formats = {};
|
|
if (typeof index.index === 'number' && typeof index.length === 'number') {
|
|
// Allow for throwaway end (used by insertText/insertEmbed)
|
|
if (typeof length !== 'number') {
|
|
source = value, value = name, name = length, length = index.length, index = index.index;
|
|
} else {
|
|
length = index.length, index = index.index;
|
|
}
|
|
} else if (typeof length !== 'number') {
|
|
source = value, value = name, name = length, length = 0;
|
|
}
|
|
// Handle format being object, two format name/value strings or excluded
|
|
if (typeof name === 'object') {
|
|
formats = name;
|
|
source = value;
|
|
} else if (typeof name === 'string') {
|
|
if (value != null) {
|
|
formats[name] = value;
|
|
} else {
|
|
source = name;
|
|
}
|
|
}
|
|
// Handle optional source
|
|
source = source || _emitter__WEBPACK_IMPORTED_MODULE_3__.default.sources.API;
|
|
return [index, length, formats, source];
|
|
}
|
|
|
|
function shiftRange(range, index, length, source) {
|
|
if (range == null) return null;
|
|
let start, end;
|
|
if (index instanceof (quill_delta__WEBPACK_IMPORTED_MODULE_1___default())) {
|
|
[start, end] = [range.index, range.index + range.length].map(function(pos) {
|
|
return index.transformPosition(pos, source !== _emitter__WEBPACK_IMPORTED_MODULE_3__.default.sources.USER);
|
|
});
|
|
} else {
|
|
[start, end] = [range.index, range.index + range.length].map(function(pos) {
|
|
if (pos < index || (pos === index && source === _emitter__WEBPACK_IMPORTED_MODULE_3__.default.sources.USER)) return pos;
|
|
if (length >= 0) {
|
|
return pos + length;
|
|
} else {
|
|
return Math.max(index, pos + length);
|
|
}
|
|
});
|
|
}
|
|
return new _selection__WEBPACK_IMPORTED_MODULE_6__.Range(start, end - start);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/core/selection.js":
|
|
/*!**********************************************!*\
|
|
!*** ./node_modules/quill/core/selection.js ***!
|
|
\**********************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "Range": () => (/* binding */ Range),
|
|
/* harmony export */ "default": () => (/* binding */ Selection)
|
|
/* harmony export */ });
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! parchment */ "./node_modules/parchment/dist/parchment.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(parchment__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var clone__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! clone */ "./node_modules/clone/clone.js");
|
|
/* harmony import */ var clone__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(clone__WEBPACK_IMPORTED_MODULE_1__);
|
|
/* harmony import */ var deep_equal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! deep-equal */ "./node_modules/deep-equal/index.js");
|
|
/* harmony import */ var deep_equal__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(deep_equal__WEBPACK_IMPORTED_MODULE_2__);
|
|
/* harmony import */ var _emitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./emitter */ "./node_modules/quill/core/emitter.js");
|
|
/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./logger */ "./node_modules/quill/core/logger.js");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let debug = (0,_logger__WEBPACK_IMPORTED_MODULE_4__.default)('quill:selection');
|
|
|
|
|
|
class Range {
|
|
constructor(index, length = 0) {
|
|
this.index = index;
|
|
this.length = length;
|
|
}
|
|
}
|
|
|
|
|
|
class Selection {
|
|
constructor(scroll, emitter) {
|
|
this.emitter = emitter;
|
|
this.scroll = scroll;
|
|
this.composing = false;
|
|
this.mouseDown = false;
|
|
this.root = this.scroll.domNode;
|
|
this.cursor = parchment__WEBPACK_IMPORTED_MODULE_0___default().create('cursor', this);
|
|
// savedRange is last non-null range
|
|
this.lastRange = this.savedRange = new Range(0, 0);
|
|
this.handleComposition();
|
|
this.handleDragging();
|
|
this.emitter.listenDOM('selectionchange', document, () => {
|
|
if (!this.mouseDown) {
|
|
setTimeout(this.update.bind(this, _emitter__WEBPACK_IMPORTED_MODULE_3__.default.sources.USER), 1);
|
|
}
|
|
});
|
|
this.emitter.on(_emitter__WEBPACK_IMPORTED_MODULE_3__.default.events.EDITOR_CHANGE, (type, delta) => {
|
|
if (type === _emitter__WEBPACK_IMPORTED_MODULE_3__.default.events.TEXT_CHANGE && delta.length() > 0) {
|
|
this.update(_emitter__WEBPACK_IMPORTED_MODULE_3__.default.sources.SILENT);
|
|
}
|
|
});
|
|
this.emitter.on(_emitter__WEBPACK_IMPORTED_MODULE_3__.default.events.SCROLL_BEFORE_UPDATE, () => {
|
|
if (!this.hasFocus()) return;
|
|
let native = this.getNativeRange();
|
|
if (native == null) return;
|
|
if (native.start.node === this.cursor.textNode) return; // cursor.restore() will handle
|
|
// TODO unclear if this has negative side effects
|
|
this.emitter.once(_emitter__WEBPACK_IMPORTED_MODULE_3__.default.events.SCROLL_UPDATE, () => {
|
|
try {
|
|
this.setNativeRange(native.start.node, native.start.offset, native.end.node, native.end.offset);
|
|
} catch (ignored) {}
|
|
});
|
|
});
|
|
this.emitter.on(_emitter__WEBPACK_IMPORTED_MODULE_3__.default.events.SCROLL_OPTIMIZE, (mutations, context) => {
|
|
if (context.range) {
|
|
const { startNode, startOffset, endNode, endOffset } = context.range;
|
|
this.setNativeRange(startNode, startOffset, endNode, endOffset);
|
|
}
|
|
});
|
|
this.update(_emitter__WEBPACK_IMPORTED_MODULE_3__.default.sources.SILENT);
|
|
}
|
|
|
|
handleComposition() {
|
|
this.root.addEventListener('compositionstart', () => {
|
|
this.composing = true;
|
|
});
|
|
this.root.addEventListener('compositionend', () => {
|
|
this.composing = false;
|
|
if (this.cursor.parent) {
|
|
const range = this.cursor.restore();
|
|
if (!range) return;
|
|
setTimeout(() => {
|
|
this.setNativeRange(range.startNode, range.startOffset, range.endNode, range.endOffset);
|
|
}, 1);
|
|
}
|
|
});
|
|
}
|
|
|
|
handleDragging() {
|
|
this.emitter.listenDOM('mousedown', document.body, () => {
|
|
this.mouseDown = true;
|
|
});
|
|
this.emitter.listenDOM('mouseup', document.body, () => {
|
|
this.mouseDown = false;
|
|
this.update(_emitter__WEBPACK_IMPORTED_MODULE_3__.default.sources.USER);
|
|
});
|
|
}
|
|
|
|
focus() {
|
|
if (this.hasFocus()) return;
|
|
this.root.focus();
|
|
this.setRange(this.savedRange);
|
|
}
|
|
|
|
format(format, value) {
|
|
if (this.scroll.whitelist != null && !this.scroll.whitelist[format]) return;
|
|
this.scroll.update();
|
|
let nativeRange = this.getNativeRange();
|
|
if (nativeRange == null || !nativeRange.native.collapsed || parchment__WEBPACK_IMPORTED_MODULE_0___default().query(format, (parchment__WEBPACK_IMPORTED_MODULE_0___default().Scope.BLOCK))) return;
|
|
if (nativeRange.start.node !== this.cursor.textNode) {
|
|
let blot = parchment__WEBPACK_IMPORTED_MODULE_0___default().find(nativeRange.start.node, false);
|
|
if (blot == null) return;
|
|
// TODO Give blot ability to not split
|
|
if (blot instanceof (parchment__WEBPACK_IMPORTED_MODULE_0___default().Leaf)) {
|
|
let after = blot.split(nativeRange.start.offset);
|
|
blot.parent.insertBefore(this.cursor, after);
|
|
} else {
|
|
blot.insertBefore(this.cursor, nativeRange.start.node); // Should never happen
|
|
}
|
|
this.cursor.attach();
|
|
}
|
|
this.cursor.format(format, value);
|
|
this.scroll.optimize();
|
|
this.setNativeRange(this.cursor.textNode, this.cursor.textNode.data.length);
|
|
this.update();
|
|
}
|
|
|
|
getBounds(index, length = 0) {
|
|
let scrollLength = this.scroll.length();
|
|
index = Math.min(index, scrollLength - 1);
|
|
length = Math.min(index + length, scrollLength - 1) - index;
|
|
let node, [leaf, offset] = this.scroll.leaf(index);
|
|
if (leaf == null) return null;
|
|
[node, offset] = leaf.position(offset, true);
|
|
let range = document.createRange();
|
|
if (length > 0) {
|
|
range.setStart(node, offset);
|
|
[leaf, offset] = this.scroll.leaf(index + length);
|
|
if (leaf == null) return null;
|
|
[node, offset] = leaf.position(offset, true);
|
|
range.setEnd(node, offset);
|
|
return range.getBoundingClientRect();
|
|
} else {
|
|
let side = 'left';
|
|
let rect;
|
|
if (node instanceof Text) {
|
|
if (offset < node.data.length) {
|
|
range.setStart(node, offset);
|
|
range.setEnd(node, offset + 1);
|
|
} else {
|
|
range.setStart(node, offset - 1);
|
|
range.setEnd(node, offset);
|
|
side = 'right';
|
|
}
|
|
rect = range.getBoundingClientRect();
|
|
} else {
|
|
rect = leaf.domNode.getBoundingClientRect();
|
|
if (offset > 0) side = 'right';
|
|
}
|
|
return {
|
|
bottom: rect.top + rect.height,
|
|
height: rect.height,
|
|
left: rect[side],
|
|
right: rect[side],
|
|
top: rect.top,
|
|
width: 0
|
|
};
|
|
}
|
|
}
|
|
|
|
getNativeRange() {
|
|
let selection = document.getSelection();
|
|
if (selection == null || selection.rangeCount <= 0) return null;
|
|
let nativeRange = selection.getRangeAt(0);
|
|
if (nativeRange == null) return null;
|
|
let range = this.normalizeNative(nativeRange);
|
|
debug.info('getNativeRange', range);
|
|
return range;
|
|
}
|
|
|
|
getRange() {
|
|
let normalized = this.getNativeRange();
|
|
if (normalized == null) return [null, null];
|
|
let range = this.normalizedToRange(normalized);
|
|
return [range, normalized];
|
|
}
|
|
|
|
hasFocus() {
|
|
return document.activeElement === this.root;
|
|
}
|
|
|
|
normalizedToRange(range) {
|
|
let positions = [[range.start.node, range.start.offset]];
|
|
if (!range.native.collapsed) {
|
|
positions.push([range.end.node, range.end.offset]);
|
|
}
|
|
let indexes = positions.map((position) => {
|
|
let [node, offset] = position;
|
|
let blot = parchment__WEBPACK_IMPORTED_MODULE_0___default().find(node, true);
|
|
let index = blot.offset(this.scroll);
|
|
if (offset === 0) {
|
|
return index;
|
|
} else if (blot instanceof (parchment__WEBPACK_IMPORTED_MODULE_0___default().Container)) {
|
|
return index + blot.length();
|
|
} else {
|
|
return index + blot.index(node, offset);
|
|
}
|
|
});
|
|
let end = Math.min(Math.max(...indexes), this.scroll.length() - 1);
|
|
let start = Math.min(end, ...indexes);
|
|
return new Range(start, end-start);
|
|
}
|
|
|
|
normalizeNative(nativeRange) {
|
|
if (!contains(this.root, nativeRange.startContainer) ||
|
|
(!nativeRange.collapsed && !contains(this.root, nativeRange.endContainer))) {
|
|
return null;
|
|
}
|
|
let range = {
|
|
start: { node: nativeRange.startContainer, offset: nativeRange.startOffset },
|
|
end: { node: nativeRange.endContainer, offset: nativeRange.endOffset },
|
|
native: nativeRange
|
|
};
|
|
[range.start, range.end].forEach(function(position) {
|
|
let node = position.node, offset = position.offset;
|
|
while (!(node instanceof Text) && node.childNodes.length > 0) {
|
|
if (node.childNodes.length > offset) {
|
|
node = node.childNodes[offset];
|
|
offset = 0;
|
|
} else if (node.childNodes.length === offset) {
|
|
node = node.lastChild;
|
|
offset = node instanceof Text ? node.data.length : node.childNodes.length + 1;
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
position.node = node, position.offset = offset;
|
|
});
|
|
return range;
|
|
}
|
|
|
|
rangeToNative(range) {
|
|
let indexes = range.collapsed ? [range.index] : [range.index, range.index + range.length];
|
|
let args = [];
|
|
let scrollLength = this.scroll.length();
|
|
indexes.forEach((index, i) => {
|
|
index = Math.min(scrollLength - 1, index);
|
|
let node, [leaf, offset] = this.scroll.leaf(index);
|
|
[node, offset] = leaf.position(offset, i !== 0);
|
|
args.push(node, offset);
|
|
});
|
|
if (args.length < 2) {
|
|
args = args.concat(args);
|
|
}
|
|
return args;
|
|
}
|
|
|
|
scrollIntoView(scrollingContainer) {
|
|
let range = this.lastRange;
|
|
if (range == null) return;
|
|
let bounds = this.getBounds(range.index, range.length);
|
|
if (bounds == null) return;
|
|
let limit = this.scroll.length()-1;
|
|
let [first, ] = this.scroll.line(Math.min(range.index, limit));
|
|
let last = first;
|
|
if (range.length > 0) {
|
|
[last, ] = this.scroll.line(Math.min(range.index + range.length, limit));
|
|
}
|
|
if (first == null || last == null) return;
|
|
let scrollBounds = scrollingContainer.getBoundingClientRect();
|
|
if (bounds.top < scrollBounds.top) {
|
|
scrollingContainer.scrollTop -= (scrollBounds.top - bounds.top);
|
|
} else if (bounds.bottom > scrollBounds.bottom) {
|
|
scrollingContainer.scrollTop += (bounds.bottom - scrollBounds.bottom);
|
|
}
|
|
}
|
|
|
|
setNativeRange(startNode, startOffset, endNode = startNode, endOffset = startOffset, force = false) {
|
|
debug.info('setNativeRange', startNode, startOffset, endNode, endOffset);
|
|
if (startNode != null && (this.root.parentNode == null || startNode.parentNode == null || endNode.parentNode == null)) {
|
|
return;
|
|
}
|
|
let selection = document.getSelection();
|
|
if (selection == null) return;
|
|
if (startNode != null) {
|
|
if (!this.hasFocus()) this.root.focus();
|
|
let native = (this.getNativeRange() || {}).native;
|
|
if (native == null || force ||
|
|
startNode !== native.startContainer ||
|
|
startOffset !== native.startOffset ||
|
|
endNode !== native.endContainer ||
|
|
endOffset !== native.endOffset) {
|
|
|
|
if (startNode.tagName == "BR") {
|
|
startOffset = [].indexOf.call(startNode.parentNode.childNodes, startNode);
|
|
startNode = startNode.parentNode;
|
|
}
|
|
if (endNode.tagName == "BR") {
|
|
endOffset = [].indexOf.call(endNode.parentNode.childNodes, endNode);
|
|
endNode = endNode.parentNode;
|
|
}
|
|
let range = document.createRange();
|
|
range.setStart(startNode, startOffset);
|
|
range.setEnd(endNode, endOffset);
|
|
selection.removeAllRanges();
|
|
selection.addRange(range);
|
|
}
|
|
} else {
|
|
selection.removeAllRanges();
|
|
this.root.blur();
|
|
document.body.focus(); // root.blur() not enough on IE11+Travis+SauceLabs (but not local VMs)
|
|
}
|
|
}
|
|
|
|
setRange(range, force = false, source = _emitter__WEBPACK_IMPORTED_MODULE_3__.default.sources.API) {
|
|
if (typeof force === 'string') {
|
|
source = force;
|
|
force = false;
|
|
}
|
|
debug.info('setRange', range);
|
|
if (range != null) {
|
|
let args = this.rangeToNative(range);
|
|
this.setNativeRange(...args, force);
|
|
} else {
|
|
this.setNativeRange(null);
|
|
}
|
|
this.update(source);
|
|
}
|
|
|
|
update(source = _emitter__WEBPACK_IMPORTED_MODULE_3__.default.sources.USER) {
|
|
let oldRange = this.lastRange;
|
|
let [lastRange, nativeRange] = this.getRange();
|
|
this.lastRange = lastRange;
|
|
if (this.lastRange != null) {
|
|
this.savedRange = this.lastRange;
|
|
}
|
|
if (!deep_equal__WEBPACK_IMPORTED_MODULE_2___default()(oldRange, this.lastRange)) {
|
|
if (!this.composing && nativeRange != null && nativeRange.native.collapsed && nativeRange.start.node !== this.cursor.textNode) {
|
|
this.cursor.restore();
|
|
}
|
|
let args = [_emitter__WEBPACK_IMPORTED_MODULE_3__.default.events.SELECTION_CHANGE, clone__WEBPACK_IMPORTED_MODULE_1___default()(this.lastRange), clone__WEBPACK_IMPORTED_MODULE_1___default()(oldRange), source];
|
|
this.emitter.emit(_emitter__WEBPACK_IMPORTED_MODULE_3__.default.events.EDITOR_CHANGE, ...args);
|
|
if (source !== _emitter__WEBPACK_IMPORTED_MODULE_3__.default.sources.SILENT) {
|
|
this.emitter.emit(...args);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
function contains(parent, descendant) {
|
|
try {
|
|
// Firefox inserts inaccessible nodes around video elements
|
|
descendant.parentNode;
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
// IE11 has bug with Text nodes
|
|
// https://connect.microsoft.com/IE/feedback/details/780874/node-contains-is-incorrect
|
|
if (descendant instanceof Text) {
|
|
descendant = descendant.parentNode;
|
|
}
|
|
return parent.contains(descendant);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/core/theme.js":
|
|
/*!******************************************!*\
|
|
!*** ./node_modules/quill/core/theme.js ***!
|
|
\******************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
class Theme {
|
|
constructor(quill, options) {
|
|
this.quill = quill;
|
|
this.options = options;
|
|
this.modules = {};
|
|
}
|
|
|
|
init() {
|
|
Object.keys(this.options.modules).forEach((name) => {
|
|
if (this.modules[name] == null) {
|
|
this.addModule(name);
|
|
}
|
|
});
|
|
}
|
|
|
|
addModule(name) {
|
|
let moduleClass = this.quill.constructor.import(`modules/${name}`);
|
|
this.modules[name] = new moduleClass(this.quill, this.options.modules[name] || {});
|
|
return this.modules[name];
|
|
}
|
|
}
|
|
Theme.DEFAULTS = {
|
|
modules: {}
|
|
};
|
|
Theme.themes = {
|
|
'default': Theme
|
|
};
|
|
|
|
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Theme);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/dist/quill.js":
|
|
/*!******************************************!*\
|
|
!*** ./node_modules/quill/dist/quill.js ***!
|
|
\******************************************/
|
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
|
|
/* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "./node_modules/buffer/index.js")["Buffer"];
|
|
/*!
|
|
* Quill Editor v1.3.7
|
|
* https://quilljs.com/
|
|
* Copyright (c) 2014, Jason Chen
|
|
* Copyright (c) 2013, salesforce.com
|
|
*/
|
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
if(true)
|
|
module.exports = factory();
|
|
else {}
|
|
})(typeof self !== 'undefined' ? self : this, function() {
|
|
return /******/ (function(modules) { // webpackBootstrap
|
|
/******/ // The module cache
|
|
/******/ var installedModules = {};
|
|
/******/
|
|
/******/ // The require function
|
|
/******/ function __nested_webpack_require_697__(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, __nested_webpack_require_697__);
|
|
/******/
|
|
/******/ // Flag the module as loaded
|
|
/******/ module.l = true;
|
|
/******/
|
|
/******/ // Return the exports of the module
|
|
/******/ return module.exports;
|
|
/******/ }
|
|
/******/
|
|
/******/
|
|
/******/ // expose the modules object (__webpack_modules__)
|
|
/******/ __nested_webpack_require_697__.m = modules;
|
|
/******/
|
|
/******/ // expose the module cache
|
|
/******/ __nested_webpack_require_697__.c = installedModules;
|
|
/******/
|
|
/******/ // define getter function for harmony exports
|
|
/******/ __nested_webpack_require_697__.d = function(exports, name, getter) {
|
|
/******/ if(!__nested_webpack_require_697__.o(exports, name)) {
|
|
/******/ Object.defineProperty(exports, name, {
|
|
/******/ configurable: false,
|
|
/******/ enumerable: true,
|
|
/******/ get: getter
|
|
/******/ });
|
|
/******/ }
|
|
/******/ };
|
|
/******/
|
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
/******/ __nested_webpack_require_697__.n = function(module) {
|
|
/******/ var getter = module && module.__esModule ?
|
|
/******/ function getDefault() { return module['default']; } :
|
|
/******/ function getModuleExports() { return module; };
|
|
/******/ __nested_webpack_require_697__.d(getter, 'a', getter);
|
|
/******/ return getter;
|
|
/******/ };
|
|
/******/
|
|
/******/ // Object.prototype.hasOwnProperty.call
|
|
/******/ __nested_webpack_require_697__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
/******/
|
|
/******/ // __webpack_public_path__
|
|
/******/ __nested_webpack_require_697__.p = "";
|
|
/******/
|
|
/******/ // Load entry module and return exports
|
|
/******/ return __nested_webpack_require_697__(__nested_webpack_require_697__.s = 109);
|
|
/******/ })
|
|
/************************************************************************/
|
|
/******/ ([
|
|
/* 0 */
|
|
/***/ (function(module, exports, __nested_webpack_require_2976__) {
|
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var container_1 = __nested_webpack_require_2976__(17);
|
|
var format_1 = __nested_webpack_require_2976__(18);
|
|
var leaf_1 = __nested_webpack_require_2976__(19);
|
|
var scroll_1 = __nested_webpack_require_2976__(45);
|
|
var inline_1 = __nested_webpack_require_2976__(46);
|
|
var block_1 = __nested_webpack_require_2976__(47);
|
|
var embed_1 = __nested_webpack_require_2976__(48);
|
|
var text_1 = __nested_webpack_require_2976__(49);
|
|
var attributor_1 = __nested_webpack_require_2976__(12);
|
|
var class_1 = __nested_webpack_require_2976__(32);
|
|
var style_1 = __nested_webpack_require_2976__(33);
|
|
var store_1 = __nested_webpack_require_2976__(31);
|
|
var Registry = __nested_webpack_require_2976__(1);
|
|
var Parchment = {
|
|
Scope: Registry.Scope,
|
|
create: Registry.create,
|
|
find: Registry.find,
|
|
query: Registry.query,
|
|
register: Registry.register,
|
|
Container: container_1.default,
|
|
Format: format_1.default,
|
|
Leaf: leaf_1.default,
|
|
Embed: embed_1.default,
|
|
Scroll: scroll_1.default,
|
|
Block: block_1.default,
|
|
Inline: inline_1.default,
|
|
Text: text_1.default,
|
|
Attributor: {
|
|
Attribute: attributor_1.default,
|
|
Class: class_1.default,
|
|
Style: style_1.default,
|
|
Store: store_1.default,
|
|
},
|
|
};
|
|
exports.default = Parchment;
|
|
|
|
|
|
/***/ }),
|
|
/* 1 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var ParchmentError = /** @class */ (function (_super) {
|
|
__extends(ParchmentError, _super);
|
|
function ParchmentError(message) {
|
|
var _this = this;
|
|
message = '[Parchment] ' + message;
|
|
_this = _super.call(this, message) || this;
|
|
_this.message = message;
|
|
_this.name = _this.constructor.name;
|
|
return _this;
|
|
}
|
|
return ParchmentError;
|
|
}(Error));
|
|
exports.ParchmentError = ParchmentError;
|
|
var attributes = {};
|
|
var classes = {};
|
|
var tags = {};
|
|
var types = {};
|
|
exports.DATA_KEY = '__blot';
|
|
var Scope;
|
|
(function (Scope) {
|
|
Scope[Scope["TYPE"] = 3] = "TYPE";
|
|
Scope[Scope["LEVEL"] = 12] = "LEVEL";
|
|
Scope[Scope["ATTRIBUTE"] = 13] = "ATTRIBUTE";
|
|
Scope[Scope["BLOT"] = 14] = "BLOT";
|
|
Scope[Scope["INLINE"] = 7] = "INLINE";
|
|
Scope[Scope["BLOCK"] = 11] = "BLOCK";
|
|
Scope[Scope["BLOCK_BLOT"] = 10] = "BLOCK_BLOT";
|
|
Scope[Scope["INLINE_BLOT"] = 6] = "INLINE_BLOT";
|
|
Scope[Scope["BLOCK_ATTRIBUTE"] = 9] = "BLOCK_ATTRIBUTE";
|
|
Scope[Scope["INLINE_ATTRIBUTE"] = 5] = "INLINE_ATTRIBUTE";
|
|
Scope[Scope["ANY"] = 15] = "ANY";
|
|
})(Scope = exports.Scope || (exports.Scope = {}));
|
|
function create(input, value) {
|
|
var match = query(input);
|
|
if (match == null) {
|
|
throw new ParchmentError("Unable to create " + input + " blot");
|
|
}
|
|
var BlotClass = match;
|
|
var node =
|
|
// @ts-ignore
|
|
input instanceof Node || input['nodeType'] === Node.TEXT_NODE ? input : BlotClass.create(value);
|
|
return new BlotClass(node, value);
|
|
}
|
|
exports.create = create;
|
|
function find(node, bubble) {
|
|
if (bubble === void 0) { bubble = false; }
|
|
if (node == null)
|
|
return null;
|
|
// @ts-ignore
|
|
if (node[exports.DATA_KEY] != null)
|
|
return node[exports.DATA_KEY].blot;
|
|
if (bubble)
|
|
return find(node.parentNode, bubble);
|
|
return null;
|
|
}
|
|
exports.find = find;
|
|
function query(query, scope) {
|
|
if (scope === void 0) { scope = Scope.ANY; }
|
|
var match;
|
|
if (typeof query === 'string') {
|
|
match = types[query] || attributes[query];
|
|
// @ts-ignore
|
|
}
|
|
else if (query instanceof Text || query['nodeType'] === Node.TEXT_NODE) {
|
|
match = types['text'];
|
|
}
|
|
else if (typeof query === 'number') {
|
|
if (query & Scope.LEVEL & Scope.BLOCK) {
|
|
match = types['block'];
|
|
}
|
|
else if (query & Scope.LEVEL & Scope.INLINE) {
|
|
match = types['inline'];
|
|
}
|
|
}
|
|
else if (query instanceof HTMLElement) {
|
|
var names = (query.getAttribute('class') || '').split(/\s+/);
|
|
for (var i in names) {
|
|
match = classes[names[i]];
|
|
if (match)
|
|
break;
|
|
}
|
|
match = match || tags[query.tagName];
|
|
}
|
|
if (match == null)
|
|
return null;
|
|
// @ts-ignore
|
|
if (scope & Scope.LEVEL & match.scope && scope & Scope.TYPE & match.scope)
|
|
return match;
|
|
return null;
|
|
}
|
|
exports.query = query;
|
|
function register() {
|
|
var Definitions = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
Definitions[_i] = arguments[_i];
|
|
}
|
|
if (Definitions.length > 1) {
|
|
return Definitions.map(function (d) {
|
|
return register(d);
|
|
});
|
|
}
|
|
var Definition = Definitions[0];
|
|
if (typeof Definition.blotName !== 'string' && typeof Definition.attrName !== 'string') {
|
|
throw new ParchmentError('Invalid definition');
|
|
}
|
|
else if (Definition.blotName === 'abstract') {
|
|
throw new ParchmentError('Cannot register abstract class');
|
|
}
|
|
types[Definition.blotName || Definition.attrName] = Definition;
|
|
if (typeof Definition.keyName === 'string') {
|
|
attributes[Definition.keyName] = Definition;
|
|
}
|
|
else {
|
|
if (Definition.className != null) {
|
|
classes[Definition.className] = Definition;
|
|
}
|
|
if (Definition.tagName != null) {
|
|
if (Array.isArray(Definition.tagName)) {
|
|
Definition.tagName = Definition.tagName.map(function (tagName) {
|
|
return tagName.toUpperCase();
|
|
});
|
|
}
|
|
else {
|
|
Definition.tagName = Definition.tagName.toUpperCase();
|
|
}
|
|
var tagNames = Array.isArray(Definition.tagName) ? Definition.tagName : [Definition.tagName];
|
|
tagNames.forEach(function (tag) {
|
|
if (tags[tag] == null || Definition.className == null) {
|
|
tags[tag] = Definition;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
return Definition;
|
|
}
|
|
exports.register = register;
|
|
|
|
|
|
/***/ }),
|
|
/* 2 */
|
|
/***/ (function(module, exports, __nested_webpack_require_9445__) {
|
|
|
|
var diff = __nested_webpack_require_9445__(51);
|
|
var equal = __nested_webpack_require_9445__(11);
|
|
var extend = __nested_webpack_require_9445__(3);
|
|
var op = __nested_webpack_require_9445__(20);
|
|
|
|
|
|
var NULL_CHARACTER = String.fromCharCode(0); // Placeholder char for embed in diff()
|
|
|
|
|
|
var Delta = function (ops) {
|
|
// Assume we are given a well formed ops
|
|
if (Array.isArray(ops)) {
|
|
this.ops = ops;
|
|
} else if (ops != null && Array.isArray(ops.ops)) {
|
|
this.ops = ops.ops;
|
|
} else {
|
|
this.ops = [];
|
|
}
|
|
};
|
|
|
|
|
|
Delta.prototype.insert = function (text, attributes) {
|
|
var newOp = {};
|
|
if (text.length === 0) return this;
|
|
newOp.insert = text;
|
|
if (attributes != null && typeof attributes === 'object' && Object.keys(attributes).length > 0) {
|
|
newOp.attributes = attributes;
|
|
}
|
|
return this.push(newOp);
|
|
};
|
|
|
|
Delta.prototype['delete'] = function (length) {
|
|
if (length <= 0) return this;
|
|
return this.push({ 'delete': length });
|
|
};
|
|
|
|
Delta.prototype.retain = function (length, attributes) {
|
|
if (length <= 0) return this;
|
|
var newOp = { retain: length };
|
|
if (attributes != null && typeof attributes === 'object' && Object.keys(attributes).length > 0) {
|
|
newOp.attributes = attributes;
|
|
}
|
|
return this.push(newOp);
|
|
};
|
|
|
|
Delta.prototype.push = function (newOp) {
|
|
var index = this.ops.length;
|
|
var lastOp = this.ops[index - 1];
|
|
newOp = extend(true, {}, newOp);
|
|
if (typeof lastOp === 'object') {
|
|
if (typeof newOp['delete'] === 'number' && typeof lastOp['delete'] === 'number') {
|
|
this.ops[index - 1] = { 'delete': lastOp['delete'] + newOp['delete'] };
|
|
return this;
|
|
}
|
|
// Since it does not matter if we insert before or after deleting at the same index,
|
|
// always prefer to insert first
|
|
if (typeof lastOp['delete'] === 'number' && newOp.insert != null) {
|
|
index -= 1;
|
|
lastOp = this.ops[index - 1];
|
|
if (typeof lastOp !== 'object') {
|
|
this.ops.unshift(newOp);
|
|
return this;
|
|
}
|
|
}
|
|
if (equal(newOp.attributes, lastOp.attributes)) {
|
|
if (typeof newOp.insert === 'string' && typeof lastOp.insert === 'string') {
|
|
this.ops[index - 1] = { insert: lastOp.insert + newOp.insert };
|
|
if (typeof newOp.attributes === 'object') this.ops[index - 1].attributes = newOp.attributes
|
|
return this;
|
|
} else if (typeof newOp.retain === 'number' && typeof lastOp.retain === 'number') {
|
|
this.ops[index - 1] = { retain: lastOp.retain + newOp.retain };
|
|
if (typeof newOp.attributes === 'object') this.ops[index - 1].attributes = newOp.attributes
|
|
return this;
|
|
}
|
|
}
|
|
}
|
|
if (index === this.ops.length) {
|
|
this.ops.push(newOp);
|
|
} else {
|
|
this.ops.splice(index, 0, newOp);
|
|
}
|
|
return this;
|
|
};
|
|
|
|
Delta.prototype.chop = function () {
|
|
var lastOp = this.ops[this.ops.length - 1];
|
|
if (lastOp && lastOp.retain && !lastOp.attributes) {
|
|
this.ops.pop();
|
|
}
|
|
return this;
|
|
};
|
|
|
|
Delta.prototype.filter = function (predicate) {
|
|
return this.ops.filter(predicate);
|
|
};
|
|
|
|
Delta.prototype.forEach = function (predicate) {
|
|
this.ops.forEach(predicate);
|
|
};
|
|
|
|
Delta.prototype.map = function (predicate) {
|
|
return this.ops.map(predicate);
|
|
};
|
|
|
|
Delta.prototype.partition = function (predicate) {
|
|
var passed = [], failed = [];
|
|
this.forEach(function(op) {
|
|
var target = predicate(op) ? passed : failed;
|
|
target.push(op);
|
|
});
|
|
return [passed, failed];
|
|
};
|
|
|
|
Delta.prototype.reduce = function (predicate, initial) {
|
|
return this.ops.reduce(predicate, initial);
|
|
};
|
|
|
|
Delta.prototype.changeLength = function () {
|
|
return this.reduce(function (length, elem) {
|
|
if (elem.insert) {
|
|
return length + op.length(elem);
|
|
} else if (elem.delete) {
|
|
return length - elem.delete;
|
|
}
|
|
return length;
|
|
}, 0);
|
|
};
|
|
|
|
Delta.prototype.length = function () {
|
|
return this.reduce(function (length, elem) {
|
|
return length + op.length(elem);
|
|
}, 0);
|
|
};
|
|
|
|
Delta.prototype.slice = function (start, end) {
|
|
start = start || 0;
|
|
if (typeof end !== 'number') end = Infinity;
|
|
var ops = [];
|
|
var iter = op.iterator(this.ops);
|
|
var index = 0;
|
|
while (index < end && iter.hasNext()) {
|
|
var nextOp;
|
|
if (index < start) {
|
|
nextOp = iter.next(start - index);
|
|
} else {
|
|
nextOp = iter.next(end - index);
|
|
ops.push(nextOp);
|
|
}
|
|
index += op.length(nextOp);
|
|
}
|
|
return new Delta(ops);
|
|
};
|
|
|
|
|
|
Delta.prototype.compose = function (other) {
|
|
var thisIter = op.iterator(this.ops);
|
|
var otherIter = op.iterator(other.ops);
|
|
var ops = [];
|
|
var firstOther = otherIter.peek();
|
|
if (firstOther != null && typeof firstOther.retain === 'number' && firstOther.attributes == null) {
|
|
var firstLeft = firstOther.retain;
|
|
while (thisIter.peekType() === 'insert' && thisIter.peekLength() <= firstLeft) {
|
|
firstLeft -= thisIter.peekLength();
|
|
ops.push(thisIter.next());
|
|
}
|
|
if (firstOther.retain - firstLeft > 0) {
|
|
otherIter.next(firstOther.retain - firstLeft);
|
|
}
|
|
}
|
|
var delta = new Delta(ops);
|
|
while (thisIter.hasNext() || otherIter.hasNext()) {
|
|
if (otherIter.peekType() === 'insert') {
|
|
delta.push(otherIter.next());
|
|
} else if (thisIter.peekType() === 'delete') {
|
|
delta.push(thisIter.next());
|
|
} else {
|
|
var length = Math.min(thisIter.peekLength(), otherIter.peekLength());
|
|
var thisOp = thisIter.next(length);
|
|
var otherOp = otherIter.next(length);
|
|
if (typeof otherOp.retain === 'number') {
|
|
var newOp = {};
|
|
if (typeof thisOp.retain === 'number') {
|
|
newOp.retain = length;
|
|
} else {
|
|
newOp.insert = thisOp.insert;
|
|
}
|
|
// Preserve null when composing with a retain, otherwise remove it for inserts
|
|
var attributes = op.attributes.compose(thisOp.attributes, otherOp.attributes, typeof thisOp.retain === 'number');
|
|
if (attributes) newOp.attributes = attributes;
|
|
delta.push(newOp);
|
|
|
|
// Optimization if rest of other is just retain
|
|
if (!otherIter.hasNext() && equal(delta.ops[delta.ops.length - 1], newOp)) {
|
|
var rest = new Delta(thisIter.rest());
|
|
return delta.concat(rest).chop();
|
|
}
|
|
|
|
// Other op should be delete, we could be an insert or retain
|
|
// Insert + delete cancels out
|
|
} else if (typeof otherOp['delete'] === 'number' && typeof thisOp.retain === 'number') {
|
|
delta.push(otherOp);
|
|
}
|
|
}
|
|
}
|
|
return delta.chop();
|
|
};
|
|
|
|
Delta.prototype.concat = function (other) {
|
|
var delta = new Delta(this.ops.slice());
|
|
if (other.ops.length > 0) {
|
|
delta.push(other.ops[0]);
|
|
delta.ops = delta.ops.concat(other.ops.slice(1));
|
|
}
|
|
return delta;
|
|
};
|
|
|
|
Delta.prototype.diff = function (other, index) {
|
|
if (this.ops === other.ops) {
|
|
return new Delta();
|
|
}
|
|
var strings = [this, other].map(function (delta) {
|
|
return delta.map(function (op) {
|
|
if (op.insert != null) {
|
|
return typeof op.insert === 'string' ? op.insert : NULL_CHARACTER;
|
|
}
|
|
var prep = (delta === other) ? 'on' : 'with';
|
|
throw new Error('diff() called ' + prep + ' non-document');
|
|
}).join('');
|
|
});
|
|
var delta = new Delta();
|
|
var diffResult = diff(strings[0], strings[1], index);
|
|
var thisIter = op.iterator(this.ops);
|
|
var otherIter = op.iterator(other.ops);
|
|
diffResult.forEach(function (component) {
|
|
var length = component[1].length;
|
|
while (length > 0) {
|
|
var opLength = 0;
|
|
switch (component[0]) {
|
|
case diff.INSERT:
|
|
opLength = Math.min(otherIter.peekLength(), length);
|
|
delta.push(otherIter.next(opLength));
|
|
break;
|
|
case diff.DELETE:
|
|
opLength = Math.min(length, thisIter.peekLength());
|
|
thisIter.next(opLength);
|
|
delta['delete'](opLength);
|
|
break;
|
|
case diff.EQUAL:
|
|
opLength = Math.min(thisIter.peekLength(), otherIter.peekLength(), length);
|
|
var thisOp = thisIter.next(opLength);
|
|
var otherOp = otherIter.next(opLength);
|
|
if (equal(thisOp.insert, otherOp.insert)) {
|
|
delta.retain(opLength, op.attributes.diff(thisOp.attributes, otherOp.attributes));
|
|
} else {
|
|
delta.push(otherOp)['delete'](opLength);
|
|
}
|
|
break;
|
|
}
|
|
length -= opLength;
|
|
}
|
|
});
|
|
return delta.chop();
|
|
};
|
|
|
|
Delta.prototype.eachLine = function (predicate, newline) {
|
|
newline = newline || '\n';
|
|
var iter = op.iterator(this.ops);
|
|
var line = new Delta();
|
|
var i = 0;
|
|
while (iter.hasNext()) {
|
|
if (iter.peekType() !== 'insert') return;
|
|
var thisOp = iter.peek();
|
|
var start = op.length(thisOp) - iter.peekLength();
|
|
var index = typeof thisOp.insert === 'string' ?
|
|
thisOp.insert.indexOf(newline, start) - start : -1;
|
|
if (index < 0) {
|
|
line.push(iter.next());
|
|
} else if (index > 0) {
|
|
line.push(iter.next(index));
|
|
} else {
|
|
if (predicate(line, iter.next(1).attributes || {}, i) === false) {
|
|
return;
|
|
}
|
|
i += 1;
|
|
line = new Delta();
|
|
}
|
|
}
|
|
if (line.length() > 0) {
|
|
predicate(line, {}, i);
|
|
}
|
|
};
|
|
|
|
Delta.prototype.transform = function (other, priority) {
|
|
priority = !!priority;
|
|
if (typeof other === 'number') {
|
|
return this.transformPosition(other, priority);
|
|
}
|
|
var thisIter = op.iterator(this.ops);
|
|
var otherIter = op.iterator(other.ops);
|
|
var delta = new Delta();
|
|
while (thisIter.hasNext() || otherIter.hasNext()) {
|
|
if (thisIter.peekType() === 'insert' && (priority || otherIter.peekType() !== 'insert')) {
|
|
delta.retain(op.length(thisIter.next()));
|
|
} else if (otherIter.peekType() === 'insert') {
|
|
delta.push(otherIter.next());
|
|
} else {
|
|
var length = Math.min(thisIter.peekLength(), otherIter.peekLength());
|
|
var thisOp = thisIter.next(length);
|
|
var otherOp = otherIter.next(length);
|
|
if (thisOp['delete']) {
|
|
// Our delete either makes their delete redundant or removes their retain
|
|
continue;
|
|
} else if (otherOp['delete']) {
|
|
delta.push(otherOp);
|
|
} else {
|
|
// We retain either their retain or insert
|
|
delta.retain(length, op.attributes.transform(thisOp.attributes, otherOp.attributes, priority));
|
|
}
|
|
}
|
|
}
|
|
return delta.chop();
|
|
};
|
|
|
|
Delta.prototype.transformPosition = function (index, priority) {
|
|
priority = !!priority;
|
|
var thisIter = op.iterator(this.ops);
|
|
var offset = 0;
|
|
while (thisIter.hasNext() && offset <= index) {
|
|
var length = thisIter.peekLength();
|
|
var nextType = thisIter.peekType();
|
|
thisIter.next();
|
|
if (nextType === 'delete') {
|
|
index -= Math.min(length, index - offset);
|
|
continue;
|
|
} else if (nextType === 'insert' && (offset < index || !priority)) {
|
|
index += length;
|
|
}
|
|
offset += length;
|
|
}
|
|
return index;
|
|
};
|
|
|
|
|
|
module.exports = Delta;
|
|
|
|
|
|
/***/ }),
|
|
/* 3 */
|
|
/***/ (function(module, exports) {
|
|
|
|
'use strict';
|
|
|
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
var toStr = Object.prototype.toString;
|
|
var defineProperty = Object.defineProperty;
|
|
var gOPD = Object.getOwnPropertyDescriptor;
|
|
|
|
var isArray = function isArray(arr) {
|
|
if (typeof Array.isArray === 'function') {
|
|
return Array.isArray(arr);
|
|
}
|
|
|
|
return toStr.call(arr) === '[object Array]';
|
|
};
|
|
|
|
var isPlainObject = function isPlainObject(obj) {
|
|
if (!obj || toStr.call(obj) !== '[object Object]') {
|
|
return false;
|
|
}
|
|
|
|
var hasOwnConstructor = hasOwn.call(obj, 'constructor');
|
|
var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf');
|
|
// Not own constructor property must be Object
|
|
if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
|
|
return false;
|
|
}
|
|
|
|
// Own properties are enumerated firstly, so to speed up,
|
|
// if last one is own, then all properties are own.
|
|
var key;
|
|
for (key in obj) { /**/ }
|
|
|
|
return typeof key === 'undefined' || hasOwn.call(obj, key);
|
|
};
|
|
|
|
// If name is '__proto__', and Object.defineProperty is available, define __proto__ as an own property on target
|
|
var setProperty = function setProperty(target, options) {
|
|
if (defineProperty && options.name === '__proto__') {
|
|
defineProperty(target, options.name, {
|
|
enumerable: true,
|
|
configurable: true,
|
|
value: options.newValue,
|
|
writable: true
|
|
});
|
|
} else {
|
|
target[options.name] = options.newValue;
|
|
}
|
|
};
|
|
|
|
// Return undefined instead of __proto__ if '__proto__' is not an own property
|
|
var getProperty = function getProperty(obj, name) {
|
|
if (name === '__proto__') {
|
|
if (!hasOwn.call(obj, name)) {
|
|
return void 0;
|
|
} else if (gOPD) {
|
|
// In early versions of node, obj['__proto__'] is buggy when obj has
|
|
// __proto__ as an own property. Object.getOwnPropertyDescriptor() works.
|
|
return gOPD(obj, name).value;
|
|
}
|
|
}
|
|
|
|
return obj[name];
|
|
};
|
|
|
|
module.exports = function extend() {
|
|
var options, name, src, copy, copyIsArray, clone;
|
|
var target = arguments[0];
|
|
var i = 1;
|
|
var length = arguments.length;
|
|
var deep = false;
|
|
|
|
// Handle a deep copy situation
|
|
if (typeof target === 'boolean') {
|
|
deep = target;
|
|
target = arguments[1] || {};
|
|
// skip the boolean and the target
|
|
i = 2;
|
|
}
|
|
if (target == null || (typeof target !== 'object' && typeof target !== 'function')) {
|
|
target = {};
|
|
}
|
|
|
|
for (; i < length; ++i) {
|
|
options = arguments[i];
|
|
// Only deal with non-null/undefined values
|
|
if (options != null) {
|
|
// Extend the base object
|
|
for (name in options) {
|
|
src = getProperty(target, name);
|
|
copy = getProperty(options, name);
|
|
|
|
// Prevent never-ending loop
|
|
if (target !== copy) {
|
|
// Recurse if we're merging plain objects or arrays
|
|
if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
|
|
if (copyIsArray) {
|
|
copyIsArray = false;
|
|
clone = src && isArray(src) ? src : [];
|
|
} else {
|
|
clone = src && isPlainObject(src) ? src : {};
|
|
}
|
|
|
|
// Never move original objects, clone them
|
|
setProperty(target, { name: name, newValue: extend(deep, clone, copy) });
|
|
|
|
// Don't bring in undefined values
|
|
} else if (typeof copy !== 'undefined') {
|
|
setProperty(target, { name: name, newValue: copy });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Return the modified object
|
|
return target;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
/* 4 */
|
|
/***/ (function(module, exports, __nested_webpack_require_23616__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = exports.BlockEmbed = exports.bubbleFormats = undefined;
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _extend = __nested_webpack_require_23616__(3);
|
|
|
|
var _extend2 = _interopRequireDefault(_extend);
|
|
|
|
var _quillDelta = __nested_webpack_require_23616__(2);
|
|
|
|
var _quillDelta2 = _interopRequireDefault(_quillDelta);
|
|
|
|
var _parchment = __nested_webpack_require_23616__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
var _break = __nested_webpack_require_23616__(16);
|
|
|
|
var _break2 = _interopRequireDefault(_break);
|
|
|
|
var _inline = __nested_webpack_require_23616__(6);
|
|
|
|
var _inline2 = _interopRequireDefault(_inline);
|
|
|
|
var _text = __nested_webpack_require_23616__(7);
|
|
|
|
var _text2 = _interopRequireDefault(_text);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var NEWLINE_LENGTH = 1;
|
|
|
|
var BlockEmbed = function (_Parchment$Embed) {
|
|
_inherits(BlockEmbed, _Parchment$Embed);
|
|
|
|
function BlockEmbed() {
|
|
_classCallCheck(this, BlockEmbed);
|
|
|
|
return _possibleConstructorReturn(this, (BlockEmbed.__proto__ || Object.getPrototypeOf(BlockEmbed)).apply(this, arguments));
|
|
}
|
|
|
|
_createClass(BlockEmbed, [{
|
|
key: 'attach',
|
|
value: function attach() {
|
|
_get(BlockEmbed.prototype.__proto__ || Object.getPrototypeOf(BlockEmbed.prototype), 'attach', this).call(this);
|
|
this.attributes = new _parchment2.default.Attributor.Store(this.domNode);
|
|
}
|
|
}, {
|
|
key: 'delta',
|
|
value: function delta() {
|
|
return new _quillDelta2.default().insert(this.value(), (0, _extend2.default)(this.formats(), this.attributes.values()));
|
|
}
|
|
}, {
|
|
key: 'format',
|
|
value: function format(name, value) {
|
|
var attribute = _parchment2.default.query(name, _parchment2.default.Scope.BLOCK_ATTRIBUTE);
|
|
if (attribute != null) {
|
|
this.attributes.attribute(attribute, value);
|
|
}
|
|
}
|
|
}, {
|
|
key: 'formatAt',
|
|
value: function formatAt(index, length, name, value) {
|
|
this.format(name, value);
|
|
}
|
|
}, {
|
|
key: 'insertAt',
|
|
value: function insertAt(index, value, def) {
|
|
if (typeof value === 'string' && value.endsWith('\n')) {
|
|
var block = _parchment2.default.create(Block.blotName);
|
|
this.parent.insertBefore(block, index === 0 ? this : this.next);
|
|
block.insertAt(0, value.slice(0, -1));
|
|
} else {
|
|
_get(BlockEmbed.prototype.__proto__ || Object.getPrototypeOf(BlockEmbed.prototype), 'insertAt', this).call(this, index, value, def);
|
|
}
|
|
}
|
|
}]);
|
|
|
|
return BlockEmbed;
|
|
}(_parchment2.default.Embed);
|
|
|
|
BlockEmbed.scope = _parchment2.default.Scope.BLOCK_BLOT;
|
|
// It is important for cursor behavior BlockEmbeds use tags that are block level elements
|
|
|
|
|
|
var Block = function (_Parchment$Block) {
|
|
_inherits(Block, _Parchment$Block);
|
|
|
|
function Block(domNode) {
|
|
_classCallCheck(this, Block);
|
|
|
|
var _this2 = _possibleConstructorReturn(this, (Block.__proto__ || Object.getPrototypeOf(Block)).call(this, domNode));
|
|
|
|
_this2.cache = {};
|
|
return _this2;
|
|
}
|
|
|
|
_createClass(Block, [{
|
|
key: 'delta',
|
|
value: function delta() {
|
|
if (this.cache.delta == null) {
|
|
this.cache.delta = this.descendants(_parchment2.default.Leaf).reduce(function (delta, leaf) {
|
|
if (leaf.length() === 0) {
|
|
return delta;
|
|
} else {
|
|
return delta.insert(leaf.value(), bubbleFormats(leaf));
|
|
}
|
|
}, new _quillDelta2.default()).insert('\n', bubbleFormats(this));
|
|
}
|
|
return this.cache.delta;
|
|
}
|
|
}, {
|
|
key: 'deleteAt',
|
|
value: function deleteAt(index, length) {
|
|
_get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'deleteAt', this).call(this, index, length);
|
|
this.cache = {};
|
|
}
|
|
}, {
|
|
key: 'formatAt',
|
|
value: function formatAt(index, length, name, value) {
|
|
if (length <= 0) return;
|
|
if (_parchment2.default.query(name, _parchment2.default.Scope.BLOCK)) {
|
|
if (index + length === this.length()) {
|
|
this.format(name, value);
|
|
}
|
|
} else {
|
|
_get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'formatAt', this).call(this, index, Math.min(length, this.length() - index - 1), name, value);
|
|
}
|
|
this.cache = {};
|
|
}
|
|
}, {
|
|
key: 'insertAt',
|
|
value: function insertAt(index, value, def) {
|
|
if (def != null) return _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'insertAt', this).call(this, index, value, def);
|
|
if (value.length === 0) return;
|
|
var lines = value.split('\n');
|
|
var text = lines.shift();
|
|
if (text.length > 0) {
|
|
if (index < this.length() - 1 || this.children.tail == null) {
|
|
_get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'insertAt', this).call(this, Math.min(index, this.length() - 1), text);
|
|
} else {
|
|
this.children.tail.insertAt(this.children.tail.length(), text);
|
|
}
|
|
this.cache = {};
|
|
}
|
|
var block = this;
|
|
lines.reduce(function (index, line) {
|
|
block = block.split(index, true);
|
|
block.insertAt(0, line);
|
|
return line.length;
|
|
}, index + text.length);
|
|
}
|
|
}, {
|
|
key: 'insertBefore',
|
|
value: function insertBefore(blot, ref) {
|
|
var head = this.children.head;
|
|
_get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'insertBefore', this).call(this, blot, ref);
|
|
if (head instanceof _break2.default) {
|
|
head.remove();
|
|
}
|
|
this.cache = {};
|
|
}
|
|
}, {
|
|
key: 'length',
|
|
value: function length() {
|
|
if (this.cache.length == null) {
|
|
this.cache.length = _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'length', this).call(this) + NEWLINE_LENGTH;
|
|
}
|
|
return this.cache.length;
|
|
}
|
|
}, {
|
|
key: 'moveChildren',
|
|
value: function moveChildren(target, ref) {
|
|
_get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'moveChildren', this).call(this, target, ref);
|
|
this.cache = {};
|
|
}
|
|
}, {
|
|
key: 'optimize',
|
|
value: function optimize(context) {
|
|
_get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'optimize', this).call(this, context);
|
|
this.cache = {};
|
|
}
|
|
}, {
|
|
key: 'path',
|
|
value: function path(index) {
|
|
return _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'path', this).call(this, index, true);
|
|
}
|
|
}, {
|
|
key: 'removeChild',
|
|
value: function removeChild(child) {
|
|
_get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'removeChild', this).call(this, child);
|
|
this.cache = {};
|
|
}
|
|
}, {
|
|
key: 'split',
|
|
value: function split(index) {
|
|
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
|
|
if (force && (index === 0 || index >= this.length() - NEWLINE_LENGTH)) {
|
|
var clone = this.clone();
|
|
if (index === 0) {
|
|
this.parent.insertBefore(clone, this);
|
|
return this;
|
|
} else {
|
|
this.parent.insertBefore(clone, this.next);
|
|
return clone;
|
|
}
|
|
} else {
|
|
var next = _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'split', this).call(this, index, force);
|
|
this.cache = {};
|
|
return next;
|
|
}
|
|
}
|
|
}]);
|
|
|
|
return Block;
|
|
}(_parchment2.default.Block);
|
|
|
|
Block.blotName = 'block';
|
|
Block.tagName = 'P';
|
|
Block.defaultChild = 'break';
|
|
Block.allowedChildren = [_inline2.default, _parchment2.default.Embed, _text2.default];
|
|
|
|
function bubbleFormats(blot) {
|
|
var formats = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
|
|
if (blot == null) return formats;
|
|
if (typeof blot.formats === 'function') {
|
|
formats = (0, _extend2.default)(formats, blot.formats());
|
|
}
|
|
if (blot.parent == null || blot.parent.blotName == 'scroll' || blot.parent.statics.scope !== blot.statics.scope) {
|
|
return formats;
|
|
}
|
|
return bubbleFormats(blot.parent, formats);
|
|
}
|
|
|
|
exports.bubbleFormats = bubbleFormats;
|
|
exports.BlockEmbed = BlockEmbed;
|
|
exports.default = Block;
|
|
|
|
/***/ }),
|
|
/* 5 */
|
|
/***/ (function(module, exports, __nested_webpack_require_33760__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = exports.overload = exports.expandConfig = undefined;
|
|
|
|
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
|
|
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
__nested_webpack_require_33760__(50);
|
|
|
|
var _quillDelta = __nested_webpack_require_33760__(2);
|
|
|
|
var _quillDelta2 = _interopRequireDefault(_quillDelta);
|
|
|
|
var _editor = __nested_webpack_require_33760__(14);
|
|
|
|
var _editor2 = _interopRequireDefault(_editor);
|
|
|
|
var _emitter3 = __nested_webpack_require_33760__(8);
|
|
|
|
var _emitter4 = _interopRequireDefault(_emitter3);
|
|
|
|
var _module = __nested_webpack_require_33760__(9);
|
|
|
|
var _module2 = _interopRequireDefault(_module);
|
|
|
|
var _parchment = __nested_webpack_require_33760__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
var _selection = __nested_webpack_require_33760__(15);
|
|
|
|
var _selection2 = _interopRequireDefault(_selection);
|
|
|
|
var _extend = __nested_webpack_require_33760__(3);
|
|
|
|
var _extend2 = _interopRequireDefault(_extend);
|
|
|
|
var _logger = __nested_webpack_require_33760__(10);
|
|
|
|
var _logger2 = _interopRequireDefault(_logger);
|
|
|
|
var _theme = __nested_webpack_require_33760__(34);
|
|
|
|
var _theme2 = _interopRequireDefault(_theme);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
var debug = (0, _logger2.default)('quill');
|
|
|
|
var Quill = function () {
|
|
_createClass(Quill, null, [{
|
|
key: 'debug',
|
|
value: function debug(limit) {
|
|
if (limit === true) {
|
|
limit = 'log';
|
|
}
|
|
_logger2.default.level(limit);
|
|
}
|
|
}, {
|
|
key: 'find',
|
|
value: function find(node) {
|
|
return node.__quill || _parchment2.default.find(node);
|
|
}
|
|
}, {
|
|
key: 'import',
|
|
value: function _import(name) {
|
|
if (this.imports[name] == null) {
|
|
debug.error('Cannot import ' + name + '. Are you sure it was registered?');
|
|
}
|
|
return this.imports[name];
|
|
}
|
|
}, {
|
|
key: 'register',
|
|
value: function register(path, target) {
|
|
var _this = this;
|
|
|
|
var overwrite = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
|
|
if (typeof path !== 'string') {
|
|
var name = path.attrName || path.blotName;
|
|
if (typeof name === 'string') {
|
|
// register(Blot | Attributor, overwrite)
|
|
this.register('formats/' + name, path, target);
|
|
} else {
|
|
Object.keys(path).forEach(function (key) {
|
|
_this.register(key, path[key], target);
|
|
});
|
|
}
|
|
} else {
|
|
if (this.imports[path] != null && !overwrite) {
|
|
debug.warn('Overwriting ' + path + ' with', target);
|
|
}
|
|
this.imports[path] = target;
|
|
if ((path.startsWith('blots/') || path.startsWith('formats/')) && target.blotName !== 'abstract') {
|
|
_parchment2.default.register(target);
|
|
} else if (path.startsWith('modules') && typeof target.register === 'function') {
|
|
target.register();
|
|
}
|
|
}
|
|
}
|
|
}]);
|
|
|
|
function Quill(container) {
|
|
var _this2 = this;
|
|
|
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
|
|
_classCallCheck(this, Quill);
|
|
|
|
this.options = expandConfig(container, options);
|
|
this.container = this.options.container;
|
|
if (this.container == null) {
|
|
return debug.error('Invalid Quill container', container);
|
|
}
|
|
if (this.options.debug) {
|
|
Quill.debug(this.options.debug);
|
|
}
|
|
var html = this.container.innerHTML.trim();
|
|
this.container.classList.add('ql-container');
|
|
this.container.innerHTML = '';
|
|
this.container.__quill = this;
|
|
this.root = this.addContainer('ql-editor');
|
|
this.root.classList.add('ql-blank');
|
|
this.root.setAttribute('data-gramm', false);
|
|
this.scrollingContainer = this.options.scrollingContainer || this.root;
|
|
this.emitter = new _emitter4.default();
|
|
this.scroll = _parchment2.default.create(this.root, {
|
|
emitter: this.emitter,
|
|
whitelist: this.options.formats
|
|
});
|
|
this.editor = new _editor2.default(this.scroll);
|
|
this.selection = new _selection2.default(this.scroll, this.emitter);
|
|
this.theme = new this.options.theme(this, this.options);
|
|
this.keyboard = this.theme.addModule('keyboard');
|
|
this.clipboard = this.theme.addModule('clipboard');
|
|
this.history = this.theme.addModule('history');
|
|
this.theme.init();
|
|
this.emitter.on(_emitter4.default.events.EDITOR_CHANGE, function (type) {
|
|
if (type === _emitter4.default.events.TEXT_CHANGE) {
|
|
_this2.root.classList.toggle('ql-blank', _this2.editor.isBlank());
|
|
}
|
|
});
|
|
this.emitter.on(_emitter4.default.events.SCROLL_UPDATE, function (source, mutations) {
|
|
var range = _this2.selection.lastRange;
|
|
var index = range && range.length === 0 ? range.index : undefined;
|
|
modify.call(_this2, function () {
|
|
return _this2.editor.update(null, mutations, index);
|
|
}, source);
|
|
});
|
|
var contents = this.clipboard.convert('<div class=\'ql-editor\' style="white-space: normal;">' + html + '<p><br></p></div>');
|
|
this.setContents(contents);
|
|
this.history.clear();
|
|
if (this.options.placeholder) {
|
|
this.root.setAttribute('data-placeholder', this.options.placeholder);
|
|
}
|
|
if (this.options.readOnly) {
|
|
this.disable();
|
|
}
|
|
}
|
|
|
|
_createClass(Quill, [{
|
|
key: 'addContainer',
|
|
value: function addContainer(container) {
|
|
var refNode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
|
|
if (typeof container === 'string') {
|
|
var className = container;
|
|
container = document.createElement('div');
|
|
container.classList.add(className);
|
|
}
|
|
this.container.insertBefore(container, refNode);
|
|
return container;
|
|
}
|
|
}, {
|
|
key: 'blur',
|
|
value: function blur() {
|
|
this.selection.setRange(null);
|
|
}
|
|
}, {
|
|
key: 'deleteText',
|
|
value: function deleteText(index, length, source) {
|
|
var _this3 = this;
|
|
|
|
var _overload = overload(index, length, source);
|
|
|
|
var _overload2 = _slicedToArray(_overload, 4);
|
|
|
|
index = _overload2[0];
|
|
length = _overload2[1];
|
|
source = _overload2[3];
|
|
|
|
return modify.call(this, function () {
|
|
return _this3.editor.deleteText(index, length);
|
|
}, source, index, -1 * length);
|
|
}
|
|
}, {
|
|
key: 'disable',
|
|
value: function disable() {
|
|
this.enable(false);
|
|
}
|
|
}, {
|
|
key: 'enable',
|
|
value: function enable() {
|
|
var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
|
|
this.scroll.enable(enabled);
|
|
this.container.classList.toggle('ql-disabled', !enabled);
|
|
}
|
|
}, {
|
|
key: 'focus',
|
|
value: function focus() {
|
|
var scrollTop = this.scrollingContainer.scrollTop;
|
|
this.selection.focus();
|
|
this.scrollingContainer.scrollTop = scrollTop;
|
|
this.scrollIntoView();
|
|
}
|
|
}, {
|
|
key: 'format',
|
|
value: function format(name, value) {
|
|
var _this4 = this;
|
|
|
|
var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _emitter4.default.sources.API;
|
|
|
|
return modify.call(this, function () {
|
|
var range = _this4.getSelection(true);
|
|
var change = new _quillDelta2.default();
|
|
if (range == null) {
|
|
return change;
|
|
} else if (_parchment2.default.query(name, _parchment2.default.Scope.BLOCK)) {
|
|
change = _this4.editor.formatLine(range.index, range.length, _defineProperty({}, name, value));
|
|
} else if (range.length === 0) {
|
|
_this4.selection.format(name, value);
|
|
return change;
|
|
} else {
|
|
change = _this4.editor.formatText(range.index, range.length, _defineProperty({}, name, value));
|
|
}
|
|
_this4.setSelection(range, _emitter4.default.sources.SILENT);
|
|
return change;
|
|
}, source);
|
|
}
|
|
}, {
|
|
key: 'formatLine',
|
|
value: function formatLine(index, length, name, value, source) {
|
|
var _this5 = this;
|
|
|
|
var formats = void 0;
|
|
|
|
var _overload3 = overload(index, length, name, value, source);
|
|
|
|
var _overload4 = _slicedToArray(_overload3, 4);
|
|
|
|
index = _overload4[0];
|
|
length = _overload4[1];
|
|
formats = _overload4[2];
|
|
source = _overload4[3];
|
|
|
|
return modify.call(this, function () {
|
|
return _this5.editor.formatLine(index, length, formats);
|
|
}, source, index, 0);
|
|
}
|
|
}, {
|
|
key: 'formatText',
|
|
value: function formatText(index, length, name, value, source) {
|
|
var _this6 = this;
|
|
|
|
var formats = void 0;
|
|
|
|
var _overload5 = overload(index, length, name, value, source);
|
|
|
|
var _overload6 = _slicedToArray(_overload5, 4);
|
|
|
|
index = _overload6[0];
|
|
length = _overload6[1];
|
|
formats = _overload6[2];
|
|
source = _overload6[3];
|
|
|
|
return modify.call(this, function () {
|
|
return _this6.editor.formatText(index, length, formats);
|
|
}, source, index, 0);
|
|
}
|
|
}, {
|
|
key: 'getBounds',
|
|
value: function getBounds(index) {
|
|
var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
|
|
var bounds = void 0;
|
|
if (typeof index === 'number') {
|
|
bounds = this.selection.getBounds(index, length);
|
|
} else {
|
|
bounds = this.selection.getBounds(index.index, index.length);
|
|
}
|
|
var containerBounds = this.container.getBoundingClientRect();
|
|
return {
|
|
bottom: bounds.bottom - containerBounds.top,
|
|
height: bounds.height,
|
|
left: bounds.left - containerBounds.left,
|
|
right: bounds.right - containerBounds.left,
|
|
top: bounds.top - containerBounds.top,
|
|
width: bounds.width
|
|
};
|
|
}
|
|
}, {
|
|
key: 'getContents',
|
|
value: function getContents() {
|
|
var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getLength() - index;
|
|
|
|
var _overload7 = overload(index, length);
|
|
|
|
var _overload8 = _slicedToArray(_overload7, 2);
|
|
|
|
index = _overload8[0];
|
|
length = _overload8[1];
|
|
|
|
return this.editor.getContents(index, length);
|
|
}
|
|
}, {
|
|
key: 'getFormat',
|
|
value: function getFormat() {
|
|
var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getSelection(true);
|
|
var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
|
|
if (typeof index === 'number') {
|
|
return this.editor.getFormat(index, length);
|
|
} else {
|
|
return this.editor.getFormat(index.index, index.length);
|
|
}
|
|
}
|
|
}, {
|
|
key: 'getIndex',
|
|
value: function getIndex(blot) {
|
|
return blot.offset(this.scroll);
|
|
}
|
|
}, {
|
|
key: 'getLength',
|
|
value: function getLength() {
|
|
return this.scroll.length();
|
|
}
|
|
}, {
|
|
key: 'getLeaf',
|
|
value: function getLeaf(index) {
|
|
return this.scroll.leaf(index);
|
|
}
|
|
}, {
|
|
key: 'getLine',
|
|
value: function getLine(index) {
|
|
return this.scroll.line(index);
|
|
}
|
|
}, {
|
|
key: 'getLines',
|
|
value: function getLines() {
|
|
var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Number.MAX_VALUE;
|
|
|
|
if (typeof index !== 'number') {
|
|
return this.scroll.lines(index.index, index.length);
|
|
} else {
|
|
return this.scroll.lines(index, length);
|
|
}
|
|
}
|
|
}, {
|
|
key: 'getModule',
|
|
value: function getModule(name) {
|
|
return this.theme.modules[name];
|
|
}
|
|
}, {
|
|
key: 'getSelection',
|
|
value: function getSelection() {
|
|
var focus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
|
|
if (focus) this.focus();
|
|
this.update(); // Make sure we access getRange with editor in consistent state
|
|
return this.selection.getRange()[0];
|
|
}
|
|
}, {
|
|
key: 'getText',
|
|
value: function getText() {
|
|
var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getLength() - index;
|
|
|
|
var _overload9 = overload(index, length);
|
|
|
|
var _overload10 = _slicedToArray(_overload9, 2);
|
|
|
|
index = _overload10[0];
|
|
length = _overload10[1];
|
|
|
|
return this.editor.getText(index, length);
|
|
}
|
|
}, {
|
|
key: 'hasFocus',
|
|
value: function hasFocus() {
|
|
return this.selection.hasFocus();
|
|
}
|
|
}, {
|
|
key: 'insertEmbed',
|
|
value: function insertEmbed(index, embed, value) {
|
|
var _this7 = this;
|
|
|
|
var source = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Quill.sources.API;
|
|
|
|
return modify.call(this, function () {
|
|
return _this7.editor.insertEmbed(index, embed, value);
|
|
}, source, index);
|
|
}
|
|
}, {
|
|
key: 'insertText',
|
|
value: function insertText(index, text, name, value, source) {
|
|
var _this8 = this;
|
|
|
|
var formats = void 0;
|
|
|
|
var _overload11 = overload(index, 0, name, value, source);
|
|
|
|
var _overload12 = _slicedToArray(_overload11, 4);
|
|
|
|
index = _overload12[0];
|
|
formats = _overload12[2];
|
|
source = _overload12[3];
|
|
|
|
return modify.call(this, function () {
|
|
return _this8.editor.insertText(index, text, formats);
|
|
}, source, index, text.length);
|
|
}
|
|
}, {
|
|
key: 'isEnabled',
|
|
value: function isEnabled() {
|
|
return !this.container.classList.contains('ql-disabled');
|
|
}
|
|
}, {
|
|
key: 'off',
|
|
value: function off() {
|
|
return this.emitter.off.apply(this.emitter, arguments);
|
|
}
|
|
}, {
|
|
key: 'on',
|
|
value: function on() {
|
|
return this.emitter.on.apply(this.emitter, arguments);
|
|
}
|
|
}, {
|
|
key: 'once',
|
|
value: function once() {
|
|
return this.emitter.once.apply(this.emitter, arguments);
|
|
}
|
|
}, {
|
|
key: 'pasteHTML',
|
|
value: function pasteHTML(index, html, source) {
|
|
this.clipboard.dangerouslyPasteHTML(index, html, source);
|
|
}
|
|
}, {
|
|
key: 'removeFormat',
|
|
value: function removeFormat(index, length, source) {
|
|
var _this9 = this;
|
|
|
|
var _overload13 = overload(index, length, source);
|
|
|
|
var _overload14 = _slicedToArray(_overload13, 4);
|
|
|
|
index = _overload14[0];
|
|
length = _overload14[1];
|
|
source = _overload14[3];
|
|
|
|
return modify.call(this, function () {
|
|
return _this9.editor.removeFormat(index, length);
|
|
}, source, index);
|
|
}
|
|
}, {
|
|
key: 'scrollIntoView',
|
|
value: function scrollIntoView() {
|
|
this.selection.scrollIntoView(this.scrollingContainer);
|
|
}
|
|
}, {
|
|
key: 'setContents',
|
|
value: function setContents(delta) {
|
|
var _this10 = this;
|
|
|
|
var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _emitter4.default.sources.API;
|
|
|
|
return modify.call(this, function () {
|
|
delta = new _quillDelta2.default(delta);
|
|
var length = _this10.getLength();
|
|
var deleted = _this10.editor.deleteText(0, length);
|
|
var applied = _this10.editor.applyDelta(delta);
|
|
var lastOp = applied.ops[applied.ops.length - 1];
|
|
if (lastOp != null && typeof lastOp.insert === 'string' && lastOp.insert[lastOp.insert.length - 1] === '\n') {
|
|
_this10.editor.deleteText(_this10.getLength() - 1, 1);
|
|
applied.delete(1);
|
|
}
|
|
var ret = deleted.compose(applied);
|
|
return ret;
|
|
}, source);
|
|
}
|
|
}, {
|
|
key: 'setSelection',
|
|
value: function setSelection(index, length, source) {
|
|
if (index == null) {
|
|
this.selection.setRange(null, length || Quill.sources.API);
|
|
} else {
|
|
var _overload15 = overload(index, length, source);
|
|
|
|
var _overload16 = _slicedToArray(_overload15, 4);
|
|
|
|
index = _overload16[0];
|
|
length = _overload16[1];
|
|
source = _overload16[3];
|
|
|
|
this.selection.setRange(new _selection.Range(index, length), source);
|
|
if (source !== _emitter4.default.sources.SILENT) {
|
|
this.selection.scrollIntoView(this.scrollingContainer);
|
|
}
|
|
}
|
|
}
|
|
}, {
|
|
key: 'setText',
|
|
value: function setText(text) {
|
|
var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _emitter4.default.sources.API;
|
|
|
|
var delta = new _quillDelta2.default().insert(text);
|
|
return this.setContents(delta, source);
|
|
}
|
|
}, {
|
|
key: 'update',
|
|
value: function update() {
|
|
var source = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _emitter4.default.sources.USER;
|
|
|
|
var change = this.scroll.update(source); // Will update selection before selection.update() does if text changes
|
|
this.selection.update(source);
|
|
return change;
|
|
}
|
|
}, {
|
|
key: 'updateContents',
|
|
value: function updateContents(delta) {
|
|
var _this11 = this;
|
|
|
|
var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _emitter4.default.sources.API;
|
|
|
|
return modify.call(this, function () {
|
|
delta = new _quillDelta2.default(delta);
|
|
return _this11.editor.applyDelta(delta, source);
|
|
}, source, true);
|
|
}
|
|
}]);
|
|
|
|
return Quill;
|
|
}();
|
|
|
|
Quill.DEFAULTS = {
|
|
bounds: null,
|
|
formats: null,
|
|
modules: {},
|
|
placeholder: '',
|
|
readOnly: false,
|
|
scrollingContainer: null,
|
|
strict: true,
|
|
theme: 'default'
|
|
};
|
|
Quill.events = _emitter4.default.events;
|
|
Quill.sources = _emitter4.default.sources;
|
|
// eslint-disable-next-line no-undef
|
|
Quill.version = false ? 0 : "1.3.7";
|
|
|
|
Quill.imports = {
|
|
'delta': _quillDelta2.default,
|
|
'parchment': _parchment2.default,
|
|
'core/module': _module2.default,
|
|
'core/theme': _theme2.default
|
|
};
|
|
|
|
function expandConfig(container, userConfig) {
|
|
userConfig = (0, _extend2.default)(true, {
|
|
container: container,
|
|
modules: {
|
|
clipboard: true,
|
|
keyboard: true,
|
|
history: true
|
|
}
|
|
}, userConfig);
|
|
if (!userConfig.theme || userConfig.theme === Quill.DEFAULTS.theme) {
|
|
userConfig.theme = _theme2.default;
|
|
} else {
|
|
userConfig.theme = Quill.import('themes/' + userConfig.theme);
|
|
if (userConfig.theme == null) {
|
|
throw new Error('Invalid theme ' + userConfig.theme + '. Did you register it?');
|
|
}
|
|
}
|
|
var themeConfig = (0, _extend2.default)(true, {}, userConfig.theme.DEFAULTS);
|
|
[themeConfig, userConfig].forEach(function (config) {
|
|
config.modules = config.modules || {};
|
|
Object.keys(config.modules).forEach(function (module) {
|
|
if (config.modules[module] === true) {
|
|
config.modules[module] = {};
|
|
}
|
|
});
|
|
});
|
|
var moduleNames = Object.keys(themeConfig.modules).concat(Object.keys(userConfig.modules));
|
|
var moduleConfig = moduleNames.reduce(function (config, name) {
|
|
var moduleClass = Quill.import('modules/' + name);
|
|
if (moduleClass == null) {
|
|
debug.error('Cannot load ' + name + ' module. Are you sure you registered it?');
|
|
} else {
|
|
config[name] = moduleClass.DEFAULTS || {};
|
|
}
|
|
return config;
|
|
}, {});
|
|
// Special case toolbar shorthand
|
|
if (userConfig.modules != null && userConfig.modules.toolbar && userConfig.modules.toolbar.constructor !== Object) {
|
|
userConfig.modules.toolbar = {
|
|
container: userConfig.modules.toolbar
|
|
};
|
|
}
|
|
userConfig = (0, _extend2.default)(true, {}, Quill.DEFAULTS, { modules: moduleConfig }, themeConfig, userConfig);
|
|
['bounds', 'container', 'scrollingContainer'].forEach(function (key) {
|
|
if (typeof userConfig[key] === 'string') {
|
|
userConfig[key] = document.querySelector(userConfig[key]);
|
|
}
|
|
});
|
|
userConfig.modules = Object.keys(userConfig.modules).reduce(function (config, name) {
|
|
if (userConfig.modules[name]) {
|
|
config[name] = userConfig.modules[name];
|
|
}
|
|
return config;
|
|
}, {});
|
|
return userConfig;
|
|
}
|
|
|
|
// Handle selection preservation and TEXT_CHANGE emission
|
|
// common to modification APIs
|
|
function modify(modifier, source, index, shift) {
|
|
if (this.options.strict && !this.isEnabled() && source === _emitter4.default.sources.USER) {
|
|
return new _quillDelta2.default();
|
|
}
|
|
var range = index == null ? null : this.getSelection();
|
|
var oldDelta = this.editor.delta;
|
|
var change = modifier();
|
|
if (range != null) {
|
|
if (index === true) index = range.index;
|
|
if (shift == null) {
|
|
range = shiftRange(range, change, source);
|
|
} else if (shift !== 0) {
|
|
range = shiftRange(range, index, shift, source);
|
|
}
|
|
this.setSelection(range, _emitter4.default.sources.SILENT);
|
|
}
|
|
if (change.length() > 0) {
|
|
var _emitter;
|
|
|
|
var args = [_emitter4.default.events.TEXT_CHANGE, change, oldDelta, source];
|
|
(_emitter = this.emitter).emit.apply(_emitter, [_emitter4.default.events.EDITOR_CHANGE].concat(args));
|
|
if (source !== _emitter4.default.sources.SILENT) {
|
|
var _emitter2;
|
|
|
|
(_emitter2 = this.emitter).emit.apply(_emitter2, args);
|
|
}
|
|
}
|
|
return change;
|
|
}
|
|
|
|
function overload(index, length, name, value, source) {
|
|
var formats = {};
|
|
if (typeof index.index === 'number' && typeof index.length === 'number') {
|
|
// Allow for throwaway end (used by insertText/insertEmbed)
|
|
if (typeof length !== 'number') {
|
|
source = value, value = name, name = length, length = index.length, index = index.index;
|
|
} else {
|
|
length = index.length, index = index.index;
|
|
}
|
|
} else if (typeof length !== 'number') {
|
|
source = value, value = name, name = length, length = 0;
|
|
}
|
|
// Handle format being object, two format name/value strings or excluded
|
|
if ((typeof name === 'undefined' ? 'undefined' : _typeof(name)) === 'object') {
|
|
formats = name;
|
|
source = value;
|
|
} else if (typeof name === 'string') {
|
|
if (value != null) {
|
|
formats[name] = value;
|
|
} else {
|
|
source = name;
|
|
}
|
|
}
|
|
// Handle optional source
|
|
source = source || _emitter4.default.sources.API;
|
|
return [index, length, formats, source];
|
|
}
|
|
|
|
function shiftRange(range, index, length, source) {
|
|
if (range == null) return null;
|
|
var start = void 0,
|
|
end = void 0;
|
|
if (index instanceof _quillDelta2.default) {
|
|
var _map = [range.index, range.index + range.length].map(function (pos) {
|
|
return index.transformPosition(pos, source !== _emitter4.default.sources.USER);
|
|
});
|
|
|
|
var _map2 = _slicedToArray(_map, 2);
|
|
|
|
start = _map2[0];
|
|
end = _map2[1];
|
|
} else {
|
|
var _map3 = [range.index, range.index + range.length].map(function (pos) {
|
|
if (pos < index || pos === index && source === _emitter4.default.sources.USER) return pos;
|
|
if (length >= 0) {
|
|
return pos + length;
|
|
} else {
|
|
return Math.max(index, pos + length);
|
|
}
|
|
});
|
|
|
|
var _map4 = _slicedToArray(_map3, 2);
|
|
|
|
start = _map4[0];
|
|
end = _map4[1];
|
|
}
|
|
return new _selection.Range(start, end - start);
|
|
}
|
|
|
|
exports.expandConfig = expandConfig;
|
|
exports.overload = overload;
|
|
exports.default = Quill;
|
|
|
|
/***/ }),
|
|
/* 6 */
|
|
/***/ (function(module, exports, __nested_webpack_require_58401__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _text = __nested_webpack_require_58401__(7);
|
|
|
|
var _text2 = _interopRequireDefault(_text);
|
|
|
|
var _parchment = __nested_webpack_require_58401__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var Inline = function (_Parchment$Inline) {
|
|
_inherits(Inline, _Parchment$Inline);
|
|
|
|
function Inline() {
|
|
_classCallCheck(this, Inline);
|
|
|
|
return _possibleConstructorReturn(this, (Inline.__proto__ || Object.getPrototypeOf(Inline)).apply(this, arguments));
|
|
}
|
|
|
|
_createClass(Inline, [{
|
|
key: 'formatAt',
|
|
value: function formatAt(index, length, name, value) {
|
|
if (Inline.compare(this.statics.blotName, name) < 0 && _parchment2.default.query(name, _parchment2.default.Scope.BLOT)) {
|
|
var blot = this.isolate(index, length);
|
|
if (value) {
|
|
blot.wrap(name, value);
|
|
}
|
|
} else {
|
|
_get(Inline.prototype.__proto__ || Object.getPrototypeOf(Inline.prototype), 'formatAt', this).call(this, index, length, name, value);
|
|
}
|
|
}
|
|
}, {
|
|
key: 'optimize',
|
|
value: function optimize(context) {
|
|
_get(Inline.prototype.__proto__ || Object.getPrototypeOf(Inline.prototype), 'optimize', this).call(this, context);
|
|
if (this.parent instanceof Inline && Inline.compare(this.statics.blotName, this.parent.statics.blotName) > 0) {
|
|
var parent = this.parent.isolate(this.offset(), this.length());
|
|
this.moveChildren(parent);
|
|
parent.wrap(this);
|
|
}
|
|
}
|
|
}], [{
|
|
key: 'compare',
|
|
value: function compare(self, other) {
|
|
var selfIndex = Inline.order.indexOf(self);
|
|
var otherIndex = Inline.order.indexOf(other);
|
|
if (selfIndex >= 0 || otherIndex >= 0) {
|
|
return selfIndex - otherIndex;
|
|
} else if (self === other) {
|
|
return 0;
|
|
} else if (self < other) {
|
|
return -1;
|
|
} else {
|
|
return 1;
|
|
}
|
|
}
|
|
}]);
|
|
|
|
return Inline;
|
|
}(_parchment2.default.Inline);
|
|
|
|
Inline.allowedChildren = [Inline, _parchment2.default.Embed, _text2.default];
|
|
// Lower index means deeper in the DOM tree, since not found (-1) is for embeds
|
|
Inline.order = ['cursor', 'inline', // Must be lower
|
|
'underline', 'strike', 'italic', 'bold', 'script', 'link', 'code' // Must be higher
|
|
];
|
|
|
|
exports.default = Inline;
|
|
|
|
/***/ }),
|
|
/* 7 */
|
|
/***/ (function(module, exports, __nested_webpack_require_62823__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _parchment = __nested_webpack_require_62823__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var TextBlot = function (_Parchment$Text) {
|
|
_inherits(TextBlot, _Parchment$Text);
|
|
|
|
function TextBlot() {
|
|
_classCallCheck(this, TextBlot);
|
|
|
|
return _possibleConstructorReturn(this, (TextBlot.__proto__ || Object.getPrototypeOf(TextBlot)).apply(this, arguments));
|
|
}
|
|
|
|
return TextBlot;
|
|
}(_parchment2.default.Text);
|
|
|
|
exports.default = TextBlot;
|
|
|
|
/***/ }),
|
|
/* 8 */
|
|
/***/ (function(module, exports, __nested_webpack_require_64422__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _eventemitter = __nested_webpack_require_64422__(54);
|
|
|
|
var _eventemitter2 = _interopRequireDefault(_eventemitter);
|
|
|
|
var _logger = __nested_webpack_require_64422__(10);
|
|
|
|
var _logger2 = _interopRequireDefault(_logger);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var debug = (0, _logger2.default)('quill:events');
|
|
|
|
var EVENTS = ['selectionchange', 'mousedown', 'mouseup', 'click'];
|
|
|
|
EVENTS.forEach(function (eventName) {
|
|
document.addEventListener(eventName, function () {
|
|
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
args[_key] = arguments[_key];
|
|
}
|
|
|
|
[].slice.call(document.querySelectorAll('.ql-container')).forEach(function (node) {
|
|
// TODO use WeakMap
|
|
if (node.__quill && node.__quill.emitter) {
|
|
var _node$__quill$emitter;
|
|
|
|
(_node$__quill$emitter = node.__quill.emitter).handleDOM.apply(_node$__quill$emitter, args);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
var Emitter = function (_EventEmitter) {
|
|
_inherits(Emitter, _EventEmitter);
|
|
|
|
function Emitter() {
|
|
_classCallCheck(this, Emitter);
|
|
|
|
var _this = _possibleConstructorReturn(this, (Emitter.__proto__ || Object.getPrototypeOf(Emitter)).call(this));
|
|
|
|
_this.listeners = {};
|
|
_this.on('error', debug.error);
|
|
return _this;
|
|
}
|
|
|
|
_createClass(Emitter, [{
|
|
key: 'emit',
|
|
value: function emit() {
|
|
debug.log.apply(debug, arguments);
|
|
_get(Emitter.prototype.__proto__ || Object.getPrototypeOf(Emitter.prototype), 'emit', this).apply(this, arguments);
|
|
}
|
|
}, {
|
|
key: 'handleDOM',
|
|
value: function handleDOM(event) {
|
|
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
args[_key2 - 1] = arguments[_key2];
|
|
}
|
|
|
|
(this.listeners[event.type] || []).forEach(function (_ref) {
|
|
var node = _ref.node,
|
|
handler = _ref.handler;
|
|
|
|
if (event.target === node || node.contains(event.target)) {
|
|
handler.apply(undefined, [event].concat(args));
|
|
}
|
|
});
|
|
}
|
|
}, {
|
|
key: 'listenDOM',
|
|
value: function listenDOM(eventName, node, handler) {
|
|
if (!this.listeners[eventName]) {
|
|
this.listeners[eventName] = [];
|
|
}
|
|
this.listeners[eventName].push({ node: node, handler: handler });
|
|
}
|
|
}]);
|
|
|
|
return Emitter;
|
|
}(_eventemitter2.default);
|
|
|
|
Emitter.events = {
|
|
EDITOR_CHANGE: 'editor-change',
|
|
SCROLL_BEFORE_UPDATE: 'scroll-before-update',
|
|
SCROLL_OPTIMIZE: 'scroll-optimize',
|
|
SCROLL_UPDATE: 'scroll-update',
|
|
SELECTION_CHANGE: 'selection-change',
|
|
TEXT_CHANGE: 'text-change'
|
|
};
|
|
Emitter.sources = {
|
|
API: 'api',
|
|
SILENT: 'silent',
|
|
USER: 'user'
|
|
};
|
|
|
|
exports.default = Emitter;
|
|
|
|
/***/ }),
|
|
/* 9 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
var Module = function Module(quill) {
|
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
|
|
_classCallCheck(this, Module);
|
|
|
|
this.quill = quill;
|
|
this.options = options;
|
|
};
|
|
|
|
Module.DEFAULTS = {};
|
|
|
|
exports.default = Module;
|
|
|
|
/***/ }),
|
|
/* 10 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
var levels = ['error', 'warn', 'log', 'info'];
|
|
var level = 'warn';
|
|
|
|
function debug(method) {
|
|
if (levels.indexOf(method) <= levels.indexOf(level)) {
|
|
var _console;
|
|
|
|
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
args[_key - 1] = arguments[_key];
|
|
}
|
|
|
|
(_console = console)[method].apply(_console, args); // eslint-disable-line no-console
|
|
}
|
|
}
|
|
|
|
function namespace(ns) {
|
|
return levels.reduce(function (logger, method) {
|
|
logger[method] = debug.bind(console, method, ns);
|
|
return logger;
|
|
}, {});
|
|
}
|
|
|
|
debug.level = namespace.level = function (newLevel) {
|
|
level = newLevel;
|
|
};
|
|
|
|
exports.default = namespace;
|
|
|
|
/***/ }),
|
|
/* 11 */
|
|
/***/ (function(module, exports, __nested_webpack_require_70685__) {
|
|
|
|
var pSlice = Array.prototype.slice;
|
|
var objectKeys = __nested_webpack_require_70685__(52);
|
|
var isArguments = __nested_webpack_require_70685__(53);
|
|
|
|
var deepEqual = module.exports = function (actual, expected, opts) {
|
|
if (!opts) opts = {};
|
|
// 7.1. All identical values are equivalent, as determined by ===.
|
|
if (actual === expected) {
|
|
return true;
|
|
|
|
} else if (actual instanceof Date && expected instanceof Date) {
|
|
return actual.getTime() === expected.getTime();
|
|
|
|
// 7.3. Other pairs that do not both pass typeof value == 'object',
|
|
// equivalence is determined by ==.
|
|
} else if (!actual || !expected || typeof actual != 'object' && typeof expected != 'object') {
|
|
return opts.strict ? actual === expected : actual == expected;
|
|
|
|
// 7.4. For all other Object pairs, including Array objects, equivalence is
|
|
// determined by having the same number of owned properties (as verified
|
|
// with Object.prototype.hasOwnProperty.call), the same set of keys
|
|
// (although not necessarily the same order), equivalent values for every
|
|
// corresponding key, and an identical 'prototype' property. Note: this
|
|
// accounts for both named and indexed properties on Arrays.
|
|
} else {
|
|
return objEquiv(actual, expected, opts);
|
|
}
|
|
}
|
|
|
|
function isUndefinedOrNull(value) {
|
|
return value === null || value === undefined;
|
|
}
|
|
|
|
function isBuffer (x) {
|
|
if (!x || typeof x !== 'object' || typeof x.length !== 'number') return false;
|
|
if (typeof x.copy !== 'function' || typeof x.slice !== 'function') {
|
|
return false;
|
|
}
|
|
if (x.length > 0 && typeof x[0] !== 'number') return false;
|
|
return true;
|
|
}
|
|
|
|
function objEquiv(a, b, opts) {
|
|
var i, key;
|
|
if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
|
|
return false;
|
|
// an identical 'prototype' property.
|
|
if (a.prototype !== b.prototype) return false;
|
|
//~~~I've managed to break Object.keys through screwy arguments passing.
|
|
// Converting to array solves the problem.
|
|
if (isArguments(a)) {
|
|
if (!isArguments(b)) {
|
|
return false;
|
|
}
|
|
a = pSlice.call(a);
|
|
b = pSlice.call(b);
|
|
return deepEqual(a, b, opts);
|
|
}
|
|
if (isBuffer(a)) {
|
|
if (!isBuffer(b)) {
|
|
return false;
|
|
}
|
|
if (a.length !== b.length) return false;
|
|
for (i = 0; i < a.length; i++) {
|
|
if (a[i] !== b[i]) return false;
|
|
}
|
|
return true;
|
|
}
|
|
try {
|
|
var ka = objectKeys(a),
|
|
kb = objectKeys(b);
|
|
} catch (e) {//happens when one is a string literal and the other isn't
|
|
return false;
|
|
}
|
|
// having the same number of owned properties (keys incorporates
|
|
// hasOwnProperty)
|
|
if (ka.length != kb.length)
|
|
return false;
|
|
//the same set of keys (although not necessarily the same order),
|
|
ka.sort();
|
|
kb.sort();
|
|
//~~~cheap key test
|
|
for (i = ka.length - 1; i >= 0; i--) {
|
|
if (ka[i] != kb[i])
|
|
return false;
|
|
}
|
|
//equivalent values for every corresponding key, and
|
|
//~~~possibly expensive deep test
|
|
for (i = ka.length - 1; i >= 0; i--) {
|
|
key = ka[i];
|
|
if (!deepEqual(a[key], b[key], opts)) return false;
|
|
}
|
|
return typeof a === typeof b;
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
/* 12 */
|
|
/***/ (function(module, exports, __nested_webpack_require_73804__) {
|
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var Registry = __nested_webpack_require_73804__(1);
|
|
var Attributor = /** @class */ (function () {
|
|
function Attributor(attrName, keyName, options) {
|
|
if (options === void 0) { options = {}; }
|
|
this.attrName = attrName;
|
|
this.keyName = keyName;
|
|
var attributeBit = Registry.Scope.TYPE & Registry.Scope.ATTRIBUTE;
|
|
if (options.scope != null) {
|
|
// Ignore type bits, force attribute bit
|
|
this.scope = (options.scope & Registry.Scope.LEVEL) | attributeBit;
|
|
}
|
|
else {
|
|
this.scope = Registry.Scope.ATTRIBUTE;
|
|
}
|
|
if (options.whitelist != null)
|
|
this.whitelist = options.whitelist;
|
|
}
|
|
Attributor.keys = function (node) {
|
|
return [].map.call(node.attributes, function (item) {
|
|
return item.name;
|
|
});
|
|
};
|
|
Attributor.prototype.add = function (node, value) {
|
|
if (!this.canAdd(node, value))
|
|
return false;
|
|
node.setAttribute(this.keyName, value);
|
|
return true;
|
|
};
|
|
Attributor.prototype.canAdd = function (node, value) {
|
|
var match = Registry.query(node, Registry.Scope.BLOT & (this.scope | Registry.Scope.TYPE));
|
|
if (match == null)
|
|
return false;
|
|
if (this.whitelist == null)
|
|
return true;
|
|
if (typeof value === 'string') {
|
|
return this.whitelist.indexOf(value.replace(/["']/g, '')) > -1;
|
|
}
|
|
else {
|
|
return this.whitelist.indexOf(value) > -1;
|
|
}
|
|
};
|
|
Attributor.prototype.remove = function (node) {
|
|
node.removeAttribute(this.keyName);
|
|
};
|
|
Attributor.prototype.value = function (node) {
|
|
var value = node.getAttribute(this.keyName);
|
|
if (this.canAdd(node, value) && value) {
|
|
return value;
|
|
}
|
|
return '';
|
|
};
|
|
return Attributor;
|
|
}());
|
|
exports.default = Attributor;
|
|
|
|
|
|
/***/ }),
|
|
/* 13 */
|
|
/***/ (function(module, exports, __nested_webpack_require_75851__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = exports.Code = undefined;
|
|
|
|
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _quillDelta = __nested_webpack_require_75851__(2);
|
|
|
|
var _quillDelta2 = _interopRequireDefault(_quillDelta);
|
|
|
|
var _parchment = __nested_webpack_require_75851__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
var _block = __nested_webpack_require_75851__(4);
|
|
|
|
var _block2 = _interopRequireDefault(_block);
|
|
|
|
var _inline = __nested_webpack_require_75851__(6);
|
|
|
|
var _inline2 = _interopRequireDefault(_inline);
|
|
|
|
var _text = __nested_webpack_require_75851__(7);
|
|
|
|
var _text2 = _interopRequireDefault(_text);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var Code = function (_Inline) {
|
|
_inherits(Code, _Inline);
|
|
|
|
function Code() {
|
|
_classCallCheck(this, Code);
|
|
|
|
return _possibleConstructorReturn(this, (Code.__proto__ || Object.getPrototypeOf(Code)).apply(this, arguments));
|
|
}
|
|
|
|
return Code;
|
|
}(_inline2.default);
|
|
|
|
Code.blotName = 'code';
|
|
Code.tagName = 'CODE';
|
|
|
|
var CodeBlock = function (_Block) {
|
|
_inherits(CodeBlock, _Block);
|
|
|
|
function CodeBlock() {
|
|
_classCallCheck(this, CodeBlock);
|
|
|
|
return _possibleConstructorReturn(this, (CodeBlock.__proto__ || Object.getPrototypeOf(CodeBlock)).apply(this, arguments));
|
|
}
|
|
|
|
_createClass(CodeBlock, [{
|
|
key: 'delta',
|
|
value: function delta() {
|
|
var _this3 = this;
|
|
|
|
var text = this.domNode.textContent;
|
|
if (text.endsWith('\n')) {
|
|
// Should always be true
|
|
text = text.slice(0, -1);
|
|
}
|
|
return text.split('\n').reduce(function (delta, frag) {
|
|
return delta.insert(frag).insert('\n', _this3.formats());
|
|
}, new _quillDelta2.default());
|
|
}
|
|
}, {
|
|
key: 'format',
|
|
value: function format(name, value) {
|
|
if (name === this.statics.blotName && value) return;
|
|
|
|
var _descendant = this.descendant(_text2.default, this.length() - 1),
|
|
_descendant2 = _slicedToArray(_descendant, 1),
|
|
text = _descendant2[0];
|
|
|
|
if (text != null) {
|
|
text.deleteAt(text.length() - 1, 1);
|
|
}
|
|
_get(CodeBlock.prototype.__proto__ || Object.getPrototypeOf(CodeBlock.prototype), 'format', this).call(this, name, value);
|
|
}
|
|
}, {
|
|
key: 'formatAt',
|
|
value: function formatAt(index, length, name, value) {
|
|
if (length === 0) return;
|
|
if (_parchment2.default.query(name, _parchment2.default.Scope.BLOCK) == null || name === this.statics.blotName && value === this.statics.formats(this.domNode)) {
|
|
return;
|
|
}
|
|
var nextNewline = this.newlineIndex(index);
|
|
if (nextNewline < 0 || nextNewline >= index + length) return;
|
|
var prevNewline = this.newlineIndex(index, true) + 1;
|
|
var isolateLength = nextNewline - prevNewline + 1;
|
|
var blot = this.isolate(prevNewline, isolateLength);
|
|
var next = blot.next;
|
|
blot.format(name, value);
|
|
if (next instanceof CodeBlock) {
|
|
next.formatAt(0, index - prevNewline + length - isolateLength, name, value);
|
|
}
|
|
}
|
|
}, {
|
|
key: 'insertAt',
|
|
value: function insertAt(index, value, def) {
|
|
if (def != null) return;
|
|
|
|
var _descendant3 = this.descendant(_text2.default, index),
|
|
_descendant4 = _slicedToArray(_descendant3, 2),
|
|
text = _descendant4[0],
|
|
offset = _descendant4[1];
|
|
|
|
text.insertAt(offset, value);
|
|
}
|
|
}, {
|
|
key: 'length',
|
|
value: function length() {
|
|
var length = this.domNode.textContent.length;
|
|
if (!this.domNode.textContent.endsWith('\n')) {
|
|
return length + 1;
|
|
}
|
|
return length;
|
|
}
|
|
}, {
|
|
key: 'newlineIndex',
|
|
value: function newlineIndex(searchIndex) {
|
|
var reverse = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
|
|
if (!reverse) {
|
|
var offset = this.domNode.textContent.slice(searchIndex).indexOf('\n');
|
|
return offset > -1 ? searchIndex + offset : -1;
|
|
} else {
|
|
return this.domNode.textContent.slice(0, searchIndex).lastIndexOf('\n');
|
|
}
|
|
}
|
|
}, {
|
|
key: 'optimize',
|
|
value: function optimize(context) {
|
|
if (!this.domNode.textContent.endsWith('\n')) {
|
|
this.appendChild(_parchment2.default.create('text', '\n'));
|
|
}
|
|
_get(CodeBlock.prototype.__proto__ || Object.getPrototypeOf(CodeBlock.prototype), 'optimize', this).call(this, context);
|
|
var next = this.next;
|
|
if (next != null && next.prev === this && next.statics.blotName === this.statics.blotName && this.statics.formats(this.domNode) === next.statics.formats(next.domNode)) {
|
|
next.optimize(context);
|
|
next.moveChildren(this);
|
|
next.remove();
|
|
}
|
|
}
|
|
}, {
|
|
key: 'replace',
|
|
value: function replace(target) {
|
|
_get(CodeBlock.prototype.__proto__ || Object.getPrototypeOf(CodeBlock.prototype), 'replace', this).call(this, target);
|
|
[].slice.call(this.domNode.querySelectorAll('*')).forEach(function (node) {
|
|
var blot = _parchment2.default.find(node);
|
|
if (blot == null) {
|
|
node.parentNode.removeChild(node);
|
|
} else if (blot instanceof _parchment2.default.Embed) {
|
|
blot.remove();
|
|
} else {
|
|
blot.unwrap();
|
|
}
|
|
});
|
|
}
|
|
}], [{
|
|
key: 'create',
|
|
value: function create(value) {
|
|
var domNode = _get(CodeBlock.__proto__ || Object.getPrototypeOf(CodeBlock), 'create', this).call(this, value);
|
|
domNode.setAttribute('spellcheck', false);
|
|
return domNode;
|
|
}
|
|
}, {
|
|
key: 'formats',
|
|
value: function formats() {
|
|
return true;
|
|
}
|
|
}]);
|
|
|
|
return CodeBlock;
|
|
}(_block2.default);
|
|
|
|
CodeBlock.blotName = 'code-block';
|
|
CodeBlock.tagName = 'PRE';
|
|
CodeBlock.TAB = ' ';
|
|
|
|
exports.Code = Code;
|
|
exports.default = CodeBlock;
|
|
|
|
/***/ }),
|
|
/* 14 */
|
|
/***/ (function(module, exports, __nested_webpack_require_84272__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
|
|
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _quillDelta = __nested_webpack_require_84272__(2);
|
|
|
|
var _quillDelta2 = _interopRequireDefault(_quillDelta);
|
|
|
|
var _op = __nested_webpack_require_84272__(20);
|
|
|
|
var _op2 = _interopRequireDefault(_op);
|
|
|
|
var _parchment = __nested_webpack_require_84272__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
var _code = __nested_webpack_require_84272__(13);
|
|
|
|
var _code2 = _interopRequireDefault(_code);
|
|
|
|
var _cursor = __nested_webpack_require_84272__(24);
|
|
|
|
var _cursor2 = _interopRequireDefault(_cursor);
|
|
|
|
var _block = __nested_webpack_require_84272__(4);
|
|
|
|
var _block2 = _interopRequireDefault(_block);
|
|
|
|
var _break = __nested_webpack_require_84272__(16);
|
|
|
|
var _break2 = _interopRequireDefault(_break);
|
|
|
|
var _clone = __nested_webpack_require_84272__(21);
|
|
|
|
var _clone2 = _interopRequireDefault(_clone);
|
|
|
|
var _deepEqual = __nested_webpack_require_84272__(11);
|
|
|
|
var _deepEqual2 = _interopRequireDefault(_deepEqual);
|
|
|
|
var _extend = __nested_webpack_require_84272__(3);
|
|
|
|
var _extend2 = _interopRequireDefault(_extend);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
var ASCII = /^[ -~]*$/;
|
|
|
|
var Editor = function () {
|
|
function Editor(scroll) {
|
|
_classCallCheck(this, Editor);
|
|
|
|
this.scroll = scroll;
|
|
this.delta = this.getDelta();
|
|
}
|
|
|
|
_createClass(Editor, [{
|
|
key: 'applyDelta',
|
|
value: function applyDelta(delta) {
|
|
var _this = this;
|
|
|
|
var consumeNextNewline = false;
|
|
this.scroll.update();
|
|
var scrollLength = this.scroll.length();
|
|
this.scroll.batchStart();
|
|
delta = normalizeDelta(delta);
|
|
delta.reduce(function (index, op) {
|
|
var length = op.retain || op.delete || op.insert.length || 1;
|
|
var attributes = op.attributes || {};
|
|
if (op.insert != null) {
|
|
if (typeof op.insert === 'string') {
|
|
var text = op.insert;
|
|
if (text.endsWith('\n') && consumeNextNewline) {
|
|
consumeNextNewline = false;
|
|
text = text.slice(0, -1);
|
|
}
|
|
if (index >= scrollLength && !text.endsWith('\n')) {
|
|
consumeNextNewline = true;
|
|
}
|
|
_this.scroll.insertAt(index, text);
|
|
|
|
var _scroll$line = _this.scroll.line(index),
|
|
_scroll$line2 = _slicedToArray(_scroll$line, 2),
|
|
line = _scroll$line2[0],
|
|
offset = _scroll$line2[1];
|
|
|
|
var formats = (0, _extend2.default)({}, (0, _block.bubbleFormats)(line));
|
|
if (line instanceof _block2.default) {
|
|
var _line$descendant = line.descendant(_parchment2.default.Leaf, offset),
|
|
_line$descendant2 = _slicedToArray(_line$descendant, 1),
|
|
leaf = _line$descendant2[0];
|
|
|
|
formats = (0, _extend2.default)(formats, (0, _block.bubbleFormats)(leaf));
|
|
}
|
|
attributes = _op2.default.attributes.diff(formats, attributes) || {};
|
|
} else if (_typeof(op.insert) === 'object') {
|
|
var key = Object.keys(op.insert)[0]; // There should only be one key
|
|
if (key == null) return index;
|
|
_this.scroll.insertAt(index, key, op.insert[key]);
|
|
}
|
|
scrollLength += length;
|
|
}
|
|
Object.keys(attributes).forEach(function (name) {
|
|
_this.scroll.formatAt(index, length, name, attributes[name]);
|
|
});
|
|
return index + length;
|
|
}, 0);
|
|
delta.reduce(function (index, op) {
|
|
if (typeof op.delete === 'number') {
|
|
_this.scroll.deleteAt(index, op.delete);
|
|
return index;
|
|
}
|
|
return index + (op.retain || op.insert.length || 1);
|
|
}, 0);
|
|
this.scroll.batchEnd();
|
|
return this.update(delta);
|
|
}
|
|
}, {
|
|
key: 'deleteText',
|
|
value: function deleteText(index, length) {
|
|
this.scroll.deleteAt(index, length);
|
|
return this.update(new _quillDelta2.default().retain(index).delete(length));
|
|
}
|
|
}, {
|
|
key: 'formatLine',
|
|
value: function formatLine(index, length) {
|
|
var _this2 = this;
|
|
|
|
var formats = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
|
|
this.scroll.update();
|
|
Object.keys(formats).forEach(function (format) {
|
|
if (_this2.scroll.whitelist != null && !_this2.scroll.whitelist[format]) return;
|
|
var lines = _this2.scroll.lines(index, Math.max(length, 1));
|
|
var lengthRemaining = length;
|
|
lines.forEach(function (line) {
|
|
var lineLength = line.length();
|
|
if (!(line instanceof _code2.default)) {
|
|
line.format(format, formats[format]);
|
|
} else {
|
|
var codeIndex = index - line.offset(_this2.scroll);
|
|
var codeLength = line.newlineIndex(codeIndex + lengthRemaining) - codeIndex + 1;
|
|
line.formatAt(codeIndex, codeLength, format, formats[format]);
|
|
}
|
|
lengthRemaining -= lineLength;
|
|
});
|
|
});
|
|
this.scroll.optimize();
|
|
return this.update(new _quillDelta2.default().retain(index).retain(length, (0, _clone2.default)(formats)));
|
|
}
|
|
}, {
|
|
key: 'formatText',
|
|
value: function formatText(index, length) {
|
|
var _this3 = this;
|
|
|
|
var formats = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
|
|
Object.keys(formats).forEach(function (format) {
|
|
_this3.scroll.formatAt(index, length, format, formats[format]);
|
|
});
|
|
return this.update(new _quillDelta2.default().retain(index).retain(length, (0, _clone2.default)(formats)));
|
|
}
|
|
}, {
|
|
key: 'getContents',
|
|
value: function getContents(index, length) {
|
|
return this.delta.slice(index, index + length);
|
|
}
|
|
}, {
|
|
key: 'getDelta',
|
|
value: function getDelta() {
|
|
return this.scroll.lines().reduce(function (delta, line) {
|
|
return delta.concat(line.delta());
|
|
}, new _quillDelta2.default());
|
|
}
|
|
}, {
|
|
key: 'getFormat',
|
|
value: function getFormat(index) {
|
|
var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
|
|
var lines = [],
|
|
leaves = [];
|
|
if (length === 0) {
|
|
this.scroll.path(index).forEach(function (path) {
|
|
var _path = _slicedToArray(path, 1),
|
|
blot = _path[0];
|
|
|
|
if (blot instanceof _block2.default) {
|
|
lines.push(blot);
|
|
} else if (blot instanceof _parchment2.default.Leaf) {
|
|
leaves.push(blot);
|
|
}
|
|
});
|
|
} else {
|
|
lines = this.scroll.lines(index, length);
|
|
leaves = this.scroll.descendants(_parchment2.default.Leaf, index, length);
|
|
}
|
|
var formatsArr = [lines, leaves].map(function (blots) {
|
|
if (blots.length === 0) return {};
|
|
var formats = (0, _block.bubbleFormats)(blots.shift());
|
|
while (Object.keys(formats).length > 0) {
|
|
var blot = blots.shift();
|
|
if (blot == null) return formats;
|
|
formats = combineFormats((0, _block.bubbleFormats)(blot), formats);
|
|
}
|
|
return formats;
|
|
});
|
|
return _extend2.default.apply(_extend2.default, formatsArr);
|
|
}
|
|
}, {
|
|
key: 'getText',
|
|
value: function getText(index, length) {
|
|
return this.getContents(index, length).filter(function (op) {
|
|
return typeof op.insert === 'string';
|
|
}).map(function (op) {
|
|
return op.insert;
|
|
}).join('');
|
|
}
|
|
}, {
|
|
key: 'insertEmbed',
|
|
value: function insertEmbed(index, embed, value) {
|
|
this.scroll.insertAt(index, embed, value);
|
|
return this.update(new _quillDelta2.default().retain(index).insert(_defineProperty({}, embed, value)));
|
|
}
|
|
}, {
|
|
key: 'insertText',
|
|
value: function insertText(index, text) {
|
|
var _this4 = this;
|
|
|
|
var formats = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
|
|
text = text.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
this.scroll.insertAt(index, text);
|
|
Object.keys(formats).forEach(function (format) {
|
|
_this4.scroll.formatAt(index, text.length, format, formats[format]);
|
|
});
|
|
return this.update(new _quillDelta2.default().retain(index).insert(text, (0, _clone2.default)(formats)));
|
|
}
|
|
}, {
|
|
key: 'isBlank',
|
|
value: function isBlank() {
|
|
if (this.scroll.children.length == 0) return true;
|
|
if (this.scroll.children.length > 1) return false;
|
|
var block = this.scroll.children.head;
|
|
if (block.statics.blotName !== _block2.default.blotName) return false;
|
|
if (block.children.length > 1) return false;
|
|
return block.children.head instanceof _break2.default;
|
|
}
|
|
}, {
|
|
key: 'removeFormat',
|
|
value: function removeFormat(index, length) {
|
|
var text = this.getText(index, length);
|
|
|
|
var _scroll$line3 = this.scroll.line(index + length),
|
|
_scroll$line4 = _slicedToArray(_scroll$line3, 2),
|
|
line = _scroll$line4[0],
|
|
offset = _scroll$line4[1];
|
|
|
|
var suffixLength = 0,
|
|
suffix = new _quillDelta2.default();
|
|
if (line != null) {
|
|
if (!(line instanceof _code2.default)) {
|
|
suffixLength = line.length() - offset;
|
|
} else {
|
|
suffixLength = line.newlineIndex(offset) - offset + 1;
|
|
}
|
|
suffix = line.delta().slice(offset, offset + suffixLength - 1).insert('\n');
|
|
}
|
|
var contents = this.getContents(index, length + suffixLength);
|
|
var diff = contents.diff(new _quillDelta2.default().insert(text).concat(suffix));
|
|
var delta = new _quillDelta2.default().retain(index).concat(diff);
|
|
return this.applyDelta(delta);
|
|
}
|
|
}, {
|
|
key: 'update',
|
|
value: function update(change) {
|
|
var mutations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
var cursorIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
|
|
var oldDelta = this.delta;
|
|
if (mutations.length === 1 && mutations[0].type === 'characterData' && mutations[0].target.data.match(ASCII) && _parchment2.default.find(mutations[0].target)) {
|
|
// Optimization for character changes
|
|
var textBlot = _parchment2.default.find(mutations[0].target);
|
|
var formats = (0, _block.bubbleFormats)(textBlot);
|
|
var index = textBlot.offset(this.scroll);
|
|
var oldValue = mutations[0].oldValue.replace(_cursor2.default.CONTENTS, '');
|
|
var oldText = new _quillDelta2.default().insert(oldValue);
|
|
var newText = new _quillDelta2.default().insert(textBlot.value());
|
|
var diffDelta = new _quillDelta2.default().retain(index).concat(oldText.diff(newText, cursorIndex));
|
|
change = diffDelta.reduce(function (delta, op) {
|
|
if (op.insert) {
|
|
return delta.insert(op.insert, formats);
|
|
} else {
|
|
return delta.push(op);
|
|
}
|
|
}, new _quillDelta2.default());
|
|
this.delta = oldDelta.compose(change);
|
|
} else {
|
|
this.delta = this.getDelta();
|
|
if (!change || !(0, _deepEqual2.default)(oldDelta.compose(change), this.delta)) {
|
|
change = oldDelta.diff(this.delta, cursorIndex);
|
|
}
|
|
}
|
|
return change;
|
|
}
|
|
}]);
|
|
|
|
return Editor;
|
|
}();
|
|
|
|
function combineFormats(formats, combined) {
|
|
return Object.keys(combined).reduce(function (merged, name) {
|
|
if (formats[name] == null) return merged;
|
|
if (combined[name] === formats[name]) {
|
|
merged[name] = combined[name];
|
|
} else if (Array.isArray(combined[name])) {
|
|
if (combined[name].indexOf(formats[name]) < 0) {
|
|
merged[name] = combined[name].concat([formats[name]]);
|
|
}
|
|
} else {
|
|
merged[name] = [combined[name], formats[name]];
|
|
}
|
|
return merged;
|
|
}, {});
|
|
}
|
|
|
|
function normalizeDelta(delta) {
|
|
return delta.reduce(function (delta, op) {
|
|
if (op.insert === 1) {
|
|
var attributes = (0, _clone2.default)(op.attributes);
|
|
delete attributes['image'];
|
|
return delta.insert({ image: op.attributes.image }, attributes);
|
|
}
|
|
if (op.attributes != null && (op.attributes.list === true || op.attributes.bullet === true)) {
|
|
op = (0, _clone2.default)(op);
|
|
if (op.attributes.list) {
|
|
op.attributes.list = 'ordered';
|
|
} else {
|
|
op.attributes.list = 'bullet';
|
|
delete op.attributes.bullet;
|
|
}
|
|
}
|
|
if (typeof op.insert === 'string') {
|
|
var text = op.insert.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
return delta.insert(text, op.attributes);
|
|
}
|
|
return delta.push(op);
|
|
}, new _quillDelta2.default());
|
|
}
|
|
|
|
exports.default = Editor;
|
|
|
|
/***/ }),
|
|
/* 15 */
|
|
/***/ (function(module, exports, __nested_webpack_require_98688__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = exports.Range = undefined;
|
|
|
|
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _parchment = __nested_webpack_require_98688__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
var _clone = __nested_webpack_require_98688__(21);
|
|
|
|
var _clone2 = _interopRequireDefault(_clone);
|
|
|
|
var _deepEqual = __nested_webpack_require_98688__(11);
|
|
|
|
var _deepEqual2 = _interopRequireDefault(_deepEqual);
|
|
|
|
var _emitter3 = __nested_webpack_require_98688__(8);
|
|
|
|
var _emitter4 = _interopRequireDefault(_emitter3);
|
|
|
|
var _logger = __nested_webpack_require_98688__(10);
|
|
|
|
var _logger2 = _interopRequireDefault(_logger);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
var debug = (0, _logger2.default)('quill:selection');
|
|
|
|
var Range = function Range(index) {
|
|
var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
|
|
_classCallCheck(this, Range);
|
|
|
|
this.index = index;
|
|
this.length = length;
|
|
};
|
|
|
|
var Selection = function () {
|
|
function Selection(scroll, emitter) {
|
|
var _this = this;
|
|
|
|
_classCallCheck(this, Selection);
|
|
|
|
this.emitter = emitter;
|
|
this.scroll = scroll;
|
|
this.composing = false;
|
|
this.mouseDown = false;
|
|
this.root = this.scroll.domNode;
|
|
this.cursor = _parchment2.default.create('cursor', this);
|
|
// savedRange is last non-null range
|
|
this.lastRange = this.savedRange = new Range(0, 0);
|
|
this.handleComposition();
|
|
this.handleDragging();
|
|
this.emitter.listenDOM('selectionchange', document, function () {
|
|
if (!_this.mouseDown) {
|
|
setTimeout(_this.update.bind(_this, _emitter4.default.sources.USER), 1);
|
|
}
|
|
});
|
|
this.emitter.on(_emitter4.default.events.EDITOR_CHANGE, function (type, delta) {
|
|
if (type === _emitter4.default.events.TEXT_CHANGE && delta.length() > 0) {
|
|
_this.update(_emitter4.default.sources.SILENT);
|
|
}
|
|
});
|
|
this.emitter.on(_emitter4.default.events.SCROLL_BEFORE_UPDATE, function () {
|
|
if (!_this.hasFocus()) return;
|
|
var native = _this.getNativeRange();
|
|
if (native == null) return;
|
|
if (native.start.node === _this.cursor.textNode) return; // cursor.restore() will handle
|
|
// TODO unclear if this has negative side effects
|
|
_this.emitter.once(_emitter4.default.events.SCROLL_UPDATE, function () {
|
|
try {
|
|
_this.setNativeRange(native.start.node, native.start.offset, native.end.node, native.end.offset);
|
|
} catch (ignored) {}
|
|
});
|
|
});
|
|
this.emitter.on(_emitter4.default.events.SCROLL_OPTIMIZE, function (mutations, context) {
|
|
if (context.range) {
|
|
var _context$range = context.range,
|
|
startNode = _context$range.startNode,
|
|
startOffset = _context$range.startOffset,
|
|
endNode = _context$range.endNode,
|
|
endOffset = _context$range.endOffset;
|
|
|
|
_this.setNativeRange(startNode, startOffset, endNode, endOffset);
|
|
}
|
|
});
|
|
this.update(_emitter4.default.sources.SILENT);
|
|
}
|
|
|
|
_createClass(Selection, [{
|
|
key: 'handleComposition',
|
|
value: function handleComposition() {
|
|
var _this2 = this;
|
|
|
|
this.root.addEventListener('compositionstart', function () {
|
|
_this2.composing = true;
|
|
});
|
|
this.root.addEventListener('compositionend', function () {
|
|
_this2.composing = false;
|
|
if (_this2.cursor.parent) {
|
|
var range = _this2.cursor.restore();
|
|
if (!range) return;
|
|
setTimeout(function () {
|
|
_this2.setNativeRange(range.startNode, range.startOffset, range.endNode, range.endOffset);
|
|
}, 1);
|
|
}
|
|
});
|
|
}
|
|
}, {
|
|
key: 'handleDragging',
|
|
value: function handleDragging() {
|
|
var _this3 = this;
|
|
|
|
this.emitter.listenDOM('mousedown', document.body, function () {
|
|
_this3.mouseDown = true;
|
|
});
|
|
this.emitter.listenDOM('mouseup', document.body, function () {
|
|
_this3.mouseDown = false;
|
|
_this3.update(_emitter4.default.sources.USER);
|
|
});
|
|
}
|
|
}, {
|
|
key: 'focus',
|
|
value: function focus() {
|
|
if (this.hasFocus()) return;
|
|
this.root.focus();
|
|
this.setRange(this.savedRange);
|
|
}
|
|
}, {
|
|
key: 'format',
|
|
value: function format(_format, value) {
|
|
if (this.scroll.whitelist != null && !this.scroll.whitelist[_format]) return;
|
|
this.scroll.update();
|
|
var nativeRange = this.getNativeRange();
|
|
if (nativeRange == null || !nativeRange.native.collapsed || _parchment2.default.query(_format, _parchment2.default.Scope.BLOCK)) return;
|
|
if (nativeRange.start.node !== this.cursor.textNode) {
|
|
var blot = _parchment2.default.find(nativeRange.start.node, false);
|
|
if (blot == null) return;
|
|
// TODO Give blot ability to not split
|
|
if (blot instanceof _parchment2.default.Leaf) {
|
|
var after = blot.split(nativeRange.start.offset);
|
|
blot.parent.insertBefore(this.cursor, after);
|
|
} else {
|
|
blot.insertBefore(this.cursor, nativeRange.start.node); // Should never happen
|
|
}
|
|
this.cursor.attach();
|
|
}
|
|
this.cursor.format(_format, value);
|
|
this.scroll.optimize();
|
|
this.setNativeRange(this.cursor.textNode, this.cursor.textNode.data.length);
|
|
this.update();
|
|
}
|
|
}, {
|
|
key: 'getBounds',
|
|
value: function getBounds(index) {
|
|
var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
|
|
var scrollLength = this.scroll.length();
|
|
index = Math.min(index, scrollLength - 1);
|
|
length = Math.min(index + length, scrollLength - 1) - index;
|
|
var node = void 0,
|
|
_scroll$leaf = this.scroll.leaf(index),
|
|
_scroll$leaf2 = _slicedToArray(_scroll$leaf, 2),
|
|
leaf = _scroll$leaf2[0],
|
|
offset = _scroll$leaf2[1];
|
|
if (leaf == null) return null;
|
|
|
|
var _leaf$position = leaf.position(offset, true);
|
|
|
|
var _leaf$position2 = _slicedToArray(_leaf$position, 2);
|
|
|
|
node = _leaf$position2[0];
|
|
offset = _leaf$position2[1];
|
|
|
|
var range = document.createRange();
|
|
if (length > 0) {
|
|
range.setStart(node, offset);
|
|
|
|
var _scroll$leaf3 = this.scroll.leaf(index + length);
|
|
|
|
var _scroll$leaf4 = _slicedToArray(_scroll$leaf3, 2);
|
|
|
|
leaf = _scroll$leaf4[0];
|
|
offset = _scroll$leaf4[1];
|
|
|
|
if (leaf == null) return null;
|
|
|
|
var _leaf$position3 = leaf.position(offset, true);
|
|
|
|
var _leaf$position4 = _slicedToArray(_leaf$position3, 2);
|
|
|
|
node = _leaf$position4[0];
|
|
offset = _leaf$position4[1];
|
|
|
|
range.setEnd(node, offset);
|
|
return range.getBoundingClientRect();
|
|
} else {
|
|
var side = 'left';
|
|
var rect = void 0;
|
|
if (node instanceof Text) {
|
|
if (offset < node.data.length) {
|
|
range.setStart(node, offset);
|
|
range.setEnd(node, offset + 1);
|
|
} else {
|
|
range.setStart(node, offset - 1);
|
|
range.setEnd(node, offset);
|
|
side = 'right';
|
|
}
|
|
rect = range.getBoundingClientRect();
|
|
} else {
|
|
rect = leaf.domNode.getBoundingClientRect();
|
|
if (offset > 0) side = 'right';
|
|
}
|
|
return {
|
|
bottom: rect.top + rect.height,
|
|
height: rect.height,
|
|
left: rect[side],
|
|
right: rect[side],
|
|
top: rect.top,
|
|
width: 0
|
|
};
|
|
}
|
|
}
|
|
}, {
|
|
key: 'getNativeRange',
|
|
value: function getNativeRange() {
|
|
var selection = document.getSelection();
|
|
if (selection == null || selection.rangeCount <= 0) return null;
|
|
var nativeRange = selection.getRangeAt(0);
|
|
if (nativeRange == null) return null;
|
|
var range = this.normalizeNative(nativeRange);
|
|
debug.info('getNativeRange', range);
|
|
return range;
|
|
}
|
|
}, {
|
|
key: 'getRange',
|
|
value: function getRange() {
|
|
var normalized = this.getNativeRange();
|
|
if (normalized == null) return [null, null];
|
|
var range = this.normalizedToRange(normalized);
|
|
return [range, normalized];
|
|
}
|
|
}, {
|
|
key: 'hasFocus',
|
|
value: function hasFocus() {
|
|
return document.activeElement === this.root;
|
|
}
|
|
}, {
|
|
key: 'normalizedToRange',
|
|
value: function normalizedToRange(range) {
|
|
var _this4 = this;
|
|
|
|
var positions = [[range.start.node, range.start.offset]];
|
|
if (!range.native.collapsed) {
|
|
positions.push([range.end.node, range.end.offset]);
|
|
}
|
|
var indexes = positions.map(function (position) {
|
|
var _position = _slicedToArray(position, 2),
|
|
node = _position[0],
|
|
offset = _position[1];
|
|
|
|
var blot = _parchment2.default.find(node, true);
|
|
var index = blot.offset(_this4.scroll);
|
|
if (offset === 0) {
|
|
return index;
|
|
} else if (blot instanceof _parchment2.default.Container) {
|
|
return index + blot.length();
|
|
} else {
|
|
return index + blot.index(node, offset);
|
|
}
|
|
});
|
|
var end = Math.min(Math.max.apply(Math, _toConsumableArray(indexes)), this.scroll.length() - 1);
|
|
var start = Math.min.apply(Math, [end].concat(_toConsumableArray(indexes)));
|
|
return new Range(start, end - start);
|
|
}
|
|
}, {
|
|
key: 'normalizeNative',
|
|
value: function normalizeNative(nativeRange) {
|
|
if (!contains(this.root, nativeRange.startContainer) || !nativeRange.collapsed && !contains(this.root, nativeRange.endContainer)) {
|
|
return null;
|
|
}
|
|
var range = {
|
|
start: { node: nativeRange.startContainer, offset: nativeRange.startOffset },
|
|
end: { node: nativeRange.endContainer, offset: nativeRange.endOffset },
|
|
native: nativeRange
|
|
};
|
|
[range.start, range.end].forEach(function (position) {
|
|
var node = position.node,
|
|
offset = position.offset;
|
|
while (!(node instanceof Text) && node.childNodes.length > 0) {
|
|
if (node.childNodes.length > offset) {
|
|
node = node.childNodes[offset];
|
|
offset = 0;
|
|
} else if (node.childNodes.length === offset) {
|
|
node = node.lastChild;
|
|
offset = node instanceof Text ? node.data.length : node.childNodes.length + 1;
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
position.node = node, position.offset = offset;
|
|
});
|
|
return range;
|
|
}
|
|
}, {
|
|
key: 'rangeToNative',
|
|
value: function rangeToNative(range) {
|
|
var _this5 = this;
|
|
|
|
var indexes = range.collapsed ? [range.index] : [range.index, range.index + range.length];
|
|
var args = [];
|
|
var scrollLength = this.scroll.length();
|
|
indexes.forEach(function (index, i) {
|
|
index = Math.min(scrollLength - 1, index);
|
|
var node = void 0,
|
|
_scroll$leaf5 = _this5.scroll.leaf(index),
|
|
_scroll$leaf6 = _slicedToArray(_scroll$leaf5, 2),
|
|
leaf = _scroll$leaf6[0],
|
|
offset = _scroll$leaf6[1];
|
|
var _leaf$position5 = leaf.position(offset, i !== 0);
|
|
|
|
var _leaf$position6 = _slicedToArray(_leaf$position5, 2);
|
|
|
|
node = _leaf$position6[0];
|
|
offset = _leaf$position6[1];
|
|
|
|
args.push(node, offset);
|
|
});
|
|
if (args.length < 2) {
|
|
args = args.concat(args);
|
|
}
|
|
return args;
|
|
}
|
|
}, {
|
|
key: 'scrollIntoView',
|
|
value: function scrollIntoView(scrollingContainer) {
|
|
var range = this.lastRange;
|
|
if (range == null) return;
|
|
var bounds = this.getBounds(range.index, range.length);
|
|
if (bounds == null) return;
|
|
var limit = this.scroll.length() - 1;
|
|
|
|
var _scroll$line = this.scroll.line(Math.min(range.index, limit)),
|
|
_scroll$line2 = _slicedToArray(_scroll$line, 1),
|
|
first = _scroll$line2[0];
|
|
|
|
var last = first;
|
|
if (range.length > 0) {
|
|
var _scroll$line3 = this.scroll.line(Math.min(range.index + range.length, limit));
|
|
|
|
var _scroll$line4 = _slicedToArray(_scroll$line3, 1);
|
|
|
|
last = _scroll$line4[0];
|
|
}
|
|
if (first == null || last == null) return;
|
|
var scrollBounds = scrollingContainer.getBoundingClientRect();
|
|
if (bounds.top < scrollBounds.top) {
|
|
scrollingContainer.scrollTop -= scrollBounds.top - bounds.top;
|
|
} else if (bounds.bottom > scrollBounds.bottom) {
|
|
scrollingContainer.scrollTop += bounds.bottom - scrollBounds.bottom;
|
|
}
|
|
}
|
|
}, {
|
|
key: 'setNativeRange',
|
|
value: function setNativeRange(startNode, startOffset) {
|
|
var endNode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : startNode;
|
|
var endOffset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : startOffset;
|
|
var force = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
|
|
debug.info('setNativeRange', startNode, startOffset, endNode, endOffset);
|
|
if (startNode != null && (this.root.parentNode == null || startNode.parentNode == null || endNode.parentNode == null)) {
|
|
return;
|
|
}
|
|
var selection = document.getSelection();
|
|
if (selection == null) return;
|
|
if (startNode != null) {
|
|
if (!this.hasFocus()) this.root.focus();
|
|
var native = (this.getNativeRange() || {}).native;
|
|
if (native == null || force || startNode !== native.startContainer || startOffset !== native.startOffset || endNode !== native.endContainer || endOffset !== native.endOffset) {
|
|
|
|
if (startNode.tagName == "BR") {
|
|
startOffset = [].indexOf.call(startNode.parentNode.childNodes, startNode);
|
|
startNode = startNode.parentNode;
|
|
}
|
|
if (endNode.tagName == "BR") {
|
|
endOffset = [].indexOf.call(endNode.parentNode.childNodes, endNode);
|
|
endNode = endNode.parentNode;
|
|
}
|
|
var range = document.createRange();
|
|
range.setStart(startNode, startOffset);
|
|
range.setEnd(endNode, endOffset);
|
|
selection.removeAllRanges();
|
|
selection.addRange(range);
|
|
}
|
|
} else {
|
|
selection.removeAllRanges();
|
|
this.root.blur();
|
|
document.body.focus(); // root.blur() not enough on IE11+Travis+SauceLabs (but not local VMs)
|
|
}
|
|
}
|
|
}, {
|
|
key: 'setRange',
|
|
value: function setRange(range) {
|
|
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _emitter4.default.sources.API;
|
|
|
|
if (typeof force === 'string') {
|
|
source = force;
|
|
force = false;
|
|
}
|
|
debug.info('setRange', range);
|
|
if (range != null) {
|
|
var args = this.rangeToNative(range);
|
|
this.setNativeRange.apply(this, _toConsumableArray(args).concat([force]));
|
|
} else {
|
|
this.setNativeRange(null);
|
|
}
|
|
this.update(source);
|
|
}
|
|
}, {
|
|
key: 'update',
|
|
value: function update() {
|
|
var source = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _emitter4.default.sources.USER;
|
|
|
|
var oldRange = this.lastRange;
|
|
|
|
var _getRange = this.getRange(),
|
|
_getRange2 = _slicedToArray(_getRange, 2),
|
|
lastRange = _getRange2[0],
|
|
nativeRange = _getRange2[1];
|
|
|
|
this.lastRange = lastRange;
|
|
if (this.lastRange != null) {
|
|
this.savedRange = this.lastRange;
|
|
}
|
|
if (!(0, _deepEqual2.default)(oldRange, this.lastRange)) {
|
|
var _emitter;
|
|
|
|
if (!this.composing && nativeRange != null && nativeRange.native.collapsed && nativeRange.start.node !== this.cursor.textNode) {
|
|
this.cursor.restore();
|
|
}
|
|
var args = [_emitter4.default.events.SELECTION_CHANGE, (0, _clone2.default)(this.lastRange), (0, _clone2.default)(oldRange), source];
|
|
(_emitter = this.emitter).emit.apply(_emitter, [_emitter4.default.events.EDITOR_CHANGE].concat(args));
|
|
if (source !== _emitter4.default.sources.SILENT) {
|
|
var _emitter2;
|
|
|
|
(_emitter2 = this.emitter).emit.apply(_emitter2, args);
|
|
}
|
|
}
|
|
}
|
|
}]);
|
|
|
|
return Selection;
|
|
}();
|
|
|
|
function contains(parent, descendant) {
|
|
try {
|
|
// Firefox inserts inaccessible nodes around video elements
|
|
descendant.parentNode;
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
// IE11 has bug with Text nodes
|
|
// https://connect.microsoft.com/IE/feedback/details/780874/node-contains-is-incorrect
|
|
if (descendant instanceof Text) {
|
|
descendant = descendant.parentNode;
|
|
}
|
|
return parent.contains(descendant);
|
|
}
|
|
|
|
exports.Range = Range;
|
|
exports.default = Selection;
|
|
|
|
/***/ }),
|
|
/* 16 */
|
|
/***/ (function(module, exports, __nested_webpack_require_116908__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _parchment = __nested_webpack_require_116908__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var Break = function (_Parchment$Embed) {
|
|
_inherits(Break, _Parchment$Embed);
|
|
|
|
function Break() {
|
|
_classCallCheck(this, Break);
|
|
|
|
return _possibleConstructorReturn(this, (Break.__proto__ || Object.getPrototypeOf(Break)).apply(this, arguments));
|
|
}
|
|
|
|
_createClass(Break, [{
|
|
key: 'insertInto',
|
|
value: function insertInto(parent, ref) {
|
|
if (parent.children.length === 0) {
|
|
_get(Break.prototype.__proto__ || Object.getPrototypeOf(Break.prototype), 'insertInto', this).call(this, parent, ref);
|
|
} else {
|
|
this.remove();
|
|
}
|
|
}
|
|
}, {
|
|
key: 'length',
|
|
value: function length() {
|
|
return 0;
|
|
}
|
|
}, {
|
|
key: 'value',
|
|
value: function value() {
|
|
return '';
|
|
}
|
|
}], [{
|
|
key: 'value',
|
|
value: function value() {
|
|
return undefined;
|
|
}
|
|
}]);
|
|
|
|
return Break;
|
|
}(_parchment2.default.Embed);
|
|
|
|
Break.blotName = 'break';
|
|
Break.tagName = 'BR';
|
|
|
|
exports.default = Break;
|
|
|
|
/***/ }),
|
|
/* 17 */
|
|
/***/ (function(module, exports, __nested_webpack_require_120162__) {
|
|
|
|
"use strict";
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var linked_list_1 = __nested_webpack_require_120162__(44);
|
|
var shadow_1 = __nested_webpack_require_120162__(30);
|
|
var Registry = __nested_webpack_require_120162__(1);
|
|
var ContainerBlot = /** @class */ (function (_super) {
|
|
__extends(ContainerBlot, _super);
|
|
function ContainerBlot(domNode) {
|
|
var _this = _super.call(this, domNode) || this;
|
|
_this.build();
|
|
return _this;
|
|
}
|
|
ContainerBlot.prototype.appendChild = function (other) {
|
|
this.insertBefore(other);
|
|
};
|
|
ContainerBlot.prototype.attach = function () {
|
|
_super.prototype.attach.call(this);
|
|
this.children.forEach(function (child) {
|
|
child.attach();
|
|
});
|
|
};
|
|
ContainerBlot.prototype.build = function () {
|
|
var _this = this;
|
|
this.children = new linked_list_1.default();
|
|
// Need to be reversed for if DOM nodes already in order
|
|
[].slice
|
|
.call(this.domNode.childNodes)
|
|
.reverse()
|
|
.forEach(function (node) {
|
|
try {
|
|
var child = makeBlot(node);
|
|
_this.insertBefore(child, _this.children.head || undefined);
|
|
}
|
|
catch (err) {
|
|
if (err instanceof Registry.ParchmentError)
|
|
return;
|
|
else
|
|
throw err;
|
|
}
|
|
});
|
|
};
|
|
ContainerBlot.prototype.deleteAt = function (index, length) {
|
|
if (index === 0 && length === this.length()) {
|
|
return this.remove();
|
|
}
|
|
this.children.forEachAt(index, length, function (child, offset, length) {
|
|
child.deleteAt(offset, length);
|
|
});
|
|
};
|
|
ContainerBlot.prototype.descendant = function (criteria, index) {
|
|
var _a = this.children.find(index), child = _a[0], offset = _a[1];
|
|
if ((criteria.blotName == null && criteria(child)) ||
|
|
(criteria.blotName != null && child instanceof criteria)) {
|
|
return [child, offset];
|
|
}
|
|
else if (child instanceof ContainerBlot) {
|
|
return child.descendant(criteria, offset);
|
|
}
|
|
else {
|
|
return [null, -1];
|
|
}
|
|
};
|
|
ContainerBlot.prototype.descendants = function (criteria, index, length) {
|
|
if (index === void 0) { index = 0; }
|
|
if (length === void 0) { length = Number.MAX_VALUE; }
|
|
var descendants = [];
|
|
var lengthLeft = length;
|
|
this.children.forEachAt(index, length, function (child, index, length) {
|
|
if ((criteria.blotName == null && criteria(child)) ||
|
|
(criteria.blotName != null && child instanceof criteria)) {
|
|
descendants.push(child);
|
|
}
|
|
if (child instanceof ContainerBlot) {
|
|
descendants = descendants.concat(child.descendants(criteria, index, lengthLeft));
|
|
}
|
|
lengthLeft -= length;
|
|
});
|
|
return descendants;
|
|
};
|
|
ContainerBlot.prototype.detach = function () {
|
|
this.children.forEach(function (child) {
|
|
child.detach();
|
|
});
|
|
_super.prototype.detach.call(this);
|
|
};
|
|
ContainerBlot.prototype.formatAt = function (index, length, name, value) {
|
|
this.children.forEachAt(index, length, function (child, offset, length) {
|
|
child.formatAt(offset, length, name, value);
|
|
});
|
|
};
|
|
ContainerBlot.prototype.insertAt = function (index, value, def) {
|
|
var _a = this.children.find(index), child = _a[0], offset = _a[1];
|
|
if (child) {
|
|
child.insertAt(offset, value, def);
|
|
}
|
|
else {
|
|
var blot = def == null ? Registry.create('text', value) : Registry.create(value, def);
|
|
this.appendChild(blot);
|
|
}
|
|
};
|
|
ContainerBlot.prototype.insertBefore = function (childBlot, refBlot) {
|
|
if (this.statics.allowedChildren != null &&
|
|
!this.statics.allowedChildren.some(function (child) {
|
|
return childBlot instanceof child;
|
|
})) {
|
|
throw new Registry.ParchmentError("Cannot insert " + childBlot.statics.blotName + " into " + this.statics.blotName);
|
|
}
|
|
childBlot.insertInto(this, refBlot);
|
|
};
|
|
ContainerBlot.prototype.length = function () {
|
|
return this.children.reduce(function (memo, child) {
|
|
return memo + child.length();
|
|
}, 0);
|
|
};
|
|
ContainerBlot.prototype.moveChildren = function (targetParent, refNode) {
|
|
this.children.forEach(function (child) {
|
|
targetParent.insertBefore(child, refNode);
|
|
});
|
|
};
|
|
ContainerBlot.prototype.optimize = function (context) {
|
|
_super.prototype.optimize.call(this, context);
|
|
if (this.children.length === 0) {
|
|
if (this.statics.defaultChild != null) {
|
|
var child = Registry.create(this.statics.defaultChild);
|
|
this.appendChild(child);
|
|
child.optimize(context);
|
|
}
|
|
else {
|
|
this.remove();
|
|
}
|
|
}
|
|
};
|
|
ContainerBlot.prototype.path = function (index, inclusive) {
|
|
if (inclusive === void 0) { inclusive = false; }
|
|
var _a = this.children.find(index, inclusive), child = _a[0], offset = _a[1];
|
|
var position = [[this, index]];
|
|
if (child instanceof ContainerBlot) {
|
|
return position.concat(child.path(offset, inclusive));
|
|
}
|
|
else if (child != null) {
|
|
position.push([child, offset]);
|
|
}
|
|
return position;
|
|
};
|
|
ContainerBlot.prototype.removeChild = function (child) {
|
|
this.children.remove(child);
|
|
};
|
|
ContainerBlot.prototype.replace = function (target) {
|
|
if (target instanceof ContainerBlot) {
|
|
target.moveChildren(this);
|
|
}
|
|
_super.prototype.replace.call(this, target);
|
|
};
|
|
ContainerBlot.prototype.split = function (index, force) {
|
|
if (force === void 0) { force = false; }
|
|
if (!force) {
|
|
if (index === 0)
|
|
return this;
|
|
if (index === this.length())
|
|
return this.next;
|
|
}
|
|
var after = this.clone();
|
|
this.parent.insertBefore(after, this.next);
|
|
this.children.forEachAt(index, this.length(), function (child, offset, length) {
|
|
child = child.split(offset, force);
|
|
after.appendChild(child);
|
|
});
|
|
return after;
|
|
};
|
|
ContainerBlot.prototype.unwrap = function () {
|
|
this.moveChildren(this.parent, this.next);
|
|
this.remove();
|
|
};
|
|
ContainerBlot.prototype.update = function (mutations, context) {
|
|
var _this = this;
|
|
var addedNodes = [];
|
|
var removedNodes = [];
|
|
mutations.forEach(function (mutation) {
|
|
if (mutation.target === _this.domNode && mutation.type === 'childList') {
|
|
addedNodes.push.apply(addedNodes, mutation.addedNodes);
|
|
removedNodes.push.apply(removedNodes, mutation.removedNodes);
|
|
}
|
|
});
|
|
removedNodes.forEach(function (node) {
|
|
// Check node has actually been removed
|
|
// One exception is Chrome does not immediately remove IFRAMEs
|
|
// from DOM but MutationRecord is correct in its reported removal
|
|
if (node.parentNode != null &&
|
|
// @ts-ignore
|
|
node.tagName !== 'IFRAME' &&
|
|
document.body.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_CONTAINED_BY) {
|
|
return;
|
|
}
|
|
var blot = Registry.find(node);
|
|
if (blot == null)
|
|
return;
|
|
if (blot.domNode.parentNode == null || blot.domNode.parentNode === _this.domNode) {
|
|
blot.detach();
|
|
}
|
|
});
|
|
addedNodes
|
|
.filter(function (node) {
|
|
return node.parentNode == _this.domNode;
|
|
})
|
|
.sort(function (a, b) {
|
|
if (a === b)
|
|
return 0;
|
|
if (a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING) {
|
|
return 1;
|
|
}
|
|
return -1;
|
|
})
|
|
.forEach(function (node) {
|
|
var refBlot = null;
|
|
if (node.nextSibling != null) {
|
|
refBlot = Registry.find(node.nextSibling);
|
|
}
|
|
var blot = makeBlot(node);
|
|
if (blot.next != refBlot || blot.next == null) {
|
|
if (blot.parent != null) {
|
|
blot.parent.removeChild(_this);
|
|
}
|
|
_this.insertBefore(blot, refBlot || undefined);
|
|
}
|
|
});
|
|
};
|
|
return ContainerBlot;
|
|
}(shadow_1.default));
|
|
function makeBlot(node) {
|
|
var blot = Registry.find(node);
|
|
if (blot == null) {
|
|
try {
|
|
blot = Registry.create(node);
|
|
}
|
|
catch (e) {
|
|
blot = Registry.create(Registry.Scope.INLINE);
|
|
[].slice.call(node.childNodes).forEach(function (child) {
|
|
// @ts-ignore
|
|
blot.domNode.appendChild(child);
|
|
});
|
|
if (node.parentNode) {
|
|
node.parentNode.replaceChild(blot.domNode, node);
|
|
}
|
|
blot.attach();
|
|
}
|
|
}
|
|
return blot;
|
|
}
|
|
exports.default = ContainerBlot;
|
|
|
|
|
|
/***/ }),
|
|
/* 18 */
|
|
/***/ (function(module, exports, __nested_webpack_require_130088__) {
|
|
|
|
"use strict";
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var attributor_1 = __nested_webpack_require_130088__(12);
|
|
var store_1 = __nested_webpack_require_130088__(31);
|
|
var container_1 = __nested_webpack_require_130088__(17);
|
|
var Registry = __nested_webpack_require_130088__(1);
|
|
var FormatBlot = /** @class */ (function (_super) {
|
|
__extends(FormatBlot, _super);
|
|
function FormatBlot(domNode) {
|
|
var _this = _super.call(this, domNode) || this;
|
|
_this.attributes = new store_1.default(_this.domNode);
|
|
return _this;
|
|
}
|
|
FormatBlot.formats = function (domNode) {
|
|
if (typeof this.tagName === 'string') {
|
|
return true;
|
|
}
|
|
else if (Array.isArray(this.tagName)) {
|
|
return domNode.tagName.toLowerCase();
|
|
}
|
|
return undefined;
|
|
};
|
|
FormatBlot.prototype.format = function (name, value) {
|
|
var format = Registry.query(name);
|
|
if (format instanceof attributor_1.default) {
|
|
this.attributes.attribute(format, value);
|
|
}
|
|
else if (value) {
|
|
if (format != null && (name !== this.statics.blotName || this.formats()[name] !== value)) {
|
|
this.replaceWith(name, value);
|
|
}
|
|
}
|
|
};
|
|
FormatBlot.prototype.formats = function () {
|
|
var formats = this.attributes.values();
|
|
var format = this.statics.formats(this.domNode);
|
|
if (format != null) {
|
|
formats[this.statics.blotName] = format;
|
|
}
|
|
return formats;
|
|
};
|
|
FormatBlot.prototype.replaceWith = function (name, value) {
|
|
var replacement = _super.prototype.replaceWith.call(this, name, value);
|
|
this.attributes.copy(replacement);
|
|
return replacement;
|
|
};
|
|
FormatBlot.prototype.update = function (mutations, context) {
|
|
var _this = this;
|
|
_super.prototype.update.call(this, mutations, context);
|
|
if (mutations.some(function (mutation) {
|
|
return mutation.target === _this.domNode && mutation.type === 'attributes';
|
|
})) {
|
|
this.attributes.build();
|
|
}
|
|
};
|
|
FormatBlot.prototype.wrap = function (name, value) {
|
|
var wrapper = _super.prototype.wrap.call(this, name, value);
|
|
if (wrapper instanceof FormatBlot && wrapper.statics.scope === this.statics.scope) {
|
|
this.attributes.move(wrapper);
|
|
}
|
|
return wrapper;
|
|
};
|
|
return FormatBlot;
|
|
}(container_1.default));
|
|
exports.default = FormatBlot;
|
|
|
|
|
|
/***/ }),
|
|
/* 19 */
|
|
/***/ (function(module, exports, __nested_webpack_require_133111__) {
|
|
|
|
"use strict";
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var shadow_1 = __nested_webpack_require_133111__(30);
|
|
var Registry = __nested_webpack_require_133111__(1);
|
|
var LeafBlot = /** @class */ (function (_super) {
|
|
__extends(LeafBlot, _super);
|
|
function LeafBlot() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
LeafBlot.value = function (domNode) {
|
|
return true;
|
|
};
|
|
LeafBlot.prototype.index = function (node, offset) {
|
|
if (this.domNode === node ||
|
|
this.domNode.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_CONTAINED_BY) {
|
|
return Math.min(offset, 1);
|
|
}
|
|
return -1;
|
|
};
|
|
LeafBlot.prototype.position = function (index, inclusive) {
|
|
var offset = [].indexOf.call(this.parent.domNode.childNodes, this.domNode);
|
|
if (index > 0)
|
|
offset += 1;
|
|
return [this.parent.domNode, offset];
|
|
};
|
|
LeafBlot.prototype.value = function () {
|
|
var _a;
|
|
return _a = {}, _a[this.statics.blotName] = this.statics.value(this.domNode) || true, _a;
|
|
};
|
|
LeafBlot.scope = Registry.Scope.INLINE_BLOT;
|
|
return LeafBlot;
|
|
}(shadow_1.default));
|
|
exports.default = LeafBlot;
|
|
|
|
|
|
/***/ }),
|
|
/* 20 */
|
|
/***/ (function(module, exports, __nested_webpack_require_134898__) {
|
|
|
|
var equal = __nested_webpack_require_134898__(11);
|
|
var extend = __nested_webpack_require_134898__(3);
|
|
|
|
|
|
var lib = {
|
|
attributes: {
|
|
compose: function (a, b, keepNull) {
|
|
if (typeof a !== 'object') a = {};
|
|
if (typeof b !== 'object') b = {};
|
|
var attributes = extend(true, {}, b);
|
|
if (!keepNull) {
|
|
attributes = Object.keys(attributes).reduce(function (copy, key) {
|
|
if (attributes[key] != null) {
|
|
copy[key] = attributes[key];
|
|
}
|
|
return copy;
|
|
}, {});
|
|
}
|
|
for (var key in a) {
|
|
if (a[key] !== undefined && b[key] === undefined) {
|
|
attributes[key] = a[key];
|
|
}
|
|
}
|
|
return Object.keys(attributes).length > 0 ? attributes : undefined;
|
|
},
|
|
|
|
diff: function(a, b) {
|
|
if (typeof a !== 'object') a = {};
|
|
if (typeof b !== 'object') b = {};
|
|
var attributes = Object.keys(a).concat(Object.keys(b)).reduce(function (attributes, key) {
|
|
if (!equal(a[key], b[key])) {
|
|
attributes[key] = b[key] === undefined ? null : b[key];
|
|
}
|
|
return attributes;
|
|
}, {});
|
|
return Object.keys(attributes).length > 0 ? attributes : undefined;
|
|
},
|
|
|
|
transform: function (a, b, priority) {
|
|
if (typeof a !== 'object') return b;
|
|
if (typeof b !== 'object') return undefined;
|
|
if (!priority) return b; // b simply overwrites us without priority
|
|
var attributes = Object.keys(b).reduce(function (attributes, key) {
|
|
if (a[key] === undefined) attributes[key] = b[key]; // null is a valid value
|
|
return attributes;
|
|
}, {});
|
|
return Object.keys(attributes).length > 0 ? attributes : undefined;
|
|
}
|
|
},
|
|
|
|
iterator: function (ops) {
|
|
return new Iterator(ops);
|
|
},
|
|
|
|
length: function (op) {
|
|
if (typeof op['delete'] === 'number') {
|
|
return op['delete'];
|
|
} else if (typeof op.retain === 'number') {
|
|
return op.retain;
|
|
} else {
|
|
return typeof op.insert === 'string' ? op.insert.length : 1;
|
|
}
|
|
}
|
|
};
|
|
|
|
|
|
function Iterator(ops) {
|
|
this.ops = ops;
|
|
this.index = 0;
|
|
this.offset = 0;
|
|
};
|
|
|
|
Iterator.prototype.hasNext = function () {
|
|
return this.peekLength() < Infinity;
|
|
};
|
|
|
|
Iterator.prototype.next = function (length) {
|
|
if (!length) length = Infinity;
|
|
var nextOp = this.ops[this.index];
|
|
if (nextOp) {
|
|
var offset = this.offset;
|
|
var opLength = lib.length(nextOp)
|
|
if (length >= opLength - offset) {
|
|
length = opLength - offset;
|
|
this.index += 1;
|
|
this.offset = 0;
|
|
} else {
|
|
this.offset += length;
|
|
}
|
|
if (typeof nextOp['delete'] === 'number') {
|
|
return { 'delete': length };
|
|
} else {
|
|
var retOp = {};
|
|
if (nextOp.attributes) {
|
|
retOp.attributes = nextOp.attributes;
|
|
}
|
|
if (typeof nextOp.retain === 'number') {
|
|
retOp.retain = length;
|
|
} else if (typeof nextOp.insert === 'string') {
|
|
retOp.insert = nextOp.insert.substr(offset, length);
|
|
} else {
|
|
// offset should === 0, length should === 1
|
|
retOp.insert = nextOp.insert;
|
|
}
|
|
return retOp;
|
|
}
|
|
} else {
|
|
return { retain: Infinity };
|
|
}
|
|
};
|
|
|
|
Iterator.prototype.peek = function () {
|
|
return this.ops[this.index];
|
|
};
|
|
|
|
Iterator.prototype.peekLength = function () {
|
|
if (this.ops[this.index]) {
|
|
// Should never return 0 if our index is being managed correctly
|
|
return lib.length(this.ops[this.index]) - this.offset;
|
|
} else {
|
|
return Infinity;
|
|
}
|
|
};
|
|
|
|
Iterator.prototype.peekType = function () {
|
|
if (this.ops[this.index]) {
|
|
if (typeof this.ops[this.index]['delete'] === 'number') {
|
|
return 'delete';
|
|
} else if (typeof this.ops[this.index].retain === 'number') {
|
|
return 'retain';
|
|
} else {
|
|
return 'insert';
|
|
}
|
|
}
|
|
return 'retain';
|
|
};
|
|
|
|
Iterator.prototype.rest = function () {
|
|
if (!this.hasNext()) {
|
|
return [];
|
|
} else if (this.offset === 0) {
|
|
return this.ops.slice(this.index);
|
|
} else {
|
|
var offset = this.offset;
|
|
var index = this.index;
|
|
var next = this.next();
|
|
var rest = this.ops.slice(this.index);
|
|
this.offset = offset;
|
|
this.index = index;
|
|
return [next].concat(rest);
|
|
}
|
|
};
|
|
|
|
|
|
module.exports = lib;
|
|
|
|
|
|
/***/ }),
|
|
/* 21 */
|
|
/***/ (function(module, exports) {
|
|
|
|
var clone = (function() {
|
|
'use strict';
|
|
|
|
function _instanceof(obj, type) {
|
|
return type != null && obj instanceof type;
|
|
}
|
|
|
|
var nativeMap;
|
|
try {
|
|
nativeMap = Map;
|
|
} catch(_) {
|
|
// maybe a reference error because no `Map`. Give it a dummy value that no
|
|
// value will ever be an instanceof.
|
|
nativeMap = function() {};
|
|
}
|
|
|
|
var nativeSet;
|
|
try {
|
|
nativeSet = Set;
|
|
} catch(_) {
|
|
nativeSet = function() {};
|
|
}
|
|
|
|
var nativePromise;
|
|
try {
|
|
nativePromise = Promise;
|
|
} catch(_) {
|
|
nativePromise = function() {};
|
|
}
|
|
|
|
/**
|
|
* Clones (copies) an Object using deep copying.
|
|
*
|
|
* This function supports circular references by default, but if you are certain
|
|
* there are no circular references in your object, you can save some CPU time
|
|
* by calling clone(obj, false).
|
|
*
|
|
* Caution: if `circular` is false and `parent` contains circular references,
|
|
* your program may enter an infinite loop and crash.
|
|
*
|
|
* @param `parent` - the object to be cloned
|
|
* @param `circular` - set to true if the object to be cloned may contain
|
|
* circular references. (optional - true by default)
|
|
* @param `depth` - set to a number if the object is only to be cloned to
|
|
* a particular depth. (optional - defaults to Infinity)
|
|
* @param `prototype` - sets the prototype to be used when cloning an object.
|
|
* (optional - defaults to parent prototype).
|
|
* @param `includeNonEnumerable` - set to true if the non-enumerable properties
|
|
* should be cloned as well. Non-enumerable properties on the prototype
|
|
* chain will be ignored. (optional - false by default)
|
|
*/
|
|
function clone(parent, circular, depth, prototype, includeNonEnumerable) {
|
|
if (typeof circular === 'object') {
|
|
depth = circular.depth;
|
|
prototype = circular.prototype;
|
|
includeNonEnumerable = circular.includeNonEnumerable;
|
|
circular = circular.circular;
|
|
}
|
|
// maintain two arrays for circular references, where corresponding parents
|
|
// and children have the same index
|
|
var allParents = [];
|
|
var allChildren = [];
|
|
|
|
var useBuffer = typeof Buffer != 'undefined';
|
|
|
|
if (typeof circular == 'undefined')
|
|
circular = true;
|
|
|
|
if (typeof depth == 'undefined')
|
|
depth = Infinity;
|
|
|
|
// recurse this function so we don't reset allParents and allChildren
|
|
function _clone(parent, depth) {
|
|
// cloning null always returns null
|
|
if (parent === null)
|
|
return null;
|
|
|
|
if (depth === 0)
|
|
return parent;
|
|
|
|
var child;
|
|
var proto;
|
|
if (typeof parent != 'object') {
|
|
return parent;
|
|
}
|
|
|
|
if (_instanceof(parent, nativeMap)) {
|
|
child = new nativeMap();
|
|
} else if (_instanceof(parent, nativeSet)) {
|
|
child = new nativeSet();
|
|
} else if (_instanceof(parent, nativePromise)) {
|
|
child = new nativePromise(function (resolve, reject) {
|
|
parent.then(function(value) {
|
|
resolve(_clone(value, depth - 1));
|
|
}, function(err) {
|
|
reject(_clone(err, depth - 1));
|
|
});
|
|
});
|
|
} else if (clone.__isArray(parent)) {
|
|
child = [];
|
|
} else if (clone.__isRegExp(parent)) {
|
|
child = new RegExp(parent.source, __getRegExpFlags(parent));
|
|
if (parent.lastIndex) child.lastIndex = parent.lastIndex;
|
|
} else if (clone.__isDate(parent)) {
|
|
child = new Date(parent.getTime());
|
|
} else if (useBuffer && Buffer.isBuffer(parent)) {
|
|
if (Buffer.allocUnsafe) {
|
|
// Node.js >= 4.5.0
|
|
child = Buffer.allocUnsafe(parent.length);
|
|
} else {
|
|
// Older Node.js versions
|
|
child = new Buffer(parent.length);
|
|
}
|
|
parent.copy(child);
|
|
return child;
|
|
} else if (_instanceof(parent, Error)) {
|
|
child = Object.create(parent);
|
|
} else {
|
|
if (typeof prototype == 'undefined') {
|
|
proto = Object.getPrototypeOf(parent);
|
|
child = Object.create(proto);
|
|
}
|
|
else {
|
|
child = Object.create(prototype);
|
|
proto = prototype;
|
|
}
|
|
}
|
|
|
|
if (circular) {
|
|
var index = allParents.indexOf(parent);
|
|
|
|
if (index != -1) {
|
|
return allChildren[index];
|
|
}
|
|
allParents.push(parent);
|
|
allChildren.push(child);
|
|
}
|
|
|
|
if (_instanceof(parent, nativeMap)) {
|
|
parent.forEach(function(value, key) {
|
|
var keyChild = _clone(key, depth - 1);
|
|
var valueChild = _clone(value, depth - 1);
|
|
child.set(keyChild, valueChild);
|
|
});
|
|
}
|
|
if (_instanceof(parent, nativeSet)) {
|
|
parent.forEach(function(value) {
|
|
var entryChild = _clone(value, depth - 1);
|
|
child.add(entryChild);
|
|
});
|
|
}
|
|
|
|
for (var i in parent) {
|
|
var attrs;
|
|
if (proto) {
|
|
attrs = Object.getOwnPropertyDescriptor(proto, i);
|
|
}
|
|
|
|
if (attrs && attrs.set == null) {
|
|
continue;
|
|
}
|
|
child[i] = _clone(parent[i], depth - 1);
|
|
}
|
|
|
|
if (Object.getOwnPropertySymbols) {
|
|
var symbols = Object.getOwnPropertySymbols(parent);
|
|
for (var i = 0; i < symbols.length; i++) {
|
|
// Don't need to worry about cloning a symbol because it is a primitive,
|
|
// like a number or string.
|
|
var symbol = symbols[i];
|
|
var descriptor = Object.getOwnPropertyDescriptor(parent, symbol);
|
|
if (descriptor && !descriptor.enumerable && !includeNonEnumerable) {
|
|
continue;
|
|
}
|
|
child[symbol] = _clone(parent[symbol], depth - 1);
|
|
if (!descriptor.enumerable) {
|
|
Object.defineProperty(child, symbol, {
|
|
enumerable: false
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
if (includeNonEnumerable) {
|
|
var allPropertyNames = Object.getOwnPropertyNames(parent);
|
|
for (var i = 0; i < allPropertyNames.length; i++) {
|
|
var propertyName = allPropertyNames[i];
|
|
var descriptor = Object.getOwnPropertyDescriptor(parent, propertyName);
|
|
if (descriptor && descriptor.enumerable) {
|
|
continue;
|
|
}
|
|
child[propertyName] = _clone(parent[propertyName], depth - 1);
|
|
Object.defineProperty(child, propertyName, {
|
|
enumerable: false
|
|
});
|
|
}
|
|
}
|
|
|
|
return child;
|
|
}
|
|
|
|
return _clone(parent, depth);
|
|
}
|
|
|
|
/**
|
|
* Simple flat clone using prototype, accepts only objects, usefull for property
|
|
* override on FLAT configuration object (no nested props).
|
|
*
|
|
* USE WITH CAUTION! This may not behave as you wish if you do not know how this
|
|
* works.
|
|
*/
|
|
clone.clonePrototype = function clonePrototype(parent) {
|
|
if (parent === null)
|
|
return null;
|
|
|
|
var c = function () {};
|
|
c.prototype = parent;
|
|
return new c();
|
|
};
|
|
|
|
// private utility functions
|
|
|
|
function __objToStr(o) {
|
|
return Object.prototype.toString.call(o);
|
|
}
|
|
clone.__objToStr = __objToStr;
|
|
|
|
function __isDate(o) {
|
|
return typeof o === 'object' && __objToStr(o) === '[object Date]';
|
|
}
|
|
clone.__isDate = __isDate;
|
|
|
|
function __isArray(o) {
|
|
return typeof o === 'object' && __objToStr(o) === '[object Array]';
|
|
}
|
|
clone.__isArray = __isArray;
|
|
|
|
function __isRegExp(o) {
|
|
return typeof o === 'object' && __objToStr(o) === '[object RegExp]';
|
|
}
|
|
clone.__isRegExp = __isRegExp;
|
|
|
|
function __getRegExpFlags(re) {
|
|
var flags = '';
|
|
if (re.global) flags += 'g';
|
|
if (re.ignoreCase) flags += 'i';
|
|
if (re.multiline) flags += 'm';
|
|
return flags;
|
|
}
|
|
clone.__getRegExpFlags = __getRegExpFlags;
|
|
|
|
return clone;
|
|
})();
|
|
|
|
if (typeof module === 'object' && module.exports) {
|
|
module.exports = clone;
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
/* 22 */
|
|
/***/ (function(module, exports, __nested_webpack_require_146497__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _parchment = __nested_webpack_require_146497__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
var _emitter = __nested_webpack_require_146497__(8);
|
|
|
|
var _emitter2 = _interopRequireDefault(_emitter);
|
|
|
|
var _block = __nested_webpack_require_146497__(4);
|
|
|
|
var _block2 = _interopRequireDefault(_block);
|
|
|
|
var _break = __nested_webpack_require_146497__(16);
|
|
|
|
var _break2 = _interopRequireDefault(_break);
|
|
|
|
var _code = __nested_webpack_require_146497__(13);
|
|
|
|
var _code2 = _interopRequireDefault(_code);
|
|
|
|
var _container = __nested_webpack_require_146497__(25);
|
|
|
|
var _container2 = _interopRequireDefault(_container);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
function isLine(blot) {
|
|
return blot instanceof _block2.default || blot instanceof _block.BlockEmbed;
|
|
}
|
|
|
|
var Scroll = function (_Parchment$Scroll) {
|
|
_inherits(Scroll, _Parchment$Scroll);
|
|
|
|
function Scroll(domNode, config) {
|
|
_classCallCheck(this, Scroll);
|
|
|
|
var _this = _possibleConstructorReturn(this, (Scroll.__proto__ || Object.getPrototypeOf(Scroll)).call(this, domNode));
|
|
|
|
_this.emitter = config.emitter;
|
|
if (Array.isArray(config.whitelist)) {
|
|
_this.whitelist = config.whitelist.reduce(function (whitelist, format) {
|
|
whitelist[format] = true;
|
|
return whitelist;
|
|
}, {});
|
|
}
|
|
// Some reason fixes composition issues with character languages in Windows/Chrome, Safari
|
|
_this.domNode.addEventListener('DOMNodeInserted', function () {});
|
|
_this.optimize();
|
|
_this.enable();
|
|
return _this;
|
|
}
|
|
|
|
_createClass(Scroll, [{
|
|
key: 'batchStart',
|
|
value: function batchStart() {
|
|
this.batch = true;
|
|
}
|
|
}, {
|
|
key: 'batchEnd',
|
|
value: function batchEnd() {
|
|
this.batch = false;
|
|
this.optimize();
|
|
}
|
|
}, {
|
|
key: 'deleteAt',
|
|
value: function deleteAt(index, length) {
|
|
var _line = this.line(index),
|
|
_line2 = _slicedToArray(_line, 2),
|
|
first = _line2[0],
|
|
offset = _line2[1];
|
|
|
|
var _line3 = this.line(index + length),
|
|
_line4 = _slicedToArray(_line3, 1),
|
|
last = _line4[0];
|
|
|
|
_get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'deleteAt', this).call(this, index, length);
|
|
if (last != null && first !== last && offset > 0) {
|
|
if (first instanceof _block.BlockEmbed || last instanceof _block.BlockEmbed) {
|
|
this.optimize();
|
|
return;
|
|
}
|
|
if (first instanceof _code2.default) {
|
|
var newlineIndex = first.newlineIndex(first.length(), true);
|
|
if (newlineIndex > -1) {
|
|
first = first.split(newlineIndex + 1);
|
|
if (first === last) {
|
|
this.optimize();
|
|
return;
|
|
}
|
|
}
|
|
} else if (last instanceof _code2.default) {
|
|
var _newlineIndex = last.newlineIndex(0);
|
|
if (_newlineIndex > -1) {
|
|
last.split(_newlineIndex + 1);
|
|
}
|
|
}
|
|
var ref = last.children.head instanceof _break2.default ? null : last.children.head;
|
|
first.moveChildren(last, ref);
|
|
first.remove();
|
|
}
|
|
this.optimize();
|
|
}
|
|
}, {
|
|
key: 'enable',
|
|
value: function enable() {
|
|
var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
|
|
this.domNode.setAttribute('contenteditable', enabled);
|
|
}
|
|
}, {
|
|
key: 'formatAt',
|
|
value: function formatAt(index, length, format, value) {
|
|
if (this.whitelist != null && !this.whitelist[format]) return;
|
|
_get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'formatAt', this).call(this, index, length, format, value);
|
|
this.optimize();
|
|
}
|
|
}, {
|
|
key: 'insertAt',
|
|
value: function insertAt(index, value, def) {
|
|
if (def != null && this.whitelist != null && !this.whitelist[value]) return;
|
|
if (index >= this.length()) {
|
|
if (def == null || _parchment2.default.query(value, _parchment2.default.Scope.BLOCK) == null) {
|
|
var blot = _parchment2.default.create(this.statics.defaultChild);
|
|
this.appendChild(blot);
|
|
if (def == null && value.endsWith('\n')) {
|
|
value = value.slice(0, -1);
|
|
}
|
|
blot.insertAt(0, value, def);
|
|
} else {
|
|
var embed = _parchment2.default.create(value, def);
|
|
this.appendChild(embed);
|
|
}
|
|
} else {
|
|
_get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'insertAt', this).call(this, index, value, def);
|
|
}
|
|
this.optimize();
|
|
}
|
|
}, {
|
|
key: 'insertBefore',
|
|
value: function insertBefore(blot, ref) {
|
|
if (blot.statics.scope === _parchment2.default.Scope.INLINE_BLOT) {
|
|
var wrapper = _parchment2.default.create(this.statics.defaultChild);
|
|
wrapper.appendChild(blot);
|
|
blot = wrapper;
|
|
}
|
|
_get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'insertBefore', this).call(this, blot, ref);
|
|
}
|
|
}, {
|
|
key: 'leaf',
|
|
value: function leaf(index) {
|
|
return this.path(index).pop() || [null, -1];
|
|
}
|
|
}, {
|
|
key: 'line',
|
|
value: function line(index) {
|
|
if (index === this.length()) {
|
|
return this.line(index - 1);
|
|
}
|
|
return this.descendant(isLine, index);
|
|
}
|
|
}, {
|
|
key: 'lines',
|
|
value: function lines() {
|
|
var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Number.MAX_VALUE;
|
|
|
|
var getLines = function getLines(blot, index, length) {
|
|
var lines = [],
|
|
lengthLeft = length;
|
|
blot.children.forEachAt(index, length, function (child, index, length) {
|
|
if (isLine(child)) {
|
|
lines.push(child);
|
|
} else if (child instanceof _parchment2.default.Container) {
|
|
lines = lines.concat(getLines(child, index, lengthLeft));
|
|
}
|
|
lengthLeft -= length;
|
|
});
|
|
return lines;
|
|
};
|
|
return getLines(this, index, length);
|
|
}
|
|
}, {
|
|
key: 'optimize',
|
|
value: function optimize() {
|
|
var mutations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
|
|
if (this.batch === true) return;
|
|
_get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'optimize', this).call(this, mutations, context);
|
|
if (mutations.length > 0) {
|
|
this.emitter.emit(_emitter2.default.events.SCROLL_OPTIMIZE, mutations, context);
|
|
}
|
|
}
|
|
}, {
|
|
key: 'path',
|
|
value: function path(index) {
|
|
return _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'path', this).call(this, index).slice(1); // Exclude self
|
|
}
|
|
}, {
|
|
key: 'update',
|
|
value: function update(mutations) {
|
|
if (this.batch === true) return;
|
|
var source = _emitter2.default.sources.USER;
|
|
if (typeof mutations === 'string') {
|
|
source = mutations;
|
|
}
|
|
if (!Array.isArray(mutations)) {
|
|
mutations = this.observer.takeRecords();
|
|
}
|
|
if (mutations.length > 0) {
|
|
this.emitter.emit(_emitter2.default.events.SCROLL_BEFORE_UPDATE, source, mutations);
|
|
}
|
|
_get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'update', this).call(this, mutations.concat([])); // pass copy
|
|
if (mutations.length > 0) {
|
|
this.emitter.emit(_emitter2.default.events.SCROLL_UPDATE, source, mutations);
|
|
}
|
|
}
|
|
}]);
|
|
|
|
return Scroll;
|
|
}(_parchment2.default.Scroll);
|
|
|
|
Scroll.blotName = 'scroll';
|
|
Scroll.className = 'ql-editor';
|
|
Scroll.tagName = 'DIV';
|
|
Scroll.defaultChild = 'block';
|
|
Scroll.allowedChildren = [_block2.default, _block.BlockEmbed, _container2.default];
|
|
|
|
exports.default = Scroll;
|
|
|
|
/***/ }),
|
|
/* 23 */
|
|
/***/ (function(module, exports, __nested_webpack_require_157111__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.SHORTKEY = exports.default = undefined;
|
|
|
|
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
|
|
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _clone = __nested_webpack_require_157111__(21);
|
|
|
|
var _clone2 = _interopRequireDefault(_clone);
|
|
|
|
var _deepEqual = __nested_webpack_require_157111__(11);
|
|
|
|
var _deepEqual2 = _interopRequireDefault(_deepEqual);
|
|
|
|
var _extend = __nested_webpack_require_157111__(3);
|
|
|
|
var _extend2 = _interopRequireDefault(_extend);
|
|
|
|
var _quillDelta = __nested_webpack_require_157111__(2);
|
|
|
|
var _quillDelta2 = _interopRequireDefault(_quillDelta);
|
|
|
|
var _op = __nested_webpack_require_157111__(20);
|
|
|
|
var _op2 = _interopRequireDefault(_op);
|
|
|
|
var _parchment = __nested_webpack_require_157111__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
var _quill = __nested_webpack_require_157111__(5);
|
|
|
|
var _quill2 = _interopRequireDefault(_quill);
|
|
|
|
var _logger = __nested_webpack_require_157111__(10);
|
|
|
|
var _logger2 = _interopRequireDefault(_logger);
|
|
|
|
var _module = __nested_webpack_require_157111__(9);
|
|
|
|
var _module2 = _interopRequireDefault(_module);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var debug = (0, _logger2.default)('quill:keyboard');
|
|
|
|
var SHORTKEY = /Mac/i.test(navigator.platform) ? 'metaKey' : 'ctrlKey';
|
|
|
|
var Keyboard = function (_Module) {
|
|
_inherits(Keyboard, _Module);
|
|
|
|
_createClass(Keyboard, null, [{
|
|
key: 'match',
|
|
value: function match(evt, binding) {
|
|
binding = normalize(binding);
|
|
if (['altKey', 'ctrlKey', 'metaKey', 'shiftKey'].some(function (key) {
|
|
return !!binding[key] !== evt[key] && binding[key] !== null;
|
|
})) {
|
|
return false;
|
|
}
|
|
return binding.key === (evt.which || evt.keyCode);
|
|
}
|
|
}]);
|
|
|
|
function Keyboard(quill, options) {
|
|
_classCallCheck(this, Keyboard);
|
|
|
|
var _this = _possibleConstructorReturn(this, (Keyboard.__proto__ || Object.getPrototypeOf(Keyboard)).call(this, quill, options));
|
|
|
|
_this.bindings = {};
|
|
Object.keys(_this.options.bindings).forEach(function (name) {
|
|
if (name === 'list autofill' && quill.scroll.whitelist != null && !quill.scroll.whitelist['list']) {
|
|
return;
|
|
}
|
|
if (_this.options.bindings[name]) {
|
|
_this.addBinding(_this.options.bindings[name]);
|
|
}
|
|
});
|
|
_this.addBinding({ key: Keyboard.keys.ENTER, shiftKey: null }, handleEnter);
|
|
_this.addBinding({ key: Keyboard.keys.ENTER, metaKey: null, ctrlKey: null, altKey: null }, function () {});
|
|
if (/Firefox/i.test(navigator.userAgent)) {
|
|
// Need to handle delete and backspace for Firefox in the general case #1171
|
|
_this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: true }, handleBackspace);
|
|
_this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: true }, handleDelete);
|
|
} else {
|
|
_this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: true, prefix: /^.?$/ }, handleBackspace);
|
|
_this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: true, suffix: /^.?$/ }, handleDelete);
|
|
}
|
|
_this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: false }, handleDeleteRange);
|
|
_this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: false }, handleDeleteRange);
|
|
_this.addBinding({ key: Keyboard.keys.BACKSPACE, altKey: null, ctrlKey: null, metaKey: null, shiftKey: null }, { collapsed: true, offset: 0 }, handleBackspace);
|
|
_this.listen();
|
|
return _this;
|
|
}
|
|
|
|
_createClass(Keyboard, [{
|
|
key: 'addBinding',
|
|
value: function addBinding(key) {
|
|
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
var handler = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
|
|
var binding = normalize(key);
|
|
if (binding == null || binding.key == null) {
|
|
return debug.warn('Attempted to add invalid keyboard binding', binding);
|
|
}
|
|
if (typeof context === 'function') {
|
|
context = { handler: context };
|
|
}
|
|
if (typeof handler === 'function') {
|
|
handler = { handler: handler };
|
|
}
|
|
binding = (0, _extend2.default)(binding, context, handler);
|
|
this.bindings[binding.key] = this.bindings[binding.key] || [];
|
|
this.bindings[binding.key].push(binding);
|
|
}
|
|
}, {
|
|
key: 'listen',
|
|
value: function listen() {
|
|
var _this2 = this;
|
|
|
|
this.quill.root.addEventListener('keydown', function (evt) {
|
|
if (evt.defaultPrevented) return;
|
|
var which = evt.which || evt.keyCode;
|
|
var bindings = (_this2.bindings[which] || []).filter(function (binding) {
|
|
return Keyboard.match(evt, binding);
|
|
});
|
|
if (bindings.length === 0) return;
|
|
var range = _this2.quill.getSelection();
|
|
if (range == null || !_this2.quill.hasFocus()) return;
|
|
|
|
var _quill$getLine = _this2.quill.getLine(range.index),
|
|
_quill$getLine2 = _slicedToArray(_quill$getLine, 2),
|
|
line = _quill$getLine2[0],
|
|
offset = _quill$getLine2[1];
|
|
|
|
var _quill$getLeaf = _this2.quill.getLeaf(range.index),
|
|
_quill$getLeaf2 = _slicedToArray(_quill$getLeaf, 2),
|
|
leafStart = _quill$getLeaf2[0],
|
|
offsetStart = _quill$getLeaf2[1];
|
|
|
|
var _ref = range.length === 0 ? [leafStart, offsetStart] : _this2.quill.getLeaf(range.index + range.length),
|
|
_ref2 = _slicedToArray(_ref, 2),
|
|
leafEnd = _ref2[0],
|
|
offsetEnd = _ref2[1];
|
|
|
|
var prefixText = leafStart instanceof _parchment2.default.Text ? leafStart.value().slice(0, offsetStart) : '';
|
|
var suffixText = leafEnd instanceof _parchment2.default.Text ? leafEnd.value().slice(offsetEnd) : '';
|
|
var curContext = {
|
|
collapsed: range.length === 0,
|
|
empty: range.length === 0 && line.length() <= 1,
|
|
format: _this2.quill.getFormat(range),
|
|
offset: offset,
|
|
prefix: prefixText,
|
|
suffix: suffixText
|
|
};
|
|
var prevented = bindings.some(function (binding) {
|
|
if (binding.collapsed != null && binding.collapsed !== curContext.collapsed) return false;
|
|
if (binding.empty != null && binding.empty !== curContext.empty) return false;
|
|
if (binding.offset != null && binding.offset !== curContext.offset) return false;
|
|
if (Array.isArray(binding.format)) {
|
|
// any format is present
|
|
if (binding.format.every(function (name) {
|
|
return curContext.format[name] == null;
|
|
})) {
|
|
return false;
|
|
}
|
|
} else if (_typeof(binding.format) === 'object') {
|
|
// all formats must match
|
|
if (!Object.keys(binding.format).every(function (name) {
|
|
if (binding.format[name] === true) return curContext.format[name] != null;
|
|
if (binding.format[name] === false) return curContext.format[name] == null;
|
|
return (0, _deepEqual2.default)(binding.format[name], curContext.format[name]);
|
|
})) {
|
|
return false;
|
|
}
|
|
}
|
|
if (binding.prefix != null && !binding.prefix.test(curContext.prefix)) return false;
|
|
if (binding.suffix != null && !binding.suffix.test(curContext.suffix)) return false;
|
|
return binding.handler.call(_this2, range, curContext) !== true;
|
|
});
|
|
if (prevented) {
|
|
evt.preventDefault();
|
|
}
|
|
});
|
|
}
|
|
}]);
|
|
|
|
return Keyboard;
|
|
}(_module2.default);
|
|
|
|
Keyboard.keys = {
|
|
BACKSPACE: 8,
|
|
TAB: 9,
|
|
ENTER: 13,
|
|
ESCAPE: 27,
|
|
LEFT: 37,
|
|
UP: 38,
|
|
RIGHT: 39,
|
|
DOWN: 40,
|
|
DELETE: 46
|
|
};
|
|
|
|
Keyboard.DEFAULTS = {
|
|
bindings: {
|
|
'bold': makeFormatHandler('bold'),
|
|
'italic': makeFormatHandler('italic'),
|
|
'underline': makeFormatHandler('underline'),
|
|
'indent': {
|
|
// highlight tab or tab at beginning of list, indent or blockquote
|
|
key: Keyboard.keys.TAB,
|
|
format: ['blockquote', 'indent', 'list'],
|
|
handler: function handler(range, context) {
|
|
if (context.collapsed && context.offset !== 0) return true;
|
|
this.quill.format('indent', '+1', _quill2.default.sources.USER);
|
|
}
|
|
},
|
|
'outdent': {
|
|
key: Keyboard.keys.TAB,
|
|
shiftKey: true,
|
|
format: ['blockquote', 'indent', 'list'],
|
|
// highlight tab or tab at beginning of list, indent or blockquote
|
|
handler: function handler(range, context) {
|
|
if (context.collapsed && context.offset !== 0) return true;
|
|
this.quill.format('indent', '-1', _quill2.default.sources.USER);
|
|
}
|
|
},
|
|
'outdent backspace': {
|
|
key: Keyboard.keys.BACKSPACE,
|
|
collapsed: true,
|
|
shiftKey: null,
|
|
metaKey: null,
|
|
ctrlKey: null,
|
|
altKey: null,
|
|
format: ['indent', 'list'],
|
|
offset: 0,
|
|
handler: function handler(range, context) {
|
|
if (context.format.indent != null) {
|
|
this.quill.format('indent', '-1', _quill2.default.sources.USER);
|
|
} else if (context.format.list != null) {
|
|
this.quill.format('list', false, _quill2.default.sources.USER);
|
|
}
|
|
}
|
|
},
|
|
'indent code-block': makeCodeBlockHandler(true),
|
|
'outdent code-block': makeCodeBlockHandler(false),
|
|
'remove tab': {
|
|
key: Keyboard.keys.TAB,
|
|
shiftKey: true,
|
|
collapsed: true,
|
|
prefix: /\t$/,
|
|
handler: function handler(range) {
|
|
this.quill.deleteText(range.index - 1, 1, _quill2.default.sources.USER);
|
|
}
|
|
},
|
|
'tab': {
|
|
key: Keyboard.keys.TAB,
|
|
handler: function handler(range) {
|
|
this.quill.history.cutoff();
|
|
var delta = new _quillDelta2.default().retain(range.index).delete(range.length).insert('\t');
|
|
this.quill.updateContents(delta, _quill2.default.sources.USER);
|
|
this.quill.history.cutoff();
|
|
this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
|
|
}
|
|
},
|
|
'list empty enter': {
|
|
key: Keyboard.keys.ENTER,
|
|
collapsed: true,
|
|
format: ['list'],
|
|
empty: true,
|
|
handler: function handler(range, context) {
|
|
this.quill.format('list', false, _quill2.default.sources.USER);
|
|
if (context.format.indent) {
|
|
this.quill.format('indent', false, _quill2.default.sources.USER);
|
|
}
|
|
}
|
|
},
|
|
'checklist enter': {
|
|
key: Keyboard.keys.ENTER,
|
|
collapsed: true,
|
|
format: { list: 'checked' },
|
|
handler: function handler(range) {
|
|
var _quill$getLine3 = this.quill.getLine(range.index),
|
|
_quill$getLine4 = _slicedToArray(_quill$getLine3, 2),
|
|
line = _quill$getLine4[0],
|
|
offset = _quill$getLine4[1];
|
|
|
|
var formats = (0, _extend2.default)({}, line.formats(), { list: 'checked' });
|
|
var delta = new _quillDelta2.default().retain(range.index).insert('\n', formats).retain(line.length() - offset - 1).retain(1, { list: 'unchecked' });
|
|
this.quill.updateContents(delta, _quill2.default.sources.USER);
|
|
this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
|
|
this.quill.scrollIntoView();
|
|
}
|
|
},
|
|
'header enter': {
|
|
key: Keyboard.keys.ENTER,
|
|
collapsed: true,
|
|
format: ['header'],
|
|
suffix: /^$/,
|
|
handler: function handler(range, context) {
|
|
var _quill$getLine5 = this.quill.getLine(range.index),
|
|
_quill$getLine6 = _slicedToArray(_quill$getLine5, 2),
|
|
line = _quill$getLine6[0],
|
|
offset = _quill$getLine6[1];
|
|
|
|
var delta = new _quillDelta2.default().retain(range.index).insert('\n', context.format).retain(line.length() - offset - 1).retain(1, { header: null });
|
|
this.quill.updateContents(delta, _quill2.default.sources.USER);
|
|
this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
|
|
this.quill.scrollIntoView();
|
|
}
|
|
},
|
|
'list autofill': {
|
|
key: ' ',
|
|
collapsed: true,
|
|
format: { list: false },
|
|
prefix: /^\s*?(\d+\.|-|\*|\[ ?\]|\[x\])$/,
|
|
handler: function handler(range, context) {
|
|
var length = context.prefix.length;
|
|
|
|
var _quill$getLine7 = this.quill.getLine(range.index),
|
|
_quill$getLine8 = _slicedToArray(_quill$getLine7, 2),
|
|
line = _quill$getLine8[0],
|
|
offset = _quill$getLine8[1];
|
|
|
|
if (offset > length) return true;
|
|
var value = void 0;
|
|
switch (context.prefix.trim()) {
|
|
case '[]':case '[ ]':
|
|
value = 'unchecked';
|
|
break;
|
|
case '[x]':
|
|
value = 'checked';
|
|
break;
|
|
case '-':case '*':
|
|
value = 'bullet';
|
|
break;
|
|
default:
|
|
value = 'ordered';
|
|
}
|
|
this.quill.insertText(range.index, ' ', _quill2.default.sources.USER);
|
|
this.quill.history.cutoff();
|
|
var delta = new _quillDelta2.default().retain(range.index - offset).delete(length + 1).retain(line.length() - 2 - offset).retain(1, { list: value });
|
|
this.quill.updateContents(delta, _quill2.default.sources.USER);
|
|
this.quill.history.cutoff();
|
|
this.quill.setSelection(range.index - length, _quill2.default.sources.SILENT);
|
|
}
|
|
},
|
|
'code exit': {
|
|
key: Keyboard.keys.ENTER,
|
|
collapsed: true,
|
|
format: ['code-block'],
|
|
prefix: /\n\n$/,
|
|
suffix: /^\s+$/,
|
|
handler: function handler(range) {
|
|
var _quill$getLine9 = this.quill.getLine(range.index),
|
|
_quill$getLine10 = _slicedToArray(_quill$getLine9, 2),
|
|
line = _quill$getLine10[0],
|
|
offset = _quill$getLine10[1];
|
|
|
|
var delta = new _quillDelta2.default().retain(range.index + line.length() - offset - 2).retain(1, { 'code-block': null }).delete(1);
|
|
this.quill.updateContents(delta, _quill2.default.sources.USER);
|
|
}
|
|
},
|
|
'embed left': makeEmbedArrowHandler(Keyboard.keys.LEFT, false),
|
|
'embed left shift': makeEmbedArrowHandler(Keyboard.keys.LEFT, true),
|
|
'embed right': makeEmbedArrowHandler(Keyboard.keys.RIGHT, false),
|
|
'embed right shift': makeEmbedArrowHandler(Keyboard.keys.RIGHT, true)
|
|
}
|
|
};
|
|
|
|
function makeEmbedArrowHandler(key, shiftKey) {
|
|
var _ref3;
|
|
|
|
var where = key === Keyboard.keys.LEFT ? 'prefix' : 'suffix';
|
|
return _ref3 = {
|
|
key: key,
|
|
shiftKey: shiftKey,
|
|
altKey: null
|
|
}, _defineProperty(_ref3, where, /^$/), _defineProperty(_ref3, 'handler', function handler(range) {
|
|
var index = range.index;
|
|
if (key === Keyboard.keys.RIGHT) {
|
|
index += range.length + 1;
|
|
}
|
|
|
|
var _quill$getLeaf3 = this.quill.getLeaf(index),
|
|
_quill$getLeaf4 = _slicedToArray(_quill$getLeaf3, 1),
|
|
leaf = _quill$getLeaf4[0];
|
|
|
|
if (!(leaf instanceof _parchment2.default.Embed)) return true;
|
|
if (key === Keyboard.keys.LEFT) {
|
|
if (shiftKey) {
|
|
this.quill.setSelection(range.index - 1, range.length + 1, _quill2.default.sources.USER);
|
|
} else {
|
|
this.quill.setSelection(range.index - 1, _quill2.default.sources.USER);
|
|
}
|
|
} else {
|
|
if (shiftKey) {
|
|
this.quill.setSelection(range.index, range.length + 1, _quill2.default.sources.USER);
|
|
} else {
|
|
this.quill.setSelection(range.index + range.length + 1, _quill2.default.sources.USER);
|
|
}
|
|
}
|
|
return false;
|
|
}), _ref3;
|
|
}
|
|
|
|
function handleBackspace(range, context) {
|
|
if (range.index === 0 || this.quill.getLength() <= 1) return;
|
|
|
|
var _quill$getLine11 = this.quill.getLine(range.index),
|
|
_quill$getLine12 = _slicedToArray(_quill$getLine11, 1),
|
|
line = _quill$getLine12[0];
|
|
|
|
var formats = {};
|
|
if (context.offset === 0) {
|
|
var _quill$getLine13 = this.quill.getLine(range.index - 1),
|
|
_quill$getLine14 = _slicedToArray(_quill$getLine13, 1),
|
|
prev = _quill$getLine14[0];
|
|
|
|
if (prev != null && prev.length() > 1) {
|
|
var curFormats = line.formats();
|
|
var prevFormats = this.quill.getFormat(range.index - 1, 1);
|
|
formats = _op2.default.attributes.diff(curFormats, prevFormats) || {};
|
|
}
|
|
}
|
|
// Check for astral symbols
|
|
var length = /[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(context.prefix) ? 2 : 1;
|
|
this.quill.deleteText(range.index - length, length, _quill2.default.sources.USER);
|
|
if (Object.keys(formats).length > 0) {
|
|
this.quill.formatLine(range.index - length, length, formats, _quill2.default.sources.USER);
|
|
}
|
|
this.quill.focus();
|
|
}
|
|
|
|
function handleDelete(range, context) {
|
|
// Check for astral symbols
|
|
var length = /^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(context.suffix) ? 2 : 1;
|
|
if (range.index >= this.quill.getLength() - length) return;
|
|
var formats = {},
|
|
nextLength = 0;
|
|
|
|
var _quill$getLine15 = this.quill.getLine(range.index),
|
|
_quill$getLine16 = _slicedToArray(_quill$getLine15, 1),
|
|
line = _quill$getLine16[0];
|
|
|
|
if (context.offset >= line.length() - 1) {
|
|
var _quill$getLine17 = this.quill.getLine(range.index + 1),
|
|
_quill$getLine18 = _slicedToArray(_quill$getLine17, 1),
|
|
next = _quill$getLine18[0];
|
|
|
|
if (next) {
|
|
var curFormats = line.formats();
|
|
var nextFormats = this.quill.getFormat(range.index, 1);
|
|
formats = _op2.default.attributes.diff(curFormats, nextFormats) || {};
|
|
nextLength = next.length();
|
|
}
|
|
}
|
|
this.quill.deleteText(range.index, length, _quill2.default.sources.USER);
|
|
if (Object.keys(formats).length > 0) {
|
|
this.quill.formatLine(range.index + nextLength - 1, length, formats, _quill2.default.sources.USER);
|
|
}
|
|
}
|
|
|
|
function handleDeleteRange(range) {
|
|
var lines = this.quill.getLines(range);
|
|
var formats = {};
|
|
if (lines.length > 1) {
|
|
var firstFormats = lines[0].formats();
|
|
var lastFormats = lines[lines.length - 1].formats();
|
|
formats = _op2.default.attributes.diff(lastFormats, firstFormats) || {};
|
|
}
|
|
this.quill.deleteText(range, _quill2.default.sources.USER);
|
|
if (Object.keys(formats).length > 0) {
|
|
this.quill.formatLine(range.index, 1, formats, _quill2.default.sources.USER);
|
|
}
|
|
this.quill.setSelection(range.index, _quill2.default.sources.SILENT);
|
|
this.quill.focus();
|
|
}
|
|
|
|
function handleEnter(range, context) {
|
|
var _this3 = this;
|
|
|
|
if (range.length > 0) {
|
|
this.quill.scroll.deleteAt(range.index, range.length); // So we do not trigger text-change
|
|
}
|
|
var lineFormats = Object.keys(context.format).reduce(function (lineFormats, format) {
|
|
if (_parchment2.default.query(format, _parchment2.default.Scope.BLOCK) && !Array.isArray(context.format[format])) {
|
|
lineFormats[format] = context.format[format];
|
|
}
|
|
return lineFormats;
|
|
}, {});
|
|
this.quill.insertText(range.index, '\n', lineFormats, _quill2.default.sources.USER);
|
|
// Earlier scroll.deleteAt might have messed up our selection,
|
|
// so insertText's built in selection preservation is not reliable
|
|
this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
|
|
this.quill.focus();
|
|
Object.keys(context.format).forEach(function (name) {
|
|
if (lineFormats[name] != null) return;
|
|
if (Array.isArray(context.format[name])) return;
|
|
if (name === 'link') return;
|
|
_this3.quill.format(name, context.format[name], _quill2.default.sources.USER);
|
|
});
|
|
}
|
|
|
|
function makeCodeBlockHandler(indent) {
|
|
return {
|
|
key: Keyboard.keys.TAB,
|
|
shiftKey: !indent,
|
|
format: { 'code-block': true },
|
|
handler: function handler(range) {
|
|
var CodeBlock = _parchment2.default.query('code-block');
|
|
var index = range.index,
|
|
length = range.length;
|
|
|
|
var _quill$scroll$descend = this.quill.scroll.descendant(CodeBlock, index),
|
|
_quill$scroll$descend2 = _slicedToArray(_quill$scroll$descend, 2),
|
|
block = _quill$scroll$descend2[0],
|
|
offset = _quill$scroll$descend2[1];
|
|
|
|
if (block == null) return;
|
|
var scrollIndex = this.quill.getIndex(block);
|
|
var start = block.newlineIndex(offset, true) + 1;
|
|
var end = block.newlineIndex(scrollIndex + offset + length);
|
|
var lines = block.domNode.textContent.slice(start, end).split('\n');
|
|
offset = 0;
|
|
lines.forEach(function (line, i) {
|
|
if (indent) {
|
|
block.insertAt(start + offset, CodeBlock.TAB);
|
|
offset += CodeBlock.TAB.length;
|
|
if (i === 0) {
|
|
index += CodeBlock.TAB.length;
|
|
} else {
|
|
length += CodeBlock.TAB.length;
|
|
}
|
|
} else if (line.startsWith(CodeBlock.TAB)) {
|
|
block.deleteAt(start + offset, CodeBlock.TAB.length);
|
|
offset -= CodeBlock.TAB.length;
|
|
if (i === 0) {
|
|
index -= CodeBlock.TAB.length;
|
|
} else {
|
|
length -= CodeBlock.TAB.length;
|
|
}
|
|
}
|
|
offset += line.length + 1;
|
|
});
|
|
this.quill.update(_quill2.default.sources.USER);
|
|
this.quill.setSelection(index, length, _quill2.default.sources.SILENT);
|
|
}
|
|
};
|
|
}
|
|
|
|
function makeFormatHandler(format) {
|
|
return {
|
|
key: format[0].toUpperCase(),
|
|
shortKey: true,
|
|
handler: function handler(range, context) {
|
|
this.quill.format(format, !context.format[format], _quill2.default.sources.USER);
|
|
}
|
|
};
|
|
}
|
|
|
|
function normalize(binding) {
|
|
if (typeof binding === 'string' || typeof binding === 'number') {
|
|
return normalize({ key: binding });
|
|
}
|
|
if ((typeof binding === 'undefined' ? 'undefined' : _typeof(binding)) === 'object') {
|
|
binding = (0, _clone2.default)(binding, false);
|
|
}
|
|
if (typeof binding.key === 'string') {
|
|
if (Keyboard.keys[binding.key.toUpperCase()] != null) {
|
|
binding.key = Keyboard.keys[binding.key.toUpperCase()];
|
|
} else if (binding.key.length === 1) {
|
|
binding.key = binding.key.toUpperCase().charCodeAt(0);
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
if (binding.shortKey) {
|
|
binding[SHORTKEY] = binding.shortKey;
|
|
delete binding.shortKey;
|
|
}
|
|
return binding;
|
|
}
|
|
|
|
exports.default = Keyboard;
|
|
exports.SHORTKEY = SHORTKEY;
|
|
|
|
/***/ }),
|
|
/* 24 */
|
|
/***/ (function(module, exports, __nested_webpack_require_181454__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _parchment = __nested_webpack_require_181454__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
var _text = __nested_webpack_require_181454__(7);
|
|
|
|
var _text2 = _interopRequireDefault(_text);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var Cursor = function (_Parchment$Embed) {
|
|
_inherits(Cursor, _Parchment$Embed);
|
|
|
|
_createClass(Cursor, null, [{
|
|
key: 'value',
|
|
value: function value() {
|
|
return undefined;
|
|
}
|
|
}]);
|
|
|
|
function Cursor(domNode, selection) {
|
|
_classCallCheck(this, Cursor);
|
|
|
|
var _this = _possibleConstructorReturn(this, (Cursor.__proto__ || Object.getPrototypeOf(Cursor)).call(this, domNode));
|
|
|
|
_this.selection = selection;
|
|
_this.textNode = document.createTextNode(Cursor.CONTENTS);
|
|
_this.domNode.appendChild(_this.textNode);
|
|
_this._length = 0;
|
|
return _this;
|
|
}
|
|
|
|
_createClass(Cursor, [{
|
|
key: 'detach',
|
|
value: function detach() {
|
|
// super.detach() will also clear domNode.__blot
|
|
if (this.parent != null) this.parent.removeChild(this);
|
|
}
|
|
}, {
|
|
key: 'format',
|
|
value: function format(name, value) {
|
|
if (this._length !== 0) {
|
|
return _get(Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), 'format', this).call(this, name, value);
|
|
}
|
|
var target = this,
|
|
index = 0;
|
|
while (target != null && target.statics.scope !== _parchment2.default.Scope.BLOCK_BLOT) {
|
|
index += target.offset(target.parent);
|
|
target = target.parent;
|
|
}
|
|
if (target != null) {
|
|
this._length = Cursor.CONTENTS.length;
|
|
target.optimize();
|
|
target.formatAt(index, Cursor.CONTENTS.length, name, value);
|
|
this._length = 0;
|
|
}
|
|
}
|
|
}, {
|
|
key: 'index',
|
|
value: function index(node, offset) {
|
|
if (node === this.textNode) return 0;
|
|
return _get(Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), 'index', this).call(this, node, offset);
|
|
}
|
|
}, {
|
|
key: 'length',
|
|
value: function length() {
|
|
return this._length;
|
|
}
|
|
}, {
|
|
key: 'position',
|
|
value: function position() {
|
|
return [this.textNode, this.textNode.data.length];
|
|
}
|
|
}, {
|
|
key: 'remove',
|
|
value: function remove() {
|
|
_get(Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), 'remove', this).call(this);
|
|
this.parent = null;
|
|
}
|
|
}, {
|
|
key: 'restore',
|
|
value: function restore() {
|
|
if (this.selection.composing || this.parent == null) return;
|
|
var textNode = this.textNode;
|
|
var range = this.selection.getNativeRange();
|
|
var restoreText = void 0,
|
|
start = void 0,
|
|
end = void 0;
|
|
if (range != null && range.start.node === textNode && range.end.node === textNode) {
|
|
var _ref = [textNode, range.start.offset, range.end.offset];
|
|
restoreText = _ref[0];
|
|
start = _ref[1];
|
|
end = _ref[2];
|
|
}
|
|
// Link format will insert text outside of anchor tag
|
|
while (this.domNode.lastChild != null && this.domNode.lastChild !== this.textNode) {
|
|
this.domNode.parentNode.insertBefore(this.domNode.lastChild, this.domNode);
|
|
}
|
|
if (this.textNode.data !== Cursor.CONTENTS) {
|
|
var text = this.textNode.data.split(Cursor.CONTENTS).join('');
|
|
if (this.next instanceof _text2.default) {
|
|
restoreText = this.next.domNode;
|
|
this.next.insertAt(0, text);
|
|
this.textNode.data = Cursor.CONTENTS;
|
|
} else {
|
|
this.textNode.data = text;
|
|
this.parent.insertBefore(_parchment2.default.create(this.textNode), this);
|
|
this.textNode = document.createTextNode(Cursor.CONTENTS);
|
|
this.domNode.appendChild(this.textNode);
|
|
}
|
|
}
|
|
this.remove();
|
|
if (start != null) {
|
|
var _map = [start, end].map(function (offset) {
|
|
return Math.max(0, Math.min(restoreText.data.length, offset - 1));
|
|
});
|
|
|
|
var _map2 = _slicedToArray(_map, 2);
|
|
|
|
start = _map2[0];
|
|
end = _map2[1];
|
|
|
|
return {
|
|
startNode: restoreText,
|
|
startOffset: start,
|
|
endNode: restoreText,
|
|
endOffset: end
|
|
};
|
|
}
|
|
}
|
|
}, {
|
|
key: 'update',
|
|
value: function update(mutations, context) {
|
|
var _this2 = this;
|
|
|
|
if (mutations.some(function (mutation) {
|
|
return mutation.type === 'characterData' && mutation.target === _this2.textNode;
|
|
})) {
|
|
var range = this.restore();
|
|
if (range) context.range = range;
|
|
}
|
|
}
|
|
}, {
|
|
key: 'value',
|
|
value: function value() {
|
|
return '';
|
|
}
|
|
}]);
|
|
|
|
return Cursor;
|
|
}(_parchment2.default.Embed);
|
|
|
|
Cursor.blotName = 'cursor';
|
|
Cursor.className = 'ql-cursor';
|
|
Cursor.tagName = 'span';
|
|
Cursor.CONTENTS = '\uFEFF'; // Zero width no break space
|
|
|
|
|
|
exports.default = Cursor;
|
|
|
|
/***/ }),
|
|
/* 25 */
|
|
/***/ (function(module, exports, __nested_webpack_require_189100__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _parchment = __nested_webpack_require_189100__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
var _block = __nested_webpack_require_189100__(4);
|
|
|
|
var _block2 = _interopRequireDefault(_block);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var Container = function (_Parchment$Container) {
|
|
_inherits(Container, _Parchment$Container);
|
|
|
|
function Container() {
|
|
_classCallCheck(this, Container);
|
|
|
|
return _possibleConstructorReturn(this, (Container.__proto__ || Object.getPrototypeOf(Container)).apply(this, arguments));
|
|
}
|
|
|
|
return Container;
|
|
}(_parchment2.default.Container);
|
|
|
|
Container.allowedChildren = [_block2.default, _block.BlockEmbed, Container];
|
|
|
|
exports.default = Container;
|
|
|
|
/***/ }),
|
|
/* 26 */
|
|
/***/ (function(module, exports, __nested_webpack_require_190886__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.ColorStyle = exports.ColorClass = exports.ColorAttributor = undefined;
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _parchment = __nested_webpack_require_190886__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var ColorAttributor = function (_Parchment$Attributor) {
|
|
_inherits(ColorAttributor, _Parchment$Attributor);
|
|
|
|
function ColorAttributor() {
|
|
_classCallCheck(this, ColorAttributor);
|
|
|
|
return _possibleConstructorReturn(this, (ColorAttributor.__proto__ || Object.getPrototypeOf(ColorAttributor)).apply(this, arguments));
|
|
}
|
|
|
|
_createClass(ColorAttributor, [{
|
|
key: 'value',
|
|
value: function value(domNode) {
|
|
var value = _get(ColorAttributor.prototype.__proto__ || Object.getPrototypeOf(ColorAttributor.prototype), 'value', this).call(this, domNode);
|
|
if (!value.startsWith('rgb(')) return value;
|
|
value = value.replace(/^[^\d]+/, '').replace(/[^\d]+$/, '');
|
|
return '#' + value.split(',').map(function (component) {
|
|
return ('00' + parseInt(component).toString(16)).slice(-2);
|
|
}).join('');
|
|
}
|
|
}]);
|
|
|
|
return ColorAttributor;
|
|
}(_parchment2.default.Attributor.Style);
|
|
|
|
var ColorClass = new _parchment2.default.Attributor.Class('color', 'ql-color', {
|
|
scope: _parchment2.default.Scope.INLINE
|
|
});
|
|
var ColorStyle = new ColorAttributor('color', 'color', {
|
|
scope: _parchment2.default.Scope.INLINE
|
|
});
|
|
|
|
exports.ColorAttributor = ColorAttributor;
|
|
exports.ColorClass = ColorClass;
|
|
exports.ColorStyle = ColorStyle;
|
|
|
|
/***/ }),
|
|
/* 27 */
|
|
/***/ (function(module, exports, __nested_webpack_require_194529__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.sanitize = exports.default = undefined;
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _inline = __nested_webpack_require_194529__(6);
|
|
|
|
var _inline2 = _interopRequireDefault(_inline);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var Link = function (_Inline) {
|
|
_inherits(Link, _Inline);
|
|
|
|
function Link() {
|
|
_classCallCheck(this, Link);
|
|
|
|
return _possibleConstructorReturn(this, (Link.__proto__ || Object.getPrototypeOf(Link)).apply(this, arguments));
|
|
}
|
|
|
|
_createClass(Link, [{
|
|
key: 'format',
|
|
value: function format(name, value) {
|
|
if (name !== this.statics.blotName || !value) return _get(Link.prototype.__proto__ || Object.getPrototypeOf(Link.prototype), 'format', this).call(this, name, value);
|
|
value = this.constructor.sanitize(value);
|
|
this.domNode.setAttribute('href', value);
|
|
}
|
|
}], [{
|
|
key: 'create',
|
|
value: function create(value) {
|
|
var node = _get(Link.__proto__ || Object.getPrototypeOf(Link), 'create', this).call(this, value);
|
|
value = this.sanitize(value);
|
|
node.setAttribute('href', value);
|
|
node.setAttribute('rel', 'noopener noreferrer');
|
|
node.setAttribute('target', '_blank');
|
|
return node;
|
|
}
|
|
}, {
|
|
key: 'formats',
|
|
value: function formats(domNode) {
|
|
return domNode.getAttribute('href');
|
|
}
|
|
}, {
|
|
key: 'sanitize',
|
|
value: function sanitize(url) {
|
|
return _sanitize(url, this.PROTOCOL_WHITELIST) ? url : this.SANITIZED_URL;
|
|
}
|
|
}]);
|
|
|
|
return Link;
|
|
}(_inline2.default);
|
|
|
|
Link.blotName = 'link';
|
|
Link.tagName = 'A';
|
|
Link.SANITIZED_URL = 'about:blank';
|
|
Link.PROTOCOL_WHITELIST = ['http', 'https', 'mailto', 'tel'];
|
|
|
|
function _sanitize(url, protocols) {
|
|
var anchor = document.createElement('a');
|
|
anchor.href = url;
|
|
var protocol = anchor.href.slice(0, anchor.href.indexOf(':'));
|
|
return protocols.indexOf(protocol) > -1;
|
|
}
|
|
|
|
exports.default = Link;
|
|
exports.sanitize = _sanitize;
|
|
|
|
/***/ }),
|
|
/* 28 */
|
|
/***/ (function(module, exports, __nested_webpack_require_198559__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _keyboard = __nested_webpack_require_198559__(23);
|
|
|
|
var _keyboard2 = _interopRequireDefault(_keyboard);
|
|
|
|
var _dropdown = __nested_webpack_require_198559__(107);
|
|
|
|
var _dropdown2 = _interopRequireDefault(_dropdown);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
var optionsCounter = 0;
|
|
|
|
function toggleAriaAttribute(element, attribute) {
|
|
element.setAttribute(attribute, !(element.getAttribute(attribute) === 'true'));
|
|
}
|
|
|
|
var Picker = function () {
|
|
function Picker(select) {
|
|
var _this = this;
|
|
|
|
_classCallCheck(this, Picker);
|
|
|
|
this.select = select;
|
|
this.container = document.createElement('span');
|
|
this.buildPicker();
|
|
this.select.style.display = 'none';
|
|
this.select.parentNode.insertBefore(this.container, this.select);
|
|
|
|
this.label.addEventListener('mousedown', function () {
|
|
_this.togglePicker();
|
|
});
|
|
this.label.addEventListener('keydown', function (event) {
|
|
switch (event.keyCode) {
|
|
// Allows the "Enter" key to open the picker
|
|
case _keyboard2.default.keys.ENTER:
|
|
_this.togglePicker();
|
|
break;
|
|
|
|
// Allows the "Escape" key to close the picker
|
|
case _keyboard2.default.keys.ESCAPE:
|
|
_this.escape();
|
|
event.preventDefault();
|
|
break;
|
|
default:
|
|
}
|
|
});
|
|
this.select.addEventListener('change', this.update.bind(this));
|
|
}
|
|
|
|
_createClass(Picker, [{
|
|
key: 'togglePicker',
|
|
value: function togglePicker() {
|
|
this.container.classList.toggle('ql-expanded');
|
|
// Toggle aria-expanded and aria-hidden to make the picker accessible
|
|
toggleAriaAttribute(this.label, 'aria-expanded');
|
|
toggleAriaAttribute(this.options, 'aria-hidden');
|
|
}
|
|
}, {
|
|
key: 'buildItem',
|
|
value: function buildItem(option) {
|
|
var _this2 = this;
|
|
|
|
var item = document.createElement('span');
|
|
item.tabIndex = '0';
|
|
item.setAttribute('role', 'button');
|
|
|
|
item.classList.add('ql-picker-item');
|
|
if (option.hasAttribute('value')) {
|
|
item.setAttribute('data-value', option.getAttribute('value'));
|
|
}
|
|
if (option.textContent) {
|
|
item.setAttribute('data-label', option.textContent);
|
|
}
|
|
item.addEventListener('click', function () {
|
|
_this2.selectItem(item, true);
|
|
});
|
|
item.addEventListener('keydown', function (event) {
|
|
switch (event.keyCode) {
|
|
// Allows the "Enter" key to select an item
|
|
case _keyboard2.default.keys.ENTER:
|
|
_this2.selectItem(item, true);
|
|
event.preventDefault();
|
|
break;
|
|
|
|
// Allows the "Escape" key to close the picker
|
|
case _keyboard2.default.keys.ESCAPE:
|
|
_this2.escape();
|
|
event.preventDefault();
|
|
break;
|
|
default:
|
|
}
|
|
});
|
|
|
|
return item;
|
|
}
|
|
}, {
|
|
key: 'buildLabel',
|
|
value: function buildLabel() {
|
|
var label = document.createElement('span');
|
|
label.classList.add('ql-picker-label');
|
|
label.innerHTML = _dropdown2.default;
|
|
label.tabIndex = '0';
|
|
label.setAttribute('role', 'button');
|
|
label.setAttribute('aria-expanded', 'false');
|
|
this.container.appendChild(label);
|
|
return label;
|
|
}
|
|
}, {
|
|
key: 'buildOptions',
|
|
value: function buildOptions() {
|
|
var _this3 = this;
|
|
|
|
var options = document.createElement('span');
|
|
options.classList.add('ql-picker-options');
|
|
|
|
// Don't want screen readers to read this until options are visible
|
|
options.setAttribute('aria-hidden', 'true');
|
|
options.tabIndex = '-1';
|
|
|
|
// Need a unique id for aria-controls
|
|
options.id = 'ql-picker-options-' + optionsCounter;
|
|
optionsCounter += 1;
|
|
this.label.setAttribute('aria-controls', options.id);
|
|
|
|
this.options = options;
|
|
|
|
[].slice.call(this.select.options).forEach(function (option) {
|
|
var item = _this3.buildItem(option);
|
|
options.appendChild(item);
|
|
if (option.selected === true) {
|
|
_this3.selectItem(item);
|
|
}
|
|
});
|
|
this.container.appendChild(options);
|
|
}
|
|
}, {
|
|
key: 'buildPicker',
|
|
value: function buildPicker() {
|
|
var _this4 = this;
|
|
|
|
[].slice.call(this.select.attributes).forEach(function (item) {
|
|
_this4.container.setAttribute(item.name, item.value);
|
|
});
|
|
this.container.classList.add('ql-picker');
|
|
this.label = this.buildLabel();
|
|
this.buildOptions();
|
|
}
|
|
}, {
|
|
key: 'escape',
|
|
value: function escape() {
|
|
var _this5 = this;
|
|
|
|
// Close menu and return focus to trigger label
|
|
this.close();
|
|
// Need setTimeout for accessibility to ensure that the browser executes
|
|
// focus on the next process thread and after any DOM content changes
|
|
setTimeout(function () {
|
|
return _this5.label.focus();
|
|
}, 1);
|
|
}
|
|
}, {
|
|
key: 'close',
|
|
value: function close() {
|
|
this.container.classList.remove('ql-expanded');
|
|
this.label.setAttribute('aria-expanded', 'false');
|
|
this.options.setAttribute('aria-hidden', 'true');
|
|
}
|
|
}, {
|
|
key: 'selectItem',
|
|
value: function selectItem(item) {
|
|
var trigger = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
|
|
var selected = this.container.querySelector('.ql-selected');
|
|
if (item === selected) return;
|
|
if (selected != null) {
|
|
selected.classList.remove('ql-selected');
|
|
}
|
|
if (item == null) return;
|
|
item.classList.add('ql-selected');
|
|
this.select.selectedIndex = [].indexOf.call(item.parentNode.children, item);
|
|
if (item.hasAttribute('data-value')) {
|
|
this.label.setAttribute('data-value', item.getAttribute('data-value'));
|
|
} else {
|
|
this.label.removeAttribute('data-value');
|
|
}
|
|
if (item.hasAttribute('data-label')) {
|
|
this.label.setAttribute('data-label', item.getAttribute('data-label'));
|
|
} else {
|
|
this.label.removeAttribute('data-label');
|
|
}
|
|
if (trigger) {
|
|
if (typeof Event === 'function') {
|
|
this.select.dispatchEvent(new Event('change'));
|
|
} else if ((typeof Event === 'undefined' ? 'undefined' : _typeof(Event)) === 'object') {
|
|
// IE11
|
|
var event = document.createEvent('Event');
|
|
event.initEvent('change', true, true);
|
|
this.select.dispatchEvent(event);
|
|
}
|
|
this.close();
|
|
}
|
|
}
|
|
}, {
|
|
key: 'update',
|
|
value: function update() {
|
|
var option = void 0;
|
|
if (this.select.selectedIndex > -1) {
|
|
var item = this.container.querySelector('.ql-picker-options').children[this.select.selectedIndex];
|
|
option = this.select.options[this.select.selectedIndex];
|
|
this.selectItem(item);
|
|
} else {
|
|
this.selectItem(null);
|
|
}
|
|
var isActive = option != null && option !== this.select.querySelector('option[selected]');
|
|
this.label.classList.toggle('ql-active', isActive);
|
|
}
|
|
}]);
|
|
|
|
return Picker;
|
|
}();
|
|
|
|
exports.default = Picker;
|
|
|
|
/***/ }),
|
|
/* 29 */
|
|
/***/ (function(module, exports, __nested_webpack_require_206753__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _parchment = __nested_webpack_require_206753__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
var _quill = __nested_webpack_require_206753__(5);
|
|
|
|
var _quill2 = _interopRequireDefault(_quill);
|
|
|
|
var _block = __nested_webpack_require_206753__(4);
|
|
|
|
var _block2 = _interopRequireDefault(_block);
|
|
|
|
var _break = __nested_webpack_require_206753__(16);
|
|
|
|
var _break2 = _interopRequireDefault(_break);
|
|
|
|
var _container = __nested_webpack_require_206753__(25);
|
|
|
|
var _container2 = _interopRequireDefault(_container);
|
|
|
|
var _cursor = __nested_webpack_require_206753__(24);
|
|
|
|
var _cursor2 = _interopRequireDefault(_cursor);
|
|
|
|
var _embed = __nested_webpack_require_206753__(35);
|
|
|
|
var _embed2 = _interopRequireDefault(_embed);
|
|
|
|
var _inline = __nested_webpack_require_206753__(6);
|
|
|
|
var _inline2 = _interopRequireDefault(_inline);
|
|
|
|
var _scroll = __nested_webpack_require_206753__(22);
|
|
|
|
var _scroll2 = _interopRequireDefault(_scroll);
|
|
|
|
var _text = __nested_webpack_require_206753__(7);
|
|
|
|
var _text2 = _interopRequireDefault(_text);
|
|
|
|
var _clipboard = __nested_webpack_require_206753__(55);
|
|
|
|
var _clipboard2 = _interopRequireDefault(_clipboard);
|
|
|
|
var _history = __nested_webpack_require_206753__(42);
|
|
|
|
var _history2 = _interopRequireDefault(_history);
|
|
|
|
var _keyboard = __nested_webpack_require_206753__(23);
|
|
|
|
var _keyboard2 = _interopRequireDefault(_keyboard);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
_quill2.default.register({
|
|
'blots/block': _block2.default,
|
|
'blots/block/embed': _block.BlockEmbed,
|
|
'blots/break': _break2.default,
|
|
'blots/container': _container2.default,
|
|
'blots/cursor': _cursor2.default,
|
|
'blots/embed': _embed2.default,
|
|
'blots/inline': _inline2.default,
|
|
'blots/scroll': _scroll2.default,
|
|
'blots/text': _text2.default,
|
|
|
|
'modules/clipboard': _clipboard2.default,
|
|
'modules/history': _history2.default,
|
|
'modules/keyboard': _keyboard2.default
|
|
});
|
|
|
|
_parchment2.default.register(_block2.default, _break2.default, _cursor2.default, _inline2.default, _scroll2.default, _text2.default);
|
|
|
|
exports.default = _quill2.default;
|
|
|
|
/***/ }),
|
|
/* 30 */
|
|
/***/ (function(module, exports, __nested_webpack_require_208833__) {
|
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var Registry = __nested_webpack_require_208833__(1);
|
|
var ShadowBlot = /** @class */ (function () {
|
|
function ShadowBlot(domNode) {
|
|
this.domNode = domNode;
|
|
// @ts-ignore
|
|
this.domNode[Registry.DATA_KEY] = { blot: this };
|
|
}
|
|
Object.defineProperty(ShadowBlot.prototype, "statics", {
|
|
// Hack for accessing inherited static methods
|
|
get: function () {
|
|
return this.constructor;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
ShadowBlot.create = function (value) {
|
|
if (this.tagName == null) {
|
|
throw new Registry.ParchmentError('Blot definition missing tagName');
|
|
}
|
|
var node;
|
|
if (Array.isArray(this.tagName)) {
|
|
if (typeof value === 'string') {
|
|
value = value.toUpperCase();
|
|
if (parseInt(value).toString() === value) {
|
|
value = parseInt(value);
|
|
}
|
|
}
|
|
if (typeof value === 'number') {
|
|
node = document.createElement(this.tagName[value - 1]);
|
|
}
|
|
else if (this.tagName.indexOf(value) > -1) {
|
|
node = document.createElement(value);
|
|
}
|
|
else {
|
|
node = document.createElement(this.tagName[0]);
|
|
}
|
|
}
|
|
else {
|
|
node = document.createElement(this.tagName);
|
|
}
|
|
if (this.className) {
|
|
node.classList.add(this.className);
|
|
}
|
|
return node;
|
|
};
|
|
ShadowBlot.prototype.attach = function () {
|
|
if (this.parent != null) {
|
|
this.scroll = this.parent.scroll;
|
|
}
|
|
};
|
|
ShadowBlot.prototype.clone = function () {
|
|
var domNode = this.domNode.cloneNode(false);
|
|
return Registry.create(domNode);
|
|
};
|
|
ShadowBlot.prototype.detach = function () {
|
|
if (this.parent != null)
|
|
this.parent.removeChild(this);
|
|
// @ts-ignore
|
|
delete this.domNode[Registry.DATA_KEY];
|
|
};
|
|
ShadowBlot.prototype.deleteAt = function (index, length) {
|
|
var blot = this.isolate(index, length);
|
|
blot.remove();
|
|
};
|
|
ShadowBlot.prototype.formatAt = function (index, length, name, value) {
|
|
var blot = this.isolate(index, length);
|
|
if (Registry.query(name, Registry.Scope.BLOT) != null && value) {
|
|
blot.wrap(name, value);
|
|
}
|
|
else if (Registry.query(name, Registry.Scope.ATTRIBUTE) != null) {
|
|
var parent = Registry.create(this.statics.scope);
|
|
blot.wrap(parent);
|
|
parent.format(name, value);
|
|
}
|
|
};
|
|
ShadowBlot.prototype.insertAt = function (index, value, def) {
|
|
var blot = def == null ? Registry.create('text', value) : Registry.create(value, def);
|
|
var ref = this.split(index);
|
|
this.parent.insertBefore(blot, ref);
|
|
};
|
|
ShadowBlot.prototype.insertInto = function (parentBlot, refBlot) {
|
|
if (refBlot === void 0) { refBlot = null; }
|
|
if (this.parent != null) {
|
|
this.parent.children.remove(this);
|
|
}
|
|
var refDomNode = null;
|
|
parentBlot.children.insertBefore(this, refBlot);
|
|
if (refBlot != null) {
|
|
refDomNode = refBlot.domNode;
|
|
}
|
|
if (this.domNode.parentNode != parentBlot.domNode ||
|
|
this.domNode.nextSibling != refDomNode) {
|
|
parentBlot.domNode.insertBefore(this.domNode, refDomNode);
|
|
}
|
|
this.parent = parentBlot;
|
|
this.attach();
|
|
};
|
|
ShadowBlot.prototype.isolate = function (index, length) {
|
|
var target = this.split(index);
|
|
target.split(length);
|
|
return target;
|
|
};
|
|
ShadowBlot.prototype.length = function () {
|
|
return 1;
|
|
};
|
|
ShadowBlot.prototype.offset = function (root) {
|
|
if (root === void 0) { root = this.parent; }
|
|
if (this.parent == null || this == root)
|
|
return 0;
|
|
return this.parent.children.offset(this) + this.parent.offset(root);
|
|
};
|
|
ShadowBlot.prototype.optimize = function (context) {
|
|
// TODO clean up once we use WeakMap
|
|
// @ts-ignore
|
|
if (this.domNode[Registry.DATA_KEY] != null) {
|
|
// @ts-ignore
|
|
delete this.domNode[Registry.DATA_KEY].mutations;
|
|
}
|
|
};
|
|
ShadowBlot.prototype.remove = function () {
|
|
if (this.domNode.parentNode != null) {
|
|
this.domNode.parentNode.removeChild(this.domNode);
|
|
}
|
|
this.detach();
|
|
};
|
|
ShadowBlot.prototype.replace = function (target) {
|
|
if (target.parent == null)
|
|
return;
|
|
target.parent.insertBefore(this, target.next);
|
|
target.remove();
|
|
};
|
|
ShadowBlot.prototype.replaceWith = function (name, value) {
|
|
var replacement = typeof name === 'string' ? Registry.create(name, value) : name;
|
|
replacement.replace(this);
|
|
return replacement;
|
|
};
|
|
ShadowBlot.prototype.split = function (index, force) {
|
|
return index === 0 ? this : this.next;
|
|
};
|
|
ShadowBlot.prototype.update = function (mutations, context) {
|
|
// Nothing to do by default
|
|
};
|
|
ShadowBlot.prototype.wrap = function (name, value) {
|
|
var wrapper = typeof name === 'string' ? Registry.create(name, value) : name;
|
|
if (this.parent != null) {
|
|
this.parent.insertBefore(wrapper, this.next);
|
|
}
|
|
wrapper.appendChild(this);
|
|
return wrapper;
|
|
};
|
|
ShadowBlot.blotName = 'abstract';
|
|
return ShadowBlot;
|
|
}());
|
|
exports.default = ShadowBlot;
|
|
|
|
|
|
/***/ }),
|
|
/* 31 */
|
|
/***/ (function(module, exports, __nested_webpack_require_214530__) {
|
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var attributor_1 = __nested_webpack_require_214530__(12);
|
|
var class_1 = __nested_webpack_require_214530__(32);
|
|
var style_1 = __nested_webpack_require_214530__(33);
|
|
var Registry = __nested_webpack_require_214530__(1);
|
|
var AttributorStore = /** @class */ (function () {
|
|
function AttributorStore(domNode) {
|
|
this.attributes = {};
|
|
this.domNode = domNode;
|
|
this.build();
|
|
}
|
|
AttributorStore.prototype.attribute = function (attribute, value) {
|
|
// verb
|
|
if (value) {
|
|
if (attribute.add(this.domNode, value)) {
|
|
if (attribute.value(this.domNode) != null) {
|
|
this.attributes[attribute.attrName] = attribute;
|
|
}
|
|
else {
|
|
delete this.attributes[attribute.attrName];
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
attribute.remove(this.domNode);
|
|
delete this.attributes[attribute.attrName];
|
|
}
|
|
};
|
|
AttributorStore.prototype.build = function () {
|
|
var _this = this;
|
|
this.attributes = {};
|
|
var attributes = attributor_1.default.keys(this.domNode);
|
|
var classes = class_1.default.keys(this.domNode);
|
|
var styles = style_1.default.keys(this.domNode);
|
|
attributes
|
|
.concat(classes)
|
|
.concat(styles)
|
|
.forEach(function (name) {
|
|
var attr = Registry.query(name, Registry.Scope.ATTRIBUTE);
|
|
if (attr instanceof attributor_1.default) {
|
|
_this.attributes[attr.attrName] = attr;
|
|
}
|
|
});
|
|
};
|
|
AttributorStore.prototype.copy = function (target) {
|
|
var _this = this;
|
|
Object.keys(this.attributes).forEach(function (key) {
|
|
var value = _this.attributes[key].value(_this.domNode);
|
|
target.format(key, value);
|
|
});
|
|
};
|
|
AttributorStore.prototype.move = function (target) {
|
|
var _this = this;
|
|
this.copy(target);
|
|
Object.keys(this.attributes).forEach(function (key) {
|
|
_this.attributes[key].remove(_this.domNode);
|
|
});
|
|
this.attributes = {};
|
|
};
|
|
AttributorStore.prototype.values = function () {
|
|
var _this = this;
|
|
return Object.keys(this.attributes).reduce(function (attributes, name) {
|
|
attributes[name] = _this.attributes[name].value(_this.domNode);
|
|
return attributes;
|
|
}, {});
|
|
};
|
|
return AttributorStore;
|
|
}());
|
|
exports.default = AttributorStore;
|
|
|
|
|
|
/***/ }),
|
|
/* 32 */
|
|
/***/ (function(module, exports, __nested_webpack_require_217128__) {
|
|
|
|
"use strict";
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var attributor_1 = __nested_webpack_require_217128__(12);
|
|
function match(node, prefix) {
|
|
var className = node.getAttribute('class') || '';
|
|
return className.split(/\s+/).filter(function (name) {
|
|
return name.indexOf(prefix + "-") === 0;
|
|
});
|
|
}
|
|
var ClassAttributor = /** @class */ (function (_super) {
|
|
__extends(ClassAttributor, _super);
|
|
function ClassAttributor() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
ClassAttributor.keys = function (node) {
|
|
return (node.getAttribute('class') || '').split(/\s+/).map(function (name) {
|
|
return name
|
|
.split('-')
|
|
.slice(0, -1)
|
|
.join('-');
|
|
});
|
|
};
|
|
ClassAttributor.prototype.add = function (node, value) {
|
|
if (!this.canAdd(node, value))
|
|
return false;
|
|
this.remove(node);
|
|
node.classList.add(this.keyName + "-" + value);
|
|
return true;
|
|
};
|
|
ClassAttributor.prototype.remove = function (node) {
|
|
var matches = match(node, this.keyName);
|
|
matches.forEach(function (name) {
|
|
node.classList.remove(name);
|
|
});
|
|
if (node.classList.length === 0) {
|
|
node.removeAttribute('class');
|
|
}
|
|
};
|
|
ClassAttributor.prototype.value = function (node) {
|
|
var result = match(node, this.keyName)[0] || '';
|
|
var value = result.slice(this.keyName.length + 1); // +1 for hyphen
|
|
return this.canAdd(node, value) ? value : '';
|
|
};
|
|
return ClassAttributor;
|
|
}(attributor_1.default));
|
|
exports.default = ClassAttributor;
|
|
|
|
|
|
/***/ }),
|
|
/* 33 */
|
|
/***/ (function(module, exports, __nested_webpack_require_219372__) {
|
|
|
|
"use strict";
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var attributor_1 = __nested_webpack_require_219372__(12);
|
|
function camelize(name) {
|
|
var parts = name.split('-');
|
|
var rest = parts
|
|
.slice(1)
|
|
.map(function (part) {
|
|
return part[0].toUpperCase() + part.slice(1);
|
|
})
|
|
.join('');
|
|
return parts[0] + rest;
|
|
}
|
|
var StyleAttributor = /** @class */ (function (_super) {
|
|
__extends(StyleAttributor, _super);
|
|
function StyleAttributor() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
StyleAttributor.keys = function (node) {
|
|
return (node.getAttribute('style') || '').split(';').map(function (value) {
|
|
var arr = value.split(':');
|
|
return arr[0].trim();
|
|
});
|
|
};
|
|
StyleAttributor.prototype.add = function (node, value) {
|
|
if (!this.canAdd(node, value))
|
|
return false;
|
|
// @ts-ignore
|
|
node.style[camelize(this.keyName)] = value;
|
|
return true;
|
|
};
|
|
StyleAttributor.prototype.remove = function (node) {
|
|
// @ts-ignore
|
|
node.style[camelize(this.keyName)] = '';
|
|
if (!node.getAttribute('style')) {
|
|
node.removeAttribute('style');
|
|
}
|
|
};
|
|
StyleAttributor.prototype.value = function (node) {
|
|
// @ts-ignore
|
|
var value = node.style[camelize(this.keyName)];
|
|
return this.canAdd(node, value) ? value : '';
|
|
};
|
|
return StyleAttributor;
|
|
}(attributor_1.default));
|
|
exports.default = StyleAttributor;
|
|
|
|
|
|
/***/ }),
|
|
/* 34 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
var Theme = function () {
|
|
function Theme(quill, options) {
|
|
_classCallCheck(this, Theme);
|
|
|
|
this.quill = quill;
|
|
this.options = options;
|
|
this.modules = {};
|
|
}
|
|
|
|
_createClass(Theme, [{
|
|
key: 'init',
|
|
value: function init() {
|
|
var _this = this;
|
|
|
|
Object.keys(this.options.modules).forEach(function (name) {
|
|
if (_this.modules[name] == null) {
|
|
_this.addModule(name);
|
|
}
|
|
});
|
|
}
|
|
}, {
|
|
key: 'addModule',
|
|
value: function addModule(name) {
|
|
var moduleClass = this.quill.constructor.import('modules/' + name);
|
|
this.modules[name] = new moduleClass(this.quill, this.options.modules[name] || {});
|
|
return this.modules[name];
|
|
}
|
|
}]);
|
|
|
|
return Theme;
|
|
}();
|
|
|
|
Theme.DEFAULTS = {
|
|
modules: {}
|
|
};
|
|
Theme.themes = {
|
|
'default': Theme
|
|
};
|
|
|
|
exports.default = Theme;
|
|
|
|
/***/ }),
|
|
/* 35 */
|
|
/***/ (function(module, exports, __nested_webpack_require_223199__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _parchment = __nested_webpack_require_223199__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
var _text = __nested_webpack_require_223199__(7);
|
|
|
|
var _text2 = _interopRequireDefault(_text);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var GUARD_TEXT = '\uFEFF';
|
|
|
|
var Embed = function (_Parchment$Embed) {
|
|
_inherits(Embed, _Parchment$Embed);
|
|
|
|
function Embed(node) {
|
|
_classCallCheck(this, Embed);
|
|
|
|
var _this = _possibleConstructorReturn(this, (Embed.__proto__ || Object.getPrototypeOf(Embed)).call(this, node));
|
|
|
|
_this.contentNode = document.createElement('span');
|
|
_this.contentNode.setAttribute('contenteditable', false);
|
|
[].slice.call(_this.domNode.childNodes).forEach(function (childNode) {
|
|
_this.contentNode.appendChild(childNode);
|
|
});
|
|
_this.leftGuard = document.createTextNode(GUARD_TEXT);
|
|
_this.rightGuard = document.createTextNode(GUARD_TEXT);
|
|
_this.domNode.appendChild(_this.leftGuard);
|
|
_this.domNode.appendChild(_this.contentNode);
|
|
_this.domNode.appendChild(_this.rightGuard);
|
|
return _this;
|
|
}
|
|
|
|
_createClass(Embed, [{
|
|
key: 'index',
|
|
value: function index(node, offset) {
|
|
if (node === this.leftGuard) return 0;
|
|
if (node === this.rightGuard) return 1;
|
|
return _get(Embed.prototype.__proto__ || Object.getPrototypeOf(Embed.prototype), 'index', this).call(this, node, offset);
|
|
}
|
|
}, {
|
|
key: 'restore',
|
|
value: function restore(node) {
|
|
var range = void 0,
|
|
textNode = void 0;
|
|
var text = node.data.split(GUARD_TEXT).join('');
|
|
if (node === this.leftGuard) {
|
|
if (this.prev instanceof _text2.default) {
|
|
var prevLength = this.prev.length();
|
|
this.prev.insertAt(prevLength, text);
|
|
range = {
|
|
startNode: this.prev.domNode,
|
|
startOffset: prevLength + text.length
|
|
};
|
|
} else {
|
|
textNode = document.createTextNode(text);
|
|
this.parent.insertBefore(_parchment2.default.create(textNode), this);
|
|
range = {
|
|
startNode: textNode,
|
|
startOffset: text.length
|
|
};
|
|
}
|
|
} else if (node === this.rightGuard) {
|
|
if (this.next instanceof _text2.default) {
|
|
this.next.insertAt(0, text);
|
|
range = {
|
|
startNode: this.next.domNode,
|
|
startOffset: text.length
|
|
};
|
|
} else {
|
|
textNode = document.createTextNode(text);
|
|
this.parent.insertBefore(_parchment2.default.create(textNode), this.next);
|
|
range = {
|
|
startNode: textNode,
|
|
startOffset: text.length
|
|
};
|
|
}
|
|
}
|
|
node.data = GUARD_TEXT;
|
|
return range;
|
|
}
|
|
}, {
|
|
key: 'update',
|
|
value: function update(mutations, context) {
|
|
var _this2 = this;
|
|
|
|
mutations.forEach(function (mutation) {
|
|
if (mutation.type === 'characterData' && (mutation.target === _this2.leftGuard || mutation.target === _this2.rightGuard)) {
|
|
var range = _this2.restore(mutation.target);
|
|
if (range) context.range = range;
|
|
}
|
|
});
|
|
}
|
|
}]);
|
|
|
|
return Embed;
|
|
}(_parchment2.default.Embed);
|
|
|
|
exports.default = Embed;
|
|
|
|
/***/ }),
|
|
/* 36 */
|
|
/***/ (function(module, exports, __nested_webpack_require_228527__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.AlignStyle = exports.AlignClass = exports.AlignAttribute = undefined;
|
|
|
|
var _parchment = __nested_webpack_require_228527__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
var config = {
|
|
scope: _parchment2.default.Scope.BLOCK,
|
|
whitelist: ['right', 'center', 'justify']
|
|
};
|
|
|
|
var AlignAttribute = new _parchment2.default.Attributor.Attribute('align', 'align', config);
|
|
var AlignClass = new _parchment2.default.Attributor.Class('align', 'ql-align', config);
|
|
var AlignStyle = new _parchment2.default.Attributor.Style('align', 'text-align', config);
|
|
|
|
exports.AlignAttribute = AlignAttribute;
|
|
exports.AlignClass = AlignClass;
|
|
exports.AlignStyle = AlignStyle;
|
|
|
|
/***/ }),
|
|
/* 37 */
|
|
/***/ (function(module, exports, __nested_webpack_require_229442__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.BackgroundStyle = exports.BackgroundClass = undefined;
|
|
|
|
var _parchment = __nested_webpack_require_229442__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
var _color = __nested_webpack_require_229442__(26);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
var BackgroundClass = new _parchment2.default.Attributor.Class('background', 'ql-bg', {
|
|
scope: _parchment2.default.Scope.INLINE
|
|
});
|
|
var BackgroundStyle = new _color.ColorAttributor('background', 'background-color', {
|
|
scope: _parchment2.default.Scope.INLINE
|
|
});
|
|
|
|
exports.BackgroundClass = BackgroundClass;
|
|
exports.BackgroundStyle = BackgroundStyle;
|
|
|
|
/***/ }),
|
|
/* 38 */
|
|
/***/ (function(module, exports, __nested_webpack_require_230249__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.DirectionStyle = exports.DirectionClass = exports.DirectionAttribute = undefined;
|
|
|
|
var _parchment = __nested_webpack_require_230249__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
var config = {
|
|
scope: _parchment2.default.Scope.BLOCK,
|
|
whitelist: ['rtl']
|
|
};
|
|
|
|
var DirectionAttribute = new _parchment2.default.Attributor.Attribute('direction', 'dir', config);
|
|
var DirectionClass = new _parchment2.default.Attributor.Class('direction', 'ql-direction', config);
|
|
var DirectionStyle = new _parchment2.default.Attributor.Style('direction', 'direction', config);
|
|
|
|
exports.DirectionAttribute = DirectionAttribute;
|
|
exports.DirectionClass = DirectionClass;
|
|
exports.DirectionStyle = DirectionStyle;
|
|
|
|
/***/ }),
|
|
/* 39 */
|
|
/***/ (function(module, exports, __nested_webpack_require_231202__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.FontClass = exports.FontStyle = undefined;
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _parchment = __nested_webpack_require_231202__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var config = {
|
|
scope: _parchment2.default.Scope.INLINE,
|
|
whitelist: ['serif', 'monospace']
|
|
};
|
|
|
|
var FontClass = new _parchment2.default.Attributor.Class('font', 'ql-font', config);
|
|
|
|
var FontStyleAttributor = function (_Parchment$Attributor) {
|
|
_inherits(FontStyleAttributor, _Parchment$Attributor);
|
|
|
|
function FontStyleAttributor() {
|
|
_classCallCheck(this, FontStyleAttributor);
|
|
|
|
return _possibleConstructorReturn(this, (FontStyleAttributor.__proto__ || Object.getPrototypeOf(FontStyleAttributor)).apply(this, arguments));
|
|
}
|
|
|
|
_createClass(FontStyleAttributor, [{
|
|
key: 'value',
|
|
value: function value(node) {
|
|
return _get(FontStyleAttributor.prototype.__proto__ || Object.getPrototypeOf(FontStyleAttributor.prototype), 'value', this).call(this, node).replace(/["']/g, '');
|
|
}
|
|
}]);
|
|
|
|
return FontStyleAttributor;
|
|
}(_parchment2.default.Attributor.Style);
|
|
|
|
var FontStyle = new FontStyleAttributor('font', 'font-family', config);
|
|
|
|
exports.FontStyle = FontStyle;
|
|
exports.FontClass = FontClass;
|
|
|
|
/***/ }),
|
|
/* 40 */
|
|
/***/ (function(module, exports, __nested_webpack_require_234578__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.SizeStyle = exports.SizeClass = undefined;
|
|
|
|
var _parchment = __nested_webpack_require_234578__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
var SizeClass = new _parchment2.default.Attributor.Class('size', 'ql-size', {
|
|
scope: _parchment2.default.Scope.INLINE,
|
|
whitelist: ['small', 'large', 'huge']
|
|
});
|
|
var SizeStyle = new _parchment2.default.Attributor.Style('size', 'font-size', {
|
|
scope: _parchment2.default.Scope.INLINE,
|
|
whitelist: ['10px', '18px', '32px']
|
|
});
|
|
|
|
exports.SizeClass = SizeClass;
|
|
exports.SizeStyle = SizeStyle;
|
|
|
|
/***/ }),
|
|
/* 41 */
|
|
/***/ (function(module, exports, __nested_webpack_require_235375__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
module.exports = {
|
|
'align': {
|
|
'': __nested_webpack_require_235375__(76),
|
|
'center': __nested_webpack_require_235375__(77),
|
|
'right': __nested_webpack_require_235375__(78),
|
|
'justify': __nested_webpack_require_235375__(79)
|
|
},
|
|
'background': __nested_webpack_require_235375__(80),
|
|
'blockquote': __nested_webpack_require_235375__(81),
|
|
'bold': __nested_webpack_require_235375__(82),
|
|
'clean': __nested_webpack_require_235375__(83),
|
|
'code': __nested_webpack_require_235375__(58),
|
|
'code-block': __nested_webpack_require_235375__(58),
|
|
'color': __nested_webpack_require_235375__(84),
|
|
'direction': {
|
|
'': __nested_webpack_require_235375__(85),
|
|
'rtl': __nested_webpack_require_235375__(86)
|
|
},
|
|
'float': {
|
|
'center': __nested_webpack_require_235375__(87),
|
|
'full': __nested_webpack_require_235375__(88),
|
|
'left': __nested_webpack_require_235375__(89),
|
|
'right': __nested_webpack_require_235375__(90)
|
|
},
|
|
'formula': __nested_webpack_require_235375__(91),
|
|
'header': {
|
|
'1': __nested_webpack_require_235375__(92),
|
|
'2': __nested_webpack_require_235375__(93)
|
|
},
|
|
'italic': __nested_webpack_require_235375__(94),
|
|
'image': __nested_webpack_require_235375__(95),
|
|
'indent': {
|
|
'+1': __nested_webpack_require_235375__(96),
|
|
'-1': __nested_webpack_require_235375__(97)
|
|
},
|
|
'link': __nested_webpack_require_235375__(98),
|
|
'list': {
|
|
'ordered': __nested_webpack_require_235375__(99),
|
|
'bullet': __nested_webpack_require_235375__(100),
|
|
'check': __nested_webpack_require_235375__(101)
|
|
},
|
|
'script': {
|
|
'sub': __nested_webpack_require_235375__(102),
|
|
'super': __nested_webpack_require_235375__(103)
|
|
},
|
|
'strike': __nested_webpack_require_235375__(104),
|
|
'underline': __nested_webpack_require_235375__(105),
|
|
'video': __nested_webpack_require_235375__(106)
|
|
};
|
|
|
|
/***/ }),
|
|
/* 42 */
|
|
/***/ (function(module, exports, __nested_webpack_require_236844__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.getLastChangeIndex = exports.default = undefined;
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _parchment = __nested_webpack_require_236844__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
var _quill = __nested_webpack_require_236844__(5);
|
|
|
|
var _quill2 = _interopRequireDefault(_quill);
|
|
|
|
var _module = __nested_webpack_require_236844__(9);
|
|
|
|
var _module2 = _interopRequireDefault(_module);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var History = function (_Module) {
|
|
_inherits(History, _Module);
|
|
|
|
function History(quill, options) {
|
|
_classCallCheck(this, History);
|
|
|
|
var _this = _possibleConstructorReturn(this, (History.__proto__ || Object.getPrototypeOf(History)).call(this, quill, options));
|
|
|
|
_this.lastRecorded = 0;
|
|
_this.ignoreChange = false;
|
|
_this.clear();
|
|
_this.quill.on(_quill2.default.events.EDITOR_CHANGE, function (eventName, delta, oldDelta, source) {
|
|
if (eventName !== _quill2.default.events.TEXT_CHANGE || _this.ignoreChange) return;
|
|
if (!_this.options.userOnly || source === _quill2.default.sources.USER) {
|
|
_this.record(delta, oldDelta);
|
|
} else {
|
|
_this.transform(delta);
|
|
}
|
|
});
|
|
_this.quill.keyboard.addBinding({ key: 'Z', shortKey: true }, _this.undo.bind(_this));
|
|
_this.quill.keyboard.addBinding({ key: 'Z', shortKey: true, shiftKey: true }, _this.redo.bind(_this));
|
|
if (/Win/i.test(navigator.platform)) {
|
|
_this.quill.keyboard.addBinding({ key: 'Y', shortKey: true }, _this.redo.bind(_this));
|
|
}
|
|
return _this;
|
|
}
|
|
|
|
_createClass(History, [{
|
|
key: 'change',
|
|
value: function change(source, dest) {
|
|
if (this.stack[source].length === 0) return;
|
|
var delta = this.stack[source].pop();
|
|
this.stack[dest].push(delta);
|
|
this.lastRecorded = 0;
|
|
this.ignoreChange = true;
|
|
this.quill.updateContents(delta[source], _quill2.default.sources.USER);
|
|
this.ignoreChange = false;
|
|
var index = getLastChangeIndex(delta[source]);
|
|
this.quill.setSelection(index);
|
|
}
|
|
}, {
|
|
key: 'clear',
|
|
value: function clear() {
|
|
this.stack = { undo: [], redo: [] };
|
|
}
|
|
}, {
|
|
key: 'cutoff',
|
|
value: function cutoff() {
|
|
this.lastRecorded = 0;
|
|
}
|
|
}, {
|
|
key: 'record',
|
|
value: function record(changeDelta, oldDelta) {
|
|
if (changeDelta.ops.length === 0) return;
|
|
this.stack.redo = [];
|
|
var undoDelta = this.quill.getContents().diff(oldDelta);
|
|
var timestamp = Date.now();
|
|
if (this.lastRecorded + this.options.delay > timestamp && this.stack.undo.length > 0) {
|
|
var delta = this.stack.undo.pop();
|
|
undoDelta = undoDelta.compose(delta.undo);
|
|
changeDelta = delta.redo.compose(changeDelta);
|
|
} else {
|
|
this.lastRecorded = timestamp;
|
|
}
|
|
this.stack.undo.push({
|
|
redo: changeDelta,
|
|
undo: undoDelta
|
|
});
|
|
if (this.stack.undo.length > this.options.maxStack) {
|
|
this.stack.undo.shift();
|
|
}
|
|
}
|
|
}, {
|
|
key: 'redo',
|
|
value: function redo() {
|
|
this.change('redo', 'undo');
|
|
}
|
|
}, {
|
|
key: 'transform',
|
|
value: function transform(delta) {
|
|
this.stack.undo.forEach(function (change) {
|
|
change.undo = delta.transform(change.undo, true);
|
|
change.redo = delta.transform(change.redo, true);
|
|
});
|
|
this.stack.redo.forEach(function (change) {
|
|
change.undo = delta.transform(change.undo, true);
|
|
change.redo = delta.transform(change.redo, true);
|
|
});
|
|
}
|
|
}, {
|
|
key: 'undo',
|
|
value: function undo() {
|
|
this.change('undo', 'redo');
|
|
}
|
|
}]);
|
|
|
|
return History;
|
|
}(_module2.default);
|
|
|
|
History.DEFAULTS = {
|
|
delay: 1000,
|
|
maxStack: 100,
|
|
userOnly: false
|
|
};
|
|
|
|
function endsWithNewlineChange(delta) {
|
|
var lastOp = delta.ops[delta.ops.length - 1];
|
|
if (lastOp == null) return false;
|
|
if (lastOp.insert != null) {
|
|
return typeof lastOp.insert === 'string' && lastOp.insert.endsWith('\n');
|
|
}
|
|
if (lastOp.attributes != null) {
|
|
return Object.keys(lastOp.attributes).some(function (attr) {
|
|
return _parchment2.default.query(attr, _parchment2.default.Scope.BLOCK) != null;
|
|
});
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function getLastChangeIndex(delta) {
|
|
var deleteLength = delta.reduce(function (length, op) {
|
|
length += op.delete || 0;
|
|
return length;
|
|
}, 0);
|
|
var changeIndex = delta.length() - deleteLength;
|
|
if (endsWithNewlineChange(delta)) {
|
|
changeIndex -= 1;
|
|
}
|
|
return changeIndex;
|
|
}
|
|
|
|
exports.default = History;
|
|
exports.getLastChangeIndex = getLastChangeIndex;
|
|
|
|
/***/ }),
|
|
/* 43 */
|
|
/***/ (function(module, exports, __nested_webpack_require_242979__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = exports.BaseTooltip = undefined;
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _extend = __nested_webpack_require_242979__(3);
|
|
|
|
var _extend2 = _interopRequireDefault(_extend);
|
|
|
|
var _quillDelta = __nested_webpack_require_242979__(2);
|
|
|
|
var _quillDelta2 = _interopRequireDefault(_quillDelta);
|
|
|
|
var _emitter = __nested_webpack_require_242979__(8);
|
|
|
|
var _emitter2 = _interopRequireDefault(_emitter);
|
|
|
|
var _keyboard = __nested_webpack_require_242979__(23);
|
|
|
|
var _keyboard2 = _interopRequireDefault(_keyboard);
|
|
|
|
var _theme = __nested_webpack_require_242979__(34);
|
|
|
|
var _theme2 = _interopRequireDefault(_theme);
|
|
|
|
var _colorPicker = __nested_webpack_require_242979__(59);
|
|
|
|
var _colorPicker2 = _interopRequireDefault(_colorPicker);
|
|
|
|
var _iconPicker = __nested_webpack_require_242979__(60);
|
|
|
|
var _iconPicker2 = _interopRequireDefault(_iconPicker);
|
|
|
|
var _picker = __nested_webpack_require_242979__(28);
|
|
|
|
var _picker2 = _interopRequireDefault(_picker);
|
|
|
|
var _tooltip = __nested_webpack_require_242979__(61);
|
|
|
|
var _tooltip2 = _interopRequireDefault(_tooltip);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var ALIGNS = [false, 'center', 'right', 'justify'];
|
|
|
|
var COLORS = ["#000000", "#e60000", "#ff9900", "#ffff00", "#008a00", "#0066cc", "#9933ff", "#ffffff", "#facccc", "#ffebcc", "#ffffcc", "#cce8cc", "#cce0f5", "#ebd6ff", "#bbbbbb", "#f06666", "#ffc266", "#ffff66", "#66b966", "#66a3e0", "#c285ff", "#888888", "#a10000", "#b26b00", "#b2b200", "#006100", "#0047b2", "#6b24b2", "#444444", "#5c0000", "#663d00", "#666600", "#003700", "#002966", "#3d1466"];
|
|
|
|
var FONTS = [false, 'serif', 'monospace'];
|
|
|
|
var HEADERS = ['1', '2', '3', false];
|
|
|
|
var SIZES = ['small', false, 'large', 'huge'];
|
|
|
|
var BaseTheme = function (_Theme) {
|
|
_inherits(BaseTheme, _Theme);
|
|
|
|
function BaseTheme(quill, options) {
|
|
_classCallCheck(this, BaseTheme);
|
|
|
|
var _this = _possibleConstructorReturn(this, (BaseTheme.__proto__ || Object.getPrototypeOf(BaseTheme)).call(this, quill, options));
|
|
|
|
var listener = function listener(e) {
|
|
if (!document.body.contains(quill.root)) {
|
|
return document.body.removeEventListener('click', listener);
|
|
}
|
|
if (_this.tooltip != null && !_this.tooltip.root.contains(e.target) && document.activeElement !== _this.tooltip.textbox && !_this.quill.hasFocus()) {
|
|
_this.tooltip.hide();
|
|
}
|
|
if (_this.pickers != null) {
|
|
_this.pickers.forEach(function (picker) {
|
|
if (!picker.container.contains(e.target)) {
|
|
picker.close();
|
|
}
|
|
});
|
|
}
|
|
};
|
|
quill.emitter.listenDOM('click', document.body, listener);
|
|
return _this;
|
|
}
|
|
|
|
_createClass(BaseTheme, [{
|
|
key: 'addModule',
|
|
value: function addModule(name) {
|
|
var module = _get(BaseTheme.prototype.__proto__ || Object.getPrototypeOf(BaseTheme.prototype), 'addModule', this).call(this, name);
|
|
if (name === 'toolbar') {
|
|
this.extendToolbar(module);
|
|
}
|
|
return module;
|
|
}
|
|
}, {
|
|
key: 'buildButtons',
|
|
value: function buildButtons(buttons, icons) {
|
|
buttons.forEach(function (button) {
|
|
var className = button.getAttribute('class') || '';
|
|
className.split(/\s+/).forEach(function (name) {
|
|
if (!name.startsWith('ql-')) return;
|
|
name = name.slice('ql-'.length);
|
|
if (icons[name] == null) return;
|
|
if (name === 'direction') {
|
|
button.innerHTML = icons[name][''] + icons[name]['rtl'];
|
|
} else if (typeof icons[name] === 'string') {
|
|
button.innerHTML = icons[name];
|
|
} else {
|
|
var value = button.value || '';
|
|
if (value != null && icons[name][value]) {
|
|
button.innerHTML = icons[name][value];
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}, {
|
|
key: 'buildPickers',
|
|
value: function buildPickers(selects, icons) {
|
|
var _this2 = this;
|
|
|
|
this.pickers = selects.map(function (select) {
|
|
if (select.classList.contains('ql-align')) {
|
|
if (select.querySelector('option') == null) {
|
|
fillSelect(select, ALIGNS);
|
|
}
|
|
return new _iconPicker2.default(select, icons.align);
|
|
} else if (select.classList.contains('ql-background') || select.classList.contains('ql-color')) {
|
|
var format = select.classList.contains('ql-background') ? 'background' : 'color';
|
|
if (select.querySelector('option') == null) {
|
|
fillSelect(select, COLORS, format === 'background' ? '#ffffff' : '#000000');
|
|
}
|
|
return new _colorPicker2.default(select, icons[format]);
|
|
} else {
|
|
if (select.querySelector('option') == null) {
|
|
if (select.classList.contains('ql-font')) {
|
|
fillSelect(select, FONTS);
|
|
} else if (select.classList.contains('ql-header')) {
|
|
fillSelect(select, HEADERS);
|
|
} else if (select.classList.contains('ql-size')) {
|
|
fillSelect(select, SIZES);
|
|
}
|
|
}
|
|
return new _picker2.default(select);
|
|
}
|
|
});
|
|
var update = function update() {
|
|
_this2.pickers.forEach(function (picker) {
|
|
picker.update();
|
|
});
|
|
};
|
|
this.quill.on(_emitter2.default.events.EDITOR_CHANGE, update);
|
|
}
|
|
}]);
|
|
|
|
return BaseTheme;
|
|
}(_theme2.default);
|
|
|
|
BaseTheme.DEFAULTS = (0, _extend2.default)(true, {}, _theme2.default.DEFAULTS, {
|
|
modules: {
|
|
toolbar: {
|
|
handlers: {
|
|
formula: function formula() {
|
|
this.quill.theme.tooltip.edit('formula');
|
|
},
|
|
image: function image() {
|
|
var _this3 = this;
|
|
|
|
var fileInput = this.container.querySelector('input.ql-image[type=file]');
|
|
if (fileInput == null) {
|
|
fileInput = document.createElement('input');
|
|
fileInput.setAttribute('type', 'file');
|
|
fileInput.setAttribute('accept', 'image/png, image/gif, image/jpeg, image/bmp, image/x-icon');
|
|
fileInput.classList.add('ql-image');
|
|
fileInput.addEventListener('change', function () {
|
|
if (fileInput.files != null && fileInput.files[0] != null) {
|
|
var reader = new FileReader();
|
|
reader.onload = function (e) {
|
|
var range = _this3.quill.getSelection(true);
|
|
_this3.quill.updateContents(new _quillDelta2.default().retain(range.index).delete(range.length).insert({ image: e.target.result }), _emitter2.default.sources.USER);
|
|
_this3.quill.setSelection(range.index + 1, _emitter2.default.sources.SILENT);
|
|
fileInput.value = "";
|
|
};
|
|
reader.readAsDataURL(fileInput.files[0]);
|
|
}
|
|
});
|
|
this.container.appendChild(fileInput);
|
|
}
|
|
fileInput.click();
|
|
},
|
|
video: function video() {
|
|
this.quill.theme.tooltip.edit('video');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
var BaseTooltip = function (_Tooltip) {
|
|
_inherits(BaseTooltip, _Tooltip);
|
|
|
|
function BaseTooltip(quill, boundsContainer) {
|
|
_classCallCheck(this, BaseTooltip);
|
|
|
|
var _this4 = _possibleConstructorReturn(this, (BaseTooltip.__proto__ || Object.getPrototypeOf(BaseTooltip)).call(this, quill, boundsContainer));
|
|
|
|
_this4.textbox = _this4.root.querySelector('input[type="text"]');
|
|
_this4.listen();
|
|
return _this4;
|
|
}
|
|
|
|
_createClass(BaseTooltip, [{
|
|
key: 'listen',
|
|
value: function listen() {
|
|
var _this5 = this;
|
|
|
|
this.textbox.addEventListener('keydown', function (event) {
|
|
if (_keyboard2.default.match(event, 'enter')) {
|
|
_this5.save();
|
|
event.preventDefault();
|
|
} else if (_keyboard2.default.match(event, 'escape')) {
|
|
_this5.cancel();
|
|
event.preventDefault();
|
|
}
|
|
});
|
|
}
|
|
}, {
|
|
key: 'cancel',
|
|
value: function cancel() {
|
|
this.hide();
|
|
}
|
|
}, {
|
|
key: 'edit',
|
|
value: function edit() {
|
|
var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'link';
|
|
var preview = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
|
|
this.root.classList.remove('ql-hidden');
|
|
this.root.classList.add('ql-editing');
|
|
if (preview != null) {
|
|
this.textbox.value = preview;
|
|
} else if (mode !== this.root.getAttribute('data-mode')) {
|
|
this.textbox.value = '';
|
|
}
|
|
this.position(this.quill.getBounds(this.quill.selection.savedRange));
|
|
this.textbox.select();
|
|
this.textbox.setAttribute('placeholder', this.textbox.getAttribute('data-' + mode) || '');
|
|
this.root.setAttribute('data-mode', mode);
|
|
}
|
|
}, {
|
|
key: 'restoreFocus',
|
|
value: function restoreFocus() {
|
|
var scrollTop = this.quill.scrollingContainer.scrollTop;
|
|
this.quill.focus();
|
|
this.quill.scrollingContainer.scrollTop = scrollTop;
|
|
}
|
|
}, {
|
|
key: 'save',
|
|
value: function save() {
|
|
var value = this.textbox.value;
|
|
switch (this.root.getAttribute('data-mode')) {
|
|
case 'link':
|
|
{
|
|
var scrollTop = this.quill.root.scrollTop;
|
|
if (this.linkRange) {
|
|
this.quill.formatText(this.linkRange, 'link', value, _emitter2.default.sources.USER);
|
|
delete this.linkRange;
|
|
} else {
|
|
this.restoreFocus();
|
|
this.quill.format('link', value, _emitter2.default.sources.USER);
|
|
}
|
|
this.quill.root.scrollTop = scrollTop;
|
|
break;
|
|
}
|
|
case 'video':
|
|
{
|
|
value = extractVideoUrl(value);
|
|
} // eslint-disable-next-line no-fallthrough
|
|
case 'formula':
|
|
{
|
|
if (!value) break;
|
|
var range = this.quill.getSelection(true);
|
|
if (range != null) {
|
|
var index = range.index + range.length;
|
|
this.quill.insertEmbed(index, this.root.getAttribute('data-mode'), value, _emitter2.default.sources.USER);
|
|
if (this.root.getAttribute('data-mode') === 'formula') {
|
|
this.quill.insertText(index + 1, ' ', _emitter2.default.sources.USER);
|
|
}
|
|
this.quill.setSelection(index + 2, _emitter2.default.sources.USER);
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
}
|
|
this.textbox.value = '';
|
|
this.hide();
|
|
}
|
|
}]);
|
|
|
|
return BaseTooltip;
|
|
}(_tooltip2.default);
|
|
|
|
function extractVideoUrl(url) {
|
|
var match = url.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/) || url.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtu\.be\/([a-zA-Z0-9_-]+)/);
|
|
if (match) {
|
|
return (match[1] || 'https') + '://www.youtube.com/embed/' + match[2] + '?showinfo=0';
|
|
}
|
|
if (match = url.match(/^(?:(https?):\/\/)?(?:www\.)?vimeo\.com\/(\d+)/)) {
|
|
// eslint-disable-line no-cond-assign
|
|
return (match[1] || 'https') + '://player.vimeo.com/video/' + match[2] + '/';
|
|
}
|
|
return url;
|
|
}
|
|
|
|
function fillSelect(select, values) {
|
|
var defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
|
|
values.forEach(function (value) {
|
|
var option = document.createElement('option');
|
|
if (value === defaultValue) {
|
|
option.setAttribute('selected', 'selected');
|
|
} else {
|
|
option.setAttribute('value', value);
|
|
}
|
|
select.appendChild(option);
|
|
});
|
|
}
|
|
|
|
exports.BaseTooltip = BaseTooltip;
|
|
exports.default = BaseTheme;
|
|
|
|
/***/ }),
|
|
/* 44 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var LinkedList = /** @class */ (function () {
|
|
function LinkedList() {
|
|
this.head = this.tail = null;
|
|
this.length = 0;
|
|
}
|
|
LinkedList.prototype.append = function () {
|
|
var nodes = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
nodes[_i] = arguments[_i];
|
|
}
|
|
this.insertBefore(nodes[0], null);
|
|
if (nodes.length > 1) {
|
|
this.append.apply(this, nodes.slice(1));
|
|
}
|
|
};
|
|
LinkedList.prototype.contains = function (node) {
|
|
var cur, next = this.iterator();
|
|
while ((cur = next())) {
|
|
if (cur === node)
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
LinkedList.prototype.insertBefore = function (node, refNode) {
|
|
if (!node)
|
|
return;
|
|
node.next = refNode;
|
|
if (refNode != null) {
|
|
node.prev = refNode.prev;
|
|
if (refNode.prev != null) {
|
|
refNode.prev.next = node;
|
|
}
|
|
refNode.prev = node;
|
|
if (refNode === this.head) {
|
|
this.head = node;
|
|
}
|
|
}
|
|
else if (this.tail != null) {
|
|
this.tail.next = node;
|
|
node.prev = this.tail;
|
|
this.tail = node;
|
|
}
|
|
else {
|
|
node.prev = null;
|
|
this.head = this.tail = node;
|
|
}
|
|
this.length += 1;
|
|
};
|
|
LinkedList.prototype.offset = function (target) {
|
|
var index = 0, cur = this.head;
|
|
while (cur != null) {
|
|
if (cur === target)
|
|
return index;
|
|
index += cur.length();
|
|
cur = cur.next;
|
|
}
|
|
return -1;
|
|
};
|
|
LinkedList.prototype.remove = function (node) {
|
|
if (!this.contains(node))
|
|
return;
|
|
if (node.prev != null)
|
|
node.prev.next = node.next;
|
|
if (node.next != null)
|
|
node.next.prev = node.prev;
|
|
if (node === this.head)
|
|
this.head = node.next;
|
|
if (node === this.tail)
|
|
this.tail = node.prev;
|
|
this.length -= 1;
|
|
};
|
|
LinkedList.prototype.iterator = function (curNode) {
|
|
if (curNode === void 0) { curNode = this.head; }
|
|
// TODO use yield when we can
|
|
return function () {
|
|
var ret = curNode;
|
|
if (curNode != null)
|
|
curNode = curNode.next;
|
|
return ret;
|
|
};
|
|
};
|
|
LinkedList.prototype.find = function (index, inclusive) {
|
|
if (inclusive === void 0) { inclusive = false; }
|
|
var cur, next = this.iterator();
|
|
while ((cur = next())) {
|
|
var length = cur.length();
|
|
if (index < length ||
|
|
(inclusive && index === length && (cur.next == null || cur.next.length() !== 0))) {
|
|
return [cur, index];
|
|
}
|
|
index -= length;
|
|
}
|
|
return [null, 0];
|
|
};
|
|
LinkedList.prototype.forEach = function (callback) {
|
|
var cur, next = this.iterator();
|
|
while ((cur = next())) {
|
|
callback(cur);
|
|
}
|
|
};
|
|
LinkedList.prototype.forEachAt = function (index, length, callback) {
|
|
if (length <= 0)
|
|
return;
|
|
var _a = this.find(index), startNode = _a[0], offset = _a[1];
|
|
var cur, curIndex = index - offset, next = this.iterator(startNode);
|
|
while ((cur = next()) && curIndex < index + length) {
|
|
var curLength = cur.length();
|
|
if (index > curIndex) {
|
|
callback(cur, index - curIndex, Math.min(length, curIndex + curLength - index));
|
|
}
|
|
else {
|
|
callback(cur, 0, Math.min(curLength, index + length - curIndex));
|
|
}
|
|
curIndex += curLength;
|
|
}
|
|
};
|
|
LinkedList.prototype.map = function (callback) {
|
|
return this.reduce(function (memo, cur) {
|
|
memo.push(callback(cur));
|
|
return memo;
|
|
}, []);
|
|
};
|
|
LinkedList.prototype.reduce = function (callback, memo) {
|
|
var cur, next = this.iterator();
|
|
while ((cur = next())) {
|
|
memo = callback(memo, cur);
|
|
}
|
|
return memo;
|
|
};
|
|
return LinkedList;
|
|
}());
|
|
exports.default = LinkedList;
|
|
|
|
|
|
/***/ }),
|
|
/* 45 */
|
|
/***/ (function(module, exports, __nested_webpack_require_260796__) {
|
|
|
|
"use strict";
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var container_1 = __nested_webpack_require_260796__(17);
|
|
var Registry = __nested_webpack_require_260796__(1);
|
|
var OBSERVER_CONFIG = {
|
|
attributes: true,
|
|
characterData: true,
|
|
characterDataOldValue: true,
|
|
childList: true,
|
|
subtree: true,
|
|
};
|
|
var MAX_OPTIMIZE_ITERATIONS = 100;
|
|
var ScrollBlot = /** @class */ (function (_super) {
|
|
__extends(ScrollBlot, _super);
|
|
function ScrollBlot(node) {
|
|
var _this = _super.call(this, node) || this;
|
|
_this.scroll = _this;
|
|
_this.observer = new MutationObserver(function (mutations) {
|
|
_this.update(mutations);
|
|
});
|
|
_this.observer.observe(_this.domNode, OBSERVER_CONFIG);
|
|
_this.attach();
|
|
return _this;
|
|
}
|
|
ScrollBlot.prototype.detach = function () {
|
|
_super.prototype.detach.call(this);
|
|
this.observer.disconnect();
|
|
};
|
|
ScrollBlot.prototype.deleteAt = function (index, length) {
|
|
this.update();
|
|
if (index === 0 && length === this.length()) {
|
|
this.children.forEach(function (child) {
|
|
child.remove();
|
|
});
|
|
}
|
|
else {
|
|
_super.prototype.deleteAt.call(this, index, length);
|
|
}
|
|
};
|
|
ScrollBlot.prototype.formatAt = function (index, length, name, value) {
|
|
this.update();
|
|
_super.prototype.formatAt.call(this, index, length, name, value);
|
|
};
|
|
ScrollBlot.prototype.insertAt = function (index, value, def) {
|
|
this.update();
|
|
_super.prototype.insertAt.call(this, index, value, def);
|
|
};
|
|
ScrollBlot.prototype.optimize = function (mutations, context) {
|
|
var _this = this;
|
|
if (mutations === void 0) { mutations = []; }
|
|
if (context === void 0) { context = {}; }
|
|
_super.prototype.optimize.call(this, context);
|
|
// We must modify mutations directly, cannot make copy and then modify
|
|
var records = [].slice.call(this.observer.takeRecords());
|
|
// Array.push currently seems to be implemented by a non-tail recursive function
|
|
// so we cannot just mutations.push.apply(mutations, this.observer.takeRecords());
|
|
while (records.length > 0)
|
|
mutations.push(records.pop());
|
|
// TODO use WeakMap
|
|
var mark = function (blot, markParent) {
|
|
if (markParent === void 0) { markParent = true; }
|
|
if (blot == null || blot === _this)
|
|
return;
|
|
if (blot.domNode.parentNode == null)
|
|
return;
|
|
// @ts-ignore
|
|
if (blot.domNode[Registry.DATA_KEY].mutations == null) {
|
|
// @ts-ignore
|
|
blot.domNode[Registry.DATA_KEY].mutations = [];
|
|
}
|
|
if (markParent)
|
|
mark(blot.parent);
|
|
};
|
|
var optimize = function (blot) {
|
|
// Post-order traversal
|
|
if (
|
|
// @ts-ignore
|
|
blot.domNode[Registry.DATA_KEY] == null ||
|
|
// @ts-ignore
|
|
blot.domNode[Registry.DATA_KEY].mutations == null) {
|
|
return;
|
|
}
|
|
if (blot instanceof container_1.default) {
|
|
blot.children.forEach(optimize);
|
|
}
|
|
blot.optimize(context);
|
|
};
|
|
var remaining = mutations;
|
|
for (var i = 0; remaining.length > 0; i += 1) {
|
|
if (i >= MAX_OPTIMIZE_ITERATIONS) {
|
|
throw new Error('[Parchment] Maximum optimize iterations reached');
|
|
}
|
|
remaining.forEach(function (mutation) {
|
|
var blot = Registry.find(mutation.target, true);
|
|
if (blot == null)
|
|
return;
|
|
if (blot.domNode === mutation.target) {
|
|
if (mutation.type === 'childList') {
|
|
mark(Registry.find(mutation.previousSibling, false));
|
|
[].forEach.call(mutation.addedNodes, function (node) {
|
|
var child = Registry.find(node, false);
|
|
mark(child, false);
|
|
if (child instanceof container_1.default) {
|
|
child.children.forEach(function (grandChild) {
|
|
mark(grandChild, false);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
else if (mutation.type === 'attributes') {
|
|
mark(blot.prev);
|
|
}
|
|
}
|
|
mark(blot);
|
|
});
|
|
this.children.forEach(optimize);
|
|
remaining = [].slice.call(this.observer.takeRecords());
|
|
records = remaining.slice();
|
|
while (records.length > 0)
|
|
mutations.push(records.pop());
|
|
}
|
|
};
|
|
ScrollBlot.prototype.update = function (mutations, context) {
|
|
var _this = this;
|
|
if (context === void 0) { context = {}; }
|
|
mutations = mutations || this.observer.takeRecords();
|
|
// TODO use WeakMap
|
|
mutations
|
|
.map(function (mutation) {
|
|
var blot = Registry.find(mutation.target, true);
|
|
if (blot == null)
|
|
return null;
|
|
// @ts-ignore
|
|
if (blot.domNode[Registry.DATA_KEY].mutations == null) {
|
|
// @ts-ignore
|
|
blot.domNode[Registry.DATA_KEY].mutations = [mutation];
|
|
return blot;
|
|
}
|
|
else {
|
|
// @ts-ignore
|
|
blot.domNode[Registry.DATA_KEY].mutations.push(mutation);
|
|
return null;
|
|
}
|
|
})
|
|
.forEach(function (blot) {
|
|
if (blot == null ||
|
|
blot === _this ||
|
|
//@ts-ignore
|
|
blot.domNode[Registry.DATA_KEY] == null)
|
|
return;
|
|
// @ts-ignore
|
|
blot.update(blot.domNode[Registry.DATA_KEY].mutations || [], context);
|
|
});
|
|
// @ts-ignore
|
|
if (this.domNode[Registry.DATA_KEY].mutations != null) {
|
|
// @ts-ignore
|
|
_super.prototype.update.call(this, this.domNode[Registry.DATA_KEY].mutations, context);
|
|
}
|
|
this.optimize(mutations, context);
|
|
};
|
|
ScrollBlot.blotName = 'scroll';
|
|
ScrollBlot.defaultChild = 'block';
|
|
ScrollBlot.scope = Registry.Scope.BLOCK_BLOT;
|
|
ScrollBlot.tagName = 'DIV';
|
|
return ScrollBlot;
|
|
}(container_1.default));
|
|
exports.default = ScrollBlot;
|
|
|
|
|
|
/***/ }),
|
|
/* 46 */
|
|
/***/ (function(module, exports, __nested_webpack_require_267910__) {
|
|
|
|
"use strict";
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var format_1 = __nested_webpack_require_267910__(18);
|
|
var Registry = __nested_webpack_require_267910__(1);
|
|
// Shallow object comparison
|
|
function isEqual(obj1, obj2) {
|
|
if (Object.keys(obj1).length !== Object.keys(obj2).length)
|
|
return false;
|
|
// @ts-ignore
|
|
for (var prop in obj1) {
|
|
// @ts-ignore
|
|
if (obj1[prop] !== obj2[prop])
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
var InlineBlot = /** @class */ (function (_super) {
|
|
__extends(InlineBlot, _super);
|
|
function InlineBlot() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
InlineBlot.formats = function (domNode) {
|
|
if (domNode.tagName === InlineBlot.tagName)
|
|
return undefined;
|
|
return _super.formats.call(this, domNode);
|
|
};
|
|
InlineBlot.prototype.format = function (name, value) {
|
|
var _this = this;
|
|
if (name === this.statics.blotName && !value) {
|
|
this.children.forEach(function (child) {
|
|
if (!(child instanceof format_1.default)) {
|
|
child = child.wrap(InlineBlot.blotName, true);
|
|
}
|
|
_this.attributes.copy(child);
|
|
});
|
|
this.unwrap();
|
|
}
|
|
else {
|
|
_super.prototype.format.call(this, name, value);
|
|
}
|
|
};
|
|
InlineBlot.prototype.formatAt = function (index, length, name, value) {
|
|
if (this.formats()[name] != null || Registry.query(name, Registry.Scope.ATTRIBUTE)) {
|
|
var blot = this.isolate(index, length);
|
|
blot.format(name, value);
|
|
}
|
|
else {
|
|
_super.prototype.formatAt.call(this, index, length, name, value);
|
|
}
|
|
};
|
|
InlineBlot.prototype.optimize = function (context) {
|
|
_super.prototype.optimize.call(this, context);
|
|
var formats = this.formats();
|
|
if (Object.keys(formats).length === 0) {
|
|
return this.unwrap(); // unformatted span
|
|
}
|
|
var next = this.next;
|
|
if (next instanceof InlineBlot && next.prev === this && isEqual(formats, next.formats())) {
|
|
next.moveChildren(this);
|
|
next.remove();
|
|
}
|
|
};
|
|
InlineBlot.blotName = 'inline';
|
|
InlineBlot.scope = Registry.Scope.INLINE_BLOT;
|
|
InlineBlot.tagName = 'SPAN';
|
|
return InlineBlot;
|
|
}(format_1.default));
|
|
exports.default = InlineBlot;
|
|
|
|
|
|
/***/ }),
|
|
/* 47 */
|
|
/***/ (function(module, exports, __nested_webpack_require_270902__) {
|
|
|
|
"use strict";
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var format_1 = __nested_webpack_require_270902__(18);
|
|
var Registry = __nested_webpack_require_270902__(1);
|
|
var BlockBlot = /** @class */ (function (_super) {
|
|
__extends(BlockBlot, _super);
|
|
function BlockBlot() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
BlockBlot.formats = function (domNode) {
|
|
var tagName = Registry.query(BlockBlot.blotName).tagName;
|
|
if (domNode.tagName === tagName)
|
|
return undefined;
|
|
return _super.formats.call(this, domNode);
|
|
};
|
|
BlockBlot.prototype.format = function (name, value) {
|
|
if (Registry.query(name, Registry.Scope.BLOCK) == null) {
|
|
return;
|
|
}
|
|
else if (name === this.statics.blotName && !value) {
|
|
this.replaceWith(BlockBlot.blotName);
|
|
}
|
|
else {
|
|
_super.prototype.format.call(this, name, value);
|
|
}
|
|
};
|
|
BlockBlot.prototype.formatAt = function (index, length, name, value) {
|
|
if (Registry.query(name, Registry.Scope.BLOCK) != null) {
|
|
this.format(name, value);
|
|
}
|
|
else {
|
|
_super.prototype.formatAt.call(this, index, length, name, value);
|
|
}
|
|
};
|
|
BlockBlot.prototype.insertAt = function (index, value, def) {
|
|
if (def == null || Registry.query(value, Registry.Scope.INLINE) != null) {
|
|
// Insert text or inline
|
|
_super.prototype.insertAt.call(this, index, value, def);
|
|
}
|
|
else {
|
|
var after = this.split(index);
|
|
var blot = Registry.create(value, def);
|
|
after.parent.insertBefore(blot, after);
|
|
}
|
|
};
|
|
BlockBlot.prototype.update = function (mutations, context) {
|
|
if (navigator.userAgent.match(/Trident/)) {
|
|
this.build();
|
|
}
|
|
else {
|
|
_super.prototype.update.call(this, mutations, context);
|
|
}
|
|
};
|
|
BlockBlot.blotName = 'block';
|
|
BlockBlot.scope = Registry.Scope.BLOCK_BLOT;
|
|
BlockBlot.tagName = 'P';
|
|
return BlockBlot;
|
|
}(format_1.default));
|
|
exports.default = BlockBlot;
|
|
|
|
|
|
/***/ }),
|
|
/* 48 */
|
|
/***/ (function(module, exports, __nested_webpack_require_273610__) {
|
|
|
|
"use strict";
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var leaf_1 = __nested_webpack_require_273610__(19);
|
|
var EmbedBlot = /** @class */ (function (_super) {
|
|
__extends(EmbedBlot, _super);
|
|
function EmbedBlot() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
EmbedBlot.formats = function (domNode) {
|
|
return undefined;
|
|
};
|
|
EmbedBlot.prototype.format = function (name, value) {
|
|
// super.formatAt wraps, which is what we want in general,
|
|
// but this allows subclasses to overwrite for formats
|
|
// that just apply to particular embeds
|
|
_super.prototype.formatAt.call(this, 0, this.length(), name, value);
|
|
};
|
|
EmbedBlot.prototype.formatAt = function (index, length, name, value) {
|
|
if (index === 0 && length === this.length()) {
|
|
this.format(name, value);
|
|
}
|
|
else {
|
|
_super.prototype.formatAt.call(this, index, length, name, value);
|
|
}
|
|
};
|
|
EmbedBlot.prototype.formats = function () {
|
|
return this.statics.formats(this.domNode);
|
|
};
|
|
return EmbedBlot;
|
|
}(leaf_1.default));
|
|
exports.default = EmbedBlot;
|
|
|
|
|
|
/***/ }),
|
|
/* 49 */
|
|
/***/ (function(module, exports, __nested_webpack_require_275351__) {
|
|
|
|
"use strict";
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var leaf_1 = __nested_webpack_require_275351__(19);
|
|
var Registry = __nested_webpack_require_275351__(1);
|
|
var TextBlot = /** @class */ (function (_super) {
|
|
__extends(TextBlot, _super);
|
|
function TextBlot(node) {
|
|
var _this = _super.call(this, node) || this;
|
|
_this.text = _this.statics.value(_this.domNode);
|
|
return _this;
|
|
}
|
|
TextBlot.create = function (value) {
|
|
return document.createTextNode(value);
|
|
};
|
|
TextBlot.value = function (domNode) {
|
|
var text = domNode.data;
|
|
// @ts-ignore
|
|
if (text['normalize'])
|
|
text = text['normalize']();
|
|
return text;
|
|
};
|
|
TextBlot.prototype.deleteAt = function (index, length) {
|
|
this.domNode.data = this.text = this.text.slice(0, index) + this.text.slice(index + length);
|
|
};
|
|
TextBlot.prototype.index = function (node, offset) {
|
|
if (this.domNode === node) {
|
|
return offset;
|
|
}
|
|
return -1;
|
|
};
|
|
TextBlot.prototype.insertAt = function (index, value, def) {
|
|
if (def == null) {
|
|
this.text = this.text.slice(0, index) + value + this.text.slice(index);
|
|
this.domNode.data = this.text;
|
|
}
|
|
else {
|
|
_super.prototype.insertAt.call(this, index, value, def);
|
|
}
|
|
};
|
|
TextBlot.prototype.length = function () {
|
|
return this.text.length;
|
|
};
|
|
TextBlot.prototype.optimize = function (context) {
|
|
_super.prototype.optimize.call(this, context);
|
|
this.text = this.statics.value(this.domNode);
|
|
if (this.text.length === 0) {
|
|
this.remove();
|
|
}
|
|
else if (this.next instanceof TextBlot && this.next.prev === this) {
|
|
this.insertAt(this.length(), this.next.value());
|
|
this.next.remove();
|
|
}
|
|
};
|
|
TextBlot.prototype.position = function (index, inclusive) {
|
|
if (inclusive === void 0) { inclusive = false; }
|
|
return [this.domNode, index];
|
|
};
|
|
TextBlot.prototype.split = function (index, force) {
|
|
if (force === void 0) { force = false; }
|
|
if (!force) {
|
|
if (index === 0)
|
|
return this;
|
|
if (index === this.length())
|
|
return this.next;
|
|
}
|
|
var after = Registry.create(this.domNode.splitText(index));
|
|
this.parent.insertBefore(after, this.next);
|
|
this.text = this.statics.value(this.domNode);
|
|
return after;
|
|
};
|
|
TextBlot.prototype.update = function (mutations, context) {
|
|
var _this = this;
|
|
if (mutations.some(function (mutation) {
|
|
return mutation.type === 'characterData' && mutation.target === _this.domNode;
|
|
})) {
|
|
this.text = this.statics.value(this.domNode);
|
|
}
|
|
};
|
|
TextBlot.prototype.value = function () {
|
|
return this.text;
|
|
};
|
|
TextBlot.blotName = 'text';
|
|
TextBlot.scope = Registry.Scope.INLINE_BLOT;
|
|
return TextBlot;
|
|
}(leaf_1.default));
|
|
exports.default = TextBlot;
|
|
|
|
|
|
/***/ }),
|
|
/* 50 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
var elem = document.createElement('div');
|
|
elem.classList.toggle('test-class', false);
|
|
if (elem.classList.contains('test-class')) {
|
|
var _toggle = DOMTokenList.prototype.toggle;
|
|
DOMTokenList.prototype.toggle = function (token, force) {
|
|
if (arguments.length > 1 && !this.contains(token) === !force) {
|
|
return force;
|
|
} else {
|
|
return _toggle.call(this, token);
|
|
}
|
|
};
|
|
}
|
|
|
|
if (!String.prototype.startsWith) {
|
|
String.prototype.startsWith = function (searchString, position) {
|
|
position = position || 0;
|
|
return this.substr(position, searchString.length) === searchString;
|
|
};
|
|
}
|
|
|
|
if (!String.prototype.endsWith) {
|
|
String.prototype.endsWith = function (searchString, position) {
|
|
var subjectString = this.toString();
|
|
if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
|
|
position = subjectString.length;
|
|
}
|
|
position -= searchString.length;
|
|
var lastIndex = subjectString.indexOf(searchString, position);
|
|
return lastIndex !== -1 && lastIndex === position;
|
|
};
|
|
}
|
|
|
|
if (!Array.prototype.find) {
|
|
Object.defineProperty(Array.prototype, "find", {
|
|
value: function value(predicate) {
|
|
if (this === null) {
|
|
throw new TypeError('Array.prototype.find called on null or undefined');
|
|
}
|
|
if (typeof predicate !== 'function') {
|
|
throw new TypeError('predicate must be a function');
|
|
}
|
|
var list = Object(this);
|
|
var length = list.length >>> 0;
|
|
var thisArg = arguments[1];
|
|
var value;
|
|
|
|
for (var i = 0; i < length; i++) {
|
|
value = list[i];
|
|
if (predicate.call(thisArg, value, i, list)) {
|
|
return value;
|
|
}
|
|
}
|
|
return undefined;
|
|
}
|
|
});
|
|
}
|
|
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
// Disable resizing in Firefox
|
|
document.execCommand("enableObjectResizing", false, false);
|
|
// Disable automatic linkifying in IE11
|
|
document.execCommand("autoUrlDetect", false, false);
|
|
});
|
|
|
|
/***/ }),
|
|
/* 51 */
|
|
/***/ (function(module, exports) {
|
|
|
|
/**
|
|
* This library modifies the diff-patch-match library by Neil Fraser
|
|
* by removing the patch and match functionality and certain advanced
|
|
* options in the diff function. The original license is as follows:
|
|
*
|
|
* ===
|
|
*
|
|
* Diff Match and Patch
|
|
*
|
|
* Copyright 2006 Google Inc.
|
|
* http://code.google.com/p/google-diff-match-patch/
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
|
|
/**
|
|
* The data structure representing a diff is an array of tuples:
|
|
* [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
|
|
* which means: delete 'Hello', add 'Goodbye' and keep ' world.'
|
|
*/
|
|
var DIFF_DELETE = -1;
|
|
var DIFF_INSERT = 1;
|
|
var DIFF_EQUAL = 0;
|
|
|
|
|
|
/**
|
|
* Find the differences between two texts. Simplifies the problem by stripping
|
|
* any common prefix or suffix off the texts before diffing.
|
|
* @param {string} text1 Old string to be diffed.
|
|
* @param {string} text2 New string to be diffed.
|
|
* @param {Int} cursor_pos Expected edit position in text1 (optional)
|
|
* @return {Array} Array of diff tuples.
|
|
*/
|
|
function diff_main(text1, text2, cursor_pos) {
|
|
// Check for equality (speedup).
|
|
if (text1 == text2) {
|
|
if (text1) {
|
|
return [[DIFF_EQUAL, text1]];
|
|
}
|
|
return [];
|
|
}
|
|
|
|
// Check cursor_pos within bounds
|
|
if (cursor_pos < 0 || text1.length < cursor_pos) {
|
|
cursor_pos = null;
|
|
}
|
|
|
|
// Trim off common prefix (speedup).
|
|
var commonlength = diff_commonPrefix(text1, text2);
|
|
var commonprefix = text1.substring(0, commonlength);
|
|
text1 = text1.substring(commonlength);
|
|
text2 = text2.substring(commonlength);
|
|
|
|
// Trim off common suffix (speedup).
|
|
commonlength = diff_commonSuffix(text1, text2);
|
|
var commonsuffix = text1.substring(text1.length - commonlength);
|
|
text1 = text1.substring(0, text1.length - commonlength);
|
|
text2 = text2.substring(0, text2.length - commonlength);
|
|
|
|
// Compute the diff on the middle block.
|
|
var diffs = diff_compute_(text1, text2);
|
|
|
|
// Restore the prefix and suffix.
|
|
if (commonprefix) {
|
|
diffs.unshift([DIFF_EQUAL, commonprefix]);
|
|
}
|
|
if (commonsuffix) {
|
|
diffs.push([DIFF_EQUAL, commonsuffix]);
|
|
}
|
|
diff_cleanupMerge(diffs);
|
|
if (cursor_pos != null) {
|
|
diffs = fix_cursor(diffs, cursor_pos);
|
|
}
|
|
diffs = fix_emoji(diffs);
|
|
return diffs;
|
|
};
|
|
|
|
|
|
/**
|
|
* Find the differences between two texts. Assumes that the texts do not
|
|
* have any common prefix or suffix.
|
|
* @param {string} text1 Old string to be diffed.
|
|
* @param {string} text2 New string to be diffed.
|
|
* @return {Array} Array of diff tuples.
|
|
*/
|
|
function diff_compute_(text1, text2) {
|
|
var diffs;
|
|
|
|
if (!text1) {
|
|
// Just add some text (speedup).
|
|
return [[DIFF_INSERT, text2]];
|
|
}
|
|
|
|
if (!text2) {
|
|
// Just delete some text (speedup).
|
|
return [[DIFF_DELETE, text1]];
|
|
}
|
|
|
|
var longtext = text1.length > text2.length ? text1 : text2;
|
|
var shorttext = text1.length > text2.length ? text2 : text1;
|
|
var i = longtext.indexOf(shorttext);
|
|
if (i != -1) {
|
|
// Shorter text is inside the longer text (speedup).
|
|
diffs = [[DIFF_INSERT, longtext.substring(0, i)],
|
|
[DIFF_EQUAL, shorttext],
|
|
[DIFF_INSERT, longtext.substring(i + shorttext.length)]];
|
|
// Swap insertions for deletions if diff is reversed.
|
|
if (text1.length > text2.length) {
|
|
diffs[0][0] = diffs[2][0] = DIFF_DELETE;
|
|
}
|
|
return diffs;
|
|
}
|
|
|
|
if (shorttext.length == 1) {
|
|
// Single character string.
|
|
// After the previous speedup, the character can't be an equality.
|
|
return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
|
|
}
|
|
|
|
// Check to see if the problem can be split in two.
|
|
var hm = diff_halfMatch_(text1, text2);
|
|
if (hm) {
|
|
// A half-match was found, sort out the return data.
|
|
var text1_a = hm[0];
|
|
var text1_b = hm[1];
|
|
var text2_a = hm[2];
|
|
var text2_b = hm[3];
|
|
var mid_common = hm[4];
|
|
// Send both pairs off for separate processing.
|
|
var diffs_a = diff_main(text1_a, text2_a);
|
|
var diffs_b = diff_main(text1_b, text2_b);
|
|
// Merge the results.
|
|
return diffs_a.concat([[DIFF_EQUAL, mid_common]], diffs_b);
|
|
}
|
|
|
|
return diff_bisect_(text1, text2);
|
|
};
|
|
|
|
|
|
/**
|
|
* Find the 'middle snake' of a diff, split the problem in two
|
|
* and return the recursively constructed diff.
|
|
* See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.
|
|
* @param {string} text1 Old string to be diffed.
|
|
* @param {string} text2 New string to be diffed.
|
|
* @return {Array} Array of diff tuples.
|
|
* @private
|
|
*/
|
|
function diff_bisect_(text1, text2) {
|
|
// Cache the text lengths to prevent multiple calls.
|
|
var text1_length = text1.length;
|
|
var text2_length = text2.length;
|
|
var max_d = Math.ceil((text1_length + text2_length) / 2);
|
|
var v_offset = max_d;
|
|
var v_length = 2 * max_d;
|
|
var v1 = new Array(v_length);
|
|
var v2 = new Array(v_length);
|
|
// Setting all elements to -1 is faster in Chrome & Firefox than mixing
|
|
// integers and undefined.
|
|
for (var x = 0; x < v_length; x++) {
|
|
v1[x] = -1;
|
|
v2[x] = -1;
|
|
}
|
|
v1[v_offset + 1] = 0;
|
|
v2[v_offset + 1] = 0;
|
|
var delta = text1_length - text2_length;
|
|
// If the total number of characters is odd, then the front path will collide
|
|
// with the reverse path.
|
|
var front = (delta % 2 != 0);
|
|
// Offsets for start and end of k loop.
|
|
// Prevents mapping of space beyond the grid.
|
|
var k1start = 0;
|
|
var k1end = 0;
|
|
var k2start = 0;
|
|
var k2end = 0;
|
|
for (var d = 0; d < max_d; d++) {
|
|
// Walk the front path one step.
|
|
for (var k1 = -d + k1start; k1 <= d - k1end; k1 += 2) {
|
|
var k1_offset = v_offset + k1;
|
|
var x1;
|
|
if (k1 == -d || (k1 != d && v1[k1_offset - 1] < v1[k1_offset + 1])) {
|
|
x1 = v1[k1_offset + 1];
|
|
} else {
|
|
x1 = v1[k1_offset - 1] + 1;
|
|
}
|
|
var y1 = x1 - k1;
|
|
while (x1 < text1_length && y1 < text2_length &&
|
|
text1.charAt(x1) == text2.charAt(y1)) {
|
|
x1++;
|
|
y1++;
|
|
}
|
|
v1[k1_offset] = x1;
|
|
if (x1 > text1_length) {
|
|
// Ran off the right of the graph.
|
|
k1end += 2;
|
|
} else if (y1 > text2_length) {
|
|
// Ran off the bottom of the graph.
|
|
k1start += 2;
|
|
} else if (front) {
|
|
var k2_offset = v_offset + delta - k1;
|
|
if (k2_offset >= 0 && k2_offset < v_length && v2[k2_offset] != -1) {
|
|
// Mirror x2 onto top-left coordinate system.
|
|
var x2 = text1_length - v2[k2_offset];
|
|
if (x1 >= x2) {
|
|
// Overlap detected.
|
|
return diff_bisectSplit_(text1, text2, x1, y1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Walk the reverse path one step.
|
|
for (var k2 = -d + k2start; k2 <= d - k2end; k2 += 2) {
|
|
var k2_offset = v_offset + k2;
|
|
var x2;
|
|
if (k2 == -d || (k2 != d && v2[k2_offset - 1] < v2[k2_offset + 1])) {
|
|
x2 = v2[k2_offset + 1];
|
|
} else {
|
|
x2 = v2[k2_offset - 1] + 1;
|
|
}
|
|
var y2 = x2 - k2;
|
|
while (x2 < text1_length && y2 < text2_length &&
|
|
text1.charAt(text1_length - x2 - 1) ==
|
|
text2.charAt(text2_length - y2 - 1)) {
|
|
x2++;
|
|
y2++;
|
|
}
|
|
v2[k2_offset] = x2;
|
|
if (x2 > text1_length) {
|
|
// Ran off the left of the graph.
|
|
k2end += 2;
|
|
} else if (y2 > text2_length) {
|
|
// Ran off the top of the graph.
|
|
k2start += 2;
|
|
} else if (!front) {
|
|
var k1_offset = v_offset + delta - k2;
|
|
if (k1_offset >= 0 && k1_offset < v_length && v1[k1_offset] != -1) {
|
|
var x1 = v1[k1_offset];
|
|
var y1 = v_offset + x1 - k1_offset;
|
|
// Mirror x2 onto top-left coordinate system.
|
|
x2 = text1_length - x2;
|
|
if (x1 >= x2) {
|
|
// Overlap detected.
|
|
return diff_bisectSplit_(text1, text2, x1, y1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// Diff took too long and hit the deadline or
|
|
// number of diffs equals number of characters, no commonality at all.
|
|
return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
|
|
};
|
|
|
|
|
|
/**
|
|
* Given the location of the 'middle snake', split the diff in two parts
|
|
* and recurse.
|
|
* @param {string} text1 Old string to be diffed.
|
|
* @param {string} text2 New string to be diffed.
|
|
* @param {number} x Index of split point in text1.
|
|
* @param {number} y Index of split point in text2.
|
|
* @return {Array} Array of diff tuples.
|
|
*/
|
|
function diff_bisectSplit_(text1, text2, x, y) {
|
|
var text1a = text1.substring(0, x);
|
|
var text2a = text2.substring(0, y);
|
|
var text1b = text1.substring(x);
|
|
var text2b = text2.substring(y);
|
|
|
|
// Compute both diffs serially.
|
|
var diffs = diff_main(text1a, text2a);
|
|
var diffsb = diff_main(text1b, text2b);
|
|
|
|
return diffs.concat(diffsb);
|
|
};
|
|
|
|
|
|
/**
|
|
* Determine the common prefix of two strings.
|
|
* @param {string} text1 First string.
|
|
* @param {string} text2 Second string.
|
|
* @return {number} The number of characters common to the start of each
|
|
* string.
|
|
*/
|
|
function diff_commonPrefix(text1, text2) {
|
|
// Quick check for common null cases.
|
|
if (!text1 || !text2 || text1.charAt(0) != text2.charAt(0)) {
|
|
return 0;
|
|
}
|
|
// Binary search.
|
|
// Performance analysis: http://neil.fraser.name/news/2007/10/09/
|
|
var pointermin = 0;
|
|
var pointermax = Math.min(text1.length, text2.length);
|
|
var pointermid = pointermax;
|
|
var pointerstart = 0;
|
|
while (pointermin < pointermid) {
|
|
if (text1.substring(pointerstart, pointermid) ==
|
|
text2.substring(pointerstart, pointermid)) {
|
|
pointermin = pointermid;
|
|
pointerstart = pointermin;
|
|
} else {
|
|
pointermax = pointermid;
|
|
}
|
|
pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
|
|
}
|
|
return pointermid;
|
|
};
|
|
|
|
|
|
/**
|
|
* Determine the common suffix of two strings.
|
|
* @param {string} text1 First string.
|
|
* @param {string} text2 Second string.
|
|
* @return {number} The number of characters common to the end of each string.
|
|
*/
|
|
function diff_commonSuffix(text1, text2) {
|
|
// Quick check for common null cases.
|
|
if (!text1 || !text2 ||
|
|
text1.charAt(text1.length - 1) != text2.charAt(text2.length - 1)) {
|
|
return 0;
|
|
}
|
|
// Binary search.
|
|
// Performance analysis: http://neil.fraser.name/news/2007/10/09/
|
|
var pointermin = 0;
|
|
var pointermax = Math.min(text1.length, text2.length);
|
|
var pointermid = pointermax;
|
|
var pointerend = 0;
|
|
while (pointermin < pointermid) {
|
|
if (text1.substring(text1.length - pointermid, text1.length - pointerend) ==
|
|
text2.substring(text2.length - pointermid, text2.length - pointerend)) {
|
|
pointermin = pointermid;
|
|
pointerend = pointermin;
|
|
} else {
|
|
pointermax = pointermid;
|
|
}
|
|
pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
|
|
}
|
|
return pointermid;
|
|
};
|
|
|
|
|
|
/**
|
|
* Do the two texts share a substring which is at least half the length of the
|
|
* longer text?
|
|
* This speedup can produce non-minimal diffs.
|
|
* @param {string} text1 First string.
|
|
* @param {string} text2 Second string.
|
|
* @return {Array.<string>} Five element Array, containing the prefix of
|
|
* text1, the suffix of text1, the prefix of text2, the suffix of
|
|
* text2 and the common middle. Or null if there was no match.
|
|
*/
|
|
function diff_halfMatch_(text1, text2) {
|
|
var longtext = text1.length > text2.length ? text1 : text2;
|
|
var shorttext = text1.length > text2.length ? text2 : text1;
|
|
if (longtext.length < 4 || shorttext.length * 2 < longtext.length) {
|
|
return null; // Pointless.
|
|
}
|
|
|
|
/**
|
|
* Does a substring of shorttext exist within longtext such that the substring
|
|
* is at least half the length of longtext?
|
|
* Closure, but does not reference any external variables.
|
|
* @param {string} longtext Longer string.
|
|
* @param {string} shorttext Shorter string.
|
|
* @param {number} i Start index of quarter length substring within longtext.
|
|
* @return {Array.<string>} Five element Array, containing the prefix of
|
|
* longtext, the suffix of longtext, the prefix of shorttext, the suffix
|
|
* of shorttext and the common middle. Or null if there was no match.
|
|
* @private
|
|
*/
|
|
function diff_halfMatchI_(longtext, shorttext, i) {
|
|
// Start with a 1/4 length substring at position i as a seed.
|
|
var seed = longtext.substring(i, i + Math.floor(longtext.length / 4));
|
|
var j = -1;
|
|
var best_common = '';
|
|
var best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b;
|
|
while ((j = shorttext.indexOf(seed, j + 1)) != -1) {
|
|
var prefixLength = diff_commonPrefix(longtext.substring(i),
|
|
shorttext.substring(j));
|
|
var suffixLength = diff_commonSuffix(longtext.substring(0, i),
|
|
shorttext.substring(0, j));
|
|
if (best_common.length < suffixLength + prefixLength) {
|
|
best_common = shorttext.substring(j - suffixLength, j) +
|
|
shorttext.substring(j, j + prefixLength);
|
|
best_longtext_a = longtext.substring(0, i - suffixLength);
|
|
best_longtext_b = longtext.substring(i + prefixLength);
|
|
best_shorttext_a = shorttext.substring(0, j - suffixLength);
|
|
best_shorttext_b = shorttext.substring(j + prefixLength);
|
|
}
|
|
}
|
|
if (best_common.length * 2 >= longtext.length) {
|
|
return [best_longtext_a, best_longtext_b,
|
|
best_shorttext_a, best_shorttext_b, best_common];
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
// First check if the second quarter is the seed for a half-match.
|
|
var hm1 = diff_halfMatchI_(longtext, shorttext,
|
|
Math.ceil(longtext.length / 4));
|
|
// Check again based on the third quarter.
|
|
var hm2 = diff_halfMatchI_(longtext, shorttext,
|
|
Math.ceil(longtext.length / 2));
|
|
var hm;
|
|
if (!hm1 && !hm2) {
|
|
return null;
|
|
} else if (!hm2) {
|
|
hm = hm1;
|
|
} else if (!hm1) {
|
|
hm = hm2;
|
|
} else {
|
|
// Both matched. Select the longest.
|
|
hm = hm1[4].length > hm2[4].length ? hm1 : hm2;
|
|
}
|
|
|
|
// A half-match was found, sort out the return data.
|
|
var text1_a, text1_b, text2_a, text2_b;
|
|
if (text1.length > text2.length) {
|
|
text1_a = hm[0];
|
|
text1_b = hm[1];
|
|
text2_a = hm[2];
|
|
text2_b = hm[3];
|
|
} else {
|
|
text2_a = hm[0];
|
|
text2_b = hm[1];
|
|
text1_a = hm[2];
|
|
text1_b = hm[3];
|
|
}
|
|
var mid_common = hm[4];
|
|
return [text1_a, text1_b, text2_a, text2_b, mid_common];
|
|
};
|
|
|
|
|
|
/**
|
|
* Reorder and merge like edit sections. Merge equalities.
|
|
* Any edit section can move as long as it doesn't cross an equality.
|
|
* @param {Array} diffs Array of diff tuples.
|
|
*/
|
|
function diff_cleanupMerge(diffs) {
|
|
diffs.push([DIFF_EQUAL, '']); // Add a dummy entry at the end.
|
|
var pointer = 0;
|
|
var count_delete = 0;
|
|
var count_insert = 0;
|
|
var text_delete = '';
|
|
var text_insert = '';
|
|
var commonlength;
|
|
while (pointer < diffs.length) {
|
|
switch (diffs[pointer][0]) {
|
|
case DIFF_INSERT:
|
|
count_insert++;
|
|
text_insert += diffs[pointer][1];
|
|
pointer++;
|
|
break;
|
|
case DIFF_DELETE:
|
|
count_delete++;
|
|
text_delete += diffs[pointer][1];
|
|
pointer++;
|
|
break;
|
|
case DIFF_EQUAL:
|
|
// Upon reaching an equality, check for prior redundancies.
|
|
if (count_delete + count_insert > 1) {
|
|
if (count_delete !== 0 && count_insert !== 0) {
|
|
// Factor out any common prefixies.
|
|
commonlength = diff_commonPrefix(text_insert, text_delete);
|
|
if (commonlength !== 0) {
|
|
if ((pointer - count_delete - count_insert) > 0 &&
|
|
diffs[pointer - count_delete - count_insert - 1][0] ==
|
|
DIFF_EQUAL) {
|
|
diffs[pointer - count_delete - count_insert - 1][1] +=
|
|
text_insert.substring(0, commonlength);
|
|
} else {
|
|
diffs.splice(0, 0, [DIFF_EQUAL,
|
|
text_insert.substring(0, commonlength)]);
|
|
pointer++;
|
|
}
|
|
text_insert = text_insert.substring(commonlength);
|
|
text_delete = text_delete.substring(commonlength);
|
|
}
|
|
// Factor out any common suffixies.
|
|
commonlength = diff_commonSuffix(text_insert, text_delete);
|
|
if (commonlength !== 0) {
|
|
diffs[pointer][1] = text_insert.substring(text_insert.length -
|
|
commonlength) + diffs[pointer][1];
|
|
text_insert = text_insert.substring(0, text_insert.length -
|
|
commonlength);
|
|
text_delete = text_delete.substring(0, text_delete.length -
|
|
commonlength);
|
|
}
|
|
}
|
|
// Delete the offending records and add the merged ones.
|
|
if (count_delete === 0) {
|
|
diffs.splice(pointer - count_insert,
|
|
count_delete + count_insert, [DIFF_INSERT, text_insert]);
|
|
} else if (count_insert === 0) {
|
|
diffs.splice(pointer - count_delete,
|
|
count_delete + count_insert, [DIFF_DELETE, text_delete]);
|
|
} else {
|
|
diffs.splice(pointer - count_delete - count_insert,
|
|
count_delete + count_insert, [DIFF_DELETE, text_delete],
|
|
[DIFF_INSERT, text_insert]);
|
|
}
|
|
pointer = pointer - count_delete - count_insert +
|
|
(count_delete ? 1 : 0) + (count_insert ? 1 : 0) + 1;
|
|
} else if (pointer !== 0 && diffs[pointer - 1][0] == DIFF_EQUAL) {
|
|
// Merge this equality with the previous one.
|
|
diffs[pointer - 1][1] += diffs[pointer][1];
|
|
diffs.splice(pointer, 1);
|
|
} else {
|
|
pointer++;
|
|
}
|
|
count_insert = 0;
|
|
count_delete = 0;
|
|
text_delete = '';
|
|
text_insert = '';
|
|
break;
|
|
}
|
|
}
|
|
if (diffs[diffs.length - 1][1] === '') {
|
|
diffs.pop(); // Remove the dummy entry at the end.
|
|
}
|
|
|
|
// Second pass: look for single edits surrounded on both sides by equalities
|
|
// which can be shifted sideways to eliminate an equality.
|
|
// e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC
|
|
var changes = false;
|
|
pointer = 1;
|
|
// Intentionally ignore the first and last element (don't need checking).
|
|
while (pointer < diffs.length - 1) {
|
|
if (diffs[pointer - 1][0] == DIFF_EQUAL &&
|
|
diffs[pointer + 1][0] == DIFF_EQUAL) {
|
|
// This is a single edit surrounded by equalities.
|
|
if (diffs[pointer][1].substring(diffs[pointer][1].length -
|
|
diffs[pointer - 1][1].length) == diffs[pointer - 1][1]) {
|
|
// Shift the edit over the previous equality.
|
|
diffs[pointer][1] = diffs[pointer - 1][1] +
|
|
diffs[pointer][1].substring(0, diffs[pointer][1].length -
|
|
diffs[pointer - 1][1].length);
|
|
diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1];
|
|
diffs.splice(pointer - 1, 1);
|
|
changes = true;
|
|
} else if (diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) ==
|
|
diffs[pointer + 1][1]) {
|
|
// Shift the edit over the next equality.
|
|
diffs[pointer - 1][1] += diffs[pointer + 1][1];
|
|
diffs[pointer][1] =
|
|
diffs[pointer][1].substring(diffs[pointer + 1][1].length) +
|
|
diffs[pointer + 1][1];
|
|
diffs.splice(pointer + 1, 1);
|
|
changes = true;
|
|
}
|
|
}
|
|
pointer++;
|
|
}
|
|
// If shifts were made, the diff needs reordering and another shift sweep.
|
|
if (changes) {
|
|
diff_cleanupMerge(diffs);
|
|
}
|
|
};
|
|
|
|
|
|
var diff = diff_main;
|
|
diff.INSERT = DIFF_INSERT;
|
|
diff.DELETE = DIFF_DELETE;
|
|
diff.EQUAL = DIFF_EQUAL;
|
|
|
|
module.exports = diff;
|
|
|
|
/*
|
|
* Modify a diff such that the cursor position points to the start of a change:
|
|
* E.g.
|
|
* cursor_normalize_diff([[DIFF_EQUAL, 'abc']], 1)
|
|
* => [1, [[DIFF_EQUAL, 'a'], [DIFF_EQUAL, 'bc']]]
|
|
* cursor_normalize_diff([[DIFF_INSERT, 'new'], [DIFF_DELETE, 'xyz']], 2)
|
|
* => [2, [[DIFF_INSERT, 'new'], [DIFF_DELETE, 'xy'], [DIFF_DELETE, 'z']]]
|
|
*
|
|
* @param {Array} diffs Array of diff tuples
|
|
* @param {Int} cursor_pos Suggested edit position. Must not be out of bounds!
|
|
* @return {Array} A tuple [cursor location in the modified diff, modified diff]
|
|
*/
|
|
function cursor_normalize_diff (diffs, cursor_pos) {
|
|
if (cursor_pos === 0) {
|
|
return [DIFF_EQUAL, diffs];
|
|
}
|
|
for (var current_pos = 0, i = 0; i < diffs.length; i++) {
|
|
var d = diffs[i];
|
|
if (d[0] === DIFF_DELETE || d[0] === DIFF_EQUAL) {
|
|
var next_pos = current_pos + d[1].length;
|
|
if (cursor_pos === next_pos) {
|
|
return [i + 1, diffs];
|
|
} else if (cursor_pos < next_pos) {
|
|
// copy to prevent side effects
|
|
diffs = diffs.slice();
|
|
// split d into two diff changes
|
|
var split_pos = cursor_pos - current_pos;
|
|
var d_left = [d[0], d[1].slice(0, split_pos)];
|
|
var d_right = [d[0], d[1].slice(split_pos)];
|
|
diffs.splice(i, 1, d_left, d_right);
|
|
return [i + 1, diffs];
|
|
} else {
|
|
current_pos = next_pos;
|
|
}
|
|
}
|
|
}
|
|
throw new Error('cursor_pos is out of bounds!')
|
|
}
|
|
|
|
/*
|
|
* Modify a diff such that the edit position is "shifted" to the proposed edit location (cursor_position).
|
|
*
|
|
* Case 1)
|
|
* Check if a naive shift is possible:
|
|
* [0, X], [ 1, Y] -> [ 1, Y], [0, X] (if X + Y === Y + X)
|
|
* [0, X], [-1, Y] -> [-1, Y], [0, X] (if X + Y === Y + X) - holds same result
|
|
* Case 2)
|
|
* Check if the following shifts are possible:
|
|
* [0, 'pre'], [ 1, 'prefix'] -> [ 1, 'pre'], [0, 'pre'], [ 1, 'fix']
|
|
* [0, 'pre'], [-1, 'prefix'] -> [-1, 'pre'], [0, 'pre'], [-1, 'fix']
|
|
* ^ ^
|
|
* d d_next
|
|
*
|
|
* @param {Array} diffs Array of diff tuples
|
|
* @param {Int} cursor_pos Suggested edit position. Must not be out of bounds!
|
|
* @return {Array} Array of diff tuples
|
|
*/
|
|
function fix_cursor (diffs, cursor_pos) {
|
|
var norm = cursor_normalize_diff(diffs, cursor_pos);
|
|
var ndiffs = norm[1];
|
|
var cursor_pointer = norm[0];
|
|
var d = ndiffs[cursor_pointer];
|
|
var d_next = ndiffs[cursor_pointer + 1];
|
|
|
|
if (d == null) {
|
|
// Text was deleted from end of original string,
|
|
// cursor is now out of bounds in new string
|
|
return diffs;
|
|
} else if (d[0] !== DIFF_EQUAL) {
|
|
// A modification happened at the cursor location.
|
|
// This is the expected outcome, so we can return the original diff.
|
|
return diffs;
|
|
} else {
|
|
if (d_next != null && d[1] + d_next[1] === d_next[1] + d[1]) {
|
|
// Case 1)
|
|
// It is possible to perform a naive shift
|
|
ndiffs.splice(cursor_pointer, 2, d_next, d)
|
|
return merge_tuples(ndiffs, cursor_pointer, 2)
|
|
} else if (d_next != null && d_next[1].indexOf(d[1]) === 0) {
|
|
// Case 2)
|
|
// d[1] is a prefix of d_next[1]
|
|
// We can assume that d_next[0] !== 0, since d[0] === 0
|
|
// Shift edit locations..
|
|
ndiffs.splice(cursor_pointer, 2, [d_next[0], d[1]], [0, d[1]]);
|
|
var suffix = d_next[1].slice(d[1].length);
|
|
if (suffix.length > 0) {
|
|
ndiffs.splice(cursor_pointer + 2, 0, [d_next[0], suffix]);
|
|
}
|
|
return merge_tuples(ndiffs, cursor_pointer, 3)
|
|
} else {
|
|
// Not possible to perform any modification
|
|
return diffs;
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Check diff did not split surrogate pairs.
|
|
* Ex. [0, '\uD83D'], [-1, '\uDC36'], [1, '\uDC2F'] -> [-1, '\uD83D\uDC36'], [1, '\uD83D\uDC2F']
|
|
* '\uD83D\uDC36' === '🐶', '\uD83D\uDC2F' === '🐯'
|
|
*
|
|
* @param {Array} diffs Array of diff tuples
|
|
* @return {Array} Array of diff tuples
|
|
*/
|
|
function fix_emoji (diffs) {
|
|
var compact = false;
|
|
var starts_with_pair_end = function(str) {
|
|
return str.charCodeAt(0) >= 0xDC00 && str.charCodeAt(0) <= 0xDFFF;
|
|
}
|
|
var ends_with_pair_start = function(str) {
|
|
return str.charCodeAt(str.length-1) >= 0xD800 && str.charCodeAt(str.length-1) <= 0xDBFF;
|
|
}
|
|
for (var i = 2; i < diffs.length; i += 1) {
|
|
if (diffs[i-2][0] === DIFF_EQUAL && ends_with_pair_start(diffs[i-2][1]) &&
|
|
diffs[i-1][0] === DIFF_DELETE && starts_with_pair_end(diffs[i-1][1]) &&
|
|
diffs[i][0] === DIFF_INSERT && starts_with_pair_end(diffs[i][1])) {
|
|
compact = true;
|
|
|
|
diffs[i-1][1] = diffs[i-2][1].slice(-1) + diffs[i-1][1];
|
|
diffs[i][1] = diffs[i-2][1].slice(-1) + diffs[i][1];
|
|
|
|
diffs[i-2][1] = diffs[i-2][1].slice(0, -1);
|
|
}
|
|
}
|
|
if (!compact) {
|
|
return diffs;
|
|
}
|
|
var fixed_diffs = [];
|
|
for (var i = 0; i < diffs.length; i += 1) {
|
|
if (diffs[i][1].length > 0) {
|
|
fixed_diffs.push(diffs[i]);
|
|
}
|
|
}
|
|
return fixed_diffs;
|
|
}
|
|
|
|
/*
|
|
* Try to merge tuples with their neigbors in a given range.
|
|
* E.g. [0, 'a'], [0, 'b'] -> [0, 'ab']
|
|
*
|
|
* @param {Array} diffs Array of diff tuples.
|
|
* @param {Int} start Position of the first element to merge (diffs[start] is also merged with diffs[start - 1]).
|
|
* @param {Int} length Number of consecutive elements to check.
|
|
* @return {Array} Array of merged diff tuples.
|
|
*/
|
|
function merge_tuples (diffs, start, length) {
|
|
// Check from (start-1) to (start+length).
|
|
for (var i = start + length - 1; i >= 0 && i >= start - 1; i--) {
|
|
if (i + 1 < diffs.length) {
|
|
var left_d = diffs[i];
|
|
var right_d = diffs[i+1];
|
|
if (left_d[0] === right_d[1]) {
|
|
diffs.splice(i, 2, [left_d[0], left_d[1] + right_d[1]]);
|
|
}
|
|
}
|
|
}
|
|
return diffs;
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
/* 52 */
|
|
/***/ (function(module, exports) {
|
|
|
|
exports = module.exports = typeof Object.keys === 'function'
|
|
? Object.keys : shim;
|
|
|
|
exports.shim = shim;
|
|
function shim (obj) {
|
|
var keys = [];
|
|
for (var key in obj) keys.push(key);
|
|
return keys;
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
/* 53 */
|
|
/***/ (function(module, exports) {
|
|
|
|
var supportsArgumentsClass = (function(){
|
|
return Object.prototype.toString.call(arguments)
|
|
})() == '[object Arguments]';
|
|
|
|
exports = module.exports = supportsArgumentsClass ? supported : unsupported;
|
|
|
|
exports.supported = supported;
|
|
function supported(object) {
|
|
return Object.prototype.toString.call(object) == '[object Arguments]';
|
|
};
|
|
|
|
exports.unsupported = unsupported;
|
|
function unsupported(object){
|
|
return object &&
|
|
typeof object == 'object' &&
|
|
typeof object.length == 'number' &&
|
|
Object.prototype.hasOwnProperty.call(object, 'callee') &&
|
|
!Object.prototype.propertyIsEnumerable.call(object, 'callee') ||
|
|
false;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
/* 54 */
|
|
/***/ (function(module, exports) {
|
|
|
|
'use strict';
|
|
|
|
var has = Object.prototype.hasOwnProperty
|
|
, prefix = '~';
|
|
|
|
/**
|
|
* Constructor to create a storage for our `EE` objects.
|
|
* An `Events` instance is a plain object whose properties are event names.
|
|
*
|
|
* @constructor
|
|
* @api private
|
|
*/
|
|
function Events() {}
|
|
|
|
//
|
|
// We try to not inherit from `Object.prototype`. In some engines creating an
|
|
// instance in this way is faster than calling `Object.create(null)` directly.
|
|
// If `Object.create(null)` is not supported we prefix the event names with a
|
|
// character to make sure that the built-in object properties are not
|
|
// overridden or used as an attack vector.
|
|
//
|
|
if (Object.create) {
|
|
Events.prototype = Object.create(null);
|
|
|
|
//
|
|
// This hack is needed because the `__proto__` property is still inherited in
|
|
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
|
|
//
|
|
if (!new Events().__proto__) prefix = false;
|
|
}
|
|
|
|
/**
|
|
* Representation of a single event listener.
|
|
*
|
|
* @param {Function} fn The listener function.
|
|
* @param {Mixed} context The context to invoke the listener with.
|
|
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
* @constructor
|
|
* @api private
|
|
*/
|
|
function EE(fn, context, once) {
|
|
this.fn = fn;
|
|
this.context = context;
|
|
this.once = once || false;
|
|
}
|
|
|
|
/**
|
|
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
* `EventEmitter` interface.
|
|
*
|
|
* @constructor
|
|
* @api public
|
|
*/
|
|
function EventEmitter() {
|
|
this._events = new Events();
|
|
this._eventsCount = 0;
|
|
}
|
|
|
|
/**
|
|
* Return an array listing the events for which the emitter has registered
|
|
* listeners.
|
|
*
|
|
* @returns {Array}
|
|
* @api public
|
|
*/
|
|
EventEmitter.prototype.eventNames = function eventNames() {
|
|
var names = []
|
|
, events
|
|
, name;
|
|
|
|
if (this._eventsCount === 0) return names;
|
|
|
|
for (name in (events = this._events)) {
|
|
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
}
|
|
|
|
if (Object.getOwnPropertySymbols) {
|
|
return names.concat(Object.getOwnPropertySymbols(events));
|
|
}
|
|
|
|
return names;
|
|
};
|
|
|
|
/**
|
|
* Return the listeners registered for a given event.
|
|
*
|
|
* @param {String|Symbol} event The event name.
|
|
* @param {Boolean} exists Only check if there are listeners.
|
|
* @returns {Array|Boolean}
|
|
* @api public
|
|
*/
|
|
EventEmitter.prototype.listeners = function listeners(event, exists) {
|
|
var evt = prefix ? prefix + event : event
|
|
, available = this._events[evt];
|
|
|
|
if (exists) return !!available;
|
|
if (!available) return [];
|
|
if (available.fn) return [available.fn];
|
|
|
|
for (var i = 0, l = available.length, ee = new Array(l); i < l; i++) {
|
|
ee[i] = available[i].fn;
|
|
}
|
|
|
|
return ee;
|
|
};
|
|
|
|
/**
|
|
* Calls each of the listeners registered for a given event.
|
|
*
|
|
* @param {String|Symbol} event The event name.
|
|
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
* @api public
|
|
*/
|
|
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
var evt = prefix ? prefix + event : event;
|
|
|
|
if (!this._events[evt]) return false;
|
|
|
|
var listeners = this._events[evt]
|
|
, len = arguments.length
|
|
, args
|
|
, i;
|
|
|
|
if (listeners.fn) {
|
|
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
|
|
|
switch (len) {
|
|
case 1: return listeners.fn.call(listeners.context), true;
|
|
case 2: return listeners.fn.call(listeners.context, a1), true;
|
|
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
|
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
}
|
|
|
|
for (i = 1, args = new Array(len -1); i < len; i++) {
|
|
args[i - 1] = arguments[i];
|
|
}
|
|
|
|
listeners.fn.apply(listeners.context, args);
|
|
} else {
|
|
var length = listeners.length
|
|
, j;
|
|
|
|
for (i = 0; i < length; i++) {
|
|
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
|
|
|
switch (len) {
|
|
case 1: listeners[i].fn.call(listeners[i].context); break;
|
|
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
|
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
|
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
|
default:
|
|
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
|
args[j - 1] = arguments[j];
|
|
}
|
|
|
|
listeners[i].fn.apply(listeners[i].context, args);
|
|
}
|
|
}
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
/**
|
|
* Add a listener for a given event.
|
|
*
|
|
* @param {String|Symbol} event The event name.
|
|
* @param {Function} fn The listener function.
|
|
* @param {Mixed} [context=this] The context to invoke the listener with.
|
|
* @returns {EventEmitter} `this`.
|
|
* @api public
|
|
*/
|
|
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
var listener = new EE(fn, context || this)
|
|
, evt = prefix ? prefix + event : event;
|
|
|
|
if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;
|
|
else if (!this._events[evt].fn) this._events[evt].push(listener);
|
|
else this._events[evt] = [this._events[evt], listener];
|
|
|
|
return this;
|
|
};
|
|
|
|
/**
|
|
* Add a one-time listener for a given event.
|
|
*
|
|
* @param {String|Symbol} event The event name.
|
|
* @param {Function} fn The listener function.
|
|
* @param {Mixed} [context=this] The context to invoke the listener with.
|
|
* @returns {EventEmitter} `this`.
|
|
* @api public
|
|
*/
|
|
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
var listener = new EE(fn, context || this, true)
|
|
, evt = prefix ? prefix + event : event;
|
|
|
|
if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;
|
|
else if (!this._events[evt].fn) this._events[evt].push(listener);
|
|
else this._events[evt] = [this._events[evt], listener];
|
|
|
|
return this;
|
|
};
|
|
|
|
/**
|
|
* Remove the listeners of a given event.
|
|
*
|
|
* @param {String|Symbol} event The event name.
|
|
* @param {Function} fn Only remove the listeners that match this function.
|
|
* @param {Mixed} context Only remove the listeners that have this context.
|
|
* @param {Boolean} once Only remove one-time listeners.
|
|
* @returns {EventEmitter} `this`.
|
|
* @api public
|
|
*/
|
|
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
var evt = prefix ? prefix + event : event;
|
|
|
|
if (!this._events[evt]) return this;
|
|
if (!fn) {
|
|
if (--this._eventsCount === 0) this._events = new Events();
|
|
else delete this._events[evt];
|
|
return this;
|
|
}
|
|
|
|
var listeners = this._events[evt];
|
|
|
|
if (listeners.fn) {
|
|
if (
|
|
listeners.fn === fn
|
|
&& (!once || listeners.once)
|
|
&& (!context || listeners.context === context)
|
|
) {
|
|
if (--this._eventsCount === 0) this._events = new Events();
|
|
else delete this._events[evt];
|
|
}
|
|
} else {
|
|
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
|
if (
|
|
listeners[i].fn !== fn
|
|
|| (once && !listeners[i].once)
|
|
|| (context && listeners[i].context !== context)
|
|
) {
|
|
events.push(listeners[i]);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Reset the array, or remove it completely if we have no more listeners.
|
|
//
|
|
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
|
else if (--this._eventsCount === 0) this._events = new Events();
|
|
else delete this._events[evt];
|
|
}
|
|
|
|
return this;
|
|
};
|
|
|
|
/**
|
|
* Remove all listeners, or those of the specified event.
|
|
*
|
|
* @param {String|Symbol} [event] The event name.
|
|
* @returns {EventEmitter} `this`.
|
|
* @api public
|
|
*/
|
|
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
var evt;
|
|
|
|
if (event) {
|
|
evt = prefix ? prefix + event : event;
|
|
if (this._events[evt]) {
|
|
if (--this._eventsCount === 0) this._events = new Events();
|
|
else delete this._events[evt];
|
|
}
|
|
} else {
|
|
this._events = new Events();
|
|
this._eventsCount = 0;
|
|
}
|
|
|
|
return this;
|
|
};
|
|
|
|
//
|
|
// Alias methods names because people roll like that.
|
|
//
|
|
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
|
|
//
|
|
// This function doesn't apply anymore.
|
|
//
|
|
EventEmitter.prototype.setMaxListeners = function setMaxListeners() {
|
|
return this;
|
|
};
|
|
|
|
//
|
|
// Expose the prefix.
|
|
//
|
|
EventEmitter.prefixed = prefix;
|
|
|
|
//
|
|
// Allow `EventEmitter` to be imported as module namespace.
|
|
//
|
|
EventEmitter.EventEmitter = EventEmitter;
|
|
|
|
//
|
|
// Expose the module.
|
|
//
|
|
if ('undefined' !== typeof module) {
|
|
module.exports = EventEmitter;
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
/* 55 */
|
|
/***/ (function(module, exports, __nested_webpack_require_316416__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.matchText = exports.matchSpacing = exports.matchNewline = exports.matchBlot = exports.matchAttributor = exports.default = undefined;
|
|
|
|
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
|
|
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _extend2 = __nested_webpack_require_316416__(3);
|
|
|
|
var _extend3 = _interopRequireDefault(_extend2);
|
|
|
|
var _quillDelta = __nested_webpack_require_316416__(2);
|
|
|
|
var _quillDelta2 = _interopRequireDefault(_quillDelta);
|
|
|
|
var _parchment = __nested_webpack_require_316416__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
var _quill = __nested_webpack_require_316416__(5);
|
|
|
|
var _quill2 = _interopRequireDefault(_quill);
|
|
|
|
var _logger = __nested_webpack_require_316416__(10);
|
|
|
|
var _logger2 = _interopRequireDefault(_logger);
|
|
|
|
var _module = __nested_webpack_require_316416__(9);
|
|
|
|
var _module2 = _interopRequireDefault(_module);
|
|
|
|
var _align = __nested_webpack_require_316416__(36);
|
|
|
|
var _background = __nested_webpack_require_316416__(37);
|
|
|
|
var _code = __nested_webpack_require_316416__(13);
|
|
|
|
var _code2 = _interopRequireDefault(_code);
|
|
|
|
var _color = __nested_webpack_require_316416__(26);
|
|
|
|
var _direction = __nested_webpack_require_316416__(38);
|
|
|
|
var _font = __nested_webpack_require_316416__(39);
|
|
|
|
var _size = __nested_webpack_require_316416__(40);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var debug = (0, _logger2.default)('quill:clipboard');
|
|
|
|
var DOM_KEY = '__ql-matcher';
|
|
|
|
var CLIPBOARD_CONFIG = [[Node.TEXT_NODE, matchText], [Node.TEXT_NODE, matchNewline], ['br', matchBreak], [Node.ELEMENT_NODE, matchNewline], [Node.ELEMENT_NODE, matchBlot], [Node.ELEMENT_NODE, matchSpacing], [Node.ELEMENT_NODE, matchAttributor], [Node.ELEMENT_NODE, matchStyles], ['li', matchIndent], ['b', matchAlias.bind(matchAlias, 'bold')], ['i', matchAlias.bind(matchAlias, 'italic')], ['style', matchIgnore]];
|
|
|
|
var ATTRIBUTE_ATTRIBUTORS = [_align.AlignAttribute, _direction.DirectionAttribute].reduce(function (memo, attr) {
|
|
memo[attr.keyName] = attr;
|
|
return memo;
|
|
}, {});
|
|
|
|
var STYLE_ATTRIBUTORS = [_align.AlignStyle, _background.BackgroundStyle, _color.ColorStyle, _direction.DirectionStyle, _font.FontStyle, _size.SizeStyle].reduce(function (memo, attr) {
|
|
memo[attr.keyName] = attr;
|
|
return memo;
|
|
}, {});
|
|
|
|
var Clipboard = function (_Module) {
|
|
_inherits(Clipboard, _Module);
|
|
|
|
function Clipboard(quill, options) {
|
|
_classCallCheck(this, Clipboard);
|
|
|
|
var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this, quill, options));
|
|
|
|
_this.quill.root.addEventListener('paste', _this.onPaste.bind(_this));
|
|
_this.container = _this.quill.addContainer('ql-clipboard');
|
|
_this.container.setAttribute('contenteditable', true);
|
|
_this.container.setAttribute('tabindex', -1);
|
|
_this.matchers = [];
|
|
CLIPBOARD_CONFIG.concat(_this.options.matchers).forEach(function (_ref) {
|
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
selector = _ref2[0],
|
|
matcher = _ref2[1];
|
|
|
|
if (!options.matchVisual && matcher === matchSpacing) return;
|
|
_this.addMatcher(selector, matcher);
|
|
});
|
|
return _this;
|
|
}
|
|
|
|
_createClass(Clipboard, [{
|
|
key: 'addMatcher',
|
|
value: function addMatcher(selector, matcher) {
|
|
this.matchers.push([selector, matcher]);
|
|
}
|
|
}, {
|
|
key: 'convert',
|
|
value: function convert(html) {
|
|
if (typeof html === 'string') {
|
|
this.container.innerHTML = html.replace(/\>\r?\n +\</g, '><'); // Remove spaces between tags
|
|
return this.convert();
|
|
}
|
|
var formats = this.quill.getFormat(this.quill.selection.savedRange.index);
|
|
if (formats[_code2.default.blotName]) {
|
|
var text = this.container.innerText;
|
|
this.container.innerHTML = '';
|
|
return new _quillDelta2.default().insert(text, _defineProperty({}, _code2.default.blotName, formats[_code2.default.blotName]));
|
|
}
|
|
|
|
var _prepareMatching = this.prepareMatching(),
|
|
_prepareMatching2 = _slicedToArray(_prepareMatching, 2),
|
|
elementMatchers = _prepareMatching2[0],
|
|
textMatchers = _prepareMatching2[1];
|
|
|
|
var delta = traverse(this.container, elementMatchers, textMatchers);
|
|
// Remove trailing newline
|
|
if (deltaEndsWith(delta, '\n') && delta.ops[delta.ops.length - 1].attributes == null) {
|
|
delta = delta.compose(new _quillDelta2.default().retain(delta.length() - 1).delete(1));
|
|
}
|
|
debug.log('convert', this.container.innerHTML, delta);
|
|
this.container.innerHTML = '';
|
|
return delta;
|
|
}
|
|
}, {
|
|
key: 'dangerouslyPasteHTML',
|
|
value: function dangerouslyPasteHTML(index, html) {
|
|
var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _quill2.default.sources.API;
|
|
|
|
if (typeof index === 'string') {
|
|
this.quill.setContents(this.convert(index), html);
|
|
this.quill.setSelection(0, _quill2.default.sources.SILENT);
|
|
} else {
|
|
var paste = this.convert(html);
|
|
this.quill.updateContents(new _quillDelta2.default().retain(index).concat(paste), source);
|
|
this.quill.setSelection(index + paste.length(), _quill2.default.sources.SILENT);
|
|
}
|
|
}
|
|
}, {
|
|
key: 'onPaste',
|
|
value: function onPaste(e) {
|
|
var _this2 = this;
|
|
|
|
if (e.defaultPrevented || !this.quill.isEnabled()) return;
|
|
var range = this.quill.getSelection();
|
|
var delta = new _quillDelta2.default().retain(range.index);
|
|
var scrollTop = this.quill.scrollingContainer.scrollTop;
|
|
this.container.focus();
|
|
this.quill.selection.update(_quill2.default.sources.SILENT);
|
|
setTimeout(function () {
|
|
delta = delta.concat(_this2.convert()).delete(range.length);
|
|
_this2.quill.updateContents(delta, _quill2.default.sources.USER);
|
|
// range.length contributes to delta.length()
|
|
_this2.quill.setSelection(delta.length() - range.length, _quill2.default.sources.SILENT);
|
|
_this2.quill.scrollingContainer.scrollTop = scrollTop;
|
|
_this2.quill.focus();
|
|
}, 1);
|
|
}
|
|
}, {
|
|
key: 'prepareMatching',
|
|
value: function prepareMatching() {
|
|
var _this3 = this;
|
|
|
|
var elementMatchers = [],
|
|
textMatchers = [];
|
|
this.matchers.forEach(function (pair) {
|
|
var _pair = _slicedToArray(pair, 2),
|
|
selector = _pair[0],
|
|
matcher = _pair[1];
|
|
|
|
switch (selector) {
|
|
case Node.TEXT_NODE:
|
|
textMatchers.push(matcher);
|
|
break;
|
|
case Node.ELEMENT_NODE:
|
|
elementMatchers.push(matcher);
|
|
break;
|
|
default:
|
|
[].forEach.call(_this3.container.querySelectorAll(selector), function (node) {
|
|
// TODO use weakmap
|
|
node[DOM_KEY] = node[DOM_KEY] || [];
|
|
node[DOM_KEY].push(matcher);
|
|
});
|
|
break;
|
|
}
|
|
});
|
|
return [elementMatchers, textMatchers];
|
|
}
|
|
}]);
|
|
|
|
return Clipboard;
|
|
}(_module2.default);
|
|
|
|
Clipboard.DEFAULTS = {
|
|
matchers: [],
|
|
matchVisual: true
|
|
};
|
|
|
|
function applyFormat(delta, format, value) {
|
|
if ((typeof format === 'undefined' ? 'undefined' : _typeof(format)) === 'object') {
|
|
return Object.keys(format).reduce(function (delta, key) {
|
|
return applyFormat(delta, key, format[key]);
|
|
}, delta);
|
|
} else {
|
|
return delta.reduce(function (delta, op) {
|
|
if (op.attributes && op.attributes[format]) {
|
|
return delta.push(op);
|
|
} else {
|
|
return delta.insert(op.insert, (0, _extend3.default)({}, _defineProperty({}, format, value), op.attributes));
|
|
}
|
|
}, new _quillDelta2.default());
|
|
}
|
|
}
|
|
|
|
function computeStyle(node) {
|
|
if (node.nodeType !== Node.ELEMENT_NODE) return {};
|
|
var DOM_KEY = '__ql-computed-style';
|
|
return node[DOM_KEY] || (node[DOM_KEY] = window.getComputedStyle(node));
|
|
}
|
|
|
|
function deltaEndsWith(delta, text) {
|
|
var endText = "";
|
|
for (var i = delta.ops.length - 1; i >= 0 && endText.length < text.length; --i) {
|
|
var op = delta.ops[i];
|
|
if (typeof op.insert !== 'string') break;
|
|
endText = op.insert + endText;
|
|
}
|
|
return endText.slice(-1 * text.length) === text;
|
|
}
|
|
|
|
function isLine(node) {
|
|
if (node.childNodes.length === 0) return false; // Exclude embed blocks
|
|
var style = computeStyle(node);
|
|
return ['block', 'list-item'].indexOf(style.display) > -1;
|
|
}
|
|
|
|
function traverse(node, elementMatchers, textMatchers) {
|
|
// Post-order
|
|
if (node.nodeType === node.TEXT_NODE) {
|
|
return textMatchers.reduce(function (delta, matcher) {
|
|
return matcher(node, delta);
|
|
}, new _quillDelta2.default());
|
|
} else if (node.nodeType === node.ELEMENT_NODE) {
|
|
return [].reduce.call(node.childNodes || [], function (delta, childNode) {
|
|
var childrenDelta = traverse(childNode, elementMatchers, textMatchers);
|
|
if (childNode.nodeType === node.ELEMENT_NODE) {
|
|
childrenDelta = elementMatchers.reduce(function (childrenDelta, matcher) {
|
|
return matcher(childNode, childrenDelta);
|
|
}, childrenDelta);
|
|
childrenDelta = (childNode[DOM_KEY] || []).reduce(function (childrenDelta, matcher) {
|
|
return matcher(childNode, childrenDelta);
|
|
}, childrenDelta);
|
|
}
|
|
return delta.concat(childrenDelta);
|
|
}, new _quillDelta2.default());
|
|
} else {
|
|
return new _quillDelta2.default();
|
|
}
|
|
}
|
|
|
|
function matchAlias(format, node, delta) {
|
|
return applyFormat(delta, format, true);
|
|
}
|
|
|
|
function matchAttributor(node, delta) {
|
|
var attributes = _parchment2.default.Attributor.Attribute.keys(node);
|
|
var classes = _parchment2.default.Attributor.Class.keys(node);
|
|
var styles = _parchment2.default.Attributor.Style.keys(node);
|
|
var formats = {};
|
|
attributes.concat(classes).concat(styles).forEach(function (name) {
|
|
var attr = _parchment2.default.query(name, _parchment2.default.Scope.ATTRIBUTE);
|
|
if (attr != null) {
|
|
formats[attr.attrName] = attr.value(node);
|
|
if (formats[attr.attrName]) return;
|
|
}
|
|
attr = ATTRIBUTE_ATTRIBUTORS[name];
|
|
if (attr != null && (attr.attrName === name || attr.keyName === name)) {
|
|
formats[attr.attrName] = attr.value(node) || undefined;
|
|
}
|
|
attr = STYLE_ATTRIBUTORS[name];
|
|
if (attr != null && (attr.attrName === name || attr.keyName === name)) {
|
|
attr = STYLE_ATTRIBUTORS[name];
|
|
formats[attr.attrName] = attr.value(node) || undefined;
|
|
}
|
|
});
|
|
if (Object.keys(formats).length > 0) {
|
|
delta = applyFormat(delta, formats);
|
|
}
|
|
return delta;
|
|
}
|
|
|
|
function matchBlot(node, delta) {
|
|
var match = _parchment2.default.query(node);
|
|
if (match == null) return delta;
|
|
if (match.prototype instanceof _parchment2.default.Embed) {
|
|
var embed = {};
|
|
var value = match.value(node);
|
|
if (value != null) {
|
|
embed[match.blotName] = value;
|
|
delta = new _quillDelta2.default().insert(embed, match.formats(node));
|
|
}
|
|
} else if (typeof match.formats === 'function') {
|
|
delta = applyFormat(delta, match.blotName, match.formats(node));
|
|
}
|
|
return delta;
|
|
}
|
|
|
|
function matchBreak(node, delta) {
|
|
if (!deltaEndsWith(delta, '\n')) {
|
|
delta.insert('\n');
|
|
}
|
|
return delta;
|
|
}
|
|
|
|
function matchIgnore() {
|
|
return new _quillDelta2.default();
|
|
}
|
|
|
|
function matchIndent(node, delta) {
|
|
var match = _parchment2.default.query(node);
|
|
if (match == null || match.blotName !== 'list-item' || !deltaEndsWith(delta, '\n')) {
|
|
return delta;
|
|
}
|
|
var indent = -1,
|
|
parent = node.parentNode;
|
|
while (!parent.classList.contains('ql-clipboard')) {
|
|
if ((_parchment2.default.query(parent) || {}).blotName === 'list') {
|
|
indent += 1;
|
|
}
|
|
parent = parent.parentNode;
|
|
}
|
|
if (indent <= 0) return delta;
|
|
return delta.compose(new _quillDelta2.default().retain(delta.length() - 1).retain(1, { indent: indent }));
|
|
}
|
|
|
|
function matchNewline(node, delta) {
|
|
if (!deltaEndsWith(delta, '\n')) {
|
|
if (isLine(node) || delta.length() > 0 && node.nextSibling && isLine(node.nextSibling)) {
|
|
delta.insert('\n');
|
|
}
|
|
}
|
|
return delta;
|
|
}
|
|
|
|
function matchSpacing(node, delta) {
|
|
if (isLine(node) && node.nextElementSibling != null && !deltaEndsWith(delta, '\n\n')) {
|
|
var nodeHeight = node.offsetHeight + parseFloat(computeStyle(node).marginTop) + parseFloat(computeStyle(node).marginBottom);
|
|
if (node.nextElementSibling.offsetTop > node.offsetTop + nodeHeight * 1.5) {
|
|
delta.insert('\n');
|
|
}
|
|
}
|
|
return delta;
|
|
}
|
|
|
|
function matchStyles(node, delta) {
|
|
var formats = {};
|
|
var style = node.style || {};
|
|
if (style.fontStyle && computeStyle(node).fontStyle === 'italic') {
|
|
formats.italic = true;
|
|
}
|
|
if (style.fontWeight && (computeStyle(node).fontWeight.startsWith('bold') || parseInt(computeStyle(node).fontWeight) >= 700)) {
|
|
formats.bold = true;
|
|
}
|
|
if (Object.keys(formats).length > 0) {
|
|
delta = applyFormat(delta, formats);
|
|
}
|
|
if (parseFloat(style.textIndent || 0) > 0) {
|
|
// Could be 0.5in
|
|
delta = new _quillDelta2.default().insert('\t').concat(delta);
|
|
}
|
|
return delta;
|
|
}
|
|
|
|
function matchText(node, delta) {
|
|
var text = node.data;
|
|
// Word represents empty line with <o:p> </o:p>
|
|
if (node.parentNode.tagName === 'O:P') {
|
|
return delta.insert(text.trim());
|
|
}
|
|
if (text.trim().length === 0 && node.parentNode.classList.contains('ql-clipboard')) {
|
|
return delta;
|
|
}
|
|
if (!computeStyle(node.parentNode).whiteSpace.startsWith('pre')) {
|
|
// eslint-disable-next-line func-style
|
|
var replacer = function replacer(collapse, match) {
|
|
match = match.replace(/[^\u00a0]/g, ''); // \u00a0 is nbsp;
|
|
return match.length < 1 && collapse ? ' ' : match;
|
|
};
|
|
text = text.replace(/\r\n/g, ' ').replace(/\n/g, ' ');
|
|
text = text.replace(/\s\s+/g, replacer.bind(replacer, true)); // collapse whitespace
|
|
if (node.previousSibling == null && isLine(node.parentNode) || node.previousSibling != null && isLine(node.previousSibling)) {
|
|
text = text.replace(/^\s+/, replacer.bind(replacer, false));
|
|
}
|
|
if (node.nextSibling == null && isLine(node.parentNode) || node.nextSibling != null && isLine(node.nextSibling)) {
|
|
text = text.replace(/\s+$/, replacer.bind(replacer, false));
|
|
}
|
|
}
|
|
return delta.insert(text);
|
|
}
|
|
|
|
exports.default = Clipboard;
|
|
exports.matchAttributor = matchAttributor;
|
|
exports.matchBlot = matchBlot;
|
|
exports.matchNewline = matchNewline;
|
|
exports.matchSpacing = matchSpacing;
|
|
exports.matchText = matchText;
|
|
|
|
/***/ }),
|
|
/* 56 */
|
|
/***/ (function(module, exports, __nested_webpack_require_333274__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _inline = __nested_webpack_require_333274__(6);
|
|
|
|
var _inline2 = _interopRequireDefault(_inline);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var Bold = function (_Inline) {
|
|
_inherits(Bold, _Inline);
|
|
|
|
function Bold() {
|
|
_classCallCheck(this, Bold);
|
|
|
|
return _possibleConstructorReturn(this, (Bold.__proto__ || Object.getPrototypeOf(Bold)).apply(this, arguments));
|
|
}
|
|
|
|
_createClass(Bold, [{
|
|
key: 'optimize',
|
|
value: function optimize(context) {
|
|
_get(Bold.prototype.__proto__ || Object.getPrototypeOf(Bold.prototype), 'optimize', this).call(this, context);
|
|
if (this.domNode.tagName !== this.statics.tagName[0]) {
|
|
this.replaceWith(this.statics.blotName);
|
|
}
|
|
}
|
|
}], [{
|
|
key: 'create',
|
|
value: function create() {
|
|
return _get(Bold.__proto__ || Object.getPrototypeOf(Bold), 'create', this).call(this);
|
|
}
|
|
}, {
|
|
key: 'formats',
|
|
value: function formats() {
|
|
return true;
|
|
}
|
|
}]);
|
|
|
|
return Bold;
|
|
}(_inline2.default);
|
|
|
|
Bold.blotName = 'bold';
|
|
Bold.tagName = ['STRONG', 'B'];
|
|
|
|
exports.default = Bold;
|
|
|
|
/***/ }),
|
|
/* 57 */
|
|
/***/ (function(module, exports, __nested_webpack_require_336502__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.addControls = exports.default = undefined;
|
|
|
|
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _quillDelta = __nested_webpack_require_336502__(2);
|
|
|
|
var _quillDelta2 = _interopRequireDefault(_quillDelta);
|
|
|
|
var _parchment = __nested_webpack_require_336502__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
var _quill = __nested_webpack_require_336502__(5);
|
|
|
|
var _quill2 = _interopRequireDefault(_quill);
|
|
|
|
var _logger = __nested_webpack_require_336502__(10);
|
|
|
|
var _logger2 = _interopRequireDefault(_logger);
|
|
|
|
var _module = __nested_webpack_require_336502__(9);
|
|
|
|
var _module2 = _interopRequireDefault(_module);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var debug = (0, _logger2.default)('quill:toolbar');
|
|
|
|
var Toolbar = function (_Module) {
|
|
_inherits(Toolbar, _Module);
|
|
|
|
function Toolbar(quill, options) {
|
|
_classCallCheck(this, Toolbar);
|
|
|
|
var _this = _possibleConstructorReturn(this, (Toolbar.__proto__ || Object.getPrototypeOf(Toolbar)).call(this, quill, options));
|
|
|
|
if (Array.isArray(_this.options.container)) {
|
|
var container = document.createElement('div');
|
|
addControls(container, _this.options.container);
|
|
quill.container.parentNode.insertBefore(container, quill.container);
|
|
_this.container = container;
|
|
} else if (typeof _this.options.container === 'string') {
|
|
_this.container = document.querySelector(_this.options.container);
|
|
} else {
|
|
_this.container = _this.options.container;
|
|
}
|
|
if (!(_this.container instanceof HTMLElement)) {
|
|
var _ret;
|
|
|
|
return _ret = debug.error('Container required for toolbar', _this.options), _possibleConstructorReturn(_this, _ret);
|
|
}
|
|
_this.container.classList.add('ql-toolbar');
|
|
_this.controls = [];
|
|
_this.handlers = {};
|
|
Object.keys(_this.options.handlers).forEach(function (format) {
|
|
_this.addHandler(format, _this.options.handlers[format]);
|
|
});
|
|
[].forEach.call(_this.container.querySelectorAll('button, select'), function (input) {
|
|
_this.attach(input);
|
|
});
|
|
_this.quill.on(_quill2.default.events.EDITOR_CHANGE, function (type, range) {
|
|
if (type === _quill2.default.events.SELECTION_CHANGE) {
|
|
_this.update(range);
|
|
}
|
|
});
|
|
_this.quill.on(_quill2.default.events.SCROLL_OPTIMIZE, function () {
|
|
var _this$quill$selection = _this.quill.selection.getRange(),
|
|
_this$quill$selection2 = _slicedToArray(_this$quill$selection, 1),
|
|
range = _this$quill$selection2[0]; // quill.getSelection triggers update
|
|
|
|
|
|
_this.update(range);
|
|
});
|
|
return _this;
|
|
}
|
|
|
|
_createClass(Toolbar, [{
|
|
key: 'addHandler',
|
|
value: function addHandler(format, handler) {
|
|
this.handlers[format] = handler;
|
|
}
|
|
}, {
|
|
key: 'attach',
|
|
value: function attach(input) {
|
|
var _this2 = this;
|
|
|
|
var format = [].find.call(input.classList, function (className) {
|
|
return className.indexOf('ql-') === 0;
|
|
});
|
|
if (!format) return;
|
|
format = format.slice('ql-'.length);
|
|
if (input.tagName === 'BUTTON') {
|
|
input.setAttribute('type', 'button');
|
|
}
|
|
if (this.handlers[format] == null) {
|
|
if (this.quill.scroll.whitelist != null && this.quill.scroll.whitelist[format] == null) {
|
|
debug.warn('ignoring attaching to disabled format', format, input);
|
|
return;
|
|
}
|
|
if (_parchment2.default.query(format) == null) {
|
|
debug.warn('ignoring attaching to nonexistent format', format, input);
|
|
return;
|
|
}
|
|
}
|
|
var eventName = input.tagName === 'SELECT' ? 'change' : 'click';
|
|
input.addEventListener(eventName, function (e) {
|
|
var value = void 0;
|
|
if (input.tagName === 'SELECT') {
|
|
if (input.selectedIndex < 0) return;
|
|
var selected = input.options[input.selectedIndex];
|
|
if (selected.hasAttribute('selected')) {
|
|
value = false;
|
|
} else {
|
|
value = selected.value || false;
|
|
}
|
|
} else {
|
|
if (input.classList.contains('ql-active')) {
|
|
value = false;
|
|
} else {
|
|
value = input.value || !input.hasAttribute('value');
|
|
}
|
|
e.preventDefault();
|
|
}
|
|
_this2.quill.focus();
|
|
|
|
var _quill$selection$getR = _this2.quill.selection.getRange(),
|
|
_quill$selection$getR2 = _slicedToArray(_quill$selection$getR, 1),
|
|
range = _quill$selection$getR2[0];
|
|
|
|
if (_this2.handlers[format] != null) {
|
|
_this2.handlers[format].call(_this2, value);
|
|
} else if (_parchment2.default.query(format).prototype instanceof _parchment2.default.Embed) {
|
|
value = prompt('Enter ' + format);
|
|
if (!value) return;
|
|
_this2.quill.updateContents(new _quillDelta2.default().retain(range.index).delete(range.length).insert(_defineProperty({}, format, value)), _quill2.default.sources.USER);
|
|
} else {
|
|
_this2.quill.format(format, value, _quill2.default.sources.USER);
|
|
}
|
|
_this2.update(range);
|
|
});
|
|
// TODO use weakmap
|
|
this.controls.push([format, input]);
|
|
}
|
|
}, {
|
|
key: 'update',
|
|
value: function update(range) {
|
|
var formats = range == null ? {} : this.quill.getFormat(range);
|
|
this.controls.forEach(function (pair) {
|
|
var _pair = _slicedToArray(pair, 2),
|
|
format = _pair[0],
|
|
input = _pair[1];
|
|
|
|
if (input.tagName === 'SELECT') {
|
|
var option = void 0;
|
|
if (range == null) {
|
|
option = null;
|
|
} else if (formats[format] == null) {
|
|
option = input.querySelector('option[selected]');
|
|
} else if (!Array.isArray(formats[format])) {
|
|
var value = formats[format];
|
|
if (typeof value === 'string') {
|
|
value = value.replace(/\"/g, '\\"');
|
|
}
|
|
option = input.querySelector('option[value="' + value + '"]');
|
|
}
|
|
if (option == null) {
|
|
input.value = ''; // TODO make configurable?
|
|
input.selectedIndex = -1;
|
|
} else {
|
|
option.selected = true;
|
|
}
|
|
} else {
|
|
if (range == null) {
|
|
input.classList.remove('ql-active');
|
|
} else if (input.hasAttribute('value')) {
|
|
// both being null should match (default values)
|
|
// '1' should match with 1 (headers)
|
|
var isActive = formats[format] === input.getAttribute('value') || formats[format] != null && formats[format].toString() === input.getAttribute('value') || formats[format] == null && !input.getAttribute('value');
|
|
input.classList.toggle('ql-active', isActive);
|
|
} else {
|
|
input.classList.toggle('ql-active', formats[format] != null);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}]);
|
|
|
|
return Toolbar;
|
|
}(_module2.default);
|
|
|
|
Toolbar.DEFAULTS = {};
|
|
|
|
function addButton(container, format, value) {
|
|
var input = document.createElement('button');
|
|
input.setAttribute('type', 'button');
|
|
input.classList.add('ql-' + format);
|
|
if (value != null) {
|
|
input.value = value;
|
|
}
|
|
container.appendChild(input);
|
|
}
|
|
|
|
function addControls(container, groups) {
|
|
if (!Array.isArray(groups[0])) {
|
|
groups = [groups];
|
|
}
|
|
groups.forEach(function (controls) {
|
|
var group = document.createElement('span');
|
|
group.classList.add('ql-formats');
|
|
controls.forEach(function (control) {
|
|
if (typeof control === 'string') {
|
|
addButton(group, control);
|
|
} else {
|
|
var format = Object.keys(control)[0];
|
|
var value = control[format];
|
|
if (Array.isArray(value)) {
|
|
addSelect(group, format, value);
|
|
} else {
|
|
addButton(group, format, value);
|
|
}
|
|
}
|
|
});
|
|
container.appendChild(group);
|
|
});
|
|
}
|
|
|
|
function addSelect(container, format, values) {
|
|
var input = document.createElement('select');
|
|
input.classList.add('ql-' + format);
|
|
values.forEach(function (value) {
|
|
var option = document.createElement('option');
|
|
if (value !== false) {
|
|
option.setAttribute('value', value);
|
|
} else {
|
|
option.setAttribute('selected', 'selected');
|
|
}
|
|
input.appendChild(option);
|
|
});
|
|
container.appendChild(input);
|
|
}
|
|
|
|
Toolbar.DEFAULTS = {
|
|
container: null,
|
|
handlers: {
|
|
clean: function clean() {
|
|
var _this3 = this;
|
|
|
|
var range = this.quill.getSelection();
|
|
if (range == null) return;
|
|
if (range.length == 0) {
|
|
var formats = this.quill.getFormat();
|
|
Object.keys(formats).forEach(function (name) {
|
|
// Clean functionality in existing apps only clean inline formats
|
|
if (_parchment2.default.query(name, _parchment2.default.Scope.INLINE) != null) {
|
|
_this3.quill.format(name, false);
|
|
}
|
|
});
|
|
} else {
|
|
this.quill.removeFormat(range, _quill2.default.sources.USER);
|
|
}
|
|
},
|
|
direction: function direction(value) {
|
|
var align = this.quill.getFormat()['align'];
|
|
if (value === 'rtl' && align == null) {
|
|
this.quill.format('align', 'right', _quill2.default.sources.USER);
|
|
} else if (!value && align === 'right') {
|
|
this.quill.format('align', false, _quill2.default.sources.USER);
|
|
}
|
|
this.quill.format('direction', value, _quill2.default.sources.USER);
|
|
},
|
|
indent: function indent(value) {
|
|
var range = this.quill.getSelection();
|
|
var formats = this.quill.getFormat(range);
|
|
var indent = parseInt(formats.indent || 0);
|
|
if (value === '+1' || value === '-1') {
|
|
var modifier = value === '+1' ? 1 : -1;
|
|
if (formats.direction === 'rtl') modifier *= -1;
|
|
this.quill.format('indent', indent + modifier, _quill2.default.sources.USER);
|
|
}
|
|
},
|
|
link: function link(value) {
|
|
if (value === true) {
|
|
value = prompt('Enter link URL:');
|
|
}
|
|
this.quill.format('link', value, _quill2.default.sources.USER);
|
|
},
|
|
list: function list(value) {
|
|
var range = this.quill.getSelection();
|
|
var formats = this.quill.getFormat(range);
|
|
if (value === 'check') {
|
|
if (formats['list'] === 'checked' || formats['list'] === 'unchecked') {
|
|
this.quill.format('list', false, _quill2.default.sources.USER);
|
|
} else {
|
|
this.quill.format('list', 'unchecked', _quill2.default.sources.USER);
|
|
}
|
|
} else {
|
|
this.quill.format('list', value, _quill2.default.sources.USER);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
exports.default = Toolbar;
|
|
exports.addControls = addControls;
|
|
|
|
/***/ }),
|
|
/* 58 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <polyline class=\"ql-even ql-stroke\" points=\"5 7 3 9 5 11\"></polyline> <polyline class=\"ql-even ql-stroke\" points=\"13 7 15 9 13 11\"></polyline> <line class=ql-stroke x1=10 x2=8 y1=5 y2=13></line> </svg>";
|
|
|
|
/***/ }),
|
|
/* 59 */
|
|
/***/ (function(module, exports, __nested_webpack_require_349781__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _picker = __nested_webpack_require_349781__(28);
|
|
|
|
var _picker2 = _interopRequireDefault(_picker);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var ColorPicker = function (_Picker) {
|
|
_inherits(ColorPicker, _Picker);
|
|
|
|
function ColorPicker(select, label) {
|
|
_classCallCheck(this, ColorPicker);
|
|
|
|
var _this = _possibleConstructorReturn(this, (ColorPicker.__proto__ || Object.getPrototypeOf(ColorPicker)).call(this, select));
|
|
|
|
_this.label.innerHTML = label;
|
|
_this.container.classList.add('ql-color-picker');
|
|
[].slice.call(_this.container.querySelectorAll('.ql-picker-item'), 0, 7).forEach(function (item) {
|
|
item.classList.add('ql-primary');
|
|
});
|
|
return _this;
|
|
}
|
|
|
|
_createClass(ColorPicker, [{
|
|
key: 'buildItem',
|
|
value: function buildItem(option) {
|
|
var item = _get(ColorPicker.prototype.__proto__ || Object.getPrototypeOf(ColorPicker.prototype), 'buildItem', this).call(this, option);
|
|
item.style.backgroundColor = option.getAttribute('value') || '';
|
|
return item;
|
|
}
|
|
}, {
|
|
key: 'selectItem',
|
|
value: function selectItem(item, trigger) {
|
|
_get(ColorPicker.prototype.__proto__ || Object.getPrototypeOf(ColorPicker.prototype), 'selectItem', this).call(this, item, trigger);
|
|
var colorLabel = this.label.querySelector('.ql-color-label');
|
|
var value = item ? item.getAttribute('data-value') || '' : '';
|
|
if (colorLabel) {
|
|
if (colorLabel.tagName === 'line') {
|
|
colorLabel.style.stroke = value;
|
|
} else {
|
|
colorLabel.style.fill = value;
|
|
}
|
|
}
|
|
}
|
|
}]);
|
|
|
|
return ColorPicker;
|
|
}(_picker2.default);
|
|
|
|
exports.default = ColorPicker;
|
|
|
|
/***/ }),
|
|
/* 60 */
|
|
/***/ (function(module, exports, __nested_webpack_require_353592__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _picker = __nested_webpack_require_353592__(28);
|
|
|
|
var _picker2 = _interopRequireDefault(_picker);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var IconPicker = function (_Picker) {
|
|
_inherits(IconPicker, _Picker);
|
|
|
|
function IconPicker(select, icons) {
|
|
_classCallCheck(this, IconPicker);
|
|
|
|
var _this = _possibleConstructorReturn(this, (IconPicker.__proto__ || Object.getPrototypeOf(IconPicker)).call(this, select));
|
|
|
|
_this.container.classList.add('ql-icon-picker');
|
|
[].forEach.call(_this.container.querySelectorAll('.ql-picker-item'), function (item) {
|
|
item.innerHTML = icons[item.getAttribute('data-value') || ''];
|
|
});
|
|
_this.defaultItem = _this.container.querySelector('.ql-selected');
|
|
_this.selectItem(_this.defaultItem);
|
|
return _this;
|
|
}
|
|
|
|
_createClass(IconPicker, [{
|
|
key: 'selectItem',
|
|
value: function selectItem(item, trigger) {
|
|
_get(IconPicker.prototype.__proto__ || Object.getPrototypeOf(IconPicker.prototype), 'selectItem', this).call(this, item, trigger);
|
|
item = item || this.defaultItem;
|
|
this.label.innerHTML = item.innerHTML;
|
|
}
|
|
}]);
|
|
|
|
return IconPicker;
|
|
}(_picker2.default);
|
|
|
|
exports.default = IconPicker;
|
|
|
|
/***/ }),
|
|
/* 61 */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
var Tooltip = function () {
|
|
function Tooltip(quill, boundsContainer) {
|
|
var _this = this;
|
|
|
|
_classCallCheck(this, Tooltip);
|
|
|
|
this.quill = quill;
|
|
this.boundsContainer = boundsContainer || document.body;
|
|
this.root = quill.addContainer('ql-tooltip');
|
|
this.root.innerHTML = this.constructor.TEMPLATE;
|
|
if (this.quill.root === this.quill.scrollingContainer) {
|
|
this.quill.root.addEventListener('scroll', function () {
|
|
_this.root.style.marginTop = -1 * _this.quill.root.scrollTop + 'px';
|
|
});
|
|
}
|
|
this.hide();
|
|
}
|
|
|
|
_createClass(Tooltip, [{
|
|
key: 'hide',
|
|
value: function hide() {
|
|
this.root.classList.add('ql-hidden');
|
|
}
|
|
}, {
|
|
key: 'position',
|
|
value: function position(reference) {
|
|
var left = reference.left + reference.width / 2 - this.root.offsetWidth / 2;
|
|
// root.scrollTop should be 0 if scrollContainer !== root
|
|
var top = reference.bottom + this.quill.root.scrollTop;
|
|
this.root.style.left = left + 'px';
|
|
this.root.style.top = top + 'px';
|
|
this.root.classList.remove('ql-flip');
|
|
var containerBounds = this.boundsContainer.getBoundingClientRect();
|
|
var rootBounds = this.root.getBoundingClientRect();
|
|
var shift = 0;
|
|
if (rootBounds.right > containerBounds.right) {
|
|
shift = containerBounds.right - rootBounds.right;
|
|
this.root.style.left = left + shift + 'px';
|
|
}
|
|
if (rootBounds.left < containerBounds.left) {
|
|
shift = containerBounds.left - rootBounds.left;
|
|
this.root.style.left = left + shift + 'px';
|
|
}
|
|
if (rootBounds.bottom > containerBounds.bottom) {
|
|
var height = rootBounds.bottom - rootBounds.top;
|
|
var verticalShift = reference.bottom - reference.top + height;
|
|
this.root.style.top = top - verticalShift + 'px';
|
|
this.root.classList.add('ql-flip');
|
|
}
|
|
return shift;
|
|
}
|
|
}, {
|
|
key: 'show',
|
|
value: function show() {
|
|
this.root.classList.remove('ql-editing');
|
|
this.root.classList.remove('ql-hidden');
|
|
}
|
|
}]);
|
|
|
|
return Tooltip;
|
|
}();
|
|
|
|
exports.default = Tooltip;
|
|
|
|
/***/ }),
|
|
/* 62 */
|
|
/***/ (function(module, exports, __nested_webpack_require_359932__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _extend = __nested_webpack_require_359932__(3);
|
|
|
|
var _extend2 = _interopRequireDefault(_extend);
|
|
|
|
var _emitter = __nested_webpack_require_359932__(8);
|
|
|
|
var _emitter2 = _interopRequireDefault(_emitter);
|
|
|
|
var _base = __nested_webpack_require_359932__(43);
|
|
|
|
var _base2 = _interopRequireDefault(_base);
|
|
|
|
var _link = __nested_webpack_require_359932__(27);
|
|
|
|
var _link2 = _interopRequireDefault(_link);
|
|
|
|
var _selection = __nested_webpack_require_359932__(15);
|
|
|
|
var _icons = __nested_webpack_require_359932__(41);
|
|
|
|
var _icons2 = _interopRequireDefault(_icons);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var TOOLBAR_CONFIG = [[{ header: ['1', '2', '3', false] }], ['bold', 'italic', 'underline', 'link'], [{ list: 'ordered' }, { list: 'bullet' }], ['clean']];
|
|
|
|
var SnowTheme = function (_BaseTheme) {
|
|
_inherits(SnowTheme, _BaseTheme);
|
|
|
|
function SnowTheme(quill, options) {
|
|
_classCallCheck(this, SnowTheme);
|
|
|
|
if (options.modules.toolbar != null && options.modules.toolbar.container == null) {
|
|
options.modules.toolbar.container = TOOLBAR_CONFIG;
|
|
}
|
|
|
|
var _this = _possibleConstructorReturn(this, (SnowTheme.__proto__ || Object.getPrototypeOf(SnowTheme)).call(this, quill, options));
|
|
|
|
_this.quill.container.classList.add('ql-snow');
|
|
return _this;
|
|
}
|
|
|
|
_createClass(SnowTheme, [{
|
|
key: 'extendToolbar',
|
|
value: function extendToolbar(toolbar) {
|
|
toolbar.container.classList.add('ql-snow');
|
|
this.buildButtons([].slice.call(toolbar.container.querySelectorAll('button')), _icons2.default);
|
|
this.buildPickers([].slice.call(toolbar.container.querySelectorAll('select')), _icons2.default);
|
|
this.tooltip = new SnowTooltip(this.quill, this.options.bounds);
|
|
if (toolbar.container.querySelector('.ql-link')) {
|
|
this.quill.keyboard.addBinding({ key: 'K', shortKey: true }, function (range, context) {
|
|
toolbar.handlers['link'].call(toolbar, !context.format.link);
|
|
});
|
|
}
|
|
}
|
|
}]);
|
|
|
|
return SnowTheme;
|
|
}(_base2.default);
|
|
|
|
SnowTheme.DEFAULTS = (0, _extend2.default)(true, {}, _base2.default.DEFAULTS, {
|
|
modules: {
|
|
toolbar: {
|
|
handlers: {
|
|
link: function link(value) {
|
|
if (value) {
|
|
var range = this.quill.getSelection();
|
|
if (range == null || range.length == 0) return;
|
|
var preview = this.quill.getText(range);
|
|
if (/^\S+@\S+\.\S+$/.test(preview) && preview.indexOf('mailto:') !== 0) {
|
|
preview = 'mailto:' + preview;
|
|
}
|
|
var tooltip = this.quill.theme.tooltip;
|
|
tooltip.edit('link', preview);
|
|
} else {
|
|
this.quill.format('link', false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
var SnowTooltip = function (_BaseTooltip) {
|
|
_inherits(SnowTooltip, _BaseTooltip);
|
|
|
|
function SnowTooltip(quill, bounds) {
|
|
_classCallCheck(this, SnowTooltip);
|
|
|
|
var _this2 = _possibleConstructorReturn(this, (SnowTooltip.__proto__ || Object.getPrototypeOf(SnowTooltip)).call(this, quill, bounds));
|
|
|
|
_this2.preview = _this2.root.querySelector('a.ql-preview');
|
|
return _this2;
|
|
}
|
|
|
|
_createClass(SnowTooltip, [{
|
|
key: 'listen',
|
|
value: function listen() {
|
|
var _this3 = this;
|
|
|
|
_get(SnowTooltip.prototype.__proto__ || Object.getPrototypeOf(SnowTooltip.prototype), 'listen', this).call(this);
|
|
this.root.querySelector('a.ql-action').addEventListener('click', function (event) {
|
|
if (_this3.root.classList.contains('ql-editing')) {
|
|
_this3.save();
|
|
} else {
|
|
_this3.edit('link', _this3.preview.textContent);
|
|
}
|
|
event.preventDefault();
|
|
});
|
|
this.root.querySelector('a.ql-remove').addEventListener('click', function (event) {
|
|
if (_this3.linkRange != null) {
|
|
var range = _this3.linkRange;
|
|
_this3.restoreFocus();
|
|
_this3.quill.formatText(range, 'link', false, _emitter2.default.sources.USER);
|
|
delete _this3.linkRange;
|
|
}
|
|
event.preventDefault();
|
|
_this3.hide();
|
|
});
|
|
this.quill.on(_emitter2.default.events.SELECTION_CHANGE, function (range, oldRange, source) {
|
|
if (range == null) return;
|
|
if (range.length === 0 && source === _emitter2.default.sources.USER) {
|
|
var _quill$scroll$descend = _this3.quill.scroll.descendant(_link2.default, range.index),
|
|
_quill$scroll$descend2 = _slicedToArray(_quill$scroll$descend, 2),
|
|
link = _quill$scroll$descend2[0],
|
|
offset = _quill$scroll$descend2[1];
|
|
|
|
if (link != null) {
|
|
_this3.linkRange = new _selection.Range(range.index - offset, link.length());
|
|
var preview = _link2.default.formats(link.domNode);
|
|
_this3.preview.textContent = preview;
|
|
_this3.preview.setAttribute('href', preview);
|
|
_this3.show();
|
|
_this3.position(_this3.quill.getBounds(_this3.linkRange));
|
|
return;
|
|
}
|
|
} else {
|
|
delete _this3.linkRange;
|
|
}
|
|
_this3.hide();
|
|
});
|
|
}
|
|
}, {
|
|
key: 'show',
|
|
value: function show() {
|
|
_get(SnowTooltip.prototype.__proto__ || Object.getPrototypeOf(SnowTooltip.prototype), 'show', this).call(this);
|
|
this.root.removeAttribute('data-mode');
|
|
}
|
|
}]);
|
|
|
|
return SnowTooltip;
|
|
}(_base.BaseTooltip);
|
|
|
|
SnowTooltip.TEMPLATE = ['<a class="ql-preview" rel="noopener noreferrer" target="_blank" href="about:blank"></a>', '<input type="text" data-formula="e=mc^2" data-link="https://quilljs.com" data-video="Embed URL">', '<a class="ql-action"></a>', '<a class="ql-remove"></a>'].join('');
|
|
|
|
exports.default = SnowTheme;
|
|
|
|
/***/ }),
|
|
/* 63 */
|
|
/***/ (function(module, exports, __nested_webpack_require_368316__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _core = __nested_webpack_require_368316__(29);
|
|
|
|
var _core2 = _interopRequireDefault(_core);
|
|
|
|
var _align = __nested_webpack_require_368316__(36);
|
|
|
|
var _direction = __nested_webpack_require_368316__(38);
|
|
|
|
var _indent = __nested_webpack_require_368316__(64);
|
|
|
|
var _blockquote = __nested_webpack_require_368316__(65);
|
|
|
|
var _blockquote2 = _interopRequireDefault(_blockquote);
|
|
|
|
var _header = __nested_webpack_require_368316__(66);
|
|
|
|
var _header2 = _interopRequireDefault(_header);
|
|
|
|
var _list = __nested_webpack_require_368316__(67);
|
|
|
|
var _list2 = _interopRequireDefault(_list);
|
|
|
|
var _background = __nested_webpack_require_368316__(37);
|
|
|
|
var _color = __nested_webpack_require_368316__(26);
|
|
|
|
var _font = __nested_webpack_require_368316__(39);
|
|
|
|
var _size = __nested_webpack_require_368316__(40);
|
|
|
|
var _bold = __nested_webpack_require_368316__(56);
|
|
|
|
var _bold2 = _interopRequireDefault(_bold);
|
|
|
|
var _italic = __nested_webpack_require_368316__(68);
|
|
|
|
var _italic2 = _interopRequireDefault(_italic);
|
|
|
|
var _link = __nested_webpack_require_368316__(27);
|
|
|
|
var _link2 = _interopRequireDefault(_link);
|
|
|
|
var _script = __nested_webpack_require_368316__(69);
|
|
|
|
var _script2 = _interopRequireDefault(_script);
|
|
|
|
var _strike = __nested_webpack_require_368316__(70);
|
|
|
|
var _strike2 = _interopRequireDefault(_strike);
|
|
|
|
var _underline = __nested_webpack_require_368316__(71);
|
|
|
|
var _underline2 = _interopRequireDefault(_underline);
|
|
|
|
var _image = __nested_webpack_require_368316__(72);
|
|
|
|
var _image2 = _interopRequireDefault(_image);
|
|
|
|
var _video = __nested_webpack_require_368316__(73);
|
|
|
|
var _video2 = _interopRequireDefault(_video);
|
|
|
|
var _code = __nested_webpack_require_368316__(13);
|
|
|
|
var _code2 = _interopRequireDefault(_code);
|
|
|
|
var _formula = __nested_webpack_require_368316__(74);
|
|
|
|
var _formula2 = _interopRequireDefault(_formula);
|
|
|
|
var _syntax = __nested_webpack_require_368316__(75);
|
|
|
|
var _syntax2 = _interopRequireDefault(_syntax);
|
|
|
|
var _toolbar = __nested_webpack_require_368316__(57);
|
|
|
|
var _toolbar2 = _interopRequireDefault(_toolbar);
|
|
|
|
var _icons = __nested_webpack_require_368316__(41);
|
|
|
|
var _icons2 = _interopRequireDefault(_icons);
|
|
|
|
var _picker = __nested_webpack_require_368316__(28);
|
|
|
|
var _picker2 = _interopRequireDefault(_picker);
|
|
|
|
var _colorPicker = __nested_webpack_require_368316__(59);
|
|
|
|
var _colorPicker2 = _interopRequireDefault(_colorPicker);
|
|
|
|
var _iconPicker = __nested_webpack_require_368316__(60);
|
|
|
|
var _iconPicker2 = _interopRequireDefault(_iconPicker);
|
|
|
|
var _tooltip = __nested_webpack_require_368316__(61);
|
|
|
|
var _tooltip2 = _interopRequireDefault(_tooltip);
|
|
|
|
var _bubble = __nested_webpack_require_368316__(108);
|
|
|
|
var _bubble2 = _interopRequireDefault(_bubble);
|
|
|
|
var _snow = __nested_webpack_require_368316__(62);
|
|
|
|
var _snow2 = _interopRequireDefault(_snow);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
_core2.default.register({
|
|
'attributors/attribute/direction': _direction.DirectionAttribute,
|
|
|
|
'attributors/class/align': _align.AlignClass,
|
|
'attributors/class/background': _background.BackgroundClass,
|
|
'attributors/class/color': _color.ColorClass,
|
|
'attributors/class/direction': _direction.DirectionClass,
|
|
'attributors/class/font': _font.FontClass,
|
|
'attributors/class/size': _size.SizeClass,
|
|
|
|
'attributors/style/align': _align.AlignStyle,
|
|
'attributors/style/background': _background.BackgroundStyle,
|
|
'attributors/style/color': _color.ColorStyle,
|
|
'attributors/style/direction': _direction.DirectionStyle,
|
|
'attributors/style/font': _font.FontStyle,
|
|
'attributors/style/size': _size.SizeStyle
|
|
}, true);
|
|
|
|
_core2.default.register({
|
|
'formats/align': _align.AlignClass,
|
|
'formats/direction': _direction.DirectionClass,
|
|
'formats/indent': _indent.IndentClass,
|
|
|
|
'formats/background': _background.BackgroundStyle,
|
|
'formats/color': _color.ColorStyle,
|
|
'formats/font': _font.FontClass,
|
|
'formats/size': _size.SizeClass,
|
|
|
|
'formats/blockquote': _blockquote2.default,
|
|
'formats/code-block': _code2.default,
|
|
'formats/header': _header2.default,
|
|
'formats/list': _list2.default,
|
|
|
|
'formats/bold': _bold2.default,
|
|
'formats/code': _code.Code,
|
|
'formats/italic': _italic2.default,
|
|
'formats/link': _link2.default,
|
|
'formats/script': _script2.default,
|
|
'formats/strike': _strike2.default,
|
|
'formats/underline': _underline2.default,
|
|
|
|
'formats/image': _image2.default,
|
|
'formats/video': _video2.default,
|
|
|
|
'formats/list/item': _list.ListItem,
|
|
|
|
'modules/formula': _formula2.default,
|
|
'modules/syntax': _syntax2.default,
|
|
'modules/toolbar': _toolbar2.default,
|
|
|
|
'themes/bubble': _bubble2.default,
|
|
'themes/snow': _snow2.default,
|
|
|
|
'ui/icons': _icons2.default,
|
|
'ui/picker': _picker2.default,
|
|
'ui/icon-picker': _iconPicker2.default,
|
|
'ui/color-picker': _colorPicker2.default,
|
|
'ui/tooltip': _tooltip2.default
|
|
}, true);
|
|
|
|
exports.default = _core2.default;
|
|
|
|
/***/ }),
|
|
/* 64 */
|
|
/***/ (function(module, exports, __nested_webpack_require_372903__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.IndentClass = undefined;
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _parchment = __nested_webpack_require_372903__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var IdentAttributor = function (_Parchment$Attributor) {
|
|
_inherits(IdentAttributor, _Parchment$Attributor);
|
|
|
|
function IdentAttributor() {
|
|
_classCallCheck(this, IdentAttributor);
|
|
|
|
return _possibleConstructorReturn(this, (IdentAttributor.__proto__ || Object.getPrototypeOf(IdentAttributor)).apply(this, arguments));
|
|
}
|
|
|
|
_createClass(IdentAttributor, [{
|
|
key: 'add',
|
|
value: function add(node, value) {
|
|
if (value === '+1' || value === '-1') {
|
|
var indent = this.value(node) || 0;
|
|
value = value === '+1' ? indent + 1 : indent - 1;
|
|
}
|
|
if (value === 0) {
|
|
this.remove(node);
|
|
return true;
|
|
} else {
|
|
return _get(IdentAttributor.prototype.__proto__ || Object.getPrototypeOf(IdentAttributor.prototype), 'add', this).call(this, node, value);
|
|
}
|
|
}
|
|
}, {
|
|
key: 'canAdd',
|
|
value: function canAdd(node, value) {
|
|
return _get(IdentAttributor.prototype.__proto__ || Object.getPrototypeOf(IdentAttributor.prototype), 'canAdd', this).call(this, node, value) || _get(IdentAttributor.prototype.__proto__ || Object.getPrototypeOf(IdentAttributor.prototype), 'canAdd', this).call(this, node, parseInt(value));
|
|
}
|
|
}, {
|
|
key: 'value',
|
|
value: function value(node) {
|
|
return parseInt(_get(IdentAttributor.prototype.__proto__ || Object.getPrototypeOf(IdentAttributor.prototype), 'value', this).call(this, node)) || undefined; // Don't return NaN
|
|
}
|
|
}]);
|
|
|
|
return IdentAttributor;
|
|
}(_parchment2.default.Attributor.Class);
|
|
|
|
var IndentClass = new IdentAttributor('indent', 'ql-indent', {
|
|
scope: _parchment2.default.Scope.BLOCK,
|
|
whitelist: [1, 2, 3, 4, 5, 6, 7, 8]
|
|
});
|
|
|
|
exports.IndentClass = IndentClass;
|
|
|
|
/***/ }),
|
|
/* 65 */
|
|
/***/ (function(module, exports, __nested_webpack_require_376943__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _block = __nested_webpack_require_376943__(4);
|
|
|
|
var _block2 = _interopRequireDefault(_block);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var Blockquote = function (_Block) {
|
|
_inherits(Blockquote, _Block);
|
|
|
|
function Blockquote() {
|
|
_classCallCheck(this, Blockquote);
|
|
|
|
return _possibleConstructorReturn(this, (Blockquote.__proto__ || Object.getPrototypeOf(Blockquote)).apply(this, arguments));
|
|
}
|
|
|
|
return Blockquote;
|
|
}(_block2.default);
|
|
|
|
Blockquote.blotName = 'blockquote';
|
|
Blockquote.tagName = 'blockquote';
|
|
|
|
exports.default = Blockquote;
|
|
|
|
/***/ }),
|
|
/* 66 */
|
|
/***/ (function(module, exports, __nested_webpack_require_378592__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _block = __nested_webpack_require_378592__(4);
|
|
|
|
var _block2 = _interopRequireDefault(_block);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var Header = function (_Block) {
|
|
_inherits(Header, _Block);
|
|
|
|
function Header() {
|
|
_classCallCheck(this, Header);
|
|
|
|
return _possibleConstructorReturn(this, (Header.__proto__ || Object.getPrototypeOf(Header)).apply(this, arguments));
|
|
}
|
|
|
|
_createClass(Header, null, [{
|
|
key: 'formats',
|
|
value: function formats(domNode) {
|
|
return this.tagName.indexOf(domNode.tagName) + 1;
|
|
}
|
|
}]);
|
|
|
|
return Header;
|
|
}(_block2.default);
|
|
|
|
Header.blotName = 'header';
|
|
Header.tagName = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6'];
|
|
|
|
exports.default = Header;
|
|
|
|
/***/ }),
|
|
/* 67 */
|
|
/***/ (function(module, exports, __nested_webpack_require_380948__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = exports.ListItem = undefined;
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _parchment = __nested_webpack_require_380948__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
var _block = __nested_webpack_require_380948__(4);
|
|
|
|
var _block2 = _interopRequireDefault(_block);
|
|
|
|
var _container = __nested_webpack_require_380948__(25);
|
|
|
|
var _container2 = _interopRequireDefault(_container);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var ListItem = function (_Block) {
|
|
_inherits(ListItem, _Block);
|
|
|
|
function ListItem() {
|
|
_classCallCheck(this, ListItem);
|
|
|
|
return _possibleConstructorReturn(this, (ListItem.__proto__ || Object.getPrototypeOf(ListItem)).apply(this, arguments));
|
|
}
|
|
|
|
_createClass(ListItem, [{
|
|
key: 'format',
|
|
value: function format(name, value) {
|
|
if (name === List.blotName && !value) {
|
|
this.replaceWith(_parchment2.default.create(this.statics.scope));
|
|
} else {
|
|
_get(ListItem.prototype.__proto__ || Object.getPrototypeOf(ListItem.prototype), 'format', this).call(this, name, value);
|
|
}
|
|
}
|
|
}, {
|
|
key: 'remove',
|
|
value: function remove() {
|
|
if (this.prev == null && this.next == null) {
|
|
this.parent.remove();
|
|
} else {
|
|
_get(ListItem.prototype.__proto__ || Object.getPrototypeOf(ListItem.prototype), 'remove', this).call(this);
|
|
}
|
|
}
|
|
}, {
|
|
key: 'replaceWith',
|
|
value: function replaceWith(name, value) {
|
|
this.parent.isolate(this.offset(this.parent), this.length());
|
|
if (name === this.parent.statics.blotName) {
|
|
this.parent.replaceWith(name, value);
|
|
return this;
|
|
} else {
|
|
this.parent.unwrap();
|
|
return _get(ListItem.prototype.__proto__ || Object.getPrototypeOf(ListItem.prototype), 'replaceWith', this).call(this, name, value);
|
|
}
|
|
}
|
|
}], [{
|
|
key: 'formats',
|
|
value: function formats(domNode) {
|
|
return domNode.tagName === this.tagName ? undefined : _get(ListItem.__proto__ || Object.getPrototypeOf(ListItem), 'formats', this).call(this, domNode);
|
|
}
|
|
}]);
|
|
|
|
return ListItem;
|
|
}(_block2.default);
|
|
|
|
ListItem.blotName = 'list-item';
|
|
ListItem.tagName = 'LI';
|
|
|
|
var List = function (_Container) {
|
|
_inherits(List, _Container);
|
|
|
|
_createClass(List, null, [{
|
|
key: 'create',
|
|
value: function create(value) {
|
|
var tagName = value === 'ordered' ? 'OL' : 'UL';
|
|
var node = _get(List.__proto__ || Object.getPrototypeOf(List), 'create', this).call(this, tagName);
|
|
if (value === 'checked' || value === 'unchecked') {
|
|
node.setAttribute('data-checked', value === 'checked');
|
|
}
|
|
return node;
|
|
}
|
|
}, {
|
|
key: 'formats',
|
|
value: function formats(domNode) {
|
|
if (domNode.tagName === 'OL') return 'ordered';
|
|
if (domNode.tagName === 'UL') {
|
|
if (domNode.hasAttribute('data-checked')) {
|
|
return domNode.getAttribute('data-checked') === 'true' ? 'checked' : 'unchecked';
|
|
} else {
|
|
return 'bullet';
|
|
}
|
|
}
|
|
return undefined;
|
|
}
|
|
}]);
|
|
|
|
function List(domNode) {
|
|
_classCallCheck(this, List);
|
|
|
|
var _this2 = _possibleConstructorReturn(this, (List.__proto__ || Object.getPrototypeOf(List)).call(this, domNode));
|
|
|
|
var listEventHandler = function listEventHandler(e) {
|
|
if (e.target.parentNode !== domNode) return;
|
|
var format = _this2.statics.formats(domNode);
|
|
var blot = _parchment2.default.find(e.target);
|
|
if (format === 'checked') {
|
|
blot.format('list', 'unchecked');
|
|
} else if (format === 'unchecked') {
|
|
blot.format('list', 'checked');
|
|
}
|
|
};
|
|
|
|
domNode.addEventListener('touchstart', listEventHandler);
|
|
domNode.addEventListener('mousedown', listEventHandler);
|
|
return _this2;
|
|
}
|
|
|
|
_createClass(List, [{
|
|
key: 'format',
|
|
value: function format(name, value) {
|
|
if (this.children.length > 0) {
|
|
this.children.tail.format(name, value);
|
|
}
|
|
}
|
|
}, {
|
|
key: 'formats',
|
|
value: function formats() {
|
|
// We don't inherit from FormatBlot
|
|
return _defineProperty({}, this.statics.blotName, this.statics.formats(this.domNode));
|
|
}
|
|
}, {
|
|
key: 'insertBefore',
|
|
value: function insertBefore(blot, ref) {
|
|
if (blot instanceof ListItem) {
|
|
_get(List.prototype.__proto__ || Object.getPrototypeOf(List.prototype), 'insertBefore', this).call(this, blot, ref);
|
|
} else {
|
|
var index = ref == null ? this.length() : ref.offset(this);
|
|
var after = this.split(index);
|
|
after.parent.insertBefore(blot, after);
|
|
}
|
|
}
|
|
}, {
|
|
key: 'optimize',
|
|
value: function optimize(context) {
|
|
_get(List.prototype.__proto__ || Object.getPrototypeOf(List.prototype), 'optimize', this).call(this, context);
|
|
var next = this.next;
|
|
if (next != null && next.prev === this && next.statics.blotName === this.statics.blotName && next.domNode.tagName === this.domNode.tagName && next.domNode.getAttribute('data-checked') === this.domNode.getAttribute('data-checked')) {
|
|
next.moveChildren(this);
|
|
next.remove();
|
|
}
|
|
}
|
|
}, {
|
|
key: 'replace',
|
|
value: function replace(target) {
|
|
if (target.statics.blotName !== this.statics.blotName) {
|
|
var item = _parchment2.default.create(this.statics.defaultChild);
|
|
target.moveChildren(item);
|
|
this.appendChild(item);
|
|
}
|
|
_get(List.prototype.__proto__ || Object.getPrototypeOf(List.prototype), 'replace', this).call(this, target);
|
|
}
|
|
}]);
|
|
|
|
return List;
|
|
}(_container2.default);
|
|
|
|
List.blotName = 'list';
|
|
List.scope = _parchment2.default.Scope.BLOCK_BLOT;
|
|
List.tagName = ['OL', 'UL'];
|
|
List.defaultChild = 'list-item';
|
|
List.allowedChildren = [ListItem];
|
|
|
|
exports.ListItem = ListItem;
|
|
exports.default = List;
|
|
|
|
/***/ }),
|
|
/* 68 */
|
|
/***/ (function(module, exports, __nested_webpack_require_389000__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _bold = __nested_webpack_require_389000__(56);
|
|
|
|
var _bold2 = _interopRequireDefault(_bold);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var Italic = function (_Bold) {
|
|
_inherits(Italic, _Bold);
|
|
|
|
function Italic() {
|
|
_classCallCheck(this, Italic);
|
|
|
|
return _possibleConstructorReturn(this, (Italic.__proto__ || Object.getPrototypeOf(Italic)).apply(this, arguments));
|
|
}
|
|
|
|
return Italic;
|
|
}(_bold2.default);
|
|
|
|
Italic.blotName = 'italic';
|
|
Italic.tagName = ['EM', 'I'];
|
|
|
|
exports.default = Italic;
|
|
|
|
/***/ }),
|
|
/* 69 */
|
|
/***/ (function(module, exports, __nested_webpack_require_390599__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _inline = __nested_webpack_require_390599__(6);
|
|
|
|
var _inline2 = _interopRequireDefault(_inline);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var Script = function (_Inline) {
|
|
_inherits(Script, _Inline);
|
|
|
|
function Script() {
|
|
_classCallCheck(this, Script);
|
|
|
|
return _possibleConstructorReturn(this, (Script.__proto__ || Object.getPrototypeOf(Script)).apply(this, arguments));
|
|
}
|
|
|
|
_createClass(Script, null, [{
|
|
key: 'create',
|
|
value: function create(value) {
|
|
if (value === 'super') {
|
|
return document.createElement('sup');
|
|
} else if (value === 'sub') {
|
|
return document.createElement('sub');
|
|
} else {
|
|
return _get(Script.__proto__ || Object.getPrototypeOf(Script), 'create', this).call(this, value);
|
|
}
|
|
}
|
|
}, {
|
|
key: 'formats',
|
|
value: function formats(domNode) {
|
|
if (domNode.tagName === 'SUB') return 'sub';
|
|
if (domNode.tagName === 'SUP') return 'super';
|
|
return undefined;
|
|
}
|
|
}]);
|
|
|
|
return Script;
|
|
}(_inline2.default);
|
|
|
|
Script.blotName = 'script';
|
|
Script.tagName = ['SUB', 'SUP'];
|
|
|
|
exports.default = Script;
|
|
|
|
/***/ }),
|
|
/* 70 */
|
|
/***/ (function(module, exports, __nested_webpack_require_393860__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _inline = __nested_webpack_require_393860__(6);
|
|
|
|
var _inline2 = _interopRequireDefault(_inline);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var Strike = function (_Inline) {
|
|
_inherits(Strike, _Inline);
|
|
|
|
function Strike() {
|
|
_classCallCheck(this, Strike);
|
|
|
|
return _possibleConstructorReturn(this, (Strike.__proto__ || Object.getPrototypeOf(Strike)).apply(this, arguments));
|
|
}
|
|
|
|
return Strike;
|
|
}(_inline2.default);
|
|
|
|
Strike.blotName = 'strike';
|
|
Strike.tagName = 'S';
|
|
|
|
exports.default = Strike;
|
|
|
|
/***/ }),
|
|
/* 71 */
|
|
/***/ (function(module, exports, __nested_webpack_require_395462__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _inline = __nested_webpack_require_395462__(6);
|
|
|
|
var _inline2 = _interopRequireDefault(_inline);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var Underline = function (_Inline) {
|
|
_inherits(Underline, _Inline);
|
|
|
|
function Underline() {
|
|
_classCallCheck(this, Underline);
|
|
|
|
return _possibleConstructorReturn(this, (Underline.__proto__ || Object.getPrototypeOf(Underline)).apply(this, arguments));
|
|
}
|
|
|
|
return Underline;
|
|
}(_inline2.default);
|
|
|
|
Underline.blotName = 'underline';
|
|
Underline.tagName = 'U';
|
|
|
|
exports.default = Underline;
|
|
|
|
/***/ }),
|
|
/* 72 */
|
|
/***/ (function(module, exports, __nested_webpack_require_397097__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _parchment = __nested_webpack_require_397097__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
var _link = __nested_webpack_require_397097__(27);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var ATTRIBUTES = ['alt', 'height', 'width'];
|
|
|
|
var Image = function (_Parchment$Embed) {
|
|
_inherits(Image, _Parchment$Embed);
|
|
|
|
function Image() {
|
|
_classCallCheck(this, Image);
|
|
|
|
return _possibleConstructorReturn(this, (Image.__proto__ || Object.getPrototypeOf(Image)).apply(this, arguments));
|
|
}
|
|
|
|
_createClass(Image, [{
|
|
key: 'format',
|
|
value: function format(name, value) {
|
|
if (ATTRIBUTES.indexOf(name) > -1) {
|
|
if (value) {
|
|
this.domNode.setAttribute(name, value);
|
|
} else {
|
|
this.domNode.removeAttribute(name);
|
|
}
|
|
} else {
|
|
_get(Image.prototype.__proto__ || Object.getPrototypeOf(Image.prototype), 'format', this).call(this, name, value);
|
|
}
|
|
}
|
|
}], [{
|
|
key: 'create',
|
|
value: function create(value) {
|
|
var node = _get(Image.__proto__ || Object.getPrototypeOf(Image), 'create', this).call(this, value);
|
|
if (typeof value === 'string') {
|
|
node.setAttribute('src', this.sanitize(value));
|
|
}
|
|
return node;
|
|
}
|
|
}, {
|
|
key: 'formats',
|
|
value: function formats(domNode) {
|
|
return ATTRIBUTES.reduce(function (formats, attribute) {
|
|
if (domNode.hasAttribute(attribute)) {
|
|
formats[attribute] = domNode.getAttribute(attribute);
|
|
}
|
|
return formats;
|
|
}, {});
|
|
}
|
|
}, {
|
|
key: 'match',
|
|
value: function match(url) {
|
|
return (/\.(jpe?g|gif|png)$/.test(url) || /^data:image\/.+;base64/.test(url)
|
|
);
|
|
}
|
|
}, {
|
|
key: 'sanitize',
|
|
value: function sanitize(url) {
|
|
return (0, _link.sanitize)(url, ['http', 'https', 'data']) ? url : '//:0';
|
|
}
|
|
}, {
|
|
key: 'value',
|
|
value: function value(domNode) {
|
|
return domNode.getAttribute('src');
|
|
}
|
|
}]);
|
|
|
|
return Image;
|
|
}(_parchment2.default.Embed);
|
|
|
|
Image.blotName = 'image';
|
|
Image.tagName = 'IMG';
|
|
|
|
exports.default = Image;
|
|
|
|
/***/ }),
|
|
/* 73 */
|
|
/***/ (function(module, exports, __nested_webpack_require_401311__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _block = __nested_webpack_require_401311__(4);
|
|
|
|
var _link = __nested_webpack_require_401311__(27);
|
|
|
|
var _link2 = _interopRequireDefault(_link);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var ATTRIBUTES = ['height', 'width'];
|
|
|
|
var Video = function (_BlockEmbed) {
|
|
_inherits(Video, _BlockEmbed);
|
|
|
|
function Video() {
|
|
_classCallCheck(this, Video);
|
|
|
|
return _possibleConstructorReturn(this, (Video.__proto__ || Object.getPrototypeOf(Video)).apply(this, arguments));
|
|
}
|
|
|
|
_createClass(Video, [{
|
|
key: 'format',
|
|
value: function format(name, value) {
|
|
if (ATTRIBUTES.indexOf(name) > -1) {
|
|
if (value) {
|
|
this.domNode.setAttribute(name, value);
|
|
} else {
|
|
this.domNode.removeAttribute(name);
|
|
}
|
|
} else {
|
|
_get(Video.prototype.__proto__ || Object.getPrototypeOf(Video.prototype), 'format', this).call(this, name, value);
|
|
}
|
|
}
|
|
}], [{
|
|
key: 'create',
|
|
value: function create(value) {
|
|
var node = _get(Video.__proto__ || Object.getPrototypeOf(Video), 'create', this).call(this, value);
|
|
node.setAttribute('frameborder', '0');
|
|
node.setAttribute('allowfullscreen', true);
|
|
node.setAttribute('src', this.sanitize(value));
|
|
return node;
|
|
}
|
|
}, {
|
|
key: 'formats',
|
|
value: function formats(domNode) {
|
|
return ATTRIBUTES.reduce(function (formats, attribute) {
|
|
if (domNode.hasAttribute(attribute)) {
|
|
formats[attribute] = domNode.getAttribute(attribute);
|
|
}
|
|
return formats;
|
|
}, {});
|
|
}
|
|
}, {
|
|
key: 'sanitize',
|
|
value: function sanitize(url) {
|
|
return _link2.default.sanitize(url);
|
|
}
|
|
}, {
|
|
key: 'value',
|
|
value: function value(domNode) {
|
|
return domNode.getAttribute('src');
|
|
}
|
|
}]);
|
|
|
|
return Video;
|
|
}(_block.BlockEmbed);
|
|
|
|
Video.blotName = 'video';
|
|
Video.className = 'ql-video';
|
|
Video.tagName = 'IFRAME';
|
|
|
|
exports.default = Video;
|
|
|
|
/***/ }),
|
|
/* 74 */
|
|
/***/ (function(module, exports, __nested_webpack_require_405371__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = exports.FormulaBlot = undefined;
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _embed = __nested_webpack_require_405371__(35);
|
|
|
|
var _embed2 = _interopRequireDefault(_embed);
|
|
|
|
var _quill = __nested_webpack_require_405371__(5);
|
|
|
|
var _quill2 = _interopRequireDefault(_quill);
|
|
|
|
var _module = __nested_webpack_require_405371__(9);
|
|
|
|
var _module2 = _interopRequireDefault(_module);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var FormulaBlot = function (_Embed) {
|
|
_inherits(FormulaBlot, _Embed);
|
|
|
|
function FormulaBlot() {
|
|
_classCallCheck(this, FormulaBlot);
|
|
|
|
return _possibleConstructorReturn(this, (FormulaBlot.__proto__ || Object.getPrototypeOf(FormulaBlot)).apply(this, arguments));
|
|
}
|
|
|
|
_createClass(FormulaBlot, null, [{
|
|
key: 'create',
|
|
value: function create(value) {
|
|
var node = _get(FormulaBlot.__proto__ || Object.getPrototypeOf(FormulaBlot), 'create', this).call(this, value);
|
|
if (typeof value === 'string') {
|
|
window.katex.render(value, node, {
|
|
throwOnError: false,
|
|
errorColor: '#f00'
|
|
});
|
|
node.setAttribute('data-value', value);
|
|
}
|
|
return node;
|
|
}
|
|
}, {
|
|
key: 'value',
|
|
value: function value(domNode) {
|
|
return domNode.getAttribute('data-value');
|
|
}
|
|
}]);
|
|
|
|
return FormulaBlot;
|
|
}(_embed2.default);
|
|
|
|
FormulaBlot.blotName = 'formula';
|
|
FormulaBlot.className = 'ql-formula';
|
|
FormulaBlot.tagName = 'SPAN';
|
|
|
|
var Formula = function (_Module) {
|
|
_inherits(Formula, _Module);
|
|
|
|
_createClass(Formula, null, [{
|
|
key: 'register',
|
|
value: function register() {
|
|
_quill2.default.register(FormulaBlot, true);
|
|
}
|
|
}]);
|
|
|
|
function Formula() {
|
|
_classCallCheck(this, Formula);
|
|
|
|
var _this2 = _possibleConstructorReturn(this, (Formula.__proto__ || Object.getPrototypeOf(Formula)).call(this));
|
|
|
|
if (window.katex == null) {
|
|
throw new Error('Formula module requires KaTeX.');
|
|
}
|
|
return _this2;
|
|
}
|
|
|
|
return Formula;
|
|
}(_module2.default);
|
|
|
|
exports.FormulaBlot = FormulaBlot;
|
|
exports.default = Formula;
|
|
|
|
/***/ }),
|
|
/* 75 */
|
|
/***/ (function(module, exports, __nested_webpack_require_409500__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = exports.CodeToken = exports.CodeBlock = undefined;
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _parchment = __nested_webpack_require_409500__(0);
|
|
|
|
var _parchment2 = _interopRequireDefault(_parchment);
|
|
|
|
var _quill = __nested_webpack_require_409500__(5);
|
|
|
|
var _quill2 = _interopRequireDefault(_quill);
|
|
|
|
var _module = __nested_webpack_require_409500__(9);
|
|
|
|
var _module2 = _interopRequireDefault(_module);
|
|
|
|
var _code = __nested_webpack_require_409500__(13);
|
|
|
|
var _code2 = _interopRequireDefault(_code);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var SyntaxCodeBlock = function (_CodeBlock) {
|
|
_inherits(SyntaxCodeBlock, _CodeBlock);
|
|
|
|
function SyntaxCodeBlock() {
|
|
_classCallCheck(this, SyntaxCodeBlock);
|
|
|
|
return _possibleConstructorReturn(this, (SyntaxCodeBlock.__proto__ || Object.getPrototypeOf(SyntaxCodeBlock)).apply(this, arguments));
|
|
}
|
|
|
|
_createClass(SyntaxCodeBlock, [{
|
|
key: 'replaceWith',
|
|
value: function replaceWith(block) {
|
|
this.domNode.textContent = this.domNode.textContent;
|
|
this.attach();
|
|
_get(SyntaxCodeBlock.prototype.__proto__ || Object.getPrototypeOf(SyntaxCodeBlock.prototype), 'replaceWith', this).call(this, block);
|
|
}
|
|
}, {
|
|
key: 'highlight',
|
|
value: function highlight(_highlight) {
|
|
var text = this.domNode.textContent;
|
|
if (this.cachedText !== text) {
|
|
if (text.trim().length > 0 || this.cachedText == null) {
|
|
this.domNode.innerHTML = _highlight(text);
|
|
this.domNode.normalize();
|
|
this.attach();
|
|
}
|
|
this.cachedText = text;
|
|
}
|
|
}
|
|
}]);
|
|
|
|
return SyntaxCodeBlock;
|
|
}(_code2.default);
|
|
|
|
SyntaxCodeBlock.className = 'ql-syntax';
|
|
|
|
var CodeToken = new _parchment2.default.Attributor.Class('token', 'hljs', {
|
|
scope: _parchment2.default.Scope.INLINE
|
|
});
|
|
|
|
var Syntax = function (_Module) {
|
|
_inherits(Syntax, _Module);
|
|
|
|
_createClass(Syntax, null, [{
|
|
key: 'register',
|
|
value: function register() {
|
|
_quill2.default.register(CodeToken, true);
|
|
_quill2.default.register(SyntaxCodeBlock, true);
|
|
}
|
|
}]);
|
|
|
|
function Syntax(quill, options) {
|
|
_classCallCheck(this, Syntax);
|
|
|
|
var _this2 = _possibleConstructorReturn(this, (Syntax.__proto__ || Object.getPrototypeOf(Syntax)).call(this, quill, options));
|
|
|
|
if (typeof _this2.options.highlight !== 'function') {
|
|
throw new Error('Syntax module requires highlight.js. Please include the library on the page before Quill.');
|
|
}
|
|
var timer = null;
|
|
_this2.quill.on(_quill2.default.events.SCROLL_OPTIMIZE, function () {
|
|
clearTimeout(timer);
|
|
timer = setTimeout(function () {
|
|
_this2.highlight();
|
|
timer = null;
|
|
}, _this2.options.interval);
|
|
});
|
|
_this2.highlight();
|
|
return _this2;
|
|
}
|
|
|
|
_createClass(Syntax, [{
|
|
key: 'highlight',
|
|
value: function highlight() {
|
|
var _this3 = this;
|
|
|
|
if (this.quill.selection.composing) return;
|
|
this.quill.update(_quill2.default.sources.USER);
|
|
var range = this.quill.getSelection();
|
|
this.quill.scroll.descendants(SyntaxCodeBlock).forEach(function (code) {
|
|
code.highlight(_this3.options.highlight);
|
|
});
|
|
this.quill.update(_quill2.default.sources.SILENT);
|
|
if (range != null) {
|
|
this.quill.setSelection(range, _quill2.default.sources.SILENT);
|
|
}
|
|
}
|
|
}]);
|
|
|
|
return Syntax;
|
|
}(_module2.default);
|
|
|
|
Syntax.DEFAULTS = {
|
|
highlight: function () {
|
|
if (window.hljs == null) return null;
|
|
return function (text) {
|
|
var result = window.hljs.highlightAuto(text);
|
|
return result.value;
|
|
};
|
|
}(),
|
|
interval: 1000
|
|
};
|
|
|
|
exports.CodeBlock = SyntaxCodeBlock;
|
|
exports.CodeToken = CodeToken;
|
|
exports.default = Syntax;
|
|
|
|
/***/ }),
|
|
/* 76 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=3 x2=15 y1=9 y2=9></line> <line class=ql-stroke x1=3 x2=13 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=9 y1=4 y2=4></line> </svg>";
|
|
|
|
/***/ }),
|
|
/* 77 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=15 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=14 x2=4 y1=14 y2=14></line> <line class=ql-stroke x1=12 x2=6 y1=4 y2=4></line> </svg>";
|
|
|
|
/***/ }),
|
|
/* 78 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=15 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=15 x2=5 y1=14 y2=14></line> <line class=ql-stroke x1=15 x2=9 y1=4 y2=4></line> </svg>";
|
|
|
|
/***/ }),
|
|
/* 79 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=15 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=15 x2=3 y1=14 y2=14></line> <line class=ql-stroke x1=15 x2=3 y1=4 y2=4></line> </svg>";
|
|
|
|
/***/ }),
|
|
/* 80 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <g class=\"ql-fill ql-color-label\"> <polygon points=\"6 6.868 6 6 5 6 5 7 5.942 7 6 6.868\"></polygon> <rect height=1 width=1 x=4 y=4></rect> <polygon points=\"6.817 5 6 5 6 6 6.38 6 6.817 5\"></polygon> <rect height=1 width=1 x=2 y=6></rect> <rect height=1 width=1 x=3 y=5></rect> <rect height=1 width=1 x=4 y=7></rect> <polygon points=\"4 11.439 4 11 3 11 3 12 3.755 12 4 11.439\"></polygon> <rect height=1 width=1 x=2 y=12></rect> <rect height=1 width=1 x=2 y=9></rect> <rect height=1 width=1 x=2 y=15></rect> <polygon points=\"4.63 10 4 10 4 11 4.192 11 4.63 10\"></polygon> <rect height=1 width=1 x=3 y=8></rect> <path d=M10.832,4.2L11,4.582V4H10.708A1.948,1.948,0,0,1,10.832,4.2Z></path> <path d=M7,4.582L7.168,4.2A1.929,1.929,0,0,1,7.292,4H7V4.582Z></path> <path d=M8,13H7.683l-0.351.8a1.933,1.933,0,0,1-.124.2H8V13Z></path> <rect height=1 width=1 x=12 y=2></rect> <rect height=1 width=1 x=11 y=3></rect> <path d=M9,3H8V3.282A1.985,1.985,0,0,1,9,3Z></path> <rect height=1 width=1 x=2 y=3></rect> <rect height=1 width=1 x=6 y=2></rect> <rect height=1 width=1 x=3 y=2></rect> <rect height=1 width=1 x=5 y=3></rect> <rect height=1 width=1 x=9 y=2></rect> <rect height=1 width=1 x=15 y=14></rect> <polygon points=\"13.447 10.174 13.469 10.225 13.472 10.232 13.808 11 14 11 14 10 13.37 10 13.447 10.174\"></polygon> <rect height=1 width=1 x=13 y=7></rect> <rect height=1 width=1 x=15 y=5></rect> <rect height=1 width=1 x=14 y=6></rect> <rect height=1 width=1 x=15 y=8></rect> <rect height=1 width=1 x=14 y=9></rect> <path d=M3.775,14H3v1H4V14.314A1.97,1.97,0,0,1,3.775,14Z></path> <rect height=1 width=1 x=14 y=3></rect> <polygon points=\"12 6.868 12 6 11.62 6 12 6.868\"></polygon> <rect height=1 width=1 x=15 y=2></rect> <rect height=1 width=1 x=12 y=5></rect> <rect height=1 width=1 x=13 y=4></rect> <polygon points=\"12.933 9 13 9 13 8 12.495 8 12.933 9\"></polygon> <rect height=1 width=1 x=9 y=14></rect> <rect height=1 width=1 x=8 y=15></rect> <path d=M6,14.926V15H7V14.316A1.993,1.993,0,0,1,6,14.926Z></path> <rect height=1 width=1 x=5 y=15></rect> <path d=M10.668,13.8L10.317,13H10v1h0.792A1.947,1.947,0,0,1,10.668,13.8Z></path> <rect height=1 width=1 x=11 y=15></rect> <path d=M14.332,12.2a1.99,1.99,0,0,1,.166.8H15V12H14.245Z></path> <rect height=1 width=1 x=14 y=15></rect> <rect height=1 width=1 x=15 y=11></rect> </g> <polyline class=ql-stroke points=\"5.5 13 9 5 12.5 13\"></polyline> <line class=ql-stroke x1=11.63 x2=6.38 y1=11 y2=11></line> </svg>";
|
|
|
|
/***/ }),
|
|
/* 81 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <rect class=\"ql-fill ql-stroke\" height=3 width=3 x=4 y=5></rect> <rect class=\"ql-fill ql-stroke\" height=3 width=3 x=11 y=5></rect> <path class=\"ql-even ql-fill ql-stroke\" d=M7,8c0,4.031-3,5-3,5></path> <path class=\"ql-even ql-fill ql-stroke\" d=M14,8c0,4.031-3,5-3,5></path> </svg>";
|
|
|
|
/***/ }),
|
|
/* 82 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-stroke d=M5,4H9.5A2.5,2.5,0,0,1,12,6.5v0A2.5,2.5,0,0,1,9.5,9H5A0,0,0,0,1,5,9V4A0,0,0,0,1,5,4Z></path> <path class=ql-stroke d=M5,9h5.5A2.5,2.5,0,0,1,13,11.5v0A2.5,2.5,0,0,1,10.5,14H5a0,0,0,0,1,0,0V9A0,0,0,0,1,5,9Z></path> </svg>";
|
|
|
|
/***/ }),
|
|
/* 83 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg class=\"\" viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=5 x2=13 y1=3 y2=3></line> <line class=ql-stroke x1=6 x2=9.35 y1=12 y2=3></line> <line class=ql-stroke x1=11 x2=15 y1=11 y2=15></line> <line class=ql-stroke x1=15 x2=11 y1=11 y2=15></line> <rect class=ql-fill height=1 rx=0.5 ry=0.5 width=7 x=2 y=14></rect> </svg>";
|
|
|
|
/***/ }),
|
|
/* 84 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=\"ql-color-label ql-stroke ql-transparent\" x1=3 x2=15 y1=15 y2=15></line> <polyline class=ql-stroke points=\"5.5 11 9 3 12.5 11\"></polyline> <line class=ql-stroke x1=11.63 x2=6.38 y1=9 y2=9></line> </svg>";
|
|
|
|
/***/ }),
|
|
/* 85 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <polygon class=\"ql-stroke ql-fill\" points=\"3 11 5 9 3 7 3 11\"></polygon> <line class=\"ql-stroke ql-fill\" x1=15 x2=11 y1=4 y2=4></line> <path class=ql-fill d=M11,3a3,3,0,0,0,0,6h1V3H11Z></path> <rect class=ql-fill height=11 width=1 x=11 y=4></rect> <rect class=ql-fill height=11 width=1 x=13 y=4></rect> </svg>";
|
|
|
|
/***/ }),
|
|
/* 86 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <polygon class=\"ql-stroke ql-fill\" points=\"15 12 13 10 15 8 15 12\"></polygon> <line class=\"ql-stroke ql-fill\" x1=9 x2=5 y1=4 y2=4></line> <path class=ql-fill d=M5,3A3,3,0,0,0,5,9H6V3H5Z></path> <rect class=ql-fill height=11 width=1 x=5 y=4></rect> <rect class=ql-fill height=11 width=1 x=7 y=4></rect> </svg>";
|
|
|
|
/***/ }),
|
|
/* 87 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M14,16H4a1,1,0,0,1,0-2H14A1,1,0,0,1,14,16Z /> <path class=ql-fill d=M14,4H4A1,1,0,0,1,4,2H14A1,1,0,0,1,14,4Z /> <rect class=ql-fill x=3 y=6 width=12 height=6 rx=1 ry=1 /> </svg>";
|
|
|
|
/***/ }),
|
|
/* 88 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M13,16H5a1,1,0,0,1,0-2h8A1,1,0,0,1,13,16Z /> <path class=ql-fill d=M13,4H5A1,1,0,0,1,5,2h8A1,1,0,0,1,13,4Z /> <rect class=ql-fill x=2 y=6 width=14 height=6 rx=1 ry=1 /> </svg>";
|
|
|
|
/***/ }),
|
|
/* 89 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M15,8H13a1,1,0,0,1,0-2h2A1,1,0,0,1,15,8Z /> <path class=ql-fill d=M15,12H13a1,1,0,0,1,0-2h2A1,1,0,0,1,15,12Z /> <path class=ql-fill d=M15,16H5a1,1,0,0,1,0-2H15A1,1,0,0,1,15,16Z /> <path class=ql-fill d=M15,4H5A1,1,0,0,1,5,2H15A1,1,0,0,1,15,4Z /> <rect class=ql-fill x=2 y=6 width=8 height=6 rx=1 ry=1 /> </svg>";
|
|
|
|
/***/ }),
|
|
/* 90 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M5,8H3A1,1,0,0,1,3,6H5A1,1,0,0,1,5,8Z /> <path class=ql-fill d=M5,12H3a1,1,0,0,1,0-2H5A1,1,0,0,1,5,12Z /> <path class=ql-fill d=M13,16H3a1,1,0,0,1,0-2H13A1,1,0,0,1,13,16Z /> <path class=ql-fill d=M13,4H3A1,1,0,0,1,3,2H13A1,1,0,0,1,13,4Z /> <rect class=ql-fill x=8 y=6 width=8 height=6 rx=1 ry=1 transform=\"translate(24 18) rotate(-180)\"/> </svg>";
|
|
|
|
/***/ }),
|
|
/* 91 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M11.759,2.482a2.561,2.561,0,0,0-3.53.607A7.656,7.656,0,0,0,6.8,6.2C6.109,9.188,5.275,14.677,4.15,14.927a1.545,1.545,0,0,0-1.3-.933A0.922,0.922,0,0,0,2,15.036S1.954,16,4.119,16s3.091-2.691,3.7-5.553c0.177-.826.36-1.726,0.554-2.6L8.775,6.2c0.381-1.421.807-2.521,1.306-2.676a1.014,1.014,0,0,0,1.02.56A0.966,0.966,0,0,0,11.759,2.482Z></path> <rect class=ql-fill height=1.6 rx=0.8 ry=0.8 width=5 x=5.15 y=6.2></rect> <path class=ql-fill d=M13.663,12.027a1.662,1.662,0,0,1,.266-0.276q0.193,0.069.456,0.138a2.1,2.1,0,0,0,.535.069,1.075,1.075,0,0,0,.767-0.3,1.044,1.044,0,0,0,.314-0.8,0.84,0.84,0,0,0-.238-0.619,0.8,0.8,0,0,0-.594-0.239,1.154,1.154,0,0,0-.781.3,4.607,4.607,0,0,0-.781,1q-0.091.15-.218,0.346l-0.246.38c-0.068-.288-0.137-0.582-0.212-0.885-0.459-1.847-2.494-.984-2.941-0.8-0.482.2-.353,0.647-0.094,0.529a0.869,0.869,0,0,1,1.281.585c0.217,0.751.377,1.436,0.527,2.038a5.688,5.688,0,0,1-.362.467,2.69,2.69,0,0,1-.264.271q-0.221-.08-0.471-0.147a2.029,2.029,0,0,0-.522-0.066,1.079,1.079,0,0,0-.768.3A1.058,1.058,0,0,0,9,15.131a0.82,0.82,0,0,0,.832.852,1.134,1.134,0,0,0,.787-0.3,5.11,5.11,0,0,0,.776-0.993q0.141-.219.215-0.34c0.046-.076.122-0.194,0.223-0.346a2.786,2.786,0,0,0,.918,1.726,2.582,2.582,0,0,0,2.376-.185c0.317-.181.212-0.565,0-0.494A0.807,0.807,0,0,1,14.176,15a5.159,5.159,0,0,1-.913-2.446l0,0Q13.487,12.24,13.663,12.027Z></path> </svg>";
|
|
|
|
/***/ }),
|
|
/* 92 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewBox=\"0 0 18 18\"> <path class=ql-fill d=M10,4V14a1,1,0,0,1-2,0V10H3v4a1,1,0,0,1-2,0V4A1,1,0,0,1,3,4V8H8V4a1,1,0,0,1,2,0Zm6.06787,9.209H14.98975V7.59863a.54085.54085,0,0,0-.605-.60547h-.62744a1.01119,1.01119,0,0,0-.748.29688L11.645,8.56641a.5435.5435,0,0,0-.022.8584l.28613.30762a.53861.53861,0,0,0,.84717.0332l.09912-.08789a1.2137,1.2137,0,0,0,.2417-.35254h.02246s-.01123.30859-.01123.60547V13.209H12.041a.54085.54085,0,0,0-.605.60547v.43945a.54085.54085,0,0,0,.605.60547h4.02686a.54085.54085,0,0,0,.605-.60547v-.43945A.54085.54085,0,0,0,16.06787,13.209Z /> </svg>";
|
|
|
|
/***/ }),
|
|
/* 93 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewBox=\"0 0 18 18\"> <path class=ql-fill d=M16.73975,13.81445v.43945a.54085.54085,0,0,1-.605.60547H11.855a.58392.58392,0,0,1-.64893-.60547V14.0127c0-2.90527,3.39941-3.42187,3.39941-4.55469a.77675.77675,0,0,0-.84717-.78125,1.17684,1.17684,0,0,0-.83594.38477c-.2749.26367-.561.374-.85791.13184l-.4292-.34082c-.30811-.24219-.38525-.51758-.1543-.81445a2.97155,2.97155,0,0,1,2.45361-1.17676,2.45393,2.45393,0,0,1,2.68408,2.40918c0,2.45312-3.1792,2.92676-3.27832,3.93848h2.79443A.54085.54085,0,0,1,16.73975,13.81445ZM9,3A.99974.99974,0,0,0,8,4V8H3V4A1,1,0,0,0,1,4V14a1,1,0,0,0,2,0V10H8v4a1,1,0,0,0,2,0V4A.99974.99974,0,0,0,9,3Z /> </svg>";
|
|
|
|
/***/ }),
|
|
/* 94 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=7 x2=13 y1=4 y2=4></line> <line class=ql-stroke x1=5 x2=11 y1=14 y2=14></line> <line class=ql-stroke x1=8 x2=10 y1=14 y2=4></line> </svg>";
|
|
|
|
/***/ }),
|
|
/* 95 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <rect class=ql-stroke height=10 width=12 x=3 y=4></rect> <circle class=ql-fill cx=6 cy=7 r=1></circle> <polyline class=\"ql-even ql-fill\" points=\"5 12 5 11 7 9 8 10 11 7 13 9 13 12 5 12\"></polyline> </svg>";
|
|
|
|
/***/ }),
|
|
/* 96 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=3 x2=15 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=9 x2=15 y1=9 y2=9></line> <polyline class=\"ql-fill ql-stroke\" points=\"3 7 3 11 5 9 3 7\"></polyline> </svg>";
|
|
|
|
/***/ }),
|
|
/* 97 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=3 x2=15 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=9 x2=15 y1=9 y2=9></line> <polyline class=ql-stroke points=\"5 7 5 11 3 9 5 7\"></polyline> </svg>";
|
|
|
|
/***/ }),
|
|
/* 98 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=7 x2=11 y1=7 y2=11></line> <path class=\"ql-even ql-stroke\" d=M8.9,4.577a3.476,3.476,0,0,1,.36,4.679A3.476,3.476,0,0,1,4.577,8.9C3.185,7.5,2.035,6.4,4.217,4.217S7.5,3.185,8.9,4.577Z></path> <path class=\"ql-even ql-stroke\" d=M13.423,9.1a3.476,3.476,0,0,0-4.679-.36,3.476,3.476,0,0,0,.36,4.679c1.392,1.392,2.5,2.542,4.679.36S14.815,10.5,13.423,9.1Z></path> </svg>";
|
|
|
|
/***/ }),
|
|
/* 99 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=7 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=7 x2=15 y1=9 y2=9></line> <line class=ql-stroke x1=7 x2=15 y1=14 y2=14></line> <line class=\"ql-stroke ql-thin\" x1=2.5 x2=4.5 y1=5.5 y2=5.5></line> <path class=ql-fill d=M3.5,6A0.5,0.5,0,0,1,3,5.5V3.085l-0.276.138A0.5,0.5,0,0,1,2.053,3c-0.124-.247-0.023-0.324.224-0.447l1-.5A0.5,0.5,0,0,1,4,2.5v3A0.5,0.5,0,0,1,3.5,6Z></path> <path class=\"ql-stroke ql-thin\" d=M4.5,10.5h-2c0-.234,1.85-1.076,1.85-2.234A0.959,0.959,0,0,0,2.5,8.156></path> <path class=\"ql-stroke ql-thin\" d=M2.5,14.846a0.959,0.959,0,0,0,1.85-.109A0.7,0.7,0,0,0,3.75,14a0.688,0.688,0,0,0,.6-0.736,0.959,0.959,0,0,0-1.85-.109></path> </svg>";
|
|
|
|
/***/ }),
|
|
/* 100 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=6 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=6 x2=15 y1=9 y2=9></line> <line class=ql-stroke x1=6 x2=15 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=3 y1=4 y2=4></line> <line class=ql-stroke x1=3 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=3 x2=3 y1=14 y2=14></line> </svg>";
|
|
|
|
/***/ }),
|
|
/* 101 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg class=\"\" viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=9 x2=15 y1=4 y2=4></line> <polyline class=ql-stroke points=\"3 4 4 5 6 3\"></polyline> <line class=ql-stroke x1=9 x2=15 y1=14 y2=14></line> <polyline class=ql-stroke points=\"3 14 4 15 6 13\"></polyline> <line class=ql-stroke x1=9 x2=15 y1=9 y2=9></line> <polyline class=ql-stroke points=\"3 9 4 10 6 8\"></polyline> </svg>";
|
|
|
|
/***/ }),
|
|
/* 102 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M15.5,15H13.861a3.858,3.858,0,0,0,1.914-2.975,1.8,1.8,0,0,0-1.6-1.751A1.921,1.921,0,0,0,12.021,11.7a0.50013,0.50013,0,1,0,.957.291h0a0.914,0.914,0,0,1,1.053-.725,0.81,0.81,0,0,1,.744.762c0,1.076-1.16971,1.86982-1.93971,2.43082A1.45639,1.45639,0,0,0,12,15.5a0.5,0.5,0,0,0,.5.5h3A0.5,0.5,0,0,0,15.5,15Z /> <path class=ql-fill d=M9.65,5.241a1,1,0,0,0-1.409.108L6,7.964,3.759,5.349A1,1,0,0,0,2.192,6.59178Q2.21541,6.6213,2.241,6.649L4.684,9.5,2.241,12.35A1,1,0,0,0,3.71,13.70722q0.02557-.02768.049-0.05722L6,11.036,8.241,13.65a1,1,0,1,0,1.567-1.24277Q9.78459,12.3777,9.759,12.35L7.316,9.5,9.759,6.651A1,1,0,0,0,9.65,5.241Z /> </svg>";
|
|
|
|
/***/ }),
|
|
/* 103 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M15.5,7H13.861a4.015,4.015,0,0,0,1.914-2.975,1.8,1.8,0,0,0-1.6-1.751A1.922,1.922,0,0,0,12.021,3.7a0.5,0.5,0,1,0,.957.291,0.917,0.917,0,0,1,1.053-.725,0.81,0.81,0,0,1,.744.762c0,1.077-1.164,1.925-1.934,2.486A1.423,1.423,0,0,0,12,7.5a0.5,0.5,0,0,0,.5.5h3A0.5,0.5,0,0,0,15.5,7Z /> <path class=ql-fill d=M9.651,5.241a1,1,0,0,0-1.41.108L6,7.964,3.759,5.349a1,1,0,1,0-1.519,1.3L4.683,9.5,2.241,12.35a1,1,0,1,0,1.519,1.3L6,11.036,8.241,13.65a1,1,0,0,0,1.519-1.3L7.317,9.5,9.759,6.651A1,1,0,0,0,9.651,5.241Z /> </svg>";
|
|
|
|
/***/ }),
|
|
/* 104 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=\"ql-stroke ql-thin\" x1=15.5 x2=2.5 y1=8.5 y2=9.5></line> <path class=ql-fill d=M9.007,8C6.542,7.791,6,7.519,6,6.5,6,5.792,7.283,5,9,5c1.571,0,2.765.679,2.969,1.309a1,1,0,0,0,1.9-.617C13.356,4.106,11.354,3,9,3,6.2,3,4,4.538,4,6.5a3.2,3.2,0,0,0,.5,1.843Z></path> <path class=ql-fill d=M8.984,10C11.457,10.208,12,10.479,12,11.5c0,0.708-1.283,1.5-3,1.5-1.571,0-2.765-.679-2.969-1.309a1,1,0,1,0-1.9.617C4.644,13.894,6.646,15,9,15c2.8,0,5-1.538,5-3.5a3.2,3.2,0,0,0-.5-1.843Z></path> </svg>";
|
|
|
|
/***/ }),
|
|
/* 105 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-stroke d=M5,3V9a4.012,4.012,0,0,0,4,4H9a4.012,4.012,0,0,0,4-4V3></path> <rect class=ql-fill height=1 rx=0.5 ry=0.5 width=12 x=3 y=15></rect> </svg>";
|
|
|
|
/***/ }),
|
|
/* 106 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <rect class=ql-stroke height=12 width=12 x=3 y=3></rect> <rect class=ql-fill height=12 width=1 x=5 y=3></rect> <rect class=ql-fill height=12 width=1 x=12 y=3></rect> <rect class=ql-fill height=2 width=8 x=5 y=8></rect> <rect class=ql-fill height=1 width=3 x=3 y=5></rect> <rect class=ql-fill height=1 width=3 x=3 y=7></rect> <rect class=ql-fill height=1 width=3 x=3 y=10></rect> <rect class=ql-fill height=1 width=3 x=3 y=12></rect> <rect class=ql-fill height=1 width=3 x=12 y=5></rect> <rect class=ql-fill height=1 width=3 x=12 y=7></rect> <rect class=ql-fill height=1 width=3 x=12 y=10></rect> <rect class=ql-fill height=1 width=3 x=12 y=12></rect> </svg>";
|
|
|
|
/***/ }),
|
|
/* 107 */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = "<svg viewbox=\"0 0 18 18\"> <polygon class=ql-stroke points=\"7 11 9 13 11 11 7 11\"></polygon> <polygon class=ql-stroke points=\"7 7 9 5 11 7 7 7\"></polygon> </svg>";
|
|
|
|
/***/ }),
|
|
/* 108 */
|
|
/***/ (function(module, exports, __nested_webpack_require_432266__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = exports.BubbleTooltip = undefined;
|
|
|
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
var _extend = __nested_webpack_require_432266__(3);
|
|
|
|
var _extend2 = _interopRequireDefault(_extend);
|
|
|
|
var _emitter = __nested_webpack_require_432266__(8);
|
|
|
|
var _emitter2 = _interopRequireDefault(_emitter);
|
|
|
|
var _base = __nested_webpack_require_432266__(43);
|
|
|
|
var _base2 = _interopRequireDefault(_base);
|
|
|
|
var _selection = __nested_webpack_require_432266__(15);
|
|
|
|
var _icons = __nested_webpack_require_432266__(41);
|
|
|
|
var _icons2 = _interopRequireDefault(_icons);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var TOOLBAR_CONFIG = [['bold', 'italic', 'link'], [{ header: 1 }, { header: 2 }, 'blockquote']];
|
|
|
|
var BubbleTheme = function (_BaseTheme) {
|
|
_inherits(BubbleTheme, _BaseTheme);
|
|
|
|
function BubbleTheme(quill, options) {
|
|
_classCallCheck(this, BubbleTheme);
|
|
|
|
if (options.modules.toolbar != null && options.modules.toolbar.container == null) {
|
|
options.modules.toolbar.container = TOOLBAR_CONFIG;
|
|
}
|
|
|
|
var _this = _possibleConstructorReturn(this, (BubbleTheme.__proto__ || Object.getPrototypeOf(BubbleTheme)).call(this, quill, options));
|
|
|
|
_this.quill.container.classList.add('ql-bubble');
|
|
return _this;
|
|
}
|
|
|
|
_createClass(BubbleTheme, [{
|
|
key: 'extendToolbar',
|
|
value: function extendToolbar(toolbar) {
|
|
this.tooltip = new BubbleTooltip(this.quill, this.options.bounds);
|
|
this.tooltip.root.appendChild(toolbar.container);
|
|
this.buildButtons([].slice.call(toolbar.container.querySelectorAll('button')), _icons2.default);
|
|
this.buildPickers([].slice.call(toolbar.container.querySelectorAll('select')), _icons2.default);
|
|
}
|
|
}]);
|
|
|
|
return BubbleTheme;
|
|
}(_base2.default);
|
|
|
|
BubbleTheme.DEFAULTS = (0, _extend2.default)(true, {}, _base2.default.DEFAULTS, {
|
|
modules: {
|
|
toolbar: {
|
|
handlers: {
|
|
link: function link(value) {
|
|
if (!value) {
|
|
this.quill.format('link', false);
|
|
} else {
|
|
this.quill.theme.tooltip.edit();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
var BubbleTooltip = function (_BaseTooltip) {
|
|
_inherits(BubbleTooltip, _BaseTooltip);
|
|
|
|
function BubbleTooltip(quill, bounds) {
|
|
_classCallCheck(this, BubbleTooltip);
|
|
|
|
var _this2 = _possibleConstructorReturn(this, (BubbleTooltip.__proto__ || Object.getPrototypeOf(BubbleTooltip)).call(this, quill, bounds));
|
|
|
|
_this2.quill.on(_emitter2.default.events.EDITOR_CHANGE, function (type, range, oldRange, source) {
|
|
if (type !== _emitter2.default.events.SELECTION_CHANGE) return;
|
|
if (range != null && range.length > 0 && source === _emitter2.default.sources.USER) {
|
|
_this2.show();
|
|
// Lock our width so we will expand beyond our offsetParent boundaries
|
|
_this2.root.style.left = '0px';
|
|
_this2.root.style.width = '';
|
|
_this2.root.style.width = _this2.root.offsetWidth + 'px';
|
|
var lines = _this2.quill.getLines(range.index, range.length);
|
|
if (lines.length === 1) {
|
|
_this2.position(_this2.quill.getBounds(range));
|
|
} else {
|
|
var lastLine = lines[lines.length - 1];
|
|
var index = _this2.quill.getIndex(lastLine);
|
|
var length = Math.min(lastLine.length() - 1, range.index + range.length - index);
|
|
var _bounds = _this2.quill.getBounds(new _selection.Range(index, length));
|
|
_this2.position(_bounds);
|
|
}
|
|
} else if (document.activeElement !== _this2.textbox && _this2.quill.hasFocus()) {
|
|
_this2.hide();
|
|
}
|
|
});
|
|
return _this2;
|
|
}
|
|
|
|
_createClass(BubbleTooltip, [{
|
|
key: 'listen',
|
|
value: function listen() {
|
|
var _this3 = this;
|
|
|
|
_get(BubbleTooltip.prototype.__proto__ || Object.getPrototypeOf(BubbleTooltip.prototype), 'listen', this).call(this);
|
|
this.root.querySelector('.ql-close').addEventListener('click', function () {
|
|
_this3.root.classList.remove('ql-editing');
|
|
});
|
|
this.quill.on(_emitter2.default.events.SCROLL_OPTIMIZE, function () {
|
|
// Let selection be restored by toolbar handlers before repositioning
|
|
setTimeout(function () {
|
|
if (_this3.root.classList.contains('ql-hidden')) return;
|
|
var range = _this3.quill.getSelection();
|
|
if (range != null) {
|
|
_this3.position(_this3.quill.getBounds(range));
|
|
}
|
|
}, 1);
|
|
});
|
|
}
|
|
}, {
|
|
key: 'cancel',
|
|
value: function cancel() {
|
|
this.show();
|
|
}
|
|
}, {
|
|
key: 'position',
|
|
value: function position(reference) {
|
|
var shift = _get(BubbleTooltip.prototype.__proto__ || Object.getPrototypeOf(BubbleTooltip.prototype), 'position', this).call(this, reference);
|
|
var arrow = this.root.querySelector('.ql-tooltip-arrow');
|
|
arrow.style.marginLeft = '';
|
|
if (shift === 0) return shift;
|
|
arrow.style.marginLeft = -1 * shift - arrow.offsetWidth / 2 + 'px';
|
|
}
|
|
}]);
|
|
|
|
return BubbleTooltip;
|
|
}(_base.BaseTooltip);
|
|
|
|
BubbleTooltip.TEMPLATE = ['<span class="ql-tooltip-arrow"></span>', '<div class="ql-tooltip-editor">', '<input type="text" data-formula="e=mc^2" data-link="https://quilljs.com" data-video="Embed URL">', '<a class="ql-close"></a>', '</div>'].join('');
|
|
|
|
exports.BubbleTooltip = BubbleTooltip;
|
|
exports.default = BubbleTheme;
|
|
|
|
/***/ }),
|
|
/* 109 */
|
|
/***/ (function(module, exports, __nested_webpack_require_439588__) {
|
|
|
|
module.exports = __nested_webpack_require_439588__(63);
|
|
|
|
|
|
/***/ })
|
|
/******/ ])["default"];
|
|
});
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/formats/align.js":
|
|
/*!*********************************************!*\
|
|
!*** ./node_modules/quill/formats/align.js ***!
|
|
\*********************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "AlignAttribute": () => (/* binding */ AlignAttribute),
|
|
/* harmony export */ "AlignClass": () => (/* binding */ AlignClass),
|
|
/* harmony export */ "AlignStyle": () => (/* binding */ AlignStyle)
|
|
/* harmony export */ });
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! parchment */ "./node_modules/parchment/dist/parchment.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(parchment__WEBPACK_IMPORTED_MODULE_0__);
|
|
|
|
|
|
let config = {
|
|
scope: (parchment__WEBPACK_IMPORTED_MODULE_0___default().Scope.BLOCK),
|
|
whitelist: ['right', 'center', 'justify']
|
|
};
|
|
|
|
let AlignAttribute = new (parchment__WEBPACK_IMPORTED_MODULE_0___default().Attributor.Attribute)('align', 'align', config);
|
|
let AlignClass = new (parchment__WEBPACK_IMPORTED_MODULE_0___default().Attributor.Class)('align', 'ql-align', config);
|
|
let AlignStyle = new (parchment__WEBPACK_IMPORTED_MODULE_0___default().Attributor.Style)('align', 'text-align', config);
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/formats/background.js":
|
|
/*!**************************************************!*\
|
|
!*** ./node_modules/quill/formats/background.js ***!
|
|
\**************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "BackgroundClass": () => (/* binding */ BackgroundClass),
|
|
/* harmony export */ "BackgroundStyle": () => (/* binding */ BackgroundStyle)
|
|
/* harmony export */ });
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! parchment */ "./node_modules/parchment/dist/parchment.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(parchment__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var _color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./color */ "./node_modules/quill/formats/color.js");
|
|
|
|
|
|
|
|
let BackgroundClass = new (parchment__WEBPACK_IMPORTED_MODULE_0___default().Attributor.Class)('background', 'ql-bg', {
|
|
scope: (parchment__WEBPACK_IMPORTED_MODULE_0___default().Scope.INLINE)
|
|
});
|
|
let BackgroundStyle = new _color__WEBPACK_IMPORTED_MODULE_1__.ColorAttributor('background', 'background-color', {
|
|
scope: (parchment__WEBPACK_IMPORTED_MODULE_0___default().Scope.INLINE)
|
|
});
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/formats/code.js":
|
|
/*!********************************************!*\
|
|
!*** ./node_modules/quill/formats/code.js ***!
|
|
\********************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "Code": () => (/* binding */ Code),
|
|
/* harmony export */ "default": () => (/* binding */ CodeBlock)
|
|
/* harmony export */ });
|
|
/* harmony import */ var quill_delta__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! quill-delta */ "./node_modules/quill-delta/lib/delta.js");
|
|
/* harmony import */ var quill_delta__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(quill_delta__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! parchment */ "./node_modules/parchment/dist/parchment.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(parchment__WEBPACK_IMPORTED_MODULE_1__);
|
|
/* harmony import */ var _blots_block__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../blots/block */ "./node_modules/quill/blots/block.js");
|
|
/* harmony import */ var _blots_inline__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../blots/inline */ "./node_modules/quill/blots/inline.js");
|
|
/* harmony import */ var _blots_text__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../blots/text */ "./node_modules/quill/blots/text.js");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Code extends _blots_inline__WEBPACK_IMPORTED_MODULE_3__.default {}
|
|
Code.blotName = 'code';
|
|
Code.tagName = 'CODE';
|
|
|
|
|
|
class CodeBlock extends _blots_block__WEBPACK_IMPORTED_MODULE_2__.default {
|
|
static create(value) {
|
|
let domNode = super.create(value);
|
|
domNode.setAttribute('spellcheck', false);
|
|
return domNode;
|
|
}
|
|
|
|
static formats() {
|
|
return true;
|
|
}
|
|
|
|
delta() {
|
|
let text = this.domNode.textContent;
|
|
if (text.endsWith('\n')) { // Should always be true
|
|
text = text.slice(0, -1);
|
|
}
|
|
return text.split('\n').reduce((delta, frag) => {
|
|
return delta.insert(frag).insert('\n', this.formats());
|
|
}, new (quill_delta__WEBPACK_IMPORTED_MODULE_0___default())());
|
|
}
|
|
|
|
format(name, value) {
|
|
if (name === this.statics.blotName && value) return;
|
|
let [text, ] = this.descendant(_blots_text__WEBPACK_IMPORTED_MODULE_4__.default, this.length() - 1);
|
|
if (text != null) {
|
|
text.deleteAt(text.length() - 1, 1);
|
|
}
|
|
super.format(name, value);
|
|
}
|
|
|
|
formatAt(index, length, name, value) {
|
|
if (length === 0) return;
|
|
if (parchment__WEBPACK_IMPORTED_MODULE_1___default().query(name, (parchment__WEBPACK_IMPORTED_MODULE_1___default().Scope.BLOCK)) == null ||
|
|
(name === this.statics.blotName && value === this.statics.formats(this.domNode))) {
|
|
return;
|
|
}
|
|
let nextNewline = this.newlineIndex(index);
|
|
if (nextNewline < 0 || nextNewline >= index + length) return;
|
|
let prevNewline = this.newlineIndex(index, true) + 1;
|
|
let isolateLength = nextNewline - prevNewline + 1;
|
|
let blot = this.isolate(prevNewline, isolateLength);
|
|
let next = blot.next;
|
|
blot.format(name, value);
|
|
if (next instanceof CodeBlock) {
|
|
next.formatAt(0, index - prevNewline + length - isolateLength, name, value);
|
|
}
|
|
}
|
|
|
|
insertAt(index, value, def) {
|
|
if (def != null) return;
|
|
let [text, offset] = this.descendant(_blots_text__WEBPACK_IMPORTED_MODULE_4__.default, index);
|
|
text.insertAt(offset, value);
|
|
}
|
|
|
|
length() {
|
|
let length = this.domNode.textContent.length;
|
|
if (!this.domNode.textContent.endsWith('\n')) {
|
|
return length + 1;
|
|
}
|
|
return length;
|
|
}
|
|
|
|
newlineIndex(searchIndex, reverse = false) {
|
|
if (!reverse) {
|
|
let offset = this.domNode.textContent.slice(searchIndex).indexOf('\n');
|
|
return offset > -1 ? searchIndex + offset : -1;
|
|
} else {
|
|
return this.domNode.textContent.slice(0, searchIndex).lastIndexOf('\n');
|
|
}
|
|
}
|
|
|
|
optimize(context) {
|
|
if (!this.domNode.textContent.endsWith('\n')) {
|
|
this.appendChild(parchment__WEBPACK_IMPORTED_MODULE_1___default().create('text', '\n'));
|
|
}
|
|
super.optimize(context);
|
|
let next = this.next;
|
|
if (next != null && next.prev === this &&
|
|
next.statics.blotName === this.statics.blotName &&
|
|
this.statics.formats(this.domNode) === next.statics.formats(next.domNode)) {
|
|
next.optimize(context);
|
|
next.moveChildren(this);
|
|
next.remove();
|
|
}
|
|
}
|
|
|
|
replace(target) {
|
|
super.replace(target);
|
|
[].slice.call(this.domNode.querySelectorAll('*')).forEach(function(node) {
|
|
let blot = parchment__WEBPACK_IMPORTED_MODULE_1___default().find(node);
|
|
if (blot == null) {
|
|
node.parentNode.removeChild(node);
|
|
} else if (blot instanceof (parchment__WEBPACK_IMPORTED_MODULE_1___default().Embed)) {
|
|
blot.remove();
|
|
} else {
|
|
blot.unwrap();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
CodeBlock.blotName = 'code-block';
|
|
CodeBlock.tagName = 'PRE';
|
|
CodeBlock.TAB = ' ';
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/formats/color.js":
|
|
/*!*********************************************!*\
|
|
!*** ./node_modules/quill/formats/color.js ***!
|
|
\*********************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "ColorAttributor": () => (/* binding */ ColorAttributor),
|
|
/* harmony export */ "ColorClass": () => (/* binding */ ColorClass),
|
|
/* harmony export */ "ColorStyle": () => (/* binding */ ColorStyle)
|
|
/* harmony export */ });
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! parchment */ "./node_modules/parchment/dist/parchment.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(parchment__WEBPACK_IMPORTED_MODULE_0__);
|
|
|
|
|
|
class ColorAttributor extends (parchment__WEBPACK_IMPORTED_MODULE_0___default().Attributor.Style) {
|
|
value(domNode) {
|
|
let value = super.value(domNode);
|
|
if (!value.startsWith('rgb(')) return value;
|
|
value = value.replace(/^[^\d]+/, '').replace(/[^\d]+$/, '');
|
|
return '#' + value.split(',').map(function(component) {
|
|
return ('00' + parseInt(component).toString(16)).slice(-2);
|
|
}).join('');
|
|
}
|
|
}
|
|
|
|
let ColorClass = new (parchment__WEBPACK_IMPORTED_MODULE_0___default().Attributor.Class)('color', 'ql-color', {
|
|
scope: (parchment__WEBPACK_IMPORTED_MODULE_0___default().Scope.INLINE)
|
|
});
|
|
let ColorStyle = new ColorAttributor('color', 'color', {
|
|
scope: (parchment__WEBPACK_IMPORTED_MODULE_0___default().Scope.INLINE)
|
|
});
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/formats/direction.js":
|
|
/*!*************************************************!*\
|
|
!*** ./node_modules/quill/formats/direction.js ***!
|
|
\*************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "DirectionAttribute": () => (/* binding */ DirectionAttribute),
|
|
/* harmony export */ "DirectionClass": () => (/* binding */ DirectionClass),
|
|
/* harmony export */ "DirectionStyle": () => (/* binding */ DirectionStyle)
|
|
/* harmony export */ });
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! parchment */ "./node_modules/parchment/dist/parchment.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(parchment__WEBPACK_IMPORTED_MODULE_0__);
|
|
|
|
|
|
let config = {
|
|
scope: (parchment__WEBPACK_IMPORTED_MODULE_0___default().Scope.BLOCK),
|
|
whitelist: ['rtl']
|
|
};
|
|
|
|
let DirectionAttribute = new (parchment__WEBPACK_IMPORTED_MODULE_0___default().Attributor.Attribute)('direction', 'dir', config);
|
|
let DirectionClass = new (parchment__WEBPACK_IMPORTED_MODULE_0___default().Attributor.Class)('direction', 'ql-direction', config);
|
|
let DirectionStyle = new (parchment__WEBPACK_IMPORTED_MODULE_0___default().Attributor.Style)('direction', 'direction', config);
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/formats/font.js":
|
|
/*!********************************************!*\
|
|
!*** ./node_modules/quill/formats/font.js ***!
|
|
\********************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "FontStyle": () => (/* binding */ FontStyle),
|
|
/* harmony export */ "FontClass": () => (/* binding */ FontClass)
|
|
/* harmony export */ });
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! parchment */ "./node_modules/parchment/dist/parchment.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(parchment__WEBPACK_IMPORTED_MODULE_0__);
|
|
|
|
|
|
let config = {
|
|
scope: (parchment__WEBPACK_IMPORTED_MODULE_0___default().Scope.INLINE),
|
|
whitelist: ['serif', 'monospace']
|
|
};
|
|
|
|
let FontClass = new (parchment__WEBPACK_IMPORTED_MODULE_0___default().Attributor.Class)('font', 'ql-font', config);
|
|
|
|
class FontStyleAttributor extends (parchment__WEBPACK_IMPORTED_MODULE_0___default().Attributor.Style) {
|
|
value(node) {
|
|
return super.value(node).replace(/["']/g, '');
|
|
}
|
|
}
|
|
|
|
let FontStyle = new FontStyleAttributor('font', 'font-family', config);
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/formats/link.js":
|
|
/*!********************************************!*\
|
|
!*** ./node_modules/quill/formats/link.js ***!
|
|
\********************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (/* binding */ Link),
|
|
/* harmony export */ "sanitize": () => (/* binding */ sanitize)
|
|
/* harmony export */ });
|
|
/* harmony import */ var _blots_inline__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../blots/inline */ "./node_modules/quill/blots/inline.js");
|
|
|
|
|
|
|
|
class Link extends _blots_inline__WEBPACK_IMPORTED_MODULE_0__.default {
|
|
static create(value) {
|
|
let node = super.create(value);
|
|
value = this.sanitize(value);
|
|
node.setAttribute('href', value);
|
|
node.setAttribute('rel', 'noopener noreferrer');
|
|
node.setAttribute('target', '_blank');
|
|
return node;
|
|
}
|
|
|
|
static formats(domNode) {
|
|
return domNode.getAttribute('href');
|
|
}
|
|
|
|
static sanitize(url) {
|
|
return sanitize(url, this.PROTOCOL_WHITELIST) ? url : this.SANITIZED_URL;
|
|
}
|
|
|
|
format(name, value) {
|
|
if (name !== this.statics.blotName || !value) return super.format(name, value);
|
|
value = this.constructor.sanitize(value);
|
|
this.domNode.setAttribute('href', value);
|
|
}
|
|
}
|
|
Link.blotName = 'link';
|
|
Link.tagName = 'A';
|
|
Link.SANITIZED_URL = 'about:blank';
|
|
Link.PROTOCOL_WHITELIST = ['http', 'https', 'mailto', 'tel'];
|
|
|
|
|
|
function sanitize(url, protocols) {
|
|
let anchor = document.createElement('a');
|
|
anchor.href = url;
|
|
let protocol = anchor.href.slice(0, anchor.href.indexOf(':'));
|
|
return protocols.indexOf(protocol) > -1;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/formats/size.js":
|
|
/*!********************************************!*\
|
|
!*** ./node_modules/quill/formats/size.js ***!
|
|
\********************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "SizeClass": () => (/* binding */ SizeClass),
|
|
/* harmony export */ "SizeStyle": () => (/* binding */ SizeStyle)
|
|
/* harmony export */ });
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! parchment */ "./node_modules/parchment/dist/parchment.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(parchment__WEBPACK_IMPORTED_MODULE_0__);
|
|
|
|
|
|
let SizeClass = new (parchment__WEBPACK_IMPORTED_MODULE_0___default().Attributor.Class)('size', 'ql-size', {
|
|
scope: (parchment__WEBPACK_IMPORTED_MODULE_0___default().Scope.INLINE),
|
|
whitelist: ['small', 'large', 'huge']
|
|
});
|
|
let SizeStyle = new (parchment__WEBPACK_IMPORTED_MODULE_0___default().Attributor.Style)('size', 'font-size', {
|
|
scope: (parchment__WEBPACK_IMPORTED_MODULE_0___default().Scope.INLINE),
|
|
whitelist: ['10px', '18px', '32px']
|
|
});
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/modules/clipboard.js":
|
|
/*!*************************************************!*\
|
|
!*** ./node_modules/quill/modules/clipboard.js ***!
|
|
\*************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (/* binding */ Clipboard),
|
|
/* harmony export */ "matchAttributor": () => (/* binding */ matchAttributor),
|
|
/* harmony export */ "matchBlot": () => (/* binding */ matchBlot),
|
|
/* harmony export */ "matchNewline": () => (/* binding */ matchNewline),
|
|
/* harmony export */ "matchSpacing": () => (/* binding */ matchSpacing),
|
|
/* harmony export */ "matchText": () => (/* binding */ matchText)
|
|
/* harmony export */ });
|
|
/* harmony import */ var extend__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! extend */ "./node_modules/extend/index.js");
|
|
/* harmony import */ var extend__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(extend__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var quill_delta__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! quill-delta */ "./node_modules/quill-delta/lib/delta.js");
|
|
/* harmony import */ var quill_delta__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(quill_delta__WEBPACK_IMPORTED_MODULE_1__);
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! parchment */ "./node_modules/parchment/dist/parchment.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(parchment__WEBPACK_IMPORTED_MODULE_2__);
|
|
/* harmony import */ var _core_quill__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../core/quill */ "./node_modules/quill/core/quill.js");
|
|
/* harmony import */ var _core_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../core/logger */ "./node_modules/quill/core/logger.js");
|
|
/* harmony import */ var _core_module__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../core/module */ "./node_modules/quill/core/module.js");
|
|
/* harmony import */ var _formats_align__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../formats/align */ "./node_modules/quill/formats/align.js");
|
|
/* harmony import */ var _formats_background__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../formats/background */ "./node_modules/quill/formats/background.js");
|
|
/* harmony import */ var _formats_code__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../formats/code */ "./node_modules/quill/formats/code.js");
|
|
/* harmony import */ var _formats_color__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../formats/color */ "./node_modules/quill/formats/color.js");
|
|
/* harmony import */ var _formats_direction__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../formats/direction */ "./node_modules/quill/formats/direction.js");
|
|
/* harmony import */ var _formats_font__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../formats/font */ "./node_modules/quill/formats/font.js");
|
|
/* harmony import */ var _formats_size__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../formats/size */ "./node_modules/quill/formats/size.js");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let debug = (0,_core_logger__WEBPACK_IMPORTED_MODULE_4__.default)('quill:clipboard');
|
|
|
|
|
|
const DOM_KEY = '__ql-matcher';
|
|
|
|
const CLIPBOARD_CONFIG = [
|
|
[Node.TEXT_NODE, matchText],
|
|
[Node.TEXT_NODE, matchNewline],
|
|
['br', matchBreak],
|
|
[Node.ELEMENT_NODE, matchNewline],
|
|
[Node.ELEMENT_NODE, matchBlot],
|
|
[Node.ELEMENT_NODE, matchSpacing],
|
|
[Node.ELEMENT_NODE, matchAttributor],
|
|
[Node.ELEMENT_NODE, matchStyles],
|
|
['li', matchIndent],
|
|
['b', matchAlias.bind(matchAlias, 'bold')],
|
|
['i', matchAlias.bind(matchAlias, 'italic')],
|
|
['style', matchIgnore]
|
|
];
|
|
|
|
const ATTRIBUTE_ATTRIBUTORS = [
|
|
_formats_align__WEBPACK_IMPORTED_MODULE_6__.AlignAttribute,
|
|
_formats_direction__WEBPACK_IMPORTED_MODULE_10__.DirectionAttribute
|
|
].reduce(function(memo, attr) {
|
|
memo[attr.keyName] = attr;
|
|
return memo;
|
|
}, {});
|
|
|
|
const STYLE_ATTRIBUTORS = [
|
|
_formats_align__WEBPACK_IMPORTED_MODULE_6__.AlignStyle,
|
|
_formats_background__WEBPACK_IMPORTED_MODULE_7__.BackgroundStyle,
|
|
_formats_color__WEBPACK_IMPORTED_MODULE_9__.ColorStyle,
|
|
_formats_direction__WEBPACK_IMPORTED_MODULE_10__.DirectionStyle,
|
|
_formats_font__WEBPACK_IMPORTED_MODULE_11__.FontStyle,
|
|
_formats_size__WEBPACK_IMPORTED_MODULE_12__.SizeStyle
|
|
].reduce(function(memo, attr) {
|
|
memo[attr.keyName] = attr;
|
|
return memo;
|
|
}, {});
|
|
|
|
|
|
class Clipboard extends _core_module__WEBPACK_IMPORTED_MODULE_5__.default {
|
|
constructor(quill, options) {
|
|
super(quill, options);
|
|
this.quill.root.addEventListener('paste', this.onPaste.bind(this));
|
|
this.container = this.quill.addContainer('ql-clipboard');
|
|
this.container.setAttribute('contenteditable', true);
|
|
this.container.setAttribute('tabindex', -1);
|
|
this.matchers = [];
|
|
CLIPBOARD_CONFIG.concat(this.options.matchers).forEach(([selector, matcher]) => {
|
|
if (!options.matchVisual && matcher === matchSpacing) return;
|
|
this.addMatcher(selector, matcher);
|
|
});
|
|
}
|
|
|
|
addMatcher(selector, matcher) {
|
|
this.matchers.push([selector, matcher]);
|
|
}
|
|
|
|
convert(html) {
|
|
if (typeof html === 'string') {
|
|
this.container.innerHTML = html.replace(/\>\r?\n +\</g, '><'); // Remove spaces between tags
|
|
return this.convert();
|
|
}
|
|
const formats = this.quill.getFormat(this.quill.selection.savedRange.index);
|
|
if (formats[_formats_code__WEBPACK_IMPORTED_MODULE_8__.default.blotName]) {
|
|
const text = this.container.innerText;
|
|
this.container.innerHTML = '';
|
|
return new (quill_delta__WEBPACK_IMPORTED_MODULE_1___default())().insert(text, { [_formats_code__WEBPACK_IMPORTED_MODULE_8__.default.blotName]: formats[_formats_code__WEBPACK_IMPORTED_MODULE_8__.default.blotName] });
|
|
}
|
|
let [elementMatchers, textMatchers] = this.prepareMatching();
|
|
let delta = traverse(this.container, elementMatchers, textMatchers);
|
|
// Remove trailing newline
|
|
if (deltaEndsWith(delta, '\n') && delta.ops[delta.ops.length - 1].attributes == null) {
|
|
delta = delta.compose(new (quill_delta__WEBPACK_IMPORTED_MODULE_1___default())().retain(delta.length() - 1).delete(1));
|
|
}
|
|
debug.log('convert', this.container.innerHTML, delta);
|
|
this.container.innerHTML = '';
|
|
return delta;
|
|
}
|
|
|
|
dangerouslyPasteHTML(index, html, source = _core_quill__WEBPACK_IMPORTED_MODULE_3__.default.sources.API) {
|
|
if (typeof index === 'string') {
|
|
this.quill.setContents(this.convert(index), html);
|
|
this.quill.setSelection(0, _core_quill__WEBPACK_IMPORTED_MODULE_3__.default.sources.SILENT);
|
|
} else {
|
|
let paste = this.convert(html);
|
|
this.quill.updateContents(new (quill_delta__WEBPACK_IMPORTED_MODULE_1___default())().retain(index).concat(paste), source);
|
|
this.quill.setSelection(index + paste.length(), _core_quill__WEBPACK_IMPORTED_MODULE_3__.default.sources.SILENT);
|
|
}
|
|
}
|
|
|
|
onPaste(e) {
|
|
if (e.defaultPrevented || !this.quill.isEnabled()) return;
|
|
let range = this.quill.getSelection();
|
|
let delta = new (quill_delta__WEBPACK_IMPORTED_MODULE_1___default())().retain(range.index);
|
|
let scrollTop = this.quill.scrollingContainer.scrollTop;
|
|
this.container.focus();
|
|
this.quill.selection.update(_core_quill__WEBPACK_IMPORTED_MODULE_3__.default.sources.SILENT);
|
|
setTimeout(() => {
|
|
delta = delta.concat(this.convert()).delete(range.length);
|
|
this.quill.updateContents(delta, _core_quill__WEBPACK_IMPORTED_MODULE_3__.default.sources.USER);
|
|
// range.length contributes to delta.length()
|
|
this.quill.setSelection(delta.length() - range.length, _core_quill__WEBPACK_IMPORTED_MODULE_3__.default.sources.SILENT);
|
|
this.quill.scrollingContainer.scrollTop = scrollTop;
|
|
this.quill.focus();
|
|
}, 1);
|
|
}
|
|
|
|
prepareMatching() {
|
|
let elementMatchers = [], textMatchers = [];
|
|
this.matchers.forEach((pair) => {
|
|
let [selector, matcher] = pair;
|
|
switch (selector) {
|
|
case Node.TEXT_NODE:
|
|
textMatchers.push(matcher);
|
|
break;
|
|
case Node.ELEMENT_NODE:
|
|
elementMatchers.push(matcher);
|
|
break;
|
|
default:
|
|
[].forEach.call(this.container.querySelectorAll(selector), (node) => {
|
|
// TODO use weakmap
|
|
node[DOM_KEY] = node[DOM_KEY] || [];
|
|
node[DOM_KEY].push(matcher);
|
|
});
|
|
break;
|
|
}
|
|
});
|
|
return [elementMatchers, textMatchers];
|
|
}
|
|
}
|
|
Clipboard.DEFAULTS = {
|
|
matchers: [],
|
|
matchVisual: true
|
|
};
|
|
|
|
|
|
function applyFormat(delta, format, value) {
|
|
if (typeof format === 'object') {
|
|
return Object.keys(format).reduce(function(delta, key) {
|
|
return applyFormat(delta, key, format[key]);
|
|
}, delta);
|
|
} else {
|
|
return delta.reduce(function(delta, op) {
|
|
if (op.attributes && op.attributes[format]) {
|
|
return delta.push(op);
|
|
} else {
|
|
return delta.insert(op.insert, extend__WEBPACK_IMPORTED_MODULE_0___default()({}, {[format]: value}, op.attributes));
|
|
}
|
|
}, new (quill_delta__WEBPACK_IMPORTED_MODULE_1___default())());
|
|
}
|
|
}
|
|
|
|
function computeStyle(node) {
|
|
if (node.nodeType !== Node.ELEMENT_NODE) return {};
|
|
const DOM_KEY = '__ql-computed-style';
|
|
return node[DOM_KEY] || (node[DOM_KEY] = window.getComputedStyle(node));
|
|
}
|
|
|
|
function deltaEndsWith(delta, text) {
|
|
let endText = "";
|
|
for (let i = delta.ops.length - 1; i >= 0 && endText.length < text.length; --i) {
|
|
let op = delta.ops[i];
|
|
if (typeof op.insert !== 'string') break;
|
|
endText = op.insert + endText;
|
|
}
|
|
return endText.slice(-1*text.length) === text;
|
|
}
|
|
|
|
function isLine(node) {
|
|
if (node.childNodes.length === 0) return false; // Exclude embed blocks
|
|
let style = computeStyle(node);
|
|
return ['block', 'list-item'].indexOf(style.display) > -1;
|
|
}
|
|
|
|
function traverse(node, elementMatchers, textMatchers) { // Post-order
|
|
if (node.nodeType === node.TEXT_NODE) {
|
|
return textMatchers.reduce(function(delta, matcher) {
|
|
return matcher(node, delta);
|
|
}, new (quill_delta__WEBPACK_IMPORTED_MODULE_1___default())());
|
|
} else if (node.nodeType === node.ELEMENT_NODE) {
|
|
return [].reduce.call(node.childNodes || [], (delta, childNode) => {
|
|
let childrenDelta = traverse(childNode, elementMatchers, textMatchers);
|
|
if (childNode.nodeType === node.ELEMENT_NODE) {
|
|
childrenDelta = elementMatchers.reduce(function(childrenDelta, matcher) {
|
|
return matcher(childNode, childrenDelta);
|
|
}, childrenDelta);
|
|
childrenDelta = (childNode[DOM_KEY] || []).reduce(function(childrenDelta, matcher) {
|
|
return matcher(childNode, childrenDelta);
|
|
}, childrenDelta);
|
|
}
|
|
return delta.concat(childrenDelta);
|
|
}, new (quill_delta__WEBPACK_IMPORTED_MODULE_1___default())());
|
|
} else {
|
|
return new (quill_delta__WEBPACK_IMPORTED_MODULE_1___default())();
|
|
}
|
|
}
|
|
|
|
|
|
function matchAlias(format, node, delta) {
|
|
return applyFormat(delta, format, true);
|
|
}
|
|
|
|
function matchAttributor(node, delta) {
|
|
let attributes = parchment__WEBPACK_IMPORTED_MODULE_2___default().Attributor.Attribute.keys(node);
|
|
let classes = parchment__WEBPACK_IMPORTED_MODULE_2___default().Attributor.Class.keys(node);
|
|
let styles = parchment__WEBPACK_IMPORTED_MODULE_2___default().Attributor.Style.keys(node);
|
|
let formats = {};
|
|
attributes.concat(classes).concat(styles).forEach((name) => {
|
|
let attr = parchment__WEBPACK_IMPORTED_MODULE_2___default().query(name, (parchment__WEBPACK_IMPORTED_MODULE_2___default().Scope.ATTRIBUTE));
|
|
if (attr != null) {
|
|
formats[attr.attrName] = attr.value(node);
|
|
if (formats[attr.attrName]) return;
|
|
}
|
|
attr = ATTRIBUTE_ATTRIBUTORS[name];
|
|
if (attr != null && (attr.attrName === name || attr.keyName === name)) {
|
|
formats[attr.attrName] = attr.value(node) || undefined;
|
|
}
|
|
attr = STYLE_ATTRIBUTORS[name]
|
|
if (attr != null && (attr.attrName === name || attr.keyName === name)) {
|
|
attr = STYLE_ATTRIBUTORS[name];
|
|
formats[attr.attrName] = attr.value(node) || undefined;
|
|
}
|
|
});
|
|
if (Object.keys(formats).length > 0) {
|
|
delta = applyFormat(delta, formats);
|
|
}
|
|
return delta;
|
|
}
|
|
|
|
function matchBlot(node, delta) {
|
|
let match = parchment__WEBPACK_IMPORTED_MODULE_2___default().query(node);
|
|
if (match == null) return delta;
|
|
if (match.prototype instanceof (parchment__WEBPACK_IMPORTED_MODULE_2___default().Embed)) {
|
|
let embed = {};
|
|
let value = match.value(node);
|
|
if (value != null) {
|
|
embed[match.blotName] = value;
|
|
delta = new (quill_delta__WEBPACK_IMPORTED_MODULE_1___default())().insert(embed, match.formats(node));
|
|
}
|
|
} else if (typeof match.formats === 'function') {
|
|
delta = applyFormat(delta, match.blotName, match.formats(node));
|
|
}
|
|
return delta;
|
|
}
|
|
|
|
function matchBreak(node, delta) {
|
|
if (!deltaEndsWith(delta, '\n')) {
|
|
delta.insert('\n');
|
|
}
|
|
return delta;
|
|
}
|
|
|
|
function matchIgnore() {
|
|
return new (quill_delta__WEBPACK_IMPORTED_MODULE_1___default())();
|
|
}
|
|
|
|
function matchIndent(node, delta) {
|
|
let match = parchment__WEBPACK_IMPORTED_MODULE_2___default().query(node);
|
|
if (match == null || match.blotName !== 'list-item' || !deltaEndsWith(delta, '\n')) {
|
|
return delta;
|
|
}
|
|
let indent = -1, parent = node.parentNode;
|
|
while (!parent.classList.contains('ql-clipboard')) {
|
|
if ((parchment__WEBPACK_IMPORTED_MODULE_2___default().query(parent) || {}).blotName === 'list') {
|
|
indent += 1;
|
|
}
|
|
parent = parent.parentNode;
|
|
}
|
|
if (indent <= 0) return delta;
|
|
return delta.compose(new (quill_delta__WEBPACK_IMPORTED_MODULE_1___default())().retain(delta.length() - 1).retain(1, { indent: indent}));
|
|
}
|
|
|
|
function matchNewline(node, delta) {
|
|
if (!deltaEndsWith(delta, '\n')) {
|
|
if (isLine(node) || (delta.length() > 0 && node.nextSibling && isLine(node.nextSibling))) {
|
|
delta.insert('\n');
|
|
}
|
|
}
|
|
return delta;
|
|
}
|
|
|
|
function matchSpacing(node, delta) {
|
|
if (isLine(node) && node.nextElementSibling != null && !deltaEndsWith(delta, '\n\n')) {
|
|
let nodeHeight = node.offsetHeight + parseFloat(computeStyle(node).marginTop) + parseFloat(computeStyle(node).marginBottom);
|
|
if (node.nextElementSibling.offsetTop > node.offsetTop + nodeHeight*1.5) {
|
|
delta.insert('\n');
|
|
}
|
|
}
|
|
return delta;
|
|
}
|
|
|
|
function matchStyles(node, delta) {
|
|
let formats = {};
|
|
let style = node.style || {};
|
|
if (style.fontStyle && computeStyle(node).fontStyle === 'italic') {
|
|
formats.italic = true;
|
|
}
|
|
if (style.fontWeight && (computeStyle(node).fontWeight.startsWith('bold') ||
|
|
parseInt(computeStyle(node).fontWeight) >= 700)) {
|
|
formats.bold = true;
|
|
}
|
|
if (Object.keys(formats).length > 0) {
|
|
delta = applyFormat(delta, formats);
|
|
}
|
|
if (parseFloat(style.textIndent || 0) > 0) { // Could be 0.5in
|
|
delta = new (quill_delta__WEBPACK_IMPORTED_MODULE_1___default())().insert('\t').concat(delta);
|
|
}
|
|
return delta;
|
|
}
|
|
|
|
function matchText(node, delta) {
|
|
let text = node.data;
|
|
// Word represents empty line with <o:p> </o:p>
|
|
if (node.parentNode.tagName === 'O:P') {
|
|
return delta.insert(text.trim());
|
|
}
|
|
if (text.trim().length === 0 && node.parentNode.classList.contains('ql-clipboard')) {
|
|
return delta;
|
|
}
|
|
if (!computeStyle(node.parentNode).whiteSpace.startsWith('pre')) {
|
|
// eslint-disable-next-line func-style
|
|
let replacer = function(collapse, match) {
|
|
match = match.replace(/[^\u00a0]/g, ''); // \u00a0 is nbsp;
|
|
return match.length < 1 && collapse ? ' ' : match;
|
|
};
|
|
text = text.replace(/\r\n/g, ' ').replace(/\n/g, ' ');
|
|
text = text.replace(/\s\s+/g, replacer.bind(replacer, true)); // collapse whitespace
|
|
if ((node.previousSibling == null && isLine(node.parentNode)) ||
|
|
(node.previousSibling != null && isLine(node.previousSibling))) {
|
|
text = text.replace(/^\s+/, replacer.bind(replacer, false));
|
|
}
|
|
if ((node.nextSibling == null && isLine(node.parentNode)) ||
|
|
(node.nextSibling != null && isLine(node.nextSibling))) {
|
|
text = text.replace(/\s+$/, replacer.bind(replacer, false));
|
|
}
|
|
}
|
|
return delta.insert(text);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/modules/history.js":
|
|
/*!***********************************************!*\
|
|
!*** ./node_modules/quill/modules/history.js ***!
|
|
\***********************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (/* binding */ History),
|
|
/* harmony export */ "getLastChangeIndex": () => (/* binding */ getLastChangeIndex)
|
|
/* harmony export */ });
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! parchment */ "./node_modules/parchment/dist/parchment.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(parchment__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var _core_quill__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../core/quill */ "./node_modules/quill/core/quill.js");
|
|
/* harmony import */ var _core_module__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../core/module */ "./node_modules/quill/core/module.js");
|
|
|
|
|
|
|
|
|
|
|
|
class History extends _core_module__WEBPACK_IMPORTED_MODULE_2__.default {
|
|
constructor(quill, options) {
|
|
super(quill, options);
|
|
this.lastRecorded = 0;
|
|
this.ignoreChange = false;
|
|
this.clear();
|
|
this.quill.on(_core_quill__WEBPACK_IMPORTED_MODULE_1__.default.events.EDITOR_CHANGE, (eventName, delta, oldDelta, source) => {
|
|
if (eventName !== _core_quill__WEBPACK_IMPORTED_MODULE_1__.default.events.TEXT_CHANGE || this.ignoreChange) return;
|
|
if (!this.options.userOnly || source === _core_quill__WEBPACK_IMPORTED_MODULE_1__.default.sources.USER) {
|
|
this.record(delta, oldDelta);
|
|
} else {
|
|
this.transform(delta);
|
|
}
|
|
});
|
|
this.quill.keyboard.addBinding({ key: 'Z', shortKey: true }, this.undo.bind(this));
|
|
this.quill.keyboard.addBinding({ key: 'Z', shortKey: true, shiftKey: true }, this.redo.bind(this));
|
|
if (/Win/i.test(navigator.platform)) {
|
|
this.quill.keyboard.addBinding({ key: 'Y', shortKey: true }, this.redo.bind(this));
|
|
}
|
|
}
|
|
|
|
change(source, dest) {
|
|
if (this.stack[source].length === 0) return;
|
|
let delta = this.stack[source].pop();
|
|
this.stack[dest].push(delta);
|
|
this.lastRecorded = 0;
|
|
this.ignoreChange = true;
|
|
this.quill.updateContents(delta[source], _core_quill__WEBPACK_IMPORTED_MODULE_1__.default.sources.USER);
|
|
this.ignoreChange = false;
|
|
let index = getLastChangeIndex(delta[source]);
|
|
this.quill.setSelection(index);
|
|
}
|
|
|
|
clear() {
|
|
this.stack = { undo: [], redo: [] };
|
|
}
|
|
|
|
cutoff() {
|
|
this.lastRecorded = 0;
|
|
}
|
|
|
|
record(changeDelta, oldDelta) {
|
|
if (changeDelta.ops.length === 0) return;
|
|
this.stack.redo = [];
|
|
let undoDelta = this.quill.getContents().diff(oldDelta);
|
|
let timestamp = Date.now();
|
|
if (this.lastRecorded + this.options.delay > timestamp && this.stack.undo.length > 0) {
|
|
let delta = this.stack.undo.pop();
|
|
undoDelta = undoDelta.compose(delta.undo);
|
|
changeDelta = delta.redo.compose(changeDelta);
|
|
} else {
|
|
this.lastRecorded = timestamp;
|
|
}
|
|
this.stack.undo.push({
|
|
redo: changeDelta,
|
|
undo: undoDelta
|
|
});
|
|
if (this.stack.undo.length > this.options.maxStack) {
|
|
this.stack.undo.shift();
|
|
}
|
|
}
|
|
|
|
redo() {
|
|
this.change('redo', 'undo');
|
|
}
|
|
|
|
transform(delta) {
|
|
this.stack.undo.forEach(function(change) {
|
|
change.undo = delta.transform(change.undo, true);
|
|
change.redo = delta.transform(change.redo, true);
|
|
});
|
|
this.stack.redo.forEach(function(change) {
|
|
change.undo = delta.transform(change.undo, true);
|
|
change.redo = delta.transform(change.redo, true);
|
|
});
|
|
}
|
|
|
|
undo() {
|
|
this.change('undo', 'redo');
|
|
}
|
|
}
|
|
History.DEFAULTS = {
|
|
delay: 1000,
|
|
maxStack: 100,
|
|
userOnly: false
|
|
};
|
|
|
|
function endsWithNewlineChange(delta) {
|
|
let lastOp = delta.ops[delta.ops.length - 1];
|
|
if (lastOp == null) return false;
|
|
if (lastOp.insert != null) {
|
|
return typeof lastOp.insert === 'string' && lastOp.insert.endsWith('\n');
|
|
}
|
|
if (lastOp.attributes != null) {
|
|
return Object.keys(lastOp.attributes).some(function(attr) {
|
|
return parchment__WEBPACK_IMPORTED_MODULE_0___default().query(attr, (parchment__WEBPACK_IMPORTED_MODULE_0___default().Scope.BLOCK)) != null;
|
|
});
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function getLastChangeIndex(delta) {
|
|
let deleteLength = delta.reduce(function(length, op) {
|
|
length += (op.delete || 0);
|
|
return length;
|
|
}, 0);
|
|
let changeIndex = delta.length() - deleteLength;
|
|
if (endsWithNewlineChange(delta)) {
|
|
changeIndex -= 1;
|
|
}
|
|
return changeIndex;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/modules/keyboard.js":
|
|
/*!************************************************!*\
|
|
!*** ./node_modules/quill/modules/keyboard.js ***!
|
|
\************************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (/* binding */ Keyboard),
|
|
/* harmony export */ "SHORTKEY": () => (/* binding */ SHORTKEY)
|
|
/* harmony export */ });
|
|
/* harmony import */ var clone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! clone */ "./node_modules/clone/clone.js");
|
|
/* harmony import */ var clone__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(clone__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var deep_equal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! deep-equal */ "./node_modules/deep-equal/index.js");
|
|
/* harmony import */ var deep_equal__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(deep_equal__WEBPACK_IMPORTED_MODULE_1__);
|
|
/* harmony import */ var extend__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! extend */ "./node_modules/extend/index.js");
|
|
/* harmony import */ var extend__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(extend__WEBPACK_IMPORTED_MODULE_2__);
|
|
/* harmony import */ var quill_delta__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! quill-delta */ "./node_modules/quill-delta/lib/delta.js");
|
|
/* harmony import */ var quill_delta__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(quill_delta__WEBPACK_IMPORTED_MODULE_3__);
|
|
/* harmony import */ var quill_delta_lib_op__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! quill-delta/lib/op */ "./node_modules/quill-delta/lib/op.js");
|
|
/* harmony import */ var quill_delta_lib_op__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(quill_delta_lib_op__WEBPACK_IMPORTED_MODULE_4__);
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! parchment */ "./node_modules/parchment/dist/parchment.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(parchment__WEBPACK_IMPORTED_MODULE_5__);
|
|
/* harmony import */ var _core_quill__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../core/quill */ "./node_modules/quill/core/quill.js");
|
|
/* harmony import */ var _core_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../core/logger */ "./node_modules/quill/core/logger.js");
|
|
/* harmony import */ var _core_module__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../core/module */ "./node_modules/quill/core/module.js");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let debug = (0,_core_logger__WEBPACK_IMPORTED_MODULE_7__.default)('quill:keyboard');
|
|
|
|
const SHORTKEY = /Mac/i.test(navigator.platform) ? 'metaKey' : 'ctrlKey';
|
|
|
|
|
|
class Keyboard extends _core_module__WEBPACK_IMPORTED_MODULE_8__.default {
|
|
static match(evt, binding) {
|
|
binding = normalize(binding);
|
|
if (['altKey', 'ctrlKey', 'metaKey', 'shiftKey'].some(function(key) {
|
|
return (!!binding[key] !== evt[key] && binding[key] !== null);
|
|
})) {
|
|
return false;
|
|
}
|
|
return binding.key === (evt.which || evt.keyCode);
|
|
}
|
|
|
|
constructor(quill, options) {
|
|
super(quill, options);
|
|
this.bindings = {};
|
|
Object.keys(this.options.bindings).forEach((name) => {
|
|
if (name === 'list autofill' &&
|
|
quill.scroll.whitelist != null &&
|
|
!quill.scroll.whitelist['list']) {
|
|
return;
|
|
}
|
|
if (this.options.bindings[name]) {
|
|
this.addBinding(this.options.bindings[name]);
|
|
}
|
|
});
|
|
this.addBinding({ key: Keyboard.keys.ENTER, shiftKey: null }, handleEnter);
|
|
this.addBinding({ key: Keyboard.keys.ENTER, metaKey: null, ctrlKey: null, altKey: null }, function() {});
|
|
if (/Firefox/i.test(navigator.userAgent)) {
|
|
// Need to handle delete and backspace for Firefox in the general case #1171
|
|
this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: true }, handleBackspace);
|
|
this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: true }, handleDelete);
|
|
} else {
|
|
this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: true, prefix: /^.?$/ }, handleBackspace);
|
|
this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: true, suffix: /^.?$/ }, handleDelete);
|
|
}
|
|
this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: false }, handleDeleteRange);
|
|
this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: false }, handleDeleteRange);
|
|
this.addBinding({ key: Keyboard.keys.BACKSPACE, altKey: null, ctrlKey: null, metaKey: null, shiftKey: null },
|
|
{ collapsed: true, offset: 0 },
|
|
handleBackspace);
|
|
this.listen();
|
|
}
|
|
|
|
addBinding(key, context = {}, handler = {}) {
|
|
let binding = normalize(key);
|
|
if (binding == null || binding.key == null) {
|
|
return debug.warn('Attempted to add invalid keyboard binding', binding);
|
|
}
|
|
if (typeof context === 'function') {
|
|
context = { handler: context };
|
|
}
|
|
if (typeof handler === 'function') {
|
|
handler = { handler: handler };
|
|
}
|
|
binding = extend__WEBPACK_IMPORTED_MODULE_2___default()(binding, context, handler);
|
|
this.bindings[binding.key] = this.bindings[binding.key] || [];
|
|
this.bindings[binding.key].push(binding);
|
|
}
|
|
|
|
listen() {
|
|
this.quill.root.addEventListener('keydown', (evt) => {
|
|
if (evt.defaultPrevented) return;
|
|
let which = evt.which || evt.keyCode;
|
|
let bindings = (this.bindings[which] || []).filter(function(binding) {
|
|
return Keyboard.match(evt, binding);
|
|
});
|
|
if (bindings.length === 0) return;
|
|
let range = this.quill.getSelection();
|
|
if (range == null || !this.quill.hasFocus()) return;
|
|
let [line, offset] = this.quill.getLine(range.index);
|
|
let [leafStart, offsetStart] = this.quill.getLeaf(range.index);
|
|
let [leafEnd, offsetEnd] = range.length === 0 ? [leafStart, offsetStart] : this.quill.getLeaf(range.index + range.length);
|
|
let prefixText = leafStart instanceof (parchment__WEBPACK_IMPORTED_MODULE_5___default().Text) ? leafStart.value().slice(0, offsetStart) : '';
|
|
let suffixText = leafEnd instanceof (parchment__WEBPACK_IMPORTED_MODULE_5___default().Text) ? leafEnd.value().slice(offsetEnd) : '';
|
|
let curContext = {
|
|
collapsed: range.length === 0,
|
|
empty: range.length === 0 && line.length() <= 1,
|
|
format: this.quill.getFormat(range),
|
|
offset: offset,
|
|
prefix: prefixText,
|
|
suffix: suffixText
|
|
};
|
|
let prevented = bindings.some((binding) => {
|
|
if (binding.collapsed != null && binding.collapsed !== curContext.collapsed) return false;
|
|
if (binding.empty != null && binding.empty !== curContext.empty) return false;
|
|
if (binding.offset != null && binding.offset !== curContext.offset) return false;
|
|
if (Array.isArray(binding.format)) {
|
|
// any format is present
|
|
if (binding.format.every(function(name) {
|
|
return curContext.format[name] == null;
|
|
})) {
|
|
return false;
|
|
}
|
|
} else if (typeof binding.format === 'object') {
|
|
// all formats must match
|
|
if (!Object.keys(binding.format).every(function(name) {
|
|
if (binding.format[name] === true) return curContext.format[name] != null;
|
|
if (binding.format[name] === false) return curContext.format[name] == null;
|
|
return deep_equal__WEBPACK_IMPORTED_MODULE_1___default()(binding.format[name], curContext.format[name]);
|
|
})) {
|
|
return false;
|
|
}
|
|
}
|
|
if (binding.prefix != null && !binding.prefix.test(curContext.prefix)) return false;
|
|
if (binding.suffix != null && !binding.suffix.test(curContext.suffix)) return false;
|
|
return binding.handler.call(this, range, curContext) !== true;
|
|
});
|
|
if (prevented) {
|
|
evt.preventDefault();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
Keyboard.keys = {
|
|
BACKSPACE: 8,
|
|
TAB: 9,
|
|
ENTER: 13,
|
|
ESCAPE: 27,
|
|
LEFT: 37,
|
|
UP: 38,
|
|
RIGHT: 39,
|
|
DOWN: 40,
|
|
DELETE: 46
|
|
};
|
|
|
|
Keyboard.DEFAULTS = {
|
|
bindings: {
|
|
'bold' : makeFormatHandler('bold'),
|
|
'italic' : makeFormatHandler('italic'),
|
|
'underline' : makeFormatHandler('underline'),
|
|
'indent': {
|
|
// highlight tab or tab at beginning of list, indent or blockquote
|
|
key: Keyboard.keys.TAB,
|
|
format: ['blockquote', 'indent', 'list'],
|
|
handler: function(range, context) {
|
|
if (context.collapsed && context.offset !== 0) return true;
|
|
this.quill.format('indent', '+1', _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
}
|
|
},
|
|
'outdent': {
|
|
key: Keyboard.keys.TAB,
|
|
shiftKey: true,
|
|
format: ['blockquote', 'indent', 'list'],
|
|
// highlight tab or tab at beginning of list, indent or blockquote
|
|
handler: function(range, context) {
|
|
if (context.collapsed && context.offset !== 0) return true;
|
|
this.quill.format('indent', '-1', _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
}
|
|
},
|
|
'outdent backspace': {
|
|
key: Keyboard.keys.BACKSPACE,
|
|
collapsed: true,
|
|
shiftKey: null,
|
|
metaKey: null,
|
|
ctrlKey: null,
|
|
altKey: null,
|
|
format: ['indent', 'list'],
|
|
offset: 0,
|
|
handler: function(range, context) {
|
|
if (context.format.indent != null) {
|
|
this.quill.format('indent', '-1', _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
} else if (context.format.list != null) {
|
|
this.quill.format('list', false, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
}
|
|
}
|
|
},
|
|
'indent code-block': makeCodeBlockHandler(true),
|
|
'outdent code-block': makeCodeBlockHandler(false),
|
|
'remove tab': {
|
|
key: Keyboard.keys.TAB,
|
|
shiftKey: true,
|
|
collapsed: true,
|
|
prefix: /\t$/,
|
|
handler: function(range) {
|
|
this.quill.deleteText(range.index - 1, 1, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
}
|
|
},
|
|
'tab': {
|
|
key: Keyboard.keys.TAB,
|
|
handler: function(range) {
|
|
this.quill.history.cutoff();
|
|
let delta = new (quill_delta__WEBPACK_IMPORTED_MODULE_3___default())().retain(range.index)
|
|
.delete(range.length)
|
|
.insert('\t');
|
|
this.quill.updateContents(delta, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
this.quill.history.cutoff();
|
|
this.quill.setSelection(range.index + 1, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.SILENT);
|
|
}
|
|
},
|
|
'list empty enter': {
|
|
key: Keyboard.keys.ENTER,
|
|
collapsed: true,
|
|
format: ['list'],
|
|
empty: true,
|
|
handler: function(range, context) {
|
|
this.quill.format('list', false, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
if (context.format.indent) {
|
|
this.quill.format('indent', false, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
}
|
|
}
|
|
},
|
|
'checklist enter': {
|
|
key: Keyboard.keys.ENTER,
|
|
collapsed: true,
|
|
format: { list: 'checked' },
|
|
handler: function(range) {
|
|
let [line, offset] = this.quill.getLine(range.index);
|
|
let formats = extend__WEBPACK_IMPORTED_MODULE_2___default()({}, line.formats(), { list: 'checked' });
|
|
let delta = new (quill_delta__WEBPACK_IMPORTED_MODULE_3___default())().retain(range.index)
|
|
.insert('\n', formats)
|
|
.retain(line.length() - offset - 1)
|
|
.retain(1, { list: 'unchecked' });
|
|
this.quill.updateContents(delta, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
this.quill.setSelection(range.index + 1, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.SILENT);
|
|
this.quill.scrollIntoView();
|
|
}
|
|
},
|
|
'header enter': {
|
|
key: Keyboard.keys.ENTER,
|
|
collapsed: true,
|
|
format: ['header'],
|
|
suffix: /^$/,
|
|
handler: function(range, context) {
|
|
let [line, offset] = this.quill.getLine(range.index);
|
|
let delta = new (quill_delta__WEBPACK_IMPORTED_MODULE_3___default())().retain(range.index)
|
|
.insert('\n', context.format)
|
|
.retain(line.length() - offset - 1)
|
|
.retain(1, { header: null });
|
|
this.quill.updateContents(delta, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
this.quill.setSelection(range.index + 1, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.SILENT);
|
|
this.quill.scrollIntoView();
|
|
}
|
|
},
|
|
'list autofill': {
|
|
key: ' ',
|
|
collapsed: true,
|
|
format: { list: false },
|
|
prefix: /^\s*?(\d+\.|-|\*|\[ ?\]|\[x\])$/,
|
|
handler: function(range, context) {
|
|
let length = context.prefix.length;
|
|
let [line, offset] = this.quill.getLine(range.index);
|
|
if (offset > length) return true;
|
|
let value;
|
|
switch (context.prefix.trim()) {
|
|
case '[]': case '[ ]':
|
|
value = 'unchecked';
|
|
break;
|
|
case '[x]':
|
|
value = 'checked';
|
|
break;
|
|
case '-': case '*':
|
|
value = 'bullet';
|
|
break;
|
|
default:
|
|
value = 'ordered';
|
|
}
|
|
this.quill.insertText(range.index, ' ', _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
this.quill.history.cutoff();
|
|
let delta = new (quill_delta__WEBPACK_IMPORTED_MODULE_3___default())().retain(range.index - offset)
|
|
.delete(length + 1)
|
|
.retain(line.length() - 2 - offset)
|
|
.retain(1, { list: value });
|
|
this.quill.updateContents(delta, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
this.quill.history.cutoff();
|
|
this.quill.setSelection(range.index - length, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.SILENT);
|
|
}
|
|
},
|
|
'code exit': {
|
|
key: Keyboard.keys.ENTER,
|
|
collapsed: true,
|
|
format: ['code-block'],
|
|
prefix: /\n\n$/,
|
|
suffix: /^\s+$/,
|
|
handler: function(range) {
|
|
const [line, offset] = this.quill.getLine(range.index);
|
|
const delta = new (quill_delta__WEBPACK_IMPORTED_MODULE_3___default())()
|
|
.retain(range.index + line.length() - offset - 2)
|
|
.retain(1, { 'code-block': null })
|
|
.delete(1);
|
|
this.quill.updateContents(delta, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
}
|
|
},
|
|
'embed left': makeEmbedArrowHandler(Keyboard.keys.LEFT, false),
|
|
'embed left shift': makeEmbedArrowHandler(Keyboard.keys.LEFT, true),
|
|
'embed right': makeEmbedArrowHandler(Keyboard.keys.RIGHT, false),
|
|
'embed right shift': makeEmbedArrowHandler(Keyboard.keys.RIGHT, true)
|
|
}
|
|
};
|
|
|
|
function makeEmbedArrowHandler(key, shiftKey) {
|
|
const where = key === Keyboard.keys.LEFT ? 'prefix' : 'suffix';
|
|
return {
|
|
key,
|
|
shiftKey,
|
|
altKey: null,
|
|
[where]: /^$/,
|
|
handler: function(range) {
|
|
let index = range.index;
|
|
if (key === Keyboard.keys.RIGHT) {
|
|
index += (range.length + 1);
|
|
}
|
|
const [leaf, ] = this.quill.getLeaf(index);
|
|
if (!(leaf instanceof (parchment__WEBPACK_IMPORTED_MODULE_5___default().Embed))) return true;
|
|
if (key === Keyboard.keys.LEFT) {
|
|
if (shiftKey) {
|
|
this.quill.setSelection(range.index - 1, range.length + 1, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
} else {
|
|
this.quill.setSelection(range.index - 1, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
}
|
|
} else {
|
|
if (shiftKey) {
|
|
this.quill.setSelection(range.index, range.length + 1, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
} else {
|
|
this.quill.setSelection(range.index + range.length + 1, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
};
|
|
}
|
|
|
|
|
|
function handleBackspace(range, context) {
|
|
if (range.index === 0 || this.quill.getLength() <= 1) return;
|
|
let [line, ] = this.quill.getLine(range.index);
|
|
let formats = {};
|
|
if (context.offset === 0) {
|
|
let [prev, ] = this.quill.getLine(range.index - 1);
|
|
if (prev != null && prev.length() > 1) {
|
|
let curFormats = line.formats();
|
|
let prevFormats = this.quill.getFormat(range.index-1, 1);
|
|
formats = quill_delta_lib_op__WEBPACK_IMPORTED_MODULE_4___default().attributes.diff(curFormats, prevFormats) || {};
|
|
}
|
|
}
|
|
// Check for astral symbols
|
|
let length = /[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(context.prefix) ? 2 : 1;
|
|
this.quill.deleteText(range.index-length, length, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
if (Object.keys(formats).length > 0) {
|
|
this.quill.formatLine(range.index-length, length, formats, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
}
|
|
this.quill.focus();
|
|
}
|
|
|
|
function handleDelete(range, context) {
|
|
// Check for astral symbols
|
|
let length = /^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(context.suffix) ? 2 : 1;
|
|
if (range.index >= this.quill.getLength() - length) return;
|
|
let formats = {}, nextLength = 0;
|
|
let [line, ] = this.quill.getLine(range.index);
|
|
if (context.offset >= line.length() - 1) {
|
|
let [next, ] = this.quill.getLine(range.index + 1);
|
|
if (next) {
|
|
let curFormats = line.formats();
|
|
let nextFormats = this.quill.getFormat(range.index, 1);
|
|
formats = quill_delta_lib_op__WEBPACK_IMPORTED_MODULE_4___default().attributes.diff(curFormats, nextFormats) || {};
|
|
nextLength = next.length();
|
|
}
|
|
}
|
|
this.quill.deleteText(range.index, length, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
if (Object.keys(formats).length > 0) {
|
|
this.quill.formatLine(range.index + nextLength - 1, length, formats, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
}
|
|
}
|
|
|
|
function handleDeleteRange(range) {
|
|
let lines = this.quill.getLines(range);
|
|
let formats = {};
|
|
if (lines.length > 1) {
|
|
let firstFormats = lines[0].formats();
|
|
let lastFormats = lines[lines.length - 1].formats();
|
|
formats = quill_delta_lib_op__WEBPACK_IMPORTED_MODULE_4___default().attributes.diff(lastFormats, firstFormats) || {};
|
|
}
|
|
this.quill.deleteText(range, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
if (Object.keys(formats).length > 0) {
|
|
this.quill.formatLine(range.index, 1, formats, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
}
|
|
this.quill.setSelection(range.index, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.SILENT);
|
|
this.quill.focus();
|
|
}
|
|
|
|
function handleEnter(range, context) {
|
|
if (range.length > 0) {
|
|
this.quill.scroll.deleteAt(range.index, range.length); // So we do not trigger text-change
|
|
}
|
|
let lineFormats = Object.keys(context.format).reduce(function(lineFormats, format) {
|
|
if (parchment__WEBPACK_IMPORTED_MODULE_5___default().query(format, (parchment__WEBPACK_IMPORTED_MODULE_5___default().Scope.BLOCK)) && !Array.isArray(context.format[format])) {
|
|
lineFormats[format] = context.format[format];
|
|
}
|
|
return lineFormats;
|
|
}, {});
|
|
this.quill.insertText(range.index, '\n', lineFormats, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
// Earlier scroll.deleteAt might have messed up our selection,
|
|
// so insertText's built in selection preservation is not reliable
|
|
this.quill.setSelection(range.index + 1, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.SILENT);
|
|
this.quill.focus();
|
|
Object.keys(context.format).forEach((name) => {
|
|
if (lineFormats[name] != null) return;
|
|
if (Array.isArray(context.format[name])) return;
|
|
if (name === 'link') return;
|
|
this.quill.format(name, context.format[name], _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
});
|
|
}
|
|
|
|
function makeCodeBlockHandler(indent) {
|
|
return {
|
|
key: Keyboard.keys.TAB,
|
|
shiftKey: !indent,
|
|
format: {'code-block': true },
|
|
handler: function(range) {
|
|
let CodeBlock = parchment__WEBPACK_IMPORTED_MODULE_5___default().query('code-block');
|
|
let index = range.index, length = range.length;
|
|
let [block, offset] = this.quill.scroll.descendant(CodeBlock, index);
|
|
if (block == null) return;
|
|
let scrollIndex = this.quill.getIndex(block);
|
|
let start = block.newlineIndex(offset, true) + 1;
|
|
let end = block.newlineIndex(scrollIndex + offset + length);
|
|
let lines = block.domNode.textContent.slice(start, end).split('\n');
|
|
offset = 0;
|
|
lines.forEach((line, i) => {
|
|
if (indent) {
|
|
block.insertAt(start + offset, CodeBlock.TAB);
|
|
offset += CodeBlock.TAB.length;
|
|
if (i === 0) {
|
|
index += CodeBlock.TAB.length;
|
|
} else {
|
|
length += CodeBlock.TAB.length;
|
|
}
|
|
} else if (line.startsWith(CodeBlock.TAB)) {
|
|
block.deleteAt(start + offset, CodeBlock.TAB.length);
|
|
offset -= CodeBlock.TAB.length;
|
|
if (i === 0) {
|
|
index -= CodeBlock.TAB.length;
|
|
} else {
|
|
length -= CodeBlock.TAB.length;
|
|
}
|
|
}
|
|
offset += line.length + 1;
|
|
});
|
|
this.quill.update(_core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
this.quill.setSelection(index, length, _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.SILENT);
|
|
}
|
|
};
|
|
}
|
|
|
|
function makeFormatHandler(format) {
|
|
return {
|
|
key: format[0].toUpperCase(),
|
|
shortKey: true,
|
|
handler: function(range, context) {
|
|
this.quill.format(format, !context.format[format], _core_quill__WEBPACK_IMPORTED_MODULE_6__.default.sources.USER);
|
|
}
|
|
};
|
|
}
|
|
|
|
function normalize(binding) {
|
|
if (typeof binding === 'string' || typeof binding === 'number') {
|
|
return normalize({ key: binding });
|
|
}
|
|
if (typeof binding === 'object') {
|
|
binding = clone__WEBPACK_IMPORTED_MODULE_0___default()(binding, false);
|
|
}
|
|
if (typeof binding.key === 'string') {
|
|
if (Keyboard.keys[binding.key.toUpperCase()] != null) {
|
|
binding.key = Keyboard.keys[binding.key.toUpperCase()];
|
|
} else if (binding.key.length === 1) {
|
|
binding.key = binding.key.toUpperCase().charCodeAt(0);
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
if (binding.shortKey) {
|
|
binding[SHORTKEY] = binding.shortKey;
|
|
delete binding.shortKey;
|
|
}
|
|
return binding;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/modules/toolbar.js":
|
|
/*!***********************************************!*\
|
|
!*** ./node_modules/quill/modules/toolbar.js ***!
|
|
\***********************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (/* binding */ Toolbar),
|
|
/* harmony export */ "addControls": () => (/* binding */ addControls)
|
|
/* harmony export */ });
|
|
/* harmony import */ var quill_delta__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! quill-delta */ "./node_modules/quill-delta/lib/delta.js");
|
|
/* harmony import */ var quill_delta__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(quill_delta__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! parchment */ "./node_modules/parchment/dist/parchment.js");
|
|
/* harmony import */ var parchment__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(parchment__WEBPACK_IMPORTED_MODULE_1__);
|
|
/* harmony import */ var _core_quill__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../core/quill */ "./node_modules/quill/core/quill.js");
|
|
/* harmony import */ var _core_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../core/logger */ "./node_modules/quill/core/logger.js");
|
|
/* harmony import */ var _core_module__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../core/module */ "./node_modules/quill/core/module.js");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let debug = (0,_core_logger__WEBPACK_IMPORTED_MODULE_3__.default)('quill:toolbar');
|
|
|
|
|
|
class Toolbar extends _core_module__WEBPACK_IMPORTED_MODULE_4__.default {
|
|
constructor(quill, options) {
|
|
super(quill, options);
|
|
if (Array.isArray(this.options.container)) {
|
|
let container = document.createElement('div');
|
|
addControls(container, this.options.container);
|
|
quill.container.parentNode.insertBefore(container, quill.container);
|
|
this.container = container;
|
|
} else if (typeof this.options.container === 'string') {
|
|
this.container = document.querySelector(this.options.container);
|
|
} else {
|
|
this.container = this.options.container;
|
|
}
|
|
if (!(this.container instanceof HTMLElement)) {
|
|
return debug.error('Container required for toolbar', this.options);
|
|
}
|
|
this.container.classList.add('ql-toolbar');
|
|
this.controls = [];
|
|
this.handlers = {};
|
|
Object.keys(this.options.handlers).forEach((format) => {
|
|
this.addHandler(format, this.options.handlers[format]);
|
|
});
|
|
[].forEach.call(this.container.querySelectorAll('button, select'), (input) => {
|
|
this.attach(input);
|
|
});
|
|
this.quill.on(_core_quill__WEBPACK_IMPORTED_MODULE_2__.default.events.EDITOR_CHANGE, (type, range) => {
|
|
if (type === _core_quill__WEBPACK_IMPORTED_MODULE_2__.default.events.SELECTION_CHANGE) {
|
|
this.update(range);
|
|
}
|
|
});
|
|
this.quill.on(_core_quill__WEBPACK_IMPORTED_MODULE_2__.default.events.SCROLL_OPTIMIZE, () => {
|
|
let [range, ] = this.quill.selection.getRange(); // quill.getSelection triggers update
|
|
this.update(range);
|
|
});
|
|
}
|
|
|
|
addHandler(format, handler) {
|
|
this.handlers[format] = handler;
|
|
}
|
|
|
|
attach(input) {
|
|
let format = [].find.call(input.classList, (className) => {
|
|
return className.indexOf('ql-') === 0;
|
|
});
|
|
if (!format) return;
|
|
format = format.slice('ql-'.length);
|
|
if (input.tagName === 'BUTTON') {
|
|
input.setAttribute('type', 'button');
|
|
}
|
|
if (this.handlers[format] == null) {
|
|
if (this.quill.scroll.whitelist != null && this.quill.scroll.whitelist[format] == null) {
|
|
debug.warn('ignoring attaching to disabled format', format, input);
|
|
return;
|
|
}
|
|
if (parchment__WEBPACK_IMPORTED_MODULE_1___default().query(format) == null) {
|
|
debug.warn('ignoring attaching to nonexistent format', format, input);
|
|
return;
|
|
}
|
|
}
|
|
let eventName = input.tagName === 'SELECT' ? 'change' : 'click';
|
|
input.addEventListener(eventName, (e) => {
|
|
let value;
|
|
if (input.tagName === 'SELECT') {
|
|
if (input.selectedIndex < 0) return;
|
|
let selected = input.options[input.selectedIndex];
|
|
if (selected.hasAttribute('selected')) {
|
|
value = false;
|
|
} else {
|
|
value = selected.value || false;
|
|
}
|
|
} else {
|
|
if (input.classList.contains('ql-active')) {
|
|
value = false;
|
|
} else {
|
|
value = input.value || !input.hasAttribute('value');
|
|
}
|
|
e.preventDefault();
|
|
}
|
|
this.quill.focus();
|
|
let [range, ] = this.quill.selection.getRange();
|
|
if (this.handlers[format] != null) {
|
|
this.handlers[format].call(this, value);
|
|
} else if (parchment__WEBPACK_IMPORTED_MODULE_1___default().query(format).prototype instanceof (parchment__WEBPACK_IMPORTED_MODULE_1___default().Embed)) {
|
|
value = prompt(`Enter ${format}`);
|
|
if (!value) return;
|
|
this.quill.updateContents(new (quill_delta__WEBPACK_IMPORTED_MODULE_0___default())()
|
|
.retain(range.index)
|
|
.delete(range.length)
|
|
.insert({ [format]: value })
|
|
, _core_quill__WEBPACK_IMPORTED_MODULE_2__.default.sources.USER);
|
|
} else {
|
|
this.quill.format(format, value, _core_quill__WEBPACK_IMPORTED_MODULE_2__.default.sources.USER);
|
|
}
|
|
this.update(range);
|
|
});
|
|
// TODO use weakmap
|
|
this.controls.push([format, input]);
|
|
}
|
|
|
|
update(range) {
|
|
let formats = range == null ? {} : this.quill.getFormat(range);
|
|
this.controls.forEach(function(pair) {
|
|
let [format, input] = pair;
|
|
if (input.tagName === 'SELECT') {
|
|
let option;
|
|
if (range == null) {
|
|
option = null;
|
|
} else if (formats[format] == null) {
|
|
option = input.querySelector('option[selected]');
|
|
} else if (!Array.isArray(formats[format])) {
|
|
let value = formats[format];
|
|
if (typeof value === 'string') {
|
|
value = value.replace(/\"/g, '\\"');
|
|
}
|
|
option = input.querySelector(`option[value="${value}"]`);
|
|
}
|
|
if (option == null) {
|
|
input.value = ''; // TODO make configurable?
|
|
input.selectedIndex = -1;
|
|
} else {
|
|
option.selected = true;
|
|
}
|
|
} else {
|
|
if (range == null) {
|
|
input.classList.remove('ql-active');
|
|
} else if (input.hasAttribute('value')) {
|
|
// both being null should match (default values)
|
|
// '1' should match with 1 (headers)
|
|
let isActive = formats[format] === input.getAttribute('value') ||
|
|
(formats[format] != null && formats[format].toString() === input.getAttribute('value')) ||
|
|
(formats[format] == null && !input.getAttribute('value'));
|
|
input.classList.toggle('ql-active', isActive);
|
|
} else {
|
|
input.classList.toggle('ql-active', formats[format] != null);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
Toolbar.DEFAULTS = {};
|
|
|
|
|
|
function addButton(container, format, value) {
|
|
let input = document.createElement('button');
|
|
input.setAttribute('type', 'button');
|
|
input.classList.add('ql-' + format);
|
|
if (value != null) {
|
|
input.value = value;
|
|
}
|
|
container.appendChild(input);
|
|
}
|
|
|
|
function addControls(container, groups) {
|
|
if (!Array.isArray(groups[0])) {
|
|
groups = [groups];
|
|
}
|
|
groups.forEach(function(controls) {
|
|
let group = document.createElement('span');
|
|
group.classList.add('ql-formats');
|
|
controls.forEach(function(control) {
|
|
if (typeof control === 'string') {
|
|
addButton(group, control);
|
|
} else {
|
|
let format = Object.keys(control)[0];
|
|
let value = control[format];
|
|
if (Array.isArray(value)) {
|
|
addSelect(group, format, value);
|
|
} else {
|
|
addButton(group, format, value);
|
|
}
|
|
}
|
|
});
|
|
container.appendChild(group);
|
|
});
|
|
}
|
|
|
|
function addSelect(container, format, values) {
|
|
let input = document.createElement('select');
|
|
input.classList.add('ql-' + format);
|
|
values.forEach(function(value) {
|
|
let option = document.createElement('option');
|
|
if (value !== false) {
|
|
option.setAttribute('value', value);
|
|
} else {
|
|
option.setAttribute('selected', 'selected');
|
|
}
|
|
input.appendChild(option);
|
|
});
|
|
container.appendChild(input);
|
|
}
|
|
|
|
Toolbar.DEFAULTS = {
|
|
container: null,
|
|
handlers: {
|
|
clean: function() {
|
|
let range = this.quill.getSelection();
|
|
if (range == null) return;
|
|
if (range.length == 0) {
|
|
let formats = this.quill.getFormat();
|
|
Object.keys(formats).forEach((name) => {
|
|
// Clean functionality in existing apps only clean inline formats
|
|
if (parchment__WEBPACK_IMPORTED_MODULE_1___default().query(name, (parchment__WEBPACK_IMPORTED_MODULE_1___default().Scope.INLINE)) != null) {
|
|
this.quill.format(name, false);
|
|
}
|
|
});
|
|
} else {
|
|
this.quill.removeFormat(range, _core_quill__WEBPACK_IMPORTED_MODULE_2__.default.sources.USER);
|
|
}
|
|
},
|
|
direction: function(value) {
|
|
let align = this.quill.getFormat()['align'];
|
|
if (value === 'rtl' && align == null) {
|
|
this.quill.format('align', 'right', _core_quill__WEBPACK_IMPORTED_MODULE_2__.default.sources.USER);
|
|
} else if (!value && align === 'right') {
|
|
this.quill.format('align', false, _core_quill__WEBPACK_IMPORTED_MODULE_2__.default.sources.USER);
|
|
}
|
|
this.quill.format('direction', value, _core_quill__WEBPACK_IMPORTED_MODULE_2__.default.sources.USER);
|
|
},
|
|
indent: function(value) {
|
|
let range = this.quill.getSelection();
|
|
let formats = this.quill.getFormat(range);
|
|
let indent = parseInt(formats.indent || 0);
|
|
if (value === '+1' || value === '-1') {
|
|
let modifier = (value === '+1') ? 1 : -1;
|
|
if (formats.direction === 'rtl') modifier *= -1;
|
|
this.quill.format('indent', indent + modifier, _core_quill__WEBPACK_IMPORTED_MODULE_2__.default.sources.USER);
|
|
}
|
|
},
|
|
link: function(value) {
|
|
if (value === true) {
|
|
value = prompt('Enter link URL:');
|
|
}
|
|
this.quill.format('link', value, _core_quill__WEBPACK_IMPORTED_MODULE_2__.default.sources.USER);
|
|
},
|
|
list: function(value) {
|
|
let range = this.quill.getSelection();
|
|
let formats = this.quill.getFormat(range);
|
|
if (value === 'check') {
|
|
if (formats['list'] === 'checked' || formats['list'] === 'unchecked') {
|
|
this.quill.format('list', false, _core_quill__WEBPACK_IMPORTED_MODULE_2__.default.sources.USER);
|
|
} else {
|
|
this.quill.format('list', 'unchecked', _core_quill__WEBPACK_IMPORTED_MODULE_2__.default.sources.USER);
|
|
}
|
|
} else {
|
|
this.quill.format('list', value, _core_quill__WEBPACK_IMPORTED_MODULE_2__.default.sources.USER);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/node_modules/eventemitter3/index.js":
|
|
/*!****************************************************************!*\
|
|
!*** ./node_modules/quill/node_modules/eventemitter3/index.js ***!
|
|
\****************************************************************/
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var has = Object.prototype.hasOwnProperty
|
|
, prefix = '~';
|
|
|
|
/**
|
|
* Constructor to create a storage for our `EE` objects.
|
|
* An `Events` instance is a plain object whose properties are event names.
|
|
*
|
|
* @constructor
|
|
* @api private
|
|
*/
|
|
function Events() {}
|
|
|
|
//
|
|
// We try to not inherit from `Object.prototype`. In some engines creating an
|
|
// instance in this way is faster than calling `Object.create(null)` directly.
|
|
// If `Object.create(null)` is not supported we prefix the event names with a
|
|
// character to make sure that the built-in object properties are not
|
|
// overridden or used as an attack vector.
|
|
//
|
|
if (Object.create) {
|
|
Events.prototype = Object.create(null);
|
|
|
|
//
|
|
// This hack is needed because the `__proto__` property is still inherited in
|
|
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
|
|
//
|
|
if (!new Events().__proto__) prefix = false;
|
|
}
|
|
|
|
/**
|
|
* Representation of a single event listener.
|
|
*
|
|
* @param {Function} fn The listener function.
|
|
* @param {Mixed} context The context to invoke the listener with.
|
|
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
* @constructor
|
|
* @api private
|
|
*/
|
|
function EE(fn, context, once) {
|
|
this.fn = fn;
|
|
this.context = context;
|
|
this.once = once || false;
|
|
}
|
|
|
|
/**
|
|
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
* `EventEmitter` interface.
|
|
*
|
|
* @constructor
|
|
* @api public
|
|
*/
|
|
function EventEmitter() {
|
|
this._events = new Events();
|
|
this._eventsCount = 0;
|
|
}
|
|
|
|
/**
|
|
* Return an array listing the events for which the emitter has registered
|
|
* listeners.
|
|
*
|
|
* @returns {Array}
|
|
* @api public
|
|
*/
|
|
EventEmitter.prototype.eventNames = function eventNames() {
|
|
var names = []
|
|
, events
|
|
, name;
|
|
|
|
if (this._eventsCount === 0) return names;
|
|
|
|
for (name in (events = this._events)) {
|
|
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
}
|
|
|
|
if (Object.getOwnPropertySymbols) {
|
|
return names.concat(Object.getOwnPropertySymbols(events));
|
|
}
|
|
|
|
return names;
|
|
};
|
|
|
|
/**
|
|
* Return the listeners registered for a given event.
|
|
*
|
|
* @param {String|Symbol} event The event name.
|
|
* @param {Boolean} exists Only check if there are listeners.
|
|
* @returns {Array|Boolean}
|
|
* @api public
|
|
*/
|
|
EventEmitter.prototype.listeners = function listeners(event, exists) {
|
|
var evt = prefix ? prefix + event : event
|
|
, available = this._events[evt];
|
|
|
|
if (exists) return !!available;
|
|
if (!available) return [];
|
|
if (available.fn) return [available.fn];
|
|
|
|
for (var i = 0, l = available.length, ee = new Array(l); i < l; i++) {
|
|
ee[i] = available[i].fn;
|
|
}
|
|
|
|
return ee;
|
|
};
|
|
|
|
/**
|
|
* Calls each of the listeners registered for a given event.
|
|
*
|
|
* @param {String|Symbol} event The event name.
|
|
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
* @api public
|
|
*/
|
|
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
var evt = prefix ? prefix + event : event;
|
|
|
|
if (!this._events[evt]) return false;
|
|
|
|
var listeners = this._events[evt]
|
|
, len = arguments.length
|
|
, args
|
|
, i;
|
|
|
|
if (listeners.fn) {
|
|
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
|
|
|
switch (len) {
|
|
case 1: return listeners.fn.call(listeners.context), true;
|
|
case 2: return listeners.fn.call(listeners.context, a1), true;
|
|
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
|
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
}
|
|
|
|
for (i = 1, args = new Array(len -1); i < len; i++) {
|
|
args[i - 1] = arguments[i];
|
|
}
|
|
|
|
listeners.fn.apply(listeners.context, args);
|
|
} else {
|
|
var length = listeners.length
|
|
, j;
|
|
|
|
for (i = 0; i < length; i++) {
|
|
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
|
|
|
switch (len) {
|
|
case 1: listeners[i].fn.call(listeners[i].context); break;
|
|
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
|
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
|
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
|
default:
|
|
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
|
args[j - 1] = arguments[j];
|
|
}
|
|
|
|
listeners[i].fn.apply(listeners[i].context, args);
|
|
}
|
|
}
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
/**
|
|
* Add a listener for a given event.
|
|
*
|
|
* @param {String|Symbol} event The event name.
|
|
* @param {Function} fn The listener function.
|
|
* @param {Mixed} [context=this] The context to invoke the listener with.
|
|
* @returns {EventEmitter} `this`.
|
|
* @api public
|
|
*/
|
|
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
var listener = new EE(fn, context || this)
|
|
, evt = prefix ? prefix + event : event;
|
|
|
|
if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;
|
|
else if (!this._events[evt].fn) this._events[evt].push(listener);
|
|
else this._events[evt] = [this._events[evt], listener];
|
|
|
|
return this;
|
|
};
|
|
|
|
/**
|
|
* Add a one-time listener for a given event.
|
|
*
|
|
* @param {String|Symbol} event The event name.
|
|
* @param {Function} fn The listener function.
|
|
* @param {Mixed} [context=this] The context to invoke the listener with.
|
|
* @returns {EventEmitter} `this`.
|
|
* @api public
|
|
*/
|
|
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
var listener = new EE(fn, context || this, true)
|
|
, evt = prefix ? prefix + event : event;
|
|
|
|
if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;
|
|
else if (!this._events[evt].fn) this._events[evt].push(listener);
|
|
else this._events[evt] = [this._events[evt], listener];
|
|
|
|
return this;
|
|
};
|
|
|
|
/**
|
|
* Remove the listeners of a given event.
|
|
*
|
|
* @param {String|Symbol} event The event name.
|
|
* @param {Function} fn Only remove the listeners that match this function.
|
|
* @param {Mixed} context Only remove the listeners that have this context.
|
|
* @param {Boolean} once Only remove one-time listeners.
|
|
* @returns {EventEmitter} `this`.
|
|
* @api public
|
|
*/
|
|
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
var evt = prefix ? prefix + event : event;
|
|
|
|
if (!this._events[evt]) return this;
|
|
if (!fn) {
|
|
if (--this._eventsCount === 0) this._events = new Events();
|
|
else delete this._events[evt];
|
|
return this;
|
|
}
|
|
|
|
var listeners = this._events[evt];
|
|
|
|
if (listeners.fn) {
|
|
if (
|
|
listeners.fn === fn
|
|
&& (!once || listeners.once)
|
|
&& (!context || listeners.context === context)
|
|
) {
|
|
if (--this._eventsCount === 0) this._events = new Events();
|
|
else delete this._events[evt];
|
|
}
|
|
} else {
|
|
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
|
if (
|
|
listeners[i].fn !== fn
|
|
|| (once && !listeners[i].once)
|
|
|| (context && listeners[i].context !== context)
|
|
) {
|
|
events.push(listeners[i]);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Reset the array, or remove it completely if we have no more listeners.
|
|
//
|
|
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
|
else if (--this._eventsCount === 0) this._events = new Events();
|
|
else delete this._events[evt];
|
|
}
|
|
|
|
return this;
|
|
};
|
|
|
|
/**
|
|
* Remove all listeners, or those of the specified event.
|
|
*
|
|
* @param {String|Symbol} [event] The event name.
|
|
* @returns {EventEmitter} `this`.
|
|
* @api public
|
|
*/
|
|
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
var evt;
|
|
|
|
if (event) {
|
|
evt = prefix ? prefix + event : event;
|
|
if (this._events[evt]) {
|
|
if (--this._eventsCount === 0) this._events = new Events();
|
|
else delete this._events[evt];
|
|
}
|
|
} else {
|
|
this._events = new Events();
|
|
this._eventsCount = 0;
|
|
}
|
|
|
|
return this;
|
|
};
|
|
|
|
//
|
|
// Alias methods names because people roll like that.
|
|
//
|
|
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
|
|
//
|
|
// This function doesn't apply anymore.
|
|
//
|
|
EventEmitter.prototype.setMaxListeners = function setMaxListeners() {
|
|
return this;
|
|
};
|
|
|
|
//
|
|
// Expose the prefix.
|
|
//
|
|
EventEmitter.prefixed = prefix;
|
|
|
|
//
|
|
// Allow `EventEmitter` to be imported as module namespace.
|
|
//
|
|
EventEmitter.EventEmitter = EventEmitter;
|
|
|
|
//
|
|
// Expose the module.
|
|
//
|
|
if (true) {
|
|
module.exports = EventEmitter;
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/themes/base.js":
|
|
/*!*******************************************!*\
|
|
!*** ./node_modules/quill/themes/base.js ***!
|
|
\*******************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "BaseTooltip": () => (/* binding */ BaseTooltip),
|
|
/* harmony export */ "default": () => (/* binding */ BaseTheme)
|
|
/* harmony export */ });
|
|
/* harmony import */ var extend__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! extend */ "./node_modules/extend/index.js");
|
|
/* harmony import */ var extend__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(extend__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var quill_delta__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! quill-delta */ "./node_modules/quill-delta/lib/delta.js");
|
|
/* harmony import */ var quill_delta__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(quill_delta__WEBPACK_IMPORTED_MODULE_1__);
|
|
/* harmony import */ var _core_emitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../core/emitter */ "./node_modules/quill/core/emitter.js");
|
|
/* harmony import */ var _modules_keyboard__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../modules/keyboard */ "./node_modules/quill/modules/keyboard.js");
|
|
/* harmony import */ var _core_theme__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../core/theme */ "./node_modules/quill/core/theme.js");
|
|
/* harmony import */ var _ui_color_picker__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../ui/color-picker */ "./node_modules/quill/ui/color-picker.js");
|
|
/* harmony import */ var _ui_icon_picker__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../ui/icon-picker */ "./node_modules/quill/ui/icon-picker.js");
|
|
/* harmony import */ var _ui_picker__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../ui/picker */ "./node_modules/quill/ui/picker.js");
|
|
/* harmony import */ var _ui_tooltip__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../ui/tooltip */ "./node_modules/quill/ui/tooltip.js");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ALIGNS = [ false, 'center', 'right', 'justify' ];
|
|
|
|
const COLORS = [
|
|
"#000000", "#e60000", "#ff9900", "#ffff00", "#008a00", "#0066cc", "#9933ff",
|
|
"#ffffff", "#facccc", "#ffebcc", "#ffffcc", "#cce8cc", "#cce0f5", "#ebd6ff",
|
|
"#bbbbbb", "#f06666", "#ffc266", "#ffff66", "#66b966", "#66a3e0", "#c285ff",
|
|
"#888888", "#a10000", "#b26b00", "#b2b200", "#006100", "#0047b2", "#6b24b2",
|
|
"#444444", "#5c0000", "#663d00", "#666600", "#003700", "#002966", "#3d1466"
|
|
];
|
|
|
|
const FONTS = [ false, 'serif', 'monospace' ];
|
|
|
|
const HEADERS = [ '1', '2', '3', false ];
|
|
|
|
const SIZES = [ 'small', false, 'large', 'huge' ];
|
|
|
|
|
|
class BaseTheme extends _core_theme__WEBPACK_IMPORTED_MODULE_4__.default {
|
|
constructor(quill, options) {
|
|
super(quill, options);
|
|
let listener = (e) => {
|
|
if (!document.body.contains(quill.root)) {
|
|
return document.body.removeEventListener('click', listener);
|
|
}
|
|
if (this.tooltip != null && !this.tooltip.root.contains(e.target) &&
|
|
document.activeElement !== this.tooltip.textbox && !this.quill.hasFocus()) {
|
|
this.tooltip.hide();
|
|
}
|
|
if (this.pickers != null) {
|
|
this.pickers.forEach(function(picker) {
|
|
if (!picker.container.contains(e.target)) {
|
|
picker.close();
|
|
}
|
|
});
|
|
}
|
|
};
|
|
quill.emitter.listenDOM('click', document.body, listener);
|
|
}
|
|
|
|
addModule(name) {
|
|
let module = super.addModule(name);
|
|
if (name === 'toolbar') {
|
|
this.extendToolbar(module);
|
|
}
|
|
return module;
|
|
}
|
|
|
|
buildButtons(buttons, icons) {
|
|
buttons.forEach((button) => {
|
|
let className = button.getAttribute('class') || '';
|
|
className.split(/\s+/).forEach((name) => {
|
|
if (!name.startsWith('ql-')) return;
|
|
name = name.slice('ql-'.length);
|
|
if (icons[name] == null) return;
|
|
if (name === 'direction') {
|
|
button.innerHTML = icons[name][''] + icons[name]['rtl'];
|
|
} else if (typeof icons[name] === 'string') {
|
|
button.innerHTML = icons[name];
|
|
} else {
|
|
let value = button.value || '';
|
|
if (value != null && icons[name][value]) {
|
|
button.innerHTML = icons[name][value];
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
buildPickers(selects, icons) {
|
|
this.pickers = selects.map((select) => {
|
|
if (select.classList.contains('ql-align')) {
|
|
if (select.querySelector('option') == null) {
|
|
fillSelect(select, ALIGNS);
|
|
}
|
|
return new _ui_icon_picker__WEBPACK_IMPORTED_MODULE_6__.default(select, icons.align);
|
|
} else if (select.classList.contains('ql-background') || select.classList.contains('ql-color')) {
|
|
let format = select.classList.contains('ql-background') ? 'background' : 'color';
|
|
if (select.querySelector('option') == null) {
|
|
fillSelect(select, COLORS, format === 'background' ? '#ffffff' : '#000000');
|
|
}
|
|
return new _ui_color_picker__WEBPACK_IMPORTED_MODULE_5__.default(select, icons[format]);
|
|
} else {
|
|
if (select.querySelector('option') == null) {
|
|
if (select.classList.contains('ql-font')) {
|
|
fillSelect(select, FONTS);
|
|
} else if (select.classList.contains('ql-header')) {
|
|
fillSelect(select, HEADERS);
|
|
} else if (select.classList.contains('ql-size')) {
|
|
fillSelect(select, SIZES);
|
|
}
|
|
}
|
|
return new _ui_picker__WEBPACK_IMPORTED_MODULE_7__.default(select);
|
|
}
|
|
});
|
|
let update = () => {
|
|
this.pickers.forEach(function(picker) {
|
|
picker.update();
|
|
});
|
|
};
|
|
this.quill.on(_core_emitter__WEBPACK_IMPORTED_MODULE_2__.default.events.EDITOR_CHANGE, update);
|
|
}
|
|
}
|
|
BaseTheme.DEFAULTS = extend__WEBPACK_IMPORTED_MODULE_0___default()(true, {}, _core_theme__WEBPACK_IMPORTED_MODULE_4__.default.DEFAULTS, {
|
|
modules: {
|
|
toolbar: {
|
|
handlers: {
|
|
formula: function() {
|
|
this.quill.theme.tooltip.edit('formula');
|
|
},
|
|
image: function() {
|
|
let fileInput = this.container.querySelector('input.ql-image[type=file]');
|
|
if (fileInput == null) {
|
|
fileInput = document.createElement('input');
|
|
fileInput.setAttribute('type', 'file');
|
|
fileInput.setAttribute('accept', 'image/png, image/gif, image/jpeg, image/bmp, image/x-icon');
|
|
fileInput.classList.add('ql-image');
|
|
fileInput.addEventListener('change', () => {
|
|
if (fileInput.files != null && fileInput.files[0] != null) {
|
|
let reader = new FileReader();
|
|
reader.onload = (e) => {
|
|
let range = this.quill.getSelection(true);
|
|
this.quill.updateContents(new (quill_delta__WEBPACK_IMPORTED_MODULE_1___default())()
|
|
.retain(range.index)
|
|
.delete(range.length)
|
|
.insert({ image: e.target.result })
|
|
, _core_emitter__WEBPACK_IMPORTED_MODULE_2__.default.sources.USER);
|
|
this.quill.setSelection(range.index + 1, _core_emitter__WEBPACK_IMPORTED_MODULE_2__.default.sources.SILENT);
|
|
fileInput.value = "";
|
|
}
|
|
reader.readAsDataURL(fileInput.files[0]);
|
|
}
|
|
});
|
|
this.container.appendChild(fileInput);
|
|
}
|
|
fileInput.click();
|
|
},
|
|
video: function() {
|
|
this.quill.theme.tooltip.edit('video');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
class BaseTooltip extends _ui_tooltip__WEBPACK_IMPORTED_MODULE_8__.default {
|
|
constructor(quill, boundsContainer) {
|
|
super(quill, boundsContainer);
|
|
this.textbox = this.root.querySelector('input[type="text"]');
|
|
this.listen();
|
|
}
|
|
|
|
listen() {
|
|
this.textbox.addEventListener('keydown', (event) => {
|
|
if (_modules_keyboard__WEBPACK_IMPORTED_MODULE_3__.default.match(event, 'enter')) {
|
|
this.save();
|
|
event.preventDefault();
|
|
} else if (_modules_keyboard__WEBPACK_IMPORTED_MODULE_3__.default.match(event, 'escape')) {
|
|
this.cancel();
|
|
event.preventDefault();
|
|
}
|
|
});
|
|
}
|
|
|
|
cancel() {
|
|
this.hide();
|
|
}
|
|
|
|
edit(mode = 'link', preview = null) {
|
|
this.root.classList.remove('ql-hidden');
|
|
this.root.classList.add('ql-editing');
|
|
if (preview != null) {
|
|
this.textbox.value = preview;
|
|
} else if (mode !== this.root.getAttribute('data-mode')) {
|
|
this.textbox.value = '';
|
|
}
|
|
this.position(this.quill.getBounds(this.quill.selection.savedRange));
|
|
this.textbox.select();
|
|
this.textbox.setAttribute('placeholder', this.textbox.getAttribute(`data-${mode}`) || '');
|
|
this.root.setAttribute('data-mode', mode);
|
|
}
|
|
|
|
restoreFocus() {
|
|
let scrollTop = this.quill.scrollingContainer.scrollTop;
|
|
this.quill.focus();
|
|
this.quill.scrollingContainer.scrollTop = scrollTop;
|
|
}
|
|
|
|
save() {
|
|
let value = this.textbox.value;
|
|
switch(this.root.getAttribute('data-mode')) {
|
|
case 'link': {
|
|
let scrollTop = this.quill.root.scrollTop;
|
|
if (this.linkRange) {
|
|
this.quill.formatText(this.linkRange, 'link', value, _core_emitter__WEBPACK_IMPORTED_MODULE_2__.default.sources.USER);
|
|
delete this.linkRange;
|
|
} else {
|
|
this.restoreFocus();
|
|
this.quill.format('link', value, _core_emitter__WEBPACK_IMPORTED_MODULE_2__.default.sources.USER);
|
|
}
|
|
this.quill.root.scrollTop = scrollTop;
|
|
break;
|
|
}
|
|
case 'video': {
|
|
value = extractVideoUrl(value);
|
|
} // eslint-disable-next-line no-fallthrough
|
|
case 'formula': {
|
|
if (!value) break;
|
|
let range = this.quill.getSelection(true);
|
|
if (range != null) {
|
|
let index = range.index + range.length;
|
|
this.quill.insertEmbed(index, this.root.getAttribute('data-mode'), value, _core_emitter__WEBPACK_IMPORTED_MODULE_2__.default.sources.USER);
|
|
if (this.root.getAttribute('data-mode') === 'formula') {
|
|
this.quill.insertText(index + 1, ' ', _core_emitter__WEBPACK_IMPORTED_MODULE_2__.default.sources.USER);
|
|
}
|
|
this.quill.setSelection(index + 2, _core_emitter__WEBPACK_IMPORTED_MODULE_2__.default.sources.USER);
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
}
|
|
this.textbox.value = '';
|
|
this.hide();
|
|
}
|
|
}
|
|
|
|
|
|
function extractVideoUrl(url) {
|
|
let match = url.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/) ||
|
|
url.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtu\.be\/([a-zA-Z0-9_-]+)/);
|
|
if (match) {
|
|
return (match[1] || 'https') + '://www.youtube.com/embed/' + match[2] + '?showinfo=0';
|
|
}
|
|
if (match = url.match(/^(?:(https?):\/\/)?(?:www\.)?vimeo\.com\/(\d+)/)) { // eslint-disable-line no-cond-assign
|
|
return (match[1] || 'https') + '://player.vimeo.com/video/' + match[2] + '/';
|
|
}
|
|
return url;
|
|
}
|
|
|
|
function fillSelect(select, values, defaultValue = false) {
|
|
values.forEach(function(value) {
|
|
let option = document.createElement('option');
|
|
if (value === defaultValue) {
|
|
option.setAttribute('selected', 'selected');
|
|
} else {
|
|
option.setAttribute('value', value);
|
|
}
|
|
select.appendChild(option);
|
|
});
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/themes/snow.js":
|
|
/*!*******************************************!*\
|
|
!*** ./node_modules/quill/themes/snow.js ***!
|
|
\*******************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony import */ var extend__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! extend */ "./node_modules/extend/index.js");
|
|
/* harmony import */ var extend__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(extend__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var _core_emitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../core/emitter */ "./node_modules/quill/core/emitter.js");
|
|
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base */ "./node_modules/quill/themes/base.js");
|
|
/* harmony import */ var _formats_link__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../formats/link */ "./node_modules/quill/formats/link.js");
|
|
/* harmony import */ var _core_selection__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../core/selection */ "./node_modules/quill/core/selection.js");
|
|
/* harmony import */ var _ui_icons__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../ui/icons */ "./node_modules/quill/ui/icons.js");
|
|
/* harmony import */ var _ui_icons__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_ui_icons__WEBPACK_IMPORTED_MODULE_5__);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const TOOLBAR_CONFIG = [
|
|
[{ header: ['1', '2', '3', false] }],
|
|
['bold', 'italic', 'underline', 'link'],
|
|
[{ list: 'ordered' }, { list: 'bullet' }],
|
|
['clean']
|
|
];
|
|
|
|
class SnowTheme extends _base__WEBPACK_IMPORTED_MODULE_2__.default {
|
|
constructor(quill, options) {
|
|
if (options.modules.toolbar != null && options.modules.toolbar.container == null) {
|
|
options.modules.toolbar.container = TOOLBAR_CONFIG;
|
|
}
|
|
super(quill, options);
|
|
this.quill.container.classList.add('ql-snow');
|
|
}
|
|
|
|
extendToolbar(toolbar) {
|
|
toolbar.container.classList.add('ql-snow');
|
|
this.buildButtons([].slice.call(toolbar.container.querySelectorAll('button')), (_ui_icons__WEBPACK_IMPORTED_MODULE_5___default()));
|
|
this.buildPickers([].slice.call(toolbar.container.querySelectorAll('select')), (_ui_icons__WEBPACK_IMPORTED_MODULE_5___default()));
|
|
this.tooltip = new SnowTooltip(this.quill, this.options.bounds);
|
|
if (toolbar.container.querySelector('.ql-link')) {
|
|
this.quill.keyboard.addBinding({ key: 'K', shortKey: true }, function(range, context) {
|
|
toolbar.handlers['link'].call(toolbar, !context.format.link);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
SnowTheme.DEFAULTS = extend__WEBPACK_IMPORTED_MODULE_0___default()(true, {}, _base__WEBPACK_IMPORTED_MODULE_2__.default.DEFAULTS, {
|
|
modules: {
|
|
toolbar: {
|
|
handlers: {
|
|
link: function(value) {
|
|
if (value) {
|
|
let range = this.quill.getSelection();
|
|
if (range == null || range.length == 0) return;
|
|
let preview = this.quill.getText(range);
|
|
if (/^\S+@\S+\.\S+$/.test(preview) && preview.indexOf('mailto:') !== 0) {
|
|
preview = 'mailto:' + preview;
|
|
}
|
|
let tooltip = this.quill.theme.tooltip;
|
|
tooltip.edit('link', preview);
|
|
} else {
|
|
this.quill.format('link', false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
class SnowTooltip extends _base__WEBPACK_IMPORTED_MODULE_2__.BaseTooltip {
|
|
constructor(quill, bounds) {
|
|
super(quill, bounds);
|
|
this.preview = this.root.querySelector('a.ql-preview');
|
|
}
|
|
|
|
listen() {
|
|
super.listen();
|
|
this.root.querySelector('a.ql-action').addEventListener('click', (event) => {
|
|
if (this.root.classList.contains('ql-editing')) {
|
|
this.save();
|
|
} else {
|
|
this.edit('link', this.preview.textContent);
|
|
}
|
|
event.preventDefault();
|
|
});
|
|
this.root.querySelector('a.ql-remove').addEventListener('click', (event) => {
|
|
if (this.linkRange != null) {
|
|
let range = this.linkRange;
|
|
this.restoreFocus();
|
|
this.quill.formatText(range, 'link', false, _core_emitter__WEBPACK_IMPORTED_MODULE_1__.default.sources.USER);
|
|
delete this.linkRange;
|
|
}
|
|
event.preventDefault();
|
|
this.hide();
|
|
});
|
|
this.quill.on(_core_emitter__WEBPACK_IMPORTED_MODULE_1__.default.events.SELECTION_CHANGE, (range, oldRange, source) => {
|
|
if (range == null) return;
|
|
if (range.length === 0 && source === _core_emitter__WEBPACK_IMPORTED_MODULE_1__.default.sources.USER) {
|
|
let [link, offset] = this.quill.scroll.descendant(_formats_link__WEBPACK_IMPORTED_MODULE_3__.default, range.index);
|
|
if (link != null) {
|
|
this.linkRange = new _core_selection__WEBPACK_IMPORTED_MODULE_4__.Range(range.index - offset, link.length());
|
|
let preview = _formats_link__WEBPACK_IMPORTED_MODULE_3__.default.formats(link.domNode);
|
|
this.preview.textContent = preview;
|
|
this.preview.setAttribute('href', preview);
|
|
this.show();
|
|
this.position(this.quill.getBounds(this.linkRange));
|
|
return;
|
|
}
|
|
} else {
|
|
delete this.linkRange;
|
|
}
|
|
this.hide();
|
|
});
|
|
}
|
|
|
|
show() {
|
|
super.show();
|
|
this.root.removeAttribute('data-mode');
|
|
}
|
|
}
|
|
SnowTooltip.TEMPLATE = [
|
|
'<a class="ql-preview" rel="noopener noreferrer" target="_blank" href="about:blank"></a>',
|
|
'<input type="text" data-formula="e=mc^2" data-link="https://quilljs.com" data-video="Embed URL">',
|
|
'<a class="ql-action"></a>',
|
|
'<a class="ql-remove"></a>'
|
|
].join('');
|
|
|
|
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (SnowTheme);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/ui/color-picker.js":
|
|
/*!***********************************************!*\
|
|
!*** ./node_modules/quill/ui/color-picker.js ***!
|
|
\***********************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony import */ var _picker__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./picker */ "./node_modules/quill/ui/picker.js");
|
|
|
|
|
|
|
|
class ColorPicker extends _picker__WEBPACK_IMPORTED_MODULE_0__.default {
|
|
constructor(select, label) {
|
|
super(select);
|
|
this.label.innerHTML = label;
|
|
this.container.classList.add('ql-color-picker');
|
|
[].slice.call(this.container.querySelectorAll('.ql-picker-item'), 0, 7).forEach(function(item) {
|
|
item.classList.add('ql-primary');
|
|
});
|
|
}
|
|
|
|
buildItem(option) {
|
|
let item = super.buildItem(option);
|
|
item.style.backgroundColor = option.getAttribute('value') || '';
|
|
return item;
|
|
}
|
|
|
|
selectItem(item, trigger) {
|
|
super.selectItem(item, trigger);
|
|
let colorLabel = this.label.querySelector('.ql-color-label');
|
|
let value = item ? item.getAttribute('data-value') || '' : '';
|
|
if (colorLabel) {
|
|
if (colorLabel.tagName === 'line') {
|
|
colorLabel.style.stroke = value;
|
|
} else {
|
|
colorLabel.style.fill = value;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ColorPicker);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/ui/icon-picker.js":
|
|
/*!**********************************************!*\
|
|
!*** ./node_modules/quill/ui/icon-picker.js ***!
|
|
\**********************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony import */ var _picker__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./picker */ "./node_modules/quill/ui/picker.js");
|
|
|
|
|
|
|
|
class IconPicker extends _picker__WEBPACK_IMPORTED_MODULE_0__.default {
|
|
constructor(select, icons) {
|
|
super(select);
|
|
this.container.classList.add('ql-icon-picker');
|
|
[].forEach.call(this.container.querySelectorAll('.ql-picker-item'), (item) => {
|
|
item.innerHTML = icons[item.getAttribute('data-value') || ''];
|
|
});
|
|
this.defaultItem = this.container.querySelector('.ql-selected');
|
|
this.selectItem(this.defaultItem);
|
|
}
|
|
|
|
selectItem(item, trigger) {
|
|
super.selectItem(item, trigger);
|
|
item = item || this.defaultItem;
|
|
this.label.innerHTML = item.innerHTML;
|
|
}
|
|
}
|
|
|
|
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (IconPicker);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/ui/icons.js":
|
|
/*!****************************************!*\
|
|
!*** ./node_modules/quill/ui/icons.js ***!
|
|
\****************************************/
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
module.exports = {
|
|
'align': {
|
|
'' : __webpack_require__(/*! ../assets/icons/align-left.svg */ "./node_modules/quill/assets/icons/align-left.svg"),
|
|
'center' : __webpack_require__(/*! ../assets/icons/align-center.svg */ "./node_modules/quill/assets/icons/align-center.svg"),
|
|
'right' : __webpack_require__(/*! ../assets/icons/align-right.svg */ "./node_modules/quill/assets/icons/align-right.svg"),
|
|
'justify' : __webpack_require__(/*! ../assets/icons/align-justify.svg */ "./node_modules/quill/assets/icons/align-justify.svg")
|
|
},
|
|
'background': __webpack_require__(/*! ../assets/icons/background.svg */ "./node_modules/quill/assets/icons/background.svg"),
|
|
'blockquote': __webpack_require__(/*! ../assets/icons/blockquote.svg */ "./node_modules/quill/assets/icons/blockquote.svg"),
|
|
'bold' : __webpack_require__(/*! ../assets/icons/bold.svg */ "./node_modules/quill/assets/icons/bold.svg"),
|
|
'clean' : __webpack_require__(/*! ../assets/icons/clean.svg */ "./node_modules/quill/assets/icons/clean.svg"),
|
|
'code' : __webpack_require__(/*! ../assets/icons/code.svg */ "./node_modules/quill/assets/icons/code.svg"),
|
|
'code-block': __webpack_require__(/*! ../assets/icons/code.svg */ "./node_modules/quill/assets/icons/code.svg"),
|
|
'color' : __webpack_require__(/*! ../assets/icons/color.svg */ "./node_modules/quill/assets/icons/color.svg"),
|
|
'direction' : {
|
|
'' : __webpack_require__(/*! ../assets/icons/direction-ltr.svg */ "./node_modules/quill/assets/icons/direction-ltr.svg"),
|
|
'rtl' : __webpack_require__(/*! ../assets/icons/direction-rtl.svg */ "./node_modules/quill/assets/icons/direction-rtl.svg")
|
|
},
|
|
'float': {
|
|
'center' : __webpack_require__(/*! ../assets/icons/float-center.svg */ "./node_modules/quill/assets/icons/float-center.svg"),
|
|
'full' : __webpack_require__(/*! ../assets/icons/float-full.svg */ "./node_modules/quill/assets/icons/float-full.svg"),
|
|
'left' : __webpack_require__(/*! ../assets/icons/float-left.svg */ "./node_modules/quill/assets/icons/float-left.svg"),
|
|
'right' : __webpack_require__(/*! ../assets/icons/float-right.svg */ "./node_modules/quill/assets/icons/float-right.svg")
|
|
},
|
|
'formula' : __webpack_require__(/*! ../assets/icons/formula.svg */ "./node_modules/quill/assets/icons/formula.svg"),
|
|
'header': {
|
|
'1' : __webpack_require__(/*! ../assets/icons/header.svg */ "./node_modules/quill/assets/icons/header.svg"),
|
|
'2' : __webpack_require__(/*! ../assets/icons/header-2.svg */ "./node_modules/quill/assets/icons/header-2.svg")
|
|
},
|
|
'italic' : __webpack_require__(/*! ../assets/icons/italic.svg */ "./node_modules/quill/assets/icons/italic.svg"),
|
|
'image' : __webpack_require__(/*! ../assets/icons/image.svg */ "./node_modules/quill/assets/icons/image.svg"),
|
|
'indent': {
|
|
'+1' : __webpack_require__(/*! ../assets/icons/indent.svg */ "./node_modules/quill/assets/icons/indent.svg"),
|
|
'-1' : __webpack_require__(/*! ../assets/icons/outdent.svg */ "./node_modules/quill/assets/icons/outdent.svg")
|
|
},
|
|
'link' : __webpack_require__(/*! ../assets/icons/link.svg */ "./node_modules/quill/assets/icons/link.svg"),
|
|
'list': {
|
|
'ordered' : __webpack_require__(/*! ../assets/icons/list-ordered.svg */ "./node_modules/quill/assets/icons/list-ordered.svg"),
|
|
'bullet' : __webpack_require__(/*! ../assets/icons/list-bullet.svg */ "./node_modules/quill/assets/icons/list-bullet.svg"),
|
|
'check' : __webpack_require__(/*! ../assets/icons/list-check.svg */ "./node_modules/quill/assets/icons/list-check.svg")
|
|
},
|
|
'script': {
|
|
'sub' : __webpack_require__(/*! ../assets/icons/subscript.svg */ "./node_modules/quill/assets/icons/subscript.svg"),
|
|
'super' : __webpack_require__(/*! ../assets/icons/superscript.svg */ "./node_modules/quill/assets/icons/superscript.svg"),
|
|
},
|
|
'strike' : __webpack_require__(/*! ../assets/icons/strike.svg */ "./node_modules/quill/assets/icons/strike.svg"),
|
|
'underline' : __webpack_require__(/*! ../assets/icons/underline.svg */ "./node_modules/quill/assets/icons/underline.svg"),
|
|
'video' : __webpack_require__(/*! ../assets/icons/video.svg */ "./node_modules/quill/assets/icons/video.svg")
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/ui/picker.js":
|
|
/*!*****************************************!*\
|
|
!*** ./node_modules/quill/ui/picker.js ***!
|
|
\*****************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
/* harmony import */ var _modules_keyboard__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../modules/keyboard */ "./node_modules/quill/modules/keyboard.js");
|
|
/* harmony import */ var _assets_icons_dropdown_svg__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../assets/icons/dropdown.svg */ "./node_modules/quill/assets/icons/dropdown.svg");
|
|
|
|
|
|
|
|
let optionsCounter = 0;
|
|
|
|
function toggleAriaAttribute(element, attribute) {
|
|
element.setAttribute(attribute, !(element.getAttribute(attribute) === 'true'));
|
|
}
|
|
|
|
class Picker {
|
|
constructor(select) {
|
|
this.select = select;
|
|
this.container = document.createElement('span');
|
|
this.buildPicker();
|
|
this.select.style.display = 'none';
|
|
this.select.parentNode.insertBefore(this.container, this.select);
|
|
|
|
this.label.addEventListener('mousedown', () => {
|
|
this.togglePicker();
|
|
});
|
|
this.label.addEventListener('keydown', (event) => {
|
|
switch(event.keyCode) {
|
|
// Allows the "Enter" key to open the picker
|
|
case _modules_keyboard__WEBPACK_IMPORTED_MODULE_0__.default.keys.ENTER:
|
|
this.togglePicker();
|
|
break;
|
|
|
|
// Allows the "Escape" key to close the picker
|
|
case _modules_keyboard__WEBPACK_IMPORTED_MODULE_0__.default.keys.ESCAPE:
|
|
this.escape();
|
|
event.preventDefault();
|
|
break;
|
|
default:
|
|
}
|
|
});
|
|
this.select.addEventListener('change', this.update.bind(this));
|
|
}
|
|
|
|
togglePicker() {
|
|
this.container.classList.toggle('ql-expanded');
|
|
// Toggle aria-expanded and aria-hidden to make the picker accessible
|
|
toggleAriaAttribute(this.label, 'aria-expanded');
|
|
toggleAriaAttribute(this.options, 'aria-hidden');
|
|
}
|
|
|
|
buildItem(option) {
|
|
let item = document.createElement('span');
|
|
item.tabIndex = '0';
|
|
item.setAttribute('role', 'button');
|
|
|
|
item.classList.add('ql-picker-item');
|
|
if (option.hasAttribute('value')) {
|
|
item.setAttribute('data-value', option.getAttribute('value'));
|
|
}
|
|
if (option.textContent) {
|
|
item.setAttribute('data-label', option.textContent);
|
|
}
|
|
item.addEventListener('click', () => {
|
|
this.selectItem(item, true);
|
|
});
|
|
item.addEventListener('keydown', (event) => {
|
|
switch(event.keyCode) {
|
|
// Allows the "Enter" key to select an item
|
|
case _modules_keyboard__WEBPACK_IMPORTED_MODULE_0__.default.keys.ENTER:
|
|
this.selectItem(item, true);
|
|
event.preventDefault();
|
|
break;
|
|
|
|
// Allows the "Escape" key to close the picker
|
|
case _modules_keyboard__WEBPACK_IMPORTED_MODULE_0__.default.keys.ESCAPE:
|
|
this.escape();
|
|
event.preventDefault();
|
|
break;
|
|
default:
|
|
}
|
|
});
|
|
|
|
return item;
|
|
}
|
|
|
|
buildLabel() {
|
|
let label = document.createElement('span');
|
|
label.classList.add('ql-picker-label');
|
|
label.innerHTML = _assets_icons_dropdown_svg__WEBPACK_IMPORTED_MODULE_1__.default;
|
|
label.tabIndex = '0';
|
|
label.setAttribute('role', 'button');
|
|
label.setAttribute('aria-expanded', 'false');
|
|
this.container.appendChild(label);
|
|
return label;
|
|
}
|
|
|
|
buildOptions() {
|
|
let options = document.createElement('span');
|
|
options.classList.add('ql-picker-options');
|
|
|
|
// Don't want screen readers to read this until options are visible
|
|
options.setAttribute('aria-hidden', 'true');
|
|
options.tabIndex = '-1';
|
|
|
|
// Need a unique id for aria-controls
|
|
options.id = `ql-picker-options-${optionsCounter}`;
|
|
optionsCounter += 1;
|
|
this.label.setAttribute('aria-controls', options.id);
|
|
|
|
this.options = options;
|
|
|
|
[].slice.call(this.select.options).forEach((option) => {
|
|
let item = this.buildItem(option);
|
|
options.appendChild(item);
|
|
if (option.selected === true) {
|
|
this.selectItem(item);
|
|
}
|
|
});
|
|
this.container.appendChild(options);
|
|
}
|
|
|
|
buildPicker() {
|
|
[].slice.call(this.select.attributes).forEach((item) => {
|
|
this.container.setAttribute(item.name, item.value);
|
|
});
|
|
this.container.classList.add('ql-picker');
|
|
this.label = this.buildLabel();
|
|
this.buildOptions();
|
|
}
|
|
|
|
escape() {
|
|
// Close menu and return focus to trigger label
|
|
this.close();
|
|
// Need setTimeout for accessibility to ensure that the browser executes
|
|
// focus on the next process thread and after any DOM content changes
|
|
setTimeout(() => this.label.focus(), 1);
|
|
}
|
|
|
|
close() {
|
|
this.container.classList.remove('ql-expanded');
|
|
this.label.setAttribute('aria-expanded', 'false');
|
|
this.options.setAttribute('aria-hidden', 'true');
|
|
}
|
|
|
|
selectItem(item, trigger = false) {
|
|
let selected = this.container.querySelector('.ql-selected');
|
|
if (item === selected) return;
|
|
if (selected != null) {
|
|
selected.classList.remove('ql-selected');
|
|
}
|
|
if (item == null) return;
|
|
item.classList.add('ql-selected');
|
|
this.select.selectedIndex = [].indexOf.call(item.parentNode.children, item);
|
|
if (item.hasAttribute('data-value')) {
|
|
this.label.setAttribute('data-value', item.getAttribute('data-value'));
|
|
} else {
|
|
this.label.removeAttribute('data-value');
|
|
}
|
|
if (item.hasAttribute('data-label')) {
|
|
this.label.setAttribute('data-label', item.getAttribute('data-label'));
|
|
} else {
|
|
this.label.removeAttribute('data-label');
|
|
}
|
|
if (trigger) {
|
|
if (typeof Event === 'function') {
|
|
this.select.dispatchEvent(new Event('change'));
|
|
} else if (typeof Event === 'object') { // IE11
|
|
let event = document.createEvent('Event');
|
|
event.initEvent('change', true, true);
|
|
this.select.dispatchEvent(event);
|
|
}
|
|
this.close();
|
|
}
|
|
}
|
|
|
|
update() {
|
|
let option;
|
|
if (this.select.selectedIndex > -1) {
|
|
let item = this.container.querySelector('.ql-picker-options').children[this.select.selectedIndex];
|
|
option = this.select.options[this.select.selectedIndex];
|
|
this.selectItem(item);
|
|
} else {
|
|
this.selectItem(null);
|
|
}
|
|
let isActive = option != null && option !== this.select.querySelector('option[selected]');
|
|
this.label.classList.toggle('ql-active', isActive);
|
|
}
|
|
}
|
|
|
|
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Picker);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/quill/ui/tooltip.js":
|
|
/*!******************************************!*\
|
|
!*** ./node_modules/quill/ui/tooltip.js ***!
|
|
\******************************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
/* harmony export */ });
|
|
class Tooltip {
|
|
constructor(quill, boundsContainer) {
|
|
this.quill = quill;
|
|
this.boundsContainer = boundsContainer || document.body;
|
|
this.root = quill.addContainer('ql-tooltip');
|
|
this.root.innerHTML = this.constructor.TEMPLATE;
|
|
if (this.quill.root === this.quill.scrollingContainer) {
|
|
this.quill.root.addEventListener('scroll', () => {
|
|
this.root.style.marginTop = (-1*this.quill.root.scrollTop) + 'px';
|
|
});
|
|
}
|
|
this.hide();
|
|
}
|
|
|
|
hide() {
|
|
this.root.classList.add('ql-hidden');
|
|
}
|
|
|
|
position(reference) {
|
|
let left = reference.left + reference.width/2 - this.root.offsetWidth/2;
|
|
// root.scrollTop should be 0 if scrollContainer !== root
|
|
let top = reference.bottom + this.quill.root.scrollTop;
|
|
this.root.style.left = left + 'px';
|
|
this.root.style.top = top + 'px';
|
|
this.root.classList.remove('ql-flip');
|
|
let containerBounds = this.boundsContainer.getBoundingClientRect();
|
|
let rootBounds = this.root.getBoundingClientRect();
|
|
let shift = 0;
|
|
if (rootBounds.right > containerBounds.right) {
|
|
shift = containerBounds.right - rootBounds.right;
|
|
this.root.style.left = (left + shift) + 'px';
|
|
}
|
|
if (rootBounds.left < containerBounds.left) {
|
|
shift = containerBounds.left - rootBounds.left;
|
|
this.root.style.left = (left + shift) + 'px';
|
|
}
|
|
if (rootBounds.bottom > containerBounds.bottom) {
|
|
let height = rootBounds.bottom - rootBounds.top;
|
|
let verticalShift = reference.bottom - reference.top + height;
|
|
this.root.style.top = (top - verticalShift) + 'px';
|
|
this.root.classList.add('ql-flip');
|
|
}
|
|
return shift;
|
|
}
|
|
|
|
show() {
|
|
this.root.classList.remove('ql-editing');
|
|
this.root.classList.remove('ql-hidden');
|
|
}
|
|
}
|
|
|
|
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Tooltip);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/regexp.prototype.flags/implementation.js":
|
|
/*!***************************************************************!*\
|
|
!*** ./node_modules/regexp.prototype.flags/implementation.js ***!
|
|
\***************************************************************/
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var $Object = Object;
|
|
var $TypeError = TypeError;
|
|
|
|
module.exports = function flags() {
|
|
if (this != null && this !== $Object(this)) {
|
|
throw new $TypeError('RegExp.prototype.flags getter called on non-object');
|
|
}
|
|
var result = '';
|
|
if (this.global) {
|
|
result += 'g';
|
|
}
|
|
if (this.ignoreCase) {
|
|
result += 'i';
|
|
}
|
|
if (this.multiline) {
|
|
result += 'm';
|
|
}
|
|
if (this.dotAll) {
|
|
result += 's';
|
|
}
|
|
if (this.unicode) {
|
|
result += 'u';
|
|
}
|
|
if (this.sticky) {
|
|
result += 'y';
|
|
}
|
|
return result;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/regexp.prototype.flags/index.js":
|
|
/*!******************************************************!*\
|
|
!*** ./node_modules/regexp.prototype.flags/index.js ***!
|
|
\******************************************************/
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var define = __webpack_require__(/*! define-properties */ "./node_modules/define-properties/index.js");
|
|
var callBind = __webpack_require__(/*! es-abstract/helpers/callBind */ "./node_modules/es-abstract/helpers/callBind.js");
|
|
|
|
var implementation = __webpack_require__(/*! ./implementation */ "./node_modules/regexp.prototype.flags/implementation.js");
|
|
var getPolyfill = __webpack_require__(/*! ./polyfill */ "./node_modules/regexp.prototype.flags/polyfill.js");
|
|
var shim = __webpack_require__(/*! ./shim */ "./node_modules/regexp.prototype.flags/shim.js");
|
|
|
|
var flagsBound = callBind(implementation);
|
|
|
|
define(flagsBound, {
|
|
getPolyfill: getPolyfill,
|
|
implementation: implementation,
|
|
shim: shim
|
|
});
|
|
|
|
module.exports = flagsBound;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/regexp.prototype.flags/polyfill.js":
|
|
/*!*********************************************************!*\
|
|
!*** ./node_modules/regexp.prototype.flags/polyfill.js ***!
|
|
\*********************************************************/
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var implementation = __webpack_require__(/*! ./implementation */ "./node_modules/regexp.prototype.flags/implementation.js");
|
|
|
|
var supportsDescriptors = __webpack_require__(/*! define-properties */ "./node_modules/define-properties/index.js").supportsDescriptors;
|
|
var $gOPD = Object.getOwnPropertyDescriptor;
|
|
var $TypeError = TypeError;
|
|
|
|
module.exports = function getPolyfill() {
|
|
if (!supportsDescriptors) {
|
|
throw new $TypeError('RegExp.prototype.flags requires a true ES5 environment that supports property descriptors');
|
|
}
|
|
if ((/a/mig).flags === 'gim') {
|
|
var descriptor = $gOPD(RegExp.prototype, 'flags');
|
|
if (descriptor && typeof descriptor.get === 'function' && typeof (/a/).dotAll === 'boolean') {
|
|
return descriptor.get;
|
|
}
|
|
}
|
|
return implementation;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/regexp.prototype.flags/shim.js":
|
|
/*!*****************************************************!*\
|
|
!*** ./node_modules/regexp.prototype.flags/shim.js ***!
|
|
\*****************************************************/
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var supportsDescriptors = __webpack_require__(/*! define-properties */ "./node_modules/define-properties/index.js").supportsDescriptors;
|
|
var getPolyfill = __webpack_require__(/*! ./polyfill */ "./node_modules/regexp.prototype.flags/polyfill.js");
|
|
var gOPD = Object.getOwnPropertyDescriptor;
|
|
var defineProperty = Object.defineProperty;
|
|
var TypeErr = TypeError;
|
|
var getProto = Object.getPrototypeOf;
|
|
var regex = /a/;
|
|
|
|
module.exports = function shimFlags() {
|
|
if (!supportsDescriptors || !getProto) {
|
|
throw new TypeErr('RegExp.prototype.flags requires a true ES5 environment that supports property descriptors');
|
|
}
|
|
var polyfill = getPolyfill();
|
|
var proto = getProto(regex);
|
|
var descriptor = gOPD(proto, 'flags');
|
|
if (!descriptor || descriptor.get !== polyfill) {
|
|
defineProperty(proto, 'flags', {
|
|
configurable: true,
|
|
enumerable: false,
|
|
get: polyfill
|
|
});
|
|
}
|
|
return polyfill;
|
|
};
|
|
|
|
|
|
/***/ })
|
|
|
|
/******/ });
|
|
/************************************************************************/
|
|
/******/ // The module cache
|
|
/******/ var __webpack_module_cache__ = {};
|
|
/******/
|
|
/******/ // The require function
|
|
/******/ function __webpack_require__(moduleId) {
|
|
/******/ // Check if module is in cache
|
|
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
/******/ if (cachedModule !== undefined) {
|
|
/******/ return cachedModule.exports;
|
|
/******/ }
|
|
/******/ // Create a new module (and put it into the cache)
|
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
/******/ // no module.id needed
|
|
/******/ // no module.loaded needed
|
|
/******/ exports: {}
|
|
/******/ };
|
|
/******/
|
|
/******/ // Execute the module function
|
|
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
/******/
|
|
/******/ // Return the exports of the module
|
|
/******/ return module.exports;
|
|
/******/ }
|
|
/******/
|
|
/************************************************************************/
|
|
/******/ /* webpack/runtime/compat get default export */
|
|
/******/ (() => {
|
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
/******/ __webpack_require__.n = (module) => {
|
|
/******/ var getter = module && module.__esModule ?
|
|
/******/ () => (module['default']) :
|
|
/******/ () => (module);
|
|
/******/ __webpack_require__.d(getter, { a: getter });
|
|
/******/ return getter;
|
|
/******/ };
|
|
/******/ })();
|
|
/******/
|
|
/******/ /* webpack/runtime/define property getters */
|
|
/******/ (() => {
|
|
/******/ // define getter functions for harmony exports
|
|
/******/ __webpack_require__.d = (exports, definition) => {
|
|
/******/ for(var key in definition) {
|
|
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
/******/ }
|
|
/******/ }
|
|
/******/ };
|
|
/******/ })();
|
|
/******/
|
|
/******/ /* webpack/runtime/global */
|
|
/******/ (() => {
|
|
/******/ __webpack_require__.g = (function() {
|
|
/******/ if (typeof globalThis === 'object') return globalThis;
|
|
/******/ try {
|
|
/******/ return this || new Function('return this')();
|
|
/******/ } catch (e) {
|
|
/******/ if (typeof window === 'object') return window;
|
|
/******/ }
|
|
/******/ })();
|
|
/******/ })();
|
|
/******/
|
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
/******/ (() => {
|
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
/******/ })();
|
|
/******/
|
|
/******/ /* webpack/runtime/make namespace object */
|
|
/******/ (() => {
|
|
/******/ // define __esModule on exports
|
|
/******/ __webpack_require__.r = (exports) => {
|
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
/******/ }
|
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
/******/ };
|
|
/******/ })();
|
|
/******/
|
|
/************************************************************************/
|
|
var __webpack_exports__ = {};
|
|
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
(() => {
|
|
/*!**************************************!*\
|
|
!*** ./resources/js/recipes/edit.js ***!
|
|
\**************************************/
|
|
__webpack_require__(/*! ../quill */ "./resources/js/quill.js");
|
|
|
|
window.Draggable = __webpack_require__(/*! @shopify/draggable */ "./node_modules/@shopify/draggable/lib/draggable.bundle.js");
|
|
window.Quill = __webpack_require__(/*! quill */ "./node_modules/quill/dist/quill.js");
|
|
})();
|
|
|
|
/******/ })()
|
|
; |