diff --git a/dist/tribute.js b/dist/tribute.js index e69de29b..9adb0875 100644 --- a/dist/tribute.js +++ b/dist/tribute.js @@ -0,0 +1,1909 @@ +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Tribute = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i', + post: _this2.current.collection.searchOpts.post || '', + skip: _this2.current.collection.searchOpts.skip, + extract: function extract(el) { + if (typeof _this2.current.collection.lookup === 'string') { + return el[_this2.current.collection.lookup]; + } else if (typeof _this2.current.collection.lookup === 'function') { + return _this2.current.collection.lookup(el, _this2.current.mentionText); + } else { + throw new Error('Invalid lookup attribute, lookup must be string or function.'); + } + } + }); + + if (_this2.current.collection.menuItemLimit) { + items = items.slice(0, _this2.current.collection.menuItemLimit); + } + + _this2.current.filteredItems = items; + + var ul = _this2.menu.querySelector('ul'); + + _this2.range.positionMenuAtCaret(scrollTo); + + if (!items.length) { + var noMatchEvent = new CustomEvent('tribute-no-match', { + detail: _this2.menu + }); + + _this2.current.element.dispatchEvent(noMatchEvent); + + if (typeof _this2.current.collection.noMatchTemplate === 'function' && !_this2.current.collection.noMatchTemplate() || !_this2.current.collection.noMatchTemplate) { + _this2.hideMenu(); + } else { + typeof _this2.current.collection.noMatchTemplate === 'function' ? ul.innerHTML = _this2.current.collection.noMatchTemplate() : ul.innerHTML = _this2.current.collection.noMatchTemplate; + } + + return; + } + + ul.innerHTML = ''; + + var fragment = _this2.range.getDocument().createDocumentFragment(); + + items.forEach(function (item, index) { + var li = _this2.range.getDocument().createElement('li'); + + li.setAttribute('data-index', index); + li.addEventListener('mousemove', function (e) { + var _this2$_findLiTarget = _this2._findLiTarget(e.target), + _this2$_findLiTarget2 = _slicedToArray(_this2$_findLiTarget, 2), + li = _this2$_findLiTarget2[0], + index = _this2$_findLiTarget2[1]; + + if (e.movementY !== 0) { + _this2.events.setActiveLi(index); + } + }); + + if (_this2.menuSelected === index) { + li.className = _this2.current.collection.selectClass; + } + + li.innerHTML = _this2.current.collection.menuItemTemplate(item); + fragment.appendChild(li); + }); + ul.appendChild(fragment); + }; + + if (typeof this.current.collection.values === 'function') { + this.current.collection.values(this.current.mentionText, processValues); + } else { + processValues(this.current.collection.values); + } + } + }, { + key: "_findLiTarget", + value: function _findLiTarget(el) { + if (!el) return []; + var index = el.getAttribute('data-index'); + return !index ? this._findLiTarget(el.parentNode) : [el, index]; + } + }, { + key: "showMenuForCollection", + value: function showMenuForCollection(element, collectionIndex) { + if (element !== document.activeElement) { + this.placeCaretAtEnd(element); + } + + this.current.collection = this.collection[collectionIndex || 0]; + this.current.externalTrigger = true; + this.current.element = element; + if (element.isContentEditable) this.insertTextAtCursor(this.current.collection.trigger);else this.insertAtCaret(element, this.current.collection.trigger); + this.showMenuFor(element); + } // TODO: make sure this works for inputs/textareas + + }, { + key: "placeCaretAtEnd", + value: function placeCaretAtEnd(el) { + el.focus(); + + if (typeof window.getSelection != "undefined" && typeof document.createRange != "undefined") { + var range = document.createRange(); + range.selectNodeContents(el); + range.collapse(false); + var sel = window.getSelection(); + sel.removeAllRanges(); + sel.addRange(range); + } else if (typeof document.body.createTextRange != "undefined") { + var textRange = document.body.createTextRange(); + textRange.moveToElementText(el); + textRange.collapse(false); + textRange.select(); + } + } // for contenteditable + + }, { + key: "insertTextAtCursor", + value: function insertTextAtCursor(text) { + var sel, range, html; + sel = window.getSelection(); + range = sel.getRangeAt(0); + range.deleteContents(); + var textNode = document.createTextNode(text); + range.insertNode(textNode); + range.selectNodeContents(textNode); + range.collapse(false); + sel.removeAllRanges(); + sel.addRange(range); + } // for regular inputs + + }, { + key: "insertAtCaret", + value: function insertAtCaret(textarea, text) { + var scrollPos = textarea.scrollTop; + var caretPos = textarea.selectionStart; + var front = textarea.value.substring(0, caretPos); + var back = textarea.value.substring(textarea.selectionEnd, textarea.value.length); + textarea.value = front + text + back; + caretPos = caretPos + text.length; + textarea.selectionStart = caretPos; + textarea.selectionEnd = caretPos; + textarea.focus(); + textarea.scrollTop = scrollPos; + } + }, { + key: "hideMenu", + value: function hideMenu() { + if (this.menu) { + this.menu.style.cssText = 'display: none;'; + this.isActive = false; + this.menuSelected = 0; + this.current = {}; + } + } + }, { + key: "selectItemAtIndex", + value: function selectItemAtIndex(index, originalEvent) { + index = parseInt(index); + if (typeof index !== 'number' || isNaN(index)) return; + var item = this.current.filteredItems[index]; + var content = this.current.collection.selectTemplate(item); + if (content !== null) this.replaceText(content, originalEvent, item); + } + }, { + key: "replaceText", + value: function replaceText(content, originalEvent, item) { + this.range.replaceTriggerText(content, true, true, originalEvent, item); + } + }, { + key: "_append", + value: function _append(collection, newValues, replace) { + if (typeof collection.values === 'function') { + throw new Error('Unable to append to values, as it is a function.'); + } else if (!replace) { + collection.values = collection.values.concat(newValues); + } else { + collection.values = newValues; + } + } + }, { + key: "append", + value: function append(collectionIndex, newValues, replace) { + var index = parseInt(collectionIndex); + if (typeof index !== 'number') throw new Error('please provide an index for the collection to update.'); + var collection = this.collection[index]; + + this._append(collection, newValues, replace); + } + }, { + key: "appendCurrent", + value: function appendCurrent(newValues, replace) { + if (this.isActive) { + this._append(this.current.collection, newValues, replace); + } else { + throw new Error('No active state. Please use append instead and pass an index.'); + } + } + }, { + key: "detach", + value: function detach(el) { + if (!el) { + throw new Error('[Tribute] Must pass in a DOM node or NodeList.'); + } // Check if it is a jQuery collection + + + if (typeof jQuery !== 'undefined' && el instanceof jQuery) { + el = el.get(); + } // Is el an Array/Array-like object? + + + if (el.constructor === NodeList || el.constructor === HTMLCollection || el.constructor === Array) { + var length = el.length; + + for (var i = 0; i < length; ++i) { + this._detach(el[i]); + } + } else { + this._detach(el); + } + } + }, { + key: "_detach", + value: function _detach(el) { + var _this3 = this; + + this.events.unbind(el); + + if (el.tributeMenu) { + this.menuEvents.unbind(el.tributeMenu); + } + + setTimeout(function () { + el.removeAttribute('data-tribute'); + _this3.isActive = false; + + if (el.tributeMenu) { + el.tributeMenu.remove(); + } + }); + } + }], [{ + key: "defaultSelectTemplate", + value: function defaultSelectTemplate(item) { + if (typeof item === 'undefined') return null; + + if (this.range.isContentEditable(this.current.element)) { + return '' + (this.current.collection.trigger + item.original[this.current.collection.fillAttr]) + ''; + } + + return this.current.collection.trigger + item.original[this.current.collection.fillAttr]; + } + }, { + key: "defaultMenuItemTemplate", + value: function defaultMenuItemTemplate(matchItem) { + return matchItem.string; + } + }, { + key: "inputTypes", + value: function inputTypes() { + return ['TEXTAREA', 'INPUT']; + } + }]); + + return Tribute; +}(); + +var _default = Tribute; +exports["default"] = _default; +module.exports = exports.default; + +},{"./TributeEvents":2,"./TributeMenuEvents":3,"./TributeRange":4,"./TributeSearch":5,"./utils":7}],2:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports["default"] = void 0; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +var TributeEvents = +/*#__PURE__*/ +function () { + function TributeEvents(tribute) { + _classCallCheck(this, TributeEvents); + + this.tribute = tribute; + this.tribute.events = this; + } + + _createClass(TributeEvents, [{ + key: "bind", + value: function bind(element) { + element.boundKeydown = this.keydown.bind(element, this); + element.boundKeyup = this.keyup.bind(element, this); + element.boundInput = this.input.bind(element, this); + element.addEventListener('keydown', element.boundKeydown, false); + element.addEventListener('keyup', element.boundKeyup, false); + element.addEventListener('input', element.boundInput, false); + } + }, { + key: "unbind", + value: function unbind(element) { + element.removeEventListener('keydown', element.boundKeydown, false); + element.removeEventListener('keyup', element.boundKeyup, false); + element.removeEventListener('input', element.boundInput, false); + delete element.boundKeydown; + delete element.boundKeyup; + delete element.boundInput; + } + }, { + key: "keydown", + value: function keydown(instance, event) { + if (instance.shouldDeactivate(event)) { + instance.tribute.isActive = false; + instance.tribute.hideMenu(); + } + + var element = this; + instance.commandEvent = false; + TributeEvents.keys().forEach(function (o) { + if (o.key === event.keyCode) { + instance.commandEvent = true; + instance.callbacks()[o.value.toLowerCase()](event, element); + } + }); + } + }, { + key: "input", + value: function input(instance, event) { + instance.inputEvent = true; + instance.keyup.call(this, instance, event); + } + }, { + key: "click", + value: function click(instance, event) { + var tribute = instance.tribute; + + if (tribute.menu && tribute.menu.contains(event.target)) { + var li = event.target; + event.preventDefault(); + event.stopPropagation(); + + while (li.nodeName.toLowerCase() !== 'li') { + li = li.parentNode; + + if (!li || li === tribute.menu) { + throw new Error('cannot find the
  • container for the click'); + } + } + + tribute.selectItemAtIndex(li.getAttribute('data-index'), event); + tribute.hideMenu(); // TODO: should fire with externalTrigger and target is outside of menu + } else if (tribute.current.element && !tribute.current.externalTrigger) { + tribute.current.externalTrigger = false; + setTimeout(function () { + return tribute.hideMenu(); + }); + } + } + }, { + key: "keyup", + value: function keyup(instance, event) { + if (instance.inputEvent) { + instance.inputEvent = false; + } + + instance.updateSelection(this); + if (event.keyCode === 27) return; + + if (!instance.tribute.allowSpaces && instance.tribute.hasTrailingSpace) { + instance.tribute.hasTrailingSpace = false; + instance.commandEvent = true; + instance.callbacks()["space"](event, this); + return; + } + + if (!instance.tribute.isActive) { + if (instance.tribute.autocompleteMode) { + instance.callbacks().triggerChar(event, this, ''); + } else { + var keyCode = instance.getKeyCode(instance, this, event); + if (isNaN(keyCode) || !keyCode) return; + var trigger = instance.tribute.triggers().find(function (trigger) { + return trigger.charCodeAt(0) === keyCode; + }); + + if (typeof trigger !== 'undefined') { + instance.callbacks().triggerChar(event, this, trigger); + } + } + } + + if ((instance.tribute.current.trigger || instance.tribute.autocompleteMode) && instance.commandEvent === false || instance.tribute.isActive && event.keyCode === 8) { + instance.tribute.showMenuFor(this, true); + } + } + }, { + key: "shouldDeactivate", + value: function shouldDeactivate(event) { + if (!this.tribute.isActive) return false; + + if (this.tribute.current.mentionText.length === 0) { + var eventKeyPressed = false; + TributeEvents.keys().forEach(function (o) { + if (event.keyCode === o.key) eventKeyPressed = true; + }); + return !eventKeyPressed; + } + + return false; + } + }, { + key: "getKeyCode", + value: function getKeyCode(instance, el, event) { + var _char; + + var tribute = instance.tribute; + var info = tribute.range.getTriggerInfo(false, tribute.hasTrailingSpace, true, tribute.allowSpaces, tribute.autocompleteMode); + + if (info) { + return info.mentionTriggerChar.charCodeAt(0); + } else { + return false; + } + } + }, { + key: "updateSelection", + value: function updateSelection(el) { + this.tribute.current.element = el; + var info = this.tribute.range.getTriggerInfo(false, this.tribute.hasTrailingSpace, true, this.tribute.allowSpaces, this.tribute.autocompleteMode); + + if (info) { + this.tribute.current.selectedPath = info.mentionSelectedPath; + this.tribute.current.mentionText = info.mentionText; + this.tribute.current.selectedOffset = info.mentionSelectedOffset; + } + } + }, { + key: "callbacks", + value: function callbacks() { + var _this = this; + + return { + triggerChar: function triggerChar(e, el, trigger) { + var tribute = _this.tribute; + tribute.current.trigger = trigger; + var collectionItem = tribute.collection.find(function (item) { + return item.trigger === trigger; + }); + tribute.current.collection = collectionItem; + if (tribute.inputEvent) tribute.showMenuFor(el, true); + }, + enter: function enter(e, el) { + // choose selection + if (_this.tribute.isActive && _this.tribute.current.filteredItems) { + e.preventDefault(); + e.stopPropagation(); + setTimeout(function () { + _this.tribute.selectItemAtIndex(_this.tribute.menuSelected, e); + + _this.tribute.hideMenu(); + }, 0); + } + }, + escape: function escape(e, el) { + if (_this.tribute.isActive) { + e.preventDefault(); + e.stopPropagation(); + _this.tribute.isActive = false; + + _this.tribute.hideMenu(); + } + }, + tab: function tab(e, el) { + // choose first match + _this.callbacks().enter(e, el); + }, + space: function space(e, el) { + if (_this.tribute.isActive) { + if (_this.tribute.spaceSelectsMatch) { + _this.callbacks().enter(e, el); + } else if (!_this.tribute.allowSpaces) { + e.stopPropagation(); + setTimeout(function () { + _this.tribute.hideMenu(); + + _this.tribute.isActive = false; + }, 0); + } + } + }, + up: function up(e, el) { + // navigate up ul + if (_this.tribute.isActive && _this.tribute.current.filteredItems) { + e.preventDefault(); + e.stopPropagation(); + var count = _this.tribute.current.filteredItems.length, + selected = _this.tribute.menuSelected; + + if (count > selected && selected > 0) { + _this.tribute.menuSelected--; + + _this.setActiveLi(); + } else if (selected === 0) { + _this.tribute.menuSelected = count - 1; + + _this.setActiveLi(); + + _this.tribute.menu.scrollTop = _this.tribute.menu.scrollHeight; + } + } + }, + down: function down(e, el) { + // navigate down ul + if (_this.tribute.isActive && _this.tribute.current.filteredItems) { + e.preventDefault(); + e.stopPropagation(); + var count = _this.tribute.current.filteredItems.length - 1, + selected = _this.tribute.menuSelected; + + if (count > selected) { + _this.tribute.menuSelected++; + + _this.setActiveLi(); + } else if (count === selected) { + _this.tribute.menuSelected = 0; + + _this.setActiveLi(); + + _this.tribute.menu.scrollTop = 0; + } + } + }, + "delete": function _delete(e, el) { + if (_this.tribute.isActive && _this.tribute.current.mentionText.length < 1) { + _this.tribute.hideMenu(); + } else if (_this.tribute.isActive) { + _this.tribute.showMenuFor(el); + } + } + }; + } + }, { + key: "setActiveLi", + value: function setActiveLi(index) { + var lis = this.tribute.menu.querySelectorAll('li'), + length = lis.length >>> 0; + if (index) this.tribute.menuSelected = parseInt(index); + + for (var i = 0; i < length; i++) { + var li = lis[i]; + + if (i === this.tribute.menuSelected) { + li.classList.add(this.tribute.current.collection.selectClass); + var liClientRect = li.getBoundingClientRect(); + var menuClientRect = this.tribute.menu.getBoundingClientRect(); + + if (liClientRect.bottom > menuClientRect.bottom) { + var scrollDistance = liClientRect.bottom - menuClientRect.bottom; + this.tribute.menu.scrollTop += scrollDistance; + } else if (liClientRect.top < menuClientRect.top) { + var _scrollDistance = menuClientRect.top - liClientRect.top; + + this.tribute.menu.scrollTop -= _scrollDistance; + } + } else { + li.classList.remove(this.tribute.current.collection.selectClass); + } + } + } + }, { + key: "getFullHeight", + value: function getFullHeight(elem, includeMargin) { + var height = elem.getBoundingClientRect().height; + + if (includeMargin) { + var style = elem.currentStyle || window.getComputedStyle(elem); + return height + parseFloat(style.marginTop) + parseFloat(style.marginBottom); + } + + return height; + } + }], [{ + key: "keys", + value: function keys() { + return [{ + key: 9, + value: 'TAB' + }, { + key: 8, + value: 'DELETE' + }, { + key: 13, + value: 'ENTER' + }, { + key: 27, + value: 'ESCAPE' + }, { + key: 32, + value: 'SPACE' + }, { + key: 38, + value: 'UP' + }, { + key: 40, + value: 'DOWN' + }]; + } + }]); + + return TributeEvents; +}(); + +var _default = TributeEvents; +exports["default"] = _default; +module.exports = exports.default; + +},{}],3:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports["default"] = void 0; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +var TributeMenuEvents = +/*#__PURE__*/ +function () { + function TributeMenuEvents(tribute) { + _classCallCheck(this, TributeMenuEvents); + + this.tribute = tribute; + this.tribute.menuEvents = this; + this.menu = this.tribute.menu; + } + + _createClass(TributeMenuEvents, [{ + key: "bind", + value: function bind(menu) { + var _this = this; + + this.menuClickEvent = this.tribute.events.click.bind(null, this); + this.menuContainerScrollEvent = this.debounce(function () { + if (_this.tribute.isActive) { + _this.tribute.showMenuFor(_this.tribute.current.element, false); + } + }, 300, false); + this.windowResizeEvent = this.debounce(function () { + if (_this.tribute.isActive) { + _this.tribute.range.positionMenuAtCaret(true); + } + }, 300, false); // fixes IE11 issues with mousedown + + this.tribute.range.getDocument().addEventListener('MSPointerDown', this.menuClickEvent, false); + this.tribute.range.getDocument().addEventListener('mousedown', this.menuClickEvent, false); + window.addEventListener('resize', this.windowResizeEvent); + + if (this.menuContainer) { + this.menuContainer.addEventListener('scroll', this.menuContainerScrollEvent, false); + } else { + window.addEventListener('scroll', this.menuContainerScrollEvent); + } + } + }, { + key: "unbind", + value: function unbind(menu) { + this.tribute.range.getDocument().removeEventListener('mousedown', this.menuClickEvent, false); + this.tribute.range.getDocument().removeEventListener('MSPointerDown', this.menuClickEvent, false); + window.removeEventListener('resize', this.windowResizeEvent); + + if (this.menuContainer) { + this.menuContainer.removeEventListener('scroll', this.menuContainerScrollEvent, false); + } else { + window.removeEventListener('scroll', this.menuContainerScrollEvent); + } + } + }, { + key: "debounce", + value: function debounce(func, wait, immediate) { + var _this2 = this, + _arguments = arguments; + + var timeout; + return function () { + var context = _this2, + args = _arguments; + + var later = function later() { + timeout = null; + if (!immediate) func.apply(context, args); + }; + + var callNow = immediate && !timeout; + clearTimeout(timeout); + timeout = setTimeout(later, wait); + if (callNow) func.apply(context, args); + }; + } + }]); + + return TributeMenuEvents; +}(); + +var _default = TributeMenuEvents; +exports["default"] = _default; +module.exports = exports.default; + +},{}],4:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports["default"] = void 0; + +require("./utils"); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +var TributeRange = +/*#__PURE__*/ +function () { + function TributeRange(tribute) { + _classCallCheck(this, TributeRange); + + this.tribute = tribute; + this.tribute.range = this; + } + + _createClass(TributeRange, [{ + key: "getDocument", + value: function getDocument() { + var iframe; + + if (this.tribute.current.collection) { + iframe = this.tribute.current.collection.iframe; + } + + if (!iframe) { + return document; + } + + return iframe.contentWindow.document; + } + }, { + key: "positionMenuAtCaret", + value: function positionMenuAtCaret(scrollTo) { + var _this = this; + + var context = this.tribute.current, + coordinates; + var info = this.getTriggerInfo(false, this.tribute.hasTrailingSpace, true, this.tribute.allowSpaces, this.tribute.autocompleteMode); + + if (typeof info !== 'undefined') { + if (!this.tribute.positionMenu) { + this.tribute.menu.style.cssText = "display: block;"; + return; + } + + if (!this.isContentEditable(context.element)) { + coordinates = this.getTextAreaOrInputUnderlinePosition(this.tribute.current.element, info.mentionPosition); + } else { + coordinates = this.getContentEditableCaretPosition(info.mentionPosition); + } + + this.tribute.menu.style.cssText = "top: ".concat(coordinates.top, "px;\n left: ").concat(coordinates.left, "px;\n right: ").concat(coordinates.right, "px;\n bottom: ").concat(coordinates.bottom, "px;\n position: absolute;\n display: block;"); + + if (coordinates.left === 'auto') { + this.tribute.menu.style.left = 'auto'; + } + + if (coordinates.top === 'auto') { + this.tribute.menu.style.top = 'auto'; + } + + if (scrollTo) this.scrollIntoView(); + window.setTimeout(function () { + var menuDimensions = { + width: _this.tribute.menu.offsetWidth, + height: _this.tribute.menu.offsetHeight + }; + + var menuIsOffScreen = _this.isMenuOffScreen(coordinates, menuDimensions); + + var menuIsOffScreenHorizontally = window.innerWidth > menuDimensions.width && (menuIsOffScreen.left || menuIsOffScreen.right); + var menuIsOffScreenVertically = window.innerHeight > menuDimensions.height && (menuIsOffScreen.top || menuIsOffScreen.bottom); + + if (menuIsOffScreenHorizontally || menuIsOffScreenVertically) { + _this.tribute.menu.style.cssText = 'display: none'; + + _this.positionMenuAtCaret(scrollTo); + } + }, 0); + } else { + this.tribute.menu.style.cssText = 'display: none'; + } + } + }, { + key: "selectElement", + value: function selectElement(targetElement, path, offset) { + var range; + var elem = targetElement; + + if (path) { + for (var i = 0; i < path.length; i++) { + elem = elem.childNodes[path[i]]; + + if (elem === undefined) { + return; + } + + while (elem.length < offset) { + offset -= elem.length; + elem = elem.nextSibling; + } + + if (elem.childNodes.length === 0 && !elem.length) { + elem = elem.previousSibling; + } + } + } + + var sel = this.getWindowSelection(); + range = this.getDocument().createRange(); + range.setStart(elem, offset); + range.setEnd(elem, offset); + range.collapse(true); + + try { + sel.removeAllRanges(); + } catch (error) {} + + sel.addRange(range); + targetElement.focus(); + } + }, { + key: "replaceTriggerText", + value: function replaceTriggerText(text, requireLeadingSpace, hasTrailingSpace, originalEvent, item) { + var info = this.getTriggerInfo(true, hasTrailingSpace, requireLeadingSpace, this.tribute.allowSpaces, this.tribute.autocompleteMode); + + if (info !== undefined) { + var context = this.tribute.current; + var replaceEvent = new CustomEvent('tribute-replaced', { + detail: { + item: item, + instance: context, + context: info, + event: originalEvent + } + }); + + if (!this.isContentEditable(context.element)) { + var myField = this.tribute.current.element; + var textSuffix = typeof this.tribute.replaceTextSuffix == 'string' ? this.tribute.replaceTextSuffix : ' '; + text += textSuffix; + var startPos = info.mentionPosition; + var endPos = info.mentionPosition + info.mentionText.length + textSuffix.length; + + if (!this.tribute.autocompleteMode) { + endPos += info.mentionTriggerChar.length - 1; + } + + myField.value = myField.value.substring(0, startPos) + text + myField.value.substring(endPos, myField.value.length); + myField.selectionStart = startPos + text.length; + myField.selectionEnd = startPos + text.length; + } else { + // add a space to the end of the pasted text + var _textSuffix = typeof this.tribute.replaceTextSuffix == 'string' ? this.tribute.replaceTextSuffix : '\xA0'; + + text += _textSuffix; + + var _endPos = info.mentionPosition + info.mentionText.length; + + if (!this.tribute.autocompleteMode) { + _endPos += info.mentionTriggerChar.length; + } + + this.pasteHtml(text, info.mentionPosition, _endPos); + } + + context.element.dispatchEvent(new CustomEvent('input', { + bubbles: true + })); + context.element.dispatchEvent(replaceEvent); + } + } + }, { + key: "pasteHtml", + value: function pasteHtml(html, startPos, endPos) { + var range, sel; + sel = this.getWindowSelection(); + range = this.getDocument().createRange(); + range.setStart(sel.anchorNode, startPos); + range.setEnd(sel.anchorNode, endPos); + range.deleteContents(); + var el = this.getDocument().createElement('div'); + el.innerHTML = html; + var frag = this.getDocument().createDocumentFragment(), + node, + lastNode; + + while (node = el.firstChild) { + lastNode = frag.appendChild(node); + } + + range.insertNode(frag); // Preserve the selection + + if (lastNode) { + range = range.cloneRange(); + range.setStartAfter(lastNode); + range.collapse(true); + sel.removeAllRanges(); + sel.addRange(range); + } + } + }, { + key: "getWindowSelection", + value: function getWindowSelection() { + if (this.tribute.collection.iframe) { + return this.tribute.collection.iframe.contentWindow.getSelection(); + } + + return window.getSelection(); + } + }, { + key: "getNodePositionInParent", + value: function getNodePositionInParent(element) { + if (element.parentNode === null) { + return 0; + } + + for (var i = 0; i < element.parentNode.childNodes.length; i++) { + var node = element.parentNode.childNodes[i]; + + if (node === element) { + return i; + } + } + } + }, { + key: "getContentEditableSelectedPath", + value: function getContentEditableSelectedPath(ctx) { + var sel = this.getWindowSelection(); + var selected = sel.anchorNode; + var path = []; + var offset; + + if (selected != null) { + var i; + var ce = selected.contentEditable; + + while (selected !== null && ce !== 'true') { + i = this.getNodePositionInParent(selected); + path.push(i); + selected = selected.parentNode; + + if (selected !== null) { + ce = selected.contentEditable; + } + } + + path.reverse(); // getRangeAt may not exist, need alternative + + offset = sel.getRangeAt(0).startOffset; + return { + selected: selected, + path: path, + offset: offset + }; + } + } + }, { + key: "getTextPrecedingCurrentSelection", + value: function getTextPrecedingCurrentSelection() { + var context = this.tribute.current, + text = ''; + + if (!this.isContentEditable(context.element)) { + var textComponent = this.tribute.current.element; + + if (textComponent) { + var startPos = textComponent.selectionStart; + + if (textComponent.value && startPos >= 0) { + text = textComponent.value.substring(0, startPos); + } + } + } else { + var selectedElem = this.getWindowSelection().anchorNode; + + if (selectedElem != null) { + var workingNodeContent = selectedElem.textContent; + var selectStartOffset = this.getWindowSelection().getRangeAt(0).startOffset; + + if (workingNodeContent && selectStartOffset >= 0) { + text = workingNodeContent.substring(0, selectStartOffset); + } + } + } + + return text; + } + }, { + key: "getLastWordInText", + value: function getLastWordInText(text) { + text = text.replace(/\u00A0/g, ' '); // https://stackoverflow.com/questions/29850407/how-do-i-replace-unicode-character-u00a0-with-a-space-in-javascript + + var wordsArray = text.split(/\s+/); + var worldsCount = wordsArray.length - 1; + return wordsArray[worldsCount].trim(); + } + }, { + key: "getTriggerInfo", + value: function getTriggerInfo(menuAlreadyActive, hasTrailingSpace, requireLeadingSpace, allowSpaces, isAutocomplete) { + var _this2 = this; + + var ctx = this.tribute.current; + var selected, path, offset; + + if (!this.isContentEditable(ctx.element)) { + selected = this.tribute.current.element; + } else { + var selectionInfo = this.getContentEditableSelectedPath(ctx); + + if (selectionInfo) { + selected = selectionInfo.selected; + path = selectionInfo.path; + offset = selectionInfo.offset; + } + } + + var effectiveRange = this.getTextPrecedingCurrentSelection(); + var lastWordOfEffectiveRange = this.getLastWordInText(effectiveRange); + + if (isAutocomplete) { + return { + mentionPosition: effectiveRange.length - lastWordOfEffectiveRange.length, + mentionText: lastWordOfEffectiveRange, + mentionSelectedElement: selected, + mentionSelectedPath: path, + mentionSelectedOffset: offset + }; + } + + if (effectiveRange !== undefined && effectiveRange !== null) { + var mostRecentTriggerCharPos = -1; + var triggerChar; + this.tribute.collection.forEach(function (config) { + var c = config.trigger; + var idx = config.requireLeadingSpace ? _this2.lastIndexWithLeadingSpace(effectiveRange, c) : effectiveRange.lastIndexOf(c); + + if (idx > mostRecentTriggerCharPos) { + mostRecentTriggerCharPos = idx; + triggerChar = c; + requireLeadingSpace = config.requireLeadingSpace; + } + }); + + if (mostRecentTriggerCharPos >= 0 && (mostRecentTriggerCharPos === 0 || !requireLeadingSpace || /[\xA0\s]/g.test(effectiveRange.substring(mostRecentTriggerCharPos - 1, mostRecentTriggerCharPos)))) { + var currentTriggerSnippet = effectiveRange.substring(mostRecentTriggerCharPos + triggerChar.length, effectiveRange.length); + triggerChar = effectiveRange.substring(mostRecentTriggerCharPos, mostRecentTriggerCharPos + triggerChar.length); + var firstSnippetChar = currentTriggerSnippet.substring(0, 1); + var leadingSpace = currentTriggerSnippet.length > 0 && (firstSnippetChar === ' ' || firstSnippetChar === '\xA0'); + + if (hasTrailingSpace) { + currentTriggerSnippet = currentTriggerSnippet.trim(); + } + + var regex = allowSpaces ? /[^\S ]/g : /[\xA0\s]/g; + this.tribute.hasTrailingSpace = regex.test(currentTriggerSnippet); + + if (!leadingSpace && (menuAlreadyActive || !regex.test(currentTriggerSnippet))) { + return { + mentionPosition: mostRecentTriggerCharPos, + mentionText: currentTriggerSnippet, + mentionSelectedElement: selected, + mentionSelectedPath: path, + mentionSelectedOffset: offset, + mentionTriggerChar: triggerChar + }; + } + } + } + } + }, { + key: "lastIndexWithLeadingSpace", + value: function lastIndexWithLeadingSpace(str, trigger) { + var reversedStr = str.split('').reverse().join(''); + var index = -1; + + for (var cidx = 0, len = str.length; cidx < len; cidx++) { + var firstChar = cidx === str.length - 1; + var leadingSpace = /\s/.test(reversedStr[cidx + 1]); + var match = true; + + for (var triggerIdx = trigger.length - 1; triggerIdx >= 0; triggerIdx--) { + if (trigger[triggerIdx] !== reversedStr[cidx - triggerIdx]) { + match = false; + break; + } + } + + if (match && (firstChar || leadingSpace)) { + index = str.length - 1 - cidx; + break; + } + } + + return index; + } + }, { + key: "isContentEditable", + value: function isContentEditable(element) { + return element.nodeName !== 'INPUT' && element.nodeName !== 'TEXTAREA'; + } + }, { + key: "isMenuOffScreen", + value: function isMenuOffScreen(coordinates, menuDimensions) { + var windowWidth = window.innerWidth; + var windowHeight = window.innerHeight; + var doc = document.documentElement; + var windowLeft = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0); + var windowTop = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0); + var menuTop = typeof coordinates.top === 'number' ? coordinates.top : windowTop + windowHeight - coordinates.bottom - menuDimensions.height; + var menuRight = typeof coordinates.right === 'number' ? coordinates.right : coordinates.left + menuDimensions.width; + var menuBottom = typeof coordinates.bottom === 'number' ? coordinates.bottom : coordinates.top + menuDimensions.height; + var menuLeft = typeof coordinates.left === 'number' ? coordinates.left : windowLeft + windowWidth - coordinates.right - menuDimensions.width; + return { + top: menuTop < Math.floor(windowTop), + right: menuRight > Math.ceil(windowLeft + windowWidth), + bottom: menuBottom > Math.ceil(windowTop + windowHeight), + left: menuLeft < Math.floor(windowLeft) + }; + } + }, { + key: "getMenuDimensions", + value: function getMenuDimensions() { + // Width of the menu depends of its contents and position + // We must check what its width would be without any obstruction + // This way, we can achieve good positioning for flipping the menu + var dimensions = { + width: null, + height: null + }; + this.tribute.menu.style.cssText = "top: 0px;\n left: 0px;\n position: fixed;\n display: block;\n visibility; hidden;"; + dimensions.width = this.tribute.menu.offsetWidth; + dimensions.height = this.tribute.menu.offsetHeight; + this.tribute.menu.style.cssText = "display: none;"; + return dimensions; + } + }, { + key: "getTextAreaOrInputUnderlinePosition", + value: function getTextAreaOrInputUnderlinePosition(element, position, flipped) { + var properties = ['direction', 'boxSizing', 'width', 'height', 'overflowX', 'overflowY', 'borderTopWidth', 'borderRightWidth', 'borderBottomWidth', 'borderLeftWidth', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'fontStyle', 'fontVariant', 'fontWeight', 'fontStretch', 'fontSize', 'fontSizeAdjust', 'lineHeight', 'fontFamily', 'textAlign', 'textTransform', 'textIndent', 'textDecoration', 'letterSpacing', 'wordSpacing']; + var isFirefox = window.mozInnerScreenX !== null; + var div = this.getDocument().createElement('div'); + div.id = 'input-textarea-caret-position-mirror-div'; + this.getDocument().body.appendChild(div); + var style = div.style; + var computed = window.getComputedStyle ? getComputedStyle(element) : element.currentStyle; + style.whiteSpace = 'pre-wrap'; + + if (element.nodeName !== 'INPUT') { + style.wordWrap = 'break-word'; + } // position off-screen + + + style.position = 'absolute'; + style.visibility = 'hidden'; // transfer the element's properties to the div + + properties.forEach(function (prop) { + style[prop] = computed[prop]; + }); + + if (isFirefox) { + style.width = "".concat(parseInt(computed.width) - 2, "px"); + if (element.scrollHeight > parseInt(computed.height)) style.overflowY = 'scroll'; + } else { + style.overflow = 'hidden'; + } + + div.textContent = element.value.substring(0, position); + + if (element.nodeName === 'INPUT') { + div.textContent = div.textContent.replace(/\s/g, ' '); + } + + var span = this.getDocument().createElement('span'); + span.textContent = element.value.substring(position) || '.'; + div.appendChild(span); + var rect = element.getBoundingClientRect(); + var doc = document.documentElement; + var windowLeft = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0); + var windowTop = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0); + var top = 0; + var left = 0; + + if (this.menuContainerIsBody) { + top = rect.top; + left = rect.left; + } + + var coordinates = { + top: top + windowTop + span.offsetTop + parseInt(computed.borderTopWidth) + parseInt(computed.fontSize) - element.scrollTop, + left: left + windowLeft + span.offsetLeft + parseInt(computed.borderLeftWidth) + }; + var windowWidth = window.innerWidth; + var windowHeight = window.innerHeight; + var menuDimensions = this.getMenuDimensions(); + var menuIsOffScreen = this.isMenuOffScreen(coordinates, menuDimensions); + + if (menuIsOffScreen.right) { + coordinates.right = windowWidth - coordinates.left; + coordinates.left = 'auto'; + } + + var parentHeight = this.tribute.menuContainer ? this.tribute.menuContainer.offsetHeight : this.getDocument().body.offsetHeight; + + if (menuIsOffScreen.bottom) { + var parentRect = this.tribute.menuContainer ? this.tribute.menuContainer.getBoundingClientRect() : this.getDocument().body.getBoundingClientRect(); + var scrollStillAvailable = parentHeight - (windowHeight - parentRect.top); + coordinates.bottom = scrollStillAvailable + (windowHeight - rect.top - span.offsetTop); + coordinates.top = 'auto'; + } + + menuIsOffScreen = this.isMenuOffScreen(coordinates, menuDimensions); + + if (menuIsOffScreen.left) { + coordinates.left = windowWidth > menuDimensions.width ? windowLeft + windowWidth - menuDimensions.width : windowLeft; + delete coordinates.right; + } + + if (menuIsOffScreen.top) { + coordinates.top = windowHeight > menuDimensions.height ? windowTop + windowHeight - menuDimensions.height : windowTop; + delete coordinates.bottom; + } + + this.getDocument().body.removeChild(div); + return coordinates; + } + }, { + key: "getContentEditableCaretPosition", + value: function getContentEditableCaretPosition(selectedNodePosition) { + var markerTextChar = ''; + var markerEl, + markerId = "sel_".concat(new Date().getTime(), "_").concat(Math.random().toString().substr(2)); + var range; + var sel = this.getWindowSelection(); + var prevRange = sel.getRangeAt(0); + range = this.getDocument().createRange(); + range.setStart(sel.anchorNode, selectedNodePosition); + range.setEnd(sel.anchorNode, selectedNodePosition); + range.collapse(false); // Create the marker element containing a single invisible character using DOM methods and insert it + + markerEl = this.getDocument().createElement('span'); + markerEl.id = markerId; + markerEl.appendChild(this.getDocument().createTextNode(markerTextChar)); + range.insertNode(markerEl); + sel.removeAllRanges(); + sel.addRange(prevRange); + var rect = markerEl.getBoundingClientRect(); + var doc = document.documentElement; + var windowLeft = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0); + var windowTop = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0); + var left = 0; + var top = 0; + + if (this.menuContainerIsBody) { + left = rect.left; + top = rect.top; + } else { + left = markerEl.offsetLeft; + top = markerEl.offsetTop; + } + + var coordinates = { + left: left + windowLeft, + top: top + markerEl.offsetHeight + windowTop + }; + var windowWidth = window.innerWidth; + var windowHeight = window.innerHeight; + var menuDimensions = this.getMenuDimensions(); + var menuIsOffScreen = this.isMenuOffScreen(coordinates, menuDimensions); + + if (menuIsOffScreen.right) { + coordinates.left = 'auto'; + coordinates.right = windowWidth - rect.left - windowLeft; + } + + var parentHeight = this.tribute.menuContainer ? this.tribute.menuContainer.offsetHeight : this.getDocument().body.offsetHeight; + + if (menuIsOffScreen.bottom) { + var parentRect = this.tribute.menuContainer ? this.tribute.menuContainer.getBoundingClientRect() : this.getDocument().body.getBoundingClientRect(); + var scrollStillAvailable = parentHeight - (windowHeight - parentRect.top); + coordinates.top = 'auto'; + coordinates.bottom = scrollStillAvailable + (windowHeight - rect.top); + } + + menuIsOffScreen = this.isMenuOffScreen(coordinates, menuDimensions); + + if (menuIsOffScreen.left) { + coordinates.left = windowWidth > menuDimensions.width ? windowLeft + windowWidth - menuDimensions.width : windowLeft; + delete coordinates.right; + } + + if (menuIsOffScreen.top) { + coordinates.top = windowHeight > menuDimensions.height ? windowTop + windowHeight - menuDimensions.height : windowTop; + delete coordinates.bottom; + } + + markerEl.parentNode.removeChild(markerEl); + return coordinates; + } + }, { + key: "scrollIntoView", + value: function scrollIntoView(elem) { + var reasonableBuffer = 20, + clientRect; + var maxScrollDisplacement = 100; + var e = this.menu; + if (typeof e === 'undefined') return; + + while (clientRect === undefined || clientRect.height === 0) { + clientRect = e.getBoundingClientRect(); + + if (clientRect.height === 0) { + e = e.childNodes[0]; + + if (e === undefined || !e.getBoundingClientRect) { + return; + } + } + } + + var elemTop = clientRect.top; + var elemBottom = elemTop + clientRect.height; + + if (elemTop < 0) { + window.scrollTo(0, window.pageYOffset + clientRect.top - reasonableBuffer); + } else if (elemBottom > window.innerHeight) { + var maxY = window.pageYOffset + clientRect.top - reasonableBuffer; + + if (maxY - window.pageYOffset > maxScrollDisplacement) { + maxY = window.pageYOffset + maxScrollDisplacement; + } + + var targetY = window.pageYOffset - (window.innerHeight - elemBottom); + + if (targetY > maxY) { + targetY = maxY; + } + + window.scrollTo(0, targetY); + } + } + }, { + key: "menuContainerIsBody", + get: function get() { + return this.tribute.menuContainer === document.body || !this.tribute.menuContainer; + } + }]); + + return TributeRange; +}(); + +var _default = TributeRange; +exports["default"] = _default; +module.exports = exports.default; + +},{"./utils":7}],5:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports["default"] = void 0; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +// Thanks to https://github.com/mattyork/fuzzy +var TributeSearch = +/*#__PURE__*/ +function () { + function TributeSearch(tribute) { + _classCallCheck(this, TributeSearch); + + this.tribute = tribute; + this.tribute.search = this; + } + + _createClass(TributeSearch, [{ + key: "simpleFilter", + value: function simpleFilter(pattern, array) { + var _this = this; + + return array.filter(function (string) { + return _this.test(pattern, string); + }); + } + }, { + key: "test", + value: function test(pattern, string) { + return this.match(pattern, string) !== null; + } + }, { + key: "match", + value: function match(pattern, string, opts) { + opts = opts || {}; + var patternIdx = 0, + result = [], + len = string.length, + totalScore = 0, + currScore = 0, + pre = opts.pre || '', + post = opts.post || '', + compareString = opts.caseSensitive && string || string.toLowerCase(), + ch, + compareChar; + + if (opts.skip) { + return { + rendered: string, + score: 0 + }; + } + + pattern = opts.caseSensitive && pattern || pattern.toLowerCase(); + var patternCache = this.traverse(compareString, pattern, 0, 0, []); + + if (!patternCache) { + return null; + } + + return { + rendered: this.render(string, patternCache.cache, pre, post), + score: patternCache.score + }; + } + }, { + key: "traverse", + value: function traverse(string, pattern, stringIndex, patternIndex, patternCache) { + // if the pattern search at end + if (pattern.length === patternIndex) { + // calculate score and copy the cache containing the indices where it's found + return { + score: this.calculateScore(patternCache), + cache: patternCache.slice() + }; + } // if string at end or remaining pattern > remaining string + + + if (string.length === stringIndex || pattern.length - patternIndex > string.length - stringIndex) { + return undefined; + } + + var c = pattern[patternIndex]; + var index = string.indexOf(c, stringIndex); + var best, temp; + + while (index > -1) { + patternCache.push(index); + temp = this.traverse(string, pattern, index + 1, patternIndex + 1, patternCache); + patternCache.pop(); // if downstream traversal failed, return best answer so far + + if (!temp) { + return best; + } + + if (!best || best.score < temp.score) { + best = temp; + } + + index = string.indexOf(c, index + 1); + } + + return best; + } + }, { + key: "calculateScore", + value: function calculateScore(patternCache) { + var score = 0; + var temp = 1; + patternCache.forEach(function (index, i) { + if (i > 0) { + if (patternCache[i - 1] + 1 === index) { + temp += temp + 1; + } else { + temp = 1; + } + } + + score += temp; + }); + return score; + } + }, { + key: "render", + value: function render(string, indices, pre, post) { + var rendered = string.substring(0, indices[0]); + indices.forEach(function (index, i) { + rendered += pre + string[index] + post + string.substring(index + 1, indices[i + 1] ? indices[i + 1] : string.length); + }); + return rendered; + } + }, { + key: "filter", + value: function filter(pattern, arr, opts) { + var _this2 = this; + + opts = opts || {}; + return arr.reduce(function (prev, element, idx, arr) { + var str = element; + + if (opts.extract) { + str = opts.extract(element); + + if (!str) { + // take care of undefineds / nulls / etc. + str = ''; + } + } + + var rendered = _this2.match(pattern, str, opts); + + if (rendered != null) { + prev[prev.length] = { + string: rendered.rendered, + score: rendered.score, + index: idx, + original: element + }; + } + + return prev; + }, []).sort(function (a, b) { + var compare = b.score - a.score; + if (compare) return compare; + return a.index - b.index; + }); + } + }]); + + return TributeSearch; +}(); + +var _default = TributeSearch; +exports["default"] = _default; +module.exports = exports.default; + +},{}],6:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports["default"] = void 0; + +var _Tribute = _interopRequireDefault(require("./Tribute")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } + +/** +* Tribute.js +* Native ES6 JavaScript @mention Plugin +**/ +var _default = _Tribute["default"]; +exports["default"] = _default; +module.exports = exports.default; + +},{"./Tribute":1}],7:[function(require,module,exports){ +"use strict"; + +if (!Array.prototype.find) { + Array.prototype.find = function (predicate) { + if (this === null) { + throw new TypeError('Array.prototype.find called on null or undefined'); + } + + if (typeof predicate !== 'function') { + throw new TypeError('predicate must be a function'); + } + + var list = Object(this); + var length = list.length >>> 0; + var thisArg = arguments[1]; + var value; + + for (var i = 0; i < length; i++) { + value = list[i]; + + if (predicate.call(thisArg, value, i, list)) { + return value; + } + } + + return undefined; + }; +} + +if (window && typeof window.CustomEvent !== "function") { + var CustomEvent = function CustomEvent(event, params) { + params = params || { + bubbles: false, + cancelable: false, + detail: undefined + }; + var evt = document.createEvent('CustomEvent'); + evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); + return evt; + }; + + if (typeof window.Event !== 'undefined') { + CustomEvent.prototype = window.Event.prototype; + } + + window.CustomEvent = CustomEvent; +} + +},{}]},{},[6])(6) +}); +//# sourceMappingURL=tribute.js.map diff --git a/dist/tribute.js.map b/dist/tribute.js.map index 9c30f26b..b392107f 100644 --- a/dist/tribute.js.map +++ b/dist/tribute.js.map @@ -11,17 +11,17 @@ "src/utils.js" ], "names": [], - "mappings": "AAAA;;;;;;;;ACAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;IAEM,O;;;AACF,yBAoBG;AAAA;;AAAA,2BAnBC,MAmBD;AAAA,QAnBC,MAmBD,4BAnBU,IAmBV;AAAA,2BAlBC,MAkBD;AAAA,QAlBC,MAkBD,4BAlBU,IAkBV;AAAA,gCAjBC,WAiBD;AAAA,QAjBC,WAiBD,iCAjBe,WAiBf;AAAA,4BAhBC,OAgBD;AAAA,QAhBC,OAgBD,6BAhBW,GAgBX;AAAA,qCAfC,gBAeD;AAAA,QAfC,gBAeD,sCAfoB,KAepB;AAAA,mCAdC,cAcD;AAAA,QAdC,cAcD,oCAdkB,IAclB;AAAA,qCAbC,gBAaD;AAAA,QAbC,gBAaD,sC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AA,MAAM,EAAE;AAHS,KAAnB;AAKA,QAAI,GAAG,GAAG,QAAQ,CAAC,WAAT,CAAqB,aAArB,CAAV;AACA,IAAA,GAAG,CAAC,eAAJ,CAAoB,KAApB,EAA2B,MAAM,CAAC,OAAlC,EAA2C,MAAM,CAAC,UAAlD,EAA8D,MAAM,CAAC,MAArE;AACA,WAAO,GAAP;AACD,GAVqD;;AAYvD,MAAI,OAAO,MAAM,CAAC,KAAd,KAAwB,WAA5B,EAAyC;AACvC,IAAA,WAAW,CAAC,SAAZ,GAAwB,MAAM,CAAC,KAAP,CAAa,SAArC;AACD;;AAEA,EAAA,MAAM,CAAC,WAAP,GAAqB,WAArB;AACD", "file": "generated.js", "sourceRoot": "", "sourcesContent": [ "(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c=\"function\"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error(\"Cannot find module '\"+i+\"'\");throw a.code=\"MODULE_NOT_FOUND\",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u=\"function\"==typeof require&&require,i=0;i {\r\n if (typeof t === 'function') {\r\n return t.bind(this)\r\n }\r\n\r\n return noMatchTemplate || function () {return ''}.bind(this)\r\n })(noMatchTemplate),\r\n\r\n // column to search against in the object\r\n lookup: lookup,\r\n\r\n // column that contains the content to insert by default\r\n fillAttr: fillAttr,\r\n\r\n // array of objects or a function returning an array of objects\r\n values: values,\r\n\r\n requireLeadingSpace: requireLeadingSpace,\r\n\r\n searchOpts: searchOpts,\r\n\r\n menuItemLimit: menuItemLimit,\r\n }]\r\n }\r\n else if (collection) {\r\n if (this.autocompleteMode)\r\n console.warn('Tribute in autocomplete mode does not work for collections')\r\n this.collection = collection.map(item => {\r\n return {\r\n trigger: item.trigger || trigger,\r\n iframe: item.iframe || iframe,\r\n selectClass: item.selectClass || selectClass,\r\n selectTemplate: (item.selectTemplate || Tribute.defaultSelectTemplate).bind(this),\r\n menuItemTemplate: (item.menuItemTemplate || Tribute.defaultMenuItemTemplate).bind(this),\r\n // function called when menu is empty, disables hiding of menu.\r\n noMatchTemplate: (t => {\r\n if (typeof t === 'function') {\r\n return t.bind(this)\r\n }\r\n\r\n return null\r\n })(noMatchTemplate),\r\n lookup: item.lookup || lookup,\r\n fillAttr: item.fillAttr || fillAttr,\r\n values: item.values,\r\n requireLeadingSpace: item.requireLeadingSpace,\r\n searchOpts: item.searchOpts || searchOpts,\r\n menuItemLimit: item.menuItemLimit || menuItemLimit,\r\n }\r\n })\r\n }\r\n else {\r\n throw new Error('[Tribute] No collection specified.')\r\n }\r\n\r\n new TributeRange(this)\r\n new TributeEvents(this)\r\n new TributeMenuEvents(this)\r\n new TributeSearch(this)\r\n }\r\n\r\n static defaultSelectTemplate(item) {\r\n if (typeof item === 'undefined') return null;\r\n if (this.range.isContentEditable(this.current.element)) {\r\n return '' + (this.current.collection.trigger + item.original[this.current.collection.fillAttr]) + '';\r\n }\r\n\r\n return this.current.collection.trigger + item.original[this.current.collection.fillAttr];\r\n }\r\n\r\n static defaultMenuItemTemplate(matchItem) {\r\n return matchItem.string\r\n }\r\n\r\n static inputTypes() {\r\n return ['TEXTAREA', 'INPUT']\r\n }\r\n\r\n triggers() {\r\n return this.collection.map(config => {\r\n return config.trigger\r\n })\r\n }\r\n\r\n attach(el) {\r\n if (!el) {\r\n throw new Error('[Tribute] Must pass in a DOM node or NodeList.')\r\n }\r\n\r\n // Check if it is a jQuery collection\r\n if (typeof jQuery !== 'undefined' && el instanceof jQuery) {\r\n el = el.get()\r\n }\r\n\r\n // Is el an Array/Array-like object?\r\n if (el.constructor === NodeList || el.constructor === HTMLCollection || el.constructor === Array) {\r\n let length = el.length\r\n for (var i = 0; i < length; ++i) {\r\n this._attach(el[i])\r\n }\r\n } else {\r\n this._attach(el)\r\n }\r\n }\r\n\r\n _attach(el) {\r\n if (el.hasAttribute('data-tribute')) {\r\n console.warn('Tribute was already bound to ' + el.nodeName)\r\n }\r\n\r\n this.ensureEditable(el)\r\n this.events.bind(el)\r\n el.setAttribute('data-tribute', true)\r\n }\r\n\r\n ensureEditable(element) {\r\n if (Tribute.inputTypes().indexOf(element.nodeName) === -1) {\r\n if (element.contentEditable) {\r\n element.contentEditable = true\r\n } else {\r\n throw new Error('[Tribute] Cannot bind to ' + element.nodeName)\r\n }\r\n }\r\n }\r\n\r\n createMenu() {\r\n let wrapper = this.range.getDocument().createElement('div'),\r\n ul = this.range.getDocument().createElement('ul')\r\n\r\n wrapper.className = 'tribute-container'\r\n wrapper.appendChild(ul)\r\n\r\n if (this.menuContainer) {\r\n return this.menuContainer.appendChild(wrapper)\r\n }\r\n\r\n return this.range.getDocument().body.appendChild(wrapper)\r\n }\r\n\r\n showMenuFor(element, scrollTo) {\r\n // Only proceed if menu isn't already shown for the current element & mentionText\r\n if (this.isActive && this.current.element === element && this.current.mentionText === this.currentMentionTextSnapshot) {\r\n return\r\n }\r\n this.currentMentionTextSnapshot = this.current.mentionText\r\n\r\n // create the menu if it doesn't exist.\r\n if (!this.menu) {\r\n this.menu = this.createMenu()\r\n element.tributeMenu = this.menu\r\n this.menuEvents.bind(this.menu)\r\n }\r\n\r\n this.isActive = true\r\n this.menuSelected = 0\r\n\r\n if (!this.current.mentionText) {\r\n this.current.mentionText = ''\r\n }\r\n\r\n const processValues = (values) => {\r\n // Tribute may not be active any more by the time the value callback returns\r\n if (!this.isActive) {\r\n return\r\n }\r\n\r\n let items = this.search.filter(this.current.mentionText, values, {\r\n pre: this.current.collection.searchOpts.pre || '',\r\n post: this.current.collection.searchOpts.post || '',\r\n skip: this.current.collection.searchOpts.skip,\r\n extract: (el) => {\r\n if (typeof this.current.collection.lookup === 'string') {\r\n return el[this.current.collection.lookup]\r\n } else if (typeof this.current.collection.lookup === 'function') {\r\n return this.current.collection.lookup(el, this.current.mentionText)\r\n } else {\r\n throw new Error('Invalid lookup attribute, lookup must be string or function.')\r\n }\r\n }\r\n })\r\n\r\n if (this.current.collection.menuItemLimit) {\r\n items = items.slice(0, this.current.collection.menuItemLimit)\r\n }\r\n\r\n this.current.filteredItems = items\r\n\r\n\r\n let ul = this.menu.querySelector('ul')\r\n\r\n this.range.positionMenuAtCaret(scrollTo)\r\n\r\n if (!items.length) {\r\n let noMatchEvent = new CustomEvent('tribute-no-match', { detail: this.menu })\r\n this.current.element.dispatchEvent(noMatchEvent)\r\n if ( typeof this.current.collection.noMatchTemplate === 'function' && !this.current.collection.noMatchTemplate() || !this.current.collection.noMatchTemplate) {\r\n this.hideMenu()\r\n } else {\r\n typeof this.current.collection.noMatchTemplate === 'function' ? ul.innerHTML = this.current.collection.noMatchTemplate() : ul.innerHTML = this.current.collection.noMatchTemplate\r\n }\r\n\r\n return\r\n }\r\n\r\n ul.innerHTML = ''\r\n let fragment = this.range.getDocument().createDocumentFragment()\r\n\r\n items.forEach((item, index) => {\r\n let li = this.range.getDocument().createElement('li')\r\n li.setAttribute('data-index', index)\r\n li.addEventListener('mousemove', (e) => {\r\n let [li, index] = this._findLiTarget(e.target)\r\n if (e.movementY !== 0) {\r\n this.events.setActiveLi(index)\r\n }\r\n })\r\n if (this.menuSelected === index) {\r\n li.className = this.current.collection.selectClass\r\n }\r\n li.innerHTML = this.current.collection.menuItemTemplate(item)\r\n fragment.appendChild(li)\r\n })\r\n ul.appendChild(fragment)\r\n }\r\n\r\n if (typeof this.current.collection.values === 'function') {\r\n this.current.collection.values(this.current.mentionText, processValues)\r\n } else {\r\n processValues(this.current.collection.values)\r\n }\r\n }\r\n\r\n _findLiTarget(el) {\r\n if (!el) return []\r\n const index = el.getAttribute('data-index');\r\n return !index ?\r\n this._findLiTarget(el.parentNode) :\r\n [el, index]\r\n }\r\n\r\n showMenuForCollection(element, collectionIndex) {\r\n if (element !== document.activeElement) {\r\n this.placeCaretAtEnd(element)\r\n }\r\n\r\n this.current.collection = this.collection[collectionIndex || 0]\r\n this.current.externalTrigger = true\r\n this.current.element = element\r\n\r\n if (element.isContentEditable)\r\n this.insertTextAtCursor(this.current.collection.trigger)\r\n else\r\n this.insertAtCaret(element, this.current.collection.trigger)\r\n\r\n this.showMenuFor(element)\r\n }\r\n\r\n // TODO: make sure this works for inputs/textareas\r\n placeCaretAtEnd(el) {\r\n el.focus();\r\n if (typeof window.getSelection != \"undefined\"\r\n && typeof document.createRange != \"undefined\") {\r\n var range = document.createRange();\r\n range.selectNodeContents(el);\r\n range.collapse(false);\r\n var sel = window.getSelection();\r\n sel.removeAllRanges();\r\n sel.addRange(range);\r\n } else if (typeof document.body.createTextRange != \"undefined\") {\r\n var textRange = document.body.createTextRange();\r\n textRange.moveToElementText(el);\r\n textRange.collapse(false);\r\n textRange.select();\r\n }\r\n }\r\n\r\n // for contenteditable\r\n insertTextAtCursor(text) {\r\n var sel, range, html;\r\n sel = window.getSelection();\r\n range = sel.getRangeAt(0);\r\n range.deleteContents();\r\n var textNode = document.createTextNode(text);\r\n range.insertNode(textNode);\r\n range.selectNodeContents(textNode)\r\n range.collapse(false)\r\n sel.removeAllRanges()\r\n sel.addRange(range)\r\n }\r\n\r\n // for regular inputs\r\n insertAtCaret(textarea, text) {\r\n var scrollPos = textarea.scrollTop;\r\n var caretPos = textarea.selectionStart;\r\n\r\n var front = (textarea.value).substring(0, caretPos);\r\n var back = (textarea.value).substring(textarea.selectionEnd, textarea.value.length);\r\n textarea.value = front + text + back;\r\n caretPos = caretPos + text.length;\r\n textarea.selectionStart = caretPos;\r\n textarea.selectionEnd = caretPos;\r\n textarea.focus();\r\n textarea.scrollTop = scrollPos;\r\n }\r\n\r\n hideMenu() {\r\n if (this.menu) {\r\n this.menu.style.cssText = 'display: none;'\r\n this.isActive = false\r\n this.menuSelected = 0\r\n this.current = {}\r\n }\r\n }\r\n\r\n selectItemAtIndex(index, originalEvent) {\r\n index = parseInt(index)\r\n if (typeof index !== 'number' || isNaN(index)) return\r\n let item = this.current.filteredItems[index]\r\n let content = this.current.collection.selectTemplate(item)\r\n if (content !== null) this.replaceText(content, originalEvent, item)\r\n }\r\n\r\n replaceText(content, originalEvent, item) {\r\n this.range.replaceTriggerText(content, true, true, originalEvent, item)\r\n }\r\n\r\n _append(collection, newValues, replace) {\r\n if (typeof collection.values === 'function') {\r\n throw new Error('Unable to append to values, as it is a function.')\r\n } else if (!replace) {\r\n collection.values = collection.values.concat(newValues)\r\n } else {\r\n collection.values = newValues\r\n }\r\n }\r\n\r\n append(collectionIndex, newValues, replace) {\r\n let index = parseInt(collectionIndex)\r\n if (typeof index !== 'number') throw new Error('please provide an index for the collection to update.')\r\n\r\n let collection = this.collection[index]\r\n\r\n this._append(collection, newValues, replace)\r\n }\r\n\r\n appendCurrent(newValues, replace) {\r\n if (this.isActive) {\r\n this._append(this.current.collection, newValues, replace)\r\n } else {\r\n throw new Error('No active state. Please use append instead and pass an index.')\r\n }\r\n }\r\n\r\n detach(el) {\r\n if (!el) {\r\n throw new Error('[Tribute] Must pass in a DOM node or NodeList.')\r\n }\r\n\r\n // Check if it is a jQuery collection\r\n if (typeof jQuery !== 'undefined' && el instanceof jQuery) {\r\n el = el.get()\r\n }\r\n\r\n // Is el an Array/Array-like object?\r\n if (el.constructor === NodeList || el.constructor === HTMLCollection || el.constructor === Array) {\r\n let length = el.length\r\n for (var i = 0; i < length; ++i) {\r\n this._detach(el[i])\r\n }\r\n } else {\r\n this._detach(el)\r\n }\r\n }\r\n\r\n _detach(el) {\r\n this.events.unbind(el)\r\n if (el.tributeMenu) {\r\n this.menuEvents.unbind(el.tributeMenu)\r\n }\r\n\r\n setTimeout(() => {\r\n el.removeAttribute('data-tribute')\r\n this.isActive = false\r\n if (el.tributeMenu) {\r\n el.tributeMenu.remove()\r\n }\r\n })\r\n }\r\n}\r\n\r\nexport default Tribute;\r\n", - "class TributeEvents {\r\n constructor(tribute) {\r\n this.tribute = tribute\r\n this.tribute.events = this\r\n }\r\n\r\n static keys() {\r\n return [{\r\n key: 9,\r\n value: 'TAB'\r\n }, {\r\n key: 8,\r\n value: 'DELETE'\r\n }, {\r\n key: 13,\r\n value: 'ENTER'\r\n }, {\r\n key: 27,\r\n value: 'ESCAPE'\r\n }, {\r\n key: 32,\r\n value: 'SPACE'\r\n }, {\r\n key: 38,\r\n value: 'UP'\r\n }, {\r\n key: 40,\r\n value: 'DOWN'\r\n }]\r\n }\r\n\r\n bind(element) {\r\n element.boundKeydown = this.keydown.bind(element, this);\r\n element.boundKeyup = this.keyup.bind(element, this);\r\n element.boundInput = this.input.bind(element, this);\r\n\r\n element.addEventListener('keydown',\r\n element.boundKeydown, false)\r\n element.addEventListener('keyup',\r\n element.boundKeyup, false)\r\n element.addEventListener('input',\r\n element.boundInput, false)\r\n }\r\n\r\n unbind(element) {\r\n element.removeEventListener('keydown',\r\n element.boundKeydown, false)\r\n element.removeEventListener('keyup',\r\n element.boundKeyup, false)\r\n element.removeEventListener('input',\r\n element.boundInput, false)\r\n\r\n delete element.boundKeydown\r\n delete element.boundKeyup\r\n delete element.boundInput\r\n }\r\n\r\n keydown(instance, event) {\r\n if (instance.shouldDeactivate(event)) {\r\n instance.tribute.isActive = false\r\n instance.tribute.hideMenu()\r\n }\r\n\r\n let element = this\r\n instance.commandEvent = false\r\n\r\n TributeEvents.keys().forEach(o => {\r\n if (o.key === event.keyCode) {\r\n instance.commandEvent = true\r\n instance.callbacks()[o.value.toLowerCase()](event, element)\r\n }\r\n })\r\n }\r\n\r\n input(instance, event) {\r\n instance.inputEvent = true\r\n instance.keyup.call(this, instance, event)\r\n }\r\n\r\n click(instance, event) {\r\n let tribute = instance.tribute\r\n if (tribute.menu && tribute.menu.contains(event.target)) {\r\n let li = event.target\r\n event.preventDefault()\r\n event.stopPropagation()\r\n while (li.nodeName.toLowerCase() !== 'li') {\r\n li = li.parentNode\r\n if (!li || li === tribute.menu) {\r\n throw new Error('cannot find the
  • container for the click')\r\n }\r\n }\r\n tribute.selectItemAtIndex(li.getAttribute('data-index'), event)\r\n tribute.hideMenu()\r\n\r\n // TODO: should fire with externalTrigger and target is outside of menu\r\n } else if (tribute.current.element && !tribute.current.externalTrigger) {\r\n tribute.current.externalTrigger = false\r\n setTimeout(() => tribute.hideMenu())\r\n }\r\n }\r\n\r\n keyup(instance, event) {\r\n if (instance.inputEvent) {\r\n instance.inputEvent = false\r\n }\r\n instance.updateSelection(this)\r\n\r\n if (event.keyCode === 27) return\r\n\r\n if (!instance.tribute.allowSpaces && instance.tribute.hasTrailingSpace) {\r\n instance.tribute.hasTrailingSpace = false;\r\n instance.commandEvent = true;\r\n instance.callbacks()[\"space\"](event, this);\r\n return\r\n }\r\n\r\n if (!instance.tribute.isActive) {\r\n if (instance.tribute.autocompleteMode) {\r\n instance.callbacks().triggerChar(event, this, '')\r\n } else {\r\n let keyCode = instance.getKeyCode(instance, this, event)\r\n \r\n if (isNaN(keyCode) || !keyCode) return\r\n \r\n let trigger = instance.tribute.triggers().find(trigger => {\r\n return trigger.charCodeAt(0) === keyCode\r\n })\r\n \r\n if (typeof trigger !== 'undefined') {\r\n instance.callbacks().triggerChar(event, this, trigger)\r\n }\r\n }\r\n }\r\n\r\n if ((instance.tribute.current.trigger || instance.tribute.autocompleteMode)\r\n && instance.commandEvent === false\r\n || instance.tribute.isActive && event.keyCode === 8) {\r\n instance.tribute.showMenuFor(this, true)\r\n }\r\n }\r\n\r\n shouldDeactivate(event) {\r\n if (!this.tribute.isActive) return false\r\n\r\n if (this.tribute.current.mentionText.length === 0) {\r\n let eventKeyPressed = false\r\n TributeEvents.keys().forEach(o => {\r\n if (event.keyCode === o.key) eventKeyPressed = true\r\n })\r\n\r\n return !eventKeyPressed\r\n }\r\n\r\n return false\r\n }\r\n\r\n getKeyCode(instance, el, event) {\r\n let char\r\n let tribute = instance.tribute\r\n let info = tribute.range.getTriggerInfo(false, tribute.hasTrailingSpace, true, tribute.allowSpaces, tribute.autocompleteMode)\r\n\r\n if (info) {\r\n return info.mentionTriggerChar.charCodeAt(0)\r\n } else {\r\n return false\r\n }\r\n }\r\n\r\n updateSelection(el) {\r\n this.tribute.current.element = el\r\n let info = this.tribute.range.getTriggerInfo(false, this.tribute.hasTrailingSpace, true, this.tribute.allowSpaces, this.tribute.autocompleteMode)\r\n\r\n if (info) {\r\n this.tribute.current.selectedPath = info.mentionSelectedPath\r\n this.tribute.current.mentionText = info.mentionText\r\n this.tribute.current.selectedOffset = info.mentionSelectedOffset\r\n }\r\n }\r\n\r\n callbacks() {\r\n return {\r\n triggerChar: (e, el, trigger) => {\r\n let tribute = this.tribute\r\n tribute.current.trigger = trigger\r\n\r\n let collectionItem = tribute.collection.find(item => {\r\n return item.trigger === trigger\r\n })\r\n\r\n tribute.current.collection = collectionItem\r\n if (tribute.inputEvent) tribute.showMenuFor(el, true)\r\n },\r\n enter: (e, el) => {\r\n // choose selection\r\n if (this.tribute.isActive && this.tribute.current.filteredItems) {\r\n e.preventDefault()\r\n e.stopPropagation()\r\n setTimeout(() => {\r\n this.tribute.selectItemAtIndex(this.tribute.menuSelected, e)\r\n this.tribute.hideMenu()\r\n }, 0)\r\n }\r\n },\r\n escape: (e, el) => {\r\n if (this.tribute.isActive) {\r\n e.preventDefault()\r\n e.stopPropagation()\r\n this.tribute.isActive = false\r\n this.tribute.hideMenu()\r\n }\r\n },\r\n tab: (e, el) => {\r\n // choose first match\r\n this.callbacks().enter(e, el)\r\n },\r\n space: (e, el) => {\r\n if (this.tribute.isActive) {\r\n if (this.tribute.spaceSelectsMatch) {\r\n this.callbacks().enter(e, el)\r\n } else if (!this.tribute.allowSpaces) {\r\n e.stopPropagation();\r\n setTimeout(() => {\r\n this.tribute.hideMenu();\r\n this.tribute.isActive = false;\r\n }, 0);\r\n }\r\n }\r\n },\r\n up: (e, el) => {\r\n // navigate up ul\r\n if (this.tribute.isActive && this.tribute.current.filteredItems) {\r\n e.preventDefault()\r\n e.stopPropagation()\r\n let count = this.tribute.current.filteredItems.length,\r\n selected = this.tribute.menuSelected\r\n\r\n if (count > selected && selected > 0) {\r\n this.tribute.menuSelected--\r\n this.setActiveLi()\r\n } else if (selected === 0) {\r\n this.tribute.menuSelected = count - 1\r\n this.setActiveLi()\r\n this.tribute.menu.scrollTop = this.tribute.menu.scrollHeight\r\n }\r\n }\r\n },\r\n down: (e, el) => {\r\n // navigate down ul\r\n if (this.tribute.isActive && this.tribute.current.filteredItems) {\r\n e.preventDefault()\r\n e.stopPropagation()\r\n let count = this.tribute.current.filteredItems.length - 1,\r\n selected = this.tribute.menuSelected\r\n\r\n if (count > selected) {\r\n this.tribute.menuSelected++\r\n this.setActiveLi()\r\n } else if (count === selected) {\r\n this.tribute.menuSelected = 0\r\n this.setActiveLi()\r\n this.tribute.menu.scrollTop = 0\r\n }\r\n }\r\n },\r\n delete: (e, el) => {\r\n if (this.tribute.isActive && this.tribute.current.mentionText.length < 1) {\r\n this.tribute.hideMenu()\r\n } else if (this.tribute.isActive) {\r\n this.tribute.showMenuFor(el)\r\n }\r\n }\r\n }\r\n }\r\n\r\n setActiveLi(index) {\r\n let lis = this.tribute.menu.querySelectorAll('li'),\r\n length = lis.length >>> 0\r\n\r\n if (index) this.tribute.menuSelected = parseInt(index);\r\n\r\n for (let i = 0; i < length; i++) {\r\n let li = lis[i]\r\n if (i === this.tribute.menuSelected) {\r\n li.classList.add(this.tribute.current.collection.selectClass);\r\n\r\n let liClientRect = li.getBoundingClientRect();\r\n let menuClientRect = this.tribute.menu.getBoundingClientRect();\r\n\r\n if (liClientRect.bottom > menuClientRect.bottom) {\r\n let scrollDistance = liClientRect.bottom - menuClientRect.bottom;\r\n this.tribute.menu.scrollTop += scrollDistance\r\n } else if (liClientRect.top < menuClientRect.top) {\r\n let scrollDistance = menuClientRect.top - liClientRect.top;\r\n this.tribute.menu.scrollTop -= scrollDistance\r\n }\r\n\r\n } else {\r\n li.classList.remove(this.tribute.current.collection.selectClass);\r\n }\r\n }\r\n }\r\n\r\n getFullHeight(elem, includeMargin) {\r\n let height = elem.getBoundingClientRect().height\r\n\r\n if (includeMargin) {\r\n let style = elem.currentStyle || window.getComputedStyle(elem)\r\n return height + parseFloat(style.marginTop) + parseFloat(style.marginBottom)\r\n }\r\n\r\n return height\r\n }\r\n\r\n}\r\n\r\nexport default TributeEvents;\r\n", - "class TributeMenuEvents {\r\n constructor(tribute) {\r\n this.tribute = tribute\r\n this.tribute.menuEvents = this\r\n this.menu = this.tribute.menu\r\n }\r\n\r\n bind(menu) {\r\n this.menuClickEvent = this.tribute.events.click.bind(null, this)\r\n this.menuContainerScrollEvent = this.debounce(() => {\r\n if (this.tribute.isActive) {\r\n this.tribute.showMenuFor(this.tribute.current.element, false)\r\n }\r\n }, 300, false)\r\n this.windowResizeEvent = this.debounce(() => {\r\n if (this.tribute.isActive) {\r\n this.tribute.range.positionMenuAtCaret(true)\r\n }\r\n }, 300, false)\r\n\r\n // fixes IE11 issues with mousedown\r\n this.tribute.range.getDocument().addEventListener('MSPointerDown',\r\n this.menuClickEvent, false)\r\n this.tribute.range.getDocument().addEventListener('mousedown',\r\n this.menuClickEvent, false)\r\n window.addEventListener('resize', this.windowResizeEvent)\r\n\r\n if (this.menuContainer) {\r\n this.menuContainer.addEventListener('scroll', this.menuContainerScrollEvent, false)\r\n } else {\r\n window.addEventListener('scroll', this.menuContainerScrollEvent)\r\n }\r\n\r\n }\r\n\r\n unbind(menu) {\r\n this.tribute.range.getDocument().removeEventListener('mousedown',\r\n this.menuClickEvent, false)\r\n this.tribute.range.getDocument().removeEventListener('MSPointerDown',\r\n this.menuClickEvent, false)\r\n window.removeEventListener('resize', this.windowResizeEvent)\r\n\r\n if (this.menuContainer) {\r\n this.menuContainer.removeEventListener('scroll', this.menuContainerScrollEvent, false)\r\n } else {\r\n window.removeEventListener('scroll', this.menuContainerScrollEvent)\r\n }\r\n }\r\n\r\n debounce(func, wait, immediate) {\r\n var timeout\r\n return () => {\r\n var context = this,\r\n args = arguments\r\n var later = () => {\r\n timeout = null\r\n if (!immediate) func.apply(context, args)\r\n }\r\n var callNow = immediate && !timeout\r\n clearTimeout(timeout)\r\n timeout = setTimeout(later, wait)\r\n if (callNow) func.apply(context, args)\r\n }\r\n }\r\n}\r\n\r\n\r\nexport default TributeMenuEvents;\r\n", - "// Thanks to https://github.com/jeff-collins/ment.io\r\nimport \"./utils\";\r\n\r\nclass TributeRange {\r\n constructor(tribute) {\r\n this.tribute = tribute\r\n this.tribute.range = this\r\n }\r\n\r\n getDocument() {\r\n let iframe\r\n if (this.tribute.current.collection) {\r\n iframe = this.tribute.current.collection.iframe\r\n }\r\n\r\n if (!iframe) {\r\n return document\r\n }\r\n\r\n return iframe.contentWindow.document\r\n }\r\n\r\n positionMenuAtCaret(scrollTo) {\r\n let context = this.tribute.current,\r\n coordinates\r\n\r\n let info = this.getTriggerInfo(false, this.tribute.hasTrailingSpace, true, this.tribute.allowSpaces, this.tribute.autocompleteMode)\r\n\r\n if (typeof info !== 'undefined') {\r\n\r\n if(!this.tribute.positionMenu){\r\n this.tribute.menu.style.cssText = `display: block;`\r\n return\r\n }\r\n\r\n if (!this.isContentEditable(context.element)) {\r\n coordinates = this.getTextAreaOrInputUnderlinePosition(this.tribute.current.element,\r\n info.mentionPosition)\r\n }\r\n else {\r\n coordinates = this.getContentEditableCaretPosition(info.mentionPosition)\r\n }\r\n\r\n this.tribute.menu.style.cssText = `top: ${coordinates.top}px;\r\n left: ${coordinates.left}px;\r\n right: ${coordinates.right}px;\r\n bottom: ${coordinates.bottom}px;\r\n position: absolute;\r\n display: block;`\r\n\r\n if (coordinates.left === 'auto') {\r\n this.tribute.menu.style.left = 'auto'\r\n }\r\n\r\n if (coordinates.top === 'auto') {\r\n this.tribute.menu.style.top = 'auto'\r\n }\r\n\r\n if (scrollTo) this.scrollIntoView()\r\n\r\n window.setTimeout(() => {\r\n let menuDimensions = {\r\n width: this.tribute.menu.offsetWidth,\r\n height: this.tribute.menu.offsetHeight\r\n }\r\n let menuIsOffScreen = this.isMenuOffScreen(coordinates, menuDimensions)\r\n\r\n let menuIsOffScreenHorizontally = window.innerWidth > menuDimensions.width && (menuIsOffScreen.left || menuIsOffScreen.right)\r\n let menuIsOffScreenVertically = window.innerHeight > menuDimensions.height && (menuIsOffScreen.top || menuIsOffScreen.bottom)\r\n if (menuIsOffScreenHorizontally || menuIsOffScreenVertically) {\r\n this.tribute.menu.style.cssText = 'display: none'\r\n this.positionMenuAtCaret(scrollTo)\r\n }\r\n }, 0)\r\n\r\n } else {\r\n this.tribute.menu.style.cssText = 'display: none'\r\n }\r\n }\r\n\r\n get menuContainerIsBody() {\r\n return this.tribute.menuContainer === document.body || !this.tribute.menuContainer;\r\n }\r\n\r\n\r\n selectElement(targetElement, path, offset) {\r\n let range\r\n let elem = targetElement\r\n\r\n if (path) {\r\n for (var i = 0; i < path.length; i++) {\r\n elem = elem.childNodes[path[i]]\r\n if (elem === undefined) {\r\n return\r\n }\r\n while (elem.length < offset) {\r\n offset -= elem.length\r\n elem = elem.nextSibling\r\n }\r\n if (elem.childNodes.length === 0 && !elem.length) {\r\n elem = elem.previousSibling\r\n }\r\n }\r\n }\r\n let sel = this.getWindowSelection()\r\n\r\n range = this.getDocument().createRange()\r\n range.setStart(elem, offset)\r\n range.setEnd(elem, offset)\r\n range.collapse(true)\r\n\r\n try {\r\n sel.removeAllRanges()\r\n } catch (error) {}\r\n\r\n sel.addRange(range)\r\n targetElement.focus()\r\n }\r\n\r\n replaceTriggerText(text, requireLeadingSpace, hasTrailingSpace, originalEvent, item) {\r\n let info = this.getTriggerInfo(true, hasTrailingSpace, requireLeadingSpace, this.tribute.allowSpaces, this.tribute.autocompleteMode)\r\n\r\n if (info !== undefined) {\r\n let context = this.tribute.current\r\n let replaceEvent = new CustomEvent('tribute-replaced', {\r\n detail: {\r\n item: item,\r\n instance: context,\r\n context: info,\r\n event: originalEvent,\r\n }\r\n })\r\n\r\n if (!this.isContentEditable(context.element)) {\r\n let myField = this.tribute.current.element\r\n let textSuffix = typeof this.tribute.replaceTextSuffix == 'string'\r\n ? this.tribute.replaceTextSuffix\r\n : ' '\r\n text += textSuffix\r\n let startPos = info.mentionPosition\r\n let endPos = info.mentionPosition + info.mentionText.length + textSuffix.length\r\n if (!this.tribute.autocompleteMode) {\r\n endPos += info.mentionTriggerChar.length - 1\r\n }\r\n myField.value = myField.value.substring(0, startPos) + text +\r\n myField.value.substring(endPos, myField.value.length)\r\n myField.selectionStart = startPos + text.length\r\n myField.selectionEnd = startPos + text.length\r\n } else {\r\n // add a space to the end of the pasted text\r\n let textSuffix = typeof this.tribute.replaceTextSuffix == 'string'\r\n ? this.tribute.replaceTextSuffix\r\n : '\\xA0'\r\n text += textSuffix\r\n let endPos = info.mentionPosition + info.mentionText.length\r\n if (!this.tribute.autocompleteMode) {\r\n endPos += info.mentionTriggerChar.length\r\n }\r\n this.pasteHtml(text, info.mentionPosition, endPos)\r\n }\r\n \r\n context.element.dispatchEvent(new CustomEvent('input', { bubbles: true }))\r\n context.element.dispatchEvent(replaceEvent)\r\n }\r\n }\r\n\r\n pasteHtml(html, startPos, endPos) {\r\n let range, sel\r\n sel = this.getWindowSelection()\r\n range = this.getDocument().createRange()\r\n range.setStart(sel.anchorNode, startPos)\r\n range.setEnd(sel.anchorNode, endPos)\r\n range.deleteContents()\r\n\r\n let el = this.getDocument().createElement('div')\r\n el.innerHTML = html\r\n let frag = this.getDocument().createDocumentFragment(),\r\n node, lastNode\r\n while ((node = el.firstChild)) {\r\n lastNode = frag.appendChild(node)\r\n }\r\n range.insertNode(frag)\r\n\r\n // Preserve the selection\r\n if (lastNode) {\r\n range = range.cloneRange()\r\n range.setStartAfter(lastNode)\r\n range.collapse(true)\r\n sel.removeAllRanges()\r\n sel.addRange(range)\r\n }\r\n }\r\n\r\n getWindowSelection() {\r\n if (this.tribute.collection.iframe) {\r\n return this.tribute.collection.iframe.contentWindow.getSelection()\r\n }\r\n\r\n return window.getSelection()\r\n }\r\n\r\n getNodePositionInParent(element) {\r\n if (element.parentNode === null) {\r\n return 0\r\n }\r\n\r\n for (var i = 0; i < element.parentNode.childNodes.length; i++) {\r\n let node = element.parentNode.childNodes[i]\r\n\r\n if (node === element) {\r\n return i\r\n }\r\n }\r\n }\r\n\r\n getContentEditableSelectedPath(ctx) {\r\n let sel = this.getWindowSelection()\r\n let selected = sel.anchorNode\r\n let path = []\r\n let offset\r\n\r\n if (selected != null) {\r\n let i\r\n let ce = selected.contentEditable\r\n while (selected !== null && ce !== 'true') {\r\n i = this.getNodePositionInParent(selected)\r\n path.push(i)\r\n selected = selected.parentNode\r\n if (selected !== null) {\r\n ce = selected.contentEditable\r\n }\r\n }\r\n path.reverse()\r\n\r\n // getRangeAt may not exist, need alternative\r\n offset = sel.getRangeAt(0).startOffset\r\n\r\n return {\r\n selected: selected,\r\n path: path,\r\n offset: offset\r\n }\r\n }\r\n }\r\n\r\n getTextPrecedingCurrentSelection() {\r\n let context = this.tribute.current,\r\n text = ''\r\n\r\n if (!this.isContentEditable(context.element)) {\r\n let textComponent = this.tribute.current.element;\r\n if (textComponent) {\r\n let startPos = textComponent.selectionStart\r\n if (textComponent.value && startPos >= 0) {\r\n text = textComponent.value.substring(0, startPos)\r\n }\r\n }\r\n\r\n } else {\r\n let selectedElem = this.getWindowSelection().anchorNode\r\n\r\n if (selectedElem != null) {\r\n let workingNodeContent = selectedElem.textContent\r\n let selectStartOffset = this.getWindowSelection().getRangeAt(0).startOffset\r\n\r\n if (workingNodeContent && selectStartOffset >= 0) {\r\n text = workingNodeContent.substring(0, selectStartOffset)\r\n }\r\n }\r\n }\r\n\r\n return text\r\n }\r\n\r\n getLastWordInText(text) {\r\n text = text.replace(/\\u00A0/g, ' '); // https://stackoverflow.com/questions/29850407/how-do-i-replace-unicode-character-u00a0-with-a-space-in-javascript\r\n let wordsArray = text.split(/\\s+/);\r\n let worldsCount = wordsArray.length - 1\r\n return wordsArray[worldsCount].trim()\r\n }\r\n\r\n getTriggerInfo(menuAlreadyActive, hasTrailingSpace, requireLeadingSpace, allowSpaces, isAutocomplete) {\r\n let ctx = this.tribute.current\r\n let selected, path, offset\r\n\r\n if (!this.isContentEditable(ctx.element)) {\r\n selected = this.tribute.current.element\r\n } else {\r\n let selectionInfo = this.getContentEditableSelectedPath(ctx)\r\n\r\n if (selectionInfo) {\r\n selected = selectionInfo.selected\r\n path = selectionInfo.path\r\n offset = selectionInfo.offset\r\n }\r\n }\r\n\r\n let effectiveRange = this.getTextPrecedingCurrentSelection()\r\n let lastWordOfEffectiveRange = this.getLastWordInText(effectiveRange)\r\n\r\n if (isAutocomplete) {\r\n return {\r\n mentionPosition: effectiveRange.length - lastWordOfEffectiveRange.length,\r\n mentionText: lastWordOfEffectiveRange,\r\n mentionSelectedElement: selected,\r\n mentionSelectedPath: path,\r\n mentionSelectedOffset: offset\r\n }\r\n }\r\n\r\n if (effectiveRange !== undefined && effectiveRange !== null) {\r\n let mostRecentTriggerCharPos = -1\r\n let triggerChar\r\n\r\n this.tribute.collection.forEach(config => {\r\n let c = config.trigger\r\n let idx = config.requireLeadingSpace ?\r\n this.lastIndexWithLeadingSpace(effectiveRange, c) :\r\n effectiveRange.lastIndexOf(c)\r\n\r\n if (idx > mostRecentTriggerCharPos) {\r\n mostRecentTriggerCharPos = idx\r\n triggerChar = c\r\n requireLeadingSpace = config.requireLeadingSpace\r\n }\r\n })\r\n\r\n if (mostRecentTriggerCharPos >= 0 &&\r\n (\r\n mostRecentTriggerCharPos === 0 ||\r\n !requireLeadingSpace ||\r\n /[\\xA0\\s]/g.test(\r\n effectiveRange.substring(\r\n mostRecentTriggerCharPos - 1,\r\n mostRecentTriggerCharPos)\r\n )\r\n )\r\n ) {\r\n let currentTriggerSnippet = effectiveRange.substring(mostRecentTriggerCharPos + triggerChar.length,\r\n effectiveRange.length)\r\n\r\n triggerChar = effectiveRange.substring(mostRecentTriggerCharPos, mostRecentTriggerCharPos + triggerChar.length)\r\n let firstSnippetChar = currentTriggerSnippet.substring(0, 1)\r\n let leadingSpace = currentTriggerSnippet.length > 0 &&\r\n (\r\n firstSnippetChar === ' ' ||\r\n firstSnippetChar === '\\xA0'\r\n )\r\n if (hasTrailingSpace) {\r\n currentTriggerSnippet = currentTriggerSnippet.trim()\r\n }\r\n\r\n let regex = allowSpaces ? /[^\\S ]/g : /[\\xA0\\s]/g;\r\n\r\n this.tribute.hasTrailingSpace = regex.test(currentTriggerSnippet);\r\n\r\n if (!leadingSpace && (menuAlreadyActive || !(regex.test(currentTriggerSnippet)))) {\r\n return {\r\n mentionPosition: mostRecentTriggerCharPos,\r\n mentionText: currentTriggerSnippet,\r\n mentionSelectedElement: selected,\r\n mentionSelectedPath: path,\r\n mentionSelectedOffset: offset,\r\n mentionTriggerChar: triggerChar\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n lastIndexWithLeadingSpace (str, trigger) {\r\n let reversedStr = str.split('').reverse().join('')\r\n let index = -1\r\n\r\n for (let cidx = 0, len = str.length; cidx < len; cidx++) {\r\n let firstChar = cidx === str.length - 1\r\n let leadingSpace = /\\s/.test(reversedStr[cidx + 1])\r\n\r\n let match = true\r\n for (let triggerIdx = trigger.length - 1; triggerIdx >= 0; triggerIdx--) {\r\n if (trigger[triggerIdx] !== reversedStr[cidx-triggerIdx]) {\r\n match = false\r\n break\r\n }\r\n }\r\n\r\n if (match && (firstChar || leadingSpace)) {\r\n index = str.length - 1 - cidx\r\n break\r\n }\r\n }\r\n\r\n return index\r\n }\r\n\r\n isContentEditable(element) {\r\n return element.nodeName !== 'INPUT' && element.nodeName !== 'TEXTAREA'\r\n }\r\n\r\n isMenuOffScreen(coordinates, menuDimensions) {\r\n let windowWidth = window.innerWidth\r\n let windowHeight = window.innerHeight\r\n let doc = document.documentElement\r\n let windowLeft = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0)\r\n let windowTop = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0)\r\n\r\n let menuTop = typeof coordinates.top === 'number' ? coordinates.top : windowTop + windowHeight - coordinates.bottom - menuDimensions.height\r\n let menuRight = typeof coordinates.right === 'number' ? coordinates.right : coordinates.left + menuDimensions.width\r\n let menuBottom = typeof coordinates.bottom === 'number' ? coordinates.bottom : coordinates.top + menuDimensions.height\r\n let menuLeft = typeof coordinates.left === 'number' ? coordinates.left : windowLeft + windowWidth - coordinates.right - menuDimensions.width\r\n\r\n return {\r\n top: menuTop < Math.floor(windowTop),\r\n right: menuRight > Math.ceil(windowLeft + windowWidth),\r\n bottom: menuBottom > Math.ceil(windowTop + windowHeight),\r\n left: menuLeft < Math.floor(windowLeft)\r\n }\r\n }\r\n\r\n getMenuDimensions() {\r\n // Width of the menu depends of its contents and position\r\n // We must check what its width would be without any obstruction\r\n // This way, we can achieve good positioning for flipping the menu\r\n let dimensions = {\r\n width: null,\r\n height: null\r\n }\r\n\r\n this.tribute.menu.style.cssText = `top: 0px;\r\n left: 0px;\r\n position: fixed;\r\n display: block;\r\n visibility; hidden;`\r\n dimensions.width = this.tribute.menu.offsetWidth\r\n dimensions.height = this.tribute.menu.offsetHeight\r\n\r\n this.tribute.menu.style.cssText = `display: none;`\r\n\r\n return dimensions\r\n }\r\n\r\n getTextAreaOrInputUnderlinePosition(element, position, flipped) {\r\n let properties = ['direction', 'boxSizing', 'width', 'height', 'overflowX',\r\n 'overflowY', 'borderTopWidth', 'borderRightWidth',\r\n 'borderBottomWidth', 'borderLeftWidth', 'paddingTop',\r\n 'paddingRight', 'paddingBottom', 'paddingLeft',\r\n 'fontStyle', 'fontVariant', 'fontWeight', 'fontStretch',\r\n 'fontSize', 'fontSizeAdjust', 'lineHeight', 'fontFamily',\r\n 'textAlign', 'textTransform', 'textIndent',\r\n 'textDecoration', 'letterSpacing', 'wordSpacing'\r\n ]\r\n\r\n let isFirefox = (window.mozInnerScreenX !== null)\r\n\r\n let div = this.getDocument().createElement('div')\r\n div.id = 'input-textarea-caret-position-mirror-div'\r\n this.getDocument().body.appendChild(div)\r\n\r\n let style = div.style\r\n let computed = window.getComputedStyle ? getComputedStyle(element) : element.currentStyle\r\n\r\n style.whiteSpace = 'pre-wrap'\r\n if (element.nodeName !== 'INPUT') {\r\n style.wordWrap = 'break-word'\r\n }\r\n\r\n // position off-screen\r\n style.position = 'absolute'\r\n style.visibility = 'hidden'\r\n\r\n // transfer the element's properties to the div\r\n properties.forEach(prop => {\r\n style[prop] = computed[prop]\r\n })\r\n\r\n if (isFirefox) {\r\n style.width = `${(parseInt(computed.width) - 2)}px`\r\n if (element.scrollHeight > parseInt(computed.height))\r\n style.overflowY = 'scroll'\r\n } else {\r\n style.overflow = 'hidden'\r\n }\r\n\r\n div.textContent = element.value.substring(0, position)\r\n\r\n if (element.nodeName === 'INPUT') {\r\n div.textContent = div.textContent.replace(/\\s/g, ' ')\r\n }\r\n\r\n let span = this.getDocument().createElement('span')\r\n span.textContent = element.value.substring(position) || '.'\r\n div.appendChild(span)\r\n\r\n let rect = element.getBoundingClientRect()\r\n let doc = document.documentElement\r\n let windowLeft = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0)\r\n let windowTop = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0)\r\n\r\n let top = 0;\r\n let left = 0;\r\n if (this.menuContainerIsBody) {\r\n top = rect.top;\r\n left = rect.left;\r\n }\r\n\r\n let coordinates = {\r\n top: top + windowTop + span.offsetTop + parseInt(computed.borderTopWidth) + parseInt(computed.fontSize) - element.scrollTop,\r\n left: left + windowLeft + span.offsetLeft + parseInt(computed.borderLeftWidth)\r\n }\r\n\r\n let windowWidth = window.innerWidth\r\n let windowHeight = window.innerHeight\r\n\r\n let menuDimensions = this.getMenuDimensions()\r\n let menuIsOffScreen = this.isMenuOffScreen(coordinates, menuDimensions)\r\n\r\n if (menuIsOffScreen.right) {\r\n coordinates.right = windowWidth - coordinates.left\r\n coordinates.left = 'auto'\r\n }\r\n\r\n let parentHeight = this.tribute.menuContainer\r\n ? this.tribute.menuContainer.offsetHeight\r\n : this.getDocument().body.offsetHeight\r\n\r\n if (menuIsOffScreen.bottom) {\r\n let parentRect = this.tribute.menuContainer\r\n ? this.tribute.menuContainer.getBoundingClientRect()\r\n : this.getDocument().body.getBoundingClientRect()\r\n let scrollStillAvailable = parentHeight - (windowHeight - parentRect.top)\r\n\r\n coordinates.bottom = scrollStillAvailable + (windowHeight - rect.top - span.offsetTop)\r\n coordinates.top = 'auto'\r\n }\r\n\r\n menuIsOffScreen = this.isMenuOffScreen(coordinates, menuDimensions)\r\n if (menuIsOffScreen.left) {\r\n coordinates.left = windowWidth > menuDimensions.width\r\n ? windowLeft + windowWidth - menuDimensions.width\r\n : windowLeft\r\n delete coordinates.right\r\n }\r\n if (menuIsOffScreen.top) {\r\n coordinates.top = windowHeight > menuDimensions.height\r\n ? windowTop + windowHeight - menuDimensions.height\r\n : windowTop\r\n delete coordinates.bottom\r\n }\r\n\r\n this.getDocument().body.removeChild(div)\r\n return coordinates\r\n }\r\n\r\n getContentEditableCaretPosition(selectedNodePosition) {\r\n let markerTextChar = ''\r\n let markerEl, markerId = `sel_${new Date().getTime()}_${Math.random().toString().substr(2)}`\r\n let range\r\n let sel = this.getWindowSelection()\r\n let prevRange = sel.getRangeAt(0)\r\n\r\n range = this.getDocument().createRange()\r\n range.setStart(sel.anchorNode, selectedNodePosition)\r\n range.setEnd(sel.anchorNode, selectedNodePosition)\r\n\r\n range.collapse(false)\r\n\r\n // Create the marker element containing a single invisible character using DOM methods and insert it\r\n markerEl = this.getDocument().createElement('span')\r\n markerEl.id = markerId\r\n\r\n markerEl.appendChild(this.getDocument().createTextNode(markerTextChar))\r\n range.insertNode(markerEl)\r\n sel.removeAllRanges()\r\n sel.addRange(prevRange)\r\n\r\n let rect = markerEl.getBoundingClientRect()\r\n let doc = document.documentElement\r\n let windowLeft = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0)\r\n let windowTop = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0)\r\n\r\n let left = 0\r\n let top = 0\r\n if (this.menuContainerIsBody) {\r\n left = rect.left\r\n top = rect.top\r\n } else {\r\n left = markerEl.offsetLeft;\r\n top = markerEl.offsetTop;\r\n }\r\n\r\n let coordinates = {\r\n left: left + windowLeft,\r\n top: top + markerEl.offsetHeight + windowTop\r\n }\r\n let windowWidth = window.innerWidth\r\n let windowHeight = window.innerHeight\r\n\r\n let menuDimensions = this.getMenuDimensions()\r\n let menuIsOffScreen = this.isMenuOffScreen(coordinates, menuDimensions)\r\n\r\n if (menuIsOffScreen.right) {\r\n coordinates.left = 'auto'\r\n coordinates.right = windowWidth - rect.left - windowLeft\r\n }\r\n\r\n let parentHeight = this.tribute.menuContainer\r\n ? this.tribute.menuContainer.offsetHeight\r\n : this.getDocument().body.offsetHeight\r\n\r\n if (menuIsOffScreen.bottom) {\r\n let parentRect = this.tribute.menuContainer\r\n ? this.tribute.menuContainer.getBoundingClientRect()\r\n : this.getDocument().body.getBoundingClientRect()\r\n let scrollStillAvailable = parentHeight - (windowHeight - parentRect.top)\r\n\r\n coordinates.top = 'auto'\r\n coordinates.bottom = scrollStillAvailable + (windowHeight - rect.top)\r\n }\r\n\r\n menuIsOffScreen = this.isMenuOffScreen(coordinates, menuDimensions)\r\n if (menuIsOffScreen.left) {\r\n coordinates.left = windowWidth > menuDimensions.width\r\n ? windowLeft + windowWidth - menuDimensions.width\r\n : windowLeft\r\n delete coordinates.right\r\n }\r\n if (menuIsOffScreen.top) {\r\n coordinates.top = windowHeight > menuDimensions.height\r\n ? windowTop + windowHeight - menuDimensions.height\r\n : windowTop\r\n delete coordinates.bottom\r\n }\r\n\r\n markerEl.parentNode.removeChild(markerEl)\r\n return coordinates\r\n }\r\n\r\n scrollIntoView(elem) {\r\n let reasonableBuffer = 20,\r\n clientRect\r\n let maxScrollDisplacement = 100\r\n let e = this.menu\r\n\r\n if (typeof e === 'undefined') return;\r\n\r\n while (clientRect === undefined || clientRect.height === 0) {\r\n clientRect = e.getBoundingClientRect()\r\n\r\n if (clientRect.height === 0) {\r\n e = e.childNodes[0]\r\n if (e === undefined || !e.getBoundingClientRect) {\r\n return\r\n }\r\n }\r\n }\r\n\r\n let elemTop = clientRect.top\r\n let elemBottom = elemTop + clientRect.height\r\n\r\n if (elemTop < 0) {\r\n window.scrollTo(0, window.pageYOffset + clientRect.top - reasonableBuffer)\r\n } else if (elemBottom > window.innerHeight) {\r\n let maxY = window.pageYOffset + clientRect.top - reasonableBuffer\r\n\r\n if (maxY - window.pageYOffset > maxScrollDisplacement) {\r\n maxY = window.pageYOffset + maxScrollDisplacement\r\n }\r\n\r\n let targetY = window.pageYOffset - (window.innerHeight - elemBottom)\r\n\r\n if (targetY > maxY) {\r\n targetY = maxY\r\n }\r\n\r\n window.scrollTo(0, targetY)\r\n }\r\n }\r\n}\r\n\r\n\r\nexport default TributeRange;\r\n", - "// Thanks to https://github.com/mattyork/fuzzy\r\nclass TributeSearch {\r\n constructor(tribute) {\r\n this.tribute = tribute\r\n this.tribute.search = this\r\n }\r\n\r\n simpleFilter(pattern, array) {\r\n return array.filter(string => {\r\n return this.test(pattern, string)\r\n })\r\n }\r\n\r\n test(pattern, string) {\r\n return this.match(pattern, string) !== null\r\n }\r\n\r\n match(pattern, string, opts) {\r\n opts = opts || {}\r\n let patternIdx = 0,\r\n result = [],\r\n len = string.length,\r\n totalScore = 0,\r\n currScore = 0,\r\n pre = opts.pre || '',\r\n post = opts.post || '',\r\n compareString = opts.caseSensitive && string || string.toLowerCase(),\r\n ch, compareChar\r\n\r\n if (opts.skip) {\r\n return {rendered: string, score: 0}\r\n }\r\n\r\n pattern = opts.caseSensitive && pattern || pattern.toLowerCase()\r\n\r\n let patternCache = this.traverse(compareString, pattern, 0, 0, [])\r\n if (!patternCache) {\r\n return null\r\n }\r\n return {\r\n rendered: this.render(string, patternCache.cache, pre, post),\r\n score: patternCache.score\r\n }\r\n }\r\n\r\n traverse(string, pattern, stringIndex, patternIndex, patternCache) {\r\n // if the pattern search at end\r\n if (pattern.length === patternIndex) {\r\n\r\n // calculate score and copy the cache containing the indices where it's found\r\n return {\r\n score: this.calculateScore(patternCache),\r\n cache: patternCache.slice()\r\n }\r\n }\r\n\r\n // if string at end or remaining pattern > remaining string\r\n if (string.length === stringIndex || pattern.length - patternIndex > string.length - stringIndex) {\r\n return undefined\r\n }\r\n\r\n let c = pattern[patternIndex]\r\n let index = string.indexOf(c, stringIndex)\r\n let best, temp\r\n\r\n while (index > -1) {\r\n patternCache.push(index)\r\n temp = this.traverse(string, pattern, index + 1, patternIndex + 1, patternCache)\r\n patternCache.pop()\r\n\r\n // if downstream traversal failed, return best answer so far\r\n if (!temp) {\r\n return best\r\n }\r\n\r\n if (!best || best.score < temp.score) {\r\n best = temp\r\n }\r\n\r\n index = string.indexOf(c, index + 1)\r\n }\r\n\r\n return best\r\n }\r\n\r\n calculateScore(patternCache) {\r\n let score = 0\r\n let temp = 1\r\n\r\n patternCache.forEach((index, i) => {\r\n if (i > 0) {\r\n if (patternCache[i - 1] + 1 === index) {\r\n temp += temp + 1\r\n }\r\n else {\r\n temp = 1\r\n }\r\n }\r\n\r\n score += temp\r\n })\r\n\r\n return score\r\n }\r\n\r\n render(string, indices, pre, post) {\r\n var rendered = string.substring(0, indices[0])\r\n\r\n indices.forEach((index, i) => {\r\n rendered += pre + string[index] + post +\r\n string.substring(index + 1, (indices[i + 1]) ? indices[i + 1] : string.length)\r\n })\r\n\r\n return rendered\r\n }\r\n\r\n filter(pattern, arr, opts) {\r\n opts = opts || {}\r\n return arr\r\n .reduce((prev, element, idx, arr) => {\r\n let str = element\r\n\r\n if (opts.extract) {\r\n str = opts.extract(element)\r\n\r\n if (!str) { // take care of undefineds / nulls / etc.\r\n str = ''\r\n }\r\n }\r\n\r\n let rendered = this.match(pattern, str, opts)\r\n\r\n if (rendered != null) {\r\n prev[prev.length] = {\r\n string: rendered.rendered,\r\n score: rendered.score,\r\n index: idx,\r\n original: element\r\n }\r\n }\r\n\r\n return prev\r\n }, [])\r\n\r\n .sort((a, b) => {\r\n let compare = b.score - a.score\r\n if (compare) return compare\r\n return a.index - b.index\r\n })\r\n }\r\n}\r\n\r\nexport default TributeSearch;\r\n", - "/**\r\n* Tribute.js\r\n* Native ES6 JavaScript @mention Plugin\r\n**/\r\n\r\nimport Tribute from \"./Tribute\";\r\n\r\nexport default Tribute;\r\n", - "if (!Array.prototype.find) {\r\n Array.prototype.find = function(predicate) {\r\n if (this === null) {\r\n throw new TypeError('Array.prototype.find called on null or undefined')\r\n }\r\n if (typeof predicate !== 'function') {\r\n throw new TypeError('predicate must be a function')\r\n }\r\n var list = Object(this)\r\n var length = list.length >>> 0\r\n var thisArg = arguments[1]\r\n var value\r\n\r\n for (var i = 0; i < length; i++) {\r\n value = list[i]\r\n if (predicate.call(thisArg, value, i, list)) {\r\n return value\r\n }\r\n }\r\n return undefined\r\n }\r\n}\r\n\r\nif (window && typeof window.CustomEvent !== \"function\") {\r\n function CustomEvent(event, params) {\r\n params = params || {\r\n bubbles: false,\r\n cancelable: false,\r\n detail: undefined\r\n }\r\n var evt = document.createEvent('CustomEvent')\r\n evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail)\r\n return evt\r\n }\r\n\r\n if (typeof window.Event !== 'undefined') {\r\n CustomEvent.prototype = window.Event.prototype\r\n }\r\n\r\n window.CustomEvent = CustomEvent\r\n}" + "import \"./utils\";\nimport TributeEvents from \"./TributeEvents\";\nimport TributeMenuEvents from \"./TributeMenuEvents\";\nimport TributeRange from \"./TributeRange\";\nimport TributeSearch from \"./TributeSearch\";\n\nclass Tribute {\n constructor({\n values = null,\n iframe = null,\n selectClass = 'highlight',\n containerClass = 'tribute-container',\n trigger = '@',\n autocompleteMode = false,\n selectTemplate = null,\n menuItemTemplate = null,\n lookup = 'key',\n fillAttr = 'value',\n collection = null,\n menuContainer = null,\n noMatchTemplate = null,\n requireLeadingSpace = true,\n allowSpaces = false,\n replaceTextSuffix = null,\n positionMenu = true,\n spaceSelectsMatch = false,\n searchOpts = {},\n menuItemLimit = null,\n }) {\n this.autocompleteMode = autocompleteMode\n this.menuSelected = 0\n this.current = {}\n this.inputEvent = false\n this.isActive = false\n this.menuContainer = menuContainer\n this.allowSpaces = allowSpaces\n this.replaceTextSuffix = replaceTextSuffix\n this.positionMenu = positionMenu\n this.hasTrailingSpace = false;\n this.spaceSelectsMatch = spaceSelectsMatch;\n\n if (this.autocompleteMode) {\n trigger = ''\n allowSpaces = false\n }\n\n if (values) {\n this.collection = [{\n // symbol that starts the lookup\n trigger: trigger,\n\n // is it wrapped in an iframe\n iframe: iframe,\n\n // class applied to selected item\n selectClass: selectClass,\n\n // class applied to the Container \n containerClass: containerClass,\n\n // function called on select that retuns the content to insert\n selectTemplate: (selectTemplate || Tribute.defaultSelectTemplate).bind(this),\n\n // function called that returns content for an item\n menuItemTemplate: (menuItemTemplate || Tribute.defaultMenuItemTemplate).bind(this),\n\n // function called when menu is empty, disables hiding of menu.\n noMatchTemplate: (t => {\n if (typeof t === 'function') {\n return t.bind(this)\n }\n\n return noMatchTemplate || function () {return ''}.bind(this)\n })(noMatchTemplate),\n\n // column to search against in the object\n lookup: lookup,\n\n // column that contains the content to insert by default\n fillAttr: fillAttr,\n\n // array of objects or a function returning an array of objects\n values: values,\n\n requireLeadingSpace: requireLeadingSpace,\n\n searchOpts: searchOpts,\n\n menuItemLimit: menuItemLimit,\n }]\n }\n else if (collection) {\n if (this.autocompleteMode)\n console.warn('Tribute in autocomplete mode does not work for collections')\n this.collection = collection.map(item => {\n return {\n trigger: item.trigger || trigger,\n iframe: item.iframe || iframe,\n selectClass: item.selectClass || selectClass,\n containerClass: item.containerClass || containerClass,\n selectTemplate: (item.selectTemplate || Tribute.defaultSelectTemplate).bind(this),\n menuItemTemplate: (item.menuItemTemplate || Tribute.defaultMenuItemTemplate).bind(this),\n // function called when menu is empty, disables hiding of menu.\n noMatchTemplate: (t => {\n if (typeof t === 'function') {\n return t.bind(this)\n }\n\n return null\n })(noMatchTemplate),\n lookup: item.lookup || lookup,\n fillAttr: item.fillAttr || fillAttr,\n values: item.values,\n requireLeadingSpace: item.requireLeadingSpace,\n searchOpts: item.searchOpts || searchOpts,\n menuItemLimit: item.menuItemLimit || menuItemLimit,\n }\n })\n }\n else {\n throw new Error('[Tribute] No collection specified.')\n }\n\n new TributeRange(this)\n new TributeEvents(this)\n new TributeMenuEvents(this)\n new TributeSearch(this)\n }\n\n static defaultSelectTemplate(item) {\n if (typeof item === 'undefined') return null;\n if (this.range.isContentEditable(this.current.element)) {\n return '' + (this.current.collection.trigger + item.original[this.current.collection.fillAttr]) + '';\n }\n\n return this.current.collection.trigger + item.original[this.current.collection.fillAttr];\n }\n\n static defaultMenuItemTemplate(matchItem) {\n return matchItem.string\n }\n\n static inputTypes() {\n return ['TEXTAREA', 'INPUT']\n }\n\n triggers() {\n return this.collection.map(config => {\n return config.trigger\n })\n }\n\n attach(el) {\n if (!el) {\n throw new Error('[Tribute] Must pass in a DOM node or NodeList.')\n }\n\n // Check if it is a jQuery collection\n if (typeof jQuery !== 'undefined' && el instanceof jQuery) {\n el = el.get()\n }\n\n // Is el an Array/Array-like object?\n if (el.constructor === NodeList || el.constructor === HTMLCollection || el.constructor === Array) {\n let length = el.length\n for (var i = 0; i < length; ++i) {\n this._attach(el[i])\n }\n } else {\n this._attach(el)\n }\n }\n\n _attach(el) {\n if (el.hasAttribute('data-tribute')) {\n console.warn('Tribute was already bound to ' + el.nodeName)\n }\n\n this.ensureEditable(el)\n this.events.bind(el)\n el.setAttribute('data-tribute', true)\n }\n\n ensureEditable(element) {\n if (Tribute.inputTypes().indexOf(element.nodeName) === -1) {\n if (element.contentEditable) {\n element.contentEditable = true\n } else {\n throw new Error('[Tribute] Cannot bind to ' + element.nodeName)\n }\n }\n }\n\n createMenu(containerClass) {\n let wrapper = this.range.getDocument().createElement('div'),\n ul = this.range.getDocument().createElement('ul')\n wrapper.className = containerClass\n wrapper.appendChild(ul)\n\n if (this.menuContainer) {\n return this.menuContainer.appendChild(wrapper)\n }\n\n return this.range.getDocument().body.appendChild(wrapper)\n }\n\n showMenuFor(element, scrollTo) {\n // Only proceed if menu isn't already shown for the current element & mentionText\n if (this.isActive && this.current.element === element && this.current.mentionText === this.currentMentionTextSnapshot) {\n return\n }\n this.currentMentionTextSnapshot = this.current.mentionText\n\n // create the menu if it doesn't exist.\n if (!this.menu) {\n this.menu = this.createMenu(this.current.collection.containerClass)\n element.tributeMenu = this.menu\n this.menuEvents.bind(this.menu)\n }\n\n this.isActive = true\n this.menuSelected = 0\n\n if (!this.current.mentionText) {\n this.current.mentionText = ''\n }\n\n const processValues = (values) => {\n // Tribute may not be active any more by the time the value callback returns\n if (!this.isActive) {\n return\n }\n\n let items = this.search.filter(this.current.mentionText, values, {\n pre: this.current.collection.searchOpts.pre || '',\n post: this.current.collection.searchOpts.post || '',\n skip: this.current.collection.searchOpts.skip,\n extract: (el) => {\n if (typeof this.current.collection.lookup === 'string') {\n return el[this.current.collection.lookup]\n } else if (typeof this.current.collection.lookup === 'function') {\n return this.current.collection.lookup(el, this.current.mentionText)\n } else {\n throw new Error('Invalid lookup attribute, lookup must be string or function.')\n }\n }\n })\n\n if (this.current.collection.menuItemLimit) {\n items = items.slice(0, this.current.collection.menuItemLimit)\n }\n\n this.current.filteredItems = items\n\n\n let ul = this.menu.querySelector('ul')\n\n this.range.positionMenuAtCaret(scrollTo)\n\n if (!items.length) {\n let noMatchEvent = new CustomEvent('tribute-no-match', { detail: this.menu })\n this.current.element.dispatchEvent(noMatchEvent)\n if ( typeof this.current.collection.noMatchTemplate === 'function' && !this.current.collection.noMatchTemplate() || !this.current.collection.noMatchTemplate) {\n this.hideMenu()\n } else {\n typeof this.current.collection.noMatchTemplate === 'function' ? ul.innerHTML = this.current.collection.noMatchTemplate() : ul.innerHTML = this.current.collection.noMatchTemplate\n }\n\n return\n }\n\n ul.innerHTML = ''\n let fragment = this.range.getDocument().createDocumentFragment()\n\n items.forEach((item, index) => {\n let li = this.range.getDocument().createElement('li')\n li.setAttribute('data-index', index)\n li.addEventListener('mousemove', (e) => {\n let [li, index] = this._findLiTarget(e.target)\n if (e.movementY !== 0) {\n this.events.setActiveLi(index)\n }\n })\n if (this.menuSelected === index) {\n li.className = this.current.collection.selectClass\n }\n li.innerHTML = this.current.collection.menuItemTemplate(item)\n fragment.appendChild(li)\n })\n ul.appendChild(fragment)\n }\n\n if (typeof this.current.collection.values === 'function') {\n this.current.collection.values(this.current.mentionText, processValues)\n } else {\n processValues(this.current.collection.values)\n }\n }\n\n _findLiTarget(el) {\n if (!el) return []\n const index = el.getAttribute('data-index');\n return !index ?\n this._findLiTarget(el.parentNode) :\n [el, index]\n }\n\n showMenuForCollection(element, collectionIndex) {\n if (element !== document.activeElement) {\n this.placeCaretAtEnd(element)\n }\n\n this.current.collection = this.collection[collectionIndex || 0]\n this.current.externalTrigger = true\n this.current.element = element\n\n if (element.isContentEditable)\n this.insertTextAtCursor(this.current.collection.trigger)\n else\n this.insertAtCaret(element, this.current.collection.trigger)\n\n this.showMenuFor(element)\n }\n\n // TODO: make sure this works for inputs/textareas\n placeCaretAtEnd(el) {\n el.focus();\n if (typeof window.getSelection != \"undefined\"\n && typeof document.createRange != \"undefined\") {\n var range = document.createRange();\n range.selectNodeContents(el);\n range.collapse(false);\n var sel = window.getSelection();\n sel.removeAllRanges();\n sel.addRange(range);\n } else if (typeof document.body.createTextRange != \"undefined\") {\n var textRange = document.body.createTextRange();\n textRange.moveToElementText(el);\n textRange.collapse(false);\n textRange.select();\n }\n }\n\n // for contenteditable\n insertTextAtCursor(text) {\n var sel, range, html;\n sel = window.getSelection();\n range = sel.getRangeAt(0);\n range.deleteContents();\n var textNode = document.createTextNode(text);\n range.insertNode(textNode);\n range.selectNodeContents(textNode)\n range.collapse(false)\n sel.removeAllRanges()\n sel.addRange(range)\n }\n\n // for regular inputs\n insertAtCaret(textarea, text) {\n var scrollPos = textarea.scrollTop;\n var caretPos = textarea.selectionStart;\n\n var front = (textarea.value).substring(0, caretPos);\n var back = (textarea.value).substring(textarea.selectionEnd, textarea.value.length);\n textarea.value = front + text + back;\n caretPos = caretPos + text.length;\n textarea.selectionStart = caretPos;\n textarea.selectionEnd = caretPos;\n textarea.focus();\n textarea.scrollTop = scrollPos;\n }\n\n hideMenu() {\n if (this.menu) {\n this.menu.style.cssText = 'display: none;'\n this.isActive = false\n this.menuSelected = 0\n this.current = {}\n }\n }\n\n selectItemAtIndex(index, originalEvent) {\n index = parseInt(index)\n if (typeof index !== 'number' || isNaN(index)) return\n let item = this.current.filteredItems[index]\n let content = this.current.collection.selectTemplate(item)\n if (content !== null) this.replaceText(content, originalEvent, item)\n }\n\n replaceText(content, originalEvent, item) {\n this.range.replaceTriggerText(content, true, true, originalEvent, item)\n }\n\n _append(collection, newValues, replace) {\n if (typeof collection.values === 'function') {\n throw new Error('Unable to append to values, as it is a function.')\n } else if (!replace) {\n collection.values = collection.values.concat(newValues)\n } else {\n collection.values = newValues\n }\n }\n\n append(collectionIndex, newValues, replace) {\n let index = parseInt(collectionIndex)\n if (typeof index !== 'number') throw new Error('please provide an index for the collection to update.')\n\n let collection = this.collection[index]\n\n this._append(collection, newValues, replace)\n }\n\n appendCurrent(newValues, replace) {\n if (this.isActive) {\n this._append(this.current.collection, newValues, replace)\n } else {\n throw new Error('No active state. Please use append instead and pass an index.')\n }\n }\n\n detach(el) {\n if (!el) {\n throw new Error('[Tribute] Must pass in a DOM node or NodeList.')\n }\n\n // Check if it is a jQuery collection\n if (typeof jQuery !== 'undefined' && el instanceof jQuery) {\n el = el.get()\n }\n\n // Is el an Array/Array-like object?\n if (el.constructor === NodeList || el.constructor === HTMLCollection || el.constructor === Array) {\n let length = el.length\n for (var i = 0; i < length; ++i) {\n this._detach(el[i])\n }\n } else {\n this._detach(el)\n }\n }\n\n _detach(el) {\n this.events.unbind(el)\n if (el.tributeMenu) {\n this.menuEvents.unbind(el.tributeMenu)\n }\n\n setTimeout(() => {\n el.removeAttribute('data-tribute')\n this.isActive = false\n if (el.tributeMenu) {\n el.tributeMenu.remove()\n }\n })\n }\n}\n\nexport default Tribute;\n", + "class TributeEvents {\n constructor(tribute) {\n this.tribute = tribute\n this.tribute.events = this\n }\n\n static keys() {\n return [{\n key: 9,\n value: 'TAB'\n }, {\n key: 8,\n value: 'DELETE'\n }, {\n key: 13,\n value: 'ENTER'\n }, {\n key: 27,\n value: 'ESCAPE'\n }, {\n key: 32,\n value: 'SPACE'\n }, {\n key: 38,\n value: 'UP'\n }, {\n key: 40,\n value: 'DOWN'\n }]\n }\n\n bind(element) {\n element.boundKeydown = this.keydown.bind(element, this);\n element.boundKeyup = this.keyup.bind(element, this);\n element.boundInput = this.input.bind(element, this);\n\n element.addEventListener('keydown',\n element.boundKeydown, false)\n element.addEventListener('keyup',\n element.boundKeyup, false)\n element.addEventListener('input',\n element.boundInput, false)\n }\n\n unbind(element) {\n element.removeEventListener('keydown',\n element.boundKeydown, false)\n element.removeEventListener('keyup',\n element.boundKeyup, false)\n element.removeEventListener('input',\n element.boundInput, false)\n\n delete element.boundKeydown\n delete element.boundKeyup\n delete element.boundInput\n }\n\n keydown(instance, event) {\n if (instance.shouldDeactivate(event)) {\n instance.tribute.isActive = false\n instance.tribute.hideMenu()\n }\n\n let element = this\n instance.commandEvent = false\n\n TributeEvents.keys().forEach(o => {\n if (o.key === event.keyCode) {\n instance.commandEvent = true\n instance.callbacks()[o.value.toLowerCase()](event, element)\n }\n })\n }\n\n input(instance, event) {\n instance.inputEvent = true\n instance.keyup.call(this, instance, event)\n }\n\n click(instance, event) {\n let tribute = instance.tribute\n if (tribute.menu && tribute.menu.contains(event.target)) {\n let li = event.target\n event.preventDefault()\n event.stopPropagation()\n while (li.nodeName.toLowerCase() !== 'li') {\n li = li.parentNode\n if (!li || li === tribute.menu) {\n throw new Error('cannot find the
  • container for the click')\n }\n }\n tribute.selectItemAtIndex(li.getAttribute('data-index'), event)\n tribute.hideMenu()\n\n // TODO: should fire with externalTrigger and target is outside of menu\n } else if (tribute.current.element && !tribute.current.externalTrigger) {\n tribute.current.externalTrigger = false\n setTimeout(() => tribute.hideMenu())\n }\n }\n\n keyup(instance, event) {\n if (instance.inputEvent) {\n instance.inputEvent = false\n }\n instance.updateSelection(this)\n\n if (event.keyCode === 27) return\n\n if (!instance.tribute.allowSpaces && instance.tribute.hasTrailingSpace) {\n instance.tribute.hasTrailingSpace = false;\n instance.commandEvent = true;\n instance.callbacks()[\"space\"](event, this);\n return\n }\n\n if (!instance.tribute.isActive) {\n if (instance.tribute.autocompleteMode) {\n instance.callbacks().triggerChar(event, this, '')\n } else {\n let keyCode = instance.getKeyCode(instance, this, event)\n \n if (isNaN(keyCode) || !keyCode) return\n \n let trigger = instance.tribute.triggers().find(trigger => {\n return trigger.charCodeAt(0) === keyCode\n })\n \n if (typeof trigger !== 'undefined') {\n instance.callbacks().triggerChar(event, this, trigger)\n }\n }\n }\n\n if ((instance.tribute.current.trigger || instance.tribute.autocompleteMode)\n && instance.commandEvent === false\n || instance.tribute.isActive && event.keyCode === 8) {\n instance.tribute.showMenuFor(this, true)\n }\n }\n\n shouldDeactivate(event) {\n if (!this.tribute.isActive) return false\n\n if (this.tribute.current.mentionText.length === 0) {\n let eventKeyPressed = false\n TributeEvents.keys().forEach(o => {\n if (event.keyCode === o.key) eventKeyPressed = true\n })\n\n return !eventKeyPressed\n }\n\n return false\n }\n\n getKeyCode(instance, el, event) {\n let char\n let tribute = instance.tribute\n let info = tribute.range.getTriggerInfo(false, tribute.hasTrailingSpace, true, tribute.allowSpaces, tribute.autocompleteMode)\n\n if (info) {\n return info.mentionTriggerChar.charCodeAt(0)\n } else {\n return false\n }\n }\n\n updateSelection(el) {\n this.tribute.current.element = el\n let info = this.tribute.range.getTriggerInfo(false, this.tribute.hasTrailingSpace, true, this.tribute.allowSpaces, this.tribute.autocompleteMode)\n\n if (info) {\n this.tribute.current.selectedPath = info.mentionSelectedPath\n this.tribute.current.mentionText = info.mentionText\n this.tribute.current.selectedOffset = info.mentionSelectedOffset\n }\n }\n\n callbacks() {\n return {\n triggerChar: (e, el, trigger) => {\n let tribute = this.tribute\n tribute.current.trigger = trigger\n\n let collectionItem = tribute.collection.find(item => {\n return item.trigger === trigger\n })\n\n tribute.current.collection = collectionItem\n if (tribute.inputEvent) tribute.showMenuFor(el, true)\n },\n enter: (e, el) => {\n // choose selection\n if (this.tribute.isActive && this.tribute.current.filteredItems) {\n e.preventDefault()\n e.stopPropagation()\n setTimeout(() => {\n this.tribute.selectItemAtIndex(this.tribute.menuSelected, e)\n this.tribute.hideMenu()\n }, 0)\n }\n },\n escape: (e, el) => {\n if (this.tribute.isActive) {\n e.preventDefault()\n e.stopPropagation()\n this.tribute.isActive = false\n this.tribute.hideMenu()\n }\n },\n tab: (e, el) => {\n // choose first match\n this.callbacks().enter(e, el)\n },\n space: (e, el) => {\n if (this.tribute.isActive) {\n if (this.tribute.spaceSelectsMatch) {\n this.callbacks().enter(e, el)\n } else if (!this.tribute.allowSpaces) {\n e.stopPropagation();\n setTimeout(() => {\n this.tribute.hideMenu();\n this.tribute.isActive = false;\n }, 0);\n }\n }\n },\n up: (e, el) => {\n // navigate up ul\n if (this.tribute.isActive && this.tribute.current.filteredItems) {\n e.preventDefault()\n e.stopPropagation()\n let count = this.tribute.current.filteredItems.length,\n selected = this.tribute.menuSelected\n\n if (count > selected && selected > 0) {\n this.tribute.menuSelected--\n this.setActiveLi()\n } else if (selected === 0) {\n this.tribute.menuSelected = count - 1\n this.setActiveLi()\n this.tribute.menu.scrollTop = this.tribute.menu.scrollHeight\n }\n }\n },\n down: (e, el) => {\n // navigate down ul\n if (this.tribute.isActive && this.tribute.current.filteredItems) {\n e.preventDefault()\n e.stopPropagation()\n let count = this.tribute.current.filteredItems.length - 1,\n selected = this.tribute.menuSelected\n\n if (count > selected) {\n this.tribute.menuSelected++\n this.setActiveLi()\n } else if (count === selected) {\n this.tribute.menuSelected = 0\n this.setActiveLi()\n this.tribute.menu.scrollTop = 0\n }\n }\n },\n delete: (e, el) => {\n if (this.tribute.isActive && this.tribute.current.mentionText.length < 1) {\n this.tribute.hideMenu()\n } else if (this.tribute.isActive) {\n this.tribute.showMenuFor(el)\n }\n }\n }\n }\n\n setActiveLi(index) {\n let lis = this.tribute.menu.querySelectorAll('li'),\n length = lis.length >>> 0\n\n if (index) this.tribute.menuSelected = parseInt(index);\n\n for (let i = 0; i < length; i++) {\n let li = lis[i]\n if (i === this.tribute.menuSelected) {\n li.classList.add(this.tribute.current.collection.selectClass);\n\n let liClientRect = li.getBoundingClientRect();\n let menuClientRect = this.tribute.menu.getBoundingClientRect();\n\n if (liClientRect.bottom > menuClientRect.bottom) {\n let scrollDistance = liClientRect.bottom - menuClientRect.bottom;\n this.tribute.menu.scrollTop += scrollDistance\n } else if (liClientRect.top < menuClientRect.top) {\n let scrollDistance = menuClientRect.top - liClientRect.top;\n this.tribute.menu.scrollTop -= scrollDistance\n }\n\n } else {\n li.classList.remove(this.tribute.current.collection.selectClass);\n }\n }\n }\n\n getFullHeight(elem, includeMargin) {\n let height = elem.getBoundingClientRect().height\n\n if (includeMargin) {\n let style = elem.currentStyle || window.getComputedStyle(elem)\n return height + parseFloat(style.marginTop) + parseFloat(style.marginBottom)\n }\n\n return height\n }\n\n}\n\nexport default TributeEvents;\n", + "class TributeMenuEvents {\n constructor(tribute) {\n this.tribute = tribute\n this.tribute.menuEvents = this\n this.menu = this.tribute.menu\n }\n\n bind(menu) {\n this.menuClickEvent = this.tribute.events.click.bind(null, this)\n this.menuContainerScrollEvent = this.debounce(() => {\n if (this.tribute.isActive) {\n this.tribute.showMenuFor(this.tribute.current.element, false)\n }\n }, 300, false)\n this.windowResizeEvent = this.debounce(() => {\n if (this.tribute.isActive) {\n this.tribute.range.positionMenuAtCaret(true)\n }\n }, 300, false)\n\n // fixes IE11 issues with mousedown\n this.tribute.range.getDocument().addEventListener('MSPointerDown',\n this.menuClickEvent, false)\n this.tribute.range.getDocument().addEventListener('mousedown',\n this.menuClickEvent, false)\n window.addEventListener('resize', this.windowResizeEvent)\n\n if (this.menuContainer) {\n this.menuContainer.addEventListener('scroll', this.menuContainerScrollEvent, false)\n } else {\n window.addEventListener('scroll', this.menuContainerScrollEvent)\n }\n\n }\n\n unbind(menu) {\n this.tribute.range.getDocument().removeEventListener('mousedown',\n this.menuClickEvent, false)\n this.tribute.range.getDocument().removeEventListener('MSPointerDown',\n this.menuClickEvent, false)\n window.removeEventListener('resize', this.windowResizeEvent)\n\n if (this.menuContainer) {\n this.menuContainer.removeEventListener('scroll', this.menuContainerScrollEvent, false)\n } else {\n window.removeEventListener('scroll', this.menuContainerScrollEvent)\n }\n }\n\n debounce(func, wait, immediate) {\n var timeout\n return () => {\n var context = this,\n args = arguments\n var later = () => {\n timeout = null\n if (!immediate) func.apply(context, args)\n }\n var callNow = immediate && !timeout\n clearTimeout(timeout)\n timeout = setTimeout(later, wait)\n if (callNow) func.apply(context, args)\n }\n }\n}\n\n\nexport default TributeMenuEvents;\n", + "// Thanks to https://github.com/jeff-collins/ment.io\nimport \"./utils\";\n\nclass TributeRange {\n constructor(tribute) {\n this.tribute = tribute\n this.tribute.range = this\n }\n\n getDocument() {\n let iframe\n if (this.tribute.current.collection) {\n iframe = this.tribute.current.collection.iframe\n }\n\n if (!iframe) {\n return document\n }\n\n return iframe.contentWindow.document\n }\n\n positionMenuAtCaret(scrollTo) {\n let context = this.tribute.current,\n coordinates\n\n let info = this.getTriggerInfo(false, this.tribute.hasTrailingSpace, true, this.tribute.allowSpaces, this.tribute.autocompleteMode)\n\n if (typeof info !== 'undefined') {\n\n if(!this.tribute.positionMenu){\n this.tribute.menu.style.cssText = `display: block;`\n return\n }\n\n if (!this.isContentEditable(context.element)) {\n coordinates = this.getTextAreaOrInputUnderlinePosition(this.tribute.current.element,\n info.mentionPosition)\n }\n else {\n coordinates = this.getContentEditableCaretPosition(info.mentionPosition)\n }\n\n this.tribute.menu.style.cssText = `top: ${coordinates.top}px;\n left: ${coordinates.left}px;\n right: ${coordinates.right}px;\n bottom: ${coordinates.bottom}px;\n position: absolute;\n display: block;`\n\n if (coordinates.left === 'auto') {\n this.tribute.menu.style.left = 'auto'\n }\n\n if (coordinates.top === 'auto') {\n this.tribute.menu.style.top = 'auto'\n }\n\n if (scrollTo) this.scrollIntoView()\n\n window.setTimeout(() => {\n let menuDimensions = {\n width: this.tribute.menu.offsetWidth,\n height: this.tribute.menu.offsetHeight\n }\n let menuIsOffScreen = this.isMenuOffScreen(coordinates, menuDimensions)\n\n let menuIsOffScreenHorizontally = window.innerWidth > menuDimensions.width && (menuIsOffScreen.left || menuIsOffScreen.right)\n let menuIsOffScreenVertically = window.innerHeight > menuDimensions.height && (menuIsOffScreen.top || menuIsOffScreen.bottom)\n if (menuIsOffScreenHorizontally || menuIsOffScreenVertically) {\n this.tribute.menu.style.cssText = 'display: none'\n this.positionMenuAtCaret(scrollTo)\n }\n }, 0)\n\n } else {\n this.tribute.menu.style.cssText = 'display: none'\n }\n }\n\n get menuContainerIsBody() {\n return this.tribute.menuContainer === document.body || !this.tribute.menuContainer;\n }\n\n\n selectElement(targetElement, path, offset) {\n let range\n let elem = targetElement\n\n if (path) {\n for (var i = 0; i < path.length; i++) {\n elem = elem.childNodes[path[i]]\n if (elem === undefined) {\n return\n }\n while (elem.length < offset) {\n offset -= elem.length\n elem = elem.nextSibling\n }\n if (elem.childNodes.length === 0 && !elem.length) {\n elem = elem.previousSibling\n }\n }\n }\n let sel = this.getWindowSelection()\n\n range = this.getDocument().createRange()\n range.setStart(elem, offset)\n range.setEnd(elem, offset)\n range.collapse(true)\n\n try {\n sel.removeAllRanges()\n } catch (error) {}\n\n sel.addRange(range)\n targetElement.focus()\n }\n\n replaceTriggerText(text, requireLeadingSpace, hasTrailingSpace, originalEvent, item) {\n let info = this.getTriggerInfo(true, hasTrailingSpace, requireLeadingSpace, this.tribute.allowSpaces, this.tribute.autocompleteMode)\n\n if (info !== undefined) {\n let context = this.tribute.current\n let replaceEvent = new CustomEvent('tribute-replaced', {\n detail: {\n item: item,\n instance: context,\n context: info,\n event: originalEvent,\n }\n })\n\n if (!this.isContentEditable(context.element)) {\n let myField = this.tribute.current.element\n let textSuffix = typeof this.tribute.replaceTextSuffix == 'string'\n ? this.tribute.replaceTextSuffix\n : ' '\n text += textSuffix\n let startPos = info.mentionPosition\n let endPos = info.mentionPosition + info.mentionText.length + textSuffix.length\n if (!this.tribute.autocompleteMode) {\n endPos += info.mentionTriggerChar.length - 1\n }\n myField.value = myField.value.substring(0, startPos) + text +\n myField.value.substring(endPos, myField.value.length)\n myField.selectionStart = startPos + text.length\n myField.selectionEnd = startPos + text.length\n } else {\n // add a space to the end of the pasted text\n let textSuffix = typeof this.tribute.replaceTextSuffix == 'string'\n ? this.tribute.replaceTextSuffix\n : '\\xA0'\n text += textSuffix\n let endPos = info.mentionPosition + info.mentionText.length\n if (!this.tribute.autocompleteMode) {\n endPos += info.mentionTriggerChar.length\n }\n this.pasteHtml(text, info.mentionPosition, endPos)\n }\n \n context.element.dispatchEvent(new CustomEvent('input', { bubbles: true }))\n context.element.dispatchEvent(replaceEvent)\n }\n }\n\n pasteHtml(html, startPos, endPos) {\n let range, sel\n sel = this.getWindowSelection()\n range = this.getDocument().createRange()\n range.setStart(sel.anchorNode, startPos)\n range.setEnd(sel.anchorNode, endPos)\n range.deleteContents()\n\n let el = this.getDocument().createElement('div')\n el.innerHTML = html\n let frag = this.getDocument().createDocumentFragment(),\n node, lastNode\n while ((node = el.firstChild)) {\n lastNode = frag.appendChild(node)\n }\n range.insertNode(frag)\n\n // Preserve the selection\n if (lastNode) {\n range = range.cloneRange()\n range.setStartAfter(lastNode)\n range.collapse(true)\n sel.removeAllRanges()\n sel.addRange(range)\n }\n }\n\n getWindowSelection() {\n if (this.tribute.collection.iframe) {\n return this.tribute.collection.iframe.contentWindow.getSelection()\n }\n\n return window.getSelection()\n }\n\n getNodePositionInParent(element) {\n if (element.parentNode === null) {\n return 0\n }\n\n for (var i = 0; i < element.parentNode.childNodes.length; i++) {\n let node = element.parentNode.childNodes[i]\n\n if (node === element) {\n return i\n }\n }\n }\n\n getContentEditableSelectedPath(ctx) {\n let sel = this.getWindowSelection()\n let selected = sel.anchorNode\n let path = []\n let offset\n\n if (selected != null) {\n let i\n let ce = selected.contentEditable\n while (selected !== null && ce !== 'true') {\n i = this.getNodePositionInParent(selected)\n path.push(i)\n selected = selected.parentNode\n if (selected !== null) {\n ce = selected.contentEditable\n }\n }\n path.reverse()\n\n // getRangeAt may not exist, need alternative\n offset = sel.getRangeAt(0).startOffset\n\n return {\n selected: selected,\n path: path,\n offset: offset\n }\n }\n }\n\n getTextPrecedingCurrentSelection() {\n let context = this.tribute.current,\n text = ''\n\n if (!this.isContentEditable(context.element)) {\n let textComponent = this.tribute.current.element;\n if (textComponent) {\n let startPos = textComponent.selectionStart\n if (textComponent.value && startPos >= 0) {\n text = textComponent.value.substring(0, startPos)\n }\n }\n\n } else {\n let selectedElem = this.getWindowSelection().anchorNode\n\n if (selectedElem != null) {\n let workingNodeContent = selectedElem.textContent\n let selectStartOffset = this.getWindowSelection().getRangeAt(0).startOffset\n\n if (workingNodeContent && selectStartOffset >= 0) {\n text = workingNodeContent.substring(0, selectStartOffset)\n }\n }\n }\n\n return text\n }\n\n getLastWordInText(text) {\n text = text.replace(/\\u00A0/g, ' '); // https://stackoverflow.com/questions/29850407/how-do-i-replace-unicode-character-u00a0-with-a-space-in-javascript\n let wordsArray = text.split(/\\s+/);\n let worldsCount = wordsArray.length - 1\n return wordsArray[worldsCount].trim()\n }\n\n getTriggerInfo(menuAlreadyActive, hasTrailingSpace, requireLeadingSpace, allowSpaces, isAutocomplete) {\n let ctx = this.tribute.current\n let selected, path, offset\n\n if (!this.isContentEditable(ctx.element)) {\n selected = this.tribute.current.element\n } else {\n let selectionInfo = this.getContentEditableSelectedPath(ctx)\n\n if (selectionInfo) {\n selected = selectionInfo.selected\n path = selectionInfo.path\n offset = selectionInfo.offset\n }\n }\n\n let effectiveRange = this.getTextPrecedingCurrentSelection()\n let lastWordOfEffectiveRange = this.getLastWordInText(effectiveRange)\n\n if (isAutocomplete) {\n return {\n mentionPosition: effectiveRange.length - lastWordOfEffectiveRange.length,\n mentionText: lastWordOfEffectiveRange,\n mentionSelectedElement: selected,\n mentionSelectedPath: path,\n mentionSelectedOffset: offset\n }\n }\n\n if (effectiveRange !== undefined && effectiveRange !== null) {\n let mostRecentTriggerCharPos = -1\n let triggerChar\n\n this.tribute.collection.forEach(config => {\n let c = config.trigger\n let idx = config.requireLeadingSpace ?\n this.lastIndexWithLeadingSpace(effectiveRange, c) :\n effectiveRange.lastIndexOf(c)\n\n if (idx > mostRecentTriggerCharPos) {\n mostRecentTriggerCharPos = idx\n triggerChar = c\n requireLeadingSpace = config.requireLeadingSpace\n }\n })\n\n if (mostRecentTriggerCharPos >= 0 &&\n (\n mostRecentTriggerCharPos === 0 ||\n !requireLeadingSpace ||\n /[\\xA0\\s]/g.test(\n effectiveRange.substring(\n mostRecentTriggerCharPos - 1,\n mostRecentTriggerCharPos)\n )\n )\n ) {\n let currentTriggerSnippet = effectiveRange.substring(mostRecentTriggerCharPos + triggerChar.length,\n effectiveRange.length)\n\n triggerChar = effectiveRange.substring(mostRecentTriggerCharPos, mostRecentTriggerCharPos + triggerChar.length)\n let firstSnippetChar = currentTriggerSnippet.substring(0, 1)\n let leadingSpace = currentTriggerSnippet.length > 0 &&\n (\n firstSnippetChar === ' ' ||\n firstSnippetChar === '\\xA0'\n )\n if (hasTrailingSpace) {\n currentTriggerSnippet = currentTriggerSnippet.trim()\n }\n\n let regex = allowSpaces ? /[^\\S ]/g : /[\\xA0\\s]/g;\n\n this.tribute.hasTrailingSpace = regex.test(currentTriggerSnippet);\n\n if (!leadingSpace && (menuAlreadyActive || !(regex.test(currentTriggerSnippet)))) {\n return {\n mentionPosition: mostRecentTriggerCharPos,\n mentionText: currentTriggerSnippet,\n mentionSelectedElement: selected,\n mentionSelectedPath: path,\n mentionSelectedOffset: offset,\n mentionTriggerChar: triggerChar\n }\n }\n }\n }\n }\n\n lastIndexWithLeadingSpace (str, trigger) {\n let reversedStr = str.split('').reverse().join('')\n let index = -1\n\n for (let cidx = 0, len = str.length; cidx < len; cidx++) {\n let firstChar = cidx === str.length - 1\n let leadingSpace = /\\s/.test(reversedStr[cidx + 1])\n\n let match = true\n for (let triggerIdx = trigger.length - 1; triggerIdx >= 0; triggerIdx--) {\n if (trigger[triggerIdx] !== reversedStr[cidx-triggerIdx]) {\n match = false\n break\n }\n }\n\n if (match && (firstChar || leadingSpace)) {\n index = str.length - 1 - cidx\n break\n }\n }\n\n return index\n }\n\n isContentEditable(element) {\n return element.nodeName !== 'INPUT' && element.nodeName !== 'TEXTAREA'\n }\n\n isMenuOffScreen(coordinates, menuDimensions) {\n let windowWidth = window.innerWidth\n let windowHeight = window.innerHeight\n let doc = document.documentElement\n let windowLeft = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0)\n let windowTop = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0)\n\n let menuTop = typeof coordinates.top === 'number' ? coordinates.top : windowTop + windowHeight - coordinates.bottom - menuDimensions.height\n let menuRight = typeof coordinates.right === 'number' ? coordinates.right : coordinates.left + menuDimensions.width\n let menuBottom = typeof coordinates.bottom === 'number' ? coordinates.bottom : coordinates.top + menuDimensions.height\n let menuLeft = typeof coordinates.left === 'number' ? coordinates.left : windowLeft + windowWidth - coordinates.right - menuDimensions.width\n\n return {\n top: menuTop < Math.floor(windowTop),\n right: menuRight > Math.ceil(windowLeft + windowWidth),\n bottom: menuBottom > Math.ceil(windowTop + windowHeight),\n left: menuLeft < Math.floor(windowLeft)\n }\n }\n\n getMenuDimensions() {\n // Width of the menu depends of its contents and position\n // We must check what its width would be without any obstruction\n // This way, we can achieve good positioning for flipping the menu\n let dimensions = {\n width: null,\n height: null\n }\n\n this.tribute.menu.style.cssText = `top: 0px;\n left: 0px;\n position: fixed;\n display: block;\n visibility; hidden;`\n dimensions.width = this.tribute.menu.offsetWidth\n dimensions.height = this.tribute.menu.offsetHeight\n\n this.tribute.menu.style.cssText = `display: none;`\n\n return dimensions\n }\n\n getTextAreaOrInputUnderlinePosition(element, position, flipped) {\n let properties = ['direction', 'boxSizing', 'width', 'height', 'overflowX',\n 'overflowY', 'borderTopWidth', 'borderRightWidth',\n 'borderBottomWidth', 'borderLeftWidth', 'paddingTop',\n 'paddingRight', 'paddingBottom', 'paddingLeft',\n 'fontStyle', 'fontVariant', 'fontWeight', 'fontStretch',\n 'fontSize', 'fontSizeAdjust', 'lineHeight', 'fontFamily',\n 'textAlign', 'textTransform', 'textIndent',\n 'textDecoration', 'letterSpacing', 'wordSpacing'\n ]\n\n let isFirefox = (window.mozInnerScreenX !== null)\n\n let div = this.getDocument().createElement('div')\n div.id = 'input-textarea-caret-position-mirror-div'\n this.getDocument().body.appendChild(div)\n\n let style = div.style\n let computed = window.getComputedStyle ? getComputedStyle(element) : element.currentStyle\n\n style.whiteSpace = 'pre-wrap'\n if (element.nodeName !== 'INPUT') {\n style.wordWrap = 'break-word'\n }\n\n // position off-screen\n style.position = 'absolute'\n style.visibility = 'hidden'\n\n // transfer the element's properties to the div\n properties.forEach(prop => {\n style[prop] = computed[prop]\n })\n\n if (isFirefox) {\n style.width = `${(parseInt(computed.width) - 2)}px`\n if (element.scrollHeight > parseInt(computed.height))\n style.overflowY = 'scroll'\n } else {\n style.overflow = 'hidden'\n }\n\n div.textContent = element.value.substring(0, position)\n\n if (element.nodeName === 'INPUT') {\n div.textContent = div.textContent.replace(/\\s/g, ' ')\n }\n\n let span = this.getDocument().createElement('span')\n span.textContent = element.value.substring(position) || '.'\n div.appendChild(span)\n\n let rect = element.getBoundingClientRect()\n let doc = document.documentElement\n let windowLeft = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0)\n let windowTop = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0)\n\n let top = 0;\n let left = 0;\n if (this.menuContainerIsBody) {\n top = rect.top;\n left = rect.left;\n }\n\n let coordinates = {\n top: top + windowTop + span.offsetTop + parseInt(computed.borderTopWidth) + parseInt(computed.fontSize) - element.scrollTop,\n left: left + windowLeft + span.offsetLeft + parseInt(computed.borderLeftWidth)\n }\n\n let windowWidth = window.innerWidth\n let windowHeight = window.innerHeight\n\n let menuDimensions = this.getMenuDimensions()\n let menuIsOffScreen = this.isMenuOffScreen(coordinates, menuDimensions)\n\n if (menuIsOffScreen.right) {\n coordinates.right = windowWidth - coordinates.left\n coordinates.left = 'auto'\n }\n\n let parentHeight = this.tribute.menuContainer\n ? this.tribute.menuContainer.offsetHeight\n : this.getDocument().body.offsetHeight\n\n if (menuIsOffScreen.bottom) {\n let parentRect = this.tribute.menuContainer\n ? this.tribute.menuContainer.getBoundingClientRect()\n : this.getDocument().body.getBoundingClientRect()\n let scrollStillAvailable = parentHeight - (windowHeight - parentRect.top)\n\n coordinates.bottom = scrollStillAvailable + (windowHeight - rect.top - span.offsetTop)\n coordinates.top = 'auto'\n }\n\n menuIsOffScreen = this.isMenuOffScreen(coordinates, menuDimensions)\n if (menuIsOffScreen.left) {\n coordinates.left = windowWidth > menuDimensions.width\n ? windowLeft + windowWidth - menuDimensions.width\n : windowLeft\n delete coordinates.right\n }\n if (menuIsOffScreen.top) {\n coordinates.top = windowHeight > menuDimensions.height\n ? windowTop + windowHeight - menuDimensions.height\n : windowTop\n delete coordinates.bottom\n }\n\n this.getDocument().body.removeChild(div)\n return coordinates\n }\n\n getContentEditableCaretPosition(selectedNodePosition) {\n let markerTextChar = ''\n let markerEl, markerId = `sel_${new Date().getTime()}_${Math.random().toString().substr(2)}`\n let range\n let sel = this.getWindowSelection()\n let prevRange = sel.getRangeAt(0)\n\n range = this.getDocument().createRange()\n range.setStart(sel.anchorNode, selectedNodePosition)\n range.setEnd(sel.anchorNode, selectedNodePosition)\n\n range.collapse(false)\n\n // Create the marker element containing a single invisible character using DOM methods and insert it\n markerEl = this.getDocument().createElement('span')\n markerEl.id = markerId\n\n markerEl.appendChild(this.getDocument().createTextNode(markerTextChar))\n range.insertNode(markerEl)\n sel.removeAllRanges()\n sel.addRange(prevRange)\n\n let rect = markerEl.getBoundingClientRect()\n let doc = document.documentElement\n let windowLeft = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0)\n let windowTop = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0)\n\n let left = 0\n let top = 0\n if (this.menuContainerIsBody) {\n left = rect.left\n top = rect.top\n } else {\n left = markerEl.offsetLeft;\n top = markerEl.offsetTop;\n }\n\n let coordinates = {\n left: left + windowLeft,\n top: top + markerEl.offsetHeight + windowTop\n }\n let windowWidth = window.innerWidth\n let windowHeight = window.innerHeight\n\n let menuDimensions = this.getMenuDimensions()\n let menuIsOffScreen = this.isMenuOffScreen(coordinates, menuDimensions)\n\n if (menuIsOffScreen.right) {\n coordinates.left = 'auto'\n coordinates.right = windowWidth - rect.left - windowLeft\n }\n\n let parentHeight = this.tribute.menuContainer\n ? this.tribute.menuContainer.offsetHeight\n : this.getDocument().body.offsetHeight\n\n if (menuIsOffScreen.bottom) {\n let parentRect = this.tribute.menuContainer\n ? this.tribute.menuContainer.getBoundingClientRect()\n : this.getDocument().body.getBoundingClientRect()\n let scrollStillAvailable = parentHeight - (windowHeight - parentRect.top)\n\n coordinates.top = 'auto'\n coordinates.bottom = scrollStillAvailable + (windowHeight - rect.top)\n }\n\n menuIsOffScreen = this.isMenuOffScreen(coordinates, menuDimensions)\n if (menuIsOffScreen.left) {\n coordinates.left = windowWidth > menuDimensions.width\n ? windowLeft + windowWidth - menuDimensions.width\n : windowLeft\n delete coordinates.right\n }\n if (menuIsOffScreen.top) {\n coordinates.top = windowHeight > menuDimensions.height\n ? windowTop + windowHeight - menuDimensions.height\n : windowTop\n delete coordinates.bottom\n }\n\n markerEl.parentNode.removeChild(markerEl)\n return coordinates\n }\n\n scrollIntoView(elem) {\n let reasonableBuffer = 20,\n clientRect\n let maxScrollDisplacement = 100\n let e = this.menu\n\n if (typeof e === 'undefined') return;\n\n while (clientRect === undefined || clientRect.height === 0) {\n clientRect = e.getBoundingClientRect()\n\n if (clientRect.height === 0) {\n e = e.childNodes[0]\n if (e === undefined || !e.getBoundingClientRect) {\n return\n }\n }\n }\n\n let elemTop = clientRect.top\n let elemBottom = elemTop + clientRect.height\n\n if (elemTop < 0) {\n window.scrollTo(0, window.pageYOffset + clientRect.top - reasonableBuffer)\n } else if (elemBottom > window.innerHeight) {\n let maxY = window.pageYOffset + clientRect.top - reasonableBuffer\n\n if (maxY - window.pageYOffset > maxScrollDisplacement) {\n maxY = window.pageYOffset + maxScrollDisplacement\n }\n\n let targetY = window.pageYOffset - (window.innerHeight - elemBottom)\n\n if (targetY > maxY) {\n targetY = maxY\n }\n\n window.scrollTo(0, targetY)\n }\n }\n}\n\n\nexport default TributeRange;\n", + "// Thanks to https://github.com/mattyork/fuzzy\nclass TributeSearch {\n constructor(tribute) {\n this.tribute = tribute\n this.tribute.search = this\n }\n\n simpleFilter(pattern, array) {\n return array.filter(string => {\n return this.test(pattern, string)\n })\n }\n\n test(pattern, string) {\n return this.match(pattern, string) !== null\n }\n\n match(pattern, string, opts) {\n opts = opts || {}\n let patternIdx = 0,\n result = [],\n len = string.length,\n totalScore = 0,\n currScore = 0,\n pre = opts.pre || '',\n post = opts.post || '',\n compareString = opts.caseSensitive && string || string.toLowerCase(),\n ch, compareChar\n\n if (opts.skip) {\n return {rendered: string, score: 0}\n }\n\n pattern = opts.caseSensitive && pattern || pattern.toLowerCase()\n\n let patternCache = this.traverse(compareString, pattern, 0, 0, [])\n if (!patternCache) {\n return null\n }\n return {\n rendered: this.render(string, patternCache.cache, pre, post),\n score: patternCache.score\n }\n }\n\n traverse(string, pattern, stringIndex, patternIndex, patternCache) {\n // if the pattern search at end\n if (pattern.length === patternIndex) {\n\n // calculate score and copy the cache containing the indices where it's found\n return {\n score: this.calculateScore(patternCache),\n cache: patternCache.slice()\n }\n }\n\n // if string at end or remaining pattern > remaining string\n if (string.length === stringIndex || pattern.length - patternIndex > string.length - stringIndex) {\n return undefined\n }\n\n let c = pattern[patternIndex]\n let index = string.indexOf(c, stringIndex)\n let best, temp\n\n while (index > -1) {\n patternCache.push(index)\n temp = this.traverse(string, pattern, index + 1, patternIndex + 1, patternCache)\n patternCache.pop()\n\n // if downstream traversal failed, return best answer so far\n if (!temp) {\n return best\n }\n\n if (!best || best.score < temp.score) {\n best = temp\n }\n\n index = string.indexOf(c, index + 1)\n }\n\n return best\n }\n\n calculateScore(patternCache) {\n let score = 0\n let temp = 1\n\n patternCache.forEach((index, i) => {\n if (i > 0) {\n if (patternCache[i - 1] + 1 === index) {\n temp += temp + 1\n }\n else {\n temp = 1\n }\n }\n\n score += temp\n })\n\n return score\n }\n\n render(string, indices, pre, post) {\n var rendered = string.substring(0, indices[0])\n\n indices.forEach((index, i) => {\n rendered += pre + string[index] + post +\n string.substring(index + 1, (indices[i + 1]) ? indices[i + 1] : string.length)\n })\n\n return rendered\n }\n\n filter(pattern, arr, opts) {\n opts = opts || {}\n return arr\n .reduce((prev, element, idx, arr) => {\n let str = element\n\n if (opts.extract) {\n str = opts.extract(element)\n\n if (!str) { // take care of undefineds / nulls / etc.\n str = ''\n }\n }\n\n let rendered = this.match(pattern, str, opts)\n\n if (rendered != null) {\n prev[prev.length] = {\n string: rendered.rendered,\n score: rendered.score,\n index: idx,\n original: element\n }\n }\n\n return prev\n }, [])\n\n .sort((a, b) => {\n let compare = b.score - a.score\n if (compare) return compare\n return a.index - b.index\n })\n }\n}\n\nexport default TributeSearch;\n", + "/**\n* Tribute.js\n* Native ES6 JavaScript @mention Plugin\n**/\n\nimport Tribute from \"./Tribute\";\n\nexport default Tribute;\n", + "if (!Array.prototype.find) {\n Array.prototype.find = function(predicate) {\n if (this === null) {\n throw new TypeError('Array.prototype.find called on null or undefined')\n }\n if (typeof predicate !== 'function') {\n throw new TypeError('predicate must be a function')\n }\n var list = Object(this)\n var length = list.length >>> 0\n var thisArg = arguments[1]\n var value\n\n for (var i = 0; i < length; i++) {\n value = list[i]\n if (predicate.call(thisArg, value, i, list)) {\n return value\n }\n }\n return undefined\n }\n}\n\nif (window && typeof window.CustomEvent !== \"function\") {\n function CustomEvent(event, params) {\n params = params || {\n bubbles: false,\n cancelable: false,\n detail: undefined\n }\n var evt = document.createEvent('CustomEvent')\n evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail)\n return evt\n }\n\n if (typeof window.Event !== 'undefined') {\n CustomEvent.prototype = window.Event.prototype\n }\n\n window.CustomEvent = CustomEvent\n}" ] } \ No newline at end of file diff --git a/dist/tribute.min.js b/dist/tribute.min.js index e69de29b..11a74c00 100644 --- a/dist/tribute.min.js +++ b/dist/tribute.min.js @@ -0,0 +1,2 @@ + +//# sourceMappingURL=tribute.min.js.map diff --git a/dist/tribute.min.js.map b/dist/tribute.min.js.map index e69de29b..b4a27e5e 100644 --- a/dist/tribute.min.js.map +++ b/dist/tribute.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":[],"names":[],"mappings":"","file":"tribute.min.js","sourcesContent":[]} \ No newline at end of file