@pdfme/schemas 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.
Files changed (37) hide show
  1. package/dist/box.d.ts +45 -0
  2. package/dist/{builtins-BNd4jd5D.js → builtins-BB2DHceW.js} +177 -73
  3. package/dist/builtins-BB2DHceW.js.map +1 -0
  4. package/dist/builtins.js +1 -1
  5. package/dist/dynamicLayout.js +4 -4
  6. package/dist/{dynamicTemplate-CjbGepw4.js → dynamicTemplate-B4GCNLF9.js} +6 -45
  7. package/dist/dynamicTemplate-B4GCNLF9.js.map +1 -0
  8. package/dist/{dynamicTemplate-BpD4RNw8.js → dynamicTemplate-BwzF9C1L.js} +2 -2
  9. package/dist/{dynamicTemplate-BpD4RNw8.js.map → dynamicTemplate-BwzF9C1L.js.map} +1 -1
  10. package/dist/{dynamicTemplate-CBvwRBx9.js → dynamicTemplate-C7MdZxPm.js} +20 -10
  11. package/dist/dynamicTemplate-C7MdZxPm.js.map +1 -0
  12. package/dist/{helper-BFz9EwDz.js → helper-CEme39Uo.js} +2 -2
  13. package/dist/{helper-BFz9EwDz.js.map → helper-CEme39Uo.js.map} +1 -1
  14. package/dist/index.js +24 -20
  15. package/dist/index.js.map +1 -1
  16. package/dist/lists.js +2 -2
  17. package/dist/{measure-Bjmh9Ro3.js → measure-L5diay3k.js} +34 -7
  18. package/dist/measure-L5diay3k.js.map +1 -0
  19. package/dist/{splitRange-CpXivbmJ.js → splitRange-DmVDtmzO.js} +88 -3
  20. package/dist/splitRange-DmVDtmzO.js.map +1 -0
  21. package/dist/tables/helper.d.ts +4 -96
  22. package/dist/tables/types.d.ts +2 -6
  23. package/dist/tables.js +2 -2
  24. package/dist/text/measure.d.ts +6 -0
  25. package/dist/text/richTextPdfRender.d.ts +1 -1
  26. package/dist/text/types.d.ts +4 -0
  27. package/dist/texts.js +3 -3
  28. package/dist/types.d.ts +1 -0
  29. package/dist/{utils-Bd4CvhPZ.js → utils-zDZkqBnX.js} +2 -2
  30. package/dist/{utils-Bd4CvhPZ.js.map → utils-zDZkqBnX.js.map} +1 -1
  31. package/dist/utils.js +2 -2
  32. package/package.json +1 -1
  33. package/dist/builtins-BNd4jd5D.js.map +0 -1
  34. package/dist/dynamicTemplate-CBvwRBx9.js.map +0 -1
  35. package/dist/dynamicTemplate-CjbGepw4.js.map +0 -1
  36. package/dist/measure-Bjmh9Ro3.js.map +0 -1
  37. package/dist/splitRange-CpXivbmJ.js.map +0 -1
package/dist/box.d.ts ADDED
@@ -0,0 +1,45 @@
1
+ import type { PropPanelSchema } from '@pdfme/common';
2
+ export type BoxDimension = {
3
+ top: number;
4
+ right: number;
5
+ bottom: number;
6
+ left: number;
7
+ };
8
+ export type BoxStyleSchema = {
9
+ borderWidth?: Partial<BoxDimension>;
10
+ padding?: Partial<BoxDimension>;
11
+ };
12
+ export type BoxLikeSchema = BoxStyleSchema & {
13
+ position: {
14
+ x: number;
15
+ y: number;
16
+ };
17
+ width: number;
18
+ height: number;
19
+ };
20
+ export declare const createBoxDimension: (value?: number) => BoxDimension;
21
+ export declare const normalizeBoxDimension: (value?: Partial<BoxDimension>) => BoxDimension;
22
+ export declare const getBoxInsets: (schema: BoxStyleSchema) => {
23
+ borderWidth: BoxDimension;
24
+ padding: BoxDimension;
25
+ };
26
+ export declare const getBoxHorizontalInset: (schema: BoxStyleSchema) => number;
27
+ export declare const getBoxVerticalInset: (schema: BoxStyleSchema) => number;
28
+ export declare const getBoxContentArea: <T extends BoxLikeSchema>(schema: T) => {
29
+ position: {
30
+ x: number;
31
+ y: number;
32
+ };
33
+ width: number;
34
+ height: number;
35
+ leftInset: number;
36
+ topInset: number;
37
+ rightInset: number;
38
+ bottomInset: number;
39
+ };
40
+ export declare const hasBoxDimension: (dimension?: Partial<BoxDimension>) => boolean;
41
+ export declare const getSplitBoxDimension: (dimension: Partial<BoxDimension> | undefined, range: {
42
+ start: number;
43
+ end?: number;
44
+ }, totalUnits: number) => BoxDimension;
45
+ export declare const getBoxDimensionPropPanelSchema: (step?: number) => Record<string, PropPanelSchema>;
@@ -1,7 +1,7 @@
1
- import { A as DEFAULT_TEXT_FORMAT, B as SYNTHETIC_BOLD_OFFSET_RATIO, C as ALIGN_RIGHT, D as DEFAULT_DYNAMIC_FIT, E as DEFAULT_ALIGNMENT, F as FONT_VARIANT_FALLBACK_ERROR, G as VERTICAL_ALIGN_BOTTOM, H as TEXT_FORMAT_PLAIN, I as FONT_VARIANT_FALLBACK_PLAIN, K as VERTICAL_ALIGN_MIDDLE, L as FONT_VARIANT_FALLBACK_SYNTHETIC, M as DYNAMIC_FIT_HORIZONTAL, N as DYNAMIC_FIT_VERTICAL, O as DEFAULT_FONT_COLOR, R as PLACEHOLDER_FONT_COLOR, T as CODE_HORIZONTAL_PADDING, U as TEXT_OVERFLOW_EXPAND, V as TEXT_FORMAT_INLINE_MARKDOWN, W as TEXT_OVERFLOW_VISIBLE, _ as isFirefox, b as ALIGN_CENTER, d as calculateDynamicFontSize, f as fetchRemoteFontData, g as heightOfFontAtSize, h as getFontKitFont, j as DEFAULT_TEXT_OVERFLOW, k as DEFAULT_FONT_VARIANT_FALLBACK, m as getFontDescentInPt, p as getBrowserVerticalFontAdjustments, u as getTextLineRange, v as splitTextToSize, w as CODE_BACKGROUND_COLOR, x as ALIGN_JUSTIFY, y as widthOfTextAtSize, z as SYNTHETIC_BOLD_CSS_TEXT_SHADOW } from "./splitRange-CpXivbmJ.js";
2
- import { a as plainTextLinesToValue, c as countRichTextLineGraphemes, f as resolveRichTextRuns, h as stripInlineMarkdown, l as isInlineMarkdownTextSchema, m as parseInlineMarkdown, s as calculateDynamicRichTextFontSize, t as applyTextLineRange, u as layoutRichTextLines } from "./measure-Bjmh9Ro3.js";
3
- import { c as HEX_COLOR_PATTERN } from "./dynamicTemplate-CjbGepw4.js";
4
- import { c as isEditable, i as createSvgStr, n as convertForPdfLayoutProps, o as hex2PrintingColor, u as rotatePoint } from "./utils-Bd4CvhPZ.js";
1
+ import { $ as VERTICAL_ALIGN_MIDDLE, A as ALIGN_RIGHT, B as DYNAMIC_FIT_VERTICAL, C as getBoxInsets, D as ALIGN_CENTER, E as hasBoxDimension, F as DEFAULT_FONT_COLOR, G as PLACEHOLDER_FONT_COLOR, H as FONT_VARIANT_FALLBACK_ERROR, I as DEFAULT_FONT_VARIANT_FALLBACK, J as TEXT_FORMAT_INLINE_MARKDOWN, K as SYNTHETIC_BOLD_CSS_TEXT_SHADOW, L as DEFAULT_TEXT_FORMAT, M as CODE_HORIZONTAL_PADDING, N as DEFAULT_ALIGNMENT, O as ALIGN_JUSTIFY, P as DEFAULT_DYNAMIC_FIT, Q as VERTICAL_ALIGN_BOTTOM, R as DEFAULT_TEXT_OVERFLOW, S as getBoxDimensionPropPanelSchema, U as FONT_VARIANT_FALLBACK_PLAIN, W as FONT_VARIANT_FALLBACK_SYNTHETIC, X as TEXT_OVERFLOW_EXPAND, Y as TEXT_FORMAT_PLAIN, Z as TEXT_OVERFLOW_VISIBLE, _ as isFirefox, b as createBoxDimension, d as calculateDynamicFontSize, f as fetchRemoteFontData, g as heightOfFontAtSize, h as getFontKitFont, j as CODE_BACKGROUND_COLOR, m as getFontDescentInPt, p as getBrowserVerticalFontAdjustments, q as SYNTHETIC_BOLD_OFFSET_RATIO, u as getTextLineRange, v as splitTextToSize, x as getBoxContentArea, y as widthOfTextAtSize, z as DYNAMIC_FIT_HORIZONTAL } from "./splitRange-DmVDtmzO.js";
2
+ import { _ as stripInlineMarkdown, d as isInlineMarkdownTextSchema, f as layoutRichTextLines, g as parseInlineMarkdown, l as calculateDynamicRichTextFontSize, m as resolveRichTextRuns, s as plainTextLinesToValue, t as applyTextLineRange, u as countRichTextLineGraphemes } from "./measure-L5diay3k.js";
3
+ import { c as HEX_COLOR_PATTERN } from "./dynamicTemplate-B4GCNLF9.js";
4
+ import { c as isEditable, i as createSvgStr, n as convertForPdfLayoutProps, o as hex2PrintingColor, u as rotatePoint } from "./utils-zDZkqBnX.js";
5
5
  import { DEFAULT_FONT_NAME, getDefaultFont, getFallbackFontName, getInternalLinkTarget, isBlankPdf, mm2pt, normalizeLinkHref, normalizeSafeLinkUri, registerInternalLinkAnnotation } from "@pdfme/common";
6
6
  import { PDFName, PDFString } from "@pdfme/pdf-lib";
7
7
  import { AlignCenter, AlignJustify, AlignLeft, AlignRight, ArrowDownToLine, ArrowUpToLine, Strikethrough, TextCursorInput, Underline } from "lucide";
@@ -36,7 +36,7 @@ var addUriLinkAnnotation = (arg) => {
36
36
  //#region src/text/richTextPdfRender.ts
37
37
  var getSyntheticBoldWidth = (run, fontSize) => run.syntheticBold ? fontSize * SYNTHETIC_BOLD_OFFSET_RATIO * 2 : 0;
38
38
  var getSyntheticItalicWidth = (run, fontSize) => run.syntheticItalic ? heightOfFontAtSize(run.fontKitFont, fontSize) * Math.tan(12 * Math.PI / 180) : 0;
39
- var getRunWidth = (run, fontSize, characterSpacing) => widthOfTextAtSize(run.text, run.fontKitFont, fontSize, characterSpacing) + getSyntheticBoldWidth(run, fontSize) + getSyntheticItalicWidth(run, fontSize);
39
+ 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);
40
40
  var getPdfFontFromObj = (run, pdfFontObj) => {
41
41
  const pdfFont = pdfFontObj[run.fontName];
42
42
  if (!pdfFont) throw new Error(`[@pdfme/schemas] Missing embedded font "${run.fontName}".`);
@@ -117,10 +117,12 @@ var getLinkAnnotationRect = (arg) => {
117
117
  var drawRun = (arg) => {
118
118
  const { page, pdfLib, run, pdfFont, x, y, rotate, pivotPoint, fontSize, lineHeight, color, opacity, colorType, characterSpacing, strikethrough, underline } = arg;
119
119
  const runWidth = getRunWidth(run, fontSize, characterSpacing);
120
+ const codePadding = run.code ? CODE_HORIZONTAL_PADDING : 0;
121
+ const textX = x + codePadding;
122
+ const textWidth = runWidth - codePadding * 2;
120
123
  const textHeight = heightOfFontAtSize(run.fontKitFont, fontSize);
121
124
  if (run.code) {
122
- const padding = CODE_HORIZONTAL_PADDING;
123
- const bgX = x - padding;
125
+ const bgX = x;
124
126
  const bgY = y - textHeight * .2;
125
127
  const bgPoint = rotate.angle === 0 ? {
126
128
  x: bgX,
@@ -132,7 +134,7 @@ var drawRun = (arg) => {
132
134
  page.drawRectangle({
133
135
  x: bgPoint.x,
134
136
  y: bgPoint.y,
135
- width: runWidth + padding * 2,
137
+ width: runWidth,
136
138
  height: textHeight * 1.2,
137
139
  rotate,
138
140
  color: hex2PrintingColor(CODE_BACKGROUND_COLOR, colorType),
@@ -141,9 +143,9 @@ var drawRun = (arg) => {
141
143
  }
142
144
  if (strikethrough && runWidth > 0) drawDecorationLine({
143
145
  page,
144
- x,
146
+ x: textX,
145
147
  y: y + textHeight / 3,
146
- width: runWidth,
148
+ width: textWidth,
147
149
  rotate,
148
150
  pivotPoint,
149
151
  fontSize,
@@ -152,9 +154,9 @@ var drawRun = (arg) => {
152
154
  });
153
155
  if (underline && runWidth > 0) drawDecorationLine({
154
156
  page,
155
- x,
157
+ x: textX,
156
158
  y: y - textHeight / 12,
157
- width: runWidth,
159
+ width: textWidth,
158
160
  rotate,
159
161
  pivotPoint,
160
162
  fontSize,
@@ -181,14 +183,14 @@ var drawRun = (arg) => {
181
183
  ...run.syntheticItalic ? { ySkew: pdfLib.degrees(12) } : {}
182
184
  });
183
185
  };
184
- drawAt(x);
186
+ drawAt(textX);
185
187
  if (run.syntheticBold) {
186
188
  const offset = fontSize * SYNTHETIC_BOLD_OFFSET_RATIO;
187
- for (let i = 1; i <= 2; i++) drawAt(x + offset * i);
189
+ for (let i = 1; i <= 2; i++) drawAt(textX + offset * i);
188
190
  }
189
191
  };
190
192
  var renderInlineMarkdownText = async (arg) => {
191
- 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;
193
+ 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;
192
194
  const allLines = layoutRichTextLines({
193
195
  runs: await resolveRichTextRuns({
194
196
  runs: parseInlineMarkdown(value),
@@ -228,7 +230,7 @@ var renderInlineMarkdownText = async (arg) => {
228
230
  let xLine = x;
229
231
  if (alignment === "center") xLine += (width - textWidth) / 2;
230
232
  else if (alignment === "right") xLine += width - textWidth;
231
- const yLine = pageHeight - mm2pt(schema.position.y) - yOffset - lineHeight * fontSize * rowIndex;
233
+ const yLine = y + height - yOffset - lineHeight * fontSize * rowIndex;
232
234
  page.pushOperators(pdfLib.setCharacterSpacing(spacing));
233
235
  if (schema.strikethrough || schema.underline) {
234
236
  const textHeight = Math.max(...line.runs.map((run) => heightOfFontAtSize(run.fontKitFont, fontSize)));
@@ -359,10 +361,36 @@ var getGraphemeSegmenter = () => {
359
361
  };
360
362
  var pdfRender = async (arg) => {
361
363
  const { value, pdfDoc, pdfLib, page, options, schema, basePdf, _cache } = arg;
362
- if (!value) return;
363
364
  const { font = getDefaultFont(), colorType } = options;
365
+ const pageHeight = page.getHeight();
366
+ const { width, height, rotate, position: { x, y }, opacity } = convertForPdfLayoutProps({
367
+ schema,
368
+ pageHeight,
369
+ applyRotateTranslate: false
370
+ });
371
+ const pivotPoint = {
372
+ x: x + width / 2,
373
+ y: pageHeight - mm2pt(schema.position.y) - height / 2
374
+ };
375
+ drawTextBoxDecoration({
376
+ page,
377
+ schema,
378
+ colorType,
379
+ x,
380
+ y,
381
+ width,
382
+ height,
383
+ rotate,
384
+ pivotPoint
385
+ });
386
+ if (!value) return;
364
387
  const fontName = schema.fontName ? schema.fontName : getFallbackFontName(font);
365
388
  const enableInlineMarkdown = isInlineMarkdownTextSchema(schema);
389
+ const contentArea = getBoxContentArea(schema);
390
+ const contentX = x + mm2pt(contentArea.leftInset);
391
+ const contentY = y + mm2pt(contentArea.bottomInset);
392
+ const contentWidth = mm2pt(contentArea.width);
393
+ const contentHeight = mm2pt(contentArea.height);
366
394
  const pdfFontValuePromise = enableInlineMarkdown ? void 0 : embedAndGetFont({
367
395
  pdfDoc,
368
396
  font,
@@ -383,40 +411,6 @@ var pdfRender = async (arg) => {
383
411
  _cache
384
412
  }) : void 0
385
413
  });
386
- const pageHeight = page.getHeight();
387
- const { width, height, rotate, position: { x, y }, opacity } = convertForPdfLayoutProps({
388
- schema,
389
- pageHeight,
390
- applyRotateTranslate: false
391
- });
392
- const pivotPoint = {
393
- x: x + width / 2,
394
- y: pageHeight - mm2pt(schema.position.y) - height / 2
395
- };
396
- if (schema.backgroundColor) {
397
- const color = hex2PrintingColor(schema.backgroundColor, colorType);
398
- if (rotate.angle !== 0) {
399
- const rotatedPoint = rotatePoint({
400
- x,
401
- y
402
- }, pivotPoint, rotate.angle);
403
- page.drawRectangle({
404
- x: rotatedPoint.x,
405
- y: rotatedPoint.y,
406
- width,
407
- height,
408
- rotate,
409
- color
410
- });
411
- } else page.drawRectangle({
412
- x,
413
- y,
414
- width,
415
- height,
416
- rotate,
417
- color
418
- });
419
- }
420
414
  if (enableInlineMarkdown) {
421
415
  await renderInlineMarkdownText({
422
416
  value,
@@ -440,10 +434,10 @@ var pdfRender = async (arg) => {
440
434
  verticalAlignment,
441
435
  lineHeight,
442
436
  characterSpacing,
443
- x,
444
- width,
445
- height,
446
- pageHeight,
437
+ x: contentX,
438
+ y: contentY,
439
+ width: contentWidth,
440
+ height: contentHeight,
447
441
  pivotPoint,
448
442
  rotate,
449
443
  opacity
@@ -460,7 +454,7 @@ var pdfRender = async (arg) => {
460
454
  characterSpacing,
461
455
  fontSize,
462
456
  fontKitFont,
463
- boxWidthInPt: width
457
+ boxWidthInPt: contentWidth
464
458
  }), getTextLineRange(schema));
465
459
  const needsTextWidth = alignment !== "left" || Boolean(schema.strikethrough || schema.underline);
466
460
  const needsTextHeight = Boolean(schema.strikethrough || schema.underline);
@@ -468,8 +462,8 @@ var pdfRender = async (arg) => {
468
462
  if (verticalAlignment === "top") yOffset = firstLineTextHeight + halfLineHeightAdjustment;
469
463
  else {
470
464
  const otherLinesHeight = lineHeight * fontSize * (lines.length - 1);
471
- if (verticalAlignment === "bottom") yOffset = height - otherLinesHeight + descent - halfLineHeightAdjustment;
472
- else if (verticalAlignment === "middle") yOffset = (height - otherLinesHeight - firstLineTextHeight + descent) / 2 + firstLineTextHeight;
465
+ if (verticalAlignment === "bottom") yOffset = contentHeight - otherLinesHeight + descent - halfLineHeightAdjustment;
466
+ else if (verticalAlignment === "middle") yOffset = (contentHeight - otherLinesHeight - firstLineTextHeight + descent) / 2 + firstLineTextHeight;
473
467
  }
474
468
  lines.forEach((line, rowIndex) => {
475
469
  const trimmed = line.replace("\n", "");
@@ -477,10 +471,10 @@ var pdfRender = async (arg) => {
477
471
  const textHeight = needsTextHeight ? heightOfFontAtSize(fontKitFont, fontSize) : 0;
478
472
  const rowYOffset = lineHeight * fontSize * rowIndex;
479
473
  if (line === "") line = "\r\n";
480
- let xLine = x;
481
- if (alignment === "center") xLine += (width - textWidth) / 2;
482
- else if (alignment === "right") xLine += width - textWidth;
483
- let yLine = pageHeight - mm2pt(schema.position.y) - yOffset - rowYOffset;
474
+ let xLine = contentX;
475
+ if (alignment === "center") xLine += (contentWidth - textWidth) / 2;
476
+ else if (alignment === "right") xLine += contentWidth - textWidth;
477
+ let yLine = contentY + contentHeight - yOffset - rowYOffset;
484
478
  if (schema.strikethrough && textWidth > 0) {
485
479
  const _x = xLine + textWidth + 1;
486
480
  const _y = yLine + textHeight / 3;
@@ -527,7 +521,7 @@ var pdfRender = async (arg) => {
527
521
  if (alignment === "justify" && line.slice(-1) !== "\n") {
528
522
  const iterator = getGraphemeSegmenter().segment(trimmed)[Symbol.iterator]();
529
523
  const len = Array.from(iterator).length;
530
- spacing += (width - textWidth) / len;
524
+ spacing += (contentWidth - textWidth) / len;
531
525
  }
532
526
  page.pushOperators(pdfLib.setCharacterSpacing(spacing));
533
527
  page.drawText(trimmed, {
@@ -542,6 +536,75 @@ var pdfRender = async (arg) => {
542
536
  });
543
537
  });
544
538
  };
539
+ var drawTextBoxDecoration = (arg) => {
540
+ const { page, schema, colorType, x, y, width, height, rotate, pivotPoint } = arg;
541
+ const { borderWidth } = getBoxInsets(schema);
542
+ const opacity = schema.opacity ?? 1;
543
+ const drawRectangle = (rect) => {
544
+ if (rect.width <= 0 || rect.height <= 0) return;
545
+ const point = rotate.angle === 0 ? {
546
+ x: rect.x,
547
+ y: rect.y
548
+ } : rotatePoint({
549
+ x: rect.x,
550
+ y: rect.y
551
+ }, pivotPoint, rotate.angle);
552
+ page.drawRectangle({
553
+ x: point.x,
554
+ y: point.y,
555
+ width: rect.width,
556
+ height: rect.height,
557
+ rotate,
558
+ color: rect.color,
559
+ opacity
560
+ });
561
+ };
562
+ if (schema.backgroundColor) {
563
+ const color = hex2PrintingColor(schema.backgroundColor, colorType);
564
+ if (color) drawRectangle({
565
+ x,
566
+ y,
567
+ width,
568
+ height,
569
+ color
570
+ });
571
+ }
572
+ if (!schema.borderColor || !hasBoxDimension(schema.borderWidth)) return;
573
+ const color = hex2PrintingColor(schema.borderColor, colorType);
574
+ if (!color) return;
575
+ const top = mm2pt(borderWidth.top);
576
+ const right = mm2pt(borderWidth.right);
577
+ const bottom = mm2pt(borderWidth.bottom);
578
+ const left = mm2pt(borderWidth.left);
579
+ drawRectangle({
580
+ x,
581
+ y: y + height - top,
582
+ width,
583
+ height: top,
584
+ color
585
+ });
586
+ drawRectangle({
587
+ x: x + width - right,
588
+ y,
589
+ width: right,
590
+ height,
591
+ color
592
+ });
593
+ drawRectangle({
594
+ x,
595
+ y,
596
+ width,
597
+ height: bottom,
598
+ color
599
+ });
600
+ drawRectangle({
601
+ x,
602
+ y,
603
+ width: left,
604
+ height,
605
+ color
606
+ });
607
+ };
545
608
  //#endregion
546
609
  //#region src/text/icons/index.ts
547
610
  var TextStrikethroughIcon = createSvgStr(Strikethrough);
@@ -810,6 +873,30 @@ var propPanel = {
810
873
  message: i18n("validation.hexColor")
811
874
  }]
812
875
  },
876
+ borderColor: {
877
+ title: i18n("schemas.borderColor"),
878
+ type: "string",
879
+ widget: "color",
880
+ props: { disabledAlpha: true },
881
+ rules: [{
882
+ pattern: HEX_COLOR_PATTERN,
883
+ message: i18n("validation.hexColor")
884
+ }]
885
+ },
886
+ borderWidth: {
887
+ title: i18n("schemas.borderWidth"),
888
+ type: "object",
889
+ widget: "lineTitle",
890
+ span: 24,
891
+ properties: getBoxDimensionPropPanelSchema(.1)
892
+ },
893
+ padding: {
894
+ title: i18n("schemas.padding"),
895
+ type: "object",
896
+ widget: "lineTitle",
897
+ span: 24,
898
+ properties: getBoxDimensionPropPanelSchema()
899
+ },
813
900
  useInlineMarkdown: {
814
901
  type: "boolean",
815
902
  widget: "UseInlineMarkdown",
@@ -901,6 +988,9 @@ var propPanel = {
901
988
  fontColor: DEFAULT_FONT_COLOR,
902
989
  fontName: void 0,
903
990
  backgroundColor: "",
991
+ borderColor: "#000000",
992
+ borderWidth: createBoxDimension(0),
993
+ padding: createBoxDimension(0),
904
994
  opacity: 1,
905
995
  strikethrough: false,
906
996
  underline: false
@@ -1039,7 +1129,7 @@ var renderInlineMarkdownReadOnly = async (arg) => {
1039
1129
  runs,
1040
1130
  fontSize: schema.fontSize ?? 13,
1041
1131
  characterSpacing: schema.characterSpacing ?? 0,
1042
- boxWidthInPt: mm2pt(schema.width)
1132
+ boxWidthInPt: mm2pt(getBoxContentArea(schema).width)
1043
1133
  }), lineRange);
1044
1134
  textBlock.innerHTML = "";
1045
1135
  lines.forEach((line, lineIndex) => {
@@ -1106,7 +1196,7 @@ var getRangedPlainTextValue = (arg) => {
1106
1196
  characterSpacing: schema.characterSpacing ?? 0,
1107
1197
  fontSize,
1108
1198
  fontKitFont,
1109
- boxWidthInPt: mm2pt(schema.width)
1199
+ boxWidthInPt: mm2pt(getBoxContentArea(schema).width)
1110
1200
  }), lineRange));
1111
1201
  };
1112
1202
  var buildStyledTextContainer = (arg, fontKitFont, value, resolvedDynamicFontSize) => {
@@ -1121,15 +1211,29 @@ var buildStyledTextContainer = (arg, fontKitFont, value, resolvedDynamicFontSize
1121
1211
  const { topAdj, bottomAdj } = getBrowserVerticalFontAdjustments(fontKitFont, dynamicFontSize ?? schema.fontSize ?? 13, schema.lineHeight ?? 1, schema.verticalAlignment ?? "top");
1122
1212
  const topAdjustment = topAdj.toString();
1123
1213
  const bottomAdjustment = bottomAdj.toString();
1214
+ const verticalAlignment = schema.verticalAlignment ?? "top";
1215
+ const isTopAligned = verticalAlignment === "top";
1124
1216
  const container = document.createElement("div");
1217
+ const { borderWidth, padding } = getBoxInsets(schema);
1218
+ const hasPadding = hasBoxDimension(schema.padding);
1219
+ const hasBorder = Boolean(schema.borderColor && hasBoxDimension(schema.borderWidth));
1125
1220
  const containerStyle = {
1126
- padding: 0,
1221
+ padding: hasPadding ? `${padding.top}mm ${padding.right}mm ${padding.bottom}mm ${padding.left}mm` : 0,
1127
1222
  resize: "none",
1128
- backgroundColor: getBackgroundColor(value, schema),
1129
- border: "none",
1223
+ backgroundColor: getBackgroundColor(schema),
1224
+ border: hasBorder ? void 0 : "none",
1225
+ ...hasBorder ? {
1226
+ borderTopWidth: `${borderWidth.top}mm`,
1227
+ borderRightWidth: `${borderWidth.right}mm`,
1228
+ borderBottomWidth: `${borderWidth.bottom}mm`,
1229
+ borderLeftWidth: `${borderWidth.left}mm`,
1230
+ borderStyle: "solid",
1231
+ borderColor: schema.borderColor
1232
+ } : {},
1233
+ ...hasPadding || hasBorder ? { boxSizing: "border-box" } : {},
1130
1234
  display: "flex",
1131
1235
  flexDirection: "column",
1132
- justifyContent: mapVerticalAlignToFlex(schema.verticalAlignment),
1236
+ justifyContent: mapVerticalAlignToFlex(verticalAlignment),
1133
1237
  width: "100%",
1134
1238
  height: "100%",
1135
1239
  cursor: isEditable(mode, schema) ? "text" : "default"
@@ -1156,7 +1260,7 @@ var buildStyledTextContainer = (arg, fontKitFont, value, resolvedDynamicFontSize
1156
1260
  paddingTop: `${topAdjustment}px`,
1157
1261
  backgroundColor: "transparent",
1158
1262
  textDecoration: textDecorations.join(" "),
1159
- height: "100%"
1263
+ ...isTopAligned ? { height: "100%" } : {}
1160
1264
  };
1161
1265
  const textBlock = document.createElement("div");
1162
1266
  textBlock.id = "text-" + String(schema.id);
@@ -1198,8 +1302,8 @@ var mapVerticalAlignToFlex = (verticalAlignmentValue) => {
1198
1302
  }
1199
1303
  return "flex-start";
1200
1304
  };
1201
- var getBackgroundColor = (value, schema) => {
1202
- if (!value || !schema.backgroundColor) return "transparent";
1305
+ var getBackgroundColor = (schema) => {
1306
+ if (!schema.backgroundColor) return "transparent";
1203
1307
  return schema.backgroundColor;
1204
1308
  };
1205
1309
  //#endregion
@@ -1216,4 +1320,4 @@ var builtInPlugins = { Text: textSchema };
1216
1320
  //#endregion
1217
1321
  export { mapVerticalAlignToFlex as a, Formatter as c, makeElementPlainTextContentEditable as i, getExtraFormatterSchema as l, textSchema as n, uiRender as o, buildStyledTextContainer as r, propPanel as s, builtInPlugins as t, pdfRender as u };
1218
1322
 
1219
- //# sourceMappingURL=builtins-BNd4jd5D.js.map
1323
+ //# sourceMappingURL=builtins-BB2DHceW.js.map