UNPKG

@nextcloud/vue

Version:
1 lines 2.33 kB
{"version":3,"file":"emoji.mjs","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":";;AAgCY,MAACA,IAAc,SAASC,GAAOC,IAAa,IAAI;AAC3D,QAAMC,IAAQ,IAAIC,EAAWC,CAAI;AACjC,MAAIJ,GAAO;AACV,QAAIK,IAAUH,EAAM,OAAO,IAAIF,KAASC,CAAU;AAClD,WAAII,EAAQ,SAASJ,MACpBI,IAAUA,EAAQ,OAAOH,EAAM,OAAOF,GAAOC,IAAaI,EAAQ,MAAM,CAAC,IAEnEA;AAAAA,EAGR;AAAA,SAAOC,EAAW,IAAIL,CAAU,EAAE,IAAKM,CAAAA,MAAOL,EAAM,MAAMK,CAAE,CAAC,KAAK,CAAE;AACrE,GAEaC,IAAiB,SAASD,GAAI;AAC1CD,EAAAA,EAAW,IAAIC,CAAE;AAClB;"}