mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 11:16:31 -05: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
|
||||
}
|
||||
|
||||
const createMarkdownIt = ():MarkdownIt => {
|
||||
const createMarkdownIt = (): MarkdownIt => {
|
||||
const md = new MarkdownIt('default', {
|
||||
html: true,
|
||||
breaks: true,
|
||||
|
|
|
@ -17,8 +17,9 @@ export class PossibleWiderReplacer implements ComponentReplacer {
|
|||
if (!(childIsImage || childIsYoutube || childIsVimeo || childIsPDF)) {
|
||||
return
|
||||
}
|
||||
return (<p className='wider-possible'>
|
||||
{subNodeConverter(node, index)}
|
||||
</p>)
|
||||
|
||||
// This appends the 'wider-possible' class to the node for a wider view in view-mode
|
||||
node.attribs = Object.assign(node.attribs || {}, { class: `wider-possible ${node.attribs?.class || ''}` })
|
||||
return subNodeConverter(node, index)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue