Coder Social home page Coder Social logo

shotishu / tinymce-mention Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stevendevooght/tinymce-mention

0.0 2.0 0.0 545 KB

Mention/Autocomplete plugin for tinyMCE WYSIWYG editor.

Home Page: http://cognistreamer.github.io/tinyMCE-mention/

tinymce-mention's Introduction

#tinyMCE mention

Mentions plugin for tinyMCE WYSIWYG editor.

preview

##Browser compatibility

  • IE7+
  • Chrome
  • Safari
  • Firefox
  • Opera

##Dependencies

NOTE: Use v1.0.0 if you're using tinyMCE v3.5.x, use v2.0.0 if you're using tinyMCE v4.0.x

##Usage

Copy the source of the plugin to the plugins directory of your tinyMCE installation. Add the mention plugin to your tinyMCE configuration.

plugins : "advlink, paste, mention",

Add configuration options for the mention plugin. source is the only required setting.

NOTE: source can also be a function. see the options section below.

mentions: {
    source: [
        { name: 'Tyra Porcelli' }, 
        { name: 'Brigid Reddish' },
        { name: 'Ashely Buckler' },
        { name: 'Teddy Whelan' }
    ]
},

##Configuration

###source (required)

The source parameter can be configured as an array or a function.

####array

source: [
    { name: 'Tyra Porcelli' }, 
    { name: 'Brigid Reddish' },
    { name: 'Ashely Buckler' },
    { name: 'Teddy Whelan' }
]

####function

source: function (query, process, delimiter) {
    // Do your ajax call
    // When using multiple delimiters you can alter the query depending on the delimiter used
    if (delimiter === '@') {
       $.getJSON('ajax/users.json', function (data) {
          //call process to show the result
          process(data)
       }
    }
}

###queryBy

The name of the property used to do the lookup in the source.

Default: 'name'.

###delimiter

Character that will trigger the mention plugin. Can be configured as a character or an array of characters.

####character

delimiter: '@'

####array

delimiter: ['@', '#']

Default: '@'.

###delay

Delay of the lookup in milliseconds when typing a new character.

Default: 500.

###items

Maximum number of items displayed in the dropdown.

Default: 10

###matcher

Checks for a match in the source collection.

matcher: function(item) {
    //only match Peter Griffin
    if(item[this.options.queryBy] === 'Peter Griffin') {
        return true;
    }
}

###highlighter

Highlights the part of the query in the matched result.

highlighter: function(text) {
    //make matched block italic
    return text.replace(new RegExp('(' + this.query + ')', 'ig'), function ($1, match) {
        return '<i>' + match + '</i>';
    });
}

###insert

Callback to set the content you want to insert in tinyMCE.

insert: function(item) {
    return '<span>' + item.name + '</span>';
}

NOTE: item parameter has all properties defined in the source option.

###render

Callback to set the HTML of an item in the autocomplete dropdown.

render: function(item) {
    return '<li>' +
               '<a href="javascript:;"><span>' + item.name + '</span></a>' +
           '</li>';
}

NOTE: item parameter has all properties defined in the source option.

###renderDropdown

Callback to set the wrapper HTML for the autocomplete dropdown.

renderDropdown: function() {
    //add twitter bootstrap dropdown-menu class
    return '<ul class="rte-autocomplete dropdown-menu"></ul>';
}

##License

MIT licensed

Copyright (C) 2013 Cognistreamer, http://cognistreamer.com

tinymce-mention's People

Contributors

stevendevooght avatar jurgenkalverboer avatar

Watchers

James Cloos avatar shotishu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.