@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
87 lines (86 loc) • 5.03 kB
TypeScript
import React from 'react';
import type { IntlShape } from 'react-intl';
import type { ADFEntity } from '@atlaskit/adf-utils/types';
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
import type { Decoration, DecorationSource, EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
import type { EventDispatcher } from '../event-dispatcher';
import type { ExtensionHandlers } from '../extensions';
import type { PortalProviderAPI } from '../portal';
import type { ProviderFactory } from '../provider-factory';
import type { ForwardRef, getPosHandler } from '../react-node-view';
import ReactNodeView from '../react-node-view';
import type { EditorAppearance } from '../types';
import type { ExtensionsPluginInjectionAPI, MacroInteractionDesignFeatureFlags, GetPMNodeHeight } from './types';
interface ExtensionNodeViewOptions {
appearance?: EditorAppearance;
getExtensionHeight?: GetPMNodeHeight;
}
interface ReactExtensionNodeProps {
extensionHandlers: ExtensionHandlers;
extensionNodeViewOptions?: ExtensionNodeViewOptions;
intl?: IntlShape;
macroInteractionDesignFeatureFlags?: MacroInteractionDesignFeatureFlags;
pluginInjectionApi: ExtensionsPluginInjectionAPI;
providerFactory: ProviderFactory;
rendererExtensionHandlers?: ExtensionHandlers;
showLivePagesBodiedMacrosRendererView?: (node: ADFEntity) => boolean;
showUpdatedLivePages1PBodiedExtensionUI?: (node: ADFEntity) => boolean;
}
export declare class ExtensionNode<AdditionalParams = unknown> extends ReactNodeView<ReactExtensionNodeProps & AdditionalParams> {
/** True between SSR DOM adoption in `createDomRef` and the SSR→React handoff in `update`. */
private didReuseSsrDom;
ignoreMutation(mutation: MutationRecord | {
target: Node;
type: 'selection';
}): boolean;
/** See {@link consumedHydrationIdentitiesByEditor}. Null when attrs are missing → SSR reuse skipped. */
private getHydrationIdentityKey;
/** True only for the first ExtensionNode of this identity in this editor. See {@link consumedHydrationIdentitiesByEditor}. */
private isInInitialHydrationWindow;
createDomRef(): HTMLElement;
/**
* Cache for SSR element lookup to avoid repeated DOM queries.
* undefined = not yet searched, null = searched but not found, HTMLElement = found
*/
private cachedSsrElement;
/**
* Attempts to find an existing SSR'd DOM element for this extension node by extensionKey and localId
* which should uniquely identify the
* extension node within the editor content.
*
* @returns The SSR'd element if found, otherwise null
*/
private findSSRElement;
/** Skip React Portal render on first init when reusing SSR DOM. See {@link consumedHydrationIdentitiesByEditor}. */
init(): this;
update(node: PmNode, decorations: ReadonlyArray<Decoration>, _innerDecorations?: DecorationSource, validUpdate?: (currentNode: PmNode, newNode: PmNode) => boolean): boolean;
/**
* When interacting with input elements inside an extension's body, the events
* bubble up to the editor and get handled by it. This almost always gets in the way
* of being able to actually interact with said input in the extension, i.e.
* typing inside a text field (in an extension body) will print the text in the editor
* content area instead. This change prevents the editor view from trying to handle these events,
* when the target of the event is an input element, so the extension can.
*/
stopEvent(event: Event): boolean;
getContentDOM(): {
contentDOM: HTMLDivElement;
dom: HTMLDivElement;
} | {
contentDOM?: undefined;
dom: HTMLDivElement;
} | undefined;
render(props: {
extensionHandlers: ExtensionHandlers;
extensionNodeViewOptions?: ExtensionNodeViewOptions;
intl?: IntlShape;
macroInteractionDesignFeatureFlags?: MacroInteractionDesignFeatureFlags;
pluginInjectionApi: ExtensionsPluginInjectionAPI;
providerFactory: ProviderFactory;
rendererExtensionHandlers?: ExtensionHandlers;
showLivePagesBodiedMacrosRendererView?: (node: ADFEntity) => boolean;
showUpdatedLivePages1PBodiedExtensionUI?: (node: ADFEntity) => boolean;
}, forwardRef: ForwardRef): React.JSX.Element;
}
export default function ExtensionNodeView(portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, extensionHandlers: ExtensionHandlers, extensionNodeViewOptions: ExtensionNodeViewOptions, pluginInjectionApi: ExtensionsPluginInjectionAPI, macroInteractionDesignFeatureFlags?: MacroInteractionDesignFeatureFlags, showLivePagesBodiedMacrosRendererView?: (node: ADFEntity) => boolean, showUpdatedLivePages1PBodiedExtensionUI?: (node: ADFEntity) => boolean, rendererExtensionHandlers?: ExtensionHandlers, intl?: IntlShape): (node: PmNode, view: EditorView, getPos: getPosHandler) => NodeView;
export {};