fix: CTA question link UX

fix: CTA question link UX
This commit is contained in:
Johannes
2023-08-28 21:35:34 +02:00
committed by GitHub
2 changed files with 22 additions and 40 deletions

View File

@@ -135,7 +135,8 @@ export default async function handle(req: NextApiRequest, res: NextApiResponse)
},
{
name: "Spark.NET",
description: "The .NET Web Framework for Makers. Build production ready, full-stack web applications fast without sweating the small stuff.",
description:
"The .NET Web Framework for Makers. Build production ready, full-stack web applications fast without sweating the small stuff.",
href: "https://spark-framework.net",
},
],

View File

@@ -26,7 +26,7 @@ import {
} from "lexical";
import { useCallback, useEffect, useRef, useState } from "react";
import { createPortal } from "react-dom";
import { Input } from "../../Input";
import { Bold, ChevronDownIcon, Italic, Link } from "lucide-react";
import { Button } from "../../Button";
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../../DropdownMenu";
@@ -158,47 +158,28 @@ function FloatingLinkEditor({ editor }: { editor: LexicalEditor }) {
return (
<div ref={editorRef} className="link-editor">
{isEditMode ? (
<input
ref={inputRef}
className="link-input"
value={linkUrl}
onChange={(event) => {
setLinkUrl(event.target.value);
}}
onKeyDown={(event) => {
if (event.key === "Enter") {
event.preventDefault();
if (lastSelection !== null) {
if (linkUrl !== "") {
editor.dispatchCommand(TOGGLE_LINK_COMMAND, linkUrl);
}
setEditMode(false);
<Input
className="bg-white"
ref={inputRef}
value={linkUrl}
onChange={(event) => {
setLinkUrl(event.target.value);
}}
onKeyDown={(event) => {
if (event.key === "Enter") {
event.preventDefault();
if (lastSelection !== null) {
if (linkUrl !== "") {
editor.dispatchCommand(TOGGLE_LINK_COMMAND, linkUrl);
}
} else if (event.key === "Escape") {
event.preventDefault();
setEditMode(false);
}
}}
/>
) : (
<>
<div className="link-input">
<a href={linkUrl} target="_blank" rel="noopener noreferrer">
{linkUrl}
</a>
<div
className="link-edit"
role="button"
tabIndex={0}
onMouseDown={(event) => event.preventDefault()}
onClick={() => {
setEditMode(true);
}}
/>
</div>
</>
)}
} else if (event.key === "Escape") {
event.preventDefault();
setEditMode(false);
}
}}
/>
</div>
);
}