@pega/cosmos-react-social 5.0.0-dev.11.0 → 5.0.0-dev.11.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenuPopover.d.ts","sourceRoot":"","sources":["../../../src/components/Email/ContextMenuPopover.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAA+B,MAAM,OAAO,CAAC;AAS5E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE7D,QAAA,MAAM,kBAAkB,EAAE,iBAAiB,CAAC,uBAAuB,
|
|
1
|
+
{"version":3,"file":"ContextMenuPopover.d.ts","sourceRoot":"","sources":["../../../src/components/Email/ContextMenuPopover.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAA+B,MAAM,OAAO,CAAC;AAS5E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE7D,QAAA,MAAM,kBAAkB,EAAE,iBAAiB,CAAC,uBAAuB,CAwFlE,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,31 +1,39 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from 'react';
|
|
2
|
+
import { forwardRef, useEffect, useRef } from 'react';
|
|
3
3
|
import { Popover, Menu, Text, useI18n } from '@pega/cosmos-react-core';
|
|
4
4
|
import { StyledEmailMoreInfoPopover, StyledContextMenuFieldSelector, StyledContextMenu } from './Email.styles';
|
|
5
5
|
const ContextMenuPopover = forwardRef(function ContextMenuPopover({ cursorPosition, contextMenu, targetNode, show }, ref) {
|
|
6
6
|
const t = useI18n();
|
|
7
|
-
const
|
|
8
|
-
const targetElement = targetNode instanceof Element ? targetNode : targetNode?.parentElement;
|
|
9
|
-
if (targetElement && targetElement.tagName.toLowerCase() === 'mark') {
|
|
10
|
-
selection?.removeAllRanges();
|
|
11
|
-
}
|
|
12
|
-
if (selection && !selection.toString() && targetNode) {
|
|
13
|
-
const range = document.createRange();
|
|
14
|
-
range.selectNodeContents(targetNode);
|
|
15
|
-
selection?.removeAllRanges();
|
|
16
|
-
selection.addRange(range);
|
|
17
|
-
}
|
|
7
|
+
const selectedText = useRef();
|
|
18
8
|
const { onItemClick, items } = contextMenu;
|
|
19
9
|
const onItemSelect = (contextMenuItemId, e) => {
|
|
20
10
|
e.stopPropagation();
|
|
21
11
|
const selectedcontextMenuItem = items.find(({ id }) => id === contextMenuItemId);
|
|
22
|
-
if (selectedcontextMenuItem &&
|
|
12
|
+
if (selectedcontextMenuItem && selectedText.current) {
|
|
23
13
|
onItemClick({
|
|
24
14
|
fieldName: selectedcontextMenuItem.primary,
|
|
25
|
-
fieldValue:
|
|
15
|
+
fieldValue: selectedText.current
|
|
26
16
|
});
|
|
27
17
|
}
|
|
28
18
|
};
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const selection = document.getSelection();
|
|
21
|
+
if (!selection || !targetNode)
|
|
22
|
+
return;
|
|
23
|
+
const targetElement = targetNode instanceof Element ? targetNode : targetNode.parentElement;
|
|
24
|
+
if (targetElement && targetElement.tagName.toLowerCase() === 'mark') {
|
|
25
|
+
selection.removeAllRanges();
|
|
26
|
+
}
|
|
27
|
+
if (!selection.toString()) {
|
|
28
|
+
const range = document.createRange();
|
|
29
|
+
range.selectNodeContents(targetNode);
|
|
30
|
+
selection.removeAllRanges();
|
|
31
|
+
selection.addRange(range);
|
|
32
|
+
}
|
|
33
|
+
if (selection.toString()) {
|
|
34
|
+
selectedText.current = selection.toString();
|
|
35
|
+
}
|
|
36
|
+
}, [show, targetNode]);
|
|
29
37
|
const itemsToRender = items.map(item => {
|
|
30
38
|
return {
|
|
31
39
|
...item,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenuPopover.js","sourceRoot":"","sources":["../../../src/components/Email/ContextMenuPopover.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ContextMenuPopover.js","sourceRoot":"","sources":["../../../src/components/Email/ContextMenuPopover.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGtD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAEvE,OAAO,EACL,0BAA0B,EAC1B,8BAA8B,EAC9B,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AAGxB,MAAM,kBAAkB,GAA+C,UAAU,CAC/E,SAAS,kBAAkB,CACzB,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAA4C,EAC3F,GAAmC;IAEnC,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,MAAM,YAAY,GAAG,MAAM,EAAU,CAAC;IAEtC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,WAAW,CAAC;IAC3C,MAAM,YAAY,GAAG,CAAC,iBAAyB,EAAE,CAAa,EAAE,EAAE;QAChE,CAAC,CAAC,eAAe,EAAE,CAAC;QACpB,MAAM,uBAAuB,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,iBAAiB,CAAC,CAAC;QAEjF,IAAI,uBAAuB,IAAI,YAAY,CAAC,OAAO,EAAE;YACnD,WAAW,CAAC;gBACV,SAAS,EAAE,uBAAuB,CAAC,OAAO;gBAC1C,UAAU,EAAE,YAAY,CAAC,OAAO;aACjC,CAAC,CAAC;SACJ;IACH,CAAC,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,SAAS,GAAG,QAAQ,CAAC,YAAY,EAAE,CAAC;QAE1C,IAAI,CAAC,SAAS,IAAI,CAAC,UAAU;YAAE,O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AAC;oBACT,IAAI,EAAE,CAAC;oBACP,CAAC;oBACD,CAAC;oBACD,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC;iBACjB,CAAC;YACJ,CAAC;SACF,EACD,IAAI,EAAE,IAAI,EACV,SAAS,EAAC,QAAQ,EAClB,GAAG,EAAE,GAAG,YAER,KAAC,iBAAiB,cAChB,KAAC,IAAI,OACC,WAAW,EACf,MAAM,EAAE,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,YAAE,CAAC,CAAC,SAAS,CAAC,GAAQ,EAChD,KAAK,EAAE,aAAa,EACpB,WAAW,EAAE,YAAY,GACzB,GACgB,GACZ,CACX,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,kBAAkB,CAAC","sourcesContent":["import { forwardRef, useEffect, useRef } from 'react';\nimport type { FunctionComponent, MouseEvent, PropsWithoutRef } from 'react';\n\nimport { Popover, Menu, Text, useI18n } from '@pega/cosmos-react-core';\n\nimport {\n StyledEmailMoreInfoPopover,\n StyledContextMenuFieldSelector,\n StyledContextMenu\n} from './Email.styles';\nimport type { ContextMenuPopoverProps } from './Email.types';\n\nconst ContextMenuPopover: FunctionComponent<ContextMenuPopoverProps> = forwardRef(\n function ContextMenuPopover(\n { cursorPosition, contextMenu, targetNode, show }: PropsWithoutRef<ContextMenuPopoverProps>,\n ref: ContextMenuPopoverProps['ref']\n ) {\n const t = useI18n();\n const selectedText = useRef<string>();\n\n const { onItemClick, items } = contextMenu;\n const onItemSelect = (contextMenuItemId: string, e: MouseEvent) => {\n e.stopPropagation();\n const selectedcontextMenuItem = items.find(({ id }) => id === contextMenuItemId);\n\n if (selectedcontextMenuItem && selectedText.current) {\n onItemClick({\n fieldName: selectedcontextMenuItem.primary,\n fieldValue: selectedText.current\n });\n }\n };\n\n useEffect(() => {\n const selection = document.getSelection();\n\n if (!selection || !targetNode) return;\n\n const targetElement = targetNode instanceof Element ? targetNode : targetNode.parentElement;\n if (targetElement && targetElement.tagName.toLowerCase() === 'mark') {\n selection.removeAllRanges();\n }\n\n if (!selection.toString()) {\n const range = document.createRange();\n range.selectNodeContents(targetNode);\n selection.removeAllRanges();\n selection.addRange(range);\n }\n\n if (selection.toString()) {\n selectedText.current = selection.toString();\n }\n }, [show, targetNode]);\n\n const itemsToRender = items.map(item => {\n return {\n ...item,\n visual: item.selected ? (\n <StyledContextMenuFieldSelector selected />\n ) : (\n <StyledContextMenuFieldSelector />\n )\n };\n });\n\n return (\n <Popover\n as={StyledEmailMoreInfoPopover}\n target={{\n getBoundingClientRect: () => {\n const { x, y } = cursorPosition;\n return {\n width: 0,\n height: 0,\n top: y,\n right: x,\n bottom: y,\n left: x,\n x,\n y,\n toJSON: () => {}\n };\n }\n }}\n show={show}\n placement='bottom'\n ref={ref}\n >\n <StyledContextMenu>\n <Menu\n {...contextMenu}\n header={<Text variant='h5'>{t('copy_to')}</Text>}\n items={itemsToRender}\n onItemClick={onItemSelect}\n />\n </StyledContextMenu>\n </Popover>\n );\n }\n);\n\nexport default ContextMenuPopover;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pega/cosmos-react-social",
|
|
3
|
-
"version": "5.0.0-dev.11.
|
|
3
|
+
"version": "5.0.0-dev.11.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/pegasystems/cosmos-react.git",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"build": "tsc -b tsconfig.build.json"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@pega/cosmos-react-core": "5.0.0-dev.11.
|
|
25
|
-
"@pega/cosmos-react-rte": "5.0.0-dev.11.
|
|
26
|
-
"@pega/cosmos-react-work": "5.0.0-dev.11.
|
|
24
|
+
"@pega/cosmos-react-core": "5.0.0-dev.11.1",
|
|
25
|
+
"@pega/cosmos-react-rte": "5.0.0-dev.11.1",
|
|
26
|
+
"@pega/cosmos-react-work": "5.0.0-dev.11.1",
|
|
27
27
|
"@types/parse5": "^6.0.0",
|
|
28
28
|
"@types/react": "^17.0.62",
|
|
29
29
|
"@types/react-dom": "^17.0.20",
|