@segnavia/format 0.12.0 → 0.13.0
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/dist/board-edit.d.ts +11 -0
- package/dist/board-edit.js +66 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Board, BoardItem } from "./board.js";
|
|
2
|
+
import { Point } from "./deck.js";
|
|
3
|
+
//#region src/board-edit.d.ts
|
|
4
|
+
export declare const MIN_BOARD_ITEM_WIDTH = 16;
|
|
5
|
+
export type BoardItemAnchor = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
6
|
+
export declare function moveItems(board: Board, ids: readonly string[], delta: Point): Board;
|
|
7
|
+
export declare function moveSection(board: Board, sectionId: string, delta: Point): Board;
|
|
8
|
+
export declare function resizeItem(board: Board, id: string, width: number, anchor: BoardItemAnchor, heightAt: (width: number) => number): Board;
|
|
9
|
+
export declare function removeItems(board: Board, ids: readonly string[]): Board;
|
|
10
|
+
export declare function addItem(board: Board, item: BoardItem): Board;
|
|
11
|
+
//#endregion
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Board } from "./board.js";
|
|
2
|
+
//#region src/board-edit.ts
|
|
3
|
+
const MIN_BOARD_ITEM_WIDTH = 16;
|
|
4
|
+
function moveItems(board, ids, delta) {
|
|
5
|
+
const moved = new Set(ids);
|
|
6
|
+
return {
|
|
7
|
+
...board,
|
|
8
|
+
items: board.items.map((item) => moved.has(item.id) ? {
|
|
9
|
+
...item,
|
|
10
|
+
x: item.x + delta.x,
|
|
11
|
+
y: item.y + delta.y
|
|
12
|
+
} : item)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function moveSection(board, sectionId, delta) {
|
|
16
|
+
const section = board.sections.find((entry) => entry.id === sectionId);
|
|
17
|
+
if (!section) return board;
|
|
18
|
+
const moved = moveItems(board, section.items, delta);
|
|
19
|
+
return {
|
|
20
|
+
...moved,
|
|
21
|
+
sections: moved.sections.map((entry) => entry.id === sectionId ? {
|
|
22
|
+
...entry,
|
|
23
|
+
rectangle: {
|
|
24
|
+
...entry.rectangle,
|
|
25
|
+
x: entry.rectangle.x + delta.x,
|
|
26
|
+
y: entry.rectangle.y + delta.y
|
|
27
|
+
}
|
|
28
|
+
} : entry)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function resizeItem(board, id, width, anchor, heightAt) {
|
|
32
|
+
const nextWidth = Math.max(16, width);
|
|
33
|
+
return {
|
|
34
|
+
...board,
|
|
35
|
+
items: board.items.map((item) => {
|
|
36
|
+
if (item.id !== id) return item;
|
|
37
|
+
const oldHeight = heightAt(item.width);
|
|
38
|
+
const newHeight = heightAt(nextWidth);
|
|
39
|
+
return {
|
|
40
|
+
...item,
|
|
41
|
+
width: nextWidth,
|
|
42
|
+
x: anchor.endsWith("right") ? item.x + item.width - nextWidth : item.x,
|
|
43
|
+
y: anchor.startsWith("bottom") ? item.y + oldHeight - newHeight : item.y
|
|
44
|
+
};
|
|
45
|
+
})
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function removeItems(board, ids) {
|
|
49
|
+
const removed = new Set(ids);
|
|
50
|
+
return {
|
|
51
|
+
...board,
|
|
52
|
+
items: board.items.filter((item) => !removed.has(item.id)),
|
|
53
|
+
sections: board.sections.map((section) => ({
|
|
54
|
+
...section,
|
|
55
|
+
items: section.items.filter((id) => !removed.has(id))
|
|
56
|
+
}))
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function addItem(board, item) {
|
|
60
|
+
return Board.parse({
|
|
61
|
+
...board,
|
|
62
|
+
items: [...board.items, item]
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { MIN_BOARD_ITEM_WIDTH, addItem, moveItems, moveSection, removeItems, resizeItem };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Board, BoardInput, BoardItem, BoardLabel, BoardSection } from "./board.js";
|
|
2
2
|
import { Annotation, Box, Cue, DECK_SIZE, Deck, DeckInput, DeckLimits, ImageFit, Manifest, Narration, Point, PublishedShot, SHOT_KEY, Shot, Size, Slide, SlideContent, Word, annotationCueIssues, exceedsLimits } from "./deck.js";
|
|
3
|
+
import { BoardItemAnchor, MIN_BOARD_ITEM_WIDTH, addItem, moveItems, moveSection, removeItems, resizeItem } from "./board-edit.js";
|
|
3
4
|
import { ArrangeOptions, BoardShapes, BoardView, MAX_BOARD_ZOOM, MIN_BOARD_ZOOM, ZoomBounds, arrange, boardBounds, boardToScreen, itemAt, itemHeight, revealView, screenToBoard, visibleItems, zoomAt, zoomToFit } from "./board-geometry.js";
|
|
4
5
|
import { BoardListingGroup, boardListing, boardListingIsEmpty, foldForSearch, nameMatches } from "./board-listing.js";
|
|
5
6
|
import { Book, BookContents, BookFrontMatterEntry, BookInput, BookMode, BookPage, BookSection, BookView, BookViewInput, Chapter, isBookContents, isHebrew, noteMarkerIssues } from "./book.js";
|
|
@@ -720,4 +721,4 @@ export declare function jsonSchemas(): {
|
|
|
720
721
|
}, z.core.$strip>>;
|
|
721
722
|
};
|
|
722
723
|
//#endregion
|
|
723
|
-
export { Annotation, type ArrangeOptions, Board, type BoardInput, BoardItem, BoardLabel, type BoardListingGroup, BoardSection, type BoardShapes, type BoardView, Book, BookContents, BookFrontMatterEntry, type BookInput, BookMode, BookPage, BookSection, BookView, type BookViewInput, Box, Chapter, Cue, DECK_SIZE, DEFAULT_TRANSITION_DURATION_MS, Deck, type DeckFromSlidesOptions, type DeckInput, type DeckLimits, Direction, ImageFit, type Imposed, Lexicon, MARK_GAP_MM, MARK_LENGTH_MM, MAX_BOARD_ZOOM, MAX_SLIDE_TIMING_MS, MAX_TRANSITION_DURATION_MS, MIN_BOARD_ZOOM, MIN_TRANSITION_DURATION_MS, MM_PER_PT, Manifest, type MillimeterEdges, NAMED_PAPERS, Narration, NoteMarker, NumberSystem, PAPER_MM, PX_PER_MM, type PageFit, type PagePlacementKind, type PagePlacementLayout, Paper, type PaperBox, type Placement, Point, PronunciationEntry, PublishedShot, SHOT_KEY, Scripts, Shot, type ShotUse, Size, Slide, SlideContent, type SlideRow, TextDirection, Transition, TransitionInput, Word, type ZoomBounds, annotationCueIssues, arrange, boardBounds, boardListing, boardListingIsEmpty, boardToScreen, deckFromSlides, exceedsLimits, firstStrongDirection, fitPage, foldForSearch, formatNumber, impose, isBookContents, isHebrew, itemAt, itemHeight, languageDirection, lexiconVersion, mirrorPlacement, nameMatches, noteMarker, noteMarkerIssues, pagePlacementLayout, printBoxes, printPadding, printProperties, resolveDirection, revealView, roundMillimeters, screenToBoard, sheetMm, shotsUsed, toMillimeters, visibleItems, zoomAt, zoomToFit };
|
|
724
|
+
export { Annotation, type ArrangeOptions, Board, type BoardInput, BoardItem, type BoardItemAnchor, BoardLabel, type BoardListingGroup, BoardSection, type BoardShapes, type BoardView, Book, BookContents, BookFrontMatterEntry, type BookInput, BookMode, BookPage, BookSection, BookView, type BookViewInput, Box, Chapter, Cue, DECK_SIZE, DEFAULT_TRANSITION_DURATION_MS, Deck, type DeckFromSlidesOptions, type DeckInput, type DeckLimits, Direction, ImageFit, type Imposed, Lexicon, MARK_GAP_MM, MARK_LENGTH_MM, MAX_BOARD_ZOOM, MAX_SLIDE_TIMING_MS, MAX_TRANSITION_DURATION_MS, MIN_BOARD_ITEM_WIDTH, MIN_BOARD_ZOOM, MIN_TRANSITION_DURATION_MS, MM_PER_PT, Manifest, type MillimeterEdges, NAMED_PAPERS, Narration, NoteMarker, NumberSystem, PAPER_MM, PX_PER_MM, type PageFit, type PagePlacementKind, type PagePlacementLayout, Paper, type PaperBox, type Placement, Point, PronunciationEntry, PublishedShot, SHOT_KEY, Scripts, Shot, type ShotUse, Size, Slide, SlideContent, type SlideRow, TextDirection, Transition, TransitionInput, Word, type ZoomBounds, addItem, annotationCueIssues, arrange, boardBounds, boardListing, boardListingIsEmpty, boardToScreen, deckFromSlides, exceedsLimits, firstStrongDirection, fitPage, foldForSearch, formatNumber, impose, isBookContents, isHebrew, itemAt, itemHeight, languageDirection, lexiconVersion, mirrorPlacement, moveItems, moveSection, nameMatches, noteMarker, noteMarkerIssues, pagePlacementLayout, printBoxes, printPadding, printProperties, removeItems, resizeItem, resolveDirection, revealView, roundMillimeters, screenToBoard, sheetMm, shotsUsed, toMillimeters, visibleItems, zoomAt, zoomToFit };
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { NoteMarker, NumberSystem, formatNumber, noteMarker } from "./numbering.
|
|
|
8
8
|
import { MARK_GAP_MM, MARK_LENGTH_MM, MM_PER_PT, NAMED_PAPERS, PAPER_MM, PX_PER_MM, Paper, printBoxes, printPadding, printProperties, roundMillimeters, sheetMm, toMillimeters } from "./paper.js";
|
|
9
9
|
import { Book, BookContents, BookFrontMatterEntry, BookMode, BookPage, BookSection, BookShape, BookView, Chapter, isBookContents, isHebrew, noteMarkerIssues } from "./book.js";
|
|
10
10
|
import { Lexicon, PronunciationEntry, lexiconVersion } from "./lexicon.js";
|
|
11
|
+
import { MIN_BOARD_ITEM_WIDTH, addItem, moveItems, moveSection, removeItems, resizeItem } from "./board-edit.js";
|
|
11
12
|
import { MAX_BOARD_ZOOM, MIN_BOARD_ZOOM, arrange, boardBounds, boardToScreen, itemAt, itemHeight, revealView, screenToBoard, visibleItems, zoomAt, zoomToFit } from "./board-geometry.js";
|
|
12
13
|
import { boardListing, boardListingIsEmpty, foldForSearch, nameMatches } from "./board-listing.js";
|
|
13
14
|
import { deckFromSlides } from "./deck-from-slides.js";
|
|
@@ -155,4 +156,4 @@ function jsonSchemas() {
|
|
|
155
156
|
};
|
|
156
157
|
}
|
|
157
158
|
//#endregion
|
|
158
|
-
export { Annotation, Board, BoardItem, BoardLabel, BoardSection, Book, BookContents, BookFrontMatterEntry, BookMode, BookPage, BookSection, BookView, Box, Chapter, Cue, DECK_SIZE, DEFAULT_TRANSITION_DURATION_MS, Deck, Direction, ImageFit, Imposition, Lexicon, MARK_GAP_MM, MARK_LENGTH_MM, MAX_BOARD_ZOOM, MAX_IMPOSITION_CELLS, MAX_SLIDE_TIMING_MS, MAX_TRANSITION_DURATION_MS, MIN_BOARD_ZOOM, MIN_TRANSITION_DURATION_MS, MM_PER_PT, Manifest, Margin, NAMED_PAPERS, Narration, NoteMarker, NumberSystem, PAPER_MM, PX_PER_MM, Page, PageSize, Paper, Point, Print, PronunciationEntry, PublishedShot, SHOT_KEY, Scripts, Shot, Size, Slide, SlideContent, TextDirection, Transition, Word, annotationCueIssues, arrange, boardBounds, boardListing, boardListingIsEmpty, boardToScreen, deckFromSlides, exceedsLimits, firstStrongDirection, fitPage, foldForSearch, formatNumber, impose, isBookContents, isHebrew, itemAt, itemHeight, jsonSchemas, languageDirection, lexiconVersion, mirrorPlacement, nameMatches, noteMarker, noteMarkerIssues, pagePlacementLayout, printBoxes, printPadding, printProperties, resolveDirection, revealView, roundMillimeters, screenToBoard, sheetMm, shotsUsed, toMillimeters, visibleItems, zoomAt, zoomToFit };
|
|
159
|
+
export { Annotation, Board, BoardItem, BoardLabel, BoardSection, Book, BookContents, BookFrontMatterEntry, BookMode, BookPage, BookSection, BookView, Box, Chapter, Cue, DECK_SIZE, DEFAULT_TRANSITION_DURATION_MS, Deck, Direction, ImageFit, Imposition, Lexicon, MARK_GAP_MM, MARK_LENGTH_MM, MAX_BOARD_ZOOM, MAX_IMPOSITION_CELLS, MAX_SLIDE_TIMING_MS, MAX_TRANSITION_DURATION_MS, MIN_BOARD_ITEM_WIDTH, MIN_BOARD_ZOOM, MIN_TRANSITION_DURATION_MS, MM_PER_PT, Manifest, Margin, NAMED_PAPERS, Narration, NoteMarker, NumberSystem, PAPER_MM, PX_PER_MM, Page, PageSize, Paper, Point, Print, PronunciationEntry, PublishedShot, SHOT_KEY, Scripts, Shot, Size, Slide, SlideContent, TextDirection, Transition, Word, addItem, annotationCueIssues, arrange, boardBounds, boardListing, boardListingIsEmpty, boardToScreen, deckFromSlides, exceedsLimits, firstStrongDirection, fitPage, foldForSearch, formatNumber, impose, isBookContents, isHebrew, itemAt, itemHeight, jsonSchemas, languageDirection, lexiconVersion, mirrorPlacement, moveItems, moveSection, nameMatches, noteMarker, noteMarkerIssues, pagePlacementLayout, printBoxes, printPadding, printProperties, removeItems, resizeItem, resolveDirection, revealView, roundMillimeters, screenToBoard, sheetMm, shotsUsed, toMillimeters, visibleItems, zoomAt, zoomToFit };
|