request = require 'request'
@@ -54,28 +54,28 @@ YandexLanguages =
'Korean': 'ko'
class TranslateButton extends React.Component
diff --git a/examples/N1-Composer-Translate/docs/main.coffee b/examples/N1-Composer-Translate/docs/main.coffee index bba0b3a01..22017ac56 100644 --- a/examples/N1-Composer-Translate/docs/main.coffee +++ b/examples/N1-Composer-Translate/docs/main.coffee @@ -51,8 +51,8 @@ class TranslateButton extends React.Component # `React.createElement('a', {href: 'http://facebook.github.io/react/'}, 'Hello!')` # # We're rendering a `Popover` with a `Menu` inside. These components are part - # of Edgehill's standard `nylas-component-kit` library, and make it easy to build - # interfaces that match the rest of Edgehill's UI. + # of N1's standard `nylas-component-kit` library, and make it easy to build + # interfaces that match the rest of N1's UI. # render: => React.createElement(Popover, {"ref": "popover", \ diff --git a/examples/N1-Composer-Translate/docs/main.html b/examples/N1-Composer-Translate/docs/main.html index eaafe2c62..4de2ef3a7 100644 --- a/examples/N1-Composer-Translate/docs/main.html +++ b/examples/N1-Composer-Translate/docs/main.html @@ -10,14 +10,14 @@
request = require 'request'
@@ -54,28 +54,28 @@ YandexLanguages =
'Korean': 'ko'
class TranslateButton extends React.Component
Adding a displayName
makes debugging React easier
@displayName: 'TranslateButton'
prop
(a read-only
property). Since our code depends on this prop, we mark it as a requirement.
@propTypes:
draftLocalId: React.PropTypes.string.isRequired
into Javascript objects which describe the HTML you want:
React.createElement('a', {href: 'http://facebook.github.io/react/'}, 'Hello!')
We’re rendering a Popover
with a Menu
inside. These components are part
-of Edgehill’s standard nylas-component-kit
library, and make it easy to build
-interfaces that match the rest of Edgehill’s UI.
nylas-component-kit
library, and make it easy to build
+interfaces that match the rest of N1’s UI.
render: =>
React.createElement(Popover, {"ref": "popover", \
"className": "translate-language-picker pull-right", \
@@ -120,13 +120,13 @@ interfaces that match the rest of Edgehill’s UI.
)
RetinaImg
will automatically chose the best image format for our display.
_renderButton: =>
React.createElement("button", {"className": "btn btn-toolbar"}, """
Translate
@@ -144,13 +144,13 @@ interfaces that match the rest of Edgehill’s UI.
_onTranslate: (lang) =>
@refs.popover.close()
session = DraftStore.sessionForLocalId(@props.draftLocalId)
session.prepare().then =>
body = session.draft().body
bodyQuoteStart = Utils.quotedTextIndex(body)
if bodyQuoteStart > 0
text = body.substr(0, bodyQuoteStart)
else
@@ -189,30 +189,30 @@ don’t translate quoted text.
lang: YandexLanguages[lang]
text: text
format: 'html'
Use Node’s request
library to perform the translation using the Yandex API.
request {url: YandexTranslationURL, qs: query}, (error, resp, data) =>
return @_onError(error) unless resp.statusCode is 200
json = JSON.parse(data)
translated = json.text.join('')
translated += body.substr(bodyQuoteStart) if bodyQuoteStart > 0
session.changes.add(body: translated)
session.changes.commit()
@@ -249,13 +249,13 @@ the same draft are notified of changes.
module.exports =
serialize
it is provided.
activate: (@state) ->
ComponentRegistry.register TranslateButton,
role: 'Composer:ActionButton'
serialize: ->
deactivate: ->
ComponentRegistry.unregister(TranslateButton)