diff --git a/packages/slate/src/commands/at-range.js b/packages/slate/src/commands/at-range.js index 7b3501606..c730a949d 100644 --- a/packages/slate/src/commands/at-range.js +++ b/packages/slate/src/commands/at-range.js @@ -1268,6 +1268,10 @@ Commands.wrapInlineAtRange = (editor, range, inline) => { // Wrapping an inline void const inlineParent = document.getClosestInline(start.key) + if (!inlineParent) { + return + } + if (!editor.isVoid(inlineParent)) { return } diff --git a/packages/slate/test/commands/at-current-range/wrap-inline/collapsed-range-without-parent-void-inline.js b/packages/slate/test/commands/at-current-range/wrap-inline/collapsed-range-without-parent-void-inline.js new file mode 100644 index 000000000..15c54fb75 --- /dev/null +++ b/packages/slate/test/commands/at-current-range/wrap-inline/collapsed-range-without-parent-void-inline.js @@ -0,0 +1,27 @@ +/** @jsx h */ + +import h from '../../../helpers/h' + +export default function(editor) { + editor.wrapInline('hashtag') +} + +export const input = ( + + + + wd + + + +) + +export const output = ( + + + + wd + + + +)