2016-12-29 4 views
1

誰かがエースエディタのカスタムオートコンプリート方法を教えてくれますか?オートコンプリートエースエディタにhtmlを追加するには?

emoji

このエディタは、私のためにうまく機能ですが、私はオートコンプリートの結果に絵文字画像を挿入する必要があります。 は、私は以下のようにemoji imagesなどを表示する必要があります。

var editor = ace.edit('editor'); 
editor.setTheme('ace/theme/github'); 
editor.getSession().setMode('ace/mode/markdown'); 
editor.$blockScrolling = Infinity; //prevents ace from logging annoying warnings 
editor.getSession().on('change', function() { 
    draceditor.val(editor.getSession().getValue()); 
}); 
editor.setOptions({ 
    enableBasicAutocompletion: true, 
    enableSnippets: true, 
    enableLiveAutocompletion: true 
}); 

// Ace autocomplete 
var emojiWordCompleter = { 
    getCompletions: function(editor, session, pos, prefix, callback) { 
     var wordList = emojis; // list emojis from `atwho/emojis.min.js` 
     var obj = editor.getSession().getTokenAt(pos.row, pos.column.count); 
     var curTokens = obj.value.split(/\s+/); 
     var lastToken = curTokens[curTokens.length-1]; 

     if (lastToken[0] == ':') { 
      console.log(lastToken); 
      callback(null, wordList.map(function(word) { 
       return { 
        caption: word, 
        value: word.replace(':', '') + ' ', 
        meta: 'emoji' // this should return as text only. 
       }; 
      })); 
     } 
    } 
} 
editor.completers = [emojiWordCompleter] 

私の悪い考えでは、私はこのmeta: '<img src="/path/to/emoji.png">'と試みるが、もちろんそれは、仕事することはできません。

これを解決する方法はありますか?あまり前にありがとう..

答えて

関連する問題