A hyperscript helper for creating Slate documents with JSX-like syntax.
90
Build a function that creates Slate editor test fixtures using JSX syntax, with correct text node merging behavior.
Create a JSX factory function that generates Slate editor structures. The function must correctly handle how adjacent text content merges: plain strings should combine when adjacent, but explicitly tagged text nodes must remain separate.
The JSX factory function should:
text property<text> elements separate (never merge them)editor and element structures with children arraystext: "onetwothree" @test<text>foo</text><text>bar</text> remain as two separate text nodes @test<text>b</text> + plain string "c" creates three separate text nodes @test@generates
/**
* Creates a Slate editor structure from JSX elements.
* Handles text node merging according to Slate's conventions.
*
* @param {string} tagName - The JSX tag name (e.g., 'editor', 'element', 'text')
* @param {Object} attributes - Properties to apply to the created node
* @param {Array} children - Child nodes or strings
* @returns {Object} A valid Slate data structure
*/
function jsx(tagName, attributes, ...children) {
// Implementation here
}
module.exports = { jsx };Provides JSX-based document creation with automatic text node merging.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-slate-hyperscriptdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10