@atlaskit/editor-common 88.6.2 → 88.8.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 +29 -0
- package/browser/package.json +15 -0
- package/dist/cjs/icons/index.js +7 -0
- package/dist/cjs/icons/shared/DynamicStrokeIconDecoration.js +46 -0
- package/dist/cjs/lazy-node-view/index.js +89 -11
- package/dist/cjs/lazy-node-view/node-view.js +27 -7
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/styles/index.js +6 -0
- package/dist/cjs/styles/shared/lists.js +2 -2
- package/dist/cjs/styles/shared/plugins.js +7 -1
- package/dist/cjs/styles/shared/table.js +2 -2
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/utils/analytics.js +7 -27
- package/dist/cjs/utils/browser.js +3 -4
- package/dist/cjs/utils/index.js +20 -5
- package/dist/cjs/utils/unsupportedContent/types.js +5 -0
- package/dist/es2019/icons/index.js +1 -0
- package/dist/es2019/icons/shared/DynamicStrokeIconDecoration.js +40 -0
- package/dist/es2019/lazy-node-view/index.js +81 -11
- package/dist/es2019/lazy-node-view/node-view.js +25 -6
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/styles/index.js +1 -1
- package/dist/es2019/styles/shared/lists.js +1 -1
- package/dist/es2019/styles/shared/plugins.js +6 -0
- package/dist/es2019/styles/shared/table.js +1 -1
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/utils/analytics.js +1 -2
- package/dist/es2019/utils/browser.js +1 -1
- package/dist/es2019/utils/index.js +47 -3
- package/dist/es2019/utils/unsupportedContent/types.js +1 -0
- package/dist/esm/icons/index.js +1 -0
- package/dist/esm/icons/shared/DynamicStrokeIconDecoration.js +39 -0
- package/dist/esm/lazy-node-view/index.js +85 -11
- package/dist/esm/lazy-node-view/node-view.js +27 -7
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/styles/index.js +1 -1
- package/dist/esm/styles/shared/lists.js +1 -1
- package/dist/esm/styles/shared/plugins.js +6 -0
- package/dist/esm/styles/shared/table.js +1 -1
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/utils/analytics.js +1 -2
- package/dist/esm/utils/browser.js +1 -1
- package/dist/esm/utils/index.js +47 -3
- package/dist/esm/utils/unsupportedContent/types.js +1 -0
- package/dist/types/icons/index.d.ts +1 -0
- package/dist/types/icons/shared/DynamicStrokeIconDecoration.d.ts +13 -0
- package/dist/types/lazy-node-view/index.d.ts +18 -1
- package/dist/types/lazy-node-view/node-view.d.ts +4 -5
- package/dist/types/styles/index.d.ts +1 -1
- package/dist/types/styles/shared/plugins.d.ts +1 -0
- package/dist/types/utils/analytics.d.ts +1 -20
- package/dist/types/utils/browser.d.ts +1 -1
- package/dist/types/utils/index.d.ts +48 -4
- package/dist/types/utils/track-unsupported-content.d.ts +1 -1
- package/dist/types/utils/unsupportedContent/types.d.ts +18 -0
- package/dist/types/utils/validate-using-spec.d.ts +1 -1
- package/dist/types-ts4.5/icons/index.d.ts +1 -0
- package/dist/types-ts4.5/icons/shared/DynamicStrokeIconDecoration.d.ts +13 -0
- package/dist/types-ts4.5/lazy-node-view/index.d.ts +18 -1
- package/dist/types-ts4.5/lazy-node-view/node-view.d.ts +4 -5
- package/dist/types-ts4.5/styles/index.d.ts +1 -1
- package/dist/types-ts4.5/styles/shared/plugins.d.ts +1 -0
- package/dist/types-ts4.5/utils/analytics.d.ts +1 -20
- package/dist/types-ts4.5/utils/browser.d.ts +1 -1
- package/dist/types-ts4.5/utils/index.d.ts +48 -4
- package/dist/types-ts4.5/utils/track-unsupported-content.d.ts +1 -1
- package/dist/types-ts4.5/utils/unsupportedContent/types.d.ts +18 -0
- package/dist/types-ts4.5/utils/validate-using-spec.d.ts +1 -1
- package/package.json +4 -2
- package/utils/analytics/package.json +15 -0
- package/dist/cjs/lazy-node-view/replace-node-views.js +0 -173
- package/dist/es2019/lazy-node-view/replace-node-views.js +0 -166
- package/dist/esm/lazy-node-view/replace-node-views.js +0 -166
- package/dist/types/lazy-node-view/replace-node-views.d.ts +0 -34
- package/dist/types-ts4.5/lazy-node-view/replace-node-views.d.ts +0 -34
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
6
|
+
import { css, jsx } from '@emotion/react';
|
|
7
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
8
|
+
const barStyles = css({
|
|
9
|
+
position: 'absolute',
|
|
10
|
+
left: 0,
|
|
11
|
+
right: 0,
|
|
12
|
+
top: "var(--ds-space-250, 20px)",
|
|
13
|
+
margin: 'auto',
|
|
14
|
+
width: "var(--ds-space-200, 16px)",
|
|
15
|
+
height: '3px'
|
|
16
|
+
});
|
|
17
|
+
const textColorIconWrapper = xcss({
|
|
18
|
+
position: 'relative'
|
|
19
|
+
});
|
|
20
|
+
const getBackground = (selectedColor, disabled) => {
|
|
21
|
+
if (selectedColor) {
|
|
22
|
+
return selectedColor;
|
|
23
|
+
}
|
|
24
|
+
return disabled ? "var(--ds-icon-disabled, #091E424F)" : "var(--ds-icon, #44546F)";
|
|
25
|
+
};
|
|
26
|
+
export const DynamicStrokeIconDecoration = ({
|
|
27
|
+
selectedColor,
|
|
28
|
+
disabled,
|
|
29
|
+
icon
|
|
30
|
+
}) => {
|
|
31
|
+
return jsx(Box, {
|
|
32
|
+
xcss: textColorIconWrapper
|
|
33
|
+
}, icon, jsx("div", {
|
|
34
|
+
"data-testid": "toolbar-icon-dynamic-stroke",
|
|
35
|
+
style: {
|
|
36
|
+
background: getBackground(selectedColor, disabled)
|
|
37
|
+
},
|
|
38
|
+
css: barStyles
|
|
39
|
+
}));
|
|
40
|
+
};
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
1
2
|
import { LazyNodeView } from './node-view';
|
|
2
|
-
import { queueReplaceNodeViews } from './replace-node-views';
|
|
3
3
|
export { convertToInlineCss } from './css-helper';
|
|
4
|
+
/**
|
|
5
|
+
* 📢 Public Plugin Key
|
|
6
|
+
*
|
|
7
|
+
* Communication channel between LazyNodeView loader and LazyNodeViewDecorationPlugin.
|
|
8
|
+
*/
|
|
9
|
+
export const lazyNodeViewDecorationPluginKey = new PluginKey('lazyNodeViewDecoration');
|
|
4
10
|
|
|
5
11
|
/**
|
|
6
12
|
* 📢 Public Type
|
|
@@ -14,6 +20,12 @@ export { convertToInlineCss } from './css-helper';
|
|
|
14
20
|
* @see {withLazyLoading}
|
|
15
21
|
*/
|
|
16
22
|
|
|
23
|
+
/**
|
|
24
|
+
* 🧱 Internal: Editor FE Platform
|
|
25
|
+
*
|
|
26
|
+
* Caches loaded node view factory functions
|
|
27
|
+
*/
|
|
28
|
+
|
|
17
29
|
/**
|
|
18
30
|
* 🧱 Internal: Editor FE Platform
|
|
19
31
|
*
|
|
@@ -21,6 +33,33 @@ export { convertToInlineCss } from './css-helper';
|
|
|
21
33
|
*/
|
|
22
34
|
const requestedNodesPerEditorView = new WeakMap();
|
|
23
35
|
|
|
36
|
+
/**
|
|
37
|
+
* 🧱 Internal: Editor FE Platform
|
|
38
|
+
*
|
|
39
|
+
* Caches loaded node view factory functions for each editor view
|
|
40
|
+
*/
|
|
41
|
+
const resolvedNodesPerEditorView = new WeakMap();
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 🧱 Internal: Editor FE Platform
|
|
45
|
+
*
|
|
46
|
+
* Stores editorView -> raf to debounce NodeView updates.
|
|
47
|
+
*/
|
|
48
|
+
const debounceToEditorViewMap = new WeakMap();
|
|
49
|
+
const testOnlyIgnoreLazyNodeViewSet = new WeakSet();
|
|
50
|
+
/**
|
|
51
|
+
* 🧱 Internal: Editor FE Platform
|
|
52
|
+
*
|
|
53
|
+
* Used in tests to prevent lazy node view being replaced by a real node view.
|
|
54
|
+
*
|
|
55
|
+
* This needs to be replaced with proper implementation once LazyNodeView is converted to a plugin.
|
|
56
|
+
*
|
|
57
|
+
* @deprecated DO NOT USE THIS OUSIDE TESTS.
|
|
58
|
+
*/
|
|
59
|
+
export function testOnlyIgnoreLazyNodeView(view) {
|
|
60
|
+
testOnlyIgnoreLazyNodeViewSet.add(view);
|
|
61
|
+
}
|
|
62
|
+
|
|
24
63
|
/**
|
|
25
64
|
* 📢 Public: Any EditorPlugin can use this function
|
|
26
65
|
*
|
|
@@ -64,29 +103,60 @@ const requestedNodesPerEditorView = new WeakMap();
|
|
|
64
103
|
export const withLazyLoading = ({
|
|
65
104
|
nodeName,
|
|
66
105
|
loader,
|
|
67
|
-
getNodeViewOptions
|
|
68
|
-
dispatchAnalyticsEvent
|
|
106
|
+
getNodeViewOptions
|
|
69
107
|
}) => {
|
|
70
108
|
const createLazyNodeView = (node, view, getPos, decorations) => {
|
|
71
109
|
var _node$type, _node$type$spec;
|
|
72
110
|
let requestedNodes = requestedNodesPerEditorView.get(view);
|
|
73
111
|
if (!requestedNodes) {
|
|
74
|
-
requestedNodes = new
|
|
112
|
+
requestedNodes = new Map();
|
|
113
|
+
requestedNodesPerEditorView.set(view, requestedNodes);
|
|
114
|
+
}
|
|
115
|
+
const resolvedNodeViews = resolvedNodesPerEditorView.get(view);
|
|
116
|
+
if (!resolvedNodeViews) {
|
|
117
|
+
resolvedNodesPerEditorView.set(view, new Map());
|
|
75
118
|
}
|
|
76
119
|
const wasAlreadyRequested = requestedNodes.has(nodeName);
|
|
77
120
|
if (wasAlreadyRequested) {
|
|
78
|
-
|
|
121
|
+
const resolvedNodeView = resolvedNodeViews === null || resolvedNodeViews === void 0 ? void 0 : resolvedNodeViews.get(nodeName);
|
|
122
|
+
if (resolvedNodeView && !testOnlyIgnoreLazyNodeViewSet.has(view)) {
|
|
123
|
+
return resolvedNodeView(node, view, getPos, decorations);
|
|
124
|
+
}
|
|
125
|
+
return new LazyNodeView(node, view, getPos, requestedNodes.get(nodeName));
|
|
79
126
|
}
|
|
80
|
-
|
|
81
|
-
|
|
127
|
+
const loaderPromise = loader().then(nodeViewFuncModule => {
|
|
128
|
+
var _resolvedNodesPerEdit;
|
|
82
129
|
const nodeViewFunc = (node, view, getPos, decorations) => {
|
|
83
130
|
return nodeViewFuncModule(node, view, getPos, decorations, getNodeViewOptions);
|
|
84
131
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
132
|
+
(_resolvedNodesPerEdit = resolvedNodesPerEditorView.get(view)) === null || _resolvedNodesPerEdit === void 0 ? void 0 : _resolvedNodesPerEdit.set(nodeName, nodeViewFunc);
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Triggering lazyNodeViewDecoration plugin to apply decorations
|
|
136
|
+
* to nodes with newly loaded NodeViews.
|
|
137
|
+
*/
|
|
138
|
+
const [raf, nodeTypes] = debounceToEditorViewMap.get(view) || [null, new Set()];
|
|
139
|
+
if (raf) {
|
|
140
|
+
cancelAnimationFrame(raf);
|
|
141
|
+
}
|
|
142
|
+
nodeTypes.add(node.type.name);
|
|
143
|
+
const nextRaf = requestAnimationFrame(() => {
|
|
144
|
+
debounceToEditorViewMap.set(view, [null, new Set()]);
|
|
145
|
+
const tr = view.state.tr;
|
|
146
|
+
tr.setMeta(lazyNodeViewDecorationPluginKey, {
|
|
147
|
+
type: 'add',
|
|
148
|
+
nodeTypes
|
|
149
|
+
});
|
|
150
|
+
view.dispatch(tr);
|
|
88
151
|
});
|
|
152
|
+
debounceToEditorViewMap.set(view, [nextRaf, nodeTypes]);
|
|
153
|
+
/**
|
|
154
|
+
* END triggering LazyNodeViewDecoration plugin
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
return nodeViewFunc;
|
|
89
158
|
});
|
|
159
|
+
requestedNodes.set(nodeName, loaderPromise);
|
|
90
160
|
if (typeof ((_node$type = node.type) === null || _node$type === void 0 ? void 0 : (_node$type$spec = _node$type.spec) === null || _node$type$spec === void 0 ? void 0 : _node$type$spec.toDOM) !== 'function') {
|
|
91
161
|
// TODO: Analytics ED-23982
|
|
92
162
|
// dispatchAnalyticsEvent({
|
|
@@ -99,7 +169,7 @@ export const withLazyLoading = ({
|
|
|
99
169
|
// },
|
|
100
170
|
// });
|
|
101
171
|
}
|
|
102
|
-
return new LazyNodeView(node, view, getPos);
|
|
172
|
+
return new LazyNodeView(node, view, getPos, loaderPromise);
|
|
103
173
|
};
|
|
104
174
|
return createLazyNodeView;
|
|
105
175
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
import memoize from 'lodash/memoize';
|
|
2
3
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
3
4
|
const getEditorLineWidth = memoize(view => {
|
|
@@ -11,17 +12,32 @@ const getEditorLineWidth = memoize(view => {
|
|
|
11
12
|
* A NodeView that serves as a placeholder until the actual NodeView is loaded.
|
|
12
13
|
*/
|
|
13
14
|
export class LazyNodeView {
|
|
14
|
-
constructor(
|
|
15
|
+
constructor(_node, view, _getPos, nodeViewLoader) {
|
|
15
16
|
var _node$type, _node$type$spec;
|
|
16
|
-
this
|
|
17
|
-
|
|
17
|
+
_defineProperty(this, "update", node => {
|
|
18
|
+
const prevNode = this.node;
|
|
19
|
+
this.node = node;
|
|
20
|
+
|
|
21
|
+
// Forcing NodeView to be re-created
|
|
22
|
+
// so that ProseMirror can replace LazyNodeView with the real one.
|
|
23
|
+
if (this.isNodeViewLoaded) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Copying some of the default NodeView update behaviour
|
|
28
|
+
// https://github.com/ProseMirror/prosemirror-view/blob/cfa73eb969777f63bcb39972594fd4a9110f5a93/src/viewdesc.ts#L803
|
|
29
|
+
return !this.node.sameMarkup(prevNode);
|
|
30
|
+
});
|
|
31
|
+
this.node = _node;
|
|
32
|
+
this.isNodeViewLoaded = false;
|
|
33
|
+
if (typeof ((_node$type = _node.type) === null || _node$type === void 0 ? void 0 : (_node$type$spec = _node$type.spec) === null || _node$type$spec === void 0 ? void 0 : _node$type$spec.toDOM) !== 'function') {
|
|
18
34
|
this.dom = document.createElement('div');
|
|
19
35
|
return;
|
|
20
36
|
}
|
|
21
37
|
const toDOMConfiguration = {
|
|
22
38
|
editorLineWidth: getEditorLineWidth(view)
|
|
23
39
|
};
|
|
24
|
-
const fallback = DOMSerializer.renderSpec(document,
|
|
40
|
+
const fallback = DOMSerializer.renderSpec(document, _node.type.spec.toDOM(_node,
|
|
25
41
|
// We are injecting a second parameter to be used by the toDOM lazy node view implementations
|
|
26
42
|
// @ts-expect-error
|
|
27
43
|
toDOMConfiguration));
|
|
@@ -30,14 +46,17 @@ export class LazyNodeView {
|
|
|
30
46
|
if (this.dom instanceof HTMLElement) {
|
|
31
47
|
// This attribute is mostly used for debugging purposed
|
|
32
48
|
// It will help us to found out when the node was replaced
|
|
33
|
-
this.dom.setAttribute('data-lazy-node-view',
|
|
49
|
+
this.dom.setAttribute('data-lazy-node-view', _node.type.name);
|
|
34
50
|
// This is used on Libra tests
|
|
35
51
|
// We are using this to make sure all lazy noded were replaced
|
|
36
52
|
// before the test started
|
|
37
53
|
this.dom.setAttribute('data-lazy-node-view-fallback', 'true');
|
|
38
54
|
}
|
|
55
|
+
nodeViewLoader.then(() => {
|
|
56
|
+
this.isNodeViewLoaded = true;
|
|
57
|
+
});
|
|
39
58
|
}
|
|
40
|
-
ignoreMutation(
|
|
59
|
+
ignoreMutation() {
|
|
41
60
|
if (this.node.type.isTextblock) {
|
|
42
61
|
return false;
|
|
43
62
|
}
|
|
@@ -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 = "88.
|
|
4
|
+
const packageVersion = "88.8.0";
|
|
5
5
|
const sanitiseSentryEvents = (data, _hint) => {
|
|
6
6
|
// Remove URL as it has UGC
|
|
7
7
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -27,7 +27,7 @@ export { resizerStyles, resizerHandleClassName, resizerHandleTrackClassName, res
|
|
|
27
27
|
export { gridStyles, GRID_GUTTER } from './shared/grid';
|
|
28
28
|
export { smartCardStyles, FLOATING_TOOLBAR_LINKPICKER_CLASSNAME, DATASOURCE_INNER_CONTAINER_CLASSNAME } from './shared/smartCard';
|
|
29
29
|
export { embedCardStyles, embedSpacingStyles } from './shared/embedCard';
|
|
30
|
-
export { buttonGroupStyle, separatorStyles, wrapperStyle, triggerWrapperStyles } from './shared/plugins';
|
|
30
|
+
export { buttonGroupStyle, separatorStyles, wrapperStyle, triggerWrapperStyles, triggerWrapperStylesWithPadding } from './shared/plugins';
|
|
31
31
|
export { UnsupportedSharedCssClassName, unsupportedStyles } from './shared/unsupported-content';
|
|
32
32
|
export { expandIconWrapperStyle, expandClassNames, expandIconContainerStyle } from './shared/expand';
|
|
33
33
|
export { sharedExpandStyles } from '../ui/Expand/sharedStyles';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
2
2
|
import { css } from '@emotion/react';
|
|
3
3
|
import { bulletListSelector, orderedListSelector } from '@atlaskit/adf-schema';
|
|
4
|
-
import browser from '../../utils/browser';
|
|
4
|
+
import { browser } from '../../utils/browser';
|
|
5
5
|
export const listItemCounterPadding = 24;
|
|
6
6
|
var CSS_VAR_NAMES = /*#__PURE__*/function (CSS_VAR_NAMES) {
|
|
7
7
|
CSS_VAR_NAMES["ITEM_COUNTER_PADDING"] = "--ed--list--item-counter--padding";
|
|
@@ -42,4 +42,10 @@ export const wrapperStyle = css({
|
|
|
42
42
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
43
43
|
export const triggerWrapperStyles = css({
|
|
44
44
|
display: 'flex'
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles
|
|
48
|
+
export const triggerWrapperStylesWithPadding = css({
|
|
49
|
+
display: 'flex',
|
|
50
|
+
paddingRight: "var(--ds-space-025, 2px)"
|
|
45
51
|
});
|
|
@@ -3,7 +3,7 @@ import { css } from '@emotion/react';
|
|
|
3
3
|
import { tableCellContentDomSelector, tableCellSelector, tableHeaderSelector, tablePrefixSelector } from '@atlaskit/adf-schema';
|
|
4
4
|
import { akEditorBreakoutPadding, akEditorFullWidthLayoutWidth, akEditorSelectedNodeClassName, akEditorTableBorder, akEditorTableNumberColumnWidth, akEditorTableToolbar, akEditorWideLayoutWidth, overflowShadow } from '@atlaskit/editor-shared-styles';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
|
-
import browser from '../../utils/browser';
|
|
6
|
+
import { browser } from '../../utils/browser';
|
|
7
7
|
import { CodeBlockSharedCssClassName } from './code-block';
|
|
8
8
|
import { tableCellBackgroundStyleOverride } from './tableCell';
|
|
9
9
|
export const tableMarginTop = 24;
|
|
@@ -14,7 +14,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
|
14
14
|
import { N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
|
|
15
15
|
import Layer from '../Layer';
|
|
16
16
|
const packageName = "@atlaskit/editor-common";
|
|
17
|
-
const packageVersion = "88.
|
|
17
|
+
const packageVersion = "88.8.0";
|
|
18
18
|
const halfFocusRing = 1;
|
|
19
19
|
const dropOffset = '0, 8';
|
|
20
20
|
class DropList extends Component {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EDITOR_APPEARANCE_CONTEXT } from '@atlaskit/analytics-namespaced-context';
|
|
1
|
+
import { EDITOR_APPEARANCE_CONTEXT } from '@atlaskit/analytics-namespaced-context/FabricEditorAnalyticsContext';
|
|
2
2
|
export const getAnalyticsAppearance = appearance => {
|
|
3
3
|
switch (appearance) {
|
|
4
4
|
case 'full-page':
|
|
@@ -29,5 +29,4 @@ export let SEVERITY = /*#__PURE__*/function (SEVERITY) {
|
|
|
29
29
|
SEVERITY["BLOCKING"] = "blocking";
|
|
30
30
|
return SEVERITY;
|
|
31
31
|
}({});
|
|
32
|
-
export { UNSUPPORTED_CONTENT_LEVEL_SEVERITY, getUnsupportedContentLevelData, UNSUPPORTED_CONTENT_LEVEL_SEVERITY_THRESHOLD_DEFAULTS } from './unsupportedContent/get-unsupported-content-level-data';
|
|
33
32
|
export const analyticsEventKey = 'EDITOR_ANALYTICS_EVENT';
|
|
@@ -36,4 +36,4 @@ if (typeof navigator !== 'undefined') {
|
|
|
36
36
|
result.supportsIntersectionObserver = typeof window !== 'undefined' && 'IntersectionObserver' in window && 'IntersectionObserverEntry' in window && 'intersectionRatio' in window.IntersectionObserverEntry.prototype;
|
|
37
37
|
result.supportsResizeObserver = typeof window !== 'undefined' && 'ResizeObserver' in window && 'ResizeObserverEntry' in window;
|
|
38
38
|
}
|
|
39
|
-
export
|
|
39
|
+
export { result as browser };
|
|
@@ -4,18 +4,56 @@ import { isEmptyParagraph } from './editor-core-utils';
|
|
|
4
4
|
export { shouldAutoLinkifyMatch } from './should-auto-linkify-tld';
|
|
5
5
|
export { getAnnotationMarksForPos, canApplyAnnotationOnRange, containsAnyAnnotations, getAnnotationIdsFromRange, getAnnotationInlineNodeTypes, hasAnnotationMark, getRangeInlineNodeNames } from './annotation';
|
|
6
6
|
export { getExtensionLozengeData } from './macro';
|
|
7
|
-
export {
|
|
7
|
+
export {
|
|
8
|
+
/**
|
|
9
|
+
* @private
|
|
10
|
+
* @deprecated
|
|
11
|
+
*
|
|
12
|
+
* Please use `@atlaskit/editor-common/browser` entry-point instead.
|
|
13
|
+
*/
|
|
14
|
+
browser } from './browser';
|
|
8
15
|
export { default as ErrorReporter } from './error-reporter';
|
|
9
16
|
export { isPastDate, timestampToIsoFormat, timestampToString, timestampToTaskContext, timestampToUTCDate, todayTimestampInUTC } from './date';
|
|
10
17
|
export { isElementInTableCell, isTextSelection, isLastItemMediaGroup, setNodeSelection, setTextSelection, setAllSelection, setCellSelection, nonNullable, stepAddsOneOf, stepHasSlice, extractSliceFromStep, isValidPosition, isEmptyParagraph, isInLayoutColumn, removeBlockMarks, filterChildrenBetween } from './editor-core-utils';
|
|
11
18
|
export { withImageLoader } from './imageLoader';
|
|
12
19
|
export { absoluteBreakoutWidth, calcBreakoutWidth, calcWideWidth, breakoutConsts, calculateBreakoutStyles, calcBreakoutWidthPx, getNextBreakoutMode, getTitle } from './breakout';
|
|
13
|
-
export {
|
|
20
|
+
export {
|
|
21
|
+
/**
|
|
22
|
+
* @private
|
|
23
|
+
* @deprecated
|
|
24
|
+
*
|
|
25
|
+
* This is only used in editor-core and shouldn't be used anywhere else.
|
|
26
|
+
* If you do need it please reach out to #cc-editor-lego
|
|
27
|
+
*/
|
|
28
|
+
findChangedNodesFromTransaction,
|
|
29
|
+
/**
|
|
30
|
+
* @private
|
|
31
|
+
* @deprecated
|
|
32
|
+
*
|
|
33
|
+
* This is only used in editor-core and shouldn't be used anywhere else.
|
|
34
|
+
* If you do need it please reach out to #cc-editor-lego
|
|
35
|
+
*/
|
|
36
|
+
validNode,
|
|
37
|
+
/**
|
|
38
|
+
* @private
|
|
39
|
+
* @deprecated
|
|
40
|
+
*
|
|
41
|
+
* This is only used in editor-core and shouldn't be used anywhere else.
|
|
42
|
+
* If you do need it please reach out to #cc-editor-lego
|
|
43
|
+
*/
|
|
44
|
+
validateNodes, isType, isParagraph, isText, isLinkMark, SelectedState, isNodeSelectedOrInRange, isSupportedInParent, isMediaNode, isNodeBeforeMediaNode } from './nodes';
|
|
14
45
|
export { pluginFactory } from './plugin-state-factory';
|
|
15
46
|
export { getFragmentBackingArray, mapFragment, mapSlice, flatmap, mapChildren } from './slice';
|
|
16
47
|
export { walkUpTreeUntil, unwrap, removeNestedEmptyEls, containsClassName, closest, closestElement, parsePx, mapElem, maphElem } from './dom';
|
|
17
48
|
export { default as ADFTraversor } from './traversor';
|
|
18
|
-
|
|
49
|
+
/**
|
|
50
|
+
* @private
|
|
51
|
+
* @deprecated
|
|
52
|
+
*
|
|
53
|
+
* Use entry-point `@atlaskit/editor-common/utils/analytics` instead
|
|
54
|
+
*/
|
|
55
|
+
export { analyticsEventKey, getAnalyticsAppearance, getAnalyticsEditorAppearance, getAnalyticsEventSeverity, SEVERITY } from './analytics';
|
|
56
|
+
export { getUnsupportedContentLevelData, UNSUPPORTED_CONTENT_LEVEL_SEVERITY, UNSUPPORTED_CONTENT_LEVEL_SEVERITY_THRESHOLD_DEFAULTS } from './unsupportedContent/get-unsupported-content-level-data';
|
|
19
57
|
export { findAndTrackUnsupportedContentNodes } from './track-unsupported-content';
|
|
20
58
|
export { getDistortedDurationMonitor, measureRender } from './performance/measure-render';
|
|
21
59
|
export { startMeasure, stopMeasure, clearMeasure } from './performance/measure';
|
|
@@ -39,6 +77,12 @@ export { RenderCountProfiler, PROFILER_KEY } from './profiler/render-count';
|
|
|
39
77
|
export { validateADFEntity, validationErrorHandler } from './validate-using-spec';
|
|
40
78
|
export { getShallowPropsDifference, getPropsDifference } from './compare-props';
|
|
41
79
|
export { useComponentRenderTracking } from './performance/hooks/use-component-render-tracking';
|
|
80
|
+
/**
|
|
81
|
+
* @private
|
|
82
|
+
* @deprecated
|
|
83
|
+
*
|
|
84
|
+
* Private API do not use
|
|
85
|
+
*/
|
|
42
86
|
export { isOutdatedBrowser } from './outdated-browsers';
|
|
43
87
|
export { autoJoinTr } from './prosemirror/autojoin';
|
|
44
88
|
export { isReferencedSource, removeConnectedNodes, getChildrenInfo, getNodeName } from './referentiality';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/icons/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { PanelSuccessIcon } from './shared/PanelSuccessIcon';
|
|
|
6
6
|
export { PanelNoteIcon } from './shared/PanelNoteIcon';
|
|
7
7
|
export { BorderIcon } from './shared/BorderIcon';
|
|
8
8
|
export { SteppedRainbowIconDecoration } from './shared/SteppedRainbowIconDecoration';
|
|
9
|
+
export { DynamicStrokeIconDecoration } from './shared/DynamicStrokeIconDecoration';
|
|
9
10
|
export var IconTable = Loadable({
|
|
10
11
|
loader: function loader() {
|
|
11
12
|
return import( /* webpackChunkName: "@atlaskit-internal_editor-icon-table" */'../icons/shared/table').then(function (module) {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
6
|
+
import { css, jsx } from '@emotion/react';
|
|
7
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
8
|
+
var barStyles = css({
|
|
9
|
+
position: 'absolute',
|
|
10
|
+
left: 0,
|
|
11
|
+
right: 0,
|
|
12
|
+
top: "var(--ds-space-250, 20px)",
|
|
13
|
+
margin: 'auto',
|
|
14
|
+
width: "var(--ds-space-200, 16px)",
|
|
15
|
+
height: '3px'
|
|
16
|
+
});
|
|
17
|
+
var textColorIconWrapper = xcss({
|
|
18
|
+
position: 'relative'
|
|
19
|
+
});
|
|
20
|
+
var getBackground = function getBackground(selectedColor, disabled) {
|
|
21
|
+
if (selectedColor) {
|
|
22
|
+
return selectedColor;
|
|
23
|
+
}
|
|
24
|
+
return disabled ? "var(--ds-icon-disabled, #091E424F)" : "var(--ds-icon, #44546F)";
|
|
25
|
+
};
|
|
26
|
+
export var DynamicStrokeIconDecoration = function DynamicStrokeIconDecoration(_ref) {
|
|
27
|
+
var selectedColor = _ref.selectedColor,
|
|
28
|
+
disabled = _ref.disabled,
|
|
29
|
+
icon = _ref.icon;
|
|
30
|
+
return jsx(Box, {
|
|
31
|
+
xcss: textColorIconWrapper
|
|
32
|
+
}, icon, jsx("div", {
|
|
33
|
+
"data-testid": "toolbar-icon-dynamic-stroke",
|
|
34
|
+
style: {
|
|
35
|
+
background: getBackground(selectedColor, disabled)
|
|
36
|
+
},
|
|
37
|
+
css: barStyles
|
|
38
|
+
}));
|
|
39
|
+
};
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
1
3
|
import { LazyNodeView } from './node-view';
|
|
2
|
-
import { queueReplaceNodeViews } from './replace-node-views';
|
|
3
4
|
export { convertToInlineCss } from './css-helper';
|
|
5
|
+
/**
|
|
6
|
+
* 📢 Public Plugin Key
|
|
7
|
+
*
|
|
8
|
+
* Communication channel between LazyNodeView loader and LazyNodeViewDecorationPlugin.
|
|
9
|
+
*/
|
|
10
|
+
export var lazyNodeViewDecorationPluginKey = new PluginKey('lazyNodeViewDecoration');
|
|
4
11
|
|
|
5
12
|
/**
|
|
6
13
|
* 📢 Public Type
|
|
@@ -14,6 +21,12 @@ export { convertToInlineCss } from './css-helper';
|
|
|
14
21
|
* @see {withLazyLoading}
|
|
15
22
|
*/
|
|
16
23
|
|
|
24
|
+
/**
|
|
25
|
+
* 🧱 Internal: Editor FE Platform
|
|
26
|
+
*
|
|
27
|
+
* Caches loaded node view factory functions
|
|
28
|
+
*/
|
|
29
|
+
|
|
17
30
|
/**
|
|
18
31
|
* 🧱 Internal: Editor FE Platform
|
|
19
32
|
*
|
|
@@ -21,6 +34,33 @@ export { convertToInlineCss } from './css-helper';
|
|
|
21
34
|
*/
|
|
22
35
|
var requestedNodesPerEditorView = new WeakMap();
|
|
23
36
|
|
|
37
|
+
/**
|
|
38
|
+
* 🧱 Internal: Editor FE Platform
|
|
39
|
+
*
|
|
40
|
+
* Caches loaded node view factory functions for each editor view
|
|
41
|
+
*/
|
|
42
|
+
var resolvedNodesPerEditorView = new WeakMap();
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 🧱 Internal: Editor FE Platform
|
|
46
|
+
*
|
|
47
|
+
* Stores editorView -> raf to debounce NodeView updates.
|
|
48
|
+
*/
|
|
49
|
+
var debounceToEditorViewMap = new WeakMap();
|
|
50
|
+
var testOnlyIgnoreLazyNodeViewSet = new WeakSet();
|
|
51
|
+
/**
|
|
52
|
+
* 🧱 Internal: Editor FE Platform
|
|
53
|
+
*
|
|
54
|
+
* Used in tests to prevent lazy node view being replaced by a real node view.
|
|
55
|
+
*
|
|
56
|
+
* This needs to be replaced with proper implementation once LazyNodeView is converted to a plugin.
|
|
57
|
+
*
|
|
58
|
+
* @deprecated DO NOT USE THIS OUSIDE TESTS.
|
|
59
|
+
*/
|
|
60
|
+
export function testOnlyIgnoreLazyNodeView(view) {
|
|
61
|
+
testOnlyIgnoreLazyNodeViewSet.add(view);
|
|
62
|
+
}
|
|
63
|
+
|
|
24
64
|
/**
|
|
25
65
|
* 📢 Public: Any EditorPlugin can use this function
|
|
26
66
|
*
|
|
@@ -64,28 +104,62 @@ var requestedNodesPerEditorView = new WeakMap();
|
|
|
64
104
|
export var withLazyLoading = function withLazyLoading(_ref) {
|
|
65
105
|
var nodeName = _ref.nodeName,
|
|
66
106
|
loader = _ref.loader,
|
|
67
|
-
getNodeViewOptions = _ref.getNodeViewOptions
|
|
68
|
-
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent;
|
|
107
|
+
getNodeViewOptions = _ref.getNodeViewOptions;
|
|
69
108
|
var createLazyNodeView = function createLazyNodeView(node, view, getPos, decorations) {
|
|
70
109
|
var _node$type;
|
|
71
110
|
var requestedNodes = requestedNodesPerEditorView.get(view);
|
|
72
111
|
if (!requestedNodes) {
|
|
73
|
-
requestedNodes = new
|
|
112
|
+
requestedNodes = new Map();
|
|
113
|
+
requestedNodesPerEditorView.set(view, requestedNodes);
|
|
114
|
+
}
|
|
115
|
+
var resolvedNodeViews = resolvedNodesPerEditorView.get(view);
|
|
116
|
+
if (!resolvedNodeViews) {
|
|
117
|
+
resolvedNodesPerEditorView.set(view, new Map());
|
|
74
118
|
}
|
|
75
119
|
var wasAlreadyRequested = requestedNodes.has(nodeName);
|
|
76
120
|
if (wasAlreadyRequested) {
|
|
77
|
-
|
|
121
|
+
var resolvedNodeView = resolvedNodeViews === null || resolvedNodeViews === void 0 ? void 0 : resolvedNodeViews.get(nodeName);
|
|
122
|
+
if (resolvedNodeView && !testOnlyIgnoreLazyNodeViewSet.has(view)) {
|
|
123
|
+
return resolvedNodeView(node, view, getPos, decorations);
|
|
124
|
+
}
|
|
125
|
+
return new LazyNodeView(node, view, getPos, requestedNodes.get(nodeName));
|
|
78
126
|
}
|
|
79
|
-
|
|
80
|
-
|
|
127
|
+
var loaderPromise = loader().then(function (nodeViewFuncModule) {
|
|
128
|
+
var _resolvedNodesPerEdit;
|
|
81
129
|
var nodeViewFunc = function nodeViewFunc(node, view, getPos, decorations) {
|
|
82
130
|
return nodeViewFuncModule(node, view, getPos, decorations, getNodeViewOptions);
|
|
83
131
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
132
|
+
(_resolvedNodesPerEdit = resolvedNodesPerEditorView.get(view)) === null || _resolvedNodesPerEdit === void 0 || _resolvedNodesPerEdit.set(nodeName, nodeViewFunc);
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Triggering lazyNodeViewDecoration plugin to apply decorations
|
|
136
|
+
* to nodes with newly loaded NodeViews.
|
|
137
|
+
*/
|
|
138
|
+
var _ref2 = debounceToEditorViewMap.get(view) || [null, new Set()],
|
|
139
|
+
_ref3 = _slicedToArray(_ref2, 2),
|
|
140
|
+
raf = _ref3[0],
|
|
141
|
+
nodeTypes = _ref3[1];
|
|
142
|
+
if (raf) {
|
|
143
|
+
cancelAnimationFrame(raf);
|
|
144
|
+
}
|
|
145
|
+
nodeTypes.add(node.type.name);
|
|
146
|
+
var nextRaf = requestAnimationFrame(function () {
|
|
147
|
+
debounceToEditorViewMap.set(view, [null, new Set()]);
|
|
148
|
+
var tr = view.state.tr;
|
|
149
|
+
tr.setMeta(lazyNodeViewDecorationPluginKey, {
|
|
150
|
+
type: 'add',
|
|
151
|
+
nodeTypes: nodeTypes
|
|
152
|
+
});
|
|
153
|
+
view.dispatch(tr);
|
|
87
154
|
});
|
|
155
|
+
debounceToEditorViewMap.set(view, [nextRaf, nodeTypes]);
|
|
156
|
+
/**
|
|
157
|
+
* END triggering LazyNodeViewDecoration plugin
|
|
158
|
+
*/
|
|
159
|
+
|
|
160
|
+
return nodeViewFunc;
|
|
88
161
|
});
|
|
162
|
+
requestedNodes.set(nodeName, loaderPromise);
|
|
89
163
|
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') {
|
|
90
164
|
// TODO: Analytics ED-23982
|
|
91
165
|
// dispatchAnalyticsEvent({
|
|
@@ -98,7 +172,7 @@ export var withLazyLoading = function withLazyLoading(_ref) {
|
|
|
98
172
|
// },
|
|
99
173
|
// });
|
|
100
174
|
}
|
|
101
|
-
return new LazyNodeView(node, view, getPos);
|
|
175
|
+
return new LazyNodeView(node, view, getPos, loaderPromise);
|
|
102
176
|
};
|
|
103
177
|
return createLazyNodeView;
|
|
104
178
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
4
|
import memoize from 'lodash/memoize';
|
|
4
5
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
5
6
|
var getEditorLineWidth = memoize(function (view) {
|
|
@@ -13,18 +14,34 @@ var getEditorLineWidth = memoize(function (view) {
|
|
|
13
14
|
* A NodeView that serves as a placeholder until the actual NodeView is loaded.
|
|
14
15
|
*/
|
|
15
16
|
export var LazyNodeView = /*#__PURE__*/function () {
|
|
16
|
-
function LazyNodeView(
|
|
17
|
-
var
|
|
17
|
+
function LazyNodeView(_node, view, _getPos, nodeViewLoader) {
|
|
18
|
+
var _this = this,
|
|
19
|
+
_node$type;
|
|
18
20
|
_classCallCheck(this, LazyNodeView);
|
|
19
|
-
this
|
|
20
|
-
|
|
21
|
+
_defineProperty(this, "update", function (node) {
|
|
22
|
+
var prevNode = _this.node;
|
|
23
|
+
_this.node = node;
|
|
24
|
+
|
|
25
|
+
// Forcing NodeView to be re-created
|
|
26
|
+
// so that ProseMirror can replace LazyNodeView with the real one.
|
|
27
|
+
if (_this.isNodeViewLoaded) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Copying some of the default NodeView update behaviour
|
|
32
|
+
// https://github.com/ProseMirror/prosemirror-view/blob/cfa73eb969777f63bcb39972594fd4a9110f5a93/src/viewdesc.ts#L803
|
|
33
|
+
return !_this.node.sameMarkup(prevNode);
|
|
34
|
+
});
|
|
35
|
+
this.node = _node;
|
|
36
|
+
this.isNodeViewLoaded = false;
|
|
37
|
+
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') {
|
|
21
38
|
this.dom = document.createElement('div');
|
|
22
39
|
return;
|
|
23
40
|
}
|
|
24
41
|
var toDOMConfiguration = {
|
|
25
42
|
editorLineWidth: getEditorLineWidth(view)
|
|
26
43
|
};
|
|
27
|
-
var fallback = DOMSerializer.renderSpec(document,
|
|
44
|
+
var fallback = DOMSerializer.renderSpec(document, _node.type.spec.toDOM(_node,
|
|
28
45
|
// We are injecting a second parameter to be used by the toDOM lazy node view implementations
|
|
29
46
|
// @ts-expect-error
|
|
30
47
|
toDOMConfiguration));
|
|
@@ -33,16 +50,19 @@ export var LazyNodeView = /*#__PURE__*/function () {
|
|
|
33
50
|
if (this.dom instanceof HTMLElement) {
|
|
34
51
|
// This attribute is mostly used for debugging purposed
|
|
35
52
|
// It will help us to found out when the node was replaced
|
|
36
|
-
this.dom.setAttribute('data-lazy-node-view',
|
|
53
|
+
this.dom.setAttribute('data-lazy-node-view', _node.type.name);
|
|
37
54
|
// This is used on Libra tests
|
|
38
55
|
// We are using this to make sure all lazy noded were replaced
|
|
39
56
|
// before the test started
|
|
40
57
|
this.dom.setAttribute('data-lazy-node-view-fallback', 'true');
|
|
41
58
|
}
|
|
59
|
+
nodeViewLoader.then(function () {
|
|
60
|
+
_this.isNodeViewLoaded = true;
|
|
61
|
+
});
|
|
42
62
|
}
|
|
43
63
|
_createClass(LazyNodeView, [{
|
|
44
64
|
key: "ignoreMutation",
|
|
45
|
-
value: function ignoreMutation(
|
|
65
|
+
value: function ignoreMutation() {
|
|
46
66
|
if (this.node.type.isTextblock) {
|
|
47
67
|
return false;
|
|
48
68
|
}
|