@atlaskit/adf-schema
Version:
Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs
63 lines (62 loc) • 1.93 kB
TypeScript
import { NodeSpec, Node as PMNode } from 'prosemirror-model';
import { BorderMarkDefinition } from '../marks/border';
import { LinkDefinition } from '../marks/link';
export declare type MediaType = 'file' | 'link' | 'external';
export declare type DisplayType = 'file' | 'thumbnail';
export declare type DefaultAttributes<T> = {
[P in keyof T]: {
default?: T[P] | null;
};
};
/**
* @name media_node
*/
export interface MediaDefinition {
type: 'media';
/**
* @minItems 1
*/
attrs: MediaADFAttrs;
marks?: Array<LinkDefinition | BorderMarkDefinition>;
}
export interface MediaBaseAttributes {
/**
* @minLength 1
*/
id: string;
collection: string;
height?: number;
width?: number;
/**
* @minLength 1
*/
occurrenceKey?: string;
alt?: string;
__fileName?: string | null;
__fileSize?: number | null;
__fileMimeType?: string | null;
__displayType?: DisplayType | null;
__contextId?: string | null;
__mediaTraceId?: string | null;
__external?: boolean;
}
export interface MediaAttributes extends MediaBaseAttributes {
type: 'file' | 'link';
}
export interface ExternalMediaAttributes {
type: 'external';
url: string;
alt?: string;
width?: number;
height?: number;
__external?: boolean;
}
export declare type MediaADFAttrs = MediaAttributes | ExternalMediaAttributes;
export declare const defaultAttrs: DefaultAttributes<MediaADFAttrs>;
export declare const createMediaSpec: (attributes: Partial<NodeSpec['attrs']>, inline?: boolean) => NodeSpec;
export declare const media: NodeSpec;
export declare const camelCaseToKebabCase: (str: string) => string;
export declare const copyPrivateAttributes: (from: Record<string, any>, to: Record<string, any>, map?: ((str: string) => string) | undefined) => void;
export declare const toJSON: (node: PMNode) => {
attrs: Record<string, any>;
};