@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.
- package/dist/components/pdf-view/pdf-view-data-model.d.ts.map +1 -1
- package/dist/components/pdf-view/pdf-view-data-model.js +8 -2
- package/dist/components/pdf-view/pdf-view-data-model.js.map +1 -1
- package/dist/utils/shared/index.d.ts +1 -0
- package/dist/utils/shared/index.d.ts.map +1 -1
- package/dist/utils/shared/index.js +1 -0
- package/dist/utils/shared/index.js.map +1 -1
- package/dist/utils/shared/schema.utils.d.ts +7 -0
- package/dist/utils/shared/schema.utils.d.ts.map +1 -0
- package/dist/utils/shared/schema.utils.js +9 -0
- package/dist/utils/shared/schema.utils.js.map +1 -0
- package/package.json +1 -1
- package/src/components/pdf-view/pdf-view-data-model.tsx +13 -2
- package/src/utils/shared/index.ts +1 -0
- package/src/utils/shared/schema.utils.ts +8 -0
|
@@ -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,
|
|
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
|
-
|
|
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;
|
|
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 +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 +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
|
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
|
-
|
|
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
|
};
|
|
@@ -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
|
+
};
|