@atlaskit/editor-plugin-table
Version:
Table plugin for the @atlaskit/editor
46 lines (45 loc) • 2.47 kB
TypeScript
import React from 'react';
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
import type { GetEditorContainerWidth, GetEditorFeatureFlags, getPosHandler, getPosHandlerNode } from '@atlaskit/editor-common/types';
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
import type { PluginInjectionAPI } from '../types';
import type { Props } from './types';
type ForwardRef = (node: HTMLElement | null) => void;
export default class TableView extends ReactNodeView<Props> {
private table;
private renderedDOM?;
private resizeObserver?;
eventDispatcher?: EventDispatcher;
getPos: getPosHandlerNode;
options: import("./types").TableOptions | undefined;
getEditorFeatureFlags: GetEditorFeatureFlags;
constructor(props: Props);
getContentDOM(): {
contentDOM?: HTMLElement;
dom: HTMLElement;
};
/**
* Handles moving the table from ProseMirror's DOM structure into a React-rendered table node.
* Temporarily disables mutation observers (except for selection changes) during the move,
* preserves selection state, and restores it afterwards if mutations occurred and cursor
* wasn't at start of node. This prevents duplicate tables and maintains editor state during
* the DOM manipulation.
*/
private _handleTableRef;
setDomAttrs(node: PmNode): void;
getNode: () => PmNode;
render(props: Props, forwardRef: ForwardRef): React.JSX.Element;
private hasHoveredRows;
viewShouldUpdate(nextNode: PmNode): boolean;
ignoreMutation(mutation: MutationRecord | {
target: Node;
type: 'selection';
}): boolean;
destroy(): void;
}
export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, dispatchAnalyticsEvent: DispatchAnalyticsEvent, pluginInjectionApi?: PluginInjectionAPI, isCommentEditor?: boolean, isChromelessEditor?: boolean, allowFixedColumnWidthOption?: boolean) => NodeView;
export {};