mirror of
https://github.com/24eme/signaturepdf.git
synced 2023-08-25 09:33:08 +02:00
La largeur du textbox s'adapte automatiquement à la largeur du texte
This commit is contained in:
parent
13bea28f0e
commit
be29f851d5
@ -12,6 +12,8 @@ dataTransfer.items.add(new File([pdfBlob], filename, {
|
|||||||
}));
|
}));
|
||||||
document.getElementById('input_pdf').files = dataTransfer.files;
|
document.getElementById('input_pdf').files = dataTransfer.files;
|
||||||
|
|
||||||
|
fabric.Textbox.prototype._wordJoiners = /[]/;
|
||||||
|
|
||||||
// Loaded via <script> tag, create shortcut to access PDF.js exports.
|
// Loaded via <script> tag, create shortcut to access PDF.js exports.
|
||||||
var pdfjsLib = window['pdfjs-dist/build/pdf'];
|
var pdfjsLib = window['pdfjs-dist/build/pdf'];
|
||||||
|
|
||||||
@ -605,7 +607,6 @@ loadingTask.promise.then(function(pdf) {
|
|||||||
var textbox = new fabric.Textbox('Texte à modifier', {
|
var textbox = new fabric.Textbox('Texte à modifier', {
|
||||||
left: x,
|
left: x,
|
||||||
top: y - 20,
|
top: y - 20,
|
||||||
width: 300,
|
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
fontFamily: 'Monospace'
|
fontFamily: 'Monospace'
|
||||||
});
|
});
|
||||||
@ -851,6 +852,13 @@ loadingTask.promise.then(function(pdf) {
|
|||||||
item.scale = event.target.width * event.target.scaleX / event.target.canvas.width;
|
item.scale = event.target.width * event.target.scaleX / event.target.canvas.width;
|
||||||
storeCollections();
|
storeCollections();
|
||||||
});
|
});
|
||||||
|
canvasEdition.on("text:changed", function(event) {
|
||||||
|
if (!event.target instanceof fabric.IText) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const textLinesMaxWidth = event.target.textLines.reduce((max, _, i) => Math.max(max, event.target.getLineWidth(i)), 0);
|
||||||
|
event.target.set({width: textLinesMaxWidth});
|
||||||
|
});
|
||||||
canvasEditions.push(canvasEdition);
|
canvasEditions.push(canvasEdition);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user