@atlaskit/editor-plugin-synced-block 5.3.12 → 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.
- package/CHANGELOG.md +16 -0
- package/afm-cc/tsconfig.json +0 -3
- package/afm-jira/tsconfig.json +0 -3
- package/afm-products/tsconfig.json +0 -3
- package/dist/cjs/editor-commands/index.js +34 -38
- package/dist/cjs/nodeviews/bodiedSyncedBlock.js +2 -7
- package/dist/cjs/nodeviews/syncedBlock.js +4 -18
- package/dist/cjs/pm-plugins/main.js +120 -67
- package/dist/cjs/pm-plugins/utils/handle-bodied-sync-block-creation.js +141 -0
- package/dist/cjs/pm-plugins/utils/track-sync-blocks.js +2 -2
- package/dist/cjs/pm-plugins/utils/utils.js +1 -46
- package/dist/cjs/syncedBlockPlugin.js +7 -7
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/ui/DeleteConfirmationModal.js +4 -20
- package/dist/cjs/ui/Flag.js +5 -1
- package/dist/cjs/ui/SyncBlockLabel.js +4 -10
- package/dist/cjs/ui/SyncBlockRefresher.js +7 -9
- package/dist/cjs/ui/floating-toolbar.js +6 -3
- package/dist/es2019/editor-commands/index.js +34 -38
- package/dist/es2019/nodeviews/bodiedSyncedBlock.js +2 -7
- package/dist/es2019/nodeviews/syncedBlock.js +4 -15
- package/dist/es2019/pm-plugins/main.js +99 -58
- package/dist/es2019/pm-plugins/utils/handle-bodied-sync-block-creation.js +134 -0
- package/dist/es2019/pm-plugins/utils/track-sync-blocks.js +2 -2
- package/dist/es2019/pm-plugins/utils/utils.js +0 -47
- package/dist/es2019/syncedBlockPlugin.js +7 -6
- package/dist/es2019/types/index.js +1 -0
- package/dist/es2019/ui/DeleteConfirmationModal.js +4 -20
- package/dist/es2019/ui/Flag.js +5 -0
- package/dist/es2019/ui/SyncBlockLabel.js +4 -10
- package/dist/es2019/ui/SyncBlockRefresher.js +7 -9
- package/dist/es2019/ui/floating-toolbar.js +6 -3
- package/dist/esm/editor-commands/index.js +34 -38
- package/dist/esm/nodeviews/bodiedSyncedBlock.js +2 -7
- package/dist/esm/nodeviews/syncedBlock.js +4 -18
- package/dist/esm/pm-plugins/main.js +120 -67
- package/dist/esm/pm-plugins/utils/handle-bodied-sync-block-creation.js +134 -0
- package/dist/esm/pm-plugins/utils/track-sync-blocks.js +2 -2
- package/dist/esm/pm-plugins/utils/utils.js +0 -45
- package/dist/esm/syncedBlockPlugin.js +7 -7
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/ui/DeleteConfirmationModal.js +4 -20
- package/dist/esm/ui/Flag.js +5 -1
- package/dist/esm/ui/SyncBlockLabel.js +4 -10
- package/dist/esm/ui/SyncBlockRefresher.js +7 -9
- package/dist/esm/ui/floating-toolbar.js +6 -3
- package/dist/types/pm-plugins/main.d.ts +2 -1
- package/dist/types/pm-plugins/utils/handle-bodied-sync-block-creation.d.ts +9 -0
- package/dist/types/pm-plugins/utils/handle-bodied-sync-block-removal.d.ts +2 -2
- package/dist/types/pm-plugins/utils/utils.d.ts +1 -3
- package/dist/types/types/index.d.ts +19 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/utils/handle-bodied-sync-block-creation.d.ts +9 -0
- package/dist/types-ts4.5/pm-plugins/utils/handle-bodied-sync-block-removal.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/utils/utils.d.ts +1 -3
- package/dist/types-ts4.5/types/index.d.ts +19 -1
- package/package.json +1 -5
|
@@ -11,7 +11,6 @@ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks'
|
|
|
11
11
|
import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
12
12
|
import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
13
13
|
import ModalDialog, { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
|
|
14
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
14
|
import { Text, Box } from '@atlaskit/primitives/compiled';
|
|
16
15
|
import Spinner from '@atlaskit/spinner';
|
|
17
16
|
import { syncedBlockPluginKey } from '../pm-plugins/main';
|
|
@@ -35,7 +34,7 @@ var styles = {
|
|
|
35
34
|
spinner: "_1mou1wug _195g1wug"
|
|
36
35
|
};
|
|
37
36
|
export var DeleteConfirmationModal = function DeleteConfirmationModal(_ref) {
|
|
38
|
-
var _api$core2, _api$core4, _api$core6
|
|
37
|
+
var _api$core2, _api$core4, _api$core6;
|
|
39
38
|
var syncBlockStoreManager = _ref.syncBlockStoreManager,
|
|
40
39
|
api = _ref.api;
|
|
41
40
|
var _useState = useState(false),
|
|
@@ -130,7 +129,7 @@ export var DeleteConfirmationModal = function DeleteConfirmationModal(_ref) {
|
|
|
130
129
|
}
|
|
131
130
|
}, [api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 ? void 0 : _api$core6.actions, bodiedSyncBlockDeletionStatus, isOpen]);
|
|
132
131
|
useEffect(function () {
|
|
133
|
-
if (isOpen && syncBlockIds !== undefined
|
|
132
|
+
if (isOpen && syncBlockIds !== undefined) {
|
|
134
133
|
var fetchReferences = /*#__PURE__*/function () {
|
|
135
134
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
136
135
|
var references, totalCount;
|
|
@@ -196,7 +195,7 @@ export var DeleteConfirmationModal = function DeleteConfirmationModal(_ref) {
|
|
|
196
195
|
onClose: handleClick(false),
|
|
197
196
|
testId: "sync-block-delete-confirmation",
|
|
198
197
|
height: 184
|
|
199
|
-
},
|
|
198
|
+
}, /*#__PURE__*/React.createElement(React.Fragment, null, referenceCount === undefined ? /*#__PURE__*/React.createElement(Box, {
|
|
200
199
|
xcss: styles.spinner
|
|
201
200
|
}, /*#__PURE__*/React.createElement(Spinner, {
|
|
202
201
|
size: "large"
|
|
@@ -209,22 +208,7 @@ export var DeleteConfirmationModal = function DeleteConfirmationModal(_ref) {
|
|
|
209
208
|
isDisabled: isOfflineMode(mode),
|
|
210
209
|
deleteReason: deleteReason,
|
|
211
210
|
sourceCount: (syncBlockIds === null || syncBlockIds === void 0 ? void 0 : syncBlockIds.length) || 0
|
|
212
|
-
}))
|
|
213
|
-
hasCloseButton: true
|
|
214
|
-
}, /*#__PURE__*/React.createElement(ModalTitle, {
|
|
215
|
-
appearance: "warning"
|
|
216
|
-
}, formatMessage(messages.deleteConfirmationModalTitleSingle))), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement(Text, null, formatMessage(messages.deleteConfirmationModalDescription, {
|
|
217
|
-
syncBlockCount: (_syncBlockIds$length = syncBlockIds === null || syncBlockIds === void 0 ? void 0 : syncBlockIds.length) !== null && _syncBlockIds$length !== void 0 ? _syncBlockIds$length : 1
|
|
218
|
-
}))), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
|
|
219
|
-
appearance: "subtle",
|
|
220
|
-
onClick: handleClick(false)
|
|
221
|
-
}, formatMessage(messages.deleteConfirmationModalCancelButton)), /*#__PURE__*/React.createElement(Button, {
|
|
222
|
-
appearance: "warning",
|
|
223
|
-
onClick: handleClick(true),
|
|
224
|
-
autoFocus: true,
|
|
225
|
-
isDisabled: isOfflineMode(mode),
|
|
226
|
-
isLoading: bodiedSyncBlockDeletionStatus === 'processing'
|
|
227
|
-
}, formatMessage(messages.deleteConfirmationModalDeleteButton))))));
|
|
211
|
+
}))));
|
|
228
212
|
};
|
|
229
213
|
var ModalContent = function ModalContent(_ref7) {
|
|
230
214
|
var content = _ref7.content,
|
package/dist/esm/ui/Flag.js
CHANGED
|
@@ -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;
|
|
@@ -4,7 +4,6 @@ import { useIntl } from 'react-intl-next';
|
|
|
4
4
|
import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
5
|
import { SyncBlockLabelSharedCssClassName } from '@atlaskit/editor-common/sync-block';
|
|
6
6
|
import BlockSyncedIcon from '@atlaskit/icon-lab/core/block-synced';
|
|
7
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
7
|
import { Text } from '@atlaskit/primitives/compiled';
|
|
9
8
|
import Tooltip from '@atlaskit/tooltip';
|
|
10
9
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
@@ -23,17 +22,12 @@ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
|
|
|
23
22
|
tooltipContent = _useState2[0],
|
|
24
23
|
setTooltipContent = _useState2[1];
|
|
25
24
|
var tooltipMessage = formatMessage(messages.defaultSyncBlockTooltip);
|
|
26
|
-
if (
|
|
27
|
-
tooltipMessage = formatMessage(messages.sourceSyncBlockTooltip);
|
|
28
|
-
} else if (title) {
|
|
25
|
+
if (title) {
|
|
29
26
|
tooltipMessage = formatMessage(messages.referenceSyncBlockTooltip, {
|
|
30
27
|
title: title
|
|
31
28
|
});
|
|
32
29
|
}
|
|
33
30
|
var updateTooltipContent = useCallback(function () {
|
|
34
|
-
if (!fg('platform_synced_block_dogfooding')) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
31
|
var tooltipContent = tooltipMessage;
|
|
38
32
|
if (contentUpdatedAt) {
|
|
39
33
|
var elapsedTime = formatElapsedTime(contentUpdatedAt, intl);
|
|
@@ -53,7 +47,7 @@ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
|
|
|
53
47
|
}, [contentUpdatedAt, formatMessage, intl, tooltipMessage]);
|
|
54
48
|
var ariaDescribedById = "sync-block-label-description-".concat(localId);
|
|
55
49
|
var getLabelContent = useMemo(function () {
|
|
56
|
-
if (isUnsyncedBlock
|
|
50
|
+
if (isUnsyncedBlock) {
|
|
57
51
|
return /*#__PURE__*/React.createElement(Text, {
|
|
58
52
|
size: "small",
|
|
59
53
|
color: "color.text.subtle"
|
|
@@ -82,12 +76,12 @@ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
|
|
|
82
76
|
size: "small",
|
|
83
77
|
label: ""
|
|
84
78
|
}), getLabelContent);
|
|
85
|
-
if (
|
|
79
|
+
if (isSource || isUnsyncedBlock) {
|
|
86
80
|
return label;
|
|
87
81
|
}
|
|
88
82
|
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
89
83
|
position: "top",
|
|
90
|
-
content:
|
|
84
|
+
content: tooltipContent
|
|
91
85
|
// workaround because tooltip adds aria-describedby with a new id every time the tooltip is opened
|
|
92
86
|
// this causes an infinite rerender loop because of the forwardRef from the node view we are inside in bodiedSyncBlock
|
|
93
87
|
// tooltip content is available for screen readers in visually hidden content after the label
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
3
3
|
import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
export var SYNC_BLOCK_FETCH_INTERVAL = 3000;
|
|
6
5
|
|
|
7
6
|
// Component that manages synced block data synchronization.
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
7
|
+
// Component that manages synced block data synchronization.
|
|
8
|
+
// Uses provider-based GraphQL subscriptions for updates when online.
|
|
9
|
+
// Falls back to polling at regular intervals when offline.
|
|
11
10
|
export var SyncBlockRefresher = function SyncBlockRefresher(_ref) {
|
|
12
11
|
var syncBlockStoreManager = _ref.syncBlockStoreManager,
|
|
13
12
|
api = _ref.api;
|
|
@@ -18,14 +17,13 @@ export var SyncBlockRefresher = function SyncBlockRefresher(_ref) {
|
|
|
18
17
|
};
|
|
19
18
|
}),
|
|
20
19
|
mode = _useSharedPluginState.mode;
|
|
21
|
-
var featureFlagEnabled = fg('platform_synced_block_dogfooding');
|
|
22
20
|
var isOnline = !isOfflineMode(mode);
|
|
23
21
|
useEffect(function () {
|
|
24
|
-
var useRealTimeSubscriptions =
|
|
22
|
+
var useRealTimeSubscriptions = isOnline;
|
|
25
23
|
syncBlockStoreManager.referenceManager.setRealTimeSubscriptionsEnabled(useRealTimeSubscriptions);
|
|
26
|
-
}, [syncBlockStoreManager,
|
|
24
|
+
}, [syncBlockStoreManager, isOnline]);
|
|
27
25
|
useEffect(function () {
|
|
28
|
-
var useRealTimeSubscriptions =
|
|
26
|
+
var useRealTimeSubscriptions = isOnline;
|
|
29
27
|
if (useRealTimeSubscriptions) {
|
|
30
28
|
return;
|
|
31
29
|
}
|
|
@@ -44,6 +42,6 @@ export var SyncBlockRefresher = function SyncBlockRefresher(_ref) {
|
|
|
44
42
|
return function () {
|
|
45
43
|
window.clearInterval(interval);
|
|
46
44
|
};
|
|
47
|
-
}, [syncBlockStoreManager, isOnline
|
|
45
|
+
}, [syncBlockStoreManager, isOnline]);
|
|
48
46
|
return null;
|
|
49
47
|
};
|
|
@@ -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;
|
|
@@ -49,11 +52,11 @@ export var getToolbarConfig = function getToolbarConfig(state, intl, api, syncBl
|
|
|
49
52
|
title: formatMessage(commonMessages.delete),
|
|
50
53
|
onClick: removeSyncedBlock(api),
|
|
51
54
|
icon: DeleteIcon,
|
|
52
|
-
testId:
|
|
53
|
-
}, hoverDecorationProps(nodeType,
|
|
55
|
+
testId: SYNCED_BLOCK_BUTTON_TEST_ID.syncedBlockToolbarReferenceDelete
|
|
56
|
+
}, hoverDecorationProps(nodeType, akEditorSelectedNodeClassName));
|
|
54
57
|
items.push(deleteButton);
|
|
55
58
|
} else {
|
|
56
|
-
if (!isErroredBlock
|
|
59
|
+
if (!isErroredBlock) {
|
|
57
60
|
var syncedLocation = {
|
|
58
61
|
type: 'custom',
|
|
59
62
|
fallback: [],
|
|
@@ -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
|
|
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:
|
|
9
|
+
export declare const handleBodiedSyncBlockRemoval: (bodiedSyncBlockRemoved: SyncBlockInfo[], syncBlockStore: SyncBlockStoreManager, api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined, confirmationTransactionRef: TransactionRef, deletionReason: DeletionReason) => boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { NodeType, Node as PMNode, Schema, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import {
|
|
3
|
+
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
5
5
|
export declare const findSyncBlock: (schema: Schema, selection: Selection) => ContentNodeWithPos | undefined;
|
|
6
6
|
export declare const findBodiedSyncBlock: (schema: Schema, selection: Selection) => ContentNodeWithPos | undefined;
|
|
@@ -20,6 +20,4 @@ export interface SyncBlockConversionInfo {
|
|
|
20
20
|
* or false if conversion is not possible
|
|
21
21
|
*/
|
|
22
22
|
export declare const canBeConvertedToSyncBlock: (selection: Selection) => SyncBlockConversionInfo | false;
|
|
23
|
-
export declare const canBeConvertedToSyncBlockOld: (selection: Selection) => SyncBlockConversionInfo | false;
|
|
24
|
-
export declare const canBeConvertedToSyncBlockNew: (selection: Selection) => SyncBlockConversionInfo | false;
|
|
25
23
|
export declare const sliceFullyContainsNode: (slice: Slice, node: PMNode) => 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
|
|
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:
|
|
9
|
+
export declare const handleBodiedSyncBlockRemoval: (bodiedSyncBlockRemoved: SyncBlockInfo[], syncBlockStore: SyncBlockStoreManager, api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined, confirmationTransactionRef: TransactionRef, deletionReason: DeletionReason) => boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { NodeType, Node as PMNode, Schema, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import {
|
|
3
|
+
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
5
5
|
export declare const findSyncBlock: (schema: Schema, selection: Selection) => ContentNodeWithPos | undefined;
|
|
6
6
|
export declare const findBodiedSyncBlock: (schema: Schema, selection: Selection) => ContentNodeWithPos | undefined;
|
|
@@ -20,6 +20,4 @@ export interface SyncBlockConversionInfo {
|
|
|
20
20
|
* or false if conversion is not possible
|
|
21
21
|
*/
|
|
22
22
|
export declare const canBeConvertedToSyncBlock: (selection: Selection) => SyncBlockConversionInfo | false;
|
|
23
|
-
export declare const canBeConvertedToSyncBlockOld: (selection: Selection) => SyncBlockConversionInfo | false;
|
|
24
|
-
export declare const canBeConvertedToSyncBlockNew: (selection: Selection) => SyncBlockConversionInfo | false;
|
|
25
23
|
export declare const sliceFullyContainsNode: (slice: Slice, node: PMNode) => 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.
|
|
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",
|
|
@@ -41,7 +41,6 @@
|
|
|
41
41
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
42
42
|
"@atlaskit/editor-shared-styles": "^3.10.0",
|
|
43
43
|
"@atlaskit/editor-synced-block-provider": "^3.26.0",
|
|
44
|
-
"@atlaskit/editor-tables": "^2.9.0",
|
|
45
44
|
"@atlaskit/editor-toolbar": "^0.19.0",
|
|
46
45
|
"@atlaskit/flag": "^17.8.0",
|
|
47
46
|
"@atlaskit/icon": "30.0.2",
|
|
@@ -105,9 +104,6 @@
|
|
|
105
104
|
}
|
|
106
105
|
},
|
|
107
106
|
"platform-feature-flags": {
|
|
108
|
-
"platform_synced_block_dogfooding": {
|
|
109
|
-
"type": "boolean"
|
|
110
|
-
},
|
|
111
107
|
"platform_synced_block_patch_1": {
|
|
112
108
|
"type": "boolean"
|
|
113
109
|
}
|