@atlaskit/editor-plugin-paste-options-toolbar 9.1.11 → 9.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,22 @@
1
1
  # @atlaskit/editor-plugin-paste-options-toolbar
2
2
 
3
+ ## 9.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 9.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`f320bfec5b28f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f320bfec5b28f) -
14
+ Hide AI paste actions when pasted content contains a table.
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+
3
20
  ## 9.1.11
4
21
 
5
22
  ### Patch Changes
@@ -107,7 +107,7 @@ var pasteOptionsToolbarPlugin = exports.pasteOptionsToolbarPlugin = function pas
107
107
  (0, _react.useEffect)(function () {
108
108
  if (config !== null && config !== void 0 && config.usePopupBasedPasteActionsMenu && (0, _platformFeatureFlags.fg)('platform_editor_paste_actions_menu_exposure')) {
109
109
  var _lastContentPasted$te, _lastContentPasted$te2;
110
- (0, _exposure.firePasteActionsMenuExperimentExposure)((_lastContentPasted$te = lastContentPasted === null || lastContentPasted === void 0 || (_lastContentPasted$te2 = lastContentPasted.text) === null || _lastContentPasted$te2 === void 0 ? void 0 : _lastContentPasted$te2.length) !== null && _lastContentPasted$te !== void 0 ? _lastContentPasted$te : 0, editorView.state, lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.pasteStartPos, lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.pasteEndPos, lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.text);
110
+ (0, _exposure.firePasteActionsMenuExperimentExposure)((_lastContentPasted$te = lastContentPasted === null || lastContentPasted === void 0 || (_lastContentPasted$te2 = lastContentPasted.text) === null || _lastContentPasted$te2 === void 0 ? void 0 : _lastContentPasted$te2.length) !== null && _lastContentPasted$te !== void 0 ? _lastContentPasted$te : 0, editorView.state, lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.pasteStartPos, lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.pasteEndPos, lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.text, lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.pastedSlice);
111
111
  }
112
112
  if (config !== null && config !== void 0 && config.usePopupBasedPasteActionsMenu && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_paste_actions_menu', 'isEnabled', true)) {
113
113
  return;
@@ -5,6 +5,20 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.firePasteActionsMenuExperimentExposure = void 0;
7
7
  var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
8
+ var hasTableNode = function hasTableNode(slice) {
9
+ if (!slice) {
10
+ return false;
11
+ }
12
+ var found = false;
13
+ slice.content.descendants(function (node) {
14
+ if (node.type.name === 'table') {
15
+ found = true;
16
+ return false;
17
+ }
18
+ return true;
19
+ });
20
+ return found;
21
+ };
8
22
  var isNotProse = function isNotProse(text) {
9
23
  var trimmed = text.trim();
10
24
  if (!trimmed) {
@@ -29,18 +43,22 @@ var isNotProse = function isNotProse(text) {
29
43
  return true;
30
44
  };
31
45
 
46
+ // Remove this file when experiment `platform_editor_paste_actions_menu` is cleaned up.
32
47
  // Manual exposure event for `platform_editor_paste_actions_menu`. Due to the fact that as part of this experiment
33
48
  // the paste menu was completely redesigned, it was very difficult to ensure that an exposure event fires accurately
34
49
  // for both control and test cohorts without executing code paths for both menus.
35
50
  // This manual exposure event executes all criteria for showing AI buttons and fires the exposure manually in a code path that
36
51
  // is guaranteed to execute on both control and test.
37
- var firePasteActionsMenuExperimentExposure = exports.firePasteActionsMenuExperimentExposure = function firePasteActionsMenuExperimentExposure(contentLength, state, pasteStartPos, pasteEndPos, pastedText) {
52
+ var firePasteActionsMenuExperimentExposure = exports.firePasteActionsMenuExperimentExposure = function firePasteActionsMenuExperimentExposure(contentLength, state, pasteStartPos, pasteEndPos, pastedText, pastedSlice) {
38
53
  if (contentLength < 100 || !pasteStartPos || !pasteEndPos || !pastedText) {
39
54
  return;
40
55
  }
41
56
  if (isNotProse(pastedText)) {
42
57
  return;
43
58
  }
59
+ if (hasTableNode(pastedSlice)) {
60
+ return;
61
+ }
44
62
  try {
45
63
  var $pos = state.doc.resolve(pasteStartPos);
46
64
  var pasteAncestorNodeNames = [];
@@ -102,7 +102,7 @@ export const pasteOptionsToolbarPlugin = ({
102
102
  useEffect(() => {
103
103
  if (config !== null && config !== void 0 && config.usePopupBasedPasteActionsMenu && fg('platform_editor_paste_actions_menu_exposure')) {
104
104
  var _lastContentPasted$te, _lastContentPasted$te2;
105
- firePasteActionsMenuExperimentExposure((_lastContentPasted$te = lastContentPasted === null || lastContentPasted === void 0 ? void 0 : (_lastContentPasted$te2 = lastContentPasted.text) === null || _lastContentPasted$te2 === void 0 ? void 0 : _lastContentPasted$te2.length) !== null && _lastContentPasted$te !== void 0 ? _lastContentPasted$te : 0, editorView.state, lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.pasteStartPos, lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.pasteEndPos, lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.text);
105
+ firePasteActionsMenuExperimentExposure((_lastContentPasted$te = lastContentPasted === null || lastContentPasted === void 0 ? void 0 : (_lastContentPasted$te2 = lastContentPasted.text) === null || _lastContentPasted$te2 === void 0 ? void 0 : _lastContentPasted$te2.length) !== null && _lastContentPasted$te !== void 0 ? _lastContentPasted$te : 0, editorView.state, lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.pasteStartPos, lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.pasteEndPos, lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.text, lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.pastedSlice);
106
106
  }
107
107
  if (config !== null && config !== void 0 && config.usePopupBasedPasteActionsMenu && expValEqualsNoExposure('platform_editor_paste_actions_menu', 'isEnabled', true)) {
108
108
  return;
@@ -1,4 +1,18 @@
1
1
  import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
2
+ const hasTableNode = slice => {
3
+ if (!slice) {
4
+ return false;
5
+ }
6
+ let found = false;
7
+ slice.content.descendants(node => {
8
+ if (node.type.name === 'table') {
9
+ found = true;
10
+ return false;
11
+ }
12
+ return true;
13
+ });
14
+ return found;
15
+ };
2
16
  const isNotProse = text => {
3
17
  const trimmed = text.trim();
4
18
  if (!trimmed) {
@@ -23,18 +37,22 @@ const isNotProse = text => {
23
37
  return true;
24
38
  };
25
39
 
40
+ // Remove this file when experiment `platform_editor_paste_actions_menu` is cleaned up.
26
41
  // Manual exposure event for `platform_editor_paste_actions_menu`. Due to the fact that as part of this experiment
27
42
  // the paste menu was completely redesigned, it was very difficult to ensure that an exposure event fires accurately
28
43
  // for both control and test cohorts without executing code paths for both menus.
29
44
  // This manual exposure event executes all criteria for showing AI buttons and fires the exposure manually in a code path that
30
45
  // is guaranteed to execute on both control and test.
31
- export const firePasteActionsMenuExperimentExposure = (contentLength, state, pasteStartPos, pasteEndPos, pastedText) => {
46
+ export const firePasteActionsMenuExperimentExposure = (contentLength, state, pasteStartPos, pasteEndPos, pastedText, pastedSlice) => {
32
47
  if (contentLength < 100 || !pasteStartPos || !pasteEndPos || !pastedText) {
33
48
  return;
34
49
  }
35
50
  if (isNotProse(pastedText)) {
36
51
  return;
37
52
  }
53
+ if (hasTableNode(pastedSlice)) {
54
+ return;
55
+ }
38
56
  try {
39
57
  const $pos = state.doc.resolve(pasteStartPos);
40
58
  const pasteAncestorNodeNames = [];
@@ -99,7 +99,7 @@ export var pasteOptionsToolbarPlugin = function pasteOptionsToolbarPlugin(_ref)
99
99
  useEffect(function () {
100
100
  if (config !== null && config !== void 0 && config.usePopupBasedPasteActionsMenu && fg('platform_editor_paste_actions_menu_exposure')) {
101
101
  var _lastContentPasted$te, _lastContentPasted$te2;
102
- firePasteActionsMenuExperimentExposure((_lastContentPasted$te = lastContentPasted === null || lastContentPasted === void 0 || (_lastContentPasted$te2 = lastContentPasted.text) === null || _lastContentPasted$te2 === void 0 ? void 0 : _lastContentPasted$te2.length) !== null && _lastContentPasted$te !== void 0 ? _lastContentPasted$te : 0, editorView.state, lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.pasteStartPos, lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.pasteEndPos, lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.text);
102
+ firePasteActionsMenuExperimentExposure((_lastContentPasted$te = lastContentPasted === null || lastContentPasted === void 0 || (_lastContentPasted$te2 = lastContentPasted.text) === null || _lastContentPasted$te2 === void 0 ? void 0 : _lastContentPasted$te2.length) !== null && _lastContentPasted$te !== void 0 ? _lastContentPasted$te : 0, editorView.state, lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.pasteStartPos, lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.pasteEndPos, lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.text, lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.pastedSlice);
103
103
  }
104
104
  if (config !== null && config !== void 0 && config.usePopupBasedPasteActionsMenu && expValEqualsNoExposure('platform_editor_paste_actions_menu', 'isEnabled', true)) {
105
105
  return;
@@ -1,4 +1,18 @@
1
1
  import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
2
+ var hasTableNode = function hasTableNode(slice) {
3
+ if (!slice) {
4
+ return false;
5
+ }
6
+ var found = false;
7
+ slice.content.descendants(function (node) {
8
+ if (node.type.name === 'table') {
9
+ found = true;
10
+ return false;
11
+ }
12
+ return true;
13
+ });
14
+ return found;
15
+ };
2
16
  var isNotProse = function isNotProse(text) {
3
17
  var trimmed = text.trim();
4
18
  if (!trimmed) {
@@ -23,18 +37,22 @@ var isNotProse = function isNotProse(text) {
23
37
  return true;
24
38
  };
25
39
 
40
+ // Remove this file when experiment `platform_editor_paste_actions_menu` is cleaned up.
26
41
  // Manual exposure event for `platform_editor_paste_actions_menu`. Due to the fact that as part of this experiment
27
42
  // the paste menu was completely redesigned, it was very difficult to ensure that an exposure event fires accurately
28
43
  // for both control and test cohorts without executing code paths for both menus.
29
44
  // This manual exposure event executes all criteria for showing AI buttons and fires the exposure manually in a code path that
30
45
  // is guaranteed to execute on both control and test.
31
- export var firePasteActionsMenuExperimentExposure = function firePasteActionsMenuExperimentExposure(contentLength, state, pasteStartPos, pasteEndPos, pastedText) {
46
+ export var firePasteActionsMenuExperimentExposure = function firePasteActionsMenuExperimentExposure(contentLength, state, pasteStartPos, pasteEndPos, pastedText, pastedSlice) {
32
47
  if (contentLength < 100 || !pasteStartPos || !pasteEndPos || !pastedText) {
33
48
  return;
34
49
  }
35
50
  if (isNotProse(pastedText)) {
36
51
  return;
37
52
  }
53
+ if (hasTableNode(pastedSlice)) {
54
+ return;
55
+ }
38
56
  try {
39
57
  var $pos = state.doc.resolve(pasteStartPos);
40
58
  var pasteAncestorNodeNames = [];
@@ -1,2 +1,3 @@
1
+ import type { Slice } from '@atlaskit/editor-prosemirror/model';
1
2
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
- export declare const firePasteActionsMenuExperimentExposure: (contentLength: number, state: EditorState, pasteStartPos?: number, pasteEndPos?: number, pastedText?: string) => void;
3
+ export declare const firePasteActionsMenuExperimentExposure: (contentLength: number, state: EditorState, pasteStartPos?: number, pasteEndPos?: number, pastedText?: string, pastedSlice?: Slice) => void;
@@ -1,2 +1,3 @@
1
+ import type { Slice } from '@atlaskit/editor-prosemirror/model';
1
2
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
- export declare const firePasteActionsMenuExperimentExposure: (contentLength: number, state: EditorState, pasteStartPos?: number, pasteEndPos?: number, pastedText?: string) => void;
3
+ export declare const firePasteActionsMenuExperimentExposure: (contentLength: number, state: EditorState, pasteStartPos?: number, pasteEndPos?: number, pastedText?: string, pastedSlice?: Slice) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-paste-options-toolbar",
3
- "version": "9.1.11",
3
+ "version": "9.2.1",
4
4
  "description": "Paste options toolbar for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -39,10 +39,10 @@
39
39
  "@atlaskit/editor-shared-styles": "^3.10.0",
40
40
  "@atlaskit/editor-toolbar": "^0.20.0",
41
41
  "@atlaskit/editor-ui-control-model": "^1.1.0",
42
- "@atlaskit/icon": "^33.1.0",
42
+ "@atlaskit/icon": "^34.0.0",
43
43
  "@atlaskit/platform-feature-flags": "^1.1.0",
44
44
  "@atlaskit/primitives": "^18.1.0",
45
- "@atlaskit/tmp-editor-statsig": "^52.0.0",
45
+ "@atlaskit/tmp-editor-statsig": "^53.0.0",
46
46
  "@atlaskit/tokens": "^11.4.0",
47
47
  "@babel/runtime": "^7.0.0",
48
48
  "@compiled/react": "^0.20.0",
@@ -50,7 +50,7 @@
50
50
  "react-intl-next": "npm:react-intl@^5.18.1"
51
51
  },
52
52
  "peerDependencies": {
53
- "@atlaskit/editor-common": "^112.13.0",
53
+ "@atlaskit/editor-common": "^112.15.0",
54
54
  "react": "^18.2.0",
55
55
  "react-dom": "^18.2.0"
56
56
  },