How to use the linkifyjs.find function in linkifyjs

To help you get started, we’ve selected a few linkifyjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ntheile / blockusign / Blockusign.Radik / common / lib / notifier / index.js View on Github external
const handleNewModel = async (db, attrs) => {
  // console.log('emitter', attrs);
  if (attrs.radiksType !== 'Message') {
    return true;
  }

  const { content, createdBy } = attrs;
  console.log(`@${createdBy}: ${content}`);
  const matches = linkify.find(content);
  const mentions = {};

  matches.forEach((match) => {
    if (match.type === 'mention') {
      const username = match.value.slice(1);
      mentions[username] = true;
    }
  });

  const mentionedUsers = Object.keys(mentions);

  console.log('Mentions:', mentionedUsers.join(','));

  const centralCollection = db.collection(CENTRAL_COLLECTION);
  const collectMentionsToSend = mentionedUsers.map((username) => new Promise(async (resolve, reject) => {
    try {
github assembl / assembl / assembl / static / js / app / views / messageSend.js View on Github external
_processHyperlinks: _.throttle(function() {
    var that = this,
        messageText = this.ui.messageBody.val()||'',
        links = linkify.find(messageText),
        missingLinks = [],
        goneModels = [];
    //console.log("_processHyperlinks called");
    //console.log(links);
    //console.log(this.attachmentsCollection);

    // this.attachmentsCollection.comparator = function (attachmentModel) {
    //   var index = _.findIndex(links, function(link) {
    //     //console.log(attachmentModel.getDocument().get('uri'), link.href);
    //     return attachmentModel.getDocument().get('uri') === link.href;
    //   })
    //   //console.log("attachmentsCollection comparator returning: ", index);
    //   return index;
    // };
    goneModels = that.attachmentsCollection.filter(function(attachment) {
      var document = attachment.getDocument();
github 01fade / me-and-my-fb-data / src / App.js View on Github external
passToNextState(msgTimes, msgContent){
    let links = [];
    if(msgTimes) {
      console.log("messagestimes", msgTimes.length);
      this.setState({messagesTimes: msgTimes});
    }
    if(msgContent) {
      console.log("messagesContent", msgContent.length);
      links = linkify.find(msgContent).filter((d)=>{return d.type === "url"; });
      this.setState({messagesContent: links});
    }
    // only for DEV
    // this.saveToLocalStorage(msgTimes, links);
    this.setState({dataReady: true});
  }
github coralproject / talk / services / moderation / phases / links.js View on Github external
module.exports = (
  ctx,
  comment,
  {
    asset: {
      settings: { premodLinksEnable },
    },
  }
) => {
  if (premodLinksEnable) {
    const links = linkify.find(comment.body.replace(/\xAD/g, ''));
    if (!links || links.length === 0) {
      return;
    }

    // Add the flag related to Trust to the comment.
    return {
      status: 'SYSTEM_WITHHELD',
      actions: [
        {
          action_type: 'FLAG',
          user_id: null,
          group_id: 'LINKS',
          metadata: {
            links: comment.body,
          },
        },
github blockstack-radiks / banter / common / lib / notifier / index.js View on Github external
const handleNewModel = async (db, attrs) => {
  if (attrs.radiksType !== 'Message') {
    return true;
  }

  const { content, createdBy } = attrs;
  console.log(`@${createdBy}: ${content}`);
  const matches = linkify.find(content);
  const mentions = {};

  matches.forEach((match) => {
    if (match.type === 'mention') {
      const username = match.value.slice(1);
      mentions[username] = true;
    }
  });

  const mentionedUsers = Object.keys(mentions);

  console.log('Mentions:', mentionedUsers.join(','));

  const centralCollection = db.collection(CENTRAL_COLLECTION);
  const collectMentionsToSend = mentionedUsers.map(
    (username) =>
github joaocarmo / react-smart-data-table / lib / TableCell.js View on Github external
parseURLs(value, filterValue, parseImg) {
    const grabLinks = linkify.find(value)
    const highlightedValue = this.highlightValue(value, filterValue)
    if (isEmpty(grabLinks)) {
      if (isDataURL(value)) {
        return this.renderImage(value, parseImg, true)
      }
      return highlightedValue
    }
    const firstLink = head(grabLinks)
    let image = null
    if (parseImg && firstLink.type === 'url') {
      image = this.renderImage(value, parseImg)
    }
    return (
      <a href="{firstLink.href}"> e.stopPropagation()}&gt;
        {image || highlightedValue}
      </a>
github kiraka / annict-web / app / frontend / javascript / common / filters / linkify.js View on Github external
export default function(str) {
  const links = linkify.find(str);

  for (let link of Array.from(links)) {
    str = str.replace(link.value, _getTag(link));
  }

  return str;
}

linkifyjs

Find URLs, email addresses, #hashtags and @mentions in plain-text strings, then convert them into HTML <a> links.

MIT
Latest version published 5 months ago

Package Health Score

81 / 100
Full package analysis