Started doing an Image component for inline text

This commit is contained in:
2023-09-03 19:45:19 +02:00
parent bfeeb71312
commit 4f5d822e11
5 changed files with 42 additions and 27 deletions

View File

@@ -1,14 +1,29 @@
import { TinaMarkdown, TinaMarkdownContent } from "tinacms/dist/rich-text";
import { Template } from "tinacms";
import { anchoringSchema } from "../util/anchoring";
import { TinaMarkdownContent } from "tinacms/dist/rich-text";
import { RichTextTemplate } from "@tinacms/schema-tools";
enum imageSize {
small = "small",
medium = "medium",
large = "large"
}
enum imageDecorations {
default = "default",
noStyle = "no-style"
}
enum imagePosition {
left = "left",
middle = "middle",
right = "right"
}
export interface ImageProps {
children: TinaMarkdownContent;
size: "small" | "medium" | "large";
size: imageSize;
imageUrl: string,
decorations: string,
position: "left" | "middle" | "right"
decorations: imageDecorations,
position: imagePosition
}
const Image = (props: ImageProps) => (
@@ -17,21 +32,27 @@ const Image = (props: ImageProps) => (
</div>);
export const imageSchema: RichTextTemplate = {
name: "image",
name: "Image",
label: "Image",
inline: true,
ui: {
defaultItem: {
size: Object.values(imageSize)[0],
decorations: Object.values(imageDecorations)[0]
}
},
fields: [
{
name: "size",
label: "Size",
type: "string",
options: ["small", "medium", "large"]
options: Object.values(imageSize)
},
{
name: "position",
label: "Position",
type: "string",
options: ["left", "middle", "right"]
options: Object.values(imagePosition)
},
{
name: "imageUrl",
@@ -41,7 +62,8 @@ export const imageSchema: RichTextTemplate = {
{
name: "decorations",
label: "Decorations",
type: "string"
type: "string",
options: Object.values(imageDecorations)
}
] };