import type { Ctx } from '@milkdown/core' ; import { ViewFactory } from '@milkdown/prose' ; import React from 'react' ; export const portalContext = React . createContext < ( Component : React . FC ) => ( ctx : Ctx ) => ViewFactory > ( ( ) => ( ) => { throw new Error ( ) ; } ) ; const getId = ( portals ) => portals . map ( ( x ) => x . key ) . join ( ',' ) ; export const Portals = React . memo ( ( { portals } ) => { return < > { ... portals } < />; } , ( prev , next ) => { return getId ( prev . portals ) === getId ( next . portals ) ; } ) ;