@atlaskit/editor-common 99.10.1 → 99.12.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 (38) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/cjs/lazy-node-view/index.js +7 -2
  3. package/dist/cjs/monitoring/error.js +1 -1
  4. package/dist/cjs/react-node-view/getInlineNodeViewProducer.js +15 -8
  5. package/dist/cjs/selection/index.js +6 -0
  6. package/dist/cjs/selection/utils.js +36 -2
  7. package/dist/cjs/ui/DropList/index.js +1 -1
  8. package/dist/cjs/utils/index.js +6 -0
  9. package/dist/cjs/utils/slice.js +20 -1
  10. package/dist/es2019/lazy-node-view/index.js +3 -2
  11. package/dist/es2019/monitoring/error.js +1 -1
  12. package/dist/es2019/react-node-view/getInlineNodeViewProducer.js +15 -8
  13. package/dist/es2019/selection/index.js +1 -1
  14. package/dist/es2019/selection/utils.js +35 -1
  15. package/dist/es2019/ui/DropList/index.js +1 -1
  16. package/dist/es2019/utils/index.js +1 -1
  17. package/dist/es2019/utils/slice.js +15 -2
  18. package/dist/esm/lazy-node-view/index.js +3 -2
  19. package/dist/esm/monitoring/error.js +1 -1
  20. package/dist/esm/react-node-view/getInlineNodeViewProducer.js +15 -8
  21. package/dist/esm/selection/index.js +1 -1
  22. package/dist/esm/selection/utils.js +35 -1
  23. package/dist/esm/ui/DropList/index.js +1 -1
  24. package/dist/esm/utils/index.js +1 -1
  25. package/dist/esm/utils/slice.js +19 -2
  26. package/dist/types/analytics/types/general-events.d.ts +2 -0
  27. package/dist/types/lazy-node-view/index.d.ts +2 -0
  28. package/dist/types/selection/index.d.ts +1 -1
  29. package/dist/types/selection/utils.d.ts +4 -0
  30. package/dist/types/utils/index.d.ts +1 -1
  31. package/dist/types/utils/slice.d.ts +3 -1
  32. package/dist/types-ts4.5/analytics/types/general-events.d.ts +2 -0
  33. package/dist/types-ts4.5/lazy-node-view/index.d.ts +2 -0
  34. package/dist/types-ts4.5/selection/index.d.ts +1 -1
  35. package/dist/types-ts4.5/selection/utils.d.ts +4 -0
  36. package/dist/types-ts4.5/utils/index.d.ts +1 -1
  37. package/dist/types-ts4.5/utils/slice.d.ts +3 -1
  38. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 99.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#111831](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/111831)
8
+ [`66895944dfac9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/66895944dfac9) -
9
+ [ED-26430] Block drag-and-drop of legacy content macro extension
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 99.11.0
16
+
17
+ ### Minor Changes
18
+
19
+ - [#111465](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/111465)
20
+ [`c0cbae02ded12`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c0cbae02ded12) -
21
+ Add utility for expanding selection boundaries
22
+
23
+ ### Patch Changes
24
+
25
+ - [#112757](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/112757)
26
+ [`16ea3fd7c7417`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/16ea3fd7c7417) -
27
+ Added account and browser locale attributes to the editor started event
28
+ - Updated dependencies
29
+
3
30
  ## 99.10.1
4
31
 
5
32
  ### Patch Changes
@@ -4,6 +4,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
+ Object.defineProperty(exports, "LazyNodeView", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _nodeView.LazyNodeView;
11
+ }
12
+ });
7
13
  Object.defineProperty(exports, "convertToInlineCss", {
8
14
  enumerable: true,
9
15
  get: function get() {
@@ -126,7 +132,7 @@ var withLazyLoading = exports.withLazyLoading = function withLazyLoading(_ref) {
126
132
  var nodeName = _ref.nodeName,
127
133
  loader = _ref.loader,
128
134
  getNodeViewOptions = _ref.getNodeViewOptions;
129
- var createLazyNodeView = function createLazyNodeView(node, view, getPos, decorations) {
135
+ return function (node, view, getPos, decorations) {
130
136
  var _node$type;
131
137
  var requestedNodes = requestedNodesPerEditorView.get(view);
132
138
  if (!requestedNodes) {
@@ -203,5 +209,4 @@ var withLazyLoading = exports.withLazyLoading = function withLazyLoading(_ref) {
203
209
  }
204
210
  return new _nodeView.LazyNodeView(node, view, getPos, decorations);
205
211
  };
206
- return createLazyNodeView;
207
212
  };
@@ -17,7 +17,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
17
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
18
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
19
19
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
20
- var packageVersion = "99.10.1";
20
+ var packageVersion = "99.12.0";
21
21
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
22
22
  // Remove URL as it has UGC
23
23
  // TODO: Sanitise the URL instead of just removing it
@@ -89,17 +89,24 @@ function createNodeView(_ref) {
89
89
  }
90
90
  function attachNodeViewObserver() {
91
91
  var observer = (0, _onVisibleObserverFactory.getOrCreateOnVisibleObserver)(nodeViewParams.view);
92
- removeIntersectionObserver = observer.observe(domRef, function () {
93
- if (!didRenderComponentWithIntersectionObserver && !destroyed) {
94
- domRef.replaceChildren();
95
- renderComponent();
96
- didRenderComponentWithIntersectionObserver = true;
97
- }
98
- });
92
+ if (domRef) {
93
+ removeIntersectionObserver = observer.observe(domRef, function () {
94
+ if (!didRenderComponentWithIntersectionObserver && !destroyed) {
95
+ domRef.replaceChildren();
96
+ renderComponent();
97
+ didRenderComponentWithIntersectionObserver = true;
98
+ }
99
+ });
100
+ }
99
101
  }
100
102
  if (shouldVirtualize) {
101
103
  renderFallback();
102
- attachNodeViewObserver();
104
+ // allow the fallback to render first before attaching the observer.
105
+ // Will tweak this in a follow up PR to optimise rendering of visible
106
+ // nodes without fallback rendering.
107
+ setTimeout(function () {
108
+ attachNodeViewObserver();
109
+ }, 0);
103
110
  } else {
104
111
  var _getPerformanceOption = (0, _utils.getPerformanceOptions)(nodeViewParams.view),
105
112
  samplingRate = _getPerformanceOption.samplingRate,
@@ -64,6 +64,12 @@ Object.defineProperty(exports, "endPositionOfParent", {
64
64
  return _utils2.endPositionOfParent;
65
65
  }
66
66
  });
67
+ Object.defineProperty(exports, "expandSelectionBounds", {
68
+ enumerable: true,
69
+ get: function get() {
70
+ return _utils2.expandSelectionBounds;
71
+ }
72
+ });
67
73
  Object.defineProperty(exports, "gapCursorStyles", {
68
74
  enumerable: true,
69
75
  get: function get() {
@@ -8,7 +8,7 @@ exports.atTheBeginningOfDoc = atTheBeginningOfDoc;
8
8
  exports.atTheEndOfBlock = atTheEndOfBlock;
9
9
  exports.atTheEndOfDoc = atTheEndOfDoc;
10
10
  exports.endPositionOfParent = endPositionOfParent;
11
- exports.isSelectionAtStartOfNode = exports.isSelectionAtEndOfNode = void 0;
11
+ exports.isSelectionAtStartOfNode = exports.isSelectionAtEndOfNode = exports.expandSelectionBounds = void 0;
12
12
  exports.startPositionOfParent = startPositionOfParent;
13
13
  var _state = require("@atlaskit/editor-prosemirror/state");
14
14
  var _selection = require("./gap-cursor/selection");
@@ -78,4 +78,38 @@ function startPositionOfParent(resolvedPos) {
78
78
  }
79
79
  function endPositionOfParent(resolvedPos) {
80
80
  return resolvedPos.end(resolvedPos.depth) + 1;
81
- }
81
+ }
82
+ var expandSelectionBounds = exports.expandSelectionBounds = function expandSelectionBounds($anchor, $head) {
83
+ var $from = $anchor.min($head);
84
+ var $to = $anchor.max($head);
85
+ var fromDepth = $from.depth;
86
+ var toDepth = $to.depth;
87
+ var selectionStart = fromDepth ? $from.before() : $from.pos;
88
+ var selectionEnd = toDepth ? $to.after() : $to.pos;
89
+ var selectionHasGrandparent = toDepth > 1 && fromDepth > 1;
90
+ var selectionIsAcrossDiffParents = selectionHasGrandparent && !$to.parent.isTextblock && !$to.sameParent($from);
91
+ var selectionIsAcrossTextBlocksWithDiffParents = selectionHasGrandparent && $to.parent.isTextblock && $to.before(toDepth - 1) !== $from.before(fromDepth - 1);
92
+ if (toDepth > fromDepth) {
93
+ // expand end of selection to after the last node
94
+ selectionEnd = fromDepth ? $to.after(fromDepth) : $to.after(1);
95
+ } else if (toDepth < fromDepth) {
96
+ // expand start of selection to before the current node
97
+ selectionStart = toDepth ? $from.before(toDepth) : $from.before(1);
98
+ } else if (selectionIsAcrossDiffParents || selectionIsAcrossTextBlocksWithDiffParents) {
99
+ // when selection from/to share same depth with different parents, hoist up the selection to the parent of the highest depth in the selection
100
+ selectionStart = $from.before(fromDepth - 1);
101
+ selectionEnd = $to.after(toDepth - 1);
102
+ } else if (!$from.node().inlineContent) {
103
+ // when selection might be a Node selection, return what was passed in
104
+ return {
105
+ $anchor: $anchor,
106
+ $head: $head
107
+ };
108
+ }
109
+ var $expandedFrom = $anchor.doc.resolve(selectionStart);
110
+ var $expandedTo = $anchor.doc.resolve(selectionEnd);
111
+ return {
112
+ $anchor: $anchor === $from ? $expandedFrom : $expandedTo,
113
+ $head: $head === $to ? $expandedTo : $expandedFrom
114
+ };
115
+ };
@@ -23,7 +23,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
23
23
  * @jsx jsx
24
24
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
25
25
  var packageName = "@atlaskit/editor-common";
26
- var packageVersion = "99.10.1";
26
+ var packageVersion = "99.12.0";
27
27
  var halfFocusRing = 1;
28
28
  var dropOffset = '0, 8';
29
29
  // Ignored via go/ees005
@@ -606,6 +606,12 @@ Object.defineProperty(exports, "hasMergedCell", {
606
606
  return _table.hasMergedCell;
607
607
  }
608
608
  });
609
+ Object.defineProperty(exports, "hasNode", {
610
+ enumerable: true,
611
+ get: function get() {
612
+ return _slice.hasNode;
613
+ }
614
+ });
609
615
  Object.defineProperty(exports, "hasVisibleContent", {
610
616
  enumerable: true,
611
617
  get: function get() {
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.flatmap = flatmap;
8
8
  exports.getFragmentBackingArray = getFragmentBackingArray;
9
+ exports.hasNode = void 0;
9
10
  exports.mapChildren = mapChildren;
10
11
  exports.mapFragment = mapFragment;
11
12
  exports.mapSlice = mapSlice;
@@ -59,4 +60,22 @@ function mapChildren(node, callback) {
59
60
  array.push(callback(node.child(i), i, node instanceof _model.Fragment ? node : node.content));
60
61
  }
61
62
  return array;
62
- }
63
+ }
64
+ var findNode = function findNode(predicate) {
65
+ return function (slice) {
66
+ var foundNode = null;
67
+ slice.content.nodesBetween(0, slice.content.size, function (node) {
68
+ if (predicate(node)) {
69
+ foundNode = node;
70
+ return false;
71
+ }
72
+ return true;
73
+ });
74
+ return foundNode;
75
+ };
76
+ };
77
+ var hasNode = exports.hasNode = function hasNode(predicate) {
78
+ return function (slice) {
79
+ return !!findNode(predicate)(slice);
80
+ };
81
+ };
@@ -5,6 +5,8 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
5
  import { cancelCallback, scheduleCallback } from './lazy-scheduler';
6
6
  import { LazyNodeView, makeNodePlaceholderId } from './node-view';
7
7
  export { convertToInlineCss } from './css-helper';
8
+ export { LazyNodeView };
9
+
8
10
  /**
9
11
  * 📢 Public Plugin Key
10
12
  *
@@ -111,7 +113,7 @@ export const withLazyLoading = ({
111
113
  loader,
112
114
  getNodeViewOptions
113
115
  }) => {
114
- const createLazyNodeView = (node, view, getPos, decorations) => {
116
+ return (node, view, getPos, decorations) => {
115
117
  var _node$type, _node$type$spec;
116
118
  let requestedNodes = requestedNodesPerEditorView.get(view);
117
119
  if (!requestedNodes) {
@@ -185,5 +187,4 @@ export const withLazyLoading = ({
185
187
  }
186
188
  return new LazyNodeView(node, view, getPos, decorations);
187
189
  };
188
- return createLazyNodeView;
189
190
  };
@@ -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 = "99.10.1";
4
+ const packageVersion = "99.12.0";
5
5
  const sanitiseSentryEvents = (data, _hint) => {
6
6
  // Remove URL as it has UGC
7
7
  // TODO: Sanitise the URL instead of just removing it
@@ -82,17 +82,24 @@ function createNodeView({
82
82
  }
83
83
  function attachNodeViewObserver() {
84
84
  const observer = getOrCreateOnVisibleObserver(nodeViewParams.view);
85
- removeIntersectionObserver = observer.observe(domRef, () => {
86
- if (!didRenderComponentWithIntersectionObserver && !destroyed) {
87
- domRef.replaceChildren();
88
- renderComponent();
89
- didRenderComponentWithIntersectionObserver = true;
90
- }
91
- });
85
+ if (domRef) {
86
+ removeIntersectionObserver = observer.observe(domRef, () => {
87
+ if (!didRenderComponentWithIntersectionObserver && !destroyed) {
88
+ domRef.replaceChildren();
89
+ renderComponent();
90
+ didRenderComponentWithIntersectionObserver = true;
91
+ }
92
+ });
93
+ }
92
94
  }
93
95
  if (shouldVirtualize) {
94
96
  renderFallback();
95
- attachNodeViewObserver();
97
+ // allow the fallback to render first before attaching the observer.
98
+ // Will tweak this in a follow up PR to optimise rendering of visible
99
+ // nodes without fallback rendering.
100
+ setTimeout(() => {
101
+ attachNodeViewObserver();
102
+ }, 0);
96
103
  } else {
97
104
  const {
98
105
  samplingRate,
@@ -12,7 +12,7 @@ export { isIgnored } from './gap-cursor/utils/is-ignored';
12
12
  export { isValidTargetNode } from './gap-cursor/utils/is-valid-target-node';
13
13
  export { setGapCursorSelection } from './gap-cursor/utils/setGapCursorSelection';
14
14
  export { hideCaretModifier, gapCursorStyles } from './gap-cursor/styles';
15
- export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent } from './utils';
15
+ export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, expandSelectionBounds, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent } from './utils';
16
16
  export function getNodeSelectionAnalyticsPayload(selection) {
17
17
  if (selection instanceof NodeSelection) {
18
18
  return {
@@ -78,4 +78,38 @@ export function startPositionOfParent(resolvedPos) {
78
78
  }
79
79
  export function endPositionOfParent(resolvedPos) {
80
80
  return resolvedPos.end(resolvedPos.depth) + 1;
81
- }
81
+ }
82
+ export const expandSelectionBounds = ($anchor, $head) => {
83
+ const $from = $anchor.min($head);
84
+ const $to = $anchor.max($head);
85
+ const fromDepth = $from.depth;
86
+ const toDepth = $to.depth;
87
+ let selectionStart = fromDepth ? $from.before() : $from.pos;
88
+ let selectionEnd = toDepth ? $to.after() : $to.pos;
89
+ const selectionHasGrandparent = toDepth > 1 && fromDepth > 1;
90
+ const selectionIsAcrossDiffParents = selectionHasGrandparent && !$to.parent.isTextblock && !$to.sameParent($from);
91
+ const selectionIsAcrossTextBlocksWithDiffParents = selectionHasGrandparent && $to.parent.isTextblock && $to.before(toDepth - 1) !== $from.before(fromDepth - 1);
92
+ if (toDepth > fromDepth) {
93
+ // expand end of selection to after the last node
94
+ selectionEnd = fromDepth ? $to.after(fromDepth) : $to.after(1);
95
+ } else if (toDepth < fromDepth) {
96
+ // expand start of selection to before the current node
97
+ selectionStart = toDepth ? $from.before(toDepth) : $from.before(1);
98
+ } else if (selectionIsAcrossDiffParents || selectionIsAcrossTextBlocksWithDiffParents) {
99
+ // when selection from/to share same depth with different parents, hoist up the selection to the parent of the highest depth in the selection
100
+ selectionStart = $from.before(fromDepth - 1);
101
+ selectionEnd = $to.after(toDepth - 1);
102
+ } else if (!$from.node().inlineContent) {
103
+ // when selection might be a Node selection, return what was passed in
104
+ return {
105
+ $anchor,
106
+ $head
107
+ };
108
+ }
109
+ const $expandedFrom = $anchor.doc.resolve(selectionStart);
110
+ const $expandedTo = $anchor.doc.resolve(selectionEnd);
111
+ return {
112
+ $anchor: $anchor === $from ? $expandedFrom : $expandedTo,
113
+ $head: $head === $to ? $expandedTo : $expandedFrom
114
+ };
115
+ };
@@ -13,7 +13,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
13
13
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
14
14
  import Layer from '../Layer';
15
15
  const packageName = "@atlaskit/editor-common";
16
- const packageVersion = "99.10.1";
16
+ const packageVersion = "99.12.0";
17
17
  const halfFocusRing = 1;
18
18
  const dropOffset = '0, 8';
19
19
  // Ignored via go/ees005
@@ -53,7 +53,7 @@ validNode,
53
53
  */
54
54
  validateNodes, isType, isParagraph, isText, isLinkMark, SelectedState, isNodeSelectedOrInRange, isSupportedInParent, isMediaNode, isNodeBeforeMediaNode } from './nodes';
55
55
  export { pluginFactory } from './plugin-state-factory';
56
- export { getFragmentBackingArray, mapFragment, mapSlice, flatmap, mapChildren } from './slice';
56
+ export { getFragmentBackingArray, mapFragment, mapSlice, flatmap, mapChildren, hasNode } from './slice';
57
57
  export { walkUpTreeUntil, unwrap, removeNestedEmptyEls, containsClassName, closest, closestElement, parsePx, mapElem, maphElem } from './dom';
58
58
  export { default as ADFTraversor } from './traversor';
59
59
  /**
@@ -1,5 +1,4 @@
1
1
  import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
2
-
3
2
  /**
4
3
  * A helper to get the underlying array of a fragment.
5
4
  */
@@ -47,4 +46,18 @@ export function mapChildren(node, callback) {
47
46
  array.push(callback(node.child(i), i, node instanceof Fragment ? node : node.content));
48
47
  }
49
48
  return array;
50
- }
49
+ }
50
+ const findNode = predicate => slice => {
51
+ let foundNode = null;
52
+ slice.content.nodesBetween(0, slice.content.size, node => {
53
+ if (predicate(node)) {
54
+ foundNode = node;
55
+ return false;
56
+ }
57
+ return true;
58
+ });
59
+ return foundNode;
60
+ };
61
+ export const hasNode = predicate => slice => {
62
+ return !!findNode(predicate)(slice);
63
+ };
@@ -6,6 +6,8 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
6
6
  import { cancelCallback, scheduleCallback } from './lazy-scheduler';
7
7
  import { LazyNodeView, makeNodePlaceholderId } from './node-view';
8
8
  export { convertToInlineCss } from './css-helper';
9
+ export { LazyNodeView };
10
+
9
11
  /**
10
12
  * 📢 Public Plugin Key
11
13
  *
@@ -111,7 +113,7 @@ export var withLazyLoading = function withLazyLoading(_ref) {
111
113
  var nodeName = _ref.nodeName,
112
114
  loader = _ref.loader,
113
115
  getNodeViewOptions = _ref.getNodeViewOptions;
114
- var createLazyNodeView = function createLazyNodeView(node, view, getPos, decorations) {
116
+ return function (node, view, getPos, decorations) {
115
117
  var _node$type;
116
118
  var requestedNodes = requestedNodesPerEditorView.get(view);
117
119
  if (!requestedNodes) {
@@ -188,5 +190,4 @@ export var withLazyLoading = function withLazyLoading(_ref) {
188
190
  }
189
191
  return new LazyNodeView(node, view, getPos, decorations);
190
192
  };
191
- return createLazyNodeView;
192
193
  };
@@ -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 = "99.10.1";
10
+ var packageVersion = "99.12.0";
11
11
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
12
12
  // Remove URL as it has UGC
13
13
  // TODO: Sanitise the URL instead of just removing it
@@ -84,17 +84,24 @@ function createNodeView(_ref) {
84
84
  }
85
85
  function attachNodeViewObserver() {
86
86
  var observer = getOrCreateOnVisibleObserver(nodeViewParams.view);
87
- removeIntersectionObserver = observer.observe(domRef, function () {
88
- if (!didRenderComponentWithIntersectionObserver && !destroyed) {
89
- domRef.replaceChildren();
90
- renderComponent();
91
- didRenderComponentWithIntersectionObserver = true;
92
- }
93
- });
87
+ if (domRef) {
88
+ removeIntersectionObserver = observer.observe(domRef, function () {
89
+ if (!didRenderComponentWithIntersectionObserver && !destroyed) {
90
+ domRef.replaceChildren();
91
+ renderComponent();
92
+ didRenderComponentWithIntersectionObserver = true;
93
+ }
94
+ });
95
+ }
94
96
  }
95
97
  if (shouldVirtualize) {
96
98
  renderFallback();
97
- attachNodeViewObserver();
99
+ // allow the fallback to render first before attaching the observer.
100
+ // Will tweak this in a follow up PR to optimise rendering of visible
101
+ // nodes without fallback rendering.
102
+ setTimeout(function () {
103
+ attachNodeViewObserver();
104
+ }, 0);
98
105
  } else {
99
106
  var _getPerformanceOption = getPerformanceOptions(nodeViewParams.view),
100
107
  samplingRate = _getPerformanceOption.samplingRate,
@@ -12,7 +12,7 @@ export { isIgnored } from './gap-cursor/utils/is-ignored';
12
12
  export { isValidTargetNode } from './gap-cursor/utils/is-valid-target-node';
13
13
  export { setGapCursorSelection } from './gap-cursor/utils/setGapCursorSelection';
14
14
  export { hideCaretModifier, gapCursorStyles } from './gap-cursor/styles';
15
- export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent } from './utils';
15
+ export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, expandSelectionBounds, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent } from './utils';
16
16
  export function getNodeSelectionAnalyticsPayload(selection) {
17
17
  if (selection instanceof NodeSelection) {
18
18
  return {
@@ -66,4 +66,38 @@ export function startPositionOfParent(resolvedPos) {
66
66
  }
67
67
  export function endPositionOfParent(resolvedPos) {
68
68
  return resolvedPos.end(resolvedPos.depth) + 1;
69
- }
69
+ }
70
+ export var expandSelectionBounds = function expandSelectionBounds($anchor, $head) {
71
+ var $from = $anchor.min($head);
72
+ var $to = $anchor.max($head);
73
+ var fromDepth = $from.depth;
74
+ var toDepth = $to.depth;
75
+ var selectionStart = fromDepth ? $from.before() : $from.pos;
76
+ var selectionEnd = toDepth ? $to.after() : $to.pos;
77
+ var selectionHasGrandparent = toDepth > 1 && fromDepth > 1;
78
+ var selectionIsAcrossDiffParents = selectionHasGrandparent && !$to.parent.isTextblock && !$to.sameParent($from);
79
+ var selectionIsAcrossTextBlocksWithDiffParents = selectionHasGrandparent && $to.parent.isTextblock && $to.before(toDepth - 1) !== $from.before(fromDepth - 1);
80
+ if (toDepth > fromDepth) {
81
+ // expand end of selection to after the last node
82
+ selectionEnd = fromDepth ? $to.after(fromDepth) : $to.after(1);
83
+ } else if (toDepth < fromDepth) {
84
+ // expand start of selection to before the current node
85
+ selectionStart = toDepth ? $from.before(toDepth) : $from.before(1);
86
+ } else if (selectionIsAcrossDiffParents || selectionIsAcrossTextBlocksWithDiffParents) {
87
+ // when selection from/to share same depth with different parents, hoist up the selection to the parent of the highest depth in the selection
88
+ selectionStart = $from.before(fromDepth - 1);
89
+ selectionEnd = $to.after(toDepth - 1);
90
+ } else if (!$from.node().inlineContent) {
91
+ // when selection might be a Node selection, return what was passed in
92
+ return {
93
+ $anchor: $anchor,
94
+ $head: $head
95
+ };
96
+ }
97
+ var $expandedFrom = $anchor.doc.resolve(selectionStart);
98
+ var $expandedTo = $anchor.doc.resolve(selectionEnd);
99
+ return {
100
+ $anchor: $anchor === $from ? $expandedFrom : $expandedTo,
101
+ $head: $head === $to ? $expandedTo : $expandedFrom
102
+ };
103
+ };
@@ -20,7 +20,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
20
20
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
21
21
  import Layer from '../Layer';
22
22
  var packageName = "@atlaskit/editor-common";
23
- var packageVersion = "99.10.1";
23
+ var packageVersion = "99.12.0";
24
24
  var halfFocusRing = 1;
25
25
  var dropOffset = '0, 8';
26
26
  // Ignored via go/ees005
@@ -53,7 +53,7 @@ validNode,
53
53
  */
54
54
  validateNodes, isType, isParagraph, isText, isLinkMark, SelectedState, isNodeSelectedOrInRange, isSupportedInParent, isMediaNode, isNodeBeforeMediaNode } from './nodes';
55
55
  export { pluginFactory } from './plugin-state-factory';
56
- export { getFragmentBackingArray, mapFragment, mapSlice, flatmap, mapChildren } from './slice';
56
+ export { getFragmentBackingArray, mapFragment, mapSlice, flatmap, mapChildren, hasNode } from './slice';
57
57
  export { walkUpTreeUntil, unwrap, removeNestedEmptyEls, containsClassName, closest, closestElement, parsePx, mapElem, maphElem } from './dom';
58
58
  export { default as ADFTraversor } from './traversor';
59
59
  /**
@@ -1,6 +1,5 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
3
-
4
3
  /**
5
4
  * A helper to get the underlying array of a fragment.
6
5
  */
@@ -49,4 +48,22 @@ export function mapChildren(node, callback) {
49
48
  array.push(callback(node.child(i), i, node instanceof Fragment ? node : node.content));
50
49
  }
51
50
  return array;
52
- }
51
+ }
52
+ var findNode = function findNode(predicate) {
53
+ return function (slice) {
54
+ var foundNode = null;
55
+ slice.content.nodesBetween(0, slice.content.size, function (node) {
56
+ if (predicate(node)) {
57
+ foundNode = node;
58
+ return false;
59
+ }
60
+ return true;
61
+ });
62
+ return foundNode;
63
+ };
64
+ };
65
+ export var hasNode = function hasNode(predicate) {
66
+ return function (slice) {
67
+ return !!findNode(predicate)(slice);
68
+ };
69
+ };
@@ -34,6 +34,8 @@ type FeedbackAEP = UIAEP<ACTION.OPENED, ACTION_SUBJECT.FEEDBACK_DIALOG, undefine
34
34
  type EditorStartAEP = UIAEP<ACTION.STARTED, ACTION_SUBJECT.EDITOR, undefined, {
35
35
  platform: PLATFORMS.NATIVE | PLATFORMS.HYBRID | PLATFORMS.WEB;
36
36
  featureFlags: FeatureFlagKey[];
37
+ accountLocale?: string;
38
+ browserLocale?: string;
37
39
  }, undefined>;
38
40
  type EditorPerfAEP = OperationalAEPWithObjectId<ACTION.EDITOR_MOUNTED | ACTION.PROSEMIRROR_RENDERED | ACTION.ON_EDITOR_READY_CALLBACK | ACTION.ON_CHANGE_CALLBACK, ACTION_SUBJECT.EDITOR, undefined, {
39
41
  duration: number;
@@ -2,9 +2,11 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
2
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { Decoration, EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { DispatchAnalyticsEvent } from '../analytics';
5
+ import { LazyNodeView } from './node-view';
5
6
  import type { LazyNodeViewToDOMConfiguration, NodeViewConstructor } from './types';
6
7
  export { convertToInlineCss } from './css-helper';
7
8
  export type { NodeViewConstructor, LazyNodeViewToDOMConfiguration };
9
+ export { LazyNodeView };
8
10
  /**
9
11
  * 📢 Public Plugin Key
10
12
  *
@@ -11,7 +11,7 @@ export { isIgnored } from './gap-cursor/utils/is-ignored';
11
11
  export { isValidTargetNode } from './gap-cursor/utils/is-valid-target-node';
12
12
  export { setGapCursorSelection } from './gap-cursor/utils/setGapCursorSelection';
13
13
  export { hideCaretModifier, gapCursorStyles } from './gap-cursor/styles';
14
- export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent, } from './utils';
14
+ export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, expandSelectionBounds, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent, } from './utils';
15
15
  export declare function getNodeSelectionAnalyticsPayload(selection: Selection): AnalyticsEventPayload | undefined;
16
16
  export declare function getAllSelectionAnalyticsPayload(selection: Selection): AnalyticsEventPayload | undefined;
17
17
  export declare function getCellSelectionAnalyticsPayload(state: EditorState): AnalyticsEventPayload | undefined;
@@ -9,3 +9,7 @@ export declare function atTheEndOfBlock(state: EditorState): boolean;
9
9
  export declare function atTheBeginningOfBlock(state: EditorState): boolean;
10
10
  export declare function startPositionOfParent(resolvedPos: ResolvedPos): number;
11
11
  export declare function endPositionOfParent(resolvedPos: ResolvedPos): number;
12
+ export declare const expandSelectionBounds: ($anchor: ResolvedPos, $head: ResolvedPos) => {
13
+ $anchor: ResolvedPos;
14
+ $head: ResolvedPos;
15
+ };
@@ -55,7 +55,7 @@ validNode,
55
55
  validateNodes, isType, isParagraph, isText, isLinkMark, SelectedState, isNodeSelectedOrInRange, isSupportedInParent, isMediaNode, isNodeBeforeMediaNode, } from './nodes';
56
56
  export type { Reducer } from './plugin-state-factory';
57
57
  export { pluginFactory } from './plugin-state-factory';
58
- export { getFragmentBackingArray, mapFragment, mapSlice, flatmap, mapChildren } from './slice';
58
+ export { getFragmentBackingArray, mapFragment, mapSlice, flatmap, mapChildren, hasNode, } from './slice';
59
59
  export type { FlatMapCallback, MapWithCallback } from './slice';
60
60
  export { walkUpTreeUntil, unwrap, removeNestedEmptyEls, containsClassName, closest, closestElement, parsePx, mapElem, maphElem, } from './dom';
61
61
  export type { MapCallback } from './dom';
@@ -1,4 +1,5 @@
1
- import { Fragment, type Node, Slice } from '@atlaskit/editor-prosemirror/model';
1
+ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
2
+ import type { Node } from '@atlaskit/editor-prosemirror/model';
2
3
  /**
3
4
  * A helper to get the underlying array of a fragment.
4
5
  */
@@ -9,3 +10,4 @@ export type FlatMapCallback = (node: Node, index: number, fragment: Fragment) =>
9
10
  export declare function flatmap(fragment: Fragment, callback: FlatMapCallback): Fragment;
10
11
  export type MapWithCallback<T> = (node: Node, index: number, fragment: Fragment) => T;
11
12
  export declare function mapChildren<T>(node: Node | Fragment, callback: MapWithCallback<T>): Array<T>;
13
+ export declare const hasNode: (predicate: (node: Node) => boolean) => (slice: Slice) => boolean;
@@ -34,6 +34,8 @@ type FeedbackAEP = UIAEP<ACTION.OPENED, ACTION_SUBJECT.FEEDBACK_DIALOG, undefine
34
34
  type EditorStartAEP = UIAEP<ACTION.STARTED, ACTION_SUBJECT.EDITOR, undefined, {
35
35
  platform: PLATFORMS.NATIVE | PLATFORMS.HYBRID | PLATFORMS.WEB;
36
36
  featureFlags: FeatureFlagKey[];
37
+ accountLocale?: string;
38
+ browserLocale?: string;
37
39
  }, undefined>;
38
40
  type EditorPerfAEP = OperationalAEPWithObjectId<ACTION.EDITOR_MOUNTED | ACTION.PROSEMIRROR_RENDERED | ACTION.ON_EDITOR_READY_CALLBACK | ACTION.ON_CHANGE_CALLBACK, ACTION_SUBJECT.EDITOR, undefined, {
39
41
  duration: number;
@@ -2,9 +2,11 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
2
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { Decoration, EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { DispatchAnalyticsEvent } from '../analytics';
5
+ import { LazyNodeView } from './node-view';
5
6
  import type { LazyNodeViewToDOMConfiguration, NodeViewConstructor } from './types';
6
7
  export { convertToInlineCss } from './css-helper';
7
8
  export type { NodeViewConstructor, LazyNodeViewToDOMConfiguration };
9
+ export { LazyNodeView };
8
10
  /**
9
11
  * 📢 Public Plugin Key
10
12
  *
@@ -11,7 +11,7 @@ export { isIgnored } from './gap-cursor/utils/is-ignored';
11
11
  export { isValidTargetNode } from './gap-cursor/utils/is-valid-target-node';
12
12
  export { setGapCursorSelection } from './gap-cursor/utils/setGapCursorSelection';
13
13
  export { hideCaretModifier, gapCursorStyles } from './gap-cursor/styles';
14
- export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent, } from './utils';
14
+ export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, expandSelectionBounds, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent, } from './utils';
15
15
  export declare function getNodeSelectionAnalyticsPayload(selection: Selection): AnalyticsEventPayload | undefined;
16
16
  export declare function getAllSelectionAnalyticsPayload(selection: Selection): AnalyticsEventPayload | undefined;
17
17
  export declare function getCellSelectionAnalyticsPayload(state: EditorState): AnalyticsEventPayload | undefined;
@@ -9,3 +9,7 @@ export declare function atTheEndOfBlock(state: EditorState): boolean;
9
9
  export declare function atTheBeginningOfBlock(state: EditorState): boolean;
10
10
  export declare function startPositionOfParent(resolvedPos: ResolvedPos): number;
11
11
  export declare function endPositionOfParent(resolvedPos: ResolvedPos): number;
12
+ export declare const expandSelectionBounds: ($anchor: ResolvedPos, $head: ResolvedPos) => {
13
+ $anchor: ResolvedPos;
14
+ $head: ResolvedPos;
15
+ };
@@ -55,7 +55,7 @@ validNode,
55
55
  validateNodes, isType, isParagraph, isText, isLinkMark, SelectedState, isNodeSelectedOrInRange, isSupportedInParent, isMediaNode, isNodeBeforeMediaNode, } from './nodes';
56
56
  export type { Reducer } from './plugin-state-factory';
57
57
  export { pluginFactory } from './plugin-state-factory';
58
- export { getFragmentBackingArray, mapFragment, mapSlice, flatmap, mapChildren } from './slice';
58
+ export { getFragmentBackingArray, mapFragment, mapSlice, flatmap, mapChildren, hasNode, } from './slice';
59
59
  export type { FlatMapCallback, MapWithCallback } from './slice';
60
60
  export { walkUpTreeUntil, unwrap, removeNestedEmptyEls, containsClassName, closest, closestElement, parsePx, mapElem, maphElem, } from './dom';
61
61
  export type { MapCallback } from './dom';
@@ -1,4 +1,5 @@
1
- import { Fragment, type Node, Slice } from '@atlaskit/editor-prosemirror/model';
1
+ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
2
+ import type { Node } from '@atlaskit/editor-prosemirror/model';
2
3
  /**
3
4
  * A helper to get the underlying array of a fragment.
4
5
  */
@@ -9,3 +10,4 @@ export type FlatMapCallback = (node: Node, index: number, fragment: Fragment) =>
9
10
  export declare function flatmap(fragment: Fragment, callback: FlatMapCallback): Fragment;
10
11
  export type MapWithCallback<T> = (node: Node, index: number, fragment: Fragment) => T;
11
12
  export declare function mapChildren<T>(node: Node | Fragment, callback: MapWithCallback<T>): Array<T>;
13
+ export declare const hasNode: (predicate: (node: Node) => boolean) => (slice: Slice) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "99.10.1",
3
+ "version": "99.12.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/"
@@ -130,10 +130,10 @@
130
130
  "@atlaskit/editor-shared-styles": "^3.2.0",
131
131
  "@atlaskit/editor-tables": "^2.9.0",
132
132
  "@atlaskit/emoji": "^67.13.0",
133
- "@atlaskit/icon": "^23.7.0",
133
+ "@atlaskit/icon": "^23.8.0",
134
134
  "@atlaskit/icon-object": "^6.10.0",
135
135
  "@atlaskit/link-datasource": "^3.19.0",
136
- "@atlaskit/link-picker": "^1.48.0",
136
+ "@atlaskit/link-picker": "^1.49.0",
137
137
  "@atlaskit/media-card": "^78.19.0",
138
138
  "@atlaskit/media-client": "^31.1.0",
139
139
  "@atlaskit/media-client-react": "^3.0.0",
@@ -141,7 +141,7 @@
141
141
  "@atlaskit/media-file-preview": "^0.10.0",
142
142
  "@atlaskit/media-picker": "^67.1.0",
143
143
  "@atlaskit/media-ui": "^27.4.0",
144
- "@atlaskit/media-viewer": "50.1.4",
144
+ "@atlaskit/media-viewer": "50.1.5",
145
145
  "@atlaskit/mention": "^23.11.0",
146
146
  "@atlaskit/menu": "^2.14.0",
147
147
  "@atlaskit/onboarding": "^12.3.0",
@@ -155,7 +155,7 @@
155
155
  "@atlaskit/spinner": "^17.1.0",
156
156
  "@atlaskit/task-decision": "^17.12.0",
157
157
  "@atlaskit/textfield": "^6.8.0",
158
- "@atlaskit/tmp-editor-statsig": "^2.44.0",
158
+ "@atlaskit/tmp-editor-statsig": "^2.45.0",
159
159
  "@atlaskit/tokens": "^3.3.0",
160
160
  "@atlaskit/tooltip": "^19.1.0",
161
161
  "@atlaskit/width-detector": "^4.4.0",