mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-28 14:04:43 -04:00
Fixed bug that two p-tags were encapsulated inside each other (#278)
* Fixed bug that two p-tags were encapsulated inside each other This bug was introduced because the wider-possible-replacer replaced each element that was subject to be enlarged with a brand new p-surrounding. That surrounding got the key of the old (now inner) element and therefore casts an duplicate key exception. This fix solves that problem by setting the 'wider-possible' class attribute directly on the selected tag instead of creating a surrounding. * Removed unnecessary console log * Optimized attribute assignment to not fail on elements without attribs * Added comment describing the node.attribs assignment
This commit is contained in:
parent
937a2e9eb9
commit
17cc691403
2 changed files with 5 additions and 4 deletions
|
@ -52,7 +52,7 @@ export interface MarkdownPreviewProps {
|
||||||
wide?: boolean
|
wide?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const createMarkdownIt = ():MarkdownIt => {
|
const createMarkdownIt = (): MarkdownIt => {
|
||||||
const md = new MarkdownIt('default', {
|
const md = new MarkdownIt('default', {
|
||||||
html: true,
|
html: true,
|
||||||
breaks: true,
|
breaks: true,
|
||||||
|
|
|
@ -17,8 +17,9 @@ export class PossibleWiderReplacer implements ComponentReplacer {
|
||||||
if (!(childIsImage || childIsYoutube || childIsVimeo || childIsPDF)) {
|
if (!(childIsImage || childIsYoutube || childIsVimeo || childIsPDF)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return (<p className='wider-possible'>
|
|
||||||
{subNodeConverter(node, index)}
|
// This appends the 'wider-possible' class to the node for a wider view in view-mode
|
||||||
</p>)
|
node.attribs = Object.assign(node.attribs || {}, { class: `wider-possible ${node.attribs?.class || ''}` })
|
||||||
|
return subNodeConverter(node, index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue