fix: emoji remark plugin sets children type to html instead of parent
This fixes the issue where if a URL was added to the comment, the remark plugin would break. Instead of changing the parent node to be html, it now sets any 'text' type children to be 'html' instead.
This commit is contained in:
parent
f215418be1
commit
77087158a9
@ -653,7 +653,7 @@ export const ActivityItemComment = styled.div<{ editable: boolean }>`
|
|||||||
${props => props.editable && 'width: 100%;'}
|
${props => props.editable && 'width: 100%;'}
|
||||||
|
|
||||||
& span {
|
& span {
|
||||||
display: flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
& ul {
|
& ul {
|
||||||
|
@ -44,9 +44,16 @@ function plugin(options) {
|
|||||||
visit(tree, 'paragraph', function(node) {
|
visit(tree, 'paragraph', function(node) {
|
||||||
console.log(tree);
|
console.log(tree);
|
||||||
// node.value = node.value.replace(RE_EMOJI, getEmoji);
|
// node.value = node.value.replace(RE_EMOJI, getEmoji);
|
||||||
node.type = 'html';
|
// jnode.type = 'html';
|
||||||
node.tagName = 'div';
|
// jnode.tagName = 'div';
|
||||||
node.value = node.children[0].value.replace(RE_EMOJI, getEmoji);
|
// jnode.value = '';
|
||||||
|
for (let nodeIdx = 0; nodeIdx < node.children.length; nodeIdx++) {
|
||||||
|
if (node.children[nodeIdx].type === 'text') {
|
||||||
|
node.children[nodeIdx].type = 'html';
|
||||||
|
node.children[nodeIdx].tagName = 'div';
|
||||||
|
node.children[nodeIdx].value = node.children[nodeIdx].value.replace(RE_EMOJI, getEmoji);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (emoticonEnable) {
|
if (emoticonEnable) {
|
||||||
// node.value = node.value.replace(RE_SHORT, getEmojiByShortCode);
|
// node.value = node.value.replace(RE_SHORT, getEmojiByShortCode);
|
||||||
|
Loading…
Reference in New Issue
Block a user