@pega/cosmos-react-rte 5.0.0-dev.4.6 → 5.0.0-dev.4.8

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 (193) hide show
  1. package/package.json +2 -2
  2. package/lib/components/DynamicContentEditor/DynamicContentEditor.d.ts +0 -12
  3. package/lib/components/DynamicContentEditor/DynamicContentEditor.d.ts.map +0 -1
  4. package/lib/components/DynamicContentEditor/DynamicContentEditor.js +0 -252
  5. package/lib/components/DynamicContentEditor/DynamicContentEditor.js.map +0 -1
  6. package/lib/components/DynamicContentEditor/DynamicContentEditor.test-ids.d.ts +0 -2
  7. package/lib/components/DynamicContentEditor/DynamicContentEditor.test-ids.d.ts.map +0 -1
  8. package/lib/components/DynamicContentEditor/DynamicContentEditor.test-ids.js +0 -8
  9. package/lib/components/DynamicContentEditor/DynamicContentEditor.test-ids.js.map +0 -1
  10. package/lib/components/DynamicContentEditor/DynamicContentEditor.types.d.ts +0 -35
  11. package/lib/components/DynamicContentEditor/DynamicContentEditor.types.d.ts.map +0 -1
  12. package/lib/components/DynamicContentEditor/DynamicContentEditor.types.js +0 -3
  13. package/lib/components/DynamicContentEditor/DynamicContentEditor.types.js.map +0 -1
  14. package/lib/components/DynamicContentEditor/PegaCustomElement.d.ts +0 -329
  15. package/lib/components/DynamicContentEditor/PegaCustomElement.d.ts.map +0 -1
  16. package/lib/components/DynamicContentEditor/PegaCustomElement.js +0 -27
  17. package/lib/components/DynamicContentEditor/PegaCustomElement.js.map +0 -1
  18. package/lib/components/DynamicContentEditor/index.d.ts +0 -3
  19. package/lib/components/DynamicContentEditor/index.d.ts.map +0 -1
  20. package/lib/components/DynamicContentEditor/index.js +0 -2
  21. package/lib/components/DynamicContentEditor/index.js.map +0 -1
  22. package/lib/components/Editor/Editor.context.d.ts +0 -10
  23. package/lib/components/Editor/Editor.context.d.ts.map +0 -1
  24. package/lib/components/Editor/Editor.context.js +0 -10
  25. package/lib/components/Editor/Editor.context.js.map +0 -1
  26. package/lib/components/Editor/Editor.d.ts +0 -19
  27. package/lib/components/Editor/Editor.d.ts.map +0 -1
  28. package/lib/components/Editor/Editor.js +0 -369
  29. package/lib/components/Editor/Editor.js.map +0 -1
  30. package/lib/components/Editor/Editor.styles.d.ts +0 -5
  31. package/lib/components/Editor/Editor.styles.d.ts.map +0 -1
  32. package/lib/components/Editor/Editor.styles.js +0 -50
  33. package/lib/components/Editor/Editor.styles.js.map +0 -1
  34. package/lib/components/Editor/Editor.test-ids.d.ts +0 -2
  35. package/lib/components/Editor/Editor.test-ids.d.ts.map +0 -1
  36. package/lib/components/Editor/Editor.test-ids.js +0 -8
  37. package/lib/components/Editor/Editor.test-ids.js.map +0 -1
  38. package/lib/components/Editor/Editor.types.d.ts +0 -69
  39. package/lib/components/Editor/Editor.types.d.ts.map +0 -1
  40. package/lib/components/Editor/Editor.types.js +0 -2
  41. package/lib/components/Editor/Editor.types.js.map +0 -1
  42. package/lib/components/Editor/ImageEditor.d.ts +0 -10
  43. package/lib/components/Editor/ImageEditor.d.ts.map +0 -1
  44. package/lib/components/Editor/ImageEditor.js +0 -276
  45. package/lib/components/Editor/ImageEditor.js.map +0 -1
  46. package/lib/components/Editor/Toolbar/AnchorButton.d.ts +0 -10
  47. package/lib/components/Editor/Toolbar/AnchorButton.d.ts.map +0 -1
  48. package/lib/components/Editor/Toolbar/AnchorButton.js +0 -161
  49. package/lib/components/Editor/Toolbar/AnchorButton.js.map +0 -1
  50. package/lib/components/Editor/Toolbar/ImageButton.d.ts +0 -8
  51. package/lib/components/Editor/Toolbar/ImageButton.d.ts.map +0 -1
  52. package/lib/components/Editor/Toolbar/ImageButton.js +0 -30
  53. package/lib/components/Editor/Toolbar/ImageButton.js.map +0 -1
  54. package/lib/components/Editor/Toolbar/TextSelect.d.ts +0 -14
  55. package/lib/components/Editor/Toolbar/TextSelect.d.ts.map +0 -1
  56. package/lib/components/Editor/Toolbar/TextSelect.js +0 -131
  57. package/lib/components/Editor/Toolbar/TextSelect.js.map +0 -1
  58. package/lib/components/Editor/Toolbar/Toolbar.d.ts +0 -17
  59. package/lib/components/Editor/Toolbar/Toolbar.d.ts.map +0 -1
  60. package/lib/components/Editor/Toolbar/Toolbar.js +0 -164
  61. package/lib/components/Editor/Toolbar/Toolbar.js.map +0 -1
  62. package/lib/components/Editor/Toolbar/Toolbar.test-ids.d.ts +0 -3
  63. package/lib/components/Editor/Toolbar/Toolbar.test-ids.d.ts.map +0 -1
  64. package/lib/components/Editor/Toolbar/Toolbar.test-ids.js +0 -16
  65. package/lib/components/Editor/Toolbar/Toolbar.test-ids.js.map +0 -1
  66. package/lib/components/Editor/index.d.ts +0 -4
  67. package/lib/components/Editor/index.d.ts.map +0 -1
  68. package/lib/components/Editor/index.js +0 -3
  69. package/lib/components/Editor/index.js.map +0 -1
  70. package/lib/components/RichTextEditor/DecoratorComponents/CodeBlock.d.ts +0 -4
  71. package/lib/components/RichTextEditor/DecoratorComponents/CodeBlock.d.ts.map +0 -1
  72. package/lib/components/RichTextEditor/DecoratorComponents/CodeBlock.js +0 -15
  73. package/lib/components/RichTextEditor/DecoratorComponents/CodeBlock.js.map +0 -1
  74. package/lib/components/RichTextEditor/DecoratorComponents/Image.d.ts +0 -4
  75. package/lib/components/RichTextEditor/DecoratorComponents/Image.d.ts.map +0 -1
  76. package/lib/components/RichTextEditor/DecoratorComponents/Image.js +0 -7
  77. package/lib/components/RichTextEditor/DecoratorComponents/Image.js.map +0 -1
  78. package/lib/components/RichTextEditor/DecoratorComponents/Link.d.ts +0 -4
  79. package/lib/components/RichTextEditor/DecoratorComponents/Link.d.ts.map +0 -1
  80. package/lib/components/RichTextEditor/DecoratorComponents/Link.js +0 -8
  81. package/lib/components/RichTextEditor/DecoratorComponents/Link.js.map +0 -1
  82. package/lib/components/RichTextEditor/DecoratorComponents/Table.d.ts +0 -6
  83. package/lib/components/RichTextEditor/DecoratorComponents/Table.d.ts.map +0 -1
  84. package/lib/components/RichTextEditor/DecoratorComponents/Table.js +0 -24
  85. package/lib/components/RichTextEditor/DecoratorComponents/Table.js.map +0 -1
  86. package/lib/components/RichTextEditor/RichTextEditor.context.d.ts +0 -15
  87. package/lib/components/RichTextEditor/RichTextEditor.context.d.ts.map +0 -1
  88. package/lib/components/RichTextEditor/RichTextEditor.context.js +0 -11
  89. package/lib/components/RichTextEditor/RichTextEditor.context.js.map +0 -1
  90. package/lib/components/RichTextEditor/RichTextEditor.d.ts +0 -6
  91. package/lib/components/RichTextEditor/RichTextEditor.d.ts.map +0 -1
  92. package/lib/components/RichTextEditor/RichTextEditor.js +0 -346
  93. package/lib/components/RichTextEditor/RichTextEditor.js.map +0 -1
  94. package/lib/components/RichTextEditor/RichTextEditor.styles.d.ts +0 -10
  95. package/lib/components/RichTextEditor/RichTextEditor.styles.d.ts.map +0 -1
  96. package/lib/components/RichTextEditor/RichTextEditor.styles.js +0 -73
  97. package/lib/components/RichTextEditor/RichTextEditor.styles.js.map +0 -1
  98. package/lib/components/RichTextEditor/RichTextEditor.types.d.ts +0 -72
  99. package/lib/components/RichTextEditor/RichTextEditor.types.d.ts.map +0 -1
  100. package/lib/components/RichTextEditor/RichTextEditor.types.js +0 -2
  101. package/lib/components/RichTextEditor/RichTextEditor.types.js.map +0 -1
  102. package/lib/components/RichTextEditor/RichTextTreeRenderer.d.ts +0 -9
  103. package/lib/components/RichTextEditor/RichTextTreeRenderer.d.ts.map +0 -1
  104. package/lib/components/RichTextEditor/RichTextTreeRenderer.js +0 -15
  105. package/lib/components/RichTextEditor/RichTextTreeRenderer.js.map +0 -1
  106. package/lib/components/RichTextEditor/RichTextViewer.d.ts +0 -7
  107. package/lib/components/RichTextEditor/RichTextViewer.d.ts.map +0 -1
  108. package/lib/components/RichTextEditor/RichTextViewer.js +0 -38
  109. package/lib/components/RichTextEditor/RichTextViewer.js.map +0 -1
  110. package/lib/components/RichTextEditor/RichTextViewer.types.d.ts +0 -33
  111. package/lib/components/RichTextEditor/RichTextViewer.types.d.ts.map +0 -1
  112. package/lib/components/RichTextEditor/RichTextViewer.types.js +0 -2
  113. package/lib/components/RichTextEditor/RichTextViewer.types.js.map +0 -1
  114. package/lib/components/RichTextEditor/Toolbar/AnchorButton.d.ts +0 -8
  115. package/lib/components/RichTextEditor/Toolbar/AnchorButton.d.ts.map +0 -1
  116. package/lib/components/RichTextEditor/Toolbar/AnchorButton.js +0 -156
  117. package/lib/components/RichTextEditor/Toolbar/AnchorButton.js.map +0 -1
  118. package/lib/components/RichTextEditor/Toolbar/ImageButton.d.ts +0 -5
  119. package/lib/components/RichTextEditor/Toolbar/ImageButton.d.ts.map +0 -1
  120. package/lib/components/RichTextEditor/Toolbar/ImageButton.js +0 -30
  121. package/lib/components/RichTextEditor/Toolbar/ImageButton.js.map +0 -1
  122. package/lib/components/RichTextEditor/Toolbar/IndentButton.d.ts +0 -8
  123. package/lib/components/RichTextEditor/Toolbar/IndentButton.d.ts.map +0 -1
  124. package/lib/components/RichTextEditor/Toolbar/IndentButton.js +0 -31
  125. package/lib/components/RichTextEditor/Toolbar/IndentButton.js.map +0 -1
  126. package/lib/components/RichTextEditor/Toolbar/TableButton.d.ts +0 -5
  127. package/lib/components/RichTextEditor/Toolbar/TableButton.d.ts.map +0 -1
  128. package/lib/components/RichTextEditor/Toolbar/TableButton.js +0 -20
  129. package/lib/components/RichTextEditor/Toolbar/TableButton.js.map +0 -1
  130. package/lib/components/RichTextEditor/Toolbar/TextSelect.d.ts +0 -6
  131. package/lib/components/RichTextEditor/Toolbar/TextSelect.d.ts.map +0 -1
  132. package/lib/components/RichTextEditor/Toolbar/TextSelect.js +0 -119
  133. package/lib/components/RichTextEditor/Toolbar/TextSelect.js.map +0 -1
  134. package/lib/components/RichTextEditor/Toolbar/Toolbar.d.ts +0 -10
  135. package/lib/components/RichTextEditor/Toolbar/Toolbar.d.ts.map +0 -1
  136. package/lib/components/RichTextEditor/Toolbar/Toolbar.js +0 -155
  137. package/lib/components/RichTextEditor/Toolbar/Toolbar.js.map +0 -1
  138. package/lib/components/RichTextEditor/Toolbar/Toolbar.types.d.ts +0 -9
  139. package/lib/components/RichTextEditor/Toolbar/Toolbar.types.d.ts.map +0 -1
  140. package/lib/components/RichTextEditor/Toolbar/Toolbar.types.js +0 -2
  141. package/lib/components/RichTextEditor/Toolbar/Toolbar.types.js.map +0 -1
  142. package/lib/components/RichTextEditor/Toolbar/ToolbarButton.d.ts +0 -14
  143. package/lib/components/RichTextEditor/Toolbar/ToolbarButton.d.ts.map +0 -1
  144. package/lib/components/RichTextEditor/Toolbar/ToolbarButton.js +0 -67
  145. package/lib/components/RichTextEditor/Toolbar/ToolbarButton.js.map +0 -1
  146. package/lib/components/RichTextEditor/Toolbar/utils.d.ts +0 -7
  147. package/lib/components/RichTextEditor/Toolbar/utils.d.ts.map +0 -1
  148. package/lib/components/RichTextEditor/Toolbar/utils.js +0 -13
  149. package/lib/components/RichTextEditor/Toolbar/utils.js.map +0 -1
  150. package/lib/components/RichTextEditor/index.d.ts +0 -9
  151. package/lib/components/RichTextEditor/index.d.ts.map +0 -1
  152. package/lib/components/RichTextEditor/index.js +0 -6
  153. package/lib/components/RichTextEditor/index.js.map +0 -1
  154. package/lib/components/RichTextEditor/utils/EditorCommands.d.ts +0 -34
  155. package/lib/components/RichTextEditor/utils/EditorCommands.d.ts.map +0 -1
  156. package/lib/components/RichTextEditor/utils/EditorCommands.js +0 -447
  157. package/lib/components/RichTextEditor/utils/EditorCommands.js.map +0 -1
  158. package/lib/components/RichTextEditor/utils/ListCommands.d.ts +0 -10
  159. package/lib/components/RichTextEditor/utils/ListCommands.d.ts.map +0 -1
  160. package/lib/components/RichTextEditor/utils/ListCommands.js +0 -346
  161. package/lib/components/RichTextEditor/utils/ListCommands.js.map +0 -1
  162. package/lib/components/RichTextEditor/utils/htmlConverter.d.ts +0 -29
  163. package/lib/components/RichTextEditor/utils/htmlConverter.d.ts.map +0 -1
  164. package/lib/components/RichTextEditor/utils/htmlConverter.js +0 -156
  165. package/lib/components/RichTextEditor/utils/htmlConverter.js.map +0 -1
  166. package/lib/components/RichTextEditor/utils/interactionRenderer.d.ts +0 -6
  167. package/lib/components/RichTextEditor/utils/interactionRenderer.d.ts.map +0 -1
  168. package/lib/components/RichTextEditor/utils/interactionRenderer.js +0 -132
  169. package/lib/components/RichTextEditor/utils/interactionRenderer.js.map +0 -1
  170. package/lib/components/RichTextEditor/utils/markdownConverter.d.ts +0 -6
  171. package/lib/components/RichTextEditor/utils/markdownConverter.d.ts.map +0 -1
  172. package/lib/components/RichTextEditor/utils/markdownConverter.js +0 -130
  173. package/lib/components/RichTextEditor/utils/markdownConverter.js.map +0 -1
  174. package/lib/components/RichTextEditor/utils/renderers.d.ts +0 -22
  175. package/lib/components/RichTextEditor/utils/renderers.d.ts.map +0 -1
  176. package/lib/components/RichTextEditor/utils/renderers.js +0 -163
  177. package/lib/components/RichTextEditor/utils/renderers.js.map +0 -1
  178. package/lib/components/RichTextEditor/utils/search.d.ts +0 -11
  179. package/lib/components/RichTextEditor/utils/search.d.ts.map +0 -1
  180. package/lib/components/RichTextEditor/utils/search.js +0 -37
  181. package/lib/components/RichTextEditor/utils/search.js.map +0 -1
  182. package/lib/components/RichTextEditor/utils/slateConverter.d.ts +0 -25
  183. package/lib/components/RichTextEditor/utils/slateConverter.d.ts.map +0 -1
  184. package/lib/components/RichTextEditor/utils/slateConverter.js +0 -88
  185. package/lib/components/RichTextEditor/utils/slateConverter.js.map +0 -1
  186. package/lib/components/RichTextEditor/utils/utils.types.d.ts +0 -3
  187. package/lib/components/RichTextEditor/utils/utils.types.d.ts.map +0 -1
  188. package/lib/components/RichTextEditor/utils/utils.types.js +0 -3
  189. package/lib/components/RichTextEditor/utils/utils.types.js.map +0 -1
  190. package/lib/index.d.ts +0 -5
  191. package/lib/index.d.ts.map +0 -1
  192. package/lib/index.js +0 -6
  193. package/lib/index.js.map +0 -1
@@ -1,88 +0,0 @@
1
- import { Element, Text } from 'slate';
2
- export const slateToHtmlMap = {
3
- link: 'a',
4
- 'heading-1': 'h1',
5
- 'heading-2': 'h2',
6
- 'heading-3': 'h3',
7
- 'heading-4': 'h4',
8
- 'unordered-list': 'ul',
9
- 'ordered-list': 'ol',
10
- 'list-item': 'li',
11
- table: 'table',
12
- 'table-body': 'tbody',
13
- 'table-row': 'tr',
14
- 'table-cell': 'td',
15
- text: 'span',
16
- paragraph: 'p',
17
- bold: 'b',
18
- 'line-through': 'del',
19
- italic: 'i',
20
- href: 'a',
21
- image: 'img'
22
- };
23
- // Reduces the properties in a slate node into the correct html attributes, mostly used for list-items at the moment
24
- const getAttrs = (el) => {
25
- // eslint-disable-next-line sonarjs/no-small-switch
26
- switch (el.type) {
27
- case 'list-item':
28
- return [
29
- { name: 'data-id', value: el.id },
30
- { name: 'data-parent-id', value: el.parentId },
31
- { name: 'data-order', value: el.order },
32
- { name: 'data-level', value: el.level }
33
- ].reduce((acc, attr) => {
34
- if (attr.value) {
35
- return `${acc} ${attr.name}='${attr.value}'`;
36
- }
37
- return acc;
38
- }, '');
39
- default:
40
- return Object.keys(el).reduce((innerAcc, key) => {
41
- return key !== 'type' && key !== 'children'
42
- ? `${innerAcc} ${key}='${el[key]}'`
43
- : innerAcc;
44
- }, '');
45
- }
46
- };
47
- // Recursive function to reduce Slate Nodes into an HTML string
48
- export const constructHtml = (nodes) => {
49
- return nodes.reduce((acc, node) => {
50
- if (Element.isElement(node) &&
51
- (node.type === 'image-placeholder' || node.type === 'custom' || node.type === 'override'))
52
- return acc;
53
- const htmlTag = Element.isElement(node) ? slateToHtmlMap[node.type] : undefined;
54
- let html;
55
- if (Text.isText(node)) {
56
- const { text, ...restNode } = node;
57
- // Reducing inline style properties from a single Slate Node into the correct HTML tags
58
- html = Object.keys(restNode).reduce((innerAcc, key, i) => {
59
- const tag = slateToHtmlMap[key];
60
- // Add the href attribute if needed
61
- const firstInnerTag = tag === 'a' ? `${tag} href='${restNode[key]}'` : tag;
62
- if (i === 0) {
63
- return `<${firstInnerTag}>${text}</${tag}>`;
64
- }
65
- return `<${firstInnerTag}>${innerAcc}</${tag}>`;
66
- }, '');
67
- if (!html) {
68
- html = text;
69
- }
70
- }
71
- else {
72
- const attrs = getAttrs(node);
73
- html = `<${htmlTag}${attrs}>${constructHtml(node.children || [])}</${htmlTag}>`;
74
- }
75
- return `${acc}${html}`;
76
- }, '');
77
- };
78
- export const convertSlateToHtml = (nodes) => {
79
- if (nodes.length === 1 &&
80
- Element.isElement(nodes[0]) &&
81
- Text.isText(nodes[0].children[0]) &&
82
- nodes[0].children[0].text === '') {
83
- return '';
84
- }
85
- const htmlNodes = constructHtml(nodes);
86
- return `<body>${htmlNodes}</body>`;
87
- };
88
- //# sourceMappingURL=slateConverter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slateConverter.js","sourceRoot":"","sources":["../../../../src/components/RichTextEditor/utils/slateConverter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAIpD,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,GAAG;IACT,WAAW,EAAE,IAAI;IACjB,WAAW,EAAE,IAAI;IACjB,WAAW,EAAE,IAAI;IACjB,WAAW,EAAE,IAAI;IACjB,gBAAgB,EAAE,IAAI;IACtB,cAAc,EAAE,IAAI;IACpB,WAAW,EAAE,IAAI;IACjB,KAAK,EAAE,OAAO;IACd,YAAY,EAAE,OAAO;IACrB,WAAW,EAAE,IAAI;IACjB,YAAY,EAAE,IAAI;IAClB,IAAI,EAAE,MAAM;IACZ,SAAS,EAAE,GAAG;IACd,IAAI,EAAE,GAAG;IACT,cAAc,EAAE,KAAK;IACrB,MAAM,EAAE,GAAG;IACX,IAAI,EAAE,GAAG;IACT,KAAK,EAAE,KAAK;CACb,CAAC;AAEF,oHAAoH;AACpH,MAAM,QAAQ,GAAG,CACf,EAA6F,EAC7F,EAAE;IACF,mDAAmD;IACnD,QAAQ,EAAE,CAAC,IAAI,EAAE;QACf,KAAK,WAAW;YACd,OAAO;g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,CAAC,KAAyB,EAAU,EAAE;IACtE,IACE,KAAK,CAAC,MAAM,KAAK,CAAC;QAClB,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC3B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACjC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,EAChC;QACA,OAAO,EAAE,CAAC;KACX;IACD,MAAM,SAAS,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IACvC,OAAO,SAAS,SAAS,SAAS,CAAC;AACrC,CAAC,CAAC","sourcesContent":["import { CosmosCustom, Element, Text } from 'slate';\n\nimport { ExcludeStrict } from '@pega/cosmos-react-core';\n\nexport const slateToHtmlMap = {\n link: 'a',\n 'heading-1': 'h1',\n 'heading-2': 'h2',\n 'heading-3': 'h3',\n 'heading-4': 'h4',\n 'unordered-list': 'ul',\n 'ordered-list': 'ol',\n 'list-item': 'li',\n table: 'table',\n 'table-body': 'tbody',\n 'table-row': 'tr',\n 'table-cell': 'td',\n text: 'span',\n paragraph: 'p',\n bold: 'b',\n 'line-through': 'del',\n italic: 'i',\n href: 'a',\n image: 'img'\n};\n\n// Reduces the properties in a slate node into the correct html attributes, mostly used for list-items at the moment\nconst getAttrs = (\n el: ExcludeStrict<Element, CosmosCustom.ImagePlaceholderElement | CosmosCustom.CustomElement>\n) => {\n // eslint-disable-next-line sonarjs/no-small-switch\n switch (el.type) {\n case 'list-item':\n return [\n { name: 'data-id', value: el.id },\n { name: 'data-parent-id', value: el.parentId },\n { name: 'data-order', value: el.order },\n { name: 'data-level', value: el.level }\n ].reduce((acc, attr) => {\n if (attr.value) {\n return `${acc} ${attr.name}='${attr.value}'`;\n }\n return acc;\n }, '');\n default:\n return Object.keys(el).reduce((innerAcc, key) => {\n return key !== 'type' && key !== 'children'\n ? `${innerAcc} ${key}='${el[key as keyof Element]}'`\n : innerAcc;\n }, '');\n }\n};\n\n// Recursive function to reduce Slate Nodes into an HTML string\nexport const constructHtml = (nodes: (Element | Text)[]): string => {\n return nodes.reduce((acc, node) => {\n if (\n Element.isElement(node) &&\n (node.type === 'image-placeholder' || node.type === 'custom' || node.type === 'override')\n )\n return acc;\n\n const htmlTag = Element.isElement(node) ? slateToHtmlMap[node.type] : undefined;\n let html;\n if (Text.isText(node)) {\n const { text, ...restNode } = node;\n // Reducing inline style properties from a single Slate Node into the correct HTML tags\n html = Object.keys(restNode).reduce((innerAcc, key, i) => {\n const tag = slateToHtmlMap[key as 'bold' | 'line-through' | 'italic' | 'href'];\n // Add the href attribute if needed\n const firstInnerTag = tag === 'a' ? `${tag} href='${restNode[key as 'href']}'` : tag;\n\n if (i === 0) {\n return `<${firstInnerTag}>${text}</${tag}>`;\n }\n return `<${firstInnerTag}>${innerAcc}</${tag}>`;\n }, '');\n if (!html) {\n html = text;\n }\n } else {\n const attrs = getAttrs(node);\n html = `<${htmlTag}${attrs}>${constructHtml(\n (node.children as (Element | Text)[]) || []\n )}</${htmlTag}>`;\n }\n return `${acc}${html}`;\n }, '');\n};\n\nexport const convertSlateToHtml = (nodes: (Element | Text)[]): string => {\n if (\n nodes.length === 1 &&\n Element.isElement(nodes[0]) &&\n Text.isText(nodes[0].children[0]) &&\n nodes[0].children[0].text === ''\n ) {\n return '';\n }\n const htmlNodes = constructHtml(nodes);\n return `<body>${htmlNodes}</body>`;\n};\n"]}
@@ -1,3 +0,0 @@
1
- export declare const LIST_TYPES: string[];
2
- export declare const TEXT_TYPES: string[];
3
- //# sourceMappingURL=utils.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.types.d.ts","sourceRoot":"","sources":["../../../../src/components/RichTextEditor/utils/utils.types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,UAAqC,CAAC;AAC7D,eAAO,MAAM,UAAU,UAAgE,CAAC"}
@@ -1,3 +0,0 @@
1
- export const LIST_TYPES = ['unordered-list', 'ordered-list'];
2
- export const TEXT_TYPES = ['paragraph', 'header-1', 'header-2', 'header-3', 'header-4'];
3
- //# sourceMappingURL=utils.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.types.js","sourceRoot":"","sources":["../../../../src/components/RichTextEditor/utils/utils.types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;AAC7D,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC","sourcesContent":["export const LIST_TYPES = ['unordered-list', 'ordered-list'];\nexport const TEXT_TYPES = ['paragraph', 'header-1', 'header-2', 'header-3', 'header-4'];\n"]}
package/lib/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export { default as DynamicContentEditor } from './components/DynamicContentEditor';
2
- export * from './components/DynamicContentEditor';
3
- export * from './components/Editor';
4
- export * from './components/RichTextEditor';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACpF,cAAc,mCAAmC,CAAC;AAClD,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC"}
package/lib/index.js DELETED
@@ -1,6 +0,0 @@
1
- // This file is autogenerated. Any changes will be overwritten.
2
- export { default as DynamicContentEditor } from './components/DynamicContentEditor';
3
- export * from './components/DynamicContentEditor';
4
- export * from './components/Editor';
5
- export * from './components/RichTextEditor';
6
- //# sourceMappingURL=index.js.map
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACpF,cAAc,mCAAmC,CAAC;AAClD,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC","sourcesContent":["// This file is autogenerated. Any changes will be overwritten.\nexport { default as DynamicContentEditor } from './components/DynamicContentEditor';\nexport * from './components/DynamicContentEditor';\nexport * from './components/Editor';\nexport * from './components/RichTextEditor';\n"]}