@blockslides/ai-context 0.1.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/LICENSE.md +36 -0
- package/README.md +268 -0
- package/dist/index.cjs +806 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +704 -0
- package/dist/index.d.ts +704 -0
- package/dist/index.js +781 -0
- package/dist/index.js.map +1 -0
- package/package.json +44 -0
- package/src/bundles/v1/all.ts +26 -0
- package/src/bundles/v1/allContexts.ts +32 -0
- package/src/bundles/v1/allSchemas.ts +20 -0
- package/src/bundles/v1/imageEditing.ts +5 -0
- package/src/bundles/v1/index.ts +6 -0
- package/src/bundles/v1/minimalCreate.ts +5 -0
- package/src/contexts/v1/blockquote.ts +14 -0
- package/src/contexts/v1/bulletList.ts +15 -0
- package/src/contexts/v1/codeBlock.ts +15 -0
- package/src/contexts/v1/column.ts +15 -0
- package/src/contexts/v1/core.ts +17 -0
- package/src/contexts/v1/editingRules.ts +9 -0
- package/src/contexts/v1/hardBreak.ts +14 -0
- package/src/contexts/v1/heading.ts +15 -0
- package/src/contexts/v1/horizontalRule.ts +14 -0
- package/src/contexts/v1/image.ts +17 -0
- package/src/contexts/v1/imageBlock.ts +27 -0
- package/src/contexts/v1/index.ts +19 -0
- package/src/contexts/v1/output.fullDocument.ts +8 -0
- package/src/contexts/v1/paragraph.ts +14 -0
- package/src/contexts/v1/row.ts +17 -0
- package/src/contexts/v1/sizing.ts +8 -0
- package/src/contexts/v1/slide.ts +16 -0
- package/src/contexts/v1/style.ts +8 -0
- package/src/contexts/v1/youtube.ts +18 -0
- package/src/examples/v1/flyers.ts +30 -0
- package/src/examples/v1/index.ts +4 -0
- package/src/examples/v1/slides.ts +31 -0
- package/src/index.ts +7 -0
- package/src/recipes/v1/addTwoColumns.ts +13 -0
- package/src/recipes/v1/createSlide.ts +29 -0
- package/src/recipes/v1/editImageToCover.ts +13 -0
- package/src/recipes/v1/index.ts +5 -0
- package/src/schemas/v1/blockquote.schema.json +16 -0
- package/src/schemas/v1/bulletList.schema.json +16 -0
- package/src/schemas/v1/codeBlock.schema.json +19 -0
- package/src/schemas/v1/column.schema.json +23 -0
- package/src/schemas/v1/hardBreak.schema.json +16 -0
- package/src/schemas/v1/heading.schema.json +23 -0
- package/src/schemas/v1/horizontalRule.schema.json +16 -0
- package/src/schemas/v1/image.schema.json +23 -0
- package/src/schemas/v1/imageBlock.schema.json +31 -0
- package/src/schemas/v1/index.ts +14 -0
- package/src/schemas/v1/paragraph.schema.json +16 -0
- package/src/schemas/v1/row.schema.json +22 -0
- package/src/schemas/v1/slide.schema.json +32 -0
- package/src/schemas/v1/youtube.schema.json +22 -0
- package/src/types/v1.ts +55 -0
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "blockquote",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"type": { "const": "blockquote" },
|
|
7
|
+
"attrs": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"additionalProperties": true
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"required": ["type"],
|
|
13
|
+
"additionalProperties": false
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "bulletList",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"type": { "const": "bulletList" },
|
|
7
|
+
"attrs": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"additionalProperties": true
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"required": ["type"],
|
|
13
|
+
"additionalProperties": false
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "codeBlock",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"type": { "const": "codeBlock" },
|
|
7
|
+
"attrs": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"language": { "type": ["string", "null"] }
|
|
11
|
+
},
|
|
12
|
+
"additionalProperties": true
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"required": ["type"],
|
|
16
|
+
"additionalProperties": false
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "column",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"type": { "const": "column" },
|
|
7
|
+
"attrs": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"className": { "type": ["string", "null"] },
|
|
11
|
+
"contentMode": { "enum": ["default", null] },
|
|
12
|
+
"verticalAlign": { "enum": ["top", "center", "bottom", null] },
|
|
13
|
+
"horizontalAlign": { "enum": ["left", "center", "right", "stretch", null] },
|
|
14
|
+
"padding": { "enum": ["none", null] }
|
|
15
|
+
},
|
|
16
|
+
"additionalProperties": true
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"required": ["type"],
|
|
20
|
+
"additionalProperties": false
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "hardBreak",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"type": { "const": "hardBreak" },
|
|
7
|
+
"attrs": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"additionalProperties": true
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"required": ["type"],
|
|
13
|
+
"additionalProperties": false
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "heading",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"type": { "const": "heading" },
|
|
7
|
+
"attrs": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"level": {
|
|
11
|
+
"type": "integer",
|
|
12
|
+
"minimum": 1,
|
|
13
|
+
"maximum": 6
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"additionalProperties": true
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"required": ["type"],
|
|
20
|
+
"additionalProperties": false
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "horizontalRule",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"type": { "const": "horizontalRule" },
|
|
7
|
+
"attrs": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"additionalProperties": true
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"required": ["type"],
|
|
13
|
+
"additionalProperties": false
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "image",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"type": { "const": "image" },
|
|
7
|
+
"attrs": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"src": { "type": ["string", "null"] },
|
|
11
|
+
"alt": { "type": ["string", "null"] },
|
|
12
|
+
"title": { "type": ["string", "null"] },
|
|
13
|
+
"width": { "type": ["number", "null"] },
|
|
14
|
+
"height": { "type": ["number", "null"] }
|
|
15
|
+
},
|
|
16
|
+
"additionalProperties": true
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"required": ["type"],
|
|
20
|
+
"additionalProperties": false
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "imageBlock",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"type": { "const": "imageBlock" },
|
|
7
|
+
"attrs": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"src": { "type": "string", "minLength": 1 },
|
|
11
|
+
"alt": { "type": "string" },
|
|
12
|
+
"caption": { "type": "string" },
|
|
13
|
+
"credit": { "type": "string" },
|
|
14
|
+
"layout": { "enum": ["cover", "contain", "fill", "focus", "pattern", null] },
|
|
15
|
+
"align": { "enum": ["left", "center", "right", "stretch", null] },
|
|
16
|
+
"width": { "type": ["number", "string", "null"] },
|
|
17
|
+
"height": { "type": ["number", "string", "null"] },
|
|
18
|
+
"fullBleed": { "type": "boolean" },
|
|
19
|
+
"assetId": { "type": ["string", "null"] },
|
|
20
|
+
"focalX": { "type": ["number", "null"], "minimum": 0, "maximum": 100 },
|
|
21
|
+
"focalY": { "type": ["number", "null"], "minimum": 0, "maximum": 100 }
|
|
22
|
+
},
|
|
23
|
+
"required": ["src"],
|
|
24
|
+
"additionalProperties": false
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"required": ["type"],
|
|
28
|
+
"additionalProperties": false
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { default as imageBlock } from "./imageBlock.schema.json";
|
|
2
|
+
export { default as row } from "./row.schema.json";
|
|
3
|
+
export { default as column } from "./column.schema.json";
|
|
4
|
+
export { default as slide } from "./slide.schema.json";
|
|
5
|
+
export { default as blockquote } from "./blockquote.schema.json";
|
|
6
|
+
export { default as bulletList } from "./bulletList.schema.json";
|
|
7
|
+
export { default as codeBlock } from "./codeBlock.schema.json";
|
|
8
|
+
export { default as hardBreak } from "./hardBreak.schema.json";
|
|
9
|
+
export { default as horizontalRule } from "./horizontalRule.schema.json";
|
|
10
|
+
export { default as image } from "./image.schema.json";
|
|
11
|
+
export { default as heading } from "./heading.schema.json";
|
|
12
|
+
export { default as paragraph } from "./paragraph.schema.json";
|
|
13
|
+
export { default as youtube } from "./youtube.schema.json";
|
|
14
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "paragraph",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"type": { "const": "paragraph" },
|
|
7
|
+
"attrs": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"additionalProperties": true
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"required": ["type"],
|
|
13
|
+
"additionalProperties": false
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
},
|
|
15
|
+
"additionalProperties": true
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"required": ["type"],
|
|
19
|
+
"additionalProperties": false
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "slide",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"type": { "const": "slide" },
|
|
7
|
+
"attrs": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"id": { "type": ["string", "null"] },
|
|
11
|
+
"className": { "type": ["string", "null"] },
|
|
12
|
+
"size": {
|
|
13
|
+
"enum": [
|
|
14
|
+
"16x9",
|
|
15
|
+
"4x3",
|
|
16
|
+
"a4-portrait",
|
|
17
|
+
"a4-landscape",
|
|
18
|
+
"letter-portrait",
|
|
19
|
+
"letter-landscape",
|
|
20
|
+
"linkedin-banner",
|
|
21
|
+
null
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"additionalProperties": true
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"required": ["type"],
|
|
29
|
+
"additionalProperties": false
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "youtube",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"type": { "const": "youtube" },
|
|
7
|
+
"attrs": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"src": { "type": ["string", "null"] },
|
|
11
|
+
"start": { "type": "number" },
|
|
12
|
+
"width": { "type": "number" },
|
|
13
|
+
"height": { "type": "number" }
|
|
14
|
+
},
|
|
15
|
+
"additionalProperties": true
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"required": ["type"],
|
|
19
|
+
"additionalProperties": false
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
package/src/types/v1.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export type SizeKey =
|
|
2
|
+
| "16x9"
|
|
3
|
+
| "4x3"
|
|
4
|
+
| "a4-portrait"
|
|
5
|
+
| "a4-landscape"
|
|
6
|
+
| "letter-portrait"
|
|
7
|
+
| "letter-landscape"
|
|
8
|
+
| "linkedin-banner";
|
|
9
|
+
|
|
10
|
+
export interface SlideAttrs {
|
|
11
|
+
id?: string | null;
|
|
12
|
+
className?: string | null;
|
|
13
|
+
size?: SizeKey | null;
|
|
14
|
+
}
|
|
15
|
+
|
|
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;
|
|
30
|
+
}
|
|
31
|
+
|
|
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";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface ImageBlockAttrs {
|
|
41
|
+
src: string;
|
|
42
|
+
assetId?: string | null;
|
|
43
|
+
alt?: string;
|
|
44
|
+
caption?: string;
|
|
45
|
+
credit?: string;
|
|
46
|
+
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
|
+
fullBleed?: boolean;
|
|
51
|
+
focalX?: number | null;
|
|
52
|
+
focalY?: number | null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|