gwt-material-addins icon indicating copy to clipboard operation
gwt-material-addins copied to clipboard

Mention functionality for MaterialRichEditor

Open ghost opened this issue 9 years ago • 3 comments

I'd love to see the "Mention" functionality in the addins module as described on

http://summernote.org/examples/#hint-for-mention

Just speaking of my personal requirements:

I'd like to be able to mention items inside a rich editor that allows user to refer to something using e.g. # as it is done on twitter like:

This week we offer #item1 
in combination with #item2.

It would be awesome to be able to retrieve this content in a parseable manner. What I mean by that is that I'd like to translate the HTML content into a XML format. Two things would be important:

  1. Being able to receive the plain text (but also)
  2. being able to retrieve the mentioned entities intact in the sense of getting e.g. their IDs

For example having:

This week we offer <span id="item-1">#item1</span> 
in combination with <span id="item-2">#item2</span>.

As can be seen in this summernote example, and if I understand that correctly, one would only have to provide a function for content:

$(".hint2mention").summernote({
  height: 100,
  toolbar: false,
  hint: {
    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;
    }    
  }
});

I've tried to implement something like this myself but it's simply an insanely complicated task - at least from what I can tell here.

ghost avatar Jun 22 '16 23:06 ghost

This addin will be in 2.0 (Because we dont want to code it on JSNI, JSInterop will be perfect and would be on gwt-material-addins 2.0)

kevzlou7979 avatar Jun 27 '16 13:06 kevzlou7979

Would love this feature!
Any way I can contribute to the java part?

mvanrobaeys avatar Mar 17 '17 16:03 mvanrobaeys

@mvanrobaeys Feel free to submit PR then we can review.

kevzlou7979 avatar Mar 19 '17 22:03 kevzlou7979