@strapi/content-manager 5.50.2 → 5.51.0
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/dist/admin/content-manager.js +31 -4
- package/dist/admin/content-manager.js.map +1 -1
- package/dist/admin/content-manager.mjs +31 -4
- package/dist/admin/content-manager.mjs.map +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/index.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js +23 -7
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs +23 -7
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js +5 -13
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs +5 -13
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +4 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +4 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
- package/dist/admin/pages/EditView/utils/draftRelationCounts.js +14 -7
- package/dist/admin/pages/EditView/utils/draftRelationCounts.js.map +1 -1
- package/dist/admin/pages/EditView/utils/draftRelationCounts.mjs +14 -8
- package/dist/admin/pages/EditView/utils/draftRelationCounts.mjs.map +1 -1
- package/dist/admin/preview/components/PreviewSidePanel.js +46 -9
- package/dist/admin/preview/components/PreviewSidePanel.js.map +1 -1
- package/dist/admin/preview/components/PreviewSidePanel.mjs +27 -10
- package/dist/admin/preview/components/PreviewSidePanel.mjs.map +1 -1
- package/dist/admin/src/index.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations/Relations.d.ts +9 -1
- package/dist/admin/src/pages/EditView/utils/draftRelationCounts.d.ts +1 -0
- package/dist/server/src/history/routes/index.d.ts +3 -1
- package/dist/server/src/history/routes/index.d.ts.map +1 -1
- package/dist/server/src/homepage/index.d.ts +6 -2
- package/dist/server/src/homepage/index.d.ts.map +1 -1
- package/dist/server/src/homepage/routes/index.d.ts +3 -1
- package/dist/server/src/homepage/routes/index.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +3 -1
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/preview/routes/index.d.ts +3 -1
- package/dist/server/src/preview/routes/index.d.ts.map +1 -1
- package/dist/server/src/routes/index.d.ts +3 -1
- package/dist/server/src/routes/index.d.ts.map +1 -1
- package/package.json +6 -6
|
@@ -30,48 +30,60 @@ var TableActions = require('./pages/ListView/components/TableActions.js');
|
|
|
30
30
|
}
|
|
31
31
|
addEditViewSidePanel(panels) {
|
|
32
32
|
if (Array.isArray(panels)) {
|
|
33
|
+
validateDescriptionItems(panels, 'addEditViewSidePanel', 'panels');
|
|
33
34
|
this.editViewSidePanels = [
|
|
34
35
|
...this.editViewSidePanels,
|
|
35
36
|
...panels
|
|
36
37
|
];
|
|
37
38
|
} else if (typeof panels === 'function') {
|
|
38
|
-
|
|
39
|
+
const result = panels(this.editViewSidePanels);
|
|
40
|
+
validateDescriptionItems(result, 'addEditViewSidePanel', 'panels');
|
|
41
|
+
this.editViewSidePanels = result;
|
|
39
42
|
} else {
|
|
40
43
|
throw new Error(`Expected the \`panels\` passed to \`addEditViewSidePanel\` to be an array or a function, but received ${getPrintableType(panels)}`);
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
46
|
addDocumentAction(actions) {
|
|
44
47
|
if (Array.isArray(actions)) {
|
|
48
|
+
validateDescriptionItems(actions, 'addDocumentAction', 'actions');
|
|
45
49
|
this.documentActions = [
|
|
46
50
|
...this.documentActions,
|
|
47
51
|
...actions
|
|
48
52
|
];
|
|
49
53
|
} else if (typeof actions === 'function') {
|
|
50
|
-
|
|
54
|
+
const result = actions(this.documentActions);
|
|
55
|
+
validateDescriptionItems(result, 'addDocumentAction', 'actions');
|
|
56
|
+
this.documentActions = result;
|
|
51
57
|
} else {
|
|
52
58
|
throw new Error(`Expected the \`actions\` passed to \`addDocumentAction\` to be an array or a function, but received ${getPrintableType(actions)}`);
|
|
53
59
|
}
|
|
54
60
|
}
|
|
55
61
|
addDocumentHeaderAction(actions) {
|
|
56
62
|
if (Array.isArray(actions)) {
|
|
63
|
+
validateDescriptionItems(actions, 'addDocumentHeaderAction', 'actions');
|
|
57
64
|
this.headerActions = [
|
|
58
65
|
...this.headerActions,
|
|
59
66
|
...actions
|
|
60
67
|
];
|
|
61
68
|
} else if (typeof actions === 'function') {
|
|
62
|
-
|
|
69
|
+
const result = actions(this.headerActions);
|
|
70
|
+
validateDescriptionItems(result, 'addDocumentHeaderAction', 'actions');
|
|
71
|
+
this.headerActions = result;
|
|
63
72
|
} else {
|
|
64
73
|
throw new Error(`Expected the \`actions\` passed to \`addDocumentHeaderAction\` to be an array or a function, but received ${getPrintableType(actions)}`);
|
|
65
74
|
}
|
|
66
75
|
}
|
|
67
76
|
addBulkAction(actions) {
|
|
68
77
|
if (Array.isArray(actions)) {
|
|
78
|
+
validateDescriptionItems(actions, 'addBulkAction', 'actions');
|
|
69
79
|
this.bulkActions = [
|
|
70
80
|
...this.bulkActions,
|
|
71
81
|
...actions
|
|
72
82
|
];
|
|
73
83
|
} else if (typeof actions === 'function') {
|
|
74
|
-
|
|
84
|
+
const result = actions(this.bulkActions);
|
|
85
|
+
validateDescriptionItems(result, 'addBulkAction', 'actions');
|
|
86
|
+
this.bulkActions = result;
|
|
75
87
|
} else {
|
|
76
88
|
throw new Error(`Expected the \`actions\` passed to \`addBulkAction\` to be an array or a function, but received ${getPrintableType(actions)}`);
|
|
77
89
|
}
|
|
@@ -152,6 +164,21 @@ var TableActions = require('./pages/ListView/components/TableActions.js');
|
|
|
152
164
|
}
|
|
153
165
|
return nativeType;
|
|
154
166
|
};
|
|
167
|
+
/* -------------------------------------------------------------------------------------------------
|
|
168
|
+
* validateDescriptionItems
|
|
169
|
+
* -----------------------------------------------------------------------------------------------*/ /**
|
|
170
|
+
* @internal
|
|
171
|
+
* @description Descriptions must be functions (they're rendered as components so hooks can be used
|
|
172
|
+
* inside them), not plain objects. Passing a plain object crashes deep inside
|
|
173
|
+
* `DescriptionComponentRenderer` with an unhelpful `description is not a function` error, so we
|
|
174
|
+
* validate eagerly here to fail fast with a clear message pointing at the offending API call.
|
|
175
|
+
*/ const validateDescriptionItems = (items, apiName, argName)=>{
|
|
176
|
+
items.forEach((item, index)=>{
|
|
177
|
+
if (typeof item !== 'function') {
|
|
178
|
+
throw new Error(`Expected every item in the \`${argName}\` array passed to \`${apiName}\` to be a function that returns a description object, but received ${getPrintableType(item)} at index ${index}. Did you forget to wrap it in a function, e.g. \`() => ({ ...yourAction })\`?`);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
};
|
|
155
182
|
|
|
156
183
|
exports.ContentManagerPlugin = ContentManagerPlugin;
|
|
157
184
|
//# sourceMappingURL=content-manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-manager.js","sources":["../../admin/src/content-manager.ts"],"sourcesContent":["/* eslint-disable check-file/filename-naming-convention */\n\nimport { INJECTION_ZONES } from './components/InjectionZone';\nimport { PLUGIN_ID } from './constants/plugin';\nimport {\n DEFAULT_ACTIONS,\n type DocumentActionPosition,\n type DocumentActionDescription,\n} from './pages/EditView/components/DocumentActions';\nimport { RichTextBlocksStore } from './pages/EditView/components/FormInputs/BlocksInput/BlocksEditor';\nimport { defaultBlocksStore } from './pages/EditView/components/FormInputs/BlocksInput/DefaultBlocksStore';\nimport {\n DEFAULT_HEADER_ACTIONS,\n type HeaderActionDescription,\n} from './pages/EditView/components/Header';\nimport { ActionsPanel, type PanelDescription } from './pages/EditView/components/Panels';\nimport {\n DEFAULT_BULK_ACTIONS,\n type BulkActionDescription,\n} from './pages/ListView/components/BulkActions/Actions';\nimport { DEFAULT_TABLE_ROW_ACTIONS } from './pages/ListView/components/TableActions';\n\nimport type { Document } from './hooks/useDocument';\nimport type { DocumentMetadata } from '../../shared/contracts/collection-types';\nimport type { DescriptionComponent, PluginConfig } from '@strapi/admin/strapi-admin';\n\n/* -------------------------------------------------------------------------------------------------\n * Configuration Types\n * -----------------------------------------------------------------------------------------------*/\n\ntype DescriptionReducer<Config extends object> = (prev: Config[]) => Config[];\ntype DescriptionObjReducer<Config extends object> = (prev: Config) => Config;\n\ninterface EditViewContext {\n /**\n * This will ONLY be null, if the content-type\n * does not have draft & published enabled.\n */\n activeTab: 'draft' | 'published' | null;\n /**\n * Will be either 'single-types' | 'collection-types'\n */\n collectionType: string;\n /**\n * this will be undefined if someone is creating an entry.\n */\n document?: Document;\n /**\n * this will be undefined if someone is creating an entry.\n */\n documentId?: string;\n /**\n * this will be undefined if someone is creating an entry.\n */\n meta?: DocumentMetadata;\n /**\n * The current content-type's model.\n */\n model: string;\n}\n\ninterface ListViewContext {\n /**\n * Will be either 'single-types' | 'collection-types'\n */\n collectionType: string;\n /**\n * The current selected documents in the table\n */\n documents: Document[];\n /**\n * The current content-type's model.\n */\n model: string;\n}\n\ninterface PanelComponentProps extends EditViewContext {}\n\ninterface PanelComponent extends DescriptionComponent<PanelComponentProps, PanelDescription> {\n /**\n * The defaults are added by Strapi only, if you're providing your own component,\n * you do not need to provide this.\n */\n type?: 'actions' | 'releases';\n}\n\ninterface DocumentActionProps extends EditViewContext {}\n\ninterface DocumentActionComponent\n extends DescriptionComponent<DocumentActionProps, DocumentActionDescription> {\n type?:\n | 'clone'\n | 'configure-the-view'\n | 'delete'\n | 'discard'\n | 'edit'\n | 'edit-the-model'\n | 'history'\n | 'publish'\n | 'unpublish'\n | 'update';\n position?: DocumentActionDescription['position'];\n}\n\ninterface HeaderActionProps extends EditViewContext {}\n\ninterface HeaderActionComponent\n extends DescriptionComponent<HeaderActionProps, HeaderActionDescription> {}\n\ninterface BulkActionComponentProps extends ListViewContext {}\n\ninterface BulkActionComponent\n extends DescriptionComponent<BulkActionComponentProps, BulkActionDescription> {\n type?: 'delete' | 'publish' | 'unpublish';\n}\n\n/* -------------------------------------------------------------------------------------------------\n * ContentManager plugin\n * -----------------------------------------------------------------------------------------------*/\n\nclass ContentManagerPlugin {\n /**\n * The following properties are the stored ones provided by any plugins registering with\n * the content-manager. The function calls however, need to be called at runtime in the\n * application, so instead we collate them and run them later with the complete list incl.\n * ones already registered & the context of the view.\n */\n richTextBlocksStore: RichTextBlocksStore = { ...defaultBlocksStore };\n bulkActions: BulkActionComponent[] = [...DEFAULT_BULK_ACTIONS];\n documentActions: DocumentActionComponent[] = [\n ...DEFAULT_ACTIONS,\n ...DEFAULT_TABLE_ROW_ACTIONS,\n ...DEFAULT_HEADER_ACTIONS,\n ];\n editViewSidePanels: PanelComponent[] = [ActionsPanel];\n headerActions: HeaderActionComponent[] = [];\n\n constructor() {}\n\n addRichTextBlocks(blocks: RichTextBlocksStore): void;\n addRichTextBlocks(blocks: DescriptionObjReducer<RichTextBlocksStore>): void;\n addRichTextBlocks(blocks: RichTextBlocksStore | DescriptionObjReducer<RichTextBlocksStore>) {\n if (typeof blocks === 'function') {\n const result = blocks(this.richTextBlocksStore);\n if (typeof result !== 'object' || result === null) {\n throw new Error(\n `Expected the \\`blocks\\` passed to \\`addRichTextBlocks\\` to be an object or a function, but received ${getPrintableType(result)}`\n );\n }\n this.richTextBlocksStore = result;\n } else if (typeof blocks === 'object') {\n this.richTextBlocksStore = { ...this.richTextBlocksStore, ...blocks };\n } else {\n throw new Error(\n `Expected the \\`blocks\\` passed to \\`addRichTextBlocks\\` to be an object or a function, but received ${getPrintableType(\n blocks\n )}`\n );\n }\n }\n\n addEditViewSidePanel(panels: DescriptionReducer<PanelComponent>): void;\n addEditViewSidePanel(panels: PanelComponent[]): void;\n addEditViewSidePanel(panels: DescriptionReducer<PanelComponent> | PanelComponent[]) {\n if (Array.isArray(panels)) {\n this.editViewSidePanels = [...this.editViewSidePanels, ...panels];\n } else if (typeof panels === 'function') {\n this.editViewSidePanels = panels(this.editViewSidePanels);\n } else {\n throw new Error(\n `Expected the \\`panels\\` passed to \\`addEditViewSidePanel\\` to be an array or a function, but received ${getPrintableType(\n panels\n )}`\n );\n }\n }\n\n addDocumentAction(actions: DescriptionReducer<DocumentActionComponent>): void;\n addDocumentAction(actions: DocumentActionComponent[]): void;\n addDocumentAction(\n actions: DescriptionReducer<DocumentActionComponent> | DocumentActionComponent[]\n ) {\n if (Array.isArray(actions)) {\n this.documentActions = [...this.documentActions, ...actions];\n } else if (typeof actions === 'function') {\n this.documentActions = actions(this.documentActions);\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addDocumentAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n addDocumentHeaderAction(actions: DescriptionReducer<HeaderActionComponent>): void;\n addDocumentHeaderAction(actions: HeaderActionComponent[]): void;\n addDocumentHeaderAction(\n actions: DescriptionReducer<HeaderActionComponent> | HeaderActionComponent[]\n ) {\n if (Array.isArray(actions)) {\n this.headerActions = [...this.headerActions, ...actions];\n } else if (typeof actions === 'function') {\n this.headerActions = actions(this.headerActions);\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addDocumentHeaderAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n addBulkAction(actions: DescriptionReducer<BulkActionComponent>): void;\n addBulkAction(actions: BulkActionComponent[]): void;\n addBulkAction(actions: DescriptionReducer<BulkActionComponent> | BulkActionComponent[]) {\n if (Array.isArray(actions)) {\n this.bulkActions = [...this.bulkActions, ...actions];\n } else if (typeof actions === 'function') {\n this.bulkActions = actions(this.bulkActions);\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addBulkAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n get config() {\n return {\n id: PLUGIN_ID,\n name: 'Content Manager',\n injectionZones: INJECTION_ZONES,\n apis: {\n addBulkAction: this.addBulkAction.bind(this),\n addDocumentAction: this.addDocumentAction.bind(this),\n addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),\n addEditViewSidePanel: this.addEditViewSidePanel.bind(this),\n addRichTextBlocks: this.addRichTextBlocks.bind(this),\n getBulkActions: () => this.bulkActions,\n getDocumentActions: (position?: DocumentActionPosition) => {\n /**\n * When possible, pre-filter the actions by the components static position property.\n * This avoids rendering the actions in multiple places where they weren't displayed,\n * which wasn't visible but created issues with useEffect for instance.\n * The response should still be filtered by the position, as the static property is new\n * and not mandatory to avoid a breaking change.\n */\n if (position) {\n return this.documentActions.filter((action) => {\n return action.position == undefined || [action.position].flat().includes(position);\n });\n }\n\n return this.documentActions;\n },\n getEditViewSidePanels: () => this.editViewSidePanels,\n getHeaderActions: () => this.headerActions,\n getRichTextBlocks: () => ({ ...this.richTextBlocksStore }),\n },\n } satisfies PluginConfig;\n }\n}\n\n/* -------------------------------------------------------------------------------------------------\n * getPrintableType\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Gets the human-friendly printable type name for the given value, for instance it will yield\n * `array` instead of `object`, as the native `typeof` operator would do.\n */\nconst getPrintableType = (value: unknown): string => {\n const nativeType = typeof value;\n\n if (nativeType === 'object') {\n if (value === null) return 'null';\n if (Array.isArray(value)) return 'array';\n if (value instanceof Object && value.constructor.name !== 'Object') {\n return value.constructor.name;\n }\n }\n\n return nativeType;\n};\n\nexport { ContentManagerPlugin };\nexport type {\n EditViewContext,\n ListViewContext,\n BulkActionComponent,\n BulkActionComponentProps,\n BulkActionDescription,\n DescriptionComponent,\n DescriptionReducer,\n PanelComponentProps,\n PanelComponent,\n PanelDescription,\n DocumentActionComponent,\n DocumentActionDescription,\n DocumentActionProps,\n HeaderActionComponent,\n HeaderActionDescription,\n HeaderActionProps,\n};\n"],"names":["ContentManagerPlugin","addRichTextBlocks","blocks","result","richTextBlocksStore","Error","getPrintableType","addEditViewSidePanel","panels","Array","isArray","editViewSidePanels","addDocumentAction","actions","documentActions","addDocumentHeaderAction","headerActions","addBulkAction","bulkActions","config","id","PLUGIN_ID","name","injectionZones","INJECTION_ZONES","apis","bind","getBulkActions","getDocumentActions","position","filter","action","undefined","flat","includes","getEditViewSidePanels","getHeaderActions","getRichTextBlocks","defaultBlocksStore","DEFAULT_BULK_ACTIONS","DEFAULT_ACTIONS","DEFAULT_TABLE_ROW_ACTIONS","DEFAULT_HEADER_ACTIONS","ActionsPanel","value","nativeType","Object"],"mappings":";;;;;;;;;;;AAoHA;;AAEkG,qGAElG,MAAMA,oBAAAA,CAAAA;AAqBJC,IAAAA,iBAAAA,CAAkBC,MAAwE,EAAE;QAC1F,IAAI,OAAOA,WAAW,UAAA,EAAY;AAChC,YAAA,MAAMC,MAAAA,GAASD,MAAAA,CAAO,IAAI,CAACE,mBAAmB,CAAA;AAC9C,YAAA,IAAI,OAAOD,MAAAA,KAAW,QAAA,IAAYA,MAAAA,KAAW,IAAA,EAAM;AACjD,gBAAA,MAAM,IAAIE,KAAAA,CACR,CAAC,oGAAoG,EAAEC,iBAAiBH,MAAAA,CAAAA,CAAAA,CAAS,CAAA;AAErI,YAAA;YACA,IAAI,CAACC,mBAAmB,GAAGD,MAAAA;QAC7B,CAAA,MAAO,IAAI,OAAOD,MAAAA,KAAW,QAAA,EAAU;YACrC,IAAI,CAACE,mBAAmB,GAAG;gBAAE,GAAG,IAAI,CAACA,mBAAmB;AAAE,gBAAA,GAAGF;AAAO,aAAA;QACtE,CAAA,MAAO;AACL,YAAA,MAAM,IAAIG,KAAAA,CACR,CAAC,oGAAoG,EAAEC,iBACrGJ,MAAAA,CAAAA,CAAAA,CACC,CAAA;AAEP,QAAA;AACF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QAC3B,IAAID,KAAAA,KAAU,MAAM,OAAO,MAAA;AAC3B,QAAA,IAAInC,KAAAA,CAAMC,OAAO,CAACkC,KAAAA,CAAAA,EAAQ,OAAO,OAAA;AACjC,QAAA,IAAIA,iBAAiBE,MAAAA,IAAUF,KAAAA,CAAM,WAAW,CAACtB,IAAI,KAAK,QAAA,EAAU;YAClE,OAAOsB,KAAAA,CAAM,WAAW,CAACtB,IAAI;AAC/B,QAAA;AACF,IAAA;IAEA,OAAOuB,UAAAA;AACT,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"content-manager.js","sources":["../../admin/src/content-manager.ts"],"sourcesContent":["/* eslint-disable check-file/filename-naming-convention */\n\nimport { INJECTION_ZONES } from './components/InjectionZone';\nimport { PLUGIN_ID } from './constants/plugin';\nimport {\n DEFAULT_ACTIONS,\n type DocumentActionPosition,\n type DocumentActionDescription,\n} from './pages/EditView/components/DocumentActions';\nimport { RichTextBlocksStore } from './pages/EditView/components/FormInputs/BlocksInput/BlocksEditor';\nimport { defaultBlocksStore } from './pages/EditView/components/FormInputs/BlocksInput/DefaultBlocksStore';\nimport {\n DEFAULT_HEADER_ACTIONS,\n type HeaderActionDescription,\n} from './pages/EditView/components/Header';\nimport { ActionsPanel, type PanelDescription } from './pages/EditView/components/Panels';\nimport {\n DEFAULT_BULK_ACTIONS,\n type BulkActionDescription,\n} from './pages/ListView/components/BulkActions/Actions';\nimport { DEFAULT_TABLE_ROW_ACTIONS } from './pages/ListView/components/TableActions';\n\nimport type { Document } from './hooks/useDocument';\nimport type { DocumentMetadata } from '../../shared/contracts/collection-types';\nimport type { DescriptionComponent, PluginConfig } from '@strapi/admin/strapi-admin';\n\n/* -------------------------------------------------------------------------------------------------\n * Configuration Types\n * -----------------------------------------------------------------------------------------------*/\n\ntype DescriptionReducer<Config extends object> = (prev: Config[]) => Config[];\ntype DescriptionObjReducer<Config extends object> = (prev: Config) => Config;\n\ninterface EditViewContext {\n /**\n * This will ONLY be null, if the content-type\n * does not have draft & published enabled.\n */\n activeTab: 'draft' | 'published' | null;\n /**\n * Will be either 'single-types' | 'collection-types'\n */\n collectionType: string;\n /**\n * this will be undefined if someone is creating an entry.\n */\n document?: Document;\n /**\n * this will be undefined if someone is creating an entry.\n */\n documentId?: string;\n /**\n * this will be undefined if someone is creating an entry.\n */\n meta?: DocumentMetadata;\n /**\n * The current content-type's model.\n */\n model: string;\n}\n\ninterface ListViewContext {\n /**\n * Will be either 'single-types' | 'collection-types'\n */\n collectionType: string;\n /**\n * The current selected documents in the table\n */\n documents: Document[];\n /**\n * The current content-type's model.\n */\n model: string;\n}\n\ninterface PanelComponentProps extends EditViewContext {}\n\ninterface PanelComponent extends DescriptionComponent<PanelComponentProps, PanelDescription> {\n /**\n * The defaults are added by Strapi only, if you're providing your own component,\n * you do not need to provide this.\n */\n type?: 'actions' | 'releases';\n}\n\ninterface DocumentActionProps extends EditViewContext {}\n\ninterface DocumentActionComponent\n extends DescriptionComponent<DocumentActionProps, DocumentActionDescription> {\n type?:\n | 'clone'\n | 'configure-the-view'\n | 'delete'\n | 'discard'\n | 'edit'\n | 'edit-the-model'\n | 'history'\n | 'publish'\n | 'unpublish'\n | 'update';\n position?: DocumentActionDescription['position'];\n}\n\ninterface HeaderActionProps extends EditViewContext {}\n\ninterface HeaderActionComponent\n extends DescriptionComponent<HeaderActionProps, HeaderActionDescription> {}\n\ninterface BulkActionComponentProps extends ListViewContext {}\n\ninterface BulkActionComponent\n extends DescriptionComponent<BulkActionComponentProps, BulkActionDescription> {\n type?: 'delete' | 'publish' | 'unpublish';\n}\n\n/* -------------------------------------------------------------------------------------------------\n * ContentManager plugin\n * -----------------------------------------------------------------------------------------------*/\n\nclass ContentManagerPlugin {\n /**\n * The following properties are the stored ones provided by any plugins registering with\n * the content-manager. The function calls however, need to be called at runtime in the\n * application, so instead we collate them and run them later with the complete list incl.\n * ones already registered & the context of the view.\n */\n richTextBlocksStore: RichTextBlocksStore = { ...defaultBlocksStore };\n bulkActions: BulkActionComponent[] = [...DEFAULT_BULK_ACTIONS];\n documentActions: DocumentActionComponent[] = [\n ...DEFAULT_ACTIONS,\n ...DEFAULT_TABLE_ROW_ACTIONS,\n ...DEFAULT_HEADER_ACTIONS,\n ];\n editViewSidePanels: PanelComponent[] = [ActionsPanel];\n headerActions: HeaderActionComponent[] = [];\n\n constructor() {}\n\n addRichTextBlocks(blocks: RichTextBlocksStore): void;\n addRichTextBlocks(blocks: DescriptionObjReducer<RichTextBlocksStore>): void;\n addRichTextBlocks(blocks: RichTextBlocksStore | DescriptionObjReducer<RichTextBlocksStore>) {\n if (typeof blocks === 'function') {\n const result = blocks(this.richTextBlocksStore);\n if (typeof result !== 'object' || result === null) {\n throw new Error(\n `Expected the \\`blocks\\` passed to \\`addRichTextBlocks\\` to be an object or a function, but received ${getPrintableType(result)}`\n );\n }\n this.richTextBlocksStore = result;\n } else if (typeof blocks === 'object') {\n this.richTextBlocksStore = { ...this.richTextBlocksStore, ...blocks };\n } else {\n throw new Error(\n `Expected the \\`blocks\\` passed to \\`addRichTextBlocks\\` to be an object or a function, but received ${getPrintableType(\n blocks\n )}`\n );\n }\n }\n\n addEditViewSidePanel(panels: DescriptionReducer<PanelComponent>): void;\n addEditViewSidePanel(panels: PanelComponent[]): void;\n addEditViewSidePanel(panels: DescriptionReducer<PanelComponent> | PanelComponent[]) {\n if (Array.isArray(panels)) {\n validateDescriptionItems(panels, 'addEditViewSidePanel', 'panels');\n this.editViewSidePanels = [...this.editViewSidePanels, ...panels];\n } else if (typeof panels === 'function') {\n const result = panels(this.editViewSidePanels);\n validateDescriptionItems(result, 'addEditViewSidePanel', 'panels');\n this.editViewSidePanels = result;\n } else {\n throw new Error(\n `Expected the \\`panels\\` passed to \\`addEditViewSidePanel\\` to be an array or a function, but received ${getPrintableType(\n panels\n )}`\n );\n }\n }\n\n addDocumentAction(actions: DescriptionReducer<DocumentActionComponent>): void;\n addDocumentAction(actions: DocumentActionComponent[]): void;\n addDocumentAction(\n actions: DescriptionReducer<DocumentActionComponent> | DocumentActionComponent[]\n ) {\n if (Array.isArray(actions)) {\n validateDescriptionItems(actions, 'addDocumentAction', 'actions');\n this.documentActions = [...this.documentActions, ...actions];\n } else if (typeof actions === 'function') {\n const result = actions(this.documentActions);\n validateDescriptionItems(result, 'addDocumentAction', 'actions');\n this.documentActions = result;\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addDocumentAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n addDocumentHeaderAction(actions: DescriptionReducer<HeaderActionComponent>): void;\n addDocumentHeaderAction(actions: HeaderActionComponent[]): void;\n addDocumentHeaderAction(\n actions: DescriptionReducer<HeaderActionComponent> | HeaderActionComponent[]\n ) {\n if (Array.isArray(actions)) {\n validateDescriptionItems(actions, 'addDocumentHeaderAction', 'actions');\n this.headerActions = [...this.headerActions, ...actions];\n } else if (typeof actions === 'function') {\n const result = actions(this.headerActions);\n validateDescriptionItems(result, 'addDocumentHeaderAction', 'actions');\n this.headerActions = result;\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addDocumentHeaderAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n addBulkAction(actions: DescriptionReducer<BulkActionComponent>): void;\n addBulkAction(actions: BulkActionComponent[]): void;\n addBulkAction(actions: DescriptionReducer<BulkActionComponent> | BulkActionComponent[]) {\n if (Array.isArray(actions)) {\n validateDescriptionItems(actions, 'addBulkAction', 'actions');\n this.bulkActions = [...this.bulkActions, ...actions];\n } else if (typeof actions === 'function') {\n const result = actions(this.bulkActions);\n validateDescriptionItems(result, 'addBulkAction', 'actions');\n this.bulkActions = result;\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addBulkAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n get config() {\n return {\n id: PLUGIN_ID,\n name: 'Content Manager',\n injectionZones: INJECTION_ZONES,\n apis: {\n addBulkAction: this.addBulkAction.bind(this),\n addDocumentAction: this.addDocumentAction.bind(this),\n addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),\n addEditViewSidePanel: this.addEditViewSidePanel.bind(this),\n addRichTextBlocks: this.addRichTextBlocks.bind(this),\n getBulkActions: () => this.bulkActions,\n getDocumentActions: (position?: DocumentActionPosition) => {\n /**\n * When possible, pre-filter the actions by the components static position property.\n * This avoids rendering the actions in multiple places where they weren't displayed,\n * which wasn't visible but created issues with useEffect for instance.\n * The response should still be filtered by the position, as the static property is new\n * and not mandatory to avoid a breaking change.\n */\n if (position) {\n return this.documentActions.filter((action) => {\n return action.position == undefined || [action.position].flat().includes(position);\n });\n }\n\n return this.documentActions;\n },\n getEditViewSidePanels: () => this.editViewSidePanels,\n getHeaderActions: () => this.headerActions,\n getRichTextBlocks: () => ({ ...this.richTextBlocksStore }),\n },\n } satisfies PluginConfig;\n }\n}\n\n/* -------------------------------------------------------------------------------------------------\n * getPrintableType\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Gets the human-friendly printable type name for the given value, for instance it will yield\n * `array` instead of `object`, as the native `typeof` operator would do.\n */\nconst getPrintableType = (value: unknown): string => {\n const nativeType = typeof value;\n\n if (nativeType === 'object') {\n if (value === null) return 'null';\n if (Array.isArray(value)) return 'array';\n if (value instanceof Object && value.constructor.name !== 'Object') {\n return value.constructor.name;\n }\n }\n\n return nativeType;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * validateDescriptionItems\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Descriptions must be functions (they're rendered as components so hooks can be used\n * inside them), not plain objects. Passing a plain object crashes deep inside\n * `DescriptionComponentRenderer` with an unhelpful `description is not a function` error, so we\n * validate eagerly here to fail fast with a clear message pointing at the offending API call.\n */\nconst validateDescriptionItems = (items: unknown[], apiName: string, argName: string): void => {\n items.forEach((item, index) => {\n if (typeof item !== 'function') {\n throw new Error(\n `Expected every item in the \\`${argName}\\` array passed to \\`${apiName}\\` to be a function that returns a description object, but received ${getPrintableType(\n item\n )} at index ${index}. Did you forget to wrap it in a function, e.g. \\`() => ({ ...yourAction })\\`?`\n );\n }\n });\n};\n\nexport { ContentManagerPlugin };\nexport type {\n EditViewContext,\n ListViewContext,\n BulkActionComponent,\n BulkActionComponentProps,\n BulkActionDescription,\n DescriptionComponent,\n DescriptionReducer,\n PanelComponentProps,\n PanelComponent,\n PanelDescription,\n DocumentActionComponent,\n DocumentActionDescription,\n DocumentActionProps,\n HeaderActionComponent,\n HeaderActionDescription,\n HeaderActionProps,\n};\n"],"names":["ContentManagerPlugin","addRichTextBlocks","blocks","result","richTextBlocksStore","Error","getPrintableType","addEditViewSidePanel","panels","Array","isArray","validateDescriptionItems","editViewSidePanels","addDocumentAction","actions","documentActions","addDocumentHeaderAction","headerActions","addBulkAction","bulkActions","config","id","PLUGIN_ID","name","injectionZones","INJECTION_ZONES","apis","bind","getBulkActions","getDocumentActions","position","filter","action","undefined","flat","includes","getEditViewSidePanels","getHeaderActions","getRichTextBlocks","defaultBlocksStore","DEFAULT_BULK_ACTIONS","DEFAULT_ACTIONS","DEFAULT_TABLE_ROW_ACTIONS","DEFAULT_HEADER_ACTIONS","ActionsPanel","value","nativeType","Object","items","apiName","argName","forEach","item","index"],"mappings":";;;;;;;;;;;AAoHA;;AAEkG,qGAElG,MAAMA,oBAAAA,CAAAA;AAqBJC,IAAAA,iBAAAA,CAAkBC,MAAwE,EAAE;QAC1F,IAAI,OAAOA,WAAW,UAAA,EAAY;AAChC,YAAA,MAAMC,MAAAA,GAASD,MAAAA,CAAO,IAAI,CAACE,mBAAmB,CAAA;AAC9C,YAAA,IAAI,OAAOD,MAAAA,KAAW,QAAA,IAAYA,MAAAA,KAAW,IAAA,EAAM;AACjD,gBAAA,MAAM,IAAIE,KAAAA,CACR,CAAC,oGAAoG,EAAEC,iBAAiBH,MAAAA,CAAAA,CAAAA,CAAS,CAAA;AAErI,YAAA;YACA,IAAI,CAACC,mBAAmB,GAAGD,MAAAA;QAC7B,CAA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EA,OAAOuB,UAAAA;AACT,CAAA;AAEA;;;;;;;;AAUC,IACD,MAAMnC,wBAAAA,GAA2B,CAACqC,KAAAA,EAAkBC,OAAAA,EAAiBC,OAAAA,GAAAA;IACnEF,KAAAA,CAAMG,OAAO,CAAC,CAACC,IAAAA,EAAMC,KAAAA,GAAAA;QACnB,IAAI,OAAOD,SAAS,UAAA,EAAY;AAC9B,YAAA,MAAM,IAAI/C,KAAAA,CACR,CAAC,6BAA6B,EAAE6C,QAAQ,qBAAqB,EAAED,OAAAA,CAAQ,oEAAoE,EAAE3C,gBAAAA,CAC3I8C,IAAAA,CAAAA,CACA,UAAU,EAAEC,KAAAA,CAAM,8EAA8E,CAAC,CAAA;AAEvG,QAAA;AACF,IAAA,CAAA,CAAA;AACF,CAAA;;;;"}
|
|
@@ -28,48 +28,60 @@ import { DEFAULT_TABLE_ROW_ACTIONS } from './pages/ListView/components/TableActi
|
|
|
28
28
|
}
|
|
29
29
|
addEditViewSidePanel(panels) {
|
|
30
30
|
if (Array.isArray(panels)) {
|
|
31
|
+
validateDescriptionItems(panels, 'addEditViewSidePanel', 'panels');
|
|
31
32
|
this.editViewSidePanels = [
|
|
32
33
|
...this.editViewSidePanels,
|
|
33
34
|
...panels
|
|
34
35
|
];
|
|
35
36
|
} else if (typeof panels === 'function') {
|
|
36
|
-
|
|
37
|
+
const result = panels(this.editViewSidePanels);
|
|
38
|
+
validateDescriptionItems(result, 'addEditViewSidePanel', 'panels');
|
|
39
|
+
this.editViewSidePanels = result;
|
|
37
40
|
} else {
|
|
38
41
|
throw new Error(`Expected the \`panels\` passed to \`addEditViewSidePanel\` to be an array or a function, but received ${getPrintableType(panels)}`);
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
addDocumentAction(actions) {
|
|
42
45
|
if (Array.isArray(actions)) {
|
|
46
|
+
validateDescriptionItems(actions, 'addDocumentAction', 'actions');
|
|
43
47
|
this.documentActions = [
|
|
44
48
|
...this.documentActions,
|
|
45
49
|
...actions
|
|
46
50
|
];
|
|
47
51
|
} else if (typeof actions === 'function') {
|
|
48
|
-
|
|
52
|
+
const result = actions(this.documentActions);
|
|
53
|
+
validateDescriptionItems(result, 'addDocumentAction', 'actions');
|
|
54
|
+
this.documentActions = result;
|
|
49
55
|
} else {
|
|
50
56
|
throw new Error(`Expected the \`actions\` passed to \`addDocumentAction\` to be an array or a function, but received ${getPrintableType(actions)}`);
|
|
51
57
|
}
|
|
52
58
|
}
|
|
53
59
|
addDocumentHeaderAction(actions) {
|
|
54
60
|
if (Array.isArray(actions)) {
|
|
61
|
+
validateDescriptionItems(actions, 'addDocumentHeaderAction', 'actions');
|
|
55
62
|
this.headerActions = [
|
|
56
63
|
...this.headerActions,
|
|
57
64
|
...actions
|
|
58
65
|
];
|
|
59
66
|
} else if (typeof actions === 'function') {
|
|
60
|
-
|
|
67
|
+
const result = actions(this.headerActions);
|
|
68
|
+
validateDescriptionItems(result, 'addDocumentHeaderAction', 'actions');
|
|
69
|
+
this.headerActions = result;
|
|
61
70
|
} else {
|
|
62
71
|
throw new Error(`Expected the \`actions\` passed to \`addDocumentHeaderAction\` to be an array or a function, but received ${getPrintableType(actions)}`);
|
|
63
72
|
}
|
|
64
73
|
}
|
|
65
74
|
addBulkAction(actions) {
|
|
66
75
|
if (Array.isArray(actions)) {
|
|
76
|
+
validateDescriptionItems(actions, 'addBulkAction', 'actions');
|
|
67
77
|
this.bulkActions = [
|
|
68
78
|
...this.bulkActions,
|
|
69
79
|
...actions
|
|
70
80
|
];
|
|
71
81
|
} else if (typeof actions === 'function') {
|
|
72
|
-
|
|
82
|
+
const result = actions(this.bulkActions);
|
|
83
|
+
validateDescriptionItems(result, 'addBulkAction', 'actions');
|
|
84
|
+
this.bulkActions = result;
|
|
73
85
|
} else {
|
|
74
86
|
throw new Error(`Expected the \`actions\` passed to \`addBulkAction\` to be an array or a function, but received ${getPrintableType(actions)}`);
|
|
75
87
|
}
|
|
@@ -150,6 +162,21 @@ import { DEFAULT_TABLE_ROW_ACTIONS } from './pages/ListView/components/TableActi
|
|
|
150
162
|
}
|
|
151
163
|
return nativeType;
|
|
152
164
|
};
|
|
165
|
+
/* -------------------------------------------------------------------------------------------------
|
|
166
|
+
* validateDescriptionItems
|
|
167
|
+
* -----------------------------------------------------------------------------------------------*/ /**
|
|
168
|
+
* @internal
|
|
169
|
+
* @description Descriptions must be functions (they're rendered as components so hooks can be used
|
|
170
|
+
* inside them), not plain objects. Passing a plain object crashes deep inside
|
|
171
|
+
* `DescriptionComponentRenderer` with an unhelpful `description is not a function` error, so we
|
|
172
|
+
* validate eagerly here to fail fast with a clear message pointing at the offending API call.
|
|
173
|
+
*/ const validateDescriptionItems = (items, apiName, argName)=>{
|
|
174
|
+
items.forEach((item, index)=>{
|
|
175
|
+
if (typeof item !== 'function') {
|
|
176
|
+
throw new Error(`Expected every item in the \`${argName}\` array passed to \`${apiName}\` to be a function that returns a description object, but received ${getPrintableType(item)} at index ${index}. Did you forget to wrap it in a function, e.g. \`() => ({ ...yourAction })\`?`);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
};
|
|
153
180
|
|
|
154
181
|
export { ContentManagerPlugin };
|
|
155
182
|
//# sourceMappingURL=content-manager.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-manager.mjs","sources":["../../admin/src/content-manager.ts"],"sourcesContent":["/* eslint-disable check-file/filename-naming-convention */\n\nimport { INJECTION_ZONES } from './components/InjectionZone';\nimport { PLUGIN_ID } from './constants/plugin';\nimport {\n DEFAULT_ACTIONS,\n type DocumentActionPosition,\n type DocumentActionDescription,\n} from './pages/EditView/components/DocumentActions';\nimport { RichTextBlocksStore } from './pages/EditView/components/FormInputs/BlocksInput/BlocksEditor';\nimport { defaultBlocksStore } from './pages/EditView/components/FormInputs/BlocksInput/DefaultBlocksStore';\nimport {\n DEFAULT_HEADER_ACTIONS,\n type HeaderActionDescription,\n} from './pages/EditView/components/Header';\nimport { ActionsPanel, type PanelDescription } from './pages/EditView/components/Panels';\nimport {\n DEFAULT_BULK_ACTIONS,\n type BulkActionDescription,\n} from './pages/ListView/components/BulkActions/Actions';\nimport { DEFAULT_TABLE_ROW_ACTIONS } from './pages/ListView/components/TableActions';\n\nimport type { Document } from './hooks/useDocument';\nimport type { DocumentMetadata } from '../../shared/contracts/collection-types';\nimport type { DescriptionComponent, PluginConfig } from '@strapi/admin/strapi-admin';\n\n/* -------------------------------------------------------------------------------------------------\n * Configuration Types\n * -----------------------------------------------------------------------------------------------*/\n\ntype DescriptionReducer<Config extends object> = (prev: Config[]) => Config[];\ntype DescriptionObjReducer<Config extends object> = (prev: Config) => Config;\n\ninterface EditViewContext {\n /**\n * This will ONLY be null, if the content-type\n * does not have draft & published enabled.\n */\n activeTab: 'draft' | 'published' | null;\n /**\n * Will be either 'single-types' | 'collection-types'\n */\n collectionType: string;\n /**\n * this will be undefined if someone is creating an entry.\n */\n document?: Document;\n /**\n * this will be undefined if someone is creating an entry.\n */\n documentId?: string;\n /**\n * this will be undefined if someone is creating an entry.\n */\n meta?: DocumentMetadata;\n /**\n * The current content-type's model.\n */\n model: string;\n}\n\ninterface ListViewContext {\n /**\n * Will be either 'single-types' | 'collection-types'\n */\n collectionType: string;\n /**\n * The current selected documents in the table\n */\n documents: Document[];\n /**\n * The current content-type's model.\n */\n model: string;\n}\n\ninterface PanelComponentProps extends EditViewContext {}\n\ninterface PanelComponent extends DescriptionComponent<PanelComponentProps, PanelDescription> {\n /**\n * The defaults are added by Strapi only, if you're providing your own component,\n * you do not need to provide this.\n */\n type?: 'actions' | 'releases';\n}\n\ninterface DocumentActionProps extends EditViewContext {}\n\ninterface DocumentActionComponent\n extends DescriptionComponent<DocumentActionProps, DocumentActionDescription> {\n type?:\n | 'clone'\n | 'configure-the-view'\n | 'delete'\n | 'discard'\n | 'edit'\n | 'edit-the-model'\n | 'history'\n | 'publish'\n | 'unpublish'\n | 'update';\n position?: DocumentActionDescription['position'];\n}\n\ninterface HeaderActionProps extends EditViewContext {}\n\ninterface HeaderActionComponent\n extends DescriptionComponent<HeaderActionProps, HeaderActionDescription> {}\n\ninterface BulkActionComponentProps extends ListViewContext {}\n\ninterface BulkActionComponent\n extends DescriptionComponent<BulkActionComponentProps, BulkActionDescription> {\n type?: 'delete' | 'publish' | 'unpublish';\n}\n\n/* -------------------------------------------------------------------------------------------------\n * ContentManager plugin\n * -----------------------------------------------------------------------------------------------*/\n\nclass ContentManagerPlugin {\n /**\n * The following properties are the stored ones provided by any plugins registering with\n * the content-manager. The function calls however, need to be called at runtime in the\n * application, so instead we collate them and run them later with the complete list incl.\n * ones already registered & the context of the view.\n */\n richTextBlocksStore: RichTextBlocksStore = { ...defaultBlocksStore };\n bulkActions: BulkActionComponent[] = [...DEFAULT_BULK_ACTIONS];\n documentActions: DocumentActionComponent[] = [\n ...DEFAULT_ACTIONS,\n ...DEFAULT_TABLE_ROW_ACTIONS,\n ...DEFAULT_HEADER_ACTIONS,\n ];\n editViewSidePanels: PanelComponent[] = [ActionsPanel];\n headerActions: HeaderActionComponent[] = [];\n\n constructor() {}\n\n addRichTextBlocks(blocks: RichTextBlocksStore): void;\n addRichTextBlocks(blocks: DescriptionObjReducer<RichTextBlocksStore>): void;\n addRichTextBlocks(blocks: RichTextBlocksStore | DescriptionObjReducer<RichTextBlocksStore>) {\n if (typeof blocks === 'function') {\n const result = blocks(this.richTextBlocksStore);\n if (typeof result !== 'object' || result === null) {\n throw new Error(\n `Expected the \\`blocks\\` passed to \\`addRichTextBlocks\\` to be an object or a function, but received ${getPrintableType(result)}`\n );\n }\n this.richTextBlocksStore = result;\n } else if (typeof blocks === 'object') {\n this.richTextBlocksStore = { ...this.richTextBlocksStore, ...blocks };\n } else {\n throw new Error(\n `Expected the \\`blocks\\` passed to \\`addRichTextBlocks\\` to be an object or a function, but received ${getPrintableType(\n blocks\n )}`\n );\n }\n }\n\n addEditViewSidePanel(panels: DescriptionReducer<PanelComponent>): void;\n addEditViewSidePanel(panels: PanelComponent[]): void;\n addEditViewSidePanel(panels: DescriptionReducer<PanelComponent> | PanelComponent[]) {\n if (Array.isArray(panels)) {\n this.editViewSidePanels = [...this.editViewSidePanels, ...panels];\n } else if (typeof panels === 'function') {\n this.editViewSidePanels = panels(this.editViewSidePanels);\n } else {\n throw new Error(\n `Expected the \\`panels\\` passed to \\`addEditViewSidePanel\\` to be an array or a function, but received ${getPrintableType(\n panels\n )}`\n );\n }\n }\n\n addDocumentAction(actions: DescriptionReducer<DocumentActionComponent>): void;\n addDocumentAction(actions: DocumentActionComponent[]): void;\n addDocumentAction(\n actions: DescriptionReducer<DocumentActionComponent> | DocumentActionComponent[]\n ) {\n if (Array.isArray(actions)) {\n this.documentActions = [...this.documentActions, ...actions];\n } else if (typeof actions === 'function') {\n this.documentActions = actions(this.documentActions);\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addDocumentAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n addDocumentHeaderAction(actions: DescriptionReducer<HeaderActionComponent>): void;\n addDocumentHeaderAction(actions: HeaderActionComponent[]): void;\n addDocumentHeaderAction(\n actions: DescriptionReducer<HeaderActionComponent> | HeaderActionComponent[]\n ) {\n if (Array.isArray(actions)) {\n this.headerActions = [...this.headerActions, ...actions];\n } else if (typeof actions === 'function') {\n this.headerActions = actions(this.headerActions);\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addDocumentHeaderAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n addBulkAction(actions: DescriptionReducer<BulkActionComponent>): void;\n addBulkAction(actions: BulkActionComponent[]): void;\n addBulkAction(actions: DescriptionReducer<BulkActionComponent> | BulkActionComponent[]) {\n if (Array.isArray(actions)) {\n this.bulkActions = [...this.bulkActions, ...actions];\n } else if (typeof actions === 'function') {\n this.bulkActions = actions(this.bulkActions);\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addBulkAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n get config() {\n return {\n id: PLUGIN_ID,\n name: 'Content Manager',\n injectionZones: INJECTION_ZONES,\n apis: {\n addBulkAction: this.addBulkAction.bind(this),\n addDocumentAction: this.addDocumentAction.bind(this),\n addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),\n addEditViewSidePanel: this.addEditViewSidePanel.bind(this),\n addRichTextBlocks: this.addRichTextBlocks.bind(this),\n getBulkActions: () => this.bulkActions,\n getDocumentActions: (position?: DocumentActionPosition) => {\n /**\n * When possible, pre-filter the actions by the components static position property.\n * This avoids rendering the actions in multiple places where they weren't displayed,\n * which wasn't visible but created issues with useEffect for instance.\n * The response should still be filtered by the position, as the static property is new\n * and not mandatory to avoid a breaking change.\n */\n if (position) {\n return this.documentActions.filter((action) => {\n return action.position == undefined || [action.position].flat().includes(position);\n });\n }\n\n return this.documentActions;\n },\n getEditViewSidePanels: () => this.editViewSidePanels,\n getHeaderActions: () => this.headerActions,\n getRichTextBlocks: () => ({ ...this.richTextBlocksStore }),\n },\n } satisfies PluginConfig;\n }\n}\n\n/* -------------------------------------------------------------------------------------------------\n * getPrintableType\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Gets the human-friendly printable type name for the given value, for instance it will yield\n * `array` instead of `object`, as the native `typeof` operator would do.\n */\nconst getPrintableType = (value: unknown): string => {\n const nativeType = typeof value;\n\n if (nativeType === 'object') {\n if (value === null) return 'null';\n if (Array.isArray(value)) return 'array';\n if (value instanceof Object && value.constructor.name !== 'Object') {\n return value.constructor.name;\n }\n }\n\n return nativeType;\n};\n\nexport { ContentManagerPlugin };\nexport type {\n EditViewContext,\n ListViewContext,\n BulkActionComponent,\n BulkActionComponentProps,\n BulkActionDescription,\n DescriptionComponent,\n DescriptionReducer,\n PanelComponentProps,\n PanelComponent,\n PanelDescription,\n DocumentActionComponent,\n DocumentActionDescription,\n DocumentActionProps,\n HeaderActionComponent,\n HeaderActionDescription,\n HeaderActionProps,\n};\n"],"names":["ContentManagerPlugin","addRichTextBlocks","blocks","result","richTextBlocksStore","Error","getPrintableType","addEditViewSidePanel","panels","Array","isArray","editViewSidePanels","addDocumentAction","actions","documentActions","addDocumentHeaderAction","headerActions","addBulkAction","bulkActions","config","id","PLUGIN_ID","name","injectionZones","INJECTION_ZONES","apis","bind","getBulkActions","getDocumentActions","position","filter","action","undefined","flat","includes","getEditViewSidePanels","getHeaderActions","getRichTextBlocks","defaultBlocksStore","DEFAULT_BULK_ACTIONS","DEFAULT_ACTIONS","DEFAULT_TABLE_ROW_ACTIONS","DEFAULT_HEADER_ACTIONS","ActionsPanel","value","nativeType","Object"],"mappings":";;;;;;;;;AAoHA;;AAEkG,qGAElG,MAAMA,oBAAAA,CAAAA;AAqBJC,IAAAA,iBAAAA,CAAkBC,MAAwE,EAAE;QAC1F,IAAI,OAAOA,WAAW,UAAA,EAAY;AAChC,YAAA,MAAMC,MAAAA,GAASD,MAAAA,CAAO,IAAI,CAACE,mBAAmB,CAAA;AAC9C,YAAA,IAAI,OAAOD,MAAAA,KAAW,QAAA,IAAYA,MAAAA,KAAW,IAAA,EAAM;AACjD,gBAAA,MAAM,IAAIE,KAAAA,CACR,CAAC,oGAAoG,EAAEC,iBAAiBH,MAAAA,CAAAA,CAAAA,CAAS,CAAA;AAErI,YAAA;YACA,IAAI,CAACC,mBAAmB,GAAGD,MAAAA;QAC7B,CAAA,MAAO,IAAI,OAAOD,MAAAA,KAAW,QAAA,EAAU;YACrC,IAAI,CAACE,mBAAmB,GAAG;gBAAE,GAAG,IAAI,CAACA,mBAAmB;AAAE,gBAAA,GAAGF;AAAO,aAAA;QACtE,CAAA,MAAO;AACL,YAAA,MAAM,IAAIG,KAAAA,CACR,CAAC,oGAAoG,EAAEC,iBACrGJ,MAAAA,CAAAA,CAAAA,CACC,CAAA;AAEP,QAAA;AACF,IAAA;AAIAK,IAAAA,oBAAAA,CAAqBC,MAA6D,EAAE;QAClF,IAAIC,KAAAA,CAAMC,OAAO,CAACF,MAAAA,CAAAA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AAQ,OAAO,OAAA;AACjC,QAAA,IAAIA,iBAAiBE,MAAAA,IAAUF,KAAAA,CAAM,WAAW,CAACtB,IAAI,KAAK,QAAA,EAAU;YAClE,OAAOsB,KAAAA,CAAM,WAAW,CAACtB,IAAI;AAC/B,QAAA;AACF,IAAA;IAEA,OAAOuB,UAAAA;AACT,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"content-manager.mjs","sources":["../../admin/src/content-manager.ts"],"sourcesContent":["/* eslint-disable check-file/filename-naming-convention */\n\nimport { INJECTION_ZONES } from './components/InjectionZone';\nimport { PLUGIN_ID } from './constants/plugin';\nimport {\n DEFAULT_ACTIONS,\n type DocumentActionPosition,\n type DocumentActionDescription,\n} from './pages/EditView/components/DocumentActions';\nimport { RichTextBlocksStore } from './pages/EditView/components/FormInputs/BlocksInput/BlocksEditor';\nimport { defaultBlocksStore } from './pages/EditView/components/FormInputs/BlocksInput/DefaultBlocksStore';\nimport {\n DEFAULT_HEADER_ACTIONS,\n type HeaderActionDescription,\n} from './pages/EditView/components/Header';\nimport { ActionsPanel, type PanelDescription } from './pages/EditView/components/Panels';\nimport {\n DEFAULT_BULK_ACTIONS,\n type BulkActionDescription,\n} from './pages/ListView/components/BulkActions/Actions';\nimport { DEFAULT_TABLE_ROW_ACTIONS } from './pages/ListView/components/TableActions';\n\nimport type { Document } from './hooks/useDocument';\nimport type { DocumentMetadata } from '../../shared/contracts/collection-types';\nimport type { DescriptionComponent, PluginConfig } from '@strapi/admin/strapi-admin';\n\n/* -------------------------------------------------------------------------------------------------\n * Configuration Types\n * -----------------------------------------------------------------------------------------------*/\n\ntype DescriptionReducer<Config extends object> = (prev: Config[]) => Config[];\ntype DescriptionObjReducer<Config extends object> = (prev: Config) => Config;\n\ninterface EditViewContext {\n /**\n * This will ONLY be null, if the content-type\n * does not have draft & published enabled.\n */\n activeTab: 'draft' | 'published' | null;\n /**\n * Will be either 'single-types' | 'collection-types'\n */\n collectionType: string;\n /**\n * this will be undefined if someone is creating an entry.\n */\n document?: Document;\n /**\n * this will be undefined if someone is creating an entry.\n */\n documentId?: string;\n /**\n * this will be undefined if someone is creating an entry.\n */\n meta?: DocumentMetadata;\n /**\n * The current content-type's model.\n */\n model: string;\n}\n\ninterface ListViewContext {\n /**\n * Will be either 'single-types' | 'collection-types'\n */\n collectionType: string;\n /**\n * The current selected documents in the table\n */\n documents: Document[];\n /**\n * The current content-type's model.\n */\n model: string;\n}\n\ninterface PanelComponentProps extends EditViewContext {}\n\ninterface PanelComponent extends DescriptionComponent<PanelComponentProps, PanelDescription> {\n /**\n * The defaults are added by Strapi only, if you're providing your own component,\n * you do not need to provide this.\n */\n type?: 'actions' | 'releases';\n}\n\ninterface DocumentActionProps extends EditViewContext {}\n\ninterface DocumentActionComponent\n extends DescriptionComponent<DocumentActionProps, DocumentActionDescription> {\n type?:\n | 'clone'\n | 'configure-the-view'\n | 'delete'\n | 'discard'\n | 'edit'\n | 'edit-the-model'\n | 'history'\n | 'publish'\n | 'unpublish'\n | 'update';\n position?: DocumentActionDescription['position'];\n}\n\ninterface HeaderActionProps extends EditViewContext {}\n\ninterface HeaderActionComponent\n extends DescriptionComponent<HeaderActionProps, HeaderActionDescription> {}\n\ninterface BulkActionComponentProps extends ListViewContext {}\n\ninterface BulkActionComponent\n extends DescriptionComponent<BulkActionComponentProps, BulkActionDescription> {\n type?: 'delete' | 'publish' | 'unpublish';\n}\n\n/* -------------------------------------------------------------------------------------------------\n * ContentManager plugin\n * -----------------------------------------------------------------------------------------------*/\n\nclass ContentManagerPlugin {\n /**\n * The following properties are the stored ones provided by any plugins registering with\n * the content-manager. The function calls however, need to be called at runtime in the\n * application, so instead we collate them and run them later with the complete list incl.\n * ones already registered & the context of the view.\n */\n richTextBlocksStore: RichTextBlocksStore = { ...defaultBlocksStore };\n bulkActions: BulkActionComponent[] = [...DEFAULT_BULK_ACTIONS];\n documentActions: DocumentActionComponent[] = [\n ...DEFAULT_ACTIONS,\n ...DEFAULT_TABLE_ROW_ACTIONS,\n ...DEFAULT_HEADER_ACTIONS,\n ];\n editViewSidePanels: PanelComponent[] = [ActionsPanel];\n headerActions: HeaderActionComponent[] = [];\n\n constructor() {}\n\n addRichTextBlocks(blocks: RichTextBlocksStore): void;\n addRichTextBlocks(blocks: DescriptionObjReducer<RichTextBlocksStore>): void;\n addRichTextBlocks(blocks: RichTextBlocksStore | DescriptionObjReducer<RichTextBlocksStore>) {\n if (typeof blocks === 'function') {\n const result = blocks(this.richTextBlocksStore);\n if (typeof result !== 'object' || result === null) {\n throw new Error(\n `Expected the \\`blocks\\` passed to \\`addRichTextBlocks\\` to be an object or a function, but received ${getPrintableType(result)}`\n );\n }\n this.richTextBlocksStore = result;\n } else if (typeof blocks === 'object') {\n this.richTextBlocksStore = { ...this.richTextBlocksStore, ...blocks };\n } else {\n throw new Error(\n `Expected the \\`blocks\\` passed to \\`addRichTextBlocks\\` to be an object or a function, but received ${getPrintableType(\n blocks\n )}`\n );\n }\n }\n\n addEditViewSidePanel(panels: DescriptionReducer<PanelComponent>): void;\n addEditViewSidePanel(panels: PanelComponent[]): void;\n addEditViewSidePanel(panels: DescriptionReducer<PanelComponent> | PanelComponent[]) {\n if (Array.isArray(panels)) {\n validateDescriptionItems(panels, 'addEditViewSidePanel', 'panels');\n this.editViewSidePanels = [...this.editViewSidePanels, ...panels];\n } else if (typeof panels === 'function') {\n const result = panels(this.editViewSidePanels);\n validateDescriptionItems(result, 'addEditViewSidePanel', 'panels');\n this.editViewSidePanels = result;\n } else {\n throw new Error(\n `Expected the \\`panels\\` passed to \\`addEditViewSidePanel\\` to be an array or a function, but received ${getPrintableType(\n panels\n )}`\n );\n }\n }\n\n addDocumentAction(actions: DescriptionReducer<DocumentActionComponent>): void;\n addDocumentAction(actions: DocumentActionComponent[]): void;\n addDocumentAction(\n actions: DescriptionReducer<DocumentActionComponent> | DocumentActionComponent[]\n ) {\n if (Array.isArray(actions)) {\n validateDescriptionItems(actions, 'addDocumentAction', 'actions');\n this.documentActions = [...this.documentActions, ...actions];\n } else if (typeof actions === 'function') {\n const result = actions(this.documentActions);\n validateDescriptionItems(result, 'addDocumentAction', 'actions');\n this.documentActions = result;\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addDocumentAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n addDocumentHeaderAction(actions: DescriptionReducer<HeaderActionComponent>): void;\n addDocumentHeaderAction(actions: HeaderActionComponent[]): void;\n addDocumentHeaderAction(\n actions: DescriptionReducer<HeaderActionComponent> | HeaderActionComponent[]\n ) {\n if (Array.isArray(actions)) {\n validateDescriptionItems(actions, 'addDocumentHeaderAction', 'actions');\n this.headerActions = [...this.headerActions, ...actions];\n } else if (typeof actions === 'function') {\n const result = actions(this.headerActions);\n validateDescriptionItems(result, 'addDocumentHeaderAction', 'actions');\n this.headerActions = result;\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addDocumentHeaderAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n addBulkAction(actions: DescriptionReducer<BulkActionComponent>): void;\n addBulkAction(actions: BulkActionComponent[]): void;\n addBulkAction(actions: DescriptionReducer<BulkActionComponent> | BulkActionComponent[]) {\n if (Array.isArray(actions)) {\n validateDescriptionItems(actions, 'addBulkAction', 'actions');\n this.bulkActions = [...this.bulkActions, ...actions];\n } else if (typeof actions === 'function') {\n const result = actions(this.bulkActions);\n validateDescriptionItems(result, 'addBulkAction', 'actions');\n this.bulkActions = result;\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addBulkAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n get config() {\n return {\n id: PLUGIN_ID,\n name: 'Content Manager',\n injectionZones: INJECTION_ZONES,\n apis: {\n addBulkAction: this.addBulkAction.bind(this),\n addDocumentAction: this.addDocumentAction.bind(this),\n addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),\n addEditViewSidePanel: this.addEditViewSidePanel.bind(this),\n addRichTextBlocks: this.addRichTextBlocks.bind(this),\n getBulkActions: () => this.bulkActions,\n getDocumentActions: (position?: DocumentActionPosition) => {\n /**\n * When possible, pre-filter the actions by the components static position property.\n * This avoids rendering the actions in multiple places where they weren't displayed,\n * which wasn't visible but created issues with useEffect for instance.\n * The response should still be filtered by the position, as the static property is new\n * and not mandatory to avoid a breaking change.\n */\n if (position) {\n return this.documentActions.filter((action) => {\n return action.position == undefined || [action.position].flat().includes(position);\n });\n }\n\n return this.documentActions;\n },\n getEditViewSidePanels: () => this.editViewSidePanels,\n getHeaderActions: () => this.headerActions,\n getRichTextBlocks: () => ({ ...this.richTextBlocksStore }),\n },\n } satisfies PluginConfig;\n }\n}\n\n/* -------------------------------------------------------------------------------------------------\n * getPrintableType\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Gets the human-friendly printable type name for the given value, for instance it will yield\n * `array` instead of `object`, as the native `typeof` operator would do.\n */\nconst getPrintableType = (value: unknown): string => {\n const nativeType = typeof value;\n\n if (nativeType === 'object') {\n if (value === null) return 'null';\n if (Array.isArray(value)) return 'array';\n if (value instanceof Object && value.constructor.name !== 'Object') {\n return value.constructor.name;\n }\n }\n\n return nativeType;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * validateDescriptionItems\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Descriptions must be functions (they're rendered as components so hooks can be used\n * inside them), not plain objects. Passing a plain object crashes deep inside\n * `DescriptionComponentRenderer` with an unhelpful `description is not a function` error, so we\n * validate eagerly here to fail fast with a clear message pointing at the offending API call.\n */\nconst validateDescriptionItems = (items: unknown[], apiName: string, argName: string): void => {\n items.forEach((item, index) => {\n if (typeof item !== 'function') {\n throw new Error(\n `Expected every item in the \\`${argName}\\` array passed to \\`${apiName}\\` to be a function that returns a description object, but received ${getPrintableType(\n item\n )} at index ${index}. Did you forget to wrap it in a function, e.g. \\`() => ({ ...yourAction })\\`?`\n );\n }\n });\n};\n\nexport { ContentManagerPlugin };\nexport type {\n EditViewContext,\n ListViewContext,\n BulkActionComponent,\n BulkActionComponentProps,\n BulkActionDescription,\n DescriptionComponent,\n DescriptionReducer,\n PanelComponentProps,\n PanelComponent,\n PanelDescription,\n DocumentActionComponent,\n DocumentActionDescription,\n DocumentActionProps,\n HeaderActionComponent,\n HeaderActionDescription,\n HeaderActionProps,\n};\n"],"names":["ContentManagerPlugin","addRichTextBlocks","blocks","result","richTextBlocksStore","Error","getPrintableType","addEditViewSidePanel","panels","Array","isArray","validateDescriptionItems","editViewSidePanels","addDocumentAction","actions","documentActions","addDocumentHeaderAction","headerActions","addBulkAction","bulkActions","config","id","PLUGIN_ID","name","injectionZones","INJECTION_ZONES","apis","bind","getBulkActions","getDocumentActions","position","filter","action","undefined","flat","includes","getEditViewSidePanels","getHeaderActions","getRichTextBlocks","defaultBlocksStore","DEFAULT_BULK_ACTIONS","DEFAULT_ACTIONS","DEFAULT_TABLE_ROW_ACTIONS","DEFAULT_HEADER_ACTIONS","ActionsPanel","value","nativeType","Object","items","apiName","argName","forEach","item","index"],"mappings":";;;;;;;;;AAoHA;;AAEkG,qGAElG,MAAMA,oBAAAA,CAAAA;AAqBJC,IAAAA,iBAAAA,CAAkBC,MAAwE,EAAE;QAC1F,IAAI,OAAOA,WAAW,UAAA,EAAY;AAChC,YAAA,MAAMC,MAAAA,GAASD,MAAAA,CAAO,IAAI,CAACE,mBAAmB,CAAA;AAC9C,YAAA,IAAI,OAAOD,MAAAA,KAAW,QAAA,IAAYA,MAAAA,KAAW,IAAA,EAAM;AACjD,gBAAA,MAAM,IAAIE,KAAAA,CACR,CAAC,oGAAoG,EAAEC,iBAAiBH,MAAAA,CAAAA,CAAAA,CAAS,CAAA;AAErI,YAAA;YACA,IAAI,CAACC,mBAAmB,GAAGD,MAAAA;QAC7B,CAAA,MAAO,IAAI,OAAOD,MAAAA,KAAW,QAAA,EAAU;YACrC,IAAI,CAACE,mBAAmB,GAAG;gBAAE,GAAG,IAAI,CAACA,mBA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AiBC,OAAAA,GAAAA;IACnEF,KAAAA,CAAMG,OAAO,CAAC,CAACC,IAAAA,EAAMC,KAAAA,GAAAA;QACnB,IAAI,OAAOD,SAAS,UAAA,EAAY;AAC9B,YAAA,MAAM,IAAI/C,KAAAA,CACR,CAAC,6BAA6B,EAAE6C,QAAQ,qBAAqB,EAAED,OAAAA,CAAQ,oEAAoE,EAAE3C,gBAAAA,CAC3I8C,IAAAA,CAAAA,CACA,UAAU,EAAEC,KAAAA,CAAM,8EAA8E,CAAC,CAAA;AAEvG,QAAA;AACF,IAAA,CAAA,CAAA;AACF,CAAA;;;;"}
|
package/dist/admin/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('prismjs');
|
|
5
6
|
var Icons = require('@strapi/icons');
|
|
6
7
|
var plugin = require('./constants/plugin.js');
|
|
7
8
|
var contentManager = require('./content-manager.js');
|
|
@@ -10,7 +11,6 @@ var reducers = require('./modules/reducers.js');
|
|
|
10
11
|
var index$2 = require('./preview/index.js');
|
|
11
12
|
var router = require('./router.js');
|
|
12
13
|
var translations = require('./utils/translations.js');
|
|
13
|
-
require('prismjs');
|
|
14
14
|
var api = require('./utils/api.js');
|
|
15
15
|
var RelativeTime = require('./components/RelativeTime.js');
|
|
16
16
|
var DocumentStatus = require('./pages/EditView/components/DocumentStatus.js');
|
package/dist/admin/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../admin/src/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../admin/src/index.ts"],"sourcesContent":["// NOTE: preload before content-manager so Blocks code-editor prism language plugins see global Prism.\nimport 'prismjs';\n\nimport { CheckCircle, Feather, Pencil, PuzzlePiece } from '@strapi/icons';\n\nimport { PLUGIN_ID } from './constants/plugin';\nimport { ContentManagerPlugin } from './content-manager';\nimport { historyAdmin } from './history';\nimport { reducer } from './modules/reducers';\nimport { previewAdmin } from './preview';\nimport { routes } from './router';\nimport { prefixPluginTranslations } from './utils/translations';\n\nimport type { StrapiApp, WidgetArgs } from '@strapi/admin/strapi-admin';\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n register(app: StrapiApp) {\n const cm = new ContentManagerPlugin();\n\n app.addReducers({\n [PLUGIN_ID]: reducer,\n });\n\n app.addMenuLink({\n to: PLUGIN_ID,\n icon: Feather,\n intlLabel: {\n id: `content-manager.plugin.name`,\n defaultMessage: 'Content Manager',\n },\n permissions: [],\n position: 1,\n });\n\n app.router.addRoute({\n path: 'content-manager/*',\n lazy: async () => {\n const { Layout } = await import('./layout');\n\n return {\n Component: Layout,\n };\n },\n children: routes,\n });\n\n app.registerPlugin(cm.config);\n\n app.widgets.register((widgets: WidgetArgs[]) => {\n const lastEditedWidget: WidgetArgs = {\n icon: Pencil,\n title: {\n id: `${PLUGIN_ID}.widget.last-edited.title`,\n defaultMessage: 'Last edited entries',\n },\n component: async () => {\n const { LastEditedWidget } = await import('./components/Widgets');\n return LastEditedWidget;\n },\n pluginId: PLUGIN_ID,\n id: 'last-edited-entries',\n permissions: [{ action: 'plugin::content-manager.explorer.read' }],\n };\n const lastPublishedWidget: WidgetArgs = {\n icon: CheckCircle,\n title: {\n id: `${PLUGIN_ID}.widget.last-published.title`,\n defaultMessage: 'Last published entries',\n },\n component: async () => {\n const { LastPublishedWidget } = await import('./components/Widgets');\n return LastPublishedWidget;\n },\n pluginId: PLUGIN_ID,\n id: 'last-published-entries',\n permissions: [{ action: 'plugin::content-manager.explorer.read' }],\n };\n const entriesWidget: WidgetArgs = {\n icon: PuzzlePiece,\n title: {\n id: `${PLUGIN_ID}.widget.chart-entries.title`,\n defaultMessage: 'Entries',\n },\n component: async () => {\n const { ChartEntriesWidget } = await import('./components/Widgets');\n return ChartEntriesWidget;\n },\n pluginId: PLUGIN_ID,\n id: 'chart-entries',\n permissions: [{ action: 'plugin::content-manager.explorer.read' }],\n };\n\n const profileInfoIndex = widgets.findIndex(\n (widget) => widget.id === 'profile-info' && widget.pluginId === 'admin'\n );\n\n // Insert chart-entries after the profile-info widget\n if (profileInfoIndex !== -1) {\n const newWidgets: WidgetArgs[] = [...widgets];\n newWidgets.splice(profileInfoIndex + 1, 0, entriesWidget);\n return [lastEditedWidget, lastPublishedWidget, ...newWidgets];\n }\n\n // Fallback: add to the end if the target widget aren't found\n return [lastEditedWidget, lastPublishedWidget, ...widgets, entriesWidget];\n });\n },\n bootstrap(app: StrapiApp) {\n if (typeof historyAdmin.bootstrap === 'function') {\n historyAdmin.bootstrap(app);\n }\n if (typeof previewAdmin.bootstrap === 'function') {\n previewAdmin.bootstrap(app);\n }\n },\n async registerTrads({ locales }: { locales: string[] }) {\n const importedTrads = await Promise.all(\n locales.map((locale) => {\n return import(`./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, PLUGIN_ID),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n\n return Promise.resolve(importedTrads);\n },\n};\n\nexport * from './exports';\n"],"names":["register","app","cm","ContentManagerPlugin","addReducers","PLUGIN_ID","reducer","addMenuLink","to","icon","Feather","intlLabel","id","defaultMessage","permissions","position","router","addRoute","path","lazy","Layout","Component","children","routes","registerPlugin","config","widgets","lastEditedWidget","Pencil","title","component","LastEditedWidget","pluginId","action","lastPublishedWidget","CheckCircle","LastPublishedWidget","entriesWidget","PuzzlePiece","ChartEntriesWidget","profileInfoIndex","findIndex","widget","newWidgets","splice","bootstrap","historyAdmin","previewAdmin","registerTrads","locales","importedTrads","Promise","all","map","locale","then","default","data","prefixPluginTranslations","catch","resolve"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA;AACA,YAAe;AACbA,IAAAA,QAAAA,CAAAA,CAASC,GAAc,EAAA;AACrB,QAAA,MAAMC,KAAK,IAAIC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BAAAA,IAAAA,EAAM,EAAC;AACPH,oBAAAA;AACF,iBAAA;AACF,YAAA,CAAA,CAAA;AACJ,QAAA,CAAA,CAAA,CAAA;QAGF,OAAOH,OAAAA,CAAQS,OAAO,CAACV,aAAAA,CAAAA;AACzB,IAAA;AACF,CAAA;;;;;;;;;;;;;"}
|
package/dist/admin/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import 'prismjs';
|
|
1
2
|
import { Feather, Pencil, CheckCircle, PuzzlePiece } from '@strapi/icons';
|
|
2
3
|
import { PLUGIN_ID } from './constants/plugin.mjs';
|
|
3
4
|
import { ContentManagerPlugin } from './content-manager.mjs';
|
|
@@ -6,7 +7,6 @@ import { reducer } from './modules/reducers.mjs';
|
|
|
6
7
|
import { previewAdmin } from './preview/index.mjs';
|
|
7
8
|
import { routes } from './router.mjs';
|
|
8
9
|
import { prefixPluginTranslations } from './utils/translations.mjs';
|
|
9
|
-
import 'prismjs';
|
|
10
10
|
export { buildValidParams } from './utils/api.mjs';
|
|
11
11
|
export { RelativeTime } from './components/RelativeTime.mjs';
|
|
12
12
|
export { DocumentStatus } from './pages/EditView/components/DocumentStatus.mjs';
|
package/dist/admin/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../admin/src/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../admin/src/index.ts"],"sourcesContent":["// NOTE: preload before content-manager so Blocks code-editor prism language plugins see global Prism.\nimport 'prismjs';\n\nimport { CheckCircle, Feather, Pencil, PuzzlePiece } from '@strapi/icons';\n\nimport { PLUGIN_ID } from './constants/plugin';\nimport { ContentManagerPlugin } from './content-manager';\nimport { historyAdmin } from './history';\nimport { reducer } from './modules/reducers';\nimport { previewAdmin } from './preview';\nimport { routes } from './router';\nimport { prefixPluginTranslations } from './utils/translations';\n\nimport type { StrapiApp, WidgetArgs } from '@strapi/admin/strapi-admin';\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n register(app: StrapiApp) {\n const cm = new ContentManagerPlugin();\n\n app.addReducers({\n [PLUGIN_ID]: reducer,\n });\n\n app.addMenuLink({\n to: PLUGIN_ID,\n icon: Feather,\n intlLabel: {\n id: `content-manager.plugin.name`,\n defaultMessage: 'Content Manager',\n },\n permissions: [],\n position: 1,\n });\n\n app.router.addRoute({\n path: 'content-manager/*',\n lazy: async () => {\n const { Layout } = await import('./layout');\n\n return {\n Component: Layout,\n };\n },\n children: routes,\n });\n\n app.registerPlugin(cm.config);\n\n app.widgets.register((widgets: WidgetArgs[]) => {\n const lastEditedWidget: WidgetArgs = {\n icon: Pencil,\n title: {\n id: `${PLUGIN_ID}.widget.last-edited.title`,\n defaultMessage: 'Last edited entries',\n },\n component: async () => {\n const { LastEditedWidget } = await import('./components/Widgets');\n return LastEditedWidget;\n },\n pluginId: PLUGIN_ID,\n id: 'last-edited-entries',\n permissions: [{ action: 'plugin::content-manager.explorer.read' }],\n };\n const lastPublishedWidget: WidgetArgs = {\n icon: CheckCircle,\n title: {\n id: `${PLUGIN_ID}.widget.last-published.title`,\n defaultMessage: 'Last published entries',\n },\n component: async () => {\n const { LastPublishedWidget } = await import('./components/Widgets');\n return LastPublishedWidget;\n },\n pluginId: PLUGIN_ID,\n id: 'last-published-entries',\n permissions: [{ action: 'plugin::content-manager.explorer.read' }],\n };\n const entriesWidget: WidgetArgs = {\n icon: PuzzlePiece,\n title: {\n id: `${PLUGIN_ID}.widget.chart-entries.title`,\n defaultMessage: 'Entries',\n },\n component: async () => {\n const { ChartEntriesWidget } = await import('./components/Widgets');\n return ChartEntriesWidget;\n },\n pluginId: PLUGIN_ID,\n id: 'chart-entries',\n permissions: [{ action: 'plugin::content-manager.explorer.read' }],\n };\n\n const profileInfoIndex = widgets.findIndex(\n (widget) => widget.id === 'profile-info' && widget.pluginId === 'admin'\n );\n\n // Insert chart-entries after the profile-info widget\n if (profileInfoIndex !== -1) {\n const newWidgets: WidgetArgs[] = [...widgets];\n newWidgets.splice(profileInfoIndex + 1, 0, entriesWidget);\n return [lastEditedWidget, lastPublishedWidget, ...newWidgets];\n }\n\n // Fallback: add to the end if the target widget aren't found\n return [lastEditedWidget, lastPublishedWidget, ...widgets, entriesWidget];\n });\n },\n bootstrap(app: StrapiApp) {\n if (typeof historyAdmin.bootstrap === 'function') {\n historyAdmin.bootstrap(app);\n }\n if (typeof previewAdmin.bootstrap === 'function') {\n previewAdmin.bootstrap(app);\n }\n },\n async registerTrads({ locales }: { locales: string[] }) {\n const importedTrads = await Promise.all(\n locales.map((locale) => {\n return import(`./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, PLUGIN_ID),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n\n return Promise.resolve(importedTrads);\n },\n};\n\nexport * from './exports';\n"],"names":["register","app","cm","ContentManagerPlugin","addReducers","PLUGIN_ID","reducer","addMenuLink","to","icon","Feather","intlLabel","id","defaultMessage","permissions","position","router","addRoute","path","lazy","Layout","Component","children","routes","registerPlugin","config","widgets","lastEditedWidget","Pencil","title","component","LastEditedWidget","pluginId","action","lastPublishedWidget","CheckCircle","LastPublishedWidget","entriesWidget","PuzzlePiece","ChartEntriesWidget","profileInfoIndex","findIndex","widget","newWidgets","splice","bootstrap","historyAdmin","previewAdmin","registerTrads","locales","importedTrads","Promise","all","map","locale","then","default","data","prefixPluginTranslations","catch","resolve"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA;AACA,YAAe;AACbA,IAAAA,QAAAA,CAAAA,CAASC,GAAc,EAAA;AACrB,QAAA,MAAMC,KAAK,IAAIC,oBAAAA,EAAAA;AAEfF,QAAAA,GAAAA,CAAIG,WAAW,CAAC;AACd,YAAA,CAACC,YAAYC;AACf,SAAA,CAAA;AAEAL,QAAAA,GAAAA,CAAIM,WAAW,CAAC;YACdC,EAAAA,EA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AAA;;;;"}
|
|
@@ -71,14 +71,26 @@ function useBlocksEditorContext(consumerName) {
|
|
|
71
71
|
valueUpdatesCount.current += 1;
|
|
72
72
|
// If the 2 refs are not equal, it means the value was updated from outside
|
|
73
73
|
if (valueUpdatesCount.current !== slateUpdatesCount.current) {
|
|
74
|
+
// Bring the 2 refs back in sync
|
|
75
|
+
slateUpdatesCount.current = valueUpdatesCount.current;
|
|
76
|
+
// The update may just be an echo of the editor's own content coming back through the form
|
|
77
|
+
// (e.g. the debounced sync, or a re-render while document queries settle). Remounting in
|
|
78
|
+
// that case is pointless and destructive: it wipes pending input and the DOM under the
|
|
79
|
+
// user's caret. Only force a remount when the content is actually different.
|
|
80
|
+
const externalState = value?.length ? normalizeBlocksState(editor, value) : null;
|
|
81
|
+
const editorState = normalizeBlocksState(editor, editor.children);
|
|
82
|
+
if (JSON.stringify(externalState) === JSON.stringify(editorState)) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
// The remount reuses the same editor instance, so a selection pointing into the old
|
|
86
|
+
// content would survive it and crash slate-react's toDOMPoint when the new content is
|
|
87
|
+
// shorter. Drop the selection before swapping the children.
|
|
74
88
|
if (editor.selection) {
|
|
75
89
|
slate.Transforms.deselect(editor);
|
|
76
90
|
}
|
|
77
|
-
//
|
|
91
|
+
// Change the key to force a rerender of the Slate editor,
|
|
78
92
|
// which will pick up the new value through its initialValue prop
|
|
79
93
|
setKey((previousKey)=>previousKey + 1);
|
|
80
|
-
// Then bring the 2 refs back in sync
|
|
81
|
-
slateUpdatesCount.current = valueUpdatesCount.current;
|
|
82
94
|
}
|
|
83
95
|
}, [
|
|
84
96
|
editor,
|
|
@@ -128,14 +140,13 @@ const BlocksEditor = /*#__PURE__*/ React__namespace.forwardRef(({ disabled = fal
|
|
|
128
140
|
}
|
|
129
141
|
clearTimeout(debounceTimeout.current);
|
|
130
142
|
debounceTimeout.current = null;
|
|
131
|
-
|
|
143
|
+
// Counter was already bumped when the AST changed; only push form state here.
|
|
132
144
|
// Ensure Strapi Form state updates before the next event (e.g. Save click) reads values.
|
|
133
145
|
reactDom.flushSync(()=>{
|
|
134
146
|
onChange(name, normalizeBlocksState(editor, editor.children));
|
|
135
147
|
});
|
|
136
148
|
}, [
|
|
137
149
|
editor,
|
|
138
|
-
incrementSlateUpdatesCount,
|
|
139
150
|
name,
|
|
140
151
|
onChange
|
|
141
152
|
]);
|
|
@@ -147,12 +158,17 @@ const BlocksEditor = /*#__PURE__*/ React__namespace.forwardRef(({ disabled = fal
|
|
|
147
158
|
* state in sync with it in order to make sure that things like the "modified" state
|
|
148
159
|
* isn't broken. Updating the whole state on every change is very expensive however,
|
|
149
160
|
* so we debounce calls to onChange to mitigate input lag.
|
|
150
|
-
|
|
161
|
+
*
|
|
162
|
+
* Bump the reset-key counter immediately (not inside the debounce). Otherwise any
|
|
163
|
+
* value-prop identity change during the 300ms window — e.g. clicking the blocks
|
|
164
|
+
* toolbar — looks like an external update with stale empty form state and remounts
|
|
165
|
+
* the editor, wiping the pending input (blocks e2e flake).
|
|
166
|
+
*/ incrementSlateUpdatesCount();
|
|
167
|
+
if (debounceTimeout.current) {
|
|
151
168
|
clearTimeout(debounceTimeout.current);
|
|
152
169
|
}
|
|
153
170
|
// Set a new debounce timeout
|
|
154
171
|
debounceTimeout.current = setTimeout(()=>{
|
|
155
|
-
incrementSlateUpdatesCount();
|
|
156
172
|
// Normalize the state (empty editor becomes null)
|
|
157
173
|
onChange(name, normalizeBlocksState(editor, state));
|
|
158
174
|
debounceTimeout.current = null;
|