1
0
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:
Arrizal Amin
2019-04-25 07:17:28 +07:00
committed by Ian Storm Taylor
parent 4cb13ee5ca
commit 8b27e7e184
6 changed files with 138 additions and 1 deletions

View File

@@ -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

View File

@@ -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()

View File

@@ -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'))

View File

@@ -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'))

View File

@@ -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'))

View File

@@ -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()