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