@atlaskit/editor-core 190.1.20 → 190.1.24

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.
Files changed (126) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/afm-cc/tsconfig.json +3 -0
  3. package/dist/cjs/composable-editor/editor-internal.js +11 -1
  4. package/dist/cjs/create-editor/ReactEditorView.js +6 -1
  5. package/dist/cjs/index.js +1 -1
  6. package/dist/cjs/plugins/index.js +0 -7
  7. package/dist/cjs/plugins/paste/pm-plugins/main.js +14 -10
  8. package/dist/cjs/presets/default.js +2 -2
  9. package/dist/cjs/presets/universal.js +2 -1
  10. package/dist/cjs/utils/index.js +12 -18
  11. package/dist/cjs/utils/performance/measure-enum.js +1 -2
  12. package/dist/cjs/version-wrapper.js +1 -1
  13. package/dist/es2019/composable-editor/editor-internal.js +11 -1
  14. package/dist/es2019/create-editor/ReactEditorView.js +6 -1
  15. package/dist/es2019/index.js +14 -1
  16. package/dist/es2019/plugins/index.js +0 -1
  17. package/dist/es2019/plugins/paste/pm-plugins/main.js +11 -5
  18. package/dist/es2019/presets/default.js +1 -1
  19. package/dist/es2019/presets/universal.js +2 -1
  20. package/dist/es2019/utils/index.js +0 -7
  21. package/dist/es2019/utils/performance/measure-enum.js +1 -2
  22. package/dist/es2019/version-wrapper.js +1 -1
  23. package/dist/esm/composable-editor/editor-internal.js +11 -1
  24. package/dist/esm/create-editor/ReactEditorView.js +6 -1
  25. package/dist/esm/index.js +14 -1
  26. package/dist/esm/plugins/index.js +0 -1
  27. package/dist/esm/plugins/paste/pm-plugins/main.js +9 -5
  28. package/dist/esm/presets/default.js +1 -1
  29. package/dist/esm/presets/universal.js +2 -1
  30. package/dist/esm/utils/index.js +0 -5
  31. package/dist/esm/utils/performance/measure-enum.js +1 -2
  32. package/dist/esm/version-wrapper.js +1 -1
  33. package/dist/types/index.d.ts +15 -2
  34. package/dist/types/plugins/index.d.ts +0 -1
  35. package/dist/types/plugins/paste/pm-plugins/main.d.ts +2 -0
  36. package/dist/types/presets/default.d.ts +1 -1
  37. package/dist/types/types/editor-props.d.ts +1 -1
  38. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
  39. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  40. package/dist/types/utils/index.d.ts +0 -1
  41. package/dist/types/utils/performance/measure-enum.d.ts +0 -1
  42. package/dist/types-ts4.5/index.d.ts +15 -2
  43. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  44. package/dist/types-ts4.5/plugins/paste/pm-plugins/main.d.ts +2 -0
  45. package/dist/types-ts4.5/presets/default.d.ts +1 -1
  46. package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
  47. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
  48. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
  49. package/dist/types-ts4.5/utils/index.d.ts +0 -1
  50. package/dist/types-ts4.5/utils/performance/measure-enum.d.ts +0 -1
  51. package/package.json +7 -5
  52. package/dist/cjs/plugins/annotation/commands/index.js +0 -150
  53. package/dist/cjs/plugins/annotation/commands/transform.js +0 -86
  54. package/dist/cjs/plugins/annotation/index.js +0 -130
  55. package/dist/cjs/plugins/annotation/nodeviews/index.js +0 -59
  56. package/dist/cjs/plugins/annotation/pm-plugins/inline-comment.js +0 -243
  57. package/dist/cjs/plugins/annotation/pm-plugins/keymap.js +0 -15
  58. package/dist/cjs/plugins/annotation/pm-plugins/plugin-factory.js +0 -107
  59. package/dist/cjs/plugins/annotation/pm-plugins/reducer.js +0 -84
  60. package/dist/cjs/plugins/annotation/pm-plugins/types.js +0 -17
  61. package/dist/cjs/plugins/annotation/toolbar.js +0 -59
  62. package/dist/cjs/plugins/annotation/types.js +0 -20
  63. package/dist/cjs/plugins/annotation/ui/AnnotationViewWrapper.js +0 -38
  64. package/dist/cjs/plugins/annotation/ui/InlineCommentView.js +0 -149
  65. package/dist/cjs/plugins/annotation/update-provider.js +0 -36
  66. package/dist/cjs/plugins/annotation/utils.js +0 -372
  67. package/dist/es2019/plugins/annotation/commands/index.js +0 -123
  68. package/dist/es2019/plugins/annotation/commands/transform.js +0 -64
  69. package/dist/es2019/plugins/annotation/index.js +0 -125
  70. package/dist/es2019/plugins/annotation/nodeviews/index.js +0 -31
  71. package/dist/es2019/plugins/annotation/pm-plugins/inline-comment.js +0 -178
  72. package/dist/es2019/plugins/annotation/pm-plugins/keymap.js +0 -9
  73. package/dist/es2019/plugins/annotation/pm-plugins/plugin-factory.js +0 -108
  74. package/dist/es2019/plugins/annotation/pm-plugins/reducer.js +0 -94
  75. package/dist/es2019/plugins/annotation/pm-plugins/types.js +0 -11
  76. package/dist/es2019/plugins/annotation/toolbar.js +0 -53
  77. package/dist/es2019/plugins/annotation/types.js +0 -14
  78. package/dist/es2019/plugins/annotation/ui/AnnotationViewWrapper.js +0 -14
  79. package/dist/es2019/plugins/annotation/ui/InlineCommentView.js +0 -147
  80. package/dist/es2019/plugins/annotation/update-provider.js +0 -9
  81. package/dist/es2019/plugins/annotation/utils.js +0 -334
  82. package/dist/esm/plugins/annotation/commands/index.js +0 -143
  83. package/dist/esm/plugins/annotation/commands/transform.js +0 -80
  84. package/dist/esm/plugins/annotation/index.js +0 -118
  85. package/dist/esm/plugins/annotation/nodeviews/index.js +0 -52
  86. package/dist/esm/plugins/annotation/pm-plugins/inline-comment.js +0 -236
  87. package/dist/esm/plugins/annotation/pm-plugins/keymap.js +0 -9
  88. package/dist/esm/plugins/annotation/pm-plugins/plugin-factory.js +0 -101
  89. package/dist/esm/plugins/annotation/pm-plugins/reducer.js +0 -77
  90. package/dist/esm/plugins/annotation/pm-plugins/types.js +0 -11
  91. package/dist/esm/plugins/annotation/toolbar.js +0 -52
  92. package/dist/esm/plugins/annotation/types.js +0 -14
  93. package/dist/esm/plugins/annotation/ui/AnnotationViewWrapper.js +0 -31
  94. package/dist/esm/plugins/annotation/ui/InlineCommentView.js +0 -144
  95. package/dist/esm/plugins/annotation/update-provider.js +0 -29
  96. package/dist/esm/plugins/annotation/utils.js +0 -345
  97. package/dist/types/plugins/annotation/commands/index.d.ts +0 -15
  98. package/dist/types/plugins/annotation/commands/transform.d.ts +0 -11
  99. package/dist/types/plugins/annotation/index.d.ts +0 -15
  100. package/dist/types/plugins/annotation/nodeviews/index.d.ts +0 -11
  101. package/dist/types/plugins/annotation/pm-plugins/inline-comment.d.ts +0 -3
  102. package/dist/types/plugins/annotation/pm-plugins/keymap.d.ts +0 -3
  103. package/dist/types/plugins/annotation/pm-plugins/plugin-factory.d.ts +0 -2
  104. package/dist/types/plugins/annotation/pm-plugins/reducer.d.ts +0 -3
  105. package/dist/types/plugins/annotation/pm-plugins/types.d.ts +0 -78
  106. package/dist/types/plugins/annotation/toolbar.d.ts +0 -5
  107. package/dist/types/plugins/annotation/types.d.ts +0 -86
  108. package/dist/types/plugins/annotation/ui/AnnotationViewWrapper.d.ts +0 -10
  109. package/dist/types/plugins/annotation/ui/InlineCommentView.d.ts +0 -13
  110. package/dist/types/plugins/annotation/update-provider.d.ts +0 -12
  111. package/dist/types/plugins/annotation/utils.d.ts +0 -45
  112. package/dist/types-ts4.5/plugins/annotation/commands/index.d.ts +0 -15
  113. package/dist/types-ts4.5/plugins/annotation/commands/transform.d.ts +0 -11
  114. package/dist/types-ts4.5/plugins/annotation/index.d.ts +0 -17
  115. package/dist/types-ts4.5/plugins/annotation/nodeviews/index.d.ts +0 -11
  116. package/dist/types-ts4.5/plugins/annotation/pm-plugins/inline-comment.d.ts +0 -3
  117. package/dist/types-ts4.5/plugins/annotation/pm-plugins/keymap.d.ts +0 -3
  118. package/dist/types-ts4.5/plugins/annotation/pm-plugins/plugin-factory.d.ts +0 -2
  119. package/dist/types-ts4.5/plugins/annotation/pm-plugins/reducer.d.ts +0 -3
  120. package/dist/types-ts4.5/plugins/annotation/pm-plugins/types.d.ts +0 -78
  121. package/dist/types-ts4.5/plugins/annotation/toolbar.d.ts +0 -5
  122. package/dist/types-ts4.5/plugins/annotation/types.d.ts +0 -86
  123. package/dist/types-ts4.5/plugins/annotation/ui/AnnotationViewWrapper.d.ts +0 -10
  124. package/dist/types-ts4.5/plugins/annotation/ui/InlineCommentView.d.ts +0 -13
  125. package/dist/types-ts4.5/plugins/annotation/update-provider.d.ts +0 -12
  126. package/dist/types-ts4.5/plugins/annotation/utils.d.ts +0 -45
@@ -1,52 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _inherits from "@babel/runtime/helpers/inherits";
4
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
7
- 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; } }
8
- import React from 'react';
9
- import { AnnotationSharedClassNames } from '@atlaskit/editor-common/styles';
10
- import ReactNodeView from '@atlaskit/editor-common/react-node-view';
11
- export var AnnotationNodeView = /*#__PURE__*/function (_ReactNodeView) {
12
- _inherits(AnnotationNodeView, _ReactNodeView);
13
- var _super = _createSuper(AnnotationNodeView);
14
- function AnnotationNodeView() {
15
- _classCallCheck(this, AnnotationNodeView);
16
- return _super.apply(this, arguments);
17
- }
18
- _createClass(AnnotationNodeView, [{
19
- key: "createDomRef",
20
- value: function createDomRef() {
21
- return document.createElement('span');
22
- }
23
- }, {
24
- key: "getContentDOM",
25
- value: function getContentDOM() {
26
- var dom = document.createElement('span');
27
- dom.className = 'ak-editor-annotation';
28
- return {
29
- dom: dom
30
- };
31
- }
32
- }, {
33
- key: "render",
34
- value: function render(_props, forwardRef) {
35
- return (
36
- /*#__PURE__*/
37
- // all inline comment states are now set in decorations at ../pm-plugins/inline-comment.ts
38
- React.createElement("span", {
39
- "data-mark-type": "annotation",
40
- ref: forwardRef
41
- })
42
- );
43
- }
44
- }]);
45
- return AnnotationNodeView;
46
- }(ReactNodeView);
47
- export var getAnnotationViewClassname = function getAnnotationViewClassname(isUnresolved, hasFocus) {
48
- if (!isUnresolved) {
49
- return;
50
- }
51
- return hasFocus ? AnnotationSharedClassNames.focus : AnnotationSharedClassNames.blur;
52
- };
@@ -1,236 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
- import _regeneratorRuntime from "@babel/runtime/regenerator";
4
- import { RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
5
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
- import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
7
- import { AnnotationTypes } from '@atlaskit/adf-schema';
8
- import { AnnotationNodeView, getAnnotationViewClassname } from '../nodeviews';
9
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
10
- import { updateInlineCommentResolvedState, updateMouseState, clearDirtyMark, setInlineCommentsVisibility, setSelectedAnnotation, closeComponent } from '../commands';
11
- import { getAllAnnotations, inlineCommentPluginKey, getPluginState } from '../utils';
12
- import { createPluginState } from './plugin-factory';
13
- var fetchProviderStates = /*#__PURE__*/function () {
14
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(provider, annotationIds) {
15
- var data, result;
16
- return _regeneratorRuntime.wrap(function _callee$(_context) {
17
- while (1) switch (_context.prev = _context.next) {
18
- case 0:
19
- _context.next = 2;
20
- return provider.getState(annotationIds);
21
- case 2:
22
- data = _context.sent;
23
- result = {};
24
- data.forEach(function (annotation) {
25
- if (annotation.annotationType === AnnotationTypes.INLINE_COMMENT) {
26
- result[annotation.id] = annotation.state.resolved;
27
- }
28
- });
29
- return _context.abrupt("return", result);
30
- case 6:
31
- case "end":
32
- return _context.stop();
33
- }
34
- }, _callee);
35
- }));
36
- return function fetchProviderStates(_x, _x2) {
37
- return _ref.apply(this, arguments);
38
- };
39
- }();
40
-
41
- // fetchState is unable to return a command as it's runs async and may dispatch at a later time
42
- // Requires `editorView` instead of the decomposition as the async means state may end up stale
43
- var fetchState = /*#__PURE__*/function () {
44
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(provider, annotationIds, editorView, editorAnalyticsAPI) {
45
- var inlineCommentStates;
46
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
47
- while (1) switch (_context2.prev = _context2.next) {
48
- case 0:
49
- if (!(!annotationIds || !annotationIds.length)) {
50
- _context2.next = 2;
51
- break;
52
- }
53
- return _context2.abrupt("return");
54
- case 2:
55
- _context2.next = 4;
56
- return fetchProviderStates(provider, annotationIds);
57
- case 4:
58
- inlineCommentStates = _context2.sent;
59
- if (editorView.dispatch) {
60
- updateInlineCommentResolvedState(editorAnalyticsAPI)(inlineCommentStates)(editorView.state, editorView.dispatch);
61
- }
62
- case 6:
63
- case "end":
64
- return _context2.stop();
65
- }
66
- }, _callee2);
67
- }));
68
- return function fetchState(_x3, _x4, _x5, _x6) {
69
- return _ref2.apply(this, arguments);
70
- };
71
- }();
72
- var initialState = function initialState() {
73
- var disallowOnWhitespace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
74
- return {
75
- annotations: {},
76
- selectedAnnotations: [],
77
- mouseData: {
78
- isSelecting: false
79
- },
80
- disallowOnWhitespace: disallowOnWhitespace,
81
- isInlineCommentViewClosed: false,
82
- isVisible: true,
83
- skipSelectionHandling: false
84
- };
85
- };
86
- var hideToolbar = function hideToolbar(state, dispatch) {
87
- return function () {
88
- updateMouseState({
89
- isSelecting: true
90
- })(state, dispatch);
91
- };
92
- };
93
-
94
- // Subscribe to updates from consumer
95
- var onResolve = function onResolve(editorAnalyticsAPI) {
96
- return function (state, dispatch) {
97
- return function (annotationId) {
98
- updateInlineCommentResolvedState(editorAnalyticsAPI)(_defineProperty({}, annotationId, true), RESOLVE_METHOD.CONSUMER)(state, dispatch);
99
- };
100
- };
101
- };
102
- var onUnResolve = function onUnResolve(editorAnalyticsAPI) {
103
- return function (state, dispatch) {
104
- return function (annotationId) {
105
- updateInlineCommentResolvedState(editorAnalyticsAPI)(_defineProperty({}, annotationId, false))(state, dispatch);
106
- };
107
- };
108
- };
109
- var onMouseUp = function onMouseUp(state, dispatch) {
110
- return function (e) {
111
- var _ref3 = getPluginState(state) || {},
112
- mouseData = _ref3.mouseData;
113
- if (mouseData !== null && mouseData !== void 0 && mouseData.isSelecting) {
114
- updateMouseState({
115
- isSelecting: false
116
- })(state, dispatch);
117
- }
118
- };
119
- };
120
- var onSetVisibility = function onSetVisibility(view) {
121
- return function (isVisible) {
122
- var state = view.state,
123
- dispatch = view.dispatch;
124
- setInlineCommentsVisibility(isVisible)(state, dispatch);
125
- if (isVisible) {
126
- // PM retains focus when we click away from the editor.
127
- // This will restore the visual aspect of the selection,
128
- // otherwise it will seem a floating toolbar will appear
129
- // for no reason.
130
- view.focus();
131
- }
132
- };
133
- };
134
- export var inlineCommentPlugin = function inlineCommentPlugin(options) {
135
- var provider = options.provider,
136
- portalProviderAPI = options.portalProviderAPI,
137
- eventDispatcher = options.eventDispatcher;
138
- return new SafePlugin({
139
- key: inlineCommentPluginKey,
140
- state: createPluginState(options.dispatch, initialState(provider.disallowOnWhitespace)),
141
- view: function view(editorView) {
142
- // Get initial state
143
- // Need to pass `editorView` to mitigate editor state going stale
144
- fetchState(provider, getAllAnnotations(editorView.state.doc), editorView, options.editorAnalyticsAPI);
145
- var resolve = function resolve(annotationId) {
146
- return onResolve(options.editorAnalyticsAPI)(editorView.state, editorView.dispatch)(annotationId);
147
- };
148
- var unResolve = function unResolve(annotationId) {
149
- return onUnResolve(options.editorAnalyticsAPI)(editorView.state, editorView.dispatch)(annotationId);
150
- };
151
- var mouseUp = function mouseUp(event) {
152
- return onMouseUp(editorView.state, editorView.dispatch)(event);
153
- };
154
- var setVisibility = function setVisibility(isVisible) {
155
- return onSetVisibility(editorView)(isVisible);
156
- };
157
- var setSelectedAnnotationFn = function setSelectedAnnotationFn(annotationId) {
158
- if (!annotationId) {
159
- closeComponent()(editorView.state, editorView.dispatch);
160
- } else {
161
- setSelectedAnnotation(annotationId)(editorView.state, editorView.dispatch);
162
- }
163
- };
164
- var updateSubscriber = provider.updateSubscriber;
165
- if (updateSubscriber) {
166
- updateSubscriber.on('resolve', resolve).on('delete', resolve).on('unresolve', unResolve).on('create', unResolve).on('setvisibility', setVisibility).on('setselectedannotation', setSelectedAnnotationFn);
167
- }
168
- editorView.root.addEventListener('mouseup', mouseUp);
169
- return {
170
- update: function update(view, _prevState) {
171
- var _ref4 = getPluginState(view.state) || {},
172
- dirtyAnnotations = _ref4.dirtyAnnotations;
173
- if (!dirtyAnnotations) {
174
- return;
175
- }
176
- clearDirtyMark()(view.state, view.dispatch);
177
- fetchState(provider, getAllAnnotations(view.state.doc), view, options.editorAnalyticsAPI);
178
- },
179
- destroy: function destroy() {
180
- editorView.root.removeEventListener('mouseup', mouseUp);
181
- if (updateSubscriber) {
182
- updateSubscriber.off('resolve', resolve).off('delete', resolve).off('unresolve', unResolve).off('create', unResolve).off('setvisibility', setVisibility).off('setselectedannotation', setSelectedAnnotationFn);
183
- }
184
- }
185
- };
186
- },
187
- props: {
188
- nodeViews: {
189
- annotation: function annotation(node, view, getPos) {
190
- return new AnnotationNodeView(node, view, getPos, portalProviderAPI, eventDispatcher) // resolved
191
- .init();
192
- }
193
- },
194
- handleDOMEvents: {
195
- mousedown: function mousedown(view) {
196
- var pluginState = getPluginState(view.state);
197
- if (!(pluginState !== null && pluginState !== void 0 && pluginState.mouseData.isSelecting)) {
198
- hideToolbar(view.state, view.dispatch)();
199
- }
200
- return false;
201
- }
202
- },
203
- decorations: function decorations(state) {
204
- // highlight comments, depending on state
205
- var _ref5 = getPluginState(state) || {},
206
- draftDecorationSet = _ref5.draftDecorationSet,
207
- annotations = _ref5.annotations,
208
- selectedAnnotations = _ref5.selectedAnnotations,
209
- isVisible = _ref5.isVisible,
210
- isInlineCommentViewClosed = _ref5.isInlineCommentViewClosed;
211
- var decorations = draftDecorationSet !== null && draftDecorationSet !== void 0 ? draftDecorationSet : DecorationSet.empty;
212
- var focusDecorations = [];
213
- state.doc.descendants(function (node, pos) {
214
- node.marks.filter(function (mark) {
215
- return mark.type === state.schema.marks.annotation;
216
- }).forEach(function (mark) {
217
- var isSelected = getBooleanFF('platform.editor.annotation.decouple-inline-comment-closed_flmox') ? !isInlineCommentViewClosed && !!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.some(function (selectedAnnotation) {
218
- return selectedAnnotation.id === mark.attrs.id;
219
- })) : !!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.some(function (selectedAnnotation) {
220
- return selectedAnnotation.id === mark.attrs.id;
221
- }));
222
- var isUnresolved = !!annotations && annotations[mark.attrs.id] === false;
223
- if (isVisible) {
224
- focusDecorations.push(Decoration.inline(pos, pos + node.nodeSize, {
225
- class: "".concat(getAnnotationViewClassname(isUnresolved, isSelected), " ").concat(isUnresolved),
226
- nodeName: 'span'
227
- }));
228
- }
229
- });
230
- });
231
- decorations = decorations.add(state.doc, focusDecorations);
232
- return decorations;
233
- }
234
- }
235
- });
236
- };
@@ -1,9 +0,0 @@
1
- import { keymap } from '@atlaskit/editor-prosemirror/keymap';
2
- import { bindKeymapWithCommand, addInlineComment } from '../../../keymaps';
3
- import { setInlineCommentDraftState } from '../commands';
4
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
- export function keymapPlugin(editorAnalyticsAPI) {
6
- var list = {};
7
- bindKeymapWithCommand(addInlineComment.common, setInlineCommentDraftState(editorAnalyticsAPI)(true, INPUT_METHOD.SHORTCUT), list);
8
- return keymap(list);
9
- }
@@ -1,101 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- 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; }
4
- import { pluginFactory } from '../../../utils/plugin-state-factory';
5
- import { findAnnotationsInSelection, inlineCommentPluginKey, isSelectedAnnotationsChanged } from '../utils';
6
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
7
- import reducer from './reducer';
8
- var handleDocChanged = function handleDocChanged(tr, prevPluginState) {
9
- if (!tr.getMeta('replaceDocument')) {
10
- return getBooleanFF('platform.editor.annotation.decouple-inline-comment-closed_flmox') ? getSelectionChangedHandler(false)(tr, prevPluginState) : handleSelectionChanged(tr, prevPluginState);
11
- }
12
- return _objectSpread(_objectSpread({}, prevPluginState), {}, {
13
- dirtyAnnotations: true
14
- });
15
- };
16
- var handleSelectionChanged = function handleSelectionChanged(tr, pluginState) {
17
- if (pluginState.skipSelectionHandling) {
18
- return _objectSpread(_objectSpread({}, pluginState), {}, {
19
- skipSelectionHandling: false
20
- });
21
- }
22
- var selectedAnnotations = findAnnotationsInSelection(tr.selection, tr.doc);
23
- var changed = selectedAnnotations.length !== pluginState.selectedAnnotations.length || selectedAnnotations.some(function (annotationInfo) {
24
- return !pluginState.selectedAnnotations.some(function (aInfo) {
25
- return aInfo.type === annotationInfo.id;
26
- });
27
- });
28
- if (changed) {
29
- return _objectSpread(_objectSpread({}, pluginState), {}, {
30
- selectedAnnotations: selectedAnnotations
31
- });
32
- }
33
- return pluginState;
34
- };
35
- var getSelectionChangedHandler = function getSelectionChangedHandler(reopenCommentView) {
36
- return function (tr, pluginState) {
37
- /**
38
- * If feature flag is **OFF** we want to keep the old behavior. Note that
39
- * reopenCommentView is not relevant here when using old behaviour.
40
- *
41
- * Feature flag is evaluated here rather than directly in onSelectionChanged where it is assigned
42
- * to prevent the plugin from setting up the handler before the feature flag is evaluated.
43
- *
44
- * This comment / logic can be cleaned up once the feature flag is removed.
45
- */
46
- if (!getBooleanFF('platform.editor.annotation.decouple-inline-comment-closed_flmox')) {
47
- return handleSelectionChanged(tr, pluginState);
48
- }
49
- if (pluginState.skipSelectionHandling) {
50
- return _objectSpread(_objectSpread({}, pluginState), {}, {
51
- skipSelectionHandling: false
52
- }, reopenCommentView && {
53
- isInlineCommentViewClosed: false
54
- });
55
- }
56
- var selectedAnnotations = findAnnotationsInSelection(tr.selection, tr.doc);
57
- if (selectedAnnotations.length === 0) {
58
- return _objectSpread(_objectSpread({}, pluginState), {}, {
59
- selectedAnnotations: selectedAnnotations,
60
- isInlineCommentViewClosed: true
61
- });
62
- }
63
- if (isSelectedAnnotationsChanged(selectedAnnotations, pluginState.selectedAnnotations)) {
64
- return _objectSpread(_objectSpread({}, pluginState), {}, {
65
- selectedAnnotations: selectedAnnotations
66
- }, reopenCommentView && {
67
- isInlineCommentViewClosed: false
68
- });
69
- }
70
- return _objectSpread(_objectSpread({}, pluginState), reopenCommentView && {
71
- isInlineCommentViewClosed: false
72
- });
73
- };
74
- };
75
- var _pluginFactory = pluginFactory(inlineCommentPluginKey, reducer, {
76
- onSelectionChanged: getSelectionChangedHandler(true),
77
- onDocChanged: handleDocChanged,
78
- mapping: function mapping(tr, pluginState) {
79
- var draftDecorationSet = pluginState.draftDecorationSet,
80
- bookmark = pluginState.bookmark;
81
- var mappedDecorationSet, mappedBookmark;
82
- if (draftDecorationSet) {
83
- mappedDecorationSet = draftDecorationSet.map(tr.mapping, tr.doc);
84
- }
85
- if (bookmark) {
86
- mappedBookmark = bookmark.map(tr.mapping);
87
- }
88
-
89
- // return same pluginState if mappings did not change
90
- if (mappedBookmark === bookmark && mappedDecorationSet === draftDecorationSet) {
91
- return pluginState;
92
- }
93
- return _objectSpread(_objectSpread({}, pluginState), {}, {
94
- draftDecorationSet: mappedDecorationSet,
95
- bookmark: mappedBookmark
96
- });
97
- }
98
- }),
99
- createPluginState = _pluginFactory.createPluginState,
100
- createCommand = _pluginFactory.createCommand;
101
- export { createPluginState, createCommand };
@@ -1,77 +0,0 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
- 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; }
5
- import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
6
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
7
- import { addDraftDecoration } from '../utils';
8
- import { ACTIONS } from './types';
9
- export default (function (pluginState, action) {
10
- switch (action.type) {
11
- case ACTIONS.UPDATE_INLINE_COMMENT_STATE:
12
- return _objectSpread(_objectSpread({}, pluginState), {}, {
13
- annotations: _objectSpread(_objectSpread({}, pluginState.annotations), action.data)
14
- });
15
- case ACTIONS.INLINE_COMMENT_UPDATE_MOUSE_STATE:
16
- var mouseData = Object.assign({}, pluginState.mouseData, action.data.mouseData);
17
- return _objectSpread(_objectSpread({}, pluginState), {}, {
18
- mouseData: mouseData
19
- });
20
- case ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE:
21
- return getNewDraftState(pluginState, action.data.drafting, action.data.editorState);
22
- case ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK:
23
- return _objectSpread(_objectSpread({}, pluginState), {}, {
24
- dirtyAnnotations: false,
25
- annotations: {}
26
- });
27
- case ACTIONS.CLOSE_COMPONENT:
28
- return getBooleanFF('platform.editor.annotation.decouple-inline-comment-closed_flmox') ? _objectSpread(_objectSpread({}, pluginState), {}, {
29
- isInlineCommentViewClosed: true
30
- }) : _objectSpread(_objectSpread({}, pluginState), {}, {
31
- selectedAnnotations: []
32
- });
33
- case ACTIONS.ADD_INLINE_COMMENT:
34
- var updatedPluginState = getNewDraftState(pluginState, action.data.drafting, action.data.editorState);
35
- return _objectSpread(_objectSpread({}, updatedPluginState), {}, {
36
- selectedAnnotations: [].concat(_toConsumableArray(updatedPluginState.selectedAnnotations), _toConsumableArray(action.data.selectedAnnotations)),
37
- annotations: _objectSpread(_objectSpread({}, pluginState.annotations), action.data.inlineComments)
38
- }, getBooleanFF('platform.editor.annotation.decouple-inline-comment-closed_flmox') && {
39
- isInlineCommentViewClosed: false
40
- });
41
- case ACTIONS.INLINE_COMMENT_SET_VISIBLE:
42
- var isVisible = action.data.isVisible;
43
- if (isVisible === pluginState.isVisible) {
44
- return pluginState;
45
- }
46
- return _objectSpread(_objectSpread({}, isVisible ? pluginState : getNewDraftState(pluginState, false)), {}, {
47
- isVisible: isVisible
48
- });
49
- case ACTIONS.SET_SELECTED_ANNOTATION:
50
- return _objectSpread(_objectSpread({}, pluginState), {}, {
51
- selectedAnnotations: _toConsumableArray(action.data.selectedAnnotations),
52
- skipSelectionHandling: true
53
- }, getBooleanFF('platform.editor.annotation.decouple-inline-comment-closed_flmox') && {
54
- // if selecting annotation explicitly, reopen the comment view
55
- isInlineCommentViewClosed: false
56
- });
57
- default:
58
- return pluginState;
59
- }
60
- });
61
- function getNewDraftState(pluginState, drafting, editorState) {
62
- var draftDecorationSet = pluginState.draftDecorationSet;
63
- if (!draftDecorationSet || !drafting) {
64
- draftDecorationSet = DecorationSet.empty;
65
- }
66
- var newState = _objectSpread(_objectSpread({}, pluginState), {}, {
67
- draftDecorationSet: draftDecorationSet
68
- });
69
- newState.bookmark = undefined;
70
- if (drafting && editorState) {
71
- newState.bookmark = editorState.selection.getBookmark();
72
- var resolvedBookmark = newState.bookmark.resolve(editorState.doc);
73
- var draftDecoration = addDraftDecoration(resolvedBookmark.from, resolvedBookmark.to);
74
- newState.draftDecorationSet = draftDecorationSet.add(editorState.doc, [draftDecoration]);
75
- }
76
- return newState;
77
- }
@@ -1,11 +0,0 @@
1
- export var ACTIONS = /*#__PURE__*/function (ACTIONS) {
2
- ACTIONS[ACTIONS["UPDATE_INLINE_COMMENT_STATE"] = 0] = "UPDATE_INLINE_COMMENT_STATE";
3
- ACTIONS[ACTIONS["SET_INLINE_COMMENT_DRAFT_STATE"] = 1] = "SET_INLINE_COMMENT_DRAFT_STATE";
4
- ACTIONS[ACTIONS["INLINE_COMMENT_UPDATE_MOUSE_STATE"] = 2] = "INLINE_COMMENT_UPDATE_MOUSE_STATE";
5
- ACTIONS[ACTIONS["INLINE_COMMENT_CLEAR_DIRTY_MARK"] = 3] = "INLINE_COMMENT_CLEAR_DIRTY_MARK";
6
- ACTIONS[ACTIONS["ADD_INLINE_COMMENT"] = 4] = "ADD_INLINE_COMMENT";
7
- ACTIONS[ACTIONS["INLINE_COMMENT_SET_VISIBLE"] = 5] = "INLINE_COMMENT_SET_VISIBLE";
8
- ACTIONS[ACTIONS["CLOSE_COMPONENT"] = 6] = "CLOSE_COMPONENT";
9
- ACTIONS[ACTIONS["SET_SELECTED_ANNOTATION"] = 7] = "SET_SELECTED_ANNOTATION";
10
- return ACTIONS;
11
- }({});
@@ -1,52 +0,0 @@
1
- import React from 'react';
2
- import CommentIcon from '@atlaskit/icon/glyph/comment';
3
- import { addInlineComment, ToolTipContent } from '../../keymaps';
4
- import { setInlineCommentDraftState } from './commands';
5
- import { AnnotationTestIds, AnnotationSelectionType } from './types';
6
- import { isSelectionValid } from './utils';
7
- import { annotationMessages } from '@atlaskit/editor-common/messages';
8
- import { calculateToolbarPositionAboveSelection, calculateToolbarPositionTrackHead } from '@atlaskit/editor-common/utils';
9
- export var buildToolbar = function buildToolbar(editorAnalyticsAPI) {
10
- return function (state, intl) {
11
- var isToolbarAbove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
12
- var schema = state.schema;
13
- var selectionValid = isSelectionValid(state);
14
- if (selectionValid === AnnotationSelectionType.INVALID) {
15
- return undefined;
16
- }
17
- var createCommentMessage = intl.formatMessage(annotationMessages.createComment);
18
- var commentDisabledMessage = intl.formatMessage(annotationMessages.createCommentInvalid);
19
- var createComment = {
20
- type: 'button',
21
- showTitle: true,
22
- disabled: selectionValid === AnnotationSelectionType.DISABLED,
23
- testId: AnnotationTestIds.floatingToolbarCreateButton,
24
- icon: CommentIcon,
25
- tooltipContent: selectionValid === AnnotationSelectionType.DISABLED ? commentDisabledMessage : /*#__PURE__*/React.createElement(ToolTipContent, {
26
- description: createCommentMessage,
27
- keymap: addInlineComment
28
- }),
29
- title: createCommentMessage,
30
- onClick: function onClick(state, dispatch) {
31
- return setInlineCommentDraftState(editorAnalyticsAPI)(true)(state, dispatch);
32
- }
33
- };
34
- var annotation = schema.marks.annotation;
35
- var validNodes = Object.keys(schema.nodes).reduce(function (acc, current) {
36
- var type = schema.nodes[current];
37
- if (type.allowsMarkType(annotation)) {
38
- acc.push(type);
39
- }
40
- return acc;
41
- }, []);
42
- var toolbarTitle = intl.formatMessage(annotationMessages.toolbar);
43
- var calcToolbarPosition = isToolbarAbove ? calculateToolbarPositionAboveSelection : calculateToolbarPositionTrackHead;
44
- var onPositionCalculated = calcToolbarPosition(toolbarTitle);
45
- return {
46
- title: toolbarTitle,
47
- nodeType: validNodes,
48
- items: [createComment],
49
- onPositionCalculated: onPositionCalculated
50
- };
51
- };
52
- };
@@ -1,14 +0,0 @@
1
- export var AnnotationSelectionType = /*#__PURE__*/function (AnnotationSelectionType) {
2
- AnnotationSelectionType["INVALID"] = "invalid";
3
- AnnotationSelectionType["DISABLED"] = "disabled";
4
- AnnotationSelectionType["VALID"] = "valid";
5
- return AnnotationSelectionType;
6
- }({}); // Annotation can be created
7
- var prefix = 'ak-editor-annotation';
8
- export var AnnotationTestIds = {
9
- prefix: prefix,
10
- floatingComponent: "".concat(prefix, "-floating-component"),
11
- floatingToolbarCreateButton: "".concat(prefix, "-toolbar-create-button"),
12
- componentSave: "".concat(prefix, "-dummy-save-button"),
13
- componentClose: "".concat(prefix, "-dummy-close-button")
14
- };
@@ -1,31 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _inherits from "@babel/runtime/helpers/inherits";
4
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
7
- 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; } }
8
- import React from 'react';
9
- export var AnnotationViewWrapper = /*#__PURE__*/function (_React$PureComponent) {
10
- _inherits(AnnotationViewWrapper, _React$PureComponent);
11
- var _super = _createSuper(AnnotationViewWrapper);
12
- function AnnotationViewWrapper() {
13
- _classCallCheck(this, AnnotationViewWrapper);
14
- return _super.apply(this, arguments);
15
- }
16
- _createClass(AnnotationViewWrapper, [{
17
- key: "componentDidMount",
18
- value: function componentDidMount() {
19
- var onViewed = this.props.onViewed;
20
- if (onViewed) {
21
- onViewed();
22
- }
23
- }
24
- }, {
25
- key: "render",
26
- value: function render() {
27
- return this.props.children;
28
- }
29
- }]);
30
- return AnnotationViewWrapper;
31
- }(React.PureComponent);