react-ink-scripter 0.0.19 → 0.0.21
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/cjs/index.js +10 -5
- package/dist/esm/index.js +8 -5
- package/dist/esm/usePagePrint.d.ts +2 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -23,10 +23,10 @@ var usePagePrint = function usePagePrint(_ref) {
|
|
|
23
23
|
var _useState = react.useState({
|
|
24
24
|
width: pageConfig.width || 0,
|
|
25
25
|
height: pageConfig.height || 0,
|
|
26
|
-
marginLeft: 0,
|
|
27
|
-
marginRight: 0,
|
|
28
|
-
marginTop: 0,
|
|
29
|
-
marginBottom: 0
|
|
26
|
+
marginLeft: pageConfig.marginLeft || 0,
|
|
27
|
+
marginRight: pageConfig.marginRight || 0,
|
|
28
|
+
marginTop: pageConfig.marginTop || 0,
|
|
29
|
+
marginBottom: pageConfig.marginBottom || 0
|
|
30
30
|
}),
|
|
31
31
|
_useState2 = _slicedToArray(_useState, 2),
|
|
32
32
|
page = _useState2[0],
|
|
@@ -59,9 +59,14 @@ var usePagePrint = function usePagePrint(_ref) {
|
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
61
|
}, [pageNode, open, pageConfig]);
|
|
62
|
+
var getPageContent = react.useCallback(function () {
|
|
63
|
+
return (pageNode === null || pageNode === void 0 ? void 0 : pageNode.innerHTML) || '';
|
|
64
|
+
}, [pageNode]);
|
|
62
65
|
return {
|
|
63
66
|
setPageNodeRef: setPageNodeRef,
|
|
64
|
-
page: page
|
|
67
|
+
page: page,
|
|
68
|
+
getPageContent: getPageContent,
|
|
69
|
+
pageNode: pageNode
|
|
65
70
|
};
|
|
66
71
|
};
|
|
67
72
|
|
package/dist/esm/index.js
CHANGED
|
@@ -12,10 +12,10 @@ const usePagePrint = ({ open, pageConfig, }) => {
|
|
|
12
12
|
const [page, setPage] = useState({
|
|
13
13
|
width: pageConfig.width || 0,
|
|
14
14
|
height: pageConfig.height || 0,
|
|
15
|
-
marginLeft: 0,
|
|
16
|
-
marginRight: 0,
|
|
17
|
-
marginTop: 0,
|
|
18
|
-
marginBottom: 0,
|
|
15
|
+
marginLeft: pageConfig.marginLeft || 0,
|
|
16
|
+
marginRight: pageConfig.marginRight || 0,
|
|
17
|
+
marginTop: pageConfig.marginTop || 0,
|
|
18
|
+
marginBottom: pageConfig.marginBottom || 0,
|
|
19
19
|
});
|
|
20
20
|
const [pageNode, setPageNode] = useState();
|
|
21
21
|
const setPageNodeRef = useCallback((node) => {
|
|
@@ -40,7 +40,10 @@ const usePagePrint = ({ open, pageConfig, }) => {
|
|
|
40
40
|
height: pageHeight,
|
|
41
41
|
}));
|
|
42
42
|
}, [pageNode, open, pageConfig]);
|
|
43
|
-
|
|
43
|
+
const getPageContent = useCallback(() => {
|
|
44
|
+
return pageNode?.innerHTML || '';
|
|
45
|
+
}, [pageNode]);
|
|
46
|
+
return { setPageNodeRef, page, getPageContent, pageNode };
|
|
44
47
|
};
|
|
45
48
|
|
|
46
49
|
const IFrame = forwardRef((props, ref) => {
|
|
@@ -15,5 +15,7 @@ export type usePagePrintProps = {
|
|
|
15
15
|
export declare const usePagePrint: <T extends Element>({ open, pageConfig, }: usePagePrintProps) => {
|
|
16
16
|
setPageNodeRef: (node: T) => void;
|
|
17
17
|
page: PageConfig;
|
|
18
|
+
getPageContent: () => string;
|
|
19
|
+
pageNode: T | undefined;
|
|
18
20
|
};
|
|
19
21
|
export default usePagePrint;
|