slate icon indicating copy to clipboard operation
slate copied to clipboard

isBlock returns true for text nodes

Open kristian-puccio opened this issue 1 year ago • 9 comments

Description

isBlock return's true for text nodes. This affects Plate as you can pass any value into it's wrapper around isBlock.

Expectation

If you pass something that isn't an element into isBlock it should return false. Quite possible the type of Value should be widened and the check for isElement happen in the function.

I have read https://github.com/ianstormtaylor/slate/issues/5219 and understand it but as isVoid and isBlock aren't defined at the type level they probably should just return booleans.

Environment

  • Slate Version: [e.g. 0.59]
  • Operating System: [e.g. iOS]
  • Browser: [e.g. Chrome, Safari]
  • TypeScript Version: [e.g. 3.9.7 - required only if it's a TypeScript issue]

Context

This affects Plate's indentPlugin as it applies the indent to the text node rather than the containing block. I'm not sure if it affects other things

kristian-puccio avatar Feb 09 '23 05:02 kristian-puccio