mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-29 09:59:48 +02:00
feat: add prop surrounds with range (#5729)
* feat: add prop surrounds with range * Create small-carrots-jam.md * fix: docx about range.included --------- Co-authored-by: Dylan Schiemann <dylan@dojotoolkit.org>
This commit is contained in:
@@ -46,6 +46,11 @@ export interface RangeInterface {
|
||||
*/
|
||||
includes: (range: Range, target: Path | Point | Range) => boolean
|
||||
|
||||
/**
|
||||
* Check if a range includes another range.
|
||||
*/
|
||||
surrounds: (range: Range, target: Range) => boolean
|
||||
|
||||
/**
|
||||
* Get the intersection of a range with another.
|
||||
*/
|
||||
@@ -124,6 +129,14 @@ export const Range: RangeInterface = {
|
||||
)
|
||||
},
|
||||
|
||||
surrounds(range: Range, target: Range): boolean {
|
||||
const intersectionRange = Range.intersection(range, target)
|
||||
if (!intersectionRange) {
|
||||
return false
|
||||
}
|
||||
return Range.equals(intersectionRange, target)
|
||||
},
|
||||
|
||||
includes(range: Range, target: Path | Point | Range): boolean {
|
||||
if (Range.isRange(target)) {
|
||||
if (
|
||||
|
Reference in New Issue
Block a user