@pdfme/schemas 6.1.1 → 6.1.2-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/box.d.ts +45 -0
- package/dist/{builtins-CWHhKSVA.js → builtins-BB2DHceW.js} +482 -548
- package/dist/builtins-BB2DHceW.js.map +1 -0
- package/dist/builtins.d.ts +1 -1
- package/dist/builtins.js +1 -1
- package/dist/checkbox/index.d.ts +2 -2
- package/dist/dynamicLayout.d.ts +4 -0
- package/dist/dynamicLayout.js +20 -0
- package/dist/dynamicLayout.js.map +1 -0
- package/dist/{dynamicTemplate-DmuRoTw4.js → dynamicTemplate-B4GCNLF9.js} +19 -53
- package/dist/dynamicTemplate-B4GCNLF9.js.map +1 -0
- package/dist/{lists-B6dmgpkS.js → dynamicTemplate-BwzF9C1L.js} +3 -6
- package/dist/dynamicTemplate-BwzF9C1L.js.map +1 -0
- package/dist/dynamicTemplate-C7MdZxPm.js +75 -0
- package/dist/dynamicTemplate-C7MdZxPm.js.map +1 -0
- package/dist/graphics/image.d.ts +1 -1
- package/dist/graphics/signature.d.ts +1 -1
- package/dist/helper-CEme39Uo.js +40 -0
- package/dist/helper-CEme39Uo.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +268 -102
- package/dist/index.js.map +1 -1
- package/dist/list/types.d.ts +0 -5
- package/dist/lists.d.ts +2 -1
- package/dist/lists.js +3 -2
- package/dist/measure-L5diay3k.js +612 -0
- package/dist/measure-L5diay3k.js.map +1 -0
- package/dist/multiVariableText/dynamicTemplate.d.ts +2 -0
- package/dist/radioGroup/index.d.ts +2 -2
- package/dist/select/index.d.ts +2 -2
- package/dist/shapes/line.d.ts +1 -1
- package/dist/shapes/rectAndEllipse.d.ts +1 -2
- package/dist/{helper-M_MmV_d5.js → splitRange-DmVDtmzO.js} +132 -6
- package/dist/splitRange-DmVDtmzO.js.map +1 -0
- package/dist/splitRange.d.ts +16 -0
- package/dist/tables/helper.d.ts +12 -104
- package/dist/tables/types.d.ts +2 -6
- package/dist/tables.d.ts +1 -0
- package/dist/tables.js +3 -2
- package/dist/text/constants.d.ts +3 -0
- package/dist/text/dynamicTemplate.d.ts +2 -0
- package/dist/text/linkAnnotation.d.ts +14 -0
- package/dist/text/measure.d.ts +32 -0
- package/dist/text/overflow.d.ts +7 -0
- package/dist/text/richTextPdfRender.d.ts +3 -2
- package/dist/text/types.d.ts +7 -0
- package/dist/texts.d.ts +5 -0
- package/dist/texts.js +4 -0
- package/dist/types.d.ts +16 -0
- package/dist/types.js +0 -0
- package/dist/utils-zDZkqBnX.js +250 -0
- package/dist/utils-zDZkqBnX.js.map +1 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +3 -215
- package/package.json +16 -1
- package/dist/builtins-CWHhKSVA.js.map +0 -1
- package/dist/dynamicTemplate-DmuRoTw4.js.map +0 -1
- package/dist/helper-M_MmV_d5.js.map +0 -1
- package/dist/lists-B6dmgpkS.js.map +0 -1
- package/dist/utils.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as
|
|
3
|
-
import { a as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { $ as VERTICAL_ALIGN_MIDDLE, F as DEFAULT_FONT_COLOR, G as PLACEHOLDER_FONT_COLOR, K as SYNTHETIC_BOLD_CSS_TEXT_SHADOW, N as DEFAULT_ALIGNMENT, a as createListItemSplitRange, b as createBoxDimension, c as getListItemRange, h as getFontKitFont, i as TEXT_LINE_SPLIT_UNIT, j as CODE_BACKGROUND_COLOR, l as getTableBodyRange, n as LIST_ITEM_SPLIT_UNIT, o as createTableBodySplitRange, r as TABLE_BODY_SPLIT_UNIT, s as createTextLineSplitRange, t as BUILT_IN_DYNAMIC_LAYOUT_SPLIT_UNITS, u as getTextLineRange, x as getBoxContentArea } from "./splitRange-DmVDtmzO.js";
|
|
2
|
+
import { a as measureTextLines, d as isInlineMarkdownTextSchema, g as parseInlineMarkdown, p as resolveFontVariant } from "./measure-L5diay3k.js";
|
|
3
|
+
import { a as mapVerticalAlignToFlex, c as Formatter, i as makeElementPlainTextContentEditable, l as getExtraFormatterSchema, n as textSchema, o as uiRender$4, r as buildStyledTextContainer, s as propPanel$3, t as builtInPlugins, u as pdfRender$4 } from "./builtins-BB2DHceW.js";
|
|
4
|
+
import { a as getCellPropPanelSchema, c as HEX_COLOR_PATTERN, i as getBodyWithSchemaRange, l as createSingleTable, n as getDynamicLayoutForTable, o as getColumnStylesPropPanelSchema, r as getBody, s as getDefaultCellStyles, t as getDynamicHeightsForTable } from "./dynamicTemplate-B4GCNLF9.js";
|
|
5
|
+
import { c as isEditable, d as countUniqueVariableNames, f as getVariableNames, i as createSvgStr, l as readFile, n as convertForPdfLayoutProps, o as hex2PrintingColor, p as visitVariables, r as createErrorElm, t as addAlphaToHex, u as rotatePoint } from "./utils-zDZkqBnX.js";
|
|
6
|
+
import { a as normalizeListItems, c as LIST_STYLE_BULLET, i as normalizeListItemEntries, l as LIST_STYLE_ORDERED, n as calculateListLayout, o as serializeListItems, s as DEFAULT_LIST_STYLE, t as getDynamicLayoutForList } from "./dynamicTemplate-BwzF9C1L.js";
|
|
7
|
+
import { n as substituteVariablesAsInlineMarkdownLiterals, r as validateVariables, t as substituteVariables } from "./helper-CEme39Uo.js";
|
|
6
8
|
import "./tables.js";
|
|
7
|
-
import
|
|
9
|
+
import "./lists.js";
|
|
10
|
+
import { DEFAULT_FONT_NAME, ZOOM, b64toUint8Array, getDefaultFont, getFallbackFontName, getInternalLinkTarget, mm2pt, normalizeLinkHref, px2mm } from "@pdfme/common";
|
|
8
11
|
import { Buffer as Buffer$1 } from "buffer";
|
|
9
12
|
import { toRadians } from "@pdfme/pdf-lib";
|
|
10
13
|
import { Barcode, Calendar, CalendarClock, ChevronDown, Circle, CircleDot, Clock, Image, List, Minus, QrCode, Route, Square, SquareCheck, Table, Type } from "lucide";
|
|
@@ -36,45 +39,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
36
39
|
enumerable: true
|
|
37
40
|
}) : target, mod));
|
|
38
41
|
//#endregion
|
|
39
|
-
//#region src/multiVariableText/helper.ts
|
|
40
|
-
var substituteVariables = (text, variablesIn, valueMapper = (value) => value) => {
|
|
41
|
-
if (!text) return "";
|
|
42
|
-
let substitutedText = text;
|
|
43
|
-
if (variablesIn) {
|
|
44
|
-
let variables;
|
|
45
|
-
try {
|
|
46
|
-
variables = typeof variablesIn === "string" ? JSON.parse(variablesIn || "{}") : variablesIn;
|
|
47
|
-
} catch {
|
|
48
|
-
throw new SyntaxError(`[@pdfme/schemas] MVT: invalid JSON string '${variablesIn}'`);
|
|
49
|
-
}
|
|
50
|
-
Object.keys(variables).forEach((variableName) => {
|
|
51
|
-
const variableForRegex = variableName.replace(/[/\-\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
52
|
-
const regex = new RegExp("\\{" + variableForRegex + "\\}", "g");
|
|
53
|
-
substitutedText = substitutedText.replace(regex, valueMapper(variables[variableName], variableName));
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
substitutedText = substitutedText.replace(/{[^{}]+}/g, "");
|
|
57
|
-
return substitutedText;
|
|
58
|
-
};
|
|
59
|
-
var substituteVariablesAsInlineMarkdownLiterals = (text, variablesIn) => substituteVariables(text, variablesIn, escapeInlineMarkdown);
|
|
60
|
-
var validateVariables = (value, schema) => {
|
|
61
|
-
if (schema.variables.length === 0) return true;
|
|
62
|
-
let values;
|
|
63
|
-
try {
|
|
64
|
-
values = value ? JSON.parse(value) : {};
|
|
65
|
-
} catch {
|
|
66
|
-
throw new SyntaxError(`[@pdfme/generator] invalid JSON string '${value}' for variables in field ${schema.name}`);
|
|
67
|
-
}
|
|
68
|
-
for (const variable of schema.variables) if (!values[variable]) {
|
|
69
|
-
if (schema.required) throw new Error(`[@pdfme/generator] variable ${variable} is missing for field ${schema.name}`);
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
return true;
|
|
73
|
-
};
|
|
74
|
-
//#endregion
|
|
75
42
|
//#region src/multiVariableText/pdfRender.ts
|
|
76
43
|
var pdfRender$3 = async (arg) => {
|
|
77
44
|
const { value, schema, ...rest } = arg;
|
|
45
|
+
if (schema.readOnly) {
|
|
46
|
+
await pdfRender$4({
|
|
47
|
+
value,
|
|
48
|
+
schema,
|
|
49
|
+
...rest
|
|
50
|
+
});
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
78
53
|
if (!validateVariables(value, schema)) return;
|
|
79
54
|
await pdfRender$4({
|
|
80
55
|
value: isInlineMarkdownTextSchema(schema) ? substituteVariablesAsInlineMarkdownLiterals(schema.text || "", value) : substituteVariables(schema.text || "", value),
|
|
@@ -83,41 +58,6 @@ var pdfRender$3 = async (arg) => {
|
|
|
83
58
|
});
|
|
84
59
|
};
|
|
85
60
|
//#endregion
|
|
86
|
-
//#region src/multiVariableText/variables.ts
|
|
87
|
-
var visitVariables = (content, visitor) => {
|
|
88
|
-
let startIndex = -1;
|
|
89
|
-
for (let i = 0; i < content.length; i++) {
|
|
90
|
-
const char = content[i];
|
|
91
|
-
if (char === "{") {
|
|
92
|
-
startIndex = i;
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
if (char === "}" && startIndex !== -1) {
|
|
96
|
-
const name = content.slice(startIndex + 1, i);
|
|
97
|
-
if (name.length > 0) visitor({
|
|
98
|
-
name,
|
|
99
|
-
startIndex,
|
|
100
|
-
endIndex: i
|
|
101
|
-
});
|
|
102
|
-
startIndex = -1;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
var countUniqueVariableNames = (content) => {
|
|
107
|
-
const variableNames = /* @__PURE__ */ new Set();
|
|
108
|
-
visitVariables(content, ({ name }) => {
|
|
109
|
-
variableNames.add(name);
|
|
110
|
-
});
|
|
111
|
-
return variableNames.size;
|
|
112
|
-
};
|
|
113
|
-
var getVariableNames = (content) => {
|
|
114
|
-
const variableNames = [];
|
|
115
|
-
visitVariables(content, ({ name }) => {
|
|
116
|
-
variableNames.push(name);
|
|
117
|
-
});
|
|
118
|
-
return variableNames;
|
|
119
|
-
};
|
|
120
|
-
//#endregion
|
|
121
61
|
//#region src/multiVariableText/propPanel.ts
|
|
122
62
|
var mapDynamicVariables = (props) => {
|
|
123
63
|
const { rootElement, changeSchemas, activeSchema, i18n, options } = props;
|
|
@@ -268,11 +208,12 @@ var uiRender$3 = async (arg) => {
|
|
|
268
208
|
const { value, schema, rootElement, mode, onChange, ...rest } = arg;
|
|
269
209
|
let text = schema.text;
|
|
270
210
|
let numVariables = schema.variables.length;
|
|
271
|
-
|
|
211
|
+
const renderResolvedValue = schema.readOnly === true && mode !== "designer";
|
|
212
|
+
const renderValue = renderResolvedValue ? value : isInlineMarkdownTextSchema(schema) ? substituteVariablesAsInlineMarkdownLiterals(text, value) : substituteVariables(text, value);
|
|
213
|
+
if (mode === "form" && numVariables > 0 && !renderResolvedValue) {
|
|
272
214
|
await formUiRender(arg);
|
|
273
215
|
return;
|
|
274
216
|
}
|
|
275
|
-
const renderValue = isInlineMarkdownTextSchema(schema) ? substituteVariablesAsInlineMarkdownLiterals(text, value) : substituteVariables(text, value);
|
|
276
217
|
await uiRender$4({
|
|
277
218
|
value: isEditable(mode, schema) ? text : renderValue,
|
|
278
219
|
schema,
|
|
@@ -317,6 +258,28 @@ var formUiRender = async (arg) => {
|
|
|
317
258
|
const inlineMarkdownRuns = isInlineMarkdownTextSchema(schema) ? parseInlineMarkdown(rawText) : void 0;
|
|
318
259
|
const font = options?.font || getDefaultFont();
|
|
319
260
|
const textBlock = buildStyledTextContainer(arg, await getFontKitFont(schema.fontName, font, _cache), inlineMarkdownRuns ? getInlineMarkdownFormDisplayText(inlineMarkdownRuns, variables) : substitutedText);
|
|
261
|
+
if (getTextLineRange(schema)) {
|
|
262
|
+
const { lines } = await measureTextLines({
|
|
263
|
+
value: inlineMarkdownRuns ? substituteVariablesAsInlineMarkdownLiterals(rawText, variables) : substitutedText,
|
|
264
|
+
schema,
|
|
265
|
+
font,
|
|
266
|
+
_cache,
|
|
267
|
+
ignoreDynamicFontSize: true
|
|
268
|
+
});
|
|
269
|
+
renderSplitVariableSpans({
|
|
270
|
+
textBlock,
|
|
271
|
+
lines,
|
|
272
|
+
runs: inlineMarkdownRuns,
|
|
273
|
+
rawText,
|
|
274
|
+
variables,
|
|
275
|
+
schema,
|
|
276
|
+
font,
|
|
277
|
+
theme,
|
|
278
|
+
onChange,
|
|
279
|
+
stopEditing
|
|
280
|
+
});
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
320
283
|
if (inlineMarkdownRuns) {
|
|
321
284
|
renderInlineMarkdownVariableSpans({
|
|
322
285
|
runs: inlineMarkdownRuns,
|
|
@@ -365,6 +328,190 @@ var formUiRender = async (arg) => {
|
|
|
365
328
|
}
|
|
366
329
|
}
|
|
367
330
|
};
|
|
331
|
+
var renderSplitVariableSpans = (arg) => {
|
|
332
|
+
const { textBlock, lines, runs, rawText, variables, schema, font, theme, onChange, stopEditing } = arg;
|
|
333
|
+
const lineRange = getTextLineRange(schema);
|
|
334
|
+
const lineSegments = getSplitLineSegments({
|
|
335
|
+
lines,
|
|
336
|
+
runs,
|
|
337
|
+
rawText,
|
|
338
|
+
variables,
|
|
339
|
+
start: lineRange?.start ?? 0,
|
|
340
|
+
end: lineRange?.end ?? lines.length
|
|
341
|
+
});
|
|
342
|
+
textBlock.innerHTML = "";
|
|
343
|
+
lineSegments.forEach((segments, lineIndex) => {
|
|
344
|
+
segments.forEach((segment) => {
|
|
345
|
+
if (segment.variableName) {
|
|
346
|
+
appendRangedVariableSpan({
|
|
347
|
+
textBlock,
|
|
348
|
+
segment,
|
|
349
|
+
variables,
|
|
350
|
+
schema,
|
|
351
|
+
font,
|
|
352
|
+
theme,
|
|
353
|
+
onChange,
|
|
354
|
+
stopEditing
|
|
355
|
+
});
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
const span = segment.run ? createStaticInlineMarkdownElement(segment.run) : document.createElement("span");
|
|
359
|
+
span.style.letterSpacing = lineIndex === lineSegments.length - 1 ? "0" : "inherit";
|
|
360
|
+
span.textContent = segment.text;
|
|
361
|
+
if (segment.run) applyInlineMarkdownStyle({
|
|
362
|
+
element: span,
|
|
363
|
+
run: segment.run,
|
|
364
|
+
schema,
|
|
365
|
+
font
|
|
366
|
+
});
|
|
367
|
+
textBlock.appendChild(span);
|
|
368
|
+
});
|
|
369
|
+
if (lineIndex < lineSegments.length - 1) textBlock.appendChild(document.createElement("br"));
|
|
370
|
+
});
|
|
371
|
+
};
|
|
372
|
+
var getSplitLineSegments = (arg) => {
|
|
373
|
+
const { lines, runs, rawText, variables, start, end } = arg;
|
|
374
|
+
return consumeMeasuredLineSegments(lines, runs ? buildResolvedInlineMarkdownChars(runs, variables) : buildResolvedPlainChars(rawText, variables), { dropUnmappedTargets: Boolean(runs) }).slice(start, end);
|
|
375
|
+
};
|
|
376
|
+
var buildResolvedPlainChars = (rawText, variables) => {
|
|
377
|
+
const chars = [];
|
|
378
|
+
let lastIndex = 0;
|
|
379
|
+
visitVariables(rawText, ({ name, startIndex, endIndex }) => {
|
|
380
|
+
appendTextChars(chars, rawText.slice(lastIndex, startIndex));
|
|
381
|
+
const value = variables[name] ?? "";
|
|
382
|
+
for (let i = 0; i < value.length; i += 1) chars.push({
|
|
383
|
+
char: value[i],
|
|
384
|
+
variableName: name,
|
|
385
|
+
variableOffset: i
|
|
386
|
+
});
|
|
387
|
+
lastIndex = endIndex + 1;
|
|
388
|
+
});
|
|
389
|
+
appendTextChars(chars, rawText.slice(lastIndex));
|
|
390
|
+
return chars;
|
|
391
|
+
};
|
|
392
|
+
var buildResolvedInlineMarkdownChars = (runs, variables) => {
|
|
393
|
+
const chars = [];
|
|
394
|
+
runs.forEach((run) => {
|
|
395
|
+
let lastIndex = 0;
|
|
396
|
+
visitVariables(run.text, ({ name, startIndex, endIndex }) => {
|
|
397
|
+
appendTextChars(chars, run.text.slice(lastIndex, startIndex), run);
|
|
398
|
+
const value = variables[name] ?? "";
|
|
399
|
+
for (let i = 0; i < value.length; i += 1) chars.push({
|
|
400
|
+
char: value[i],
|
|
401
|
+
variableName: name,
|
|
402
|
+
variableOffset: i,
|
|
403
|
+
run
|
|
404
|
+
});
|
|
405
|
+
lastIndex = endIndex + 1;
|
|
406
|
+
});
|
|
407
|
+
appendTextChars(chars, run.text.slice(lastIndex), run);
|
|
408
|
+
});
|
|
409
|
+
return chars;
|
|
410
|
+
};
|
|
411
|
+
var appendTextChars = (chars, text, run) => {
|
|
412
|
+
for (let i = 0; i < text.length; i += 1) chars.push({
|
|
413
|
+
char: text[i],
|
|
414
|
+
run
|
|
415
|
+
});
|
|
416
|
+
};
|
|
417
|
+
var consumeMeasuredLineSegments = (lines, resolvedChars, options = {}) => {
|
|
418
|
+
const lineSegments = [];
|
|
419
|
+
let cursor = 0;
|
|
420
|
+
lines.forEach((line) => {
|
|
421
|
+
const segments = [];
|
|
422
|
+
const lineText = stripTrailingLineBreaks(line);
|
|
423
|
+
for (let i = 0; i < lineText.length; i += 1) {
|
|
424
|
+
const target = lineText[i];
|
|
425
|
+
while (cursor < resolvedChars.length && resolvedChars[cursor].char !== target && isWhitespaceChar(resolvedChars[cursor].char) && !isWhitespaceChar(target)) cursor += 1;
|
|
426
|
+
if (cursor >= resolvedChars.length) {
|
|
427
|
+
if (options.dropUnmappedTargets) continue;
|
|
428
|
+
appendSegment(segments, { char: target });
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
const sourceChar = resolvedChars[cursor];
|
|
432
|
+
if (sourceChar.char === target) {
|
|
433
|
+
appendSegment(segments, sourceChar);
|
|
434
|
+
cursor += 1;
|
|
435
|
+
} else {
|
|
436
|
+
if (options.dropUnmappedTargets) continue;
|
|
437
|
+
appendSegment(segments, { char: target });
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
cursor = absorbHiddenTrailingWhitespace(segments, resolvedChars, cursor);
|
|
441
|
+
if (line.endsWith("\r\n") || line.endsWith("\n") || line.endsWith("\r")) {
|
|
442
|
+
if (resolvedChars[cursor]?.char === "\r" && resolvedChars[cursor + 1]?.char === "\n") cursor += 2;
|
|
443
|
+
else if (resolvedChars[cursor]?.char === "\n" || resolvedChars[cursor]?.char === "\r") cursor += 1;
|
|
444
|
+
}
|
|
445
|
+
lineSegments.push(segments);
|
|
446
|
+
});
|
|
447
|
+
return lineSegments;
|
|
448
|
+
};
|
|
449
|
+
var absorbHiddenTrailingWhitespace = (segments, resolvedChars, cursor) => {
|
|
450
|
+
let nextCursor = cursor;
|
|
451
|
+
while (nextCursor < resolvedChars.length && isHorizontalWhitespaceChar(resolvedChars[nextCursor].char)) {
|
|
452
|
+
const sourceChar = resolvedChars[nextCursor];
|
|
453
|
+
const lastSegment = segments.at(-1);
|
|
454
|
+
if (lastSegment && lastSegment.variableName === sourceChar.variableName && lastSegment.variableEnd === sourceChar.variableOffset && lastSegment.run === sourceChar.run && sourceChar.variableOffset !== void 0) lastSegment.variableEnd = sourceChar.variableOffset + 1;
|
|
455
|
+
nextCursor += 1;
|
|
456
|
+
}
|
|
457
|
+
return nextCursor;
|
|
458
|
+
};
|
|
459
|
+
var stripTrailingLineBreaks = (value) => {
|
|
460
|
+
let end = value.length;
|
|
461
|
+
while (end > 0) {
|
|
462
|
+
const char = value[end - 1];
|
|
463
|
+
if (char !== "\n" && char !== "\r") break;
|
|
464
|
+
end -= 1;
|
|
465
|
+
}
|
|
466
|
+
return value.slice(0, end);
|
|
467
|
+
};
|
|
468
|
+
var isWhitespaceChar = (value) => value === " " || value === " " || value === "\n" || value === "\r" || value === "\f" || value === "\v";
|
|
469
|
+
var isHorizontalWhitespaceChar = (value) => value === " " || value === " " || value === "\f" || value === "\v";
|
|
470
|
+
var appendSegment = (segments, sourceChar) => {
|
|
471
|
+
const lastSegment = segments.at(-1);
|
|
472
|
+
if (lastSegment && lastSegment.variableName === sourceChar.variableName && lastSegment.variableEnd === sourceChar.variableOffset && lastSegment.run === sourceChar.run) {
|
|
473
|
+
lastSegment.text += sourceChar.char;
|
|
474
|
+
if (sourceChar.variableOffset !== void 0) lastSegment.variableEnd = sourceChar.variableOffset + 1;
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
segments.push({
|
|
478
|
+
text: sourceChar.char,
|
|
479
|
+
variableName: sourceChar.variableName,
|
|
480
|
+
variableStart: sourceChar.variableOffset,
|
|
481
|
+
variableEnd: sourceChar.variableOffset === void 0 ? void 0 : sourceChar.variableOffset + 1,
|
|
482
|
+
run: sourceChar.run
|
|
483
|
+
});
|
|
484
|
+
};
|
|
485
|
+
var appendRangedVariableSpan = (arg) => {
|
|
486
|
+
const { textBlock, segment, variables, schema, font, theme, onChange, stopEditing } = arg;
|
|
487
|
+
if (!segment.variableName) return;
|
|
488
|
+
const span = document.createElement("span");
|
|
489
|
+
span.style.outline = `${theme.colorPrimary} dashed 1px`;
|
|
490
|
+
if (segment.run) applyInlineMarkdownStyle({
|
|
491
|
+
element: span,
|
|
492
|
+
run: segment.run,
|
|
493
|
+
schema,
|
|
494
|
+
font
|
|
495
|
+
});
|
|
496
|
+
makeElementPlainTextContentEditable(span);
|
|
497
|
+
span.textContent = segment.text;
|
|
498
|
+
span.addEventListener("blur", (e) => {
|
|
499
|
+
const variableName = segment.variableName;
|
|
500
|
+
if (!variableName) return;
|
|
501
|
+
const newValue = e.target.textContent || "";
|
|
502
|
+
if (newValue === segment.text) return;
|
|
503
|
+
const currentValue = variables[variableName] ?? "";
|
|
504
|
+
const start = Math.min(segment.variableStart ?? 0, currentValue.length);
|
|
505
|
+
const end = Math.min(segment.variableEnd ?? currentValue.length, currentValue.length);
|
|
506
|
+
variables[variableName] = currentValue.slice(0, start) + newValue + currentValue.slice(end);
|
|
507
|
+
if (onChange) onChange({
|
|
508
|
+
key: "content",
|
|
509
|
+
value: JSON.stringify(variables)
|
|
510
|
+
});
|
|
511
|
+
if (stopEditing) stopEditing();
|
|
512
|
+
});
|
|
513
|
+
textBlock.appendChild(span);
|
|
514
|
+
};
|
|
368
515
|
var getInlineMarkdownFormDisplayText = (runs, variables) => runs.map((run) => substituteVariables(run.text, variables)).join("");
|
|
369
516
|
var applyInlineMarkdownStyle = (arg) => {
|
|
370
517
|
const { element, run, schema, font } = arg;
|
|
@@ -375,7 +522,10 @@ var applyInlineMarkdownStyle = (arg) => {
|
|
|
375
522
|
element.style.textShadow = SYNTHETIC_BOLD_CSS_TEXT_SHADOW;
|
|
376
523
|
}
|
|
377
524
|
if (resolvedFont.syntheticItalic) element.style.fontStyle = "italic";
|
|
378
|
-
|
|
525
|
+
const textDecorations = [];
|
|
526
|
+
if (run.href) textDecorations.push("underline");
|
|
527
|
+
if (run.strikethrough) textDecorations.push("line-through");
|
|
528
|
+
if (textDecorations.length > 0) element.style.textDecoration = textDecorations.join(" ");
|
|
379
529
|
if (run.code) {
|
|
380
530
|
element.style.backgroundColor = CODE_BACKGROUND_COLOR;
|
|
381
531
|
element.style.borderRadius = "2px";
|
|
@@ -383,10 +533,21 @@ var applyInlineMarkdownStyle = (arg) => {
|
|
|
383
533
|
if (!schema.fontVariants?.code || !font[schema.fontVariants.code]) element.style.fontFamily = resolvedFont.fontName ? `'${resolvedFont.fontName}', monospace` : "monospace";
|
|
384
534
|
}
|
|
385
535
|
};
|
|
536
|
+
var createStaticInlineMarkdownElement = (run) => {
|
|
537
|
+
const href = run.href ? normalizeLinkHref(run.href) : void 0;
|
|
538
|
+
if (!href) return document.createElement("span");
|
|
539
|
+
const anchor = document.createElement("a");
|
|
540
|
+
anchor.href = href;
|
|
541
|
+
if (!getInternalLinkTarget(href)) {
|
|
542
|
+
anchor.target = "_blank";
|
|
543
|
+
anchor.rel = "noopener noreferrer";
|
|
544
|
+
}
|
|
545
|
+
return anchor;
|
|
546
|
+
};
|
|
386
547
|
var appendTextSpan = (arg) => {
|
|
387
548
|
const { textBlock, text, run, schema, font } = arg;
|
|
388
549
|
if (!text) return;
|
|
389
|
-
const span =
|
|
550
|
+
const span = createStaticInlineMarkdownElement(run);
|
|
390
551
|
span.textContent = text;
|
|
391
552
|
applyInlineMarkdownStyle({
|
|
392
553
|
element: span,
|
|
@@ -622,7 +783,7 @@ var rectanglePdfRender$2 = rectangle.pdf;
|
|
|
622
783
|
var pdfRender$2 = async (arg) => {
|
|
623
784
|
const { schema, value } = arg;
|
|
624
785
|
const items = normalizeListItems(value);
|
|
625
|
-
const range = schema
|
|
786
|
+
const range = getListItemRange(schema) ?? {
|
|
626
787
|
start: 0,
|
|
627
788
|
end: items.length
|
|
628
789
|
};
|
|
@@ -887,7 +1048,7 @@ var uiRender$2 = async (arg) => {
|
|
|
887
1048
|
const usePlaceholder = editable && !value && Boolean(placeholder);
|
|
888
1049
|
const items = normalizeListItems(usePlaceholder ? placeholder || "" : value);
|
|
889
1050
|
const originalItems = normalizeListItemEntries(value);
|
|
890
|
-
const range = schema
|
|
1051
|
+
const range = getListItemRange(schema) ?? {
|
|
891
1052
|
start: 0,
|
|
892
1053
|
end: items.length
|
|
893
1054
|
};
|
|
@@ -2315,14 +2476,14 @@ var renderLine = async (arg, schema, position, width, height) => linePdfRender({
|
|
|
2315
2476
|
}
|
|
2316
2477
|
});
|
|
2317
2478
|
var createTextDiv = (schema) => {
|
|
2318
|
-
const
|
|
2479
|
+
const contentArea = getBoxContentArea(schema);
|
|
2319
2480
|
const textDiv = document.createElement("div");
|
|
2320
2481
|
textDiv.style.position = "absolute";
|
|
2321
2482
|
textDiv.style.zIndex = "1";
|
|
2322
|
-
textDiv.style.width = `${width
|
|
2323
|
-
textDiv.style.height = `${height
|
|
2324
|
-
textDiv.style.top = `${
|
|
2325
|
-
textDiv.style.left = `${
|
|
2483
|
+
textDiv.style.width = `${contentArea.width}mm`;
|
|
2484
|
+
textDiv.style.height = `${contentArea.height}mm`;
|
|
2485
|
+
textDiv.style.top = `${contentArea.topInset}mm`;
|
|
2486
|
+
textDiv.style.left = `${contentArea.leftInset}mm`;
|
|
2326
2487
|
return textDiv;
|
|
2327
2488
|
};
|
|
2328
2489
|
var createLineDiv = (width, height, top, right, bottom, left, borderColor) => {
|
|
@@ -2340,7 +2501,8 @@ var createLineDiv = (width, height, top, right, bottom, left, borderColor) => {
|
|
|
2340
2501
|
var cellSchema = {
|
|
2341
2502
|
pdf: async (arg) => {
|
|
2342
2503
|
const { schema } = arg;
|
|
2343
|
-
const { position, width, height, borderWidth
|
|
2504
|
+
const { position, width, height, borderWidth } = schema;
|
|
2505
|
+
const contentArea = getBoxContentArea(schema);
|
|
2344
2506
|
await Promise.all([
|
|
2345
2507
|
rectanglePdfRender$1({
|
|
2346
2508
|
...arg,
|
|
@@ -2377,12 +2539,12 @@ var cellSchema = {
|
|
|
2377
2539
|
...schema,
|
|
2378
2540
|
type: "text",
|
|
2379
2541
|
backgroundColor: "",
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
width: width
|
|
2385
|
-
height: height
|
|
2542
|
+
borderColor: "",
|
|
2543
|
+
borderWidth: createBoxDimension(0),
|
|
2544
|
+
padding: createBoxDimension(0),
|
|
2545
|
+
position: contentArea.position,
|
|
2546
|
+
width: contentArea.width,
|
|
2547
|
+
height: contentArea.height
|
|
2386
2548
|
}
|
|
2387
2549
|
});
|
|
2388
2550
|
},
|
|
@@ -2395,7 +2557,10 @@ var cellSchema = {
|
|
|
2395
2557
|
...arg,
|
|
2396
2558
|
schema: {
|
|
2397
2559
|
...schema,
|
|
2398
|
-
backgroundColor: ""
|
|
2560
|
+
backgroundColor: "",
|
|
2561
|
+
borderColor: "",
|
|
2562
|
+
borderWidth: createBoxDimension(0),
|
|
2563
|
+
padding: createBoxDimension(0)
|
|
2399
2564
|
},
|
|
2400
2565
|
rootElement: textDiv
|
|
2401
2566
|
});
|
|
@@ -2515,7 +2680,7 @@ async function drawTable(arg, table) {
|
|
|
2515
2680
|
}
|
|
2516
2681
|
var pdfRender = async (arg) => {
|
|
2517
2682
|
const { value, schema, basePdf, options, _cache } = arg;
|
|
2518
|
-
const body =
|
|
2683
|
+
const body = getBodyWithSchemaRange(typeof value !== "string" ? JSON.stringify(value || "[]") : value, schema);
|
|
2519
2684
|
const createTableArgs = {
|
|
2520
2685
|
schema,
|
|
2521
2686
|
basePdf,
|
|
@@ -2642,7 +2807,7 @@ var renderRowUi = (args) => {
|
|
|
2642
2807
|
if (!arg.onChange) return;
|
|
2643
2808
|
const newValue = Array.isArray(v) ? v[0].value : v.value;
|
|
2644
2809
|
if (section === "body") {
|
|
2645
|
-
const startRange = arg.schema
|
|
2810
|
+
const startRange = getTableBodyRange(arg.schema)?.start ?? 0;
|
|
2646
2811
|
value[rowIndex + startRange][colIndex] = newValue;
|
|
2647
2812
|
arg.onChange({
|
|
2648
2813
|
key: "content",
|
|
@@ -2695,7 +2860,8 @@ var resetEditingPosition = () => {
|
|
|
2695
2860
|
var uiRender = async (arg) => {
|
|
2696
2861
|
const { rootElement, onChange, schema, value, mode, scale } = arg;
|
|
2697
2862
|
const body = getBody(value);
|
|
2698
|
-
const
|
|
2863
|
+
const bodyRange = getTableBodyRange(schema);
|
|
2864
|
+
const bodyWidthRange = getBodyWithSchemaRange(value, schema, bodyRange);
|
|
2699
2865
|
const table = await createSingleTable(bodyWidthRange, arg);
|
|
2700
2866
|
const showHead = table.settings.showHead;
|
|
2701
2867
|
rootElement.innerHTML = "";
|
|
@@ -2748,7 +2914,7 @@ var uiRender = async (arg) => {
|
|
|
2748
2914
|
text: "-",
|
|
2749
2915
|
ariaLabel: "Remove row",
|
|
2750
2916
|
onClick: () => {
|
|
2751
|
-
const newTableBody = body.filter((_, j) => j !== i + (
|
|
2917
|
+
const newTableBody = body.filter((_, j) => j !== i + (bodyRange?.start ?? 0));
|
|
2752
2918
|
if (onChange) onChange({
|
|
2753
2919
|
key: "content",
|
|
2754
2920
|
value: JSON.stringify(newTableBody)
|
|
@@ -2758,7 +2924,7 @@ var uiRender = async (arg) => {
|
|
|
2758
2924
|
});
|
|
2759
2925
|
};
|
|
2760
2926
|
if (mode === "form" && onChange && !schema.readOnly) {
|
|
2761
|
-
if (
|
|
2927
|
+
if (bodyRange?.end === void 0 || bodyRange.end >= JSON.parse(value || "[]").length) rootElement.appendChild(createAddRowButton());
|
|
2762
2928
|
createRemoveRowButtons().forEach((button) => rootElement.appendChild(button));
|
|
2763
2929
|
}
|
|
2764
2930
|
if (mode === "designer" && onChange) {
|
|
@@ -6159,6 +6325,6 @@ var schema = {
|
|
|
6159
6325
|
icon: getCheckedIcon()
|
|
6160
6326
|
};
|
|
6161
6327
|
//#endregion
|
|
6162
|
-
export { barcodes, builtInPlugins, schema as checkbox, date_default as date, dateTime_default as dateTime, ellipse, getDynamicHeightsForTable, getDynamicLayoutForList, getDynamicLayoutForTable, imageSchema as image, lineSchema as line, listSchema as list, schema$1 as multiVariableText, schema$2 as radioGroup, rectangle, schema$3 as select, signature, svgSchema as svg, tableSchema as table, textSchema as text, time_default as time };
|
|
6328
|
+
export { BUILT_IN_DYNAMIC_LAYOUT_SPLIT_UNITS, LIST_ITEM_SPLIT_UNIT, TABLE_BODY_SPLIT_UNIT, TEXT_LINE_SPLIT_UNIT, barcodes, builtInPlugins, schema as checkbox, createListItemSplitRange, createTableBodySplitRange, createTextLineSplitRange, date_default as date, dateTime_default as dateTime, ellipse, getDynamicHeightsForTable, getDynamicLayoutForList, getDynamicLayoutForTable, getListItemRange, getTableBodyRange, getTextLineRange, imageSchema as image, lineSchema as line, listSchema as list, schema$1 as multiVariableText, schema$2 as radioGroup, rectangle, schema$3 as select, signature, svgSchema as svg, tableSchema as table, textSchema as text, time_default as time };
|
|
6163
6329
|
|
|
6164
6330
|
//# sourceMappingURL=index.js.map
|