forked from toeverything/blocksuite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(page): inline format should be extended when range is not collaps…
…ed (toeverything#4964)
- Loading branch information
Showing
5 changed files
with
213 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { expect, type Page } from '@playwright/test'; | ||
|
||
import { assertAlmostEqual } from './asserts.js'; | ||
|
||
export function getFormatBar(page: Page) { | ||
const formatBar = page.locator('.affine-format-bar-widget'); | ||
const boldBtn = formatBar.getByTestId('bold'); | ||
const italicBtn = formatBar.getByTestId('italic'); | ||
const underlineBtn = formatBar.getByTestId('underline'); | ||
const strikeBtn = formatBar.getByTestId('strike'); | ||
const codeBtn = formatBar.getByTestId('code'); | ||
const linkBtn = formatBar.getByTestId('link'); | ||
const copyBtn = formatBar.getByTestId('copy'); | ||
// highlight | ||
const backgroundBtn = formatBar.locator('.background-highlight-icon'); | ||
const pinkBtn = formatBar.getByTestId('var(--affine-text-highlight-pink)'); | ||
const defaultColorBtn = formatBar.getByTestId('unset'); | ||
const highlight = { | ||
backgroundBtn, | ||
pinkBtn, | ||
defaultColorBtn, | ||
}; | ||
|
||
const paragraphBtn = formatBar.locator(`.paragraph-button`); | ||
const openParagraphMenu = async () => { | ||
await expect(formatBar).toBeVisible(); | ||
await paragraphBtn.hover(); | ||
}; | ||
|
||
const textBtn = formatBar.getByTestId('affine:paragraph/text'); | ||
const h1Btn = formatBar.getByTestId('affine:paragraph/h1'); | ||
const bulletedBtn = formatBar.getByTestId('affine:list/bulleted'); | ||
const codeBlockBtn = formatBar.getByTestId('affine:code/'); | ||
|
||
const assertBoundingBox = async (x: number, y: number) => { | ||
const boundingBox = await formatBar.boundingBox(); | ||
if (!boundingBox) { | ||
throw new Error("formatBar doesn't exist"); | ||
} | ||
assertAlmostEqual(boundingBox.x, x, 6); | ||
assertAlmostEqual(boundingBox.y, y, 6); | ||
}; | ||
|
||
return { | ||
formatBar, | ||
boldBtn, | ||
italicBtn, | ||
underlineBtn, | ||
strikeBtn, | ||
codeBtn, | ||
linkBtn, | ||
copyBtn, | ||
highlight, | ||
|
||
openParagraphMenu, | ||
textBtn, | ||
h1Btn, | ||
bulletedBtn, | ||
codeBlockBtn, | ||
|
||
assertBoundingBox, | ||
}; | ||
} |
c3aa109
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Size Report
Bundles
Packages
c3aa109
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Size Report
Bundles
Packages