@atlaskit/editor-core 190.1.20 → 190.1.23

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 (120) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/afm-cc/tsconfig.json +3 -0
  3. package/dist/cjs/index.js +1 -1
  4. package/dist/cjs/plugins/index.js +0 -7
  5. package/dist/cjs/plugins/paste/pm-plugins/main.js +14 -10
  6. package/dist/cjs/presets/default.js +2 -2
  7. package/dist/cjs/presets/universal.js +2 -1
  8. package/dist/cjs/utils/index.js +12 -18
  9. package/dist/cjs/utils/performance/measure-enum.js +1 -2
  10. package/dist/cjs/version-wrapper.js +1 -1
  11. package/dist/es2019/index.js +14 -1
  12. package/dist/es2019/plugins/index.js +0 -1
  13. package/dist/es2019/plugins/paste/pm-plugins/main.js +11 -5
  14. package/dist/es2019/presets/default.js +1 -1
  15. package/dist/es2019/presets/universal.js +2 -1
  16. package/dist/es2019/utils/index.js +0 -7
  17. package/dist/es2019/utils/performance/measure-enum.js +1 -2
  18. package/dist/es2019/version-wrapper.js +1 -1
  19. package/dist/esm/index.js +14 -1
  20. package/dist/esm/plugins/index.js +0 -1
  21. package/dist/esm/plugins/paste/pm-plugins/main.js +9 -5
  22. package/dist/esm/presets/default.js +1 -1
  23. package/dist/esm/presets/universal.js +2 -1
  24. package/dist/esm/utils/index.js +0 -5
  25. package/dist/esm/utils/performance/measure-enum.js +1 -2
  26. package/dist/esm/version-wrapper.js +1 -1
  27. package/dist/types/index.d.ts +15 -2
  28. package/dist/types/plugins/index.d.ts +0 -1
  29. package/dist/types/plugins/paste/pm-plugins/main.d.ts +2 -0
  30. package/dist/types/presets/default.d.ts +1 -1
  31. package/dist/types/types/editor-props.d.ts +1 -1
  32. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
  33. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  34. package/dist/types/utils/index.d.ts +0 -1
  35. package/dist/types/utils/performance/measure-enum.d.ts +0 -1
  36. package/dist/types-ts4.5/index.d.ts +15 -2
  37. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  38. package/dist/types-ts4.5/plugins/paste/pm-plugins/main.d.ts +2 -0
  39. package/dist/types-ts4.5/presets/default.d.ts +1 -1
  40. package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
  41. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
  42. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
  43. package/dist/types-ts4.5/utils/index.d.ts +0 -1
  44. package/dist/types-ts4.5/utils/performance/measure-enum.d.ts +0 -1
  45. package/package.json +5 -3
  46. package/dist/cjs/plugins/annotation/commands/index.js +0 -150
  47. package/dist/cjs/plugins/annotation/commands/transform.js +0 -86
  48. package/dist/cjs/plugins/annotation/index.js +0 -130
  49. package/dist/cjs/plugins/annotation/nodeviews/index.js +0 -59
  50. package/dist/cjs/plugins/annotation/pm-plugins/inline-comment.js +0 -243
  51. package/dist/cjs/plugins/annotation/pm-plugins/keymap.js +0 -15
  52. package/dist/cjs/plugins/annotation/pm-plugins/plugin-factory.js +0 -107
  53. package/dist/cjs/plugins/annotation/pm-plugins/reducer.js +0 -84
  54. package/dist/cjs/plugins/annotation/pm-plugins/types.js +0 -17
  55. package/dist/cjs/plugins/annotation/toolbar.js +0 -59
  56. package/dist/cjs/plugins/annotation/types.js +0 -20
  57. package/dist/cjs/plugins/annotation/ui/AnnotationViewWrapper.js +0 -38
  58. package/dist/cjs/plugins/annotation/ui/InlineCommentView.js +0 -149
  59. package/dist/cjs/plugins/annotation/update-provider.js +0 -36
  60. package/dist/cjs/plugins/annotation/utils.js +0 -372
  61. package/dist/es2019/plugins/annotation/commands/index.js +0 -123
  62. package/dist/es2019/plugins/annotation/commands/transform.js +0 -64
  63. package/dist/es2019/plugins/annotation/index.js +0 -125
  64. package/dist/es2019/plugins/annotation/nodeviews/index.js +0 -31
  65. package/dist/es2019/plugins/annotation/pm-plugins/inline-comment.js +0 -178
  66. package/dist/es2019/plugins/annotation/pm-plugins/keymap.js +0 -9
  67. package/dist/es2019/plugins/annotation/pm-plugins/plugin-factory.js +0 -108
  68. package/dist/es2019/plugins/annotation/pm-plugins/reducer.js +0 -94
  69. package/dist/es2019/plugins/annotation/pm-plugins/types.js +0 -11
  70. package/dist/es2019/plugins/annotation/toolbar.js +0 -53
  71. package/dist/es2019/plugins/annotation/types.js +0 -14
  72. package/dist/es2019/plugins/annotation/ui/AnnotationViewWrapper.js +0 -14
  73. package/dist/es2019/plugins/annotation/ui/InlineCommentView.js +0 -147
  74. package/dist/es2019/plugins/annotation/update-provider.js +0 -9
  75. package/dist/es2019/plugins/annotation/utils.js +0 -334
  76. package/dist/esm/plugins/annotation/commands/index.js +0 -143
  77. package/dist/esm/plugins/annotation/commands/transform.js +0 -80
  78. package/dist/esm/plugins/annotation/index.js +0 -118
  79. package/dist/esm/plugins/annotation/nodeviews/index.js +0 -52
  80. package/dist/esm/plugins/annotation/pm-plugins/inline-comment.js +0 -236
  81. package/dist/esm/plugins/annotation/pm-plugins/keymap.js +0 -9
  82. package/dist/esm/plugins/annotation/pm-plugins/plugin-factory.js +0 -101
  83. package/dist/esm/plugins/annotation/pm-plugins/reducer.js +0 -77
  84. package/dist/esm/plugins/annotation/pm-plugins/types.js +0 -11
  85. package/dist/esm/plugins/annotation/toolbar.js +0 -52
  86. package/dist/esm/plugins/annotation/types.js +0 -14
  87. package/dist/esm/plugins/annotation/ui/AnnotationViewWrapper.js +0 -31
  88. package/dist/esm/plugins/annotation/ui/InlineCommentView.js +0 -144
  89. package/dist/esm/plugins/annotation/update-provider.js +0 -29
  90. package/dist/esm/plugins/annotation/utils.js +0 -345
  91. package/dist/types/plugins/annotation/commands/index.d.ts +0 -15
  92. package/dist/types/plugins/annotation/commands/transform.d.ts +0 -11
  93. package/dist/types/plugins/annotation/index.d.ts +0 -15
  94. package/dist/types/plugins/annotation/nodeviews/index.d.ts +0 -11
  95. package/dist/types/plugins/annotation/pm-plugins/inline-comment.d.ts +0 -3
  96. package/dist/types/plugins/annotation/pm-plugins/keymap.d.ts +0 -3
  97. package/dist/types/plugins/annotation/pm-plugins/plugin-factory.d.ts +0 -2
  98. package/dist/types/plugins/annotation/pm-plugins/reducer.d.ts +0 -3
  99. package/dist/types/plugins/annotation/pm-plugins/types.d.ts +0 -78
  100. package/dist/types/plugins/annotation/toolbar.d.ts +0 -5
  101. package/dist/types/plugins/annotation/types.d.ts +0 -86
  102. package/dist/types/plugins/annotation/ui/AnnotationViewWrapper.d.ts +0 -10
  103. package/dist/types/plugins/annotation/ui/InlineCommentView.d.ts +0 -13
  104. package/dist/types/plugins/annotation/update-provider.d.ts +0 -12
  105. package/dist/types/plugins/annotation/utils.d.ts +0 -45
  106. package/dist/types-ts4.5/plugins/annotation/commands/index.d.ts +0 -15
  107. package/dist/types-ts4.5/plugins/annotation/commands/transform.d.ts +0 -11
  108. package/dist/types-ts4.5/plugins/annotation/index.d.ts +0 -17
  109. package/dist/types-ts4.5/plugins/annotation/nodeviews/index.d.ts +0 -11
  110. package/dist/types-ts4.5/plugins/annotation/pm-plugins/inline-comment.d.ts +0 -3
  111. package/dist/types-ts4.5/plugins/annotation/pm-plugins/keymap.d.ts +0 -3
  112. package/dist/types-ts4.5/plugins/annotation/pm-plugins/plugin-factory.d.ts +0 -2
  113. package/dist/types-ts4.5/plugins/annotation/pm-plugins/reducer.d.ts +0 -3
  114. package/dist/types-ts4.5/plugins/annotation/pm-plugins/types.d.ts +0 -78
  115. package/dist/types-ts4.5/plugins/annotation/toolbar.d.ts +0 -5
  116. package/dist/types-ts4.5/plugins/annotation/types.d.ts +0 -86
  117. package/dist/types-ts4.5/plugins/annotation/ui/AnnotationViewWrapper.d.ts +0 -10
  118. package/dist/types-ts4.5/plugins/annotation/ui/InlineCommentView.d.ts +0 -13
  119. package/dist/types-ts4.5/plugins/annotation/update-provider.d.ts +0 -12
  120. package/dist/types-ts4.5/plugins/annotation/utils.d.ts +0 -45
@@ -1,84 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
- var _view = require("@atlaskit/editor-prosemirror/view");
11
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
- var _utils = require("../utils");
13
- var _types = require("./types");
14
- 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; }
15
- 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) { (0, _defineProperty2.default)(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; }
16
- var _default = exports.default = function _default(pluginState, action) {
17
- switch (action.type) {
18
- case _types.ACTIONS.UPDATE_INLINE_COMMENT_STATE:
19
- return _objectSpread(_objectSpread({}, pluginState), {}, {
20
- annotations: _objectSpread(_objectSpread({}, pluginState.annotations), action.data)
21
- });
22
- case _types.ACTIONS.INLINE_COMMENT_UPDATE_MOUSE_STATE:
23
- var mouseData = Object.assign({}, pluginState.mouseData, action.data.mouseData);
24
- return _objectSpread(_objectSpread({}, pluginState), {}, {
25
- mouseData: mouseData
26
- });
27
- case _types.ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE:
28
- return getNewDraftState(pluginState, action.data.drafting, action.data.editorState);
29
- case _types.ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK:
30
- return _objectSpread(_objectSpread({}, pluginState), {}, {
31
- dirtyAnnotations: false,
32
- annotations: {}
33
- });
34
- case _types.ACTIONS.CLOSE_COMPONENT:
35
- return (0, _platformFeatureFlags.getBooleanFF)('platform.editor.annotation.decouple-inline-comment-closed_flmox') ? _objectSpread(_objectSpread({}, pluginState), {}, {
36
- isInlineCommentViewClosed: true
37
- }) : _objectSpread(_objectSpread({}, pluginState), {}, {
38
- selectedAnnotations: []
39
- });
40
- case _types.ACTIONS.ADD_INLINE_COMMENT:
41
- var updatedPluginState = getNewDraftState(pluginState, action.data.drafting, action.data.editorState);
42
- return _objectSpread(_objectSpread({}, updatedPluginState), {}, {
43
- selectedAnnotations: [].concat((0, _toConsumableArray2.default)(updatedPluginState.selectedAnnotations), (0, _toConsumableArray2.default)(action.data.selectedAnnotations)),
44
- annotations: _objectSpread(_objectSpread({}, pluginState.annotations), action.data.inlineComments)
45
- }, (0, _platformFeatureFlags.getBooleanFF)('platform.editor.annotation.decouple-inline-comment-closed_flmox') && {
46
- isInlineCommentViewClosed: false
47
- });
48
- case _types.ACTIONS.INLINE_COMMENT_SET_VISIBLE:
49
- var isVisible = action.data.isVisible;
50
- if (isVisible === pluginState.isVisible) {
51
- return pluginState;
52
- }
53
- return _objectSpread(_objectSpread({}, isVisible ? pluginState : getNewDraftState(pluginState, false)), {}, {
54
- isVisible: isVisible
55
- });
56
- case _types.ACTIONS.SET_SELECTED_ANNOTATION:
57
- return _objectSpread(_objectSpread({}, pluginState), {}, {
58
- selectedAnnotations: (0, _toConsumableArray2.default)(action.data.selectedAnnotations),
59
- skipSelectionHandling: true
60
- }, (0, _platformFeatureFlags.getBooleanFF)('platform.editor.annotation.decouple-inline-comment-closed_flmox') && {
61
- // if selecting annotation explicitly, reopen the comment view
62
- isInlineCommentViewClosed: false
63
- });
64
- default:
65
- return pluginState;
66
- }
67
- };
68
- function getNewDraftState(pluginState, drafting, editorState) {
69
- var draftDecorationSet = pluginState.draftDecorationSet;
70
- if (!draftDecorationSet || !drafting) {
71
- draftDecorationSet = _view.DecorationSet.empty;
72
- }
73
- var newState = _objectSpread(_objectSpread({}, pluginState), {}, {
74
- draftDecorationSet: draftDecorationSet
75
- });
76
- newState.bookmark = undefined;
77
- if (drafting && editorState) {
78
- newState.bookmark = editorState.selection.getBookmark();
79
- var resolvedBookmark = newState.bookmark.resolve(editorState.doc);
80
- var draftDecoration = (0, _utils.addDraftDecoration)(resolvedBookmark.from, resolvedBookmark.to);
81
- newState.draftDecorationSet = draftDecorationSet.add(editorState.doc, [draftDecoration]);
82
- }
83
- return newState;
84
- }
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ACTIONS = void 0;
7
- var ACTIONS = exports.ACTIONS = /*#__PURE__*/function (ACTIONS) {
8
- ACTIONS[ACTIONS["UPDATE_INLINE_COMMENT_STATE"] = 0] = "UPDATE_INLINE_COMMENT_STATE";
9
- ACTIONS[ACTIONS["SET_INLINE_COMMENT_DRAFT_STATE"] = 1] = "SET_INLINE_COMMENT_DRAFT_STATE";
10
- ACTIONS[ACTIONS["INLINE_COMMENT_UPDATE_MOUSE_STATE"] = 2] = "INLINE_COMMENT_UPDATE_MOUSE_STATE";
11
- ACTIONS[ACTIONS["INLINE_COMMENT_CLEAR_DIRTY_MARK"] = 3] = "INLINE_COMMENT_CLEAR_DIRTY_MARK";
12
- ACTIONS[ACTIONS["ADD_INLINE_COMMENT"] = 4] = "ADD_INLINE_COMMENT";
13
- ACTIONS[ACTIONS["INLINE_COMMENT_SET_VISIBLE"] = 5] = "INLINE_COMMENT_SET_VISIBLE";
14
- ACTIONS[ACTIONS["CLOSE_COMPONENT"] = 6] = "CLOSE_COMPONENT";
15
- ACTIONS[ACTIONS["SET_SELECTED_ANNOTATION"] = 7] = "SET_SELECTED_ANNOTATION";
16
- return ACTIONS;
17
- }({});
@@ -1,59 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.buildToolbar = void 0;
8
- var _react = _interopRequireDefault(require("react"));
9
- var _comment = _interopRequireDefault(require("@atlaskit/icon/glyph/comment"));
10
- var _keymaps = require("../../keymaps");
11
- var _commands = require("./commands");
12
- var _types = require("./types");
13
- var _utils = require("./utils");
14
- var _messages = require("@atlaskit/editor-common/messages");
15
- var _utils2 = require("@atlaskit/editor-common/utils");
16
- var buildToolbar = exports.buildToolbar = function buildToolbar(editorAnalyticsAPI) {
17
- return function (state, intl) {
18
- var isToolbarAbove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
19
- var schema = state.schema;
20
- var selectionValid = (0, _utils.isSelectionValid)(state);
21
- if (selectionValid === _types.AnnotationSelectionType.INVALID) {
22
- return undefined;
23
- }
24
- var createCommentMessage = intl.formatMessage(_messages.annotationMessages.createComment);
25
- var commentDisabledMessage = intl.formatMessage(_messages.annotationMessages.createCommentInvalid);
26
- var createComment = {
27
- type: 'button',
28
- showTitle: true,
29
- disabled: selectionValid === _types.AnnotationSelectionType.DISABLED,
30
- testId: _types.AnnotationTestIds.floatingToolbarCreateButton,
31
- icon: _comment.default,
32
- tooltipContent: selectionValid === _types.AnnotationSelectionType.DISABLED ? commentDisabledMessage : /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
33
- description: createCommentMessage,
34
- keymap: _keymaps.addInlineComment
35
- }),
36
- title: createCommentMessage,
37
- onClick: function onClick(state, dispatch) {
38
- return (0, _commands.setInlineCommentDraftState)(editorAnalyticsAPI)(true)(state, dispatch);
39
- }
40
- };
41
- var annotation = schema.marks.annotation;
42
- var validNodes = Object.keys(schema.nodes).reduce(function (acc, current) {
43
- var type = schema.nodes[current];
44
- if (type.allowsMarkType(annotation)) {
45
- acc.push(type);
46
- }
47
- return acc;
48
- }, []);
49
- var toolbarTitle = intl.formatMessage(_messages.annotationMessages.toolbar);
50
- var calcToolbarPosition = isToolbarAbove ? _utils2.calculateToolbarPositionAboveSelection : _utils2.calculateToolbarPositionTrackHead;
51
- var onPositionCalculated = calcToolbarPosition(toolbarTitle);
52
- return {
53
- title: toolbarTitle,
54
- nodeType: validNodes,
55
- items: [createComment],
56
- onPositionCalculated: onPositionCalculated
57
- };
58
- };
59
- };
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.AnnotationTestIds = exports.AnnotationSelectionType = void 0;
7
- var AnnotationSelectionType = exports.AnnotationSelectionType = /*#__PURE__*/function (AnnotationSelectionType) {
8
- AnnotationSelectionType["INVALID"] = "invalid";
9
- AnnotationSelectionType["DISABLED"] = "disabled";
10
- AnnotationSelectionType["VALID"] = "valid";
11
- return AnnotationSelectionType;
12
- }({}); // Annotation can be created
13
- var prefix = 'ak-editor-annotation';
14
- var AnnotationTestIds = exports.AnnotationTestIds = {
15
- prefix: prefix,
16
- floatingComponent: "".concat(prefix, "-floating-component"),
17
- floatingToolbarCreateButton: "".concat(prefix, "-toolbar-create-button"),
18
- componentSave: "".concat(prefix, "-dummy-save-button"),
19
- componentClose: "".concat(prefix, "-dummy-close-button")
20
- };
@@ -1,38 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.AnnotationViewWrapper = 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
- 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); }; }
15
- 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; } }
16
- var AnnotationViewWrapper = exports.AnnotationViewWrapper = /*#__PURE__*/function (_React$PureComponent) {
17
- (0, _inherits2.default)(AnnotationViewWrapper, _React$PureComponent);
18
- var _super = _createSuper(AnnotationViewWrapper);
19
- function AnnotationViewWrapper() {
20
- (0, _classCallCheck2.default)(this, AnnotationViewWrapper);
21
- return _super.apply(this, arguments);
22
- }
23
- (0, _createClass2.default)(AnnotationViewWrapper, [{
24
- key: "componentDidMount",
25
- value: function componentDidMount() {
26
- var onViewed = this.props.onViewed;
27
- if (onViewed) {
28
- onViewed();
29
- }
30
- }
31
- }, {
32
- key: "render",
33
- value: function render() {
34
- return this.props.children;
35
- }
36
- }]);
37
- return AnnotationViewWrapper;
38
- }(_react.default.PureComponent);
@@ -1,149 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.InlineCommentView = InlineCommentView;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _react = _interopRequireDefault(require("react"));
10
- var _utils = require("@atlaskit/editor-prosemirror/utils");
11
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
- var _AnnotationViewWrapper = require("./AnnotationViewWrapper");
13
- var _types = require("../types");
14
- var _utils2 = require("../utils");
15
- var _commands = require("../commands");
16
- var _analytics = require("@atlaskit/editor-common/analytics");
17
- var findPosForDOM = function findPosForDOM(sel) {
18
- var $from = sel.$from,
19
- from = sel.from;
20
-
21
- // Retrieve current TextNode
22
- var index = $from.index();
23
- var node = index < $from.parent.childCount && $from.parent.child(index);
24
-
25
- // Right edge of a mark.
26
- if (!node && $from.nodeBefore && $from.nodeBefore.isText && $from.nodeBefore.marks.find(function (mark) {
27
- return mark.type.name === 'annotation';
28
- })) {
29
- return from - 1;
30
- }
31
- return from;
32
- };
33
- function InlineCommentView(_ref) {
34
- var providers = _ref.providers,
35
- editorView = _ref.editorView,
36
- editorAnalyticsAPI = _ref.editorAnalyticsAPI,
37
- dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent;
38
- // As inlineComment is the only annotation present, this function is not generic
39
- var inlineCommentProvider = providers.inlineComment;
40
- var state = editorView.state,
41
- dispatch = editorView.dispatch;
42
- var CreateComponent = inlineCommentProvider.createComponent,
43
- ViewComponent = inlineCommentProvider.viewComponent;
44
- var inlineCommentState = (0, _utils2.getPluginState)(state);
45
- var _ref2 = inlineCommentState || {},
46
- bookmark = _ref2.bookmark,
47
- selectedAnnotations = _ref2.selectedAnnotations,
48
- annotations = _ref2.annotations,
49
- isInlineCommentViewClosed = _ref2.isInlineCommentViewClosed;
50
- var annotationsList = (0, _utils2.getAllAnnotations)(editorView.state.doc);
51
- var selection = (0, _utils2.getSelectionPositions)(state, inlineCommentState);
52
- var position = findPosForDOM(selection);
53
- var dom;
54
- try {
55
- dom = (0, _utils.findDomRefAtPos)(position, editorView.domAtPos.bind(editorView));
56
- } catch (error) {
57
- // eslint-disable-next-line no-console
58
- console.warn(error);
59
- if (dispatchAnalyticsEvent) {
60
- var payload = {
61
- action: _analytics.ACTION.ERRORED,
62
- actionSubject: _analytics.ACTION_SUBJECT.CONTENT_COMPONENT,
63
- eventType: _analytics.EVENT_TYPE.OPERATIONAL,
64
- attributes: {
65
- component: _analytics.CONTENT_COMPONENT.INLINE_COMMENT,
66
- selection: selection.toJSON(),
67
- position: position,
68
- docSize: editorView.state.doc.nodeSize,
69
- error: error.toString()
70
- }
71
- };
72
- dispatchAnalyticsEvent(payload);
73
- }
74
- }
75
- if (!dom) {
76
- return null;
77
- }
78
-
79
- // Create Component
80
- if (bookmark) {
81
- if (!CreateComponent) {
82
- return null;
83
- }
84
-
85
- //getting all text between bookmarked positions
86
- var textSelection = state.doc.textBetween(selection.from, selection.to);
87
- return /*#__PURE__*/_react.default.createElement("div", {
88
- "data-testid": _types.AnnotationTestIds.floatingComponent,
89
- "data-editor-popup": "true"
90
- }, /*#__PURE__*/_react.default.createElement(CreateComponent, {
91
- dom: dom,
92
- textSelection: textSelection,
93
- onCreate: function onCreate(id) {
94
- (0, _commands.createAnnotation)(editorAnalyticsAPI)(id)(editorView.state, editorView.dispatch);
95
- !editorView.hasFocus() && editorView.focus();
96
- },
97
- onClose: function onClose() {
98
- (0, _commands.setInlineCommentDraftState)(editorAnalyticsAPI)(false)(editorView.state, editorView.dispatch);
99
- !editorView.hasFocus() && editorView.focus();
100
- }
101
- }));
102
- }
103
-
104
- // View Component
105
- var activeAnnotations = (selectedAnnotations === null || selectedAnnotations === void 0 ? void 0 : selectedAnnotations.filter(function (mark) {
106
- return annotations && annotations[mark.id] === false;
107
- })) || [];
108
- if (!ViewComponent || activeAnnotations.length === 0) {
109
- return null;
110
- }
111
- var onAnnotationViewed = function onAnnotationViewed() {
112
- if (!dispatchAnalyticsEvent) {
113
- return;
114
- }
115
- // fire analytics
116
- var payload = {
117
- action: _analytics.ACTION.VIEWED,
118
- actionSubject: _analytics.ACTION_SUBJECT.ANNOTATION,
119
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.INLINE_COMMENT,
120
- eventType: _analytics.EVENT_TYPE.TRACK,
121
- attributes: {
122
- overlap: activeAnnotations.length ? activeAnnotations.length - 1 : 0
123
- }
124
- };
125
- dispatchAnalyticsEvent(payload);
126
- };
127
- if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.annotation.decouple-inline-comment-closed_flmox') && isInlineCommentViewClosed || !selectedAnnotations) {
128
- return null;
129
- }
130
- return /*#__PURE__*/_react.default.createElement(_AnnotationViewWrapper.AnnotationViewWrapper, {
131
- "data-editor-popup": "true",
132
- "data-testid": _types.AnnotationTestIds.floatingComponent,
133
- key: (0, _utils2.getAnnotationViewKey)(activeAnnotations),
134
- onViewed: onAnnotationViewed
135
- }, /*#__PURE__*/_react.default.createElement(ViewComponent, {
136
- annotationsList: annotationsList,
137
- annotations: activeAnnotations,
138
- dom: dom,
139
- onDelete: function onDelete(id) {
140
- return (0, _commands.removeInlineCommentNearSelection)(id)(state, dispatch);
141
- },
142
- onResolve: function onResolve(id) {
143
- return (0, _commands.updateInlineCommentResolvedState)(editorAnalyticsAPI)((0, _defineProperty2.default)({}, id, true), _analytics.RESOLVE_METHOD.COMPONENT)(editorView.state, editorView.dispatch);
144
- },
145
- onClose: function onClose() {
146
- (0, _commands.closeComponent)()(editorView.state, editorView.dispatch);
147
- }
148
- }));
149
- }
@@ -1,36 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.AnnotationUpdateEmitter = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
11
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
- var _events = require("events");
15
- 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); }; }
16
- 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; } }
17
- var AnnotationUpdateEmitter = exports.AnnotationUpdateEmitter = /*#__PURE__*/function (_EventEmitter) {
18
- (0, _inherits2.default)(AnnotationUpdateEmitter, _EventEmitter);
19
- var _super = _createSuper(AnnotationUpdateEmitter);
20
- function AnnotationUpdateEmitter() {
21
- (0, _classCallCheck2.default)(this, AnnotationUpdateEmitter);
22
- return _super.apply(this, arguments);
23
- }
24
- (0, _createClass2.default)(AnnotationUpdateEmitter, [{
25
- key: "on",
26
- value: function on(event, listener) {
27
- return (0, _get2.default)((0, _getPrototypeOf2.default)(AnnotationUpdateEmitter.prototype), "on", this).call(this, event, listener);
28
- }
29
- }, {
30
- key: "off",
31
- value: function off(event, listener) {
32
- return (0, _get2.default)((0, _getPrototypeOf2.default)(AnnotationUpdateEmitter.prototype), "removeListener", this).call(this, event, listener);
33
- }
34
- }]);
35
- return AnnotationUpdateEmitter;
36
- }(_events.EventEmitter);