@pega/cosmos-react-rte 2.0.0-dev.2.0 → 2.0.0-dev.21.1
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/lib/components/RichTextEditor/DecoratorComponents/CodeBlock.d.ts.map +1 -1
- package/lib/components/RichTextEditor/DecoratorComponents/CodeBlock.js +3 -3
- package/lib/components/RichTextEditor/DecoratorComponents/CodeBlock.js.map +1 -1
- package/lib/components/RichTextEditor/DecoratorComponents/Image.d.ts.map +1 -1
- package/lib/components/RichTextEditor/DecoratorComponents/Image.js +2 -3
- package/lib/components/RichTextEditor/DecoratorComponents/Image.js.map +1 -1
- package/lib/components/RichTextEditor/DecoratorComponents/Link.d.ts.map +1 -1
- package/lib/components/RichTextEditor/DecoratorComponents/Link.js +2 -2
- package/lib/components/RichTextEditor/DecoratorComponents/Link.js.map +1 -1
- package/lib/components/RichTextEditor/DecoratorComponents/Table.d.ts +2 -0
- package/lib/components/RichTextEditor/DecoratorComponents/Table.d.ts.map +1 -1
- package/lib/components/RichTextEditor/DecoratorComponents/Table.js +10 -8
- package/lib/components/RichTextEditor/DecoratorComponents/Table.js.map +1 -1
- package/lib/components/RichTextEditor/RichTextEditor.context.d.ts +3 -3
- package/lib/components/RichTextEditor/RichTextEditor.context.d.ts.map +1 -1
- package/lib/components/RichTextEditor/RichTextEditor.context.js +1 -1
- package/lib/components/RichTextEditor/RichTextEditor.context.js.map +1 -1
- package/lib/components/RichTextEditor/RichTextEditor.d.ts.map +1 -1
- package/lib/components/RichTextEditor/RichTextEditor.js +103 -75
- package/lib/components/RichTextEditor/RichTextEditor.js.map +1 -1
- package/lib/components/RichTextEditor/RichTextEditor.styles.d.ts +3 -0
- package/lib/components/RichTextEditor/RichTextEditor.styles.d.ts.map +1 -1
- package/lib/components/RichTextEditor/RichTextEditor.styles.js +121 -51
- package/lib/components/RichTextEditor/RichTextEditor.styles.js.map +1 -1
- package/lib/components/RichTextEditor/RichTextEditor.types.d.ts +41 -13
- package/lib/components/RichTextEditor/RichTextEditor.types.d.ts.map +1 -1
- package/lib/components/RichTextEditor/RichTextEditor.types.js.map +1 -1
- package/lib/components/RichTextEditor/RichTextViewer.d.ts.map +1 -1
- package/lib/components/RichTextEditor/RichTextViewer.js +21 -12
- package/lib/components/RichTextEditor/RichTextViewer.js.map +1 -1
- package/lib/components/RichTextEditor/RichTextViewer.types.d.ts +3 -1
- package/lib/components/RichTextEditor/RichTextViewer.types.d.ts.map +1 -1
- package/lib/components/RichTextEditor/RichTextViewer.types.js.map +1 -1
- package/lib/components/RichTextEditor/Toolbar/AnchorButton.d.ts.map +1 -1
- package/lib/components/RichTextEditor/Toolbar/AnchorButton.js +50 -59
- package/lib/components/RichTextEditor/Toolbar/AnchorButton.js.map +1 -1
- package/lib/components/RichTextEditor/Toolbar/ImageButton.d.ts.map +1 -1
- package/lib/components/RichTextEditor/Toolbar/ImageButton.js +10 -16
- package/lib/components/RichTextEditor/Toolbar/ImageButton.js.map +1 -1
- package/lib/components/RichTextEditor/Toolbar/IndentButton.d.ts.map +1 -1
- package/lib/components/RichTextEditor/Toolbar/IndentButton.js +6 -4
- package/lib/components/RichTextEditor/Toolbar/IndentButton.js.map +1 -1
- package/lib/components/RichTextEditor/Toolbar/TableButton.d.ts.map +1 -1
- package/lib/components/RichTextEditor/Toolbar/TableButton.js +6 -5
- package/lib/components/RichTextEditor/Toolbar/TableButton.js.map +1 -1
- package/lib/components/RichTextEditor/Toolbar/TextSelect.d.ts.map +1 -1
- package/lib/components/RichTextEditor/Toolbar/TextSelect.js +50 -35
- package/lib/components/RichTextEditor/Toolbar/TextSelect.js.map +1 -1
- package/lib/components/RichTextEditor/Toolbar/Toolbar.d.ts.map +1 -1
- package/lib/components/RichTextEditor/Toolbar/Toolbar.js +18 -35
- package/lib/components/RichTextEditor/Toolbar/Toolbar.js.map +1 -1
- package/lib/components/RichTextEditor/Toolbar/ToolbarButton.d.ts.map +1 -1
- package/lib/components/RichTextEditor/Toolbar/ToolbarButton.js +7 -8
- package/lib/components/RichTextEditor/Toolbar/ToolbarButton.js.map +1 -1
- package/lib/components/RichTextEditor/utils/EditorCommands.d.ts +9 -1
- package/lib/components/RichTextEditor/utils/EditorCommands.d.ts.map +1 -1
- package/lib/components/RichTextEditor/utils/EditorCommands.js +130 -17
- package/lib/components/RichTextEditor/utils/EditorCommands.js.map +1 -1
- package/lib/components/RichTextEditor/utils/ListCommands.js +10 -14
- package/lib/components/RichTextEditor/utils/ListCommands.js.map +1 -1
- package/lib/components/RichTextEditor/utils/htmlConverter.d.ts +2 -1
- package/lib/components/RichTextEditor/utils/htmlConverter.d.ts.map +1 -1
- package/lib/components/RichTextEditor/utils/htmlConverter.js +67 -28
- package/lib/components/RichTextEditor/utils/htmlConverter.js.map +1 -1
- package/lib/components/RichTextEditor/utils/interactionRenderer.d.ts +12 -0
- package/lib/components/RichTextEditor/utils/interactionRenderer.d.ts.map +1 -0
- package/lib/components/RichTextEditor/utils/interactionRenderer.js +105 -0
- package/lib/components/RichTextEditor/utils/interactionRenderer.js.map +1 -0
- package/lib/components/RichTextEditor/utils/markdownConverter.d.ts +2 -0
- package/lib/components/RichTextEditor/utils/markdownConverter.d.ts.map +1 -1
- package/lib/components/RichTextEditor/utils/markdownConverter.js +30 -94
- package/lib/components/RichTextEditor/utils/markdownConverter.js.map +1 -1
- package/lib/components/RichTextEditor/utils/renderers.d.ts.map +1 -1
- package/lib/components/RichTextEditor/utils/renderers.js +26 -25
- package/lib/components/RichTextEditor/utils/renderers.js.map +1 -1
- package/lib/components/RichTextEditor/utils/search.d.ts.map +1 -1
- package/lib/components/RichTextEditor/utils/search.js +7 -3
- package/lib/components/RichTextEditor/utils/search.js.map +1 -1
- package/lib/components/RichTextEditor/utils/slateConverter.d.ts.map +1 -1
- package/lib/components/RichTextEditor/utils/slateConverter.js +1 -0
- package/lib/components/RichTextEditor/utils/slateConverter.js.map +1 -1
- package/package.json +19 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.d.ts","sourceRoot":"","sources":["../../../../src/components/RichTextEditor/DecoratorComponents/CodeBlock.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"CodeBlock.d.ts","sourceRoot":"","sources":["../../../../src/components/RichTextEditor/DecoratorComponents/CodeBlock.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAc3B,QAAA,MAAM,SAAS,EAAE,EAAE,CAAC,GAAG,CAEtB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { defaultThemeProp } from '@pega/cosmos-react-core';
|
|
4
4
|
const StyledCodeBlock = styled.code `
|
|
5
|
-
background-color: ${props => props.theme.base.colors.gray
|
|
5
|
+
background-color: ${props => props.theme.base.colors.gray['extra-light']};
|
|
6
6
|
display: block;
|
|
7
7
|
font-family: monospace;
|
|
8
8
|
padding: ${props => props.theme.base.spacing};
|
|
9
9
|
`;
|
|
10
10
|
StyledCodeBlock.defaultProps = defaultThemeProp;
|
|
11
11
|
const CodeBlock = (props) => {
|
|
12
|
-
return
|
|
12
|
+
return _jsx(StyledCodeBlock, { ...props }, void 0);
|
|
13
13
|
};
|
|
14
14
|
export default CodeBlock;
|
|
15
15
|
//# sourceMappingURL=CodeBlock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.js","sourceRoot":"","sources":["../../../../src/components/RichTextEditor/DecoratorComponents/CodeBlock.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CodeBlock.js","sourceRoot":"","sources":["../../../../src/components/RichTextEditor/DecoratorComponents/CodeBlock.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAA;sBACb,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;;;aAG7D,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO;CAC7C,CAAC;AAEF,eAAe,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEhD,MAAM,SAAS,GAAY,CAAC,KAAU,EAAE,EAAE;IACxC,OAAO,KAAC,eAAe,OAAK,KAAK,WAAI,CAAC;AACxC,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import { FC } from 'react';\nimport styled from 'styled-components';\n\nimport { defaultThemeProp } from '@pega/cosmos-react-core';\n\nconst StyledCodeBlock = styled.code`\n background-color: ${props => props.theme.base.colors.gray['extra-light']};\n display: block;\n font-family: monospace;\n padding: ${props => props.theme.base.spacing};\n`;\n\nStyledCodeBlock.defaultProps = defaultThemeProp;\n\nconst CodeBlock: FC<any> = (props: any) => {\n return <StyledCodeBlock {...props} />;\n};\n\nexport default CodeBlock;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../../../src/components/RichTextEditor/DecoratorComponents/Image.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../../../src/components/RichTextEditor/DecoratorComponents/Image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAS3B,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC,GAAG,CAMvB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Flex, Image } from '@pega/cosmos-react-core';
|
|
3
3
|
const ImageBlock = (props) => {
|
|
4
|
-
return (
|
|
5
|
-
React.createElement(Image, { src: props.src, alt: props.alt })));
|
|
4
|
+
return (_jsx(Flex, { container: { alignItems: 'end' }, children: _jsx(Image, { src: props.src, alt: props.alt }, void 0) }, void 0));
|
|
6
5
|
};
|
|
7
6
|
export default ImageBlock;
|
|
8
7
|
//# sourceMappingURL=Image.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.js","sourceRoot":"","sources":["../../../../src/components/RichTextEditor/DecoratorComponents/Image.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Image.js","sourceRoot":"","sources":["../../../../src/components/RichTextEditor/DecoratorComponents/Image.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAOtD,MAAM,UAAU,GAAY,CAAC,KAAsB,EAAE,EAAE;IACrD,OAAO,CACL,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,YACpC,KAAC,KAAK,IAAC,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,WAAI,WACpC,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { FC } from 'react';\n\nimport { Flex, Image } from '@pega/cosmos-react-core';\n\ninterface ImageBlockProps {\n src: string;\n alt: string;\n}\n\nconst ImageBlock: FC<any> = (props: ImageBlockProps) => {\n return (\n <Flex container={{ alignItems: 'end' }}>\n <Image src={props.src} alt={props.alt} />\n </Flex>\n );\n};\n\nexport default ImageBlock;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../../../src/components/RichTextEditor/DecoratorComponents/Link.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../../../src/components/RichTextEditor/DecoratorComponents/Link.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAI3B,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC,GAAG,CAOvB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Link } from '@pega/cosmos-react-core';
|
|
3
3
|
const LinkEntity = (props) => {
|
|
4
4
|
const { url } = props.contentState.getEntity(props.entityKey).getData();
|
|
5
|
-
return (
|
|
5
|
+
return (_jsx(Link, { href: url, target: '_blank', children: props.children }, void 0));
|
|
6
6
|
};
|
|
7
7
|
export default LinkEntity;
|
|
8
8
|
//# sourceMappingURL=Link.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.js","sourceRoot":"","sources":["../../../../src/components/RichTextEditor/DecoratorComponents/Link.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Link.js","sourceRoot":"","sources":["../../../../src/components/RichTextEditor/DecoratorComponents/Link.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAE/C,MAAM,UAAU,GAAY,CAAC,KAAU,EAAE,EAAE;IACzC,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC;IACxE,OAAO,CACL,KAAC,IAAI,IAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAC,QAAQ,YAC7B,KAAK,CAAC,QAAQ,WACV,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { FC } from 'react';\n\nimport { Link } from '@pega/cosmos-react-core';\n\nconst LinkEntity: FC<any> = (props: any) => {\n const { url } = props.contentState.getEntity(props.entityKey).getData();\n return (\n <Link href={url} target='_blank'>\n {props.children}\n </Link>\n );\n};\n\nexport default LinkEntity;\n"]}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
+
import { DefaultTheme } from 'styled-components';
|
|
3
|
+
export declare const getTableStyles: (theme: DefaultTheme) => import("styled-components").FlattenSimpleInterpolation;
|
|
2
4
|
export declare const TableBody: FC<any>;
|
|
3
5
|
export declare const Table: FC<any>;
|
|
4
6
|
export declare const TableRow: FC<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../../src/components/RichTextEditor/DecoratorComponents/Table.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../../src/components/RichTextEditor/DecoratorComponents/Table.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAmB,MAAM,OAAO,CAAC;AAC5C,OAAe,EAAE,YAAY,EAAO,MAAM,mBAAmB,CAAC;AAI9D,eAAO,MAAM,cAAc,UAAW,YAAY,2DA2BjD,CAAC;AAMF,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,GAAG,CAO5B,CAAC;AAEH,eAAO,MAAM,KAAK,EAAE,EAAE,CAAC,GAAG,CAOxB,CAAC;AAEH,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,GAAG,CAO3B,CAAC;AAEH,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,GAAG,CAO5B,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
3
4
|
import { defaultThemeProp } from '@pega/cosmos-react-core';
|
|
4
|
-
const
|
|
5
|
+
export const getTableStyles = (theme) => css `
|
|
5
6
|
border-collapse: collapse;
|
|
6
7
|
|
|
7
8
|
td {
|
|
8
|
-
border: 0.0625rem solid ${
|
|
9
|
+
border: 0.0625rem solid ${theme.base.palette['border-line']};
|
|
9
10
|
min-width: 6.25rem;
|
|
10
11
|
}
|
|
11
12
|
|
|
@@ -29,21 +30,22 @@ const StyledTable = styled.table `
|
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
`;
|
|
33
|
+
const StyledTable = styled.table(props => getTableStyles(props.theme));
|
|
32
34
|
StyledTable.defaultProps = defaultThemeProp;
|
|
33
35
|
export const TableBody = forwardRef((props, ref) => {
|
|
34
36
|
const { children, ...restProps } = props;
|
|
35
|
-
return (
|
|
37
|
+
return (_jsx("tbody", { ...restProps, ref: ref, children: children }, void 0));
|
|
36
38
|
});
|
|
37
39
|
export const Table = forwardRef((props, ref) => {
|
|
38
40
|
const { children, ...restProps } = props;
|
|
39
|
-
return (
|
|
41
|
+
return (_jsx(StyledTable, { ...restProps, ref: ref, children: children }, void 0));
|
|
40
42
|
});
|
|
41
43
|
export const TableRow = forwardRef((props, ref) => {
|
|
42
44
|
const { children, ...restProps } = props;
|
|
43
|
-
return (
|
|
45
|
+
return (_jsx("tr", { ...restProps, ref: ref, children: children }, void 0));
|
|
44
46
|
});
|
|
45
47
|
export const TableCell = forwardRef((props, ref) => {
|
|
46
48
|
const { children, ...restProps } = props;
|
|
47
|
-
return (
|
|
49
|
+
return (_jsx("td", { ...restProps, ref: ref, children: children }, void 0));
|
|
48
50
|
});
|
|
49
51
|
//# sourceMappingURL=Table.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.js","sourceRoot":"","sources":["../../../../src/components/RichTextEditor/DecoratorComponents/Table.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Table.js","sourceRoot":"","sources":["../../../../src/components/RichTextEditor/DecoratorComponents/Table.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAO,MAAM,OAAO,CAAC;AAC5C,OAAO,MAAM,EAAE,EAAgB,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,GAAG,CAAA;;;;8BAI5B,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;CAuB9D,CAAC;AAEF,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAEvE,WAAW,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE5C,MAAM,CAAC,MAAM,SAAS,GAAY,UAAU,CAAC,CAAC,KAAU,EAAE,GAAa,EAAE,EAAE;IACzE,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IACzC,OAAO,CACL,mBAAW,SAAS,EAAE,GAAG,EAAE,GAAG,YAC3B,QAAQ,WACH,CACT,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,KAAK,GAAY,UAAU,CAAC,CAAC,KAAU,EAAE,GAAa,EAAE,EAAE;IACrE,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IACzC,OAAO,CACL,KAAC,WAAW,OAAK,SAAS,EAAE,GAAG,EAAE,GAAG,YACjC,QAAQ,WACG,CACf,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAY,UAAU,CAAC,CAAC,KAAU,EAAE,GAAa,EAAE,EAAE;IACxE,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IACzC,OAAO,CACL,gBAAQ,SAAS,EAAE,GAAG,EAAE,GAAG,YACxB,QAAQ,WACN,CACN,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,SAAS,GAAY,UAAU,CAAC,CAAC,KAAU,EAAE,GAAa,EAAE,EAAE;IACzE,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IACzC,OAAO,CACL,gBAAQ,SAAS,EAAE,GAAG,EAAE,GAAG,YACxB,QAAQ,WACN,CACN,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { FC, forwardRef, Ref } from 'react';\nimport styled, { DefaultTheme, css } from 'styled-components';\n\nimport { defaultThemeProp } from '@pega/cosmos-react-core';\n\nexport const getTableStyles = (theme: DefaultTheme) => css`\n border-collapse: collapse;\n\n td {\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n min-width: 6.25rem;\n }\n\n tr:first-child {\n td:first-child {\n border-top-left-radius: 0.125rem;\n }\n\n td:last-child {\n border-top-right-radius: 0.125rem;\n }\n }\n\n tr:last-child {\n td:first-child {\n border-bottom-left-radius: 0.125rem;\n }\n\n td:last-child {\n border-bottom-right-radius: 0.125rem;\n }\n }\n`;\n\nconst StyledTable = styled.table(props => getTableStyles(props.theme));\n\nStyledTable.defaultProps = defaultThemeProp;\n\nexport const TableBody: FC<any> = forwardRef((props: any, ref: Ref<any>) => {\n const { children, ...restProps } = props;\n return (\n <tbody {...restProps} ref={ref}>\n {children}\n </tbody>\n );\n});\n\nexport const Table: FC<any> = forwardRef((props: any, ref: Ref<any>) => {\n const { children, ...restProps } = props;\n return (\n <StyledTable {...restProps} ref={ref}>\n {children}\n </StyledTable>\n );\n});\n\nexport const TableRow: FC<any> = forwardRef((props: any, ref: Ref<any>) => {\n const { children, ...restProps } = props;\n return (\n <tr {...restProps} ref={ref}>\n {children}\n </tr>\n );\n});\n\nexport const TableCell: FC<any> = forwardRef((props: any, ref: Ref<any>) => {\n const { children, ...restProps } = props;\n return (\n <td {...restProps} ref={ref}>\n {children}\n </td>\n );\n});\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { MouseEvent } from 'react';
|
|
1
|
+
import { MouseEvent, FocusEvent } from 'react';
|
|
2
2
|
export interface RichTextEditorContextValue {
|
|
3
|
-
|
|
3
|
+
addImage: (image: File) => void;
|
|
4
4
|
setPopoverOpen: (open: boolean) => void;
|
|
5
5
|
onEditorFocus: (args: {
|
|
6
|
-
event?: MouseEvent | FocusEvent
|
|
6
|
+
event?: MouseEvent | FocusEvent<any>;
|
|
7
7
|
force?: boolean;
|
|
8
8
|
runAfterFocus?: () => void;
|
|
9
9
|
focusEditor?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextEditor.context.d.ts","sourceRoot":"","sources":["../../../src/components/RichTextEditor/RichTextEditor.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,UAAU,EAAc,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"RichTextEditor.context.d.ts","sourceRoot":"","sources":["../../../src/components/RichTextEditor/RichTextEditor.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,UAAU,EAAc,UAAU,EAAE,MAAM,OAAO,CAAC;AAE1E,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,IAAI,CAAC;IAChC,cAAc,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,aAAa,EAAE,CAAC,IAAI,EAAE;QACpB,KAAK,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;QACrC,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;QAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;KACvB,KAAK,IAAI,CAAC;IACX,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,qBAAqB,qDAKhC,CAAC;AAEH,eAAO,MAAM,aAAa,kCAEzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextEditor.context.js","sourceRoot":"","sources":["../../../src/components/RichTextEditor/RichTextEditor.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAc,UAAU,
|
|
1
|
+
{"version":3,"file":"RichTextEditor.context.js","sourceRoot":"","sources":["../../../src/components/RichTextEditor/RichTextEditor.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAc,UAAU,EAAc,MAAM,OAAO,CAAC;AAc1E,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAA6B;IAC7E,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;IAClB,cAAc,EAAE,GAAG,EAAE,GAAE,CAAC;IACxB,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC;IACvB,QAAQ,EAAE,KAAK;CAChB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,OAAO,UAAU,CAAC,qBAAqB,CAAC,CAAC;AAC3C,CAAC,CAAC","sourcesContent":["import { createContext, MouseEvent, useContext, FocusEvent } from 'react';\n\nexport interface RichTextEditorContextValue {\n addImage: (image: File) => void;\n setPopoverOpen: (open: boolean) => void;\n onEditorFocus: (args: {\n event?: MouseEvent | FocusEvent<any>;\n force?: boolean;\n runAfterFocus?: () => void;\n focusEditor?: boolean;\n }) => void;\n disabled: boolean;\n}\n\nexport const RichTextEditorContext = createContext<RichTextEditorContextValue>({\n addImage: () => {},\n setPopoverOpen: () => {},\n onEditorFocus: () => {},\n disabled: false\n});\n\nexport const useRTEContext = () => {\n return useContext(RichTextEditorContext);\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextEditor.d.ts","sourceRoot":"","sources":["../../../src/components/RichTextEditor/RichTextEditor.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"RichTextEditor.d.ts","sourceRoot":"","sources":["../../../src/components/RichTextEditor/RichTextEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,EAAE,EASH,MAAM,OAAO,CAAC;AASf,OAAO,EAQL,YAAY,EAMb,MAAM,yBAAyB,CAAC;AAUjC,OAAO,EAAuB,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AA2DlF,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,GAAG,YAAY,CA2b1D,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useState, useRef, useMemo, useEffect, useCallback, useImperativeHandle, useReducer } from 'react';
|
|
2
3
|
// Import the Slate editor factory.
|
|
3
|
-
import { createEditor, Node } from 'slate';
|
|
4
|
+
import { createEditor, Node, Transforms } from 'slate';
|
|
4
5
|
// Import the Slate components and React plugin.
|
|
5
6
|
import { Slate, Editable, withReact, ReactEditor } from 'slate-react';
|
|
7
|
+
import { withHistory } from 'slate-history';
|
|
6
8
|
import styled from 'styled-components';
|
|
7
|
-
import { FormField, FormControl, StyledPopover, useTheme, useUID, createUID, debounce, Popover, Menu, menuHelpers
|
|
8
|
-
import StyledRichTextEditor, { EditorContainer } from './RichTextEditor.styles';
|
|
9
|
+
import { FormField, FormControl, StyledPopover, useTheme, useUID, createUID, debounce, Popover, Menu, menuHelpers } from '@pega/cosmos-react-core';
|
|
10
|
+
import StyledRichTextEditor, { EditorContainer, StyledFormField } from './RichTextEditor.styles';
|
|
9
11
|
import Toolbar from './Toolbar/Toolbar';
|
|
10
12
|
import { nodeRenderer, leafRenderer } from './utils/renderers';
|
|
11
13
|
import { onSearchChange } from './utils/search';
|
|
@@ -14,6 +16,7 @@ import ListCommands from './utils/ListCommands';
|
|
|
14
16
|
import { convertHtml } from './utils/htmlConverter';
|
|
15
17
|
import { convertSlateToHtml } from './utils/slateConverter';
|
|
16
18
|
import { RichTextEditorContext } from './RichTextEditor.context';
|
|
19
|
+
import { convertMarkdownForEditor } from './utils/markdownConverter';
|
|
17
20
|
const withVoids = (editor) => {
|
|
18
21
|
editor.isVoid = element => {
|
|
19
22
|
if (element.type === 'image' || element.type === 'image-placeholder') {
|
|
@@ -24,7 +27,6 @@ const withVoids = (editor) => {
|
|
|
24
27
|
return editor;
|
|
25
28
|
};
|
|
26
29
|
const syntheticFocusReducer = (currentId, action) => {
|
|
27
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
28
30
|
const { type, menuItems, selectedItemId } = action;
|
|
29
31
|
switch (type) {
|
|
30
32
|
case 'child':
|
|
@@ -32,24 +34,24 @@ const syntheticFocusReducer = (currentId, action) => {
|
|
|
32
34
|
if (!currentId)
|
|
33
35
|
return menuItems[0].id;
|
|
34
36
|
// if currently highlighted item has children, select first of them
|
|
35
|
-
return
|
|
37
|
+
return menuHelpers.getItem(menuItems, currentId)?.items?.[0].id;
|
|
36
38
|
case 'parent':
|
|
37
39
|
// find and return parent of currently selected item
|
|
38
|
-
return
|
|
40
|
+
return menuHelpers.getParentItem(menuItems, currentId)?.id;
|
|
39
41
|
case 'next':
|
|
40
42
|
// return next sibling of currently selected item
|
|
41
|
-
return
|
|
43
|
+
return menuHelpers.getNextItem(menuItems, currentId)?.id ?? currentId;
|
|
42
44
|
case 'prev':
|
|
43
45
|
// return prev sibling of currently selected item
|
|
44
|
-
return
|
|
46
|
+
return menuHelpers.getPrevItem(menuItems, currentId)?.id ?? currentId;
|
|
45
47
|
case 'list_change':
|
|
46
48
|
// if currently selected item does not exist in new list, select first one
|
|
47
49
|
if (currentId && menuHelpers.getItem(menuItems, currentId))
|
|
48
50
|
return currentId;
|
|
49
|
-
return
|
|
51
|
+
return menuItems[0]?.id;
|
|
50
52
|
case 'set':
|
|
51
53
|
// return arbitrary selected item id if it is in the tree; undefined otherwise
|
|
52
|
-
return selectedItemId ?
|
|
54
|
+
return selectedItemId ? menuHelpers.getItem(menuItems, selectedItemId)?.id : undefined;
|
|
53
55
|
case 'clear':
|
|
54
56
|
return undefined;
|
|
55
57
|
default:
|
|
@@ -61,17 +63,13 @@ const StyledSearchPopover = styled(StyledPopover) `
|
|
|
61
63
|
`;
|
|
62
64
|
const RichTextEditor = forwardRef((props, ref) => {
|
|
63
65
|
const { components: { 'text-area': { 'min-height': minHeight } } } = useTheme();
|
|
64
|
-
const
|
|
66
|
+
const uid = useUID();
|
|
67
|
+
const { id = uid, label, labelHidden, info, status, required, disabled, readOnly, onChange, onFocus, onBlur, placeholder, toolbar, onImageAdded, markdownOnly, searchTriggers, onSearch, getSearchItemReplacement, searchRenderers, menu, height = { min: minHeight }, defaultValue, autoFocus, ...restProps } = props;
|
|
65
68
|
const formFieldRef = useRef(null);
|
|
66
|
-
const editor = useMemo(() => withVoids(withReact(createEditor())), []);
|
|
67
|
-
const [value, setValue] = useState(defaultValue && !markdownOnly
|
|
69
|
+
const editor = useMemo(() => withVoids(withReact(withHistory(createEditor()))), []);
|
|
70
|
+
const [value, setValue] = useState(() => defaultValue && !markdownOnly
|
|
68
71
|
? convertHtml(defaultValue)
|
|
69
|
-
:
|
|
70
|
-
{
|
|
71
|
-
type: 'paragraph',
|
|
72
|
-
children: [{ text: defaultValue || '' }]
|
|
73
|
-
}
|
|
74
|
-
]);
|
|
72
|
+
: convertMarkdownForEditor(defaultValue, searchRenderers));
|
|
75
73
|
const [toolbarPopover, setToolbarPopover] = useState(false);
|
|
76
74
|
const [toolbarSticky, setToolbarSticky] = useState(false);
|
|
77
75
|
const [focusableToolbarBtn, setFocusableToolbarBtn] = useState(null);
|
|
@@ -79,8 +77,7 @@ const RichTextEditor = forwardRef((props, ref) => {
|
|
|
79
77
|
const [popoverTarget, setPopoverTarget] = useState(null);
|
|
80
78
|
const [searchEl, setSearchEl] = useState(null);
|
|
81
79
|
const updateToolbarStyle = () => {
|
|
82
|
-
|
|
83
|
-
if ((((_a = formFieldRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) || 0) > window.innerHeight) {
|
|
80
|
+
if ((formFieldRef.current?.offsetHeight || 0) > window.innerHeight) {
|
|
84
81
|
setToolbarSticky(true);
|
|
85
82
|
}
|
|
86
83
|
else {
|
|
@@ -91,24 +88,36 @@ const RichTextEditor = forwardRef((props, ref) => {
|
|
|
91
88
|
const getPlainText = () => {
|
|
92
89
|
return value
|
|
93
90
|
.map(node => {
|
|
91
|
+
if (markdownOnly && node.children) {
|
|
92
|
+
return node.children
|
|
93
|
+
.map(textNode => textNode.searchResult?.markdown || textNode.text)
|
|
94
|
+
.join('');
|
|
95
|
+
}
|
|
94
96
|
return Node.string(node);
|
|
95
97
|
})
|
|
96
98
|
.join('\n');
|
|
97
99
|
};
|
|
98
100
|
const onEditorFocus = ({ event, force, focusEditor, runAfterFocus }) => {
|
|
99
101
|
if (focusEditor) {
|
|
100
|
-
|
|
102
|
+
setTimeout(() => {
|
|
103
|
+
if (!ReactEditor.isFocused(editor)) {
|
|
104
|
+
ReactEditor.focus(editor);
|
|
105
|
+
onFocus?.();
|
|
106
|
+
}
|
|
107
|
+
}, 0);
|
|
101
108
|
}
|
|
102
109
|
if (runAfterFocus && (force || (!disabled && !toolbarPopover))) {
|
|
103
110
|
setTimeout(runAfterFocus, 0);
|
|
104
111
|
}
|
|
105
112
|
else {
|
|
106
|
-
event
|
|
113
|
+
event?.stopPropagation();
|
|
107
114
|
}
|
|
108
115
|
};
|
|
109
116
|
const blurEditor = () => {
|
|
110
|
-
ReactEditor.
|
|
111
|
-
|
|
117
|
+
if (ReactEditor.isFocused(editor)) {
|
|
118
|
+
ReactEditor.blur(editor);
|
|
119
|
+
onBlur?.();
|
|
120
|
+
}
|
|
112
121
|
};
|
|
113
122
|
useImperativeHandle(ref, () => ({
|
|
114
123
|
focus: () => {
|
|
@@ -134,19 +143,48 @@ const RichTextEditor = forwardRef((props, ref) => {
|
|
|
134
143
|
]);
|
|
135
144
|
},
|
|
136
145
|
appendImage: ({ src, alt }, imageId) => {
|
|
137
|
-
EditorCommands.appendImage(editor, { src, alt }, imageId);
|
|
146
|
+
const path = EditorCommands.appendImage(editor, { src, alt }, imageId);
|
|
147
|
+
if (path) {
|
|
148
|
+
Transforms.select(editor, { anchor: path, focus: path });
|
|
149
|
+
ReactEditor.focus(editor);
|
|
150
|
+
}
|
|
138
151
|
},
|
|
139
152
|
insertText: (text) => {
|
|
140
153
|
editor.insertText(text);
|
|
154
|
+
},
|
|
155
|
+
insertHtml: (html, overwrite = false) => {
|
|
156
|
+
setValue(prevValue => {
|
|
157
|
+
if (overwrite) {
|
|
158
|
+
const point = { path: [0, 0], offset: 0 };
|
|
159
|
+
editor.selection = { anchor: point, focus: point };
|
|
160
|
+
return convertHtml(html !== '' ? html : '<p></p>');
|
|
161
|
+
}
|
|
162
|
+
return [...prevValue, ...convertHtml(html)];
|
|
163
|
+
});
|
|
141
164
|
}
|
|
142
165
|
}), [value, setValue]);
|
|
143
166
|
const onMenuItemClick = (itemId, e) => {
|
|
144
|
-
var _a;
|
|
145
167
|
// MenuItem expects actual click events, but we don't have reference to actual menu item element to trigger a click.
|
|
146
|
-
|
|
147
|
-
const
|
|
148
|
-
if (
|
|
149
|
-
|
|
168
|
+
menu?.onItemClick?.(itemId, e);
|
|
169
|
+
const replacement = getSearchItemReplacement?.(itemId);
|
|
170
|
+
if (replacement) {
|
|
171
|
+
let node;
|
|
172
|
+
if (replacement.markdown && replacement.component && replacement.props) {
|
|
173
|
+
node = {
|
|
174
|
+
text: replacement.text,
|
|
175
|
+
searchResult: {
|
|
176
|
+
markdown: replacement.markdown,
|
|
177
|
+
component: replacement.component,
|
|
178
|
+
props: replacement.props,
|
|
179
|
+
// Prevents copying searchResult attribute onPaste
|
|
180
|
+
toJSON: () => undefined
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
node = { text: replacement.text };
|
|
186
|
+
}
|
|
187
|
+
EditorCommands.replaceWithNodes(editor, popoverTarget, node);
|
|
150
188
|
}
|
|
151
189
|
};
|
|
152
190
|
const onKeyDown = useCallback((event) => {
|
|
@@ -164,7 +202,6 @@ const RichTextEditor = forwardRef((props, ref) => {
|
|
|
164
202
|
event.preventDefault();
|
|
165
203
|
if (focusedId) {
|
|
166
204
|
onMenuItemClick(focusedId, event);
|
|
167
|
-
setPopoverTarget(null);
|
|
168
205
|
dispatchFocus({ type: 'clear', menuItems: menu.items });
|
|
169
206
|
}
|
|
170
207
|
break;
|
|
@@ -185,15 +222,19 @@ const RichTextEditor = forwardRef((props, ref) => {
|
|
|
185
222
|
else {
|
|
186
223
|
ListCommands.checkListEnter(editor, event);
|
|
187
224
|
EditorCommands.checkLinkBreak(editor, event);
|
|
225
|
+
EditorCommands.checkSearchDownKeys(editor, event);
|
|
188
226
|
EditorCommands.checkImageEnter(editor, event);
|
|
189
227
|
EditorCommands.checkKeyCommands(editor, event);
|
|
190
228
|
}
|
|
191
|
-
}, [focusedId, popoverTarget, focusableToolbarBtn]);
|
|
229
|
+
}, [menu, focusedId, popoverTarget, focusableToolbarBtn]);
|
|
230
|
+
const onKeyUp = (event) => {
|
|
231
|
+
EditorCommands.checkSearchUpKeys(editor, event);
|
|
232
|
+
};
|
|
192
233
|
// Adds an image placeholder to be replaced later in time by an image
|
|
193
234
|
const addImage = (file) => {
|
|
194
235
|
const placeholderId = EditorCommands.appendImagePlaceholder(editor);
|
|
195
236
|
if (placeholderId)
|
|
196
|
-
onImageAdded
|
|
237
|
+
onImageAdded?.(file, placeholderId);
|
|
197
238
|
};
|
|
198
239
|
const onPaste = (e) => {
|
|
199
240
|
let image;
|
|
@@ -224,14 +265,14 @@ const RichTextEditor = forwardRef((props, ref) => {
|
|
|
224
265
|
}
|
|
225
266
|
}, [popoverTarget]);
|
|
226
267
|
useEffect(() => {
|
|
227
|
-
onChange
|
|
268
|
+
onChange?.();
|
|
228
269
|
}, [value]);
|
|
229
270
|
useEffect(() => {
|
|
230
271
|
if (menu && popoverTarget) {
|
|
231
272
|
dispatchFocus({
|
|
232
273
|
type: 'set',
|
|
233
274
|
menuItems: menu.items,
|
|
234
|
-
selectedItemId: menu.items[0]
|
|
275
|
+
selectedItemId: menu.items[0]?.id
|
|
235
276
|
});
|
|
236
277
|
}
|
|
237
278
|
}, [menu, popoverTarget]);
|
|
@@ -242,24 +283,18 @@ const RichTextEditor = forwardRef((props, ref) => {
|
|
|
242
283
|
}, 0);
|
|
243
284
|
}
|
|
244
285
|
}, []);
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
ReactEditor.focus(editor);
|
|
248
|
-
}
|
|
249
|
-
}, [menu]);
|
|
250
|
-
return (React.createElement(RichTextEditorContext.Provider, { value: {
|
|
251
|
-
onImageAdded,
|
|
286
|
+
return (_jsx(RichTextEditorContext.Provider, { value: {
|
|
287
|
+
addImage,
|
|
252
288
|
setPopoverOpen: setToolbarPopover,
|
|
253
289
|
onEditorFocus,
|
|
254
290
|
disabled: disabled || false
|
|
255
|
-
}
|
|
256
|
-
React.createElement(FormField, { label:
|
|
291
|
+
}, children: _jsx(FormField, { as: StyledFormField, toolbar: !!(!markdownOnly && toolbar?.length), label:
|
|
257
292
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
|
|
258
|
-
|
|
259
|
-
if (e.target === formFieldRef.current)
|
|
260
|
-
onEditorFocus({});
|
|
261
|
-
|
|
262
|
-
|
|
293
|
+
_jsx("span", { onClick: () => onEditorFocus({ focusEditor: true }), children: label }, void 0), labelHidden: labelHidden, id: id, info: info, status: status, required: required, disabled: disabled, readOnly: readOnly, onDrop: onDrop, onFocus: (e) => {
|
|
294
|
+
if (e.target === formFieldRef.current) {
|
|
295
|
+
onEditorFocus({ focusEditor: true });
|
|
296
|
+
}
|
|
297
|
+
}, onBlur: blurEditor, ref: formFieldRef, "aria-label": `${label} ${!markdownOnly && !readOnly && toolbar?.length ? 'Hit tab to edit toolbar below' : ''}`, children: _jsxs(Slate, { editor: editor, value: value, onChange: newValue => {
|
|
263
298
|
if (!disabled) {
|
|
264
299
|
setValue(newValue);
|
|
265
300
|
debouncedUpdateToolbarStyle();
|
|
@@ -272,7 +307,7 @@ const RichTextEditor = forwardRef((props, ref) => {
|
|
|
272
307
|
{
|
|
273
308
|
trigger,
|
|
274
309
|
groupId: `g${groupId}`,
|
|
275
|
-
regex: new RegExp(String.raw
|
|
310
|
+
regex: new RegExp(String.raw `(?:^|\s)(?<match>${trigger}(?<g${groupId}>${regex || String.raw `\w*`}))$`)
|
|
276
311
|
}
|
|
277
312
|
];
|
|
278
313
|
}
|
|
@@ -299,29 +334,22 @@ const RichTextEditor = forwardRef((props, ref) => {
|
|
|
299
334
|
}
|
|
300
335
|
}
|
|
301
336
|
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
blurEditor();
|
|
319
|
-
}
|
|
320
|
-
}, onBlur: blurEditor, disabled: disabled, readOnly: readOnly, onPaste: onPaste })),
|
|
321
|
-
!markdownOnly && !readOnly && (toolbar === null || toolbar === void 0 ? void 0 : toolbar.length) ? (React.createElement(Toolbar, { features: toolbar, sticky: toolbarSticky, setFocusableBtn: el => {
|
|
322
|
-
setFocusableToolbarBtn(el);
|
|
323
|
-
} })) : null),
|
|
324
|
-
React.createElement(Popover, { show: !!popoverTarget && !!menu, strategy: 'fixed', target: searchEl, placement: 'bottom-start' }, menu && (React.createElement(Menu, { ...menu, as: StyledSearchPopover, currentItemId: focusedId, mode: 'action', onItemClick: onMenuItemClick })))))));
|
|
337
|
+
}, children: [_jsxs(FormControl, { ...restProps, ref: ref, ariaLabel: label, id: id, required: required, disabled: disabled, readOnly: readOnly, status: status, as: StyledRichTextEditor, toolbar: !!(!markdownOnly && toolbar?.length), onClick: () => {
|
|
338
|
+
onEditorFocus({ focusEditor: true });
|
|
339
|
+
}, focused: ReactEditor.isFocused(editor), children: [_jsx(EditorContainer, { toolbar: !!(!markdownOnly && toolbar?.length), containerHeight: height, onClick: () => {
|
|
340
|
+
if (!disabled) {
|
|
341
|
+
onEditorFocus({ focusEditor: true });
|
|
342
|
+
}
|
|
343
|
+
}, children: _jsx(Editable, { renderElement: nodeRenderer, renderLeaf: leafRenderer, onKeyDown: onKeyDown, onKeyUp: onKeyUp, placeholder: placeholder, onFocus: event => {
|
|
344
|
+
if (!disabled) {
|
|
345
|
+
onEditorFocus({ focusEditor: true, event });
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
blurEditor();
|
|
349
|
+
}
|
|
350
|
+
}, onBlur: blurEditor, disabled: disabled, readOnly: readOnly, onPaste: onPaste }, void 0) }, void 0), !markdownOnly && !readOnly && toolbar?.length ? (_jsx(Toolbar, { features: toolbar, sticky: toolbarSticky, setFocusableBtn: el => {
|
|
351
|
+
setFocusableToolbarBtn(el);
|
|
352
|
+
} }, void 0)) : null] }, void 0), _jsx(Popover, { show: !!popoverTarget && !!menu, strategy: 'fixed', target: searchEl, placement: 'bottom-start', children: menu && (_jsx(Menu, { ...menu, as: StyledSearchPopover, currentItemId: focusedId, mode: 'action', onItemClick: onMenuItemClick }, void 0)) }, void 0)] }, void 0) }, void 0) }, void 0));
|
|
325
353
|
});
|
|
326
354
|
export default RichTextEditor;
|
|
327
355
|
//# sourceMappingURL=RichTextEditor.js.map
|