tiptap: inset block node at after, no need for create paragraph

This commit is contained in:
fantasticit 2022-06-21 21:36:08 +08:00
parent 2e991f0a79
commit ccc8adfe6b
2 changed files with 0 additions and 10 deletions

View File

@ -6,7 +6,6 @@ import tippy from 'tippy.js';
import { EXTENSION_PRIORITY_HIGHEST } from 'tiptap/core/constants'; import { EXTENSION_PRIORITY_HIGHEST } from 'tiptap/core/constants';
import { insertMenuLRUCache, QUICK_INSERT_COMMANDS, transformToCommands } from 'tiptap/core/menus/commands'; import { insertMenuLRUCache, QUICK_INSERT_COMMANDS, transformToCommands } from 'tiptap/core/menus/commands';
import { MenuList } from 'tiptap/core/wrappers/menu-list'; import { MenuList } from 'tiptap/core/wrappers/menu-list';
import { createNewParagraphBelow } from 'tiptap/prose-utils';
export const QuickInsertPluginKey = new PluginKey('quickInsert'); export const QuickInsertPluginKey = new PluginKey('quickInsert');
@ -34,10 +33,6 @@ export const QuickInsert = Node.create({
const tr = state.tr.deleteRange(from, end); const tr = state.tr.deleteRange(from, end);
dispatch(tr); dispatch(tr);
if (props.isBlock) {
createNewParagraphBelow(state, dispatch);
}
props?.action(editor, props.user); props?.action(editor, props.user);
insertMenuLRUCache.put(props.label); insertMenuLRUCache.put(props.label);
editor?.view?.focus(); editor?.view?.focus();

View File

@ -7,7 +7,6 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { Editor } from 'tiptap/core'; import { Editor } from 'tiptap/core';
import { Title } from 'tiptap/core/extensions/title'; import { Title } from 'tiptap/core/extensions/title';
import { useActive } from 'tiptap/core/hooks/use-active'; import { useActive } from 'tiptap/core/hooks/use-active';
import { createNewParagraphBelow } from 'tiptap/prose-utils';
import { COMMANDS, insertMenuLRUCache, transformToCommands } from '../commands'; import { COMMANDS, insertMenuLRUCache, transformToCommands } from '../commands';
@ -28,10 +27,6 @@ export const Insert: React.FC<{ editor: Editor }> = ({ editor }) => {
insertMenuLRUCache.put(command.label); insertMenuLRUCache.put(command.label);
setRecentUsed(transformToCommands(COMMANDS, insertMenuLRUCache.get() as string[])); setRecentUsed(transformToCommands(COMMANDS, insertMenuLRUCache.get() as string[]));
if (command.isBlock) {
createNewParagraphBelow(editor.view.state, editor.view.dispatch);
}
command.action(editor, user); command.action(editor, user);
toggleVisible(false); toggleVisible(false);
}; };