import React from "react";
import { icons } from "../../icons";
import { toolNormalBtn, toolClasses as classes } from "../style";
import { ToolAttr } from "../utils";
import { BtnTip } from "./widget";
import { FabricButton } from "@gland/react/button";
import { Callout } from "@gland/react/popover";
import { TextInput } from "@gland/react/input";
export function Link(props: { attr: ToolAttr }) {
const [show, setShow] = React.useState(false);
const btnAttr = React.useRef({} as { root }).current;
const lang = props.attr.lang;
return (
(btnAttr.root = r)}
onClick={() => {
if (props.attr.editorCtx.target?.isCollapsed) {
return;
}
setShow(!show);
}}
>
{
if (type === "click" && !isTarget) {
setShow(false);
}
}}
onMouseDown={(e) => {
const target: HTMLInputElement = e.target;
if (target.tagName !== "INPUT") {
e.preventDefault();
}
}}
>
{
const attr = props.attr;
setTimeout(() => {
if (href) {
attr.event.emit(attr.editEvent.addLink, href);
}
setShow(false);
});
}}
/>
);
}
function LinkInput(props) {
const [text, setText] = React.useState("");
return (
{
setText(e.target.value);
}}
autoFocus
forceAutoFocus
onEntry={() => {
props.onConfirm && props.onConfirm(text);
}}
/>
{
props.onConfirm && props.onConfirm(text);
}}
>
{props.lang.base.confirm}
);
}