Skip to content

Build your personal knowledge base with Trilium Notes

refactor(deps): get rid of print-this

Elian Doran2cc7113c2c09
diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts
index bdb4e311e1..6ffc2cf988 100644
--- a/bin/copy-dist.ts
+++ b/bin/copy-dist.ts
@@ -81,7 +81,6 @@ const copy = async () => {
"node_modules/mermaid/dist/",
"node_modules/jquery/dist/",
"node_modules/jquery-hotkeys/",
- "node_modules/print-this/",
"node_modules/split.js/dist/",
"node_modules/panzoom/dist/",
"node_modules/i18next/",
diff --git a/package-lock.json b/package-lock.json
index da8a3c3130..49e0287348 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -78,7 +78,6 @@
"normalize-strings": "1.1.1",
"normalize.css": "8.0.1",
"panzoom": "9.4.3",
- "print-this": "2.0.0",
"rand-token": "1.0.1",
"react": "18.3.1",
"react-dom": "18.3.1",
@@ -12681,15 +12680,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
- "node_modules/opencollective-postinstall": {
- "version": "2.0.3",
- "resolved": "https://registry.npmjs.org/opencollective-postinstall/-/opencollective-postinstall-2.0.3.tgz",
- "integrity": "sha512-8AV/sCtuzUeTo8gQK5qDZzARrulB3egtLzFgteqB2tcT4Mw7B8Kt7JcDHmltjz6FOAHsvTevk70gZEbhM4ZS9Q==",
- "license": "MIT",
- "bin": {
- "opencollective-postinstall": "index.js"
- }
- },
"node_modules/ora": {
"version": "5.4.1",
"resolved": "https://registry.npmjs.org/ora/-/ora-5.4.1.tgz",
@@ -13495,17 +13485,6 @@
"url": "https://github.com/prettier/prettier?sponsor=1"
}
},
- "node_modules/print-this": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/print-this/-/print-this-2.0.0.tgz",
- "integrity": "sha512-/v1/tXs4BQGpEF7OYKe05h4xiQR09Q4HgASL28pngx6aedCQaB1OlHs8t9RDVgUayXHDWHG9V5EBjPlXb46k4w==",
- "hasInstallScript": true,
- "license": "MIT",
- "dependencies": {
- "jquery": ">=1.11",
- "opencollective-postinstall": "^2.0.2"
- }
- },
"node_modules/proc-log": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/proc-log/-/proc-log-2.0.1.tgz",
diff --git a/package.json b/package.json
index c847354958..4216a3d267 100644
--- a/package.json
+++ b/package.json
@@ -123,7 +123,6 @@
"normalize-strings": "1.1.1",
"normalize.css": "8.0.1",
"panzoom": "9.4.3",
- "print-this": "2.0.0",
"rand-token": "1.0.1",
"react": "18.3.1",
"react-dom": "18.3.1",
diff --git a/src/public/app/services/library_loader.ts b/src/public/app/services/library_loader.ts
index f8b3633024..0cb836f399 100644
--- a/src/public/app/services/library_loader.ts
+++ b/src/public/app/services/library_loader.ts
@@ -51,10 +51,6 @@ const RELATION_MAP: Library = {
css: ["stylesheets/relation_map.css"]
};
-const PRINT_THIS: Library = {
- js: ["node_modules/print-this/printThis.js"]
-};
-
const CALENDAR_WIDGET: Library = {
css: ["stylesheets/calendar.css"]
};
@@ -193,7 +189,6 @@ export default {
CODE_MIRROR,
ESLINT,
RELATION_MAP,
- PRINT_THIS,
CALENDAR_WIDGET,
KATEX,
WHEEL_ZOOM,
diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.js
index 7c3de4426c..21f84dbc18 100644
--- a/src/public/app/widgets/note_detail.js
+++ b/src/public/app/widgets/note_detail.js
@@ -250,46 +250,7 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
return;
}
- await libraryLoader.requireLibrary(libraryLoader.PRINT_THIS);
-
- let $promotedAttributes = $("");
-
- if (this.note.getPromotedDefinitionAttributes().length > 0) {
- $promotedAttributes = (await attributeRenderer.renderNormalAttributes(this.note)).$renderedAttributes;
- }
-
- const { assetPath } = window.glob;
- const cssToLoad = [
- `${assetPath}/node_modules/codemirror/lib/codemirror.css`,
- `${assetPath}/libraries/ckeditor/ckeditor-content.css`,
- `${assetPath}/node_modules/bootstrap/dist/css/bootstrap.min.css`,
- `${assetPath}/node_modules/katex/dist/katex.min.css`,
- `${assetPath}/stylesheets/print.css`,
- `${assetPath}/stylesheets/relation_map.css`,
- `${assetPath}/stylesheets/ckeditor-theme.css`
- ];
-
- if (isSyntaxHighlightEnabled()) {
- cssToLoad.push(getStylesheetUrl("default:vs"));
- }
-
- this.$widget.find(".note-detail-printable:visible").printThis({
- header: $("<div>").append($("<h2>").text(this.note.title)).append($promotedAttributes).prop("outerHTML"),
-
- footer: `
-<script src="${assetPath}/node_modules/katex/dist/katex.min.js"></script>
-<script src="${assetPath}/node_modules/katex/dist/contrib/mhchem.min.js"></script>
-<script src="${assetPath}/node_modules/katex/dist/contrib/auto-render.min.js"></script>
-<script>
- document.body.className += ' ck-content printed-content';
-
- renderMathInElement(document.body, {trust: true});
-</script>
-`,
- importCSS: false,
- loadCSS: cssToLoad,
- debug: true
- });
+ window.print();
}
async exportAsPdfEvent() {
diff --git a/src/routes/assets.ts b/src/routes/assets.ts
index c20c468d0b..959de788b6 100644
--- a/src/routes/assets.ts
+++ b/src/routes/assets.ts
@@ -66,8 +66,6 @@ async function register(app: express.Application) {
app.use(`/${assetPath}/node_modules/jquery-hotkeys/`, persistentCacheStatic(path.join(srcRoot, "..", "node_modules/jquery-hotkeys/")));
- app.use(`/${assetPath}/node_modules/print-this/`, persistentCacheStatic(path.join(srcRoot, "..", "node_modules/print-this/")));
-
app.use(`/${assetPath}/node_modules/split.js/dist/`, persistentCacheStatic(path.join(srcRoot, "..", "node_modules/split.js/dist/")));
app.use(`/${assetPath}/node_modules/panzoom/dist/`, persistentCacheStatic(path.join(srcRoot, "..", "node_modules/panzoom/dist/")));