mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-11 03:33:12 +08:00
refactoring
This commit is contained in:
parent
f61c9883e3
commit
5010abb01b
@ -36,14 +36,8 @@ export default new Node<CodeBlockOptions>()
|
||||
{
|
||||
tag: 'pre',
|
||||
preserveWhitespace: 'full',
|
||||
getAttrs(dom) {
|
||||
const code = (dom as HTMLElement).firstChild
|
||||
|
||||
if (!code) {
|
||||
return null
|
||||
}
|
||||
|
||||
const classAttribute = ((code as HTMLElement).getAttribute('class') as string)
|
||||
getAttrs(node) {
|
||||
const classAttribute = (node as Element).firstElementChild?.getAttribute('class')
|
||||
|
||||
if (!classAttribute) {
|
||||
return null
|
||||
@ -55,7 +49,9 @@ export default new Node<CodeBlockOptions>()
|
||||
},
|
||||
},
|
||||
],
|
||||
toDOM: node => ['pre', ['code', { class: node.attrs.language && options.languageClassPrefix + node.attrs.language }, 0]],
|
||||
toDOM: node => ['pre', ['code', {
|
||||
class: node.attrs.language && options.languageClassPrefix + node.attrs.language,
|
||||
}, 0]],
|
||||
}))
|
||||
.commands(({ name }) => ({
|
||||
codeBlock: attrs => ({ commands }) => {
|
||||
|
Loading…
Reference in New Issue
Block a user