@atlaskit/editor-common 110.23.0 → 110.24.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 110.24.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`c094becfaeeaa`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c094becfaeeaa) -
8
+ EDITOR-2476 Introduce new utility method to check if nested tables is supported in the schema to
9
+ facilitate removal of gate `platform_editor_use_nested_table_pm_nodes`
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 110.23.0
4
16
 
5
17
  ### Minor Changes
@@ -16,7 +16,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
16
16
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
17
17
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
18
18
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
19
- var packageVersion = "110.22.2";
19
+ var packageVersion = "110.23.0";
20
20
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
21
21
  // Remove URL as it has UGC
22
22
  // Ignored via go/ees007
@@ -3,8 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isSelectionTableNestedInTable = exports.getPositionAfterTopParentNodeOfType = exports.getParentOfTypeCount = void 0;
6
+ exports.isSelectionTableNestedInTable = exports.isNestedTablesSupported = exports.getPositionAfterTopParentNodeOfType = exports.getParentOfTypeCount = void 0;
7
7
  var _editorTables = require("@atlaskit/editor-tables");
8
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
8
9
  /*
9
10
  * Returns the level of nesting of a given `nodeType` in the current position.
10
11
  * eg. table > table is nested 1 level, table > table > table is nested 2 levels.
@@ -63,4 +64,31 @@ var isSelectionTableNestedInTable = exports.isSelectionTableNestedInTable = func
63
64
  var parent = state.doc.resolve(table.pos).parent;
64
65
  var nodeTypes = state.schema.nodes;
65
66
  return [nodeTypes.tableHeader, nodeTypes.tableCell].includes(parent.type);
67
+ };
68
+
69
+ /*
70
+ * Returns true if the schema supports nesting tables inside table cells.
71
+ * This is determined by checking if table cells can contain table nodes in their content model.
72
+ *
73
+ * ```typescript
74
+ * const supportsNestedTables = isNestedTablesSupported(state.schema);
75
+ * ```
76
+ */
77
+ var isNestedTablesSupported = exports.isNestedTablesSupported = function isNestedTablesSupported(schema) {
78
+ var _tableCell$contentMat, _tableHeader$contentM;
79
+ if (!(0, _expValEquals.expValEquals)('platform_editor_nested_table_detection', 'isEnabled', true)) {
80
+ return true;
81
+ }
82
+ var _schema$nodes = schema.nodes,
83
+ table = _schema$nodes.table,
84
+ tableCell = _schema$nodes.tableCell,
85
+ tableHeader = _schema$nodes.tableHeader;
86
+ if (!table || !tableCell || !tableHeader) {
87
+ return false;
88
+ }
89
+
90
+ // Check if table cells can contain table nodes by testing their content match
91
+ var tableCellCanContainTable = ((_tableCell$contentMat = tableCell.contentMatch.matchType(table)) === null || _tableCell$contentMat === void 0 ? void 0 : _tableCell$contentMat.validEnd) === true;
92
+ var tableHeaderCanContainTable = ((_tableHeader$contentM = tableHeader.contentMatch.matchType(table)) === null || _tableHeader$contentM === void 0 ? void 0 : _tableHeader$contentM.validEnd) === true;
93
+ return tableCellCanContainTable || tableHeaderCanContainTable;
66
94
  };
@@ -6,6 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.generateUniqueNodeKey = void 0;
8
8
  var _v = _interopRequireDefault(require("uuid/v4"));
9
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
10
+
9
11
  var generateUniqueNodeKey = exports.generateUniqueNodeKey = function generateUniqueNodeKey() {
12
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
10
13
  return (0, _v.default)();
11
14
  };
@@ -24,7 +24,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
24
24
  * @jsx jsx
25
25
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
26
26
  var packageName = "@atlaskit/editor-common";
27
- var packageVersion = "110.22.2";
27
+ var packageVersion = "110.23.0";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var fadeIn = (0, _react2.keyframes)({
@@ -8,6 +8,8 @@ exports.useComponentRenderTracking = useComponentRenderTracking;
8
8
  var _react = require("react");
9
9
  var _v = _interopRequireDefault(require("uuid/v4"));
10
10
  var _compareProps = require("../../../compare-props");
11
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
12
+
11
13
  function useComponentRenderTracking(_ref) {
12
14
  var onRender = _ref.onRender,
13
15
  propsDiffingOptions = _ref.propsDiffingOptions,
@@ -15,6 +17,7 @@ function useComponentRenderTracking(_ref) {
15
17
  zeroBasedCount = _ref$zeroBasedCount === void 0 ? true : _ref$zeroBasedCount;
16
18
  var propsRef = (0, _react.useRef)();
17
19
  var renderCountRef = (0, _react.useRef)(zeroBasedCount ? 0 : 1);
20
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
18
21
  var _useRef = (0, _react.useRef)((0, _v.default)()),
19
22
  componentId = _useRef.current;
20
23
  (0, _react.useEffect)(function () {
@@ -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 = "110.22.2";
4
+ const packageVersion = "110.23.0";
5
5
  const sanitiseSentryEvents = (data, _hint) => {
6
6
  // Remove URL as it has UGC
7
7
  // Ignored via go/ees007
@@ -1,4 +1,5 @@
1
1
  import { findTable } from '@atlaskit/editor-tables';
2
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
2
3
 
3
4
  /*
4
5
  * Returns the level of nesting of a given `nodeType` in the current position.
@@ -54,4 +55,32 @@ export const isSelectionTableNestedInTable = state => {
54
55
  const parent = state.doc.resolve(table.pos).parent;
55
56
  const nodeTypes = state.schema.nodes;
56
57
  return [nodeTypes.tableHeader, nodeTypes.tableCell].includes(parent.type);
58
+ };
59
+
60
+ /*
61
+ * Returns true if the schema supports nesting tables inside table cells.
62
+ * This is determined by checking if table cells can contain table nodes in their content model.
63
+ *
64
+ * ```typescript
65
+ * const supportsNestedTables = isNestedTablesSupported(state.schema);
66
+ * ```
67
+ */
68
+ export const isNestedTablesSupported = schema => {
69
+ var _tableCell$contentMat, _tableHeader$contentM;
70
+ if (!expValEquals('platform_editor_nested_table_detection', 'isEnabled', true)) {
71
+ return true;
72
+ }
73
+ const {
74
+ table,
75
+ tableCell,
76
+ tableHeader
77
+ } = schema.nodes;
78
+ if (!table || !tableCell || !tableHeader) {
79
+ return false;
80
+ }
81
+
82
+ // Check if table cells can contain table nodes by testing their content match
83
+ const tableCellCanContainTable = ((_tableCell$contentMat = tableCell.contentMatch.matchType(table)) === null || _tableCell$contentMat === void 0 ? void 0 : _tableCell$contentMat.validEnd) === true;
84
+ const tableHeaderCanContainTable = ((_tableHeader$contentM = tableHeader.contentMatch.matchType(table)) === null || _tableHeader$contentM === void 0 ? void 0 : _tableHeader$contentM.validEnd) === true;
85
+ return tableCellCanContainTable || tableHeaderCanContainTable;
57
86
  };
@@ -1,4 +1,6 @@
1
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
1
2
  import uuid from 'uuid/v4';
2
3
  export const generateUniqueNodeKey = () => {
4
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
3
5
  return uuid();
4
6
  };
@@ -14,7 +14,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
14
14
  import { fg } from '@atlaskit/platform-feature-flags';
15
15
  import Layer from '../Layer';
16
16
  const packageName = "@atlaskit/editor-common";
17
- const packageVersion = "110.22.2";
17
+ const packageVersion = "110.23.0";
18
18
  const halfFocusRing = 1;
19
19
  const dropOffset = '0, 8';
20
20
  const fadeIn = keyframes({
@@ -1,4 +1,6 @@
1
1
  import { useEffect, useRef } from 'react';
2
+
3
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
2
4
  import uuidv4 from 'uuid/v4';
3
5
  import { getPropsDifference, getShallowPropsDifference } from '../../../compare-props';
4
6
  export function useComponentRenderTracking({
@@ -8,6 +10,7 @@ export function useComponentRenderTracking({
8
10
  }) {
9
11
  const propsRef = useRef();
10
12
  const renderCountRef = useRef(zeroBasedCount ? 0 : 1);
13
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
11
14
  const {
12
15
  current: componentId
13
16
  } = useRef(uuidv4());
@@ -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 = "110.22.2";
10
+ var packageVersion = "110.23.0";
11
11
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
12
12
  // Remove URL as it has UGC
13
13
  // Ignored via go/ees007
@@ -1,4 +1,5 @@
1
1
  import { findTable } from '@atlaskit/editor-tables';
2
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
2
3
 
3
4
  /*
4
5
  * Returns the level of nesting of a given `nodeType` in the current position.
@@ -58,4 +59,31 @@ export var isSelectionTableNestedInTable = function isSelectionTableNestedInTabl
58
59
  var parent = state.doc.resolve(table.pos).parent;
59
60
  var nodeTypes = state.schema.nodes;
60
61
  return [nodeTypes.tableHeader, nodeTypes.tableCell].includes(parent.type);
62
+ };
63
+
64
+ /*
65
+ * Returns true if the schema supports nesting tables inside table cells.
66
+ * This is determined by checking if table cells can contain table nodes in their content model.
67
+ *
68
+ * ```typescript
69
+ * const supportsNestedTables = isNestedTablesSupported(state.schema);
70
+ * ```
71
+ */
72
+ export var isNestedTablesSupported = function isNestedTablesSupported(schema) {
73
+ var _tableCell$contentMat, _tableHeader$contentM;
74
+ if (!expValEquals('platform_editor_nested_table_detection', 'isEnabled', true)) {
75
+ return true;
76
+ }
77
+ var _schema$nodes = schema.nodes,
78
+ table = _schema$nodes.table,
79
+ tableCell = _schema$nodes.tableCell,
80
+ tableHeader = _schema$nodes.tableHeader;
81
+ if (!table || !tableCell || !tableHeader) {
82
+ return false;
83
+ }
84
+
85
+ // Check if table cells can contain table nodes by testing their content match
86
+ var tableCellCanContainTable = ((_tableCell$contentMat = tableCell.contentMatch.matchType(table)) === null || _tableCell$contentMat === void 0 ? void 0 : _tableCell$contentMat.validEnd) === true;
87
+ var tableHeaderCanContainTable = ((_tableHeader$contentM = tableHeader.contentMatch.matchType(table)) === null || _tableHeader$contentM === void 0 ? void 0 : _tableHeader$contentM.validEnd) === true;
88
+ return tableCellCanContainTable || tableHeaderCanContainTable;
61
89
  };
@@ -1,4 +1,6 @@
1
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
1
2
  import uuid from 'uuid/v4';
2
3
  export var generateUniqueNodeKey = function generateUniqueNodeKey() {
4
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
3
5
  return uuid();
4
6
  };
@@ -21,7 +21,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
21
21
  import { fg } from '@atlaskit/platform-feature-flags';
22
22
  import Layer from '../Layer';
23
23
  var packageName = "@atlaskit/editor-common";
24
- var packageVersion = "110.22.2";
24
+ var packageVersion = "110.23.0";
25
25
  var halfFocusRing = 1;
26
26
  var dropOffset = '0, 8';
27
27
  var fadeIn = keyframes({
@@ -1,4 +1,6 @@
1
1
  import { useEffect, useRef } from 'react';
2
+
3
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
2
4
  import uuidv4 from 'uuid/v4';
3
5
  import { getPropsDifference, getShallowPropsDifference } from '../../../compare-props';
4
6
  export function useComponentRenderTracking(_ref) {
@@ -8,6 +10,7 @@ export function useComponentRenderTracking(_ref) {
8
10
  zeroBasedCount = _ref$zeroBasedCount === void 0 ? true : _ref$zeroBasedCount;
9
11
  var propsRef = useRef();
10
12
  var renderCountRef = useRef(zeroBasedCount ? 0 : 1);
13
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
11
14
  var _useRef = useRef(uuidv4()),
12
15
  componentId = _useRef.current;
13
16
  useEffect(function () {
@@ -1,5 +1,6 @@
1
- import type { NodeType, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
1
+ import type { NodeType, ResolvedPos, Schema } from '@atlaskit/editor-prosemirror/model';
2
2
  import { type EditorState } from '@atlaskit/editor-prosemirror/state';
3
3
  export declare const getParentOfTypeCount: (nodeType: NodeType) => ($pos: ResolvedPos) => number;
4
4
  export declare const getPositionAfterTopParentNodeOfType: (nodeType: NodeType) => ($pos: ResolvedPos) => number | undefined;
5
5
  export declare const isSelectionTableNestedInTable: (state: EditorState) => boolean;
6
+ export declare const isNestedTablesSupported: (schema: Schema) => boolean;
@@ -1,5 +1,6 @@
1
- import type { NodeType, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
1
+ import type { NodeType, ResolvedPos, Schema } from '@atlaskit/editor-prosemirror/model';
2
2
  import { type EditorState } from '@atlaskit/editor-prosemirror/state';
3
3
  export declare const getParentOfTypeCount: (nodeType: NodeType) => ($pos: ResolvedPos) => number;
4
4
  export declare const getPositionAfterTopParentNodeOfType: (nodeType: NodeType) => ($pos: ResolvedPos) => number | undefined;
5
5
  export declare const isSelectionTableNestedInTable: (state: EditorState) => boolean;
6
+ export declare const isNestedTablesSupported: (schema: Schema) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "110.23.0",
3
+ "version": "110.24.0",
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/"
@@ -82,7 +82,7 @@
82
82
  "@atlaskit/task-decision": "^19.2.0",
83
83
  "@atlaskit/textfield": "^8.0.0",
84
84
  "@atlaskit/theme": "^21.0.0",
85
- "@atlaskit/tmp-editor-statsig": "^13.30.0",
85
+ "@atlaskit/tmp-editor-statsig": "^13.31.0",
86
86
  "@atlaskit/tokens": "^7.1.0",
87
87
  "@atlaskit/tooltip": "^20.7.0",
88
88
  "@atlaskit/ufo": "^0.4.0",