2019-12-18 18:16:02 +02:00
|
|
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
2019-12-02 12:04:07 +01:00
|
|
|
declare module 'netlify-cms-core' {
|
2022-09-20 10:14:40 -04:00
|
|
|
import type { ComponentType, ReactNode } from 'react';
|
2021-05-31 14:23:16 +02:00
|
|
|
import type { List, Map } from 'immutable';
|
2021-07-25 15:03:35 +02:00
|
|
|
import type { Pluggable } from 'unified';
|
2019-12-02 12:04:07 +01:00
|
|
|
|
2020-11-26 04:55:24 -06:00
|
|
|
export type CmsBackendType =
|
|
|
|
| 'azure'
|
|
|
|
| 'git-gateway'
|
|
|
|
| 'github'
|
|
|
|
| 'gitlab'
|
|
|
|
| 'bitbucket'
|
2021-02-14 18:41:02 +01:00
|
|
|
| 'test-repo'
|
|
|
|
| 'proxy';
|
2019-12-02 12:04:07 +01:00
|
|
|
|
2019-12-18 18:16:02 +02:00
|
|
|
export type CmsMapWidgetType = 'Point' | 'LineString' | 'Polygon';
|
2019-12-02 12:04:07 +01:00
|
|
|
|
2019-12-18 18:16:02 +02:00
|
|
|
export type CmsMarkdownWidgetButton =
|
|
|
|
| 'bold'
|
2019-12-02 12:04:07 +01:00
|
|
|
| 'italic'
|
|
|
|
| 'code'
|
|
|
|
| 'link'
|
|
|
|
| 'heading-one'
|
|
|
|
| 'heading-two'
|
|
|
|
| 'heading-three'
|
|
|
|
| 'heading-four'
|
|
|
|
| 'heading-five'
|
|
|
|
| 'heading-six'
|
|
|
|
| 'quote'
|
|
|
|
| 'code-block'
|
|
|
|
| 'bulleted-list'
|
|
|
|
| 'numbered-list';
|
|
|
|
|
2020-06-01 09:42:11 +02:00
|
|
|
export interface CmsSelectWidgetOptionObject {
|
|
|
|
label: string;
|
|
|
|
value: any;
|
|
|
|
}
|
2019-12-02 12:04:07 +01:00
|
|
|
|
2019-12-18 18:16:02 +02:00
|
|
|
export type CmsCollectionFormatType =
|
|
|
|
| 'yml'
|
2019-12-02 12:04:07 +01:00
|
|
|
| 'yaml'
|
|
|
|
| 'toml'
|
|
|
|
| 'json'
|
|
|
|
| 'frontmatter'
|
|
|
|
| 'yaml-frontmatter'
|
|
|
|
| 'toml-frontmatter'
|
|
|
|
| 'json-frontmatter';
|
|
|
|
|
|
|
|
export type CmsAuthScope = 'repo' | 'public_repo';
|
|
|
|
|
|
|
|
export type CmsPublishMode = 'simple' | 'editorial_workflow';
|
|
|
|
|
|
|
|
export type CmsSlugEncoding = 'unicode' | 'ascii';
|
|
|
|
|
2020-11-30 05:41:07 -05:00
|
|
|
export interface CmsI18nConfig {
|
|
|
|
structure: 'multiple_folders' | 'multiple_files' | 'single_file';
|
|
|
|
locales: string[];
|
|
|
|
default_locale?: string;
|
|
|
|
}
|
|
|
|
|
2020-11-30 09:04:25 -05:00
|
|
|
export interface CmsFieldBase {
|
2019-12-02 12:04:07 +01:00
|
|
|
name: string;
|
|
|
|
label?: string;
|
|
|
|
required?: boolean;
|
2020-06-01 09:42:11 +02:00
|
|
|
hint?: string;
|
|
|
|
pattern?: [string, string];
|
2021-02-14 18:41:02 +01:00
|
|
|
i18n?: boolean | 'translate' | 'duplicate' | 'none';
|
|
|
|
media_folder?: string;
|
|
|
|
public_folder?: string;
|
|
|
|
comment?: string;
|
2020-11-30 09:04:25 -05:00
|
|
|
}
|
|
|
|
|
2020-11-30 19:53:15 +03:00
|
|
|
export interface CmsFieldBoolean {
|
|
|
|
widget: 'boolean';
|
|
|
|
default?: boolean;
|
|
|
|
}
|
|
|
|
|
2020-11-30 09:04:25 -05:00
|
|
|
export interface CmsFieldCode {
|
|
|
|
widget: 'code';
|
|
|
|
default?: any;
|
2020-06-01 09:42:11 +02:00
|
|
|
|
|
|
|
default_language?: string;
|
|
|
|
allow_language_selection?: boolean;
|
|
|
|
keys?: { code: string; lang: string };
|
|
|
|
output_code_only?: boolean;
|
2020-11-30 09:04:25 -05:00
|
|
|
}
|
|
|
|
|
2020-11-30 19:53:15 +03:00
|
|
|
export interface CmsFieldColor {
|
|
|
|
widget: 'color';
|
|
|
|
default?: string;
|
|
|
|
|
|
|
|
allowInput?: boolean;
|
|
|
|
enableAlpha?: boolean;
|
|
|
|
}
|
|
|
|
|
2020-11-30 09:04:25 -05:00
|
|
|
export interface CmsFieldDateTime {
|
|
|
|
widget: 'datetime';
|
|
|
|
default?: string;
|
2020-06-01 09:42:11 +02:00
|
|
|
|
|
|
|
format?: string;
|
2020-08-31 19:25:48 +08:00
|
|
|
date_format?: boolean | string;
|
|
|
|
time_format?: boolean | string;
|
|
|
|
picker_utc?: boolean;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated Use date_format instead
|
|
|
|
*/
|
2020-06-01 09:42:11 +02:00
|
|
|
dateFormat?: boolean | string;
|
2020-08-31 19:25:48 +08:00
|
|
|
/**
|
|
|
|
* @deprecated Use time_format instead
|
|
|
|
*/
|
2020-06-01 09:42:11 +02:00
|
|
|
timeFormat?: boolean | string;
|
2020-08-31 19:25:48 +08:00
|
|
|
/**
|
|
|
|
* @deprecated Use picker_utc instead
|
|
|
|
*/
|
2020-06-01 09:42:11 +02:00
|
|
|
pickerUtc?: boolean;
|
2020-11-30 09:04:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface CmsFieldFileOrImage {
|
|
|
|
widget: 'file' | 'image';
|
|
|
|
default?: string;
|
2020-06-01 09:42:11 +02:00
|
|
|
|
|
|
|
media_library?: CmsMediaLibrary;
|
|
|
|
allow_multiple?: boolean;
|
|
|
|
config?: any;
|
2020-11-30 09:04:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface CmsFieldObject {
|
|
|
|
widget: 'object';
|
|
|
|
default?: any;
|
2020-06-01 09:42:11 +02:00
|
|
|
|
|
|
|
collapsed?: boolean;
|
2020-11-30 09:04:25 -05:00
|
|
|
summary?: string;
|
|
|
|
fields: CmsField[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface CmsFieldList {
|
|
|
|
widget: 'list';
|
|
|
|
default?: any;
|
2020-06-01 09:42:11 +02:00
|
|
|
|
|
|
|
allow_add?: boolean;
|
2020-11-30 09:04:25 -05:00
|
|
|
collapsed?: boolean;
|
2020-06-01 09:42:11 +02:00
|
|
|
summary?: string;
|
|
|
|
minimize_collapsed?: boolean;
|
|
|
|
label_singular?: string;
|
2020-11-30 09:04:25 -05:00
|
|
|
field?: CmsField;
|
|
|
|
fields?: CmsField[];
|
|
|
|
max?: number;
|
|
|
|
min?: number;
|
|
|
|
add_to_top?: boolean;
|
|
|
|
types?: (CmsFieldBase & CmsFieldObject)[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface CmsFieldMap {
|
|
|
|
widget: 'map';
|
|
|
|
default?: string;
|
2020-06-01 09:42:11 +02:00
|
|
|
|
|
|
|
decimals?: number;
|
|
|
|
type?: CmsMapWidgetType;
|
2020-11-30 09:04:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface CmsFieldMarkdown {
|
|
|
|
widget: 'markdown';
|
|
|
|
default?: string;
|
2020-06-01 09:42:11 +02:00
|
|
|
|
|
|
|
minimal?: boolean;
|
|
|
|
buttons?: CmsMarkdownWidgetButton[];
|
2020-08-31 19:25:48 +08:00
|
|
|
editor_components?: string[];
|
2020-11-30 09:04:25 -05:00
|
|
|
modes?: ('raw' | 'rich_text')[];
|
2020-08-31 19:25:48 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated Use editor_components instead
|
|
|
|
*/
|
2020-06-01 09:42:11 +02:00
|
|
|
editorComponents?: string[];
|
2020-11-30 09:04:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface CmsFieldNumber {
|
|
|
|
widget: 'number';
|
|
|
|
default?: string | number;
|
2020-06-01 09:42:11 +02:00
|
|
|
|
2020-08-31 19:25:48 +08:00
|
|
|
value_type?: 'int' | 'float' | string;
|
2020-11-30 09:04:25 -05:00
|
|
|
min?: number;
|
|
|
|
max?: number;
|
|
|
|
|
2020-06-01 09:42:11 +02:00
|
|
|
step?: number;
|
|
|
|
|
2020-08-31 19:25:48 +08:00
|
|
|
/**
|
|
|
|
* @deprecated Use valueType instead
|
|
|
|
*/
|
|
|
|
valueType?: 'int' | 'float' | string;
|
2020-11-30 09:04:25 -05:00
|
|
|
}
|
2020-08-31 19:25:48 +08:00
|
|
|
|
2020-11-30 09:04:25 -05:00
|
|
|
export interface CmsFieldSelect {
|
|
|
|
widget: 'select';
|
|
|
|
default?: string | string[];
|
|
|
|
|
|
|
|
options: string[] | CmsSelectWidgetOptionObject[];
|
|
|
|
multiple?: boolean;
|
2020-06-01 09:42:11 +02:00
|
|
|
min?: number;
|
|
|
|
max?: number;
|
2020-11-30 09:04:25 -05:00
|
|
|
}
|
2020-06-01 09:42:11 +02:00
|
|
|
|
2020-11-30 09:04:25 -05:00
|
|
|
export interface CmsFieldRelation {
|
|
|
|
widget: 'relation';
|
|
|
|
default?: string | string[];
|
2020-06-01 09:42:11 +02:00
|
|
|
|
2020-11-30 09:04:25 -05:00
|
|
|
collection: string;
|
|
|
|
value_field: string;
|
|
|
|
search_fields: string[];
|
2020-08-31 19:25:48 +08:00
|
|
|
file?: string;
|
|
|
|
display_fields?: string[];
|
2020-11-30 09:04:25 -05:00
|
|
|
multiple?: boolean;
|
2020-08-31 19:25:48 +08:00
|
|
|
options_length?: number;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated Use value_field instead
|
|
|
|
*/
|
2020-06-01 09:42:11 +02:00
|
|
|
valueField?: string;
|
2020-08-31 19:25:48 +08:00
|
|
|
/**
|
|
|
|
* @deprecated Use search_fields instead
|
|
|
|
*/
|
2020-06-01 09:42:11 +02:00
|
|
|
searchFields?: string[];
|
2020-08-31 19:25:48 +08:00
|
|
|
/**
|
|
|
|
* @deprecated Use display_fields instead
|
|
|
|
*/
|
2020-06-01 09:42:11 +02:00
|
|
|
displayFields?: string[];
|
2020-08-31 19:25:48 +08:00
|
|
|
/**
|
|
|
|
* @deprecated Use options_length instead
|
|
|
|
*/
|
2020-06-01 09:42:11 +02:00
|
|
|
optionsLength?: number;
|
2020-11-30 09:04:25 -05:00
|
|
|
}
|
2020-06-01 09:42:11 +02:00
|
|
|
|
2020-11-30 09:04:25 -05:00
|
|
|
export interface CmsFieldHidden {
|
|
|
|
widget: 'hidden';
|
|
|
|
default?: any;
|
2019-12-02 12:04:07 +01:00
|
|
|
}
|
|
|
|
|
2020-11-30 09:04:25 -05:00
|
|
|
export interface CmsFieldStringOrText {
|
|
|
|
// This is the default widget, so declaring its type is optional.
|
|
|
|
widget?: 'string' | 'text';
|
|
|
|
default?: string;
|
|
|
|
}
|
|
|
|
|
2021-02-14 18:41:02 +01:00
|
|
|
export interface CmsFieldMeta {
|
|
|
|
name: string;
|
|
|
|
label: string;
|
|
|
|
widget: string;
|
|
|
|
required: boolean;
|
|
|
|
index_file: string;
|
|
|
|
meta: boolean;
|
|
|
|
}
|
|
|
|
|
2020-11-30 09:04:25 -05:00
|
|
|
export type CmsField = CmsFieldBase &
|
|
|
|
(
|
2020-11-30 19:53:15 +03:00
|
|
|
| CmsFieldBoolean
|
2020-11-30 09:04:25 -05:00
|
|
|
| CmsFieldCode
|
2020-11-30 19:53:15 +03:00
|
|
|
| CmsFieldColor
|
2020-11-30 09:04:25 -05:00
|
|
|
| CmsFieldDateTime
|
|
|
|
| CmsFieldFileOrImage
|
|
|
|
| CmsFieldList
|
|
|
|
| CmsFieldMap
|
|
|
|
| CmsFieldMarkdown
|
|
|
|
| CmsFieldNumber
|
|
|
|
| CmsFieldObject
|
|
|
|
| CmsFieldRelation
|
|
|
|
| CmsFieldSelect
|
|
|
|
| CmsFieldHidden
|
|
|
|
| CmsFieldStringOrText
|
2021-02-14 18:41:02 +01:00
|
|
|
| CmsFieldMeta
|
2020-11-30 09:04:25 -05:00
|
|
|
);
|
|
|
|
|
2019-12-02 12:04:07 +01:00
|
|
|
export interface CmsCollectionFile {
|
|
|
|
name: string;
|
|
|
|
label: string;
|
|
|
|
file: string;
|
|
|
|
fields: CmsField[];
|
|
|
|
label_singular?: string;
|
|
|
|
description?: string;
|
2021-02-14 18:41:02 +01:00
|
|
|
preview_path?: string;
|
|
|
|
preview_path_date_field?: string;
|
|
|
|
i18n?: boolean | CmsI18nConfig;
|
|
|
|
media_folder?: string;
|
|
|
|
public_folder?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ViewFilter {
|
|
|
|
label: string;
|
|
|
|
field: string;
|
|
|
|
pattern: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ViewGroup {
|
|
|
|
label: string;
|
|
|
|
field: string;
|
2021-02-22 01:44:44 -06:00
|
|
|
pattern?: string;
|
2019-12-02 12:04:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface CmsCollection {
|
|
|
|
name: string;
|
2022-09-20 11:07:57 -04:00
|
|
|
icon?: string;
|
2019-12-02 12:04:07 +01:00
|
|
|
label: string;
|
|
|
|
label_singular?: string;
|
|
|
|
description?: string;
|
|
|
|
folder?: string;
|
|
|
|
files?: CmsCollectionFile[];
|
|
|
|
identifier_field?: string;
|
|
|
|
summary?: string;
|
|
|
|
slug?: string;
|
|
|
|
preview_path?: string;
|
|
|
|
preview_path_date_field?: string;
|
|
|
|
create?: boolean;
|
2020-06-01 09:42:11 +02:00
|
|
|
delete?: boolean;
|
2021-05-30 14:12:47 +02:00
|
|
|
hide?: boolean;
|
2019-12-02 12:04:07 +01:00
|
|
|
editor?: {
|
|
|
|
preview?: boolean;
|
|
|
|
};
|
2021-02-14 18:41:02 +01:00
|
|
|
publish?: boolean;
|
|
|
|
nested?: {
|
|
|
|
depth: number;
|
|
|
|
};
|
|
|
|
meta?: { path?: { label: string; widget: string; index_file: string } };
|
2020-06-01 09:42:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* It accepts the following values: yml, yaml, toml, json, md, markdown, html
|
|
|
|
*
|
|
|
|
* You may also specify a custom extension not included in the list above, by specifying the format value.
|
|
|
|
*/
|
|
|
|
extension?: string;
|
2019-12-02 12:04:07 +01:00
|
|
|
format?: CmsCollectionFormatType;
|
2020-06-01 09:42:11 +02:00
|
|
|
|
2019-12-02 12:04:07 +01:00
|
|
|
frontmatter_delimiter?: string[] | string;
|
|
|
|
fields?: CmsField[];
|
2020-06-01 09:42:11 +02:00
|
|
|
filter?: { field: string; value: any };
|
|
|
|
path?: string;
|
|
|
|
media_folder?: string;
|
|
|
|
public_folder?: string;
|
2020-08-31 19:25:48 +08:00
|
|
|
sortable_fields?: string[];
|
2021-02-14 18:41:02 +01:00
|
|
|
view_filters?: ViewFilter[];
|
|
|
|
view_groups?: ViewGroup[];
|
2020-11-30 05:41:07 -05:00
|
|
|
i18n?: boolean | CmsI18nConfig;
|
2020-08-31 19:25:48 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated Use sortable_fields instead
|
|
|
|
*/
|
2020-06-01 09:42:11 +02:00
|
|
|
sortableFields?: string[];
|
2019-12-02 12:04:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface CmsBackend {
|
|
|
|
name: CmsBackendType;
|
|
|
|
auth_scope?: CmsAuthScope;
|
|
|
|
open_authoring?: boolean;
|
2021-06-10 18:47:40 +02:00
|
|
|
always_fork?: boolean;
|
2020-04-29 11:52:01 -04:00
|
|
|
repo?: string;
|
|
|
|
branch?: string;
|
|
|
|
api_root?: string;
|
|
|
|
site_domain?: string;
|
|
|
|
base_url?: string;
|
|
|
|
auth_endpoint?: string;
|
2022-01-03 11:01:04 +01:00
|
|
|
app_id?: string;
|
2021-11-15 14:01:35 +01:00
|
|
|
auth_type?: 'implicit' | 'pkce';
|
2020-09-06 20:13:46 +02:00
|
|
|
cms_label_prefix?: string;
|
2020-11-30 05:41:07 -05:00
|
|
|
squash_merges?: boolean;
|
2021-02-14 18:41:02 +01:00
|
|
|
proxy_url?: string;
|
2021-03-11 12:08:46 +02:00
|
|
|
commit_messages?: {
|
|
|
|
create?: string;
|
|
|
|
update?: string;
|
|
|
|
delete?: string;
|
|
|
|
uploadMedia?: string;
|
|
|
|
deleteMedia?: string;
|
|
|
|
openAuthoring?: string;
|
|
|
|
};
|
2019-12-02 12:04:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface CmsSlug {
|
|
|
|
encoding?: CmsSlugEncoding;
|
|
|
|
clean_accents?: boolean;
|
2021-02-14 18:41:02 +01:00
|
|
|
sanitize_replacement?: string;
|
2019-12-02 12:04:07 +01:00
|
|
|
}
|
|
|
|
|
2020-11-30 13:25:29 +01:00
|
|
|
export interface CmsLocalBackend {
|
|
|
|
url?: string;
|
|
|
|
allowed_hosts?: string[];
|
|
|
|
}
|
|
|
|
|
2019-12-02 12:04:07 +01:00
|
|
|
export interface CmsConfig {
|
|
|
|
backend: CmsBackend;
|
|
|
|
collections: CmsCollection[];
|
|
|
|
locale?: string;
|
|
|
|
site_url?: string;
|
|
|
|
display_url?: string;
|
|
|
|
logo_url?: string;
|
|
|
|
show_preview_links?: boolean;
|
|
|
|
media_folder?: string;
|
|
|
|
public_folder?: string;
|
|
|
|
media_folder_relative?: boolean;
|
|
|
|
media_library?: CmsMediaLibrary;
|
|
|
|
publish_mode?: CmsPublishMode;
|
2021-02-14 18:41:02 +01:00
|
|
|
load_config_file?: boolean;
|
2021-03-11 12:08:46 +02:00
|
|
|
integrations?: {
|
|
|
|
hooks: string[];
|
|
|
|
provider: string;
|
|
|
|
collections?: '*' | string[];
|
|
|
|
applicationID?: string;
|
|
|
|
apiKey?: string;
|
|
|
|
getSignedFormURL?: string;
|
|
|
|
}[];
|
2019-12-02 12:04:07 +01:00
|
|
|
slug?: CmsSlug;
|
2020-11-30 05:41:07 -05:00
|
|
|
i18n?: CmsI18nConfig;
|
2020-11-30 13:25:29 +01:00
|
|
|
local_backend?: boolean | CmsLocalBackend;
|
2021-02-14 18:41:02 +01:00
|
|
|
editor?: {
|
|
|
|
preview?: boolean;
|
|
|
|
};
|
2019-12-02 12:04:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface InitOptions {
|
|
|
|
config: CmsConfig;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface EditorComponentField {
|
|
|
|
name: string;
|
|
|
|
label: string;
|
|
|
|
widget: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface EditorComponentOptions {
|
|
|
|
id: string;
|
|
|
|
label: string;
|
|
|
|
fields: EditorComponentField[];
|
|
|
|
pattern: RegExp;
|
2020-08-04 05:30:25 -04:00
|
|
|
allow_add?: boolean;
|
2020-06-01 09:42:11 +02:00
|
|
|
fromBlock: (match: RegExpMatchArray) => any;
|
|
|
|
toBlock: (data: any) => string;
|
|
|
|
toPreview: (data: any) => string;
|
2019-12-02 12:04:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface PreviewStyleOptions {
|
|
|
|
raw: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface PreviewStyle extends PreviewStyleOptions {
|
|
|
|
value: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type CmsBackendClass = any; // TODO: type properly
|
|
|
|
|
|
|
|
export interface CmsRegistryBackend {
|
|
|
|
init: (args: any) => CmsBackendClass;
|
|
|
|
}
|
|
|
|
|
2021-03-30 16:31:23 +02:00
|
|
|
export interface CmsWidgetControlProps<T = any> {
|
|
|
|
value: T;
|
|
|
|
field: Map<string, any>;
|
|
|
|
onChange: (value: T) => void;
|
|
|
|
forID: string;
|
|
|
|
classNameWrapper: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface CmsWidgetPreviewProps<T = any> {
|
|
|
|
value: T;
|
|
|
|
field: Map<string, any>;
|
|
|
|
metadata: Map<string, any>;
|
|
|
|
getAsset: GetAssetFunction;
|
|
|
|
entry: Map<string, any>;
|
|
|
|
fieldsMetaData: Map<string, any>;
|
|
|
|
}
|
|
|
|
|
2021-12-07 20:50:22 +08:00
|
|
|
export interface CmsWidgetParam<T = any> {
|
2019-12-02 12:04:07 +01:00
|
|
|
name: string;
|
2021-12-07 20:50:22 +08:00
|
|
|
controlComponent: CmsWidgetControlProps<T>;
|
|
|
|
previewComponent?: CmsWidgetPreviewProps<T>;
|
2021-02-23 18:34:23 +09:00
|
|
|
globalStyles?: any;
|
2019-12-02 12:04:07 +01:00
|
|
|
}
|
|
|
|
|
2021-12-07 20:50:22 +08:00
|
|
|
export interface CmsWidget<T = any> {
|
|
|
|
control: CmsWidgetControlProps<T>;
|
|
|
|
preview?: CmsWidgetPreviewProps<T>;
|
2019-12-02 12:04:07 +01:00
|
|
|
globalStyles?: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type CmsWidgetValueSerializer = any; // TODO: type properly
|
|
|
|
|
|
|
|
export type CmsMediaLibraryOptions = any; // TODO: type properly
|
|
|
|
|
|
|
|
export interface CmsMediaLibrary {
|
|
|
|
name: string;
|
|
|
|
config?: CmsMediaLibraryOptions;
|
|
|
|
}
|
|
|
|
|
2021-01-05 04:41:13 -08:00
|
|
|
export interface CmsEventListener {
|
|
|
|
name: 'prePublish' | 'postPublish' | 'preUnpublish' | 'postUnpublish' | 'preSave' | 'postSave';
|
2021-05-10 01:11:04 -07:00
|
|
|
handler: ({
|
|
|
|
entry,
|
|
|
|
author,
|
|
|
|
}: {
|
|
|
|
entry: Map<string, any>;
|
|
|
|
author: { login: string; name: string };
|
|
|
|
}) => any;
|
2021-01-05 04:41:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
export type CmsEventListenerOptions = any; // TODO: type properly
|
|
|
|
|
2019-12-02 12:04:07 +01:00
|
|
|
export type CmsLocalePhrases = any; // TODO: type properly
|
|
|
|
|
|
|
|
export interface CmsRegistry {
|
|
|
|
backends: {
|
|
|
|
[name: string]: CmsRegistryBackend;
|
|
|
|
};
|
|
|
|
templates: {
|
2020-04-20 15:15:04 +02:00
|
|
|
[name: string]: ComponentType<any>;
|
2019-12-02 12:04:07 +01:00
|
|
|
};
|
|
|
|
previewStyles: PreviewStyle[];
|
|
|
|
widgets: {
|
|
|
|
[name: string]: CmsWidget;
|
|
|
|
};
|
2020-04-20 15:15:04 +02:00
|
|
|
editorComponents: Map<string, ComponentType<any>>;
|
2019-12-02 12:04:07 +01:00
|
|
|
widgetValueSerializers: {
|
|
|
|
[name: string]: CmsWidgetValueSerializer;
|
|
|
|
};
|
|
|
|
mediaLibraries: CmsMediaLibrary[];
|
|
|
|
locales: {
|
|
|
|
[name: string]: CmsLocalePhrases;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-19 14:39:35 +02:00
|
|
|
type GetAssetFunction = (asset: string) => {
|
|
|
|
url: string;
|
|
|
|
path: string;
|
|
|
|
field?: any;
|
|
|
|
fileObj: File;
|
|
|
|
};
|
2020-06-01 09:42:11 +02:00
|
|
|
|
|
|
|
export type PreviewTemplateComponentProps = {
|
|
|
|
entry: Map<string, any>;
|
|
|
|
collection: Map<string, any>;
|
|
|
|
widgetFor: (name: any, fields?: any, values?: any, fieldsMetaData?: any) => JSX.Element | null;
|
|
|
|
widgetsFor: (name: any) => any;
|
|
|
|
getAsset: GetAssetFunction;
|
|
|
|
boundGetAsset: (collection: any, path: any) => GetAssetFunction;
|
|
|
|
fieldsMetaData: Map<string, any>;
|
|
|
|
config: Map<string, any>;
|
|
|
|
fields: List<Map<string, any>>;
|
|
|
|
isLoadingAsset: boolean;
|
2021-05-30 16:09:48 +02:00
|
|
|
window: Window;
|
|
|
|
document: Document;
|
2020-06-01 09:42:11 +02:00
|
|
|
};
|
|
|
|
|
2019-12-02 12:04:07 +01:00
|
|
|
export interface CMS {
|
|
|
|
getBackend: (name: string) => CmsRegistryBackend | undefined;
|
2020-04-20 15:15:04 +02:00
|
|
|
getEditorComponents: () => Map<string, ComponentType<any>>;
|
2021-07-25 15:03:35 +02:00
|
|
|
getRemarkPlugins: () => Array<Pluggable>;
|
2019-12-02 12:04:07 +01:00
|
|
|
getLocale: (locale: string) => CmsLocalePhrases | undefined;
|
|
|
|
getMediaLibrary: (name: string) => CmsMediaLibrary | undefined;
|
2022-09-07 22:57:18 -04:00
|
|
|
resolveWidget: (name: string) => CmsWidget | undefined;
|
2019-12-02 12:04:07 +01:00
|
|
|
getPreviewStyles: () => PreviewStyle[];
|
2020-06-01 09:42:11 +02:00
|
|
|
getPreviewTemplate: (name: string) => ComponentType<PreviewTemplateComponentProps> | undefined;
|
2019-12-02 12:04:07 +01:00
|
|
|
getWidget: (name: string) => CmsWidget | undefined;
|
|
|
|
getWidgetValueSerializer: (widgetName: string) => CmsWidgetValueSerializer | undefined;
|
|
|
|
init: (options?: InitOptions) => void;
|
|
|
|
registerBackend: (name: string, backendClass: CmsBackendClass) => void;
|
|
|
|
registerEditorComponent: (options: EditorComponentOptions) => void;
|
2021-07-25 15:03:35 +02:00
|
|
|
registerRemarkPlugin: (plugin: Pluggable) => void;
|
2021-01-05 04:41:13 -08:00
|
|
|
registerEventListener: (
|
|
|
|
eventListener: CmsEventListener,
|
2021-05-30 14:11:28 +02:00
|
|
|
options?: CmsEventListenerOptions,
|
2021-01-05 04:41:13 -08:00
|
|
|
) => void;
|
2019-12-02 12:04:07 +01:00
|
|
|
registerLocale: (locale: string, phrases: CmsLocalePhrases) => void;
|
|
|
|
registerMediaLibrary: (mediaLibrary: CmsMediaLibrary, options?: CmsMediaLibraryOptions) => void;
|
|
|
|
registerPreviewStyle: (filePath: string, options?: PreviewStyleOptions) => void;
|
2020-06-01 09:42:11 +02:00
|
|
|
registerPreviewTemplate: (
|
|
|
|
name: string,
|
|
|
|
component: ComponentType<PreviewTemplateComponentProps>,
|
|
|
|
) => void;
|
2019-12-18 18:16:02 +02:00
|
|
|
registerWidget: (
|
|
|
|
widget: string | CmsWidgetParam,
|
2021-03-30 16:31:23 +02:00
|
|
|
control?: ComponentType<CmsWidgetControlProps> | string,
|
|
|
|
preview?: ComponentType<CmsWidgetPreviewProps>,
|
2019-12-18 18:16:02 +02:00
|
|
|
) => void;
|
|
|
|
registerWidgetValueSerializer: (
|
|
|
|
widgetName: string,
|
|
|
|
serializer: CmsWidgetValueSerializer,
|
|
|
|
) => void;
|
2022-09-20 10:14:40 -04:00
|
|
|
registerIcon: (iconName: string, icon: ReactNode) => void;
|
|
|
|
getIcon: (iconName: string) => ReactNode;
|
2022-09-20 10:46:59 -04:00
|
|
|
registerAdditionalLink: (id: string, title: string, link: string, iconName?: string) => void;
|
2022-09-20 10:14:40 -04:00
|
|
|
getAdditionalLinks: () => { title: string, link: string, iconName?: string }[];
|
2019-12-02 12:04:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export const NetlifyCmsCore: CMS;
|
|
|
|
|
|
|
|
export default NetlifyCmsCore;
|
2019-12-18 18:16:02 +02:00
|
|
|
}
|