feat: set the correct mode when loading the page (#1069)
Co-authored-by: Himself65 <himself65@outlook.com>
This commit is contained in:
1
.github/CLA.md
vendored
1
.github/CLA.md
vendored
@@ -47,3 +47,4 @@ Example:
|
|||||||
|
|
||||||
- Dark Sky, @darkskygit, 2022/07/22
|
- Dark Sky, @darkskygit, 2022/07/22
|
||||||
- Lin Onetwo, @linonetwo, 2022/02/14
|
- Lin Onetwo, @linonetwo, 2022/02/14
|
||||||
|
- zqran, @zqran, 2023/02/17
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ export const Editor = ({
|
|||||||
|
|
||||||
const editor = new EditorContainer();
|
const editor = new EditorContainer();
|
||||||
editor.page = page;
|
editor.page = page;
|
||||||
|
editor.mode = page.meta.mode as typeof editor.mode;
|
||||||
|
|
||||||
editorContainer.current?.appendChild(editor);
|
editorContainer.current?.appendChild(editor);
|
||||||
if (page.isEmpty) {
|
if (page.isEmpty) {
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ export const usePageHelper = (): EditorHandlers => {
|
|||||||
addedPageId => {
|
addedPageId => {
|
||||||
currentWorkspace.blocksuiteWorkspace?.setPageMeta(addedPageId, {
|
currentWorkspace.blocksuiteWorkspace?.setPageMeta(addedPageId, {
|
||||||
title,
|
title,
|
||||||
|
mode: 'page',
|
||||||
});
|
});
|
||||||
resolve(addedPageId);
|
resolve(addedPageId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,18 +10,24 @@ const openQuickSearchByShortcut = async (page: Page) =>
|
|||||||
await withCtrlOrMeta(page, () => page.keyboard.press('k', { delay: 50 }));
|
await withCtrlOrMeta(page, () => page.keyboard.press('k', { delay: 50 }));
|
||||||
|
|
||||||
async function assertTitle(page: Page, text: string) {
|
async function assertTitle(page: Page, text: string) {
|
||||||
const locator = page.locator('.affine-default-page-block-title').nth(0);
|
const edgeless = page.locator('affine-edgeless-page');
|
||||||
const actual = await locator.inputValue();
|
if (!edgeless) {
|
||||||
expect(actual).toBe(text);
|
const locator = page.locator('.affine-default-page-block-title').nth(0);
|
||||||
|
const actual = await locator.inputValue();
|
||||||
|
expect(actual).toBe(text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async function assertResultList(page: Page, texts: string[]) {
|
async function assertResultList(page: Page, texts: string[]) {
|
||||||
const actual = await page.locator('[cmdk-item]').allInnerTexts();
|
const actual = await page.locator('[cmdk-item]').allInnerTexts();
|
||||||
expect(actual).toEqual(texts);
|
expect(actual).toEqual(texts);
|
||||||
}
|
}
|
||||||
async function titleIsFocused(page: Page) {
|
async function titleIsFocused(page: Page) {
|
||||||
const title = page.locator('.affine-default-page-block-title');
|
const edgeless = page.locator('affine-edgeless-page');
|
||||||
await expect(title).toBeVisible();
|
if (!edgeless) {
|
||||||
await expect(title).toBeFocused();
|
const title = page.locator('.affine-default-page-block-title');
|
||||||
|
await expect(title).toBeVisible();
|
||||||
|
await expect(title).toBeFocused();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
test.describe('Open quick search', () => {
|
test.describe('Open quick search', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user