From 55c4aa1f550ac6701b101c24b167eda83bd26917 Mon Sep 17 00:00:00 2001 From: Abhishek Ezhava Date: Sun, 6 Jul 2025 13:08:30 +0530 Subject: [PATCH 1/2] feat: support globalfullpage & getDraftdata --- README.md | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/README.md b/README.md index 6193f73..3b62a89 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ Locations refers to the position or the placement of the app (sidebar widget, cu - **[AppConfigWidget](#AppConfigWidget)**: It's an object representing the current App configuration for the current App in the Contentstack UI. - **[FieldModifierLocation](#FieldModifierLocation)**: It's an object representing the Field Modifier reference over the field in the Contentstack UI. - **[ContentTypeSidebarWidget](#ContentTypeSidebarWidget)**: It's an object representing the Content Type Sidebar Widget in the Contentstack UI. +- **[GlobalFullPageWidget](#GlobalFullPageWidget)**: It's an object representing the Global Full Page Widget in the Contentstack UI. # External @@ -150,6 +151,9 @@ ContentstackAppSDK.init().then(function (appSdk) { // fetch entry information var fieldData = await customField.entry.getData(); + + // fetch draft entry information (including unsaved changes) + var draftData = await customField.entry.getDraftData(); }); ``` @@ -168,6 +172,9 @@ ContentstackAppSDK.init().then(function (location) { // fetch entry information var fieldData = await sidebarWidget.entry.getData(); + + // fetch draft entry information (including unsaved changes) + var draftData = await sidebarWidget.entry.getDraftData(); }); ``` @@ -204,6 +211,9 @@ ContentstackAppSDK.init().then(function (appSdk) { // fetch entry information var fieldData = await fieldModifierLocation.entry.getData(); + + // fetch draft entry information (including unsaved changes) + var draftData = await fieldModifierLocation.entry.getDraftData(); }); ``` @@ -500,6 +510,7 @@ This method gives you the entry, object which allows you to interact with the cu - [.content_type](#entry) : Object - [.locale](#entrylocale--string) : string - [.getData()](#entrygetdata--object) ⇒ Object + - [.getDraftData()](#entrygetdraftdata--object) ⇒ Object - [.getField(uid, options?)](#entrygetfielduid-options--object) ⇒ Object - [.onSave(callback)](#entryonsavecallback) - [.onChange(callback)](#Entry+onChange) @@ -533,6 +544,24 @@ Gets data of the current entry. **Kind**: instance method of [Entry](#Entry) **Returns**: Object - Returns entry data. + + +#### entry.getDraftData() ⇒ Object + +Gets the draft data of the current entry, including unsaved changes made in the editor. + +**Kind**: instance method of [Entry](#Entry) +**Returns**: Object - Returns entry draft data in the same format as getData(), but without metadata like UID, version, publish info, etc. + +**Note**: This method is particularly useful for accessing entry data that hasn't been saved yet, allowing apps to read what the user has typed in real-time. + +**Example** + +```js +var draftData = await entry.getDraftData(); +console.log("Draft Data:", draftData); +``` + #### entry.getField(uid, options?) ⇒ Object @@ -743,6 +772,37 @@ sidebarWidget.onSave((updatedContentType) => { }); ``` +## GlobalFullPageWidget + +It is an object representing the Global Full Page Widget in the Contentstack UI. + +**Kind**: The instance property of [GlobalFullPageWidget](#supported-locations) + +### GlobalFullPage.currentOrganization ⇒ [Organization](#Organization) + +This method retrieves the current organization details. + +**Kind**: instance method of [GlobalFullPageWidget](#GlobalFullPageWidget) + +**Returns**: [Organization](#Organization) - The current organization data. + +**Example** + +```js +// javascript +ContentstackAppSDK.init().then(function (appSdk) { + + var globalFullPageWidget = await appSdk.location.GlobalFullPageLocation; + + // fetch app configuration + var appConfig = await appSdk.getConfig(); + + // fetch current organization information + var currentOrganization = globalFullPageWidget.currentOrganization; + console.log("Current Organization:", currentOrganization); +}); +``` + ## frame It is a class representing an iframe window from the Contentstack UI. Please note that it is not available for Custom Widgets. From dcd0ce91f8d52a3777700723c3b0e60adbfa07c4 Mon Sep 17 00:00:00 2001 From: Abhishek Ezhava Date: Thu, 17 Jul 2025 12:39:11 +0530 Subject: [PATCH 2/2] docs feedback --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3b62a89..8d198e6 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ Locations refers to the position or the placement of the app (sidebar widget, cu - **[AppConfigWidget](#AppConfigWidget)**: It's an object representing the current App configuration for the current App in the Contentstack UI. - **[FieldModifierLocation](#FieldModifierLocation)**: It's an object representing the Field Modifier reference over the field in the Contentstack UI. - **[ContentTypeSidebarWidget](#ContentTypeSidebarWidget)**: It's an object representing the Content Type Sidebar Widget in the Contentstack UI. -- **[GlobalFullPageWidget](#GlobalFullPageWidget)**: It's an object representing the Global Full Page Widget in the Contentstack UI. +- **[GlobalFullPageWidget](#GlobalFullPageWidget)**: An object that represents the Global Full Page Widget in the Contentstack UI. # External @@ -551,9 +551,9 @@ Gets data of the current entry. Gets the draft data of the current entry, including unsaved changes made in the editor. **Kind**: instance method of [Entry](#Entry) -**Returns**: Object - Returns entry draft data in the same format as getData(), but without metadata like UID, version, publish info, etc. +**Returns**: Object - Returns the draft data of the entry in the same format as getData(), but excludes metadata such as UID, version, publish information, and more. -**Note**: This method is particularly useful for accessing entry data that hasn't been saved yet, allowing apps to read what the user has typed in real-time. +**Note**: This method is especially useful for retrieving entry content that has not been saved yet, enabling apps to access what the user is currently typing in real time. **Example** @@ -774,13 +774,13 @@ sidebarWidget.onSave((updatedContentType) => { ## GlobalFullPageWidget -It is an object representing the Global Full Page Widget in the Contentstack UI. +This is an object representing the Global Full Page Widget in the Contentstack UI. **Kind**: The instance property of [GlobalFullPageWidget](#supported-locations) ### GlobalFullPage.currentOrganization ⇒ [Organization](#Organization) -This method retrieves the current organization details. +This method retrieves the current organization's details. **Kind**: instance method of [GlobalFullPageWidget](#GlobalFullPageWidget)