mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-16 05:00:45 +08:00
cfdc401c54
Summary: - Rename DraftStoreExtension to ComposerExtension - Rename MessageStoreExtension to MessageViewExtension - Rename ContenteditablePlugin to ContenteditableExtension - Update Contenteditable to use new naming convention - Adds support for extension handlers as props - Add ExtensionRegistry to register extensions: - ContenteditableExtensions will not be registered through the ExtensionRegistry. They are meant for internal use, or if anyone wants to use our Contenteditable component directly in their plugins. - Adds specs - Refactors internal_packages and src to use new names and new ExtensionRegistry api - Adds deprecation util function and deprecation notices for old api methods: - DraftStore.{registerExtension, unregisterExtension} - MessageStore.{registerExtension, unregisterExtension} - DraftStoreExtension.{onMouseUp, onTabDown} - MessageStoreExtension - Adds and updates docs Test Plan: - Unit tests Reviewers: bengotow, evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D2293
16 lines
675 B
CoffeeScript
16 lines
675 B
CoffeeScript
Autolinker = require 'autolinker'
|
|
{MessageViewExtension} = require 'nylas-exports'
|
|
|
|
class AutolinkerExtension extends MessageViewExtension
|
|
|
|
@formatMessageBody: (message) ->
|
|
# Apply the autolinker pass to make emails and links clickable
|
|
message.body = Autolinker.link(message.body, {twitter: false})
|
|
|
|
# Ensure that the hrefs in the email always have alt text so you can't hide
|
|
# the target of links
|
|
# https://regex101.com/r/cH0qM7/1
|
|
message.body = message.body.replace /href[ ]*=[ ]*?['"]([^'"]*)(['"]+)/gi, (match, url, quoteCharacter) =>
|
|
return "#{match} title=#{quoteCharacter}#{url}#{quoteCharacter} "
|
|
|
|
module.exports = AutolinkerExtension
|