@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
19 lines (18 loc) • 1.11 kB
TypeScript
import type { LinkStepMetadata } from '@atlaskit/adf-schema/steps';
import type { EditorState, ReadonlyTransaction, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
/**
* Records metadata about the user action and input method relating to a transaction
* as a custom LinkStepMetadata prosemirror step so that it is preserved in
* the history for undo/redo.
*/
export declare function addLinkMetadata(initialSelection: Selection, tr: Transaction, metadata: LinkStepMetadata): Transaction;
export declare function getLinkMetadataFromTransaction(tr: Transaction | ReadonlyTransaction): LinkStepMetadata;
export type CommandDispatch = (tr: Transaction) => void;
export type Command = (state: EditorState, dispatch?: CommandDispatch, view?: EditorView) => boolean;
/**
* Adds metadata to the transaction created from a command
* The metadata describes the user intent and input method
* for executing the command
*/
export declare const commandWithMetadata: (command: Command, metadata: LinkStepMetadata) => Command;