@atlaskit/editor-common 86.0.0 → 86.2.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 +33 -0
- package/dist/cjs/lazy-node-view/index.js +217 -0
- package/dist/cjs/link/ConfigureLinkOverlay/Dropdown.js +19 -4
- package/dist/cjs/link/ConfigureLinkOverlay/index.js +2 -1
- package/dist/cjs/messages/help-dialog.js +5 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/ui/WidthProvider/index.js +18 -2
- package/dist/cjs/ui-menu/DropdownMenu/index.js +4 -4
- package/dist/cjs/ui-menu/ToolbarButton/index.js +7 -1
- package/dist/cjs/utils/index.js +7 -0
- package/dist/cjs/utils/page-element-counts.js +44 -0
- package/dist/es2019/lazy-node-view/index.js +212 -0
- package/dist/es2019/link/ConfigureLinkOverlay/Dropdown.js +17 -4
- package/dist/es2019/link/ConfigureLinkOverlay/index.js +2 -1
- package/dist/es2019/messages/help-dialog.js +5 -0
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/ui/WidthProvider/index.js +18 -2
- package/dist/es2019/ui-menu/DropdownMenu/index.js +4 -4
- package/dist/es2019/ui-menu/ToolbarButton/index.js +7 -1
- package/dist/es2019/utils/index.js +2 -1
- package/dist/es2019/utils/page-element-counts.js +38 -0
- package/dist/esm/lazy-node-view/index.js +211 -0
- package/dist/esm/link/ConfigureLinkOverlay/Dropdown.js +19 -4
- package/dist/esm/link/ConfigureLinkOverlay/index.js +2 -1
- package/dist/esm/messages/help-dialog.js +5 -0
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/ui/WidthProvider/index.js +18 -2
- package/dist/esm/ui-menu/DropdownMenu/index.js +4 -4
- package/dist/esm/ui-menu/ToolbarButton/index.js +7 -1
- package/dist/esm/utils/index.js +2 -1
- package/dist/esm/utils/page-element-counts.js +38 -0
- package/dist/types/lazy-node-view/index.d.ts +109 -0
- package/dist/types/link/ConfigureLinkOverlay/Dropdown.d.ts +2 -0
- package/dist/types/messages/help-dialog.d.ts +5 -0
- package/dist/types/ui-menu/ToolbarButton/index.d.ts +3 -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/lazy-node-view/index.d.ts +109 -0
- package/dist/types-ts4.5/link/ConfigureLinkOverlay/Dropdown.d.ts +2 -0
- package/dist/types-ts4.5/messages/help-dialog.d.ts +5 -0
- package/dist/types-ts4.5/ui-menu/ToolbarButton/index.d.ts +3 -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/lazy-node-view/package.json +15 -0
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @atlaskit/editor-common
|
|
2
2
|
|
|
3
|
+
## 86.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`ca831efa17dd5`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ca831efa17dd5) -
|
|
8
|
+
[ED-23922] Added utility to count the number of unique elements, text formats, macros and layouts
|
|
9
|
+
in a JSONDocNode or JSONNode
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#121046](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/121046)
|
|
14
|
+
[`c5cbf1d63b0c8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c5cbf1d63b0c8) -
|
|
15
|
+
[ED-24241] Memonize the document.body to avoid multiple Layout Reflows for the same page
|
|
16
|
+
|
|
17
|
+
## 86.1.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- [#120893](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/120893)
|
|
22
|
+
[`67a22e5eb05a2`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/67a22e5eb05a2) -
|
|
23
|
+
[ux] [ECA11Y-113] This change adds the keyboard shortcut (Shift+F10) to the Cell Options Tooltip
|
|
24
|
+
and to the Editor Help dialog. This change is behind the `platform_editor_a11y_table_context_menu`
|
|
25
|
+
feature flag.
|
|
26
|
+
- [#120665](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/120665)
|
|
27
|
+
[`a4ee6908e0e2c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a4ee6908e0e2c) -
|
|
28
|
+
[ED-23943] Milestone: Initial LazyNodeViewLoading implementation for Table
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- [#120665](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/120665)
|
|
33
|
+
[`3f142b915c0a2`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3f142b915c0a2) -
|
|
34
|
+
Return focus to editor after clicking link overlay dropdown options
|
|
35
|
+
|
|
3
36
|
## 86.0.0
|
|
4
37
|
|
|
5
38
|
### Major Changes
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.withLazyLoading = exports.debouncedReplaceNodeviews = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
12
|
+
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
13
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
|
+
/**
|
|
16
|
+
* 📢 Public Type
|
|
17
|
+
*
|
|
18
|
+
* @see {withLazyLoading}
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 📢 Public Type
|
|
23
|
+
*
|
|
24
|
+
* @see {withLazyLoading}
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 🧱 Internal: Editor FE Platform
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 🧱 Internal: Editor FE Platform
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 🧱 Internal: Editor FE Platform
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 🧱 Internal: Editor FE Platform
|
|
41
|
+
*
|
|
42
|
+
* A cache to store loaded React NodeViews for each EditorView.
|
|
43
|
+
*
|
|
44
|
+
* This cache will help us to avoid any race condition
|
|
45
|
+
* when multiple Editors exist in the same page.
|
|
46
|
+
*
|
|
47
|
+
* @type {CacheType}
|
|
48
|
+
*/
|
|
49
|
+
var cachePerEditorView = new WeakMap();
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 🧱 Internal: Editor FE Platform
|
|
53
|
+
*/
|
|
54
|
+
var isFirefox = /gecko\/\d/i.test(navigator.userAgent);
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 🧱 Internal: Editor FE Platform
|
|
58
|
+
*
|
|
59
|
+
* A NodeView that serves as a placeholder until the actual NodeView is loaded.
|
|
60
|
+
*/
|
|
61
|
+
var LazyNodeView = /*#__PURE__*/(0, _createClass2.default)(function LazyNodeView(node, view, getPos) {
|
|
62
|
+
var _node$type;
|
|
63
|
+
(0, _classCallCheck2.default)(this, LazyNodeView);
|
|
64
|
+
if (typeof ((_node$type = node.type) === null || _node$type === void 0 || (_node$type = _node$type.spec) === null || _node$type === void 0 ? void 0 : _node$type.toDOM) !== 'function') {
|
|
65
|
+
this.dom = document.createElement('div');
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
var fallback = _model.DOMSerializer.renderSpec(document, node.type.spec.toDOM(node));
|
|
69
|
+
this.dom = fallback.dom;
|
|
70
|
+
this.contentDOM = fallback.contentDOM;
|
|
71
|
+
if (this.dom instanceof HTMLElement) {
|
|
72
|
+
// This attribute is mostly used for debugging purposed
|
|
73
|
+
// It will help us to found out when the node was replaced
|
|
74
|
+
this.dom.setAttribute('data-lazy-node-view', node.type.name);
|
|
75
|
+
// This is used on Libra tests
|
|
76
|
+
// We are using this to make sure all lazy noded were replaced
|
|
77
|
+
// before the test started
|
|
78
|
+
this.dom.setAttribute('data-lazy-node-view-fallback', 'true');
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
/**
|
|
82
|
+
* 🧱 Internal: Editor FE Platform
|
|
83
|
+
*
|
|
84
|
+
* Debounces and replaces the node views in a ProseMirror editor with lazy-loaded node views.
|
|
85
|
+
*
|
|
86
|
+
* This function is used to update the `nodeViews` property of the `EditorView` after lazy-loaded
|
|
87
|
+
* node views have been loaded. It uses a debounced approach to ensure that the replacement does
|
|
88
|
+
* not happen too frequently, which can be performance-intensive.
|
|
89
|
+
*
|
|
90
|
+
* The function checks if there are any loaded node views in the cache associated with the given
|
|
91
|
+
* `EditorView`. If there are, it replaces the current `nodeViews` in the `EditorView` with the
|
|
92
|
+
* loaded node views. The replacement is scheduled using `requestIdleCallback` or
|
|
93
|
+
* `requestAnimationFrame` to avoid blocking the main thread, especially in Firefox where
|
|
94
|
+
* `requestIdleCallback` may not be supported.
|
|
95
|
+
*
|
|
96
|
+
* @param {WeakMap<EditorView, Record<string, NodeViewConstructor>>} cache - A WeakMap that stores
|
|
97
|
+
* the loaded node views for each `EditorView`. The key is the `EditorView`, and the value
|
|
98
|
+
* is a record of node type names to their corresponding `NodeViewConstructor`.
|
|
99
|
+
* @param {EditorView} view - The ProseMirror `EditorView` instance whose `nodeViews` property
|
|
100
|
+
* needs to be updated.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* const cache = new WeakMap();
|
|
104
|
+
* const view = new EditorView(...);
|
|
105
|
+
*
|
|
106
|
+
* // Assume some node views have been loaded and stored in the cache
|
|
107
|
+
* cache.set(view, {
|
|
108
|
+
* 'table': TableViewConstructor,
|
|
109
|
+
* 'tableCell': TableCellViewConstructor,
|
|
110
|
+
* });
|
|
111
|
+
*
|
|
112
|
+
* debouncedReplaceNodeviews(cache, view);
|
|
113
|
+
*/
|
|
114
|
+
var debouncedReplaceNodeviews = exports.debouncedReplaceNodeviews = (0, _debounce.default)(function (cache, view) {
|
|
115
|
+
var loadedNodeviews = cache.get(view);
|
|
116
|
+
if (!loadedNodeviews) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
cache.delete(view);
|
|
120
|
+
|
|
121
|
+
// eslint-disable-next-line compat/compat
|
|
122
|
+
var idle = window.requestIdleCallback;
|
|
123
|
+
|
|
124
|
+
/*
|
|
125
|
+
* For reasons that goes beyond my knowledge
|
|
126
|
+
* some Firefox versions aren't calling the requestIdleCallback.
|
|
127
|
+
*
|
|
128
|
+
* So, we need this check to make sure we use the requestAnimationFrame instead
|
|
129
|
+
*/
|
|
130
|
+
var later = isFirefox || typeof idle !== 'function' ? window.requestAnimationFrame : idle;
|
|
131
|
+
later(function () {
|
|
132
|
+
var currentNodeViews = view.props.nodeViews;
|
|
133
|
+
var nextNodeViews = _objectSpread(_objectSpread({}, currentNodeViews), loadedNodeviews);
|
|
134
|
+
view.setProps({
|
|
135
|
+
nodeViews: nextNodeViews
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* 📢 Public: Any EditorPlugin can use this function
|
|
142
|
+
*
|
|
143
|
+
* Wraps a NodeView constructor with laziness, allowing the NodeView to be loaded only when required.
|
|
144
|
+
*
|
|
145
|
+
* This higher-order function is designed to optimize the loading and rendering performance
|
|
146
|
+
* of ProseMirror editor nodes by deferring the loading of their associated NodeViews until they are actually needed.
|
|
147
|
+
* This is particularly useful for complex or heavy NodeViews, such as tables, table cells, rows, and headers within
|
|
148
|
+
* the ProseMirror editor. By using dynamic imports (with promises), the initial load time of the editor can be significantly
|
|
149
|
+
* reduced, leading to a smoother and faster user experience.
|
|
150
|
+
*
|
|
151
|
+
* The function accepts configuration parameters including the node name, a loader function that dynamically imports
|
|
152
|
+
* the NodeView, and a function to retrieve NodeView options. It returns a NodeViewConstructor that ProseMirror
|
|
153
|
+
* can use when rendering nodes of the specified type.
|
|
154
|
+
*
|
|
155
|
+
* @template NodeViewOptions - The type parameter that describes the shape of the options object for the NodeView.
|
|
156
|
+
* @param {LazyLoadingProps<NodeViewOptions>} params - Configuration parameters for lazy loading.
|
|
157
|
+
* @param {string} params.nodeName - The name of the node (e.g., 'table', 'tableCell', 'tableHeader', 'tableRow') for which the lazy-loaded NodeView is intended.
|
|
158
|
+
* @param {() => Promise<CreateReactNodeViewProps<NodeViewOptions>>} params.loader - A function that, when called, returns a promise that resolves to the actual NodeView constructor. This function typically uses dynamic `import()` to load the NodeView code.
|
|
159
|
+
* @param {() => NodeViewOptions} params.getNodeViewOptions - A function that returns the options to be passed to the NodeView constructor. These options can include dependencies like `portalProviderAPI`, `eventDispatcher`, and others, which are necessary for the NodeView's operation.
|
|
160
|
+
* @param {DispatchAnalyticsEvent} [params.dispatchAnalyticsEvent] - An optional function for dispatching analytics events, which can be used to monitor the performance and usage of the lazy-loaded NodeViews.
|
|
161
|
+
* @returns {NodeViewConstructor} A constructor function for creating a NodeView that ProseMirror can instantiate when it encounters a node of the specified type. This constructor is a lightweight placeholder until the actual NodeView is loaded.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* // Lazy load a table NodeView with specific options
|
|
165
|
+
* const lazyTableView = withLazyLoading({
|
|
166
|
+
* nodeName: 'table',
|
|
167
|
+
* loader: () => import('./table').then(module => module.createTableView),
|
|
168
|
+
* getNodeViewOptions: () => ({
|
|
169
|
+
* portalProviderAPI,
|
|
170
|
+
* eventDispatcher,
|
|
171
|
+
* getEditorContainerWidth,
|
|
172
|
+
* getEditorFeatureFlags,
|
|
173
|
+
* dispatchAnalyticsEvent,
|
|
174
|
+
* pluginInjectionApi,
|
|
175
|
+
* }),
|
|
176
|
+
* });
|
|
177
|
+
*
|
|
178
|
+
* // Then, use `lazyTableView` in ProseMirror editor setup to enhance 'table' nodes with lazy loading
|
|
179
|
+
*/
|
|
180
|
+
var withLazyLoading = exports.withLazyLoading = function withLazyLoading(_ref) {
|
|
181
|
+
var nodeName = _ref.nodeName,
|
|
182
|
+
loader = _ref.loader,
|
|
183
|
+
getNodeViewOptions = _ref.getNodeViewOptions,
|
|
184
|
+
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent;
|
|
185
|
+
var createLazyNodeView = function createLazyNodeView(node, view, getPos, decorations) {
|
|
186
|
+
var _node$type2;
|
|
187
|
+
var cachedMap = cachePerEditorView.get(view);
|
|
188
|
+
if (!cachedMap) {
|
|
189
|
+
cachedMap = {};
|
|
190
|
+
cachePerEditorView.set(view, cachedMap);
|
|
191
|
+
}
|
|
192
|
+
var wasAlreadyRequested = cachedMap.hasOwnProperty(nodeName);
|
|
193
|
+
if (wasAlreadyRequested) {
|
|
194
|
+
return new LazyNodeView(node, view, getPos);
|
|
195
|
+
}
|
|
196
|
+
loader().then(function (nodeViewFuncModule) {
|
|
197
|
+
cachedMap[nodeName] = function (node, view, getPos, decorations) {
|
|
198
|
+
return nodeViewFuncModule(node, view, getPos, decorations, getNodeViewOptions);
|
|
199
|
+
};
|
|
200
|
+
debouncedReplaceNodeviews(cachePerEditorView, view);
|
|
201
|
+
});
|
|
202
|
+
if (typeof ((_node$type2 = node.type) === null || _node$type2 === void 0 || (_node$type2 = _node$type2.spec) === null || _node$type2 === void 0 ? void 0 : _node$type2.toDOM) !== 'function') {
|
|
203
|
+
// TODO: Analytics ED-23982
|
|
204
|
+
// dispatchAnalyticsEvent({
|
|
205
|
+
// action: ACTION.LAZY_NODE_VIEW_ERROR,
|
|
206
|
+
// actionSubject: ACTION_SUBJECT.LAZY_NODE_VIEW,
|
|
207
|
+
// eventType: EVENT_TYPE.OPERATIONAL,
|
|
208
|
+
// attributes: {
|
|
209
|
+
// nodeName,
|
|
210
|
+
// error: 'No spec found',
|
|
211
|
+
// },
|
|
212
|
+
// });
|
|
213
|
+
}
|
|
214
|
+
return new LazyNodeView(node, view, getPos);
|
|
215
|
+
};
|
|
216
|
+
return createLazyNodeView;
|
|
217
|
+
};
|
|
@@ -28,6 +28,7 @@ var SMALL_LINK_TOOLBAR_ANALYTICS_SOURCE = 'smallLinkToolbar';
|
|
|
28
28
|
var Dropdown = function Dropdown(_ref) {
|
|
29
29
|
var onConfigureClickCallback = _ref.onConfigureClick,
|
|
30
30
|
onDropdownChange = _ref.onDropdownChange,
|
|
31
|
+
editorView = _ref.editorView,
|
|
31
32
|
testId = _ref.testId;
|
|
32
33
|
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
33
34
|
formatMessage = _useIntl.formatMessage;
|
|
@@ -37,20 +38,34 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
37
38
|
fireActionClickEvent = _useLinkOverlayAnalyt.fireActionClickEvent,
|
|
38
39
|
fireLinkClickEvent = _useLinkOverlayAnalyt.fireLinkClickEvent,
|
|
39
40
|
fireToolbarViewEvent = _useLinkOverlayAnalyt.fireToolbarViewEvent;
|
|
41
|
+
var focusEditor = (0, _react.useCallback)(function () {
|
|
42
|
+
// Fix dropdown giving focus back to the trigger async which is then unmounted and losing focus
|
|
43
|
+
// this is happening deep within atlaskit dropdown as a result of this code: https://github.com/focus-trap/focus-trap/blob/master/index.js#L987
|
|
44
|
+
// use setTimeout to run this async after that call
|
|
45
|
+
setTimeout(function () {
|
|
46
|
+
return editorView.focus();
|
|
47
|
+
}, 0);
|
|
48
|
+
}, [editorView]);
|
|
40
49
|
var onOpenChange = (0, _react.useCallback)(function (_ref2) {
|
|
41
|
-
var isOpen = _ref2.isOpen
|
|
50
|
+
var isOpen = _ref2.isOpen,
|
|
51
|
+
event = _ref2.event;
|
|
42
52
|
onDropdownChange === null || onDropdownChange === void 0 || onDropdownChange(isOpen);
|
|
43
53
|
if (isOpen) {
|
|
44
54
|
fireToolbarViewEvent();
|
|
45
55
|
}
|
|
46
|
-
|
|
56
|
+
if (!isOpen && event instanceof KeyboardEvent) {
|
|
57
|
+
focusEditor();
|
|
58
|
+
}
|
|
59
|
+
}, [fireToolbarViewEvent, focusEditor, onDropdownChange]);
|
|
47
60
|
var onGoToLinkClick = (0, _react.useCallback)(function () {
|
|
48
61
|
fireActionClickEvent('goToLink');
|
|
49
|
-
|
|
62
|
+
focusEditor();
|
|
63
|
+
}, [fireActionClickEvent, focusEditor]);
|
|
50
64
|
var onConfigureClick = (0, _react.useCallback)(function () {
|
|
51
65
|
fireActionClickEvent('configureLink');
|
|
52
66
|
onConfigureClickCallback === null || onConfigureClickCallback === void 0 || onConfigureClickCallback();
|
|
53
|
-
|
|
67
|
+
focusEditor();
|
|
68
|
+
}, [fireActionClickEvent, focusEditor, onConfigureClickCallback]);
|
|
54
69
|
return (0, _react2.jsx)(_dropdownMenu.default, {
|
|
55
70
|
trigger: function trigger(_ref3) {
|
|
56
71
|
var _onClick = _ref3.onClick,
|
|
@@ -95,7 +95,8 @@ var OverlayButton = exports.OverlayButton = (0, _analyticsNext.withAnalyticsCont
|
|
|
95
95
|
}, showDropdown ? (0, _react2.jsx)(_Dropdown.default, {
|
|
96
96
|
testId: testId,
|
|
97
97
|
onConfigureClick: handleConfigureClick,
|
|
98
|
-
onDropdownChange: onDropdownChange
|
|
98
|
+
onDropdownChange: onDropdownChange,
|
|
99
|
+
editorView: editorView
|
|
99
100
|
}) : (0, _react2.jsx)(_tooltip.default, {
|
|
100
101
|
content: configureLinkLabel,
|
|
101
102
|
hideTooltipOnClick: true,
|
|
@@ -76,6 +76,11 @@ var helpDialogMessages = exports.helpDialogMessages = (0, _reactIntlNext.defineM
|
|
|
76
76
|
defaultMessage: 'Decrease table or media size',
|
|
77
77
|
description: 'The text is shown as an shortcut description in help dialog modal, when the user uses the described shortcut, he is able to decrease the width of the selected element. Optimal characters less than 21.'
|
|
78
78
|
},
|
|
79
|
+
openCellOptions: {
|
|
80
|
+
id: 'fabric.editor.openCellOptions',
|
|
81
|
+
defaultMessage: 'Open cell options',
|
|
82
|
+
description: 'Keyboard shortcut to open cell options.'
|
|
83
|
+
},
|
|
79
84
|
focusTableResizeHandle: {
|
|
80
85
|
id: 'fabric.editor.focusTableResizeHandle',
|
|
81
86
|
defaultMessage: 'Focus table resize handle',
|
|
@@ -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.
|
|
20
|
+
var packageVersion = "86.2.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
|
|
@@ -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.
|
|
23
|
+
var packageVersion = "86.2.0";
|
|
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];
|
|
@@ -105,7 +105,7 @@ var DropdownMenuWrapper = exports.default = /*#__PURE__*/function (_PureComponen
|
|
|
105
105
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleCloseAndFocus", function (event) {
|
|
106
106
|
var _this$state$target;
|
|
107
107
|
(_this$state$target = _this.state.target) === null || _this$state$target === void 0 || (_this$state$target = _this$state$target.querySelector('button')) === null || _this$state$target === void 0 || _this$state$target.focus();
|
|
108
|
-
if ((0, _platformFeatureFlags.fg)('
|
|
108
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_a11y_table_context_menu')) {
|
|
109
109
|
_this.handleClose(event);
|
|
110
110
|
} else {
|
|
111
111
|
_this.handleClose();
|
|
@@ -114,7 +114,7 @@ var DropdownMenuWrapper = exports.default = /*#__PURE__*/function (_PureComponen
|
|
|
114
114
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleClose", function (event) {
|
|
115
115
|
var onOpenChange = _this.props.onOpenChange;
|
|
116
116
|
if (onOpenChange) {
|
|
117
|
-
if ((0, _platformFeatureFlags.fg)('
|
|
117
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_a11y_table_context_menu')) {
|
|
118
118
|
onOpenChange({
|
|
119
119
|
isOpen: false,
|
|
120
120
|
event: event
|
|
@@ -193,7 +193,7 @@ var DropdownMenuWrapper = exports.default = /*#__PURE__*/function (_PureComponen
|
|
|
193
193
|
handleClickOutside: this.handleClose,
|
|
194
194
|
handleEscapeKeydown: (0, _platformFeatureFlags.fg)('platform-editor-a11y-image-border-options-dropdown') ? handleEscapeKeydown || this.handleCloseAndFocus : this.handleCloseAndFocus,
|
|
195
195
|
handleEnterKeydown: function handleEnterKeydown(e) {
|
|
196
|
-
if ((0, _platformFeatureFlags.fg)('
|
|
196
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_a11y_table_context_menu') || (0, _platformFeatureFlags.fg)('platform-editor-a11y-image-border-options-dropdown')) {
|
|
197
197
|
if (!allowEnterDefaultBehavior) {
|
|
198
198
|
e.preventDefault();
|
|
199
199
|
}
|
|
@@ -365,7 +365,7 @@ function DropdownMenuItem(_ref) {
|
|
|
365
365
|
item: item
|
|
366
366
|
});
|
|
367
367
|
},
|
|
368
|
-
"aria-expanded": (0, _platformFeatureFlags.fg)('
|
|
368
|
+
"aria-expanded": (0, _platformFeatureFlags.fg)('platform_editor_a11y_table_context_menu') ? item['aria-expanded'] : undefined
|
|
369
369
|
}, item.content));
|
|
370
370
|
if (item.tooltipDescription) {
|
|
371
371
|
var _item$key3;
|
|
@@ -10,8 +10,10 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _react2 = require("@emotion/react");
|
|
12
12
|
var _analyticsListeners = require("@atlaskit/analytics-listeners");
|
|
13
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
14
|
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
14
15
|
var _analytics = require("../../analytics");
|
|
16
|
+
var _keymaps = require("../../keymaps");
|
|
15
17
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
16
18
|
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); }
|
|
17
19
|
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; }
|
|
@@ -39,6 +41,7 @@ var ToolbarButton = /*#__PURE__*/_react.default.forwardRef(function (props, ref)
|
|
|
39
41
|
children = props.children,
|
|
40
42
|
hideTooltip = props.hideTooltip,
|
|
41
43
|
title = props.title,
|
|
44
|
+
keymap = props.keymap,
|
|
42
45
|
_props$titlePosition = props.titlePosition,
|
|
43
46
|
titlePosition = _props$titlePosition === void 0 ? 'top' : _props$titlePosition,
|
|
44
47
|
item = props.item,
|
|
@@ -99,7 +102,10 @@ var ToolbarButton = /*#__PURE__*/_react.default.forwardRef(function (props, ref)
|
|
|
99
102
|
if (!title) {
|
|
100
103
|
return button;
|
|
101
104
|
}
|
|
102
|
-
var tooltipContent =
|
|
105
|
+
var tooltipContent = hideTooltip ? null : (0, _platformFeatureFlags.fg)('platform_editor_a11y_table_context_menu') ? (0, _react2.jsx)(_keymaps.ToolTipContent, {
|
|
106
|
+
description: title,
|
|
107
|
+
keymap: keymap
|
|
108
|
+
}) : title;
|
|
103
109
|
return (0, _react2.jsx)(_tooltip.default, {
|
|
104
110
|
content: tooltipContent,
|
|
105
111
|
hideTooltipOnClick: true,
|
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
|
+
};
|