🐛 place field outside pdf, add field to cursor center
This commit is contained in:
@@ -56,7 +56,7 @@ export default function EditableField(props: FieldPropsType) {
|
|||||||
<div
|
<div
|
||||||
hidden={props.hidden}
|
hidden={props.hidden}
|
||||||
ref={nodeRef}
|
ref={nodeRef}
|
||||||
className="cursor-move opacity-80 p-2 m-auto w-auto flex-row-reverse text-lg font-bold text-center absolute top-0 left-0 select-none"
|
className="cursor-move opacity-80 p-2 m-auto w-48 h-24 flex-row-reverse text-lg font-bold text-center absolute top-0 left-0 select-none"
|
||||||
style={{
|
style={{
|
||||||
background: stc(props.field.Recipient.email),
|
background: stc(props.field.Recipient.email),
|
||||||
}}
|
}}
|
||||||
@@ -64,7 +64,8 @@ export default function EditableField(props: FieldPropsType) {
|
|||||||
<div className="mb-2 pointer-events-none">
|
<div className="mb-2 pointer-events-none">
|
||||||
<Logo className="w-16 mx-auto"></Logo>
|
<Logo className="w-16 mx-auto"></Logo>
|
||||||
</div>
|
</div>
|
||||||
<div className="m-auto w-auto flex-row-reverse text-lg font-bold text-center">
|
{/* width: 192 height 96 */}
|
||||||
|
<div className="m-auto overflow-hidden flex-row-reverse text-lg font-bold text-center">
|
||||||
{field.type}
|
{field.type}
|
||||||
{field.type === "SIGNATURE" ? (
|
{field.type === "SIGNATURE" ? (
|
||||||
<div className="text-xs text-center">
|
<div className="text-xs text-center">
|
||||||
|
|||||||
@@ -223,8 +223,17 @@ export default function PDFEditor(props: any) {
|
|||||||
|
|
||||||
function addField(e: any, page: number) {
|
function addField(e: any, page: number) {
|
||||||
var rect = e.target.getBoundingClientRect();
|
var rect = e.target.getBoundingClientRect();
|
||||||
var newFieldX = e.clientX - rect.left; //x position within the element.
|
const fieldSize = { width: 192, height: 96 };
|
||||||
var newFieldY = e.clientY - rect.top; //y position within the element.
|
var newFieldX = e.clientX - rect.left - fieldSize.width / 2; //x position within the element.
|
||||||
|
var newFieldY = e.clientY - rect.top - fieldSize.height / 2; //y position within the element.
|
||||||
|
if (newFieldX < 0) newFieldX = 0;
|
||||||
|
if (newFieldY < 0) newFieldY = 0;
|
||||||
|
|
||||||
|
if (newFieldX + fieldSize.width > rect.width)
|
||||||
|
newFieldX = rect.width - fieldSize.width;
|
||||||
|
if (newFieldY + fieldSize.height > rect.height)
|
||||||
|
newFieldY = rect.height - fieldSize.height;
|
||||||
|
|
||||||
const signatureField = {
|
const signatureField = {
|
||||||
id: -1,
|
id: -1,
|
||||||
page: page,
|
page: page,
|
||||||
|
|||||||
Reference in New Issue
Block a user