generated from arvinxx/npm-template
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:Highlight & Markdown 切换为 ProEditor (#12)
* ✨ feat: change Highlight & Markdown into ProEditor * ✨ feat: delete lobeui * 💚 fix: ci fixed --------- Co-authored-by: ONLY-yours <[email protected]>
- Loading branch information
1 parent
e733305
commit f742db3
Showing
27 changed files
with
149 additions
and
3,055 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,48 @@ | ||
import { ActionIconGroup, ChatItem, ChatItemProps } from '@ant-design/pro-chat'; | ||
import { StoryBook, useControls, useCreateStore } from '@lobehub/ui'; | ||
import { useState } from 'react'; | ||
|
||
import { avatar, dropdownMenu, items } from './data'; | ||
|
||
export default () => { | ||
const [edit, setEdit] = useState(false); | ||
const store = useCreateStore(); | ||
const control: ChatItemProps | any = useControls( | ||
{ | ||
loading: false, | ||
message: { | ||
rows: true, | ||
value: | ||
"要使用 dayjs 的 fromNow 函数,需要先安装 dayjs 库并在代码中引入它。然后,可以使用以下语法来获取当前时间与给定时间之间的相对时间:\n\n```javascript\ndayjs().fromNow();\ndayjs('2021-05-01').fromNow();\n```", | ||
}, | ||
placement: { | ||
options: ['left', 'right'], | ||
value: 'left', | ||
}, | ||
primary: false, | ||
showTitle: false, | ||
time: 1_686_538_950_084, | ||
type: { | ||
options: ['block', 'pure'], | ||
value: 'block', | ||
}, | ||
const control: ChatItemProps | any = { | ||
loading: false, | ||
message: { | ||
rows: true, | ||
value: | ||
"要使用 dayjs 的 fromNow 函数,需要先安装 dayjs 库并在代码中引入它。然后,可以使用以下语法来获取当前时间与给定时间之间的相对时间:\n\n```javascript\ndayjs().fromNow();\ndayjs('2021-05-01').fromNow();\n```", | ||
}, | ||
{ store }, | ||
); | ||
placement: { | ||
options: ['left', 'right'], | ||
value: 'left', | ||
}, | ||
primary: false, | ||
showTitle: false, | ||
time: 1_686_538_950_084, | ||
type: { | ||
options: ['block', 'pure'], | ||
value: 'block', | ||
}, | ||
}; | ||
|
||
return ( | ||
<StoryBook levaStore={store}> | ||
<ChatItem | ||
{...control} | ||
actions={ | ||
<ActionIconGroup | ||
dropdownMenu={dropdownMenu} | ||
items={items} | ||
onActionClick={(action) => { | ||
if (action.key === 'edit') { | ||
setEdit(true); | ||
} | ||
}} | ||
type="ghost" | ||
/> | ||
} | ||
avatar={avatar} | ||
editing={edit} | ||
onEditingChange={setEdit} | ||
/> | ||
</StoryBook> | ||
<ChatItem | ||
{...control} | ||
actions={ | ||
<ActionIconGroup | ||
dropdownMenu={dropdownMenu} | ||
items={items} | ||
onActionClick={(action) => { | ||
if (action.key === 'edit') { | ||
setEdit(true); | ||
} | ||
}} | ||
type="ghost" | ||
/> | ||
} | ||
avatar={avatar} | ||
editing={edit} | ||
onEditingChange={setEdit} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,106 @@ | ||
import { EditableMessage } from '@ant-design/pro-chat'; | ||
import { StoryBook, useControls, useCreateStore } from '@lobehub/ui'; | ||
import { button } from 'leva'; | ||
import { useState } from 'react'; | ||
|
||
import { content } from '../../Markdown/demos/data'; | ||
export const content = `# This is an H1 | ||
## This is an H2 | ||
### This is an H3 | ||
#### This is an H4 | ||
##### This is an H5 | ||
The point of reference-style links is not that they’re easier to write. The point is that with reference-style links, your document source is vastly more readable. Compare the above examples: using reference-style links, the paragraph itself is only 81 characters long; with inline-style links, it’s 176 characters; and as raw \`HTML\`, it’s 234 characters. In the raw \`HTML\`, there’s more markup than there is text. | ||
--- | ||
> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, | ||
> consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. | ||
> Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. | ||
> | ||
> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse | ||
> id sem consectetuer libero luctus adipiscing. | ||
--- | ||
an example | *an example* | **an example** | ||
--- | ||
1. Bird | ||
1. McHale | ||
1. Parish | ||
1. Bird | ||
1. McHale | ||
1. Parish | ||
--- | ||
- Red | ||
- Green | ||
- Blue | ||
- Red | ||
- Green | ||
- Blue | ||
--- | ||
This is [an example](http://example.com/ "Title") inline link. | ||
<http://example.com/> | ||
| title | title | title | | ||
| --- | --- | --- | | ||
| content | content | content | | ||
\`\`\`bash | ||
$ pnpm install | ||
\`\`\` | ||
\`\`\`javascript | ||
import { renderHook } from '@testing-library/react-hooks'; | ||
import { act } from 'react-dom/test-utils'; | ||
import { useDropNodeOnCanvas } from './useDropNodeOnCanvas'; | ||
\`\`\` | ||
--- | ||
以下是一段Markdown格式的LaTeX数学公式: | ||
我是一个行内公式:$E=mc^2$ | ||
我是一个独立公式: | ||
$$ | ||
\\sum_{i=1}^{n} x_i = x_1 + x_2 + \\ldots + x_n | ||
$$ | ||
我是一个带有分式的公式: | ||
$$ | ||
\\frac{{n!}}{{k!(n-k)!}} = \\binom{n}{k} | ||
$$ | ||
我是一个带有上下标的公式: | ||
$$ | ||
x^{2} + y^{2} = r^{2} | ||
$$ | ||
我是一个带有积分符号的公式: | ||
$$ | ||
\\int_{a}^{b} f(x) \\, dx | ||
$$ | ||
`; | ||
|
||
export default () => { | ||
const [openModal, setOpenModal] = useState(false); | ||
const [editing, setEdit] = useState(false); | ||
const store = useCreateStore(); | ||
|
||
useControls( | ||
{ | ||
editing: button(() => { | ||
setEdit(true); | ||
}), | ||
openModal: button(() => { | ||
setOpenModal(true); | ||
}), | ||
}, | ||
{ store }, | ||
); | ||
|
||
return ( | ||
<StoryBook levaStore={store}> | ||
<EditableMessage | ||
editing={editing} | ||
onEditingChange={setEdit} | ||
onOpenChange={setOpenModal} | ||
openModal={openModal} | ||
value={content} | ||
/> | ||
</StoryBook> | ||
<EditableMessage | ||
editing={editing} | ||
onEditingChange={setEdit} | ||
onOpenChange={setOpenModal} | ||
openModal={openModal} | ||
value={content} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
f742db3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ProEditor在不断地流式输出Markdown代码块时,界面所有的代码块都会出现闪动,输出大段的代码块时会导致直接无法显示代码内容,感觉像是频繁渲染代码高亮导致的,有解决方法吗
f742db3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ONLY-yours 排查下?
f742db3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是的,主要就是代码块的问题,疯狂在触发 Siki 的重新计算,得仔细看看了
f742db3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感觉是 memo 挂掉了 - -
f742db3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修了一版本,感觉应该可以了,我在 Editor 模拟了下应该ok了 ant-design/pro-editor#122 @arvinxx
f742db3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
确认已修复