From 9581821b9997aa94476b53adcd86d09a324835a8 Mon Sep 17 00:00:00 2001 From: liufuwei Date: Wed, 17 Aug 2022 15:39:59 +0800 Subject: [PATCH] fix: quickinsert tippy postion wrong --- .../tiptap/core/extensions/quick-insert.ts | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/client/src/tiptap/core/extensions/quick-insert.ts b/packages/client/src/tiptap/core/extensions/quick-insert.ts index cad374cc..5df5eb7a 100644 --- a/packages/client/src/tiptap/core/extensions/quick-insert.ts +++ b/packages/client/src/tiptap/core/extensions/quick-insert.ts @@ -8,9 +8,10 @@ import { insertMenuLRUCache, QUICK_INSERT_COMMANDS, transformToCommands } from ' import { MenuList } from 'tiptap/core/wrappers/menu-list'; export const QuickInsertPluginKey = new PluginKey('quickInsert'); +const extensionName = 'quickInsert' export const QuickInsert = Node.create({ - name: 'quickInsert', + name: extensionName, priority: EXTENSION_PRIORITY_HIGHEST, @@ -52,6 +53,19 @@ export const QuickInsert = Node.create({ }), ]; }, + + addStorage() { + return { + rect: { + width: 0, + height: 0, + left: 0, + top: 0, + right: 0, + bottom: 0, + } + } + }, }).configure({ suggestion: { items: ({ query }) => { @@ -79,7 +93,7 @@ export const QuickInsert = Node.create({ }); popup = tippy('body', { - getReferenceClientRect: props.clientRect, + getReferenceClientRect: props.clientRect || (() => props.editor.storage[extensionName].rect), appendTo: () => document.body, content: component.element, showOnCreate: true, @@ -93,6 +107,9 @@ export const QuickInsert = Node.create({ if (!isEditable) return; component.updateProps(props); + + props.editor.storage[extensionName].rect = props.clientRect(); + popup[0].setProps({ getReferenceClientRect: props.clientRect, });