fix: adjust field cropping
This commit is contained in:
@@ -345,28 +345,9 @@ export const insertFieldInPDF = async (pdf: PDFDocument, field: FieldWithSignatu
|
||||
* - True = text will overflow downwards.
|
||||
* - False = text will overflow sideways.
|
||||
*/
|
||||
const isMultiline = (() => {
|
||||
// No multiline for date, number or email fields, it MUST overflow on X axis.
|
||||
if (
|
||||
field.type === FieldType.DATE ||
|
||||
field.type === FieldType.NUMBER ||
|
||||
field.type === FieldType.EMAIL
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If width of text overflows, multiline is enabled.
|
||||
if (textWidth > fieldWidth) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the text contains a newline, it must be multiline.
|
||||
if (field.customText.includes('\n')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
})();
|
||||
const isMultiline =
|
||||
field.type === FieldType.TEXT &&
|
||||
(textWidth > fieldWidth || field.customText.includes('\n'));
|
||||
|
||||
// Add padding similar to web display (roughly 0.5rem equivalent in PDF units)
|
||||
const padding = 8;
|
||||
|
||||
@@ -80,7 +80,7 @@ export function FieldRootContainer({ field, children, color, className }: FieldR
|
||||
data-field-type={field.type}
|
||||
data-inserted={field.inserted ? 'true' : 'false'}
|
||||
className={cn(
|
||||
'field--FieldRootContainer field-card-container dark-mode-disabled group relative z-20 flex h-full w-full items-center overflow-clip rounded-[2px] bg-white/90 ring-2 ring-gray-200 transition-all',
|
||||
'field--FieldRootContainer field-card-container dark-mode-disabled group relative z-20 flex h-full w-full items-center rounded-[2px] bg-white/90 ring-2 ring-gray-200 transition-all',
|
||||
color?.base,
|
||||
{
|
||||
'px-2': field.type !== FieldType.SIGNATURE && field.type !== FieldType.FREE_SIGNATURE,
|
||||
|
||||
@@ -62,7 +62,9 @@ export const FieldContent = ({ field, documentMeta }: FieldIconProps) => {
|
||||
<Checkbox
|
||||
className="h-3 w-3"
|
||||
id={`checkbox-${index}`}
|
||||
checked={checkedValues.includes(item.value)}
|
||||
checked={checkedValues.includes(
|
||||
item.value === '' ? `empty-value-${index + 1}` : item.value, // I got no idea...
|
||||
)}
|
||||
/>
|
||||
|
||||
{item.value && (
|
||||
@@ -171,7 +173,7 @@ export const FieldContent = ({ field, documentMeta }: FieldIconProps) => {
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
'text-field-card-foreground flex h-full w-full items-center justify-center gap-x-1.5 whitespace-nowrap text-center text-[clamp(0.07rem,25cqw,0.825rem)]',
|
||||
'text-field-card-foreground flex h-full w-full items-center justify-center gap-x-1.5 overflow-clip whitespace-nowrap text-center text-[clamp(0.07rem,25cqw,0.825rem)]',
|
||||
{
|
||||
// Using justify instead of align because we also vertically center the text.
|
||||
'justify-start': field.inserted && !isSignatureField && textAlign === 'left',
|
||||
|
||||
Reference in New Issue
Block a user