@allejo/decap-extras 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ All factory functions follow the same signature: `widget(label, name, options?)`
|
|
|
35
35
|
|
|
36
36
|
```ts
|
|
37
37
|
import {
|
|
38
|
-
|
|
38
|
+
RICH_MARKDOWN,
|
|
39
39
|
boolWidget,
|
|
40
40
|
imageWidget,
|
|
41
41
|
INLINE_MARKDOWN,
|
|
@@ -113,7 +113,7 @@ const contentField = markdownWidget('Content', 'content');
|
|
|
113
113
|
const descriptionField = markdownWidget(
|
|
114
114
|
'Description',
|
|
115
115
|
'description',
|
|
116
|
-
|
|
116
|
+
RICH_MARKDOWN,
|
|
117
117
|
);
|
|
118
118
|
|
|
119
119
|
// Inline elements only: bold, italic, and links
|
|
@@ -148,7 +148,7 @@ Define your CMS config using the widget factories and `as const`, then let `Prop
|
|
|
148
148
|
```ts
|
|
149
149
|
// cms/config.ts
|
|
150
150
|
import {
|
|
151
|
-
|
|
151
|
+
RICH_MARKDOWN,
|
|
152
152
|
boolWidget,
|
|
153
153
|
imageWidget,
|
|
154
154
|
markdownWidget,
|
|
@@ -172,7 +172,7 @@ export const config = {
|
|
|
172
172
|
stringWidget('Title', 'title'),
|
|
173
173
|
optional(stringWidget('Subtitle', 'subtitle')),
|
|
174
174
|
imageWidget('Hero Image', 'hero'),
|
|
175
|
-
markdownWidget('Body', 'body',
|
|
175
|
+
markdownWidget('Body', 'body', RICH_MARKDOWN),
|
|
176
176
|
selectWidget('Theme', 'theme', ['light', 'dark'] as const),
|
|
177
177
|
objectWidget('SEO', 'seo', [
|
|
178
178
|
stringWidget('Meta Title', 'metaTitle'),
|
|
@@ -472,7 +472,7 @@ export default function Admin({ cssFiles }: Props) {
|
|
|
472
472
|
|
|
473
473
|
| Constant | Description |
|
|
474
474
|
| ----------------- | ------------------------------------------------------------- |
|
|
475
|
-
| `
|
|
475
|
+
| `RICH_MARKDOWN` | Bold, italic, lists, links, quotes. No images or code blocks. |
|
|
476
476
|
| `INLINE_MARKDOWN` | Bold, italic, and links only. No block-level elements. |
|
|
477
477
|
|
|
478
478
|
### Type utilities
|
package/dist/index.d.mts
CHANGED
|
@@ -325,12 +325,12 @@ declare function textWidget<T extends string>(label: string, name: T, options?:
|
|
|
325
325
|
* - No images or code block components
|
|
326
326
|
* - Rich Text preview only
|
|
327
327
|
*/
|
|
328
|
-
declare const
|
|
328
|
+
declare const RICH_MARKDOWN: WidgetOpts<CmsFieldMarkdown>;
|
|
329
329
|
/**
|
|
330
330
|
* Stripped down Markdown Widget configuration that allows only inline
|
|
331
331
|
* elements (e.g., no lists, quotes, or headings) and rich text preview only.
|
|
332
332
|
*/
|
|
333
333
|
declare const INLINE_MARKDOWN: WidgetOpts<CmsFieldMarkdown>;
|
|
334
334
|
//#endregion
|
|
335
|
-
export {
|
|
335
|
+
export { CollectionItemNames, INLINE_MARKDOWN, OptionalWidget, PropsByCollectionAndFile, RICH_MARKDOWN, WidgetOpts, WidgetTypeFromFactory, boolWidget, imageWidget, listWidget, markdownWidget, numberWidget, objectWidget, optional, selectWidget, stringWidget, textWidget };
|
|
336
336
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -88,7 +88,7 @@ function textWidget(label, name, options) {
|
|
|
88
88
|
* - No images or code block components
|
|
89
89
|
* - Rich Text preview only
|
|
90
90
|
*/
|
|
91
|
-
const
|
|
91
|
+
const RICH_MARKDOWN = {
|
|
92
92
|
buttons: [
|
|
93
93
|
"bold",
|
|
94
94
|
"bulleted-list",
|
|
@@ -115,5 +115,5 @@ const INLINE_MARKDOWN = {
|
|
|
115
115
|
};
|
|
116
116
|
|
|
117
117
|
//#endregion
|
|
118
|
-
export {
|
|
118
|
+
export { INLINE_MARKDOWN, RICH_MARKDOWN, boolWidget, imageWidget, listWidget, markdownWidget, numberWidget, objectWidget, optional, selectWidget, stringWidget, textWidget };
|
|
119
119
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/widgets.ts"],"sourcesContent":["import type {\n\tCmsField,\n\tCmsFieldBoolean,\n\tCmsFieldFileOrImage,\n\tCmsFieldList,\n\tCmsFieldMarkdown,\n\tCmsFieldNumber,\n\tCmsFieldObject,\n\tCmsFieldSelect,\n\tCmsFieldStringOrText,\n} from 'decap-cms-core';\n\nimport type { OptionalWidget, WidgetOpts } from './api.js';\n\n// Widget Modifiers\n\nexport function optional<T extends CmsField>(widget: T): OptionalWidget<T> {\n\treturn {\n\t\t...widget,\n\t\trequired: false as const,\n\t\t__optional: true as const,\n\t};\n}\n\n// Primitive Widgets\n\nexport function boolWidget<T extends string>(\n\tlabel: string,\n\tname: T,\n\toptions?: WidgetOpts<CmsFieldBoolean>,\n) {\n\treturn {\n\t\tlabel,\n\t\tname,\n\t\twidget: 'boolean',\n\t\t...(options ?? {}),\n\t} as const satisfies CmsField;\n}\n\nexport function imageWidget<T extends string>(\n\tlabel: string,\n\tname: T,\n\toptions?: WidgetOpts<CmsFieldFileOrImage>,\n) {\n\treturn {\n\t\tlabel,\n\t\tname,\n\t\twidget: 'image',\n\t\t...(options ?? {}),\n\t} as const satisfies CmsField;\n}\n\nexport function listWidget<T extends string, F extends CmsField>(\n\tlabel: string,\n\tname: T,\n\tfields: F,\n\toptions?: WidgetOpts<CmsFieldList>,\n): { label: string; name: T; widget: 'list'; field: F };\nexport function listWidget<T extends string, F extends CmsField[]>(\n\tlabel: string,\n\tname: T,\n\tfields: F,\n\toptions?: WidgetOpts<CmsFieldList>,\n): { label: string; name: T; widget: 'list'; fields: F };\nexport function listWidget<T extends string, F extends CmsField | CmsField[]>(\n\tlabel: string,\n\tname: T,\n\tfields: F,\n\toptions?: WidgetOpts<CmsFieldList>,\n) {\n\treturn {\n\t\tlabel,\n\t\tname,\n\t\twidget: 'list',\n\t\t...(options ?? {}),\n\t\t...(Array.isArray(fields) ? { fields } : { field: fields }),\n\t} as const;\n}\n\nexport function markdownWidget<T extends string>(\n\tlabel: string,\n\tname: T,\n\toptions?: WidgetOpts<CmsFieldMarkdown>,\n) {\n\treturn {\n\t\tlabel,\n\t\tname,\n\t\twidget: 'richtext' as 'string',\n\t\t...(options ?? {}),\n\t} as const satisfies CmsField;\n}\n\nexport function objectWidget<T extends string, F extends CmsField[]>(\n\tlabel: string,\n\tname: T,\n\tfields: F,\n\toptions?: WidgetOpts<CmsFieldObject>,\n) {\n\treturn {\n\t\tlabel,\n\t\tname,\n\t\twidget: 'object',\n\t\t...(options ?? {}),\n\t\tfields,\n\t} as const satisfies CmsField;\n}\n\nexport function numberWidget<T extends string>(\n\tlabel: string,\n\tname: T,\n\toptions?: WidgetOpts<CmsFieldNumber>,\n) {\n\treturn {\n\t\tlabel,\n\t\tname,\n\t\twidget: 'number',\n\t\t...(options ?? {}),\n\t} as const satisfies CmsField;\n}\n\nexport function selectWidget<T extends string, O extends string[]>(\n\tlabel: string,\n\tname: T,\n\tchoices: O,\n\toptions?: WidgetOpts<CmsFieldSelect>,\n) {\n\treturn {\n\t\tlabel,\n\t\tname,\n\t\twidget: 'select',\n\t\t...(options ?? {}),\n\t\toptions: choices ?? [],\n\t} as const satisfies CmsField;\n}\n\nexport function stringWidget<T extends string>(\n\tlabel: string,\n\tname: T,\n\toptions?: WidgetOpts<CmsFieldStringOrText>,\n) {\n\treturn {\n\t\tlabel,\n\t\tname,\n\t\twidget: 'string',\n\t\t...(options ?? {}),\n\t} as const satisfies CmsField;\n}\n\nexport function textWidget<T extends string>(\n\tlabel: string,\n\tname: T,\n\toptions?: WidgetOpts<CmsFieldStringOrText>,\n) {\n\treturn {\n\t\tlabel,\n\t\tname,\n\t\twidget: 'text',\n\t\t...(options ?? {}),\n\t} as const satisfies CmsField;\n}\n\n// Reusable Widget Configurations\n\n/**\n * Stripped down Markdown widget configuration that does the following:\n *\n * - Allows bold, italic, lists (bullet + numbered), quotes\n * - No images or code block components\n * - Rich Text preview only\n */\nexport const
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/widgets.ts"],"sourcesContent":["import type {\n\tCmsField,\n\tCmsFieldBoolean,\n\tCmsFieldFileOrImage,\n\tCmsFieldList,\n\tCmsFieldMarkdown,\n\tCmsFieldNumber,\n\tCmsFieldObject,\n\tCmsFieldSelect,\n\tCmsFieldStringOrText,\n} from 'decap-cms-core';\n\nimport type { OptionalWidget, WidgetOpts } from './api.js';\n\n// Widget Modifiers\n\nexport function optional<T extends CmsField>(widget: T): OptionalWidget<T> {\n\treturn {\n\t\t...widget,\n\t\trequired: false as const,\n\t\t__optional: true as const,\n\t};\n}\n\n// Primitive Widgets\n\nexport function boolWidget<T extends string>(\n\tlabel: string,\n\tname: T,\n\toptions?: WidgetOpts<CmsFieldBoolean>,\n) {\n\treturn {\n\t\tlabel,\n\t\tname,\n\t\twidget: 'boolean',\n\t\t...(options ?? {}),\n\t} as const satisfies CmsField;\n}\n\nexport function imageWidget<T extends string>(\n\tlabel: string,\n\tname: T,\n\toptions?: WidgetOpts<CmsFieldFileOrImage>,\n) {\n\treturn {\n\t\tlabel,\n\t\tname,\n\t\twidget: 'image',\n\t\t...(options ?? {}),\n\t} as const satisfies CmsField;\n}\n\nexport function listWidget<T extends string, F extends CmsField>(\n\tlabel: string,\n\tname: T,\n\tfields: F,\n\toptions?: WidgetOpts<CmsFieldList>,\n): { label: string; name: T; widget: 'list'; field: F };\nexport function listWidget<T extends string, F extends CmsField[]>(\n\tlabel: string,\n\tname: T,\n\tfields: F,\n\toptions?: WidgetOpts<CmsFieldList>,\n): { label: string; name: T; widget: 'list'; fields: F };\nexport function listWidget<T extends string, F extends CmsField | CmsField[]>(\n\tlabel: string,\n\tname: T,\n\tfields: F,\n\toptions?: WidgetOpts<CmsFieldList>,\n) {\n\treturn {\n\t\tlabel,\n\t\tname,\n\t\twidget: 'list',\n\t\t...(options ?? {}),\n\t\t...(Array.isArray(fields) ? { fields } : { field: fields }),\n\t} as const;\n}\n\nexport function markdownWidget<T extends string>(\n\tlabel: string,\n\tname: T,\n\toptions?: WidgetOpts<CmsFieldMarkdown>,\n) {\n\treturn {\n\t\tlabel,\n\t\tname,\n\t\twidget: 'richtext' as 'string',\n\t\t...(options ?? {}),\n\t} as const satisfies CmsField;\n}\n\nexport function objectWidget<T extends string, F extends CmsField[]>(\n\tlabel: string,\n\tname: T,\n\tfields: F,\n\toptions?: WidgetOpts<CmsFieldObject>,\n) {\n\treturn {\n\t\tlabel,\n\t\tname,\n\t\twidget: 'object',\n\t\t...(options ?? {}),\n\t\tfields,\n\t} as const satisfies CmsField;\n}\n\nexport function numberWidget<T extends string>(\n\tlabel: string,\n\tname: T,\n\toptions?: WidgetOpts<CmsFieldNumber>,\n) {\n\treturn {\n\t\tlabel,\n\t\tname,\n\t\twidget: 'number',\n\t\t...(options ?? {}),\n\t} as const satisfies CmsField;\n}\n\nexport function selectWidget<T extends string, O extends string[]>(\n\tlabel: string,\n\tname: T,\n\tchoices: O,\n\toptions?: WidgetOpts<CmsFieldSelect>,\n) {\n\treturn {\n\t\tlabel,\n\t\tname,\n\t\twidget: 'select',\n\t\t...(options ?? {}),\n\t\toptions: choices ?? [],\n\t} as const satisfies CmsField;\n}\n\nexport function stringWidget<T extends string>(\n\tlabel: string,\n\tname: T,\n\toptions?: WidgetOpts<CmsFieldStringOrText>,\n) {\n\treturn {\n\t\tlabel,\n\t\tname,\n\t\twidget: 'string',\n\t\t...(options ?? {}),\n\t} as const satisfies CmsField;\n}\n\nexport function textWidget<T extends string>(\n\tlabel: string,\n\tname: T,\n\toptions?: WidgetOpts<CmsFieldStringOrText>,\n) {\n\treturn {\n\t\tlabel,\n\t\tname,\n\t\twidget: 'text',\n\t\t...(options ?? {}),\n\t} as const satisfies CmsField;\n}\n\n// Reusable Widget Configurations\n\n/**\n * Stripped down Markdown widget configuration that does the following:\n *\n * - Allows bold, italic, lists (bullet + numbered), quotes\n * - No images or code block components\n * - Rich Text preview only\n */\nexport const RICH_MARKDOWN: WidgetOpts<CmsFieldMarkdown> = {\n\tbuttons: [\n\t\t'bold',\n\t\t'bulleted-list',\n\t\t'italic',\n\t\t'link',\n\t\t'numbered-list',\n\t\t'quote',\n\t],\n\teditor_components: [],\n\tmodes: ['rich_text'],\n};\n\n/**\n * Stripped down Markdown Widget configuration that allows only inline\n * elements (e.g., no lists, quotes, or headings) and rich text preview only.\n */\nexport const INLINE_MARKDOWN: WidgetOpts<CmsFieldMarkdown> = {\n\tbuttons: ['bold', 'italic', 'link'],\n\teditor_components: [],\n\tmodes: ['rich_text'],\n};\n"],"mappings":";AAgBA,SAAgB,SAA6B,QAA8B;CAC1E,OAAO;EACN,GAAG;EACH,UAAU;EACV,YAAY;CACb;AACD;AAIA,SAAgB,WACf,OACA,MACA,SACC;CACD,OAAO;EACN;EACA;EACA,QAAQ;EACR,GAAI,WAAW,CAAC;CACjB;AACD;AAEA,SAAgB,YACf,OACA,MACA,SACC;CACD,OAAO;EACN;EACA;EACA,QAAQ;EACR,GAAI,WAAW,CAAC;CACjB;AACD;AAcA,SAAgB,WACf,OACA,MACA,QACA,SACC;CACD,OAAO;EACN;EACA;EACA,QAAQ;EACR,GAAI,WAAW,CAAC;EAChB,GAAI,MAAM,QAAQ,MAAM,IAAI,EAAE,OAAO,IAAI,EAAE,OAAO,OAAO;CAC1D;AACD;AAEA,SAAgB,eACf,OACA,MACA,SACC;CACD,OAAO;EACN;EACA;EACA,QAAQ;EACR,GAAI,WAAW,CAAC;CACjB;AACD;AAEA,SAAgB,aACf,OACA,MACA,QACA,SACC;CACD,OAAO;EACN;EACA;EACA,QAAQ;EACR,GAAI,WAAW,CAAC;EAChB;CACD;AACD;AAEA,SAAgB,aACf,OACA,MACA,SACC;CACD,OAAO;EACN;EACA;EACA,QAAQ;EACR,GAAI,WAAW,CAAC;CACjB;AACD;AAEA,SAAgB,aACf,OACA,MACA,SACA,SACC;CACD,OAAO;EACN;EACA;EACA,QAAQ;EACR,GAAI,WAAW,CAAC;EAChB,SAAS,WAAW,CAAC;CACtB;AACD;AAEA,SAAgB,aACf,OACA,MACA,SACC;CACD,OAAO;EACN;EACA;EACA,QAAQ;EACR,GAAI,WAAW,CAAC;CACjB;AACD;AAEA,SAAgB,WACf,OACA,MACA,SACC;CACD,OAAO;EACN;EACA;EACA,QAAQ;EACR,GAAI,WAAW,CAAC;CACjB;AACD;;;;;;;;AAWA,MAAa,gBAA8C;CAC1D,SAAS;EACR;EACA;EACA;EACA;EACA;EACA;CACD;CACA,mBAAmB,CAAC;CACpB,OAAO,CAAC,WAAW;AACpB;;;;;AAMA,MAAa,kBAAgD;CAC5D,SAAS;EAAC;EAAQ;EAAU;CAAM;CAClC,mBAAmB,CAAC;CACpB,OAAO,CAAC,WAAW;AACpB"}
|
package/package.json
CHANGED