@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
71 lines (70 loc) • 2.9 kB
TypeScript
import type { ExperienceCheck, ExperienceCheckCallback } from './ExperienceCheck';
/**
* Popup check type determines how popups are observed based on their DOM location:
* - 'inline': Popups appearing in toolbar button-groups (emoji, media, table selector, image)
* - 'editorRoot': Popups attached to editor root (e.g., mention popups)
* - 'editorContent': Content-level popups or modals in portal containers (e.g., block menu)
* - 'portalRoot': Popups in body > .atlaskit-portal-container (e.g., flags, modals)
*/
export type PopupCheckType = 'inline' | 'editorRoot' | 'editorContent' | 'portalRoot';
type InlineConfig = {
getTarget: () => HTMLElement | undefined | null;
nestedElementQuery: string;
/**
* Observe the entire subtree for mutations, not just direct children.
* Use with caution — only enable when the observed DOM subtree is small/lightweight
* (e.g. a single toolbar button). Enabling on large subtrees can cause performance issues.
*/
subtree?: boolean;
type: 'inline';
};
type EditorRootConfig = {
getEditorDom: () => HTMLElement | undefined | null;
nestedElementQuery: string;
type: 'editorRoot';
};
type EditorContentConfig = {
getTarget: () => HTMLElement | undefined | null;
nestedElementQuery: string;
type: 'editorContent';
};
type PortalRootConfig = {
nestedElementQuery: string;
type: 'portalRoot';
};
export type ExperienceCheckPopupMutationConfig = InlineConfig | EditorRootConfig | EditorContentConfig | PortalRootConfig;
export declare class ExperienceCheckPopupMutation implements ExperienceCheck {
private config;
private observers;
constructor(config: ExperienceCheckPopupMutationConfig);
/**
* Returns the list of DOM elements to observe based on popup type.
*/
private getObserveTargets;
/**
* For 'portalRoot' type: observe .atlaskit-portal-container.
* Popups like flags and modals render in body > .atlaskit-portal-container.
*/
private getPortalRootTargets;
/**
* For 'editorContent' type: observe the target (mount point) and any existing
* [data-editor-popup] wrappers within it. Content-level popups and modals
* appear in portal containers.
*/
private getEditorContentTargets;
/**
* For 'inline' type: observe the target element directly.
* The caller is responsible for resolving the correct container
* (e.g. the toolbar button-group) via the getTarget function.
*/
private getInlineTargets;
/**
* For 'editorRoot' type: observe the actual editor root container.
* The editorDom is the ProseMirror element, but popups appear as direct children
* of the parent .akEditor container. So we observe the parent of editorDom.
*/
private getEditorRootTargets;
start(callback: ExperienceCheckCallback): void;
stop(): void;
}
export {};