@atlaskit/editor-core 178.0.2 → 178.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.
Files changed (179) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/cjs/create-editor/create-plugins-list.js +3 -1
  3. package/dist/cjs/plugins/alignment/ui/ToolbarAlignment/index.js +26 -13
  4. package/dist/cjs/plugins/annotation/index.js +4 -2
  5. package/dist/cjs/plugins/annotation/ui/InlineCommentView.js +6 -2
  6. package/dist/cjs/plugins/base/pm-plugins/react-nodeview.js +8 -1
  7. package/dist/cjs/plugins/block-type/commands/delete-block-content.js +53 -0
  8. package/dist/cjs/plugins/block-type/commands/index.js +9 -1
  9. package/dist/cjs/plugins/block-type/pm-plugins/keymap.js +2 -2
  10. package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/index.js +8 -4
  11. package/dist/cjs/plugins/card/nodeviews/blockCard.js +1 -1
  12. package/dist/cjs/plugins/card/nodeviews/embedCard.js +1 -3
  13. package/dist/cjs/plugins/card/pm-plugins/doc.js +21 -4
  14. package/dist/cjs/plugins/card/toolbar.js +4 -2
  15. package/dist/cjs/plugins/card/ui/EditLinkToolbar.js +4 -1
  16. package/dist/cjs/plugins/card/ui/LinkToolbarAppearance.js +16 -9
  17. package/dist/cjs/plugins/collab-edit/actions.js +1 -1
  18. package/dist/cjs/plugins/collab-edit/index.js +1 -1
  19. package/dist/cjs/plugins/collab-edit/provider/channel.js +1 -1
  20. package/dist/cjs/plugins/expand/pm-plugins/keymap.js +5 -0
  21. package/dist/cjs/plugins/floating-toolbar/ui/Select.js +2 -1
  22. package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +18 -9
  23. package/dist/cjs/plugins/hyperlink/HyperlinkToolbarAppearance.js +1 -0
  24. package/dist/cjs/plugins/hyperlink/index.js +2 -1
  25. package/dist/cjs/plugins/hyperlink/ui/EditorLinkPicker/index.js +15 -2
  26. package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +27 -22
  27. package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +6 -2
  28. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +2 -1
  29. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +2 -1
  30. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +2 -1
  31. package/dist/cjs/plugins/media/commands/helpers.js +24 -2
  32. package/dist/cjs/plugins/media/nodeviews/mediaGroup.js +14 -16
  33. package/dist/cjs/plugins/media/nodeviews/mediaNodeUpdater.js +232 -183
  34. package/dist/cjs/plugins/media/nodeviews/mediaNodeView/index.js +1 -3
  35. package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +1 -1
  36. package/dist/cjs/plugins/media/pm-plugins/keymap.js +46 -0
  37. package/dist/cjs/plugins/rank.js +3 -2
  38. package/dist/cjs/plugins/selection/pm-plugins/events/create-selection-between.js +86 -0
  39. package/dist/cjs/plugins/selection/pm-plugins/events/keydown.js +84 -0
  40. package/dist/cjs/plugins/selection/pm-plugins/selection-main.js +6 -56
  41. package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/index.js +1 -1
  42. package/dist/cjs/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +7 -2
  43. package/dist/cjs/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +4 -2
  44. package/dist/cjs/ui/Addon/ClickAreaBlock/index.js +22 -61
  45. package/dist/cjs/ui/Addon/ClickAreaInline/index.js +22 -56
  46. package/dist/cjs/ui/Addon/click-area-helper.js +28 -6
  47. package/dist/cjs/ui/Alignment/AlignmentButton/index.js +4 -2
  48. package/dist/cjs/ui/ElementBrowser/InsertMenu.js +2 -1
  49. package/dist/cjs/ui/ToolbarArrowKeyNavigationProvider/index.js +22 -9
  50. package/dist/cjs/utils/document.js +11 -2
  51. package/dist/cjs/version-wrapper.js +1 -1
  52. package/dist/cjs/version.json +1 -1
  53. package/dist/es2019/create-editor/create-plugins-list.js +3 -1
  54. package/dist/es2019/plugins/alignment/ui/ToolbarAlignment/index.js +28 -13
  55. package/dist/es2019/plugins/annotation/index.js +4 -2
  56. package/dist/es2019/plugins/annotation/ui/InlineCommentView.js +6 -2
  57. package/dist/es2019/plugins/base/pm-plugins/react-nodeview.js +8 -1
  58. package/dist/es2019/plugins/block-type/commands/delete-block-content.js +49 -0
  59. package/dist/es2019/plugins/block-type/commands/index.js +2 -1
  60. package/dist/es2019/plugins/block-type/pm-plugins/keymap.js +3 -3
  61. package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/index.js +8 -4
  62. package/dist/es2019/plugins/card/nodeviews/blockCard.js +1 -1
  63. package/dist/es2019/plugins/card/nodeviews/embedCard.js +1 -2
  64. package/dist/es2019/plugins/card/pm-plugins/doc.js +19 -3
  65. package/dist/es2019/plugins/card/toolbar.js +4 -2
  66. package/dist/es2019/plugins/card/ui/EditLinkToolbar.js +5 -2
  67. package/dist/es2019/plugins/card/ui/LinkToolbarAppearance.js +15 -9
  68. package/dist/es2019/plugins/collab-edit/actions.js +1 -1
  69. package/dist/es2019/plugins/collab-edit/index.js +1 -1
  70. package/dist/es2019/plugins/collab-edit/provider/channel.js +1 -1
  71. package/dist/es2019/plugins/expand/pm-plugins/keymap.js +5 -0
  72. package/dist/es2019/plugins/floating-toolbar/ui/Select.js +2 -1
  73. package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +18 -9
  74. package/dist/es2019/plugins/hyperlink/HyperlinkToolbarAppearance.js +1 -0
  75. package/dist/es2019/plugins/hyperlink/index.js +2 -1
  76. package/dist/es2019/plugins/hyperlink/ui/EditorLinkPicker/index.js +11 -2
  77. package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +1 -5
  78. package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +6 -2
  79. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +2 -1
  80. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +2 -1
  81. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +2 -1
  82. package/dist/es2019/plugins/media/commands/helpers.js +18 -1
  83. package/dist/es2019/plugins/media/nodeviews/mediaGroup.js +14 -16
  84. package/dist/es2019/plugins/media/nodeviews/mediaNodeUpdater.js +37 -13
  85. package/dist/es2019/plugins/media/nodeviews/mediaNodeView/index.js +1 -2
  86. package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +1 -1
  87. package/dist/es2019/plugins/media/pm-plugins/keymap.js +45 -0
  88. package/dist/es2019/plugins/rank.js +3 -2
  89. package/dist/es2019/plugins/selection/pm-plugins/events/create-selection-between.js +79 -0
  90. package/dist/es2019/plugins/selection/pm-plugins/events/keydown.js +77 -0
  91. package/dist/es2019/plugins/selection/pm-plugins/selection-main.js +5 -55
  92. package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/index.js +1 -1
  93. package/dist/es2019/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +6 -2
  94. package/dist/es2019/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +3 -2
  95. package/dist/es2019/ui/Addon/ClickAreaBlock/index.js +20 -31
  96. package/dist/es2019/ui/Addon/ClickAreaInline/index.js +20 -27
  97. package/dist/es2019/ui/Addon/click-area-helper.js +28 -6
  98. package/dist/es2019/ui/Alignment/AlignmentButton/index.js +4 -2
  99. package/dist/es2019/ui/ElementBrowser/InsertMenu.js +2 -1
  100. package/dist/es2019/ui/ToolbarArrowKeyNavigationProvider/index.js +22 -9
  101. package/dist/es2019/utils/document.js +9 -2
  102. package/dist/es2019/version-wrapper.js +1 -1
  103. package/dist/es2019/version.json +1 -1
  104. package/dist/esm/create-editor/create-plugins-list.js +3 -1
  105. package/dist/esm/plugins/alignment/ui/ToolbarAlignment/index.js +26 -13
  106. package/dist/esm/plugins/annotation/index.js +4 -2
  107. package/dist/esm/plugins/annotation/ui/InlineCommentView.js +6 -2
  108. package/dist/esm/plugins/base/pm-plugins/react-nodeview.js +8 -1
  109. package/dist/esm/plugins/block-type/commands/delete-block-content.js +46 -0
  110. package/dist/esm/plugins/block-type/commands/index.js +2 -1
  111. package/dist/esm/plugins/block-type/pm-plugins/keymap.js +3 -3
  112. package/dist/esm/plugins/block-type/ui/ToolbarBlockType/index.js +8 -4
  113. package/dist/esm/plugins/card/nodeviews/blockCard.js +1 -1
  114. package/dist/esm/plugins/card/nodeviews/embedCard.js +1 -2
  115. package/dist/esm/plugins/card/pm-plugins/doc.js +20 -3
  116. package/dist/esm/plugins/card/toolbar.js +4 -2
  117. package/dist/esm/plugins/card/ui/EditLinkToolbar.js +5 -2
  118. package/dist/esm/plugins/card/ui/LinkToolbarAppearance.js +16 -9
  119. package/dist/esm/plugins/collab-edit/actions.js +1 -1
  120. package/dist/esm/plugins/collab-edit/index.js +1 -1
  121. package/dist/esm/plugins/collab-edit/provider/channel.js +1 -1
  122. package/dist/esm/plugins/expand/pm-plugins/keymap.js +5 -0
  123. package/dist/esm/plugins/floating-toolbar/ui/Select.js +2 -1
  124. package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +18 -9
  125. package/dist/esm/plugins/hyperlink/HyperlinkToolbarAppearance.js +1 -0
  126. package/dist/esm/plugins/hyperlink/index.js +2 -1
  127. package/dist/esm/plugins/hyperlink/ui/EditorLinkPicker/index.js +15 -3
  128. package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +27 -22
  129. package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +6 -2
  130. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +2 -1
  131. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +2 -1
  132. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +2 -1
  133. package/dist/esm/plugins/media/commands/helpers.js +20 -1
  134. package/dist/esm/plugins/media/nodeviews/mediaGroup.js +14 -16
  135. package/dist/esm/plugins/media/nodeviews/mediaNodeUpdater.js +235 -184
  136. package/dist/esm/plugins/media/nodeviews/mediaNodeView/index.js +1 -2
  137. package/dist/esm/plugins/media/nodeviews/mediaSingle.js +1 -1
  138. package/dist/esm/plugins/media/pm-plugins/keymap.js +45 -0
  139. package/dist/esm/plugins/rank.js +3 -2
  140. package/dist/esm/plugins/selection/pm-plugins/events/create-selection-between.js +76 -0
  141. package/dist/esm/plugins/selection/pm-plugins/events/keydown.js +74 -0
  142. package/dist/esm/plugins/selection/pm-plugins/selection-main.js +4 -57
  143. package/dist/esm/plugins/text-color/ui/ToolbarTextColor/index.js +1 -1
  144. package/dist/esm/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +7 -2
  145. package/dist/esm/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +4 -2
  146. package/dist/esm/ui/Addon/ClickAreaBlock/index.js +17 -58
  147. package/dist/esm/ui/Addon/ClickAreaInline/index.js +17 -53
  148. package/dist/esm/ui/Addon/click-area-helper.js +28 -6
  149. package/dist/esm/ui/Alignment/AlignmentButton/index.js +4 -2
  150. package/dist/esm/ui/ElementBrowser/InsertMenu.js +2 -1
  151. package/dist/esm/ui/ToolbarArrowKeyNavigationProvider/index.js +22 -9
  152. package/dist/esm/utils/document.js +11 -2
  153. package/dist/esm/version-wrapper.js +1 -1
  154. package/dist/esm/version.json +1 -1
  155. package/dist/types/plugins/alignment/ui/ToolbarAlignment/index.d.ts +1 -1
  156. package/dist/types/plugins/block-type/commands/delete-block-content.d.ts +10 -0
  157. package/dist/types/plugins/block-type/commands/index.d.ts +1 -0
  158. package/dist/types/plugins/card/pm-plugins/doc.d.ts +1 -1
  159. package/dist/types/plugins/card/ui/LinkToolbarAppearance.d.ts +1 -0
  160. package/dist/types/plugins/floating-toolbar/ui/Select.d.ts +1 -0
  161. package/dist/types/plugins/hyperlink/ui/EditorLinkPicker/index.d.ts +6 -1
  162. package/dist/types/plugins/hyperlink/ui/HyperlinkAddToolbar/index.d.ts +1 -1
  163. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.d.ts +1 -0
  164. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.d.ts +1 -0
  165. package/dist/types/plugins/media/commands/helpers.d.ts +1 -0
  166. package/dist/types/plugins/media/nodeviews/__mocks__/mediaNodeUpdater.d.ts +1 -0
  167. package/dist/types/plugins/media/nodeviews/mediaNodeUpdater.d.ts +3 -1
  168. package/dist/types/plugins/media/types.d.ts +2 -0
  169. package/dist/types/plugins/selection/pm-plugins/events/create-selection-between.d.ts +4 -0
  170. package/dist/types/plugins/selection/pm-plugins/events/keydown.d.ts +2 -0
  171. package/dist/types/ui/Addon/ClickAreaBlock/index.d.ts +2 -5
  172. package/dist/types/ui/Addon/ClickAreaInline/index.d.ts +2 -5
  173. package/dist/types/ui/Addon/click-area-helper.d.ts +1 -1
  174. package/dist/types/ui/Alignment/AlignmentButton/index.d.ts +1 -1
  175. package/dist/types/ui/ElementBrowser/InsertMenu.d.ts +1 -1
  176. package/dist/types/ui/ElementBrowser/types.d.ts +1 -0
  177. package/docs/0-intro.tsx +9 -0
  178. package/package.json +13 -15
  179. package/report.api.md +4 -1
@@ -13,7 +13,6 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
13
13
 
14
14
  import { WithProviders } from '@atlaskit/editor-common/provider-factory';
15
15
  import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/ui';
16
- import { browser } from '@atlaskit/editor-common/utils';
17
16
  import { NodeSelection } from 'prosemirror-state';
18
17
  import React from 'react';
19
18
  import { SelectionBasedNodeView } from '../../../../nodeviews';
@@ -112,7 +111,7 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
112
111
  value: function createDomRef() {
113
112
  var domRef = document.createElement('div');
114
113
 
115
- if (browser.chrome && this.reactComponentProps.mediaOptions && this.reactComponentProps.mediaOptions.allowMediaSingleEditable) {
114
+ if (this.reactComponentProps.mediaOptions && this.reactComponentProps.mediaOptions.allowMediaSingleEditable) {
116
115
  // workaround Chrome bug in https://product-fabric.atlassian.net/browse/ED-5379
117
116
  // see also: https://github.com/ProseMirror/prosemirror/issues/884
118
117
  domRef.contentEditable = 'true';
@@ -530,7 +530,7 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
530
530
  value: function createDomRef() {
531
531
  var domRef = document.createElement('div');
532
532
 
533
- if (browser.chrome && this.reactComponentProps.mediaOptions && this.reactComponentProps.mediaOptions.allowMediaSingleEditable) {
533
+ if (this.reactComponentProps.mediaOptions && this.reactComponentProps.mediaOptions.allowMediaSingleEditable) {
534
534
  // workaround Chrome bug in https://product-fabric.atlassian.net/browse/ED-5379
535
535
  // see also: https://github.com/ProseMirror/prosemirror/issues/884
536
536
  domRef.contentEditable = 'true';
@@ -3,6 +3,7 @@ import { NodeSelection } from 'prosemirror-state';
3
3
  import * as keymaps from '../../../keymaps';
4
4
  import { stateKey } from '../pm-plugins/plugin-key';
5
5
  import { getMediaFeatureFlag } from '@atlaskit/media-common';
6
+ import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
6
7
  import { insertAndSelectCaptionFromMediaSinglePos, selectCaptionFromMediaSinglePos } from '../commands/captions';
7
8
  export function keymapPlugin(options) {
8
9
  var list = {};
@@ -16,6 +17,8 @@ export function keymapPlugin(options) {
16
17
  if (getMediaFeatureFlag('captions', featureFlags)) {
17
18
  keymaps.bindKeymapWithCommand(keymaps.moveDown.common, insertAndSelectCaption, list);
18
19
  keymaps.bindKeymapWithCommand(keymaps.tab.common, insertAndSelectCaption, list);
20
+ keymaps.bindKeymapWithCommand(keymaps.moveLeft.common, arrowLeftFromMediaSingle(options === null || options === void 0 ? void 0 : options.editorSelectionAPI), list);
21
+ keymaps.bindKeymapWithCommand(keymaps.moveRight.common, arrowRightFromMediaSingle(options === null || options === void 0 ? void 0 : options.editorSelectionAPI), list);
19
22
  }
20
23
 
21
24
  keymaps.bindKeymapWithCommand(keymaps.insertNewLine.common, splitMediaGroup, list);
@@ -53,4 +56,46 @@ var insertAndSelectCaption = function insertAndSelectCaption(state, dispatch) {
53
56
  return false;
54
57
  };
55
58
 
59
+ var arrowLeftFromMediaSingle = function arrowLeftFromMediaSingle(editorSelectionAPI) {
60
+ return function (state, dispatch) {
61
+ var selection = state.selection;
62
+
63
+ if (editorSelectionAPI && selection instanceof NodeSelection && selection.node.type.name === 'mediaSingle') {
64
+ var tr = editorSelectionAPI.setSelectionRelativeToNode({
65
+ selectionRelativeToNode: undefined,
66
+ selection: new GapCursorSelection(state.doc.resolve(selection.from), Side.LEFT)
67
+ })(state);
68
+
69
+ if (dispatch) {
70
+ dispatch(tr);
71
+ }
72
+
73
+ return true;
74
+ }
75
+
76
+ return false;
77
+ };
78
+ };
79
+
80
+ var arrowRightFromMediaSingle = function arrowRightFromMediaSingle(editorSelectionAPI) {
81
+ return function (state, dispatch) {
82
+ var selection = state.selection;
83
+
84
+ if (editorSelectionAPI && selection instanceof NodeSelection && selection.node.type.name === 'mediaSingle') {
85
+ var tr = editorSelectionAPI.setSelectionRelativeToNode({
86
+ selectionRelativeToNode: undefined,
87
+ selection: new GapCursorSelection(state.doc.resolve(selection.to), Side.RIGHT)
88
+ })(state);
89
+
90
+ if (dispatch) {
91
+ dispatch(tr);
92
+ }
93
+
94
+ return true;
95
+ }
96
+
97
+ return false;
98
+ };
99
+ };
100
+
56
101
  export default keymapPlugin;
@@ -4,9 +4,10 @@ export default {
4
4
  'indentationKeymap', 'textColor', 'alignmentPlugin', 'listInputRule', 'listKeymap', 'codeBlock', 'codeBlockIDEKeyBindings', 'codeBlockKeyMap', 'textFormatting', 'textFormattingCursor', 'textFormattingInputRule', 'textFormattingSmartRule', 'textFormattingClear', 'textFormattingKeymap', // task/decisions keymap needs to be above table keymap so can indent actions in a table
5
5
  'tasksAndDecisionsKeyMap', // expand and table keymaps need to be above selection keymap to add their custom selection behaviour:
6
6
  // https://product-fabric.atlassian.net/wiki/spaces/E/pages/1113098008/Selection+Guide#Special-Cases
7
- 'expandKeymap', 'tableSelectionKeymap', 'tableKeymap', 'captionKeymap', // selection keymap needs to be above gap cursor keymap so it can set node selections from
7
+ 'expandKeymap', 'tableSelectionKeymap', 'tableKeymap', 'captionKeymap', // media keymap above selection keymap to allow navigating past the mediaSingle node
8
+ 'mediaKeymap', // selection keymap needs to be above gap cursor keymap so it can set node selections from
8
9
  // left/right arrows
9
- 'selectionKeymap', 'gapCursorKeymap', 'gapCursor', 'syncUrlText', 'fakeCursorToolbarPlugin', 'hyperLink', 'table', 'tableDecorations', 'hyperlinkInputRule', 'tablePMColResizing', 'hyperlinkKeymap', 'tableColResizing', 'undoRedoKeyMap', 'blockTypeKeyMap', 'tableEditing', 'filterStepsPlugin', 'pmCollab', 'collab', 'ruleInputRule', 'ruleKeymap', 'panel', 'media', 'mediaKeymap', 'mediaSingleKeymap', 'mediaEditor', 'unsupportedContent', 'jiraIssue', 'fakeTextCursor', 'helpDialog', 'helpDialogKeymap', 'macro', 'expand', 'extension', 'layout', 'contextPanel', 'floatingToolbar', 'clearMarksOnChange', 'reactNodeView', 'history', 'undoRedoPlugin', 'codeBlockIndent', 'placeholder', 'width', 'maxContentSize', 'multilineContent', 'grid', 'mobileDimensions', 'scrollGutterPlugin', 'analytics', 'findReplace', 'selection', 'avatarGroup', 'viewUpdateSubscription', 'beforePrimaryToolbar', 'inlineCode'],
10
+ 'selectionKeymap', 'gapCursorKeymap', 'gapCursor', 'syncUrlText', 'fakeCursorToolbarPlugin', 'hyperLink', 'table', 'tableDecorations', 'hyperlinkInputRule', 'tablePMColResizing', 'hyperlinkKeymap', 'tableColResizing', 'undoRedoKeyMap', 'blockTypeKeyMap', 'tableEditing', 'filterStepsPlugin', 'pmCollab', 'collab', 'ruleInputRule', 'ruleKeymap', 'panel', 'media', 'mediaSingleKeymap', 'mediaEditor', 'unsupportedContent', 'jiraIssue', 'fakeTextCursor', 'helpDialog', 'helpDialogKeymap', 'macro', 'expand', 'extension', 'layout', 'contextPanel', 'floatingToolbar', 'clearMarksOnChange', 'reactNodeView', 'history', 'undoRedoPlugin', 'codeBlockIndent', 'placeholder', 'width', 'maxContentSize', 'multilineContent', 'grid', 'mobileDimensions', 'scrollGutterPlugin', 'analytics', 'findReplace', 'selection', 'avatarGroup', 'viewUpdateSubscription', 'beforePrimaryToolbar', 'inlineCode'],
10
11
  nodes: ['doc', 'paragraph', 'text', 'bulletList', 'orderedList', 'listItem', 'heading', 'blockquote', 'codeBlock', 'rule', 'panel', 'mention', 'confluenceUnsupportedBlock', 'confluenceUnsupportedInline', 'unsupportedBlock', 'unsupportedInline', 'confluenceJiraIssue', 'hardBreak', 'emoji', 'placeholder', 'mediaSingle', 'mediaGroup', 'table', 'expand', 'nestedExpand', 'media', 'tableHeader', 'decisionList', 'tableRow', 'decisionItem', 'tableCell', 'taskList', 'taskItem', 'extension', 'bodiedExtension', 'inlineExtension', 'layoutSection', 'layoutColumn', 'inlineCard', 'blockCard', 'embedCard'],
11
12
  marks: [// Fragment mark is both for inline and block elements
12
13
  'fragment', // Inline marks
@@ -0,0 +1,76 @@
1
+ import { NodeSelection, TextSelection } from 'prosemirror-state';
2
+
3
+ function findEmptySelectableParentNodePosition($pos, isValidPosition) {
4
+ var doc = $pos.doc;
5
+
6
+ if ($pos.pos + 1 > doc.content.size) {
7
+ return null;
8
+ }
9
+
10
+ if ($pos.depth === 0) {
11
+ if (isValidPosition($pos)) {
12
+ return $pos;
13
+ }
14
+
15
+ return null;
16
+ }
17
+
18
+ if (isValidPosition($pos)) {
19
+ return $pos;
20
+ }
21
+
22
+ var positionLevelUp = $pos.before();
23
+ var resolvedPositionLevelUp = doc.resolve(positionLevelUp);
24
+ return findEmptySelectableParentNodePosition(resolvedPositionLevelUp, isValidPosition);
25
+ }
26
+
27
+ var checkPositionNode = function checkPositionNode($pos) {
28
+ var maybeNode = $pos.nodeAfter;
29
+
30
+ if (!maybeNode || !maybeNode.isBlock) {
31
+ return false;
32
+ }
33
+
34
+ if (maybeNode.isAtom) {
35
+ return true;
36
+ }
37
+
38
+ var isParentEmpty = maybeNode.content.size === 0 || maybeNode.textContent === '';
39
+ return isParentEmpty && NodeSelection.isSelectable(maybeNode);
40
+ };
41
+
42
+ function findNextSelectionPosition(_ref) {
43
+ var $targetHead = _ref.$targetHead,
44
+ $anchor = _ref.$anchor,
45
+ doc = _ref.doc;
46
+ var direction = $anchor.pos < $targetHead.pos ? 'down' : 'up';
47
+ var maybeNextPosition = findEmptySelectableParentNodePosition($targetHead, checkPositionNode);
48
+
49
+ if (maybeNextPosition && maybeNextPosition.nodeAfter) {
50
+ var nodeAfter = maybeNextPosition.nodeAfter;
51
+ var pos = maybeNextPosition.pos;
52
+ var nextPositionToSelect = direction === 'down' ? Math.min(nodeAfter.nodeSize + pos, doc.content.size) : Math.max(pos, 0);
53
+ return doc.resolve(nextPositionToSelect);
54
+ }
55
+
56
+ return null;
57
+ }
58
+
59
+ export var onCreateSelectionBetween = function onCreateSelectionBetween(view, $anchor, $head) {
60
+ if ($anchor.pos === $head.pos) {
61
+ return null;
62
+ }
63
+
64
+ var $nextHeadPosition = findNextSelectionPosition({
65
+ $targetHead: $head,
66
+ $anchor: $anchor,
67
+ doc: view.state.doc
68
+ });
69
+
70
+ if (!$nextHeadPosition) {
71
+ return null;
72
+ }
73
+
74
+ var forcedTextSelection = TextSelection.create(view.state.doc, $anchor.pos, $nextHeadPosition.pos);
75
+ return forcedTextSelection;
76
+ };
@@ -0,0 +1,74 @@
1
+ import { TextSelection } from 'prosemirror-state';
2
+
3
+ var isCollpasedExpand = function isCollpasedExpand(node) {
4
+ return Boolean(node && ['expand', 'nestedExpand'].includes(node.type.name) && !node.attrs.__expanded);
5
+ };
6
+
7
+ var findFixedProblematicNodePosition = function findFixedProblematicNodePosition($pos, direction) {
8
+ if ($pos.pos === 0 || $pos.depth === 0) {
9
+ return null;
10
+ }
11
+
12
+ var pos = direction === 'up' ? $pos.before() : $pos.after();
13
+ var $posResolved = $pos.doc.resolve(pos);
14
+ var maybeExpandNode = direction === 'up' ? $posResolved.nodeBefore : $posResolved.nodeAfter;
15
+
16
+ if (maybeExpandNode && isCollpasedExpand(maybeExpandNode)) {
17
+ var nodeSize = maybeExpandNode.nodeSize;
18
+ var expandPosition = direction === 'up' ? pos - nodeSize : pos + nodeSize;
19
+ var startPosNode = Math.max(expandPosition, 0);
20
+ var $startPosNode = $pos.doc.resolve(Math.min(startPosNode, $pos.doc.content.size));
21
+ return $startPosNode;
22
+ }
23
+
24
+ return null;
25
+ };
26
+
27
+ export var onKeydown = function onKeydown(view, event) {
28
+ /*
29
+ * This workaround is needed for some specific situation with collapsed expand.
30
+ *
31
+ * The way expand was built, no browser reconize selection on it.
32
+ * For instance, when a selection going to a "collapsed" expand
33
+ * the browser will try to send the cursor to inside the expand content (wrong),
34
+ * this behavior is caused because the expand content is never true hidden
35
+ * we just set the height to 1px.
36
+ *
37
+ * So, we need to capture a possible selection event
38
+ * when a collapsed exxpand is the next node in the common depth.
39
+ * If that is true, we create a new TextSelection and stop the event bubble
40
+ */
41
+ if (!(event instanceof KeyboardEvent)) {
42
+ return false;
43
+ }
44
+
45
+ if (!event.shiftKey || event.ctrlKey || event.metaKey) {
46
+ return false;
47
+ }
48
+
49
+ if (!['ArrowUp', 'ArrowDown', 'ArrowRight', 'ArrowLeft', 'Home', 'End'].includes(event.key)) {
50
+ return false;
51
+ }
52
+
53
+ var _view$state$selection = view.state.selection,
54
+ $head = _view$state$selection.$head,
55
+ $anchor = _view$state$selection.$anchor;
56
+
57
+ if (event.key === 'ArrowRight' && $head.nodeAfter || event.key === 'ArrowLeft' && $head.nodeBefore) {
58
+ return false;
59
+ }
60
+
61
+ var direction = ['ArrowLeft', 'ArrowUp', 'Home'].includes(event.key) ? 'up' : 'down';
62
+ var $fixedProblematicNodePosition = findFixedProblematicNodePosition($head, direction);
63
+
64
+ if ($fixedProblematicNodePosition) {
65
+ var forcedTextSelection = TextSelection.create(view.state.doc, $anchor.pos, $fixedProblematicNodePosition.pos);
66
+ var tr = view.state.tr;
67
+ tr.setSelection(forcedTextSelection);
68
+ view.dispatch(tr);
69
+ event.preventDefault();
70
+ return true;
71
+ }
72
+
73
+ return false;
74
+ };
@@ -4,35 +4,14 @@ import { SelectionActionTypes } from '../actions';
4
4
  import { createPluginState, getPluginState } from '../plugin-factory';
5
5
  import { selectionPluginKey } from '../types';
6
6
  import { getAllSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload, getDecorations, getNodeSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, shouldRecalcDecorations } from '../utils';
7
+ import { onKeydown } from './events/keydown';
8
+ import { onCreateSelectionBetween } from './events/create-selection-between';
7
9
  export var getInitialState = function getInitialState(state) {
8
10
  return {
9
11
  decorationSet: getDecorations(state.tr),
10
12
  selection: state.selection
11
13
  };
12
14
  };
13
-
14
- var toggleContentEditable = function toggleContentEditable(node) {
15
- var root = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
16
-
17
- if (root || node.getAttribute('contenteditable') === 'true') {
18
- var wasTrue = node.getAttribute('contenteditable') === 'true';
19
- node.setAttribute('contenteditable', 'false');
20
- requestAnimationFrame(function () {
21
- if (wasTrue) {
22
- node.setAttribute('contenteditable', 'true');
23
- } else {
24
- node.removeAttribute('contenteditable');
25
- }
26
- });
27
- } // any children with contenteditable = true block selection from proceeding
28
-
29
-
30
- var children = Array.from(node.children);
31
- children.forEach(function (child) {
32
- return toggleContentEditable(child);
33
- });
34
- };
35
-
36
15
  export var createPlugin = function createPlugin(dispatch, dispatchAnalyticsEvent) {
37
16
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
38
17
  return new SafePlugin({
@@ -96,10 +75,12 @@ export var createPlugin = function createPlugin(dispatch, dispatchAnalyticsEvent
96
75
  return true;
97
76
  },
98
77
  props: {
78
+ createSelectionBetween: onCreateSelectionBetween,
99
79
  decorations: function decorations(state) {
100
80
  return getPluginState(state).decorationSet;
101
81
  },
102
82
  handleDOMEvents: {
83
+ keydown: onKeydown,
103
84
  // We only want to fire analytics for a click and drag range/cell selection when
104
85
  // the user has finished, otherwise we will get an event almost every time they move
105
86
  // their mouse which is too much
@@ -114,40 +95,6 @@ export var createPlugin = function createPlugin(dispatch, dispatchAnalyticsEvent
114
95
  }
115
96
  }
116
97
 
117
- return false;
118
- },
119
- keydown: function keydown(editorView, event) {
120
- // Bugfix for block ReactNodeViews like table and extension
121
- // They could not be selected with Shift + ArrowDown/ArrowUp
122
- // Fixed when contenteditable = false, but then you couldn't edit their contents
123
- // Therefore, briefly set contenteditable=false to allow the selection through, then set it back to true
124
- if (event instanceof KeyboardEvent && event.shiftKey && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {
125
- var state = editorView.state; // If current depth is on the top most level, skip that
126
-
127
- if (state.selection.$head.depth <= 0) {
128
- return false;
129
- }
130
-
131
- var pos;
132
-
133
- if (event.key === 'ArrowDown') {
134
- pos = state.selection.$head.after();
135
- } else {
136
- pos = Math.max(state.selection.$head.before() - 1, 0); // block extensions only take up one position, dont need to get before()
137
-
138
- if (!editorView.nodeDOM(pos)) {
139
- pos = state.doc.resolve(pos).before();
140
- }
141
- }
142
-
143
- var node = editorView.nodeDOM(pos);
144
-
145
- if (node instanceof HTMLDivElement && node.className.includes('View-content-wrap') // class added by ReactNodeView
146
- ) {
147
- toggleContentEditable(node, true);
148
- }
149
- }
150
-
151
98
  return false;
152
99
  }
153
100
  }
@@ -203,7 +203,7 @@ export var ToolbarTextColor = /*#__PURE__*/function (_React$Component) {
203
203
  zIndex: akEditorMenuZIndex,
204
204
  fitWidth: fitWidth,
205
205
  onOpenChange: this.onOpenChange,
206
- closeonTab: true,
206
+ closeOnTab: true,
207
207
  trigger: jsx(ToolbarButton, {
208
208
  buttonId: TOOLBAR_BUTTON.TEXT_COLOR,
209
209
  spacing: isReducedSpacing ? 'none' : 'default',
@@ -26,9 +26,14 @@ export var FormattingTextDropdownMenu = /*#__PURE__*/React.memo(function (_ref)
26
26
  }];
27
27
  }, [items]);
28
28
  var onItemActivated = useCallback(function (_ref2) {
29
- var item = _ref2.item;
29
+ var item = _ref2.item,
30
+ _ref2$shouldCloseMenu = _ref2.shouldCloseMenu,
31
+ shouldCloseMenu = _ref2$shouldCloseMenu === void 0 ? true : _ref2$shouldCloseMenu;
30
32
  item.command(editorView.state, editorView.dispatch);
31
- closeMenu();
33
+
34
+ if (shouldCloseMenu) {
35
+ closeMenu();
36
+ }
32
37
  }, [editorView.state, editorView.dispatch, closeMenu]);
33
38
  return /*#__PURE__*/React.createElement(DropdownMenu, {
34
39
  mountTo: popupsMountPoint,
@@ -45,8 +45,10 @@ export function ToolbarDropdown(props) {
45
45
  var items = useItems(props);
46
46
 
47
47
  var handleOnItemActivated = function handleOnItemActivated(_ref) {
48
- var item = _ref.item;
49
- setIsDropdownOpen(false);
48
+ var item = _ref.item,
49
+ _ref$shouldCloseMenu = _ref.shouldCloseMenu,
50
+ shouldCloseMenu = _ref$shouldCloseMenu === void 0 ? true : _ref$shouldCloseMenu;
51
+ setIsDropdownOpen(!shouldCloseMenu);
50
52
  return onItemActivated({
51
53
  editorView: props.editorView,
52
54
  buttonName: item.value.name
@@ -1,70 +1,29 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
9
2
 
10
3
  var _templateObject;
11
4
 
12
- 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); }; }
13
-
14
- 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; } }
15
-
16
5
  /** @jsx jsx */
17
6
  import React from 'react';
18
7
  import { css, jsx } from '@emotion/react';
19
8
  import { clickAreaClickHandler } from '../click-area-helper';
20
9
  var clickWrapper = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n flex-grow: 1;\n height: 100%;\n"])));
21
-
22
- var ClickAreaBlock = /*#__PURE__*/function (_React$Component) {
23
- _inherits(ClickAreaBlock, _React$Component);
24
-
25
- var _super = _createSuper(ClickAreaBlock);
26
-
27
- function ClickAreaBlock() {
28
- var _this;
29
-
30
- _classCallCheck(this, ClickAreaBlock);
31
-
32
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
33
- args[_key] = arguments[_key];
10
+ export var ClickAreaBlock = function ClickAreaBlock(_ref) {
11
+ var editorView = _ref.editorView,
12
+ editorDisabled = _ref.editorDisabled,
13
+ children = _ref.children;
14
+ var handleMouseDown = React.useCallback(function (event) {
15
+ if (!editorView) {
16
+ return;
34
17
  }
35
18
 
36
- _this = _super.call.apply(_super, [this].concat(args));
37
-
38
- _defineProperty(_assertThisInitialized(_this), "handleClick", function (event) {
39
- var _this$props = _this.props,
40
- view = _this$props.editorView,
41
- editorDisabled = _this$props.editorDisabled;
42
-
43
- if (!view) {
44
- return;
45
- }
46
-
47
- if (!editorDisabled) {
48
- // if the editor is disabled -- we don't want to intercept any click events
49
- clickAreaClickHandler(view, event);
50
- }
51
- });
52
-
53
- return _this;
54
- }
55
-
56
- _createClass(ClickAreaBlock, [{
57
- key: "render",
58
- value: function render() {
59
- return jsx("div", {
60
- "data-testid": "click-wrapper",
61
- css: clickWrapper,
62
- onClick: this.handleClick
63
- }, this.props.children);
19
+ if (!editorDisabled) {
20
+ clickAreaClickHandler(editorView, event);
64
21
  }
65
- }]);
66
-
67
- return ClickAreaBlock;
68
- }(React.Component);
69
-
70
- export { ClickAreaBlock as default };
22
+ }, [editorView, editorDisabled]);
23
+ return jsx("div", {
24
+ "data-testid": "click-wrapper",
25
+ css: clickWrapper,
26
+ onMouseDown: handleMouseDown
27
+ }, children);
28
+ };
29
+ export default ClickAreaBlock;
@@ -1,65 +1,29 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
9
2
 
10
3
  var _templateObject;
11
4
 
12
- 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); }; }
13
-
14
- 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; } }
15
-
16
5
  /** @jsx jsx */
17
6
  import React from 'react';
18
7
  import { css, jsx } from '@emotion/react';
19
8
  import { createParagraphAtEnd } from '../../../commands';
20
9
  var clickArea = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n flex-grow: 1;\n"])));
21
-
22
- var ClickAreaInline = /*#__PURE__*/function (_React$Component) {
23
- _inherits(ClickAreaInline, _React$Component);
24
-
25
- var _super = _createSuper(ClickAreaInline);
26
-
27
- function ClickAreaInline() {
28
- var _this;
29
-
30
- _classCallCheck(this, ClickAreaInline);
31
-
32
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
33
- args[_key] = arguments[_key];
10
+ export var ClickAreaInline = function ClickAreaInline(_ref) {
11
+ var editorView = _ref.editorView,
12
+ children = _ref.children;
13
+ var handleMouseDown = React.useCallback(function (event) {
14
+ if (!editorView) {
15
+ return;
34
16
  }
35
17
 
36
- _this = _super.call.apply(_super, [this].concat(args));
37
-
38
- _defineProperty(_assertThisInitialized(_this), "handleClick", function (event) {
39
- var editorView = _this.props.editorView;
40
-
41
- if (editorView) {
42
- if (createParagraphAtEnd()(editorView.state, editorView.dispatch)) {
43
- editorView.focus();
44
- event.stopPropagation();
45
- }
46
- }
47
- });
48
-
49
- return _this;
50
- }
51
-
52
- _createClass(ClickAreaInline, [{
53
- key: "render",
54
- value: function render() {
55
- return jsx("div", {
56
- css: clickArea,
57
- onClick: this.handleClick
58
- });
18
+ if (createParagraphAtEnd()(editorView.state, editorView.dispatch)) {
19
+ editorView.focus();
20
+ event.stopPropagation();
59
21
  }
60
- }]);
61
-
62
- return ClickAreaInline;
63
- }(React.Component);
64
-
65
- export { ClickAreaInline as default };
22
+ }, [editorView]);
23
+ return jsx("div", {
24
+ "data-testid": "click-wrapper",
25
+ css: clickArea,
26
+ onMouseDown: handleMouseDown
27
+ });
28
+ };
29
+ export default ClickAreaInline;
@@ -13,6 +13,10 @@ var insideContentArea = function insideContentArea(ref) {
13
13
 
14
14
  return false;
15
15
  };
16
+
17
+ var insideProseMirrorEditableArea = function insideProseMirrorEditableArea(ref) {
18
+ return Boolean(ref === null || ref === void 0 ? void 0 : ref.closest('.ProseMirror'));
19
+ };
16
20
  /**
17
21
  * @see ED-14699 - check if editor is inside a modal to continue to bring cursor to input when
18
22
  * any part of the editor container is clicked
@@ -37,11 +41,19 @@ export var checkForModal = function checkForModal(target) {
37
41
  };
38
42
 
39
43
  var clickAreaClickHandler = function clickAreaClickHandler(view, event) {
40
- var _view$hasFocus;
44
+ var _view$hasFocus, _event$currentTarget;
41
45
 
42
- var isTargetContentArea = event.currentTarget.querySelector('.ak-editor-content-area');
43
46
  var isEditorFocused = !!(view !== null && view !== void 0 && (_view$hasFocus = view.hasFocus) !== null && _view$hasFocus !== void 0 && _view$hasFocus.call(view));
44
- var target = event.target; // @see https://product-fabric.atlassian.net/browse/ED-4287
47
+ var target = event.target;
48
+ var isTargetContentArea = target.classList.contains('ak-editor-content-area');
49
+ var isTargetChildOfContentArea = insideContentArea(target.parentNode);
50
+ var isTargetInsideEditableArea = insideProseMirrorEditableArea(target); // Any click inside ProseMirror should be managed by ProseMirror
51
+
52
+ if (isTargetInsideEditableArea) {
53
+ return false;
54
+ }
55
+
56
+ var isEventComingFromContentArea = Boolean(event.currentTarget.querySelector('.ak-editor-content-area')); // @see https://product-fabric.atlassian.net/browse/ED-4287
45
57
  // click event gets triggered twice on a checkbox (on <label> first and then on <input>)
46
58
  // by the time it gets triggered on input, PM already re-renders nodeView and detaches it from DOM
47
59
  // which doesn't pass the check !contentArea.contains(event.target)
@@ -52,10 +64,20 @@ var clickAreaClickHandler = function clickAreaClickHandler(view, event) {
52
64
 
53
65
  var isTextAreaClicked = target.nodeName === 'TEXTAREA';
54
66
  var isBreadcrumbClicked = !!closestElement(target, 'nav[aria-label="Breadcrumbs"]');
55
- var isTargetChildOfContentArea = insideContentArea(target.parentNode);
56
67
  var selection = window.getSelection();
57
- var isEditorPopupTextSelected = (selection === null || selection === void 0 ? void 0 : selection.type) === 'Range' && closestElement(selection === null || selection === void 0 ? void 0 : selection.anchorNode, '[data-editor-popup]');
58
- var isClickOutsideEditor = (!isTargetContentArea || !isTargetChildOfContentArea || !isEditorFocused) && !isInputClicked && !isTextAreaClicked && !isPopupClicked && !isBreadcrumbClicked && !isEditorPopupTextSelected && checkForModal(target); // click was within editor container and focus should be brought to input
68
+ var isEditorPopupTextSelected = (selection === null || selection === void 0 ? void 0 : selection.type) === 'Range' && closestElement(selection === null || selection === void 0 ? void 0 : selection.anchorNode, '[data-editor-popup]'); // This is a super workaround to find when events are coming from Confluence InlineComment modal
69
+ // We don't own those components, so we can't change them
70
+
71
+ var isEventComingFromInlineCommentPopup = Boolean(closestElement(event.currentTarget, 'div[offset]')) || Boolean(closestElement(target, 'div[offset]'));
72
+ var isButtonClicked = Boolean(closestElement(event.currentTarget, 'button')) || Boolean(closestElement(target, 'button')) || ((_event$currentTarget = event.currentTarget) === null || _event$currentTarget === void 0 ? void 0 : _event$currentTarget.nodeName) === 'BUTTON' || target.nodeName === 'BUTTON';
73
+ var isTargetInsideContentArea = Boolean(isTargetChildOfContentArea);
74
+ var isBetweenContentAreaAndEditableContent = isTargetInsideContentArea && !isTargetInsideEditableArea;
75
+ var edgeCaseScenario1 = (isBetweenContentAreaAndEditableContent || !isEventComingFromContentArea) && !isEditorFocused;
76
+ var edgeCaseScenario2 = !isTargetInsideContentArea && isEditorFocused;
77
+ var edgeCaseScenario3 = isTargetContentArea && !isTargetInsideContentArea && !isEditorFocused;
78
+ var edgeCaseScenario4 = isEventComingFromContentArea && !isTargetContentArea && !isTargetInsideContentArea && !isEditorFocused;
79
+ var edgeCases = edgeCaseScenario1 || edgeCaseScenario2 || edgeCaseScenario3 || edgeCaseScenario4;
80
+ var isClickOutsideEditor = edgeCases && !isEventComingFromInlineCommentPopup && !isButtonClicked && !isInputClicked && !isTextAreaClicked && !isPopupClicked && !isBreadcrumbClicked && !isEditorPopupTextSelected && checkForModal(target); // click was within editor container and focus should be brought to input
59
81
 
60
82
  if (isClickOutsideEditor && view) {
61
83
  outsideProsemirrorEditorClickHandler(view, event);
@@ -35,9 +35,11 @@ var AlignmentButton = /*#__PURE__*/function (_PureComponent) {
35
35
  _defineProperty(_assertThisInitialized(_this), "onClick", function (e) {
36
36
  var _this$props = _this.props,
37
37
  onClick = _this$props.onClick,
38
- value = _this$props.value;
38
+ value = _this$props.value; // detect if the click event comes from keyboard where screenX and screenY are 0
39
+
40
+ var isMouseEvent = e instanceof MouseEvent;
39
41
  e.preventDefault();
40
- onClick(value);
42
+ onClick(value, isMouseEvent);
41
43
  });
42
44
 
43
45
  return _this;