This commit is contained in:
Timothy Jaeryang Baek
2025-10-28 01:46:36 -07:00
parent f524a6a8e7
commit d1c9555a0b
@@ -1,4 +1,6 @@
import { mount, unmount } from 'svelte'; import { mount, unmount } from 'svelte';
import { createClassComponent } from 'svelte/legacy';
import tippy from 'tippy.js'; import tippy from 'tippy.js';
export function getSuggestionRenderer(Component: any, ComponentProps = {}) { export function getSuggestionRenderer(Component: any, ComponentProps = {}) {
@@ -16,7 +18,8 @@ export function getSuggestionRenderer(Component: any, ComponentProps = {}) {
document.body.appendChild(container); document.body.appendChild(container);
// mount Svelte component // mount Svelte component
component = mount(Component, { component = createClassComponent({
component: Component,
target: container, target: container,
props: { props: {
char: props?.text, char: props?.text,
@@ -106,7 +109,7 @@ export function getSuggestionRenderer(Component: any, ComponentProps = {}) {
popup = null; popup = null;
try { try {
unmount(component); component.$destroy();
} catch (e) { } catch (e) {
console.error('Error unmounting component:', e); console.error('Error unmounting component:', e);
} }