mirror of https://github.com/fantasticit/think.git
tiptap: insert block node after current pos
This commit is contained in:
parent
1687dc297c
commit
a9f3de8ff0
|
@ -66,7 +66,7 @@ export const Countdown = Node.create({
|
|||
const pos = selection.$head;
|
||||
|
||||
return chain()
|
||||
.insertContentAt(pos.before(), [
|
||||
.insertContentAt(pos.after(), [
|
||||
{
|
||||
type: this.name,
|
||||
attrs: options,
|
||||
|
|
|
@ -84,8 +84,9 @@ export const Flow = Node.create({
|
|||
|
||||
const { selection } = editor.state;
|
||||
const pos = selection.$head;
|
||||
|
||||
return chain()
|
||||
.insertContentAt(pos.before(), [
|
||||
.insertContentAt(pos.after(), [
|
||||
{
|
||||
type: this.name,
|
||||
attrs: options,
|
||||
|
|
|
@ -86,7 +86,7 @@ export const Iframe = Node.create({
|
|||
const pos = selection.$head;
|
||||
|
||||
return chain()
|
||||
.insertContentAt(pos.before(), [
|
||||
.insertContentAt(pos.after(), [
|
||||
{
|
||||
type: this.name,
|
||||
attrs,
|
||||
|
|
|
@ -96,7 +96,7 @@ export const Mind = Node.create({
|
|||
const { selection } = editor.state;
|
||||
const pos = selection.$head;
|
||||
return chain()
|
||||
.insertContentAt(pos.before(), [
|
||||
.insertContentAt(pos.after(), [
|
||||
{
|
||||
type: this.name,
|
||||
attrs: options,
|
||||
|
|
|
@ -6,7 +6,7 @@ import tippy from 'tippy.js';
|
|||
import { EXTENSION_PRIORITY_HIGHEST } from 'tiptap/core/constants';
|
||||
import { insertMenuLRUCache, QUICK_INSERT_COMMANDS, transformToCommands } from 'tiptap/core/menus/commands';
|
||||
import { MenuList } from 'tiptap/core/wrappers/menu-list';
|
||||
import { createNewParagraphAbove } from 'tiptap/prose-utils';
|
||||
import { createNewParagraphBelow } from 'tiptap/prose-utils';
|
||||
|
||||
export const QuickInsertPluginKey = new PluginKey('quickInsert');
|
||||
|
||||
|
@ -35,7 +35,7 @@ export const QuickInsert = Node.create({
|
|||
dispatch(tr);
|
||||
|
||||
if (props.isBlock) {
|
||||
createNewParagraphAbove(state, dispatch);
|
||||
createNewParagraphBelow(state, dispatch);
|
||||
}
|
||||
|
||||
props?.action(editor, props.user);
|
||||
|
|
|
@ -181,7 +181,7 @@ export const QUICK_INSERT_COMMANDS = [
|
|||
];
|
||||
|
||||
export const transformToCommands = (commands, data: string[]) => {
|
||||
return data
|
||||
return (data || [])
|
||||
.map((label) => {
|
||||
return commands.find((command) => {
|
||||
if ('title' in command) {
|
||||
|
|
Loading…
Reference in New Issue