Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to support redactor 10, add bower, gulp and numerous other enhancements #17

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ __MACOSX
*~
Thumbs.db
desktop.ini

node_modules/*
bower_components/*
72 changes: 72 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Overview

Updated, backwards incompatible version of [redactor-mentions](https://github.com/tr42/redactor-mentions) plugin that supports [Redactor 10](http://imperavi.com/redactor/) and some enhancements (like floating div by the underneath the cursor). My goal is to eventually support searching through AJAX URLs.

Note that this project is under heavy development so no guarantees that it will work for you yet.

# Installation

## Manual

Copy `redactor-mentions.min.css` and `redactor-mentions.min.js` from the `dist` folder.

## Bower

I am just getting started with this so I haven't published to bower yet. I will do that soon.

# Usage

1. Copy `redactor-mentions.min.css` and `redactor-mentions.min.js` somewhere in your assets directory.

2. Add them to your markup after redactor stuff.

```html
<link rel="stylesheet" href="js/redactor/redactor.css" />
<link rel="stylesheet" href="js/redactor/redactor-mentions.min.css" />
<script src="js/redactor/redactor.js"></script>
<script src="js/redactor/redactor-mentions.min.js"></script>
```

3. Add the mention plugins to your initialization:

```javascript
$('.post').redactor({
plugins: ['mentions'],
mentions {
url: "users.json", // user data for mentions plugin
maxUsers: 5, // maximum users to show in user select dialog
urlPrefix: "/user/", // optional url prefix for user

// Optional. Pass in a function to format each user li. This should return
// a jQuery object.
formatUserListItem: function(user) {
return '<img src="' + user.icon + '" />' + user.username + ' (' + user.name + ')';
},

// Optional. Pass in a function to format or modify the link that will be
// displayed in redactor. You can use this to add any additional properties to
// the link.
alterUserLink: function($mentionHref, user) {
$mentionHref.text("@" + user.name);
$mentionHref.attr("data-hovercard", "/e/" + user.username + "/_hovercard");
}
}
});
```

The users JSON data should look like:

```javascript
[
{
"icon": "/icons/bob.gif",
"name": "Bob",
"username": "bob"
},
{
"icon": "/icons/alice.gif",
"name": "Alice",
"username": "alice"
}
]
```
34 changes: 0 additions & 34 deletions README.rst

This file was deleted.

23 changes: 23 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "redactor-mentions",
"version": "0.2",
"homepage": "https://github.com/thebitguru/redactor-mentions",
"authors": [
"Jason Keene (https://github.com/jasonkeene)",
"Farhan Ahmad <[email protected]>"
],
"description": "Mentions plugin for redactor editor.",
"keywords": [
"redactor",
"editor",
"mentions"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}
28 changes: 28 additions & 0 deletions dist/redactor-mentions.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*! redactor-mentions - compiled at Tue Mar 31 2015 02:58:41 GMT-0500 (CDT) */
.redactor-box .redactor-mentions-container {
position: absolute;
border: 2px solid #aaa;
background: #fff;
z-index: 5000;
}
.redactor-box .mention {
text-decoration: none !important;
cursor: default;
}
.redactor-box .user-select {
list-style-type: none;
margin: 0;
padding: 0;
}
.redactor-box .user-select li {
padding: 3px;
cursor: pointer;
}
.redactor-box .user-select li img {
margin: 0 4px 0 0;
vertical-align: bottom;
}
.redactor-box .user-select .selected {
background-color: #3577b9;
color: #ffffff;
}
Loading