fix: restore blocknote slash menu styling

This commit is contained in:
lucaronin
2026-04-14 11:14:49 +02:00
parent 0c9bfb14c3
commit 60da17e13b
2 changed files with 58 additions and 1 deletions

View File

@@ -26,10 +26,17 @@ type TestTableBlock = {
}
function SharedContextBlockNoteView(props: React.ComponentProps<typeof BlockNoteViewRaw>) {
const { className, theme, ...rest } = props
const mantineContext = useContext(MantineContext)
const colorScheme = theme === 'dark' ? 'dark' : 'light'
const view = (
<ComponentsContext.Provider value={components}>
<BlockNoteViewRaw {...props} />
<BlockNoteViewRaw
{...rest}
className={['bn-mantine', className].filter(Boolean).join(' ')}
data-mantine-color-scheme={colorScheme}
theme={theme}
/>
</ComponentsContext.Provider>
)
@@ -37,6 +44,7 @@ function SharedContextBlockNoteView(props: React.ComponentProps<typeof BlockNote
return (
<MantineProvider
// BlockNote scopes Mantine defaults under `.bn-mantine` instead of `:root`.
withCssVariables={false}
getRootElement={() => undefined}
>

View File

@@ -0,0 +1,49 @@
import { test, expect, type Page } from '@playwright/test'
import { createFixtureVaultCopy, openFixtureVault, removeFixtureVaultCopy } from '../helpers/fixtureVault'
let tempVaultDir: string
async function openAlphaProject(page: Page) {
await openFixtureVault(page, tempVaultDir)
await page.getByText('Alpha Project', { exact: true }).first().click()
await expect(page.locator('.bn-editor')).toBeVisible({ timeout: 10_000 })
}
test.describe('BlockNote slash menu styling', () => {
test.beforeEach(() => {
tempVaultDir = createFixtureVaultCopy()
})
test.afterEach(() => {
removeFixtureVaultCopy(tempVaultDir)
})
test('slash menu keeps Mantine styling tokens in the editor', async ({ page }) => {
await openAlphaProject(page)
await page.locator('.bn-editor').click()
await page.keyboard.type('/')
const menu = page.locator('.bn-suggestion-menu')
await expect(menu).toBeVisible({ timeout: 5_000 })
const menuStyles = await menu.evaluate((node) => {
const style = getComputedStyle(node)
return {
backgroundColor: style.backgroundColor,
borderRadius: style.borderRadius,
boxShadow: style.boxShadow,
spacing: style.getPropertyValue('--mantine-spacing-sm').trim(),
radius: style.getPropertyValue('--mantine-radius-default').trim(),
shadow: style.getPropertyValue('--mantine-shadow-md').trim(),
}
})
expect(menuStyles.backgroundColor).not.toBe('rgba(0, 0, 0, 0)')
expect(menuStyles.borderRadius).not.toBe('0px')
expect(menuStyles.boxShadow).not.toBe('none')
expect(menuStyles.spacing).not.toBe('')
expect(menuStyles.radius).not.toBe('')
expect(menuStyles.shadow).not.toBe('')
})
})