tiptap: use id instead of name

This commit is contained in:
fantasticit 2022-06-05 00:19:30 +08:00
parent d073531325
commit e928981c08
3 changed files with 7 additions and 7 deletions

View File

@ -128,13 +128,12 @@ export const COMMANDS: ICommand[] = [
{
icon: <IconMath />,
label: '数学公式',
action: (editor, user) => editor.chain().focus().setKatex({ defaultShowPicker: true, createUser: user.name }).run(),
action: (editor, user) => editor.chain().focus().setKatex({ defaultShowPicker: true, createUser: user.id }).run(),
},
{
icon: <IconStatus />,
label: '状态',
action: (editor, user) =>
editor.chain().focus().setStatus({ defaultShowPicker: true, createUser: user.name }).run(),
action: (editor, user) => editor.chain().focus().setStatus({ defaultShowPicker: true, createUser: user.id }).run(),
},
{
icon: <IconCallout />,

View File

@ -41,10 +41,11 @@ export const KatexBubbleMenu: React.FC<{ editor: Editor }> = ({ editor }) => {
}, [editor, createUser]);
useEffect(() => {
if (defaultShowPicker && user && createUser === user.name) {
if (defaultShowPicker && user && createUser === user.id) {
toggleVisible(true);
editor.chain().updateAttributes(Katex.name, { defaultShowPicker: false }).focus().run();
}
}, [defaultShowPicker, toggleVisible, createUser, user]);
}, [editor, defaultShowPicker, toggleVisible, createUser, user]);
useEffect(() => {
if (visible) {

View File

@ -69,7 +69,7 @@ export const StatusWrapper = ({ editor, node, updateAttributes }) => {
const onVisibleChange = useCallback(
(value) => {
toggleVisible(value);
if (defaultShowPicker && user && user.name === createUser) {
if (defaultShowPicker && user && user.id === createUser) {
updateAttributes({ defaultShowPicker: false });
}
},
@ -77,7 +77,7 @@ export const StatusWrapper = ({ editor, node, updateAttributes }) => {
);
useEffect(() => {
if (defaultShowPicker && user && user.name === createUser) {
if (defaultShowPicker && user && user.id === createUser) {
toggleVisible(true);
setTimeout(() => ref.current?.focus(), 100);
}