@toptal/picasso-rich-text-editor 17.0.21-alpha-allow-to-pass-class-names-in-modal-package-7c2827b69.2 → 17.1.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/dist-package/src/RichText/RichText.d.ts.map +1 -1
- package/dist-package/src/RichText/RichText.js +2 -3
- package/dist-package/src/RichText/RichText.js.map +1 -1
- package/dist-package/src/RichText/hooks/useRichText/useRichText.d.ts.map +1 -1
- package/dist-package/src/RichText/hooks/useRichText/useRichText.js +28 -13
- package/dist-package/src/RichText/hooks/useRichText/useRichText.js.map +1 -1
- package/package.json +22 -23
- package/src/RichText/RichText.tsx +4 -8
- package/src/RichText/hooks/useRichText/useRichText.tsx +39 -23
- package/LICENSE +0 -20
- package/dist-package/src/RichText/hooks/useRichText/styles.d.ts +0 -4
- package/dist-package/src/RichText/hooks/useRichText/styles.d.ts.map +0 -1
- package/dist-package/src/RichText/hooks/useRichText/styles.js +0 -9
- package/dist-package/src/RichText/hooks/useRichText/styles.js.map +0 -1
- package/src/RichText/hooks/useRichText/styles.ts +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichText.d.ts","sourceRoot":"","sources":["../../../src/RichText/RichText.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"RichText.d.ts","sourceRoot":"","sources":["../../../src/RichText/RichText.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAGvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAGtC,MAAM,WAAW,KAAM,SAAQ,SAAS;IACtC;;OAEG;IACH,KAAK,EAAE,OAAO,CAAA;CACf;AAED,eAAO,MAAM,QAAQ,4DAKlB,KAAK,gBAYP,CAAA;AAED,eAAe,QAAQ,CAAA"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { twJoin } from '@toptal/picasso-tailwind-merge';
|
|
2
|
+
import { twMerge } from '@toptal/picasso-tailwind-merge';
|
|
4
3
|
import useRichText from './hooks/useRichText';
|
|
5
4
|
export const RichText = ({ value, style, className, 'data-testid': dataTestId, }) => {
|
|
6
5
|
const richText = useRichText(value);
|
|
7
|
-
return (React.createElement(
|
|
6
|
+
return (React.createElement("div", { style: style, "data-testid": dataTestId, className: twMerge('gap-2 flex flex-col break-words', className) }, richText));
|
|
8
7
|
};
|
|
9
8
|
export default RichText;
|
|
10
9
|
//# sourceMappingURL=RichText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichText.js","sourceRoot":"","sources":["../../../src/RichText/RichText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"RichText.js","sourceRoot":"","sources":["../../../src/RichText/RichText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AAGxD,OAAO,WAAW,MAAM,qBAAqB,CAAA;AAS7C,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EACvB,KAAK,EACL,KAAK,EACL,SAAS,EACT,aAAa,EAAE,UAAU,GACnB,EAAE,EAAE;IACV,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,CAAC,CAAA;IAEnC,OAAO,CACL,6BACE,KAAK,EAAE,KAAK,iBACC,UAAU,EACvB,SAAS,EAAE,OAAO,CAAC,iCAAiC,EAAE,SAAS,CAAC,IAE/D,QAAQ,CACL,CACP,CAAA;AACH,CAAC,CAAA;AAED,eAAe,QAAQ,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRichText.d.ts","sourceRoot":"","sources":["../../../../../src/RichText/hooks/useRichText/useRichText.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAgB,SAAS,EAAM,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"useRichText.d.ts","sourceRoot":"","sources":["../../../../../src/RichText/hooks/useRichText/useRichText.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAgB,SAAS,EAAM,MAAM,OAAO,CAAA;AAQxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAkG1C,QAAA,MAAM,WAAW,UAAW,OAAO,KAAG,SAAS,EAAE,GAAG,SAwBnD,CAAA;AAED,eAAe,WAAW,CAAA"}
|
|
@@ -15,28 +15,43 @@ import { Container } from '@toptal/picasso-container';
|
|
|
15
15
|
import { Typography } from '@toptal/picasso-typography';
|
|
16
16
|
import { List, ListItem } from '@toptal/picasso-list';
|
|
17
17
|
import { Link } from '@toptal/picasso-link';
|
|
18
|
-
import {
|
|
18
|
+
import { twMerge } from '@toptal/picasso-tailwind-merge';
|
|
19
19
|
import { Emoji, Image, Code, CodeBlock } from '../../components';
|
|
20
20
|
import { isCustomEmoji } from '../../../utils';
|
|
21
|
-
import styles from './styles';
|
|
22
|
-
const useStyles = makeStyles(styles, { name: 'PicassoRichText' });
|
|
23
21
|
// List internaly passes another props to ListItem
|
|
24
22
|
const Li = (_a) => {
|
|
25
23
|
var { children } = _a, props = __rest(_a, ["children"]);
|
|
26
24
|
return (React.createElement(ListItem, Object.assign({}, props), children));
|
|
27
25
|
};
|
|
28
26
|
/* eslint-disable id-length */
|
|
29
|
-
const P = (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
const P = (_a) => {
|
|
28
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
29
|
+
return (React.createElement(Typography, Object.assign({ size: 'medium' }, props), children));
|
|
30
|
+
};
|
|
31
|
+
const Strong = (_a) => {
|
|
32
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
33
|
+
return (React.createElement(Typography, Object.assign({ size: 'inherit', as: 'strong', weight: 'semibold', color: 'inherit' }, props), children));
|
|
34
|
+
};
|
|
35
|
+
const Em = (_a) => {
|
|
36
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
37
|
+
return (React.createElement(Typography, Object.assign({ size: 'inherit', as: 'em', color: 'inherit' }, props), children));
|
|
38
|
+
};
|
|
39
|
+
const H3 = (_a) => {
|
|
37
40
|
var { children } = _a, props = __rest(_a, ["children"]);
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
return (React.createElement(Container, Object.assign({ top: 'xsmall' }, props),
|
|
42
|
+
React.createElement(Typography, { as: 'h3', variant: 'heading', size: 'medium' }, children)));
|
|
43
|
+
};
|
|
44
|
+
const Ul = (_a) => {
|
|
45
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
46
|
+
return (React.createElement(List, Object.assign({ variant: 'unordered' }, props), children));
|
|
47
|
+
};
|
|
48
|
+
const Ol = (_a) => {
|
|
49
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
50
|
+
return (React.createElement(List, Object.assign({ variant: 'ordered' }, props), children));
|
|
51
|
+
};
|
|
52
|
+
const A = (_a) => {
|
|
53
|
+
var { children, className } = _a, props = __rest(_a, ["children", "className"]);
|
|
54
|
+
return (React.createElement(Link, Object.assign({}, props, { className: twMerge('[&:visited>strong]:text-purple-500 [&:visited>em]:text-purple-500', className) }), children));
|
|
40
55
|
};
|
|
41
56
|
const Img = (_a) => {
|
|
42
57
|
var props = __rest(_a, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRichText.js","sourceRoot":"","sources":["../../../../../src/RichText/hooks/useRichText/useRichText.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,GAAG,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"useRichText.js","sourceRoot":"","sources":["../../../../../src/RichText/hooks/useRich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E,QAAQ,EAAE,WAAW,EAAE,GAAG,KAAK,CAAA;QAEvC,IAAI,CAAC,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM,CAAA,EAAE;YACxB,OAAO,IAAI,CAAA;SACZ;QAED,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,KAAK,CAAC,CAAA;QAC9C,MAAM,YAAY,GAAG,GAAG,CAAC,aAAa,EAAE,KAAK,CAAiB,CAAA;QAE9D,IAAI,aAAa,EAAE;YACjB,OAAO,aAAa,CAAC,YAAY,CAAC,CAAA;SACnC;QAED,uCAAuC;QACvC,gEAAgE;QAChE,oFAAoF;QACpF,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAA;QAE7C,OAAO,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;IACrC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IAEX,OAAO,eAAe,CAAA;AACxB,CAAC,CAAA;AAED,eAAe,WAAW,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toptal/picasso-rich-text-editor",
|
|
3
|
-
"version": "17.0
|
|
3
|
+
"version": "17.1.0",
|
|
4
4
|
"description": "Picasso rich text editor",
|
|
5
5
|
"author": "Toptal",
|
|
6
6
|
"homepage": "https://github.com/toptal/picasso/tree/master/packages/picasso-rich-text-editor#readme",
|
|
@@ -30,32 +30,32 @@
|
|
|
30
30
|
"@lexical/utils": "0.11.2",
|
|
31
31
|
"@material-ui/core": "4.12.4",
|
|
32
32
|
"@toptal/picasso-shared": "^15.0.0",
|
|
33
|
-
"@toptal/picasso-tailwind": ">=2.7",
|
|
34
|
-
"@toptal/picasso-tailwind-merge": "^2.0.0",
|
|
35
33
|
"react": ">=16.12.0 < 19.0.0",
|
|
36
34
|
"react-dom": ">=16.12.0 < 19.0.0",
|
|
37
|
-
"typescript": "~4.7.0"
|
|
35
|
+
"typescript": "~4.7.0",
|
|
36
|
+
"@toptal/picasso-tailwind-merge": "^2.0.0",
|
|
37
|
+
"@toptal/picasso-tailwind": ">=2.7"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@emoji-mart/data": "^1.2.1",
|
|
41
41
|
"@emoji-mart/react": "^1.1.1",
|
|
42
42
|
"@lexical/html": "0.11.2",
|
|
43
43
|
"@lexical/react": "0.11.2",
|
|
44
|
-
"@toptal/picasso-
|
|
45
|
-
"@toptal/picasso-
|
|
46
|
-
"@toptal/picasso-
|
|
47
|
-
"@toptal/picasso-
|
|
48
|
-
"@toptal/picasso-
|
|
49
|
-
"@toptal/picasso-
|
|
50
|
-
"@toptal/picasso-
|
|
51
|
-
"@toptal/picasso-
|
|
52
|
-
"@toptal/picasso-
|
|
53
|
-
"@toptal/picasso-
|
|
54
|
-
"@toptal/picasso-
|
|
55
|
-
"@toptal/picasso-
|
|
56
|
-
"@toptal/picasso-
|
|
57
|
-
"@toptal/picasso-
|
|
58
|
-
"@toptal/picasso-utils": "3.1.
|
|
44
|
+
"@toptal/picasso-container": "3.1.2",
|
|
45
|
+
"@toptal/picasso-button": "4.0.21",
|
|
46
|
+
"@toptal/picasso-icons": "1.12.1",
|
|
47
|
+
"@toptal/picasso-file-input": "4.0.19",
|
|
48
|
+
"@toptal/picasso-image": "3.0.3",
|
|
49
|
+
"@toptal/picasso-outlined-input": "4.0.20",
|
|
50
|
+
"@toptal/picasso-list": "5.0.10",
|
|
51
|
+
"@toptal/picasso-link": "3.0.5",
|
|
52
|
+
"@toptal/picasso-select": "4.0.20",
|
|
53
|
+
"@toptal/picasso-input-adornment": "3.0.10",
|
|
54
|
+
"@toptal/picasso-typography": "4.0.3",
|
|
55
|
+
"@toptal/picasso-modal": "3.2.0",
|
|
56
|
+
"@toptal/picasso-form": "6.2.1",
|
|
57
|
+
"@toptal/picasso-input": "4.0.20",
|
|
58
|
+
"@toptal/picasso-utils": "3.1.0",
|
|
59
59
|
"classnames": "^2.5.1",
|
|
60
60
|
"emoji-mart": "^5.5.2",
|
|
61
61
|
"hast-to-hyperscript": "^9.0.1",
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@material-ui/core": "4.12.4",
|
|
70
70
|
"@testing-library/react-hooks": "^8.0.1",
|
|
71
|
-
"@toptal/picasso-
|
|
72
|
-
"@toptal/picasso-
|
|
71
|
+
"@toptal/picasso-test-utils": "1.1.1",
|
|
72
|
+
"@toptal/picasso-tailwind-merge": "2.0.3",
|
|
73
73
|
"@types/classnames": "^2.3.1"
|
|
74
74
|
},
|
|
75
75
|
"sideEffects": false,
|
|
@@ -84,6 +84,5 @@
|
|
|
84
84
|
"src",
|
|
85
85
|
"eager.js",
|
|
86
86
|
"eager.d.ts"
|
|
87
|
-
]
|
|
88
|
-
"gitHead": "7c2827b6982cdc7bf2c0927d859a4bdcf905beee"
|
|
87
|
+
]
|
|
89
88
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import type { BaseProps } from '@toptal/picasso-shared'
|
|
3
|
-
import {
|
|
4
|
-
import { twJoin } from '@toptal/picasso-tailwind-merge'
|
|
3
|
+
import { twMerge } from '@toptal/picasso-tailwind-merge'
|
|
5
4
|
|
|
6
5
|
import type { ASTType } from './types'
|
|
7
6
|
import useRichText from './hooks/useRichText'
|
|
@@ -22,16 +21,13 @@ export const RichText = ({
|
|
|
22
21
|
const richText = useRichText(value)
|
|
23
22
|
|
|
24
23
|
return (
|
|
25
|
-
<
|
|
24
|
+
<div
|
|
26
25
|
style={style}
|
|
27
26
|
data-testid={dataTestId}
|
|
28
|
-
className={
|
|
29
|
-
gap='xsmall'
|
|
30
|
-
flex
|
|
31
|
-
direction='column'
|
|
27
|
+
className={twMerge('gap-2 flex flex-col break-words', className)}
|
|
32
28
|
>
|
|
33
29
|
{richText}
|
|
34
|
-
</
|
|
30
|
+
</div>
|
|
35
31
|
)
|
|
36
32
|
}
|
|
37
33
|
|
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import toH from 'hast-to-hyperscript'
|
|
2
2
|
import type { ReactElement, ReactNode, FC } from 'react'
|
|
3
|
-
import type { Theme } from '@material-ui/core/styles'
|
|
4
3
|
import React, { useMemo, createElement, isValidElement } from 'react'
|
|
5
4
|
import { Container } from '@toptal/picasso-container'
|
|
6
5
|
import { Typography } from '@toptal/picasso-typography'
|
|
7
6
|
import { List, ListItem } from '@toptal/picasso-list'
|
|
8
7
|
import { Link } from '@toptal/picasso-link'
|
|
9
|
-
import {
|
|
8
|
+
import { twMerge } from '@toptal/picasso-tailwind-merge'
|
|
10
9
|
|
|
11
10
|
import type { ASTType } from '../../types'
|
|
12
11
|
import { Emoji, Image, Code, CodeBlock } from '../../components'
|
|
13
12
|
import { isCustomEmoji } from '../../../utils'
|
|
14
|
-
import styles from './styles'
|
|
15
|
-
|
|
16
|
-
const useStyles = makeStyles<Theme>(styles, { name: 'PicassoRichText' })
|
|
17
13
|
|
|
18
14
|
type Props = {
|
|
19
15
|
children?: React.ReactNode
|
|
16
|
+
className?: string
|
|
20
17
|
}
|
|
21
18
|
|
|
22
19
|
// List internaly passes another props to ListItem
|
|
@@ -25,39 +22,58 @@ const Li = ({ children, ...props }: Props) => (
|
|
|
25
22
|
)
|
|
26
23
|
|
|
27
24
|
/* eslint-disable id-length */
|
|
28
|
-
const P = ({ children }: Props) => (
|
|
29
|
-
<Typography size='medium'
|
|
25
|
+
const P = ({ children, ...props }: Props) => (
|
|
26
|
+
<Typography size='medium' {...props}>
|
|
27
|
+
{children}
|
|
28
|
+
</Typography>
|
|
30
29
|
)
|
|
31
|
-
const Strong = ({ children }: Props) => (
|
|
32
|
-
<Typography
|
|
30
|
+
const Strong = ({ children, ...props }: Props) => (
|
|
31
|
+
<Typography
|
|
32
|
+
size='inherit'
|
|
33
|
+
as='strong'
|
|
34
|
+
weight='semibold'
|
|
35
|
+
color='inherit'
|
|
36
|
+
{...props}
|
|
37
|
+
>
|
|
33
38
|
{children}
|
|
34
39
|
</Typography>
|
|
35
40
|
)
|
|
36
41
|
|
|
37
|
-
const Em = ({ children }: Props) => (
|
|
38
|
-
<Typography size='inherit' as='em' color='inherit'>
|
|
42
|
+
const Em = ({ children, ...props }: Props) => (
|
|
43
|
+
<Typography size='inherit' as='em' color='inherit' {...props}>
|
|
39
44
|
{children}
|
|
40
45
|
</Typography>
|
|
41
46
|
)
|
|
42
47
|
|
|
43
|
-
const H3 = ({ children }: Props) => (
|
|
44
|
-
<Container top='xsmall'>
|
|
48
|
+
const H3 = ({ children, ...props }: Props) => (
|
|
49
|
+
<Container top='xsmall' {...props}>
|
|
45
50
|
<Typography as='h3' variant='heading' size='medium'>
|
|
46
51
|
{children}
|
|
47
52
|
</Typography>
|
|
48
53
|
</Container>
|
|
49
54
|
)
|
|
50
|
-
const Ul = ({ children }: Props) => <List variant='unordered'>{children}</List>
|
|
51
|
-
const Ol = ({ children }: Props) => <List variant='ordered'>{children}</List>
|
|
52
|
-
const A = ({ children, ...props }: Props) => {
|
|
53
|
-
const classes = useStyles()
|
|
54
55
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
56
|
+
const Ul = ({ children, ...props }: Props) => (
|
|
57
|
+
<List variant='unordered' {...props}>
|
|
58
|
+
{children}
|
|
59
|
+
</List>
|
|
60
|
+
)
|
|
61
|
+
const Ol = ({ children, ...props }: Props) => (
|
|
62
|
+
<List variant='ordered' {...props}>
|
|
63
|
+
{children}
|
|
64
|
+
</List>
|
|
65
|
+
)
|
|
66
|
+
const A = ({ children, className, ...props }: Props) => (
|
|
67
|
+
<Link
|
|
68
|
+
{...props}
|
|
69
|
+
className={twMerge(
|
|
70
|
+
'[&:visited>strong]:text-purple-500 [&:visited>em]:text-purple-500',
|
|
71
|
+
className
|
|
72
|
+
)}
|
|
73
|
+
>
|
|
74
|
+
{children}
|
|
75
|
+
</Link>
|
|
76
|
+
)
|
|
61
77
|
|
|
62
78
|
const Img = ({ ...props }: Props) =>
|
|
63
79
|
isCustomEmoji(props) ? <Emoji {...props} /> : <Image {...props} />
|
package/LICENSE
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021-2022 Toptal, LLC
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
-
this software and associated documentation files (the “Software”), to deal in
|
|
7
|
-
the Software without restriction, including without limitation the rights to
|
|
8
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
-
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
-
subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../src/RichText/hooks/useRichText/styles.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;sCAExB,KAAK;AAAlC,wBAOI"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../../src/RichText/hooks/useRichText/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAGvD,eAAe,CAAC,EAAE,OAAO,EAAS,EAAE,EAAE,CACpC,YAAY,CAAC;IACX,gBAAgB,EAAE;QAChB,oCAAoC,EAAE;YACpC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI;SAC3B;KACF;CACF,CAAC,CAAA"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createStyles } from '@material-ui/core/styles'
|
|
2
|
-
import type { Theme } from '@material-ui/core/styles'
|
|
3
|
-
|
|
4
|
-
export default ({ palette }: Theme) =>
|
|
5
|
-
createStyles({
|
|
6
|
-
visitedLinkChild: {
|
|
7
|
-
'&:visited > strong, &:visited > em': {
|
|
8
|
-
color: palette.purple.main,
|
|
9
|
-
},
|
|
10
|
-
},
|
|
11
|
-
})
|