@servicetitan/dte-pdf-editor 1.48.0 → 1.49.0

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 +1 @@
1
- {"version":3,"file":"pdf-view-data-model.d.ts","sourceRoot":"","sources":["../../../src/components/pdf-view/pdf-view-data-model.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGlE,UAAU,qBAAqB;IAC3B,KAAK,EAAE,QAAQ,CAAC;IAChB,IAAI,CAAC,EAAE,eAAe,CAAC;CAC1B;AAED,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAGtD,CAAC"}
1
+ {"version":3,"file":"pdf-view-data-model.d.ts","sourceRoot":"","sources":["../../../src/components/pdf-view/pdf-view-data-model.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGlE,UAAU,qBAAqB;IAC3B,KAAK,EAAE,QAAQ,CAAC;IAChB,IAAI,CAAC,EAAE,eAAe,CAAC;CAC1B;AAED,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CActD,CAAC"}
@@ -1,7 +1,13 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { resolvePdfDataValues } from '../../utils';
2
+ import { nl2br, resolvePdfDataValues } from '../../utils';
3
3
  export const PdfViewDataModel = ({ data, field }) => {
4
4
  const resolvedValue = field.path ? resolvePdfDataValues(data, field.path) : '';
5
- return _jsx("div", { className: "dte-pdf-field-value", children: resolvedValue !== null && resolvedValue !== void 0 ? resolvedValue : '' });
5
+ /*
6
+ * Mirrors Unlayer's `{{ field | safe | nl2br }}` as
7
+ * conversion. The `__html` key and `dangerouslySetInnerHTML` are mandated by React's API.
8
+ */
9
+ return (_jsx("div", { className: "dte-pdf-field-value",
10
+ // eslint-disable-next-line react/no-danger, @typescript-eslint/naming-convention
11
+ dangerouslySetInnerHTML: { __html: nl2br(resolvedValue !== null && resolvedValue !== void 0 ? resolvedValue : '') } }));
6
12
  };
7
13
  //# sourceMappingURL=pdf-view-data-model.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pdf-view-data-model.js","sourceRoot":"","sources":["../../../src/components/pdf-view/pdf-view-data-model.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAOnD,MAAM,CAAC,MAAM,gBAAgB,GAA8B,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;IAC3E,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,oBAAoB,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/E,OAAO,cAAK,SAAS,EAAC,qBAAqB,YAAE,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,EAAE,GAAO,CAAC;AAC5E,CAAC,CAAC"}
1
+ {"version":3,"file":"pdf-view-data-model.js","sourceRoot":"","sources":["../../../src/components/pdf-view/pdf-view-data-model.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAO1D,MAAM,CAAC,MAAM,gBAAgB,GAA8B,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;IAC3E,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,oBAAoB,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAE/E;;;OAGG;IACH,OAAO,CACH,cACI,SAAS,EAAC,qBAAqB;QAC/B,iFAAiF;QACjF,uBAAuB,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,EAAE,CAAC,EAAE,GACjE,CACL,CAAC;AACN,CAAC,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from './date.utils';
2
2
  export * from './number.utils';
3
+ export * from './schema.utils';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from './date.utils';
2
2
  export * from './number.utils';
3
+ export * from './schema.utils';
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * React/HTML equivalent of the Nunjucks `nl2br` filter used by Unlayer's
3
+ * `{{ field | safe | nl2br }}` template. Replaces every `\r\n` or `\n` with `<br />\n`,
4
+ * keeping the original newline so the rendered HTML source still wraps in dev tools.
5
+ */
6
+ export declare const nl2br: (value: string) => string;
7
+ //# sourceMappingURL=schema.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.utils.d.ts","sourceRoot":"","sources":["../../../src/utils/shared/schema.utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,KAAG,MAErC,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * React/HTML equivalent of the Nunjucks `nl2br` filter used by Unlayer's
3
+ * `{{ field | safe | nl2br }}` template. Replaces every `\r\n` or `\n` with `<br />\n`,
4
+ * keeping the original newline so the rendered HTML source still wraps in dev tools.
5
+ */
6
+ export const nl2br = (value) => {
7
+ return value.replace(/\r\n|\n/g, '<br />\n');
8
+ };
9
+ //# sourceMappingURL=schema.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.utils.js","sourceRoot":"","sources":["../../../src/utils/shared/schema.utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAa,EAAU,EAAE;IAC3C,OAAO,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AACjD,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicetitan/dte-pdf-editor",
3
- "version": "1.48.0",
3
+ "version": "1.49.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "typings": "./dist/index.d.ts",
@@ -1,6 +1,6 @@
1
1
  import { FC } from 'react';
2
2
  import { DataModelValues, PdfField } from '../../interface/types';
3
- import { resolvePdfDataValues } from '../../utils';
3
+ import { nl2br, resolvePdfDataValues } from '../../utils';
4
4
 
5
5
  interface PdfViewDataModelProps {
6
6
  field: PdfField;
@@ -9,5 +9,16 @@ interface PdfViewDataModelProps {
9
9
 
10
10
  export const PdfViewDataModel: FC<PdfViewDataModelProps> = ({ data, field }) => {
11
11
  const resolvedValue = field.path ? resolvePdfDataValues(data, field.path) : '';
12
- return <div className="dte-pdf-field-value">{resolvedValue ?? ''}</div>;
12
+
13
+ /*
14
+ * Mirrors Unlayer's `{{ field | safe | nl2br }}` as
15
+ * conversion. The `__html` key and `dangerouslySetInnerHTML` are mandated by React's API.
16
+ */
17
+ return (
18
+ <div
19
+ className="dte-pdf-field-value"
20
+ // eslint-disable-next-line react/no-danger, @typescript-eslint/naming-convention
21
+ dangerouslySetInnerHTML={{ __html: nl2br(resolvedValue ?? '') }}
22
+ />
23
+ );
13
24
  };
@@ -1,2 +1,3 @@
1
1
  export * from './date.utils';
2
2
  export * from './number.utils';
3
+ export * from './schema.utils';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * React/HTML equivalent of the Nunjucks `nl2br` filter used by Unlayer's
3
+ * `{{ field | safe | nl2br }}` template. Replaces every `\r\n` or `\n` with `<br />\n`,
4
+ * keeping the original newline so the rendered HTML source still wraps in dev tools.
5
+ */
6
+ export const nl2br = (value: string): string => {
7
+ return value.replace(/\r\n|\n/g, '<br />\n');
8
+ };