@pdfme/schemas 3.0.1 → 3.1.0-dev.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 (92) hide show
  1. package/dist/cjs/__tests__/barcode.test.js +6 -15
  2. package/dist/cjs/__tests__/barcode.test.js.map +1 -1
  3. package/dist/cjs/__tests__/renderUtils.test.js +0 -7
  4. package/dist/cjs/__tests__/renderUtils.test.js.map +1 -1
  5. package/dist/cjs/__tests__/text.test.js +49 -58
  6. package/dist/cjs/__tests__/text.test.js.map +1 -1
  7. package/dist/cjs/src/barcodes/helper.js +5 -14
  8. package/dist/cjs/src/barcodes/helper.js.map +1 -1
  9. package/dist/cjs/src/barcodes/index.js +6 -6
  10. package/dist/cjs/src/barcodes/index.js.map +1 -1
  11. package/dist/cjs/src/barcodes/pdfRender.js +12 -18
  12. package/dist/cjs/src/barcodes/pdfRender.js.map +1 -1
  13. package/dist/cjs/src/barcodes/propPanel.js +107 -19
  14. package/dist/cjs/src/barcodes/propPanel.js.map +1 -1
  15. package/dist/cjs/src/barcodes/uiRender.js +44 -26
  16. package/dist/cjs/src/barcodes/uiRender.js.map +1 -1
  17. package/dist/cjs/src/image/index.js +4 -4
  18. package/dist/cjs/src/image/index.js.map +1 -1
  19. package/dist/cjs/src/image/pdfRender.js +7 -15
  20. package/dist/cjs/src/image/pdfRender.js.map +1 -1
  21. package/dist/cjs/src/image/uiRender.js +19 -17
  22. package/dist/cjs/src/image/uiRender.js.map +1 -1
  23. package/dist/cjs/src/index.js +10 -10
  24. package/dist/cjs/src/index.js.map +1 -1
  25. package/dist/cjs/src/renderUtils.js +12 -3
  26. package/dist/cjs/src/renderUtils.js.map +1 -1
  27. package/dist/cjs/src/text/helper.js +18 -28
  28. package/dist/cjs/src/text/helper.js.map +1 -1
  29. package/dist/cjs/src/text/index.js +4 -4
  30. package/dist/cjs/src/text/index.js.map +1 -1
  31. package/dist/cjs/src/text/pdfRender.js +31 -41
  32. package/dist/cjs/src/text/pdfRender.js.map +1 -1
  33. package/dist/cjs/src/text/propPanel.js +55 -35
  34. package/dist/cjs/src/text/propPanel.js.map +1 -1
  35. package/dist/cjs/src/text/uiRender.js +27 -33
  36. package/dist/cjs/src/text/uiRender.js.map +1 -1
  37. package/dist/esm/__tests__/barcode.test.js +6 -15
  38. package/dist/esm/__tests__/barcode.test.js.map +1 -1
  39. package/dist/esm/__tests__/renderUtils.test.js +1 -8
  40. package/dist/esm/__tests__/renderUtils.test.js.map +1 -1
  41. package/dist/esm/__tests__/text.test.js +49 -58
  42. package/dist/esm/__tests__/text.test.js.map +1 -1
  43. package/dist/esm/src/barcodes/helper.js +4 -13
  44. package/dist/esm/src/barcodes/helper.js.map +1 -1
  45. package/dist/esm/src/barcodes/index.js +4 -4
  46. package/dist/esm/src/barcodes/index.js.map +1 -1
  47. package/dist/esm/src/barcodes/pdfRender.js +9 -15
  48. package/dist/esm/src/barcodes/pdfRender.js.map +1 -1
  49. package/dist/esm/src/barcodes/propPanel.js +104 -16
  50. package/dist/esm/src/barcodes/propPanel.js.map +1 -1
  51. package/dist/esm/src/barcodes/uiRender.js +43 -25
  52. package/dist/esm/src/barcodes/uiRender.js.map +1 -1
  53. package/dist/esm/src/image/index.js +3 -3
  54. package/dist/esm/src/image/index.js.map +1 -1
  55. package/dist/esm/src/image/pdfRender.js +5 -13
  56. package/dist/esm/src/image/pdfRender.js.map +1 -1
  57. package/dist/esm/src/image/uiRender.js +19 -17
  58. package/dist/esm/src/image/uiRender.js.map +1 -1
  59. package/dist/esm/src/index.js +4 -4
  60. package/dist/esm/src/index.js.map +1 -1
  61. package/dist/esm/src/renderUtils.js +10 -1
  62. package/dist/esm/src/renderUtils.js.map +1 -1
  63. package/dist/esm/src/text/helper.js +9 -19
  64. package/dist/esm/src/text/helper.js.map +1 -1
  65. package/dist/esm/src/text/index.js +3 -3
  66. package/dist/esm/src/text/index.js.map +1 -1
  67. package/dist/esm/src/text/pdfRender.js +20 -30
  68. package/dist/esm/src/text/pdfRender.js.map +1 -1
  69. package/dist/esm/src/text/propPanel.js +46 -26
  70. package/dist/esm/src/text/propPanel.js.map +1 -1
  71. package/dist/esm/src/text/uiRender.js +23 -29
  72. package/dist/esm/src/text/uiRender.js.map +1 -1
  73. package/dist/types/src/barcodes/types.d.ts +1 -1
  74. package/dist/types/src/index.d.ts +5 -5
  75. package/dist/types/src/renderUtils.d.ts +1 -1
  76. package/package.json +5 -3
  77. package/src/barcodes/helper.ts +1 -1
  78. package/src/barcodes/index.ts +4 -4
  79. package/src/barcodes/pdfRender.ts +7 -3
  80. package/src/barcodes/propPanel.ts +13 -9
  81. package/src/barcodes/types.ts +1 -1
  82. package/src/barcodes/uiRender.ts +5 -3
  83. package/src/image/index.ts +3 -3
  84. package/src/image/pdfRender.ts +4 -2
  85. package/src/image/uiRender.ts +4 -2
  86. package/src/index.ts +4 -4
  87. package/src/renderUtils.ts +9 -1
  88. package/src/text/helper.ts +1 -1
  89. package/src/text/index.ts +3 -3
  90. package/src/text/pdfRender.ts +3 -3
  91. package/src/text/propPanel.ts +44 -24
  92. package/src/text/uiRender.ts +13 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/schemas",
3
- "version": "3.0.1",
3
+ "version": "3.1.0-dev.1",
4
4
  "sideEffects": false,
5
5
  "author": "hand-dot",
6
6
  "license": "MIT",
@@ -21,13 +21,15 @@
21
21
  "bugs": {
22
22
  "url": "https://github.com/pdfme/pdfme/issues"
23
23
  },
24
+ "type": "module",
24
25
  "main": "dist/cjs/src/index.js",
25
26
  "module": "dist/esm/src/index.js",
26
27
  "types": "dist/types/src/index.d.ts",
27
28
  "exports": {
28
29
  ".": {
29
30
  "import": "./dist/esm/src/index.js",
30
- "require": "./dist/cjs/src/index.js"
31
+ "require": "./dist/cjs/src/index.js",
32
+ "types": "./dist/types/src/index.d.ts"
31
33
  }
32
34
  },
33
35
  "engines": {
@@ -35,7 +37,7 @@
35
37
  },
36
38
  "scripts": {
37
39
  "develop": "tsc -p tsconfig.esm.json -w",
38
- "build": "npm run build:cjs && npm run build:esm",
40
+ "build": "npm-run-all --parallel build:cjs build:esm",
39
41
  "build:cjs": "tsc -p tsconfig.cjs.json",
40
42
  "build:esm": "tsc -p tsconfig.esm.json",
41
43
  "clean": "rimraf dist",
@@ -1,7 +1,7 @@
1
1
  import { b64toUint8Array } from '@pdfme/common';
2
2
  import bwipjs, { RenderOptions } from 'bwip-js';
3
3
  import { Buffer } from 'buffer';
4
- import { BARCODE_TYPES } from './constants';
4
+ import { BARCODE_TYPES } from './constants.js';
5
5
  import { BarcodeTypes } from './types';
6
6
 
7
7
  // GTIN-13, GTIN-8, GTIN-12, GTIN-14
@@ -1,8 +1,8 @@
1
- import { pdfRender } from './pdfRender';
2
- import { getPropPanelByBarcodeType } from './propPanel';
3
- import { uiRender } from './uiRender';
1
+ import { pdfRender } from './pdfRender.js';
2
+ import { getPropPanelByBarcodeType } from './propPanel.js';
3
+ import { uiRender } from './uiRender.js';
4
4
  import type { BarcodeSchema, BarcodeTypes } from './types';
5
- import { BARCODE_TYPES } from './constants';
5
+ import { BARCODE_TYPES } from './constants.js';
6
6
  import { Plugin } from '@pdfme/common';
7
7
 
8
8
  const schemas = BARCODE_TYPES.reduce(
@@ -1,13 +1,17 @@
1
1
  import { PDFRenderProps } from '@pdfme/common';
2
- import { getCacheKey, convertForPdfLayoutProps } from '../renderUtils';
2
+ import { convertForPdfLayoutProps } from '../renderUtils.js';
3
3
  import type { BarcodeSchema } from './types';
4
- import { createBarCode, validateBarcodeInput } from './helper';
4
+ import { createBarCode, validateBarcodeInput } from './helper.js';
5
+
6
+ const getBarcodeCacheKey = (schema: BarcodeSchema, value: string) => {
7
+ return `${schema.type}${schema.backgroundColor}${schema.barColor}${schema.textColor}${value}`;
8
+ };
5
9
 
6
10
  export const pdfRender = async (arg: PDFRenderProps<BarcodeSchema>) => {
7
11
  const { value, schema, pdfDoc, page, _cache } = arg;
8
12
  if (!validateBarcodeInput(schema.type, value)) return;
9
13
 
10
- const inputBarcodeCacheKey = getCacheKey(schema, value);
14
+ const inputBarcodeCacheKey = getBarcodeCacheKey(schema, value);
11
15
  let image = _cache.get(inputBarcodeCacheKey);
12
16
  if (!image) {
13
17
  const imageBuf = await createBarCode(
@@ -1,6 +1,6 @@
1
1
  import type { PropPanel } from '@pdfme/common';
2
2
  import type { BarcodeSchema } from './types';
3
- import { DEFAULT_BARCODE_COLOR, DEFAULT_BARCODE_BG_COLOR } from './constants';
3
+ import { DEFAULT_BARCODE_COLOR, DEFAULT_BARCODE_BG_COLOR } from './constants.js';
4
4
 
5
5
  const defaultColors = {
6
6
  backgroundColor: DEFAULT_BARCODE_BG_COLOR,
@@ -140,16 +140,20 @@ const barcodeDefaults: { defaultValue: string; defaultSchema: BarcodeSchema }[]
140
140
  export const getPropPanelByBarcodeType = (barcodeType: string): PropPanel<BarcodeSchema> => {
141
141
  const barcodeHasText = barcodeType !== 'qrcode' && barcodeType !== 'gs1datamatrix';
142
142
 
143
- const schema = {
144
- barColor: { title: 'Bar Color', type: 'string', widget: 'color' },
145
- backgroundColor: { title: 'Background', type: 'string', widget: 'color' },
146
- ...(barcodeHasText
147
- ? { textColor: { title: 'Text Color', type: 'string', widget: 'color' } }
148
- : {}),
149
- };
150
143
  const defaults = barcodeDefaults.find(({ defaultSchema }) => defaultSchema.type === barcodeType);
151
144
 
152
145
  if (!defaults) throw new Error(`[@pdfme/schemas] No default for barcode type ${barcodeType}`);
153
146
 
154
- return { schema, ...defaults };
147
+ return {
148
+ schema: ({ i18n }) => {
149
+ return {
150
+ barColor: { title: i18n('schemas.barcodes.barColor'), type: 'string', widget: 'color' },
151
+ backgroundColor: { title: i18n('schemas.bgColor'), type: 'string', widget: 'color' },
152
+ ...(barcodeHasText
153
+ ? { textColor: { title: i18n('schemas.textColor'), type: 'string', widget: 'color' } }
154
+ : {}),
155
+ };
156
+ },
157
+ ...defaults,
158
+ };
155
159
  };
@@ -1,5 +1,5 @@
1
1
  import { Schema } from '@pdfme/common';
2
- import { BARCODE_TYPES } from './constants';
2
+ import { BARCODE_TYPES } from './constants.js';
3
3
 
4
4
  export interface BarcodeSchema extends Schema {
5
5
  type: (typeof BARCODE_TYPES)[number];
@@ -1,7 +1,8 @@
1
1
  import type * as CSS from 'csstype';
2
2
  import { UIRenderProps } from '@pdfme/common';
3
3
  import type { BarcodeSchema } from './types';
4
- import { validateBarcodeInput, createBarCode } from './helper';
4
+ import { validateBarcodeInput, createBarCode } from './helper.js';
5
+ import { addAlphaToHex } from '../renderUtils.js';
5
6
 
6
7
  const fullSize = { width: '100%', height: '100%' };
7
8
 
@@ -60,7 +61,8 @@ const createBarcodeImageElm = async (schema: BarcodeSchema, value: string) => {
60
61
  };
61
62
 
62
63
  export const uiRender = async (arg: UIRenderProps<BarcodeSchema>) => {
63
- const { value, rootElement, mode, onChange, stopEditing, tabIndex, placeholder, schema } = arg;
64
+ const { value, rootElement, mode, onChange, stopEditing, tabIndex, placeholder, schema, theme } =
65
+ arg;
64
66
 
65
67
  const container = document.createElement('div');
66
68
  const containerStyle: CSS.Properties = {
@@ -81,7 +83,7 @@ export const uiRender = async (arg: UIRenderProps<BarcodeSchema>) => {
81
83
  textAlign: 'center',
82
84
  fontSize: '1rem',
83
85
  color: '#000',
84
- backgroundColor: editable || value ? 'rgb(242 244 255 / 75%)' : 'none',
86
+ backgroundColor: editable || value ? addAlphaToHex(theme.colorPrimaryBg, 30) : 'none',
85
87
  border: 'none',
86
88
  display: 'flex',
87
89
  alignItems: 'center',
@@ -1,7 +1,7 @@
1
1
  import type { Plugin } from '@pdfme/common';
2
- import { pdfRender } from './pdfRender';
3
- import { propPanel } from './propPanel';
4
- import { uiRender } from './uiRender';
2
+ import { pdfRender } from './pdfRender.js';
3
+ import { propPanel } from './propPanel.js';
4
+ import { uiRender } from './uiRender.js';
5
5
  import type { ImageSchema } from './types';
6
6
 
7
7
  const schema: Plugin<ImageSchema> = { pdf: pdfRender, ui: uiRender, propPanel };
@@ -1,6 +1,8 @@
1
- import type { PDFRenderProps } from '@pdfme/common';
1
+ import type { PDFRenderProps, Schema } from '@pdfme/common';
2
2
  import type { ImageSchema } from './types';
3
- import { getCacheKey, convertForPdfLayoutProps } from '../renderUtils';
3
+ import { convertForPdfLayoutProps } from '../renderUtils.js';
4
+
5
+ const getCacheKey = (schema: Schema, input: string) => `${schema.type}${input}`;
4
6
 
5
7
  export const pdfRender = async (arg: PDFRenderProps<ImageSchema>) => {
6
8
  const { value, schema, pdfDoc, page, _cache } = arg;
@@ -2,6 +2,7 @@ import type { ChangeEvent } from 'react';
2
2
  import type * as CSS from 'csstype';
3
3
  import type { ImageSchema } from './types';
4
4
  import { UIRenderProps, ZOOM } from '@pdfme/common';
5
+ import { addAlphaToHex } from '../renderUtils.js';
5
6
 
6
7
  const fullSize = { width: '100%', height: '100%' };
7
8
 
@@ -34,7 +35,8 @@ const readFile = (input: File | FileList | null): Promise<string | ArrayBuffer>
34
35
  });
35
36
 
36
37
  export const uiRender = async (arg: UIRenderProps<ImageSchema>) => {
37
- const { value, rootElement, mode, onChange, stopEditing, tabIndex, placeholder, schema } = arg;
38
+ const { value, rootElement, mode, onChange, stopEditing, tabIndex, placeholder, schema, theme } =
39
+ arg;
38
40
  const editable = mode === 'form' || mode === 'designer';
39
41
 
40
42
  const size = { width: schema.width * ZOOM, height: schema.height * ZOOM };
@@ -97,7 +99,7 @@ export const uiRender = async (arg: UIRenderProps<ImageSchema>) => {
97
99
  display: editable ? 'flex' : 'none',
98
100
  position: 'absolute',
99
101
  top: 0,
100
- backgroundColor: editable || value ? 'rgb(242 244 255 / 50%)' : 'none',
102
+ backgroundColor: editable || value ? addAlphaToHex(theme.colorPrimaryBg, 30) : 'none',
101
103
  cursor: 'pointer',
102
104
  };
103
105
  Object.assign(label.style, labelStyle);
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
- import text from './text';
2
- import image from './image';
3
- import barcodes from './barcodes';
4
- import { convertForPdfLayoutProps, rotatePoint } from './renderUtils';
1
+ import text from './text/index.js';
2
+ import image from './image/index.js';
3
+ import barcodes from './barcodes/index.js';
4
+ import { convertForPdfLayoutProps, rotatePoint } from './renderUtils.js';
5
5
 
6
6
  const builtInPlugins = { Text: text };
7
7
 
@@ -61,4 +61,12 @@ export const rotatePoint = (
61
61
  return { x, y };
62
62
  };
63
63
 
64
- export const getCacheKey = (schema: Schema, input: string) => `${schema.type}${input}`;
64
+ export const addAlphaToHex = (hex: string, alphaPercentage: number) => {
65
+ if (!/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/i.test(hex)) {
66
+ throw new Error('Invalid HEX color code');
67
+ }
68
+ const alphaValue = Math.round((alphaPercentage / 100) * 255);
69
+ let alphaHex = alphaValue.toString(16);
70
+ if (alphaHex.length === 1) alphaHex = '0' + alphaHex;
71
+ return hex + alphaHex;
72
+ };
@@ -22,7 +22,7 @@ import {
22
22
  DYNAMIC_FIT_HORIZONTAL,
23
23
  DYNAMIC_FIT_VERTICAL,
24
24
  VERTICAL_ALIGN_TOP,
25
- } from './constants';
25
+ } from './constants.js';
26
26
 
27
27
  export const getBrowserVerticalFontAdjustments = (
28
28
  fontKitFont: FontKitFont,
package/src/text/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { Plugin } from '@pdfme/common';
2
- import { pdfRender } from './pdfRender';
3
- import { propPanel } from './propPanel';
4
- import { uiRender } from './uiRender';
2
+ import { pdfRender } from './pdfRender.js';
3
+ import { propPanel } from './propPanel.js';
4
+ import { uiRender } from './uiRender.js';
5
5
  import type { TextSchema } from './types';
6
6
 
7
7
  const schema: Plugin<TextSchema> = { pdf: pdfRender, ui: uiRender, propPanel };
@@ -11,7 +11,7 @@ import {
11
11
  DEFAULT_LINE_HEIGHT,
12
12
  DEFAULT_CHARACTER_SPACING,
13
13
  DEFAULT_FONT_COLOR,
14
- } from './constants';
14
+ } from './constants.js';
15
15
  import {
16
16
  calculateDynamicFontSize,
17
17
  heightOfFontAtSize,
@@ -19,8 +19,8 @@ import {
19
19
  getFontKitFont,
20
20
  getSplittedLines,
21
21
  widthOfTextAtSize,
22
- } from './helper';
23
- import { convertForPdfLayoutProps, rotatePoint } from '../renderUtils';
22
+ } from './helper.js';
23
+ import { convertForPdfLayoutProps, rotatePoint } from '../renderUtils.js';
24
24
 
25
25
  const hex2rgb = (hex: string) => {
26
26
  if (hex.slice(0, 1) === '#') hex = hex.slice(1);
@@ -23,10 +23,10 @@ import {
23
23
  DEFAULT_DYNAMIC_MAX_FONT_SIZE,
24
24
  ALIGN_RIGHT,
25
25
  ALIGN_CENTER,
26
- } from './constants';
26
+ } from './constants.js';
27
27
 
28
28
  const UseDynamicFontSize = (props: PropPanelWidgetProps) => {
29
- const { rootElement, changeSchemas, activeSchema } = props;
29
+ const { rootElement, changeSchemas, activeSchema, i18n } = props;
30
30
 
31
31
  const checkbox = document.createElement('input');
32
32
  checkbox.type = 'checkbox';
@@ -42,14 +42,14 @@ const UseDynamicFontSize = (props: PropPanelWidgetProps) => {
42
42
  changeSchemas([{ key: 'dynamicFontSize', value: val, schemaId: activeSchema.id }]);
43
43
  };
44
44
  const label = document.createElement('label');
45
- label.innerText = 'Dynamic Font Size';
45
+ label.innerText = i18n('schemas.text.dynamicFontSize') || '';
46
46
  label.style.cssText = 'display: flex; width: 100%;';
47
47
  label.appendChild(checkbox);
48
48
  rootElement.appendChild(label);
49
49
  };
50
50
 
51
51
  export const propPanel: PropPanel<TextSchema> = {
52
- schema: ({ options, activeSchema }) => {
52
+ schema: ({ options, activeSchema, i18n }) => {
53
53
  const font = options.font || { [DEFAULT_FONT_NAME]: { data: '', fallback: true } };
54
54
  const fontNames = Object.keys(font);
55
55
  const fallbackFontName = getFallbackFontName(font);
@@ -58,7 +58,7 @@ export const propPanel: PropPanel<TextSchema> = {
58
58
 
59
59
  const textSchema: Record<string, PropPanelSchema> = {
60
60
  fontName: {
61
- title: 'Font Name',
61
+ title: i18n('schemas.text.fontName'),
62
62
  type: 'string',
63
63
  widget: 'select',
64
64
  default: fallbackFontName,
@@ -66,64 +66,84 @@ export const propPanel: PropPanel<TextSchema> = {
66
66
  span: 12,
67
67
  },
68
68
  fontSize: {
69
- title: 'Size',
69
+ title: i18n('schemas.text.size'),
70
70
  type: 'number',
71
71
  widget: 'inputNumber',
72
72
  span: 6,
73
73
  disabled: enableDynamicFont,
74
74
  },
75
- characterSpacing: { title: 'Spacing', type: 'number', widget: 'inputNumber', span: 6 },
75
+ characterSpacing: {
76
+ title: i18n('schemas.text.spacing'),
77
+ type: 'number',
78
+ widget: 'inputNumber',
79
+ span: 6,
80
+ },
76
81
  alignment: {
77
- title: 'Text Align',
82
+ title: i18n('schemas.text.textAlign'),
78
83
  type: 'string',
79
84
  widget: 'select',
80
85
  props: {
81
86
  options: [
82
- { label: 'Left', value: DEFAULT_ALIGNMENT },
83
- { label: 'Center', value: ALIGN_CENTER },
84
- { label: 'Right', value: ALIGN_RIGHT },
87
+ { label: i18n('schemas.left'), value: DEFAULT_ALIGNMENT },
88
+ { label: i18n('schemas.center'), value: ALIGN_CENTER },
89
+ { label: i18n('schemas.right'), value: ALIGN_RIGHT },
85
90
  ],
86
91
  },
87
92
  span: 8,
88
93
  },
89
94
  verticalAlignment: {
90
- title: 'Vertical Align',
95
+ title: i18n('schemas.text.verticalAlign'),
91
96
  type: 'string',
92
97
  widget: 'select',
93
98
  props: {
94
99
  options: [
95
- { label: 'Top', value: VERTICAL_ALIGN_TOP },
96
- { label: 'Middle', value: VERTICAL_ALIGN_MIDDLE },
97
- { label: 'Bottom', value: VERTICAL_ALIGN_BOTTOM },
100
+ { label: i18n('schemas.top'), value: VERTICAL_ALIGN_TOP },
101
+ { label: i18n('schemas.middle'), value: VERTICAL_ALIGN_MIDDLE },
102
+ { label: i18n('schemas.bottom'), value: VERTICAL_ALIGN_BOTTOM },
98
103
  ],
99
104
  },
100
105
  span: 8,
101
106
  },
102
- lineHeight: { title: 'Line Height', type: 'number', widget: 'inputNumber', span: 8 },
103
- useDynamicFontSize: { type: 'boolean', widget: 'UseDynamicFontSize', bind: false },
107
+ lineHeight: {
108
+ title: i18n('schemas.text.lineHeight'),
109
+ type: 'number',
110
+ widget: 'inputNumber',
111
+ span: 8,
112
+ },
113
+ useDynamicFontSize: { type: 'boolean', widget: 'UseDynamicFontSize', bind: false, span: 16 },
104
114
  dynamicFontSize: {
105
115
  type: 'object',
106
116
  widget: 'card',
107
117
  column: 3,
108
118
  properties: {
109
- min: { title: 'Min', type: 'number', widget: 'inputNumber', hidden: !enableDynamicFont },
110
- max: { title: 'Max', type: 'number', widget: 'inputNumber', hidden: !enableDynamicFont },
119
+ min: {
120
+ title: i18n('schemas.text.min'),
121
+ type: 'number',
122
+ widget: 'inputNumber',
123
+ hidden: !enableDynamicFont,
124
+ },
125
+ max: {
126
+ title: i18n('schemas.text.max'),
127
+ type: 'number',
128
+ widget: 'inputNumber',
129
+ hidden: !enableDynamicFont,
130
+ },
111
131
  fit: {
112
- title: 'Fit',
132
+ title: i18n('schemas.text.fit'),
113
133
  type: 'string',
114
134
  widget: 'select',
115
135
  hidden: !enableDynamicFont,
116
136
  props: {
117
137
  options: [
118
- { label: 'Horizontal', value: DYNAMIC_FIT_HORIZONTAL },
119
- { label: 'Vertical', value: DYNAMIC_FIT_VERTICAL },
138
+ { label: i18n('schemas.horizontal'), value: DYNAMIC_FIT_HORIZONTAL },
139
+ { label: i18n('schemas.vertical'), value: DYNAMIC_FIT_VERTICAL },
120
140
  ],
121
141
  },
122
142
  },
123
143
  },
124
144
  },
125
- fontColor: { title: 'Font Color', type: 'string', widget: 'color' },
126
- backgroundColor: { title: 'Background', type: 'string', widget: 'color' },
145
+ fontColor: { title: i18n('schemas.textColor'), type: 'string', widget: 'color' },
146
+ backgroundColor: { title: i18n('schemas.bgColor'), type: 'string', widget: 'color' },
127
147
  };
128
148
 
129
149
  return textSchema;
@@ -11,12 +11,13 @@ import {
11
11
  DEFAULT_LINE_HEIGHT,
12
12
  DEFAULT_CHARACTER_SPACING,
13
13
  DEFAULT_FONT_COLOR,
14
- } from './constants';
14
+ } from './constants.js';
15
15
  import {
16
16
  calculateDynamicFontSize,
17
17
  getFontKitFont,
18
18
  getBrowserVerticalFontAdjustments,
19
- } from './helper';
19
+ } from './helper.js';
20
+ import { addAlphaToHex } from '../renderUtils.js';
20
21
 
21
22
  const mapVerticalAlignToFlex = (verticalAlignmentValue: string | undefined) => {
22
23
  switch (verticalAlignmentValue) {
@@ -33,14 +34,15 @@ const mapVerticalAlignToFlex = (verticalAlignmentValue: string | undefined) => {
33
34
  const getBackgroundColor = (
34
35
  mode: 'form' | 'viewer' | 'designer',
35
36
  value: string,
36
- schema: Schema
37
+ schema: Schema,
38
+ defaultBackgroundColor: string
37
39
  ) => {
38
40
  if ((mode === 'form' || mode === 'designer') && value && schema.backgroundColor) {
39
41
  return schema.backgroundColor as string;
40
42
  } else if (mode === 'viewer') {
41
43
  return (schema.backgroundColor as string) ?? 'transparent';
42
44
  } else {
43
- return 'rgb(242 244 255 / 75%)';
45
+ return defaultBackgroundColor;
44
46
  }
45
47
  };
46
48
 
@@ -55,6 +57,7 @@ export const uiRender = async (arg: UIRenderProps<TextSchema>) => {
55
57
  tabIndex,
56
58
  placeholder,
57
59
  options,
60
+ theme,
58
61
  } = arg;
59
62
  const font = options?.font || getDefaultFont();
60
63
 
@@ -86,7 +89,12 @@ export const uiRender = async (arg: UIRenderProps<TextSchema>) => {
86
89
  const containerStyle: CSS.Properties = {
87
90
  padding: 0,
88
91
  resize: 'none',
89
- backgroundColor: getBackgroundColor(mode, value, schema),
92
+ backgroundColor: getBackgroundColor(
93
+ mode,
94
+ value,
95
+ schema,
96
+ addAlphaToHex(theme.colorPrimaryBg, 30)
97
+ ),
90
98
  border: 'none',
91
99
  display: 'flex',
92
100
  flexDirection: 'column',