gwt-material-addins
gwt-material-addins copied to clipboard
Mention functionality for MaterialRichEditor
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:
- Being able to receive the plain text (but also)
- 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.
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)
Would love this feature!
Any way I can contribute to the java part?
@mvanrobaeys Feel free to submit PR then we can review.