@atlaskit/editor-plugin-media 0.10.3 → 0.10.4
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
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 0.10.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#65825](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/65825) [`d08cdd1cb2aa`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d08cdd1cb2aa) - add extra attributes for media link
|
|
8
|
+
|
|
3
9
|
## 0.10.3
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -185,7 +185,7 @@ var unlink = exports.unlink = function unlink(editorAnalyticsAPI) {
|
|
|
185
185
|
var transaction = toggleLinkMark(tr, state, {
|
|
186
186
|
forceRemove: true
|
|
187
187
|
});
|
|
188
|
-
return fireAnalyticForMediaLink(transaction, _analytics.ACTION.DELETED,
|
|
188
|
+
return fireAnalyticForMediaLink(transaction, _analytics.ACTION.DELETED, _objectSpread({}, getNodeTypeAndMediaTypeAttributes(state)), editorAnalyticsAPI);
|
|
189
189
|
});
|
|
190
190
|
};
|
|
191
191
|
var getAction = function getAction(newUrl, state) {
|
|
@@ -197,6 +197,32 @@ var getAction = function getAction(newUrl, state) {
|
|
|
197
197
|
}
|
|
198
198
|
return undefined;
|
|
199
199
|
};
|
|
200
|
+
var getNodeTypeAndMediaTypeAttributes = function getNodeTypeAndMediaTypeAttributes(state) {
|
|
201
|
+
var mediaLinkingState = (0, _linking.getMediaLinkingState)(state);
|
|
202
|
+
var _getMediaPluginState2 = (0, _main.getMediaPluginState)(state),
|
|
203
|
+
allowInlineImages = _getMediaPluginState2.allowInlineImages;
|
|
204
|
+
var _state$schema$nodes2 = state.schema.nodes,
|
|
205
|
+
mediaInline = _state$schema$nodes2.mediaInline,
|
|
206
|
+
mediaSingle = _state$schema$nodes2.mediaSingle;
|
|
207
|
+
if (!mediaLinkingState || mediaLinkingState.mediaPos === null) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
var $pos = state.doc.resolve(mediaLinkingState.mediaPos);
|
|
211
|
+
var node = state.doc.nodeAt($pos.pos);
|
|
212
|
+
if (!node) {
|
|
213
|
+
return {};
|
|
214
|
+
}
|
|
215
|
+
if (allowInlineImages && node.type === mediaInline) {
|
|
216
|
+
return {
|
|
217
|
+
type: mediaInline.name,
|
|
218
|
+
mediaType: node.attrs.type
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
type: mediaSingle.name,
|
|
223
|
+
mediaType: node.attrs.type
|
|
224
|
+
};
|
|
225
|
+
};
|
|
200
226
|
var setUrlToMedia = exports.setUrlToMedia = function setUrlToMedia(url, inputMethod, editorAnalyticsAPI) {
|
|
201
227
|
return (0, _linking.createMediaLinkingCommand)({
|
|
202
228
|
type: _actions.MediaLinkingActionsTypes.setUrl,
|
|
@@ -206,18 +232,19 @@ var setUrlToMedia = exports.setUrlToMedia = function setUrlToMedia(url, inputMet
|
|
|
206
232
|
if (!action) {
|
|
207
233
|
return tr;
|
|
208
234
|
}
|
|
235
|
+
var nodeTypeAndMediaTypeAttrs = getNodeTypeAndMediaTypeAttributes(state);
|
|
209
236
|
try {
|
|
210
237
|
var toggleLinkMarkResult = toggleLinkMark(tr, state, {
|
|
211
238
|
url: url
|
|
212
239
|
});
|
|
213
|
-
fireAnalyticForMediaLink(tr, action, action === _analytics.ACTION.ADDED ? {
|
|
240
|
+
fireAnalyticForMediaLink(tr, action, action === _analytics.ACTION.ADDED ? _objectSpread({
|
|
214
241
|
inputMethod: inputMethod
|
|
215
|
-
} :
|
|
242
|
+
}, nodeTypeAndMediaTypeAttrs) : nodeTypeAndMediaTypeAttrs, editorAnalyticsAPI);
|
|
216
243
|
return toggleLinkMarkResult;
|
|
217
244
|
} catch (e) {
|
|
218
|
-
fireAnalyticForMediaLink(tr, _analytics.ACTION.ERRORED, {
|
|
245
|
+
fireAnalyticForMediaLink(tr, _analytics.ACTION.ERRORED, _objectSpread({
|
|
219
246
|
action: action
|
|
220
|
-
}, editorAnalyticsAPI);
|
|
247
|
+
}, nodeTypeAndMediaTypeAttrs), editorAnalyticsAPI);
|
|
221
248
|
throw e;
|
|
222
249
|
}
|
|
223
250
|
});
|
|
@@ -176,7 +176,9 @@ export const unlink = editorAnalyticsAPI => createMediaLinkingCommand({
|
|
|
176
176
|
const transaction = toggleLinkMark(tr, state, {
|
|
177
177
|
forceRemove: true
|
|
178
178
|
});
|
|
179
|
-
return fireAnalyticForMediaLink(transaction, ACTION.DELETED,
|
|
179
|
+
return fireAnalyticForMediaLink(transaction, ACTION.DELETED, {
|
|
180
|
+
...getNodeTypeAndMediaTypeAttributes(state)
|
|
181
|
+
}, editorAnalyticsAPI);
|
|
180
182
|
});
|
|
181
183
|
const getAction = (newUrl, state) => {
|
|
182
184
|
const currentUrl = getCurrentUrl(state);
|
|
@@ -187,6 +189,34 @@ const getAction = (newUrl, state) => {
|
|
|
187
189
|
}
|
|
188
190
|
return undefined;
|
|
189
191
|
};
|
|
192
|
+
const getNodeTypeAndMediaTypeAttributes = state => {
|
|
193
|
+
const mediaLinkingState = getMediaLinkingState(state);
|
|
194
|
+
const {
|
|
195
|
+
allowInlineImages
|
|
196
|
+
} = getMediaPluginState(state);
|
|
197
|
+
const {
|
|
198
|
+
mediaInline,
|
|
199
|
+
mediaSingle
|
|
200
|
+
} = state.schema.nodes;
|
|
201
|
+
if (!mediaLinkingState || mediaLinkingState.mediaPos === null) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const $pos = state.doc.resolve(mediaLinkingState.mediaPos);
|
|
205
|
+
const node = state.doc.nodeAt($pos.pos);
|
|
206
|
+
if (!node) {
|
|
207
|
+
return {};
|
|
208
|
+
}
|
|
209
|
+
if (allowInlineImages && node.type === mediaInline) {
|
|
210
|
+
return {
|
|
211
|
+
type: mediaInline.name,
|
|
212
|
+
mediaType: node.attrs.type
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
type: mediaSingle.name,
|
|
217
|
+
mediaType: node.attrs.type
|
|
218
|
+
};
|
|
219
|
+
};
|
|
190
220
|
export const setUrlToMedia = (url, inputMethod, editorAnalyticsAPI) => createMediaLinkingCommand({
|
|
191
221
|
type: MediaLinkingActionsTypes.setUrl,
|
|
192
222
|
payload: normalizeUrl(url)
|
|
@@ -195,17 +225,20 @@ export const setUrlToMedia = (url, inputMethod, editorAnalyticsAPI) => createMed
|
|
|
195
225
|
if (!action) {
|
|
196
226
|
return tr;
|
|
197
227
|
}
|
|
228
|
+
const nodeTypeAndMediaTypeAttrs = getNodeTypeAndMediaTypeAttributes(state);
|
|
198
229
|
try {
|
|
199
230
|
const toggleLinkMarkResult = toggleLinkMark(tr, state, {
|
|
200
231
|
url: url
|
|
201
232
|
});
|
|
202
233
|
fireAnalyticForMediaLink(tr, action, action === ACTION.ADDED ? {
|
|
203
|
-
inputMethod
|
|
204
|
-
|
|
234
|
+
inputMethod,
|
|
235
|
+
...nodeTypeAndMediaTypeAttrs
|
|
236
|
+
} : nodeTypeAndMediaTypeAttrs, editorAnalyticsAPI);
|
|
205
237
|
return toggleLinkMarkResult;
|
|
206
238
|
} catch (e) {
|
|
207
239
|
fireAnalyticForMediaLink(tr, ACTION.ERRORED, {
|
|
208
|
-
action: action
|
|
240
|
+
action: action,
|
|
241
|
+
...nodeTypeAndMediaTypeAttrs
|
|
209
242
|
}, editorAnalyticsAPI);
|
|
210
243
|
throw e;
|
|
211
244
|
}
|
|
@@ -178,7 +178,7 @@ export var unlink = function unlink(editorAnalyticsAPI) {
|
|
|
178
178
|
var transaction = toggleLinkMark(tr, state, {
|
|
179
179
|
forceRemove: true
|
|
180
180
|
});
|
|
181
|
-
return fireAnalyticForMediaLink(transaction, ACTION.DELETED,
|
|
181
|
+
return fireAnalyticForMediaLink(transaction, ACTION.DELETED, _objectSpread({}, getNodeTypeAndMediaTypeAttributes(state)), editorAnalyticsAPI);
|
|
182
182
|
});
|
|
183
183
|
};
|
|
184
184
|
var getAction = function getAction(newUrl, state) {
|
|
@@ -190,6 +190,32 @@ var getAction = function getAction(newUrl, state) {
|
|
|
190
190
|
}
|
|
191
191
|
return undefined;
|
|
192
192
|
};
|
|
193
|
+
var getNodeTypeAndMediaTypeAttributes = function getNodeTypeAndMediaTypeAttributes(state) {
|
|
194
|
+
var mediaLinkingState = getMediaLinkingState(state);
|
|
195
|
+
var _getMediaPluginState2 = getMediaPluginState(state),
|
|
196
|
+
allowInlineImages = _getMediaPluginState2.allowInlineImages;
|
|
197
|
+
var _state$schema$nodes2 = state.schema.nodes,
|
|
198
|
+
mediaInline = _state$schema$nodes2.mediaInline,
|
|
199
|
+
mediaSingle = _state$schema$nodes2.mediaSingle;
|
|
200
|
+
if (!mediaLinkingState || mediaLinkingState.mediaPos === null) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
var $pos = state.doc.resolve(mediaLinkingState.mediaPos);
|
|
204
|
+
var node = state.doc.nodeAt($pos.pos);
|
|
205
|
+
if (!node) {
|
|
206
|
+
return {};
|
|
207
|
+
}
|
|
208
|
+
if (allowInlineImages && node.type === mediaInline) {
|
|
209
|
+
return {
|
|
210
|
+
type: mediaInline.name,
|
|
211
|
+
mediaType: node.attrs.type
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
type: mediaSingle.name,
|
|
216
|
+
mediaType: node.attrs.type
|
|
217
|
+
};
|
|
218
|
+
};
|
|
193
219
|
export var setUrlToMedia = function setUrlToMedia(url, inputMethod, editorAnalyticsAPI) {
|
|
194
220
|
return createMediaLinkingCommand({
|
|
195
221
|
type: MediaLinkingActionsTypes.setUrl,
|
|
@@ -199,18 +225,19 @@ export var setUrlToMedia = function setUrlToMedia(url, inputMethod, editorAnalyt
|
|
|
199
225
|
if (!action) {
|
|
200
226
|
return tr;
|
|
201
227
|
}
|
|
228
|
+
var nodeTypeAndMediaTypeAttrs = getNodeTypeAndMediaTypeAttributes(state);
|
|
202
229
|
try {
|
|
203
230
|
var toggleLinkMarkResult = toggleLinkMark(tr, state, {
|
|
204
231
|
url: url
|
|
205
232
|
});
|
|
206
|
-
fireAnalyticForMediaLink(tr, action, action === ACTION.ADDED ? {
|
|
233
|
+
fireAnalyticForMediaLink(tr, action, action === ACTION.ADDED ? _objectSpread({
|
|
207
234
|
inputMethod: inputMethod
|
|
208
|
-
} :
|
|
235
|
+
}, nodeTypeAndMediaTypeAttrs) : nodeTypeAndMediaTypeAttrs, editorAnalyticsAPI);
|
|
209
236
|
return toggleLinkMarkResult;
|
|
210
237
|
} catch (e) {
|
|
211
|
-
fireAnalyticForMediaLink(tr, ACTION.ERRORED, {
|
|
238
|
+
fireAnalyticForMediaLink(tr, ACTION.ERRORED, _objectSpread({
|
|
212
239
|
action: action
|
|
213
|
-
}, editorAnalyticsAPI);
|
|
240
|
+
}, nodeTypeAndMediaTypeAttrs), editorAnalyticsAPI);
|
|
214
241
|
throw e;
|
|
215
242
|
}
|
|
216
243
|
});
|