@jpmorganchase/mosaic-content-editor-plugin 0.1.0-beta.72 → 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 (70) hide show
  1. package/package.json +6 -3
  2. package/.turbo/turbo-build.log +0 -4
  3. package/CHANGELOG.md +0 -687
  4. package/src/components/ActionMenu/ActionMenu.css.ts +0 -9
  5. package/src/components/ActionMenu/ActionMenu.tsx +0 -26
  6. package/src/components/BaseToolbar/BaseToolbar.css.ts +0 -21
  7. package/src/components/BaseToolbar/BaseToolbar.tsx +0 -13
  8. package/src/components/BaseTooltray/BaseTooltray.css.ts +0 -31
  9. package/src/components/BaseTooltray/BaseTooltray.tsx +0 -22
  10. package/src/components/ContentEditor.tsx +0 -14
  11. package/src/components/Dialog.css.ts +0 -7
  12. package/src/components/Dialog.tsx +0 -12
  13. package/src/components/Editor.css.ts +0 -64
  14. package/src/components/Editor.tsx +0 -145
  15. package/src/components/EditorControls.css.ts +0 -6
  16. package/src/components/EditorControls.tsx +0 -37
  17. package/src/components/LinkEditor/EditLinkButton.tsx +0 -9
  18. package/src/components/LinkEditor/LinkEditor.css.ts +0 -15
  19. package/src/components/LinkEditor/LinkEditor.tsx +0 -136
  20. package/src/components/LinkEditor/SaveAdornment.tsx +0 -17
  21. package/src/components/PersistEditDialog/PersistStatus.css.ts +0 -21
  22. package/src/components/PersistEditDialog/PersistStatus.tsx +0 -57
  23. package/src/components/PersistEditDialog/__tests__/index.test.tsx +0 -90
  24. package/src/components/PersistEditDialog/index.css.ts +0 -14
  25. package/src/components/PersistEditDialog/index.tsx +0 -152
  26. package/src/components/Popper/Popper.css.ts +0 -12
  27. package/src/components/Popper/Popper.tsx +0 -36
  28. package/src/components/SaveButton.tsx +0 -23
  29. package/src/components/ScrollableSection/ScrollableSection.css.ts +0 -10
  30. package/src/components/ScrollableSection/ScrollableSection.tsx +0 -20
  31. package/src/components/StatusBanner.tsx +0 -16
  32. package/src/components/Toolbar/InsertBlockDropdown.tsx +0 -134
  33. package/src/components/Toolbar/InsertHorizontalRule.tsx +0 -18
  34. package/src/components/Toolbar/InsertImage.css.ts +0 -7
  35. package/src/components/Toolbar/InsertImage.tsx +0 -138
  36. package/src/components/Toolbar/InsertLink.css.ts +0 -7
  37. package/src/components/Toolbar/InsertLink.tsx +0 -148
  38. package/src/components/Toolbar/InsertTable.css.ts +0 -52
  39. package/src/components/Toolbar/InsertTable.tsx +0 -196
  40. package/src/components/Toolbar/TextFormatTooltray.css.ts +0 -22
  41. package/src/components/Toolbar/TextFormatTooltray.tsx +0 -113
  42. package/src/components/Toolbar/Toolbar.tsx +0 -52
  43. package/src/components/Toolbar/ToolbarButton.css.ts +0 -11
  44. package/src/components/Toolbar/ToolbarButton.tsx +0 -41
  45. package/src/components/Toolbar/ToolbarSeparator.css.ts +0 -28
  46. package/src/components/Toolbar/ToolbarSepartor.tsx +0 -13
  47. package/src/components/__tests__/EditorControls.test.tsx +0 -69
  48. package/src/components/__tests__/StatusBanner.test.tsx +0 -33
  49. package/src/hooks/useEditHistory.ts +0 -49
  50. package/src/hooks/useWorkflowFeed.ts +0 -69
  51. package/src/index.ts +0 -5
  52. package/src/nodes/index.ts +0 -23
  53. package/src/plugins/FloatingToolbarPlugin.css.ts +0 -14
  54. package/src/plugins/FloatingToolbarPlugin.tsx +0 -101
  55. package/src/plugins/HorizontalRulePlugin.tsx +0 -39
  56. package/src/plugins/MarkdownImagePlugin.tsx +0 -58
  57. package/src/plugins/MarkdownLinkPlugin.tsx +0 -69
  58. package/src/plugins/PreviewPlugin.tsx +0 -71
  59. package/src/plugins/TableActionMenuPlugin.css.ts +0 -29
  60. package/src/plugins/TableActionMenuPlugin.tsx +0 -274
  61. package/src/store/__tests__/index.test.ts +0 -171
  62. package/src/store/index.ts +0 -84
  63. package/src/theme/index.css.ts +0 -39
  64. package/src/theme/index.ts +0 -22
  65. package/src/transformers/horizontalRule.ts +0 -25
  66. package/src/transformers/index.ts +0 -6
  67. package/src/transformers/link.ts +0 -3
  68. package/src/transformers/tableRule.ts +0 -193
  69. package/src/utils/getSelectedNode.ts +0 -16
  70. package/tsconfig.json +0 -8
@@ -1,148 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
3
- import { Button, Icon } from '@jpmorganchase/mosaic-components';
4
- import { string, object } from 'yup';
5
- import {
6
- Input,
7
- FormField,
8
- FormFieldLabel,
9
- FormFieldHelperText,
10
- DialogContent,
11
- DialogActions,
12
- DialogHeader
13
- } from '@salt-ds/core';
14
- import { ButtonBar } from '@salt-ds/lab';
15
- import { $getSelection, $isRangeSelection } from 'lexical';
16
-
17
- import { ToolbarButton } from './ToolbarButton';
18
- import { Dialog } from '../Dialog';
19
- import { INSERT_MARKDOWN_LINK_COMMAND, InsertLinkPayload } from '../../plugins/MarkdownLinkPlugin';
20
- import { useIsInsertingLink } from '../../store';
21
- import styles from './InsertLink.css';
22
-
23
- const validationSchema = object({
24
- url: string().required('Url is required'),
25
- text: string().required('Text is required').max(100, 'Text must be fewer than 100 characters')
26
- });
27
-
28
- export const InsertLinkButton = () => {
29
- const { isInsertingLink, setIsInsertingLink } = useIsInsertingLink();
30
- return (
31
- <ToolbarButton
32
- active={isInsertingLink}
33
- onClick={() => setIsInsertingLink(true)}
34
- label="Insert Link"
35
- >
36
- <Icon name="linked" />
37
- </ToolbarButton>
38
- );
39
- };
40
-
41
- const initialState = {
42
- url: 'https://',
43
- text: ''
44
- };
45
-
46
- type FormValueState =
47
- | {
48
- text?: string;
49
- url?: string;
50
- }
51
- | undefined;
52
-
53
- type FormErrorState =
54
- | {
55
- text?: string;
56
- url?: string;
57
- }
58
- | undefined;
59
-
60
- export const InsertLinkDialog = () => {
61
- const [editor] = useLexicalComposerContext();
62
- const { isInsertingLink, setIsInsertingLink } = useIsInsertingLink();
63
- const [values, setValues] = useState<FormValueState>(initialState);
64
- const [errors, setErrors] = useState<FormErrorState>();
65
-
66
- const handleOpenChange = (open: boolean) => {
67
- setIsInsertingLink(open);
68
- if (!open) {
69
- setErrors(undefined);
70
- setValues(initialState);
71
- }
72
- };
73
-
74
- const handleClose = () => {
75
- handleOpenChange(false);
76
- };
77
-
78
- useEffect(() => {
79
- editor.getEditorState().read(() => {
80
- if (isInsertingLink) {
81
- const selection = $getSelection();
82
- if ($isRangeSelection(selection)) {
83
- const textContent = selection.getTextContent();
84
- setValues(prevState => ({ ...prevState, text: textContent }));
85
- }
86
- }
87
- });
88
- }, [editor, isInsertingLink]);
89
-
90
- const processErrors = validationErrors => {
91
- const newErrors = validationErrors.inner.reduce(
92
- (acc, { path, message }) => ({
93
- ...acc,
94
- [path]: message
95
- }),
96
- {}
97
- );
98
- setErrors(newErrors);
99
- };
100
-
101
- const handleChange = event => {
102
- const { name, value } = event.target;
103
- const newValues = { ...values, [name]: value };
104
- validationSchema.validateAt(name, newValues, { abortEarly: false }).then(() => {
105
- setErrors({ ...errors, [name]: undefined });
106
- }, processErrors);
107
- setValues(newValues);
108
- };
109
-
110
- const handleSubmit = async () => {
111
- validationSchema.validate(values, { abortEarly: false }).then(() => {
112
- const payload: InsertLinkPayload = {
113
- url: values?.url,
114
- text: values?.text
115
- };
116
- editor.dispatchCommand(INSERT_MARKDOWN_LINK_COMMAND, payload);
117
- handleClose();
118
- }, processErrors);
119
- };
120
-
121
- return (
122
- <Dialog onOpenChange={handleOpenChange} open={isInsertingLink}>
123
- <DialogHeader header="Insert Link" />
124
- <DialogContent>
125
- <div className={styles.fullWidth}>
126
- <FormField validationStatus={errors?.url ? 'error' : undefined}>
127
- <FormFieldLabel>Image URL text</FormFieldLabel>
128
- <Input value={values?.url} inputProps={{ name: 'url' }} onChange={handleChange} />
129
- <FormFieldHelperText>{errors?.url}</FormFieldHelperText>
130
- </FormField>
131
- <FormField validationStatus={errors?.text ? 'error' : undefined}>
132
- <FormFieldLabel>Link Text</FormFieldLabel>
133
- <Input value={values?.text} inputProps={{ name: 'text' }} onChange={handleChange} />
134
- <FormFieldHelperText>{errors?.text}</FormFieldHelperText>
135
- </FormField>
136
- </div>
137
- </DialogContent>
138
- <DialogActions>
139
- <ButtonBar>
140
- <Button onClick={handleClose}>Cancel</Button>
141
- <Button variant="cta" onClick={handleSubmit}>
142
- Insert
143
- </Button>
144
- </ButtonBar>
145
- </DialogActions>
146
- </Dialog>
147
- );
148
- };
@@ -1,52 +0,0 @@
1
- import { globalStyle, style } from '@vanilla-extract/css';
2
- import {
3
- selectableColor,
4
- table,
5
- neutralBorder,
6
- vars,
7
- backgroundColor,
8
- foregroundColor
9
- } from '@jpmorganchase/mosaic-theme';
10
-
11
- const button = style({ width: vars.space.horizontal.x10 });
12
-
13
- export default {
14
- tableContainer: style({
15
- position: 'relative',
16
- margin: vars.space.horizontal.x2
17
- }),
18
- table: table({ context: 'component' }),
19
- addColumnArea: style({
20
- position: 'absolute',
21
- top: 0,
22
- width: '25px'
23
- }),
24
- addRowArea: style({
25
- position: 'absolute',
26
- left: 0,
27
- height: '25px'
28
- }),
29
- headerRow: selectableColor({ variant: 'inEdit' }),
30
- row: selectableColor({ variant: 'hover' }),
31
- cell: style([
32
- neutralBorder({
33
- variant: 'high',
34
- borderWidth: 'thin'
35
- })
36
- ]),
37
- dimensions: style([
38
- style({
39
- display: 'flex',
40
- justifyContent: 'center',
41
- alignItems: 'center',
42
- paddingTop: vars.space.vertical.x2
43
- }),
44
- foregroundColor({ variant: 'high' })
45
- ]),
46
- popper: style([style({ zIndex: 1600 }), backgroundColor({ variant: 'regular' })]),
47
- button
48
- };
49
-
50
- globalStyle(`${button} > *:not(:first-child)`, {
51
- marginLeft: vars.space.horizontal.x1
52
- });
@@ -1,196 +0,0 @@
1
- import React, { ReactElement, FC, ReactNode, MouseEventHandler, useRef, useState } from 'react';
2
- import { Icon } from '@jpmorganchase/mosaic-components';
3
- import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
4
- import { INSERT_TABLE_COMMAND } from '@lexical/table';
5
-
6
- import { useFloatingUI } from '@salt-ds/core';
7
- import { useDismiss, useInteractions } from '@floating-ui/react';
8
- import { Popper } from '../Popper/Popper';
9
- import { ToolbarButton } from './ToolbarButton';
10
- import styles from './InsertTable.css';
11
-
12
- interface IndexableEntity {
13
- children?: ReactNode;
14
- index: number;
15
- }
16
-
17
- const Cell: FC<IndexableEntity> = ({ index, ...rest }) => (
18
- <td className={styles.cell} data-column={index} {...rest} />
19
- );
20
-
21
- const Row: FC<IndexableEntity> = ({ children, index }) => (
22
- <tr className={index === 1 ? styles.headerRow : styles.row} data-row={index}>
23
- {children}
24
- </tr>
25
- );
26
-
27
- interface TableBodyProps {
28
- rowCount: number;
29
- columnCount: number;
30
- }
31
-
32
- const TableBody: FC<TableBodyProps> = ({ rowCount, columnCount }) => {
33
- const cells: ReactElement[] = [];
34
- const rows: ReactElement[] = [];
35
- for (let i = 1; i <= columnCount; i++) {
36
- cells.push(<Cell key={i} index={i} />);
37
- }
38
-
39
- for (let i = 1; i <= rowCount; i++) {
40
- rows.push(
41
- <Row key={i} index={i}>
42
- {cells}
43
- </Row>
44
- );
45
- }
46
- return <tbody>{rows}</tbody>;
47
- };
48
-
49
- function getPosition(node: HTMLElement) {
50
- const columnIndex = parseInt(node?.dataset?.column || '0', 10);
51
- const parentRow = node.parentNode as HTMLTableRowElement;
52
- const rowIndex = parseInt(parentRow?.dataset?.row || '0', 10);
53
-
54
- return { columnIndex, rowIndex };
55
- }
56
-
57
- interface InsertTableProps {
58
- minRows?: number;
59
- minColumns?: number;
60
- maxColumns?: number;
61
- initialRowCount?: number;
62
- initialColumnCount?: number;
63
- }
64
-
65
- export const InsertTable: FC<InsertTableProps> = ({
66
- minRows = 2,
67
- minColumns = 2,
68
- maxColumns = 10,
69
- initialRowCount = 4,
70
- initialColumnCount = 4
71
- }) => {
72
- const [editor] = useLexicalComposerContext();
73
- const tableRef = useRef<HTMLTableElement>(null);
74
- const boundaryTouchedRef = useRef(false);
75
- const [columnCount, setColumnCount] = useState(initialColumnCount);
76
- const [rowCount, setRowCount] = useState(initialRowCount);
77
- const [isOpen, setIsOpen] = useState(false);
78
-
79
- const togglePopper = () => {
80
- reset();
81
- setIsOpen(prevState => !prevState);
82
- };
83
-
84
- const { context, floating, reference, strategy, x, y } = useFloatingUI({
85
- placement: 'bottom',
86
- strategy: 'absolute',
87
- open: isOpen,
88
- onOpenChange: togglePopper
89
- });
90
-
91
- const { getFloatingProps } = useInteractions([
92
- useDismiss(context, {
93
- ancestorScroll: true
94
- })
95
- ]);
96
-
97
- const handleCellMouseOver: MouseEventHandler<HTMLDivElement> = event => {
98
- const target = event.nativeEvent.target as HTMLElement;
99
- if (!tableRef.current?.contains(target) || !boundaryTouchedRef.current) {
100
- return;
101
- }
102
-
103
- const { columnIndex, rowIndex } = getPosition(target);
104
-
105
- if (columnIndex < columnCount && columnIndex >= minColumns) {
106
- setColumnCount(columnIndex);
107
- }
108
- if (rowIndex < rowCount && rowIndex >= minRows) {
109
- setRowCount(rowIndex);
110
- }
111
- };
112
-
113
- function reset() {
114
- setColumnCount(initialColumnCount);
115
- setRowCount(initialRowCount);
116
- boundaryTouchedRef.current = false;
117
- }
118
-
119
- const addColumn = () => {
120
- boundaryTouchedRef.current = true;
121
- if (columnCount + 1 <= maxColumns) {
122
- setColumnCount(prevState => prevState + 1);
123
- }
124
- };
125
-
126
- const addRow = () => {
127
- boundaryTouchedRef.current = true;
128
- setRowCount(prevState => prevState + 1);
129
- };
130
-
131
- const handleSelect = () => {
132
- editor.dispatchCommand(INSERT_TABLE_COMMAND, {
133
- columns: columnCount.toString(),
134
- rows: rowCount.toString()
135
- });
136
- reset();
137
- setIsOpen(false);
138
- };
139
-
140
- const cellSize = 25;
141
- const tableHeight = rowCount * cellSize;
142
- const tableWidth = columnCount * cellSize;
143
-
144
- return (
145
- <>
146
- <ToolbarButton
147
- className={styles.button}
148
- ref={reference}
149
- onClick={togglePopper}
150
- active={isOpen}
151
- label="Insert Table"
152
- >
153
- <Icon name="grid" />
154
- <Icon name="chevronDown" />
155
- </ToolbarButton>
156
- <Popper
157
- className={styles.popper}
158
- ref={floating}
159
- open={isOpen}
160
- style={{ top: y ?? '', left: x ?? '', position: strategy }}
161
- {...getFloatingProps({})}
162
- >
163
- <div
164
- className={styles.tableContainer}
165
- onMouseOver={handleCellMouseOver}
166
- onClick={handleSelect}
167
- >
168
- <table
169
- className={styles.table}
170
- style={{ width: tableWidth, height: tableHeight }}
171
- ref={tableRef}
172
- >
173
- <TableBody rowCount={rowCount} columnCount={columnCount} />
174
- </table>
175
- <div className={styles.dimensions}>{`${columnCount} x ${rowCount}`}</div>
176
- <div
177
- className={styles.addColumnArea}
178
- style={{
179
- left: tableWidth,
180
- height: tableHeight + cellSize
181
- }}
182
- onMouseOver={addColumn}
183
- />
184
- <div
185
- className={styles.addRowArea}
186
- style={{
187
- top: tableHeight,
188
- width: tableWidth + cellSize
189
- }}
190
- onMouseOver={addRow}
191
- />
192
- </div>
193
- </Popper>
194
- </>
195
- );
196
- };
@@ -1,22 +0,0 @@
1
- import { style } from '@vanilla-extract/css';
2
- import { vars, code } from '@jpmorganchase/mosaic-theme';
3
-
4
- export default {
5
- icon: style({
6
- width: '14px',
7
- fontSize: '12px'
8
- }),
9
- bold: style({ fontWeight: vars.fontWeight.bold }),
10
- italic: style({ fontStyle: 'italic' }),
11
- code: style([
12
- code({ variant: 'regular' }),
13
- style({
14
- width: '22px',
15
- height: '18px',
16
- backgroundColor: 'inherit!important',
17
- display: 'inline-flex',
18
- justifyContent: 'center',
19
- alignItems: 'center'
20
- })
21
- ])
22
- };
@@ -1,113 +0,0 @@
1
- import React, { useCallback, useEffect, useState } from 'react';
2
- import classnames from 'clsx';
3
- import {
4
- FORMAT_TEXT_COMMAND,
5
- SELECTION_CHANGE_COMMAND,
6
- COMMAND_PRIORITY_CRITICAL,
7
- $getSelection,
8
- $isRangeSelection,
9
- TextFormatType
10
- } from 'lexical';
11
- import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
12
- import { $isListNode, ListNode } from '@lexical/list';
13
- import { $getNearestNodeOfType } from '@lexical/utils';
14
- import { $isHeadingNode } from '@lexical/rich-text';
15
- import { $isCodeNode } from '@lexical/code';
16
- import { Icon } from '@jpmorganchase/mosaic-components';
17
-
18
- import { BaseTooltray as Tooltray } from '../BaseTooltray/BaseTooltray';
19
- import { ToolbarButton } from './ToolbarButton';
20
- import styles from './TextFormatTooltray.css';
21
- import { InsertBlockDropdown } from './InsertBlockDropdown';
22
-
23
- export function TextFormatTooltray({ floating = false }) {
24
- const [editor] = useLexicalComposerContext();
25
- const [activeEditor, setActiveEditor] = useState(editor);
26
- const [isBold, setIsBold] = useState(false);
27
- const [isItalic, setIsItalic] = useState(false);
28
- const [isCode, setIsCode] = useState(false);
29
- const [blockType, setBlockType] = useState<string>('paragraph');
30
-
31
- const handleFormat = (format: TextFormatType) => {
32
- activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND, format);
33
- };
34
- const updateToolbar = useCallback(() => {
35
- const selection = $getSelection();
36
- if ($isRangeSelection(selection)) {
37
- setIsBold(selection.hasFormat('bold'));
38
- setIsItalic(selection.hasFormat('italic'));
39
- setIsCode(selection.hasFormat('code'));
40
-
41
- const anchorNode = selection.anchor.getNode();
42
- const element =
43
- anchorNode.getKey() === 'root' ? anchorNode : anchorNode.getTopLevelElementOrThrow();
44
- const elementKey = element.getKey();
45
- const elementDOM = activeEditor.getElementByKey(elementKey);
46
-
47
- if (elementDOM !== null) {
48
- if ($isListNode(element)) {
49
- const parentList = $getNearestNodeOfType<ListNode>(anchorNode, ListNode);
50
- const type = parentList ? parentList.getListType() : element.getListType();
51
- setBlockType(type);
52
- } else {
53
- const type = $isHeadingNode(element) ? element.getTag() : element.getType();
54
- if (type) {
55
- setBlockType(type);
56
- }
57
- if ($isCodeNode(element)) {
58
- setIsCode(true);
59
- }
60
- }
61
- }
62
- }
63
- }, [activeEditor]);
64
-
65
- useEffect(
66
- () =>
67
- activeEditor.registerUpdateListener(({ editorState }) => {
68
- editorState.read(() => {
69
- updateToolbar();
70
- });
71
- }),
72
-
73
- [activeEditor, updateToolbar]
74
- );
75
-
76
- useEffect(
77
- () =>
78
- editor.registerCommand(
79
- SELECTION_CHANGE_COMMAND,
80
- (_payload, newEditor) => {
81
- updateToolbar();
82
- setActiveEditor(newEditor);
83
- return false;
84
- },
85
- COMMAND_PRIORITY_CRITICAL
86
- ),
87
- [editor, updateToolbar]
88
- );
89
-
90
- return (
91
- <>
92
- {!floating && (
93
- <Tooltray>
94
- <InsertBlockDropdown editor={activeEditor} type={blockType} />
95
- </Tooltray>
96
- )}
97
- <Tooltray>
98
- <ToolbarButton active={isBold} onClick={() => handleFormat('bold')} label="Bold">
99
- <span className={classnames(styles.icon, styles.bold)}>B</span>
100
- </ToolbarButton>
101
- <ToolbarButton active={isItalic} onClick={() => handleFormat('italic')} label="Italic">
102
- <span className={classnames(styles.icon, styles.italic)}>I</span>
103
- </ToolbarButton>
104
- <ToolbarButton active={isCode} onClick={() => handleFormat('code')} label="Inline Code">
105
- <span className={classnames(styles.code)}>
106
- <Icon name="chevronLeft" />
107
- <Icon name="chevronRight" />
108
- </span>
109
- </ToolbarButton>
110
- </Tooltray>
111
- </>
112
- );
113
- }
@@ -1,52 +0,0 @@
1
- import React from 'react';
2
- import { Icon } from '@jpmorganchase/mosaic-components';
3
- import { useEditHistory } from '../../hooks/useEditHistory';
4
- import { usePageState } from '../../store';
5
- import { SaveButton } from '../SaveButton';
6
- import { TextFormatTooltray } from './TextFormatTooltray';
7
- import { InsertTable } from './InsertTable';
8
- import { InsertImage } from './InsertImage';
9
- import { InsertLinkButton } from './InsertLink';
10
- import { InsertHorizontalRule } from './InsertHorizontalRule';
11
- import { BaseToolbar } from '../BaseToolbar/BaseToolbar';
12
- import { BaseTooltray as Tooltray } from '../BaseTooltray/BaseTooltray';
13
- import { ToolbarButton } from './ToolbarButton';
14
- import { ToolbarSeparator } from './ToolbarSepartor';
15
-
16
- const Toolbar = () => {
17
- const { canRedo, canUndo, redoEdit, undoEdit } = useEditHistory();
18
- const { setPageState } = usePageState();
19
-
20
- return (
21
- <BaseToolbar aria-label="page editing toolbar">
22
- <Tooltray aria-label="history tooltray">
23
- <ToolbarButton label="Undo" disabled={!canUndo} onClick={undoEdit}>
24
- <Icon name="undo" />
25
- </ToolbarButton>
26
- <ToolbarButton label="Redo" disabled={!canRedo} onClick={redoEdit}>
27
- <Icon name="redo" />
28
- </ToolbarButton>
29
- <ToolbarSeparator />
30
- </Tooltray>
31
- <TextFormatTooltray />
32
- <Tooltray aria-label="text format tooltray">
33
- <InsertLinkButton />
34
- <InsertTable />
35
- <InsertImage />
36
- <InsertHorizontalRule />
37
- <ToolbarSeparator />
38
- </Tooltray>
39
- <Tooltray aria-label="stop editing tooltray" align="right">
40
- <ToolbarButton label="Cancel Editing" onClick={() => setPageState('VIEW')}>
41
- <Icon name="delete" />
42
- </ToolbarButton>
43
- <ToolbarSeparator />
44
- </Tooltray>
45
- <Tooltray aria-label="copy tooltray">
46
- <SaveButton />
47
- </Tooltray>
48
- </BaseToolbar>
49
- );
50
- };
51
-
52
- export default Toolbar;
@@ -1,11 +0,0 @@
1
- import { style } from '@vanilla-extract/css';
2
- import { vars } from '@jpmorganchase/mosaic-theme';
3
-
4
- export default {
5
- root: style({
6
- width: '28px',
7
- height: '28px',
8
- lineHeight: 1,
9
- padding: vars.space.horizontal.none
10
- })
11
- };
@@ -1,41 +0,0 @@
1
- import React, { forwardRef, Ref } from 'react';
2
- import classnames from 'clsx';
3
- import { Button, type ButtonProps, Label } from '@jpmorganchase/mosaic-components';
4
-
5
- import styles from './ToolbarButton.css';
6
-
7
- export interface ToolbarButtonProps extends ButtonProps {
8
- active?: boolean;
9
- label?: string;
10
- disableTooltip?: boolean;
11
- }
12
-
13
- export const ToolbarButton = forwardRef(
14
- (
15
- {
16
- active,
17
- className,
18
- onClick,
19
- children,
20
- label,
21
- disabled,
22
- disableTooltip = disabled,
23
- ...rest
24
- }: ToolbarButtonProps,
25
- ref: Ref<HTMLButtonElement>
26
- ) => (
27
- <Label tooltip={!disableTooltip} TooltipProps={{ title: label, placement: 'bottom' }}>
28
- <Button
29
- aria-label={label}
30
- ref={ref}
31
- onClick={onClick}
32
- className={classnames(className, styles.root)}
33
- variant={active ? 'regular' : 'secondary'}
34
- disabled={disabled}
35
- {...rest}
36
- >
37
- {children}
38
- </Button>
39
- </Label>
40
- )
41
- );
@@ -1,28 +0,0 @@
1
- import { style } from '@vanilla-extract/css';
2
- import { vars, beforeElementColorSprinkles } from '@jpmorganchase/mosaic-theme';
3
-
4
- const beforeElementBackground = beforeElementColorSprinkles({
5
- backgroundColor: {
6
- lightMode: vars.color.dark.neutral.foreground.low,
7
- darkMode: vars.color.light.neutral.foreground.low
8
- }
9
- });
10
-
11
- export default {
12
- root: style([
13
- beforeElementBackground,
14
- style({
15
- selectors: {
16
- '&:before': {
17
- content: '""',
18
- position: 'absolute',
19
- background: 'inherit',
20
- top: '6px',
21
- right: 0,
22
- width: '1px',
23
- height: vars.space.vertical.x6
24
- }
25
- }
26
- })
27
- ])
28
- };
@@ -1,13 +0,0 @@
1
- import React, { type ReactNode } from 'react';
2
- import classnames from 'clsx';
3
-
4
- import styles from './ToolbarSeparator.css';
5
-
6
- interface ToolbarSeparatorProps {
7
- className?: string;
8
- children?: ReactNode;
9
- }
10
-
11
- export const ToolbarSeparator = ({ className, ...rest }: ToolbarSeparatorProps) => (
12
- <div className={classnames(className, styles.root)} {...rest} />
13
- );