forked from kaydelaney/slate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
insertTextByPath should replace marks on the inserted text with the o…
…nce that are provided (ianstormtaylor#2936) It were trying to add those marks that are passed to the function to the existing once, but it should replace them instead. Example error behavior was: * put cursor at the end of the marked text * toggle marks * enter text expected: text is being added without toggled marks actual: text is added with those marks applied
- Loading branch information
1 parent
9d9d606
commit 65796c8
Showing
6 changed files
with
153 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/slate/test/commands/by-key/replace-marks-by-key/different-set-of-marks.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** @jsx h */ | ||
|
||
import h from '../../../helpers/h' | ||
|
||
export default function(editor) { | ||
editor.replaceMarksByKey('a', 0, 2, [{ type: 'italic' }]) | ||
} | ||
|
||
export const input = ( | ||
<value> | ||
<document> | ||
<paragraph> | ||
<b key="a" thing="value"> | ||
word | ||
</b> | ||
</paragraph> | ||
</document> | ||
</value> | ||
) | ||
|
||
export const output = ( | ||
<value> | ||
<document> | ||
<paragraph> | ||
<i>wo</i> | ||
<b thing="value">rd</b> | ||
</paragraph> | ||
</document> | ||
</value> | ||
) |
30 changes: 30 additions & 0 deletions
30
packages/slate/test/commands/by-key/replace-marks-by-key/empty-set.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** @jsx h */ | ||
|
||
import h from '../../../helpers/h' | ||
|
||
export default function(editor) { | ||
editor.replaceMarksByKey('a', 0, 2, []) | ||
} | ||
|
||
export const input = ( | ||
<value> | ||
<document> | ||
<paragraph> | ||
<b key="a" thing="value"> | ||
word | ||
</b> | ||
</paragraph> | ||
</document> | ||
</value> | ||
) | ||
|
||
export const output = ( | ||
<value> | ||
<document> | ||
<paragraph> | ||
wo | ||
<b thing="value">rd</b> | ||
</paragraph> | ||
</document> | ||
</value> | ||
) |
32 changes: 32 additions & 0 deletions
32
packages/slate/test/commands/by-key/replace-marks-by-key/same-marks-different-data.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** @jsx h */ | ||
|
||
import h from '../../../helpers/h' | ||
|
||
export default function(editor) { | ||
editor.replaceMarksByKey('a', 0, 2, [ | ||
{ type: 'bold', data: { thing: 'new value' } }, | ||
]) | ||
} | ||
|
||
export const input = ( | ||
<value> | ||
<document> | ||
<paragraph> | ||
<b key="a" thing="value"> | ||
word | ||
</b> | ||
</paragraph> | ||
</document> | ||
</value> | ||
) | ||
|
||
export const output = ( | ||
<value> | ||
<document> | ||
<paragraph> | ||
<b thing="new value">wo</b> | ||
<b thing="value">rd</b> | ||
</paragraph> | ||
</document> | ||
</value> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters