@atlaskit/editor-core 185.2.27 → 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 +17 -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 +13 -9
- package/report.api.md +2 -2
- package/tmp/api-report-tmp.d.ts +2 -2
|
@@ -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.
|
|
@@ -15,6 +15,9 @@ class Task extends ReactNodeView {
|
|
|
15
15
|
tr
|
|
16
16
|
} = this.view.state;
|
|
17
17
|
const nodePos = this.getPos();
|
|
18
|
+
if (typeof nodePos !== 'number') {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
18
21
|
|
|
19
22
|
// SetAttrsStep should be used to prevent task updates from being dropped when mapping task ticks
|
|
20
23
|
// from a previous version of the document, such as a published page.
|
|
@@ -36,7 +39,11 @@ class Task extends ReactNodeView {
|
|
|
36
39
|
*/
|
|
37
40
|
_defineProperty(this, "addListAnalyticsData", event => {
|
|
38
41
|
try {
|
|
39
|
-
const
|
|
42
|
+
const nodePos = this.getPos();
|
|
43
|
+
if (typeof nodePos !== 'number') {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
const resolvedPos = this.view.state.doc.resolve(nodePos);
|
|
40
47
|
const position = resolvedPos.index();
|
|
41
48
|
const listSize = resolvedPos.parent.childCount;
|
|
42
49
|
const listLocalId = resolvedPos.parent.attrs.localId;
|
package/dist/es2019/version.json
CHANGED
|
@@ -41,10 +41,14 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
41
41
|
// don't dispatch immediately since we might be in the middle of
|
|
42
42
|
// rendering a nodeview
|
|
43
43
|
rafSchedule(function () {
|
|
44
|
-
|
|
44
|
+
var pos = getPos();
|
|
45
|
+
if (typeof pos !== 'number') {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
view.dispatch(registerCard({
|
|
45
49
|
title: title,
|
|
46
50
|
url: url,
|
|
47
|
-
pos:
|
|
51
|
+
pos: pos
|
|
48
52
|
})(view.state.tr));
|
|
49
53
|
})();
|
|
50
54
|
});
|
|
@@ -38,10 +38,15 @@ export var InlineCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
38
38
|
// don't dispatch immediately since we might be in the middle of
|
|
39
39
|
// rendering a nodeview
|
|
40
40
|
rafSchedule(function () {
|
|
41
|
-
|
|
41
|
+
// prosemirror-bump-fix
|
|
42
|
+
var pos = getPos();
|
|
43
|
+
if (typeof pos !== 'number') {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
view.dispatch(registerCard({
|
|
42
47
|
title: title,
|
|
43
48
|
url: url,
|
|
44
|
-
pos:
|
|
49
|
+
pos: pos
|
|
45
50
|
})(view.state.tr));
|
|
46
51
|
})();
|
|
47
52
|
});
|
|
@@ -12,10 +12,11 @@ export function DateNodeView(props) {
|
|
|
12
12
|
selection = _props$view$state.selection,
|
|
13
13
|
getPos = props.getPos;
|
|
14
14
|
var intl = useIntl();
|
|
15
|
+
var pos = typeof getPos === 'function' ? getPos() : undefined;
|
|
15
16
|
|
|
16
17
|
// We fall back to selection.$from even though it does not cover all use cases
|
|
17
18
|
// eg. upon Editor init, selection is at the start, not at the Date node
|
|
18
|
-
var $nodePos = typeof
|
|
19
|
+
var $nodePos = typeof pos === 'number' ? doc.resolve(pos) : selection.$from;
|
|
19
20
|
var parent = $nodePos.parent;
|
|
20
21
|
var withinIncompleteTask = parent.type === schema.nodes.taskItem && parent.attrs.state !== 'DONE';
|
|
21
22
|
var color = withinIncompleteTask && isPastDate(timestamp) ? 'red' : undefined;
|
|
@@ -84,6 +84,10 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
84
84
|
return _this.featureFlags && !!_this.featureFlags.interactiveExpand;
|
|
85
85
|
});
|
|
86
86
|
_defineProperty(this, "handleClick", function (event) {
|
|
87
|
+
var pos = _this.getPos();
|
|
88
|
+
if (typeof pos !== 'number') {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
87
91
|
var target = event.target;
|
|
88
92
|
var _this$view2 = _this.view,
|
|
89
93
|
state = _this$view2.state,
|
|
@@ -99,7 +103,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
99
103
|
if (_this.view.dom instanceof HTMLElement) {
|
|
100
104
|
_this.view.dom.blur();
|
|
101
105
|
}
|
|
102
|
-
toggleExpandExpanded(
|
|
106
|
+
toggleExpandExpanded(pos, _this.node.type)(state, dispatch);
|
|
103
107
|
return;
|
|
104
108
|
}
|
|
105
109
|
if (target === _this.input) {
|
|
@@ -109,13 +113,17 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
109
113
|
}
|
|
110
114
|
});
|
|
111
115
|
_defineProperty(this, "handleInput", function (event) {
|
|
116
|
+
var pos = _this.getPos();
|
|
117
|
+
if (typeof pos !== 'number') {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
112
120
|
var target = event.target;
|
|
113
121
|
if (target === _this.input) {
|
|
114
122
|
event.stopPropagation();
|
|
115
123
|
var _this$view3 = _this.view,
|
|
116
124
|
state = _this$view3.state,
|
|
117
125
|
dispatch = _this$view3.dispatch;
|
|
118
|
-
updateExpandTitle(target.value,
|
|
126
|
+
updateExpandTitle(target.value, pos, _this.node.type)(state, dispatch);
|
|
119
127
|
}
|
|
120
128
|
});
|
|
121
129
|
_defineProperty(this, "handleFocus", function (event) {
|
|
@@ -148,6 +156,10 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
148
156
|
if (!_this.input) {
|
|
149
157
|
return;
|
|
150
158
|
}
|
|
159
|
+
var pos = _this.getPos();
|
|
160
|
+
if (typeof pos !== 'number') {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
151
163
|
var _this$input = _this.input,
|
|
152
164
|
selectionStart = _this$input.selectionStart,
|
|
153
165
|
selectionEnd = _this$input.selectionEnd;
|
|
@@ -157,15 +169,19 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
157
169
|
var state = _this.view.state;
|
|
158
170
|
var 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", function () {
|
|
176
|
+
var pos = _this.getPos();
|
|
177
|
+
if (typeof pos !== 'number') {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
164
180
|
if (_this.isAllowInteractiveExpandEnabled()) {
|
|
165
181
|
var _this$view4 = _this.view,
|
|
166
182
|
state = _this$view4.state,
|
|
167
183
|
dispatch = _this$view4.dispatch;
|
|
168
|
-
toggleExpandExpanded(
|
|
184
|
+
toggleExpandExpanded(pos, _this.node.type)(state, dispatch);
|
|
169
185
|
}
|
|
170
186
|
});
|
|
171
187
|
_defineProperty(this, "moveToOutsideOfTitle", function (event) {
|
|
@@ -203,6 +219,10 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
203
219
|
if (!_this.input) {
|
|
204
220
|
return;
|
|
205
221
|
}
|
|
222
|
+
var pos = _this.getPos();
|
|
223
|
+
if (typeof pos !== 'number') {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
206
226
|
var _this$input2 = _this.input,
|
|
207
227
|
value = _this$input2.value,
|
|
208
228
|
selectionStart = _this$input2.selectionStart,
|
|
@@ -213,13 +233,17 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
213
233
|
dispatch = _this$view6.dispatch;
|
|
214
234
|
event.preventDefault();
|
|
215
235
|
_this.view.focus();
|
|
216
|
-
dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(_this.node.nodeSize +
|
|
236
|
+
dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(_this.node.nodeSize + pos), Side.RIGHT)));
|
|
217
237
|
}
|
|
218
238
|
});
|
|
219
239
|
_defineProperty(this, "setLeftGapCursor", function (event) {
|
|
220
240
|
if (!_this.input) {
|
|
221
241
|
return;
|
|
222
242
|
}
|
|
243
|
+
var pos = _this.getPos();
|
|
244
|
+
if (typeof pos !== 'number') {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
223
247
|
var _this$input3 = _this.input,
|
|
224
248
|
selectionStart = _this$input3.selectionStart,
|
|
225
249
|
selectionEnd = _this$input3.selectionEnd;
|
|
@@ -229,13 +253,17 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
229
253
|
state = _this$view7.state,
|
|
230
254
|
dispatch = _this$view7.dispatch;
|
|
231
255
|
_this.view.focus();
|
|
232
|
-
dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(
|
|
256
|
+
dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(pos), Side.LEFT)));
|
|
233
257
|
}
|
|
234
258
|
});
|
|
235
259
|
_defineProperty(this, "handleArrowRightFromTitle", function (event) {
|
|
236
260
|
if (!_this.input) {
|
|
237
261
|
return;
|
|
238
262
|
}
|
|
263
|
+
var pos = _this.getPos();
|
|
264
|
+
if (typeof pos !== 'number') {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
239
267
|
var _this$input4 = _this.input,
|
|
240
268
|
value = _this$input4.value,
|
|
241
269
|
selectionStart = _this$input4.selectionStart,
|
|
@@ -246,13 +274,17 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
246
274
|
state = _this$view8.state,
|
|
247
275
|
dispatch = _this$view8.dispatch;
|
|
248
276
|
_this.view.focus();
|
|
249
|
-
setSelectionRelativeToNode(RelativeSelectionPos.End, NodeSelection.create(state.doc,
|
|
277
|
+
setSelectionRelativeToNode(RelativeSelectionPos.End, NodeSelection.create(state.doc, pos))(state, dispatch);
|
|
250
278
|
}
|
|
251
279
|
});
|
|
252
280
|
_defineProperty(this, "handleArrowLeftFromTitle", function (event) {
|
|
253
281
|
if (!_this.input) {
|
|
254
282
|
return;
|
|
255
283
|
}
|
|
284
|
+
var pos = _this.getPos();
|
|
285
|
+
if (typeof pos !== 'number') {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
256
288
|
var _this$input5 = _this.input,
|
|
257
289
|
selectionStart = _this$input5.selectionStart,
|
|
258
290
|
selectionEnd = _this$input5.selectionEnd;
|
|
@@ -266,9 +298,9 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
266
298
|
// selectionRelativeToNode is undefined when user clicked to select node, then hit left to get focus in title
|
|
267
299
|
// This is a special case where we want to bypass node selection and jump straight to gap cursor
|
|
268
300
|
if (getSelectionPluginState(state).selectionRelativeToNode === undefined) {
|
|
269
|
-
setSelectionRelativeToNode(undefined, new GapCursorSelection(state.doc.resolve(
|
|
301
|
+
setSelectionRelativeToNode(undefined, new GapCursorSelection(state.doc.resolve(pos), Side.LEFT))(state, dispatch);
|
|
270
302
|
} else {
|
|
271
|
-
setSelectionRelativeToNode(RelativeSelectionPos.Start, NodeSelection.create(state.doc,
|
|
303
|
+
setSelectionRelativeToNode(RelativeSelectionPos.Start, NodeSelection.create(state.doc, pos))(state, dispatch);
|
|
272
304
|
}
|
|
273
305
|
}
|
|
274
306
|
});
|
|
@@ -277,7 +309,6 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
277
309
|
dom = _DOMSerializer$render.dom,
|
|
278
310
|
contentDOM = _DOMSerializer$render.contentDOM;
|
|
279
311
|
this.getPos = getPos;
|
|
280
|
-
this.pos = getPos();
|
|
281
312
|
this.view = view;
|
|
282
313
|
this.node = node;
|
|
283
314
|
this.dom = dom;
|
|
@@ -30,7 +30,8 @@ function ExtensionWithPluginState(props) {
|
|
|
30
30
|
var isMobile = editorAppearance === 'mobile';
|
|
31
31
|
var hasChildren = !!children;
|
|
32
32
|
var removeBorder = hideFrame && !isMobile && !hasBody || false;
|
|
33
|
-
var
|
|
33
|
+
var pos = typeof props.getPos === 'function' ? props.getPos() : undefined;
|
|
34
|
+
var isTopLevelNode = typeof pos !== 'undefined' && !isNaN(pos) && props.view.state.doc.resolve(pos).depth === 0;
|
|
34
35
|
var shouldBreakout =
|
|
35
36
|
// Extension should breakout when the layout is set to 'full-width' or 'wide'.
|
|
36
37
|
['full-width', 'wide'].includes(node.attrs.layout) &&
|
|
@@ -19,6 +19,9 @@ export var selectCaptionFromMediaSinglePos = function selectCaptionFromMediaSing
|
|
|
19
19
|
};
|
|
20
20
|
export var insertAndSelectCaptionFromMediaSinglePos = function insertAndSelectCaptionFromMediaSinglePos(mediaSingleNodePos, mediaSingleNode) {
|
|
21
21
|
return function (state, dispatch) {
|
|
22
|
+
if (typeof mediaSingleNodePos !== 'number') {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
22
25
|
var tr = state.tr;
|
|
23
26
|
|
|
24
27
|
// node should have one child, media
|