@atlaskit/editor-common 75.2.3 → 75.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/media-single/constants.js +4 -2
  3. package/dist/cjs/media-single/index.js +6 -0
  4. package/dist/cjs/media-single/utils.js +2 -1
  5. package/dist/cjs/monitoring/error.js +1 -1
  6. package/dist/cjs/selection/index.js +22 -1
  7. package/dist/cjs/ui/DropList/index.js +1 -1
  8. package/dist/cjs/ui/MediaSingle/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/media-single/constants.js +2 -1
  12. package/dist/es2019/media-single/index.js +1 -1
  13. package/dist/es2019/media-single/utils.js +2 -1
  14. package/dist/es2019/monitoring/error.js +1 -1
  15. package/dist/es2019/selection/index.js +18 -1
  16. package/dist/es2019/ui/DropList/index.js +1 -1
  17. package/dist/es2019/ui/MediaSingle/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/media-single/constants.js +2 -1
  21. package/dist/esm/media-single/index.js +1 -1
  22. package/dist/esm/media-single/utils.js +2 -1
  23. package/dist/esm/monitoring/error.js +1 -1
  24. package/dist/esm/selection/index.js +20 -1
  25. package/dist/esm/ui/DropList/index.js +1 -1
  26. package/dist/esm/ui/MediaSingle/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/media-single/constants.d.ts +1 -0
  30. package/dist/types/media-single/index.d.ts +1 -1
  31. package/dist/types/media-single/utils.d.ts +2 -1
  32. package/dist/types/selection/index.d.ts +11 -0
  33. package/dist/types/utils/index.d.ts +1 -1
  34. package/dist/types/utils/table.d.ts +2 -1
  35. package/dist/types-ts4.5/media-single/constants.d.ts +1 -0
  36. package/dist/types-ts4.5/media-single/index.d.ts +1 -1
  37. package/dist/types-ts4.5/media-single/utils.d.ts +2 -1
  38. package/dist/types-ts4.5/selection/index.d.ts +11 -0
  39. package/dist/types-ts4.5/utils/index.d.ts +1 -1
  40. package/dist/types-ts4.5/utils/table.d.ts +2 -1
  41. package/package.json +3 -3
  42. package/tsconfig.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 75.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`fa39c6ce044`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fa39c6ce044) - [ED-19775] Decouple selection plugin from the editor-core code
8
+
9
+ ### Patch Changes
10
+
11
+ - [`ced80eee086`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ced80eee086) - Updated notes for getMaxWidthForNestedNodeNext
12
+
13
+ ## 75.2.4
14
+
15
+ ### Patch Changes
16
+
17
+ - [`ca001e68a96`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ca001e68a96) - Fixed typos in comments
18
+
3
19
  ## 75.2.3
4
20
 
5
21
  ### Patch Changes
@@ -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.3";
19
+ var packageVersion = "75.3.0";
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.3";
27
+ var packageVersion = "75.3.0";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var DropList = /*#__PURE__*/function (_Component) {
@@ -44,7 +44,7 @@ function MediaSingle(_ref) {
44
44
  }
45
45
  // When width is not set we have an absolute height for a given embed.
46
46
  // When both width and height are set we use them to determine ratio and use that to define
47
- // embed height in relation to whatever width of an dom element is in runtime
47
+ // embed height in relation to whatever width of an dom element is in runtime.
48
48
  var isHeightOnly = width === undefined;
49
49
  if (mediaSingleWidth) {
50
50
  var pxWidth = (0, _utils.getMediaSinglePixelWidth)(mediaSingleWidth, editorWidth, size === null || size === void 0 ? void 0 : size.widthType, _constants.MEDIA_SINGLE_GUTTER_SIZE);
@@ -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
  }
@@ -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.3";
3
+ const packageVersion = "75.3.0";
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.3";
12
+ const packageVersion = "75.3.0";
13
13
  const halfFocusRing = 1;
14
14
  const dropOffset = '0, 8';
15
15
  class DropList extends Component {
@@ -32,7 +32,7 @@ export default function MediaSingle({
32
32
  }
33
33
  // When width is not set we have an absolute height for a given embed.
34
34
  // When both width and height are set we use them to determine ratio and use that to define
35
- // embed height in relation to whatever width of an dom element is in runtime
35
+ // embed height in relation to whatever width of an dom element is in runtime.
36
36
  const isHeightOnly = width === undefined;
37
37
  if (mediaSingleWidth) {
38
38
  const pxWidth = getMediaSinglePixelWidth(mediaSingleWidth, editorWidth, size === null || size === void 0 ? void 0 : size.widthType, MEDIA_SINGLE_GUTTER_SIZE);
@@ -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
  }
@@ -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.3";
9
+ var packageVersion = "75.3.0";
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.3";
22
+ var packageVersion = "75.3.0";
23
23
  var halfFocusRing = 1;
24
24
  var dropOffset = '0, 8';
25
25
  var DropList = /*#__PURE__*/function (_Component) {
@@ -36,7 +36,7 @@ export default function MediaSingle(_ref) {
36
36
  }
37
37
  // When width is not set we have an absolute height for a given embed.
38
38
  // When both width and height are set we use them to determine ratio and use that to define
39
- // embed height in relation to whatever width of an dom element is in runtime
39
+ // embed height in relation to whatever width of an dom element is in runtime.
40
40
  var isHeightOnly = width === undefined;
41
41
  if (mediaSingleWidth) {
42
42
  var pxWidth = getMediaSinglePixelWidth(mediaSingleWidth, editorWidth, size === null || size === void 0 ? void 0 : size.widthType, MEDIA_SINGLE_GUTTER_SIZE);
@@ -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
  }
@@ -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;
@@ -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.3",
3
+ "version": "75.3.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/"
@@ -102,7 +102,7 @@
102
102
  "@atlaskit/icon-object": "^6.3.0",
103
103
  "@atlaskit/in-product-testing": "^0.2.0",
104
104
  "@atlaskit/link-datasource": "^1.2.0",
105
- "@atlaskit/link-picker": "^1.29.0",
105
+ "@atlaskit/link-picker": "^1.30.0",
106
106
  "@atlaskit/media-card": "^77.0.0",
107
107
  "@atlaskit/media-client": "^24.0.0",
108
108
  "@atlaskit/media-picker": "^66.2.0",
@@ -115,7 +115,7 @@
115
115
  "@atlaskit/task-decision": "^17.9.0",
116
116
  "@atlaskit/textfield": "^5.6.0",
117
117
  "@atlaskit/theme": "^12.6.0",
118
- "@atlaskit/tokens": "^1.24.0",
118
+ "@atlaskit/tokens": "^1.25.0",
119
119
  "@atlaskit/tooltip": "^17.8.0",
120
120
  "@atlaskit/ufo": "^0.2.0",
121
121
  "@atlaskit/width-detector": "^4.1.0",
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",