fix: add attributes to pre tag instead of code tag by default, fix #2440
This commit is contained in:
@@ -25,26 +25,20 @@ export function injectExtensionAttributesToParseRule(parseRule: ParseRule, exten
|
||||
return false
|
||||
}
|
||||
|
||||
const newAttributes = extensionAttributes
|
||||
.filter(item => item.attribute.rendered)
|
||||
.reduce((items, item) => {
|
||||
const value = item.attribute.parseHTML
|
||||
? item.attribute.parseHTML(node as HTMLElement)
|
||||
: fromString((node as HTMLElement).getAttribute(item.name))
|
||||
const newAttributes = extensionAttributes.reduce((items, item) => {
|
||||
const value = item.attribute.parseHTML
|
||||
? item.attribute.parseHTML(node as HTMLElement)
|
||||
: fromString((node as HTMLElement).getAttribute(item.name))
|
||||
|
||||
if (isObject(value)) {
|
||||
console.warn(`[tiptap warn]: BREAKING CHANGE: "parseHTML" for your attribute "${item.name}" returns an object but should return the value itself. If this is expected you can ignore this message. This warning will be removed in one of the next releases. Further information: https://github.com/ueberdosis/tiptap/issues/1863`)
|
||||
}
|
||||
if (value === null || value === undefined) {
|
||||
return items
|
||||
}
|
||||
|
||||
if (value === null || value === undefined) {
|
||||
return items
|
||||
}
|
||||
|
||||
return {
|
||||
...items,
|
||||
[item.name]: value,
|
||||
}
|
||||
}, {})
|
||||
return {
|
||||
...items,
|
||||
[item.name]: value,
|
||||
}
|
||||
}, {})
|
||||
|
||||
return { ...oldAttributes, ...newAttributes }
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user