Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@grammarly/editor-sdk

Package Overview
Dependencies
Maintainers
7
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@grammarly/editor-sdk - npm Package Compare versions

Comparing version 2.0.0-alpha.0 to 2.0.0-alpha.1

91

lib/editor-sdk.beta.d.ts

@@ -240,3 +240,2 @@ /**

*
*
* @defaultValue "on"

@@ -256,2 +255,12 @@ * @public

underlines?: "on" | "off";
/**
* Activation strategy used by the Editor Plugin
* - focus: Plugin activates once the text field is focused
* - immediate: Plugin activates immediately
*
* @defaultValue "focus"
* @public
* @since v2.0.0-alpha.1
*/
activation?: "focus" | "immediate";
}

@@ -324,2 +333,43 @@

/**
* `<grammarly-button>` is a web component that allows you to place the Grammarly button
* in a custom position in your app.
*
* @remarks
* [Learn more](https://developer.grammarly.com/docs/customization#grammarly-button)
*
* @public
*/
declare class GrammarlyButtonElement extends HTMLElement {
private readonly _outlet;
private readonly _attrs;
private readonly _cleanup;
/**
* The position of the {@link https://developer.grammarly.com/docs/tone | tone detector} (if present) relative to the Grammarly button.
*
* @example
* ```html
* <grammarly-button tone-position="left"></grammarly-button>
* ```
*
* @defaultValue "left"
* @public
*/
get tonePosition(): TonePosition | undefined;
set tonePosition(value: TonePosition | undefined);
private _render;
/**
* Upgrade property to prototype getter/setter.
*
* @see https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
*/
private _upgradeProperty;
}
/** @public */

@@ -372,8 +422,7 @@ declare interface GrammarlyEditorPluginCallbacks {

/**
* @public
* `<grammarly-editor-plugin>` is a web component that adds Grammarly suggestions to the HTML element it wraps.
*
* A web component to encapsulate DOM elements rendered
* for displaying highlights and suggestion cards.
* Emits custom events: {@link GrammarlyEditorPluginElementEventMap}
*
* Emits custom events: {@link GrammarlyEditorPluginElementEventMap}
* @public
*/

@@ -395,2 +444,16 @@ declare class GrammarlyEditorPluginElement extends HTMLElement {

*
* @example
* ```html
* <grammarly-editor-plugin>
* <textarea></textarea>
* </grammarly-editor-plugin>
* ```
*
* ```js
* <script>
* const editor = document.querySelector("grammarly-editor-plugin")
* editor.config = { autocomplete: "on", documentDialect: "british" };
* </script>
* ```
*
* @public

@@ -405,5 +468,10 @@ */

* and connect to an editable child element (editor) and its scrollable container
* (viewport). This function provides a way to specify the editor and viewport,
* overriding what was automatically detected.
* (viewport).
*
* In rare cases, you may need to override what was automatically detected.
* This function provides a way to do that by specifying a different editor and viewport.
*
* @example
* See [editor-sdk-tinymce-imperative](https://codesandbox.io/s/github/grammarly/grammarly-for-developers/tree/main/examples/editor-sdk-tinymce-imperative?file=/public/index.html)
*
* @param editor - the editable element

@@ -763,2 +831,9 @@ * @param viewport - scrollable outer element of the editable element

export { ClientId, Config, Dialect, DocumentStats, Domain, Editor, EditorConfig, EditorSDK, Event_2 as Event, EventListener_2 as EventListener, GrammarlyEditorPluginCallbacks, GrammarlyEditorPluginElement, GrammarlyEditorPluginElementEventMap, SessionStats, SessionSuggestionBreakdown, SuggestionCategories, Time, init };
/**
* Position of the {@link https://developer.grammarly.com/docs/tone | tone detector} (if present) relative to the Grammarly button.
*
* @public
*/
declare type TonePosition = "left" | "right";
export { ClientId, Config, Dialect, DocumentStats, Domain, Editor, EditorConfig, EditorSDK, Event_2 as Event, EventListener_2 as EventListener, GrammarlyButtonElement, GrammarlyEditorPluginCallbacks, GrammarlyEditorPluginElement, GrammarlyEditorPluginElementEventMap, SessionStats, SessionSuggestionBreakdown, SuggestionCategories, Time, TonePosition, init };

@@ -232,3 +232,2 @@ /**

*
*
* @defaultValue "on"

@@ -248,2 +247,12 @@ * @public

underlines?: "on" | "off";
/**
* Activation strategy used by the Editor Plugin
* - focus: Plugin activates once the text field is focused
* - immediate: Plugin activates immediately
*
* @defaultValue "focus"
* @public
* @since v2.0.0-alpha.1
*/
activation?: "focus" | "immediate";
}

@@ -316,2 +325,43 @@

/**
* `<grammarly-button>` is a web component that allows you to place the Grammarly button
* in a custom position in your app.
*
* @remarks
* [Learn more](https://developer.grammarly.com/docs/customization#grammarly-button)
*
* @public
*/
declare class GrammarlyButtonElement extends HTMLElement {
private readonly _outlet;
private readonly _attrs;
private readonly _cleanup;
/**
* The position of the {@link https://developer.grammarly.com/docs/tone | tone detector} (if present) relative to the Grammarly button.
*
* @example
* ```html
* <grammarly-button tone-position="left"></grammarly-button>
* ```
*
* @defaultValue "left"
* @public
*/
get tonePosition(): TonePosition | undefined;
set tonePosition(value: TonePosition | undefined);
private _render;
/**
* Upgrade property to prototype getter/setter.
*
* @see https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
*/
private _upgradeProperty;
}
/** @public */

@@ -364,8 +414,7 @@ declare interface GrammarlyEditorPluginCallbacks {

/**
* @public
* `<grammarly-editor-plugin>` is a web component that adds Grammarly suggestions to the HTML element it wraps.
*
* A web component to encapsulate DOM elements rendered
* for displaying highlights and suggestion cards.
* Emits custom events: {@link GrammarlyEditorPluginElementEventMap}
*
* Emits custom events: {@link GrammarlyEditorPluginElementEventMap}
* @public
*/

@@ -387,2 +436,16 @@ declare class GrammarlyEditorPluginElement extends HTMLElement {

*
* @example
* ```html
* <grammarly-editor-plugin>
* <textarea></textarea>
* </grammarly-editor-plugin>
* ```
*
* ```js
* <script>
* const editor = document.querySelector("grammarly-editor-plugin")
* editor.config = { autocomplete: "on", documentDialect: "british" };
* </script>
* ```
*
* @public

@@ -397,5 +460,10 @@ */

* and connect to an editable child element (editor) and its scrollable container
* (viewport). This function provides a way to specify the editor and viewport,
* overriding what was automatically detected.
* (viewport).
*
* In rare cases, you may need to override what was automatically detected.
* This function provides a way to do that by specifying a different editor and viewport.
*
* @example
* See [editor-sdk-tinymce-imperative](https://codesandbox.io/s/github/grammarly/grammarly-for-developers/tree/main/examples/editor-sdk-tinymce-imperative?file=/public/index.html)
*
* @param editor - the editable element

@@ -755,2 +823,9 @@ * @param viewport - scrollable outer element of the editable element

export { ClientId, Config, Dialect, DocumentStats, Domain, Editor, EditorConfig, EditorSDK, Event_2 as Event, EventListener_2 as EventListener, GrammarlyEditorPluginCallbacks, GrammarlyEditorPluginElement, GrammarlyEditorPluginElementEventMap, SessionStats, SessionSuggestionBreakdown, SuggestionCategories, Time, init };
/**
* Position of the {@link https://developer.grammarly.com/docs/tone | tone detector} (if present) relative to the Grammarly button.
*
* @public
*/
declare type TonePosition = "left" | "right";
export { ClientId, Config, Dialect, DocumentStats, Domain, Editor, EditorConfig, EditorSDK, Event_2 as Event, EventListener_2 as EventListener, GrammarlyButtonElement, GrammarlyEditorPluginCallbacks, GrammarlyEditorPluginElement, GrammarlyEditorPluginElementEventMap, SessionStats, SessionSuggestionBreakdown, SuggestionCategories, Time, TonePosition, init };

2

lib/index.esm.js

@@ -17,2 +17,2 @@ /**

*/
function t(t,r,n){return r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}class r extends Error{constructor(r,n){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";super(),t(this,"args",void 0),t(this,"code",void 0),t(this,"url",void 0);var o=new URL("https://developer.grammarly.com/docs/error-explainer");o.searchParams.set("code",r.toString()),n.forEach((t=>o.searchParams.append("args",String(t)))),null!=this.stack&&o.searchParams.set("trace",this.stack),this.message="Minified error #".concat(r,": ").concat(e," See ").concat(o.toString()," for details."),this.args=n,this.code=r,this.url=o.toString()}}const n=new WeakMap;async function e(t,e,o){if("undefined"==typeof window&&void 0===o)throw new r(21,[]);const a=await async function(t,e,o){const a=n.get(t);if(null!=a)return await a;!function(t){null==t.Grammarly&&(t.Grammarly={})}(t);const s=new Promise(((n,a)=>{try{let n=function(t,r){return t.document.querySelectorAll(`script[src^="${r}"]`)[0]}(t,e);null!=n?s():(n=function(t,r){const n=t.document.createElement("script");return n.src=r,t.document.head.appendChild(n),n}(t,null!=o?`${e}?clientId=${o}`:e),n.addEventListener("load",s),n.addEventListener("error",(function(){try{throw new r(23,[])}catch(t){a(t)}})))}catch(t){return a(t)}function s(){try{if(null==t.Grammarly||"function"!=typeof t.Grammarly.EditorSDK)throw new r(22,[]);n(t.Grammarly)}catch(t){a(t)}}}));return n.set(t,s),await s}(null!=o?o:window,"https://js.grammarly.com/grammarly-editor-sdk@2.0",t);if(null!=t)return new a.EditorSDK(t,e)}const o={onBeforeSuggestionCardOpen:"before-suggestion-card-open",onSuggestionCardOpen:"suggestion-card-open",onSuggestionCardClose:"suggestion-card-close",onPluginTurnedOff:"plugin-turned-off",onPluginError:"plugin-error",onDocumentStats:"document-stats",onSessionStats:"session-stats"};export{o as callbackToEventName,e as init};
function t(t,r,n){return r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}class r extends Error{constructor(r,n){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";super(),t(this,"args",void 0),t(this,"code",void 0),t(this,"url",void 0);var o=new URL("https://developer.grammarly.com/docs/error-explainer");o.searchParams.set("code",r.toString()),n.forEach((t=>o.searchParams.append("args",String(t)))),null!=this.stack&&o.searchParams.set("trace",this.stack),this.message="Minified error #".concat(r,": ").concat(e," See ").concat(o.toString()," for details."),this.args=n,this.code=r,this.url=o.toString()}}const n=new WeakMap;async function e(t,e,o){if("undefined"==typeof window&&void 0===o)throw new r(21,[]);const a=await async function(t,e,o){const a=n.get(t);if(null!=a)return await a;!function(t){null==t.Grammarly&&(t.Grammarly={})}(t);const s=new Promise(((n,a)=>{try{let n=function(t,r){return t.document.querySelectorAll(`script[src^="${r}"]`)[0]}(t,e);null!=n?s():(n=function(t,r){const n=t.document.createElement("script");return n.src=r,t.document.head.appendChild(n),n}(t,null!=o?`${e}?clientId=${o}`:e),n.addEventListener("load",s),n.addEventListener("error",(function(){try{throw new r(23,[])}catch(t){a(t)}})))}catch(t){return a(t)}function s(){try{if(null==t.Grammarly||"function"!=typeof t.Grammarly.EditorSDK)throw new r(22,[]);n(t.Grammarly)}catch(t){a(t)}}}));return n.set(t,s),await s}(null!=o?o:window,"https://js.grammarly.com/grammarly-editor-sdk@2.0.0-alpha.1",t);if(null!=t)return new a.EditorSDK(t,e)}const o={onBeforeSuggestionCardOpen:"before-suggestion-card-open",onSuggestionCardOpen:"suggestion-card-open",onSuggestionCardClose:"suggestion-card-close",onPluginTurnedOff:"plugin-turned-off",onPluginError:"plugin-error",onDocumentStats:"document-stats",onSessionStats:"session-stats"};export{o as callbackToEventName,e as init};

@@ -17,2 +17,2 @@ /**

*/
!function(){"use strict";function t(t,r,n){return r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}class r extends Error{constructor(r,n){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";super(),t(this,"args",void 0),t(this,"code",void 0),t(this,"url",void 0);var a=new URL("https://developer.grammarly.com/docs/error-explainer");a.searchParams.set("code",r.toString()),n.forEach((t=>a.searchParams.append("args",String(t)))),null!=this.stack&&a.searchParams.set("trace",this.stack),this.message="Minified error #".concat(r,": ").concat(e," See ").concat(a.toString()," for details."),this.args=n,this.code=r,this.url=a.toString()}}const n=new WeakMap;async function e(t,e,a){if("undefined"==typeof window&&void 0===a)throw new r(21,[]);const c=await async function(t,e,a){const c=n.get(t);if(null!=c)return await c;!function(t){null==t.Grammarly&&(t.Grammarly={})}(t);const i=new Promise(((n,c)=>{try{let n=function(t,r){return t.document.querySelectorAll('script[src^="https://js.grammarly.com/grammarly-editor-sdk@2.0"]')[0]}(t);null!=n?i():(n=function(t,r){const n=t.document.createElement("script");return n.src=r,t.document.head.appendChild(n),n}(t,null!=a?`${e}?clientId=${a}`:e),n.addEventListener("load",i),n.addEventListener("error",(function(){try{throw new r(23,[])}catch(t){c(t)}})))}catch(t){return c(t)}function i(){try{if(null==t.Grammarly||"function"!=typeof t.Grammarly.EditorSDK)throw new r(22,[]);n(t.Grammarly)}catch(t){c(t)}}}));return n.set(t,i),await i}(null!=a?a:window,"https://js.grammarly.com/grammarly-editor-sdk@2.0",t);if(null!=t)return new c.EditorSDK(t,e)}const a=function(){const t=function(){if(document.currentScript instanceof HTMLScriptElement)return document.currentScript}();if(t){const r=t.src;if(r){const t=new URL(r).searchParams.get("clientId");if(null!=t)return t}const n=t.getAttribute("clientId");if(null!=n)return n}}(),c=async function(t){return await t.catch((t=>{console.error(t.message)}))}(null!=a?e(a):e());window.Grammarly.init=async(t=a)=>{const n=a===t?await c:null!=t?await e(t):void 0;if(null==n)throw new r(20,[]);return n}}();
!function(){"use strict";function t(t,r,n){return r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}class r extends Error{constructor(r,n){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";super(),t(this,"args",void 0),t(this,"code",void 0),t(this,"url",void 0);var a=new URL("https://developer.grammarly.com/docs/error-explainer");a.searchParams.set("code",r.toString()),n.forEach((t=>a.searchParams.append("args",String(t)))),null!=this.stack&&a.searchParams.set("trace",this.stack),this.message="Minified error #".concat(r,": ").concat(e," See ").concat(a.toString()," for details."),this.args=n,this.code=r,this.url=a.toString()}}const n=new WeakMap;async function e(t,e,a){if("undefined"==typeof window&&void 0===a)throw new r(21,[]);const c=await async function(t,e,a){const c=n.get(t);if(null!=c)return await c;!function(t){null==t.Grammarly&&(t.Grammarly={})}(t);const i=new Promise(((n,c)=>{try{let n=function(t,r){return t.document.querySelectorAll('script[src^="https://js.grammarly.com/grammarly-editor-sdk@2.0.0-alpha.1"]')[0]}(t);null!=n?i():(n=function(t,r){const n=t.document.createElement("script");return n.src=r,t.document.head.appendChild(n),n}(t,null!=a?`${e}?clientId=${a}`:e),n.addEventListener("load",i),n.addEventListener("error",(function(){try{throw new r(23,[])}catch(t){c(t)}})))}catch(t){return c(t)}function i(){try{if(null==t.Grammarly||"function"!=typeof t.Grammarly.EditorSDK)throw new r(22,[]);n(t.Grammarly)}catch(t){c(t)}}}));return n.set(t,i),await i}(null!=a?a:window,"https://js.grammarly.com/grammarly-editor-sdk@2.0.0-alpha.1",t);if(null!=t)return new c.EditorSDK(t,e)}const a=function(){const t=function(){if(document.currentScript instanceof HTMLScriptElement)return document.currentScript}();if(t){const r=t.src;if(r){const t=new URL(r).searchParams.get("clientId");if(null!=t)return t}const n=t.getAttribute("clientId");if(null!=n)return n}}(),c=async function(t){return await t.catch((t=>{console.error(t.message)}))}(null!=a?e(a):e());window.Grammarly.init=async(t=a)=>{const n=a===t?await c:null!=t?await e(t):void 0;if(null==n)throw new r(20,[]);return n}}();

@@ -17,2 +17,2 @@ /**

*/
"use strict";function e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class t extends Error{constructor(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";super(),e(this,"args",void 0),e(this,"code",void 0),e(this,"url",void 0);var o=new URL("https://developer.grammarly.com/docs/error-explainer");o.searchParams.set("code",t.toString()),r.forEach((e=>o.searchParams.append("args",String(e)))),null!=this.stack&&o.searchParams.set("trace",this.stack),this.message="Minified error #".concat(t,": ").concat(n," See ").concat(o.toString()," for details."),this.args=r,this.code=t,this.url=o.toString()}}const r=new WeakMap;exports.callbackToEventName={onBeforeSuggestionCardOpen:"before-suggestion-card-open",onSuggestionCardOpen:"suggestion-card-open",onSuggestionCardClose:"suggestion-card-close",onPluginTurnedOff:"plugin-turned-off",onPluginError:"plugin-error",onDocumentStats:"document-stats",onSessionStats:"session-stats"},exports.init=async function(e,n,o){if("undefined"==typeof window&&void 0===o)throw new t(21,[]);const a=await async function(e,n,o){const a=r.get(e);if(null!=a)return await a;!function(e){null==e.Grammarly&&(e.Grammarly={})}(e);const s=new Promise(((r,a)=>{try{let r=function(e,t){return e.document.querySelectorAll(`script[src^="${t}"]`)[0]}(e,n);null!=r?s():(r=function(e,t){const r=e.document.createElement("script");return r.src=t,e.document.head.appendChild(r),r}(e,null!=o?`${n}?clientId=${o}`:n),r.addEventListener("load",s),r.addEventListener("error",(function(){try{throw new t(23,[])}catch(e){a(e)}})))}catch(e){return a(e)}function s(){try{if(null==e.Grammarly||"function"!=typeof e.Grammarly.EditorSDK)throw new t(22,[]);r(e.Grammarly)}catch(e){a(e)}}}));return r.set(e,s),await s}(null!=o?o:window,"https://js.grammarly.com/grammarly-editor-sdk@2.0",e);if(null!=e)return new a.EditorSDK(e,n)};
"use strict";function e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class t extends Error{constructor(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";super(),e(this,"args",void 0),e(this,"code",void 0),e(this,"url",void 0);var o=new URL("https://developer.grammarly.com/docs/error-explainer");o.searchParams.set("code",t.toString()),r.forEach((e=>o.searchParams.append("args",String(e)))),null!=this.stack&&o.searchParams.set("trace",this.stack),this.message="Minified error #".concat(t,": ").concat(n," See ").concat(o.toString()," for details."),this.args=r,this.code=t,this.url=o.toString()}}const r=new WeakMap;exports.callbackToEventName={onBeforeSuggestionCardOpen:"before-suggestion-card-open",onSuggestionCardOpen:"suggestion-card-open",onSuggestionCardClose:"suggestion-card-close",onPluginTurnedOff:"plugin-turned-off",onPluginError:"plugin-error",onDocumentStats:"document-stats",onSessionStats:"session-stats"},exports.init=async function(e,n,o){if("undefined"==typeof window&&void 0===o)throw new t(21,[]);const a=await async function(e,n,o){const a=r.get(e);if(null!=a)return await a;!function(e){null==e.Grammarly&&(e.Grammarly={})}(e);const s=new Promise(((r,a)=>{try{let r=function(e,t){return e.document.querySelectorAll(`script[src^="${t}"]`)[0]}(e,n);null!=r?s():(r=function(e,t){const r=e.document.createElement("script");return r.src=t,e.document.head.appendChild(r),r}(e,null!=o?`${n}?clientId=${o}`:n),r.addEventListener("load",s),r.addEventListener("error",(function(){try{throw new t(23,[])}catch(e){a(e)}})))}catch(e){return a(e)}function s(){try{if(null==e.Grammarly||"function"!=typeof e.Grammarly.EditorSDK)throw new t(22,[]);r(e.Grammarly)}catch(e){a(e)}}}));return r.set(e,s),await s}(null!=o?o:window,"https://js.grammarly.com/grammarly-editor-sdk@2.0.0-alpha.1",e);if(null!=e)return new a.EditorSDK(e,n)};

@@ -5,3 +5,3 @@ {

"description": "Grammarly writing SDK for web editors",
"version": "2.0.0-alpha.0",
"version": "2.0.0-alpha.1",
"main": "./lib/index.js",

@@ -29,6 +29,6 @@ "module": "./lib/index.esm.js",

"devDependencies": {
"@grammarly/plugin-core": "2.0.0-alpha.0",
"@grammarly/plugin-editor": "2.0.0-alpha.0",
"@grammarly/plugin-invariant": "2.0.0-alpha.0",
"@grammarly/plugin-reactivity": "2.0.0-alpha.0",
"@grammarly/plugin-core": "2.0.0-alpha.1",
"@grammarly/plugin-editor": "2.0.0-alpha.1",
"@grammarly/plugin-invariant": "2.0.0-alpha.1",
"@grammarly/plugin-reactivity": "2.0.0-alpha.1",
"@microsoft/api-extractor": "^7.28.7",

@@ -35,0 +35,0 @@ "@testing-library/jest-dom": "^5.11.10",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc