@atlaskit/editor-core 185.3.0 → 185.4.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/plugins/card/nodeviews/blockCard.js +6 -2
- package/dist/cjs/plugins/card/nodeviews/datasource.js +139 -0
- package/dist/cjs/plugins/card/nodeviews/inlineCard.js +7 -2
- package/dist/cjs/plugins/card/pm-plugins/main.js +4 -0
- 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/datasource.js +100 -0
- package/dist/es2019/plugins/card/nodeviews/inlineCard.js +12 -5
- package/dist/es2019/plugins/card/pm-plugins/main.js +4 -0
- 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/datasource.js +131 -0
- package/dist/esm/plugins/card/nodeviews/inlineCard.js +7 -2
- package/dist/esm/plugins/card/pm-plugins/main.js +4 -0
- 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/card/nodeviews/datasource.d.ts +27 -0
- 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/card/nodeviews/datasource.d.ts +27 -0
- 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 +8 -7
- package/report.api.md +2 -2
- package/tmp/api-report-tmp.d.ts +2 -2
|
@@ -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.
|
|
9
|
+
var version = "185.4.0";
|
|
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)
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { css, jsx } from '@emotion/react';
|
|
6
|
+
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
7
|
+
import { DatasourceTableView } from '@atlaskit/link-datasource';
|
|
8
|
+
const containerStyles = css({
|
|
9
|
+
height: '500px',
|
|
10
|
+
overflow: 'auto'
|
|
11
|
+
});
|
|
12
|
+
export class DatasourceComponent extends React.PureComponent {
|
|
13
|
+
constructor(props) {
|
|
14
|
+
super(props);
|
|
15
|
+
_defineProperty(this, "getPosSafely", () => {
|
|
16
|
+
const {
|
|
17
|
+
getPos
|
|
18
|
+
} = this.props;
|
|
19
|
+
if (!getPos || typeof getPos === 'boolean') {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
return getPos();
|
|
24
|
+
} catch (e) {
|
|
25
|
+
// Can blow up in rare cases, when node has been removed.
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
_defineProperty(this, "getDatasource", () => this.props.node.attrs.datasource);
|
|
29
|
+
_defineProperty(this, "getTableView", datasource => {
|
|
30
|
+
const views = (datasource || this.getDatasource()).views;
|
|
31
|
+
return views.find(view => view.type === 'table') || undefined;
|
|
32
|
+
});
|
|
33
|
+
_defineProperty(this, "handleColumnChange", columnKeys => {
|
|
34
|
+
const {
|
|
35
|
+
state,
|
|
36
|
+
dispatch
|
|
37
|
+
} = this.props.view;
|
|
38
|
+
const pos = this.getPosSafely();
|
|
39
|
+
if (pos === undefined) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const attrs = this.props.node.attrs;
|
|
43
|
+
const views = [{
|
|
44
|
+
type: 'table',
|
|
45
|
+
properties: {
|
|
46
|
+
columns: columnKeys.map(key => ({
|
|
47
|
+
key
|
|
48
|
+
}))
|
|
49
|
+
}
|
|
50
|
+
}];
|
|
51
|
+
const tr = state.tr.setNodeMarkup(pos, undefined, {
|
|
52
|
+
...attrs,
|
|
53
|
+
datasource: {
|
|
54
|
+
...attrs.datasource,
|
|
55
|
+
views
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
tr.setMeta('scrollIntoView', false);
|
|
59
|
+
dispatch(tr);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
render() {
|
|
63
|
+
const cardContext = this.context.contextAdapter ? this.context.contextAdapter.card : undefined;
|
|
64
|
+
const datasource = this.getDatasource();
|
|
65
|
+
const tableView = this.getTableView();
|
|
66
|
+
if (tableView) {
|
|
67
|
+
var _tableView$properties;
|
|
68
|
+
const visibleColumnKeys = (_tableView$properties = tableView.properties) === null || _tableView$properties === void 0 ? void 0 : _tableView$properties.columns.map(({
|
|
69
|
+
key
|
|
70
|
+
}) => key);
|
|
71
|
+
|
|
72
|
+
// [WS-2307]: we only render card wrapped into a Provider when the value is ready
|
|
73
|
+
if (cardContext && cardContext.value) {
|
|
74
|
+
return jsx(cardContext.Provider, {
|
|
75
|
+
value: cardContext.value
|
|
76
|
+
}, jsx(DatasourceTableView, {
|
|
77
|
+
datasourceId: datasource.id,
|
|
78
|
+
parameters: datasource.parameters,
|
|
79
|
+
visibleColumnKeys: visibleColumnKeys,
|
|
80
|
+
onVisibleColumnKeysChange: this.handleColumnChange
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
_defineProperty(DatasourceComponent, "contextTypes", {
|
|
88
|
+
contextAdapter: PropTypes.object
|
|
89
|
+
});
|
|
90
|
+
export class Datasource extends ReactNodeView {
|
|
91
|
+
render() {
|
|
92
|
+
return jsx("div", {
|
|
93
|
+
css: containerStyles
|
|
94
|
+
}, jsx(DatasourceComponent, {
|
|
95
|
+
node: this.node,
|
|
96
|
+
view: this.view,
|
|
97
|
+
getPos: this.getPos
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -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 {
|
|
@@ -9,6 +9,7 @@ import reducer from './reducers';
|
|
|
9
9
|
import { handleProvider, resolveWithProvider } from './util/resolve';
|
|
10
10
|
import { getNewRequests, getPluginState, getPluginStateWithUpdatedPos } from './util/state';
|
|
11
11
|
import { createAnalyticsQueue, eventsFromTransaction } from './analytics';
|
|
12
|
+
import { Datasource } from '../nodeviews/datasource';
|
|
12
13
|
export { pluginKey } from './plugin-key';
|
|
13
14
|
export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryParams => {
|
|
14
15
|
const {
|
|
@@ -119,6 +120,9 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
|
|
|
119
120
|
showServerActions
|
|
120
121
|
};
|
|
121
122
|
const hasIntlContext = true;
|
|
123
|
+
if (node.attrs.datasource) {
|
|
124
|
+
return new Datasource(node, view, getPos, portalProviderAPI, eventDispatcher, undefined, undefined, true, undefined, hasIntlContext).init();
|
|
125
|
+
}
|
|
122
126
|
return new BlockCard(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, undefined, true, undefined, hasIntlContext).init();
|
|
123
127
|
},
|
|
124
128
|
embedCard: (node, view, getPos) => {
|
|
@@ -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;
|
|
@@ -79,6 +79,10 @@ export class ExpandNodeView {
|
|
|
79
79
|
return this.featureFlags && !!this.featureFlags.interactiveExpand;
|
|
80
80
|
});
|
|
81
81
|
_defineProperty(this, "handleClick", event => {
|
|
82
|
+
const pos = this.getPos();
|
|
83
|
+
if (typeof pos !== 'number') {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
82
86
|
const target = event.target;
|
|
83
87
|
const {
|
|
84
88
|
state,
|
|
@@ -95,7 +99,7 @@ export class ExpandNodeView {
|
|
|
95
99
|
if (this.view.dom instanceof HTMLElement) {
|
|
96
100
|
this.view.dom.blur();
|
|
97
101
|
}
|
|
98
|
-
toggleExpandExpanded(
|
|
102
|
+
toggleExpandExpanded(pos, this.node.type)(state, dispatch);
|
|
99
103
|
return;
|
|
100
104
|
}
|
|
101
105
|
if (target === this.input) {
|
|
@@ -105,6 +109,10 @@ export class ExpandNodeView {
|
|
|
105
109
|
}
|
|
106
110
|
});
|
|
107
111
|
_defineProperty(this, "handleInput", event => {
|
|
112
|
+
const pos = this.getPos();
|
|
113
|
+
if (typeof pos !== 'number') {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
108
116
|
const target = event.target;
|
|
109
117
|
if (target === this.input) {
|
|
110
118
|
event.stopPropagation();
|
|
@@ -112,7 +120,7 @@ export class ExpandNodeView {
|
|
|
112
120
|
state,
|
|
113
121
|
dispatch
|
|
114
122
|
} = this.view;
|
|
115
|
-
updateExpandTitle(target.value,
|
|
123
|
+
updateExpandTitle(target.value, pos, this.node.type)(state, dispatch);
|
|
116
124
|
}
|
|
117
125
|
});
|
|
118
126
|
_defineProperty(this, "handleFocus", event => {
|
|
@@ -145,6 +153,10 @@ export class ExpandNodeView {
|
|
|
145
153
|
if (!this.input) {
|
|
146
154
|
return;
|
|
147
155
|
}
|
|
156
|
+
const pos = this.getPos();
|
|
157
|
+
if (typeof pos !== 'number') {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
148
160
|
const {
|
|
149
161
|
selectionStart,
|
|
150
162
|
selectionEnd
|
|
@@ -157,16 +169,20 @@ export class ExpandNodeView {
|
|
|
157
169
|
} = this.view;
|
|
158
170
|
const expandNode = this.node;
|
|
159
171
|
if (expandNode && isEmptyNode(state.schema)(expandNode)) {
|
|
160
|
-
deleteExpandAtPos(
|
|
172
|
+
deleteExpandAtPos(pos, expandNode)(state, this.view.dispatch);
|
|
161
173
|
}
|
|
162
174
|
});
|
|
163
175
|
_defineProperty(this, "toggleExpand", () => {
|
|
176
|
+
const pos = this.getPos();
|
|
177
|
+
if (typeof pos !== 'number') {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
164
180
|
if (this.isAllowInteractiveExpandEnabled()) {
|
|
165
181
|
const {
|
|
166
182
|
state,
|
|
167
183
|
dispatch
|
|
168
184
|
} = this.view;
|
|
169
|
-
toggleExpandExpanded(
|
|
185
|
+
toggleExpandExpanded(pos, this.node.type)(state, dispatch);
|
|
170
186
|
}
|
|
171
187
|
});
|
|
172
188
|
_defineProperty(this, "moveToOutsideOfTitle", event => {
|
|
@@ -205,6 +221,10 @@ export class ExpandNodeView {
|
|
|
205
221
|
if (!this.input) {
|
|
206
222
|
return;
|
|
207
223
|
}
|
|
224
|
+
const pos = this.getPos();
|
|
225
|
+
if (typeof pos !== 'number') {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
208
228
|
const {
|
|
209
229
|
value,
|
|
210
230
|
selectionStart,
|
|
@@ -217,13 +237,17 @@ export class ExpandNodeView {
|
|
|
217
237
|
} = this.view;
|
|
218
238
|
event.preventDefault();
|
|
219
239
|
this.view.focus();
|
|
220
|
-
dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(this.node.nodeSize +
|
|
240
|
+
dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(this.node.nodeSize + pos), Side.RIGHT)));
|
|
221
241
|
}
|
|
222
242
|
});
|
|
223
243
|
_defineProperty(this, "setLeftGapCursor", event => {
|
|
224
244
|
if (!this.input) {
|
|
225
245
|
return;
|
|
226
246
|
}
|
|
247
|
+
const pos = this.getPos();
|
|
248
|
+
if (typeof pos !== 'number') {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
227
251
|
const {
|
|
228
252
|
selectionStart,
|
|
229
253
|
selectionEnd
|
|
@@ -235,13 +259,17 @@ export class ExpandNodeView {
|
|
|
235
259
|
dispatch
|
|
236
260
|
} = this.view;
|
|
237
261
|
this.view.focus();
|
|
238
|
-
dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(
|
|
262
|
+
dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(pos), Side.LEFT)));
|
|
239
263
|
}
|
|
240
264
|
});
|
|
241
265
|
_defineProperty(this, "handleArrowRightFromTitle", event => {
|
|
242
266
|
if (!this.input) {
|
|
243
267
|
return;
|
|
244
268
|
}
|
|
269
|
+
const pos = this.getPos();
|
|
270
|
+
if (typeof pos !== 'number') {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
245
273
|
const {
|
|
246
274
|
value,
|
|
247
275
|
selectionStart,
|
|
@@ -254,13 +282,17 @@ export class ExpandNodeView {
|
|
|
254
282
|
dispatch
|
|
255
283
|
} = this.view;
|
|
256
284
|
this.view.focus();
|
|
257
|
-
setSelectionRelativeToNode(RelativeSelectionPos.End, NodeSelection.create(state.doc,
|
|
285
|
+
setSelectionRelativeToNode(RelativeSelectionPos.End, NodeSelection.create(state.doc, pos))(state, dispatch);
|
|
258
286
|
}
|
|
259
287
|
});
|
|
260
288
|
_defineProperty(this, "handleArrowLeftFromTitle", event => {
|
|
261
289
|
if (!this.input) {
|
|
262
290
|
return;
|
|
263
291
|
}
|
|
292
|
+
const pos = this.getPos();
|
|
293
|
+
if (typeof pos !== 'number') {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
264
296
|
const {
|
|
265
297
|
selectionStart,
|
|
266
298
|
selectionEnd
|
|
@@ -276,9 +308,9 @@ export class ExpandNodeView {
|
|
|
276
308
|
// selectionRelativeToNode is undefined when user clicked to select node, then hit left to get focus in title
|
|
277
309
|
// This is a special case where we want to bypass node selection and jump straight to gap cursor
|
|
278
310
|
if (getSelectionPluginState(state).selectionRelativeToNode === undefined) {
|
|
279
|
-
setSelectionRelativeToNode(undefined, new GapCursorSelection(state.doc.resolve(
|
|
311
|
+
setSelectionRelativeToNode(undefined, new GapCursorSelection(state.doc.resolve(pos), Side.LEFT))(state, dispatch);
|
|
280
312
|
} else {
|
|
281
|
-
setSelectionRelativeToNode(RelativeSelectionPos.Start, NodeSelection.create(state.doc,
|
|
313
|
+
setSelectionRelativeToNode(RelativeSelectionPos.Start, NodeSelection.create(state.doc, pos))(state, dispatch);
|
|
282
314
|
}
|
|
283
315
|
}
|
|
284
316
|
});
|
|
@@ -288,7 +320,6 @@ export class ExpandNodeView {
|
|
|
288
320
|
contentDOM
|
|
289
321
|
} = DOMSerializer.renderSpec(document, toDOM(node, this.intl));
|
|
290
322
|
this.getPos = getPos;
|
|
291
|
-
this.pos = getPos();
|
|
292
323
|
this.view = view;
|
|
293
324
|
this.node = node;
|
|
294
325
|
this.dom = dom;
|
|
@@ -26,7 +26,8 @@ function ExtensionWithPluginState(props) {
|
|
|
26
26
|
const isMobile = editorAppearance === 'mobile';
|
|
27
27
|
const hasChildren = !!children;
|
|
28
28
|
const removeBorder = hideFrame && !isMobile && !hasBody || false;
|
|
29
|
-
const
|
|
29
|
+
const pos = typeof props.getPos === 'function' ? props.getPos() : undefined;
|
|
30
|
+
const isTopLevelNode = typeof pos !== 'undefined' && !isNaN(pos) && props.view.state.doc.resolve(pos).depth === 0;
|
|
30
31
|
const shouldBreakout =
|
|
31
32
|
// Extension should breakout when the layout is set to 'full-width' or 'wide'.
|
|
32
33
|
['full-width', 'wide'].includes(node.attrs.layout) &&
|
|
@@ -16,6 +16,9 @@ export const selectCaptionFromMediaSinglePos = (mediaSingleNodePos, mediaSingleN
|
|
|
16
16
|
return true;
|
|
17
17
|
};
|
|
18
18
|
export const insertAndSelectCaptionFromMediaSinglePos = (mediaSingleNodePos, mediaSingleNode) => (state, dispatch) => {
|
|
19
|
+
if (typeof mediaSingleNodePos !== 'number') {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
19
22
|
let tr = state.tr;
|
|
20
23
|
|
|
21
24
|
// node should have one child, media
|
|
@@ -42,7 +42,7 @@ export const updateAllMediaSingleNodesAttrs = (id, attrs) => (state, dispatch) =
|
|
|
42
42
|
getPos
|
|
43
43
|
}) => {
|
|
44
44
|
const pos = getPos();
|
|
45
|
-
if (isNaN(pos) || typeof pos === 'number' && !isMediaNode(pos, state)) {
|
|
45
|
+
if (typeof pos !== 'number' || isNaN(pos) || typeof pos === 'number' && !isMediaNode(pos, state)) {
|
|
46
46
|
return acc;
|
|
47
47
|
}
|
|
48
48
|
acc.push(pos);
|
|
@@ -61,7 +61,7 @@ export const updateAllMediaSingleNodesAttrs = (id, attrs) => (state, dispatch) =
|
|
|
61
61
|
};
|
|
62
62
|
export const updateCurrentMediaNodeAttrs = (attrs, mediaNode) => (state, dispatch) => {
|
|
63
63
|
const pos = mediaNode.getPos();
|
|
64
|
-
if (isNaN(pos) || typeof pos === 'number' && !isMediaNode(pos, state)) {
|
|
64
|
+
if (typeof pos !== 'number' || isNaN(pos) || typeof pos === 'number' && !isMediaNode(pos, state)) {
|
|
65
65
|
return false;
|
|
66
66
|
}
|
|
67
67
|
const tr = state.tr;
|
|
@@ -80,7 +80,7 @@ export const updateMediaSingleNodeAttrs = (id, attrs) => (state, dispatch) => {
|
|
|
80
80
|
}
|
|
81
81
|
const tr = state.tr;
|
|
82
82
|
const pos = mediaNodeWithPos.getPos();
|
|
83
|
-
if (!isMediaNode(pos, state)) {
|
|
83
|
+
if (typeof pos !== 'number' || !isMediaNode(pos, state)) {
|
|
84
84
|
return false;
|
|
85
85
|
}
|
|
86
86
|
tr.step(new SetAttrsStep(pos, attrs)).setMeta('addToHistory', false);
|
|
@@ -13,7 +13,11 @@ import { injectIntl } from 'react-intl-next';
|
|
|
13
13
|
import { messages } from './messages';
|
|
14
14
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
15
15
|
const isMediaGroupSelectedFromProps = props => {
|
|
16
|
-
|
|
16
|
+
const pos = props.getPos();
|
|
17
|
+
if (typeof pos !== 'number') {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
return isNodeSelectedOrInRange(props.anchorPos, props.headPos, pos, props.node.nodeSize);
|
|
17
21
|
};
|
|
18
22
|
const hasSelectionChanged = (oldProps, newProps) => {
|
|
19
23
|
if (isMediaGroupSelectedFromProps(oldProps) !== isMediaGroupSelectedFromProps(newProps)) {
|
|
@@ -52,7 +56,18 @@ class MediaGroup extends React.Component {
|
|
|
52
56
|
const oldMediaNodes = this.mediaNodes;
|
|
53
57
|
this.mediaNodes = [];
|
|
54
58
|
node.forEach((item, childOffset) => {
|
|
55
|
-
const getPos = () =>
|
|
59
|
+
const getPos = () => {
|
|
60
|
+
const pos = props.getPos();
|
|
61
|
+
if (typeof pos !== 'number') {
|
|
62
|
+
// 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
|
|
63
|
+
// Because the original code would return NaN on runtime
|
|
64
|
+
// We are just make it explict now.
|
|
65
|
+
// 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.
|
|
66
|
+
// TODO: ED-13910 prosemirror-bump leftovers
|
|
67
|
+
return NaN;
|
|
68
|
+
}
|
|
69
|
+
return pos + childOffset + 1;
|
|
70
|
+
};
|
|
56
71
|
this.mediaNodes.push(item);
|
|
57
72
|
if (updatedAttrs) {
|
|
58
73
|
this.updateNodeAttrs(props, item, getPos);
|
|
@@ -96,7 +111,16 @@ class MediaGroup extends React.Component {
|
|
|
96
111
|
const items = this.mediaNodes.map((item, idx) => {
|
|
97
112
|
// We declared this to get a fresh position every time
|
|
98
113
|
const getNodePos = () => {
|
|
99
|
-
|
|
114
|
+
const pos = getPos();
|
|
115
|
+
if (typeof pos !== 'number') {
|
|
116
|
+
// 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
|
|
117
|
+
// Because the original code would return NaN on runtime
|
|
118
|
+
// We are just make it explict now.
|
|
119
|
+
// 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.
|
|
120
|
+
// TODO: ED-13910 prosemirror-bump leftovers
|
|
121
|
+
return NaN;
|
|
122
|
+
}
|
|
123
|
+
return pos + idx + 1;
|
|
100
124
|
};
|
|
101
125
|
|
|
102
126
|
// Media Inline creates a floating toolbar with the same options, excludes these options if enabled
|
|
@@ -154,7 +178,18 @@ class MediaGroup extends React.Component {
|
|
|
154
178
|
node,
|
|
155
179
|
isMediaSingle: false
|
|
156
180
|
});
|
|
157
|
-
const getPos = () =>
|
|
181
|
+
const getPos = () => {
|
|
182
|
+
const pos = this.props.getPos();
|
|
183
|
+
if (typeof pos !== 'number') {
|
|
184
|
+
// 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
|
|
185
|
+
// Because the original code would return NaN on runtime
|
|
186
|
+
// We are just make it explict now.
|
|
187
|
+
// 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.
|
|
188
|
+
// TODO: ED-13910 prosemirror-bump leftovers
|
|
189
|
+
return NaN;
|
|
190
|
+
}
|
|
191
|
+
return pos + 1;
|
|
192
|
+
};
|
|
158
193
|
const contextId = mediaNodeUpdater.getNodeContextId();
|
|
159
194
|
if (!contextId) {
|
|
160
195
|
await mediaNodeUpdater.updateNodeContextId(getPos);
|
|
@@ -126,7 +126,11 @@ export class MediaNodeUpdater {
|
|
|
126
126
|
uploadableFileUpfrontIds,
|
|
127
127
|
dimensions
|
|
128
128
|
} = uploader;
|
|
129
|
-
|
|
129
|
+
const pos = getPos();
|
|
130
|
+
if (typeof pos !== 'number') {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
replaceExternalMedia(pos + 1, {
|
|
130
134
|
id: uploadableFileUpfrontIds.id,
|
|
131
135
|
collection,
|
|
132
136
|
height: dimensions.height,
|
|
@@ -230,7 +234,11 @@ export class MediaNodeUpdater {
|
|
|
230
234
|
occurrenceKey: uuidV4()
|
|
231
235
|
};
|
|
232
236
|
const mediaFile = await mediaClient.file.copyFile(source, destination);
|
|
233
|
-
|
|
237
|
+
const pos = getPos();
|
|
238
|
+
if (typeof pos !== 'number') {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
replaceExternalMedia(pos + 1, {
|
|
234
242
|
id: mediaFile.id,
|
|
235
243
|
collection: currentCollectionName,
|
|
236
244
|
height,
|
|
@@ -30,10 +30,14 @@ export class MediaNode extends Component {
|
|
|
30
30
|
this.selectMediaSingle(event);
|
|
31
31
|
});
|
|
32
32
|
_defineProperty(this, "selectMediaSingle", event => {
|
|
33
|
+
const propPos = this.props.getPos();
|
|
34
|
+
if (typeof propPos !== 'number') {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
33
38
|
// We need to call "stopPropagation" here in order to prevent the browser from navigating to
|
|
34
39
|
// another URL if the media node is wrapped in a link mark.
|
|
35
40
|
event.stopPropagation();
|
|
36
|
-
const propPos = this.props.getPos();
|
|
37
41
|
const {
|
|
38
42
|
state
|
|
39
43
|
} = this.props.view;
|
|
@@ -99,10 +99,14 @@ export default class MediaSingleNode extends Component {
|
|
|
99
99
|
_defineProperty(this, "selectMediaSingle", ({
|
|
100
100
|
event
|
|
101
101
|
}) => {
|
|
102
|
+
const propPos = this.props.getPos();
|
|
103
|
+
if (typeof propPos !== 'number') {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
102
107
|
// We need to call "stopPropagation" here in order to prevent the browser from navigating to
|
|
103
108
|
// another URL if the media node is wrapped in a link mark.
|
|
104
109
|
event.stopPropagation();
|
|
105
|
-
const propPos = this.props.getPos();
|
|
106
110
|
const {
|
|
107
111
|
state
|
|
108
112
|
} = this.props.view;
|
|
@@ -180,6 +184,9 @@ export default class MediaSingleNode extends Component {
|
|
|
180
184
|
insertAndSelectCaptionFromMediaSinglePos(getPos(), node)(view.state, view.dispatch);
|
|
181
185
|
});
|
|
182
186
|
_defineProperty(this, "getLineLength", (view, pos) => {
|
|
187
|
+
if (typeof pos !== 'number') {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
183
190
|
if (isRichMediaInsideOfBlockNode(view, pos)) {
|
|
184
191
|
const $pos = view.state.doc.resolve(pos);
|
|
185
192
|
const domNode = view.nodeDOM($pos.pos);
|
|
@@ -237,7 +237,11 @@ export class MediaPluginStateImplementation {
|
|
|
237
237
|
_defineProperty(this, "handleMediaNodeRemoval", (node, getPos) => {
|
|
238
238
|
let getNode = node;
|
|
239
239
|
if (!getNode) {
|
|
240
|
-
|
|
240
|
+
const pos = getPos();
|
|
241
|
+
if (typeof pos !== 'number') {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
getNode = this.view.state.doc.nodeAt(pos);
|
|
241
245
|
}
|
|
242
246
|
removeMediaNode(this.view, getNode, getPos);
|
|
243
247
|
});
|
|
@@ -123,6 +123,9 @@ export const removeMediaNode = (view, node, getPos) => {
|
|
|
123
123
|
doc
|
|
124
124
|
} = state;
|
|
125
125
|
const currentMediaNodePos = getPos();
|
|
126
|
+
if (typeof currentMediaNodePos !== 'number') {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
126
129
|
tr.deleteRange(currentMediaNodePos, currentMediaNodePos + node.nodeSize);
|
|
127
130
|
if (isTemporary(id)) {
|
|
128
131
|
tr.setMeta('addToHistory', false);
|
|
@@ -37,6 +37,9 @@ export class PlaceholderTextNodeView {
|
|
|
37
37
|
view
|
|
38
38
|
} = this;
|
|
39
39
|
const startNodePosition = this.getPos();
|
|
40
|
+
if (typeof startNodePosition !== 'number') {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
40
43
|
const tr = view.state.tr;
|
|
41
44
|
tr.setSelection(Selection.near(tr.doc.resolve(startNodePosition)));
|
|
42
45
|
view.dispatch(tr);
|
|
@@ -53,7 +56,10 @@ export class PlaceholderTextNodeView {
|
|
|
53
56
|
node
|
|
54
57
|
} = this;
|
|
55
58
|
const placeholderStartPosition = this.getPos();
|
|
56
|
-
|
|
59
|
+
if (typeof placeholderStartPosition !== 'number') {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
const placeholderEndPosition = placeholderStartPosition + node.nodeSize;
|
|
57
63
|
const selection = view.state.selection;
|
|
58
64
|
|
|
59
65
|
// when the selection is set right after the placeholder.
|