mirror of https://github.com/fantasticit/think.git
tiptap: use id instead of name
This commit is contained in:
parent
d073531325
commit
e928981c08
|
@ -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 />,
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue