These are chat archives for GetmeUK/ContentTools

28th
Oct 2015
Luis Vegerano
@lvegerano
Oct 28 2015 01:41
Is there a way to intercept user input to apply some tags based on a text pattern?
Benjamin Intal
@bfintal
Oct 28 2015 04:19
You'll have to extend ContentEdit.Text._onKeyUp to grab the content, then to apply the tags, you'll have to call this.attr(...)
Anthony Blackshaw
@anthonyjb
Oct 28 2015 08:02
This message was deleted

Hi @lvegerano, as @bfintal suggested you could look to override ContentEdit.Text._onKeyUp, the other option that might be worth exploring is binding to the taint event:

ContentEdit.Root.get().bind('taint', function (element) {

    // We're only interested in elements that have text content
    if (element.content === undefined) {
        return;
    }

    // Using the element's content check for pattern matches
   ...
});

element.content will be a HTMLString instance (http://getcontenttools.com/api/html-string).

Luis Vegerano
@lvegerano
Oct 28 2015 13:55
@bfintal @anthonyjb thanks
I will give that a try