@atlaskit/editor-common 75.2.4 → 75.3.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/hooks/useSharedPluginState.js +39 -3
  3. package/dist/cjs/media-single/constants.js +4 -2
  4. package/dist/cjs/media-single/index.js +6 -0
  5. package/dist/cjs/media-single/utils.js +2 -1
  6. package/dist/cjs/monitoring/error.js +1 -1
  7. package/dist/cjs/selection/index.js +22 -1
  8. package/dist/cjs/ui/DropList/index.js +1 -1
  9. package/dist/cjs/utils/index.js +6 -0
  10. package/dist/cjs/utils/table.js +24 -0
  11. package/dist/es2019/hooks/useSharedPluginState.js +41 -5
  12. package/dist/es2019/media-single/constants.js +2 -1
  13. package/dist/es2019/media-single/index.js +1 -1
  14. package/dist/es2019/media-single/utils.js +2 -1
  15. package/dist/es2019/monitoring/error.js +1 -1
  16. package/dist/es2019/selection/index.js +18 -1
  17. package/dist/es2019/ui/DropList/index.js +1 -1
  18. package/dist/es2019/utils/index.js +1 -1
  19. package/dist/es2019/utils/table.js +23 -0
  20. package/dist/esm/hooks/useSharedPluginState.js +40 -4
  21. package/dist/esm/media-single/constants.js +2 -1
  22. package/dist/esm/media-single/index.js +1 -1
  23. package/dist/esm/media-single/utils.js +2 -1
  24. package/dist/esm/monitoring/error.js +1 -1
  25. package/dist/esm/selection/index.js +20 -1
  26. package/dist/esm/ui/DropList/index.js +1 -1
  27. package/dist/esm/utils/index.js +1 -1
  28. package/dist/esm/utils/table.js +23 -0
  29. package/dist/types/hooks/useSharedPluginState.d.ts +29 -0
  30. package/dist/types/media-single/constants.d.ts +1 -0
  31. package/dist/types/media-single/index.d.ts +1 -1
  32. package/dist/types/media-single/utils.d.ts +2 -1
  33. package/dist/types/selection/index.d.ts +11 -0
  34. package/dist/types/utils/index.d.ts +1 -1
  35. package/dist/types/utils/table.d.ts +2 -1
  36. package/dist/types-ts4.5/hooks/useSharedPluginState.d.ts +29 -0
  37. package/dist/types-ts4.5/media-single/constants.d.ts +1 -0
  38. package/dist/types-ts4.5/media-single/index.d.ts +1 -1
  39. package/dist/types-ts4.5/media-single/utils.d.ts +2 -1
  40. package/dist/types-ts4.5/selection/index.d.ts +11 -0
  41. package/dist/types-ts4.5/utils/index.d.ts +1 -1
  42. package/dist/types-ts4.5/utils/table.d.ts +2 -1
  43. package/package.json +1 -1
  44. package/tsconfig.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 75.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`32e751116bb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/32e751116bb) - [ED-20088] Debounce updates into the useSharedPluginState to avoid blocking the main thread with unnecessary UI updates
8
+
9
+ ## 75.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`fa39c6ce044`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fa39c6ce044) - [ED-19775] Decouple selection plugin from the editor-core code
14
+
15
+ ### Patch Changes
16
+
17
+ - [`ced80eee086`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ced80eee086) - Updated notes for getMaxWidthForNestedNodeNext
18
+
3
19
  ## 75.2.4
4
20
 
5
21
  ### Patch Changes
@@ -8,6 +8,7 @@ exports.useSharedPluginState = useSharedPluginState;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
10
  var _react = require("react");
11
+ var _debounce = _interopRequireDefault(require("lodash/debounce"));
11
12
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
13
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
14
  /**
@@ -39,6 +40,35 @@ function useStaticPlugins(plugins) {
39
40
  }
40
41
 
41
42
  /**
43
+ *
44
+ * ⚠️⚠️⚠️ This is a debounced hook ⚠️⚠️⚠️
45
+ * If the plugins you are listening to generate multiple shared states while the user is typing,
46
+ * your React Component will get only the last one.
47
+ *
48
+ * Usually, for UI updates, you may need only the last state. But, if you have a specific scenario requiring you to access all states,
49
+ * do not use this hook. Instead, you can subscribe directly to the plugin sharedState API:
50
+ *
51
+ * ```typescript
52
+ *
53
+ * function ExampleSpecialCase({ api }: Props) {
54
+ * const [dogState, setDogState] = React.useState(null);
55
+ * useEffect(() => {
56
+ * const unsub = api.dog.sharedState.onChange(({ nextSharedState, prevSharedState }) => {
57
+ * setDogState(nextSharedState);
58
+ * });
59
+ *
60
+ * return unsub;
61
+ * }, [api]);
62
+ *
63
+ * useEffect(() => {
64
+ * someCriticalAndWeirdUseCase(dogState);
65
+ *
66
+ * }, [dogState]);
67
+ *
68
+ * return null;
69
+ * }
70
+ *
71
+ * ```
42
72
  *
43
73
  * Used to return the current plugin state of
44
74
  * input dependencies
@@ -88,7 +118,13 @@ function useSharedPluginStateInternal(externalPlugins) {
88
118
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
89
119
  pluginStates = _useState2[0],
90
120
  setPluginState = _useState2[1];
121
+ var refStates = (0, _react.useRef)({});
91
122
  (0, _react.useLayoutEffect)(function () {
123
+ var debouncedPluginStateUpdate = (0, _debounce.default)(function () {
124
+ setPluginState(function (currentPluginStates) {
125
+ return _objectSpread(_objectSpread({}, currentPluginStates), refStates.current);
126
+ });
127
+ });
92
128
  var unsubs = Object.entries(externalPlugins).map(function (_ref3) {
93
129
  var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
94
130
  pluginKey = _ref4[0],
@@ -99,12 +135,12 @@ function useSharedPluginStateInternal(externalPlugins) {
99
135
  if (prevSharedState === nextSharedState) {
100
136
  return;
101
137
  }
102
- setPluginState(function (currentPluginStates) {
103
- return _objectSpread(_objectSpread({}, currentPluginStates), {}, (0, _defineProperty2.default)({}, pluginKey, nextSharedState));
104
- });
138
+ refStates.current[pluginKey] = nextSharedState;
139
+ debouncedPluginStateUpdate();
105
140
  });
106
141
  });
107
142
  return function () {
143
+ refStates.current = {};
108
144
  unsubs.forEach(function (cb) {
109
145
  return cb === null || cb === void 0 ? void 0 : cb();
110
146
  });
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.wrappedLayouts = exports.MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH = exports.MEDIA_SINGLE_SNAP_GAP = exports.MEDIA_SINGLE_RESIZE_THROTTLE_TIME = exports.MEDIA_SINGLE_HIGHLIGHT_GAP = exports.MEDIA_SINGLE_HANDLE_MARGIN = exports.MEDIA_SINGLE_GUTTER_SIZE = exports.MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH = exports.Layout = exports.DEFAULT_ROUNDING_INTERVAL = exports.DEFAULT_IMAGE_WIDTH = exports.DEFAULT_IMAGE_HEIGHT = void 0;
6
+ exports.wrappedLayouts = exports.MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH = exports.MEDIA_SINGLE_SNAP_GAP = exports.MEDIA_SINGLE_RESIZE_THROTTLE_TIME = exports.MEDIA_SINGLE_HIGHLIGHT_GAP = exports.MEDIA_SINGLE_HANDLE_MARGIN = exports.MEDIA_SINGLE_GUTTER_SIZE = exports.MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH = exports.Layout = exports.DEFAULT_ROUNDING_INTERVAL = exports.DEFAULT_IMAGE_WIDTH = exports.DEFAULT_IMAGE_HEIGHT = exports.CAPTION_PLACEHOLDER_ID = void 0;
7
7
  var MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH = 24;
8
8
  exports.MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH = MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH;
9
9
  var MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH = 320;
@@ -36,4 +36,6 @@ exports.Layout = Layout;
36
36
  var wrappedLayouts = ['wrap-left', 'wrap-right', 'align-end', 'align-start'];
37
37
  exports.wrappedLayouts = wrappedLayouts;
38
38
  var DEFAULT_ROUNDING_INTERVAL = 0.5;
39
- exports.DEFAULT_ROUNDING_INTERVAL = DEFAULT_ROUNDING_INTERVAL;
39
+ exports.DEFAULT_ROUNDING_INTERVAL = DEFAULT_ROUNDING_INTERVAL;
40
+ var CAPTION_PLACEHOLDER_ID = 'caption-placeholder';
41
+ exports.CAPTION_PLACEHOLDER_ID = CAPTION_PLACEHOLDER_ID;
@@ -3,6 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "CAPTION_PLACEHOLDER_ID", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _constants.CAPTION_PLACEHOLDER_ID;
10
+ }
11
+ });
6
12
  Object.defineProperty(exports, "DEFAULT_IMAGE_HEIGHT", {
7
13
  enumerable: true,
8
14
  get: function get() {
@@ -186,6 +186,7 @@ var calcParentPadding = function calcParentPadding(view, resolvedPos) {
186
186
 
187
187
  /**
188
188
  * Get parent width for a nested media single node for new experience
189
+ * We don't check for mediaSingle selection in this function.
189
190
  * @param view Editor view
190
191
  * @param pos node position
191
192
  * @param forInsertion for insertion
@@ -202,7 +203,7 @@ var getMaxWidthForNestedNodeNext = function getMaxWidthForNestedNodeNext(view, p
202
203
  };
203
204
 
204
205
  /**
205
- * Get parent content width for nested media single node
206
+ * Get parent content width for nested media single node.
206
207
  * @param resolvedPos resolved Position of the node
207
208
  * @param view editor view
208
209
  * @returns parent content width for nested node
@@ -16,7 +16,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
16
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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 = "75.2.4";
19
+ var packageVersion = "75.3.1";
20
20
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
21
21
  // Remove URL as it has UGC
22
22
  // TODO: Sanitise the URL instead of just removing it
@@ -91,6 +91,7 @@ Object.defineProperty(exports, "isValidTargetNode", {
91
91
  return _utils2.isValidTargetNode;
92
92
  }
93
93
  });
94
+ exports.selectNode = void 0;
94
95
  Object.defineProperty(exports, "setGapCursorSelection", {
95
96
  enumerable: true,
96
97
  get: function get() {
@@ -179,4 +180,24 @@ function getRangeSelectionAnalyticsPayload(selection, doc) {
179
180
  }
180
181
  };
181
182
  }
182
- }
183
+ }
184
+
185
+ /**
186
+ * Insert content, delete a range and create a new selection
187
+ * This function automatically handles the mapping of positions for insertion and deletion.
188
+ * The new selection is handled as a function since it may not always be necessary to resolve a position to the transactions mapping
189
+ *
190
+ * @param getSelectionResolvedPos get the resolved position to create a new selection
191
+ * @param insertions content to insert at the specified position
192
+ * @param deletions the ranges to delete
193
+ */
194
+
195
+ var selectNode = function selectNode(pos) {
196
+ return function (state, dispatch) {
197
+ if (dispatch) {
198
+ dispatch(state.tr.setSelection(new _state.NodeSelection(state.doc.resolve(pos))));
199
+ }
200
+ return true;
201
+ };
202
+ };
203
+ exports.selectNode = selectNode;
@@ -24,7 +24,7 @@ var _templateObject, _templateObject2, _templateObject3;
24
24
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
25
25
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
26
26
  var packageName = "@atlaskit/editor-common";
27
- var packageVersion = "75.2.4";
27
+ var packageVersion = "75.3.1";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var DropList = /*#__PURE__*/function (_Component) {
@@ -682,6 +682,12 @@ Object.defineProperty(exports, "isPerformanceObserverAvailable", {
682
682
  return _isPerformanceApiAvailable.isPerformanceObserverAvailable;
683
683
  }
684
684
  });
685
+ Object.defineProperty(exports, "isPositionNearTableRow", {
686
+ enumerable: true,
687
+ get: function get() {
688
+ return _table.isPositionNearTableRow;
689
+ }
690
+ });
685
691
  Object.defineProperty(exports, "isReferencedSource", {
686
692
  enumerable: true,
687
693
  get: function get() {
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.calcTableColumnWidths = calcTableColumnWidths;
8
8
  exports.convertProsemirrorTableNodeToArrayOfRows = convertProsemirrorTableNodeToArrayOfRows;
9
9
  exports.hasMergedCell = hasMergedCell;
10
+ exports.isPositionNearTableRow = isPositionNearTableRow;
10
11
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
12
  function calcTableColumnWidths(node) {
12
13
  var tableColumnWidths = [];
@@ -53,4 +54,27 @@ function convertProsemirrorTableNodeToArrayOfRows(tableNode) {
53
54
  }
54
55
  });
55
56
  return result;
57
+ }
58
+
59
+ /*
60
+ isPositionNearTableRow()
61
+ Returns true when a sibling node, or any of the parent's sibling
62
+ nodes are a tableRow
63
+ */
64
+ function isPositionNearTableRow(pos, schema, direction) {
65
+ if (!schema.nodes.tableRow) {
66
+ return false;
67
+ }
68
+ var doc = pos.doc;
69
+ var resolved = pos;
70
+ var sibling = direction === 'before' ? 'nodeBefore' : 'nodeAfter';
71
+ while (resolved.depth > 0) {
72
+ var _resolved$sibling;
73
+ var siblingType = (_resolved$sibling = resolved[sibling]) === null || _resolved$sibling === void 0 ? void 0 : _resolved$sibling.type;
74
+ if (siblingType === schema.nodes.tableRow) {
75
+ return true;
76
+ }
77
+ resolved = doc.resolve(resolved[direction]());
78
+ }
79
+ return false;
56
80
  }
@@ -1,4 +1,5 @@
1
- import { useLayoutEffect, useMemo, useState } from 'react';
1
+ import { useLayoutEffect, useMemo, useRef, useState } from 'react';
2
+ import debounce from 'lodash/debounce';
2
3
  /**
3
4
  *
4
5
  * Directly map object values
@@ -24,6 +25,35 @@ function useStaticPlugins(plugins) {
24
25
  }
25
26
 
26
27
  /**
28
+ *
29
+ * ⚠️⚠️⚠️ This is a debounced hook ⚠️⚠️⚠️
30
+ * If the plugins you are listening to generate multiple shared states while the user is typing,
31
+ * your React Component will get only the last one.
32
+ *
33
+ * Usually, for UI updates, you may need only the last state. But, if you have a specific scenario requiring you to access all states,
34
+ * do not use this hook. Instead, you can subscribe directly to the plugin sharedState API:
35
+ *
36
+ * ```typescript
37
+ *
38
+ * function ExampleSpecialCase({ api }: Props) {
39
+ * const [dogState, setDogState] = React.useState(null);
40
+ * useEffect(() => {
41
+ * const unsub = api.dog.sharedState.onChange(({ nextSharedState, prevSharedState }) => {
42
+ * setDogState(nextSharedState);
43
+ * });
44
+ *
45
+ * return unsub;
46
+ * }, [api]);
47
+ *
48
+ * useEffect(() => {
49
+ * someCriticalAndWeirdUseCase(dogState);
50
+ *
51
+ * }, [dogState]);
52
+ *
53
+ * return null;
54
+ * }
55
+ *
56
+ * ```
27
57
  *
28
58
  * Used to return the current plugin state of
29
59
  * input dependencies
@@ -67,7 +97,14 @@ export function useSharedPluginState(injectionApi, plugins) {
67
97
  }
68
98
  function useSharedPluginStateInternal(externalPlugins) {
69
99
  const [pluginStates, setPluginState] = useState(mapValues(externalPlugins, value => value === null || value === void 0 ? void 0 : value.sharedState.currentState()));
100
+ const refStates = useRef({});
70
101
  useLayoutEffect(() => {
102
+ const debouncedPluginStateUpdate = debounce(() => {
103
+ setPluginState(currentPluginStates => ({
104
+ ...currentPluginStates,
105
+ ...refStates.current
106
+ }));
107
+ });
71
108
  const unsubs = Object.entries(externalPlugins).map(([pluginKey, externalPlugin]) => {
72
109
  return externalPlugin === null || externalPlugin === void 0 ? void 0 : externalPlugin.sharedState.onChange(({
73
110
  nextSharedState,
@@ -76,13 +113,12 @@ function useSharedPluginStateInternal(externalPlugins) {
76
113
  if (prevSharedState === nextSharedState) {
77
114
  return;
78
115
  }
79
- setPluginState(currentPluginStates => ({
80
- ...currentPluginStates,
81
- [pluginKey]: nextSharedState
82
- }));
116
+ refStates.current[pluginKey] = nextSharedState;
117
+ debouncedPluginStateUpdate();
83
118
  });
84
119
  });
85
120
  return () => {
121
+ refStates.current = {};
86
122
  unsubs.forEach(cb => cb === null || cb === void 0 ? void 0 : cb());
87
123
  };
88
124
  // Do not re-render due to state changes, we only need to check this when
@@ -18,4 +18,5 @@ export let Layout = /*#__PURE__*/function (Layout) {
18
18
  return Layout;
19
19
  }({});
20
20
  export const wrappedLayouts = ['wrap-left', 'wrap-right', 'align-end', 'align-start'];
21
- export const DEFAULT_ROUNDING_INTERVAL = 0.5;
21
+ export const DEFAULT_ROUNDING_INTERVAL = 0.5;
22
+ export const CAPTION_PLACEHOLDER_ID = 'caption-placeholder';
@@ -1,2 +1,2 @@
1
- export { MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_HIGHLIGHT_GAP, MEDIA_SINGLE_GUTTER_SIZE, MEDIA_SINGLE_RESIZE_THROTTLE_TIME, Layout as MediaSingleLayout, DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, wrappedLayouts } from './constants';
1
+ export { MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_HIGHLIGHT_GAP, MEDIA_SINGLE_GUTTER_SIZE, MEDIA_SINGLE_RESIZE_THROTTLE_TIME, Layout as MediaSingleLayout, DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, wrappedLayouts, CAPTION_PLACEHOLDER_ID } from './constants';
2
2
  export { getMediaSinglePixelWidth, calcMediaSinglePixelWidth, calcMediaSingleMaxWidth, getMediaSingleInitialWidth, calculateOffsetLeft, roundToNearest, calcMinWidth, getMaxWidthForNestedNode, getMaxWidthForNestedNodeNext } from './utils';
@@ -163,6 +163,7 @@ const calcParentPadding = (view, resolvedPos) => {
163
163
 
164
164
  /**
165
165
  * Get parent width for a nested media single node for new experience
166
+ * We don't check for mediaSingle selection in this function.
166
167
  * @param view Editor view
167
168
  * @param pos node position
168
169
  * @param forInsertion for insertion
@@ -179,7 +180,7 @@ export const getMaxWidthForNestedNodeNext = (view, pos, forInsertion) => {
179
180
  };
180
181
 
181
182
  /**
182
- * Get parent content width for nested media single node
183
+ * Get parent content width for nested media single node.
183
184
  * @param resolvedPos resolved Position of the node
184
185
  * @param view editor view
185
186
  * @returns parent content width for nested node
@@ -1,6 +1,6 @@
1
1
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
2
2
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
3
- const packageVersion = "75.2.4";
3
+ const packageVersion = "75.3.1";
4
4
  const sanitiseSentryEvents = (data, _hint) => {
5
5
  // Remove URL as it has UGC
6
6
  // TODO: Sanitise the URL instead of just removing it
@@ -76,4 +76,21 @@ export function getRangeSelectionAnalyticsPayload(selection, doc) {
76
76
  }
77
77
  };
78
78
  }
79
- }
79
+ }
80
+
81
+ /**
82
+ * Insert content, delete a range and create a new selection
83
+ * This function automatically handles the mapping of positions for insertion and deletion.
84
+ * The new selection is handled as a function since it may not always be necessary to resolve a position to the transactions mapping
85
+ *
86
+ * @param getSelectionResolvedPos get the resolved position to create a new selection
87
+ * @param insertions content to insert at the specified position
88
+ * @param deletions the ranges to delete
89
+ */
90
+
91
+ export const selectNode = pos => (state, dispatch) => {
92
+ if (dispatch) {
93
+ dispatch(state.tr.setSelection(new NodeSelection(state.doc.resolve(pos))));
94
+ }
95
+ return true;
96
+ };
@@ -9,7 +9,7 @@ import { themed } from '@atlaskit/theme/components';
9
9
  import { borderRadius } from '@atlaskit/theme/constants';
10
10
  import Layer from '../Layer';
11
11
  const packageName = "@atlaskit/editor-common";
12
- const packageVersion = "75.2.4";
12
+ const packageVersion = "75.3.1";
13
13
  const halfFocusRing = 1;
14
14
  const dropOffset = '0, 8';
15
15
  class DropList extends Component {
@@ -21,7 +21,7 @@ export { measureTTI, getTTISeverity, TTI_SEVERITY_THRESHOLD_DEFAULTS, TTI_FROM_I
21
21
  export { isPerformanceAPIAvailable, isPerformanceObserverAvailable } from './performance/is-performance-api-available';
22
22
  export { getResponseEndTime } from './performance/navigation';
23
23
  export { getExtensionRenderer } from './extension-handler';
24
- export { hasMergedCell, calcTableColumnWidths, convertProsemirrorTableNodeToArrayOfRows } from './table';
24
+ export { hasMergedCell, calcTableColumnWidths, convertProsemirrorTableNodeToArrayOfRows, isPositionNearTableRow } from './table';
25
25
  export { createCompareNodes } from './compareNodes';
26
26
  export { compose } from './compose';
27
27
  export { isTextInput } from './is-text-input';
@@ -42,4 +42,27 @@ export function convertProsemirrorTableNodeToArrayOfRows(tableNode) {
42
42
  }
43
43
  });
44
44
  return result;
45
+ }
46
+
47
+ /*
48
+ isPositionNearTableRow()
49
+ Returns true when a sibling node, or any of the parent's sibling
50
+ nodes are a tableRow
51
+ */
52
+ export function isPositionNearTableRow(pos, schema, direction) {
53
+ if (!schema.nodes.tableRow) {
54
+ return false;
55
+ }
56
+ let doc = pos.doc;
57
+ let resolved = pos;
58
+ const sibling = direction === 'before' ? 'nodeBefore' : 'nodeAfter';
59
+ while (resolved.depth > 0) {
60
+ var _resolved$sibling;
61
+ const siblingType = (_resolved$sibling = resolved[sibling]) === null || _resolved$sibling === void 0 ? void 0 : _resolved$sibling.type;
62
+ if (siblingType === schema.nodes.tableRow) {
63
+ return true;
64
+ }
65
+ resolved = doc.resolve(resolved[direction]());
66
+ }
67
+ return false;
45
68
  }
@@ -2,7 +2,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
- import { useLayoutEffect, useMemo, useState } from 'react';
5
+ import { useLayoutEffect, useMemo, useRef, useState } from 'react';
6
+ import debounce from 'lodash/debounce';
6
7
  /**
7
8
  *
8
9
  * Directly map object values
@@ -32,6 +33,35 @@ function useStaticPlugins(plugins) {
32
33
  }
33
34
 
34
35
  /**
36
+ *
37
+ * ⚠️⚠️⚠️ This is a debounced hook ⚠️⚠️⚠️
38
+ * If the plugins you are listening to generate multiple shared states while the user is typing,
39
+ * your React Component will get only the last one.
40
+ *
41
+ * Usually, for UI updates, you may need only the last state. But, if you have a specific scenario requiring you to access all states,
42
+ * do not use this hook. Instead, you can subscribe directly to the plugin sharedState API:
43
+ *
44
+ * ```typescript
45
+ *
46
+ * function ExampleSpecialCase({ api }: Props) {
47
+ * const [dogState, setDogState] = React.useState(null);
48
+ * useEffect(() => {
49
+ * const unsub = api.dog.sharedState.onChange(({ nextSharedState, prevSharedState }) => {
50
+ * setDogState(nextSharedState);
51
+ * });
52
+ *
53
+ * return unsub;
54
+ * }, [api]);
55
+ *
56
+ * useEffect(() => {
57
+ * someCriticalAndWeirdUseCase(dogState);
58
+ *
59
+ * }, [dogState]);
60
+ *
61
+ * return null;
62
+ * }
63
+ *
64
+ * ```
35
65
  *
36
66
  * Used to return the current plugin state of
37
67
  * input dependencies
@@ -81,7 +111,13 @@ function useSharedPluginStateInternal(externalPlugins) {
81
111
  _useState2 = _slicedToArray(_useState, 2),
82
112
  pluginStates = _useState2[0],
83
113
  setPluginState = _useState2[1];
114
+ var refStates = useRef({});
84
115
  useLayoutEffect(function () {
116
+ var debouncedPluginStateUpdate = debounce(function () {
117
+ setPluginState(function (currentPluginStates) {
118
+ return _objectSpread(_objectSpread({}, currentPluginStates), refStates.current);
119
+ });
120
+ });
85
121
  var unsubs = Object.entries(externalPlugins).map(function (_ref3) {
86
122
  var _ref4 = _slicedToArray(_ref3, 2),
87
123
  pluginKey = _ref4[0],
@@ -92,12 +128,12 @@ function useSharedPluginStateInternal(externalPlugins) {
92
128
  if (prevSharedState === nextSharedState) {
93
129
  return;
94
130
  }
95
- setPluginState(function (currentPluginStates) {
96
- return _objectSpread(_objectSpread({}, currentPluginStates), {}, _defineProperty({}, pluginKey, nextSharedState));
97
- });
131
+ refStates.current[pluginKey] = nextSharedState;
132
+ debouncedPluginStateUpdate();
98
133
  });
99
134
  });
100
135
  return function () {
136
+ refStates.current = {};
101
137
  unsubs.forEach(function (cb) {
102
138
  return cb === null || cb === void 0 ? void 0 : cb();
103
139
  });
@@ -18,4 +18,5 @@ export var Layout = /*#__PURE__*/function (Layout) {
18
18
  return Layout;
19
19
  }({});
20
20
  export var wrappedLayouts = ['wrap-left', 'wrap-right', 'align-end', 'align-start'];
21
- export var DEFAULT_ROUNDING_INTERVAL = 0.5;
21
+ export var DEFAULT_ROUNDING_INTERVAL = 0.5;
22
+ export var CAPTION_PLACEHOLDER_ID = 'caption-placeholder';
@@ -1,2 +1,2 @@
1
- export { MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_HIGHLIGHT_GAP, MEDIA_SINGLE_GUTTER_SIZE, MEDIA_SINGLE_RESIZE_THROTTLE_TIME, Layout as MediaSingleLayout, DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, wrappedLayouts } from './constants';
1
+ export { MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_HIGHLIGHT_GAP, MEDIA_SINGLE_GUTTER_SIZE, MEDIA_SINGLE_RESIZE_THROTTLE_TIME, Layout as MediaSingleLayout, DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, wrappedLayouts, CAPTION_PLACEHOLDER_ID } from './constants';
2
2
  export { getMediaSinglePixelWidth, calcMediaSinglePixelWidth, calcMediaSingleMaxWidth, getMediaSingleInitialWidth, calculateOffsetLeft, roundToNearest, calcMinWidth, getMaxWidthForNestedNode, getMaxWidthForNestedNodeNext } from './utils';
@@ -171,6 +171,7 @@ var calcParentPadding = function calcParentPadding(view, resolvedPos) {
171
171
 
172
172
  /**
173
173
  * Get parent width for a nested media single node for new experience
174
+ * We don't check for mediaSingle selection in this function.
174
175
  * @param view Editor view
175
176
  * @param pos node position
176
177
  * @param forInsertion for insertion
@@ -187,7 +188,7 @@ export var getMaxWidthForNestedNodeNext = function getMaxWidthForNestedNodeNext(
187
188
  };
188
189
 
189
190
  /**
190
- * Get parent content width for nested media single node
191
+ * Get parent content width for nested media single node.
191
192
  * @param resolvedPos resolved Position of the node
192
193
  * @param view editor view
193
194
  * @returns parent content width for nested node
@@ -6,7 +6,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
6
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
7
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
8
8
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
9
- var packageVersion = "75.2.4";
9
+ var packageVersion = "75.3.1";
10
10
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
11
11
  // Remove URL as it has UGC
12
12
  // TODO: Sanitise the URL instead of just removing it
@@ -74,4 +74,23 @@ export function getRangeSelectionAnalyticsPayload(selection, doc) {
74
74
  }
75
75
  };
76
76
  }
77
- }
77
+ }
78
+
79
+ /**
80
+ * Insert content, delete a range and create a new selection
81
+ * This function automatically handles the mapping of positions for insertion and deletion.
82
+ * The new selection is handled as a function since it may not always be necessary to resolve a position to the transactions mapping
83
+ *
84
+ * @param getSelectionResolvedPos get the resolved position to create a new selection
85
+ * @param insertions content to insert at the specified position
86
+ * @param deletions the ranges to delete
87
+ */
88
+
89
+ export var selectNode = function selectNode(pos) {
90
+ return function (state, dispatch) {
91
+ if (dispatch) {
92
+ dispatch(state.tr.setSelection(new NodeSelection(state.doc.resolve(pos))));
93
+ }
94
+ return true;
95
+ };
96
+ };
@@ -19,7 +19,7 @@ import { themed } from '@atlaskit/theme/components';
19
19
  import { borderRadius } from '@atlaskit/theme/constants';
20
20
  import Layer from '../Layer';
21
21
  var packageName = "@atlaskit/editor-common";
22
- var packageVersion = "75.2.4";
22
+ var packageVersion = "75.3.1";
23
23
  var halfFocusRing = 1;
24
24
  var dropOffset = '0, 8';
25
25
  var DropList = /*#__PURE__*/function (_Component) {
@@ -21,7 +21,7 @@ export { measureTTI, getTTISeverity, TTI_SEVERITY_THRESHOLD_DEFAULTS, TTI_FROM_I
21
21
  export { isPerformanceAPIAvailable, isPerformanceObserverAvailable } from './performance/is-performance-api-available';
22
22
  export { getResponseEndTime } from './performance/navigation';
23
23
  export { getExtensionRenderer } from './extension-handler';
24
- export { hasMergedCell, calcTableColumnWidths, convertProsemirrorTableNodeToArrayOfRows } from './table';
24
+ export { hasMergedCell, calcTableColumnWidths, convertProsemirrorTableNodeToArrayOfRows, isPositionNearTableRow } from './table';
25
25
  export { createCompareNodes } from './compareNodes';
26
26
  export { compose } from './compose';
27
27
  export { isTextInput } from './is-text-input';
@@ -44,4 +44,27 @@ export function convertProsemirrorTableNodeToArrayOfRows(tableNode) {
44
44
  }
45
45
  });
46
46
  return result;
47
+ }
48
+
49
+ /*
50
+ isPositionNearTableRow()
51
+ Returns true when a sibling node, or any of the parent's sibling
52
+ nodes are a tableRow
53
+ */
54
+ export function isPositionNearTableRow(pos, schema, direction) {
55
+ if (!schema.nodes.tableRow) {
56
+ return false;
57
+ }
58
+ var doc = pos.doc;
59
+ var resolved = pos;
60
+ var sibling = direction === 'before' ? 'nodeBefore' : 'nodeAfter';
61
+ while (resolved.depth > 0) {
62
+ var _resolved$sibling;
63
+ var siblingType = (_resolved$sibling = resolved[sibling]) === null || _resolved$sibling === void 0 ? void 0 : _resolved$sibling.type;
64
+ if (siblingType === schema.nodes.tableRow) {
65
+ return true;
66
+ }
67
+ resolved = doc.resolve(resolved[direction]());
68
+ }
69
+ return false;
47
70
  }
@@ -4,6 +4,35 @@ type NamedPluginStatesFromInjectionAPI<API extends PublicPluginAPI<any> | undefi
4
4
  }>;
5
5
  type ExtractPluginNames<API extends PublicPluginAPI<any>> = API extends PublicPluginAPI<any> ? keyof API : never;
6
6
  /**
7
+ *
8
+ * ⚠️⚠️⚠️ This is a debounced hook ⚠️⚠️⚠️
9
+ * If the plugins you are listening to generate multiple shared states while the user is typing,
10
+ * your React Component will get only the last one.
11
+ *
12
+ * Usually, for UI updates, you may need only the last state. But, if you have a specific scenario requiring you to access all states,
13
+ * do not use this hook. Instead, you can subscribe directly to the plugin sharedState API:
14
+ *
15
+ * ```typescript
16
+ *
17
+ * function ExampleSpecialCase({ api }: Props) {
18
+ * const [dogState, setDogState] = React.useState(null);
19
+ * useEffect(() => {
20
+ * const unsub = api.dog.sharedState.onChange(({ nextSharedState, prevSharedState }) => {
21
+ * setDogState(nextSharedState);
22
+ * });
23
+ *
24
+ * return unsub;
25
+ * }, [api]);
26
+ *
27
+ * useEffect(() => {
28
+ * someCriticalAndWeirdUseCase(dogState);
29
+ *
30
+ * }, [dogState]);
31
+ *
32
+ * return null;
33
+ * }
34
+ *
35
+ * ```
7
36
  *
8
37
  * Used to return the current plugin state of
9
38
  * input dependencies
@@ -19,3 +19,4 @@ export declare enum Layout {
19
19
  }
20
20
  export declare const wrappedLayouts: RichMediaLayout[];
21
21
  export declare const DEFAULT_ROUNDING_INTERVAL = 0.5;
22
+ export declare const CAPTION_PLACEHOLDER_ID = "caption-placeholder";
@@ -1,2 +1,2 @@
1
- export { MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_HIGHLIGHT_GAP, MEDIA_SINGLE_GUTTER_SIZE, MEDIA_SINGLE_RESIZE_THROTTLE_TIME, Layout as MediaSingleLayout, DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, wrappedLayouts, } from './constants';
1
+ export { MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_HIGHLIGHT_GAP, MEDIA_SINGLE_GUTTER_SIZE, MEDIA_SINGLE_RESIZE_THROTTLE_TIME, Layout as MediaSingleLayout, DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, wrappedLayouts, CAPTION_PLACEHOLDER_ID, } from './constants';
2
2
  export { getMediaSinglePixelWidth, calcMediaSinglePixelWidth, calcMediaSingleMaxWidth, getMediaSingleInitialWidth, calculateOffsetLeft, roundToNearest, calcMinWidth, getMaxWidthForNestedNode, getMaxWidthForNestedNodeNext, } from './utils';
@@ -70,13 +70,14 @@ export declare const calcMinWidth: (isVideoFile: boolean, contentWidth: number)
70
70
  export declare const getMaxWidthForNestedNode: (view: EditorView, pos: number | undefined) => number | null;
71
71
  /**
72
72
  * Get parent width for a nested media single node for new experience
73
+ * We don't check for mediaSingle selection in this function.
73
74
  * @param view Editor view
74
75
  * @param pos node position
75
76
  * @param forInsertion for insertion
76
77
  */
77
78
  export declare const getMaxWidthForNestedNodeNext: (view: EditorView, pos: number | undefined, forInsertion?: boolean) => number | null;
78
79
  /**
79
- * Get parent content width for nested media single node
80
+ * Get parent content width for nested media single node.
80
81
  * @param resolvedPos resolved Position of the node
81
82
  * @param view editor view
82
83
  * @returns parent content width for nested node
@@ -1,6 +1,7 @@
1
1
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { AnalyticsEventPayload } from '../analytics';
4
+ import type { Command } from '../types';
4
5
  export { RelativeSelectionPos } from './types';
5
6
  export type { SelectionPluginState, EditorSelectionAPI } from './types';
6
7
  export { GapCursorSelection, Side, JSON_ID, GapBookmark, } from './gap-cursor/selection';
@@ -11,3 +12,13 @@ export declare function getNodeSelectionAnalyticsPayload(selection: Selection):
11
12
  export declare function getAllSelectionAnalyticsPayload(selection: Selection): AnalyticsEventPayload | undefined;
12
13
  export declare function getCellSelectionAnalyticsPayload(state: EditorState): AnalyticsEventPayload | undefined;
13
14
  export declare function getRangeSelectionAnalyticsPayload(selection: Selection, doc: PmNode): AnalyticsEventPayload | undefined;
15
+ /**
16
+ * Insert content, delete a range and create a new selection
17
+ * This function automatically handles the mapping of positions for insertion and deletion.
18
+ * The new selection is handled as a function since it may not always be necessary to resolve a position to the transactions mapping
19
+ *
20
+ * @param getSelectionResolvedPos get the resolved position to create a new selection
21
+ * @param insertions content to insert at the specified position
22
+ * @param deletions the ranges to delete
23
+ */
24
+ export declare const selectNode: (pos: number) => Command;
@@ -30,7 +30,7 @@ export { measureTTI, getTTISeverity, TTI_SEVERITY_THRESHOLD_DEFAULTS, TTI_FROM_I
30
30
  export { isPerformanceAPIAvailable, isPerformanceObserverAvailable, } from './performance/is-performance-api-available';
31
31
  export { getResponseEndTime } from './performance/navigation';
32
32
  export { getExtensionRenderer } from './extension-handler';
33
- export { hasMergedCell, calcTableColumnWidths, convertProsemirrorTableNodeToArrayOfRows, } from './table';
33
+ export { hasMergedCell, calcTableColumnWidths, convertProsemirrorTableNodeToArrayOfRows, isPositionNearTableRow, } from './table';
34
34
  export { createCompareNodes } from './compareNodes';
35
35
  export { compose } from './compose';
36
36
  export { isTextInput } from './is-text-input';
@@ -1,4 +1,5 @@
1
- import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
1
+ import type { Node as PmNode, ResolvedPos, Schema } from '@atlaskit/editor-prosemirror/model';
2
2
  export declare function calcTableColumnWidths(node: PmNode): number[];
3
3
  export declare function hasMergedCell(tableNode: PmNode): boolean;
4
4
  export declare function convertProsemirrorTableNodeToArrayOfRows(tableNode: PmNode): Array<Array<PmNode | null>>;
5
+ export declare function isPositionNearTableRow(pos: ResolvedPos, schema: Schema, direction: 'before' | 'after'): boolean;
@@ -4,6 +4,35 @@ type NamedPluginStatesFromInjectionAPI<API extends PublicPluginAPI<any> | undefi
4
4
  }>;
5
5
  type ExtractPluginNames<API extends PublicPluginAPI<any>> = API extends PublicPluginAPI<any> ? keyof API : never;
6
6
  /**
7
+ *
8
+ * ⚠️⚠️⚠️ This is a debounced hook ⚠️⚠️⚠️
9
+ * If the plugins you are listening to generate multiple shared states while the user is typing,
10
+ * your React Component will get only the last one.
11
+ *
12
+ * Usually, for UI updates, you may need only the last state. But, if you have a specific scenario requiring you to access all states,
13
+ * do not use this hook. Instead, you can subscribe directly to the plugin sharedState API:
14
+ *
15
+ * ```typescript
16
+ *
17
+ * function ExampleSpecialCase({ api }: Props) {
18
+ * const [dogState, setDogState] = React.useState(null);
19
+ * useEffect(() => {
20
+ * const unsub = api.dog.sharedState.onChange(({ nextSharedState, prevSharedState }) => {
21
+ * setDogState(nextSharedState);
22
+ * });
23
+ *
24
+ * return unsub;
25
+ * }, [api]);
26
+ *
27
+ * useEffect(() => {
28
+ * someCriticalAndWeirdUseCase(dogState);
29
+ *
30
+ * }, [dogState]);
31
+ *
32
+ * return null;
33
+ * }
34
+ *
35
+ * ```
7
36
  *
8
37
  * Used to return the current plugin state of
9
38
  * input dependencies
@@ -19,3 +19,4 @@ export declare enum Layout {
19
19
  }
20
20
  export declare const wrappedLayouts: RichMediaLayout[];
21
21
  export declare const DEFAULT_ROUNDING_INTERVAL = 0.5;
22
+ export declare const CAPTION_PLACEHOLDER_ID = "caption-placeholder";
@@ -1,2 +1,2 @@
1
- export { MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_HIGHLIGHT_GAP, MEDIA_SINGLE_GUTTER_SIZE, MEDIA_SINGLE_RESIZE_THROTTLE_TIME, Layout as MediaSingleLayout, DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, wrappedLayouts, } from './constants';
1
+ export { MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_HIGHLIGHT_GAP, MEDIA_SINGLE_GUTTER_SIZE, MEDIA_SINGLE_RESIZE_THROTTLE_TIME, Layout as MediaSingleLayout, DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, wrappedLayouts, CAPTION_PLACEHOLDER_ID, } from './constants';
2
2
  export { getMediaSinglePixelWidth, calcMediaSinglePixelWidth, calcMediaSingleMaxWidth, getMediaSingleInitialWidth, calculateOffsetLeft, roundToNearest, calcMinWidth, getMaxWidthForNestedNode, getMaxWidthForNestedNodeNext, } from './utils';
@@ -70,13 +70,14 @@ export declare const calcMinWidth: (isVideoFile: boolean, contentWidth: number)
70
70
  export declare const getMaxWidthForNestedNode: (view: EditorView, pos: number | undefined) => number | null;
71
71
  /**
72
72
  * Get parent width for a nested media single node for new experience
73
+ * We don't check for mediaSingle selection in this function.
73
74
  * @param view Editor view
74
75
  * @param pos node position
75
76
  * @param forInsertion for insertion
76
77
  */
77
78
  export declare const getMaxWidthForNestedNodeNext: (view: EditorView, pos: number | undefined, forInsertion?: boolean) => number | null;
78
79
  /**
79
- * Get parent content width for nested media single node
80
+ * Get parent content width for nested media single node.
80
81
  * @param resolvedPos resolved Position of the node
81
82
  * @param view editor view
82
83
  * @returns parent content width for nested node
@@ -1,6 +1,7 @@
1
1
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { AnalyticsEventPayload } from '../analytics';
4
+ import type { Command } from '../types';
4
5
  export { RelativeSelectionPos } from './types';
5
6
  export type { SelectionPluginState, EditorSelectionAPI } from './types';
6
7
  export { GapCursorSelection, Side, JSON_ID, GapBookmark, } from './gap-cursor/selection';
@@ -11,3 +12,13 @@ export declare function getNodeSelectionAnalyticsPayload(selection: Selection):
11
12
  export declare function getAllSelectionAnalyticsPayload(selection: Selection): AnalyticsEventPayload | undefined;
12
13
  export declare function getCellSelectionAnalyticsPayload(state: EditorState): AnalyticsEventPayload | undefined;
13
14
  export declare function getRangeSelectionAnalyticsPayload(selection: Selection, doc: PmNode): AnalyticsEventPayload | undefined;
15
+ /**
16
+ * Insert content, delete a range and create a new selection
17
+ * This function automatically handles the mapping of positions for insertion and deletion.
18
+ * The new selection is handled as a function since it may not always be necessary to resolve a position to the transactions mapping
19
+ *
20
+ * @param getSelectionResolvedPos get the resolved position to create a new selection
21
+ * @param insertions content to insert at the specified position
22
+ * @param deletions the ranges to delete
23
+ */
24
+ export declare const selectNode: (pos: number) => Command;
@@ -30,7 +30,7 @@ export { measureTTI, getTTISeverity, TTI_SEVERITY_THRESHOLD_DEFAULTS, TTI_FROM_I
30
30
  export { isPerformanceAPIAvailable, isPerformanceObserverAvailable, } from './performance/is-performance-api-available';
31
31
  export { getResponseEndTime } from './performance/navigation';
32
32
  export { getExtensionRenderer } from './extension-handler';
33
- export { hasMergedCell, calcTableColumnWidths, convertProsemirrorTableNodeToArrayOfRows, } from './table';
33
+ export { hasMergedCell, calcTableColumnWidths, convertProsemirrorTableNodeToArrayOfRows, isPositionNearTableRow, } from './table';
34
34
  export { createCompareNodes } from './compareNodes';
35
35
  export { compose } from './compose';
36
36
  export { isTextInput } from './is-text-input';
@@ -1,4 +1,5 @@
1
- import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
1
+ import type { Node as PmNode, ResolvedPos, Schema } from '@atlaskit/editor-prosemirror/model';
2
2
  export declare function calcTableColumnWidths(node: PmNode): number[];
3
3
  export declare function hasMergedCell(tableNode: PmNode): boolean;
4
4
  export declare function convertProsemirrorTableNodeToArrayOfRows(tableNode: PmNode): Array<Array<PmNode | null>>;
5
+ export declare function isPositionNearTableRow(pos: ResolvedPos, schema: Schema, direction: 'before' | 'after'): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "75.2.4",
3
+ "version": "75.3.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/"
package/tsconfig.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "./docs/**/*.tsx",
12
12
  "test-helpers/**/*.ts",
13
13
  "test-helpers/**/*.tsx"
14
- ],
14
+ , "../editor-core/src/utils/__tests__/unit/table.ts" ],
15
15
  "exclude": [
16
16
  "node_modules",
17
17
  "src/json-schema",