@atlaskit/editor-common 103.11.2 → 103.12.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 (38) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/afm-cc/tsconfig.json +3 -0
  3. package/dist/cjs/analytics/types/enums.js +1 -0
  4. package/dist/cjs/monitoring/error.js +1 -1
  5. package/dist/cjs/ui/DropList/index.js +1 -1
  6. package/dist/cjs/ui/TableSelector/index.js +270 -0
  7. package/dist/cjs/ui/TableSelector/table-selector.js +162 -0
  8. package/dist/cjs/ui/WidthProvider/index.js +1 -0
  9. package/dist/cjs/ui/index.js +7 -0
  10. package/dist/cjs/utils/get-dom-ref-from-selection.js +38 -0
  11. package/dist/es2019/analytics/types/enums.js +1 -0
  12. package/dist/es2019/monitoring/error.js +1 -1
  13. package/dist/es2019/ui/DropList/index.js +1 -1
  14. package/dist/es2019/ui/TableSelector/index.js +265 -0
  15. package/dist/es2019/ui/TableSelector/table-selector.js +154 -0
  16. package/dist/es2019/ui/WidthProvider/index.js +1 -0
  17. package/dist/es2019/ui/index.js +2 -1
  18. package/dist/es2019/utils/get-dom-ref-from-selection.js +32 -0
  19. package/dist/esm/analytics/types/enums.js +1 -0
  20. package/dist/esm/monitoring/error.js +1 -1
  21. package/dist/esm/ui/DropList/index.js +1 -1
  22. package/dist/esm/ui/TableSelector/index.js +264 -0
  23. package/dist/esm/ui/TableSelector/table-selector.js +154 -0
  24. package/dist/esm/ui/WidthProvider/index.js +1 -0
  25. package/dist/esm/ui/index.js +2 -1
  26. package/dist/esm/utils/get-dom-ref-from-selection.js +32 -0
  27. package/dist/types/analytics/types/enums.d.ts +1 -0
  28. package/dist/types/ui/TableSelector/index.d.ts +28 -0
  29. package/dist/types/ui/TableSelector/table-selector.d.ts +31 -0
  30. package/dist/types/ui/index.d.ts +1 -0
  31. package/dist/types/utils/get-dom-ref-from-selection.d.ts +4 -0
  32. package/dist/types-ts4.5/analytics/types/enums.d.ts +1 -0
  33. package/dist/types-ts4.5/ui/TableSelector/index.d.ts +28 -0
  34. package/dist/types-ts4.5/ui/TableSelector/table-selector.d.ts +31 -0
  35. package/dist/types-ts4.5/ui/index.d.ts +1 -0
  36. package/dist/types-ts4.5/utils/get-dom-ref-from-selection.d.ts +4 -0
  37. package/get-dom-ref-from-selection/package.json +17 -0
  38. package/package.json +7 -2
@@ -0,0 +1,265 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+
6
+ import { useCallback, useEffect, useRef, useState } from 'react';
7
+
8
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
9
+ import { css, jsx } from '@emotion/react';
10
+ import { bind } from 'bind-event-listener';
11
+ import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
12
+ import { fg } from '@atlaskit/platform-feature-flags';
13
+ import { N0, N30A, N60A } from '@atlaskit/theme/colors';
14
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
15
+ import { withReactEditorViewOuterListeners as withOuterListeners } from '../../ui-react';
16
+ import Popup from '../Popup';
17
+ import tableSelectorPopup, { TABLE_SELECTOR_BUTTON_GAP, TABLE_SELECTOR_BUTTON_SIZE } from './table-selector';
18
+ const TABLE_SELECTOR_PADDING_TOP = 8;
19
+ const TABLE_SELECTOR_PADDING_SIDE = 10;
20
+ const DEFAULT_TABLE_SELECTOR_ROWS = 5;
21
+ const DEFAULT_TABLE_SELECTOR_COLS = 10;
22
+ const DEFAULT_TABLE_SELECTOR_SELECTION_SIZE = 1;
23
+ const DEFAULT_MAX_TABLE_SELECTOR_ROWS = 10;
24
+ const TableSelectorWithListeners = withOuterListeners(tableSelectorPopup);
25
+ const initialSizeState = {
26
+ col: DEFAULT_TABLE_SELECTOR_SELECTION_SIZE,
27
+ row: DEFAULT_TABLE_SELECTOR_SELECTION_SIZE,
28
+ maxCol: DEFAULT_TABLE_SELECTOR_COLS,
29
+ maxRow: DEFAULT_TABLE_SELECTOR_ROWS
30
+ };
31
+ const tableSelectorPopupWrapperStyles = css({
32
+ borderRadius: "var(--ds-border-radius, 3px)",
33
+ backgroundColor: `var(--ds-surface-overlay, ${N0})`,
34
+ boxShadow: `var(--ds-shadow-overlay, ${`0 0 0 1px ${N30A}, 0 2px 1px ${N30A}, 0 0 20px -6px ${N60A}`})`,
35
+ padding: `${`var(--ds-space-100, ${`${TABLE_SELECTOR_PADDING_TOP}px`})`} ${TABLE_SELECTOR_PADDING_SIDE}px`
36
+ });
37
+ export const TableSelectorPopup = props => {
38
+ const [size, setSize] = useState({
39
+ ...initialSizeState,
40
+ ...props.defaultSize
41
+ });
42
+ const tablePopupRef = useRef(null);
43
+ // If popup opened by keyboard enable keyboard mode
44
+ const isKeyboardMode = useRef(props.isOpenedByKeyboard);
45
+ const enableKeyboardMode = useCallback(() => {
46
+ if (!isKeyboardMode.current) {
47
+ isKeyboardMode.current = true;
48
+ }
49
+ }, [isKeyboardMode]);
50
+ const disableKeyboardMode = useCallback(() => {
51
+ if (isKeyboardMode.current) {
52
+ isKeyboardMode.current = false;
53
+ }
54
+ }, [isKeyboardMode]);
55
+
56
+ // Mouse move is used to allow selection changes outside of the popup and is more reactive to changes.
57
+ const handleMouseMove = useCallback(e => {
58
+ if (!tablePopupRef.current) {
59
+ return;
60
+ }
61
+ disableKeyboardMode();
62
+ const tablePopup = tablePopupRef.current;
63
+ const {
64
+ left,
65
+ top
66
+ } = tablePopup.getBoundingClientRect();
67
+
68
+ // Mouse position on popup
69
+ const selectedWidth = e.clientX - left;
70
+ const selectedHeight = e.clientY - top;
71
+
72
+ // Calculate number grid cells selected
73
+ let selectedGridCols = Math.ceil((selectedWidth - TABLE_SELECTOR_PADDING_SIDE + TABLE_SELECTOR_BUTTON_GAP) / (TABLE_SELECTOR_BUTTON_GAP + TABLE_SELECTOR_BUTTON_SIZE));
74
+ let selectedGridRows = Math.ceil((selectedHeight - TABLE_SELECTOR_PADDING_TOP + TABLE_SELECTOR_BUTTON_GAP) / (TABLE_SELECTOR_BUTTON_GAP + TABLE_SELECTOR_BUTTON_SIZE));
75
+ // Keep the selected rows and columns within the defined bounds
76
+ let gridRows = DEFAULT_TABLE_SELECTOR_ROWS;
77
+ if (selectedGridCols < 1) {
78
+ selectedGridCols = 1;
79
+ }
80
+ if (selectedGridCols > size.maxCol) {
81
+ selectedGridCols = size.maxCol;
82
+ }
83
+ if (selectedGridRows < 1) {
84
+ selectedGridRows = 1;
85
+ }
86
+
87
+ // Expand grid when row selection is greater than the default grid size
88
+ if (selectedGridRows >= DEFAULT_TABLE_SELECTOR_ROWS && selectedGridRows < DEFAULT_MAX_TABLE_SELECTOR_ROWS) {
89
+ gridRows = selectedGridRows + 1;
90
+ }
91
+ if (selectedGridRows >= DEFAULT_MAX_TABLE_SELECTOR_ROWS) {
92
+ selectedGridRows = DEFAULT_MAX_TABLE_SELECTOR_ROWS;
93
+ gridRows = DEFAULT_MAX_TABLE_SELECTOR_ROWS;
94
+ }
95
+ if (selectedGridCols !== size.col || selectedGridRows !== size.row) {
96
+ setSize({
97
+ col: selectedGridCols,
98
+ row: selectedGridRows,
99
+ maxCol: DEFAULT_TABLE_SELECTOR_COLS,
100
+ maxRow: gridRows
101
+ });
102
+ }
103
+ }, [disableKeyboardMode, size, setSize]);
104
+ const decreasingSequence = (maxNumber, prevNumber) => {
105
+ let nextNumber = prevNumber - 1;
106
+ if (prevNumber === 1) {
107
+ nextNumber = maxNumber;
108
+ }
109
+ return nextNumber;
110
+ };
111
+ const getMaxRow = (prevSize, eventKey) => {
112
+ switch (eventKey) {
113
+ case 'ArrowDown':
114
+ // Expand the grid size when last row selected
115
+ if (prevSize.maxRow < DEFAULT_MAX_TABLE_SELECTOR_ROWS && prevSize.row >= DEFAULT_TABLE_SELECTOR_ROWS - 1) {
116
+ return prevSize.maxRow + 1;
117
+ }
118
+ if (prevSize.row === DEFAULT_MAX_TABLE_SELECTOR_ROWS) {
119
+ return DEFAULT_TABLE_SELECTOR_ROWS;
120
+ }
121
+ return prevSize.maxRow;
122
+ case 'ArrowLeft':
123
+ const moveToPrevRow = prevSize.col === 1 && prevSize.row > 1;
124
+ const moveToLastRow = prevSize.row === 1 && prevSize.col === 1;
125
+ // Expand the popup to max size when selected row wraps around to last row
126
+ if (moveToLastRow) {
127
+ return DEFAULT_MAX_TABLE_SELECTOR_ROWS;
128
+ }
129
+ // Decrease the popup when decreased row selection
130
+ if (prevSize.maxRow > DEFAULT_TABLE_SELECTOR_ROWS && moveToPrevRow) {
131
+ return prevSize.row;
132
+ }
133
+ return prevSize.maxRow;
134
+ case 'ArrowUp':
135
+ if (prevSize.row === 1) {
136
+ return DEFAULT_MAX_TABLE_SELECTOR_ROWS;
137
+ // Decrease the popup size when decreased row selection
138
+ } else if (prevSize.maxRow > DEFAULT_TABLE_SELECTOR_ROWS) {
139
+ return prevSize.row;
140
+ }
141
+ return prevSize.maxRow;
142
+ case 'ArrowRight':
143
+ const moveToNextRow = prevSize.col === DEFAULT_TABLE_SELECTOR_COLS;
144
+ const increaseMaxRow = prevSize.maxRow < DEFAULT_MAX_TABLE_SELECTOR_ROWS && moveToNextRow && prevSize.row + 1 === prevSize.maxRow;
145
+
146
+ // Decrease popup size for wrap around to selection 1 x 1
147
+ if (prevSize.row === DEFAULT_MAX_TABLE_SELECTOR_ROWS && prevSize.col === DEFAULT_TABLE_SELECTOR_COLS) {
148
+ return DEFAULT_TABLE_SELECTOR_ROWS;
149
+ // Decrease the popup size when decreased row selection
150
+ } else if (increaseMaxRow) {
151
+ return prevSize.maxRow + 1;
152
+ }
153
+ return prevSize.maxRow;
154
+ default:
155
+ return prevSize.maxRow;
156
+ }
157
+ };
158
+ const handleInitialButtonFocus = useCallback(() => {
159
+ if (isKeyboardMode.current !== true) {
160
+ enableKeyboardMode();
161
+ setSize(initialSizeState);
162
+ }
163
+ }, [enableKeyboardMode, setSize]);
164
+ const handleKeyDown = useCallback(
165
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
166
+ event => {
167
+ if (event.key === 'ArrowDown') {
168
+ enableKeyboardMode();
169
+ setSize(prevSize => {
170
+ return {
171
+ ...prevSize,
172
+ row: prevSize.row % prevSize.maxRow + 1,
173
+ maxRow: getMaxRow(prevSize, event.key)
174
+ };
175
+ });
176
+ if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_table_picker')) {
177
+ event.preventDefault();
178
+ }
179
+ }
180
+ if (event.key === 'ArrowRight') {
181
+ enableKeyboardMode();
182
+ setSize(prevSize => {
183
+ const moveToNextRow = prevSize.col === DEFAULT_TABLE_SELECTOR_COLS;
184
+ return {
185
+ ...prevSize,
186
+ col: prevSize.col % DEFAULT_TABLE_SELECTOR_COLS + 1,
187
+ row: moveToNextRow ? prevSize.row % prevSize.maxRow + 1 : prevSize.row,
188
+ maxRow: getMaxRow(prevSize, event.key)
189
+ };
190
+ });
191
+ }
192
+ if (event.key === 'ArrowLeft') {
193
+ enableKeyboardMode();
194
+ setSize(prevSize => {
195
+ const getRow = (prevRow, prevCol) => {
196
+ const row = prevRow;
197
+ // Move to previous row for wrap around
198
+ if (prevSize.col === 1 && prevSize.row > 1) {
199
+ return prevRow - 1;
200
+ // Increase the selection to max size when selected row and column wraps around
201
+ } else if (prevRow === 1 && prevCol === 1) {
202
+ return DEFAULT_MAX_TABLE_SELECTOR_ROWS;
203
+ }
204
+ return row;
205
+ };
206
+ return {
207
+ ...prevSize,
208
+ col: decreasingSequence(prevSize.maxCol, prevSize.col),
209
+ row: getRow(prevSize.row, prevSize.col),
210
+ maxRow: getMaxRow(prevSize, event.key)
211
+ };
212
+ });
213
+ }
214
+ if (event.key === 'ArrowUp') {
215
+ enableKeyboardMode();
216
+ setSize(prevSize => {
217
+ const moveToLastRow = prevSize.row === 1;
218
+ return {
219
+ ...prevSize,
220
+ row: moveToLastRow ? DEFAULT_MAX_TABLE_SELECTOR_ROWS : decreasingSequence(prevSize.maxRow, prevSize.row),
221
+ maxRow: getMaxRow(prevSize, event.key)
222
+ };
223
+ });
224
+ if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_table_picker')) {
225
+ event.preventDefault();
226
+ }
227
+ }
228
+ }, [enableKeyboardMode, setSize]);
229
+ useEffect(() => {
230
+ let unbind;
231
+ const target = props.allowOutsideSelection ? window : tablePopupRef.current;
232
+ if (target) {
233
+ unbind = bind(target, {
234
+ type: 'mousemove',
235
+ listener: handleMouseMove
236
+ });
237
+ }
238
+ return unbind;
239
+ }, [handleMouseMove, props.allowOutsideSelection, tablePopupRef]);
240
+ return jsx(Popup, {
241
+ target: props.target,
242
+ offset: [0, 3],
243
+ mountTo: props.popupsMountPoint,
244
+ boundariesElement: props.popupsBoundariesElement,
245
+ scrollableElement: props.popupsScrollableElement,
246
+ focusTrap: true,
247
+ onUnmount: props.onUnmount,
248
+ zIndex: akEditorMenuZIndex
249
+ }, jsx("div", {
250
+ css: tableSelectorPopupWrapperStyles,
251
+ ref: tablePopupRef
252
+ }, jsx(TableSelectorWithListeners, {
253
+ handleClickOutside: props.handleClickOutside,
254
+ handleEscapeKeydown: props.handleEscapeKeydown,
255
+ maxCols: size.maxCol,
256
+ maxRows: size.maxRow,
257
+ onSelection: props.onSelection,
258
+ selectedCol: size.col,
259
+ selectedRow: size.row,
260
+ onKeyDown: handleKeyDown,
261
+ isFocused: isKeyboardMode.current,
262
+ handleInitialButtonFocus: handleInitialButtonFocus
263
+ })));
264
+ };
265
+ export default TableSelectorPopup;
@@ -0,0 +1,154 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import { useContext, useEffect, useMemo, useRef } from 'react';
6
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
+ import { css, jsx } from '@emotion/react';
8
+ import { injectIntl } from 'react-intl-next';
9
+ import { fg } from '@atlaskit/platform-feature-flags';
10
+ import { Stack } from '@atlaskit/primitives';
11
+ import { B100 } from '@atlaskit/theme/colors';
12
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
13
+ import { toolbarInsertBlockMessages as messages } from '../../messages';
14
+ import { OutsideClickTargetRefContext } from '../../ui-react';
15
+ export const TABLE_SELECTOR_BUTTON_GAP = 2;
16
+ export const TABLE_SELECTOR_BUTTON_SIZE = 17;
17
+ const selectedButtonStyles = css({
18
+ backgroundColor: "var(--ds-background-accent-blue-subtlest, #579DFF)",
19
+ border: `1px solid ${"var(--ds-background-accent-blue-subtle, #579DFF)"}`
20
+ });
21
+ const buttonStyles = css({
22
+ height: `${TABLE_SELECTOR_BUTTON_SIZE}px`,
23
+ width: `${TABLE_SELECTOR_BUTTON_SIZE}px`,
24
+ border: `1px solid ${"var(--ds-border, #091e4224)"}`,
25
+ backgroundColor: "var(--ds-background-input, #ffffff)",
26
+ borderRadius: '3px',
27
+ cursor: 'pointer',
28
+ display: 'block',
29
+ '&:focus': {
30
+ outline: 'none',
31
+ border: `1px solid ${`var(--ds-border-focused, ${B100})`}`,
32
+ boxShadow: `0 0 0 0.5px ${`var(--ds-border-focused, ${B100})`}`
33
+ }
34
+ });
35
+ const selectionSizeTextStyles = css({
36
+ // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
37
+ lineHeight: '14px',
38
+ display: 'flex',
39
+ justifyContent: 'center',
40
+ marginTop: "var(--ds-space-075, 5px)",
41
+ padding: "var(--ds-space-075, 10px)"
42
+ });
43
+ const TableSelectorButton = ({
44
+ row,
45
+ col,
46
+ isActive,
47
+ onClick,
48
+ label,
49
+ onKeyDown,
50
+ isFocused,
51
+ handleInitialButtonFocus
52
+ }) => {
53
+ const btnRef = useRef(null);
54
+ useEffect(() => {
55
+ if (btnRef.current) {
56
+ if (isFocused) {
57
+ btnRef.current.focus({
58
+ preventScroll: editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_table_picker') ? true : undefined
59
+ });
60
+ } else {
61
+ btnRef.current.blur();
62
+ }
63
+ }
64
+ }, [isFocused, btnRef]);
65
+ const handleFocus = col === 1 && row === 1 ? () => handleInitialButtonFocus() : undefined;
66
+ return jsx("button", {
67
+ type: "button",
68
+ css: [buttonStyles, isActive ? selectedButtonStyles : undefined],
69
+ onClick: () => onClick(row, col),
70
+ "aria-label": label,
71
+ onKeyDown: onKeyDown,
72
+ ref: btnRef,
73
+ onFocus: handleFocus
74
+ });
75
+ };
76
+ const createArray = (maxCols, maxRows) => {
77
+ const arr = [];
78
+ for (let i = 1; i < maxRows + 1; i++) {
79
+ for (let j = 1; j < maxCols + 1; j++) {
80
+ arr.push({
81
+ col: j,
82
+ row: i
83
+ });
84
+ }
85
+ }
86
+ return arr;
87
+ };
88
+ const gridWrapperStyles = ({
89
+ maxCols,
90
+ maxRows
91
+ }) => css({
92
+ display: 'grid',
93
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
94
+ gridTemplateColumns: `repeat(${maxCols}, 1fr)`,
95
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
96
+ gridTemplateRows: `repeat(${maxRows}, 1fr)`,
97
+ gap: `${`var(--ds-space-025, ${`${TABLE_SELECTOR_BUTTON_GAP}px`})`}`
98
+ });
99
+ const TableSelectorPopup = ({
100
+ maxCols,
101
+ maxRows,
102
+ onSelection,
103
+ selectedCol,
104
+ selectedRow,
105
+ onKeyDown,
106
+ isFocused,
107
+ handleInitialButtonFocus,
108
+ intl: {
109
+ formatMessage
110
+ }
111
+ }) => {
112
+ const buttons = useMemo(() => {
113
+ return createArray(maxCols, maxRows);
114
+ }, [maxCols, maxRows]);
115
+ const setOutsideClickTargetRef = useContext(OutsideClickTargetRefContext);
116
+ return jsx(Stack, {
117
+ ref: setOutsideClickTargetRef
118
+ }, jsx("div", {
119
+ "aria-label": `${formatMessage(messages.tableSizeSelectorPopup)}`,
120
+ css:
121
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
122
+ gridWrapperStyles({
123
+ maxCols: maxCols,
124
+ maxRows: maxRows
125
+ })
126
+ }, buttons.map(({
127
+ col,
128
+ row
129
+ }, index) => {
130
+ const isCurrentFocused = isFocused && selectedCol === col && selectedRow === row;
131
+ const isActive = selectedCol >= col && selectedRow >= row ? true : false;
132
+ return jsx(TableSelectorButton
133
+ // Ignored via go/ees005
134
+ // eslint-disable-next-line react/no-array-index-key
135
+ , {
136
+ key: index,
137
+ isActive: isActive,
138
+ col: col,
139
+ row: row,
140
+ onClick: onSelection,
141
+ label: `${formatMessage(messages.tableSizeSelectorButton, {
142
+ numberOfColumns: col,
143
+ numberOfRows: row
144
+ })}`,
145
+ onKeyDown: onKeyDown,
146
+ isFocused: isCurrentFocused,
147
+ handleInitialButtonFocus: handleInitialButtonFocus
148
+ });
149
+ })), jsx("span", {
150
+ css: selectionSizeTextStyles,
151
+ "aria-hidden": true
152
+ }, `${selectedCol} x ${selectedRow}`));
153
+ };
154
+ export default injectIntl(TableSelectorPopup);
@@ -74,6 +74,7 @@ export const WidthProvider = ({
74
74
  if (!isMountedRef.current) {
75
75
  return;
76
76
  }
77
+ widthRef.current = nextWidth;
77
78
  setWidth(nextWidth);
78
79
  });
79
80
  }, []);
@@ -42,4 +42,5 @@ export { ToolbarDropdownWrapper } from './Toolbar/DropdownWrapper';
42
42
  export { ToolbarExpandIcon } from './Toolbar/ExpandIcon';
43
43
  export { ToolbarSeparator } from './Toolbar/Separator';
44
44
  export { default as DropList } from './DropList';
45
- export { sharedMultiBodiedExtensionStyles } from './MultiBodiedExtension';
45
+ export { sharedMultiBodiedExtensionStyles } from './MultiBodiedExtension';
46
+ export { default as TableSelectorPopup } from './TableSelector';
@@ -0,0 +1,32 @@
1
+ import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
2
+ import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '../analytics';
3
+ export const getDomRefFromSelection = (view, actionSubjectId, dispatchAnalyticsEvent) => {
4
+ try {
5
+ const domRef = findDomRefAtPos(view.state.selection.from, view.domAtPos.bind(view));
6
+ if (domRef instanceof HTMLElement) {
7
+ // If element is not a paragraph, we need to find the closest paragraph parent
8
+ if (domRef.nodeName !== 'P') {
9
+ const paragraphRef = domRef.closest('p');
10
+ if (paragraphRef) {
11
+ return paragraphRef;
12
+ }
13
+ }
14
+ return domRef;
15
+ } else {
16
+ throw new Error('Invalid DOM reference');
17
+ }
18
+ } catch (error) {
19
+ if (dispatchAnalyticsEvent) {
20
+ const payload = {
21
+ action: ACTION.ERRORED,
22
+ actionSubject: ACTION_SUBJECT.PICKER,
23
+ actionSubjectId: actionSubjectId,
24
+ eventType: EVENT_TYPE.OPERATIONAL,
25
+ attributes: {
26
+ error: 'Error getting DOM reference from selection'
27
+ }
28
+ };
29
+ dispatchAnalyticsEvent(payload);
30
+ }
31
+ }
32
+ };
@@ -427,6 +427,7 @@ export var ACTION_SUBJECT_ID = /*#__PURE__*/function (ACTION_SUBJECT_ID) {
427
427
  ACTION_SUBJECT_ID["PICKER_MEDIA"] = "mediaPicker";
428
428
  ACTION_SUBJECT_ID["PICKER_COLOR"] = "colorPicker";
429
429
  ACTION_SUBJECT_ID["PICKER_EMOJI"] = "emojiPicker";
430
+ ACTION_SUBJECT_ID["PICKER_TABLE_SIZE"] = "tableSizePicker";
430
431
  ACTION_SUBJECT_ID["DOCKED_PRIMARY_TOOLBAR"] = "dockedPrimaryToolbar";
431
432
  ACTION_SUBJECT_ID["PLACEHOLDER_TEXT"] = "placeholderText";
432
433
  ACTION_SUBJECT_ID["POST_QUERY_SEARCH_RESULTS"] = "postQuerySearchResults";
@@ -7,7 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
7
7
  import { isFedRamp } from './environment';
8
8
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
9
9
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
10
- var packageVersion = "103.11.2";
10
+ var packageVersion = "103.12.0";
11
11
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
12
12
  // Remove URL as it has UGC
13
13
  // Ignored via go/ees007
@@ -20,7 +20,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
20
20
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
21
21
  import Layer from '../Layer';
22
22
  var packageName = "@atlaskit/editor-common";
23
- var packageVersion = "103.11.2";
23
+ var packageVersion = "103.12.0";
24
24
  var halfFocusRing = 1;
25
25
  var dropOffset = '0, 8';
26
26
  // Ignored via go/ees005