@ewizardjs/structure-api
Advanced tools
Comparing version 0.1.3 to 1.0.0
@@ -110,3 +110,3 @@ "use strict"; | ||
id: slideId, | ||
name: structureV2Json.slides[slideId].name, | ||
name: structureV2Json.slides[slideId]?.name, | ||
chapter: { | ||
@@ -121,3 +121,4 @@ id: slideChapter, | ||
thumbnail: systemSettings ? (0, path_1.join)(systemSettings.path.slides, slideId, systemSettings.path.slide.thumbnail) : undefined, | ||
template: structureV2Json.slides[slideId].template, | ||
screenshot: systemSettings ? (0, path_1.join)(systemSettings.path.slides, slideId, systemSettings.path.slide.screenshot) : undefined, | ||
template: structureV2Json.slides[slideId]?.template, | ||
subslides: (0, helpers_1.getSubslidesNestedData)(structureV2Json, slideId), | ||
@@ -245,3 +246,3 @@ custom: (0, utils_1.getSlideCustomFields)(structureV2Json, slideId) | ||
const firstVisibleSlide = getVisibleSlides(structureV2Json, systemSettings)[0]; | ||
return { slide: firstVisibleSlide.id, chapter: firstVisibleSlide.chapter?.id }; | ||
return { slide: firstVisibleSlide?.id, chapter: firstVisibleSlide?.chapter?.id }; | ||
}; | ||
@@ -285,3 +286,3 @@ exports.getStartSlide = getStartSlide; | ||
}; | ||
const normalizedSlides = (0, utils_1.normalizeStructureV1Subslides)(initialJson.slides); | ||
const normalizedSlides = (0, utils_1.normalizeStructureV1Subslides)(initialJson); | ||
const normalizedSlidesWithSubslides = Object | ||
@@ -291,3 +292,3 @@ .entries(normalizedSlides) | ||
const normalizedChapters = (0, utils_1.normalizeStructureV1Chapters)(initialJson); | ||
const convertedStoryboard = (0, helpers_1.convertStoryboardStructureV1ToV2)(initialJson.storyboard); | ||
const convertedStoryboard = (0, helpers_1.convertStoryboardStructureV1ToV2)(initialJson.storyboard, Object.keys(initialJson.chapters)); | ||
const convertedChapters = (0, helpers_1.migrateSubslidesToChapters)(normalizedSlidesWithSubslides, normalizedChapters, initialJson); | ||
@@ -298,4 +299,3 @@ const convertedSlides = (0, helpers_1.removeSubslidesFromNormalizedSlides)(normalizedSlides); | ||
resultingJson.slides = convertedSlides; | ||
const archivedSlides = getSlides(resultingJson, { archived: true }); | ||
resultingJson.archivedSlides = archivedSlides.map(slideData => ({ slide: slideData.id, chapter: slideData.chapter?.id })); | ||
resultingJson.archivedSlides = (0, utils_1.getStructureV1ArchivedSlides)(structureJson); | ||
return resultingJson; | ||
@@ -305,11 +305,9 @@ }; | ||
const makeStructure = (nestedSlidesData, targetStructureVersion) => { | ||
const structureScheme = { | ||
slides: {}, | ||
chapters: {}, | ||
storyboard: [], | ||
}; | ||
(0, helpers_1.restoreSlidesStructure)(nestedSlidesData, structureScheme); | ||
const nestedChapters = (0, helpers_1.restoreChaptersStructure)(nestedSlidesData, structureScheme); | ||
(0, helpers_1.restoreStoryboard)(nestedChapters, structureScheme); | ||
return targetStructureVersion === 1 ? structureScheme : convertToStructureV2(structureScheme); | ||
if (targetStructureVersion === 1) { | ||
return (0, helpers_1.makeV1StructureJSON)(nestedSlidesData); | ||
} | ||
if (targetStructureVersion === 2) { | ||
return (0, helpers_1.makeV2StructureJSON)(nestedSlidesData); | ||
} | ||
throw new Error(`Unsupported structure version: ${targetStructureVersion}`); | ||
}; | ||
@@ -316,0 +314,0 @@ exports.makeStructure = makeStructure; |
@@ -66,2 +66,3 @@ import { SemVer } from 'semver'; | ||
thumbnail: string; | ||
screenshot: string; | ||
}; | ||
@@ -86,2 +87,3 @@ }; | ||
thumbnail?: string; | ||
screenshot?: string; | ||
template?: string; | ||
@@ -198,1 +200,8 @@ custom?: { | ||
} | ||
export interface TypedChapter { | ||
id?: string; | ||
type?: string; | ||
storyboardIndex?: number; | ||
name?: string; | ||
custom?: Record<string, unknown>; | ||
} |
@@ -18,2 +18,3 @@ import { StructureV1, StructureV2, StructureApi } from '../types/interfaces'; | ||
thumbnail: string | undefined; | ||
screenshot: string | undefined; | ||
template: string; | ||
@@ -23,3 +24,3 @@ }[]; | ||
export declare function getParentSlide(structure: StructureV2.iStructureJSON, slideId: string): string | undefined; | ||
export declare function getChapterType(structure: StructureV2.iStructureJSON, chapterId: string): StructureApi.ChapterType; | ||
export declare function getChapterType(structure: StructureV2.iStructureJSON, chapterId: string): StructureApi.ChapterType.Visible | StructureApi.ChapterType.Hidden; | ||
export declare function restoreSlidesStructure(nestedSlidesData: StructureApi.NestedSlideData[], structureScheme: StructureV1.iStructureJSON): string[]; | ||
@@ -29,3 +30,3 @@ export declare function restoreChaptersStructure(nestedSlidesData: StructureApi.NestedSlideData[], structureScheme: StructureV1.iStructureJSON): StructureApi.ChapterNestedData[]; | ||
export declare function getOrderedSlidesId(allChaptersId: string[], structureJson: StructureV2.iStructureJSON): string[]; | ||
export declare function convertStoryboardStructureV1ToV2(storyboard: string[]): (string | StructureV2.iStoryboardItem)[]; | ||
export declare function convertStoryboardStructureV1ToV2(storyboard: string[], chapters: string[]): (string | StructureV2.iStoryboardItem)[]; | ||
export declare function migrateSubslidesToChapters(normalizedSlidesWithSubslides: [string, NormalizedStructureV1Slide][], chapters: Record<string, StructureV2.iChapter>, structureJson: StructureV2.iStructureJSON): Record<string, StructureV2.iChapter> | undefined; | ||
@@ -38,1 +39,3 @@ export declare function removeSubslidesFromNormalizedSlides(slides: Record<string, NormalizedStructureV1Slide>): { | ||
}; | ||
export declare function makeV1StructureJSON(nestedSlidesData: StructureApi.NestedSlideData[]): StructureV1.iStructureJSON; | ||
export declare function makeV2StructureJSON(nestedSlidesData: StructureApi.NestedSlideData[]): StructureV2.iStructureJSON; |
@@ -1,2 +0,2 @@ | ||
import { StructureV1, StructureV2, StructureApi } from '../types/interfaces'; | ||
import { StructureV1, StructureV2, StructureApi, TypedChapter } from '../types/interfaces'; | ||
import { EntityType, UnnormalizedEntity, NormalizedChapters, NormalizedEntity, NormalizedStructureV1Slide } from '../types/types'; | ||
@@ -26,7 +26,29 @@ export declare function normalizeEntity(entity: UnnormalizedEntity, entityType: EntityType): Partial<NormalizedEntity>; | ||
export declare function flatChapterContent(chapterContent: (string | StructureV2.iChapterContentItem)[]): (string | StructureV2.iSlideItem)[]; | ||
export declare function normalizeStructureV1Subslides(slides: { | ||
[key: string]: StructureV1.iSlides; | ||
}): Record<string, NormalizedStructureV1Slide>; | ||
export declare function normalizeStructureV1Subslides(structureJson: StructureV1.iStructureJSON): Record<string, NormalizedStructureV1Slide>; | ||
export declare function normalizeStructureV1Chapters(structure: StructureV1.iStructureJSON): Record<string, StructureV2.iChapter>; | ||
export declare function getSlideCustomFields(structure: StructureV2.iStructureJSON, slideId: string): {}; | ||
export declare function getChapterCustomFields(structure: StructureV2.iStructureJSON | StructureV1.iStructureJSON, chapterId: string): {}; | ||
export declare function getStructureV1ArchivedSlides(structureJson: StructureV1.iStructureJSON): { | ||
slide: string; | ||
chapter: string | undefined; | ||
}[]; | ||
export declare function getChapterSlidesById(nestedSlides: StructureApi.NestedSlideData[], chapterId: string): (string | StructureV2.iChapterContentItem)[]; | ||
export declare function getChaptersFromNestedSlides(nestedSlidesData: StructureApi.NestedSlideData[]): TypedChapter[]; | ||
export declare function getV2StoryboardRecord(typedChapters: TypedChapter[]): { | ||
storyboard: (string | { | ||
chapter: string | undefined; | ||
hidden: boolean; | ||
} | undefined)[]; | ||
}; | ||
export declare function getV2ChaptersRecord(typedChapters: TypedChapter[], nestedSlidesData: StructureApi.NestedSlideData[]): { | ||
chapters: any; | ||
}; | ||
export declare function getV2SlidesRecord(nestedSlidesData: StructureApi.NestedSlideData[]): { | ||
slides: any; | ||
}; | ||
export declare function getV2ArchivedSlidesRecord(nestedSlidesData: StructureApi.NestedSlideData[]): { | ||
archivedSlides: { | ||
slide: string; | ||
chapter: string | undefined; | ||
}[]; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.removeSubslidesFromNormalizedSlides = exports.migrateSubslidesToChapters = exports.convertStoryboardStructureV1ToV2 = exports.getOrderedSlidesId = exports.restoreStoryboard = exports.restoreChaptersStructure = exports.restoreSlidesStructure = exports.getChapterType = exports.getParentSlide = exports.getRawSlideSubslides = exports.getSubslidesNestedData = exports.getV1SlideChapter = exports.getSlideChapter = exports.getSlideType = void 0; | ||
exports.makeV2StructureJSON = exports.makeV1StructureJSON = exports.removeSubslidesFromNormalizedSlides = exports.migrateSubslidesToChapters = exports.convertStoryboardStructureV1ToV2 = exports.getOrderedSlidesId = exports.restoreStoryboard = exports.restoreChaptersStructure = exports.restoreSlidesStructure = exports.getChapterType = exports.getParentSlide = exports.getRawSlideSubslides = exports.getSubslidesNestedData = exports.getV1SlideChapter = exports.getSlideChapter = exports.getSlideType = void 0; | ||
const path_1 = require("path"); | ||
@@ -14,7 +14,6 @@ const interfaces_1 = require("../types/interfaces"); | ||
const slideChapterIsHidden = slideChapterType === interfaces_1.StructureApi.ChapterType.Hidden; | ||
const slideChapterIsArchived = slideChapterType === interfaces_1.StructureApi.ChapterType.Archived; | ||
const parentSlideIsHidden = parentSlide ? (0, index_1.listIncludesSlide)(hiddenSlides, parentSlide) : false; | ||
const slideIsDefinitelyHidden = (0, index_1.listIncludesSlide)(hiddenSlides, slideId); | ||
const parentSlideIsArchived = parentSlide ? (0, index_1.listIncludesSlide)(archivedSlides, parentSlide) : false; | ||
if (!slideChapter || slideChapterIsArchived || parentSlideIsArchived || (0, index_1.listIncludesSlide)(archivedSlides, slideId)) { | ||
if (!slideChapter || parentSlideIsArchived || (0, index_1.listIncludesSlide)(archivedSlides, slideId)) { | ||
return interfaces_1.StructureApi.SlideType.Archived; | ||
@@ -29,2 +28,6 @@ } | ||
function getSlideChapter(structure, slideId) { | ||
const slideFromArchived = structure.archivedSlides?.find(slideData => slideData.slide === slideId); | ||
if (slideFromArchived && slideFromArchived.chapter) { | ||
return slideFromArchived.chapter; | ||
} | ||
const normalizedChapters = (0, index_1.getNormalizedChapters)(structure); | ||
@@ -73,2 +76,3 @@ const parentSlide = getParentSlide(structure, slideId); | ||
thumbnail: systemSettings ? (0, path_1.join)(systemSettings.path.slides, subslideId, systemSettings.path.slide.thumbnail) : undefined, | ||
screenshot: systemSettings ? (0, path_1.join)(systemSettings.path.slides, subslideId, systemSettings.path.slide.screenshot) : undefined, | ||
template: structure.slides[subslideId].template, | ||
@@ -103,6 +107,6 @@ }; | ||
const chapterInStoryBoard = normalizedStoryboard.find(normalizedChapter => normalizedChapter.chapter === chapterId); | ||
if (!chapterInStoryBoard) { | ||
return interfaces_1.StructureApi.ChapterType.Archived; | ||
if (chapterInStoryBoard && !chapterInStoryBoard.hidden) { | ||
return interfaces_1.StructureApi.ChapterType.Visible; | ||
} | ||
return chapterInStoryBoard.hidden ? interfaces_1.StructureApi.ChapterType.Hidden : interfaces_1.StructureApi.ChapterType.Visible; | ||
return interfaces_1.StructureApi.ChapterType.Hidden; | ||
} | ||
@@ -119,3 +123,3 @@ exports.getChapterType = getChapterType; | ||
const slideSubslides = nestedSlide.subslides.map(subslide => { | ||
if (subslide.type === interfaces_1.StructureApi.SlideType.Hidden) { | ||
if (subslide.type === interfaces_1.StructureApi.SlideType.Archived) { | ||
return `!${subslide.id}`; | ||
@@ -185,7 +189,10 @@ } | ||
} | ||
return slidesId; | ||
return Array.from(new Set(slidesId)); | ||
} | ||
exports.getOrderedSlidesId = getOrderedSlidesId; | ||
function convertStoryboardStructureV1ToV2(storyboard) { | ||
return storyboard.map(chapterName => (0, index_1.getNormalizedChapterEntity)(chapterName)); | ||
function convertStoryboardStructureV1ToV2(storyboard, chapters) { | ||
const storyboardChapters = storyboard.map(chapterName => (0, index_1.getNormalizedChapterEntity)(chapterName)); | ||
const otherChapters = chapters.filter(chapterName => !storyboard.includes(chapterName) && !storyboard.includes(`!${chapterName}`)) | ||
.map(chapterName => (0, index_1.getNormalizedChapterEntity)(`!${chapterName}`)); | ||
return [...storyboardChapters, ...otherChapters]; | ||
} | ||
@@ -225,2 +232,23 @@ exports.convertStoryboardStructureV1ToV2 = convertStoryboardStructureV1ToV2; | ||
exports.removeSubslidesFromNormalizedSlides = removeSubslidesFromNormalizedSlides; | ||
function makeV1StructureJSON(nestedSlidesData) { | ||
const structureScheme = { | ||
slides: {}, | ||
chapters: {}, | ||
storyboard: [], | ||
}; | ||
restoreSlidesStructure(nestedSlidesData, structureScheme); | ||
const nestedChapters = restoreChaptersStructure(nestedSlidesData, structureScheme); | ||
restoreStoryboard(nestedChapters, structureScheme); | ||
return structureScheme; | ||
} | ||
exports.makeV1StructureJSON = makeV1StructureJSON; | ||
function makeV2StructureJSON(nestedSlidesData) { | ||
const typedChapters = (0, index_1.getChaptersFromNestedSlides)(nestedSlidesData); | ||
const slidesRecord = (0, index_1.getV2SlidesRecord)(nestedSlidesData); | ||
const storyboardRecord = (0, index_1.getV2StoryboardRecord)(typedChapters); | ||
const archivedSlidesRecord = (0, index_1.getV2ArchivedSlidesRecord)(nestedSlidesData); | ||
const chaptersRecord = (0, index_1.getV2ChaptersRecord)(typedChapters, nestedSlidesData); | ||
return Object.assign({ structureFileVersion: 2 }, slidesRecord, chaptersRecord, storyboardRecord, archivedSlidesRecord); | ||
} | ||
exports.makeV2StructureJSON = makeV2StructureJSON; | ||
//# sourceMappingURL=helpers.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getChapterCustomFields = exports.getSlideCustomFields = exports.normalizeStructureV1Chapters = exports.normalizeStructureV1Subslides = exports.flatChapterContent = exports.getChapterSlidesFromNested = exports.getNormalizedChapterEntity = exports.getNormalizedSlideEntity = exports.normalizeEntityForStructureV1 = exports.nestedSlideHasNoSubslides = exports.isSubslide = exports.getFiltersList = exports.getDefinitelyArchivedSlides = exports.listIncludesSlide = exports.getHiddenSlides = exports.getNormalizedChapters = exports.getSlidesWithSubslides = exports.getAllContent = exports.normalizeChapter = exports.normalizeSlide = exports.normalizeEntity = void 0; | ||
exports.getV2ArchivedSlidesRecord = exports.getV2SlidesRecord = exports.getV2ChaptersRecord = exports.getV2StoryboardRecord = exports.getChaptersFromNestedSlides = exports.getChapterSlidesById = exports.getStructureV1ArchivedSlides = exports.getChapterCustomFields = exports.getSlideCustomFields = exports.normalizeStructureV1Chapters = exports.normalizeStructureV1Subslides = exports.flatChapterContent = exports.getChapterSlidesFromNested = exports.getNormalizedChapterEntity = exports.getNormalizedSlideEntity = exports.normalizeEntityForStructureV1 = exports.nestedSlideHasNoSubslides = exports.isSubslide = exports.getFiltersList = exports.getDefinitelyArchivedSlides = exports.listIncludesSlide = exports.getHiddenSlides = exports.getNormalizedChapters = exports.getSlidesWithSubslides = exports.getAllContent = exports.normalizeChapter = exports.normalizeSlide = exports.normalizeEntity = void 0; | ||
const interfaces_1 = require("../types/interfaces"); | ||
@@ -97,3 +97,3 @@ const types_1 = require("../types/types"); | ||
function getNormalizedSlideEntity(entity) { | ||
if (entity.startsWith('!')) { | ||
if (isV1HiddenEntity(entity)) { | ||
return { | ||
@@ -108,3 +108,3 @@ slide: entity.replace('!', ''), | ||
function getNormalizedChapterEntity(entity) { | ||
if (entity.startsWith('!')) { | ||
if (isV1HiddenEntity(entity)) { | ||
return { | ||
@@ -122,3 +122,3 @@ chapter: entity.replace('!', ''), | ||
.map(nestedSlide => { | ||
return nestedSlide.type === interfaces_1.StructureApi.SlideType.Hidden ? `!${nestedSlide.id}` : nestedSlide.id; | ||
return nestedSlide.type === interfaces_1.StructureApi.SlideType.Archived ? `!${nestedSlide.id}` : nestedSlide.id; | ||
}); | ||
@@ -138,7 +138,16 @@ } | ||
exports.flatChapterContent = flatChapterContent; | ||
function normalizeStructureV1Subslides(slides) { | ||
function normalizeStructureV1Subslides(structureJson) { | ||
const slides = structureJson.slides; | ||
const rawSlides = Object.entries(slides).map(slideEntry => { | ||
const slideData = slideEntry[1]; | ||
if (slideData.subslides) { | ||
slideData.subslides = slideData.subslides.map(subslideName => { | ||
slideData.subslides = slideData.subslides | ||
.filter(slide => !isV1HiddenEntity(slide)) | ||
.map(subslideName => { | ||
if (typeof subslideName === 'string' && subslideIsHidden(structureJson, subslideName)) { | ||
return { | ||
slide: subslideName.replace('!', ''), | ||
hidden: true | ||
}; | ||
} | ||
if (typeof subslideName === 'string') { | ||
@@ -159,6 +168,9 @@ return getNormalizedSlideEntity(subslideName); | ||
const { content } = chapterEntry[1]; | ||
const normalizedContent = content.map(slideName => { | ||
const normalizedSlide = getNormalizedSlideEntity(slideName); | ||
return normalizedSlide; | ||
}); | ||
const isHiddenChapter = (id) => { | ||
const slideChapter = getV1SlideChapter(structure, id) ?? getV1SlideChapter(structure, `!${id}`) ?? ''; | ||
return getV1ChapterType(structure, slideChapter) === interfaces_1.StructureApi.ChapterType.Hidden; | ||
}; | ||
const normalizedContent = content | ||
.filter(slideName => !isV1HiddenEntity(slideName)) | ||
.map(slideName => isHiddenChapter(slideName) ? { slide: slideName, hidden: true } : slideName); | ||
const normalizedChapterData = { | ||
@@ -192,2 +204,175 @@ name: chapterEntry[1].name, | ||
exports.getChapterCustomFields = getChapterCustomFields; | ||
function getStructureV1ArchivedSlides(structureJson) { | ||
const slidesV1Subslides = Object.values(structureJson.slides).flatMap(slide => slide.subslides || []).filter(elem => elem); | ||
const chaptersV1Slides = Object.values(structureJson.chapters).flatMap(chapterData => chapterData.content); | ||
const allExistingV1Slides = [...slidesV1Subslides, ...chaptersV1Slides]; | ||
Object.keys(structureJson.slides).forEach(slide => { | ||
if (allExistingV1Slides.includes(slide) || allExistingV1Slides.includes(`!${slide}`)) { | ||
return; | ||
} | ||
allExistingV1Slides.push(slide); | ||
}); | ||
return allExistingV1Slides | ||
.map(slideId => ({ id: slideId, type: getV1SlideType(structureJson, slideId) })) | ||
.filter(slideData => slideData.type === interfaces_1.StructureApi.SlideType.Archived) | ||
.map(slideData => ({ slide: slideData.id.replace('!', ''), chapter: getV1SlideChapter(structureJson, slideData.id) })); | ||
} | ||
exports.getStructureV1ArchivedSlides = getStructureV1ArchivedSlides; | ||
function getV1ChapterType(structureJson, chapterId) { | ||
const chapterIncludedToStoryboard = structureJson.storyboard.includes(chapterId) || structureJson.storyboard.includes(`!${chapterId}`); | ||
const chapterIsHidden = structureJson.storyboard.some(chapter => chapter === `!${chapterId}`); | ||
const isHidden = !chapterIncludedToStoryboard || isV1HiddenEntity(chapterId) || chapterIsHidden; | ||
return isHidden ? interfaces_1.StructureApi.ChapterType.Hidden : interfaces_1.StructureApi.ChapterType.Visible; | ||
} | ||
function getV1SlideType(structureJson, slideId) { | ||
const slideChapter = getV1SlideChapter(structureJson, slideId); | ||
const parentSlide = getV1ParentSlide(structureJson, slideId, slideChapter || ''); | ||
if (parentSlide && !isV1HiddenEntity(slideId)) { | ||
return getV1SlideType(structureJson, parentSlide); | ||
} | ||
if (isV1HiddenEntity(slideId) || !slideChapter) { | ||
return interfaces_1.StructureApi.SlideType.Archived; | ||
} | ||
if (slideChapter) { | ||
return getV1ChapterType(structureJson, slideChapter); | ||
} | ||
return interfaces_1.StructureApi.SlideType.Visible; | ||
} | ||
function getV1SlideChapter(structureJson, slideId) { | ||
const chapterSlidesSet = {}; | ||
const slidesSubslidesSet = {}; | ||
Object.keys(structureJson.chapters).forEach(chapterId => { | ||
chapterSlidesSet[chapterId] = structureJson.chapters[chapterId].content; | ||
}); | ||
const chapterEntry = findSlide(Object.entries(chapterSlidesSet), slideId); | ||
if (chapterEntry) { | ||
return chapterEntry[0]; | ||
} | ||
Object.keys(structureJson.slides).forEach(slideId => { | ||
slidesSubslidesSet[slideId] = structureJson.slides[slideId].subslides || []; | ||
}); | ||
const parentSlide = findSlide(Object.entries(slidesSubslidesSet), slideId); | ||
if (parentSlide) { | ||
const chapterEntry = Object.entries(chapterSlidesSet) | ||
.find(([chapterId, slides]) => slides.includes(parentSlide[0]) || slides.includes(`!${parentSlide[0]}`)); | ||
return chapterEntry ? chapterEntry[0] : undefined; | ||
} | ||
return; | ||
} | ||
function getV1ParentSlide(structureJson, slideId, slideChapter) { | ||
const parent = Object.entries(structureJson.slides).find(([slide, slideData]) => { | ||
return slideData.subslides?.includes(slideId) || slideData.subslides?.includes(`!${slideId}`); | ||
}); | ||
const parentId = parent ? parent[0] : undefined; | ||
return structureJson.chapters[slideChapter]?.content.find(slide => slide === parentId || slide === `!${parentId}`); | ||
} | ||
function findSlide(entries, slideId) { | ||
return entries.find(([slide, subslides]) => subslides.includes(slideId) || subslides.includes(`!${slideId}`)); | ||
} | ||
function getChapterSlidesById(nestedSlides, chapterId) { | ||
const chapterSlides = nestedSlides.filter(slide => slide.chapter?.id === chapterId).map(nestedSlide => { | ||
if (nestedSlide.type === interfaces_1.StructureApi.SlideType.Hidden) { | ||
return { slide: nestedSlide.id, hidden: true }; | ||
} | ||
return nestedSlide.id; | ||
}); | ||
return chapterSlides.map(slideEntity => { | ||
if (typeof slideEntity === 'string') { | ||
const nestedSlide = nestedSlides.find(slide => slide.id === slideEntity); | ||
if (nestedSlide?.subslides.length) { | ||
return { | ||
slide: slideEntity, | ||
subslides: nestedSlide?.subslides.map(subslide => ({ | ||
slide: subslide.id, | ||
hidden: subslide.type === interfaces_1.StructureApi.SlideType.Hidden | ||
})) | ||
}; | ||
} | ||
return slideEntity; | ||
} | ||
const nestedSlide = nestedSlides.find(slide => slide.id === slideEntity.slide); | ||
const slideData = { | ||
slide: slideEntity.slide, | ||
hidden: slideEntity.hidden, | ||
}; | ||
if (nestedSlide?.subslides?.length) { | ||
slideData.subslides = nestedSlide?.subslides.map(subslide => ({ | ||
slide: subslide.id, | ||
hidden: subslide.type === interfaces_1.StructureApi.SlideType.Hidden | ||
})); | ||
} | ||
return slideData; | ||
}); | ||
} | ||
exports.getChapterSlidesById = getChapterSlidesById; | ||
function getChaptersFromNestedSlides(nestedSlidesData) { | ||
return nestedSlidesData | ||
.map(slideData => ({ | ||
id: slideData.chapter?.id, | ||
name: slideData.chapter?.name, | ||
type: slideData.chapter?.type, | ||
storyboardIndex: slideData.chapter?.storyboardIndex, | ||
custom: slideData.chapter?.custom, | ||
})) | ||
.filter(chapterData => !!chapterData.id) | ||
.reduce((acc, chapterData) => { | ||
if (!acc.some(elem => elem.id === chapterData?.id)) { | ||
acc.push(chapterData); | ||
} | ||
return acc; | ||
}, []); | ||
} | ||
exports.getChaptersFromNestedSlides = getChaptersFromNestedSlides; | ||
function getV2StoryboardRecord(typedChapters) { | ||
const chaptersForStoryboard = typedChapters.filter(chapter => chapter.storyboardIndex !== undefined) | ||
.sort((first, second) => { | ||
if (first.storyboardIndex === undefined || second.storyboardIndex === undefined) { | ||
return 0; | ||
} | ||
return first.storyboardIndex - second.storyboardIndex; | ||
}); | ||
const storyboard = chaptersForStoryboard.map(chapterData => chapterData.type === interfaces_1.StructureApi.ChapterType.Hidden ? { chapter: chapterData.id, hidden: true } : chapterData.id); | ||
return { storyboard }; | ||
} | ||
exports.getV2StoryboardRecord = getV2StoryboardRecord; | ||
function getV2ChaptersRecord(typedChapters, nestedSlidesData) { | ||
const chapterEntries = typedChapters.map(chapterData => [ | ||
chapterData.id, | ||
{ | ||
name: chapterData.name, | ||
content: getChapterSlidesById(nestedSlidesData, chapterData.id || ''), | ||
...chapterData.custom, | ||
} | ||
]); | ||
return { chapters: Object.fromEntries(chapterEntries) }; | ||
} | ||
exports.getV2ChaptersRecord = getV2ChaptersRecord; | ||
function getV2SlidesRecord(nestedSlidesData) { | ||
const slidesAsEntries = nestedSlidesData.map(slideData => [slideData.id, { name: slideData.name, template: slideData.template, ...slideData.custom }]); | ||
const slidesRecord = { slides: Object.fromEntries(slidesAsEntries) }; | ||
const subslidesAsEntries = nestedSlidesData | ||
.flatMap(slideData => slideData.subslides) | ||
.map(slideData => [slideData.id, { name: slideData.name, template: slideData.template, ...slideData.custom }]); | ||
subslidesAsEntries.forEach(subslideEntry => slidesRecord.slides[subslideEntry[0]] = subslideEntry[1]); | ||
return slidesRecord; | ||
} | ||
exports.getV2SlidesRecord = getV2SlidesRecord; | ||
function getV2ArchivedSlidesRecord(nestedSlidesData) { | ||
return { | ||
archivedSlides: nestedSlidesData | ||
.filter(slideData => slideData.type === interfaces_1.StructureApi.SlideType.Archived) | ||
.map(slideData => ({ slide: slideData.id, chapter: slideData.chapter?.id })) | ||
}; | ||
} | ||
exports.getV2ArchivedSlidesRecord = getV2ArchivedSlidesRecord; | ||
function isV1HiddenEntity(entity) { | ||
return entity.startsWith('!'); | ||
} | ||
function subslideIsHidden(structureJson, subslideName) { | ||
const subslideChapter = getV1SlideChapter(structureJson, subslideName); | ||
const subslideParent = getV1ParentSlide(structureJson, subslideName, subslideChapter ?? ''); | ||
const parentSlideType = getV1SlideType(structureJson, subslideParent ?? ''); | ||
const subslideChapterType = getV1ChapterType(structureJson, subslideChapter ?? ''); | ||
return typeof subslideName === 'string' && (parentSlideType === interfaces_1.StructureApi.SlideType.Hidden || subslideChapterType === interfaces_1.StructureApi.ChapterType.Hidden); | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@ewizardjs/structure-api", | ||
"version": "0.1.3", | ||
"version": "1.0.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
450
README.md
## **StructureApi** | ||
Structure API is a set of separate functions for working with structure.json. | ||
# STRUCTURE API | ||
### Installation: | ||
```npm i @ewizardjs/structure``` | ||
Note: You can also use the api from ewizardjs | ||
### Usage: | ||
**In your .ts/js files:** | ||
`` | ||
import { | ||
getSlides, | ||
getFlatSlides, | ||
getVisibleSlides, | ||
getFlatVisibleSlides, | ||
getHiddenSlides, | ||
getFlatHiddenSlides, | ||
getArchivedSlides, | ||
getSlide, | ||
getChapters, | ||
getHiddenChapters, | ||
getChapter, | ||
getChapterSlides, | ||
getSlideSubslides, | ||
getStartSlide, | ||
getStoryboard, | ||
StructureApi, | ||
getStructureFileVersion, | ||
getVisibleChapters, | ||
getFlatSlide, | ||
} from '@ewizardjs/structure'; | ||
`` | ||
**In your content (.vue files):** | ||
``this.$structure.someMethod()`` | ||
Structure api is a set of methods that will allow you to simplify your work with slides, chapters, storyboard, structure.json and the structure of the eDetailer as a whole. | ||
It also can be used in content from *ewizardjs* module. | ||
*Note: in order to get the values in the **thumbnail** field when calling the corresponding methods, they need to pass a fragment of the systemSettings object* | ||
### Data structures: | ||
- SlideType | ||
* **type**: `string` | ||
* **values**: `visible`, `hidden`, `archived` | ||
- ChapterType | ||
* **type**: `string` | ||
* **values**: `visible`, `hidden` | ||
- SlideTypes | ||
* **type**: Object | ||
* **value**: `{ | ||
visible: boolean; | ||
hidden: boolean; | ||
archived: boolean; | ||
}` | ||
- ChapterTypes | ||
* **type**: Object | ||
* **value**: `{ | ||
visible: boolean; | ||
hidden: boolean; | ||
}` | ||
- SlideData | ||
* **type**: Object | ||
* **value**: `{ | ||
id: string; | ||
name: string; | ||
chapter: string | undefined; | ||
type: SlideType; | ||
thumbnail?: string; | ||
template?: string; | ||
}` | ||
- FlatSlideData | ||
* **type**: Object | ||
* **value**: `{ | ||
id: string; | ||
name: string; | ||
chapter: string | undefined; | ||
type: SlideType; | ||
thumbnail?: string; | ||
template?: string; | ||
isSubslide: boolean; | ||
parentSlide?: string; | ||
}` | ||
- NestedSlideData | ||
* **type**: Object | ||
* **value**: `{ | ||
id: string; | ||
name: string; | ||
chapter: string | undefined; | ||
type: SlideType; | ||
thumbnail?: string; | ||
template?: string; | ||
subslides: SlideData[]; | ||
}` | ||
- ChapterData | ||
* **type**: Object | ||
* **value**: `{ | ||
id: string; | ||
name: string; | ||
type: ChapterType; | ||
}` | ||
- NestedChapterData | ||
* **type**: Object | ||
* **value**: `{ | ||
id: string; | ||
name: string; | ||
type: ChapterType; | ||
slides: NestedSlideData[]; | ||
}` | ||
- SystemSettingsSlideFragment | ||
* **type**: Object | ||
* **value**: `{ | ||
path: { | ||
slides: string, | ||
slide: { | ||
thumbnail: string | ||
} | ||
} | ||
}` | ||
- StartSlide | ||
* **type**: Object | ||
* **value**: `{ | ||
slide?: string; | ||
chapter?: string; | ||
}` | ||
Install structure-api with npm | ||
### Functions | ||
```bash | ||
npm i @ewizardjs/structure-api | ||
``` | ||
------------ | ||
## Usage/Examples | ||
In your ".ts"/".js" files: | ||
```javascript | ||
import { | ||
getSlides, | ||
getSlidesAsync, | ||
getFlatSlides, | ||
getVisibleSlides, | ||
getFlatVisibleSlides, | ||
getHiddenSlides, | ||
getFlatHiddenSlides, | ||
getArchivedSlides, | ||
getSlide, | ||
getFlatSlide, | ||
getChapters, | ||
getHiddenChapters, | ||
getVisibleChapters, | ||
getChapter, | ||
getChapterSlides, | ||
getFlatChapterSlides, | ||
getSlideSubslides, | ||
getStartSlide, | ||
getStoryboard, | ||
getStructureFileVersion, | ||
convertToStructureV2, | ||
makeStructure, | ||
supportsStructureV2, | ||
} from '@ewizardjs/structure-api'; | ||
const structure = readJson('./structure.json'); | ||
const visibleSlides = getSlides(structure, { visible: true }); | ||
const storyboard = getStoryboard(structure); | ||
const onlyVisisbleSlidesStructure = makeStructure(visibleSlides); | ||
``` | ||
In your ".vue" files: | ||
- **getSlides** | ||
* args: | ||
- structureJson | ||
*type:* `StructureV2.iStructureJSON`, | ||
*optional:* `false` | ||
- slideTypes | ||
*type:* `SlideTypes` | ||
*optional:* `true` | ||
- systemSettings | ||
*type:* `SystemSettingsSlideFragment` | ||
*optional:* `true` | ||
* return | ||
- type: `Array`, | ||
- value: Array of `NestedSlideData` | ||
```javascript | ||
this.$structure.someMethod() | ||
``` | ||
- **getFlatSlides** | ||
* args: | ||
- structureJson | ||
*type:* `StructureV2.iStructureJSON`, | ||
*optional:* `false` | ||
- slideTypes | ||
*type:* `SlideTypes` | ||
*optional:* `true` | ||
- systemSettings | ||
*type:* `SystemSettingsSlideFragment` | ||
*optional:* `true` | ||
* return | ||
- type: `Array`, | ||
- value: Array of `FlatSlideData` | ||
- **getVisibleSlides** | ||
* args: | ||
- structureJson | ||
*type:* `StructureV2.iStructureJSON`, | ||
*optional:* `false` | ||
- systemSettings | ||
*type:* `SystemSettingsSlideFragment` | ||
*optional:* `true` | ||
* return | ||
- type: `Array`, | ||
- value: Array of `NestedSlideData` | ||
## Data-structures | ||
| Name | Fields | | ||
| :-------- | :-------------------------------- | | ||
| NestedSlideData | id, name, chapter , type , thumbnail, template, custom, subslides | | ||
| FlatSlideData | id, name, chapter , type , thumbnail, template, custom, subslides, isSubslide ,parentSlide | | ||
| ChapterData | id, name, type, custom | | ||
| StartSlide | slide, chapter | | ||
| NestedChapterData | id, name, type, slides | | ||
- **getFlatVisibleSlides** | ||
* args: | ||
- structureJson | ||
*type:* `StructureV2.iStructureJSON`, | ||
*optional:* `false` | ||
- systemSettings | ||
*type:* `SystemSettingsSlideFragment` | ||
*optional:* `true` | ||
* return | ||
- type: `Array`, | ||
- value: Array of `FlatSlideData` | ||
- **getHiddenSlides** | ||
* args: | ||
- structureJson | ||
*type:* `StructureV2.iStructureJSON`, | ||
*optional:* `false` | ||
- systemSettings | ||
*type:* `SystemSettingsSlideFragment` | ||
*optional:* `true` | ||
* return | ||
- type: `Array`, | ||
- value: Array of `NestedSlideData` | ||
## Available Interfaces / Types / etc | ||
| Name | Description | | ||
| :-------- | :-------------------------------- | | ||
| StructureApi | Namespace under which all api methods are available, as well as data structures and their types | | ||
| iStructureJSON | Union for structure.json format version 1 or 2 | | ||
| StructureV1 | Namespace under which the json structure format of the first version, the slide and chapter interface are available | | ||
| StructureV2 | Namespace under which the json structure format of the second version, the slide and chapter interface are available as well as the Storyboard element | | ||
| iStart | Start slide interface | | ||
- **getFlatHiddenSlides** | ||
* args: | ||
- structureJson | ||
*type:* `StructureV2.iStructureJSON`, | ||
*optional:* `false` | ||
- systemSettings | ||
*type:* `SystemSettingsSlideFragment` | ||
*optional:* `true` | ||
* return | ||
- type: `Array`, | ||
- value: Array of `FlatSlideData` | ||
- **getArchivedSlides** | ||
* args: | ||
- structureJson | ||
*type:* `StructureV2.iStructureJSON`, | ||
*optional:* `false` | ||
- systemSettings | ||
*type:* `SystemSettingsSlideFragment` | ||
*optional:* `true` | ||
* return | ||
- type: `Array`, | ||
- value: Array of `NestedSlideData` | ||
## API Reference | ||
- **getSlide** | ||
* args: | ||
- structureJson | ||
*type:* `StructureV2.iStructureJSON`, | ||
*optional:* `false` | ||
- slideId | ||
*type:* `string` | ||
*optional:* `false` | ||
- systemSettings | ||
*type:* `SystemSettingsSlideFragment` | ||
*optional:* `true` | ||
* return | ||
- type: `Object`, | ||
- value: `NestedSlideData` | ||
| Method | Arguments | Execution result | Description | | ||
| :-------- | :------- | :-------------------------------- | :-------------------------------- | | ||
| `getSlide` | `structureJson`, `slideId`[, `systemSettings`] | Object of type `NestedSlideData` or `undefined` | To retrieve information about a single, specific slide, use this method | | ||
| `getSlides` | `structureJson`[, `slideTypes` [, `systemSettings`]] | Array of objects of type `NestedSlideData` | Use this method to get information about all slides | | ||
| `getSlidesAsync` | `structureJson`[, `slideTypes`[, `systemSettings`[, `callback`]]] | Array of objects of type `NestedSlideData` or any other Object | To get custom slide data objects or modify slide fields, use this method. The callback code will be called for all slides, including their subslides. | | ||
| `getFlatSlides` | `structureJson`[, `slideTypes`[, `systemSettings`]] | Array of objects of type `FlatSlideData` | Similar to getSlides, but will return a set of slide objects without the "subslides" field - subslides will be returned along with the slides. Use isSubslide to distinguish between a slide and a subslide | | ||
| `getVisibleSlides` | `structureJson`[, `systemSettings`] | Array of objects of type `NestedSlideData` | Similar to the getSlides method , but will only return slides of the "visible" type | | ||
| `getFlatVisibleSlides` | `structureJson`[, `systemSettings`] | Array of objects of type `FlatSlideData` | Similar to the getFlatSlides method , but will only return slides of the "visible" type | | ||
| `getHiddenSlides` | `structureJson`[, `systemSettings`] | Array of objects of type `NestedSlideData` | Similar to the getSlides method , but will only return slides of the "hidden" type | | ||
| `getFlatHiddenSlides` | `structureJson`[, `systemSettings`] | Array of objects of type `FlatSlideData` | Similar to the getFlatSlides method , but will only return slides of the "visible" type | | ||
| `getArchivedSlides` | `structureJson`[, `systemSettings`] | Array of objects of type `NestedSlideData` | Similar to the getSlides method , but will only return slides of the "archived" type | | ||
| `getFlatSlide` | `structureJson`, `slideId`[, `systemSettings`] | Object of type `FlatSlideData` | To retrieve slide data (without the "subslides" field) or to check if a given slide is a subslide or to retrieve a parent slide, use this method. | | ||
| `getChapters` | `structureJson`[, `chapterTypes`] | Array of objects of type `ChapterData` | Use this method to get a list of chapters and define their types. The order is determined by the order in the "chapters" field | | ||
| `getHiddenChapters` | `structureJson` | Array of objects of type `ChapterData` | Similar to the "getChapters" method, but it will only return "hidden" chapters | | ||
| `getVisibleChapters` | `structureJson` | Array of objects of type `ChapterData` | Similar to the "getChapters" method, but it will only return "visible" chapters | | ||
| `getChapter` | `structureJson`, `chapterId` | Object of type `ChapterData` or `undefined` | Use this method to get a chapter data or check if it exists | | ||
| `getChapterSlides` | `structureJson`, `chapterId`[, `slideTypes`[, `systemSettings`]] | Array of objects of type `NestedSlideData` | Similar to the getSlides method , but will only return slides of the passed chapter | | ||
| `getFlatChapterSlides` | `structureJson`, `chapterId`[, `slideTypes`[, `systemSettings`]] | Array of objects of type `FlatSlideData` | Similar to the getFlatSlides method , but will only return slides of the passed chapter | | ||
| `getSlideSubslides` | `structureJson`, `slideId`[, `slideTypes`[, `systemSettings`]] | Array of objects of type `SlideData`| Use this method to get a subslide of a particular slide | | ||
| `getStartSlide` | `structureJson`[, `systemSettings`] | Object of type `StartSlide` or `undefined` | Use to get a starting slide. If not specified explicitly in structure.json - it will return the first "visible" slide | | ||
| `getStoryboard` | `structureJson`[, `chapterTypes`[, `systemSettings`]] | Array of objects of type `NestedChapterData` | Returns the list of chapters and slides in them, based on their order in the "storyboard" and "content" fields, respectively | | ||
| `getStructureFileVersion` | `structureJson` | `number` | Returns the file format number of the structure.json file | | ||
| `convertToStructureV2` | `structureJson` | JSON of type `StructureV2.iStructureJSON` | Use when you want to convert structure.json content to version 2 | | ||
| `makeStructure` | `nestedSlidesData`, `targetStructureVersion` | JSON of type `iStructureJSON` | Accepts nestedSlidesData objects as input and builds structure.json content based on them | | ||
| `supportsStructureV2` | `ewizardjsVersion` | `boolean` | Use if necessary to check if the version of "ewizardjs" transferred supports the structure of the second version. (Incompatible structure.json and content versions cause navigation problems, etc.) | | ||
- **getFlatSlide** | ||
* args: | ||
- structureJson | ||
*type:* `StructureV2.iStructureJSON`, | ||
*optional:* `false` | ||
- slideId | ||
*type:* `string` | ||
*optional:* `false` | ||
- systemSettings | ||
*type:* `SystemSettingsSlideFragment` | ||
*optional:* `true` | ||
* return | ||
- type: `Object`, | ||
- value: `FlatSlideData` | ||
## Arguments of the methods | ||
| Name | Description | Example | | ||
| :-------- | :-------------------------------- | :-------------------------------- | | ||
| `structureJson` | structure.json file content | -- | | ||
| `slideTypes` | The filters object for the slide type | { visible?: true, hidden?: false, archived?: false } | | ||
| `systemSettings` | Fragment of the default paths object. Necessary to form a thumbnail path in slide-type structures. Can be obtained from module "@ewizardjs/system-settings". If not passed - field "thumbnail" will be empty for all slides and subslides | { path: { slides: string, slide: { thumbnail: string }}} | | ||
| `chapterTypes` | The filters object for the chapters type | { visible?: true, hidden?: false } | | ||
| `slideId` | String that represents target slide id | 'custom' | | ||
| `chapterId` | String that represents target chapter id | 'home' | | ||
| `targetStructureVersion` | structure.json format version. Default is 1 | 2 | | ||
| `ewizardjsVersion` |The full version of the "ewizardjs" module. The version must be valid for the "semver" module | '5.23.0' | | ||
- **getChapters** | ||
* args: | ||
- structureJson | ||
*type:* `StructureV2.iStructureJSON`, | ||
*optional:* `false` | ||
- chapterTypes | ||
*type:* `ChapterTypes` | ||
*optional:* `true` | ||
* return | ||
- type: `Array`, | ||
- value: Array of `ChapterData` | ||
## How does type detection works? | ||
- **getHiddenChapters** | ||
* args: | ||
- structureJson | ||
*type:* `StructureV2.iStructureJSON`, | ||
*optional:* `false` | ||
* return | ||
- type: `Array`, | ||
- value: Array of `ChapterData` | ||
Structure-api methods work in 2 steps. | ||
On the first stage the JSON version of the structure is checked. | ||
If it is the first version, it converts to the second one. | ||
On the second stage, they work directly with JSON of the second version. | ||
The following describes the logic of determining the types of slides and chappers at each stage: | ||
- **getVisibleChapters** | ||
* args: | ||
- structureJson | ||
*type:* `StructureV2.iStructureJSON`, | ||
*optional:* `false` | ||
* return | ||
- type: `Array`, | ||
- value: Array of `ChapterData` | ||
**Defining types of slides and chappers when converting the structure of the first version to the second version:** | ||
1. Archived slides: slides that start with "!" or do not have a chapter (missing in the chapters content). | ||
2. Chapter cannot be "archived". If the chapter is not in the storyboard, or it is, but starts with "!" - "hidden" | ||
- **getChapter** | ||
* args: | ||
- structureJson | ||
*type:* `StructureV2.iStructureJSON`, | ||
*optional:* `false` | ||
- chapterId | ||
*type:* `string` | ||
*optional:* `false` | ||
* return | ||
- type: `Object`, | ||
- value: `ChapterData` | ||
**Defining types of slides and chappers when working with the structure of version 2:** | ||
1. A chapter cannot be an archive at all. Chapter is "visible" if it is present in the storyboard and has { hidden: false }. In other cases, it is "hidden". | ||
2. A slide can be "archived" only if it has no chapter , or if it is listed as archived in "archivedSlides" field. | ||
- **getChapterSlides** | ||
* args: | ||
- structureJson | ||
*type:* `StructureV2.iStructureJSON`, | ||
*optional:* `false` | ||
- chapterId | ||
*type:* `string` | ||
*optional:* `false` | ||
- slideTypes | ||
*type:* `SlideTypes` | ||
*optional:* `true` | ||
- systemSettings | ||
*type:* `SystemSettingsSlideFragment` | ||
*optional:* `true` | ||
* return | ||
- type: `Array`, | ||
- value: Array of `SlideData` | ||
- **getSlideSubslides** | ||
* args: | ||
- structureJson | ||
*type:* `StructureV2.iStructureJSON`, | ||
*optional:* `false` | ||
- slideId | ||
*type:* `StructureV2.iStructureJSON`, | ||
*optional:* `false` | ||
- slideTypes | ||
*type:* `SlideTypes` | ||
*optional:* `true` | ||
- systemSettings | ||
*type:* `SystemSettingsSlideFragment` | ||
*optional:* `true` | ||
* return | ||
- type: `Array`, | ||
- value: Array of `SlideData` | ||
- **getStartSlide** | ||
* args: | ||
- structureJson | ||
*type:* `StructureV2.iStructureJSON`, | ||
*optional:* `false` | ||
* return | ||
- type: `Object`, | ||
- value: `StartSlide` | ||
- **getStoryboard** | ||
* args: | ||
- structureJson | ||
*type:* `StructureV2.iStructureJSON`, | ||
*optional:* `false` | ||
- chapterTypes | ||
*type:* `ChapterTypes` | ||
*optional:* `true` | ||
- systemSettings | ||
*type:* `SystemSettingsSlideFragment` | ||
*optional:* `true` | ||
* return | ||
- type: `Array`, | ||
- value: Array of `NestedChapterData` | ||
- **getStructureFileVersion** | ||
* args: | ||
- structureJson | ||
*type:* `StructureV2.iStructureJSON`, | ||
*optional:* `false` | ||
* return | ||
- type: `Number`, | ||
- value: `1` or `2` | ||
## How is the order of slides determined? | ||
There are two main methods for getting slides: `getSlides` and `getFlatSlides` (the other methods overuse these). The order of the slides is determined by the order of the chapters in the "chapters" field of the structure.json file. Getting a list of all chapters from this field collects all slides from each chapter (from the "content" field). During this assembly, if a slide from the "content" field has sub-slides, they will go right after the parent slide. After that, this set is supplemented with slides that are in the "slides" field of structure.json file, but were not included in the previous stages. | ||
If the order of chapters and slides is important to you, use the `getStoryboard` method |
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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
113483
1297
1
135