Merge pull request #198 from fantasticit/fix/0918

This commit is contained in:
fantasticit 2022-09-18 13:13:46 +08:00 committed by GitHub
commit 325e794322
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 4 deletions

View File

@ -73,7 +73,10 @@ export const COMMANDS: ICommand[] = [
onSelect={({ rows, cols }) => { onSelect={({ rows, cols }) => {
return runCommand({ return runCommand({
label: '表格', 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 }) => { onSelect={({ cols }) => {
return runCommand({ return runCommand({
label: '布局', 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();
},
})(); })();
}} }}
/> />

View File

@ -28,10 +28,10 @@ export const TableBubbleMenu = ({ editor }) => {
const getRenderContainer = useCallback((node) => { const getRenderContainer = useCallback((node) => {
let container = node; let container = node;
// 文本节点 // 文本节点
if (!container.tag) { if (container && !container.tag) {
container = node.parentElement; container = node.parentElement;
} }
while (container.tagName !== 'TABLE') { while (container && container.tagName !== 'TABLE') {
container = container.parentElement; container = container.parentElement;
} }
return container.parentElement; return container.parentElement;

View File

@ -4,6 +4,7 @@ import { BubbleMenu } from 'tiptap/core/bubble-menu';
import { Attachment } from 'tiptap/core/extensions/attachment'; import { Attachment } from 'tiptap/core/extensions/attachment';
import { Callout } from 'tiptap/core/extensions/callout'; import { Callout } from 'tiptap/core/extensions/callout';
import { CodeBlock } from 'tiptap/core/extensions/code-block'; import { CodeBlock } from 'tiptap/core/extensions/code-block';
import { Columns } from 'tiptap/core/extensions/columns';
import { Countdown } from 'tiptap/core/extensions/countdown'; import { Countdown } from 'tiptap/core/extensions/countdown';
import { DocumentChildren } from 'tiptap/core/extensions/document-children'; import { DocumentChildren } from 'tiptap/core/extensions/document-children';
import { DocumentReference } from 'tiptap/core/extensions/document-reference'; import { DocumentReference } from 'tiptap/core/extensions/document-reference';
@ -49,6 +50,7 @@ const OTHER_BUBBLE_MENU_TYPES = [
HorizontalRule.name, HorizontalRule.name,
Status.name, Status.name,
Excalidraw.name, Excalidraw.name,
Columns.name,
]; ];
export const Text = ({ editor }) => { export const Text = ({ editor }) => {