How to use the twitter-text.autoLinkWithJSON function in twitter-text

To help you get started, we’ve selected a few twitter-text 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 mitmedialab / gobo / client / app / components / Post / TweetText.js View on Github external
entities.media.forEach((e) => {
      text = text.replace(e.url, '');
    });
  }

  // remove any quote links
  if (entities && data.quoted_status) {
    entities.urls.forEach((u) => {
      if (u.expanded_url.indexOf('/status/') > -1) {
        text = text.replace(u.url, '');
      }
    });
  }

  // replace + style links and mentions
  text = twitterText.autoLinkWithJSON(text, (entities || {}), { usernameIncludeSymbol: true });
  text = text.replace(/href=/g, 'style="text-decoration: none;color:#6CCCF9;" href=');

  // replace + style emoji
  text = twemoji.parse(text);
  text = text.replace(/
github GoogleChromeLabs / adaptive-loading / react-twitter-save-data-loading(client-hint) / src / components / Twitter / Text.js View on Github external
}

  // remove any quote links
  if (entities && data.quoted_status) {
    entities.urls.forEach(item => {
      if (item.expanded_url.indexOf('/status/') > -1) {
        text = text.replace(item.url, '');
      }
    });
  }

  // replace line break
  text = text.replace(/\r?\n/, '<br>');

  // replace + style links and mentions
  text = twitterText.autoLinkWithJSON(text, (entities || {}), {'usernameIncludeSymbol': true});
  text = text.replace(/href=/g, 'style="text-decoration: none;color:#1da1f2;" href=');

  // replace + style emoji
  text = twemoji.parse(text);
  text = text.replace(/
github mannynotfound / react-tweet / src / components / Tweet / Text.js View on Github external
entities.media.forEach( e =&gt; {
        text = text.replace(e.url, '')
      })
    }

    // remove any quote links
    if (entities &amp;&amp; data.quoted_status) {
      entities.urls.forEach( u =&gt; {
        if (u.expanded_url.indexOf('/status/') &gt; -1) {
          text = text.replace(u.url, '')
        }
      })
    }

    // replace + style links and mentions
    text = twitterText.autoLinkWithJSON(text, (entities || {}), {'usernameIncludeSymbol': true})
    text = text.replace(/href=/g, 'style="text-decoration: none;color:#6CCCF9;" href=')

    // replace + style emoji
    text = twemoji.parse(text)
    text = text.replace(/
github shprink / ionic-angular-twitter-pwa / src / components / tweet-text / tweet-text.ts View on Github external
ngOnChanges(changes: any) {
    if (changes.text && changes.text.currentValue && this.tweetContent && changes.text.currentValue !== changes.text.previousValue) {
      this.text = this.entities
        ? autoLinkWithJSON(this.text, this.entities || {}, this.options)
        : autoLink(this.text, this.options);
      this.tweetContent.nativeElement.innerHTML = this.text;
      const links = this.tweetContent.nativeElement.querySelectorAll('a');

      [].forEach.call(links, a => {
        if (a.classList.contains('username')) {
          a.onclick = e => this.goToProfile(e, a.innerText);
        } else if (a.classList.contains('hashtag')) {
          a.onclick = e => this.goToSearch(e, a.innerText);
        } else {
          a.onclick = e => this.openLink(e, a.getAttribute('href'));
        }
      });
    }
  }