Skip to content

Commit

Permalink
Add prop to optionally enable grammarly
Browse files Browse the repository at this point in the history
  • Loading branch information
nadeemsk committed Jun 14, 2019
1 parent 7d4062c commit 1742a1d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/slate-react/src/components/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Types from 'prop-types'
import getWindow from 'get-window'
import warning from 'tiny-warning'
import throttle from 'lodash/throttle'
import omit from 'lodash/omit'
import { List } from 'immutable'
import {
IS_ANDROID,
Expand Down Expand Up @@ -541,8 +542,11 @@ class Content extends React.Component {
[DATA_ATTRS.KEY]: document.key,
}

const domProps = omit(this.props, Object.keys(Content.propTypes))

return (
<Container
{...domProps}
key={this.tmp.contentKey}
{...handlers}
{...data}
Expand All @@ -559,7 +563,9 @@ class Content extends React.Component {
// COMPAT: The Grammarly Chrome extension works by changing the DOM out
// from under `contenteditable` elements, which leads to weird behaviors
// so we have to disable it like this. (2017/04/24)
data-gramm={false}

// just the existence of the flag is disabling the extension irrespective of its value
data-gramm={customProps['data-gramm'] ? undefined : false}
>
<Node
annotations={value.annotations}
Expand Down
4 changes: 4 additions & 0 deletions packages/slate-react/src/components/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Types from 'prop-types'
import invariant from 'tiny-invariant'
import memoizeOne from 'memoize-one'
import warning from 'tiny-warning'
import omit from 'lodash/omit'
import { Editor as Controller } from 'slate'

import EVENT_HANDLERS from '../constants/event-handlers'
Expand Down Expand Up @@ -174,8 +175,11 @@ class Editor extends React.Component {
tagName,
} = this.props

const domProps = omit(this.props, Object.keys(Editor.propTypes))

const children = (
<Content
{...domProps}
ref={this.tmp.contentRef}
autoCorrect={autoCorrect}
className={className}
Expand Down

0 comments on commit 1742a1d

Please sign in to comment.