fix types
This commit is contained in:
parent
9fc6c3b641
commit
200cdbd4ef
1 changed files with 20 additions and 10 deletions
|
@ -2,7 +2,7 @@ import { ApplicationController } from './application_controller';
|
||||||
import { Editor } from '@tiptap/core';
|
import { Editor } from '@tiptap/core';
|
||||||
import StarterKit from '@tiptap/starter-kit';
|
import StarterKit from '@tiptap/starter-kit';
|
||||||
import Mention from '@tiptap/extension-mention';
|
import Mention from '@tiptap/extension-mention';
|
||||||
import tippy from 'tippy.js';
|
import tippy, { type Instance } from 'tippy.js';
|
||||||
import { httpRequest } from '@utils';
|
import { httpRequest } from '@utils';
|
||||||
|
|
||||||
export class AttestationController extends ApplicationController {
|
export class AttestationController extends ApplicationController {
|
||||||
|
@ -43,7 +43,7 @@ export class AttestationController extends ApplicationController {
|
||||||
},
|
},
|
||||||
|
|
||||||
render: () => {
|
render: () => {
|
||||||
let popup: { setProps: Function, hide: Function, destroy: Function }[];
|
let popup: Instance;
|
||||||
let div: HTMLElement;
|
let div: HTMLElement;
|
||||||
let selectedIndex = 0;
|
let selectedIndex = 0;
|
||||||
let items: string[];
|
let items: string[];
|
||||||
|
@ -73,10 +73,14 @@ export class AttestationController extends ApplicationController {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let body: Element = document.body;
|
popup = tippy(document.body, {
|
||||||
|
getReferenceClientRect: () => {
|
||||||
popup = tippy(body, {
|
const domrect = props.clientRect?.();
|
||||||
getReferenceClientRect: props.clientRect,
|
if (!domrect) {
|
||||||
|
throw new Error('No client rect');
|
||||||
|
}
|
||||||
|
return domrect;
|
||||||
|
},
|
||||||
appendTo: () => this.element,
|
appendTo: () => this.element,
|
||||||
content: div,
|
content: div,
|
||||||
showOnCreate: true,
|
showOnCreate: true,
|
||||||
|
@ -96,14 +100,20 @@ export class AttestationController extends ApplicationController {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
popup[0].setProps({
|
popup.setProps({
|
||||||
getReferenceClientRect: props.clientRect
|
getReferenceClientRect: () => {
|
||||||
|
const domrect = props.clientRect?.();
|
||||||
|
if (!domrect) {
|
||||||
|
throw new Error('No client rect');
|
||||||
|
}
|
||||||
|
return domrect;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onKeyDown(props) {
|
onKeyDown(props) {
|
||||||
if (props.event.key === 'Escape') {
|
if (props.event.key === 'Escape') {
|
||||||
popup[0].hide();
|
popup.hide();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -134,7 +144,7 @@ export class AttestationController extends ApplicationController {
|
||||||
},
|
},
|
||||||
|
|
||||||
onExit() {
|
onExit() {
|
||||||
popup[0].destroy();
|
popup.destroy();
|
||||||
div.remove();
|
div.remove();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue