@atlaskit/editor-plugin-media 1.20.6 → 1.20.7
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,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 1.20.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#107716](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/107716)
|
|
8
|
+
[`62ea5418666f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/62ea5418666f) -
|
|
9
|
+
ED-22554 fix selection position after updating alt text
|
|
10
|
+
|
|
3
11
|
## 1.20.6
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -60,7 +60,10 @@ var updateAltTextTransform = exports.updateAltTextTransform = function updateAlt
|
|
|
60
60
|
return function (tr, state) {
|
|
61
61
|
var mediaNode = (0, _mediaCommon.getMediaSingleOrInlineNodeFromSelection)(state);
|
|
62
62
|
if (mediaNode) {
|
|
63
|
-
|
|
63
|
+
// mediaSingle or mediaInline
|
|
64
|
+
var originalSelectionPos = tr.selection.from;
|
|
65
|
+
var mediaPos = mediaNode.type === state.schema.nodes.media ? originalSelectionPos + 1 // media inside mediaSingle
|
|
66
|
+
: originalSelectionPos; // mediaInline
|
|
64
67
|
|
|
65
68
|
/**
|
|
66
69
|
* Any changes to attributes of a node count the node as "recreated" in Prosemirror[1]
|
|
@@ -70,9 +73,9 @@ var updateAltTextTransform = exports.updateAltTextTransform = function updateAlt
|
|
|
70
73
|
* [1] https://discuss.prosemirror.net/t/setnodemarkup-loses-current-nodeselection/976
|
|
71
74
|
* [2] https://discuss.prosemirror.net/t/setnodemarkup-and-deselect/3673
|
|
72
75
|
*/
|
|
73
|
-
tr.setMeta('scrollIntoView', false).setNodeMarkup(
|
|
76
|
+
tr.setMeta('scrollIntoView', false).setNodeMarkup(mediaPos, undefined, _objectSpread(_objectSpread({}, mediaNode.attrs), {}, {
|
|
74
77
|
alt: newAltText
|
|
75
|
-
})).setSelection(_state.NodeSelection.create(tr.doc,
|
|
78
|
+
})).setSelection(_state.NodeSelection.create(tr.doc, originalSelectionPos));
|
|
76
79
|
}
|
|
77
80
|
return tr;
|
|
78
81
|
};
|
|
@@ -47,7 +47,10 @@ export const openMediaAltTextMenu = createCommandWithAnalytics(ACTION.OPENED, st
|
|
|
47
47
|
export const updateAltTextTransform = newAltText => (tr, state) => {
|
|
48
48
|
const mediaNode = getMediaSingleOrInlineNodeFromSelection(state);
|
|
49
49
|
if (mediaNode) {
|
|
50
|
-
|
|
50
|
+
// mediaSingle or mediaInline
|
|
51
|
+
const originalSelectionPos = tr.selection.from;
|
|
52
|
+
const mediaPos = mediaNode.type === state.schema.nodes.media ? originalSelectionPos + 1 // media inside mediaSingle
|
|
53
|
+
: originalSelectionPos; // mediaInline
|
|
51
54
|
|
|
52
55
|
/**
|
|
53
56
|
* Any changes to attributes of a node count the node as "recreated" in Prosemirror[1]
|
|
@@ -57,10 +60,10 @@ export const updateAltTextTransform = newAltText => (tr, state) => {
|
|
|
57
60
|
* [1] https://discuss.prosemirror.net/t/setnodemarkup-loses-current-nodeselection/976
|
|
58
61
|
* [2] https://discuss.prosemirror.net/t/setnodemarkup-and-deselect/3673
|
|
59
62
|
*/
|
|
60
|
-
tr.setMeta('scrollIntoView', false).setNodeMarkup(
|
|
63
|
+
tr.setMeta('scrollIntoView', false).setNodeMarkup(mediaPos, undefined, {
|
|
61
64
|
...mediaNode.attrs,
|
|
62
65
|
alt: newAltText
|
|
63
|
-
}).setSelection(NodeSelection.create(tr.doc,
|
|
66
|
+
}).setSelection(NodeSelection.create(tr.doc, originalSelectionPos));
|
|
64
67
|
}
|
|
65
68
|
return tr;
|
|
66
69
|
};
|
|
@@ -53,7 +53,10 @@ export var updateAltTextTransform = function updateAltTextTransform(newAltText)
|
|
|
53
53
|
return function (tr, state) {
|
|
54
54
|
var mediaNode = getMediaSingleOrInlineNodeFromSelection(state);
|
|
55
55
|
if (mediaNode) {
|
|
56
|
-
|
|
56
|
+
// mediaSingle or mediaInline
|
|
57
|
+
var originalSelectionPos = tr.selection.from;
|
|
58
|
+
var mediaPos = mediaNode.type === state.schema.nodes.media ? originalSelectionPos + 1 // media inside mediaSingle
|
|
59
|
+
: originalSelectionPos; // mediaInline
|
|
57
60
|
|
|
58
61
|
/**
|
|
59
62
|
* Any changes to attributes of a node count the node as "recreated" in Prosemirror[1]
|
|
@@ -63,9 +66,9 @@ export var updateAltTextTransform = function updateAltTextTransform(newAltText)
|
|
|
63
66
|
* [1] https://discuss.prosemirror.net/t/setnodemarkup-loses-current-nodeselection/976
|
|
64
67
|
* [2] https://discuss.prosemirror.net/t/setnodemarkup-and-deselect/3673
|
|
65
68
|
*/
|
|
66
|
-
tr.setMeta('scrollIntoView', false).setNodeMarkup(
|
|
69
|
+
tr.setMeta('scrollIntoView', false).setNodeMarkup(mediaPos, undefined, _objectSpread(_objectSpread({}, mediaNode.attrs), {}, {
|
|
67
70
|
alt: newAltText
|
|
68
|
-
})).setSelection(NodeSelection.create(tr.doc,
|
|
71
|
+
})).setSelection(NodeSelection.create(tr.doc, originalSelectionPos));
|
|
69
72
|
}
|
|
70
73
|
return tr;
|
|
71
74
|
};
|