@atlaskit/editor-plugin-synced-block 5.3.13 → 5.3.14

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 (34) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/editor-commands/index.js +7 -5
  3. package/dist/cjs/pm-plugins/main.js +87 -25
  4. package/dist/cjs/pm-plugins/utils/handle-bodied-sync-block-creation.js +141 -0
  5. package/dist/cjs/pm-plugins/utils/track-sync-blocks.js +1 -0
  6. package/dist/cjs/syncedBlockPlugin.js +4 -2
  7. package/dist/cjs/types/index.js +1 -0
  8. package/dist/cjs/ui/Flag.js +5 -1
  9. package/dist/cjs/ui/floating-toolbar.js +3 -0
  10. package/dist/es2019/editor-commands/index.js +7 -5
  11. package/dist/es2019/pm-plugins/main.js +67 -17
  12. package/dist/es2019/pm-plugins/utils/handle-bodied-sync-block-creation.js +134 -0
  13. package/dist/es2019/pm-plugins/utils/track-sync-blocks.js +1 -0
  14. package/dist/es2019/syncedBlockPlugin.js +4 -2
  15. package/dist/es2019/types/index.js +1 -0
  16. package/dist/es2019/ui/Flag.js +5 -0
  17. package/dist/es2019/ui/floating-toolbar.js +3 -0
  18. package/dist/esm/editor-commands/index.js +7 -5
  19. package/dist/esm/pm-plugins/main.js +87 -25
  20. package/dist/esm/pm-plugins/utils/handle-bodied-sync-block-creation.js +134 -0
  21. package/dist/esm/pm-plugins/utils/track-sync-blocks.js +1 -0
  22. package/dist/esm/syncedBlockPlugin.js +4 -2
  23. package/dist/esm/types/index.js +1 -0
  24. package/dist/esm/ui/Flag.js +5 -1
  25. package/dist/esm/ui/floating-toolbar.js +3 -0
  26. package/dist/types/pm-plugins/main.d.ts +2 -1
  27. package/dist/types/pm-plugins/utils/handle-bodied-sync-block-creation.d.ts +9 -0
  28. package/dist/types/pm-plugins/utils/handle-bodied-sync-block-removal.d.ts +2 -2
  29. package/dist/types/types/index.d.ts +19 -1
  30. package/dist/types-ts4.5/pm-plugins/main.d.ts +2 -1
  31. package/dist/types-ts4.5/pm-plugins/utils/handle-bodied-sync-block-creation.d.ts +9 -0
  32. package/dist/types-ts4.5/pm-plugins/utils/handle-bodied-sync-block-removal.d.ts +2 -2
  33. package/dist/types-ts4.5/types/index.d.ts +19 -1
  34. package/package.json +1 -1
@@ -0,0 +1,134 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
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
+ 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 { TextSelection } from '@atlaskit/editor-prosemirror/state';
5
+ import { FLAG_ID } from '../../types';
6
+ import { syncedBlockPluginKey } from '../main';
7
+ var onRetry = function onRetry(api, resourceId) {
8
+ return function () {
9
+ var _api$core, _api$core2;
10
+ api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.focus();
11
+ api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref) {
12
+ var _api$syncedBlock, _api$syncedBlock2;
13
+ var tr = _ref.tr;
14
+ var pos = api === null || api === void 0 || (_api$syncedBlock = api.syncedBlock) === null || _api$syncedBlock === void 0 || (_api$syncedBlock = _api$syncedBlock.sharedState.currentState()) === null || _api$syncedBlock === void 0 || (_api$syncedBlock = _api$syncedBlock.retryCreationPosMap) === null || _api$syncedBlock === void 0 ? void 0 : _api$syncedBlock.get(resourceId);
15
+ var from = pos === null || pos === void 0 ? void 0 : pos.from;
16
+ var to = pos === null || pos === void 0 ? void 0 : pos.to;
17
+ if (from === undefined || to === undefined) {
18
+ return tr;
19
+ }
20
+ tr.setSelection(TextSelection.create(tr.doc, from, to)).setMeta(syncedBlockPluginKey, {
21
+ activeFlag: false
22
+ });
23
+ api === null || api === void 0 || (_api$syncedBlock2 = api.syncedBlock) === null || _api$syncedBlock2 === void 0 || _api$syncedBlock2.commands.insertSyncedBlock()({
24
+ tr: tr
25
+ });
26
+ return tr;
27
+ });
28
+ };
29
+ };
30
+ var getRevertCreationPos = function getRevertCreationPos(api, doc, resourceId) {
31
+ var _api$syncedBlock3;
32
+ var retryCreationPos = api === null || api === void 0 || (_api$syncedBlock3 = api.syncedBlock) === null || _api$syncedBlock3 === void 0 || (_api$syncedBlock3 = _api$syncedBlock3.sharedState.currentState()) === null || _api$syncedBlock3 === void 0 || (_api$syncedBlock3 = _api$syncedBlock3.retryCreationPosMap) === null || _api$syncedBlock3 === void 0 ? void 0 : _api$syncedBlock3.get(resourceId);
33
+ if (retryCreationPos) {
34
+ return retryCreationPos;
35
+ }
36
+
37
+ // Fallback to find the positions in case BE call returns before plugin state becomes available
38
+ // which is highly unlikely
39
+ var currentPos;
40
+ doc.descendants(function (node, pos) {
41
+ if (currentPos) {
42
+ return false;
43
+ }
44
+ if (node.type.name === 'bodiedSyncBlock' && resourceId === node.attrs.resourceId) {
45
+ currentPos = {
46
+ from: pos,
47
+ to: pos + node.nodeSize
48
+ };
49
+ return false;
50
+ }
51
+ });
52
+ return currentPos;
53
+ };
54
+ var buildRevertCreationTr = function buildRevertCreationTr(tr, pos) {
55
+ var _tr$doc$nodeAt;
56
+ var content = (_tr$doc$nodeAt = tr.doc.nodeAt(pos.from)) === null || _tr$doc$nodeAt === void 0 ? void 0 : _tr$doc$nodeAt.content;
57
+ if (content) {
58
+ tr.replaceWith(pos.from, pos.to, content);
59
+ var contentFrom = tr.mapping.map(pos.from);
60
+ tr.setSelection(TextSelection.create(tr.doc, contentFrom, contentFrom + content.size));
61
+ } else {
62
+ tr.delete(pos.from, pos.to);
63
+ }
64
+ return tr;
65
+ };
66
+
67
+ /**
68
+ *
69
+ * Save the new bodiedSyncBlock to backend with empty content and handles revert (if failed) and retry flow
70
+ */
71
+ export var handleBodiedSyncBlockCreation = function handleBodiedSyncBlockCreation(bodiedSyncBlockAdded, editorState, api) {
72
+ var syncBlockStore = syncedBlockPluginKey.getState(editorState).syncBlockStore;
73
+ bodiedSyncBlockAdded.forEach(function (node) {
74
+ if (node.from === undefined || node.to === undefined) {
75
+ return;
76
+ }
77
+ var retryCreationPos = {
78
+ from: node.from,
79
+ to: node.to
80
+ };
81
+ var resourceId = node.attrs.resourceId;
82
+ setTimeout(function () {
83
+ var _api$core3;
84
+ api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref2) {
85
+ var tr = _ref2.tr;
86
+ return tr.setMeta(syncedBlockPluginKey, {
87
+ retryCreationPos: {
88
+ resourceId: resourceId,
89
+ pos: retryCreationPos
90
+ }
91
+ });
92
+ });
93
+ });
94
+ syncBlockStore.sourceManager.createBodiedSyncBlockNode(node.attrs, function (success) {
95
+ if (success) {
96
+ var _api$core4, _api$core5;
97
+ api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(function (_ref3) {
98
+ var tr = _ref3.tr;
99
+ return tr.setMeta(syncedBlockPluginKey, {
100
+ retryCreationPos: {
101
+ resourceId: resourceId,
102
+ pos: undefined
103
+ }
104
+ });
105
+ });
106
+ api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.focus();
107
+ } else {
108
+ var _api$core6;
109
+ api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.execute(function (_ref4) {
110
+ var tr = _ref4.tr;
111
+ var revertCreationPos = getRevertCreationPos(api, tr.doc, resourceId);
112
+ if (!revertCreationPos) {
113
+ return tr;
114
+ }
115
+ var revertTr = buildRevertCreationTr(tr, revertCreationPos);
116
+ return revertTr.setMeta('isConfirmedSyncBlockDeletion', true).setMeta('addToHistory', false).setMeta(syncedBlockPluginKey, {
117
+ activeFlag: {
118
+ id: FLAG_ID.CANNOT_CREATE_SYNC_BLOCK,
119
+ onRetry: onRetry(api, resourceId),
120
+ onDismissed: function onDismissed(tr) {
121
+ return tr.setMeta(syncedBlockPluginKey, _objectSpread(_objectSpread({}, tr.getMeta(syncedBlockPluginKey)), {}, {
122
+ retryCreationPos: {
123
+ resourceId: resourceId,
124
+ pos: undefined
125
+ }
126
+ }));
127
+ }
128
+ }
129
+ });
130
+ });
131
+ }
132
+ }, node.node);
133
+ });
134
+ };
@@ -69,6 +69,7 @@ export var trackSyncBlocks = function trackSyncBlocks(predicate, tr, state) {
69
69
  var syncBlockAttr = node.attrs;
70
70
  syncBlockMapNew[syncBlockAttr.localId] = {
71
71
  attrs: syncBlockAttr,
72
+ node: node,
72
73
  from: offset,
73
74
  to: offset + node.nodeSize
74
75
  };
@@ -143,11 +143,13 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
143
143
  var _syncedBlockPluginKey = syncedBlockPluginKey.getState(editorState),
144
144
  activeFlag = _syncedBlockPluginKey.activeFlag,
145
145
  currentSyncBlockStore = _syncedBlockPluginKey.syncBlockStore,
146
- bodiedSyncBlockDeletionStatus = _syncedBlockPluginKey.bodiedSyncBlockDeletionStatus;
146
+ bodiedSyncBlockDeletionStatus = _syncedBlockPluginKey.bodiedSyncBlockDeletionStatus,
147
+ retryCreationPosMap = _syncedBlockPluginKey.retryCreationPosMap;
147
148
  return {
148
149
  activeFlag: activeFlag,
149
150
  syncBlockStore: currentSyncBlockStore,
150
- bodiedSyncBlockDeletionStatus: bodiedSyncBlockDeletionStatus
151
+ bodiedSyncBlockDeletionStatus: bodiedSyncBlockDeletionStatus,
152
+ retryCreationPosMap: retryCreationPosMap
151
153
  };
152
154
  }
153
155
  };
@@ -5,6 +5,7 @@ export var FLAG_ID = /*#__PURE__*/function (FLAG_ID) {
5
5
  FLAG_ID["FAIL_TO_DELETE"] = "fail-to-delete";
6
6
  FLAG_ID["SYNC_BLOCK_COPIED"] = "sync-block-copied";
7
7
  FLAG_ID["UNPUBLISHED_SYNC_BLOCK_PASTED"] = "unpublished-sync-block-pasted";
8
+ FLAG_ID["CANNOT_CREATE_SYNC_BLOCK"] = "cannot-create-sync-block";
8
9
  return FLAG_ID;
9
10
  }({});
10
11
  export var SYNCED_BLOCK_BUTTON_TEST_ID = {
@@ -11,7 +11,7 @@ import StatusSuccessIcon from '@atlaskit/icon/core/status-success';
11
11
  import StatusWarningIcon from '@atlaskit/icon/core/status-warning';
12
12
  import { syncedBlockPluginKey } from '../pm-plugins/main';
13
13
  import { FLAG_ID } from '../types';
14
- var flagMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE, {
14
+ var flagMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE, {
15
15
  title: messages.failToDeleteTitle,
16
16
  description: messages.failToDeleteWhenOfflineDescription,
17
17
  type: 'error'
@@ -34,6 +34,10 @@ var flagMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_d
34
34
  title: messages.unpublishedSyncBlockPastedTitle,
35
35
  description: messages.unpublishedSyncBlockPastedDescription,
36
36
  type: 'info'
37
+ }), FLAG_ID.CANNOT_CREATE_SYNC_BLOCK, {
38
+ title: messages.cannotCreateSyncBlockTitle,
39
+ description: messages.CannotCreateSyncBlockDescription,
40
+ type: 'error'
37
41
  });
38
42
  export var Flag = function Flag(_ref) {
39
43
  var api = _ref.api;
@@ -23,6 +23,9 @@ export var getToolbarConfig = function getToolbarConfig(state, intl, api, syncBl
23
23
  if (!syncBlockObject) {
24
24
  return;
25
25
  }
26
+ if (syncBlockStore.sourceManager.isPendingCreation(syncBlockObject.node.attrs.resourceId) && fg('platform_synced_block_patch_1')) {
27
+ return;
28
+ }
26
29
  var syncBlockInstance = syncBlockStore.referenceManager.getFromCache(syncBlockObject.node.attrs.resourceId);
27
30
  var isUnsyncedBlock = (syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$er = syncBlockInstance.error) === null || _syncBlockInstance$er === void 0 ? void 0 : _syncBlockInstance$er.type) === SyncBlockError.NotFound;
28
31
  var isErroredBlock = syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error;
@@ -4,11 +4,12 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
4
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
5
5
  import { type SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
6
6
  import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlockPluginType';
7
- import { type ActiveFlag, type BodiedSyncBlockDeletionStatus } from '../types';
7
+ import { type ActiveFlag, type BodiedSyncBlockDeletionStatus, type RetryCreationPosMap } from '../types';
8
8
  export declare const syncedBlockPluginKey: PluginKey<any>;
9
9
  type SyncedBlockPluginState = {
10
10
  activeFlag: ActiveFlag;
11
11
  bodiedSyncBlockDeletionStatus?: BodiedSyncBlockDeletionStatus;
12
+ retryCreationPosMap: RetryCreationPosMap;
12
13
  selectionDecorationSet: DecorationSet;
13
14
  syncBlockStore: SyncBlockStoreManager;
14
15
  };
@@ -0,0 +1,9 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import { type EditorState } from '@atlaskit/editor-prosemirror/state';
3
+ import type { SyncedBlockPlugin } from '../../syncedBlockPluginType';
4
+ import { type SyncBlockInfo } from '../../types';
5
+ /**
6
+ *
7
+ * Save the new bodiedSyncBlock to backend with empty content and handles revert (if failed) and retry flow
8
+ */
9
+ export declare const handleBodiedSyncBlockCreation: (bodiedSyncBlockAdded: SyncBlockInfo[], editorState: EditorState, api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined) => void;
@@ -3,7 +3,7 @@ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { DeletionReason, SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
4
4
  import type { SyncedBlockPlugin } from '../../syncedBlockPluginType';
5
5
  import { type SyncBlockInfo } from '../../types';
6
- export type ConfirmationTransactionRef = {
6
+ export type TransactionRef = {
7
7
  current: Transaction | undefined;
8
8
  };
9
- export declare const handleBodiedSyncBlockRemoval: (bodiedSyncBlockRemoved: SyncBlockInfo[], syncBlockStore: SyncBlockStoreManager, api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined, confirmationTransactionRef: ConfirmationTransactionRef, deletionReason: DeletionReason) => boolean;
9
+ export declare const handleBodiedSyncBlockRemoval: (bodiedSyncBlockRemoved: SyncBlockInfo[], syncBlockStore: SyncBlockStoreManager, api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined, confirmationTransactionRef: TransactionRef, deletionReason: DeletionReason) => boolean;
@@ -1,3 +1,4 @@
1
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
1
2
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
3
  import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
3
4
  export declare enum FLAG_ID {
@@ -6,7 +7,8 @@ export declare enum FLAG_ID {
6
7
  CANNOT_CREATE_WHEN_OFFLINE = "cannot-create-when-offline",
7
8
  FAIL_TO_DELETE = "fail-to-delete",
8
9
  SYNC_BLOCK_COPIED = "sync-block-copied",
9
- UNPUBLISHED_SYNC_BLOCK_PASTED = "unpublished-sync-block-pasted"
10
+ UNPUBLISHED_SYNC_BLOCK_PASTED = "unpublished-sync-block-pasted",
11
+ CANNOT_CREATE_SYNC_BLOCK = "cannot-create-sync-block"
10
12
  }
11
13
  type FlagConfig = {
12
14
  id: FLAG_ID;
@@ -15,6 +17,15 @@ type FlagConfig = {
15
17
  };
16
18
  export type BodiedSyncBlockDeletionStatus = 'none' | 'processing' | 'completed';
17
19
  export type ActiveFlag = FlagConfig | false;
20
+ type RetryCreationPos = {
21
+ from: number;
22
+ to: number;
23
+ };
24
+ export type RetryCreationPosMap = Map<string, RetryCreationPos>;
25
+ export type RetryCreationPosEntry = {
26
+ pos?: RetryCreationPos;
27
+ resourceId: string;
28
+ };
18
29
  export type SyncedBlockSharedState = {
19
30
  /**
20
31
  * Whether to show a flag (usually for errors, e.g. fail to delete)
@@ -24,6 +35,12 @@ export type SyncedBlockSharedState = {
24
35
  * Whether the plugin is currently saving bodiedSyncBlock deletion to backend
25
36
  */
26
37
  bodiedSyncBlockDeletionStatus?: BodiedSyncBlockDeletionStatus;
38
+ /**
39
+ * Positions of pending creations keyed by resourceId, used for retry/revert flow.
40
+ * When a new bodiedSyncBlock is added, a new entry is added to map for mapping. The entry is removed when creation succeeds or retry option is dismissed.
41
+ *
42
+ */
43
+ retryCreationPosMap?: RetryCreationPosMap;
27
44
  /**
28
45
  * The current sync block store manager, used to manage fetching and updating sync block data
29
46
  */
@@ -36,6 +53,7 @@ export type SyncBlockAttrs = {
36
53
  export type SyncBlockInfo = {
37
54
  attrs: SyncBlockAttrs;
38
55
  from?: number;
56
+ node?: PMNode;
39
57
  to?: number;
40
58
  };
41
59
  export type SyncBlockMap = {
@@ -4,11 +4,12 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
4
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
5
5
  import { type SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
6
6
  import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlockPluginType';
7
- import { type ActiveFlag, type BodiedSyncBlockDeletionStatus } from '../types';
7
+ import { type ActiveFlag, type BodiedSyncBlockDeletionStatus, type RetryCreationPosMap } from '../types';
8
8
  export declare const syncedBlockPluginKey: PluginKey<any>;
9
9
  type SyncedBlockPluginState = {
10
10
  activeFlag: ActiveFlag;
11
11
  bodiedSyncBlockDeletionStatus?: BodiedSyncBlockDeletionStatus;
12
+ retryCreationPosMap: RetryCreationPosMap;
12
13
  selectionDecorationSet: DecorationSet;
13
14
  syncBlockStore: SyncBlockStoreManager;
14
15
  };
@@ -0,0 +1,9 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import { type EditorState } from '@atlaskit/editor-prosemirror/state';
3
+ import type { SyncedBlockPlugin } from '../../syncedBlockPluginType';
4
+ import { type SyncBlockInfo } from '../../types';
5
+ /**
6
+ *
7
+ * Save the new bodiedSyncBlock to backend with empty content and handles revert (if failed) and retry flow
8
+ */
9
+ export declare const handleBodiedSyncBlockCreation: (bodiedSyncBlockAdded: SyncBlockInfo[], editorState: EditorState, api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined) => void;
@@ -3,7 +3,7 @@ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { DeletionReason, SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
4
4
  import type { SyncedBlockPlugin } from '../../syncedBlockPluginType';
5
5
  import { type SyncBlockInfo } from '../../types';
6
- export type ConfirmationTransactionRef = {
6
+ export type TransactionRef = {
7
7
  current: Transaction | undefined;
8
8
  };
9
- export declare const handleBodiedSyncBlockRemoval: (bodiedSyncBlockRemoved: SyncBlockInfo[], syncBlockStore: SyncBlockStoreManager, api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined, confirmationTransactionRef: ConfirmationTransactionRef, deletionReason: DeletionReason) => boolean;
9
+ export declare const handleBodiedSyncBlockRemoval: (bodiedSyncBlockRemoved: SyncBlockInfo[], syncBlockStore: SyncBlockStoreManager, api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined, confirmationTransactionRef: TransactionRef, deletionReason: DeletionReason) => boolean;
@@ -1,3 +1,4 @@
1
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
1
2
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
3
  import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
3
4
  export declare enum FLAG_ID {
@@ -6,7 +7,8 @@ export declare enum FLAG_ID {
6
7
  CANNOT_CREATE_WHEN_OFFLINE = "cannot-create-when-offline",
7
8
  FAIL_TO_DELETE = "fail-to-delete",
8
9
  SYNC_BLOCK_COPIED = "sync-block-copied",
9
- UNPUBLISHED_SYNC_BLOCK_PASTED = "unpublished-sync-block-pasted"
10
+ UNPUBLISHED_SYNC_BLOCK_PASTED = "unpublished-sync-block-pasted",
11
+ CANNOT_CREATE_SYNC_BLOCK = "cannot-create-sync-block"
10
12
  }
11
13
  type FlagConfig = {
12
14
  id: FLAG_ID;
@@ -15,6 +17,15 @@ type FlagConfig = {
15
17
  };
16
18
  export type BodiedSyncBlockDeletionStatus = 'none' | 'processing' | 'completed';
17
19
  export type ActiveFlag = FlagConfig | false;
20
+ type RetryCreationPos = {
21
+ from: number;
22
+ to: number;
23
+ };
24
+ export type RetryCreationPosMap = Map<string, RetryCreationPos>;
25
+ export type RetryCreationPosEntry = {
26
+ pos?: RetryCreationPos;
27
+ resourceId: string;
28
+ };
18
29
  export type SyncedBlockSharedState = {
19
30
  /**
20
31
  * Whether to show a flag (usually for errors, e.g. fail to delete)
@@ -24,6 +35,12 @@ export type SyncedBlockSharedState = {
24
35
  * Whether the plugin is currently saving bodiedSyncBlock deletion to backend
25
36
  */
26
37
  bodiedSyncBlockDeletionStatus?: BodiedSyncBlockDeletionStatus;
38
+ /**
39
+ * Positions of pending creations keyed by resourceId, used for retry/revert flow.
40
+ * When a new bodiedSyncBlock is added, a new entry is added to map for mapping. The entry is removed when creation succeeds or retry option is dismissed.
41
+ *
42
+ */
43
+ retryCreationPosMap?: RetryCreationPosMap;
27
44
  /**
28
45
  * The current sync block store manager, used to manage fetching and updating sync block data
29
46
  */
@@ -36,6 +53,7 @@ export type SyncBlockAttrs = {
36
53
  export type SyncBlockInfo = {
37
54
  attrs: SyncBlockAttrs;
38
55
  from?: number;
56
+ node?: PMNode;
39
57
  to?: number;
40
58
  };
41
59
  export type SyncBlockMap = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-synced-block",
3
- "version": "5.3.13",
3
+ "version": "5.3.14",
4
4
  "description": "SyncedBlock plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",