mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-17 14:27:02 +08:00
fix(editor): can not move carte at the end of inline element (#11558)
Close [BS-2922](https://linear.app/affine-design/issue/BS-2922/【移动端-ios】文档添加linked-page后,无法删除)
This commit is contained in:
@@ -2,6 +2,13 @@ import type { InlineEditor, InlineRange } from '@blocksuite/affine/std/inline';
|
||||
import type { DeltaInsert } from '@blocksuite/affine/store';
|
||||
import { expect, type Page, test } from '@playwright/test';
|
||||
|
||||
import { pressArrowLeft, pressEnter } from '../utils/actions/keyboard.js';
|
||||
import {
|
||||
enterPlaygroundRoom,
|
||||
focusRichText,
|
||||
initEmptyParagraphState,
|
||||
} from '../utils/actions/misc.js';
|
||||
import { assertRichTextInlineDeltas } from '../utils/asserts.js';
|
||||
import { ZERO_WIDTH_SPACE } from '../utils/inline-editor.js';
|
||||
// FIXME(mirone): copy paste from framework/inline/__tests__/utils.ts
|
||||
const defaultPlaygroundURL = new URL(
|
||||
@@ -1124,3 +1131,41 @@ test('triple click to select line', async ({ page }) => {
|
||||
await press(page, 'Backspace');
|
||||
expect(await editorA.innerText()).toBe('abc\n' + ZERO_WIDTH_SPACE + '\nabc');
|
||||
});
|
||||
|
||||
test('caret should move correctly when inline elements are exist', async ({
|
||||
page,
|
||||
}) => {
|
||||
await enterPlaygroundRoom(page);
|
||||
await initEmptyParagraphState(page);
|
||||
await focusRichText(page, 0);
|
||||
|
||||
// hello 'link doc' world
|
||||
await type(page, 'hello ');
|
||||
await press(page, '@');
|
||||
await type(page, 'link doc');
|
||||
await pressEnter(page);
|
||||
await type(page, ' world');
|
||||
|
||||
await pressArrowLeft(page, ' world'.length);
|
||||
await pressArrowLeft(page); // on 'linked doc'
|
||||
await pressArrowLeft(page); // on the left side of 'linked doc'
|
||||
await type(page, 'test');
|
||||
|
||||
await assertRichTextInlineDeltas(page, [
|
||||
{
|
||||
insert: 'hello test',
|
||||
},
|
||||
{
|
||||
attributes: {
|
||||
reference: {
|
||||
pageId: '3',
|
||||
type: 'LinkedPage',
|
||||
},
|
||||
},
|
||||
insert: ' ',
|
||||
},
|
||||
{
|
||||
insert: ' world',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user