@atlaskit/editor-core 216.7.16 → 216.7.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,14 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 216.7.17
4
+
5
+ ### Patch Changes
6
+
7
+ - [`e98a16b48e245`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e98a16b48e245) -
8
+ Fix a suspected bug where cross-origin selections would throw a dom security error when testing
9
+ whether to set focus
10
+ - Updated dependencies
11
+
3
12
  ## 216.7.16
4
13
 
5
14
  ### Patch Changes
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.handleEditorFocus = handleEditorFocus;
7
7
  var _state = require("@atlaskit/editor-prosemirror/state");
8
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
8
9
  function handleEditorFocus(view) {
9
10
  var _domSelection$getRang;
10
11
  if (view !== null && view !== void 0 && view.hasFocus()) {
@@ -34,9 +35,24 @@ function handleEditorFocus(view) {
34
35
  }
35
36
 
36
37
  // if selection is outside editor focus and exit
37
- if (view && range !== null && range !== void 0 && range.startContainer.contains(view.dom)) {
38
- view.focus();
39
- return;
38
+ try {
39
+ if (view && range !== null && range !== void 0 && range.startContainer.contains(view.dom)) {
40
+ view.focus();
41
+ return;
42
+ }
43
+ } catch (error) {
44
+ // If we get a SecurityError-type DOMException here, then we probably just tried to
45
+ // access a cross-origin iframe's contents. In that case, we can ignore the error and
46
+ // just reasonably assume the selection is outside the editor, since we can't access it.
47
+ if (error instanceof DOMException && error.name === 'SecurityError' && (0, _expValEquals.expValEquals)('platform_editor_fix_cross_origin_editor_focus', 'isEnabled', true)) {
48
+ if (view) {
49
+ view.focus();
50
+ return;
51
+ }
52
+ } else {
53
+ // re-throw other unexpected errors
54
+ throw error;
55
+ }
40
56
  }
41
57
 
42
58
  // set cursor/selection and focus
@@ -1,4 +1,5 @@
1
1
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
2
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
2
3
  export function handleEditorFocus(view) {
3
4
  var _domSelection$getRang;
4
5
  if (view !== null && view !== void 0 && view.hasFocus()) {
@@ -28,9 +29,24 @@ export function handleEditorFocus(view) {
28
29
  }
29
30
 
30
31
  // if selection is outside editor focus and exit
31
- if (view && range !== null && range !== void 0 && range.startContainer.contains(view.dom)) {
32
- view.focus();
33
- return;
32
+ try {
33
+ if (view && range !== null && range !== void 0 && range.startContainer.contains(view.dom)) {
34
+ view.focus();
35
+ return;
36
+ }
37
+ } catch (error) {
38
+ // If we get a SecurityError-type DOMException here, then we probably just tried to
39
+ // access a cross-origin iframe's contents. In that case, we can ignore the error and
40
+ // just reasonably assume the selection is outside the editor, since we can't access it.
41
+ if (error instanceof DOMException && error.name === 'SecurityError' && expValEquals('platform_editor_fix_cross_origin_editor_focus', 'isEnabled', true)) {
42
+ if (view) {
43
+ view.focus();
44
+ return;
45
+ }
46
+ } else {
47
+ // re-throw other unexpected errors
48
+ throw error;
49
+ }
34
50
  }
35
51
 
36
52
  // set cursor/selection and focus
@@ -1,4 +1,5 @@
1
1
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
2
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
2
3
  export function handleEditorFocus(view) {
3
4
  var _domSelection$getRang;
4
5
  if (view !== null && view !== void 0 && view.hasFocus()) {
@@ -28,9 +29,24 @@ export function handleEditorFocus(view) {
28
29
  }
29
30
 
30
31
  // if selection is outside editor focus and exit
31
- if (view && range !== null && range !== void 0 && range.startContainer.contains(view.dom)) {
32
- view.focus();
33
- return;
32
+ try {
33
+ if (view && range !== null && range !== void 0 && range.startContainer.contains(view.dom)) {
34
+ view.focus();
35
+ return;
36
+ }
37
+ } catch (error) {
38
+ // If we get a SecurityError-type DOMException here, then we probably just tried to
39
+ // access a cross-origin iframe's contents. In that case, we can ignore the error and
40
+ // just reasonably assume the selection is outside the editor, since we can't access it.
41
+ if (error instanceof DOMException && error.name === 'SecurityError' && expValEquals('platform_editor_fix_cross_origin_editor_focus', 'isEnabled', true)) {
42
+ if (view) {
43
+ view.focus();
44
+ return;
45
+ }
46
+ } else {
47
+ // re-throw other unexpected errors
48
+ throw error;
49
+ }
34
50
  }
35
51
 
36
52
  // set cursor/selection and focus
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "216.7.16",
3
+ "version": "216.7.17",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -66,7 +66,7 @@
66
66
  "@atlaskit/platform-feature-flags-react": "^0.4.0",
67
67
  "@atlaskit/react-ufo": "^5.0.0",
68
68
  "@atlaskit/task-decision": "^19.2.0",
69
- "@atlaskit/tmp-editor-statsig": "^17.7.0",
69
+ "@atlaskit/tmp-editor-statsig": "^17.8.0",
70
70
  "@atlaskit/tokens": "^10.1.0",
71
71
  "@atlaskit/tooltip": "^20.14.0",
72
72
  "@atlaskit/width-detector": "^5.0.0",
@@ -107,7 +107,7 @@
107
107
  "@atlaskit/media-integration-test-helpers": "workspace:^",
108
108
  "@atlaskit/media-test-helpers": "^39.0.0",
109
109
  "@atlaskit/modal-dialog": "^14.10.0",
110
- "@atlaskit/renderer": "^126.4.0",
110
+ "@atlaskit/renderer": "^126.5.0",
111
111
  "@atlaskit/section-message": "^8.12.0",
112
112
  "@atlaskit/synchrony-test-helpers": "workspace:^",
113
113
  "@atlaskit/toggle": "^15.2.0",