UNPKG

datocms-plugin-sdk

Version:
1,258 lines 142 kB
{ "hooks": { "validateManualFieldExtensionParameters": { "name": "validateManualFieldExtensionParameters", "comment": { "markdownText": "This function will be called each time the configuration object changes. It\nmust return an object containing possible validation errors.", "tag": "manualFieldExtensions" }, "nonCtxArguments": [ { "name": "fieldExtensionId", "typeName": "string" }, { "name": "parameters", "typeName": "Record<string, unknown>" } ], "returnType": "Record<string, unknown> | Promise<Record<string, unknown>>", "location": { "filePath": "src/hooks/validateManualFieldExtensionParameters.ts", "lineNumber": 10 } }, "uploadsDropdownActions": { "name": "uploadsDropdownActions", "comment": { "markdownText": "This function lets you set up custom actions (or groups of actions) that\nshow up when the user:\n\n* selects multiple assets in the Media Area for batch operations, or\n* opens up a specific asset from the Media Area.\n\nThe `executeUploadsDropdownAction()` hook will be triggered once the user\nclicks on one of the defined actions.", "tag": "dropdownActions" }, "nonCtxArguments": [], "ctxArgument": { "type": "Ctx", "additionalProperties": [], "additionalMethods": [] }, "returnType": "Array<DropdownAction | DropdownActionGroup>", "location": { "filePath": "src/hooks/uploadsDropdownActions.ts", "lineNumber": 17 } }, "uploadSidebars": { "name": "uploadSidebars", "comment": { "markdownText": "Use this function to declare new sidebar to be shown when the user opens\nup an asset in the Media Area.", "tag": "sidebarPanels" }, "nonCtxArguments": [], "ctxArgument": { "type": "Ctx", "additionalProperties": [], "additionalMethods": [] }, "returnType": "UploadSidebar[]", "location": { "filePath": "src/hooks/uploadSidebars.ts", "lineNumber": 17 } }, "uploadSidebarPanels": { "name": "uploadSidebarPanels", "comment": { "markdownText": "Use this function to declare new sidebar panels to be shown when the user\nopens up an asset in the Media Area.", "tag": "sidebarPanels" }, "nonCtxArguments": [], "ctxArgument": { "type": "Ctx", "additionalProperties": [], "additionalMethods": [] }, "returnType": "UploadSidebarPanel[]", "location": { "filePath": "src/hooks/uploadSidebarPanels.ts", "lineNumber": 19 } }, "settingsAreaSidebarItemGroups": { "name": "settingsAreaSidebarItemGroups", "comment": { "markdownText": "Use this function to declare new navigation sections in the Settings Area\nsidebar.", "tag": "pages" }, "nonCtxArguments": [], "ctxArgument": { "type": "Ctx", "additionalProperties": [], "additionalMethods": [] }, "returnType": "SettingsAreaSidebarItemGroup[]", "location": { "filePath": "src/hooks/settingsAreaSidebarItemGroups.ts", "lineNumber": 19 } }, "schemaItemTypeDropdownActions": { "name": "schemaItemTypeDropdownActions", "comment": { "markdownText": "Use this function to define custom actions (or groups of actions) for a model/block model in the Schema section.\n\nThe `executeSchemaItemTypeDropdownAction()` hook will be triggered once the user\nclicks on one of the defined actions.", "tag": "dropdownActions" }, "nonCtxArguments": [ { "name": "itemType", "typeName": "ItemType" } ], "ctxArgument": { "type": "Ctx", "additionalProperties": [], "additionalMethods": [] }, "returnType": "Array<DropdownAction | DropdownActionGroup>", "location": { "filePath": "src/hooks/schemaItemTypeDropdownActions.ts", "lineNumber": 16 } }, "renderUploadSidebarPanel": { "name": "renderUploadSidebarPanel", "comment": { "markdownText": "This function will be called when the plugin needs to render a sidebar panel\n(see the `uploadSidebarPanels` hook).", "tag": "sidebarPanels" }, "nonCtxArguments": [ { "name": "sidebarPaneId", "typeName": "string" } ], "ctxArgument": { "type": "SelfResizingPluginFrameCtx", "additionalProperties": [ { "items": { "sidebarPaneId": { "comment": { "markdownText": "The ID of the sidebar panel that needs to be rendered." }, "location": { "filePath": "src/hooks/renderUploadSidebarPanel.ts", "lineNumber": 24 }, "type": "string" }, "parameters": { "comment": { "markdownText": "The arbitrary `parameters` of the panel declared in the\n`uploadSidebarPanels` function." }, "location": { "filePath": "src/hooks/renderUploadSidebarPanel.ts", "lineNumber": 30 }, "type": "Record<string, unknown>" }, "upload": { "comment": { "markdownText": "The active asset." }, "location": { "filePath": "src/hooks/renderUploadSidebarPanel.ts", "lineNumber": 33 }, "type": "Upload" } } } ], "additionalMethods": [] }, "returnType": "void", "location": { "filePath": "src/hooks/renderUploadSidebarPanel.ts", "lineNumber": 14 } }, "renderUploadSidebar": { "name": "renderUploadSidebar", "comment": { "markdownText": "This function will be called when the plugin needs to render a sidebar (see\nthe `uploadSidebars` hook).", "tag": "sidebarPanels" }, "nonCtxArguments": [ { "name": "sidebarId", "typeName": "string" } ], "ctxArgument": { "type": "ImposedSizePluginFrameCtx", "additionalProperties": [ { "items": { "sidebarId": { "comment": { "markdownText": "The ID of the sidebar that needs to be rendered." }, "location": { "filePath": "src/hooks/renderUploadSidebar.ts", "lineNumber": 21 }, "type": "string" }, "parameters": { "comment": { "markdownText": "The arbitrary `parameters` of the declared in the `uploadSidebars`\nfunction." }, "location": { "filePath": "src/hooks/renderUploadSidebar.ts", "lineNumber": 27 }, "type": "Record<string, unknown>" }, "upload": { "comment": { "markdownText": "The active asset." }, "location": { "filePath": "src/hooks/renderUploadSidebar.ts", "lineNumber": 30 }, "type": "Upload" } } } ], "additionalMethods": [] }, "returnType": "void", "location": { "filePath": "src/hooks/renderUploadSidebar.ts", "lineNumber": 14 } }, "renderPage": { "name": "renderPage", "comment": { "markdownText": "This function will be called when the plugin needs to render a specific\npage (see the `mainNavigationTabs`, `settingsAreaSidebarItemGroups` and\n`contentAreaSidebarItems` functions).", "tag": "pages" }, "nonCtxArguments": [ { "name": "pageId", "typeName": "string" } ], "ctxArgument": { "type": "ImposedSizePluginFrameCtx", "additionalProperties": [ { "items": { "pageId": { "comment": { "markdownText": "The ID of the page that needs to be rendered." }, "location": { "filePath": "src/hooks/renderPage.ts", "lineNumber": 19 }, "type": "string" }, "location": { "comment": { "markdownText": "Current page location." }, "location": { "filePath": "src/hooks/renderPage.ts", "lineNumber": 22 }, "type": "{\n pathname: string;\n search: string;\n hash: string;\n }" } } } ], "additionalMethods": [] }, "returnType": "void", "location": { "filePath": "src/hooks/renderPage.ts", "lineNumber": 12 } }, "renderModal": { "name": "renderModal", "comment": { "markdownText": "This function will be called when the plugin requested to open a modal (see\nthe `openModal` hook).", "tag": "modals" }, "nonCtxArguments": [ { "name": "modalId", "typeName": "string" } ], "ctxArgument": { "type": "SelfResizingPluginFrameCtx", "additionalProperties": [ { "items": { "modalId": { "comment": { "markdownText": "The ID of the modal that needs to be rendered." }, "location": { "filePath": "src/hooks/renderModal.ts", "lineNumber": 17 }, "type": "string" }, "parameters": { "comment": { "markdownText": "The arbitrary `parameters` of the modal declared in the `openModal`\nfunction." }, "location": { "filePath": "src/hooks/renderModal.ts", "lineNumber": 22 }, "type": "Record<string, unknown>" } } } ], "additionalMethods": [ { "items": { "resolve": { "comment": { "markdownText": "A function to be called by the plugin to close the modal. The `openModal`\ncall will be resolved with the passed return value.", "example": "const returnValue = prompt(\n 'Please specify the value to return to the caller:',\n 'success',\n);\n\nawait ctx.resolve(returnValue);" }, "location": { "filePath": "src/hooks/renderModal.ts", "lineNumber": 40 }, "type": "(returnValue: unknown) => Promise<void>" } } } ] }, "returnType": "void", "location": { "filePath": "src/hooks/renderModal.ts", "lineNumber": 11 } }, "renderManualFieldExtensionConfigScreen": { "name": "renderManualFieldExtensionConfigScreen", "nonCtxArguments": [ { "name": "fieldExtensionId", "typeName": "string" } ], "ctxArgument": { "type": "SelfResizingPluginFrameCtx", "additionalProperties": [ { "items": { "fieldExtensionId": { "comment": { "markdownText": "The ID of the field extension for which we need to render the parameters\nform." }, "location": { "filePath": "src/hooks/renderManualFieldExtensionConfigScreen.ts", "lineNumber": 23 }, "type": "string" }, "parameters": { "comment": { "markdownText": "The current value of the parameters (you can change the value with the\n`setParameters` hook)." }, "location": { "filePath": "src/hooks/renderManualFieldExtensionConfigScreen.ts", "lineNumber": 28 }, "type": "Record<string, unknown>" }, "errors": { "comment": { "markdownText": "The current validation errors for the parameters (you can set them\nimplementing the `validateManualFieldExtensionParameters` hook)." }, "location": { "filePath": "src/hooks/renderManualFieldExtensionConfigScreen.ts", "lineNumber": 33 }, "type": "Record<string, unknown>" }, "pendingField": { "comment": { "markdownText": "The field entity that is being edited in the form." }, "location": { "filePath": "src/hooks/renderManualFieldExtensionConfigScreen.ts", "lineNumber": 36 }, "type": "PendingField" }, "itemType": { "comment": { "markdownText": "The model for the field being edited." }, "location": { "filePath": "src/hooks/renderManualFieldExtensionConfigScreen.ts", "lineNumber": 39 }, "type": "ItemType" } } } ], "additionalMethods": [ { "items": { "setParameters": { "comment": { "markdownText": "Sets a new value for the parameters.", "example": "await ctx.setParameters({ color: '#ff0000' });" }, "location": { "filePath": "src/hooks/renderManualFieldExtensionConfigScreen.ts", "lineNumber": 51 }, "type": "(params: Record<string, unknown>) => Promise<void>" } } } ] }, "returnType": "void", "location": { "filePath": "src/hooks/renderManualFieldExtensionConfigScreen.ts", "lineNumber": 9 } }, "renderItemFormSidebarPanel": { "name": "renderItemFormSidebarPanel", "comment": { "markdownText": "This function will be called when the plugin needs to render a sidebar panel\n(see the `itemFormSidebarPanels` hook).", "tag": "sidebarPanels" }, "nonCtxArguments": [ { "name": "sidebarPaneId", "typeName": "string" } ], "ctxArgument": { "type": "SelfResizingPluginFrameCtx", "additionalProperties": [ { "name": "ItemFormAdditionalProperties", "comment": { "markdownText": "These information describe the current state of the form that's being shown\nto the end-user to edit a record." }, "items": { "locale": { "comment": { "markdownText": "The currently active locale for the record." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 12 }, "type": "string" }, "item": { "comment": { "markdownText": "If an already persisted record is being edited, returns the full record\nentity." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 17 }, "type": "Item | null" }, "itemType": { "comment": { "markdownText": "The model for the record being edited." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 19 }, "type": "ItemType" }, "formValues": { "comment": { "markdownText": "The complete internal form state." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 21 }, "type": "Record<string, unknown>" }, "itemStatus": { "comment": { "markdownText": "The current status of the record being edited." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 23 }, "type": "'new' | 'draft' | 'updated' | 'published'" }, "isSubmitting": { "comment": { "markdownText": "Whether the form is currently submitting itself or not." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 25 }, "type": "boolean" }, "isFormDirty": { "comment": { "markdownText": "Whether the form has some non-persisted changes or not." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 27 }, "type": "boolean" }, "blocksAnalysis": { "comment": { "markdownText": "Provides information on how many blocks are currently present in the form." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 29 }, "type": "BlocksAnalysis" } } }, { "items": { "sidebarPaneId": { "comment": { "markdownText": "The ID of the sidebar panel that needs to be rendered." }, "location": { "filePath": "src/hooks/renderItemFormSidebarPanel.ts", "lineNumber": 25 }, "type": "string" }, "parameters": { "comment": { "markdownText": "The arbitrary `parameters` of the panel declared in the\n`itemFormSidebarPanels` function." }, "location": { "filePath": "src/hooks/renderItemFormSidebarPanel.ts", "lineNumber": 31 }, "type": "Record<string, unknown>" } } } ], "additionalMethods": [ { "name": "ItemFormAdditionalMethods", "comment": { "markdownText": "These methods can be used to interact with the form that's being shown to the\nend-user to edit a record." }, "items": { "toggleField": { "comment": { "markdownText": "Hides/shows a specific field in the form. Please be aware that when a field\nis hidden, the field editor for that field will be removed from the DOM\nitself, including any associated plugins. When it is shown again, its\nplugins will be reinitialized.", "example": "const fieldPath = prompt(\n 'Please insert the path of a field in the form',\n ctx.fieldPath,\n);\n\nawait ctx.toggleField(fieldPath, true);" }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 68 }, "type": "(path: string, show: boolean) => Promise<void>" }, "disableField": { "comment": { "markdownText": "Disables/re-enables a specific field in the form.", "example": "const fieldPath = prompt(\n 'Please insert the path of a field in the form',\n ctx.fieldPath,\n);\n\nawait ctx.disableField(fieldPath, true);" }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 83 }, "type": "(path: string, disable: boolean) => Promise<void>" }, "scrollToField": { "comment": { "markdownText": "Smoothly navigates to a specific field in the form. If the field is\nlocalized it will switch language tab and then navigate to the chosen\nfield.", "example": "const fieldPath = prompt(\n 'Please insert the path of a field in the form',\n ctx.fieldPath,\n);\n\nawait ctx.scrollToField(fieldPath);" }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 100 }, "type": "(path: string, locale?: string) => Promise<void>" }, "setFieldValue": { "comment": { "markdownText": "Changes a specific path of the `formValues` object.", "example": "const fieldPath = prompt(\n 'Please insert the path of a field in the form',\n ctx.fieldPath,\n);\n\nawait ctx.setFieldValue(fieldPath, 'new value');" }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 115 }, "type": "(path: string, value: unknown) => Promise<void>" }, "formValuesToItem": { "comment": { "markdownText": "Takes the internal form state, and transforms it into an Item entity\ncompatible with DatoCMS API.\n\nWhen `skipUnchangedFields`, only the fields that changed value will be\nserialized.\n\nIf the required nested blocks are still not loaded, this method will return\n`undefined`.", "example": "await ctx.formValuesToItem(ctx.formValues, false);" }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 132 }, "type": "(\n formValues: Record<string, unknown>,\n skipUnchangedFields?: boolean,\n ) => Promise<Omit<Item, 'id' | 'meta'> | undefined>" }, "itemToFormValues": { "comment": { "markdownText": "Takes an Item entity, and converts it into the internal form state.", "example": "await ctx.itemToFormValues(ctx.item);" }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 145 }, "type": "(\n item: Omit<Item, 'id' | 'meta'>,\n ) => Promise<Record<string, unknown>>" }, "saveCurrentItem": { "comment": { "markdownText": "Triggers a submit form for current record.", "example": "await ctx.saveCurrentItem();" }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 157 }, "type": "(showToast?: boolean) => Promise<void>" } } } ] }, "returnType": "void", "location": { "filePath": "src/hooks/renderItemFormSidebarPanel.ts", "lineNumber": 15 } }, "renderItemFormSidebar": { "name": "renderItemFormSidebar", "comment": { "markdownText": "This function will be called when the plugin needs to render a sidebar (see\nthe `itemFormSidebars` hook).", "tag": "sidebarPanels" }, "nonCtxArguments": [ { "name": "sidebarId", "typeName": "string" } ], "ctxArgument": { "type": "ImposedSizePluginFrameCtx", "additionalProperties": [ { "name": "ItemFormAdditionalProperties", "comment": { "markdownText": "These information describe the current state of the form that's being shown\nto the end-user to edit a record." }, "items": { "locale": { "comment": { "markdownText": "The currently active locale for the record." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 12 }, "type": "string" }, "item": { "comment": { "markdownText": "If an already persisted record is being edited, returns the full record\nentity." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 17 }, "type": "Item | null" }, "itemType": { "comment": { "markdownText": "The model for the record being edited." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 19 }, "type": "ItemType" }, "formValues": { "comment": { "markdownText": "The complete internal form state." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 21 }, "type": "Record<string, unknown>" }, "itemStatus": { "comment": { "markdownText": "The current status of the record being edited." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 23 }, "type": "'new' | 'draft' | 'updated' | 'published'" }, "isSubmitting": { "comment": { "markdownText": "Whether the form is currently submitting itself or not." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 25 }, "type": "boolean" }, "isFormDirty": { "comment": { "markdownText": "Whether the form has some non-persisted changes or not." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 27 }, "type": "boolean" }, "blocksAnalysis": { "comment": { "markdownText": "Provides information on how many blocks are currently present in the form." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 29 }, "type": "BlocksAnalysis" } } }, { "items": { "sidebarId": { "comment": { "markdownText": "The ID of the sidebar that needs to be rendered." }, "location": { "filePath": "src/hooks/renderItemFormSidebar.ts", "lineNumber": 25 }, "type": "string" }, "parameters": { "comment": { "markdownText": "The arbitrary `parameters` of the declared in the `itemFormSidebars`\nfunction." }, "location": { "filePath": "src/hooks/renderItemFormSidebar.ts", "lineNumber": 30 }, "type": "Record<string, unknown>" } } } ], "additionalMethods": [ { "name": "ItemFormAdditionalMethods", "comment": { "markdownText": "These methods can be used to interact with the form that's being shown to the\nend-user to edit a record." }, "items": { "toggleField": { "comment": { "markdownText": "Hides/shows a specific field in the form. Please be aware that when a field\nis hidden, the field editor for that field will be removed from the DOM\nitself, including any associated plugins. When it is shown again, its\nplugins will be reinitialized.", "example": "const fieldPath = prompt(\n 'Please insert the path of a field in the form',\n ctx.fieldPath,\n);\n\nawait ctx.toggleField(fieldPath, true);" }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 68 }, "type": "(path: string, show: boolean) => Promise<void>" }, "disableField": { "comment": { "markdownText": "Disables/re-enables a specific field in the form.", "example": "const fieldPath = prompt(\n 'Please insert the path of a field in the form',\n ctx.fieldPath,\n);\n\nawait ctx.disableField(fieldPath, true);" }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 83 }, "type": "(path: string, disable: boolean) => Promise<void>" }, "scrollToField": { "comment": { "markdownText": "Smoothly navigates to a specific field in the form. If the field is\nlocalized it will switch language tab and then navigate to the chosen\nfield.", "example": "const fieldPath = prompt(\n 'Please insert the path of a field in the form',\n ctx.fieldPath,\n);\n\nawait ctx.scrollToField(fieldPath);" }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 100 }, "type": "(path: string, locale?: string) => Promise<void>" }, "setFieldValue": { "comment": { "markdownText": "Changes a specific path of the `formValues` object.", "example": "const fieldPath = prompt(\n 'Please insert the path of a field in the form',\n ctx.fieldPath,\n);\n\nawait ctx.setFieldValue(fieldPath, 'new value');" }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 115 }, "type": "(path: string, value: unknown) => Promise<void>" }, "formValuesToItem": { "comment": { "markdownText": "Takes the internal form state, and transforms it into an Item entity\ncompatible with DatoCMS API.\n\nWhen `skipUnchangedFields`, only the fields that changed value will be\nserialized.\n\nIf the required nested blocks are still not loaded, this method will return\n`undefined`.", "example": "await ctx.formValuesToItem(ctx.formValues, false);" }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 132 }, "type": "(\n formValues: Record<string, unknown>,\n skipUnchangedFields?: boolean,\n ) => Promise<Omit<Item, 'id' | 'meta'> | undefined>" }, "itemToFormValues": { "comment": { "markdownText": "Takes an Item entity, and converts it into the internal form state.", "example": "await ctx.itemToFormValues(ctx.item);" }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 145 }, "type": "(\n item: Omit<Item, 'id' | 'meta'>,\n ) => Promise<Record<string, unknown>>" }, "saveCurrentItem": { "comment": { "markdownText": "Triggers a submit form for current record.", "example": "await ctx.saveCurrentItem();" }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 157 }, "type": "(showToast?: boolean) => Promise<void>" } } } ] }, "returnType": "void", "location": { "filePath": "src/hooks/renderItemFormSidebar.ts", "lineNumber": 15 } }, "renderItemFormOutlet": { "name": "renderItemFormOutlet", "comment": { "markdownText": "This function will be called when the plugin needs to render an outlet\ndefined by the `itemFormOutlets()` hook.", "tag": "outlets" }, "nonCtxArguments": [ { "name": "itemFormOutletId", "typeName": "string" } ], "ctxArgument": { "type": "SelfResizingPluginFrameCtx", "additionalProperties": [ { "name": "ItemFormAdditionalProperties", "comment": { "markdownText": "These information describe the current state of the form that's being shown\nto the end-user to edit a record." }, "items": { "locale": { "comment": { "markdownText": "The currently active locale for the record." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 12 }, "type": "string" }, "item": { "comment": { "markdownText": "If an already persisted record is being edited, returns the full record\nentity." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 17 }, "type": "Item | null" }, "itemType": { "comment": { "markdownText": "The model for the record being edited." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 19 }, "type": "ItemType" }, "formValues": { "comment": { "markdownText": "The complete internal form state." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 21 }, "type": "Record<string, unknown>" }, "itemStatus": { "comment": { "markdownText": "The current status of the record being edited." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 23 }, "type": "'new' | 'draft' | 'updated' | 'published'" }, "isSubmitting": { "comment": { "markdownText": "Whether the form is currently submitting itself or not." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 25 }, "type": "boolean" }, "isFormDirty": { "comment": { "markdownText": "Whether the form has some non-persisted changes or not." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 27 }, "type": "boolean" }, "blocksAnalysis": { "comment": { "markdownText": "Provides information on how many blocks are currently present in the form." }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 29 }, "type": "BlocksAnalysis" } } }, { "items": { "itemFormOutletId": { "comment": { "markdownText": "The ID of the outlet that needs to be rendered." }, "location": { "filePath": "src/hooks/renderItemFormOutlet.ts", "lineNumber": 25 }, "type": "string" } } } ], "additionalMethods": [ { "name": "ItemFormAdditionalMethods", "comment": { "markdownText": "These methods can be used to interact with the form that's being shown to the\nend-user to edit a record." }, "items": { "toggleField": { "comment": { "markdownText": "Hides/shows a specific field in the form. Please be aware that when a field\nis hidden, the field editor for that field will be removed from the DOM\nitself, including any associated plugins. When it is shown again, its\nplugins will be reinitialized.", "example": "const fieldPath = prompt(\n 'Please insert the path of a field in the form',\n ctx.fieldPath,\n);\n\nawait ctx.toggleField(fieldPath, true);" }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 68 }, "type": "(path: string, show: boolean) => Promise<void>" }, "disableField": { "comment": { "markdownText": "Disables/re-enables a specific field in the form.", "example": "const fieldPath = prompt(\n 'Please insert the path of a field in the form',\n ctx.fieldPath,\n);\n\nawait ctx.disableField(fieldPath, true);" }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 83 }, "type": "(path: string, disable: boolean) => Promise<void>" }, "scrollToField": { "comment": { "markdownText": "Smoothly navigates to a specific field in the form. If the field is\nlocalized it will switch language tab and then navigate to the chosen\nfield.", "example": "const fieldPath = prompt(\n 'Please insert the path of a field in the form',\n ctx.fieldPath,\n);\n\nawait ctx.scrollToField(fieldPath);" }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 100 }, "type": "(path: string, locale?: string) => Promise<void>" }, "setFieldValue": { "comment": { "markdownText": "Changes a specific path of the `formValues` object.", "example": "const fieldPath = prompt(\n 'Please insert the path of a field in the form',\n ctx.fieldPath,\n);\n\nawait ctx.setFieldValue(fieldPath, 'new value');" }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 115 }, "type": "(path: string, value: unknown) => Promise<void>" }, "formValuesToItem": { "comment": { "markdownText": "Takes the internal form state, and transforms it into an Item entity\ncompatible with DatoCMS API.\n\nWhen `skipUnchangedFields`, only the fields that changed value will be\nserialized.\n\nIf the required nested blocks are still not loaded, this method will return\n`undefined`.", "example": "await ctx.formValuesToItem(ctx.formValues, false);" }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 132 }, "type": "(\n formValues: Record<string, unknown>,\n skipUnchangedFields?: boolean,\n ) => Promise<Omit<Item, 'id' | 'meta'> | undefined>" }, "itemToFormValues": { "comment": { "markdownText": "Takes an Item entity, and converts it into the internal form state.", "example": "await ctx.itemToFormValues(ctx.item);" }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 145 }, "type": "(\n item: Omit<Item, 'id' | 'meta'>,\n ) => Promise<Record<string, unknown>>" }, "saveCurrentItem": { "comment": { "markdownText": "Triggers a submit form for current record.", "example": "await ctx.saveCurrentItem();" }, "location": { "filePath": "src/ctx/commonExtras/itemForm.ts", "lineNumber": 157 }, "type": "(showToast?: boolean) => Promise<void>" } } } ] }, "returnType": "void", "location": { "filePath": "src/hooks/renderItemFormOutlet.ts", "lineNumber": 15 } }, "renderItemCollectionOutlet": { "name": "renderItemCollectionOutlet", "comment": { "markdownText": "This function will be called when the plugin needs to render an outlet\ndefined by the `itemCollectionOutlets()` hook.", "tag": "outlets" }, "nonCtxArguments": [ { "name": "itemCollectionOutletId", "typeName": "string" } ], "ctxArgument": { "type": "SelfResizingPluginFrameCtx", "additionalProperties": [ { "items": { "itemCollectionOutletId": { "comment": { "markdownText": "The ID of the outlet that needs to be rendered." }, "location": { "filePath": "src/hooks/renderItemCollectionOutlet.ts", "lineNumber": 24 }, "type": "string" }, "itemType": { "comment": { "markdownText": "The model for which the outlet is being rendered." }, "location": { "filePath": "src/hooks/renderItemCollectionOutlet.ts", "lineNumber": 26 }, "type": "ItemType" } } } ], "additionalMethods": [] }, "returnType": "void", "location": { "filePath": "src/hooks/renderItemCollectionOutlet.ts", "lineNumber": 14 } }, "renderInspectorPanel": { "name": "renderInspectorPanel", "comment": { "markdownText": "This function will be called when an inspector needs to render a specific\npanel (see the `renderInspector` and `setInspectorMode` functions).", "tag": "inspector" }, "nonCtxArguments": [ { "name": "panelId", "typeName": "string" } ], "ctxArgument": { "type": "ImposedSizePluginFrameCtx", "additionalProperties": [ { "items": { "panelId": { "comment": { "markdownText": "The ID of the inspector panel that needs to be rendered." }, "location": { "filePath": "src/hooks/renderInspectorPanel.ts", "lineNumber": 18 }, "type": "string" }, "parameters": { "comment": { "markdownText": "The arbitrary `parameters` of the modal declared in the `setInspectorMode`\nfunction." }, "location": { "filePath": "src/hooks/renderInspectorPanel.ts", "lineNumber": 24 }, "type": "Record<string, unknown>" } } } ], "additionalMethods": [] }, "returnType": "void", "location": { "filePath": "src/hooks/renderInspectorPanel.ts", "lineNumber": 11 } }, "renderInspector": { "name": "renderInspector", "comment": { "markdownText": "This function will be called when the plugin needs to render a specific\ninspector. Inspectors provide a side panel interface for displaying and\ninteracting with content alongside a custom interface.", "tag": "inspector", "example": "connect({\n renderInspector(inspectorId, ctx) {\n render(\n <div>\n <h1>Inspector: {inspectorId}</h1>\n <button onClick={() => ctx.setInspectorMode({\n type: 'itemEditor',\n itemId: 'some-item-id'\n })}>\n Show Item Editor\n </button>\n </div>\n );\n }\n});" }, "nonCtxArguments": [ { "name": "inspectorId", "typeName": "string" } ], "ctxArgument": { "type": "ImposedSizePluginFrameCtx", "additionalProperties": [ { "items": { "inspectorId": { "comment": { "markdownText": "The ID of the inspector that needs to be rendered." }, "location": { "filePath": "src/hooks/renderInspector.ts", "lineNumber": 80 }, "type": "string" }, "highlightedItemId": { "comment": { "markdownText": "The ID of the record the currently is highlighted by the user." }, "location": { "filePath": "src/hooks/renderInspector.ts", "lineNumber": 83 }, "type": "string | undefined" }, "location": { "comment": { "markdownText": "Current page location." }, "location": { "filePath": "src/hooks/renderInspector.ts", "lineNumber": 86 }, "type": "{\n pathname: string;\n search: string;\n hash: string;\n }" } } } ], "additionalMethods": [ { "items": { "setInspectorMode": { "comment": { "markdownText": "Changes the current display mode of the inspector. This allows the plugin\nto dynamically switch between showing a record list, record editor, or custom\npanel within the inspector interface.", "example": "// Switch to record editor mode\nawait ctx.setInspectorMode({\n type: 'itemEditor',\n itemId: 'item-123',\n fieldPath: 'title'\n});\n\n// Switch to record list mode\nawait ctx.setInspectorMode({ type: 'itemList' });\nawait ctx.setInspectorItemListData({\n title: 'Related Records',\n itemIds: ['item-1', 'item-2', 'item-3']\n});\n\n// Switch to custom panel mode\nawait ctx.setInspectorMode({\n type: 'customPanel',\n panelId: 'my-custom-panel',\n parameters: { filter: 'active' }\n});\n\n// Low intent mode change - won't interrupt editing with unsaved changes\nawait ctx.setInspectorMode(\n { type: 'itemList' },\n { ignoreIfUnsavedChanges: true }\n);" }, "location": { "filePath": "src/hooks/renderInspector.ts", "lineNumber": 136 }, "type": "(\n mode: InspectorMode,\n options?: SetInspectorModeOptions,\n ) => Promise<void>" }, "setInspectorItemListData": { "comment": { "markdownText": "Sets the data for the item list inspector mode.", "example": "// Set the item list data\nawait ctx.setI