From fe4defe752a7a22e7d59483fde75b779ee78c3a4 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 26 Apr 2018 12:38:25 +0200 Subject: upgrade to textcomplete (jquery.textcomplete is discontinued), enable built-in cache and unify to start lookup after 3 characters --- library/textcomplete/textcomplete.js | 2409 ++++++++++++++++++++++++++ library/textcomplete/textcomplete.js.map | 1 + library/textcomplete/textcomplete.min.js | 2 + library/textcomplete/textcomplete.min.js.map | 1 + 4 files changed, 2413 insertions(+) create mode 100644 library/textcomplete/textcomplete.js create mode 100644 library/textcomplete/textcomplete.js.map create mode 100644 library/textcomplete/textcomplete.min.js create mode 100644 library/textcomplete/textcomplete.min.js.map (limited to 'library/textcomplete') diff --git a/library/textcomplete/textcomplete.js b/library/textcomplete/textcomplete.js new file mode 100644 index 000000000..5134be691 --- /dev/null +++ b/library/textcomplete/textcomplete.js @@ -0,0 +1,2409 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 5); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _strategy = __webpack_require__(2); + +var _strategy2 = _interopRequireDefault(_strategy); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/** + * Encapsulate an result of each search results. + */ +var SearchResult = function () { + + /** + * @param {object} data - An element of array callbacked by search function. + */ + function SearchResult(data, term, strategy) { + _classCallCheck(this, SearchResult); + + this.data = data; + this.term = term; + this.strategy = strategy; + } + + _createClass(SearchResult, [{ + key: "replace", + value: function replace(beforeCursor, afterCursor) { + var replacement = this.strategy.replace(this.data); + if (replacement !== null) { + if (Array.isArray(replacement)) { + afterCursor = replacement[1] + afterCursor; + replacement = replacement[0]; + } + var match = this.strategy.matchText(beforeCursor); + if (match) { + replacement = replacement.replace(/\$&/g, match[0]).replace(/\$(\d)/g, function (_, p1) { + return match[parseInt(p1, 10)]; + }); + return [[beforeCursor.slice(0, match.index), replacement, beforeCursor.slice(match.index + match[0].length)].join(""), afterCursor]; + } + } + } + }, { + key: "render", + value: function render() { + return this.strategy.template(this.data, this.term); + } + }]); + + return SearchResult; +}(); + +exports.default = SearchResult; + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var has = Object.prototype.hasOwnProperty + , prefix = '~'; + +/** + * Constructor to create a storage for our `EE` objects. + * An `Events` instance is a plain object whose properties are event names. + * + * @constructor + * @api private + */ +function Events() {} + +// +// We try to not inherit from `Object.prototype`. In some engines creating an +// instance in this way is faster than calling `Object.create(null)` directly. +// If `Object.create(null)` is not supported we prefix the event names with a +// character to make sure that the built-in object properties are not +// overridden or used as an attack vector. +// +if (Object.create) { + Events.prototype = Object.create(null); + + // + // This hack is needed because the `__proto__` property is still inherited in + // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5. + // + if (!new Events().__proto__) prefix = false; +} + +/** + * Representation of a single event listener. + * + * @param {Function} fn The listener function. + * @param {Mixed} context The context to invoke the listener with. + * @param {Boolean} [once=false] Specify if the listener is a one-time listener. + * @constructor + * @api private + */ +function EE(fn, context, once) { + this.fn = fn; + this.context = context; + this.once = once || false; +} + +/** + * Minimal `EventEmitter` interface that is molded against the Node.js + * `EventEmitter` interface. + * + * @constructor + * @api public + */ +function EventEmitter() { + this._events = new Events(); + this._eventsCount = 0; +} + +/** + * Return an array listing the events for which the emitter has registered + * listeners. + * + * @returns {Array} + * @api public + */ +EventEmitter.prototype.eventNames = function eventNames() { + var names = [] + , events + , name; + + if (this._eventsCount === 0) return names; + + for (name in (events = this._events)) { + if (has.call(events, name)) names.push(prefix ? name.slice(1) : name); + } + + if (Object.getOwnPropertySymbols) { + return names.concat(Object.getOwnPropertySymbols(events)); + } + + return names; +}; + +/** + * Return the listeners registered for a given event. + * + * @param {String|Symbol} event The event name. + * @param {Boolean} exists Only check if there are listeners. + * @returns {Array|Boolean} + * @api public + */ +EventEmitter.prototype.listeners = function listeners(event, exists) { + var evt = prefix ? prefix + event : event + , available = this._events[evt]; + + if (exists) return !!available; + if (!available) return []; + if (available.fn) return [available.fn]; + + for (var i = 0, l = available.length, ee = new Array(l); i < l; i++) { + ee[i] = available[i].fn; + } + + return ee; +}; + +/** + * Calls each of the listeners registered for a given event. + * + * @param {String|Symbol} event The event name. + * @returns {Boolean} `true` if the event had listeners, else `false`. + * @api public + */ +EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { + var evt = prefix ? prefix + event : event; + + if (!this._events[evt]) return false; + + var listeners = this._events[evt] + , len = arguments.length + , args + , i; + + if (listeners.fn) { + if (listeners.once) this.removeListener(event, listeners.fn, undefined, true); + + switch (len) { + case 1: return listeners.fn.call(listeners.context), true; + case 2: return listeners.fn.call(listeners.context, a1), true; + case 3: return listeners.fn.call(listeners.context, a1, a2), true; + case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true; + case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; + case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; + } + + for (i = 1, args = new Array(len -1); i < len; i++) { + args[i - 1] = arguments[i]; + } + + listeners.fn.apply(listeners.context, args); + } else { + var length = listeners.length + , j; + + for (i = 0; i < length; i++) { + if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true); + + switch (len) { + case 1: listeners[i].fn.call(listeners[i].context); break; + case 2: listeners[i].fn.call(listeners[i].context, a1); break; + case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break; + case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break; + default: + if (!args) for (j = 1, args = new Array(len -1); j < len; j++) { + args[j - 1] = arguments[j]; + } + + listeners[i].fn.apply(listeners[i].context, args); + } + } + } + + return true; +}; + +/** + * Add a listener for a given event. + * + * @param {String|Symbol} event The event name. + * @param {Function} fn The listener function. + * @param {Mixed} [context=this] The context to invoke the listener with. + * @returns {EventEmitter} `this`. + * @api public + */ +EventEmitter.prototype.on = function on(event, fn, context) { + var listener = new EE(fn, context || this) + , evt = prefix ? prefix + event : event; + + if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++; + else if (!this._events[evt].fn) this._events[evt].push(listener); + else this._events[evt] = [this._events[evt], listener]; + + return this; +}; + +/** + * Add a one-time listener for a given event. + * + * @param {String|Symbol} event The event name. + * @param {Function} fn The listener function. + * @param {Mixed} [context=this] The context to invoke the listener with. + * @returns {EventEmitter} `this`. + * @api public + */ +EventEmitter.prototype.once = function once(event, fn, context) { + var listener = new EE(fn, context || this, true) + , evt = prefix ? prefix + event : event; + + if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++; + else if (!this._events[evt].fn) this._events[evt].push(listener); + else this._events[evt] = [this._events[evt], listener]; + + return this; +}; + +/** + * Remove the listeners of a given event. + * + * @param {String|Symbol} event The event name. + * @param {Function} fn Only remove the listeners that match this function. + * @param {Mixed} context Only remove the listeners that have this context. + * @param {Boolean} once Only remove one-time listeners. + * @returns {EventEmitter} `this`. + * @api public + */ +EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) { + var evt = prefix ? prefix + event : event; + + if (!this._events[evt]) return this; + if (!fn) { + if (--this._eventsCount === 0) this._events = new Events(); + else delete this._events[evt]; + return this; + } + + var listeners = this._events[evt]; + + if (listeners.fn) { + if ( + listeners.fn === fn + && (!once || listeners.once) + && (!context || listeners.context === context) + ) { + if (--this._eventsCount === 0) this._events = new Events(); + else delete this._events[evt]; + } + } else { + for (var i = 0, events = [], length = listeners.length; i < length; i++) { + if ( + listeners[i].fn !== fn + || (once && !listeners[i].once) + || (context && listeners[i].context !== context) + ) { + events.push(listeners[i]); + } + } + + // + // Reset the array, or remove it completely if we have no more listeners. + // + if (events.length) this._events[evt] = events.length === 1 ? events[0] : events; + else if (--this._eventsCount === 0) this._events = new Events(); + else delete this._events[evt]; + } + + return this; +}; + +/** + * Remove all listeners, or those of the specified event. + * + * @param {String|Symbol} [event] The event name. + * @returns {EventEmitter} `this`. + * @api public + */ +EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) { + var evt; + + if (event) { + evt = prefix ? prefix + event : event; + if (this._events[evt]) { + if (--this._eventsCount === 0) this._events = new Events(); + else delete this._events[evt]; + } + } else { + this._events = new Events(); + this._eventsCount = 0; + } + + return this; +}; + +// +// Alias methods names because people roll like that. +// +EventEmitter.prototype.off = EventEmitter.prototype.removeListener; +EventEmitter.prototype.addListener = EventEmitter.prototype.on; + +// +// This function doesn't apply anymore. +// +EventEmitter.prototype.setMaxListeners = function setMaxListeners() { + return this; +}; + +// +// Expose the prefix. +// +EventEmitter.prefixed = prefix; + +// +// Allow `EventEmitter` to be imported as module namespace. +// +EventEmitter.EventEmitter = EventEmitter; + +// +// Expose the module. +// +if (true) { + module.exports = EventEmitter; +} + + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var DEFAULT_INDEX = 2; + +function DEFAULT_TEMPLATE(value) { + return value; +} + +/** + * Properties for a strategy. + * + * @typedef + */ + +/** + * Encapsulate a single strategy. + */ +var Strategy = function () { + function Strategy(props) { + _classCallCheck(this, Strategy); + + this.props = props; + this.cache = props.cache ? {} : null; + } + + /** + * @return {this} + */ + + + _createClass(Strategy, [{ + key: "destroy", + value: function destroy() { + this.cache = null; + return this; + } + }, { + key: "search", + value: function search(term, callback, match) { + if (this.cache) { + this.searchWithCache(term, callback, match); + } else { + this.props.search(term, callback, match); + } + } + + /** + * @param {object} data - An element of array callbacked by search function. + */ + + }, { + key: "replace", + value: function replace(data) { + return this.props.replace(data); + } + + /** @private */ + + }, { + key: "searchWithCache", + value: function searchWithCache(term, callback, match) { + var _this = this; + + if (this.cache && this.cache[term]) { + callback(this.cache[term]); + } else { + this.props.search(term, function (results) { + if (_this.cache) { + _this.cache[term] = results; + } + callback(results); + }, match); + } + } + + /** @private */ + + }, { + key: "matchText", + value: function matchText(text) { + if (typeof this.match === "function") { + return this.match(text); + } else { + return text.match(this.match); + } + } + + /** @private */ + + }, { + key: "match", + get: function get() { + return this.props.match; + } + + /** @private */ + + }, { + key: "index", + get: function get() { + return typeof this.props.index === "number" ? this.props.index : DEFAULT_INDEX; + } + }, { + key: "template", + get: function get() { + return this.props.template || DEFAULT_TEMPLATE; + } + }]); + + return Strategy; +}(); + +exports.default = Strategy; + +/***/ }), +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.calculateElementOffset = calculateElementOffset; +exports.getLineHeightPx = getLineHeightPx; +exports.calculateLineHeightPx = calculateLineHeightPx; + + +/** + * Create a custom event + * + * @private + */ +var createCustomEvent = exports.createCustomEvent = function () { + if (typeof window.CustomEvent === "function") { + return function (type, options) { + return new document.defaultView.CustomEvent(type, { + cancelable: options && options.cancelable || false, + detail: options && options.detail || undefined + }); + }; + } else { + // Custom event polyfill from + // https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#polyfill + return function (type, options) { + var event = document.createEvent("CustomEvent"); + event.initCustomEvent(type, + /* bubbles */false, options && options.cancelable || false, options && options.detail || undefined); + return event; + }; + } +} + +/** + * Get the current coordinates of the `el` relative to the document. + * + * @private + */ +();function calculateElementOffset(el) { + var rect = el.getBoundingClientRect(); + var _el$ownerDocument = el.ownerDocument, + defaultView = _el$ownerDocument.defaultView, + documentElement = _el$ownerDocument.documentElement; + + var offset = { + top: rect.top + defaultView.pageYOffset, + left: rect.left + defaultView.pageXOffset + }; + if (documentElement) { + offset.top -= documentElement.clientTop; + offset.left -= documentElement.clientLeft; + } + return offset; +} + +var CHAR_CODE_ZERO = "0".charCodeAt(0); +var CHAR_CODE_NINE = "9".charCodeAt(0); + +function isDigit(charCode) { + return charCode >= CHAR_CODE_ZERO && charCode <= CHAR_CODE_NINE; +} + +/** + * Returns the line-height of the given node in pixels. + * + * @private + */ +function getLineHeightPx(node) { + var computedStyle = window.getComputedStyle(node + + // If the char code starts with a digit, it is either a value in pixels, + // or unitless, as per: + // https://drafts.csswg.org/css2/visudet.html#propdef-line-height + // https://drafts.csswg.org/css2/cascade.html#computed-value + );if (isDigit(computedStyle.lineHeight.charCodeAt(0))) { + // In real browsers the value is *always* in pixels, even for unit-less + // line-heights. However, we still check as per the spec. + if (isDigit(computedStyle.lineHeight.charCodeAt(computedStyle.lineHeight.length - 1))) { + return parseFloat(computedStyle.lineHeight) * parseFloat(computedStyle.fontSize); + } else { + return parseFloat(computedStyle.lineHeight); + } + } + + // Otherwise, the value is "normal". + // If the line-height is "normal", calculate by font-size + return calculateLineHeightPx(node.nodeName, computedStyle); +} + +/** + * Returns calculated line-height of the given node in pixels. + * + * @private + */ +function calculateLineHeightPx(nodeName, computedStyle) { + var body = document.body; + if (!body) { + return 0; + } + + var tempNode = document.createElement(nodeName); + tempNode.innerHTML = " "; + tempNode.style.fontSize = computedStyle.fontSize; + tempNode.style.fontFamily = computedStyle.fontFamily; + tempNode.style.padding = "0"; + body.appendChild(tempNode + + // Make sure textarea has only 1 row + );if (tempNode instanceof HTMLTextAreaElement) { + ;tempNode.rows = 1; + } + + // Assume the height of the element is the line-height + var height = tempNode.offsetHeight; + body.removeChild(tempNode); + + return height; +} + +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _eventemitter = __webpack_require__(1); + +var _eventemitter2 = _interopRequireDefault(_eventemitter); + +var _utils = __webpack_require__(3); + +var _search_result = __webpack_require__(0); + +var _search_result2 = _interopRequireDefault(_search_result); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } +/*eslint no-unused-vars: off*/ + +/** + * Abstract class representing a editor target. + * + * Editor classes must implement `#applySearchResult`, `#getCursorOffset` and + * `#getBeforeCursor` methods. + * + * Editor classes must invoke `#emitMoveEvent`, `#emitEnterEvent`, + * `#emitChangeEvent` and `#emitEscEvent` at proper timing. + * + * @abstract + */ + + +/** @typedef */ +var Editor = function (_EventEmitter) { + _inherits(Editor, _EventEmitter); + + function Editor() { + _classCallCheck(this, Editor); + + return _possibleConstructorReturn(this, (Editor.__proto__ || Object.getPrototypeOf(Editor)).apply(this, arguments)); + } + + _createClass(Editor, [{ + key: "destroy", + + /** + * It is called when associated textcomplete object is destroyed. + * + * @return {this} + */ + value: function destroy() { + return this; + } + + /** + * It is called when a search result is selected by a user. + */ + + }, { + key: "applySearchResult", + value: function applySearchResult(_) { + throw new Error("Not implemented."); + } + + /** + * The input cursor's absolute coordinates from the window's left + * top corner. + */ + + }, { + key: "getCursorOffset", + value: function getCursorOffset() { + throw new Error("Not implemented."); + } + + /** + * Editor string value from head to cursor. + * Returns null if selection type is range not cursor. + */ + + }, { + key: "getBeforeCursor", + value: function getBeforeCursor() { + throw new Error("Not implemented."); + } + + /** + * Emit a move event, which moves active dropdown element. + * Child class must call this method at proper timing with proper parameter. + * + * @see {@link Textarea} for live example. + */ + + }, { + key: "emitMoveEvent", + value: function emitMoveEvent(code) { + var moveEvent = (0, _utils.createCustomEvent)("move", { + cancelable: true, + detail: { + code: code + } + }); + this.emit("move", moveEvent); + return moveEvent; + } + + /** + * Emit a enter event, which selects current search result. + * Child class must call this method at proper timing. + * + * @see {@link Textarea} for live example. + */ + + }, { + key: "emitEnterEvent", + value: function emitEnterEvent() { + var enterEvent = (0, _utils.createCustomEvent)("enter", { cancelable: true }); + this.emit("enter", enterEvent); + return enterEvent; + } + + /** + * Emit a change event, which triggers auto completion. + * Child class must call this method at proper timing. + * + * @see {@link Textarea} for live example. + */ + + }, { + key: "emitChangeEvent", + value: function emitChangeEvent() { + var changeEvent = (0, _utils.createCustomEvent)("change", { + detail: { + beforeCursor: this.getBeforeCursor() + } + }); + this.emit("change", changeEvent); + return changeEvent; + } + + /** + * Emit a esc event, which hides dropdown element. + * Child class must call this method at proper timing. + * + * @see {@link Textarea} for live example. + */ + + }, { + key: "emitEscEvent", + value: function emitEscEvent() { + var escEvent = (0, _utils.createCustomEvent)("esc", { cancelable: true }); + this.emit("esc", escEvent); + return escEvent; + } + + /** + * Helper method for parsing KeyboardEvent. + * + * @see {@link Textarea} for live example. + */ + + }, { + key: "getCode", + value: function getCode(e) { + return e.keyCode === 9 ? "ENTER" // tab + : e.keyCode === 13 ? "ENTER" // enter + : e.keyCode === 27 ? "ESC" // esc + : e.keyCode === 38 ? "UP" // up + : e.keyCode === 40 ? "DOWN" // down + : e.keyCode === 78 && e.ctrlKey ? "DOWN" // ctrl-n + : e.keyCode === 80 && e.ctrlKey ? "UP" // ctrl-p + : "OTHER"; + } + }]); + + return Editor; +}(_eventemitter2.default); + +exports.default = Editor; + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(global) { + +var _textcomplete = __webpack_require__(7); + +var _textcomplete2 = _interopRequireDefault(_textcomplete); + +var _textarea = __webpack_require__(12); + +var _textarea2 = _interopRequireDefault(_textarea); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var editors = void 0; +if (global.Textcomplete && global.Textcomplete.editors) { + editors = global.Textcomplete.editors; +} else { + editors = {}; +} +editors.Textarea = _textarea2.default; + +global.Textcomplete = _textcomplete2.default; +global.Textcomplete.editors = editors; +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) + +/***/ }), +/* 6 */ +/***/ (function(module, exports) { + +var g; + +// This works in non-strict mode +g = (function() { + return this; +})(); + +try { + // This works if eval is allowed (see CSP) + g = g || Function("return this")() || (1,eval)("this"); +} catch(e) { + // This works if the window reference is available + if(typeof window === "object") + g = window; +} + +// g can still be undefined, but nothing to do about it... +// We return undefined, instead of nothing here, so it's +// easier to handle this case. if(!global) { ...} + +module.exports = g; + + +/***/ }), +/* 7 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _completer = __webpack_require__(8); + +var _completer2 = _interopRequireDefault(_completer); + +var _editor = __webpack_require__(4); + +var _editor2 = _interopRequireDefault(_editor); + +var _dropdown = __webpack_require__(10); + +var _dropdown2 = _interopRequireDefault(_dropdown); + +var _strategy = __webpack_require__(2); + +var _strategy2 = _interopRequireDefault(_strategy); + +var _search_result = __webpack_require__(0); + +var _search_result2 = _interopRequireDefault(_search_result); + +var _eventemitter = __webpack_require__(1); + +var _eventemitter2 = _interopRequireDefault(_eventemitter); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var CALLBACK_METHODS = ["handleChange", "handleEnter", "handleEsc", "handleHit", "handleMove", "handleSelect"]; + +/** @typedef */ + +/** + * The core of textcomplete. It acts as a mediator. + */ +var Textcomplete = function (_EventEmitter) { + _inherits(Textcomplete, _EventEmitter); + + /** + * @param {Editor} editor - Where the textcomplete works on. + */ + function Textcomplete(editor) { + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + _classCallCheck(this, Textcomplete); + + var _this = _possibleConstructorReturn(this, (Textcomplete.__proto__ || Object.getPrototypeOf(Textcomplete)).call(this)); + + _this.completer = new _completer2.default(); + _this.isQueryInFlight = false; + _this.nextPendingQuery = null; + _this.dropdown = new _dropdown2.default(options.dropdown || {}); + _this.editor = editor; + _this.options = options; + + CALLBACK_METHODS.forEach(function (method) { + ;_this[method] = _this[method].bind(_this); + }); + + _this.startListening(); + return _this; + } + + /** + * @return {this} + */ + + + _createClass(Textcomplete, [{ + key: "destroy", + value: function destroy() { + var destroyEditor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; + + this.completer.destroy(); + this.dropdown.destroy(); + if (destroyEditor) { + this.editor.destroy(); + } + this.stopListening(); + return this; + } + + /** + * @return {this} + */ + + }, { + key: "hide", + value: function hide() { + this.dropdown.deactivate(); + return this; + } + + /** + * @return {this} + * @example + * textcomplete.register([{ + * match: /(^|\s)(\w+)$/, + * search: function (term, callback) { + * $.ajax({ ... }) + * .done(callback) + * .fail([]); + * }, + * replace: function (value) { + * return '$1' + value + ' '; + * } + * }]); + */ + + }, { + key: "register", + value: function register(strategyPropsArray) { + var _this2 = this; + + strategyPropsArray.forEach(function (props) { + _this2.completer.registerStrategy(new _strategy2.default(props)); + }); + return this; + } + + /** + * Start autocompleting. + * + * @param {string} text - Head to input cursor. + * @return {this} + */ + + }, { + key: "trigger", + value: function trigger(text) { + if (this.isQueryInFlight) { + this.nextPendingQuery = text; + } else { + this.isQueryInFlight = true; + this.nextPendingQuery = null; + this.completer.run(text); + } + return this; + } + + /** @private */ + + }, { + key: "handleHit", + value: function handleHit(_ref) { + var searchResults = _ref.searchResults; + + if (searchResults.length) { + this.dropdown.render(searchResults, this.editor.getCursorOffset()); + } else { + this.dropdown.deactivate(); + } + this.isQueryInFlight = false; + if (this.nextPendingQuery !== null) { + this.trigger(this.nextPendingQuery); + } + } + + /** @private */ + + }, { + key: "handleMove", + value: function handleMove(e) { + e.detail.code === "UP" ? this.dropdown.up(e) : this.dropdown.down(e); + } + + /** @private */ + + }, { + key: "handleEnter", + value: function handleEnter(e) { + var activeItem = this.dropdown.getActiveItem(); + if (activeItem) { + this.dropdown.select(activeItem); + e.preventDefault(); + } else { + this.dropdown.deactivate(); + } + } + + /** @private */ + + }, { + key: "handleEsc", + value: function handleEsc(e) { + if (this.dropdown.shown) { + this.dropdown.deactivate(); + e.preventDefault(); + } + } + + /** @private */ + + }, { + key: "handleChange", + value: function handleChange(e) { + if (e.detail.beforeCursor != null) { + this.trigger(e.detail.beforeCursor); + } else { + this.dropdown.deactivate(); + } + } + + /** @private */ + + }, { + key: "handleSelect", + value: function handleSelect(selectEvent) { + this.emit("select", selectEvent); + if (!selectEvent.defaultPrevented) { + this.editor.applySearchResult(selectEvent.detail.searchResult); + } + } + + /** @private */ + + }, { + key: "startListening", + value: function startListening() { + var _this3 = this; + + this.editor.on("move", this.handleMove).on("enter", this.handleEnter).on("esc", this.handleEsc).on("change", this.handleChange); + this.dropdown.on("select", this.handleSelect);["show", "shown", "render", "rendered", "selected", "hidden", "hide"].forEach(function (eventName) { + _this3.dropdown.on(eventName, function () { + return _this3.emit(eventName); + }); + }); + this.completer.on("hit", this.handleHit); + } + + /** @private */ + + }, { + key: "stopListening", + value: function stopListening() { + this.completer.removeAllListeners(); + this.dropdown.removeAllListeners(); + this.editor.removeListener("move", this.handleMove).removeListener("enter", this.handleEnter).removeListener("esc", this.handleEsc).removeListener("change", this.handleChange); + } + }]); + + return Textcomplete; +}(_eventemitter2.default); + +exports.default = Textcomplete; + +/***/ }), +/* 8 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _eventemitter = __webpack_require__(1); + +var _eventemitter2 = _interopRequireDefault(_eventemitter); + +var _query = __webpack_require__(9); + +var _query2 = _interopRequireDefault(_query); + +var _search_result = __webpack_require__(0); + +var _search_result2 = _interopRequireDefault(_search_result); + +var _strategy = __webpack_require__(2); + +var _strategy2 = _interopRequireDefault(_strategy); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var CALLBACK_METHODS = ["handleQueryResult"]; + +/** + * Complete engine. + */ + +var Completer = function (_EventEmitter) { + _inherits(Completer, _EventEmitter); + + function Completer() { + _classCallCheck(this, Completer); + + var _this = _possibleConstructorReturn(this, (Completer.__proto__ || Object.getPrototypeOf(Completer)).call(this)); + + _this.strategies = []; + + CALLBACK_METHODS.forEach(function (method) { + ;_this[method] = _this[method].bind(_this); + }); + return _this; + } + + /** + * @return {this} + */ + + + _createClass(Completer, [{ + key: "destroy", + value: function destroy() { + this.strategies.forEach(function (strategy) { + return strategy.destroy(); + }); + return this; + } + + /** + * Register a strategy to the completer. + * + * @return {this} + */ + + }, { + key: "registerStrategy", + value: function registerStrategy(strategy) { + this.strategies.push(strategy); + return this; + } + + /** + * @param {string} text - Head to input cursor. + */ + + }, { + key: "run", + value: function run(text) { + var query = this.extractQuery(text); + if (query) { + query.execute(this.handleQueryResult); + } else { + this.handleQueryResult([]); + } + } + + /** + * Find a query, which matches to the given text. + * + * @private + */ + + }, { + key: "extractQuery", + value: function extractQuery(text) { + for (var i = 0; i < this.strategies.length; i++) { + var query = _query2.default.build(this.strategies[i], text); + if (query) { + return query; + } + } + return null; + } + + /** + * Callbacked by {@link Query#execute}. + * + * @private + */ + + }, { + key: "handleQueryResult", + value: function handleQueryResult(searchResults) { + this.emit("hit", { searchResults: searchResults }); + } + }]); + + return Completer; +}(_eventemitter2.default); + +exports.default = Completer; + +/***/ }), +/* 9 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _search_result = __webpack_require__(0); + +var _search_result2 = _interopRequireDefault(_search_result); + +var _strategy = __webpack_require__(2); + +var _strategy2 = _interopRequireDefault(_strategy); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/** + * Encapsulate matching condition between a Strategy and current editor's value. + */ +var Query = function () { + _createClass(Query, null, [{ + key: "build", + + + /** + * Build a Query object by the given string if this matches to the string. + * + * @param {string} text - Head to input cursor. + */ + value: function build(strategy, text) { + if (typeof strategy.props.context === "function") { + var context = strategy.props.context(text); + if (typeof context === "string") { + text = context; + } else if (!context) { + return null; + } + } + var match = strategy.matchText(text); + return match ? new Query(strategy, match[strategy.index], match) : null; + } + }]); + + function Query(strategy, term, match) { + _classCallCheck(this, Query); + + this.strategy = strategy; + this.term = term; + this.match = match; + } + + /** + * Invoke search strategy and callback the given function. + */ + + + _createClass(Query, [{ + key: "execute", + value: function execute(callback) { + var _this = this; + + this.strategy.search(this.term, function (results) { + callback(results.map(function (result) { + return new _search_result2.default(result, _this.term, _this.strategy); + })); + }, this.match); + } + }]); + + return Query; +}(); + +exports.default = Query; + +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _eventemitter = __webpack_require__(1); + +var _eventemitter2 = _interopRequireDefault(_eventemitter); + +var _dropdown_item = __webpack_require__(11); + +var _dropdown_item2 = _interopRequireDefault(_dropdown_item); + +var _search_result = __webpack_require__(0); + +var _search_result2 = _interopRequireDefault(_search_result); + +var _utils = __webpack_require__(3); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var DEFAULT_CLASS_NAME = "dropdown-menu textcomplete-dropdown"; + +/** @typedef */ + +/** + * Encapsulate a dropdown view. + * + * @prop {boolean} shown - Whether the #el is shown or not. + * @prop {DropdownItem[]} items - The array of rendered dropdown items. + */ +var Dropdown = function (_EventEmitter) { + _inherits(Dropdown, _EventEmitter); + + _createClass(Dropdown, null, [{ + key: "createElement", + value: function createElement() { + var el = document.createElement("ul"); + var style = el.style; + style.display = "none"; + style.position = "absolute"; + style.zIndex = "10000"; + var body = document.body; + if (body) { + body.appendChild(el); + } + return el; + } + }]); + + function Dropdown(options) { + _classCallCheck(this, Dropdown); + + var _this = _possibleConstructorReturn(this, (Dropdown.__proto__ || Object.getPrototypeOf(Dropdown)).call(this)); + + _this.shown = false; + _this.items = []; + _this.activeItem = null; + _this.footer = options.footer; + _this.header = options.header; + _this.maxCount = options.maxCount || 10; + _this.el.className = options.className || DEFAULT_CLASS_NAME; + _this.rotate = options.hasOwnProperty("rotate") ? options.rotate : true; + _this.placement = options.placement; + _this.itemOptions = options.item || {}; + var style = options.style; + if (style) { + Object.keys(style).forEach(function (key) { + ;_this.el.style[key] = style[key]; + }); + } + return _this; + } + + /** + * @return {this} + */ + + + _createClass(Dropdown, [{ + key: "destroy", + value: function destroy() { + var parentNode = this.el.parentNode; + if (parentNode) { + parentNode.removeChild(this.el); + } + this.clear()._el = null; + return this; + } + }, { + key: "render", + + + /** + * Render the given data as dropdown items. + * + * @return {this} + */ + value: function render(searchResults, cursorOffset) { + var _this2 = this; + + var renderEvent = (0, _utils.createCustomEvent)("render", { cancelable: true }); + this.emit("render", renderEvent); + if (renderEvent.defaultPrevented) { + return this; + } + var rawResults = searchResults.map(function (searchResult) { + return searchResult.data; + }); + var dropdownItems = searchResults.slice(0, this.maxCount || searchResults.length).map(function (searchResult) { + return new _dropdown_item2.default(searchResult, _this2.itemOptions); + }); + this.clear().setStrategyId(searchResults[0]).renderEdge(rawResults, "header").append(dropdownItems).renderEdge(rawResults, "footer").show().setOffset(cursorOffset); + this.emit("rendered", (0, _utils.createCustomEvent)("rendered")); + return this; + } + + /** + * Hide the dropdown then sweep out items. + * + * @return {this} + */ + + }, { + key: "deactivate", + value: function deactivate() { + return this.hide().clear(); + } + + /** + * @return {this} + */ + + }, { + key: "select", + value: function select(dropdownItem) { + var detail = { searchResult: dropdownItem.searchResult }; + var selectEvent = (0, _utils.createCustomEvent)("select", { + cancelable: true, + detail: detail + }); + this.emit("select", selectEvent); + if (selectEvent.defaultPrevented) { + return this; + } + this.deactivate(); + this.emit("selected", (0, _utils.createCustomEvent)("selected", { detail: detail })); + return this; + } + + /** + * @return {this} + */ + + }, { + key: "up", + value: function up(e) { + return this.shown ? this.moveActiveItem("prev", e) : this; + } + + /** + * @return {this} + */ + + }, { + key: "down", + value: function down(e) { + return this.shown ? this.moveActiveItem("next", e) : this; + } + + /** + * Retrieve the active item. + */ + + }, { + key: "getActiveItem", + value: function getActiveItem() { + return this.activeItem; + } + + /** + * Add items to dropdown. + * + * @private + */ + + }, { + key: "append", + value: function append(items) { + var _this3 = this; + + var fragment = document.createDocumentFragment(); + items.forEach(function (item) { + _this3.items.push(item); + item.appended(_this3); + fragment.appendChild(item.el); + }); + this.el.appendChild(fragment); + return this; + } + + /** @private */ + + }, { + key: "setOffset", + value: function setOffset(cursorOffset) { + var doc = document.documentElement; + if (doc) { + var elementWidth = this.el.offsetWidth; + if (cursorOffset.left) { + var browserWidth = doc.clientWidth; + if (cursorOffset.left + elementWidth > browserWidth) { + cursorOffset.left = browserWidth - elementWidth; + } + this.el.style.left = cursorOffset.left + "px"; + } else if (cursorOffset.right) { + if (cursorOffset.right - elementWidth < 0) { + cursorOffset.right = 0; + } + this.el.style.right = cursorOffset.right + "px"; + } + if (this.isPlacementTop()) { + this.el.style.bottom = doc.clientHeight - cursorOffset.top + cursorOffset.lineHeight + "px"; + } else { + this.el.style.top = cursorOffset.top + "px"; + } + } + return this; + } + + /** + * Show the element. + * + * @private + */ + + }, { + key: "show", + value: function show() { + if (!this.shown) { + var showEvent = (0, _utils.createCustomEvent)("show", { cancelable: true }); + this.emit("show", showEvent); + if (showEvent.defaultPrevented) { + return this; + } + this.el.style.display = "block"; + this.shown = true; + this.emit("shown", (0, _utils.createCustomEvent)("shown")); + } + return this; + } + + /** + * Hide the element. + * + * @private + */ + + }, { + key: "hide", + value: function hide() { + if (this.shown) { + var hideEvent = (0, _utils.createCustomEvent)("hide", { cancelable: true }); + this.emit("hide", hideEvent); + if (hideEvent.defaultPrevented) { + return this; + } + this.el.style.display = "none"; + this.shown = false; + this.emit("hidden", (0, _utils.createCustomEvent)("hidden")); + } + return this; + } + + /** + * Clear search results. + * + * @private + */ + + }, { + key: "clear", + value: function clear() { + this.el.innerHTML = ""; + this.items.forEach(function (item) { + return item.destroy(); + }); + this.items = []; + return this; + } + + /** @private */ + + }, { + key: "moveActiveItem", + value: function moveActiveItem(direction, e) { + var nextActiveItem = direction === "next" ? this.activeItem ? this.activeItem.next : this.items[0] : this.activeItem ? this.activeItem.prev : this.items[this.items.length - 1]; + if (nextActiveItem) { + nextActiveItem.activate(); + e.preventDefault(); + } + return this; + } + + /** @private */ + + }, { + key: "setStrategyId", + value: function setStrategyId(searchResult) { + var strategyId = searchResult && searchResult.strategy.props.id; + if (strategyId) { + this.el.setAttribute("data-strategy", strategyId); + } else { + this.el.removeAttribute("data-strategy"); + } + return this; + } + + /** + * @private + * @param {object[]} rawResults - What callbacked by search function. + */ + + }, { + key: "renderEdge", + value: function renderEdge(rawResults, type) { + var source = (type === "header" ? this.header : this.footer) || ""; + var content = typeof source === "function" ? source(rawResults) : source; + var li = document.createElement("li"); + li.classList.add("textcomplete-" + type); + li.innerHTML = content; + this.el.appendChild(li); + return this; + } + + /** @private */ + + }, { + key: "isPlacementTop", + value: function isPlacementTop() { + return this.placement === "top"; + } + }, { + key: "el", + get: function get() { + if (!this._el) { + this._el = Dropdown.createElement(); + } + return this._el; + } + }]); + + return Dropdown; +}(_eventemitter2.default); + +exports.default = Dropdown; + +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.DEFAULT_CLASS_NAME = undefined; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _search_result = __webpack_require__(0); + +var _search_result2 = _interopRequireDefault(_search_result); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var DEFAULT_CLASS_NAME = exports.DEFAULT_CLASS_NAME = "textcomplete-item"; +var CALLBACK_METHODS = ["onClick", "onMouseover"]; + +/** @typedef */ + + +// Declare interface instead of importing Dropdown itself to prevent circular dependency. + +/** + * Encapsulate an item of dropdown. + */ +var DropdownItem = function () { + function DropdownItem(searchResult, options) { + var _this = this; + + _classCallCheck(this, DropdownItem); + + this.searchResult = searchResult; + this.active = false; + this.className = options.className || DEFAULT_CLASS_NAME; + this.activeClassName = this.className + " active"; + + CALLBACK_METHODS.forEach(function (method) { + ;_this[method] = _this[method].bind(_this); + }); + } + + _createClass(DropdownItem, [{ + key: "destroy", + + + /** + * Try to free resources and perform other cleanup operations. + */ + value: function destroy() { + this.el.removeEventListener("mousedown", this.onClick, false); + this.el.removeEventListener("mouseover", this.onMouseover, false); + this.el.removeEventListener("touchstart", this.onClick, false); + if (this.active) { + this.dropdown.activeItem = null; + } + // This element has already been removed by {@link Dropdown#clear}. + this._el = null; + } + + /** + * Callbacked when it is appended to a dropdown. + * + * @see Dropdown#append + */ + + }, { + key: "appended", + value: function appended(dropdown) { + this.dropdown = dropdown; + this.siblings = dropdown.items; + this.index = this.siblings.length - 1; + } + + /** + * Deactivate active item then activate itself. + * + * @return {this} + */ + + }, { + key: "activate", + value: function activate() { + if (!this.active) { + var _activeItem = this.dropdown.getActiveItem(); + if (_activeItem) { + _activeItem.deactivate(); + } + this.dropdown.activeItem = this; + this.active = true; + this.el.className = this.activeClassName; + } + return this; + } + + /** + * Get the next sibling. + */ + + }, { + key: "deactivate", + + + /** @private */ + value: function deactivate() { + if (this.active) { + this.active = false; + this.el.className = this.className; + this.dropdown.activeItem = null; + } + return this; + } + + /** @private */ + + }, { + key: "onClick", + value: function onClick(e) { + e.preventDefault // Prevent blur event + ();this.dropdown.select(this); + } + + /** @private */ + + }, { + key: "onMouseover", + value: function onMouseover() { + this.activate(); + } + }, { + key: "el", + get: function get() { + if (this._el) { + return this._el; + } + var li = document.createElement("li"); + li.className = this.active ? this.activeClassName : this.className; + var a = document.createElement("a"); + a.innerHTML = this.searchResult.render(); + li.appendChild(a); + this._el = li; + li.addEventListener("mousedown", this.onClick); + li.addEventListener("mouseover", this.onMouseover); + li.addEventListener("touchstart", this.onClick); + return li; + } + }, { + key: "next", + get: function get() { + var nextIndex = void 0; + if (this.index === this.siblings.length - 1) { + if (!this.dropdown.rotate) { + return null; + } + nextIndex = 0; + } else { + nextIndex = this.index + 1; + } + return this.siblings[nextIndex]; + } + + /** + * Get the previous sibling. + */ + + }, { + key: "prev", + get: function get() { + var nextIndex = void 0; + if (this.index === 0) { + if (!this.dropdown.rotate) { + return null; + } + nextIndex = this.siblings.length - 1; + } else { + nextIndex = this.index - 1; + } + return this.siblings[nextIndex]; + } + }]); + + return DropdownItem; +}(); + +exports.default = DropdownItem; + +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + +var _update = __webpack_require__(13); + +var _update2 = _interopRequireDefault(_update); + +var _editor = __webpack_require__(4); + +var _editor2 = _interopRequireDefault(_editor); + +var _utils = __webpack_require__(3); + +var _search_result = __webpack_require__(0); + +var _search_result2 = _interopRequireDefault(_search_result); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var getCaretCoordinates = __webpack_require__(14); + +var CALLBACK_METHODS = ["onInput", "onKeydown"]; + +/** + * Encapsulate the target textarea element. + */ + +var Textarea = function (_Editor) { + _inherits(Textarea, _Editor); + + /** + * @param {HTMLTextAreaElement} el - Where the textcomplete works on. + */ + function Textarea(el) { + _classCallCheck(this, Textarea); + + var _this = _possibleConstructorReturn(this, (Textarea.__proto__ || Object.getPrototypeOf(Textarea)).call(this)); + + _this.el = el; + + CALLBACK_METHODS.forEach(function (method) { + ;_this[method] = _this[method].bind(_this); + }); + + _this.startListening(); + return _this; + } + + /** + * @return {this} + */ + + + _createClass(Textarea, [{ + key: "destroy", + value: function destroy() { + _get(Textarea.prototype.__proto__ || Object.getPrototypeOf(Textarea.prototype), "destroy", this).call(this); + this.stopListening + // Release the element reference early to help garbage collection. + ();this.el = null; + return this; + } + + /** + * Implementation for {@link Editor#applySearchResult} + */ + + }, { + key: "applySearchResult", + value: function applySearchResult(searchResult) { + var before = this.getBeforeCursor(); + if (before != null) { + var replace = searchResult.replace(before, this.getAfterCursor()); + this.el.focus // Clicking a dropdown item removes focus from the element. + ();if (Array.isArray(replace)) { + (0, _update2.default)(this.el, replace[0], replace[1]); + this.el.dispatchEvent(new Event("input")); + } + } + } + + /** + * Implementation for {@link Editor#getCursorOffset} + */ + + }, { + key: "getCursorOffset", + value: function getCursorOffset() { + var elOffset = (0, _utils.calculateElementOffset)(this.el); + var elScroll = this.getElScroll(); + var cursorPosition = this.getCursorPosition(); + var lineHeight = (0, _utils.getLineHeightPx)(this.el); + var top = elOffset.top - elScroll.top + cursorPosition.top + lineHeight; + var left = elOffset.left - elScroll.left + cursorPosition.left; + if (this.el.dir !== "rtl") { + return { top: top, left: left, lineHeight: lineHeight }; + } else { + var right = document.documentElement ? document.documentElement.clientWidth - left : 0; + return { top: top, right: right, lineHeight: lineHeight }; + } + } + + /** + * Implementation for {@link Editor#getBeforeCursor} + */ + + }, { + key: "getBeforeCursor", + value: function getBeforeCursor() { + return this.el.selectionStart !== this.el.selectionEnd ? null : this.el.value.substring(0, this.el.selectionEnd); + } + + /** @private */ + + }, { + key: "getAfterCursor", + value: function getAfterCursor() { + return this.el.value.substring(this.el.selectionEnd); + } + + /** @private */ + + }, { + key: "getElScroll", + value: function getElScroll() { + return { top: this.el.scrollTop, left: this.el.scrollLeft }; + } + + /** + * The input cursor's relative coordinates from the textarea's left + * top corner. + * + * @private + */ + + }, { + key: "getCursorPosition", + value: function getCursorPosition() { + return getCaretCoordinates(this.el, this.el.selectionEnd); + } + + /** @private */ + + }, { + key: "onInput", + value: function onInput() { + this.emitChangeEvent(); + } + + /** @private */ + + }, { + key: "onKeydown", + value: function onKeydown(e) { + var code = this.getCode(e); + var event = void 0; + if (code === "UP" || code === "DOWN") { + event = this.emitMoveEvent(code); + } else if (code === "ENTER") { + event = this.emitEnterEvent(); + } else if (code === "ESC") { + event = this.emitEscEvent(); + } + if (event && event.defaultPrevented) { + e.preventDefault(); + } + } + + /** @private */ + + }, { + key: "startListening", + value: function startListening() { + this.el.addEventListener("input", this.onInput); + this.el.addEventListener("keydown", this.onKeydown); + } + + /** @private */ + + }, { + key: "stopListening", + value: function stopListening() { + this.el.removeEventListener("input", this.onInput); + this.el.removeEventListener("keydown", this.onKeydown); + } + }]); + + return Textarea; +}(_editor2.default); + +exports.default = Textarea; + +/***/ }), +/* 13 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +exports.default = function (el, headToCursor, cursorToTail) { + var curr = el.value, + // strA + strB1 + strC + next = headToCursor + (cursorToTail || ''), + // strA + strB2 + strC + activeElement = document.activeElement; + + // Calculate length of strA and strC + var aLength = 0, + cLength = 0; + while (aLength < curr.length && aLength < next.length && curr[aLength] === next[aLength]) { + aLength++; + } + while (curr.length - cLength - 1 >= 0 && next.length - cLength - 1 >= 0 && curr[curr.length - cLength - 1] === next[next.length - cLength - 1]) { + cLength++; + } + aLength = Math.min(aLength, Math.min(curr.length, next.length) - cLength); + + // Select strB1 + el.setSelectionRange(aLength, curr.length - cLength); + + // Get strB2 + var strB2 = next.substring(aLength, next.length - cLength); + + // Replace strB1 with strB2 + el.focus(); + if (!document.execCommand('insertText', false, strB2)) { + // Document.execCommand returns false if the command is not supported. + // Firefox and IE returns false in this case. + el.value = next; + el.dispatchEvent(createInputEvent()); + } + + // Move cursor to the end of headToCursor + el.setSelectionRange(headToCursor.length, headToCursor.length); + + activeElement && activeElement.focus(); + return el; +}; + +function createInputEvent() { + if (typeof Event !== "undefined") { + return new Event("input", { bubbles: true, cancelable: true }); + } else { + var event = document.createEvent("Event"); + event.initEvent("input", true, true); + return event; + } +} + +/***/ }), +/* 14 */ +/***/ (function(module, exports) { + +/* jshint browser: true */ + +(function () { + +// The properties that we copy into a mirrored div. +// Note that some browsers, such as Firefox, +// do not concatenate properties, i.e. padding-top, bottom etc. -> padding, +// so we have to do every single property specifically. +var properties = [ + 'direction', // RTL support + 'boxSizing', + 'width', // on Chrome and IE, exclude the scrollbar, so the mirror div wraps exactly as the textarea does + 'height', + 'overflowX', + 'overflowY', // copy the scrollbar for IE + + 'borderTopWidth', + 'borderRightWidth', + 'borderBottomWidth', + 'borderLeftWidth', + 'borderStyle', + + 'paddingTop', + 'paddingRight', + 'paddingBottom', + 'paddingLeft', + + // https://developer.mozilla.org/en-US/docs/Web/CSS/font + 'fontStyle', + 'fontVariant', + 'fontWeight', + 'fontStretch', + 'fontSize', + 'fontSizeAdjust', + 'lineHeight', + 'fontFamily', + + 'textAlign', + 'textTransform', + 'textIndent', + 'textDecoration', // might not make a difference, but better be safe + + 'letterSpacing', + 'wordSpacing', + + 'tabSize', + 'MozTabSize' + +]; + +var isBrowser = (typeof window !== 'undefined'); +var isFirefox = (isBrowser && window.mozInnerScreenX != null); + +function getCaretCoordinates(element, position, options) { + if(!isBrowser) { + throw new Error('textarea-caret-position#getCaretCoordinates should only be called in a browser'); + } + + var debug = options && options.debug || false; + if (debug) { + var el = document.querySelector('#input-textarea-caret-position-mirror-div'); + if ( el ) { el.parentNode.removeChild(el); } + } + + // mirrored div + var div = document.createElement('div'); + div.id = 'input-textarea-caret-position-mirror-div'; + document.body.appendChild(div); + + var style = div.style; + var computed = window.getComputedStyle? getComputedStyle(element) : element.currentStyle; // currentStyle for IE < 9 + + // default textarea styles + style.whiteSpace = 'pre-wrap'; + if (element.nodeName !== 'INPUT') + style.wordWrap = 'break-word'; // only for textarea-s + + // position off-screen + style.position = 'absolute'; // required to return coordinates properly + if (!debug) + style.visibility = 'hidden'; // not 'display: none' because we want rendering + + // transfer the element's properties to the div + properties.forEach(function (prop) { + style[prop] = computed[prop]; + }); + + if (isFirefox) { + // Firefox lies about the overflow property for textareas: https://bugzilla.mozilla.org/show_bug.cgi?id=984275 + if (element.scrollHeight > parseInt(computed.height)) + style.overflowY = 'scroll'; + } else { + style.overflow = 'hidden'; // for Chrome to not render a scrollbar; IE keeps overflowY = 'scroll' + } + + div.textContent = element.value.substring(0, position); + // the second special handling for input type="text" vs textarea: spaces need to be replaced with non-breaking spaces - http://stackoverflow.com/a/13402035/1269037 + if (element.nodeName === 'INPUT') + div.textContent = div.textContent.replace(/\s/g, '\u00a0'); + + var span = document.createElement('span'); + // Wrapping must be replicated *exactly*, including when a long word gets + // onto the next line, with whitespace at the end of the line before (#7). + // The *only* reliable way to do that is to copy the *entire* rest of the + // textarea's content into the created at the caret position. + // for inputs, just '.' would be enough, but why bother? + span.textContent = element.value.substring(position) || '.'; // || because a completely empty faux span doesn't render at all + div.appendChild(span); + + var coordinates = { + top: span.offsetTop + parseInt(computed['borderTopWidth']), + left: span.offsetLeft + parseInt(computed['borderLeftWidth']) + }; + + if (debug) { + span.style.backgroundColor = '#aaa'; + } else { + document.body.removeChild(div); + } + + return coordinates; +} + +if (typeof module != 'undefined' && typeof module.exports != 'undefined') { + module.exports = getCaretCoordinates; +} else if(isBrowser){ + window.getCaretCoordinates = getCaretCoordinates; +} + +}()); + + +/***/ }) +/******/ ]); +//# sourceMappingURL=textcomplete.js.map \ No newline at end of file diff --git a/library/textcomplete/textcomplete.js.map b/library/textcomplete/textcomplete.js.map new file mode 100644 index 000000000..42ed11883 --- /dev/null +++ b/library/textcomplete/textcomplete.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/bootstrap 0bc74e584933ddf1c7ac","webpack:///./src/search_result.js","webpack:///./node_modules/eventemitter3/index.js","webpack:///./src/strategy.js","webpack:///./src/utils.js","webpack:///./src/editor.js","webpack:///./src/main.js","webpack:///(webpack)/buildin/global.js","webpack:///./src/textcomplete.js","webpack:///./src/completer.js","webpack:///./src/query.js","webpack:///./src/dropdown.js","webpack:///./src/dropdown_item.js","webpack:///./src/textarea.js","webpack:///./node_modules/undate/lib/update.js","webpack:///./node_modules/textarea-caret/index.js"],"names":["SearchResult","data","term","strategy","beforeCursor","afterCursor","replacement","replace","Array","isArray","match","matchText","_","p1","parseInt","slice","index","length","join","template","DEFAULT_INDEX","DEFAULT_TEMPLATE","value","Strategy","props","cache","callback","searchWithCache","search","results","text","calculateElementOffset","getLineHeightPx","calculateLineHeightPx","createCustomEvent","window","CustomEvent","type","options","document","defaultView","cancelable","detail","undefined","event","createEvent","initCustomEvent","el","rect","getBoundingClientRect","ownerDocument","documentElement","offset","top","pageYOffset","left","pageXOffset","clientTop","clientLeft","CHAR_CODE_ZERO","charCodeAt","CHAR_CODE_NINE","isDigit","charCode","node","computedStyle","getComputedStyle","lineHeight","parseFloat","fontSize","nodeName","body","tempNode","createElement","innerHTML","style","fontFamily","padding","appendChild","HTMLTextAreaElement","rows","height","offsetHeight","removeChild","Editor","Error","code","moveEvent","emit","enterEvent","changeEvent","getBeforeCursor","escEvent","e","keyCode","ctrlKey","editors","global","Textcomplete","Textarea","CALLBACK_METHODS","editor","completer","isQueryInFlight","nextPendingQuery","dropdown","forEach","method","bind","startListening","destroyEditor","destroy","stopListening","deactivate","strategyPropsArray","registerStrategy","run","searchResults","render","getCursorOffset","trigger","up","down","activeItem","getActiveItem","select","preventDefault","shown","selectEvent","defaultPrevented","applySearchResult","searchResult","on","handleMove","handleEnter","handleEsc","handleChange","handleSelect","eventName","handleHit","removeAllListeners","removeListener","Completer","strategies","push","query","extractQuery","execute","handleQueryResult","i","build","Query","context","map","result","DEFAULT_CLASS_NAME","Dropdown","display","position","zIndex","items","footer","header","maxCount","className","rotate","hasOwnProperty","placement","itemOptions","item","Object","keys","key","parentNode","clear","_el","cursorOffset","renderEvent","rawResults","dropdownItems","setStrategyId","renderEdge","append","show","setOffset","hide","dropdownItem","moveActiveItem","fragment","createDocumentFragment","appended","doc","elementWidth","offsetWidth","browserWidth","clientWidth","right","isPlacementTop","bottom","clientHeight","showEvent","hideEvent","direction","nextActiveItem","next","prev","activate","strategyId","id","setAttribute","removeAttribute","source","content","li","classList","add","DropdownItem","active","activeClassName","removeEventListener","onClick","onMouseover","siblings","a","addEventListener","nextIndex","getCaretCoordinates","require","before","getAfterCursor","focus","dispatchEvent","Event","elOffset","elScroll","getElScroll","cursorPosition","getCursorPosition","dir","selectionStart","selectionEnd","substring","scrollTop","scrollLeft","emitChangeEvent","getCode","emitMoveEvent","emitEnterEvent","emitEscEvent","onInput","onKeydown"],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;AC3DA;;;;;;;;AAEA;;;IAGqBA,Y;;AAKnB;;;AAGA,wBAAYC,IAAZ,EAA0BC,IAA1B,EAAwCC,QAAxC,EAA4D;AAAA;;AAC1D,SAAKF,IAAL,GAAYA,IAAZ;AACA,SAAKC,IAAL,GAAYA,IAAZ;AACA,SAAKC,QAAL,GAAgBA,QAAhB;AACD;;;;4BAEOC,Y,EAAsBC,W,EAAqB;AACjD,UAAIC,cAAc,KAAKH,QAAL,CAAcI,OAAd,CAAsB,KAAKN,IAA3B,CAAlB;AACA,UAAIK,gBAAgB,IAApB,EAA0B;AACxB,YAAIE,MAAMC,OAAN,CAAcH,WAAd,CAAJ,EAAgC;AAC9BD,wBAAcC,YAAY,CAAZ,IAAiBD,WAA/B;AACAC,wBAAcA,YAAY,CAAZ,CAAd;AACD;AACD,YAAMI,QAAQ,KAAKP,QAAL,CAAcQ,SAAd,CAAwBP,YAAxB,CAAd;AACA,YAAIM,KAAJ,EAAW;AACTJ,wBAAcA,YACXC,OADW,C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;AACA;AACA;AACA;AACA;AACA;;AAEA,yCAAyC,SAAS;AAClD;AACA;;AAEA;AACA,GAAG;AACH;AACA;;AAEA,eAAe,YAAY;AAC3B;;AAEA;AACA,2DAA2D;AAC3D,+DAA+D;AAC/D,mEAAmE;AACnE,uEAAuE;AACvE;AACA,0DAA0D,SAAS;AACnE;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,cAAc;AACzB,WAAW,SAAS;AACpB,WAAW,MAAM;AACjB,aAAa,aAAa;AAC1B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,cAAc;AACzB,WAAW,SAAS;AACpB,WAAW,MAAM;AACjB,aAAa,aAAa;AAC1B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,cAAc;AACzB,WAAW,SAAS;AACpB,WAAW,MAAM;AACjB,WAAW,QAAQ;AACnB,aAAa,aAAa;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH,2DAA2D,YAAY;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,cAAc;AACzB,aAAa,aAAa;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;AC9SA,IAAMoB,gBAAgB,CAAtB;;AAEA,SAASC,gBAAT,CAA0BC,KAA1B,EAAi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ACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;AACH,8BAA8B,0CAA0C;AACxE;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,8DAA8D;AAC9D;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;;AAEA;AACA;AACA,CAAC;AACD;AACA;;AAEA,CAAC","file":"textcomplete.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 5);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 0bc74e584933ddf1c7ac","// @flow\n\nimport Strategy from \"./strategy\"\n\n/**\n * Encapsulate an result of each search results.\n */\nexport default class SearchResult {\n data: Object\n term: string\n strategy: Strategy\n\n /**\n * @param {object} data - An element of array callbacked by search function.\n */\n constructor(data: Object, term: string, strategy: Strategy) {\n this.data = data\n this.term = term\n this.strategy = strategy\n }\n\n replace(beforeCursor: string, afterCursor: string) {\n let replacement = this.strategy.replace(this.data)\n if (replacement !== null) {\n if (Array.isArray(replacement)) {\n afterCursor = replacement[1] + afterCursor\n replacement = replacement[0]\n }\n const match = this.strategy.matchText(beforeCursor)\n if (match) {\n replacement = replacement\n .replace(/\\$&/g, match[0])\n .replace(/\\$(\\d)/g, (_, p1) => match[parseInt(p1, 10)])\n return [\n [\n beforeCursor.slice(0, match.index),\n replacement,\n beforeCursor.slice(match.index + match[0].length),\n ].join(\"\"),\n afterCursor,\n ]\n }\n }\n }\n\n render(): string {\n return this.strategy.template(this.data, this.term)\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/search_result.js","'use strict';\n\nvar has = Object.prototype.hasOwnProperty\n , prefix = '~';\n\n/**\n * Constructor to create a storage for our `EE` objects.\n * An `Events` instance is a plain object whose properties are event names.\n *\n * @constructor\n * @api private\n */\nfunction Events() {}\n\n//\n// We try to not inherit from `Object.prototype`. In some engines creating an\n// instance in this way is faster than calling `Object.create(null)` directly.\n// If `Object.create(null)` is not supported we prefix the event names with a\n// character to make sure that the built-in object properties are not\n// overridden or used as an attack vector.\n//\nif (Object.create) {\n Events.prototype = Object.create(null);\n\n //\n // This hack is needed because the `__proto__` property is still inherited in\n // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.\n //\n if (!new Events().__proto__) prefix = false;\n}\n\n/**\n * Representation of a single event listener.\n *\n * @param {Function} fn The listener function.\n * @param {Mixed} context The context to invoke the listener with.\n * @param {Boolean} [once=false] Specify if the listener is a one-time listener.\n * @constructor\n * @api private\n */\nfunction EE(fn, context, once) {\n this.fn = fn;\n this.context = context;\n this.once = once || false;\n}\n\n/**\n * Minimal `EventEmitter` interface that is molded against the Node.js\n * `EventEmitter` interface.\n *\n * @constructor\n * @api public\n */\nfunction EventEmitter() {\n this._events = new Events();\n this._eventsCount = 0;\n}\n\n/**\n * Return an array listing the events for which the emitter has registered\n * listeners.\n *\n * @returns {Array}\n * @api public\n */\nEventEmitter.prototype.eventNames = function eventNames() {\n var names = []\n , events\n , name;\n\n if (this._eventsCount === 0) return names;\n\n for (name in (events = this._events)) {\n if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);\n }\n\n if (Object.getOwnPropertySymbols) {\n return names.concat(Object.getOwnPropertySymbols(events));\n }\n\n return names;\n};\n\n/**\n * Return the listeners registered for a given event.\n *\n * @param {String|Symbol} event The event name.\n * @param {Boolean} exists Only check if there are listeners.\n * @returns {Array|Boolean}\n * @api public\n */\nEventEmitter.prototype.listeners = function listeners(event, exists) {\n var evt = prefix ? prefix + event : event\n , available = this._events[evt];\n\n if (exists) return !!available;\n if (!available) return [];\n if (available.fn) return [available.fn];\n\n for (var i = 0, l = available.length, ee = new Array(l); i < l; i++) {\n ee[i] = available[i].fn;\n }\n\n return ee;\n};\n\n/**\n * Calls each of the listeners registered for a given event.\n *\n * @param {String|Symbol} event The event name.\n * @returns {Boolean} `true` if the event had listeners, else `false`.\n * @api public\n */\nEventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return false;\n\n var listeners = this._events[evt]\n , len = arguments.length\n , args\n , i;\n\n if (listeners.fn) {\n if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);\n\n switch (len) {\n case 1: return listeners.fn.call(listeners.context), true;\n case 2: return listeners.fn.call(listeners.context, a1), true;\n case 3: return listeners.fn.call(listeners.context, a1, a2), true;\n case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;\n case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;\n case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;\n }\n\n for (i = 1, args = new Array(len -1); i < len; i++) {\n args[i - 1] = arguments[i];\n }\n\n listeners.fn.apply(listeners.context, args);\n } else {\n var length = listeners.length\n , j;\n\n for (i = 0; i < length; i++) {\n if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);\n\n switch (len) {\n case 1: listeners[i].fn.call(listeners[i].context); break;\n case 2: listeners[i].fn.call(listeners[i].context, a1); break;\n case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;\n case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;\n default:\n if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {\n args[j - 1] = arguments[j];\n }\n\n listeners[i].fn.apply(listeners[i].context, args);\n }\n }\n }\n\n return true;\n};\n\n/**\n * Add a listener for a given event.\n *\n * @param {String|Symbol} event The event name.\n * @param {Function} fn The listener function.\n * @param {Mixed} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @api public\n */\nEventEmitter.prototype.on = function on(event, fn, context) {\n var listener = new EE(fn, context || this)\n , evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;\n else if (!this._events[evt].fn) this._events[evt].push(listener);\n else this._events[evt] = [this._events[evt], listener];\n\n return this;\n};\n\n/**\n * Add a one-time listener for a given event.\n *\n * @param {String|Symbol} event The event name.\n * @param {Function} fn The listener function.\n * @param {Mixed} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @api public\n */\nEventEmitter.prototype.once = function once(event, fn, context) {\n var listener = new EE(fn, context || this, true)\n , evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;\n else if (!this._events[evt].fn) this._events[evt].push(listener);\n else this._events[evt] = [this._events[evt], listener];\n\n return this;\n};\n\n/**\n * Remove the listeners of a given event.\n *\n * @param {String|Symbol} event The event name.\n * @param {Function} fn Only remove the listeners that match this function.\n * @param {Mixed} context Only remove the listeners that have this context.\n * @param {Boolean} once Only remove one-time listeners.\n * @returns {EventEmitter} `this`.\n * @api public\n */\nEventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return this;\n if (!fn) {\n if (--this._eventsCount === 0) this._events = new Events();\n else delete this._events[evt];\n return this;\n }\n\n var listeners = this._events[evt];\n\n if (listeners.fn) {\n if (\n listeners.fn === fn\n && (!once || listeners.once)\n && (!context || listeners.context === context)\n ) {\n if (--this._eventsCount === 0) this._events = new Events();\n else delete this._events[evt];\n }\n } else {\n for (var i = 0, events = [], length = listeners.length; i < length; i++) {\n if (\n listeners[i].fn !== fn\n || (once && !listeners[i].once)\n || (context && listeners[i].context !== context)\n ) {\n events.push(listeners[i]);\n }\n }\n\n //\n // Reset the array, or remove it completely if we have no more listeners.\n //\n if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;\n else if (--this._eventsCount === 0) this._events = new Events();\n else delete this._events[evt];\n }\n\n return this;\n};\n\n/**\n * Remove all listeners, or those of the specified event.\n *\n * @param {String|Symbol} [event] The event name.\n * @returns {EventEmitter} `this`.\n * @api public\n */\nEventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {\n var evt;\n\n if (event) {\n evt = prefix ? prefix + event : event;\n if (this._events[evt]) {\n if (--this._eventsCount === 0) this._events = new Events();\n else delete this._events[evt];\n }\n } else {\n this._events = new Events();\n this._eventsCount = 0;\n }\n\n return this;\n};\n\n//\n// Alias methods names because people roll like that.\n//\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\nEventEmitter.prototype.addListener = EventEmitter.prototype.on;\n\n//\n// This function doesn't apply anymore.\n//\nEventEmitter.prototype.setMaxListeners = function setMaxListeners() {\n return this;\n};\n\n//\n// Expose the prefix.\n//\nEventEmitter.prefixed = prefix;\n\n//\n// Allow `EventEmitter` to be imported as module namespace.\n//\nEventEmitter.EventEmitter = EventEmitter;\n\n//\n// Expose the module.\n//\nif ('undefined' !== typeof module) {\n module.exports = EventEmitter;\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/eventemitter3/index.js\n// module id = 1\n// module chunks = 0","// @flow\n\ndeclare class MatchData extends Array {\n index: number;\n}\n\nexport type { MatchData }\n\nconst DEFAULT_INDEX = 2\n\nfunction DEFAULT_TEMPLATE(value) {\n return value\n}\n\n/**\n * Properties for a strategy.\n *\n * @typedef\n */\nexport type StrategyProperties = {\n match: RegExp | (string => MatchData | null),\n search: Function,\n replace: any => string[] | string | null,\n cache?: boolean,\n context?: Function,\n template?: any => string,\n index?: number,\n id?: string,\n}\n\n/**\n * Encapsulate a single strategy.\n */\nexport default class Strategy {\n props: StrategyProperties\n cache: ?Object\n\n constructor(props: StrategyProperties) {\n this.props = props\n this.cache = props.cache ? {} : null\n }\n\n /**\n * @return {this}\n */\n destroy() {\n this.cache = null\n return this\n }\n\n search(term: string, callback: Function, match: MatchData): void {\n if (this.cache) {\n this.searchWithCache(term, callback, match)\n } else {\n this.props.search(term, callback, match)\n }\n }\n\n /**\n * @param {object} data - An element of array callbacked by search function.\n */\n replace(data: any) {\n return this.props.replace(data)\n }\n\n /** @private */\n searchWithCache(term: string, callback: Function, match: MatchData): void {\n if (this.cache && this.cache[term]) {\n callback(this.cache[term])\n } else {\n this.props.search(\n term,\n results => {\n if (this.cache) {\n this.cache[term] = results\n }\n callback(results)\n },\n match,\n )\n }\n }\n\n /** @private */\n matchText(text: string): MatchData | null {\n if (typeof this.match === \"function\") {\n return this.match(text)\n } else {\n return (text.match(this.match): any)\n }\n }\n\n /** @private */\n get match(): $PropertyType {\n return this.props.match\n }\n\n /** @private */\n get index(): number {\n return typeof this.props.index === \"number\"\n ? this.props.index\n : DEFAULT_INDEX\n }\n\n get template(): (...any) => string {\n return this.props.template || DEFAULT_TEMPLATE\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/strategy.js","// @flow\n\n/**\n * Create a custom event\n *\n * @private\n */\nexport const createCustomEvent = (() => {\n if (typeof window.CustomEvent === \"function\") {\n return function(\n type: string,\n options: ?{ detail?: Object, cancelable?: boolean },\n ): CustomEvent {\n return new document.defaultView.CustomEvent(type, {\n cancelable: (options && options.cancelable) || false,\n detail: (options && options.detail) || undefined,\n })\n }\n } else {\n // Custom event polyfill from\n // https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#polyfill\n return function(\n type: string,\n options: ?{ detail?: Object, cancelable?: boolean },\n ): CustomEvent {\n const event = document.createEvent(\"CustomEvent\")\n event.initCustomEvent(\n type,\n /* bubbles */ false,\n (options && options.cancelable) || false,\n (options && options.detail) || undefined,\n )\n return event\n }\n }\n})()\n\n/**\n * Get the current coordinates of the `el` relative to the document.\n *\n * @private\n */\nexport function calculateElementOffset(\n el: HTMLElement,\n): { top: number, left: number } {\n const rect = el.getBoundingClientRect()\n const { defaultView, documentElement } = el.ownerDocument\n const offset = {\n top: rect.top + defaultView.pageYOffset,\n left: rect.left + defaultView.pageXOffset,\n }\n if (documentElement) {\n offset.top -= documentElement.clientTop\n offset.left -= documentElement.clientLeft\n }\n return offset\n}\n\nconst CHAR_CODE_ZERO = \"0\".charCodeAt(0)\nconst CHAR_CODE_NINE = \"9\".charCodeAt(0)\n\nfunction isDigit(charCode: number): boolean {\n return charCode >= CHAR_CODE_ZERO && charCode <= CHAR_CODE_NINE\n}\n\n/**\n * Returns the line-height of the given node in pixels.\n *\n * @private\n */\nexport function getLineHeightPx(node: HTMLElement): number {\n const computedStyle = window.getComputedStyle(node)\n\n // If the char code starts with a digit, it is either a value in pixels,\n // or unitless, as per:\n // https://drafts.csswg.org/css2/visudet.html#propdef-line-height\n // https://drafts.csswg.org/css2/cascade.html#computed-value\n if (isDigit(computedStyle.lineHeight.charCodeAt(0))) {\n // In real browsers the value is *always* in pixels, even for unit-less\n // line-heights. However, we still check as per the spec.\n if (\n isDigit(\n computedStyle.lineHeight.charCodeAt(\n computedStyle.lineHeight.length - 1,\n ),\n )\n ) {\n return (\n parseFloat(computedStyle.lineHeight) *\n parseFloat(computedStyle.fontSize)\n )\n } else {\n return parseFloat(computedStyle.lineHeight)\n }\n }\n\n // Otherwise, the value is \"normal\".\n // If the line-height is \"normal\", calculate by font-size\n return calculateLineHeightPx(node.nodeName, computedStyle)\n}\n\n/**\n * Returns calculated line-height of the given node in pixels.\n *\n * @private\n */\nexport function calculateLineHeightPx(\n nodeName: string,\n computedStyle: CSSStyleDeclaration,\n): number {\n const body = document.body\n if (!body) {\n return 0\n }\n\n const tempNode = document.createElement(nodeName)\n tempNode.innerHTML = \" \"\n tempNode.style.fontSize = computedStyle.fontSize\n tempNode.style.fontFamily = computedStyle.fontFamily\n tempNode.style.padding = \"0\"\n body.appendChild(tempNode)\n\n // Make sure textarea has only 1 row\n if (tempNode instanceof HTMLTextAreaElement) {\n ;(tempNode: HTMLTextAreaElement).rows = 1\n }\n\n // Assume the height of the element is the line-height\n const height = tempNode.offsetHeight\n body.removeChild(tempNode)\n\n return height\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/utils.js","// @flow\n/*eslint no-unused-vars: off*/\n\nimport EventEmitter from \"eventemitter3\"\n\nimport { createCustomEvent } from \"./utils\"\nimport SearchResult from \"./search_result\"\n\n/** @typedef */\nexport type CursorOffset = {\n lineHeight: number,\n top: number,\n left?: number,\n right?: number,\n}\n\ntype KeyCode = \"ESC\" | \"ENTER\" | \"UP\" | \"DOWN\" | \"OTHER\"\n\n/**\n * Abstract class representing a editor target.\n *\n * Editor classes must implement `#applySearchResult`, `#getCursorOffset` and\n * `#getBeforeCursor` methods.\n *\n * Editor classes must invoke `#emitMoveEvent`, `#emitEnterEvent`,\n * `#emitChangeEvent` and `#emitEscEvent` at proper timing.\n *\n * @abstract\n */\nexport default class Editor extends EventEmitter {\n /**\n * It is called when associated textcomplete object is destroyed.\n *\n * @return {this}\n */\n destroy() {\n return this\n }\n\n /**\n * It is called when a search result is selected by a user.\n */\n applySearchResult(_: SearchResult): void {\n throw new Error(\"Not implemented.\")\n }\n\n /**\n * The input cursor's absolute coordinates from the window's left\n * top corner.\n */\n getCursorOffset(): CursorOffset {\n throw new Error(\"Not implemented.\")\n }\n\n /**\n * Editor string value from head to cursor.\n * Returns null if selection type is range not cursor.\n */\n getBeforeCursor(): ?string {\n throw new Error(\"Not implemented.\")\n }\n\n /**\n * Emit a move event, which moves active dropdown element.\n * Child class must call this method at proper timing with proper parameter.\n *\n * @see {@link Textarea} for live example.\n */\n emitMoveEvent(code: \"UP\" | \"DOWN\"): CustomEvent {\n const moveEvent = createCustomEvent(\"move\", {\n cancelable: true,\n detail: {\n code: code,\n },\n })\n this.emit(\"move\", moveEvent)\n return moveEvent\n }\n\n /**\n * Emit a enter event, which selects current search result.\n * Child class must call this method at proper timing.\n *\n * @see {@link Textarea} for live example.\n */\n emitEnterEvent(): CustomEvent {\n const enterEvent = createCustomEvent(\"enter\", { cancelable: true })\n this.emit(\"enter\", enterEvent)\n return enterEvent\n }\n\n /**\n * Emit a change event, which triggers auto completion.\n * Child class must call this method at proper timing.\n *\n * @see {@link Textarea} for live example.\n */\n emitChangeEvent(): CustomEvent {\n const changeEvent = createCustomEvent(\"change\", {\n detail: {\n beforeCursor: this.getBeforeCursor(),\n },\n })\n this.emit(\"change\", changeEvent)\n return changeEvent\n }\n\n /**\n * Emit a esc event, which hides dropdown element.\n * Child class must call this method at proper timing.\n *\n * @see {@link Textarea} for live example.\n */\n emitEscEvent(): CustomEvent {\n const escEvent = createCustomEvent(\"esc\", { cancelable: true })\n this.emit(\"esc\", escEvent)\n return escEvent\n }\n\n /**\n * Helper method for parsing KeyboardEvent.\n *\n * @see {@link Textarea} for live example.\n */\n getCode(e: KeyboardEvent): KeyCode {\n return e.keyCode === 9\n ? \"ENTER\" // tab\n : e.keyCode === 13\n ? \"ENTER\" // enter\n : e.keyCode === 27\n ? \"ESC\" // esc\n : e.keyCode === 38\n ? \"UP\" // up\n : e.keyCode === 40\n ? \"DOWN\" // down\n : e.keyCode === 78 && e.ctrlKey\n ? \"DOWN\" // ctrl-n\n : e.keyCode === 80 && e.ctrlKey\n ? \"UP\" // ctrl-p\n : \"OTHER\"\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/editor.js","import Textcomplete from \"./textcomplete\"\nimport Textarea from \"./textarea\"\n\nlet editors\nif (global.Textcomplete && global.Textcomplete.editors) {\n editors = global.Textcomplete.editors\n} else {\n editors = {}\n}\neditors.Textarea = Textarea\n\nglobal.Textcomplete = Textcomplete\nglobal.Textcomplete.editors = editors\n\n\n\n// WEBPACK FOOTER //\n// ./src/main.js","var g;\r\n\r\n// This works in non-strict mode\r\ng = (function() {\r\n\treturn this;\r\n})();\r\n\r\ntry {\r\n\t// This works if eval is allowed (see CSP)\r\n\tg = g || Function(\"return this\")() || (1,eval)(\"this\");\r\n} catch(e) {\r\n\t// This works if the window reference is available\r\n\tif(typeof window === \"object\")\r\n\t\tg = window;\r\n}\r\n\r\n// g can still be undefined, but nothing to do about it...\r\n// We return undefined, instead of nothing here, so it's\r\n// easier to handle this case. if(!global) { ...}\r\n\r\nmodule.exports = g;\r\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// (webpack)/buildin/global.js\n// module id = 6\n// module chunks = 0","// @flow\n\nimport Completer from \"./completer\"\nimport Editor from \"./editor\"\nimport Dropdown, { type DropdownOptions } from \"./dropdown\"\nimport Strategy, { type StrategyProperties } from \"./strategy\"\nimport SearchResult from \"./search_result\"\n\nimport EventEmitter from \"eventemitter3\"\n\nconst CALLBACK_METHODS = [\n \"handleChange\",\n \"handleEnter\",\n \"handleEsc\",\n \"handleHit\",\n \"handleMove\",\n \"handleSelect\",\n]\n\n/** @typedef */\ntype TextcompleteOptions = {\n dropdown?: DropdownOptions,\n}\n\n/**\n * The core of textcomplete. It acts as a mediator.\n */\nexport default class Textcomplete extends EventEmitter {\n dropdown: Dropdown\n editor: Editor\n options: TextcompleteOptions\n completer: Completer\n isQueryInFlight: boolean\n nextPendingQuery: string | null\n\n /**\n * @param {Editor} editor - Where the textcomplete works on.\n */\n constructor(editor: Editor, options: TextcompleteOptions = {}) {\n super()\n\n this.completer = new Completer()\n this.isQueryInFlight = false\n this.nextPendingQuery = null\n this.dropdown = new Dropdown(options.dropdown || {})\n this.editor = editor\n this.options = options\n\n CALLBACK_METHODS.forEach(method => {\n ;(this: any)[method] = (this: any)[method].bind(this)\n })\n\n this.startListening()\n }\n\n /**\n * @return {this}\n */\n destroy(destroyEditor: boolean = true) {\n this.completer.destroy()\n this.dropdown.destroy()\n if (destroyEditor) {\n this.editor.destroy()\n }\n this.stopListening()\n return this\n }\n\n /**\n * @return {this}\n */\n hide() {\n this.dropdown.deactivate()\n return this\n }\n\n /**\n * @return {this}\n * @example\n * textcomplete.register([{\n * match: /(^|\\s)(\\w+)$/,\n * search: function (term, callback) {\n * $.ajax({ ... })\n * .done(callback)\n * .fail([]);\n * },\n * replace: function (value) {\n * return '$1' + value + ' ';\n * }\n * }]);\n */\n register(strategyPropsArray: StrategyProperties[]) {\n strategyPropsArray.forEach(props => {\n this.completer.registerStrategy(new Strategy(props))\n })\n return this\n }\n\n /**\n * Start autocompleting.\n *\n * @param {string} text - Head to input cursor.\n * @return {this}\n */\n trigger(text: string) {\n if (this.isQueryInFlight) {\n this.nextPendingQuery = text\n } else {\n this.isQueryInFlight = true\n this.nextPendingQuery = null\n this.completer.run(text)\n }\n return this\n }\n\n /** @private */\n handleHit({ searchResults }: { searchResults: SearchResult[] }) {\n if (searchResults.length) {\n this.dropdown.render(searchResults, this.editor.getCursorOffset())\n } else {\n this.dropdown.deactivate()\n }\n this.isQueryInFlight = false\n if (this.nextPendingQuery !== null) {\n this.trigger(this.nextPendingQuery)\n }\n }\n\n /** @private */\n handleMove(e: CustomEvent) {\n e.detail.code === \"UP\" ? this.dropdown.up(e) : this.dropdown.down(e)\n }\n\n /** @private */\n handleEnter(e: CustomEvent) {\n const activeItem = this.dropdown.getActiveItem()\n if (activeItem) {\n this.dropdown.select(activeItem)\n e.preventDefault()\n } else {\n this.dropdown.deactivate()\n }\n }\n\n /** @private */\n handleEsc(e: CustomEvent) {\n if (this.dropdown.shown) {\n this.dropdown.deactivate()\n e.preventDefault()\n }\n }\n\n /** @private */\n handleChange(e: CustomEvent) {\n if (e.detail.beforeCursor != null) {\n this.trigger(e.detail.beforeCursor)\n } else {\n this.dropdown.deactivate()\n }\n }\n\n /** @private */\n handleSelect(selectEvent: CustomEvent) {\n this.emit(\"select\", selectEvent)\n if (!selectEvent.defaultPrevented) {\n this.editor.applySearchResult(selectEvent.detail.searchResult)\n }\n }\n\n /** @private */\n startListening() {\n this.editor\n .on(\"move\", this.handleMove)\n .on(\"enter\", this.handleEnter)\n .on(\"esc\", this.handleEsc)\n .on(\"change\", this.handleChange)\n this.dropdown.on(\"select\", this.handleSelect)\n ;[\n \"show\",\n \"shown\",\n \"render\",\n \"rendered\",\n \"selected\",\n \"hidden\",\n \"hide\",\n ].forEach(eventName => {\n this.dropdown.on(eventName, () => this.emit(eventName))\n })\n this.completer.on(\"hit\", this.handleHit)\n }\n\n /** @private */\n stopListening() {\n this.completer.removeAllListeners()\n this.dropdown.removeAllListeners()\n this.editor\n .removeListener(\"move\", this.handleMove)\n .removeListener(\"enter\", this.handleEnter)\n .removeListener(\"esc\", this.handleEsc)\n .removeListener(\"change\", this.handleChange)\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/textcomplete.js","// @flow\n\nimport EventEmitter from \"eventemitter3\"\n\nimport Query from \"./query\"\nimport SearchResult from \"./search_result\"\nimport Strategy from \"./strategy\"\n\nconst CALLBACK_METHODS = [\"handleQueryResult\"]\n\n/**\n * Complete engine.\n */\nexport default class Completer extends EventEmitter {\n strategies: Strategy[]\n\n constructor() {\n super()\n this.strategies = []\n\n CALLBACK_METHODS.forEach(method => {\n ;(this: any)[method] = (this: any)[method].bind(this)\n })\n }\n\n /**\n * @return {this}\n */\n destroy() {\n this.strategies.forEach(strategy => strategy.destroy())\n return this\n }\n\n /**\n * Register a strategy to the completer.\n *\n * @return {this}\n */\n registerStrategy(strategy: Strategy) {\n this.strategies.push(strategy)\n return this\n }\n\n /**\n * @param {string} text - Head to input cursor.\n */\n run(text: string): void {\n const query = this.extractQuery(text)\n if (query) {\n query.execute(this.handleQueryResult)\n } else {\n this.handleQueryResult([])\n }\n }\n\n /**\n * Find a query, which matches to the given text.\n *\n * @private\n */\n extractQuery(text: string) {\n for (let i = 0; i < this.strategies.length; i++) {\n const query = Query.build(this.strategies[i], text)\n if (query) {\n return query\n }\n }\n return null\n }\n\n /**\n * Callbacked by {@link Query#execute}.\n *\n * @private\n */\n handleQueryResult(searchResults: SearchResult[]) {\n this.emit(\"hit\", { searchResults })\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/completer.js","// @flow\n\nimport SearchResult from \"./search_result\"\nimport Strategy from \"./strategy\"\nimport type { MatchData } from \"./strategy\"\n\n/**\n * Encapsulate matching condition between a Strategy and current editor's value.\n */\nexport default class Query {\n strategy: Strategy\n term: string\n match: MatchData\n\n /**\n * Build a Query object by the given string if this matches to the string.\n *\n * @param {string} text - Head to input cursor.\n */\n static build(strategy: Strategy, text: string): ?Query {\n if (typeof strategy.props.context === \"function\") {\n const context = strategy.props.context(text)\n if (typeof context === \"string\") {\n text = context\n } else if (!context) {\n return null\n }\n }\n const match = strategy.matchText(text)\n return match ? new Query(strategy, match[strategy.index], match) : null\n }\n\n constructor(strategy: Strategy, term: string, match: MatchData) {\n this.strategy = strategy\n this.term = term\n this.match = match\n }\n\n /**\n * Invoke search strategy and callback the given function.\n */\n execute(callback: (SearchResult[]) => void) {\n this.strategy.search(\n this.term,\n results => {\n callback(\n results.map(result => {\n return new SearchResult(result, this.term, this.strategy)\n }),\n )\n },\n this.match,\n )\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/query.js","// @flow\nimport EventEmitter from \"eventemitter3\"\n\nimport DropdownItem, { type DropdownItemOptions } from \"./dropdown_item\"\nimport SearchResult from \"./search_result\"\nimport { createCustomEvent } from \"./utils\"\nimport type { CursorOffset } from \"./editor\"\n\nconst DEFAULT_CLASS_NAME = \"dropdown-menu textcomplete-dropdown\"\n\n/** @typedef */\nexport type DropdownOptions = {\n className?: string,\n footer?: any => string | string,\n header?: any => string | string,\n maxCount?: number,\n placement?: string,\n rotate?: boolean,\n style?: { [string]: string },\n item?: DropdownItemOptions,\n}\n\n/**\n * Encapsulate a dropdown view.\n *\n * @prop {boolean} shown - Whether the #el is shown or not.\n * @prop {DropdownItem[]} items - The array of rendered dropdown items.\n */\nexport default class Dropdown extends EventEmitter {\n shown: boolean\n items: DropdownItem[]\n activeItem: DropdownItem | null\n footer: $PropertyType\n header: $PropertyType\n maxCount: $PropertyType\n rotate: $PropertyType\n placement: $PropertyType\n itemOptions: DropdownItemOptions\n _el: ?HTMLUListElement\n\n static createElement(): HTMLUListElement {\n const el = document.createElement(\"ul\")\n const style = el.style\n style.display = \"none\"\n style.position = \"absolute\"\n style.zIndex = \"10000\"\n const body = document.body\n if (body) {\n body.appendChild(el)\n }\n return el\n }\n\n constructor(options: DropdownOptions) {\n super()\n this.shown = false\n this.items = []\n this.activeItem = null\n this.footer = options.footer\n this.header = options.header\n this.maxCount = options.maxCount || 10\n this.el.className = options.className || DEFAULT_CLASS_NAME\n this.rotate = options.hasOwnProperty(\"rotate\") ? options.rotate : true\n this.placement = options.placement\n this.itemOptions = options.item || {}\n const style = options.style\n if (style) {\n Object.keys(style).forEach(key => {\n ;(this.el.style: any)[key] = style[key]\n })\n }\n }\n\n /**\n * @return {this}\n */\n destroy() {\n const parentNode = this.el.parentNode\n if (parentNode) {\n parentNode.removeChild(this.el)\n }\n this.clear()._el = null\n return this\n }\n\n get el(): HTMLUListElement {\n if (!this._el) {\n this._el = Dropdown.createElement()\n }\n return this._el\n }\n\n /**\n * Render the given data as dropdown items.\n *\n * @return {this}\n */\n render(searchResults: SearchResult[], cursorOffset: CursorOffset) {\n const renderEvent = createCustomEvent(\"render\", { cancelable: true })\n this.emit(\"render\", renderEvent)\n if (renderEvent.defaultPrevented) {\n return this\n }\n const rawResults = searchResults.map(searchResult => searchResult.data)\n const dropdownItems = searchResults\n .slice(0, this.maxCount || searchResults.length)\n .map(searchResult => new DropdownItem(searchResult, this.itemOptions))\n this.clear()\n .setStrategyId(searchResults[0])\n .renderEdge(rawResults, \"header\")\n .append(dropdownItems)\n .renderEdge(rawResults, \"footer\")\n .show()\n .setOffset(cursorOffset)\n this.emit(\"rendered\", createCustomEvent(\"rendered\"))\n return this\n }\n\n /**\n * Hide the dropdown then sweep out items.\n *\n * @return {this}\n */\n deactivate() {\n return this.hide().clear()\n }\n\n /**\n * @return {this}\n */\n select(dropdownItem: DropdownItem) {\n const detail = { searchResult: dropdownItem.searchResult }\n const selectEvent = createCustomEvent(\"select\", {\n cancelable: true,\n detail: detail,\n })\n this.emit(\"select\", selectEvent)\n if (selectEvent.defaultPrevented) {\n return this\n }\n this.deactivate()\n this.emit(\"selected\", createCustomEvent(\"selected\", { detail }))\n return this\n }\n\n /**\n * @return {this}\n */\n up(e: CustomEvent) {\n return this.shown ? this.moveActiveItem(\"prev\", e) : this\n }\n\n /**\n * @return {this}\n */\n down(e: CustomEvent) {\n return this.shown ? this.moveActiveItem(\"next\", e) : this\n }\n\n /**\n * Retrieve the active item.\n */\n getActiveItem(): DropdownItem | null {\n return this.activeItem\n }\n\n /**\n * Add items to dropdown.\n *\n * @private\n */\n append(items: DropdownItem[]) {\n const fragment = document.createDocumentFragment()\n items.forEach(item => {\n this.items.push(item)\n item.appended(this)\n fragment.appendChild(item.el)\n })\n this.el.appendChild(fragment)\n return this\n }\n\n /** @private */\n setOffset(cursorOffset: CursorOffset) {\n const doc = document.documentElement\n if (doc) {\n const elementWidth = this.el.offsetWidth\n if (cursorOffset.left) {\n const browserWidth = doc.clientWidth\n if (cursorOffset.left + elementWidth > browserWidth) {\n cursorOffset.left = browserWidth - elementWidth\n }\n this.el.style.left = `${cursorOffset.left}px`\n } else if (cursorOffset.right) {\n if (cursorOffset.right - elementWidth < 0) {\n cursorOffset.right = 0\n }\n this.el.style.right = `${cursorOffset.right}px`\n }\n if (this.isPlacementTop()) {\n this.el.style.bottom = `${doc.clientHeight -\n cursorOffset.top +\n cursorOffset.lineHeight}px`\n } else {\n this.el.style.top = `${cursorOffset.top}px`\n }\n }\n return this\n }\n\n /**\n * Show the element.\n *\n * @private\n */\n show() {\n if (!this.shown) {\n const showEvent = createCustomEvent(\"show\", { cancelable: true })\n this.emit(\"show\", showEvent)\n if (showEvent.defaultPrevented) {\n return this\n }\n this.el.style.display = \"block\"\n this.shown = true\n this.emit(\"shown\", createCustomEvent(\"shown\"))\n }\n return this\n }\n\n /**\n * Hide the element.\n *\n * @private\n */\n hide() {\n if (this.shown) {\n const hideEvent = createCustomEvent(\"hide\", { cancelable: true })\n this.emit(\"hide\", hideEvent)\n if (hideEvent.defaultPrevented) {\n return this\n }\n this.el.style.display = \"none\"\n this.shown = false\n this.emit(\"hidden\", createCustomEvent(\"hidden\"))\n }\n return this\n }\n\n /**\n * Clear search results.\n *\n * @private\n */\n clear() {\n this.el.innerHTML = \"\"\n this.items.forEach(item => item.destroy())\n this.items = []\n return this\n }\n\n /** @private */\n moveActiveItem(direction: \"next\" | \"prev\", e: CustomEvent) {\n const nextActiveItem =\n direction === \"next\"\n ? this.activeItem ? this.activeItem.next : this.items[0]\n : this.activeItem\n ? this.activeItem.prev\n : this.items[this.items.length - 1]\n if (nextActiveItem) {\n nextActiveItem.activate()\n e.preventDefault()\n }\n return this\n }\n\n /** @private */\n setStrategyId(searchResult: ?SearchResult) {\n const strategyId = searchResult && searchResult.strategy.props.id\n if (strategyId) {\n this.el.setAttribute(\"data-strategy\", strategyId)\n } else {\n this.el.removeAttribute(\"data-strategy\")\n }\n return this\n }\n\n /**\n * @private\n * @param {object[]} rawResults - What callbacked by search function.\n */\n renderEdge(rawResults: Object[], type: \"header\" | \"footer\") {\n const source = (type === \"header\" ? this.header : this.footer) || \"\"\n const content: any =\n typeof source === \"function\" ? source(rawResults) : source\n const li = document.createElement(\"li\")\n li.classList.add(`textcomplete-${type}`)\n li.innerHTML = content\n this.el.appendChild(li)\n return this\n }\n\n /** @private */\n isPlacementTop() {\n return this.placement === \"top\"\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/dropdown.js","// @flow\n\nimport SearchResult from \"./search_result\"\n\nexport const DEFAULT_CLASS_NAME = \"textcomplete-item\"\nconst CALLBACK_METHODS = [\"onClick\", \"onMouseover\"]\n\n/** @typedef */\nexport type DropdownItemOptions = {\n className?: string,\n}\n\n// Declare interface instead of importing Dropdown itself to prevent circular dependency.\ninterface Dropdown {\n activeItem: DropdownItem | null;\n items: DropdownItem[];\n rotate: ?Boolean;\n getActiveItem(): DropdownItem | null;\n select(DropdownItem): DropdownItem;\n}\n\n/**\n * Encapsulate an item of dropdown.\n */\nexport default class DropdownItem {\n searchResult: SearchResult\n active: boolean\n className: string\n activeClassName: string\n siblings: DropdownItem[]\n dropdown: Dropdown\n index: number\n _el: ?HTMLLIElement\n\n constructor(searchResult: SearchResult, options: DropdownItemOptions) {\n this.searchResult = searchResult\n this.active = false\n this.className = options.className || DEFAULT_CLASS_NAME\n this.activeClassName = `${this.className} active`\n\n CALLBACK_METHODS.forEach(method => {\n ;(this: any)[method] = (this: any)[method].bind(this)\n })\n }\n\n get el(): HTMLLIElement {\n if (this._el) {\n return this._el\n }\n const li = document.createElement(\"li\")\n li.className = this.active ? this.activeClassName : this.className\n const a = document.createElement(\"a\")\n a.innerHTML = this.searchResult.render()\n li.appendChild(a)\n this._el = li\n li.addEventListener(\"mousedown\", this.onClick)\n li.addEventListener(\"mouseover\", this.onMouseover)\n li.addEventListener(\"touchstart\", this.onClick)\n return li\n }\n\n /**\n * Try to free resources and perform other cleanup operations.\n */\n destroy() {\n this.el.removeEventListener(\"mousedown\", this.onClick, false)\n this.el.removeEventListener(\"mouseover\", this.onMouseover, false)\n this.el.removeEventListener(\"touchstart\", this.onClick, false)\n if (this.active) {\n this.dropdown.activeItem = null\n }\n // This element has already been removed by {@link Dropdown#clear}.\n this._el = null\n }\n\n /**\n * Callbacked when it is appended to a dropdown.\n *\n * @see Dropdown#append\n */\n appended(dropdown: Dropdown) {\n this.dropdown = dropdown\n this.siblings = dropdown.items\n this.index = this.siblings.length - 1\n }\n\n /**\n * Deactivate active item then activate itself.\n *\n * @return {this}\n */\n activate() {\n if (!this.active) {\n const activeItem = this.dropdown.getActiveItem()\n if (activeItem) {\n activeItem.deactivate()\n }\n this.dropdown.activeItem = this\n this.active = true\n this.el.className = this.activeClassName\n }\n return this\n }\n\n /**\n * Get the next sibling.\n */\n get next(): ?DropdownItem {\n let nextIndex\n if (this.index === this.siblings.length - 1) {\n if (!this.dropdown.rotate) {\n return null\n }\n nextIndex = 0\n } else {\n nextIndex = this.index + 1\n }\n return this.siblings[nextIndex]\n }\n\n /**\n * Get the previous sibling.\n */\n get prev(): ?DropdownItem {\n let nextIndex\n if (this.index === 0) {\n if (!this.dropdown.rotate) {\n return null\n }\n nextIndex = this.siblings.length - 1\n } else {\n nextIndex = this.index - 1\n }\n return this.siblings[nextIndex]\n }\n\n /** @private */\n deactivate() {\n if (this.active) {\n this.active = false\n this.el.className = this.className\n this.dropdown.activeItem = null\n }\n return this\n }\n\n /** @private */\n onClick(e: Event) {\n e.preventDefault() // Prevent blur event\n this.dropdown.select(this)\n }\n\n /** @private */\n onMouseover() {\n this.activate()\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/dropdown_item.js","// @flow\n\nimport update from \"undate/lib/update\"\n\nimport Editor from \"./editor\"\nimport { calculateElementOffset, getLineHeightPx } from \"./utils\"\nimport SearchResult from \"./search_result\"\n\nconst getCaretCoordinates = require(\"textarea-caret\")\n\nconst CALLBACK_METHODS = [\"onInput\", \"onKeydown\"]\n\n/**\n * Encapsulate the target textarea element.\n */\nexport default class Textarea extends Editor {\n el: HTMLTextAreaElement\n\n /**\n * @param {HTMLTextAreaElement} el - Where the textcomplete works on.\n */\n constructor(el: HTMLTextAreaElement) {\n super()\n this.el = el\n\n CALLBACK_METHODS.forEach(method => {\n ;(this: any)[method] = (this: any)[method].bind(this)\n })\n\n this.startListening()\n }\n\n /**\n * @return {this}\n */\n destroy() {\n super.destroy()\n this.stopListening()\n // Release the element reference early to help garbage collection.\n ;(this: any).el = null\n return this\n }\n\n /**\n * Implementation for {@link Editor#applySearchResult}\n */\n applySearchResult(searchResult: SearchResult) {\n const before = this.getBeforeCursor()\n if (before != null) {\n const replace = searchResult.replace(before, this.getAfterCursor())\n this.el.focus() // Clicking a dropdown item removes focus from the element.\n if (Array.isArray(replace)) {\n update(this.el, replace[0], replace[1])\n this.el.dispatchEvent(new Event(\"input\"))\n }\n }\n }\n\n /**\n * Implementation for {@link Editor#getCursorOffset}\n */\n getCursorOffset() {\n const elOffset = calculateElementOffset(this.el)\n const elScroll = this.getElScroll()\n const cursorPosition = this.getCursorPosition()\n const lineHeight = getLineHeightPx(this.el)\n const top = elOffset.top - elScroll.top + cursorPosition.top + lineHeight\n const left = elOffset.left - elScroll.left + cursorPosition.left\n if (this.el.dir !== \"rtl\") {\n return { top, left, lineHeight }\n } else {\n const right = document.documentElement\n ? document.documentElement.clientWidth - left\n : 0\n return { top, right, lineHeight }\n }\n }\n\n /**\n * Implementation for {@link Editor#getBeforeCursor}\n */\n getBeforeCursor() {\n return this.el.selectionStart !== this.el.selectionEnd\n ? null\n : this.el.value.substring(0, this.el.selectionEnd)\n }\n\n /** @private */\n getAfterCursor() {\n return this.el.value.substring(this.el.selectionEnd)\n }\n\n /** @private */\n getElScroll(): { top: number, left: number } {\n return { top: this.el.scrollTop, left: this.el.scrollLeft }\n }\n\n /**\n * The input cursor's relative coordinates from the textarea's left\n * top corner.\n *\n * @private\n */\n getCursorPosition(): { top: number, left: number } {\n return getCaretCoordinates(this.el, this.el.selectionEnd)\n }\n\n /** @private */\n onInput() {\n this.emitChangeEvent()\n }\n\n /** @private */\n onKeydown(e: KeyboardEvent) {\n const code = this.getCode(e)\n let event\n if (code === \"UP\" || code === \"DOWN\") {\n event = this.emitMoveEvent(code)\n } else if (code === \"ENTER\") {\n event = this.emitEnterEvent()\n } else if (code === \"ESC\") {\n event = this.emitEscEvent()\n }\n if (event && event.defaultPrevented) {\n e.preventDefault()\n }\n }\n\n /** @private */\n startListening() {\n this.el.addEventListener(\"input\", this.onInput)\n this.el.addEventListener(\"keydown\", this.onKeydown)\n }\n\n /** @private */\n stopListening() {\n this.el.removeEventListener(\"input\", this.onInput)\n this.el.removeEventListener(\"keydown\", this.onKeydown)\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/textarea.js","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nexports.default = function (el, headToCursor, cursorToTail) {\n var curr = el.value,\n // strA + strB1 + strC\n next = headToCursor + (cursorToTail || ''),\n // strA + strB2 + strC\n activeElement = document.activeElement;\n\n // Calculate length of strA and strC\n var aLength = 0,\n cLength = 0;\n while (aLength < curr.length && aLength < next.length && curr[aLength] === next[aLength]) {\n aLength++;\n }\n while (curr.length - cLength - 1 >= 0 && next.length - cLength - 1 >= 0 && curr[curr.length - cLength - 1] === next[next.length - cLength - 1]) {\n cLength++;\n }\n aLength = Math.min(aLength, Math.min(curr.length, next.length) - cLength);\n\n // Select strB1\n el.setSelectionRange(aLength, curr.length - cLength);\n\n // Get strB2\n var strB2 = next.substring(aLength, next.length - cLength);\n\n // Replace strB1 with strB2\n el.focus();\n if (!document.execCommand('insertText', false, strB2)) {\n // Document.execCommand returns false if the command is not supported.\n // Firefox and IE returns false in this case.\n el.value = next;\n el.dispatchEvent(createInputEvent());\n }\n\n // Move cursor to the end of headToCursor\n el.setSelectionRange(headToCursor.length, headToCursor.length);\n\n activeElement && activeElement.focus();\n return el;\n};\n\nfunction createInputEvent() {\n if (typeof Event !== \"undefined\") {\n return new Event(\"input\", { bubbles: true, cancelable: true });\n } else {\n var event = document.createEvent(\"Event\");\n event.initEvent(\"input\", true, true);\n return event;\n }\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/undate/lib/update.js\n// module id = 13\n// module chunks = 0","/* jshint browser: true */\n\n(function () {\n\n// The properties that we copy into a mirrored div.\n// Note that some browsers, such as Firefox,\n// do not concatenate properties, i.e. padding-top, bottom etc. -> padding,\n// so we have to do every single property specifically.\nvar properties = [\n 'direction', // RTL support\n 'boxSizing',\n 'width', // on Chrome and IE, exclude the scrollbar, so the mirror div wraps exactly as the textarea does\n 'height',\n 'overflowX',\n 'overflowY', // copy the scrollbar for IE\n\n 'borderTopWidth',\n 'borderRightWidth',\n 'borderBottomWidth',\n 'borderLeftWidth',\n 'borderStyle',\n\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n\n // https://developer.mozilla.org/en-US/docs/Web/CSS/font\n 'fontStyle',\n 'fontVariant',\n 'fontWeight',\n 'fontStretch',\n 'fontSize',\n 'fontSizeAdjust',\n 'lineHeight',\n 'fontFamily',\n\n 'textAlign',\n 'textTransform',\n 'textIndent',\n 'textDecoration', // might not make a difference, but better be safe\n\n 'letterSpacing',\n 'wordSpacing',\n\n 'tabSize',\n 'MozTabSize'\n\n];\n\nvar isBrowser = (typeof window !== 'undefined');\nvar isFirefox = (isBrowser && window.mozInnerScreenX != null);\n\nfunction getCaretCoordinates(element, position, options) {\n if(!isBrowser) {\n throw new Error('textarea-caret-position#getCaretCoordinates should only be called in a browser');\n }\n\n var debug = options && options.debug || false;\n if (debug) {\n var el = document.querySelector('#input-textarea-caret-position-mirror-div');\n if ( el ) { el.parentNode.removeChild(el); }\n }\n\n // mirrored div\n var div = document.createElement('div');\n div.id = 'input-textarea-caret-position-mirror-div';\n document.body.appendChild(div);\n\n var style = div.style;\n var computed = window.getComputedStyle? getComputedStyle(element) : element.currentStyle; // currentStyle for IE < 9\n\n // default textarea styles\n style.whiteSpace = 'pre-wrap';\n if (element.nodeName !== 'INPUT')\n style.wordWrap = 'break-word'; // only for textarea-s\n\n // position off-screen\n style.position = 'absolute'; // required to return coordinates properly\n if (!debug)\n style.visibility = 'hidden'; // not 'display: none' because we want rendering\n\n // transfer the element's properties to the div\n properties.forEach(function (prop) {\n style[prop] = computed[prop];\n });\n\n if (isFirefox) {\n // Firefox lies about the overflow property for textareas: https://bugzilla.mozilla.org/show_bug.cgi?id=984275\n if (element.scrollHeight > parseInt(computed.height))\n style.overflowY = 'scroll';\n } else {\n style.overflow = 'hidden'; // for Chrome to not render a scrollbar; IE keeps overflowY = 'scroll'\n }\n\n div.textContent = element.value.substring(0, position);\n // the second special handling for input type=\"text\" vs textarea: spaces need to be replaced with non-breaking spaces - http://stackoverflow.com/a/13402035/1269037\n if (element.nodeName === 'INPUT')\n div.textContent = div.textContent.replace(/\\s/g, '\\u00a0');\n\n var span = document.createElement('span');\n // Wrapping must be replicated *exactly*, including when a long word gets\n // onto the next line, with whitespace at the end of the line before (#7).\n // The *only* reliable way to do that is to copy the *entire* rest of the\n // textarea's content into the created at the caret position.\n // for inputs, just '.' would be enough, but why bother?\n span.textContent = element.value.substring(position) || '.'; // || because a completely empty faux span doesn't render at all\n div.appendChild(span);\n\n var coordinates = {\n top: span.offsetTop + parseInt(computed['borderTopWidth']),\n left: span.offsetLeft + parseInt(computed['borderLeftWidth'])\n };\n\n if (debug) {\n span.style.backgroundColor = '#aaa';\n } else {\n document.body.removeChild(div);\n }\n\n return coordinates;\n}\n\nif (typeof module != 'undefined' && typeof module.exports != 'undefined') {\n module.exports = getCaretCoordinates;\n} else if(isBrowser){\n window.getCaretCoordinates = getCaretCoordinates;\n}\n\n}());\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/textarea-caret/index.js\n// module id = 14\n// module chunks = 0"],"sourceRoot":""} \ No newline at end of file diff --git a/library/textcomplete/textcomplete.min.js b/library/textcomplete/textcomplete.min.js new file mode 100644 index 000000000..717a2c905 --- /dev/null +++ b/library/textcomplete/textcomplete.min.js @@ -0,0 +1,2 @@ +!function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=5)}([function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n=s&&e<=a}function i(e){var t=window.getComputedStyle(e);return r(t.lineHeight.charCodeAt(0))?r(t.lineHeight.charCodeAt(t.lineHeight.length-1))?parseFloat(t.lineHeight)*parseFloat(t.fontSize):parseFloat(t.lineHeight):o(e.nodeName,t)}function o(e,t){var n=document.body;if(!n)return 0;var r=document.createElement(e);r.innerHTML=" ",r.style.fontSize=t.fontSize,r.style.fontFamily=t.fontFamily,r.style.padding="0",n.appendChild(r),r instanceof HTMLTextAreaElement&&(r.rows=1);var i=r.offsetHeight;return n.removeChild(r),i}Object.defineProperty(t,"__esModule",{value:!0}),t.calculateElementOffset=n,t.getLineHeightPx=i,t.calculateLineHeightPx=o;var s=(t.createCustomEvent=function(){return"function"==typeof window.CustomEvent?function(e,t){return new document.defaultView.CustomEvent(e,{cancelable:t&&t.cancelable||!1,detail:t&&t.detail||void 0})}:function(e,t){var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,!1,t&&t.cancelable||!1,t&&t.detail||void 0),n}}(),"0".charCodeAt(0)),a="9".charCodeAt(0)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};i(this,t);var r=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return r.completer=new l.default,r.isQueryInFlight=!1,r.nextPendingQuery=null,r.dropdown=new f.default(n.dropdown||{}),r.editor=e,r.options=n,g.forEach(function(e){r[e]=r[e].bind(r)}),r.startListening(),r}return s(t,e),a(t,[{key:"destroy",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.completer.destroy(),this.dropdown.destroy(),e&&this.editor.destroy(),this.stopListening(),this}},{key:"hide",value:function(){return this.dropdown.deactivate(),this}},{key:"register",value:function(e){var t=this;return e.forEach(function(e){t.completer.registerStrategy(new v.default(e))}),this}},{key:"trigger",value:function(e){return this.isQueryInFlight?this.nextPendingQuery=e:(this.isQueryInFlight=!0,this.nextPendingQuery=null,this.completer.run(e)),this}},{key:"handleHit",value:function(e){var t=e.searchResults;t.length?this.dropdown.render(t,this.editor.getCursorOffset()):this.dropdown.deactivate(),this.isQueryInFlight=!1,null!==this.nextPendingQuery&&this.trigger(this.nextPendingQuery)}},{key:"handleMove",value:function(e){"UP"===e.detail.code?this.dropdown.up(e):this.dropdown.down(e)}},{key:"handleEnter",value:function(e){var t=this.dropdown.getActiveItem();t?(this.dropdown.select(t),e.preventDefault()):this.dropdown.deactivate()}},{key:"handleEsc",value:function(e){this.dropdown.shown&&(this.dropdown.deactivate(),e.preventDefault())}},{key:"handleChange",value:function(e){null!=e.detail.beforeCursor?this.trigger(e.detail.beforeCursor):this.dropdown.deactivate()}},{key:"handleSelect",value:function(e){this.emit("select",e),e.defaultPrevented||this.editor.applySearchResult(e.detail.searchResult)}},{key:"startListening",value:function(){var e=this;this.editor.on("move",this.handleMove).on("enter",this.handleEnter).on("esc",this.handleEsc).on("change",this.handleChange),this.dropdown.on("select",this.handleSelect),["show","shown","render","rendered","selected","hidden","hide"].forEach(function(t){e.dropdown.on(t,function(){return e.emit(t)})}),this.completer.on("hit",this.handleHit)}},{key:"stopListening",value:function(){this.completer.removeAllListeners(),this.dropdown.removeAllListeners(),this.editor.removeListener("move",this.handleMove).removeListener("enter",this.handleEnter).removeListener("esc",this.handleEsc).removeListener("change",this.handleChange)}}]),t}(m.default);t.default=b},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;nr&&(e.left=r-n),this.el.style.left=e.left+"px"}else e.right&&(e.right-n<0&&(e.right=0),this.el.style.right=e.right+"px");this.isPlacementTop()?this.el.style.bottom=t.clientHeight-e.top+e.lineHeight+"px":this.el.style.top=e.top+"px"}return this}},{key:"show",value:function(){if(!this.shown){var e=(0,d.createCustomEvent)("show",{cancelable:!0});if(this.emit("show",e),e.defaultPrevented)return this;this.el.style.display="block",this.shown=!0,this.emit("shown",(0,d.createCustomEvent)("shown"))}return this}},{key:"hide",value:function(){if(this.shown){var e=(0,d.createCustomEvent)("hide",{cancelable:!0});if(this.emit("hide",e),e.defaultPrevented)return this;this.el.style.display="none",this.shown=!1,this.emit("hidden",(0,d.createCustomEvent)("hidden"))}return this}},{key:"clear",value:function(){return this.el.innerHTML="",this.items.forEach(function(e){return e.destroy()}),this.items=[],this}},{key:"moveActiveItem",value:function(e,t){var n="next"===e?this.activeItem?this.activeItem.next:this.items[0]:this.activeItem?this.activeItem.prev:this.items[this.items.length-1];return n&&(n.activate(),t.preventDefault()),this}},{key:"setStrategyId",value:function(e){var t=e&&e.strategy.props.id;return t?this.el.setAttribute("data-strategy",t):this.el.removeAttribute("data-strategy"),this}},{key:"renderEdge",value:function(e,t){var n=("header"===t?this.header:this.footer)||"",r="function"==typeof n?n(e):n,i=document.createElement("li");return i.classList.add("textcomplete-"+t),i.innerHTML=r,this.el.appendChild(i),this}},{key:"isPlacementTop",value:function(){return"top"===this.placement}},{key:"el",get:function(){return this._el||(this._el=t.createElement()),this._el}}]),t}(l.default);t.default=p},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_CLASS_NAME=void 0;var i=function(){function e(e,t){for(var n=0;n=0&&o.length-u-1>=0&&i[i.length-u-1]===o[o.length-u-1];)u++;a=Math.min(a,Math.min(i.length,o.length)-u),e.setSelectionRange(a,i.length-u);var l=o.substring(a,o.length-u);return e.focus(),document.execCommand("insertText",!1,l)||(e.value=o,e.dispatchEvent(n())),e.setSelectionRange(t.length,t.length),s&&s.focus(),e}},function(e){!function(){function t(e,t,o){if(!r)throw new Error("textarea-caret-position#getCaretCoordinates should only be called in a browser");var s=o&&o.debug||!1;if(s){var a=document.querySelector("#input-textarea-caret-position-mirror-div");a&&a.parentNode.removeChild(a)}var u=document.createElement("div");u.id="input-textarea-caret-position-mirror-div",document.body.appendChild(u);var l=u.style,c=window.getComputedStyle?getComputedStyle(e):e.currentStyle;l.whiteSpace="pre-wrap","INPUT"!==e.nodeName&&(l.wordWrap="break-word"),l.position="absolute",s||(l.visibility="hidden"),n.forEach(function(e){l[e]=c[e]}),i?e.scrollHeight>parseInt(c.height)&&(l.overflowY="scroll"):l.overflow="hidden",u.textContent=e.value.substring(0,t),"INPUT"===e.nodeName&&(u.textContent=u.textContent.replace(/\s/g," "));var h=document.createElement("span");h.textContent=e.value.substring(t)||".",u.appendChild(h);var f={top:h.offsetTop+parseInt(c.borderTopWidth),left:h.offsetLeft+parseInt(c.borderLeftWidth)};return s?h.style.backgroundColor="#aaa":document.body.removeChild(u),f}var n=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize","MozTabSize"],r="undefined"!=typeof window,i=r&&null!=window.mozInnerScreenX;void 0!==e&&void 0!==e.exports?e.exports=t:r&&(window.getCaretCoordinates=t)}()}]); +//# sourceMappingURL=textcomplete.min.js.map \ No newline at end of file diff --git a/library/textcomplete/textcomplete.min.js.map b/library/textcomplete/textcomplete.min.js.map new file mode 100644 index 000000000..435675297 --- /dev/null +++ b/library/textcomplete/textcomplete.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///textcomplete.min.js","webpack:///webpack/bootstrap 5fdd342a07201b673919","webpack:///./src/search_result.js","webpack:///./node_modules/eventemitter3/index.js","webpack:///./src/strategy.js","webpack:///./src/utils.js","webpack:///./src/editor.js","webpack:///./src/main.js","webpack:///(webpack)/buildin/global.js","webpack:///./src/textcomplete.js","webpack:///./src/completer.js","webpack:///./src/query.js","webpack:///./src/dropdown.js","webpack:///./src/dropdown_item.js","webpack:///./src/textarea.js","webpack:///./node_modules/undate/lib/update.js","webpack:///./node_modules/textarea-caret/index.js"],"names":["modules","__webpack_require__","moduleId","installedModules","exports","module","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","_classCallCheck","instance","Constructor","TypeError","value","_createClass","defineProperties","target","props","length","descriptor","writable","key","protoProps","staticProps","_strategy","SearchResult","obj","data","term","strategy","this","beforeCursor","afterCursor","replacement","replace","Array","isArray","match","matchText","_","p1","parseInt","slice","index","join","template","default","Events","EE","fn","context","once","EventEmitter","_events","_eventsCount","has","prefix","create","__proto__","eventNames","events","names","push","getOwnPropertySymbols","concat","listeners","event","exists","evt","available","ee","emit","a1","a2","a3","a4","a5","args","len","arguments","removeListener","undefined","apply","j","on","listener","removeAllListeners","off","addListener","setMaxListeners","prefixed","DEFAULT_TEMPLATE","Strategy","cache","callback","searchWithCache","search","_this","results","text","calculateElementOffset","el","rect","getBoundingClientRect","_el$ownerDocument","ownerDocument","defaultView","documentElement","offset","top","pageYOffset","left","pageXOffset","clientTop","clientLeft","isDigit","charCode","CHAR_CODE_ZERO","CHAR_CODE_NINE","getLineHeightPx","node","computedStyle","window","getComputedStyle","lineHeight","charCodeAt","parseFloat","fontSize","calculateLineHeightPx","nodeName","body","document","tempNode","createElement","innerHTML","style","fontFamily","padding","appendChild","HTMLTextAreaElement","rows","height","offsetHeight","removeChild","createCustomEvent","CustomEvent","type","options","cancelable","detail","createEvent","initCustomEvent","_interopRequireDefault","_possibleConstructorReturn","self","ReferenceError","_inherits","subClass","superClass","constructor","setPrototypeOf","_eventemitter","_eventemitter2","_utils","_search_result","Editor","_EventEmitter","getPrototypeOf","Error","code","moveEvent","enterEvent","changeEvent","getBeforeCursor","escEvent","e","keyCode","ctrlKey","global","_textcomplete","_textcomplete2","_textarea","_textarea2","editors","Textcomplete","Textarea","g","Function","eval","_completer","_completer2","_editor","_dropdown","_dropdown2","_strategy2","CALLBACK_METHODS","editor","completer","isQueryInFlight","nextPendingQuery","dropdown","forEach","method","bind","startListening","destroyEditor","destroy","stopListening","deactivate","strategyPropsArray","_this2","registerStrategy","run","_ref","searchResults","render","getCursorOffset","trigger","up","down","activeItem","getActiveItem","select","preventDefault","shown","selectEvent","defaultPrevented","applySearchResult","searchResult","_this3","handleMove","handleEnter","handleEsc","handleChange","handleSelect","eventName","handleHit","_query","_query2","Completer","strategies","query","extractQuery","execute","handleQueryResult","build","_search_result2","Query","map","result","_dropdown_item","_dropdown_item2","DEFAULT_CLASS_NAME","Dropdown","items","footer","header","maxCount","className","rotate","placement","itemOptions","item","keys","display","position","zIndex","parentNode","clear","_el","cursorOffset","renderEvent","rawResults","dropdownItems","setStrategyId","renderEdge","append","show","setOffset","hide","dropdownItem","moveActiveItem","fragment","createDocumentFragment","appended","doc","elementWidth","offsetWidth","browserWidth","clientWidth","right","isPlacementTop","bottom","clientHeight","showEvent","hideEvent","direction","nextActiveItem","next","prev","activate","strategyId","id","setAttribute","removeAttribute","source","content","li","classList","add","DropdownItem","active","activeClassName","removeEventListener","onClick","onMouseover","siblings","a","addEventListener","nextIndex","_get","receiver","desc","getOwnPropertyDescriptor","parent","_update","_update2","_editor2","getCaretCoordinates","_Editor","before","getAfterCursor","focus","dispatchEvent","Event","elOffset","elScroll","getElScroll","cursorPosition","getCursorPosition","dir","selectionStart","selectionEnd","substring","scrollTop","scrollLeft","emitChangeEvent","getCode","emitMoveEvent","emitEnterEvent","emitEscEvent","onInput","onKeydown","createInputEvent","bubbles","initEvent","headToCursor","cursorToTail","curr","activeElement","aLength","cLength","Math","min","setSelectionRange","strB2","execCommand","element","isBrowser","debug","querySelector","div","computed","currentStyle","whiteSpace","wordWrap","visibility","properties","prop","isFirefox","scrollHeight","overflowY","overflow","textContent","span","coordinates","offsetTop","offsetLeft","backgroundColor","mozInnerScreenX"],"mappings":"CAAS,SAAUA,GCInB,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAE,OAGA,IAAAC,GAAAF,EAAAD,IACAI,EAAAJ,EACAK,GAAA,EACAH,WAUA,OANAJ,GAAAE,GAAAM,KAAAH,EAAAD,QAAAC,IAAAD,QAAAH,GAGAI,EAAAE,GAAA,EAGAF,EAAAD,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A,WACAwG,IACA1O,EAAAiP,WAAA,UAGAC,EAAAhL,QAAA,SAAAiL,GACAnP,EAAAmP,GAAAN,EAAAM,KAGAC,EAEAZ,EAAAa,aAAAnV,SAAA2U,EAAAvO,UACAN,EAAAsP,UAAA,UAEAtP,EAAAuP,SAAA,SAGAX,EAAAY,YAAAhB,EAAAlW,MAAA0U,UAAA,EAAA9E,GAEA,UAAAsG,EAAA9O,WACAkP,EAAAY,YAAAZ,EAAAY,YAAA7V,QAAA,WAEA,IAAA8V,GAAA7P,SAAAE,cAAA,OAMA2P,GAAAD,YAAAhB,EAAAlW,MAAA0U,UAAA9E,IAAA,IACA0G,EAAAzO,YAAAsP,EAEA,IAAAC,IACApR,IAAAmR,EAAAE,UAAAzV,SAAA2U,EAAA,gBACArQ,KAAAiR,EAAAG,WAAA1V,SAAA2U,EAAA,iBASA,OANAH,GACAe,EAAAzP,MAAA6P,gBAAA,OAEAjQ,SAAAD,KAAAa,YAAAoO,GAGAc,EAhHA,GAAAR,IACA,YACA,YACA,QACA,SACA,YACA,YAEA,iBACA,mBACA,oBACA,kBACA,cAEA,aACA,eACA,gBACA,cAGA,YACA,cACA,aACA,cACA,WACA,iBACA,aACA,aAEA,YACA,gBACA,aACA,iBAEA,gBACA,cAEA,UACA,cAIAT,EAAA,mBAAAtP,QACAiQ,EAAAX,GAAA,MAAAtP,OAAA2Q,oBAwEA,KAAAnZ,OAAA,KAAAA,EAAAD,QACAC,EAAAD,QAAAuV,EACCwC,IACDtP,OAAA8M","file":"textcomplete.min.js","sourcesContent":["/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 5);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _strategy = __webpack_require__(2);\n\nvar _strategy2 = _interopRequireDefault(_strategy);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n/**\n * Encapsulate an result of each search results.\n */\nvar SearchResult = function () {\n\n /**\n * @param {object} data - An element of array callbacked by search function.\n */\n function SearchResult(data, term, strategy) {\n _classCallCheck(this, SearchResult);\n\n this.data = data;\n this.term = term;\n this.strategy = strategy;\n }\n\n _createClass(SearchResult, [{\n key: \"replace\",\n value: function replace(beforeCursor, afterCursor) {\n var replacement = this.strategy.replace(this.data);\n if (replacement !== null) {\n if (Array.isArray(replacement)) {\n afterCursor = replacement[1] + afterCursor;\n replacement = replacement[0];\n }\n var match = this.strategy.matchText(beforeCursor);\n if (match) {\n replacement = replacement.replace(/\\$&/g, match[0]).replace(/\\$(\\d)/g, function (_, p1) {\n return match[parseInt(p1, 10)];\n });\n return [[beforeCursor.slice(0, match.index), replacement, beforeCursor.slice(match.index + match[0].length)].join(\"\"), afterCursor];\n }\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n return this.strategy.template(this.data, this.term);\n }\n }]);\n\n return SearchResult;\n}();\n\nexports.default = SearchResult;\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar has = Object.prototype.hasOwnProperty\n , prefix = '~';\n\n/**\n * Constructor to create a storage for our `EE` objects.\n * An `Events` instance is a plain object whose properties are event names.\n *\n * @constructor\n * @api private\n */\nfunction Events() {}\n\n//\n// We try to not inherit from `Object.prototype`. In some engines creating an\n// instance in this way is faster than calling `Object.create(null)` directly.\n// If `Object.create(null)` is not supported we prefix the event names with a\n// character to make sure that the built-in object properties are not\n// overridden or used as an attack vector.\n//\nif (Object.create) {\n Events.prototype = Object.create(null);\n\n //\n // This hack is needed because the `__proto__` property is still inherited in\n // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.\n //\n if (!new Events().__proto__) prefix = false;\n}\n\n/**\n * Representation of a single event listener.\n *\n * @param {Function} fn The listener function.\n * @param {Mixed} context The context to invoke the listener with.\n * @param {Boolean} [once=false] Specify if the listener is a one-time listener.\n * @constructor\n * @api private\n */\nfunction EE(fn, context, once) {\n this.fn = fn;\n this.context = context;\n this.once = once || false;\n}\n\n/**\n * Minimal `EventEmitter` interface that is molded against the Node.js\n * `EventEmitter` interface.\n *\n * @constructor\n * @api public\n */\nfunction EventEmitter() {\n this._events = new Events();\n this._eventsCount = 0;\n}\n\n/**\n * Return an array listing the events for which the emitter has registered\n * listeners.\n *\n * @returns {Array}\n * @api public\n */\nEventEmitter.prototype.eventNames = function eventNames() {\n var names = []\n , events\n , name;\n\n if (this._eventsCount === 0) return names;\n\n for (name in (events = this._events)) {\n if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);\n }\n\n if (Object.getOwnPropertySymbols) {\n return names.concat(Object.getOwnPropertySymbols(events));\n }\n\n return names;\n};\n\n/**\n * Return the listeners registered for a given event.\n *\n * @param {String|Symbol} event The event name.\n * @param {Boolean} exists Only check if there are listeners.\n * @returns {Array|Boolean}\n * @api public\n */\nEventEmitter.prototype.listeners = function listeners(event, exists) {\n var evt = prefix ? prefix + event : event\n , available = this._events[evt];\n\n if (exists) return !!available;\n if (!available) return [];\n if (available.fn) return [available.fn];\n\n for (var i = 0, l = available.length, ee = new Array(l); i < l; i++) {\n ee[i] = available[i].fn;\n }\n\n return ee;\n};\n\n/**\n * Calls each of the listeners registered for a given event.\n *\n * @param {String|Symbol} event The event name.\n * @returns {Boolean} `true` if the event had listeners, else `false`.\n * @api public\n */\nEventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return false;\n\n var listeners = this._events[evt]\n , len = arguments.length\n , args\n , i;\n\n if (listeners.fn) {\n if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);\n\n switch (len) {\n case 1: return listeners.fn.call(listeners.context), true;\n case 2: return listeners.fn.call(listeners.context, a1), true;\n case 3: return listeners.fn.call(listeners.context, a1, a2), true;\n case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;\n case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;\n case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;\n }\n\n for (i = 1, args = new Array(len -1); i < len; i++) {\n args[i - 1] = arguments[i];\n }\n\n listeners.fn.apply(listeners.context, args);\n } else {\n var length = listeners.length\n , j;\n\n for (i = 0; i < length; i++) {\n if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);\n\n switch (len) {\n case 1: listeners[i].fn.call(listeners[i].context); break;\n case 2: listeners[i].fn.call(listeners[i].context, a1); break;\n case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;\n case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;\n default:\n if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {\n args[j - 1] = arguments[j];\n }\n\n listeners[i].fn.apply(listeners[i].context, args);\n }\n }\n }\n\n return true;\n};\n\n/**\n * Add a listener for a given event.\n *\n * @param {String|Symbol} event The event name.\n * @param {Function} fn The listener function.\n * @param {Mixed} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @api public\n */\nEventEmitter.prototype.on = function on(event, fn, context) {\n var listener = new EE(fn, context || this)\n , evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;\n else if (!this._events[evt].fn) this._events[evt].push(listener);\n else this._events[evt] = [this._events[evt], listener];\n\n return this;\n};\n\n/**\n * Add a one-time listener for a given event.\n *\n * @param {String|Symbol} event The event name.\n * @param {Function} fn The listener function.\n * @param {Mixed} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @api public\n */\nEventEmitter.prototype.once = function once(event, fn, context) {\n var listener = new EE(fn, context || this, true)\n , evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;\n else if (!this._events[evt].fn) this._events[evt].push(listener);\n else this._events[evt] = [this._events[evt], listener];\n\n return this;\n};\n\n/**\n * Remove the listeners of a given event.\n *\n * @param {String|Symbol} event The event name.\n * @param {Function} fn Only remove the listeners that match this function.\n * @param {Mixed} context Only remove the listeners that have this context.\n * @param {Boolean} once Only remove one-time listeners.\n * @returns {EventEmitter} `this`.\n * @api public\n */\nEventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return this;\n if (!fn) {\n if (--this._eventsCount === 0) this._events = new Events();\n else delete this._events[evt];\n return this;\n }\n\n var listeners = this._events[evt];\n\n if (listeners.fn) {\n if (\n listeners.fn === fn\n && (!once || listeners.once)\n && (!context || listeners.context === context)\n ) {\n if (--this._eventsCount === 0) this._events = new Events();\n else delete this._events[evt];\n }\n } else {\n for (var i = 0, events = [], length = listeners.length; i < length; i++) {\n if (\n listeners[i].fn !== fn\n || (once && !listeners[i].once)\n || (context && listeners[i].context !== context)\n ) {\n events.push(listeners[i]);\n }\n }\n\n //\n // Reset the array, or remove it completely if we have no more listeners.\n //\n if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;\n else if (--this._eventsCount === 0) this._events = new Events();\n else delete this._events[evt];\n }\n\n return this;\n};\n\n/**\n * Remove all listeners, or those of the specified event.\n *\n * @param {String|Symbol} [event] The event name.\n * @returns {EventEmitter} `this`.\n * @api public\n */\nEventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {\n var evt;\n\n if (event) {\n evt = prefix ? prefix + event : event;\n if (this._events[evt]) {\n if (--this._eventsCount === 0) this._events = new Events();\n else delete this._events[evt];\n }\n } else {\n this._events = new Events();\n this._eventsCount = 0;\n }\n\n return this;\n};\n\n//\n// Alias methods names because people roll like that.\n//\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\nEventEmitter.prototype.addListener = EventEmitter.prototype.on;\n\n//\n// This function doesn't apply anymore.\n//\nEventEmitter.prototype.setMaxListeners = function setMaxListeners() {\n return this;\n};\n\n//\n// Expose the prefix.\n//\nEventEmitter.prefixed = prefix;\n\n//\n// Allow `EventEmitter` to be imported as module namespace.\n//\nEventEmitter.EventEmitter = EventEmitter;\n\n//\n// Expose the module.\n//\nif (true) {\n module.exports = EventEmitter;\n}\n\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar DEFAULT_INDEX = 2;\n\nfunction DEFAULT_TEMPLATE(value) {\n return value;\n}\n\n/**\n * Properties for a strategy.\n *\n * @typedef\n */\n\n/**\n * Encapsulate a single strategy.\n */\nvar Strategy = function () {\n function Strategy(props) {\n _classCallCheck(this, Strategy);\n\n this.props = props;\n this.cache = props.cache ? {} : null;\n }\n\n /**\n * @return {this}\n */\n\n\n _createClass(Strategy, [{\n key: \"destroy\",\n value: function destroy() {\n this.cache = null;\n return this;\n }\n }, {\n key: \"search\",\n value: function search(term, callback, match) {\n if (this.cache) {\n this.searchWithCache(term, callback, match);\n } else {\n this.props.search(term, callback, match);\n }\n }\n\n /**\n * @param {object} data - An element of array callbacked by search function.\n */\n\n }, {\n key: \"replace\",\n value: function replace(data) {\n return this.props.replace(data);\n }\n\n /** @private */\n\n }, {\n key: \"searchWithCache\",\n value: function searchWithCache(term, callback, match) {\n var _this = this;\n\n if (this.cache && this.cache[term]) {\n callback(this.cache[term]);\n } else {\n this.props.search(term, function (results) {\n if (_this.cache) {\n _this.cache[term] = results;\n }\n callback(results);\n }, match);\n }\n }\n\n /** @private */\n\n }, {\n key: \"matchText\",\n value: function matchText(text) {\n if (typeof this.match === \"function\") {\n return this.match(text);\n } else {\n return text.match(this.match);\n }\n }\n\n /** @private */\n\n }, {\n key: \"match\",\n get: function get() {\n return this.props.match;\n }\n\n /** @private */\n\n }, {\n key: \"index\",\n get: function get() {\n return typeof this.props.index === \"number\" ? this.props.index : DEFAULT_INDEX;\n }\n }, {\n key: \"template\",\n get: function get() {\n return this.props.template || DEFAULT_TEMPLATE;\n }\n }]);\n\n return Strategy;\n}();\n\nexports.default = Strategy;\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.calculateElementOffset = calculateElementOffset;\nexports.getLineHeightPx = getLineHeightPx;\nexports.calculateLineHeightPx = calculateLineHeightPx;\n\n\n/**\n * Create a custom event\n *\n * @private\n */\nvar createCustomEvent = exports.createCustomEvent = function () {\n if (typeof window.CustomEvent === \"function\") {\n return function (type, options) {\n return new document.defaultView.CustomEvent(type, {\n cancelable: options && options.cancelable || false,\n detail: options && options.detail || undefined\n });\n };\n } else {\n // Custom event polyfill from\n // https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#polyfill\n return function (type, options) {\n var event = document.createEvent(\"CustomEvent\");\n event.initCustomEvent(type,\n /* bubbles */false, options && options.cancelable || false, options && options.detail || undefined);\n return event;\n };\n }\n}\n\n/**\n * Get the current coordinates of the `el` relative to the document.\n *\n * @private\n */\n();function calculateElementOffset(el) {\n var rect = el.getBoundingClientRect();\n var _el$ownerDocument = el.ownerDocument,\n defaultView = _el$ownerDocument.defaultView,\n documentElement = _el$ownerDocument.documentElement;\n\n var offset = {\n top: rect.top + defaultView.pageYOffset,\n left: rect.left + defaultView.pageXOffset\n };\n if (documentElement) {\n offset.top -= documentElement.clientTop;\n offset.left -= documentElement.clientLeft;\n }\n return offset;\n}\n\nvar CHAR_CODE_ZERO = \"0\".charCodeAt(0);\nvar CHAR_CODE_NINE = \"9\".charCodeAt(0);\n\nfunction isDigit(charCode) {\n return charCode >= CHAR_CODE_ZERO && charCode <= CHAR_CODE_NINE;\n}\n\n/**\n * Returns the line-height of the given node in pixels.\n *\n * @private\n */\nfunction getLineHeightPx(node) {\n var computedStyle = window.getComputedStyle(node\n\n // If the char code starts with a digit, it is either a value in pixels,\n // or unitless, as per:\n // https://drafts.csswg.org/css2/visudet.html#propdef-line-height\n // https://drafts.csswg.org/css2/cascade.html#computed-value\n );if (isDigit(computedStyle.lineHeight.charCodeAt(0))) {\n // In real browsers the value is *always* in pixels, even for unit-less\n // line-heights. However, we still check as per the spec.\n if (isDigit(computedStyle.lineHeight.charCodeAt(computedStyle.lineHeight.length - 1))) {\n return parseFloat(computedStyle.lineHeight) * parseFloat(computedStyle.fontSize);\n } else {\n return parseFloat(computedStyle.lineHeight);\n }\n }\n\n // Otherwise, the value is \"normal\".\n // If the line-height is \"normal\", calculate by font-size\n return calculateLineHeightPx(node.nodeName, computedStyle);\n}\n\n/**\n * Returns calculated line-height of the given node in pixels.\n *\n * @private\n */\nfunction calculateLineHeightPx(nodeName, computedStyle) {\n var body = document.body;\n if (!body) {\n return 0;\n }\n\n var tempNode = document.createElement(nodeName);\n tempNode.innerHTML = \" \";\n tempNode.style.fontSize = computedStyle.fontSize;\n tempNode.style.fontFamily = computedStyle.fontFamily;\n tempNode.style.padding = \"0\";\n body.appendChild(tempNode\n\n // Make sure textarea has only 1 row\n );if (tempNode instanceof HTMLTextAreaElement) {\n ;tempNode.rows = 1;\n }\n\n // Assume the height of the element is the line-height\n var height = tempNode.offsetHeight;\n body.removeChild(tempNode);\n\n return height;\n}\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _eventemitter = __webpack_require__(1);\n\nvar _eventemitter2 = _interopRequireDefault(_eventemitter);\n\nvar _utils = __webpack_require__(3);\n\nvar _search_result = __webpack_require__(0);\n\nvar _search_result2 = _interopRequireDefault(_search_result);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n/*eslint no-unused-vars: off*/\n\n/**\n * Abstract class representing a editor target.\n *\n * Editor classes must implement `#applySearchResult`, `#getCursorOffset` and\n * `#getBeforeCursor` methods.\n *\n * Editor classes must invoke `#emitMoveEvent`, `#emitEnterEvent`,\n * `#emitChangeEvent` and `#emitEscEvent` at proper timing.\n *\n * @abstract\n */\n\n\n/** @typedef */\nvar Editor = function (_EventEmitter) {\n _inherits(Editor, _EventEmitter);\n\n function Editor() {\n _classCallCheck(this, Editor);\n\n return _possibleConstructorReturn(this, (Editor.__proto__ || Object.getPrototypeOf(Editor)).apply(this, arguments));\n }\n\n _createClass(Editor, [{\n key: \"destroy\",\n\n /**\n * It is called when associated textcomplete object is destroyed.\n *\n * @return {this}\n */\n value: function destroy() {\n return this;\n }\n\n /**\n * It is called when a search result is selected by a user.\n */\n\n }, {\n key: \"applySearchResult\",\n value: function applySearchResult(_) {\n throw new Error(\"Not implemented.\");\n }\n\n /**\n * The input cursor's absolute coordinates from the window's left\n * top corner.\n */\n\n }, {\n key: \"getCursorOffset\",\n value: function getCursorOffset() {\n throw new Error(\"Not implemented.\");\n }\n\n /**\n * Editor string value from head to cursor.\n * Returns null if selection type is range not cursor.\n */\n\n }, {\n key: \"getBeforeCursor\",\n value: function getBeforeCursor() {\n throw new Error(\"Not implemented.\");\n }\n\n /**\n * Emit a move event, which moves active dropdown element.\n * Child class must call this method at proper timing with proper parameter.\n *\n * @see {@link Textarea} for live example.\n */\n\n }, {\n key: \"emitMoveEvent\",\n value: function emitMoveEvent(code) {\n var moveEvent = (0, _utils.createCustomEvent)(\"move\", {\n cancelable: true,\n detail: {\n code: code\n }\n });\n this.emit(\"move\", moveEvent);\n return moveEvent;\n }\n\n /**\n * Emit a enter event, which selects current search result.\n * Child class must call this method at proper timing.\n *\n * @see {@link Textarea} for live example.\n */\n\n }, {\n key: \"emitEnterEvent\",\n value: function emitEnterEvent() {\n var enterEvent = (0, _utils.createCustomEvent)(\"enter\", { cancelable: true });\n this.emit(\"enter\", enterEvent);\n return enterEvent;\n }\n\n /**\n * Emit a change event, which triggers auto completion.\n * Child class must call this method at proper timing.\n *\n * @see {@link Textarea} for live example.\n */\n\n }, {\n key: \"emitChangeEvent\",\n value: function emitChangeEvent() {\n var changeEvent = (0, _utils.createCustomEvent)(\"change\", {\n detail: {\n beforeCursor: this.getBeforeCursor()\n }\n });\n this.emit(\"change\", changeEvent);\n return changeEvent;\n }\n\n /**\n * Emit a esc event, which hides dropdown element.\n * Child class must call this method at proper timing.\n *\n * @see {@link Textarea} for live example.\n */\n\n }, {\n key: \"emitEscEvent\",\n value: function emitEscEvent() {\n var escEvent = (0, _utils.createCustomEvent)(\"esc\", { cancelable: true });\n this.emit(\"esc\", escEvent);\n return escEvent;\n }\n\n /**\n * Helper method for parsing KeyboardEvent.\n *\n * @see {@link Textarea} for live example.\n */\n\n }, {\n key: \"getCode\",\n value: function getCode(e) {\n return e.keyCode === 9 ? \"ENTER\" // tab\n : e.keyCode === 13 ? \"ENTER\" // enter\n : e.keyCode === 27 ? \"ESC\" // esc\n : e.keyCode === 38 ? \"UP\" // up\n : e.keyCode === 40 ? \"DOWN\" // down\n : e.keyCode === 78 && e.ctrlKey ? \"DOWN\" // ctrl-n\n : e.keyCode === 80 && e.ctrlKey ? \"UP\" // ctrl-p\n : \"OTHER\";\n }\n }]);\n\n return Editor;\n}(_eventemitter2.default);\n\nexports.default = Editor;\n\n/***/ }),\n/* 5 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n/* WEBPACK VAR INJECTION */(function(global) {\n\nvar _textcomplete = __webpack_require__(7);\n\nvar _textcomplete2 = _interopRequireDefault(_textcomplete);\n\nvar _textarea = __webpack_require__(12);\n\nvar _textarea2 = _interopRequireDefault(_textarea);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar editors = void 0;\nif (global.Textcomplete && global.Textcomplete.editors) {\n editors = global.Textcomplete.editors;\n} else {\n editors = {};\n}\neditors.Textarea = _textarea2.default;\n\nglobal.Textcomplete = _textcomplete2.default;\nglobal.Textcomplete.editors = editors;\n/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6)))\n\n/***/ }),\n/* 6 */\n/***/ (function(module, exports) {\n\nvar g;\r\n\r\n// This works in non-strict mode\r\ng = (function() {\r\n\treturn this;\r\n})();\r\n\r\ntry {\r\n\t// This works if eval is allowed (see CSP)\r\n\tg = g || Function(\"return this\")() || (1,eval)(\"this\");\r\n} catch(e) {\r\n\t// This works if the window reference is available\r\n\tif(typeof window === \"object\")\r\n\t\tg = window;\r\n}\r\n\r\n// g can still be undefined, but nothing to do about it...\r\n// We return undefined, instead of nothing here, so it's\r\n// easier to handle this case. if(!global) { ...}\r\n\r\nmodule.exports = g;\r\n\n\n/***/ }),\n/* 7 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _completer = __webpack_require__(8);\n\nvar _completer2 = _interopRequireDefault(_completer);\n\nvar _editor = __webpack_require__(4);\n\nvar _editor2 = _interopRequireDefault(_editor);\n\nvar _dropdown = __webpack_require__(10);\n\nvar _dropdown2 = _interopRequireDefault(_dropdown);\n\nvar _strategy = __webpack_require__(2);\n\nvar _strategy2 = _interopRequireDefault(_strategy);\n\nvar _search_result = __webpack_require__(0);\n\nvar _search_result2 = _interopRequireDefault(_search_result);\n\nvar _eventemitter = __webpack_require__(1);\n\nvar _eventemitter2 = _interopRequireDefault(_eventemitter);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar CALLBACK_METHODS = [\"handleChange\", \"handleEnter\", \"handleEsc\", \"handleHit\", \"handleMove\", \"handleSelect\"];\n\n/** @typedef */\n\n/**\n * The core of textcomplete. It acts as a mediator.\n */\nvar Textcomplete = function (_EventEmitter) {\n _inherits(Textcomplete, _EventEmitter);\n\n /**\n * @param {Editor} editor - Where the textcomplete works on.\n */\n function Textcomplete(editor) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n _classCallCheck(this, Textcomplete);\n\n var _this = _possibleConstructorReturn(this, (Textcomplete.__proto__ || Object.getPrototypeOf(Textcomplete)).call(this));\n\n _this.completer = new _completer2.default();\n _this.isQueryInFlight = false;\n _this.nextPendingQuery = null;\n _this.dropdown = new _dropdown2.default(options.dropdown || {});\n _this.editor = editor;\n _this.options = options;\n\n CALLBACK_METHODS.forEach(function (method) {\n ;_this[method] = _this[method].bind(_this);\n });\n\n _this.startListening();\n return _this;\n }\n\n /**\n * @return {this}\n */\n\n\n _createClass(Textcomplete, [{\n key: \"destroy\",\n value: function destroy() {\n var destroyEditor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n\n this.completer.destroy();\n this.dropdown.destroy();\n if (destroyEditor) {\n this.editor.destroy();\n }\n this.stopListening();\n return this;\n }\n\n /**\n * @return {this}\n */\n\n }, {\n key: \"hide\",\n value: function hide() {\n this.dropdown.deactivate();\n return this;\n }\n\n /**\n * @return {this}\n * @example\n * textcomplete.register([{\n * match: /(^|\\s)(\\w+)$/,\n * search: function (term, callback) {\n * $.ajax({ ... })\n * .done(callback)\n * .fail([]);\n * },\n * replace: function (value) {\n * return '$1' + value + ' ';\n * }\n * }]);\n */\n\n }, {\n key: \"register\",\n value: function register(strategyPropsArray) {\n var _this2 = this;\n\n strategyPropsArray.forEach(function (props) {\n _this2.completer.registerStrategy(new _strategy2.default(props));\n });\n return this;\n }\n\n /**\n * Start autocompleting.\n *\n * @param {string} text - Head to input cursor.\n * @return {this}\n */\n\n }, {\n key: \"trigger\",\n value: function trigger(text) {\n if (this.isQueryInFlight) {\n this.nextPendingQuery = text;\n } else {\n this.isQueryInFlight = true;\n this.nextPendingQuery = null;\n this.completer.run(text);\n }\n return this;\n }\n\n /** @private */\n\n }, {\n key: \"handleHit\",\n value: function handleHit(_ref) {\n var searchResults = _ref.searchResults;\n\n if (searchResults.length) {\n this.dropdown.render(searchResults, this.editor.getCursorOffset());\n } else {\n this.dropdown.deactivate();\n }\n this.isQueryInFlight = false;\n if (this.nextPendingQuery !== null) {\n this.trigger(this.nextPendingQuery);\n }\n }\n\n /** @private */\n\n }, {\n key: \"handleMove\",\n value: function handleMove(e) {\n e.detail.code === \"UP\" ? this.dropdown.up(e) : this.dropdown.down(e);\n }\n\n /** @private */\n\n }, {\n key: \"handleEnter\",\n value: function handleEnter(e) {\n var activeItem = this.dropdown.getActiveItem();\n if (activeItem) {\n this.dropdown.select(activeItem);\n e.preventDefault();\n } else {\n this.dropdown.deactivate();\n }\n }\n\n /** @private */\n\n }, {\n key: \"handleEsc\",\n value: function handleEsc(e) {\n if (this.dropdown.shown) {\n this.dropdown.deactivate();\n e.preventDefault();\n }\n }\n\n /** @private */\n\n }, {\n key: \"handleChange\",\n value: function handleChange(e) {\n if (e.detail.beforeCursor != null) {\n this.trigger(e.detail.beforeCursor);\n } else {\n this.dropdown.deactivate();\n }\n }\n\n /** @private */\n\n }, {\n key: \"handleSelect\",\n value: function handleSelect(selectEvent) {\n this.emit(\"select\", selectEvent);\n if (!selectEvent.defaultPrevented) {\n this.editor.applySearchResult(selectEvent.detail.searchResult);\n }\n }\n\n /** @private */\n\n }, {\n key: \"startListening\",\n value: function startListening() {\n var _this3 = this;\n\n this.editor.on(\"move\", this.handleMove).on(\"enter\", this.handleEnter).on(\"esc\", this.handleEsc).on(\"change\", this.handleChange);\n this.dropdown.on(\"select\", this.handleSelect);[\"show\", \"shown\", \"render\", \"rendered\", \"selected\", \"hidden\", \"hide\"].forEach(function (eventName) {\n _this3.dropdown.on(eventName, function () {\n return _this3.emit(eventName);\n });\n });\n this.completer.on(\"hit\", this.handleHit);\n }\n\n /** @private */\n\n }, {\n key: \"stopListening\",\n value: function stopListening() {\n this.completer.removeAllListeners();\n this.dropdown.removeAllListeners();\n this.editor.removeListener(\"move\", this.handleMove).removeListener(\"enter\", this.handleEnter).removeListener(\"esc\", this.handleEsc).removeListener(\"change\", this.handleChange);\n }\n }]);\n\n return Textcomplete;\n}(_eventemitter2.default);\n\nexports.default = Textcomplete;\n\n/***/ }),\n/* 8 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _eventemitter = __webpack_require__(1);\n\nvar _eventemitter2 = _interopRequireDefault(_eventemitter);\n\nvar _query = __webpack_require__(9);\n\nvar _query2 = _interopRequireDefault(_query);\n\nvar _search_result = __webpack_require__(0);\n\nvar _search_result2 = _interopRequireDefault(_search_result);\n\nvar _strategy = __webpack_require__(2);\n\nvar _strategy2 = _interopRequireDefault(_strategy);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar CALLBACK_METHODS = [\"handleQueryResult\"];\n\n/**\n * Complete engine.\n */\n\nvar Completer = function (_EventEmitter) {\n _inherits(Completer, _EventEmitter);\n\n function Completer() {\n _classCallCheck(this, Completer);\n\n var _this = _possibleConstructorReturn(this, (Completer.__proto__ || Object.getPrototypeOf(Completer)).call(this));\n\n _this.strategies = [];\n\n CALLBACK_METHODS.forEach(function (method) {\n ;_this[method] = _this[method].bind(_this);\n });\n return _this;\n }\n\n /**\n * @return {this}\n */\n\n\n _createClass(Completer, [{\n key: \"destroy\",\n value: function destroy() {\n this.strategies.forEach(function (strategy) {\n return strategy.destroy();\n });\n return this;\n }\n\n /**\n * Register a strategy to the completer.\n *\n * @return {this}\n */\n\n }, {\n key: \"registerStrategy\",\n value: function registerStrategy(strategy) {\n this.strategies.push(strategy);\n return this;\n }\n\n /**\n * @param {string} text - Head to input cursor.\n */\n\n }, {\n key: \"run\",\n value: function run(text) {\n var query = this.extractQuery(text);\n if (query) {\n query.execute(this.handleQueryResult);\n } else {\n this.handleQueryResult([]);\n }\n }\n\n /**\n * Find a query, which matches to the given text.\n *\n * @private\n */\n\n }, {\n key: \"extractQuery\",\n value: function extractQuery(text) {\n for (var i = 0; i < this.strategies.length; i++) {\n var query = _query2.default.build(this.strategies[i], text);\n if (query) {\n return query;\n }\n }\n return null;\n }\n\n /**\n * Callbacked by {@link Query#execute}.\n *\n * @private\n */\n\n }, {\n key: \"handleQueryResult\",\n value: function handleQueryResult(searchResults) {\n this.emit(\"hit\", { searchResults: searchResults });\n }\n }]);\n\n return Completer;\n}(_eventemitter2.default);\n\nexports.default = Completer;\n\n/***/ }),\n/* 9 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _search_result = __webpack_require__(0);\n\nvar _search_result2 = _interopRequireDefault(_search_result);\n\nvar _strategy = __webpack_require__(2);\n\nvar _strategy2 = _interopRequireDefault(_strategy);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n/**\n * Encapsulate matching condition between a Strategy and current editor's value.\n */\nvar Query = function () {\n _createClass(Query, null, [{\n key: \"build\",\n\n\n /**\n * Build a Query object by the given string if this matches to the string.\n *\n * @param {string} text - Head to input cursor.\n */\n value: function build(strategy, text) {\n if (typeof strategy.props.context === \"function\") {\n var context = strategy.props.context(text);\n if (typeof context === \"string\") {\n text = context;\n } else if (!context) {\n return null;\n }\n }\n var match = strategy.matchText(text);\n return match ? new Query(strategy, match[strategy.index], match) : null;\n }\n }]);\n\n function Query(strategy, term, match) {\n _classCallCheck(this, Query);\n\n this.strategy = strategy;\n this.term = term;\n this.match = match;\n }\n\n /**\n * Invoke search strategy and callback the given function.\n */\n\n\n _createClass(Query, [{\n key: \"execute\",\n value: function execute(callback) {\n var _this = this;\n\n this.strategy.search(this.term, function (results) {\n callback(results.map(function (result) {\n return new _search_result2.default(result, _this.term, _this.strategy);\n }));\n }, this.match);\n }\n }]);\n\n return Query;\n}();\n\nexports.default = Query;\n\n/***/ }),\n/* 10 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _eventemitter = __webpack_require__(1);\n\nvar _eventemitter2 = _interopRequireDefault(_eventemitter);\n\nvar _dropdown_item = __webpack_require__(11);\n\nvar _dropdown_item2 = _interopRequireDefault(_dropdown_item);\n\nvar _search_result = __webpack_require__(0);\n\nvar _search_result2 = _interopRequireDefault(_search_result);\n\nvar _utils = __webpack_require__(3);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar DEFAULT_CLASS_NAME = \"dropdown-menu textcomplete-dropdown\";\n\n/** @typedef */\n\n/**\n * Encapsulate a dropdown view.\n *\n * @prop {boolean} shown - Whether the #el is shown or not.\n * @prop {DropdownItem[]} items - The array of rendered dropdown items.\n */\nvar Dropdown = function (_EventEmitter) {\n _inherits(Dropdown, _EventEmitter);\n\n _createClass(Dropdown, null, [{\n key: \"createElement\",\n value: function createElement() {\n var el = document.createElement(\"ul\");\n var style = el.style;\n style.display = \"none\";\n style.position = \"absolute\";\n style.zIndex = \"10000\";\n var body = document.body;\n if (body) {\n body.appendChild(el);\n }\n return el;\n }\n }]);\n\n function Dropdown(options) {\n _classCallCheck(this, Dropdown);\n\n var _this = _possibleConstructorReturn(this, (Dropdown.__proto__ || Object.getPrototypeOf(Dropdown)).call(this));\n\n _this.shown = false;\n _this.items = [];\n _this.activeItem = null;\n _this.footer = options.footer;\n _this.header = options.header;\n _this.maxCount = options.maxCount || 10;\n _this.el.className = options.className || DEFAULT_CLASS_NAME;\n _this.rotate = options.hasOwnProperty(\"rotate\") ? options.rotate : true;\n _this.placement = options.placement;\n _this.itemOptions = options.item || {};\n var style = options.style;\n if (style) {\n Object.keys(style).forEach(function (key) {\n ;_this.el.style[key] = style[key];\n });\n }\n return _this;\n }\n\n /**\n * @return {this}\n */\n\n\n _createClass(Dropdown, [{\n key: \"destroy\",\n value: function destroy() {\n var parentNode = this.el.parentNode;\n if (parentNode) {\n parentNode.removeChild(this.el);\n }\n this.clear()._el = null;\n return this;\n }\n }, {\n key: \"render\",\n\n\n /**\n * Render the given data as dropdown items.\n *\n * @return {this}\n */\n value: function render(searchResults, cursorOffset) {\n var _this2 = this;\n\n var renderEvent = (0, _utils.createCustomEvent)(\"render\", { cancelable: true });\n this.emit(\"render\", renderEvent);\n if (renderEvent.defaultPrevented) {\n return this;\n }\n var rawResults = searchResults.map(function (searchResult) {\n return searchResult.data;\n });\n var dropdownItems = searchResults.slice(0, this.maxCount || searchResults.length).map(function (searchResult) {\n return new _dropdown_item2.default(searchResult, _this2.itemOptions);\n });\n this.clear().setStrategyId(searchResults[0]).renderEdge(rawResults, \"header\").append(dropdownItems).renderEdge(rawResults, \"footer\").show().setOffset(cursorOffset);\n this.emit(\"rendered\", (0, _utils.createCustomEvent)(\"rendered\"));\n return this;\n }\n\n /**\n * Hide the dropdown then sweep out items.\n *\n * @return {this}\n */\n\n }, {\n key: \"deactivate\",\n value: function deactivate() {\n return this.hide().clear();\n }\n\n /**\n * @return {this}\n */\n\n }, {\n key: \"select\",\n value: function select(dropdownItem) {\n var detail = { searchResult: dropdownItem.searchResult };\n var selectEvent = (0, _utils.createCustomEvent)(\"select\", {\n cancelable: true,\n detail: detail\n });\n this.emit(\"select\", selectEvent);\n if (selectEvent.defaultPrevented) {\n return this;\n }\n this.deactivate();\n this.emit(\"selected\", (0, _utils.createCustomEvent)(\"selected\", { detail: detail }));\n return this;\n }\n\n /**\n * @return {this}\n */\n\n }, {\n key: \"up\",\n value: function up(e) {\n return this.shown ? this.moveActiveItem(\"prev\", e) : this;\n }\n\n /**\n * @return {this}\n */\n\n }, {\n key: \"down\",\n value: function down(e) {\n return this.shown ? this.moveActiveItem(\"next\", e) : this;\n }\n\n /**\n * Retrieve the active item.\n */\n\n }, {\n key: \"getActiveItem\",\n value: function getActiveItem() {\n return this.activeItem;\n }\n\n /**\n * Add items to dropdown.\n *\n * @private\n */\n\n }, {\n key: \"append\",\n value: function append(items) {\n var _this3 = this;\n\n var fragment = document.createDocumentFragment();\n items.forEach(function (item) {\n _this3.items.push(item);\n item.appended(_this3);\n fragment.appendChild(item.el);\n });\n this.el.appendChild(fragment);\n return this;\n }\n\n /** @private */\n\n }, {\n key: \"setOffset\",\n value: function setOffset(cursorOffset) {\n var doc = document.documentElement;\n if (doc) {\n var elementWidth = this.el.offsetWidth;\n if (cursorOffset.left) {\n var browserWidth = doc.clientWidth;\n if (cursorOffset.left + elementWidth > browserWidth) {\n cursorOffset.left = browserWidth - elementWidth;\n }\n this.el.style.left = cursorOffset.left + \"px\";\n } else if (cursorOffset.right) {\n if (cursorOffset.right - elementWidth < 0) {\n cursorOffset.right = 0;\n }\n this.el.style.right = cursorOffset.right + \"px\";\n }\n if (this.isPlacementTop()) {\n this.el.style.bottom = doc.clientHeight - cursorOffset.top + cursorOffset.lineHeight + \"px\";\n } else {\n this.el.style.top = cursorOffset.top + \"px\";\n }\n }\n return this;\n }\n\n /**\n * Show the element.\n *\n * @private\n */\n\n }, {\n key: \"show\",\n value: function show() {\n if (!this.shown) {\n var showEvent = (0, _utils.createCustomEvent)(\"show\", { cancelable: true });\n this.emit(\"show\", showEvent);\n if (showEvent.defaultPrevented) {\n return this;\n }\n this.el.style.display = \"block\";\n this.shown = true;\n this.emit(\"shown\", (0, _utils.createCustomEvent)(\"shown\"));\n }\n return this;\n }\n\n /**\n * Hide the element.\n *\n * @private\n */\n\n }, {\n key: \"hide\",\n value: function hide() {\n if (this.shown) {\n var hideEvent = (0, _utils.createCustomEvent)(\"hide\", { cancelable: true });\n this.emit(\"hide\", hideEvent);\n if (hideEvent.defaultPrevented) {\n return this;\n }\n this.el.style.display = \"none\";\n this.shown = false;\n this.emit(\"hidden\", (0, _utils.createCustomEvent)(\"hidden\"));\n }\n return this;\n }\n\n /**\n * Clear search results.\n *\n * @private\n */\n\n }, {\n key: \"clear\",\n value: function clear() {\n this.el.innerHTML = \"\";\n this.items.forEach(function (item) {\n return item.destroy();\n });\n this.items = [];\n return this;\n }\n\n /** @private */\n\n }, {\n key: \"moveActiveItem\",\n value: function moveActiveItem(direction, e) {\n var nextActiveItem = direction === \"next\" ? this.activeItem ? this.activeItem.next : this.items[0] : this.activeItem ? this.activeItem.prev : this.items[this.items.length - 1];\n if (nextActiveItem) {\n nextActiveItem.activate();\n e.preventDefault();\n }\n return this;\n }\n\n /** @private */\n\n }, {\n key: \"setStrategyId\",\n value: function setStrategyId(searchResult) {\n var strategyId = searchResult && searchResult.strategy.props.id;\n if (strategyId) {\n this.el.setAttribute(\"data-strategy\", strategyId);\n } else {\n this.el.removeAttribute(\"data-strategy\");\n }\n return this;\n }\n\n /**\n * @private\n * @param {object[]} rawResults - What callbacked by search function.\n */\n\n }, {\n key: \"renderEdge\",\n value: function renderEdge(rawResults, type) {\n var source = (type === \"header\" ? this.header : this.footer) || \"\";\n var content = typeof source === \"function\" ? source(rawResults) : source;\n var li = document.createElement(\"li\");\n li.classList.add(\"textcomplete-\" + type);\n li.innerHTML = content;\n this.el.appendChild(li);\n return this;\n }\n\n /** @private */\n\n }, {\n key: \"isPlacementTop\",\n value: function isPlacementTop() {\n return this.placement === \"top\";\n }\n }, {\n key: \"el\",\n get: function get() {\n if (!this._el) {\n this._el = Dropdown.createElement();\n }\n return this._el;\n }\n }]);\n\n return Dropdown;\n}(_eventemitter2.default);\n\nexports.default = Dropdown;\n\n/***/ }),\n/* 11 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.DEFAULT_CLASS_NAME = undefined;\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _search_result = __webpack_require__(0);\n\nvar _search_result2 = _interopRequireDefault(_search_result);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar DEFAULT_CLASS_NAME = exports.DEFAULT_CLASS_NAME = \"textcomplete-item\";\nvar CALLBACK_METHODS = [\"onClick\", \"onMouseover\"];\n\n/** @typedef */\n\n\n// Declare interface instead of importing Dropdown itself to prevent circular dependency.\n\n/**\n * Encapsulate an item of dropdown.\n */\nvar DropdownItem = function () {\n function DropdownItem(searchResult, options) {\n var _this = this;\n\n _classCallCheck(this, DropdownItem);\n\n this.searchResult = searchResult;\n this.active = false;\n this.className = options.className || DEFAULT_CLASS_NAME;\n this.activeClassName = this.className + \" active\";\n\n CALLBACK_METHODS.forEach(function (method) {\n ;_this[method] = _this[method].bind(_this);\n });\n }\n\n _createClass(DropdownItem, [{\n key: \"destroy\",\n\n\n /**\n * Try to free resources and perform other cleanup operations.\n */\n value: function destroy() {\n this.el.removeEventListener(\"mousedown\", this.onClick, false);\n this.el.removeEventListener(\"mouseover\", this.onMouseover, false);\n this.el.removeEventListener(\"touchstart\", this.onClick, false);\n if (this.active) {\n this.dropdown.activeItem = null;\n }\n // This element has already been removed by {@link Dropdown#clear}.\n this._el = null;\n }\n\n /**\n * Callbacked when it is appended to a dropdown.\n *\n * @see Dropdown#append\n */\n\n }, {\n key: \"appended\",\n value: function appended(dropdown) {\n this.dropdown = dropdown;\n this.siblings = dropdown.items;\n this.index = this.siblings.length - 1;\n }\n\n /**\n * Deactivate active item then activate itself.\n *\n * @return {this}\n */\n\n }, {\n key: \"activate\",\n value: function activate() {\n if (!this.active) {\n var _activeItem = this.dropdown.getActiveItem();\n if (_activeItem) {\n _activeItem.deactivate();\n }\n this.dropdown.activeItem = this;\n this.active = true;\n this.el.className = this.activeClassName;\n }\n return this;\n }\n\n /**\n * Get the next sibling.\n */\n\n }, {\n key: \"deactivate\",\n\n\n /** @private */\n value: function deactivate() {\n if (this.active) {\n this.active = false;\n this.el.className = this.className;\n this.dropdown.activeItem = null;\n }\n return this;\n }\n\n /** @private */\n\n }, {\n key: \"onClick\",\n value: function onClick(e) {\n e.preventDefault // Prevent blur event\n ();this.dropdown.select(this);\n }\n\n /** @private */\n\n }, {\n key: \"onMouseover\",\n value: function onMouseover() {\n this.activate();\n }\n }, {\n key: \"el\",\n get: function get() {\n if (this._el) {\n return this._el;\n }\n var li = document.createElement(\"li\");\n li.className = this.active ? this.activeClassName : this.className;\n var a = document.createElement(\"a\");\n a.innerHTML = this.searchResult.render();\n li.appendChild(a);\n this._el = li;\n li.addEventListener(\"mousedown\", this.onClick);\n li.addEventListener(\"mouseover\", this.onMouseover);\n li.addEventListener(\"touchstart\", this.onClick);\n return li;\n }\n }, {\n key: \"next\",\n get: function get() {\n var nextIndex = void 0;\n if (this.index === this.siblings.length - 1) {\n if (!this.dropdown.rotate) {\n return null;\n }\n nextIndex = 0;\n } else {\n nextIndex = this.index + 1;\n }\n return this.siblings[nextIndex];\n }\n\n /**\n * Get the previous sibling.\n */\n\n }, {\n key: \"prev\",\n get: function get() {\n var nextIndex = void 0;\n if (this.index === 0) {\n if (!this.dropdown.rotate) {\n return null;\n }\n nextIndex = this.siblings.length - 1;\n } else {\n nextIndex = this.index - 1;\n }\n return this.siblings[nextIndex];\n }\n }]);\n\n return DropdownItem;\n}();\n\nexports.default = DropdownItem;\n\n/***/ }),\n/* 12 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if (\"value\" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };\n\nvar _update = __webpack_require__(13);\n\nvar _update2 = _interopRequireDefault(_update);\n\nvar _editor = __webpack_require__(4);\n\nvar _editor2 = _interopRequireDefault(_editor);\n\nvar _utils = __webpack_require__(3);\n\nvar _search_result = __webpack_require__(0);\n\nvar _search_result2 = _interopRequireDefault(_search_result);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar getCaretCoordinates = __webpack_require__(14);\n\nvar CALLBACK_METHODS = [\"onInput\", \"onKeydown\"];\n\n/**\n * Encapsulate the target textarea element.\n */\n\nvar Textarea = function (_Editor) {\n _inherits(Textarea, _Editor);\n\n /**\n * @param {HTMLTextAreaElement} el - Where the textcomplete works on.\n */\n function Textarea(el) {\n _classCallCheck(this, Textarea);\n\n var _this = _possibleConstructorReturn(this, (Textarea.__proto__ || Object.getPrototypeOf(Textarea)).call(this));\n\n _this.el = el;\n\n CALLBACK_METHODS.forEach(function (method) {\n ;_this[method] = _this[method].bind(_this);\n });\n\n _this.startListening();\n return _this;\n }\n\n /**\n * @return {this}\n */\n\n\n _createClass(Textarea, [{\n key: \"destroy\",\n value: function destroy() {\n _get(Textarea.prototype.__proto__ || Object.getPrototypeOf(Textarea.prototype), \"destroy\", this).call(this);\n this.stopListening\n // Release the element reference early to help garbage collection.\n ();this.el = null;\n return this;\n }\n\n /**\n * Implementation for {@link Editor#applySearchResult}\n */\n\n }, {\n key: \"applySearchResult\",\n value: function applySearchResult(searchResult) {\n var before = this.getBeforeCursor();\n if (before != null) {\n var replace = searchResult.replace(before, this.getAfterCursor());\n this.el.focus // Clicking a dropdown item removes focus from the element.\n ();if (Array.isArray(replace)) {\n (0, _update2.default)(this.el, replace[0], replace[1]);\n this.el.dispatchEvent(new Event(\"input\"));\n }\n }\n }\n\n /**\n * Implementation for {@link Editor#getCursorOffset}\n */\n\n }, {\n key: \"getCursorOffset\",\n value: function getCursorOffset() {\n var elOffset = (0, _utils.calculateElementOffset)(this.el);\n var elScroll = this.getElScroll();\n var cursorPosition = this.getCursorPosition();\n var lineHeight = (0, _utils.getLineHeightPx)(this.el);\n var top = elOffset.top - elScroll.top + cursorPosition.top + lineHeight;\n var left = elOffset.left - elScroll.left + cursorPosition.left;\n if (this.el.dir !== \"rtl\") {\n return { top: top, left: left, lineHeight: lineHeight };\n } else {\n var right = document.documentElement ? document.documentElement.clientWidth - left : 0;\n return { top: top, right: right, lineHeight: lineHeight };\n }\n }\n\n /**\n * Implementation for {@link Editor#getBeforeCursor}\n */\n\n }, {\n key: \"getBeforeCursor\",\n value: function getBeforeCursor() {\n return this.el.selectionStart !== this.el.selectionEnd ? null : this.el.value.substring(0, this.el.selectionEnd);\n }\n\n /** @private */\n\n }, {\n key: \"getAfterCursor\",\n value: function getAfterCursor() {\n return this.el.value.substring(this.el.selectionEnd);\n }\n\n /** @private */\n\n }, {\n key: \"getElScroll\",\n value: function getElScroll() {\n return { top: this.el.scrollTop, left: this.el.scrollLeft };\n }\n\n /**\n * The input cursor's relative coordinates from the textarea's left\n * top corner.\n *\n * @private\n */\n\n }, {\n key: \"getCursorPosition\",\n value: function getCursorPosition() {\n return getCaretCoordinates(this.el, this.el.selectionEnd);\n }\n\n /** @private */\n\n }, {\n key: \"onInput\",\n value: function onInput() {\n this.emitChangeEvent();\n }\n\n /** @private */\n\n }, {\n key: \"onKeydown\",\n value: function onKeydown(e) {\n var code = this.getCode(e);\n var event = void 0;\n if (code === \"UP\" || code === \"DOWN\") {\n event = this.emitMoveEvent(code);\n } else if (code === \"ENTER\") {\n event = this.emitEnterEvent();\n } else if (code === \"ESC\") {\n event = this.emitEscEvent();\n }\n if (event && event.defaultPrevented) {\n e.preventDefault();\n }\n }\n\n /** @private */\n\n }, {\n key: \"startListening\",\n value: function startListening() {\n this.el.addEventListener(\"input\", this.onInput);\n this.el.addEventListener(\"keydown\", this.onKeydown);\n }\n\n /** @private */\n\n }, {\n key: \"stopListening\",\n value: function stopListening() {\n this.el.removeEventListener(\"input\", this.onInput);\n this.el.removeEventListener(\"keydown\", this.onKeydown);\n }\n }]);\n\n return Textarea;\n}(_editor2.default);\n\nexports.default = Textarea;\n\n/***/ }),\n/* 13 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nexports.default = function (el, headToCursor, cursorToTail) {\n var curr = el.value,\n // strA + strB1 + strC\n next = headToCursor + (cursorToTail || ''),\n // strA + strB2 + strC\n activeElement = document.activeElement;\n\n // Calculate length of strA and strC\n var aLength = 0,\n cLength = 0;\n while (aLength < curr.length && aLength < next.length && curr[aLength] === next[aLength]) {\n aLength++;\n }\n while (curr.length - cLength - 1 >= 0 && next.length - cLength - 1 >= 0 && curr[curr.length - cLength - 1] === next[next.length - cLength - 1]) {\n cLength++;\n }\n aLength = Math.min(aLength, Math.min(curr.length, next.length) - cLength);\n\n // Select strB1\n el.setSelectionRange(aLength, curr.length - cLength);\n\n // Get strB2\n var strB2 = next.substring(aLength, next.length - cLength);\n\n // Replace strB1 with strB2\n el.focus();\n if (!document.execCommand('insertText', false, strB2)) {\n // Document.execCommand returns false if the command is not supported.\n // Firefox and IE returns false in this case.\n el.value = next;\n el.dispatchEvent(createInputEvent());\n }\n\n // Move cursor to the end of headToCursor\n el.setSelectionRange(headToCursor.length, headToCursor.length);\n\n activeElement && activeElement.focus();\n return el;\n};\n\nfunction createInputEvent() {\n if (typeof Event !== \"undefined\") {\n return new Event(\"input\", { bubbles: true, cancelable: true });\n } else {\n var event = document.createEvent(\"Event\");\n event.initEvent(\"input\", true, true);\n return event;\n }\n}\n\n/***/ }),\n/* 14 */\n/***/ (function(module, exports) {\n\n/* jshint browser: true */\n\n(function () {\n\n// The properties that we copy into a mirrored div.\n// Note that some browsers, such as Firefox,\n// do not concatenate properties, i.e. padding-top, bottom etc. -> padding,\n// so we have to do every single property specifically.\nvar properties = [\n 'direction', // RTL support\n 'boxSizing',\n 'width', // on Chrome and IE, exclude the scrollbar, so the mirror div wraps exactly as the textarea does\n 'height',\n 'overflowX',\n 'overflowY', // copy the scrollbar for IE\n\n 'borderTopWidth',\n 'borderRightWidth',\n 'borderBottomWidth',\n 'borderLeftWidth',\n 'borderStyle',\n\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n\n // https://developer.mozilla.org/en-US/docs/Web/CSS/font\n 'fontStyle',\n 'fontVariant',\n 'fontWeight',\n 'fontStretch',\n 'fontSize',\n 'fontSizeAdjust',\n 'lineHeight',\n 'fontFamily',\n\n 'textAlign',\n 'textTransform',\n 'textIndent',\n 'textDecoration', // might not make a difference, but better be safe\n\n 'letterSpacing',\n 'wordSpacing',\n\n 'tabSize',\n 'MozTabSize'\n\n];\n\nvar isBrowser = (typeof window !== 'undefined');\nvar isFirefox = (isBrowser && window.mozInnerScreenX != null);\n\nfunction getCaretCoordinates(element, position, options) {\n if(!isBrowser) {\n throw new Error('textarea-caret-position#getCaretCoordinates should only be called in a browser');\n }\n\n var debug = options && options.debug || false;\n if (debug) {\n var el = document.querySelector('#input-textarea-caret-position-mirror-div');\n if ( el ) { el.parentNode.removeChild(el); }\n }\n\n // mirrored div\n var div = document.createElement('div');\n div.id = 'input-textarea-caret-position-mirror-div';\n document.body.appendChild(div);\n\n var style = div.style;\n var computed = window.getComputedStyle? getComputedStyle(element) : element.currentStyle; // currentStyle for IE < 9\n\n // default textarea styles\n style.whiteSpace = 'pre-wrap';\n if (element.nodeName !== 'INPUT')\n style.wordWrap = 'break-word'; // only for textarea-s\n\n // position off-screen\n style.position = 'absolute'; // required to return coordinates properly\n if (!debug)\n style.visibility = 'hidden'; // not 'display: none' because we want rendering\n\n // transfer the element's properties to the div\n properties.forEach(function (prop) {\n style[prop] = computed[prop];\n });\n\n if (isFirefox) {\n // Firefox lies about the overflow property for textareas: https://bugzilla.mozilla.org/show_bug.cgi?id=984275\n if (element.scrollHeight > parseInt(computed.height))\n style.overflowY = 'scroll';\n } else {\n style.overflow = 'hidden'; // for Chrome to not render a scrollbar; IE keeps overflowY = 'scroll'\n }\n\n div.textContent = element.value.substring(0, position);\n // the second special handling for input type=\"text\" vs textarea: spaces need to be replaced with non-breaking spaces - http://stackoverflow.com/a/13402035/1269037\n if (element.nodeName === 'INPUT')\n div.textContent = div.textContent.replace(/\\s/g, '\\u00a0');\n\n var span = document.createElement('span');\n // Wrapping must be replicated *exactly*, including when a long word gets\n // onto the next line, with whitespace at the end of the line before (#7).\n // The *only* reliable way to do that is to copy the *entire* rest of the\n // textarea's content into the created at the caret position.\n // for inputs, just '.' would be enough, but why bother?\n span.textContent = element.value.substring(position) || '.'; // || because a completely empty faux span doesn't render at all\n div.appendChild(span);\n\n var coordinates = {\n top: span.offsetTop + parseInt(computed['borderTopWidth']),\n left: span.offsetLeft + parseInt(computed['borderLeftWidth'])\n };\n\n if (debug) {\n span.style.backgroundColor = '#aaa';\n } else {\n document.body.removeChild(div);\n }\n\n return coordinates;\n}\n\nif (typeof module != 'undefined' && typeof module.exports != 'undefined') {\n module.exports = getCaretCoordinates;\n} else if(isBrowser){\n window.getCaretCoordinates = getCaretCoordinates;\n}\n\n}());\n\n\n/***/ })\n/******/ ]);\n\n\n// WEBPACK FOOTER //\n// textcomplete.min.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 5);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 5fdd342a07201b673919","// @flow\n\nimport Strategy from \"./strategy\"\n\n/**\n * Encapsulate an result of each search results.\n */\nexport default class SearchResult {\n data: Object\n term: string\n strategy: Strategy\n\n /**\n * @param {object} data - An element of array callbacked by search function.\n */\n constructor(data: Object, term: string, strategy: Strategy) {\n this.data = data\n this.term = term\n this.strategy = strategy\n }\n\n replace(beforeCursor: string, afterCursor: string) {\n let replacement = this.strategy.replace(this.data)\n if (replacement !== null) {\n if (Array.isArray(replacement)) {\n afterCursor = replacement[1] + afterCursor\n replacement = replacement[0]\n }\n const match = this.strategy.matchText(beforeCursor)\n if (match) {\n replacement = replacement\n .replace(/\\$&/g, match[0])\n .replace(/\\$(\\d)/g, (_, p1) => match[parseInt(p1, 10)])\n return [\n [\n beforeCursor.slice(0, match.index),\n replacement,\n beforeCursor.slice(match.index + match[0].length),\n ].join(\"\"),\n afterCursor,\n ]\n }\n }\n }\n\n render(): string {\n return this.strategy.template(this.data, this.term)\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/search_result.js","'use strict';\n\nvar has = Object.prototype.hasOwnProperty\n , prefix = '~';\n\n/**\n * Constructor to create a storage for our `EE` objects.\n * An `Events` instance is a plain object whose properties are event names.\n *\n * @constructor\n * @api private\n */\nfunction Events() {}\n\n//\n// We try to not inherit from `Object.prototype`. In some engines creating an\n// instance in this way is faster than calling `Object.create(null)` directly.\n// If `Object.create(null)` is not supported we prefix the event names with a\n// character to make sure that the built-in object properties are not\n// overridden or used as an attack vector.\n//\nif (Object.create) {\n Events.prototype = Object.create(null);\n\n //\n // This hack is needed because the `__proto__` property is still inherited in\n // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.\n //\n if (!new Events().__proto__) prefix = false;\n}\n\n/**\n * Representation of a single event listener.\n *\n * @param {Function} fn The listener function.\n * @param {Mixed} context The context to invoke the listener with.\n * @param {Boolean} [once=false] Specify if the listener is a one-time listener.\n * @constructor\n * @api private\n */\nfunction EE(fn, context, once) {\n this.fn = fn;\n this.context = context;\n this.once = once || false;\n}\n\n/**\n * Minimal `EventEmitter` interface that is molded against the Node.js\n * `EventEmitter` interface.\n *\n * @constructor\n * @api public\n */\nfunction EventEmitter() {\n this._events = new Events();\n this._eventsCount = 0;\n}\n\n/**\n * Return an array listing the events for which the emitter has registered\n * listeners.\n *\n * @returns {Array}\n * @api public\n */\nEventEmitter.prototype.eventNames = function eventNames() {\n var names = []\n , events\n , name;\n\n if (this._eventsCount === 0) return names;\n\n for (name in (events = this._events)) {\n if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);\n }\n\n if (Object.getOwnPropertySymbols) {\n return names.concat(Object.getOwnPropertySymbols(events));\n }\n\n return names;\n};\n\n/**\n * Return the listeners registered for a given event.\n *\n * @param {String|Symbol} event The event name.\n * @param {Boolean} exists Only check if there are listeners.\n * @returns {Array|Boolean}\n * @api public\n */\nEventEmitter.prototype.listeners = function listeners(event, exists) {\n var evt = prefix ? prefix + event : event\n , available = this._events[evt];\n\n if (exists) return !!available;\n if (!available) return [];\n if (available.fn) return [available.fn];\n\n for (var i = 0, l = available.length, ee = new Array(l); i < l; i++) {\n ee[i] = available[i].fn;\n }\n\n return ee;\n};\n\n/**\n * Calls each of the listeners registered for a given event.\n *\n * @param {String|Symbol} event The event name.\n * @returns {Boolean} `true` if the event had listeners, else `false`.\n * @api public\n */\nEventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return false;\n\n var listeners = this._events[evt]\n , len = arguments.length\n , args\n , i;\n\n if (listeners.fn) {\n if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);\n\n switch (len) {\n case 1: return listeners.fn.call(listeners.context), true;\n case 2: return listeners.fn.call(listeners.context, a1), true;\n case 3: return listeners.fn.call(listeners.context, a1, a2), true;\n case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;\n case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;\n case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;\n }\n\n for (i = 1, args = new Array(len -1); i < len; i++) {\n args[i - 1] = arguments[i];\n }\n\n listeners.fn.apply(listeners.context, args);\n } else {\n var length = listeners.length\n , j;\n\n for (i = 0; i < length; i++) {\n if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);\n\n switch (len) {\n case 1: listeners[i].fn.call(listeners[i].context); break;\n case 2: listeners[i].fn.call(listeners[i].context, a1); break;\n case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;\n case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;\n default:\n if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {\n args[j - 1] = arguments[j];\n }\n\n listeners[i].fn.apply(listeners[i].context, args);\n }\n }\n }\n\n return true;\n};\n\n/**\n * Add a listener for a given event.\n *\n * @param {String|Symbol} event The event name.\n * @param {Function} fn The listener function.\n * @param {Mixed} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @api public\n */\nEventEmitter.prototype.on = function on(event, fn, context) {\n var listener = new EE(fn, context || this)\n , evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;\n else if (!this._events[evt].fn) this._events[evt].push(listener);\n else this._events[evt] = [this._events[evt], listener];\n\n return this;\n};\n\n/**\n * Add a one-time listener for a given event.\n *\n * @param {String|Symbol} event The event name.\n * @param {Function} fn The listener function.\n * @param {Mixed} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @api public\n */\nEventEmitter.prototype.once = function once(event, fn, context) {\n var listener = new EE(fn, context || this, true)\n , evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;\n else if (!this._events[evt].fn) this._events[evt].push(listener);\n else this._events[evt] = [this._events[evt], listener];\n\n return this;\n};\n\n/**\n * Remove the listeners of a given event.\n *\n * @param {String|Symbol} event The event name.\n * @param {Function} fn Only remove the listeners that match this function.\n * @param {Mixed} context Only remove the listeners that have this context.\n * @param {Boolean} once Only remove one-time listeners.\n * @returns {EventEmitter} `this`.\n * @api public\n */\nEventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return this;\n if (!fn) {\n if (--this._eventsCount === 0) this._events = new Events();\n else delete this._events[evt];\n return this;\n }\n\n var listeners = this._events[evt];\n\n if (listeners.fn) {\n if (\n listeners.fn === fn\n && (!once || listeners.once)\n && (!context || listeners.context === context)\n ) {\n if (--this._eventsCount === 0) this._events = new Events();\n else delete this._events[evt];\n }\n } else {\n for (var i = 0, events = [], length = listeners.length; i < length; i++) {\n if (\n listeners[i].fn !== fn\n || (once && !listeners[i].once)\n || (context && listeners[i].context !== context)\n ) {\n events.push(listeners[i]);\n }\n }\n\n //\n // Reset the array, or remove it completely if we have no more listeners.\n //\n if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;\n else if (--this._eventsCount === 0) this._events = new Events();\n else delete this._events[evt];\n }\n\n return this;\n};\n\n/**\n * Remove all listeners, or those of the specified event.\n *\n * @param {String|Symbol} [event] The event name.\n * @returns {EventEmitter} `this`.\n * @api public\n */\nEventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {\n var evt;\n\n if (event) {\n evt = prefix ? prefix + event : event;\n if (this._events[evt]) {\n if (--this._eventsCount === 0) this._events = new Events();\n else delete this._events[evt];\n }\n } else {\n this._events = new Events();\n this._eventsCount = 0;\n }\n\n return this;\n};\n\n//\n// Alias methods names because people roll like that.\n//\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\nEventEmitter.prototype.addListener = EventEmitter.prototype.on;\n\n//\n// This function doesn't apply anymore.\n//\nEventEmitter.prototype.setMaxListeners = function setMaxListeners() {\n return this;\n};\n\n//\n// Expose the prefix.\n//\nEventEmitter.prefixed = prefix;\n\n//\n// Allow `EventEmitter` to be imported as module namespace.\n//\nEventEmitter.EventEmitter = EventEmitter;\n\n//\n// Expose the module.\n//\nif ('undefined' !== typeof module) {\n module.exports = EventEmitter;\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/eventemitter3/index.js\n// module id = 1\n// module chunks = 0","// @flow\n\ndeclare class MatchData extends Array {\n index: number;\n}\n\nexport type { MatchData }\n\nconst DEFAULT_INDEX = 2\n\nfunction DEFAULT_TEMPLATE(value) {\n return value\n}\n\n/**\n * Properties for a strategy.\n *\n * @typedef\n */\nexport type StrategyProperties = {\n match: RegExp | (string => MatchData | null),\n search: Function,\n replace: any => string[] | string | null,\n cache?: boolean,\n context?: Function,\n template?: any => string,\n index?: number,\n id?: string,\n}\n\n/**\n * Encapsulate a single strategy.\n */\nexport default class Strategy {\n props: StrategyProperties\n cache: ?Object\n\n constructor(props: StrategyProperties) {\n this.props = props\n this.cache = props.cache ? {} : null\n }\n\n /**\n * @return {this}\n */\n destroy() {\n this.cache = null\n return this\n }\n\n search(term: string, callback: Function, match: MatchData): void {\n if (this.cache) {\n this.searchWithCache(term, callback, match)\n } else {\n this.props.search(term, callback, match)\n }\n }\n\n /**\n * @param {object} data - An element of array callbacked by search function.\n */\n replace(data: any) {\n return this.props.replace(data)\n }\n\n /** @private */\n searchWithCache(term: string, callback: Function, match: MatchData): void {\n if (this.cache && this.cache[term]) {\n callback(this.cache[term])\n } else {\n this.props.search(\n term,\n results => {\n if (this.cache) {\n this.cache[term] = results\n }\n callback(results)\n },\n match,\n )\n }\n }\n\n /** @private */\n matchText(text: string): MatchData | null {\n if (typeof this.match === \"function\") {\n return this.match(text)\n } else {\n return (text.match(this.match): any)\n }\n }\n\n /** @private */\n get match(): $PropertyType {\n return this.props.match\n }\n\n /** @private */\n get index(): number {\n return typeof this.props.index === \"number\"\n ? this.props.index\n : DEFAULT_INDEX\n }\n\n get template(): (...any) => string {\n return this.props.template || DEFAULT_TEMPLATE\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/strategy.js","// @flow\n\n/**\n * Create a custom event\n *\n * @private\n */\nexport const createCustomEvent = (() => {\n if (typeof window.CustomEvent === \"function\") {\n return function(\n type: string,\n options: ?{ detail?: Object, cancelable?: boolean },\n ): CustomEvent {\n return new document.defaultView.CustomEvent(type, {\n cancelable: (options && options.cancelable) || false,\n detail: (options && options.detail) || undefined,\n })\n }\n } else {\n // Custom event polyfill from\n // https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#polyfill\n return function(\n type: string,\n options: ?{ detail?: Object, cancelable?: boolean },\n ): CustomEvent {\n const event = document.createEvent(\"CustomEvent\")\n event.initCustomEvent(\n type,\n /* bubbles */ false,\n (options && options.cancelable) || false,\n (options && options.detail) || undefined,\n )\n return event\n }\n }\n})()\n\n/**\n * Get the current coordinates of the `el` relative to the document.\n *\n * @private\n */\nexport function calculateElementOffset(\n el: HTMLElement,\n): { top: number, left: number } {\n const rect = el.getBoundingClientRect()\n const { defaultView, documentElement } = el.ownerDocument\n const offset = {\n top: rect.top + defaultView.pageYOffset,\n left: rect.left + defaultView.pageXOffset,\n }\n if (documentElement) {\n offset.top -= documentElement.clientTop\n offset.left -= documentElement.clientLeft\n }\n return offset\n}\n\nconst CHAR_CODE_ZERO = \"0\".charCodeAt(0)\nconst CHAR_CODE_NINE = \"9\".charCodeAt(0)\n\nfunction isDigit(charCode: number): boolean {\n return charCode >= CHAR_CODE_ZERO && charCode <= CHAR_CODE_NINE\n}\n\n/**\n * Returns the line-height of the given node in pixels.\n *\n * @private\n */\nexport function getLineHeightPx(node: HTMLElement): number {\n const computedStyle = window.getComputedStyle(node)\n\n // If the char code starts with a digit, it is either a value in pixels,\n // or unitless, as per:\n // https://drafts.csswg.org/css2/visudet.html#propdef-line-height\n // https://drafts.csswg.org/css2/cascade.html#computed-value\n if (isDigit(computedStyle.lineHeight.charCodeAt(0))) {\n // In real browsers the value is *always* in pixels, even for unit-less\n // line-heights. However, we still check as per the spec.\n if (\n isDigit(\n computedStyle.lineHeight.charCodeAt(\n computedStyle.lineHeight.length - 1,\n ),\n )\n ) {\n return (\n parseFloat(computedStyle.lineHeight) *\n parseFloat(computedStyle.fontSize)\n )\n } else {\n return parseFloat(computedStyle.lineHeight)\n }\n }\n\n // Otherwise, the value is \"normal\".\n // If the line-height is \"normal\", calculate by font-size\n return calculateLineHeightPx(node.nodeName, computedStyle)\n}\n\n/**\n * Returns calculated line-height of the given node in pixels.\n *\n * @private\n */\nexport function calculateLineHeightPx(\n nodeName: string,\n computedStyle: CSSStyleDeclaration,\n): number {\n const body = document.body\n if (!body) {\n return 0\n }\n\n const tempNode = document.createElement(nodeName)\n tempNode.innerHTML = \" \"\n tempNode.style.fontSize = computedStyle.fontSize\n tempNode.style.fontFamily = computedStyle.fontFamily\n tempNode.style.padding = \"0\"\n body.appendChild(tempNode)\n\n // Make sure textarea has only 1 row\n if (tempNode instanceof HTMLTextAreaElement) {\n ;(tempNode: HTMLTextAreaElement).rows = 1\n }\n\n // Assume the height of the element is the line-height\n const height = tempNode.offsetHeight\n body.removeChild(tempNode)\n\n return height\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/utils.js","// @flow\n/*eslint no-unused-vars: off*/\n\nimport EventEmitter from \"eventemitter3\"\n\nimport { createCustomEvent } from \"./utils\"\nimport SearchResult from \"./search_result\"\n\n/** @typedef */\nexport type CursorOffset = {\n lineHeight: number,\n top: number,\n left?: number,\n right?: number,\n}\n\ntype KeyCode = \"ESC\" | \"ENTER\" | \"UP\" | \"DOWN\" | \"OTHER\"\n\n/**\n * Abstract class representing a editor target.\n *\n * Editor classes must implement `#applySearchResult`, `#getCursorOffset` and\n * `#getBeforeCursor` methods.\n *\n * Editor classes must invoke `#emitMoveEvent`, `#emitEnterEvent`,\n * `#emitChangeEvent` and `#emitEscEvent` at proper timing.\n *\n * @abstract\n */\nexport default class Editor extends EventEmitter {\n /**\n * It is called when associated textcomplete object is destroyed.\n *\n * @return {this}\n */\n destroy() {\n return this\n }\n\n /**\n * It is called when a search result is selected by a user.\n */\n applySearchResult(_: SearchResult): void {\n throw new Error(\"Not implemented.\")\n }\n\n /**\n * The input cursor's absolute coordinates from the window's left\n * top corner.\n */\n getCursorOffset(): CursorOffset {\n throw new Error(\"Not implemented.\")\n }\n\n /**\n * Editor string value from head to cursor.\n * Returns null if selection type is range not cursor.\n */\n getBeforeCursor(): ?string {\n throw new Error(\"Not implemented.\")\n }\n\n /**\n * Emit a move event, which moves active dropdown element.\n * Child class must call this method at proper timing with proper parameter.\n *\n * @see {@link Textarea} for live example.\n */\n emitMoveEvent(code: \"UP\" | \"DOWN\"): CustomEvent {\n const moveEvent = createCustomEvent(\"move\", {\n cancelable: true,\n detail: {\n code: code,\n },\n })\n this.emit(\"move\", moveEvent)\n return moveEvent\n }\n\n /**\n * Emit a enter event, which selects current search result.\n * Child class must call this method at proper timing.\n *\n * @see {@link Textarea} for live example.\n */\n emitEnterEvent(): CustomEvent {\n const enterEvent = createCustomEvent(\"enter\", { cancelable: true })\n this.emit(\"enter\", enterEvent)\n return enterEvent\n }\n\n /**\n * Emit a change event, which triggers auto completion.\n * Child class must call this method at proper timing.\n *\n * @see {@link Textarea} for live example.\n */\n emitChangeEvent(): CustomEvent {\n const changeEvent = createCustomEvent(\"change\", {\n detail: {\n beforeCursor: this.getBeforeCursor(),\n },\n })\n this.emit(\"change\", changeEvent)\n return changeEvent\n }\n\n /**\n * Emit a esc event, which hides dropdown element.\n * Child class must call this method at proper timing.\n *\n * @see {@link Textarea} for live example.\n */\n emitEscEvent(): CustomEvent {\n const escEvent = createCustomEvent(\"esc\", { cancelable: true })\n this.emit(\"esc\", escEvent)\n return escEvent\n }\n\n /**\n * Helper method for parsing KeyboardEvent.\n *\n * @see {@link Textarea} for live example.\n */\n getCode(e: KeyboardEvent): KeyCode {\n return e.keyCode === 9\n ? \"ENTER\" // tab\n : e.keyCode === 13\n ? \"ENTER\" // enter\n : e.keyCode === 27\n ? \"ESC\" // esc\n : e.keyCode === 38\n ? \"UP\" // up\n : e.keyCode === 40\n ? \"DOWN\" // down\n : e.keyCode === 78 && e.ctrlKey\n ? \"DOWN\" // ctrl-n\n : e.keyCode === 80 && e.ctrlKey\n ? \"UP\" // ctrl-p\n : \"OTHER\"\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/editor.js","import Textcomplete from \"./textcomplete\"\nimport Textarea from \"./textarea\"\n\nlet editors\nif (global.Textcomplete && global.Textcomplete.editors) {\n editors = global.Textcomplete.editors\n} else {\n editors = {}\n}\neditors.Textarea = Textarea\n\nglobal.Textcomplete = Textcomplete\nglobal.Textcomplete.editors = editors\n\n\n\n// WEBPACK FOOTER //\n// ./src/main.js","var g;\r\n\r\n// This works in non-strict mode\r\ng = (function() {\r\n\treturn this;\r\n})();\r\n\r\ntry {\r\n\t// This works if eval is allowed (see CSP)\r\n\tg = g || Function(\"return this\")() || (1,eval)(\"this\");\r\n} catch(e) {\r\n\t// This works if the window reference is available\r\n\tif(typeof window === \"object\")\r\n\t\tg = window;\r\n}\r\n\r\n// g can still be undefined, but nothing to do about it...\r\n// We return undefined, instead of nothing here, so it's\r\n// easier to handle this case. if(!global) { ...}\r\n\r\nmodule.exports = g;\r\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// (webpack)/buildin/global.js\n// module id = 6\n// module chunks = 0","// @flow\n\nimport Completer from \"./completer\"\nimport Editor from \"./editor\"\nimport Dropdown, { type DropdownOptions } from \"./dropdown\"\nimport Strategy, { type StrategyProperties } from \"./strategy\"\nimport SearchResult from \"./search_result\"\n\nimport EventEmitter from \"eventemitter3\"\n\nconst CALLBACK_METHODS = [\n \"handleChange\",\n \"handleEnter\",\n \"handleEsc\",\n \"handleHit\",\n \"handleMove\",\n \"handleSelect\",\n]\n\n/** @typedef */\ntype TextcompleteOptions = {\n dropdown?: DropdownOptions,\n}\n\n/**\n * The core of textcomplete. It acts as a mediator.\n */\nexport default class Textcomplete extends EventEmitter {\n dropdown: Dropdown\n editor: Editor\n options: TextcompleteOptions\n completer: Completer\n isQueryInFlight: boolean\n nextPendingQuery: string | null\n\n /**\n * @param {Editor} editor - Where the textcomplete works on.\n */\n constructor(editor: Editor, options: TextcompleteOptions = {}) {\n super()\n\n this.completer = new Completer()\n this.isQueryInFlight = false\n this.nextPendingQuery = null\n this.dropdown = new Dropdown(options.dropdown || {})\n this.editor = editor\n this.options = options\n\n CALLBACK_METHODS.forEach(method => {\n ;(this: any)[method] = (this: any)[method].bind(this)\n })\n\n this.startListening()\n }\n\n /**\n * @return {this}\n */\n destroy(destroyEditor: boolean = true) {\n this.completer.destroy()\n this.dropdown.destroy()\n if (destroyEditor) {\n this.editor.destroy()\n }\n this.stopListening()\n return this\n }\n\n /**\n * @return {this}\n */\n hide() {\n this.dropdown.deactivate()\n return this\n }\n\n /**\n * @return {this}\n * @example\n * textcomplete.register([{\n * match: /(^|\\s)(\\w+)$/,\n * search: function (term, callback) {\n * $.ajax({ ... })\n * .done(callback)\n * .fail([]);\n * },\n * replace: function (value) {\n * return '$1' + value + ' ';\n * }\n * }]);\n */\n register(strategyPropsArray: StrategyProperties[]) {\n strategyPropsArray.forEach(props => {\n this.completer.registerStrategy(new Strategy(props))\n })\n return this\n }\n\n /**\n * Start autocompleting.\n *\n * @param {string} text - Head to input cursor.\n * @return {this}\n */\n trigger(text: string) {\n if (this.isQueryInFlight) {\n this.nextPendingQuery = text\n } else {\n this.isQueryInFlight = true\n this.nextPendingQuery = null\n this.completer.run(text)\n }\n return this\n }\n\n /** @private */\n handleHit({ searchResults }: { searchResults: SearchResult[] }) {\n if (searchResults.length) {\n this.dropdown.render(searchResults, this.editor.getCursorOffset())\n } else {\n this.dropdown.deactivate()\n }\n this.isQueryInFlight = false\n if (this.nextPendingQuery !== null) {\n this.trigger(this.nextPendingQuery)\n }\n }\n\n /** @private */\n handleMove(e: CustomEvent) {\n e.detail.code === \"UP\" ? this.dropdown.up(e) : this.dropdown.down(e)\n }\n\n /** @private */\n handleEnter(e: CustomEvent) {\n const activeItem = this.dropdown.getActiveItem()\n if (activeItem) {\n this.dropdown.select(activeItem)\n e.preventDefault()\n } else {\n this.dropdown.deactivate()\n }\n }\n\n /** @private */\n handleEsc(e: CustomEvent) {\n if (this.dropdown.shown) {\n this.dropdown.deactivate()\n e.preventDefault()\n }\n }\n\n /** @private */\n handleChange(e: CustomEvent) {\n if (e.detail.beforeCursor != null) {\n this.trigger(e.detail.beforeCursor)\n } else {\n this.dropdown.deactivate()\n }\n }\n\n /** @private */\n handleSelect(selectEvent: CustomEvent) {\n this.emit(\"select\", selectEvent)\n if (!selectEvent.defaultPrevented) {\n this.editor.applySearchResult(selectEvent.detail.searchResult)\n }\n }\n\n /** @private */\n startListening() {\n this.editor\n .on(\"move\", this.handleMove)\n .on(\"enter\", this.handleEnter)\n .on(\"esc\", this.handleEsc)\n .on(\"change\", this.handleChange)\n this.dropdown.on(\"select\", this.handleSelect)\n ;[\n \"show\",\n \"shown\",\n \"render\",\n \"rendered\",\n \"selected\",\n \"hidden\",\n \"hide\",\n ].forEach(eventName => {\n this.dropdown.on(eventName, () => this.emit(eventName))\n })\n this.completer.on(\"hit\", this.handleHit)\n }\n\n /** @private */\n stopListening() {\n this.completer.removeAllListeners()\n this.dropdown.removeAllListeners()\n this.editor\n .removeListener(\"move\", this.handleMove)\n .removeListener(\"enter\", this.handleEnter)\n .removeListener(\"esc\", this.handleEsc)\n .removeListener(\"change\", this.handleChange)\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/textcomplete.js","// @flow\n\nimport EventEmitter from \"eventemitter3\"\n\nimport Query from \"./query\"\nimport SearchResult from \"./search_result\"\nimport Strategy from \"./strategy\"\n\nconst CALLBACK_METHODS = [\"handleQueryResult\"]\n\n/**\n * Complete engine.\n */\nexport default class Completer extends EventEmitter {\n strategies: Strategy[]\n\n constructor() {\n super()\n this.strategies = []\n\n CALLBACK_METHODS.forEach(method => {\n ;(this: any)[method] = (this: any)[method].bind(this)\n })\n }\n\n /**\n * @return {this}\n */\n destroy() {\n this.strategies.forEach(strategy => strategy.destroy())\n return this\n }\n\n /**\n * Register a strategy to the completer.\n *\n * @return {this}\n */\n registerStrategy(strategy: Strategy) {\n this.strategies.push(strategy)\n return this\n }\n\n /**\n * @param {string} text - Head to input cursor.\n */\n run(text: string): void {\n const query = this.extractQuery(text)\n if (query) {\n query.execute(this.handleQueryResult)\n } else {\n this.handleQueryResult([])\n }\n }\n\n /**\n * Find a query, which matches to the given text.\n *\n * @private\n */\n extractQuery(text: string) {\n for (let i = 0; i < this.strategies.length; i++) {\n const query = Query.build(this.strategies[i], text)\n if (query) {\n return query\n }\n }\n return null\n }\n\n /**\n * Callbacked by {@link Query#execute}.\n *\n * @private\n */\n handleQueryResult(searchResults: SearchResult[]) {\n this.emit(\"hit\", { searchResults })\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/completer.js","// @flow\n\nimport SearchResult from \"./search_result\"\nimport Strategy from \"./strategy\"\nimport type { MatchData } from \"./strategy\"\n\n/**\n * Encapsulate matching condition between a Strategy and current editor's value.\n */\nexport default class Query {\n strategy: Strategy\n term: string\n match: MatchData\n\n /**\n * Build a Query object by the given string if this matches to the string.\n *\n * @param {string} text - Head to input cursor.\n */\n static build(strategy: Strategy, text: string): ?Query {\n if (typeof strategy.props.context === \"function\") {\n const context = strategy.props.context(text)\n if (typeof context === \"string\") {\n text = context\n } else if (!context) {\n return null\n }\n }\n const match = strategy.matchText(text)\n return match ? new Query(strategy, match[strategy.index], match) : null\n }\n\n constructor(strategy: Strategy, term: string, match: MatchData) {\n this.strategy = strategy\n this.term = term\n this.match = match\n }\n\n /**\n * Invoke search strategy and callback the given function.\n */\n execute(callback: (SearchResult[]) => void) {\n this.strategy.search(\n this.term,\n results => {\n callback(\n results.map(result => {\n return new SearchResult(result, this.term, this.strategy)\n }),\n )\n },\n this.match,\n )\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/query.js","// @flow\nimport EventEmitter from \"eventemitter3\"\n\nimport DropdownItem, { type DropdownItemOptions } from \"./dropdown_item\"\nimport SearchResult from \"./search_result\"\nimport { createCustomEvent } from \"./utils\"\nimport type { CursorOffset } from \"./editor\"\n\nconst DEFAULT_CLASS_NAME = \"dropdown-menu textcomplete-dropdown\"\n\n/** @typedef */\nexport type DropdownOptions = {\n className?: string,\n footer?: any => string | string,\n header?: any => string | string,\n maxCount?: number,\n placement?: string,\n rotate?: boolean,\n style?: { [string]: string },\n item?: DropdownItemOptions,\n}\n\n/**\n * Encapsulate a dropdown view.\n *\n * @prop {boolean} shown - Whether the #el is shown or not.\n * @prop {DropdownItem[]} items - The array of rendered dropdown items.\n */\nexport default class Dropdown extends EventEmitter {\n shown: boolean\n items: DropdownItem[]\n activeItem: DropdownItem | null\n footer: $PropertyType\n header: $PropertyType\n maxCount: $PropertyType\n rotate: $PropertyType\n placement: $PropertyType\n itemOptions: DropdownItemOptions\n _el: ?HTMLUListElement\n\n static createElement(): HTMLUListElement {\n const el = document.createElement(\"ul\")\n const style = el.style\n style.display = \"none\"\n style.position = \"absolute\"\n style.zIndex = \"10000\"\n const body = document.body\n if (body) {\n body.appendChild(el)\n }\n return el\n }\n\n constructor(options: DropdownOptions) {\n super()\n this.shown = false\n this.items = []\n this.activeItem = null\n this.footer = options.footer\n this.header = options.header\n this.maxCount = options.maxCount || 10\n this.el.className = options.className || DEFAULT_CLASS_NAME\n this.rotate = options.hasOwnProperty(\"rotate\") ? options.rotate : true\n this.placement = options.placement\n this.itemOptions = options.item || {}\n const style = options.style\n if (style) {\n Object.keys(style).forEach(key => {\n ;(this.el.style: any)[key] = style[key]\n })\n }\n }\n\n /**\n * @return {this}\n */\n destroy() {\n const parentNode = this.el.parentNode\n if (parentNode) {\n parentNode.removeChild(this.el)\n }\n this.clear()._el = null\n return this\n }\n\n get el(): HTMLUListElement {\n if (!this._el) {\n this._el = Dropdown.createElement()\n }\n return this._el\n }\n\n /**\n * Render the given data as dropdown items.\n *\n * @return {this}\n */\n render(searchResults: SearchResult[], cursorOffset: CursorOffset) {\n const renderEvent = createCustomEvent(\"render\", { cancelable: true })\n this.emit(\"render\", renderEvent)\n if (renderEvent.defaultPrevented) {\n return this\n }\n const rawResults = searchResults.map(searchResult => searchResult.data)\n const dropdownItems = searchResults\n .slice(0, this.maxCount || searchResults.length)\n .map(searchResult => new DropdownItem(searchResult, this.itemOptions))\n this.clear()\n .setStrategyId(searchResults[0])\n .renderEdge(rawResults, \"header\")\n .append(dropdownItems)\n .renderEdge(rawResults, \"footer\")\n .show()\n .setOffset(cursorOffset)\n this.emit(\"rendered\", createCustomEvent(\"rendered\"))\n return this\n }\n\n /**\n * Hide the dropdown then sweep out items.\n *\n * @return {this}\n */\n deactivate() {\n return this.hide().clear()\n }\n\n /**\n * @return {this}\n */\n select(dropdownItem: DropdownItem) {\n const detail = { searchResult: dropdownItem.searchResult }\n const selectEvent = createCustomEvent(\"select\", {\n cancelable: true,\n detail: detail,\n })\n this.emit(\"select\", selectEvent)\n if (selectEvent.defaultPrevented) {\n return this\n }\n this.deactivate()\n this.emit(\"selected\", createCustomEvent(\"selected\", { detail }))\n return this\n }\n\n /**\n * @return {this}\n */\n up(e: CustomEvent) {\n return this.shown ? this.moveActiveItem(\"prev\", e) : this\n }\n\n /**\n * @return {this}\n */\n down(e: CustomEvent) {\n return this.shown ? this.moveActiveItem(\"next\", e) : this\n }\n\n /**\n * Retrieve the active item.\n */\n getActiveItem(): DropdownItem | null {\n return this.activeItem\n }\n\n /**\n * Add items to dropdown.\n *\n * @private\n */\n append(items: DropdownItem[]) {\n const fragment = document.createDocumentFragment()\n items.forEach(item => {\n this.items.push(item)\n item.appended(this)\n fragment.appendChild(item.el)\n })\n this.el.appendChild(fragment)\n return this\n }\n\n /** @private */\n setOffset(cursorOffset: CursorOffset) {\n const doc = document.documentElement\n if (doc) {\n const elementWidth = this.el.offsetWidth\n if (cursorOffset.left) {\n const browserWidth = doc.clientWidth\n if (cursorOffset.left + elementWidth > browserWidth) {\n cursorOffset.left = browserWidth - elementWidth\n }\n this.el.style.left = `${cursorOffset.left}px`\n } else if (cursorOffset.right) {\n if (cursorOffset.right - elementWidth < 0) {\n cursorOffset.right = 0\n }\n this.el.style.right = `${cursorOffset.right}px`\n }\n if (this.isPlacementTop()) {\n this.el.style.bottom = `${doc.clientHeight -\n cursorOffset.top +\n cursorOffset.lineHeight}px`\n } else {\n this.el.style.top = `${cursorOffset.top}px`\n }\n }\n return this\n }\n\n /**\n * Show the element.\n *\n * @private\n */\n show() {\n if (!this.shown) {\n const showEvent = createCustomEvent(\"show\", { cancelable: true })\n this.emit(\"show\", showEvent)\n if (showEvent.defaultPrevented) {\n return this\n }\n this.el.style.display = \"block\"\n this.shown = true\n this.emit(\"shown\", createCustomEvent(\"shown\"))\n }\n return this\n }\n\n /**\n * Hide the element.\n *\n * @private\n */\n hide() {\n if (this.shown) {\n const hideEvent = createCustomEvent(\"hide\", { cancelable: true })\n this.emit(\"hide\", hideEvent)\n if (hideEvent.defaultPrevented) {\n return this\n }\n this.el.style.display = \"none\"\n this.shown = false\n this.emit(\"hidden\", createCustomEvent(\"hidden\"))\n }\n return this\n }\n\n /**\n * Clear search results.\n *\n * @private\n */\n clear() {\n this.el.innerHTML = \"\"\n this.items.forEach(item => item.destroy())\n this.items = []\n return this\n }\n\n /** @private */\n moveActiveItem(direction: \"next\" | \"prev\", e: CustomEvent) {\n const nextActiveItem =\n direction === \"next\"\n ? this.activeItem ? this.activeItem.next : this.items[0]\n : this.activeItem\n ? this.activeItem.prev\n : this.items[this.items.length - 1]\n if (nextActiveItem) {\n nextActiveItem.activate()\n e.preventDefault()\n }\n return this\n }\n\n /** @private */\n setStrategyId(searchResult: ?SearchResult) {\n const strategyId = searchResult && searchResult.strategy.props.id\n if (strategyId) {\n this.el.setAttribute(\"data-strategy\", strategyId)\n } else {\n this.el.removeAttribute(\"data-strategy\")\n }\n return this\n }\n\n /**\n * @private\n * @param {object[]} rawResults - What callbacked by search function.\n */\n renderEdge(rawResults: Object[], type: \"header\" | \"footer\") {\n const source = (type === \"header\" ? this.header : this.footer) || \"\"\n const content: any =\n typeof source === \"function\" ? source(rawResults) : source\n const li = document.createElement(\"li\")\n li.classList.add(`textcomplete-${type}`)\n li.innerHTML = content\n this.el.appendChild(li)\n return this\n }\n\n /** @private */\n isPlacementTop() {\n return this.placement === \"top\"\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/dropdown.js","// @flow\n\nimport SearchResult from \"./search_result\"\n\nexport const DEFAULT_CLASS_NAME = \"textcomplete-item\"\nconst CALLBACK_METHODS = [\"onClick\", \"onMouseover\"]\n\n/** @typedef */\nexport type DropdownItemOptions = {\n className?: string,\n}\n\n// Declare interface instead of importing Dropdown itself to prevent circular dependency.\ninterface Dropdown {\n activeItem: DropdownItem | null;\n items: DropdownItem[];\n rotate: ?Boolean;\n getActiveItem(): DropdownItem | null;\n select(DropdownItem): DropdownItem;\n}\n\n/**\n * Encapsulate an item of dropdown.\n */\nexport default class DropdownItem {\n searchResult: SearchResult\n active: boolean\n className: string\n activeClassName: string\n siblings: DropdownItem[]\n dropdown: Dropdown\n index: number\n _el: ?HTMLLIElement\n\n constructor(searchResult: SearchResult, options: DropdownItemOptions) {\n this.searchResult = searchResult\n this.active = false\n this.className = options.className || DEFAULT_CLASS_NAME\n this.activeClassName = `${this.className} active`\n\n CALLBACK_METHODS.forEach(method => {\n ;(this: any)[method] = (this: any)[method].bind(this)\n })\n }\n\n get el(): HTMLLIElement {\n if (this._el) {\n return this._el\n }\n const li = document.createElement(\"li\")\n li.className = this.active ? this.activeClassName : this.className\n const a = document.createElement(\"a\")\n a.innerHTML = this.searchResult.render()\n li.appendChild(a)\n this._el = li\n li.addEventListener(\"mousedown\", this.onClick)\n li.addEventListener(\"mouseover\", this.onMouseover)\n li.addEventListener(\"touchstart\", this.onClick)\n return li\n }\n\n /**\n * Try to free resources and perform other cleanup operations.\n */\n destroy() {\n this.el.removeEventListener(\"mousedown\", this.onClick, false)\n this.el.removeEventListener(\"mouseover\", this.onMouseover, false)\n this.el.removeEventListener(\"touchstart\", this.onClick, false)\n if (this.active) {\n this.dropdown.activeItem = null\n }\n // This element has already been removed by {@link Dropdown#clear}.\n this._el = null\n }\n\n /**\n * Callbacked when it is appended to a dropdown.\n *\n * @see Dropdown#append\n */\n appended(dropdown: Dropdown) {\n this.dropdown = dropdown\n this.siblings = dropdown.items\n this.index = this.siblings.length - 1\n }\n\n /**\n * Deactivate active item then activate itself.\n *\n * @return {this}\n */\n activate() {\n if (!this.active) {\n const activeItem = this.dropdown.getActiveItem()\n if (activeItem) {\n activeItem.deactivate()\n }\n this.dropdown.activeItem = this\n this.active = true\n this.el.className = this.activeClassName\n }\n return this\n }\n\n /**\n * Get the next sibling.\n */\n get next(): ?DropdownItem {\n let nextIndex\n if (this.index === this.siblings.length - 1) {\n if (!this.dropdown.rotate) {\n return null\n }\n nextIndex = 0\n } else {\n nextIndex = this.index + 1\n }\n return this.siblings[nextIndex]\n }\n\n /**\n * Get the previous sibling.\n */\n get prev(): ?DropdownItem {\n let nextIndex\n if (this.index === 0) {\n if (!this.dropdown.rotate) {\n return null\n }\n nextIndex = this.siblings.length - 1\n } else {\n nextIndex = this.index - 1\n }\n return this.siblings[nextIndex]\n }\n\n /** @private */\n deactivate() {\n if (this.active) {\n this.active = false\n this.el.className = this.className\n this.dropdown.activeItem = null\n }\n return this\n }\n\n /** @private */\n onClick(e: Event) {\n e.preventDefault() // Prevent blur event\n this.dropdown.select(this)\n }\n\n /** @private */\n onMouseover() {\n this.activate()\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/dropdown_item.js","// @flow\n\nimport update from \"undate/lib/update\"\n\nimport Editor from \"./editor\"\nimport { calculateElementOffset, getLineHeightPx } from \"./utils\"\nimport SearchResult from \"./search_result\"\n\nconst getCaretCoordinates = require(\"textarea-caret\")\n\nconst CALLBACK_METHODS = [\"onInput\", \"onKeydown\"]\n\n/**\n * Encapsulate the target textarea element.\n */\nexport default class Textarea extends Editor {\n el: HTMLTextAreaElement\n\n /**\n * @param {HTMLTextAreaElement} el - Where the textcomplete works on.\n */\n constructor(el: HTMLTextAreaElement) {\n super()\n this.el = el\n\n CALLBACK_METHODS.forEach(method => {\n ;(this: any)[method] = (this: any)[method].bind(this)\n })\n\n this.startListening()\n }\n\n /**\n * @return {this}\n */\n destroy() {\n super.destroy()\n this.stopListening()\n // Release the element reference early to help garbage collection.\n ;(this: any).el = null\n return this\n }\n\n /**\n * Implementation for {@link Editor#applySearchResult}\n */\n applySearchResult(searchResult: SearchResult) {\n const before = this.getBeforeCursor()\n if (before != null) {\n const replace = searchResult.replace(before, this.getAfterCursor())\n this.el.focus() // Clicking a dropdown item removes focus from the element.\n if (Array.isArray(replace)) {\n update(this.el, replace[0], replace[1])\n this.el.dispatchEvent(new Event(\"input\"))\n }\n }\n }\n\n /**\n * Implementation for {@link Editor#getCursorOffset}\n */\n getCursorOffset() {\n const elOffset = calculateElementOffset(this.el)\n const elScroll = this.getElScroll()\n const cursorPosition = this.getCursorPosition()\n const lineHeight = getLineHeightPx(this.el)\n const top = elOffset.top - elScroll.top + cursorPosition.top + lineHeight\n const left = elOffset.left - elScroll.left + cursorPosition.left\n if (this.el.dir !== \"rtl\") {\n return { top, left, lineHeight }\n } else {\n const right = document.documentElement\n ? document.documentElement.clientWidth - left\n : 0\n return { top, right, lineHeight }\n }\n }\n\n /**\n * Implementation for {@link Editor#getBeforeCursor}\n */\n getBeforeCursor() {\n return this.el.selectionStart !== this.el.selectionEnd\n ? null\n : this.el.value.substring(0, this.el.selectionEnd)\n }\n\n /** @private */\n getAfterCursor() {\n return this.el.value.substring(this.el.selectionEnd)\n }\n\n /** @private */\n getElScroll(): { top: number, left: number } {\n return { top: this.el.scrollTop, left: this.el.scrollLeft }\n }\n\n /**\n * The input cursor's relative coordinates from the textarea's left\n * top corner.\n *\n * @private\n */\n getCursorPosition(): { top: number, left: number } {\n return getCaretCoordinates(this.el, this.el.selectionEnd)\n }\n\n /** @private */\n onInput() {\n this.emitChangeEvent()\n }\n\n /** @private */\n onKeydown(e: KeyboardEvent) {\n const code = this.getCode(e)\n let event\n if (code === \"UP\" || code === \"DOWN\") {\n event = this.emitMoveEvent(code)\n } else if (code === \"ENTER\") {\n event = this.emitEnterEvent()\n } else if (code === \"ESC\") {\n event = this.emitEscEvent()\n }\n if (event && event.defaultPrevented) {\n e.preventDefault()\n }\n }\n\n /** @private */\n startListening() {\n this.el.addEventListener(\"input\", this.onInput)\n this.el.addEventListener(\"keydown\", this.onKeydown)\n }\n\n /** @private */\n stopListening() {\n this.el.removeEventListener(\"input\", this.onInput)\n this.el.removeEventListener(\"keydown\", this.onKeydown)\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/textarea.js","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nexports.default = function (el, headToCursor, cursorToTail) {\n var curr = el.value,\n // strA + strB1 + strC\n next = headToCursor + (cursorToTail || ''),\n // strA + strB2 + strC\n activeElement = document.activeElement;\n\n // Calculate length of strA and strC\n var aLength = 0,\n cLength = 0;\n while (aLength < curr.length && aLength < next.length && curr[aLength] === next[aLength]) {\n aLength++;\n }\n while (curr.length - cLength - 1 >= 0 && next.length - cLength - 1 >= 0 && curr[curr.length - cLength - 1] === next[next.length - cLength - 1]) {\n cLength++;\n }\n aLength = Math.min(aLength, Math.min(curr.length, next.length) - cLength);\n\n // Select strB1\n el.setSelectionRange(aLength, curr.length - cLength);\n\n // Get strB2\n var strB2 = next.substring(aLength, next.length - cLength);\n\n // Replace strB1 with strB2\n el.focus();\n if (!document.execCommand('insertText', false, strB2)) {\n // Document.execCommand returns false if the command is not supported.\n // Firefox and IE returns false in this case.\n el.value = next;\n el.dispatchEvent(createInputEvent());\n }\n\n // Move cursor to the end of headToCursor\n el.setSelectionRange(headToCursor.length, headToCursor.length);\n\n activeElement && activeElement.focus();\n return el;\n};\n\nfunction createInputEvent() {\n if (typeof Event !== \"undefined\") {\n return new Event(\"input\", { bubbles: true, cancelable: true });\n } else {\n var event = document.createEvent(\"Event\");\n event.initEvent(\"input\", true, true);\n return event;\n }\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/undate/lib/update.js\n// module id = 13\n// module chunks = 0","/* jshint browser: true */\n\n(function () {\n\n// The properties that we copy into a mirrored div.\n// Note that some browsers, such as Firefox,\n// do not concatenate properties, i.e. padding-top, bottom etc. -> padding,\n// so we have to do every single property specifically.\nvar properties = [\n 'direction', // RTL support\n 'boxSizing',\n 'width', // on Chrome and IE, exclude the scrollbar, so the mirror div wraps exactly as the textarea does\n 'height',\n 'overflowX',\n 'overflowY', // copy the scrollbar for IE\n\n 'borderTopWidth',\n 'borderRightWidth',\n 'borderBottomWidth',\n 'borderLeftWidth',\n 'borderStyle',\n\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n\n // https://developer.mozilla.org/en-US/docs/Web/CSS/font\n 'fontStyle',\n 'fontVariant',\n 'fontWeight',\n 'fontStretch',\n 'fontSize',\n 'fontSizeAdjust',\n 'lineHeight',\n 'fontFamily',\n\n 'textAlign',\n 'textTransform',\n 'textIndent',\n 'textDecoration', // might not make a difference, but better be safe\n\n 'letterSpacing',\n 'wordSpacing',\n\n 'tabSize',\n 'MozTabSize'\n\n];\n\nvar isBrowser = (typeof window !== 'undefined');\nvar isFirefox = (isBrowser && window.mozInnerScreenX != null);\n\nfunction getCaretCoordinates(element, position, options) {\n if(!isBrowser) {\n throw new Error('textarea-caret-position#getCaretCoordinates should only be called in a browser');\n }\n\n var debug = options && options.debug || false;\n if (debug) {\n var el = document.querySelector('#input-textarea-caret-position-mirror-div');\n if ( el ) { el.parentNode.removeChild(el); }\n }\n\n // mirrored div\n var div = document.createElement('div');\n div.id = 'input-textarea-caret-position-mirror-div';\n document.body.appendChild(div);\n\n var style = div.style;\n var computed = window.getComputedStyle? getComputedStyle(element) : element.currentStyle; // currentStyle for IE < 9\n\n // default textarea styles\n style.whiteSpace = 'pre-wrap';\n if (element.nodeName !== 'INPUT')\n style.wordWrap = 'break-word'; // only for textarea-s\n\n // position off-screen\n style.position = 'absolute'; // required to return coordinates properly\n if (!debug)\n style.visibility = 'hidden'; // not 'display: none' because we want rendering\n\n // transfer the element's properties to the div\n properties.forEach(function (prop) {\n style[prop] = computed[prop];\n });\n\n if (isFirefox) {\n // Firefox lies about the overflow property for textareas: https://bugzilla.mozilla.org/show_bug.cgi?id=984275\n if (element.scrollHeight > parseInt(computed.height))\n style.overflowY = 'scroll';\n } else {\n style.overflow = 'hidden'; // for Chrome to not render a scrollbar; IE keeps overflowY = 'scroll'\n }\n\n div.textContent = element.value.substring(0, position);\n // the second special handling for input type=\"text\" vs textarea: spaces need to be replaced with non-breaking spaces - http://stackoverflow.com/a/13402035/1269037\n if (element.nodeName === 'INPUT')\n div.textContent = div.textContent.replace(/\\s/g, '\\u00a0');\n\n var span = document.createElement('span');\n // Wrapping must be replicated *exactly*, including when a long word gets\n // onto the next line, with whitespace at the end of the line before (#7).\n // The *only* reliable way to do that is to copy the *entire* rest of the\n // textarea's content into the created at the caret position.\n // for inputs, just '.' would be enough, but why bother?\n span.textContent = element.value.substring(position) || '.'; // || because a completely empty faux span doesn't render at all\n div.appendChild(span);\n\n var coordinates = {\n top: span.offsetTop + parseInt(computed['borderTopWidth']),\n left: span.offsetLeft + parseInt(computed['borderLeftWidth'])\n };\n\n if (debug) {\n span.style.backgroundColor = '#aaa';\n } else {\n document.body.removeChild(div);\n }\n\n return coordinates;\n}\n\nif (typeof module != 'undefined' && typeof module.exports != 'undefined') {\n module.exports = getCaretCoordinates;\n} else if(isBrowser){\n window.getCaretCoordinates = getCaretCoordinates;\n}\n\n}());\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/textarea-caret/index.js\n// module id = 14\n// module chunks = 0"],"sourceRoot":""} \ No newline at end of file -- cgit v1.2.3