File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -5,8 +5,17 @@ import { printEditorContent } from '@/utils/pdf';
55
66import type { GeneralOptions , PaperSize , PageMargin } from '@/types' ;
77
8+ declare module '@tiptap/core' {
9+ interface Commands < ReturnType > {
10+ exportPdf : {
11+ exportToPdf : ( ) => ReturnType
12+ }
13+ }
14+ }
15+
816export interface ExportPdfOptions extends GeneralOptions < ExportPdfOptions > {
917 paperSize : PaperSize ;
18+ title ?: string ;
1019 margins : {
1120 top ?: PageMargin ;
1221 right ?: PageMargin ;
@@ -21,6 +30,7 @@ export const ExportPdf = /* @__PURE__ */ Extension.create<ExportPdfOptions>({
2130 return {
2231 ...this . parent ?.( ) ,
2332 paperSize : 'Letter' ,
33+ title : 'Echo Editor' ,
2434 margins : {
2535 top : '0.4in' ,
2636 right : '0.4in' ,
@@ -41,4 +51,13 @@ export const ExportPdf = /* @__PURE__ */ Extension.create<ExportPdfOptions>({
4151 } ) ,
4252 } ;
4353 } ,
54+ addCommands ( ) {
55+ return {
56+ exportToPdf :
57+ ( ) =>
58+ ( { editor } ) => {
59+ return printEditorContent ( editor , this . options ) ;
60+ } ,
61+ } ;
62+ } ,
4463} ) ;
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ function printHtml(content: string, exportPdfOptions: ExportPdfOptions) {
1515
1616 const {
1717 paperSize,
18+ title = 'Echo Editor' ,
1819 margins : {
1920 top : marginTop ,
2021 right : marginRight ,
@@ -27,7 +28,7 @@ function printHtml(content: string, exportPdfOptions: ExportPdfOptions) {
2728 <!DOCTYPE html>
2829 <html lang="en">
2930 <head>
30- <title>Echo Editor </title>
31+ <title>${ title } </title>
3132 <meta charset="UTF-8">
3233 <meta name="viewport" content="width=device-width, initial-scale=1.0">
3334 <style>
You can’t perform that action at this time.
0 commit comments