@blocksuite/virgo
Advanced tools
Comparing version 0.4.0-20230217222321-04d1424 to 0.4.0-20230218141339-f0c5a7b
@@ -515,2 +515,27 @@ import { expect, test } from '@playwright/test'; | ||
}); | ||
test('select from the start of line using shift+arrow', async ({ page }) => { | ||
await enterVirgoPlayground(page); | ||
await focusVirgoRichText(page); | ||
const editorA = page.locator('[data-virgo-root="true"]').nth(0); | ||
const editorB = page.locator('[data-virgo-root="true"]').nth(1); | ||
expect(await editorA.innerText()).toBe(ZERO_WIDTH_SPACE); | ||
expect(await editorB.innerText()).toBe(ZERO_WIDTH_SPACE); | ||
await type(page, 'abc'); | ||
await page.keyboard.press('Enter', { delay: 50 }); | ||
await type(page, 'def'); | ||
await page.keyboard.press('Enter', { delay: 50 }); | ||
await type(page, 'ghi'); | ||
expect(await editorA.innerText()).toBe('abc\ndef\nghi'); | ||
expect(await editorB.innerText()).toBe('abc\ndef\nghi'); | ||
await page.keyboard.press('ArrowLeft'); | ||
await page.keyboard.press('ArrowLeft'); | ||
await page.keyboard.press('ArrowLeft'); | ||
await page.keyboard.down('Shift'); | ||
await page.keyboard.press('ArrowUp'); | ||
await page.keyboard.press('ArrowUp'); | ||
await page.keyboard.press('ArrowRight'); | ||
await page.keyboard.press('Backspace'); | ||
expect(await editorA.innerText()).toBe('aghi'); | ||
expect(await editorB.innerText()).toBe('aghi'); | ||
}); | ||
//# sourceMappingURL=virgo.spec.js.map |
@@ -355,2 +355,13 @@ import { assertExists, Signal } from '@blocksuite/global/utils'; | ||
} | ||
else if (anchorNode instanceof HTMLElement && | ||
anchorNode.parentElement instanceof VirgoLine) { | ||
const firstTextElement = anchorNode.querySelector('v-text'); | ||
if (firstTextElement) { | ||
const textNode = getTextNodeFromElement(firstTextElement); | ||
if (textNode) { | ||
anchorText = textNode; | ||
anchorTextOffset = 0; | ||
} | ||
} | ||
} | ||
if (focusNode instanceof Text && isVText(focusNode)) { | ||
@@ -368,2 +379,13 @@ focusText = focusNode; | ||
} | ||
else if (focusNode instanceof HTMLElement && | ||
focusNode.parentElement instanceof VirgoLine) { | ||
const firstTextElement = focusNode.querySelector('v-text'); | ||
if (firstTextElement) { | ||
const textNode = getTextNodeFromElement(firstTextElement); | ||
if (textNode) { | ||
anchorText = textNode; | ||
anchorTextOffset = 0; | ||
} | ||
} | ||
} | ||
// case 1 | ||
@@ -370,0 +392,0 @@ if (anchorText && focusText) { |
{ | ||
"name": "@blocksuite/virgo", | ||
"version": "0.4.0-20230217222321-04d1424", | ||
"version": "0.4.0-20230218141339-f0c5a7b", | ||
"description": "A micro editor.", | ||
@@ -26,3 +26,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@blocksuite/global": "0.4.0-20230217222321-04d1424", | ||
"@blocksuite/global": "0.4.0-20230218141339-f0c5a7b", | ||
"zod": "^3.20.6" | ||
@@ -29,0 +29,0 @@ }, |
@@ -618,1 +618,34 @@ import { expect, test } from '@playwright/test'; | ||
}); | ||
test('select from the start of line using shift+arrow', async ({ page }) => { | ||
await enterVirgoPlayground(page); | ||
await focusVirgoRichText(page); | ||
const editorA = page.locator('[data-virgo-root="true"]').nth(0); | ||
const editorB = page.locator('[data-virgo-root="true"]').nth(1); | ||
expect(await editorA.innerText()).toBe(ZERO_WIDTH_SPACE); | ||
expect(await editorB.innerText()).toBe(ZERO_WIDTH_SPACE); | ||
await type(page, 'abc'); | ||
await page.keyboard.press('Enter', { delay: 50 }); | ||
await type(page, 'def'); | ||
await page.keyboard.press('Enter', { delay: 50 }); | ||
await type(page, 'ghi'); | ||
expect(await editorA.innerText()).toBe('abc\ndef\nghi'); | ||
expect(await editorB.innerText()).toBe('abc\ndef\nghi'); | ||
await page.keyboard.press('ArrowLeft'); | ||
await page.keyboard.press('ArrowLeft'); | ||
await page.keyboard.press('ArrowLeft'); | ||
await page.keyboard.down('Shift'); | ||
await page.keyboard.press('ArrowUp'); | ||
await page.keyboard.press('ArrowUp'); | ||
await page.keyboard.press('ArrowRight'); | ||
await page.keyboard.press('Backspace'); | ||
expect(await editorA.innerText()).toBe('aghi'); | ||
expect(await editorB.innerText()).toBe('aghi'); | ||
}); |
@@ -420,2 +420,14 @@ import { assertExists, Signal } from '@blocksuite/global/utils'; | ||
} | ||
} else if ( | ||
anchorNode instanceof HTMLElement && | ||
anchorNode.parentElement instanceof VirgoLine | ||
) { | ||
const firstTextElement = anchorNode.querySelector('v-text'); | ||
if (firstTextElement) { | ||
const textNode = getTextNodeFromElement(firstTextElement); | ||
if (textNode) { | ||
anchorText = textNode; | ||
anchorTextOffset = 0; | ||
} | ||
} | ||
} | ||
@@ -434,4 +446,15 @@ if (focusNode instanceof Text && isVText(focusNode)) { | ||
} | ||
} else if ( | ||
focusNode instanceof HTMLElement && | ||
focusNode.parentElement instanceof VirgoLine | ||
) { | ||
const firstTextElement = focusNode.querySelector('v-text'); | ||
if (firstTextElement) { | ||
const textNode = getTextNodeFromElement(firstTextElement); | ||
if (textNode) { | ||
anchorText = textNode; | ||
anchorTextOffset = 0; | ||
} | ||
} | ||
} | ||
// case 1 | ||
@@ -438,0 +461,0 @@ if (anchorText && focusText) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
244900
3507
+ Added@blocksuite/global@0.4.0-20230218141339-f0c5a7b(transitive)
- Removed@blocksuite/global@0.4.0-20230217222321-04d1424(transitive)