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 />,
|
icon: <IconMath />,
|
||||||
label: '数学公式',
|
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 />,
|
icon: <IconStatus />,
|
||||||
label: '状态',
|
label: '状态',
|
||||||
action: (editor, user) =>
|
action: (editor, user) => editor.chain().focus().setStatus({ defaultShowPicker: true, createUser: user.id }).run(),
|
||||||
editor.chain().focus().setStatus({ defaultShowPicker: true, createUser: user.name }).run(),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: <IconCallout />,
|
icon: <IconCallout />,
|
||||||
|
|
|
@ -41,10 +41,11 @@ export const KatexBubbleMenu: React.FC<{ editor: Editor }> = ({ editor }) => {
|
||||||
}, [editor, createUser]);
|
}, [editor, createUser]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (defaultShowPicker && user && createUser === user.name) {
|
if (defaultShowPicker && user && createUser === user.id) {
|
||||||
toggleVisible(true);
|
toggleVisible(true);
|
||||||
|
editor.chain().updateAttributes(Katex.name, { defaultShowPicker: false }).focus().run();
|
||||||
}
|
}
|
||||||
}, [defaultShowPicker, toggleVisible, createUser, user]);
|
}, [editor, defaultShowPicker, toggleVisible, createUser, user]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
|
|
|
@ -69,7 +69,7 @@ export const StatusWrapper = ({ editor, node, updateAttributes }) => {
|
||||||
const onVisibleChange = useCallback(
|
const onVisibleChange = useCallback(
|
||||||
(value) => {
|
(value) => {
|
||||||
toggleVisible(value);
|
toggleVisible(value);
|
||||||
if (defaultShowPicker && user && user.name === createUser) {
|
if (defaultShowPicker && user && user.id === createUser) {
|
||||||
updateAttributes({ defaultShowPicker: false });
|
updateAttributes({ defaultShowPicker: false });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -77,7 +77,7 @@ export const StatusWrapper = ({ editor, node, updateAttributes }) => {
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (defaultShowPicker && user && user.name === createUser) {
|
if (defaultShowPicker && user && user.id === createUser) {
|
||||||
toggleVisible(true);
|
toggleVisible(true);
|
||||||
setTimeout(() => ref.current?.focus(), 100);
|
setTimeout(() => ref.current?.focus(), 100);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue