UNPKG

@nextcloud/vue

Version:
1 lines 2.31 kB
{"version":3,"file":"emoji.cjs","sources":["../../src/functions/emoji/emoji.js"],"sourcesContent":["/**\n * @copyright Copyright (c) 2021 Jonas Meurer <jonas@freesources.org>\n *\n * @author Jonas Meurer <jonas@freesources.org>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport data from 'emoji-mart-vue-fast/data/all.json'\nimport { EmojiIndex, frequently } from 'emoji-mart-vue-fast'\n\n// export const allEmojis = index.buildIndex()\n\n/**\n * @param {string} query Emoji search string\n * @param {number} maxResults Maximum of returned emojis\n * @return {Array} list of found emojis\n */\nexport const emojiSearch = function(query, maxResults = 10) {\n\tconst index = new EmojiIndex(data)\n\tif (query) {\n\t\tlet results = index.search(`:${query}`, maxResults)\n\t\tif (results.length < maxResults) {\n\t\t\tresults = results.concat(index.search(query, maxResults - results.length))\n\t\t}\n\t\treturn results\n\t}\n\n\treturn frequently.get(maxResults).map((id) => index.emoji(id)) || []\n}\n\nexport const emojiAddRecent = function(id) {\n\tfrequently.add(id)\n}\n\nexport default { emojiSearch, emojiAddRecent }\n"],"names":["emojiSearch","query","maxResults","index","EmojiIndex","data","results","frequently","id","emojiAddRecent"],"mappings":"sKAgCaA,EAAc,SAASC,EAAOC,EAAa,GAAI,CAC3D,MAAMC,EAAQ,IAAIC,EAAU,WAACC,CAAI,EACjC,GAAIJ,EAAO,CACV,IAAIK,EAAUH,EAAM,OAAO,IAAIF,CAAAA,GAASC,CAAU,EAClD,OAAII,EAAQ,OAASJ,IACpBI,EAAUA,EAAQ,OAAOH,EAAM,OAAOF,EAAOC,EAAaI,EAAQ,MAAM,CAAC,GAEnEA,EAGR,OAAOC,aAAW,IAAIL,CAAU,EAAE,IAAKM,GAAOL,EAAM,MAAMK,CAAE,CAAC,GAAK,CAAE,CACrE,EAEaC,EAAiB,SAASD,EAAI,CAC1CD,EAAU,WAAC,IAAIC,CAAE,CAClB"}