%PDF- %PDF-
Direktori : /var/www/projetos/suporte.iigd.com.br.old/js/RichText/ |
Current File : /var/www/projetos/suporte.iigd.com.br.old/js/RichText/UserMention.min.js |
/** * --------------------------------------------------------------------- * * GLPI - Gestionnaire Libre de Parc Informatique * * http://glpi-project.org * * @copyright 2015-2022 Teclib' and contributors. * @copyright 2003-2014 by the INDEPNET Development Team. * @licence https://www.gnu.org/licenses/gpl-3.0.html * * --------------------------------------------------------------------- * * LICENSE * * This file is part of GLPI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * * --------------------------------------------------------------------- */ var GLPI=GLPI||{};GLPI.RichText=GLPI.RichText||{};GLPI.RichText.UserMention=class{constructor(t,e,n){this.editor=t;this.activeEntity=e;this.idorToken=n}register(){const t=this;this.editor.ui.registry.addAutocompleter("user_mention",{ch:"@",minChars:0,fetch:function(e){return t.fetchItems(e)},onAction:function(e,n,i){t.mentionUser(e,n,i)}})}fetchItems(t){const e=this;return new Promise((function(n){$.post(CFG_GLPI.root_doc+"/ajax/getDropdownUsers.php",{entity_restrict:e.activeEntity,right:"all",display_emptychoice:0,searchText:t,_idor_token:e.idorToken}).done((function(t){const e=t.results.map((function(t){return{type:"autocompleteitem",value:JSON.stringify({id:t.id,name:t.text}),text:t.text}}));n(e)}))}))}mentionUser(t,e,n){const i=JSON.parse(n);this.editor.selection.setRng(e);this.editor.insertContent(this.generateUserMentionHtml(i));t.hide()}generateUserMentionHtml(t){return`<span contenteditable="false"\n data-user-mention="true"\n data-user-id="${t.id}">@${t.name}</span> `}};