@atlaskit/editor-plugin-selection 1.1.3 → 1.2.1

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,21 @@
1
1
  # @atlaskit/editor-plugin-selection
2
2
 
3
+ ## 1.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#92552](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/92552) [`7cd874b858c8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7cd874b858c8) - Check target elements are actually HTMLElement rather than typecasting.
8
+
9
+ ## 1.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#91934](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/91934) [`b76a78c6a199`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b76a78c6a199) - bumped editor-prosemirror version to 4.0.0
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies
18
+
3
19
  ## 1.1.3
4
20
 
5
21
  ### Patch Changes
@@ -89,12 +89,12 @@ function getLayoutModeFromTargetNode(node) {
89
89
  return layout;
90
90
  }
91
91
  var isIgnoredClick = exports.isIgnoredClick = function isIgnoredClick(elem) {
92
- if (elem.nodeName === 'BUTTON' || elem.closest('button')) {
92
+ if ((elem === null || elem === void 0 ? void 0 : elem.nodeName) === 'BUTTON' || elem !== null && elem !== void 0 && elem.closest('button')) {
93
93
  return true;
94
94
  }
95
95
 
96
96
  // check if we're clicking an image caption placeholder
97
- if (elem.closest("[data-id=\"".concat(_mediaSingle.CAPTION_PLACEHOLDER_ID, "\"]"))) {
97
+ if (elem !== null && elem !== void 0 && elem.closest("[data-id=\"".concat(_mediaSingle.CAPTION_PLACEHOLDER_ID, "\"]"))) {
98
98
  return true;
99
99
  }
100
100
 
@@ -116,7 +116,7 @@ var isIgnoredClick = exports.isIgnoredClick = function isIgnoredClick(elem) {
116
116
 
117
117
  // Check if unsupported node selection
118
118
  // (without this, selection requires double clicking in FF due to posAtCoords differences)
119
- if (elem.closest(".".concat(_styles.UnsupportedSharedCssClassName.BLOCK_CONTAINER))) {
119
+ if (elem !== null && elem !== void 0 && elem.closest(".".concat(_styles.UnsupportedSharedCssClassName.BLOCK_CONTAINER))) {
120
120
  return true;
121
121
  }
122
122
  return false;
@@ -10,6 +10,7 @@ var _state = require("@atlaskit/editor-prosemirror/state");
10
10
  var _utils = require("@atlaskit/editor-prosemirror/utils");
11
11
  var _view2 = require("@atlaskit/editor-prosemirror/view");
12
12
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
13
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
14
  var _actions = require("../gap-cursor/actions");
14
15
  var _direction = require("../gap-cursor/direction");
15
16
  var _utils2 = require("../gap-cursor/utils");
@@ -112,8 +113,14 @@ var plugin = new _safePlugin.SafePlugin({
112
113
  left: event.clientX,
113
114
  top: event.clientY
114
115
  });
115
- if (!posAtCoords || (0, _utils2.isIgnoredClick)(event.target)) {
116
- return false;
116
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.explicit-html-element-check')) {
117
+ if (!posAtCoords || (0, _utils2.isIgnoredClick)(event.target instanceof HTMLElement ? event.target : null)) {
118
+ return false;
119
+ }
120
+ } else {
121
+ if (!posAtCoords || (0, _utils2.isIgnoredClick)(event.target)) {
122
+ return false;
123
+ }
117
124
  }
118
125
  var isInsideTheTarget = posAtCoords.pos === posAtCoords.inside;
119
126
  if (isInsideTheTarget) {
@@ -76,12 +76,12 @@ export function getLayoutModeFromTargetNode(node) {
76
76
  return layout;
77
77
  }
78
78
  export const isIgnoredClick = elem => {
79
- if (elem.nodeName === 'BUTTON' || elem.closest('button')) {
79
+ if ((elem === null || elem === void 0 ? void 0 : elem.nodeName) === 'BUTTON' || elem !== null && elem !== void 0 && elem.closest('button')) {
80
80
  return true;
81
81
  }
82
82
 
83
83
  // check if we're clicking an image caption placeholder
84
- if (elem.closest(`[data-id="${CAPTION_PLACEHOLDER_ID}"]`)) {
84
+ if (elem !== null && elem !== void 0 && elem.closest(`[data-id="${CAPTION_PLACEHOLDER_ID}"]`)) {
85
85
  return true;
86
86
  }
87
87
 
@@ -103,7 +103,7 @@ export const isIgnoredClick = elem => {
103
103
 
104
104
  // Check if unsupported node selection
105
105
  // (without this, selection requires double clicking in FF due to posAtCoords differences)
106
- if (elem.closest(`.${UnsupportedSharedCssClassName.BLOCK_CONTAINER}`)) {
106
+ if (elem !== null && elem !== void 0 && elem.closest(`.${UnsupportedSharedCssClassName.BLOCK_CONTAINER}`)) {
107
107
  return true;
108
108
  }
109
109
  return false;
@@ -4,6 +4,7 @@ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { findPositionOfNodeBefore } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
6
6
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
7
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
7
8
  import { deleteNode } from '../gap-cursor/actions';
8
9
  import { Direction } from '../gap-cursor/direction';
9
10
  import { getLayoutModeFromTargetNode, isIgnoredClick } from '../gap-cursor/utils';
@@ -110,8 +111,14 @@ const plugin = new SafePlugin({
110
111
  left: event.clientX,
111
112
  top: event.clientY
112
113
  });
113
- if (!posAtCoords || isIgnoredClick(event.target)) {
114
- return false;
114
+ if (getBooleanFF('platform.editor.explicit-html-element-check')) {
115
+ if (!posAtCoords || isIgnoredClick(event.target instanceof HTMLElement ? event.target : null)) {
116
+ return false;
117
+ }
118
+ } else {
119
+ if (!posAtCoords || isIgnoredClick(event.target)) {
120
+ return false;
121
+ }
115
122
  }
116
123
  const isInsideTheTarget = posAtCoords.pos === posAtCoords.inside;
117
124
  if (isInsideTheTarget) {
@@ -80,12 +80,12 @@ export function getLayoutModeFromTargetNode(node) {
80
80
  return layout;
81
81
  }
82
82
  export var isIgnoredClick = function isIgnoredClick(elem) {
83
- if (elem.nodeName === 'BUTTON' || elem.closest('button')) {
83
+ if ((elem === null || elem === void 0 ? void 0 : elem.nodeName) === 'BUTTON' || elem !== null && elem !== void 0 && elem.closest('button')) {
84
84
  return true;
85
85
  }
86
86
 
87
87
  // check if we're clicking an image caption placeholder
88
- if (elem.closest("[data-id=\"".concat(CAPTION_PLACEHOLDER_ID, "\"]"))) {
88
+ if (elem !== null && elem !== void 0 && elem.closest("[data-id=\"".concat(CAPTION_PLACEHOLDER_ID, "\"]"))) {
89
89
  return true;
90
90
  }
91
91
 
@@ -107,7 +107,7 @@ export var isIgnoredClick = function isIgnoredClick(elem) {
107
107
 
108
108
  // Check if unsupported node selection
109
109
  // (without this, selection requires double clicking in FF due to posAtCoords differences)
110
- if (elem.closest(".".concat(UnsupportedSharedCssClassName.BLOCK_CONTAINER))) {
110
+ if (elem !== null && elem !== void 0 && elem.closest(".".concat(UnsupportedSharedCssClassName.BLOCK_CONTAINER))) {
111
111
  return true;
112
112
  }
113
113
  return false;
@@ -4,6 +4,7 @@ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { findPositionOfNodeBefore } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
6
6
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
7
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
7
8
  import { deleteNode } from '../gap-cursor/actions';
8
9
  import { Direction } from '../gap-cursor/direction';
9
10
  import { getLayoutModeFromTargetNode, isIgnoredClick } from '../gap-cursor/utils';
@@ -106,8 +107,14 @@ var plugin = new SafePlugin({
106
107
  left: event.clientX,
107
108
  top: event.clientY
108
109
  });
109
- if (!posAtCoords || isIgnoredClick(event.target)) {
110
- return false;
110
+ if (getBooleanFF('platform.editor.explicit-html-element-check')) {
111
+ if (!posAtCoords || isIgnoredClick(event.target instanceof HTMLElement ? event.target : null)) {
112
+ return false;
113
+ }
114
+ } else {
115
+ if (!posAtCoords || isIgnoredClick(event.target)) {
116
+ return false;
117
+ }
111
118
  }
112
119
  var isInsideTheTarget = posAtCoords.pos === posAtCoords.inside;
113
120
  if (isInsideTheTarget) {
@@ -4,5 +4,5 @@ export declare const isLeftCursor: (side: Side) => side is Side.LEFT;
4
4
  export declare function getMediaNearPos(doc: PMNode, $pos: ResolvedPos, schema: Schema, dir?: number): PMNode | null;
5
5
  export declare const isTextBlockNearPos: (doc: PMNode, schema: Schema, $pos: ResolvedPos, dir: number) => boolean;
6
6
  export declare function getLayoutModeFromTargetNode(node: PMNode): string;
7
- export declare const isIgnoredClick: (elem: HTMLElement) => boolean;
7
+ export declare const isIgnoredClick: (elem: HTMLElement | null) => boolean | null;
8
8
  export declare const getComputedStyleForLayoutMode: (dom: HTMLElement, node: PMNode | undefined | null, style: CSSStyleDeclaration) => CSSStyleDeclaration;
@@ -4,5 +4,5 @@ export declare const isLeftCursor: (side: Side) => side is Side.LEFT;
4
4
  export declare function getMediaNearPos(doc: PMNode, $pos: ResolvedPos, schema: Schema, dir?: number): PMNode | null;
5
5
  export declare const isTextBlockNearPos: (doc: PMNode, schema: Schema, $pos: ResolvedPos, dir: number) => boolean;
6
6
  export declare function getLayoutModeFromTargetNode(node: PMNode): string;
7
- export declare const isIgnoredClick: (elem: HTMLElement) => boolean;
7
+ export declare const isIgnoredClick: (elem: HTMLElement | null) => boolean | null;
8
8
  export declare const getComputedStyleForLayoutMode: (dom: HTMLElement, node: PMNode | undefined | null, style: CSSStyleDeclaration) => CSSStyleDeclaration;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-selection",
3
- "version": "1.1.3",
3
+ "version": "1.2.1",
4
4
  "description": "Selection plugin for @atlaskit/editor-core",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -21,10 +21,10 @@
21
21
  "runReact18": false
22
22
  },
23
23
  "dependencies": {
24
- "@atlaskit/editor-common": "^78.29.0",
25
- "@atlaskit/editor-prosemirror": "3.0.0",
26
- "@atlaskit/editor-shared-styles": "^2.9.0",
27
- "@atlaskit/editor-tables": "^2.6.0",
24
+ "@atlaskit/editor-common": "^78.33.0",
25
+ "@atlaskit/editor-prosemirror": "4.0.0",
26
+ "@atlaskit/editor-shared-styles": "^2.10.0",
27
+ "@atlaskit/editor-tables": "^2.7.0",
28
28
  "@atlaskit/platform-feature-flags": "^0.2.4",
29
29
  "@babel/runtime": "^7.0.0"
30
30
  },
@@ -84,6 +84,9 @@
84
84
  },
85
85
  "platform.editor.single-player-expand": {
86
86
  "type": "boolean"
87
+ },
88
+ "platform.editor.explicit-html-element-check": {
89
+ "type": "boolean"
87
90
  }
88
91
  }
89
92
  }