Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,24 @@ and this project adheres to

## [Unreleased]

## [2.5.0] - 2025-03-18

## Added

- πŸ“(doc) Added GNU Make link to README #750
- ✨(frontend) add pinning on doc detail #711
- 🚩(frontend) feature flag analytic on copy as html #649
- ✨(frontend) Custom block divider with export #698
- 🌐(i18n) activate dutch language #742
- ✨(frontend) add Beautify action to AI transform #478
- ✨(frontend) add Emojify action to AI transform #478

## Changed

- πŸ§‘β€πŸ’»(frontend) change literal section open source #702
- ♻️(frontend) replace cors proxy for export #695
- 🚨(gitlint) Allow uppercase in commit messages #756
- ♻️(frontend) Improve AI translations #478

## Fixed

Expand All @@ -39,13 +44,10 @@ and this project adheres to
## Added

- ✨(frontend) synchronize language-choice #401
- ✨(frontend) add Beautify action to AI transform #478
- ✨(frontend) add Emojify action to AI transform #478

## Changed

- Use sentry tags instead of extra scope
- ♻️(frontend) Improve AI translations #478

## Fixed

Expand Down Expand Up @@ -466,7 +468,9 @@ and this project adheres to
- ✨(frontend) Coming Soon page (#67)
- πŸš€ Impress, project to manage your documents easily and collaboratively.

[unreleased]: https://github.com/numerique-gouv/impress/compare/v2.3.0...main
[unreleased]: https://github.com/numerique-gouv/impress/compare/v2.5.0...main
[v2.5.0]: https://github.com/numerique-gouv/impress/releases/v2.5.0
[v2.4.0]: https://github.com/numerique-gouv/impress/releases/v2.4.0
[v2.3.0]: https://github.com/numerique-gouv/impress/releases/v2.3.0
[v2.2.0]: https://github.com/numerique-gouv/impress/releases/v2.2.0
[v2.1.0]: https://github.com/numerique-gouv/impress/releases/v2.1.0
Expand Down
2 changes: 1 addition & 1 deletion src/backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "impress"
version = "2.4.0"
version = "2.5.0"
authors = [{ "name" = "DINUM", "email" = "dev@mail.numerique.gouv.fr" }]
classifiers = [
"Development Status :: 5 - Production/Stable",
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/apps/e2e/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "app-e2e",
"version": "2.4.0",
"version": "2.5.0",
"private": true,
"scripts": {
"lint": "eslint . --ext .ts",
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/apps/impress/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "app-impress",
"version": "2.4.0",
"version": "2.5.0",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ export const blockMappingImageDocx: DocsExporterDocx['mappings']['blockMapping']
let pngConverted: string | undefined;
let dimensions: { width: number; height: number } | undefined;

if (!blob.type.includes('image')) {
return [];
}

if (blob.type.includes('svg')) {
const svgText = await blob.text();
pngConverted = await convertSvgToPng(svgText);
pngConverted = await convertSvgToPng(svgText, block.props.previewWidth);
const img = new Image();
img.src = pngConverted;
await new Promise((resolve) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ export const blockMappingImagePDF: DocsExporterPDF['mappings']['blockMapping']['
const blob = await exporter.resolveFile(block.props.url);
let pngConverted: string | undefined;

if (!blob.type.includes('image')) {
return <View wrap={false} />;
}

if (blob.type.includes('svg')) {
const svgText = await blob.text();
pngConverted = await convertSvgToPng(svgText);
pngConverted = await convertSvgToPng(svgText, block.props.previewWidth);
}

return (
Expand Down
25 changes: 23 additions & 2 deletions src/frontend/apps/impress/src/features/docs/doc-export/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,37 @@ export function downloadFile(blob: Blob, filename: string) {
* @param svgText - The SVG text to convert
* @returns The PNG data URL
*/
export async function convertSvgToPng(svgText: string) {
export async function convertSvgToPng(svgText: string, width: number) {
// Create a canvas and render the SVG onto it
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
const ctx = canvas.getContext('2d', {
alpha: true,
});

if (!ctx) {
throw new Error('Canvas context is null');
}

// Parse SVG to get original dimensions
const parser = new DOMParser();
const svgDoc = parser.parseFromString(svgText, 'image/svg+xml');
const svgElement = svgDoc.documentElement;

// Get viewBox or fallback to width/height attributes
let height;
const svgWidth = svgElement.getAttribute?.('width');
const svgHeight = svgElement.getAttribute?.('height');
const viewBox = svgElement.getAttribute('viewBox')?.split(' ').map(Number);

const originalWidth = svgWidth ? parseInt(svgWidth) : viewBox?.[2];
const originalHeight = svgHeight ? parseInt(svgHeight) : viewBox?.[3];
if (originalWidth && originalHeight) {
const aspectRatio = originalHeight / originalWidth;
height = Math.round(width * aspectRatio);
}

const svg = Canvg.fromString(ctx, svgText);
svg.resize(width, height, true);
await svg.render();

return canvas.toDataURL('image/png');
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "impress",
"version": "2.4.0",
"version": "2.5.0",
"private": true,
"workspaces": {
"packages": [
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/packages/eslint-config-impress/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-impress",
"version": "2.4.0",
"version": "2.5.0",
"license": "MIT",
"scripts": {
"lint": "eslint --ext .js ."
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/packages/i18n/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "packages-i18n",
"version": "2.4.0",
"version": "2.5.0",
"private": true,
"scripts": {
"extract-translation": "yarn extract-translation:impress",
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/servers/y-provider/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "server-y-provider",
"version": "2.4.0",
"version": "2.5.0",
"description": "Y.js provider for docs",
"repository": "https://github.com/numerique-gouv/impress",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/helm/helmfile.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
environments:
dev:
values:
- version: 2.4.0
- version: 2.5.0
---
repositories:
- name: bitnami
Expand Down
2 changes: 1 addition & 1 deletion src/helm/impress/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
type: application
name: docs
version: 2.4.0
version: 2.5.0
appVersion: latest
2 changes: 1 addition & 1 deletion src/mail/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mail_mjml",
"version": "2.4.0",
"version": "2.5.0",
"description": "An util to generate html and text django's templates from mjml templates",
"type": "module",
"dependencies": {
Expand Down
Loading