@flipbook-md/core 0.14.0 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +12 -0
- package/package.json +1 -1
- package/src/slides.js +4 -2
package/index.d.ts
CHANGED
|
@@ -447,6 +447,18 @@ export function insertSlide(
|
|
|
447
447
|
export function removeSlide(deckPath: string, slideId: SlideId, baseHash: string): Promise<{ hashes: Record<string, string> }>;
|
|
448
448
|
/** `slideIds` must be a permutation of the deck's slides, or it throws ValidationError. */
|
|
449
449
|
export function reorderSlides(deckPath: string, slideIds: SlideId[], baseHash: string): Promise<{ hashes: Record<string, string> }>;
|
|
450
|
+
/**
|
|
451
|
+
* A single-file deck's text as `glue[0] cores[0] glue[1] … cores[n-1] glue[n]`, split the way
|
|
452
|
+
* the slide writer splits it: `---` lines outside notes comments, after the frontmatter. Cores
|
|
453
|
+
* are the slides without surrounding whitespace; glue holds the frontmatter, blank lines and `---`.
|
|
454
|
+
*/
|
|
455
|
+
export interface ChunkLayout {
|
|
456
|
+
cores: string[];
|
|
457
|
+
glue: string[];
|
|
458
|
+
}
|
|
459
|
+
export function chunkLayout(text: string): ChunkLayout;
|
|
460
|
+
/** The inverse of chunkLayout: `joinLayout(chunkLayout(text)) === text`. */
|
|
461
|
+
export function joinLayout(layout: ChunkLayout): string;
|
|
450
462
|
|
|
451
463
|
// server
|
|
452
464
|
/**
|
package/package.json
CHANGED
package/src/slides.js
CHANGED
|
@@ -531,8 +531,9 @@ async function structureBase(deckPath, baseHash) {
|
|
|
531
531
|
/**
|
|
532
532
|
* A single-file deck as glue and chunk cores: `glue[0] core[0] glue[1] core[1] … glue[n]`.
|
|
533
533
|
* Cores are the chunks without surrounding whitespace; glue holds frontmatter, blank lines and `---`.
|
|
534
|
+
* Exported so tools can swap one slide's text and keep every other byte (Studio's slide restore).
|
|
534
535
|
*/
|
|
535
|
-
function chunkLayout(text) {
|
|
536
|
+
export function chunkLayout(text) {
|
|
536
537
|
const bom = text.startsWith("") ? 1 : 0;
|
|
537
538
|
const cores = chunkSpans(text.slice(bom)).map(([from, to]) => {
|
|
538
539
|
const raw = text.slice(from + bom, to + bom);
|
|
@@ -549,7 +550,8 @@ function chunkLayout(text) {
|
|
|
549
550
|
return { cores: cores.map(([from, to]) => text.slice(from, to)), glue };
|
|
550
551
|
}
|
|
551
552
|
|
|
552
|
-
|
|
553
|
+
/** The inverse of chunkLayout: `joinLayout(chunkLayout(text)) === text`. */
|
|
554
|
+
export function joinLayout({ cores, glue }) {
|
|
553
555
|
return cores.map((core, index) => glue[index] + core).join("") + glue[cores.length];
|
|
554
556
|
}
|
|
555
557
|
|