@atlaskit/editor-plugin-type-ahead 3.1.10 → 3.1.12
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 +15 -0
- package/dist/cjs/ui/InputQuery.js +30 -0
- package/dist/es2019/ui/InputQuery.js +30 -0
- package/dist/esm/ui/InputQuery.js +30 -0
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-type-ahead
|
|
2
2
|
|
|
3
|
+
## 3.1.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 3.1.11
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`2a8dcec064275`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2a8dcec064275) -
|
|
14
|
+
[ux] [ED-28449] add a paste event listener to insert plain text when user tries to paste rich text
|
|
15
|
+
into the typeahead
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 3.1.10
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -17,6 +17,7 @@ var _ui = require("@atlaskit/editor-common/ui");
|
|
|
17
17
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
18
18
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
19
19
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
20
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
20
21
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
21
22
|
var _constants = require("../pm-plugins/constants");
|
|
22
23
|
var _utils2 = require("../pm-plugins/utils");
|
|
@@ -285,6 +286,25 @@ var InputQuery = exports.InputQuery = /*#__PURE__*/_react.default.memo(function
|
|
|
285
286
|
}
|
|
286
287
|
checkKeyEvent(event);
|
|
287
288
|
};
|
|
289
|
+
var onPaste = function onPaste(event) {
|
|
290
|
+
var _event$clipboardData, _event$clipboardData2;
|
|
291
|
+
var html = (_event$clipboardData = event.clipboardData) === null || _event$clipboardData === void 0 ? void 0 : _event$clipboardData.getData('text/html');
|
|
292
|
+
var plainText = (_event$clipboardData2 = event.clipboardData) === null || _event$clipboardData2 === void 0 ? void 0 : _event$clipboardData2.getData('text/plain');
|
|
293
|
+
if (html && plainText) {
|
|
294
|
+
event.preventDefault();
|
|
295
|
+
|
|
296
|
+
// insert the plain text into the type-ahead input field
|
|
297
|
+
var _selection = window.getSelection();
|
|
298
|
+
if (_selection && ref.current) {
|
|
299
|
+
if (_selection.rangeCount > 0) {
|
|
300
|
+
var range = _selection.getRangeAt(0);
|
|
301
|
+
range.deleteContents();
|
|
302
|
+
range.insertNode(document.createTextNode(plainText));
|
|
303
|
+
range.collapse(false);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
};
|
|
288
308
|
var onFocusOut = function onFocusOut(event) {
|
|
289
309
|
var _window$getSelection;
|
|
290
310
|
var relatedTarget = event.relatedTarget;
|
|
@@ -386,6 +406,11 @@ var InputQuery = exports.InputQuery = /*#__PURE__*/_react.default.memo(function
|
|
|
386
406
|
// Ignored via go/ees005
|
|
387
407
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
388
408
|
element.addEventListener('beforeinput', beforeinput);
|
|
409
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_paste_rich_text_bugfix', 'isEnabled', true)) {
|
|
410
|
+
// Ignored via go/ees005
|
|
411
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
412
|
+
element.addEventListener('paste', onPaste);
|
|
413
|
+
}
|
|
389
414
|
return function () {
|
|
390
415
|
// Ignored via go/ees005
|
|
391
416
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
@@ -399,6 +424,11 @@ var InputQuery = exports.InputQuery = /*#__PURE__*/_react.default.memo(function
|
|
|
399
424
|
// Ignored via go/ees005
|
|
400
425
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
401
426
|
element.removeEventListener('beforeinput', beforeinput);
|
|
427
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_paste_rich_text_bugfix', 'isEnabled', true)) {
|
|
428
|
+
// Ignored via go/ees005
|
|
429
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
430
|
+
element.removeEventListener('paste', onPaste);
|
|
431
|
+
}
|
|
402
432
|
if (_browser.browser.safari) {
|
|
403
433
|
// Ignored via go/ees005
|
|
404
434
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
@@ -14,6 +14,7 @@ import { AssistiveText } from '@atlaskit/editor-common/ui';
|
|
|
14
14
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
15
15
|
import { blockNodesVerticalMargin } from '@atlaskit/editor-shared-styles';
|
|
16
16
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
17
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
17
18
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
18
19
|
import { CloseSelectionOptions, TYPE_AHEAD_DECORATION_ELEMENT_ID, TYPE_AHEAD_POPUP_CONTENT_CLASS } from '../pm-plugins/constants';
|
|
19
20
|
import { getPluginState } from '../pm-plugins/utils';
|
|
@@ -272,6 +273,25 @@ export const InputQuery = /*#__PURE__*/React.memo(({
|
|
|
272
273
|
}
|
|
273
274
|
checkKeyEvent(event);
|
|
274
275
|
};
|
|
276
|
+
const onPaste = event => {
|
|
277
|
+
var _event$clipboardData, _event$clipboardData2;
|
|
278
|
+
const html = (_event$clipboardData = event.clipboardData) === null || _event$clipboardData === void 0 ? void 0 : _event$clipboardData.getData('text/html');
|
|
279
|
+
const plainText = (_event$clipboardData2 = event.clipboardData) === null || _event$clipboardData2 === void 0 ? void 0 : _event$clipboardData2.getData('text/plain');
|
|
280
|
+
if (html && plainText) {
|
|
281
|
+
event.preventDefault();
|
|
282
|
+
|
|
283
|
+
// insert the plain text into the type-ahead input field
|
|
284
|
+
const selection = window.getSelection();
|
|
285
|
+
if (selection && ref.current) {
|
|
286
|
+
if (selection.rangeCount > 0) {
|
|
287
|
+
const range = selection.getRangeAt(0);
|
|
288
|
+
range.deleteContents();
|
|
289
|
+
range.insertNode(document.createTextNode(plainText));
|
|
290
|
+
range.collapse(false);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
};
|
|
275
295
|
const onFocusOut = event => {
|
|
276
296
|
var _window$getSelection;
|
|
277
297
|
const {
|
|
@@ -379,6 +399,11 @@ export const InputQuery = /*#__PURE__*/React.memo(({
|
|
|
379
399
|
// Ignored via go/ees005
|
|
380
400
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
381
401
|
element.addEventListener('beforeinput', beforeinput);
|
|
402
|
+
if (expValEquals('platform_editor_paste_rich_text_bugfix', 'isEnabled', true)) {
|
|
403
|
+
// Ignored via go/ees005
|
|
404
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
405
|
+
element.addEventListener('paste', onPaste);
|
|
406
|
+
}
|
|
382
407
|
return () => {
|
|
383
408
|
// Ignored via go/ees005
|
|
384
409
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
@@ -392,6 +417,11 @@ export const InputQuery = /*#__PURE__*/React.memo(({
|
|
|
392
417
|
// Ignored via go/ees005
|
|
393
418
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
394
419
|
element.removeEventListener('beforeinput', beforeinput);
|
|
420
|
+
if (expValEquals('platform_editor_paste_rich_text_bugfix', 'isEnabled', true)) {
|
|
421
|
+
// Ignored via go/ees005
|
|
422
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
423
|
+
element.removeEventListener('paste', onPaste);
|
|
424
|
+
}
|
|
395
425
|
if (browser.safari) {
|
|
396
426
|
// Ignored via go/ees005
|
|
397
427
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
@@ -15,6 +15,7 @@ import { AssistiveText } from '@atlaskit/editor-common/ui';
|
|
|
15
15
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
16
16
|
import { blockNodesVerticalMargin } from '@atlaskit/editor-shared-styles';
|
|
17
17
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
18
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
18
19
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
19
20
|
import { CloseSelectionOptions, TYPE_AHEAD_DECORATION_ELEMENT_ID, TYPE_AHEAD_POPUP_CONTENT_CLASS } from '../pm-plugins/constants';
|
|
20
21
|
import { getPluginState } from '../pm-plugins/utils';
|
|
@@ -275,6 +276,25 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
275
276
|
}
|
|
276
277
|
checkKeyEvent(event);
|
|
277
278
|
};
|
|
279
|
+
var onPaste = function onPaste(event) {
|
|
280
|
+
var _event$clipboardData, _event$clipboardData2;
|
|
281
|
+
var html = (_event$clipboardData = event.clipboardData) === null || _event$clipboardData === void 0 ? void 0 : _event$clipboardData.getData('text/html');
|
|
282
|
+
var plainText = (_event$clipboardData2 = event.clipboardData) === null || _event$clipboardData2 === void 0 ? void 0 : _event$clipboardData2.getData('text/plain');
|
|
283
|
+
if (html && plainText) {
|
|
284
|
+
event.preventDefault();
|
|
285
|
+
|
|
286
|
+
// insert the plain text into the type-ahead input field
|
|
287
|
+
var _selection = window.getSelection();
|
|
288
|
+
if (_selection && ref.current) {
|
|
289
|
+
if (_selection.rangeCount > 0) {
|
|
290
|
+
var range = _selection.getRangeAt(0);
|
|
291
|
+
range.deleteContents();
|
|
292
|
+
range.insertNode(document.createTextNode(plainText));
|
|
293
|
+
range.collapse(false);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
};
|
|
278
298
|
var onFocusOut = function onFocusOut(event) {
|
|
279
299
|
var _window$getSelection;
|
|
280
300
|
var relatedTarget = event.relatedTarget;
|
|
@@ -376,6 +396,11 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
376
396
|
// Ignored via go/ees005
|
|
377
397
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
378
398
|
element.addEventListener('beforeinput', beforeinput);
|
|
399
|
+
if (expValEquals('platform_editor_paste_rich_text_bugfix', 'isEnabled', true)) {
|
|
400
|
+
// Ignored via go/ees005
|
|
401
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
402
|
+
element.addEventListener('paste', onPaste);
|
|
403
|
+
}
|
|
379
404
|
return function () {
|
|
380
405
|
// Ignored via go/ees005
|
|
381
406
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
@@ -389,6 +414,11 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
389
414
|
// Ignored via go/ees005
|
|
390
415
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
391
416
|
element.removeEventListener('beforeinput', beforeinput);
|
|
417
|
+
if (expValEquals('platform_editor_paste_rich_text_bugfix', 'isEnabled', true)) {
|
|
418
|
+
// Ignored via go/ees005
|
|
419
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
420
|
+
element.removeEventListener('paste', onPaste);
|
|
421
|
+
}
|
|
392
422
|
if (browser.safari) {
|
|
393
423
|
// Ignored via go/ees005
|
|
394
424
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-type-ahead",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.12",
|
|
4
4
|
"description": "Type-ahead plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
".": "./src/index.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@atlaskit/adf-schema": "^50.2.
|
|
35
|
+
"@atlaskit/adf-schema": "^50.2.2",
|
|
36
36
|
"@atlaskit/editor-element-browser": "^1.0.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^3.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-connectivity": "^3.1.0",
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
42
42
|
"@atlaskit/editor-shared-styles": "^3.6.0",
|
|
43
43
|
"@atlaskit/heading": "^5.2.0",
|
|
44
|
-
"@atlaskit/icon": "^28.
|
|
44
|
+
"@atlaskit/icon": "^28.1.0",
|
|
45
45
|
"@atlaskit/menu": "^8.3.0",
|
|
46
46
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
47
|
-
"@atlaskit/primitives": "^14.
|
|
47
|
+
"@atlaskit/primitives": "^14.12.0",
|
|
48
48
|
"@atlaskit/prosemirror-input-rules": "^3.4.0",
|
|
49
|
-
"@atlaskit/theme": "^
|
|
50
|
-
"@atlaskit/tmp-editor-statsig": "^11.
|
|
51
|
-
"@atlaskit/tokens": "^6.
|
|
49
|
+
"@atlaskit/theme": "^20.0.0",
|
|
50
|
+
"@atlaskit/tmp-editor-statsig": "^11.8.0",
|
|
51
|
+
"@atlaskit/tokens": "^6.1.0",
|
|
52
52
|
"@babel/runtime": "^7.0.0",
|
|
53
53
|
"@emotion/react": "^11.7.1",
|
|
54
54
|
"lodash": "^4.17.21",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"w3c-keyname": "^2.1.8"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"@atlaskit/editor-common": "^107.
|
|
61
|
+
"@atlaskit/editor-common": "^107.31.0",
|
|
62
62
|
"react": "^18.2.0",
|
|
63
63
|
"react-dom": "^18.2.0",
|
|
64
64
|
"react-intl-next": "npm:react-intl@^5.18.1"
|