@atlaskit/editor-core 188.11.4 → 188.12.1

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 (116) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/labs/next/presets/universal.js +15 -3
  3. package/dist/cjs/plugins/annotation/index.js +12 -1
  4. package/dist/cjs/plugins/annotation/pm-plugins/inline-comment.js +2 -1
  5. package/dist/cjs/plugins/annotation/pm-plugins/plugin-factory.js +5 -0
  6. package/dist/cjs/plugins/annotation/pm-plugins/reducer.js +2 -1
  7. package/dist/cjs/plugins/annotation/toolbar.js +2 -156
  8. package/dist/cjs/plugins/index.js +0 -7
  9. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +33 -31
  10. package/dist/cjs/plugins/layout/actions.js +20 -17
  11. package/dist/cjs/plugins/layout/index.js +6 -2
  12. package/dist/cjs/plugins/panel/index.js +1 -1
  13. package/dist/cjs/plugins/panel/toolbar.js +9 -7
  14. package/dist/cjs/plugins/paste/pm-plugins/analytics.js +0 -6
  15. package/dist/cjs/plugins/rank.js +1 -1
  16. package/dist/cjs/plugins/tasks-and-decisions/index.js +1 -1
  17. package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/keymaps.js +104 -90
  18. package/dist/cjs/plugins/toolbar-lists-indentation/ui/onItemActivated.js +4 -2
  19. package/dist/cjs/plugins/undo-redo/index.js +7 -16
  20. package/dist/cjs/plugins/undo-redo/ui/ToolbarUndoRedo/index.js +59 -75
  21. package/dist/cjs/version-wrapper.js +1 -1
  22. package/dist/es2019/labs/next/presets/universal.js +14 -2
  23. package/dist/es2019/plugins/annotation/index.js +14 -1
  24. package/dist/es2019/plugins/annotation/pm-plugins/inline-comment.js +2 -1
  25. package/dist/es2019/plugins/annotation/pm-plugins/plugin-factory.js +6 -0
  26. package/dist/es2019/plugins/annotation/pm-plugins/reducer.js +2 -1
  27. package/dist/es2019/plugins/annotation/toolbar.js +1 -156
  28. package/dist/es2019/plugins/index.js +0 -1
  29. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -3
  30. package/dist/es2019/plugins/layout/actions.js +4 -3
  31. package/dist/es2019/plugins/layout/index.js +63 -57
  32. package/dist/es2019/plugins/panel/index.js +1 -1
  33. package/dist/es2019/plugins/panel/toolbar.js +9 -7
  34. package/dist/es2019/plugins/paste/pm-plugins/analytics.js +1 -4
  35. package/dist/es2019/plugins/rank.js +1 -1
  36. package/dist/es2019/plugins/tasks-and-decisions/index.js +1 -1
  37. package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/keymaps.js +22 -14
  38. package/dist/es2019/plugins/toolbar-lists-indentation/ui/onItemActivated.js +4 -2
  39. package/dist/es2019/plugins/undo-redo/index.js +6 -17
  40. package/dist/es2019/plugins/undo-redo/ui/ToolbarUndoRedo/index.js +60 -61
  41. package/dist/es2019/version-wrapper.js +1 -1
  42. package/dist/esm/labs/next/presets/universal.js +14 -2
  43. package/dist/esm/plugins/annotation/index.js +12 -1
  44. package/dist/esm/plugins/annotation/pm-plugins/inline-comment.js +2 -1
  45. package/dist/esm/plugins/annotation/pm-plugins/plugin-factory.js +5 -0
  46. package/dist/esm/plugins/annotation/pm-plugins/reducer.js +2 -1
  47. package/dist/esm/plugins/annotation/toolbar.js +1 -156
  48. package/dist/esm/plugins/index.js +0 -1
  49. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +33 -31
  50. package/dist/esm/plugins/layout/actions.js +15 -12
  51. package/dist/esm/plugins/layout/index.js +7 -3
  52. package/dist/esm/plugins/panel/index.js +1 -1
  53. package/dist/esm/plugins/panel/toolbar.js +9 -7
  54. package/dist/esm/plugins/paste/pm-plugins/analytics.js +1 -6
  55. package/dist/esm/plugins/rank.js +1 -1
  56. package/dist/esm/plugins/tasks-and-decisions/index.js +1 -1
  57. package/dist/esm/plugins/tasks-and-decisions/pm-plugins/keymaps.js +104 -90
  58. package/dist/esm/plugins/toolbar-lists-indentation/ui/onItemActivated.js +4 -2
  59. package/dist/esm/plugins/undo-redo/index.js +6 -16
  60. package/dist/esm/plugins/undo-redo/ui/ToolbarUndoRedo/index.js +56 -74
  61. package/dist/esm/version-wrapper.js +1 -1
  62. package/dist/types/plugins/annotation/pm-plugins/types.d.ts +1 -0
  63. package/dist/types/plugins/index.d.ts +0 -1
  64. package/dist/types/plugins/insert-block/types.d.ts +3 -1
  65. package/dist/types/plugins/layout/actions.d.ts +2 -1
  66. package/dist/types/plugins/layout/index.d.ts +4 -0
  67. package/dist/types/plugins/panel/index.d.ts +2 -2
  68. package/dist/types/plugins/panel/toolbar.d.ts +5 -3
  69. package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +0 -1
  70. package/dist/types/plugins/tasks-and-decisions/pm-plugins/keymaps.d.ts +7 -4
  71. package/dist/types/plugins/tasks-and-decisions/types.d.ts +5 -1
  72. package/dist/types/plugins/undo-redo/types.d.ts +2 -1
  73. package/dist/types/plugins/undo-redo/ui/ToolbarUndoRedo/index.d.ts +2 -6
  74. package/dist/types-ts4.5/plugins/annotation/pm-plugins/types.d.ts +1 -0
  75. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  76. package/dist/types-ts4.5/plugins/insert-block/types.d.ts +3 -1
  77. package/dist/types-ts4.5/plugins/layout/actions.d.ts +2 -1
  78. package/dist/types-ts4.5/plugins/layout/index.d.ts +4 -0
  79. package/dist/types-ts4.5/plugins/panel/index.d.ts +2 -2
  80. package/dist/types-ts4.5/plugins/panel/toolbar.d.ts +5 -3
  81. package/dist/types-ts4.5/plugins/paste/pm-plugins/analytics.d.ts +0 -1
  82. package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/keymaps.d.ts +7 -4
  83. package/dist/types-ts4.5/plugins/tasks-and-decisions/types.d.ts +3 -1
  84. package/dist/types-ts4.5/plugins/undo-redo/types.d.ts +3 -1
  85. package/dist/types-ts4.5/plugins/undo-redo/ui/ToolbarUndoRedo/index.d.ts +2 -6
  86. package/package.json +8 -3
  87. package/dist/cjs/plugins/history/actions.js +0 -10
  88. package/dist/cjs/plugins/history/index.js +0 -75
  89. package/dist/cjs/plugins/history/pm-history-types.js +0 -5
  90. package/dist/cjs/plugins/history/reducer.js +0 -18
  91. package/dist/cjs/plugins/history/types.js +0 -5
  92. package/dist/cjs/plugins/history/utils.js +0 -19
  93. package/dist/es2019/plugins/history/actions.js +0 -4
  94. package/dist/es2019/plugins/history/index.js +0 -61
  95. package/dist/es2019/plugins/history/pm-history-types.js +0 -1
  96. package/dist/es2019/plugins/history/reducer.js +0 -12
  97. package/dist/es2019/plugins/history/types.js +0 -1
  98. package/dist/es2019/plugins/history/utils.js +0 -11
  99. package/dist/esm/plugins/history/actions.js +0 -4
  100. package/dist/esm/plugins/history/index.js +0 -68
  101. package/dist/esm/plugins/history/pm-history-types.js +0 -1
  102. package/dist/esm/plugins/history/reducer.js +0 -12
  103. package/dist/esm/plugins/history/types.js +0 -1
  104. package/dist/esm/plugins/history/utils.js +0 -13
  105. package/dist/types/plugins/history/actions.d.ts +0 -8
  106. package/dist/types/plugins/history/index.d.ts +0 -13
  107. package/dist/types/plugins/history/pm-history-types.d.ts +0 -17
  108. package/dist/types/plugins/history/reducer.d.ts +0 -4
  109. package/dist/types/plugins/history/types.d.ts +0 -4
  110. package/dist/types/plugins/history/utils.d.ts +0 -4
  111. package/dist/types-ts4.5/plugins/history/actions.d.ts +0 -8
  112. package/dist/types-ts4.5/plugins/history/index.d.ts +0 -13
  113. package/dist/types-ts4.5/plugins/history/pm-history-types.d.ts +0 -17
  114. package/dist/types-ts4.5/plugins/history/reducer.d.ts +0 -4
  115. package/dist/types-ts4.5/plugins/history/types.d.ts +0 -4
  116. package/dist/types-ts4.5/plugins/history/utils.d.ts +0 -4
@@ -1,9 +1,9 @@
1
1
  /** @jsx jsx */
2
- import { PureComponent } from 'react';
3
2
  import { jsx } from '@emotion/react';
4
3
  import { injectIntl } from 'react-intl-next';
5
4
  import UndoIcon from '@atlaskit/icon/glyph/undo';
6
5
  import RedoIcon from '@atlaskit/icon/glyph/redo';
6
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
7
7
  import { undo as undoKeymap, redo as redoKeymap, ToolTipContent, tooltip } from '../../../../keymaps';
8
8
  import { separatorStyles, buttonGroupStyle } from '@atlaskit/editor-common/styles';
9
9
  import ToolbarButton, { TOOLBAR_BUTTON } from '../../../../ui/ToolbarButton';
@@ -31,65 +31,64 @@ const forceFocus = (editorView, api) => command => {
31
31
  editorView.focus();
32
32
  }
33
33
  };
34
- export class ToolbarUndoRedo extends PureComponent {
35
- render() {
36
- const {
37
- disabled,
38
- isReducedSpacing,
39
- historyState,
40
- editorView,
41
- api,
42
- intl: {
43
- formatMessage
44
- }
45
- } = this.props;
46
- const handleUndo = () => {
47
- forceFocus(editorView, api)(undoFromToolbar);
48
- };
49
- const handleRedo = () => {
50
- forceFocus(editorView, api)(redoFromToolbar);
51
- };
52
- const labelUndo = formatMessage(undoRedoMessages.undo);
53
- const labelRedo = formatMessage(undoRedoMessages.redo);
54
- const {
55
- canUndo,
56
- canRedo
57
- } = historyState;
58
- return jsx("span", {
59
- css: buttonGroupStyle
60
- }, jsx(ToolbarButton, {
61
- buttonId: TOOLBAR_BUTTON.UNDO,
62
- spacing: isReducedSpacing ? 'none' : 'default',
63
- onClick: handleUndo,
64
- disabled: !canUndo || disabled,
65
- "aria-label": tooltip(undoKeymap, labelUndo),
66
- "aria-keyshortcuts": getAriaKeyshortcuts(undoKeymap),
67
- title: jsx(ToolTipContent, {
68
- description: labelUndo,
69
- keymap: undoKeymap
70
- }),
71
- iconBefore: jsx(UndoIcon, {
72
- label: ""
73
- }),
74
- testId: "ak-editor-toolbar-button-undo"
75
- }), jsx(ToolbarButton, {
76
- spacing: isReducedSpacing ? 'none' : 'default',
77
- buttonId: TOOLBAR_BUTTON.REDO,
78
- onClick: handleRedo,
79
- disabled: !canRedo || disabled,
80
- title: jsx(ToolTipContent, {
81
- description: labelRedo,
82
- keymap: redoKeymap
83
- }),
84
- iconBefore: jsx(RedoIcon, {
85
- label: ""
86
- }),
87
- testId: "ak-editor-toolbar-button-redo",
88
- "aria-label": tooltip(redoKeymap, labelRedo),
89
- "aria-keyshortcuts": getAriaKeyshortcuts(redoKeymap)
90
- }), jsx("span", {
91
- css: separatorStyles
92
- }));
34
+ export const ToolbarUndoRedo = ({
35
+ disabled,
36
+ isReducedSpacing,
37
+ editorView,
38
+ api,
39
+ intl: {
40
+ formatMessage
93
41
  }
94
- }
42
+ }) => {
43
+ const {
44
+ historyState
45
+ } = useSharedPluginState(api, ['history']);
46
+ const handleUndo = () => {
47
+ forceFocus(editorView, api)(undoFromToolbar);
48
+ };
49
+ const handleRedo = () => {
50
+ forceFocus(editorView, api)(redoFromToolbar);
51
+ };
52
+ const labelUndo = formatMessage(undoRedoMessages.undo);
53
+ const labelRedo = formatMessage(undoRedoMessages.redo);
54
+ const {
55
+ canUndo,
56
+ canRedo
57
+ } = historyState !== null && historyState !== void 0 ? historyState : {};
58
+ return jsx("span", {
59
+ css: buttonGroupStyle
60
+ }, jsx(ToolbarButton, {
61
+ buttonId: TOOLBAR_BUTTON.UNDO,
62
+ spacing: isReducedSpacing ? 'none' : 'default',
63
+ onClick: handleUndo,
64
+ disabled: !canUndo || disabled,
65
+ "aria-label": tooltip(undoKeymap, labelUndo),
66
+ "aria-keyshortcuts": getAriaKeyshortcuts(undoKeymap),
67
+ title: jsx(ToolTipContent, {
68
+ description: labelUndo,
69
+ keymap: undoKeymap
70
+ }),
71
+ iconBefore: jsx(UndoIcon, {
72
+ label: ""
73
+ }),
74
+ testId: "ak-editor-toolbar-button-undo"
75
+ }), jsx(ToolbarButton, {
76
+ spacing: isReducedSpacing ? 'none' : 'default',
77
+ buttonId: TOOLBAR_BUTTON.REDO,
78
+ onClick: handleRedo,
79
+ disabled: !canRedo || disabled,
80
+ title: jsx(ToolTipContent, {
81
+ description: labelRedo,
82
+ keymap: redoKeymap
83
+ }),
84
+ iconBefore: jsx(RedoIcon, {
85
+ label: ""
86
+ }),
87
+ testId: "ak-editor-toolbar-button-redo",
88
+ "aria-label": tooltip(redoKeymap, labelRedo),
89
+ "aria-keyshortcuts": getAriaKeyshortcuts(redoKeymap)
90
+ }), jsx("span", {
91
+ css: separatorStyles
92
+ }));
93
+ };
95
94
  export default injectIntl(ToolbarUndoRedo);
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "188.11.4";
2
+ export const version = "188.12.1";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -2,7 +2,8 @@ import _typeof from "@babel/runtime/helpers/typeof";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
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
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 { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, extensionPlugin, fragmentMarkPlugin, insertBlockPlugin, jiraIssuePlugin, layoutPlugin, toolbarListsIndentationPlugin, macroPlugin, maxContentSizePlugin, panelPlugin, placeholderTextPlugin, tasksAndDecisionsPlugin, textColorPlugin, alignmentPlugin, indentationPlugin, customAutoformatPlugin, feedbackDialogPlugin, historyPlugin, expandPlugin, isExpandInsertionEnabled, mobileDimensionsPlugin, findReplacePlugin, mobileSelectionPlugin, annotationPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin } from '../../../plugins';
5
+ import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, extensionPlugin, fragmentMarkPlugin, insertBlockPlugin, jiraIssuePlugin, layoutPlugin, toolbarListsIndentationPlugin, macroPlugin, maxContentSizePlugin, panelPlugin, placeholderTextPlugin, tasksAndDecisionsPlugin, textColorPlugin, alignmentPlugin, indentationPlugin, customAutoformatPlugin, feedbackDialogPlugin, expandPlugin, isExpandInsertionEnabled, mobileDimensionsPlugin, findReplacePlugin, mobileSelectionPlugin, annotationPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin } from '../../../plugins';
6
+ import { historyPlugin } from '@atlaskit/editor-plugin-history';
6
7
  import { statusPlugin } from '@atlaskit/editor-plugin-status';
7
8
  import { datePlugin } from '@atlaskit/editor-plugin-date';
8
9
  import { captionPlugin } from '@atlaskit/editor-plugin-caption';
@@ -23,6 +24,7 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
23
24
  import { saveOnEnterPlugin } from '@atlaskit/editor-plugin-save-on-enter';
24
25
  import { scrollIntoViewPlugin } from '@atlaskit/editor-plugin-scroll-into-view';
25
26
  import { mentionsPlugin } from '@atlaskit/editor-plugin-mentions';
27
+ import { selectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-toolbar';
26
28
  import { isFullPage as fullPageCheck } from '../../../utils/is-full-page';
27
29
  import { getMediaFeatureFlag } from '@atlaskit/media-common';
28
30
  import { createDefaultPreset } from './default';
@@ -393,6 +395,16 @@ export default function createUniversalPreset(appearance, props, featureFlags, p
393
395
  return builder;
394
396
  }).add([codeBidiWarningPlugin, {
395
397
  appearance: appearance
396
- }]);
398
+ }])
399
+ /**
400
+ * Do not use this plugin - it is for AI purposes only.
401
+ */.maybeAdd(selectionToolbarPlugin, function (plugin, builder) {
402
+ if (getBooleanFF('platform.editor.enable-selection-toolbar_ucdwd')) {
403
+ return builder.add([plugin, {
404
+ preferenceToolbarAboveSelection: false
405
+ }]);
406
+ }
407
+ return builder;
408
+ });
397
409
  return finalPreset;
398
410
  }
@@ -7,6 +7,7 @@ import { getPluginState } from './utils';
7
7
  import { buildToolbar } from './toolbar';
8
8
  import { InlineCommentView } from './ui/InlineCommentView';
9
9
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
10
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
10
11
  var annotationPlugin = function annotationPlugin(_ref) {
11
12
  var annotationProviders = _ref.config,
12
13
  api = _ref.api;
@@ -53,7 +54,17 @@ var annotationPlugin = function annotationPlugin(_ref) {
53
54
  },
54
55
  pluginsOptions: {
55
56
  floatingToolbar: function floatingToolbar(state, intl) {
56
- if (!annotationProviders) {
57
+ if (getBooleanFF('platform.editor.enable-selection-toolbar_ucdwd') || !annotationProviders) {
58
+ return;
59
+ }
60
+ var pluginState = getPluginState(state);
61
+ if (pluginState && pluginState.isVisible && !pluginState.bookmark && !pluginState.mouseData.isSelecting) {
62
+ var isToolbarAbove = annotationProviders.inlineComment.isToolbarAbove;
63
+ return buildToolbar(state, intl, isToolbarAbove);
64
+ }
65
+ },
66
+ selectionToolbar: function selectionToolbar(state, intl) {
67
+ if (!getBooleanFF('platform.editor.enable-selection-toolbar_ucdwd') || !annotationProviders) {
57
68
  return;
58
69
  }
59
70
  var pluginState = getPluginState(state);
@@ -77,7 +77,8 @@ var initialState = function initialState() {
77
77
  isSelecting: false
78
78
  },
79
79
  disallowOnWhitespace: disallowOnWhitespace,
80
- isVisible: true
80
+ isVisible: true,
81
+ skipSelectionHandling: false
81
82
  };
82
83
  };
83
84
  var hideToolbar = function hideToolbar(state, dispatch) {
@@ -13,6 +13,11 @@ var handleDocChanged = function handleDocChanged(tr, prevPluginState) {
13
13
  });
14
14
  };
15
15
  var handleSelectionChanged = function handleSelectionChanged(tr, pluginState) {
16
+ if (pluginState.skipSelectionHandling) {
17
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
18
+ skipSelectionHandling: false
19
+ });
20
+ }
16
21
  var selectedAnnotations = findAnnotationsInSelection(tr.selection, tr.doc);
17
22
  var changed = selectedAnnotations.length !== pluginState.selectedAnnotations.length || selectedAnnotations.some(function (annotationInfo) {
18
23
  return !pluginState.selectedAnnotations.some(function (aInfo) {
@@ -43,7 +43,8 @@ export default (function (pluginState, action) {
43
43
  });
44
44
  case ACTIONS.SET_SELECTED_ANNOTATION:
45
45
  return _objectSpread(_objectSpread({}, pluginState), {}, {
46
- selectedAnnotations: _toConsumableArray(action.data.selectedAnnotations)
46
+ selectedAnnotations: _toConsumableArray(action.data.selectedAnnotations),
47
+ skipSelectionHandling: true
47
48
  });
48
49
  default:
49
50
  return pluginState;
@@ -1,166 +1,11 @@
1
1
  import React from 'react';
2
2
  import CommentIcon from '@atlaskit/icon/glyph/comment';
3
- // AFP-2532 TODO: Fix automatic suppressions below
4
- // eslint-disable-next-line @atlassian/tangerine/import/entry-points
5
3
  import { addInlineComment, ToolTipContent } from '../../keymaps';
6
4
  import { setInlineCommentDraftState } from './commands';
7
5
  import { AnnotationTestIds, AnnotationSelectionType } from './types';
8
6
  import { isSelectionValid } from './utils';
9
7
  import { annotationMessages } from '@atlaskit/editor-common/messages';
10
-
11
- /**
12
- * Returns the coordintes at the bottom the selection.
13
- */
14
- var getCoordsBelowSelection = function getCoordsBelowSelection(bottomCoords, toolbarRect) {
15
- return {
16
- top: (bottomCoords.top || 0) + toolbarRect.height / 1.15,
17
- left: bottomCoords.right - toolbarRect.width / 2
18
- };
19
- };
20
-
21
- /*
22
- Calculates the position of the floating toolbar relative to the selection.
23
-
24
- This is a re-implementation which closely matches the behaviour on Confluence renderer.
25
- The main difference is the popup is always above the selection.
26
-
27
- Things to consider:
28
- - popup is always above the selection
29
- - coordinates of head X and getBoundingClientRect() are absolute in client viewport (not including scroll offsets)
30
- - popup may appear in '.fabric-editor-popup-scroll-parent' (or body)
31
- - we use the toolbarRect to center align toolbar
32
- - use wrapperBounds to clamp values
33
- - editorView.dom bounds differ to wrapperBounds, convert at the end
34
- */
35
- var calculateToolbarPositionAboveSelection = function calculateToolbarPositionAboveSelection(toolbarTitle) {
36
- return function (editorView, nextPos) {
37
- var toolbar = document.querySelector("div[aria-label=\"".concat(toolbarTitle, "\"]"));
38
- if (!toolbar) {
39
- return nextPos;
40
- }
41
-
42
- // scroll wrapper for full page, fall back to document body
43
- // TODO: look into using getScrollGutterOptions()
44
- var scrollWrapper = editorView.dom.closest('.fabric-editor-popup-scroll-parent') || document.body;
45
- var wrapperBounds = scrollWrapper.getBoundingClientRect();
46
- var selection = window && window.getSelection();
47
- var range = selection && !selection.isCollapsed && selection.getRangeAt(0);
48
- if (!range) {
49
- return nextPos;
50
- }
51
- var toolbarRect = toolbar.getBoundingClientRect();
52
- var _editorView$state$sel = editorView.state.selection,
53
- head = _editorView$state$sel.head,
54
- anchor = _editorView$state$sel.anchor;
55
- var topCoords = editorView.coordsAtPos(Math.min(head, anchor));
56
- var bottomCoords = editorView.coordsAtPos(Math.max(head, anchor) - Math.min(range.endOffset, 1));
57
- var top = (topCoords.top || 0) - toolbarRect.height * 1.5;
58
- var left = 0;
59
-
60
- // If not on the same line
61
- if (topCoords.top !== bottomCoords.top) {
62
- // selecting downwards
63
- if (head > anchor) {
64
- left = Math.max(topCoords.right, bottomCoords.right);
65
- } else {
66
- left = Math.min(topCoords.left, bottomCoords.left);
67
- }
68
-
69
- /*
70
- short selection above a long paragraph
71
- eg. short {<}heading
72
- The purpose of this text is to show the selection range{>}.
73
- The horizontal positioning should center around "heading",
74
- not where it ends at "range".
75
- Note: if it was "head<b>ing</b>" then it would only center
76
- around "head". Undesireable but matches the current renderer.
77
- */
78
- var cliffPosition = range.getClientRects()[0];
79
- if (cliffPosition.right < left) {
80
- left = cliffPosition.left + cliffPosition.width / 2;
81
- }
82
- } else {
83
- // Otherwise center on the single line selection
84
- left = topCoords.left + (bottomCoords.right - topCoords.left) / 2;
85
- }
86
- left -= toolbarRect.width / 2;
87
-
88
- // Place toolbar below selection if not sufficient space above
89
- if (top < wrapperBounds.top) {
90
- var _getCoordsBelowSelect = getCoordsBelowSelection(bottomCoords, toolbarRect);
91
- top = _getCoordsBelowSelect.top;
92
- left = _getCoordsBelowSelect.left;
93
- }
94
-
95
- // remap positions from browser document to wrapperBounds
96
- return {
97
- top: top - wrapperBounds.top + scrollWrapper.scrollTop,
98
- left: Math.max(0, left - wrapperBounds.left)
99
- };
100
- };
101
- };
102
-
103
- /*
104
- Calculates the position of the floating toolbar relative to the selection.
105
-
106
- This is a re-implementation which closely matches the behaviour on Confluence renderer.
107
- The main difference is the popup is always above the selection.
108
-
109
- Things to consider:
110
- - stick as close to the head X release coordinates as possible
111
- - coordinates of head X and getBoundingClientRect() are absolute in client viewport (not including scroll offsets)
112
- - popup may appear in '.fabric-editor-popup-scroll-parent' (or body)
113
- - we use the toolbarRect to center align toolbar
114
- - use wrapperBounds to clamp values
115
- - editorView.dom bounds differ to wrapperBounds, convert at the end
116
- */
117
- var calculateToolbarPositionTrackHead = function calculateToolbarPositionTrackHead(toolbarTitle) {
118
- return function (editorView, nextPos) {
119
- var toolbar = document.querySelector("div[aria-label=\"".concat(toolbarTitle, "\"]"));
120
- if (!toolbar) {
121
- return nextPos;
122
- }
123
-
124
- // scroll wrapper for full page, fall back to document body
125
- // TODO: look into using getScrollGutterOptions()
126
- var scrollWrapper = editorView.dom.closest('.fabric-editor-popup-scroll-parent') || document.body;
127
- var wrapperBounds = scrollWrapper.getBoundingClientRect();
128
- var selection = window && window.getSelection();
129
- var range = selection && !selection.isCollapsed && selection.getRangeAt(0);
130
- if (!range) {
131
- return nextPos;
132
- }
133
- var toolbarRect = toolbar.getBoundingClientRect();
134
- var _editorView$state$sel2 = editorView.state.selection,
135
- head = _editorView$state$sel2.head,
136
- anchor = _editorView$state$sel2.anchor;
137
- var topCoords = editorView.coordsAtPos(Math.min(head, anchor));
138
- var bottomCoords = editorView.coordsAtPos(Math.max(head, anchor) - Math.min(range.endOffset, 1));
139
- var top;
140
- // If not the same line, display toolbar below.
141
- if (head > anchor && topCoords.top !== bottomCoords.top) {
142
- // We are taking the previous pos to the maxium, so avoid end of line positions
143
- // returning the next line's rect.
144
- top = (bottomCoords.top || 0) + toolbarRect.height / 1.15;
145
- } else {
146
- top = (topCoords.top || 0) - toolbarRect.height * 1.5;
147
- }
148
- var left = (head > anchor ? bottomCoords.right : topCoords.left) - toolbarRect.width / 2;
149
-
150
- // Place toolbar below selection if not sufficient space above
151
- if (top < wrapperBounds.top) {
152
- var _getCoordsBelowSelect2 = getCoordsBelowSelection(bottomCoords, toolbarRect);
153
- top = _getCoordsBelowSelect2.top;
154
- left = _getCoordsBelowSelect2.left;
155
- }
156
-
157
- // remap positions from browser document to wrapperBounds
158
- return {
159
- top: top - wrapperBounds.top + scrollWrapper.scrollTop,
160
- left: Math.max(0, left - wrapperBounds.left)
161
- };
162
- };
163
- };
8
+ import { calculateToolbarPositionAboveSelection, calculateToolbarPositionTrackHead } from '@atlaskit/editor-common/utils';
164
9
  export var buildToolbar = function buildToolbar(state, intl) {
165
10
  var isToolbarAbove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
166
11
  var schema = state.schema;
@@ -24,7 +24,6 @@ export { default as annotationPlugin } from './annotation';
24
24
  export { default as analyticsPlugin } from './analytics';
25
25
  export { default as customAutoformatPlugin } from './custom-autoformat';
26
26
  export { default as feedbackDialogPlugin } from './feedback-dialog';
27
- export { default as historyPlugin } from './history';
28
27
  export { default as expandPlugin, isExpandInsertionEnabled } from './expand';
29
28
  export { default as mobileDimensionsPlugin } from './mobile-dimensions';
30
29
  export { default as findReplacePlugin } from './find-replace';
@@ -21,7 +21,6 @@ import ToolbarButton from '../../../../ui/ToolbarButton';
21
21
  import { separatorStyles, buttonGroupStyle, wrapperStyle } from '@atlaskit/editor-common/styles';
22
22
  import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
23
23
  import { showPlaceholderFloatingToolbar } from '../../../placeholder-text/actions';
24
- import { insertLayoutColumnsWithAnalytics } from '../../../layout/actions';
25
24
  import { insertTaskDecisionCommand } from '../../../tasks-and-decisions/commands';
26
25
  import { insertExpand } from '../../../expand/commands';
27
26
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
@@ -210,21 +209,24 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
210
209
  return true;
211
210
  });
212
211
  _defineProperty(_assertThisInitialized(_this), "insertLayoutColumns", function (inputMethod) {
213
- var editorView = _this.props.editorView;
214
- insertLayoutColumnsWithAnalytics(inputMethod)(editorView.state, editorView.dispatch);
212
+ var _pluginInjectionApi$l;
213
+ var _this$props3 = _this.props,
214
+ editorView = _this$props3.editorView,
215
+ pluginInjectionApi = _this$props3.pluginInjectionApi;
216
+ pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$l = pluginInjectionApi.layout) === null || _pluginInjectionApi$l === void 0 || _pluginInjectionApi$l.actions.insertLayoutColumns(inputMethod)(editorView.state, editorView.dispatch);
215
217
  return true;
216
218
  });
217
219
  _defineProperty(_assertThisInitialized(_this), "createStatus", function (inputMethod) {
218
220
  var _pluginInjectionApi$s, _pluginInjectionApi$s2;
219
- var _this$props3 = _this.props,
220
- pluginInjectionApi = _this$props3.pluginInjectionApi,
221
- editorView = _this$props3.editorView;
221
+ var _this$props4 = _this.props,
222
+ pluginInjectionApi = _this$props4.pluginInjectionApi,
223
+ editorView = _this$props4.editorView;
222
224
  return (_pluginInjectionApi$s = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$s2 = pluginInjectionApi.status) === null || _pluginInjectionApi$s2 === void 0 || (_pluginInjectionApi$s2 = _pluginInjectionApi$s2.actions) === null || _pluginInjectionApi$s2 === void 0 ? void 0 : _pluginInjectionApi$s2.updateStatus(inputMethod)(editorView.state, editorView.dispatch)) !== null && _pluginInjectionApi$s !== void 0 ? _pluginInjectionApi$s : false;
223
225
  });
224
226
  _defineProperty(_assertThisInitialized(_this), "openMediaPicker", function (inputMethod) {
225
- var _this$props4 = _this.props,
226
- onShowMediaPicker = _this$props4.onShowMediaPicker,
227
- dispatchAnalyticsEvent = _this$props4.dispatchAnalyticsEvent;
227
+ var _this$props5 = _this.props,
228
+ onShowMediaPicker = _this$props5.onShowMediaPicker,
229
+ dispatchAnalyticsEvent = _this$props5.dispatchAnalyticsEvent;
228
230
  if (onShowMediaPicker) {
229
231
  onShowMediaPicker();
230
232
  if (dispatchAnalyticsEvent) {
@@ -252,11 +254,11 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
252
254
  });
253
255
  _defineProperty(_assertThisInitialized(_this), "insertHorizontalRule", function (inputMethod) {
254
256
  var _pluginInjectionApi$r, _pluginInjectionApi$r2;
255
- var _this$props5 = _this.props,
256
- _this$props5$editorVi = _this$props5.editorView,
257
- state = _this$props5$editorVi.state,
258
- dispatch = _this$props5$editorVi.dispatch,
259
- pluginInjectionApi = _this$props5.pluginInjectionApi;
257
+ var _this$props6 = _this.props,
258
+ _this$props6$editorVi = _this$props6.editorView,
259
+ state = _this$props6$editorVi.state,
260
+ dispatch = _this$props6$editorVi.dispatch,
261
+ pluginInjectionApi = _this$props6.pluginInjectionApi;
260
262
  return (_pluginInjectionApi$r = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$r2 = pluginInjectionApi.rule) === null || _pluginInjectionApi$r2 === void 0 ? void 0 : _pluginInjectionApi$r2.actions.insertHorizontalRule(inputMethod)(state, dispatch)) !== null && _pluginInjectionApi$r !== void 0 ? _pluginInjectionApi$r : false;
261
263
  });
262
264
  _defineProperty(_assertThisInitialized(_this), "insertExpand", function () {
@@ -267,9 +269,9 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
267
269
  });
268
270
  _defineProperty(_assertThisInitialized(_this), "insertBlockType", function (itemName) {
269
271
  return function () {
270
- var _this$props6 = _this.props,
271
- editorView = _this$props6.editorView,
272
- onInsertBlockType = _this$props6.onInsertBlockType;
272
+ var _this$props7 = _this.props,
273
+ editorView = _this$props7.editorView,
274
+ onInsertBlockType = _this$props7.onInsertBlockType;
273
275
  var state = editorView.state,
274
276
  dispatch = editorView.dispatch;
275
277
  onInsertBlockType(itemName)(state, dispatch);
@@ -292,11 +294,11 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
292
294
  _defineProperty(_assertThisInitialized(_this), "onItemActivated", function (_ref2) {
293
295
  var item = _ref2.item,
294
296
  inputMethod = _ref2.inputMethod;
295
- var _this$props7 = _this.props,
296
- editorView = _this$props7.editorView,
297
- editorActions = _this$props7.editorActions,
298
- handleImageUpload = _this$props7.handleImageUpload,
299
- expandEnabled = _this$props7.expandEnabled;
297
+ var _this$props8 = _this.props,
298
+ editorView = _this$props8.editorView,
299
+ editorActions = _this$props8.editorActions,
300
+ handleImageUpload = _this$props8.handleImageUpload,
301
+ expandEnabled = _this$props8.expandEnabled;
300
302
 
301
303
  // need to do this before inserting nodes so scrollIntoView works properly
302
304
  if (!editorView.hasFocus()) {
@@ -412,12 +414,12 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
412
414
  key: "renderPopup",
413
415
  value: function renderPopup() {
414
416
  var emojiPickerOpen = this.state.emojiPickerOpen;
415
- var _this$props8 = this.props,
416
- popupsMountPoint = _this$props8.popupsMountPoint,
417
- popupsBoundariesElement = _this$props8.popupsBoundariesElement,
418
- popupsScrollableElement = _this$props8.popupsScrollableElement,
419
- emojiProvider = _this$props8.emojiProvider,
420
- replacePlusMenuWithElementBrowser = _this$props8.replacePlusMenuWithElementBrowser;
417
+ var _this$props9 = this.props,
418
+ popupsMountPoint = _this$props9.popupsMountPoint,
419
+ popupsBoundariesElement = _this$props9.popupsBoundariesElement,
420
+ popupsScrollableElement = _this$props9.popupsScrollableElement,
421
+ emojiProvider = _this$props9.emojiProvider,
422
+ replacePlusMenuWithElementBrowser = _this$props9.replacePlusMenuWithElementBrowser;
421
423
  var dropdownEmoji = this.state.dropdownItems.some(function (_ref4) {
422
424
  var name = _ref4.value.name;
423
425
  return name === 'emoji';
@@ -454,9 +456,9 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
454
456
  buttons = _this$state.buttons,
455
457
  dropdownItems = _this$state.dropdownItems,
456
458
  emojiPickerOpen = _this$state.emojiPickerOpen;
457
- var _this$props9 = this.props,
458
- isDisabled = _this$props9.isDisabled,
459
- isReducedSpacing = _this$props9.isReducedSpacing;
459
+ var _this$props10 = this.props,
460
+ isDisabled = _this$props10.isDisabled,
461
+ isReducedSpacing = _this$props10.isReducedSpacing;
460
462
  if (buttons.length === 0 && dropdownItems.length === 0) {
461
463
  return null;
462
464
  }
@@ -6,8 +6,9 @@ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
6
6
  import { TextSelection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
7
7
  import { flatmap, mapChildren } from '../../utils/slice';
8
8
  import { getStepRange, isEmptyDocument } from '@atlaskit/editor-common/utils';
9
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../analytics/types/enums';
10
- import { addAnalytics, withAnalytics } from '../analytics/utils';
9
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
10
+ import { addAnalytics } from '../analytics/utils';
11
+ import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
11
12
  import { LAYOUT_TYPE } from '../analytics/types/node-events';
12
13
  import { pluginKey } from './pm-plugins/plugin-key';
13
14
  export var ONE_COL_LAYOUTS = ['single'];
@@ -79,16 +80,18 @@ export var insertLayoutColumns = function insertLayoutColumns(state, dispatch) {
79
80
  }
80
81
  return true;
81
82
  };
82
- export var insertLayoutColumnsWithAnalytics = function insertLayoutColumnsWithAnalytics(inputMethod) {
83
- return withAnalytics({
84
- action: ACTION.INSERTED,
85
- actionSubject: ACTION_SUBJECT.DOCUMENT,
86
- actionSubjectId: ACTION_SUBJECT_ID.LAYOUT,
87
- attributes: {
88
- inputMethod: inputMethod
89
- },
90
- eventType: EVENT_TYPE.TRACK
91
- })(insertLayoutColumns);
83
+ export var insertLayoutColumnsWithAnalytics = function insertLayoutColumnsWithAnalytics(editorAnalyticsAPI) {
84
+ return function (inputMethod) {
85
+ return withAnalytics(editorAnalyticsAPI, {
86
+ action: ACTION.INSERTED,
87
+ actionSubject: ACTION_SUBJECT.DOCUMENT,
88
+ actionSubjectId: ACTION_SUBJECT_ID.LAYOUT,
89
+ attributes: {
90
+ inputMethod: inputMethod
91
+ },
92
+ eventType: EVENT_TYPE.TRACK
93
+ })(insertLayoutColumns);
94
+ };
92
95
  };
93
96
 
94
97
  /**
@@ -2,13 +2,14 @@ import React from 'react';
2
2
  import { layoutColumn, layoutSection } from '@atlaskit/adf-schema';
3
3
  import { default as createLayoutPlugin } from './pm-plugins/main';
4
4
  import { buildToolbar } from './toolbar';
5
- import { createDefaultLayoutSection } from './actions';
5
+ import { createDefaultLayoutSection, insertLayoutColumnsWithAnalytics } from './actions';
6
6
  import { IconLayout } from '@atlaskit/editor-common/quick-insert';
7
7
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
8
8
  import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
9
9
  import { pluginKey } from './pm-plugins/plugin-key';
10
10
  export { pluginKey };
11
11
  var layoutPlugin = function layoutPlugin(_ref) {
12
+ var _api$analytics;
12
13
  var _ref$config = _ref.config,
13
14
  options = _ref$config === void 0 ? {} : _ref$config,
14
15
  api = _ref.api;
@@ -31,6 +32,9 @@ var layoutPlugin = function layoutPlugin(_ref) {
31
32
  }
32
33
  }];
33
34
  },
35
+ actions: {
36
+ insertLayoutColumns: insertLayoutColumnsWithAnalytics(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
37
+ },
34
38
  pluginsOptions: {
35
39
  floatingToolbar: function floatingToolbar(state, intl) {
36
40
  var _ref2 = pluginKey.getState(state),
@@ -56,9 +60,9 @@ var layoutPlugin = function layoutPlugin(_ref) {
56
60
  return /*#__PURE__*/React.createElement(IconLayout, null);
57
61
  },
58
62
  action: function action(insert, state) {
59
- var _api$analytics;
63
+ var _api$analytics2;
60
64
  var tr = insert(createDefaultLayoutSection(state));
61
- api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.attachAnalyticsEvent({
65
+ api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || (_api$analytics2 = _api$analytics2.actions) === null || _api$analytics2 === void 0 || _api$analytics2.attachAnalyticsEvent({
62
66
  action: ACTION.INSERTED,
63
67
  actionSubject: ACTION_SUBJECT.DOCUMENT,
64
68
  actionSubjectId: ACTION_SUBJECT_ID.LAYOUT,
@@ -158,7 +158,7 @@ var panelPlugin = function panelPlugin(_ref) {
158
158
  return quickInsertOptions;
159
159
  },
160
160
  floatingToolbar: function floatingToolbar(state, intl, providerFactory) {
161
- return getToolbarConfig(state, intl, options, providerFactory, api === null || api === void 0 ? void 0 : api.decorations.actions.hoverDecoration);
161
+ return getToolbarConfig(state, intl, options, providerFactory, api);
162
162
  }
163
163
  }
164
164
  };