quill-cursors
Advanced tools
Comparing version 0.1.7 to 1.0.0
@@ -1,361 +0,3 @@ | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
if(typeof exports === 'object' && typeof module === 'object') | ||
module.exports = factory(require("quill")); | ||
else if(typeof define === 'function' && define.amd) | ||
define(["quill"], factory); | ||
else if(typeof exports === 'object') | ||
exports["QuillCursors"] = factory(require("quill")); | ||
else | ||
root["QuillCursors"] = factory(root["Quill"]); | ||
})(this, function(__WEBPACK_EXTERNAL_MODULE_3__) { | ||
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; | ||
/******/ | ||
/******/ // identity function for calling harmony imports with the correct context | ||
/******/ __webpack_require__.i = function(value) { return value; }; | ||
/******/ | ||
/******/ // 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 = 6); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_quill__ = __webpack_require__(3); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_quill___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_quill__); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_rangefix_rangefix__ = __webpack_require__(1); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_rangefix_rangefix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_rangefix_rangefix__); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_tinycolor2__ = __webpack_require__(2); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_tinycolor2___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_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 CursorsModule(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)); | ||
} | ||
CursorsModule.prototype.registerTextChangeListener = function() { | ||
this.quill.on(this.quill.constructor.events.TEXT_CHANGE, this._applyDelta.bind(this)); | ||
}; | ||
CursorsModule.prototype.clearCursors = function() { | ||
Object.keys(this.cursors).forEach(this.removeCursor.bind(this)); | ||
}; | ||
CursorsModule.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? | ||
} | ||
}; | ||
CursorsModule.prototype.removeCursor = function(userId) { | ||
var cursor = this.cursors[userId]; | ||
if (cursor) | ||
cursor.el.parentNode.removeChild(cursor.el); | ||
delete this.cursors[userId]; | ||
}; | ||
CursorsModule.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]; | ||
}; | ||
CursorsModule.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); | ||
}; | ||
CursorsModule.prototype.update = function() { | ||
Object.keys(this.cursors).map(function(key) { | ||
this._updateCursor(this.cursors[key]) | ||
}.bind(this)); | ||
}; | ||
CursorsModule.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; | ||
}; | ||
CursorsModule.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(); | ||
}; | ||
CursorsModule.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; | ||
}; | ||
CursorsModule.prototype._shiftCursor = function(userId, index, length) { | ||
var cursor = this.cursors[userId]; | ||
if (cursor.range.index > index) | ||
cursor.range.index += length; | ||
}; | ||
CursorsModule.prototype._hideCursor = function(userId) { | ||
var cursor = this.cursors[userId]; | ||
if (cursor) | ||
cursor.el.classList.add('hidden'); | ||
}; | ||
CursorsModule.prototype._updateCursor = function(cursor) { | ||
if (!cursor || !cursor.range) return; | ||
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 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.log('Troubles!', cursor); | ||
return this._hideCursor(cursor.userId); | ||
} | ||
range.setStart(startLeaf[0].domNode, startLeaf[1]); | ||
range.setEnd(endLeaf[0].domNode, endLeaf[1]); | ||
rects = window.RangeFix.getClientRects(range); | ||
this._updateCaret(cursor, endLeaf); | ||
this._updateSelection(cursor, rects, containerRect); | ||
}; | ||
CursorsModule.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'; | ||
}; | ||
CursorsModule.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_2_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); | ||
}; | ||
__WEBPACK_IMPORTED_MODULE_0_quill___default.a.register('modules/cursors', CursorsModule); | ||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, exports) { | ||
/*! | ||
* RangeFix v0.2.3 | ||
!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;/*! | ||
* RangeFix v0.2.5 | ||
* https://github.com/edg2s/rangefix | ||
@@ -366,1479 +8,2 @@ * | ||
*/ | ||
( 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; | ||
}; | ||
// Expose | ||
window.RangeFix = 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) { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_3__; | ||
/***/ }), | ||
/* 4 */ | ||
/***/ (function(module, exports) { | ||
// removed by extract-text-webpack-plugin | ||
/***/ }), | ||
/* 5 */, | ||
/* 6 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
__webpack_require__(0); | ||
module.exports = __webpack_require__(4); | ||
/***/ }) | ||
/******/ ]); | ||
}); | ||
!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}); |
@@ -1,3 +0,3 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("quill")):"function"==typeof define&&define.amd?define(["quill"],e):"object"==typeof exports?exports.QuillCursors=e(require("quill")):t.QuillCursors=e(t.Quill)}(this,function(t){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.i=function(t){return t},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(3),o=r.n(i),a=r(1),s=(r.n(a),r(2)),l=r.n(s),u={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=u,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"),i.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),o=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);o.setStart(n[0].domNode,n[1]),o.setEnd(i[0].domNode,i[1]),e=window.RangeFix.getClientRects(o),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){function n(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=l()(t.color).setAlpha(.3).toString(),n}t.selectionEl.innerHTML=null;var i,o=[];[].forEach.call(e,function(e){i=""+e.top+e.left+e.width+e.height,!~o.indexOf(i)&&e.width>1&&(o.push(i),t.selectionEl.appendChild(n(e)))},this)},o.a.register("modules/cursors",n)},function(t,e){/*! | ||
* RangeFix v0.2.3 | ||
!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 | ||
@@ -8,2 +8,2 @@ * | ||
*/ | ||
!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"),a.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={};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(),s.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(),l.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},window.RangeFix=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=a(t);this._originalInput=t,this._r=r.r,this._g=r.g,this._b=r.b,this._a=r.a,this._roundA=$(100*this._a)/100,this._format=e.format||r.format,this._gradientType=e.gradientType,this._r<1&&(this._r=$(this._r)),this._g<1&&(this._g=$(this._g)),this._b<1&&(this._b=$(this._b)),this._ok=r.ok,this._tc_id=X++}function a(t){var e={r:0,g:0,b:0},r=1,n=null,i=null,o=null,a=!1,l=!1;return"string"==typeof t&&(t=I(t)),"object"==typeof t&&(D(t.r)&&D(t.g)&&D(t.b)?(e=s(t.r,t.g,t.b),a=!0,l="%"===String(t.r).substr(-1)?"prgb":"rgb"):D(t.h)&&D(t.s)&&D(t.v)?(n=j(t.s),i=j(t.v),e=h(t.h,n,i),a=!0,l="hsv"):D(t.h)&&D(t.s)&&D(t.l)&&(n=j(t.s),o=j(t.l),e=u(t.h,n,o),a=!0,l="hsl"),t.hasOwnProperty("a")&&(r=t.a)),r=q(r),{ok:a,format:t.format||l,r:Q(255,U(e.r,0)),g:Q(255,U(e.g,0)),b:Q(255,U(e.b,0)),a:r}}function s(t,e,r){return{r:255*E(t,255),g:255*E(e,255),b:255*E(r,255)}}function l(t,e,r){t=E(t,255),e=E(e,255),r=E(r,255);var n,i,o=U(t,e,r),a=Q(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 u(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;if(t=E(t,360),e=E(e,100),r=E(r,100),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}}function c(t,e,r){t=E(t,255),e=E(e,255),r=E(r,255);var n,i,o=U(t,e,r),a=Q(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 h(t,e,r){t=6*E(t,360),e=E(e,100),r=E(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]}}function f(t,e,r,n){var i=[N($(t).toString(16)),N($(e).toString(16)),N($(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 d(t,e,r,n,i){var o=[N($(t).toString(16)),N($(e).toString(16)),N($(r).toString(16)),N(M(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("")}function g(t,e,r,n){return[N(M(n)),N($(t).toString(16)),N($(e).toString(16)),N($(r).toString(16))].join("")}function p(t,e){e=0===e?0:e||10;var r=o(t).toHsl();return r.s-=e/100,r.s=H(r.s),o(r)}function b(t,e){e=0===e?0:e||10;var r=o(t).toHsl();return r.s+=e/100,r.s=H(r.s),o(r)}function m(t){return o(t).desaturate(100)}function _(t,e){e=0===e?0:e||10;var r=o(t).toHsl();return r.l+=e/100,r.l=H(r.l),o(r)}function v(t,e){e=0===e?0:e||10;var r=o(t).toRgb();return r.r=U(0,Q(255,r.r-$(-e/100*255))),r.g=U(0,Q(255,r.g-$(-e/100*255))),r.b=U(0,Q(255,r.b-$(-e/100*255))),o(r)}function y(t,e){e=0===e?0:e||10;var r=o(t).toHsl();return r.l-=e/100,r.l=H(r.l),o(r)}function x(t,e){var r=o(t).toHsl(),n=(r.h+e)%360;return r.h=n<0?360+n:n,o(r)}function C(t){var e=o(t).toHsl();return e.h=(e.h+180)%360,o(e)}function A(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 w(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 R(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 k(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 S(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 q(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function E(t,e){L(t)&&(t="100%");var r=O(t);return t=Q(e,U(0,parseFloat(t))),r&&(t=parseInt(t*e,10)/100),i.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function H(t){return Q(1,U(0,t))}function F(t){return parseInt(t,16)}function L(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)}function O(t){return"string"==typeof t&&-1!=t.indexOf("%")}function N(t){return 1==t.length?"0"+t:""+t}function j(t){return t<=1&&(t=100*t+"%"),t}function M(t){return i.round(255*parseFloat(t)).toString(16)}function T(t){return F(t)/255}function D(t){return!!J.CSS_UNIT.exec(t)}function I(t){t=t.replace(B,"").replace(z,"").toLowerCase();var e=!1;if(G[t])t=G[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};var r;return(r=J.rgb.exec(t))?{r:r[1],g:r[2],b:r[3]}:(r=J.rgba.exec(t))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=J.hsl.exec(t))?{h:r[1],s:r[2],l:r[3]}:(r=J.hsla.exec(t))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=J.hsv.exec(t))?{h:r[1],s:r[2],v:r[3]}:(r=J.hsva.exec(t))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=J.hex8.exec(t))?{r:F(r[1]),g:F(r[2]),b:F(r[3]),a:T(r[4]),format:e?"name":"hex8"}:(r=J.hex6.exec(t))?{r:F(r[1]),g:F(r[2]),b:F(r[3]),format:e?"name":"hex"}:(r=J.hex4.exec(t))?{r:F(r[1]+""+r[1]),g:F(r[2]+""+r[2]),b:F(r[3]+""+r[3]),a:T(r[4]+""+r[4]),format:e?"name":"hex8"}:!!(r=J.hex3.exec(t))&&{r:F(r[1]+""+r[1]),g:F(r[2]+""+r[2]),b:F(r[3]+""+r[3]),format:e?"name":"hex"}}function P(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}}var B=/^\s+/,z=/\s+$/,X=0,$=i.round,Q=i.min,U=i.max,Z=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=q(t),this._roundA=$(100*this._a)/100,this},toHsv:function(){var t=c(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=c(this._r,this._g,this._b),e=$(360*t.h),r=$(100*t.s),n=$(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=l(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=l(this._r,this._g,this._b),e=$(360*t.h),r=$(100*t.s),n=$(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return f(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return d(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:$(this._r),g:$(this._g),b:$(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+$(this._r)+", "+$(this._g)+", "+$(this._b)+")":"rgba("+$(this._r)+", "+$(this._g)+", "+$(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:$(100*E(this._r,255))+"%",g:$(100*E(this._g,255))+"%",b:$(100*E(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+$(100*E(this._r,255))+"%, "+$(100*E(this._g,255))+"%, "+$(100*E(this._b,255))+"%)":"rgba("+$(100*E(this._r,255))+"%, "+$(100*E(this._g,255))+"%, "+$(100*E(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(V[f(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+g(this._r,this._g,this._b,this._a),r=e,n=this._gradientType?"GradientType = 1, ":"";if(t){var i=o(t);r="#"+g(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(_,arguments)},brighten:function(){return this._applyModification(v,arguments)},darken:function(){return this._applyModification(y,arguments)},desaturate:function(){return this._applyModification(p,arguments)},saturate:function(){return this._applyModification(b,arguments)},greyscale:function(){return this._applyModification(m,arguments)},spin:function(){return this._applyModification(x,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(k,arguments)},complement:function(){return this._applyCombination(C,arguments)},monochromatic:function(){return this._applyCombination(S,arguments)},splitcomplement:function(){return this._applyCombination(R,arguments)},triad:function(){return this._applyCombination(A,arguments)},tetrad:function(){return this._applyCombination(w,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]:j(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:Z(),g:Z(),b:Z()})},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=P(r),n.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;r=r||{},i=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 G=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"},V=o.hexNames=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}(G),J=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(e,r){e.exports=t},,function(t,e,r){t.exports=r(0)}])}); | ||
!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}); |
@@ -0,1 +1,3 @@ | ||
Quill.register('modules/cursors', QuillCursors); | ||
var quillOne = new Quill('#editor-one', { | ||
@@ -2,0 +4,0 @@ theme: 'snow', |
{ | ||
"name": "quill-cursors", | ||
"version": "0.1.7", | ||
"version": "1.0.0", | ||
"description": "A multi cursor module for Quill.", | ||
@@ -13,2 +13,6 @@ "keywords": [ | ||
"license": "MIT", | ||
"engines": { | ||
"node": "~8", | ||
"npm": "~5" | ||
}, | ||
"main": "dist/quill-cursors.js", | ||
@@ -18,3 +22,3 @@ "scripts": { | ||
"build": "./node_modules/.bin/webpack", | ||
"start": "./node_modules/.bin/webpack-dev-server --open" | ||
"dev": "./node_modules/.bin/webpack-dev-server --open" | ||
}, | ||
@@ -26,17 +30,17 @@ "repository": { | ||
"devDependencies": { | ||
"css-loader": "^0.28.0", | ||
"extract-text-webpack-plugin": "^2.1.0", | ||
"node-sass": "^4.5.2", | ||
"normalize.css": "^6.0.0", | ||
"quill": "^1.2.3", | ||
"sass-loader": "^6.0.3", | ||
"style-loader": "^0.16.1", | ||
"uglifyjs-webpack-plugin": "^0.4.2", | ||
"webpack": "^2.4.1", | ||
"webpack-dev-server": "^2.4.2" | ||
"css-loader": "^0.28.7", | ||
"extract-text-webpack-plugin": "^3.0.2", | ||
"node-sass": "^4.6.1", | ||
"normalize.css": "^7.0.0", | ||
"quill": "^1.3.4", | ||
"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" | ||
}, | ||
"dependencies": { | ||
"rangefix": "^0.2.3", | ||
"rangefix": "^0.2.5", | ||
"tinycolor2": "^1.4.1" | ||
} | ||
} |
# quill-cursors | ||
A multi cursor module for [Quill](https://github.com/quilljs/quill) text editor. | ||
(Fancy working with these libraries to help build an amazing product for self-publishing authors? Don't miss out [Reedsy current job openings](https://angel.co/reedsy/jobs).) | ||
## Install | ||
@@ -14,3 +16,3 @@ | ||
To include `quill-cursors` in your Quill project, simply add the stylesheet and all the Javascripts to your page. The module already takes care of its registering so you just need to add 'cursors' to your module config when you instantiate your editor(s). | ||
To include `quill-cursors` in your Quill project, simply add the stylesheet and all the Javascripts to your page. The module is built as a [UMD module](https://github.com/umdjs/umd) falling back to expose a `QuillCursors` global. Keep in mind you should register this module on Quill as below before usage. | ||
@@ -30,2 +32,4 @@ ```html | ||
<script> | ||
Quill.register('modules/cursors', QuillCursors); | ||
var editor = new Quill('#editor-container', { | ||
@@ -32,0 +36,0 @@ modules: { |
@@ -1,3 +0,2 @@ | ||
import Quill from 'quill'; | ||
import 'rangefix/rangefix'; | ||
import rangeFix from 'rangefix'; | ||
import tinycolor from 'tinycolor2'; | ||
@@ -21,3 +20,3 @@ | ||
function CursorsModule(quill, options) { | ||
function QuillCursors(quill, options) { | ||
this.quill = quill; | ||
@@ -34,11 +33,11 @@ this._initOptions(options); | ||
CursorsModule.prototype.registerTextChangeListener = function() { | ||
QuillCursors.prototype.registerTextChangeListener = function() { | ||
this.quill.on(this.quill.constructor.events.TEXT_CHANGE, this._applyDelta.bind(this)); | ||
}; | ||
CursorsModule.prototype.clearCursors = function() { | ||
QuillCursors.prototype.clearCursors = function() { | ||
Object.keys(this.cursors).forEach(this.removeCursor.bind(this)); | ||
}; | ||
CursorsModule.prototype.moveCursor = function(userId, range) { | ||
QuillCursors.prototype.moveCursor = function(userId, range) { | ||
var cursor = this.cursors[userId]; | ||
@@ -53,3 +52,3 @@ if (cursor) { | ||
CursorsModule.prototype.removeCursor = function(userId) { | ||
QuillCursors.prototype.removeCursor = function(userId) { | ||
var cursor = this.cursors[userId]; | ||
@@ -61,3 +60,3 @@ if (cursor) | ||
CursorsModule.prototype.setCursor = function(userId, range, name, color) { | ||
QuillCursors.prototype.setCursor = function(userId, range, name, color) { | ||
// Init cursor if it doesn't exist | ||
@@ -87,3 +86,3 @@ if (!this.cursors[userId]) { | ||
CursorsModule.prototype.shiftCursors = function(index, length) { | ||
QuillCursors.prototype.shiftCursors = function(index, length) { | ||
var cursor; | ||
@@ -105,3 +104,3 @@ | ||
CursorsModule.prototype.update = function() { | ||
QuillCursors.prototype.update = function() { | ||
Object.keys(this.cursors).map(function(key) { | ||
@@ -112,3 +111,3 @@ this._updateCursor(this.cursors[key]) | ||
CursorsModule.prototype._initOptions = function(options) { | ||
QuillCursors.prototype._initOptions = function(options) { | ||
this.options = DEFAULTS; | ||
@@ -121,3 +120,3 @@ this.options.template = options.template || this.options.template; | ||
CursorsModule.prototype._applyDelta = function(delta) { | ||
QuillCursors.prototype._applyDelta = function(delta) { | ||
var index = 0; | ||
@@ -145,3 +144,3 @@ | ||
CursorsModule.prototype._buildCursor = function(userId, name) { | ||
QuillCursors.prototype._buildCursor = function(userId, name) { | ||
var cursor = this.cursors[userId]; | ||
@@ -178,3 +177,3 @@ var el = document.createElement('span'); | ||
CursorsModule.prototype._shiftCursor = function(userId, index, length) { | ||
QuillCursors.prototype._shiftCursor = function(userId, index, length) { | ||
var cursor = this.cursors[userId]; | ||
@@ -185,3 +184,3 @@ if (cursor.range.index > index) | ||
CursorsModule.prototype._hideCursor = function(userId) { | ||
QuillCursors.prototype._hideCursor = function(userId) { | ||
var cursor = this.cursors[userId]; | ||
@@ -192,3 +191,3 @@ if (cursor) | ||
CursorsModule.prototype._updateCursor = function(cursor) { | ||
QuillCursors.prototype._updateCursor = function(cursor) { | ||
if (!cursor || !cursor.range) return; | ||
@@ -214,3 +213,3 @@ | ||
range.setEnd(endLeaf[0].domNode, endLeaf[1]); | ||
rects = window.RangeFix.getClientRects(range); | ||
rects = rangeFix.getClientRects(range); | ||
@@ -221,3 +220,3 @@ this._updateCaret(cursor, endLeaf); | ||
CursorsModule.prototype._updateCaret = function(cursor, leaf) { | ||
QuillCursors.prototype._updateCaret = function(cursor, leaf) { | ||
var rect, index = cursor.range.index + cursor.range.length; | ||
@@ -244,3 +243,3 @@ | ||
CursorsModule.prototype._updateSelection = function(cursor, rects, containerRect) { | ||
QuillCursors.prototype._updateSelection = function(cursor, rects, containerRect) { | ||
function createSelectionBlock(rect) { | ||
@@ -277,2 +276,2 @@ var selectionBlockEl = document.createElement('span'); | ||
Quill.register('modules/cursors', CursorsModule); | ||
export default QuillCursors; |
@@ -15,2 +15,3 @@ var path = require('path'); | ||
library: 'QuillCursors', | ||
libraryExport: 'default', | ||
libraryTarget: 'umd', | ||
@@ -17,0 +18,0 @@ path: path.resolve(__dirname, 'dist') |
Sorry, the diff of this file is not supported yet
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
157
1
67897
14
424
Updatedrangefix@^0.2.5