import React from "react";
import clsx from "clsx";
import { richClasses as classes } from "../style";
import { Spinner } from "@gland/react/spin";
import { icons } from "../icons";
import { editEvent } from "../editEvent";
export function Image(props) {
return props.data.isRemote ? : ;
}
function RemoteImage(props) {
props = props.props;
const [URL, setURL] = React.useState(null);
React.useEffect(() => {
const getContentAsset = props.context.editor?.remote?.getContentAsset;
if (getContentAsset) {
getContentAsset(props.data, setURL, "Image");
} else {
setURL("");
}
}, [props.data]);
if (URL === null) {
return (
);
}
return ;
}
function ImageContent(props) {
const URL = props.URL;
const { context, data, isSelected, blockKey } = props.props;
const { widthType, width, align, title } = data;
let style = {} as any;
let imgStyle = {};
if (width) {
if (widthType === "rate") {
style["width"] = width + "%";
imgStyle["width"] = "100%";
} else if (widthType === "px") {
imgStyle["width"] = width + "px";
}
}
if (align === "left" || align === "right") {
style.float = align;
}
return (
{
if (e.detail >= 2) {
openEdit();
}
}
}
style={style}
>

{context.readOnly ? null :
{"\r"}
}
{title ?
{title}
: null}
{context.readOnly ? null : (
{
event.stopPropagation();
openEdit();
}}
>
)}
);
function openEdit() {
context.event.emit(editEvent.openEditImage, { key: blockKey, data, type: "block" });
}
}