diff --git a/README.md b/README.md index 6193f73..8d198e6 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)**: An object that represents 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 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 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** + +```js +var draftData = await entry.getDraftData(); +console.log("Draft Data:", draftData); +``` + #### entry.getField(uid, options?) ⇒ Object @@ -743,6 +772,37 @@ sidebarWidget.onSave((updatedContentType) => { }); ``` +## GlobalFullPageWidget + +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's 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.