@pdfme/ui 6.1.1-dev.26 → 6.1.1-dev.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +306 -86
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -98636,7 +98636,7 @@ $d636bc798e7178db$export$36b2f24e97d43be($21ee218f84ac7f32$export$2e2bcd8739ae03
|
|
|
98636
98636
|
$d636bc798e7178db$export$36b2f24e97d43be($cd5853a56c68fec7$export$2e2bcd8739ae039);
|
|
98637
98637
|
$d636bc798e7178db$export$36b2f24e97d43be($05f49f930186144e$export$2e2bcd8739ae039);
|
|
98638
98638
|
//#endregion
|
|
98639
|
-
//#region ../schemas/dist/splitRange-
|
|
98639
|
+
//#region ../schemas/dist/splitRange-DmVDtmzO.js
|
|
98640
98640
|
var ALIGN_LEFT = "left";
|
|
98641
98641
|
var ALIGN_CENTER = "center";
|
|
98642
98642
|
var ALIGN_RIGHT = "right";
|
|
@@ -98730,6 +98730,84 @@ var LINE_END_FORBIDDEN_CHARS = [
|
|
|
98730
98730
|
"⦅",
|
|
98731
98731
|
"«"
|
|
98732
98732
|
];
|
|
98733
|
+
var createBoxDimension = (value = 0) => ({
|
|
98734
|
+
top: value,
|
|
98735
|
+
right: value,
|
|
98736
|
+
bottom: value,
|
|
98737
|
+
left: value
|
|
98738
|
+
});
|
|
98739
|
+
var normalizeBoxDimension = (value) => ({
|
|
98740
|
+
top: value?.top ?? 0,
|
|
98741
|
+
right: value?.right ?? 0,
|
|
98742
|
+
bottom: value?.bottom ?? 0,
|
|
98743
|
+
left: value?.left ?? 0
|
|
98744
|
+
});
|
|
98745
|
+
var getBoxInsets = (schema) => ({
|
|
98746
|
+
borderWidth: normalizeBoxDimension(schema.borderWidth),
|
|
98747
|
+
padding: normalizeBoxDimension(schema.padding)
|
|
98748
|
+
});
|
|
98749
|
+
var getBoxContentArea = (schema) => {
|
|
98750
|
+
const { borderWidth, padding } = getBoxInsets(schema);
|
|
98751
|
+
const leftInset = borderWidth.left + padding.left;
|
|
98752
|
+
const topInset = borderWidth.top + padding.top;
|
|
98753
|
+
const rightInset = borderWidth.right + padding.right;
|
|
98754
|
+
const bottomInset = borderWidth.bottom + padding.bottom;
|
|
98755
|
+
return {
|
|
98756
|
+
position: {
|
|
98757
|
+
x: schema.position.x + leftInset,
|
|
98758
|
+
y: schema.position.y + topInset
|
|
98759
|
+
},
|
|
98760
|
+
width: Math.max(0, schema.width - leftInset - rightInset),
|
|
98761
|
+
height: Math.max(0, schema.height - topInset - bottomInset),
|
|
98762
|
+
leftInset,
|
|
98763
|
+
topInset,
|
|
98764
|
+
rightInset,
|
|
98765
|
+
bottomInset
|
|
98766
|
+
};
|
|
98767
|
+
};
|
|
98768
|
+
var hasBoxDimension = (dimension) => {
|
|
98769
|
+
const resolved = normalizeBoxDimension(dimension);
|
|
98770
|
+
return resolved.top > 0 || resolved.right > 0 || resolved.bottom > 0 || resolved.left > 0;
|
|
98771
|
+
};
|
|
98772
|
+
var getSplitBoxDimension = (dimension, range, totalUnits) => {
|
|
98773
|
+
const resolved = normalizeBoxDimension(dimension);
|
|
98774
|
+
const end = range.end ?? totalUnits;
|
|
98775
|
+
return {
|
|
98776
|
+
top: range.start === 0 ? resolved.top : 0,
|
|
98777
|
+
right: resolved.right,
|
|
98778
|
+
bottom: end >= totalUnits ? resolved.bottom : 0,
|
|
98779
|
+
left: resolved.left
|
|
98780
|
+
};
|
|
98781
|
+
};
|
|
98782
|
+
var getBoxDimensionPropPanelSchema = (step = 1) => {
|
|
98783
|
+
const getCommonProp = () => ({
|
|
98784
|
+
type: "number",
|
|
98785
|
+
widget: "inputNumber",
|
|
98786
|
+
props: {
|
|
98787
|
+
min: 0,
|
|
98788
|
+
step
|
|
98789
|
+
},
|
|
98790
|
+
span: 6
|
|
98791
|
+
});
|
|
98792
|
+
return {
|
|
98793
|
+
top: {
|
|
98794
|
+
title: "Top",
|
|
98795
|
+
...getCommonProp()
|
|
98796
|
+
},
|
|
98797
|
+
right: {
|
|
98798
|
+
title: "Right",
|
|
98799
|
+
...getCommonProp()
|
|
98800
|
+
},
|
|
98801
|
+
bottom: {
|
|
98802
|
+
title: "Bottom",
|
|
98803
|
+
...getCommonProp()
|
|
98804
|
+
},
|
|
98805
|
+
left: {
|
|
98806
|
+
title: "Left",
|
|
98807
|
+
...getCommonProp()
|
|
98808
|
+
}
|
|
98809
|
+
};
|
|
98810
|
+
};
|
|
98733
98811
|
var getBrowserVerticalFontAdjustments = (fontKitFont, fontSize, lineHeight, verticalAlignment) => {
|
|
98734
98812
|
const { ascent, descent, unitsPerEm } = fontKitFont;
|
|
98735
98813
|
const fontBaseLineHeight = (ascent - descent) / unitsPerEm;
|
|
@@ -98817,7 +98895,8 @@ var getFontKitFont = async (fontName, font, _cache) => {
|
|
|
98817
98895
|
* the box width based on the proposed size.
|
|
98818
98896
|
*/
|
|
98819
98897
|
var calculateDynamicFontSize = ({ textSchema, fontKitFont, value, startingFontSize }) => {
|
|
98820
|
-
const { fontSize: schemaFontSize, dynamicFontSize: dynamicFontSizeSetting, characterSpacing: schemaCharacterSpacing,
|
|
98898
|
+
const { fontSize: schemaFontSize, dynamicFontSize: dynamicFontSizeSetting, characterSpacing: schemaCharacterSpacing, lineHeight = 1 } = textSchema;
|
|
98899
|
+
const { width: boxWidth, height: boxHeight } = getBoxContentArea(textSchema);
|
|
98821
98900
|
const fontSize = startingFontSize || schemaFontSize || 13;
|
|
98822
98901
|
if (!dynamicFontSizeSetting) return fontSize;
|
|
98823
98902
|
if (dynamicFontSizeSetting.max < dynamicFontSizeSetting.min) return fontSize;
|
|
@@ -99023,7 +99102,7 @@ var createTextLineSplitRange = (start, end) => createDynamicLayoutSplitRange(TEX
|
|
|
99023
99102
|
var getTableBodyRange = (schema) => getDynamicLayoutSplitRange(schema, TABLE_BODY_SPLIT_UNIT);
|
|
99024
99103
|
var getTextLineRange = (schema) => getDynamicLayoutSplitRange(schema, TEXT_LINE_SPLIT_UNIT);
|
|
99025
99104
|
//#endregion
|
|
99026
|
-
//#region ../schemas/dist/measure-
|
|
99105
|
+
//#region ../schemas/dist/measure-L5diay3k.js
|
|
99027
99106
|
var MARKDOWN_ESCAPABLE_CHARS = new Set([
|
|
99028
99107
|
"\\",
|
|
99029
99108
|
"*",
|
|
@@ -99262,7 +99341,7 @@ var resolveRichTextRuns = async (arg) => {
|
|
|
99262
99341
|
var measureRunText = (run, text, fontSize, characterSpacing) => {
|
|
99263
99342
|
const syntheticBoldWidth = run.syntheticBold ? fontSize * SYNTHETIC_BOLD_OFFSET_RATIO * 2 : 0;
|
|
99264
99343
|
const syntheticItalicWidth = run.syntheticItalic ? heightOfFontAtSize(run.fontKitFont, fontSize) * Math.tan(12 * Math.PI / 180) : 0;
|
|
99265
|
-
return widthOfTextAtSize(text, run.fontKitFont, fontSize, characterSpacing) + syntheticBoldWidth + syntheticItalicWidth;
|
|
99344
|
+
return widthOfTextAtSize(text, run.fontKitFont, fontSize, characterSpacing) + syntheticBoldWidth + syntheticItalicWidth + (run.code ? CODE_HORIZONTAL_PADDING * 2 : 0);
|
|
99266
99345
|
};
|
|
99267
99346
|
var createLine = () => ({
|
|
99268
99347
|
runs: [],
|
|
@@ -99272,6 +99351,14 @@ var createLine = () => ({
|
|
|
99272
99351
|
var pushRunToLine = (line, run, text, fontSize, characterSpacing) => {
|
|
99273
99352
|
if (!text) return;
|
|
99274
99353
|
const width = measureRunText(run, text, fontSize, characterSpacing);
|
|
99354
|
+
const lastRun = line.runs[line.runs.length - 1];
|
|
99355
|
+
if (lastRun && canMergeRichTextRuns(lastRun, run)) {
|
|
99356
|
+
const previousWidth = lastRun.width;
|
|
99357
|
+
lastRun.text += text;
|
|
99358
|
+
lastRun.width = measureRunText(lastRun, lastRun.text, fontSize, characterSpacing);
|
|
99359
|
+
line.width += lastRun.width - previousWidth;
|
|
99360
|
+
return;
|
|
99361
|
+
}
|
|
99275
99362
|
if (line.runs.length > 0) line.width += characterSpacing;
|
|
99276
99363
|
line.runs.push({
|
|
99277
99364
|
...run,
|
|
@@ -99280,6 +99367,7 @@ var pushRunToLine = (line, run, text, fontSize, characterSpacing) => {
|
|
|
99280
99367
|
});
|
|
99281
99368
|
line.width += width;
|
|
99282
99369
|
};
|
|
99370
|
+
var canMergeRichTextRuns = (a, b) => a.fontName === b.fontName && a.fontKitFont === b.fontKitFont && a.syntheticBold === b.syntheticBold && a.syntheticItalic === b.syntheticItalic && a.bold === b.bold && a.italic === b.italic && a.strikethrough === b.strikethrough && a.code === b.code && a.href === b.href;
|
|
99283
99371
|
var measurePiecesWidth = (pieces, fontSize, characterSpacing) => {
|
|
99284
99372
|
let width = 0;
|
|
99285
99373
|
let hasText = false;
|
|
@@ -99435,7 +99523,8 @@ var getLineHeightAtSize = (line, fontSize) => {
|
|
|
99435
99523
|
};
|
|
99436
99524
|
var calculateDynamicRichTextFontSize = async (arg) => {
|
|
99437
99525
|
const { value, schema, font, _cache, startingFontSize } = arg;
|
|
99438
|
-
const { fontSize: schemaFontSize, dynamicFontSize: dynamicFontSizeSetting, characterSpacing: schemaCharacterSpacing,
|
|
99526
|
+
const { fontSize: schemaFontSize, dynamicFontSize: dynamicFontSizeSetting, characterSpacing: schemaCharacterSpacing, lineHeight = 1 } = schema;
|
|
99527
|
+
const { width: boxWidth, height: boxHeight } = getBoxContentArea(schema);
|
|
99439
99528
|
const fontSize = startingFontSize || schemaFontSize || 13;
|
|
99440
99529
|
if (!dynamicFontSizeSetting) return fontSize;
|
|
99441
99530
|
if (dynamicFontSizeSetting.max < dynamicFontSizeSetting.min) return fontSize;
|
|
@@ -99521,7 +99610,7 @@ var measureTextLines = async ({ value, schema, font = getDefaultFont(), _cache =
|
|
|
99521
99610
|
const fontSize = schema.fontSize ?? 13;
|
|
99522
99611
|
const lineHeight = schema.lineHeight ?? 1;
|
|
99523
99612
|
const characterSpacing = schema.characterSpacing ?? 0;
|
|
99524
|
-
const boxWidthInPt = mm2pt(schema.width);
|
|
99613
|
+
const boxWidthInPt = mm2pt(getBoxContentArea(schema).width);
|
|
99525
99614
|
if (isInlineMarkdownTextSchema(schema)) {
|
|
99526
99615
|
const resolvedRuns = await resolveRichTextRuns({
|
|
99527
99616
|
runs: parseInlineMarkdown(value),
|
|
@@ -99580,6 +99669,23 @@ var mergeTextLineRangeValue = async ({ value, replacement, schema, font = getDef
|
|
|
99580
99669
|
return plainTextLinesToValue(nextLines);
|
|
99581
99670
|
};
|
|
99582
99671
|
var sumLineHeights = (lineHeights) => lineHeights.reduce((sum, height) => sum + height, 0);
|
|
99672
|
+
var getTextLineHeightsWithBox = (lineHeights, schema) => lineHeights.map((height, index) => height + getTextBoxVerticalInsetForRange(schema, {
|
|
99673
|
+
start: index,
|
|
99674
|
+
end: index + 1
|
|
99675
|
+
}, lineHeights.length));
|
|
99676
|
+
var getTextSplitBoxStyle = (schema, range, totalLines) => {
|
|
99677
|
+
const { borderWidth, padding } = getBoxInsets(schema);
|
|
99678
|
+
return {
|
|
99679
|
+
...hasBoxDimension(schema.borderWidth) ? { borderWidth: getSplitBoxDimension(borderWidth, range, totalLines) } : {},
|
|
99680
|
+
...hasBoxDimension(schema.padding) ? { padding: getSplitBoxDimension(padding, range, totalLines) } : {}
|
|
99681
|
+
};
|
|
99682
|
+
};
|
|
99683
|
+
var getTextBoxVerticalInsetForRange = (schema, range, totalLines) => {
|
|
99684
|
+
const { borderWidth, padding } = getBoxInsets(schema);
|
|
99685
|
+
const splitBorderWidth = getSplitBoxDimension(borderWidth, range, totalLines);
|
|
99686
|
+
const splitPadding = getSplitBoxDimension(padding, range, totalLines);
|
|
99687
|
+
return splitBorderWidth.top + splitBorderWidth.bottom + splitPadding.top + splitPadding.bottom;
|
|
99688
|
+
};
|
|
99583
99689
|
var measurePlainTextLineHeights = (lines, fontKitFont, fontSize, lineHeight) => {
|
|
99584
99690
|
if (lines.length === 0) return [];
|
|
99585
99691
|
const firstLineHeight = heightOfFontAtSize(fontKitFont, fontSize) * lineHeight;
|
|
@@ -99595,7 +99701,7 @@ var getRichTextLineHeight = (line, fontSize) => {
|
|
|
99595
99701
|
return Math.max(...line.runs.map((run) => heightOfFontAtSize(run.fontKitFont, fontSize)));
|
|
99596
99702
|
};
|
|
99597
99703
|
//#endregion
|
|
99598
|
-
//#region ../schemas/dist/dynamicTemplate-
|
|
99704
|
+
//#region ../schemas/dist/dynamicTemplate-B4GCNLF9.js
|
|
99599
99705
|
function _typeof$18(o) {
|
|
99600
99706
|
"@babel/helpers - typeof";
|
|
99601
99707
|
return _typeof$18 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -100159,7 +100265,7 @@ var getDynamicLayoutForTable = async (value, args) => {
|
|
|
100159
100265
|
};
|
|
100160
100266
|
};
|
|
100161
100267
|
//#endregion
|
|
100162
|
-
//#region ../schemas/dist/utils-
|
|
100268
|
+
//#region ../schemas/dist/utils-zDZkqBnX.js
|
|
100163
100269
|
var convertForPdfLayoutProps = ({ schema, pageHeight, applyRotateTranslate = true }) => {
|
|
100164
100270
|
const { width: mmWidth, height: mmHeight, position, rotate, opacity } = schema;
|
|
100165
100271
|
const { x: mmX, y: mmY } = position;
|
|
@@ -100449,7 +100555,7 @@ var Underline = [["path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }], ["line", {
|
|
|
100449
100555
|
y2: "20"
|
|
100450
100556
|
}]];
|
|
100451
100557
|
//#endregion
|
|
100452
|
-
//#region ../schemas/dist/builtins-
|
|
100558
|
+
//#region ../schemas/dist/builtins-BB2DHceW.js
|
|
100453
100559
|
var addUriLinkAnnotation = (arg) => {
|
|
100454
100560
|
const { pdfDoc, page, uri, rect, borderWidth = 0 } = arg;
|
|
100455
100561
|
const safeUri = normalizeSafeLinkUri(uri);
|
|
@@ -100478,7 +100584,7 @@ var addUriLinkAnnotation = (arg) => {
|
|
|
100478
100584
|
};
|
|
100479
100585
|
var getSyntheticBoldWidth = (run, fontSize) => run.syntheticBold ? fontSize * SYNTHETIC_BOLD_OFFSET_RATIO * 2 : 0;
|
|
100480
100586
|
var getSyntheticItalicWidth = (run, fontSize) => run.syntheticItalic ? heightOfFontAtSize(run.fontKitFont, fontSize) * Math.tan(12 * Math.PI / 180) : 0;
|
|
100481
|
-
var getRunWidth = (run, fontSize, characterSpacing) => widthOfTextAtSize(run.text, run.fontKitFont, fontSize, characterSpacing) + getSyntheticBoldWidth(run, fontSize) + getSyntheticItalicWidth(run, fontSize);
|
|
100587
|
+
var getRunWidth = (run, fontSize, characterSpacing) => widthOfTextAtSize(run.text, run.fontKitFont, fontSize, characterSpacing) + getSyntheticBoldWidth(run, fontSize) + getSyntheticItalicWidth(run, fontSize) + (run.code ? CODE_HORIZONTAL_PADDING * 2 : 0);
|
|
100482
100588
|
var getPdfFontFromObj = (run, pdfFontObj) => {
|
|
100483
100589
|
const pdfFont = pdfFontObj[run.fontName];
|
|
100484
100590
|
if (!pdfFont) throw new Error(`[@pdfme/schemas] Missing embedded font "${run.fontName}".`);
|
|
@@ -100559,10 +100665,12 @@ var getLinkAnnotationRect = (arg) => {
|
|
|
100559
100665
|
var drawRun = (arg) => {
|
|
100560
100666
|
const { page, pdfLib, run, pdfFont, x, y, rotate, pivotPoint, fontSize, lineHeight, color, opacity, colorType, characterSpacing, strikethrough, underline } = arg;
|
|
100561
100667
|
const runWidth = getRunWidth(run, fontSize, characterSpacing);
|
|
100668
|
+
const codePadding = run.code ? CODE_HORIZONTAL_PADDING : 0;
|
|
100669
|
+
const textX = x + codePadding;
|
|
100670
|
+
const textWidth = runWidth - codePadding * 2;
|
|
100562
100671
|
const textHeight = heightOfFontAtSize(run.fontKitFont, fontSize);
|
|
100563
100672
|
if (run.code) {
|
|
100564
|
-
const
|
|
100565
|
-
const bgX = x - padding;
|
|
100673
|
+
const bgX = x;
|
|
100566
100674
|
const bgY = y - textHeight * .2;
|
|
100567
100675
|
const bgPoint = rotate.angle === 0 ? {
|
|
100568
100676
|
x: bgX,
|
|
@@ -100574,7 +100682,7 @@ var drawRun = (arg) => {
|
|
|
100574
100682
|
page.drawRectangle({
|
|
100575
100683
|
x: bgPoint.x,
|
|
100576
100684
|
y: bgPoint.y,
|
|
100577
|
-
width: runWidth
|
|
100685
|
+
width: runWidth,
|
|
100578
100686
|
height: textHeight * 1.2,
|
|
100579
100687
|
rotate,
|
|
100580
100688
|
color: hex2PrintingColor(CODE_BACKGROUND_COLOR, colorType),
|
|
@@ -100583,9 +100691,9 @@ var drawRun = (arg) => {
|
|
|
100583
100691
|
}
|
|
100584
100692
|
if (strikethrough && runWidth > 0) drawDecorationLine({
|
|
100585
100693
|
page,
|
|
100586
|
-
x,
|
|
100694
|
+
x: textX,
|
|
100587
100695
|
y: y + textHeight / 3,
|
|
100588
|
-
width:
|
|
100696
|
+
width: textWidth,
|
|
100589
100697
|
rotate,
|
|
100590
100698
|
pivotPoint,
|
|
100591
100699
|
fontSize,
|
|
@@ -100594,9 +100702,9 @@ var drawRun = (arg) => {
|
|
|
100594
100702
|
});
|
|
100595
100703
|
if (underline && runWidth > 0) drawDecorationLine({
|
|
100596
100704
|
page,
|
|
100597
|
-
x,
|
|
100705
|
+
x: textX,
|
|
100598
100706
|
y: y - textHeight / 12,
|
|
100599
|
-
width:
|
|
100707
|
+
width: textWidth,
|
|
100600
100708
|
rotate,
|
|
100601
100709
|
pivotPoint,
|
|
100602
100710
|
fontSize,
|
|
@@ -100623,14 +100731,14 @@ var drawRun = (arg) => {
|
|
|
100623
100731
|
...run.syntheticItalic ? { ySkew: pdfLib.degrees(12) } : {}
|
|
100624
100732
|
});
|
|
100625
100733
|
};
|
|
100626
|
-
drawAt(
|
|
100734
|
+
drawAt(textX);
|
|
100627
100735
|
if (run.syntheticBold) {
|
|
100628
100736
|
const offset = fontSize * SYNTHETIC_BOLD_OFFSET_RATIO;
|
|
100629
|
-
for (let i = 1; i <= 2; i++) drawAt(
|
|
100737
|
+
for (let i = 1; i <= 2; i++) drawAt(textX + offset * i);
|
|
100630
100738
|
}
|
|
100631
100739
|
};
|
|
100632
100740
|
var renderInlineMarkdownText = async (arg) => {
|
|
100633
|
-
const { value, schema, font, embedPdfFont, fontKitFont, pdfDoc, page, pdfLib, _cache, colorType, fontSize, color, alignment, verticalAlignment, lineHeight, characterSpacing, x, width, height,
|
|
100741
|
+
const { value, schema, font, embedPdfFont, fontKitFont, pdfDoc, page, pdfLib, _cache, colorType, fontSize, color, alignment, verticalAlignment, lineHeight, characterSpacing, x, y, width, height, pivotPoint, rotate, opacity } = arg;
|
|
100634
100742
|
const allLines = layoutRichTextLines({
|
|
100635
100743
|
runs: await resolveRichTextRuns({
|
|
100636
100744
|
runs: parseInlineMarkdown(value),
|
|
@@ -100670,7 +100778,7 @@ var renderInlineMarkdownText = async (arg) => {
|
|
|
100670
100778
|
let xLine = x;
|
|
100671
100779
|
if (alignment === "center") xLine += (width - textWidth) / 2;
|
|
100672
100780
|
else if (alignment === "right") xLine += width - textWidth;
|
|
100673
|
-
const yLine =
|
|
100781
|
+
const yLine = y + height - yOffset - lineHeight * fontSize * rowIndex;
|
|
100674
100782
|
page.pushOperators(pdfLib.setCharacterSpacing(spacing));
|
|
100675
100783
|
if (schema.strikethrough || schema.underline) {
|
|
100676
100784
|
const textHeight = Math.max(...line.runs.map((run) => heightOfFontAtSize(run.fontKitFont, fontSize)));
|
|
@@ -100797,10 +100905,36 @@ var getGraphemeSegmenter = () => {
|
|
|
100797
100905
|
};
|
|
100798
100906
|
var pdfRender = async (arg) => {
|
|
100799
100907
|
const { value, pdfDoc, pdfLib, page, options, schema, basePdf, _cache } = arg;
|
|
100800
|
-
if (!value) return;
|
|
100801
100908
|
const { font = getDefaultFont(), colorType } = options;
|
|
100909
|
+
const pageHeight = page.getHeight();
|
|
100910
|
+
const { width, height, rotate, position: { x, y }, opacity } = convertForPdfLayoutProps({
|
|
100911
|
+
schema,
|
|
100912
|
+
pageHeight,
|
|
100913
|
+
applyRotateTranslate: false
|
|
100914
|
+
});
|
|
100915
|
+
const pivotPoint = {
|
|
100916
|
+
x: x + width / 2,
|
|
100917
|
+
y: pageHeight - mm2pt(schema.position.y) - height / 2
|
|
100918
|
+
};
|
|
100919
|
+
drawTextBoxDecoration({
|
|
100920
|
+
page,
|
|
100921
|
+
schema,
|
|
100922
|
+
colorType,
|
|
100923
|
+
x,
|
|
100924
|
+
y,
|
|
100925
|
+
width,
|
|
100926
|
+
height,
|
|
100927
|
+
rotate,
|
|
100928
|
+
pivotPoint
|
|
100929
|
+
});
|
|
100930
|
+
if (!value) return;
|
|
100802
100931
|
const fontName = schema.fontName ? schema.fontName : getFallbackFontName(font);
|
|
100803
100932
|
const enableInlineMarkdown = isInlineMarkdownTextSchema(schema);
|
|
100933
|
+
const contentArea = getBoxContentArea(schema);
|
|
100934
|
+
const contentX = x + mm2pt(contentArea.leftInset);
|
|
100935
|
+
const contentY = y + mm2pt(contentArea.bottomInset);
|
|
100936
|
+
const contentWidth = mm2pt(contentArea.width);
|
|
100937
|
+
const contentHeight = mm2pt(contentArea.height);
|
|
100804
100938
|
const pdfFontValuePromise = enableInlineMarkdown ? void 0 : embedAndGetFont({
|
|
100805
100939
|
pdfDoc,
|
|
100806
100940
|
font,
|
|
@@ -100821,40 +100955,6 @@ var pdfRender = async (arg) => {
|
|
|
100821
100955
|
_cache
|
|
100822
100956
|
}) : void 0
|
|
100823
100957
|
});
|
|
100824
|
-
const pageHeight = page.getHeight();
|
|
100825
|
-
const { width, height, rotate, position: { x, y }, opacity } = convertForPdfLayoutProps({
|
|
100826
|
-
schema,
|
|
100827
|
-
pageHeight,
|
|
100828
|
-
applyRotateTranslate: false
|
|
100829
|
-
});
|
|
100830
|
-
const pivotPoint = {
|
|
100831
|
-
x: x + width / 2,
|
|
100832
|
-
y: pageHeight - mm2pt(schema.position.y) - height / 2
|
|
100833
|
-
};
|
|
100834
|
-
if (schema.backgroundColor) {
|
|
100835
|
-
const color = hex2PrintingColor(schema.backgroundColor, colorType);
|
|
100836
|
-
if (rotate.angle !== 0) {
|
|
100837
|
-
const rotatedPoint = rotatePoint({
|
|
100838
|
-
x,
|
|
100839
|
-
y
|
|
100840
|
-
}, pivotPoint, rotate.angle);
|
|
100841
|
-
page.drawRectangle({
|
|
100842
|
-
x: rotatedPoint.x,
|
|
100843
|
-
y: rotatedPoint.y,
|
|
100844
|
-
width,
|
|
100845
|
-
height,
|
|
100846
|
-
rotate,
|
|
100847
|
-
color
|
|
100848
|
-
});
|
|
100849
|
-
} else page.drawRectangle({
|
|
100850
|
-
x,
|
|
100851
|
-
y,
|
|
100852
|
-
width,
|
|
100853
|
-
height,
|
|
100854
|
-
rotate,
|
|
100855
|
-
color
|
|
100856
|
-
});
|
|
100857
|
-
}
|
|
100858
100958
|
if (enableInlineMarkdown) {
|
|
100859
100959
|
await renderInlineMarkdownText({
|
|
100860
100960
|
value,
|
|
@@ -100878,10 +100978,10 @@ var pdfRender = async (arg) => {
|
|
|
100878
100978
|
verticalAlignment,
|
|
100879
100979
|
lineHeight,
|
|
100880
100980
|
characterSpacing,
|
|
100881
|
-
x,
|
|
100882
|
-
|
|
100883
|
-
|
|
100884
|
-
|
|
100981
|
+
x: contentX,
|
|
100982
|
+
y: contentY,
|
|
100983
|
+
width: contentWidth,
|
|
100984
|
+
height: contentHeight,
|
|
100885
100985
|
pivotPoint,
|
|
100886
100986
|
rotate,
|
|
100887
100987
|
opacity
|
|
@@ -100898,7 +100998,7 @@ var pdfRender = async (arg) => {
|
|
|
100898
100998
|
characterSpacing,
|
|
100899
100999
|
fontSize,
|
|
100900
101000
|
fontKitFont,
|
|
100901
|
-
boxWidthInPt:
|
|
101001
|
+
boxWidthInPt: contentWidth
|
|
100902
101002
|
}), getTextLineRange(schema));
|
|
100903
101003
|
const needsTextWidth = alignment !== "left" || Boolean(schema.strikethrough || schema.underline);
|
|
100904
101004
|
const needsTextHeight = Boolean(schema.strikethrough || schema.underline);
|
|
@@ -100906,8 +101006,8 @@ var pdfRender = async (arg) => {
|
|
|
100906
101006
|
if (verticalAlignment === "top") yOffset = firstLineTextHeight + halfLineHeightAdjustment;
|
|
100907
101007
|
else {
|
|
100908
101008
|
const otherLinesHeight = lineHeight * fontSize * (lines.length - 1);
|
|
100909
|
-
if (verticalAlignment === "bottom") yOffset =
|
|
100910
|
-
else if (verticalAlignment === "middle") yOffset = (
|
|
101009
|
+
if (verticalAlignment === "bottom") yOffset = contentHeight - otherLinesHeight + descent - halfLineHeightAdjustment;
|
|
101010
|
+
else if (verticalAlignment === "middle") yOffset = (contentHeight - otherLinesHeight - firstLineTextHeight + descent) / 2 + firstLineTextHeight;
|
|
100911
101011
|
}
|
|
100912
101012
|
lines.forEach((line, rowIndex) => {
|
|
100913
101013
|
const trimmed = line.replace("\n", "");
|
|
@@ -100915,10 +101015,10 @@ var pdfRender = async (arg) => {
|
|
|
100915
101015
|
const textHeight = needsTextHeight ? heightOfFontAtSize(fontKitFont, fontSize) : 0;
|
|
100916
101016
|
const rowYOffset = lineHeight * fontSize * rowIndex;
|
|
100917
101017
|
if (line === "") line = "\r\n";
|
|
100918
|
-
let xLine =
|
|
100919
|
-
if (alignment === "center") xLine += (
|
|
100920
|
-
else if (alignment === "right") xLine +=
|
|
100921
|
-
let yLine =
|
|
101018
|
+
let xLine = contentX;
|
|
101019
|
+
if (alignment === "center") xLine += (contentWidth - textWidth) / 2;
|
|
101020
|
+
else if (alignment === "right") xLine += contentWidth - textWidth;
|
|
101021
|
+
let yLine = contentY + contentHeight - yOffset - rowYOffset;
|
|
100922
101022
|
if (schema.strikethrough && textWidth > 0) {
|
|
100923
101023
|
const _x = xLine + textWidth + 1;
|
|
100924
101024
|
const _y = yLine + textHeight / 3;
|
|
@@ -100965,7 +101065,7 @@ var pdfRender = async (arg) => {
|
|
|
100965
101065
|
if (alignment === "justify" && line.slice(-1) !== "\n") {
|
|
100966
101066
|
const iterator = getGraphemeSegmenter().segment(trimmed)[Symbol.iterator]();
|
|
100967
101067
|
const len = Array.from(iterator).length;
|
|
100968
|
-
spacing += (
|
|
101068
|
+
spacing += (contentWidth - textWidth) / len;
|
|
100969
101069
|
}
|
|
100970
101070
|
page.pushOperators(pdfLib.setCharacterSpacing(spacing));
|
|
100971
101071
|
page.drawText(trimmed, {
|
|
@@ -100980,6 +101080,75 @@ var pdfRender = async (arg) => {
|
|
|
100980
101080
|
});
|
|
100981
101081
|
});
|
|
100982
101082
|
};
|
|
101083
|
+
var drawTextBoxDecoration = (arg) => {
|
|
101084
|
+
const { page, schema, colorType, x, y, width, height, rotate, pivotPoint } = arg;
|
|
101085
|
+
const { borderWidth } = getBoxInsets(schema);
|
|
101086
|
+
const opacity = schema.opacity ?? 1;
|
|
101087
|
+
const drawRectangle = (rect) => {
|
|
101088
|
+
if (rect.width <= 0 || rect.height <= 0) return;
|
|
101089
|
+
const point = rotate.angle === 0 ? {
|
|
101090
|
+
x: rect.x,
|
|
101091
|
+
y: rect.y
|
|
101092
|
+
} : rotatePoint({
|
|
101093
|
+
x: rect.x,
|
|
101094
|
+
y: rect.y
|
|
101095
|
+
}, pivotPoint, rotate.angle);
|
|
101096
|
+
page.drawRectangle({
|
|
101097
|
+
x: point.x,
|
|
101098
|
+
y: point.y,
|
|
101099
|
+
width: rect.width,
|
|
101100
|
+
height: rect.height,
|
|
101101
|
+
rotate,
|
|
101102
|
+
color: rect.color,
|
|
101103
|
+
opacity
|
|
101104
|
+
});
|
|
101105
|
+
};
|
|
101106
|
+
if (schema.backgroundColor) {
|
|
101107
|
+
const color = hex2PrintingColor(schema.backgroundColor, colorType);
|
|
101108
|
+
if (color) drawRectangle({
|
|
101109
|
+
x,
|
|
101110
|
+
y,
|
|
101111
|
+
width,
|
|
101112
|
+
height,
|
|
101113
|
+
color
|
|
101114
|
+
});
|
|
101115
|
+
}
|
|
101116
|
+
if (!schema.borderColor || !hasBoxDimension(schema.borderWidth)) return;
|
|
101117
|
+
const color = hex2PrintingColor(schema.borderColor, colorType);
|
|
101118
|
+
if (!color) return;
|
|
101119
|
+
const top = mm2pt(borderWidth.top);
|
|
101120
|
+
const right = mm2pt(borderWidth.right);
|
|
101121
|
+
const bottom = mm2pt(borderWidth.bottom);
|
|
101122
|
+
const left = mm2pt(borderWidth.left);
|
|
101123
|
+
drawRectangle({
|
|
101124
|
+
x,
|
|
101125
|
+
y: y + height - top,
|
|
101126
|
+
width,
|
|
101127
|
+
height: top,
|
|
101128
|
+
color
|
|
101129
|
+
});
|
|
101130
|
+
drawRectangle({
|
|
101131
|
+
x: x + width - right,
|
|
101132
|
+
y,
|
|
101133
|
+
width: right,
|
|
101134
|
+
height,
|
|
101135
|
+
color
|
|
101136
|
+
});
|
|
101137
|
+
drawRectangle({
|
|
101138
|
+
x,
|
|
101139
|
+
y,
|
|
101140
|
+
width,
|
|
101141
|
+
height: bottom,
|
|
101142
|
+
color
|
|
101143
|
+
});
|
|
101144
|
+
drawRectangle({
|
|
101145
|
+
x,
|
|
101146
|
+
y,
|
|
101147
|
+
width: left,
|
|
101148
|
+
height,
|
|
101149
|
+
color
|
|
101150
|
+
});
|
|
101151
|
+
};
|
|
100983
101152
|
var TextStrikethroughIcon = createSvgStr(Strikethrough);
|
|
100984
101153
|
var TextUnderlineIcon = createSvgStr(Underline);
|
|
100985
101154
|
var TextAlignLeftIcon = createSvgStr(TextAlignStart);
|
|
@@ -101242,6 +101411,30 @@ var propPanel = {
|
|
|
101242
101411
|
message: i18n("validation.hexColor")
|
|
101243
101412
|
}]
|
|
101244
101413
|
},
|
|
101414
|
+
borderColor: {
|
|
101415
|
+
title: i18n("schemas.borderColor"),
|
|
101416
|
+
type: "string",
|
|
101417
|
+
widget: "color",
|
|
101418
|
+
props: { disabledAlpha: true },
|
|
101419
|
+
rules: [{
|
|
101420
|
+
pattern: HEX_COLOR_PATTERN,
|
|
101421
|
+
message: i18n("validation.hexColor")
|
|
101422
|
+
}]
|
|
101423
|
+
},
|
|
101424
|
+
borderWidth: {
|
|
101425
|
+
title: i18n("schemas.borderWidth"),
|
|
101426
|
+
type: "object",
|
|
101427
|
+
widget: "lineTitle",
|
|
101428
|
+
span: 24,
|
|
101429
|
+
properties: getBoxDimensionPropPanelSchema(.1)
|
|
101430
|
+
},
|
|
101431
|
+
padding: {
|
|
101432
|
+
title: i18n("schemas.padding"),
|
|
101433
|
+
type: "object",
|
|
101434
|
+
widget: "lineTitle",
|
|
101435
|
+
span: 24,
|
|
101436
|
+
properties: getBoxDimensionPropPanelSchema()
|
|
101437
|
+
},
|
|
101245
101438
|
useInlineMarkdown: {
|
|
101246
101439
|
type: "boolean",
|
|
101247
101440
|
widget: "UseInlineMarkdown",
|
|
@@ -101333,6 +101526,9 @@ var propPanel = {
|
|
|
101333
101526
|
fontColor: DEFAULT_FONT_COLOR,
|
|
101334
101527
|
fontName: void 0,
|
|
101335
101528
|
backgroundColor: "",
|
|
101529
|
+
borderColor: "#000000",
|
|
101530
|
+
borderWidth: createBoxDimension(0),
|
|
101531
|
+
padding: createBoxDimension(0),
|
|
101336
101532
|
opacity: 1,
|
|
101337
101533
|
strikethrough: false,
|
|
101338
101534
|
underline: false
|
|
@@ -101469,7 +101665,7 @@ var renderInlineMarkdownReadOnly = async (arg) => {
|
|
|
101469
101665
|
runs,
|
|
101470
101666
|
fontSize: schema.fontSize ?? 13,
|
|
101471
101667
|
characterSpacing: schema.characterSpacing ?? 0,
|
|
101472
|
-
boxWidthInPt: mm2pt(schema.width)
|
|
101668
|
+
boxWidthInPt: mm2pt(getBoxContentArea(schema).width)
|
|
101473
101669
|
}), lineRange);
|
|
101474
101670
|
textBlock.innerHTML = "";
|
|
101475
101671
|
lines.forEach((line, lineIndex) => {
|
|
@@ -101536,7 +101732,7 @@ var getRangedPlainTextValue = (arg) => {
|
|
|
101536
101732
|
characterSpacing: schema.characterSpacing ?? 0,
|
|
101537
101733
|
fontSize,
|
|
101538
101734
|
fontKitFont,
|
|
101539
|
-
boxWidthInPt: mm2pt(schema.width)
|
|
101735
|
+
boxWidthInPt: mm2pt(getBoxContentArea(schema).width)
|
|
101540
101736
|
}), lineRange));
|
|
101541
101737
|
};
|
|
101542
101738
|
var buildStyledTextContainer = (arg, fontKitFont, value, resolvedDynamicFontSize) => {
|
|
@@ -101551,15 +101747,29 @@ var buildStyledTextContainer = (arg, fontKitFont, value, resolvedDynamicFontSize
|
|
|
101551
101747
|
const { topAdj, bottomAdj } = getBrowserVerticalFontAdjustments(fontKitFont, dynamicFontSize ?? schema.fontSize ?? 13, schema.lineHeight ?? 1, schema.verticalAlignment ?? "top");
|
|
101552
101748
|
const topAdjustment = topAdj.toString();
|
|
101553
101749
|
const bottomAdjustment = bottomAdj.toString();
|
|
101750
|
+
const verticalAlignment = schema.verticalAlignment ?? "top";
|
|
101751
|
+
const isTopAligned = verticalAlignment === "top";
|
|
101554
101752
|
const container = document.createElement("div");
|
|
101753
|
+
const { borderWidth, padding } = getBoxInsets(schema);
|
|
101754
|
+
const hasPadding = hasBoxDimension(schema.padding);
|
|
101755
|
+
const hasBorder = Boolean(schema.borderColor && hasBoxDimension(schema.borderWidth));
|
|
101555
101756
|
const containerStyle = {
|
|
101556
|
-
padding: 0,
|
|
101757
|
+
padding: hasPadding ? `${padding.top}mm ${padding.right}mm ${padding.bottom}mm ${padding.left}mm` : 0,
|
|
101557
101758
|
resize: "none",
|
|
101558
|
-
backgroundColor: getBackgroundColor(
|
|
101559
|
-
border: "none",
|
|
101759
|
+
backgroundColor: getBackgroundColor(schema),
|
|
101760
|
+
border: hasBorder ? void 0 : "none",
|
|
101761
|
+
...hasBorder ? {
|
|
101762
|
+
borderTopWidth: `${borderWidth.top}mm`,
|
|
101763
|
+
borderRightWidth: `${borderWidth.right}mm`,
|
|
101764
|
+
borderBottomWidth: `${borderWidth.bottom}mm`,
|
|
101765
|
+
borderLeftWidth: `${borderWidth.left}mm`,
|
|
101766
|
+
borderStyle: "solid",
|
|
101767
|
+
borderColor: schema.borderColor
|
|
101768
|
+
} : {},
|
|
101769
|
+
...hasPadding || hasBorder ? { boxSizing: "border-box" } : {},
|
|
101560
101770
|
display: "flex",
|
|
101561
101771
|
flexDirection: "column",
|
|
101562
|
-
justifyContent: mapVerticalAlignToFlex(
|
|
101772
|
+
justifyContent: mapVerticalAlignToFlex(verticalAlignment),
|
|
101563
101773
|
width: "100%",
|
|
101564
101774
|
height: "100%",
|
|
101565
101775
|
cursor: isEditable(mode, schema) ? "text" : "default"
|
|
@@ -101586,7 +101796,7 @@ var buildStyledTextContainer = (arg, fontKitFont, value, resolvedDynamicFontSize
|
|
|
101586
101796
|
paddingTop: `${topAdjustment}px`,
|
|
101587
101797
|
backgroundColor: "transparent",
|
|
101588
101798
|
textDecoration: textDecorations.join(" "),
|
|
101589
|
-
height: "100%"
|
|
101799
|
+
...isTopAligned ? { height: "100%" } : {}
|
|
101590
101800
|
};
|
|
101591
101801
|
const textBlock = document.createElement("div");
|
|
101592
101802
|
textBlock.id = "text-" + String(schema.id);
|
|
@@ -101628,8 +101838,8 @@ var mapVerticalAlignToFlex = (verticalAlignmentValue) => {
|
|
|
101628
101838
|
}
|
|
101629
101839
|
return "flex-start";
|
|
101630
101840
|
};
|
|
101631
|
-
var getBackgroundColor = (
|
|
101632
|
-
if (!
|
|
101841
|
+
var getBackgroundColor = (schema) => {
|
|
101842
|
+
if (!schema.backgroundColor) return "transparent";
|
|
101633
101843
|
return schema.backgroundColor;
|
|
101634
101844
|
};
|
|
101635
101845
|
var builtInPlugins = { Text: {
|
|
@@ -213697,7 +213907,7 @@ withProvider(FormCore, { Html: html });
|
|
|
213697
213907
|
//#region ../../node_modules/form-render/es/index.js
|
|
213698
213908
|
var es_default = withProvider(FormCore, widgets_exports);
|
|
213699
213909
|
//#endregion
|
|
213700
|
-
//#region ../schemas/dist/helper-
|
|
213910
|
+
//#region ../schemas/dist/helper-CEme39Uo.js
|
|
213701
213911
|
var substituteVariables = (text, variablesIn, valueMapper = (value) => value) => {
|
|
213702
213912
|
if (!text) return "";
|
|
213703
213913
|
let substitutedText = text;
|
|
@@ -213733,7 +213943,7 @@ var validateVariables = (value, schema) => {
|
|
|
213733
213943
|
return true;
|
|
213734
213944
|
};
|
|
213735
213945
|
//#endregion
|
|
213736
|
-
//#region ../schemas/dist/dynamicTemplate-
|
|
213946
|
+
//#region ../schemas/dist/dynamicTemplate-C7MdZxPm.js
|
|
213737
213947
|
var getDynamicLayoutForMultiVariableText = async (value, args) => {
|
|
213738
213948
|
if (args.schema.type !== "multiVariableText") return { heights: [args.schema.height] };
|
|
213739
213949
|
const schema = args.schema;
|
|
@@ -213750,17 +213960,22 @@ var getDynamicLayoutForMultiVariableText = async (value, args) => {
|
|
|
213750
213960
|
_cache: args._cache,
|
|
213751
213961
|
ignoreDynamicFontSize: true
|
|
213752
213962
|
});
|
|
213753
|
-
const
|
|
213963
|
+
const heights = getTextLineHeightsWithBox(lineHeights, schema);
|
|
213964
|
+
const measuredHeight = sumLineHeights(heights);
|
|
213754
213965
|
if (measuredHeight <= schema.height || lineHeights.length === 0) return {
|
|
213755
213966
|
heights: [schema.height],
|
|
213756
213967
|
patchSplitSchema: () => ({ dynamicFontSize: void 0 })
|
|
213757
213968
|
};
|
|
213758
213969
|
return {
|
|
213759
|
-
heights: lineHeights.length === 1 ? [Math.max(schema.height, measuredHeight)] :
|
|
213970
|
+
heights: lineHeights.length === 1 ? [Math.max(schema.height, measuredHeight)] : heights,
|
|
213760
213971
|
patchSplitSchema: ({ start, end, isSplit }) => ({
|
|
213761
213972
|
dynamicFontSize: void 0,
|
|
213762
213973
|
__splitRange: lineHeights.length === 1 ? void 0 : createTextLineSplitRange(start, end),
|
|
213763
|
-
__isSplit: isSplit
|
|
213974
|
+
__isSplit: isSplit,
|
|
213975
|
+
...getTextSplitBoxStyle(schema, {
|
|
213976
|
+
start,
|
|
213977
|
+
end
|
|
213978
|
+
}, lineHeights.length)
|
|
213764
213979
|
})
|
|
213765
213980
|
};
|
|
213766
213981
|
};
|
|
@@ -213775,17 +213990,22 @@ var getDynamicLayoutForText = async (value, args) => {
|
|
|
213775
213990
|
_cache: args._cache,
|
|
213776
213991
|
ignoreDynamicFontSize: true
|
|
213777
213992
|
});
|
|
213778
|
-
const
|
|
213993
|
+
const heights = getTextLineHeightsWithBox(lineHeights, schema);
|
|
213994
|
+
const measuredHeight = sumLineHeights(heights);
|
|
213779
213995
|
if (measuredHeight <= schema.height || lineHeights.length === 0) return {
|
|
213780
213996
|
heights: [schema.height],
|
|
213781
213997
|
patchSplitSchema: () => ({ dynamicFontSize: void 0 })
|
|
213782
213998
|
};
|
|
213783
213999
|
return {
|
|
213784
|
-
heights: lineHeights.length === 1 ? [Math.max(schema.height, measuredHeight)] :
|
|
214000
|
+
heights: lineHeights.length === 1 ? [Math.max(schema.height, measuredHeight)] : heights,
|
|
213785
214001
|
patchSplitSchema: ({ start, end, isSplit }) => ({
|
|
213786
214002
|
dynamicFontSize: void 0,
|
|
213787
214003
|
__splitRange: lineHeights.length === 1 ? void 0 : createTextLineSplitRange(start, end),
|
|
213788
|
-
__isSplit: isSplit
|
|
214004
|
+
__isSplit: isSplit,
|
|
214005
|
+
...getTextSplitBoxStyle(schema, {
|
|
214006
|
+
start,
|
|
214007
|
+
end
|
|
214008
|
+
}, lineHeights.length)
|
|
213789
214009
|
})
|
|
213790
214010
|
};
|
|
213791
214011
|
};
|
|
@@ -235755,7 +235975,7 @@ var Designer = class extends BaseUIClass {
|
|
|
235755
235975
|
}
|
|
235756
235976
|
};
|
|
235757
235977
|
//#endregion
|
|
235758
|
-
//#region ../schemas/dist/dynamicTemplate-
|
|
235978
|
+
//#region ../schemas/dist/dynamicTemplate-BwzF9C1L.js
|
|
235759
235979
|
var normalizeListItems = (value) => {
|
|
235760
235980
|
if (Array.isArray(value)) return value.map((item) => String(item));
|
|
235761
235981
|
if (typeof value !== "string") return value == null ? [] : [String(value)];
|