@pega/cosmos-react-rte 3.0.0-dev.28.0 → 3.0.0-dev.30.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.
@@ -89,7 +89,7 @@ const parseTextToCustomSlateNodes = (text, renderers) => {
89
89
  }
90
90
  /* If we are at the end of the positions array, and there's still text left
91
91
  slice the text and add it as a new text node */
92
- if (i === positions.length - 1 && pos.end < text.length - 1) {
92
+ if (i === positions.length - 1 && pos.end < text.length) {
93
93
  nodes.push({
94
94
  text: text.slice(pos.end, text.length)
95
95
  });
@@ -1 +1 @@
1
- {"version":3,"file":"interactionRenderer.js","sourceRoot":"","sources":["../../../../src/components/RichTextEditor/utils/interactionRenderer.ts"],"names":[],"mappings":"AAqBA,oEAAoE;AACpE,MAAM,UAAU,GAAG,CAAC,MAAwB,EAAE,EAAE;IAC9C,MAAM,YAAY,GAAiB,EAAE,CAAC;IACtC,IAAI,GAAG,CAAC;IACR,0CAA0C;IAC1C,OAAO,CAAC,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE;QACpD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;QACxB,YAAY,CAAC,IAAI,CAAC;YAChB,KAAK;YACL,GAAG,EAAE,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM;YAC1B,KAAK,EAAE,GAAG;YACV,GAAG,MAAM;SACV,CAAC,CAAC;KACJ;IACD,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF,wCAAwC;AACxC,MAAM,2BAA2B,GAAG,CAAC,IAAY,EAAE,SAAuB,EAAE,EAAE;IAC5E,iEAAiE;IACjE,MAAM,SAAS,GACb,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,GAAG,QAAQ,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAE1E,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C,EAAE;YAC3D,KAAK,CAAC,IAAI,CAAC;gBACT,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC;aACvC,CAAC,CAAC;SACJ;QACD,OAAO,GAAG,GAAG,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;AACnD,CAAC,CAAC;AAEF,eAAe,2BAA2B,CAAC","sourcesContent":["import type * as slate from 'slate';\n\nimport { SearchRenderers } from '../RichTextEditor.types';\nimport { InteractionRenderers } from '../RichTextViewer.types';\n\ninterface Renderers {\n regexPattern: InteractionRenderers['regexPattern'];\n type?: InteractionRenderers['type'];\n component?: InteractionRenderers['component'];\n getSearchAttributes?: SearchRenderers['getSearchAttributes'];\n}\ninterface RegexMatch extends Renderers {\n start: number;\n end: number;\n match: RegExpExecArray;\n}\n\ninterface CheckRegexParams extends Renderers {\n text: string;\n}\n\n// Checks a string for regex matches and returns an array of matches\nconst checkRegex = (params: CheckRegexParams) => {\n const regexMatches: RegexMatch[] = [];\n let res;\n // eslint-disable-next-line no-cond-assign\n while ((res = params.regexPattern.exec(params.text))) {\n const start = res.index;\n regexMatches.push({\n start,\n end: start + res[0].length,\n match: res,\n ...params\n });\n }\n return regexMatches;\n};\n\n// Parses text node to custom slate node\nconst parseTextToCustomSlateNodes = (text: string, renderers?: Renderers[]) => {\n // Runs through an array of custom renderers and gets the matches\n const positions: RegexMatch[] =\n renderers?.flatMap(renderer => checkRegex({ text, ...renderer })) || [];\n\n // Early exit when no matched positions\n if (positions.length === 0) {\n return [{ text }];\n }\n\n // Sorts the matches based on the start positions of the matches\n positions.sort((a, b) => a.start - b.start);\n\n const nodes: (slate.Element | slate.Text)[] = [];\n\n // Use the regex match positions to slice the text into the correct text nodes and other custom nodes\n let lastPos: RegexMatch;\n positions.forEach((pos, i) => {\n /* If the first regex match isn't at the start of the text node,\n slice the text node up to the first match and insert it into the nodes array */\n\n if (i === 0 && pos.start !== 0) {\n nodes.push({\n text: text.slice(i, pos.start)\n });\n }\n\n /* If there was a last position, slice the text between the last position\n and the new position to insert it as a new text node */\n if (lastPos && lastPos.end < pos.start) {\n nodes.push({\n text: text.slice(lastPos.end, pos.start)\n });\n } else if (i !== 0) {\n nodes.push({\n text: ' '\n });\n }\n\n if (pos.type === 'builtin-url' && pos.match.groups) {\n const { leadingChar, url } = pos.match.groups;\n\n try {\n // Check for valid URL since the regex isn't exhaustive.\n const { href } = new URL(pos.match.groups.protocol ? url : `https://${url}`);\n\n if (leadingChar) {\n nodes.push({ text: leadingChar });\n }\n\n nodes.push({\n text: url,\n href\n });\n } catch {\n // Invalid URL, just render as text.\n nodes.push({ text: pos.match[0] });\n }\n } else if (pos.component) {\n nodes.push({\n type: 'custom',\n component: pos.component,\n content: pos.match,\n children: [{ text: '' }]\n });\n } else if (pos.getSearchAttributes) {\n const searchResult = pos.getSearchAttributes(pos.match);\n if (searchResult) {\n nodes.push({\n text: searchResult.text,\n searchResult: {\n markdown: searchResult.markdown,\n component: searchResult.component,\n props: searchResult.props,\n toJSON: () => undefined\n }\n });\n }\n }\n\n /* If we are at the end of the positions array, and there's still text left\n slice the text and add it as a new text node */\n if (i === positions.length - 1 && pos.end < text.length - 1) {\n nodes.push({\n text: text.slice(pos.end, text.length)\n });\n }\n lastPos = pos;\n });\n\n return nodes.length > 0 ? nodes : [{ text: '' }];\n};\n\nexport default parseTextToCustomSlateNodes;\n"]}
1
+ {"version":3,"file":"interactionRenderer.js","sourceRoot":"","sources":["../../../../src/components/RichTextEditor/utils/interactionRenderer.ts"],"names":[],"mappings":"AAqBA,oEAAoE;AACpE,MAAM,UAAU,GAAG,CAAC,MAAwB,EAAE,EAAE;IAC9C,MAAM,YAAY,GAAiB,EAAE,CAAC;IACtC,IAAI,GAAG,CAAC;I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,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;aACzB,CAAC,CAAC;SACJ;aAAM,IAAI,GAAG,CAAC,mBAAmB,EAAE;YAClC,MAAM,YAAY,GAAG,GAAG,CAAC,mBAAmB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACxD,IAAI,YAAY,EAAE;gBAChB,KAAK,CAAC,IAAI,CAAC;oBACT,IAAI,EAAE,YAAY,CAAC,IAAI;oBACvB,YAAY,EAAE;wBACZ,QAAQ,EAAE,YAAY,CAAC,QAAQ;wBAC/B,SAAS,EAAE,YAAY,CAAC,SAAS;wBACjC,KAAK,EAAE,YAAY,CAAC,KAAK;wBACzB,MAAM,EAAE,GAAG,EAAE,CAAC,SAAS;qBACxB;iBACF,CAAC,CAAC;aACJ;SACF;QAED;yDACiD;QACjD,IAAI,CAAC,KAAK,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE;YACvD,KAAK,CAAC,IAAI,CAAC;gBACT,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC;aACvC,CAAC,CAAC;SACJ;QACD,OAAO,GAAG,GAAG,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;AACnD,CAAC,CAAC;AAEF,eAAe,2BAA2B,CAAC","sourcesContent":["import type * as slate from 'slate';\n\nimport { SearchRenderers } from '../RichTextEditor.types';\nimport { InteractionRenderers } from '../RichTextViewer.types';\n\ninterface Renderers {\n regexPattern: InteractionRenderers['regexPattern'];\n type?: InteractionRenderers['type'];\n component?: InteractionRenderers['component'];\n getSearchAttributes?: SearchRenderers['getSearchAttributes'];\n}\ninterface RegexMatch extends Renderers {\n start: number;\n end: number;\n match: RegExpExecArray;\n}\n\ninterface CheckRegexParams extends Renderers {\n text: string;\n}\n\n// Checks a string for regex matches and returns an array of matches\nconst checkRegex = (params: CheckRegexParams) => {\n const regexMatches: RegexMatch[] = [];\n let res;\n // eslint-disable-next-line no-cond-assign\n while ((res = params.regexPattern.exec(params.text))) {\n const start = res.index;\n regexMatches.push({\n start,\n end: start + res[0].length,\n match: res,\n ...params\n });\n }\n return regexMatches;\n};\n\n// Parses text node to custom slate node\nconst parseTextToCustomSlateNodes = (text: string, renderers?: Renderers[]) => {\n // Runs through an array of custom renderers and gets the matches\n const positions: RegexMatch[] =\n renderers?.flatMap(renderer => checkRegex({ text, ...renderer })) || [];\n\n // Early exit when no matched positions\n if (positions.length === 0) {\n return [{ text }];\n }\n\n // Sorts the matches based on the start positions of the matches\n positions.sort((a, b) => a.start - b.start);\n\n const nodes: (slate.Element | slate.Text)[] = [];\n\n // Use the regex match positions to slice the text into the correct text nodes and other custom nodes\n let lastPos: RegexMatch;\n positions.forEach((pos, i) => {\n /* If the first regex match isn't at the start of the text node,\n slice the text node up to the first match and insert it into the nodes array */\n\n if (i === 0 && pos.start !== 0) {\n nodes.push({\n text: text.slice(i, pos.start)\n });\n }\n\n /* If there was a last position, slice the text between the last position\n and the new position to insert it as a new text node */\n if (lastPos && lastPos.end < pos.start) {\n nodes.push({\n text: text.slice(lastPos.end, pos.start)\n });\n } else if (i !== 0) {\n nodes.push({\n text: ' '\n });\n }\n\n if (pos.type === 'builtin-url' && pos.match.groups) {\n const { leadingChar, url } = pos.match.groups;\n\n try {\n // Check for valid URL since the regex isn't exhaustive.\n const { href } = new URL(pos.match.groups.protocol ? url : `https://${url}`);\n\n if (leadingChar) {\n nodes.push({ text: leadingChar });\n }\n\n nodes.push({\n text: url,\n href\n });\n } catch {\n // Invalid URL, just render as text.\n nodes.push({ text: pos.match[0] });\n }\n } else if (pos.component) {\n nodes.push({\n type: 'custom',\n component: pos.component,\n content: pos.match,\n children: [{ text: '' }]\n });\n } else if (pos.getSearchAttributes) {\n const searchResult = pos.getSearchAttributes(pos.match);\n if (searchResult) {\n nodes.push({\n text: searchResult.text,\n searchResult: {\n markdown: searchResult.markdown,\n component: searchResult.component,\n props: searchResult.props,\n toJSON: () => undefined\n }\n });\n }\n }\n\n /* If we are at the end of the positions array, and there's still text left\n slice the text and add it as a new text node */\n if (i === positions.length - 1 && pos.end < text.length) {\n nodes.push({\n text: text.slice(pos.end, text.length)\n });\n }\n lastPos = pos;\n });\n\n return nodes.length > 0 ? nodes : [{ text: '' }];\n};\n\nexport default parseTextToCustomSlateNodes;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/cosmos-react-rte",
3
- "version": "3.0.0-dev.28.0",
3
+ "version": "3.0.0-dev.30.0",
4
4
  "author": "Pegasystems",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {
@@ -20,7 +20,7 @@
20
20
  "build": "tsc -b"
21
21
  },
22
22
  "dependencies": {
23
- "@pega/cosmos-react-core": "3.0.0-dev.28.0",
23
+ "@pega/cosmos-react-core": "3.0.0-dev.30.0",
24
24
  "@popperjs/core": "^2.11.4",
25
25
  "@types/marked": "^4.0.2",
26
26
  "@types/parse5": "^6.0.0",