@pdfme/schemas 5.3.5 → 5.3.7-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 (110) hide show
  1. package/dist/node/__tests__/barcode.test.js +332 -0
  2. package/dist/node/__tests__/barcode.test.js.map +1 -0
  3. package/dist/node/__tests__/multiVariableText.test.js +96 -0
  4. package/dist/node/__tests__/multiVariableText.test.js.map +1 -0
  5. package/dist/node/__tests__/text.test.js +409 -0
  6. package/dist/node/__tests__/text.test.js.map +1 -0
  7. package/dist/node/__tests__/utils.test.js +132 -0
  8. package/dist/node/__tests__/utils.test.js.map +1 -0
  9. package/dist/node/src/barcodes/constants.js +20 -0
  10. package/dist/node/src/barcodes/constants.js.map +1 -0
  11. package/dist/node/src/barcodes/helper.js +145 -0
  12. package/dist/node/src/barcodes/helper.js.map +1 -0
  13. package/dist/node/src/barcodes/index.js +18 -0
  14. package/dist/node/src/barcodes/index.js.map +1 -0
  15. package/dist/node/src/barcodes/pdfRender.js +25 -0
  16. package/dist/node/src/barcodes/pdfRender.js.map +1 -0
  17. package/dist/node/src/barcodes/propPanel.js +228 -0
  18. package/dist/node/src/barcodes/propPanel.js.map +1 -0
  19. package/dist/node/src/barcodes/types.js +3 -0
  20. package/dist/node/src/barcodes/types.js.map +1 -0
  21. package/dist/node/src/barcodes/uiRender.js +89 -0
  22. package/dist/node/src/barcodes/uiRender.js.map +1 -0
  23. package/dist/node/src/checkbox/index.js +61 -0
  24. package/dist/node/src/checkbox/index.js.map +1 -0
  25. package/dist/node/src/constants.js +6 -0
  26. package/dist/node/src/constants.js.map +1 -0
  27. package/dist/node/src/date/date.js +9 -0
  28. package/dist/node/src/date/date.js.map +1 -0
  29. package/dist/node/src/date/dateTime.js +9 -0
  30. package/dist/node/src/date/dateTime.js.map +1 -0
  31. package/dist/node/src/date/helper.js +420 -0
  32. package/dist/node/src/date/helper.js.map +1 -0
  33. package/dist/node/src/date/time.js +9 -0
  34. package/dist/node/src/date/time.js.map +1 -0
  35. package/dist/node/src/date/types.js +3 -0
  36. package/dist/node/src/date/types.js.map +1 -0
  37. package/dist/node/src/graphics/cacheKey.js +6 -0
  38. package/dist/node/src/graphics/cacheKey.js.map +1 -0
  39. package/dist/node/src/graphics/image.js +167 -0
  40. package/dist/node/src/graphics/image.js.map +1 -0
  41. package/dist/node/src/graphics/imagehelper.js +124 -0
  42. package/dist/node/src/graphics/imagehelper.js.map +1 -0
  43. package/dist/node/src/graphics/svg.js +85 -0
  44. package/dist/node/src/graphics/svg.js.map +1 -0
  45. package/dist/node/src/index.js +38 -0
  46. package/dist/node/src/index.js.map +1 -0
  47. package/dist/node/src/multiVariableText/helper.js +46 -0
  48. package/dist/node/src/multiVariableText/helper.js.map +1 -0
  49. package/dist/node/src/multiVariableText/index.js +16 -0
  50. package/dist/node/src/multiVariableText/index.js.map +1 -0
  51. package/dist/node/src/multiVariableText/pdfRender.js +20 -0
  52. package/dist/node/src/multiVariableText/pdfRender.js.map +1 -0
  53. package/dist/node/src/multiVariableText/propPanel.js +130 -0
  54. package/dist/node/src/multiVariableText/propPanel.js.map +1 -0
  55. package/dist/node/src/multiVariableText/types.js +3 -0
  56. package/dist/node/src/multiVariableText/types.js.map +1 -0
  57. package/dist/node/src/multiVariableText/uiRender.js +138 -0
  58. package/dist/node/src/multiVariableText/uiRender.js.map +1 -0
  59. package/dist/node/src/radioGroup/index.js +93 -0
  60. package/dist/node/src/radioGroup/index.js.map +1 -0
  61. package/dist/node/src/select/index.js +164 -0
  62. package/dist/node/src/select/index.js.map +1 -0
  63. package/dist/node/src/shapes/line.js +60 -0
  64. package/dist/node/src/shapes/line.js.map +1 -0
  65. package/dist/node/src/shapes/rectAndEllipse.js +122 -0
  66. package/dist/node/src/shapes/rectAndEllipse.js.map +1 -0
  67. package/dist/node/src/tables/cell.js +126 -0
  68. package/dist/node/src/tables/cell.js.map +1 -0
  69. package/dist/node/src/tables/classes.js +467 -0
  70. package/dist/node/src/tables/classes.js.map +1 -0
  71. package/dist/node/src/tables/dynamicTemplate.js +17 -0
  72. package/dist/node/src/tables/dynamicTemplate.js.map +1 -0
  73. package/dist/node/src/tables/helper.js +189 -0
  74. package/dist/node/src/tables/helper.js.map +1 -0
  75. package/dist/node/src/tables/index.js +15 -0
  76. package/dist/node/src/tables/index.js.map +1 -0
  77. package/dist/node/src/tables/pdfRender.js +95 -0
  78. package/dist/node/src/tables/pdfRender.js.map +1 -0
  79. package/dist/node/src/tables/propPanel.js +101 -0
  80. package/dist/node/src/tables/propPanel.js.map +1 -0
  81. package/dist/node/src/tables/tableHelper.js +196 -0
  82. package/dist/node/src/tables/tableHelper.js.map +1 -0
  83. package/dist/node/src/tables/types.js +3 -0
  84. package/dist/node/src/tables/types.js.map +1 -0
  85. package/dist/node/src/tables/uiRender.js +367 -0
  86. package/dist/node/src/tables/uiRender.js.map +1 -0
  87. package/dist/node/src/text/constants.js +97 -0
  88. package/dist/node/src/text/constants.js.map +1 -0
  89. package/dist/node/src/text/extraFormatter.js +48 -0
  90. package/dist/node/src/text/extraFormatter.js.map +1 -0
  91. package/dist/node/src/text/helper.js +472 -0
  92. package/dist/node/src/text/helper.js.map +1 -0
  93. package/dist/node/src/text/icons/index.js +16 -0
  94. package/dist/node/src/text/icons/index.js.map +1 -0
  95. package/dist/node/src/text/index.js +15 -0
  96. package/dist/node/src/text/index.js.map +1 -0
  97. package/dist/node/src/text/pdfRender.js +156 -0
  98. package/dist/node/src/text/pdfRender.js.map +1 -0
  99. package/dist/node/src/text/propPanel.js +161 -0
  100. package/dist/node/src/text/propPanel.js.map +1 -0
  101. package/dist/node/src/text/types.js +3 -0
  102. package/dist/node/src/text/types.js.map +1 -0
  103. package/dist/node/src/text/uiRender.js +223 -0
  104. package/dist/node/src/text/uiRender.js.map +1 -0
  105. package/dist/node/src/utils.js +190 -0
  106. package/dist/node/src/utils.js.map +1 -0
  107. package/package.json +11 -4
  108. package/tsconfig.cjs.json +1 -1
  109. package/tsconfig.esm.json +1 -1
  110. package/tsconfig.node.json +10 -0
@@ -0,0 +1,472 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.filterEndJP = exports.filterStartJP = exports.isFirefox = exports.splitTextToSize = exports.calculateDynamicFontSize = exports.getSplittedLines = exports.getFontKitFont = exports.widthOfTextAtSize = exports.heightOfFontAtSize = exports.getFontDescentInPt = exports.getBrowserVerticalFontAdjustments = void 0;
27
+ const fontkit = __importStar(require("fontkit"));
28
+ const common_1 = require("@pdfme/common");
29
+ const buffer_1 = require("buffer");
30
+ const constants_js_1 = require("./constants.js");
31
+ const getBrowserVerticalFontAdjustments = (fontKitFont, fontSize, lineHeight, verticalAlignment) => {
32
+ const { ascent, descent, unitsPerEm } = fontKitFont;
33
+ // Fonts have a designed line height that the browser renders when using `line-height: normal`
34
+ const fontBaseLineHeight = (ascent - descent) / unitsPerEm;
35
+ // For vertical alignment top
36
+ // To achieve consistent positioning between browser and PDF, we apply the difference between
37
+ // the font's actual height and the font size in pixels.
38
+ // Browsers middle the font within this height, so we only need half of it to apply to the top.
39
+ // This means the font renders a bit lower in the browser, but achieves PDF alignment
40
+ const topAdjustment = (fontBaseLineHeight * fontSize - fontSize) / 2;
41
+ if (verticalAlignment === constants_js_1.VERTICAL_ALIGN_TOP) {
42
+ return { topAdj: (0, common_1.pt2px)(topAdjustment), bottomAdj: 0 };
43
+ }
44
+ // For vertical alignment bottom and middle
45
+ // When browsers render text in a non-form element (such as a <div>), some of the text may be
46
+ // lowered below and outside the containing element if the line height used is less than
47
+ // the base line-height of the font.
48
+ // This behaviour does not happen in a <textarea> though, so we need to adjust the positioning
49
+ // for consistency between editing and viewing to stop text jumping up and down.
50
+ // This portion of text is half of the difference between the base line height and the used
51
+ // line height. If using the same or higher line-height than the base font, then line-height
52
+ // takes over in the browser and this adjustment is not needed.
53
+ // Unlike the top adjustment - this is only driven by browser behaviour, not PDF alignment.
54
+ let bottomAdjustment = 0;
55
+ if (lineHeight < fontBaseLineHeight) {
56
+ bottomAdjustment = ((fontBaseLineHeight - lineHeight) * fontSize) / 2;
57
+ }
58
+ return { topAdj: 0, bottomAdj: (0, common_1.pt2px)(bottomAdjustment) };
59
+ };
60
+ exports.getBrowserVerticalFontAdjustments = getBrowserVerticalFontAdjustments;
61
+ const getFontDescentInPt = (fontKitFont, fontSize) => {
62
+ const { descent, unitsPerEm } = fontKitFont;
63
+ return (descent / unitsPerEm) * fontSize;
64
+ };
65
+ exports.getFontDescentInPt = getFontDescentInPt;
66
+ const heightOfFontAtSize = (fontKitFont, fontSize) => {
67
+ const { ascent, descent, bbox, unitsPerEm } = fontKitFont;
68
+ const scale = 1000 / unitsPerEm;
69
+ const yTop = (ascent || bbox.maxY) * scale;
70
+ const yBottom = (descent || bbox.minY) * scale;
71
+ let height = yTop - yBottom;
72
+ height -= Math.abs(descent * scale) || 0;
73
+ return (height / 1000) * fontSize;
74
+ };
75
+ exports.heightOfFontAtSize = heightOfFontAtSize;
76
+ const calculateCharacterSpacing = (textContent, textCharacterSpacing) => {
77
+ return (textContent.length - 1) * textCharacterSpacing;
78
+ };
79
+ const widthOfTextAtSize = (text, fontKitFont, fontSize, characterSpacing) => {
80
+ const { glyphs } = fontKitFont.layout(text);
81
+ const scale = 1000 / fontKitFont.unitsPerEm;
82
+ const standardWidth = glyphs.reduce((totalWidth, glyph) => totalWidth + glyph.advanceWidth * scale, 0) *
83
+ (fontSize / 1000);
84
+ return standardWidth + calculateCharacterSpacing(text, characterSpacing);
85
+ };
86
+ exports.widthOfTextAtSize = widthOfTextAtSize;
87
+ const getFallbackFont = (font) => {
88
+ const fallbackFontName = (0, common_1.getFallbackFontName)(font);
89
+ return font[fallbackFontName];
90
+ };
91
+ const getCacheKey = (fontName) => `getFontKitFont-${fontName}`;
92
+ const getFontKitFont = async (fontName, font, _cache) => {
93
+ const fntNm = fontName || (0, common_1.getFallbackFontName)(font);
94
+ const cacheKey = getCacheKey(fntNm);
95
+ if (_cache.has(cacheKey)) {
96
+ return _cache.get(cacheKey);
97
+ }
98
+ const currentFont = font[fntNm] || getFallbackFont(font) || (0, common_1.getDefaultFont)()[common_1.DEFAULT_FONT_NAME];
99
+ let fontData = currentFont.data;
100
+ if (typeof fontData === 'string') {
101
+ fontData = fontData.startsWith('http')
102
+ ? await fetch(fontData).then((res) => res.arrayBuffer())
103
+ : (0, common_1.b64toUint8Array)(fontData);
104
+ }
105
+ const fontKitFont = fontkit.create(fontData instanceof buffer_1.Buffer ? fontData : buffer_1.Buffer.from(fontData));
106
+ _cache.set(cacheKey, fontKitFont);
107
+ return fontKitFont;
108
+ };
109
+ exports.getFontKitFont = getFontKitFont;
110
+ const isTextExceedingBoxWidth = (text, calcValues) => {
111
+ const { font, fontSize, characterSpacing, boxWidthInPt } = calcValues;
112
+ const textWidth = (0, exports.widthOfTextAtSize)(text, font, fontSize, characterSpacing);
113
+ return textWidth > boxWidthInPt;
114
+ };
115
+ /**
116
+ * Incrementally checks the current line for its real length
117
+ * and returns the position where it exceeds the box width.
118
+ * Returns `null` to indicate if textLine is shorter than the available box.
119
+ */
120
+ const getOverPosition = (textLine, calcValues) => {
121
+ for (let i = 0; i <= textLine.length; i++) {
122
+ if (isTextExceedingBoxWidth(textLine.slice(0, i + 1), calcValues)) {
123
+ return i;
124
+ }
125
+ }
126
+ return null;
127
+ };
128
+ /**
129
+ * Line breakable chars depend on the language and writing system.
130
+ * Western writing systems typically use spaces and hyphens as line breakable chars.
131
+ * Other writing systems often break on word boundaries so the following
132
+ * does not negatively impact them.
133
+ * However, this might need to be revisited for broader language support.
134
+ */
135
+ const isLineBreakableChar = (char) => {
136
+ const lineBreakableChars = [' ', '-', '\u2014', '\u2013'];
137
+ return lineBreakableChars.includes(char);
138
+ };
139
+ /**
140
+ * Gets the position of the split. Splits the exceeding line at
141
+ * the last breakable char prior to it exceeding the bounding box width.
142
+ */
143
+ const getSplitPosition = (textLine, calcValues) => {
144
+ const overPos = getOverPosition(textLine, calcValues);
145
+ if (overPos === null)
146
+ return textLine.length; // input line is shorter than the available space
147
+ if (textLine[overPos] === ' ') {
148
+ // if the character immediately beyond the boundary is a space, split
149
+ return overPos;
150
+ }
151
+ let overPosTmp = overPos - 1;
152
+ while (overPosTmp >= 0) {
153
+ if (isLineBreakableChar(textLine[overPosTmp])) {
154
+ return overPosTmp + 1;
155
+ }
156
+ overPosTmp--;
157
+ }
158
+ // For very long lines with no breakable chars use the original overPos
159
+ return overPos;
160
+ };
161
+ /**
162
+ * Recursively splits the line at getSplitPosition.
163
+ * If there is some leftover, split the rest again in the same manner.
164
+ */
165
+ const getSplittedLines = (textLine, calcValues) => {
166
+ const splitPos = getSplitPosition(textLine, calcValues);
167
+ const splittedLine = textLine.substring(0, splitPos).trimEnd();
168
+ const rest = textLine.substring(splitPos).trimStart();
169
+ if (rest === textLine) {
170
+ // if we went so small that we want to split on the first char
171
+ // then end recursion to avoid infinite loop
172
+ return [textLine];
173
+ }
174
+ if (rest.length === 0) {
175
+ // end recursion if there is no leftover
176
+ return [splittedLine];
177
+ }
178
+ return [splittedLine, ...(0, exports.getSplittedLines)(rest, calcValues)];
179
+ };
180
+ exports.getSplittedLines = getSplittedLines;
181
+ /**
182
+ * If using dynamic font size, iteratively increment or decrement the
183
+ * font size to fit the containing box.
184
+ * Calculating space usage involves splitting lines where they exceed
185
+ * the box width based on the proposed size.
186
+ */
187
+ const calculateDynamicFontSize = ({ textSchema, fontKitFont, value, startingFontSize, }) => {
188
+ const { fontSize: schemaFontSize, dynamicFontSize: dynamicFontSizeSetting, characterSpacing: schemaCharacterSpacing, width: boxWidth, height: boxHeight, lineHeight = constants_js_1.DEFAULT_LINE_HEIGHT, } = textSchema;
189
+ const fontSize = startingFontSize || schemaFontSize || constants_js_1.DEFAULT_FONT_SIZE;
190
+ if (!dynamicFontSizeSetting)
191
+ return fontSize;
192
+ if (dynamicFontSizeSetting.max < dynamicFontSizeSetting.min)
193
+ return fontSize;
194
+ const characterSpacing = schemaCharacterSpacing ?? constants_js_1.DEFAULT_CHARACTER_SPACING;
195
+ const paragraphs = value.split('\n');
196
+ let dynamicFontSize = fontSize;
197
+ if (dynamicFontSize < dynamicFontSizeSetting.min) {
198
+ dynamicFontSize = dynamicFontSizeSetting.min;
199
+ }
200
+ else if (dynamicFontSize > dynamicFontSizeSetting.max) {
201
+ dynamicFontSize = dynamicFontSizeSetting.max;
202
+ }
203
+ const dynamicFontFit = dynamicFontSizeSetting.fit ?? constants_js_1.DEFAULT_DYNAMIC_FIT;
204
+ const calculateConstraints = (size) => {
205
+ let totalWidthInMm = 0;
206
+ let totalHeightInMm = 0;
207
+ const boxWidthInPt = (0, common_1.mm2pt)(boxWidth);
208
+ const firstLineTextHeight = (0, exports.heightOfFontAtSize)(fontKitFont, size);
209
+ const firstLineHeightInMm = (0, common_1.pt2mm)(firstLineTextHeight * lineHeight);
210
+ const otherRowHeightInMm = (0, common_1.pt2mm)(size * lineHeight);
211
+ paragraphs.forEach((paragraph, paraIndex) => {
212
+ const lines = getSplittedLinesBySegmenter(paragraph, {
213
+ font: fontKitFont,
214
+ fontSize: size,
215
+ characterSpacing,
216
+ boxWidthInPt,
217
+ });
218
+ lines.forEach((line, lineIndex) => {
219
+ if (dynamicFontFit === constants_js_1.DYNAMIC_FIT_VERTICAL) {
220
+ // For vertical fit we want to consider the width of text lines where we detect a split
221
+ const textWidth = (0, exports.widthOfTextAtSize)(line.replace('\n', ''), fontKitFont, size, characterSpacing);
222
+ const textWidthInMm = (0, common_1.pt2mm)(textWidth);
223
+ totalWidthInMm = Math.max(totalWidthInMm, textWidthInMm);
224
+ }
225
+ if (paraIndex + lineIndex === 0) {
226
+ totalHeightInMm += firstLineHeightInMm;
227
+ }
228
+ else {
229
+ totalHeightInMm += otherRowHeightInMm;
230
+ }
231
+ });
232
+ if (dynamicFontFit === constants_js_1.DYNAMIC_FIT_HORIZONTAL) {
233
+ // For horizontal fit we want to consider the line's width 'unsplit'
234
+ const textWidth = (0, exports.widthOfTextAtSize)(paragraph, fontKitFont, size, characterSpacing);
235
+ const textWidthInMm = (0, common_1.pt2mm)(textWidth);
236
+ totalWidthInMm = Math.max(totalWidthInMm, textWidthInMm);
237
+ }
238
+ });
239
+ return { totalWidthInMm, totalHeightInMm };
240
+ };
241
+ const shouldFontGrowToFit = (totalWidthInMm, totalHeightInMm) => {
242
+ if (dynamicFontSize >= dynamicFontSizeSetting.max) {
243
+ return false;
244
+ }
245
+ if (dynamicFontFit === constants_js_1.DYNAMIC_FIT_HORIZONTAL) {
246
+ return totalWidthInMm < boxWidth;
247
+ }
248
+ return totalHeightInMm < boxHeight;
249
+ };
250
+ const shouldFontShrinkToFit = (totalWidthInMm, totalHeightInMm) => {
251
+ if (dynamicFontSize <= dynamicFontSizeSetting.min || dynamicFontSize <= 0) {
252
+ return false;
253
+ }
254
+ return totalWidthInMm > boxWidth || totalHeightInMm > boxHeight;
255
+ };
256
+ let { totalWidthInMm, totalHeightInMm } = calculateConstraints(dynamicFontSize);
257
+ // Attempt to increase the font size up to desired fit
258
+ while (shouldFontGrowToFit(totalWidthInMm, totalHeightInMm)) {
259
+ dynamicFontSize += constants_js_1.FONT_SIZE_ADJUSTMENT;
260
+ const { totalWidthInMm: newWidth, totalHeightInMm: newHeight } = calculateConstraints(dynamicFontSize);
261
+ if (newHeight < boxHeight) {
262
+ totalWidthInMm = newWidth;
263
+ totalHeightInMm = newHeight;
264
+ }
265
+ else {
266
+ dynamicFontSize -= constants_js_1.FONT_SIZE_ADJUSTMENT;
267
+ break;
268
+ }
269
+ }
270
+ // Attempt to decrease the font size down to desired fit
271
+ while (shouldFontShrinkToFit(totalWidthInMm, totalHeightInMm)) {
272
+ dynamicFontSize -= constants_js_1.FONT_SIZE_ADJUSTMENT;
273
+ ({ totalWidthInMm, totalHeightInMm } = calculateConstraints(dynamicFontSize));
274
+ }
275
+ return dynamicFontSize;
276
+ };
277
+ exports.calculateDynamicFontSize = calculateDynamicFontSize;
278
+ const splitTextToSize = (arg) => {
279
+ const { value, characterSpacing, fontSize, fontKitFont, boxWidthInPt } = arg;
280
+ const fontWidthCalcValues = {
281
+ font: fontKitFont,
282
+ fontSize,
283
+ characterSpacing,
284
+ boxWidthInPt,
285
+ };
286
+ let lines = [];
287
+ value.split(/\r\n|\r|\n|\f|\u000B/g).forEach((line) => {
288
+ lines = lines.concat(getSplittedLinesBySegmenter(line, fontWidthCalcValues));
289
+ });
290
+ return lines;
291
+ };
292
+ exports.splitTextToSize = splitTextToSize;
293
+ const isFirefox = () => navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
294
+ exports.isFirefox = isFirefox;
295
+ const getSplittedLinesBySegmenter = (line, calcValues) => {
296
+ // nothing to process but need to keep this for new lines.
297
+ if (line.trim() === '') {
298
+ return [''];
299
+ }
300
+ const { font, fontSize, characterSpacing, boxWidthInPt } = calcValues;
301
+ const segmenter = new Intl.Segmenter(undefined, { granularity: 'word' });
302
+ const iterator = segmenter.segment(line.trimEnd())[Symbol.iterator]();
303
+ let lines = [];
304
+ let lineCounter = 0;
305
+ let currentTextSize = 0;
306
+ while (true) {
307
+ const chunk = iterator.next();
308
+ if (chunk.done)
309
+ break;
310
+ const segment = chunk.value.segment;
311
+ const textWidth = (0, exports.widthOfTextAtSize)(segment, font, fontSize, characterSpacing);
312
+ if (currentTextSize + textWidth <= boxWidthInPt) {
313
+ // the size of boxWidth is large enough to add the segment
314
+ if (lines[lineCounter]) {
315
+ lines[lineCounter] += segment;
316
+ currentTextSize += textWidth + characterSpacing;
317
+ }
318
+ else {
319
+ lines[lineCounter] = segment;
320
+ currentTextSize = textWidth + characterSpacing;
321
+ }
322
+ }
323
+ else if (segment.trim() === '') {
324
+ // a segment can be consist of multiple spaces like ' '
325
+ // if they overflow the box, treat them as a line break and move to the next line
326
+ lines[++lineCounter] = '';
327
+ currentTextSize = 0;
328
+ }
329
+ else if (textWidth <= boxWidthInPt) {
330
+ // the segment is small enough to be added to the next line
331
+ lines[++lineCounter] = segment;
332
+ currentTextSize = textWidth + characterSpacing;
333
+ }
334
+ else {
335
+ // the segment is too large to fit in the boxWidth, we wrap the segment
336
+ for (const char of segment) {
337
+ const size = (0, exports.widthOfTextAtSize)(char, font, fontSize, characterSpacing);
338
+ if (currentTextSize + size <= boxWidthInPt) {
339
+ if (lines[lineCounter]) {
340
+ lines[lineCounter] += char;
341
+ currentTextSize += size + characterSpacing;
342
+ }
343
+ else {
344
+ lines[lineCounter] = char;
345
+ currentTextSize = size + characterSpacing;
346
+ }
347
+ }
348
+ else {
349
+ lines[++lineCounter] = char;
350
+ currentTextSize = size + characterSpacing;
351
+ }
352
+ }
353
+ }
354
+ }
355
+ if (lines.some(containsJapanese)) {
356
+ return adjustEndOfLine((0, exports.filterEndJP)((0, exports.filterStartJP)(lines)));
357
+ }
358
+ else {
359
+ return adjustEndOfLine(lines);
360
+ }
361
+ };
362
+ // add a newline if the line is the end of the paragraph
363
+ const adjustEndOfLine = (lines) => {
364
+ return lines.map((line, index) => {
365
+ if (index === lines.length - 1) {
366
+ return line.trimEnd() + '\n';
367
+ }
368
+ else {
369
+ return line.trimEnd();
370
+ }
371
+ });
372
+ };
373
+ function containsJapanese(text) {
374
+ return /[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/u.test(text);
375
+ }
376
+ //
377
+ // 日本語禁則処理
378
+ //
379
+ // https://www.morisawa.co.jp/blogs/MVP/8760
380
+ //
381
+ // 行頭禁則
382
+ const filterStartJP = (lines) => {
383
+ const filtered = [];
384
+ let charToAppend = null;
385
+ lines
386
+ .slice()
387
+ .reverse()
388
+ .forEach((line) => {
389
+ if (line.trim().length === 0) {
390
+ filtered.push('');
391
+ }
392
+ else {
393
+ const charAtStart = line.charAt(0);
394
+ if (constants_js_1.LINE_START_FORBIDDEN_CHARS.includes(charAtStart)) {
395
+ if (line.trim().length === 1) {
396
+ filtered.push(line);
397
+ charToAppend = null;
398
+ }
399
+ else {
400
+ if (charToAppend) {
401
+ filtered.push(line.slice(1) + charToAppend);
402
+ }
403
+ else {
404
+ filtered.push(line.slice(1));
405
+ }
406
+ charToAppend = charAtStart;
407
+ }
408
+ }
409
+ else {
410
+ if (charToAppend) {
411
+ filtered.push(line + charToAppend);
412
+ charToAppend = null;
413
+ }
414
+ else {
415
+ filtered.push(line);
416
+ }
417
+ }
418
+ }
419
+ });
420
+ if (charToAppend) {
421
+ return [charToAppend + filtered.slice(0, 1)[0], ...filtered.slice(1)].reverse();
422
+ }
423
+ else {
424
+ return filtered.reverse();
425
+ }
426
+ };
427
+ exports.filterStartJP = filterStartJP;
428
+ // 行末禁則
429
+ const filterEndJP = (lines) => {
430
+ const filtered = [];
431
+ let charToPrepend = null;
432
+ lines.forEach((line) => {
433
+ if (line.trim().length === 0) {
434
+ filtered.push('');
435
+ }
436
+ else {
437
+ const chartAtEnd = line.slice(-1);
438
+ if (constants_js_1.LINE_END_FORBIDDEN_CHARS.includes(chartAtEnd)) {
439
+ if (line.trim().length === 1) {
440
+ filtered.push(line);
441
+ charToPrepend = null;
442
+ }
443
+ else {
444
+ if (charToPrepend) {
445
+ filtered.push(charToPrepend + line.slice(0, -1));
446
+ }
447
+ else {
448
+ filtered.push(line.slice(0, -1));
449
+ }
450
+ charToPrepend = chartAtEnd;
451
+ }
452
+ }
453
+ else {
454
+ if (charToPrepend) {
455
+ filtered.push(charToPrepend + line);
456
+ charToPrepend = null;
457
+ }
458
+ else {
459
+ filtered.push(line);
460
+ }
461
+ }
462
+ }
463
+ });
464
+ if (charToPrepend) {
465
+ return [...filtered.slice(0, -1), filtered.slice(-1)[0] + charToPrepend];
466
+ }
467
+ else {
468
+ return filtered;
469
+ }
470
+ };
471
+ exports.filterEndJP = filterEndJP;
472
+ //# sourceMappingURL=helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../../src/text/helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AAEnC,0CASuB;AACvB,mCAAgC;AAEhC,iDAWwB;AAEjB,MAAM,iCAAiC,GAAG,CAC/C,WAAwB,EACxB,QAAgB,EAChB,UAAkB,EAClB,iBAAyB,EACzB,EAAE;IACF,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,WAAW,CAAC;IAEpD,8FAA8F;IAC9F,MAAM,kBAAkB,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,GAAG,UAAU,CAAC;IAE3D,6BAA6B;IAC7B,6FAA6F;IAC7F,wDAAwD;IACxD,+FAA+F;IAC/F,qFAAqF;IACrF,MAAM,aAAa,GAAG,CAAC,kBAAkB,GAAG,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;IAErE,IAAI,iBAAiB,KAAK,iCAAkB,EAAE;QAC5C,OAAO,EAAE,MAAM,EAAE,IAAA,cAAK,EAAC,aAAa,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;KACvD;IAED,2CAA2C;IAC3C,6FAA6F;IAC7F,wFAAwF;IACxF,oCAAoC;IACpC,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,CAAC,UAAU,CAAC,EAAE;gBACjD,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE;oBAC5B,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBACpB,aAAa,GAAG,IAAI,CAAC;iBACtB;qBAAM;oBACL,IAAI,aAAa,EAAE;wBACjB,QAAQ,CAAC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;qBAClD;yBAAM;wBACL,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;qBAClC;oBACD,aAAa,GAAG,UAAU,CAAC;iBAC5B;aACF;iBAAM;gBACL,IAAI,aAAa,EAAE;oBACjB,QAAQ,CAAC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;oBACpC,aAAa,GAAG,IAAI,CAAC;iBACtB;qBAAM;oBACL,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBACrB;aACF;SACF;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,aAAa,EAAE;QACjB,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC;KAC1E;SAAM;QACL,OAAO,QAAQ,CAAC;KACjB;AACH,CAAC,CAAC;AAtCW,QAAA,WAAW,eAsCtB"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TextVerticalAlignBottomIcon = exports.TextVerticalAlignMiddleIcon = exports.TextVerticalAlignTopIcon = exports.TextAlignJustifyIcon = exports.TextAlignRightIcon = exports.TextAlignCenterIcon = exports.TextAlignLeftIcon = exports.TextUnderlineIcon = exports.TextStrikethroughIcon = void 0;
4
+ const lucide_1 = require("lucide");
5
+ const utils_js_1 = require("../../utils.js");
6
+ exports.TextStrikethroughIcon = (0, utils_js_1.createSvgStr)(lucide_1.Strikethrough);
7
+ exports.TextUnderlineIcon = (0, utils_js_1.createSvgStr)(lucide_1.Underline);
8
+ exports.TextAlignLeftIcon = (0, utils_js_1.createSvgStr)(lucide_1.AlignLeft);
9
+ exports.TextAlignCenterIcon = (0, utils_js_1.createSvgStr)(lucide_1.AlignCenter);
10
+ exports.TextAlignRightIcon = (0, utils_js_1.createSvgStr)(lucide_1.AlignRight);
11
+ exports.TextAlignJustifyIcon = (0, utils_js_1.createSvgStr)(lucide_1.AlignJustify);
12
+ exports.TextVerticalAlignTopIcon = (0, utils_js_1.createSvgStr)(lucide_1.ArrowUpToLine);
13
+ // svg icons are material icons from https://www.xicons.org
14
+ exports.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>`;
15
+ exports.TextVerticalAlignBottomIcon = (0, utils_js_1.createSvgStr)(lucide_1.ArrowDownToLine);
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/text/icons/index.ts"],"names":[],"mappings":";;;AAAA,mCASgB;AAChB,6CAA8C;AAEjC,QAAA,qBAAqB,GAAG,IAAA,uBAAY,EAAC,sBAAa,CAAC,CAAC;AAEpD,QAAA,iBAAiB,GAAG,IAAA,uBAAY,EAAC,kBAAS,CAAC,CAAC;AAE5C,QAAA,iBAAiB,GAAG,IAAA,uBAAY,EAAC,kBAAS,CAAC,CAAC;AAE5C,QAAA,mBAAmB,GAAG,IAAA,uBAAY,EAAC,oBAAW,CAAC,CAAC;AAEhD,QAAA,kBAAkB,GAAG,IAAA,uBAAY,EAAC,mBAAU,CAAC,CAAC;AAE9C,QAAA,oBAAoB,GAAG,IAAA,uBAAY,EAAC,qBAAY,CAAC,CAAC;AAElD,QAAA,wBAAwB,GAAG,IAAA,uBAAY,EAAC,sBAAa,CAAC,CAAC;AAEpE,2DAA2D;AAC9C,QAAA,2BAA2B,GAAG,0NAA0N,CAAC;AAEzP,QAAA,2BAA2B,GAAG,IAAA,uBAAY,EAAC,wBAAe,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const pdfRender_js_1 = require("./pdfRender.js");
4
+ const propPanel_js_1 = require("./propPanel.js");
5
+ const uiRender_js_1 = require("./uiRender.js");
6
+ const lucide_1 = require("lucide");
7
+ const utils_js_1 = require("../utils.js");
8
+ const textSchema = {
9
+ pdf: pdfRender_js_1.pdfRender,
10
+ ui: uiRender_js_1.uiRender,
11
+ propPanel: propPanel_js_1.propPanel,
12
+ icon: (0, utils_js_1.createSvgStr)(lucide_1.TextCursorInput),
13
+ };
14
+ exports.default = textSchema;
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/text/index.ts"],"names":[],"mappings":";;AACA,iDAA2C;AAC3C,iDAA2C;AAC3C,+CAAyC;AAEzC,mCAAyC;AACzC,0CAA2C;AAE3C,MAAM,UAAU,GAAuB;IACrC,GAAG,EAAE,wBAAS;IACd,EAAE,EAAE,sBAAQ;IACZ,SAAS,EAAT,wBAAS;IACT,IAAI,EAAE,IAAA,uBAAY,EAAC,wBAAe,CAAC;CACpC,CAAC;AAEF,kBAAe,UAAU,CAAC"}