@atlaskit/editor-plugin-media-insert 6.2.4 → 6.2.5

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,14 @@
1
1
  # @atlaskit/editor-plugin-media-insert
2
2
 
3
+ ## 6.2.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#144658](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/144658)
8
+ [`e59e7f0ae0803`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e59e7f0ae0803) -
9
+ Change to use getDomRefFromSelection utility from editor-common
10
+ - Updated dependencies
11
+
3
12
  ## 6.2.4
4
13
 
5
14
  ### Patch Changes
@@ -10,10 +10,10 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
10
10
  var _react = _interopRequireDefault(require("react"));
11
11
  var _reactIntlNext = require("react-intl-next");
12
12
  var _analytics = require("@atlaskit/editor-common/analytics");
13
+ var _getDomRefFromSelection = require("@atlaskit/editor-common/get-dom-ref-from-selection");
13
14
  var _hooks = require("@atlaskit/editor-common/hooks");
14
15
  var _messages = require("@atlaskit/editor-common/messages");
15
16
  var _ui = require("@atlaskit/editor-common/ui");
16
- var _utils = require("@atlaskit/editor-prosemirror/utils");
17
17
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
18
18
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
19
19
  var _compiled = require("@atlaskit/primitives/compiled");
@@ -27,36 +27,6 @@ var _MediaInsertWrapper = require("./MediaInsertWrapper");
27
27
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
28
28
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
29
29
  var PopupWithListeners = (0, _ui.withOuterListeners)(_ui.Popup);
30
- var getDomRefFromSelection = function getDomRefFromSelection(view, dispatchAnalyticsEvent) {
31
- try {
32
- var domRef = (0, _utils.findDomRefAtPos)(view.state.selection.from, view.domAtPos.bind(view));
33
- if (domRef instanceof HTMLElement) {
34
- // If element is not a paragraph, we need to find the closest paragraph parent
35
- if (domRef.nodeName !== 'P') {
36
- var paragraphRef = domRef.closest('p');
37
- if (paragraphRef) {
38
- return paragraphRef;
39
- }
40
- }
41
- return domRef;
42
- } else {
43
- throw new Error('Invalid DOM reference');
44
- }
45
- } catch (error) {
46
- if (dispatchAnalyticsEvent) {
47
- var payload = {
48
- action: _analytics.ACTION.ERRORED,
49
- actionSubject: _analytics.ACTION_SUBJECT.PICKER,
50
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.PICKER_MEDIA,
51
- eventType: _analytics.EVENT_TYPE.OPERATIONAL,
52
- attributes: {
53
- error: 'Error getting DOM reference from selection'
54
- }
55
- };
56
- dispatchAnalyticsEvent(payload);
57
- }
58
- }
59
- };
60
30
 
61
31
  /**
62
32
  * A custom TabPanel that is non-focusable.
@@ -96,8 +66,9 @@ var MediaInsertPicker = exports.MediaInsertPicker = function MediaInsertPicker(_
96
66
  targetRef = mountInfo.ref;
97
67
  mountPoint = mountInfo.mountPoint;
98
68
  } else {
69
+ var _api$analytics;
99
70
  // If targetRef is undefined, target the selection in the editor
100
- targetRef = getDomRefFromSelection(editorView, dispatchAnalyticsEvent);
71
+ targetRef = (0, _getDomRefFromSelection.getDomRefFromSelection)(editorView, _analytics.ACTION_SUBJECT_ID.PICKER_MEDIA, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
101
72
  mountPoint = popupsMountPoint;
102
73
  }
103
74
  var mediaProvider = (_useSharedPluginState3 = (0, _hooks.useSharedPluginState)(api, ['media'])) === null || _useSharedPluginState3 === void 0 || (_useSharedPluginState3 = _useSharedPluginState3.mediaState) === null || _useSharedPluginState3 === void 0 ? void 0 : _useSharedPluginState3.mediaProvider;
@@ -2,10 +2,10 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
3
  import { useIntl } from 'react-intl-next';
4
4
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
+ import { getDomRefFromSelection } from '@atlaskit/editor-common/get-dom-ref-from-selection';
5
6
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
6
7
  import { mediaInsertMessages } from '@atlaskit/editor-common/messages';
7
8
  import { PlainOutsideClickTargetRefContext, Popup, withOuterListeners } from '@atlaskit/editor-common/ui';
8
- import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
9
9
  import { akEditorFloatingDialogZIndex } from '@atlaskit/editor-shared-styles';
10
10
  import { fg } from '@atlaskit/platform-feature-flags';
11
11
  import { Box } from '@atlaskit/primitives/compiled';
@@ -17,36 +17,6 @@ import { MediaFromURL } from './MediaFromURL';
17
17
  import { MediaFromURLWithForm } from './MediaFromURLWithForm';
18
18
  import { MediaInsertWrapper } from './MediaInsertWrapper';
19
19
  const PopupWithListeners = withOuterListeners(Popup);
20
- const getDomRefFromSelection = (view, dispatchAnalyticsEvent) => {
21
- try {
22
- const domRef = findDomRefAtPos(view.state.selection.from, view.domAtPos.bind(view));
23
- if (domRef instanceof HTMLElement) {
24
- // If element is not a paragraph, we need to find the closest paragraph parent
25
- if (domRef.nodeName !== 'P') {
26
- const paragraphRef = domRef.closest('p');
27
- if (paragraphRef) {
28
- return paragraphRef;
29
- }
30
- }
31
- return domRef;
32
- } else {
33
- throw new Error('Invalid DOM reference');
34
- }
35
- } catch (error) {
36
- if (dispatchAnalyticsEvent) {
37
- const payload = {
38
- action: ACTION.ERRORED,
39
- actionSubject: ACTION_SUBJECT.PICKER,
40
- actionSubjectId: ACTION_SUBJECT_ID.PICKER_MEDIA,
41
- eventType: EVENT_TYPE.OPERATIONAL,
42
- attributes: {
43
- error: 'Error getting DOM reference from selection'
44
- }
45
- };
46
- dispatchAnalyticsEvent(payload);
47
- }
48
- }
49
- };
50
20
 
51
21
  /**
52
22
  * A custom TabPanel that is non-focusable.
@@ -89,8 +59,9 @@ export const MediaInsertPicker = ({
89
59
  targetRef = mountInfo.ref;
90
60
  mountPoint = mountInfo.mountPoint;
91
61
  } else {
62
+ var _api$analytics;
92
63
  // If targetRef is undefined, target the selection in the editor
93
- targetRef = getDomRefFromSelection(editorView, dispatchAnalyticsEvent);
64
+ targetRef = getDomRefFromSelection(editorView, ACTION_SUBJECT_ID.PICKER_MEDIA, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
94
65
  mountPoint = popupsMountPoint;
95
66
  }
96
67
  const mediaProvider = (_useSharedPluginState3 = useSharedPluginState(api, ['media'])) === null || _useSharedPluginState3 === void 0 ? void 0 : (_useSharedPluginState4 = _useSharedPluginState3.mediaState) === null || _useSharedPluginState4 === void 0 ? void 0 : _useSharedPluginState4.mediaProvider;
@@ -2,10 +2,10 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
3
  import { useIntl } from 'react-intl-next';
4
4
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
+ import { getDomRefFromSelection } from '@atlaskit/editor-common/get-dom-ref-from-selection';
5
6
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
6
7
  import { mediaInsertMessages } from '@atlaskit/editor-common/messages';
7
8
  import { PlainOutsideClickTargetRefContext, Popup, withOuterListeners } from '@atlaskit/editor-common/ui';
8
- import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
9
9
  import { akEditorFloatingDialogZIndex } from '@atlaskit/editor-shared-styles';
10
10
  import { fg } from '@atlaskit/platform-feature-flags';
11
11
  import { Box } from '@atlaskit/primitives/compiled';
@@ -17,36 +17,6 @@ import { MediaFromURL } from './MediaFromURL';
17
17
  import { MediaFromURLWithForm } from './MediaFromURLWithForm';
18
18
  import { MediaInsertWrapper } from './MediaInsertWrapper';
19
19
  var PopupWithListeners = withOuterListeners(Popup);
20
- var getDomRefFromSelection = function getDomRefFromSelection(view, dispatchAnalyticsEvent) {
21
- try {
22
- var domRef = findDomRefAtPos(view.state.selection.from, view.domAtPos.bind(view));
23
- if (domRef instanceof HTMLElement) {
24
- // If element is not a paragraph, we need to find the closest paragraph parent
25
- if (domRef.nodeName !== 'P') {
26
- var paragraphRef = domRef.closest('p');
27
- if (paragraphRef) {
28
- return paragraphRef;
29
- }
30
- }
31
- return domRef;
32
- } else {
33
- throw new Error('Invalid DOM reference');
34
- }
35
- } catch (error) {
36
- if (dispatchAnalyticsEvent) {
37
- var payload = {
38
- action: ACTION.ERRORED,
39
- actionSubject: ACTION_SUBJECT.PICKER,
40
- actionSubjectId: ACTION_SUBJECT_ID.PICKER_MEDIA,
41
- eventType: EVENT_TYPE.OPERATIONAL,
42
- attributes: {
43
- error: 'Error getting DOM reference from selection'
44
- }
45
- };
46
- dispatchAnalyticsEvent(payload);
47
- }
48
- }
49
- };
50
20
 
51
21
  /**
52
22
  * A custom TabPanel that is non-focusable.
@@ -86,8 +56,9 @@ export var MediaInsertPicker = function MediaInsertPicker(_ref2) {
86
56
  targetRef = mountInfo.ref;
87
57
  mountPoint = mountInfo.mountPoint;
88
58
  } else {
59
+ var _api$analytics;
89
60
  // If targetRef is undefined, target the selection in the editor
90
- targetRef = getDomRefFromSelection(editorView, dispatchAnalyticsEvent);
61
+ targetRef = getDomRefFromSelection(editorView, ACTION_SUBJECT_ID.PICKER_MEDIA, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
91
62
  mountPoint = popupsMountPoint;
92
63
  }
93
64
  var mediaProvider = (_useSharedPluginState3 = useSharedPluginState(api, ['media'])) === null || _useSharedPluginState3 === void 0 || (_useSharedPluginState3 = _useSharedPluginState3.mediaState) === null || _useSharedPluginState3 === void 0 ? void 0 : _useSharedPluginState3.mediaProvider;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media-insert",
3
- "version": "6.2.4",
3
+ "version": "6.2.5",
4
4
  "description": "Media Insert plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "@atlaskit/adf-schema": "^47.6.0",
29
29
  "@atlaskit/button": "^23.0.0",
30
- "@atlaskit/editor-common": "^103.12.0",
30
+ "@atlaskit/editor-common": "^103.19.0",
31
31
  "@atlaskit/editor-plugin-analytics": "^2.2.0",
32
32
  "@atlaskit/editor-plugin-media": "^2.6.0",
33
33
  "@atlaskit/editor-prosemirror": "7.0.0",
@@ -43,7 +43,7 @@
43
43
  "@atlaskit/section-message": "^8.2.0",
44
44
  "@atlaskit/tabs": "^18.0.0",
45
45
  "@atlaskit/textfield": "^8.0.0",
46
- "@atlaskit/tmp-editor-statsig": "^4.12.0",
46
+ "@atlaskit/tmp-editor-statsig": "^4.15.0",
47
47
  "@babel/runtime": "^7.0.0",
48
48
  "react-intl-next": "npm:react-intl@^5.18.1"
49
49
  },