cozy-ui 111.8.1 → 111.9.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 CHANGED
@@ -1,3 +1,10 @@
1
+ # [111.9.0](https://github.com/cozy/cozy-ui/compare/v111.8.1...v111.9.0) (2024-09-05)
2
+
3
+
4
+ ### Features
5
+
6
+ * Add markdwon component ([366def6](https://github.com/cozy/cozy-ui/commit/366def6))
7
+
1
8
  ## [111.8.1](https://github.com/cozy/cozy-ui/compare/v111.8.0...v111.8.1) (2024-08-28)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "111.8.1",
3
+ "version": "111.9.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -0,0 +1,71 @@
1
+ This component is used to render markdown content. To see more about the Markdown, you can check the [Markdown Guide](https://www.markdownguide.org/).
2
+
3
+ ```jsx
4
+
5
+ import Markdown from 'cozy-ui/transpiled/react/Markdown'
6
+
7
+ const textInMarkdown = `
8
+ # Demo
9
+
10
+ This is a text to test all possibilities of markdown.
11
+
12
+ ## Headers
13
+
14
+ # H1 Header
15
+ ## H2 Header
16
+ ### H3 Header
17
+ #### H4 Header
18
+ ##### H5 Header
19
+ ###### H6 Header
20
+
21
+ ## Paragraphs
22
+
23
+ I really like using Markdown.
24
+
25
+ I think I'll use it to format all of my documents from now on.
26
+
27
+ ## Emphasis
28
+
29
+ _Italic Text_
30
+
31
+ ***Bold Text***
32
+
33
+ __Bold and Italic Text__
34
+
35
+ ~~Strikethrough~~
36
+
37
+ <u>Underline</u>
38
+
39
+ ## Lists
40
+
41
+ 1. Ordered List Item 1
42
+ 2. Ordered List Item 2
43
+ 3. Ordered List Item 3
44
+
45
+ - Unordered List Item 1
46
+ - Unordered List Item 2
47
+ - Unordered List Item 3
48
+
49
+ ## Links
50
+
51
+ [Link to GitHub](https://github.com/cozy/cozy-ui)
52
+
53
+ ## Images
54
+
55
+ ![The San Juan Mountains are beautiful!](/assets/images/san-juan-mountains.jpg "San Juan Mountains")
56
+
57
+ ## Code
58
+
59
+ Inline code: \`const variable = 'value';\`
60
+
61
+ Block code:
62
+ \`\`\`javascript function add(a, b) { return a + b; }\`\`\`
63
+
64
+ ## Blockquotes
65
+
66
+ > This is a blockquote.
67
+ `;
68
+
69
+ <Markdown content={textInMarkdown} />
70
+
71
+ ```
@@ -0,0 +1,32 @@
1
+ import React from 'react'
2
+ import ReactMarkdown from 'react-markdown'
3
+
4
+ import Link from '../Link'
5
+ import Typography from '../Typography'
6
+
7
+ const Markdown = ({ content }) => {
8
+ return (
9
+ <ReactMarkdown
10
+ source={content}
11
+ renderers={{
12
+ link: ({ children, href }) => (
13
+ <Link href={href} rel="noreferrer" target="_blank">
14
+ {children}
15
+ </Link>
16
+ ),
17
+ heading: ({ children, level }) => (
18
+ <Typography variant={`h${level}`} className="u-mb-1">
19
+ {children}
20
+ </Typography>
21
+ ),
22
+ paragraph: ({ children }) => (
23
+ <Typography variant="body1" className="u-mb-1">
24
+ {children}
25
+ </Typography>
26
+ )
27
+ }}
28
+ />
29
+ )
30
+ }
31
+
32
+ export default Markdown
@@ -1,6 +1,5 @@
1
1
  import PropTypes from 'prop-types'
2
2
  import React, { useEffect, useState } from 'react'
3
- import ReactMarkdown from 'react-markdown'
4
3
 
5
4
  import { useInstanceInfo } from 'cozy-client'
6
5
  import { buildPremiumLink } from 'cozy-client/dist/models/instance'
@@ -14,6 +13,7 @@ import Button from '../Buttons'
14
13
  import { IllustrationDialog } from '../CozyDialogs'
15
14
  import Icon from '../Icon'
16
15
  import CozyUpgradeIcon from '../Icons/CozyUpgrade'
16
+ import Markdown from '../Markdown'
17
17
  import Spinner from '../Spinner'
18
18
  import Typography from '../Typography'
19
19
  import { useI18n } from '../providers/I18n'
@@ -94,13 +94,10 @@ const Paywall = ({ variant, onClose, isPublic, contentInterpolation }) => {
94
94
  />
95
95
  }
96
96
  content={
97
- <ReactMarkdown
98
- source={t(`${variant}Paywall.${type}.content`, {
97
+ <Markdown
98
+ content={t(`${variant}Paywall.${type}.content`, {
99
99
  ...contentInterpolation
100
100
  })}
101
- renderers={{
102
- paragraph: ({ children }) => <p className="u-mt-0">{children}</p>
103
- }}
104
101
  />
105
102
  }
106
103
  onClose={onClose}
@@ -94,15 +94,15 @@ const makeClient = premiumLink =>
94
94
  }
95
95
  ]
96
96
  },
97
- 'io.cozy.settings/context': {
97
+ 'io.cozy.settings/io.cozy.settings.context': {
98
98
  doctype: 'io.cozy.settings',
99
99
  definition: {
100
100
  doctype: 'io.cozy.settings',
101
- id: 'io.cozy.settings/context'
101
+ id: 'io.cozy.settings/io.cozy.settings.context'
102
102
  },
103
103
  data: [
104
104
  {
105
- id: 'io.cozy.settings/context',
105
+ id: 'io.cozy.settings/io.cozy.settings.context',
106
106
  attributes: {
107
107
  enable_premium_links: premiumLink,
108
108
  manager_url: 'http://mycozy.cloud',
package/react/index.js CHANGED
@@ -137,3 +137,4 @@ export { default as AlertProvider, useAlert } from './Alert'
137
137
  export { default as Modal } from './Modal'
138
138
  export { ListSkeleton, ListItemSkeleton } from './Skeletons'
139
139
  export { default as ActionsBar } from './ActionsBar'
140
+ export { default as Markdown } from './Markdown'
@@ -0,0 +1,39 @@
1
+ import React from 'react';
2
+ import ReactMarkdown from 'react-markdown';
3
+ import Link from "cozy-ui/transpiled/react/Link";
4
+ import Typography from "cozy-ui/transpiled/react/Typography";
5
+
6
+ var Markdown = function Markdown(_ref) {
7
+ var content = _ref.content;
8
+ return /*#__PURE__*/React.createElement(ReactMarkdown, {
9
+ source: content,
10
+ renderers: {
11
+ link: function link(_ref2) {
12
+ var children = _ref2.children,
13
+ href = _ref2.href;
14
+ return /*#__PURE__*/React.createElement(Link, {
15
+ href: href,
16
+ rel: "noreferrer",
17
+ target: "_blank"
18
+ }, children);
19
+ },
20
+ heading: function heading(_ref3) {
21
+ var children = _ref3.children,
22
+ level = _ref3.level;
23
+ return /*#__PURE__*/React.createElement(Typography, {
24
+ variant: "h".concat(level),
25
+ className: "u-mb-1"
26
+ }, children);
27
+ },
28
+ paragraph: function paragraph(_ref4) {
29
+ var children = _ref4.children;
30
+ return /*#__PURE__*/React.createElement(Typography, {
31
+ variant: "body1",
32
+ className: "u-mb-1"
33
+ }, children);
34
+ }
35
+ }
36
+ });
37
+ };
38
+
39
+ export default Markdown;
@@ -9,7 +9,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
9
9
  import _regeneratorRuntime from "@babel/runtime/regenerator";
10
10
  import PropTypes from 'prop-types';
11
11
  import React, { useEffect, useState } from 'react';
12
- import ReactMarkdown from 'react-markdown';
13
12
  import { useInstanceInfo } from 'cozy-client';
14
13
  import { buildPremiumLink } from 'cozy-client/dist/models/instance';
15
14
  import { isFlagshipApp } from 'cozy-device-helper';
@@ -21,6 +20,7 @@ import Button from "cozy-ui/transpiled/react/Buttons";
21
20
  import { IllustrationDialog } from "cozy-ui/transpiled/react/CozyDialogs";
22
21
  import Icon from "cozy-ui/transpiled/react/Icon";
23
22
  import CozyUpgradeIcon from "cozy-ui/transpiled/react/Icons/CozyUpgrade";
23
+ import Markdown from "cozy-ui/transpiled/react/Markdown";
24
24
  import Spinner from "cozy-ui/transpiled/react/Spinner";
25
25
  import Typography from "cozy-ui/transpiled/react/Typography";
26
26
  import { useI18n } from "cozy-ui/transpiled/react/providers/I18n";
@@ -140,16 +140,8 @@ var Paywall = function Paywall(_ref) {
140
140
  label: isFlagshipAppIapAvailable === null ? t("action.loading") : canOpenPremiumLink ? t("".concat(variant, "Paywall.").concat(type, ".action")) : t("action.withoutIAP"),
141
141
  busy: isFlagshipAppIapAvailable === null
142
142
  }),
143
- content: /*#__PURE__*/React.createElement(ReactMarkdown, {
144
- source: t("".concat(variant, "Paywall.").concat(type, ".content"), _objectSpread({}, contentInterpolation)),
145
- renderers: {
146
- paragraph: function paragraph(_ref3) {
147
- var children = _ref3.children;
148
- return /*#__PURE__*/React.createElement("p", {
149
- className: "u-mt-0"
150
- }, children);
151
- }
152
- }
143
+ content: /*#__PURE__*/React.createElement(Markdown, {
144
+ content: t("".concat(variant, "Paywall.").concat(type, ".content"), _objectSpread({}, contentInterpolation))
153
145
  }),
154
146
  onClose: onClose
155
147
  });
@@ -109,4 +109,5 @@ export { default as TimelineSeparator } from './TimelineSeparator';
109
109
  export { default as AlertProvider, useAlert } from './Alert';
110
110
  export { default as Modal } from './Modal';
111
111
  export { ListSkeleton, ListItemSkeleton } from './Skeletons';
112
- export { default as ActionsBar } from './ActionsBar';
112
+ export { default as ActionsBar } from './ActionsBar';
113
+ export { default as Markdown } from './Markdown';