The Syntax: What’s New in Grammarly for Developers | Grammarly

  • Post category:Blog


OMG, y’all, it’s June! Four months have flown by since I posted the last edition of The Syntax, and I’m excited to share with you the features and fixes our engineering team has implemented since then. Here is what I’ll cover in this post:

Video overview

Dictionaries 📖

Emoji autocomplete 😲

suggestion-card-action ➡️

Performance improvements for long-form text 📈

Wrapping up

Video overview

Last week I hosted a live stream where members of the Grammarly for Developers team joined me to show off the latest features and fixes. A recording of the stream is available below:

Dictionaries 📖

TL;DR: You can create an app dictionary so Grammarly will recognize the terms and jargon that your users frequently write.

Grammarly recognizes a wide variety of words, but we’ve heard from many of you that your users include industry-specific jargon and terms in their text. When Grammarly doesn’t recognize the jargon and terms, Grammarly flags them as being misspelled.

If your app is on the Plus plan, you can create app dictionaries and configure which of your text editors use them beginning in version 2.5.0. For example, you might want to configure some text editors to use legal and medical dictionaries while you might want to configure others to use a dictionary of tech jargon.

A user adds the words prebirds, sandoozles, and youie to a new app dictionary.

I built a dictionary of words from the TV show Parks and Recreation because, in my opinion, it’s the best show ever created. And that is a fact. 😉

On the Dictionaries page in the App Console, you can add words to a dictionary individually, or you can upload a CSV file containing a line-separated list of words. Once you’ve added words to a dictionary and configured your text editor to use it, Grammarly will no longer flag the words in the dictionary as being misspelled.

Side note for those of you who are wondering how this functionality differs from the personal dictionary I described in the February edition of The Syntax:

  • Individual users of your app can add words to their own personal dictionaries. Only they have access to that dictionary.
  • App owners and collaborators can create app dictionaries. Once you have configured a text editor to use an app dictionary, Grammarly will use the app dictionary for any user who writes text in that editor.

If you create a dictionary that others may find helpful, I encourage you to upload the CSV file to GitHub or another location of your choice and share the link in this discussion thread in the Grammarly for Developers GitHub repo. To get the fun started, I’ve created a dictionary for terms from the TV show Parks and Recreation and shared it in the thread.

Emoji autocomplete 😲

TL;DR: Your users can insert emojis by typing a colon followed by a letter.

I love emojis, and chances are good that many of your users do as well. We’ve made it easier for your users to add emojis to their text by implementing emoji autocomplete in version 2.4.0 of the SDK.

If your app is on the Plus plan, you can turn on emoji autocomplete using the autocomplete config option. You can choose between four possible values for autocomplete:

  • on: Text phrase autocomplete and emoji autocomplete
  • text: Only text phrase autocomplete
  • emoji: Only emoji autocomplete
  • off: No autocomplete of any kind. This is the default option.

When emoji autocomplete is turned on, your users will be able to add an emoji by typing a colon followed by a letter.

A user types text that ends with ‘:smile.’ An emoji selection menu appears, and the user selects the ‘smile-cat’ emoji.

suggestion-card-action ➡️

TL;DR: Your app can listen for the suggestion-card-action event to know when a user has accepted a suggestion, dismissed a suggestion, or closed an open suggestion card.

We know that many of you need to programmatically take an action when your users interact with the Grammarly Text Editor Plugin. We received a request for the plugin to emit an event whenever a user interacts with an open suggestion card, so we created the suggestion-card-action event in version 2.3.14.

The suggestion-card-action event is emitted whenever a user interacts with an open suggestion card by accepting a suggestion, dismissing a suggestion, or closing the card.

A user accepts a suggestion, dismisses a suggestion, and closes a suggestion box. As they do, information about each event appears on the page.

For example, in JavaScript you can add an event listener to your editor:

Then you can create a function to handle the event. The example function below only logs the event, but your function could do something more useful with the event data.

The suggestion-card-action event includes a lot of information. You’ll likely be most interested in the type and detail properties.

The Text Editor Plugin exposes several custom events, including document-stats (which provides information like the readability score, word count, and reading time) and session-stats (which provides information like the number of accepted suggestions and the number of words analyzed during the current session). Learn more about all of the events on the new Custom Events page in the docs. You can also explore the events in this example hosted on CodeSandbox.

Performance improvements for long-form text 📈

TL;DR: We fixed performance issues for long-form text.

I feel the need: the need for speed!

 

 

 

 

 

 

We made performance improvements for editors containing large amounts of text (text >1500 words) in version 2.3.15. (A huge shout out to Gnohz Gniy for reporting the performance issue!) Be on the lookout for an upcoming post on the Grammarly for Developers blog where we’ll provide a behind-the-scenes look at how we optimize SDK performance.

If you encounter any performance issues after upgrading to version 2.3.15 or later, please report an issue in the Grammarly for Developers GitHub repo.

Wrapping up

Our team has delivered fun and useful features and fixes over the last few months:

  • You can create an app dictionary so that Grammarly won’t flag terms that are common in your app as misspelled words.
  • Your users can insert emojis by typing a colon followed by a letter.
  • Your app can programmatically take an action whenever a user accepts a suggestion, dismisses a suggestion, or closes an open suggestion card by listening for the suggestion-card-action event.
  • You’ll notice a performance improvement when using the SDK with long-form text.

For a detailed list of what was included in each release, check out the changelog.

As always, we would love to hear from you! If you have any questions or suggestions for improvement, please start a discussion in the Grammarly for Developers GitHub repo. I look forward to chatting with you there!



Source link