首页
话题
消息
手册
我的
返回介绍

Mentions plugin

发布于 2019-05-06 字数65979 浏览 863 评论 0

The mentions plugin will present a list of users when a user types the “@” symbol followed by the beginnings of a username after it. It will then query your server using the mentions_fetch callback.

Example

TinyMCE HTML CSS JS Edit on CodePen textarea#mentions { height: 350px; } div.card { width: 300px; background: white; border: 3px inset grey; padding: 10px; font-size: 16px; font-family: -apple-system,BlinkMacSystemFont,”Segoe UI”,Roboto,Oxygen-Sans,Ubuntu,Cantarell,”Helvetica Neue”,sans-serif; } div.card::after { content: “”; clear: both; display: table; } div.card h1 { font-size: large; font-weight: bold; margin: 0; padding: 0; line-height: normal; font-family: -apple-system,BlinkMacSystemFont,”Segoe UI”,Roboto,Oxygen-Sans,Ubuntu,Cantarell,”Helvetica Neue”,sans-serif; } div.card p { font-family: -apple-system,BlinkMacSystemFont,”Segoe UI”,Roboto,Oxygen-Sans,Ubuntu,Cantarell,”Helvetica Neue”,sans-serif; } div.card img.avatar { width: 50px; height: 50px; margin-right: 5px; float: left; }


<textarea id="mentions">
  <p>Type @ followed by a name</p>
  <p>Aliquam purus massa, consequat ut massa euismod, vulputate vestibulum lorem. Curabitur ante ipsum, consectetur ut turpis ut, facilisis volutpat nulla. Etiam rhoncus sagittis urna, vitae interdum enim facilisis eget. Ut non tellus sit amet massa cursus tempus. Suspendisse mattis dui purus. Integer porta mi nec faucibus condimentum. Aliquam feugiat lacinia ante sagittis efficitur. Suspendisse ac porta tellus, nec feugiat libero.</p>
  <p>Morbi pellentesque tortor sed cursus tempus. Nam commodo varius dapibus. Sed nec justo vel orci ornare porta. Nullam bibendum malesuada elit, eget bibendum arcu dignissim ac. Aliquam ac accumsan lectus. Aliquam odio sem, tincidunt sed aliquet quis, laoreet at diam. Donec mattis sapien at magna venenatis, id condimentum velit porta. Proin a augue eget urna volutpat bibendum. Praesent finibus urna leo, a euismod neque vestibulum eget. Aliquam iaculis turpis non libero suscipit, vitae cursus lectus rutrum. Quisque faucibus dignissim enim vitae blandit. Morbi ullamcorper et nulla quis varius. Vestibulum eu velit nec mauris ullamcorper venenatis. Suspendisse dictum vitae lectus at laoreet. Nullam ac volutpat arcu. Nulla vitae aliquam nibh.</p>
  <p>Donec in tellus venenatis, aliquam felis eget, condimentum tellus. Praesent a scelerisque nibh. Sed efficitur lectus ut nisl mollis elementum. Aliquam bibendum, nisl a euismod dignissim, libero mi posuere elit, in fermentum mauris mi in nulla. Aliquam mollis rhoncus vestibulum. Fusce euismod ex ex, et ultrices nibh dignissim et. In hac habitasse platea dictumst. Donec in diam sit amet lorem condimentum consequat sit amet at lorem. Sed tempor sagittis mauris, ut placerat mi convallis in.</p>   
</textarea>



textarea#mentions {
  height: 350px;
}

div.card {
  width: 300px;
  background: white;
  border: 3px inset grey;
  padding: 10px;
  font-size: 16px;
  font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
}
div.card::after {
  content: "";
  clear: both;
  display: table;
}

div.card h1 {
  font-size: large;
  font-weight: bold;
  margin: 0;
  padding: 0;
  line-height: normal;
  font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
}

div.card p {
  font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
}

div.card img.avatar {
  width: 50px;
  height: 50px;
  margin-right: 5px;
  float: left;
}



/* 
** This is to simulate requesting information from a server.
**
** It has 2 functions:
** fetchUsers() - returns a complete list of users' ids and names.
** fetchUser(id) - returns the full information about a single user id.
**
** Both of these functions have a slight delay to simulate a server request.
*/
var fakeServer = (function () {
  /* Use tinymce's Promise shim */
  var Promise = tinymce.util.Promise;

  /* Some user names for our fake server */
  var userNames = [
    'Terry Green', 'Edward Carroll', 'Virginia Turner', 'Alexander Schneider', 'Gary Vasquez', 'Randy Howell',
    'Katherine Moore', 'Betty Washington', 'Grace Chapman', 'Christina Nguyen', 'Danielle Rose', 'Thomas Freeman',
    'Thomas Armstrong', 'Vincent Lee', 'Brittany Kelley', 'Brenda Wheeler', 'Amy Price', 'Hannah Harvey',
    'Bobby Howard', 'Frank Fox', 'Diane Hopkins', 'Johnny Hawkins', 'Sean Alexander', 'Emma Roberts', 'Thomas Snyder',
    'Thomas Allen', 'Rebecca Ross', 'Amy Boyd', 'Kenneth Watkins', 'Sarah Tucker', 'Lawrence Burke', 'Emma Carr',
    'Zachary Mason', 'John Scott', 'Michelle Davis', 'Nicholas Cole', 'Gerald Nelson', 'Emily Smith', 'Christian Stephens',
    'Grace Carr', 'Arthur Watkins', 'Frances Baker', 'Katherine Cook', 'Roger Wallace', 'Pamela Arnold', 'Linda Barnes',
    'Jacob Warren', 'Billy Ramirez', 'Pamela Walsh', 'Paul Wade', 'Katherine Campbell', 'Jeffrey Berry', 'Patrick Bowman',
    'Dennis Alvarez', 'Crystal Lucas', 'Howard Mendoza', 'Patricia Wallace', 'Peter Stone', 'Tiffany Lane', 'Joe Perkins',
    'Gloria Reynolds', 'Willie Fernandez', 'Doris Harper', 'Heather Sandoval', 'Danielle Franklin', 'Ann Ellis',
    'Christopher Hernandez', 'Pamela Perry', 'Matthew Henderson', 'Jesse Mitchell', 'Olivia Reed', 'David Clark', 'Juan Taylor',
    'Michael Garrett', 'Gerald Guerrero', 'Jerry Coleman', 'Joyce Vasquez', 'Jane Bryant', 'Sean West', 'Deborah Bradley',
    'Phillip Castillo', 'Martha Coleman', 'Ryan Santos', 'Harold Hanson', 'Frances Hoffman', 'Heather Fisher', 'Martha Martin',
    'George Gray', 'Rachel Herrera', 'Billy Hart', 'Kelly Campbell', 'Kelly Marshall', 'Doris Simmons', 'Julie George',
    'Raymond Burke', 'Ruth Hart', 'Jack Schmidt', 'Billy Schmidt', 'Ruth Wagner', 'Zachary Estrada', 'Olivia Griffin', 'Ann Hayes',
    'Julia Weaver', 'Anna Nelson', 'Willie Anderson', 'Anna Schneider', 'Debra Torres', 'Jordan Holmes', 'Thomas Dean',
    'Maria Burton', 'Terry Long', 'Danielle McDonald', 'Kyle Flores', 'Cheryl Garcia', 'Judy Delgado', 'Karen Elliott',
    'Vincent Ortiz', 'Ann Wright', 'Ann Ramos', 'Roy Jensen', 'Keith Cunningham', 'Mary Campbell', 'Jesse Ortiz', 'Joseph Mendoza',
    'Nathan Bishop', 'Lori Valdez', 'Tammy Jacobs', 'Mary West', 'Juan Mitchell', 'Thomas Adams', 'Christian Martinez', 'James Ramos',
    'Deborah Ross', 'Eric Holmes', 'Thomas Diaz', 'Sharon Morales', 'Kathryn Hamilton', 'Helen Edwards', 'Betty Powell',
    'Harry Campbell', 'Raymond Perkins', 'Melissa Wallace', 'Danielle Hicks', 'Harold Brewer', 'Jack Burns', 'Anna Robinson',
    'Dorothy Nguyen', 'Jane Dean', 'Janice Hunter', 'Ryan Moore', 'Brian Riley', 'Brittany Bradley', 'Phillip Ortega', 'William Fisher',
    'Jennifer Schultz', 'Samantha Perez', 'Linda Carr', 'Ann Brown', 'Shirley Kim', 'Jeremy Alvarez', 'Dylan Oliver', 'Roy Gomez',
    'Ethan Brewer', 'Ruth Lucas', 'Marilyn Myers', 'Danielle Wright', 'Jose Meyer', 'Bobby Brown', 'Angela Crawford', 'Brandon Willis',
    'Kyle McDonald', 'Aaron Valdez', 'Kevin Webb', 'Ashley Gordon', 'Karen Jenkins', 'Johnny Santos', 'Ashley Henderson', 'Amy Walters',
    'Amber Rodriguez', 'Thomas Ross', 'Dorothy Wells', 'Jennifer Murphy', 'Douglas Phillips', 'Helen Johnston', 'Nathan Hawkins',
    'Roger Mitchell', 'Michael Young', 'Eugene Cruz', 'Kevin Snyder', 'Frank Ryan', 'Tiffany Peters', 'Beverly Garza', 'Maria Wright',
    'Shirley Jensen', 'Carolyn Munoz', 'Kathleen Day', 'Ethan Meyer', 'Rachel Fields', 'Joan Bell', 'Ashley Sims', 'Sara Fields',
    'Elizabeth Willis', 'Ralph Torres', 'Charles Lopez', 'Aaron Green', 'Arthur Hanson', 'Betty Snyder', 'Jose Romero', 'Linda Martinez',
    'Zachary Tran', 'Sean Matthews', 'Eric Elliott', 'Kimberly Welch', 'Jason Bennett', 'Nicole Patel', 'Emily Guzman', 'Lori Snyder',
    'Sandra White', 'Christina Lawson', 'Jacob Campbell', 'Ruth Foster', 'Mark McDonald', 'Carol Williams', 'Alice Washington',
    'Brandon Ross', 'Judy Burns', 'Zachary Hawkins', 'Julie Chavez', 'Randy Duncan', 'Lisa Robinson', 'Jacqueline Reynolds', 'Paul Weaver',
    'Edward Gilbert', 'Deborah Butler', 'Frances Fox', 'Joshua Schmidt', 'Ashley Oliver', 'Martha Chavez', 'Heather Hudson',
    'Lauren Collins', 'Catherine Marshall', 'Katherine Wells', 'Robert Munoz', 'Pamela Nelson', 'Dylan Bowman', 'Virginia Snyder',
    'Janet Ruiz', 'Ralph Burton', 'Jose Bryant', 'Russell Medina', 'Brittany Snyder', 'Richard Cruz', 'Matthew Jimenez', 'Danielle Graham',
    'Steven Guerrero', 'Benjamin Matthews', 'Janet Mendoza', 'Harry Brewer', 'Scott Cooper', 'Alexander Keller', 'Virginia Gordon',
    'Randy Scott', 'Kimberly Olson', 'Helen Lynch', 'Ronald Garcia', 'Joseph Willis', 'Philip Walker', 'Tiffany Harris', 'Brittany Weber',
    'Gregory Harris', 'Sean Owens', 'Wayne Meyer', 'Roy McCoy', 'Keith Lucas', 'Christian Watkins', 'Christopher Porter', 'Sandra Lopez',
    'Harry Ward', 'Julie Sims', 'Albert Keller', 'Lori Ortiz', 'Virginia Henry', 'Samuel Green', 'Judith Cole', 'Ethan Castillo', 'Angela Ellis',
    'Amy Reid', 'Jason Brewer', 'Aaron Clark', 'Aaron Elliott', 'Doris Herrera', 'Howard Castro', 'Kenneth Davis', 'Austin Spencer',
    'Jonathan Marshall', 'Phillip Nelson', 'Julia Guzman', 'Robert Hansen', 'Kevin Anderson', 'Gerald Arnold', 'Austin Castro', 'Zachary Moore',
    'Joseph Cooper', 'Barbara Black', 'Albert Mendez', 'Marie Lane', 'Jacob Nichols', 'Virginia Marshall', 'Aaron Miller', 'Linda Harvey',
    'Christopher Morris', 'Emma Fields', 'Scott Guzman', 'Olivia Alexander', 'Kelly Garrett', 'Jesse Hanson', 'Henry Wong', 'Billy Vasquez',
    'Larry Ramirez', 'Bryan Brooks', 'Alan Berry', 'Nicole Powell', 'Stephen Bowman', 'Eric Hughes', 'Elizabeth Obrien', 'Timothy Ramos',
    'Michelle Russell', 'Denise Ruiz', 'Sean Carter', 'Amanda Barnett', 'Kathy Black', 'Terry Gutierrez', 'John Jensen', 'Grace Sanchez',
    'Tiffany Harvey', 'Jacqueline Sims', 'Wayne Lee', 'Roy Foster', 'Joyce Hart', 'Joseph Russell', 'Harold Washington', 'Beverly Cox',
    'Nicole Morales', 'Anna Carpenter', 'Jesse Ray', 'Ann Snyder', 'Mark Diaz', 'Elizabeth Harper', 'Andrew Guerrero', 'Cheryl Silva',
    'Michelle Hudson', 'Jeffrey Santos', 'Victoria Vasquez', 'Matthew Meyer', 'Jacob Murray', 'Jose Munoz', 'Edward Howell', 'Vincent Hunter',
    'Daniel Walters', 'Samantha Obrien', 'Laura Elliott', 'Richard Olson', 'Daniel Graham', 'Carol Lee', 'Grace Sullivan', 'Nancy Rodriguez',
    'Tyler Tran', 'Crystal Shaw', 'Madison Allen', 'Ralph Sims', 'Joe Jenkins', 'Dennis Ray', 'Arthur Davidson', 'Victoria Allen', 'Arthur Jackson',
    'Joan Thomas', 'Daniel Hopkins', 'Gloria Hicks', 'Danielle Price', 'Craig Keller', 'Alan Morgan', 'Gregory Silva', 'Samantha Kelly',
    'Rachel Williamson', 'Bruce Garrett', 'Jacob Smith', 'Kathleen Nichols', 'Sarah Long', 'Carol Pearson', 'Virginia Mendez', 'Judy Valdez',
    'Jason Garza', 'Brenda Fowler', 'Karen Edwards', 'Alexander Anderson', 'Pamela Wallace', 'Ruth Howell', 'Walter Hernandez', 'George Lucas',
    'Samantha Long', 'Margaret Garza', 'Kathleen Schultz', 'Frances Guerrero', 'Amber Meyer', 'Rachel Morales', 'Teresa Curtis', 'Heather Bell',
    'Grace Johnson', 'Melissa King', 'Zachary Cook', 'Carol Schultz', 'Jane Beck', 'Karen Stone', 'Roger Brooks', 'Carolyn Fuller', 'Nicholas Coleman',
    'William Bishop', 'Christine May', 'Linda George', 'Jean Meyer', 'Cheryl Armstrong', 'Danielle Welch', 'Amanda Graham', 'Janice Carter',
    'Catherine Brooks', 'Lawrence Gonzalez', 'Amy Russell', 'Eugene Jimenez', 'Joseph Carlson', 'Peter McCoy', 'Jerry Washington', 'Carolyn Obrien',
    'Mark Walker', 'Stephanie Hoffman', 'Julie Pena', 'Karen Curtis', 'Bryan Cruz', 'Madison Shaw', 'Rachel Graham', 'Susan Simpson', 'Andrea Harrison',
    'Bryan Miller', 'Vincent McDonald', 'Jesse McCoy', 'Christine Ramos', 'Dorothy Riley', 'Karen Warren', 'Ashley Weber', 'Judith Robinson',
    'Alan Mendez', 'Donna Medina', 'Helen Lane', 'Douglas Clark', 'Brenda Romero', 'Doris Wells', 'Patrick Howell', 'Doris Lawrence', 'Harry Jacobs',
    'Phillip Rose', 'Deborah Patel', 'Bryan Day', 'Rachel Butler', 'Paul Butler', 'Judy Knight', 'Willie Wallace', 'Phillip Anderson', 'Emma Black',
    'Lisa Lynch', 'Kimberly Freeman', 'Ronald West', 'Kathleen Harris', 'Martha Ruiz', 'Phillip Moreno', 'Robert Vargas', 'Jesse Diaz', 'Christine Weber',
    'Karen Stanley', 'Theresa Edwards', 'Kathryn Chavez', 'Sarah Rios', 'Danielle Wong', 'Kathy Carr', 'Joan Diaz', 'Albert Walters',
    'Denise Kim', 'Katherine Pearson', 'Diana Richardson', 'Harry Ford', 'Eric Mills', 'Sean Hicks', 'Joe Brown', 'Judith Morgan', 'Harry Hunter',
    'Matthew Bryant', 'Tyler Rose', 'Mildred Delgado', 'Emma Peters', 'Walter Delgado', 'Lauren Gilbert', 'Christopher Romero'
  ];

  /* some user profile images for our fake server */
  var images = [
    'camilarocun', 'brianmichel', 'absolutehype', '4l3d', 'lynseybrowne', 'hi_kendall', '4ae78e7058d2434', 'yusuf_y7',
    'beauty__tattoos', 'mehrank36176270', 'fabriziocuscini', 'hassaminian', 'mediajorge', 'alexbienz', 'eesates', 'donjain',
    'austinknight', 'ehlersd', 'bipiiin', 'victorstuber', 'curiousoffice', 'chowdhury_sayan', 'upslon', 'gcauchon', 'pawel_murawski',
    'mr_r_a', 'jeremieges', 'nickttng', 'patrikward', 'sinecdoques', 'gabrielbeduschi', 'ashmigosh', 'shxnx', 'laborisova',
    'anand_2688', 'mefahad', 'puneetsmail', 'jefrydagucci', 'duck4fuck', 'verbaux', 'nicolasjengler', 'sorousht_', 'am0rz',
    'dominiklevitsky', 'jarjan', 'ganilaughs', 'namphong122', 'tiggreen', 'allisongrayce', 'messagepadapp', 'madebylipsum',
    'tweetubhai', 'avonelink', 'ahmedkojito', 'piripipirics', 'dmackerman', 'markcipolla'
  ];

  /* some user profile descriptions for our fake server */
  var descriptions = [
    'I like to work hard, play hard!',
    'I drink like a fish, that is a fish that drinks coffee.',
    'OutOfCheeseError: Please reinstall universe.',
    'Do not quote me.',
    'No one reads these things right?'
  ];

  /* This represents a database of users on the server */
  var userDb = {};
  userNames.map(function (fullName) {
    var name = fullName.toLowerCase().replace(/ /g, '');
    var description = descriptions[Math.floor(descriptions.length * Math.random())];
    var image = 'https://s3.amazonaws.com/uifaces/faces/twitter/' + images[Math.floor(images.length * Math.random())] + '/128.jpg';
    return {
      id: name,
      name: name,
      fullName: fullName,
      description: description,
      image: image
    };
  }).forEach(function(user) {
    userDb[user.id] = user;
  });

  /* This represents getting the complete list of users from the server with only basic details */
  var fetchUsers = function() {
    return new Promise(function(resolve, _reject) {
      /* simulate a server delay */
      setTimeout(function() {
        var users = Object.keys(userDb).map(function(id) {
          return {
            id: id,
            name: userDb[id].name,
          };
        });
        resolve(users);
      }, 500);
    });
  };

  /* This represents requesting all the details of a single user from the server database */
  var fetchUser = function(id) {
    return new Promise(function(resolve, reject) {
      /* simulate a server delay */
      setTimeout(function() {
        if (Object.prototype.hasOwnProperty.call(userDb, id)) {
          resolve(userDb[id]);
        }
        reject('unknown user id "' + id + '"');
      }, 300);
    });
  };
  
  return {
    fetchUsers: fetchUsers,
    fetchUser: fetchUser
  };
})();

/* These are "local" caches of the data returned from the fake server */
var usersRequest = null;
var userRequest = {};

var mentions_fetch = function (query, success) {
  /* Fetch your full user list from somewhere */
  if (usersRequest === null) {
    usersRequest = fakeServer.fetchUsers();
  }
  usersRequest.then(function(users) {
    /* query.term is the text the user typed after the '@' */
    users = users.filter(function (user) {
      return user.name.indexOf(query.term.toLowerCase()) !== -1;
    });

    users = users.slice(0, 10);
    
    /* Where the user object must contain the properties `id` and `name`
       but you could additionally include anything else you deem useful. */
    success(users);
  });
};

var mentions_menu_hover = function (userInfo, success) {
  /* request more information about the user from the server and cache it locally */
  if (!userRequest[userInfo.id]) {
    userRequest[userInfo.id] = fakeServer.fetchUser(userInfo.id);
  }
  userRequest[userInfo.id].then(function(userDetail) {
    var div = document.createElement('div');

    div.innerHTML = (
    '<div class="card">' +
      '<h1>' + userDetail.fullName + '</h1>' +
      '<img class="avatar" src="' + userDetail.image + '"/>' +
      '<p>' + userDetail.description + '</p>' +
    '</div>'
    );

    success(div);
  });
};

var mentions_menu_complete = function (editor, userInfo) {
  var span = editor.getDoc().createElement('span');
  span.className = 'mymention';
  span.setAttribute('data-mention-id', userInfo.id);
  span.appendChild(editor.getDoc().createTextNode('@' + userInfo.name));
  return span;
};

var mentions_select = function (mention, success) {
  /* `mention` is the element we previously created with `mentions_menu_complete`
     in this case we have chosen to store the id as an attribute */
  var id = mention.getAttribute('data-mention-id');
  /* request more information about the user from the server and cache it locally */
  if (!userRequest[id]) {
    userRequest[id] = fakeServer.fetchUser(id);
  }
  userRequest[id].then(function(userDetail) {
    var div = document.createElement('div');
    div.innerHTML = (
      '<div class="card">' +
      '<h1>' + userDetail.fullName + '</h1>' +
      '<img class="avatar" src="' + userDetail.image + '"/>' +
      '<p>' + userDetail.description + '</p>' +
      '</div>'
    );
    success(div);
  });
};

tinymce.init({
  selector: "textarea#mentions",
  plugins: "mentions",
  content_style: ".mymention{ color: green; }",

  mentions_selector: '.mymention',
  mentions_fetch: mentions_fetch,
  mentions_menu_hover: mentions_menu_hover,
  mentions_menu_complete: mentions_menu_complete,
  mentions_select: mentions_select

});

(function() { var isIE = !!window.MSInputMethodContext && !!document.documentMode; if (isIE && document.getElementsByClassName(“ie11_optional”)[0] !== undefined) { document.getElementsByClassName(“ie11_optional”)[0].style.display = ‘none’; } })(); (function() { /* ** This is to simulate requesting information from a server. ** ** It has 2 functions: ** fetchUsers() – returns a complete list of users’ ids and names. ** fetchUser(id) – returns the full information about a single user id. ** ** Both of these functions have a slight delay to simulate a server request. */ var fakeServer = (function () { /* Use tinymce’s Promise shim */ var Promise = tinymce.util.Promise; /* Some user names for our fake server */ var userNames = [ ‘Terry Green’, ‘Edward Carroll’, ‘Virginia Turner’, ‘Alexander Schneider’, ‘Gary Vasquez’, ‘Randy Howell’, ‘Katherine Moore’, ‘Betty Washington’, ‘Grace Chapman’, ‘Christina Nguyen’, ‘Danielle Rose’, ‘Thomas Freeman’, ‘Thomas Armstrong’, ‘Vincent Lee’, ‘Brittany Kelley’, ‘Brenda Wheeler’, ‘Amy Price’, ‘Hannah Harvey’, ‘Bobby Howard’, ‘Frank Fox’, ‘Diane Hopkins’, ‘Johnny Hawkins’, ‘Sean Alexander’, ‘Emma Roberts’, ‘Thomas Snyder’, ‘Thomas Allen’, ‘Rebecca Ross’, ‘Amy Boyd’, ‘Kenneth Watkins’, ‘Sarah Tucker’, ‘Lawrence Burke’, ‘Emma Carr’, ‘Zachary Mason’, ‘John Scott’, ‘Michelle Davis’, ‘Nicholas Cole’, ‘Gerald Nelson’, ‘Emily Smith’, ‘Christian Stephens’, ‘Grace Carr’, ‘Arthur Watkins’, ‘Frances Baker’, ‘Katherine Cook’, ‘Roger Wallace’, ‘Pamela Arnold’, ‘Linda Barnes’, ‘Jacob Warren’, ‘Billy Ramirez’, ‘Pamela Walsh’, ‘Paul Wade’, ‘Katherine Campbell’, ‘Jeffrey Berry’, ‘Patrick Bowman’, ‘Dennis Alvarez’, ‘Crystal Lucas’, ‘Howard Mendoza’, ‘Patricia Wallace’, ‘Peter Stone’, ‘Tiffany Lane’, ‘Joe Perkins’, ‘Gloria Reynolds’, ‘Willie Fernandez’, ‘Doris Harper’, ‘Heather Sandoval’, ‘Danielle Franklin’, ‘Ann Ellis’, ‘Christopher Hernandez’, ‘Pamela Perry’, ‘Matthew Henderson’, ‘Jesse Mitchell’, ‘Olivia Reed’, ‘David Clark’, ‘Juan Taylor’, ‘Michael Garrett’, ‘Gerald Guerrero’, ‘Jerry Coleman’, ‘Joyce Vasquez’, ‘Jane Bryant’, ‘Sean West’, ‘Deborah Bradley’, ‘Phillip Castillo’, ‘Martha Coleman’, ‘Ryan Santos’, ‘Harold Hanson’, ‘Frances Hoffman’, ‘Heather Fisher’, ‘Martha Martin’, ‘George Gray’, ‘Rachel Herrera’, ‘Billy Hart’, ‘Kelly Campbell’, ‘Kelly Marshall’, ‘Doris Simmons’, ‘Julie George’, ‘Raymond Burke’, ‘Ruth Hart’, ‘Jack Schmidt’, ‘Billy Schmidt’, ‘Ruth Wagner’, ‘Zachary Estrada’, ‘Olivia Griffin’, ‘Ann Hayes’, ‘Julia Weaver’, ‘Anna Nelson’, ‘Willie Anderson’, ‘Anna Schneider’, ‘Debra Torres’, ‘Jordan Holmes’, ‘Thomas Dean’, ‘Maria Burton’, ‘Terry Long’, ‘Danielle McDonald’, ‘Kyle Flores’, ‘Cheryl Garcia’, ‘Judy Delgado’, ‘Karen Elliott’, ‘Vincent Ortiz’, ‘Ann Wright’, ‘Ann Ramos’, ‘Roy Jensen’, ‘Keith Cunningham’, ‘Mary Campbell’, ‘Jesse Ortiz’, ‘Joseph Mendoza’, ‘Nathan Bishop’, ‘Lori Valdez’, ‘Tammy Jacobs’, ‘Mary West’, ‘Juan Mitchell’, ‘Thomas Adams’, ‘Christian Martinez’, ‘James Ramos’, ‘Deborah Ross’, ‘Eric Holmes’, ‘Thomas Diaz’, ‘Sharon Morales’, ‘Kathryn Hamilton’, ‘Helen Edwards’, ‘Betty Powell’, ‘Harry Campbell’, ‘Raymond Perkins’, ‘Melissa Wallace’, ‘Danielle Hicks’, ‘Harold Brewer’, ‘Jack Burns’, ‘Anna Robinson’, ‘Dorothy Nguyen’, ‘Jane Dean’, ‘Janice Hunter’, ‘Ryan Moore’, ‘Brian Riley’, ‘Brittany Bradley’, ‘Phillip Ortega’, ‘William Fisher’, ‘Jennifer Schultz’, ‘Samantha Perez’, ‘Linda Carr’, ‘Ann Brown’, ‘Shirley Kim’, ‘Jeremy Alvarez’, ‘Dylan Oliver’, ‘Roy Gomez’, ‘Ethan Brewer’, ‘Ruth Lucas’, ‘Marilyn Myers’, ‘Danielle Wright’, ‘Jose Meyer’, ‘Bobby Brown’, ‘Angela Crawford’, ‘Brandon Willis’, ‘Kyle McDonald’, ‘Aaron Valdez’, ‘Kevin Webb’, ‘Ashley Gordon’, ‘Karen Jenkins’, ‘Johnny Santos’, ‘Ashley Henderson’, ‘Amy Walters’, ‘Amber Rodriguez’, ‘Thomas Ross’, ‘Dorothy Wells’, ‘Jennifer Murphy’, ‘Douglas Phillips’, ‘Helen Johnston’, ‘Nathan Hawkins’, ‘Roger Mitchell’, ‘Michael Young’, ‘Eugene Cruz’, ‘Kevin Snyder’, ‘Frank Ryan’, ‘Tiffany Peters’, ‘Beverly Garza’, ‘Maria Wright’, ‘Shirley Jensen’, ‘Carolyn Munoz’, ‘Kathleen Day’, ‘Ethan Meyer’, ‘Rachel Fields’, ‘Joan Bell’, ‘Ashley Sims’, ‘Sara Fields’, ‘Elizabeth Willis’, ‘Ralph Torres’, ‘Charles Lopez’, ‘Aaron Green’, ‘Arthur Hanson’, ‘Betty Snyder’, ‘Jose Romero’, ‘Linda Martinez’, ‘Zachary Tran’, ‘Sean Matthews’, ‘Eric Elliott’, ‘Kimberly Welch’, ‘Jason Bennett’, ‘Nicole Patel’, ‘Emily Guzman’, ‘Lori Snyder’, ‘Sandra White’, ‘Christina Lawson’, ‘Jacob Campbell’, ‘Ruth Foster’, ‘Mark McDonald’, ‘Carol Williams’, ‘Alice Washington’, ‘Brandon Ross’, ‘Judy Burns’, ‘Zachary Hawkins’, ‘Julie Chavez’, ‘Randy Duncan’, ‘Lisa Robinson’, ‘Jacqueline Reynolds’, ‘Paul Weaver’, ‘Edward Gilbert’, ‘Deborah Butler’, ‘Frances Fox’, ‘Joshua Schmidt’, ‘Ashley Oliver’, ‘Martha Chavez’, ‘Heather Hudson’, ‘Lauren Collins’, ‘Catherine Marshall’, ‘Katherine Wells’, ‘Robert Munoz’, ‘Pamela Nelson’, ‘Dylan Bowman’, ‘Virginia Snyder’, ‘Janet Ruiz’, ‘Ralph Burton’, ‘Jose Bryant’, ‘Russell Medina’, ‘Brittany Snyder’, ‘Richard Cruz’, ‘Matthew Jimenez’, ‘Danielle Graham’, ‘Steven Guerrero’, ‘Benjamin Matthews’, ‘Janet Mendoza’, ‘Harry Brewer’, ‘Scott Cooper’, ‘Alexander Keller’, ‘Virginia Gordon’, ‘Randy Scott’, ‘Kimberly Olson’, ‘Helen Lynch’, ‘Ronald Garcia’, ‘Joseph Willis’, ‘Philip Walker’, ‘Tiffany Harris’, ‘Brittany Weber’, ‘Gregory Harris’, ‘Sean Owens’, ‘Wayne Meyer’, ‘Roy McCoy’, ‘Keith Lucas’, ‘Christian Watkins’, ‘Christopher Porter’, ‘Sandra Lopez’, ‘Harry Ward’, ‘Julie Sims’, ‘Albert Keller’, ‘Lori Ortiz’, ‘Virginia Henry’, ‘Samuel Green’, ‘Judith Cole’, ‘Ethan Castillo’, ‘Angela Ellis’, ‘Amy Reid’, ‘Jason Brewer’, ‘Aaron Clark’, ‘Aaron Elliott’, ‘Doris Herrera’, ‘Howard Castro’, ‘Kenneth Davis’, ‘Austin Spencer’, ‘Jonathan Marshall’, ‘Phillip Nelson’, ‘Julia Guzman’, ‘Robert Hansen’, ‘Kevin Anderson’, ‘Gerald Arnold’, ‘Austin Castro’, ‘Zachary Moore’, ‘Joseph Cooper’, ‘Barbara Black’, ‘Albert Mendez’, ‘Marie Lane’, ‘Jacob Nichols’, ‘Virginia Marshall’, ‘Aaron Miller’, ‘Linda Harvey’, ‘Christopher Morris’, ‘Emma Fields’, ‘Scott Guzman’, ‘Olivia Alexander’, ‘Kelly Garrett’, ‘Jesse Hanson’, ‘Henry Wong’, ‘Billy Vasquez’, ‘Larry Ramirez’, ‘Bryan Brooks’, ‘Alan Berry’, ‘Nicole Powell’, ‘Stephen Bowman’, ‘Eric Hughes’, ‘Elizabeth Obrien’, ‘Timothy Ramos’, ‘Michelle Russell’, ‘Denise Ruiz’, ‘Sean Carter’, ‘Amanda Barnett’, ‘Kathy Black’, ‘Terry Gutierrez’, ‘John Jensen’, ‘Grace Sanchez’, ‘Tiffany Harvey’, ‘Jacqueline Sims’, ‘Wayne Lee’, ‘Roy Foster’, ‘Joyce Hart’, ‘Joseph Russell’, ‘Harold Washington’, ‘Beverly Cox’, ‘Nicole Morales’, ‘Anna Carpenter’, ‘Jesse Ray’, ‘Ann Snyder’, ‘Mark Diaz’, ‘Elizabeth Harper’, ‘Andrew Guerrero’, ‘Cheryl Silva’, ‘Michelle Hudson’, ‘Jeffrey Santos’, ‘Victoria Vasquez’, ‘Matthew Meyer’, ‘Jacob Murray’, ‘Jose Munoz’, ‘Edward Howell’, ‘Vincent Hunter’, ‘Daniel Walters’, ‘Samantha Obrien’, ‘Laura Elliott’, ‘Richard Olson’, ‘Daniel Graham’, ‘Carol Lee’, ‘Grace Sullivan’, ‘Nancy Rodriguez’, ‘Tyler Tran’, ‘Crystal Shaw’, ‘Madison Allen’, ‘Ralph Sims’, ‘Joe Jenkins’, ‘Dennis Ray’, ‘Arthur Davidson’, ‘Victoria Allen’, ‘Arthur Jackson’, ‘Joan Thomas’, ‘Daniel Hopkins’, ‘Gloria Hicks’, ‘Danielle Price’, ‘Craig Keller’, ‘Alan Morgan’, ‘Gregory Silva’, ‘Samantha Kelly’, ‘Rachel Williamson’, ‘Bruce Garrett’, ‘Jacob Smith’, ‘Kathleen Nichols’, ‘Sarah Long’, ‘Carol Pearson’, ‘Virginia Mendez’, ‘Judy Valdez’, ‘Jason Garza’, ‘Brenda Fowler’, ‘Karen Edwards’, ‘Alexander Anderson’, ‘Pamela Wallace’, ‘Ruth Howell’, ‘Walter Hernandez’, ‘George Lucas’, ‘Samantha Long’, ‘Margaret Garza’, ‘Kathleen Schultz’, ‘Frances Guerrero’, ‘Amber Meyer’, ‘Rachel Morales’, ‘Teresa Curtis’, ‘Heather Bell’, ‘Grace Johnson’, ‘Melissa King’, ‘Zachary Cook’, ‘Carol Schultz’, ‘Jane Beck’, ‘Karen Stone’, ‘Roger Brooks’, ‘Carolyn Fuller’, ‘Nicholas Coleman’, ‘William Bishop’, ‘Christine May’, ‘Linda George’, ‘Jean Meyer’, ‘Cheryl Armstrong’, ‘Danielle Welch’, ‘Amanda Graham’, ‘Janice Carter’, ‘Catherine Brooks’, ‘Lawrence Gonzalez’, ‘Amy Russell’, ‘Eugene Jimenez’, ‘Joseph Carlson’, ‘Peter McCoy’, ‘Jerry Washington’, ‘Carolyn Obrien’, ‘Mark Walker’, ‘Stephanie Hoffman’, ‘Julie Pena’, ‘Karen Curtis’, ‘Bryan Cruz’, ‘Madison Shaw’, ‘Rachel Graham’, ‘Susan Simpson’, ‘Andrea Harrison’, ‘Bryan Miller’, ‘Vincent McDonald’, ‘Jesse McCoy’, ‘Christine Ramos’, ‘Dorothy Riley’, ‘Karen Warren’, ‘Ashley Weber’, ‘Judith Robinson’, ‘Alan Mendez’, ‘Donna Medina’, ‘Helen Lane’, ‘Douglas Clark’, ‘Brenda Romero’, ‘Doris Wells’, ‘Patrick Howell’, ‘Doris Lawrence’, ‘Harry Jacobs’, ‘Phillip Rose’, ‘Deborah Patel’, ‘Bryan Day’, ‘Rachel Butler’, ‘Paul Butler’, ‘Judy Knight’, ‘Willie Wallace’, ‘Phillip Anderson’, ‘Emma Black’, ‘Lisa Lynch’, ‘Kimberly Freeman’, ‘Ronald West’, ‘Kathleen Harris’, ‘Martha Ruiz’, ‘Phillip Moreno’, ‘Robert Vargas’, ‘Jesse Diaz’, ‘Christine Weber’, ‘Karen Stanley’, ‘Theresa Edwards’, ‘Kathryn Chavez’, ‘Sarah Rios’, ‘Danielle Wong’, ‘Kathy Carr’, ‘Joan Diaz’, ‘Albert Walters’, ‘Denise Kim’, ‘Katherine Pearson’, ‘Diana Richardson’, ‘Harry Ford’, ‘Eric Mills’, ‘Sean Hicks’, ‘Joe Brown’, ‘Judith Morgan’, ‘Harry Hunter’, ‘Matthew Bryant’, ‘Tyler Rose’, ‘Mildred Delgado’, ‘Emma Peters’, ‘Walter Delgado’, ‘Lauren Gilbert’, ‘Christopher Romero’ ]; /* some user profile images for our fake server */ var images = [ ‘camilarocun’, ‘brianmichel’, ‘absolutehype’, ‘4l3d’, ‘lynseybrowne’, ‘hi_kendall’, ‘4ae78e7058d2434’, ‘yusuf_y7’, ‘beauty__tattoos’, ‘mehrank36176270’, ‘fabriziocuscini’, ‘hassaminian’, ‘mediajorge’, ‘alexbienz’, ‘eesates’, ‘donjain’, ‘austinknight’, ‘ehlersd’, ‘bipiiin’, ‘victorstuber’, ‘curiousoffice’, ‘chowdhury_sayan’, ‘upslon’, ‘gcauchon’, ‘pawel_murawski’, ‘mr_r_a’, ‘jeremieges’, ‘nickttng’, ‘patrikward’, ‘sinecdoques’, ‘gabrielbeduschi’, ‘ashmigosh’, ‘shxnx’, ‘laborisova’, ‘anand_2688’, ‘mefahad’, ‘puneetsmail’, ‘jefrydagucci’, ‘duck4fuck’, ‘verbaux’, ‘nicolasjengler’, ‘sorousht_’, ‘am0rz’, ‘dominiklevitsky’, ‘jarjan’, ‘ganilaughs’, ‘namphong122’, ‘tiggreen’, ‘allisongrayce’, ‘messagepadapp’, ‘madebylipsum’, ‘tweetubhai’, ‘avonelink’, ‘ahmedkojito’, ‘piripipirics’, ‘dmackerman’, ‘markcipolla’ ]; /* some user profile descriptions for our fake server */ var descriptions = [ ‘I like to work hard, play hard!’, ‘I drink like a fish, that is a fish that drinks coffee.’, ‘OutOfCheeseError: Please reinstall universe.’, ‘Do not quote me.’, ‘No one reads these things right?’ ]; /* This represents a database of users on the server */ var userDb = {}; userNames.map(function (fullName) { var name = fullName.toLowerCase().replace(/ /g, ”); var description = descriptions[Math.floor(descriptions.length * Math.random())]; var image = ‘https://s3.amazonaws.com/uifaces/faces/twitter/’ + images[Math.floor(images.length * Math.random())] + ‘/128.jpg’; return { id: name, name: name, fullName: fullName, description: description, image: image }; }).forEach(function(user) { userDb[user.id] = user; }); /* This represents getting the complete list of users from the server with only basic details */ var fetchUsers = function() { return new Promise(function(resolve, _reject) { /* simulate a server delay */ setTimeout(function() { var users = Object.keys(userDb).map(function(id) { return { id: id, name: userDb[id].name, }; }); resolve(users); }, 500); }); }; /* This represents requesting all the details of a single user from the server database */ var fetchUser = function(id) { return new Promise(function(resolve, reject) { /* simulate a server delay */ setTimeout(function() { if (Object.prototype.hasOwnProperty.call(userDb, id)) { resolve(userDb[id]); } reject(‘unknown user id “‘ + id + ‘”‘); }, 300); }); }; return { fetchUsers: fetchUsers, fetchUser: fetchUser }; })(); /* These are “local” caches of the data returned from the fake server */ var usersRequest = null; var userRequest = {}; var mentions_fetch = function (query, success) { /* Fetch your full user list from somewhere */ if (usersRequest === null) { usersRequest = fakeServer.fetchUsers(); } usersRequest.then(function(users) { /* query.term is the text the user typed after the ‘@’ */ users = users.filter(function (user) { return user.name.indexOf(query.term.toLowerCase()) !== -1; }); users = users.slice(0, 10); /* Where the user object must contain the properties `id` and `name` but you could additionally include anything else you deem useful. */ success(users); }); }; var mentions_menu_hover = function (userInfo, success) { /* request more information about the user from the server and cache it locally */ if (!userRequest[userInfo.id]) { userRequest[userInfo.id] = fakeServer.fetchUser(userInfo.id); } userRequest[userInfo.id].then(function(userDetail) { var div = document.createElement(‘div’); div.innerHTML = ( ” + ‘

‘ + userDetail.fullName + ‘

‘ + ‘‘ + ‘

‘ + userDetail.description + ‘

‘ + ” ); success(div); }); }; var mentions_menu_complete = function (editor, userInfo) { var span = editor.getDoc().createElement(‘span’); span.className = ‘mymention’; span.setAttribute(‘data-mention-id’, userInfo.id); span.appendChild(editor.getDoc().createTextNode(‘@’ + userInfo.name)); return span; }; var mentions_select = function (mention, success) { /* `mention` is the element we previously created with `mentions_menu_complete` in this case we have chosen to store the id as an attribute */ var id = mention.getAttribute(‘data-mention-id’); /* request more information about the user from the server and cache it locally */ if (!userRequest[id]) { userRequest[id] = fakeServer.fetchUser(id); } userRequest[id].then(function(userDetail) { var div = document.createElement(‘div’); div.innerHTML = ( ” + ‘

‘ + userDetail.fullName + ‘

‘ + ‘‘ + ‘

‘ + userDetail.description + ‘

‘ + ” ); success(div); }); }; tinymce.init({ selector: “textarea#mentions”, plugins: “mentions”, content_style: “.mymention{ color: green; }”, mentions_selector: ‘.mymention’, mentions_fetch: mentions_fetch, mentions_menu_hover: mentions_menu_hover, mentions_menu_complete: mentions_menu_complete, mentions_select: mentions_select }); })(); (function() { /* TODO: more js, less jekyll */ var id = “mentions”; var html = decodeURIComponent(“%0A%3Ctextarea%20id=%22mentions%22%3E%0A%20%20%3Cp%3EType%20@%20followed%20by%20a%20name%3C/p%3E%0A%20%20%3Cp%3EAliquam%20purus%20massa,%20consequat%20ut%20massa%20euismod,%20vulputate%20vestibulum%20lorem.%20Curabitur%20ante%20ipsum,%20consectetur%20ut%20turpis%20ut,%20facilisis%20volutpat%20nulla.%20Etiam%20rhoncus%20sagittis%20urna,%20vitae%20interdum%20enim%20facilisis%20eget.%20Ut%20non%20tellus%20sit%20amet%20massa%20cursus%20tempus.%20Suspendisse%20mattis%20dui%20purus.%20Integer%20porta%20mi%20nec%20faucibus%20condimentum.%20Aliquam%20feugiat%20lacinia%20ante%20sagittis%20efficitur.%20Suspendisse%20ac%20porta%20tellus,%20nec%20feugiat%20libero.%3C/p%3E%0A%20%20%3Cp%3EMorbi%20pellentesque%20tortor%20sed%20cursus%20tempus.%20Nam%20commodo%20varius%20dapibus.%20Sed%20nec%20justo%20vel%20orci%20ornare%20porta.%20Nullam%20bibendum%20malesuada%20elit,%20eget%20bibendum%20arcu%20dignissim%20ac.%20Aliquam%20ac%20accumsan%20lectus.%20Aliquam%20odio%20sem,%20tincidunt%20sed%20aliquet%20quis,%20laoreet%20at%20diam.%20Donec%20mattis%20sapien%20at%20magna%20venenatis,%20id%20condimentum%20velit%20porta.%20Proin%20a%20augue%20eget%20urna%20volutpat%20bibendum.%20Praesent%20finibus%20urna%20leo,%20a%20euismod%20neque%20vestibulum%20eget.%20Aliquam%20iaculis%20turpis%20non%20libero%20suscipit,%20vitae%20cursus%20lectus%20rutrum.%20Quisque%20faucibus%20dignissim%20enim%20vitae%20blandit.%20Morbi%20ullamcorper%20et%20nulla%20quis%20varius.%20Vestibulum%20eu%20velit%20nec%20mauris%20ullamcorper%20venenatis.%20Suspendisse%20dictum%20vitae%20lectus%20at%20laoreet.%20Nullam%20ac%20volutpat%20arcu.%20Nulla%20vitae%20aliquam%20nibh.%3C/p%3E%0A%20%20%3Cp%3EDonec%20in%20tellus%20venenatis,%20aliquam%20felis%20eget,%20condimentum%20tellus.%20Praesent%20a%20scelerisque%20nibh.%20Sed%20efficitur%20lectus%20ut%20nisl%20mollis%20elementum.%20Aliquam%20bibendum,%20nisl%20a%20euismod%20dignissim,%20libero%20mi%20posuere%20elit,%20in%20fermentum%20mauris%20mi%20in%20nulla.%20Aliquam%20mollis%20rhoncus%20vestibulum.%20Fusce%20euismod%20ex%20ex,%20et%20ultrices%20nibh%20dignissim%20et.%20In%20hac%20habitasse%20platea%20dictumst.%20Donec%20in%20diam%20sit%20amet%20lorem%20condimentum%20consequat%20sit%20amet%20at%20lorem.%20Sed%20tempor%20sagittis%20mauris,%20ut%20placerat%20mi%20convallis%20in.%3C/p%3E%20%20%20%0A%3C/textarea%3E%0A%0A”); var js = decodeURIComponent(“%0A%0A/*%20%0A**%20This%20is%20to%20simulate%20requesting%20information%20from%20a%20server.%0A**%0A**%20It%20has%202%20functions:%0A**%20fetchUsers()%20-%20returns%20a%20complete%20list%20of%20users’%20ids%20and%20names.%0A**%20fetchUser(id)%20-%20returns%20the%20full%20information%20about%20a%20single%20user%20id.%0A**%0A**%20Both%20of%20these%20functions%20have%20a%20slight%20delay%20to%20simulate%20a%20server%20request.%0A*/%0Avar%20fakeServer%20=%20(function%20()%20%7B%0A%20%20/*%20Use%20tinymce’s%20Promise%20shim%20*/%0A%20%20var%20Promise%20=%20tinymce.util.Promise;%0A%0A%20%20/*%20Some%20user%20names%20for%20our%20fake%20server%20*/%0A%20%20var%20userNames%20=%20[%0A%20%20%20%20’Terry%20Green’,%20’Edward%20Carroll’,%20’Virginia%20Turner’,%20’Alexander%20Schneider’,%20’Gary%20Vasquez’,%20’Randy%20Howell’,%0A%20%20%20%20’Katherine%20Moore’,%20’Betty%20Washington’,%20’Grace%20Chapman’,%20’Christina%20Nguyen’,%20’Danielle%20Rose’,%20’Thomas%20Freeman’,%0A%20%20%20%20’Thomas%20Armstrong’,%20’Vincent%20Lee’,%20’Brittany%20Kelley’,%20’Brenda%20Wheeler’,%20’Amy%20Price’,%20’Hannah%20Harvey’,%0A%20%20%20%20’Bobby%20Howard’,%20’Frank%20Fox’,%20’Diane%20Hopkins’,%20’Johnny%20Hawkins’,%20’Sean%20Alexander’,%20’Emma%20Roberts’,%20’Thomas%20Snyder’,%0A%20%20%20%20’Thomas%20Allen’,%20’Rebecca%20Ross’,%20’Amy%20Boyd’,%20’Kenneth%20Watkins’,%20’Sarah%20Tucker’,%20’Lawrence%20Burke’,%20’Emma%20Carr’,%0A%20%20%20%20’Zachary%20Mason’,%20’John%20Scott’,%20’Michelle%20Davis’,%20’Nicholas%20Cole’,%20’Gerald%20Nelson’,%20’Emily%20Smith’,%20’Christian%20Stephens’,%0A%20%20%20%20’Grace%20Carr’,%20’Arthur%20Watkins’,%20’Frances%20Baker’,%20’Katherine%20Cook’,%20’Roger%20Wallace’,%20’Pamela%20Arnold’,%20’Linda%20Barnes’,%0A%20%20%20%20’Jacob%20Warren’,%20’Billy%20Ramirez’,%20’Pamela%20Walsh’,%20’Paul%20Wade’,%20’Katherine%20Campbell’,%20’Jeffrey%20Berry’,%20’Patrick%20Bowman’,%0A%20%20%20%20’Dennis%20Alvarez’,%20’Crystal%20Lucas’,%20’Howard%20Mendoza’,%20’Patricia%20Wallace’,%20’Peter%20Stone’,%20’Tiffany%20Lane’,%20’Joe%20Perkins’,%0A%20%20%20%20’Gloria%20Reynolds’,%20’Willie%20Fernandez’,%20’Doris%20Harper’,%20’Heather%20Sandoval’,%20’Danielle%20Franklin’,%20’Ann%20Ellis’,%0A%20%20%20%20’Christopher%20Hernandez’,%20’Pamela%20Perry’,%20’Matthew%20Henderson’,%20’Jesse%20Mitchell’,%20’Olivia%20Reed’,%20’David%20Clark’,%20’Juan%20Taylor’,%0A%20%20%20%20’Michael%20Garrett’,%20’Gerald%20Guerrero’,%20’Jerry%20Coleman’,%20’Joyce%20Vasquez’,%20’Jane%20Bryant’,%20’Sean%20West’,%20’Deborah%20Bradley’,%0A%20%20%20%20’Phillip%20Castillo’,%20’Martha%20Coleman’,%20’Ryan%20Santos’,%20’Harold%20Hanson’,%20’Frances%20Hoffman’,%20’Heather%20Fisher’,%20’Martha%20Martin’,%0A%20%20%20%20’George%20Gray’,%20’Rachel%20Herrera’,%20’Billy%20Hart’,%20’Kelly%20Campbell’,%20’Kelly%20Marshall’,%20’Doris%20Simmons’,%20’Julie%20George’,%0A%20%20%20%20’Raymond%20Burke’,%20’Ruth%20Hart’,%20’Jack%20Schmidt’,%20’Billy%20Schmidt’,%20’Ruth%20Wagner’,%20’Zachary%20Estrada’,%20’Olivia%20Griffin’,%20’Ann%20Hayes’,%0A%20%20%20%20’Julia%20Weaver’,%20’Anna%20Nelson’,%20’Willie%20Anderson’,%20’Anna%20Schneider’,%20’Debra%20Torres’,%20’Jordan%20Holmes’,%20’Thomas%20Dean’,%0A%20%20%20%20’Maria%20Burton’,%20’Terry%20Long’,%20’Danielle%20McDonald’,%20’Kyle%20Flores’,%20’Cheryl%20Garcia’,%20’Judy%20Delgado’,%20’Karen%20Elliott’,%0A%20%20%20%20’Vincent%20Ortiz’,%20’Ann%20Wright’,%20’Ann%20Ramos’,%20’Roy%20Jensen’,%20’Keith%20Cunningham’,%20’Mary%20Campbell’,%20’Jesse%20Ortiz’,%20’Joseph%20Mendoza’,%0A%20%20%20%20’Nathan%20Bishop’,%20’Lori%20Valdez’,%20’Tammy%20Jacobs’,%20’Mary%20West’,%20’Juan%20Mitchell’,%20’Thomas%20Adams’,%20’Christian%20Martinez’,%20’James%20Ramos’,%0A%20%20%20%20’Deborah%20Ross’,%20’Eric%20Holmes’,%20’Thomas%20Diaz’,%20’Sharon%20Morales’,%20’Kathryn%20Hamilton’,%20’Helen%20Edwards’,%20’Betty%20Powell’,%0A%20%20%20%20’Harry%20Campbell’,%20’Raymond%20Perkins’,%20’Melissa%20Wallace’,%20’Danielle%20Hicks’,%20’Harold%20Brewer’,%20’Jack%20Burns’,%20’Anna%20Robinson’,%0A%20%20%20%20’Dorothy%20Nguyen’,%20’Jane%20Dean’,%20’Janice%20Hunter’,%20’Ryan%20Moore’,%20’Brian%20Riley’,%20’Brittany%20Bradley’,%20’Phillip%20Ortega’,%20’William%20Fisher’,%0A%20%20%20%20’Jennifer%20Schultz’,%20’Samantha%20Perez’,%20’Linda%20Carr’,%20’Ann%20Brown’,%20’Shirley%20Kim’,%20’Jeremy%20Alvarez’,%20’Dylan%20Oliver’,%20’Roy%20Gomez’,%0A%20%20%20%20’Ethan%20Brewer’,%20’Ruth%20Lucas’,%20’Marilyn%20Myers’,%20’Danielle%20Wright’,%20’Jose%20Meyer’,%20’Bobby%20Brown’,%20’Angela%20Crawford’,%20’Brandon%20Willis’,%0A%20%20%20%20’Kyle%20McDonald’,%20’Aaron%20Valdez’,%20’Kevin%20Webb’,%20’Ashley%20Gordon’,%20’Karen%20Jenkins’,%20’Johnny%20Santos’,%20’Ashley%20Henderson’,%20’Amy%20Walters’,%0A%20%20%20%20’Amber%20Rodriguez’,%20’Thomas%20Ross’,%20’Dorothy%20Wells’,%20’Jennifer%20Murphy’,%20’Douglas%20Phillips’,%20’Helen%20Johnston’,%20’Nathan%20Hawkins’,%0A%20%20%20%20’Roger%20Mitchell’,%20’Michael%20Young’,%20’Eugene%20Cruz’,%20’Kevin%20Snyder’,%20’Frank%20Ryan’,%20’Tiffany%20Peters’,%20’Beverly%20Garza’,%20’Maria%20Wright’,%0A%20%20%20%20’Shirley%20Jensen’,%20’Carolyn%20Munoz’,%20’Kathleen%20Day’,%20’Ethan%20Meyer’,%20’Rachel%20Fields’,%20’Joan%20Bell’,%20’Ashley%20Sims’,%20’Sara%20Fields’,%0A%20%20%20%20’Elizabeth%20Willis’,%20’Ralph%20Torres’,%20’Charles%20Lopez’,%20’Aaron%20Green’,%20’Arthur%20Hanson’,%20’Betty%20Snyder’,%20’Jose%20Romero’,%20’Linda%20Martinez’,%0A%20%20%20%20’Zachary%20Tran’,%20’Sean%20Matthews’,%20’Eric%20Elliott’,%20’Kimberly%20Welch’,%20’Jason%20Bennett’,%20’Nicole%20Patel’,%20’Emily%20Guzman’,%20’Lori%20Snyder’,%0A%20%20%20%20’Sandra%20White’,%20’Christina%20Lawson’,%20’Jacob%20Campbell’,%20’Ruth%20Foster’,%20’Mark%20McDonald’,%20’Carol%20Williams’,%20’Alice%20Washington’,%0A%20%20%20%20’Brandon%20Ross’,%20’Judy%20Burns’,%20’Zachary%20Hawkins’,%20’Julie%20Chavez’,%20’Randy%20Duncan’,%20’Lisa%20Robinson’,%20’Jacqueline%20Reynolds’,%20’Paul%20Weaver’,%0A%20%20%20%20’Edward%20Gilbert’,%20’Deborah%20Butler’,%20’Frances%20Fox’,%20’Joshua%20Schmidt’,%20’Ashley%20Oliver’,%20’Martha%20Chavez’,%20’Heather%20Hudson’,%0A%20%20%20%20’Lauren%20Collins’,%20’Catherine%20Marshall’,%20’Katherine%20Wells’,%20’Robert%20Munoz’,%20’Pamela%20Nelson’,%20’Dylan%20Bowman’,%20’Virginia%20Snyder’,%0A%20%20%20%20’Janet%20Ruiz’,%20’Ralph%20Burton’,%20’Jose%20Bryant’,%20’Russell%20Medina’,%20’Brittany%20Snyder’,%20’Richard%20Cruz’,%20’Matthew%20Jimenez’,%20’Danielle%20Graham’,%0A%20%20%20%20’Steven%20Guerrero’,%20’Benjamin%20Matthews’,%20’Janet%20Mendoza’,%20’Harry%20Brewer’,%20’Scott%20Cooper’,%20’Alexander%20Keller’,%20’Virginia%20Gordon’,%0A%20%20%20%20’Randy%20Scott’,%20’Kimberly%20Olson’,%20’Helen%20Lynch’,%20’Ronald%20Garcia’,%20’Joseph%20Willis’,%20’Philip%20Walker’,%20’Tiffany%20Harris’,%20’Brittany%20Weber’,%0A%20%20%20%20’Gregory%20Harris’,%20’Sean%20Owens’,%20’Wayne%20Meyer’,%20’Roy%20McCoy’,%20’Keith%20Lucas’,%20’Christian%20Watkins’,%20’Christopher%20Porter’,%20’Sandra%20Lopez’,%0A%20%20%20%20’Harry%20Ward’,%20’Julie%20Sims’,%20’Albert%20Keller’,%20’Lori%20Ortiz’,%20’Virginia%20Henry’,%20’Samuel%20Green’,%20’Judith%20Cole’,%20’Ethan%20Castillo’,%20’Angela%20Ellis’,%0A%20%20%20%20’Amy%20Reid’,%20’Jason%20Brewer’,%20’Aaron%20Clark’,%20’Aaron%20Elliott’,%20’Doris%20Herrera’,%20’Howard%20Castro’,%20’Kenneth%20Davis’,%20’Austin%20Spencer’,%0A%20%20%20%20’Jonathan%20Marshall’,%20’Phillip%20Nelson’,%20’Julia%20Guzman’,%20’Robert%20Hansen’,%20’Kevin%20Anderson’,%20’Gerald%20Arnold’,%20’Austin%20Castro’,%20’Zachary%20Moore’,%0A%20%20%20%20’Joseph%20Cooper’,%20’Barbara%20Black’,%20’Albert%20Mendez’,%20’Marie%20Lane’,%20’Jacob%20Nichols’,%20’Virginia%20Marshall’,%20’Aaron%20Miller’,%20’Linda%20Harvey’,%0A%20%20%20%20’Christopher%20Morris’,%20’Emma%20Fields’,%20’Scott%20Guzman’,%20’Olivia%20Alexander’,%20’Kelly%20Garrett’,%20’Jesse%20Hanson’,%20’Henry%20Wong’,%20’Billy%20Vasquez’,%0A%20%20%20%20’Larry%20Ramirez’,%20’Bryan%20Brooks’,%20’Alan%20Berry’,%20’Nicole%20Powell’,%20’Stephen%20Bowman’,%20’Eric%20Hughes’,%20’Elizabeth%20Obrien’,%20’Timothy%20Ramos’,%0A%20%20%20%20’Michelle%20Russell’,%20’Denise%20Ruiz’,%20’Sean%20Carter’,%20’Amanda%20Barnett’,%20’Kathy%20Black’,%20’Terry%20Gutierrez’,%20’John%20Jensen’,%20’Grace%20Sanchez’,%0A%20%20%20%20’Tiffany%20Harvey’,%20’Jacqueline%20Sims’,%20’Wayne%20Lee’,%20’Roy%20Foster’,%20’Joyce%20Hart’,%20’Joseph%20Russell’,%20’Harold%20Washington’,%20’Beverly%20Cox’,%0A%20%20%20%20’Nicole%20Morales’,%20’Anna%20Carpenter’,%20’Jesse%20Ray’,%20’Ann%20Snyder’,%20’Mark%20Diaz’,%20’Elizabeth%20Harper’,%20’Andrew%20Guerrero’,%20’Cheryl%20Silva’,%0A%20%20%20%20’Michelle%20Hudson’,%20’Jeffrey%20Santos’,%20’Victoria%20Vasquez’,%20’Matthew%20Meyer’,%20’Jacob%20Murray’,%20’Jose%20Munoz’,%20’Edward%20Howell’,%20’Vincent%20Hunter’,%0A%20%20%20%20’Daniel%20Walters’,%20’Samantha%20Obrien’,%20’Laura%20Elliott’,%20’Richard%20Olson’,%20’Daniel%20Graham’,%20’Carol%20Lee’,%20’Grace%20Sullivan’,%20’Nancy%20Rodriguez’,%0A%20%20%20%20’Tyler%20Tran’,%20’Crystal%20Shaw’,%20’Madison%20Allen’,%20’Ralph%20Sims’,%20’Joe%20Jenkins’,%20’Dennis%20Ray’,%20’Arthur%20Davidson’,%20’Victoria%20Allen’,%20’Arthur%20Jackson’,%0A%20%20%20%20’Joan%20Thomas’,%20’Daniel%20Hopkins’,%20’Gloria%20Hicks’,%20’Danielle%20Price’,%20’Craig%20Keller’,%20’Alan%20Morgan’,%20’Gregory%20Silva’,%20’Samantha%20Kelly’,%0A%20%20%20%20’Rachel%20Williamson’,%20’Bruce%20Garrett’,%20’Jacob%20Smith’,%20’Kathleen%20Nichols’,%20’Sarah%20Long’,%20’Carol%20Pearson’,%20’Virginia%20Mendez’,%20’Judy%20Valdez’,%0A%20%20%20%20’Jason%20Garza’,%20’Brenda%20Fowler’,%20’Karen%20Edwards’,%20’Alexander%20Anderson’,%20’Pamela%20Wallace’,%20’Ruth%20Howell’,%20’Walter%20Hernandez’,%20’George%20Lucas’,%0A%20%20%20%20’Samantha%20Long’,%20’Margaret%20Garza’,%20’Kathleen%20Schultz’,%20’Frances%20Guerrero’,%20’Amber%20Meyer’,%20’Rachel%20Morales’,%20’Teresa%20Curtis’,%20’Heather%20Bell’,%0A%20%20%20%20’Grace%20Johnson’,%20’Melissa%20King’,%20’Zachary%20Cook’,%20’Carol%20Schultz’,%20’Jane%20Beck’,%20’Karen%20Stone’,%20’Roger%20Brooks’,%20’Carolyn%20Fuller’,%20’Nicholas%20Coleman’,%0A%20%20%20%20’William%20Bishop’,%20’Christine%20May’,%20’Linda%20George’,%20’Jean%20Meyer’,%20’Cheryl%20Armstrong’,%20’Danielle%20Welch’,%20’Amanda%20Graham’,%20’Janice%20Carter’,%0A%20%20%20%20’Catherine%20Brooks’,%20’Lawrence%20Gonzalez’,%20’Amy%20Russell’,%20’Eugene%20Jimenez’,%20’Joseph%20Carlson’,%20’Peter%20McCoy’,%20’Jerry%20Washington’,%20’Carolyn%20Obrien’,%0A%20%20%20%20’Mark%20Walker’,%20’Stephanie%20Hoffman’,%20’Julie%20Pena’,%20’Karen%20Curtis’,%20’Bryan%20Cruz’,%20’Madison%20Shaw’,%20’Rachel%20Graham’,%20’Susan%20Simpson’,%20’Andrea%20Harrison’,%0A%20%20%20%20’Bryan%20Miller’,%20’Vincent%20McDonald’,%20’Jesse%20McCoy’,%20’Christine%20Ramos’,%20’Dorothy%20Riley’,%20’Karen%20Warren’,%20’Ashley%20Weber’,%20’Judith%20Robinson’,%0A%20%20%20%20’Alan%20Mendez’,%20’Donna%20Medina’,%20’Helen%20Lane’,%20’Douglas%20Clark’,%20’Brenda%20Romero’,%20’Doris%20Wells’,%20’Patrick%20Howell’,%20’Doris%20Lawrence’,%20’Harry%20Jacobs’,%0A%20%20%20%20’Phillip%20Rose’,%20’Deborah%20Patel’,%20’Bryan%20Day’,%20’Rachel%20Butler’,%20’Paul%20Butler’,%20’Judy%20Knight’,%20’Willie%20Wallace’,%20’Phillip%20Anderson’,%20’Emma%20Black’,%0A%20%20%20%20’Lisa%20Lynch’,%20’Kimberly%20Freeman’,%20’Ronald%20West’,%20’Kathleen%20Harris’,%20’Martha%20Ruiz’,%20’Phillip%20Moreno’,%20’Robert%20Vargas’,%20’Jesse%20Diaz’,%20’Christine%20Weber’,%0A%20%20%20%20’Karen%20Stanley’,%20’Theresa%20Edwards’,%20’Kathryn%20Chavez’,%20’Sarah%20Rios’,%20’Danielle%20Wong’,%20’Kathy%20Carr’,%20’Joan%20Diaz’,%20’Albert%20Walters’,%0A%20%20%20%20’Denise%20Kim’,%20’Katherine%20Pearson’,%20’Diana%20Richardson’,%20’Harry%20Ford’,%20’Eric%20Mills’,%20’Sean%20Hicks’,%20’Joe%20Brown’,%20’Judith%20Morgan’,%20’Harry%20Hunter’,%0A%20%20%20%20’Matthew%20Bryant’,%20’Tyler%20Rose’,%20’Mildred%20Delgado’,%20’Emma%20Peters’,%20’Walter%20Delgado’,%20’Lauren%20Gilbert’,%20’Christopher%20Romero’%0A%20%20];%0A%0A%20%20/*%20some%20user%20profile%20images%20for%20our%20fake%20server%20*/%0A%20%20var%20images%20=%20[%0A%20%20%20%20’camilarocun’,%20’brianmichel’,%20’absolutehype’,%20’4l3d’,%20’lynseybrowne’,%20’hi_kendall’,%20’4ae78e7058d2434′,%20’yusuf_y7′,%0A%20%20%20%20’beauty__tattoos’,%20’mehrank36176270′,%20’fabriziocuscini’,%20’hassaminian’,%20’mediajorge’,%20’alexbienz’,%20’eesates’,%20’donjain’,%0A%20%20%20%20’austinknight’,%20’ehlersd’,%20’bipiiin’,%20’victorstuber’,%20’curiousoffice’,%20’chowdhury_sayan’,%20’upslon’,%20’gcauchon’,%20’pawel_murawski’,%0A%20%20%20%20’mr_r_a’,%20’jeremieges’,%20’nickttng’,%20’patrikward’,%20’sinecdoques’,%20’gabrielbeduschi’,%20’ashmigosh’,%20’shxnx’,%20’laborisova’,%0A%20%20%20%20’anand_2688′,%20’mefahad’,%20’puneetsmail’,%20’jefrydagucci’,%20’duck4fuck’,%20’verbaux’,%20’nicolasjengler’,%20’sorousht_’,%20’am0rz’,%0A%20%20%20%20’dominiklevitsky’,%20’jarjan’,%20’ganilaughs’,%20’namphong122′,%20’tiggreen’,%20’allisongrayce’,%20’messagepadapp’,%20’madebylipsum’,%0A%20%20%20%20’tweetubhai’,%20’avonelink’,%20’ahmedkojito’,%20’piripipirics’,%20’dmackerman’,%20’markcipolla’%0A%20%20];%0A%0A%20%20/*%20some%20user%20profile%20descriptions%20for%20our%20fake%20server%20*/%0A%20%20var%20descriptions%20=%20[%0A%20%20%20%20’I%20like%20to%20work%20hard,%20play%20hard!’,%0A%20%20%20%20’I%20drink%20like%20a%20fish,%20that%20is%20a%20fish%20that%20drinks%20coffee.’,%0A%20%20%20%20’OutOfCheeseError:%20Please%20reinstall%20universe.’,%0A%20%20%20%20’Do%20not%20quote%20me.’,%0A%20%20%20%20’No%20one%20reads%20these%20things%20right?’%0A%20%20];%0A%0A%20%20/*%20This%20represents%20a%20database%20of%20users%20on%20the%20server%20*/%0A%20%20var%20userDb%20=%20%7B%7D;%0A%20%20userNames.map(function%20(fullName)%20%7B%0A%20%20%20%20var%20name%20=%20fullName.toLowerCase().replace(/%20/g,%20”);%0A%20%20%20%20var%20description%20=%20descriptions[Math.floor(descriptions.length%20*%20Math.random())];%0A%20%20%20%20var%20image%20=%20’https://s3.amazonaws.com/uifaces/faces/twitter/’%20+%20images[Math.floor(images.length%20*%20Math.random())]%20+%20’/128.jpg’;%0A%20%20%20%20return%20%7B%0A%20%20%20%20%20%20id:%20name,%0A%20%20%20%20%20%20name:%20name,%0A%20%20%20%20%20%20fullName:%20fullName,%0A%20%20%20%20%20%20description:%20description,%0A%20%20%20%20%20%20image:%20image%0A%20%20%20%20%7D;%0A%20%20%7D).forEach(function(user)%20%7B%0A%20%20%20%20userDb[user.id]%20=%20user;%0A%20%20%7D);%0A%0A%20%20/*%20This%20represents%20getting%20the%20complete%20list%20of%20users%20from%20the%20server%20with%20only%20basic%20details%20*/%0A%20%20var%20fetchUsers%20=%20function()%20%7B%0A%20%20%20%20return%20new%20Promise(function(resolve,%20_reject)%20%7B%0A%20%20%20%20%20%20/*%20simulate%20a%20server%20delay%20*/%0A%20%20%20%20%20%20setTimeout(function()%20%7B%0A%20%20%20%20%20%20%20%20var%20users%20=%20Object.keys(userDb).map(function(id)%20%7B%0A%20%20%20%20%20%20%20%20%20%20return%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20id:%20id,%0A%20%20%20%20%20%20%20%20%20%20%20%20name:%20userDb[id].name,%0A%20%20%20%20%20%20%20%20%20%20%7D;%0A%20%20%20%20%20%20%20%20%7D);%0A%20%20%20%20%20%20%20%20resolve(users);%0A%20%20%20%20%20%20%7D,%20500);%0A%20%20%20%20%7D);%0A%20%20%7D;%0A%0A%20%20/*%20This%20represents%20requesting%20all%20the%20details%20of%20a%20single%20user%20from%20the%20server%20database%20*/%0A%20%20var%20fetchUser%20=%20function(id)%20%7B%0A%20%20%20%20return%20new%20Promise(function(resolve,%20reject)%20%7B%0A%20%20%20%20%20%20/*%20simulate%20a%20server%20delay%20*/%0A%20%20%20%20%20%20setTimeout(function()%20%7B%0A%20%20%20%20%20%20%20%20if%20(Object.prototype.hasOwnProperty.call(userDb,%20id))%20%7B%0A%20%20%20%20%20%20%20%20%20%20resolve(userDb[id]);%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20reject(‘unknown%20user%20id%20%22’%20+%20id%20+%20’%22’);%0A%20%20%20%20%20%20%7D,%20300);%0A%20%20%20%20%7D);%0A%20%20%7D;%0A%20%20%0A%20%20return%20%7B%0A%20%20%20%20fetchUsers:%20fetchUsers,%0A%20%20%20%20fetchUser:%20fetchUser%0A%20%20%7D;%0A%7D)();%0A%0A/*%20These%20are%20%22local%22%20caches%20of%20the%20data%20returned%20from%20the%20fake%20server%20*/%0Avar%20usersRequest%20=%20null;%0Avar%20userRequest%20=%20%7B%7D;%0A%0Avar%20mentions_fetch%20=%20function%20(query,%20success)%20%7B%0A%20%20/*%20Fetch%20your%20full%20user%20list%20from%20somewhere%20*/%0A%20%20if%20(usersRequest%20===%20null)%20%7B%0A%20%20%20%20usersRequest%20=%20fakeServer.fetchUsers();%0A%20%20%7D%0A%20%20usersRequest.then(function(users)%20%7B%0A%20%20%20%20/*%20query.term%20is%20the%20text%20the%20user%20typed%20after%20the%20’@’%20*/%0A%20%20%20%20users%20=%20users.filter(function%20(user)%20%7B%0A%20%20%20%20%20%20return%20user.name.indexOf(query.term.toLowerCase())%20!==%20-1;%0A%20%20%20%20%7D);%0A%0A%20%20%20%20users%20=%20users.slice(0,%2010);%0A%20%20%20%20%0A%20%20%20%20/*%20Where%20the%20user%20object%20must%20contain%20the%20properties%20%60id%60%20and%20%60name%60%0A%20%20%20%20%20%20%20but%20you%20could%20additionally%20include%20anything%20else%20you%20deem%20useful.%20*/%0A%20%20%20%20success(users);%0A%20%20%7D);%0A%7D;%0A%0Avar%20mentions_menu_hover%20=%20function%20(userInfo,%20success)%20%7B%0A%20%20/*%20request%20more%20information%20about%20the%20user%20from%20the%20server%20and%20cache%20it%20locally%20*/%0A%20%20if%20(!userRequest[userInfo.id])%20%7B%0A%20%20%20%20userRequest[userInfo.id]%20=%20fakeServer.fetchUser(userInfo.id);%0A%20%20%7D%0A%20%20userRequest[userInfo.id].then(function(userDetail)%20%7B%0A%20%20%20%20var%20div%20=%20document.createElement(‘div’);%0A%0A%20%20%20%20div.innerHTML%20=%20(%0A%20%20%20%20’%3Cdiv%20class=%22card%22%3E’%20+%0A%20%20%20%20%20%20’%3Ch1%3E’%20+%20userDetail.fullName%20+%20’%3C/h1%3E’%20+%0A%20%20%20%20%20%20’%3Cimg%20class=%22avatar%22%20src=%22’%20+%20userDetail.image%20+%20’%22/%3E’%20+%0A%20%20%20%20%20%20’%3Cp%3E’%20+%20userDetail.description%20+%20’%3C/p%3E’%20+%0A%20%20%20%20’%3C/div%3E’%0A%20%20%20%20);%0A%0A%20%20%20%20success(div);%0A%20%20%7D);%0A%7D;%0A%0Avar%20mentions_menu_complete%20=%20function%20(editor,%20userInfo)%20%7B%0A%20%20var%20span%20=%20editor.getDoc().createElement(‘span’);%0A%20%20span.className%20=%20’mymention’;%0A%20%20span.setAttribute(‘data-mention-id’,%20userInfo.id);%0A%20%20span.appendChild(editor.getDoc().createTextNode(‘@’%20+%20userInfo.name));%0A%20%20return%20span;%0A%7D;%0A%0Avar%20mentions_select%20=%20function%20(mention,%20success)%20%7B%0A%20%20/*%20%60mention%60%20is%20the%20element%20we%20previously%20created%20with%20%60mentions_menu_complete%60%0A%20%20%20%20%20in%20this%20case%20we%20have%20chosen%20to%20store%20the%20id%20as%20an%20attribute%20*/%0A%20%20var%20id%20=%20mention.getAttribute(‘data-mention-id’);%0A%20%20/*%20request%20more%20information%20about%20the%20user%20from%20the%20server%20and%20cache%20it%20locally%20*/%0A%20%20if%20(!userRequest[id])%20%7B%0A%20%20%20%20userRequest[id]%20=%20fakeServer.fetchUser(id);%0A%20%20%7D%0A%20%20userRequest[id].then(function(userDetail)%20%7B%0A%20%20%20%20var%20div%20=%20document.createElement(‘div’);%0A%20%20%20%20div.innerHTML%20=%20(%0A%20%20%20%20%20%20’%3Cdiv%20class=%22card%22%3E’%20+%0A%20%20%20%20%20%20’%3Ch1%3E’%20+%20userDetail.fullName%20+%20’%3C/h1%3E’%20+%0A%20%20%20%20%20%20’%3Cimg%20class=%22avatar%22%20src=%22’%20+%20userDetail.image%20+%20’%22/%3E’%20+%0A%20%20%20%20%20%20’%3Cp%3E’%20+%20userDetail.description%20+%20’%3C/p%3E’%20+%0A%20%20%20%20%20%20’%3C/div%3E’%0A%20%20%20%20);%0A%20%20%20%20success(div);%0A%20%20%7D);%0A%7D;%0A%0Atinymce.init(%7B%0A%20%20selector:%20%22textarea#mentions%22,%0A%20%20plugins:%20%22mentions%22,%0A%20%20content_style:%20%22.mymention%7B%20color:%20green;%20%7D%22,%0A%0A%20%20mentions_selector:%20′.mymention’,%0A%20%20mentions_fetch:%20mentions_fetch,%0A%20%20mentions_menu_hover:%20mentions_menu_hover,%0A%20%20mentions_menu_complete:%20mentions_menu_complete,%0A%20%20mentions_select:%20mentions_select%0A%0A%7D);%0A”); var css = decodeURIComponent(“%0Atextarea#mentions%20%7B%0A%20%20height:%20350px;%0A%7D%0A%0Adiv.card%20%7B%0A%20%20width:%20300px;%0A%20%20background:%20white;%0A%20%20border:%203px%20inset%20grey;%0A%20%20padding:%2010px;%0A%20%20font-size:%2016px;%0A%20%20font-family:%20-apple-system,BlinkMacSystemFont,%22Segoe%20UI%22,Roboto,Oxygen-Sans,Ubuntu,Cantarell,%22Helvetica%20Neue%22,sans-serif;%0A%7D%0Adiv.card::after%20%7B%0A%20%20content:%20%22%22;%0A%20%20clear:%20both;%0A%20%20display:%20table;%0A%7D%0A%0Adiv.card%20h1%20%7B%0A%20%20font-size:%20large;%0A%20%20font-weight:%20bold;%0A%20%20margin:%200;%0A%20%20padding:%200;%0A%20%20line-height:%20normal;%0A%20%20font-family:%20-apple-system,BlinkMacSystemFont,%22Segoe%20UI%22,Roboto,Oxygen-Sans,Ubuntu,Cantarell,%22Helvetica%20Neue%22,sans-serif;%0A%7D%0A%0Adiv.card%20p%20%7B%0A%20%20font-family:%20-apple-system,BlinkMacSystemFont,%22Segoe%20UI%22,Roboto,Oxygen-Sans,Ubuntu,Cantarell,%22Helvetica%20Neue%22,sans-serif;%0A%7D%0A%0Adiv.card%20img.avatar%20%7B%0A%20%20width:%2050px;%0A%20%20height:%2050px;%0A%20%20margin-right:%205px;%0A%20%20float:%20left;%0A%7D%0A”); var tabNames = [“run”,”html”,”css”,”js”]; /* Note: there are some other fields we could populate here to polish this. */ /* See: https://blog.codepen.io/documentation/api/prefill/ */ var data = { title: “TinyMCE Example”, description: ”, html: html, css: css, css_external: ‘https://www.tiny.cloud/css/codepen.min.css’, js: js, js_external: ‘https://cloud.tinymce.com/5/tinymce.min.js?apiKey=qagffr3pkuv17a8on1afax661irst1hbr4e6tbv888sz91jc’ }; document.getElementById(“codepen_data_mentions”).value = JSON.stringify(data); /* TODO: */ var tabs = tabNames.map(function(t) { return { tab: document.getElementById(“codepen_tab_” + t + “_” + id), pane: document.getElementById(“codepen_pane_” + t + “_” + id) }; }); tabs.forEach(function(t) { t.tab.onclick = function(e) { tabs.forEach(function(tt) { tt.pane.style.display = t === tt ? ‘block’ : ‘none’; tt.tab.className = t === tt ? ‘codepen_tab_selected’ : ‘codepen_tab_deselected’; }); e.preventDefault(); }; }); if (document.getElementById(“codepen_tab_codepen_” + id) !== null) { document.getElementById(“codepen_tab_codepen_” + id).onclick = function() { document.getElementById(“codepen_form_” + id).submit(); }; } })();

Options

These configuration options affect the execution of the mentions plugin. The main option that needs to be implemented is the mentions_fetch callback.

mentions_fetch

This option lets you request a list of uses from your server that match a search query. The callback gets passed two parameters: one is the search query object, the other is the success callback to execute with the results. The query object has a term property that contains what the user has typed after the “@” sign. The success call should contain an array of users with the required properties “id” and “name”.

Type: function

Default Value: none

Example
var usersRequest = null;
tinymce.init({
  selector: "textarea",
  plugins: "mentions",
  mentions_fetch: function (query, success) {
    // Fetch your full user list from the server and cache locally
    if (usersRequest === null) {
      usersRequest = fetch('/users');
    }
    usersRequest.then(function(users) {
      // query.term is the text the user typed after the '@'
      users = users.filter(function (user) {
        return user.name.indexOf(query.term.toLowerCase()) !== -1;
      });

      users = users.slice(0, 10);
      
      // Where the user object must contain the properties `id` and `name`
      // but you could additionally include anything else you deem useful.
      success(users);
    });
  }
});

Note: The values returned in the users array for “id” and “name” all need to be String values

mentions_menu_complete

This option overrides the default logic for inserting the mention into the editor. The callback should return an element created using the editor’s document.

Type: function

Default Value: none

Example
tinymce.init({
  selector: "textarea",
  plugins: "mentions",
  mentions_selector: 'span.mymention',
  mentions_menu_complete: function (editor, userInfo) {
    var span = editor.getDoc().createElement('span');
    span.className = 'mymention';
    // store the user id in the mention so it can be identified later
    span.setAttribute('data-mention-id', userInfo.id);
    span.appendChild(editor.getDoc().createTextNode('@' + userInfo.name));
    return span;
  }
});

mentions_menu_hover

This option enables you to provide an element to present next to the menu item being hovered. This lets you do custom UIs for presenting user information.

Type: function

Default Value: none

Example
var userRequest = {};
tinymce.init({
  selector: "textarea",
  plugins: "mentions",
  mentions_menu_hover: function (userInfo, success) {
    // request more information about the user from the server and cache it locally
    if (!userRequest[userInfo.id]) {
      userRequest[userInfo.id] = fetch('/user?id=' + userInfo.id);
    }
    userRequest[userInfo.id].then(function(userDetail) {
      var div = document.createElement('div');

      div.innerHTML = (
      '<div>' +
        '<h1>' + userDetail.fullName + '</h1>' +
        '<img src="' + userDetail.image + '" ' +
            'style="width: 50px; height: 50px; float: left;"/>' +
        '<p>' + userDetail.description + '</p>' +
      '</div>'
      );

      success(div);
    });
  }
});

mentions_selector

This option enables you to provide a custom CSS selector that should match the element created using mentions_menu_complete. This enables the plugin to find existing mentions. The callback takes two parameters: the editor instance and the userInfo object.

Type: function

Default Value: none

Example
tinymce.init({
  selector: "textarea",
  plugins: "mentions",
  mentions_selector: 'span.mymention',
  mentions_menu_complete: function (editor, userInfo) {
    var span = editor.getDoc().createElement('span');
    span.className = 'mymention';
    span.setAttribute('data-mention-id', userInfo.id);
    span.appendChild(editor.getDoc().createTextNode('@' + userInfo.name));
    return span;
  }
});

mentions_select

This option enables you to provide an element to be presented below a hovered mention on the page. This could include more details about the user.

Type: function

Default Value: none

Example
var userRequest = {};
tinymce.init({
  selector: "textarea",
  plugins: "mentions",
  mentions_selector: 'span.mymention',
  mentions_menu_complete: function (editor, userInfo) {
    var span = editor.getDoc().createElement('span');
    span.className = 'mymention';
    span.setAttribute('data-mention-id', userInfo.id);
    span.appendChild(editor.getDoc().createTextNode('@' + userInfo.name));
    return span;
  },
  mentions_select: function (mention, success) {
    // `mention` is the element we previously created with `mentions_menu_complete`
    // in this case we have chosen to store the id as an attribute
    var id = mention.getAttribute('data-mention-id');
    // request more information about the user from the server and cache locally
    if (!userRequest[id]) {
      userRequest[id] = fetch('/user?id=' + id);
    }
    userRequest[id].then(function(userDetail) {
      var div = document.createElement('div');
      div.innerHTML = (
        '<div>' +
        '<h1>' + userDetail.fullName + '</h1>' +
        '<img src="' + userDetail.image + '" ' +
            'style="width: 50px; height: 50px; float: left;"/>' +
        '<p>' + userDetail.description + '</p>' +
        '</div>'
      );
      success(div);
    });
  }
});

API

getUsers

You can retrieve the inserted users by calling getUsers on the plugin instance object of an editor. This will return an array of users that the author @mentioned in the content, but only the ones currently present in the content and will exclude any existing before the content was created. It will also exclude duplicate inserts by using the userInfo objects id property.

Example
var users = tinymce.activeEditor.plugins.mentions.getUsers();
console.log(users);

Downloading Mentions Plugin

A TinyMCE Enterprise subscription includes the ability to download and install the mentions feature for the editor.

您暂时不能评论!

管理员开启了需要登录才能够评论,你可以免费注册一个本站的账号。

还没有评论!

目前还没有任何评论,快来抢沙发吧!