@atlaskit/editor-plugin-table 11.1.0 → 11.1.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 11.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#185075](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/185075)
8
+ [`0ffa67091b61f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0ffa67091b61f) -
9
+ Adds resiliency for consumers that end up with multiple table plugins
10
+ - Updated dependencies
11
+
3
12
  ## 11.1.0
4
13
 
5
14
  ### Minor Changes
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = exports._reset_tableComponentCount = void 0;
7
+ exports.default = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
@@ -76,12 +76,15 @@ var isOverflowAnalyticsEnabled = false;
76
76
  // Prevent unnecessary parentWidth updates when table is nested inside of a node that is nested itself.
77
77
  var NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MIN_THRESHOLD = 2;
78
78
  var NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MAX_THRESHOLD = 20;
79
- var _tableComponentCount = 1;
80
- /**
81
- * Exported for test purposes only
82
- */
83
- var _reset_tableComponentCount = exports._reset_tableComponentCount = function _reset_tableComponentCount() {
84
- return _tableComponentCount = 0;
79
+ // Generate a unique ID to prevent collisions when multiple plugin versions exist on the same page
80
+ var generateUniqueTableId = function generateUniqueTableId() {
81
+ // Use crypto.randomUUID() if available, fallback to Math.random() based approach
82
+ if (!globalThis.crypto || typeof globalThis.crypto.randomUUID !== 'function') {
83
+ // Fallback: for older environments (IE).
84
+ // Not the best fallback, but the crypto.randomUUID is widely available
85
+ return (Math.random() + 1).toString(36).substring(20);
86
+ }
87
+ return crypto.randomUUID();
85
88
  };
86
89
 
87
90
  // Ignored via go/ees005
@@ -96,7 +99,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
96
99
  parentWidth: undefined
97
100
  }, _types.ShadowEvent.SHOW_BEFORE_SHADOW, false), _types.ShadowEvent.SHOW_AFTER_SHADOW, false), "tableWrapperWidth", undefined), "tableWrapperHeight", undefined));
98
101
  (0, _defineProperty3.default)(_this, "holdCompleted", false);
99
- (0, _defineProperty3.default)(_this, "dispatchEventName", "tableResized-".concat(_tableComponentCount++));
102
+ (0, _defineProperty3.default)(_this, "dispatchEventName", "tableResized-".concat(generateUniqueTableId()));
100
103
  (0, _defineProperty3.default)(_this, "handleMouseOut", function (event) {
101
104
  if (!(0, _eventHandlers.isTableInFocus)(_this.props.view)) {
102
105
  return false;
@@ -56,11 +56,16 @@ const isOverflowAnalyticsEnabled = false;
56
56
  // Prevent unnecessary parentWidth updates when table is nested inside of a node that is nested itself.
57
57
  const NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MIN_THRESHOLD = 2;
58
58
  const NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MAX_THRESHOLD = 20;
59
- let _tableComponentCount = 1;
60
- /**
61
- * Exported for test purposes only
62
- */
63
- export const _reset_tableComponentCount = () => _tableComponentCount = 0;
59
+ // Generate a unique ID to prevent collisions when multiple plugin versions exist on the same page
60
+ const generateUniqueTableId = () => {
61
+ // Use crypto.randomUUID() if available, fallback to Math.random() based approach
62
+ if (!globalThis.crypto || typeof globalThis.crypto.randomUUID !== 'function') {
63
+ // Fallback: for older environments (IE).
64
+ // Not the best fallback, but the crypto.randomUUID is widely available
65
+ return (Math.random() + 1).toString(36).substring(20);
66
+ }
67
+ return crypto.randomUUID();
68
+ };
64
69
 
65
70
  // Ignored via go/ees005
66
71
  // eslint-disable-next-line @repo/internal/react/no-class-components
@@ -76,7 +81,7 @@ class TableComponent extends React.Component {
76
81
  tableWrapperHeight: undefined
77
82
  });
78
83
  _defineProperty(this, "holdCompleted", false);
79
- _defineProperty(this, "dispatchEventName", `tableResized-${_tableComponentCount++}`);
84
+ _defineProperty(this, "dispatchEventName", `tableResized-${generateUniqueTableId()}`);
80
85
  _defineProperty(this, "handleMouseOut", event => {
81
86
  if (!isTableInFocus(this.props.view)) {
82
87
  return false;
@@ -70,12 +70,15 @@ var isOverflowAnalyticsEnabled = false;
70
70
  // Prevent unnecessary parentWidth updates when table is nested inside of a node that is nested itself.
71
71
  var NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MIN_THRESHOLD = 2;
72
72
  var NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MAX_THRESHOLD = 20;
73
- var _tableComponentCount = 1;
74
- /**
75
- * Exported for test purposes only
76
- */
77
- export var _reset_tableComponentCount = function _reset_tableComponentCount() {
78
- return _tableComponentCount = 0;
73
+ // Generate a unique ID to prevent collisions when multiple plugin versions exist on the same page
74
+ var generateUniqueTableId = function generateUniqueTableId() {
75
+ // Use crypto.randomUUID() if available, fallback to Math.random() based approach
76
+ if (!globalThis.crypto || typeof globalThis.crypto.randomUUID !== 'function') {
77
+ // Fallback: for older environments (IE).
78
+ // Not the best fallback, but the crypto.randomUUID is widely available
79
+ return (Math.random() + 1).toString(36).substring(20);
80
+ }
81
+ return crypto.randomUUID();
79
82
  };
80
83
 
81
84
  // Ignored via go/ees005
@@ -90,7 +93,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
90
93
  parentWidth: undefined
91
94
  }, ShadowEvent.SHOW_BEFORE_SHADOW, false), ShadowEvent.SHOW_AFTER_SHADOW, false), "tableWrapperWidth", undefined), "tableWrapperHeight", undefined));
92
95
  _defineProperty(_this, "holdCompleted", false);
93
- _defineProperty(_this, "dispatchEventName", "tableResized-".concat(_tableComponentCount++));
96
+ _defineProperty(_this, "dispatchEventName", "tableResized-".concat(generateUniqueTableId()));
94
97
  _defineProperty(_this, "handleMouseOut", function (event) {
95
98
  if (!isTableInFocus(_this.props.view)) {
96
99
  return false;
@@ -40,10 +40,6 @@ interface ComponentProps {
40
40
  isWholeTableInDanger?: boolean;
41
41
  selection?: Selection;
42
42
  }
43
- /**
44
- * Exported for test purposes only
45
- */
46
- export declare const _reset_tableComponentCount: () => number;
47
43
  declare const _default: React.FC<import("react-intl-next").WithIntlProps<ComponentProps>> & {
48
44
  WrappedComponent: React.ComponentType<ComponentProps>;
49
45
  };
@@ -40,10 +40,6 @@ interface ComponentProps {
40
40
  isWholeTableInDanger?: boolean;
41
41
  selection?: Selection;
42
42
  }
43
- /**
44
- * Exported for test purposes only
45
- */
46
- export declare const _reset_tableComponentCount: () => number;
47
43
  declare const _default: React.FC<import("react-intl-next").WithIntlProps<ComponentProps>> & {
48
44
  WrappedComponent: React.ComponentType<ComponentProps>;
49
45
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "11.1.0",
3
+ "version": "11.1.1",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -54,9 +54,9 @@
54
54
  "@atlaskit/primitives": "^14.10.0",
55
55
  "@atlaskit/react-ufo": "^3.14.0",
56
56
  "@atlaskit/theme": "^19.0.0",
57
- "@atlaskit/tmp-editor-statsig": "^9.4.0",
57
+ "@atlaskit/tmp-editor-statsig": "^9.5.0",
58
58
  "@atlaskit/toggle": "^15.0.0",
59
- "@atlaskit/tokens": "^5.4.0",
59
+ "@atlaskit/tokens": "^5.5.0",
60
60
  "@atlaskit/tooltip": "^20.3.0",
61
61
  "@babel/runtime": "^7.0.0",
62
62
  "@emotion/react": "^11.7.1",
@@ -148,11 +148,16 @@ interface TableState {
148
148
  tableWrapperHeight?: number;
149
149
  }
150
150
 
151
- let _tableComponentCount = 1;
152
- /**
153
- * Exported for test purposes only
154
- */
155
- export const _reset_tableComponentCount = () => (_tableComponentCount = 0);
151
+ // Generate a unique ID to prevent collisions when multiple plugin versions exist on the same page
152
+ const generateUniqueTableId = () => {
153
+ // Use crypto.randomUUID() if available, fallback to Math.random() based approach
154
+ if (!globalThis.crypto || typeof globalThis.crypto.randomUUID !== 'function') {
155
+ // Fallback: for older environments (IE).
156
+ // Not the best fallback, but the crypto.randomUUID is widely available
157
+ return (Math.random() + 1).toString(36).substring(20);
158
+ }
159
+ return crypto.randomUUID();
160
+ };
156
161
 
157
162
  // Ignored via go/ees005
158
163
  // eslint-disable-next-line @repo/internal/react/no-class-components
@@ -191,7 +196,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
191
196
  private dragAndDropCleanupFn?: CleanupFn;
192
197
  private nodeVisibilityObserverCleanupFn?: CleanupFn;
193
198
  private holdCompleted = false;
194
- private dispatchEventName = `tableResized-${_tableComponentCount++}`;
199
+ private dispatchEventName = `tableResized-${generateUniqueTableId()}`;
195
200
 
196
201
  constructor(props: ComponentProps) {
197
202
  super(props);
@@ -116,7 +116,7 @@ export const ColumnControls = ({
116
116
  const hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
117
117
 
118
118
  const rowControlStickyTop = 45;
119
- const marginTop = hasHeaderRow && stickyTop !== undefined ? (rowControlStickyTop ?? 0) : 0;
119
+ const marginTop = hasHeaderRow && stickyTop !== undefined ? rowControlStickyTop ?? 0 : 0;
120
120
 
121
121
  const handleClick = useCallback(
122
122
  (event: MouseEvent) => {