UNPKG

1.93 kBTypeScriptView Raw
1import { NodeSpec, Node as PMNode } from 'prosemirror-model';
2import { BorderMarkDefinition } from '../marks/border';
3import { LinkDefinition } from '../marks/link';
4export declare type MediaType = 'file' | 'link' | 'external';
5export declare type DisplayType = 'file' | 'thumbnail';
6export declare type DefaultAttributes<T> = {
7 [P in keyof T]: {
8 default?: T[P] | null;
9 };
10};
11/**
12 * @name media_node
13 */
14export interface MediaDefinition {
15 type: 'media';
16 /**
17 * @minItems 1
18 */
19 attrs: MediaADFAttrs;
20 marks?: Array<LinkDefinition | BorderMarkDefinition>;
21}
22export interface MediaBaseAttributes {
23 /**
24 * @minLength 1
25 */
26 id: string;
27 collection: string;
28 height?: number;
29 width?: number;
30 /**
31 * @minLength 1
32 */
33 occurrenceKey?: string;
34 alt?: string;
35 __fileName?: string | null;
36 __fileSize?: number | null;
37 __fileMimeType?: string | null;
38 __displayType?: DisplayType | null;
39 __contextId?: string | null;
40 __mediaTraceId?: string | null;
41 __external?: boolean;
42}
43export interface MediaAttributes extends MediaBaseAttributes {
44 type: 'file' | 'link';
45}
46export interface ExternalMediaAttributes {
47 type: 'external';
48 url: string;
49 alt?: string;
50 width?: number;
51 height?: number;
52 __external?: boolean;
53}
54export declare type MediaADFAttrs = MediaAttributes | ExternalMediaAttributes;
55export declare const defaultAttrs: DefaultAttributes<MediaADFAttrs>;
56export declare const createMediaSpec: (attributes: Partial<NodeSpec['attrs']>, inline?: boolean) => NodeSpec;
57export declare const media: NodeSpec;
58export declare const camelCaseToKebabCase: (str: string) => string;
59export declare const copyPrivateAttributes: (from: Record<string, any>, to: Record<string, any>, map?: ((str: string) => string) | undefined) => void;
60export declare const toJSON: (node: PMNode) => {
61 attrs: Record<string, any>;
62};