@atlaskit/editor-common 108.3.1 → 108.5.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 +23 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/user-intent/UserIntentPopupWrapper.js +26 -0
- package/dist/cjs/user-intent/index.js +12 -0
- package/dist/cjs/utils/annotation/index.js +57 -0
- package/dist/cjs/utils/index.js +6 -0
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/user-intent/UserIntentPopupWrapper.js +21 -0
- package/dist/es2019/user-intent/index.js +4 -0
- package/dist/es2019/utils/annotation/index.js +57 -0
- package/dist/es2019/utils/index.js +1 -1
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/user-intent/UserIntentPopupWrapper.js +20 -0
- package/dist/esm/user-intent/index.js +4 -0
- package/dist/esm/utils/annotation/index.js +56 -0
- package/dist/esm/utils/index.js +1 -1
- package/dist/types/annotation/index.d.ts +2 -0
- package/dist/types/types/annotation/index.d.ts +2 -0
- package/dist/types/user-intent/UserIntentPopupWrapper.d.ts +9 -0
- package/dist/types/user-intent/index.d.ts +1 -0
- package/dist/types/utils/annotation/index.d.ts +10 -0
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/annotation/index.d.ts +2 -0
- package/dist/types-ts4.5/types/annotation/index.d.ts +2 -0
- package/dist/types-ts4.5/user-intent/UserIntentPopupWrapper.d.ts +9 -0
- package/dist/types-ts4.5/user-intent/index.d.ts +1 -0
- package/dist/types-ts4.5/utils/annotation/index.d.ts +10 -0
- package/dist/types-ts4.5/utils/index.d.ts +1 -1
- package/package.json +8 -4
- package/user-intent/package.json +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @atlaskit/editor-common
|
|
2
2
|
|
|
3
|
+
## 108.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`a8630c1107c3d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a8630c1107c3d) -
|
|
8
|
+
[ED-28781] Hide inline text toolbar when other popups are open
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
14
|
+
## 108.4.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- [`d9be3a6937275`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d9be3a6937275) -
|
|
19
|
+
Add the list of ancestor node types to the result of applyAnnotation, to make it easier to debug
|
|
20
|
+
comments errors
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
|
|
3
26
|
## 108.3.1
|
|
4
27
|
|
|
5
28
|
### 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.
|
|
19
|
+
var packageVersion = "108.4.0";
|
|
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.
|
|
27
|
+
var packageVersion = "108.4.0";
|
|
28
28
|
var halfFocusRing = 1;
|
|
29
29
|
var dropOffset = '0, 8';
|
|
30
30
|
var fadeIn = (0, _react2.keyframes)({
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.UserIntentPopupWrapper = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* A wrapper for popups to signal popupOpen user intent
|
|
11
|
+
*/
|
|
12
|
+
var UserIntentPopupWrapper = exports.UserIntentPopupWrapper = function UserIntentPopupWrapper(_ref) {
|
|
13
|
+
var children = _ref.children,
|
|
14
|
+
api = _ref.api;
|
|
15
|
+
(0, _react.useEffect)(function () {
|
|
16
|
+
var _api$userIntent;
|
|
17
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent('popupOpen'));
|
|
18
|
+
return function () {
|
|
19
|
+
var _api$userIntent2;
|
|
20
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.commands.setCurrentUserIntent('default'));
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
|
+
}, []);
|
|
25
|
+
return children;
|
|
26
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "UserIntentPopupWrapper", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _UserIntentPopupWrapper.UserIntentPopupWrapper;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _UserIntentPopupWrapper = require("./UserIntentPopupWrapper");
|
|
@@ -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
|
*
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -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.
|
|
4
|
+
const packageVersion = "108.4.0";
|
|
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.
|
|
17
|
+
const packageVersion = "108.4.0";
|
|
18
18
|
const halfFocusRing = 1;
|
|
19
19
|
const dropOffset = '0, 8';
|
|
20
20
|
const fadeIn = keyframes({
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* A wrapper for popups to signal popupOpen user intent
|
|
5
|
+
*/
|
|
6
|
+
export const UserIntentPopupWrapper = ({
|
|
7
|
+
children,
|
|
8
|
+
api
|
|
9
|
+
}) => {
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
var _api$userIntent;
|
|
12
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent('popupOpen'));
|
|
13
|
+
return () => {
|
|
14
|
+
var _api$userIntent2;
|
|
15
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.commands.setCurrentUserIntent('default'));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
|
+
}, []);
|
|
20
|
+
return children;
|
|
21
|
+
};
|
|
@@ -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.
|
|
10
|
+
var packageVersion = "108.4.0";
|
|
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.
|
|
24
|
+
var packageVersion = "108.4.0";
|
|
25
25
|
var halfFocusRing = 1;
|
|
26
26
|
var dropOffset = '0, 8';
|
|
27
27
|
var fadeIn = keyframes({
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* A wrapper for popups to signal popupOpen user intent
|
|
5
|
+
*/
|
|
6
|
+
export var UserIntentPopupWrapper = function UserIntentPopupWrapper(_ref) {
|
|
7
|
+
var children = _ref.children,
|
|
8
|
+
api = _ref.api;
|
|
9
|
+
useEffect(function () {
|
|
10
|
+
var _api$userIntent;
|
|
11
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent('popupOpen'));
|
|
12
|
+
return function () {
|
|
13
|
+
var _api$userIntent2;
|
|
14
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.commands.setCurrentUserIntent('default'));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
18
|
+
}, []);
|
|
19
|
+
return children;
|
|
20
|
+
};
|
|
@@ -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
|
*
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -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[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ExtractInjectionAPI, NextEditorPlugin } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* A wrapper for popups to signal popupOpen user intent
|
|
5
|
+
*/
|
|
6
|
+
export declare const UserIntentPopupWrapper: ({ children, api, }: {
|
|
7
|
+
api: ExtractInjectionAPI<NextEditorPlugin<any, any>> | undefined | null;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}) => import("react").ReactNode;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { UserIntentPopupWrapper } from './UserIntentPopupWrapper';
|
|
@@ -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[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ExtractInjectionAPI, NextEditorPlugin } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* A wrapper for popups to signal popupOpen user intent
|
|
5
|
+
*/
|
|
6
|
+
export declare const UserIntentPopupWrapper: ({ children, api, }: {
|
|
7
|
+
api: ExtractInjectionAPI<NextEditorPlugin<any, any>> | undefined | null;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}) => import("react").ReactNode;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { UserIntentPopupWrapper } from './UserIntentPopupWrapper';
|
|
@@ -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
|
+
"version": "108.5.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/"
|
|
@@ -122,7 +122,8 @@
|
|
|
122
122
|
"./get-dom-ref-from-selection": "./src/utils/get-dom-ref-from-selection.ts",
|
|
123
123
|
"./ncs-step-metrics": "./src/ncs-step-metrics/index.ts",
|
|
124
124
|
"./toolbar-flag-check": "./src/toolbar-flag-check.ts",
|
|
125
|
-
"./context-panel": "./src/ui/ContextPanel/context.tsx"
|
|
125
|
+
"./context-panel": "./src/ui/ContextPanel/context.tsx",
|
|
126
|
+
"./user-intent": "./src/user-intent/index.ts"
|
|
126
127
|
},
|
|
127
128
|
"dependencies": {
|
|
128
129
|
"@atlaskit/activity-provider": "^2.5.0",
|
|
@@ -166,10 +167,10 @@
|
|
|
166
167
|
"@atlaskit/platform-feature-flags-react": "^0.3.0",
|
|
167
168
|
"@atlaskit/popper": "^7.1.0",
|
|
168
169
|
"@atlaskit/primitives": "^14.13.0",
|
|
169
|
-
"@atlaskit/profilecard": "^24.
|
|
170
|
+
"@atlaskit/profilecard": "^24.11.0",
|
|
170
171
|
"@atlaskit/react-ufo": "^4.5.0",
|
|
171
172
|
"@atlaskit/section-message": "^8.7.0",
|
|
172
|
-
"@atlaskit/smart-card": "^40.
|
|
173
|
+
"@atlaskit/smart-card": "^40.20.0",
|
|
173
174
|
"@atlaskit/smart-user-picker": "^8.2.0",
|
|
174
175
|
"@atlaskit/spinner": "^19.0.0",
|
|
175
176
|
"@atlaskit/status": "^3.0.0",
|
|
@@ -339,6 +340,9 @@
|
|
|
339
340
|
"confluence_connect_macro_preset_height": {
|
|
340
341
|
"type": "boolean"
|
|
341
342
|
},
|
|
343
|
+
"cc_comments_log_draft_annotation_ancestor_nodes": {
|
|
344
|
+
"type": "boolean"
|
|
345
|
+
},
|
|
342
346
|
"platform_editor_breakout_resizing_hello_release": {
|
|
343
347
|
"type": "boolean"
|
|
344
348
|
},
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/editor-common/user-intent",
|
|
3
|
+
"main": "../dist/cjs/user-intent/index.js",
|
|
4
|
+
"module": "../dist/esm/user-intent/index.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/user-intent/index.js",
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"**/*.compiled.css"
|
|
8
|
+
],
|
|
9
|
+
"types": "../dist/types/user-intent/index.d.ts",
|
|
10
|
+
"typesVersions": {
|
|
11
|
+
">=4.5 <5.9": {
|
|
12
|
+
"*": [
|
|
13
|
+
"../dist/types-ts4.5/user-intent/index.d.ts"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|