UNPKG

@contentstack/live-preview-utils

Version:

Contentstack provides the Live Preview SDK to establish a communication channel between the various Contentstack SDKs and your website, transmitting live changes to the preview pane.

1 lines 1.69 kB
{"version":3,"sources":["../../../../src/visualBuilder/utils/getEntryIdentifiersInCurrentPage.ts"],"sourcesContent":["import { extractDetailsFromCslp } from \"../../cslp/cslpdata\";\n\ntype EntryIdentifiers = {\n entriesInCurrentPage: {\n entryUid: string;\n contentTypeUid: string;\n locale: string;\n }[];\n}\n\nexport function getEntryIdentifiersInCurrentPage(): EntryIdentifiers {\n const elementsWithCslp = Array.from(\n document.querySelectorAll(\"[data-cslp]\")\n );\n const uniqueEntriesMap = new Map<string, { entryUid: string, contentTypeUid: string, locale: string}>();\n elementsWithCslp.forEach((element) => {\n const cslpData = extractDetailsFromCslp(\n element.getAttribute(\"data-cslp\") as string\n );\n uniqueEntriesMap.set(cslpData.entry_uid, \n { \n entryUid: cslpData.entry_uid, \n contentTypeUid: cslpData.content_type_uid, \n locale: cslpData.locale \n }\n );\n });\n \n const uniqueEntriesArray = Array.from(uniqueEntriesMap.values());\n\n return {\n entriesInCurrentPage: uniqueEntriesArray,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAuC;AAUhC,SAAS,mCAAqD;AACjE,QAAM,mBAAmB,MAAM;AAAA,IAC3B,SAAS,iBAAiB,aAAa;AAAA,EAC3C;AACA,QAAM,mBAAmB,oBAAI,IAAyE;AACtG,mBAAiB,QAAQ,CAAC,YAAY;AAClC,UAAM,eAAW;AAAA,MACb,QAAQ,aAAa,WAAW;AAAA,IACpC;AACA,qBAAiB;AAAA,MAAI,SAAS;AAAA,MAC1B;AAAA,QACI,UAAU,SAAS;AAAA,QACnB,gBAAgB,SAAS;AAAA,QACzB,QAAQ,SAAS;AAAA,MACrB;AAAA,IACJ;AAAA,EACJ,CAAC;AAED,QAAM,qBAAqB,MAAM,KAAK,iBAAiB,OAAO,CAAC;AAE/D,SAAO;AAAA,IACH,sBAAsB;AAAA,EAC1B;AACJ;","names":[]}