import React from "react";
import { icons } from "../../icons";
import { DropButton } from "./widget";
import { ToolAttr, ToolContext } from "../utils";
export function TextAlign(props: { attr: ToolAttr }) {
const lang = props.attr.lang;
return (
{lang.other.defaultAlign},
value: null,
},
{
label: (
{lang.other.leftAlign}
),
value: "left",
},
{
label: (
{lang.other.rightAlign}
),
value: "right",
},
{
label: (
{lang.other.centerAlign}
),
value: "center",
},
{
label: (
{lang.other.justifyAlign}
),
value: "justify",
},
]}
getCurValue={() => {
const attr = props.attr;
return attr.toolCtx.blockStyle?.textAlign || null;
}}
onSelect={(item) => {
const attr = props.attr;
attr.event.emit(attr.editEvent.blockAlign, item.value);
}}
>
);
}
function getLabel(value) {
if (!value || value === "left") return ;
if (value === "right") return ;
if (value === "center") return ;
if (value === "justify") return ;
return null;
}
function AlignIcon(props) {
let ctx = React.useContext(ToolContext);
return getLabel(ctx.blockStyle?.textAlign);
}