chore(tooling): add husky and lint-staged

This commit is contained in:
Michael Zetterberg
2024-03-26 13:12:21 +01:00
parent 083c57d0ca
commit e65df3eb97
14 changed files with 828 additions and 206 deletions

View File

@@ -10,20 +10,20 @@
declare global {
interface Window {
ImageVault: {
InsertMediaWindow: typeof InsertMediaWindow;
};
iframeRef: HTMLElement | null;
InsertMediaWindow: typeof InsertMediaWindow
}
iframeRef: HTMLElement | null
}
}
export declare class InsertMediaWindow {
constructor(config: Config, windowOptions: string);
openImageVault: () => void;
containerWindow: Window | null;
constructor(config: Config, windowOptions: string)
openImageVault: () => void
containerWindow: Window | null
}
export interface IInsertSuccessCallback {
(message: InsertSuccessMessageEvent): void;
(message: InsertSuccessMessageEvent): void
}
/**
@@ -33,33 +33,33 @@ export interface InsertSuccessMessageEvent extends MessageEvent {
/**
* The response from the ImageVault insert operation
*/
data: string;
data: string
/**
* The response from the ImageVault insert operation
*/
response: InsertResponse;
response: InsertResponse
}
export type MetaData = {
DefinitionType?: number;
Description: string | null;
LanguageId: null;
MetadataDefinitionId: number;
Name: string;
Value: string;
};
DefinitionType?: number
Description: string | null
LanguageId: null
MetadataDefinitionId: number
Name: string
Value: string
}
export type ImageVaultAsset = {
id: number;
title: string;
url: string;
id: number
title: string
url: string
dimensions: {
width: number;
height: number;
aspectRatio: number;
};
meta: { alt: string | undefined; caption: string | undefined };
};
width: number
height: number
aspectRatio: number
}
meta: { alt: string | undefined; caption: string | undefined }
}
/**
* The response from ImageVault when inserting an asset
@@ -68,29 +68,29 @@ export declare class InsertResponse {
/**
* The media item id of the asset
*/
Id: number;
Id: number
/**
* The id of the vault where the asset resides
*/
VaultId: number;
VaultId: number
/**
* The name of the asset
*/
Name: string;
Name: string
/**
* The conversion selected by the user. Is an array but will only contain one object
*/
MediaConversions: MediaConversion[];
MediaConversions: MediaConversion[]
/**
* Date when the asset was added to ImageVault
*/
DateAdded: string;
DateAdded: string
/**
* Name of the user that added the asset to ImageVault
*/
AddedBy: string;
AddedBy: string
Metadata?: MetaData[] | undefined;
Metadata?: MetaData[] | undefined
}
/**
@@ -100,51 +100,51 @@ export declare class MediaConversion {
/**
* The url to the conversion
*/
Url: string;
Url: string
/**
* Name of the conversion
*/
Name: string;
Name: string
/**
* Html representing the conversion
*/
Html: string;
Html: string
/**
* Content type of the conversion
*/
ContentType: string;
ContentType: string
/**
* Width, in pixels, of the conversion
*/
Width: number;
Width: number
/**
* Height, in pixels, of the conversion
*/
Height: number;
Height: number
/**
* Aspect ratio of the conversion
*/
AspectRatio: number;
AspectRatio: number
/**
* Width of the selected/requested format
*/
FormatWidth: number;
FormatWidth: number
/**
* Height of the selected/requested format
*/
FormatHeight: number;
FormatHeight: number
/**
* Aspect ratio of the selected/requested format
*/
FormatAspectRatio: number;
FormatAspectRatio: number
/**
* Name of the media format
*/
MediaFormatName: string;
MediaFormatName: string
/**
* Id of the selected media format
*/
MediaFormatId: number;
MediaFormatId: number
}
/**
* Defines where an ImageVault asset is used when requesting it
@@ -153,15 +153,15 @@ export declare class PublishDetails {
/**
* The textual description on where an asset is used
*/
text: string;
text: string
/**
* The url to where the asset is used
*/
url: string;
url: string
/**
* An optional id for grouping usage
*/
groupId?: string;
groupId?: string
}
/**
@@ -171,73 +171,73 @@ export declare class Config {
/**
* The url to the ImageVault ui that should be used
*/
imageVaultUiUrl: string;
imageVaultUiUrl: string
/**
* [Optional] Origin where the insert function is launched from. Is normally calculated and does not need to be supplied.
*/
origin?: string;
origin?: string
/**
* The language that the ImageVault ui should be displayed in
*/
uiLang: string;
uiLang: string
/**
* [Optional] The language for the default content in ImageVault
*/
pageLang?: string;
pageLang?: string
/**
* The publishingSource where the image should be used. Normally the url for the site.
*/
publishingSource: string;
publishingSource: string
/**
* If it should be possible to select multiple assets from ImageVault. Default is false.
*/
insertMultiple: boolean;
insertMultiple: boolean
/**
* The url base that the media assets should use. Supply the url to a cdn.
*/
mediaUrlBase: string;
mediaUrlBase: string
/**
* The ids of the formats that the selection should result in.
*/
formatId: string;
formatId: string
/**
* [Optional] The comma-separated id-list of additional metadata definitions that the selection should result in.
*/
additionalMetadataIds?: string;
additionalMetadataIds?: string
/**
* The publishDetails to use. If supplied, published urls are returned.
*/
publishDetails?: PublishDetails;
publishDetails?: PublishDetails
/**
* Function that is invoked when the user insert items from ImageVault
*/
success: IInsertSuccessCallback;
success: IInsertSuccessCallback
/**
* This function is called when the Insert window should be closed
*/
close: (result: unknown) => void;
close: (result: unknown) => void
/**
* [Optional] This function is called whenever an error is encountered
*/
error?: (result: unknown, errorMessage: string) => void;
error?: (result: unknown, errorMessage: string) => void
/**
* [Optional] Listen on this method for debug messages
*/
debug?: (result: unknown) => void;
debug?: (result: unknown) => void
/**
* [Optional] Set media url to edit existing media
*/
mediaUrl?: string;
mediaUrl?: string
/**
* [Optional] Set media id to show specific media
*/
mediaId?: number;
mediaId?: number
/**
* [Optional]
* @0 (Default) Insert with format or choose format from dropdown in ImageVault UI
* @1 Same as 0 (default) except that you can edit media in editor before insert
*/
insertMode?: number;
insertMode?: number
}