diff --git a/opencti-platform/opencti-front/package.json b/opencti-platform/opencti-front/package.json index 10f0ce40cb65..6afe6e1df160 100644 --- a/opencti-platform/opencti-front/package.json +++ b/opencti-platform/opencti-front/package.json @@ -25,6 +25,7 @@ "analytics": "0.8.14", "apexcharts": "3.53.0", "axios": "1.7.7", + "buffer": "6.0.3", "ckeditor5-custom-build": "0.0.1", "classnames": "2.5.1", "convert": "5.4.0", @@ -47,6 +48,7 @@ "js-file-download": "0.4.12", "leaflet": "1.9.4", "lodash": "4.17.21", + "markdown-to-jsx": "7.5.0", "mdi-material-ui": "7.9.1", "moment": "2.30.1", "moment-timezone": "0.5.45", diff --git a/opencti-platform/opencti-front/src/private/components/common/containers/ContainerAddStixCoreObjectsLine.jsx b/opencti-platform/opencti-front/src/private/components/common/containers/ContainerAddStixCoreObjectsLine.jsx index 034e5011b6ac..d55a0e6adb4f 100644 --- a/opencti-platform/opencti-front/src/private/components/common/containers/ContainerAddStixCoreObjectsLine.jsx +++ b/opencti-platform/opencti-front/src/private/components/common/containers/ContainerAddStixCoreObjectsLine.jsx @@ -276,6 +276,12 @@ export const ContainerAddStixCoreObjectsLine = createFragmentContainer( } ... on StixCyberObservable { observable_value + ... on StixFile { + hashes { + algorithm + hash + } + } } createdBy { id diff --git a/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectContent.jsx b/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectContent.jsx index 65ad924f75bb..2065ec13a93d 100644 --- a/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectContent.jsx +++ b/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectContent.jsx @@ -17,6 +17,9 @@ import 'react-pdf/dist/esm/Page/TextLayer.css'; import 'react-pdf/dist/esm/Page/AnnotationLayer.css'; import ReactMde from 'react-mde'; import { interval } from 'rxjs'; +import { compiler } from 'markdown-to-jsx'; +import { renderToString } from 'react-dom/server'; +import { Buffer } from 'buffer'; import StixCoreObjectMappableContent from './StixCoreObjectMappableContent'; import TextFieldAskAI from '../form/TextFieldAskAI'; import inject18n from '../../../../components/i18n'; @@ -413,13 +416,16 @@ class StixCoreObjectContentComponent extends Component { this.setState({ markdownSelectedTab: tab }); } - handleDownloadPdf() { + async handleDownloadPdf() { const { currentFileId, currentContent } = this.state; const { stixCoreObject } = this.props; const regex = /]+src=(\\?["'])[^'"]+\.gif\1[^>]*\/?>/gi; - const htmlData = currentContent + let htmlData = currentContent .replaceAll('id="undefined" ', '') .replaceAll(regex, ''); + if (currentFileId.endsWith('.md')) { + htmlData = renderToString(compiler(htmlData, { wrapper: null })); + } const ret = htmlToPdfmake(htmlData, { imagesByReference: true, ignoreStyles: ['font-family'], @@ -536,7 +542,7 @@ class StixCoreObjectContentComponent extends Component { && [...files, ...exportFiles].find((n) => n.id === currentFileId); const currentFileType = currentFile && currentFile.metaData.mimetype; const { innerHeight } = window; - const height = innerHeight - 270; + const height = innerHeight - 300; const isContentCompatible = isContainerWithContent(stixCoreObject.entity_type); return (