TagSpaces is an offline, open source, document manager with tagging support
feature: added print functionality for the entry description
Ilian Sapundshiev0def7b0fa644
diff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsxindex 4ccc22405..12772bdb7 100644--- a/app/components/EntryProperties.tsx+++ b/app/components/EntryProperties.tsx@@ -203,6 +203,21 @@ const EntryProperties = (props: Props) => {): props.openedEntry.path;+ const printHTML = html => {+ const printWin = window.open('', 'PRINT', 'height=400,width=600');+ printWin.document.write(+ '<html><head><title>' + entryName + ' description</title>'+ );+ printWin.document.write('</head><body >');+ printWin.document.write(sanitizedDescription);+ printWin.document.write('</body></html>');+ printWin.document.close(); // necessary for IE >= 10+ printWin.focus(); // necessary for IE >= 10*/+ printWin.print();+ // printWin.close();+ return true;+ };+const customRenderer = new marked.Renderer();customRenderer.link = (href, title, text) => `<a href="#"@@ -633,6 +648,10 @@ const EntryProperties = (props: Props) => {);}+ const sanitizedDescription = currentEntry.description+ ? marked(DOMPurify.sanitize(currentEntry.description))+ : i18n.t('core:addMarkdownDescription');+// @ts-ignorereturn (<div className={classes.entryProperties}>@@ -819,6 +838,14 @@ const EntryProperties = (props: Props) => {{i18n.t('core:cancel')}</Button>)}+ {editDescription === undefined && (+ <Button+ className={classes.button}+ onClick={() => printHTML(sanitizedDescription)}+ >+ {i18n.t('core:print')}+ </Button>+ )}<ProTooltip tooltip={i18n.t('editDescription')}><Buttoncolor="primary"@@ -887,9 +914,7 @@ const EntryProperties = (props: Props) => {id="descriptionArea"dangerouslySetInnerHTML={{// eslint-disable-next-line no-nested-ternary- __html: currentEntry.description- ? marked(DOMPurify.sanitize(currentEntry.description))- : i18n.t('core:addMarkdownDescription')+ __html: sanitizedDescription}}onDoubleClick={() => {if (!currentEntry.editMode && editName === undefined) {diff --git a/app/locales/en/core.json b/app/locales/en/core.jsonindex 0355019d6..e95341651 100644--- a/app/locales/en/core.json+++ b/app/locales/en/core.json@@ -632,5 +632,6 @@"contactUs": "Contact us","sessionToken": "Session Token","s3serviceURL": "URL of the S3 service",+ "print": "Print","-": "-"}diff --git a/app/services/electron-menus.ts b/app/services/electron-menus.tsindex c9a1961c8..2b03825e2 100644--- a/app/services/electron-menus.ts+++ b/app/services/electron-menus.ts@@ -59,6 +59,15 @@ export default function buildDesktopMenu(props: any, i18n) {{type: 'separator'},+ {+ label: i18n.t('print'),+ accelerator: 'CmdOrCtrl+p',+ click: (item, focusedWindow) => {+ if (focusedWindow.webContents && focusedWindow.webContents.print) {+ focusedWindow.webContents.print();+ }+ }+ },{type: 'separator'},