quill-cursors
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -1,2 +0,364 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.QuillCursors=e():t.QuillCursors=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var r={};return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=3)}([function(t,e,r){"use strict";function n(t,e){this.quill=t,this._initOptions(e),this.cursors={},this.container=this.quill.addContainer("ql-cursors"),this.options.autoRegisterListener&&this.registerTextChangeListener(),window.addEventListener("resize",this.update.bind(this))}Object.defineProperty(e,"__esModule",{value:!0});var i=r(1),o=r.n(i),a=r(2),s=r.n(a),l={template:['<span class="ql-cursor-selections"></span>','<span class="ql-cursor-caret-container">',' <span class="ql-cursor-caret"></span>',"</span>",'<div class="ql-cursor-flag">',' <small class="ql-cursor-name"></small>',' <span class="ql-cursor-flag-flap"></span>',"</div>"].join(""),autoRegisterListener:!0,hideDelay:3e3,hideSpeed:400};n.prototype.registerTextChangeListener=function(){this.quill.on(this.quill.constructor.events.TEXT_CHANGE,this._applyDelta.bind(this))},n.prototype.clearCursors=function(){Object.keys(this.cursors).forEach(this.removeCursor.bind(this))},n.prototype.moveCursor=function(t,e){var r=this.cursors[t];r&&(r.range=e,r.el.classList.remove("hidden"),this._updateCursor(r))},n.prototype.removeCursor=function(t){var e=this.cursors[t];e&&e.el.parentNode.removeChild(e.el),delete this.cursors[t]},n.prototype.setCursor=function(t,e,r,n){return this.cursors[t]||(this.cursors[t]={userId:t,color:n,range:e,el:null,selectionEl:null,caretEl:null,flagEl:null},this._buildCursor(t,r)),window.setTimeout(function(){this.moveCursor(t,e)}.bind(this)),this.cursors[t]},n.prototype.shiftCursors=function(t,e){var r;Object.keys(this.cursors).forEach(function(n){(r=this.cursors[n])&&r.range&&(e>0||0==r.range.length?this._shiftCursor(n,t-1,e):this._shiftCursor(n,t,e))},this)},n.prototype.update=function(){Object.keys(this.cursors).map(function(t){this._updateCursor(this.cursors[t])}.bind(this))},n.prototype._initOptions=function(t){this.options=l,this.options.template=t.template||this.options.template,this.options.autoRegisterListener=0==t.autoRegisterListener?t.autoRegisterListener:this.options.autoRegisterListener,this.options.hideDelay=void 0==t.hideDelay?this.options.hideDelay:t.hideDelay,this.options.hideSpeed=void 0==t.hideSpeed?this.options.hideSpeed:t.hideSpeed},n.prototype._applyDelta=function(t){var e=0;t.ops.forEach(function(t){var r=0;t.insert?(r=t.insert.length||1,this.shiftCursors(e,r)):t.delete?this.shiftCursors(e,-1*t.delete):t.retain&&(r=t.retain),e+=r},this),this.update()},n.prototype._buildCursor=function(t,e){var r,n,i,o=this.cursors[t],a=document.createElement("span");a.classList.add("ql-cursor"),a.innerHTML=this.options.template,r=a.querySelector(".ql-cursor-selections"),n=a.querySelector(".ql-cursor-caret-container"),(i=a.querySelector(".ql-cursor-flag")).style.backgroundColor=o.color,n.querySelector(".ql-cursor-caret").style.backgroundColor=o.color,a.querySelector(".ql-cursor-name").innerText=e,i.style.transitionDelay=this.options.hideDelay+"ms",i.style.transitionDuration=this.options.hideSpeed+"ms",this.container.appendChild(a),o.el=a,o.selectionEl=r,o.caretEl=n,o.flagEl=i},n.prototype._shiftCursor=function(t,e,r){var n=this.cursors[t];n.range.index>e&&(n.range.index+=r)},n.prototype._hideCursor=function(t){var e=this.cursors[t];e&&e.el.classList.add("hidden")},n.prototype._updateCursor=function(t){if(t&&t.range){var e,r=this.quill.container.getBoundingClientRect(),n=this.quill.getLeaf(t.range.index),i=this.quill.getLeaf(t.range.index+t.range.length),a=document.createRange();if(!n||!i||!n[0]||!i[0]||n[1]<0||i[1]<0||!n[0].domNode||!i[0].domNode)return console.log("Troubles!",t),this._hideCursor(t.userId);a.setStart(n[0].domNode,n[1]),a.setEnd(i[0].domNode,i[1]),e=o.a.getClientRects(a),this._updateCaret(t,i),this._updateSelection(t,e,r)}},n.prototype._updateCaret=function(t,e){var r,n=t.range.index+t.range.length;n>0&&0===e[1]&&t.range.index!==t.range.index+t.range.length&&n--,r=this.quill.getBounds(n),t.caretEl.style.top=r.top+"px",t.caretEl.style.left=r.left+"px",t.caretEl.style.height=r.height+"px",t.flagEl.style.top=r.top+"px",t.flagEl.style.left=r.left+"px"},n.prototype._updateSelection=function(t,e,r){t.selectionEl.innerHTML=null;var n,i=[];[].forEach.call(e,function(e){n=""+e.top+e.left+e.width+e.height,!~i.indexOf(n)&&e.width>1&&(i.push(n),t.selectionEl.appendChild(function(e){var n=document.createElement("span");return n.classList.add("ql-cursor-selection-block"),n.style.top=e.top-r.top+"px",n.style.left=e.left-r.left+"px",n.style.width=e.width+"px",n.style.height=e.height+"px",n.style.backgroundColor=s()(t.color).setAlpha(.3).toString(),n}(e)))},this)},e.default=n},function(t,e,r){var n,i;/*! | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
if(typeof exports === 'object' && typeof module === 'object') | ||
module.exports = factory(); | ||
else if(typeof define === 'function' && define.amd) | ||
define([], factory); | ||
else if(typeof exports === 'object') | ||
exports["QuillCursors"] = factory(); | ||
else | ||
root["QuillCursors"] = factory(); | ||
})(typeof self !== 'undefined' ? self : this, function() { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) { | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.l = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 3); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_rangefix__ = __webpack_require__(1); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_rangefix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_rangefix__); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_tinycolor2__ = __webpack_require__(2); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_tinycolor2___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_tinycolor2__); | ||
var DEFAULTS = { | ||
template: [ | ||
'<span class="ql-cursor-selections"></span>', | ||
'<span class="ql-cursor-caret-container">', | ||
' <span class="ql-cursor-caret"></span>', | ||
'</span>', | ||
'<div class="ql-cursor-flag">', | ||
' <small class="ql-cursor-name"></small>', | ||
' <span class="ql-cursor-flag-flap"></span>', | ||
'</div>' | ||
].join(''), | ||
autoRegisterListener: true, | ||
hideDelay: 3000, | ||
hideSpeed: 400 | ||
}; | ||
function QuillCursors(quill, options) { | ||
this.quill = quill; | ||
this._initOptions(options); | ||
this.cursors = {}; | ||
this.container = this.quill.addContainer('ql-cursors'); | ||
if (this.options.autoRegisterListener) | ||
this.registerTextChangeListener(); | ||
window.addEventListener('resize', this.update.bind(this)); | ||
} | ||
QuillCursors.prototype.registerTextChangeListener = function() { | ||
this.quill.on(this.quill.constructor.events.TEXT_CHANGE, this._applyDelta.bind(this)); | ||
}; | ||
QuillCursors.prototype.clearCursors = function() { | ||
Object.keys(this.cursors).forEach(this.removeCursor.bind(this)); | ||
}; | ||
QuillCursors.prototype.moveCursor = function(userId, range) { | ||
var cursor = this.cursors[userId]; | ||
if (cursor) { | ||
cursor.range = range; | ||
cursor.el.classList.remove('hidden'); | ||
this._updateCursor(cursor); | ||
// TODO Implement cursor hiding timeout like 0.20/benbro? | ||
} | ||
}; | ||
QuillCursors.prototype.removeCursor = function(userId) { | ||
var cursor = this.cursors[userId]; | ||
if (cursor) | ||
cursor.el.parentNode.removeChild(cursor.el); | ||
delete this.cursors[userId]; | ||
}; | ||
QuillCursors.prototype.setCursor = function(userId, range, name, color) { | ||
// Init cursor if it doesn't exist | ||
if (!this.cursors[userId]) { | ||
this.cursors[userId] = { | ||
userId: userId, | ||
color: color, | ||
range: range, | ||
el: null, | ||
selectionEl: null, | ||
caretEl: null, | ||
flagEl: null | ||
}; | ||
// Build and init the remaining cursor elements | ||
this._buildCursor(userId, name); | ||
} | ||
// Move and update cursor | ||
window.setTimeout(function() { | ||
this.moveCursor(userId, range); | ||
}.bind(this)); | ||
return this.cursors[userId]; | ||
}; | ||
QuillCursors.prototype.shiftCursors = function(index, length) { | ||
var cursor; | ||
Object.keys(this.cursors).forEach(function(userId) { | ||
if ((cursor = this.cursors[userId]) && cursor.range) { | ||
// If characters we're added or there is no selection | ||
// advance start/end if it's greater or equal than index | ||
if (length > 0 || cursor.range.length == 0) | ||
this._shiftCursor(userId, index - 1, length); | ||
// Else if characters were removed | ||
// move start/end back if it's only greater than index | ||
else | ||
this._shiftCursor(userId, index, length); | ||
} | ||
}, this); | ||
}; | ||
QuillCursors.prototype.update = function() { | ||
Object.keys(this.cursors).map(function(key) { | ||
this._updateCursor(this.cursors[key]) | ||
}.bind(this)); | ||
}; | ||
QuillCursors.prototype._initOptions = function(options) { | ||
this.options = DEFAULTS; | ||
this.options.template = options.template || this.options.template; | ||
this.options.autoRegisterListener = (options.autoRegisterListener == false) ? options.autoRegisterListener : this.options.autoRegisterListener; | ||
this.options.hideDelay = (options.hideDelay == undefined) ? this.options.hideDelay : options.hideDelay; | ||
this.options.hideSpeed = (options.hideSpeed == undefined) ? this.options.hideSpeed : options.hideSpeed; | ||
}; | ||
QuillCursors.prototype._applyDelta = function(delta) { | ||
var index = 0; | ||
delta.ops.forEach(function(op) { | ||
var length = 0; | ||
if (op.insert) { | ||
length = op.insert.length || 1; | ||
this.shiftCursors(index, length); | ||
} else if (op.delete) { | ||
this.shiftCursors(index, -1 * op.delete); | ||
} else if (op.retain) { | ||
// Is this really needed? | ||
//this.shiftCursors(index, 0); | ||
length = op.retain | ||
} | ||
index += length; | ||
}, this); | ||
this.update(); | ||
}; | ||
QuillCursors.prototype._buildCursor = function(userId, name) { | ||
var cursor = this.cursors[userId]; | ||
var el = document.createElement('span'); | ||
var selectionEl; | ||
var caretEl; | ||
var flagEl; | ||
el.classList.add('ql-cursor'); | ||
el.innerHTML = this.options.template; | ||
selectionEl = el.querySelector('.ql-cursor-selections'); | ||
caretEl = el.querySelector('.ql-cursor-caret-container'); | ||
flagEl = el.querySelector('.ql-cursor-flag'); | ||
// Set color | ||
flagEl.style.backgroundColor = cursor.color; | ||
caretEl.querySelector('.ql-cursor-caret').style.backgroundColor = cursor.color; | ||
el.querySelector('.ql-cursor-name').innerText = name; | ||
// Set flag delay, speed | ||
flagEl.style.transitionDelay = this.options.hideDelay + 'ms'; | ||
flagEl.style.transitionDuration = this.options.hideSpeed + 'ms'; | ||
this.container.appendChild(el); | ||
// Set cursor elements | ||
cursor.el = el; | ||
cursor.selectionEl = selectionEl; | ||
cursor.caretEl = caretEl; | ||
cursor.flagEl = flagEl; | ||
}; | ||
QuillCursors.prototype._shiftCursor = function(userId, index, length) { | ||
var cursor = this.cursors[userId]; | ||
if (cursor.range.index > index) | ||
cursor.range.index += length; | ||
}; | ||
QuillCursors.prototype._hideCursor = function(userId) { | ||
var cursor = this.cursors[userId]; | ||
if (cursor) | ||
cursor.el.classList.add('hidden'); | ||
}; | ||
QuillCursors.prototype._updateCursor = function(cursor) { | ||
if (!cursor || !cursor.range) return; | ||
var startRange = cursor.range.index; | ||
var endRange = cursor.range.index + cursor.range.length; | ||
// Check ranges | ||
if(endRange > this.quill.getLength() - 1) | ||
endRange = this.quill.getLength() - 1; | ||
var containerRect = this.quill.container.getBoundingClientRect(); | ||
var startLeaf = this.quill.getLeaf(startRange); | ||
var endLeaf = this.quill.getLeaf(endRange); | ||
var range = document.createRange(); | ||
var rects; | ||
// Sanity check | ||
if (!startLeaf || !endLeaf || | ||
!startLeaf[0] || !endLeaf[0] || | ||
startLeaf[1] < 0 || endLeaf[1] < 0 || | ||
!startLeaf[0].domNode || !endLeaf[0].domNode) { | ||
console.warn('[quill-cursors] A cursor couldn\'t be updated (ID ' + cursor.userId +'), hiding.'); | ||
this._hideCursor(cursor.userId); | ||
return; | ||
} | ||
range.setStart(startLeaf[0].domNode, startLeaf[1]); | ||
range.setEnd(endLeaf[0].domNode, endLeaf[1]); | ||
rects = __WEBPACK_IMPORTED_MODULE_0_rangefix___default.a.getClientRects(range); | ||
this._updateCaret(cursor, endLeaf); | ||
this._updateSelection(cursor, rects, containerRect); | ||
}; | ||
QuillCursors.prototype._updateCaret = function(cursor, leaf) { | ||
var rect, index = cursor.range.index + cursor.range.length; | ||
// The only time a valid offset of 0 can occur is when the cursor is positioned | ||
// before the first character in a line, and it will be the case that the start | ||
// and end points of the range will be exactly the same... if they are not then | ||
// a block selection is taking place and we need to offset the character position | ||
// by -1; | ||
if (index > 0 && leaf[1] === 0 && cursor.range.index !== (cursor.range.index + cursor.range.length)) { | ||
index--; | ||
} | ||
rect = this.quill.getBounds(index); | ||
cursor.caretEl.style.top = (rect.top) + 'px'; | ||
cursor.caretEl.style.left = (rect.left) + 'px'; | ||
cursor.caretEl.style.height = rect.height + 'px'; | ||
cursor.flagEl.style.top = (rect.top) + 'px'; | ||
cursor.flagEl.style.left = (rect.left) + 'px'; | ||
}; | ||
QuillCursors.prototype._updateSelection = function(cursor, rects, containerRect) { | ||
function createSelectionBlock(rect) { | ||
var selectionBlockEl = document.createElement('span'); | ||
selectionBlockEl.classList.add('ql-cursor-selection-block'); | ||
selectionBlockEl.style.top = (rect.top - containerRect.top) + 'px'; | ||
selectionBlockEl.style.left = (rect.left - containerRect.left) + 'px'; | ||
selectionBlockEl.style.width = rect.width + 'px'; | ||
selectionBlockEl.style.height = rect.height + 'px'; | ||
selectionBlockEl.style.backgroundColor = __WEBPACK_IMPORTED_MODULE_1_tinycolor2___default()(cursor.color).setAlpha(0.3).toString(); | ||
return selectionBlockEl; | ||
} | ||
// Wipe the slate clean | ||
cursor.selectionEl.innerHTML = null; | ||
var index = []; | ||
var rectIndex; | ||
[].forEach.call(rects, function(rect) { | ||
rectIndex = ('' + rect.top + rect.left + rect.width + rect.height); | ||
// Note: Safari throws a rect with length 1 when caret with no selection. | ||
// A check was addedfor to avoid drawing those carets - they show up on blinking. | ||
if (!~index.indexOf(rectIndex) && rect.width > 1) { | ||
index.push(rectIndex); | ||
cursor.selectionEl.appendChild(createSelectionBlock(rect)); | ||
} | ||
}, this); | ||
}; | ||
/* harmony default export */ __webpack_exports__["default"] = (QuillCursors); | ||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! | ||
* RangeFix v0.2.5 | ||
@@ -8,2 +370,1485 @@ * https://github.com/edg2s/rangefix | ||
*/ | ||
!function(o,a){void 0!==(i="function"==typeof(n=a)?n.call(e,r,e,t):n)&&(t.exports=i)}(0,function(){function t(){var t,e,r,i,o,a,s,l;return void 0===n&&(e=document.createElement("p"),r=document.createElement("span"),i=document.createTextNode("aa"),o=document.createTextNode("aa"),(a=document.createElement("img")).setAttribute("src","#null"),s=document.createRange(),n={},e.appendChild(i),e.appendChild(r),r.appendChild(a),r.appendChild(o),document.body.appendChild(e),s.setStart(i,1),s.setEnd(r,0),n.getClientRects=n.getBoundingClientRect=s.getClientRects().length>1,n.getClientRects||(s.setEnd(o,1),n.getClientRects=n.getBoundingClientRect=s.getClientRects().length<3),n.getBoundingClientRect||(s.setEnd(s.startContainer,s.startOffset),t=s.getBoundingClientRect(),n.getBoundingClientRect=0===t.top&&0===t.left),document.body.removeChild(e),l=window.ActiveXObject&&new Function("/*@cc_on return @_jscript_version; @*/")(),n.ieZoom=l&&l<=10),n}function e(t){var r;return t?screen.deviceXDPI===screen.logicalXDPI?t:"length"in t?Array.prototype.map.call(t,e):(r=screen.deviceXDPI/screen.logicalXDPI,{top:t.top/r,bottom:t.bottom/r,left:t.left/r,right:t.right/r,width:t.width/r,height:t.height/r}):t}function r(t,e){var r,n=0;if(1024>=e.length)return Array.prototype.push.apply(t,e);for(;n<e.length;)r=Array.prototype.push.apply(t,Array.prototype.slice.call(e,n,n+1024)),n+=1024;return r}var n,i={};return i.getClientRects=function(n){var i,o,a,s,l=t();if(l.ieZoom)return e(n.getClientRects());if(!l.getClientRects)return n.getClientRects();for(i=[],o=n.endContainer,a=n.endOffset,s=document.createRange();o!==n.commonAncestorContainer;)s.setStart(o,0),s.setEnd(o,a),r(i,s.getClientRects()),a=Array.prototype.indexOf.call(o.parentNode.childNodes,o),o=o.parentNode;return(s=n.cloneRange()).setEnd(o,a),r(i,s.getClientRects()),i},i.getBoundingClientRect=function(r){var n,i,o,a,s,l,u=this.getClientRects(r);if(0===u.length)return null;if(s=r.getBoundingClientRect(),(l=t()).ieZoom)return e(s);if(!l.getBoundingClientRect)return s;if(0===s.width&&0===s.height)return u[0];for(n=0,i=u.length;n<i;n++)a=u[n],o?(o.left=Math.min(o.left,a.left),o.top=Math.min(o.top,a.top),o.right=Math.max(o.right,a.right),o.bottom=Math.max(o.bottom,a.bottom)):o={left:a.left,top:a.top,right:a.right,bottom:a.bottom};return o&&(o.width=o.right-o.left,o.height=o.bottom-o.top),o},i})},function(t,e,r){var n;!function(i){function o(t,e){if(t=t||"",e=e||{},t instanceof o)return t;if(!(this instanceof o))return new o(t,e);var r=function(t){var e={r:0,g:0,b:0},r=1,n=null,o=null,a=null,s=!1,l=!1;"string"==typeof t&&(t=function(t){t=t.replace(F,"").replace(O,"").toLowerCase();var e=!1;if(I[t])t=I[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};var r;if(r=B.rgb.exec(t))return{r:r[1],g:r[2],b:r[3]};if(r=B.rgba.exec(t))return{r:r[1],g:r[2],b:r[3],a:r[4]};if(r=B.hsl.exec(t))return{h:r[1],s:r[2],l:r[3]};if(r=B.hsla.exec(t))return{h:r[1],s:r[2],l:r[3],a:r[4]};if(r=B.hsv.exec(t))return{h:r[1],s:r[2],v:r[3]};if(r=B.hsva.exec(t))return{h:r[1],s:r[2],v:r[3],a:r[4]};if(r=B.hex8.exec(t))return{r:k(r[1]),g:k(r[2]),b:k(r[3]),a:H(r[4]),format:e?"name":"hex8"};if(r=B.hex6.exec(t))return{r:k(r[1]),g:k(r[2]),b:k(r[3]),format:e?"name":"hex"};if(r=B.hex4.exec(t))return{r:k(r[1]+""+r[1]),g:k(r[2]+""+r[2]),b:k(r[3]+""+r[3]),a:H(r[4]+""+r[4]),format:e?"name":"hex8"};if(r=B.hex3.exec(t))return{r:k(r[1]+""+r[1]),g:k(r[2]+""+r[2]),b:k(r[3]+""+r[3]),format:e?"name":"hex"};return!1}(t));"object"==typeof t&&(L(t.r)&&L(t.g)&&L(t.b)?(e=function(t,e,r){return{r:255*R(t,255),g:255*R(e,255),b:255*R(r,255)}}(t.r,t.g,t.b),s=!0,l="%"===String(t.r).substr(-1)?"prgb":"rgb"):L(t.h)&&L(t.s)&&L(t.v)?(n=E(t.s),o=E(t.v),e=function(t,e,r){t=6*R(t,360),e=R(e,100),r=R(r,100);var n=i.floor(t),o=t-n,a=r*(1-e),s=r*(1-o*e),l=r*(1-(1-o)*e),u=n%6;return{r:255*[r,s,a,a,l,r][u],g:255*[l,r,r,s,a,a][u],b:255*[a,a,l,r,r,s][u]}}(t.h,n,o),s=!0,l="hsv"):L(t.h)&&L(t.s)&&L(t.l)&&(n=E(t.s),a=E(t.l),e=function(t,e,r){function n(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}var i,o,a;t=R(t,360),e=R(e,100),r=R(r,100);if(0===e)i=o=a=r;else{var s=r<.5?r*(1+e):r+e-r*e,l=2*r-s;i=n(l,s,t+1/3),o=n(l,s,t),a=n(l,s,t-1/3)}return{r:255*i,g:255*o,b:255*a}}(t.h,n,a),s=!0,l="hsl"),t.hasOwnProperty("a")&&(r=t.a));return r=A(r),{ok:s,format:t.format||l,r:M(255,T(e.r,0)),g:M(255,T(e.g,0)),b:M(255,T(e.b,0)),a:r}}(t);this._originalInput=t,this._r=r.r,this._g=r.g,this._b=r.b,this._a=r.a,this._roundA=j(100*this._a)/100,this._format=e.format||r.format,this._gradientType=e.gradientType,this._r<1&&(this._r=j(this._r)),this._g<1&&(this._g=j(this._g)),this._b<1&&(this._b=j(this._b)),this._ok=r.ok,this._tc_id=N++}function a(t,e,r){t=R(t,255),e=R(e,255),r=R(r,255);var n,i,o=T(t,e,r),a=M(t,e,r),s=(o+a)/2;if(o==a)n=i=0;else{var l=o-a;switch(i=s>.5?l/(2-o-a):l/(o+a),o){case t:n=(e-r)/l+(e<r?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return{h:n,s:i,l:s}}function s(t,e,r){t=R(t,255),e=R(e,255),r=R(r,255);var n,i,o=T(t,e,r),a=M(t,e,r),s=o-a;if(i=0===o?0:s/o,o==a)n=0;else{switch(o){case t:n=(e-r)/s+(e<r?6:0);break;case e:n=(r-t)/s+2;break;case r:n=(t-e)/s+4}n/=6}return{h:n,s:i,v:o}}function l(t,e,r,n){var i=[S(j(t).toString(16)),S(j(e).toString(16)),S(j(r).toString(16))];return n&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}function u(t,e,r,n){return[S(q(n)),S(j(t).toString(16)),S(j(e).toString(16)),S(j(r).toString(16))].join("")}function c(t,e){e=0===e?0:e||10;var r=o(t).toHsl();return r.s-=e/100,r.s=w(r.s),o(r)}function f(t,e){e=0===e?0:e||10;var r=o(t).toHsl();return r.s+=e/100,r.s=w(r.s),o(r)}function h(t){return o(t).desaturate(100)}function d(t,e){e=0===e?0:e||10;var r=o(t).toHsl();return r.l+=e/100,r.l=w(r.l),o(r)}function g(t,e){e=0===e?0:e||10;var r=o(t).toRgb();return r.r=T(0,M(255,r.r-j(-e/100*255))),r.g=T(0,M(255,r.g-j(-e/100*255))),r.b=T(0,M(255,r.b-j(-e/100*255))),o(r)}function p(t,e){e=0===e?0:e||10;var r=o(t).toHsl();return r.l-=e/100,r.l=w(r.l),o(r)}function b(t,e){var r=o(t).toHsl(),n=(r.h+e)%360;return r.h=n<0?360+n:n,o(r)}function m(t){var e=o(t).toHsl();return e.h=(e.h+180)%360,o(e)}function _(t){var e=o(t).toHsl(),r=e.h;return[o(t),o({h:(r+120)%360,s:e.s,l:e.l}),o({h:(r+240)%360,s:e.s,l:e.l})]}function v(t){var e=o(t).toHsl(),r=e.h;return[o(t),o({h:(r+90)%360,s:e.s,l:e.l}),o({h:(r+180)%360,s:e.s,l:e.l}),o({h:(r+270)%360,s:e.s,l:e.l})]}function y(t){var e=o(t).toHsl(),r=e.h;return[o(t),o({h:(r+72)%360,s:e.s,l:e.l}),o({h:(r+216)%360,s:e.s,l:e.l})]}function x(t,e,r){e=e||6,r=r||30;var n=o(t).toHsl(),i=360/r,a=[o(t)];for(n.h=(n.h-(i*e>>1)+720)%360;--e;)n.h=(n.h+i)%360,a.push(o(n));return a}function C(t,e){e=e||6;for(var r=o(t).toHsv(),n=r.h,i=r.s,a=r.v,s=[],l=1/e;e--;)s.push(o({h:n,s:i,v:a})),a=(a+l)%1;return s}function A(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function R(t,e){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(t)&&(t="100%");var r=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(t);return t=M(e,T(0,parseFloat(t))),r&&(t=parseInt(t*e,10)/100),i.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function w(t){return M(1,T(0,t))}function k(t){return parseInt(t,16)}function S(t){return 1==t.length?"0"+t:""+t}function E(t){return t<=1&&(t=100*t+"%"),t}function q(t){return i.round(255*parseFloat(t)).toString(16)}function H(t){return k(t)/255}function L(t){return!!B.CSS_UNIT.exec(t)}var F=/^\s+/,O=/\s+$/,N=0,j=i.round,M=i.min,T=i.max,D=i.random;o.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,e,r,n,o,a,s=this.toRgb();return t=s.r/255,e=s.g/255,r=s.b/255,n=t<=.03928?t/12.92:i.pow((t+.055)/1.055,2.4),o=e<=.03928?e/12.92:i.pow((e+.055)/1.055,2.4),a=r<=.03928?r/12.92:i.pow((r+.055)/1.055,2.4),.2126*n+.7152*o+.0722*a},setAlpha:function(t){return this._a=A(t),this._roundA=j(100*this._a)/100,this},toHsv:function(){var t=s(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=s(this._r,this._g,this._b),e=j(360*t.h),r=j(100*t.s),n=j(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=a(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=a(this._r,this._g,this._b),e=j(360*t.h),r=j(100*t.s),n=j(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return l(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,r,n,i){var o=[S(j(t).toString(16)),S(j(e).toString(16)),S(j(r).toString(16)),S(q(n))];return i&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1)?o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0):o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:j(this._r),g:j(this._g),b:j(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+j(this._r)+", "+j(this._g)+", "+j(this._b)+")":"rgba("+j(this._r)+", "+j(this._g)+", "+j(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:j(100*R(this._r,255))+"%",g:j(100*R(this._g,255))+"%",b:j(100*R(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+j(100*R(this._r,255))+"%, "+j(100*R(this._g,255))+"%, "+j(100*R(this._b,255))+"%)":"rgba("+j(100*R(this._r,255))+"%, "+j(100*R(this._g,255))+"%, "+j(100*R(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(P[l(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+u(this._r,this._g,this._b,this._a),r=e,n=this._gradientType?"GradientType = 1, ":"";if(t){var i=o(t);r="#"+u(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0;return e||!n||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex4"===t&&(r=this.toHex8String(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return o(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(d,arguments)},brighten:function(){return this._applyModification(g,arguments)},darken:function(){return this._applyModification(p,arguments)},desaturate:function(){return this._applyModification(c,arguments)},saturate:function(){return this._applyModification(f,arguments)},greyscale:function(){return this._applyModification(h,arguments)},spin:function(){return this._applyModification(b,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(x,arguments)},complement:function(){return this._applyCombination(m,arguments)},monochromatic:function(){return this._applyCombination(C,arguments)},splitcomplement:function(){return this._applyCombination(y,arguments)},triad:function(){return this._applyCombination(_,arguments)},tetrad:function(){return this._applyCombination(v,arguments)}},o.fromRatio=function(t,e){if("object"==typeof t){var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]="a"===n?t[n]:E(t[n]));t=r}return o(t,e)},o.equals=function(t,e){return!(!t||!e)&&o(t).toRgbString()==o(e).toRgbString()},o.random=function(){return o.fromRatio({r:D(),g:D(),b:D()})},o.mix=function(t,e,r){r=0===r?0:r||50;var n=o(t).toRgb(),i=o(e).toRgb(),a=r/100;return o({r:(i.r-n.r)*a+n.r,g:(i.g-n.g)*a+n.g,b:(i.b-n.b)*a+n.b,a:(i.a-n.a)*a+n.a})},o.readability=function(t,e){var r=o(t),n=o(e);return(i.max(r.getLuminance(),n.getLuminance())+.05)/(i.min(r.getLuminance(),n.getLuminance())+.05)},o.isReadable=function(t,e,r){var n,i,a=o.readability(t,e);switch(i=!1,(n=function(t){var e,r;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA"),"small"!==r&&"large"!==r&&(r="small"),{level:e,size:r}}(r)).level+n.size){case"AAsmall":case"AAAlarge":i=a>=4.5;break;case"AAlarge":i=a>=3;break;case"AAAsmall":i=a>=7}return i},o.mostReadable=function(t,e,r){var n,i,a,s,l=null,u=0;i=(r=r||{}).includeFallbackColors,a=r.level,s=r.size;for(var c=0;c<e.length;c++)(n=o.readability(t,e[c]))>u&&(u=n,l=o(e[c]));return o.isReadable(t,l,{level:a,size:s})||!i?l:(r.includeFallbackColors=!1,o.mostReadable(t,["#fff","#000"],r))};var I=o.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},P=o.hexNames=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}(I),B=function(){var t="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)",e="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",r="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?";return{CSS_UNIT:new RegExp(t),rgb:new RegExp("rgb"+e),rgba:new RegExp("rgba"+r),hsl:new RegExp("hsl"+e),hsla:new RegExp("hsla"+r),hsv:new RegExp("hsv"+e),hsva:new RegExp("hsva"+r),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();void 0!==t&&t.exports?t.exports=o:void 0!==(n=function(){return o}.call(e,r,e,t))&&(t.exports=n)}(Math)},function(t,e,r){r(0),t.exports=r(4)},function(t,e){}]).default}); | ||
( function ( root, factory ) { | ||
if ( true ) { | ||
// AMD. Register as an anonymous module. | ||
!(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory), | ||
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? | ||
(__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : | ||
__WEBPACK_AMD_DEFINE_FACTORY__), | ||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
} else if ( typeof exports === 'object' && typeof exports.nodeName !== 'string' ) { | ||
// CommonJS | ||
module.exports = factory(); | ||
} else { | ||
// Browser globals | ||
root.RangeFix = factory(); | ||
} | ||
}( this, function () { | ||
var broken, | ||
rangeFix = {}; | ||
/** | ||
* Check if bugs are present in the native functions | ||
* | ||
* For getClientRects, constructs two lines of text and | ||
* creates a range between them. Broken browsers will | ||
* return three rectangles instead of two. | ||
* | ||
* For getBoundingClientRect, create a collapsed range | ||
* and check if the resulting rect has non-zero offsets. | ||
* | ||
* getBoundingClientRect is also considered broken if | ||
* getClientRects is broken. | ||
* | ||
* For the IE zoom bug, just check the version number as | ||
* we can't detect the bug if the zoom level is currently 100%. | ||
* | ||
* @private | ||
* @return {Object} Object containing boolean properties 'getClientRects', | ||
* 'getBoundingClientRect' and 'ieZoom' indicating bugs are present | ||
* in these functions/browsers. | ||
*/ | ||
function isBroken() { | ||
var boundingRect, p, span, t1, t2, img, range, jscriptVersion; | ||
if ( broken === undefined ) { | ||
p = document.createElement( 'p' ); | ||
span = document.createElement( 'span' ); | ||
t1 = document.createTextNode( 'aa' ); | ||
t2 = document.createTextNode( 'aa' ); | ||
img = document.createElement( 'img' ); | ||
img.setAttribute( 'src', '#null' ); | ||
range = document.createRange(); | ||
broken = {}; | ||
p.appendChild( t1 ); | ||
p.appendChild( span ); | ||
span.appendChild( img ); | ||
span.appendChild( t2 ); | ||
document.body.appendChild( p ); | ||
range.setStart( t1, 1 ); | ||
range.setEnd( span, 0 ); | ||
// A selection ending just inside another element shouldn't select that whole element | ||
// Broken in Chrome <= 55 and Firefox | ||
broken.getClientRects = broken.getBoundingClientRect = range.getClientRects().length > 1; | ||
if ( !broken.getClientRects ) { | ||
// A selection across a wrapped image should give a rect for that image | ||
// Regression in Chrome 55 | ||
range.setEnd( t2, 1 ); | ||
broken.getClientRects = broken.getBoundingClientRect = range.getClientRects().length < 3; | ||
} | ||
if ( !broken.getBoundingClientRect ) { | ||
// Safari doesn't return a valid bounding rect for collapsed ranges | ||
// Equivalent to range.collapse( true ) which isn't well supported | ||
range.setEnd( range.startContainer, range.startOffset ); | ||
boundingRect = range.getBoundingClientRect(); | ||
broken.getBoundingClientRect = boundingRect.top === 0 && boundingRect.left === 0; | ||
} | ||
document.body.removeChild( p ); | ||
// Detect IE<=10 where zooming scaling is broken | ||
// eslint-disable-next-line no-new-func | ||
jscriptVersion = window.ActiveXObject && new Function( '/*@cc_on return @_jscript_version; @*/' )(); | ||
broken.ieZoom = jscriptVersion && jscriptVersion <= 10; | ||
} | ||
return broken; | ||
} | ||
/** | ||
* Compensate for the current zoom level in IE<=10 | ||
* | ||
* getClientRects returns values in real pixels in these browsers, | ||
* so using them in your CSS will result in them getting scaled again. | ||
* | ||
* @private | ||
* @param {ClientRectList|ClientRect[]|ClientRect|Object|null} rectOrRects Rect or list of rects to fix | ||
* @return {ClientRectList|ClientRect[]|ClientRect|Object|null} Fixed rect or list of rects | ||
*/ | ||
function zoomFix( rectOrRects ) { | ||
var zoom; | ||
if ( !rectOrRects ) { | ||
return rectOrRects; | ||
} | ||
// Optimisation when zoom level is 1: return original object | ||
if ( screen.deviceXDPI === screen.logicalXDPI ) { | ||
return rectOrRects; | ||
} | ||
// Rect list: map this function to each rect | ||
if ( 'length' in rectOrRects ) { | ||
return Array.prototype.map.call( rectOrRects, zoomFix ); | ||
} | ||
// Single rect: Adjust by zoom factor | ||
zoom = screen.deviceXDPI / screen.logicalXDPI; | ||
return { | ||
top: rectOrRects.top / zoom, | ||
bottom: rectOrRects.bottom / zoom, | ||
left: rectOrRects.left / zoom, | ||
right: rectOrRects.right / zoom, | ||
width: rectOrRects.width / zoom, | ||
height: rectOrRects.height / zoom | ||
}; | ||
} | ||
/** | ||
* Push one array-like object onto another. | ||
* | ||
* @param {Object} arr Array or array-like object. Will be modified | ||
* @param {Object} data Array-like object of items to insert. | ||
* @return {number} length of the new array | ||
*/ | ||
function batchPush( arr, data ) { | ||
// We need to push insertion in batches, because of parameter list length limits which vary | ||
// cross-browser - 1024 seems to be a safe batch size on all browsers | ||
var length, | ||
index = 0, | ||
batchSize = 1024; | ||
if ( batchSize >= data.length ) { | ||
// Avoid slicing for small lists | ||
return Array.prototype.push.apply( arr, data ); | ||
} | ||
while ( index < data.length ) { | ||
// Call arr.push( i0, i1, i2, ..., i1023 ); | ||
length = Array.prototype.push.apply( | ||
arr, Array.prototype.slice.call( data, index, index + batchSize ) | ||
); | ||
index += batchSize; | ||
} | ||
return length; | ||
} | ||
/** | ||
* Get client rectangles from a range | ||
* | ||
* @param {Range} range Range | ||
* @return {ClientRectList|ClientRect[]} ClientRectList or list of ClientRect objects describing range | ||
*/ | ||
rangeFix.getClientRects = function ( range ) { | ||
var rects, endContainer, endOffset, partialRange, | ||
broken = isBroken(); | ||
if ( broken.ieZoom ) { | ||
return zoomFix( range.getClientRects() ); | ||
} else if ( !broken.getClientRects ) { | ||
return range.getClientRects(); | ||
} | ||
// Chrome gets the end container rects wrong when spanning | ||
// nodes so we need to traverse up the tree from the endContainer until | ||
// we reach the common ancestor, then we can add on from start to where | ||
// we got up to | ||
// https://code.google.com/p/chromium/issues/detail?id=324437 | ||
rects = []; | ||
endContainer = range.endContainer; | ||
endOffset = range.endOffset; | ||
partialRange = document.createRange(); | ||
while ( endContainer !== range.commonAncestorContainer ) { | ||
partialRange.setStart( endContainer, 0 ); | ||
partialRange.setEnd( endContainer, endOffset ); | ||
batchPush( rects, partialRange.getClientRects() ); | ||
endOffset = Array.prototype.indexOf.call( endContainer.parentNode.childNodes, endContainer ); | ||
endContainer = endContainer.parentNode; | ||
} | ||
// Once we've reached the common ancestor, add on the range from the | ||
// original start position to where we ended up. | ||
partialRange = range.cloneRange(); | ||
partialRange.setEnd( endContainer, endOffset ); | ||
batchPush( rects, partialRange.getClientRects() ); | ||
return rects; | ||
}; | ||
/** | ||
* Get bounding rectangle from a range | ||
* | ||
* @param {Range} range Range | ||
* @return {ClientRect|Object|null} ClientRect or ClientRect-like object describing | ||
* bounding rectangle, or null if not computable | ||
*/ | ||
rangeFix.getBoundingClientRect = function ( range ) { | ||
var i, l, boundingRect, rect, nativeBoundingRect, broken, | ||
rects = this.getClientRects( range ); | ||
// If there are no rects return null, otherwise we'll fall through to | ||
// getBoundingClientRect, which in Chrome and Firefox becomes [0,0,0,0]. | ||
if ( rects.length === 0 ) { | ||
return null; | ||
} | ||
nativeBoundingRect = range.getBoundingClientRect(); | ||
broken = isBroken(); | ||
if ( broken.ieZoom ) { | ||
return zoomFix( nativeBoundingRect ); | ||
} else if ( !broken.getBoundingClientRect ) { | ||
return nativeBoundingRect; | ||
} | ||
// When nativeRange is a collapsed cursor at the end of a line or | ||
// the start of a line, the bounding rect is [0,0,0,0] in Chrome. | ||
// getClientRects returns two rects, one correct, and one at the | ||
// end of the next line / start of the previous line. We can't tell | ||
// here which one to use so just pick the first. This matches | ||
// Firefox's behaviour, which tells you the cursor is at the end | ||
// of the previous line when it is at the start of the line. | ||
// See https://code.google.com/p/chromium/issues/detail?id=426017 | ||
if ( nativeBoundingRect.width === 0 && nativeBoundingRect.height === 0 ) { | ||
return rects[ 0 ]; | ||
} | ||
for ( i = 0, l = rects.length; i < l; i++ ) { | ||
rect = rects[ i ]; | ||
if ( !boundingRect ) { | ||
boundingRect = { | ||
left: rect.left, | ||
top: rect.top, | ||
right: rect.right, | ||
bottom: rect.bottom | ||
}; | ||
} else { | ||
boundingRect.left = Math.min( boundingRect.left, rect.left ); | ||
boundingRect.top = Math.min( boundingRect.top, rect.top ); | ||
boundingRect.right = Math.max( boundingRect.right, rect.right ); | ||
boundingRect.bottom = Math.max( boundingRect.bottom, rect.bottom ); | ||
} | ||
} | ||
if ( boundingRect ) { | ||
boundingRect.width = boundingRect.right - boundingRect.left; | ||
boundingRect.height = boundingRect.bottom - boundingRect.top; | ||
} | ||
return boundingRect; | ||
}; | ||
return rangeFix; | ||
} ) ); | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var __WEBPACK_AMD_DEFINE_RESULT__;// TinyColor v1.4.1 | ||
// https://github.com/bgrins/TinyColor | ||
// Brian Grinstead, MIT License | ||
(function(Math) { | ||
var trimLeft = /^\s+/, | ||
trimRight = /\s+$/, | ||
tinyCounter = 0, | ||
mathRound = Math.round, | ||
mathMin = Math.min, | ||
mathMax = Math.max, | ||
mathRandom = Math.random; | ||
function tinycolor (color, opts) { | ||
color = (color) ? color : ''; | ||
opts = opts || { }; | ||
// If input is already a tinycolor, return itself | ||
if (color instanceof tinycolor) { | ||
return color; | ||
} | ||
// If we are called as a function, call using new instead | ||
if (!(this instanceof tinycolor)) { | ||
return new tinycolor(color, opts); | ||
} | ||
var rgb = inputToRGB(color); | ||
this._originalInput = color, | ||
this._r = rgb.r, | ||
this._g = rgb.g, | ||
this._b = rgb.b, | ||
this._a = rgb.a, | ||
this._roundA = mathRound(100*this._a) / 100, | ||
this._format = opts.format || rgb.format; | ||
this._gradientType = opts.gradientType; | ||
// Don't let the range of [0,255] come back in [0,1]. | ||
// Potentially lose a little bit of precision here, but will fix issues where | ||
// .5 gets interpreted as half of the total, instead of half of 1 | ||
// If it was supposed to be 128, this was already taken care of by `inputToRgb` | ||
if (this._r < 1) { this._r = mathRound(this._r); } | ||
if (this._g < 1) { this._g = mathRound(this._g); } | ||
if (this._b < 1) { this._b = mathRound(this._b); } | ||
this._ok = rgb.ok; | ||
this._tc_id = tinyCounter++; | ||
} | ||
tinycolor.prototype = { | ||
isDark: function() { | ||
return this.getBrightness() < 128; | ||
}, | ||
isLight: function() { | ||
return !this.isDark(); | ||
}, | ||
isValid: function() { | ||
return this._ok; | ||
}, | ||
getOriginalInput: function() { | ||
return this._originalInput; | ||
}, | ||
getFormat: function() { | ||
return this._format; | ||
}, | ||
getAlpha: function() { | ||
return this._a; | ||
}, | ||
getBrightness: function() { | ||
//http://www.w3.org/TR/AERT#color-contrast | ||
var rgb = this.toRgb(); | ||
return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000; | ||
}, | ||
getLuminance: function() { | ||
//http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef | ||
var rgb = this.toRgb(); | ||
var RsRGB, GsRGB, BsRGB, R, G, B; | ||
RsRGB = rgb.r/255; | ||
GsRGB = rgb.g/255; | ||
BsRGB = rgb.b/255; | ||
if (RsRGB <= 0.03928) {R = RsRGB / 12.92;} else {R = Math.pow(((RsRGB + 0.055) / 1.055), 2.4);} | ||
if (GsRGB <= 0.03928) {G = GsRGB / 12.92;} else {G = Math.pow(((GsRGB + 0.055) / 1.055), 2.4);} | ||
if (BsRGB <= 0.03928) {B = BsRGB / 12.92;} else {B = Math.pow(((BsRGB + 0.055) / 1.055), 2.4);} | ||
return (0.2126 * R) + (0.7152 * G) + (0.0722 * B); | ||
}, | ||
setAlpha: function(value) { | ||
this._a = boundAlpha(value); | ||
this._roundA = mathRound(100*this._a) / 100; | ||
return this; | ||
}, | ||
toHsv: function() { | ||
var hsv = rgbToHsv(this._r, this._g, this._b); | ||
return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a }; | ||
}, | ||
toHsvString: function() { | ||
var hsv = rgbToHsv(this._r, this._g, this._b); | ||
var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), v = mathRound(hsv.v * 100); | ||
return (this._a == 1) ? | ||
"hsv(" + h + ", " + s + "%, " + v + "%)" : | ||
"hsva(" + h + ", " + s + "%, " + v + "%, "+ this._roundA + ")"; | ||
}, | ||
toHsl: function() { | ||
var hsl = rgbToHsl(this._r, this._g, this._b); | ||
return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a }; | ||
}, | ||
toHslString: function() { | ||
var hsl = rgbToHsl(this._r, this._g, this._b); | ||
var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), l = mathRound(hsl.l * 100); | ||
return (this._a == 1) ? | ||
"hsl(" + h + ", " + s + "%, " + l + "%)" : | ||
"hsla(" + h + ", " + s + "%, " + l + "%, "+ this._roundA + ")"; | ||
}, | ||
toHex: function(allow3Char) { | ||
return rgbToHex(this._r, this._g, this._b, allow3Char); | ||
}, | ||
toHexString: function(allow3Char) { | ||
return '#' + this.toHex(allow3Char); | ||
}, | ||
toHex8: function(allow4Char) { | ||
return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char); | ||
}, | ||
toHex8String: function(allow4Char) { | ||
return '#' + this.toHex8(allow4Char); | ||
}, | ||
toRgb: function() { | ||
return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a }; | ||
}, | ||
toRgbString: function() { | ||
return (this._a == 1) ? | ||
"rgb(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ")" : | ||
"rgba(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ", " + this._roundA + ")"; | ||
}, | ||
toPercentageRgb: function() { | ||
return { r: mathRound(bound01(this._r, 255) * 100) + "%", g: mathRound(bound01(this._g, 255) * 100) + "%", b: mathRound(bound01(this._b, 255) * 100) + "%", a: this._a }; | ||
}, | ||
toPercentageRgbString: function() { | ||
return (this._a == 1) ? | ||
"rgb(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%)" : | ||
"rgba(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")"; | ||
}, | ||
toName: function() { | ||
if (this._a === 0) { | ||
return "transparent"; | ||
} | ||
if (this._a < 1) { | ||
return false; | ||
} | ||
return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false; | ||
}, | ||
toFilter: function(secondColor) { | ||
var hex8String = '#' + rgbaToArgbHex(this._r, this._g, this._b, this._a); | ||
var secondHex8String = hex8String; | ||
var gradientType = this._gradientType ? "GradientType = 1, " : ""; | ||
if (secondColor) { | ||
var s = tinycolor(secondColor); | ||
secondHex8String = '#' + rgbaToArgbHex(s._r, s._g, s._b, s._a); | ||
} | ||
return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")"; | ||
}, | ||
toString: function(format) { | ||
var formatSet = !!format; | ||
format = format || this._format; | ||
var formattedString = false; | ||
var hasAlpha = this._a < 1 && this._a >= 0; | ||
var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name"); | ||
if (needsAlphaFormat) { | ||
// Special case for "transparent", all other non-alpha formats | ||
// will return rgba when there is transparency. | ||
if (format === "name" && this._a === 0) { | ||
return this.toName(); | ||
} | ||
return this.toRgbString(); | ||
} | ||
if (format === "rgb") { | ||
formattedString = this.toRgbString(); | ||
} | ||
if (format === "prgb") { | ||
formattedString = this.toPercentageRgbString(); | ||
} | ||
if (format === "hex" || format === "hex6") { | ||
formattedString = this.toHexString(); | ||
} | ||
if (format === "hex3") { | ||
formattedString = this.toHexString(true); | ||
} | ||
if (format === "hex4") { | ||
formattedString = this.toHex8String(true); | ||
} | ||
if (format === "hex8") { | ||
formattedString = this.toHex8String(); | ||
} | ||
if (format === "name") { | ||
formattedString = this.toName(); | ||
} | ||
if (format === "hsl") { | ||
formattedString = this.toHslString(); | ||
} | ||
if (format === "hsv") { | ||
formattedString = this.toHsvString(); | ||
} | ||
return formattedString || this.toHexString(); | ||
}, | ||
clone: function() { | ||
return tinycolor(this.toString()); | ||
}, | ||
_applyModification: function(fn, args) { | ||
var color = fn.apply(null, [this].concat([].slice.call(args))); | ||
this._r = color._r; | ||
this._g = color._g; | ||
this._b = color._b; | ||
this.setAlpha(color._a); | ||
return this; | ||
}, | ||
lighten: function() { | ||
return this._applyModification(lighten, arguments); | ||
}, | ||
brighten: function() { | ||
return this._applyModification(brighten, arguments); | ||
}, | ||
darken: function() { | ||
return this._applyModification(darken, arguments); | ||
}, | ||
desaturate: function() { | ||
return this._applyModification(desaturate, arguments); | ||
}, | ||
saturate: function() { | ||
return this._applyModification(saturate, arguments); | ||
}, | ||
greyscale: function() { | ||
return this._applyModification(greyscale, arguments); | ||
}, | ||
spin: function() { | ||
return this._applyModification(spin, arguments); | ||
}, | ||
_applyCombination: function(fn, args) { | ||
return fn.apply(null, [this].concat([].slice.call(args))); | ||
}, | ||
analogous: function() { | ||
return this._applyCombination(analogous, arguments); | ||
}, | ||
complement: function() { | ||
return this._applyCombination(complement, arguments); | ||
}, | ||
monochromatic: function() { | ||
return this._applyCombination(monochromatic, arguments); | ||
}, | ||
splitcomplement: function() { | ||
return this._applyCombination(splitcomplement, arguments); | ||
}, | ||
triad: function() { | ||
return this._applyCombination(triad, arguments); | ||
}, | ||
tetrad: function() { | ||
return this._applyCombination(tetrad, arguments); | ||
} | ||
}; | ||
// If input is an object, force 1 into "1.0" to handle ratios properly | ||
// String input requires "1.0" as input, so 1 will be treated as 1 | ||
tinycolor.fromRatio = function(color, opts) { | ||
if (typeof color == "object") { | ||
var newColor = {}; | ||
for (var i in color) { | ||
if (color.hasOwnProperty(i)) { | ||
if (i === "a") { | ||
newColor[i] = color[i]; | ||
} | ||
else { | ||
newColor[i] = convertToPercentage(color[i]); | ||
} | ||
} | ||
} | ||
color = newColor; | ||
} | ||
return tinycolor(color, opts); | ||
}; | ||
// Given a string or object, convert that input to RGB | ||
// Possible string inputs: | ||
// | ||
// "red" | ||
// "#f00" or "f00" | ||
// "#ff0000" or "ff0000" | ||
// "#ff000000" or "ff000000" | ||
// "rgb 255 0 0" or "rgb (255, 0, 0)" | ||
// "rgb 1.0 0 0" or "rgb (1, 0, 0)" | ||
// "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1" | ||
// "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1" | ||
// "hsl(0, 100%, 50%)" or "hsl 0 100% 50%" | ||
// "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1" | ||
// "hsv(0, 100%, 100%)" or "hsv 0 100% 100%" | ||
// | ||
function inputToRGB(color) { | ||
var rgb = { r: 0, g: 0, b: 0 }; | ||
var a = 1; | ||
var s = null; | ||
var v = null; | ||
var l = null; | ||
var ok = false; | ||
var format = false; | ||
if (typeof color == "string") { | ||
color = stringInputToObject(color); | ||
} | ||
if (typeof color == "object") { | ||
if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) { | ||
rgb = rgbToRgb(color.r, color.g, color.b); | ||
ok = true; | ||
format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb"; | ||
} | ||
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) { | ||
s = convertToPercentage(color.s); | ||
v = convertToPercentage(color.v); | ||
rgb = hsvToRgb(color.h, s, v); | ||
ok = true; | ||
format = "hsv"; | ||
} | ||
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) { | ||
s = convertToPercentage(color.s); | ||
l = convertToPercentage(color.l); | ||
rgb = hslToRgb(color.h, s, l); | ||
ok = true; | ||
format = "hsl"; | ||
} | ||
if (color.hasOwnProperty("a")) { | ||
a = color.a; | ||
} | ||
} | ||
a = boundAlpha(a); | ||
return { | ||
ok: ok, | ||
format: color.format || format, | ||
r: mathMin(255, mathMax(rgb.r, 0)), | ||
g: mathMin(255, mathMax(rgb.g, 0)), | ||
b: mathMin(255, mathMax(rgb.b, 0)), | ||
a: a | ||
}; | ||
} | ||
// Conversion Functions | ||
// -------------------- | ||
// `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from: | ||
// <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript> | ||
// `rgbToRgb` | ||
// Handle bounds / percentage checking to conform to CSS color spec | ||
// <http://www.w3.org/TR/css3-color/> | ||
// *Assumes:* r, g, b in [0, 255] or [0, 1] | ||
// *Returns:* { r, g, b } in [0, 255] | ||
function rgbToRgb(r, g, b){ | ||
return { | ||
r: bound01(r, 255) * 255, | ||
g: bound01(g, 255) * 255, | ||
b: bound01(b, 255) * 255 | ||
}; | ||
} | ||
// `rgbToHsl` | ||
// Converts an RGB color value to HSL. | ||
// *Assumes:* r, g, and b are contained in [0, 255] or [0, 1] | ||
// *Returns:* { h, s, l } in [0,1] | ||
function rgbToHsl(r, g, b) { | ||
r = bound01(r, 255); | ||
g = bound01(g, 255); | ||
b = bound01(b, 255); | ||
var max = mathMax(r, g, b), min = mathMin(r, g, b); | ||
var h, s, l = (max + min) / 2; | ||
if(max == min) { | ||
h = s = 0; // achromatic | ||
} | ||
else { | ||
var d = max - min; | ||
s = l > 0.5 ? d / (2 - max - min) : d / (max + min); | ||
switch(max) { | ||
case r: h = (g - b) / d + (g < b ? 6 : 0); break; | ||
case g: h = (b - r) / d + 2; break; | ||
case b: h = (r - g) / d + 4; break; | ||
} | ||
h /= 6; | ||
} | ||
return { h: h, s: s, l: l }; | ||
} | ||
// `hslToRgb` | ||
// Converts an HSL color value to RGB. | ||
// *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100] | ||
// *Returns:* { r, g, b } in the set [0, 255] | ||
function hslToRgb(h, s, l) { | ||
var r, g, b; | ||
h = bound01(h, 360); | ||
s = bound01(s, 100); | ||
l = bound01(l, 100); | ||
function hue2rgb(p, q, t) { | ||
if(t < 0) t += 1; | ||
if(t > 1) t -= 1; | ||
if(t < 1/6) return p + (q - p) * 6 * t; | ||
if(t < 1/2) return q; | ||
if(t < 2/3) return p + (q - p) * (2/3 - t) * 6; | ||
return p; | ||
} | ||
if(s === 0) { | ||
r = g = b = l; // achromatic | ||
} | ||
else { | ||
var q = l < 0.5 ? l * (1 + s) : l + s - l * s; | ||
var p = 2 * l - q; | ||
r = hue2rgb(p, q, h + 1/3); | ||
g = hue2rgb(p, q, h); | ||
b = hue2rgb(p, q, h - 1/3); | ||
} | ||
return { r: r * 255, g: g * 255, b: b * 255 }; | ||
} | ||
// `rgbToHsv` | ||
// Converts an RGB color value to HSV | ||
// *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1] | ||
// *Returns:* { h, s, v } in [0,1] | ||
function rgbToHsv(r, g, b) { | ||
r = bound01(r, 255); | ||
g = bound01(g, 255); | ||
b = bound01(b, 255); | ||
var max = mathMax(r, g, b), min = mathMin(r, g, b); | ||
var h, s, v = max; | ||
var d = max - min; | ||
s = max === 0 ? 0 : d / max; | ||
if(max == min) { | ||
h = 0; // achromatic | ||
} | ||
else { | ||
switch(max) { | ||
case r: h = (g - b) / d + (g < b ? 6 : 0); break; | ||
case g: h = (b - r) / d + 2; break; | ||
case b: h = (r - g) / d + 4; break; | ||
} | ||
h /= 6; | ||
} | ||
return { h: h, s: s, v: v }; | ||
} | ||
// `hsvToRgb` | ||
// Converts an HSV color value to RGB. | ||
// *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100] | ||
// *Returns:* { r, g, b } in the set [0, 255] | ||
function hsvToRgb(h, s, v) { | ||
h = bound01(h, 360) * 6; | ||
s = bound01(s, 100); | ||
v = bound01(v, 100); | ||
var i = Math.floor(h), | ||
f = h - i, | ||
p = v * (1 - s), | ||
q = v * (1 - f * s), | ||
t = v * (1 - (1 - f) * s), | ||
mod = i % 6, | ||
r = [v, q, p, p, t, v][mod], | ||
g = [t, v, v, q, p, p][mod], | ||
b = [p, p, t, v, v, q][mod]; | ||
return { r: r * 255, g: g * 255, b: b * 255 }; | ||
} | ||
// `rgbToHex` | ||
// Converts an RGB color to hex | ||
// Assumes r, g, and b are contained in the set [0, 255] | ||
// Returns a 3 or 6 character hex | ||
function rgbToHex(r, g, b, allow3Char) { | ||
var hex = [ | ||
pad2(mathRound(r).toString(16)), | ||
pad2(mathRound(g).toString(16)), | ||
pad2(mathRound(b).toString(16)) | ||
]; | ||
// Return a 3 character hex if possible | ||
if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) { | ||
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0); | ||
} | ||
return hex.join(""); | ||
} | ||
// `rgbaToHex` | ||
// Converts an RGBA color plus alpha transparency to hex | ||
// Assumes r, g, b are contained in the set [0, 255] and | ||
// a in [0, 1]. Returns a 4 or 8 character rgba hex | ||
function rgbaToHex(r, g, b, a, allow4Char) { | ||
var hex = [ | ||
pad2(mathRound(r).toString(16)), | ||
pad2(mathRound(g).toString(16)), | ||
pad2(mathRound(b).toString(16)), | ||
pad2(convertDecimalToHex(a)) | ||
]; | ||
// Return a 4 character hex if possible | ||
if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) { | ||
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0); | ||
} | ||
return hex.join(""); | ||
} | ||
// `rgbaToArgbHex` | ||
// Converts an RGBA color to an ARGB Hex8 string | ||
// Rarely used, but required for "toFilter()" | ||
function rgbaToArgbHex(r, g, b, a) { | ||
var hex = [ | ||
pad2(convertDecimalToHex(a)), | ||
pad2(mathRound(r).toString(16)), | ||
pad2(mathRound(g).toString(16)), | ||
pad2(mathRound(b).toString(16)) | ||
]; | ||
return hex.join(""); | ||
} | ||
// `equals` | ||
// Can be called with any tinycolor input | ||
tinycolor.equals = function (color1, color2) { | ||
if (!color1 || !color2) { return false; } | ||
return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString(); | ||
}; | ||
tinycolor.random = function() { | ||
return tinycolor.fromRatio({ | ||
r: mathRandom(), | ||
g: mathRandom(), | ||
b: mathRandom() | ||
}); | ||
}; | ||
// Modification Functions | ||
// ---------------------- | ||
// Thanks to less.js for some of the basics here | ||
// <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js> | ||
function desaturate(color, amount) { | ||
amount = (amount === 0) ? 0 : (amount || 10); | ||
var hsl = tinycolor(color).toHsl(); | ||
hsl.s -= amount / 100; | ||
hsl.s = clamp01(hsl.s); | ||
return tinycolor(hsl); | ||
} | ||
function saturate(color, amount) { | ||
amount = (amount === 0) ? 0 : (amount || 10); | ||
var hsl = tinycolor(color).toHsl(); | ||
hsl.s += amount / 100; | ||
hsl.s = clamp01(hsl.s); | ||
return tinycolor(hsl); | ||
} | ||
function greyscale(color) { | ||
return tinycolor(color).desaturate(100); | ||
} | ||
function lighten (color, amount) { | ||
amount = (amount === 0) ? 0 : (amount || 10); | ||
var hsl = tinycolor(color).toHsl(); | ||
hsl.l += amount / 100; | ||
hsl.l = clamp01(hsl.l); | ||
return tinycolor(hsl); | ||
} | ||
function brighten(color, amount) { | ||
amount = (amount === 0) ? 0 : (amount || 10); | ||
var rgb = tinycolor(color).toRgb(); | ||
rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100)))); | ||
rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100)))); | ||
rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100)))); | ||
return tinycolor(rgb); | ||
} | ||
function darken (color, amount) { | ||
amount = (amount === 0) ? 0 : (amount || 10); | ||
var hsl = tinycolor(color).toHsl(); | ||
hsl.l -= amount / 100; | ||
hsl.l = clamp01(hsl.l); | ||
return tinycolor(hsl); | ||
} | ||
// Spin takes a positive or negative amount within [-360, 360] indicating the change of hue. | ||
// Values outside of this range will be wrapped into this range. | ||
function spin(color, amount) { | ||
var hsl = tinycolor(color).toHsl(); | ||
var hue = (hsl.h + amount) % 360; | ||
hsl.h = hue < 0 ? 360 + hue : hue; | ||
return tinycolor(hsl); | ||
} | ||
// Combination Functions | ||
// --------------------- | ||
// Thanks to jQuery xColor for some of the ideas behind these | ||
// <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js> | ||
function complement(color) { | ||
var hsl = tinycolor(color).toHsl(); | ||
hsl.h = (hsl.h + 180) % 360; | ||
return tinycolor(hsl); | ||
} | ||
function triad(color) { | ||
var hsl = tinycolor(color).toHsl(); | ||
var h = hsl.h; | ||
return [ | ||
tinycolor(color), | ||
tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }), | ||
tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l }) | ||
]; | ||
} | ||
function tetrad(color) { | ||
var hsl = tinycolor(color).toHsl(); | ||
var h = hsl.h; | ||
return [ | ||
tinycolor(color), | ||
tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }), | ||
tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }), | ||
tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l }) | ||
]; | ||
} | ||
function splitcomplement(color) { | ||
var hsl = tinycolor(color).toHsl(); | ||
var h = hsl.h; | ||
return [ | ||
tinycolor(color), | ||
tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}), | ||
tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l}) | ||
]; | ||
} | ||
function analogous(color, results, slices) { | ||
results = results || 6; | ||
slices = slices || 30; | ||
var hsl = tinycolor(color).toHsl(); | ||
var part = 360 / slices; | ||
var ret = [tinycolor(color)]; | ||
for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) { | ||
hsl.h = (hsl.h + part) % 360; | ||
ret.push(tinycolor(hsl)); | ||
} | ||
return ret; | ||
} | ||
function monochromatic(color, results) { | ||
results = results || 6; | ||
var hsv = tinycolor(color).toHsv(); | ||
var h = hsv.h, s = hsv.s, v = hsv.v; | ||
var ret = []; | ||
var modification = 1 / results; | ||
while (results--) { | ||
ret.push(tinycolor({ h: h, s: s, v: v})); | ||
v = (v + modification) % 1; | ||
} | ||
return ret; | ||
} | ||
// Utility Functions | ||
// --------------------- | ||
tinycolor.mix = function(color1, color2, amount) { | ||
amount = (amount === 0) ? 0 : (amount || 50); | ||
var rgb1 = tinycolor(color1).toRgb(); | ||
var rgb2 = tinycolor(color2).toRgb(); | ||
var p = amount / 100; | ||
var rgba = { | ||
r: ((rgb2.r - rgb1.r) * p) + rgb1.r, | ||
g: ((rgb2.g - rgb1.g) * p) + rgb1.g, | ||
b: ((rgb2.b - rgb1.b) * p) + rgb1.b, | ||
a: ((rgb2.a - rgb1.a) * p) + rgb1.a | ||
}; | ||
return tinycolor(rgba); | ||
}; | ||
// Readability Functions | ||
// --------------------- | ||
// <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2) | ||
// `contrast` | ||
// Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2) | ||
tinycolor.readability = function(color1, color2) { | ||
var c1 = tinycolor(color1); | ||
var c2 = tinycolor(color2); | ||
return (Math.max(c1.getLuminance(),c2.getLuminance())+0.05) / (Math.min(c1.getLuminance(),c2.getLuminance())+0.05); | ||
}; | ||
// `isReadable` | ||
// Ensure that foreground and background color combinations meet WCAG2 guidelines. | ||
// The third argument is an optional Object. | ||
// the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA'; | ||
// the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'. | ||
// If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}. | ||
// *Example* | ||
// tinycolor.isReadable("#000", "#111") => false | ||
// tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false | ||
tinycolor.isReadable = function(color1, color2, wcag2) { | ||
var readability = tinycolor.readability(color1, color2); | ||
var wcag2Parms, out; | ||
out = false; | ||
wcag2Parms = validateWCAG2Parms(wcag2); | ||
switch (wcag2Parms.level + wcag2Parms.size) { | ||
case "AAsmall": | ||
case "AAAlarge": | ||
out = readability >= 4.5; | ||
break; | ||
case "AAlarge": | ||
out = readability >= 3; | ||
break; | ||
case "AAAsmall": | ||
out = readability >= 7; | ||
break; | ||
} | ||
return out; | ||
}; | ||
// `mostReadable` | ||
// Given a base color and a list of possible foreground or background | ||
// colors for that base, returns the most readable color. | ||
// Optionally returns Black or White if the most readable color is unreadable. | ||
// *Example* | ||
// tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255" | ||
// tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff" | ||
// tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3" | ||
// tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff" | ||
tinycolor.mostReadable = function(baseColor, colorList, args) { | ||
var bestColor = null; | ||
var bestScore = 0; | ||
var readability; | ||
var includeFallbackColors, level, size ; | ||
args = args || {}; | ||
includeFallbackColors = args.includeFallbackColors ; | ||
level = args.level; | ||
size = args.size; | ||
for (var i= 0; i < colorList.length ; i++) { | ||
readability = tinycolor.readability(baseColor, colorList[i]); | ||
if (readability > bestScore) { | ||
bestScore = readability; | ||
bestColor = tinycolor(colorList[i]); | ||
} | ||
} | ||
if (tinycolor.isReadable(baseColor, bestColor, {"level":level,"size":size}) || !includeFallbackColors) { | ||
return bestColor; | ||
} | ||
else { | ||
args.includeFallbackColors=false; | ||
return tinycolor.mostReadable(baseColor,["#fff", "#000"],args); | ||
} | ||
}; | ||
// Big List of Colors | ||
// ------------------ | ||
// <http://www.w3.org/TR/css3-color/#svg-color> | ||
var names = tinycolor.names = { | ||
aliceblue: "f0f8ff", | ||
antiquewhite: "faebd7", | ||
aqua: "0ff", | ||
aquamarine: "7fffd4", | ||
azure: "f0ffff", | ||
beige: "f5f5dc", | ||
bisque: "ffe4c4", | ||
black: "000", | ||
blanchedalmond: "ffebcd", | ||
blue: "00f", | ||
blueviolet: "8a2be2", | ||
brown: "a52a2a", | ||
burlywood: "deb887", | ||
burntsienna: "ea7e5d", | ||
cadetblue: "5f9ea0", | ||
chartreuse: "7fff00", | ||
chocolate: "d2691e", | ||
coral: "ff7f50", | ||
cornflowerblue: "6495ed", | ||
cornsilk: "fff8dc", | ||
crimson: "dc143c", | ||
cyan: "0ff", | ||
darkblue: "00008b", | ||
darkcyan: "008b8b", | ||
darkgoldenrod: "b8860b", | ||
darkgray: "a9a9a9", | ||
darkgreen: "006400", | ||
darkgrey: "a9a9a9", | ||
darkkhaki: "bdb76b", | ||
darkmagenta: "8b008b", | ||
darkolivegreen: "556b2f", | ||
darkorange: "ff8c00", | ||
darkorchid: "9932cc", | ||
darkred: "8b0000", | ||
darksalmon: "e9967a", | ||
darkseagreen: "8fbc8f", | ||
darkslateblue: "483d8b", | ||
darkslategray: "2f4f4f", | ||
darkslategrey: "2f4f4f", | ||
darkturquoise: "00ced1", | ||
darkviolet: "9400d3", | ||
deeppink: "ff1493", | ||
deepskyblue: "00bfff", | ||
dimgray: "696969", | ||
dimgrey: "696969", | ||
dodgerblue: "1e90ff", | ||
firebrick: "b22222", | ||
floralwhite: "fffaf0", | ||
forestgreen: "228b22", | ||
fuchsia: "f0f", | ||
gainsboro: "dcdcdc", | ||
ghostwhite: "f8f8ff", | ||
gold: "ffd700", | ||
goldenrod: "daa520", | ||
gray: "808080", | ||
green: "008000", | ||
greenyellow: "adff2f", | ||
grey: "808080", | ||
honeydew: "f0fff0", | ||
hotpink: "ff69b4", | ||
indianred: "cd5c5c", | ||
indigo: "4b0082", | ||
ivory: "fffff0", | ||
khaki: "f0e68c", | ||
lavender: "e6e6fa", | ||
lavenderblush: "fff0f5", | ||
lawngreen: "7cfc00", | ||
lemonchiffon: "fffacd", | ||
lightblue: "add8e6", | ||
lightcoral: "f08080", | ||
lightcyan: "e0ffff", | ||
lightgoldenrodyellow: "fafad2", | ||
lightgray: "d3d3d3", | ||
lightgreen: "90ee90", | ||
lightgrey: "d3d3d3", | ||
lightpink: "ffb6c1", | ||
lightsalmon: "ffa07a", | ||
lightseagreen: "20b2aa", | ||
lightskyblue: "87cefa", | ||
lightslategray: "789", | ||
lightslategrey: "789", | ||
lightsteelblue: "b0c4de", | ||
lightyellow: "ffffe0", | ||
lime: "0f0", | ||
limegreen: "32cd32", | ||
linen: "faf0e6", | ||
magenta: "f0f", | ||
maroon: "800000", | ||
mediumaquamarine: "66cdaa", | ||
mediumblue: "0000cd", | ||
mediumorchid: "ba55d3", | ||
mediumpurple: "9370db", | ||
mediumseagreen: "3cb371", | ||
mediumslateblue: "7b68ee", | ||
mediumspringgreen: "00fa9a", | ||
mediumturquoise: "48d1cc", | ||
mediumvioletred: "c71585", | ||
midnightblue: "191970", | ||
mintcream: "f5fffa", | ||
mistyrose: "ffe4e1", | ||
moccasin: "ffe4b5", | ||
navajowhite: "ffdead", | ||
navy: "000080", | ||
oldlace: "fdf5e6", | ||
olive: "808000", | ||
olivedrab: "6b8e23", | ||
orange: "ffa500", | ||
orangered: "ff4500", | ||
orchid: "da70d6", | ||
palegoldenrod: "eee8aa", | ||
palegreen: "98fb98", | ||
paleturquoise: "afeeee", | ||
palevioletred: "db7093", | ||
papayawhip: "ffefd5", | ||
peachpuff: "ffdab9", | ||
peru: "cd853f", | ||
pink: "ffc0cb", | ||
plum: "dda0dd", | ||
powderblue: "b0e0e6", | ||
purple: "800080", | ||
rebeccapurple: "663399", | ||
red: "f00", | ||
rosybrown: "bc8f8f", | ||
royalblue: "4169e1", | ||
saddlebrown: "8b4513", | ||
salmon: "fa8072", | ||
sandybrown: "f4a460", | ||
seagreen: "2e8b57", | ||
seashell: "fff5ee", | ||
sienna: "a0522d", | ||
silver: "c0c0c0", | ||
skyblue: "87ceeb", | ||
slateblue: "6a5acd", | ||
slategray: "708090", | ||
slategrey: "708090", | ||
snow: "fffafa", | ||
springgreen: "00ff7f", | ||
steelblue: "4682b4", | ||
tan: "d2b48c", | ||
teal: "008080", | ||
thistle: "d8bfd8", | ||
tomato: "ff6347", | ||
turquoise: "40e0d0", | ||
violet: "ee82ee", | ||
wheat: "f5deb3", | ||
white: "fff", | ||
whitesmoke: "f5f5f5", | ||
yellow: "ff0", | ||
yellowgreen: "9acd32" | ||
}; | ||
// Make it easy to access colors via `hexNames[hex]` | ||
var hexNames = tinycolor.hexNames = flip(names); | ||
// Utilities | ||
// --------- | ||
// `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }` | ||
function flip(o) { | ||
var flipped = { }; | ||
for (var i in o) { | ||
if (o.hasOwnProperty(i)) { | ||
flipped[o[i]] = i; | ||
} | ||
} | ||
return flipped; | ||
} | ||
// Return a valid alpha value [0,1] with all invalid values being set to 1 | ||
function boundAlpha(a) { | ||
a = parseFloat(a); | ||
if (isNaN(a) || a < 0 || a > 1) { | ||
a = 1; | ||
} | ||
return a; | ||
} | ||
// Take input from [0, n] and return it as [0, 1] | ||
function bound01(n, max) { | ||
if (isOnePointZero(n)) { n = "100%"; } | ||
var processPercent = isPercentage(n); | ||
n = mathMin(max, mathMax(0, parseFloat(n))); | ||
// Automatically convert percentage into number | ||
if (processPercent) { | ||
n = parseInt(n * max, 10) / 100; | ||
} | ||
// Handle floating point rounding errors | ||
if ((Math.abs(n - max) < 0.000001)) { | ||
return 1; | ||
} | ||
// Convert into [0, 1] range if it isn't already | ||
return (n % max) / parseFloat(max); | ||
} | ||
// Force a number between 0 and 1 | ||
function clamp01(val) { | ||
return mathMin(1, mathMax(0, val)); | ||
} | ||
// Parse a base-16 hex value into a base-10 integer | ||
function parseIntFromHex(val) { | ||
return parseInt(val, 16); | ||
} | ||
// Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1 | ||
// <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0> | ||
function isOnePointZero(n) { | ||
return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1; | ||
} | ||
// Check to see if string passed in is a percentage | ||
function isPercentage(n) { | ||
return typeof n === "string" && n.indexOf('%') != -1; | ||
} | ||
// Force a hex value to have 2 characters | ||
function pad2(c) { | ||
return c.length == 1 ? '0' + c : '' + c; | ||
} | ||
// Replace a decimal with it's percentage value | ||
function convertToPercentage(n) { | ||
if (n <= 1) { | ||
n = (n * 100) + "%"; | ||
} | ||
return n; | ||
} | ||
// Converts a decimal to a hex value | ||
function convertDecimalToHex(d) { | ||
return Math.round(parseFloat(d) * 255).toString(16); | ||
} | ||
// Converts a hex value to a decimal | ||
function convertHexToDecimal(h) { | ||
return (parseIntFromHex(h) / 255); | ||
} | ||
var matchers = (function() { | ||
// <http://www.w3.org/TR/css3-values/#integers> | ||
var CSS_INTEGER = "[-\\+]?\\d+%?"; | ||
// <http://www.w3.org/TR/css3-values/#number-value> | ||
var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?"; | ||
// Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome. | ||
var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")"; | ||
// Actual matching. | ||
// Parentheses and commas are optional, but not required. | ||
// Whitespace can take the place of commas or opening paren | ||
var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; | ||
var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; | ||
return { | ||
CSS_UNIT: new RegExp(CSS_UNIT), | ||
rgb: new RegExp("rgb" + PERMISSIVE_MATCH3), | ||
rgba: new RegExp("rgba" + PERMISSIVE_MATCH4), | ||
hsl: new RegExp("hsl" + PERMISSIVE_MATCH3), | ||
hsla: new RegExp("hsla" + PERMISSIVE_MATCH4), | ||
hsv: new RegExp("hsv" + PERMISSIVE_MATCH3), | ||
hsva: new RegExp("hsva" + PERMISSIVE_MATCH4), | ||
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, | ||
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/, | ||
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, | ||
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/ | ||
}; | ||
})(); | ||
// `isValidCSSUnit` | ||
// Take in a single string / number and check to see if it looks like a CSS unit | ||
// (see `matchers` above for definition). | ||
function isValidCSSUnit(color) { | ||
return !!matchers.CSS_UNIT.exec(color); | ||
} | ||
// `stringInputToObject` | ||
// Permissive string parsing. Take in a number of formats, and output an object | ||
// based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}` | ||
function stringInputToObject(color) { | ||
color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase(); | ||
var named = false; | ||
if (names[color]) { | ||
color = names[color]; | ||
named = true; | ||
} | ||
else if (color == 'transparent') { | ||
return { r: 0, g: 0, b: 0, a: 0, format: "name" }; | ||
} | ||
// Try to match string input using regular expressions. | ||
// Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360] | ||
// Just return an object and let the conversion functions handle that. | ||
// This way the result will be the same whether the tinycolor is initialized with string or object. | ||
var match; | ||
if ((match = matchers.rgb.exec(color))) { | ||
return { r: match[1], g: match[2], b: match[3] }; | ||
} | ||
if ((match = matchers.rgba.exec(color))) { | ||
return { r: match[1], g: match[2], b: match[3], a: match[4] }; | ||
} | ||
if ((match = matchers.hsl.exec(color))) { | ||
return { h: match[1], s: match[2], l: match[3] }; | ||
} | ||
if ((match = matchers.hsla.exec(color))) { | ||
return { h: match[1], s: match[2], l: match[3], a: match[4] }; | ||
} | ||
if ((match = matchers.hsv.exec(color))) { | ||
return { h: match[1], s: match[2], v: match[3] }; | ||
} | ||
if ((match = matchers.hsva.exec(color))) { | ||
return { h: match[1], s: match[2], v: match[3], a: match[4] }; | ||
} | ||
if ((match = matchers.hex8.exec(color))) { | ||
return { | ||
r: parseIntFromHex(match[1]), | ||
g: parseIntFromHex(match[2]), | ||
b: parseIntFromHex(match[3]), | ||
a: convertHexToDecimal(match[4]), | ||
format: named ? "name" : "hex8" | ||
}; | ||
} | ||
if ((match = matchers.hex6.exec(color))) { | ||
return { | ||
r: parseIntFromHex(match[1]), | ||
g: parseIntFromHex(match[2]), | ||
b: parseIntFromHex(match[3]), | ||
format: named ? "name" : "hex" | ||
}; | ||
} | ||
if ((match = matchers.hex4.exec(color))) { | ||
return { | ||
r: parseIntFromHex(match[1] + '' + match[1]), | ||
g: parseIntFromHex(match[2] + '' + match[2]), | ||
b: parseIntFromHex(match[3] + '' + match[3]), | ||
a: convertHexToDecimal(match[4] + '' + match[4]), | ||
format: named ? "name" : "hex8" | ||
}; | ||
} | ||
if ((match = matchers.hex3.exec(color))) { | ||
return { | ||
r: parseIntFromHex(match[1] + '' + match[1]), | ||
g: parseIntFromHex(match[2] + '' + match[2]), | ||
b: parseIntFromHex(match[3] + '' + match[3]), | ||
format: named ? "name" : "hex" | ||
}; | ||
} | ||
return false; | ||
} | ||
function validateWCAG2Parms(parms) { | ||
// return valid WCAG2 parms for isReadable. | ||
// If input parms are invalid, return {"level":"AA", "size":"small"} | ||
var level, size; | ||
parms = parms || {"level":"AA", "size":"small"}; | ||
level = (parms.level || "AA").toUpperCase(); | ||
size = (parms.size || "small").toLowerCase(); | ||
if (level !== "AA" && level !== "AAA") { | ||
level = "AA"; | ||
} | ||
if (size !== "small" && size !== "large") { | ||
size = "small"; | ||
} | ||
return {"level":level, "size":size}; | ||
} | ||
// Node: Export function | ||
if (typeof module !== "undefined" && module.exports) { | ||
module.exports = tinycolor; | ||
} | ||
// AMD/requirejs: Define the module | ||
else if (true) { | ||
!(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {return tinycolor;}).call(exports, __webpack_require__, exports, module), | ||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
} | ||
// Browser: Expose to window | ||
else { | ||
window.tinycolor = tinycolor; | ||
} | ||
})(Math); | ||
/***/ }), | ||
/* 3 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
__webpack_require__(0); | ||
module.exports = __webpack_require__(4); | ||
/***/ }), | ||
/* 4 */ | ||
/***/ (function(module, exports) { | ||
// removed by extract-text-webpack-plugin | ||
/***/ }) | ||
/******/ ])["default"]; | ||
}); |
@@ -1,8 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.QuillCursors=e():t.QuillCursors=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var r={};return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=5)}([function(t,e,r){"use strict";function n(t,e){this.quill=t,this._initOptions(e),this.cursors={},this.container=this.quill.addContainer("ql-cursors"),this.options.autoRegisterListener&&this.registerTextChangeListener(),window.addEventListener("resize",this.update.bind(this))}Object.defineProperty(e,"__esModule",{value:!0});var i=r(1),o=r.n(i),a=r(2),s=r.n(a),l={template:['<span class="ql-cursor-selections"></span>','<span class="ql-cursor-caret-container">',' <span class="ql-cursor-caret"></span>',"</span>",'<div class="ql-cursor-flag">',' <small class="ql-cursor-name"></small>',' <span class="ql-cursor-flag-flap"></span>',"</div>"].join(""),autoRegisterListener:!0,hideDelay:3e3,hideSpeed:400};n.prototype.registerTextChangeListener=function(){this.quill.on(this.quill.constructor.events.TEXT_CHANGE,this._applyDelta.bind(this))},n.prototype.clearCursors=function(){Object.keys(this.cursors).forEach(this.removeCursor.bind(this))},n.prototype.moveCursor=function(t,e){var r=this.cursors[t];r&&(r.range=e,r.el.classList.remove("hidden"),this._updateCursor(r))},n.prototype.removeCursor=function(t){var e=this.cursors[t];e&&e.el.parentNode.removeChild(e.el),delete this.cursors[t]},n.prototype.setCursor=function(t,e,r,n){return this.cursors[t]||(this.cursors[t]={userId:t,color:n,range:e,el:null,selectionEl:null,caretEl:null,flagEl:null},this._buildCursor(t,r)),window.setTimeout(function(){this.moveCursor(t,e)}.bind(this)),this.cursors[t]},n.prototype.shiftCursors=function(t,e){var r;Object.keys(this.cursors).forEach(function(n){(r=this.cursors[n])&&r.range&&(e>0||0==r.range.length?this._shiftCursor(n,t-1,e):this._shiftCursor(n,t,e))},this)},n.prototype.update=function(){Object.keys(this.cursors).map(function(t){this._updateCursor(this.cursors[t])}.bind(this))},n.prototype._initOptions=function(t){this.options=l,this.options.template=t.template||this.options.template,this.options.autoRegisterListener=0==t.autoRegisterListener?t.autoRegisterListener:this.options.autoRegisterListener,this.options.hideDelay=void 0==t.hideDelay?this.options.hideDelay:t.hideDelay,this.options.hideSpeed=void 0==t.hideSpeed?this.options.hideSpeed:t.hideSpeed},n.prototype._applyDelta=function(t){var e=0;t.ops.forEach(function(t){var r=0;t.insert?(r=t.insert.length||1,this.shiftCursors(e,r)):t.delete?this.shiftCursors(e,-1*t.delete):t.retain&&(r=t.retain),e+=r},this),this.update()},n.prototype._buildCursor=function(t,e){var r,n,i,o=this.cursors[t],a=document.createElement("span");a.classList.add("ql-cursor"),a.innerHTML=this.options.template,r=a.querySelector(".ql-cursor-selections"),n=a.querySelector(".ql-cursor-caret-container"),(i=a.querySelector(".ql-cursor-flag")).style.backgroundColor=o.color,n.querySelector(".ql-cursor-caret").style.backgroundColor=o.color,a.querySelector(".ql-cursor-name").innerText=e,i.style.transitionDelay=this.options.hideDelay+"ms",i.style.transitionDuration=this.options.hideSpeed+"ms",this.container.appendChild(a),o.el=a,o.selectionEl=r,o.caretEl=n,o.flagEl=i},n.prototype._shiftCursor=function(t,e,r){var n=this.cursors[t];n.range.index>e&&(n.range.index+=r)},n.prototype._hideCursor=function(t){var e=this.cursors[t];e&&e.el.classList.add("hidden")},n.prototype._updateCursor=function(t){if(t&&t.range){var e,r=this.quill.container.getBoundingClientRect(),n=this.quill.getLeaf(t.range.index),i=this.quill.getLeaf(t.range.index+t.range.length),a=document.createRange();if(!n||!i||!n[0]||!i[0]||n[1]<0||i[1]<0||!n[0].domNode||!i[0].domNode)return console.log("Troubles!",t),this._hideCursor(t.userId);a.setStart(n[0].domNode,n[1]),a.setEnd(i[0].domNode,i[1]),e=o.a.getClientRects(a),this._updateCaret(t,i),this._updateSelection(t,e,r)}},n.prototype._updateCaret=function(t,e){var r,n=t.range.index+t.range.length;n>0&&0===e[1]&&t.range.index!==t.range.index+t.range.length&&n--,r=this.quill.getBounds(n),t.caretEl.style.top=r.top+"px",t.caretEl.style.left=r.left+"px",t.caretEl.style.height=r.height+"px",t.flagEl.style.top=r.top+"px",t.flagEl.style.left=r.left+"px"},n.prototype._updateSelection=function(t,e,r){t.selectionEl.innerHTML=null;var n,i=[];[].forEach.call(e,function(e){n=""+e.top+e.left+e.width+e.height,!~i.indexOf(n)&&e.width>1&&(i.push(n),t.selectionEl.appendChild(function(e){var n=document.createElement("span");return n.classList.add("ql-cursor-selection-block"),n.style.top=e.top-r.top+"px",n.style.left=e.left-r.left+"px",n.style.width=e.width+"px",n.style.height=e.height+"px",n.style.backgroundColor=s()(t.color).setAlpha(.3).toString(),n}(e)))},this)},e.default=n},function(t,e,r){var n,i;/*! | ||
* RangeFix v0.2.5 | ||
* https://github.com/edg2s/rangefix | ||
* | ||
* Copyright 2014-17 Ed Sanders. | ||
* Released under the MIT license | ||
*/ | ||
!function(o,a){void 0!==(i="function"==typeof(n=a)?n.call(e,r,e,t):n)&&(t.exports=i)}(0,function(){function t(){var t,e,r,i,o,a,s,l;return void 0===n&&(e=document.createElement("p"),r=document.createElement("span"),i=document.createTextNode("aa"),o=document.createTextNode("aa"),(a=document.createElement("img")).setAttribute("src","#null"),s=document.createRange(),n={},e.appendChild(i),e.appendChild(r),r.appendChild(a),r.appendChild(o),document.body.appendChild(e),s.setStart(i,1),s.setEnd(r,0),n.getClientRects=n.getBoundingClientRect=s.getClientRects().length>1,n.getClientRects||(s.setEnd(o,1),n.getClientRects=n.getBoundingClientRect=s.getClientRects().length<3),n.getBoundingClientRect||(s.setEnd(s.startContainer,s.startOffset),t=s.getBoundingClientRect(),n.getBoundingClientRect=0===t.top&&0===t.left),document.body.removeChild(e),l=window.ActiveXObject&&new Function("/*@cc_on return @_jscript_version; @*/")(),n.ieZoom=l&&l<=10),n}function e(t){var r;return t?screen.deviceXDPI===screen.logicalXDPI?t:"length"in t?Array.prototype.map.call(t,e):(r=screen.deviceXDPI/screen.logicalXDPI,{top:t.top/r,bottom:t.bottom/r,left:t.left/r,right:t.right/r,width:t.width/r,height:t.height/r}):t}function r(t,e){var r,n=0;if(1024>=e.length)return Array.prototype.push.apply(t,e);for(;n<e.length;)r=Array.prototype.push.apply(t,Array.prototype.slice.call(e,n,n+1024)),n+=1024;return r}var n,i={};return i.getClientRects=function(n){var i,o,a,s,l=t();if(l.ieZoom)return e(n.getClientRects());if(!l.getClientRects)return n.getClientRects();for(i=[],o=n.endContainer,a=n.endOffset,s=document.createRange();o!==n.commonAncestorContainer;)s.setStart(o,0),s.setEnd(o,a),r(i,s.getClientRects()),a=Array.prototype.indexOf.call(o.parentNode.childNodes,o),o=o.parentNode;return(s=n.cloneRange()).setEnd(o,a),r(i,s.getClientRects()),i},i.getBoundingClientRect=function(r){var n,i,o,a,s,l,u=this.getClientRects(r);if(0===u.length)return null;if(s=r.getBoundingClientRect(),(l=t()).ieZoom)return e(s);if(!l.getBoundingClientRect)return s;if(0===s.width&&0===s.height)return u[0];for(n=0,i=u.length;n<i;n++)a=u[n],o?(o.left=Math.min(o.left,a.left),o.top=Math.min(o.top,a.top),o.right=Math.max(o.right,a.right),o.bottom=Math.max(o.bottom,a.bottom)):o={left:a.left,top:a.top,right:a.right,bottom:a.bottom};return o&&(o.width=o.right-o.left,o.height=o.bottom-o.top),o},i})},function(t,e,r){var n;!function(i){function o(t,e){if(t=t||"",e=e||{},t instanceof o)return t;if(!(this instanceof o))return new o(t,e);var r=function(t){var e={r:0,g:0,b:0},r=1,n=null,o=null,a=null,s=!1,l=!1;"string"==typeof t&&(t=function(t){t=t.replace(F,"").replace(O,"").toLowerCase();var e=!1;if(I[t])t=I[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};var r;if(r=B.rgb.exec(t))return{r:r[1],g:r[2],b:r[3]};if(r=B.rgba.exec(t))return{r:r[1],g:r[2],b:r[3],a:r[4]};if(r=B.hsl.exec(t))return{h:r[1],s:r[2],l:r[3]};if(r=B.hsla.exec(t))return{h:r[1],s:r[2],l:r[3],a:r[4]};if(r=B.hsv.exec(t))return{h:r[1],s:r[2],v:r[3]};if(r=B.hsva.exec(t))return{h:r[1],s:r[2],v:r[3],a:r[4]};if(r=B.hex8.exec(t))return{r:k(r[1]),g:k(r[2]),b:k(r[3]),a:H(r[4]),format:e?"name":"hex8"};if(r=B.hex6.exec(t))return{r:k(r[1]),g:k(r[2]),b:k(r[3]),format:e?"name":"hex"};if(r=B.hex4.exec(t))return{r:k(r[1]+""+r[1]),g:k(r[2]+""+r[2]),b:k(r[3]+""+r[3]),a:H(r[4]+""+r[4]),format:e?"name":"hex8"};if(r=B.hex3.exec(t))return{r:k(r[1]+""+r[1]),g:k(r[2]+""+r[2]),b:k(r[3]+""+r[3]),format:e?"name":"hex"};return!1}(t));"object"==typeof t&&(L(t.r)&&L(t.g)&&L(t.b)?(e=function(t,e,r){return{r:255*R(t,255),g:255*R(e,255),b:255*R(r,255)}}(t.r,t.g,t.b),s=!0,l="%"===String(t.r).substr(-1)?"prgb":"rgb"):L(t.h)&&L(t.s)&&L(t.v)?(n=E(t.s),o=E(t.v),e=function(t,e,r){t=6*R(t,360),e=R(e,100),r=R(r,100);var n=i.floor(t),o=t-n,a=r*(1-e),s=r*(1-o*e),l=r*(1-(1-o)*e),u=n%6;return{r:255*[r,s,a,a,l,r][u],g:255*[l,r,r,s,a,a][u],b:255*[a,a,l,r,r,s][u]}}(t.h,n,o),s=!0,l="hsv"):L(t.h)&&L(t.s)&&L(t.l)&&(n=E(t.s),a=E(t.l),e=function(t,e,r){function n(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}var i,o,a;t=R(t,360),e=R(e,100),r=R(r,100);if(0===e)i=o=a=r;else{var s=r<.5?r*(1+e):r+e-r*e,l=2*r-s;i=n(l,s,t+1/3),o=n(l,s,t),a=n(l,s,t-1/3)}return{r:255*i,g:255*o,b:255*a}}(t.h,n,a),s=!0,l="hsl"),t.hasOwnProperty("a")&&(r=t.a));return r=A(r),{ok:s,format:t.format||l,r:M(255,T(e.r,0)),g:M(255,T(e.g,0)),b:M(255,T(e.b,0)),a:r}}(t);this._originalInput=t,this._r=r.r,this._g=r.g,this._b=r.b,this._a=r.a,this._roundA=j(100*this._a)/100,this._format=e.format||r.format,this._gradientType=e.gradientType,this._r<1&&(this._r=j(this._r)),this._g<1&&(this._g=j(this._g)),this._b<1&&(this._b=j(this._b)),this._ok=r.ok,this._tc_id=N++}function a(t,e,r){t=R(t,255),e=R(e,255),r=R(r,255);var n,i,o=T(t,e,r),a=M(t,e,r),s=(o+a)/2;if(o==a)n=i=0;else{var l=o-a;switch(i=s>.5?l/(2-o-a):l/(o+a),o){case t:n=(e-r)/l+(e<r?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return{h:n,s:i,l:s}}function s(t,e,r){t=R(t,255),e=R(e,255),r=R(r,255);var n,i,o=T(t,e,r),a=M(t,e,r),s=o-a;if(i=0===o?0:s/o,o==a)n=0;else{switch(o){case t:n=(e-r)/s+(e<r?6:0);break;case e:n=(r-t)/s+2;break;case r:n=(t-e)/s+4}n/=6}return{h:n,s:i,v:o}}function l(t,e,r,n){var i=[S(j(t).toString(16)),S(j(e).toString(16)),S(j(r).toString(16))];return n&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}function u(t,e,r,n){return[S(q(n)),S(j(t).toString(16)),S(j(e).toString(16)),S(j(r).toString(16))].join("")}function c(t,e){e=0===e?0:e||10;var r=o(t).toHsl();return r.s-=e/100,r.s=w(r.s),o(r)}function h(t,e){e=0===e?0:e||10;var r=o(t).toHsl();return r.s+=e/100,r.s=w(r.s),o(r)}function f(t){return o(t).desaturate(100)}function d(t,e){e=0===e?0:e||10;var r=o(t).toHsl();return r.l+=e/100,r.l=w(r.l),o(r)}function g(t,e){e=0===e?0:e||10;var r=o(t).toRgb();return r.r=T(0,M(255,r.r-j(-e/100*255))),r.g=T(0,M(255,r.g-j(-e/100*255))),r.b=T(0,M(255,r.b-j(-e/100*255))),o(r)}function p(t,e){e=0===e?0:e||10;var r=o(t).toHsl();return r.l-=e/100,r.l=w(r.l),o(r)}function b(t,e){var r=o(t).toHsl(),n=(r.h+e)%360;return r.h=n<0?360+n:n,o(r)}function m(t){var e=o(t).toHsl();return e.h=(e.h+180)%360,o(e)}function _(t){var e=o(t).toHsl(),r=e.h;return[o(t),o({h:(r+120)%360,s:e.s,l:e.l}),o({h:(r+240)%360,s:e.s,l:e.l})]}function v(t){var e=o(t).toHsl(),r=e.h;return[o(t),o({h:(r+90)%360,s:e.s,l:e.l}),o({h:(r+180)%360,s:e.s,l:e.l}),o({h:(r+270)%360,s:e.s,l:e.l})]}function y(t){var e=o(t).toHsl(),r=e.h;return[o(t),o({h:(r+72)%360,s:e.s,l:e.l}),o({h:(r+216)%360,s:e.s,l:e.l})]}function x(t,e,r){e=e||6,r=r||30;var n=o(t).toHsl(),i=360/r,a=[o(t)];for(n.h=(n.h-(i*e>>1)+720)%360;--e;)n.h=(n.h+i)%360,a.push(o(n));return a}function C(t,e){e=e||6;for(var r=o(t).toHsv(),n=r.h,i=r.s,a=r.v,s=[],l=1/e;e--;)s.push(o({h:n,s:i,v:a})),a=(a+l)%1;return s}function A(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function R(t,e){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(t)&&(t="100%");var r=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(t);return t=M(e,T(0,parseFloat(t))),r&&(t=parseInt(t*e,10)/100),i.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function w(t){return M(1,T(0,t))}function k(t){return parseInt(t,16)}function S(t){return 1==t.length?"0"+t:""+t}function E(t){return t<=1&&(t=100*t+"%"),t}function q(t){return i.round(255*parseFloat(t)).toString(16)}function H(t){return k(t)/255}function L(t){return!!B.CSS_UNIT.exec(t)}var F=/^\s+/,O=/\s+$/,N=0,j=i.round,M=i.min,T=i.max,D=i.random;o.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,e,r,n,o,a,s=this.toRgb();return t=s.r/255,e=s.g/255,r=s.b/255,n=t<=.03928?t/12.92:i.pow((t+.055)/1.055,2.4),o=e<=.03928?e/12.92:i.pow((e+.055)/1.055,2.4),a=r<=.03928?r/12.92:i.pow((r+.055)/1.055,2.4),.2126*n+.7152*o+.0722*a},setAlpha:function(t){return this._a=A(t),this._roundA=j(100*this._a)/100,this},toHsv:function(){var t=s(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=s(this._r,this._g,this._b),e=j(360*t.h),r=j(100*t.s),n=j(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=a(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=a(this._r,this._g,this._b),e=j(360*t.h),r=j(100*t.s),n=j(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return l(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,r,n,i){var o=[S(j(t).toString(16)),S(j(e).toString(16)),S(j(r).toString(16)),S(q(n))];return i&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1)?o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0):o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:j(this._r),g:j(this._g),b:j(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+j(this._r)+", "+j(this._g)+", "+j(this._b)+")":"rgba("+j(this._r)+", "+j(this._g)+", "+j(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:j(100*R(this._r,255))+"%",g:j(100*R(this._g,255))+"%",b:j(100*R(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+j(100*R(this._r,255))+"%, "+j(100*R(this._g,255))+"%, "+j(100*R(this._b,255))+"%)":"rgba("+j(100*R(this._r,255))+"%, "+j(100*R(this._g,255))+"%, "+j(100*R(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(P[l(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+u(this._r,this._g,this._b,this._a),r=e,n=this._gradientType?"GradientType = 1, ":"";if(t){var i=o(t);r="#"+u(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0;return e||!n||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex4"===t&&(r=this.toHex8String(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return o(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(d,arguments)},brighten:function(){return this._applyModification(g,arguments)},darken:function(){return this._applyModification(p,arguments)},desaturate:function(){return this._applyModification(c,arguments)},saturate:function(){return this._applyModification(h,arguments)},greyscale:function(){return this._applyModification(f,arguments)},spin:function(){return this._applyModification(b,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(x,arguments)},complement:function(){return this._applyCombination(m,arguments)},monochromatic:function(){return this._applyCombination(C,arguments)},splitcomplement:function(){return this._applyCombination(y,arguments)},triad:function(){return this._applyCombination(_,arguments)},tetrad:function(){return this._applyCombination(v,arguments)}},o.fromRatio=function(t,e){if("object"==typeof t){var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]="a"===n?t[n]:E(t[n]));t=r}return o(t,e)},o.equals=function(t,e){return!(!t||!e)&&o(t).toRgbString()==o(e).toRgbString()},o.random=function(){return o.fromRatio({r:D(),g:D(),b:D()})},o.mix=function(t,e,r){r=0===r?0:r||50;var n=o(t).toRgb(),i=o(e).toRgb(),a=r/100;return o({r:(i.r-n.r)*a+n.r,g:(i.g-n.g)*a+n.g,b:(i.b-n.b)*a+n.b,a:(i.a-n.a)*a+n.a})},o.readability=function(t,e){var r=o(t),n=o(e);return(i.max(r.getLuminance(),n.getLuminance())+.05)/(i.min(r.getLuminance(),n.getLuminance())+.05)},o.isReadable=function(t,e,r){var n,i,a=o.readability(t,e);switch(i=!1,(n=function(t){var e,r;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA"),"small"!==r&&"large"!==r&&(r="small"),{level:e,size:r}}(r)).level+n.size){case"AAsmall":case"AAAlarge":i=a>=4.5;break;case"AAlarge":i=a>=3;break;case"AAAsmall":i=a>=7}return i},o.mostReadable=function(t,e,r){var n,i,a,s,l=null,u=0;i=(r=r||{}).includeFallbackColors,a=r.level,s=r.size;for(var c=0;c<e.length;c++)(n=o.readability(t,e[c]))>u&&(u=n,l=o(e[c]));return o.isReadable(t,l,{level:a,size:s})||!i?l:(r.includeFallbackColors=!1,o.mostReadable(t,["#fff","#000"],r))};var I=o.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},P=o.hexNames=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}(I),B=function(){var t="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)",e="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",r="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?";return{CSS_UNIT:new RegExp(t),rgb:new RegExp("rgb"+e),rgba:new RegExp("rgba"+r),hsl:new RegExp("hsl"+e),hsla:new RegExp("hsla"+r),hsv:new RegExp("hsv"+e),hsva:new RegExp("hsva"+r),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();void 0!==t&&t.exports?t.exports=o:void 0!==(n=function(){return o}.call(e,r,e,t))&&(t.exports=n)}(Math)},,,function(t,e,r){t.exports=r(0)}]).default}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.QuillCursors=e():t.QuillCursors=e()}("undefined"!=typeof self?self:this,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=5)}([function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(1),i=r.n(n),o=r(2),a=r.n(o),s={template:['<span class="ql-cursor-selections"></span>','<span class="ql-cursor-caret-container">',' <span class="ql-cursor-caret"></span>',"</span>",'<div class="ql-cursor-flag">',' <small class="ql-cursor-name"></small>',' <span class="ql-cursor-flag-flap"></span>',"</div>"].join(""),autoRegisterListener:!0,hideDelay:3e3,hideSpeed:400};function l(t,e){this.quill=t,this._initOptions(e),this.cursors={},this.container=this.quill.addContainer("ql-cursors"),this.options.autoRegisterListener&&this.registerTextChangeListener(),window.addEventListener("resize",this.update.bind(this))}l.prototype.registerTextChangeListener=function(){this.quill.on(this.quill.constructor.events.TEXT_CHANGE,this._applyDelta.bind(this))},l.prototype.clearCursors=function(){Object.keys(this.cursors).forEach(this.removeCursor.bind(this))},l.prototype.moveCursor=function(t,e){var r=this.cursors[t];r&&(r.range=e,r.el.classList.remove("hidden"),this._updateCursor(r))},l.prototype.removeCursor=function(t){var e=this.cursors[t];e&&e.el.parentNode.removeChild(e.el),delete this.cursors[t]},l.prototype.setCursor=function(t,e,r,n){return this.cursors[t]||(this.cursors[t]={userId:t,color:n,range:e,el:null,selectionEl:null,caretEl:null,flagEl:null},this._buildCursor(t,r)),window.setTimeout(function(){this.moveCursor(t,e)}.bind(this)),this.cursors[t]},l.prototype.shiftCursors=function(t,e){var r;Object.keys(this.cursors).forEach(function(n){(r=this.cursors[n])&&r.range&&(e>0||0==r.range.length?this._shiftCursor(n,t-1,e):this._shiftCursor(n,t,e))},this)},l.prototype.update=function(){Object.keys(this.cursors).map(function(t){this._updateCursor(this.cursors[t])}.bind(this))},l.prototype._initOptions=function(t){this.options=s,this.options.template=t.template||this.options.template,this.options.autoRegisterListener=0==t.autoRegisterListener?t.autoRegisterListener:this.options.autoRegisterListener,this.options.hideDelay=void 0==t.hideDelay?this.options.hideDelay:t.hideDelay,this.options.hideSpeed=void 0==t.hideSpeed?this.options.hideSpeed:t.hideSpeed},l.prototype._applyDelta=function(t){var e=0;t.ops.forEach(function(t){var r=0;t.insert?(r=t.insert.length||1,this.shiftCursors(e,r)):t.delete?this.shiftCursors(e,-1*t.delete):t.retain&&(r=t.retain),e+=r},this),this.update()},l.prototype._buildCursor=function(t,e){var r,n,i,o=this.cursors[t],a=document.createElement("span");a.classList.add("ql-cursor"),a.innerHTML=this.options.template,r=a.querySelector(".ql-cursor-selections"),n=a.querySelector(".ql-cursor-caret-container"),(i=a.querySelector(".ql-cursor-flag")).style.backgroundColor=o.color,n.querySelector(".ql-cursor-caret").style.backgroundColor=o.color,a.querySelector(".ql-cursor-name").innerText=e,i.style.transitionDelay=this.options.hideDelay+"ms",i.style.transitionDuration=this.options.hideSpeed+"ms",this.container.appendChild(a),o.el=a,o.selectionEl=r,o.caretEl=n,o.flagEl=i},l.prototype._shiftCursor=function(t,e,r){var n=this.cursors[t];n.range.index>e&&(n.range.index+=r)},l.prototype._hideCursor=function(t){var e=this.cursors[t];e&&e.el.classList.add("hidden")},l.prototype._updateCursor=function(t){if(t&&t.range){var e=t.range.index,r=t.range.index+t.range.length;r>this.quill.getLength()-1&&(r=this.quill.getLength()-1);var n,o=this.quill.container.getBoundingClientRect(),a=this.quill.getLeaf(e),s=this.quill.getLeaf(r),l=document.createRange();if(!a||!s||!a[0]||!s[0]||a[1]<0||s[1]<0||!a[0].domNode||!s[0].domNode)return console.warn("[quill-cursors] A cursor couldn't be updated (ID "+t.userId+"), hiding."),void this._hideCursor(t.userId);l.setStart(a[0].domNode,a[1]),l.setEnd(s[0].domNode,s[1]),n=i.a.getClientRects(l),this._updateCaret(t,s),this._updateSelection(t,n,o)}},l.prototype._updateCaret=function(t,e){var r,n=t.range.index+t.range.length;n>0&&0===e[1]&&t.range.index!==t.range.index+t.range.length&&n--,r=this.quill.getBounds(n),t.caretEl.style.top=r.top+"px",t.caretEl.style.left=r.left+"px",t.caretEl.style.height=r.height+"px",t.flagEl.style.top=r.top+"px",t.flagEl.style.left=r.left+"px"},l.prototype._updateSelection=function(t,e,r){t.selectionEl.innerHTML=null;var n,i=[];[].forEach.call(e,function(e){n=""+e.top+e.left+e.width+e.height,!~i.indexOf(n)&&e.width>1&&(i.push(n),t.selectionEl.appendChild(function(e){var n=document.createElement("span");return n.classList.add("ql-cursor-selection-block"),n.style.top=e.top-r.top+"px",n.style.left=e.left-r.left+"px",n.style.width=e.width+"px",n.style.height=e.height+"px",n.style.backgroundColor=a()(t.color).setAlpha(.3).toString(),n}(e)))},this)},e.default=l},function(t,e,r){var n,i;void 0===(i="function"==typeof(n=function(){var t,e={};function r(){var e,r,n,i,o,a,s,l;return void 0===t&&(r=document.createElement("p"),n=document.createElement("span"),i=document.createTextNode("aa"),o=document.createTextNode("aa"),(a=document.createElement("img")).setAttribute("src","#null"),s=document.createRange(),t={},r.appendChild(i),r.appendChild(n),n.appendChild(a),n.appendChild(o),document.body.appendChild(r),s.setStart(i,1),s.setEnd(n,0),t.getClientRects=t.getBoundingClientRect=s.getClientRects().length>1,t.getClientRects||(s.setEnd(o,1),t.getClientRects=t.getBoundingClientRect=s.getClientRects().length<3),t.getBoundingClientRect||(s.setEnd(s.startContainer,s.startOffset),e=s.getBoundingClientRect(),t.getBoundingClientRect=0===e.top&&0===e.left),document.body.removeChild(r),l=window.ActiveXObject&&new Function("/*@cc_on return @_jscript_version; @*/")(),t.ieZoom=l&&l<=10),t}function n(t){var e;return t?screen.deviceXDPI===screen.logicalXDPI?t:"length"in t?Array.prototype.map.call(t,n):(e=screen.deviceXDPI/screen.logicalXDPI,{top:t.top/e,bottom:t.bottom/e,left:t.left/e,right:t.right/e,width:t.width/e,height:t.height/e}):t}function i(t,e){var r,n=0;if(1024>=e.length)return Array.prototype.push.apply(t,e);for(;n<e.length;)r=Array.prototype.push.apply(t,Array.prototype.slice.call(e,n,n+1024)),n+=1024;return r}return e.getClientRects=function(t){var e,o,a,s,l=r();if(l.ieZoom)return n(t.getClientRects());if(!l.getClientRects)return t.getClientRects();for(e=[],o=t.endContainer,a=t.endOffset,s=document.createRange();o!==t.commonAncestorContainer;)s.setStart(o,0),s.setEnd(o,a),i(e,s.getClientRects()),a=Array.prototype.indexOf.call(o.parentNode.childNodes,o),o=o.parentNode;return(s=t.cloneRange()).setEnd(o,a),i(e,s.getClientRects()),e},e.getBoundingClientRect=function(t){var e,i,o,a,s,l,u=this.getClientRects(t);if(0===u.length)return null;if(s=t.getBoundingClientRect(),(l=r()).ieZoom)return n(s);if(!l.getBoundingClientRect)return s;if(0===s.width&&0===s.height)return u[0];for(e=0,i=u.length;e<i;e++)a=u[e],o?(o.left=Math.min(o.left,a.left),o.top=Math.min(o.top,a.top),o.right=Math.max(o.right,a.right),o.bottom=Math.max(o.bottom,a.bottom)):o={left:a.left,top:a.top,right:a.right,bottom:a.bottom};return o&&(o.width=o.right-o.left,o.height=o.bottom-o.top),o},e})?n.call(e,r,e,t):n)||(t.exports=i)},function(t,e,r){var n;!function(i){var o=/^\s+/,a=/\s+$/,s=0,l=i.round,u=i.min,c=i.max,h=i.random;function f(t,e){if(t=t||"",e=e||{},t instanceof f)return t;if(!(this instanceof f))return new f(t,e);var r=function(t){var e={r:0,g:0,b:0},r=1,n=null,s=null,l=null,h=!1,f=!1;"string"==typeof t&&(t=function(t){t=t.replace(o,"").replace(a,"").toLowerCase();var e,r=!1;if(H[t])t=H[t],r=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};if(e=X.rgb.exec(t))return{r:e[1],g:e[2],b:e[3]};if(e=X.rgba.exec(t))return{r:e[1],g:e[2],b:e[3],a:e[4]};if(e=X.hsl.exec(t))return{h:e[1],s:e[2],l:e[3]};if(e=X.hsla.exec(t))return{h:e[1],s:e[2],l:e[3],a:e[4]};if(e=X.hsv.exec(t))return{h:e[1],s:e[2],v:e[3]};if(e=X.hsva.exec(t))return{h:e[1],s:e[2],v:e[3],a:e[4]};if(e=X.hex8.exec(t))return{r:j(e[1]),g:j(e[2]),b:j(e[3]),a:I(e[4]),format:r?"name":"hex8"};if(e=X.hex6.exec(t))return{r:j(e[1]),g:j(e[2]),b:j(e[3]),format:r?"name":"hex"};if(e=X.hex4.exec(t))return{r:j(e[1]+""+e[1]),g:j(e[2]+""+e[2]),b:j(e[3]+""+e[3]),a:I(e[4]+""+e[4]),format:r?"name":"hex8"};if(e=X.hex3.exec(t))return{r:j(e[1]+""+e[1]),g:j(e[2]+""+e[2]),b:j(e[3]+""+e[3]),format:r?"name":"hex"};return!1}(t));"object"==typeof t&&($(t.r)&&$(t.g)&&$(t.b)?(d=t.r,g=t.g,p=t.b,e={r:255*O(d,255),g:255*O(g,255),b:255*O(p,255)},h=!0,f="%"===String(t.r).substr(-1)?"prgb":"rgb"):$(t.h)&&$(t.s)&&$(t.v)?(n=M(t.s),s=M(t.v),e=function(t,e,r){t=6*O(t,360),e=O(e,100),r=O(r,100);var n=i.floor(t),o=t-n,a=r*(1-e),s=r*(1-o*e),l=r*(1-(1-o)*e),u=n%6;return{r:255*[r,s,a,a,l,r][u],g:255*[l,r,r,s,a,a][u],b:255*[a,a,l,r,r,s][u]}}(t.h,n,s),h=!0,f="hsv"):$(t.h)&&$(t.s)&&$(t.l)&&(n=M(t.s),l=M(t.l),e=function(t,e,r){var n,i,o;function a(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}if(t=O(t,360),e=O(e,100),r=O(r,100),0===e)n=i=o=r;else{var s=r<.5?r*(1+e):r+e-r*e,l=2*r-s;n=a(l,s,t+1/3),i=a(l,s,t),o=a(l,s,t-1/3)}return{r:255*n,g:255*i,b:255*o}}(t.h,n,l),h=!0,f="hsl"),t.hasOwnProperty("a")&&(r=t.a));var d,g,p;return r=F(r),{ok:h,format:t.format||f,r:u(255,c(e.r,0)),g:u(255,c(e.g,0)),b:u(255,c(e.b,0)),a:r}}(t);this._originalInput=t,this._r=r.r,this._g=r.g,this._b=r.b,this._a=r.a,this._roundA=l(100*this._a)/100,this._format=e.format||r.format,this._gradientType=e.gradientType,this._r<1&&(this._r=l(this._r)),this._g<1&&(this._g=l(this._g)),this._b<1&&(this._b=l(this._b)),this._ok=r.ok,this._tc_id=s++}function d(t,e,r){t=O(t,255),e=O(e,255),r=O(r,255);var n,i,o=c(t,e,r),a=u(t,e,r),s=(o+a)/2;if(o==a)n=i=0;else{var l=o-a;switch(i=s>.5?l/(2-o-a):l/(o+a),o){case t:n=(e-r)/l+(e<r?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return{h:n,s:i,l:s}}function g(t,e,r){t=O(t,255),e=O(e,255),r=O(r,255);var n,i,o=c(t,e,r),a=u(t,e,r),s=o,l=o-a;if(i=0===o?0:l/o,o==a)n=0;else{switch(o){case t:n=(e-r)/l+(e<r?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return{h:n,s:i,v:s}}function p(t,e,r,n){var i=[D(l(t).toString(16)),D(l(e).toString(16)),D(l(r).toString(16))];return n&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}function b(t,e,r,n){return[D(T(n)),D(l(t).toString(16)),D(l(e).toString(16)),D(l(r).toString(16))].join("")}function m(t,e){e=0===e?0:e||10;var r=f(t).toHsl();return r.s-=e/100,r.s=N(r.s),f(r)}function _(t,e){e=0===e?0:e||10;var r=f(t).toHsl();return r.s+=e/100,r.s=N(r.s),f(r)}function v(t){return f(t).desaturate(100)}function y(t,e){e=0===e?0:e||10;var r=f(t).toHsl();return r.l+=e/100,r.l=N(r.l),f(r)}function x(t,e){e=0===e?0:e||10;var r=f(t).toRgb();return r.r=c(0,u(255,r.r-l(-e/100*255))),r.g=c(0,u(255,r.g-l(-e/100*255))),r.b=c(0,u(255,r.b-l(-e/100*255))),f(r)}function C(t,e){e=0===e?0:e||10;var r=f(t).toHsl();return r.l-=e/100,r.l=N(r.l),f(r)}function A(t,e){var r=f(t).toHsl(),n=(r.h+e)%360;return r.h=n<0?360+n:n,f(r)}function w(t){var e=f(t).toHsl();return e.h=(e.h+180)%360,f(e)}function R(t){var e=f(t).toHsl(),r=e.h;return[f(t),f({h:(r+120)%360,s:e.s,l:e.l}),f({h:(r+240)%360,s:e.s,l:e.l})]}function k(t){var e=f(t).toHsl(),r=e.h;return[f(t),f({h:(r+90)%360,s:e.s,l:e.l}),f({h:(r+180)%360,s:e.s,l:e.l}),f({h:(r+270)%360,s:e.s,l:e.l})]}function S(t){var e=f(t).toHsl(),r=e.h;return[f(t),f({h:(r+72)%360,s:e.s,l:e.l}),f({h:(r+216)%360,s:e.s,l:e.l})]}function q(t,e,r){e=e||6,r=r||30;var n=f(t).toHsl(),i=360/r,o=[f(t)];for(n.h=(n.h-(i*e>>1)+720)%360;--e;)n.h=(n.h+i)%360,o.push(f(n));return o}function E(t,e){e=e||6;for(var r=f(t).toHsv(),n=r.h,i=r.s,o=r.v,a=[],s=1/e;e--;)a.push(f({h:n,s:i,v:o})),o=(o+s)%1;return a}f.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,e,r,n=this.toRgb();return t=n.r/255,e=n.g/255,r=n.b/255,.2126*(t<=.03928?t/12.92:i.pow((t+.055)/1.055,2.4))+.7152*(e<=.03928?e/12.92:i.pow((e+.055)/1.055,2.4))+.0722*(r<=.03928?r/12.92:i.pow((r+.055)/1.055,2.4))},setAlpha:function(t){return this._a=F(t),this._roundA=l(100*this._a)/100,this},toHsv:function(){var t=g(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=g(this._r,this._g,this._b),e=l(360*t.h),r=l(100*t.s),n=l(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=d(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=d(this._r,this._g,this._b),e=l(360*t.h),r=l(100*t.s),n=l(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return p(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,r,n,i){var o=[D(l(t).toString(16)),D(l(e).toString(16)),D(l(r).toString(16)),D(T(n))];if(i&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1))return o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0);return o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:l(this._r),g:l(this._g),b:l(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+l(this._r)+", "+l(this._g)+", "+l(this._b)+")":"rgba("+l(this._r)+", "+l(this._g)+", "+l(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:l(100*O(this._r,255))+"%",g:l(100*O(this._g,255))+"%",b:l(100*O(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+l(100*O(this._r,255))+"%, "+l(100*O(this._g,255))+"%, "+l(100*O(this._b,255))+"%)":"rgba("+l(100*O(this._r,255))+"%, "+l(100*O(this._g,255))+"%, "+l(100*O(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(L[p(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+b(this._r,this._g,this._b,this._a),r=e,n=this._gradientType?"GradientType = 1, ":"";if(t){var i=f(t);r="#"+b(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0;return e||!n||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex4"===t&&(r=this.toHex8String(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return f(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(y,arguments)},brighten:function(){return this._applyModification(x,arguments)},darken:function(){return this._applyModification(C,arguments)},desaturate:function(){return this._applyModification(m,arguments)},saturate:function(){return this._applyModification(_,arguments)},greyscale:function(){return this._applyModification(v,arguments)},spin:function(){return this._applyModification(A,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(q,arguments)},complement:function(){return this._applyCombination(w,arguments)},monochromatic:function(){return this._applyCombination(E,arguments)},splitcomplement:function(){return this._applyCombination(S,arguments)},triad:function(){return this._applyCombination(R,arguments)},tetrad:function(){return this._applyCombination(k,arguments)}},f.fromRatio=function(t,e){if("object"==typeof t){var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]="a"===n?t[n]:M(t[n]));t=r}return f(t,e)},f.equals=function(t,e){return!(!t||!e)&&f(t).toRgbString()==f(e).toRgbString()},f.random=function(){return f.fromRatio({r:h(),g:h(),b:h()})},f.mix=function(t,e,r){r=0===r?0:r||50;var n=f(t).toRgb(),i=f(e).toRgb(),o=r/100;return f({r:(i.r-n.r)*o+n.r,g:(i.g-n.g)*o+n.g,b:(i.b-n.b)*o+n.b,a:(i.a-n.a)*o+n.a})},f.readability=function(t,e){var r=f(t),n=f(e);return(i.max(r.getLuminance(),n.getLuminance())+.05)/(i.min(r.getLuminance(),n.getLuminance())+.05)},f.isReadable=function(t,e,r){var n,i,o=f.readability(t,e);switch(i=!1,(n=function(t){var e,r;e=((t=t||{level:"AA",size:"small"}).level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA");"small"!==r&&"large"!==r&&(r="small");return{level:e,size:r}}(r)).level+n.size){case"AAsmall":case"AAAlarge":i=o>=4.5;break;case"AAlarge":i=o>=3;break;case"AAAsmall":i=o>=7}return i},f.mostReadable=function(t,e,r){var n,i,o,a,s=null,l=0;i=(r=r||{}).includeFallbackColors,o=r.level,a=r.size;for(var u=0;u<e.length;u++)(n=f.readability(t,e[u]))>l&&(l=n,s=f(e[u]));return f.isReadable(t,s,{level:o,size:a})||!i?s:(r.includeFallbackColors=!1,f.mostReadable(t,["#fff","#000"],r))};var H=f.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},L=f.hexNames=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}(H);function F(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function O(t,e){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(t)&&(t="100%");var r=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(t);return t=u(e,c(0,parseFloat(t))),r&&(t=parseInt(t*e,10)/100),i.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function N(t){return u(1,c(0,t))}function j(t){return parseInt(t,16)}function D(t){return 1==t.length?"0"+t:""+t}function M(t){return t<=1&&(t=100*t+"%"),t}function T(t){return i.round(255*parseFloat(t)).toString(16)}function I(t){return j(t)/255}var P,B,z,X=(B="[\\s|\\(]+("+(P="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+P+")[,|\\s]+("+P+")\\s*\\)?",z="[\\s|\\(]+("+P+")[,|\\s]+("+P+")[,|\\s]+("+P+")[,|\\s]+("+P+")\\s*\\)?",{CSS_UNIT:new RegExp(P),rgb:new RegExp("rgb"+B),rgba:new RegExp("rgba"+z),hsl:new RegExp("hsl"+B),hsla:new RegExp("hsla"+z),hsv:new RegExp("hsv"+B),hsva:new RegExp("hsva"+z),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function $(t){return!!X.CSS_UNIT.exec(t)}void 0!==t&&t.exports?t.exports=f:void 0===(n=function(){return f}.call(e,r,e,t))||(t.exports=n)}(Math)},,,function(t,e,r){t.exports=r(0)}]).default}); |
{ | ||
"name": "quill-cursors", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A multi cursor module for Quill.", | ||
@@ -18,2 +18,3 @@ "keywords": [ | ||
"main": "dist/quill-cursors.js", | ||
"module": "src/cursors.js", | ||
"scripts": { | ||
@@ -29,12 +30,12 @@ "prepublish": "npm run build", | ||
"devDependencies": { | ||
"css-loader": "^0.28.7", | ||
"css-loader": "^0.28.9", | ||
"extract-text-webpack-plugin": "^3.0.2", | ||
"node-sass": "^4.6.1", | ||
"node-sass": "^4.7.2", | ||
"normalize.css": "^7.0.0", | ||
"quill": "^1.3.4", | ||
"quill": "^1.3.5", | ||
"sass-loader": "^6.0.6", | ||
"style-loader": "^0.19.0", | ||
"uglifyjs-webpack-plugin": "^1.0.1", | ||
"webpack": "^3.8.1", | ||
"webpack-dev-server": "^2.9.4" | ||
"style-loader": "^0.19.1", | ||
"uglifyjs-webpack-plugin": "^1.1.6", | ||
"webpack": "^3.10.0", | ||
"webpack-dev-server": "^2.11.1" | ||
}, | ||
@@ -41,0 +42,0 @@ "dependencies": { |
@@ -144,3 +144,3 @@ # quill-cursors | ||
Run `npm run build` to package a build and `npm run start` to build, start the example webserver and watch for changes. | ||
Run `npm run build` to package a build and `npm run dev` to build, start the example webserver and watch for changes. | ||
@@ -147,0 +147,0 @@ ## TODO |
@@ -183,5 +183,12 @@ import rangeFix from 'rangefix'; | ||
var startRange = cursor.range.index; | ||
var endRange = cursor.range.index + cursor.range.length; | ||
// Check ranges | ||
if(endRange > this.quill.getLength() - 1) | ||
endRange = this.quill.getLength() - 1; | ||
var containerRect = this.quill.container.getBoundingClientRect(); | ||
var startLeaf = this.quill.getLeaf(cursor.range.index); | ||
var endLeaf = this.quill.getLeaf(cursor.range.index + cursor.range.length); | ||
var startLeaf = this.quill.getLeaf(startRange); | ||
var endLeaf = this.quill.getLeaf(endRange); | ||
var range = document.createRange(); | ||
@@ -195,5 +202,8 @@ var rects; | ||
!startLeaf[0].domNode || !endLeaf[0].domNode) { | ||
console.log('Troubles!', cursor); | ||
return this._hideCursor(cursor.userId); | ||
console.warn('[quill-cursors] A cursor couldn\'t be updated (ID ' + cursor.userId +'), hiding.'); | ||
this._hideCursor(cursor.userId); | ||
return; | ||
} | ||
@@ -200,0 +210,0 @@ |
@@ -38,3 +38,3 @@ var path = require('path'); | ||
new UglifyJSPlugin({ | ||
include: /\.min\.js$/, | ||
test: /\.min\.js$/ | ||
}), | ||
@@ -49,3 +49,2 @@ new ExtractTextPlugin({ // define where to save the file | ||
path.join(__dirname, 'example'), | ||
path.join(__dirname, 'dist'), | ||
path.join(__dirname, 'node_modules/normalize.css'), | ||
@@ -52,0 +51,0 @@ path.join(__dirname, 'node_modules/quill/dist') |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
104085
1992