@atlaskit/editor-common 103.2.0 → 103.3.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 +13 -0
- package/dist/cjs/annotation/index.js +16 -1
- package/dist/cjs/annotation/manager.js +243 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/es2019/annotation/index.js +22 -0
- package/dist/es2019/annotation/manager.js +196 -0
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/esm/annotation/index.js +23 -1
- package/dist/esm/annotation/manager.js +236 -0
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/types/annotation/index.d.ts +132 -0
- package/dist/types/annotation/manager.d.ts +32 -0
- package/dist/types/types/annotation/index.d.ts +2 -0
- package/dist/types-ts4.5/annotation/index.d.ts +132 -0
- package/dist/types-ts4.5/annotation/manager.d.ts +32 -0
- package/dist/types-ts4.5/types/annotation/index.d.ts +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-common
|
|
2
2
|
|
|
3
|
+
## 103.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#137860](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/137860)
|
|
8
|
+
[`04e753d1ba0f4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/04e753d1ba0f4) -
|
|
9
|
+
Created a new Annotation manager implementation and interface and updated CCFE to create and share
|
|
10
|
+
this instance around
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 103.2.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.AnnotationUpdateEmitter = void 0;
|
|
8
|
+
exports.createAnnotationManager = createAnnotationManager;
|
|
8
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
11
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
@@ -12,6 +13,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
|
|
|
12
13
|
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
13
14
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
14
15
|
var _events = require("events");
|
|
16
|
+
var _manager = require("./manager");
|
|
15
17
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
16
18
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
17
19
|
function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
|
|
@@ -32,4 +34,17 @@ var AnnotationUpdateEmitter = exports.AnnotationUpdateEmitter = /*#__PURE__*/fun
|
|
|
32
34
|
return _superPropGet(AnnotationUpdateEmitter, "removeListener", this, 3)([event, listener]);
|
|
33
35
|
}
|
|
34
36
|
}]);
|
|
35
|
-
}(_events.EventEmitter);
|
|
37
|
+
}(_events.EventEmitter); // type ActionResult = { step: Step; doc: JSONDocNode } | false;
|
|
38
|
+
// } & AnnotationByMatches)
|
|
39
|
+
// | false;
|
|
40
|
+
// ### Events
|
|
41
|
+
// ### Hook Results
|
|
42
|
+
/**
|
|
43
|
+
* This is the list of methods which exist on the Manager interface. These are the methods that can be hooked into.
|
|
44
|
+
*/
|
|
45
|
+
/*
|
|
46
|
+
* This is the public interface for the AnnotationManager. It provides methods for interacting with the manager.
|
|
47
|
+
*/
|
|
48
|
+
function createAnnotationManager() {
|
|
49
|
+
return new _manager.SharedAnnotationManager();
|
|
50
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.SharedAnnotationManager = void 0;
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _events = require("events");
|
|
12
|
+
var SharedAnnotationManager = exports.SharedAnnotationManager = /*#__PURE__*/function () {
|
|
13
|
+
function SharedAnnotationManager() {
|
|
14
|
+
(0, _classCallCheck2.default)(this, SharedAnnotationManager);
|
|
15
|
+
/**
|
|
16
|
+
* This is the event emitter that is used to emit events from the manager. It is used to communicate with
|
|
17
|
+
* other parts of the application.
|
|
18
|
+
*/
|
|
19
|
+
(0, _defineProperty2.default)(this, "emitter", new _events.EventEmitter());
|
|
20
|
+
/**
|
|
21
|
+
* This is the map of hooks that can be added to the manager. Hooks are a 1:1 mapping of methods that can be
|
|
22
|
+
* called on the manager. They are used to extend the functionality of the manager.
|
|
23
|
+
*/
|
|
24
|
+
(0, _defineProperty2.default)(this, "hooks", new Map());
|
|
25
|
+
(0, _defineProperty2.default)(this, "preemptiveGate", function () {
|
|
26
|
+
return Promise.resolve(true);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return (0, _createClass2.default)(SharedAnnotationManager, [{
|
|
30
|
+
key: "setPreemptiveGate",
|
|
31
|
+
value: function setPreemptiveGate(handler) {
|
|
32
|
+
this.preemptiveGate = handler;
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
}, {
|
|
36
|
+
key: "checkPreemptiveGate",
|
|
37
|
+
value: function checkPreemptiveGate() {
|
|
38
|
+
return this.preemptiveGate();
|
|
39
|
+
}
|
|
40
|
+
}, {
|
|
41
|
+
key: "onDraftAnnotationStarted",
|
|
42
|
+
value: function onDraftAnnotationStarted(handler) {
|
|
43
|
+
this.emitter.on('draftAnnotationStarted', handler);
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
}, {
|
|
47
|
+
key: "offDraftAnnotationStarted",
|
|
48
|
+
value: function offDraftAnnotationStarted(handler) {
|
|
49
|
+
this.emitter.off('draftAnnotationStarted', handler);
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
}, {
|
|
53
|
+
key: "onAnnotationSelectionChange",
|
|
54
|
+
value: function onAnnotationSelectionChange(handler) {
|
|
55
|
+
this.emitter.on('annotationSelectionChanged', handler);
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
key: "offAnnotationSelectionChange",
|
|
60
|
+
value: function offAnnotationSelectionChange(handler) {
|
|
61
|
+
this.emitter.off('annotationSelectionChanged', handler);
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
}, {
|
|
65
|
+
key: "emit",
|
|
66
|
+
value: function emit(event) {
|
|
67
|
+
this.emitter.emit(event.name, event.data);
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
}, {
|
|
71
|
+
key: "hook",
|
|
72
|
+
value: function hook(method, handler) {
|
|
73
|
+
this.hooks.set(method, handler);
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
}, {
|
|
77
|
+
key: "unhook",
|
|
78
|
+
value: function unhook(method, handler) {
|
|
79
|
+
if (!this.hooks.has(method) || this.hooks.get(method) !== handler) {
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
this.hooks.delete(method);
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
}, {
|
|
86
|
+
key: "allowAnnotation",
|
|
87
|
+
value: function allowAnnotation() {
|
|
88
|
+
var fn = this.hooks.get('allowAnnotation');
|
|
89
|
+
if (!fn) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
return fn();
|
|
94
|
+
} catch (error) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}, {
|
|
99
|
+
key: "startDraft",
|
|
100
|
+
value: function startDraft() {
|
|
101
|
+
var fn = this.hooks.get('startDraft');
|
|
102
|
+
if (!fn) {
|
|
103
|
+
return {
|
|
104
|
+
success: false,
|
|
105
|
+
reason: 'manager-not-initialized'
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
var result = fn();
|
|
110
|
+
if (result.success) {
|
|
111
|
+
this.emitter.emit('draftAnnotationStarted', {
|
|
112
|
+
targetElement: result.targetElement,
|
|
113
|
+
inlineNodeTypes: result.inlineNodeTypes,
|
|
114
|
+
actionResult: result.actionResult
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
} catch (error) {
|
|
119
|
+
return {
|
|
120
|
+
success: false,
|
|
121
|
+
reason: 'hook-execution-error'
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}, {
|
|
126
|
+
key: "clearDraft",
|
|
127
|
+
value: function clearDraft() {
|
|
128
|
+
var fn = this.hooks.get('clearDraft');
|
|
129
|
+
if (!fn) {
|
|
130
|
+
return {
|
|
131
|
+
success: false,
|
|
132
|
+
reason: 'manager-not-initialized'
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
return fn();
|
|
137
|
+
} catch (error) {
|
|
138
|
+
return {
|
|
139
|
+
success: false,
|
|
140
|
+
reason: 'hook-execution-error'
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}, {
|
|
145
|
+
key: "applyDraft",
|
|
146
|
+
value: function applyDraft(id) {
|
|
147
|
+
var fn = this.hooks.get('applyDraft');
|
|
148
|
+
if (!fn) {
|
|
149
|
+
return {
|
|
150
|
+
success: false,
|
|
151
|
+
reason: 'manager-not-initialized'
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
return fn(id);
|
|
156
|
+
} catch (error) {
|
|
157
|
+
return {
|
|
158
|
+
success: false,
|
|
159
|
+
reason: 'hook-execution-error'
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}, {
|
|
164
|
+
key: "getDraft",
|
|
165
|
+
value: function getDraft() {
|
|
166
|
+
var fn = this.hooks.get('getDraft');
|
|
167
|
+
if (!fn) {
|
|
168
|
+
return {
|
|
169
|
+
success: false,
|
|
170
|
+
reason: 'manager-not-initialized'
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
try {
|
|
174
|
+
return fn();
|
|
175
|
+
} catch (error) {
|
|
176
|
+
return {
|
|
177
|
+
success: false,
|
|
178
|
+
reason: 'hook-execution-error'
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}, {
|
|
183
|
+
key: "setIsAnnotationSelected",
|
|
184
|
+
value: function setIsAnnotationSelected(id, isSelected) {
|
|
185
|
+
var fn = this.hooks.get('setIsAnnotationSelected');
|
|
186
|
+
if (!fn) {
|
|
187
|
+
return {
|
|
188
|
+
success: false,
|
|
189
|
+
reason: 'manager-not-initialized'
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
try {
|
|
193
|
+
// NOTE: The hook needs to manage the firing the annotationSelectionChanged event when a change is made. This is
|
|
194
|
+
// because the hook is responsible for the state of the selection. The manager is not responsible for the state of
|
|
195
|
+
// the selection.
|
|
196
|
+
return fn(id, isSelected);
|
|
197
|
+
} catch (error) {
|
|
198
|
+
return {
|
|
199
|
+
success: false,
|
|
200
|
+
reason: 'hook-execution-error'
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}, {
|
|
205
|
+
key: "setIsAnnotationHovered",
|
|
206
|
+
value: function setIsAnnotationHovered(id, isHovered) {
|
|
207
|
+
var fn = this.hooks.get('setIsAnnotationHovered');
|
|
208
|
+
if (!fn) {
|
|
209
|
+
return {
|
|
210
|
+
success: false,
|
|
211
|
+
reason: 'manager-not-initialized'
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
try {
|
|
215
|
+
return fn(id, isHovered);
|
|
216
|
+
} catch (error) {
|
|
217
|
+
return {
|
|
218
|
+
success: false,
|
|
219
|
+
reason: 'hook-execution-error'
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}, {
|
|
224
|
+
key: "clearAnnotation",
|
|
225
|
+
value: function clearAnnotation(id) {
|
|
226
|
+
var fn = this.hooks.get('clearAnnotation');
|
|
227
|
+
if (!fn) {
|
|
228
|
+
return {
|
|
229
|
+
success: false,
|
|
230
|
+
reason: 'manager-not-initialized'
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
try {
|
|
234
|
+
return fn(id);
|
|
235
|
+
} catch (error) {
|
|
236
|
+
return {
|
|
237
|
+
success: false,
|
|
238
|
+
reason: 'hook-execution-error'
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}]);
|
|
243
|
+
}();
|
|
@@ -17,7 +17,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
17
17
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
18
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
19
19
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
20
|
-
var packageVersion = "103.
|
|
20
|
+
var packageVersion = "103.3.0";
|
|
21
21
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
22
22
|
// Remove URL as it has UGC
|
|
23
23
|
// Ignored via go/ees007
|
|
@@ -23,7 +23,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
23
23
|
* @jsx jsx
|
|
24
24
|
*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
25
25
|
var packageName = "@atlaskit/editor-common";
|
|
26
|
-
var packageVersion = "103.
|
|
26
|
+
var packageVersion = "103.3.0";
|
|
27
27
|
var halfFocusRing = 1;
|
|
28
28
|
var dropOffset = '0, 8';
|
|
29
29
|
// Ignored via go/ees005
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
+
import { SharedAnnotationManager } from './manager';
|
|
2
3
|
export class AnnotationUpdateEmitter extends EventEmitter {
|
|
3
4
|
on(event, listener) {
|
|
4
5
|
return super.on(event, listener);
|
|
@@ -6,4 +7,25 @@ export class AnnotationUpdateEmitter extends EventEmitter {
|
|
|
6
7
|
off(event, listener) {
|
|
7
8
|
return super.removeListener(event, listener);
|
|
8
9
|
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// type ActionResult = { step: Step; doc: JSONDocNode } | false;
|
|
13
|
+
|
|
14
|
+
// } & AnnotationByMatches)
|
|
15
|
+
// | false;
|
|
16
|
+
|
|
17
|
+
// ### Events
|
|
18
|
+
|
|
19
|
+
// ### Hook Results
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* This is the list of methods which exist on the Manager interface. These are the methods that can be hooked into.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/*
|
|
26
|
+
* This is the public interface for the AnnotationManager. It provides methods for interacting with the manager.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
export function createAnnotationManager() {
|
|
30
|
+
return new SharedAnnotationManager();
|
|
9
31
|
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
export class SharedAnnotationManager {
|
|
4
|
+
constructor() {
|
|
5
|
+
/**
|
|
6
|
+
* This is the event emitter that is used to emit events from the manager. It is used to communicate with
|
|
7
|
+
* other parts of the application.
|
|
8
|
+
*/
|
|
9
|
+
_defineProperty(this, "emitter", new EventEmitter());
|
|
10
|
+
/**
|
|
11
|
+
* This is the map of hooks that can be added to the manager. Hooks are a 1:1 mapping of methods that can be
|
|
12
|
+
* called on the manager. They are used to extend the functionality of the manager.
|
|
13
|
+
*/
|
|
14
|
+
_defineProperty(this, "hooks", new Map());
|
|
15
|
+
_defineProperty(this, "preemptiveGate", () => Promise.resolve(true));
|
|
16
|
+
}
|
|
17
|
+
setPreemptiveGate(handler) {
|
|
18
|
+
this.preemptiveGate = handler;
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
checkPreemptiveGate() {
|
|
22
|
+
return this.preemptiveGate();
|
|
23
|
+
}
|
|
24
|
+
onDraftAnnotationStarted(handler) {
|
|
25
|
+
this.emitter.on('draftAnnotationStarted', handler);
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
offDraftAnnotationStarted(handler) {
|
|
29
|
+
this.emitter.off('draftAnnotationStarted', handler);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
onAnnotationSelectionChange(handler) {
|
|
33
|
+
this.emitter.on('annotationSelectionChanged', handler);
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
offAnnotationSelectionChange(handler) {
|
|
37
|
+
this.emitter.off('annotationSelectionChanged', handler);
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
emit(event) {
|
|
41
|
+
this.emitter.emit(event.name, event.data);
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
hook(method, handler) {
|
|
45
|
+
this.hooks.set(method, handler);
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
unhook(method, handler) {
|
|
49
|
+
if (!this.hooks.has(method) || this.hooks.get(method) !== handler) {
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
this.hooks.delete(method);
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
allowAnnotation() {
|
|
56
|
+
const fn = this.hooks.get('allowAnnotation');
|
|
57
|
+
if (!fn) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
return fn();
|
|
62
|
+
} catch (error) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
startDraft() {
|
|
67
|
+
const fn = this.hooks.get('startDraft');
|
|
68
|
+
if (!fn) {
|
|
69
|
+
return {
|
|
70
|
+
success: false,
|
|
71
|
+
reason: 'manager-not-initialized'
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
const result = fn();
|
|
76
|
+
if (result.success) {
|
|
77
|
+
this.emitter.emit('draftAnnotationStarted', {
|
|
78
|
+
targetElement: result.targetElement,
|
|
79
|
+
inlineNodeTypes: result.inlineNodeTypes,
|
|
80
|
+
actionResult: result.actionResult
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
84
|
+
} catch (error) {
|
|
85
|
+
return {
|
|
86
|
+
success: false,
|
|
87
|
+
reason: 'hook-execution-error'
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
clearDraft() {
|
|
92
|
+
const fn = this.hooks.get('clearDraft');
|
|
93
|
+
if (!fn) {
|
|
94
|
+
return {
|
|
95
|
+
success: false,
|
|
96
|
+
reason: 'manager-not-initialized'
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
return fn();
|
|
101
|
+
} catch (error) {
|
|
102
|
+
return {
|
|
103
|
+
success: false,
|
|
104
|
+
reason: 'hook-execution-error'
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
applyDraft(id) {
|
|
109
|
+
const fn = this.hooks.get('applyDraft');
|
|
110
|
+
if (!fn) {
|
|
111
|
+
return {
|
|
112
|
+
success: false,
|
|
113
|
+
reason: 'manager-not-initialized'
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
return fn(id);
|
|
118
|
+
} catch (error) {
|
|
119
|
+
return {
|
|
120
|
+
success: false,
|
|
121
|
+
reason: 'hook-execution-error'
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
getDraft() {
|
|
126
|
+
const fn = this.hooks.get('getDraft');
|
|
127
|
+
if (!fn) {
|
|
128
|
+
return {
|
|
129
|
+
success: false,
|
|
130
|
+
reason: 'manager-not-initialized'
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
return fn();
|
|
135
|
+
} catch (error) {
|
|
136
|
+
return {
|
|
137
|
+
success: false,
|
|
138
|
+
reason: 'hook-execution-error'
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
setIsAnnotationSelected(id, isSelected) {
|
|
143
|
+
const fn = this.hooks.get('setIsAnnotationSelected');
|
|
144
|
+
if (!fn) {
|
|
145
|
+
return {
|
|
146
|
+
success: false,
|
|
147
|
+
reason: 'manager-not-initialized'
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
// NOTE: The hook needs to manage the firing the annotationSelectionChanged event when a change is made. This is
|
|
152
|
+
// because the hook is responsible for the state of the selection. The manager is not responsible for the state of
|
|
153
|
+
// the selection.
|
|
154
|
+
return fn(id, isSelected);
|
|
155
|
+
} catch (error) {
|
|
156
|
+
return {
|
|
157
|
+
success: false,
|
|
158
|
+
reason: 'hook-execution-error'
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
setIsAnnotationHovered(id, isHovered) {
|
|
163
|
+
const fn = this.hooks.get('setIsAnnotationHovered');
|
|
164
|
+
if (!fn) {
|
|
165
|
+
return {
|
|
166
|
+
success: false,
|
|
167
|
+
reason: 'manager-not-initialized'
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
try {
|
|
171
|
+
return fn(id, isHovered);
|
|
172
|
+
} catch (error) {
|
|
173
|
+
return {
|
|
174
|
+
success: false,
|
|
175
|
+
reason: 'hook-execution-error'
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
clearAnnotation(id) {
|
|
180
|
+
const fn = this.hooks.get('clearAnnotation');
|
|
181
|
+
if (!fn) {
|
|
182
|
+
return {
|
|
183
|
+
success: false,
|
|
184
|
+
reason: 'manager-not-initialized'
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
try {
|
|
188
|
+
return fn(id);
|
|
189
|
+
} catch (error) {
|
|
190
|
+
return {
|
|
191
|
+
success: false,
|
|
192
|
+
reason: 'hook-execution-error'
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isFedRamp } from './environment';
|
|
2
2
|
const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
3
3
|
const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
4
|
-
const packageVersion = "103.
|
|
4
|
+
const packageVersion = "103.3.0";
|
|
5
5
|
const sanitiseSentryEvents = (data, _hint) => {
|
|
6
6
|
// Remove URL as it has UGC
|
|
7
7
|
// Ignored via go/ees007
|
|
@@ -13,7 +13,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
|
|
|
13
13
|
import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
14
14
|
import Layer from '../Layer';
|
|
15
15
|
const packageName = "@atlaskit/editor-common";
|
|
16
|
-
const packageVersion = "103.
|
|
16
|
+
const packageVersion = "103.3.0";
|
|
17
17
|
const halfFocusRing = 1;
|
|
18
18
|
const dropOffset = '0, 8';
|
|
19
19
|
// Ignored via go/ees005
|
|
@@ -8,6 +8,7 @@ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstruct
|
|
|
8
8
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
9
9
|
function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
|
|
10
10
|
import { EventEmitter } from 'events';
|
|
11
|
+
import { SharedAnnotationManager } from './manager';
|
|
11
12
|
export var AnnotationUpdateEmitter = /*#__PURE__*/function (_EventEmitter) {
|
|
12
13
|
function AnnotationUpdateEmitter() {
|
|
13
14
|
_classCallCheck(this, AnnotationUpdateEmitter);
|
|
@@ -25,4 +26,25 @@ export var AnnotationUpdateEmitter = /*#__PURE__*/function (_EventEmitter) {
|
|
|
25
26
|
return _superPropGet(AnnotationUpdateEmitter, "removeListener", this, 3)([event, listener]);
|
|
26
27
|
}
|
|
27
28
|
}]);
|
|
28
|
-
}(EventEmitter);
|
|
29
|
+
}(EventEmitter);
|
|
30
|
+
|
|
31
|
+
// type ActionResult = { step: Step; doc: JSONDocNode } | false;
|
|
32
|
+
|
|
33
|
+
// } & AnnotationByMatches)
|
|
34
|
+
// | false;
|
|
35
|
+
|
|
36
|
+
// ### Events
|
|
37
|
+
|
|
38
|
+
// ### Hook Results
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* This is the list of methods which exist on the Manager interface. These are the methods that can be hooked into.
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
* This is the public interface for the AnnotationManager. It provides methods for interacting with the manager.
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
export function createAnnotationManager() {
|
|
49
|
+
return new SharedAnnotationManager();
|
|
50
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
import { EventEmitter } from 'events';
|
|
5
|
+
export var SharedAnnotationManager = /*#__PURE__*/function () {
|
|
6
|
+
function SharedAnnotationManager() {
|
|
7
|
+
_classCallCheck(this, SharedAnnotationManager);
|
|
8
|
+
/**
|
|
9
|
+
* This is the event emitter that is used to emit events from the manager. It is used to communicate with
|
|
10
|
+
* other parts of the application.
|
|
11
|
+
*/
|
|
12
|
+
_defineProperty(this, "emitter", new EventEmitter());
|
|
13
|
+
/**
|
|
14
|
+
* This is the map of hooks that can be added to the manager. Hooks are a 1:1 mapping of methods that can be
|
|
15
|
+
* called on the manager. They are used to extend the functionality of the manager.
|
|
16
|
+
*/
|
|
17
|
+
_defineProperty(this, "hooks", new Map());
|
|
18
|
+
_defineProperty(this, "preemptiveGate", function () {
|
|
19
|
+
return Promise.resolve(true);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return _createClass(SharedAnnotationManager, [{
|
|
23
|
+
key: "setPreemptiveGate",
|
|
24
|
+
value: function setPreemptiveGate(handler) {
|
|
25
|
+
this.preemptiveGate = handler;
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
}, {
|
|
29
|
+
key: "checkPreemptiveGate",
|
|
30
|
+
value: function checkPreemptiveGate() {
|
|
31
|
+
return this.preemptiveGate();
|
|
32
|
+
}
|
|
33
|
+
}, {
|
|
34
|
+
key: "onDraftAnnotationStarted",
|
|
35
|
+
value: function onDraftAnnotationStarted(handler) {
|
|
36
|
+
this.emitter.on('draftAnnotationStarted', handler);
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
key: "offDraftAnnotationStarted",
|
|
41
|
+
value: function offDraftAnnotationStarted(handler) {
|
|
42
|
+
this.emitter.off('draftAnnotationStarted', handler);
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
}, {
|
|
46
|
+
key: "onAnnotationSelectionChange",
|
|
47
|
+
value: function onAnnotationSelectionChange(handler) {
|
|
48
|
+
this.emitter.on('annotationSelectionChanged', handler);
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
}, {
|
|
52
|
+
key: "offAnnotationSelectionChange",
|
|
53
|
+
value: function offAnnotationSelectionChange(handler) {
|
|
54
|
+
this.emitter.off('annotationSelectionChanged', handler);
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
}, {
|
|
58
|
+
key: "emit",
|
|
59
|
+
value: function emit(event) {
|
|
60
|
+
this.emitter.emit(event.name, event.data);
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
key: "hook",
|
|
65
|
+
value: function hook(method, handler) {
|
|
66
|
+
this.hooks.set(method, handler);
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
key: "unhook",
|
|
71
|
+
value: function unhook(method, handler) {
|
|
72
|
+
if (!this.hooks.has(method) || this.hooks.get(method) !== handler) {
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
this.hooks.delete(method);
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
}, {
|
|
79
|
+
key: "allowAnnotation",
|
|
80
|
+
value: function allowAnnotation() {
|
|
81
|
+
var fn = this.hooks.get('allowAnnotation');
|
|
82
|
+
if (!fn) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
return fn();
|
|
87
|
+
} catch (error) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
key: "startDraft",
|
|
93
|
+
value: function startDraft() {
|
|
94
|
+
var fn = this.hooks.get('startDraft');
|
|
95
|
+
if (!fn) {
|
|
96
|
+
return {
|
|
97
|
+
success: false,
|
|
98
|
+
reason: 'manager-not-initialized'
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
var result = fn();
|
|
103
|
+
if (result.success) {
|
|
104
|
+
this.emitter.emit('draftAnnotationStarted', {
|
|
105
|
+
targetElement: result.targetElement,
|
|
106
|
+
inlineNodeTypes: result.inlineNodeTypes,
|
|
107
|
+
actionResult: result.actionResult
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return result;
|
|
111
|
+
} catch (error) {
|
|
112
|
+
return {
|
|
113
|
+
success: false,
|
|
114
|
+
reason: 'hook-execution-error'
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}, {
|
|
119
|
+
key: "clearDraft",
|
|
120
|
+
value: function clearDraft() {
|
|
121
|
+
var fn = this.hooks.get('clearDraft');
|
|
122
|
+
if (!fn) {
|
|
123
|
+
return {
|
|
124
|
+
success: false,
|
|
125
|
+
reason: 'manager-not-initialized'
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
return fn();
|
|
130
|
+
} catch (error) {
|
|
131
|
+
return {
|
|
132
|
+
success: false,
|
|
133
|
+
reason: 'hook-execution-error'
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}, {
|
|
138
|
+
key: "applyDraft",
|
|
139
|
+
value: function applyDraft(id) {
|
|
140
|
+
var fn = this.hooks.get('applyDraft');
|
|
141
|
+
if (!fn) {
|
|
142
|
+
return {
|
|
143
|
+
success: false,
|
|
144
|
+
reason: 'manager-not-initialized'
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
return fn(id);
|
|
149
|
+
} catch (error) {
|
|
150
|
+
return {
|
|
151
|
+
success: false,
|
|
152
|
+
reason: 'hook-execution-error'
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}, {
|
|
157
|
+
key: "getDraft",
|
|
158
|
+
value: function getDraft() {
|
|
159
|
+
var fn = this.hooks.get('getDraft');
|
|
160
|
+
if (!fn) {
|
|
161
|
+
return {
|
|
162
|
+
success: false,
|
|
163
|
+
reason: 'manager-not-initialized'
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
try {
|
|
167
|
+
return fn();
|
|
168
|
+
} catch (error) {
|
|
169
|
+
return {
|
|
170
|
+
success: false,
|
|
171
|
+
reason: 'hook-execution-error'
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}, {
|
|
176
|
+
key: "setIsAnnotationSelected",
|
|
177
|
+
value: function setIsAnnotationSelected(id, isSelected) {
|
|
178
|
+
var fn = this.hooks.get('setIsAnnotationSelected');
|
|
179
|
+
if (!fn) {
|
|
180
|
+
return {
|
|
181
|
+
success: false,
|
|
182
|
+
reason: 'manager-not-initialized'
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
try {
|
|
186
|
+
// NOTE: The hook needs to manage the firing the annotationSelectionChanged event when a change is made. This is
|
|
187
|
+
// because the hook is responsible for the state of the selection. The manager is not responsible for the state of
|
|
188
|
+
// the selection.
|
|
189
|
+
return fn(id, isSelected);
|
|
190
|
+
} catch (error) {
|
|
191
|
+
return {
|
|
192
|
+
success: false,
|
|
193
|
+
reason: 'hook-execution-error'
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}, {
|
|
198
|
+
key: "setIsAnnotationHovered",
|
|
199
|
+
value: function setIsAnnotationHovered(id, isHovered) {
|
|
200
|
+
var fn = this.hooks.get('setIsAnnotationHovered');
|
|
201
|
+
if (!fn) {
|
|
202
|
+
return {
|
|
203
|
+
success: false,
|
|
204
|
+
reason: 'manager-not-initialized'
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
try {
|
|
208
|
+
return fn(id, isHovered);
|
|
209
|
+
} catch (error) {
|
|
210
|
+
return {
|
|
211
|
+
success: false,
|
|
212
|
+
reason: 'hook-execution-error'
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}, {
|
|
217
|
+
key: "clearAnnotation",
|
|
218
|
+
value: function clearAnnotation(id) {
|
|
219
|
+
var fn = this.hooks.get('clearAnnotation');
|
|
220
|
+
if (!fn) {
|
|
221
|
+
return {
|
|
222
|
+
success: false,
|
|
223
|
+
reason: 'manager-not-initialized'
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
try {
|
|
227
|
+
return fn(id);
|
|
228
|
+
} catch (error) {
|
|
229
|
+
return {
|
|
230
|
+
success: false,
|
|
231
|
+
reason: 'hook-execution-error'
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}]);
|
|
236
|
+
}();
|
|
@@ -7,7 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
7
7
|
import { isFedRamp } from './environment';
|
|
8
8
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
9
9
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
10
|
-
var packageVersion = "103.
|
|
10
|
+
var packageVersion = "103.3.0";
|
|
11
11
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
12
12
|
// Remove URL as it has UGC
|
|
13
13
|
// Ignored via go/ees007
|
|
@@ -20,7 +20,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
|
|
|
20
20
|
import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
21
21
|
import Layer from '../Layer';
|
|
22
22
|
var packageName = "@atlaskit/editor-common";
|
|
23
|
-
var packageVersion = "103.
|
|
23
|
+
var packageVersion = "103.3.0";
|
|
24
24
|
var halfFocusRing = 1;
|
|
25
25
|
var dropOffset = '0, 8';
|
|
26
26
|
// Ignored via go/ees005
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
/// <reference types="node/events" />
|
|
3
3
|
/// <reference types="typings/events" />
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
|
+
import type { AnnotationId } from '@atlaskit/adf-schema';
|
|
6
|
+
import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
7
|
+
import type { Step } from '@atlaskit/editor-prosemirror/transform';
|
|
5
8
|
export type UpdateEvent = 'create' | 'delete' | 'resolve' | 'unresolve' | 'setselectedannotation' | 'sethoveredannotation' | 'removehoveredannotation';
|
|
6
9
|
export type VisibilityEvent = 'setvisibility';
|
|
7
10
|
type AnnotationCallback = (params: string) => void;
|
|
@@ -11,4 +14,133 @@ export declare class AnnotationUpdateEmitter extends EventEmitter {
|
|
|
11
14
|
on(event: UpdateEvent, listener: (annotationId: string) => void): this;
|
|
12
15
|
off(event: string, listener: AnnotationCallback | VisibilityCallback): this;
|
|
13
16
|
}
|
|
17
|
+
type ActionResult = {
|
|
18
|
+
step: Step;
|
|
19
|
+
doc: JSONDocNode;
|
|
20
|
+
/** The list of types of all inline nodes, which were wrapped by annotation. */
|
|
21
|
+
inlineNodeTypes?: string[];
|
|
22
|
+
targetNodeType?: string;
|
|
23
|
+
};
|
|
24
|
+
export type AnnotationDraftStartedData = {
|
|
25
|
+
targetElement: HTMLElement | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* This list of inline node types at the draft selection location
|
|
28
|
+
*/
|
|
29
|
+
inlineNodeTypes: string[];
|
|
30
|
+
/**
|
|
31
|
+
* The actionResult can be used by Product so they're able to perform the
|
|
32
|
+
* required NCS transaction to add the annotation to the document.
|
|
33
|
+
*/
|
|
34
|
+
actionResult: ActionResult | undefined;
|
|
35
|
+
};
|
|
36
|
+
export type AnnotationSelectedChangeData = {
|
|
37
|
+
annotationId: AnnotationId;
|
|
38
|
+
isSelected: boolean;
|
|
39
|
+
inlineNodeTypes: string[];
|
|
40
|
+
};
|
|
41
|
+
export type AnnotationManagerEvents = {
|
|
42
|
+
name: 'draftAnnotationStarted';
|
|
43
|
+
data: AnnotationDraftStartedData;
|
|
44
|
+
} | {
|
|
45
|
+
name: 'annotationSelectionChanged';
|
|
46
|
+
data: AnnotationSelectedChangeData;
|
|
47
|
+
};
|
|
48
|
+
export type ManagerFailureReasons = 'manager-not-initialized' | 'hook-execution-error';
|
|
49
|
+
export type StartDraftResult = {
|
|
50
|
+
success: false;
|
|
51
|
+
reason: ManagerFailureReasons | 'invalid-range' | 'draft-in-progress';
|
|
52
|
+
} | ({
|
|
53
|
+
success: true;
|
|
54
|
+
} & AnnotationDraftStartedData);
|
|
55
|
+
export type ClearDraftResult = {
|
|
56
|
+
success: false;
|
|
57
|
+
reason: ManagerFailureReasons | 'draft-not-started';
|
|
58
|
+
} | {
|
|
59
|
+
success: true;
|
|
60
|
+
};
|
|
61
|
+
export type ApplyDraftResult = {
|
|
62
|
+
success: false;
|
|
63
|
+
reason: ManagerFailureReasons | 'draft-not-started' | 'range-no-longer-exists';
|
|
64
|
+
} | {
|
|
65
|
+
success: true;
|
|
66
|
+
targetElement: HTMLElement | undefined;
|
|
67
|
+
};
|
|
68
|
+
export type GetDraftResult = {
|
|
69
|
+
success: false;
|
|
70
|
+
reason: ManagerFailureReasons | 'draft-not-started';
|
|
71
|
+
} | ({
|
|
72
|
+
success: true;
|
|
73
|
+
} & AnnotationDraftStartedData);
|
|
74
|
+
export type ClearAnnotationResult = {
|
|
75
|
+
success: false;
|
|
76
|
+
reason: ManagerFailureReasons | 'id-not-valid';
|
|
77
|
+
} | {
|
|
78
|
+
success: true;
|
|
79
|
+
actionResult: ActionResult | undefined;
|
|
80
|
+
};
|
|
81
|
+
export type SelectAnnotationResult = {
|
|
82
|
+
success: false;
|
|
83
|
+
reason: ManagerFailureReasons | 'id-not-valid';
|
|
84
|
+
} | {
|
|
85
|
+
success: true;
|
|
86
|
+
isSelected: boolean;
|
|
87
|
+
};
|
|
88
|
+
export type HoverAnnotationResult = {
|
|
89
|
+
success: false;
|
|
90
|
+
reason: ManagerFailureReasons | 'id-not-valid';
|
|
91
|
+
} | {
|
|
92
|
+
success: true;
|
|
93
|
+
isHovered: boolean;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* This is the list of methods which exist on the Manager interface. These are the methods that can be hooked into.
|
|
97
|
+
*/
|
|
98
|
+
export type AnnotationManagerMethods = {
|
|
99
|
+
allowAnnotation: () => boolean;
|
|
100
|
+
startDraft: () => StartDraftResult;
|
|
101
|
+
clearDraft: () => ClearDraftResult;
|
|
102
|
+
applyDraft: (id: AnnotationId) => ApplyDraftResult;
|
|
103
|
+
getDraft: () => GetDraftResult;
|
|
104
|
+
setIsAnnotationSelected: (id: AnnotationId, isSelected: boolean) => SelectAnnotationResult;
|
|
105
|
+
setIsAnnotationHovered: (id: AnnotationId, isHovered: boolean) => HoverAnnotationResult;
|
|
106
|
+
clearAnnotation: (id: AnnotationId) => ClearAnnotationResult;
|
|
107
|
+
};
|
|
108
|
+
export type AnnotationManager = AnnotationManagerMethods & {
|
|
109
|
+
/**
|
|
110
|
+
* This method is used to set a preemptive gate. A preemptive gate is a function that will be called
|
|
111
|
+
* before the manager performs an action. If the function returns false, the action will not be performed.
|
|
112
|
+
*/
|
|
113
|
+
setPreemptiveGate(handler: () => Promise<boolean>): AnnotationManager;
|
|
114
|
+
/**
|
|
115
|
+
* This method is used to run the configured preemptive gate check.
|
|
116
|
+
* @internal
|
|
117
|
+
*/
|
|
118
|
+
checkPreemptiveGate(): Promise<boolean>;
|
|
119
|
+
onDraftAnnotationStarted(handler: (data: AnnotationDraftStartedData) => void): AnnotationManager;
|
|
120
|
+
offDraftAnnotationStarted(handler: (data: AnnotationDraftStartedData) => void): AnnotationManager;
|
|
121
|
+
onAnnotationSelectionChange(handler: (data: AnnotationSelectedChangeData) => void): AnnotationManager;
|
|
122
|
+
offAnnotationSelectionChange(handler: (data: AnnotationSelectedChangeData) => void): AnnotationManager;
|
|
123
|
+
/**
|
|
124
|
+
* @internal
|
|
125
|
+
* This method is intended for internal Platform use only. It is not intended for use by Product code.
|
|
126
|
+
*/
|
|
127
|
+
emit(event: {
|
|
128
|
+
name: 'draftAnnotationStarted';
|
|
129
|
+
data: AnnotationDraftStartedData;
|
|
130
|
+
} | {
|
|
131
|
+
name: 'annotationSelectionChanged';
|
|
132
|
+
data: AnnotationSelectedChangeData;
|
|
133
|
+
}): AnnotationManager;
|
|
134
|
+
/**
|
|
135
|
+
* @internal
|
|
136
|
+
* This method is intended for internal Platform use only. It is not intended for use by Product code.
|
|
137
|
+
*/
|
|
138
|
+
hook<H extends keyof AnnotationManagerMethods>(method: H, handler: AnnotationManagerMethods[H]): AnnotationManager;
|
|
139
|
+
/**
|
|
140
|
+
* @internal
|
|
141
|
+
* This method is intended for internal Platform use only. It is not intended for use by Product code.
|
|
142
|
+
*/
|
|
143
|
+
unhook<H extends keyof AnnotationManagerMethods>(method: H, handler: AnnotationManagerMethods[H]): AnnotationManager;
|
|
144
|
+
};
|
|
145
|
+
export declare function createAnnotationManager(): AnnotationManager;
|
|
14
146
|
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AnnotationId } from '@atlaskit/adf-schema';
|
|
2
|
+
import type { AnnotationDraftStartedData, AnnotationManager, AnnotationManagerEvents, AnnotationManagerMethods, AnnotationSelectedChangeData, ApplyDraftResult, ClearAnnotationResult, ClearDraftResult, GetDraftResult, HoverAnnotationResult, SelectAnnotationResult, StartDraftResult } from './index';
|
|
3
|
+
export declare class SharedAnnotationManager implements AnnotationManager {
|
|
4
|
+
/**
|
|
5
|
+
* This is the event emitter that is used to emit events from the manager. It is used to communicate with
|
|
6
|
+
* other parts of the application.
|
|
7
|
+
*/
|
|
8
|
+
private emitter;
|
|
9
|
+
/**
|
|
10
|
+
* This is the map of hooks that can be added to the manager. Hooks are a 1:1 mapping of methods that can be
|
|
11
|
+
* called on the manager. They are used to extend the functionality of the manager.
|
|
12
|
+
*/
|
|
13
|
+
private hooks;
|
|
14
|
+
private preemptiveGate;
|
|
15
|
+
setPreemptiveGate(handler: () => Promise<boolean>): AnnotationManager;
|
|
16
|
+
checkPreemptiveGate(): Promise<boolean>;
|
|
17
|
+
onDraftAnnotationStarted(handler: (data: AnnotationDraftStartedData) => void): AnnotationManager;
|
|
18
|
+
offDraftAnnotationStarted(handler: (data: AnnotationDraftStartedData) => void): AnnotationManager;
|
|
19
|
+
onAnnotationSelectionChange(handler: (data: AnnotationSelectedChangeData) => void): AnnotationManager;
|
|
20
|
+
offAnnotationSelectionChange(handler: (data: AnnotationSelectedChangeData) => void): AnnotationManager;
|
|
21
|
+
emit(event: AnnotationManagerEvents): AnnotationManager;
|
|
22
|
+
hook<H extends keyof AnnotationManagerMethods>(method: H, handler: AnnotationManagerMethods[H]): AnnotationManager;
|
|
23
|
+
unhook<H extends keyof AnnotationManagerMethods>(method: H, handler: AnnotationManagerMethods[H]): AnnotationManager;
|
|
24
|
+
allowAnnotation(): boolean;
|
|
25
|
+
startDraft(): StartDraftResult;
|
|
26
|
+
clearDraft(): ClearDraftResult;
|
|
27
|
+
applyDraft(id: AnnotationId): ApplyDraftResult;
|
|
28
|
+
getDraft(): GetDraftResult;
|
|
29
|
+
setIsAnnotationSelected(id: string, isSelected: boolean): SelectAnnotationResult;
|
|
30
|
+
setIsAnnotationHovered(id: string, isHovered: boolean): HoverAnnotationResult;
|
|
31
|
+
clearAnnotation(id: AnnotationId): ClearAnnotationResult;
|
|
32
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { AnnotationId, AnnotationTypes } from '@atlaskit/adf-schema';
|
|
3
3
|
import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
4
4
|
import type { Step } from '@atlaskit/editor-prosemirror/transform';
|
|
5
|
+
import type { AnnotationManager } from '../../annotation';
|
|
5
6
|
import type { AnnotationState, AnnotationUpdateEmitter } from './emitter';
|
|
6
7
|
export type AnnotationByMatches = {
|
|
7
8
|
originalSelection: string;
|
|
@@ -141,5 +142,6 @@ export type InlineCommentAnnotationProvider = AnnotationTypeProvider<AnnotationT
|
|
|
141
142
|
};
|
|
142
143
|
export type AnnotationProviders = {
|
|
143
144
|
inlineComment: InlineCommentAnnotationProvider;
|
|
145
|
+
annotationManager?: AnnotationManager;
|
|
144
146
|
};
|
|
145
147
|
export {};
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
/// <reference types="node/events" />
|
|
3
3
|
/// <reference types="typings/events" />
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
|
+
import type { AnnotationId } from '@atlaskit/adf-schema';
|
|
6
|
+
import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
7
|
+
import type { Step } from '@atlaskit/editor-prosemirror/transform';
|
|
5
8
|
export type UpdateEvent = 'create' | 'delete' | 'resolve' | 'unresolve' | 'setselectedannotation' | 'sethoveredannotation' | 'removehoveredannotation';
|
|
6
9
|
export type VisibilityEvent = 'setvisibility';
|
|
7
10
|
type AnnotationCallback = (params: string) => void;
|
|
@@ -11,4 +14,133 @@ export declare class AnnotationUpdateEmitter extends EventEmitter {
|
|
|
11
14
|
on(event: UpdateEvent, listener: (annotationId: string) => void): this;
|
|
12
15
|
off(event: string, listener: AnnotationCallback | VisibilityCallback): this;
|
|
13
16
|
}
|
|
17
|
+
type ActionResult = {
|
|
18
|
+
step: Step;
|
|
19
|
+
doc: JSONDocNode;
|
|
20
|
+
/** The list of types of all inline nodes, which were wrapped by annotation. */
|
|
21
|
+
inlineNodeTypes?: string[];
|
|
22
|
+
targetNodeType?: string;
|
|
23
|
+
};
|
|
24
|
+
export type AnnotationDraftStartedData = {
|
|
25
|
+
targetElement: HTMLElement | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* This list of inline node types at the draft selection location
|
|
28
|
+
*/
|
|
29
|
+
inlineNodeTypes: string[];
|
|
30
|
+
/**
|
|
31
|
+
* The actionResult can be used by Product so they're able to perform the
|
|
32
|
+
* required NCS transaction to add the annotation to the document.
|
|
33
|
+
*/
|
|
34
|
+
actionResult: ActionResult | undefined;
|
|
35
|
+
};
|
|
36
|
+
export type AnnotationSelectedChangeData = {
|
|
37
|
+
annotationId: AnnotationId;
|
|
38
|
+
isSelected: boolean;
|
|
39
|
+
inlineNodeTypes: string[];
|
|
40
|
+
};
|
|
41
|
+
export type AnnotationManagerEvents = {
|
|
42
|
+
name: 'draftAnnotationStarted';
|
|
43
|
+
data: AnnotationDraftStartedData;
|
|
44
|
+
} | {
|
|
45
|
+
name: 'annotationSelectionChanged';
|
|
46
|
+
data: AnnotationSelectedChangeData;
|
|
47
|
+
};
|
|
48
|
+
export type ManagerFailureReasons = 'manager-not-initialized' | 'hook-execution-error';
|
|
49
|
+
export type StartDraftResult = {
|
|
50
|
+
success: false;
|
|
51
|
+
reason: ManagerFailureReasons | 'invalid-range' | 'draft-in-progress';
|
|
52
|
+
} | ({
|
|
53
|
+
success: true;
|
|
54
|
+
} & AnnotationDraftStartedData);
|
|
55
|
+
export type ClearDraftResult = {
|
|
56
|
+
success: false;
|
|
57
|
+
reason: ManagerFailureReasons | 'draft-not-started';
|
|
58
|
+
} | {
|
|
59
|
+
success: true;
|
|
60
|
+
};
|
|
61
|
+
export type ApplyDraftResult = {
|
|
62
|
+
success: false;
|
|
63
|
+
reason: ManagerFailureReasons | 'draft-not-started' | 'range-no-longer-exists';
|
|
64
|
+
} | {
|
|
65
|
+
success: true;
|
|
66
|
+
targetElement: HTMLElement | undefined;
|
|
67
|
+
};
|
|
68
|
+
export type GetDraftResult = {
|
|
69
|
+
success: false;
|
|
70
|
+
reason: ManagerFailureReasons | 'draft-not-started';
|
|
71
|
+
} | ({
|
|
72
|
+
success: true;
|
|
73
|
+
} & AnnotationDraftStartedData);
|
|
74
|
+
export type ClearAnnotationResult = {
|
|
75
|
+
success: false;
|
|
76
|
+
reason: ManagerFailureReasons | 'id-not-valid';
|
|
77
|
+
} | {
|
|
78
|
+
success: true;
|
|
79
|
+
actionResult: ActionResult | undefined;
|
|
80
|
+
};
|
|
81
|
+
export type SelectAnnotationResult = {
|
|
82
|
+
success: false;
|
|
83
|
+
reason: ManagerFailureReasons | 'id-not-valid';
|
|
84
|
+
} | {
|
|
85
|
+
success: true;
|
|
86
|
+
isSelected: boolean;
|
|
87
|
+
};
|
|
88
|
+
export type HoverAnnotationResult = {
|
|
89
|
+
success: false;
|
|
90
|
+
reason: ManagerFailureReasons | 'id-not-valid';
|
|
91
|
+
} | {
|
|
92
|
+
success: true;
|
|
93
|
+
isHovered: boolean;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* This is the list of methods which exist on the Manager interface. These are the methods that can be hooked into.
|
|
97
|
+
*/
|
|
98
|
+
export type AnnotationManagerMethods = {
|
|
99
|
+
allowAnnotation: () => boolean;
|
|
100
|
+
startDraft: () => StartDraftResult;
|
|
101
|
+
clearDraft: () => ClearDraftResult;
|
|
102
|
+
applyDraft: (id: AnnotationId) => ApplyDraftResult;
|
|
103
|
+
getDraft: () => GetDraftResult;
|
|
104
|
+
setIsAnnotationSelected: (id: AnnotationId, isSelected: boolean) => SelectAnnotationResult;
|
|
105
|
+
setIsAnnotationHovered: (id: AnnotationId, isHovered: boolean) => HoverAnnotationResult;
|
|
106
|
+
clearAnnotation: (id: AnnotationId) => ClearAnnotationResult;
|
|
107
|
+
};
|
|
108
|
+
export type AnnotationManager = AnnotationManagerMethods & {
|
|
109
|
+
/**
|
|
110
|
+
* This method is used to set a preemptive gate. A preemptive gate is a function that will be called
|
|
111
|
+
* before the manager performs an action. If the function returns false, the action will not be performed.
|
|
112
|
+
*/
|
|
113
|
+
setPreemptiveGate(handler: () => Promise<boolean>): AnnotationManager;
|
|
114
|
+
/**
|
|
115
|
+
* This method is used to run the configured preemptive gate check.
|
|
116
|
+
* @internal
|
|
117
|
+
*/
|
|
118
|
+
checkPreemptiveGate(): Promise<boolean>;
|
|
119
|
+
onDraftAnnotationStarted(handler: (data: AnnotationDraftStartedData) => void): AnnotationManager;
|
|
120
|
+
offDraftAnnotationStarted(handler: (data: AnnotationDraftStartedData) => void): AnnotationManager;
|
|
121
|
+
onAnnotationSelectionChange(handler: (data: AnnotationSelectedChangeData) => void): AnnotationManager;
|
|
122
|
+
offAnnotationSelectionChange(handler: (data: AnnotationSelectedChangeData) => void): AnnotationManager;
|
|
123
|
+
/**
|
|
124
|
+
* @internal
|
|
125
|
+
* This method is intended for internal Platform use only. It is not intended for use by Product code.
|
|
126
|
+
*/
|
|
127
|
+
emit(event: {
|
|
128
|
+
name: 'draftAnnotationStarted';
|
|
129
|
+
data: AnnotationDraftStartedData;
|
|
130
|
+
} | {
|
|
131
|
+
name: 'annotationSelectionChanged';
|
|
132
|
+
data: AnnotationSelectedChangeData;
|
|
133
|
+
}): AnnotationManager;
|
|
134
|
+
/**
|
|
135
|
+
* @internal
|
|
136
|
+
* This method is intended for internal Platform use only. It is not intended for use by Product code.
|
|
137
|
+
*/
|
|
138
|
+
hook<H extends keyof AnnotationManagerMethods>(method: H, handler: AnnotationManagerMethods[H]): AnnotationManager;
|
|
139
|
+
/**
|
|
140
|
+
* @internal
|
|
141
|
+
* This method is intended for internal Platform use only. It is not intended for use by Product code.
|
|
142
|
+
*/
|
|
143
|
+
unhook<H extends keyof AnnotationManagerMethods>(method: H, handler: AnnotationManagerMethods[H]): AnnotationManager;
|
|
144
|
+
};
|
|
145
|
+
export declare function createAnnotationManager(): AnnotationManager;
|
|
14
146
|
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AnnotationId } from '@atlaskit/adf-schema';
|
|
2
|
+
import type { AnnotationDraftStartedData, AnnotationManager, AnnotationManagerEvents, AnnotationManagerMethods, AnnotationSelectedChangeData, ApplyDraftResult, ClearAnnotationResult, ClearDraftResult, GetDraftResult, HoverAnnotationResult, SelectAnnotationResult, StartDraftResult } from './index';
|
|
3
|
+
export declare class SharedAnnotationManager implements AnnotationManager {
|
|
4
|
+
/**
|
|
5
|
+
* This is the event emitter that is used to emit events from the manager. It is used to communicate with
|
|
6
|
+
* other parts of the application.
|
|
7
|
+
*/
|
|
8
|
+
private emitter;
|
|
9
|
+
/**
|
|
10
|
+
* This is the map of hooks that can be added to the manager. Hooks are a 1:1 mapping of methods that can be
|
|
11
|
+
* called on the manager. They are used to extend the functionality of the manager.
|
|
12
|
+
*/
|
|
13
|
+
private hooks;
|
|
14
|
+
private preemptiveGate;
|
|
15
|
+
setPreemptiveGate(handler: () => Promise<boolean>): AnnotationManager;
|
|
16
|
+
checkPreemptiveGate(): Promise<boolean>;
|
|
17
|
+
onDraftAnnotationStarted(handler: (data: AnnotationDraftStartedData) => void): AnnotationManager;
|
|
18
|
+
offDraftAnnotationStarted(handler: (data: AnnotationDraftStartedData) => void): AnnotationManager;
|
|
19
|
+
onAnnotationSelectionChange(handler: (data: AnnotationSelectedChangeData) => void): AnnotationManager;
|
|
20
|
+
offAnnotationSelectionChange(handler: (data: AnnotationSelectedChangeData) => void): AnnotationManager;
|
|
21
|
+
emit(event: AnnotationManagerEvents): AnnotationManager;
|
|
22
|
+
hook<H extends keyof AnnotationManagerMethods>(method: H, handler: AnnotationManagerMethods[H]): AnnotationManager;
|
|
23
|
+
unhook<H extends keyof AnnotationManagerMethods>(method: H, handler: AnnotationManagerMethods[H]): AnnotationManager;
|
|
24
|
+
allowAnnotation(): boolean;
|
|
25
|
+
startDraft(): StartDraftResult;
|
|
26
|
+
clearDraft(): ClearDraftResult;
|
|
27
|
+
applyDraft(id: AnnotationId): ApplyDraftResult;
|
|
28
|
+
getDraft(): GetDraftResult;
|
|
29
|
+
setIsAnnotationSelected(id: string, isSelected: boolean): SelectAnnotationResult;
|
|
30
|
+
setIsAnnotationHovered(id: string, isHovered: boolean): HoverAnnotationResult;
|
|
31
|
+
clearAnnotation(id: AnnotationId): ClearAnnotationResult;
|
|
32
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { AnnotationId, AnnotationTypes } from '@atlaskit/adf-schema';
|
|
3
3
|
import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
4
4
|
import type { Step } from '@atlaskit/editor-prosemirror/transform';
|
|
5
|
+
import type { AnnotationManager } from '../../annotation';
|
|
5
6
|
import type { AnnotationState, AnnotationUpdateEmitter } from './emitter';
|
|
6
7
|
export type AnnotationByMatches = {
|
|
7
8
|
originalSelection: string;
|
|
@@ -141,5 +142,6 @@ export type InlineCommentAnnotationProvider = AnnotationTypeProvider<AnnotationT
|
|
|
141
142
|
};
|
|
142
143
|
export type AnnotationProviders = {
|
|
143
144
|
inlineComment: InlineCommentAnnotationProvider;
|
|
145
|
+
annotationManager?: AnnotationManager;
|
|
144
146
|
};
|
|
145
147
|
export {};
|
package/package.json
CHANGED