mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-27 09:04:31 +02:00
Support decorations without path (#2697)
* Add support with warning for decorations without paths * Fix linting * Update text.js * Update text.js
This commit is contained in:
committed by
Ian Storm Taylor
parent
feaad7e7cd
commit
662f584d4d
@@ -1,11 +1,10 @@
|
||||
import Debug from 'debug'
|
||||
import ImmutableTypes from 'react-immutable-proptypes'
|
||||
import Leaf from './leaf'
|
||||
import { PathUtils } from 'slate'
|
||||
import React from 'react'
|
||||
import SlateTypes from 'slate-prop-types'
|
||||
import Types from 'prop-types'
|
||||
import { PathUtils } from 'slate'
|
||||
|
||||
import Leaf from './leaf'
|
||||
|
||||
/**
|
||||
* Debug.
|
||||
@@ -117,12 +116,15 @@ class Text extends React.Component {
|
||||
// Otherwise, if the decoration is in a single node, it's not ours.
|
||||
if (start.key === end.key) return false
|
||||
|
||||
// If the node's path is before the start path, ignore it.
|
||||
const path = document.assertPath(key)
|
||||
if (PathUtils.compare(path, start.path) === -1) return false
|
||||
const startPath = start.path || document.assertPath(start.key)
|
||||
const endPath = end.path || document.assertPath(end.key)
|
||||
|
||||
// If the node's path is before the start path, ignore it.
|
||||
if (PathUtils.compare(path, startPath) === -1) return false
|
||||
|
||||
// If the node's path is after the end path, ignore it.
|
||||
if (PathUtils.compare(path, end.path) === 1) return false
|
||||
if (PathUtils.compare(path, endPath) === 1) return false
|
||||
|
||||
// Otherwise, include it.
|
||||
return true
|
||||
|
Reference in New Issue
Block a user