@blockslides/ai-context 0.2.0 → 0.3.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.
Files changed (49) hide show
  1. package/dist/index.cjs +985 -996
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +817 -300
  4. package/dist/index.d.ts +817 -300
  5. package/dist/index.js +985 -994
  6. package/dist/index.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/bundles/v1/all.ts +0 -1
  9. package/src/bundles/v1/allContexts.ts +1 -1
  10. package/src/bundles/v1/minimalCreate.ts +2 -2
  11. package/src/contexts/v1/blockquote.ts +10 -5
  12. package/src/contexts/v1/bulletList.ts +10 -5
  13. package/src/contexts/v1/codeBlock.ts +11 -3
  14. package/src/contexts/v1/column.ts +34 -14
  15. package/src/contexts/v1/columnGroup.ts +44 -0
  16. package/src/contexts/v1/core.ts +24 -4
  17. package/src/contexts/v1/editingRules.ts +5 -5
  18. package/src/contexts/v1/heading.ts +11 -4
  19. package/src/contexts/v1/horizontalRule.ts +9 -4
  20. package/src/contexts/v1/imageBlock.ts +31 -22
  21. package/src/contexts/v1/index.ts +1 -1
  22. package/src/contexts/v1/paragraph.ts +11 -5
  23. package/src/contexts/v1/slide.ts +5 -1
  24. package/src/contexts/v1/youtube.ts +14 -7
  25. package/src/index.ts +0 -3
  26. package/src/schemas/v1/blockquote.schema.json +13 -2
  27. package/src/schemas/v1/bulletList.schema.json +13 -2
  28. package/src/schemas/v1/codeBlock.schema.json +12 -3
  29. package/src/schemas/v1/column.schema.json +18 -14
  30. package/src/schemas/v1/columnGroup.schema.json +45 -0
  31. package/src/schemas/v1/heading.schema.json +12 -7
  32. package/src/schemas/v1/horizontalRule.schema.json +7 -2
  33. package/src/schemas/v1/imageBlock.schema.json +25 -15
  34. package/src/schemas/v1/index.ts +1 -1
  35. package/src/schemas/v1/paragraph.schema.json +13 -2
  36. package/src/schemas/v1/slide.schema.json +6 -0
  37. package/src/schemas/v1/youtube.schema.json +9 -6
  38. package/src/templates/v1/presetTemplateBuilder.ts +401 -443
  39. package/src/templates/v1/schemaBuilder.ts +195 -263
  40. package/src/types/v1.ts +40 -25
  41. package/src/contexts/v1/row.ts +0 -25
  42. package/src/examples/v1/flyers.ts +0 -30
  43. package/src/examples/v1/index.ts +0 -4
  44. package/src/examples/v1/slides.ts +0 -31
  45. package/src/recipes/v1/addTwoColumns.ts +0 -13
  46. package/src/recipes/v1/createSlide.ts +0 -29
  47. package/src/recipes/v1/editImageToCover.ts +0 -13
  48. package/src/recipes/v1/index.ts +0 -5
  49. package/src/schemas/v1/row.schema.json +0 -29
package/src/types/v1.ts CHANGED
@@ -7,46 +7,61 @@ export type SizeKey =
7
7
  | "letter-landscape"
8
8
  | "linkedin-banner";
9
9
 
10
- export interface SlideAttrs {
10
+ export type SpacingToken = "none" | "sm" | "md" | "lg";
11
+ export type BorderRadiusToken = "none" | "sm" | "md" | "lg";
12
+ export type AlignValue = "left" | "center" | "right" | "stretch";
13
+ export type JustifyValue = "start" | "center" | "end" | "space-between";
14
+
15
+ export interface SlideAttrs extends BaseBlockAttrs {
11
16
  id?: string | null;
12
17
  className?: string | null;
13
18
  size?: SizeKey | null;
14
19
  }
15
20
 
16
- export interface RowAttrs {
17
- layout?:
18
- | ""
19
- | "1"
20
- | "1-1"
21
- | "2-1"
22
- | "1-2"
23
- | "1-1-1"
24
- | "2-1-1"
25
- | "1-2-1"
26
- | "1-1-2"
27
- | "1-1-1-1"
28
- | null;
29
- className?: string | null;
21
+ /**
22
+ * Base attributes shared by all block types
23
+ */
24
+ export interface BaseBlockAttrs {
25
+ align?: AlignValue | null;
26
+ justify?: JustifyValue | null;
27
+ padding?: SpacingToken | string | null;
28
+ margin?: SpacingToken | string | null;
29
+ gap?: SpacingToken | string | null;
30
+ backgroundColor?: string | null;
31
+ backgroundImage?: string | null;
32
+ borderRadius?: BorderRadiusToken | string | null;
33
+ border?: string | null;
34
+ fill?: boolean | null;
35
+ width?: string | null;
36
+ height?: string | null;
30
37
  }
31
38
 
32
- export interface ColumnAttrs {
33
- className?: string | null;
34
- contentMode?: "default";
35
- verticalAlign?: "top" | "center" | "bottom";
36
- horizontalAlign?: "left" | "center" | "right" | "stretch";
37
- padding?: "none";
39
+ export interface ColumnAttrs extends BaseBlockAttrs {
40
+ // No column-specific attributes, all from BaseBlockAttrs
38
41
  }
39
42
 
40
- export interface ImageBlockAttrs {
43
+ export type ImageBlockSize = "fill" | "fit" | "natural";
44
+ export type ImageBlockCrop =
45
+ | "center"
46
+ | "top"
47
+ | "bottom"
48
+ | "left"
49
+ | "right"
50
+ | "top-left"
51
+ | "top-right"
52
+ | "bottom-left"
53
+ | "bottom-right";
54
+
55
+ export interface ImageBlockAttrs extends BaseBlockAttrs {
41
56
  src: string;
42
57
  assetId?: string | null;
43
58
  alt?: string;
44
59
  caption?: string;
45
60
  credit?: string;
61
+ size?: ImageBlockSize | null;
62
+ crop?: ImageBlockCrop | null;
63
+ // Deprecated attributes (kept for backwards compatibility)
46
64
  layout?: "cover" | "contain" | "fill" | "focus" | "pattern" | null;
47
- align?: "left" | "center" | "right" | "stretch" | null;
48
- width?: string | number | null;
49
- height?: string | number | null;
50
65
  fullBleed?: boolean;
51
66
  focalX?: number | null;
52
67
  focalY?: number | null;
@@ -1,25 +0,0 @@
1
- export const row = `
2
- <row>
3
- Node: row
4
- Attrs:
5
- - layout (optional): "", "1", "1-1", "2-1", "1-2", "1-1-1", "2-1-1", "1-2-1", "1-1-2", "1-1-1-1"
6
- - className (optional): string (CSS classes)
7
- - backgroundMode (optional): "none" | "color" | "image" | "imageOverlay"
8
- - backgroundColor (optional): string (CSS color for row background)
9
- - backgroundImage (optional): string (URL for row-level background image)
10
- - backgroundOverlayColor (optional): string (overlay color when using imageOverlay)
11
- - backgroundOverlayOpacity (optional): number (0–1, overlay opacity)
12
-
13
- Semantics:
14
- - Fractions determine relative column flex:
15
- - 1-1: two equal columns
16
- - 2-1: first column is double width
17
- - 1-2: second column is double width
18
- - 1-1-1: three equal columns
19
- - 1-1-1-1: four equal columns
20
- - Empty layout ("", "1") acts as a single full-width column.
21
- - Use row backgrounds for horizontal bands (e.g., header strip) instead of attaching everything to the slide.
22
- </row>
23
- `.trim();
24
-
25
-
@@ -1,30 +0,0 @@
1
- export const flyers = `
2
- Examples: Flyers (A4 slides; full-document output)
3
-
4
- {
5
- "type": "doc",
6
- "content": [
7
- {
8
- "type": "slide",
9
- "attrs": { "id": "a4-flyer", "size": "a4-portrait", "className": "bg-white text-slate-900" },
10
- "content": [
11
- {
12
- "type": "row",
13
- "attrs": { "layout": "1" },
14
- "content": [
15
- { "type": "column", "content": [
16
- { "type": "heading", "attrs": { "level": 2 }, "content": [{ "type": "text", "text": "Event Title" }] },
17
- { "type": "paragraph", "content": [{ "type": "text", "text": "Date · Location" }] },
18
- { "type": "imageBlock", "attrs": { "src": "https://picsum.photos/seed/a4/1600/1000", "layout": "contain", "align": "center", "height": 320 } }
19
- ]}
20
- ]
21
- }
22
- ]
23
- }
24
- ]
25
- }
26
-
27
- /* more-flyer-examples to be added here */
28
- `.trim();
29
-
30
-
@@ -1,4 +0,0 @@
1
- export { slides } from "./slides";
2
- export { flyers } from "./flyers";
3
-
4
-
@@ -1,31 +0,0 @@
1
- export const slides = `
2
- Examples: Slides (full-document output)
3
-
4
- {
5
- "type": "doc",
6
- "content": [
7
- {
8
- "type": "slide",
9
- "attrs": { "id": "intro", "size": "16x9" },
10
- "content": [
11
- {
12
- "type": "row",
13
- "attrs": { "layout": "1-1" },
14
- "content": [
15
- { "type": "column", "content": [
16
- { "type": "heading", "attrs": { "level": 2 }, "content": [{ "type": "text", "text": "Welcome" }] }
17
- ]},
18
- { "type": "column", "content": [
19
- { "type": "imageBlock", "attrs": { "src": "https://picsum.photos/seed/welcome/1200/800", "layout": "cover", "align": "center" } }
20
- ]}
21
- ]
22
- }
23
- ]
24
- }
25
- ]
26
- }
27
-
28
- /* more-slide-examples to be added here */
29
- `.trim();
30
-
31
-
@@ -1,13 +0,0 @@
1
- import { core, fullDocument, row, column } from "../../contexts/v1";
2
-
3
- export const addTwoColumns = [
4
- core,
5
- fullDocument,
6
- row,
7
- column,
8
- `
9
- Return a full document where the first slide contains a row with layout "1-1" and two columns with simple text paragraphs.
10
- `.trim(),
11
- ].join("\n\n");
12
-
13
-
@@ -1,29 +0,0 @@
1
- import { core, fullDocument, slide, row, column } from "../../contexts/v1";
2
-
3
- export const createSlide = [
4
- core,
5
- fullDocument,
6
- slide,
7
- row,
8
- column,
9
- `
10
- Return a single JSON document that creates one 16x9 slide with a 1-1 row:
11
- {
12
- "type": "doc",
13
- "content": [
14
- {
15
- "type": "slide",
16
- "attrs": { "size": "16x9" },
17
- "content": [
18
- { "type": "row", "attrs": { "layout": "1-1" }, "content": [
19
- { "type": "column", "content": [{ "type": "paragraph", "content": [{ "type": "text", "text": "Left" }] }] },
20
- { "type": "column", "content": [{ "type": "paragraph", "content": [{ "type": "text", "text": "Right" }] }] }
21
- ] }
22
- ]
23
- }
24
- ]
25
- }
26
- `.trim(),
27
- ].join("\n\n");
28
-
29
-
@@ -1,13 +0,0 @@
1
- import { core, fullDocument, imageBlock, editingRules } from "../../contexts/v1";
2
-
3
- export const editImageToCover = [
4
- core,
5
- fullDocument,
6
- imageBlock,
7
- editingRules,
8
- `
9
- Update an existing imageBlock on the first slide so it uses layout "cover" and align "center". Preserve all other attributes.
10
- `.trim(),
11
- ].join("\n\n");
12
-
13
-
@@ -1,5 +0,0 @@
1
- export { createSlide } from "./createSlide";
2
- export { addTwoColumns } from "./addTwoColumns";
3
- export { editImageToCover } from "./editImageToCover";
4
-
5
-
@@ -1,29 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "title": "row",
4
- "type": "object",
5
- "properties": {
6
- "type": { "const": "row" },
7
- "attrs": {
8
- "type": "object",
9
- "properties": {
10
- "layout": {
11
- "enum": ["", "1", "1-1", "2-1", "1-2", "1-1-1", "2-1-1", "1-2-1", "1-1-2", "1-1-1-1", null]
12
- },
13
- "className": { "type": ["string", "null"] },
14
- "backgroundMode": {
15
- "enum": ["none", "color", "image", "imageOverlay", null]
16
- },
17
- "backgroundColor": { "type": ["string", "null"] },
18
- "backgroundImage": { "type": ["string", "null"] },
19
- "backgroundOverlayColor": { "type": ["string", "null"] },
20
- "backgroundOverlayOpacity": { "type": ["number", "null"] }
21
- },
22
- "additionalProperties": true
23
- }
24
- },
25
- "required": ["type"],
26
- "additionalProperties": false
27
- }
28
-
29
-