@linagora/twake-mui 18.2.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 +14 -0
- package/dist/components/ContactPopover/ContactPopoverCalendarAction.d.ts +6 -2
- package/dist/components/ContactPopover/ContactPopoverCalendarAction.js +5 -9
- package/dist/components/ContactPopover/ContactPopoverChatAction.d.ts +6 -2
- package/dist/components/ContactPopover/ContactPopoverChatAction.js +5 -9
- package/dist/components/ContactPopover/ContactPopoverEmailAction.d.ts +4 -2
- package/dist/components/ContactPopover/ContactPopoverEmailAction.js +5 -2
- package/dist/components/ContactPopover/ContactPopoverIconAction.d.ts +15 -0
- package/dist/components/ContactPopover/ContactPopoverIconAction.js +19 -0
- package/dist/components/ContactPopover/ContactPopoverVideoAction.d.ts +6 -2
- package/dist/components/ContactPopover/ContactPopoverVideoAction.js +5 -9
- package/dist/components/ContactPopover/index.d.ts +2 -0
- package/dist/components/ContactPopover/index.js +7 -6
- package/dist/components/ContactPopover/locales/de.json +5 -1
- package/dist/components/ContactPopover/locales/en.json +5 -1
- package/dist/components/ContactPopover/locales/es.json +5 -1
- package/dist/components/ContactPopover/locales/fr.json +5 -1
- package/dist/components/ContactPopover/locales/it.json +5 -1
- package/dist/components/ContactPopover/locales/ru.json +5 -1
- package/dist/components/ContactPopover/locales/vi.json +5 -1
- 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,17 @@
|
|
|
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
|
+
|
|
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)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **twake-mui:** Name the close and icon action buttons of ContactPopover ([4ece4c5](https://github.com/linagora/twake-ui/commit/4ece4c5509ae5c0f0b1a09c3492d834ffba40f80))
|
|
14
|
+
|
|
1
15
|
# @linagora/twake-mui [18.2.0](https://github.com/linagora/twake-ui/compare/@linagora/twake-mui@18.1.0...@linagora/twake-mui@18.2.0) (2026-10-22)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export interface ContactPopoverCalendarActionProps {
|
|
3
3
|
/** URL for calendar action (e.g., view attendee's calendar) */
|
|
4
|
-
url
|
|
4
|
+
url?: string;
|
|
5
|
+
/** Callback when the action is clicked, used when no url is given */
|
|
6
|
+
onClick?: () => void;
|
|
5
7
|
/** Disable the action button */
|
|
6
8
|
disabled?: boolean;
|
|
9
|
+
/** Accessible name and tooltip of the action, defaults to "Plan a meeting" */
|
|
10
|
+
label?: string;
|
|
7
11
|
}
|
|
8
|
-
export declare const ContactPopoverCalendarAction: ({ url, disabled }: ContactPopoverCalendarActionProps) => React.ReactElement;
|
|
12
|
+
export declare const ContactPopoverCalendarAction: ({ url, onClick, disabled, label }: ContactPopoverCalendarActionProps) => React.ReactElement;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { Icon } from '@linagora/twake-icons';
|
|
2
1
|
import { CalendarToday } from '@linagora/twake-icons';
|
|
3
|
-
import { IconButton, useTheme } from '@mui/material';
|
|
4
2
|
import React from 'react';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} },
|
|
11
|
-
React.createElement(Icon, { icon: CalendarToday, size: 20 })));
|
|
3
|
+
import { useI18n } from 'twake-i18n';
|
|
4
|
+
import { ContactPopoverIconAction } from './ContactPopoverIconAction';
|
|
5
|
+
export const ContactPopoverCalendarAction = ({ url, onClick, disabled = false, label }) => {
|
|
6
|
+
const { t } = useI18n();
|
|
7
|
+
return (React.createElement(ContactPopoverIconAction, { icon: CalendarToday, label: label ?? t('ContactPopover.calendarButton'), url: url, onClick: onClick, disabled: disabled }));
|
|
12
8
|
};
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export interface ContactPopoverChatActionProps {
|
|
3
3
|
/** URL for chat action (e.g., Twake Chat link) */
|
|
4
|
-
url
|
|
4
|
+
url?: string;
|
|
5
|
+
/** Callback when the action is clicked, used when no url is given */
|
|
6
|
+
onClick?: () => void;
|
|
5
7
|
/** Disable the action button */
|
|
6
8
|
disabled?: boolean;
|
|
9
|
+
/** Accessible name and tooltip of the action, defaults to "Open a chat" */
|
|
10
|
+
label?: string;
|
|
7
11
|
}
|
|
8
|
-
export declare const ContactPopoverChatAction: ({ url, disabled }: ContactPopoverChatActionProps) => React.ReactElement;
|
|
12
|
+
export declare const ContactPopoverChatAction: ({ url, onClick, disabled, label }: ContactPopoverChatActionProps) => React.ReactElement;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { Icon } from '@linagora/twake-icons';
|
|
2
1
|
import { Discuss } from '@linagora/twake-icons';
|
|
3
|
-
import { IconButton, useTheme } from '@mui/material';
|
|
4
2
|
import React from 'react';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} },
|
|
11
|
-
React.createElement(Icon, { icon: Discuss, size: 20 })));
|
|
3
|
+
import { useI18n } from 'twake-i18n';
|
|
4
|
+
import { ContactPopoverIconAction } from './ContactPopoverIconAction';
|
|
5
|
+
export const ContactPopoverChatAction = ({ url, onClick, disabled = false, label }) => {
|
|
6
|
+
const { t } = useI18n();
|
|
7
|
+
return (React.createElement(ContactPopoverIconAction, { icon: Discuss, label: label ?? t('ContactPopover.chatButton'), url: url, onClick: onClick, disabled: disabled }));
|
|
12
8
|
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export interface ContactPopoverEmailActionProps {
|
|
3
3
|
/** URL for email action */
|
|
4
|
-
url
|
|
4
|
+
url?: string;
|
|
5
|
+
/** Callback when the action is clicked, used when no url is given */
|
|
6
|
+
onClick?: () => void;
|
|
5
7
|
/** Disable the action button */
|
|
6
8
|
disabled?: boolean;
|
|
7
9
|
}
|
|
8
|
-
export declare const ContactPopoverEmailAction: ({ url, disabled }: ContactPopoverEmailActionProps) => React.ReactElement;
|
|
10
|
+
export declare const ContactPopoverEmailAction: ({ url, onClick, disabled }: ContactPopoverEmailActionProps) => React.ReactElement;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { Button, useTheme } from '@mui/material';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { useI18n } from 'twake-i18n';
|
|
4
|
-
export const ContactPopoverEmailAction = ({ url, disabled = false }) => {
|
|
4
|
+
export const ContactPopoverEmailAction = ({ url, onClick, disabled = false }) => {
|
|
5
5
|
const theme = useTheme();
|
|
6
6
|
const { t } = useI18n();
|
|
7
|
-
|
|
7
|
+
const linkProps = url
|
|
8
|
+
? { href: url, target: '_blank', rel: 'noopener noreferrer' }
|
|
9
|
+
: { onClick };
|
|
10
|
+
return (React.createElement(Button, { ...linkProps, variant: "outlined", size: "small", disabled: disabled, sx: {
|
|
8
11
|
justifyContent: 'center',
|
|
9
12
|
color: theme.vars.palette.text.primary,
|
|
10
13
|
borderColor: theme.vars.palette.divider
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Icon } from '@linagora/twake-icons';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface ContactPopoverIconActionProps {
|
|
4
|
+
/** Icon shown in the button */
|
|
5
|
+
icon: React.ComponentProps<typeof Icon>['icon'];
|
|
6
|
+
/** Accessible name of the button, also shown as its tooltip */
|
|
7
|
+
label: string;
|
|
8
|
+
/** URL opened in a new tab when the button is clicked */
|
|
9
|
+
url?: string;
|
|
10
|
+
/** Callback when the button is clicked, used when no url is given */
|
|
11
|
+
onClick?: () => void;
|
|
12
|
+
/** Disable the action button */
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare const ContactPopoverIconAction: ({ icon, label, url, onClick, disabled }: ContactPopoverIconActionProps) => React.ReactElement;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Icon } from '@linagora/twake-icons';
|
|
2
|
+
import { Box, IconButton, Tooltip, useTheme } from '@mui/material';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export const ContactPopoverIconAction = ({ icon, label, url, onClick, disabled = false }) => {
|
|
5
|
+
const theme = useTheme();
|
|
6
|
+
const linkProps = url
|
|
7
|
+
? { href: url, target: '_blank', rel: 'noopener noreferrer' }
|
|
8
|
+
: { onClick };
|
|
9
|
+
return (
|
|
10
|
+
// the span lets the tooltip show on a disabled button, and takes its
|
|
11
|
+
// aria-label: the button is named too
|
|
12
|
+
React.createElement(Tooltip, { title: label },
|
|
13
|
+
React.createElement(Box, { component: "span", sx: { display: 'inline-flex' } },
|
|
14
|
+
React.createElement(IconButton, { ...linkProps, "aria-label": label, size: "small", disabled: disabled, sx: {
|
|
15
|
+
border: `1px solid ${theme.vars.palette.divider}`,
|
|
16
|
+
color: theme.vars.palette.text.icon
|
|
17
|
+
} },
|
|
18
|
+
React.createElement(Icon, { icon: icon, size: 20 })))));
|
|
19
|
+
};
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export interface ContactPopoverVideoActionProps {
|
|
3
3
|
/** URL for video call action (e.g., Twake Meet link) */
|
|
4
|
-
url
|
|
4
|
+
url?: string;
|
|
5
|
+
/** Callback when the action is clicked, used when no url is given */
|
|
6
|
+
onClick?: () => void;
|
|
5
7
|
/** Disable the action button */
|
|
6
8
|
disabled?: boolean;
|
|
9
|
+
/** Accessible name and tooltip of the action, defaults to "Start a video call" */
|
|
10
|
+
label?: string;
|
|
7
11
|
}
|
|
8
|
-
export declare const ContactPopoverVideoAction: ({ url, disabled }: ContactPopoverVideoActionProps) => React.ReactElement;
|
|
12
|
+
export declare const ContactPopoverVideoAction: ({ url, onClick, disabled, label }: ContactPopoverVideoActionProps) => React.ReactElement;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { Icon } from '@linagora/twake-icons';
|
|
2
1
|
import { Camera } from '@linagora/twake-icons';
|
|
3
|
-
import { IconButton, useTheme } from '@mui/material';
|
|
4
2
|
import React from 'react';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} },
|
|
11
|
-
React.createElement(Icon, { icon: Camera, size: 20 })));
|
|
3
|
+
import { useI18n } from 'twake-i18n';
|
|
4
|
+
import { ContactPopoverIconAction } from './ContactPopoverIconAction';
|
|
5
|
+
export const ContactPopoverVideoAction = ({ url, onClick, disabled = false, label }) => {
|
|
6
|
+
const { t } = useI18n();
|
|
7
|
+
return (React.createElement(ContactPopoverIconAction, { icon: Camera, label: label ?? t('ContactPopover.videoButton'), url: url, onClick: onClick, disabled: disabled }));
|
|
12
8
|
};
|
|
@@ -17,6 +17,8 @@ export interface ContactPopoverProps {
|
|
|
17
17
|
onClose?: () => void;
|
|
18
18
|
/** Disable the popover (render children only) */
|
|
19
19
|
disabled?: boolean;
|
|
20
|
+
/** Open the popover when the trigger is hovered, not only when clicked */
|
|
21
|
+
openOnHover?: boolean;
|
|
20
22
|
}
|
|
21
23
|
interface ContactPopoverComponent extends React.FC<ContactPopoverProps> {
|
|
22
24
|
Actions: typeof ContactPopoverActions;
|
|
@@ -2,7 +2,7 @@ import { Icon } from '@linagora/twake-icons';
|
|
|
2
2
|
import { Cross } from '@linagora/twake-icons';
|
|
3
3
|
import { Box, IconButton, Popover, styled } from '@mui/material';
|
|
4
4
|
import React, { useEffect, useRef, useState } from 'react';
|
|
5
|
-
import { useExtendI18n } from 'twake-i18n';
|
|
5
|
+
import { useExtendI18n, useI18n } from 'twake-i18n';
|
|
6
6
|
import { AttendeeInfo } from './AttendeeInfo';
|
|
7
7
|
import { ContactPopoverActions } from './ContactPopoverActions';
|
|
8
8
|
import { ContactPopoverCalendarAction } from './ContactPopoverCalendarAction';
|
|
@@ -30,8 +30,9 @@ const CloseButton = styled(IconButton)(() => ({
|
|
|
30
30
|
top: 8,
|
|
31
31
|
right: 8
|
|
32
32
|
}));
|
|
33
|
-
const ContactPopover = ({ name, email, children, onEmailCopy, onClose, disabled = false }) => {
|
|
33
|
+
const ContactPopover = ({ name, email, children, onEmailCopy, onClose, disabled = false, openOnHover = true }) => {
|
|
34
34
|
useExtendI18n(locales);
|
|
35
|
+
const { t } = useI18n();
|
|
35
36
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
36
37
|
const openTimeoutRef = useRef(null);
|
|
37
38
|
const closeTimeoutRef = useRef(null);
|
|
@@ -103,7 +104,7 @@ const ContactPopover = ({ name, email, children, onEmailCopy, onClose, disabled
|
|
|
103
104
|
return React.createElement(React.Fragment, null, triggerChildren);
|
|
104
105
|
}
|
|
105
106
|
return (React.createElement("div", null,
|
|
106
|
-
React.createElement("div", { onClick: handleClick, onMouseEnter: handleTriggerMouseEnter, onMouseLeave: handleTriggerMouseLeave, onKeyDown: event => {
|
|
107
|
+
React.createElement("div", { onClick: handleClick, onMouseEnter: openOnHover ? handleTriggerMouseEnter : undefined, onMouseLeave: openOnHover ? handleTriggerMouseLeave : undefined, onKeyDown: event => {
|
|
107
108
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
108
109
|
handleClick(event);
|
|
109
110
|
}
|
|
@@ -119,12 +120,12 @@ const ContactPopover = ({ name, email, children, onEmailCopy, onClose, disabled
|
|
|
119
120
|
borderRadius: 2,
|
|
120
121
|
maxWidth: 400
|
|
121
122
|
},
|
|
122
|
-
onMouseEnter: handlePopoverMouseEnter,
|
|
123
|
-
onMouseLeave: handleMouseLeave
|
|
123
|
+
onMouseEnter: openOnHover ? handlePopoverMouseEnter : undefined,
|
|
124
|
+
onMouseLeave: openOnHover ? handleMouseLeave : undefined
|
|
124
125
|
}
|
|
125
126
|
} },
|
|
126
127
|
React.createElement(StyledPopoverContent, { onClick: event => event.stopPropagation() },
|
|
127
|
-
React.createElement(CloseButton, { size: "small", onClick: handleClose },
|
|
128
|
+
React.createElement(CloseButton, { size: "small", onClick: handleClose, "aria-label": t('ContactPopover.closeButton') },
|
|
128
129
|
React.createElement(Icon, { icon: Cross, size: 16 })),
|
|
129
130
|
React.createElement(AttendeeInfo, { name: name, email: email, onEmailCopy: onEmailCopy }),
|
|
130
131
|
actionsChild))));
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
"ContactPopover": {
|
|
3
3
|
"emailButton": "E-Mail senden",
|
|
4
4
|
"copyTooltip": "E-Mail kopieren",
|
|
5
|
-
"copiedTooltip": "Kopiert!"
|
|
5
|
+
"copiedTooltip": "Kopiert!",
|
|
6
|
+
"closeButton": "Schließen",
|
|
7
|
+
"chatButton": "Chat öffnen",
|
|
8
|
+
"videoButton": "Videoanruf starten",
|
|
9
|
+
"calendarButton": "Besprechung planen"
|
|
6
10
|
}
|
|
7
11
|
}
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
"ContactPopover": {
|
|
3
3
|
"emailButton": "Send an email",
|
|
4
4
|
"copyTooltip": "Copy email",
|
|
5
|
-
"copiedTooltip": "Copied!"
|
|
5
|
+
"copiedTooltip": "Copied!",
|
|
6
|
+
"closeButton": "Close",
|
|
7
|
+
"chatButton": "Open a chat",
|
|
8
|
+
"videoButton": "Start a video call",
|
|
9
|
+
"calendarButton": "Plan a meeting"
|
|
6
10
|
}
|
|
7
11
|
}
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
"ContactPopover": {
|
|
3
3
|
"emailButton": "Enviar un correo",
|
|
4
4
|
"copyTooltip": "Copiar correo",
|
|
5
|
-
"copiedTooltip": "¡Copiado!"
|
|
5
|
+
"copiedTooltip": "¡Copiado!",
|
|
6
|
+
"closeButton": "Cerrar",
|
|
7
|
+
"chatButton": "Abrir un chat",
|
|
8
|
+
"videoButton": "Iniciar una videollamada",
|
|
9
|
+
"calendarButton": "Planificar una reunión"
|
|
6
10
|
}
|
|
7
11
|
}
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
"ContactPopover": {
|
|
3
3
|
"emailButton": "Envoyer un email",
|
|
4
4
|
"copyTooltip": "Copier l'email",
|
|
5
|
-
"copiedTooltip": "Copié !"
|
|
5
|
+
"copiedTooltip": "Copié !",
|
|
6
|
+
"closeButton": "Fermer",
|
|
7
|
+
"chatButton": "Ouvrir une discussion",
|
|
8
|
+
"videoButton": "Lancer un appel vidéo",
|
|
9
|
+
"calendarButton": "Planifier une réunion"
|
|
6
10
|
}
|
|
7
11
|
}
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
"ContactPopover": {
|
|
3
3
|
"emailButton": "Invia un'email",
|
|
4
4
|
"copyTooltip": "Copia email",
|
|
5
|
-
"copiedTooltip": "Copiato!"
|
|
5
|
+
"copiedTooltip": "Copiato!",
|
|
6
|
+
"closeButton": "Chiudi",
|
|
7
|
+
"chatButton": "Apri una chat",
|
|
8
|
+
"videoButton": "Avvia una videochiamata",
|
|
9
|
+
"calendarButton": "Pianifica una riunione"
|
|
6
10
|
}
|
|
7
11
|
}
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
"ContactPopover": {
|
|
3
3
|
"emailButton": "Отправить email",
|
|
4
4
|
"copyTooltip": "Копировать email",
|
|
5
|
-
"copiedTooltip": "Скопировано!"
|
|
5
|
+
"copiedTooltip": "Скопировано!",
|
|
6
|
+
"closeButton": "Закрыть",
|
|
7
|
+
"chatButton": "Открыть чат",
|
|
8
|
+
"videoButton": "Начать видеозвонок",
|
|
9
|
+
"calendarButton": "Запланировать встречу"
|
|
6
10
|
}
|
|
7
11
|
}
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
"ContactPopover": {
|
|
3
3
|
"emailButton": "Gửi email",
|
|
4
4
|
"copyTooltip": "Sao chép email",
|
|
5
|
-
"copiedTooltip": "Đã sao chép!"
|
|
5
|
+
"copiedTooltip": "Đã sao chép!",
|
|
6
|
+
"closeButton": "Đóng",
|
|
7
|
+
"chatButton": "Mở trò chuyện",
|
|
8
|
+
"videoButton": "Bắt đầu cuộc gọi video",
|
|
9
|
+
"calendarButton": "Lên lịch cuộc họp"
|
|
6
10
|
}
|
|
7
11
|
}
|
|
@@ -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
|