feat: add line height & font size settings for plaintext editor (#1700)

This commit is contained in:
Aman Harwara
2022-09-30 00:50:33 +05:30
committed by GitHub
parent fc86cebc75
commit 3c699eaa4a
12 changed files with 178 additions and 31 deletions

View File

@@ -3,7 +3,10 @@ import { ComponentPropsWithoutRef, ForwardedRef, forwardRef } from 'react'
// Based on: https://css-tricks.com/auto-growing-inputs-textareas/#aa-other-ideas
const AutoresizingNoteViewTextarea = forwardRef(
({ value, ...textareaProps }: ComponentPropsWithoutRef<'textarea'>, ref: ForwardedRef<HTMLTextAreaElement>) => {
(
{ value, className, ...textareaProps }: ComponentPropsWithoutRef<'textarea'>,
ref: ForwardedRef<HTMLTextAreaElement>,
) => {
return (
<div className="relative inline-grid min-h-[75vh] w-full grid-rows-1 items-stretch md:block md:flex-grow">
<pre
@@ -11,6 +14,7 @@ const AutoresizingNoteViewTextarea = forwardRef(
className={classNames(
'editable font-editor break-word whitespace-pre-wrap',
'invisible [grid-area:1_/_1] md:hidden',
className,
)}
aria-hidden
>
@@ -18,7 +22,7 @@ const AutoresizingNoteViewTextarea = forwardRef(
</pre>
<textarea
value={value}
className="editable font-editor [grid-area:1_/_1] md:h-full md:min-h-0"
className={classNames('editable font-editor [grid-area:1_/_1] md:h-full md:min-h-0', className)}
{...textareaProps}
ref={ref}
></textarea>