@atlaskit/editor-core 187.28.0 → 187.28.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 (110) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/create-editor/ReactEditorViewInternal.js +3 -3
  3. package/dist/cjs/create-editor/create-plugins-list.js +2 -2
  4. package/dist/cjs/index.js +0 -7
  5. package/dist/cjs/labs/next/presets/default.js +2 -2
  6. package/dist/cjs/plugins/base/index.js +7 -126
  7. package/dist/cjs/plugins/base/plugin.js +140 -0
  8. package/dist/cjs/plugins/base/pm-plugins/scroll-gutter.js +3 -9
  9. package/dist/cjs/plugins/index.js +2 -2
  10. package/dist/cjs/plugins/list/index.js +17 -0
  11. package/dist/cjs/plugins/list/utils/find.js +4 -3
  12. package/dist/cjs/plugins/paste/handlers.js +27 -3
  13. package/dist/cjs/plugins/paste/pm-plugins/analytics.js +2 -2
  14. package/dist/cjs/plugins/paste/pm-plugins/main.js +2 -2
  15. package/dist/cjs/plugins/toolbar-lists-indentation/index.js +58 -36
  16. package/dist/cjs/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +6 -6
  17. package/dist/cjs/plugins/toolbar-lists-indentation/ui/index.js +3 -3
  18. package/dist/cjs/plugins/toolbar-lists-indentation/ui/onItemActivated.js +8 -9
  19. package/dist/cjs/test-utils.js +2 -2
  20. package/dist/cjs/ui/ContentStyles/index.js +19 -18
  21. package/dist/cjs/ui/ToolbarFeedback/index.js +22 -16
  22. package/dist/cjs/version-wrapper.js +1 -1
  23. package/dist/es2019/create-editor/ReactEditorViewInternal.js +3 -3
  24. package/dist/es2019/create-editor/create-plugins-list.js +1 -1
  25. package/dist/es2019/index.js +0 -1
  26. package/dist/es2019/labs/next/presets/default.js +1 -1
  27. package/dist/es2019/plugins/base/index.js +2 -104
  28. package/dist/es2019/plugins/base/plugin.js +109 -0
  29. package/dist/es2019/plugins/base/pm-plugins/scroll-gutter.js +1 -4
  30. package/dist/es2019/plugins/index.js +1 -1
  31. package/dist/es2019/plugins/list/index.js +19 -0
  32. package/dist/es2019/plugins/list/utils/find.js +2 -2
  33. package/dist/es2019/plugins/paste/handlers.js +27 -3
  34. package/dist/es2019/plugins/paste/pm-plugins/analytics.js +2 -2
  35. package/dist/es2019/plugins/paste/pm-plugins/main.js +2 -2
  36. package/dist/es2019/plugins/toolbar-lists-indentation/index.js +62 -38
  37. package/dist/es2019/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +6 -6
  38. package/dist/es2019/plugins/toolbar-lists-indentation/ui/index.js +3 -3
  39. package/dist/es2019/plugins/toolbar-lists-indentation/ui/onItemActivated.js +5 -6
  40. package/dist/es2019/test-utils.js +1 -1
  41. package/dist/es2019/ui/ContentStyles/index.js +25 -3
  42. package/dist/es2019/ui/ToolbarFeedback/index.js +14 -9
  43. package/dist/es2019/version-wrapper.js +1 -1
  44. package/dist/esm/create-editor/ReactEditorViewInternal.js +3 -3
  45. package/dist/esm/create-editor/create-plugins-list.js +1 -1
  46. package/dist/esm/index.js +0 -1
  47. package/dist/esm/labs/next/presets/default.js +1 -1
  48. package/dist/esm/plugins/base/index.js +2 -123
  49. package/dist/esm/plugins/base/plugin.js +128 -0
  50. package/dist/esm/plugins/base/pm-plugins/scroll-gutter.js +1 -4
  51. package/dist/esm/plugins/index.js +1 -1
  52. package/dist/esm/plugins/list/index.js +19 -0
  53. package/dist/esm/plugins/list/utils/find.js +2 -2
  54. package/dist/esm/plugins/paste/handlers.js +25 -3
  55. package/dist/esm/plugins/paste/pm-plugins/analytics.js +2 -2
  56. package/dist/esm/plugins/paste/pm-plugins/main.js +2 -2
  57. package/dist/esm/plugins/toolbar-lists-indentation/index.js +60 -37
  58. package/dist/esm/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +6 -6
  59. package/dist/esm/plugins/toolbar-lists-indentation/ui/index.js +3 -3
  60. package/dist/esm/plugins/toolbar-lists-indentation/ui/onItemActivated.js +5 -6
  61. package/dist/esm/test-utils.js +1 -1
  62. package/dist/esm/ui/ContentStyles/index.js +6 -5
  63. package/dist/esm/ui/ToolbarFeedback/index.js +20 -14
  64. package/dist/esm/version-wrapper.js +1 -1
  65. package/dist/types/index.d.ts +0 -1
  66. package/dist/types/plugins/base/index.d.ts +4 -16
  67. package/dist/types/plugins/base/plugin.d.ts +23 -0
  68. package/dist/types/plugins/base/pm-plugins/scroll-gutter.d.ts +0 -3
  69. package/dist/types/plugins/index.d.ts +1 -1
  70. package/dist/types/plugins/list/types.d.ts +1 -8
  71. package/dist/types/plugins/list/utils/find.d.ts +1 -1
  72. package/dist/types/plugins/paste/handlers.d.ts +4 -2
  73. package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +2 -1
  74. package/dist/types/plugins/toolbar-lists-indentation/index.d.ts +5 -2
  75. package/dist/types/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.d.ts +4 -1
  76. package/dist/types/plugins/toolbar-lists-indentation/ui/index.d.ts +3 -3
  77. package/dist/types/plugins/toolbar-lists-indentation/ui/onItemActivated.d.ts +3 -2
  78. package/dist/types/ui/ToolbarFeedback/index.d.ts +1 -19
  79. package/dist/types-ts4.5/index.d.ts +0 -1
  80. package/dist/types-ts4.5/plugins/base/index.d.ts +4 -18
  81. package/dist/types-ts4.5/plugins/base/plugin.d.ts +25 -0
  82. package/dist/types-ts4.5/plugins/base/pm-plugins/scroll-gutter.d.ts +0 -3
  83. package/dist/types-ts4.5/plugins/index.d.ts +1 -1
  84. package/dist/types-ts4.5/plugins/list/types.d.ts +1 -8
  85. package/dist/types-ts4.5/plugins/list/utils/find.d.ts +1 -1
  86. package/dist/types-ts4.5/plugins/paste/handlers.d.ts +4 -2
  87. package/dist/types-ts4.5/plugins/paste/pm-plugins/analytics.d.ts +2 -1
  88. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/index.d.ts +5 -2
  89. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.d.ts +4 -1
  90. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/index.d.ts +3 -3
  91. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/onItemActivated.d.ts +3 -2
  92. package/dist/types-ts4.5/ui/ToolbarFeedback/index.d.ts +1 -19
  93. package/package.json +2 -2
  94. package/report.api.md +4 -58
  95. package/tmp/api-report-tmp.d.ts +4 -47
  96. package/dist/cjs/plugins/list/styles.js +0 -15
  97. package/dist/cjs/utils/list-commands.js +0 -17
  98. package/dist/cjs/utils/lists.js +0 -31
  99. package/dist/es2019/plugins/list/styles.js +0 -26
  100. package/dist/es2019/utils/list-commands.js +0 -11
  101. package/dist/es2019/utils/lists.js +0 -26
  102. package/dist/esm/plugins/list/styles.js +0 -7
  103. package/dist/esm/utils/list-commands.js +0 -11
  104. package/dist/esm/utils/lists.js +0 -24
  105. package/dist/types/plugins/list/styles.d.ts +0 -1
  106. package/dist/types/utils/list-commands.d.ts +0 -6
  107. package/dist/types/utils/lists.d.ts +0 -2
  108. package/dist/types-ts4.5/plugins/list/styles.d.ts +0 -1
  109. package/dist/types-ts4.5/utils/list-commands.d.ts +0 -6
  110. package/dist/types-ts4.5/utils/lists.d.ts +0 -2
@@ -0,0 +1,109 @@
1
+ import { baseKeymap } from '@atlaskit/editor-prosemirror/commands';
2
+ import { history } from '@atlaskit/editor-prosemirror/history';
3
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
4
+ import { browser } from '@atlaskit/editor-common/utils';
5
+ import { doc, paragraph, text } from '@atlaskit/adf-schema';
6
+ import filterStepsPlugin from './pm-plugins/filter-steps';
7
+ import fixChrome88SelectionPlugin from './pm-plugins/fix-chrome-88-selection';
8
+ import disableSpellcheckingPlugin from './pm-plugins/disable-spell-checking';
9
+ import contextIdentifierPlugin, { getContextIdentifier } from './pm-plugins/context-identifier';
10
+ import newlinePreserveMarksPlugin from './pm-plugins/newline-preserve-marks';
11
+ import inlineCursorTargetPlugin from './pm-plugins/inline-cursor-target';
12
+ import scrollGutter from './pm-plugins/scroll-gutter';
13
+ import { keymap } from '@atlaskit/editor-common/keymaps';
14
+ import frozenEditor from './pm-plugins/frozen-editor';
15
+ // Chrome >= 88
16
+ export const isChromeWithSelectionBug = browser.chrome && browser.chrome_version >= 88;
17
+ const basePlugin = (options, api) => {
18
+ var _api$dependencies, _api$dependencies$fea;
19
+ const featureFlags = (api === null || api === void 0 ? void 0 : (_api$dependencies = api.dependencies) === null || _api$dependencies === void 0 ? void 0 : (_api$dependencies$fea = _api$dependencies.featureFlags) === null || _api$dependencies$fea === void 0 ? void 0 : _api$dependencies$fea.sharedState.currentState()) || {};
20
+ return {
21
+ name: 'base',
22
+ getSharedState(editorState) {
23
+ return {
24
+ contextIdentifier: getContextIdentifier(editorState)
25
+ };
26
+ },
27
+ pmPlugins() {
28
+ const plugins = [{
29
+ name: 'filterStepsPlugin',
30
+ plugin: ({
31
+ dispatchAnalyticsEvent
32
+ }) => filterStepsPlugin(dispatchAnalyticsEvent)
33
+ }];
34
+
35
+ // In Chrome, when the selection is placed between adjacent nodes which are not contenteditatble
36
+ // the cursor appears at the right most point of the parent container.
37
+ // In Firefox, when the selection is placed between adjacent nodes which are not contenteditatble
38
+ // no cursor is presented to users.
39
+ // In Safari, when the selection is placed between adjacent nodes which are not contenteditatble
40
+ // it is not possible to navigate with arrow keys.
41
+ // This plugin works around the issues by inserting decorations between
42
+ // inline nodes which are set as contenteditable, and have a zero width space.
43
+ plugins.push({
44
+ name: 'inlineCursorTargetPlugin',
45
+ plugin: () => options && options.allowInlineCursorTarget ? inlineCursorTargetPlugin() : undefined
46
+ });
47
+ plugins.push({
48
+ name: 'newlinePreserveMarksPlugin',
49
+ plugin: newlinePreserveMarksPlugin
50
+ }, {
51
+ name: 'frozenEditor',
52
+ plugin: ({
53
+ dispatchAnalyticsEvent
54
+ }) => {
55
+ var _options$inputTrackin;
56
+ return options !== null && options !== void 0 && (_options$inputTrackin = options.inputTracking) !== null && _options$inputTrackin !== void 0 && _options$inputTrackin.enabled || options !== null && options !== void 0 && options.ufo ? frozenEditor(dispatchAnalyticsEvent, options.inputTracking, options.browserFreezeTracking, options.ufo) : undefined;
57
+ }
58
+ }, {
59
+ name: 'history',
60
+ plugin: () => history()
61
+ },
62
+ // should be last :(
63
+ {
64
+ name: 'codeBlockIndent',
65
+ plugin: () => keymap({
66
+ ...baseKeymap,
67
+ 'Mod-[': () => true,
68
+ 'Mod-]': () => true
69
+ })
70
+ }, {
71
+ name: 'contextIdentifier',
72
+ plugin: ({
73
+ dispatch,
74
+ providerFactory
75
+ }) => contextIdentifierPlugin(dispatch, providerFactory)
76
+ });
77
+ if (options && options.allowScrollGutter) {
78
+ plugins.push({
79
+ name: 'scrollGutterPlugin',
80
+ plugin: () => scrollGutter(options.allowScrollGutter)
81
+ });
82
+ }
83
+ if (isChromeWithSelectionBug && !getBooleanFF('platform.editor.disable-chrome-88-selection-fix_uk53m')) {
84
+ plugins.push({
85
+ name: 'fixChrome88SelectionPlugin',
86
+ plugin: () => fixChrome88SelectionPlugin()
87
+ });
88
+ }
89
+ plugins.push({
90
+ name: 'disableSpellcheckingPlugin',
91
+ plugin: () => disableSpellcheckingPlugin(featureFlags)
92
+ });
93
+ return plugins;
94
+ },
95
+ nodes() {
96
+ return [{
97
+ name: 'doc',
98
+ node: doc
99
+ }, {
100
+ name: 'paragraph',
101
+ node: paragraph
102
+ }, {
103
+ name: 'text',
104
+ node: text
105
+ }];
106
+ }
107
+ };
108
+ };
109
+ export default basePlugin;
@@ -1,9 +1,6 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { isEmptyDocument } from '@atlaskit/editor-common/utils';
2
+ import { GUTTER_SELECTOR, GUTTER_SIZE_IN_PX, isEmptyDocument } from '@atlaskit/editor-common/utils';
3
3
  import { getMobileDimensionsPluginState } from '../../mobile-dimensions/utils';
4
- export const GUTTER_SIZE_IN_PX = 120; // Default gutter size
5
- export const GUTTER_SIZE_MOBILE_IN_PX = 36; // Gutter size for Mobile
6
- export const GUTTER_SELECTOR = '#editor-scroll-gutter';
7
4
  const MIN_TAP_SIZE_IN_PX = 40;
8
5
  function supportsIntersectionObserver() {
9
6
  if (typeof window !== 'undefined' && 'IntersectionObserver' in window && 'IntersectionObserverEntry' in window && 'intersectionRatio' in window.IntersectionObserverEntry.prototype) {
@@ -1,4 +1,4 @@
1
- export { default as basePlugin } from './base';
1
+ export { basePlugin } from './base';
2
2
  export { default as blockTypePlugin } from './block-type';
3
3
  export { pluginKey as blockPluginStateKey } from './block-type';
4
4
  export { default as betterTypeHistoryPlugin } from './better-type-history';
@@ -7,6 +7,11 @@ import { listMessages as messages } from '@atlaskit/editor-common/messages';
7
7
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '../analytics';
8
8
  import { toggleBulletList, toggleOrderedList, tooltip } from '../../keymaps';
9
9
  import { IconList, IconListNumber } from '@atlaskit/editor-common/quick-insert';
10
+ import { isInsideListItem } from './utils/selection';
11
+ import { indentList, outdentList, toggleBulletList as toggleBulletListCommand, toggleOrderedList as toggleOrderedListCommand } from './commands';
12
+ import { findRootParentListNode } from './utils/find';
13
+ import { pluginKey as listPluginKey } from './pm-plugins/main';
14
+
10
15
  /*
11
16
  Toolbar buttons to bullet and ordered list can be found in
12
17
  packages/editor/editor-core/src/plugins/toolbar-lists-indentation/ui/Toolbar.tsx
@@ -17,6 +22,20 @@ const listPlugin = (options, api) => {
17
22
  const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions;
18
23
  return {
19
24
  name: 'list',
25
+ actions: {
26
+ indentList: indentList(editorAnalyticsAPI),
27
+ outdentList: outdentList(editorAnalyticsAPI),
28
+ toggleOrderedList: toggleOrderedListCommand(editorAnalyticsAPI),
29
+ toggleBulletList: toggleBulletListCommand(editorAnalyticsAPI),
30
+ isInsideListItem,
31
+ findRootParentListNode
32
+ },
33
+ getSharedState: editorState => {
34
+ if (!editorState) {
35
+ return undefined;
36
+ }
37
+ return listPluginKey.getState(editorState);
38
+ },
20
39
  nodes() {
21
40
  return [{
22
41
  name: 'bulletList',
@@ -36,7 +36,7 @@ export function findFirstParentListItemNode($pos) {
36
36
  pos: listItemNodePosition.pos
37
37
  };
38
38
  }
39
- export function findRootParentListNode($pos) {
39
+ export const findRootParentListNode = $pos => {
40
40
  const {
41
41
  doc
42
42
  } = $pos;
@@ -58,4 +58,4 @@ export function findRootParentListNode($pos) {
58
58
  }
59
59
  const listNodePosition = doc.resolve(parentList.pos);
60
60
  return findRootParentListNode(listNodePosition);
61
- }
61
+ };
@@ -15,7 +15,6 @@ import { linkifyContent, isListItemNode, isListNode, canLinkBeCreatedInRange } f
15
15
  import { insertSliceForLists } from './edge-cases';
16
16
  import { startTrackingPastedMacroPositions, stopTrackingPastedMacroPositions } from './commands';
17
17
  import { getPluginState as getPastePluginState } from './pm-plugins/plugin-factory';
18
- import { doesSelectionWhichStartsOrEndsInListContainEntireList } from '../../utils/lists';
19
18
  import { anyMarkActive } from '@atlaskit/editor-common/mark';
20
19
  // remove text attribute from mention for copy/paste (GDPR)
21
20
  export function handleMention(slice, schema) {
@@ -234,7 +233,32 @@ export function handlePasteNonNestableBlockNodesIntoList(slice) {
234
233
  return false;
235
234
  };
236
235
  }
237
- export function handlePastePanelOrDecisionContentIntoList(slice) {
236
+ export const doesSelectionWhichStartsOrEndsInListContainEntireList = (selection, findRootParentListNode) => {
237
+ const {
238
+ $from,
239
+ $to,
240
+ from,
241
+ to
242
+ } = selection;
243
+ const selectionParentListItemNodeResolvedPos = findRootParentListNode ? findRootParentListNode($from) || findRootParentListNode($to) : null;
244
+ const selectionParentListNode = selectionParentListItemNodeResolvedPos === null || selectionParentListItemNodeResolvedPos === void 0 ? void 0 : selectionParentListItemNodeResolvedPos.parent;
245
+ if (!selectionParentListItemNodeResolvedPos || !selectionParentListNode) {
246
+ return false;
247
+ }
248
+ const startOfEntireList = $from.pos < $to.pos ? selectionParentListItemNodeResolvedPos.pos + $from.depth - 1 : selectionParentListItemNodeResolvedPos.pos + $to.depth - 1;
249
+ const endOfEntireList = $from.pos < $to.pos ? selectionParentListItemNodeResolvedPos.pos + selectionParentListNode.nodeSize - $to.depth - 1 : selectionParentListItemNodeResolvedPos.pos + selectionParentListNode.nodeSize - $from.depth - 1;
250
+ if (!startOfEntireList || !endOfEntireList) {
251
+ return false;
252
+ }
253
+ if (from < to) {
254
+ return startOfEntireList >= $from.pos && endOfEntireList <= $to.pos;
255
+ } else if (from > to) {
256
+ return startOfEntireList >= $to.pos && endOfEntireList <= $from.pos;
257
+ } else {
258
+ return false;
259
+ }
260
+ };
261
+ export function handlePastePanelOrDecisionContentIntoList(slice, findRootParentListNode) {
238
262
  return (state, dispatch) => {
239
263
  const {
240
264
  schema,
@@ -247,7 +271,7 @@ export function handlePastePanelOrDecisionContentIntoList(slice) {
247
271
  const blockNode = slice.content.firstChild;
248
272
  const isSliceWholeNode = slice.openStart === 0 && slice.openEnd === 0;
249
273
  const selectionParentListItemNode = selection.$to.node(selection.$to.depth - 1);
250
- const sliceIsWholeNodeButShouldNotReplaceSelection = isSliceWholeNode && !doesSelectionWhichStartsOrEndsInListContainEntireList(selection);
274
+ const sliceIsWholeNodeButShouldNotReplaceSelection = isSliceWholeNode && !doesSelectionWhichStartsOrEndsInListContainEntireList(selection, findRootParentListNode);
251
275
  if (!selectionParentListItemNode || (selectionParentListItemNode === null || selectionParentListItemNode === void 0 ? void 0 : selectionParentListItemNode.type) !== schema.nodes.listItem || !blockNode || !['panel', 'decisionList'].includes(blockNode === null || blockNode === void 0 ? void 0 : blockNode.type.name) || slice.content.childCount > 1 || (blockNode === null || blockNode === void 0 ? void 0 : blockNode.content.firstChild) === undefined || sliceIsWholeNodeButShouldNotReplaceSelection) {
252
276
  return false;
253
277
  }
@@ -280,9 +280,9 @@ function injectAnalyticsPayloadBeforeCommand(createPayloadByTransaction) {
280
280
  };
281
281
  };
282
282
  }
283
- export const handlePastePanelOrDecisionIntoListWithAnalytics = (view, event, slice) => injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
283
+ export const handlePastePanelOrDecisionIntoListWithAnalytics = (view, event, slice, findRootParentListNode) => injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
284
284
  type: PasteTypes.richText
285
- }))(handlePastePanelOrDecisionContentIntoList(slice));
285
+ }))(handlePastePanelOrDecisionContentIntoList(slice, findRootParentListNode));
286
286
  export const handlePasteNonNestableBlockNodesIntoListWithAnalytics = (view, event, slice) => injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
287
287
  type: PasteTypes.richText,
288
288
  pasteSplitList: true
@@ -281,7 +281,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
281
281
 
282
282
  // finally, handle rich-text copy-paste
283
283
  if (isRichText) {
284
- var _pluginInjectionApi$d6, _pluginInjectionApi$d7;
284
+ var _pluginInjectionApi$d6, _pluginInjectionApi$d7, _pluginInjectionApi$d8;
285
285
  // linkify the text where possible
286
286
  slice = linkifyContent(state.schema)(slice);
287
287
  if (handlePasteLinkOnSelectedTextWithAnalytics(view, event, slice, PasteTypes.richText)(state, dispatch)) {
@@ -344,7 +344,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
344
344
  if (handlePasteIntoCaptionWithAnalytics(view, event, slice, PasteTypes.richText)(state, dispatch)) {
345
345
  return true;
346
346
  }
347
- if (handlePastePanelOrDecisionIntoListWithAnalytics(view, event, slice)(state, dispatch)) {
347
+ if (handlePastePanelOrDecisionIntoListWithAnalytics(view, event, slice, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d8 = pluginInjectionApi.dependencies.list) === null || _pluginInjectionApi$d8 === void 0 ? void 0 : _pluginInjectionApi$d8.actions.findRootParentListNode)(state, dispatch)) {
348
348
  return true;
349
349
  }
350
350
  if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists && handlePasteNonNestableBlockNodesIntoListWithAnalytics(view, event, slice)(state, dispatch)) {
@@ -1,18 +1,23 @@
1
1
  import React from 'react';
2
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
2
3
  import ToolbarListsIndentation from './ui';
3
- import WithPluginState from '../../ui/WithPluginState';
4
4
  import { ToolbarSize } from '../../ui/Toolbar/types';
5
- import { pluginKey as listPluginKey } from '../list/pm-plugins/main';
6
- import { pluginKey as indentationButtonsPluginKey, createPlugin as indentationButtonsPlugin } from './pm-plugins/indentation-buttons';
5
+ import { createPlugin as indentationButtonsPlugin } from './pm-plugins/indentation-buttons';
6
+ import { pluginKey as indentationButtonPluginKey } from './pm-plugins/indentation-buttons';
7
7
  const toolbarListsIndentationPlugin = ({
8
8
  showIndentationButtons,
9
9
  allowHeadingAndParagraphIndentation
10
10
  }, api) => {
11
- var _api$dependencies$ana;
12
- const featureFlags = (api === null || api === void 0 ? void 0 : api.dependencies.featureFlags.sharedState.currentState()) || {};
13
- const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions;
11
+ var _api$dependencies$fea;
12
+ const featureFlags = (api === null || api === void 0 ? void 0 : (_api$dependencies$fea = api.dependencies.featureFlags) === null || _api$dependencies$fea === void 0 ? void 0 : _api$dependencies$fea.sharedState.currentState()) || {};
14
13
  return {
15
14
  name: 'toolbarListsIndentation',
15
+ getSharedState(editorState) {
16
+ if (!editorState) {
17
+ return undefined;
18
+ }
19
+ return indentationButtonPluginKey.getState(editorState);
20
+ },
16
21
  pmPlugins() {
17
22
  return [{
18
23
  name: 'indentationButtons',
@@ -21,7 +26,8 @@ const toolbarListsIndentationPlugin = ({
21
26
  }) => indentationButtonsPlugin({
22
27
  dispatch,
23
28
  showIndentationButtons,
24
- allowHeadingAndParagraphIndentation
29
+ allowHeadingAndParagraphIndentation,
30
+ api
25
31
  })
26
32
  }];
27
33
  },
@@ -35,39 +41,57 @@ const toolbarListsIndentationPlugin = ({
35
41
  isToolbarReducedSpacing
36
42
  }) {
37
43
  const isSmall = toolbarSize < ToolbarSize.L;
38
- return /*#__PURE__*/React.createElement(WithPluginState, {
39
- plugins: {
40
- listState: listPluginKey,
41
- indentationState: indentationButtonsPluginKey
42
- },
43
- render: ({
44
- listState,
45
- indentationState
46
- }) => {
47
- if (!listState) {
48
- return null;
49
- }
50
- return /*#__PURE__*/React.createElement(ToolbarListsIndentation, {
51
- featureFlags: featureFlags,
52
- isSmall: isSmall,
53
- isReducedSpacing: isToolbarReducedSpacing,
54
- disabled: disabled,
55
- editorView: editorView,
56
- popupsMountPoint: popupsMountPoint,
57
- popupsBoundariesElement: popupsBoundariesElement,
58
- popupsScrollableElement: popupsScrollableElement,
59
- bulletListActive: listState.bulletListActive,
60
- bulletListDisabled: listState.bulletListDisabled,
61
- orderedListActive: listState.orderedListActive,
62
- orderedListDisabled: listState.orderedListDisabled,
63
- showIndentationButtons: !!showIndentationButtons,
64
- indentDisabled: indentationState.indentDisabled,
65
- outdentDisabled: indentationState.outdentDisabled,
66
- editorAnalyticsAPI: editorAnalyticsAPI
67
- });
68
- }
44
+ return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
45
+ featureFlags: featureFlags,
46
+ popupsMountPoint: popupsMountPoint,
47
+ popupsBoundariesElement: popupsBoundariesElement,
48
+ popupsScrollableElement: popupsScrollableElement,
49
+ isSmall: isSmall,
50
+ isToolbarReducedSpacing: isToolbarReducedSpacing,
51
+ disabled: disabled,
52
+ editorView: editorView,
53
+ showIndentationButtons: showIndentationButtons,
54
+ pluginInjectionApi: api
69
55
  });
70
56
  }
71
57
  };
72
58
  };
59
+ function PrimaryToolbarComponent({
60
+ featureFlags,
61
+ popupsMountPoint,
62
+ popupsBoundariesElement,
63
+ popupsScrollableElement,
64
+ isSmall,
65
+ isToolbarReducedSpacing,
66
+ disabled,
67
+ editorView,
68
+ showIndentationButtons,
69
+ pluginInjectionApi
70
+ }) {
71
+ const {
72
+ listState,
73
+ toolbarListsIndentationState
74
+ } = useSharedPluginState(pluginInjectionApi, ['list', 'toolbarListsIndentation']);
75
+ if (!listState) {
76
+ return null;
77
+ }
78
+ return /*#__PURE__*/React.createElement(ToolbarListsIndentation, {
79
+ featureFlags: featureFlags,
80
+ isSmall: isSmall,
81
+ isReducedSpacing: isToolbarReducedSpacing,
82
+ disabled: disabled,
83
+ editorView: editorView,
84
+ popupsMountPoint: popupsMountPoint,
85
+ popupsBoundariesElement: popupsBoundariesElement,
86
+ popupsScrollableElement: popupsScrollableElement,
87
+ bulletListActive: listState.bulletListActive,
88
+ bulletListDisabled: listState.bulletListDisabled,
89
+ orderedListActive: listState.orderedListActive,
90
+ orderedListDisabled: listState.orderedListDisabled,
91
+ showIndentationButtons: !!showIndentationButtons,
92
+ indentDisabled: toolbarListsIndentationState.indentDisabled,
93
+ outdentDisabled: toolbarListsIndentationState.outdentDisabled,
94
+ pluginInjectionApi: pluginInjectionApi
95
+ });
96
+ }
73
97
  export default toolbarListsIndentationPlugin;
@@ -2,12 +2,11 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
2
  import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
3
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
4
  import { shallowEqual } from '@atlaskit/editor-common/utils';
5
- import { isInsideListItem } from '../../list/utils/selection';
6
5
  import { getCurrentIndentLevel as getTaskListIndentLevel, getTaskItemIndex, isInsideTask } from '../../tasks-and-decisions/pm-plugins/helpers';
7
6
  import { isIndentationAllowed, MAX_INDENTATION_LEVEL } from '../../indentation/commands';
8
7
  import { getListItemAttributes } from '@atlaskit/editor-common/lists';
9
8
  export const pluginKey = new PluginKey('indentationButtonsPlugin');
10
- function getIndentationButtonsState(editorState, allowHeadingAndParagraphIndentation) {
9
+ function getIndentationButtonsState(editorState, allowHeadingAndParagraphIndentation, api) {
11
10
  const state = {
12
11
  indentDisabled: true,
13
12
  outdentDisabled: true,
@@ -22,7 +21,7 @@ function getIndentationButtonsState(editorState, allowHeadingAndParagraphIndenta
22
21
  // not use the indentation mark.
23
22
  // Check for lists before paragraphs and headings in case
24
23
  // the selection is in a list nested in a layout column.
25
- if (isInsideListItem(editorState)) {
24
+ if (api !== null && api !== void 0 && api.dependencies.list.actions.isInsideListItem(editorState)) {
26
25
  const {
27
26
  indentLevel,
28
27
  itemIndex
@@ -70,7 +69,8 @@ function getIndentationButtonsState(editorState, allowHeadingAndParagraphIndenta
70
69
  export const createPlugin = ({
71
70
  dispatch,
72
71
  showIndentationButtons,
73
- allowHeadingAndParagraphIndentation
72
+ allowHeadingAndParagraphIndentation,
73
+ api
74
74
  }) => new SafePlugin({
75
75
  state: {
76
76
  init(_config, state) {
@@ -79,11 +79,11 @@ export const createPlugin = ({
79
79
  outdentDisabled: true,
80
80
  node: null
81
81
  };
82
- return showIndentationButtons ? getIndentationButtonsState(state, allowHeadingAndParagraphIndentation) : initialState;
82
+ return showIndentationButtons ? getIndentationButtonsState(state, allowHeadingAndParagraphIndentation, api) : initialState;
83
83
  },
84
84
  apply(_tr, pluginState, _oldState, newState) {
85
85
  if (showIndentationButtons) {
86
- const state = getIndentationButtonsState(newState, allowHeadingAndParagraphIndentation);
86
+ const state = getIndentationButtonsState(newState, allowHeadingAndParagraphIndentation, api);
87
87
  if (!shallowEqual(pluginState, state)) {
88
88
  dispatch(pluginKey, state);
89
89
  return state;
@@ -19,7 +19,7 @@ export default function ToolbarListsIndentation(props) {
19
19
  indentDisabled,
20
20
  outdentDisabled,
21
21
  featureFlags,
22
- editorAnalyticsAPI
22
+ pluginInjectionApi
23
23
  } = props;
24
24
  if (isSmall) {
25
25
  return jsx(ToolbarDropdown, {
@@ -36,7 +36,7 @@ export default function ToolbarListsIndentation(props) {
36
36
  indentDisabled: indentDisabled,
37
37
  outdentDisabled: outdentDisabled,
38
38
  disabled: disabled,
39
- onItemActivated: onItemActivated(editorAnalyticsAPI),
39
+ onItemActivated: onItemActivated(pluginInjectionApi),
40
40
  featureFlags: featureFlags
41
41
  });
42
42
  }
@@ -51,7 +51,7 @@ export default function ToolbarListsIndentation(props) {
51
51
  indentDisabled: indentDisabled,
52
52
  outdentDisabled: outdentDisabled,
53
53
  disabled: disabled,
54
- onItemActivated: onItemActivated(editorAnalyticsAPI),
54
+ onItemActivated: onItemActivated(pluginInjectionApi),
55
55
  featureFlags: featureFlags
56
56
  });
57
57
  }
@@ -1,19 +1,18 @@
1
- import { indentList, outdentList, toggleBulletList, toggleOrderedList } from '../../list/commands';
2
1
  import { getIndentCommand as indentParagraphOrHeading, getOutdentCommand as outdentParagraphOrHeading } from '../../indentation/commands';
3
2
  import { getIndentCommand as indentTaskList, getUnindentCommand as outdentTaskList } from '../../tasks-and-decisions/pm-plugins/keymaps';
4
3
  import { INPUT_METHOD } from '../../analytics';
5
4
  import { pluginKey as indentationButtonsPluginKey } from '../pm-plugins/indentation-buttons';
6
- export const onItemActivated = editorAnalyticsAPI => ({
5
+ export const onItemActivated = pluginInjectionApi => ({
7
6
  buttonName,
8
7
  editorView,
9
8
  featureFlags
10
9
  }) => {
11
10
  switch (buttonName) {
12
11
  case 'bullet_list':
13
- toggleBulletList(editorAnalyticsAPI)(editorView, INPUT_METHOD.TOOLBAR);
12
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.list.actions.toggleBulletList(editorView, INPUT_METHOD.TOOLBAR);
14
13
  break;
15
14
  case 'ordered_list':
16
- toggleOrderedList(editorAnalyticsAPI)(editorView, INPUT_METHOD.TOOLBAR);
15
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.list.actions.toggleOrderedList(editorView, INPUT_METHOD.TOOLBAR);
17
16
  break;
18
17
  case 'indent':
19
18
  {
@@ -23,7 +22,7 @@ export const onItemActivated = editorAnalyticsAPI => ({
23
22
  indentParagraphOrHeading(INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
24
23
  }
25
24
  if (node === 'list') {
26
- indentList(editorAnalyticsAPI)(INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
25
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.list.actions.indentList(INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
27
26
  }
28
27
  if (node === 'taskList') {
29
28
  indentTaskList(INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
@@ -38,7 +37,7 @@ export const onItemActivated = editorAnalyticsAPI => ({
38
37
  outdentParagraphOrHeading(INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
39
38
  }
40
39
  if (node === 'list') {
41
- outdentList(editorAnalyticsAPI)(INPUT_METHOD.TOOLBAR, featureFlags)(editorView.state, editorView.dispatch);
40
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.list.actions.outdentList(INPUT_METHOD.TOOLBAR, featureFlags)(editorView.state, editorView.dispatch);
42
41
  }
43
42
  if (node === 'taskList') {
44
43
  outdentTaskList(INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
@@ -3,7 +3,7 @@ import { EditorPresetBuilder } from '@atlaskit/editor-common/preset';
3
3
  import { createSchema } from './create-editor/create-schema';
4
4
  import { sortByOrder } from './create-editor/sort-by-order';
5
5
  import { analyticsPluginKey } from './plugins/analytics/plugin-key';
6
- import basePlugin from './plugins/base';
6
+ import { basePlugin } from './plugins/base';
7
7
  export { createTypeAheadTools } from './plugins/type-ahead/api';
8
8
  export function getFireAnalytics(editorView) {
9
9
  var _analyticsPluginKey$g;
@@ -1,8 +1,8 @@
1
1
  /** @jsx jsx */
2
2
  import React, { useMemo } from 'react';
3
3
  import { jsx, css, useTheme } from '@emotion/react';
4
- import { whitespaceSharedStyles, paragraphSharedStyles, listsSharedStyles, indentationSharedStyles, blockMarksSharedStyles, shadowSharedStyle, dateSharedStyle, tasksAndDecisionsStyles, annotationSharedStyles, smartCardSharedStyles, textColorStyles, resizerStyles, gridStyles, smartCardStyles, embedCardStyles } from '@atlaskit/editor-common/styles';
5
- import { editorFontSize } from '@atlaskit/editor-shared-styles';
4
+ import { whitespaceSharedStyles, paragraphSharedStyles, listsSharedStyles, indentationSharedStyles, blockMarksSharedStyles, shadowSharedStyle, dateSharedStyle, tasksAndDecisionsStyles, annotationSharedStyles, smartCardSharedStyles, textColorStyles, resizerStyles, gridStyles, smartCardStyles, embedCardStyles, codeBlockInListSafariFix } from '@atlaskit/editor-common/styles';
5
+ import { blockNodesVerticalMargin, editorFontSize } from '@atlaskit/editor-shared-styles';
6
6
  import { unsupportedStyles } from '../../plugins/unsupported-content/styles';
7
7
  import { telepointerStyle } from '../../plugins/collab-edit/styles';
8
8
  import { gapCursorStyles } from '../../plugins/selection/gap-cursor/styles';
@@ -10,7 +10,6 @@ import { tableStyles } from '@atlaskit/editor-plugin-table/ui/common-styles';
10
10
  import { placeholderStyles } from '../../plugins/placeholder/styles';
11
11
  import { blocktypeStyles } from '../../plugins/block-type/styles';
12
12
  import { codeBlockStyles } from '../../plugins/code-block/styles';
13
- import { listsStyles } from '../../plugins/list/styles';
14
13
  import { ruleStyles } from '../../plugins/rule/styles';
15
14
  import { mediaStyles } from '../../plugins/media/styles';
16
15
  import { layoutStyles } from '../../plugins/layout/styles';
@@ -28,11 +27,34 @@ import { statusStyles } from '../../plugins/status/styles';
28
27
  import { dateStyles } from '../../plugins/date/styles';
29
28
  import { InlineNodeViewSharedStyles } from '../../nodeviews/getInlineNodeViewProducer.styles';
30
29
  import { linkSharedStyle, codeMarkSharedStyles } from '@atlaskit/editor-common/styles';
30
+ import { browser } from '@atlaskit/editor-common/utils';
31
31
  export const linkStyles = css`
32
32
  .ProseMirror {
33
33
  ${linkSharedStyle}
34
34
  }
35
35
  `;
36
+ const listsStyles = css`
37
+ .ProseMirror {
38
+ li {
39
+ position: relative;
40
+
41
+ > p:not(:first-child) {
42
+ margin: 4px 0 0 0;
43
+ }
44
+
45
+ // In SSR the above rule will apply to all p tags because first-child would be a style tag.
46
+ // The following rule resets the first p tag back to its original margin
47
+ // defined in packages/editor/editor-common/src/styles/shared/paragraph.ts
48
+ > style:first-child + p {
49
+ margin-top: ${blockNodesVerticalMargin};
50
+ }
51
+ }
52
+
53
+ & :not([data-node-type='decisionList']) > li {
54
+ ${browser.safari ? codeBlockInListSafariFix : ''}
55
+ }
56
+ }
57
+ `;
36
58
  const contentStyles = props => css`
37
59
  .ProseMirror {
38
60
  outline: none;
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
3
  /** @jsx jsx */
3
4
  import { jsx } from '@emotion/react';
@@ -17,7 +18,7 @@ import { openFeedbackDialog } from '../../plugins/feedback-dialog';
17
18
  import deprecationWarnings from '../../utils/deprecation-warnings';
18
19
  import pickBy from '../../utils/pick-by';
19
20
  import { analyticsEventKey } from '../../plugins/analytics/consts';
20
- import { getContextIdentifier } from '../../plugins/base/pm-plugins/context-identifier';
21
+ import { usePresetContext } from '../../presets/context';
21
22
  const PopupWithOutsideListeners = withOuterListeners(Popup);
22
23
  const POPUP_HEIGHT = 388;
23
24
  const POPUP_WIDTH = 280;
@@ -36,7 +37,7 @@ const deprecations = [{
36
37
  type: 'removed'
37
38
  }];
38
39
  const isNullOrUndefined = attr => attr === null || attr === undefined;
39
- export default class ToolbarFeedback extends PureComponent {
40
+ class ToolbarFeedbackInternal extends PureComponent {
40
41
  constructor(props) {
41
42
  super(props);
42
43
  _defineProperty(this, "state", {
@@ -70,16 +71,14 @@ export default class ToolbarFeedback extends PureComponent {
70
71
  });
71
72
  });
72
73
  _defineProperty(this, "openJiraIssueCollector", async () => {
73
- var _window$localStorage$, _getContextIdentifier;
74
+ var _this$props$api, _window$localStorage$, _basePluginState$cont;
74
75
  this.setState({
75
76
  jiraIssueCollectorScriptLoading: true,
76
77
  showOptOutOption: false
77
78
  });
78
- const {
79
- editorView
80
- } = this.context.editorActions;
79
+ const basePluginState = (_this$props$api = this.props.api) === null || _this$props$api === void 0 ? void 0 : _this$props$api.dependencies.base.sharedState.currentState();
81
80
  const sessionId = (_window$localStorage$ = window.localStorage.getItem('awc.session.id')) === null || _window$localStorage$ === void 0 ? void 0 : _window$localStorage$.toString();
82
- const contentId = (_getContextIdentifier = getContextIdentifier(editorView === null || editorView === void 0 ? void 0 : editorView.state)) === null || _getContextIdentifier === void 0 ? void 0 : _getContextIdentifier.objectId;
81
+ const contentId = basePluginState === null || basePluginState === void 0 ? void 0 : (_basePluginState$cont = basePluginState.contextIdentifier) === null || _basePluginState$cont === void 0 ? void 0 : _basePluginState$cont.objectId;
83
82
  const tabId = window.sessionStorage['awc.tab.id'];
84
83
  await openFeedbackDialog({
85
84
  ...this.getFeedbackInfo(),
@@ -159,6 +158,12 @@ export default class ToolbarFeedback extends PureComponent {
159
158
  }, "Learn more")))))) : null;
160
159
  }
161
160
  }
162
- _defineProperty(ToolbarFeedback, "contextTypes", {
161
+ _defineProperty(ToolbarFeedbackInternal, "contextTypes", {
163
162
  editorActions: PropTypes.object.isRequired
164
- });
163
+ });
164
+ export default function ToolbarFeedback(props) {
165
+ const api = usePresetContext();
166
+ return jsx(ToolbarFeedbackInternal, _extends({
167
+ api: api
168
+ }, props));
169
+ }
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.28.0";
2
+ export const version = "187.28.1";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };