UNPKG

@yuntijs/ui

Version:

☁️ Yunti UI - an open-source UI component library for building Cloud Native web apps

24 lines 764 B
import { TOGGLE_LINK_COMMAND } from '@lexical/link'; import { ActionIcon } from '@lobehub/ui'; import { Link } from 'lucide-react'; import React, { useCallback } from 'react'; import { sanitizeUrl } from "../../utils/url"; import { jsx as _jsx } from "react/jsx-runtime"; export var LinkAction = function LinkAction(_ref) { var editor = _ref.editor, isLink = _ref.isLink, size = _ref.size; var insertLink = useCallback(function () { if (isLink) { editor.dispatchCommand(TOGGLE_LINK_COMMAND, null); } else { editor.dispatchCommand(TOGGLE_LINK_COMMAND, sanitizeUrl('https://')); } }, [editor, isLink]); return /*#__PURE__*/_jsx(ActionIcon, { active: isLink, icon: Link, onClick: insertLink, size: size }); };