@atlaskit/editor-plugin-media 14.2.18 → 14.3.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-plugin-media
2
2
 
3
+ ## 14.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`1bdd62ad6abf9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1bdd62ad6abf9) -
8
+ Fix the AI "Ask Rovo" / "Edit image" loading overlay appearing on every copy of a duplicated
9
+ image, so only the acted-on image shows the loading state. Behind an experiment.
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 14.2.18
4
16
 
5
17
  ### Patch Changes
@@ -39,15 +39,27 @@ var AI_GENERATING_DECORATION_TYPE = 'ai-generating';
39
39
 
40
40
  /**
41
41
  * Build a DecorationSet containing a Decoration.node for every media node
42
- * whose `id` is in the given set.
42
+ * targeted by the given set.
43
+ *
44
+ * Targets are matched by `localId` first (the mediaSingle wrapper's or the media
45
+ * node's own) so that duplicate copies of the same image — which share a media
46
+ * file `id` — don't all get decorated; only the node the user acted on lights
47
+ * up. Falls back to the media file `id` for the CWR flow and for any node that
48
+ * has no localId yet.
43
49
  */
44
- function buildDecorationSet(doc, mediaIds) {
45
- if (mediaIds.size === 0) {
50
+ function buildDecorationSet(doc, targetIds) {
51
+ if (targetIds.size === 0) {
46
52
  return _view.DecorationSet.empty;
47
53
  }
48
54
  var decorations = [];
49
- doc.descendants(function (node, pos) {
50
- if (node.type.name === 'media' && mediaIds.has(node.attrs.id)) {
55
+ doc.descendants(function (node, pos, parent) {
56
+ var _parent$attrs;
57
+ if (node.type.name !== 'media') {
58
+ return;
59
+ }
60
+ var wrapperLocalId = parent === null || parent === void 0 || (_parent$attrs = parent.attrs) === null || _parent$attrs === void 0 ? void 0 : _parent$attrs.localId;
61
+ var matches = wrapperLocalId && targetIds.has(wrapperLocalId) || node.attrs.localId && targetIds.has(node.attrs.localId) || targetIds.has(node.attrs.id);
62
+ if (matches) {
51
63
  decorations.push(_view.Decoration.node(pos, pos + node.nodeSize, {},
52
64
  // no DOM attrs needed — the NodeView reads the decoration spec
53
65
  {
@@ -25,15 +25,27 @@ const AI_GENERATING_DECORATION_TYPE = 'ai-generating';
25
25
 
26
26
  /**
27
27
  * Build a DecorationSet containing a Decoration.node for every media node
28
- * whose `id` is in the given set.
28
+ * targeted by the given set.
29
+ *
30
+ * Targets are matched by `localId` first (the mediaSingle wrapper's or the media
31
+ * node's own) so that duplicate copies of the same image — which share a media
32
+ * file `id` — don't all get decorated; only the node the user acted on lights
33
+ * up. Falls back to the media file `id` for the CWR flow and for any node that
34
+ * has no localId yet.
29
35
  */
30
- function buildDecorationSet(doc, mediaIds) {
31
- if (mediaIds.size === 0) {
36
+ function buildDecorationSet(doc, targetIds) {
37
+ if (targetIds.size === 0) {
32
38
  return DecorationSet.empty;
33
39
  }
34
40
  const decorations = [];
35
- doc.descendants((node, pos) => {
36
- if (node.type.name === 'media' && mediaIds.has(node.attrs.id)) {
41
+ doc.descendants((node, pos, parent) => {
42
+ var _parent$attrs;
43
+ if (node.type.name !== 'media') {
44
+ return;
45
+ }
46
+ const wrapperLocalId = parent === null || parent === void 0 ? void 0 : (_parent$attrs = parent.attrs) === null || _parent$attrs === void 0 ? void 0 : _parent$attrs.localId;
47
+ const matches = wrapperLocalId && targetIds.has(wrapperLocalId) || node.attrs.localId && targetIds.has(node.attrs.localId) || targetIds.has(node.attrs.id);
48
+ if (matches) {
37
49
  decorations.push(Decoration.node(pos, pos + node.nodeSize, {},
38
50
  // no DOM attrs needed — the NodeView reads the decoration spec
39
51
  {
@@ -29,15 +29,27 @@ var AI_GENERATING_DECORATION_TYPE = 'ai-generating';
29
29
 
30
30
  /**
31
31
  * Build a DecorationSet containing a Decoration.node for every media node
32
- * whose `id` is in the given set.
32
+ * targeted by the given set.
33
+ *
34
+ * Targets are matched by `localId` first (the mediaSingle wrapper's or the media
35
+ * node's own) so that duplicate copies of the same image — which share a media
36
+ * file `id` — don't all get decorated; only the node the user acted on lights
37
+ * up. Falls back to the media file `id` for the CWR flow and for any node that
38
+ * has no localId yet.
33
39
  */
34
- function buildDecorationSet(doc, mediaIds) {
35
- if (mediaIds.size === 0) {
40
+ function buildDecorationSet(doc, targetIds) {
41
+ if (targetIds.size === 0) {
36
42
  return DecorationSet.empty;
37
43
  }
38
44
  var decorations = [];
39
- doc.descendants(function (node, pos) {
40
- if (node.type.name === 'media' && mediaIds.has(node.attrs.id)) {
45
+ doc.descendants(function (node, pos, parent) {
46
+ var _parent$attrs;
47
+ if (node.type.name !== 'media') {
48
+ return;
49
+ }
50
+ var wrapperLocalId = parent === null || parent === void 0 || (_parent$attrs = parent.attrs) === null || _parent$attrs === void 0 ? void 0 : _parent$attrs.localId;
51
+ var matches = wrapperLocalId && targetIds.has(wrapperLocalId) || node.attrs.localId && targetIds.has(node.attrs.localId) || targetIds.has(node.attrs.id);
52
+ if (matches) {
41
53
  decorations.push(Decoration.node(pos, pos + node.nodeSize, {},
42
54
  // no DOM attrs needed — the NodeView reads the decoration spec
43
55
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media",
3
- "version": "14.2.18",
3
+ "version": "14.3.0",
4
4
  "description": "Media plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -57,7 +57,7 @@
57
57
  "@atlaskit/platform-feature-flags": "^2.0.0",
58
58
  "@atlaskit/primitives": "^20.5.0",
59
59
  "@atlaskit/textfield": "^9.1.0",
60
- "@atlaskit/tmp-editor-statsig": "^124.0.0",
60
+ "@atlaskit/tmp-editor-statsig": "^124.1.0",
61
61
  "@atlaskit/tokens": "^15.5.0",
62
62
  "@atlaskit/tooltip": "^23.1.0",
63
63
  "@babel/runtime": "^7.0.0",