chore: fix blockquote renderer

This commit is contained in:
Steven 2024-01-15 20:41:37 +08:00
parent 5a723f00fa
commit fdbf2d8af2
4 changed files with 17 additions and 3 deletions

View file

@ -14,7 +14,7 @@ func NewBlockquoteParser() *BlockquoteParser {
}
func (*BlockquoteParser) Match(tokens []*tokenizer.Token) (int, bool) {
if len(tokens) < 4 {
if len(tokens) < 3 {
return 0, false
}
if tokens[0].Type != tokenizer.GreaterThan || tokens[1].Type != tokenizer.Space {

View file

@ -29,6 +29,20 @@ func TestBlockquoteParser(t *testing.T) {
},
},
},
{
text: "> 你好",
blockquote: &ast.Blockquote{
Children: []ast.Node{
&ast.Paragraph{
Children: []ast.Node{
&ast.Text{
Content: "你好",
},
},
},
},
},
},
{
text: "> Hello\nworld",
blockquote: &ast.Blockquote{

View file

@ -8,7 +8,7 @@ interface Props extends BaseProps {
const Blockquote: React.FC<Props> = ({ children }: Props) => {
return (
<blockquote>
<blockquote className="p-2 border-s-4 border-gray-300 bg-gray-50 dark:border-gray-500 dark:bg-zinc-700">
{children.map((child, index) => (
<Renderer key={`${child.type}-${index}`} index={String(index)} node={child} />
))}

View file

@ -368,6 +368,7 @@ const MemoEditor = (props: Props) => {
<Editor ref={editorRef} {...editorConfig} />
<div className="relative w-full flex flex-row justify-between items-center pt-2" onFocus={(e) => e.stopPropagation()}>
<div className="flex flex-row justify-start items-center opacity-80">
<MarkdownMenu editorRef={editorRef} />
<TagSelector editorRef={editorRef} />
<IconButton size="sm" onClick={handleUploadFileBtnClick}>
<Icon.Image className="w-5 h-5 mx-auto" />
@ -375,7 +376,6 @@ const MemoEditor = (props: Props) => {
<IconButton size="sm" onClick={handleAddMemoRelationBtnClick}>
<Icon.Link className="w-5 h-5 mx-auto" />
</IconButton>
<MarkdownMenu editorRef={editorRef} />
</div>
</div>
<ResourceListView resourceList={state.resourceList} setResourceList={handleSetResourceList} />