@atlaskit/editor-common 74.5.2 → 74.7.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 +12 -0
- package/dist/cjs/analytics/index.js +26 -1
- package/dist/cjs/analytics/linking-utils.js +84 -0
- package/dist/cjs/card/MediaAndEmbedsToolbar/index.js +156 -0
- package/dist/cjs/card/index.js +9 -1
- package/dist/cjs/messages/index.js +14 -0
- package/dist/cjs/messages/link-toolbar.js +60 -0
- package/dist/cjs/messages/media-and-embed-toolbar.js +20 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/node-width/index.js +16 -2
- package/dist/cjs/react-node-view/getInlineNodeViewProducer.js +225 -0
- package/dist/cjs/react-node-view/index.js +13 -0
- package/dist/cjs/{ui/Resizer/index.js → resizer/Resizer.js} +6 -3
- package/dist/cjs/{resizer.js → resizer/index.js} +1 -1
- package/dist/cjs/resizer/utils.js +21 -0
- package/dist/cjs/styles/shared/resizer.js +1 -1
- package/dist/cjs/styles/shared/table.js +5 -4
- package/dist/cjs/types/hyperlink.js +5 -0
- package/dist/cjs/types/resizable-media-single.js +5 -0
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/ui/LinkSearch/const.js +14 -0
- package/dist/cjs/ui/ResizerLegacy/index.js +210 -0
- package/dist/cjs/ui/ResizerLegacy/styled.js +15 -0
- package/dist/cjs/ui/ResizerLegacy/types.js +5 -0
- package/dist/cjs/ui/ResizerLegacy/utils.js +21 -0
- package/dist/cjs/ui/index.js +58 -0
- package/dist/cjs/utils/document.js +258 -0
- package/dist/cjs/utils/editor-core-utils.js +7 -2
- package/dist/cjs/utils/filter/privacy-filter.js +55 -0
- package/dist/cjs/utils/index.js +75 -0
- package/dist/cjs/utils/rich-media-utils.js +131 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics/index.js +2 -1
- package/dist/es2019/analytics/linking-utils.js +74 -0
- package/dist/es2019/card/MediaAndEmbedsToolbar/index.js +161 -0
- package/dist/es2019/card/index.js +2 -1
- package/dist/es2019/messages/index.js +2 -0
- package/dist/es2019/messages/link-toolbar.js +53 -0
- package/dist/es2019/messages/media-and-embed-toolbar.js +13 -0
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/node-width/index.js +12 -1
- package/dist/es2019/react-node-view/getInlineNodeViewProducer.js +219 -0
- package/dist/es2019/react-node-view/index.js +1 -0
- package/dist/es2019/{ui/Resizer/index.js → resizer/Resizer.js} +5 -3
- package/dist/es2019/resizer/index.js +1 -0
- package/dist/es2019/resizer/utils.js +12 -0
- package/dist/es2019/styles/shared/resizer.js +8 -4
- package/dist/es2019/styles/shared/table.js +5 -4
- package/dist/es2019/types/resizable-media-single.js +1 -0
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/ui/LinkSearch/const.js +4 -0
- package/dist/es2019/ui/ResizerLegacy/index.js +191 -0
- package/dist/es2019/ui/ResizerLegacy/styled.js +15 -0
- package/dist/es2019/ui/ResizerLegacy/types.js +1 -0
- package/dist/es2019/ui/ResizerLegacy/utils.js +12 -0
- package/dist/es2019/ui/index.js +5 -1
- package/dist/es2019/utils/document.js +253 -0
- package/dist/es2019/utils/editor-core-utils.js +4 -0
- package/dist/es2019/utils/filter/privacy-filter.js +47 -0
- package/dist/es2019/utils/index.js +5 -2
- package/dist/es2019/utils/rich-media-utils.js +109 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics/index.js +2 -1
- package/dist/esm/analytics/linking-utils.js +74 -0
- package/dist/esm/card/MediaAndEmbedsToolbar/index.js +146 -0
- package/dist/esm/card/index.js +2 -1
- package/dist/esm/messages/index.js +2 -0
- package/dist/esm/messages/link-toolbar.js +53 -0
- package/dist/esm/messages/media-and-embed-toolbar.js +13 -0
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/node-width/index.js +12 -1
- package/dist/esm/react-node-view/getInlineNodeViewProducer.js +215 -0
- package/dist/esm/react-node-view/index.js +1 -0
- package/dist/esm/{ui/Resizer/index.js → resizer/Resizer.js} +6 -3
- package/dist/esm/resizer/index.js +1 -0
- package/dist/esm/resizer/types.js +1 -0
- package/dist/esm/resizer/utils.js +12 -0
- package/dist/esm/styles/shared/resizer.js +1 -1
- package/dist/esm/styles/shared/table.js +5 -4
- package/dist/esm/types/hyperlink.js +1 -0
- package/dist/esm/types/resizable-media-single.js +1 -0
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/ui/LinkSearch/const.js +4 -0
- package/dist/esm/ui/ResizerLegacy/index.js +203 -0
- package/dist/esm/ui/ResizerLegacy/styled.js +7 -0
- package/dist/esm/ui/ResizerLegacy/types.js +1 -0
- package/dist/esm/ui/ResizerLegacy/utils.js +12 -0
- package/dist/esm/ui/index.js +5 -1
- package/dist/esm/utils/document.js +246 -0
- package/dist/esm/utils/editor-core-utils.js +4 -0
- package/dist/esm/utils/filter/privacy-filter.js +48 -0
- package/dist/esm/utils/index.js +5 -2
- package/dist/esm/utils/rich-media-utils.js +118 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics/index.d.ts +2 -0
- package/dist/types/analytics/linking-utils.d.ts +14 -0
- package/dist/types/card/MediaAndEmbedsToolbar/index.d.ts +11 -0
- package/dist/types/card/index.d.ts +1 -0
- package/dist/types/messages/index.d.ts +2 -0
- package/dist/types/messages/link-toolbar.d.ts +52 -0
- package/dist/types/messages/media-and-embed-toolbar.d.ts +12 -0
- package/dist/types/node-width/index.d.ts +7 -0
- package/dist/types/react-node-view/getInlineNodeViewProducer.d.ts +25 -0
- package/dist/types/react-node-view/index.d.ts +3 -0
- package/dist/types/{ui/Resizer/index.d.ts → resizer/Resizer.d.ts} +1 -0
- package/dist/types/resizer/index.d.ts +2 -0
- package/dist/types/resizer/utils.d.ts +6 -0
- package/dist/types/styles/shared/table.d.ts +2 -1
- package/dist/types/types/hyperlink.d.ts +35 -0
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types/types/resizable-media-single.d.ts +15 -0
- package/dist/types/ui/DropList/index.d.ts +1 -1
- package/dist/types/ui/LinkSearch/const.d.ts +4 -0
- package/dist/types/ui/ResizerLegacy/index.d.ts +40 -0
- package/dist/types/ui/ResizerLegacy/styled.d.ts +2 -0
- package/dist/types/ui/ResizerLegacy/types.d.ts +26 -0
- package/dist/types/ui/ResizerLegacy/utils.d.ts +6 -0
- package/dist/types/ui/index.d.ts +6 -0
- package/dist/types/utils/document.d.ts +19 -0
- package/dist/types/utils/editor-core-utils.d.ts +1 -0
- package/dist/types/utils/filter/privacy-filter.d.ts +9 -0
- package/dist/types/utils/index.d.ts +4 -1
- package/dist/types/utils/rich-media-utils.d.ts +8 -0
- package/dist/types-ts4.5/analytics/index.d.ts +2 -0
- package/dist/types-ts4.5/analytics/linking-utils.d.ts +14 -0
- package/dist/types-ts4.5/card/MediaAndEmbedsToolbar/index.d.ts +11 -0
- package/dist/types-ts4.5/card/index.d.ts +1 -0
- package/dist/types-ts4.5/messages/index.d.ts +2 -0
- package/dist/types-ts4.5/messages/link-toolbar.d.ts +52 -0
- package/dist/types-ts4.5/messages/media-and-embed-toolbar.d.ts +12 -0
- package/dist/types-ts4.5/node-width/index.d.ts +7 -0
- package/dist/types-ts4.5/react-node-view/getInlineNodeViewProducer.d.ts +25 -0
- package/dist/types-ts4.5/react-node-view/index.d.ts +3 -0
- package/dist/types-ts4.5/{ui/Resizer/index.d.ts → resizer/Resizer.d.ts} +1 -0
- package/dist/types-ts4.5/resizer/index.d.ts +2 -0
- package/dist/types-ts4.5/resizer/utils.d.ts +6 -0
- package/dist/types-ts4.5/styles/shared/table.d.ts +2 -1
- package/dist/types-ts4.5/types/hyperlink.d.ts +35 -0
- package/dist/types-ts4.5/types/index.d.ts +2 -0
- package/dist/types-ts4.5/types/resizable-media-single.d.ts +15 -0
- package/dist/types-ts4.5/ui/DropList/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/LinkSearch/const.d.ts +4 -0
- package/dist/types-ts4.5/ui/ResizerLegacy/index.d.ts +40 -0
- package/dist/types-ts4.5/ui/ResizerLegacy/styled.d.ts +2 -0
- package/dist/types-ts4.5/ui/ResizerLegacy/types.d.ts +26 -0
- package/dist/types-ts4.5/ui/ResizerLegacy/utils.d.ts +6 -0
- package/dist/types-ts4.5/ui/index.d.ts +6 -0
- package/dist/types-ts4.5/utils/document.d.ts +19 -0
- package/dist/types-ts4.5/utils/editor-core-utils.d.ts +1 -0
- package/dist/types-ts4.5/utils/filter/privacy-filter.d.ts +9 -0
- package/dist/types-ts4.5/utils/index.d.ts +4 -1
- package/dist/types-ts4.5/utils/rich-media-utils.d.ts +8 -0
- package/package.json +9 -9
- package/resizer/package.json +5 -5
- package/dist/cjs/ui/Resizer/utils.js +0 -8
- package/dist/es2019/resizer.js +0 -1
- package/dist/es2019/ui/Resizer/utils.js +0 -1
- package/dist/esm/resizer.js +0 -1
- package/dist/esm/ui/Resizer/utils.js +0 -1
- package/dist/types/resizer.d.ts +0 -2
- package/dist/types/ui/Resizer/utils.d.ts +0 -1
- package/dist/types-ts4.5/resizer.d.ts +0 -2
- package/dist/types-ts4.5/ui/Resizer/utils.d.ts +0 -1
- /package/dist/cjs/{ui/Resizer → resizer}/types.js +0 -0
- /package/dist/es2019/{ui/Resizer → resizer}/types.js +0 -0
- /package/dist/{esm/ui/Resizer/types.js → es2019/types/hyperlink.js} +0 -0
- /package/dist/types/{ui/Resizer → resizer}/types.d.ts +0 -0
- /package/dist/types-ts4.5/{ui/Resizer → resizer}/types.d.ts +0 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { jsx } from '@emotion/react';
|
|
5
|
+
import { ACTION_SUBJECT, ACTION_SUBJECT_ID } from '../analytics';
|
|
6
|
+
import { ErrorBoundary } from '../ui/ErrorBoundary';
|
|
7
|
+
import { analyticsEventKey, getPerformanceOptions, startMeasureReactNodeViewRendered, stopMeasureReactNodeViewRendered, ZERO_WIDTH_SPACE } from '../utils';
|
|
8
|
+
export const inlineNodeViewClassname = 'inlineNodeView';
|
|
9
|
+
function createNodeView({
|
|
10
|
+
nodeViewParams,
|
|
11
|
+
pmPluginFactoryParams,
|
|
12
|
+
Component,
|
|
13
|
+
extraComponentProps
|
|
14
|
+
}) {
|
|
15
|
+
// We set a variable for the current node which is
|
|
16
|
+
// used for comparisions when doing updates, before being
|
|
17
|
+
// overwritten to the updated node.
|
|
18
|
+
let currentNode = nodeViewParams.node;
|
|
19
|
+
|
|
20
|
+
// First we setup the dom element which will be rendered and "tracked" by prosemirror
|
|
21
|
+
// and also used as a "editor portal" (not react portal) target by the editor
|
|
22
|
+
// portal provider api, for rendering the Component passed.
|
|
23
|
+
|
|
24
|
+
let domRef = document.createElement('span');
|
|
25
|
+
domRef.contentEditable = 'false';
|
|
26
|
+
setDomAttrs(nodeViewParams.node, domRef);
|
|
27
|
+
|
|
28
|
+
// @see ED-3790
|
|
29
|
+
// something gets messed up during mutation processing inside of a
|
|
30
|
+
// nodeView if DOM structure has nested plain "div"s, it doesn't see the
|
|
31
|
+
// difference between them and it kills the nodeView
|
|
32
|
+
domRef.classList.add(`${nodeViewParams.node.type.name}View-content-wrap`, `${inlineNodeViewClassname}`);
|
|
33
|
+
|
|
34
|
+
// This util is shared for tracking rendering, and the ErrorBoundary that
|
|
35
|
+
// is setup to wrap the Component when rendering
|
|
36
|
+
// NOTE: This is not a prosemirror dispatch
|
|
37
|
+
function dispatchAnalyticsEvent(payload) {
|
|
38
|
+
pmPluginFactoryParams.eventDispatcher.emit(analyticsEventKey, {
|
|
39
|
+
payload
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// This is called to render the Component into domRef which is inside the
|
|
44
|
+
// prosemirror View.
|
|
45
|
+
// Internally it uses the unstable_renderSubtreeIntoContainer api to render,
|
|
46
|
+
// to the passed dom element (domRef) which means it is automatically
|
|
47
|
+
// "cleaned up" when you do a "re render".
|
|
48
|
+
function renderComponent() {
|
|
49
|
+
pmPluginFactoryParams.portalProviderAPI.render(getPortalChildren({
|
|
50
|
+
dispatchAnalyticsEvent,
|
|
51
|
+
currentNode,
|
|
52
|
+
nodeViewParams,
|
|
53
|
+
Component,
|
|
54
|
+
extraComponentProps
|
|
55
|
+
}), domRef, false,
|
|
56
|
+
// node views should be rendered with intl context
|
|
57
|
+
true);
|
|
58
|
+
}
|
|
59
|
+
const {
|
|
60
|
+
samplingRate,
|
|
61
|
+
slowThreshold,
|
|
62
|
+
trackingEnabled
|
|
63
|
+
} = getPerformanceOptions(nodeViewParams.view);
|
|
64
|
+
trackingEnabled && startMeasureReactNodeViewRendered({
|
|
65
|
+
nodeTypeName: currentNode.type.name
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// We render the component while creating the node view
|
|
69
|
+
renderComponent();
|
|
70
|
+
trackingEnabled && stopMeasureReactNodeViewRendered({
|
|
71
|
+
nodeTypeName: currentNode.type.name,
|
|
72
|
+
dispatchAnalyticsEvent,
|
|
73
|
+
editorState: nodeViewParams.view.state,
|
|
74
|
+
samplingRate,
|
|
75
|
+
slowThreshold
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// https://prosemirror.net/docs/ref/#view.NodeView
|
|
79
|
+
const nodeView = {
|
|
80
|
+
get dom() {
|
|
81
|
+
return domRef;
|
|
82
|
+
},
|
|
83
|
+
update(nextNode, _decorations) {
|
|
84
|
+
// Let ProseMirror handle the update if node types are different.
|
|
85
|
+
// This prevents an issue where it was not possible to select the
|
|
86
|
+
// inline node view then replace it by entering text - the node
|
|
87
|
+
// view contents would be deleted but the node view itself would
|
|
88
|
+
// stay in the view and become uneditable.
|
|
89
|
+
if (currentNode.type !== nextNode.type) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
// On updates, we only set the new attributes if the type, attributes, and marks
|
|
93
|
+
// have changed on the node.
|
|
94
|
+
|
|
95
|
+
// NOTE: this could mean attrs changes aren't reflected in the dom,
|
|
96
|
+
// when an attribute key which was previously present is no longer
|
|
97
|
+
// present.
|
|
98
|
+
// ie.
|
|
99
|
+
// -> Original attributes { text: "hello world", color: "red" }
|
|
100
|
+
// -> Updated attributes { color: "blue" }
|
|
101
|
+
// in this case, the dom text attribute will not be cleared.
|
|
102
|
+
//
|
|
103
|
+
// This may not be an issue with any of our current node schemas.
|
|
104
|
+
if (!currentNode.sameMarkup(nextNode)) {
|
|
105
|
+
setDomAttrs(nextNode, domRef);
|
|
106
|
+
}
|
|
107
|
+
currentNode = nextNode;
|
|
108
|
+
renderComponent();
|
|
109
|
+
return true;
|
|
110
|
+
},
|
|
111
|
+
destroy() {
|
|
112
|
+
// When prosemirror destroys the node view, we need to clean up
|
|
113
|
+
// what we have previously rendered using the editor portal
|
|
114
|
+
// provider api.
|
|
115
|
+
pmPluginFactoryParams.portalProviderAPI.remove(domRef);
|
|
116
|
+
// @ts-expect-error Expect an error as domRef is expected to be
|
|
117
|
+
// of HTMLSpanElement type however once the node view has
|
|
118
|
+
// been destroyed no other consumers should still be using it.
|
|
119
|
+
domRef = undefined;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
return nodeView;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Copies the attributes from a ProseMirror Node to a DOM node.
|
|
127
|
+
* @param node The Prosemirror Node from which to source the attributes
|
|
128
|
+
*/
|
|
129
|
+
function setDomAttrs(node, element) {
|
|
130
|
+
Object.keys(node.attrs || {}).forEach(attr => {
|
|
131
|
+
element.setAttribute(attr, node.attrs[attr]);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function getPortalChildren({
|
|
135
|
+
dispatchAnalyticsEvent,
|
|
136
|
+
currentNode,
|
|
137
|
+
nodeViewParams,
|
|
138
|
+
Component,
|
|
139
|
+
extraComponentProps
|
|
140
|
+
}) {
|
|
141
|
+
return function portalChildren() {
|
|
142
|
+
var _currentNode$type$nam, _currentNode$type;
|
|
143
|
+
// All inline nodes use `display: inline` to allow for multi-line
|
|
144
|
+
// wrapping. This does produce an issue in Chrome where it is not
|
|
145
|
+
// possible to click select the position after the node,
|
|
146
|
+
// see: https://product-fabric.atlassian.net/browse/ED-12003
|
|
147
|
+
// however this is only a problem for node views that use
|
|
148
|
+
// `display: inline-block` somewhere within the Component.
|
|
149
|
+
// Looking at the below structure, spans with className
|
|
150
|
+
// `inlineNodeViewAddZeroWidthSpace` have pseudo elements that
|
|
151
|
+
// add a zero width space which fixes the problem.
|
|
152
|
+
// Without the additional zero width space before the Component,
|
|
153
|
+
// it is not possible to use the keyboard to range select in Safari.
|
|
154
|
+
//
|
|
155
|
+
// Zero width spaces on either side of the Component also prevent
|
|
156
|
+
// the cursor from appearing inside the node view on all browsers.
|
|
157
|
+
//
|
|
158
|
+
// Note:
|
|
159
|
+
// In future it is worth considering prohibiting the use of `display: inline-block`
|
|
160
|
+
// within inline node view Components however would require a sizable
|
|
161
|
+
// refactor. A test suite to catch any instances of this is ideal however
|
|
162
|
+
// the refactor required is currently out of scope for https://product-fabric.atlassian.net/browse/ED-14176
|
|
163
|
+
|
|
164
|
+
return jsx(ErrorBoundary, {
|
|
165
|
+
component: ACTION_SUBJECT.REACT_NODE_VIEW,
|
|
166
|
+
componentId: (_currentNode$type$nam = currentNode === null || currentNode === void 0 ? void 0 : (_currentNode$type = currentNode.type) === null || _currentNode$type === void 0 ? void 0 : _currentNode$type.name) !== null && _currentNode$type$nam !== void 0 ? _currentNode$type$nam : ACTION_SUBJECT_ID.UNKNOWN_NODE,
|
|
167
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
168
|
+
}, jsx("span", {
|
|
169
|
+
"aria-hidden": "true",
|
|
170
|
+
className: `zeroWidthSpaceContainer`
|
|
171
|
+
}, jsx("span", {
|
|
172
|
+
className: `${inlineNodeViewClassname}AddZeroWidthSpace`
|
|
173
|
+
}), ZERO_WIDTH_SPACE), jsx(Component, _extends({
|
|
174
|
+
view: nodeViewParams.view,
|
|
175
|
+
getPos: nodeViewParams.getPos,
|
|
176
|
+
node: currentNode
|
|
177
|
+
}, extraComponentProps)), jsx("span", {
|
|
178
|
+
"aria-hidden": "true",
|
|
179
|
+
className: `${inlineNodeViewClassname}AddZeroWidthSpace`
|
|
180
|
+
}));
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// https://prosemirror.net/docs/ref/#view.EditorProps.nodeViews
|
|
185
|
+
// The prosemirror EditorProps has a nodeViews key which has the rough shape:
|
|
186
|
+
// type nodeViews: {
|
|
187
|
+
// [nodeViewName: string]: (node, editorView, getPos, decorations, innerDecorations) => NodeView
|
|
188
|
+
// }
|
|
189
|
+
// So the value of the keys on the nodeViews object, are a function which should return a NodeView.
|
|
190
|
+
// The following type NodeViewProducer, refers to these functions which return a NodeView.
|
|
191
|
+
//
|
|
192
|
+
// So the above type could also be described as
|
|
193
|
+
// type NodeViewProducer = (node, editorView, getPos, decorations, innerDecorations) => NodeView
|
|
194
|
+
// nodeViews: {
|
|
195
|
+
// [nodeViewName: string]: NodeViewProducer
|
|
196
|
+
// }
|
|
197
|
+
// This return of this function is intended to be the value of a key
|
|
198
|
+
// in a ProseMirror nodeViews object.
|
|
199
|
+
export function getInlineNodeViewProducer({
|
|
200
|
+
pmPluginFactoryParams,
|
|
201
|
+
Component,
|
|
202
|
+
extraComponentProps
|
|
203
|
+
}) {
|
|
204
|
+
function nodeViewProducer(...nodeViewProducerParameters) {
|
|
205
|
+
const nodeView = createNodeView({
|
|
206
|
+
nodeViewParams: {
|
|
207
|
+
node: nodeViewProducerParameters[0],
|
|
208
|
+
view: nodeViewProducerParameters[1],
|
|
209
|
+
getPos: nodeViewProducerParameters[2],
|
|
210
|
+
decorations: nodeViewProducerParameters[3]
|
|
211
|
+
},
|
|
212
|
+
pmPluginFactoryParams,
|
|
213
|
+
Component,
|
|
214
|
+
extraComponentProps
|
|
215
|
+
});
|
|
216
|
+
return nodeView;
|
|
217
|
+
}
|
|
218
|
+
return nodeViewProducer;
|
|
219
|
+
}
|
|
@@ -6,6 +6,7 @@ import { createDispatch } from '../event-dispatcher';
|
|
|
6
6
|
import { ErrorBoundary } from '../ui/ErrorBoundary';
|
|
7
7
|
import { getPerformanceOptions, startMeasureReactNodeViewRendered, stopMeasureReactNodeViewRendered } from '../utils';
|
|
8
8
|
import { analyticsEventKey } from '../utils/analytics';
|
|
9
|
+
export { getInlineNodeViewProducer, inlineNodeViewClassname } from './getInlineNodeViewProducer';
|
|
9
10
|
export default class ReactNodeView {
|
|
10
11
|
constructor(_node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, reactComponent, hasAnalyticsContext = false, viewShouldUpdate, hasIntlContext = false) {
|
|
11
12
|
_defineProperty(this, "handleRef", node => this._handleRef(node));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
3
|
import { Resizable } from 're-resizable';
|
|
4
|
-
import { resizerHandleLeftClassName, resizerHandlePadding, resizerHandlerClassName, resizerHandleRightClassName, resizerHandleStickyClassName, resizerHandleZIndex, resizerItemClassName } from '
|
|
4
|
+
import { resizerHandleLeftClassName, resizerHandlePadding, resizerHandlerClassName, resizerHandleRightClassName, resizerHandleStickyClassName, resizerHandleZIndex, resizerItemClassName } from '../styles/shared/resizer';
|
|
5
5
|
export default function ResizerNext(props) {
|
|
6
6
|
const resizable = React.useRef(null);
|
|
7
7
|
const {
|
|
@@ -9,7 +9,8 @@ export default function ResizerNext(props) {
|
|
|
9
9
|
handleResizeStart,
|
|
10
10
|
handleResizeStop,
|
|
11
11
|
handlerHeightSize = 'medium',
|
|
12
|
-
handleAlignmentMethod = 'center'
|
|
12
|
+
handleAlignmentMethod = 'center',
|
|
13
|
+
resizeRatio = 1
|
|
13
14
|
} = props;
|
|
14
15
|
const onResizeStart = React.useCallback(event => {
|
|
15
16
|
// prevent creating a drag event on Firefox
|
|
@@ -91,6 +92,7 @@ export default function ResizerNext(props) {
|
|
|
91
92
|
,
|
|
92
93
|
onResizeStart: onResizeStart,
|
|
93
94
|
onResize: onResize,
|
|
94
|
-
onResizeStop: onResizeStop
|
|
95
|
+
onResizeStop: onResizeStop,
|
|
96
|
+
resizeRatio: resizeRatio
|
|
95
97
|
}, props.children);
|
|
96
98
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ResizerNext } from './Resizer';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const snapTo = (target, points) => {
|
|
2
|
+
return points.length === 0 ?
|
|
3
|
+
// extreme last case if there are no points somehow
|
|
4
|
+
target : points.reduce((point, closest) => {
|
|
5
|
+
return Math.abs(closest - target) < Math.abs(point - target) ? closest : point;
|
|
6
|
+
});
|
|
7
|
+
};
|
|
8
|
+
export const handleSides = ['left', 'right'];
|
|
9
|
+
export const imageAlignmentMap = {
|
|
10
|
+
left: 'start',
|
|
11
|
+
right: 'end'
|
|
12
|
+
};
|
|
@@ -23,12 +23,9 @@ export const resizerHandlerClassName = {
|
|
|
23
23
|
large: resizerHandlerLargeClassName
|
|
24
24
|
};
|
|
25
25
|
export const resizerStyles = css`
|
|
26
|
-
.${resizerItemClassName} {
|
|
27
|
-
background: ${`var(--ds-border-focused, ${B200})`};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
26
|
.${resizerHandleRightClassName}, .${resizerHandleLeftClassName} {
|
|
31
27
|
display: flex;
|
|
28
|
+
visibility: hidden;
|
|
32
29
|
flex-direction: column;
|
|
33
30
|
justify-content: center;
|
|
34
31
|
}
|
|
@@ -51,6 +48,13 @@ export const resizerStyles = css`
|
|
|
51
48
|
border-radius: 6px;
|
|
52
49
|
}
|
|
53
50
|
|
|
51
|
+
.${resizerItemClassName}:hover
|
|
52
|
+
.${resizerHandleLeftClassName},
|
|
53
|
+
.${resizerItemClassName}:hover
|
|
54
|
+
.${resizerHandleRightClassName} {
|
|
55
|
+
visibility: visible;
|
|
56
|
+
}
|
|
57
|
+
|
|
54
58
|
.${resizerItemClassName}:hover
|
|
55
59
|
.${resizerHandleLeftClassName}::after,
|
|
56
60
|
.${resizerItemClassName}:hover
|
|
@@ -32,7 +32,8 @@ export const TableSharedCssClassName = {
|
|
|
32
32
|
TABLE_CELL_WRAPPER: tableCellSelector,
|
|
33
33
|
TABLE_HEADER_CELL_WRAPPER: tableHeaderSelector,
|
|
34
34
|
TABLE_ROW_CONTROLS_WRAPPER: `${tablePrefixSelector}-row-controls-wrapper`,
|
|
35
|
-
TABLE_COLUMN_CONTROLS_DECORATIONS: `${tablePrefixSelector}-column-controls-decoration
|
|
35
|
+
TABLE_COLUMN_CONTROLS_DECORATIONS: `${tablePrefixSelector}-column-controls-decoration`,
|
|
36
|
+
TABLE_RESIZER_CONTAINER: `${tablePrefixSelector}-resizer-container`
|
|
36
37
|
};
|
|
37
38
|
const tableSharedStyle = props => css`
|
|
38
39
|
${tableCellBackgroundStyleOverride()}
|
|
@@ -206,12 +207,12 @@ const tableSharedStyle = props => css`
|
|
|
206
207
|
export const calcTableWidth = (layout, containerWidth, addControllerPadding = true) => {
|
|
207
208
|
switch (layout) {
|
|
208
209
|
case 'full-width':
|
|
209
|
-
return containerWidth ?
|
|
210
|
+
return containerWidth ? Math.min(containerWidth - (addControllerPadding ? akEditorBreakoutPadding : 0), akEditorFullWidthLayoutWidth) : akEditorFullWidthLayoutWidth;
|
|
210
211
|
case 'wide':
|
|
211
212
|
if (containerWidth) {
|
|
212
|
-
return
|
|
213
|
+
return Math.min(containerWidth - (addControllerPadding ? akEditorBreakoutPadding : 0), akEditorWideLayoutWidth);
|
|
213
214
|
}
|
|
214
|
-
return
|
|
215
|
+
return akEditorWideLayoutWidth;
|
|
215
216
|
default:
|
|
216
217
|
return 'inherit';
|
|
217
218
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -8,7 +8,7 @@ import { themed } from '@atlaskit/theme/components';
|
|
|
8
8
|
import { borderRadius } from '@atlaskit/theme/constants';
|
|
9
9
|
import Layer from '../Layer';
|
|
10
10
|
const packageName = "@atlaskit/editor-common";
|
|
11
|
-
const packageVersion = "74.
|
|
11
|
+
const packageVersion = "74.7.0";
|
|
12
12
|
const halfFocusRing = 1;
|
|
13
13
|
const dropOffset = '0, 8';
|
|
14
14
|
class DropList extends Component {
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import { Resizable } from 're-resizable';
|
|
5
|
+
import { akRichMediaResizeZIndex } from '@atlaskit/editor-shared-styles';
|
|
6
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../../analytics';
|
|
7
|
+
import { richMediaClassName } from '../../styles';
|
|
8
|
+
import { gridTypeForLayout } from '../../utils';
|
|
9
|
+
import { handleSides, snapTo } from './utils';
|
|
10
|
+
const getResizeAnalyticsEvent = (type, size, layout) => {
|
|
11
|
+
const actionSubject = type === 'embed' ? ACTION_SUBJECT.EMBEDS : ACTION_SUBJECT.MEDIA_SINGLE;
|
|
12
|
+
return {
|
|
13
|
+
action: ACTION.EDITED,
|
|
14
|
+
actionSubject,
|
|
15
|
+
actionSubjectId: ACTION_SUBJECT_ID.RESIZED,
|
|
16
|
+
attributes: {
|
|
17
|
+
size,
|
|
18
|
+
layout
|
|
19
|
+
},
|
|
20
|
+
eventType: EVENT_TYPE.UI
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
const getWidthFromSnapPoints = (width, snapPoints) => {
|
|
24
|
+
if (snapPoints.length) {
|
|
25
|
+
return Math.min(Math.max(width, snapPoints[0]), snapPoints[snapPoints.length - 1]);
|
|
26
|
+
}
|
|
27
|
+
return width;
|
|
28
|
+
};
|
|
29
|
+
export default class Resizer extends React.Component {
|
|
30
|
+
constructor(...args) {
|
|
31
|
+
super(...args);
|
|
32
|
+
_defineProperty(this, "resizable", /*#__PURE__*/React.createRef());
|
|
33
|
+
_defineProperty(this, "state", {
|
|
34
|
+
isResizing: false
|
|
35
|
+
});
|
|
36
|
+
_defineProperty(this, "handleResizeStart", event => {
|
|
37
|
+
const {
|
|
38
|
+
innerPadding = 0,
|
|
39
|
+
highlights,
|
|
40
|
+
displayGrid,
|
|
41
|
+
layout,
|
|
42
|
+
width,
|
|
43
|
+
snapPoints
|
|
44
|
+
} = this.props;
|
|
45
|
+
|
|
46
|
+
// prevent creating a drag event on Firefox
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
this.setState({
|
|
49
|
+
isResizing: true
|
|
50
|
+
}, () => {
|
|
51
|
+
const newHighlights = highlights(width + innerPadding, snapPoints);
|
|
52
|
+
displayGrid === null || displayGrid === void 0 ? void 0 : displayGrid(newHighlights.length > 0, gridTypeForLayout(layout), newHighlights);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
_defineProperty(this, "handleResize", (_event, _direction, _elementRef, delta) => {
|
|
56
|
+
const {
|
|
57
|
+
highlights,
|
|
58
|
+
calcNewSize,
|
|
59
|
+
scaleFactor,
|
|
60
|
+
snapPoints,
|
|
61
|
+
displayGrid,
|
|
62
|
+
layout,
|
|
63
|
+
updateSize,
|
|
64
|
+
innerPadding = 0
|
|
65
|
+
} = this.props;
|
|
66
|
+
const resizable = this.resizable.current;
|
|
67
|
+
const {
|
|
68
|
+
isResizing
|
|
69
|
+
} = this.state;
|
|
70
|
+
if (!resizable || !resizable.state.original || !isResizing) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const newWidth = getWidthFromSnapPoints(resizable.state.original.width + delta.width * (scaleFactor || 1), snapPoints);
|
|
74
|
+
const newSize = calcNewSize(newWidth + innerPadding, false);
|
|
75
|
+
if (newSize.layout !== layout) {
|
|
76
|
+
updateSize(newSize.width, newSize.layout);
|
|
77
|
+
}
|
|
78
|
+
const newHighlights = highlights(newWidth, snapPoints);
|
|
79
|
+
displayGrid === null || displayGrid === void 0 ? void 0 : displayGrid(newHighlights.length > 0, gridTypeForLayout(newSize.layout), newHighlights);
|
|
80
|
+
resizable.updateSize({
|
|
81
|
+
width: newWidth,
|
|
82
|
+
height: 'auto'
|
|
83
|
+
});
|
|
84
|
+
resizable.setState({
|
|
85
|
+
isResizing: true
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
_defineProperty(this, "handleResizeStop", (_event, _direction, _elementRef, delta) => {
|
|
89
|
+
const {
|
|
90
|
+
highlights,
|
|
91
|
+
calcNewSize,
|
|
92
|
+
snapPoints,
|
|
93
|
+
displayGrid,
|
|
94
|
+
layout,
|
|
95
|
+
updateSize,
|
|
96
|
+
dispatchAnalyticsEvent,
|
|
97
|
+
nodeType
|
|
98
|
+
} = this.props;
|
|
99
|
+
const resizable = this.resizable.current;
|
|
100
|
+
const {
|
|
101
|
+
isResizing
|
|
102
|
+
} = this.state;
|
|
103
|
+
if (!resizable || !resizable.state.original || !isResizing) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const newWidth = getWidthFromSnapPoints(resizable.state.original.width + delta.width, snapPoints);
|
|
107
|
+
const snapWidth = snapTo(newWidth, snapPoints);
|
|
108
|
+
const newSize = calcNewSize(snapWidth, true);
|
|
109
|
+
const newHighlights = highlights(newWidth, snapPoints);
|
|
110
|
+
if (dispatchAnalyticsEvent) {
|
|
111
|
+
dispatchAnalyticsEvent(getResizeAnalyticsEvent(nodeType, newSize.width, newSize.layout));
|
|
112
|
+
}
|
|
113
|
+
// show committed grid size
|
|
114
|
+
displayGrid === null || displayGrid === void 0 ? void 0 : displayGrid(newHighlights.length > 0, gridTypeForLayout(newSize.layout), newHighlights);
|
|
115
|
+
this.setState({
|
|
116
|
+
isResizing: false
|
|
117
|
+
}, () => {
|
|
118
|
+
updateSize(newSize.width, newSize.layout);
|
|
119
|
+
displayGrid === null || displayGrid === void 0 ? void 0 : displayGrid(false, gridTypeForLayout(layout), []);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
render() {
|
|
124
|
+
const handleStyles = {};
|
|
125
|
+
const handles = {};
|
|
126
|
+
const handleComponent = {};
|
|
127
|
+
const {
|
|
128
|
+
innerPadding = 0,
|
|
129
|
+
width,
|
|
130
|
+
pctWidth,
|
|
131
|
+
selected,
|
|
132
|
+
layout,
|
|
133
|
+
enable,
|
|
134
|
+
children,
|
|
135
|
+
ratio,
|
|
136
|
+
handleComponentFunc
|
|
137
|
+
} = this.props;
|
|
138
|
+
const {
|
|
139
|
+
isResizing
|
|
140
|
+
} = this.state;
|
|
141
|
+
handleSides.forEach(side => {
|
|
142
|
+
handles[side] = `richMedia-resize-handle-${side}`;
|
|
143
|
+
handleStyles[side] = {
|
|
144
|
+
width: '24px',
|
|
145
|
+
[side]: `${-13 - innerPadding}px`,
|
|
146
|
+
zIndex: akRichMediaResizeZIndex,
|
|
147
|
+
pointerEvents: 'auto'
|
|
148
|
+
};
|
|
149
|
+
const sideHandleComponent = handleComponentFunc && handleComponentFunc(side);
|
|
150
|
+
if (sideHandleComponent) {
|
|
151
|
+
handleComponent[side] = sideHandleComponent;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
const className = classnames(richMediaClassName, `image-${layout}`, this.props.className, {
|
|
155
|
+
'is-resizing': isResizing,
|
|
156
|
+
'not-resized': !pctWidth,
|
|
157
|
+
'richMedia-selected': selected,
|
|
158
|
+
'rich-media-wrapped': layout === 'wrap-left' || layout === 'wrap-right'
|
|
159
|
+
});
|
|
160
|
+
let handleWrapperStyle;
|
|
161
|
+
if (ratio) {
|
|
162
|
+
handleWrapperStyle = {
|
|
163
|
+
position: 'absolute',
|
|
164
|
+
width: '100%',
|
|
165
|
+
paddingBottom: `${ratio}%`,
|
|
166
|
+
top: 0,
|
|
167
|
+
pointerEvents: 'none'
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Ideally, Resizable would let you pass in the component rather than
|
|
172
|
+
// the div. For now, we just apply the same styles using CSS
|
|
173
|
+
return /*#__PURE__*/React.createElement(Resizable, {
|
|
174
|
+
ref: this.resizable,
|
|
175
|
+
size: {
|
|
176
|
+
width,
|
|
177
|
+
// just content itself (no paddings)
|
|
178
|
+
height: 'auto'
|
|
179
|
+
},
|
|
180
|
+
className: className,
|
|
181
|
+
handleClasses: handles,
|
|
182
|
+
handleStyles: handleStyles,
|
|
183
|
+
handleWrapperStyle: handleWrapperStyle,
|
|
184
|
+
handleComponent: handleComponent,
|
|
185
|
+
enable: enable,
|
|
186
|
+
onResize: this.handleResize,
|
|
187
|
+
onResizeStop: this.handleResizeStop,
|
|
188
|
+
onResizeStart: this.handleResizeStart
|
|
189
|
+
}, children);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
import { MediaSingleDimensionHelper } from '../MediaSingle/styled';
|
|
3
|
+
export const wrapperStyle = props => css`
|
|
4
|
+
& > div {
|
|
5
|
+
${MediaSingleDimensionHelper(props)};
|
|
6
|
+
position: relative;
|
|
7
|
+
clear: both;
|
|
8
|
+
|
|
9
|
+
> div {
|
|
10
|
+
position: absolute;
|
|
11
|
+
height: 100%;
|
|
12
|
+
width: 100%;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const snapTo = (target, points) => {
|
|
2
|
+
return points.length === 0 ?
|
|
3
|
+
// extreme last case if there are no points somehow
|
|
4
|
+
target : points.reduce((point, closest) => {
|
|
5
|
+
return Math.abs(closest - target) < Math.abs(point - target) ? closest : point;
|
|
6
|
+
});
|
|
7
|
+
};
|
|
8
|
+
export const handleSides = ['left', 'right'];
|
|
9
|
+
export const imageAlignmentMap = {
|
|
10
|
+
left: 'start',
|
|
11
|
+
right: 'end'
|
|
12
|
+
};
|
package/dist/es2019/ui/index.js
CHANGED
|
@@ -18,4 +18,8 @@ export { clearNextSiblingMarginTopStyle, clearNextSiblingBlockMarkMarginTopStyle
|
|
|
18
18
|
export { IntlErrorBoundary, REACT_INTL_ERROR_MESSAGE } from './IntlErrorBoundary';
|
|
19
19
|
export { default as IntlProviderIfMissingWrapper } from './IntlProviderIfMissingWrapper';
|
|
20
20
|
export { default as FloatingToolbarButton } from './FloatingToolbar/Button';
|
|
21
|
-
export {
|
|
21
|
+
export { RECENT_SEARCH_WIDTH_IN_PX, RECENT_SEARCH_WIDTH_WITHOUT_ITEMS_IN_PX, RECENT_SEARCH_HEIGHT_IN_PX, LINKPICKER_HEIGHT_IN_PX } from './LinkSearch/const';
|
|
22
|
+
export { ContextPanelProvider, ContextPanelWidthProvider, ContextPanelConsumer, ContextPanel } from './ContextPanel/context';
|
|
23
|
+
export { default as Resizer } from './ResizerLegacy';
|
|
24
|
+
export { snapTo, handleSides, imageAlignmentMap } from './ResizerLegacy/utils';
|
|
25
|
+
export { wrapperStyle } from './ResizerLegacy/styled';
|