@atlaskit/editor-core 185.3.0 → 185.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/cjs/plugins/card/nodeviews/blockCard.js +6 -2
- package/dist/cjs/plugins/card/nodeviews/inlineCard.js +7 -2
- package/dist/cjs/plugins/date/nodeviews/date.js +2 -1
- package/dist/cjs/plugins/expand/nodeviews/index.js +41 -10
- package/dist/cjs/plugins/extension/ui/Extension/Extension/index.js +2 -1
- package/dist/cjs/plugins/media/commands/captions.js +3 -0
- package/dist/cjs/plugins/media/commands/helpers.js +3 -3
- package/dist/cjs/plugins/media/nodeviews/mediaGroup.js +35 -4
- package/dist/cjs/plugins/media/nodeviews/mediaNodeUpdater.js +25 -11
- package/dist/cjs/plugins/media/nodeviews/mediaNodeView/media.js +5 -1
- package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +8 -1
- package/dist/cjs/plugins/media/pm-plugins/main.js +5 -1
- package/dist/cjs/plugins/media/utils/media-common.js +3 -0
- package/dist/cjs/plugins/placeholder-text/placeholder-text-nodeview.js +7 -1
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +8 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/card/nodeviews/blockCard.js +11 -5
- package/dist/es2019/plugins/card/nodeviews/inlineCard.js +12 -5
- package/dist/es2019/plugins/date/nodeviews/date.js +2 -1
- package/dist/es2019/plugins/expand/nodeviews/index.js +41 -10
- package/dist/es2019/plugins/extension/ui/Extension/Extension/index.js +2 -1
- package/dist/es2019/plugins/media/commands/captions.js +3 -0
- package/dist/es2019/plugins/media/commands/helpers.js +3 -3
- package/dist/es2019/plugins/media/nodeviews/mediaGroup.js +39 -4
- package/dist/es2019/plugins/media/nodeviews/mediaNodeUpdater.js +10 -2
- package/dist/es2019/plugins/media/nodeviews/mediaNodeView/media.js +5 -1
- package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +8 -1
- package/dist/es2019/plugins/media/pm-plugins/main.js +5 -1
- package/dist/es2019/plugins/media/utils/media-common.js +3 -0
- package/dist/es2019/plugins/placeholder-text/placeholder-text-nodeview.js +7 -1
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +8 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/card/nodeviews/blockCard.js +6 -2
- package/dist/esm/plugins/card/nodeviews/inlineCard.js +7 -2
- package/dist/esm/plugins/date/nodeviews/date.js +2 -1
- package/dist/esm/plugins/expand/nodeviews/index.js +41 -10
- package/dist/esm/plugins/extension/ui/Extension/Extension/index.js +2 -1
- package/dist/esm/plugins/media/commands/captions.js +3 -0
- package/dist/esm/plugins/media/commands/helpers.js +3 -3
- package/dist/esm/plugins/media/nodeviews/mediaGroup.js +35 -4
- package/dist/esm/plugins/media/nodeviews/mediaNodeUpdater.js +25 -11
- package/dist/esm/plugins/media/nodeviews/mediaNodeView/media.js +5 -1
- package/dist/esm/plugins/media/nodeviews/mediaSingle.js +8 -1
- package/dist/esm/plugins/media/pm-plugins/main.js +5 -1
- package/dist/esm/plugins/media/utils/media-common.js +3 -0
- package/dist/esm/plugins/placeholder-text/placeholder-text-nodeview.js +7 -1
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +8 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/nodeviews/types.d.ts +2 -2
- package/dist/types/plugins/expand/nodeviews/index.d.ts +0 -1
- package/dist/types/plugins/media/commands/captions.d.ts +1 -1
- package/dist/types/plugins/media/nodeviews/mediaGroup.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/types.d.ts +2 -2
- package/dist/types-ts4.5/plugins/expand/nodeviews/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/media/commands/captions.d.ts +1 -1
- package/dist/types-ts4.5/plugins/media/nodeviews/mediaGroup.d.ts +1 -1
- package/package.json +1 -1
- package/report.api.md +2 -2
- package/tmp/api-report-tmp.d.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -47,10 +47,14 @@ var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
47
47
|
// don't dispatch immediately since we might be in the middle of
|
|
48
48
|
// rendering a nodeview
|
|
49
49
|
(0, _rafSchd.default)(function () {
|
|
50
|
-
|
|
50
|
+
var pos = getPos();
|
|
51
|
+
if (typeof pos !== 'number') {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
view.dispatch((0, _actions.registerCard)({
|
|
51
55
|
title: title,
|
|
52
56
|
url: url,
|
|
53
|
-
pos:
|
|
57
|
+
pos: pos
|
|
54
58
|
})(view.state.tr));
|
|
55
59
|
})();
|
|
56
60
|
});
|
|
@@ -45,10 +45,15 @@ var InlineCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
45
45
|
// don't dispatch immediately since we might be in the middle of
|
|
46
46
|
// rendering a nodeview
|
|
47
47
|
(0, _rafSchd.default)(function () {
|
|
48
|
-
|
|
48
|
+
// prosemirror-bump-fix
|
|
49
|
+
var pos = getPos();
|
|
50
|
+
if (typeof pos !== 'number') {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
view.dispatch((0, _actions.registerCard)({
|
|
49
54
|
title: title,
|
|
50
55
|
url: url,
|
|
51
|
-
pos:
|
|
56
|
+
pos: pos
|
|
52
57
|
})(view.state.tr));
|
|
53
58
|
})();
|
|
54
59
|
});
|
|
@@ -19,10 +19,11 @@ function DateNodeView(props) {
|
|
|
19
19
|
selection = _props$view$state.selection,
|
|
20
20
|
getPos = props.getPos;
|
|
21
21
|
var intl = (0, _reactIntlNext.useIntl)();
|
|
22
|
+
var pos = typeof getPos === 'function' ? getPos() : undefined;
|
|
22
23
|
|
|
23
24
|
// We fall back to selection.$from even though it does not cover all use cases
|
|
24
25
|
// eg. upon Editor init, selection is at the start, not at the Date node
|
|
25
|
-
var $nodePos = typeof
|
|
26
|
+
var $nodePos = typeof pos === 'number' ? doc.resolve(pos) : selection.$from;
|
|
26
27
|
var parent = $nodePos.parent;
|
|
27
28
|
var withinIncompleteTask = parent.type === schema.nodes.taskItem && parent.attrs.state !== 'DONE';
|
|
28
29
|
var color = withinIncompleteTask && (0, _utils.isPastDate)(timestamp) ? 'red' : undefined;
|
|
@@ -92,6 +92,10 @@ var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
92
92
|
return _this.featureFlags && !!_this.featureFlags.interactiveExpand;
|
|
93
93
|
});
|
|
94
94
|
(0, _defineProperty2.default)(this, "handleClick", function (event) {
|
|
95
|
+
var pos = _this.getPos();
|
|
96
|
+
if (typeof pos !== 'number') {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
95
99
|
var target = event.target;
|
|
96
100
|
var _this$view2 = _this.view,
|
|
97
101
|
state = _this$view2.state,
|
|
@@ -107,7 +111,7 @@ var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
107
111
|
if (_this.view.dom instanceof HTMLElement) {
|
|
108
112
|
_this.view.dom.blur();
|
|
109
113
|
}
|
|
110
|
-
(0, _commands.toggleExpandExpanded)(
|
|
114
|
+
(0, _commands.toggleExpandExpanded)(pos, _this.node.type)(state, dispatch);
|
|
111
115
|
return;
|
|
112
116
|
}
|
|
113
117
|
if (target === _this.input) {
|
|
@@ -117,13 +121,17 @@ var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
117
121
|
}
|
|
118
122
|
});
|
|
119
123
|
(0, _defineProperty2.default)(this, "handleInput", function (event) {
|
|
124
|
+
var pos = _this.getPos();
|
|
125
|
+
if (typeof pos !== 'number') {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
120
128
|
var target = event.target;
|
|
121
129
|
if (target === _this.input) {
|
|
122
130
|
event.stopPropagation();
|
|
123
131
|
var _this$view3 = _this.view,
|
|
124
132
|
state = _this$view3.state,
|
|
125
133
|
dispatch = _this$view3.dispatch;
|
|
126
|
-
(0, _commands.updateExpandTitle)(target.value,
|
|
134
|
+
(0, _commands.updateExpandTitle)(target.value, pos, _this.node.type)(state, dispatch);
|
|
127
135
|
}
|
|
128
136
|
});
|
|
129
137
|
(0, _defineProperty2.default)(this, "handleFocus", function (event) {
|
|
@@ -156,6 +164,10 @@ var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
156
164
|
if (!_this.input) {
|
|
157
165
|
return;
|
|
158
166
|
}
|
|
167
|
+
var pos = _this.getPos();
|
|
168
|
+
if (typeof pos !== 'number') {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
159
171
|
var _this$input = _this.input,
|
|
160
172
|
selectionStart = _this$input.selectionStart,
|
|
161
173
|
selectionEnd = _this$input.selectionEnd;
|
|
@@ -165,15 +177,19 @@ var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
165
177
|
var state = _this.view.state;
|
|
166
178
|
var expandNode = _this.node;
|
|
167
179
|
if (expandNode && (0, _utils.isEmptyNode)(state.schema)(expandNode)) {
|
|
168
|
-
(0, _commands.deleteExpandAtPos)(
|
|
180
|
+
(0, _commands.deleteExpandAtPos)(pos, expandNode)(state, _this.view.dispatch);
|
|
169
181
|
}
|
|
170
182
|
});
|
|
171
183
|
(0, _defineProperty2.default)(this, "toggleExpand", function () {
|
|
184
|
+
var pos = _this.getPos();
|
|
185
|
+
if (typeof pos !== 'number') {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
172
188
|
if (_this.isAllowInteractiveExpandEnabled()) {
|
|
173
189
|
var _this$view4 = _this.view,
|
|
174
190
|
state = _this$view4.state,
|
|
175
191
|
dispatch = _this$view4.dispatch;
|
|
176
|
-
(0, _commands.toggleExpandExpanded)(
|
|
192
|
+
(0, _commands.toggleExpandExpanded)(pos, _this.node.type)(state, dispatch);
|
|
177
193
|
}
|
|
178
194
|
});
|
|
179
195
|
(0, _defineProperty2.default)(this, "moveToOutsideOfTitle", function (event) {
|
|
@@ -211,6 +227,10 @@ var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
211
227
|
if (!_this.input) {
|
|
212
228
|
return;
|
|
213
229
|
}
|
|
230
|
+
var pos = _this.getPos();
|
|
231
|
+
if (typeof pos !== 'number') {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
214
234
|
var _this$input2 = _this.input,
|
|
215
235
|
value = _this$input2.value,
|
|
216
236
|
selectionStart = _this$input2.selectionStart,
|
|
@@ -221,13 +241,17 @@ var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
221
241
|
dispatch = _this$view6.dispatch;
|
|
222
242
|
event.preventDefault();
|
|
223
243
|
_this.view.focus();
|
|
224
|
-
dispatch(state.tr.setSelection(new _gapCursorSelection.GapCursorSelection(state.doc.resolve(_this.node.nodeSize +
|
|
244
|
+
dispatch(state.tr.setSelection(new _gapCursorSelection.GapCursorSelection(state.doc.resolve(_this.node.nodeSize + pos), _gapCursorSelection.Side.RIGHT)));
|
|
225
245
|
}
|
|
226
246
|
});
|
|
227
247
|
(0, _defineProperty2.default)(this, "setLeftGapCursor", function (event) {
|
|
228
248
|
if (!_this.input) {
|
|
229
249
|
return;
|
|
230
250
|
}
|
|
251
|
+
var pos = _this.getPos();
|
|
252
|
+
if (typeof pos !== 'number') {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
231
255
|
var _this$input3 = _this.input,
|
|
232
256
|
selectionStart = _this$input3.selectionStart,
|
|
233
257
|
selectionEnd = _this$input3.selectionEnd;
|
|
@@ -237,13 +261,17 @@ var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
237
261
|
state = _this$view7.state,
|
|
238
262
|
dispatch = _this$view7.dispatch;
|
|
239
263
|
_this.view.focus();
|
|
240
|
-
dispatch(state.tr.setSelection(new _gapCursorSelection.GapCursorSelection(state.doc.resolve(
|
|
264
|
+
dispatch(state.tr.setSelection(new _gapCursorSelection.GapCursorSelection(state.doc.resolve(pos), _gapCursorSelection.Side.LEFT)));
|
|
241
265
|
}
|
|
242
266
|
});
|
|
243
267
|
(0, _defineProperty2.default)(this, "handleArrowRightFromTitle", function (event) {
|
|
244
268
|
if (!_this.input) {
|
|
245
269
|
return;
|
|
246
270
|
}
|
|
271
|
+
var pos = _this.getPos();
|
|
272
|
+
if (typeof pos !== 'number') {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
247
275
|
var _this$input4 = _this.input,
|
|
248
276
|
value = _this$input4.value,
|
|
249
277
|
selectionStart = _this$input4.selectionStart,
|
|
@@ -254,13 +282,17 @@ var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
254
282
|
state = _this$view8.state,
|
|
255
283
|
dispatch = _this$view8.dispatch;
|
|
256
284
|
_this.view.focus();
|
|
257
|
-
(0, _commands2.setSelectionRelativeToNode)(_types.RelativeSelectionPos.End, _prosemirrorState.NodeSelection.create(state.doc,
|
|
285
|
+
(0, _commands2.setSelectionRelativeToNode)(_types.RelativeSelectionPos.End, _prosemirrorState.NodeSelection.create(state.doc, pos))(state, dispatch);
|
|
258
286
|
}
|
|
259
287
|
});
|
|
260
288
|
(0, _defineProperty2.default)(this, "handleArrowLeftFromTitle", function (event) {
|
|
261
289
|
if (!_this.input) {
|
|
262
290
|
return;
|
|
263
291
|
}
|
|
292
|
+
var pos = _this.getPos();
|
|
293
|
+
if (typeof pos !== 'number') {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
264
296
|
var _this$input5 = _this.input,
|
|
265
297
|
selectionStart = _this$input5.selectionStart,
|
|
266
298
|
selectionEnd = _this$input5.selectionEnd;
|
|
@@ -274,9 +306,9 @@ var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
274
306
|
// selectionRelativeToNode is undefined when user clicked to select node, then hit left to get focus in title
|
|
275
307
|
// This is a special case where we want to bypass node selection and jump straight to gap cursor
|
|
276
308
|
if ((0, _pluginFactory.getPluginState)(state).selectionRelativeToNode === undefined) {
|
|
277
|
-
(0, _commands2.setSelectionRelativeToNode)(undefined, new _gapCursorSelection.GapCursorSelection(state.doc.resolve(
|
|
309
|
+
(0, _commands2.setSelectionRelativeToNode)(undefined, new _gapCursorSelection.GapCursorSelection(state.doc.resolve(pos), _gapCursorSelection.Side.LEFT))(state, dispatch);
|
|
278
310
|
} else {
|
|
279
|
-
(0, _commands2.setSelectionRelativeToNode)(_types.RelativeSelectionPos.Start, _prosemirrorState.NodeSelection.create(state.doc,
|
|
311
|
+
(0, _commands2.setSelectionRelativeToNode)(_types.RelativeSelectionPos.Start, _prosemirrorState.NodeSelection.create(state.doc, pos))(state, dispatch);
|
|
280
312
|
}
|
|
281
313
|
}
|
|
282
314
|
});
|
|
@@ -285,7 +317,6 @@ var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
285
317
|
dom = _DOMSerializer$render.dom,
|
|
286
318
|
contentDOM = _DOMSerializer$render.contentDOM;
|
|
287
319
|
this.getPos = getPos;
|
|
288
|
-
this.pos = getPos();
|
|
289
320
|
this.view = view;
|
|
290
321
|
this.node = node;
|
|
291
322
|
this.dom = dom;
|
|
@@ -38,7 +38,8 @@ function ExtensionWithPluginState(props) {
|
|
|
38
38
|
var isMobile = editorAppearance === 'mobile';
|
|
39
39
|
var hasChildren = !!children;
|
|
40
40
|
var removeBorder = hideFrame && !isMobile && !hasBody || false;
|
|
41
|
-
var
|
|
41
|
+
var pos = typeof props.getPos === 'function' ? props.getPos() : undefined;
|
|
42
|
+
var isTopLevelNode = typeof pos !== 'undefined' && !isNaN(pos) && props.view.state.doc.resolve(pos).depth === 0;
|
|
42
43
|
var shouldBreakout =
|
|
43
44
|
// Extension should breakout when the layout is set to 'full-width' or 'wide'.
|
|
44
45
|
['full-width', 'wide'].includes(node.attrs.layout) &&
|
|
@@ -26,6 +26,9 @@ var selectCaptionFromMediaSinglePos = function selectCaptionFromMediaSinglePos(m
|
|
|
26
26
|
exports.selectCaptionFromMediaSinglePos = selectCaptionFromMediaSinglePos;
|
|
27
27
|
var insertAndSelectCaptionFromMediaSinglePos = function insertAndSelectCaptionFromMediaSinglePos(mediaSingleNodePos, mediaSingleNode) {
|
|
28
28
|
return function (state, dispatch) {
|
|
29
|
+
if (typeof mediaSingleNodePos !== 'number') {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
29
32
|
var tr = state.tr;
|
|
30
33
|
|
|
31
34
|
// node should have one child, media
|
|
@@ -51,7 +51,7 @@ var updateAllMediaSingleNodesAttrs = function updateAllMediaSingleNodesAttrs(id,
|
|
|
51
51
|
var validMediaNodePositions = mediaNodes.reduce(function (acc, _ref) {
|
|
52
52
|
var getPos = _ref.getPos;
|
|
53
53
|
var pos = getPos();
|
|
54
|
-
if (isNaN(pos) || typeof pos === 'number' && !isMediaNode(pos, state)) {
|
|
54
|
+
if (typeof pos !== 'number' || isNaN(pos) || typeof pos === 'number' && !isMediaNode(pos, state)) {
|
|
55
55
|
return acc;
|
|
56
56
|
}
|
|
57
57
|
acc.push(pos);
|
|
@@ -75,7 +75,7 @@ exports.updateAllMediaSingleNodesAttrs = updateAllMediaSingleNodesAttrs;
|
|
|
75
75
|
var updateCurrentMediaNodeAttrs = function updateCurrentMediaNodeAttrs(attrs, mediaNode) {
|
|
76
76
|
return function (state, dispatch) {
|
|
77
77
|
var pos = mediaNode.getPos();
|
|
78
|
-
if (isNaN(pos) || typeof pos === 'number' && !isMediaNode(pos, state)) {
|
|
78
|
+
if (typeof pos !== 'number' || isNaN(pos) || typeof pos === 'number' && !isMediaNode(pos, state)) {
|
|
79
79
|
return false;
|
|
80
80
|
}
|
|
81
81
|
var tr = state.tr;
|
|
@@ -97,7 +97,7 @@ var updateMediaSingleNodeAttrs = function updateMediaSingleNodeAttrs(id, attrs)
|
|
|
97
97
|
}
|
|
98
98
|
var tr = state.tr;
|
|
99
99
|
var pos = mediaNodeWithPos.getPos();
|
|
100
|
-
if (!isMediaNode(pos, state)) {
|
|
100
|
+
if (typeof pos !== 'number' || !isMediaNode(pos, state)) {
|
|
101
101
|
return false;
|
|
102
102
|
}
|
|
103
103
|
tr.step(new _steps.SetAttrsStep(pos, attrs)).setMeta('addToHistory', false);
|
|
@@ -32,7 +32,11 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
32
32
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
33
33
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
34
34
|
var isMediaGroupSelectedFromProps = function isMediaGroupSelectedFromProps(props) {
|
|
35
|
-
|
|
35
|
+
var pos = props.getPos();
|
|
36
|
+
if (typeof pos !== 'number') {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return (0, _nodes.isNodeSelectedOrInRange)(props.anchorPos, props.headPos, pos, props.node.nodeSize);
|
|
36
40
|
};
|
|
37
41
|
var hasSelectionChanged = function hasSelectionChanged(oldProps, newProps) {
|
|
38
42
|
if (isMediaGroupSelectedFromProps(oldProps) !== isMediaGroupSelectedFromProps(newProps)) {
|
|
@@ -73,7 +77,16 @@ var MediaGroup = /*#__PURE__*/function (_React$Component) {
|
|
|
73
77
|
_this.mediaNodes = [];
|
|
74
78
|
node.forEach(function (item, childOffset) {
|
|
75
79
|
var getPos = function getPos() {
|
|
76
|
-
|
|
80
|
+
var pos = props.getPos();
|
|
81
|
+
if (typeof pos !== 'number') {
|
|
82
|
+
// That may seems weird, but the previous type wasn't match with the real ProseMirror code. And a lot of Media API was built expecting a number
|
|
83
|
+
// Because the original code would return NaN on runtime
|
|
84
|
+
// We are just make it explict now.
|
|
85
|
+
// We may run a deep investagation on Media code to figure out a better fix. But, for now, we want to keep the current behavior.
|
|
86
|
+
// TODO: ED-13910 prosemirror-bump leftovers
|
|
87
|
+
return NaN;
|
|
88
|
+
}
|
|
89
|
+
return pos + childOffset + 1;
|
|
77
90
|
};
|
|
78
91
|
_this.mediaNodes.push(item);
|
|
79
92
|
if (updatedAttrs) {
|
|
@@ -115,7 +128,16 @@ var MediaGroup = /*#__PURE__*/function (_React$Component) {
|
|
|
115
128
|
var items = _this.mediaNodes.map(function (item, idx) {
|
|
116
129
|
// We declared this to get a fresh position every time
|
|
117
130
|
var getNodePos = function getNodePos() {
|
|
118
|
-
|
|
131
|
+
var pos = getPos();
|
|
132
|
+
if (typeof pos !== 'number') {
|
|
133
|
+
// That may seems weird, but the previous type wasn't match with the real ProseMirror code. And a lot of Media API was built expecting a number
|
|
134
|
+
// Because the original code would return NaN on runtime
|
|
135
|
+
// We are just make it explict now.
|
|
136
|
+
// We may run a deep investagation on Media code to figure out a better fix. But, for now, we want to keep the current behavior.
|
|
137
|
+
// TODO: ED-13910 prosemirror-bump leftovers
|
|
138
|
+
return NaN;
|
|
139
|
+
}
|
|
140
|
+
return pos + idx + 1;
|
|
119
141
|
};
|
|
120
142
|
|
|
121
143
|
// Media Inline creates a floating toolbar with the same options, excludes these options if enabled
|
|
@@ -182,7 +204,16 @@ var MediaGroup = /*#__PURE__*/function (_React$Component) {
|
|
|
182
204
|
isMediaSingle: false
|
|
183
205
|
});
|
|
184
206
|
getPos = function getPos() {
|
|
185
|
-
|
|
207
|
+
var pos = _this2.props.getPos();
|
|
208
|
+
if (typeof pos !== 'number') {
|
|
209
|
+
// That may seems weird, but the previous type wasn't match with the real ProseMirror code. And a lot of Media API was built expecting a number
|
|
210
|
+
// Because the original code would return NaN on runtime
|
|
211
|
+
// We are just make it explict now.
|
|
212
|
+
// We may run a deep investagation on Media code to figure out a better fix. But, for now, we want to keep the current behavior.
|
|
213
|
+
// TODO: ED-13910 prosemirror-bump leftovers
|
|
214
|
+
return NaN;
|
|
215
|
+
}
|
|
216
|
+
return pos + 1;
|
|
186
217
|
};
|
|
187
218
|
contextId = mediaNodeUpdater.getNodeContextId();
|
|
188
219
|
if (contextId) {
|
|
@@ -223,7 +223,7 @@ var MediaNodeUpdater = /*#__PURE__*/function () {
|
|
|
223
223
|
})));
|
|
224
224
|
(0, _defineProperty2.default)(this, "uploadExternalMedia", /*#__PURE__*/function () {
|
|
225
225
|
var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(getPos) {
|
|
226
|
-
var node, mediaProvider, uploadMediaClientConfig, mediaClient, collection, uploader, uploadableFileUpfrontIds, dimensions;
|
|
226
|
+
var node, mediaProvider, uploadMediaClientConfig, mediaClient, collection, uploader, uploadableFileUpfrontIds, dimensions, pos;
|
|
227
227
|
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
228
228
|
while (1) switch (_context7.prev = _context7.next) {
|
|
229
229
|
case 0:
|
|
@@ -233,7 +233,7 @@ var MediaNodeUpdater = /*#__PURE__*/function () {
|
|
|
233
233
|
case 3:
|
|
234
234
|
mediaProvider = _context7.sent;
|
|
235
235
|
if (!(node && mediaProvider)) {
|
|
236
|
-
_context7.next =
|
|
236
|
+
_context7.next = 24;
|
|
237
237
|
break;
|
|
238
238
|
}
|
|
239
239
|
uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig;
|
|
@@ -251,17 +251,24 @@ var MediaNodeUpdater = /*#__PURE__*/function () {
|
|
|
251
251
|
case 13:
|
|
252
252
|
uploader = _context7.sent;
|
|
253
253
|
uploadableFileUpfrontIds = uploader.uploadableFileUpfrontIds, dimensions = uploader.dimensions;
|
|
254
|
-
|
|
254
|
+
pos = getPos();
|
|
255
|
+
if (!(typeof pos !== 'number')) {
|
|
256
|
+
_context7.next = 18;
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
return _context7.abrupt("return");
|
|
260
|
+
case 18:
|
|
261
|
+
(0, _helpers.replaceExternalMedia)(pos + 1, {
|
|
255
262
|
id: uploadableFileUpfrontIds.id,
|
|
256
263
|
collection: collection,
|
|
257
264
|
height: dimensions.height,
|
|
258
265
|
width: dimensions.width,
|
|
259
266
|
occurrenceKey: uploadableFileUpfrontIds.occurrenceKey
|
|
260
267
|
})(_this.props.view.state, _this.props.view.dispatch);
|
|
261
|
-
_context7.next =
|
|
268
|
+
_context7.next = 24;
|
|
262
269
|
break;
|
|
263
|
-
case
|
|
264
|
-
_context7.prev =
|
|
270
|
+
case 21:
|
|
271
|
+
_context7.prev = 21;
|
|
265
272
|
_context7.t0 = _context7["catch"](10);
|
|
266
273
|
//keep it as external media
|
|
267
274
|
if (_this.props.dispatchAnalyticsEvent) {
|
|
@@ -271,11 +278,11 @@ var MediaNodeUpdater = /*#__PURE__*/function () {
|
|
|
271
278
|
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
272
279
|
});
|
|
273
280
|
}
|
|
274
|
-
case
|
|
281
|
+
case 24:
|
|
275
282
|
case "end":
|
|
276
283
|
return _context7.stop();
|
|
277
284
|
}
|
|
278
|
-
}, _callee7, null, [[10,
|
|
285
|
+
}, _callee7, null, [[10, 21]]);
|
|
279
286
|
}));
|
|
280
287
|
return function (_x3) {
|
|
281
288
|
return _ref8.apply(this, arguments);
|
|
@@ -367,7 +374,7 @@ var MediaNodeUpdater = /*#__PURE__*/function () {
|
|
|
367
374
|
})));
|
|
368
375
|
(0, _defineProperty2.default)(this, "copyNodeFromBlobUrl", /*#__PURE__*/function () {
|
|
369
376
|
var _ref11 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(getPos) {
|
|
370
|
-
var attrs, url, mediaAttrs, mediaProvider, currentCollectionName, contextId, id, collection, height, width, mimeType, name, size, uploadMediaClientConfig, mediaClient, auth, source, destination, mediaFile;
|
|
377
|
+
var attrs, url, mediaAttrs, mediaProvider, currentCollectionName, contextId, id, collection, height, width, mimeType, name, size, uploadMediaClientConfig, mediaClient, auth, source, destination, mediaFile, pos;
|
|
371
378
|
return _regenerator.default.wrap(function _callee10$(_context10) {
|
|
372
379
|
while (1) switch (_context10.prev = _context10.next) {
|
|
373
380
|
case 0:
|
|
@@ -426,7 +433,14 @@ var MediaNodeUpdater = /*#__PURE__*/function () {
|
|
|
426
433
|
return mediaClient.file.copyFile(source, destination);
|
|
427
434
|
case 25:
|
|
428
435
|
mediaFile = _context10.sent;
|
|
429
|
-
|
|
436
|
+
pos = getPos();
|
|
437
|
+
if (!(typeof pos !== 'number')) {
|
|
438
|
+
_context10.next = 29;
|
|
439
|
+
break;
|
|
440
|
+
}
|
|
441
|
+
return _context10.abrupt("return");
|
|
442
|
+
case 29:
|
|
443
|
+
(0, _helpers.replaceExternalMedia)(pos + 1, {
|
|
430
444
|
id: mediaFile.id,
|
|
431
445
|
collection: currentCollectionName,
|
|
432
446
|
height: height,
|
|
@@ -435,7 +449,7 @@ var MediaNodeUpdater = /*#__PURE__*/function () {
|
|
|
435
449
|
__fileMimeType: mimeType,
|
|
436
450
|
__fileSize: size
|
|
437
451
|
})(_this.props.view.state, _this.props.view.dispatch);
|
|
438
|
-
case
|
|
452
|
+
case 30:
|
|
439
453
|
case "end":
|
|
440
454
|
return _context10.stop();
|
|
441
455
|
}
|
|
@@ -67,10 +67,14 @@ var MediaNode = /*#__PURE__*/function (_Component) {
|
|
|
67
67
|
_this.selectMediaSingle(event);
|
|
68
68
|
});
|
|
69
69
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "selectMediaSingle", function (event) {
|
|
70
|
+
var propPos = _this.props.getPos();
|
|
71
|
+
if (typeof propPos !== 'number') {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
70
75
|
// We need to call "stopPropagation" here in order to prevent the browser from navigating to
|
|
71
76
|
// another URL if the media node is wrapped in a link mark.
|
|
72
77
|
event.stopPropagation();
|
|
73
|
-
var propPos = _this.props.getPos();
|
|
74
78
|
var state = _this.props.view.state;
|
|
75
79
|
if (event.shiftKey) {
|
|
76
80
|
// don't select text if there is current selection in a table (as this would override selected cells)
|
|
@@ -177,10 +177,14 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
177
177
|
}());
|
|
178
178
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "selectMediaSingle", function (_ref3) {
|
|
179
179
|
var event = _ref3.event;
|
|
180
|
+
var propPos = _this.props.getPos();
|
|
181
|
+
if (typeof propPos !== 'number') {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
|
|
180
185
|
// We need to call "stopPropagation" here in order to prevent the browser from navigating to
|
|
181
186
|
// another URL if the media node is wrapped in a link mark.
|
|
182
187
|
event.stopPropagation();
|
|
183
|
-
var propPos = _this.props.getPos();
|
|
184
188
|
var state = _this.props.view.state;
|
|
185
189
|
if (event.shiftKey) {
|
|
186
190
|
// don't select text if there is current selection in a table (as this would override selected cells)
|
|
@@ -252,6 +256,9 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
252
256
|
(0, _captions.insertAndSelectCaptionFromMediaSinglePos)(getPos(), node)(view.state, view.dispatch);
|
|
253
257
|
});
|
|
254
258
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getLineLength", function (view, pos) {
|
|
259
|
+
if (typeof pos !== 'number') {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
255
262
|
if ((0, _utils.isRichMediaInsideOfBlockNode)(view, pos)) {
|
|
256
263
|
var $pos = view.state.doc.resolve(pos);
|
|
257
264
|
var domNode = view.nodeDOM($pos.pos);
|
|
@@ -308,7 +308,11 @@ var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
308
308
|
(0, _defineProperty2.default)(this, "handleMediaNodeRemoval", function (node, getPos) {
|
|
309
309
|
var getNode = node;
|
|
310
310
|
if (!getNode) {
|
|
311
|
-
|
|
311
|
+
var pos = getPos();
|
|
312
|
+
if (typeof pos !== 'number') {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
getNode = _this.view.state.doc.nodeAt(pos);
|
|
312
316
|
}
|
|
313
317
|
(0, _mediaCommon.removeMediaNode)(_this.view, getNode, getPos);
|
|
314
318
|
});
|
|
@@ -124,6 +124,9 @@ var removeMediaNode = function removeMediaNode(view, node, getPos) {
|
|
|
124
124
|
selection = state.selection,
|
|
125
125
|
doc = state.doc;
|
|
126
126
|
var currentMediaNodePos = getPos();
|
|
127
|
+
if (typeof currentMediaNodePos !== 'number') {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
127
130
|
tr.deleteRange(currentMediaNodePos, currentMediaNodePos + node.nodeSize);
|
|
128
131
|
if ((0, _utils.isTemporary)(id)) {
|
|
129
132
|
tr.setMeta('addToHistory', false);
|
|
@@ -47,6 +47,9 @@ var PlaceholderTextNodeView = /*#__PURE__*/function () {
|
|
|
47
47
|
e.preventDefault();
|
|
48
48
|
var _view = this.view;
|
|
49
49
|
var startNodePosition = this.getPos();
|
|
50
|
+
if (typeof startNodePosition !== 'number') {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
50
53
|
var tr = _view.state.tr;
|
|
51
54
|
tr.setSelection(_prosemirrorState.Selection.near(tr.doc.resolve(startNodePosition)));
|
|
52
55
|
_view.dispatch(tr);
|
|
@@ -63,7 +66,10 @@ var PlaceholderTextNodeView = /*#__PURE__*/function () {
|
|
|
63
66
|
var view = this.view,
|
|
64
67
|
node = this.node;
|
|
65
68
|
var placeholderStartPosition = this.getPos();
|
|
66
|
-
|
|
69
|
+
if (typeof placeholderStartPosition !== 'number') {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
var placeholderEndPosition = placeholderStartPosition + node.nodeSize;
|
|
67
73
|
var selection = view.state.selection;
|
|
68
74
|
|
|
69
75
|
// when the selection is set right after the placeholder.
|
|
@@ -38,6 +38,9 @@ var Task = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
38
38
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleOnChange", function (taskId, isChecked) {
|
|
39
39
|
var tr = _this.view.state.tr;
|
|
40
40
|
var nodePos = _this.getPos();
|
|
41
|
+
if (typeof nodePos !== 'number') {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
41
44
|
|
|
42
45
|
// SetAttrsStep should be used to prevent task updates from being dropped when mapping task ticks
|
|
43
46
|
// from a previous version of the document, such as a published page.
|
|
@@ -59,7 +62,11 @@ var Task = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
59
62
|
*/
|
|
60
63
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "addListAnalyticsData", function (event) {
|
|
61
64
|
try {
|
|
62
|
-
var
|
|
65
|
+
var nodePos = _this.getPos();
|
|
66
|
+
if (typeof nodePos !== 'number') {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
var resolvedPos = _this.view.state.doc.resolve(nodePos);
|
|
63
70
|
var position = resolvedPos.index();
|
|
64
71
|
var listSize = resolvedPos.parent.childCount;
|
|
65
72
|
var listLocalId = resolvedPos.parent.attrs.localId;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = "@atlaskit/editor-core";
|
|
8
8
|
exports.name = name;
|
|
9
|
-
var version = "185.3.
|
|
9
|
+
var version = "185.3.1";
|
|
10
10
|
exports.version = version;
|
|
11
11
|
var nextMajorVersion = function nextMajorVersion() {
|
|
12
12
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
package/dist/cjs/version.json
CHANGED
|
@@ -28,11 +28,17 @@ export class BlockCardComponent extends React.PureComponent {
|
|
|
28
28
|
|
|
29
29
|
// don't dispatch immediately since we might be in the middle of
|
|
30
30
|
// rendering a nodeview
|
|
31
|
-
rafSchedule(() =>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
rafSchedule(() => {
|
|
32
|
+
const pos = getPos();
|
|
33
|
+
if (typeof pos !== 'number') {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
view.dispatch(registerCard({
|
|
37
|
+
title,
|
|
38
|
+
url,
|
|
39
|
+
pos
|
|
40
|
+
})(view.state.tr));
|
|
41
|
+
})();
|
|
36
42
|
});
|
|
37
43
|
_defineProperty(this, "gapCursorSpan", () => {
|
|
38
44
|
// Don't render in EdgeHTMl version <= 18 (Edge version 44)
|
|
@@ -25,11 +25,18 @@ export class InlineCardComponent extends React.PureComponent {
|
|
|
25
25
|
} = data;
|
|
26
26
|
// don't dispatch immediately since we might be in the middle of
|
|
27
27
|
// rendering a nodeview
|
|
28
|
-
rafSchedule(() =>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
pos
|
|
32
|
-
|
|
28
|
+
rafSchedule(() => {
|
|
29
|
+
// prosemirror-bump-fix
|
|
30
|
+
const pos = getPos();
|
|
31
|
+
if (typeof pos !== 'number') {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
view.dispatch(registerCard({
|
|
35
|
+
title,
|
|
36
|
+
url,
|
|
37
|
+
pos
|
|
38
|
+
})(view.state.tr));
|
|
39
|
+
})();
|
|
33
40
|
});
|
|
34
41
|
_defineProperty(this, "onError", data => {
|
|
35
42
|
const {
|
|
@@ -21,10 +21,11 @@ export function DateNodeView(props) {
|
|
|
21
21
|
getPos
|
|
22
22
|
} = props;
|
|
23
23
|
const intl = useIntl();
|
|
24
|
+
const pos = typeof getPos === 'function' ? getPos() : undefined;
|
|
24
25
|
|
|
25
26
|
// We fall back to selection.$from even though it does not cover all use cases
|
|
26
27
|
// eg. upon Editor init, selection is at the start, not at the Date node
|
|
27
|
-
const $nodePos = typeof
|
|
28
|
+
const $nodePos = typeof pos === 'number' ? doc.resolve(pos) : selection.$from;
|
|
28
29
|
const parent = $nodePos.parent;
|
|
29
30
|
const withinIncompleteTask = parent.type === schema.nodes.taskItem && parent.attrs.state !== 'DONE';
|
|
30
31
|
const color = withinIncompleteTask && isPastDate(timestamp) ? 'red' : undefined;
|