@atlaskit/editor-common 108.3.1 → 108.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 108.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`d9be3a6937275`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d9be3a6937275) -
8
+ Add the list of ancestor node types to the result of applyAnnotation, to make it easier to debug
9
+ comments errors
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 108.3.1
4
16
 
5
17
  ### Patch Changes
@@ -16,7 +16,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
16
16
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
17
17
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
18
18
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
19
- var packageVersion = "108.3.0";
19
+ var packageVersion = "108.3.1";
20
20
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
21
21
  // Remove URL as it has UGC
22
22
  // Ignored via go/ees007
@@ -24,7 +24,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
24
24
  * @jsx jsx
25
25
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
26
26
  var packageName = "@atlaskit/editor-common";
27
- var packageVersion = "108.3.0";
27
+ var packageVersion = "108.3.1";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var fadeIn = (0, _react2.keyframes)({
@@ -9,6 +9,7 @@ exports.containsAnyAnnotations = containsAnyAnnotations;
9
9
  exports.getAnnotationIdsFromRange = void 0;
10
10
  exports.getAnnotationInlineNodeTypes = getAnnotationInlineNodeTypes;
11
11
  exports.getAnnotationMarksForPos = getAnnotationMarksForPos;
12
+ exports.getRangeAncestorNodeNames = getRangeAncestorNodeNames;
12
13
  exports.getRangeInlineNodeNames = getRangeInlineNodeNames;
13
14
  exports.hasAnnotationMark = hasAnnotationMark;
14
15
  exports.isEmptyTextSelection = isEmptyTextSelection;
@@ -129,6 +130,62 @@ function getRangeInlineNodeNames(_ref) {
129
130
  }
130
131
  }
131
132
 
133
+ /**
134
+ * This returns a list of ancestor node names that contain the given position.
135
+ */
136
+ function getRangeAncestorNodeNames(_ref2) {
137
+ var doc = _ref2.doc,
138
+ pos = _ref2.pos;
139
+ if (!(0, _platformFeatureFlags.fg)('cc_comments_log_draft_annotation_ancestor_nodes')) {
140
+ return undefined;
141
+ }
142
+ var nodeNames = new Set();
143
+ try {
144
+ // For a range, we can get ancestors at both from and to positions
145
+ // or just use the from position if you want ancestors at the start
146
+ var resolvedFromPos = doc.resolve(pos.from);
147
+ var resolvedToPos = doc.resolve(pos.to);
148
+
149
+ // Collect ancestors at the 'from' position
150
+ for (var depth = resolvedFromPos.depth; depth > 0; depth--) {
151
+ var ancestorNode = resolvedFromPos.node(depth);
152
+ nodeNames.add(ancestorNode.type.name);
153
+ }
154
+
155
+ // Use nodesBetween to collect parent types without additional resolve() calls
156
+ // This isn't as precise as calling resolve() on each parent, but it's a lot faster
157
+ // and should hopefully provide a good approximation of the ancestor nodes
158
+ var seenParents = new Set();
159
+ doc.nodesBetween(pos.from, pos.to, function (node, nodePos, parent) {
160
+ // Collect parent chain using the parent parameter
161
+ var currentParent = parent;
162
+ if (!!currentParent && !seenParents.has(currentParent)) {
163
+ seenParents.add(currentParent);
164
+ nodeNames.add(currentParent.type.name);
165
+ // Note: We can't easily get the parent's parent from this context
166
+ // without additional resolve calls, so this approach has limitations
167
+ }
168
+ return true;
169
+ });
170
+
171
+ // Optionally collect ancestors at the 'to' position if different
172
+ // This ensures we capture all ancestor contexts across the range
173
+ if (pos.from !== pos.to) {
174
+ for (var _depth = resolvedToPos.depth; _depth > 0; _depth--) {
175
+ var _ancestorNode = resolvedToPos.node(_depth);
176
+ nodeNames.add(_ancestorNode.type.name);
177
+ }
178
+ }
179
+ return (0, _toConsumableArray2.default)(nodeNames);
180
+ } catch (_unused2) {
181
+ // Some callers have existing gaps where the positions are not valid,
182
+ // and so when called in the current document can throw an error if out of range.
183
+ //
184
+ // This is a defensive check to ensure we don't throw an error in those cases.
185
+ return undefined;
186
+ }
187
+ }
188
+
132
189
  /**
133
190
  * This function returns a list of node types that are wrapped by an annotation mark.
134
191
  *
@@ -534,6 +534,12 @@ Object.defineProperty(exports, "getPropsDifference", {
534
534
  return _compareProps.getPropsDifference;
535
535
  }
536
536
  });
537
+ Object.defineProperty(exports, "getRangeAncestorNodeNames", {
538
+ enumerable: true,
539
+ get: function get() {
540
+ return _annotation.getRangeAncestorNodeNames;
541
+ }
542
+ });
537
543
  Object.defineProperty(exports, "getRangeInlineNodeNames", {
538
544
  enumerable: true,
539
545
  get: function get() {
@@ -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 = "108.3.0";
4
+ const packageVersion = "108.3.1";
5
5
  const sanitiseSentryEvents = (data, _hint) => {
6
6
  // Remove URL as it has UGC
7
7
  // Ignored via go/ees007
@@ -14,7 +14,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
14
14
  import { fg } from '@atlaskit/platform-feature-flags';
15
15
  import Layer from '../Layer';
16
16
  const packageName = "@atlaskit/editor-common";
17
- const packageVersion = "108.3.0";
17
+ const packageVersion = "108.3.1";
18
18
  const halfFocusRing = 1;
19
19
  const dropOffset = '0, 8';
20
20
  const fadeIn = keyframes({
@@ -124,6 +124,63 @@ export function getRangeInlineNodeNames({
124
124
  }
125
125
  }
126
126
 
127
+ /**
128
+ * This returns a list of ancestor node names that contain the given position.
129
+ */
130
+ export function getRangeAncestorNodeNames({
131
+ doc,
132
+ pos
133
+ }) {
134
+ if (!fg('cc_comments_log_draft_annotation_ancestor_nodes')) {
135
+ return undefined;
136
+ }
137
+ const nodeNames = new Set();
138
+ try {
139
+ // For a range, we can get ancestors at both from and to positions
140
+ // or just use the from position if you want ancestors at the start
141
+ const resolvedFromPos = doc.resolve(pos.from);
142
+ const resolvedToPos = doc.resolve(pos.to);
143
+
144
+ // Collect ancestors at the 'from' position
145
+ for (let depth = resolvedFromPos.depth; depth > 0; depth--) {
146
+ const ancestorNode = resolvedFromPos.node(depth);
147
+ nodeNames.add(ancestorNode.type.name);
148
+ }
149
+
150
+ // Use nodesBetween to collect parent types without additional resolve() calls
151
+ // This isn't as precise as calling resolve() on each parent, but it's a lot faster
152
+ // and should hopefully provide a good approximation of the ancestor nodes
153
+ const seenParents = new Set();
154
+ doc.nodesBetween(pos.from, pos.to, (node, nodePos, parent) => {
155
+ // Collect parent chain using the parent parameter
156
+ const currentParent = parent;
157
+ if (!!currentParent && !seenParents.has(currentParent)) {
158
+ seenParents.add(currentParent);
159
+ nodeNames.add(currentParent.type.name);
160
+ // Note: We can't easily get the parent's parent from this context
161
+ // without additional resolve calls, so this approach has limitations
162
+ }
163
+ return true;
164
+ });
165
+
166
+ // Optionally collect ancestors at the 'to' position if different
167
+ // This ensures we capture all ancestor contexts across the range
168
+ if (pos.from !== pos.to) {
169
+ for (let depth = resolvedToPos.depth; depth > 0; depth--) {
170
+ const ancestorNode = resolvedToPos.node(depth);
171
+ nodeNames.add(ancestorNode.type.name);
172
+ }
173
+ }
174
+ return [...nodeNames];
175
+ } catch {
176
+ // Some callers have existing gaps where the positions are not valid,
177
+ // and so when called in the current document can throw an error if out of range.
178
+ //
179
+ // This is a defensive check to ensure we don't throw an error in those cases.
180
+ return undefined;
181
+ }
182
+ }
183
+
127
184
  /**
128
185
  * This function returns a list of node types that are wrapped by an annotation mark.
129
186
  *
@@ -5,7 +5,7 @@ import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { hasDocAsParent } from './document';
6
6
  import { isEmptyParagraph } from './editor-core-utils';
7
7
  export { shouldAutoLinkifyMatch } from './should-auto-linkify-tld';
8
- export { getAnnotationMarksForPos, canApplyAnnotationOnRange, containsAnyAnnotations, getAnnotationIdsFromRange, getAnnotationInlineNodeTypes, hasAnnotationMark, getRangeInlineNodeNames, isEmptyTextSelection, isEmptyTextSelectionRenderer } from './annotation';
8
+ export { getAnnotationMarksForPos, canApplyAnnotationOnRange, containsAnyAnnotations, getAnnotationIdsFromRange, getAnnotationInlineNodeTypes, hasAnnotationMark, getRangeInlineNodeNames, getRangeAncestorNodeNames, isEmptyTextSelection, isEmptyTextSelectionRenderer } from './annotation';
9
9
  export { getExtensionLozengeData } from './macro';
10
10
  export {
11
11
  /**
@@ -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 = "108.3.0";
10
+ var packageVersion = "108.3.1";
11
11
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
12
12
  // Remove URL as it has UGC
13
13
  // Ignored via go/ees007
@@ -21,7 +21,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
21
21
  import { fg } from '@atlaskit/platform-feature-flags';
22
22
  import Layer from '../Layer';
23
23
  var packageName = "@atlaskit/editor-common";
24
- var packageVersion = "108.3.0";
24
+ var packageVersion = "108.3.1";
25
25
  var halfFocusRing = 1;
26
26
  var dropOffset = '0, 8';
27
27
  var fadeIn = keyframes({
@@ -114,6 +114,62 @@ export function getRangeInlineNodeNames(_ref) {
114
114
  }
115
115
  }
116
116
 
117
+ /**
118
+ * This returns a list of ancestor node names that contain the given position.
119
+ */
120
+ export function getRangeAncestorNodeNames(_ref2) {
121
+ var doc = _ref2.doc,
122
+ pos = _ref2.pos;
123
+ if (!fg('cc_comments_log_draft_annotation_ancestor_nodes')) {
124
+ return undefined;
125
+ }
126
+ var nodeNames = new Set();
127
+ try {
128
+ // For a range, we can get ancestors at both from and to positions
129
+ // or just use the from position if you want ancestors at the start
130
+ var resolvedFromPos = doc.resolve(pos.from);
131
+ var resolvedToPos = doc.resolve(pos.to);
132
+
133
+ // Collect ancestors at the 'from' position
134
+ for (var depth = resolvedFromPos.depth; depth > 0; depth--) {
135
+ var ancestorNode = resolvedFromPos.node(depth);
136
+ nodeNames.add(ancestorNode.type.name);
137
+ }
138
+
139
+ // Use nodesBetween to collect parent types without additional resolve() calls
140
+ // This isn't as precise as calling resolve() on each parent, but it's a lot faster
141
+ // and should hopefully provide a good approximation of the ancestor nodes
142
+ var seenParents = new Set();
143
+ doc.nodesBetween(pos.from, pos.to, function (node, nodePos, parent) {
144
+ // Collect parent chain using the parent parameter
145
+ var currentParent = parent;
146
+ if (!!currentParent && !seenParents.has(currentParent)) {
147
+ seenParents.add(currentParent);
148
+ nodeNames.add(currentParent.type.name);
149
+ // Note: We can't easily get the parent's parent from this context
150
+ // without additional resolve calls, so this approach has limitations
151
+ }
152
+ return true;
153
+ });
154
+
155
+ // Optionally collect ancestors at the 'to' position if different
156
+ // This ensures we capture all ancestor contexts across the range
157
+ if (pos.from !== pos.to) {
158
+ for (var _depth = resolvedToPos.depth; _depth > 0; _depth--) {
159
+ var _ancestorNode = resolvedToPos.node(_depth);
160
+ nodeNames.add(_ancestorNode.type.name);
161
+ }
162
+ }
163
+ return _toConsumableArray(nodeNames);
164
+ } catch (_unused2) {
165
+ // Some callers have existing gaps where the positions are not valid,
166
+ // and so when called in the current document can throw an error if out of range.
167
+ //
168
+ // This is a defensive check to ensure we don't throw an error in those cases.
169
+ return undefined;
170
+ }
171
+ }
172
+
117
173
  /**
118
174
  * This function returns a list of node types that are wrapped by an annotation mark.
119
175
  *
@@ -5,7 +5,7 @@ import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { hasDocAsParent } from './document';
6
6
  import { isEmptyParagraph } from './editor-core-utils';
7
7
  export { shouldAutoLinkifyMatch } from './should-auto-linkify-tld';
8
- export { getAnnotationMarksForPos, canApplyAnnotationOnRange, containsAnyAnnotations, getAnnotationIdsFromRange, getAnnotationInlineNodeTypes, hasAnnotationMark, getRangeInlineNodeNames, isEmptyTextSelection, isEmptyTextSelectionRenderer } from './annotation';
8
+ export { getAnnotationMarksForPos, canApplyAnnotationOnRange, containsAnyAnnotations, getAnnotationIdsFromRange, getAnnotationInlineNodeTypes, hasAnnotationMark, getRangeInlineNodeNames, getRangeAncestorNodeNames, isEmptyTextSelection, isEmptyTextSelectionRenderer } from './annotation';
9
9
  export { getExtensionLozengeData } from './macro';
10
10
  export {
11
11
  /**
@@ -18,6 +18,8 @@ type AnnotationByMatches = {
18
18
  pos?: number;
19
19
  };
20
20
  export type ActionResult = {
21
+ /** The list of types of all nodes, which wrap the annotation. */
22
+ ancestorNodeTypes?: string[];
21
23
  doc: JSONDocNode;
22
24
  /** The list of types of all inline nodes, which were wrapped by annotation. */
23
25
  inlineNodeTypes?: string[];
@@ -15,6 +15,8 @@ type ActionResult = {
15
15
  step: RemoveMarkStep | RemoveNodeMarkStep;
16
16
  } | false;
17
17
  export type AnnotationActionResult = ({
18
+ /** The list of types of all nodes, which wrap the annotation. */
19
+ ancestorNodeTypes?: string[];
18
20
  doc: JSONDocNode;
19
21
  /** The list of types of all inline nodes, which were wrapped by annotation. */
20
22
  inlineNodeTypes?: string[];
@@ -18,6 +18,16 @@ export declare function getRangeInlineNodeNames({ doc, pos, }: {
18
18
  to: number;
19
19
  };
20
20
  }): string[] | undefined;
21
+ /**
22
+ * This returns a list of ancestor node names that contain the given position.
23
+ */
24
+ export declare function getRangeAncestorNodeNames({ doc, pos, }: {
25
+ doc: PMNode;
26
+ pos: {
27
+ from: number;
28
+ to: number;
29
+ };
30
+ }): string[] | undefined;
21
31
  /**
22
32
  * This function returns a list of node types that are wrapped by an annotation mark.
23
33
  *
@@ -2,7 +2,7 @@ import type { Node as PMNode, ResolvedPos, Schema } from '@atlaskit/editor-prose
2
2
  import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
4
4
  export { shouldAutoLinkifyMatch } from './should-auto-linkify-tld';
5
- export { getAnnotationMarksForPos, canApplyAnnotationOnRange, containsAnyAnnotations, getAnnotationIdsFromRange, getAnnotationInlineNodeTypes, hasAnnotationMark, getRangeInlineNodeNames, isEmptyTextSelection, isEmptyTextSelectionRenderer, } from './annotation';
5
+ export { getAnnotationMarksForPos, canApplyAnnotationOnRange, containsAnyAnnotations, getAnnotationIdsFromRange, getAnnotationInlineNodeTypes, hasAnnotationMark, getRangeInlineNodeNames, getRangeAncestorNodeNames, isEmptyTextSelection, isEmptyTextSelectionRenderer, } from './annotation';
6
6
  export { getExtensionLozengeData } from './macro';
7
7
  export type { Params } from './macro';
8
8
  export {
@@ -18,6 +18,8 @@ type AnnotationByMatches = {
18
18
  pos?: number;
19
19
  };
20
20
  export type ActionResult = {
21
+ /** The list of types of all nodes, which wrap the annotation. */
22
+ ancestorNodeTypes?: string[];
21
23
  doc: JSONDocNode;
22
24
  /** The list of types of all inline nodes, which were wrapped by annotation. */
23
25
  inlineNodeTypes?: string[];
@@ -15,6 +15,8 @@ type ActionResult = {
15
15
  step: RemoveMarkStep | RemoveNodeMarkStep;
16
16
  } | false;
17
17
  export type AnnotationActionResult = ({
18
+ /** The list of types of all nodes, which wrap the annotation. */
19
+ ancestorNodeTypes?: string[];
18
20
  doc: JSONDocNode;
19
21
  /** The list of types of all inline nodes, which were wrapped by annotation. */
20
22
  inlineNodeTypes?: string[];
@@ -18,6 +18,16 @@ export declare function getRangeInlineNodeNames({ doc, pos, }: {
18
18
  to: number;
19
19
  };
20
20
  }): string[] | undefined;
21
+ /**
22
+ * This returns a list of ancestor node names that contain the given position.
23
+ */
24
+ export declare function getRangeAncestorNodeNames({ doc, pos, }: {
25
+ doc: PMNode;
26
+ pos: {
27
+ from: number;
28
+ to: number;
29
+ };
30
+ }): string[] | undefined;
21
31
  /**
22
32
  * This function returns a list of node types that are wrapped by an annotation mark.
23
33
  *
@@ -2,7 +2,7 @@ import type { Node as PMNode, ResolvedPos, Schema } from '@atlaskit/editor-prose
2
2
  import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
4
4
  export { shouldAutoLinkifyMatch } from './should-auto-linkify-tld';
5
- export { getAnnotationMarksForPos, canApplyAnnotationOnRange, containsAnyAnnotations, getAnnotationIdsFromRange, getAnnotationInlineNodeTypes, hasAnnotationMark, getRangeInlineNodeNames, isEmptyTextSelection, isEmptyTextSelectionRenderer, } from './annotation';
5
+ export { getAnnotationMarksForPos, canApplyAnnotationOnRange, containsAnyAnnotations, getAnnotationIdsFromRange, getAnnotationInlineNodeTypes, hasAnnotationMark, getRangeInlineNodeNames, getRangeAncestorNodeNames, isEmptyTextSelection, isEmptyTextSelectionRenderer, } from './annotation';
6
6
  export { getExtensionLozengeData } from './macro';
7
7
  export type { Params } from './macro';
8
8
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "108.3.1",
3
+ "version": "108.4.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/"
@@ -169,7 +169,7 @@
169
169
  "@atlaskit/profilecard": "^24.10.0",
170
170
  "@atlaskit/react-ufo": "^4.5.0",
171
171
  "@atlaskit/section-message": "^8.7.0",
172
- "@atlaskit/smart-card": "^40.19.0",
172
+ "@atlaskit/smart-card": "^40.20.0",
173
173
  "@atlaskit/smart-user-picker": "^8.2.0",
174
174
  "@atlaskit/spinner": "^19.0.0",
175
175
  "@atlaskit/status": "^3.0.0",
@@ -339,6 +339,9 @@
339
339
  "confluence_connect_macro_preset_height": {
340
340
  "type": "boolean"
341
341
  },
342
+ "cc_comments_log_draft_annotation_ancestor_nodes": {
343
+ "type": "boolean"
344
+ },
342
345
  "platform_editor_breakout_resizing_hello_release": {
343
346
  "type": "boolean"
344
347
  },