@cenk1cenk2/md-printer 2.21.0 → 3.1.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/README.md +333 -48
- package/bin/dev.js +0 -2
- package/bin/run.js +0 -1
- package/dist/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorate.mjs +1 -2
- package/dist/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorateMetadata.mjs +1 -2
- package/dist/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorateParam.mjs +8 -0
- package/dist/commands/index.mjs +32 -345
- package/dist/components/Date.svelte +1 -0
- package/dist/components/Markdown.svelte +20 -0
- package/dist/components/Nodes.svelte +32 -0
- package/dist/components/Page.svelte +20 -0
- package/dist/components/PageBreak.svelte +5 -0
- package/dist/components/PageNumber.svelte +1 -0
- package/dist/components/SignatureBlock.svelte +56 -0
- package/dist/components/Title.svelte +1 -0
- package/dist/components/TotalPages.svelte +1 -0
- package/dist/components/index.ts +8 -0
- package/dist/constants/file.constants.mjs +1 -8
- package/dist/constants/index.mjs +5 -4
- package/dist/constants/preview.constants.mjs +9 -0
- package/dist/constants/signature.constants.mjs +7 -0
- package/dist/constants/template.constants.mjs +48 -10
- package/dist/interfaces/commands/index.mjs +1 -1
- package/dist/interfaces/commands/run.interface.mjs +1 -1
- package/dist/interfaces/index.mjs +1 -1
- package/dist/interfaces/markdown.interface.mjs +1 -0
- package/dist/interfaces/renderer.interface.mjs +1 -0
- package/dist/interfaces/session.interface.mjs +1 -0
- package/dist/interfaces/signature.interface.mjs +1 -1
- package/dist/interfaces/template.interface.mjs +1 -0
- package/dist/modules/md-printer/md-printer.handler.mjs +113 -0
- package/dist/modules/md-printer/md-printer.module.mjs +21 -0
- package/dist/modules/md-printer/md-printer.schema.mjs +50 -0
- package/dist/services/i18n.service.mjs +12 -15
- package/dist/services/index.mjs +9 -2
- package/dist/services/loopback.mjs +18 -0
- package/dist/services/markdown.service.mjs +123 -0
- package/dist/services/printer.module.mjs +39 -0
- package/dist/services/printer.service.mjs +171 -0
- package/dist/services/renderer/browser.mjs +41 -0
- package/dist/services/renderer/browser.service.mjs +56 -0
- package/dist/services/renderer/renderer.service.mjs +198 -0
- package/dist/services/session/Preview.svelte +238 -0
- package/dist/services/session/preview.service.mjs +187 -0
- package/dist/services/session/session.service.mjs +115 -0
- package/dist/services/signature/adapters/a-trust.adapter.mjs +32 -36
- package/dist/services/signature/index.mjs +1 -2
- package/dist/services/signature/signature.adapter.mjs +1 -2
- package/dist/services/signature/signature.service.mjs +6 -10
- package/dist/services/template/Document.svelte +21 -0
- package/dist/services/template/Margin.svelte +15 -0
- package/dist/services/template/assets.mjs +127 -0
- package/dist/services/template/render.entry.ts +32 -0
- package/dist/services/template/svelte.plugin.mjs +66 -0
- package/dist/services/template/template.service.mjs +211 -0
- package/oclif.manifest.json +49 -36
- package/package.json +69 -35
- package/templates/default/Template.svelte +83 -0
- package/templates/default/settings.json +1 -3
- package/templates/invoice/Template.svelte +247 -0
- package/templates/invoice/components/Client.svelte +42 -0
- package/templates/invoice/components/Company.svelte +41 -0
- package/templates/invoice/components/Items.svelte +66 -0
- package/templates/invoice/components/Notes.svelte +21 -0
- package/templates/invoice/components/Payment.svelte +25 -0
- package/templates/invoice/components/Signature.svelte +34 -0
- package/templates/invoice/components/Totals.svelte +47 -0
- package/templates/invoice/round.js +2 -0
- package/templates/invoice/settings.json +1 -4
- package/templates/kilic.dev/Template.svelte +102 -0
- package/templates/kilic.dev/settings.json +1 -3
- package/templates/mail/Template.svelte +166 -0
- package/templates/mail/settings.json +1 -3
- package/dist/hooks/not-found.hook.mjs +0 -7
- package/dist/hooks/update-notifier.hook.mjs +0 -7
- package/dist/interfaces/pupeteer.mjs +0 -1
- package/templates/default/main.css +0 -73
- package/templates/invoice/.gitignore +0 -1
- package/templates/invoice/footer.html +0 -18
- package/templates/invoice/tailwind.css +0 -164
- package/templates/invoice/template.html.j2 +0 -226
- package/templates/kilic.dev/footer.html +0 -26
- package/templates/kilic.dev/header.html +0 -16
- package/templates/kilic.dev/main.css +0 -74
- package/templates/mail/.gitignore +0 -1
- package/templates/mail/tailwind.css +0 -145
- package/templates/mail/template.html.j2 +0 -14
package/oclif.manifest.json
CHANGED
|
@@ -4,16 +4,15 @@
|
|
|
4
4
|
"aliases": [],
|
|
5
5
|
"args": {
|
|
6
6
|
"file": {
|
|
7
|
-
"description": "
|
|
7
|
+
"description": "Markdown or yaml file to render.",
|
|
8
8
|
"name": "file"
|
|
9
9
|
},
|
|
10
10
|
"output": {
|
|
11
|
-
"description": "Output file
|
|
12
|
-
"name": "output"
|
|
13
|
-
"required": false
|
|
11
|
+
"description": "Output file. Overwrites the one defined in front-matter.",
|
|
12
|
+
"name": "output"
|
|
14
13
|
}
|
|
15
14
|
},
|
|
16
|
-
"description": "
|
|
15
|
+
"description": "Renders a markdown or yaml file through a Svelte template into a PDF or HTML document.",
|
|
17
16
|
"flags": {
|
|
18
17
|
"log-level": {
|
|
19
18
|
"description": "Set the log level of the application.",
|
|
@@ -57,20 +56,14 @@
|
|
|
57
56
|
"stdin": {
|
|
58
57
|
"char": "I",
|
|
59
58
|
"description": "Read the input from stdin.",
|
|
60
|
-
"exclusive": [
|
|
61
|
-
"file"
|
|
62
|
-
],
|
|
63
59
|
"name": "stdin",
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"multiple": false,
|
|
67
|
-
"type": "option"
|
|
60
|
+
"allowNo": false,
|
|
61
|
+
"type": "boolean"
|
|
68
62
|
},
|
|
69
63
|
"input-filetype": {
|
|
70
64
|
"char": "f",
|
|
71
|
-
"description": "
|
|
65
|
+
"description": "Input file type. Detected from the file extension, markdown for stdin and unknown extensions.",
|
|
72
66
|
"name": "input-filetype",
|
|
73
|
-
"default": "md",
|
|
74
67
|
"hasDynamicHelp": false,
|
|
75
68
|
"multiple": false,
|
|
76
69
|
"options": [
|
|
@@ -82,9 +75,8 @@
|
|
|
82
75
|
},
|
|
83
76
|
"output-filetype": {
|
|
84
77
|
"char": "F",
|
|
85
|
-
"description": "
|
|
78
|
+
"description": "Output file type, defaults to pdf. Overwrites the one defined in front-matter.",
|
|
86
79
|
"name": "output-filetype",
|
|
87
|
-
"default": "pdf",
|
|
88
80
|
"hasDynamicHelp": false,
|
|
89
81
|
"multiple": false,
|
|
90
82
|
"options": [
|
|
@@ -95,23 +87,22 @@
|
|
|
95
87
|
},
|
|
96
88
|
"stdout": {
|
|
97
89
|
"char": "O",
|
|
98
|
-
"description": "Write to stdout instead of a file.",
|
|
90
|
+
"description": "Write the output to stdout instead of a file.",
|
|
99
91
|
"name": "stdout",
|
|
100
92
|
"allowNo": false,
|
|
101
93
|
"type": "boolean"
|
|
102
94
|
},
|
|
103
95
|
"template": {
|
|
104
96
|
"char": "t",
|
|
105
|
-
"description": "
|
|
97
|
+
"description": "Built-in template name or path to a template directory, defaults to \"default\". Overwrites the one defined in front-matter.",
|
|
106
98
|
"name": "template",
|
|
107
|
-
"default": "default",
|
|
108
99
|
"hasDynamicHelp": false,
|
|
109
100
|
"multiple": false,
|
|
110
101
|
"type": "option"
|
|
111
102
|
},
|
|
112
103
|
"title": {
|
|
113
104
|
"char": "T",
|
|
114
|
-
"description": "
|
|
105
|
+
"description": "Document title. Overwrites the one defined in front-matter or the template.",
|
|
115
106
|
"name": "title",
|
|
116
107
|
"hasDynamicHelp": false,
|
|
117
108
|
"multiple": false,
|
|
@@ -119,7 +110,7 @@
|
|
|
119
110
|
},
|
|
120
111
|
"language": {
|
|
121
112
|
"char": "l",
|
|
122
|
-
"description": "Language
|
|
113
|
+
"description": "Language for template translations. Overwrites the one defined in front-matter and template settings.",
|
|
123
114
|
"name": "language",
|
|
124
115
|
"hasDynamicHelp": false,
|
|
125
116
|
"multiple": false,
|
|
@@ -127,31 +118,50 @@
|
|
|
127
118
|
},
|
|
128
119
|
"browser": {
|
|
129
120
|
"char": "b",
|
|
130
|
-
"description": "Browser
|
|
121
|
+
"description": "Browser executable used for printing. Discovered automatically when omitted (Brave, Chrome, Chromium, Edge).",
|
|
131
122
|
"name": "browser",
|
|
132
|
-
"default": "/usr/bin/brave",
|
|
133
123
|
"hasDynamicHelp": false,
|
|
134
124
|
"multiple": false,
|
|
135
125
|
"type": "option"
|
|
136
126
|
},
|
|
137
|
-
"
|
|
138
|
-
"
|
|
139
|
-
"
|
|
140
|
-
"name": "watch",
|
|
127
|
+
"continuous": {
|
|
128
|
+
"description": "Render the PDF as a single continuous page without page breaks.",
|
|
129
|
+
"name": "continuous",
|
|
141
130
|
"allowNo": false,
|
|
142
131
|
"type": "boolean"
|
|
143
132
|
},
|
|
144
|
-
"
|
|
145
|
-
"char": "
|
|
146
|
-
"description": "
|
|
147
|
-
"name": "
|
|
133
|
+
"preview": {
|
|
134
|
+
"char": "p",
|
|
135
|
+
"description": "Rebuild whenever the input, the template or its assets change, show the HTML and the PDF in a live preview and rewrite the output file when there is one.",
|
|
136
|
+
"name": "preview",
|
|
148
137
|
"allowNo": false,
|
|
149
138
|
"type": "boolean"
|
|
150
139
|
},
|
|
151
|
-
"
|
|
152
|
-
"description": "
|
|
153
|
-
"name": "
|
|
154
|
-
"
|
|
140
|
+
"host": {
|
|
141
|
+
"description": "Loopback host for the preview server, it serves the files next to the input and is never exposed to the network.",
|
|
142
|
+
"name": "host",
|
|
143
|
+
"default": "127.0.0.1",
|
|
144
|
+
"hasDynamicHelp": false,
|
|
145
|
+
"multiple": false,
|
|
146
|
+
"options": [
|
|
147
|
+
"127.0.0.1",
|
|
148
|
+
"localhost",
|
|
149
|
+
"::1"
|
|
150
|
+
],
|
|
151
|
+
"type": "option"
|
|
152
|
+
},
|
|
153
|
+
"port": {
|
|
154
|
+
"description": "Port for the preview server, random when 0.",
|
|
155
|
+
"name": "port",
|
|
156
|
+
"default": 0,
|
|
157
|
+
"hasDynamicHelp": false,
|
|
158
|
+
"multiple": false,
|
|
159
|
+
"type": "option"
|
|
160
|
+
},
|
|
161
|
+
"open": {
|
|
162
|
+
"description": "Open the preview window, --no-open keeps rebuilding and writing without one.",
|
|
163
|
+
"name": "open",
|
|
164
|
+
"allowNo": true,
|
|
155
165
|
"type": "boolean"
|
|
156
166
|
},
|
|
157
167
|
"sign": {
|
|
@@ -165,6 +175,9 @@
|
|
|
165
175
|
"name": "sign-provider",
|
|
166
176
|
"hasDynamicHelp": false,
|
|
167
177
|
"multiple": false,
|
|
178
|
+
"options": [
|
|
179
|
+
"a-trust"
|
|
180
|
+
],
|
|
168
181
|
"type": "option"
|
|
169
182
|
},
|
|
170
183
|
"sign-certificate": {
|
|
@@ -185,5 +198,5 @@
|
|
|
185
198
|
"enableJsonFlag": false
|
|
186
199
|
}
|
|
187
200
|
},
|
|
188
|
-
"version": "
|
|
201
|
+
"version": "3.1.0"
|
|
189
202
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cenk1cenk2/md-printer",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"module": "dist/index.mjs",
|
|
3
|
+
"version": "3.1.0",
|
|
4
|
+
"description": "Render markdown or yaml through Svelte templates into PDF or HTML with Puppeteer.",
|
|
6
5
|
"type": "module",
|
|
7
6
|
"repository": {
|
|
8
7
|
"type": "git",
|
|
9
|
-
"url": "https://gitlab.kilic.dev/utils/md-printer"
|
|
8
|
+
"url": "https://gitlab.kilic.dev/utils/md-printer.git"
|
|
10
9
|
},
|
|
11
10
|
"author": "Cenk Kilic",
|
|
12
11
|
"license": "MIT",
|
|
@@ -17,7 +16,6 @@
|
|
|
17
16
|
"access": "public"
|
|
18
17
|
},
|
|
19
18
|
"files": [
|
|
20
|
-
"/config",
|
|
21
19
|
"/bin",
|
|
22
20
|
"/dist",
|
|
23
21
|
"/oclif.manifest.json",
|
|
@@ -31,85 +29,121 @@
|
|
|
31
29
|
"target": "./dist/commands/index.mjs"
|
|
32
30
|
},
|
|
33
31
|
"plugins": [
|
|
34
|
-
"@oclif/plugin-help"
|
|
32
|
+
"@oclif/plugin-help",
|
|
33
|
+
"@cenk1cenk2/oclif-common"
|
|
35
34
|
],
|
|
36
|
-
"hooks": {
|
|
37
|
-
"init": [
|
|
38
|
-
"./dist/hooks/update-notifier.hook"
|
|
39
|
-
],
|
|
40
|
-
"command_not_found": "./dist/hooks/not-found.hook"
|
|
41
|
-
},
|
|
42
35
|
"topicSeparator": " "
|
|
43
36
|
},
|
|
44
37
|
"engines": {
|
|
45
|
-
"node": ">=24.
|
|
38
|
+
"node": ">=24.15.0"
|
|
46
39
|
},
|
|
47
40
|
"keywords": [
|
|
41
|
+
"markdown",
|
|
42
|
+
"pdf",
|
|
43
|
+
"svelte",
|
|
44
|
+
"tailwind",
|
|
45
|
+
"puppeteer",
|
|
46
|
+
"invoice",
|
|
47
|
+
"cli",
|
|
48
48
|
"oclif",
|
|
49
49
|
"cenk1cenk2"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@cenk1cenk2/oclif-common": "^
|
|
52
|
+
"@cenk1cenk2/oclif-common": "^8.0.0",
|
|
53
|
+
"@fontsource/montserrat": "^5.3.0",
|
|
53
54
|
"@listr2/manager": "^4.3.1",
|
|
54
55
|
"@nestjs/common": "^12.1.2",
|
|
55
56
|
"@oclif/core": "^5.1.2",
|
|
56
57
|
"@oclif/plugin-help": "^7.0.2",
|
|
57
58
|
"@signpdf/placeholder-plain": "^3.3.0",
|
|
58
59
|
"@signpdf/utils": "^3.3.0",
|
|
59
|
-
"@tailwindcss/
|
|
60
|
-
"@tailwindcss/
|
|
60
|
+
"@tailwindcss/node": "^4.3.3",
|
|
61
|
+
"@tailwindcss/oxide": "^4.3.3",
|
|
61
62
|
"@tailwindcss/typography": "^0.5.20",
|
|
63
|
+
"change-case": "^5.4.4",
|
|
62
64
|
"chokidar": "^5.0.0",
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
65
|
+
"enhanced-resolve": "^5.26.0",
|
|
66
|
+
"entities": "^8.1.0",
|
|
67
|
+
"es-toolkit": "^1.52.0",
|
|
68
|
+
"github-markdown-css": "^5.9.0",
|
|
69
|
+
"hast-util-from-html": "^2.0.3",
|
|
70
|
+
"hast-util-to-html": "^9.0.5",
|
|
71
|
+
"highlight.js": "^11.12.0",
|
|
66
72
|
"i18next": "^26.4.2",
|
|
73
|
+
"lightningcss": "^1.33.0",
|
|
67
74
|
"listr2": "^11.2.0",
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
75
|
+
"lowlight": "^3.3.0",
|
|
76
|
+
"mime": "^4.1.1",
|
|
77
|
+
"perfect-debounce": "^2.1.0",
|
|
78
|
+
"property-information": "^7.2.0",
|
|
79
|
+
"puppeteer-core": "^25.13.0",
|
|
80
|
+
"raw-body": "^4.0.0",
|
|
81
|
+
"rehype-highlight": "^7.0.2",
|
|
82
|
+
"rehype-raw": "^7.0.0",
|
|
83
|
+
"rehype-slug": "^6.0.0",
|
|
84
|
+
"remark-directive": "^4.0.0",
|
|
85
|
+
"remark-frontmatter": "^5.0.0",
|
|
86
|
+
"remark-gfm": "^4.0.1",
|
|
87
|
+
"remark-parse": "^11.0.0",
|
|
88
|
+
"remark-rehype": "^11.1.2",
|
|
89
|
+
"rolldown": "^1.2.13",
|
|
72
90
|
"rxjs": "^7.8.2",
|
|
73
|
-
"
|
|
91
|
+
"serve-static": "^2.2.1",
|
|
74
92
|
"source-map-support": "^0.5.21",
|
|
93
|
+
"srcset": "^5.0.3",
|
|
94
|
+
"svelte": "^5.57.2",
|
|
75
95
|
"tailwindcss": "^4.3.3",
|
|
76
|
-
"
|
|
96
|
+
"unified": "^11.0.5",
|
|
97
|
+
"unist-util-visit": "^5.1.0",
|
|
98
|
+
"vfile": "^6.0.3",
|
|
99
|
+
"vfile-matter": "^5.0.1",
|
|
100
|
+
"which": "^7.0.0",
|
|
101
|
+
"write-file-atomic": "^8.0.0",
|
|
102
|
+
"yaml": "^2.9.1",
|
|
103
|
+
"zod": "^4.6.7"
|
|
77
104
|
},
|
|
78
105
|
"devDependencies": {
|
|
79
106
|
"@cenk1cenk2/cz-cc": "^3.0.6",
|
|
80
107
|
"@cenk1cenk2/eslint-config": "^3.3.9",
|
|
81
108
|
"@tsconfig/node24": "^24.0.5",
|
|
82
|
-
"@types/
|
|
109
|
+
"@types/hast": "^3.0.5",
|
|
110
|
+
"@types/mdast": "^4.0.4",
|
|
83
111
|
"@types/node": "^24.19.1",
|
|
84
|
-
"@types/
|
|
85
|
-
"@types/
|
|
112
|
+
"@types/serve-static": "^2.2.0",
|
|
113
|
+
"@types/which": "^3.0.4",
|
|
114
|
+
"@types/write-file-atomic": "^4.0.3",
|
|
86
115
|
"eslint": "^10.12.0",
|
|
116
|
+
"eslint-plugin-svelte": "^3.23.1",
|
|
87
117
|
"execa": "^10.1.0",
|
|
88
|
-
"globby": "^16.2.4",
|
|
89
118
|
"oclif": "^6.0.2",
|
|
90
119
|
"prettier": "^3.9.9",
|
|
91
|
-
"prettier-plugin-
|
|
92
|
-
"
|
|
93
|
-
"tpm": "^1.4.14",
|
|
120
|
+
"prettier-plugin-svelte": "^4.1.1",
|
|
121
|
+
"svelte-eslint-parser": "^1.9.0",
|
|
94
122
|
"ts-node": "^10.9.2",
|
|
95
123
|
"tsconfig-paths": "^4.2.0",
|
|
96
124
|
"tsdown": "^0.23.0",
|
|
97
|
-
"typescript": "^6.0.3"
|
|
125
|
+
"typescript": "^6.0.3",
|
|
126
|
+
"vite": "^8.3.4",
|
|
127
|
+
"vitest": "^5.0.4"
|
|
98
128
|
},
|
|
99
129
|
"config": {
|
|
100
130
|
"commitizen": {
|
|
101
131
|
"path": "./node_modules/@cenk1cenk2/cz-cc"
|
|
102
132
|
}
|
|
103
133
|
},
|
|
134
|
+
"bugs": {
|
|
135
|
+
"url": "https://gitlab.kilic.dev/utils/md-printer/-/issues"
|
|
136
|
+
},
|
|
137
|
+
"homepage": "https://gitlab.kilic.dev/utils/md-printer",
|
|
104
138
|
"scripts": {
|
|
105
139
|
"dev": "./bin/dev.js",
|
|
106
140
|
"start": "./bin/run.js",
|
|
107
141
|
"build": "tsdown",
|
|
108
142
|
"dev:start": "tsdown --watch src/",
|
|
109
|
-
"clean": "rimraf oclif.manifest.json",
|
|
110
143
|
"format": "prettier --write src/ --log-level warn && eslint --fix",
|
|
111
144
|
"lint": "eslint",
|
|
112
145
|
"manifest": "oclif manifest",
|
|
113
|
-
"
|
|
146
|
+
"typecheck": "tsc --noEmit",
|
|
147
|
+
"test": "vitest run"
|
|
114
148
|
}
|
|
115
149
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { Markdown, Page } from '@cenk1cenk2/md-printer/components'
|
|
3
|
+
|
|
4
|
+
let { data } = $props()
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<svelte:head>
|
|
8
|
+
{#if data.documentTitle}
|
|
9
|
+
<title>{data.documentTitle}</title>
|
|
10
|
+
{/if}
|
|
11
|
+
</svelte:head>
|
|
12
|
+
|
|
13
|
+
<Page>
|
|
14
|
+
<Markdown />
|
|
15
|
+
</Page>
|
|
16
|
+
|
|
17
|
+
<style lang="postcss">
|
|
18
|
+
@import 'github-markdown-css/github-markdown-light.css';
|
|
19
|
+
@import '@fontsource/montserrat/latin-400.css';
|
|
20
|
+
@import '@fontsource/montserrat/latin-ext-400.css';
|
|
21
|
+
@import '@fontsource/montserrat/latin-700.css';
|
|
22
|
+
@import '@fontsource/montserrat/latin-ext-700.css';
|
|
23
|
+
@import '@fontsource/montserrat/latin-800.css';
|
|
24
|
+
@import '@fontsource/montserrat/latin-ext-800.css';
|
|
25
|
+
|
|
26
|
+
.markdown-body {
|
|
27
|
+
font-size: 11px;
|
|
28
|
+
font-family: 'Montserrat', sans-serif;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.markdown-body h1,
|
|
32
|
+
.markdown-body h2 {
|
|
33
|
+
font-weight: 800;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.markdown-body h3,
|
|
37
|
+
.markdown-body h4,
|
|
38
|
+
.markdown-body h5,
|
|
39
|
+
.markdown-body h6,
|
|
40
|
+
.markdown-body strong,
|
|
41
|
+
.markdown-body b {
|
|
42
|
+
font-weight: 700;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.markdown-body pre > code {
|
|
46
|
+
white-space: pre-wrap;
|
|
47
|
+
padding: 0;
|
|
48
|
+
margin: 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.markdown-body .document-title-header {
|
|
52
|
+
height: 500px;
|
|
53
|
+
margin: auto auto;
|
|
54
|
+
padding-top: 50%;
|
|
55
|
+
break-after: page;
|
|
56
|
+
border-bottom: 0;
|
|
57
|
+
font-size: 2.5em;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.markdown-body pre {
|
|
61
|
+
padding: 12px 8px;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.markdown-body output pre {
|
|
65
|
+
margin-top: -36px;
|
|
66
|
+
border-top-left-radius: 0;
|
|
67
|
+
border-top-right-radius: 0;
|
|
68
|
+
border-top: 2px solid #d1d9e0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.markdown-body output::before {
|
|
72
|
+
padding: 4px 16px;
|
|
73
|
+
position: relative;
|
|
74
|
+
top: -24px;
|
|
75
|
+
border-top-left-radius: 4px;
|
|
76
|
+
border-top-right-radius: 4px;
|
|
77
|
+
border-top: 2px solid #d1d9e0;
|
|
78
|
+
color: #59636e;
|
|
79
|
+
background-color: #f6f8fa;
|
|
80
|
+
content: '> output';
|
|
81
|
+
font-size: 0.85em;
|
|
82
|
+
}
|
|
83
|
+
</style>
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Client from './components/Client.svelte'
|
|
3
|
+
import Company from './components/Company.svelte'
|
|
4
|
+
import Items from './components/Items.svelte'
|
|
5
|
+
import Notes from './components/Notes.svelte'
|
|
6
|
+
import Payment from './components/Payment.svelte'
|
|
7
|
+
import Signature from './components/Signature.svelte'
|
|
8
|
+
import Totals from './components/Totals.svelte'
|
|
9
|
+
import { Page, PageNumber, TotalPages, Title } from '@cenk1cenk2/md-printer/components'
|
|
10
|
+
|
|
11
|
+
let { data, content, t, signature } = $props()
|
|
12
|
+
|
|
13
|
+
const { company = {}, client = {}, payment = {}, currency = '', date, id } = $derived(data)
|
|
14
|
+
|
|
15
|
+
const rows = $derived.by(() =>
|
|
16
|
+
(data.items ?? []).map((item) => {
|
|
17
|
+
const subtotal = item.quantity * item.price
|
|
18
|
+
const tax = (subtotal * item.tax) / 100
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
item,
|
|
22
|
+
subtotal,
|
|
23
|
+
tax,
|
|
24
|
+
total: subtotal + tax
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
)
|
|
28
|
+
const calculatedSubtotal = $derived(rows.reduce((sum, row) => sum + row.subtotal, 0))
|
|
29
|
+
const calculatedTax = $derived(rows.reduce((sum, row) => sum + row.tax, 0))
|
|
30
|
+
const calculatedTotal = $derived(calculatedSubtotal + calculatedTax)
|
|
31
|
+
|
|
32
|
+
const title = $derived(
|
|
33
|
+
`${date} - Invoice from ${company.name}${company.tax_number ? ` (${company.tax_number})` : ''} to ${client.name}${client.tax_number ? ` (${client.tax_number})` : ''} - #${id}`
|
|
34
|
+
)
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<svelte:head>
|
|
38
|
+
<title>{title}</title>
|
|
39
|
+
</svelte:head>
|
|
40
|
+
|
|
41
|
+
<Page>
|
|
42
|
+
{#snippet footer()}
|
|
43
|
+
<div style="margin: 0 auto; text-align: center; font-size: 8px; color: #38404b; width: 100%; padding-top: 8px; margin-bottom: -8px;">
|
|
44
|
+
<Title />
|
|
45
|
+
-
|
|
46
|
+
<b> <PageNumber />/<TotalPages /> </b>
|
|
47
|
+
</div>
|
|
48
|
+
{/snippet}
|
|
49
|
+
|
|
50
|
+
<div class="max-w-full leading-tight prose grid">
|
|
51
|
+
<section id="header" class="relative grid grid-cols-12">
|
|
52
|
+
<Company {company} {t} />
|
|
53
|
+
</section>
|
|
54
|
+
<section id="client" class="grid grid-cols-12">
|
|
55
|
+
<Client {client} {date} {id} {t} />
|
|
56
|
+
</section>
|
|
57
|
+
<section id="items" class="grid grid-cols-12">
|
|
58
|
+
<Items {rows} {currency} {t} />
|
|
59
|
+
</section>
|
|
60
|
+
<section id="payment" class="grid grid-cols-12">
|
|
61
|
+
<Payment {payment} {t} />
|
|
62
|
+
<div class="col-span-1"></div>
|
|
63
|
+
<Totals subtotal={calculatedSubtotal} tax={calculatedTax} total={calculatedTotal} {currency} {t} />
|
|
64
|
+
</section>
|
|
65
|
+
<section id="footer" class="grid grid-cols-12">
|
|
66
|
+
<Notes {content} {t} />
|
|
67
|
+
<div class="col-span-1"></div>
|
|
68
|
+
<Signature {signature} {t} />
|
|
69
|
+
</section>
|
|
70
|
+
</div>
|
|
71
|
+
</Page>
|
|
72
|
+
|
|
73
|
+
<style lang="postcss">
|
|
74
|
+
@import '@fontsource/montserrat/latin-400.css';
|
|
75
|
+
@import '@fontsource/montserrat/latin-ext-400.css';
|
|
76
|
+
@import '@fontsource/montserrat/latin-500.css';
|
|
77
|
+
@import '@fontsource/montserrat/latin-ext-500.css';
|
|
78
|
+
@import '@fontsource/montserrat/latin-700.css';
|
|
79
|
+
@import '@fontsource/montserrat/latin-ext-700.css';
|
|
80
|
+
@import '@fontsource/montserrat/latin-800.css';
|
|
81
|
+
@import '@fontsource/montserrat/latin-ext-800.css';
|
|
82
|
+
@import '@fontsource/montserrat/latin-900.css';
|
|
83
|
+
@import '@fontsource/montserrat/latin-ext-900.css';
|
|
84
|
+
|
|
85
|
+
@import 'tailwindcss';
|
|
86
|
+
@plugin '@tailwindcss/typography';
|
|
87
|
+
|
|
88
|
+
@theme {
|
|
89
|
+
--font-sans: 'Montserrat';
|
|
90
|
+
--font-serif: 'Montserrat';
|
|
91
|
+
--font-weight-semibold: 700;
|
|
92
|
+
--font-weight-bold: 800;
|
|
93
|
+
--font-weight-extrabold: 900;
|
|
94
|
+
--color-primary-500: #cd0043;
|
|
95
|
+
--color-gray-50: oklch(98.5% 0.002 247.839);
|
|
96
|
+
--color-gray-100: #abb2bf;
|
|
97
|
+
--color-gray-200: #979eab;
|
|
98
|
+
--color-gray-300: #7c8a9d;
|
|
99
|
+
--color-gray-400: #5c6370;
|
|
100
|
+
--color-gray-500: #4b5263;
|
|
101
|
+
--color-gray-600: #2c333d;
|
|
102
|
+
--color-gray-700: #22282f;
|
|
103
|
+
--color-gray-800: #1e2127;
|
|
104
|
+
--color-gray-900: #17191e;
|
|
105
|
+
--color-gray-950: oklch(13% 0.028 261.692);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
*,
|
|
109
|
+
::after,
|
|
110
|
+
::before,
|
|
111
|
+
::backdrop,
|
|
112
|
+
::file-selector-button {
|
|
113
|
+
border-color: var(--color-gray-200, currentcolor);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
body {
|
|
117
|
+
font-family: var(--font-sans);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
address {
|
|
121
|
+
@apply text-sm;
|
|
122
|
+
white-space: pre-line;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* Typography styles converted from config */
|
|
126
|
+
.prose a {
|
|
127
|
+
text-decoration: none;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.prose h1 {
|
|
131
|
+
font-weight: 800;
|
|
132
|
+
padding-top: 0.1875rem;
|
|
133
|
+
/* 0.75 * 0.25rem */
|
|
134
|
+
padding-bottom: 0.1875rem;
|
|
135
|
+
margin-bottom: 0;
|
|
136
|
+
margin-top: 0;
|
|
137
|
+
border-width: 0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.prose h2 {
|
|
141
|
+
font-weight: 800;
|
|
142
|
+
padding-top: 0.125rem;
|
|
143
|
+
/* 0.5 * 0.25rem */
|
|
144
|
+
padding-bottom: 0.125rem;
|
|
145
|
+
margin-bottom: 0;
|
|
146
|
+
margin-top: 0;
|
|
147
|
+
border-width: 0;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.prose h3 {
|
|
151
|
+
font-weight: 700;
|
|
152
|
+
padding-top: 0.0625rem;
|
|
153
|
+
/* 0.25 * 0.25rem */
|
|
154
|
+
padding-bottom: 0.0625rem;
|
|
155
|
+
margin-bottom: 0;
|
|
156
|
+
margin-top: 0;
|
|
157
|
+
border-width: 0;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
p {
|
|
161
|
+
margin: 0.1em 0em;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.prose blockquote {
|
|
165
|
+
font-weight: 400;
|
|
166
|
+
color: var(--color-gray-600);
|
|
167
|
+
font-style: normal;
|
|
168
|
+
quotes: '\201C' '\201D' '\2018' '\2019';
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.prose blockquote p:first-of-type::before {
|
|
172
|
+
content: '';
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.prose blockquote p:last-of-type::after {
|
|
176
|
+
content: '';
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.prose ul > li {
|
|
180
|
+
padding-left: 1em;
|
|
181
|
+
text-align: left;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.prose ol > li {
|
|
185
|
+
padding-left: 1em;
|
|
186
|
+
text-align: left;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.prose ol > li::before {
|
|
190
|
+
top: calc(0.875em - 0.1em);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.prose ul > li::before {
|
|
194
|
+
top: calc(0.875em - 0.1em);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
html {
|
|
198
|
+
font-size: 12px;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.page-break {
|
|
202
|
+
page-break-after: always;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.text-vertical {
|
|
206
|
+
text-orientation: upright;
|
|
207
|
+
writing-mode: vertical-lr;
|
|
208
|
+
display: flex;
|
|
209
|
+
flex-direction: column;
|
|
210
|
+
justify-content: center;
|
|
211
|
+
@apply p-4;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/* md-to-pdf ships github-markdown-css, which sets `table { display: block }` for horizontal
|
|
215
|
+
* scrolling. That collapses rows into an anonymous max-content box, so column widths are ignored. */
|
|
216
|
+
table {
|
|
217
|
+
display: table;
|
|
218
|
+
width: 100%;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
table th {
|
|
222
|
+
@apply bg-gray-700 text-white;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
table tr {
|
|
226
|
+
border-top: 0;
|
|
227
|
+
break-inside: avoid;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/* zebra rows only pay off over many rows, so striping is opt-in; the short key/value
|
|
231
|
+
* tables use hairline row dividers instead and stay quieter beside the items table.
|
|
232
|
+
* The reset is needed because md-to-pdf's markdown.css stripes every table itself. */
|
|
233
|
+
table tr:nth-child(even) {
|
|
234
|
+
background-color: transparent;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
table.striped tr:nth-child(even) {
|
|
238
|
+
@apply bg-gray-50;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
table th,
|
|
242
|
+
table td,
|
|
243
|
+
table tr {
|
|
244
|
+
border: 0;
|
|
245
|
+
padding: 0.5em 0.5em;
|
|
246
|
+
}
|
|
247
|
+
</style>
|