【问题标题】:Summernote - how to combine Emojis and Mentions?Summernote - 如何结合表情符号和提及?
【发布时间】:2020-02-18 21:23:52
【问题描述】:

我不得不说,我对 JS 的了解为零,所以我像 CPP 和 PHP 等其他语言一样看待它,但不知道这种语言的任何功能。所以我需要你的帮助。如何在一个 Summernote 窗口中结合提示:提及和表情符号?

当我一个接一个地粘贴时,第一个不起作用。当我结合它。提及开始看起来像 [img]:name: 而不仅仅是 The_Name

在这里链接,检查一下,请告诉我如何组合它!请谢谢 https://summernote.org/examples/#multiple-editor

【问题讨论】:

    标签: emoji summernote mention


    【解决方案1】:

    你应该使用提示数组:

    hint: [{
              match: /:([\-+\w]+)$/,
              search: function (keyword, callback) {
                callback($.grep(emojis, function (item) {
                  return item.indexOf(keyword)  === 0;
                }));
              },
              template: function (item) {
                var content = emojiUrls[item];
                return '<img src="' + content + '" width="20" /> :' + item + ':';
              },
              content: function (item) {
                var url = emojiUrls[item];
                if (url) {
                  return $('<img />').attr('src', url).css('width', 20)[0];
                }
                return '';
              }
            },
            {
                mentions: ['jayden', 'sam', 'alvin', 'david'],
                match: /\B@(\w*)$/,
                search: function (keyword, callback) {
                  callback($.grep(this.mentions, function (item) {
                    return item.indexOf(keyword) == 0;
                  }));
                },
                content: function (item) {
                  return '@' + item;
                }    
              }]
    

    【讨论】:

      猜你喜欢
      • 2018-04-23
      • 2018-03-07
      • 2021-09-21
      • 2016-07-13
      • 1970-01-01
      • 2018-12-13
      • 1970-01-01
      • 1970-01-01
      • 2018-08-22
      相关资源
      最近更新 更多