@atlaskit/editor-common 76.33.2 → 76.35.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 +54 -0
- package/dist/cjs/collab/index.js +27 -2
- package/dist/cjs/core-utils/document-logger.js +171 -0
- package/dist/cjs/core-utils/index.js +8 -1
- package/dist/cjs/extensibility/Extension/Extension/index.js +151 -0
- package/dist/cjs/extensibility/Extension/Extension/styles.js +17 -0
- package/dist/cjs/extensibility/Extension/InlineExtension/index.js +50 -0
- package/dist/cjs/extensibility/Extension/InlineExtension/styles.js +12 -0
- package/dist/cjs/extensibility/Extension/Lozenge.js +95 -0
- package/dist/cjs/extensibility/Extension/styles.js +30 -0
- package/dist/cjs/extensibility/Extension.js +79 -0
- package/dist/cjs/extensibility/ExtensionComponent.js +252 -0
- package/dist/cjs/extensibility/ExtensionNodeWrapper.js +21 -0
- package/dist/cjs/extensibility/MultiBodiedExtension/index.js +264 -0
- package/dist/cjs/extensibility/extensionNodeView.js +91 -0
- package/dist/cjs/extensibility/index.js +42 -0
- package/dist/cjs/extensibility/types.js +5 -0
- package/dist/cjs/media-inline/media-inline-image-card.js +24 -19
- package/dist/cjs/monitoring/error.js +3 -2
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/utils/index.js +7 -0
- package/dist/cjs/utils/insert-node-into-ordered-list.js +91 -0
- package/dist/es2019/collab/index.js +54 -1
- package/dist/es2019/core-utils/document-logger.js +161 -0
- package/dist/es2019/core-utils/index.js +2 -1
- package/dist/es2019/extensibility/Extension/Extension/index.js +155 -0
- package/dist/es2019/extensibility/Extension/Extension/styles.js +42 -0
- package/dist/es2019/extensibility/Extension/InlineExtension/index.js +26 -0
- package/dist/es2019/extensibility/Extension/InlineExtension/styles.js +26 -0
- package/dist/es2019/extensibility/Extension/Lozenge.js +71 -0
- package/dist/es2019/extensibility/Extension/styles.js +62 -0
- package/dist/es2019/extensibility/Extension.js +52 -0
- package/dist/es2019/extensibility/ExtensionComponent.js +204 -0
- package/dist/es2019/extensibility/ExtensionNodeWrapper.js +13 -0
- package/dist/es2019/extensibility/MultiBodiedExtension/index.js +283 -0
- package/dist/es2019/extensibility/extensionNodeView.js +62 -0
- package/dist/es2019/extensibility/index.js +4 -0
- package/dist/es2019/extensibility/types.js +1 -0
- package/dist/es2019/media-inline/media-inline-image-card.js +24 -19
- package/dist/es2019/monitoring/error.js +3 -2
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/utils/index.js +1 -0
- package/dist/es2019/utils/insert-node-into-ordered-list.js +84 -0
- package/dist/esm/collab/index.js +23 -1
- package/dist/esm/core-utils/document-logger.js +165 -0
- package/dist/esm/core-utils/index.js +2 -1
- package/dist/esm/extensibility/Extension/Extension/index.js +146 -0
- package/dist/esm/extensibility/Extension/Extension/styles.js +10 -0
- package/dist/esm/extensibility/Extension/InlineExtension/index.js +43 -0
- package/dist/esm/extensibility/Extension/InlineExtension/styles.js +5 -0
- package/dist/esm/extensibility/Extension/Lozenge.js +90 -0
- package/dist/esm/extensibility/Extension/styles.js +11 -0
- package/dist/esm/extensibility/Extension.js +69 -0
- package/dist/esm/extensibility/ExtensionComponent.js +243 -0
- package/dist/esm/extensibility/ExtensionNodeWrapper.js +14 -0
- package/dist/esm/extensibility/MultiBodiedExtension/index.js +257 -0
- package/dist/esm/extensibility/extensionNodeView.js +83 -0
- package/dist/esm/extensibility/index.js +4 -0
- package/dist/esm/extensibility/types.js +1 -0
- package/dist/esm/media-inline/media-inline-image-card.js +24 -19
- package/dist/esm/monitoring/error.js +3 -2
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/insert-node-into-ordered-list.js +84 -0
- package/dist/types/collab/index.d.ts +7 -0
- package/dist/types/core-utils/document-logger.d.ts +6 -0
- package/dist/types/core-utils/index.d.ts +1 -0
- package/dist/types/extensibility/Extension/Extension/index.d.ts +108 -0
- package/dist/types/extensibility/Extension/Extension/styles.d.ts +5 -0
- package/dist/types/extensibility/Extension/InlineExtension/index.d.ts +12 -0
- package/dist/types/extensibility/Extension/InlineExtension/styles.d.ts +1 -0
- package/dist/types/extensibility/Extension/Lozenge.d.ts +14 -0
- package/dist/types/extensibility/Extension/styles.d.ts +7 -0
- package/dist/types/extensibility/Extension.d.ts +29 -0
- package/dist/types/extensibility/ExtensionComponent.d.ts +53 -0
- package/dist/types/extensibility/ExtensionNodeWrapper.d.ts +14 -0
- package/dist/types/extensibility/MultiBodiedExtension/index.d.ts +26 -0
- package/dist/types/extensibility/extensionNodeView.d.ts +31 -0
- package/dist/types/extensibility/index.d.ts +4 -0
- package/dist/types/extensibility/types.d.ts +6 -0
- package/dist/types/extensions/types/extension-handler.d.ts +2 -0
- package/dist/types/media-inline/media-inline-image-card.d.ts +3 -2
- package/dist/types/media-inline/types.d.ts +6 -2
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/types/next-editor-plugin.d.ts +0 -1
- package/dist/types/ui/DropList/index.d.ts +1 -1
- package/dist/types/ui-menu/ColorPickerButton/index.d.ts +1 -1
- package/dist/types/ui-menu/ToolbarButton/index.d.ts +1 -1
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/insert-node-into-ordered-list.d.ts +3 -0
- package/dist/types-ts4.5/collab/index.d.ts +7 -0
- package/dist/types-ts4.5/core-utils/document-logger.d.ts +6 -0
- package/dist/types-ts4.5/core-utils/index.d.ts +1 -0
- package/dist/types-ts4.5/extensibility/Extension/Extension/index.d.ts +108 -0
- package/dist/types-ts4.5/extensibility/Extension/Extension/styles.d.ts +5 -0
- package/dist/types-ts4.5/extensibility/Extension/InlineExtension/index.d.ts +12 -0
- package/dist/types-ts4.5/extensibility/Extension/InlineExtension/styles.d.ts +1 -0
- package/dist/types-ts4.5/extensibility/Extension/Lozenge.d.ts +14 -0
- package/dist/types-ts4.5/extensibility/Extension/styles.d.ts +7 -0
- package/dist/types-ts4.5/extensibility/Extension.d.ts +29 -0
- package/dist/types-ts4.5/extensibility/ExtensionComponent.d.ts +53 -0
- package/dist/types-ts4.5/extensibility/ExtensionNodeWrapper.d.ts +14 -0
- package/dist/types-ts4.5/extensibility/MultiBodiedExtension/index.d.ts +26 -0
- package/dist/types-ts4.5/extensibility/extensionNodeView.d.ts +31 -0
- package/dist/types-ts4.5/extensibility/index.d.ts +4 -0
- package/dist/types-ts4.5/extensibility/types.d.ts +8 -0
- package/dist/types-ts4.5/extensions/types/extension-handler.d.ts +2 -0
- package/dist/types-ts4.5/media-inline/media-inline-image-card.d.ts +3 -2
- package/dist/types-ts4.5/media-inline/types.d.ts +6 -2
- package/dist/types-ts4.5/types/index.d.ts +1 -1
- package/dist/types-ts4.5/types/next-editor-plugin.d.ts +0 -3
- package/dist/types-ts4.5/ui/DropList/index.d.ts +1 -1
- package/dist/types-ts4.5/ui-menu/ColorPickerButton/index.d.ts +1 -1
- package/dist/types-ts4.5/ui-menu/ToolbarButton/index.d.ts +1 -1
- package/dist/types-ts4.5/utils/index.d.ts +1 -0
- package/dist/types-ts4.5/utils/insert-node-into-ordered-list.d.ts +3 -0
- package/extensibility/package.json +15 -0
- package/package.json +6 -5
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
|
|
4
|
+
import React, { useState } from 'react';
|
|
5
|
+
import { css, jsx } from '@emotion/react';
|
|
6
|
+
import { N30, N40, N50 } from '@atlaskit/theme/colors';
|
|
7
|
+
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '../../analytics';
|
|
8
|
+
import { createDispatch } from '../../event-dispatcher';
|
|
9
|
+
import { useSharedPluginState } from '../../hooks';
|
|
10
|
+
import { analyticsEventKey, calculateBreakoutStyles } from '../../utils';
|
|
11
|
+
import { WithPluginState } from '../../with-plugin-state';
|
|
12
|
+
const useMultiBodiedExtensionActions = ({
|
|
13
|
+
updateActiveChild,
|
|
14
|
+
editorView,
|
|
15
|
+
getPos,
|
|
16
|
+
node,
|
|
17
|
+
eventDispatcher
|
|
18
|
+
}) => {
|
|
19
|
+
const actions = React.useMemo(() => {
|
|
20
|
+
return {
|
|
21
|
+
changeActive(index) {
|
|
22
|
+
const updateActiveChildResult = updateActiveChild(index);
|
|
23
|
+
if (eventDispatcher) {
|
|
24
|
+
sendMBEAnalyticsEvent(ACTION.CHANGE_ACTIVE, node, eventDispatcher);
|
|
25
|
+
}
|
|
26
|
+
return updateActiveChildResult;
|
|
27
|
+
},
|
|
28
|
+
addChild() {
|
|
29
|
+
const {
|
|
30
|
+
state,
|
|
31
|
+
dispatch
|
|
32
|
+
} = editorView;
|
|
33
|
+
if (node.content.childCount >= node.attrs.maxFrames) {
|
|
34
|
+
throw new Error(`Cannot add more than ${node.attrs.maxFrames} frames`);
|
|
35
|
+
}
|
|
36
|
+
const p = state.schema.nodes.paragraph.createAndFill({});
|
|
37
|
+
if (!p) {
|
|
38
|
+
throw new Error('Could not create paragraph');
|
|
39
|
+
}
|
|
40
|
+
const frame = state.schema.nodes.extensionFrame.createAndFill({}, [p]);
|
|
41
|
+
const pos = getPos();
|
|
42
|
+
if (typeof pos !== 'number' || !frame) {
|
|
43
|
+
throw new Error('Could not create frame or position not valid');
|
|
44
|
+
}
|
|
45
|
+
const insertAt = Math.min((pos || 1) + node.content.size, state.doc.content.size);
|
|
46
|
+
dispatch(state.tr.insert(insertAt, frame));
|
|
47
|
+
if (eventDispatcher) {
|
|
48
|
+
sendMBEAnalyticsEvent(ACTION.ADD_CHILD, node, eventDispatcher);
|
|
49
|
+
}
|
|
50
|
+
return true;
|
|
51
|
+
},
|
|
52
|
+
getChildrenCount() {
|
|
53
|
+
return node.content.childCount;
|
|
54
|
+
},
|
|
55
|
+
removeChild(index) {
|
|
56
|
+
const pos = getPos();
|
|
57
|
+
// TODO: Add child index validation here, don't trust this data
|
|
58
|
+
if (typeof pos !== 'number' || typeof index !== 'number') {
|
|
59
|
+
throw new Error('Position or index not valid');
|
|
60
|
+
}
|
|
61
|
+
const {
|
|
62
|
+
state,
|
|
63
|
+
dispatch
|
|
64
|
+
} = editorView;
|
|
65
|
+
if (node.content.childCount === 1) {
|
|
66
|
+
const tr = state.tr;
|
|
67
|
+
tr.deleteRange(pos, pos + node.content.size);
|
|
68
|
+
dispatch(tr);
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
const $pos = state.doc.resolve(pos);
|
|
72
|
+
const $startNodePos = state.doc.resolve($pos.start($pos.depth + 1));
|
|
73
|
+
const startFramePosition = $startNodePos.posAtIndex(index);
|
|
74
|
+
const maybeFrameNode = state.doc.nodeAt(startFramePosition);
|
|
75
|
+
if (!maybeFrameNode) {
|
|
76
|
+
throw new Error('Could not find frame node');
|
|
77
|
+
}
|
|
78
|
+
const endFramePosition = maybeFrameNode.content.size + startFramePosition;
|
|
79
|
+
const tr = state.tr;
|
|
80
|
+
tr.deleteRange(startFramePosition, endFramePosition);
|
|
81
|
+
dispatch(tr);
|
|
82
|
+
if (eventDispatcher) {
|
|
83
|
+
sendMBEAnalyticsEvent(ACTION.REMOVE_CHILD, node, eventDispatcher);
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
},
|
|
87
|
+
updateParameters(parameters) {
|
|
88
|
+
const {
|
|
89
|
+
state,
|
|
90
|
+
dispatch
|
|
91
|
+
} = editorView;
|
|
92
|
+
const pos = getPos();
|
|
93
|
+
if (typeof pos !== 'number') {
|
|
94
|
+
throw new Error('Position not valid');
|
|
95
|
+
}
|
|
96
|
+
const tr = state.tr.setNodeMarkup(pos, undefined, {
|
|
97
|
+
...node.attrs,
|
|
98
|
+
parameters: {
|
|
99
|
+
...node.attrs.parameters,
|
|
100
|
+
macroParams: parameters
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
dispatch(tr);
|
|
104
|
+
if (eventDispatcher) {
|
|
105
|
+
sendMBEAnalyticsEvent(ACTION.UPDATE_PARAMETERS, node, eventDispatcher);
|
|
106
|
+
}
|
|
107
|
+
return true;
|
|
108
|
+
},
|
|
109
|
+
getChildren() {
|
|
110
|
+
var _state$doc$nodeAt;
|
|
111
|
+
const {
|
|
112
|
+
state
|
|
113
|
+
} = editorView;
|
|
114
|
+
const pos = getPos();
|
|
115
|
+
if (typeof pos !== 'number') {
|
|
116
|
+
return [];
|
|
117
|
+
}
|
|
118
|
+
const children = (_state$doc$nodeAt = state.doc.nodeAt(pos)) === null || _state$doc$nodeAt === void 0 ? void 0 : _state$doc$nodeAt.content;
|
|
119
|
+
if (eventDispatcher) {
|
|
120
|
+
sendMBEAnalyticsEvent(ACTION.GET_CHILDERN, node, eventDispatcher);
|
|
121
|
+
}
|
|
122
|
+
return children ? children.toJSON() : [];
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}, [node, editorView, getPos, updateActiveChild, eventDispatcher]);
|
|
126
|
+
return actions;
|
|
127
|
+
};
|
|
128
|
+
const navigationCSS = css`
|
|
129
|
+
// make sure the user can't see a range selection inside the navigation
|
|
130
|
+
// This is really important to keep the navigation working properly
|
|
131
|
+
user-select: none;
|
|
132
|
+
-webkit-user-modify: read-only;
|
|
133
|
+
border: 1px solid ${`var(--ds-border, ${N40})`};
|
|
134
|
+
`;
|
|
135
|
+
const MultiBodiedExtensionWithWidth = ({
|
|
136
|
+
node,
|
|
137
|
+
handleContentDOMRef,
|
|
138
|
+
getPos,
|
|
139
|
+
tryExtensionHandler,
|
|
140
|
+
editorView,
|
|
141
|
+
eventDispatcher,
|
|
142
|
+
widthState,
|
|
143
|
+
editorAppearance
|
|
144
|
+
}) => {
|
|
145
|
+
const [activeChildIndex, setActiveChildIndex] = useState(0);
|
|
146
|
+
// Adding to avoid aliasing `this` for the callbacks
|
|
147
|
+
const updateActiveChild = React.useCallback(index => {
|
|
148
|
+
if (typeof index !== 'number') {
|
|
149
|
+
setActiveChildIndex(0);
|
|
150
|
+
throw new Error('Index is not valid');
|
|
151
|
+
}
|
|
152
|
+
setActiveChildIndex(index);
|
|
153
|
+
return true;
|
|
154
|
+
}, [setActiveChildIndex]);
|
|
155
|
+
const actions = useMultiBodiedExtensionActions({
|
|
156
|
+
updateActiveChild,
|
|
157
|
+
editorView,
|
|
158
|
+
getPos,
|
|
159
|
+
eventDispatcher,
|
|
160
|
+
node
|
|
161
|
+
});
|
|
162
|
+
const extensionHandlerResult = React.useMemo(() => {
|
|
163
|
+
return tryExtensionHandler(actions);
|
|
164
|
+
}, [tryExtensionHandler, actions]);
|
|
165
|
+
const articleRef = React.useCallback(node => {
|
|
166
|
+
return handleContentDOMRef(node);
|
|
167
|
+
}, [handleContentDOMRef]);
|
|
168
|
+
const containerCSS = css`
|
|
169
|
+
border: 1px solid ${`var(--ds-border, ${N30})`};
|
|
170
|
+
min-height: 100px;
|
|
171
|
+
.multiBodiedExtension-content-dom-wrapper > [data-extension-frame='true'] {
|
|
172
|
+
display: none;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.multiBodiedExtension-content-dom-wrapper
|
|
176
|
+
> [data-extension-frame='true']:nth-of-type(${activeChildIndex + 1}) {
|
|
177
|
+
border: 1px solid ${`var(--ds-border, ${N50})`};
|
|
178
|
+
display: block;
|
|
179
|
+
min-height: 100px;
|
|
180
|
+
}
|
|
181
|
+
`;
|
|
182
|
+
const shouldBreakout =
|
|
183
|
+
// Extension should breakout when the layout is set to 'full-width' or 'wide'.
|
|
184
|
+
['full-width', 'wide'].includes(node.attrs.layout) &&
|
|
185
|
+
// Extension breakout state should not be respected when the editor appearance is full-width mode
|
|
186
|
+
editorAppearance !== 'full-width';
|
|
187
|
+
let mbeContainerStyles = {};
|
|
188
|
+
if (shouldBreakout) {
|
|
189
|
+
const {
|
|
190
|
+
...breakoutStyles
|
|
191
|
+
} = calculateBreakoutStyles({
|
|
192
|
+
mode: node.attrs.layout,
|
|
193
|
+
widthStateLineLength: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength,
|
|
194
|
+
widthStateWidth: widthState === null || widthState === void 0 ? void 0 : widthState.width
|
|
195
|
+
});
|
|
196
|
+
mbeContainerStyles = breakoutStyles;
|
|
197
|
+
}
|
|
198
|
+
return jsx("section", {
|
|
199
|
+
className: "multiBodiedExtension--container",
|
|
200
|
+
css: containerCSS,
|
|
201
|
+
"data-testid": "multiBodiedExtension--container",
|
|
202
|
+
"data-active-child-index": activeChildIndex,
|
|
203
|
+
style: mbeContainerStyles
|
|
204
|
+
}, jsx("nav", {
|
|
205
|
+
className: "multiBodiedExtension-navigation",
|
|
206
|
+
css: navigationCSS,
|
|
207
|
+
"data-testid": "multiBodiedExtension-navigation"
|
|
208
|
+
}, extensionHandlerResult), jsx("article", {
|
|
209
|
+
className: "multiBodiedExtension--frames",
|
|
210
|
+
"data-testid": "multiBodiedExtension--frames",
|
|
211
|
+
ref: articleRef
|
|
212
|
+
}));
|
|
213
|
+
};
|
|
214
|
+
const sendMBEAnalyticsEvent = (action, node, eventDispatcher) => {
|
|
215
|
+
const analyticsDispatch = createDispatch(eventDispatcher);
|
|
216
|
+
analyticsDispatch(analyticsEventKey, {
|
|
217
|
+
payload: {
|
|
218
|
+
action,
|
|
219
|
+
actionSubject: ACTION_SUBJECT.MULTI_BODIED_EXTENSION,
|
|
220
|
+
eventType: EVENT_TYPE.TRACK,
|
|
221
|
+
attributes: {
|
|
222
|
+
extensionType: node.attrs.extensionType,
|
|
223
|
+
extensionKey: node.attrs.extensionKey,
|
|
224
|
+
localId: node.attrs.localId,
|
|
225
|
+
maxFramesCount: node.attrs.maxFrames,
|
|
226
|
+
currentFramesCount: node.content.childCount
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
const MultiBodiedExtensionWithSharedState = props => {
|
|
232
|
+
const {
|
|
233
|
+
pluginInjectionApi
|
|
234
|
+
} = props;
|
|
235
|
+
const {
|
|
236
|
+
widthState
|
|
237
|
+
} = useSharedPluginState(pluginInjectionApi, ['width']);
|
|
238
|
+
return jsx(MultiBodiedExtensionWithWidth, _extends({
|
|
239
|
+
widthState: widthState
|
|
240
|
+
}, props));
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
// Workaround taken from platform/packages/editor/editor-core/src/plugins/extension/ui/Extension/Extension/index.tsx
|
|
244
|
+
const MultiBodiedExtension = props => {
|
|
245
|
+
// TODO: ED-17836 This code is here because confluence injects
|
|
246
|
+
// the `editor-referentiality` plugin via `dangerouslyAppendPlugins`
|
|
247
|
+
// which cannot access the `pluginInjectionApi`. When we move
|
|
248
|
+
// Confluence to using presets we can remove this workaround.
|
|
249
|
+
const {
|
|
250
|
+
pluginInjectionApi
|
|
251
|
+
} = props;
|
|
252
|
+
return pluginInjectionApi === undefined ? jsx(MultiBodiedExtensionDeprecated, props) : jsx(MultiBodiedExtensionWithSharedState, props);
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
// TODO: ED-17836 This code is here because Confluence injects
|
|
256
|
+
// the `editor-referentiality` plugin via `dangerouslyAppendPlugins`
|
|
257
|
+
// which cannot access the `pluginInjectionApi`. When we move
|
|
258
|
+
// Confluence to using presets we can remove this workaround.
|
|
259
|
+
// @ts-ignore
|
|
260
|
+
const widthPluginKey = {
|
|
261
|
+
key: 'widthPlugin$',
|
|
262
|
+
getState: state => {
|
|
263
|
+
return state['widthPlugin$'];
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
const MultiBodiedExtensionDeprecated = props => {
|
|
267
|
+
return jsx(WithPluginState, {
|
|
268
|
+
editorView: props.editorView,
|
|
269
|
+
plugins: {
|
|
270
|
+
widthState: widthPluginKey
|
|
271
|
+
},
|
|
272
|
+
render: ({
|
|
273
|
+
widthState
|
|
274
|
+
}) => jsx(MultiBodiedExtensionWithWidth, _extends({
|
|
275
|
+
widthState: widthState
|
|
276
|
+
}, props))
|
|
277
|
+
});
|
|
278
|
+
};
|
|
279
|
+
/**
|
|
280
|
+
* End workaround
|
|
281
|
+
*/
|
|
282
|
+
|
|
283
|
+
export default MultiBodiedExtension;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactNodeView from '../react-node-view';
|
|
3
|
+
import { Extension } from './Extension';
|
|
4
|
+
import { ExtensionNodeWrapper } from './ExtensionNodeWrapper';
|
|
5
|
+
// getInlineNodeViewProducer is a new api to use instead of ReactNodeView
|
|
6
|
+
// when creating inline node views, however, it is difficult to test the impact
|
|
7
|
+
// on selections when migrating inlineExtension to use the new api.
|
|
8
|
+
// The ReactNodeView api will be visited in the second phase of the selections
|
|
9
|
+
// project whilst investigating block nodes. We will revisit the Extension node view there too.
|
|
10
|
+
export class ExtensionNode extends ReactNodeView {
|
|
11
|
+
ignoreMutation(mutation) {
|
|
12
|
+
// Extensions can perform async operations that will change the DOM.
|
|
13
|
+
// To avoid having their tree rebuilt, we need to ignore the mutation
|
|
14
|
+
// for atom based extensions if its not a layout, we need to give
|
|
15
|
+
// children a chance to recalc
|
|
16
|
+
return this.node.type.isAtom || mutation.type !== 'selection' && mutation.attributeName !== 'data-layout';
|
|
17
|
+
}
|
|
18
|
+
getContentDOM() {
|
|
19
|
+
if (this.node.isInline) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const dom = document.createElement('div');
|
|
23
|
+
dom.className = `${this.node.type.name}-content-dom-wrapper`;
|
|
24
|
+
return {
|
|
25
|
+
dom
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
render(props, forwardRef) {
|
|
29
|
+
var _props$extensionNodeV;
|
|
30
|
+
return /*#__PURE__*/React.createElement(ExtensionNodeWrapper, {
|
|
31
|
+
nodeType: this.node.type.name
|
|
32
|
+
}, /*#__PURE__*/React.createElement(Extension, {
|
|
33
|
+
editorView: this.view,
|
|
34
|
+
node: this.node,
|
|
35
|
+
eventDispatcher: this.eventDispatcher
|
|
36
|
+
// The getPos arg is always a function when used with nodes
|
|
37
|
+
// the version of the types we use has a union with the type
|
|
38
|
+
// for marks.
|
|
39
|
+
// This has been fixed in later versions of the definitly typed
|
|
40
|
+
// types (and also in prosmirror-views inbuilt types).
|
|
41
|
+
// https://github.com/DefinitelyTyped/DefinitelyTyped/pull/57384
|
|
42
|
+
,
|
|
43
|
+
getPos: this.getPos,
|
|
44
|
+
providerFactory: props.providerFactory,
|
|
45
|
+
handleContentDOMRef: forwardRef,
|
|
46
|
+
extensionHandlers: props.extensionHandlers,
|
|
47
|
+
editorAppearance: (_props$extensionNodeV = props.extensionNodeViewOptions) === null || _props$extensionNodeV === void 0 ? void 0 : _props$extensionNodeV.appearance,
|
|
48
|
+
pluginInjectionApi: props.pluginInjectionApi
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export default function ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi) {
|
|
53
|
+
return (node, view, getPos) => {
|
|
54
|
+
const hasIntlContext = true;
|
|
55
|
+
return new ExtensionNode(node, view, getPos, portalProviderAPI, eventDispatcher, {
|
|
56
|
+
providerFactory,
|
|
57
|
+
extensionHandlers,
|
|
58
|
+
extensionNodeViewOptions,
|
|
59
|
+
pluginInjectionApi
|
|
60
|
+
}, undefined, undefined, undefined, hasIntlContext).init();
|
|
61
|
+
};
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -18,7 +18,8 @@ export const MediaInlineImageCardInternal = ({
|
|
|
18
18
|
isLazy,
|
|
19
19
|
width,
|
|
20
20
|
height,
|
|
21
|
-
border
|
|
21
|
+
border,
|
|
22
|
+
ssr
|
|
22
23
|
}) => {
|
|
23
24
|
const [fileState, setFileState] = useState();
|
|
24
25
|
const [subscribeError, setSubscribeError] = useState();
|
|
@@ -28,21 +29,23 @@ export const MediaInlineImageCardInternal = ({
|
|
|
28
29
|
locale: 'en'
|
|
29
30
|
});
|
|
30
31
|
useEffect(() => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
32
|
+
if (mediaClient) {
|
|
33
|
+
const subscription = mediaClient.file.getFileState(identifier.id, {
|
|
34
|
+
collectionName: identifier.collectionName
|
|
35
|
+
}).subscribe({
|
|
36
|
+
next: fileState => {
|
|
37
|
+
setFileState(fileState);
|
|
38
|
+
setSubscribeError(undefined);
|
|
39
|
+
},
|
|
40
|
+
error: e => {
|
|
41
|
+
setSubscribeError(e);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return () => {
|
|
45
|
+
subscription.unsubscribe();
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}, [identifier, mediaClient]);
|
|
46
49
|
const content = dimensions => {
|
|
47
50
|
if (subscribeError) {
|
|
48
51
|
const isUploading = (fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'uploading';
|
|
@@ -67,25 +70,27 @@ export const MediaInlineImageCardInternal = ({
|
|
|
67
70
|
message: formatMessage(messages.unableToLoadContent)
|
|
68
71
|
});
|
|
69
72
|
}
|
|
73
|
+
const mediaClientConfig = (ssr === null || ssr === void 0 ? void 0 : ssr.config) || (mediaClient === null || mediaClient === void 0 ? void 0 : mediaClient.mediaClientConfig);
|
|
70
74
|
if (!fileState) {
|
|
71
75
|
return jsx(InlineImageCardLoadingView, null);
|
|
72
76
|
}
|
|
73
77
|
return jsx(Card, {
|
|
74
|
-
mediaClientConfig:
|
|
78
|
+
mediaClientConfig: mediaClientConfig,
|
|
75
79
|
isLazy: isLazy,
|
|
76
80
|
identifier: identifier,
|
|
77
81
|
dimensions: dimensions,
|
|
78
82
|
selectable: true,
|
|
79
83
|
disableOverlay: true,
|
|
80
84
|
selected: isSelected,
|
|
81
|
-
alt: alt
|
|
85
|
+
alt: alt,
|
|
86
|
+
ssr: ssr === null || ssr === void 0 ? void 0 : ssr.mode
|
|
82
87
|
});
|
|
83
88
|
};
|
|
84
89
|
const aspectRatio = useMemo(() => width && height ? width / height : undefined, [width, height]);
|
|
85
90
|
|
|
86
91
|
/**
|
|
87
92
|
* scaledDimensions is used to define the correct media size fetched from media service
|
|
88
|
-
* inline images will only ever be
|
|
93
|
+
* inline images will only ever be rendered at a maximum height of H1 and so scaled dimensions
|
|
89
94
|
* will only ever return a width and height where the height has a maximum height of H1
|
|
90
95
|
*/
|
|
91
96
|
const scaledDimension = useMemo(() => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
2
2
|
const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
3
|
-
const packageVersion = "76.
|
|
3
|
+
const packageVersion = "76.35.0";
|
|
4
4
|
const sanitiseSentryEvents = (data, _hint) => {
|
|
5
5
|
// Remove URL as it has UGC
|
|
6
6
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -50,13 +50,14 @@ export const logException = async (error, tags) => {
|
|
|
50
50
|
const hub = getCurrentHub();
|
|
51
51
|
hub.bindClient(client);
|
|
52
52
|
hub.withScope(scope => {
|
|
53
|
+
var _buildInfo;
|
|
53
54
|
scope.setTags({
|
|
54
55
|
// Jira environment variables
|
|
55
56
|
'jira-bundler': window.BUNDLER_VERSION,
|
|
56
57
|
'jira-variant': window.BUILD_VARIANT,
|
|
57
58
|
'jira-release': window.BUILD_KEY,
|
|
58
59
|
// Confluence environment variables
|
|
59
|
-
'confluence-frontend-version': window.__buildInfo.FRONTEND_VERSION,
|
|
60
|
+
'confluence-frontend-version': (_buildInfo = window.__buildInfo) === null || _buildInfo === void 0 ? void 0 : _buildInfo.FRONTEND_VERSION,
|
|
60
61
|
...tags
|
|
61
62
|
});
|
|
62
63
|
// Explicitly remove the breadcrumbs as it's too likely to log UGC/PII to side-step the hub integrations not being respected
|
|
@@ -7,7 +7,7 @@ import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@
|
|
|
7
7
|
import { N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
|
|
8
8
|
import Layer from '../Layer';
|
|
9
9
|
const packageName = "@atlaskit/editor-common";
|
|
10
|
-
const packageVersion = "76.
|
|
10
|
+
const packageVersion = "76.35.0";
|
|
11
11
|
const halfFocusRing = 1;
|
|
12
12
|
const dropOffset = '0, 8';
|
|
13
13
|
class DropList extends Component {
|
|
@@ -213,6 +213,7 @@ export function isInEmptyLine(state) {
|
|
|
213
213
|
}
|
|
214
214
|
export { dedupe } from './dedupe';
|
|
215
215
|
export { createWrapSelectionTransaction } from './create-wrap-selection-transaction';
|
|
216
|
+
export { transformNodeIntoListItem } from './insert-node-into-ordered-list';
|
|
216
217
|
export { wrapSelectionIn } from './wrap-selection-in';
|
|
217
218
|
export { toJSON, nodeToJSON } from './nodes';
|
|
218
219
|
export { calculateToolbarPositionAboveSelection, calculateToolbarPositionTrackHead } from './calculate-toolbar-position';
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { findParentNodeOfType, findParentNodeOfTypeClosestToPos, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
2
|
+
import { isListNode } from './list';
|
|
3
|
+
export function transformNodeIntoListItem(tr, node) {
|
|
4
|
+
var _tr$doc$nodeAt, _findParentNodeOfType;
|
|
5
|
+
const {
|
|
6
|
+
$to,
|
|
7
|
+
$from,
|
|
8
|
+
to,
|
|
9
|
+
from
|
|
10
|
+
} = tr.selection;
|
|
11
|
+
const {
|
|
12
|
+
orderedList,
|
|
13
|
+
bulletList,
|
|
14
|
+
listItem
|
|
15
|
+
} = tr.doc.type.schema.nodes;
|
|
16
|
+
const startLinePosition = $from.start();
|
|
17
|
+
const parentStartPosition = $from.depth === 0 ? 0 : $from.before();
|
|
18
|
+
|
|
19
|
+
// Setting the start position
|
|
20
|
+
const startMapped = startLinePosition === from ? parentStartPosition : from;
|
|
21
|
+
|
|
22
|
+
// Selected nodes
|
|
23
|
+
const selectionParentListItemNode = findParentNodeOfType(listItem)(tr.selection);
|
|
24
|
+
const selectionParentListNodeWithPos = findParentNodeOfType([bulletList, orderedList])(tr.selection);
|
|
25
|
+
const selectionParentListNode = selectionParentListNodeWithPos === null || selectionParentListNodeWithPos === void 0 ? void 0 : selectionParentListNodeWithPos.node;
|
|
26
|
+
if (!selectionParentListNodeWithPos) {
|
|
27
|
+
return tr;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Offsets
|
|
31
|
+
const listWrappingOffset = $to.depth - selectionParentListNodeWithPos.depth + 1; // difference in depth between to position and list node
|
|
32
|
+
const listItemWrappingOffset = $to.depth - selectionParentListNodeWithPos.depth; // difference in depth between to position and list item node
|
|
33
|
+
|
|
34
|
+
// Anything to do with nested lists should safeInsert and not be handled here
|
|
35
|
+
const grandParentListNode = findParentNodeOfTypeClosestToPos(tr.doc.resolve(selectionParentListNodeWithPos.pos), [bulletList, orderedList]);
|
|
36
|
+
const selectionIsInNestedList = !!grandParentListNode;
|
|
37
|
+
let selectedListItemHasNestedList = false;
|
|
38
|
+
selectionParentListItemNode === null || selectionParentListItemNode === void 0 ? void 0 : selectionParentListItemNode.node.content.forEach(child => {
|
|
39
|
+
if (isListNode(child)) {
|
|
40
|
+
selectedListItemHasNestedList = true;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
if (selectedListItemHasNestedList || selectionIsInNestedList) {
|
|
44
|
+
return safeInsert(node)(tr).scrollIntoView();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Check if node after the insert position is listItem
|
|
48
|
+
const isNodeAfterInsertPositionIsListItem = ((_tr$doc$nodeAt = tr.doc.nodeAt(to + listItemWrappingOffset)) === null || _tr$doc$nodeAt === void 0 ? void 0 : _tr$doc$nodeAt.type) === listItem;
|
|
49
|
+
let replaceTo;
|
|
50
|
+
if (isNodeAfterInsertPositionIsListItem) {
|
|
51
|
+
replaceTo = to + listItemWrappingOffset;
|
|
52
|
+
} else if (!isNodeAfterInsertPositionIsListItem) {
|
|
53
|
+
replaceTo = to;
|
|
54
|
+
} else {
|
|
55
|
+
replaceTo = to + listWrappingOffset;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// handle the insertion of the slice
|
|
59
|
+
tr.replaceWith(startMapped, replaceTo, node).scrollIntoView();
|
|
60
|
+
|
|
61
|
+
// Get the next list items position (used later to find the split out ordered list)
|
|
62
|
+
const indexOfNextListItem = $to.indexAfter($to.depth - listItemWrappingOffset);
|
|
63
|
+
const positionOfNextListItem = tr.doc.resolve(selectionParentListNodeWithPos.pos + 1).posAtIndex(indexOfNextListItem);
|
|
64
|
+
|
|
65
|
+
// Find the ordered list node after the pasted content so we can set it's order
|
|
66
|
+
const mappedPositionOfNextListItem = tr.mapping.map(positionOfNextListItem);
|
|
67
|
+
if (mappedPositionOfNextListItem > tr.doc.nodeSize) {
|
|
68
|
+
return tr;
|
|
69
|
+
}
|
|
70
|
+
const nodeAfterPastedContentResolvedPos = findParentNodeOfTypeClosestToPos(tr.doc.resolve(mappedPositionOfNextListItem), [orderedList]);
|
|
71
|
+
|
|
72
|
+
// Work out the new split out lists 'order' (the number it starts from)
|
|
73
|
+
const originalParentOrderedListNodeOrder = selectionParentListNode === null || selectionParentListNode === void 0 ? void 0 : selectionParentListNode.attrs.order;
|
|
74
|
+
const numOfListItemsInOriginalList = (_findParentNodeOfType = findParentNodeOfTypeClosestToPos(tr.doc.resolve(from - 1), [orderedList])) === null || _findParentNodeOfType === void 0 ? void 0 : _findParentNodeOfType.node.childCount;
|
|
75
|
+
|
|
76
|
+
// Set the new split out lists order attribute
|
|
77
|
+
if (typeof originalParentOrderedListNodeOrder === 'number' && numOfListItemsInOriginalList && nodeAfterPastedContentResolvedPos) {
|
|
78
|
+
tr.setNodeMarkup(nodeAfterPastedContentResolvedPos.pos, orderedList, {
|
|
79
|
+
...nodeAfterPastedContentResolvedPos.node.attrs,
|
|
80
|
+
order: originalParentOrderedListNodeOrder + numOfListItemsInOriginalList
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return tr;
|
|
84
|
+
}
|
package/dist/esm/collab/index.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject;
|
|
3
|
+
import { css } from '@emotion/react';
|
|
4
|
+
import { hexToRgba } from '@atlaskit/adf-schema';
|
|
5
|
+
import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
|
|
6
|
+
import * as themeColors from '@atlaskit/theme/colors';
|
|
7
|
+
|
|
1
8
|
// Format of the payload returned by the callback function passed to the collab provider
|
|
2
9
|
// that gets called when syncing with the back-end service fails.
|
|
3
10
|
// Format of the document and its metadata returned from the collab provider
|
|
@@ -118,4 +125,19 @@ export var DisconnectReason = /*#__PURE__*/function (DisconnectReason) {
|
|
|
118
125
|
DisconnectReason["SOCKET_TIMEOUT"] = "SOCKET_TIMEOUT";
|
|
119
126
|
DisconnectReason["UNKNOWN_DISCONNECT"] = "UNKNOWN_DISCONNECT";
|
|
120
127
|
return DisconnectReason;
|
|
121
|
-
}({});
|
|
128
|
+
}({});
|
|
129
|
+
// TODO: https://product-fabric.atlassian.net/browse/DSP-7269
|
|
130
|
+
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
131
|
+
export var colors = [themeColors.R100, themeColors.R300, themeColors.R500, themeColors.Y100, themeColors.Y300, themeColors.Y500, themeColors.G100, themeColors.G300, themeColors.G500, themeColors.T100, themeColors.T300, themeColors.T500, themeColors.B100, themeColors.B300, themeColors.B500, themeColors.P100, themeColors.P300, themeColors.P500, themeColors.N70, themeColors.N200, themeColors.N800].map(function (solid) {
|
|
132
|
+
return {
|
|
133
|
+
solid: solid,
|
|
134
|
+
selection: hexToRgba(solid, 0.2)
|
|
135
|
+
};
|
|
136
|
+
});
|
|
137
|
+
var telepointerColorStyle = function telepointerColorStyle(color, index) {
|
|
138
|
+
return "\n &.color-".concat(index, " {\n background-color: ").concat(color.selection, ";\n &::after {\n background-color: ").concat(color.solid, ";\n color: ", "var(--ds-text-inverse, #fff)", ";\n border-color: ").concat(color.solid, ";\n }\n }\n");
|
|
139
|
+
};
|
|
140
|
+
export var TELEPOINTER_DIM_CLASS = 'telepointer-dim';
|
|
141
|
+
export var telepointerStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ProseMirror .telepointer {\n position: relative;\n transition: opacity 200ms;\n\n &.telepointer-selection {\n line-height: 1.2;\n pointer-events: none;\n user-select: none;\n }\n\n &.telepointer-selection-badge::after {\n content: attr(data-initial);\n position: absolute;\n display: block;\n top: -14px;\n font-size: ", ";\n padding: ", ";\n color: ", ";\n left: -1px;\n border-radius: 2px 2px 2px 0;\n line-height: initial;\n }\n\n &.", " {\n opacity: 0.2;\n }\n\n ", ";\n }\n"])), relativeFontSizeToBase16(9), "var(--ds-space-025, 2px)", "var(--ds-text-inverse, white)", TELEPOINTER_DIM_CLASS, colors.map(function (color, index) {
|
|
142
|
+
return telepointerColorStyle(color, index);
|
|
143
|
+
}));
|