@atlaskit/editor-core 189.3.19 → 189.3.20

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 (84) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/actions/index.js +6 -5
  3. package/dist/cjs/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +2 -2
  4. package/dist/cjs/plugins/extension/context-panel.js +117 -107
  5. package/dist/cjs/plugins/extension/extension-api.js +1 -1
  6. package/dist/cjs/plugins/extension/index.js +4 -1
  7. package/dist/cjs/plugins/extension/plugin-factory.js +2 -2
  8. package/dist/cjs/plugins/extension/pm-plugins/unique-id.js +2 -2
  9. package/dist/cjs/plugins/extension/toolbar.js +1 -1
  10. package/dist/cjs/plugins/extension/utils.js +4 -5
  11. package/dist/cjs/plugins/find-replace/plugin.js +3 -3
  12. package/dist/cjs/ui/ContentStyles/index.js +4 -4
  13. package/dist/cjs/utils/nodes-by-localIds.js +1 -29
  14. package/dist/cjs/utils/selection.js +1 -15
  15. package/dist/cjs/version-wrapper.js +1 -1
  16. package/dist/es2019/actions/index.js +5 -4
  17. package/dist/es2019/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +1 -1
  18. package/dist/es2019/plugins/extension/context-panel.js +55 -47
  19. package/dist/es2019/plugins/extension/extension-api.js +1 -1
  20. package/dist/es2019/plugins/extension/index.js +4 -1
  21. package/dist/es2019/plugins/extension/plugin-factory.js +1 -1
  22. package/dist/es2019/plugins/extension/pm-plugins/macro/actions.js +1 -2
  23. package/dist/es2019/plugins/extension/pm-plugins/unique-id.js +1 -1
  24. package/dist/es2019/plugins/extension/toolbar.js +1 -1
  25. package/dist/es2019/plugins/extension/utils.js +1 -2
  26. package/dist/es2019/plugins/find-replace/plugin.js +1 -1
  27. package/dist/es2019/ui/ContentStyles/index.js +1 -1
  28. package/dist/es2019/utils/nodes-by-localIds.js +0 -27
  29. package/dist/es2019/utils/selection.js +0 -14
  30. package/dist/es2019/version-wrapper.js +1 -1
  31. package/dist/esm/actions/index.js +5 -4
  32. package/dist/esm/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +1 -1
  33. package/dist/esm/plugins/extension/context-panel.js +115 -105
  34. package/dist/esm/plugins/extension/extension-api.js +1 -1
  35. package/dist/esm/plugins/extension/index.js +4 -1
  36. package/dist/esm/plugins/extension/plugin-factory.js +1 -1
  37. package/dist/esm/plugins/extension/pm-plugins/macro/actions.js +1 -2
  38. package/dist/esm/plugins/extension/pm-plugins/unique-id.js +1 -1
  39. package/dist/esm/plugins/extension/toolbar.js +1 -1
  40. package/dist/esm/plugins/extension/utils.js +1 -2
  41. package/dist/esm/plugins/find-replace/plugin.js +1 -1
  42. package/dist/esm/ui/ContentStyles/index.js +1 -1
  43. package/dist/esm/utils/nodes-by-localIds.js +0 -28
  44. package/dist/esm/utils/selection.js +0 -14
  45. package/dist/esm/version-wrapper.js +1 -1
  46. package/dist/types/plugins/extension/actions.d.ts +1 -1
  47. package/dist/types/plugins/extension/context-panel.d.ts +4 -2
  48. package/dist/types/plugins/extension/nodeviews/extension.d.ts +3 -4
  49. package/dist/types/plugins/extension/plugin-factory.d.ts +1 -1
  50. package/dist/types/plugins/extension/pm-plugins/main.d.ts +2 -4
  51. package/dist/types/plugins/extension/ui/Extension/Extension/index.d.ts +2 -3
  52. package/dist/types/plugins/extension/ui/Extension/ExtensionComponent.d.ts +2 -3
  53. package/dist/types/plugins/extension/ui/Extension/index.d.ts +2 -3
  54. package/dist/types/plugins/extension/utils.d.ts +1 -2
  55. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  56. package/dist/types/ui/ConfigPanel/ConfigPanelFieldsLoader.d.ts +2 -2
  57. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  58. package/dist/types/utils/nodes-by-localIds.d.ts +0 -5
  59. package/dist/types/utils/selection.d.ts +1 -3
  60. package/dist/types-ts4.5/plugins/extension/actions.d.ts +1 -1
  61. package/dist/types-ts4.5/plugins/extension/context-panel.d.ts +4 -2
  62. package/dist/types-ts4.5/plugins/extension/nodeviews/extension.d.ts +3 -4
  63. package/dist/types-ts4.5/plugins/extension/plugin-factory.d.ts +1 -1
  64. package/dist/types-ts4.5/plugins/extension/pm-plugins/main.d.ts +2 -4
  65. package/dist/types-ts4.5/plugins/extension/ui/Extension/Extension/index.d.ts +2 -3
  66. package/dist/types-ts4.5/plugins/extension/ui/Extension/ExtensionComponent.d.ts +2 -3
  67. package/dist/types-ts4.5/plugins/extension/ui/Extension/index.d.ts +2 -3
  68. package/dist/types-ts4.5/plugins/extension/utils.d.ts +1 -2
  69. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  70. package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanelFieldsLoader.d.ts +2 -2
  71. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
  72. package/dist/types-ts4.5/utils/nodes-by-localIds.d.ts +0 -5
  73. package/dist/types-ts4.5/utils/selection.d.ts +1 -3
  74. package/package.json +3 -6
  75. package/dist/cjs/utils/step.js +0 -24
  76. package/dist/es2019/utils/step.js +0 -1
  77. package/dist/esm/utils/step.js +0 -1
  78. package/dist/types/utils/step.d.ts +0 -1
  79. package/dist/types-ts4.5/utils/step.d.ts +0 -1
  80. /package/dist/cjs/{plugins/extension/ui/styles.js → ui/ContentStyles/extension.js} +0 -0
  81. /package/dist/es2019/{plugins/extension/ui/styles.js → ui/ContentStyles/extension.js} +0 -0
  82. /package/dist/esm/{plugins/extension/ui/styles.js → ui/ContentStyles/extension.js} +0 -0
  83. /package/dist/types/{plugins/extension/ui/styles.d.ts → ui/ContentStyles/extension.d.ts} +0 -0
  84. /package/dist/types-ts4.5/{plugins/extension/ui/styles.d.ts → ui/ContentStyles/extension.d.ts} +0 -0
@@ -2,12 +2,13 @@ import React from 'react';
2
2
  import { getExtensionKeyAndNodeKey } from '@atlaskit/editor-common/extensions';
3
3
  import { getPluginState } from './pm-plugins/main';
4
4
  import { getSelectedExtension } from './utils';
5
- import WithEditorActions from '../../ui/WithEditorActions';
6
5
  import ConfigPanelLoader from '../../ui/ConfigPanel/ConfigPanelLoader';
7
- import { duplicateSelection } from '../../utils/selection';
8
6
  import { clearEditingContext, forceAutoSave, updateState } from './commands';
9
7
  import { buildExtensionNode } from './actions';
10
8
  import { SaveIndicator } from './ui/SaveIndicator/SaveIndicator';
9
+ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
10
+ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
11
+ import { GapCursorSelection } from '@atlaskit/editor-common/selection';
11
12
  const areParametersEqual = (firstParameters, secondParameters) => {
12
13
  if (typeof firstParameters === 'object' && typeof secondParameters === 'object' && firstParameters !== null && secondParameters !== null) {
13
14
  const firstKeys = Object.keys(firstParameters);
@@ -16,7 +17,18 @@ const areParametersEqual = (firstParameters, secondParameters) => {
16
17
  }
17
18
  return firstParameters === secondParameters;
18
19
  };
19
- export const getContextPanel = (allowAutoSave, featureFlags, applyChange) => state => {
20
+ export const duplicateSelection = (selectionToDuplicate, doc) => {
21
+ if (selectionToDuplicate instanceof NodeSelection) {
22
+ return NodeSelection.create(doc, selectionToDuplicate.from);
23
+ } else if (selectionToDuplicate instanceof TextSelection) {
24
+ return TextSelection.create(doc, selectionToDuplicate.from, selectionToDuplicate.to);
25
+ } else if (selectionToDuplicate instanceof GapCursorSelection) {
26
+ return new GapCursorSelection(doc.resolve(selectionToDuplicate.from), selectionToDuplicate.side);
27
+ } else if (selectionToDuplicate instanceof CellSelection) {
28
+ return new CellSelection(doc.resolve(selectionToDuplicate.$anchorCell.pos), doc.resolve(selectionToDuplicate.$headCell.pos));
29
+ }
30
+ };
31
+ export const getContextPanel = getEditorView => (allowAutoSave, featureFlags, applyChange) => state => {
20
32
  const nodeWithPos = getSelectedExtension(state, true);
21
33
 
22
34
  // Adding checks to bail out early
@@ -47,51 +59,47 @@ export const getContextPanel = (allowAutoSave, featureFlags, applyChange) => sta
47
59
  onSaveStarted,
48
60
  onSaveEnded
49
61
  }) => {
50
- return /*#__PURE__*/React.createElement(WithEditorActions, {
51
- render: actions => {
52
- const editorView = actions._privateGetEditorView();
53
- if (!editorView) {
54
- return null;
62
+ const editorView = getEditorView === null || getEditorView === void 0 ? void 0 : getEditorView();
63
+ if (!editorView) {
64
+ return null;
65
+ }
66
+ return /*#__PURE__*/React.createElement(ConfigPanelLoader, {
67
+ showHeader: true,
68
+ closeOnEsc: true,
69
+ extensionType: extensionType,
70
+ extensionKey: extKey,
71
+ nodeKey: nodeKey,
72
+ extensionParameters: parameters,
73
+ parameters: configParams,
74
+ extensionProvider: extensionProvider,
75
+ autoSave: allowAutoSave,
76
+ autoSaveTrigger: autoSaveResolve,
77
+ autoSaveReject: autoSaveReject,
78
+ onChange: async updatedParameters => {
79
+ await onChangeAction(editorView, updatedParameters, parameters, nodeWithPos, onSaveStarted);
80
+ onSaveEnded();
81
+ if (autoSaveResolve) {
82
+ autoSaveResolve();
83
+ }
84
+ if (!allowAutoSave) {
85
+ clearEditingContext(applyChange)(editorView.state, editorView.dispatch);
86
+ }
87
+ },
88
+ onCancel: async () => {
89
+ if (allowAutoSave) {
90
+ try {
91
+ await new Promise((resolve, reject) => {
92
+ forceAutoSave(applyChange)(resolve, reject)(editorView.state, editorView.dispatch);
93
+ });
94
+ } catch (e) {
95
+ // Even if the save failed, we should proceed with closing the panel
96
+ // eslint-disable-next-line no-console
97
+ console.error(`Autosave failed with error`, e);
98
+ }
55
99
  }
56
- return /*#__PURE__*/React.createElement(ConfigPanelLoader, {
57
- showHeader: true,
58
- closeOnEsc: true,
59
- extensionType: extensionType,
60
- extensionKey: extKey,
61
- nodeKey: nodeKey,
62
- extensionParameters: parameters,
63
- parameters: configParams,
64
- extensionProvider: extensionProvider,
65
- autoSave: allowAutoSave,
66
- autoSaveTrigger: autoSaveResolve,
67
- autoSaveReject: autoSaveReject,
68
- onChange: async updatedParameters => {
69
- await onChangeAction(editorView, updatedParameters, parameters, nodeWithPos, onSaveStarted);
70
- onSaveEnded();
71
- if (autoSaveResolve) {
72
- autoSaveResolve();
73
- }
74
- if (!allowAutoSave) {
75
- clearEditingContext(applyChange)(editorView.state, editorView.dispatch);
76
- }
77
- },
78
- onCancel: async () => {
79
- if (allowAutoSave) {
80
- try {
81
- await new Promise((resolve, reject) => {
82
- forceAutoSave(applyChange)(resolve, reject)(editorView.state, editorView.dispatch);
83
- });
84
- } catch (e) {
85
- // Even if the save failed, we should proceed with closing the panel
86
- // eslint-disable-next-line no-console
87
- console.error(`Autosave failed with error`, e);
88
- }
89
- }
90
- clearEditingContext(applyChange)(editorView.state, editorView.dispatch);
91
- },
92
- featureFlags: featureFlags
93
- });
94
- }
100
+ clearEditingContext(applyChange)(editorView.state, editorView.dispatch);
101
+ },
102
+ featureFlags: featureFlags
95
103
  });
96
104
  });
97
105
  }
@@ -4,7 +4,7 @@ import { Fragment, Mark } from '@atlaskit/editor-prosemirror/model';
4
4
  import { NodeSelection, Selection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { insertMacroFromMacroBrowser } from './pm-plugins/macro/actions';
6
6
  import { pluginKey as macroPluginKey } from './pm-plugins/macro/plugin-key';
7
- import { nodeToJSON } from '../../utils';
7
+ import { nodeToJSON } from '@atlaskit/editor-common/utils';
8
8
  import { setEditingContextToContextPanel } from './commands';
9
9
  import { findNodePosWithLocalId, getDataConsumerMark, getNodeTypesReferenced, getSelectedExtension } from './utils';
10
10
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
@@ -97,7 +97,10 @@ const extensionPlugin = ({
97
97
  applyChangeToContextPanel: api === null || api === void 0 ? void 0 : (_api$contextPanel3 = api.contextPanel) === null || _api$contextPanel3 === void 0 ? void 0 : _api$contextPanel3.actions.applyChange,
98
98
  editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions
99
99
  }),
100
- contextPanel: getContextPanel(options.allowAutoSave, featureFlags, api === null || api === void 0 ? void 0 : (_api$contextPanel4 = api.contextPanel) === null || _api$contextPanel4 === void 0 ? void 0 : _api$contextPanel4.actions.applyChange)
100
+ contextPanel: getContextPanel(() => {
101
+ var _editorViewRef$curren;
102
+ return (_editorViewRef$curren = editorViewRef.current) !== null && _editorViewRef$curren !== void 0 ? _editorViewRef$curren : undefined;
103
+ })(options.allowAutoSave, featureFlags, api === null || api === void 0 ? void 0 : (_api$contextPanel4 = api.contextPanel) === null || _api$contextPanel4 === void 0 ? void 0 : _api$contextPanel4.actions.applyChange)
101
104
  }
102
105
  };
103
106
  };
@@ -1,4 +1,4 @@
1
- import { pluginFactory } from '../../utils/plugin-state-factory';
1
+ import { pluginFactory } from '@atlaskit/editor-common/utils';
2
2
  import reducer from './reducer';
3
3
  import { pluginKey } from './plugin-key';
4
4
  const factory = pluginFactory(pluginKey, reducer, {
@@ -4,8 +4,7 @@ import { safeInsert, replaceSelectedNode, findSelectedNodeOfType, replaceParentN
4
4
  import { getValidNode } from '@atlaskit/editor-common/validator';
5
5
  import { normaliseNestedLayout } from '@atlaskit/editor-common/insert';
6
6
  import { getPluginState as getExtensionPluginState } from '../../plugin-factory';
7
- import { ACTION, ACTION_SUBJECT, INPUT_METHOD, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
8
- import { TARGET_SELECTION_SOURCE } from '@atlaskit/editor-common/analytics';
7
+ import { ACTION, ACTION_SUBJECT, INPUT_METHOD, EVENT_TYPE, TARGET_SELECTION_SOURCE } from '@atlaskit/editor-common/analytics';
9
8
  import { pluginKey } from './plugin-key';
10
9
  export const insertMacroFromMacroBrowser = editorAnalyticsAPI => (macroProvider, macroNode, isEditing) => async view => {
11
10
  if (!macroProvider) {
@@ -1,7 +1,7 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
3
  import { uuid } from '@atlaskit/adf-schema';
4
- import { stepAddsOneOf } from '../../../utils/step';
4
+ import { stepAddsOneOf } from '@atlaskit/editor-common/utils';
5
5
  const pluginKey = new PluginKey('extensionUniqueIdPlugin');
6
6
  const createPlugin = () => new SafePlugin({
7
7
  // TODO: @see ED-8839
@@ -5,7 +5,7 @@ import EditIcon from '@atlaskit/icon/glyph/editor/edit';
5
5
  import FullWidthIcon from '@atlaskit/icon/glyph/editor/media-full-width';
6
6
  import WideIcon from '@atlaskit/icon/glyph/editor/media-wide';
7
7
  import CenterIcon from '@atlaskit/icon/glyph/editor/media-center';
8
- import commonMessages from '../../messages';
8
+ import commonMessages from '@atlaskit/editor-common/messages';
9
9
  import { editExtension } from './actions';
10
10
  import { getPluginState } from './pm-plugins/main';
11
11
  import { getSelectedExtension } from './utils';
@@ -1,6 +1,5 @@
1
1
  import { findParentNodeOfType, findSelectedNodeOfType, findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
2
- import { closestElement } from '../../utils/dom';
3
- import { findNodePosByLocalIds } from '../../utils/nodes-by-localIds';
2
+ import { findNodePosByLocalIds, closestElement } from '@atlaskit/editor-common/utils';
4
3
  export const getSelectedExtension = (state, searchParent = false) => {
5
4
  const {
6
5
  inlineExtension,
@@ -5,7 +5,7 @@ import reducer from './reducer';
5
5
  import { findReplacePluginKey } from './types';
6
6
  import { findMatches, createDecorations, removeDecorationsFromSet, findSearchIndex, removeMatchesFromSet, findDecorationFromMatch, isMatchAffectedByStep } from './utils';
7
7
  import { findUniqueItemsIn } from '../../utils/array';
8
- import { stepHasSlice } from '../../utils/step';
8
+ import { stepHasSlice } from '@atlaskit/editor-common/utils';
9
9
  export const initialState = {
10
10
  isActive: false,
11
11
  shouldFocus: false,
@@ -13,7 +13,7 @@ import { mediaStyles } from './media';
13
13
  import { layoutStyles } from './layout';
14
14
  import { panelStyles } from './panel';
15
15
  import { placeholderTextStyles } from '@atlaskit/editor-plugin-placeholder-text/styles';
16
- import { extensionStyles } from '../../plugins/extension/ui/styles';
16
+ import { extensionStyles } from './extension';
17
17
  import { expandStyles } from './expand';
18
18
  import { MediaSharedClassNames } from '@atlaskit/editor-common/styles';
19
19
  import { findReplaceStyles } from '../../plugins/find-replace/styles';
@@ -1,30 +1,3 @@
1
- export const findNodePosByLocalIds = (state, ids, option = {}) => {
2
- var _state$doc$attrs;
3
- if (ids.length === 0) {
4
- return [];
5
- }
6
- const nodes = [];
7
- const localIdSet = new Set(ids);
8
- if (option.includeDocNode && localIdSet.has((_state$doc$attrs = state.doc.attrs) === null || _state$doc$attrs === void 0 ? void 0 : _state$doc$attrs.localId)) {
9
- nodes.push({
10
- node: state.doc,
11
- pos: 0
12
- });
13
- }
14
- state.doc.descendants((node, pos) => {
15
- var _node$attrs;
16
- if (localIdSet.has((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId)) {
17
- nodes.push({
18
- node,
19
- pos
20
- });
21
- }
22
-
23
- // stop traversing once we found all the nodes
24
- return localIdSet.size !== nodes.length;
25
- });
26
- return nodes;
27
- };
28
1
  export const findNodePosByFragmentLocalIds = (state, ids) => {
29
2
  if (ids.length === 0) {
30
3
  return [];
@@ -1,6 +1,3 @@
1
- import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
2
- import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
3
- import { GapCursorSelection } from '@atlaskit/editor-common/selection';
4
1
  export { setNodeSelection, setTextSelection, setAllSelection, setCellSelection } from '@atlaskit/editor-common/utils';
5
2
 
6
3
  // checks if the given position is within the ProseMirror document
@@ -9,15 +6,4 @@ export const isValidPosition = (pos, state) => {
9
6
  return true;
10
7
  }
11
8
  return false;
12
- };
13
- export const duplicateSelection = (selectionToDuplicate, doc) => {
14
- if (selectionToDuplicate instanceof NodeSelection) {
15
- return NodeSelection.create(doc, selectionToDuplicate.from);
16
- } else if (selectionToDuplicate instanceof TextSelection) {
17
- return TextSelection.create(doc, selectionToDuplicate.from, selectionToDuplicate.to);
18
- } else if (selectionToDuplicate instanceof GapCursorSelection) {
19
- return new GapCursorSelection(doc.resolve(selectionToDuplicate.from), selectionToDuplicate.side);
20
- } else if (selectionToDuplicate instanceof CellSelection) {
21
- return new CellSelection(doc.resolve(selectionToDuplicate.$anchorCell.pos), doc.resolve(selectionToDuplicate.$headCell.pos));
22
- }
23
9
  };
@@ -1,2 +1,2 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "189.3.19";
2
+ export const version = "189.3.20";
@@ -6,10 +6,9 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
  import { Node } from '@atlaskit/editor-prosemirror/model';
7
7
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
8
8
  import { findParentNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
9
- import { analyticsEventKey, isEmptyDocument, processRawValue } from '@atlaskit/editor-common/utils';
9
+ import { analyticsEventKey, isEmptyDocument, processRawValue, findNodePosByLocalIds } from '@atlaskit/editor-common/utils';
10
10
  import { createDispatch } from '../event-dispatcher';
11
11
  import { getCollabProvider } from '../plugins/collab-edit/native-collab-provider-plugin';
12
- import { findNodePosWithLocalId } from '../plugins/extension/utils';
13
12
  import { toJSON } from '../utils';
14
13
  import { __temporaryFixForConfigPanel as _temporaryFixForConfigPanel, getEditorValueWithMedia } from '../utils/action';
15
14
  import deprecationWarnings from '../utils/deprecation-warnings';
@@ -255,8 +254,10 @@ var EditorActions = /*#__PURE__*/function () {
255
254
  value: function getNodeByLocalId(id) {
256
255
  var _this$editorView;
257
256
  if ((_this$editorView = this.editorView) !== null && _this$editorView !== void 0 && _this$editorView.state) {
258
- var _findNodePosWithLocal, _this$editorView2;
259
- return (_findNodePosWithLocal = findNodePosWithLocalId((_this$editorView2 = this.editorView) === null || _this$editorView2 === void 0 ? void 0 : _this$editorView2.state, id)) === null || _findNodePosWithLocal === void 0 ? void 0 : _findNodePosWithLocal.node;
257
+ var _this$editorView2;
258
+ var nodes = findNodePosByLocalIds((_this$editorView2 = this.editorView) === null || _this$editorView2 === void 0 ? void 0 : _this$editorView2.state, [id]);
259
+ var node = nodes.length >= 1 ? nodes[0] : undefined;
260
+ return node === null || node === void 0 ? void 0 : node.node;
260
261
  }
261
262
  }
262
263
  }, {
@@ -7,7 +7,7 @@ import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
7
7
  import CodeBidiWarning from '@atlaskit/code/bidi-warning';
8
8
  import codeBidiWarningDecorator from '@atlaskit/code/bidi-warning-decorator';
9
9
  import { pluginFactory } from '../../../utils/plugin-state-factory';
10
- import { stepHasSlice } from '../../../utils/step';
10
+ import { stepHasSlice } from '@atlaskit/editor-common/utils';
11
11
  import { codeBidiWarningPluginKey } from '../plugin-key';
12
12
  import reducer from './reducer';
13
13
  var _pluginFactory = pluginFactory(codeBidiWarningPluginKey, reducer, {
@@ -9,12 +9,13 @@ import React from 'react';
9
9
  import { getExtensionKeyAndNodeKey } from '@atlaskit/editor-common/extensions';
10
10
  import { getPluginState } from './pm-plugins/main';
11
11
  import { getSelectedExtension } from './utils';
12
- import WithEditorActions from '../../ui/WithEditorActions';
13
12
  import ConfigPanelLoader from '../../ui/ConfigPanel/ConfigPanelLoader';
14
- import { duplicateSelection } from '../../utils/selection';
15
13
  import { clearEditingContext, forceAutoSave, updateState } from './commands';
16
14
  import { buildExtensionNode } from './actions';
17
15
  import { SaveIndicator } from './ui/SaveIndicator/SaveIndicator';
16
+ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
17
+ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
18
+ import { GapCursorSelection } from '@atlaskit/editor-common/selection';
18
19
  var areParametersEqual = function areParametersEqual(firstParameters, secondParameters) {
19
20
  if (_typeof(firstParameters) === 'object' && _typeof(secondParameters) === 'object' && firstParameters !== null && secondParameters !== null) {
20
21
  var firstKeys = Object.keys(firstParameters);
@@ -25,116 +26,125 @@ var areParametersEqual = function areParametersEqual(firstParameters, secondPara
25
26
  }
26
27
  return firstParameters === secondParameters;
27
28
  };
28
- export var getContextPanel = function getContextPanel(allowAutoSave, featureFlags, applyChange) {
29
- return function (state) {
30
- var nodeWithPos = getSelectedExtension(state, true);
29
+ export var duplicateSelection = function duplicateSelection(selectionToDuplicate, doc) {
30
+ if (selectionToDuplicate instanceof NodeSelection) {
31
+ return NodeSelection.create(doc, selectionToDuplicate.from);
32
+ } else if (selectionToDuplicate instanceof TextSelection) {
33
+ return TextSelection.create(doc, selectionToDuplicate.from, selectionToDuplicate.to);
34
+ } else if (selectionToDuplicate instanceof GapCursorSelection) {
35
+ return new GapCursorSelection(doc.resolve(selectionToDuplicate.from), selectionToDuplicate.side);
36
+ } else if (selectionToDuplicate instanceof CellSelection) {
37
+ return new CellSelection(doc.resolve(selectionToDuplicate.$anchorCell.pos), doc.resolve(selectionToDuplicate.$headCell.pos));
38
+ }
39
+ };
40
+ export var getContextPanel = function getContextPanel(getEditorView) {
41
+ return function (allowAutoSave, featureFlags, applyChange) {
42
+ return function (state) {
43
+ var nodeWithPos = getSelectedExtension(state, true);
31
44
 
32
- // Adding checks to bail out early
33
- if (!nodeWithPos) {
34
- return;
35
- }
36
- var extensionState = getPluginState(state);
37
- var autoSaveResolve = extensionState.autoSaveResolve,
38
- autoSaveReject = extensionState.autoSaveReject,
39
- showContextPanel = extensionState.showContextPanel,
40
- extensionProvider = extensionState.extensionProvider,
41
- processParametersBefore = extensionState.processParametersBefore,
42
- processParametersAfter = extensionState.processParametersAfter;
43
- if (extensionState && showContextPanel && extensionProvider && processParametersAfter) {
44
- var _nodeWithPos$node$att = nodeWithPos.node.attrs,
45
- extensionType = _nodeWithPos$node$att.extensionType,
46
- extensionKey = _nodeWithPos$node$att.extensionKey,
47
- parameters = _nodeWithPos$node$att.parameters;
48
- var _getExtensionKeyAndNo = getExtensionKeyAndNodeKey(extensionKey, extensionType),
49
- _getExtensionKeyAndNo2 = _slicedToArray(_getExtensionKeyAndNo, 2),
50
- extKey = _getExtensionKeyAndNo2[0],
51
- nodeKey = _getExtensionKeyAndNo2[1];
52
- var configParams = processParametersBefore ? processParametersBefore(parameters || {}) : parameters;
53
- return /*#__PURE__*/React.createElement(SaveIndicator, {
54
- duration: 5000,
55
- visible: allowAutoSave
56
- }, function (_ref) {
57
- var onSaveStarted = _ref.onSaveStarted,
58
- onSaveEnded = _ref.onSaveEnded;
59
- return /*#__PURE__*/React.createElement(WithEditorActions, {
60
- render: function render(actions) {
61
- var editorView = actions._privateGetEditorView();
62
- if (!editorView) {
63
- return null;
64
- }
65
- return /*#__PURE__*/React.createElement(ConfigPanelLoader, {
66
- showHeader: true,
67
- closeOnEsc: true,
68
- extensionType: extensionType,
69
- extensionKey: extKey,
70
- nodeKey: nodeKey,
71
- extensionParameters: parameters,
72
- parameters: configParams,
73
- extensionProvider: extensionProvider,
74
- autoSave: allowAutoSave,
75
- autoSaveTrigger: autoSaveResolve,
76
- autoSaveReject: autoSaveReject,
77
- onChange: /*#__PURE__*/function () {
78
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(updatedParameters) {
79
- return _regeneratorRuntime.wrap(function _callee$(_context) {
80
- while (1) switch (_context.prev = _context.next) {
81
- case 0:
82
- _context.next = 2;
83
- return onChangeAction(editorView, updatedParameters, parameters, nodeWithPos, onSaveStarted);
84
- case 2:
85
- onSaveEnded();
86
- if (autoSaveResolve) {
87
- autoSaveResolve();
88
- }
89
- if (!allowAutoSave) {
90
- clearEditingContext(applyChange)(editorView.state, editorView.dispatch);
91
- }
92
- case 5:
93
- case "end":
94
- return _context.stop();
95
- }
96
- }, _callee);
97
- }));
98
- return function (_x) {
99
- return _ref2.apply(this, arguments);
100
- };
101
- }(),
102
- onCancel: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
103
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
104
- while (1) switch (_context2.prev = _context2.next) {
45
+ // Adding checks to bail out early
46
+ if (!nodeWithPos) {
47
+ return;
48
+ }
49
+ var extensionState = getPluginState(state);
50
+ var autoSaveResolve = extensionState.autoSaveResolve,
51
+ autoSaveReject = extensionState.autoSaveReject,
52
+ showContextPanel = extensionState.showContextPanel,
53
+ extensionProvider = extensionState.extensionProvider,
54
+ processParametersBefore = extensionState.processParametersBefore,
55
+ processParametersAfter = extensionState.processParametersAfter;
56
+ if (extensionState && showContextPanel && extensionProvider && processParametersAfter) {
57
+ var _nodeWithPos$node$att = nodeWithPos.node.attrs,
58
+ extensionType = _nodeWithPos$node$att.extensionType,
59
+ extensionKey = _nodeWithPos$node$att.extensionKey,
60
+ parameters = _nodeWithPos$node$att.parameters;
61
+ var _getExtensionKeyAndNo = getExtensionKeyAndNodeKey(extensionKey, extensionType),
62
+ _getExtensionKeyAndNo2 = _slicedToArray(_getExtensionKeyAndNo, 2),
63
+ extKey = _getExtensionKeyAndNo2[0],
64
+ nodeKey = _getExtensionKeyAndNo2[1];
65
+ var configParams = processParametersBefore ? processParametersBefore(parameters || {}) : parameters;
66
+ return /*#__PURE__*/React.createElement(SaveIndicator, {
67
+ duration: 5000,
68
+ visible: allowAutoSave
69
+ }, function (_ref) {
70
+ var onSaveStarted = _ref.onSaveStarted,
71
+ onSaveEnded = _ref.onSaveEnded;
72
+ var editorView = getEditorView === null || getEditorView === void 0 ? void 0 : getEditorView();
73
+ if (!editorView) {
74
+ return null;
75
+ }
76
+ return /*#__PURE__*/React.createElement(ConfigPanelLoader, {
77
+ showHeader: true,
78
+ closeOnEsc: true,
79
+ extensionType: extensionType,
80
+ extensionKey: extKey,
81
+ nodeKey: nodeKey,
82
+ extensionParameters: parameters,
83
+ parameters: configParams,
84
+ extensionProvider: extensionProvider,
85
+ autoSave: allowAutoSave,
86
+ autoSaveTrigger: autoSaveResolve,
87
+ autoSaveReject: autoSaveReject,
88
+ onChange: /*#__PURE__*/function () {
89
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(updatedParameters) {
90
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
91
+ while (1) switch (_context.prev = _context.next) {
105
92
  case 0:
93
+ _context.next = 2;
94
+ return onChangeAction(editorView, updatedParameters, parameters, nodeWithPos, onSaveStarted);
95
+ case 2:
96
+ onSaveEnded();
97
+ if (autoSaveResolve) {
98
+ autoSaveResolve();
99
+ }
106
100
  if (!allowAutoSave) {
107
- _context2.next = 9;
108
- break;
101
+ clearEditingContext(applyChange)(editorView.state, editorView.dispatch);
109
102
  }
110
- _context2.prev = 1;
111
- _context2.next = 4;
112
- return new Promise(function (resolve, reject) {
113
- forceAutoSave(applyChange)(resolve, reject)(editorView.state, editorView.dispatch);
114
- });
115
- case 4:
116
- _context2.next = 9;
117
- break;
118
- case 6:
119
- _context2.prev = 6;
120
- _context2.t0 = _context2["catch"](1);
121
- // Even if the save failed, we should proceed with closing the panel
122
- // eslint-disable-next-line no-console
123
- console.error("Autosave failed with error", _context2.t0);
124
- case 9:
125
- clearEditingContext(applyChange)(editorView.state, editorView.dispatch);
126
- case 10:
103
+ case 5:
127
104
  case "end":
128
- return _context2.stop();
105
+ return _context.stop();
129
106
  }
130
- }, _callee2, null, [[1, 6]]);
131
- })),
132
- featureFlags: featureFlags
133
- });
134
- }
107
+ }, _callee);
108
+ }));
109
+ return function (_x) {
110
+ return _ref2.apply(this, arguments);
111
+ };
112
+ }(),
113
+ onCancel: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
114
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
115
+ while (1) switch (_context2.prev = _context2.next) {
116
+ case 0:
117
+ if (!allowAutoSave) {
118
+ _context2.next = 9;
119
+ break;
120
+ }
121
+ _context2.prev = 1;
122
+ _context2.next = 4;
123
+ return new Promise(function (resolve, reject) {
124
+ forceAutoSave(applyChange)(resolve, reject)(editorView.state, editorView.dispatch);
125
+ });
126
+ case 4:
127
+ _context2.next = 9;
128
+ break;
129
+ case 6:
130
+ _context2.prev = 6;
131
+ _context2.t0 = _context2["catch"](1);
132
+ // Even if the save failed, we should proceed with closing the panel
133
+ // eslint-disable-next-line no-console
134
+ console.error("Autosave failed with error", _context2.t0);
135
+ case 9:
136
+ clearEditingContext(applyChange)(editorView.state, editorView.dispatch);
137
+ case 10:
138
+ case "end":
139
+ return _context2.stop();
140
+ }
141
+ }, _callee2, null, [[1, 6]]);
142
+ })),
143
+ featureFlags: featureFlags
144
+ });
135
145
  });
136
- });
137
- }
146
+ }
147
+ };
138
148
  };
139
149
  };
140
150
  export function onChangeAction(_x2) {
@@ -5,7 +5,7 @@ import { Fragment, Mark } from '@atlaskit/editor-prosemirror/model';
5
5
  import { NodeSelection, Selection } from '@atlaskit/editor-prosemirror/state';
6
6
  import { insertMacroFromMacroBrowser } from './pm-plugins/macro/actions';
7
7
  import { pluginKey as macroPluginKey } from './pm-plugins/macro/plugin-key';
8
- import { nodeToJSON } from '../../utils';
8
+ import { nodeToJSON } from '@atlaskit/editor-common/utils';
9
9
  import { setEditingContextToContextPanel } from './commands';
10
10
  import { findNodePosWithLocalId, getDataConsumerMark, getNodeTypesReferenced, getSelectedExtension } from './utils';
11
11
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
@@ -99,7 +99,10 @@ var extensionPlugin = function extensionPlugin(_ref) {
99
99
  applyChangeToContextPanel: _api === null || _api === void 0 || (_api$contextPanel3 = _api.contextPanel) === null || _api$contextPanel3 === void 0 ? void 0 : _api$contextPanel3.actions.applyChange,
100
100
  editorAnalyticsAPI: _api === null || _api === void 0 || (_api$analytics3 = _api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions
101
101
  }),
102
- contextPanel: getContextPanel(options.allowAutoSave, featureFlags, _api === null || _api === void 0 || (_api$contextPanel4 = _api.contextPanel) === null || _api$contextPanel4 === void 0 ? void 0 : _api$contextPanel4.actions.applyChange)
102
+ contextPanel: getContextPanel(function () {
103
+ var _editorViewRef$curren;
104
+ return (_editorViewRef$curren = editorViewRef.current) !== null && _editorViewRef$curren !== void 0 ? _editorViewRef$curren : undefined;
105
+ })(options.allowAutoSave, featureFlags, _api === null || _api === void 0 || (_api$contextPanel4 = _api.contextPanel) === null || _api$contextPanel4 === void 0 ? void 0 : _api$contextPanel4.actions.applyChange)
103
106
  }
104
107
  };
105
108
  };
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  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
3
  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
- import { pluginFactory } from '../../utils/plugin-state-factory';
4
+ import { pluginFactory } from '@atlaskit/editor-common/utils';
5
5
  import reducer from './reducer';
6
6
  import { pluginKey } from './plugin-key';
7
7
  var factory = pluginFactory(pluginKey, reducer, {
@@ -9,8 +9,7 @@ import { safeInsert, replaceSelectedNode, findSelectedNodeOfType, replaceParentN
9
9
  import { getValidNode } from '@atlaskit/editor-common/validator';
10
10
  import { normaliseNestedLayout } from '@atlaskit/editor-common/insert';
11
11
  import { getPluginState as getExtensionPluginState } from '../../plugin-factory';
12
- import { ACTION, ACTION_SUBJECT, INPUT_METHOD, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
13
- import { TARGET_SELECTION_SOURCE } from '@atlaskit/editor-common/analytics';
12
+ import { ACTION, ACTION_SUBJECT, INPUT_METHOD, EVENT_TYPE, TARGET_SELECTION_SOURCE } from '@atlaskit/editor-common/analytics';
14
13
  import { pluginKey } from './plugin-key';
15
14
  export var insertMacroFromMacroBrowser = function insertMacroFromMacroBrowser(editorAnalyticsAPI) {
16
15
  return function (macroProvider, macroNode, isEditing) {
@@ -4,7 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
5
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
6
6
  import { uuid } from '@atlaskit/adf-schema';
7
- import { stepAddsOneOf } from '../../../utils/step';
7
+ import { stepAddsOneOf } from '@atlaskit/editor-common/utils';
8
8
  var pluginKey = new PluginKey('extensionUniqueIdPlugin');
9
9
  var createPlugin = function createPlugin() {
10
10
  return new SafePlugin({
@@ -6,7 +6,7 @@ import EditIcon from '@atlaskit/icon/glyph/editor/edit';
6
6
  import FullWidthIcon from '@atlaskit/icon/glyph/editor/media-full-width';
7
7
  import WideIcon from '@atlaskit/icon/glyph/editor/media-wide';
8
8
  import CenterIcon from '@atlaskit/icon/glyph/editor/media-center';
9
- import commonMessages from '../../messages';
9
+ import commonMessages from '@atlaskit/editor-common/messages';
10
10
  import { editExtension } from './actions';
11
11
  import { getPluginState } from './pm-plugins/main';
12
12
  import { getSelectedExtension } from './utils';