@pega/cosmos-react-demos 5.0.0-dev.10.5 → 5.0.0-dev.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/jsx/core/RadioButtonGroup/RadioButtonGroup.stories.d.ts +3 -0
  2. package/jsx/core/RadioButtonGroup/RadioButtonGroup.stories.d.ts.map +1 -1
  3. package/jsx/core/RadioButtonGroup/RadioButtonGroup.stories.jsx +2 -2
  4. package/jsx/core/RadioButtonGroup/RadioButtonGroup.stories.jsx.map +1 -1
  5. package/jsx/rte/Editor/Editor.stories.d.ts.map +1 -1
  6. package/jsx/rte/Editor/Editor.stories.jsx +14 -1
  7. package/jsx/rte/Editor/Editor.stories.jsx.map +1 -1
  8. package/jsx/rte/RichTextEditor/RichTextEditor.stories.d.ts +1 -0
  9. package/jsx/rte/RichTextEditor/RichTextEditor.stories.d.ts.map +1 -1
  10. package/jsx/rte/RichTextEditor/RichTextEditor.stories.jsx +67 -4
  11. package/jsx/rte/RichTextEditor/RichTextEditor.stories.jsx.map +1 -1
  12. package/jsx/rte/RichTextEditor/RichTextViewer.stories.d.ts +8 -3
  13. package/jsx/rte/RichTextEditor/RichTextViewer.stories.d.ts.map +1 -1
  14. package/jsx/rte/RichTextEditor/RichTextViewer.stories.jsx +67 -12
  15. package/jsx/rte/RichTextEditor/RichTextViewer.stories.jsx.map +1 -1
  16. package/jsx/social/Chat/Chat.mocks.js +1 -1
  17. package/jsx/social/Chat/Chat.mocks.js.map +1 -1
  18. package/jsx/work/CaseView/CaseView.mocks.d.ts +4 -2
  19. package/jsx/work/CaseView/CaseView.mocks.d.ts.map +1 -1
  20. package/jsx/work/CaseView/CaseView.mocks.jsx +4 -3
  21. package/jsx/work/CaseView/CaseView.mocks.jsx.map +1 -1
  22. package/jsx/work/Stakeholders/Stakeholders.stories.d.ts +4 -1
  23. package/jsx/work/Stakeholders/Stakeholders.stories.d.ts.map +1 -1
  24. package/jsx/work/Stakeholders/Stakeholders.stories.jsx +14 -6
  25. package/jsx/work/Stakeholders/Stakeholders.stories.jsx.map +1 -1
  26. package/lib/core/RadioButtonGroup/RadioButtonGroup.stories.d.ts +3 -0
  27. package/lib/core/RadioButtonGroup/RadioButtonGroup.stories.d.ts.map +1 -1
  28. package/lib/core/RadioButtonGroup/RadioButtonGroup.stories.js +2 -2
  29. package/lib/core/RadioButtonGroup/RadioButtonGroup.stories.js.map +1 -1
  30. package/lib/rte/Editor/Editor.stories.d.ts.map +1 -1
  31. package/lib/rte/Editor/Editor.stories.js +8 -1
  32. package/lib/rte/Editor/Editor.stories.js.map +1 -1
  33. package/lib/rte/RichTextEditor/RichTextEditor.stories.d.ts +1 -0
  34. package/lib/rte/RichTextEditor/RichTextEditor.stories.d.ts.map +1 -1
  35. package/lib/rte/RichTextEditor/RichTextEditor.stories.js +37 -5
  36. package/lib/rte/RichTextEditor/RichTextEditor.stories.js.map +1 -1
  37. package/lib/rte/RichTextEditor/RichTextViewer.stories.d.ts +8 -3
  38. package/lib/rte/RichTextEditor/RichTextViewer.stories.d.ts.map +1 -1
  39. package/lib/rte/RichTextEditor/RichTextViewer.stories.js +66 -11
  40. package/lib/rte/RichTextEditor/RichTextViewer.stories.js.map +1 -1
  41. package/lib/social/Chat/Chat.mocks.js +1 -1
  42. package/lib/social/Chat/Chat.mocks.js.map +1 -1
  43. package/lib/work/CaseView/CaseView.mocks.d.ts +4 -2
  44. package/lib/work/CaseView/CaseView.mocks.d.ts.map +1 -1
  45. package/lib/work/CaseView/CaseView.mocks.js +4 -3
  46. package/lib/work/CaseView/CaseView.mocks.js.map +1 -1
  47. package/lib/work/Stakeholders/Stakeholders.stories.d.ts +4 -1
  48. package/lib/work/Stakeholders/Stakeholders.stories.d.ts.map +1 -1
  49. package/lib/work/Stakeholders/Stakeholders.stories.js +14 -6
  50. package/lib/work/Stakeholders/Stakeholders.stories.js.map +1 -1
  51. package/package.json +7 -7
@@ -1,10 +1,13 @@
1
1
  import type { StoryFn } from '@storybook/react';
2
+ import type { FocusEventHandler, MouseEventHandler } from 'react';
2
3
  import type { RadioCheckGroupProps, OmitStrict } from '@pega/cosmos-react-core';
3
4
  declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
4
5
  export default _default;
5
6
  interface RadioCheckGroupStoryProps extends RadioCheckGroupProps {
6
7
  showAdditionalInfo?: boolean;
7
8
  showNestedAdditionalInfo?: boolean;
9
+ onBlur?: FocusEventHandler<HTMLInputElement>;
10
+ onClick?: MouseEventHandler<HTMLInputElement>;
8
11
  }
9
12
  export declare const RadioButtonGroupDemo: StoryFn<OmitStrict<RadioCheckGroupStoryProps, 'children'>>;
10
13
  export declare const RadioButtonCardGroup: StoryFn<OmitStrict<RadioCheckGroupStoryProps, 'children'>>;
@@ -1 +1 @@
1
- {"version":3,"file":"RadioButtonGroup.stories.d.ts","sourceRoot":"","sources":["../../../src/core/RadioButtonGroup/RadioButtonGroup.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAUtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;;AAIhF,wBA6BU;AAEV,UAAU,yBAA0B,SAAQ,oBAAoB;IAC9D,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC;AAED,eAAO,MAAM,oBAAoB,EAAE,OAAO,CAAC,UAAU,CAAC,yBAAyB,EAAE,UAAU,CAAC,CA+E3F,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,OAAO,CAAC,UAAU,CAAC,yBAAyB,EAAE,UAAU,CAAC,CAsF3F,CAAC"}
1
+ {"version":3,"file":"RadioButtonGroup.stories.d.ts","sourceRoot":"","sources":["../../../src/core/RadioButtonGroup/RadioButtonGroup.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAUlE,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;;AAIhF,wBA6BU;AAEV,UAAU,yBAA0B,SAAQ,oBAAoB;IAC9D,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,MAAM,CAAC,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IAC7C,OAAO,CAAC,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;CAC/C;AAED,eAAO,MAAM,oBAAoB,EAAE,OAAO,CAAC,UAAU,CAAC,yBAAyB,EAAE,UAAU,CAAC,CAmF3F,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,OAAO,CAAC,UAAU,CAAC,yBAAyB,EAAE,UAAU,CAAC,CAsF3F,CAAC"}
@@ -35,7 +35,7 @@ export const RadioButtonGroupDemo = (args) => {
35
35
  ? {
36
36
  content: 'Some additional info'
37
37
  }
38
- : undefined} label={args.label} name='Fruit' labelHidden={args.labelHidden} inline={args.inline} autoStack={args.autoStack} required={args.required} disabled={args.disabled} readOnly={args.readOnly} status={args.status} info={args.info}>
38
+ : undefined} label={args.label} name='Fruit' labelHidden={args.labelHidden} inline={args.inline} autoStack={args.autoStack} required={args.required} disabled={args.disabled} readOnly={args.readOnly} status={args.status} info={args.info} onClick={args.onClick} onBlur={args.onBlur}>
39
39
  <RadioButton label='Banana' id='Banana' defaultChecked additionalInfo={{
40
40
  content: 'Some additional info'
41
41
  }}/>
@@ -52,7 +52,7 @@ export const RadioButtonGroupDemo = (args) => {
52
52
  ? {
53
53
  content: 'Some additional info'
54
54
  }
55
- : undefined} label={args.label} name='Fruit' labelHidden={args.labelHidden} inline={args.inline} autoStack={args.autoStack} required={args.required} disabled={args.disabled} readOnly={args.readOnly} status={args.status} info={args.info}>
55
+ : undefined} label={args.label} name='Fruit' labelHidden={args.labelHidden} inline={args.inline} autoStack={args.autoStack} required={args.required} disabled={args.disabled} readOnly={args.readOnly} status={args.status} info={args.info} onClick={args.onClick} onBlur={args.onBlur}>
56
56
  <RadioButton label='Banana' id='Banana' defaultChecked/>
57
57
  <RadioButton label='Apple' id='Apple'/>
58
58
  <RadioButton label='Mango' id='Mango'/>
@@ -1 +1 @@
1
- {"version":3,"file":"RadioButtonGroup.stories.jsx","sourceRoot":"","sources":["../../../src/core/RadioButtonGroup/RadioButtonGroup.stories.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EACV,cAAc,EACd,IAAI,EACJ,WAAW,EACX,gBAAgB,EAChB,IAAI,EACL,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAEnE,eAAe;IACb,KAAK,EAAE,uBAAuB;IAC9B,SAAS,EAAE,gBAAgB;IAC3B,IAAI,EAAE;QACJ,KAAK,EAAE,0BAA0B;QACjC,WAAW,EAAE,KAAK;QAClB,MAAM,EAAE,KAAK;QACb,SAAS,EAAE,IAAI;QACf,QAAQ,EAAE,KAAK;QACf,QAAQ,EAAE,KAAK;QACf,QAAQ,EAAE,KAAK;QACf,kBAAkB,EAAE,KAAK;QACzB,wBAAwB,EAAE,KAAK;QAC/B,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,oBAAoB;KAC3B;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;QACpC,WAAW,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;QAC7C,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;QACxC,SAAS,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,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,UAAU,CAAC,IAAI,CAClD;YAAA,CAAC,cAAc,CACb,MAAM,CAAC,CAAC;gBACN,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,QAAQ,EAAE;gBAC1D,EAAE,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,EAAE;gBAC9D,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE;aAC7D,CAAC,EAEN;UAAA,EAAE,UAAU,CAAC,CACd,CACD,EAAE,CAAC,YAAY,EAEnB;IAAA,EAAE,gBAAgB,CAAC,CACpB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { Meta, StoryFn } from '@storybook/react';\n\nimport {\n FieldGroup,\n FieldValueList,\n Flex,\n RadioButton,\n RadioButtonGroup,\n Text\n} from '@pega/cosmos-react-core';\nimport type { RadioCheckGroupProps, OmitStrict } from '@pega/cosmos-react-core';\n\nimport { Paragraph, StyledImage } from './RadioButtonGroup.styles';\n\nexport default {\n title: 'Core/RadioButtonGroup',\n component: RadioButtonGroup,\n args: {\n label: 'What do you want to eat?',\n labelHidden: false,\n inline: false,\n autoStack: true,\n required: false,\n disabled: false,\n readOnly: false,\n showAdditionalInfo: false,\n showNestedAdditionalInfo: false,\n status: undefined,\n info: 'You must select it'\n },\n argTypes: {\n label: { control: { type: 'text' } },\n labelHidden: { control: { type: 'boolean' } },\n inline: { control: { type: 'boolean' } },\n autoStack: { control: { type: 'boolean' } },\n required: { control: { type: 'boolean' } },\n disabled: { control: { type: 'boolean' } },\n readOnly: { control: { type: 'boolean' } },\n showAdditionalInfo: { control: { type: 'boolean' } },\n showNestedAdditionalInfo: { control: { type: 'boolean' } },\n status: { options: [undefined, 'success', 'warning', 'error'], control: { type: 'select' } },\n info: { control: { type: 'text', label: 'Helper text' } }\n }\n} as Meta;\n\ninterface RadioCheckGroupStoryProps extends RadioCheckGroupProps {\n showAdditionalInfo?: boolean;\n showNestedAdditionalInfo?: boolean;\n}\n\nexport const RadioButtonGroupDemo: StoryFn<OmitStrict<RadioCheckGroupStoryProps, 'children'>> = (\n args: OmitStrict<RadioCheckGroupStoryProps, 'children'>\n) => {\n return args.showNestedAdditionalInfo ? (\n <RadioButtonGroup\n additionalInfo={\n args.showAdditionalInfo\n ? {\n content: 'Some additional info'\n }\n : undefined\n }\n label={args.label}\n name='Fruit'\n labelHidden={args.labelHidden}\n inline={args.inline}\n autoStack={args.autoStack}\n required={args.required}\n disabled={args.disabled}\n readOnly={args.readOnly}\n status={args.status}\n info={args.info}\n >\n <RadioButton\n label='Banana'\n id='Banana'\n defaultChecked\n additionalInfo={{\n content: 'Some additional info'\n }}\n />\n <RadioButton\n label='Apple'\n id='Apple'\n additionalInfo={{\n content: 'Some additional info'\n }}\n />\n <RadioButton\n label='Mango'\n id='Mango'\n additionalInfo={{\n content: 'Some additional info'\n }}\n />\n <RadioButton\n label='Orange'\n id='Orange'\n additionalInfo={{\n content: 'Some additional info'\n }}\n />\n </RadioButtonGroup>\n ) : (\n <RadioButtonGroup\n additionalInfo={\n args.showAdditionalInfo\n ? {\n content: 'Some additional info'\n }\n : undefined\n }\n label={args.label}\n name='Fruit'\n labelHidden={args.labelHidden}\n inline={args.inline}\n autoStack={args.autoStack}\n required={args.required}\n disabled={args.disabled}\n readOnly={args.readOnly}\n status={args.status}\n info={args.info}\n >\n <RadioButton label='Banana' id='Banana' defaultChecked />\n <RadioButton label='Apple' id='Apple' />\n <RadioButton label='Mango' id='Mango' />\n <RadioButton label='Orange' id='Orange' />\n </RadioButtonGroup>\n );\n};\n\nexport const RadioButtonCardGroup: StoryFn<OmitStrict<RadioCheckGroupStoryProps, 'children'>> = (\n args: OmitStrict<RadioCheckGroupStoryProps, 'children'>\n) => {\n return (\n <RadioButtonGroup\n additionalInfo={\n args.showAdditionalInfo\n ? {\n content: 'Some additional info'\n }\n : undefined\n }\n variant='card'\n label='Which visuals appear satisfying?'\n labelHidden={args.labelHidden}\n inline={args.inline}\n autoStack={args.autoStack}\n required={args.required}\n disabled={args.disabled}\n readOnly={args.readOnly}\n >\n <RadioButton\n additionalInfo={\n args.showNestedAdditionalInfo\n ? {\n content: 'Some additional info'\n }\n : undefined\n }\n label={\n <Flex container={{ direction: 'column', gap: 1 }}>\n <Text variant='h4'>A paragraph</Text>\n <Paragraph>\n This is a paragraph of text. It is meant to appear visually satisfying amongst the\n other options in this group.\n </Paragraph>\n </Flex>\n }\n id='paragraph'\n defaultChecked\n />\n <RadioButton\n label={\n <Flex container={{ direction: 'column', gap: 1 }}>\n <Text variant='h4'>Space</Text>\n <StyledImage\n src='https://thumbor.forbes.com/thumbor/960x0/https%3A%2F%2Fspecials-images.forbesimg.com%2Fdam%2Fimageserve%2F765877054%2F960x0.jpg%3Ffit%3Dscale'\n alt='space'\n />\n </Flex>\n }\n id='space-photo'\n />\n <RadioButton\n label={\n <Flex container={{ gap: 1, alignItems: 'start' }}>\n <StyledImage\n src='https://thumbor.forbes.com/thumbor/960x0/https%3A%2F%2Fspecials-images.forbesimg.com%2Fdam%2Fimageserve%2F765877054%2F960x0.jpg%3Ffit%3Dscale'\n alt='space'\n />\n <Flex container={{ direction: 'column', gap: 1 }}>\n <Text variant='h4'>Space</Text>\n <Paragraph>\n Space is the final frontier. There is so much to discover within Constellation!\n </Paragraph>\n </Flex>\n </Flex>\n }\n id='cosmos'\n />\n <RadioButton\n label={\n <FieldGroup name='Gold service plan' headingTag='h3'>\n <FieldValueList\n fields={[\n { id: 'service', name: 'Service length', value: '1 year' },\n { id: 'monthly-cost', name: 'Monthly cost', value: '$180.00' },\n { id: 'total-cost', name: 'Total cost', value: '$2,160.00' }\n ]}\n />\n </FieldGroup>\n }\n id='phone-plan'\n />\n </RadioButtonGroup>\n );\n};\n"]}
1
+ {"version":3,"file":"RadioButtonGroup.stories.jsx","sourceRoot":"","sources":["../../../src/core/RadioButtonGroup/RadioButtonGroup.stories.tsx"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AE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,EAAE;gBAC9D,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE;aAC7D,CAAC,EAEN;UAAA,EAAE,UAAU,CAAC,CACd,CACD,EAAE,CAAC,YAAY,EAEnB;IAAA,EAAE,gBAAgB,CAAC,CACpB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { Meta, StoryFn } from '@storybook/react';\nimport type { FocusEventHandler, MouseEventHandler } from 'react';\n\nimport {\n FieldGroup,\n FieldValueList,\n Flex,\n RadioButton,\n RadioButtonGroup,\n Text\n} from '@pega/cosmos-react-core';\nimport type { RadioCheckGroupProps, OmitStrict } from '@pega/cosmos-react-core';\n\nimport { Paragraph, StyledImage } from './RadioButtonGroup.styles';\n\nexport default {\n title: 'Core/RadioButtonGroup',\n component: RadioButtonGroup,\n args: {\n label: 'What do you want to eat?',\n labelHidden: false,\n inline: false,\n autoStack: true,\n required: false,\n disabled: false,\n readOnly: false,\n showAdditionalInfo: false,\n showNestedAdditionalInfo: false,\n status: undefined,\n info: 'You must select it'\n },\n argTypes: {\n label: { control: { type: 'text' } },\n labelHidden: { control: { type: 'boolean' } },\n inline: { control: { type: 'boolean' } },\n autoStack: { control: { type: 'boolean' } },\n required: { control: { type: 'boolean' } },\n disabled: { control: { type: 'boolean' } },\n readOnly: { control: { type: 'boolean' } },\n showAdditionalInfo: { control: { type: 'boolean' } },\n showNestedAdditionalInfo: { control: { type: 'boolean' } },\n status: { options: [undefined, 'success', 'warning', 'error'], control: { type: 'select' } },\n info: { control: { type: 'text', label: 'Helper text' } }\n }\n} as Meta;\n\ninterface RadioCheckGroupStoryProps extends RadioCheckGroupProps {\n showAdditionalInfo?: boolean;\n showNestedAdditionalInfo?: boolean;\n onBlur?: FocusEventHandler<HTMLInputElement>;\n onClick?: MouseEventHandler<HTMLInputElement>;\n}\n\nexport const RadioButtonGroupDemo: StoryFn<OmitStrict<RadioCheckGroupStoryProps, 'children'>> = (\n args: OmitStrict<RadioCheckGroupStoryProps, 'children'>\n) => {\n return args.showNestedAdditionalInfo ? (\n <RadioButtonGroup\n additionalInfo={\n args.showAdditionalInfo\n ? {\n content: 'Some additional info'\n }\n : undefined\n }\n label={args.label}\n name='Fruit'\n labelHidden={args.labelHidden}\n inline={args.inline}\n autoStack={args.autoStack}\n required={args.required}\n disabled={args.disabled}\n readOnly={args.readOnly}\n status={args.status}\n info={args.info}\n onClick={args.onClick}\n onBlur={args.onBlur}\n >\n <RadioButton\n label='Banana'\n id='Banana'\n defaultChecked\n additionalInfo={{\n content: 'Some additional info'\n }}\n />\n <RadioButton\n label='Apple'\n id='Apple'\n additionalInfo={{\n content: 'Some additional info'\n }}\n />\n <RadioButton\n label='Mango'\n id='Mango'\n additionalInfo={{\n content: 'Some additional info'\n }}\n />\n <RadioButton\n label='Orange'\n id='Orange'\n additionalInfo={{\n content: 'Some additional info'\n }}\n />\n </RadioButtonGroup>\n ) : (\n <RadioButtonGroup\n additionalInfo={\n args.showAdditionalInfo\n ? {\n content: 'Some additional info'\n }\n : undefined\n }\n label={args.label}\n name='Fruit'\n labelHidden={args.labelHidden}\n inline={args.inline}\n autoStack={args.autoStack}\n required={args.required}\n disabled={args.disabled}\n readOnly={args.readOnly}\n status={args.status}\n info={args.info}\n onClick={args.onClick}\n onBlur={args.onBlur}\n >\n <RadioButton label='Banana' id='Banana' defaultChecked />\n <RadioButton label='Apple' id='Apple' />\n <RadioButton label='Mango' id='Mango' />\n <RadioButton label='Orange' id='Orange' />\n </RadioButtonGroup>\n );\n};\n\nexport const RadioButtonCardGroup: StoryFn<OmitStrict<RadioCheckGroupStoryProps, 'children'>> = (\n args: OmitStrict<RadioCheckGroupStoryProps, 'children'>\n) => {\n return (\n <RadioButtonGroup\n additionalInfo={\n args.showAdditionalInfo\n ? {\n content: 'Some additional info'\n }\n : undefined\n }\n variant='card'\n label='Which visuals appear satisfying?'\n labelHidden={args.labelHidden}\n inline={args.inline}\n autoStack={args.autoStack}\n required={args.required}\n disabled={args.disabled}\n readOnly={args.readOnly}\n >\n <RadioButton\n additionalInfo={\n args.showNestedAdditionalInfo\n ? {\n content: 'Some additional info'\n }\n : undefined\n }\n label={\n <Flex container={{ direction: 'column', gap: 1 }}>\n <Text variant='h4'>A paragraph</Text>\n <Paragraph>\n This is a paragraph of text. It is meant to appear visually satisfying amongst the\n other options in this group.\n </Paragraph>\n </Flex>\n }\n id='paragraph'\n defaultChecked\n />\n <RadioButton\n label={\n <Flex container={{ direction: 'column', gap: 1 }}>\n <Text variant='h4'>Space</Text>\n <StyledImage\n src='https://thumbor.forbes.com/thumbor/960x0/https%3A%2F%2Fspecials-images.forbesimg.com%2Fdam%2Fimageserve%2F765877054%2F960x0.jpg%3Ffit%3Dscale'\n alt='space'\n />\n </Flex>\n }\n id='space-photo'\n />\n <RadioButton\n label={\n <Flex container={{ gap: 1, alignItems: 'start' }}>\n <StyledImage\n src='https://thumbor.forbes.com/thumbor/960x0/https%3A%2F%2Fspecials-images.forbesimg.com%2Fdam%2Fimageserve%2F765877054%2F960x0.jpg%3Ffit%3Dscale'\n alt='space'\n />\n <Flex container={{ direction: 'column', gap: 1 }}>\n <Text variant='h4'>Space</Text>\n <Paragraph>\n Space is the final frontier. There is so much to discover within Constellation!\n </Paragraph>\n </Flex>\n </Flex>\n }\n id='cosmos'\n />\n <RadioButton\n label={\n <FieldGroup name='Gold service plan' headingTag='h3'>\n <FieldValueList\n fields={[\n { id: 'service', name: 'Service length', value: '1 year' },\n { id: 'monthly-cost', name: 'Monthly cost', value: '$180.00' },\n { id: 'total-cost', name: 'Total cost', value: '$2,160.00' }\n ]}\n />\n </FieldGroup>\n }\n id='phone-plan'\n />\n </RadioButtonGroup>\n );\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Editor.stories.d.ts","sourceRoot":"","sources":["../../../src/rte/Editor/Editor.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAgBtD,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,wBAAwB,CAAC;;AAIvE,wBAGU;AAEV,UAAU,gBAAiB,SAAQ,WAAW;IAC5C,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,eAAO,MAAM,UAAU,EAAE,OAAO,CAAC,gBAAgB,CAwDhD,CAAC;AA2BF,eAAO,MAAM,eAAe,EAAE,OAmB7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,OAc/B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,OA6BjC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,OAkCpC,CAAC;AAEF,eAAO,MAAM,6BAA6B,EAAE,OA8B3C,CAAC"}
1
+ {"version":3,"file":"Editor.stories.d.ts","sourceRoot":"","sources":["../../../src/rte/Editor/Editor.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAgBtD,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,wBAAwB,CAAC;;AAIvE,wBAGU;AAEV,UAAU,gBAAiB,SAAQ,WAAW;IAC5C,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,eAAO,MAAM,UAAU,EAAE,OAAO,CAAC,gBAAgB,CAwDhD,CAAC;AA2BF,eAAO,MAAM,eAAe,EAAE,OAmB7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,OAc/B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,OA6BjC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,OAoDpC,CAAC;AAEF,eAAO,MAAM,6BAA6B,EAAE,OA8B3C,CAAC"}
@@ -114,12 +114,25 @@ export const RichTextEditorWithLogs = () => {
114
114
  <Editor ref={editorRef} toolbar={['inline-styling', 'headers', 'tables', 'links', 'images', 'lists', 'indentation']} onImageAdded={onImageAdded} label='Rich text editor with logs' info='Click on the buttons below to show the different formatted outputs of the RTE'/>
115
115
 
116
116
  <Flex container={{ gap: 1 }}>
117
+ <Button onClick={() => editorRef.current?.focus()}>Focus</Button>
117
118
  <Button onClick={() => showContent('html')}>Show HTML</Button>
118
119
  <Button onClick={() => showContent('plain_text')}>Show plain text</Button>
119
120
  <Button onClick={() => showContent('rich_text')}>Show rich text</Button>
121
+ <Button onClick={() => editorRef.current?.insertText('Some text')}>Insert text</Button>
122
+ <Button onClick={() => editorRef.current?.clear()}>Clear</Button>
123
+ <Button onClick={() => {
124
+ const clipboardData = new DataTransfer();
125
+ clipboardData.setData('text/html', '<img src="https://www.pega.com/themes/custom/pegawww_theme/images/pega-logo.svg" alt="Pega" />');
126
+ const clipboardEvent = new ClipboardEvent('paste', {
127
+ clipboardData
128
+ });
129
+ editorRef.current?.getEditor()?.dispatch('paste', clipboardEvent);
130
+ }}>
131
+ Paste image
132
+ </Button>
120
133
  </Flex>
121
134
 
122
- <Text>{content}</Text>
135
+ <Text data-testid='textRegion'>{content}</Text>
123
136
  </Flex>);
124
137
  };
125
138
  export const RichTextEditorHtmlParsingDemo = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"Editor.stories.jsx","sourceRoot":"","sources":["../../../src/rte/Editor/Editor.stories.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAGlD,OAAO,EACL,MAAM,EACN,IAAI,EACJ,WAAW,EACX,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,QAAQ,EACT,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAGhD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,eAAe;IACb,KAAK,EAAE,YAAY;IACnB,SAAS,EAAE,MAAM;CACV,CAAC;AAMV,MAA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CAAC,IAAI,CAAC,CACnB,YAAY,CAAC,CAAC,YAAY,CAAC,CAC3B,GAAG,CAAC,CAAC,MAAM,CAAC,CACZ,KAAK,CAAC,kBAAkB,CACxB,OAAO,CAAC,CAAC,CAAC,gBAAgB,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,EAEhG;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { Meta, StoryFn } from '@storybook/react';\nimport { useState, useRef } from 'react';\nimport { action } from '@storybook/addon-actions';\nimport type { Editor as TinymceEditor } from 'tinymce';\n\nimport {\n Button,\n Card,\n CardContent,\n CardFooter,\n Flex,\n Link,\n Text,\n TextArea\n} from '@pega/cosmos-react-core';\nimport { Editor } from '@pega/cosmos-react-rte';\nimport type { EditorProps, EditorState } from '@pega/cosmos-react-rte';\n\nimport { createPegaCustomElement } from './Editor.mocks';\n\nexport default {\n title: 'RTE/Editor',\n component: Editor\n} as Meta;\n\ninterface EditorStoryProps extends EditorProps {\n showAdditionalInfo?: boolean;\n}\n\nexport const EditorDemo: StoryFn<EditorStoryProps> = (args: EditorStoryProps) => {\n const editorRef = useRef<EditorState>(null);\n\n const onImageAdded = (image: File, id: string) => {\n const src = URL.createObjectURL(image);\n editorRef.current?.appendImage(\n {\n src,\n alt: image.name,\n attachmentId: 'sample-id'\n },\n id\n );\n };\n\n return (\n <Editor\n ref={editorRef}\n label={args.label}\n labelHidden={args.labelHidden}\n info={args.info}\n status={args.status}\n required={args.required}\n disabled={args.disabled}\n readOnly={args.readOnly}\n toolbar={['inline-styling', 'lists', 'indentation', 'images', 'links']}\n onFocus={action('Editor focused')}\n onBlur={action('Editor blurred')}\n onChange={action('Editor changed')}\n onImageAdded={onImageAdded}\n defaultValue='<body><p>Hi mom <a href=\"https://google.com\">link</a></p><img alt=\"Example alt text\" src=\"http://via.placeholder.com/640x360\"/></body>'\n additionalInfo={\n args.showAdditionalInfo\n ? {\n content: (\n <Flex container={{ direction: 'column', alignItems: 'start', gap: 2 }}>\n <p>\n Lorem ipsum dolor sit amet, consectetur it, sed do tempor incididunt ut labore\n magna aliqua. Nibh praesent tristique magna sit amet. Nec tincidunt praesent\n semper feugiat nibh sed pulvinar proin gravida.\n </p>\n <p>\n Pharetra pharetra massa massa ultricies mi quis hendrerit dolor. Est velit\n egestas dui id ornare arcu odio ut. Varius sit amet mattis vulputate enim nulla\n aliquet porttitor lacus.\n </p>\n <Link href='/' target='_blank'>\n Neque vitae\n </Link>\n </Flex>\n )\n }\n : undefined\n }\n />\n );\n};\n\nEditorDemo.args = {\n showAdditionalInfo: false,\n label: 'Form field label',\n labelHidden: false,\n info: 'Enter some value',\n status: undefined,\n required: false,\n disabled: false,\n readOnly: false\n};\n\nEditorDemo.argTypes = {\n showAdditionalInfo: { control: { type: 'boolean' } },\n label: { control: { type: 'text' } },\n labelHidden: { control: { type: 'boolean' } },\n info: { control: { type: 'text', label: 'Helper text' } },\n status: {\n options: [undefined, 'success', 'warning', 'error', 'pending'],\n control: { type: 'select' }\n },\n required: { control: { type: 'boolean' } },\n disabled: { control: { type: 'boolean' } },\n readOnly: { control: { type: 'boolean' } }\n};\n\nexport const EmptyEditorDemo: StoryFn = () => {\n const editorRef = useRef<EditorState>(null);\n\n const onImageAdded = (image: File, id: string) => {\n const src = URL.createObjectURL(image);\n editorRef.current?.appendImage({ src, alt: image.name }, id);\n };\n\n return (\n <Editor\n ref={editorRef}\n label='Form field label'\n toolbar={['inline-styling', 'lists', 'indentation', 'images', 'links']}\n onImageAdded={onImageAdded}\n onFocus={action('Editor has focus')}\n onBlur={action('Editor has blurred')}\n placeholder='Type some stuff in here'\n />\n );\n};\n\nexport const ReadonlyFormField: StoryFn = () => {\n return (\n <Editor\n label='Form field label'\n readOnly\n defaultValue={`<article class=\"main-page-content\" lang=\"en-US\"><h1>HTML: HyperText Markup Language</h1><div><p><strong>HTML</strong> (HyperText Markup Language) is the most basic building block of the Web. It defines the meaning and structure of web content. Other technologies besides HTML are generally used to describe a web page's appearance/presentation (<a href=\"/en-US/docs/Web/CSS\">CSS</a>) or functionality/behavior (<a href=\"/en-US/docs/Web/JavaScript\">JavaScript</a>).</p>\n <p>\"Hypertext\" refers to links that connect web pages to one another, either within a single website or between websites. Links are a fundamental aspect of the Web. By uploading content to the Internet and linking it to pages created by other people, you become an active participant in the World Wide Web.</p>\n <p>HTML uses \"markup\" to annotate text, images, and other content for display in a Web browser. HTML markup includes special \"elements\" such as <a href=\"/en-US/docs/Web/HTML/Element/head\"><code>&lt;head&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/title\"><code>&lt;title&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/body\"><code>&lt;body&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/header\"><code>&lt;header&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/footer\"><code>&lt;footer&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/article\"><code>&lt;article&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/section\"><code>&lt;section&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/p\"><code>&lt;p&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/div\"><code>&lt;div&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/span\"><code>&lt;span&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/img\"><code>&lt;img&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/aside\"><code>&lt;aside&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/audio\"><code>&lt;audio&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/canvas\"><code>&lt;canvas&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/datalist\"><code>&lt;datalist&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/details\"><code>&lt;details&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/embed\"><code>&lt;embed&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/nav\"><code>&lt;nav&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/output\"><code>&lt;output&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/progress\"><code>&lt;progress&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/video\"><code>&lt;video&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/ul\"><code>&lt;ul&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/ol\"><code>&lt;ol&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/li\"><code>&lt;li&gt;</code></a> and many others.</p>\n <p>An HTML element is set off from other text in a document by \"tags\", which consist of the element name surrounded by \"<code>&lt;</code>\" and \"<code>&gt;</code>\".&nbsp; The name of an element inside a tag is case insensitive. That is, it can be written in uppercase, lowercase, or a mixture. For example, the <code>&lt;title&gt;</code> tag can be written as <code>&lt;Title&gt;</code>, <code>&lt;TITLE&gt;</code>, or in any other way.</p>\n\n <div id=\"on-github\" class=\"on-github\"><h3>Found a problem with this page?</h3><ul><li><a href=\"https://github.com/mdn/content/edit/main/files/en-us/web/html/index.md\" title=\"You're going to need to sign in to GitHub first (Opens in a new tab)\" target=\"_blank\" rel=\"noopener noreferrer\">Edit on <b>GitHub</b></a></li><li><a href=\"https://github.com/mdn/content/blob/main/files/en-us/web/html/index.md\" title=\"Folder: en-us/web/html (Opens in a new tab)\" target=\"_blank\" rel=\"noopener noreferrer\">Source on <b>GitHub</b></a></li><li><a href=\"https://github.com/mdn/content/issues/new?body=MDN+URL%3A+https%3A%2F%2Fdeveloper.mozilla.org%2Fen-US%2Fdocs%2FWeb%2FHTML%0A%0A%23%23%23%23+What+information+was+incorrect%2C+unhelpful%2C+or+incomplete%3F%0A%0A%0A%23%23%23%23+Specific+section+or+headline%3F%0A%0A%0A%23%23%23%23+What+did+you+expect+to+see%3F%0A%0A%0A%23%23%23%23+Did+you+test+this%3F+If+so%2C+how%3F%0A%0A%0A%3C%21--+Do+not+make+changes+below+this+line+--%3E%0A%3Cdetails%3E%0A%3Csummary%3EMDN+Content+page+report+details%3C%2Fsummary%3E%0A%0A*+Folder%3A+%60en-us%2Fweb%2Fhtml%60%0A*+MDN+URL%3A+https%3A%2F%2Fdeveloper.mozilla.org%2Fen-US%2Fdocs%2FWeb%2FHTML%0A*+GitHub+URL%3A+https%3A%2F%2Fgithub.com%2Fmdn%2Fcontent%2Fblob%2Fmain%2Ffiles%2Fen-us%2Fweb%2Fhtml%2Findex.md%0A*+Last+commit%3A+https%3A%2F%2Fgithub.com%2Fmdn%2Fcontent%2Fcommit%2F775662998e66813a612e3ff27e02f2ada867bc17%0A*+Document+last+modified%3A+2021-10-03T00%3A01%3A51.000Z%0A%0A%3C%2Fdetails%3E&amp;title=Issue+with+%22HTML%3A+HyperText+Markup+Language%22%3A+%28short+summary+here+please%29&amp;labels=needs-triage%2CContent%3AHTML\" title=\"This will take you to https://github.com/mdn/content to file a new issue\" target=\"_blank\" rel=\"noopener noreferrer\">Report a problem with this content on <b>GitHub</b></a></li><li>Want to fix the problem yourself? See <a href=\"https://github.com/mdn/content/blob/main/README.md\" target=\"_blank\" rel=\"noopener noreferrer\">our Contribution guide</a>.</li></ul></div>\n `}\n />\n );\n};\n\nexport const CustomComponentDemo: StoryFn = () => {\n const editorRef = useRef<EditorState>(null);\n const [editor, setEditor] = useState({} as TinymceEditor);\n\n const onCustomAction = () => {\n editor.insertContent('<pega-custom>Inserted from toolbar</pega-custom>');\n };\n\n return (\n <Editor\n ref={editorRef}\n label='Form field label'\n toolbar={['inline-styling', 'lists', 'indentation', 'links', 'images']}\n defaultValue='<body><p>Hi mom <a href=\"https://google.com\">link</a></p><p>hi <pega-custom>Hello from custom element.</pega-custom></p></body>'\n customComponents={[{ createCustomElement: createPegaCustomElement, name: 'pega-custom' }]}\n customActions={[\n {\n icon: 'pega',\n text: 'Insert a custom element',\n onMouseDown: () => {\n onCustomAction();\n }\n }\n ]}\n onInit={initializedEditor => {\n setEditor(initializedEditor);\n }}\n />\n );\n};\n\nexport const RichTextEditorWithLogs: StoryFn = () => {\n const editorRef = useRef<EditorState>(null);\n const [content, setContent] = useState<string | undefined>();\n\n const onImageAdded = (image: File, id: string) => {\n const src = URL.createObjectURL(image);\n editorRef.current?.appendImage({ src, alt: image.name }, id);\n };\n\n const showContent = (type: 'html' | 'plain_text' | 'rich_text') => {\n if (type === 'html') setContent(editorRef.current?.getHtml());\n else if (type === 'plain_text') setContent(editorRef.current?.getPlainText());\n else if (type === 'rich_text') setContent(editorRef.current?.getRichText());\n };\n\n return (\n <Flex container={{ direction: 'column', gap: 2 }}>\n <Editor\n ref={editorRef}\n toolbar={['inline-styling', 'headers', 'tables', 'links', 'images', 'lists', 'indentation']}\n onImageAdded={onImageAdded}\n label='Rich text editor with logs'\n info='Click on the buttons below to show the different formatted outputs of the RTE'\n />\n\n <Flex container={{ gap: 1 }}>\n <Button onClick={() => showContent('html')}>Show HTML</Button>\n <Button onClick={() => showContent('plain_text')}>Show plain text</Button>\n <Button onClick={() => showContent('rich_text')}>Show rich text</Button>\n </Flex>\n\n <Text>{content}</Text>\n </Flex>\n );\n};\n\nexport const RichTextEditorHtmlParsingDemo: StoryFn = () => {\n const [html, setHtml] = useState('<p>Hello world!</p>');\n const rteRef = useRef<EditorState>(null);\n\n const onImageAdded = (image: File, id: string) => {\n const src = URL.createObjectURL(image);\n rteRef.current?.appendImage({ src, alt: image.name }, id);\n };\n\n return (\n <Flex container={{ direction: 'column', gap: 2 }}>\n <Card>\n <CardContent>\n <TextArea value={html} onChange={e => setHtml(e.target.value)} />\n </CardContent>\n <CardFooter>\n <Button onClick={() => rteRef.current?.insertHtml(html.trim(), true)}>\n Overwrite RTE with new HTML\n </Button>\n </CardFooter>\n </Card>\n <Editor\n defaultValue={html}\n onImageAdded={onImageAdded}\n ref={rteRef}\n label='Form field label'\n toolbar={['inline-styling', 'headers', 'tables', 'links', 'images', 'lists', 'indentation']}\n />\n </Flex>\n );\n};\n"]}
1
+ {"version":3,"file":"Editor.stories.jsx","sourceRoot":"","sources":["../../../src/rte/Editor/Editor.stories.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAGlD,OAAO,EACL,MAAM,EACN,IAAI,EACJ,WAAW,EACX,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,QAAQ,EACT,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAGhD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,eAAe;IACb,KAAK,EAAE,YAAY;IACnB,SAAS,EAAE,MAAM;CACV,CAAC;AAMV,MAAM,CAAC,MAAM,UAAU,GAA8B,CAAC,IAAsB,EAAE,EAAE;IAC9E,MAAM,SAAS,GAAG,MAAM,CAAc,IAAI,CAAC,CAAC;IAE5C,MAAM,YAAY,GAAG,CAAC,KAAW,EAAE,EAAU,EAAE,EAAE;QAC/C,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QACvC,SAAS,CAAC,OAAO,EAAE,WAAW,CAC5B;YACE,GAAG;YACH,GAAG,EAAE,KAAK,CAAC,IAAI;YACf,YAAY,EAAE,WAAW;SAC1B,EACD,EAAE,CACH,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CACL,CAAC,MAAM,CACL,GAAG,CAAC,CAAC,SAAS,CAAC,CACf,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAClB,WAAW,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAC9B,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAChB,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CACpB,QAAQ,CAAC,CAAC,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AAE,EAAE,IAAI,CAAC,CAAC,CACnE;;UACF,EAAE,MAAM,CACV;QAAA,EAAE,UAAU,CACd;MAAA,EAAE,IAAI,CACN;MAAA,CAAC,MAAM,CACL,YAAY,CAAC,CAAC,IAAI,CAAC,CACnB,YAAY,CAAC,CAAC,YAAY,CAAC,CAC3B,GAAG,CAAC,CAAC,MAAM,CAAC,CACZ,KAAK,CAAC,kBAAkB,CACxB,OAAO,CAAC,CAAC,CAAC,gBAAgB,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,EAEhG;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { Meta, StoryFn } from '@storybook/react';\nimport { useState, useRef } from 'react';\nimport { action } from '@storybook/addon-actions';\nimport type { Editor as TinymceEditor } from 'tinymce';\n\nimport {\n Button,\n Card,\n CardContent,\n CardFooter,\n Flex,\n Link,\n Text,\n TextArea\n} from '@pega/cosmos-react-core';\nimport { Editor } from '@pega/cosmos-react-rte';\nimport type { EditorProps, EditorState } from '@pega/cosmos-react-rte';\n\nimport { createPegaCustomElement } from './Editor.mocks';\n\nexport default {\n title: 'RTE/Editor',\n component: Editor\n} as Meta;\n\ninterface EditorStoryProps extends EditorProps {\n showAdditionalInfo?: boolean;\n}\n\nexport const EditorDemo: StoryFn<EditorStoryProps> = (args: EditorStoryProps) => {\n const editorRef = useRef<EditorState>(null);\n\n const onImageAdded = (image: File, id: string) => {\n const src = URL.createObjectURL(image);\n editorRef.current?.appendImage(\n {\n src,\n alt: image.name,\n attachmentId: 'sample-id'\n },\n id\n );\n };\n\n return (\n <Editor\n ref={editorRef}\n label={args.label}\n labelHidden={args.labelHidden}\n info={args.info}\n status={args.status}\n required={args.required}\n disabled={args.disabled}\n readOnly={args.readOnly}\n toolbar={['inline-styling', 'lists', 'indentation', 'images', 'links']}\n onFocus={action('Editor focused')}\n onBlur={action('Editor blurred')}\n onChange={action('Editor changed')}\n onImageAdded={onImageAdded}\n defaultValue='<body><p>Hi mom <a href=\"https://google.com\">link</a></p><img alt=\"Example alt text\" src=\"http://via.placeholder.com/640x360\"/></body>'\n additionalInfo={\n args.showAdditionalInfo\n ? {\n content: (\n <Flex container={{ direction: 'column', alignItems: 'start', gap: 2 }}>\n <p>\n Lorem ipsum dolor sit amet, consectetur it, sed do tempor incididunt ut labore\n magna aliqua. Nibh praesent tristique magna sit amet. Nec tincidunt praesent\n semper feugiat nibh sed pulvinar proin gravida.\n </p>\n <p>\n Pharetra pharetra massa massa ultricies mi quis hendrerit dolor. Est velit\n egestas dui id ornare arcu odio ut. Varius sit amet mattis vulputate enim nulla\n aliquet porttitor lacus.\n </p>\n <Link href='/' target='_blank'>\n Neque vitae\n </Link>\n </Flex>\n )\n }\n : undefined\n }\n />\n );\n};\n\nEditorDemo.args = {\n showAdditionalInfo: false,\n label: 'Form field label',\n labelHidden: false,\n info: 'Enter some value',\n status: undefined,\n required: false,\n disabled: false,\n readOnly: false\n};\n\nEditorDemo.argTypes = {\n showAdditionalInfo: { control: { type: 'boolean' } },\n label: { control: { type: 'text' } },\n labelHidden: { control: { type: 'boolean' } },\n info: { control: { type: 'text', label: 'Helper text' } },\n status: {\n options: [undefined, 'success', 'warning', 'error', 'pending'],\n control: { type: 'select' }\n },\n required: { control: { type: 'boolean' } },\n disabled: { control: { type: 'boolean' } },\n readOnly: { control: { type: 'boolean' } }\n};\n\nexport const EmptyEditorDemo: StoryFn = () => {\n const editorRef = useRef<EditorState>(null);\n\n const onImageAdded = (image: File, id: string) => {\n const src = URL.createObjectURL(image);\n editorRef.current?.appendImage({ src, alt: image.name }, id);\n };\n\n return (\n <Editor\n ref={editorRef}\n label='Form field label'\n toolbar={['inline-styling', 'lists', 'indentation', 'images', 'links']}\n onImageAdded={onImageAdded}\n onFocus={action('Editor has focus')}\n onBlur={action('Editor has blurred')}\n placeholder='Type some stuff in here'\n />\n );\n};\n\nexport const ReadonlyFormField: StoryFn = () => {\n return (\n <Editor\n label='Form field label'\n readOnly\n defaultValue={`<article class=\"main-page-content\" lang=\"en-US\"><h1>HTML: HyperText Markup Language</h1><div><p><strong>HTML</strong> (HyperText Markup Language) is the most basic building block of the Web. It defines the meaning and structure of web content. Other technologies besides HTML are generally used to describe a web page's appearance/presentation (<a href=\"/en-US/docs/Web/CSS\">CSS</a>) or functionality/behavior (<a href=\"/en-US/docs/Web/JavaScript\">JavaScript</a>).</p>\n <p>\"Hypertext\" refers to links that connect web pages to one another, either within a single website or between websites. Links are a fundamental aspect of the Web. By uploading content to the Internet and linking it to pages created by other people, you become an active participant in the World Wide Web.</p>\n <p>HTML uses \"markup\" to annotate text, images, and other content for display in a Web browser. HTML markup includes special \"elements\" such as <a href=\"/en-US/docs/Web/HTML/Element/head\"><code>&lt;head&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/title\"><code>&lt;title&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/body\"><code>&lt;body&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/header\"><code>&lt;header&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/footer\"><code>&lt;footer&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/article\"><code>&lt;article&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/section\"><code>&lt;section&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/p\"><code>&lt;p&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/div\"><code>&lt;div&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/span\"><code>&lt;span&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/img\"><code>&lt;img&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/aside\"><code>&lt;aside&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/audio\"><code>&lt;audio&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/canvas\"><code>&lt;canvas&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/datalist\"><code>&lt;datalist&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/details\"><code>&lt;details&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/embed\"><code>&lt;embed&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/nav\"><code>&lt;nav&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/output\"><code>&lt;output&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/progress\"><code>&lt;progress&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/video\"><code>&lt;video&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/ul\"><code>&lt;ul&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/ol\"><code>&lt;ol&gt;</code></a>, <a href=\"/en-US/docs/Web/HTML/Element/li\"><code>&lt;li&gt;</code></a> and many others.</p>\n <p>An HTML element is set off from other text in a document by \"tags\", which consist of the element name surrounded by \"<code>&lt;</code>\" and \"<code>&gt;</code>\".&nbsp; The name of an element inside a tag is case insensitive. That is, it can be written in uppercase, lowercase, or a mixture. For example, the <code>&lt;title&gt;</code> tag can be written as <code>&lt;Title&gt;</code>, <code>&lt;TITLE&gt;</code>, or in any other way.</p>\n\n <div id=\"on-github\" class=\"on-github\"><h3>Found a problem with this page?</h3><ul><li><a href=\"https://github.com/mdn/content/edit/main/files/en-us/web/html/index.md\" title=\"You're going to need to sign in to GitHub first (Opens in a new tab)\" target=\"_blank\" rel=\"noopener noreferrer\">Edit on <b>GitHub</b></a></li><li><a href=\"https://github.com/mdn/content/blob/main/files/en-us/web/html/index.md\" title=\"Folder: en-us/web/html (Opens in a new tab)\" target=\"_blank\" rel=\"noopener noreferrer\">Source on <b>GitHub</b></a></li><li><a href=\"https://github.com/mdn/content/issues/new?body=MDN+URL%3A+https%3A%2F%2Fdeveloper.mozilla.org%2Fen-US%2Fdocs%2FWeb%2FHTML%0A%0A%23%23%23%23+What+information+was+incorrect%2C+unhelpful%2C+or+incomplete%3F%0A%0A%0A%23%23%23%23+Specific+section+or+headline%3F%0A%0A%0A%23%23%23%23+What+did+you+expect+to+see%3F%0A%0A%0A%23%23%23%23+Did+you+test+this%3F+If+so%2C+how%3F%0A%0A%0A%3C%21--+Do+not+make+changes+below+this+line+--%3E%0A%3Cdetails%3E%0A%3Csummary%3EMDN+Content+page+report+details%3C%2Fsummary%3E%0A%0A*+Folder%3A+%60en-us%2Fweb%2Fhtml%60%0A*+MDN+URL%3A+https%3A%2F%2Fdeveloper.mozilla.org%2Fen-US%2Fdocs%2FWeb%2FHTML%0A*+GitHub+URL%3A+https%3A%2F%2Fgithub.com%2Fmdn%2Fcontent%2Fblob%2Fmain%2Ffiles%2Fen-us%2Fweb%2Fhtml%2Findex.md%0A*+Last+commit%3A+https%3A%2F%2Fgithub.com%2Fmdn%2Fcontent%2Fcommit%2F775662998e66813a612e3ff27e02f2ada867bc17%0A*+Document+last+modified%3A+2021-10-03T00%3A01%3A51.000Z%0A%0A%3C%2Fdetails%3E&amp;title=Issue+with+%22HTML%3A+HyperText+Markup+Language%22%3A+%28short+summary+here+please%29&amp;labels=needs-triage%2CContent%3AHTML\" title=\"This will take you to https://github.com/mdn/content to file a new issue\" target=\"_blank\" rel=\"noopener noreferrer\">Report a problem with this content on <b>GitHub</b></a></li><li>Want to fix the problem yourself? See <a href=\"https://github.com/mdn/content/blob/main/README.md\" target=\"_blank\" rel=\"noopener noreferrer\">our Contribution guide</a>.</li></ul></div>\n `}\n />\n );\n};\n\nexport const CustomComponentDemo: StoryFn = () => {\n const editorRef = useRef<EditorState>(null);\n const [editor, setEditor] = useState({} as TinymceEditor);\n\n const onCustomAction = () => {\n editor.insertContent('<pega-custom>Inserted from toolbar</pega-custom>');\n };\n\n return (\n <Editor\n ref={editorRef}\n label='Form field label'\n toolbar={['inline-styling', 'lists', 'indentation', 'links', 'images']}\n defaultValue='<body><p>Hi mom <a href=\"https://google.com\">link</a></p><p>hi <pega-custom>Hello from custom element.</pega-custom></p></body>'\n customComponents={[{ createCustomElement: createPegaCustomElement, name: 'pega-custom' }]}\n customActions={[\n {\n icon: 'pega',\n text: 'Insert a custom element',\n onMouseDown: () => {\n onCustomAction();\n }\n }\n ]}\n onInit={initializedEditor => {\n setEditor(initializedEditor);\n }}\n />\n );\n};\n\nexport const RichTextEditorWithLogs: StoryFn = () => {\n const editorRef = useRef<EditorState>(null);\n const [content, setContent] = useState<string | undefined>();\n\n const onImageAdded = (image: File, id: string) => {\n const src = URL.createObjectURL(image);\n editorRef.current?.appendImage({ src, alt: image.name }, id);\n };\n\n const showContent = (type: 'html' | 'plain_text' | 'rich_text') => {\n if (type === 'html') setContent(editorRef.current?.getHtml());\n else if (type === 'plain_text') setContent(editorRef.current?.getPlainText());\n else if (type === 'rich_text') setContent(editorRef.current?.getRichText());\n };\n\n return (\n <Flex container={{ direction: 'column', gap: 2 }}>\n <Editor\n ref={editorRef}\n toolbar={['inline-styling', 'headers', 'tables', 'links', 'images', 'lists', 'indentation']}\n onImageAdded={onImageAdded}\n label='Rich text editor with logs'\n info='Click on the buttons below to show the different formatted outputs of the RTE'\n />\n\n <Flex container={{ gap: 1 }}>\n <Button onClick={() => editorRef.current?.focus()}>Focus</Button>\n <Button onClick={() => showContent('html')}>Show HTML</Button>\n <Button onClick={() => showContent('plain_text')}>Show plain text</Button>\n <Button onClick={() => showContent('rich_text')}>Show rich text</Button>\n <Button onClick={() => editorRef.current?.insertText('Some text')}>Insert text</Button>\n <Button onClick={() => editorRef.current?.clear()}>Clear</Button>\n <Button\n onClick={() => {\n const clipboardData = new DataTransfer();\n clipboardData.setData(\n 'text/html',\n '<img src=\"https://www.pega.com/themes/custom/pegawww_theme/images/pega-logo.svg\" alt=\"Pega\" />'\n );\n const clipboardEvent = new ClipboardEvent('paste', {\n clipboardData\n });\n editorRef.current?.getEditor()?.dispatch('paste', clipboardEvent);\n }}\n >\n Paste image\n </Button>\n </Flex>\n\n <Text data-testid='textRegion'>{content}</Text>\n </Flex>\n );\n};\n\nexport const RichTextEditorHtmlParsingDemo: StoryFn = () => {\n const [html, setHtml] = useState('<p>Hello world!</p>');\n const rteRef = useRef<EditorState>(null);\n\n const onImageAdded = (image: File, id: string) => {\n const src = URL.createObjectURL(image);\n rteRef.current?.appendImage({ src, alt: image.name }, id);\n };\n\n return (\n <Flex container={{ direction: 'column', gap: 2 }}>\n <Card>\n <CardContent>\n <TextArea value={html} onChange={e => setHtml(e.target.value)} />\n </CardContent>\n <CardFooter>\n <Button onClick={() => rteRef.current?.insertHtml(html.trim(), true)}>\n Overwrite RTE with new HTML\n </Button>\n </CardFooter>\n </Card>\n <Editor\n defaultValue={html}\n onImageAdded={onImageAdded}\n ref={rteRef}\n label='Form field label'\n toolbar={['inline-styling', 'headers', 'tables', 'links', 'images', 'lists', 'indentation']}\n />\n </Flex>\n );\n};\n"]}
@@ -3,4 +3,5 @@ import type { RichTextEditorProps } from '@pega/cosmos-react-rte';
3
3
  declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
4
4
  export default _default;
5
5
  export declare const RichTextEditorMDDemo: StoryFn<RichTextEditorProps>;
6
+ export declare const RichTextEditorImperativeHandleDemo: StoryFn;
6
7
  //# sourceMappingURL=RichTextEditor.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RichTextEditor.stories.d.ts","sourceRoot":"","sources":["../../../src/rte/RichTextEditor/RichTextEditor.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAKtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;;AAIlE,wBAqBU;AAEV,eAAO,MAAM,oBAAoB,EAAE,OAAO,CAAC,mBAAmB,CAsC7D,CAAC"}
1
+ {"version":3,"file":"RichTextEditor.stories.d.ts","sourceRoot":"","sources":["../../../src/rte/RichTextEditor/RichTextEditor.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAKtD,OAAO,KAAK,EAAE,mBAAmB,EAAuB,MAAM,wBAAwB,CAAC;;AAKvF,wBAsBU;AAEV,eAAO,MAAM,oBAAoB,EAAE,OAAO,CAAC,mBAAmB,CA6C7D,CAAC;AAEF,eAAO,MAAM,kCAAkC,EAAE,OA0FhD,CAAC"}
@@ -1,5 +1,7 @@
1
- import { useState } from 'react';
1
+ import { useRef, useState } from 'react';
2
+ import { Button, Flex } from '@pega/cosmos-react-core';
2
3
  import { RichTextEditor } from '@pega/cosmos-react-rte';
4
+ import { MentionButton } from '@pega/cosmos-react-social';
3
5
  import { demoUsers } from './RichTextEditor.mocks';
4
6
  export default {
5
7
  title: 'RTE/RichTextEditor',
@@ -7,7 +9,7 @@ export default {
7
9
  args: {
8
10
  label: 'Rich text editor',
9
11
  labelHidden: false,
10
- info: 'The rich text editor can be used in forms, comments, and documents',
12
+ info: 'The markdown editor offers dynamic rendering of markdown syntax',
11
13
  status: undefined,
12
14
  required: false,
13
15
  disabled: false,
@@ -38,8 +40,69 @@ export const RichTextEditorMDDemo = (args) => {
38
40
  return undefined;
39
41
  return {
40
42
  markdown: `@${item.id}:${item.primary}:user:`,
41
- text: item.primary
43
+ text: item.primary,
44
+ component: MentionButton,
45
+ props: {
46
+ id: item.id,
47
+ text: item.primary,
48
+ type: 'user'
49
+ }
42
50
  };
43
- }} menu={users.length ? { items: users } : undefined} markdownOnly label={args.label} labelHidden={args.labelHidden} info={args.info} status={args.status} required={args.required} disabled={args.disabled} readOnly={args.readOnly}/>);
51
+ }} menu={users.length ? { items: users } : undefined} markdownOnly label={args.label} labelHidden={args.labelHidden} info={args.info} status={args.status} required={args.required} disabled={args.disabled} readOnly={args.readOnly} autoFocus/>);
52
+ };
53
+ export const RichTextEditorImperativeHandleDemo = () => {
54
+ const rteRef = useRef(null);
55
+ const [textContent, setTextContent] = useState('');
56
+ return (<>
57
+ <RichTextEditor ref={rteRef} type='html' toolbar={['headers', 'inline-styling', 'indentation', 'lists']} defaultValue='Hello, World! '/>
58
+ <Flex container={{ gap: 1, pad: 1 }}>
59
+ <Button data-testid='focusHandle' onClick={() => {
60
+ rteRef.current?.focus();
61
+ }}>
62
+ Focus
63
+ </Button>
64
+ <Button data-testid='plainTextHandle' onClick={() => {
65
+ setTextContent(rteRef.current?.getPlainText() || '');
66
+ }}>
67
+ Get plain text
68
+ </Button>
69
+ <Button data-testid='richTextHandle' onClick={() => {
70
+ setTextContent(rteRef.current?.getRichText() || '');
71
+ }}>
72
+ Get rich text
73
+ </Button>
74
+ <Button data-testid='htmlHandle' onClick={() => {
75
+ setTextContent(rteRef.current?.getHtml() || '');
76
+ }}>
77
+ Get HTML
78
+ </Button>
79
+ <Button data-testid='clearHandle' onClick={() => {
80
+ rteRef.current?.clear();
81
+ }}>
82
+ Clear
83
+ </Button>
84
+ <Button data-testid='insertTextHandle' onClick={() => {
85
+ rteRef.current?.insertText('Some text');
86
+ }}>
87
+ Insert text
88
+ </Button>
89
+ <Button data-testid='insertHTMLHandle' onClick={() => {
90
+ rteRef.current?.insertHtml('Some text', true);
91
+ }}>
92
+ Insert HTML
93
+ </Button>
94
+ <Button data-testid='appendHTMLHandle' onClick={() => {
95
+ rteRef.current?.insertHtml('Some text', false);
96
+ }}>
97
+ Append HTML
98
+ </Button>
99
+ <Button data-testid='insertEmptyHTMLHandle' onClick={() => {
100
+ rteRef.current?.insertHtml('', true);
101
+ }}>
102
+ Insert empty HTML
103
+ </Button>
104
+ </Flex>
105
+ <div data-testid='textRegion'>{textContent}</div>
106
+ </>);
44
107
  };
45
108
  //# sourceMappingURL=RichTextEditor.stories.jsx.map
@@ -1 +1 @@
1
- {"version":3,"file":"RichTextEditor.stories.jsx","sourceRoot":"","sources":["../../../src/rte/RichTextEditor/RichTextEditor.stories.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAG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ACxB,QAAQ,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,EACxB,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { Meta, StoryFn } from '@storybook/react';\nimport { useState } from 'react';\n\nimport type { MenuItemProps } from '@pega/cosmos-react-core';\nimport { RichTextEditor } from '@pega/cosmos-react-rte';\nimport type { RichTextEditorProps } from '@pega/cosmos-react-rte';\n\nimport { demoUsers } from './RichTextEditor.mocks';\n\nexport default {\n title: 'RTE/RichTextEditor',\n component: RichTextEditor,\n args: {\n label: 'Rich text editor',\n labelHidden: false,\n info: 'The rich text editor can be used in forms, comments, and documents',\n status: undefined,\n required: false,\n disabled: false,\n readOnly: false\n },\n argTypes: {\n label: { control: { type: 'text' } },\n labelHidden: { control: { type: 'boolean' } },\n info: { control: { type: 'text', label: 'Helper text' } },\n status: { options: [undefined, 'success', 'warning', 'error'], control: { type: 'select' } },\n required: { control: { type: 'boolean' } },\n disabled: { control: { type: 'boolean' } },\n readOnly: { control: { type: 'boolean' } }\n }\n} as Meta;\n\nexport const RichTextEditorMDDemo: StoryFn<RichTextEditorProps> = (args: RichTextEditorProps) => {\n const [users, setUsers] = useState<MenuItemProps[]>(demoUsers);\n\n const searchUsers = (event: { search: string; trigger: string }) => {\n if (event.trigger === '@') {\n setUsers(\n demoUsers.filter(user => {\n return user.primary.toLowerCase().includes(event.search.toLowerCase());\n })\n );\n }\n };\n\n return (\n <RichTextEditor\n searchTriggers={[{ trigger: '@', regex: '[a-zA-Z]*(?: [a-zA-Z]*)?' }]}\n onSearch={searchUsers}\n getSearchItemReplacement={(id: string) => {\n const item = demoUsers.find(({ id: itemId }) => itemId === id);\n\n if (!item) return undefined;\n\n return {\n markdown: `@${item.id}:${item.primary}:user:`,\n text: item.primary\n };\n }}\n menu={users.length ? { items: users } : undefined}\n markdownOnly\n label={args.label}\n labelHidden={args.labelHidden}\n info={args.info}\n status={args.status}\n required={args.required}\n disabled={args.disabled}\n readOnly={args.readOnly}\n />\n );\n};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GAAG,EAAE;YACZ,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACjD,CAAC,CAAC,CAEF;;QACF,EAAE,MAAM,CACR;QAAA,CAAC,MAAM,CACL,WAAW,CAAC,uBAAuB,CACnC,OAAO,CAAC,CAAC,GAAG,EAAE;YACZ,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QACvC,CAAC,CAAC,CAEF;;QACF,EAAE,MAAM,CACV;MAAA,EAAE,IAAI,CACN;MAAA,CAAC,GAAG,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,WAAW,CAAC,EAAE,GAAG,CAClD;IAAA,GAAG,CACJ,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { Meta, StoryFn } from '@storybook/react';\nimport { useRef, useState } from 'react';\n\nimport { Button, Flex, type MenuItemProps } from '@pega/cosmos-react-core';\nimport { RichTextEditor } from '@pega/cosmos-react-rte';\nimport type { RichTextEditorProps, RichTextEditorState } from '@pega/cosmos-react-rte';\nimport { MentionButton } from '@pega/cosmos-react-social';\n\nimport { demoUsers } from './RichTextEditor.mocks';\n\nexport default {\n title: 'RTE/RichTextEditor',\n component: RichTextEditor,\n args: {\n label: 'Rich text editor',\n labelHidden: false,\n info: 'The markdown editor offers dynamic rendering of markdown syntax',\n status: undefined,\n required: false,\n disabled: false,\n readOnly: false\n },\n argTypes: {\n label: { control: { type: 'text' } },\n labelHidden: { control: { type: 'boolean' } },\n info: { control: { type: 'text', label: 'Helper text' } },\n status: { options: [undefined, 'success', 'warning', 'error'], control: { type: 'select' } },\n required: { control: { type: 'boolean' } },\n disabled: { control: { type: 'boolean' } },\n readOnly: { control: { type: 'boolean' } }\n }\n // excludeStories: ['RichTextEditorImperativeHandleDemo']\n} as Meta;\n\nexport const RichTextEditorMDDemo: StoryFn<RichTextEditorProps> = (args: RichTextEditorProps) => {\n const [users, setUsers] = useState<MenuItemProps[]>(demoUsers);\n\n const searchUsers = (event: { search: string; trigger: string }) => {\n if (event.trigger === '@') {\n setUsers(\n demoUsers.filter(user => {\n return user.primary.toLowerCase().includes(event.search.toLowerCase());\n })\n );\n }\n };\n\n return (\n <RichTextEditor\n searchTriggers={[{ trigger: '@', regex: '[a-zA-Z]*(?: [a-zA-Z]*)?' }]}\n onSearch={searchUsers}\n getSearchItemReplacement={(id: string) => {\n const item = demoUsers.find(({ id: itemId }) => itemId === id);\n\n if (!item) return undefined;\n\n return {\n markdown: `@${item.id}:${item.primary}:user:`,\n text: item.primary,\n component: MentionButton,\n props: {\n id: item.id,\n text: item.primary,\n type: 'user'\n }\n };\n }}\n menu={users.length ? { items: users } : undefined}\n markdownOnly\n label={args.label}\n labelHidden={args.labelHidden}\n info={args.info}\n status={args.status}\n required={args.required}\n disabled={args.disabled}\n readOnly={args.readOnly}\n autoFocus\n />\n );\n};\n\nexport const RichTextEditorImperativeHandleDemo: StoryFn = () => {\n const rteRef = useRef<RichTextEditorState>(null);\n\n const [textContent, setTextContent] = useState('');\n\n return (\n <>\n <RichTextEditor\n ref={rteRef}\n type='html'\n toolbar={['headers', 'inline-styling', 'indentation', 'lists']}\n defaultValue='Hello, World! '\n />\n <Flex container={{ gap: 1, pad: 1 }}>\n <Button\n data-testid='focusHandle'\n onClick={() => {\n rteRef.current?.focus();\n }}\n >\n Focus\n </Button>\n <Button\n data-testid='plainTextHandle'\n onClick={() => {\n setTextContent(rteRef.current?.getPlainText() || '');\n }}\n >\n Get plain text\n </Button>\n <Button\n data-testid='richTextHandle'\n onClick={() => {\n setTextContent(rteRef.current?.getRichText() || '');\n }}\n >\n Get rich text\n </Button>\n <Button\n data-testid='htmlHandle'\n onClick={() => {\n setTextContent(rteRef.current?.getHtml() || '');\n }}\n >\n Get HTML\n </Button>\n <Button\n data-testid='clearHandle'\n onClick={() => {\n rteRef.current?.clear();\n }}\n >\n Clear\n </Button>\n <Button\n data-testid='insertTextHandle'\n onClick={() => {\n rteRef.current?.insertText('Some text');\n }}\n >\n Insert text\n </Button>\n <Button\n data-testid='insertHTMLHandle'\n onClick={() => {\n rteRef.current?.insertHtml('Some text', true);\n }}\n >\n Insert HTML\n </Button>\n <Button\n data-testid='appendHTMLHandle'\n onClick={() => {\n rteRef.current?.insertHtml('Some text', false);\n }}\n >\n Append HTML\n </Button>\n <Button\n data-testid='insertEmptyHTMLHandle'\n onClick={() => {\n rteRef.current?.insertHtml('', true);\n }}\n >\n Insert empty HTML\n </Button>\n </Flex>\n <div data-testid='textRegion'>{textContent}</div>\n </>\n );\n};\n"]}
@@ -1,8 +1,13 @@
1
1
  import type { StoryFn } from '@storybook/react';
2
+ import type { RichTextViewerProps } from '@pega/cosmos-react-rte';
2
3
  declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
3
4
  export default _default;
4
- export declare const RichTextViewerDemo: StoryFn;
5
- export declare const RichTextViewerHTMLDemo: StoryFn;
5
+ interface RichTextViewerDemoProps {
6
+ content?: RichTextViewerProps['content'];
7
+ interactionRenderers?: boolean;
8
+ }
9
+ export declare const RichTextViewerDemo: StoryFn<RichTextViewerDemoProps>;
10
+ export declare const RichTextViewerHTMLDemo: StoryFn<RichTextViewerDemoProps>;
6
11
  export declare const RichTextViewerHTMLOverflowDemo: StoryFn;
7
- export declare const RichTextViewerMDDemo: StoryFn;
12
+ export declare const RichTextViewerMDDemo: StoryFn<RichTextViewerDemoProps>;
8
13
  //# sourceMappingURL=RichTextViewer.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RichTextViewer.stories.d.ts","sourceRoot":"","sources":["../../../src/rte/RichTextEditor/RichTextViewer.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,OAAO,EAAE,MAAM,kBAAkB,CAAC;;AAWtD,wBAGU;AAEV,eAAO,MAAM,kBAAkB,EAAE,OAuBhC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,OAuBpC,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,OA0B5C,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,OA2DlC,CAAC"}
1
+ {"version":3,"file":"RichTextViewer.stories.d.ts","sourceRoot":"","sources":["../../../src/rte/RichTextEditor/RichTextViewer.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAOtD,OAAO,KAAK,EAAuB,mBAAmB,EAAY,MAAM,wBAAwB,CAAC;;AAIjG,wBAWU;AAEV,UAAU,uBAAuB;IAC/B,OAAO,CAAC,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;IACzC,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,eAAO,MAAM,kBAAkB,EAAE,OAAO,CAAC,uBAAuB,CAyB/D,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,OAAO,CAAC,uBAAuB,CAsCnE,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,OA0B5C,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,OAAO,CAAC,uBAAuB,CAuGjE,CAAC"}
@@ -1,13 +1,21 @@
1
1
  import { useRef, useState } from 'react';
2
2
  import { Flex, Link } from '@pega/cosmos-react-core';
3
3
  import { HashtagButtonConfig, MentionButtonConfig } from '@pega/cosmos-react-social';
4
- import { RichTextViewer, RichTextEditor } from '@pega/cosmos-react-rte';
4
+ import { RichTextViewer, RichTextEditor, getXMLAttributes } from '@pega/cosmos-react-rte';
5
5
  import { demoUsers } from './RichTextEditor.mocks';
6
6
  export default {
7
7
  title: 'RTE/RichTextViewer',
8
- component: RichTextViewer
8
+ component: RichTextViewer,
9
+ args: {
10
+ content: undefined,
11
+ interactionRenderers: false
12
+ },
13
+ argTypes: {
14
+ content: { control: { type: 'text' }, table: { disable: true } },
15
+ interactionRenderers: { control: { type: 'boolean' } }
16
+ }
9
17
  };
10
- export const RichTextViewerDemo = () => {
18
+ export const RichTextViewerDemo = (args) => {
11
19
  const editorRef = useRef(null);
12
20
  const [content, setContent] = useState('[]');
13
21
  return (<Flex container={{ direction: 'column', gap: 2 }}>
@@ -21,10 +29,10 @@ export const RichTextViewerDemo = () => {
21
29
  'indentation'
22
30
  ]} onChange={() => setContent(editorRef.current?.getRichText() || '')}/>
23
31
 
24
- <RichTextViewer content={content} type='richtext'/>
32
+ <RichTextViewer content={args.content || content} type='richtext'/>
25
33
  </Flex>);
26
34
  };
27
- export const RichTextViewerHTMLDemo = () => {
35
+ export const RichTextViewerHTMLDemo = (args) => {
28
36
  const editorRef = useRef(null);
29
37
  const [content, setContent] = useState('');
30
38
  return (<Flex container={{ direction: 'column', gap: 2 }}>
@@ -38,7 +46,14 @@ export const RichTextViewerHTMLDemo = () => {
38
46
  'indentation'
39
47
  ]} onChange={() => setContent(editorRef.current?.getHtml() || '')}/>
40
48
 
41
- <RichTextViewer content={content} type='html'/>
49
+ <RichTextViewer content={args.content || content} type='html' interactionRenderers={args.interactionRenderers
50
+ ? [
51
+ {
52
+ regexPattern: /A custom pattern/g,
53
+ type: 'custom'
54
+ }
55
+ ]
56
+ : undefined}/>
42
57
  </Flex>);
43
58
  };
44
59
  export const RichTextViewerHTMLOverflowDemo = () => {
@@ -58,7 +73,7 @@ export const RichTextViewerHTMLOverflowDemo = () => {
58
73
  <RichTextViewer content={content} type='html'/>
59
74
  </Flex>);
60
75
  };
61
- export const RichTextViewerMDDemo = () => {
76
+ export const RichTextViewerMDDemo = (args) => {
62
77
  const LinkComponent = ({ token }) => {
63
78
  return (<Link href={token.href} previewable>
64
79
  {token.text}
@@ -74,18 +89,58 @@ export const RichTextViewerMDDemo = () => {
74
89
  }));
75
90
  }
76
91
  };
92
+ const getSearchAttributes = (xmlElement, searchResult) => {
93
+ if (xmlElement === 'pega-mention') {
94
+ const attributes = getXMLAttributes(searchResult);
95
+ if (!attributes)
96
+ return;
97
+ return {
98
+ markdown: searchResult,
99
+ component: MentionButtonConfig.component,
100
+ props: attributes,
101
+ text: attributes.text
102
+ };
103
+ }
104
+ };
77
105
  return (<Flex container={{ direction: 'column', gap: 2 }}>
78
- <RichTextEditor ref={editorRef} searchTriggers={[{ trigger: '@', regex: '[a-zA-Z]*(?: [a-zA-Z]*)?' }]} onSearch={searchUsers} getSearchItemReplacement={(id) => {
79
- const item = demoUsers.find(({ id: itemId }) => itemId === id);
106
+ <RichTextEditor markdownOnly ref={editorRef} searchTriggers={[
107
+ { trigger: '@', regex: String.raw `(?:\S+(?:[^\n\S][^@#\s]\S*)*[^\n\S]?|)` },
108
+ { trigger: '#', regex: String.raw `[^\s,]*` }
109
+ ]} getSearchItemReplacement={(id) => {
110
+ const item = users.find(({ id: itemId }) => itemId === id);
80
111
  if (!item)
81
112
  return undefined;
82
113
  return {
83
- markdown: `@${item.id}:${item.primary}:user:`,
114
+ markdown: MentionButtonConfig.inject({
115
+ id: item.id,
116
+ type: 'user',
117
+ text: item.primary
118
+ }),
119
+ component: MentionButtonConfig.component,
120
+ props: {
121
+ id: item.id,
122
+ text: item.primary,
123
+ type: 'user',
124
+ tabIndex: -1
125
+ },
84
126
  text: item.primary
85
127
  };
86
- }} menu={users.length ? { items: users } : undefined} markdownOnly defaultValue={"# Try writing some of your own markdown and see how it renders!\n\nYou can interact with mentions such as <pega-mention id='deans' text='Seth DeAngelo' type='user'/>\n\nThere is built in support for <pega-tag tag='tags'/> as well!\n\nComponent renderings can also be conditionally overwritten: [Link](https://www.google.com) -- [Link with preview](https://www.pega.com)"} onChange={() => setContent(editorRef.current?.getPlainText() || '')}/>
128
+ }} searchRenderers={[
129
+ {
130
+ type: MentionButtonConfig.type,
131
+ xmlElement: MentionButtonConfig.xmlElement,
132
+ regexPattern: MentionButtonConfig.regexPattern,
133
+ getSearchAttributes
134
+ },
135
+ {
136
+ type: HashtagButtonConfig.type,
137
+ xmlElement: HashtagButtonConfig.xmlElement,
138
+ regexPattern: HashtagButtonConfig.regexPattern,
139
+ getSearchAttributes
140
+ }
141
+ ]} onSearch={searchUsers} menu={users.length ? { items: users } : undefined} defaultValue={"# Try writing some of your own markdown and see how it renders!\n\nYou can interact with mentions such as <pega-mention id='deans' text='Seth DeAngelo' type='user'/>\n\nThere is built in support for <pega-tag tag='tags'/> as well!\n\nComponent renderings can also be conditionally overwritten: [Link](https://www.google.com) -- [Link with preview](https://www.pega.com)"} onChange={() => setContent(editorRef.current?.getPlainText() || '')}/>
87
142
 
88
- <RichTextViewer content={content} type='markdown' interactionRenderers={[MentionButtonConfig, HashtagButtonConfig]} markdownMap={{
143
+ <RichTextViewer content={args.content || content} type='markdown' interactionRenderers={[MentionButtonConfig, HashtagButtonConfig]} markdownMap={{
89
144
  link: (linkToken) => {
90
145
  if (linkToken.href?.includes('www.pega.com'))
91
146
  return LinkComponent;