@linagora/twake-mui 18.3.0 → 18.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/components/Markdown/Markdown.stories.d.ts +1 -0
- package/dist/components/Markdown/Markdown.stories.js +9 -0
- package/dist/components/Markdown/helpers.d.ts +7 -0
- package/dist/components/Markdown/helpers.js +33 -0
- package/dist/components/Markdown/index.js +1 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/package.json +5 -3
- /package/dist/components/{Apptitle/Apptitle.stories.d.ts → AppTitle/AppTitle.stories.d.ts} +0 -0
- /package/dist/components/{Apptitle/Apptitle.stories.js → AppTitle/AppTitle.stories.js} +0 -0
- /package/dist/components/{Apptitle → AppTitle}/index.d.ts +0 -0
- /package/dist/components/{Apptitle → AppTitle}/index.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# @linagora/twake-mui [18.4.0](https://github.com/linagora/twake-ui/compare/@linagora/twake-mui@18.3.0...@linagora/twake-mui@18.4.0) (2026-10-22)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **twake-mui:** Add getPlainTextFromMarkdown helper ([a47e189](https://github.com/linagora/twake-ui/commit/a47e1897ecdd14e8d2e8b7c6663815272c00aad4)), closes [cozy/cozy-ui#2965](https://github.com/cozy/cozy-ui/issues/2965)
|
|
7
|
+
|
|
1
8
|
# @linagora/twake-mui [18.3.0](https://github.com/linagora/twake-ui/compare/@linagora/twake-mui@18.2.0...@linagora/twake-mui@18.3.0) (2026-10-22)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Typography } from '@mui/material';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { getPlainTextFromMarkdown } from './helpers';
|
|
1
4
|
import Markdown from './index';
|
|
2
5
|
const content = `
|
|
3
6
|
# Demo
|
|
@@ -76,3 +79,9 @@ export const Screenshot = {
|
|
|
76
79
|
tags: ['argos'],
|
|
77
80
|
args: { content }
|
|
78
81
|
};
|
|
82
|
+
export const PlainText = {
|
|
83
|
+
args: {
|
|
84
|
+
content: '# Demo\n\nSome **bold** text, a [link](https://twake.app) and a list:\n\n- first\n- second'
|
|
85
|
+
},
|
|
86
|
+
render: ({ content }) => (React.createElement(Typography, { noWrap: true }, getPlainTextFromMarkdown(content)))
|
|
87
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import remarkGfm from 'remark-gfm';
|
|
2
|
+
export declare const remarkPlugins: (typeof remarkGfm)[];
|
|
3
|
+
/**
|
|
4
|
+
* Gives the words of a Markdown content on one line, without its syntax,
|
|
5
|
+
* as the Markdown component shows them: for a preview
|
|
6
|
+
*/
|
|
7
|
+
export declare const getPlainTextFromMarkdown: (content: string) => string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import remarkGfm from 'remark-gfm';
|
|
2
|
+
import remarkParse from 'remark-parse';
|
|
3
|
+
import { unified } from 'unified';
|
|
4
|
+
export const remarkPlugins = [remarkGfm];
|
|
5
|
+
const markdown = unified().use(remarkParse).use(remarkPlugins);
|
|
6
|
+
// Nodes whose children are blocks or cells: a space keeps their words apart
|
|
7
|
+
const BLOCKS = [
|
|
8
|
+
'root',
|
|
9
|
+
'blockquote',
|
|
10
|
+
'footnoteDefinition',
|
|
11
|
+
'list',
|
|
12
|
+
'listItem',
|
|
13
|
+
'table',
|
|
14
|
+
'tableRow'
|
|
15
|
+
];
|
|
16
|
+
const getWords = (node) => {
|
|
17
|
+
if (node.type === 'image' || node.type === 'imageReference')
|
|
18
|
+
return node.alt ?? '';
|
|
19
|
+
if (node.type === 'break')
|
|
20
|
+
return ' ';
|
|
21
|
+
if (typeof node.value === 'string')
|
|
22
|
+
return node.value;
|
|
23
|
+
return (node.children ?? [])
|
|
24
|
+
.map(getWords)
|
|
25
|
+
.join(BLOCKS.includes(node.type) ? ' ' : '');
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Gives the words of a Markdown content on one line, without its syntax,
|
|
29
|
+
* as the Markdown component shows them: for a preview
|
|
30
|
+
*/
|
|
31
|
+
export const getPlainTextFromMarkdown = (content) => getWords(markdown.runSync(markdown.parse(content)))
|
|
32
|
+
.replace(/\s+/g, ' ')
|
|
33
|
+
.trim();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Link, Typography } from '@mui/material';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import ReactMarkdown from 'react-markdown';
|
|
4
|
-
import
|
|
4
|
+
import { remarkPlugins } from './helpers';
|
|
5
5
|
const makeHeading = (variant) => {
|
|
6
6
|
const Heading = ({ children }) => (React.createElement(Typography, { variant: variant, sx: { mb: 2 } }, children));
|
|
7
7
|
return Heading;
|
|
@@ -16,6 +16,5 @@ const components = {
|
|
|
16
16
|
h5: makeHeading('h5'),
|
|
17
17
|
h6: makeHeading('h6')
|
|
18
18
|
};
|
|
19
|
-
const remarkPlugins = [remarkGfm];
|
|
20
19
|
const Markdown = ({ content }) => (React.createElement(ReactMarkdown, { remarkPlugins: remarkPlugins, components: components }, content));
|
|
21
20
|
export default Markdown;
|
package/dist/index.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export { copyToClipboard } from './components/ActionsMenu/Actions/copyToClipboar
|
|
|
31
31
|
export { editAttribute } from './components/ActionsMenu/Actions/editAttribute';
|
|
32
32
|
export { others } from './components/ActionsMenu/Actions/others';
|
|
33
33
|
export { exportToText } from './components/ActionsMenu/Actions/exportToText';
|
|
34
|
-
export { default as AppTitle } from './components/
|
|
34
|
+
export { default as AppTitle } from './components/AppTitle';
|
|
35
35
|
export { default as Avatar } from './components/Avatar';
|
|
36
36
|
export { default as BarTitle } from './components/BarTitle';
|
|
37
37
|
export { default as Button } from './components/Button';
|
|
@@ -70,6 +70,7 @@ export { default as ListSkeleton } from './components/ListSkeleton';
|
|
|
70
70
|
export { default as ListSubheader } from './components/ListSubheader';
|
|
71
71
|
export { default as LoadMore } from './components/LoadMore';
|
|
72
72
|
export { default as Markdown } from './components/Markdown';
|
|
73
|
+
export { getPlainTextFromMarkdown } from './components/Markdown/helpers';
|
|
73
74
|
export { default as MidEllipsis } from './components/MidEllipsis';
|
|
74
75
|
export { default as NavigationList } from './components/NavigationList';
|
|
75
76
|
export { default as NavigationListHeader } from './components/NavigationList/NavigationListHeader';
|
|
@@ -128,7 +129,7 @@ export type { FavoritesActionOptions } from './components/ActionsMenu/Actions/fa
|
|
|
128
129
|
export type { DownloadActionOptions, DownloadFileOptions } from './components/ActionsMenu/Actions/download';
|
|
129
130
|
export type { PrintActionOptions, PrintClient } from './components/ActionsMenu/Actions/print';
|
|
130
131
|
export type { ExportToTextActionOptions } from './components/ActionsMenu/Actions/exportToText';
|
|
131
|
-
export type { AppTitleProps } from './components/
|
|
132
|
+
export type { AppTitleProps } from './components/AppTitle';
|
|
132
133
|
export type { AvatarProps } from './components/Avatar';
|
|
133
134
|
export type { BarTitleProps } from './components/BarTitle';
|
|
134
135
|
export type { ButtonProps } from './components/Button';
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,7 @@ export { copyToClipboard } from './components/ActionsMenu/Actions/copyToClipboar
|
|
|
34
34
|
export { editAttribute } from './components/ActionsMenu/Actions/editAttribute';
|
|
35
35
|
export { others } from './components/ActionsMenu/Actions/others';
|
|
36
36
|
export { exportToText } from './components/ActionsMenu/Actions/exportToText';
|
|
37
|
-
export { default as AppTitle } from './components/
|
|
37
|
+
export { default as AppTitle } from './components/AppTitle';
|
|
38
38
|
export { default as Avatar } from './components/Avatar';
|
|
39
39
|
export { default as BarTitle } from './components/BarTitle';
|
|
40
40
|
export { default as Button } from './components/Button';
|
|
@@ -73,6 +73,7 @@ export { default as ListSkeleton } from './components/ListSkeleton';
|
|
|
73
73
|
export { default as ListSubheader } from './components/ListSubheader';
|
|
74
74
|
export { default as LoadMore } from './components/LoadMore';
|
|
75
75
|
export { default as Markdown } from './components/Markdown';
|
|
76
|
+
export { getPlainTextFromMarkdown } from './components/Markdown/helpers';
|
|
76
77
|
export { default as MidEllipsis } from './components/MidEllipsis';
|
|
77
78
|
export { default as NavigationList } from './components/NavigationList';
|
|
78
79
|
export { default as NavigationListHeader } from './components/NavigationList/NavigationListHeader';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linagora/twake-mui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "18.
|
|
4
|
+
"version": "18.4.0",
|
|
5
5
|
"description": "MUI v9 theme system for Twake applications",
|
|
6
6
|
"author": "Twake",
|
|
7
7
|
"license": "MIT",
|
|
@@ -69,8 +69,10 @@
|
|
|
69
69
|
"react-markdown": "^10.1.0",
|
|
70
70
|
"react-use-measure": "2.1.7",
|
|
71
71
|
"react-virtuoso": "4.13.0",
|
|
72
|
-
"remark-gfm": "
|
|
73
|
-
"
|
|
72
|
+
"remark-gfm": "4.0.1",
|
|
73
|
+
"remark-parse": "11.0.0",
|
|
74
|
+
"rooks": "8.4.0",
|
|
75
|
+
"unified": "11.0.5"
|
|
74
76
|
},
|
|
75
77
|
"devDependencies": {
|
|
76
78
|
"@argos-ci/cli": "6.9.5",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|