CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-slate-hyperscript

A hyperscript helper for creating Slate documents with JSX-like syntax.

90

1.15x
Overview
Eval results
Files

task.mdevals/scenario-7/

Text Selection Test Fixture Generator

A utility for generating test fixtures for a rich text editor, with support for various cursor positions and text selections.

Capabilities

Creates editor state with cursor at text start

  • Given an element with text content, placing a cursor marker at the beginning of the text produces an editor with selection at offset 0. @test

Creates editor state with cursor in middle of text

  • Given an element with text content, placing a cursor marker in the middle of the text produces an editor with selection at the correct offset. @test

Creates editor state with cursor at text end

  • Given an element with text content, placing a cursor marker at the end of the text produces an editor with selection at the final offset. @test

Creates editor state with text range selection

  • Given an element with text content, placing anchor and focus markers at different positions produces an editor with a range selection spanning the correct offsets. @test

Implementation

@generates

API

/**
 * Creates a test fixture for an editor with a cursor at the start of text.
 *
 * @returns {Object} An editor object with selection at text start
 */
function createEditorWithCursorAtStart() {
  // IMPLEMENTATION HERE
}

/**
 * Creates a test fixture for an editor with a cursor in the middle of text.
 *
 * @returns {Object} An editor object with selection in middle of text
 */
function createEditorWithCursorInMiddle() {
  // IMPLEMENTATION HERE
}

/**
 * Creates a test fixture for an editor with a cursor at the end of text.
 *
 * @returns {Object} An editor object with selection at text end
 */
function createEditorWithCursorAtEnd() {
  // IMPLEMENTATION HERE
}

/**
 * Creates a test fixture for an editor with a range selection.
 *
 * @returns {Object} An editor object with a range selection
 */
function createEditorWithRangeSelection() {
  // IMPLEMENTATION HERE
}

module.exports = {
  createEditorWithCursorAtStart,
  createEditorWithCursorInMiddle,
  createEditorWithCursorAtEnd,
  createEditorWithRangeSelection
};

Dependencies { .dependencies }

slate-hyperscript { .dependency }

Provides hyperscript helpers for creating Slate documents with inline selection markers.

Install with Tessl CLI

npx tessl i tessl/npm-slate-hyperscript

tile.json