import './ai-popup.js'; import type { InlineRange } from '@blockeditor/inline'; import type { AffineInlineEditor } from '../../../affine-inline-specs.js'; import { AIPopup } from './ai-popup.js'; export function toggleAIPopup( inlineEditors : AffineInlineEditor[], type : AIPopup['type'], targetInlineRanges : InlineRange[] ) : AIPopup { const popup = new AIPopup(); popup.inlineEditors = inlineEditors; popup.type = type; popup.targetInlineRanges = targetInlineRanges; //console.log(111, inlineEditors, targetInlineRanges) const docPageEle = document.querySelectorAll('.affine-doc-viewport')[0]; if (docPageEle) { const scrollTop = docPageEle ? docPageEle.scrollTop : 0; docPageEle.appendChild(popup); setTimeout(() => { docPageEle.scrollTo({ top: scrollTop, behavior: 'instant' }) // smooth }, 0) } // document.body.appendChild(popup); return popup; }