diff --git a/web/plugins/com.msgbyte.bbcode/src/__tests__/__snapshots__/render.spec.tsx.snap b/web/plugins/com.msgbyte.bbcode/src/__tests__/__snapshots__/render.spec.tsx.snap
new file mode 100644
index 00000000..01883699
--- /dev/null
+++ b/web/plugins/com.msgbyte.bbcode/src/__tests__/__snapshots__/render.spec.tsx.snap
@@ -0,0 +1,18 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`render mention with space name 1`] = `
+
+
+ @
+ Notify Bot
+
+
+ 123123
+
+
+`;
diff --git a/web/plugins/com.msgbyte.bbcode/src/__tests__/render.spec.tsx b/web/plugins/com.msgbyte.bbcode/src/__tests__/render.spec.tsx
new file mode 100644
index 00000000..fffe0ae6
--- /dev/null
+++ b/web/plugins/com.msgbyte.bbcode/src/__tests__/render.spec.tsx
@@ -0,0 +1,11 @@
+import { render } from '@testing-library/react';
+import React from 'react';
+import BBCode from '../render';
+
+describe('render ', () => {
+ test('mention with space name', () => {
+ const raw = '[at=6251986eab331ca2efbba9c6]Notify Bot[/at] 123123';
+ const wrapper = render();
+ expect(wrapper.container).toMatchSnapshot();
+ });
+});
diff --git a/web/plugins/com.msgbyte.bbcode/src/bbcode/__tests__/parser.spec.ts b/web/plugins/com.msgbyte.bbcode/src/bbcode/__tests__/parser.spec.ts
index 789f4a43..d1fd5a8d 100644
--- a/web/plugins/com.msgbyte.bbcode/src/bbcode/__tests__/parser.spec.ts
+++ b/web/plugins/com.msgbyte.bbcode/src/bbcode/__tests__/parser.spec.ts
@@ -56,4 +56,20 @@ describe('bbcode parser', () => {
]);
});
});
+
+ test('with space', () => {
+ const ast = bbcodeParser.parse(
+ '[at=6251986eab331ca2efbba9c6]Notify Bot[/at] 123123'
+ );
+
+ expect(ast).toMatchObject([
+ {
+ tag: 'at',
+ attrs: { at: '6251986eab331ca2efbba9c6' },
+ content: ['Notify', ' ', 'Bot'],
+ },
+ ' ',
+ '123123',
+ ]);
+ });
});
diff --git a/web/plugins/com.msgbyte.bbcode/src/bbcode/parser.tsx b/web/plugins/com.msgbyte.bbcode/src/bbcode/parser.tsx
index cea59fa5..f22ed58b 100644
--- a/web/plugins/com.msgbyte.bbcode/src/bbcode/parser.tsx
+++ b/web/plugins/com.msgbyte.bbcode/src/bbcode/parser.tsx
@@ -87,7 +87,7 @@ class BBCodeParser {
})
// NOTICE: 这里排序看起来好像有问题,但是attrs的顺序是有序的,所以没有问题
.join('');
- return `[${tag}${attrsStr}]${content}[/${tag}]`;
+ return `[${tag}${attrsStr}]${content.join('')}[/${tag}]`;
})
.join('');
}