@jpmorganchase/mosaic-content-editor-plugin 0.1.0-beta.71 → 0.1.0-beta.73

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 (92) hide show
  1. package/dist/chunk-55WG3HBR.js +1 -0
  2. package/dist/chunk-HIIAB4W2.js +1 -0
  3. package/dist/{chunk-7O2SLISS.js → chunk-JLXXPRWJ.js} +1 -1
  4. package/dist/{chunk-CBQZGN4Y.js → chunk-U52GJYI4.js} +1 -1
  5. package/dist/chunk-UFRXMSJP.js +1 -0
  6. package/dist/{chunk-WOLMNJ7G.js → chunk-X5M73NRM.js} +1 -1
  7. package/dist/chunk-YDLF23AQ.js +1 -0
  8. package/dist/components/Dialog.d.ts +1 -1
  9. package/dist/components/Dialog.js +1 -1
  10. package/dist/components/Editor.js +1 -1
  11. package/dist/components/PersistEditDialog/index.js +1 -1
  12. package/dist/components/Toolbar/InsertImage.js +1 -1
  13. package/dist/components/Toolbar/InsertLink.js +1 -1
  14. package/dist/components/Toolbar/Toolbar.js +1 -1
  15. package/dist/index.js +1 -1
  16. package/dist/plugins/FloatingToolbarPlugin.js +1 -1
  17. package/dist/plugins/MarkdownLinkPlugin.js +1 -1
  18. package/dist/plugins/PreviewPlugin.js +1 -1
  19. package/package.json +9 -6
  20. package/.turbo/turbo-build.log +0 -4
  21. package/CHANGELOG.md +0 -673
  22. package/dist/chunk-CXTIKD2Y.js +0 -1
  23. package/dist/chunk-EPOQVSZ5.js +0 -1
  24. package/dist/chunk-LQBKKB6A.js +0 -1
  25. package/dist/chunk-XSZUCLBY.js +0 -1
  26. package/src/components/ActionMenu/ActionMenu.css.ts +0 -9
  27. package/src/components/ActionMenu/ActionMenu.tsx +0 -26
  28. package/src/components/BaseToolbar/BaseToolbar.css.ts +0 -21
  29. package/src/components/BaseToolbar/BaseToolbar.tsx +0 -13
  30. package/src/components/BaseTooltray/BaseTooltray.css.ts +0 -31
  31. package/src/components/BaseTooltray/BaseTooltray.tsx +0 -22
  32. package/src/components/ContentEditor.tsx +0 -14
  33. package/src/components/Dialog.css.ts +0 -7
  34. package/src/components/Dialog.tsx +0 -12
  35. package/src/components/Editor.css.ts +0 -64
  36. package/src/components/Editor.tsx +0 -145
  37. package/src/components/EditorControls.css.ts +0 -6
  38. package/src/components/EditorControls.tsx +0 -37
  39. package/src/components/LinkEditor/EditLinkButton.tsx +0 -9
  40. package/src/components/LinkEditor/LinkEditor.css.ts +0 -15
  41. package/src/components/LinkEditor/LinkEditor.tsx +0 -136
  42. package/src/components/LinkEditor/SaveAdornment.tsx +0 -17
  43. package/src/components/PersistEditDialog/PersistStatus.css.ts +0 -21
  44. package/src/components/PersistEditDialog/PersistStatus.tsx +0 -57
  45. package/src/components/PersistEditDialog/__tests__/index.test.tsx +0 -90
  46. package/src/components/PersistEditDialog/index.css.ts +0 -14
  47. package/src/components/PersistEditDialog/index.tsx +0 -150
  48. package/src/components/Popper/Popper.css.ts +0 -12
  49. package/src/components/Popper/Popper.tsx +0 -36
  50. package/src/components/SaveButton.tsx +0 -23
  51. package/src/components/ScrollableSection/ScrollableSection.css.ts +0 -10
  52. package/src/components/ScrollableSection/ScrollableSection.tsx +0 -20
  53. package/src/components/StatusBanner.tsx +0 -16
  54. package/src/components/Toolbar/InsertBlockDropdown.tsx +0 -134
  55. package/src/components/Toolbar/InsertHorizontalRule.tsx +0 -18
  56. package/src/components/Toolbar/InsertImage.css.ts +0 -7
  57. package/src/components/Toolbar/InsertImage.tsx +0 -130
  58. package/src/components/Toolbar/InsertLink.css.ts +0 -7
  59. package/src/components/Toolbar/InsertLink.tsx +0 -140
  60. package/src/components/Toolbar/InsertTable.css.ts +0 -52
  61. package/src/components/Toolbar/InsertTable.tsx +0 -196
  62. package/src/components/Toolbar/TextFormatTooltray.css.ts +0 -22
  63. package/src/components/Toolbar/TextFormatTooltray.tsx +0 -113
  64. package/src/components/Toolbar/Toolbar.tsx +0 -52
  65. package/src/components/Toolbar/ToolbarButton.css.ts +0 -11
  66. package/src/components/Toolbar/ToolbarButton.tsx +0 -41
  67. package/src/components/Toolbar/ToolbarSeparator.css.ts +0 -28
  68. package/src/components/Toolbar/ToolbarSepartor.tsx +0 -13
  69. package/src/components/__tests__/EditorControls.test.tsx +0 -69
  70. package/src/components/__tests__/StatusBanner.test.tsx +0 -33
  71. package/src/hooks/useEditHistory.ts +0 -49
  72. package/src/hooks/useWorkflowFeed.ts +0 -69
  73. package/src/index.ts +0 -5
  74. package/src/nodes/index.ts +0 -23
  75. package/src/plugins/FloatingToolbarPlugin.css.ts +0 -14
  76. package/src/plugins/FloatingToolbarPlugin.tsx +0 -101
  77. package/src/plugins/HorizontalRulePlugin.tsx +0 -39
  78. package/src/plugins/MarkdownImagePlugin.tsx +0 -58
  79. package/src/plugins/MarkdownLinkPlugin.tsx +0 -69
  80. package/src/plugins/PreviewPlugin.tsx +0 -71
  81. package/src/plugins/TableActionMenuPlugin.css.ts +0 -29
  82. package/src/plugins/TableActionMenuPlugin.tsx +0 -274
  83. package/src/store/__tests__/index.test.ts +0 -171
  84. package/src/store/index.ts +0 -84
  85. package/src/theme/index.css.ts +0 -39
  86. package/src/theme/index.ts +0 -22
  87. package/src/transformers/horizontalRule.ts +0 -25
  88. package/src/transformers/index.ts +0 -6
  89. package/src/transformers/link.ts +0 -3
  90. package/src/transformers/tableRule.ts +0 -193
  91. package/src/utils/getSelectedNode.ts +0 -16
  92. package/tsconfig.json +0 -8
@@ -1,193 +0,0 @@
1
- import { ElementTransformer } from '@lexical/markdown';
2
- import type { ElementNode, LexicalNode } from 'lexical';
3
- import {
4
- $createTableCellNode,
5
- $createTableNode,
6
- $createTableRowNode,
7
- $isTableNode,
8
- $isTableRowNode,
9
- TableCellHeaderStates,
10
- TableCellNode,
11
- TableNode,
12
- TableRowNode
13
- } from '@lexical/table';
14
- import {
15
- $createParagraphNode,
16
- $createTextNode,
17
- $isElementNode,
18
- $isParagraphNode,
19
- $isTextNode
20
- } from 'lexical';
21
-
22
- import LINK_TRANSFORMER from './link';
23
-
24
- const TABLE_ROW_REG_EXP = /^(?:\|)(.+)(?:\|)\s?$/;
25
- const TABLE_HEADER_REG_EXP = /(---)/;
26
-
27
- export const TABLE_RULE: ElementTransformer = {
28
- dependencies: [TableNode, TableRowNode, TableCellNode],
29
- export: (node: LexicalNode, exportChildren: (elementNode: ElementNode) => string) => {
30
- if (!$isTableNode(node)) {
31
- return null;
32
- }
33
-
34
- const output: string[] = [];
35
- let columnCount: number | null = null;
36
-
37
- // eslint-disable-next-line no-restricted-syntax
38
- for (const row of node.getChildren()) {
39
- const rowOutput: string[] = [];
40
-
41
- if ($isTableRowNode(row)) {
42
- // eslint-disable-next-line no-restricted-syntax
43
- for (const cell of row.getChildren()) {
44
- if ($isElementNode(cell)) {
45
- rowOutput.push(exportChildren(cell));
46
- }
47
- }
48
- if (columnCount === null) {
49
- columnCount = rowOutput.length;
50
- }
51
- }
52
- output.push(`| ${rowOutput.join(' | ')} |`);
53
- }
54
- addHeaderDividerToOutput(output, columnCount);
55
- return output.join('\n');
56
- },
57
- regExp: TABLE_ROW_REG_EXP,
58
- replace: (parentNode, _1, match) => {
59
- const matchCells = mapToTableCells(match[0]);
60
-
61
- if (matchCells == null) {
62
- return;
63
- }
64
-
65
- const rows = handleHeaderDashes(matchCells);
66
- let sibling = parentNode.getPreviousSibling();
67
- let maxCells = matchCells.length;
68
-
69
- while (sibling) {
70
- if (!$isParagraphNode(sibling)) {
71
- break;
72
- }
73
-
74
- if (sibling.getChildrenSize() !== 1) {
75
- break;
76
- }
77
-
78
- const firstChild = sibling.getFirstChild();
79
-
80
- if (!$isTextNode(firstChild)) {
81
- break;
82
- }
83
-
84
- const cells = mapToTableCells(firstChild.getTextContent());
85
-
86
- if (cells == null) {
87
- break;
88
- }
89
-
90
- maxCells = Math.max(maxCells, cells.length);
91
- rows.unshift(cells);
92
- const previousSibling = sibling.getPreviousSibling();
93
- sibling.remove();
94
- sibling = previousSibling;
95
- }
96
-
97
- const table = createTableNode(rows, maxCells);
98
-
99
- const previousSibling = parentNode.getPreviousSibling();
100
- if ($isTableNode(previousSibling) && getTableColumnsSize(previousSibling) === maxCells) {
101
- previousSibling.append(...table.getChildren());
102
- parentNode.remove();
103
- } else {
104
- parentNode.replace(table);
105
- }
106
-
107
- table.selectEnd();
108
- },
109
- type: 'element'
110
- };
111
-
112
- function getTableColumnsSize(table: TableNode) {
113
- const row = table.getFirstChild();
114
- return $isTableRowNode(row) ? row.getChildrenSize() : 0;
115
- }
116
-
117
- const createTableCell = (textContent: string | null | undefined): TableCellNode => {
118
- const cell = $createTableCellNode(TableCellHeaderStates.NO_STATUS);
119
- const paragraph = $createParagraphNode();
120
-
121
- if (textContent != null) {
122
- const textNode = $createTextNode(textContent.trim());
123
- paragraph.append(textNode);
124
- /**
125
- * Table cells are treated as text only.
126
- * However, it is very common to see links inside tables
127
- * so we check if the content is a markdown link and render a link accordingly
128
- */
129
- const linkMatch = textContent.trim().match(LINK_TRANSFORMER.regExp);
130
- if (linkMatch) {
131
- LINK_TRANSFORMER.replace(textNode, linkMatch);
132
- }
133
- }
134
-
135
- cell.append(paragraph);
136
- return cell;
137
- };
138
-
139
- const mapToTableCells = (textContent: string): Array<TableCellNode> | null => {
140
- const match = textContent.match(TABLE_ROW_REG_EXP);
141
-
142
- if (!match || !match[1]) {
143
- return null;
144
- }
145
-
146
- return match[1].split('|').map(text => createTableCell(text));
147
- };
148
-
149
- const addHeaderDividerToOutput = (output: string[], columnCount?: number | null) => {
150
- let divider = '';
151
-
152
- if (!columnCount) {
153
- return output;
154
- }
155
- for (let i = 0; i < columnCount + 1; i++) {
156
- divider = divider.concat('|');
157
-
158
- if (i < columnCount) {
159
- divider = divider.concat('----');
160
- }
161
- }
162
-
163
- const headerMatch = output[1]?.match(TABLE_HEADER_REG_EXP);
164
- if (headerMatch) {
165
- // output already has the header dashes
166
- return output;
167
- }
168
- return output.splice(1, 0, divider);
169
- };
170
-
171
- /**
172
- * if a table has the markdown dashes then
173
- * we don't want to render them as part of the table
174
- */
175
- const handleHeaderDashes = (matchCells: TableCellNode[]) => {
176
- const test = matchCells[0].getFirstChild()?.getTextContent();
177
- const headerMatch = test?.match(TABLE_HEADER_REG_EXP);
178
- return headerMatch === null ? [matchCells] : [];
179
- };
180
-
181
- const createTableNode = (rows: TableCellNode[][], maxCells: number) => {
182
- const table = $createTableNode();
183
- // eslint-disable-next-line no-restricted-syntax
184
- for (const cells of rows) {
185
- const tableRow = $createTableRowNode();
186
- table.append(tableRow);
187
-
188
- for (let i = 0; i < maxCells; i++) {
189
- tableRow.append(i < cells.length ? cells[i] : createTableCell(null));
190
- }
191
- }
192
- return table;
193
- };
@@ -1,16 +0,0 @@
1
- import { $isAtNodeEnd } from '@lexical/selection';
2
- import { ElementNode, RangeSelection, TextNode } from 'lexical';
3
-
4
- export function getSelectedNode(selection: RangeSelection): TextNode | ElementNode {
5
- const { anchor, focus } = selection;
6
- const anchorNode = selection.anchor.getNode();
7
- const focusNode = selection.focus.getNode();
8
- if (anchorNode === focusNode) {
9
- return anchorNode;
10
- }
11
- const isBackward = selection.isBackward();
12
- if (isBackward) {
13
- return $isAtNodeEnd(focus) ? anchorNode : focusNode;
14
- }
15
- return $isAtNodeEnd(anchor) ? focusNode : anchorNode;
16
- }
package/tsconfig.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.bundle.json",
3
- "compilerOptions": {
4
- "rootDir": "./src",
5
- "outDir": "./dist"
6
- },
7
- "include": ["src"]
8
- }