@pdfme/ui 6.1.1-dev.8 → 6.1.2

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 CHANGED
@@ -45683,7 +45683,7 @@ function parseExpressionAt(input, pos, options) {
45683
45683
  }
45684
45684
  //#endregion
45685
45685
  //#region ../common/dist/index.js
45686
- var PDFME_VERSION = "6.1.1";
45686
+ var PDFME_VERSION = "6.1.2";
45687
45687
  var PAGE_SIZE_PRESETS = {
45688
45688
  A3: {
45689
45689
  width: 297,
@@ -45859,6 +45859,11 @@ object$1({
45859
45859
  height: number$1(),
45860
45860
  width: number$1()
45861
45861
  });
45862
+ var DynamicLayoutSplitRange = object$1({
45863
+ unit: string$1().min(1),
45864
+ start: number$1(),
45865
+ end: number$1().optional()
45866
+ });
45862
45867
  var Schema$1 = object$1({
45863
45868
  name: string$1(),
45864
45869
  type: string$1(),
@@ -45873,18 +45878,7 @@ var Schema$1 = object$1({
45873
45878
  opacity: number$1().optional(),
45874
45879
  readOnly: boolean$1().optional(),
45875
45880
  required: boolean$1().optional(),
45876
- __bodyRange: object$1({
45877
- start: number$1(),
45878
- end: number$1().optional()
45879
- }).optional(),
45880
- __itemRange: object$1({
45881
- start: number$1(),
45882
- end: number$1().optional()
45883
- }).optional(),
45884
- __textLineRange: object$1({
45885
- start: number$1(),
45886
- end: number$1().optional()
45887
- }).optional(),
45881
+ __splitRange: DynamicLayoutSplitRange.optional(),
45888
45882
  __isSplit: boolean$1().optional()
45889
45883
  }).passthrough();
45890
45884
  var SchemaForUIAdditionalInfo = object$1({ id: string$1() });
@@ -46708,6 +46702,19 @@ var getDynamicTemplate = async (arg) => {
46708
46702
  schemas: resultPages
46709
46703
  };
46710
46704
  };
46705
+ var createDynamicLayoutSplitRange = (unit, start, end) => ({
46706
+ unit,
46707
+ start,
46708
+ ...end === void 0 ? {} : { end }
46709
+ });
46710
+ var getDynamicLayoutSplitRange = (schema, unit) => {
46711
+ const range = schema.__splitRange;
46712
+ if (range?.unit !== unit) return void 0;
46713
+ return {
46714
+ start: range.start,
46715
+ ...range.end === void 0 ? {} : { end: range.end }
46716
+ };
46717
+ };
46711
46718
  /**
46712
46719
  * Wraps plugins collection with utility methods
46713
46720
  */
@@ -98629,7 +98636,7 @@ $d636bc798e7178db$export$36b2f24e97d43be($21ee218f84ac7f32$export$2e2bcd8739ae03
98629
98636
  $d636bc798e7178db$export$36b2f24e97d43be($cd5853a56c68fec7$export$2e2bcd8739ae039);
98630
98637
  $d636bc798e7178db$export$36b2f24e97d43be($05f49f930186144e$export$2e2bcd8739ae039);
98631
98638
  //#endregion
98632
- //#region ../schemas/dist/helper-CBd9plP_.js
98639
+ //#region ../schemas/dist/splitRange-DmVDtmzO.js
98633
98640
  var ALIGN_LEFT = "left";
98634
98641
  var ALIGN_CENTER = "center";
98635
98642
  var ALIGN_RIGHT = "right";
@@ -98723,6 +98730,84 @@ var LINE_END_FORBIDDEN_CHARS = [
98723
98730
  "⦅",
98724
98731
  "«"
98725
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
+ };
98726
98811
  var getBrowserVerticalFontAdjustments = (fontKitFont, fontSize, lineHeight, verticalAlignment) => {
98727
98812
  const { ascent, descent, unitsPerEm } = fontKitFont;
98728
98813
  const fontBaseLineHeight = (ascent - descent) / unitsPerEm;
@@ -98810,7 +98895,8 @@ var getFontKitFont = async (fontName, font, _cache) => {
98810
98895
  * the box width based on the proposed size.
98811
98896
  */
98812
98897
  var calculateDynamicFontSize = ({ textSchema, fontKitFont, value, startingFontSize }) => {
98813
- const { fontSize: schemaFontSize, dynamicFontSize: dynamicFontSizeSetting, characterSpacing: schemaCharacterSpacing, width: boxWidth, height: boxHeight, lineHeight = 1 } = textSchema;
98898
+ const { fontSize: schemaFontSize, dynamicFontSize: dynamicFontSizeSetting, characterSpacing: schemaCharacterSpacing, lineHeight = 1 } = textSchema;
98899
+ const { width: boxWidth, height: boxHeight } = getBoxContentArea(textSchema);
98814
98900
  const fontSize = startingFontSize || schemaFontSize || 13;
98815
98901
  if (!dynamicFontSizeSetting) return fontSize;
98816
98902
  if (dynamicFontSizeSetting.max < dynamicFontSizeSetting.min) return fontSize;
@@ -99002,8 +99088,21 @@ var filterEndJP = (lines) => {
99002
99088
  return [...filtered.slice(0, -1), combinedItem];
99003
99089
  } else return filtered;
99004
99090
  };
99005
- //#endregion
99006
- //#region ../schemas/dist/measure-h-7PUE2B.js
99091
+ var BUILT_IN_DYNAMIC_LAYOUT_SPLIT_UNITS = {
99092
+ tableBody: "tableBody",
99093
+ listItem: "listItem",
99094
+ textLine: "textLine"
99095
+ };
99096
+ var TABLE_BODY_SPLIT_UNIT = BUILT_IN_DYNAMIC_LAYOUT_SPLIT_UNITS.tableBody;
99097
+ var LIST_ITEM_SPLIT_UNIT = BUILT_IN_DYNAMIC_LAYOUT_SPLIT_UNITS.listItem;
99098
+ var TEXT_LINE_SPLIT_UNIT = BUILT_IN_DYNAMIC_LAYOUT_SPLIT_UNITS.textLine;
99099
+ var createTableBodySplitRange = (start, end) => createDynamicLayoutSplitRange(TABLE_BODY_SPLIT_UNIT, start, end);
99100
+ var createListItemSplitRange = (start, end) => createDynamicLayoutSplitRange(LIST_ITEM_SPLIT_UNIT, start, end);
99101
+ var createTextLineSplitRange = (start, end) => createDynamicLayoutSplitRange(TEXT_LINE_SPLIT_UNIT, start, end);
99102
+ var getTableBodyRange = (schema) => getDynamicLayoutSplitRange(schema, TABLE_BODY_SPLIT_UNIT);
99103
+ var getTextLineRange = (schema) => getDynamicLayoutSplitRange(schema, TEXT_LINE_SPLIT_UNIT);
99104
+ //#endregion
99105
+ //#region ../schemas/dist/measure-L5diay3k.js
99007
99106
  var MARKDOWN_ESCAPABLE_CHARS = new Set([
99008
99107
  "\\",
99009
99108
  "*",
@@ -99242,7 +99341,7 @@ var resolveRichTextRuns = async (arg) => {
99242
99341
  var measureRunText = (run, text, fontSize, characterSpacing) => {
99243
99342
  const syntheticBoldWidth = run.syntheticBold ? fontSize * SYNTHETIC_BOLD_OFFSET_RATIO * 2 : 0;
99244
99343
  const syntheticItalicWidth = run.syntheticItalic ? heightOfFontAtSize(run.fontKitFont, fontSize) * Math.tan(12 * Math.PI / 180) : 0;
99245
- 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);
99246
99345
  };
99247
99346
  var createLine = () => ({
99248
99347
  runs: [],
@@ -99252,6 +99351,14 @@ var createLine = () => ({
99252
99351
  var pushRunToLine = (line, run, text, fontSize, characterSpacing) => {
99253
99352
  if (!text) return;
99254
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
+ }
99255
99362
  if (line.runs.length > 0) line.width += characterSpacing;
99256
99363
  line.runs.push({
99257
99364
  ...run,
@@ -99260,6 +99367,7 @@ var pushRunToLine = (line, run, text, fontSize, characterSpacing) => {
99260
99367
  });
99261
99368
  line.width += width;
99262
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;
99263
99371
  var measurePiecesWidth = (pieces, fontSize, characterSpacing) => {
99264
99372
  let width = 0;
99265
99373
  let hasText = false;
@@ -99415,7 +99523,8 @@ var getLineHeightAtSize = (line, fontSize) => {
99415
99523
  };
99416
99524
  var calculateDynamicRichTextFontSize = async (arg) => {
99417
99525
  const { value, schema, font, _cache, startingFontSize } = arg;
99418
- const { fontSize: schemaFontSize, dynamicFontSize: dynamicFontSizeSetting, characterSpacing: schemaCharacterSpacing, width: boxWidth, height: boxHeight, lineHeight = 1 } = schema;
99526
+ const { fontSize: schemaFontSize, dynamicFontSize: dynamicFontSizeSetting, characterSpacing: schemaCharacterSpacing, lineHeight = 1 } = schema;
99527
+ const { width: boxWidth, height: boxHeight } = getBoxContentArea(schema);
99419
99528
  const fontSize = startingFontSize || schemaFontSize || 13;
99420
99529
  if (!dynamicFontSizeSetting) return fontSize;
99421
99530
  if (dynamicFontSizeSetting.max < dynamicFontSizeSetting.min) return fontSize;
@@ -99501,7 +99610,7 @@ var measureTextLines = async ({ value, schema, font = getDefaultFont(), _cache =
99501
99610
  const fontSize = schema.fontSize ?? 13;
99502
99611
  const lineHeight = schema.lineHeight ?? 1;
99503
99612
  const characterSpacing = schema.characterSpacing ?? 0;
99504
- const boxWidthInPt = mm2pt(schema.width);
99613
+ const boxWidthInPt = mm2pt(getBoxContentArea(schema).width);
99505
99614
  if (isInlineMarkdownTextSchema(schema)) {
99506
99615
  const resolvedRuns = await resolveRichTextRuns({
99507
99616
  runs: parseInlineMarkdown(value),
@@ -99545,7 +99654,8 @@ var measureTextLines = async ({ value, schema, font = getDefaultFont(), _cache =
99545
99654
  };
99546
99655
  };
99547
99656
  var mergeTextLineRangeValue = async ({ value, replacement, schema, font = getDefaultFont(), _cache = /* @__PURE__ */ new Map() }) => {
99548
- if (!schema.__textLineRange) return replacement;
99657
+ const range = getTextLineRange(schema);
99658
+ if (!range) return replacement;
99549
99659
  const { lines } = await measureTextLines({
99550
99660
  value,
99551
99661
  schema,
@@ -99553,12 +99663,29 @@ var mergeTextLineRangeValue = async ({ value, replacement, schema, font = getDef
99553
99663
  _cache,
99554
99664
  ignoreDynamicFontSize: true
99555
99665
  });
99556
- const { start, end = lines.length } = schema.__textLineRange;
99666
+ const { start, end = lines.length } = range;
99557
99667
  const nextLines = [...lines];
99558
99668
  nextLines.splice(start, end - start, ...splitReplacementTextToLines(replacement));
99559
99669
  return plainTextLinesToValue(nextLines);
99560
99670
  };
99561
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
+ };
99562
99689
  var measurePlainTextLineHeights = (lines, fontKitFont, fontSize, lineHeight) => {
99563
99690
  if (lines.length === 0) return [];
99564
99691
  const firstLineHeight = heightOfFontAtSize(fontKitFont, fontSize) * lineHeight;
@@ -99574,7 +99701,7 @@ var getRichTextLineHeight = (line, fontSize) => {
99574
99701
  return Math.max(...line.runs.map((run) => heightOfFontAtSize(run.fontKitFont, fontSize)));
99575
99702
  };
99576
99703
  //#endregion
99577
- //#region ../schemas/dist/dynamicTemplate-CkrZKlg-.js
99704
+ //#region ../schemas/dist/dynamicTemplate-B4GCNLF9.js
99578
99705
  function _typeof$18(o) {
99579
99706
  "@babel/helpers - typeof";
99580
99707
  return _typeof$18 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -100043,7 +100170,7 @@ function createSingleTable(body, args) {
100043
100170
  const { options, _cache, basePdf } = args;
100044
100171
  if (!isBlankPdf(basePdf)) console.warn("[@pdfme/schema/table]When specifying a custom PDF for basePdf, you cannot use features such as page breaks or re-layout of other elements.To utilize these features, please define basePdf as follows:\n{ width: number; height: number; padding: [number, number, number, number]; }");
100045
100172
  const schema = cloneDeep$1(args.schema);
100046
- const { start } = schema.__bodyRange || { start: 0 };
100173
+ const { start } = getTableBodyRange(schema) || { start: 0 };
100047
100174
  if (start % 2 === 1) {
100048
100175
  const alternateBackgroundColor = schema.bodyStyles.alternateBackgroundColor;
100049
100176
  schema.bodyStyles.alternateBackgroundColor = schema.bodyStyles.backgroundColor;
@@ -100073,7 +100200,8 @@ var getBodyWithRange = (value, range) => {
100073
100200
  var getDynamicHeightsForTable = async (value, args) => {
100074
100201
  if (args.schema.type !== "table") return Promise.resolve([args.schema.height]);
100075
100202
  const schema = args.schema;
100076
- const table = await createSingleTable(schema.__bodyRange?.start === 0 ? getBody$1(value) : getBodyWithRange(value, schema.__bodyRange), args);
100203
+ const bodyRange = getTableBodyRange(schema);
100204
+ const table = await createSingleTable(bodyRange?.start === 0 ? getBody$1(value) : getBodyWithRange(value, bodyRange), args);
100077
100205
  const baseHeights = schema.showHead ? table.allRows().map((row) => row.height) : [0].concat(table.body.map((row) => row.height));
100078
100206
  const headerHeight = schema.showHead ? table.getHeadHeight() : 0;
100079
100207
  if (!(schema.repeatHead && isBlankPdf(args.basePdf) && headerHeight > 0)) return baseHeights;
@@ -100124,17 +100252,20 @@ var getDynamicLayoutForTable = async (value, args) => {
100124
100252
  return {
100125
100253
  heights: await getDynamicHeightsForTable(value, args),
100126
100254
  avoidFirstUnitOnly: true,
100127
- patchSplitSchema: ({ start, end, isSplit }) => ({
100128
- __bodyRange: {
100255
+ patchSplitSchema: ({ start, end, isSplit }) => {
100256
+ const range = {
100129
100257
  start: start === 0 ? 0 : start - 1,
100130
100258
  end: end - 1
100131
- },
100132
- __isSplit: isSplit
100133
- })
100259
+ };
100260
+ return {
100261
+ __splitRange: createTableBodySplitRange(range.start, range.end),
100262
+ __isSplit: isSplit
100263
+ };
100264
+ }
100134
100265
  };
100135
100266
  };
100136
100267
  //#endregion
100137
- //#region ../schemas/dist/utils.js
100268
+ //#region ../schemas/dist/utils-zDZkqBnX.js
100138
100269
  var convertForPdfLayoutProps = ({ schema, pageHeight, applyRotateTranslate = true }) => {
100139
100270
  const { width: mmWidth, height: mmHeight, position, rotate, opacity } = schema;
100140
100271
  const { x: mmX, y: mmY } = position;
@@ -100424,7 +100555,7 @@ var Underline = [["path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }], ["line", {
100424
100555
  y2: "20"
100425
100556
  }]];
100426
100557
  //#endregion
100427
- //#region ../schemas/dist/builtins-pN5NVCSV.js
100558
+ //#region ../schemas/dist/builtins-BB2DHceW.js
100428
100559
  var addUriLinkAnnotation = (arg) => {
100429
100560
  const { pdfDoc, page, uri, rect, borderWidth = 0 } = arg;
100430
100561
  const safeUri = normalizeSafeLinkUri(uri);
@@ -100453,7 +100584,7 @@ var addUriLinkAnnotation = (arg) => {
100453
100584
  };
100454
100585
  var getSyntheticBoldWidth = (run, fontSize) => run.syntheticBold ? fontSize * SYNTHETIC_BOLD_OFFSET_RATIO * 2 : 0;
100455
100586
  var getSyntheticItalicWidth = (run, fontSize) => run.syntheticItalic ? heightOfFontAtSize(run.fontKitFont, fontSize) * Math.tan(12 * Math.PI / 180) : 0;
100456
- 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);
100457
100588
  var getPdfFontFromObj = (run, pdfFontObj) => {
100458
100589
  const pdfFont = pdfFontObj[run.fontName];
100459
100590
  if (!pdfFont) throw new Error(`[@pdfme/schemas] Missing embedded font "${run.fontName}".`);
@@ -100534,10 +100665,12 @@ var getLinkAnnotationRect = (arg) => {
100534
100665
  var drawRun = (arg) => {
100535
100666
  const { page, pdfLib, run, pdfFont, x, y, rotate, pivotPoint, fontSize, lineHeight, color, opacity, colorType, characterSpacing, strikethrough, underline } = arg;
100536
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;
100537
100671
  const textHeight = heightOfFontAtSize(run.fontKitFont, fontSize);
100538
100672
  if (run.code) {
100539
- const padding = CODE_HORIZONTAL_PADDING;
100540
- const bgX = x - padding;
100673
+ const bgX = x;
100541
100674
  const bgY = y - textHeight * .2;
100542
100675
  const bgPoint = rotate.angle === 0 ? {
100543
100676
  x: bgX,
@@ -100549,7 +100682,7 @@ var drawRun = (arg) => {
100549
100682
  page.drawRectangle({
100550
100683
  x: bgPoint.x,
100551
100684
  y: bgPoint.y,
100552
- width: runWidth + padding * 2,
100685
+ width: runWidth,
100553
100686
  height: textHeight * 1.2,
100554
100687
  rotate,
100555
100688
  color: hex2PrintingColor(CODE_BACKGROUND_COLOR, colorType),
@@ -100558,9 +100691,9 @@ var drawRun = (arg) => {
100558
100691
  }
100559
100692
  if (strikethrough && runWidth > 0) drawDecorationLine({
100560
100693
  page,
100561
- x,
100694
+ x: textX,
100562
100695
  y: y + textHeight / 3,
100563
- width: runWidth,
100696
+ width: textWidth,
100564
100697
  rotate,
100565
100698
  pivotPoint,
100566
100699
  fontSize,
@@ -100569,9 +100702,9 @@ var drawRun = (arg) => {
100569
100702
  });
100570
100703
  if (underline && runWidth > 0) drawDecorationLine({
100571
100704
  page,
100572
- x,
100705
+ x: textX,
100573
100706
  y: y - textHeight / 12,
100574
- width: runWidth,
100707
+ width: textWidth,
100575
100708
  rotate,
100576
100709
  pivotPoint,
100577
100710
  fontSize,
@@ -100598,14 +100731,14 @@ var drawRun = (arg) => {
100598
100731
  ...run.syntheticItalic ? { ySkew: pdfLib.degrees(12) } : {}
100599
100732
  });
100600
100733
  };
100601
- drawAt(x);
100734
+ drawAt(textX);
100602
100735
  if (run.syntheticBold) {
100603
100736
  const offset = fontSize * SYNTHETIC_BOLD_OFFSET_RATIO;
100604
- for (let i = 1; i <= 2; i++) drawAt(x + offset * i);
100737
+ for (let i = 1; i <= 2; i++) drawAt(textX + offset * i);
100605
100738
  }
100606
100739
  };
100607
100740
  var renderInlineMarkdownText = async (arg) => {
100608
- const { value, schema, font, embedPdfFont, fontKitFont, pdfDoc, page, pdfLib, _cache, colorType, fontSize, color, alignment, verticalAlignment, lineHeight, characterSpacing, x, width, height, pageHeight, pivotPoint, rotate, opacity } = arg;
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;
100609
100742
  const allLines = layoutRichTextLines({
100610
100743
  runs: await resolveRichTextRuns({
100611
100744
  runs: parseInlineMarkdown(value),
@@ -100617,8 +100750,9 @@ var renderInlineMarkdownText = async (arg) => {
100617
100750
  characterSpacing,
100618
100751
  boxWidthInPt: width
100619
100752
  });
100620
- const lines = applyTextLineRange(allLines, schema.__textLineRange);
100621
- const lineRangeStart = schema.__textLineRange?.start ?? 0;
100753
+ const lineRange = getTextLineRange(schema);
100754
+ const lines = applyTextLineRange(allLines, lineRange);
100755
+ const lineRangeStart = lineRange?.start ?? 0;
100622
100756
  const pdfFontObj = await embedFontsForRuns(lines.flatMap((line) => line.runs), embedPdfFont);
100623
100757
  const firstLineTextHeight = heightOfFontAtSize(fontKitFont, fontSize);
100624
100758
  const descent = getFontDescentInPt(fontKitFont, fontSize);
@@ -100644,7 +100778,7 @@ var renderInlineMarkdownText = async (arg) => {
100644
100778
  let xLine = x;
100645
100779
  if (alignment === "center") xLine += (width - textWidth) / 2;
100646
100780
  else if (alignment === "right") xLine += width - textWidth;
100647
- const yLine = pageHeight - mm2pt(schema.position.y) - yOffset - lineHeight * fontSize * rowIndex;
100781
+ const yLine = y + height - yOffset - lineHeight * fontSize * rowIndex;
100648
100782
  page.pushOperators(pdfLib.setCharacterSpacing(spacing));
100649
100783
  if (schema.strikethrough || schema.underline) {
100650
100784
  const textHeight = Math.max(...line.runs.map((run) => heightOfFontAtSize(run.fontKitFont, fontSize)));
@@ -100719,8 +100853,11 @@ var renderInlineMarkdownText = async (arg) => {
100719
100853
  }, xLine);
100720
100854
  });
100721
100855
  };
100722
- var isTextOverflowExpand = (schema) => schema.overflow === TEXT_OVERFLOW_EXPAND;
100723
- var shouldUseDynamicFontSize = (schema) => Boolean(schema.dynamicFontSize) && !isTextOverflowExpand(schema);
100856
+ var TEXT_OVERFLOW_EXPAND_SCHEMA_TYPES$1 = new Set(["text", "multiVariableText"]);
100857
+ var isTextOverflowExpandSchema = (schema) => schema.type === void 0 || TEXT_OVERFLOW_EXPAND_SCHEMA_TYPES$1.has(schema.type);
100858
+ var canUseTextOverflowExpand = (schema, basePdf) => !isTextOverflowExpandSchema(schema) || basePdf === void 0 || isBlankPdf(basePdf);
100859
+ var isTextOverflowExpand = (schema, basePdf) => canUseTextOverflowExpand(schema, basePdf) && schema.overflow === "expand";
100860
+ var shouldUseDynamicFontSize = (schema, basePdf) => Boolean(schema.dynamicFontSize) && !isTextOverflowExpand(schema, basePdf);
100724
100861
  var PDF_FONT_CACHE_KEY = "text-pdf-font-cache";
100725
100862
  var getPdfFontCache = (_cache) => {
100726
100863
  let pdfFontCache = _cache.get(PDF_FONT_CACHE_KEY);
@@ -100745,8 +100882,8 @@ var embedAndGetFont = (arg) => {
100745
100882
  pdfFontCache[fontName] = pdfFontPromise;
100746
100883
  return pdfFontPromise;
100747
100884
  };
100748
- var getFontProp = ({ value, fontKitFont, schema, colorType, fontSize: resolvedFontSize }) => {
100749
- const fontSize = resolvedFontSize ?? (shouldUseDynamicFontSize(schema) ? calculateDynamicFontSize({
100885
+ var getFontProp = ({ value, fontKitFont, schema, basePdf, colorType, fontSize: resolvedFontSize }) => {
100886
+ const fontSize = resolvedFontSize ?? (shouldUseDynamicFontSize(schema, basePdf) ? calculateDynamicFontSize({
100750
100887
  textSchema: schema,
100751
100888
  fontKitFont,
100752
100889
  value
@@ -100767,11 +100904,37 @@ var getGraphemeSegmenter = () => {
100767
100904
  return graphemeSegmenter;
100768
100905
  };
100769
100906
  var pdfRender = async (arg) => {
100770
- const { value, pdfDoc, pdfLib, page, options, schema, _cache } = arg;
100771
- if (!value) return;
100907
+ const { value, pdfDoc, pdfLib, page, options, schema, basePdf, _cache } = arg;
100772
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;
100773
100931
  const fontName = schema.fontName ? schema.fontName : getFallbackFontName(font);
100774
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);
100775
100938
  const pdfFontValuePromise = enableInlineMarkdown ? void 0 : embedAndGetFont({
100776
100939
  pdfDoc,
100777
100940
  font,
@@ -100783,48 +100946,15 @@ var pdfRender = async (arg) => {
100783
100946
  value: enableInlineMarkdown ? stripInlineMarkdown(value) : value,
100784
100947
  fontKitFont,
100785
100948
  schema,
100949
+ basePdf,
100786
100950
  colorType,
100787
- fontSize: enableInlineMarkdown && shouldUseDynamicFontSize(schema) ? await calculateDynamicRichTextFontSize({
100951
+ fontSize: enableInlineMarkdown && shouldUseDynamicFontSize(schema, basePdf) ? await calculateDynamicRichTextFontSize({
100788
100952
  value,
100789
100953
  schema,
100790
100954
  font,
100791
100955
  _cache
100792
100956
  }) : void 0
100793
100957
  });
100794
- const pageHeight = page.getHeight();
100795
- const { width, height, rotate, position: { x, y }, opacity } = convertForPdfLayoutProps({
100796
- schema,
100797
- pageHeight,
100798
- applyRotateTranslate: false
100799
- });
100800
- const pivotPoint = {
100801
- x: x + width / 2,
100802
- y: pageHeight - mm2pt(schema.position.y) - height / 2
100803
- };
100804
- if (schema.backgroundColor) {
100805
- const color = hex2PrintingColor(schema.backgroundColor, colorType);
100806
- if (rotate.angle !== 0) {
100807
- const rotatedPoint = rotatePoint({
100808
- x,
100809
- y
100810
- }, pivotPoint, rotate.angle);
100811
- page.drawRectangle({
100812
- x: rotatedPoint.x,
100813
- y: rotatedPoint.y,
100814
- width,
100815
- height,
100816
- rotate,
100817
- color
100818
- });
100819
- } else page.drawRectangle({
100820
- x,
100821
- y,
100822
- width,
100823
- height,
100824
- rotate,
100825
- color
100826
- });
100827
- }
100828
100958
  if (enableInlineMarkdown) {
100829
100959
  await renderInlineMarkdownText({
100830
100960
  value,
@@ -100848,10 +100978,10 @@ var pdfRender = async (arg) => {
100848
100978
  verticalAlignment,
100849
100979
  lineHeight,
100850
100980
  characterSpacing,
100851
- x,
100852
- width,
100853
- height,
100854
- pageHeight,
100981
+ x: contentX,
100982
+ y: contentY,
100983
+ width: contentWidth,
100984
+ height: contentHeight,
100855
100985
  pivotPoint,
100856
100986
  rotate,
100857
100987
  opacity
@@ -100868,16 +100998,16 @@ var pdfRender = async (arg) => {
100868
100998
  characterSpacing,
100869
100999
  fontSize,
100870
101000
  fontKitFont,
100871
- boxWidthInPt: width
100872
- }), schema.__textLineRange);
101001
+ boxWidthInPt: contentWidth
101002
+ }), getTextLineRange(schema));
100873
101003
  const needsTextWidth = alignment !== "left" || Boolean(schema.strikethrough || schema.underline);
100874
101004
  const needsTextHeight = Boolean(schema.strikethrough || schema.underline);
100875
101005
  let yOffset = 0;
100876
101006
  if (verticalAlignment === "top") yOffset = firstLineTextHeight + halfLineHeightAdjustment;
100877
101007
  else {
100878
101008
  const otherLinesHeight = lineHeight * fontSize * (lines.length - 1);
100879
- if (verticalAlignment === "bottom") yOffset = height - otherLinesHeight + descent - halfLineHeightAdjustment;
100880
- else if (verticalAlignment === "middle") yOffset = (height - otherLinesHeight - firstLineTextHeight + descent) / 2 + firstLineTextHeight;
101009
+ if (verticalAlignment === "bottom") yOffset = contentHeight - otherLinesHeight + descent - halfLineHeightAdjustment;
101010
+ else if (verticalAlignment === "middle") yOffset = (contentHeight - otherLinesHeight - firstLineTextHeight + descent) / 2 + firstLineTextHeight;
100881
101011
  }
100882
101012
  lines.forEach((line, rowIndex) => {
100883
101013
  const trimmed = line.replace("\n", "");
@@ -100885,10 +101015,10 @@ var pdfRender = async (arg) => {
100885
101015
  const textHeight = needsTextHeight ? heightOfFontAtSize(fontKitFont, fontSize) : 0;
100886
101016
  const rowYOffset = lineHeight * fontSize * rowIndex;
100887
101017
  if (line === "") line = "\r\n";
100888
- let xLine = x;
100889
- if (alignment === "center") xLine += (width - textWidth) / 2;
100890
- else if (alignment === "right") xLine += width - textWidth;
100891
- let yLine = pageHeight - mm2pt(schema.position.y) - yOffset - rowYOffset;
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;
100892
101022
  if (schema.strikethrough && textWidth > 0) {
100893
101023
  const _x = xLine + textWidth + 1;
100894
101024
  const _y = yLine + textHeight / 3;
@@ -100935,7 +101065,7 @@ var pdfRender = async (arg) => {
100935
101065
  if (alignment === "justify" && line.slice(-1) !== "\n") {
100936
101066
  const iterator = getGraphemeSegmenter().segment(trimmed)[Symbol.iterator]();
100937
101067
  const len = Array.from(iterator).length;
100938
- spacing += (width - textWidth) / len;
101068
+ spacing += (contentWidth - textWidth) / len;
100939
101069
  }
100940
101070
  page.pushOperators(pdfLib.setCharacterSpacing(spacing));
100941
101071
  page.drawText(trimmed, {
@@ -100950,6 +101080,75 @@ var pdfRender = async (arg) => {
100950
101080
  });
100951
101081
  });
100952
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
+ };
100953
101152
  var TextStrikethroughIcon = createSvgStr(Strikethrough);
100954
101153
  var TextUnderlineIcon = createSvgStr(Underline);
100955
101154
  var TextAlignLeftIcon = createSvgStr(TextAlignStart);
@@ -101029,8 +101228,8 @@ function getExtraFormatterSchema(i18n) {
101029
101228
  };
101030
101229
  }
101031
101230
  var UseDynamicFontSize = (props) => {
101032
- const { rootElement, changeSchemas, activeSchema, i18n } = props;
101033
- const isExpand = isTextOverflowExpand(activeSchema);
101231
+ const { rootElement, changeSchemas, activeSchema, i18n, basePdf } = props;
101232
+ const isExpand = isTextOverflowExpand(activeSchema, basePdf);
101034
101233
  const checkbox = document.createElement("input");
101035
101234
  checkbox.type = "checkbox";
101036
101235
  checkbox.checked = !isExpand && Boolean(activeSchema?.dynamicFontSize);
@@ -101078,7 +101277,7 @@ var UseInlineMarkdown = (props) => {
101078
101277
  rootElement.appendChild(label);
101079
101278
  };
101080
101279
  var propPanel = {
101081
- schema: ({ options, activeSchema, i18n }) => {
101280
+ schema: ({ options, activeSchema, i18n, basePdf }) => {
101082
101281
  const font = options.font || { ["Roboto"]: {
101083
101282
  data: "",
101084
101283
  fallback: true
@@ -101086,7 +101285,8 @@ var propPanel = {
101086
101285
  const fontNames = Object.keys(font);
101087
101286
  const fallbackFontName = getFallbackFontName(font);
101088
101287
  const activeTextSchema = activeSchema;
101089
- const enableDynamicFont = !isTextOverflowExpand(activeTextSchema) && Boolean(activeSchema?.dynamicFontSize);
101288
+ const canExpandOverflow = canUseTextOverflowExpand(activeTextSchema, basePdf);
101289
+ const enableDynamicFont = !isTextOverflowExpand(activeTextSchema, basePdf) && Boolean(activeSchema?.dynamicFontSize);
101090
101290
  const hideTextFormat = activeTextSchema.type === "text" && activeTextSchema.readOnly !== true;
101091
101291
  const enableInlineMarkdown = activeTextSchema.textFormat === "inline-markdown" && !hideTextFormat;
101092
101292
  const baseFontName = activeTextSchema.fontName && font[activeTextSchema.fontName] ? activeTextSchema.fontName : fallbackFontName;
@@ -101097,6 +101297,13 @@ var propPanel = {
101097
101297
  label: name,
101098
101298
  value: name
101099
101299
  }))];
101300
+ const overflowOptions = [{
101301
+ label: i18n("schemas.text.overflowVisible"),
101302
+ value: TEXT_OVERFLOW_VISIBLE
101303
+ }, ...canExpandOverflow ? [{
101304
+ label: i18n("schemas.text.overflowExpand"),
101305
+ value: TEXT_OVERFLOW_EXPAND
101306
+ }] : []];
101100
101307
  return {
101101
101308
  fontName: {
101102
101309
  title: i18n("schemas.text.fontName"),
@@ -101141,13 +101348,7 @@ var propPanel = {
101141
101348
  type: "string",
101142
101349
  widget: "select",
101143
101350
  default: DEFAULT_TEXT_OVERFLOW,
101144
- props: { options: [{
101145
- label: i18n("schemas.text.overflowVisible"),
101146
- value: TEXT_OVERFLOW_VISIBLE
101147
- }, {
101148
- label: i18n("schemas.text.overflowExpand"),
101149
- value: TEXT_OVERFLOW_EXPAND
101150
- }] },
101351
+ props: { options: overflowOptions },
101151
101352
  span: 8
101152
101353
  },
101153
101354
  useDynamicFontSize: {
@@ -101210,6 +101411,30 @@ var propPanel = {
101210
101411
  message: i18n("validation.hexColor")
101211
101412
  }]
101212
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
+ },
101213
101438
  useInlineMarkdown: {
101214
101439
  type: "boolean",
101215
101440
  widget: "UseInlineMarkdown",
@@ -101301,6 +101526,9 @@ var propPanel = {
101301
101526
  fontColor: DEFAULT_FONT_COLOR,
101302
101527
  fontName: void 0,
101303
101528
  backgroundColor: "",
101529
+ borderColor: "#000000",
101530
+ borderWidth: createBoxDimension(0),
101531
+ padding: createBoxDimension(0),
101304
101532
  opacity: 1,
101305
101533
  strikethrough: false,
101306
101534
  underline: false
@@ -101323,10 +101551,10 @@ var replaceUnsupportedChars = (text, fontKitFont) => {
101323
101551
  }).join("");
101324
101552
  };
101325
101553
  var uiRender = async (arg) => {
101326
- const { value, schema, mode, onChange, stopEditing, tabIndex, placeholder, options, _cache } = arg;
101554
+ const { value, schema, basePdf, mode, onChange, stopEditing, tabIndex, placeholder, options, _cache } = arg;
101327
101555
  const hasInlineMarkdownFormat = schema.textFormat === TEXT_FORMAT_INLINE_MARKDOWN;
101328
101556
  const enableInlineMarkdown = isInlineMarkdownTextSchema(schema);
101329
- const isReadOnlySplitInlineMarkdownFormChunk = mode === "form" && Boolean(schema.__textLineRange) && hasInlineMarkdownFormat;
101557
+ const isReadOnlySplitInlineMarkdownFormChunk = mode === "form" && Boolean(getTextLineRange(schema)) && hasInlineMarkdownFormat;
101330
101558
  const renderInlineMarkdownReadOnlyChunk = enableInlineMarkdown || isReadOnlySplitInlineMarkdownFormChunk;
101331
101559
  const editable = isEditable(mode, schema) && !isReadOnlySplitInlineMarkdownFormChunk;
101332
101560
  const usePlaceholder = editable && placeholder && !value;
@@ -101337,7 +101565,7 @@ var uiRender = async (arg) => {
101337
101565
  };
101338
101566
  const font = options?.font || getDefaultFont();
101339
101567
  const fontKitFont = await getFontKitFont(schema.fontName, font, _cache);
101340
- const enableDynamicFontSize = shouldUseDynamicFontSize(schema);
101568
+ const enableDynamicFontSize = shouldUseDynamicFontSize(schema, basePdf);
101341
101569
  const displayValue = enableInlineMarkdown ? stripInlineMarkdown(value) : value;
101342
101570
  const dynamicRichTextFontSize = enableInlineMarkdown && enableDynamicFontSize ? await calculateDynamicRichTextFontSize({
101343
101571
  value: usePlaceholder ? placeholder : value,
@@ -101431,13 +101659,14 @@ var renderInlineMarkdownReadOnly = async (arg) => {
101431
101659
  font,
101432
101660
  _cache
101433
101661
  });
101434
- if (schema.__textLineRange) {
101662
+ const lineRange = getTextLineRange(schema);
101663
+ if (lineRange) {
101435
101664
  const lines = applyTextLineRange(layoutRichTextLines({
101436
101665
  runs,
101437
101666
  fontSize: schema.fontSize ?? 13,
101438
101667
  characterSpacing: schema.characterSpacing ?? 0,
101439
- boxWidthInPt: mm2pt(schema.width)
101440
- }), schema.__textLineRange);
101668
+ boxWidthInPt: mm2pt(getBoxContentArea(schema).width)
101669
+ }), lineRange);
101441
101670
  textBlock.innerHTML = "";
101442
101671
  lines.forEach((line, lineIndex) => {
101443
101672
  line.runs.forEach((run) => {
@@ -101496,19 +101725,20 @@ var appendInlineMarkdownRun = (arg) => {
101496
101725
  };
101497
101726
  var getRangedPlainTextValue = (arg) => {
101498
101727
  const { value, schema, fontKitFont, fontSize } = arg;
101499
- if (!schema.__textLineRange) return value;
101728
+ const lineRange = getTextLineRange(schema);
101729
+ if (!lineRange) return value;
101500
101730
  return plainTextLinesToValue(applyTextLineRange(splitTextToSize({
101501
101731
  value,
101502
101732
  characterSpacing: schema.characterSpacing ?? 0,
101503
101733
  fontSize,
101504
101734
  fontKitFont,
101505
- boxWidthInPt: mm2pt(schema.width)
101506
- }), schema.__textLineRange));
101735
+ boxWidthInPt: mm2pt(getBoxContentArea(schema).width)
101736
+ }), lineRange));
101507
101737
  };
101508
101738
  var buildStyledTextContainer = (arg, fontKitFont, value, resolvedDynamicFontSize) => {
101509
101739
  const { schema, rootElement, mode } = arg;
101510
101740
  let dynamicFontSize = resolvedDynamicFontSize;
101511
- if (dynamicFontSize === void 0 && shouldUseDynamicFontSize(schema) && value) dynamicFontSize = calculateDynamicFontSize({
101741
+ if (dynamicFontSize === void 0 && shouldUseDynamicFontSize(schema, arg.basePdf) && value) dynamicFontSize = calculateDynamicFontSize({
101512
101742
  textSchema: schema,
101513
101743
  fontKitFont,
101514
101744
  value,
@@ -101517,15 +101747,29 @@ var buildStyledTextContainer = (arg, fontKitFont, value, resolvedDynamicFontSize
101517
101747
  const { topAdj, bottomAdj } = getBrowserVerticalFontAdjustments(fontKitFont, dynamicFontSize ?? schema.fontSize ?? 13, schema.lineHeight ?? 1, schema.verticalAlignment ?? "top");
101518
101748
  const topAdjustment = topAdj.toString();
101519
101749
  const bottomAdjustment = bottomAdj.toString();
101750
+ const verticalAlignment = schema.verticalAlignment ?? "top";
101751
+ const isTopAligned = verticalAlignment === "top";
101520
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));
101521
101756
  const containerStyle = {
101522
- padding: 0,
101757
+ padding: hasPadding ? `${padding.top}mm ${padding.right}mm ${padding.bottom}mm ${padding.left}mm` : 0,
101523
101758
  resize: "none",
101524
- backgroundColor: getBackgroundColor(value, schema),
101525
- 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" } : {},
101526
101770
  display: "flex",
101527
101771
  flexDirection: "column",
101528
- justifyContent: mapVerticalAlignToFlex(schema.verticalAlignment),
101772
+ justifyContent: mapVerticalAlignToFlex(verticalAlignment),
101529
101773
  width: "100%",
101530
101774
  height: "100%",
101531
101775
  cursor: isEditable(mode, schema) ? "text" : "default"
@@ -101551,7 +101795,8 @@ var buildStyledTextContainer = (arg, fontKitFont, value, resolvedDynamicFontSize
101551
101795
  marginBottom: `${bottomAdjustment}px`,
101552
101796
  paddingTop: `${topAdjustment}px`,
101553
101797
  backgroundColor: "transparent",
101554
- textDecoration: textDecorations.join(" ")
101798
+ textDecoration: textDecorations.join(" "),
101799
+ ...isTopAligned ? { height: "100%" } : {}
101555
101800
  };
101556
101801
  const textBlock = document.createElement("div");
101557
101802
  textBlock.id = "text-" + String(schema.id);
@@ -101593,8 +101838,8 @@ var mapVerticalAlignToFlex = (verticalAlignmentValue) => {
101593
101838
  }
101594
101839
  return "flex-start";
101595
101840
  };
101596
- var getBackgroundColor = (value, schema) => {
101597
- if (!value || !schema.backgroundColor) return "transparent";
101841
+ var getBackgroundColor = (schema) => {
101842
+ if (!schema.backgroundColor) return "transparent";
101598
101843
  return schema.backgroundColor;
101599
101844
  };
101600
101845
  var builtInPlugins = { Text: {
@@ -213662,7 +213907,7 @@ withProvider(FormCore, { Html: html });
213662
213907
  //#region ../../node_modules/form-render/es/index.js
213663
213908
  var es_default = withProvider(FormCore, widgets_exports);
213664
213909
  //#endregion
213665
- //#region ../schemas/dist/helper-BaUAusvL.js
213910
+ //#region ../schemas/dist/helper-CEme39Uo.js
213666
213911
  var substituteVariables = (text, variablesIn, valueMapper = (value) => value) => {
213667
213912
  if (!text) return "";
213668
213913
  let substitutedText = text;
@@ -213698,7 +213943,7 @@ var validateVariables = (value, schema) => {
213698
213943
  return true;
213699
213944
  };
213700
213945
  //#endregion
213701
- //#region ../schemas/dist/dynamicTemplate-ByBNu75x.js
213946
+ //#region ../schemas/dist/dynamicTemplate-C7MdZxPm.js
213702
213947
  var getDynamicLayoutForMultiVariableText = async (value, args) => {
213703
213948
  if (args.schema.type !== "multiVariableText") return { heights: [args.schema.height] };
213704
213949
  const schema = args.schema;
@@ -213715,20 +213960,22 @@ var getDynamicLayoutForMultiVariableText = async (value, args) => {
213715
213960
  _cache: args._cache,
213716
213961
  ignoreDynamicFontSize: true
213717
213962
  });
213718
- const measuredHeight = sumLineHeights(lineHeights);
213963
+ const heights = getTextLineHeightsWithBox(lineHeights, schema);
213964
+ const measuredHeight = sumLineHeights(heights);
213719
213965
  if (measuredHeight <= schema.height || lineHeights.length === 0) return {
213720
213966
  heights: [schema.height],
213721
213967
  patchSplitSchema: () => ({ dynamicFontSize: void 0 })
213722
213968
  };
213723
213969
  return {
213724
- heights: lineHeights.length === 1 ? [Math.max(schema.height, measuredHeight)] : lineHeights,
213970
+ heights: lineHeights.length === 1 ? [Math.max(schema.height, measuredHeight)] : heights,
213725
213971
  patchSplitSchema: ({ start, end, isSplit }) => ({
213726
213972
  dynamicFontSize: void 0,
213727
- __textLineRange: lineHeights.length === 1 ? void 0 : {
213973
+ __splitRange: lineHeights.length === 1 ? void 0 : createTextLineSplitRange(start, end),
213974
+ __isSplit: isSplit,
213975
+ ...getTextSplitBoxStyle(schema, {
213728
213976
  start,
213729
213977
  end
213730
- },
213731
- __isSplit: isSplit
213978
+ }, lineHeights.length)
213732
213979
  })
213733
213980
  };
213734
213981
  };
@@ -213743,20 +213990,22 @@ var getDynamicLayoutForText = async (value, args) => {
213743
213990
  _cache: args._cache,
213744
213991
  ignoreDynamicFontSize: true
213745
213992
  });
213746
- const measuredHeight = sumLineHeights(lineHeights);
213993
+ const heights = getTextLineHeightsWithBox(lineHeights, schema);
213994
+ const measuredHeight = sumLineHeights(heights);
213747
213995
  if (measuredHeight <= schema.height || lineHeights.length === 0) return {
213748
213996
  heights: [schema.height],
213749
213997
  patchSplitSchema: () => ({ dynamicFontSize: void 0 })
213750
213998
  };
213751
213999
  return {
213752
- heights: lineHeights.length === 1 ? [Math.max(schema.height, measuredHeight)] : lineHeights,
214000
+ heights: lineHeights.length === 1 ? [Math.max(schema.height, measuredHeight)] : heights,
213753
214001
  patchSplitSchema: ({ start, end, isSplit }) => ({
213754
214002
  dynamicFontSize: void 0,
213755
- __textLineRange: lineHeights.length === 1 ? void 0 : {
214003
+ __splitRange: lineHeights.length === 1 ? void 0 : createTextLineSplitRange(start, end),
214004
+ __isSplit: isSplit,
214005
+ ...getTextSplitBoxStyle(schema, {
213756
214006
  start,
213757
214007
  end
213758
- },
213759
- __isSplit: isSplit
214008
+ }, lineHeights.length)
213760
214009
  })
213761
214010
  };
213762
214011
  };
@@ -213983,6 +214232,7 @@ var ButtonGroupWidget = (props) => {
213983
214232
  //#endregion
213984
214233
  //#region src/components/Designer/RightSidebar/DetailView/index.tsx
213985
214234
  var { Text: Text$2 } = Typography;
214235
+ var TEXT_OVERFLOW_EXPAND_SCHEMA_TYPES = new Set(["text", "multiVariableText"]);
213986
214236
  var DetailView = (props) => {
213987
214237
  const { token } = theme_default.useToken();
213988
214238
  const { schemasList, changeSchemas, deselectSchema, activeSchema, pageSize, basePdf } = props;
@@ -214037,6 +214287,19 @@ var DetailView = (props) => {
214037
214287
  values.editable = !(typeof values.readOnly === "boolean" ? values.readOnly : false);
214038
214288
  form.setValues(values);
214039
214289
  }, [activeSchema, form]);
214290
+ (0, import_react$9.useEffect)(() => {
214291
+ if (isBlankPdf(basePdf) || !TEXT_OVERFLOW_EXPAND_SCHEMA_TYPES.has(activeSchema.type)) return;
214292
+ if (activeSchema.overflow !== "expand") return;
214293
+ changeSchemas([{
214294
+ key: "overflow",
214295
+ value: TEXT_OVERFLOW_VISIBLE,
214296
+ schemaId: activeSchema.id
214297
+ }]);
214298
+ }, [
214299
+ activeSchema,
214300
+ basePdf,
214301
+ changeSchemas
214302
+ ]);
214040
214303
  (0, import_react$9.useEffect)(() => {
214041
214304
  uniqueSchemaName.current = (value) => {
214042
214305
  for (const page of schemasList) for (const s of Object.values(page)) if (s.name === value && s.id !== activeSchema.id) return false;
@@ -214268,11 +214531,12 @@ var DetailView = (props) => {
214268
214531
  };
214269
214532
  const safeProperties = { ...propPanelSchema.properties };
214270
214533
  if (typeof activePropPanelSchema === "function") {
214271
- const { size, schemas, pageSize, changeSchemas, activeElements, deselectSchema, activeSchema } = props;
214534
+ const { size, schemas, pageSize, basePdf, changeSchemas, activeElements, deselectSchema, activeSchema } = props;
214272
214535
  const functionResult = activePropPanelSchema({
214273
214536
  size,
214274
214537
  schemas,
214275
214538
  pageSize,
214539
+ basePdf,
214276
214540
  changeSchemas,
214277
214541
  activeElements,
214278
214542
  deselectSchema,
@@ -235711,7 +235975,7 @@ var Designer = class extends BaseUIClass {
235711
235975
  }
235712
235976
  };
235713
235977
  //#endregion
235714
- //#region ../schemas/dist/dynamicTemplate-Cy07Imb5.js
235978
+ //#region ../schemas/dist/dynamicTemplate-BwzF9C1L.js
235715
235979
  var normalizeListItems = (value) => {
235716
235980
  if (Array.isArray(value)) return value.map((item) => String(item));
235717
235981
  if (typeof value !== "string") return value == null ? [] : [String(value)];
@@ -235801,10 +236065,7 @@ var getDynamicLayoutForList = async (value, args) => {
235801
236065
  })).items.map((item) => item.height),
235802
236066
  avoidFirstUnitOnly: false,
235803
236067
  patchSplitSchema: ({ start, end, isSplit }) => ({
235804
- __itemRange: {
235805
- start,
235806
- end
235807
- },
236068
+ __splitRange: createListItemSplitRange(start, end),
235808
236069
  __isSplit: isSplit
235809
236070
  })
235810
236071
  };
@@ -236045,7 +236306,7 @@ var Preview = ({ template, inputs, size, onChangeInput, onPageChange }) => {
236045
236306
  for (const { key: _key, value } of args) if (_key === "content") {
236046
236307
  const oldValue = input?.[schema.name] || "";
236047
236308
  const rawNewValue = value;
236048
- const newValue = schema.type === "text" && schema.__textLineRange ? await mergeTextLineRangeValue({
236309
+ const newValue = schema.type === "text" && getTextLineRange(schema) ? await mergeTextLineRangeValue({
236049
236310
  value: oldValue,
236050
236311
  replacement: rawNewValue,
236051
236312
  schema,