UNPKG

1.66 kBTypeScriptView Raw
1import { Node as PMNode, Schema } from 'prosemirror-model';
2import { ReplaceStep, Step, StepMap, StepResult, Mappable } from 'prosemirror-transform';
3export declare const stepType = "editor-linking-meta";
4export declare const invertStepType = "editor-linking-meta-invert";
5export declare type LinkStepMetadata = {
6 /**
7 * Editor action performed
8 */
9 action?: string;
10 /**
11 * Editor input method that triggered the transaction
12 */
13 inputMethod?: string;
14 /**
15 * The applicable card action for this step
16 * if is RESOLVE then the undo/redo steps should be considered "updates" of a link
17 */
18 cardAction?: 'RESOLVE';
19 /**
20 * Source UI that tiggered this step, if available/applicable
21 */
22 sourceEvent?: unknown;
23};
24/**
25 * Custom Prosemirror Step to attach metadata about user interactions with links
26 * Using a Step means that it will work with prosemirror-history and we get utilise when
27 * firing events on history change
28 */
29export declare class LinkMetaStep extends Step {
30 private pos;
31 private metadata;
32 private isInverted;
33 constructor(pos: number | null, metadata: LinkStepMetadata, isInverted?: boolean);
34 getMetadata(): LinkStepMetadata;
35 /**
36 * Generate new undo/redo analytics event when step is inverted
37 */
38 invert(): LinkMetaStep;
39 apply(doc: PMNode): StepResult<any>;
40 map(mapping: Mappable): LinkMetaStep;
41 getMap(): StepMap;
42 merge(): null;
43 toJSON(): {
44 stepType: string;
45 from: number;
46 to: number;
47 };
48 static fromJSON<S extends Schema = any>(_: S, __: {
49 [key: string]: any;
50 }): ReplaceStep<any>;
51}