fix(richtext-lexical): prevent disallowed headings to be pasted (#13765)

Fixes #13705

With this PR, if the editor detects a disallowed heading in
`HeadingFeature`, it automatically converts it to the lowest allowed
heading.

I've also verified that disallowed headings aren't introduced when
pasting from the clipboard if the HeadingFeature isn't registered at
all. The reason this works is because the LexicalEditor doesn't have the
HeadingNode in that case.
This commit is contained in:
German Jablonski
2025-09-19 19:02:18 +01:00
committed by GitHub
parent 77cac30046
commit 207caa570c
13 changed files with 171 additions and 70 deletions

View File

@@ -88,6 +88,18 @@ export class LexicalHelpers {
return {}
}
async paste(type: 'html' | 'markdown', text: string) {
await this.page.evaluate(
async ([text, type]) => {
const blob = new Blob([text!], { type: type === 'html' ? 'text/html' : 'text/markdown' })
const clipboardItem = new ClipboardItem({ 'text/html': blob })
await navigator.clipboard.write([clipboardItem])
},
[text, type],
)
await this.page.keyboard.press(`ControlOrMeta+v`)
}
async save(container: 'document' | 'drawer') {
if (container === 'drawer') {
await this.drawer.getByText('Save').click()