@atlaskit/editor-common 96.5.8 → 96.6.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,26 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 96.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#181016](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/181016)
8
+ [`fb9a503ee55c3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fb9a503ee55c3) -
9
+ Add new `getColumnWidths` function which will loop through each table row, looking for the max
10
+ number of table cells to use to render the table correctly when table resizing is enabled.
11
+
12
+ ## 96.6.0
13
+
14
+ ### Minor Changes
15
+
16
+ - [#180750](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/180750)
17
+ [`f019b16b9161a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f019b16b9161a) -
18
+ [ux] Introduces access to the ExtensionAPI from extension module quickInsert actions
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies
23
+
3
24
  ## 96.5.8
4
25
 
5
26
  ### Patch Changes
@@ -17,7 +17,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
17
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
18
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
19
19
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
20
- var packageVersion = "96.5.8";
20
+ var packageVersion = "96.6.1";
21
21
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
22
22
  // Remove URL as it has UGC
23
23
  // TODO: Sanitise the URL instead of just removing it
@@ -23,7 +23,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
23
23
  * @jsx jsx
24
24
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
25
25
  var packageName = "@atlaskit/editor-common";
26
- var packageVersion = "96.5.8";
26
+ var packageVersion = "96.6.1";
27
27
  var halfFocusRing = 1;
28
28
  var dropOffset = '0, 8';
29
29
  var DropList = /*#__PURE__*/function (_Component) {
@@ -432,6 +432,12 @@ Object.defineProperty(exports, "getChildrenInfo", {
432
432
  return _referentiality.getChildrenInfo;
433
433
  }
434
434
  });
435
+ Object.defineProperty(exports, "getColumnWidths", {
436
+ enumerable: true,
437
+ get: function get() {
438
+ return _table.getColumnWidths;
439
+ }
440
+ });
435
441
  Object.defineProperty(exports, "getDatasourceType", {
436
442
  enumerable: true,
437
443
  get: function get() {
@@ -6,11 +6,44 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.calcTableColumnWidths = calcTableColumnWidths;
8
8
  exports.convertProsemirrorTableNodeToArrayOfRows = convertProsemirrorTableNodeToArrayOfRows;
9
+ exports.getColumnWidths = getColumnWidths;
9
10
  exports.hasMergedCell = hasMergedCell;
10
11
  exports.isPositionNearTableRow = isPositionNearTableRow;
11
12
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
12
13
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
+ /**
15
+ * Looks at every table row to find the correct number of columns for table, which
16
+ * accounts for tables with uneven rows.
17
+ *
18
+ * Returns an array of column widths if defined otherwise 0, positions respect table order.
19
+ */
20
+ function getColumnWidths(node) {
21
+ var tableColumnWidths = [];
22
+ node.forEach(function (row) {
23
+ var currentTableWidth = [];
24
+ row.forEach(function (cell) {
25
+ var _ref = cell.attrs,
26
+ colspan = _ref.colspan,
27
+ colwidth = _ref.colwidth;
28
+ // column has been resized, colWidth will be an array, can safely take values even if cell is merged
29
+ if (Array.isArray(colwidth)) {
30
+ currentTableWidth.push.apply(currentTableWidth, (0, _toConsumableArray2.default)(colwidth));
31
+ // table has merged cells but no colWidth, so columns haven't been resized, default to 0
32
+ } else if (colspan !== undefined && colspan > 1) {
33
+ currentTableWidth.push.apply(currentTableWidth, (0, _toConsumableArray2.default)(Array(colspan).fill(0)));
34
+ // no merged cells, no column resized, default to 0
35
+ } else {
36
+ currentTableWidth.push(0);
37
+ }
38
+ });
39
+ if (currentTableWidth.length > tableColumnWidths.length) {
40
+ tableColumnWidths = currentTableWidth;
41
+ }
42
+ });
43
+ return tableColumnWidths;
44
+ }
13
45
  function calcTableColumnWidths(node) {
46
+ // TODO: replaced with getColumnWidths, which correctly scans entire table for column widths
14
47
  if ((0, _platformFeatureFlags.fg)('platform_editor_table_row_span_fix')) {
15
48
  var _firstRow = node.firstChild;
16
49
  var _tableColumnWidths = [];
@@ -1,7 +1,7 @@
1
1
  import { isFedRamp } from './environment';
2
2
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
3
3
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
4
- const packageVersion = "96.5.8";
4
+ const packageVersion = "96.6.1";
5
5
  const sanitiseSentryEvents = (data, _hint) => {
6
6
  // Remove URL as it has UGC
7
7
  // TODO: Sanitise the URL instead of just removing it
@@ -13,7 +13,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
13
13
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
14
14
  import Layer from '../Layer';
15
15
  const packageName = "@atlaskit/editor-common";
16
- const packageVersion = "96.5.8";
16
+ const packageVersion = "96.6.1";
17
17
  const halfFocusRing = 1;
18
18
  const dropOffset = '0, 8';
19
19
  class DropList extends Component {
@@ -122,7 +122,7 @@ export { isPerformanceAPIAvailable, isPerformanceObserverAvailable } from './per
122
122
  */
123
123
  export { getResponseEndTime } from './performance/navigation';
124
124
  export { getExtensionRenderer } from './extension-handler';
125
- export { hasMergedCell, calcTableColumnWidths, convertProsemirrorTableNodeToArrayOfRows, isPositionNearTableRow } from './table';
125
+ export { hasMergedCell, getColumnWidths, calcTableColumnWidths, convertProsemirrorTableNodeToArrayOfRows, isPositionNearTableRow } from './table';
126
126
  export { createCompareNodes } from './compareNodes';
127
127
  export { compose } from './compose';
128
128
  export { isTextInput } from './is-text-input';
@@ -1,5 +1,39 @@
1
1
  import { fg } from '@atlaskit/platform-feature-flags';
2
+
3
+ /**
4
+ * Looks at every table row to find the correct number of columns for table, which
5
+ * accounts for tables with uneven rows.
6
+ *
7
+ * Returns an array of column widths if defined otherwise 0, positions respect table order.
8
+ */
9
+ export function getColumnWidths(node) {
10
+ let tableColumnWidths = [];
11
+ node.forEach(row => {
12
+ let currentTableWidth = [];
13
+ row.forEach(cell => {
14
+ const {
15
+ colspan,
16
+ colwidth
17
+ } = cell.attrs;
18
+ // column has been resized, colWidth will be an array, can safely take values even if cell is merged
19
+ if (Array.isArray(colwidth)) {
20
+ currentTableWidth.push(...colwidth);
21
+ // table has merged cells but no colWidth, so columns haven't been resized, default to 0
22
+ } else if (colspan !== undefined && colspan > 1) {
23
+ currentTableWidth.push(...Array(colspan).fill(0));
24
+ // no merged cells, no column resized, default to 0
25
+ } else {
26
+ currentTableWidth.push(0);
27
+ }
28
+ });
29
+ if (currentTableWidth.length > tableColumnWidths.length) {
30
+ tableColumnWidths = currentTableWidth;
31
+ }
32
+ });
33
+ return tableColumnWidths;
34
+ }
2
35
  export function calcTableColumnWidths(node) {
36
+ // TODO: replaced with getColumnWidths, which correctly scans entire table for column widths
3
37
  if (fg('platform_editor_table_row_span_fix')) {
4
38
  const firstRow = node.firstChild;
5
39
  let tableColumnWidths = [];
@@ -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 = "96.5.8";
10
+ var packageVersion = "96.6.1";
11
11
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
12
12
  // Remove URL as it has UGC
13
13
  // TODO: Sanitise the URL instead of just removing it
@@ -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 = "96.5.8";
23
+ var packageVersion = "96.6.1";
24
24
  var halfFocusRing = 1;
25
25
  var dropOffset = '0, 8';
26
26
  var DropList = /*#__PURE__*/function (_Component) {
@@ -122,7 +122,7 @@ export { isPerformanceAPIAvailable, isPerformanceObserverAvailable } from './per
122
122
  */
123
123
  export { getResponseEndTime } from './performance/navigation';
124
124
  export { getExtensionRenderer } from './extension-handler';
125
- export { hasMergedCell, calcTableColumnWidths, convertProsemirrorTableNodeToArrayOfRows, isPositionNearTableRow } from './table';
125
+ export { hasMergedCell, getColumnWidths, calcTableColumnWidths, convertProsemirrorTableNodeToArrayOfRows, isPositionNearTableRow } from './table';
126
126
  export { createCompareNodes } from './compareNodes';
127
127
  export { compose } from './compose';
128
128
  export { isTextInput } from './is-text-input';
@@ -1,6 +1,39 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import { fg } from '@atlaskit/platform-feature-flags';
3
+
4
+ /**
5
+ * Looks at every table row to find the correct number of columns for table, which
6
+ * accounts for tables with uneven rows.
7
+ *
8
+ * Returns an array of column widths if defined otherwise 0, positions respect table order.
9
+ */
10
+ export function getColumnWidths(node) {
11
+ var tableColumnWidths = [];
12
+ node.forEach(function (row) {
13
+ var currentTableWidth = [];
14
+ row.forEach(function (cell) {
15
+ var _ref = cell.attrs,
16
+ colspan = _ref.colspan,
17
+ colwidth = _ref.colwidth;
18
+ // column has been resized, colWidth will be an array, can safely take values even if cell is merged
19
+ if (Array.isArray(colwidth)) {
20
+ currentTableWidth.push.apply(currentTableWidth, _toConsumableArray(colwidth));
21
+ // table has merged cells but no colWidth, so columns haven't been resized, default to 0
22
+ } else if (colspan !== undefined && colspan > 1) {
23
+ currentTableWidth.push.apply(currentTableWidth, _toConsumableArray(Array(colspan).fill(0)));
24
+ // no merged cells, no column resized, default to 0
25
+ } else {
26
+ currentTableWidth.push(0);
27
+ }
28
+ });
29
+ if (currentTableWidth.length > tableColumnWidths.length) {
30
+ tableColumnWidths = currentTableWidth;
31
+ }
32
+ });
33
+ return tableColumnWidths;
34
+ }
3
35
  export function calcTableColumnWidths(node) {
36
+ // TODO: replaced with getColumnWidths, which correctly scans entire table for column widths
4
37
  if (fg('platform_editor_table_row_span_fix')) {
5
38
  var _firstRow = node.firstChild;
6
39
  var _tableColumnWidths = [];
@@ -1,6 +1,6 @@
1
1
  import type { ComponentType } from 'react';
2
2
  import type { ADFEntity } from '@atlaskit/adf-utils/types';
3
- import type { ExtensionParams, MultiBodiedExtensionActions, UpdateExtension } from './extension-handler';
3
+ import type { ExtensionAPI, ExtensionParams, MultiBodiedExtensionActions, UpdateExtension } from './extension-handler';
4
4
  import type { ExtensionIconModule, MaybeESModule } from './extension-manifest-common';
5
5
  import type { ContextualToolbar } from './extension-manifest-toolbar-item';
6
6
  import type { Parameters } from './extension-parameters';
@@ -23,7 +23,7 @@ export type ExtensionModuleActionObject<T extends Parameters = Parameters> = {
23
23
  parameters?: T;
24
24
  };
25
25
  export type MaybeADFEntity = MaybeESModule<ADFEntity | Array<ADFEntity> | void>;
26
- export type ExtensionModuleActionHandler = () => Promise<MaybeADFEntity>;
26
+ export type ExtensionModuleActionHandler = (extensionAPI: ExtensionAPI) => Promise<MaybeADFEntity>;
27
27
  export type ExtensionModuleAction<T extends Parameters = Parameters> = ExtensionModuleActionObject<T> | ExtensionModuleActionHandler;
28
28
  export type ExtensionModule<T extends Parameters = Parameters> = {
29
29
  key: string;
@@ -127,7 +127,7 @@ export { isPerformanceAPIAvailable, isPerformanceObserverAvailable, } from './pe
127
127
  */
128
128
  export { getResponseEndTime } from './performance/navigation';
129
129
  export { getExtensionRenderer } from './extension-handler';
130
- export { hasMergedCell, calcTableColumnWidths, convertProsemirrorTableNodeToArrayOfRows, isPositionNearTableRow, } from './table';
130
+ export { hasMergedCell, getColumnWidths, calcTableColumnWidths, convertProsemirrorTableNodeToArrayOfRows, isPositionNearTableRow, } from './table';
131
131
  export { createCompareNodes } from './compareNodes';
132
132
  export { compose } from './compose';
133
133
  export { isTextInput } from './is-text-input';
@@ -1,4 +1,11 @@
1
1
  import type { Node as PmNode, ResolvedPos, Schema } from '@atlaskit/editor-prosemirror/model';
2
+ /**
3
+ * Looks at every table row to find the correct number of columns for table, which
4
+ * accounts for tables with uneven rows.
5
+ *
6
+ * Returns an array of column widths if defined otherwise 0, positions respect table order.
7
+ */
8
+ export declare function getColumnWidths(node: PmNode): number[];
2
9
  export declare function calcTableColumnWidths(node: PmNode): number[];
3
10
  export declare function hasMergedCell(tableNode: PmNode): boolean;
4
11
  export declare function convertProsemirrorTableNodeToArrayOfRows(tableNode: PmNode): Array<Array<PmNode | null>>;
@@ -1,6 +1,6 @@
1
1
  import type { ComponentType } from 'react';
2
2
  import type { ADFEntity } from '@atlaskit/adf-utils/types';
3
- import type { ExtensionParams, MultiBodiedExtensionActions, UpdateExtension } from './extension-handler';
3
+ import type { ExtensionAPI, ExtensionParams, MultiBodiedExtensionActions, UpdateExtension } from './extension-handler';
4
4
  import type { ExtensionIconModule, MaybeESModule } from './extension-manifest-common';
5
5
  import type { ContextualToolbar } from './extension-manifest-toolbar-item';
6
6
  import type { Parameters } from './extension-parameters';
@@ -23,7 +23,7 @@ export type ExtensionModuleActionObject<T extends Parameters = Parameters> = {
23
23
  parameters?: T;
24
24
  };
25
25
  export type MaybeADFEntity = MaybeESModule<ADFEntity | Array<ADFEntity> | void>;
26
- export type ExtensionModuleActionHandler = () => Promise<MaybeADFEntity>;
26
+ export type ExtensionModuleActionHandler = (extensionAPI: ExtensionAPI) => Promise<MaybeADFEntity>;
27
27
  export type ExtensionModuleAction<T extends Parameters = Parameters> = ExtensionModuleActionObject<T> | ExtensionModuleActionHandler;
28
28
  export type ExtensionModule<T extends Parameters = Parameters> = {
29
29
  key: string;
@@ -127,7 +127,7 @@ export { isPerformanceAPIAvailable, isPerformanceObserverAvailable, } from './pe
127
127
  */
128
128
  export { getResponseEndTime } from './performance/navigation';
129
129
  export { getExtensionRenderer } from './extension-handler';
130
- export { hasMergedCell, calcTableColumnWidths, convertProsemirrorTableNodeToArrayOfRows, isPositionNearTableRow, } from './table';
130
+ export { hasMergedCell, getColumnWidths, calcTableColumnWidths, convertProsemirrorTableNodeToArrayOfRows, isPositionNearTableRow, } from './table';
131
131
  export { createCompareNodes } from './compareNodes';
132
132
  export { compose } from './compose';
133
133
  export { isTextInput } from './is-text-input';
@@ -1,4 +1,11 @@
1
1
  import type { Node as PmNode, ResolvedPos, Schema } from '@atlaskit/editor-prosemirror/model';
2
+ /**
3
+ * Looks at every table row to find the correct number of columns for table, which
4
+ * accounts for tables with uneven rows.
5
+ *
6
+ * Returns an array of column widths if defined otherwise 0, positions respect table order.
7
+ */
8
+ export declare function getColumnWidths(node: PmNode): number[];
2
9
  export declare function calcTableColumnWidths(node: PmNode): number[];
3
10
  export declare function hasMergedCell(tableNode: PmNode): boolean;
4
11
  export declare function convertProsemirrorTableNodeToArrayOfRows(tableNode: PmNode): Array<Array<PmNode | null>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "96.5.8",
3
+ "version": "96.6.1",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -154,7 +154,7 @@
154
154
  "@atlaskit/spinner": "^16.3.0",
155
155
  "@atlaskit/task-decision": "^17.11.0",
156
156
  "@atlaskit/textfield": "^6.7.0",
157
- "@atlaskit/tmp-editor-statsig": "^2.27.0",
157
+ "@atlaskit/tmp-editor-statsig": "^2.28.0",
158
158
  "@atlaskit/tokens": "^2.5.0",
159
159
  "@atlaskit/tooltip": "^19.0.0",
160
160
  "@atlaskit/width-detector": "^4.3.0",