@campxdev/pdfme 1.2.0 → 1.2.1

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 (29) hide show
  1. package/dist/cjs/chunks/{helper-DU7Bm8ZQ.js → helper-C2o2tpNj.js} +2 -1
  2. package/dist/cjs/chunks/{index-Co0Y0KJj.js → index-CXm3doOM.js} +31 -4
  3. package/dist/cjs/chunks/{index-mgS9yYj7.js → index-dHRmLCnu.js} +4 -4
  4. package/dist/cjs/chunks/{index-BzWo8eqh.js → index-qB7eb2BC.js} +2 -2
  5. package/dist/cjs/chunks/{pluginRegistry-DlJQZP6L.js → pluginRegistry-Ba3ANzzx.js} +1 -1
  6. package/dist/cjs/common.js +3 -3
  7. package/dist/cjs/converter.js +1 -1
  8. package/dist/cjs/generator.js +3 -3
  9. package/dist/cjs/index.js +5 -5
  10. package/dist/cjs/print-designer-editor.js +223 -128
  11. package/dist/cjs/schemas.js +3 -3
  12. package/dist/cjs/ui.js +106 -83
  13. package/dist/esm/chunks/{helper-C8LqGaF4.js → helper-D7XF1bxK.js} +2 -1
  14. package/dist/esm/chunks/{index-d0iAk7OA.js → index-D1FuD_XZ.js} +3 -3
  15. package/dist/esm/chunks/{index-Rwcd_Vzj.js → index-pDt5vVVj.js} +4 -4
  16. package/dist/esm/chunks/{index-CwqHuiCe.js → index-qTsnfbi7.js} +32 -5
  17. package/dist/esm/chunks/{pluginRegistry-C0a91XEw.js → pluginRegistry-DEA2P0ud.js} +1 -1
  18. package/dist/esm/common.js +3 -3
  19. package/dist/esm/converter.js +1 -1
  20. package/dist/esm/generator.js +3 -3
  21. package/dist/esm/index.js +5 -5
  22. package/dist/esm/print-designer-editor.js +224 -129
  23. package/dist/esm/schemas.js +5 -5
  24. package/dist/esm/ui.js +106 -83
  25. package/dist/types/_vendors/schemas/text/extraFormatter.d.ts +2 -0
  26. package/dist/types/_vendors/schemas/text/helper.d.ts +1 -0
  27. package/dist/types/_vendors/schemas/text/icons/index.d.ts +2 -0
  28. package/dist/types/_vendors/schemas/text/types.d.ts +2 -0
  29. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
- import { m as propPanel$1, p as pdfRender$2, u as uiRender$2, c as createSvgStr, d as convertForPdfLayoutProps, i as isEditable, a as addAlphaToHex, k as createErrorElm, D as DEFAULT_OPACITY, H as HEX_COLOR_PATTERN, n as getBodyWithRange, o as createSingleTable, q as getBody, f as getDefaultCellStyles, t as getColumnStylesPropPanelSchema, v as getCellPropPanelSchema, w as DEFAULT_FONT_COLOR, x as DEFAULT_CHARACTER_SPACING, y as DEFAULT_FONT_SIZE, z as DEFAULT_ALIGNMENT, A as getExtraFormatterSchema, F as Formatter, B as DEFAULT_LINE_HEIGHT, V as VERTICAL_ALIGN_MIDDLE, C as mapVerticalAlignToFlex } from './chunks/index-CwqHuiCe.js';
2
- export { b as builtInPlugins, g as getDynamicHeightsForTable, s as multiVariableText } from './chunks/index-CwqHuiCe.js';
3
- import { c as validateBarcodeInput, f as createBarCode, D as DEFAULT_BARCODE_COLOR, g as DEFAULT_BARCODE_BG_COLOR, h as DEFAULT_BARCODE_INCLUDETEXT, B as BARCODE_TYPES, r as rectangle, j as cellSchema } from './chunks/index-Rwcd_Vzj.js';
4
- export { d as dynamicBarcode, a as dynamicQrCode, b as dynamicTable, e as ellipse, i as image, l as line, s as signature, v as variableBarcodes } from './chunks/index-Rwcd_Vzj.js';
1
+ import { m as propPanel$1, p as pdfRender$2, u as uiRender$2, c as createSvgStr, d as convertForPdfLayoutProps, i as isEditable, a as addAlphaToHex, k as createErrorElm, D as DEFAULT_OPACITY, H as HEX_COLOR_PATTERN, n as getBodyWithRange, o as createSingleTable, q as getBody, f as getDefaultCellStyles, t as getColumnStylesPropPanelSchema, v as getCellPropPanelSchema, w as DEFAULT_FONT_COLOR, x as DEFAULT_CHARACTER_SPACING, y as DEFAULT_FONT_SIZE, z as DEFAULT_ALIGNMENT, A as getExtraFormatterSchema, F as Formatter, B as DEFAULT_LINE_HEIGHT, V as VERTICAL_ALIGN_MIDDLE, C as mapVerticalAlignToFlex } from './chunks/index-qTsnfbi7.js';
2
+ export { b as builtInPlugins, g as getDynamicHeightsForTable, s as multiVariableText } from './chunks/index-qTsnfbi7.js';
3
+ import { c as validateBarcodeInput, f as createBarCode, D as DEFAULT_BARCODE_COLOR, g as DEFAULT_BARCODE_BG_COLOR, h as DEFAULT_BARCODE_INCLUDETEXT, B as BARCODE_TYPES, r as rectangle, j as cellSchema } from './chunks/index-pDt5vVVj.js';
4
+ export { d as dynamicBarcode, a as dynamicQrCode, b as dynamicTable, e as ellipse, i as image, l as line, s as signature, v as variableBarcodes } from './chunks/index-pDt5vVVj.js';
5
5
  import { TextCursorInput, Route, QrCode, Barcode, Table, CalendarClock, Calendar, Clock, ChevronDown, CircleDot, Circle, SquareCheck, Square } from 'lucide';
6
- import { x as px2mm, Z as ZOOM, q as getFallbackFontName, D as DEFAULT_FONT_NAME } from './chunks/helper-C8LqGaF4.js';
6
+ import { x as px2mm, Z as ZOOM, q as getFallbackFontName, D as DEFAULT_FONT_NAME } from './chunks/helper-D7XF1bxK.js';
7
7
  import AirDatepicker from 'air-datepicker';
8
8
  import localeAr from 'air-datepicker/locale/ar';
9
9
  import localeBg from 'air-datepicker/locale/bg';
package/dist/esm/ui.js CHANGED
@@ -73964,6 +73964,15 @@ const getBrowserVerticalFontAdjustments = (a, s, c, u) => {
73964
73964
  v instanceof bufferExports.Buffer ? A = v : A = bufferExports.Buffer.from(v);
73965
73965
  const x = $d636bc798e7178db$export$185802fd694ee1f5(A);
73966
73966
  return c.set(d, x), x;
73967
+ }, resolveFontName = (a, s, c, u) => {
73968
+ const d = a || getFallbackFontName(u);
73969
+ if (!s && !c)
73970
+ return d;
73971
+ const p = s && c ? [" Bold Italic", "BoldItalic", "-BoldItalic"] : s ? [" Bold", "Bold", "-Bold"] : [" Italic", "Italic", "-Italic"];
73972
+ for (const v of p)
73973
+ if (u[d + v])
73974
+ return d + v;
73975
+ return d;
73967
73976
  }, calculateDynamicFontSize = ({ textSchema: a, fontKitFont: s, value: c, startingFontSize: u }) => {
73968
73977
  const { fontSize: d, dynamicFontSize: p, characterSpacing: v, width: A, height: x, lineHeight: g = DEFAULT_LINE_HEIGHT } = a, b = u || d || DEFAULT_FONT_SIZE;
73969
73978
  if (!p || p.max < p.min)
@@ -74644,84 +74653,84 @@ const DEFAULT_OPACITY = 1, HEX_COLOR_PATTERN = "^#(?:[A-Fa-f0-9]{6})$", getBody$
74644
74653
  const { value: s, pdfDoc: c, pdfLib: u, page: d, options: p, schema: v, _cache: A } = a;
74645
74654
  if (!s)
74646
74655
  return;
74647
- const { font: x = getDefaultFont(), colorType: g } = p, [b, y] = await Promise.all([
74656
+ const { font: x = getDefaultFont(), colorType: g } = p, b = resolveFontName(v.fontName, v.bold, v.italic, x), [y, f] = await Promise.all([
74648
74657
  embedAndGetFontObj({
74649
74658
  pdfDoc: c,
74650
74659
  font: x,
74651
74660
  _cache: A
74652
74661
  }),
74653
- getFontKitFont(v.fontName, x, A)
74654
- ]), f = getFontProp({ value: s, fontKitFont: y, schema: v, colorType: g }), { fontSize: m, color: E, alignment: w, verticalAlignment: S, lineHeight: $, characterSpacing: R } = f, _ = v.fontName ? v.fontName : getFallbackFontName(x), I = b && b[_], C = d.getHeight(), { width: T, height: B, rotate: N, position: { x: O, y: F }, opacity: k } = convertForPdfLayoutProps({ schema: v, pageHeight: C, applyRotateTranslate: false }), V = { x: O + T / 2, y: C - mm2pt(v.position.y) - B / 2 };
74662
+ getFontKitFont(b, x, A)
74663
+ ]), m = getFontProp({ value: s, fontKitFont: f, schema: v, colorType: g }), { fontSize: E, color: w, alignment: S, verticalAlignment: $, lineHeight: R, characterSpacing: _ } = m, C = y && y[b], T = d.getHeight(), { width: B, height: N, rotate: O, position: { x: F, y: k }, opacity: V } = convertForPdfLayoutProps({ schema: v, pageHeight: T, applyRotateTranslate: false }), z = { x: F + B / 2, y: T - mm2pt(v.position.y) - N / 2 };
74655
74664
  if (v.backgroundColor) {
74656
- const D = hex2PrintingColor(v.backgroundColor, g);
74657
- if (N.angle !== 0) {
74658
- const H = rotatePoint({ x: O, y: F }, V, N.angle);
74659
- d.drawRectangle({ x: H.x, y: H.y, width: T, height: B, rotate: N, color: D });
74665
+ const H = hex2PrintingColor(v.backgroundColor, g);
74666
+ if (O.angle !== 0) {
74667
+ const U = rotatePoint({ x: F, y: k }, z, O.angle);
74668
+ d.drawRectangle({ x: U.x, y: U.y, width: B, height: N, rotate: O, color: H });
74660
74669
  } else
74661
- d.drawRectangle({ x: O, y: F, width: T, height: B, rotate: N, color: D });
74670
+ d.drawRectangle({ x: F, y: k, width: B, height: N, rotate: O, color: H });
74662
74671
  }
74663
- const z = heightOfFontAtSize(y, m), G = getFontDescentInPt(y, m), W = $ === 0 ? 0 : ($ - 1) * m / 2, M = splitTextToSize({
74672
+ const G = heightOfFontAtSize(f, E), W = getFontDescentInPt(f, E), M = R === 0 ? 0 : (R - 1) * E / 2, L = splitTextToSize({
74664
74673
  value: s,
74665
- characterSpacing: R,
74666
- fontSize: m,
74667
- fontKitFont: y,
74668
- boxWidthInPt: T
74674
+ characterSpacing: _,
74675
+ fontSize: E,
74676
+ fontKitFont: f,
74677
+ boxWidthInPt: B
74669
74678
  });
74670
- let L = 0;
74671
- if (S === VERTICAL_ALIGN_TOP)
74672
- L = z + W;
74679
+ let P = 0;
74680
+ if ($ === VERTICAL_ALIGN_TOP)
74681
+ P = G + M;
74673
74682
  else {
74674
- const D = $ * m * (M.length - 1);
74675
- S === VERTICAL_ALIGN_BOTTOM ? L = B - D + G - W : S === VERTICAL_ALIGN_MIDDLE && (L = (B - D - z + G) / 2 + z);
74676
- }
74677
- const P = new Intl.Segmenter(void 0, { granularity: "grapheme" });
74678
- M.forEach((D, H) => {
74679
- const U = D.replace(`
74680
- `, ""), Y = widthOfTextAtSize(U, y, m, R), ee = heightOfFontAtSize(y, m), Z = $ * m * H;
74681
- D === "" && (D = `\r
74683
+ const H = R * E * (L.length - 1);
74684
+ $ === VERTICAL_ALIGN_BOTTOM ? P = N - H + W - M : $ === VERTICAL_ALIGN_MIDDLE && (P = (N - H - G + W) / 2 + G);
74685
+ }
74686
+ const D = new Intl.Segmenter(void 0, { granularity: "grapheme" });
74687
+ L.forEach((H, U) => {
74688
+ const Y = H.replace(`
74689
+ `, ""), ee = widthOfTextAtSize(Y, f, E, _), Z = heightOfFontAtSize(f, E), re = R * E * U;
74690
+ H === "" && (H = `\r
74682
74691
  `);
74683
- let re = O;
74684
- w === "center" ? re += (T - Y) / 2 : w === "right" && (re += T - Y);
74685
- let K = C - mm2pt(v.position.y) - L - Z;
74686
- if (v.strikethrough && Y > 0) {
74687
- const q = re + Y + 1, J = K + ee / 3;
74692
+ let K = F;
74693
+ S === "center" ? K += (B - ee) / 2 : S === "right" && (K += B - ee);
74694
+ let te = T - mm2pt(v.position.y) - P - re;
74695
+ if (v.strikethrough && ee > 0) {
74696
+ const J = K + ee + 1, ne = te + Z / 3;
74688
74697
  d.drawLine({
74689
- start: rotatePoint({ x: re, y: J }, V, N.angle),
74690
- end: rotatePoint({ x: q, y: J }, V, N.angle),
74691
- thickness: 1 / 12 * m,
74692
- color: E,
74693
- opacity: k
74698
+ start: rotatePoint({ x: K, y: ne }, z, O.angle),
74699
+ end: rotatePoint({ x: J, y: ne }, z, O.angle),
74700
+ thickness: 1 / 12 * E,
74701
+ color: w,
74702
+ opacity: V
74694
74703
  });
74695
74704
  }
74696
- if (v.underline && Y > 0) {
74697
- const q = re + Y + 1, J = K - ee / 12;
74705
+ if (v.underline && ee > 0) {
74706
+ const J = K + ee + 1, ne = te - Z / 12;
74698
74707
  d.drawLine({
74699
- start: rotatePoint({ x: re, y: J }, V, N.angle),
74700
- end: rotatePoint({ x: q, y: J }, V, N.angle),
74701
- thickness: 1 / 12 * m,
74702
- color: E,
74703
- opacity: k
74708
+ start: rotatePoint({ x: K, y: ne }, z, O.angle),
74709
+ end: rotatePoint({ x: J, y: ne }, z, O.angle),
74710
+ thickness: 1 / 12 * E,
74711
+ color: w,
74712
+ opacity: V
74704
74713
  });
74705
74714
  }
74706
- if (N.angle !== 0) {
74707
- const q = rotatePoint({ x: re, y: K }, V, N.angle);
74708
- re = q.x, K = q.y;
74715
+ if (O.angle !== 0) {
74716
+ const J = rotatePoint({ x: K, y: te }, z, O.angle);
74717
+ K = J.x, te = J.y;
74709
74718
  }
74710
- let te = R;
74711
- if (w === "justify" && D.slice(-1) !== `
74719
+ let q = _;
74720
+ if (S === "justify" && H.slice(-1) !== `
74712
74721
  `) {
74713
- const q = P.segment(U)[Symbol.iterator](), J = Array.from(q).length;
74714
- te += (T - Y) / J;
74715
- }
74716
- d.pushOperators(u.setCharacterSpacing(te)), d.drawText(U, {
74717
- x: re,
74718
- y: K,
74719
- rotate: N,
74720
- size: m,
74721
- color: E,
74722
- lineHeight: $ * m,
74723
- font: I,
74724
- opacity: k
74722
+ const J = D.segment(Y)[Symbol.iterator](), ne = Array.from(J).length;
74723
+ q += (B - ee) / ne;
74724
+ }
74725
+ d.pushOperators(u.setCharacterSpacing(q)), d.drawText(Y, {
74726
+ x: K,
74727
+ y: te,
74728
+ rotate: O,
74729
+ size: E,
74730
+ color: w,
74731
+ lineHeight: R * E,
74732
+ font: C,
74733
+ opacity: V
74725
74734
  });
74726
74735
  });
74727
74736
  }, substituteVariables = (a, s, c) => {
@@ -74780,6 +74789,14 @@ const ArrowUpToLine = [
74780
74789
  ["path", { d: "m18 13-6-6-6 6" }],
74781
74790
  ["path", { d: "M12 7v14" }]
74782
74791
  ];
74792
+ const Bold = [
74793
+ ["path", { d: "M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8" }]
74794
+ ];
74795
+ const Italic = [
74796
+ ["line", { x1: "19", x2: "10", y1: "4", y2: "4" }],
74797
+ ["line", { x1: "14", x2: "5", y1: "20", y2: "20" }],
74798
+ ["line", { x1: "15", x2: "9", y1: "4", y2: "20" }]
74799
+ ];
74783
74800
  const Strikethrough = [
74784
74801
  ["path", { d: "M16 4H9a3 3 0 0 0-2.83 4" }],
74785
74802
  ["path", { d: "M14 12a4 4 0 0 1 0 8H6" }],
@@ -74813,13 +74830,15 @@ const Type = [
74813
74830
  const Underline = [
74814
74831
  ["path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }],
74815
74832
  ["line", { x1: "4", x2: "20", y1: "20", y2: "20" }]
74816
- ], TextStrikethroughIcon = createSvgStr(Strikethrough), TextUnderlineIcon = createSvgStr(Underline), TextAlignLeftIcon = createSvgStr(TextAlignStart), TextAlignCenterIcon = createSvgStr(TextAlignCenter), TextAlignRightIcon = createSvgStr(TextAlignEnd), TextAlignJustifyIcon = createSvgStr(TextAlignJustify), TextVerticalAlignTopIcon = createSvgStr(ArrowUpToLine), TextVerticalAlignMiddleIcon = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"><path d="M8 19h3v4h2v-4h3l-4-4l-4 4zm8-14h-3V1h-2v4H8l4 4l4-4zM4 11v2h16v-2H4z" fill="currentColor"></path></svg>', TextVerticalAlignBottomIcon = createSvgStr(ArrowDownToLine);
74833
+ ], TextBoldIcon = createSvgStr(Bold), TextItalicIcon = createSvgStr(Italic), TextStrikethroughIcon = createSvgStr(Strikethrough), TextUnderlineIcon = createSvgStr(Underline), TextAlignLeftIcon = createSvgStr(TextAlignStart), TextAlignCenterIcon = createSvgStr(TextAlignCenter), TextAlignRightIcon = createSvgStr(TextAlignEnd), TextAlignJustifyIcon = createSvgStr(TextAlignJustify), TextVerticalAlignTopIcon = createSvgStr(ArrowUpToLine), TextVerticalAlignMiddleIcon = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"><path d="M8 19h3v4h2v-4h3l-4-4l-4 4zm8-14h-3V1h-2v4H8l4 4l4-4zM4 11v2h16v-2H4z" fill="currentColor"></path></svg>', TextVerticalAlignBottomIcon = createSvgStr(ArrowDownToLine);
74817
74834
  var Formatter;
74818
74835
  (function(a) {
74819
- a.STRIKETHROUGH = "strikethrough", a.UNDERLINE = "underline", a.ALIGNMENT = "alignment", a.VERTICAL_ALIGNMENT = "verticalAlignment";
74836
+ a.BOLD = "bold", a.ITALIC = "italic", a.STRIKETHROUGH = "strikethrough", a.UNDERLINE = "underline", a.ALIGNMENT = "alignment", a.VERTICAL_ALIGNMENT = "verticalAlignment";
74820
74837
  })(Formatter || (Formatter = {}));
74821
74838
  function getExtraFormatterSchema(a) {
74822
74839
  const s = [
74840
+ { key: Formatter.BOLD, icon: TextBoldIcon, type: "boolean" },
74841
+ { key: Formatter.ITALIC, icon: TextItalicIcon, type: "boolean" },
74823
74842
  { key: Formatter.STRIKETHROUGH, icon: TextStrikethroughIcon, type: "boolean" },
74824
74843
  { key: Formatter.UNDERLINE, icon: TextUnderlineIcon, type: "boolean" },
74825
74844
  { key: Formatter.ALIGNMENT, icon: TextAlignLeftIcon, type: "select", value: DEFAULT_ALIGNMENT },
@@ -74985,6 +75004,8 @@ const UseDynamicFontSize = (a) => {
74985
75004
  fontName: void 0,
74986
75005
  backgroundColor: "",
74987
75006
  opacity: DEFAULT_OPACITY,
75007
+ bold: false,
75008
+ italic: false,
74988
75009
  strikethrough: false,
74989
75010
  underline: false
74990
75011
  }
@@ -75159,42 +75180,42 @@ const UseDynamicFontSize = (a) => {
75159
75180
  };
75160
75181
  return a.split(/(\r\n|\n|\r)/).map((p) => /\r\n|\n|\r/.test(p) ? p : p.split("").map((v) => /\s/.test(v) || v.charCodeAt(0) < 32 || u(v) ? v : "〿").join("")).join("");
75161
75182
  }, uiRender$1 = async (a) => {
75162
- const { value: s, schema: c, mode: u, onChange: d, stopEditing: p, tabIndex: v, placeholder: A, options: x, _cache: g } = a, b = isEditable(u, c) && A && !s, y = (S) => {
75163
- let $ = S.innerText;
75164
- return $.endsWith(`
75165
- `) && ($ = $.slice(0, -1)), $;
75166
- }, f = x?.font || getDefaultFont(), m = await getFontKitFont(c.fontName, f, g), E = buildStyledTextContainer(a, m, b ? A : s), w = replaceUnsupportedChars(s, m);
75183
+ const { value: s, schema: c, mode: u, onChange: d, stopEditing: p, tabIndex: v, placeholder: A, options: x, _cache: g } = a, b = isEditable(u, c) && A && !s, y = ($) => {
75184
+ let R = $.innerText;
75185
+ return R.endsWith(`
75186
+ `) && (R = R.slice(0, -1)), R;
75187
+ }, f = x?.font || getDefaultFont(), m = resolveFontName(c.fontName, c.bold, c.italic, f), E = await getFontKitFont(m, f, g), w = buildStyledTextContainer(a, E, b ? A : s), S = replaceUnsupportedChars(s, E);
75167
75188
  if (!isEditable(u, c)) {
75168
- E.innerHTML = w.split("").map((S, $) => `<span style="letter-spacing:${String(s).length === $ + 1 ? 0 : "inherit"};">${S}</span>`).join("");
75189
+ w.innerHTML = S.split("").map(($, R) => `<span style="letter-spacing:${String(s).length === R + 1 ? 0 : "inherit"};">${$}</span>`).join("");
75169
75190
  return;
75170
75191
  }
75171
- if (makeElementPlainTextContentEditable(E), E.tabIndex = v || 0, E.innerText = u === "designer" ? s : w, E.addEventListener("blur", (S) => {
75172
- d && d({ key: "content", value: y(S.target) }), p && p();
75192
+ if (makeElementPlainTextContentEditable(w), w.tabIndex = v || 0, w.innerText = u === "designer" ? s : S, w.addEventListener("blur", ($) => {
75193
+ d && d({ key: "content", value: y($.target) }), p && p();
75173
75194
  }), c.dynamicFontSize) {
75174
- let S;
75175
- E.addEventListener("keyup", () => {
75195
+ let $;
75196
+ w.addEventListener("keyup", () => {
75176
75197
  setTimeout(() => {
75177
75198
  (() => {
75178
- if (!E.textContent)
75199
+ if (!w.textContent)
75179
75200
  return;
75180
- S = calculateDynamicFontSize({
75201
+ $ = calculateDynamicFontSize({
75181
75202
  textSchema: c,
75182
- fontKitFont: m,
75183
- value: y(E),
75184
- startingFontSize: S
75185
- }), E.style.fontSize = `${S}pt`;
75186
- const { topAdj: $, bottomAdj: R } = getBrowserVerticalFontAdjustments(m, S ?? c.fontSize ?? DEFAULT_FONT_SIZE, c.lineHeight ?? DEFAULT_LINE_HEIGHT, c.verticalAlignment ?? DEFAULT_VERTICAL_ALIGNMENT);
75187
- E.style.paddingTop = `${$}px`, E.style.marginBottom = `${R}px`;
75203
+ fontKitFont: E,
75204
+ value: y(w),
75205
+ startingFontSize: $
75206
+ }), w.style.fontSize = `${$}pt`;
75207
+ const { topAdj: R, bottomAdj: _ } = getBrowserVerticalFontAdjustments(E, $ ?? c.fontSize ?? DEFAULT_FONT_SIZE, c.lineHeight ?? DEFAULT_LINE_HEIGHT, c.verticalAlignment ?? DEFAULT_VERTICAL_ALIGNMENT);
75208
+ w.style.paddingTop = `${R}px`, w.style.marginBottom = `${_}px`;
75188
75209
  })();
75189
75210
  }, 0);
75190
75211
  });
75191
75212
  }
75192
- b && (E.style.color = PLACEHOLDER_FONT_COLOR, E.addEventListener("focus", () => {
75193
- E.innerText === A && (E.innerText = "", E.style.color = c.fontColor ?? DEFAULT_FONT_COLOR);
75213
+ b && (w.style.color = PLACEHOLDER_FONT_COLOR, w.addEventListener("focus", () => {
75214
+ w.innerText === A && (w.innerText = "", w.style.color = c.fontColor ?? DEFAULT_FONT_COLOR);
75194
75215
  })), u === "designer" && setTimeout(() => {
75195
- E.focus();
75196
- const S = window.getSelection(), $ = document.createRange();
75197
- S && $ && ($.selectNodeContents(E), $.collapse(false), S?.removeAllRanges(), S?.addRange($));
75216
+ w.focus();
75217
+ const $ = window.getSelection(), R = document.createRange();
75218
+ $ && R && (R.selectNodeContents(w), R.collapse(false), $?.removeAllRanges(), $?.addRange(R));
75198
75219
  });
75199
75220
  }, buildStyledTextContainer = (a, s, c) => {
75200
75221
  const { schema: u, rootElement: d, mode: p } = a;
@@ -75223,6 +75244,8 @@ const UseDynamicFontSize = (a) => {
75223
75244
  const E = {
75224
75245
  // Font formatting styles
75225
75246
  fontFamily: u.fontName ? `'${u.fontName}'` : "inherit",
75247
+ fontWeight: u.bold ? "bold" : "normal",
75248
+ fontStyle: u.italic ? "italic" : "normal",
75226
75249
  color: u.fontColor ? u.fontColor : DEFAULT_FONT_COLOR,
75227
75250
  fontSize: `${v ?? u.fontSize ?? DEFAULT_FONT_SIZE}pt`,
75228
75251
  letterSpacing: `${u.characterSpacing ?? DEFAULT_CHARACTER_SPACING}pt`,
@@ -1,4 +1,6 @@
1
1
  export declare enum Formatter {
2
+ BOLD = "bold",
3
+ ITALIC = "italic",
2
4
  STRIKETHROUGH = "strikethrough",
3
5
  UNDERLINE = "underline",
4
6
  ALIGNMENT = "alignment",
@@ -10,6 +10,7 @@ export declare const getFontDescentInPt: (fontKitFont: FontKitFont, fontSize: nu
10
10
  export declare const heightOfFontAtSize: (fontKitFont: FontKitFont, fontSize: number) => number;
11
11
  export declare const widthOfTextAtSize: (text: string, fontKitFont: FontKitFont, fontSize: number, characterSpacing: number) => number;
12
12
  export declare const getFontKitFont: (fontName: string | undefined, font: Font, _cache: Map<string | number, fontkit.Font>) => Promise<fontkit.Font>;
13
+ export declare const resolveFontName: (fontName: string | undefined, bold: boolean | undefined, italic: boolean | undefined, font: Font) => string;
13
14
  /**
14
15
  * Recursively splits the line at getSplitPosition.
15
16
  * If there is some leftover, split the rest again in the same manner.
@@ -1,3 +1,5 @@
1
+ export declare const TextBoldIcon: string;
2
+ export declare const TextItalicIcon: string;
1
3
  export declare const TextStrikethroughIcon: string;
2
4
  export declare const TextUnderlineIcon: string;
3
5
  export declare const TextAlignLeftIcon: string;
@@ -15,6 +15,8 @@ export interface TextSchema extends Schema {
15
15
  verticalAlignment: VERTICAL_ALIGNMENT;
16
16
  fontSize: number;
17
17
  lineHeight: number;
18
+ bold?: boolean;
19
+ italic?: boolean;
18
20
  strikethrough?: boolean;
19
21
  underline?: boolean;
20
22
  characterSpacing: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@campxdev/pdfme",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "sideEffects": false,
5
5
  "author": "hand-dot",
6
6
  "license": "MIT",