@atlaskit/adf-schema
Version:
Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs
60 lines (59 loc) • 2.06 kB
TypeScript
import { Node as PMNode } from 'prosemirror-model';
import { Step, StepResult, StepMap, ReplaceStep, Mappable } from 'prosemirror-transform';
export declare const analyticsStepType = "atlaskit-analytics";
export declare const analyticsInvertStepType = "atlaskit-analytics-invert";
export interface AnalyticsPayload {
action: string;
actionSubject: string;
actionSubjectId?: string | null;
attributes?: Record<string, any>;
eventType: string;
}
export interface AnalyticsWithChannel<P extends AnalyticsPayload> {
payload: P;
channel: string;
}
declare enum HISTORY_ACTIONS {
UNDID = "undid",
REDID = "redid"
}
interface UndoAnalyticsEventPayload {
action: HISTORY_ACTIONS.UNDID;
actionSubject: string;
actionSubjectId?: string;
attributes?: Record<string, any>;
eventType: string;
}
interface RedoAnalyticsEventPayload {
action: HISTORY_ACTIONS.REDID;
actionSubject: string;
actionSubjectId?: string;
attributes?: Record<string, any>;
eventType: string;
}
declare type AnalyticsInvertPayload = UndoAnalyticsEventPayload | RedoAnalyticsEventPayload;
export declare type AnalyticsInvertStep = AnalyticsStep<AnalyticsInvertPayload>;
/**
* Custom Prosemirror Step to fire our GAS V3 analytics events
* Using a Step means that it will work with prosemirror-history and we get
* undo/redo events for free
*/
export declare class AnalyticsStep<P extends AnalyticsPayload> extends Step {
analyticsEvents: AnalyticsWithChannel<P>[];
pos?: number;
private actionsToIgnore;
constructor(analyticsEvents: AnalyticsWithChannel<P>[], actionsToIgnore?: string[], pos?: number);
/**
* Generate new undo/redo analytics event when step is inverted
*/
invert(): AnalyticsStep<AnalyticsInvertPayload>;
apply(doc: PMNode): StepResult<any>;
map(mapping: Mappable): AnalyticsStep<P>;
getMap(): StepMap;
merge(other: Step): AnalyticsStep<P> | null;
toJSON(): {
stepType: string;
};
static fromJSON(): ReplaceStep<any>;
}
export {};