@pdfme/ui 5.4.0-dev.63 → 5.4.0-dev.65
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/index.es.js +19 -14
- package/package.json +1 -1
- package/src/Viewer.tsx +3 -1
- package/src/components/Designer/Canvas/Moveable.tsx +1 -1
- package/src/components/Designer/Canvas/index.tsx +10 -9
- package/src/components/Designer/LeftSidebar.tsx +18 -15
- package/src/components/StaticSchema.tsx +9 -5
- package/src/helper.ts +5 -1
package/dist/index.es.js
CHANGED
@@ -146580,19 +146580,22 @@ Check this document: https://pdfme.com/docs/custom-schemas`), /* @__PURE__ */ js
|
|
146580
146580
|
const w = getFallbackFontName(p.font);
|
146581
146581
|
setFontNameRecursively(v, w);
|
146582
146582
|
}
|
146583
|
-
const A = useDraggable({ id: v.type, data: v }), { listeners: x, setNodeRef: g, attributes: b, transform: y, isDragging: f } = A, m = { transform: CSS$1.Translate.toString(y) }, C = React.useMemo(
|
146584
|
-
|
146585
|
-
|
146586
|
-
|
146587
|
-
|
146588
|
-
|
146589
|
-
|
146590
|
-
|
146591
|
-
|
146592
|
-
|
146593
|
-
|
146594
|
-
|
146595
|
-
|
146583
|
+
const A = useDraggable({ id: v.type, data: v }), { listeners: x, setNodeRef: g, attributes: b, transform: y, isDragging: f } = A, m = { transform: CSS$1.Translate.toString(y) }, C = React.useMemo(
|
146584
|
+
() => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { transform: `scale(${s})` }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
146585
|
+
Renderer,
|
146586
|
+
{
|
146587
|
+
schema: { ...v, id: v.type },
|
146588
|
+
basePdf: c,
|
146589
|
+
value: v.content || "",
|
146590
|
+
onChangeHoveringSchemaId: () => {
|
146591
|
+
},
|
146592
|
+
mode: "viewer",
|
146593
|
+
outline: `1px solid ${d.colorPrimary}`,
|
146594
|
+
scale: s
|
146595
|
+
}
|
146596
|
+
) }),
|
146597
|
+
[v, c, s, d.colorPrimary]
|
146598
|
+
);
|
146596
146599
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: g, style: m, ...x, ...b, children: [
|
146597
146600
|
f && C,
|
146598
146601
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { visibility: f ? "hidden" : "visible" }, children: a.children })
|
@@ -159122,7 +159125,9 @@ class Form extends PreviewUI {
|
|
159122
159125
|
}
|
159123
159126
|
class Viewer extends PreviewUI {
|
159124
159127
|
constructor(s) {
|
159125
|
-
super(s), console.warn(
|
159128
|
+
super(s), console.warn(
|
159129
|
+
"[@pdfme/ui] Viewer component is deprecated and will be removed in a future version."
|
159130
|
+
);
|
159126
159131
|
}
|
159127
159132
|
render() {
|
159128
159133
|
if (!this.domContainer) throw Error(DESTROYED_ERR_MSG);
|
package/package.json
CHANGED
package/src/Viewer.tsx
CHANGED
@@ -9,7 +9,9 @@ import AppContextProvider from './components/AppContextProvider.js';
|
|
9
9
|
class Viewer extends PreviewUI {
|
10
10
|
constructor(props: PreviewProps) {
|
11
11
|
super(props);
|
12
|
-
console.warn(
|
12
|
+
console.warn(
|
13
|
+
'[@pdfme/ui] Viewer component is deprecated and will be removed in a future version.',
|
14
|
+
);
|
13
15
|
}
|
14
16
|
|
15
17
|
protected render() {
|
@@ -508,20 +508,21 @@ const Canvas = (props: Props, ref: Ref<HTMLDivElement>) => {
|
|
508
508
|
onChange={
|
509
509
|
(schemasList[pageCursor] || []).some((s) => s.id === schema.id)
|
510
510
|
? (arg) => {
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
511
|
+
// Use type assertion to safely handle the argument
|
512
|
+
type ChangeArg = { key: string; value: unknown };
|
513
|
+
const args = Array.isArray(arg) ? (arg as ChangeArg[]) : [arg as ChangeArg];
|
514
|
+
changeSchemas(
|
515
|
+
args.map(({ key, value }) => ({ key, value, schemaId: schema.id })),
|
516
|
+
);
|
517
|
+
}
|
518
518
|
: undefined
|
519
519
|
}
|
520
520
|
stopEditing={() => setEditing(false)}
|
521
|
-
outline={`1px ${hoveringSchemaId === schema.id ? 'solid' : 'dashed'} ${
|
521
|
+
outline={`1px ${hoveringSchemaId === schema.id ? 'solid' : 'dashed'} ${
|
522
|
+
schema.readOnly && hoveringSchemaId !== schema.id
|
522
523
|
? 'transparent'
|
523
524
|
: token.colorPrimary
|
524
|
-
|
525
|
+
}`}
|
525
526
|
scale={scale}
|
526
527
|
/>
|
527
528
|
);
|
@@ -27,21 +27,24 @@ const Draggable = (props: {
|
|
27
27
|
const { listeners, setNodeRef, attributes, transform, isDragging } = draggable;
|
28
28
|
const style = { transform: CSS.Translate.toString(transform) };
|
29
29
|
|
30
|
-
const renderedSchema = React.useMemo(
|
31
|
-
|
32
|
-
<
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
30
|
+
const renderedSchema = React.useMemo(
|
31
|
+
() => (
|
32
|
+
<div style={{ transform: `scale(${scale})` }}>
|
33
|
+
<Renderer
|
34
|
+
schema={{ ...defaultSchema, id: defaultSchema.type }}
|
35
|
+
basePdf={basePdf}
|
36
|
+
value={defaultSchema.content || ''}
|
37
|
+
onChangeHoveringSchemaId={() => {
|
38
|
+
void 0;
|
39
|
+
}}
|
40
|
+
mode={'viewer'}
|
41
|
+
outline={`1px solid ${token.colorPrimary}`}
|
42
|
+
scale={scale}
|
43
|
+
/>
|
44
|
+
</div>
|
45
|
+
),
|
46
|
+
[defaultSchema, basePdf, scale, token.colorPrimary],
|
47
|
+
);
|
45
48
|
|
46
49
|
return (
|
47
50
|
<div ref={setNodeRef} style={style} {...listeners} {...attributes}>
|
@@ -25,11 +25,15 @@ const StaticSchema = (props: {
|
|
25
25
|
key={schema.name}
|
26
26
|
schema={{ ...schema, id: uuid() }}
|
27
27
|
basePdf={basePdf}
|
28
|
-
value={
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
value={
|
29
|
+
schema.readOnly
|
30
|
+
? replacePlaceholders({
|
31
|
+
content: schema.content || '',
|
32
|
+
variables: { ...input, totalPages, currentPage },
|
33
|
+
schemas,
|
34
|
+
})
|
35
|
+
: schema.content || ''
|
36
|
+
}
|
33
37
|
onChangeHoveringSchemaId={() => {
|
34
38
|
void 0;
|
35
39
|
}}
|
package/src/helper.ts
CHANGED
@@ -526,7 +526,11 @@ export const setFontNameRecursively = (
|
|
526
526
|
seen.add(obj);
|
527
527
|
|
528
528
|
for (const key in obj) {
|
529
|
-
if (
|
529
|
+
if (
|
530
|
+
key === 'fontName' &&
|
531
|
+
Object.prototype.hasOwnProperty.call(obj, key) &&
|
532
|
+
obj[key] === undefined
|
533
|
+
) {
|
530
534
|
obj[key] = fontName;
|
531
535
|
} else if (typeof obj[key] === 'object' && obj[key] !== null) {
|
532
536
|
setFontNameRecursively(obj[key] as Record<string, unknown>, fontName, seen);
|