@atlaskit/editor-core 187.47.0 → 187.47.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 187.47.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`c89c55c6d49`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c89c55c6d49) - [ux] ED-19508 fixes closed inline comments reopening when user toggles an expand node
8
+
3
9
  ## 187.47.0
4
10
 
5
11
  ### Minor Changes
@@ -27,9 +27,12 @@ var updateInlineCommentResolvedState = function updateInlineCommentResolvedState
27
27
  return (0, _pluginFactory.createCommand)(command);
28
28
  };
29
29
  exports.updateInlineCommentResolvedState = updateInlineCommentResolvedState;
30
- var closeComponent = function closeComponent() {
30
+ var closeComponent = function closeComponent(state) {
31
31
  return (0, _pluginFactory.createCommand)({
32
- type: _types.ACTIONS.CLOSE_COMPONENT
32
+ type: _types.ACTIONS.CLOSE_COMPONENT,
33
+ data: {
34
+ lastClosedPos: state.selection.$head.pos
35
+ }
33
36
  });
34
37
  };
35
38
  exports.closeComponent = closeComponent;
@@ -156,7 +156,7 @@ var inlineCommentPlugin = function inlineCommentPlugin(options) {
156
156
  };
157
157
  var setSelectedAnnotationFn = function setSelectedAnnotationFn(annotationId) {
158
158
  if (!annotationId) {
159
- (0, _commands.closeComponent)()(editorView.state, editorView.dispatch);
159
+ (0, _commands.closeComponent)(editorView.state)(editorView.state, editorView.dispatch);
160
160
  } else {
161
161
  (0, _commands.setSelectedAnnotation)(annotationId)(editorView.state, editorView.dispatch);
162
162
  }
@@ -21,7 +21,8 @@ var _default = function _default(pluginState, action) {
21
21
  case _types.ACTIONS.INLINE_COMMENT_UPDATE_MOUSE_STATE:
22
22
  var mouseData = Object.assign({}, pluginState.mouseData, action.data.mouseData);
23
23
  return _objectSpread(_objectSpread({}, pluginState), {}, {
24
- mouseData: mouseData
24
+ mouseData: mouseData,
25
+ lastClosedPos: undefined
25
26
  });
26
27
  case _types.ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE:
27
28
  return getNewDraftState(pluginState, action.data.drafting, action.data.editorState);
@@ -32,7 +33,8 @@ var _default = function _default(pluginState, action) {
32
33
  });
33
34
  case _types.ACTIONS.CLOSE_COMPONENT:
34
35
  return _objectSpread(_objectSpread({}, pluginState), {}, {
35
- selectedAnnotations: []
36
+ selectedAnnotations: [],
37
+ lastClosedPos: action.data.lastClosedPos
36
38
  });
37
39
  case _types.ACTIONS.ADD_INLINE_COMMENT:
38
40
  var updatedPluginState = getNewDraftState(pluginState, action.data.drafting, action.data.editorState);
@@ -45,7 +45,8 @@ function InlineCommentView(_ref) {
45
45
  var _ref2 = inlineCommentState || {},
46
46
  bookmark = _ref2.bookmark,
47
47
  selectedAnnotations = _ref2.selectedAnnotations,
48
- annotations = _ref2.annotations;
48
+ annotations = _ref2.annotations,
49
+ lastClosedPos = _ref2.lastClosedPos;
49
50
  var annotationsList = (0, _utils2.getAllAnnotations)(editorView.state.doc);
50
51
  var selection = (0, _utils2.getSelectionPositions)(state, inlineCommentState);
51
52
  var position = findPosForDOM(selection);
@@ -107,7 +108,9 @@ function InlineCommentView(_ref) {
107
108
  var activeAnnotations = (selectedAnnotations === null || selectedAnnotations === void 0 ? void 0 : selectedAnnotations.filter(function (mark) {
108
109
  return annotations && annotations[mark.id] === false;
109
110
  })) || [];
110
- if (!ViewComponent || activeAnnotations.length === 0) {
111
+ if (!ViewComponent || activeAnnotations.length === 0 ||
112
+ // Check if the user has moved the selection since closing the previous comment
113
+ editorView.state.selection.$head.pos === lastClosedPos) {
111
114
  return null;
112
115
  }
113
116
  var onAnnotationViewed = function onAnnotationViewed() {
@@ -145,7 +148,7 @@ function InlineCommentView(_ref) {
145
148
  return (0, _commands.updateInlineCommentResolvedState)((0, _defineProperty2.default)({}, id, true), _inlineCommentEvents.RESOLVE_METHOD.COMPONENT)(editorView.state, editorView.dispatch);
146
149
  },
147
150
  onClose: function onClose() {
148
- (0, _commands.closeComponent)()(editorView.state, editorView.dispatch);
151
+ (0, _commands.closeComponent)(editorView.state)(editorView.state, editorView.dispatch);
149
152
  }
150
153
  }));
151
154
  }
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = "@atlaskit/editor-core";
8
8
  exports.name = name;
9
- var version = "187.47.0";
9
+ var version = "187.47.2";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -16,8 +16,11 @@ export const updateInlineCommentResolvedState = (partialNewState, resolveMethod)
16
16
  }
17
17
  return createCommand(command);
18
18
  };
19
- export const closeComponent = () => createCommand({
20
- type: ACTIONS.CLOSE_COMPONENT
19
+ export const closeComponent = state => createCommand({
20
+ type: ACTIONS.CLOSE_COMPONENT,
21
+ data: {
22
+ lastClosedPos: state.selection.$head.pos
23
+ }
21
24
  });
22
25
  export const clearDirtyMark = () => createCommand({
23
26
  type: ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK
@@ -99,7 +99,7 @@ export const inlineCommentPlugin = options => {
99
99
  const setVisibility = isVisible => onSetVisibility(editorView)(isVisible);
100
100
  const setSelectedAnnotationFn = annotationId => {
101
101
  if (!annotationId) {
102
- closeComponent()(editorView.state, editorView.dispatch);
102
+ closeComponent(editorView.state)(editorView.state, editorView.dispatch);
103
103
  } else {
104
104
  setSelectedAnnotation(annotationId)(editorView.state, editorView.dispatch);
105
105
  }
@@ -15,7 +15,8 @@ export default ((pluginState, action) => {
15
15
  const mouseData = Object.assign({}, pluginState.mouseData, action.data.mouseData);
16
16
  return {
17
17
  ...pluginState,
18
- mouseData
18
+ mouseData,
19
+ lastClosedPos: undefined
19
20
  };
20
21
  case ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE:
21
22
  return getNewDraftState(pluginState, action.data.drafting, action.data.editorState);
@@ -28,7 +29,8 @@ export default ((pluginState, action) => {
28
29
  case ACTIONS.CLOSE_COMPONENT:
29
30
  return {
30
31
  ...pluginState,
31
- selectedAnnotations: []
32
+ selectedAnnotations: [],
33
+ lastClosedPos: action.data.lastClosedPos
32
34
  };
33
35
  case ACTIONS.ADD_INLINE_COMMENT:
34
36
  const updatedPluginState = getNewDraftState(pluginState, action.data.drafting, action.data.editorState);
@@ -44,7 +44,8 @@ export function InlineCommentView({
44
44
  const {
45
45
  bookmark,
46
46
  selectedAnnotations,
47
- annotations
47
+ annotations,
48
+ lastClosedPos
48
49
  } = inlineCommentState || {};
49
50
  const annotationsList = getAllAnnotations(editorView.state.doc);
50
51
  const selection = getSelectionPositions(state, inlineCommentState);
@@ -105,7 +106,9 @@ export function InlineCommentView({
105
106
 
106
107
  // View Component
107
108
  const activeAnnotations = (selectedAnnotations === null || selectedAnnotations === void 0 ? void 0 : selectedAnnotations.filter(mark => annotations && annotations[mark.id] === false)) || [];
108
- if (!ViewComponent || activeAnnotations.length === 0) {
109
+ if (!ViewComponent || activeAnnotations.length === 0 ||
110
+ // Check if the user has moved the selection since closing the previous comment
111
+ editorView.state.selection.$head.pos === lastClosedPos) {
109
112
  return null;
110
113
  }
111
114
  const onAnnotationViewed = () => {
@@ -141,7 +144,7 @@ export function InlineCommentView({
141
144
  [id]: true
142
145
  }, RESOLVE_METHOD.COMPONENT)(editorView.state, editorView.dispatch),
143
146
  onClose: () => {
144
- closeComponent()(editorView.state, editorView.dispatch);
147
+ closeComponent(editorView.state)(editorView.state, editorView.dispatch);
145
148
  }
146
149
  }));
147
150
  }
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.47.0";
2
+ export const version = "187.47.2";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -19,9 +19,12 @@ export var updateInlineCommentResolvedState = function updateInlineCommentResolv
19
19
  }
20
20
  return createCommand(command);
21
21
  };
22
- export var closeComponent = function closeComponent() {
22
+ export var closeComponent = function closeComponent(state) {
23
23
  return createCommand({
24
- type: ACTIONS.CLOSE_COMPONENT
24
+ type: ACTIONS.CLOSE_COMPONENT,
25
+ data: {
26
+ lastClosedPos: state.selection.$head.pos
27
+ }
25
28
  });
26
29
  };
27
30
  export var clearDirtyMark = function clearDirtyMark() {
@@ -149,7 +149,7 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
149
149
  };
150
150
  var setSelectedAnnotationFn = function setSelectedAnnotationFn(annotationId) {
151
151
  if (!annotationId) {
152
- closeComponent()(editorView.state, editorView.dispatch);
152
+ closeComponent(editorView.state)(editorView.state, editorView.dispatch);
153
153
  } else {
154
154
  setSelectedAnnotation(annotationId)(editorView.state, editorView.dispatch);
155
155
  }
@@ -14,7 +14,8 @@ export default (function (pluginState, action) {
14
14
  case ACTIONS.INLINE_COMMENT_UPDATE_MOUSE_STATE:
15
15
  var mouseData = Object.assign({}, pluginState.mouseData, action.data.mouseData);
16
16
  return _objectSpread(_objectSpread({}, pluginState), {}, {
17
- mouseData: mouseData
17
+ mouseData: mouseData,
18
+ lastClosedPos: undefined
18
19
  });
19
20
  case ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE:
20
21
  return getNewDraftState(pluginState, action.data.drafting, action.data.editorState);
@@ -25,7 +26,8 @@ export default (function (pluginState, action) {
25
26
  });
26
27
  case ACTIONS.CLOSE_COMPONENT:
27
28
  return _objectSpread(_objectSpread({}, pluginState), {}, {
28
- selectedAnnotations: []
29
+ selectedAnnotations: [],
30
+ lastClosedPos: action.data.lastClosedPos
29
31
  });
30
32
  case ACTIONS.ADD_INLINE_COMMENT:
31
33
  var updatedPluginState = getNewDraftState(pluginState, action.data.drafting, action.data.editorState);
@@ -38,7 +38,8 @@ export function InlineCommentView(_ref) {
38
38
  var _ref2 = inlineCommentState || {},
39
39
  bookmark = _ref2.bookmark,
40
40
  selectedAnnotations = _ref2.selectedAnnotations,
41
- annotations = _ref2.annotations;
41
+ annotations = _ref2.annotations,
42
+ lastClosedPos = _ref2.lastClosedPos;
42
43
  var annotationsList = getAllAnnotations(editorView.state.doc);
43
44
  var selection = getSelectionPositions(state, inlineCommentState);
44
45
  var position = findPosForDOM(selection);
@@ -100,7 +101,9 @@ export function InlineCommentView(_ref) {
100
101
  var activeAnnotations = (selectedAnnotations === null || selectedAnnotations === void 0 ? void 0 : selectedAnnotations.filter(function (mark) {
101
102
  return annotations && annotations[mark.id] === false;
102
103
  })) || [];
103
- if (!ViewComponent || activeAnnotations.length === 0) {
104
+ if (!ViewComponent || activeAnnotations.length === 0 ||
105
+ // Check if the user has moved the selection since closing the previous comment
106
+ editorView.state.selection.$head.pos === lastClosedPos) {
104
107
  return null;
105
108
  }
106
109
  var onAnnotationViewed = function onAnnotationViewed() {
@@ -138,7 +141,7 @@ export function InlineCommentView(_ref) {
138
141
  return updateInlineCommentResolvedState(_defineProperty({}, id, true), RESOLVE_METHOD.COMPONENT)(editorView.state, editorView.dispatch);
139
142
  },
140
143
  onClose: function onClose() {
141
- closeComponent()(editorView.state, editorView.dispatch);
144
+ closeComponent(editorView.state)(editorView.state, editorView.dispatch);
142
145
  }
143
146
  }));
144
147
  }
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "187.47.0";
2
+ export var version = "187.47.2";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,10 +1,11 @@
1
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
1
2
  import type { RESOLVE_METHOD } from './../../analytics/types/inline-comment-events';
2
3
  import type { Command } from '../../../types';
3
4
  import { AnnotationTypes } from '@atlaskit/adf-schema';
4
5
  import { INPUT_METHOD } from '../../analytics';
5
6
  import type { InlineCommentMap, InlineCommentMouseData } from '../pm-plugins/types';
6
7
  export declare const updateInlineCommentResolvedState: (partialNewState: InlineCommentMap, resolveMethod?: RESOLVE_METHOD) => Command;
7
- export declare const closeComponent: () => Command;
8
+ export declare const closeComponent: (state: EditorState) => Command;
8
9
  export declare const clearDirtyMark: () => Command;
9
10
  export declare const removeInlineCommentNearSelection: (id: string) => Command;
10
11
  export declare const setInlineCommentDraftState: (drafting: boolean, inputMethod?: INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHORTCUT) => Command;
@@ -43,6 +43,9 @@ export type InlineCommentAction = {
43
43
  type: ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK;
44
44
  } | {
45
45
  type: ACTIONS.CLOSE_COMPONENT;
46
+ data: {
47
+ lastClosedPos: number;
48
+ };
46
49
  } | {
47
50
  type: ACTIONS.ADD_INLINE_COMMENT;
48
51
  data: {
@@ -71,4 +74,5 @@ export type InlineCommentPluginState = {
71
74
  bookmark?: SelectionBookmark;
72
75
  disallowOnWhitespace: boolean;
73
76
  isVisible: boolean;
77
+ lastClosedPos?: number;
74
78
  };
@@ -1,10 +1,11 @@
1
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
1
2
  import type { RESOLVE_METHOD } from './../../analytics/types/inline-comment-events';
2
3
  import type { Command } from '../../../types';
3
4
  import { AnnotationTypes } from '@atlaskit/adf-schema';
4
5
  import { INPUT_METHOD } from '../../analytics';
5
6
  import type { InlineCommentMap, InlineCommentMouseData } from '../pm-plugins/types';
6
7
  export declare const updateInlineCommentResolvedState: (partialNewState: InlineCommentMap, resolveMethod?: RESOLVE_METHOD) => Command;
7
- export declare const closeComponent: () => Command;
8
+ export declare const closeComponent: (state: EditorState) => Command;
8
9
  export declare const clearDirtyMark: () => Command;
9
10
  export declare const removeInlineCommentNearSelection: (id: string) => Command;
10
11
  export declare const setInlineCommentDraftState: (drafting: boolean, inputMethod?: INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHORTCUT) => Command;
@@ -43,6 +43,9 @@ export type InlineCommentAction = {
43
43
  type: ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK;
44
44
  } | {
45
45
  type: ACTIONS.CLOSE_COMPONENT;
46
+ data: {
47
+ lastClosedPos: number;
48
+ };
46
49
  } | {
47
50
  type: ACTIONS.ADD_INLINE_COMMENT;
48
51
  data: {
@@ -71,4 +74,5 @@ export type InlineCommentPluginState = {
71
74
  bookmark?: SelectionBookmark;
72
75
  disallowOnWhitespace: boolean;
73
76
  isVisible: boolean;
77
+ lastClosedPos?: number;
74
78
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.47.0",
3
+ "version": "187.47.2",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"