UNPKG

@atlaskit/editor-plugin-synced-block

Version:

SyncedBlock plugin for @atlaskit/editor-core

49 lines (48 loc) • 2.45 kB
import React from 'react'; import type { PortalProviderAPI } from '@atlaskit/editor-common/portal'; import type { getPosHandler } from '@atlaskit/editor-common/react-node-view'; import type { ExtractInjectionAPI, getPosHandlerNode, PMPluginFactoryParams } 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 { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider'; import type { SourceSyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider/syncBlockStoreManager'; import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlockPluginType'; export interface BodiedSyncBlockNodeViewProperties { api?: ExtractInjectionAPI<SyncedBlockPlugin>; pluginOptions: SyncedBlockPluginOptions | undefined; pmPluginFactoryParams: PMPluginFactoryParams; syncBlockStore?: SyncBlockStoreManager; } export declare const SourceSyncBlockLabel: ({ localId, resourceId, sourceManager, }: { localId: string; resourceId: string; sourceManager?: SourceSyncBlockStoreManager; }) => React.JSX.Element; export declare class BodiedSyncBlock implements NodeView { dom: HTMLElement; contentDOM: HTMLElement; node: PMNode; view: EditorView; getPos: getPosHandlerNode; nodeViewPortalProviderAPI: PortalProviderAPI; private api?; private cleanupConnectivityModeListener?; private cleanupViewModeListener?; private labelKey; constructor(node: PMNode, view: EditorView, getPos: getPosHandlerNode, api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined, nodeViewPortalProviderAPI: PortalProviderAPI, sourceManager?: SourceSyncBlockStoreManager); private updateContentEditable; private handleConnectivityModeChange; private handleViewModeChange; /** * Marks the block as empty so the source placeholder can be shown purely from document state. * See `isEmptySourceSyncBlock` for why the DOM is not used to decide this. */ private updateEmptyClass; update(node: PMNode): boolean; ignoreMutation(mutation: MutationRecord | { target: Node; type: 'selection'; }): boolean; destroy(): void; } export declare const bodiedSyncBlockNodeView: (props: BodiedSyncBlockNodeViewProperties) => ((node: PMNode, view: EditorView, getPos: getPosHandler) => NodeView);