simplify rich text link styles

This commit is contained in:
Sinclair Chen 2022-07-13 16:12:19 -07:00
parent 664e55a40b
commit 98192ee580
2 changed files with 6 additions and 8 deletions

View File

@ -18,12 +18,10 @@ import { uploadImage } from 'web/lib/firebase/storage'
import { useMutation } from 'react-query' import { useMutation } from 'react-query'
import { exhibitExts } from 'common/util/parse' import { exhibitExts } from 'common/util/parse'
import { FileUploadButton } from './file-upload-button' import { FileUploadButton } from './file-upload-button'
import { linkClass } from './site-link'
const proseClass = clsx( const proseClass = clsx(
'prose prose-sm prose-p:my-0 prose-li:my-0 prose-blockquote:not-italic max-w-none', 'prose prose-sm prose-p:my-0 prose-li:my-0 prose-blockquote:not-italic max-w-none',
// link styles mostly copied from site-link.ts
'prose-a:no-underline prose-a:!text-indigo-700',
'prose-a:z-10 prose-a:break-words hover:prose-a:underline hover:prose-a:decoration-indigo-400 prose-a:hover:decoration-2'
) )
export function useTextEditor(props: { export function useTextEditor(props: {
@ -52,7 +50,7 @@ export function useTextEditor(props: {
}), }),
CharacterCount.configure({ limit: max }), CharacterCount.configure({ limit: max }),
Image, Image,
Link, Link.configure({ HTMLAttributes: { class: clsx('no-underline !text-indigo-700', linkClass)}}),
], ],
content: defaultValue, content: defaultValue,
}) })

View File

@ -2,6 +2,9 @@ import clsx from 'clsx'
import { ReactNode } from 'react' import { ReactNode } from 'react'
import Link from 'next/link' import Link from 'next/link'
export const linkClass =
'z-10 break-words hover:underline hover:decoration-indigo-400 hover:decoration-2'
export const SiteLink = (props: { export const SiteLink = (props: {
href: string href: string
children?: ReactNode children?: ReactNode
@ -13,10 +16,7 @@ export const SiteLink = (props: {
return ( return (
<MaybeLink href={href}> <MaybeLink href={href}>
<a <a
className={clsx( className={clsx(linkClass, className)}
'z-10 break-words hover:underline hover:decoration-indigo-400 hover:decoration-2',
className
)}
href={href} href={href}
target={href.startsWith('http') ? '_blank' : undefined} target={href.startsWith('http') ? '_blank' : undefined}
style={{ /* For iOS safari */ wordBreak: 'break-word' }} style={{ /* For iOS safari */ wordBreak: 'break-word' }}