Merge pull request #168 from helloforrestworld/hot-fix-quickinsert-20220817

This commit is contained in:
fantasticit 2022-08-17 16:40:56 +08:00 committed by GitHub
commit b5e2bea519
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 2 deletions

View File

@ -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,
});