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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user