TagSpaces is an offline, open source, document manager with tagging support
chore: remove usage of marked lib and printing entry description
Ilian Sapundshievce39518d1f11
diff --git a/package-lock.json b/package-lock.jsonindex 1f8a0998f..b9b58467b 100644--- a/package-lock.json+++ b/package-lock.json@@ -49,7 +49,6 @@"i18next": "^23.4.6","i18next-http-backend": "^2.2.2","leaflet": "^1.9.4",- "marked": "^4.0.12","mgrs": "^1.0.0","open-location-code": "^1.0.3","open-location-code-typescript": "^1.5.0",@@ -13570,6 +13569,13 @@"react-dom": "*"}},+ "node_modules/@tagspacespro/tagspacespro": {+ "version": "5.0.19",+ "resolved": "https://npm.pkg.github.com/download/@tagspacespro/tagspacespro/5.0.19/59fd47d16d6842df95662ea6393c8ee7768f677d",+ "integrity": "sha512-kDI0hmNOputR7sPWVWhQkTDU1q6FpwROKWQwacXiBEVtUQcclI8i0YWmajlX4SqCcEqCLSLe0bY/ZuGtbarmOA==",+ "license": "Proprietary",+ "optional": true+ },"node_modules/@teamsupercell/typings-for-css-modules-loader": {"version": "2.5.2","resolved": "https://registry.npmjs.org/@teamsupercell/typings-for-css-modules-loader/-/typings-for-css-modules-loader-2.5.2.tgz",@@ -29841,17 +29847,6 @@"url": "https://github.com/sponsors/wooorm"}},- "node_modules/marked": {- "version": "4.3.0",- "resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz",- "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==",- "bin": {- "marked": "bin/marked.js"- },- "engines": {- "node": ">= 12"- }- },"node_modules/marky": {"version": "1.2.5","resolved": "https://registry.npmjs.org/marky/-/marky-1.2.5.tgz",@@ -54684,6 +54679,12 @@"tailwind-nord": "^1.3.0"}},+ "@tagspacespro/tagspacespro": {+ "version": "5.0.19",+ "resolved": "https://npm.pkg.github.com/download/@tagspacespro/tagspacespro/5.0.19/59fd47d16d6842df95662ea6393c8ee7768f677d",+ "integrity": "sha512-kDI0hmNOputR7sPWVWhQkTDU1q6FpwROKWQwacXiBEVtUQcclI8i0YWmajlX4SqCcEqCLSLe0bY/ZuGtbarmOA==",+ "optional": true+ },"@teamsupercell/typings-for-css-modules-loader": {"version": "2.5.2","resolved": "https://registry.npmjs.org/@teamsupercell/typings-for-css-modules-loader/-/typings-for-css-modules-loader-2.5.2.tgz",@@ -67187,11 +67188,6 @@"resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-3.0.3.tgz","integrity": "sha512-Z1NL3Tb1M9wH4XESsCDEksWoKTdlUafKc4pt0GRwjUyXaCFZ+dc3g2erqB6zm3szA2IUSi7VnPI+o/9jnxh9hw=="},- "marked": {- "version": "4.3.0",- "resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz",- "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A=="- },"marky": {"version": "1.2.5","resolved": "https://registry.npmjs.org/marky/-/marky-1.2.5.tgz",diff --git a/package.json b/package.jsonindex cecb4d2a0..478cbfa8f 100644--- a/package.json+++ b/package.json@@ -187,7 +187,6 @@"i18next": "^23.4.6","i18next-http-backend": "^2.2.2","leaflet": "^1.9.4",- "marked": "^4.0.12","mgrs": "^1.0.0","open-location-code": "^1.0.3","open-location-code-typescript": "^1.5.0",diff --git a/src/renderer/components/EditDescriptionButtons.tsx b/src/renderer/components/EditDescriptionButtons.tsxindex d55ac34b6..7192741b3 100644--- a/src/renderer/components/EditDescriptionButtons.tsx+++ b/src/renderer/components/EditDescriptionButtons.tsx@@ -3,7 +3,6 @@ import { styled } from '@mui/material/styles';import Button from '@mui/material/Button';import { ProTooltip } from '-/components/HelperComponents';import { Pro } from '-/pro';-import { convertMarkDown } from '-/services/utils-io';import { useTranslation } from 'react-i18next';import { useDescriptionContext } from '-/hooks/useDescriptionContext';import ConfirmDialog from '-/components/dialogs/ConfirmDialog';@@ -61,24 +60,24 @@ const EditDescriptionButtons: React.FC<Props> = ({}}, [editMode]);- const printHTML = () => {- const sanitizedDescription = description- ? convertMarkDown(description, currentDirectoryPath)- : t('core:addMarkdownDescription');+ // const printHTML = () => {+ // const sanitizedDescription = description+ // ? convertMarkDown(description, currentDirectoryPath)+ // : t('core:addMarkdownDescription');- const printWin = window.open('', 'PRINT', 'height=400,width=600');- printWin.document.write(- '<html><head><title>' + currentDirectoryPath + ' 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 printWin = window.open('', 'PRINT', 'height=400,width=600');+ // printWin.document.write(+ // '<html><head><title>' + currentDirectoryPath + ' 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;+ // };return (<Root>@@ -92,11 +91,11 @@ const EditDescriptionButtons: React.FC<Props> = ({{t(isDescriptionChanged ? 'core:cancel' : 'core:close')}</Button>)}- {!editMode && (+ {/* {!editMode && (<Button className={classes.button} onClick={printHTML}>{t('core:print')}</Button>- )}+ )} */}<ProTooltip tooltip={t('editDescription')}><Buttondata-tid="editDescriptionTID"diff --git a/src/renderer/services/utils-io.ts b/src/renderer/services/utils-io.tsindex c2330c88f..05a6c1655 100644--- a/src/renderer/services/utils-io.ts+++ b/src/renderer/services/utils-io.ts@@ -1310,57 +1310,57 @@ export function getDescriptionPreview(mdContent, maxLength = 200) {return preview.replace(/[#*!_\[\]()`]/g, '');}-export function removeMarkDown(mdContent) {- if (!mdContent) return '';- let result = marked.parse(DOMPurify.sanitize(mdContent));- const span = document.createElement('span');- span.innerHTML = result;- result = span.textContent || span.innerText;- return result;-}--export function convertMarkDown(mdContent: string, directoryPath: string) {- const customRenderer = new marked.Renderer();- customRenderer.link = (href, title, text) => `- <a href="#"- title="${href}"- onClick="event.preventDefault(); event.stopPropagation(); window.postMessage(JSON.stringify({ command: 'openLinkExternally', link: '${href}' }), '*'); return false;">- ${text}- </a>`;-- customRenderer.image = (href, title, text) => {- let sourceUrl = href;- const dirSep = PlatformIO.getDirSeparator();- if (- !sourceUrl.startsWith('http') &&- directoryPath &&- directoryPath !== dirSep- ) {- sourceUrl = directoryPath.endsWith(dirSep)- ? directoryPath + sourceUrl- : directoryPath + dirSep + sourceUrl;- }- if (PlatformIO.haveObjectStoreSupport() || PlatformIO.haveWebDavSupport()) {- sourceUrl = PlatformIO.getURLforPath(sourceUrl);- }- return `<img src="${sourceUrl}" style="max-width: 100%">- ${text}- </img>`;- };-- marked.setOptions({- renderer: customRenderer,- pedantic: false,- gfm: true,- tables: true,- breaks: false,- smartLists: true,- smartypants: false,- xhtml: true,- });-- return marked.parse(DOMPurify.sanitize(mdContent));-}+// export function removeMarkDown(mdContent) {+// if (!mdContent) return '';+// let result = marked.parse(DOMPurify.sanitize(mdContent));+// const span = document.createElement('span');+// span.innerHTML = result;+// result = span.textContent || span.innerText;+// return result;+// }++// export function convertMarkDown(mdContent: string, directoryPath: string) {+// const customRenderer = new marked.Renderer();+// customRenderer.link = (href, title, text) => `+// <a href="#"+// title="${href}"+// onClick="event.preventDefault(); event.stopPropagation(); window.postMessage(JSON.stringify({ command: 'openLinkExternally', link: '${href}' }), '*'); return false;">+// ${text}+// </a>`;++// customRenderer.image = (href, title, text) => {+// let sourceUrl = href;+// const dirSep = PlatformIO.getDirSeparator();+// if (+// !sourceUrl.startsWith('http') &&+// directoryPath &&+// directoryPath !== dirSep+// ) {+// sourceUrl = directoryPath.endsWith(dirSep)+// ? directoryPath + sourceUrl+// : directoryPath + dirSep + sourceUrl;+// }+// if (PlatformIO.haveObjectStoreSupport() || PlatformIO.haveWebDavSupport()) {+// sourceUrl = PlatformIO.getURLforPath(sourceUrl);+// }+// return `<img src="${sourceUrl}" style="max-width: 100%">+// ${text}+// </img>`;+// };+//+// marked.setOptions({+// renderer: customRenderer,+// pedantic: false,+// gfm: true,+// tables: true,+// breaks: false,+// smartLists: true,+// smartypants: false,+// xhtml: true,+// });++// return marked.parse(DOMPurify.sanitize(mdContent));+// }/*** forbidden characters # \ / * ? " < > |