@contentstack/utils
Version:
Contentstack utilities for Javascript
28 lines (27 loc) • 1.45 kB
TypeScript
import { EntryModel } from ".";
interface AppliedVariants {
_applied_variants: {
[key: string]: any;
};
shouldApplyVariant: boolean;
metaKey: string;
}
/**
* Adds Contentstack Live Preview (CSLP) data tags to an entry for editable UIs.
* Mutates the entry by attaching a `$` property with tag strings or objects
* (e.g. `data-cslp` / `data-cslp-parent-field`) for each field, including nested
* objects and references. Supports variant-aware tagging when the entry has
* applied variants.
*
* @param entry - The entry (EmbeddedItem) to tag. Must have uid and optional system/applied variants.
* @param contentTypeUid - Content type UID (e.g. `blog_post`). Used as part of the tag path.
* @param tagsAsObject - If true, tags are stored as objects (e.g. `{ "data-cslp": "..." }`); if false, as strings (e.g. `data-cslp=...`).
* @param locale - Locale code for the tag path (default: `'en-us'`).
* @param options.useLowerCaseLocale - Optional boolean to make locale case-insensitive.
*/
export declare function addTags(entry: EntryModel, contentTypeUid: string, tagsAsObject: boolean, locale?: string, options?: {
useLowerCaseLocale?: boolean;
}): void;
/** @internal Exported for testing the null/undefined guard (Issue #193). */
export declare function getTag(content: object, prefix: string, tagsAsObject: boolean, locale: string, appliedVariants: AppliedVariants): object;
export {};