mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-09-02 03:32:36 +02:00
rename isNonEditable to isInContentEditable
This commit is contained in:
@@ -149,19 +149,22 @@ class Content extends React.Component {
|
|||||||
* @param {Element} n
|
* @param {Element} n
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ref = (n) => this.element = n
|
ref = (element) => {
|
||||||
|
this.element = element
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if an `event` is being fired from inside a non-contentediable child
|
* Check if an `event` is being fired from within the contenteditable element.
|
||||||
* element, in which case we'll want to ignore it.
|
* This will return false for edits happening in non-contenteditable children,
|
||||||
|
* such as void nodes and other nested Slate editors.
|
||||||
*
|
*
|
||||||
* @param {Event} event
|
* @param {Event} event
|
||||||
* @return {Boolean}
|
* @return {Boolean}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
isNonEditable = (event) => {
|
isInContentEditable = (event) => {
|
||||||
const { target } = event
|
const { target } = event
|
||||||
return !target.isContentEditable || target !== this.element
|
return target.isContentEditable && target === this.element
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -172,7 +175,7 @@ class Content extends React.Component {
|
|||||||
|
|
||||||
onBeforeInput = (e) => {
|
onBeforeInput = (e) => {
|
||||||
if (this.props.readOnly) return
|
if (this.props.readOnly) return
|
||||||
if (this.isNonEditable(e)) return
|
if (!this.isInContentEditable(e)) return
|
||||||
|
|
||||||
const data = {}
|
const data = {}
|
||||||
|
|
||||||
@@ -189,7 +192,7 @@ class Content extends React.Component {
|
|||||||
onBlur = (e) => {
|
onBlur = (e) => {
|
||||||
if (this.props.readOnly) return
|
if (this.props.readOnly) return
|
||||||
if (this.tmp.isCopying) return
|
if (this.tmp.isCopying) return
|
||||||
if (this.isNonEditable(e)) return
|
if (!this.isInContentEditable(e)) return
|
||||||
|
|
||||||
const data = {}
|
const data = {}
|
||||||
|
|
||||||
@@ -215,7 +218,7 @@ class Content extends React.Component {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
onCompositionStart = (e) => {
|
onCompositionStart = (e) => {
|
||||||
if (this.isNonEditable(e)) return
|
if (!this.isInContentEditable(e)) return
|
||||||
|
|
||||||
this.tmp.isComposing = true
|
this.tmp.isComposing = true
|
||||||
this.tmp.compositions++
|
this.tmp.compositions++
|
||||||
@@ -232,7 +235,7 @@ class Content extends React.Component {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
onCompositionEnd = (e) => {
|
onCompositionEnd = (e) => {
|
||||||
if (this.isNonEditable(e)) return
|
if (!this.isInContentEditable(e)) return
|
||||||
|
|
||||||
this.forces++
|
this.forces++
|
||||||
const count = this.tmp.compositions
|
const count = this.tmp.compositions
|
||||||
@@ -255,7 +258,7 @@ class Content extends React.Component {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
onCopy = (e) => {
|
onCopy = (e) => {
|
||||||
if (this.isNonEditable(e)) return
|
if (!this.isInContentEditable(e)) return
|
||||||
const window = getWindow(e.target)
|
const window = getWindow(e.target)
|
||||||
|
|
||||||
this.tmp.isCopying = true
|
this.tmp.isCopying = true
|
||||||
@@ -280,7 +283,7 @@ class Content extends React.Component {
|
|||||||
|
|
||||||
onCut = (e) => {
|
onCut = (e) => {
|
||||||
if (this.props.readOnly) return
|
if (this.props.readOnly) return
|
||||||
if (this.isNonEditable(e)) return
|
if (!this.isInContentEditable(e)) return
|
||||||
const window = getWindow(e.target)
|
const window = getWindow(e.target)
|
||||||
|
|
||||||
this.tmp.isCopying = true
|
this.tmp.isCopying = true
|
||||||
@@ -304,7 +307,7 @@ class Content extends React.Component {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
onDragEnd = (e) => {
|
onDragEnd = (e) => {
|
||||||
if (this.isNonEditable(e)) return
|
if (!this.isInContentEditable(e)) return
|
||||||
|
|
||||||
this.tmp.isDragging = false
|
this.tmp.isDragging = false
|
||||||
this.tmp.isInternalDrag = null
|
this.tmp.isInternalDrag = null
|
||||||
@@ -319,7 +322,7 @@ class Content extends React.Component {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
onDragOver = (e) => {
|
onDragOver = (e) => {
|
||||||
if (this.isNonEditable(e)) return
|
if (!this.isInContentEditable(e)) return
|
||||||
|
|
||||||
const { dataTransfer } = e.nativeEvent
|
const { dataTransfer } = e.nativeEvent
|
||||||
const transfer = new Transfer(dataTransfer)
|
const transfer = new Transfer(dataTransfer)
|
||||||
@@ -343,7 +346,7 @@ class Content extends React.Component {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
onDragStart = (e) => {
|
onDragStart = (e) => {
|
||||||
if (this.isNonEditable(e)) return
|
if (!this.isInContentEditable(e)) return
|
||||||
|
|
||||||
this.tmp.isDragging = true
|
this.tmp.isDragging = true
|
||||||
this.tmp.isInternalDrag = true
|
this.tmp.isInternalDrag = true
|
||||||
@@ -369,7 +372,7 @@ class Content extends React.Component {
|
|||||||
|
|
||||||
onDrop = (e) => {
|
onDrop = (e) => {
|
||||||
if (this.props.readOnly) return
|
if (this.props.readOnly) return
|
||||||
if (this.isNonEditable(e)) return
|
if (!this.isInContentEditable(e)) return
|
||||||
|
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
@@ -426,7 +429,7 @@ class Content extends React.Component {
|
|||||||
onInput = (e) => {
|
onInput = (e) => {
|
||||||
if (this.tmp.isComposing) return
|
if (this.tmp.isComposing) return
|
||||||
if (this.props.state.isBlurred) return
|
if (this.props.state.isBlurred) return
|
||||||
if (this.isNonEditable(e)) return
|
if (!this.isInContentEditable(e)) return
|
||||||
debug('onInput')
|
debug('onInput')
|
||||||
|
|
||||||
const window = getWindow(e.target)
|
const window = getWindow(e.target)
|
||||||
@@ -496,7 +499,7 @@ class Content extends React.Component {
|
|||||||
|
|
||||||
onKeyDown = (e) => {
|
onKeyDown = (e) => {
|
||||||
if (this.props.readOnly) return
|
if (this.props.readOnly) return
|
||||||
if (this.isNonEditable(e)) return
|
if (!this.isInContentEditable(e)) return
|
||||||
|
|
||||||
const key = keycode(e.which)
|
const key = keycode(e.which)
|
||||||
const data = {}
|
const data = {}
|
||||||
@@ -551,7 +554,7 @@ class Content extends React.Component {
|
|||||||
|
|
||||||
onPaste = (e) => {
|
onPaste = (e) => {
|
||||||
if (this.props.readOnly) return
|
if (this.props.readOnly) return
|
||||||
if (this.isNonEditable(e)) return
|
if (!this.isInContentEditable(e)) return
|
||||||
|
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
const transfer = new Transfer(e.clipboardData)
|
const transfer = new Transfer(e.clipboardData)
|
||||||
@@ -571,7 +574,7 @@ class Content extends React.Component {
|
|||||||
if (this.props.readOnly) return
|
if (this.props.readOnly) return
|
||||||
if (this.tmp.isCopying) return
|
if (this.tmp.isCopying) return
|
||||||
if (this.tmp.isComposing) return
|
if (this.tmp.isComposing) return
|
||||||
if (this.isNonEditable(e)) return
|
if (!this.isInContentEditable(e)) return
|
||||||
|
|
||||||
const window = getWindow(e.target)
|
const window = getWindow(e.target)
|
||||||
const { state } = this.props
|
const { state } = this.props
|
||||||
|
Reference in New Issue
Block a user