@atlaskit/editor-core 189.1.15 → 189.3.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 (82) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/composable-editor/editor-internal.js +24 -2
  3. package/dist/cjs/create-editor/feature-flags-from-props.js +4 -5
  4. package/dist/cjs/plugins/index.js +0 -7
  5. package/dist/cjs/presets/universal.js +11 -6
  6. package/dist/cjs/ui/Appearance/FullPage/FullPage.js +2 -1
  7. package/dist/cjs/ui/Appearance/FullPage/FullPageToolbar.js +19 -12
  8. package/dist/cjs/version-wrapper.js +1 -1
  9. package/dist/es2019/composable-editor/editor-internal.js +27 -3
  10. package/dist/es2019/create-editor/feature-flags-from-props.js +4 -5
  11. package/dist/es2019/plugins/index.js +0 -1
  12. package/dist/es2019/presets/universal.js +11 -6
  13. package/dist/es2019/ui/Appearance/FullPage/FullPage.js +2 -1
  14. package/dist/es2019/ui/Appearance/FullPage/FullPageToolbar.js +35 -30
  15. package/dist/es2019/version-wrapper.js +1 -1
  16. package/dist/esm/composable-editor/editor-internal.js +25 -3
  17. package/dist/esm/create-editor/feature-flags-from-props.js +4 -5
  18. package/dist/esm/plugins/index.js +0 -1
  19. package/dist/esm/presets/universal.js +11 -6
  20. package/dist/esm/ui/Appearance/FullPage/FullPage.js +2 -1
  21. package/dist/esm/ui/Appearance/FullPage/FullPageToolbar.js +19 -12
  22. package/dist/esm/version-wrapper.js +1 -1
  23. package/dist/types/create-editor/get-ui-component.d.ts +1 -1
  24. package/dist/types/plugins/index.d.ts +0 -1
  25. package/dist/types/plugins/insert-block/types.d.ts +1 -1
  26. package/dist/types/types/editor-appearance-component.d.ts +1 -0
  27. package/dist/types/types/editor-props.d.ts +2 -1
  28. package/dist/types/ui/Appearance/FullPage/FullPageToolbar.d.ts +2 -1
  29. package/dist/types-ts4.5/create-editor/get-ui-component.d.ts +1 -1
  30. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  31. package/dist/types-ts4.5/plugins/insert-block/types.d.ts +1 -1
  32. package/dist/types-ts4.5/types/editor-appearance-component.d.ts +1 -0
  33. package/dist/types-ts4.5/types/editor-props.d.ts +2 -1
  34. package/dist/types-ts4.5/ui/Appearance/FullPage/FullPageToolbar.d.ts +2 -1
  35. package/package.json +5 -7
  36. package/report.api.md +3 -8
  37. package/tmp/api-report-tmp.d.ts +3 -8
  38. package/dist/cjs/plugins/panel/actions.js +0 -125
  39. package/dist/cjs/plugins/panel/index.js +0 -215
  40. package/dist/cjs/plugins/panel/message.js +0 -44
  41. package/dist/cjs/plugins/panel/nodeviews/panel.js +0 -94
  42. package/dist/cjs/plugins/panel/pm-plugins/keymaps.js +0 -81
  43. package/dist/cjs/plugins/panel/pm-plugins/main.js +0 -28
  44. package/dist/cjs/plugins/panel/toolbar.js +0 -293
  45. package/dist/cjs/plugins/panel/types.js +0 -8
  46. package/dist/cjs/plugins/panel/utils.js +0 -53
  47. package/dist/es2019/plugins/panel/actions.js +0 -116
  48. package/dist/es2019/plugins/panel/index.js +0 -192
  49. package/dist/es2019/plugins/panel/message.js +0 -38
  50. package/dist/es2019/plugins/panel/nodeviews/panel.js +0 -82
  51. package/dist/es2019/plugins/panel/pm-plugins/keymaps.js +0 -82
  52. package/dist/es2019/plugins/panel/pm-plugins/main.js +0 -21
  53. package/dist/es2019/plugins/panel/toolbar.js +0 -279
  54. package/dist/es2019/plugins/panel/types.js +0 -2
  55. package/dist/es2019/plugins/panel/utils.js +0 -48
  56. package/dist/esm/plugins/panel/actions.js +0 -116
  57. package/dist/esm/plugins/panel/index.js +0 -209
  58. package/dist/esm/plugins/panel/message.js +0 -38
  59. package/dist/esm/plugins/panel/nodeviews/panel.js +0 -87
  60. package/dist/esm/plugins/panel/pm-plugins/keymaps.js +0 -74
  61. package/dist/esm/plugins/panel/pm-plugins/main.js +0 -22
  62. package/dist/esm/plugins/panel/toolbar.js +0 -286
  63. package/dist/esm/plugins/panel/types.js +0 -2
  64. package/dist/esm/plugins/panel/utils.js +0 -46
  65. package/dist/types/plugins/panel/actions.d.ts +0 -12
  66. package/dist/types/plugins/panel/index.d.ts +0 -17
  67. package/dist/types/plugins/panel/message.d.ts +0 -37
  68. package/dist/types/plugins/panel/nodeviews/panel.d.ts +0 -36
  69. package/dist/types/plugins/panel/pm-plugins/keymaps.d.ts +0 -3
  70. package/dist/types/plugins/panel/pm-plugins/main.d.ts +0 -11
  71. package/dist/types/plugins/panel/toolbar.d.ts +0 -15
  72. package/dist/types/plugins/panel/types.d.ts +0 -21
  73. package/dist/types/plugins/panel/utils.d.ts +0 -5
  74. package/dist/types-ts4.5/plugins/panel/actions.d.ts +0 -12
  75. package/dist/types-ts4.5/plugins/panel/index.d.ts +0 -17
  76. package/dist/types-ts4.5/plugins/panel/message.d.ts +0 -37
  77. package/dist/types-ts4.5/plugins/panel/nodeviews/panel.d.ts +0 -36
  78. package/dist/types-ts4.5/plugins/panel/pm-plugins/keymaps.d.ts +0 -3
  79. package/dist/types-ts4.5/plugins/panel/pm-plugins/main.d.ts +0 -11
  80. package/dist/types-ts4.5/plugins/panel/toolbar.d.ts +0 -15
  81. package/dist/types-ts4.5/plugins/panel/types.d.ts +0 -21
  82. package/dist/types-ts4.5/plugins/panel/utils.d.ts +0 -5
@@ -1,8 +1,9 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
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; }
3
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; }
4
5
  /** @jsx jsx */
5
- import { Fragment } from 'react';
6
+ import { Fragment, useCallback } from 'react';
6
7
  import { css, jsx } from '@emotion/react';
7
8
  import { ACTION, ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
8
9
  import { PortalProviderWithThemeProviders, PortalRenderer } from '@atlaskit/editor-common/portal-provider';
@@ -68,7 +69,7 @@ export function EditorInternal(_ref) {
68
69
  onAnalyticsEvent: handleAnalyticsEvent,
69
70
  useAnalyticsContext: props.UNSAFE_useAnalyticsContext,
70
71
  render: function render(portalProviderAPI) {
71
- return jsx(Fragment, null, jsx(ReactEditorView, {
72
+ return jsx(Fragment, null, jsx(ReactEditorViewContextWrapper, {
72
73
  editorProps: overriddenEditorProps,
73
74
  createAnalyticsEvent: createAnalyticsEvent,
74
75
  portalProviderAPI: portalProviderAPI,
@@ -118,7 +119,8 @@ export function EditorInternal(_ref) {
118
119
  enableToolbarMinWidth: ((_props$featureFlags = props.featureFlags) === null || _props$featureFlags === void 0 ? void 0 : _props$featureFlags.toolbarMinWidthOverflow) != null ? !!((_props$featureFlags2 = props.featureFlags) !== null && _props$featureFlags2 !== void 0 && _props$featureFlags2.toolbarMinWidthOverflow) : props.allowUndoRedoButtons,
119
120
  useStickyToolbar: props.useStickyToolbar,
120
121
  featureFlags: featureFlags,
121
- pluginHooks: config.pluginHooks
122
+ pluginHooks: config.pluginHooks,
123
+ hideAvatarGroup: props.hideAvatarGroup
122
124
  }));
123
125
  }
124
126
  }), jsx(PortalRenderer, {
@@ -126,4 +128,24 @@ export function EditorInternal(_ref) {
126
128
  }));
127
129
  }
128
130
  }))))));
131
+ }
132
+ function ReactEditorViewContextWrapper(props) {
133
+ var setInternalEditorAPI = useSetPresetContext();
134
+ var setExternalEditorAPI = props.setEditorApi;
135
+
136
+ /**
137
+ * We use the context to retrieve the editorAPI
138
+ * externally for consumers via `usePreset`.
139
+ *
140
+ * However we also may need to retrieve this value internally via context
141
+ * so we should also set the value for the `EditorContext` that is used in
142
+ * `EditorInternal`.
143
+ */
144
+ var setEditorAPI = useCallback(function (api) {
145
+ setInternalEditorAPI === null || setInternalEditorAPI === void 0 || setInternalEditorAPI(api);
146
+ setExternalEditorAPI === null || setExternalEditorAPI === void 0 || setExternalEditorAPI(api);
147
+ }, [setInternalEditorAPI, setExternalEditorAPI]);
148
+ return jsx(ReactEditorView, _extends({}, props, {
149
+ setEditorApi: setEditorAPI
150
+ }));
129
151
  }
@@ -25,7 +25,7 @@ function getSpellCheck(featureFlags) {
25
25
  * which is used by both current and archv3 editors.
26
26
  */
27
27
  export function createFeatureFlagsFromProps(props) {
28
- var _props$allowLayouts, _props$performanceTra, _props$allowExtension, _props$featureFlags, _props$featureFlags2, _props$featureFlags3, _props$featureFlags4, _props$featureFlags5, _props$featureFlags6, _props$featureFlags7, _props$featureFlags8, _props$featureFlags9, _props$featureFlags10, _props$featureFlags11, _props$featureFlags12, _props$featureFlags13, _props$featureFlags14, _props$collabEdit, _props$collabEdit2, _props$featureFlags15, _props$featureFlags16, _props$featureFlags17, _props$featureFlags18, _props$featureFlags19, _props$featureFlags20, _props$featureFlags21, _props$featureFlags22;
28
+ var _props$allowLayouts, _props$performanceTra, _props$allowExtension, _props$featureFlags, _props$featureFlags2, _props$featureFlags3, _props$featureFlags4, _props$featureFlags5, _props$featureFlags6, _props$featureFlags7, _props$featureFlags8, _props$featureFlags9, _props$featureFlags10, _props$featureFlags11, _props$featureFlags12, _props$featureFlags13, _props$featureFlags14, _props$collabEdit, _props$collabEdit2, _props$featureFlags15, _props$featureFlags16, _props$featureFlags17, _props$featureFlags18, _props$featureFlags19, _props$featureFlags20;
29
29
  var normalizedFeatureFlags = normalizeFeatureFlags(props.featureFlags);
30
30
  return _objectSpread(_objectSpread({}, normalizedFeatureFlags), {}, {
31
31
  newInsertionBehaviour: props.allowNewInsertionBehaviour,
@@ -47,13 +47,12 @@ export function createFeatureFlagsFromProps(props) {
47
47
  twoLineEditorToolbar: Boolean(typeof ((_props$featureFlags13 = props.featureFlags) === null || _props$featureFlags13 === void 0 ? void 0 : _props$featureFlags13.twoLineEditorToolbar) === 'boolean' ? !!((_props$featureFlags14 = props.featureFlags) !== null && _props$featureFlags14 !== void 0 && _props$featureFlags14.twoLineEditorToolbar) : false),
48
48
  useNativeCollabPlugin: Boolean(typeof ((_props$collabEdit = props.collabEdit) === null || _props$collabEdit === void 0 ? void 0 : _props$collabEdit.useNativePlugin) === 'boolean' ? !!((_props$collabEdit2 = props.collabEdit) !== null && _props$collabEdit2 !== void 0 && _props$collabEdit2.useNativePlugin) : false),
49
49
  showHoverPreview: Boolean(typeof ((_props$featureFlags15 = props.featureFlags) === null || _props$featureFlags15 === void 0 ? void 0 : _props$featureFlags15.showHoverPreview) === 'boolean' ? !!((_props$featureFlags16 = props.featureFlags) !== null && _props$featureFlags16 !== void 0 && _props$featureFlags16.showHoverPreview) : false),
50
- indentationButtonsInTheToolbar: typeof props.showIndentationButtons === 'boolean' ? props.showIndentationButtons : Boolean(typeof normalizedFeatureFlags.indentationButtonsInTheToolbar === 'boolean' && !!normalizedFeatureFlags.indentationButtonsInTheToolbar || (typeof ((_props$featureFlags17 = props.featureFlags) === null || _props$featureFlags17 === void 0 ? void 0 : _props$featureFlags17.indentationButtonsInTheToolbar) === 'boolean' ? !!((_props$featureFlags18 = props.featureFlags) !== null && _props$featureFlags18 !== void 0 && _props$featureFlags18.indentationButtonsInTheToolbar) : false)),
51
- floatingToolbarLinkSettingsButton: typeof ((_props$featureFlags19 = props.featureFlags) === null || _props$featureFlags19 === void 0 ? void 0 : _props$featureFlags19['floating-toolbar-link-settings-button']) === 'string' ? props.featureFlags['floating-toolbar-link-settings-button'] || undefined : undefined,
50
+ floatingToolbarLinkSettingsButton: typeof ((_props$featureFlags17 = props.featureFlags) === null || _props$featureFlags17 === void 0 ? void 0 : _props$featureFlags17['floating-toolbar-link-settings-button']) === 'string' ? props.featureFlags['floating-toolbar-link-settings-button'] || undefined : undefined,
52
51
  disableSpellcheckByBrowser: getSpellCheck(props.featureFlags),
53
52
  // Including fallback to props.featureFlags so that mobile feature flags
54
53
  // are included (they are not kebab cased)
55
- restartNumberedLists: normalizedFeatureFlags.restartNumberedLists === true || ((_props$featureFlags20 = props.featureFlags) === null || _props$featureFlags20 === void 0 ? void 0 : _props$featureFlags20.restartNumberedLists) === true,
54
+ restartNumberedLists: normalizedFeatureFlags.restartNumberedLists === true || ((_props$featureFlags18 = props.featureFlags) === null || _props$featureFlags18 === void 0 ? void 0 : _props$featureFlags18.restartNumberedLists) === true,
56
55
  lpLinkPickerFocusTrap: Boolean(normalizedFeatureFlags.lpLinkPickerFocusTrap),
57
- preventPopupOverflow: Boolean(typeof ((_props$featureFlags21 = props.featureFlags) === null || _props$featureFlags21 === void 0 ? void 0 : _props$featureFlags21['prevent-popup-overflow']) === 'boolean' ? !!((_props$featureFlags22 = props.featureFlags) !== null && _props$featureFlags22 !== void 0 && _props$featureFlags22['prevent-popup-overflow']) : false)
56
+ preventPopupOverflow: Boolean(typeof ((_props$featureFlags19 = props.featureFlags) === null || _props$featureFlags19 === void 0 ? void 0 : _props$featureFlags19['prevent-popup-overflow']) === 'boolean' ? !!((_props$featureFlags20 = props.featureFlags) !== null && _props$featureFlags20 !== void 0 && _props$featureFlags20['prevent-popup-overflow']) : false)
58
57
  });
59
58
  }
@@ -7,7 +7,6 @@ export { default as jiraIssuePlugin } from './jira-issue';
7
7
  export { default as toolbarListsIndentationPlugin } from './toolbar-lists-indentation';
8
8
  export { default as macroPlugin } from './macro';
9
9
  export { default as maxContentSizePlugin } from './max-content-size';
10
- export { default as panelPlugin } from './panel';
11
10
  export { default as pastePlugin } from './paste';
12
11
  export { default as tasksAndDecisionsPlugin } from './tasks-and-decisions';
13
12
  export { default as breakoutPlugin } from './breakout';
@@ -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, insertBlockPlugin, jiraIssuePlugin, toolbarListsIndentationPlugin, macroPlugin, maxContentSizePlugin, panelPlugin, tasksAndDecisionsPlugin, alignmentPlugin, indentationPlugin, customAutoformatPlugin, feedbackDialogPlugin, expandPlugin, isExpandInsertionEnabled, mobileDimensionsPlugin, findReplacePlugin, mobileSelectionPlugin, annotationPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin } from '../plugins';
5
+ import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, extensionPlugin, insertBlockPlugin, jiraIssuePlugin, toolbarListsIndentationPlugin, macroPlugin, maxContentSizePlugin, tasksAndDecisionsPlugin, alignmentPlugin, indentationPlugin, customAutoformatPlugin, feedbackDialogPlugin, expandPlugin, isExpandInsertionEnabled, mobileDimensionsPlugin, findReplacePlugin, mobileSelectionPlugin, annotationPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin } from '../plugins';
6
+ import { panelPlugin } from '@atlaskit/editor-plugin-panel';
6
7
  import { textColorPlugin } from '@atlaskit/editor-plugin-text-color';
7
8
  import { historyPlugin } from '@atlaskit/editor-plugin-history';
8
9
  import { statusPlugin } from '@atlaskit/editor-plugin-status';
@@ -349,7 +350,7 @@ export default function createUniversalPreset(appearance, props, featureFlags, p
349
350
  }
350
351
  return builder;
351
352
  }).add([toolbarListsIndentationPlugin, {
352
- showIndentationButtons: !!featureFlags.indentationButtonsInTheToolbar,
353
+ showIndentationButtons: !!props.showIndentationButtons,
353
354
  allowHeadingAndParagraphIndentation: !!props.allowIndentation
354
355
  }]).add([insertBlockPlugin, {
355
356
  allowTables: !!props.allowTables,
@@ -360,14 +361,18 @@ export default function createUniversalPreset(appearance, props, featureFlags, p
360
361
  showElementBrowserLink: props.elementBrowser && props.elementBrowser.showModal || false,
361
362
  replacePlusMenuWithElementBrowser: props.elementBrowser && props.elementBrowser.replacePlusMenu || false
362
363
  }]).maybeAdd(beforePrimaryToolbarPlugin, function (plugin, builder) {
363
- if (!getBooleanFF('platform.confluence.frontend.editor.no.platform.avatar.group') && hasBeforePrimaryToolbar(props.primaryToolbarComponents) && !featureFlags.twoLineEditorToolbar) {
364
+ if (hasBeforePrimaryToolbar(props.primaryToolbarComponents) && !featureFlags.twoLineEditorToolbar) {
364
365
  return builder.add([plugin, {
365
366
  beforePrimaryToolbarComponents: props.primaryToolbarComponents.before
366
367
  }]);
367
368
  }
368
369
  return builder;
369
370
  }).maybeAdd(avatarGroupPlugin, function (plugin, builder) {
370
- if (!getBooleanFF('platform.confluence.frontend.editor.no.platform.avatar.group') && featureFlags.showAvatarGroupAsPlugin === true && !featureFlags.twoLineEditorToolbar) {
371
+ if (!props.hideAvatarGroup && featureFlags.showAvatarGroupAsPlugin === true && !featureFlags.twoLineEditorToolbar) {
372
+ // Avatars are moved to Confluence codebase for Edit in Context
373
+ // When Edit in Context is enabled primaryToolbarComponents is undefined
374
+ // For more details please check
375
+ // https://hello.atlassian.net/wiki/spaces/PCG/pages/2851572180/Editor+toolbar+for+live+pages+and+edit+in+context+projects
371
376
  return builder.add([plugin, {
372
377
  collabEdit: props.collabEdit,
373
378
  takeFullWidth: !hasBeforePrimaryToolbar(props.primaryToolbarComponents)
@@ -377,8 +382,8 @@ export default function createUniversalPreset(appearance, props, featureFlags, p
377
382
  }).maybeAdd(findReplacePlugin, function (plugin, builder) {
378
383
  if (props.allowFindReplace) {
379
384
  return builder.add([plugin, {
380
- takeFullWidth: !getBooleanFF('platform.confluence.frontend.editor.no.platform.avatar.group') && !!featureFlags.showAvatarGroupAsPlugin === false && !hasBeforePrimaryToolbar(props.primaryToolbarComponents),
381
- twoLineEditorToolbar: !!featureFlags.twoLineEditorToolbar
385
+ takeFullWidth: !props.hideAvatarGroup && !!featureFlags.showAvatarGroupAsPlugin === false && !hasBeforePrimaryToolbar(props.primaryToolbarComponents),
386
+ twoLineEditorToolbar: !!props.primaryToolbarComponents && !!featureFlags.twoLineEditorToolbar
382
387
  }]);
383
388
  }
384
389
  return builder;
@@ -66,7 +66,8 @@ export var FullPageEditor = function FullPageEditor(props) {
66
66
  primaryToolbarComponents: props.primaryToolbarComponents,
67
67
  providerFactory: props.providerFactory,
68
68
  showKeyline: showKeyline,
69
- featureFlags: props.featureFlags
69
+ featureFlags: props.featureFlags,
70
+ hideAvatarGroup: props.hideAvatarGroup
70
71
  }), jsx(FullPageContentArea, {
71
72
  ref: scrollContentContainerRef,
72
73
  appearance: props.appearance,
@@ -12,13 +12,17 @@ import { mainToolbarStyle, mainToolbarIconBeforeStyle, mainToolbarFirstChildStyl
12
12
  import { ContextPanelConsumer } from '@atlaskit/editor-common/ui';
13
13
  import { fullPageMessages as messages } from '@atlaskit/editor-common/messages';
14
14
  import { ToolbarArrowKeyNavigationProvider } from '@atlaskit/editor-common/ui-menu';
15
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
15
+ import { usePresetContext } from '../../../presets/context';
16
16
  export var EditorToolbar = /*#__PURE__*/React.memo(function (props) {
17
- var _props$featureFlags, _props$featureFlags2, _props$featureFlags3, _props$featureFlags4, _props$collabEdit, _props$collabEdit2, _props$collabEdit3, _props$featureFlags5, _props$featureFlags6;
17
+ var _props$featureFlags, _props$featureFlags2, _props$featureFlags3, _props$collabEdit, _props$collabEdit2, _props$collabEdit3;
18
18
  var _useState = useState(false),
19
19
  _useState2 = _slicedToArray(_useState, 2),
20
20
  shouldSplitToolbar = _useState2[0],
21
21
  setShouldSplitToolbar = _useState2[1];
22
+ var editorAPI = usePresetContext();
23
+
24
+ // When primary toolbar components is undefined, do not show two line editor toolbar
25
+ var twoLineEditorToolbar = !!props.customPrimaryToolbarComponents && !!((_props$featureFlags = props.featureFlags) !== null && _props$featureFlags !== void 0 && _props$featureFlags.twoLineEditorToolbar);
22
26
  var nonCustomToolbar = jsx("div", {
23
27
  css: nonCustomToolbarWrapperStyle
24
28
  }, props.beforeIcon && jsx("div", {
@@ -37,20 +41,25 @@ export var EditorToolbar = /*#__PURE__*/React.memo(function (props) {
37
41
  dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
38
42
  containerElement: props.containerElement,
39
43
  hasMinWidth: props.hasMinWidth,
40
- twoLineEditorToolbar: !!((_props$featureFlags = props.featureFlags) !== null && _props$featureFlags !== void 0 && _props$featureFlags.twoLineEditorToolbar)
44
+ twoLineEditorToolbar: twoLineEditorToolbar
41
45
  }));
42
46
  var customToolbar = jsx("div", {
43
47
  css: customToolbarWrapperStyle
44
- }, (_props$featureFlags2 = props.featureFlags) !== null && _props$featureFlags2 !== void 0 && _props$featureFlags2.twoLineEditorToolbar && !!props.customPrimaryToolbarComponents && 'before' in props.customPrimaryToolbarComponents ? jsx(BeforePrimaryToolbarWrapper, {
48
+ }, twoLineEditorToolbar && !!props.customPrimaryToolbarComponents && 'before' in props.customPrimaryToolbarComponents ? jsx(BeforePrimaryToolbarWrapper, {
45
49
  beforePrimaryToolbarComponents: props.customPrimaryToolbarComponents.before
46
- }) : null, getBooleanFF('platform.confluence.frontend.editor.no.platform.avatar.group') || (props === null || props === void 0 || (_props$featureFlags3 = props.featureFlags) === null || _props$featureFlags3 === void 0 ? void 0 : _props$featureFlags3.showAvatarGroupAsPlugin) === true && !((_props$featureFlags4 = props.featureFlags) !== null && _props$featureFlags4 !== void 0 && _props$featureFlags4.twoLineEditorToolbar) ? null : jsx(AvatarsWithPluginState, {
50
+ }) : null, props.hideAvatarGroup || (props === null || props === void 0 || (_props$featureFlags2 = props.featureFlags) === null || _props$featureFlags2 === void 0 ? void 0 : _props$featureFlags2.showAvatarGroupAsPlugin) === true && !((_props$featureFlags3 = props.featureFlags) !== null && _props$featureFlags3 !== void 0 && _props$featureFlags3.twoLineEditorToolbar) ? null :
51
+ // Avatars are moved to Confluence codebase for Edit in Context
52
+ // When Edit in Context is enabled customPrimaryToolbarComponents is undefined
53
+ // For more details please check
54
+ // https://hello.atlassian.net/wiki/spaces/PCG/pages/2851572180/Editor+toolbar+for+live+pages+and+edit+in+context+projects
55
+ jsx(AvatarsWithPluginState, {
47
56
  editorView: props.editorView,
48
57
  eventDispatcher: props.eventDispatcher,
49
58
  inviteToEditComponent: (_props$collabEdit = props.collabEdit) === null || _props$collabEdit === void 0 ? void 0 : _props$collabEdit.inviteToEditComponent,
50
59
  inviteToEditHandler: (_props$collabEdit2 = props.collabEdit) === null || _props$collabEdit2 === void 0 ? void 0 : _props$collabEdit2.inviteToEditHandler,
51
60
  isInviteToEditButtonSelected: (_props$collabEdit3 = props.collabEdit) === null || _props$collabEdit3 === void 0 ? void 0 : _props$collabEdit3.isInviteToEditButtonSelected,
52
61
  featureFlags: props.featureFlags || {}
53
- }), (_props$featureFlags5 = props.featureFlags) !== null && _props$featureFlags5 !== void 0 && _props$featureFlags5.findReplace && (_props$featureFlags6 = props.featureFlags) !== null && _props$featureFlags6 !== void 0 && _props$featureFlags6.twoLineEditorToolbar ? jsx(FindReplaceToolbarButtonWithState, {
62
+ }), editorAPI !== null && editorAPI !== void 0 && editorAPI.findReplace && twoLineEditorToolbar ? jsx(FindReplaceToolbarButtonWithState, {
54
63
  popupsBoundariesElement: props.popupsBoundariesElement,
55
64
  popupsMountPoint: props.popupsMountPoint,
56
65
  popupsScrollableElement: props.popupsScrollableElement,
@@ -60,8 +69,7 @@ export var EditorToolbar = /*#__PURE__*/React.memo(function (props) {
60
69
  featureFlags: props.featureFlags
61
70
  }) : null, !!props.customPrimaryToolbarComponents && 'after' in props.customPrimaryToolbarComponents ? props.customPrimaryToolbarComponents.after : props.customPrimaryToolbarComponents);
62
71
  useEffect(function () {
63
- var _props$featureFlags7;
64
- if ((_props$featureFlags7 = props.featureFlags) !== null && _props$featureFlags7 !== void 0 && _props$featureFlags7.twoLineEditorToolbar) {
72
+ if (twoLineEditorToolbar) {
65
73
  var updateOnResize = function updateOnResize() {
66
74
  setShouldSplitToolbar(window.innerWidth <= MAXIMUM_TWO_LINE_TOOLBAR_BREAKPOINT);
67
75
  };
@@ -86,7 +94,6 @@ export var EditorToolbar = /*#__PURE__*/React.memo(function (props) {
86
94
  event.stopPropagation();
87
95
  };
88
96
  return jsx(ContextPanelConsumer, null, function (_ref) {
89
- var _props$featureFlags8, _props$featureFlags9, _props$featureFlags10;
90
97
  var contextPanelWidth = _ref.width;
91
98
  return jsx(ToolbarArrowKeyNavigationProvider, {
92
99
  editorView: props.editorView,
@@ -95,14 +102,14 @@ export var EditorToolbar = /*#__PURE__*/React.memo(function (props) {
95
102
  handleEscape: handleEscape,
96
103
  intl: props.intl
97
104
  }, jsx("div", {
98
- css: mainToolbarStyle(props.showKeyline || contextPanelWidth > 0, !!((_props$featureFlags8 = props.featureFlags) !== null && _props$featureFlags8 !== void 0 && _props$featureFlags8.twoLineEditorToolbar)),
105
+ css: mainToolbarStyle(props.showKeyline || contextPanelWidth > 0, twoLineEditorToolbar),
99
106
  "data-testid": "ak-editor-main-toolbar"
100
107
  }, jsx("div", {
101
- css: mainToolbarFirstChildStyle(!!((_props$featureFlags9 = props.featureFlags) !== null && _props$featureFlags9 !== void 0 && _props$featureFlags9.twoLineEditorToolbar)),
108
+ css: mainToolbarFirstChildStyle(twoLineEditorToolbar),
102
109
  role: "toolbar",
103
110
  "aria-label": props.intl.formatMessage(messages.toolbarLabel)
104
111
  }, shouldSplitToolbar ? customToolbar : nonCustomToolbar), jsx("div", {
105
- css: mainToolbarSecondChildStyle(!!((_props$featureFlags10 = props.featureFlags) !== null && _props$featureFlags10 !== void 0 && _props$featureFlags10.twoLineEditorToolbar)),
112
+ css: mainToolbarSecondChildStyle(twoLineEditorToolbar),
106
113
  "data-testid": 'avatar-group-outside-plugin',
107
114
  role: "region",
108
115
  "aria-label": props.intl.formatMessage(messages.pageActionsLabel)
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "189.1.15";
2
+ export var version = "189.3.0";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- import { EditorAppearance, EditorAppearanceComponentProps } from '../types';
2
+ import type { EditorAppearance, EditorAppearanceComponentProps } from '../types';
3
3
  export default function getUiComponent(appearance: EditorAppearance): React.ComponentClass<EditorAppearanceComponentProps> | React.FunctionComponent<EditorAppearanceComponentProps>;
@@ -7,7 +7,6 @@ export { default as jiraIssuePlugin } from './jira-issue';
7
7
  export { default as toolbarListsIndentationPlugin } from './toolbar-lists-indentation';
8
8
  export { default as macroPlugin } from './macro';
9
9
  export { default as maxContentSizePlugin } from './max-content-size';
10
- export { default as panelPlugin } from './panel';
11
10
  export { default as pastePlugin } from './paste';
12
11
  export { default as tasksAndDecisionsPlugin } from './tasks-and-decisions';
13
12
  export { default as breakoutPlugin } from './breakout';
@@ -9,7 +9,7 @@ import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
9
9
  import type { QuickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
10
10
  import type { BlockTypePlugin } from '@atlaskit/editor-plugin-block-type';
11
11
  import type { CodeBlockPlugin } from '../code-block';
12
- import type { PanelPlugin } from '../panel';
12
+ import type { PanelPlugin } from '@atlaskit/editor-plugin-panel';
13
13
  import type { LayoutPlugin } from '@atlaskit/editor-plugin-layout';
14
14
  import type { RulePlugin } from '@atlaskit/editor-plugin-rule';
15
15
  import type { MediaPlugin } from '@atlaskit/editor-plugin-media';
@@ -47,4 +47,5 @@ export interface EditorAppearanceComponentProps {
47
47
  featureFlags: FeatureFlags;
48
48
  useStickyToolbar?: UseStickyToolbarType;
49
49
  innerRef?: RefObject<HTMLDivElement>;
50
+ hideAvatarGroup?: boolean;
50
51
  }
@@ -21,7 +21,7 @@ import type { FindReplaceOptions } from '../plugins/find-replace/types';
21
21
  import type { LayoutPluginOptions } from '@atlaskit/editor-plugin-layout';
22
22
  import type { MediaOptions, MediaState } from '@atlaskit/editor-plugin-media/types';
23
23
  import type { MentionPluginConfig } from '@atlaskit/editor-plugin-mentions';
24
- import type { PanelPluginConfig } from '../plugins/panel/types';
24
+ import type { PanelPluginConfig } from '@atlaskit/editor-plugin-panel';
25
25
  import type { PlaceholderTextOptions } from '@atlaskit/editor-plugin-placeholder-text';
26
26
  import type { TextColorPluginConfig } from '@atlaskit/editor-plugin-text-color';
27
27
  import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
@@ -149,6 +149,7 @@ export interface EditorSharedPropsWithPlugins {
149
149
  * Configure and extend editor linking behaviour
150
150
  */
151
151
  linking?: LinkingOptions;
152
+ hideAvatarGroup?: boolean;
152
153
  }
153
154
  export interface EditorProps extends EditorBaseProps, EditorPluginFeatureProps, EditorSharedPropsWithPlugins, EditorProviderProps {
154
155
  /**
@@ -30,7 +30,8 @@ export interface FullPageToolbarProps {
30
30
  containerElement: HTMLElement | null;
31
31
  beforeIcon?: ReactElement;
32
32
  hasMinWidth?: boolean;
33
- featureFlags?: FeatureFlags;
33
+ featureFlags: FeatureFlags;
34
+ hideAvatarGroup?: boolean;
34
35
  }
35
36
  export declare const EditorToolbar: React.MemoExoticComponent<(props: FullPageToolbarProps & WrappedComponentProps) => jsx.JSX.Element>;
36
37
  export declare const FullPageToolbar: React.FC<import("react-intl-next").WithIntlProps<FullPageToolbarProps & WrappedComponentProps<"intl">>> & {
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- import { EditorAppearance, EditorAppearanceComponentProps } from '../types';
2
+ import type { EditorAppearance, EditorAppearanceComponentProps } from '../types';
3
3
  export default function getUiComponent(appearance: EditorAppearance): React.ComponentClass<EditorAppearanceComponentProps> | React.FunctionComponent<EditorAppearanceComponentProps>;
@@ -7,7 +7,6 @@ export { default as jiraIssuePlugin } from './jira-issue';
7
7
  export { default as toolbarListsIndentationPlugin } from './toolbar-lists-indentation';
8
8
  export { default as macroPlugin } from './macro';
9
9
  export { default as maxContentSizePlugin } from './max-content-size';
10
- export { default as panelPlugin } from './panel';
11
10
  export { default as pastePlugin } from './paste';
12
11
  export { default as tasksAndDecisionsPlugin } from './tasks-and-decisions';
13
12
  export { default as breakoutPlugin } from './breakout';
@@ -9,7 +9,7 @@ import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
9
9
  import type { QuickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
10
10
  import type { BlockTypePlugin } from '@atlaskit/editor-plugin-block-type';
11
11
  import type { CodeBlockPlugin } from '../code-block';
12
- import type { PanelPlugin } from '../panel';
12
+ import type { PanelPlugin } from '@atlaskit/editor-plugin-panel';
13
13
  import type { LayoutPlugin } from '@atlaskit/editor-plugin-layout';
14
14
  import type { RulePlugin } from '@atlaskit/editor-plugin-rule';
15
15
  import type { MediaPlugin } from '@atlaskit/editor-plugin-media';
@@ -47,4 +47,5 @@ export interface EditorAppearanceComponentProps {
47
47
  featureFlags: FeatureFlags;
48
48
  useStickyToolbar?: UseStickyToolbarType;
49
49
  innerRef?: RefObject<HTMLDivElement>;
50
+ hideAvatarGroup?: boolean;
50
51
  }
@@ -21,7 +21,7 @@ import type { FindReplaceOptions } from '../plugins/find-replace/types';
21
21
  import type { LayoutPluginOptions } from '@atlaskit/editor-plugin-layout';
22
22
  import type { MediaOptions, MediaState } from '@atlaskit/editor-plugin-media/types';
23
23
  import type { MentionPluginConfig } from '@atlaskit/editor-plugin-mentions';
24
- import type { PanelPluginConfig } from '../plugins/panel/types';
24
+ import type { PanelPluginConfig } from '@atlaskit/editor-plugin-panel';
25
25
  import type { PlaceholderTextOptions } from '@atlaskit/editor-plugin-placeholder-text';
26
26
  import type { TextColorPluginConfig } from '@atlaskit/editor-plugin-text-color';
27
27
  import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
@@ -149,6 +149,7 @@ export interface EditorSharedPropsWithPlugins {
149
149
  * Configure and extend editor linking behaviour
150
150
  */
151
151
  linking?: LinkingOptions;
152
+ hideAvatarGroup?: boolean;
152
153
  }
153
154
  export interface EditorProps extends EditorBaseProps, EditorPluginFeatureProps, EditorSharedPropsWithPlugins, EditorProviderProps {
154
155
  /**
@@ -30,7 +30,8 @@ export interface FullPageToolbarProps {
30
30
  containerElement: HTMLElement | null;
31
31
  beforeIcon?: ReactElement;
32
32
  hasMinWidth?: boolean;
33
- featureFlags?: FeatureFlags;
33
+ featureFlags: FeatureFlags;
34
+ hideAvatarGroup?: boolean;
34
35
  }
35
36
  export declare const EditorToolbar: React.MemoExoticComponent<(props: FullPageToolbarProps & WrappedComponentProps) => jsx.JSX.Element>;
36
37
  export declare const FullPageToolbar: React.FC<import("react-intl-next").WithIntlProps<FullPageToolbarProps & WrappedComponentProps<"intl">>> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "189.1.15",
3
+ "version": "189.3.0",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -48,7 +48,7 @@
48
48
  "@atlaskit/analytics-next-stable-react-context": "1.0.1",
49
49
  "@atlaskit/avatar": "^21.4.0",
50
50
  "@atlaskit/avatar-group": "^9.4.0",
51
- "@atlaskit/button": "^16.12.0",
51
+ "@atlaskit/button": "^16.13.0",
52
52
  "@atlaskit/checkbox": "^12.6.0",
53
53
  "@atlaskit/code": "^14.6.0",
54
54
  "@atlaskit/date": "^0.10.0",
@@ -56,7 +56,6 @@
56
56
  "@atlaskit/editor-common": "^76.18.0",
57
57
  "@atlaskit/editor-json-transformer": "^8.10.0",
58
58
  "@atlaskit/editor-markdown-transformer": "^5.2.5",
59
- "@atlaskit/editor-palette": "1.5.1",
60
59
  "@atlaskit/editor-plugin-analytics": "^0.3.0",
61
60
  "@atlaskit/editor-plugin-base": "^0.2.0",
62
61
  "@atlaskit/editor-plugin-better-type-history": "^0.1.0",
@@ -88,6 +87,7 @@
88
87
  "@atlaskit/editor-plugin-list": "^1.3.0",
89
88
  "@atlaskit/editor-plugin-media": "^0.3.0",
90
89
  "@atlaskit/editor-plugin-mentions": "^0.1.0",
90
+ "@atlaskit/editor-plugin-panel": "^0.1.0",
91
91
  "@atlaskit/editor-plugin-paste": "^0.1.0",
92
92
  "@atlaskit/editor-plugin-paste-options-toolbar": "^0.2.0",
93
93
  "@atlaskit/editor-plugin-placeholder": "^0.1.0",
@@ -165,6 +165,7 @@
165
165
  "@atlaskit/collab-provider": "9.15.4",
166
166
  "@atlaskit/dropdown-menu": "^12.1.0",
167
167
  "@atlaskit/editor-extension-dropbox": "^0.4.0",
168
+ "@atlaskit/editor-palette": "1.5.1",
168
169
  "@atlaskit/flag": "^15.2.0",
169
170
  "@atlaskit/icon-object": "^6.3.0",
170
171
  "@atlaskit/inline-dialog": "^13.6.0",
@@ -186,7 +187,7 @@
186
187
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
187
188
  "@atlassian/editor-extension-link-create": "^0.6.0",
188
189
  "@atlassian/feature-flags-test-utils": "^0.1.1",
189
- "@atlassian/link-picker-plugins": "^23.1.0",
190
+ "@atlassian/link-picker-plugins": "^23.2.0",
190
191
  "@atlassian/search-provider": "2.4.8",
191
192
  "@atlassian/ufo": "^0.2.0",
192
193
  "@emotion/jest": "^11.8.0",
@@ -236,9 +237,6 @@
236
237
  "platform.editor.custom-table-width": {
237
238
  "type": "boolean"
238
239
  },
239
- "platform.confluence.frontend.editor.no.platform.avatar.group": {
240
- "type": "boolean"
241
- },
242
240
  "platform.linking-platform.editor.fix-link-insert-analytics": {
243
241
  "type": "boolean"
244
242
  },
package/report.api.md CHANGED
@@ -62,6 +62,7 @@ import { MentionProvider } from '@atlaskit/mention/resource';
62
62
  import { MentionResource } from '@atlaskit/mention/resource';
63
63
  import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
64
64
  import { Node as Node_2 } from '@atlaskit/editor-prosemirror/model';
65
+ import type { PanelPluginConfig } from '@atlaskit/editor-plugin-panel';
65
66
  import { PerformanceTracking } from '@atlaskit/editor-common/types';
66
67
  import type { PlaceholderTextOptions } from '@atlaskit/editor-plugin-placeholder-text';
67
68
  import type { PluginConfig } from '@atlaskit/editor-plugin-table/types';
@@ -540,6 +541,8 @@ interface EditorSharedPropsWithPlugins {
540
541
  allowUndoRedoButtons?: boolean;
541
542
  // (undocumented)
542
543
  collabEdit?: CollabEditOptions;
544
+ // (undocumented)
545
+ hideAvatarGroup?: boolean;
543
546
  linking?: LinkingOptions;
544
547
  // (undocumented)
545
548
  media?: MediaOptions;
@@ -663,14 +666,6 @@ type OnEditorViewStateUpdated = (props: {
663
666
  readonly newEditorState: Readonly<EditorState>;
664
667
  }) => void;
665
668
 
666
- // @public (undocumented)
667
- interface PanelPluginConfig {
668
- // (undocumented)
669
- allowCustomPanel?: boolean;
670
- // (undocumented)
671
- allowCustomPanelEdit?: boolean;
672
- }
673
-
674
669
  export { PortalProvider };
675
670
 
676
671
  export { PortalProviderAPI };
@@ -51,6 +51,7 @@ import { MentionProvider } from '@atlaskit/mention/resource';
51
51
  import { MentionResource } from '@atlaskit/mention/resource';
52
52
  import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
53
53
  import { Node as Node_2 } from '@atlaskit/editor-prosemirror/model';
54
+ import type { PanelPluginConfig } from '@atlaskit/editor-plugin-panel';
54
55
  import { PerformanceTracking } from '@atlaskit/editor-common/types';
55
56
  import type { PlaceholderTextOptions } from '@atlaskit/editor-plugin-placeholder-text';
56
57
  import type { PluginConfig } from '@atlaskit/editor-plugin-table/types';
@@ -495,6 +496,8 @@ interface EditorSharedPropsWithPlugins {
495
496
  allowUndoRedoButtons?: boolean;
496
497
  // (undocumented)
497
498
  collabEdit?: CollabEditOptions;
499
+ // (undocumented)
500
+ hideAvatarGroup?: boolean;
498
501
  linking?: LinkingOptions;
499
502
  // (undocumented)
500
503
  media?: MediaOptions;
@@ -611,14 +614,6 @@ type OnEditorViewStateUpdated = (props: {
611
614
  readonly newEditorState: Readonly<EditorState>;
612
615
  }) => void;
613
616
 
614
- // @public (undocumented)
615
- interface PanelPluginConfig {
616
- // (undocumented)
617
- allowCustomPanel?: boolean;
618
- // (undocumented)
619
- allowCustomPanelEdit?: boolean;
620
- }
621
-
622
617
  export { PortalProvider }
623
618
 
624
619
  export { PortalProviderAPI }
@@ -1,125 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.changePanelType = void 0;
8
- exports.insertPanelWithAnalytics = insertPanelWithAnalytics;
9
- exports.removePanel = void 0;
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
- var _adfSchema = require("@atlaskit/adf-schema");
12
- var _analytics = require("@atlaskit/editor-common/analytics");
13
- var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
14
- var _panel = require("@atlaskit/editor-common/panel");
15
- var _utils = require("@atlaskit/editor-common/utils");
16
- var _state = require("@atlaskit/editor-prosemirror/state");
17
- var _utils2 = require("@atlaskit/editor-prosemirror/utils");
18
- var _utils3 = require("./utils");
19
- 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; }
20
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
21
- var removePanel = exports.removePanel = function removePanel(editorAnalyticsAPI) {
22
- return function (state, dispatch) {
23
- var nodes = state.schema.nodes,
24
- tr = state.tr;
25
- var payload = {
26
- action: _analytics.ACTION.DELETED,
27
- actionSubject: _analytics.ACTION_SUBJECT.PANEL,
28
- attributes: {
29
- inputMethod: _analytics.INPUT_METHOD.TOOLBAR
30
- },
31
- eventType: _analytics.EVENT_TYPE.TRACK
32
- };
33
- var deleteTr = tr;
34
- if ((0, _utils2.findSelectedNodeOfType)(nodes.panel)(tr.selection)) {
35
- deleteTr = (0, _utils2.removeSelectedNode)(tr);
36
- } else if ((0, _utils2.findParentNodeOfType)(nodes.panel)(tr.selection)) {
37
- deleteTr = (0, _utils2.removeParentNodeOfType)(nodes.panel)(tr);
38
- }
39
- if (!deleteTr) {
40
- return false;
41
- }
42
- if (dispatch) {
43
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(deleteTr);
44
- dispatch(deleteTr);
45
- }
46
- return true;
47
- };
48
- };
49
- var changePanelType = exports.changePanelType = function changePanelType(editorAnalyticsAPI) {
50
- return function (panelType) {
51
- var panelOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
52
- var allowCustomPanel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
53
- return function (state, dispatch) {
54
- var nodes = state.schema.nodes,
55
- tr = state.tr;
56
- var panelNode = (0, _utils3.findPanel)(state);
57
- if (panelNode === undefined) {
58
- return false;
59
- }
60
- var newType = panelType;
61
- var previousType = panelNode.node.attrs.panelType;
62
- var newTr;
63
- if (allowCustomPanel) {
64
- var previousColor = panelNode.node.attrs.panelType === 'custom' ? panelNode.node.attrs.panelColor || 'none' : (0, _panel.getPanelTypeBackgroundNoTokens)(previousType);
65
- var previousIcon = panelNode.node.attrs.panelIcon;
66
- var previousIconId = panelNode.node.attrs.panelIconId;
67
- var previousIconText = panelNode.node.attrs.panelIconText;
68
- var newPanelOptions = _objectSpread({
69
- color: previousColor,
70
- emoji: previousIcon,
71
- emojiId: previousIconId,
72
- emojiText: previousIconText
73
- }, panelOptions);
74
- newTr = tr.setNodeMarkup(panelNode.pos, nodes.panel, {
75
- panelIcon: newPanelOptions.emoji,
76
- panelIconId: newPanelOptions.emojiId,
77
- panelIconText: newPanelOptions.emojiText,
78
- panelColor: newPanelOptions.color,
79
- panelType: panelType
80
- });
81
- } else {
82
- newTr = tr.setNodeMarkup(panelNode.pos, nodes.panel, {
83
- panelType: panelType
84
- });
85
- }
86
- var payload = {
87
- action: _analytics.ACTION.CHANGED_TYPE,
88
- actionSubject: _analytics.ACTION_SUBJECT.PANEL,
89
- attributes: {
90
- newType: newType,
91
- previousType: previousType
92
- },
93
- eventType: _analytics.EVENT_TYPE.TRACK
94
- };
95
-
96
- // Select the panel if it was previously selected
97
- var newTrWithSelection = state.selection instanceof _state.NodeSelection && state.selection.node.type.name === 'panel' ? newTr.setSelection(new _state.NodeSelection(tr.doc.resolve(panelNode.pos))) : newTr;
98
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(newTrWithSelection);
99
- newTrWithSelection.setMeta('scrollIntoView', false);
100
- if (dispatch) {
101
- dispatch(newTrWithSelection);
102
- }
103
- return true;
104
- };
105
- };
106
- };
107
- function insertPanelWithAnalytics(inputMethod, analyticsAPI) {
108
- return (0, _editorAnalytics.withAnalytics)(analyticsAPI, {
109
- action: _analytics.ACTION.INSERTED,
110
- actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
111
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.PANEL,
112
- attributes: {
113
- inputMethod: inputMethod,
114
- panelType: _adfSchema.PanelType.INFO // only info panels can be inserted via this action
115
- },
116
-
117
- eventType: _analytics.EVENT_TYPE.TRACK
118
- })(function (state, dispatch) {
119
- var nodes = state.schema.nodes;
120
- if (nodes.panel && nodes.paragraph) {
121
- return (0, _utils.wrapSelectionIn)(nodes.panel)(state, dispatch);
122
- }
123
- return false;
124
- });
125
- }