@contentful/live-preview
Advanced tools
Comparing version 1.13.0 to 1.14.0
@@ -1,3 +0,2 @@ | ||
import type { EntryProps } from 'contentful-management'; | ||
import { SysProps, EntityReferenceMap, Entity, ContentType } from '../types'; | ||
import { SysProps, Entity, UpdateEntryProps } from '../types'; | ||
/** | ||
@@ -12,6 +11,4 @@ * Updates GraphQL response data based on CMA entry object | ||
*/ | ||
export declare function updateEntry(contentType: ContentType, dataFromPreviewApp: Entity & { | ||
export declare function updateEntry({ contentType, dataFromPreviewApp, updateFromEntryEditor, locale, entityReferenceMap, }: UpdateEntryProps): Entity & { | ||
sys: SysProps; | ||
}, updateFromEntryEditor: EntryProps, locale: string, entityReferenceMap: EntityReferenceMap): Entity & { | ||
sys: SysProps; | ||
}; |
@@ -6,2 +6,4 @@ import { FieldTagging } from './fieldTagging'; | ||
debugMode?: boolean; | ||
enableFieldTagging?: boolean; | ||
enableLiveUpdates?: boolean; | ||
} | ||
@@ -11,6 +13,10 @@ export declare class ContentfulLivePreview { | ||
static liveUpdates: LiveUpdates | null; | ||
static init({ debugMode }?: ContentfulLivePreviewInitConfig): Promise<FieldTagging> | undefined; | ||
static fieldTaggingEnabled: boolean; | ||
static liveUpdatesEnabled: boolean; | ||
static init({ debugMode, enableFieldTagging, enableLiveUpdates }?: ContentfulLivePreviewInitConfig): Promise<FieldTagging | null> | undefined; | ||
static subscribe(data: Argument, locale: string, callback: SubscribeCallback): VoidFunction; | ||
static getProps({ fieldId, entryId, locale, }: LivePreviewProps): Record<TagAttributes, string | null | undefined>; | ||
static togglefieldTagging(): boolean; | ||
static toggleLiveUpdatesMode(): boolean; | ||
} | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
import { C as r } from "./index-7e24ba7c.js"; | ||
import { C as r } from "./index-7eac4424.js"; | ||
export { | ||
@@ -3,0 +3,0 @@ r as ContentfulLivePreview |
import * as f from "react"; | ||
import { useState as m, useRef as c } from "react"; | ||
import { d as o, C as v } from "./index-7e24ba7c.js"; | ||
import { useState as v, useRef as c } from "react"; | ||
import { d as o, C as g } from "./index-7eac4424.js"; | ||
var l = Object.prototype.hasOwnProperty; | ||
@@ -75,10 +75,10 @@ function p(e, t, n) { | ||
function A(e, t) { | ||
return e ? !1 : !!(Array.isArray(t) && t.length || t && typeof t == "object" && Object.keys(t).length); | ||
return !g.liveUpdatesEnabled || e ? !1 : !!(Array.isArray(t) && t.length || t && typeof t == "object" && Object.keys(t).length); | ||
} | ||
function R(e, t, n = !1) { | ||
const [r, i] = m({ data: e, version: 1 }), s = c(e), g = c(o(i)); | ||
const [r, i] = v({ data: e, version: 1 }), s = c(e), y = c(o(i)); | ||
return j(() => { | ||
if (s.current !== e && (i({ data: e, version: 1 }), s.current = e), !!A(n, e)) | ||
return v.subscribe(e, t, (y) => { | ||
g.current((h) => ({ data: y, version: h.version++ })); | ||
return g.subscribe(e, t, (h) => { | ||
y.current((m) => ({ data: h, version: m.version++ })); | ||
}); | ||
@@ -85,0 +85,0 @@ }, [e]), r.data; |
@@ -60,2 +60,28 @@ import type { AssetProps, EntryProps, ContentTypeProps } from 'contentful-management'; | ||
} | ||
export type UpdateEntryProps = { | ||
contentType: ContentType; | ||
dataFromPreviewApp: Entity & { | ||
sys: SysProps; | ||
}; | ||
updateFromEntryEditor: EntryProps; | ||
locale: string; | ||
entityReferenceMap: EntityReferenceMap; | ||
}; | ||
export type UpdateFieldProps = { | ||
dataFromPreviewApp: Entity; | ||
updateFromEntryEditor: EntryProps; | ||
name: string; | ||
locale: string; | ||
entityReferenceMap?: EntityReferenceMap; | ||
}; | ||
export type UpdateReferenceFieldProps = { | ||
referenceFromPreviewApp: (EntryProps & { | ||
__typename?: string; | ||
}) | null | undefined; | ||
updatedReference: EntryProps & { | ||
__typename?: string; | ||
}; | ||
entityReferenceMap: EntityReferenceMap; | ||
locale: string; | ||
}; | ||
export {}; |
{ | ||
"name": "@contentful/live-preview", | ||
"version": "1.13.0", | ||
"version": "1.14.0", | ||
"author": "Contentful GmbH", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -41,5 +41,21 @@ # @contentful/live-preview | ||
#### Init Configuration | ||
The init command also accepts a configuration object that allows you to customize your live preview SDK experience. The following options are available: | ||
```jsx | ||
import { ContentfulLivePreview } from '@contentful/live-preview'; | ||
... | ||
ContentfulLivePreview.init({ | ||
enablefieldTagging: false, // This allows you to toggle the inspector mode which is on by default | ||
enableLiveUpdates: false, // This allows you to toggle the live updates which is on by default | ||
debugMode: false, // This allows you to toggle the debug mode which is off by default | ||
}); | ||
``` | ||
### Field Tagging | ||
To tag fields you need to add the live preview data-attributes to the rendered HTML element output. | ||
To tag fields you need to add the live preview data-attributes (`data-contentful-entry-id`, `data-contentful-field-id`, `data-contentful-locale`) to the rendered HTML element output. | ||
You can do this in React via our helper function. | ||
@@ -64,3 +80,3 @@ The necessary styles for the live edit tags can be found in the '@contentful/live-preview/style.css' file. | ||
```tsx | ||
import { useContentfulLiveUpdates } from "@contentful/live-preview/react"; | ||
import { useContentfulLiveUpdates } from '@contentful/live-preview/react'; | ||
@@ -67,0 +83,0 @@ // ... |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
200308
1093
260
2