@atlaskit/editor-common 86.1.0 → 86.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/styles/shared/annotation.js +3 -1
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/ui/WidthProvider/index.js +18 -2
- package/dist/cjs/utils/annotation/index.js +16 -8
- package/dist/cjs/utils/index.js +7 -0
- package/dist/cjs/utils/page-element-counts.js +44 -0
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/styles/shared/annotation.js +3 -1
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/ui/WidthProvider/index.js +18 -2
- package/dist/es2019/utils/annotation/index.js +16 -8
- package/dist/es2019/utils/index.js +2 -1
- package/dist/es2019/utils/page-element-counts.js +38 -0
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/styles/shared/annotation.js +3 -1
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/ui/WidthProvider/index.js +18 -2
- package/dist/esm/utils/annotation/index.js +16 -8
- package/dist/esm/utils/index.js +2 -1
- package/dist/esm/utils/page-element-counts.js +38 -0
- package/dist/types/react-node-view/generateUniqueNodeKey.d.ts +1 -1
- package/dist/types/styles/shared/annotation.d.ts +6 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/page-element-counts.d.ts +17 -0
- package/dist/types-ts4.5/react-node-view/generateUniqueNodeKey.d.ts +1 -1
- package/dist/types-ts4.5/styles/shared/annotation.d.ts +6 -0
- package/dist/types-ts4.5/utils/index.d.ts +1 -0
- package/dist/types-ts4.5/utils/page-element-counts.d.ts +17 -0
- package/package.json +8 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @atlaskit/editor-common
|
|
2
2
|
|
|
3
|
+
## 86.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#121315](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/121315)
|
|
8
|
+
[`f550b1a0c6e85`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f550b1a0c6e85) -
|
|
9
|
+
[ux] ED-24237 Fix comment appearances in renderer to match editor
|
|
10
|
+
- [#120992](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/120992)
|
|
11
|
+
[`a61cfb5567823`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a61cfb5567823) -
|
|
12
|
+
ED-23357 Update annotation node name calculations to avoid crashes on invalid ranges
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 86.2.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- [`ca831efa17dd5`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ca831efa17dd5) -
|
|
20
|
+
[ED-23922] Added utility to count the number of unique elements, text formats, macros and layouts
|
|
21
|
+
in a JSONDocNode or JSONNode
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [#121046](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/121046)
|
|
26
|
+
[`c5cbf1d63b0c8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c5cbf1d63b0c8) -
|
|
27
|
+
[ED-24241] Memonize the document.body to avoid multiple Layout Reflows for the same page
|
|
28
|
+
|
|
3
29
|
## 86.1.0
|
|
4
30
|
|
|
5
31
|
### Minor Changes
|
|
@@ -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 && Object.prototype.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 = "86.1
|
|
20
|
+
var packageVersion = "86.2.1";
|
|
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
|
|
@@ -36,7 +36,9 @@ var AnnotationSharedCSSByState = exports.AnnotationSharedCSSByState = function A
|
|
|
36
36
|
borderBottom: '2px solid transparent',
|
|
37
37
|
cursor: 'pointer',
|
|
38
38
|
padding: '1px 0 2px',
|
|
39
|
-
'&:has(.card), &:has([data-inline-card])': {
|
|
39
|
+
'&:has(.card), &:has([data-inline-card])': (0, _platformFeatureFlags.fg)('annotations_align_editor_and_renderer_styles') ? {
|
|
40
|
+
padding: '5px 0 3px 0'
|
|
41
|
+
} : {
|
|
40
42
|
paddingTop: '4px',
|
|
41
43
|
border: 'none',
|
|
42
44
|
boxShadow: "0 2px 0 0 ".concat("var(--ds-border-accent-yellow, ".concat(Y200a, ")"))
|
|
@@ -20,7 +20,7 @@ var _Layer = _interopRequireDefault(require("../Layer"));
|
|
|
20
20
|
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); }; }
|
|
21
21
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /** @jsx jsx */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
22
22
|
var packageName = "@atlaskit/editor-common";
|
|
23
|
-
var packageVersion = "86.1
|
|
23
|
+
var packageVersion = "86.2.1";
|
|
24
24
|
var halfFocusRing = 1;
|
|
25
25
|
var dropOffset = '0, 8';
|
|
26
26
|
var DropList = /*#__PURE__*/function (_Component) {
|
|
@@ -11,6 +11,7 @@ exports.getBreakpoint = getBreakpoint;
|
|
|
11
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _react2 = require("@emotion/react");
|
|
14
|
+
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
14
15
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
15
16
|
var _widthDetector = require("@atlaskit/width-detector");
|
|
16
17
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
@@ -45,13 +46,28 @@ function createWidthContext() {
|
|
|
45
46
|
var WidthContext = exports.WidthContext = /*#__PURE__*/_react.default.createContext(createWidthContext());
|
|
46
47
|
var Provider = WidthContext.Provider,
|
|
47
48
|
Consumer = exports.WidthConsumer = WidthContext.Consumer;
|
|
48
|
-
|
|
49
|
+
/**
|
|
50
|
+
* 🧱 Internal function: Editor FE Platform
|
|
51
|
+
*
|
|
52
|
+
* Returns the width of the document body.
|
|
53
|
+
*
|
|
54
|
+
* This function is memoized to avoid forcing a layout reflow multiple times.
|
|
55
|
+
* It uses `document.body.offsetWidth` as the source of the width, which can lead to
|
|
56
|
+
* a layout reflow if accessed repeatedly. To mitigate performance issues, the result
|
|
57
|
+
* is cached using `memoizeOne`.
|
|
58
|
+
*
|
|
59
|
+
* @returns {number} The width of the document body or 0 if the document is undefined.
|
|
60
|
+
*/
|
|
61
|
+
var getBodyWidth = (0, _memoizeOne.default)(function () {
|
|
49
62
|
var _document$body$offset, _document$body;
|
|
63
|
+
return typeof document !== 'undefined' ? (_document$body$offset = (_document$body = document.body) === null || _document$body === void 0 ? void 0 : _document$body.offsetWidth) !== null && _document$body$offset !== void 0 ? _document$body$offset : 0 : 0;
|
|
64
|
+
});
|
|
65
|
+
var WidthProvider = exports.WidthProvider = function WidthProvider(_ref) {
|
|
50
66
|
var className = _ref.className,
|
|
51
67
|
shouldCheckExistingValue = _ref.shouldCheckExistingValue,
|
|
52
68
|
children = _ref.children;
|
|
53
69
|
var existingContextValue = _react.default.useContext(WidthContext);
|
|
54
|
-
var _React$useState = _react.default.useState(
|
|
70
|
+
var _React$useState = _react.default.useState(getBodyWidth),
|
|
55
71
|
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
|
|
56
72
|
width = _React$useState2[0],
|
|
57
73
|
setWidth = _React$useState2[1];
|
|
@@ -107,15 +107,23 @@ function getRangeInlineNodeNames(_ref) {
|
|
|
107
107
|
return undefined;
|
|
108
108
|
}
|
|
109
109
|
var nodeNames = new Set();
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
try {
|
|
111
|
+
doc.nodesBetween(pos.from, pos.to, function (node) {
|
|
112
|
+
if (node.isInline) {
|
|
113
|
+
nodeNames.add(node.type.name);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
115
116
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
// We sort the list alphabetically to make human consumption of the list easier (in tools like the analytics extension)
|
|
118
|
+
var sortedNames = (0, _toConsumableArray2.default)(nodeNames).sort();
|
|
119
|
+
return sortedNames;
|
|
120
|
+
} catch (_unused) {
|
|
121
|
+
// Some callers have existing gaps where the positions are not valid,
|
|
122
|
+
// and so when called in the current document can throw an error if out of range.
|
|
123
|
+
//
|
|
124
|
+
// This is a defensive check to ensure we don't throw an error in those cases.
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
119
127
|
}
|
|
120
128
|
|
|
121
129
|
/**
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -492,6 +492,12 @@ Object.defineProperty(exports, "getOrderFromOrderedListNode", {
|
|
|
492
492
|
return _list.getOrderFromOrderedListNode;
|
|
493
493
|
}
|
|
494
494
|
});
|
|
495
|
+
Object.defineProperty(exports, "getPageElementCounts", {
|
|
496
|
+
enumerable: true,
|
|
497
|
+
get: function get() {
|
|
498
|
+
return _pageElementCounts.getPageElementCounts;
|
|
499
|
+
}
|
|
500
|
+
});
|
|
495
501
|
Object.defineProperty(exports, "getPerformanceOptions", {
|
|
496
502
|
enumerable: true,
|
|
497
503
|
get: function get() {
|
|
@@ -1181,6 +1187,7 @@ var _insertNodeIntoOrderedList = require("./insert-node-into-ordered-list");
|
|
|
1181
1187
|
var _wrapSelectionIn = require("./wrap-selection-in");
|
|
1182
1188
|
var _calculateToolbarPosition = require("./calculate-toolbar-position");
|
|
1183
1189
|
var _nodesByLocalIds = require("./nodes-by-localIds");
|
|
1190
|
+
var _pageElementCounts = require("./page-element-counts");
|
|
1184
1191
|
/**
|
|
1185
1192
|
* @deprecated - [ED-23844] moving to own entry point @atlaskit/editor-common/whitespace
|
|
1186
1193
|
*/
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getPageElementCounts = void 0;
|
|
7
|
+
var _traverse = require("@atlaskit/adf-utils/traverse");
|
|
8
|
+
/**
|
|
9
|
+
* Traverses a JSON document and counts the number of unique elements, text formatting and macros.
|
|
10
|
+
*
|
|
11
|
+
**/
|
|
12
|
+
var getPageElementCounts = exports.getPageElementCounts = function getPageElementCounts(doc) {
|
|
13
|
+
var pageElementCounts = {
|
|
14
|
+
elements: {},
|
|
15
|
+
textFormats: {},
|
|
16
|
+
macros: {}
|
|
17
|
+
};
|
|
18
|
+
(0, _traverse.reduce)(doc, function (acc, node) {
|
|
19
|
+
if (node.type === 'text') {
|
|
20
|
+
var _acc$elements$node$ty;
|
|
21
|
+
if (node.marks) {
|
|
22
|
+
node.marks.forEach(function (mark) {
|
|
23
|
+
var _acc$textFormats$mark;
|
|
24
|
+
var markType = mark.type;
|
|
25
|
+
acc.textFormats[markType] = ((_acc$textFormats$mark = acc.textFormats[markType]) !== null && _acc$textFormats$mark !== void 0 ? _acc$textFormats$mark : 0) + 1;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
acc.elements[node.type] = ((_acc$elements$node$ty = acc.elements[node.type]) !== null && _acc$elements$node$ty !== void 0 ? _acc$elements$node$ty : 0) + 1;
|
|
29
|
+
}
|
|
30
|
+
// If the node is a 'macro'or extension
|
|
31
|
+
else if (node.type === 'extension' || node.type === 'inlineExtension' || node.type === 'bodiedExtension' || node.type === 'multiBodiedExtension' || node.type === 'extensionFrame') {
|
|
32
|
+
if ('attrs' in node && node.attrs && 'extensionKey' in node.attrs && node.attrs.extensionKey) {
|
|
33
|
+
var _acc$macros$extension;
|
|
34
|
+
var extensionKey = node.attrs.extensionKey;
|
|
35
|
+
acc.macros[extensionKey] = ((_acc$macros$extension = acc.macros[extensionKey]) !== null && _acc$macros$extension !== void 0 ? _acc$macros$extension : 0) + 1;
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
var _acc$elements$node$ty2;
|
|
39
|
+
acc.elements[node.type] = ((_acc$elements$node$ty2 = acc.elements[node.type]) !== null && _acc$elements$node$ty2 !== void 0 ? _acc$elements$node$ty2 : 0) + 1;
|
|
40
|
+
}
|
|
41
|
+
return acc;
|
|
42
|
+
}, pageElementCounts);
|
|
43
|
+
return pageElementCounts;
|
|
44
|
+
};
|
|
@@ -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 = "86.1
|
|
4
|
+
const packageVersion = "86.2.1";
|
|
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
|
|
@@ -28,7 +28,9 @@ export const AnnotationSharedCSSByState = () => {
|
|
|
28
28
|
borderBottom: '2px solid transparent',
|
|
29
29
|
cursor: 'pointer',
|
|
30
30
|
padding: '1px 0 2px',
|
|
31
|
-
'&:has(.card), &:has([data-inline-card])': {
|
|
31
|
+
'&:has(.card), &:has([data-inline-card])': fg('annotations_align_editor_and_renderer_styles') ? {
|
|
32
|
+
padding: '5px 0 3px 0'
|
|
33
|
+
} : {
|
|
32
34
|
paddingTop: '4px',
|
|
33
35
|
border: 'none',
|
|
34
36
|
boxShadow: `0 2px 0 0 ${`var(--ds-border-accent-yellow, ${Y200a})`}`
|
|
@@ -9,7 +9,7 @@ import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@
|
|
|
9
9
|
import { N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
|
|
10
10
|
import Layer from '../Layer';
|
|
11
11
|
const packageName = "@atlaskit/editor-common";
|
|
12
|
-
const packageVersion = "86.1
|
|
12
|
+
const packageVersion = "86.2.1";
|
|
13
13
|
const halfFocusRing = 1;
|
|
14
14
|
const dropOffset = '0, 8';
|
|
15
15
|
class DropList extends Component {
|
|
@@ -3,6 +3,7 @@ import React, { Fragment } from 'react';
|
|
|
3
3
|
|
|
4
4
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
5
5
|
import { css, jsx } from '@emotion/react';
|
|
6
|
+
import memoizeOne from 'memoize-one';
|
|
6
7
|
import rafSchedule from 'raf-schd';
|
|
7
8
|
import { WidthObserver } from '@atlaskit/width-detector';
|
|
8
9
|
const styles = css({
|
|
@@ -31,14 +32,29 @@ const {
|
|
|
31
32
|
Provider,
|
|
32
33
|
Consumer
|
|
33
34
|
} = WidthContext;
|
|
35
|
+
/**
|
|
36
|
+
* 🧱 Internal function: Editor FE Platform
|
|
37
|
+
*
|
|
38
|
+
* Returns the width of the document body.
|
|
39
|
+
*
|
|
40
|
+
* This function is memoized to avoid forcing a layout reflow multiple times.
|
|
41
|
+
* It uses `document.body.offsetWidth` as the source of the width, which can lead to
|
|
42
|
+
* a layout reflow if accessed repeatedly. To mitigate performance issues, the result
|
|
43
|
+
* is cached using `memoizeOne`.
|
|
44
|
+
*
|
|
45
|
+
* @returns {number} The width of the document body or 0 if the document is undefined.
|
|
46
|
+
*/
|
|
47
|
+
const getBodyWidth = memoizeOne(() => {
|
|
48
|
+
var _document$body$offset, _document$body;
|
|
49
|
+
return typeof document !== 'undefined' ? (_document$body$offset = (_document$body = document.body) === null || _document$body === void 0 ? void 0 : _document$body.offsetWidth) !== null && _document$body$offset !== void 0 ? _document$body$offset : 0 : 0;
|
|
50
|
+
});
|
|
34
51
|
export const WidthProvider = ({
|
|
35
52
|
className,
|
|
36
53
|
shouldCheckExistingValue,
|
|
37
54
|
children
|
|
38
55
|
}) => {
|
|
39
|
-
var _document$body$offset, _document$body;
|
|
40
56
|
const existingContextValue = React.useContext(WidthContext);
|
|
41
|
-
const [width, setWidth] = React.useState(
|
|
57
|
+
const [width, setWidth] = React.useState(getBodyWidth);
|
|
42
58
|
const widthRef = React.useRef(width);
|
|
43
59
|
const isMountedRef = React.useRef(true);
|
|
44
60
|
const providerValue = React.useMemo(() => createWidthContext(width), [width]);
|
|
@@ -105,15 +105,23 @@ export function getRangeInlineNodeNames({
|
|
|
105
105
|
return undefined;
|
|
106
106
|
}
|
|
107
107
|
let nodeNames = new Set();
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
108
|
+
try {
|
|
109
|
+
doc.nodesBetween(pos.from, pos.to, node => {
|
|
110
|
+
if (node.isInline) {
|
|
111
|
+
nodeNames.add(node.type.name);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
113
114
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
// We sort the list alphabetically to make human consumption of the list easier (in tools like the analytics extension)
|
|
116
|
+
const sortedNames = [...nodeNames].sort();
|
|
117
|
+
return sortedNames;
|
|
118
|
+
} catch {
|
|
119
|
+
// Some callers have existing gaps where the positions are not valid,
|
|
120
|
+
// and so when called in the current document can throw an error if out of range.
|
|
121
|
+
//
|
|
122
|
+
// This is a defensive check to ensure we don't throw an error in those cases.
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
117
125
|
}
|
|
118
126
|
|
|
119
127
|
/**
|
|
@@ -221,4 +221,5 @@ export { transformNodeIntoListItem } from './insert-node-into-ordered-list';
|
|
|
221
221
|
export { wrapSelectionIn } from './wrap-selection-in';
|
|
222
222
|
export { toJSON, nodeToJSON } from './nodes';
|
|
223
223
|
export { calculateToolbarPositionAboveSelection, calculateToolbarPositionTrackHead } from './calculate-toolbar-position';
|
|
224
|
-
export { findNodePosByLocalIds } from './nodes-by-localIds';
|
|
224
|
+
export { findNodePosByLocalIds } from './nodes-by-localIds';
|
|
225
|
+
export { getPageElementCounts } from './page-element-counts';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { reduce } from '@atlaskit/adf-utils/traverse';
|
|
2
|
+
/**
|
|
3
|
+
* Traverses a JSON document and counts the number of unique elements, text formatting and macros.
|
|
4
|
+
*
|
|
5
|
+
**/
|
|
6
|
+
export const getPageElementCounts = doc => {
|
|
7
|
+
const pageElementCounts = {
|
|
8
|
+
elements: {},
|
|
9
|
+
textFormats: {},
|
|
10
|
+
macros: {}
|
|
11
|
+
};
|
|
12
|
+
reduce(doc, (acc, node) => {
|
|
13
|
+
if (node.type === 'text') {
|
|
14
|
+
var _acc$elements$node$ty;
|
|
15
|
+
if (node.marks) {
|
|
16
|
+
node.marks.forEach(mark => {
|
|
17
|
+
var _acc$textFormats$mark;
|
|
18
|
+
const markType = mark.type;
|
|
19
|
+
acc.textFormats[markType] = ((_acc$textFormats$mark = acc.textFormats[markType]) !== null && _acc$textFormats$mark !== void 0 ? _acc$textFormats$mark : 0) + 1;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
acc.elements[node.type] = ((_acc$elements$node$ty = acc.elements[node.type]) !== null && _acc$elements$node$ty !== void 0 ? _acc$elements$node$ty : 0) + 1;
|
|
23
|
+
}
|
|
24
|
+
// If the node is a 'macro'or extension
|
|
25
|
+
else if (node.type === 'extension' || node.type === 'inlineExtension' || node.type === 'bodiedExtension' || node.type === 'multiBodiedExtension' || node.type === 'extensionFrame') {
|
|
26
|
+
if ('attrs' in node && node.attrs && 'extensionKey' in node.attrs && node.attrs.extensionKey) {
|
|
27
|
+
var _acc$macros$extension;
|
|
28
|
+
const extensionKey = node.attrs.extensionKey;
|
|
29
|
+
acc.macros[extensionKey] = ((_acc$macros$extension = acc.macros[extensionKey]) !== null && _acc$macros$extension !== void 0 ? _acc$macros$extension : 0) + 1;
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
var _acc$elements$node$ty2;
|
|
33
|
+
acc.elements[node.type] = ((_acc$elements$node$ty2 = acc.elements[node.type]) !== null && _acc$elements$node$ty2 !== void 0 ? _acc$elements$node$ty2 : 0) + 1;
|
|
34
|
+
}
|
|
35
|
+
return acc;
|
|
36
|
+
}, pageElementCounts);
|
|
37
|
+
return pageElementCounts;
|
|
38
|
+
};
|
|
@@ -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 = "86.1
|
|
10
|
+
var packageVersion = "86.2.1";
|
|
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
|
|
@@ -30,7 +30,9 @@ export var AnnotationSharedCSSByState = function AnnotationSharedCSSByState() {
|
|
|
30
30
|
borderBottom: '2px solid transparent',
|
|
31
31
|
cursor: 'pointer',
|
|
32
32
|
padding: '1px 0 2px',
|
|
33
|
-
'&:has(.card), &:has([data-inline-card])': {
|
|
33
|
+
'&:has(.card), &:has([data-inline-card])': fg('annotations_align_editor_and_renderer_styles') ? {
|
|
34
|
+
padding: '5px 0 3px 0'
|
|
35
|
+
} : {
|
|
34
36
|
paddingTop: '4px',
|
|
35
37
|
border: 'none',
|
|
36
38
|
boxShadow: "0 2px 0 0 ".concat("var(--ds-border-accent-yellow, ".concat(Y200a, ")"))
|
|
@@ -17,7 +17,7 @@ import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@
|
|
|
17
17
|
import { N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
|
|
18
18
|
import Layer from '../Layer';
|
|
19
19
|
var packageName = "@atlaskit/editor-common";
|
|
20
|
-
var packageVersion = "86.1
|
|
20
|
+
var packageVersion = "86.2.1";
|
|
21
21
|
var halfFocusRing = 1;
|
|
22
22
|
var dropOffset = '0, 8';
|
|
23
23
|
var DropList = /*#__PURE__*/function (_Component) {
|
|
@@ -4,6 +4,7 @@ import React, { Fragment } from 'react';
|
|
|
4
4
|
|
|
5
5
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
6
6
|
import { css, jsx } from '@emotion/react';
|
|
7
|
+
import memoizeOne from 'memoize-one';
|
|
7
8
|
import rafSchedule from 'raf-schd';
|
|
8
9
|
import { WidthObserver } from '@atlaskit/width-detector';
|
|
9
10
|
var styles = css({
|
|
@@ -32,13 +33,28 @@ export function createWidthContext() {
|
|
|
32
33
|
export var WidthContext = /*#__PURE__*/React.createContext(createWidthContext());
|
|
33
34
|
var Provider = WidthContext.Provider,
|
|
34
35
|
Consumer = WidthContext.Consumer;
|
|
35
|
-
|
|
36
|
+
/**
|
|
37
|
+
* 🧱 Internal function: Editor FE Platform
|
|
38
|
+
*
|
|
39
|
+
* Returns the width of the document body.
|
|
40
|
+
*
|
|
41
|
+
* This function is memoized to avoid forcing a layout reflow multiple times.
|
|
42
|
+
* It uses `document.body.offsetWidth` as the source of the width, which can lead to
|
|
43
|
+
* a layout reflow if accessed repeatedly. To mitigate performance issues, the result
|
|
44
|
+
* is cached using `memoizeOne`.
|
|
45
|
+
*
|
|
46
|
+
* @returns {number} The width of the document body or 0 if the document is undefined.
|
|
47
|
+
*/
|
|
48
|
+
var getBodyWidth = memoizeOne(function () {
|
|
36
49
|
var _document$body$offset, _document$body;
|
|
50
|
+
return typeof document !== 'undefined' ? (_document$body$offset = (_document$body = document.body) === null || _document$body === void 0 ? void 0 : _document$body.offsetWidth) !== null && _document$body$offset !== void 0 ? _document$body$offset : 0 : 0;
|
|
51
|
+
});
|
|
52
|
+
export var WidthProvider = function WidthProvider(_ref) {
|
|
37
53
|
var className = _ref.className,
|
|
38
54
|
shouldCheckExistingValue = _ref.shouldCheckExistingValue,
|
|
39
55
|
children = _ref.children;
|
|
40
56
|
var existingContextValue = React.useContext(WidthContext);
|
|
41
|
-
var _React$useState = React.useState(
|
|
57
|
+
var _React$useState = React.useState(getBodyWidth),
|
|
42
58
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
43
59
|
width = _React$useState2[0],
|
|
44
60
|
setWidth = _React$useState2[1];
|
|
@@ -95,15 +95,23 @@ export function getRangeInlineNodeNames(_ref) {
|
|
|
95
95
|
return undefined;
|
|
96
96
|
}
|
|
97
97
|
var nodeNames = new Set();
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
try {
|
|
99
|
+
doc.nodesBetween(pos.from, pos.to, function (node) {
|
|
100
|
+
if (node.isInline) {
|
|
101
|
+
nodeNames.add(node.type.name);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
103
104
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
// We sort the list alphabetically to make human consumption of the list easier (in tools like the analytics extension)
|
|
106
|
+
var sortedNames = _toConsumableArray(nodeNames).sort();
|
|
107
|
+
return sortedNames;
|
|
108
|
+
} catch (_unused) {
|
|
109
|
+
// Some callers have existing gaps where the positions are not valid,
|
|
110
|
+
// and so when called in the current document can throw an error if out of range.
|
|
111
|
+
//
|
|
112
|
+
// This is a defensive check to ensure we don't throw an error in those cases.
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
107
115
|
}
|
|
108
116
|
|
|
109
117
|
/**
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -224,4 +224,5 @@ export { transformNodeIntoListItem } from './insert-node-into-ordered-list';
|
|
|
224
224
|
export { wrapSelectionIn } from './wrap-selection-in';
|
|
225
225
|
export { toJSON, nodeToJSON } from './nodes';
|
|
226
226
|
export { calculateToolbarPositionAboveSelection, calculateToolbarPositionTrackHead } from './calculate-toolbar-position';
|
|
227
|
-
export { findNodePosByLocalIds } from './nodes-by-localIds';
|
|
227
|
+
export { findNodePosByLocalIds } from './nodes-by-localIds';
|
|
228
|
+
export { getPageElementCounts } from './page-element-counts';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { reduce } from '@atlaskit/adf-utils/traverse';
|
|
2
|
+
/**
|
|
3
|
+
* Traverses a JSON document and counts the number of unique elements, text formatting and macros.
|
|
4
|
+
*
|
|
5
|
+
**/
|
|
6
|
+
export var getPageElementCounts = function getPageElementCounts(doc) {
|
|
7
|
+
var pageElementCounts = {
|
|
8
|
+
elements: {},
|
|
9
|
+
textFormats: {},
|
|
10
|
+
macros: {}
|
|
11
|
+
};
|
|
12
|
+
reduce(doc, function (acc, node) {
|
|
13
|
+
if (node.type === 'text') {
|
|
14
|
+
var _acc$elements$node$ty;
|
|
15
|
+
if (node.marks) {
|
|
16
|
+
node.marks.forEach(function (mark) {
|
|
17
|
+
var _acc$textFormats$mark;
|
|
18
|
+
var markType = mark.type;
|
|
19
|
+
acc.textFormats[markType] = ((_acc$textFormats$mark = acc.textFormats[markType]) !== null && _acc$textFormats$mark !== void 0 ? _acc$textFormats$mark : 0) + 1;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
acc.elements[node.type] = ((_acc$elements$node$ty = acc.elements[node.type]) !== null && _acc$elements$node$ty !== void 0 ? _acc$elements$node$ty : 0) + 1;
|
|
23
|
+
}
|
|
24
|
+
// If the node is a 'macro'or extension
|
|
25
|
+
else if (node.type === 'extension' || node.type === 'inlineExtension' || node.type === 'bodiedExtension' || node.type === 'multiBodiedExtension' || node.type === 'extensionFrame') {
|
|
26
|
+
if ('attrs' in node && node.attrs && 'extensionKey' in node.attrs && node.attrs.extensionKey) {
|
|
27
|
+
var _acc$macros$extension;
|
|
28
|
+
var extensionKey = node.attrs.extensionKey;
|
|
29
|
+
acc.macros[extensionKey] = ((_acc$macros$extension = acc.macros[extensionKey]) !== null && _acc$macros$extension !== void 0 ? _acc$macros$extension : 0) + 1;
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
var _acc$elements$node$ty2;
|
|
33
|
+
acc.elements[node.type] = ((_acc$elements$node$ty2 = acc.elements[node.type]) !== null && _acc$elements$node$ty2 !== void 0 ? _acc$elements$node$ty2 : 0) + 1;
|
|
34
|
+
}
|
|
35
|
+
return acc;
|
|
36
|
+
}, pageElementCounts);
|
|
37
|
+
return pageElementCounts;
|
|
38
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const generateUniqueNodeKey: () =>
|
|
1
|
+
export declare const generateUniqueNodeKey: () => any;
|
|
@@ -16,9 +16,15 @@ export declare const AnnotationSharedCSSByState: () => {
|
|
|
16
16
|
cursor: string;
|
|
17
17
|
padding: string;
|
|
18
18
|
'&:has(.card), &:has([data-inline-card])': {
|
|
19
|
+
padding: string;
|
|
20
|
+
paddingTop?: undefined;
|
|
21
|
+
border?: undefined;
|
|
22
|
+
boxShadow?: undefined;
|
|
23
|
+
} | {
|
|
19
24
|
paddingTop: string;
|
|
20
25
|
border: string;
|
|
21
26
|
boxShadow: string;
|
|
27
|
+
padding?: undefined;
|
|
22
28
|
};
|
|
23
29
|
'&:has(.date-lozenger-container)': {
|
|
24
30
|
paddingTop: string;
|
|
@@ -91,3 +91,4 @@ export { wrapSelectionIn } from './wrap-selection-in';
|
|
|
91
91
|
export { toJSON, nodeToJSON } from './nodes';
|
|
92
92
|
export { calculateToolbarPositionAboveSelection, calculateToolbarPositionTrackHead, } from './calculate-toolbar-position';
|
|
93
93
|
export { findNodePosByLocalIds } from './nodes-by-localIds';
|
|
94
|
+
export { getPageElementCounts } from './page-element-counts';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
2
|
+
export type PageElementCounts = {
|
|
3
|
+
elements: {
|
|
4
|
+
[key: string]: number;
|
|
5
|
+
};
|
|
6
|
+
textFormats: {
|
|
7
|
+
[key: string]: number;
|
|
8
|
+
};
|
|
9
|
+
macros: {
|
|
10
|
+
[key: string]: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Traverses a JSON document and counts the number of unique elements, text formatting and macros.
|
|
15
|
+
*
|
|
16
|
+
**/
|
|
17
|
+
export declare const getPageElementCounts: (doc: JSONDocNode) => PageElementCounts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const generateUniqueNodeKey: () =>
|
|
1
|
+
export declare const generateUniqueNodeKey: () => any;
|
|
@@ -16,9 +16,15 @@ export declare const AnnotationSharedCSSByState: () => {
|
|
|
16
16
|
cursor: string;
|
|
17
17
|
padding: string;
|
|
18
18
|
'&:has(.card), &:has([data-inline-card])': {
|
|
19
|
+
padding: string;
|
|
20
|
+
paddingTop?: undefined;
|
|
21
|
+
border?: undefined;
|
|
22
|
+
boxShadow?: undefined;
|
|
23
|
+
} | {
|
|
19
24
|
paddingTop: string;
|
|
20
25
|
border: string;
|
|
21
26
|
boxShadow: string;
|
|
27
|
+
padding?: undefined;
|
|
22
28
|
};
|
|
23
29
|
'&:has(.date-lozenger-container)': {
|
|
24
30
|
paddingTop: string;
|
|
@@ -91,3 +91,4 @@ export { wrapSelectionIn } from './wrap-selection-in';
|
|
|
91
91
|
export { toJSON, nodeToJSON } from './nodes';
|
|
92
92
|
export { calculateToolbarPositionAboveSelection, calculateToolbarPositionTrackHead, } from './calculate-toolbar-position';
|
|
93
93
|
export { findNodePosByLocalIds } from './nodes-by-localIds';
|
|
94
|
+
export { getPageElementCounts } from './page-element-counts';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
2
|
+
export type PageElementCounts = {
|
|
3
|
+
elements: {
|
|
4
|
+
[key: string]: number;
|
|
5
|
+
};
|
|
6
|
+
textFormats: {
|
|
7
|
+
[key: string]: number;
|
|
8
|
+
};
|
|
9
|
+
macros: {
|
|
10
|
+
[key: string]: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Traverses a JSON document and counts the number of unique elements, text formatting and macros.
|
|
15
|
+
*
|
|
16
|
+
**/
|
|
17
|
+
export declare const getPageElementCounts: (doc: JSONDocNode) => PageElementCounts;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-common",
|
|
3
|
-
"version": "86.1
|
|
3
|
+
"version": "86.2.1",
|
|
4
4
|
"description": "A package that contains common classes and components for editor and renderer",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"@atlaskit/analytics-namespaced-context": "^6.10.0",
|
|
104
104
|
"@atlaskit/analytics-next": "^9.3.0",
|
|
105
105
|
"@atlaskit/atlassian-context": "^0.0.0",
|
|
106
|
-
"@atlaskit/button": "^
|
|
106
|
+
"@atlaskit/button": "^19.0.0",
|
|
107
107
|
"@atlaskit/code": "^15.4.0",
|
|
108
108
|
"@atlaskit/codemod-utils": "^4.2.0",
|
|
109
109
|
"@atlaskit/custom-steps": "^0.4.0",
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
"@atlaskit/media-file-preview": "^0.6.0",
|
|
126
126
|
"@atlaskit/media-picker": "^66.4.0",
|
|
127
127
|
"@atlaskit/media-ui": "^25.10.0",
|
|
128
|
-
"@atlaskit/media-viewer": "48.6.
|
|
128
|
+
"@atlaskit/media-viewer": "48.6.12",
|
|
129
129
|
"@atlaskit/mention": "^23.2.0",
|
|
130
130
|
"@atlaskit/menu": "^2.8.0",
|
|
131
131
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
"@atlaskit/task-decision": "^17.10.0",
|
|
139
139
|
"@atlaskit/textfield": "^6.4.0",
|
|
140
140
|
"@atlaskit/theme": "^12.11.0",
|
|
141
|
-
"@atlaskit/tokens": "^1.
|
|
141
|
+
"@atlaskit/tokens": "^1.56.0",
|
|
142
142
|
"@atlaskit/tooltip": "^18.5.0",
|
|
143
143
|
"@atlaskit/ufo": "^0.2.0",
|
|
144
144
|
"@atlaskit/width-detector": "^4.2.0",
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
"devDependencies": {
|
|
177
177
|
"@af/visual-regression": "*",
|
|
178
178
|
"@atlaskit/media-core": "^34.2.0",
|
|
179
|
-
"@atlaskit/media-test-helpers": "^
|
|
179
|
+
"@atlaskit/media-test-helpers": "^34.0.0",
|
|
180
180
|
"@atlaskit/util-data-test": "^17.9.0",
|
|
181
181
|
"@atlaskit/visual-regression": "*",
|
|
182
182
|
"@atlassian/feature-flags-test-utils": "*",
|
|
@@ -244,6 +244,9 @@
|
|
|
244
244
|
"platform_editor_tables_padding_increase": {
|
|
245
245
|
"type": "boolean"
|
|
246
246
|
},
|
|
247
|
+
"annotations_align_editor_and_renderer_styles": {
|
|
248
|
+
"type": "boolean"
|
|
249
|
+
},
|
|
247
250
|
"platform-editor-a11y-image-border-options-dropdown": {
|
|
248
251
|
"type": "boolean"
|
|
249
252
|
},
|