From 4f8549b8ba6cd4fe39cc79520342b0576a568f51 Mon Sep 17 00:00:00 2001 From: fantasticit Date: Sun, 18 Sep 2022 13:11:44 +0800 Subject: [PATCH 1/3] close #186 --- packages/client/src/tiptap/core/menus/commands.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/client/src/tiptap/core/menus/commands.tsx b/packages/client/src/tiptap/core/menus/commands.tsx index 1b005c87..12dddfc1 100644 --- a/packages/client/src/tiptap/core/menus/commands.tsx +++ b/packages/client/src/tiptap/core/menus/commands.tsx @@ -73,7 +73,10 @@ export const COMMANDS: ICommand[] = [ onSelect={({ rows, cols }) => { return runCommand({ label: '表格', - action: () => editor.chain().focus().insertTable({ rows, cols, withHeaderRow: true }).run(), + action: () => { + editor.chain().focus().run(); + editor.chain().insertTable({ rows, cols, withHeaderRow: true }).focus().run(); + }, })(); }} /> @@ -105,7 +108,10 @@ export const COMMANDS: ICommand[] = [ onSelect={({ cols }) => { return runCommand({ label: '布局', - action: () => editor.chain().focus().setColumns({ type: 'left-right', columns: cols }).run(), + action: () => { + editor.chain().focus().run(); + editor.chain().setColumns({ type: 'left-right', columns: cols }).focus().run(); + }, })(); }} /> From d5a1d824a97d5d5f665733f038f38db8eff51a7d Mon Sep 17 00:00:00 2001 From: fantasticit Date: Sun, 18 Sep 2022 13:12:01 +0800 Subject: [PATCH 2/3] fix jserror --- packages/client/src/tiptap/core/menus/table/bubble.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/client/src/tiptap/core/menus/table/bubble.tsx b/packages/client/src/tiptap/core/menus/table/bubble.tsx index d0aa7c0e..be1a0bfc 100644 --- a/packages/client/src/tiptap/core/menus/table/bubble.tsx +++ b/packages/client/src/tiptap/core/menus/table/bubble.tsx @@ -28,10 +28,10 @@ export const TableBubbleMenu = ({ editor }) => { const getRenderContainer = useCallback((node) => { let container = node; // 文本节点 - if (!container.tag) { + if (container && !container.tag) { container = node.parentElement; } - while (container.tagName !== 'TABLE') { + while (container && container.tagName !== 'TABLE') { container = container.parentElement; } return container.parentElement; From 408e9284284a3836e980cde3f732eb54efbcaa83 Mon Sep 17 00:00:00 2001 From: fantasticit Date: Sun, 18 Sep 2022 13:12:20 +0800 Subject: [PATCH 3/3] don't show text-bubble-menu when columns is active --- packages/client/src/tiptap/core/menus/text/index.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/client/src/tiptap/core/menus/text/index.tsx b/packages/client/src/tiptap/core/menus/text/index.tsx index 4384f008..d585f584 100644 --- a/packages/client/src/tiptap/core/menus/text/index.tsx +++ b/packages/client/src/tiptap/core/menus/text/index.tsx @@ -4,6 +4,7 @@ import { BubbleMenu } from 'tiptap/core/bubble-menu'; import { Attachment } from 'tiptap/core/extensions/attachment'; import { Callout } from 'tiptap/core/extensions/callout'; import { CodeBlock } from 'tiptap/core/extensions/code-block'; +import { Columns } from 'tiptap/core/extensions/columns'; import { Countdown } from 'tiptap/core/extensions/countdown'; import { DocumentChildren } from 'tiptap/core/extensions/document-children'; import { DocumentReference } from 'tiptap/core/extensions/document-reference'; @@ -49,6 +50,7 @@ const OTHER_BUBBLE_MENU_TYPES = [ HorizontalRule.name, Status.name, Excalidraw.name, + Columns.name, ]; export const Text = ({ editor }) => {