@frontmatter/extensibility
Advanced tools
Comparing version 0.0.2 to 0.0.3
declare global { | ||
interface Window { | ||
fmExternal: { | ||
getCardFooter: (filePath: string, data: any) => Promise<string>; | ||
getCustomFields: { | ||
name: string; | ||
html: (data: any, change: (value: any) => void) => Promise<{ | ||
title: string; | ||
content: string; | ||
} | undefined>; | ||
}[]; | ||
getPanelView: (data: any) => Promise<PanelViewResult | undefined>; | ||
getCardImage: (filePath: string, data: any) => Promise<string | undefined>; | ||
getCardFooter: (filePath: string, data: any) => Promise<string | undefined>; | ||
}; | ||
} | ||
} | ||
export declare const registerCardFooter: (cb: (filePath: string, data: any) => Promise<string>) => void; | ||
export interface PanelViewResult { | ||
title: string; | ||
content: string; | ||
} | ||
/** | ||
* Register a card image renderer | ||
* @param cb | ||
*/ | ||
export declare const registerCardImage: (cb: (filePath: string, metadata: any) => Promise<string>) => void; | ||
/** | ||
* Register a card footer renderer | ||
* @param cb | ||
*/ | ||
export declare const registerCardFooter: (cb: (filePath: string, metadata: any) => Promise<string>) => void; | ||
/** | ||
* Register a panel view renderer | ||
* @param cb | ||
*/ | ||
export declare const registerPanelView: (cb: (metadata: any) => Promise<PanelViewResult | undefined>) => void; | ||
/** | ||
* Register a custom field | ||
* @param name | ||
* @param cb | ||
*/ | ||
export declare const registerCustomFields: (name: string, cb: any) => void; |
@@ -0,1 +1,14 @@ | ||
// Dashboard | ||
/** | ||
* Register a card image renderer | ||
* @param cb | ||
*/ | ||
export const registerCardImage = (cb) => { | ||
window.fmExternal = window.fmExternal || {}; | ||
window.fmExternal.getCardImage = cb; | ||
}; | ||
/** | ||
* Register a card footer renderer | ||
* @param cb | ||
*/ | ||
export const registerCardFooter = (cb) => { | ||
@@ -5,2 +18,27 @@ window.fmExternal = window.fmExternal || {}; | ||
}; | ||
// Panel | ||
/** | ||
* Register a panel view renderer | ||
* @param cb | ||
*/ | ||
export const registerPanelView = (cb) => { | ||
window.fmExternal = window.fmExternal || {}; | ||
window.fmExternal.getPanelView = cb; | ||
}; | ||
/** | ||
* Register a custom field | ||
* @param name | ||
* @param cb | ||
*/ | ||
export const registerCustomFields = (name, cb) => { | ||
window.fmExternal = window.fmExternal || {}; | ||
window.fmExternal.getCustomFields = window.fmExternal.getCustomFields || []; | ||
const fieldRef = window.fmExternal.getCustomFields.find((x) => x.name === name); | ||
if (fieldRef) { | ||
fieldRef.html = cb; | ||
} | ||
else { | ||
window.fmExternal.getCustomFields.push({ name, html: cb }); | ||
} | ||
}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@frontmatter/extensibility", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Front Matter CMS extensibility library", | ||
@@ -5,0 +5,0 @@ "type": "module", |
declare global { | ||
interface Window { | ||
fmExternal: { | ||
getCardFooter: (filePath: string, data: any) => Promise<string>; | ||
getCustomFields: { | ||
name: string; | ||
html: ( | ||
data: any, | ||
change: (value: any) => void | ||
) => Promise<{ title: string; content: string } | undefined>; | ||
}[]; | ||
getPanelView: (data: any) => Promise<PanelViewResult | undefined>; | ||
getCardImage: ( | ||
filePath: string, | ||
data: any | ||
) => Promise<string | undefined>; | ||
getCardFooter: ( | ||
filePath: string, | ||
data: any | ||
) => Promise<string | undefined>; | ||
}; | ||
@@ -9,4 +24,29 @@ } | ||
// Interfaces | ||
export interface PanelViewResult { | ||
title: string; | ||
content: string; | ||
} | ||
// Dashboard | ||
/** | ||
* Register a card image renderer | ||
* @param cb | ||
*/ | ||
export const registerCardImage = ( | ||
cb: (filePath: string, metadata: any) => Promise<string> | ||
) => { | ||
window.fmExternal = window.fmExternal || {}; | ||
window.fmExternal.getCardImage = cb; | ||
}; | ||
/** | ||
* Register a card footer renderer | ||
* @param cb | ||
*/ | ||
export const registerCardFooter = ( | ||
cb: (filePath: string, data: any) => Promise<string> | ||
cb: (filePath: string, metadata: any) => Promise<string> | ||
) => { | ||
@@ -17,1 +57,34 @@ window.fmExternal = window.fmExternal || {}; | ||
}; | ||
// Panel | ||
/** | ||
* Register a panel view renderer | ||
* @param cb | ||
*/ | ||
export const registerPanelView = ( | ||
cb: (metadata: any) => Promise<PanelViewResult | undefined> | ||
) => { | ||
window.fmExternal = window.fmExternal || {}; | ||
window.fmExternal.getPanelView = cb; | ||
}; | ||
/** | ||
* Register a custom field | ||
* @param name | ||
* @param cb | ||
*/ | ||
export const registerCustomFields = (name: string, cb: any) => { | ||
window.fmExternal = window.fmExternal || {}; | ||
window.fmExternal.getCustomFields = window.fmExternal.getCustomFields || []; | ||
const fieldRef = window.fmExternal.getCustomFields.find( | ||
(x) => x.name === name | ||
); | ||
if (fieldRef) { | ||
fieldRef.html = cb; | ||
} else { | ||
window.fmExternal.getCustomFields.push({ name, html: cb }); | ||
} | ||
}; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7726
159