@atlaskit/editor-common 75.1.2 → 75.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 +6 -0
- package/clipboard/package.json +15 -0
- package/dist/cjs/clipboard/index.js +182 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/selection/index.js +88 -12
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/es2019/clipboard/index.js +106 -0
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/selection/index.js +75 -1
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/esm/clipboard/index.js +168 -0
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/selection/index.js +73 -1
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/types/clipboard/index.d.ts +6 -0
- package/dist/types/selection/index.d.ts +7 -0
- package/dist/types-ts4.5/clipboard/index.d.ts +6 -0
- package/dist/types-ts4.5/selection/index.d.ts +7 -0
- package/package.json +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-common
|
|
2
2
|
|
|
3
|
+
## 75.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`9f2365fabcc`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9f2365fabcc) - ED-19617 - Initial creation of editor-plugin-copy-button package
|
|
8
|
+
|
|
3
9
|
## 75.1.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/editor-common/clipboard",
|
|
3
|
+
"main": "../dist/cjs/clipboard/index.js",
|
|
4
|
+
"module": "../dist/esm/clipboard/index.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/clipboard/index.js",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"types": "../dist/types/clipboard/index.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.5 <4.9": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../dist/types-ts4.5/clipboard/index.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.getAnalyticsPayload = exports.copyToClipboard = exports.copyHTMLToClipboardPolyfill = exports.copyHTMLToClipboard = void 0;
|
|
9
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
+
var clipboard = _interopRequireWildcard(require("clipboard-polyfill"));
|
|
14
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
15
|
+
var _analytics = require("../analytics");
|
|
16
|
+
var _selection = require("../selection");
|
|
17
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
+
var isClipboardApiSupported = function isClipboardApiSupported() {
|
|
20
|
+
return !!navigator.clipboard && typeof navigator.clipboard.writeText === 'function';
|
|
21
|
+
};
|
|
22
|
+
var isIEClipboardApiSupported = function isIEClipboardApiSupported() {
|
|
23
|
+
return window.clipboardData && typeof window.clipboardData.setData === 'function';
|
|
24
|
+
};
|
|
25
|
+
var copyToClipboard = /*#__PURE__*/function () {
|
|
26
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(textToCopy) {
|
|
27
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
28
|
+
while (1) switch (_context.prev = _context.next) {
|
|
29
|
+
case 0:
|
|
30
|
+
if (!isClipboardApiSupported()) {
|
|
31
|
+
_context.next = 11;
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
_context.prev = 1;
|
|
35
|
+
_context.next = 4;
|
|
36
|
+
return navigator.clipboard.writeText(textToCopy);
|
|
37
|
+
case 4:
|
|
38
|
+
_context.next = 9;
|
|
39
|
+
break;
|
|
40
|
+
case 6:
|
|
41
|
+
_context.prev = 6;
|
|
42
|
+
_context.t0 = _context["catch"](1);
|
|
43
|
+
throw new Error('Clipboard api is not supported');
|
|
44
|
+
case 9:
|
|
45
|
+
_context.next = 23;
|
|
46
|
+
break;
|
|
47
|
+
case 11:
|
|
48
|
+
if (!isIEClipboardApiSupported()) {
|
|
49
|
+
_context.next = 22;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
_context.prev = 12;
|
|
53
|
+
_context.next = 15;
|
|
54
|
+
return window.clipboardData.setData('text', textToCopy);
|
|
55
|
+
case 15:
|
|
56
|
+
_context.next = 20;
|
|
57
|
+
break;
|
|
58
|
+
case 17:
|
|
59
|
+
_context.prev = 17;
|
|
60
|
+
_context.t1 = _context["catch"](12);
|
|
61
|
+
throw new Error('IE clipboard api is not supported');
|
|
62
|
+
case 20:
|
|
63
|
+
_context.next = 23;
|
|
64
|
+
break;
|
|
65
|
+
case 22:
|
|
66
|
+
throw new Error('Clipboard api is not supported');
|
|
67
|
+
case 23:
|
|
68
|
+
case "end":
|
|
69
|
+
return _context.stop();
|
|
70
|
+
}
|
|
71
|
+
}, _callee, null, [[1, 6], [12, 17]]);
|
|
72
|
+
}));
|
|
73
|
+
return function copyToClipboard(_x) {
|
|
74
|
+
return _ref.apply(this, arguments);
|
|
75
|
+
};
|
|
76
|
+
}();
|
|
77
|
+
exports.copyToClipboard = copyToClipboard;
|
|
78
|
+
var copyHTMLToClipboard = /*#__PURE__*/function () {
|
|
79
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(elementToCopy, plainTextToCopy) {
|
|
80
|
+
var data;
|
|
81
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
82
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
83
|
+
case 0:
|
|
84
|
+
if (!(isClipboardApiSupported() && typeof ClipboardItem !== 'undefined')) {
|
|
85
|
+
_context2.next = 12;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
_context2.prev = 1;
|
|
89
|
+
data = new ClipboardItem({
|
|
90
|
+
'text/plain': new Blob([plainTextToCopy || elementToCopy.innerText], {
|
|
91
|
+
type: 'text/plain'
|
|
92
|
+
}),
|
|
93
|
+
'text/html': new Blob([elementToCopy.innerHTML], {
|
|
94
|
+
type: 'text/html'
|
|
95
|
+
})
|
|
96
|
+
}); // @ts-ignore
|
|
97
|
+
_context2.next = 5;
|
|
98
|
+
return navigator.clipboard.write([data]);
|
|
99
|
+
case 5:
|
|
100
|
+
_context2.next = 10;
|
|
101
|
+
break;
|
|
102
|
+
case 7:
|
|
103
|
+
_context2.prev = 7;
|
|
104
|
+
_context2.t0 = _context2["catch"](1);
|
|
105
|
+
throw new Error('Clipboard api is not supported');
|
|
106
|
+
case 10:
|
|
107
|
+
_context2.next = 13;
|
|
108
|
+
break;
|
|
109
|
+
case 12:
|
|
110
|
+
if ((typeof document === "undefined" ? "undefined" : (0, _typeof2.default)(document)) !== undefined) {
|
|
111
|
+
// ED-17083 extension copy seems have issue with ClipboardItem API
|
|
112
|
+
// Hence of use of this polyfill
|
|
113
|
+
copyHTMLToClipboardPolyfill(elementToCopy, plainTextToCopy);
|
|
114
|
+
}
|
|
115
|
+
case 13:
|
|
116
|
+
case "end":
|
|
117
|
+
return _context2.stop();
|
|
118
|
+
}
|
|
119
|
+
}, _callee2, null, [[1, 7]]);
|
|
120
|
+
}));
|
|
121
|
+
return function copyHTMLToClipboard(_x2, _x3) {
|
|
122
|
+
return _ref2.apply(this, arguments);
|
|
123
|
+
};
|
|
124
|
+
}();
|
|
125
|
+
|
|
126
|
+
// At the time of development, Firefox doesn't support ClipboardItem API
|
|
127
|
+
// Hence of use of this polyfill
|
|
128
|
+
exports.copyHTMLToClipboard = copyHTMLToClipboard;
|
|
129
|
+
var copyHTMLToClipboardPolyfill = function copyHTMLToClipboardPolyfill(elementToCopy, plainTextToCopy) {
|
|
130
|
+
var Clipboard = clipboard;
|
|
131
|
+
var dt = new Clipboard.DT();
|
|
132
|
+
dt.setData('text/plain', plainTextToCopy || elementToCopy.innerText);
|
|
133
|
+
dt.setData('text/html', elementToCopy.innerHTML);
|
|
134
|
+
Clipboard.write(dt);
|
|
135
|
+
};
|
|
136
|
+
exports.copyHTMLToClipboardPolyfill = copyHTMLToClipboardPolyfill;
|
|
137
|
+
var getAnalyticsPayload = function getAnalyticsPayload(state, action) {
|
|
138
|
+
var selection = state.selection,
|
|
139
|
+
doc = state.doc;
|
|
140
|
+
var selectionAnalyticsPayload = (0, _selection.getNodeSelectionAnalyticsPayload)(selection) || (0, _selection.getRangeSelectionAnalyticsPayload)(selection, doc) || (0, _selection.getAllSelectionAnalyticsPayload)(selection) || (0, _selection.getCellSelectionAnalyticsPayload)(state);
|
|
141
|
+
if (selectionAnalyticsPayload) {
|
|
142
|
+
var selectionActionSubjectId = selectionAnalyticsPayload.actionSubjectId;
|
|
143
|
+
var content = [];
|
|
144
|
+
switch (selectionActionSubjectId) {
|
|
145
|
+
case _analytics.ACTION_SUBJECT_ID.NODE:
|
|
146
|
+
content.push(selectionAnalyticsPayload.attributes.node);
|
|
147
|
+
break;
|
|
148
|
+
case _analytics.ACTION_SUBJECT_ID.RANGE:
|
|
149
|
+
content.push.apply(content, (0, _toConsumableArray2.default)(selectionAnalyticsPayload.attributes.nodes));
|
|
150
|
+
break;
|
|
151
|
+
case _analytics.ACTION_SUBJECT_ID.ALL:
|
|
152
|
+
content.push('all');
|
|
153
|
+
break;
|
|
154
|
+
case _analytics.ACTION_SUBJECT_ID.CELL:
|
|
155
|
+
{
|
|
156
|
+
var _ref3 = selectionAnalyticsPayload.attributes,
|
|
157
|
+
selectedCells = _ref3.selectedCells;
|
|
158
|
+
content.push.apply(content, (0, _toConsumableArray2.default)(Array(selectedCells).fill('tableCell')));
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
164
|
+
action: action,
|
|
165
|
+
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
166
|
+
attributes: {
|
|
167
|
+
content: content
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
if (selection instanceof _state.TextSelection && selection.$cursor) {
|
|
172
|
+
return {
|
|
173
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
174
|
+
action: action,
|
|
175
|
+
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
176
|
+
attributes: {
|
|
177
|
+
content: ['caret']
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
exports.getAnalyticsPayload = getAnalyticsPayload;
|
|
@@ -16,7 +16,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
16
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
17
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
18
18
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
19
|
-
var packageVersion = "75.
|
|
19
|
+
var packageVersion = "75.2.0";
|
|
20
20
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
21
21
|
// Remove URL as it has UGC
|
|
22
22
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -36,55 +36,59 @@ Object.defineProperty(exports, "Side", {
|
|
|
36
36
|
Object.defineProperty(exports, "atTheBeginningOfBlock", {
|
|
37
37
|
enumerable: true,
|
|
38
38
|
get: function get() {
|
|
39
|
-
return
|
|
39
|
+
return _utils3.atTheBeginningOfBlock;
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
Object.defineProperty(exports, "atTheBeginningOfDoc", {
|
|
43
43
|
enumerable: true,
|
|
44
44
|
get: function get() {
|
|
45
|
-
return
|
|
45
|
+
return _utils3.atTheBeginningOfDoc;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
Object.defineProperty(exports, "atTheEndOfBlock", {
|
|
49
49
|
enumerable: true,
|
|
50
50
|
get: function get() {
|
|
51
|
-
return
|
|
51
|
+
return _utils3.atTheEndOfBlock;
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
54
|
Object.defineProperty(exports, "atTheEndOfDoc", {
|
|
55
55
|
enumerable: true,
|
|
56
56
|
get: function get() {
|
|
57
|
-
return
|
|
57
|
+
return _utils3.atTheEndOfDoc;
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
Object.defineProperty(exports, "endPositionOfParent", {
|
|
61
61
|
enumerable: true,
|
|
62
62
|
get: function get() {
|
|
63
|
-
return
|
|
63
|
+
return _utils3.endPositionOfParent;
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
|
+
exports.getAllSelectionAnalyticsPayload = getAllSelectionAnalyticsPayload;
|
|
67
|
+
exports.getCellSelectionAnalyticsPayload = getCellSelectionAnalyticsPayload;
|
|
68
|
+
exports.getNodeSelectionAnalyticsPayload = getNodeSelectionAnalyticsPayload;
|
|
69
|
+
exports.getRangeSelectionAnalyticsPayload = getRangeSelectionAnalyticsPayload;
|
|
66
70
|
Object.defineProperty(exports, "isIgnored", {
|
|
67
71
|
enumerable: true,
|
|
68
72
|
get: function get() {
|
|
69
|
-
return
|
|
73
|
+
return _utils2.isIgnored;
|
|
70
74
|
}
|
|
71
75
|
});
|
|
72
76
|
Object.defineProperty(exports, "isSelectionAtEndOfNode", {
|
|
73
77
|
enumerable: true,
|
|
74
78
|
get: function get() {
|
|
75
|
-
return
|
|
79
|
+
return _utils3.isSelectionAtEndOfNode;
|
|
76
80
|
}
|
|
77
81
|
});
|
|
78
82
|
Object.defineProperty(exports, "isSelectionAtStartOfNode", {
|
|
79
83
|
enumerable: true,
|
|
80
84
|
get: function get() {
|
|
81
|
-
return
|
|
85
|
+
return _utils3.isSelectionAtStartOfNode;
|
|
82
86
|
}
|
|
83
87
|
});
|
|
84
88
|
Object.defineProperty(exports, "isValidTargetNode", {
|
|
85
89
|
enumerable: true,
|
|
86
90
|
get: function get() {
|
|
87
|
-
return
|
|
91
|
+
return _utils2.isValidTargetNode;
|
|
88
92
|
}
|
|
89
93
|
});
|
|
90
94
|
Object.defineProperty(exports, "setGapCursorSelection", {
|
|
@@ -96,11 +100,83 @@ Object.defineProperty(exports, "setGapCursorSelection", {
|
|
|
96
100
|
Object.defineProperty(exports, "startPositionOfParent", {
|
|
97
101
|
enumerable: true,
|
|
98
102
|
get: function get() {
|
|
99
|
-
return
|
|
103
|
+
return _utils3.startPositionOfParent;
|
|
100
104
|
}
|
|
101
105
|
});
|
|
106
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
107
|
+
var _editorTables = require("@atlaskit/editor-tables");
|
|
108
|
+
var _utils = require("@atlaskit/editor-tables/utils");
|
|
109
|
+
var _analytics = require("../analytics");
|
|
102
110
|
var _types = require("./types");
|
|
103
111
|
var _selection = require("./gap-cursor/selection");
|
|
104
|
-
var
|
|
112
|
+
var _utils2 = require("./gap-cursor/utils");
|
|
105
113
|
var _setGapCursorSelection = require("./gap-cursor/utils/setGapCursorSelection");
|
|
106
|
-
var
|
|
114
|
+
var _utils3 = require("./utils");
|
|
115
|
+
function getNodeSelectionAnalyticsPayload(selection) {
|
|
116
|
+
if (selection instanceof _state.NodeSelection) {
|
|
117
|
+
return {
|
|
118
|
+
action: _analytics.ACTION.SELECTED,
|
|
119
|
+
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
120
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.NODE,
|
|
121
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
122
|
+
attributes: {
|
|
123
|
+
node: selection.node.type.name
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function getAllSelectionAnalyticsPayload(selection) {
|
|
129
|
+
if (selection instanceof _state.AllSelection) {
|
|
130
|
+
return {
|
|
131
|
+
action: _analytics.ACTION.SELECTED,
|
|
132
|
+
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
133
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.ALL,
|
|
134
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function getCellSelectionAnalyticsPayload(state) {
|
|
139
|
+
if (state.selection instanceof _editorTables.CellSelection) {
|
|
140
|
+
var rect = (0, _utils.selectedRect)(state);
|
|
141
|
+
var selectedCells = rect.map.cellsInRect(rect).length;
|
|
142
|
+
var totalCells = rect.map.map.length;
|
|
143
|
+
return {
|
|
144
|
+
action: _analytics.ACTION.SELECTED,
|
|
145
|
+
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
146
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.CELL,
|
|
147
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
148
|
+
attributes: {
|
|
149
|
+
selectedCells: selectedCells,
|
|
150
|
+
totalCells: totalCells
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function getRangeSelectionAnalyticsPayload(selection, doc) {
|
|
156
|
+
if (selection instanceof _state.TextSelection && selection.from !== selection.to) {
|
|
157
|
+
var from = selection.from,
|
|
158
|
+
to = selection.to,
|
|
159
|
+
anchor = selection.anchor,
|
|
160
|
+
head = selection.head;
|
|
161
|
+
var nodes = [];
|
|
162
|
+
doc.nodesBetween(from, to, function (node, pos) {
|
|
163
|
+
// We want to send top-level nodes only, ie. the nodes that would have the selection styling
|
|
164
|
+
// We allow text nodes that are not fully covered as they are a special case
|
|
165
|
+
if (node.isText || pos >= from && pos + node.nodeSize <= to) {
|
|
166
|
+
nodes.push(node.type.name);
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
return {
|
|
171
|
+
action: _analytics.ACTION.SELECTED,
|
|
172
|
+
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
173
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.RANGE,
|
|
174
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
175
|
+
attributes: {
|
|
176
|
+
from: anchor,
|
|
177
|
+
to: head,
|
|
178
|
+
nodes: nodes
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -24,7 +24,7 @@ var _templateObject, _templateObject2, _templateObject3;
|
|
|
24
24
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
25
25
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
|
|
26
26
|
var packageName = "@atlaskit/editor-common";
|
|
27
|
-
var packageVersion = "75.
|
|
27
|
+
var packageVersion = "75.2.0";
|
|
28
28
|
var halfFocusRing = 1;
|
|
29
29
|
var dropOffset = '0, 8';
|
|
30
30
|
var DropList = /*#__PURE__*/function (_Component) {
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import * as clipboard from 'clipboard-polyfill';
|
|
2
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../analytics';
|
|
4
|
+
import { getAllSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload, getNodeSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload } from '../selection';
|
|
5
|
+
const isClipboardApiSupported = () => !!navigator.clipboard && typeof navigator.clipboard.writeText === 'function';
|
|
6
|
+
const isIEClipboardApiSupported = () => window.clipboardData && typeof window.clipboardData.setData === 'function';
|
|
7
|
+
export const copyToClipboard = async textToCopy => {
|
|
8
|
+
if (isClipboardApiSupported()) {
|
|
9
|
+
try {
|
|
10
|
+
await navigator.clipboard.writeText(textToCopy);
|
|
11
|
+
} catch (error) {
|
|
12
|
+
throw new Error('Clipboard api is not supported');
|
|
13
|
+
}
|
|
14
|
+
} else if (isIEClipboardApiSupported()) {
|
|
15
|
+
try {
|
|
16
|
+
await window.clipboardData.setData('text', textToCopy);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
throw new Error('IE clipboard api is not supported');
|
|
19
|
+
}
|
|
20
|
+
} else {
|
|
21
|
+
throw new Error('Clipboard api is not supported');
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
export const copyHTMLToClipboard = async (elementToCopy, plainTextToCopy) => {
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
if (isClipboardApiSupported() && typeof ClipboardItem !== 'undefined') {
|
|
27
|
+
try {
|
|
28
|
+
const data = new ClipboardItem({
|
|
29
|
+
'text/plain': new Blob([plainTextToCopy || elementToCopy.innerText], {
|
|
30
|
+
type: 'text/plain'
|
|
31
|
+
}),
|
|
32
|
+
'text/html': new Blob([elementToCopy.innerHTML], {
|
|
33
|
+
type: 'text/html'
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
await navigator.clipboard.write([data]);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
throw new Error('Clipboard api is not supported');
|
|
40
|
+
}
|
|
41
|
+
} else if (typeof document !== undefined) {
|
|
42
|
+
// ED-17083 extension copy seems have issue with ClipboardItem API
|
|
43
|
+
// Hence of use of this polyfill
|
|
44
|
+
copyHTMLToClipboardPolyfill(elementToCopy, plainTextToCopy);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// At the time of development, Firefox doesn't support ClipboardItem API
|
|
49
|
+
// Hence of use of this polyfill
|
|
50
|
+
export const copyHTMLToClipboardPolyfill = (elementToCopy, plainTextToCopy) => {
|
|
51
|
+
const Clipboard = clipboard;
|
|
52
|
+
const dt = new Clipboard.DT();
|
|
53
|
+
dt.setData('text/plain', plainTextToCopy || elementToCopy.innerText);
|
|
54
|
+
dt.setData('text/html', elementToCopy.innerHTML);
|
|
55
|
+
Clipboard.write(dt);
|
|
56
|
+
};
|
|
57
|
+
export const getAnalyticsPayload = (state, action) => {
|
|
58
|
+
const {
|
|
59
|
+
selection,
|
|
60
|
+
doc
|
|
61
|
+
} = state;
|
|
62
|
+
const selectionAnalyticsPayload = getNodeSelectionAnalyticsPayload(selection) || getRangeSelectionAnalyticsPayload(selection, doc) || getAllSelectionAnalyticsPayload(selection) || getCellSelectionAnalyticsPayload(state);
|
|
63
|
+
if (selectionAnalyticsPayload) {
|
|
64
|
+
const {
|
|
65
|
+
actionSubjectId: selectionActionSubjectId
|
|
66
|
+
} = selectionAnalyticsPayload;
|
|
67
|
+
let content = [];
|
|
68
|
+
switch (selectionActionSubjectId) {
|
|
69
|
+
case ACTION_SUBJECT_ID.NODE:
|
|
70
|
+
content.push(selectionAnalyticsPayload.attributes.node);
|
|
71
|
+
break;
|
|
72
|
+
case ACTION_SUBJECT_ID.RANGE:
|
|
73
|
+
content.push(...selectionAnalyticsPayload.attributes.nodes);
|
|
74
|
+
break;
|
|
75
|
+
case ACTION_SUBJECT_ID.ALL:
|
|
76
|
+
content.push('all');
|
|
77
|
+
break;
|
|
78
|
+
case ACTION_SUBJECT_ID.CELL:
|
|
79
|
+
{
|
|
80
|
+
const {
|
|
81
|
+
selectedCells
|
|
82
|
+
} = selectionAnalyticsPayload.attributes;
|
|
83
|
+
content.push(...Array(selectedCells).fill('tableCell'));
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
eventType: EVENT_TYPE.TRACK,
|
|
89
|
+
action,
|
|
90
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
91
|
+
attributes: {
|
|
92
|
+
content
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
if (selection instanceof TextSelection && selection.$cursor) {
|
|
97
|
+
return {
|
|
98
|
+
eventType: EVENT_TYPE.TRACK,
|
|
99
|
+
action,
|
|
100
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
101
|
+
attributes: {
|
|
102
|
+
content: ['caret']
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
2
2
|
const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
3
|
-
const packageVersion = "75.
|
|
3
|
+
const packageVersion = "75.2.0";
|
|
4
4
|
const sanitiseSentryEvents = (data, _hint) => {
|
|
5
5
|
// Remove URL as it has UGC
|
|
6
6
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -1,5 +1,79 @@
|
|
|
1
|
+
import { AllSelection, NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import { CellSelection } from '@atlaskit/editor-tables';
|
|
3
|
+
import { selectedRect } from '@atlaskit/editor-tables/utils';
|
|
4
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../analytics';
|
|
1
5
|
export { RelativeSelectionPos } from './types';
|
|
2
6
|
export { GapCursorSelection, Side, JSON_ID, GapBookmark } from './gap-cursor/selection';
|
|
3
7
|
export { isIgnored, isValidTargetNode } from './gap-cursor/utils';
|
|
4
8
|
export { setGapCursorSelection } from './gap-cursor/utils/setGapCursorSelection';
|
|
5
|
-
export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent } from './utils';
|
|
9
|
+
export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent } from './utils';
|
|
10
|
+
export function getNodeSelectionAnalyticsPayload(selection) {
|
|
11
|
+
if (selection instanceof NodeSelection) {
|
|
12
|
+
return {
|
|
13
|
+
action: ACTION.SELECTED,
|
|
14
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
15
|
+
actionSubjectId: ACTION_SUBJECT_ID.NODE,
|
|
16
|
+
eventType: EVENT_TYPE.TRACK,
|
|
17
|
+
attributes: {
|
|
18
|
+
node: selection.node.type.name
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function getAllSelectionAnalyticsPayload(selection) {
|
|
24
|
+
if (selection instanceof AllSelection) {
|
|
25
|
+
return {
|
|
26
|
+
action: ACTION.SELECTED,
|
|
27
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
28
|
+
actionSubjectId: ACTION_SUBJECT_ID.ALL,
|
|
29
|
+
eventType: EVENT_TYPE.TRACK
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function getCellSelectionAnalyticsPayload(state) {
|
|
34
|
+
if (state.selection instanceof CellSelection) {
|
|
35
|
+
const rect = selectedRect(state);
|
|
36
|
+
const selectedCells = rect.map.cellsInRect(rect).length;
|
|
37
|
+
const totalCells = rect.map.map.length;
|
|
38
|
+
return {
|
|
39
|
+
action: ACTION.SELECTED,
|
|
40
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
41
|
+
actionSubjectId: ACTION_SUBJECT_ID.CELL,
|
|
42
|
+
eventType: EVENT_TYPE.TRACK,
|
|
43
|
+
attributes: {
|
|
44
|
+
selectedCells,
|
|
45
|
+
totalCells
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export function getRangeSelectionAnalyticsPayload(selection, doc) {
|
|
51
|
+
if (selection instanceof TextSelection && selection.from !== selection.to) {
|
|
52
|
+
const {
|
|
53
|
+
from,
|
|
54
|
+
to,
|
|
55
|
+
anchor,
|
|
56
|
+
head
|
|
57
|
+
} = selection;
|
|
58
|
+
const nodes = [];
|
|
59
|
+
doc.nodesBetween(from, to, (node, pos) => {
|
|
60
|
+
// We want to send top-level nodes only, ie. the nodes that would have the selection styling
|
|
61
|
+
// We allow text nodes that are not fully covered as they are a special case
|
|
62
|
+
if (node.isText || pos >= from && pos + node.nodeSize <= to) {
|
|
63
|
+
nodes.push(node.type.name);
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
action: ACTION.SELECTED,
|
|
69
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
70
|
+
actionSubjectId: ACTION_SUBJECT_ID.RANGE,
|
|
71
|
+
eventType: EVENT_TYPE.TRACK,
|
|
72
|
+
attributes: {
|
|
73
|
+
from: anchor,
|
|
74
|
+
to: head,
|
|
75
|
+
nodes
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -9,7 +9,7 @@ import { themed } from '@atlaskit/theme/components';
|
|
|
9
9
|
import { borderRadius } from '@atlaskit/theme/constants';
|
|
10
10
|
import Layer from '../Layer';
|
|
11
11
|
const packageName = "@atlaskit/editor-common";
|
|
12
|
-
const packageVersion = "75.
|
|
12
|
+
const packageVersion = "75.2.0";
|
|
13
13
|
const halfFocusRing = 1;
|
|
14
14
|
const dropOffset = '0, 8';
|
|
15
15
|
class DropList extends Component {
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
+
import * as clipboard from 'clipboard-polyfill';
|
|
6
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
import { ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../analytics';
|
|
8
|
+
import { getAllSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload, getNodeSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload } from '../selection';
|
|
9
|
+
var isClipboardApiSupported = function isClipboardApiSupported() {
|
|
10
|
+
return !!navigator.clipboard && typeof navigator.clipboard.writeText === 'function';
|
|
11
|
+
};
|
|
12
|
+
var isIEClipboardApiSupported = function isIEClipboardApiSupported() {
|
|
13
|
+
return window.clipboardData && typeof window.clipboardData.setData === 'function';
|
|
14
|
+
};
|
|
15
|
+
export var copyToClipboard = /*#__PURE__*/function () {
|
|
16
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(textToCopy) {
|
|
17
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
18
|
+
while (1) switch (_context.prev = _context.next) {
|
|
19
|
+
case 0:
|
|
20
|
+
if (!isClipboardApiSupported()) {
|
|
21
|
+
_context.next = 11;
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
_context.prev = 1;
|
|
25
|
+
_context.next = 4;
|
|
26
|
+
return navigator.clipboard.writeText(textToCopy);
|
|
27
|
+
case 4:
|
|
28
|
+
_context.next = 9;
|
|
29
|
+
break;
|
|
30
|
+
case 6:
|
|
31
|
+
_context.prev = 6;
|
|
32
|
+
_context.t0 = _context["catch"](1);
|
|
33
|
+
throw new Error('Clipboard api is not supported');
|
|
34
|
+
case 9:
|
|
35
|
+
_context.next = 23;
|
|
36
|
+
break;
|
|
37
|
+
case 11:
|
|
38
|
+
if (!isIEClipboardApiSupported()) {
|
|
39
|
+
_context.next = 22;
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
_context.prev = 12;
|
|
43
|
+
_context.next = 15;
|
|
44
|
+
return window.clipboardData.setData('text', textToCopy);
|
|
45
|
+
case 15:
|
|
46
|
+
_context.next = 20;
|
|
47
|
+
break;
|
|
48
|
+
case 17:
|
|
49
|
+
_context.prev = 17;
|
|
50
|
+
_context.t1 = _context["catch"](12);
|
|
51
|
+
throw new Error('IE clipboard api is not supported');
|
|
52
|
+
case 20:
|
|
53
|
+
_context.next = 23;
|
|
54
|
+
break;
|
|
55
|
+
case 22:
|
|
56
|
+
throw new Error('Clipboard api is not supported');
|
|
57
|
+
case 23:
|
|
58
|
+
case "end":
|
|
59
|
+
return _context.stop();
|
|
60
|
+
}
|
|
61
|
+
}, _callee, null, [[1, 6], [12, 17]]);
|
|
62
|
+
}));
|
|
63
|
+
return function copyToClipboard(_x) {
|
|
64
|
+
return _ref.apply(this, arguments);
|
|
65
|
+
};
|
|
66
|
+
}();
|
|
67
|
+
export var copyHTMLToClipboard = /*#__PURE__*/function () {
|
|
68
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(elementToCopy, plainTextToCopy) {
|
|
69
|
+
var data;
|
|
70
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
71
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
72
|
+
case 0:
|
|
73
|
+
if (!(isClipboardApiSupported() && typeof ClipboardItem !== 'undefined')) {
|
|
74
|
+
_context2.next = 12;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
_context2.prev = 1;
|
|
78
|
+
data = new ClipboardItem({
|
|
79
|
+
'text/plain': new Blob([plainTextToCopy || elementToCopy.innerText], {
|
|
80
|
+
type: 'text/plain'
|
|
81
|
+
}),
|
|
82
|
+
'text/html': new Blob([elementToCopy.innerHTML], {
|
|
83
|
+
type: 'text/html'
|
|
84
|
+
})
|
|
85
|
+
}); // @ts-ignore
|
|
86
|
+
_context2.next = 5;
|
|
87
|
+
return navigator.clipboard.write([data]);
|
|
88
|
+
case 5:
|
|
89
|
+
_context2.next = 10;
|
|
90
|
+
break;
|
|
91
|
+
case 7:
|
|
92
|
+
_context2.prev = 7;
|
|
93
|
+
_context2.t0 = _context2["catch"](1);
|
|
94
|
+
throw new Error('Clipboard api is not supported');
|
|
95
|
+
case 10:
|
|
96
|
+
_context2.next = 13;
|
|
97
|
+
break;
|
|
98
|
+
case 12:
|
|
99
|
+
if ((typeof document === "undefined" ? "undefined" : _typeof(document)) !== undefined) {
|
|
100
|
+
// ED-17083 extension copy seems have issue with ClipboardItem API
|
|
101
|
+
// Hence of use of this polyfill
|
|
102
|
+
copyHTMLToClipboardPolyfill(elementToCopy, plainTextToCopy);
|
|
103
|
+
}
|
|
104
|
+
case 13:
|
|
105
|
+
case "end":
|
|
106
|
+
return _context2.stop();
|
|
107
|
+
}
|
|
108
|
+
}, _callee2, null, [[1, 7]]);
|
|
109
|
+
}));
|
|
110
|
+
return function copyHTMLToClipboard(_x2, _x3) {
|
|
111
|
+
return _ref2.apply(this, arguments);
|
|
112
|
+
};
|
|
113
|
+
}();
|
|
114
|
+
|
|
115
|
+
// At the time of development, Firefox doesn't support ClipboardItem API
|
|
116
|
+
// Hence of use of this polyfill
|
|
117
|
+
export var copyHTMLToClipboardPolyfill = function copyHTMLToClipboardPolyfill(elementToCopy, plainTextToCopy) {
|
|
118
|
+
var Clipboard = clipboard;
|
|
119
|
+
var dt = new Clipboard.DT();
|
|
120
|
+
dt.setData('text/plain', plainTextToCopy || elementToCopy.innerText);
|
|
121
|
+
dt.setData('text/html', elementToCopy.innerHTML);
|
|
122
|
+
Clipboard.write(dt);
|
|
123
|
+
};
|
|
124
|
+
export var getAnalyticsPayload = function getAnalyticsPayload(state, action) {
|
|
125
|
+
var selection = state.selection,
|
|
126
|
+
doc = state.doc;
|
|
127
|
+
var selectionAnalyticsPayload = getNodeSelectionAnalyticsPayload(selection) || getRangeSelectionAnalyticsPayload(selection, doc) || getAllSelectionAnalyticsPayload(selection) || getCellSelectionAnalyticsPayload(state);
|
|
128
|
+
if (selectionAnalyticsPayload) {
|
|
129
|
+
var selectionActionSubjectId = selectionAnalyticsPayload.actionSubjectId;
|
|
130
|
+
var content = [];
|
|
131
|
+
switch (selectionActionSubjectId) {
|
|
132
|
+
case ACTION_SUBJECT_ID.NODE:
|
|
133
|
+
content.push(selectionAnalyticsPayload.attributes.node);
|
|
134
|
+
break;
|
|
135
|
+
case ACTION_SUBJECT_ID.RANGE:
|
|
136
|
+
content.push.apply(content, _toConsumableArray(selectionAnalyticsPayload.attributes.nodes));
|
|
137
|
+
break;
|
|
138
|
+
case ACTION_SUBJECT_ID.ALL:
|
|
139
|
+
content.push('all');
|
|
140
|
+
break;
|
|
141
|
+
case ACTION_SUBJECT_ID.CELL:
|
|
142
|
+
{
|
|
143
|
+
var _ref3 = selectionAnalyticsPayload.attributes,
|
|
144
|
+
selectedCells = _ref3.selectedCells;
|
|
145
|
+
content.push.apply(content, _toConsumableArray(Array(selectedCells).fill('tableCell')));
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
eventType: EVENT_TYPE.TRACK,
|
|
151
|
+
action: action,
|
|
152
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
153
|
+
attributes: {
|
|
154
|
+
content: content
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
if (selection instanceof TextSelection && selection.$cursor) {
|
|
159
|
+
return {
|
|
160
|
+
eventType: EVENT_TYPE.TRACK,
|
|
161
|
+
action: action,
|
|
162
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
163
|
+
attributes: {
|
|
164
|
+
content: ['caret']
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
};
|
|
@@ -6,7 +6,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
6
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
7
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
8
8
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
9
|
-
var packageVersion = "75.
|
|
9
|
+
var packageVersion = "75.2.0";
|
|
10
10
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
11
11
|
// Remove URL as it has UGC
|
|
12
12
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -1,5 +1,77 @@
|
|
|
1
|
+
import { AllSelection, NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import { CellSelection } from '@atlaskit/editor-tables';
|
|
3
|
+
import { selectedRect } from '@atlaskit/editor-tables/utils';
|
|
4
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../analytics';
|
|
1
5
|
export { RelativeSelectionPos } from './types';
|
|
2
6
|
export { GapCursorSelection, Side, JSON_ID, GapBookmark } from './gap-cursor/selection';
|
|
3
7
|
export { isIgnored, isValidTargetNode } from './gap-cursor/utils';
|
|
4
8
|
export { setGapCursorSelection } from './gap-cursor/utils/setGapCursorSelection';
|
|
5
|
-
export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent } from './utils';
|
|
9
|
+
export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent } from './utils';
|
|
10
|
+
export function getNodeSelectionAnalyticsPayload(selection) {
|
|
11
|
+
if (selection instanceof NodeSelection) {
|
|
12
|
+
return {
|
|
13
|
+
action: ACTION.SELECTED,
|
|
14
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
15
|
+
actionSubjectId: ACTION_SUBJECT_ID.NODE,
|
|
16
|
+
eventType: EVENT_TYPE.TRACK,
|
|
17
|
+
attributes: {
|
|
18
|
+
node: selection.node.type.name
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function getAllSelectionAnalyticsPayload(selection) {
|
|
24
|
+
if (selection instanceof AllSelection) {
|
|
25
|
+
return {
|
|
26
|
+
action: ACTION.SELECTED,
|
|
27
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
28
|
+
actionSubjectId: ACTION_SUBJECT_ID.ALL,
|
|
29
|
+
eventType: EVENT_TYPE.TRACK
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function getCellSelectionAnalyticsPayload(state) {
|
|
34
|
+
if (state.selection instanceof CellSelection) {
|
|
35
|
+
var rect = selectedRect(state);
|
|
36
|
+
var selectedCells = rect.map.cellsInRect(rect).length;
|
|
37
|
+
var totalCells = rect.map.map.length;
|
|
38
|
+
return {
|
|
39
|
+
action: ACTION.SELECTED,
|
|
40
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
41
|
+
actionSubjectId: ACTION_SUBJECT_ID.CELL,
|
|
42
|
+
eventType: EVENT_TYPE.TRACK,
|
|
43
|
+
attributes: {
|
|
44
|
+
selectedCells: selectedCells,
|
|
45
|
+
totalCells: totalCells
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export function getRangeSelectionAnalyticsPayload(selection, doc) {
|
|
51
|
+
if (selection instanceof TextSelection && selection.from !== selection.to) {
|
|
52
|
+
var from = selection.from,
|
|
53
|
+
to = selection.to,
|
|
54
|
+
anchor = selection.anchor,
|
|
55
|
+
head = selection.head;
|
|
56
|
+
var nodes = [];
|
|
57
|
+
doc.nodesBetween(from, to, function (node, pos) {
|
|
58
|
+
// We want to send top-level nodes only, ie. the nodes that would have the selection styling
|
|
59
|
+
// We allow text nodes that are not fully covered as they are a special case
|
|
60
|
+
if (node.isText || pos >= from && pos + node.nodeSize <= to) {
|
|
61
|
+
nodes.push(node.type.name);
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return {
|
|
66
|
+
action: ACTION.SELECTED,
|
|
67
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
68
|
+
actionSubjectId: ACTION_SUBJECT_ID.RANGE,
|
|
69
|
+
eventType: EVENT_TYPE.TRACK,
|
|
70
|
+
attributes: {
|
|
71
|
+
from: anchor,
|
|
72
|
+
to: head,
|
|
73
|
+
nodes: nodes
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -19,7 +19,7 @@ import { themed } from '@atlaskit/theme/components';
|
|
|
19
19
|
import { borderRadius } from '@atlaskit/theme/constants';
|
|
20
20
|
import Layer from '../Layer';
|
|
21
21
|
var packageName = "@atlaskit/editor-common";
|
|
22
|
-
var packageVersion = "75.
|
|
22
|
+
var packageVersion = "75.2.0";
|
|
23
23
|
var halfFocusRing = 1;
|
|
24
24
|
var dropOffset = '0, 8';
|
|
25
25
|
var DropList = /*#__PURE__*/function (_Component) {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import type { ACTION, AnalyticsEventPayload } from '../analytics';
|
|
3
|
+
export declare const copyToClipboard: (textToCopy: string) => Promise<void>;
|
|
4
|
+
export declare const copyHTMLToClipboard: (elementToCopy: HTMLElement, plainTextToCopy?: string) => Promise<void>;
|
|
5
|
+
export declare const copyHTMLToClipboardPolyfill: (elementToCopy: HTMLElement, plainTextToCopy?: string) => void;
|
|
6
|
+
export declare const getAnalyticsPayload: (state: EditorState, action: ACTION.CUT | ACTION.COPIED) => AnalyticsEventPayload | undefined;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { AnalyticsEventPayload } from '../analytics';
|
|
1
4
|
export { RelativeSelectionPos } from './types';
|
|
2
5
|
export type { SelectionPluginState, EditorSelectionAPI } from './types';
|
|
3
6
|
export { GapCursorSelection, Side, JSON_ID, GapBookmark, } from './gap-cursor/selection';
|
|
4
7
|
export { isIgnored, isValidTargetNode } from './gap-cursor/utils';
|
|
5
8
|
export { setGapCursorSelection } from './gap-cursor/utils/setGapCursorSelection';
|
|
6
9
|
export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent, } from './utils';
|
|
10
|
+
export declare function getNodeSelectionAnalyticsPayload(selection: Selection): AnalyticsEventPayload | undefined;
|
|
11
|
+
export declare function getAllSelectionAnalyticsPayload(selection: Selection): AnalyticsEventPayload | undefined;
|
|
12
|
+
export declare function getCellSelectionAnalyticsPayload(state: EditorState): AnalyticsEventPayload | undefined;
|
|
13
|
+
export declare function getRangeSelectionAnalyticsPayload(selection: Selection, doc: PmNode): AnalyticsEventPayload | undefined;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import type { ACTION, AnalyticsEventPayload } from '../analytics';
|
|
3
|
+
export declare const copyToClipboard: (textToCopy: string) => Promise<void>;
|
|
4
|
+
export declare const copyHTMLToClipboard: (elementToCopy: HTMLElement, plainTextToCopy?: string) => Promise<void>;
|
|
5
|
+
export declare const copyHTMLToClipboardPolyfill: (elementToCopy: HTMLElement, plainTextToCopy?: string) => void;
|
|
6
|
+
export declare const getAnalyticsPayload: (state: EditorState, action: ACTION.CUT | ACTION.COPIED) => AnalyticsEventPayload | undefined;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { AnalyticsEventPayload } from '../analytics';
|
|
1
4
|
export { RelativeSelectionPos } from './types';
|
|
2
5
|
export type { SelectionPluginState, EditorSelectionAPI } from './types';
|
|
3
6
|
export { GapCursorSelection, Side, JSON_ID, GapBookmark, } from './gap-cursor/selection';
|
|
4
7
|
export { isIgnored, isValidTargetNode } from './gap-cursor/utils';
|
|
5
8
|
export { setGapCursorSelection } from './gap-cursor/utils/setGapCursorSelection';
|
|
6
9
|
export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent, } from './utils';
|
|
10
|
+
export declare function getNodeSelectionAnalyticsPayload(selection: Selection): AnalyticsEventPayload | undefined;
|
|
11
|
+
export declare function getAllSelectionAnalyticsPayload(selection: Selection): AnalyticsEventPayload | undefined;
|
|
12
|
+
export declare function getCellSelectionAnalyticsPayload(state: EditorState): AnalyticsEventPayload | undefined;
|
|
13
|
+
export declare function getRangeSelectionAnalyticsPayload(selection: Selection, doc: PmNode): AnalyticsEventPayload | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-common",
|
|
3
|
-
"version": "75.
|
|
3
|
+
"version": "75.2.0",
|
|
4
4
|
"description": "A package that contains common classes and components for editor and renderer",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
"./link": "./src/link/index.ts",
|
|
78
78
|
"./mark": "./src/mark/index.ts",
|
|
79
79
|
"./commands": "./src/commands/index.ts",
|
|
80
|
+
"./clipboard": "./src/clipboard/index.ts",
|
|
80
81
|
"./lists": "./src/lists/index.ts",
|
|
81
82
|
"./element-browser": "./src/element-browser/index.ts"
|
|
82
83
|
},
|
|
@@ -114,7 +115,7 @@
|
|
|
114
115
|
"@atlaskit/task-decision": "^17.9.0",
|
|
115
116
|
"@atlaskit/textfield": "^5.6.0",
|
|
116
117
|
"@atlaskit/theme": "^12.6.0",
|
|
117
|
-
"@atlaskit/tokens": "^1.
|
|
118
|
+
"@atlaskit/tokens": "^1.23.0",
|
|
118
119
|
"@atlaskit/tooltip": "^17.8.0",
|
|
119
120
|
"@atlaskit/ufo": "^0.2.0",
|
|
120
121
|
"@atlaskit/width-detector": "^4.1.0",
|
|
@@ -124,6 +125,7 @@
|
|
|
124
125
|
"@sentry/integrations": "^6.18.2",
|
|
125
126
|
"chromatism": "^2.6.0",
|
|
126
127
|
"classnames": "^2.2.5",
|
|
128
|
+
"clipboard-polyfill": "2.4.3",
|
|
127
129
|
"date-fns": "^2.17.0",
|
|
128
130
|
"focus-trap": "^2.4.5",
|
|
129
131
|
"fuse.js": "^6.6.2",
|
|
@@ -149,7 +151,7 @@
|
|
|
149
151
|
"devDependencies": {
|
|
150
152
|
"@atlaskit/media-core": "^34.1.0",
|
|
151
153
|
"@atlaskit/media-test-helpers": "^33.0.0",
|
|
152
|
-
"@atlaskit/smart-card": "^26.
|
|
154
|
+
"@atlaskit/smart-card": "^26.27.0",
|
|
153
155
|
"@atlaskit/util-data-test": "^17.8.0",
|
|
154
156
|
"@atlaskit/visual-regression": "*",
|
|
155
157
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|