@pdfme/common 6.1.13-dev.17 → 6.1.13-dev.22

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.
@@ -1,4 +1,15 @@
1
- import type { SchemaPageArray } from './types.js';
1
+ import type { Schema, SchemaPageArray } from './types.js';
2
+ /**
3
+ * Resolve a read-only schema's render value.
4
+ * Text `content` is an expression template. MVT `content` is a variable JSON
5
+ * map and must not go through {@link replacePlaceholders}. Other types (table,
6
+ * image, …) keep the previous generate/UI behavior of evaluating expressions.
7
+ */
8
+ export declare const resolveReadOnlyContent: (arg: {
9
+ schema: Schema;
10
+ variables: Record<string, unknown>;
11
+ schemas: SchemaPageArray;
12
+ }) => string;
2
13
  export declare const replacePlaceholders: (arg: {
3
14
  content: string;
4
15
  variables: Record<string, unknown>;
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import { cloneDeep, getFallbackFontName, getDefaultFont, getB64BasePdf, b64toUin
7
7
  import { PAGE_SIZE_PRESETS, detectPaperSize, resolvePageSize } from './pageSize.js';
8
8
  import { getDynamicTemplate, getReadOnlyTableValue, getSchemaValue } from './dynamicTemplate.js';
9
9
  import { createDynamicLayoutSplitRange, getDynamicLayoutSplitRange } from './splitRange.js';
10
- import { replacePlaceholders } from './expression.js';
10
+ import { replacePlaceholders, resolveReadOnlyContent } from './expression.js';
11
11
  import { pluginRegistry } from './pluginRegistry.js';
12
- export { PDFME_VERSION, MM_TO_PT_RATIO, PT_TO_MM_RATIO, PT_TO_PX_RATIO, BLANK_PDF, BLANK_A4_PDF, CUSTOM_A4_PDF, ZOOM, DEFAULT_FONT_NAME, cloneDeep, getFallbackFontName, getDefaultFont, getB64BasePdf, b64toUint8Array, mm2pt, pt2mm, pt2px, px2mm, isHexValid, getInputFromTemplate, isBlankPdf, getDynamicTemplate, getReadOnlyTableValue, getSchemaValue, replacePlaceholders, checkFont, checkInputs, checkUIOptions, checkTemplate, checkUIProps, checkPreviewProps, checkDesignerProps, checkGenerateProps, pluginRegistry, isUrlSafeToFetch, getInternalLinkTarget, normalizeInternalLinkHref, normalizeLinkHref, normalizeSafeLinkUri, registerInternalLinkAnchor, registerInternalLinkAnnotation, resetInternalLinkAnnotations, applyInternalLinkAnnotations, PAGE_SIZE_PRESETS, detectPaperSize, resolvePageSize, createDynamicLayoutSplitRange, getDynamicLayoutSplitRange, };
12
+ export { PDFME_VERSION, MM_TO_PT_RATIO, PT_TO_MM_RATIO, PT_TO_PX_RATIO, BLANK_PDF, BLANK_A4_PDF, CUSTOM_A4_PDF, ZOOM, DEFAULT_FONT_NAME, cloneDeep, getFallbackFontName, getDefaultFont, getB64BasePdf, b64toUint8Array, mm2pt, pt2mm, pt2px, px2mm, isHexValid, getInputFromTemplate, isBlankPdf, getDynamicTemplate, getReadOnlyTableValue, getSchemaValue, replacePlaceholders, resolveReadOnlyContent, checkFont, checkInputs, checkUIOptions, checkTemplate, checkUIProps, checkPreviewProps, checkDesignerProps, checkGenerateProps, pluginRegistry, isUrlSafeToFetch, getInternalLinkTarget, normalizeInternalLinkHref, normalizeLinkHref, normalizeSafeLinkUri, registerInternalLinkAnchor, registerInternalLinkAnnotation, resetInternalLinkAnnotations, applyInternalLinkAnnotations, PAGE_SIZE_PRESETS, detectPaperSize, resolvePageSize, createDynamicLayoutSplitRange, getDynamicLayoutSplitRange, };
13
13
  export type { Lang, Dict, Size, Schema, SchemaForUI, Font, ColorType, DynamicLayoutRange, DynamicLayoutSplitRange, BasePdf, BlankPdf, CustomPdf, Template, CommonOptions, GeneratorOptions, Plugin, Plugins, PluginRegistry, GenerateProps, UIOptions, UIProps, PreviewProps, DesignerProps, ChangeSchemaItem, ChangeSchemas, SchemaPageArray, PropPanel, PropPanelSchema, PropPanelWidgetProps, PDFRenderProps, UIRenderProps, Mode, DynamicLayoutArgs, DynamicLayoutCallbackResult, DynamicLayoutPatchArgs, DynamicLayoutResult, GetDynamicLayout, PdfLinkAnnotationRect, PageOrientation, PageSize, PageSizePreset, };
package/dist/index.js CHANGED
@@ -942,6 +942,21 @@ var evaluatePlaceholders = (arg) => {
942
942
  }
943
943
  return resultContent;
944
944
  };
945
+ /**
946
+ * Resolve a read-only schema's render value.
947
+ * Text `content` is an expression template. MVT `content` is a variable JSON
948
+ * map and must not go through {@link replacePlaceholders}. Other types (table,
949
+ * image, …) keep the previous generate/UI behavior of evaluating expressions.
950
+ */
951
+ var resolveReadOnlyContent = (arg) => {
952
+ const content = arg.schema.content || "";
953
+ if (arg.schema.type === "multiVariableText") return content;
954
+ return replacePlaceholders({
955
+ content,
956
+ variables: arg.variables,
957
+ schemas: arg.schemas
958
+ });
959
+ };
945
960
  var replacePlaceholders = (arg) => {
946
961
  const { content, variables, schemas } = arg;
947
962
  if (!content || typeof content !== "string" || !content.includes("{") || !content.includes("}")) return content;
@@ -987,7 +1002,7 @@ var getReadOnlyTableValue = (schema, input) => {
987
1002
  var getSchemaValue = (schema, input, schemas) => {
988
1003
  if (!schema.readOnly) return input?.[schema.name] || "";
989
1004
  if (schema.type === "table") return getReadOnlyTableValue(schema, input);
990
- if (schema.type !== "text" && schema.type !== "multiVariableText") return schema.content || "";
1005
+ if (schema.type !== "text") return schema.content || "";
991
1006
  return replacePlaceholders({
992
1007
  content: schema.content || "",
993
1008
  variables: input,
@@ -1226,6 +1241,6 @@ var pluginRegistry = (plugins) => {
1226
1241
  };
1227
1242
  };
1228
1243
  //#endregion
1229
- export { BLANK_A4_PDF, BLANK_PDF, CUSTOM_A4_PDF, DEFAULT_FONT_NAME, MM_TO_PT_RATIO, PAGE_SIZE_PRESETS, PDFME_VERSION, PT_TO_MM_RATIO, PT_TO_PX_RATIO, ZOOM, applyInternalLinkAnnotations, b64toUint8Array, checkDesignerProps, checkFont, checkGenerateProps, checkInputs, checkPreviewProps, checkTemplate, checkUIOptions, checkUIProps, cloneDeep, createDynamicLayoutSplitRange, detectPaperSize, getB64BasePdf, getDefaultFont, getDynamicLayoutSplitRange, getDynamicTemplate, getFallbackFontName, getInputFromTemplate, getInternalLinkTarget, getReadOnlyTableValue, getSchemaValue, isBlankPdf, isHexValid, isUrlSafeToFetch, mm2pt, normalizeInternalLinkHref, normalizeLinkHref, normalizeSafeLinkUri, pluginRegistry, pt2mm, pt2px, px2mm, registerInternalLinkAnchor, registerInternalLinkAnnotation, replacePlaceholders, resetInternalLinkAnnotations, resolvePageSize };
1244
+ export { BLANK_A4_PDF, BLANK_PDF, CUSTOM_A4_PDF, DEFAULT_FONT_NAME, MM_TO_PT_RATIO, PAGE_SIZE_PRESETS, PDFME_VERSION, PT_TO_MM_RATIO, PT_TO_PX_RATIO, ZOOM, applyInternalLinkAnnotations, b64toUint8Array, checkDesignerProps, checkFont, checkGenerateProps, checkInputs, checkPreviewProps, checkTemplate, checkUIOptions, checkUIProps, cloneDeep, createDynamicLayoutSplitRange, detectPaperSize, getB64BasePdf, getDefaultFont, getDynamicLayoutSplitRange, getDynamicTemplate, getFallbackFontName, getInputFromTemplate, getInternalLinkTarget, getReadOnlyTableValue, getSchemaValue, isBlankPdf, isHexValid, isUrlSafeToFetch, mm2pt, normalizeInternalLinkHref, normalizeLinkHref, normalizeSafeLinkUri, pluginRegistry, pt2mm, pt2px, px2mm, registerInternalLinkAnchor, registerInternalLinkAnnotation, replacePlaceholders, resetInternalLinkAnnotations, resolvePageSize, resolveReadOnlyContent };
1230
1245
 
1231
1246
  //# sourceMappingURL=index.js.map