@atlaskit/adf-schema
Version:
Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs
69 lines (68 loc) • 2.17 kB
TypeScript
import { NodeSpec, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
import { BorderMarkDefinition } from '../marks/border';
import { LinkDefinition } from '../marks/link';
import { AnnotationMarkDefinition } from '../marks/annotation';
export type MediaType = 'file' | 'link' | 'external';
export type DisplayType = 'file' | 'thumbnail';
export 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 | AnnotationMarkDefinition>;
}
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 type MediaADFAttrs = MediaAttributes | ExternalMediaAttributes;
export declare const defaultAttrs: {
[name: string]: import("prosemirror-model").AttributeSpec;
};
export interface MutableMediaAttributes extends MediaAttributes {
[key: string]: string | number | undefined | null | boolean;
}
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>;
};