@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.
Files changed (82) hide show
  1. package/lib/components/RichTextEditor/DecoratorComponents/CodeBlock.d.ts.map +1 -1
  2. package/lib/components/RichTextEditor/DecoratorComponents/CodeBlock.js +3 -3
  3. package/lib/components/RichTextEditor/DecoratorComponents/CodeBlock.js.map +1 -1
  4. package/lib/components/RichTextEditor/DecoratorComponents/Image.d.ts.map +1 -1
  5. package/lib/components/RichTextEditor/DecoratorComponents/Image.js +2 -3
  6. package/lib/components/RichTextEditor/DecoratorComponents/Image.js.map +1 -1
  7. package/lib/components/RichTextEditor/DecoratorComponents/Link.d.ts.map +1 -1
  8. package/lib/components/RichTextEditor/DecoratorComponents/Link.js +2 -2
  9. package/lib/components/RichTextEditor/DecoratorComponents/Link.js.map +1 -1
  10. package/lib/components/RichTextEditor/DecoratorComponents/Table.d.ts +2 -0
  11. package/lib/components/RichTextEditor/DecoratorComponents/Table.d.ts.map +1 -1
  12. package/lib/components/RichTextEditor/DecoratorComponents/Table.js +10 -8
  13. package/lib/components/RichTextEditor/DecoratorComponents/Table.js.map +1 -1
  14. package/lib/components/RichTextEditor/RichTextEditor.context.d.ts +3 -3
  15. package/lib/components/RichTextEditor/RichTextEditor.context.d.ts.map +1 -1
  16. package/lib/components/RichTextEditor/RichTextEditor.context.js +1 -1
  17. package/lib/components/RichTextEditor/RichTextEditor.context.js.map +1 -1
  18. package/lib/components/RichTextEditor/RichTextEditor.d.ts.map +1 -1
  19. package/lib/components/RichTextEditor/RichTextEditor.js +103 -75
  20. package/lib/components/RichTextEditor/RichTextEditor.js.map +1 -1
  21. package/lib/components/RichTextEditor/RichTextEditor.styles.d.ts +3 -0
  22. package/lib/components/RichTextEditor/RichTextEditor.styles.d.ts.map +1 -1
  23. package/lib/components/RichTextEditor/RichTextEditor.styles.js +121 -51
  24. package/lib/components/RichTextEditor/RichTextEditor.styles.js.map +1 -1
  25. package/lib/components/RichTextEditor/RichTextEditor.types.d.ts +41 -13
  26. package/lib/components/RichTextEditor/RichTextEditor.types.d.ts.map +1 -1
  27. package/lib/components/RichTextEditor/RichTextEditor.types.js.map +1 -1
  28. package/lib/components/RichTextEditor/RichTextViewer.d.ts.map +1 -1
  29. package/lib/components/RichTextEditor/RichTextViewer.js +21 -12
  30. package/lib/components/RichTextEditor/RichTextViewer.js.map +1 -1
  31. package/lib/components/RichTextEditor/RichTextViewer.types.d.ts +3 -1
  32. package/lib/components/RichTextEditor/RichTextViewer.types.d.ts.map +1 -1
  33. package/lib/components/RichTextEditor/RichTextViewer.types.js.map +1 -1
  34. package/lib/components/RichTextEditor/Toolbar/AnchorButton.d.ts.map +1 -1
  35. package/lib/components/RichTextEditor/Toolbar/AnchorButton.js +50 -59
  36. package/lib/components/RichTextEditor/Toolbar/AnchorButton.js.map +1 -1
  37. package/lib/components/RichTextEditor/Toolbar/ImageButton.d.ts.map +1 -1
  38. package/lib/components/RichTextEditor/Toolbar/ImageButton.js +10 -16
  39. package/lib/components/RichTextEditor/Toolbar/ImageButton.js.map +1 -1
  40. package/lib/components/RichTextEditor/Toolbar/IndentButton.d.ts.map +1 -1
  41. package/lib/components/RichTextEditor/Toolbar/IndentButton.js +6 -4
  42. package/lib/components/RichTextEditor/Toolbar/IndentButton.js.map +1 -1
  43. package/lib/components/RichTextEditor/Toolbar/TableButton.d.ts.map +1 -1
  44. package/lib/components/RichTextEditor/Toolbar/TableButton.js +6 -5
  45. package/lib/components/RichTextEditor/Toolbar/TableButton.js.map +1 -1
  46. package/lib/components/RichTextEditor/Toolbar/TextSelect.d.ts.map +1 -1
  47. package/lib/components/RichTextEditor/Toolbar/TextSelect.js +50 -35
  48. package/lib/components/RichTextEditor/Toolbar/TextSelect.js.map +1 -1
  49. package/lib/components/RichTextEditor/Toolbar/Toolbar.d.ts.map +1 -1
  50. package/lib/components/RichTextEditor/Toolbar/Toolbar.js +18 -35
  51. package/lib/components/RichTextEditor/Toolbar/Toolbar.js.map +1 -1
  52. package/lib/components/RichTextEditor/Toolbar/ToolbarButton.d.ts.map +1 -1
  53. package/lib/components/RichTextEditor/Toolbar/ToolbarButton.js +7 -8
  54. package/lib/components/RichTextEditor/Toolbar/ToolbarButton.js.map +1 -1
  55. package/lib/components/RichTextEditor/utils/EditorCommands.d.ts +9 -1
  56. package/lib/components/RichTextEditor/utils/EditorCommands.d.ts.map +1 -1
  57. package/lib/components/RichTextEditor/utils/EditorCommands.js +130 -17
  58. package/lib/components/RichTextEditor/utils/EditorCommands.js.map +1 -1
  59. package/lib/components/RichTextEditor/utils/ListCommands.js +10 -14
  60. package/lib/components/RichTextEditor/utils/ListCommands.js.map +1 -1
  61. package/lib/components/RichTextEditor/utils/htmlConverter.d.ts +2 -1
  62. package/lib/components/RichTextEditor/utils/htmlConverter.d.ts.map +1 -1
  63. package/lib/components/RichTextEditor/utils/htmlConverter.js +67 -28
  64. package/lib/components/RichTextEditor/utils/htmlConverter.js.map +1 -1
  65. package/lib/components/RichTextEditor/utils/interactionRenderer.d.ts +12 -0
  66. package/lib/components/RichTextEditor/utils/interactionRenderer.d.ts.map +1 -0
  67. package/lib/components/RichTextEditor/utils/interactionRenderer.js +105 -0
  68. package/lib/components/RichTextEditor/utils/interactionRenderer.js.map +1 -0
  69. package/lib/components/RichTextEditor/utils/markdownConverter.d.ts +2 -0
  70. package/lib/components/RichTextEditor/utils/markdownConverter.d.ts.map +1 -1
  71. package/lib/components/RichTextEditor/utils/markdownConverter.js +30 -94
  72. package/lib/components/RichTextEditor/utils/markdownConverter.js.map +1 -1
  73. package/lib/components/RichTextEditor/utils/renderers.d.ts.map +1 -1
  74. package/lib/components/RichTextEditor/utils/renderers.js +26 -25
  75. package/lib/components/RichTextEditor/utils/renderers.js.map +1 -1
  76. package/lib/components/RichTextEditor/utils/search.d.ts.map +1 -1
  77. package/lib/components/RichTextEditor/utils/search.js +7 -3
  78. package/lib/components/RichTextEditor/utils/search.js.map +1 -1
  79. package/lib/components/RichTextEditor/utils/slateConverter.d.ts.map +1 -1
  80. package/lib/components/RichTextEditor/utils/slateConverter.js +1 -0
  81. package/lib/components/RichTextEditor/utils/slateConverter.js.map +1 -1
  82. 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,OAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAclC,QAAA,MAAM,SAAS,EAAE,EAAE,CAAC,GAAG,CAEtB,CAAC;AAEF,eAAe,SAAS,CAAC"}
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 React from 'react';
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.light};
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 React.createElement(StyledCodeBlock, { ...props });
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":"AAAA,OAAO,KAAa,MAAM,OAAO,CAAC;AAClC,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,KAAK;;;aAGpD,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,oBAAC,eAAe,OAAK,KAAK,GAAI,CAAC;AACxC,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import React, { 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.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
+ {"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,OAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AASlC,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC,GAAG,CAMvB,CAAC;AAEF,eAAe,UAAU,CAAC"}
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 React from 'react';
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 (React.createElement(Flex, { container: { alignItems: 'end' } },
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":"AAAA,OAAO,KAAa,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAOtD,MAAM,UAAU,GAAY,CAAC,KAAsB,EAAE,EAAE;IACrD,OAAO,CACL,oBAAC,IAAI,IAAC,SAAS,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QACpC,oBAAC,KAAK,IAAC,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,GAAI,CACpC,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import React, { 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
+ {"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,OAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAIlC,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC,GAAG,CAOvB,CAAC;AAEF,eAAe,UAAU,CAAC"}
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 React from 'react';
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 (React.createElement(Link, { href: url, target: '_blank' }, props.children));
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":"AAAA,OAAO,KAAa,MAAM,OAAO,CAAC;AAElC,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,oBAAC,IAAI,IAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAC,QAAQ,IAC7B,KAAK,CAAC,QAAQ,CACV,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import React, { 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
+ {"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,OAAc,EAAE,EAAE,EAAmB,MAAM,OAAO,CAAC;AAoCnD,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
+ {"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 React, { forwardRef } from 'react';
2
- import styled from 'styled-components';
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 StyledTable = styled.table `
5
+ export const getTableStyles = (theme) => css `
5
6
  border-collapse: collapse;
6
7
 
7
8
  td {
8
- border: 0.0625rem solid ${props => props.theme.base.palette['border-line']};
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 (React.createElement("tbody", { ...restProps, ref: ref }, children));
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 (React.createElement(StyledTable, { ...restProps, ref: ref }, children));
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 (React.createElement("tr", { ...restProps, ref: ref }, children));
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 (React.createElement("td", { ...restProps, ref: ref }, children));
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,KAAK,EAAE,EAAM,UAAU,EAAO,MAAM,OAAO,CAAC;AACnD,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAA;;;;8BAIF,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;CAuB7E,CAAC;AAEF,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,kCAAW,SAAS,EAAE,GAAG,EAAE,GAAG,IAC3B,QAAQ,CACH,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,oBAAC,WAAW,OAAK,SAAS,EAAE,GAAG,EAAE,GAAG,IACjC,QAAQ,CACG,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,+BAAQ,SAAS,EAAE,GAAG,EAAE,GAAG,IACxB,QAAQ,CACN,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,+BAAQ,SAAS,EAAE,GAAG,EAAE,GAAG,IACxB,QAAQ,CACN,CACN,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import React, { FC, forwardRef, Ref } from 'react';\nimport styled from 'styled-components';\n\nimport { defaultThemeProp } from '@pega/cosmos-react-core';\n\nconst StyledTable = styled.table`\n border-collapse: collapse;\n\n td {\n border: 0.0625rem solid ${props => props.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\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
+ {"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
- onImageAdded?: (image: File, id: string) => void;
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;AAE9D,MAAM,WAAW,0BAA0B;IACzC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,cAAc,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,aAAa,EAAE,CAAC,IAAI,EAAE;QACpB,KAAK,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;QAChC,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
+ {"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,6 +1,6 @@
1
1
  import { createContext, useContext } from 'react';
2
2
  export const RichTextEditorContext = createContext({
3
- onImageAdded: () => { },
3
+ addImage: () => { },
4
4
  setPopoverOpen: () => { },
5
5
  onEditorFocus: () => { },
6
6
  disabled: false
@@ -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,EAAE,MAAM,OAAO,CAAC;AAc9D,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAA6B;IAC7E,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;IACtB,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 } from 'react';\n\nexport interface RichTextEditorContextValue {\n onImageAdded?: (image: File, id: string) => void;\n setPopoverOpen: (open: boolean) => void;\n onEditorFocus: (args: {\n event?: MouseEvent | FocusEvent;\n force?: boolean;\n runAfterFocus?: () => void;\n focusEditor?: boolean;\n }) => void;\n disabled: boolean;\n}\n\nexport const RichTextEditorContext = createContext<RichTextEditorContextValue>({\n onImageAdded: () => {},\n setPopoverOpen: () => {},\n onEditorFocus: () => {},\n disabled: false\n});\n\nexport const useRTEContext = () => {\n return useContext(RichTextEditorContext);\n};\n"]}
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,OAAc,EAOZ,EAAE,EASH,MAAM,OAAO,CAAC;AAQf,OAAO,EAQL,YAAY,EAMb,MAAM,yBAAyB,CAAC;AAUjC,OAAO,EAAuB,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AA0DlF,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,GAAG,YAAY,CA+Y1D,CAAC;AAEF,eAAe,cAAc,CAAC"}
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 React, { forwardRef, useState, useRef, useMemo, useEffect, useCallback, useImperativeHandle, useReducer } from 'react';
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, useAfterInitialEffect } from '@pega/cosmos-react-core';
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 (_b = (_a = menuHelpers.getItem(menuItems, currentId)) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b[0].id;
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 (_c = menuHelpers.getParentItem(menuItems, currentId)) === null || _c === void 0 ? void 0 : _c.id;
40
+ return menuHelpers.getParentItem(menuItems, currentId)?.id;
39
41
  case 'next':
40
42
  // return next sibling of currently selected item
41
- return (_e = (_d = menuHelpers.getNextItem(menuItems, currentId)) === null || _d === void 0 ? void 0 : _d.id) !== null && _e !== void 0 ? _e : currentId;
43
+ return menuHelpers.getNextItem(menuItems, currentId)?.id ?? currentId;
42
44
  case 'prev':
43
45
  // return prev sibling of currently selected item
44
- return (_g = (_f = menuHelpers.getPrevItem(menuItems, currentId)) === null || _f === void 0 ? void 0 : _f.id) !== null && _g !== void 0 ? _g : currentId;
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 (_h = menuItems[0]) === null || _h === void 0 ? void 0 : _h.id;
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 ? (_j = menuHelpers.getItem(menuItems, selectedItemId)) === null || _j === void 0 ? void 0 : _j.id : undefined;
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 { id = useUID(), label, labelHidden, info, status, required, disabled, readOnly, onChange, onFocus, onBlur, placeholder, toolbar, onImageAdded, markdownOnly, searchTriggers, onSearch, getSearchItemReplacement, menu, height = { min: minHeight }, defaultValue, autoFocus, ...restProps } = props;
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
- var _a;
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
- ReactEditor.focus(editor);
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 === null || event === void 0 ? void 0 : event.stopPropagation();
113
+ event?.stopPropagation();
107
114
  }
108
115
  };
109
116
  const blurEditor = () => {
110
- ReactEditor.blur(editor);
111
- onBlur === null || onBlur === void 0 ? void 0 : onBlur();
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
- (_a = menu === null || menu === void 0 ? void 0 : menu.onItemClick) === null || _a === void 0 ? void 0 : _a.call(menu, itemId, e);
147
- const replacementText = getSearchItemReplacement === null || getSearchItemReplacement === void 0 ? void 0 : getSearchItemReplacement(itemId);
148
- if (replacementText) {
149
- EditorCommands.replaceWithText(editor, popoverTarget, replacementText);
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 === null || onImageAdded === void 0 ? void 0 : onImageAdded(file, placeholderId);
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 === null || onChange === void 0 ? void 0 : 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].id
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
- useAfterInitialEffect(() => {
246
- if (!menu) {
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
- React.createElement("span", { onClick: () => onEditorFocus({ focusEditor: true }) }, label), labelHidden: labelHidden, id: id, labelOrder: -1, info: info, status: status, required: required, disabled: disabled, readOnly: readOnly, onDrop: onDrop, onFocus: (e) => {
259
- if (e.target === formFieldRef.current)
260
- onEditorFocus({});
261
- }, ref: formFieldRef, "aria-label": `${label} ${!markdownOnly && !readOnly && (toolbar === null || toolbar === void 0 ? void 0 : toolbar.length) ? 'Hit tab to edit toolbar below' : ''}` },
262
- React.createElement(Slate, { editor: editor, value: value, onChange: newValue => {
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 `${trigger}(?<g${groupId}>${regex || String.raw `\w*`})$`)
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
- React.createElement(FormControl, { ...restProps, ref: ref, ariaLabel: label, id: id, required: required, disabled: disabled, readOnly: readOnly, status: status, as: StyledRichTextEditor, toolbar: !!(!markdownOnly && (toolbar === null || toolbar === void 0 ? void 0 : toolbar.length)), onClick: () => {
304
- onEditorFocus({ focusEditor: true });
305
- }, focused: ReactEditor.isFocused(editor) },
306
- React.createElement(EditorContainer, { toolbar: !!(!markdownOnly && (toolbar === null || toolbar === void 0 ? void 0 : toolbar.length)), containerHeight: height, onClick: () => {
307
- if (!disabled) {
308
- onEditorFocus({ focusEditor: true });
309
- onFocus === null || onFocus === void 0 ? void 0 : onFocus();
310
- }
311
- } },
312
- React.createElement(Editable, { renderElement: nodeRenderer, renderLeaf: leafRenderer, onKeyDown: onKeyDown, placeholder: placeholder, onFocus: () => {
313
- if (!disabled) {
314
- onEditorFocus({});
315
- onFocus === null || onFocus === void 0 ? void 0 : onFocus();
316
- }
317
- else {
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