@drawnagency/primitives 0.1.56 → 0.1.57
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-KGYWQDBB.js → chunk-ICLXLWQ5.js} +9 -72
- package/dist/chunk-NSCT3AMV.js +32 -0
- package/dist/{chunk-EU6NZ4GS.js → chunk-PRKUXM7E.js} +23 -9
- package/dist/{chunk-7IAWF7LE.js → chunk-PYWS3MOJ.js} +12 -2
- package/dist/chunk-TG43X7JO.js +123 -0
- package/dist/chunk-VKAGMEKE.js +90 -0
- package/dist/components/editor/ChildBlockWrapper.d.ts +19 -0
- package/dist/components/editor/ChildBlockWrapper.d.ts.map +1 -0
- package/dist/components/editor/ColSpanControl.d.ts +9 -0
- package/dist/components/editor/ColSpanControl.d.ts.map +1 -0
- package/dist/components/editor/SectionWrapper.d.ts +1 -1
- package/dist/components/editor/SectionWrapper.d.ts.map +1 -1
- package/dist/components/editor/SettingsForm.d.ts +5 -1
- package/dist/components/editor/SettingsForm.d.ts.map +1 -1
- package/dist/components/primitives/EditableGrid.d.ts.map +1 -1
- package/dist/components/primitives/IconPicker.d.ts +7 -1
- package/dist/components/primitives/IconPicker.d.ts.map +1 -1
- package/dist/components/sections/Container/Container.d.ts +20 -0
- package/dist/components/sections/Container/Container.d.ts.map +1 -0
- package/dist/components/sections/Container/ContainerSettingsForm.d.ts +17 -0
- package/dist/components/sections/Container/ContainerSettingsForm.d.ts.map +1 -0
- package/dist/components/sections/Container/index.d.ts +11 -0
- package/dist/components/sections/Container/index.d.ts.map +1 -0
- package/dist/components/sections/IconList/IconList.d.ts +1 -0
- package/dist/components/sections/IconList/IconList.d.ts.map +1 -1
- package/dist/components/sections/IconList/IconListSettings.d.ts +3 -4
- package/dist/components/sections/IconList/IconListSettings.d.ts.map +1 -1
- package/dist/components/sections/IconList/index.d.ts +1 -0
- package/dist/components/sections/IconList/index.d.ts.map +1 -1
- package/dist/components/sections/Media/MediaBlock.d.ts +19 -0
- package/dist/components/sections/Media/MediaBlock.d.ts.map +1 -0
- package/dist/components/sections/{MediaGrid → Media}/index.d.ts +15 -25
- package/dist/components/sections/Media/index.d.ts.map +1 -0
- package/dist/components/sections/Prose/index.d.ts.map +1 -1
- package/dist/components/sections/Spacer/Spacer.d.ts +2 -0
- package/dist/components/sections/Spacer/Spacer.d.ts.map +1 -0
- package/dist/components/sections/Spacer/index.d.ts +6 -0
- package/dist/components/sections/Spacer/index.d.ts.map +1 -0
- package/dist/components/sections/all-sections.d.ts +29 -103
- package/dist/components/sections/all-sections.d.ts.map +1 -1
- package/dist/components/sections/register-schemas.d.ts.map +1 -1
- package/dist/components/shared/Tabs.d.ts +24 -0
- package/dist/components/shared/Tabs.d.ts.map +1 -0
- package/dist/components/shell/EditorShell.d.ts.map +1 -1
- package/dist/components/shell/SiteSettingsModal.d.ts.map +1 -1
- package/dist/components/shell/blockMoveDispatch.d.ts +21 -0
- package/dist/components/shell/blockMoveDispatch.d.ts.map +1 -0
- package/dist/hooks/useBlockDnd.d.ts +48 -0
- package/dist/hooks/useBlockDnd.d.ts.map +1 -0
- package/dist/index.js +56 -48
- package/dist/lib/block-dnd.d.ts +42 -0
- package/dist/lib/block-dnd.d.ts.map +1 -0
- package/dist/lib/block-move.d.ts +31 -0
- package/dist/lib/block-move.d.ts.map +1 -0
- package/dist/lib/container-grid.d.ts +29 -0
- package/dist/lib/container-grid.d.ts.map +1 -0
- package/dist/lib/container-ops.d.ts +44 -0
- package/dist/lib/container-ops.d.ts.map +1 -0
- package/dist/lib/dexie.d.ts.map +1 -1
- package/dist/lib/dexie.js +13 -0
- package/dist/lib/index.js +10 -7
- package/dist/lib/loader.d.ts.map +1 -1
- package/dist/lib/migrate-sections-transform.d.ts +12 -0
- package/dist/lib/migrate-sections-transform.d.ts.map +1 -0
- package/dist/lib/migrate-sections-transform.js +6 -0
- package/dist/lib/registry.d.ts +39 -0
- package/dist/lib/registry.d.ts.map +1 -1
- package/dist/lib/registry.js +26 -0
- package/dist/schemas/block.d.ts +20 -0
- package/dist/schemas/block.d.ts.map +1 -0
- package/dist/schemas/block.js +14 -0
- package/dist/schemas/index.js +8 -2
- package/dist/schemas/link.d.ts +7 -0
- package/dist/schemas/link.d.ts.map +1 -1
- package/dist/schemas/rich-text.d.ts +9 -0
- package/dist/schemas/rich-text.d.ts.map +1 -0
- package/dist/schemas/sections.d.ts +2 -0
- package/dist/schemas/sections.d.ts.map +1 -1
- package/dist/schemas/shared.d.ts +30 -0
- package/dist/schemas/shared.d.ts.map +1 -1
- package/package.json +13 -1
- package/src/components/brandguide/Colors.tsx +35 -33
- package/src/components/editor/ChildBlockWrapper.tsx +108 -0
- package/src/components/editor/ColSpanControl.tsx +56 -0
- package/src/components/editor/SectionWrapper.tsx +44 -20
- package/src/components/editor/SettingsForm.tsx +100 -73
- package/src/components/primitives/EditableGrid.tsx +40 -36
- package/src/components/primitives/IconPicker.tsx +116 -26
- package/src/components/sections/Container/Container.tsx +354 -0
- package/src/components/sections/Container/ContainerSettingsForm.tsx +113 -0
- package/src/components/sections/Container/index.tsx +51 -0
- package/src/components/sections/IconList/IconList.tsx +113 -43
- package/src/components/sections/IconList/IconListSettings.tsx +2 -2
- package/src/components/sections/IconList/index.tsx +1 -1
- package/src/components/sections/Media/MediaBlock.tsx +103 -0
- package/src/components/sections/Media/index.tsx +85 -0
- package/src/components/sections/Prose/index.tsx +1 -0
- package/src/components/sections/Spacer/Spacer.tsx +6 -0
- package/src/components/sections/Spacer/index.tsx +18 -0
- package/src/components/sections/all-sections.ts +10 -8
- package/src/components/sections/register-schemas.ts +5 -2
- package/src/components/shared/Tabs.tsx +63 -0
- package/src/components/shell/EditorShell.tsx +105 -13
- package/src/components/shell/SiteSettingsModal.tsx +41 -51
- package/src/components/shell/blockMoveDispatch.ts +40 -0
- package/src/hooks/useBlockDnd.ts +144 -0
- package/src/lib/block-dnd.ts +58 -0
- package/src/lib/block-move.ts +236 -0
- package/src/lib/container-grid.ts +58 -0
- package/src/lib/container-ops.ts +159 -0
- package/src/lib/dexie.ts +22 -0
- package/src/lib/loader.ts +16 -4
- package/src/lib/migrate-sections-transform.ts +147 -0
- package/src/lib/registry.ts +48 -0
- package/src/schemas/block.ts +40 -0
- package/src/schemas/link.ts +19 -1
- package/src/schemas/rich-text.ts +11 -0
- package/src/schemas/sections.ts +5 -1
- package/src/schemas/shared.ts +6 -0
- package/dist/components/brandguide/DoDontList.d.ts +0 -16
- package/dist/components/brandguide/DoDontList.d.ts.map +0 -1
- package/dist/components/brandguide/DoDontMediaGrid.d.ts +0 -16
- package/dist/components/brandguide/DoDontMediaGrid.d.ts.map +0 -1
- package/dist/components/primitives/MediaSettingsForms.d.ts +0 -23
- package/dist/components/primitives/MediaSettingsForms.d.ts.map +0 -1
- package/dist/components/sections/DoDontList/index.d.ts +0 -21
- package/dist/components/sections/DoDontList/index.d.ts.map +0 -1
- package/dist/components/sections/DoDontMediaGrid/index.d.ts +0 -55
- package/dist/components/sections/DoDontMediaGrid/index.d.ts.map +0 -1
- package/dist/components/sections/MediaGrid/MediaGrid.d.ts +0 -17
- package/dist/components/sections/MediaGrid/MediaGrid.d.ts.map +0 -1
- package/dist/components/sections/MediaGrid/index.d.ts.map +0 -1
- package/dist/components/sections/SplitContent/SplitContent.d.ts +0 -14
- package/dist/components/sections/SplitContent/SplitContent.d.ts.map +0 -1
- package/dist/components/sections/SplitContent/index.d.ts +0 -13
- package/dist/components/sections/SplitContent/index.d.ts.map +0 -1
- package/src/components/brandguide/DoDontList.d.ts.map +0 -1
- package/src/components/brandguide/DoDontList.tsx +0 -67
- package/src/components/brandguide/DoDontMediaGrid.d.ts.map +0 -1
- package/src/components/brandguide/DoDontMediaGrid.tsx +0 -19
- package/src/components/primitives/MediaSettingsForms.tsx +0 -128
- package/src/components/sections/DoDontList/index.d.ts.map +0 -1
- package/src/components/sections/DoDontList/index.tsx +0 -45
- package/src/components/sections/DoDontMediaGrid/index.d.ts.map +0 -1
- package/src/components/sections/DoDontMediaGrid/index.tsx +0 -63
- package/src/components/sections/MediaGrid/MediaGrid.d.ts.map +0 -1
- package/src/components/sections/MediaGrid/MediaGrid.tsx +0 -239
- package/src/components/sections/MediaGrid/index.d.ts.map +0 -1
- package/src/components/sections/MediaGrid/index.tsx +0 -57
- package/src/components/sections/SplitContent/SplitContent.d.ts.map +0 -1
- package/src/components/sections/SplitContent/SplitContent.tsx +0 -84
- package/src/components/sections/SplitContent/index.d.ts.map +0 -1
- package/src/components/sections/SplitContent/index.tsx +0 -55
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { cn } from "../../../lib/cn";
|
|
2
|
-
import { sanitizeHtml } from "../../../lib/sanitize";
|
|
3
|
-
import { ResolvedMedia } from "../../primitives/ResolvedMedia";
|
|
4
|
-
import { EditableRichText } from "../../primitives/EditableRichText";
|
|
5
|
-
import { IconButton } from "../../shared/IconButton";
|
|
6
|
-
import { ImageDropZone } from "../../primitives/ImageDropZone";
|
|
7
|
-
import type { SectionContent } from "../../../schemas/sections";
|
|
8
|
-
import { useMediaLibrary } from "../../shell/MediaLibraryContext";
|
|
9
|
-
import { ImageIcon } from "lucide-react";
|
|
10
|
-
|
|
11
|
-
interface Props {
|
|
12
|
-
imageId: string | undefined;
|
|
13
|
-
src?: string;
|
|
14
|
-
srcset?: string;
|
|
15
|
-
alt?: string;
|
|
16
|
-
body: string;
|
|
17
|
-
border?: boolean;
|
|
18
|
-
imagePosition?: "left" | "right";
|
|
19
|
-
onChange?: (content: SectionContent) => void;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export default function SplitContent({ imageId, src, srcset, alt, body, border, imagePosition = "left", onChange }: Props) {
|
|
23
|
-
const mediaLibrary = useMediaLibrary();
|
|
24
|
-
|
|
25
|
-
const handleImageChange = (newImageId: string) => {
|
|
26
|
-
onChange?.({
|
|
27
|
-
type: "split_content",
|
|
28
|
-
content: { imageId: newImageId, body },
|
|
29
|
-
options: { border, imagePosition },
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const handleBodyChange = (html: string) => {
|
|
34
|
-
onChange?.({
|
|
35
|
-
type: "split_content",
|
|
36
|
-
content: { imageId, body: html, src, srcset, alt },
|
|
37
|
-
options: { border, imagePosition },
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const handleImageClick = () => {
|
|
42
|
-
mediaLibrary?.openSelectModal(handleImageChange);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<div className={cn(
|
|
47
|
-
"flex flex-col gap-6 lg:flex-row lg:items-start",
|
|
48
|
-
imagePosition === "right" && "lg:flex-row-reverse",
|
|
49
|
-
)}>
|
|
50
|
-
<div className={cn("group/img relative flex-shrink-0 lg:w-1/2", border && "overflow-hidden rounded-md border border-base-200")}>
|
|
51
|
-
{onChange && mediaLibrary ? (
|
|
52
|
-
<ImageDropZone onImageSelected={handleImageChange}>
|
|
53
|
-
<ResolvedMedia imageId={imageId} src={src} srcset={srcset} alt={alt} className="w-full" />
|
|
54
|
-
</ImageDropZone>
|
|
55
|
-
) : (
|
|
56
|
-
<ResolvedMedia imageId={imageId} src={src} srcset={srcset} alt={alt} className="w-full" />
|
|
57
|
-
)}
|
|
58
|
-
{onChange && mediaLibrary && (
|
|
59
|
-
<div className="absolute top-1.5 right-1.5 z-10 opacity-0 transition-opacity group-hover/img:opacity-100">
|
|
60
|
-
<IconButton
|
|
61
|
-
icon={<ImageIcon size={16} />}
|
|
62
|
-
label="Change image"
|
|
63
|
-
onClick={handleImageClick}
|
|
64
|
-
className="bg-base/80 shadow-sm"
|
|
65
|
-
/>
|
|
66
|
-
</div>
|
|
67
|
-
)}
|
|
68
|
-
</div>
|
|
69
|
-
<div className="prose-content lg:w-1/2">
|
|
70
|
-
{onChange ? (
|
|
71
|
-
<EditableRichText
|
|
72
|
-
value={body}
|
|
73
|
-
onChange={handleBodyChange}
|
|
74
|
-
isEditMode={true}
|
|
75
|
-
preset="rich"
|
|
76
|
-
/>
|
|
77
|
-
) : (
|
|
78
|
-
// eslint-disable-next-line react/no-danger
|
|
79
|
-
<div dangerouslySetInnerHTML={{ __html: sanitizeHtml(body) }} />
|
|
80
|
-
)}
|
|
81
|
-
</div>
|
|
82
|
-
</div>
|
|
83
|
-
);
|
|
84
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":";;;;;;;;;;;AAiBA,wBAkBG"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { defineSection } from "../../../lib/registry";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { Columns2 } from "lucide-react";
|
|
4
|
-
import SplitContent from "./SplitContent";
|
|
5
|
-
import { stripHtmlToPlainText, truncate } from "../../../lib/text";
|
|
6
|
-
|
|
7
|
-
const schema = z.object({
|
|
8
|
-
type: z.literal("split_content"),
|
|
9
|
-
content: z.object({
|
|
10
|
-
imageId: z.string().optional(),
|
|
11
|
-
body: z.string(),
|
|
12
|
-
}),
|
|
13
|
-
options: z.object({
|
|
14
|
-
border: z.boolean().optional(),
|
|
15
|
-
imagePosition: z.enum(["left", "right"]).optional(),
|
|
16
|
-
}).optional(),
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export default defineSection({
|
|
20
|
-
type: "split_content",
|
|
21
|
-
label: "Split Content",
|
|
22
|
-
icon: <Columns2 size={18} />,
|
|
23
|
-
schema,
|
|
24
|
-
component: ({ content, options, onChange }) => (
|
|
25
|
-
<SplitContent
|
|
26
|
-
imageId={content.content.imageId as string | undefined}
|
|
27
|
-
src={(content.content as Record<string, unknown>).src as string | undefined}
|
|
28
|
-
srcset={(content.content as Record<string, unknown>).srcset as string | undefined}
|
|
29
|
-
alt={(content.content as Record<string, unknown>).alt as string | undefined}
|
|
30
|
-
body={content.content.body as string}
|
|
31
|
-
border={options?.border as boolean}
|
|
32
|
-
imagePosition={options?.imagePosition as "left" | "right"}
|
|
33
|
-
onChange={onChange ? (c) => onChange(c as typeof content) : undefined}
|
|
34
|
-
/>
|
|
35
|
-
),
|
|
36
|
-
defaults: () => ({
|
|
37
|
-
type: "split_content" as const,
|
|
38
|
-
content: { imageId: undefined, body: "<p></p>" },
|
|
39
|
-
}),
|
|
40
|
-
settings: {
|
|
41
|
-
imagePosition: {
|
|
42
|
-
type: "select",
|
|
43
|
-
label: "Image Position",
|
|
44
|
-
default: "left",
|
|
45
|
-
options: [
|
|
46
|
-
{ label: "Left", value: "left" },
|
|
47
|
-
{ label: "Right", value: "right" },
|
|
48
|
-
],
|
|
49
|
-
},
|
|
50
|
-
border: { type: "checkbox", label: "Show border", default: false },
|
|
51
|
-
},
|
|
52
|
-
getLabel: (content) => truncate(stripHtmlToPlainText(content.content.body), 60),
|
|
53
|
-
getThumbnails: (content) =>
|
|
54
|
-
content.content.imageId ? [{ type: "image" as const, src: content.content.imageId }] : [],
|
|
55
|
-
});
|