Skip to content
Open
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
92 changes: 55 additions & 37 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/visualizations-react/stories/Map/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export const dataReg: ChoroplethDataValue[] = [
];

export const shapesTiles: ChoroplethShapeVectorTilesValue = {
url: 'https://static.opendatasoft.com/vector-tiles/fr_40_region_2021/{z}/{x}/{y}.pbf',
layer: 'fr_40_region_2021',
url: 'https://static.opendatasoft.com/vector-tiles/fr_40_region_2024/{z}/{x}/{y}.pbf',
layer: 'fr_40_region_2024',
key: 'reg_code',
label: 'reg_code',
};
Expand Down
13 changes: 13 additions & 0 deletions packages/visualizations-react/stories/MarkdownText.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,16 @@ Link.args = {
},
options: {},
};

export const Image = Template.bind({});
Image.args = {
data: {
value: `
I'd like to show an image:
![My image](https://hub.huwise.com/static/ods/imgv4/huwise-black.svg "Huwise logo")

Thanks!
`,
},
options: {},
};
18 changes: 9 additions & 9 deletions packages/visualizations-react/test/MarkdownText.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,22 @@ describe('MarkdownText', () => {
});

it('renders markdown supported syntax', () => {
const { getByText, queryByText } = render(
<MarkdownText options={{}} data={{ value: '**Bold**' }} />
const { getByText, queryByText, getByRole } = render(
<MarkdownText options={{}} data={{ value: '**Bold**\n\n![alt text](image.jpg)' }} />
);

// Bold
getByText('Bold');
expect(queryByText('**Bold**')).not.toBeInTheDocument();

// Image
getByRole('img', { name: 'alt text' });
expect(queryByText('[alt text]')).not.toBeInTheDocument();
});

it("doesn't transform unsupported syntax", () => {
const value =
'Hello <strong>bold</strong>\n\n```code```\n\n`inline`\n\n' +
'![alt text](image.jpg)\n\n~~strikethrough~~';
const { getByText, getByRole } = render(<MarkdownText options={{}} data={{ value }} />);
const value = 'Hello <strong>bold</strong>\n\n```code```\n\n`inline`\n\n~~strikethrough~~';
const { getByText } = render(<MarkdownText options={{}} data={{ value }} />);

// HTML should be kept as-is (and encoded)
getByText('Hello <strong>bold</strong>');
Expand All @@ -31,9 +34,6 @@ describe('MarkdownText', () => {
getByText('```code```');
getByText('`inline`');

// Image (should be parsed as a link, not as an image tag)
getByRole('link', { name: 'alt text' });

// Strikethrough
getByText('~~strikethrough~~');
});
Expand Down
2 changes: 1 addition & 1 deletion packages/visualizations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"lodash": "^4.17.21",
"luxon": "^2.5.0",
"maplibre-gl": "^3.6.2",
"markdown-it": "^12.0.4",
"markdown-it": "14.1.0",
"markdown-it-link-attributes": "^3.0.0",
"markdown-it-mark": "^3.0.1",
"sass": "^1.70.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
})
.enable([
'hr',
'image',
'list',
'heading',
'emphasis', // bold & italic
Expand Down