Skip to content

Commit 9a18998

Browse files
committed
fix
1 parent f204cbf commit 9a18998

File tree

3 files changed

+11
-18
lines changed

3 files changed

+11
-18
lines changed

apps/www/content/docs/examples/export.mdx

-9
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@ title: Export
1717

1818
Install the [PDF Toolbar Button](/docs/plate-ui/pdf-toolbar-button) component.
1919

20-
Note: When using Tailwind CSS, you may encounter background color issues. Please refer to [this link](https://github.com/niklasvh/html2canvas/issues/2775#issuecomment-1204988157) for a solution.
21-
22-
Add the following CSS to fix background color rendering issues with html2canvas:
23-
```css
24-
@layer base {
25-
img {
26-
@apply inline-block;
27-
}
28-
}
2920
```
3021
3122
## Examples

apps/www/src/registry/default/plate-ui/pdf-toolbar-button.tsx

+10-7
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
import React from 'react';
44

55
import { withRef } from '@udecode/cn';
6-
import { useEditorRef } from '@udecode/plate-core/react';
7-
import { toDOMNode } from '@udecode/slate-react';
6+
import { toDOMNode, useEditorRef } from '@udecode/plate-common/react';
87

98
import { ToolbarButton } from './toolbar';
109

@@ -19,11 +18,15 @@ export const PdfToolbarButton = withRef<typeof ToolbarButton>(
1918
onClick={async () => {
2019
const { default: html2canvas } = await import('html2canvas');
2120

22-
const canvas = await html2canvas(toDOMNode(editor, editor)!, {
23-
onclone(document, element) {
24-
console.log(document, element, 'fj');
25-
},
26-
});
21+
const style = document.createElement('style');
22+
document.head.append(style);
23+
style.sheet?.insertRule(
24+
'body > div:last-child img { display: inline-block !important; }'
25+
);
26+
27+
const canvas = await html2canvas(toDOMNode(editor, editor)!);
28+
29+
style.remove();
2730

2831
const PDFLib = await import('pdf-lib');
2932
const pdfDoc = await PDFLib.PDFDocument.create();

apps/www/src/styles/globals.css

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
@tailwind components;
33
@tailwind utilities;
44

5-
/* global.css */
65
@layer base {
76
:root {
87
--background: 0 0% 100%;
@@ -36,7 +35,7 @@
3635

3736
--brand: 217.2 91.2% 59.8%;
3837
--highlight: 47.9 95.8% 53.1%;
39-
38+
4039
.prose {
4140
--tw-prose-body: var(--foreground);
4241
--tw-prose-bold: inherit;

0 commit comments

Comments
 (0)