mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-15 15:44:45 -04:00
fix(blockquote): remove extra color tag
Remove the extra color tag in a way that still makes us able to use the color tag in the blockquote Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
2aaea6fe3f
commit
c6c972c56c
2 changed files with 17 additions and 29 deletions
|
@ -46,11 +46,10 @@ exports[`blockquote extra tag renders the tag "[color=#abcdef]" correctly 1`] =
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<span
|
<span>
|
||||||
class="blockquote-extra"
|
[color=
|
||||||
style="color: rgb(171, 205, 239);"
|
#abcdef
|
||||||
>
|
]
|
||||||
BootstrapIconMock_Tag
|
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@ -66,11 +65,10 @@ exports[`blockquote extra tag renders the tag "[color=#dfe]" correctly 1`] = `
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<span
|
<span>
|
||||||
class="blockquote-extra"
|
[color=
|
||||||
style="color: rgb(221, 255, 238);"
|
#dfe
|
||||||
>
|
]
|
||||||
BootstrapIconMock_Tag
|
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@ -101,10 +99,10 @@ exports[`blockquote extra tag renders the tag "[color=notarealcolor]" correctly
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<span
|
<span>
|
||||||
class="blockquote-extra"
|
[color=
|
||||||
>
|
|
||||||
notarealcolor
|
notarealcolor
|
||||||
|
]
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@ -120,11 +118,10 @@ exports[`blockquote extra tag renders the tag "[color=white]" correctly 1`] = `
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<span
|
<span>
|
||||||
class="blockquote-extra"
|
[color=
|
||||||
style="color: white;"
|
white
|
||||||
>
|
]
|
||||||
BootstrapIconMock_Tag
|
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,18 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
import { UiIcon } from '../../../components/common/icons/ui-icon'
|
|
||||||
import type { NodeReplacement } from '../../../components/markdown-renderer/replace-components/component-replacer'
|
import type { NodeReplacement } from '../../../components/markdown-renderer/replace-components/component-replacer'
|
||||||
import {
|
import {
|
||||||
ComponentReplacer,
|
ComponentReplacer,
|
||||||
DO_NOT_REPLACE
|
DO_NOT_REPLACE
|
||||||
} from '../../../components/markdown-renderer/replace-components/component-replacer'
|
} from '../../../components/markdown-renderer/replace-components/component-replacer'
|
||||||
import { cssColor } from './blockquote-border-color-node-preprocessor'
|
|
||||||
import { BlockquoteExtraTagMarkdownExtension } from './blockquote-extra-tag-markdown-extension'
|
import { BlockquoteExtraTagMarkdownExtension } from './blockquote-extra-tag-markdown-extension'
|
||||||
import { Optional } from '@mrdrogdrog/optional'
|
import { Optional } from '@mrdrogdrog/optional'
|
||||||
import type { Element } from 'domhandler'
|
import type { Element } from 'domhandler'
|
||||||
import { isText } from 'domhandler'
|
import { isText } from 'domhandler'
|
||||||
import type { Text } from 'domhandler/lib/node'
|
import type { Text } from 'domhandler/lib/node'
|
||||||
import { Tag as IconTag } from 'react-bootstrap-icons'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replaces <blockquote-tag> elements with "color" as label and a valid color as content
|
* Replaces <blockquote-tag> elements with "color" as label and a valid color as content
|
||||||
|
@ -32,13 +29,7 @@ export class BlockquoteColorExtraTagReplacer extends ComponentReplacer {
|
||||||
)
|
)
|
||||||
.map((element) => element.children[0])
|
.map((element) => element.children[0])
|
||||||
.filter(isText)
|
.filter(isText)
|
||||||
.map((child) => (child as Text).data)
|
.map((child) => <span key={1}>[color={(child as Text).data}]</span>)
|
||||||
.filter((content) => cssColor.test(content))
|
|
||||||
.map((color) => (
|
|
||||||
<span className={'blockquote-extra'} key={1} style={{ color: color }}>
|
|
||||||
<UiIcon icon={IconTag} key='icon' className={'mx-1'} />
|
|
||||||
</span>
|
|
||||||
))
|
|
||||||
.orElse(DO_NOT_REPLACE)
|
.orElse(DO_NOT_REPLACE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue