- // Tests need fixing:
- // ...GRAPHEME_SCENARIOS.flatMap(({description, grapheme}) => [
- // {
- // name: `Delete backward eliminates entire ${description} (${grapheme})`,
- // inputs: [insertText(grapheme + grapheme), deleteBackward(1)],
- // expectedHTML: `<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p dir=\"ltr\"><span>${grapheme}</span></p></div>`,
- // expectedSelection: {
- // anchorPath: [0, 0, 0],
- // anchorOffset: grapheme.length,
- // focusPath: [0, 0, 0],
- // focusOffset: grapheme.length,
- // },
- // setup: emptySetup,
- // },
- // {
- // name: `Delete forward eliminates entire ${description} (${grapheme})`,
- // inputs: [
- // insertText(grapheme + grapheme),
- // moveNativeSelection([0, 0, 0], 0, [0, 0, 0], 0),
- // deleteForward(),
- // ],
- // expectedHTML: `<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p dir=\"ltr\"><span>${grapheme}</span></p></div>`,
- // expectedSelection: {
- // anchorPath: [0, 0, 0],
- // anchorOffset: 0,
- // focusPath: [0, 0, 0],
- // focusOffset: 0,
- // },
- // setup: emptySetup,
- // },
- // {
- // name: `Move backward skips over grapheme cluster (${grapheme})`,
- // inputs: [insertText(grapheme + grapheme), moveBackward(1)],
- // expectedHTML: `<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p dir=\"ltr\"><span>${grapheme}${grapheme}</span></p></div>`,
- // expectedSelection: {
- // anchorPath: [0, 0, 0],
- // anchorOffset: grapheme.length,
- // focusPath: [0, 0, 0],
- // focusOffset: grapheme.length,
- // },
- // setup: emptySetup,
- // },
- // {
- // name: `Move forward skips over grapheme cluster (${grapheme})`,
- // inputs: [
- // insertText(grapheme + grapheme),
- // moveNativeSelection([0, 0, 0], 0, [0, 0, 0], 0),
- // moveForward(),
- // ],
- // expectedHTML: `<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p dir=\"ltr\"><span>${grapheme}${grapheme}</span></p></div>`,
- // expectedSelection: {
- // anchorPath: [0, 0, 0],
- // anchorOffset: grapheme.length,
- // focusPath: [0, 0, 0],
- // focusOffset: grapheme.length,
- // },
- // setup: emptySetup,
- // },
- // ]),
- // {
- // name: 'Jump to beginning and insert',
- // inputs: [
- // insertText('1'),
- // insertText('1'),
- // insertText('2'),
- // insertText('3'),
- // moveNativeSelection([0, 0, 0], 0, [0, 0, 0], 0),
- // insertText('a'),
- // insertText('b'),
- // insertText('c'),
- // deleteForward(),
- // ],
- // expectedHTML:
- // '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph" dir="ltr"><span data-lexical-text="true">abc123</span></p></div>',
- // expectedSelection: {
- // anchorPath: [0, 0, 0],
- // anchorOffset: 3,
- // focusPath: [0, 0, 0],
- // focusOffset: 3,
- // },
- // },
- // {
- // name: 'Select and replace',
- // inputs: [
- // insertText('Hello draft!'),
- // moveNativeSelection([0, 0, 0], 6, [0, 0, 0], 11),
- // insertText('lexical'),
- // ],
- // expectedHTML:
- // '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph" dir="ltr"><span data-lexical-text="true">Hello lexical!</span></p></div>',
- // expectedSelection: {
- // anchorPath: [0, 0, 0],
- // anchorOffset: 13,
- // focusPath: [0, 0, 0],
- // focusOffset: 13,
- // },
- // },
- // {
- // name: 'Select and bold',
- // inputs: [
- // insertText('Hello draft!'),
- // moveNativeSelection([0, 0, 0], 6, [0, 0, 0], 11),
- // formatBold(),
- // ],
- // expectedHTML:
- // '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph" dir="ltr"><span data-lexical-text="true">Hello </span>' +
- // '<strong class="editor-text-bold" data-lexical-text="true">draft</strong><span data-lexical-text="true">!</span></p></div>',
- // expectedSelection: {
- // anchorPath: [0, 1, 0],
- // anchorOffset: 0,
- // focusPath: [0, 1, 0],
- // focusOffset: 5,
- // },
- // },
- // {
- // name: 'Select and italic',
- // inputs: [
- // insertText('Hello draft!'),
- // moveNativeSelection([0, 0, 0], 6, [0, 0, 0], 11),
- // formatItalic(),
- // ],
- // expectedHTML:
- // '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph" dir="ltr"><span data-lexical-text="true">Hello </span>' +
- // '<em class="editor-text-italic" data-lexical-text="true">draft</em><span data-lexical-text="true">!</span></p></div>',
- // expectedSelection: {
- // anchorPath: [0, 1, 0],
- // anchorOffset: 0,
- // focusPath: [0, 1, 0],
- // focusOffset: 5,
- // },
- // },
- // {
- // name: 'Select and bold + italic',
- // inputs: [
- // insertText('Hello draft!'),
- // moveNativeSelection([0, 0, 0], 6, [0, 0, 0], 11),
- // formatBold(),
- // formatItalic(),
- // ],
- // expectedHTML:
- // '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph" dir="ltr"><span data-lexical-text="true">Hello </span>' +
- // '<strong class="editor-text-bold editor-text-italic" data-lexical-text="true">draft</strong><span data-lexical-text="true">!</span></p></div>',
- // expectedSelection: {
- // anchorPath: [0, 1, 0],
- // anchorOffset: 0,
- // focusPath: [0, 1, 0],
- // focusOffset: 5,
- // },
- // },
- // {
- // name: 'Select and underline',
- // inputs: [
- // insertText('Hello draft!'),
- // moveNativeSelection([0, 0, 0], 6, [0, 0, 0], 11),
- // formatUnderline(),
- // ],
- // expectedHTML:
- // '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph" dir="ltr"><span data-lexical-text="true">Hello </span>' +
- // '<span class="editor-text-underline" data-lexical-text="true">draft</span><span data-lexical-text="true">!</span></p></div>',
- // expectedSelection: {
- // anchorPath: [0, 1, 0],
- // anchorOffset: 0,
- // focusPath: [0, 1, 0],
- // focusOffset: 5,
- // },
- // },
- // {
- // name: 'Select and strikethrough',
- // inputs: [
- // insertText('Hello draft!'),
- // moveNativeSelection([0, 0, 0], 6, [0, 0, 0], 11),
- // formatStrikeThrough(),
- // ],
- // expectedHTML:
- // '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph" dir="ltr"><span data-lexical-text="true">Hello </span>' +
- // '<span class="editor-text-strikethrough" data-lexical-text="true">draft</span><span data-lexical-text="true">!</span></p></div>',
- // expectedSelection: {
- // anchorPath: [0, 1, 0],
- // anchorOffset: 0,
- // focusPath: [0, 1, 0],
- // focusOffset: 5,
- // },
- // },
- // {
- // name: 'Select and underline + strikethrough',
- // inputs: [
- // insertText('Hello draft!'),
- // moveNativeSelection([0, 0, 0], 6, [0, 0, 0], 11),
- // formatUnderline(),
- // formatStrikeThrough(),
- // ],
- // expectedHTML:
- // '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph" dir="ltr"><span data-lexical-text="true">Hello </span>' +
- // '<span class="editor-text-underlineStrikethrough" data-lexical-text="true">draft</span><span data-lexical-text="true">!</span></p></div>',
- // expectedSelection: {
- // anchorPath: [0, 1, 0],
- // anchorOffset: 0,
- // focusPath: [0, 1, 0],
- // focusOffset: 5,
- // },
- // },
- // {
- // name: 'Select and replace all',
- // inputs: [
- // insertText('This is broken.'),
- // moveNativeSelection([0, 0, 0], 0, [0, 0, 0], 15),
- // insertText('This works!'),
- // ],
- // expectedHTML:
- // '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph" dir="ltr"><span data-lexical-text="true">This works!</span></p></div>',
- // expectedSelection: {
- // anchorPath: [0, 0, 0],
- // anchorOffset: 11,
- // focusPath: [0, 0, 0],
- // focusOffset: 11,
- // },
- // },
- // {
- // name: 'Select and delete',
- // inputs: [
- // insertText('A lion.'),
- // moveNativeSelection([0, 0, 0], 2, [0, 0, 0], 6),
- // deleteForward(),
- // insertText('duck'),
- // moveNativeSelection([0, 0, 0], 2, [0, 0, 0], 6),
- // ],
- // expectedHTML:
- // '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph" dir="ltr"><span data-lexical-text="true">A duck.</span></p></div>',
- // expectedSelection: {
- // anchorPath: [0, 0, 0],
- // anchorOffset: 2,
- // focusPath: [0, 0, 0],
- // focusOffset: 6,
- // },
- // },
- // {
- // name: 'Inserting a paragraph',
- // inputs: [insertParagraph()],
- // expectedHTML:
- // '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph"><span data-lexical-text="true"><br></span></p>' +
- // '<p class="editor-paragraph"><span data-lexical-text="true"><br></span></p></div>',
- // expectedSelection: {
- // anchorPath: [1, 0, 0],
- // anchorOffset: 0,
- // focusPath: [1, 0, 0],
- // focusOffset: 0,
- // },
- // },
- // {
- // name: 'Inserting a paragraph and then removing it',
- // inputs: [insertParagraph(), deleteBackward(1)],
- // expectedHTML:
- // '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph"><span data-lexical-text="true"><br></span></p></div>',
- // expectedSelection: {
- // anchorPath: [0, 0, 0],
- // anchorOffset: 0,
- // focusPath: [0, 0, 0],
- // focusOffset: 0,
- // },
- // },
- // {
- // name: 'Inserting a paragraph part way through text',
- // inputs: [
- // insertText('Hello world'),
- // moveNativeSelection([0, 0, 0], 6, [0, 0, 0], 6),
- // insertParagraph(),
- // ],
- // expectedHTML:
- // '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph" dir="ltr"><span data-lexical-text="true">Hello </span></p>' +
- // '<p class="editor-paragraph" dir="ltr"><span data-lexical-text="true">world</span></p></div>',
- // expectedSelection: {
- // anchorPath: [1, 0, 0],
- // anchorOffset: 0,
- // focusPath: [1, 0, 0],
- // focusOffset: 0,
- // },
- // },
- // {
- // name: 'Inserting two paragraphs and then deleting via selection',
- // inputs: [
- // insertText('123'),
- // insertParagraph(),
- // insertText('456'),
- // moveNativeSelection([0, 0, 0], 0, [1, 0, 0], 3),
- // deleteBackward(1),
- // ],
- // expectedHTML:
- // '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph"><span data-lexical-text="true"><br></span></p></div>',
- // expectedSelection: {
- // anchorPath: [0, 0, 0],
- // anchorOffset: 0,
- // focusPath: [0, 0, 0],
- // focusOffset: 0,
- // },
- // },