mirror of
https://github.com/block/buzz.git
synced 2026-11-09 10:51:42 +00:00
Signed-off-by: Taylor Ho <taylorkmho@gmail.com> Co-authored-by: npub1223z34hd7vtwc6qj4s7flsxkj644nlre2nthu7lrrmkumhu3xddsrx9r6w <52a228d6edf316ec6812ac3c9fc0d696ab59fc7954d77e7be31eedcddf91335b@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub14vtk7pvazqrq9639qu7e560wnqtl0d53ca4gjuvq6jzf3k2el23qqlwa7f <ab176f059d100602ea25073d9a69ee9817f7b691c76a897180d48498d959faa2@sprout-oss.stage.blox.sqprod.co>
15 lines
397 B
TypeScript
15 lines
397 B
TypeScript
import type { LinkSelectionInfo } from "./useRichTextEditor";
|
|
|
|
export type LinkEditorInitialFocus = "text" | "url";
|
|
|
|
export function getLinkEditorInitialFocus(
|
|
info: LinkSelectionInfo,
|
|
): LinkEditorInitialFocus {
|
|
const isSelectedTextLinkInsert =
|
|
info.href.length === 0 &&
|
|
info.text.trim().length > 0 &&
|
|
info.from !== info.to;
|
|
|
|
return isSelectedTextLinkInsert ? "url" : "text";
|
|
}
|