@atlaskit/editor-plugin-paste-options-toolbar 9.1.11 → 9.2.0
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 +11 -0
- package/dist/cjs/pasteOptionsToolbarPlugin.js +1 -1
- package/dist/cjs/ui/on-paste-actions-menu/exposure.js +19 -1
- package/dist/es2019/pasteOptionsToolbarPlugin.js +1 -1
- package/dist/es2019/ui/on-paste-actions-menu/exposure.js +19 -1
- package/dist/esm/pasteOptionsToolbarPlugin.js +1 -1
- package/dist/esm/ui/on-paste-actions-menu/exposure.js +19 -1
- package/dist/types/ui/on-paste-actions-menu/exposure.d.ts +2 -1
- package/dist/types-ts4.5/ui/on-paste-actions-menu/exposure.d.ts +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-paste-options-toolbar
|
|
2
2
|
|
|
3
|
+
## 9.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`f320bfec5b28f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f320bfec5b28f) -
|
|
8
|
+
Hide AI paste actions when pasted content contains a table.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
3
14
|
## 9.1.11
|
|
4
15
|
|
|
5
16
|
### 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;
|