@drawnagency/primitives 0.1.26 → 0.1.27
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/{chunk-UMSFICAC.js → chunk-DKOUFIP6.js} +0 -1
- package/dist/{chunk-FSVPD7TW.js → chunk-HXXZBTPF.js} +12 -5
- package/dist/{chunk-IP6ODLXX.js → chunk-JHSYLVKI.js} +19 -84
- package/dist/{chunk-P24YUT3O.js → chunk-MNK7XA6S.js} +1 -1
- package/dist/{chunk-EAEX6DS7.js → chunk-V43WVSVS.js} +3 -2
- package/dist/components/editor/SectionOrderingModal.d.ts +10 -0
- package/dist/components/editor/SectionOrderingModal.d.ts.map +1 -0
- package/dist/components/editor/SectionWrapper.d.ts.map +1 -1
- package/dist/components/primitives/EditableRichText.d.ts.map +1 -1
- package/dist/components/sections/Button/index.d.ts.map +1 -1
- package/dist/components/sections/Colors/index.d.ts.map +1 -1
- package/dist/components/sections/DoDontMediaGrid/index.d.ts.map +1 -1
- package/dist/components/sections/IconList/index.d.ts.map +1 -1
- package/dist/components/sections/LinkHeading/index.d.ts.map +1 -1
- package/dist/components/sections/MediaGrid/index.d.ts.map +1 -1
- package/dist/components/sections/Prose/index.d.ts.map +1 -1
- package/dist/components/sections/SplitContent/index.d.ts.map +1 -1
- package/dist/components/sections/SubHeading/index.d.ts.map +1 -1
- package/dist/components/sections/SubSubHeading/index.d.ts.map +1 -1
- package/dist/components/sections/ViewRenderer.d.ts +0 -1
- package/dist/components/sections/ViewRenderer.d.ts.map +1 -1
- package/dist/components/sections/register-schemas.d.ts.map +1 -1
- package/dist/components/sections/register.d.ts.map +1 -1
- package/dist/components/shell/EditorShell.d.ts +0 -1
- package/dist/components/shell/EditorShell.d.ts.map +1 -1
- package/dist/deploy/index.d.ts +2 -0
- package/dist/deploy/index.d.ts.map +1 -0
- package/dist/deploy/types.d.ts +12 -0
- package/dist/deploy/types.d.ts.map +1 -0
- package/dist/hooks/useEditorPublish.d.ts.map +1 -1
- package/dist/hooks/useMediaPipeline.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -8
- package/dist/lib/dexie.d.ts +4 -1
- package/dist/lib/dexie.d.ts.map +1 -1
- package/dist/lib/dexie.js +319 -0
- package/dist/lib/index.js +3 -3
- package/dist/lib/nav.d.ts +2 -6
- package/dist/lib/nav.d.ts.map +1 -1
- package/dist/lib/registry.d.ts +14 -0
- package/dist/lib/registry.d.ts.map +1 -1
- package/dist/lib/text.d.ts +3 -0
- package/dist/lib/text.d.ts.map +1 -0
- package/dist/media/index.d.ts +4 -2
- package/dist/media/index.d.ts.map +1 -1
- package/dist/media/index.js +8 -6
- package/dist/media/provider.d.ts +7 -0
- package/dist/media/provider.d.ts.map +1 -0
- package/dist/media/resolve.d.ts +3 -2
- package/dist/media/resolve.d.ts.map +1 -1
- package/dist/media/types.d.ts +0 -9
- package/dist/media/types.d.ts.map +1 -1
- package/dist/schemas/index.js +3 -3
- package/dist/schemas/media.d.ts +0 -3
- package/dist/schemas/media.d.ts.map +1 -1
- package/dist/schemas/site-config.d.ts +1 -3
- package/dist/schemas/site-config.d.ts.map +1 -1
- package/dist/storage/index.d.ts +2 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/types.d.ts +21 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/package.json +5 -1
- package/src/components/editor/DragHandle.tsx +1 -1
- package/src/components/editor/SectionOrderingModal.tsx +215 -0
- package/src/components/editor/SectionWrapper.tsx +3 -1
- package/src/components/primitives/EditableRichText.tsx +4 -2
- package/src/components/sections/Button/index.tsx +1 -0
- package/src/components/sections/Colors/index.tsx +8 -0
- package/src/components/sections/DoDontMediaGrid/index.tsx +8 -0
- package/src/components/sections/IconList/index.tsx +4 -0
- package/src/components/sections/LinkHeading/index.tsx +2 -0
- package/src/components/sections/MediaGrid/index.tsx +8 -0
- package/src/components/sections/Prose/index.tsx +2 -0
- package/src/components/sections/SplitContent/index.tsx +16 -2
- package/src/components/sections/SubHeading/index.tsx +2 -0
- package/src/components/sections/SubSubHeading/index.tsx +2 -0
- package/src/components/sections/ViewRenderer.tsx +3 -1
- package/src/components/sections/register-schemas.ts +0 -2
- package/src/components/sections/register.ts +0 -2
- package/src/components/shell/EditorShell.tsx +40 -9
- package/src/deploy/index.ts +1 -0
- package/src/deploy/types.ts +12 -0
- package/src/hooks/useEditorPublish.ts +18 -43
- package/src/hooks/useMediaPipeline.ts +41 -11
- package/src/hooks/useResolvedMedia.ts +3 -3
- package/src/index.ts +2 -0
- package/src/lib/dexie.ts +28 -1
- package/src/lib/nav.ts +16 -9
- package/src/lib/registry.ts +10 -0
- package/src/lib/text.ts +8 -0
- package/src/media/index.ts +13 -4
- package/src/media/provider.ts +7 -0
- package/src/media/resolve.ts +9 -6
- package/src/media/types.ts +0 -9
- package/src/schemas/media.ts +0 -1
- package/src/schemas/site-config.ts +1 -0
- package/src/storage/index.ts +1 -0
- package/src/storage/types.ts +23 -0
- package/dist/components/sections/SplitContent/SplitContentSettings.d.ts +0 -9
- package/dist/components/sections/SplitContent/SplitContentSettings.d.ts.map +0 -1
- package/dist/media/github.d.ts +0 -3
- package/dist/media/github.d.ts.map +0 -1
- package/src/components/sections/SplitContent/SplitContentSettings.d.ts +0 -9
- package/src/components/sections/SplitContent/SplitContentSettings.d.ts.map +0 -1
- package/src/components/sections/SplitContent/SplitContentSettings.tsx +0 -42
- package/src/media/github.ts +0 -72
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
import { Select } from "../../shared/Select";
|
|
3
|
-
import { Checkbox } from "../../shared/Checkbox";
|
|
4
|
-
|
|
5
|
-
export function SplitContentSettings({
|
|
6
|
-
imagePosition: initialPos,
|
|
7
|
-
border: initialBorder,
|
|
8
|
-
onChange,
|
|
9
|
-
}: {
|
|
10
|
-
imagePosition: "left" | "right";
|
|
11
|
-
border: boolean;
|
|
12
|
-
onChange: (values: { imagePosition: "left" | "right"; border: boolean }) => void;
|
|
13
|
-
}) {
|
|
14
|
-
const [imagePosition, setImagePosition] = useState(initialPos);
|
|
15
|
-
const [border, setBorder] = useState(initialBorder);
|
|
16
|
-
|
|
17
|
-
const emit = (overrides: Partial<{ imagePosition: "left" | "right"; border: boolean }>) =>
|
|
18
|
-
onChange({ imagePosition, border, ...overrides });
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<div className="space-y-4">
|
|
22
|
-
<Select
|
|
23
|
-
label="Image Position"
|
|
24
|
-
value={imagePosition}
|
|
25
|
-
onChange={(val) => {
|
|
26
|
-
const v = val as "left" | "right";
|
|
27
|
-
setImagePosition(v);
|
|
28
|
-
emit({ imagePosition: v });
|
|
29
|
-
}}
|
|
30
|
-
options={[
|
|
31
|
-
{ value: "left", label: "Left" },
|
|
32
|
-
{ value: "right", label: "Right" },
|
|
33
|
-
]}
|
|
34
|
-
/>
|
|
35
|
-
<Checkbox
|
|
36
|
-
checked={border}
|
|
37
|
-
onChange={(v) => { setBorder(v); emit({ border: v }); }}
|
|
38
|
-
label="Show border"
|
|
39
|
-
/>
|
|
40
|
-
</div>
|
|
41
|
-
);
|
|
42
|
-
}
|
package/src/media/github.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type { MediaAdapter, MediaFile, MediaItem, MediaManifest, ResolvedMedia } from "./types";
|
|
2
|
-
import { sanitizeMediaName, mimeToExt, hashFileBuffer } from "./utils";
|
|
3
|
-
|
|
4
|
-
export function createGitHubMediaAdapter(manifest: MediaManifest): MediaAdapter {
|
|
5
|
-
return {
|
|
6
|
-
async hash(file: MediaFile): Promise<string> {
|
|
7
|
-
return hashFileBuffer(file.buffer);
|
|
8
|
-
},
|
|
9
|
-
|
|
10
|
-
async exists(hash: string): Promise<boolean> {
|
|
11
|
-
return hash in manifest.images;
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
async process(file: MediaFile, hash: string, _sizes: number[]): Promise<MediaItem> {
|
|
15
|
-
const name = sanitizeMediaName(file.originalName);
|
|
16
|
-
const folder = `${name}-${hash}`;
|
|
17
|
-
return {
|
|
18
|
-
id: hash, hash, kind: "image", originalName: name,
|
|
19
|
-
width: 0, height: 0, mimeType: "image/webp", size: 0, folder, variants: [], alt: "",
|
|
20
|
-
};
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
async delete(id: string): Promise<void> {
|
|
24
|
-
delete manifest.images[id];
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
resolve(id: string, sizes: number[]): ResolvedMedia | null {
|
|
28
|
-
const item = manifest.images[id];
|
|
29
|
-
if (!item) return null;
|
|
30
|
-
|
|
31
|
-
if (item.kind === "video") {
|
|
32
|
-
return {
|
|
33
|
-
tag: "video",
|
|
34
|
-
src: `/api/media/${id}/original.${mimeToExt(item.mimeType)}`,
|
|
35
|
-
poster: `/api/media/${id}/poster.webp`,
|
|
36
|
-
width: item.width, height: item.height,
|
|
37
|
-
autoplay: true, loop: true, muted: true,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (item.kind === "animated") {
|
|
42
|
-
return {
|
|
43
|
-
tag: "img",
|
|
44
|
-
src: `/api/media/${id}/original.${mimeToExt(item.mimeType)}`,
|
|
45
|
-
width: item.width, height: item.height,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Static image with srcset
|
|
50
|
-
const availableVariants = item.variants.filter((v) =>
|
|
51
|
-
sizes.length === 0 || sizes.includes(v.width),
|
|
52
|
-
);
|
|
53
|
-
const sorted = [...availableVariants].sort((a, b) => a.width - b.width);
|
|
54
|
-
const midIndex = Math.floor(sorted.length / 2);
|
|
55
|
-
const defaultVariant = sorted[midIndex] ?? sorted[0];
|
|
56
|
-
if (!defaultVariant) return null;
|
|
57
|
-
|
|
58
|
-
const srcSet = sorted.map((v) => `/api/media/${id}/${v.width}.webp ${v.width}w`).join(", ");
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
tag: "img",
|
|
62
|
-
src: `/api/media/${id}/${defaultVariant.width}.webp`,
|
|
63
|
-
srcSet,
|
|
64
|
-
width: item.width, height: item.height,
|
|
65
|
-
};
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
async list(): Promise<MediaItem[]> {
|
|
69
|
-
return Object.values(manifest.images);
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
}
|