@atlaskit/editor-plugin-annotation 0.1.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/.eslintrc.js +18 -0
- package/CHANGELOG.md +1 -0
- package/LICENSE.md +13 -0
- package/README.md +30 -0
- package/dist/cjs/commands/index.js +150 -0
- package/dist/cjs/commands/transform.js +86 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/nodeviews/index.js +59 -0
- package/dist/cjs/plugin.js +132 -0
- package/dist/cjs/pm-plugins/inline-comment.js +246 -0
- package/dist/cjs/pm-plugins/keymap.js +15 -0
- package/dist/cjs/pm-plugins/plugin-factory.js +107 -0
- package/dist/cjs/pm-plugins/reducer.js +84 -0
- package/dist/cjs/pm-plugins/types.js +17 -0
- package/dist/cjs/toolbar.js +59 -0
- package/dist/cjs/types.js +20 -0
- package/dist/cjs/ui/AnnotationViewWrapper.js +39 -0
- package/dist/cjs/ui/InlineCommentView.js +149 -0
- package/dist/cjs/utils.js +372 -0
- package/dist/es2019/commands/index.js +123 -0
- package/dist/es2019/commands/transform.js +64 -0
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/nodeviews/index.js +31 -0
- package/dist/es2019/plugin.js +127 -0
- package/dist/es2019/pm-plugins/inline-comment.js +181 -0
- package/dist/es2019/pm-plugins/keymap.js +9 -0
- package/dist/es2019/pm-plugins/plugin-factory.js +108 -0
- package/dist/es2019/pm-plugins/reducer.js +94 -0
- package/dist/es2019/pm-plugins/types.js +11 -0
- package/dist/es2019/toolbar.js +53 -0
- package/dist/es2019/types.js +14 -0
- package/dist/es2019/ui/AnnotationViewWrapper.js +15 -0
- package/dist/es2019/ui/InlineCommentView.js +145 -0
- package/dist/es2019/utils.js +334 -0
- package/dist/esm/commands/index.js +143 -0
- package/dist/esm/commands/transform.js +80 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/nodeviews/index.js +52 -0
- package/dist/esm/plugin.js +120 -0
- package/dist/esm/pm-plugins/inline-comment.js +239 -0
- package/dist/esm/pm-plugins/keymap.js +9 -0
- package/dist/esm/pm-plugins/plugin-factory.js +101 -0
- package/dist/esm/pm-plugins/reducer.js +77 -0
- package/dist/esm/pm-plugins/types.js +11 -0
- package/dist/esm/toolbar.js +52 -0
- package/dist/esm/types.js +14 -0
- package/dist/esm/ui/AnnotationViewWrapper.js +32 -0
- package/dist/esm/ui/InlineCommentView.js +142 -0
- package/dist/esm/utils.js +345 -0
- package/dist/types/commands/index.d.ts +15 -0
- package/dist/types/commands/transform.d.ts +11 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/nodeviews/index.d.ts +11 -0
- package/dist/types/plugin.d.ts +6 -0
- package/dist/types/pm-plugins/inline-comment.d.ts +3 -0
- package/dist/types/pm-plugins/keymap.d.ts +3 -0
- package/dist/types/pm-plugins/plugin-factory.d.ts +2 -0
- package/dist/types/pm-plugins/reducer.d.ts +3 -0
- package/dist/types/pm-plugins/types.d.ts +78 -0
- package/dist/types/toolbar.d.ts +5 -0
- package/dist/types/types.d.ts +100 -0
- package/dist/types/ui/AnnotationViewWrapper.d.ts +10 -0
- package/dist/types/ui/InlineCommentView.d.ts +12 -0
- package/dist/types/utils.d.ts +44 -0
- package/dist/types-ts4.5/commands/index.d.ts +15 -0
- package/dist/types-ts4.5/commands/transform.d.ts +11 -0
- package/dist/types-ts4.5/index.d.ts +3 -0
- package/dist/types-ts4.5/nodeviews/index.d.ts +11 -0
- package/dist/types-ts4.5/plugin.d.ts +6 -0
- package/dist/types-ts4.5/pm-plugins/inline-comment.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/plugin-factory.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/reducer.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/types.d.ts +78 -0
- package/dist/types-ts4.5/toolbar.d.ts +5 -0
- package/dist/types-ts4.5/types.d.ts +102 -0
- package/dist/types-ts4.5/ui/AnnotationViewWrapper.d.ts +10 -0
- package/dist/types-ts4.5/ui/InlineCommentView.d.ts +12 -0
- package/dist/types-ts4.5/utils.d.ts +44 -0
- package/package.json +106 -0
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
rules: {
|
|
3
|
+
'@typescript-eslint/no-duplicate-imports': 'error',
|
|
4
|
+
'@typescript-eslint/no-explicit-any': 'error',
|
|
5
|
+
'@typescript-eslint/ban-types': [
|
|
6
|
+
'error',
|
|
7
|
+
{
|
|
8
|
+
types: {
|
|
9
|
+
'React.FC':
|
|
10
|
+
'Please use types directly on props instead, and explicitly define children if required',
|
|
11
|
+
'React.FunctionalComponent':
|
|
12
|
+
'Please use types directly on props instead, and explicitly define children if required',
|
|
13
|
+
},
|
|
14
|
+
extendDefaults: false,
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
};
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @atlaskit/editor-plugin-annotation
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 Atlassian Pty Ltd
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Editor plugin annotation
|
|
2
|
+
|
|
3
|
+
Annotation plugin for @atlaskit/editor-core
|
|
4
|
+
|
|
5
|
+
**Note:** This component is designed for internal Atlassian development.
|
|
6
|
+
External contributors will be able to use this component but will not be able to submit issues.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
---
|
|
10
|
+
- **Install** - *yarn add @atlaskit/editor-plugin-annotation*
|
|
11
|
+
- **npm** - [@atlaskit/editor-plugin-annotation](https://www.npmjs.com/package/@atlaskit/editor-plugin-annotation)
|
|
12
|
+
- **Source** - [Bitbucket](https://bitbucket.org/atlassian/atlassian-frontend/src/master/packages/editor/editor-plugin-annotation)
|
|
13
|
+
- **Bundle** - [unpkg.com](https://unpkg.com/@atlaskit/editor-plugin-annotation/dist/)
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
---
|
|
17
|
+
**Internal use only**
|
|
18
|
+
|
|
19
|
+
@atlaskit/editor-plugin-annotation is intended for internal use by the @atlaskit/editor-core and as a plugin dependency of the Editor within your product.
|
|
20
|
+
|
|
21
|
+
Direct use of this component is not supported.
|
|
22
|
+
|
|
23
|
+
Please see [Atlaskit - Editor plugin annotation](https://atlaskit.atlassian.com/packages/editor/editor-plugin-annotation) for documentation and examples for this package.
|
|
24
|
+
|
|
25
|
+
## Support
|
|
26
|
+
---
|
|
27
|
+
For internal Atlassian, visit the slack channel [#help-editor](https://atlassian.slack.com/archives/CFG3PSQ9E) for support or visit [go/editor-help](https://go/editor-help) to submit a bug.
|
|
28
|
+
## License
|
|
29
|
+
---
|
|
30
|
+
Please see [Atlassian Frontend - License](https://hello.atlassian.net/wiki/spaces/AF/pages/2589099144/Documentation#License) for more licensing information.
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.updateMouseState = exports.updateInlineCommentResolvedState = exports.setSelectedAnnotation = exports.setInlineCommentsVisibility = exports.setInlineCommentDraftState = exports.removeInlineCommentNearSelection = exports.createAnnotation = exports.closeComponent = exports.clearDirtyMark = exports.addInlineComment = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
|
+
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
12
|
+
var _types = require("../pm-plugins/types");
|
|
13
|
+
var _types2 = require("../types");
|
|
14
|
+
var _utils = require("../utils");
|
|
15
|
+
var _transform = _interopRequireDefault(require("./transform"));
|
|
16
|
+
var updateInlineCommentResolvedState = exports.updateInlineCommentResolvedState = function updateInlineCommentResolvedState(editorAnalyticsAPI) {
|
|
17
|
+
return function (partialNewState, resolveMethod) {
|
|
18
|
+
var command = {
|
|
19
|
+
type: _types.ACTIONS.UPDATE_INLINE_COMMENT_STATE,
|
|
20
|
+
data: partialNewState
|
|
21
|
+
};
|
|
22
|
+
var allResolved = Object.values(partialNewState).every(function (state) {
|
|
23
|
+
return state;
|
|
24
|
+
});
|
|
25
|
+
if (resolveMethod && allResolved) {
|
|
26
|
+
return (0, _pluginFactory.createCommand)(command, _transform.default.addResolveAnalytics(editorAnalyticsAPI)(resolveMethod));
|
|
27
|
+
}
|
|
28
|
+
return (0, _pluginFactory.createCommand)(command);
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
var closeComponent = exports.closeComponent = function closeComponent() {
|
|
32
|
+
return (0, _pluginFactory.createCommand)({
|
|
33
|
+
type: _types.ACTIONS.CLOSE_COMPONENT
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
var clearDirtyMark = exports.clearDirtyMark = function clearDirtyMark() {
|
|
37
|
+
return (0, _pluginFactory.createCommand)({
|
|
38
|
+
type: _types.ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
var removeInlineCommentNearSelection = exports.removeInlineCommentNearSelection = function removeInlineCommentNearSelection(id) {
|
|
42
|
+
return function (state, dispatch) {
|
|
43
|
+
var tr = state.tr,
|
|
44
|
+
$from = state.selection.$from;
|
|
45
|
+
var annotationMarkType = state.schema.marks.annotation;
|
|
46
|
+
var hasAnnotation = $from.marks().some(function (mark) {
|
|
47
|
+
return mark.type === annotationMarkType;
|
|
48
|
+
});
|
|
49
|
+
if (!hasAnnotation) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// just remove entire mark from around the node
|
|
54
|
+
tr.removeMark($from.start(), $from.end(), annotationMarkType.create({
|
|
55
|
+
id: id,
|
|
56
|
+
type: _adfSchema.AnnotationTypes.INLINE_COMMENT
|
|
57
|
+
}));
|
|
58
|
+
if (dispatch) {
|
|
59
|
+
dispatch(tr);
|
|
60
|
+
}
|
|
61
|
+
return true;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
var getDraftCommandAction = function getDraftCommandAction(drafting) {
|
|
65
|
+
return function (editorState) {
|
|
66
|
+
// validate selection only when entering draft mode
|
|
67
|
+
if (drafting && (0, _utils.isSelectionValid)(editorState) !== _types2.AnnotationSelectionType.VALID) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
type: _types.ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE,
|
|
72
|
+
data: {
|
|
73
|
+
drafting: drafting,
|
|
74
|
+
editorState: editorState
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
var setInlineCommentDraftState = exports.setInlineCommentDraftState = function setInlineCommentDraftState(editorAnalyticsAPI) {
|
|
80
|
+
return function (drafting) {
|
|
81
|
+
var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _analytics.INPUT_METHOD.TOOLBAR;
|
|
82
|
+
var commandAction = getDraftCommandAction(drafting);
|
|
83
|
+
return (0, _pluginFactory.createCommand)(commandAction, _transform.default.addOpenCloseAnalytics(editorAnalyticsAPI)(drafting, inputMethod));
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
var addInlineComment = exports.addInlineComment = function addInlineComment(editorAnalyticsAPI) {
|
|
87
|
+
return function (id) {
|
|
88
|
+
var commandAction = function commandAction(editorState) {
|
|
89
|
+
return {
|
|
90
|
+
type: _types.ACTIONS.ADD_INLINE_COMMENT,
|
|
91
|
+
data: {
|
|
92
|
+
drafting: false,
|
|
93
|
+
inlineComments: (0, _defineProperty2.default)({}, id, false),
|
|
94
|
+
// Auto make the newly inserted comment selected.
|
|
95
|
+
// We move the selection to the head of the comment selection.
|
|
96
|
+
selectedAnnotations: [{
|
|
97
|
+
id: id,
|
|
98
|
+
type: _adfSchema.AnnotationTypes.INLINE_COMMENT
|
|
99
|
+
}],
|
|
100
|
+
editorState: editorState
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
return (0, _pluginFactory.createCommand)(commandAction, _transform.default.addInlineComment(editorAnalyticsAPI)(id));
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
var updateMouseState = exports.updateMouseState = function updateMouseState(mouseData) {
|
|
108
|
+
return (0, _pluginFactory.createCommand)({
|
|
109
|
+
type: _types.ACTIONS.INLINE_COMMENT_UPDATE_MOUSE_STATE,
|
|
110
|
+
data: {
|
|
111
|
+
mouseData: mouseData
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
var setSelectedAnnotation = exports.setSelectedAnnotation = function setSelectedAnnotation(id) {
|
|
116
|
+
return (0, _pluginFactory.createCommand)({
|
|
117
|
+
type: _types.ACTIONS.SET_SELECTED_ANNOTATION,
|
|
118
|
+
data: {
|
|
119
|
+
selectedAnnotations: [{
|
|
120
|
+
id: id,
|
|
121
|
+
type: _adfSchema.AnnotationTypes.INLINE_COMMENT
|
|
122
|
+
}]
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
var createAnnotation = exports.createAnnotation = function createAnnotation(editorAnalyticsAPI) {
|
|
127
|
+
return function (id) {
|
|
128
|
+
var annotationType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _adfSchema.AnnotationTypes.INLINE_COMMENT;
|
|
129
|
+
return function (state, dispatch) {
|
|
130
|
+
// don't try to add if there are is no temp highlight bookmarked
|
|
131
|
+
var _ref = (0, _utils.getPluginState)(state) || {},
|
|
132
|
+
bookmark = _ref.bookmark;
|
|
133
|
+
if (!bookmark || !dispatch) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
if (annotationType === _adfSchema.AnnotationTypes.INLINE_COMMENT) {
|
|
137
|
+
return addInlineComment(editorAnalyticsAPI)(id)(state, dispatch);
|
|
138
|
+
}
|
|
139
|
+
return false;
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
var setInlineCommentsVisibility = exports.setInlineCommentsVisibility = function setInlineCommentsVisibility(isVisible) {
|
|
144
|
+
return (0, _pluginFactory.createCommand)({
|
|
145
|
+
type: _types.ACTIONS.INLINE_COMMENT_SET_VISIBLE,
|
|
146
|
+
data: {
|
|
147
|
+
isVisible: isVisible
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _adfSchema = require("@atlaskit/adf-schema");
|
|
8
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
9
|
+
var _mark = require("@atlaskit/editor-common/mark");
|
|
10
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
|
+
var _utils = require("../utils");
|
|
12
|
+
var addAnnotationMark = function addAnnotationMark(id) {
|
|
13
|
+
return function (transaction, state) {
|
|
14
|
+
var inlineCommentState = (0, _utils.getPluginState)(state);
|
|
15
|
+
var _getSelectionPosition = (0, _utils.getSelectionPositions)(state, inlineCommentState),
|
|
16
|
+
from = _getSelectionPosition.from,
|
|
17
|
+
to = _getSelectionPosition.to,
|
|
18
|
+
head = _getSelectionPosition.head;
|
|
19
|
+
var annotationMark = state.schema.marks.annotation.create({
|
|
20
|
+
id: id,
|
|
21
|
+
type: _adfSchema.AnnotationTypes.INLINE_COMMENT
|
|
22
|
+
});
|
|
23
|
+
// Apply the mark only to text node in the range.
|
|
24
|
+
var tr = (0, _mark.applyMarkOnRange)(from, to, false, annotationMark, transaction);
|
|
25
|
+
// set selection back to the end of annotation once annotation mark is applied
|
|
26
|
+
tr.setSelection(_state.TextSelection.create(tr.doc, head));
|
|
27
|
+
return tr;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
var addInlineComment = function addInlineComment(editorAnalyticsAPI) {
|
|
31
|
+
return function (id) {
|
|
32
|
+
return function (transaction, state) {
|
|
33
|
+
var tr = addAnnotationMark(id)(transaction, state);
|
|
34
|
+
// add insert analytics step to transaction
|
|
35
|
+
tr = addInsertAnalytics(editorAnalyticsAPI)(tr, state);
|
|
36
|
+
// add close analytics step to transaction
|
|
37
|
+
tr = addOpenCloseAnalytics(editorAnalyticsAPI)(false, _analytics.INPUT_METHOD.TOOLBAR)(tr, state);
|
|
38
|
+
return tr;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
var addOpenCloseAnalytics = function addOpenCloseAnalytics(editorAnalyticsAPI) {
|
|
43
|
+
return function (drafting) {
|
|
44
|
+
var method = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _analytics.INPUT_METHOD.TOOLBAR;
|
|
45
|
+
return function (transaction, state) {
|
|
46
|
+
var draftingPayload = (0, _utils.getDraftCommandAnalyticsPayload)(drafting, method)(state);
|
|
47
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(draftingPayload)(transaction);
|
|
48
|
+
return transaction;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
var addInsertAnalytics = function addInsertAnalytics(editorAnalyticsAPI) {
|
|
53
|
+
return function (transaction, state) {
|
|
54
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
55
|
+
action: _analytics.ACTION.INSERTED,
|
|
56
|
+
actionSubject: _analytics.ACTION_SUBJECT.ANNOTATION,
|
|
57
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
58
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.INLINE_COMMENT
|
|
59
|
+
})(transaction);
|
|
60
|
+
return transaction;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
var addResolveAnalytics = function addResolveAnalytics(editorAnalyticsAPI) {
|
|
64
|
+
return function (method) {
|
|
65
|
+
return function (transaction, state) {
|
|
66
|
+
var resolvedPayload = {
|
|
67
|
+
action: _analytics.ACTION.RESOLVED,
|
|
68
|
+
actionSubject: _analytics.ACTION_SUBJECT.ANNOTATION,
|
|
69
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.INLINE_COMMENT,
|
|
70
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
71
|
+
attributes: {
|
|
72
|
+
method: method
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(resolvedPayload)(transaction);
|
|
76
|
+
return transaction;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
var _default = exports.default = {
|
|
81
|
+
addAnnotationMark: addAnnotationMark,
|
|
82
|
+
addInlineComment: addInlineComment,
|
|
83
|
+
addOpenCloseAnalytics: addOpenCloseAnalytics,
|
|
84
|
+
addInsertAnalytics: addInsertAnalytics,
|
|
85
|
+
addResolveAnalytics: addResolveAnalytics
|
|
86
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "annotationPlugin", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _plugin.annotationPlugin;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _plugin = require("./plugin");
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getAnnotationViewClassname = exports.AnnotationNodeView = void 0;
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
11
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
12
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
13
|
+
var _react = _interopRequireDefault(require("react"));
|
|
14
|
+
var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
|
|
15
|
+
var _styles = require("@atlaskit/editor-common/styles");
|
|
16
|
+
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); }; }
|
|
17
|
+
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; } }
|
|
18
|
+
var AnnotationNodeView = exports.AnnotationNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
19
|
+
(0, _inherits2.default)(AnnotationNodeView, _ReactNodeView);
|
|
20
|
+
var _super = _createSuper(AnnotationNodeView);
|
|
21
|
+
function AnnotationNodeView() {
|
|
22
|
+
(0, _classCallCheck2.default)(this, AnnotationNodeView);
|
|
23
|
+
return _super.apply(this, arguments);
|
|
24
|
+
}
|
|
25
|
+
(0, _createClass2.default)(AnnotationNodeView, [{
|
|
26
|
+
key: "createDomRef",
|
|
27
|
+
value: function createDomRef() {
|
|
28
|
+
return document.createElement('span');
|
|
29
|
+
}
|
|
30
|
+
}, {
|
|
31
|
+
key: "getContentDOM",
|
|
32
|
+
value: function getContentDOM() {
|
|
33
|
+
var dom = document.createElement('span');
|
|
34
|
+
dom.className = 'ak-editor-annotation';
|
|
35
|
+
return {
|
|
36
|
+
dom: dom
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
key: "render",
|
|
41
|
+
value: function render(_props, forwardRef) {
|
|
42
|
+
return (
|
|
43
|
+
/*#__PURE__*/
|
|
44
|
+
// all inline comment states are now set in decorations at ../pm-plugins/inline-comment.ts
|
|
45
|
+
_react.default.createElement("span", {
|
|
46
|
+
"data-mark-type": "annotation",
|
|
47
|
+
ref: forwardRef
|
|
48
|
+
})
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}]);
|
|
52
|
+
return AnnotationNodeView;
|
|
53
|
+
}(_reactNodeView.default);
|
|
54
|
+
var getAnnotationViewClassname = exports.getAnnotationViewClassname = function getAnnotationViewClassname(isUnresolved, hasFocus) {
|
|
55
|
+
if (!isUnresolved) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
return hasFocus ? _styles.AnnotationSharedClassNames.focus : _styles.AnnotationSharedClassNames.blur;
|
|
59
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "AnnotationUpdateEmitter", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _annotation.AnnotationUpdateEmitter;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
exports.annotationPlugin = void 0;
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
15
|
+
var _adfSchema = require("@atlaskit/adf-schema");
|
|
16
|
+
var _annotation = require("@atlaskit/editor-common/annotation");
|
|
17
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
18
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
19
|
+
var _inlineComment = require("./pm-plugins/inline-comment");
|
|
20
|
+
var _keymap = require("./pm-plugins/keymap");
|
|
21
|
+
var _toolbar = require("./toolbar");
|
|
22
|
+
var _InlineCommentView = require("./ui/InlineCommentView");
|
|
23
|
+
var _utils = require("./utils");
|
|
24
|
+
var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref) {
|
|
25
|
+
var annotationProviders = _ref.config,
|
|
26
|
+
api = _ref.api;
|
|
27
|
+
return {
|
|
28
|
+
name: 'annotation',
|
|
29
|
+
marks: function marks() {
|
|
30
|
+
return [{
|
|
31
|
+
name: 'annotation',
|
|
32
|
+
mark: _adfSchema.annotation
|
|
33
|
+
}];
|
|
34
|
+
},
|
|
35
|
+
actions: {
|
|
36
|
+
stripNonExistingAnnotations: _utils.stripNonExistingAnnotations
|
|
37
|
+
},
|
|
38
|
+
getSharedState: function getSharedState(editorState) {
|
|
39
|
+
if (!editorState) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
return (0, _utils.getPluginState)(editorState) || undefined;
|
|
43
|
+
},
|
|
44
|
+
pmPlugins: function pmPlugins() {
|
|
45
|
+
return [{
|
|
46
|
+
name: 'annotation',
|
|
47
|
+
plugin: function plugin(_ref2) {
|
|
48
|
+
var dispatch = _ref2.dispatch,
|
|
49
|
+
portalProviderAPI = _ref2.portalProviderAPI,
|
|
50
|
+
eventDispatcher = _ref2.eventDispatcher;
|
|
51
|
+
if (annotationProviders) {
|
|
52
|
+
var _api$analytics;
|
|
53
|
+
return (0, _inlineComment.inlineCommentPlugin)({
|
|
54
|
+
dispatch: dispatch,
|
|
55
|
+
portalProviderAPI: portalProviderAPI,
|
|
56
|
+
eventDispatcher: eventDispatcher,
|
|
57
|
+
provider: annotationProviders.inlineComment,
|
|
58
|
+
editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
name: 'annotationKeymap',
|
|
65
|
+
plugin: function plugin() {
|
|
66
|
+
if (annotationProviders) {
|
|
67
|
+
var _api$analytics2;
|
|
68
|
+
return (0, _keymap.keymapPlugin)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions);
|
|
69
|
+
}
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
}];
|
|
73
|
+
},
|
|
74
|
+
pluginsOptions: {
|
|
75
|
+
floatingToolbar: function floatingToolbar(state, intl) {
|
|
76
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.enable-selection-toolbar_ucdwd') || !annotationProviders) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
var pluginState = (0, _utils.getPluginState)(state);
|
|
80
|
+
if (pluginState && pluginState.isVisible && !pluginState.bookmark && !pluginState.mouseData.isSelecting) {
|
|
81
|
+
var _api$analytics3;
|
|
82
|
+
var isToolbarAbove = annotationProviders.inlineComment.isToolbarAbove;
|
|
83
|
+
return (0, _toolbar.buildToolbar)(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions)(state, intl, isToolbarAbove);
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
selectionToolbar: function selectionToolbar(state, intl) {
|
|
87
|
+
if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.enable-selection-toolbar_ucdwd') || !annotationProviders) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
var pluginState = (0, _utils.getPluginState)(state);
|
|
91
|
+
if (pluginState && pluginState.isVisible && !pluginState.bookmark && !pluginState.mouseData.isSelecting) {
|
|
92
|
+
var _api$analytics4;
|
|
93
|
+
var isToolbarAbove = annotationProviders.inlineComment.isToolbarAbove;
|
|
94
|
+
return (0, _toolbar.buildToolbar)(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)(state, intl, isToolbarAbove);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
contentComponent: function contentComponent(_ref3) {
|
|
99
|
+
var editorView = _ref3.editorView,
|
|
100
|
+
dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent;
|
|
101
|
+
if (!annotationProviders) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
return /*#__PURE__*/_react.default.createElement(AnnotationContentComponent, {
|
|
105
|
+
api: api,
|
|
106
|
+
editorView: editorView,
|
|
107
|
+
annotationProviders: annotationProviders,
|
|
108
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
function AnnotationContentComponent(_ref4) {
|
|
114
|
+
var _api$analytics5;
|
|
115
|
+
var api = _ref4.api,
|
|
116
|
+
editorView = _ref4.editorView,
|
|
117
|
+
annotationProviders = _ref4.annotationProviders,
|
|
118
|
+
dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
|
|
119
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['annotation']),
|
|
120
|
+
inlineCommentState = _useSharedPluginState.annotationState;
|
|
121
|
+
if (inlineCommentState && !inlineCommentState.isVisible) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
125
|
+
"data-editor-popup": "true"
|
|
126
|
+
}, /*#__PURE__*/_react.default.createElement(_InlineCommentView.InlineCommentView, {
|
|
127
|
+
providers: annotationProviders,
|
|
128
|
+
editorView: editorView,
|
|
129
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
130
|
+
editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions
|
|
131
|
+
}));
|
|
132
|
+
}
|