mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-18 05:01:17 +02:00
fix get marks from previous text on method getMarksAtPosition (#2688)
This commit is contained in:
committed by
Ian Storm Taylor
parent
4cb13ee5ca
commit
8b27e7e184
@@ -973,7 +973,7 @@ class ElementInterface {
|
||||
const [previousText, previousPath] = previous
|
||||
|
||||
if (closestBlock.hasDescendant(previousPath)) {
|
||||
return previous.getMarksAtIndex(previousText.text.length)
|
||||
return previousText.getMarksAtIndex(previousText.text.length)
|
||||
}
|
||||
|
||||
return currentMarks
|
||||
|
@@ -0,0 +1,25 @@
|
||||
/** @jsx h */
|
||||
|
||||
import h from '../../../helpers/h'
|
||||
import { Set } from 'immutable'
|
||||
import PathUtils from '../../../../src/utils/path-utils'
|
||||
|
||||
const path = PathUtils.create([0, 0])
|
||||
|
||||
export const input = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>
|
||||
<text>
|
||||
<b>Cat is Cute</b>
|
||||
</text>
|
||||
</paragraph>
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
|
||||
export default function({ document, selection }) {
|
||||
return document.getMarksAtPosition(path, 0)
|
||||
}
|
||||
|
||||
export const output = Set.of()
|
@@ -0,0 +1,29 @@
|
||||
/** @jsx h */
|
||||
|
||||
import h from '../../../helpers/h'
|
||||
import { Set } from 'immutable'
|
||||
import { Mark } from 'slate'
|
||||
import PathUtils from '../../../../src/utils/path-utils'
|
||||
|
||||
const path = PathUtils.create([1, 0])
|
||||
|
||||
export const input = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>
|
||||
<text>Cat is Cute</text>
|
||||
</paragraph>
|
||||
<paragraph>
|
||||
<text>
|
||||
<b>Dog is Delightful</b>
|
||||
</text>
|
||||
</paragraph>
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
|
||||
export default function({ document, selection }) {
|
||||
return document.getMarksAtPosition(path, 0)
|
||||
}
|
||||
|
||||
export const output = Set.of(Mark.create('bold'))
|
@@ -0,0 +1,28 @@
|
||||
/** @jsx h */
|
||||
|
||||
import h from '../../../helpers/h'
|
||||
import { Set } from 'immutable'
|
||||
import { Mark } from 'slate'
|
||||
import PathUtils from '../../../../src/utils/path-utils'
|
||||
|
||||
const path = PathUtils.create([0, 0])
|
||||
|
||||
export const input = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>
|
||||
<text>
|
||||
<i>Cat </i>
|
||||
is
|
||||
<b> Cute</b>
|
||||
</text>
|
||||
</paragraph>
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
|
||||
export default function({ document, selection }) {
|
||||
return document.getMarksAtPosition(path, 1)
|
||||
}
|
||||
|
||||
export const output = Set.of(Mark.create('italic'))
|
@@ -0,0 +1,32 @@
|
||||
/** @jsx h */
|
||||
|
||||
import h from '../../../helpers/h'
|
||||
import { Set } from 'immutable'
|
||||
import { Mark } from 'slate'
|
||||
import PathUtils from '../../../../src/utils/path-utils'
|
||||
|
||||
const path = PathUtils.create([1, 1, 0])
|
||||
|
||||
export const input = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>
|
||||
<text>Cat is Cute</text>
|
||||
</paragraph>
|
||||
<paragraph>
|
||||
<text>
|
||||
<b>Dog is</b>
|
||||
</text>
|
||||
<link>
|
||||
<text>Delightful</text>
|
||||
</link>
|
||||
</paragraph>
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
|
||||
export default function({ document, selection }) {
|
||||
return document.getMarksAtPosition(path, 0)
|
||||
}
|
||||
|
||||
export const output = Set.of(Mark.create('bold'))
|
@@ -0,0 +1,23 @@
|
||||
/** @jsx h */
|
||||
|
||||
import h from '../../../helpers/h'
|
||||
import { Set } from 'immutable'
|
||||
import PathUtils from '../../../../src/utils/path-utils'
|
||||
|
||||
const path = PathUtils.create([0, 0])
|
||||
|
||||
export const input = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>
|
||||
<text>Cat is Cute</text>
|
||||
</paragraph>
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
|
||||
export default function({ document, selection }) {
|
||||
return document.getMarksAtPosition(path, 1)
|
||||
}
|
||||
|
||||
export const output = Set.of()
|
Reference in New Issue
Block a user