@atlaskit/editor-plugin-media 8.4.16 → 8.4.17

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
+ ## 8.4.17
4
+
5
+ ### Patch Changes
6
+
7
+ - [`1083b6f1f8eb2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1083b6f1f8eb2) -
8
+ [ux] Fix issues where media is selected when a parent node is selected
9
+ - Updated dependencies
10
+
3
11
  ## 8.4.16
4
12
 
5
13
  ### Patch Changes
@@ -936,7 +936,7 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
936
936
  doc = state.doc;
937
937
 
938
938
  // Find any media nodes in the current selection
939
- if (state.selection instanceof _state2.TextSelection || state.selection instanceof _state2.AllSelection || state.selection instanceof _state2.NodeSelection || state.selection instanceof _cellSelection.CellSelection) {
939
+ if (state.selection instanceof _state2.TextSelection || state.selection instanceof _state2.AllSelection || !(0, _expValEquals.expValEquals)('platform_editor_nested_media_selection_fix', 'isEnabled', true) && state.selection instanceof _state2.NodeSelection || state.selection instanceof _cellSelection.CellSelection) {
940
940
  doc.nodesBetween(state.selection.from, state.selection.to, function (node, pos) {
941
941
  if (node.type === schema.nodes.media) {
942
942
  mediaNodes.push(_view2.Decoration.node(pos, pos + node.nodeSize, {}, {
@@ -947,6 +947,22 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
947
947
  }
948
948
  return true;
949
949
  });
950
+ } else if ((0, _expValEquals.expValEquals)('platform_editor_nested_media_selection_fix', 'isEnabled', true) && state.selection instanceof _state2.NodeSelection) {
951
+ var _state$selection = state.selection,
952
+ node = _state$selection.node,
953
+ $from = _state$selection.$from;
954
+ if (node.type === schema.nodes.mediaSingle || node.type === schema.nodes.mediaGroup) {
955
+ doc.nodesBetween($from.pos, $from.pos + node.nodeSize, function (mediaNode, mediaPos) {
956
+ if (mediaNode.type === schema.nodes.media) {
957
+ mediaNodes.push(_view2.Decoration.node(mediaPos, mediaPos + mediaNode.nodeSize, {}, {
958
+ type: 'media',
959
+ selected: true
960
+ }));
961
+ return false;
962
+ }
963
+ return true;
964
+ });
965
+ }
950
966
  }
951
967
  var pluginState = getMediaPluginState(state);
952
968
  if (!pluginState.showDropzone) {
@@ -955,8 +971,8 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
955
971
 
956
972
  // When a media is already selected
957
973
  if (state.selection instanceof _state2.NodeSelection) {
958
- var node = state.selection.node;
959
- if (node.type === schema.nodes.mediaSingle) {
974
+ var _node = state.selection.node;
975
+ if (_node.type === schema.nodes.mediaSingle) {
960
976
  var deco = _view2.Decoration.node(state.selection.from, state.selection.to, {
961
977
  class: 'richMedia-selected'
962
978
  });
@@ -824,7 +824,7 @@ export const createPlugin = (_schema, options, getIntl, pluginInjectionApi, node
824
824
  } = state;
825
825
 
826
826
  // Find any media nodes in the current selection
827
- if (state.selection instanceof TextSelection || state.selection instanceof AllSelection || state.selection instanceof NodeSelection || state.selection instanceof CellSelection) {
827
+ if (state.selection instanceof TextSelection || state.selection instanceof AllSelection || !expValEquals('platform_editor_nested_media_selection_fix', 'isEnabled', true) && state.selection instanceof NodeSelection || state.selection instanceof CellSelection) {
828
828
  doc.nodesBetween(state.selection.from, state.selection.to, (node, pos) => {
829
829
  if (node.type === schema.nodes.media) {
830
830
  mediaNodes.push(Decoration.node(pos, pos + node.nodeSize, {}, {
@@ -835,6 +835,23 @@ export const createPlugin = (_schema, options, getIntl, pluginInjectionApi, node
835
835
  }
836
836
  return true;
837
837
  });
838
+ } else if (expValEquals('platform_editor_nested_media_selection_fix', 'isEnabled', true) && state.selection instanceof NodeSelection) {
839
+ const {
840
+ node,
841
+ $from
842
+ } = state.selection;
843
+ if (node.type === schema.nodes.mediaSingle || node.type === schema.nodes.mediaGroup) {
844
+ doc.nodesBetween($from.pos, $from.pos + node.nodeSize, (mediaNode, mediaPos) => {
845
+ if (mediaNode.type === schema.nodes.media) {
846
+ mediaNodes.push(Decoration.node(mediaPos, mediaPos + mediaNode.nodeSize, {}, {
847
+ type: 'media',
848
+ selected: true
849
+ }));
850
+ return false;
851
+ }
852
+ return true;
853
+ });
854
+ }
838
855
  }
839
856
  const pluginState = getMediaPluginState(state);
840
857
  if (!pluginState.showDropzone) {
@@ -928,7 +928,7 @@ export var createPlugin = function createPlugin(_schema, options, getIntl, plugi
928
928
  doc = state.doc;
929
929
 
930
930
  // Find any media nodes in the current selection
931
- if (state.selection instanceof TextSelection || state.selection instanceof AllSelection || state.selection instanceof NodeSelection || state.selection instanceof CellSelection) {
931
+ if (state.selection instanceof TextSelection || state.selection instanceof AllSelection || !expValEquals('platform_editor_nested_media_selection_fix', 'isEnabled', true) && state.selection instanceof NodeSelection || state.selection instanceof CellSelection) {
932
932
  doc.nodesBetween(state.selection.from, state.selection.to, function (node, pos) {
933
933
  if (node.type === schema.nodes.media) {
934
934
  mediaNodes.push(Decoration.node(pos, pos + node.nodeSize, {}, {
@@ -939,6 +939,22 @@ export var createPlugin = function createPlugin(_schema, options, getIntl, plugi
939
939
  }
940
940
  return true;
941
941
  });
942
+ } else if (expValEquals('platform_editor_nested_media_selection_fix', 'isEnabled', true) && state.selection instanceof NodeSelection) {
943
+ var _state$selection = state.selection,
944
+ node = _state$selection.node,
945
+ $from = _state$selection.$from;
946
+ if (node.type === schema.nodes.mediaSingle || node.type === schema.nodes.mediaGroup) {
947
+ doc.nodesBetween($from.pos, $from.pos + node.nodeSize, function (mediaNode, mediaPos) {
948
+ if (mediaNode.type === schema.nodes.media) {
949
+ mediaNodes.push(Decoration.node(mediaPos, mediaPos + mediaNode.nodeSize, {}, {
950
+ type: 'media',
951
+ selected: true
952
+ }));
953
+ return false;
954
+ }
955
+ return true;
956
+ });
957
+ }
942
958
  }
943
959
  var pluginState = getMediaPluginState(state);
944
960
  if (!pluginState.showDropzone) {
@@ -947,8 +963,8 @@ export var createPlugin = function createPlugin(_schema, options, getIntl, plugi
947
963
 
948
964
  // When a media is already selected
949
965
  if (state.selection instanceof NodeSelection) {
950
- var node = state.selection.node;
951
- if (node.type === schema.nodes.mediaSingle) {
966
+ var _node = state.selection.node;
967
+ if (_node.type === schema.nodes.mediaSingle) {
952
968
  var deco = Decoration.node(state.selection.from, state.selection.to, {
953
969
  class: 'richMedia-selected'
954
970
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media",
3
- "version": "8.4.16",
3
+ "version": "8.4.17",
4
4
  "description": "Media plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -66,7 +66,7 @@
66
66
  "@atlaskit/primitives": "^16.4.0",
67
67
  "@atlaskit/textfield": "^8.1.0",
68
68
  "@atlaskit/theme": "^21.0.0",
69
- "@atlaskit/tmp-editor-statsig": "^14.5.0",
69
+ "@atlaskit/tmp-editor-statsig": "^14.6.0",
70
70
  "@atlaskit/tokens": "^8.4.0",
71
71
  "@atlaskit/tooltip": "^20.10.0",
72
72
  "@babel/runtime": "^7.0.0",