UNPKG

2.06 kBTypeScriptView Raw
1import { Node as PMNode } from 'prosemirror-model';
2import { Step, StepResult, StepMap, ReplaceStep, Mappable } from 'prosemirror-transform';
3export declare const analyticsStepType = "atlaskit-analytics";
4export declare const analyticsInvertStepType = "atlaskit-analytics-invert";
5export interface AnalyticsPayload {
6 action: string;
7 actionSubject: string;
8 actionSubjectId?: string | null;
9 attributes?: Record<string, any>;
10 eventType: string;
11}
12export interface AnalyticsWithChannel<P extends AnalyticsPayload> {
13 payload: P;
14 channel: string;
15}
16declare enum HISTORY_ACTIONS {
17 UNDID = "undid",
18 REDID = "redid"
19}
20interface UndoAnalyticsEventPayload {
21 action: HISTORY_ACTIONS.UNDID;
22 actionSubject: string;
23 actionSubjectId?: string;
24 attributes?: Record<string, any>;
25 eventType: string;
26}
27interface RedoAnalyticsEventPayload {
28 action: HISTORY_ACTIONS.REDID;
29 actionSubject: string;
30 actionSubjectId?: string;
31 attributes?: Record<string, any>;
32 eventType: string;
33}
34declare type AnalyticsInvertPayload = UndoAnalyticsEventPayload | RedoAnalyticsEventPayload;
35export declare type AnalyticsInvertStep = AnalyticsStep<AnalyticsInvertPayload>;
36/**
37 * Custom Prosemirror Step to fire our GAS V3 analytics events
38 * Using a Step means that it will work with prosemirror-history and we get
39 * undo/redo events for free
40 */
41export declare class AnalyticsStep<P extends AnalyticsPayload> extends Step {
42 analyticsEvents: AnalyticsWithChannel<P>[];
43 pos?: number;
44 private actionsToIgnore;
45 constructor(analyticsEvents: AnalyticsWithChannel<P>[], actionsToIgnore?: string[], pos?: number);
46 /**
47 * Generate new undo/redo analytics event when step is inverted
48 */
49 invert(): AnalyticsStep<AnalyticsInvertPayload>;
50 apply(doc: PMNode): StepResult<any>;
51 map(mapping: Mappable): AnalyticsStep<P>;
52 getMap(): StepMap;
53 merge(other: Step): AnalyticsStep<P> | null;
54 toJSON(): {
55 stepType: string;
56 };
57 static fromJSON(): ReplaceStep<any>;
58}
59export {};