@atlaskit/editor-plugin-synced-block 4.3.15 → 4.4.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.
- package/CHANGELOG.md +20 -0
- package/afm-cc/tsconfig.json +2 -1
- package/afm-jira/tsconfig.json +2 -1
- package/afm-products/tsconfig.json +2 -1
- package/dist/cjs/editor-commands/index.js +14 -10
- package/dist/cjs/pm-plugins/main.js +21 -34
- package/dist/cjs/pm-plugins/utils/handle-bodied-sync-block-removal.js +87 -0
- package/dist/cjs/syncedBlockPlugin.js +7 -5
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/ui/DeleteConfirmationModal.js +53 -12
- package/dist/cjs/ui/Flag.js +44 -17
- package/dist/cjs/ui/floating-toolbar.js +1 -1
- package/dist/es2019/editor-commands/index.js +6 -6
- package/dist/es2019/pm-plugins/main.js +21 -32
- package/dist/es2019/pm-plugins/utils/handle-bodied-sync-block-removal.js +74 -0
- package/dist/es2019/syncedBlockPlugin.js +7 -5
- package/dist/es2019/types/index.js +1 -0
- package/dist/es2019/ui/DeleteConfirmationModal.js +56 -12
- package/dist/es2019/ui/Flag.js +43 -13
- package/dist/es2019/ui/floating-toolbar.js +1 -1
- package/dist/esm/editor-commands/index.js +14 -10
- package/dist/esm/pm-plugins/main.js +21 -34
- package/dist/esm/pm-plugins/utils/handle-bodied-sync-block-removal.js +80 -0
- package/dist/esm/syncedBlockPlugin.js +7 -5
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/ui/DeleteConfirmationModal.js +53 -12
- package/dist/esm/ui/Flag.js +44 -17
- package/dist/esm/ui/floating-toolbar.js +1 -1
- package/dist/types/editor-commands/index.d.ts +2 -2
- package/dist/types/pm-plugins/main.d.ts +3 -2
- package/dist/types/pm-plugins/utils/handle-bodied-sync-block-removal.d.ts +9 -0
- package/dist/types/pm-plugins/utils/track-sync-blocks.d.ts +2 -11
- package/dist/types/syncedBlockPluginType.d.ts +0 -4
- package/dist/types/types/index.d.ts +28 -2
- package/dist/types/ui/CreateSyncedBlockButton.d.ts +1 -1
- package/dist/types/ui/OverflowMenuSection.d.ts +1 -1
- package/dist/types-ts4.5/editor-commands/index.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/main.d.ts +3 -2
- package/dist/types-ts4.5/pm-plugins/utils/handle-bodied-sync-block-removal.d.ts +9 -0
- package/dist/types-ts4.5/pm-plugins/utils/track-sync-blocks.d.ts +2 -11
- package/dist/types-ts4.5/syncedBlockPluginType.d.ts +0 -4
- package/dist/types-ts4.5/types/index.d.ts +28 -2
- package/dist/types-ts4.5/ui/CreateSyncedBlockButton.d.ts +1 -1
- package/dist/types-ts4.5/ui/OverflowMenuSection.d.ts +1 -1
- package/package.json +7 -7
|
@@ -0,0 +1,80 @@
|
|
|
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 { pmHistoryPluginKey } from '@atlaskit/editor-common/utils';
|
|
5
|
+
import { FLAG_ID } from '../../types';
|
|
6
|
+
import { syncedBlockPluginKey } from '../main';
|
|
7
|
+
var onRetry = function onRetry(api, syncBlockStore) {
|
|
8
|
+
return function () {
|
|
9
|
+
var _api$core;
|
|
10
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref) {
|
|
11
|
+
var tr = _ref.tr;
|
|
12
|
+
return tr.setMeta(syncedBlockPluginKey, {
|
|
13
|
+
bodiedSyncBlockDeletionStatus: 'processing',
|
|
14
|
+
activeFlag: false
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
syncBlockStore.sourceManager.retryDeletion();
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
var onDismissed = function onDismissed(syncBlockStore) {
|
|
21
|
+
return function (tr) {
|
|
22
|
+
syncBlockStore.sourceManager.clearPendingDeletion();
|
|
23
|
+
return tr.setMeta(syncedBlockPluginKey, {
|
|
24
|
+
bodiedSyncBlockDeletionStatus: 'none'
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export var handleBodiedSyncBlockRemoval = function handleBodiedSyncBlockRemoval(tr, bodiedSyncBlockRemoved, syncBlockStore, api, confirmationTransactionRef) {
|
|
29
|
+
// Clear potential old pending deletion to retreat the deletion as first attempt
|
|
30
|
+
syncBlockStore.sourceManager.clearPendingDeletion();
|
|
31
|
+
|
|
32
|
+
// If there are source sync blocks being removed, and we need to confirm with user before deleting,
|
|
33
|
+
// we block the transaction here, and wait for user confirmation to proceed with deletion.
|
|
34
|
+
// See editor-common/src/sync-block/sync-block-store-manager.ts for how we handle user confirmation and
|
|
35
|
+
// proceed with deletion.
|
|
36
|
+
syncBlockStore.sourceManager.deleteSyncBlocksWithConfirmation(bodiedSyncBlockRemoved.map(function (node) {
|
|
37
|
+
return node.attrs;
|
|
38
|
+
}), function () {
|
|
39
|
+
var _api$core2;
|
|
40
|
+
var confirmationTransaction = confirmationTransactionRef.current;
|
|
41
|
+
if (!confirmationTransaction) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function () {
|
|
45
|
+
var trToDispatch = confirmationTransaction.setMeta('isConfirmedSyncBlockDeletion', true);
|
|
46
|
+
if (!trToDispatch.getMeta(pmHistoryPluginKey)) {
|
|
47
|
+
// bodiedSyncBlock deletion is expected to be permanent (cannot undo)
|
|
48
|
+
// For a normal deletion (not triggered by undo), remove it from history so that it cannot be undone
|
|
49
|
+
trToDispatch.setMeta('addToHistory', false);
|
|
50
|
+
}
|
|
51
|
+
return trToDispatch;
|
|
52
|
+
});
|
|
53
|
+
}, function (success) {
|
|
54
|
+
var _api$core3;
|
|
55
|
+
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref2) {
|
|
56
|
+
var tr = _ref2.tr;
|
|
57
|
+
var newState;
|
|
58
|
+
if (!success) {
|
|
59
|
+
newState = {
|
|
60
|
+
activeFlag: {
|
|
61
|
+
id: FLAG_ID.FAIL_TO_DELETE,
|
|
62
|
+
onRetry: onRetry(api, syncBlockStore),
|
|
63
|
+
onDismissed: onDismissed(syncBlockStore)
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
newState = _objectSpread(_objectSpread({}, newState), {}, {
|
|
68
|
+
bodiedSyncBlockDeletionStatus: syncBlockStore.sourceManager.isRetryingDeletion() ?
|
|
69
|
+
// For retry, reset to none directly to clean up the status
|
|
70
|
+
'none' :
|
|
71
|
+
// For the first attempt, set to completed for deletion modal can close the modal
|
|
72
|
+
'completed'
|
|
73
|
+
});
|
|
74
|
+
return tr.setMeta(syncedBlockPluginKey, newState);
|
|
75
|
+
});
|
|
76
|
+
}, function () {
|
|
77
|
+
confirmationTransactionRef.current = undefined;
|
|
78
|
+
});
|
|
79
|
+
return false;
|
|
80
|
+
};
|
|
@@ -41,7 +41,7 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
|
|
|
41
41
|
},
|
|
42
42
|
commands: {
|
|
43
43
|
copySyncedBlockReferenceToClipboard: function copySyncedBlockReferenceToClipboard() {
|
|
44
|
-
return copySyncedBlockReferenceToClipboardEditorCommand;
|
|
44
|
+
return copySyncedBlockReferenceToClipboardEditorCommand(syncBlockStore);
|
|
45
45
|
},
|
|
46
46
|
insertSyncedBlock: function insertSyncedBlock() {
|
|
47
47
|
return function (_ref2) {
|
|
@@ -106,11 +106,13 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
|
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
108
|
var _syncedBlockPluginKey = syncedBlockPluginKey.getState(editorState),
|
|
109
|
-
|
|
110
|
-
currentSyncBlockStore = _syncedBlockPluginKey.syncBlockStore
|
|
109
|
+
activeFlag = _syncedBlockPluginKey.activeFlag,
|
|
110
|
+
currentSyncBlockStore = _syncedBlockPluginKey.syncBlockStore,
|
|
111
|
+
bodiedSyncBlockDeletionStatus = _syncedBlockPluginKey.bodiedSyncBlockDeletionStatus;
|
|
111
112
|
return {
|
|
112
|
-
|
|
113
|
-
syncBlockStore: currentSyncBlockStore
|
|
113
|
+
activeFlag: activeFlag,
|
|
114
|
+
syncBlockStore: currentSyncBlockStore,
|
|
115
|
+
bodiedSyncBlockDeletionStatus: bodiedSyncBlockDeletionStatus
|
|
114
116
|
};
|
|
115
117
|
}
|
|
116
118
|
};
|
package/dist/esm/types/index.js
CHANGED
|
@@ -2,5 +2,6 @@ export var FLAG_ID = /*#__PURE__*/function (FLAG_ID) {
|
|
|
2
2
|
FLAG_ID["CANNOT_DELETE_WHEN_OFFLINE"] = "cannot-delete-when-offline";
|
|
3
3
|
FLAG_ID["CANNOT_EDIT_WHEN_OFFLINE"] = "cannot-edit-when-offline";
|
|
4
4
|
FLAG_ID["CANNOT_CREATE_WHEN_OFFLINE"] = "cannot-create-when-offline";
|
|
5
|
+
FLAG_ID["FAIL_TO_DELETE"] = "fail-to-delete";
|
|
5
6
|
return FLAG_ID;
|
|
6
7
|
}({});
|
|
@@ -6,7 +6,9 @@ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks'
|
|
|
6
6
|
import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
7
|
import ModalDialog, { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
|
|
8
8
|
import { Text } from '@atlaskit/primitives/compiled';
|
|
9
|
+
import { syncedBlockPluginKey } from '../pm-plugins/main';
|
|
9
10
|
export var DeleteConfirmationModal = function DeleteConfirmationModal(_ref) {
|
|
11
|
+
var _api$core2, _api$core4, _api$core6;
|
|
10
12
|
var syncBlockStoreManager = _ref.syncBlockStoreManager,
|
|
11
13
|
api = _ref.api;
|
|
12
14
|
var _useState = useState(false),
|
|
@@ -17,41 +19,79 @@ export var DeleteConfirmationModal = function DeleteConfirmationModal(_ref) {
|
|
|
17
19
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
18
20
|
syncBlockCount = _useState4[0],
|
|
19
21
|
setSyncBlockCount = _useState4[1];
|
|
20
|
-
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['connectivity'], function (states) {
|
|
21
|
-
var _states$connectivityS;
|
|
22
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['connectivity', 'syncedBlock'], function (states) {
|
|
23
|
+
var _states$connectivityS, _states$syncedBlockSt, _states$syncedBlockSt2;
|
|
22
24
|
return {
|
|
23
|
-
mode: (_states$connectivityS = states.connectivityState) === null || _states$connectivityS === void 0 ? void 0 : _states$connectivityS.mode
|
|
25
|
+
mode: (_states$connectivityS = states.connectivityState) === null || _states$connectivityS === void 0 ? void 0 : _states$connectivityS.mode,
|
|
26
|
+
bodiedSyncBlockDeletionStatus: (_states$syncedBlockSt = states.syncedBlockState) === null || _states$syncedBlockSt === void 0 ? void 0 : _states$syncedBlockSt.bodiedSyncBlockDeletionStatus,
|
|
27
|
+
activeFlag: (_states$syncedBlockSt2 = states.syncedBlockState) === null || _states$syncedBlockSt2 === void 0 ? void 0 : _states$syncedBlockSt2.activeFlag
|
|
24
28
|
};
|
|
25
29
|
}),
|
|
26
|
-
mode = _useSharedPluginState.mode
|
|
30
|
+
mode = _useSharedPluginState.mode,
|
|
31
|
+
bodiedSyncBlockDeletionStatus = _useSharedPluginState.bodiedSyncBlockDeletionStatus,
|
|
32
|
+
activeFlag = _useSharedPluginState.activeFlag;
|
|
27
33
|
var _useIntl = useIntl(),
|
|
28
34
|
formatMessage = _useIntl.formatMessage;
|
|
29
35
|
var resolverRef = React.useRef(undefined);
|
|
30
|
-
var
|
|
36
|
+
var handleClick = useCallback(function (confirm) {
|
|
31
37
|
return function () {
|
|
38
|
+
var _api$core;
|
|
32
39
|
if (resolverRef.current) {
|
|
33
40
|
resolverRef.current(confirm);
|
|
34
41
|
resolverRef.current = undefined;
|
|
35
42
|
}
|
|
36
|
-
|
|
43
|
+
if (!confirm) {
|
|
44
|
+
setIsOpen(false);
|
|
45
|
+
}
|
|
46
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
|
|
47
|
+
var tr = _ref2.tr;
|
|
48
|
+
return tr.setMeta(syncedBlockPluginKey, {
|
|
49
|
+
bodiedSyncBlockDeletionStatus: confirm ? 'processing' : 'none',
|
|
50
|
+
activeFlag: false
|
|
51
|
+
});
|
|
52
|
+
});
|
|
37
53
|
};
|
|
38
|
-
}, []);
|
|
54
|
+
}, [api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions]);
|
|
39
55
|
var confirmationCallback = useCallback(function (syncBlockCount) {
|
|
40
56
|
setIsOpen(true);
|
|
41
57
|
setSyncBlockCount(syncBlockCount);
|
|
42
58
|
var confirmedPromise = new Promise(function (resolve) {
|
|
43
59
|
resolverRef.current = resolve;
|
|
44
60
|
});
|
|
61
|
+
if (activeFlag) {
|
|
62
|
+
var _api$core3;
|
|
63
|
+
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref3) {
|
|
64
|
+
var tr = _ref3.tr;
|
|
65
|
+
return tr.setMeta(syncedBlockPluginKey, {
|
|
66
|
+
// Clear flag to avoid potential retry deletion of different blocks
|
|
67
|
+
activeFlag: false
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
45
71
|
return confirmedPromise;
|
|
46
|
-
}, []);
|
|
72
|
+
}, [activeFlag, api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions]);
|
|
47
73
|
useEffect(function () {
|
|
48
74
|
var unregister = syncBlockStoreManager.sourceManager.registerConfirmationCallback(confirmationCallback);
|
|
49
75
|
return function () {
|
|
50
76
|
unregister();
|
|
51
77
|
};
|
|
52
78
|
}, [syncBlockStoreManager, confirmationCallback]);
|
|
79
|
+
useEffect(function () {
|
|
80
|
+
if (bodiedSyncBlockDeletionStatus === 'completed' && isOpen) {
|
|
81
|
+
var _api$core5;
|
|
82
|
+
// auto close modal once deletion is successful
|
|
83
|
+
setIsOpen(false);
|
|
84
|
+
api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.execute(function (_ref4) {
|
|
85
|
+
var tr = _ref4.tr;
|
|
86
|
+
return tr.setMeta(syncedBlockPluginKey, {
|
|
87
|
+
// Reset deletion status to have a clean state for next deletion
|
|
88
|
+
bodiedSyncBlockDeletionStatus: 'none'
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}, [api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 ? void 0 : _api$core6.actions, bodiedSyncBlockDeletionStatus, isOpen]);
|
|
53
93
|
return /*#__PURE__*/React.createElement(ModalTransition, null, isOpen && /*#__PURE__*/React.createElement(ModalDialog, {
|
|
54
|
-
onClose:
|
|
94
|
+
onClose: handleClick(false),
|
|
55
95
|
testId: "sync-block-delete-confirmation"
|
|
56
96
|
}, /*#__PURE__*/React.createElement(ModalHeader, {
|
|
57
97
|
hasCloseButton: true
|
|
@@ -61,11 +101,12 @@ export var DeleteConfirmationModal = function DeleteConfirmationModal(_ref) {
|
|
|
61
101
|
syncBlockCount: syncBlockCount
|
|
62
102
|
}))), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
|
|
63
103
|
appearance: "subtle",
|
|
64
|
-
onClick:
|
|
104
|
+
onClick: handleClick(false)
|
|
65
105
|
}, formatMessage(messages.deleteConfirmationModalCancelButton)), /*#__PURE__*/React.createElement(Button, {
|
|
66
106
|
appearance: "warning",
|
|
67
|
-
onClick:
|
|
107
|
+
onClick: handleClick(true),
|
|
68
108
|
autoFocus: true,
|
|
69
|
-
isDisabled: mode === 'offline'
|
|
109
|
+
isDisabled: mode === 'offline',
|
|
110
|
+
isLoading: bodiedSyncBlockDeletionStatus === 'processing'
|
|
70
111
|
}, formatMessage(messages.deleteConfirmationModalDeleteButton)))));
|
|
71
112
|
};
|
package/dist/esm/ui/Flag.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
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; }
|
|
2
4
|
import React from 'react';
|
|
3
5
|
import { useIntl } from 'react-intl-next';
|
|
4
6
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
5
7
|
import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
8
|
import AkFlag, { FlagGroup } from '@atlaskit/flag';
|
|
7
|
-
import
|
|
9
|
+
import StatusWarningIcon from '@atlaskit/icon/core/status-warning';
|
|
8
10
|
import { syncedBlockPluginKey } from '../pm-plugins/main';
|
|
9
11
|
import { FLAG_ID } from '../types';
|
|
10
|
-
var flagMap = _defineProperty(_defineProperty(_defineProperty({}, FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE, {
|
|
12
|
+
var flagMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE, {
|
|
11
13
|
title: messages.failToDeleteTitle,
|
|
12
14
|
description: messages.failToDeleteWhenOfflineDescription
|
|
13
15
|
}), FLAG_ID.CANNOT_EDIT_WHEN_OFFLINE, {
|
|
@@ -16,43 +18,68 @@ var flagMap = _defineProperty(_defineProperty(_defineProperty({}, FLAG_ID.CANNOT
|
|
|
16
18
|
}), FLAG_ID.CANNOT_CREATE_WHEN_OFFLINE, {
|
|
17
19
|
title: messages.failToCreateTitle,
|
|
18
20
|
description: messages.failToCreateWhenOfflineDescription
|
|
21
|
+
}), FLAG_ID.FAIL_TO_DELETE, {
|
|
22
|
+
title: messages.cannotDeleteTitle,
|
|
23
|
+
description: messages.cannotDeleteDescription
|
|
19
24
|
});
|
|
20
25
|
export var Flag = function Flag(_ref) {
|
|
21
26
|
var api = _ref.api;
|
|
22
|
-
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['syncedBlock'], function (states) {
|
|
23
|
-
var _states$syncedBlockSt;
|
|
27
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['syncedBlock', 'connectivity'], function (states) {
|
|
28
|
+
var _states$syncedBlockSt, _states$connectivityS;
|
|
24
29
|
return {
|
|
25
|
-
|
|
30
|
+
activeFlag: (_states$syncedBlockSt = states.syncedBlockState) === null || _states$syncedBlockSt === void 0 ? void 0 : _states$syncedBlockSt.activeFlag,
|
|
31
|
+
mode: (_states$connectivityS = states.connectivityState) === null || _states$connectivityS === void 0 ? void 0 : _states$connectivityS.mode
|
|
26
32
|
};
|
|
27
33
|
}),
|
|
28
|
-
|
|
34
|
+
activeFlag = _useSharedPluginState.activeFlag,
|
|
35
|
+
mode = _useSharedPluginState.mode;
|
|
29
36
|
var _useIntl = useIntl(),
|
|
30
37
|
formatMessage = _useIntl.formatMessage;
|
|
31
|
-
if (!
|
|
38
|
+
if (!activeFlag) {
|
|
32
39
|
return;
|
|
33
40
|
}
|
|
34
|
-
var _flagMap$
|
|
35
|
-
title = _flagMap$
|
|
36
|
-
description = _flagMap$
|
|
37
|
-
var
|
|
41
|
+
var _flagMap$activeFlag$i = flagMap[activeFlag.id],
|
|
42
|
+
title = _flagMap$activeFlag$i.title,
|
|
43
|
+
description = _flagMap$activeFlag$i.description;
|
|
44
|
+
var onRetry = activeFlag.onRetry,
|
|
45
|
+
onDismissedCallback = activeFlag.onDismissed;
|
|
46
|
+
|
|
47
|
+
// Retry button often involves network request, hence we dismiss the flag in offline mode to avoid retry
|
|
48
|
+
if (mode === 'offline' && !!onRetry) {
|
|
38
49
|
api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
|
|
39
50
|
var tr = _ref2.tr;
|
|
40
51
|
tr.setMeta(syncedBlockPluginKey, {
|
|
41
|
-
|
|
52
|
+
activeFlag: false
|
|
42
53
|
});
|
|
43
54
|
return tr;
|
|
44
55
|
});
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
var onDismissed = function onDismissed() {
|
|
59
|
+
api === null || api === void 0 || api.core.actions.execute(function (_ref3) {
|
|
60
|
+
var tr = _ref3.tr;
|
|
61
|
+
onDismissedCallback === null || onDismissedCallback === void 0 || onDismissedCallback(tr);
|
|
62
|
+
var oldMeta = tr.getMeta(syncedBlockPluginKey);
|
|
63
|
+
tr.setMeta(syncedBlockPluginKey, _objectSpread(_objectSpread({}, oldMeta), {}, {
|
|
64
|
+
activeFlag: false
|
|
65
|
+
}));
|
|
66
|
+
return tr;
|
|
67
|
+
});
|
|
45
68
|
api === null || api === void 0 || api.core.actions.focus();
|
|
46
69
|
};
|
|
47
70
|
return /*#__PURE__*/React.createElement(FlagGroup, null, /*#__PURE__*/React.createElement(AkFlag, {
|
|
48
71
|
onDismissed: onDismissed,
|
|
49
72
|
title: formatMessage(title),
|
|
50
73
|
description: formatMessage(description),
|
|
51
|
-
id:
|
|
52
|
-
testId:
|
|
53
|
-
icon: /*#__PURE__*/React.createElement(
|
|
74
|
+
id: activeFlag.id,
|
|
75
|
+
testId: activeFlag.id,
|
|
76
|
+
icon: /*#__PURE__*/React.createElement(StatusWarningIcon, {
|
|
54
77
|
label: "",
|
|
55
|
-
color: "var(--ds-icon-
|
|
56
|
-
})
|
|
78
|
+
color: "var(--ds-icon-warning, #E06C00)"
|
|
79
|
+
}),
|
|
80
|
+
actions: onRetry ? [{
|
|
81
|
+
content: formatMessage(messages.deleteRetryButton),
|
|
82
|
+
onClick: onRetry
|
|
83
|
+
}] : undefined
|
|
57
84
|
}));
|
|
58
85
|
};
|
|
@@ -38,7 +38,7 @@ export var getToolbarConfig = function getToolbarConfig(state, intl, api, syncBl
|
|
|
38
38
|
title: formatMessage(messages.copySyncBlockLabel),
|
|
39
39
|
showTitle: false,
|
|
40
40
|
tooltipContent: formatMessage(messages.copySyncBlockTooltip),
|
|
41
|
-
onClick: copySyncedBlockReferenceToClipboard
|
|
41
|
+
onClick: copySyncedBlockReferenceToClipboard(syncBlockStore)
|
|
42
42
|
}, hoverDecorationProps(nodeType, akEditorSelectedNodeClassName));
|
|
43
43
|
items.push(copyButton);
|
|
44
44
|
var disabled = !syncBlockStore.referenceManager.getSyncBlockURL(syncBlockObject.node.attrs.resourceId);
|
|
@@ -8,8 +8,8 @@ type createSyncedBlockProps = {
|
|
|
8
8
|
typeAheadInsert?: TypeAheadInsert;
|
|
9
9
|
};
|
|
10
10
|
export declare const createSyncedBlock: ({ tr, syncBlockStore, typeAheadInsert, }: createSyncedBlockProps) => false | Transaction;
|
|
11
|
-
export declare const copySyncedBlockReferenceToClipboardEditorCommand: EditorCommand;
|
|
12
|
-
export declare const copySyncedBlockReferenceToClipboard: Command;
|
|
11
|
+
export declare const copySyncedBlockReferenceToClipboardEditorCommand: (syncBlockStore: SyncBlockStoreManager) => EditorCommand;
|
|
12
|
+
export declare const copySyncedBlockReferenceToClipboard: (syncBlockStore: SyncBlockStoreManager) => Command;
|
|
13
13
|
export declare const editSyncedBlockSource: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
14
14
|
export declare const removeSyncedBlock: (api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
15
15
|
export {};
|
|
@@ -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 {
|
|
7
|
+
import { type ActiveFlag, type BodiedSyncBlockDeletionStatus } from '../types';
|
|
8
8
|
export declare const syncedBlockPluginKey: PluginKey<any>;
|
|
9
9
|
type SyncedBlockPluginState = {
|
|
10
|
+
activeFlag: ActiveFlag;
|
|
11
|
+
bodiedSyncBlockDeletionStatus?: BodiedSyncBlockDeletionStatus;
|
|
10
12
|
selectionDecorationSet: DecorationSet;
|
|
11
|
-
showFlag: FLAG_ID | false;
|
|
12
13
|
syncBlockStore: SyncBlockStoreManager;
|
|
13
14
|
};
|
|
14
15
|
export declare const createPlugin: (options: SyncedBlockPluginOptions | undefined, pmPluginFactoryParams: PMPluginFactoryParams, syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => SafePlugin<SyncedBlockPluginState>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
4
|
+
import type { SyncedBlockPlugin } from '../../syncedBlockPluginType';
|
|
5
|
+
import { type SyncBlockInfo } from '../../types';
|
|
6
|
+
export type ConfirmationTransactionRef = {
|
|
7
|
+
current: Transaction | undefined;
|
|
8
|
+
};
|
|
9
|
+
export declare const handleBodiedSyncBlockRemoval: (tr: Transaction, bodiedSyncBlockRemoved: SyncBlockInfo[], syncBlockStore: SyncBlockStoreManager, api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined, confirmationTransactionRef: ConfirmationTransactionRef) => boolean;
|
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type { SyncBlockAttrs } from '../../syncedBlockPluginType';
|
|
4
3
|
export declare const trackSyncBlocks: (predicate: (node: PMNode) => boolean, tr: Transaction, state: EditorState) => {
|
|
5
|
-
removed:
|
|
6
|
-
|
|
7
|
-
from?: number;
|
|
8
|
-
to?: number;
|
|
9
|
-
}[];
|
|
10
|
-
added: {
|
|
11
|
-
attrs: SyncBlockAttrs;
|
|
12
|
-
from?: number;
|
|
13
|
-
to?: number;
|
|
14
|
-
}[];
|
|
4
|
+
removed: import("../../types").SyncBlockInfo[];
|
|
5
|
+
added: import("../../types").SyncBlockInfo[];
|
|
15
6
|
};
|
|
16
7
|
/**
|
|
17
8
|
*
|
|
@@ -71,7 +71,3 @@ export type SyncedBlockPlugin = NextEditorPlugin<'syncedBlock', {
|
|
|
71
71
|
pluginConfiguration: SyncedBlockPluginOptions | undefined;
|
|
72
72
|
sharedState: SyncedBlockSharedState | undefined;
|
|
73
73
|
}>;
|
|
74
|
-
export type SyncBlockAttrs = {
|
|
75
|
-
localId: string;
|
|
76
|
-
resourceId: string;
|
|
77
|
-
};
|
|
@@ -1,16 +1,42 @@
|
|
|
1
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
1
2
|
import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
2
3
|
export declare enum FLAG_ID {
|
|
3
4
|
CANNOT_DELETE_WHEN_OFFLINE = "cannot-delete-when-offline",
|
|
4
5
|
CANNOT_EDIT_WHEN_OFFLINE = "cannot-edit-when-offline",
|
|
5
|
-
CANNOT_CREATE_WHEN_OFFLINE = "cannot-create-when-offline"
|
|
6
|
+
CANNOT_CREATE_WHEN_OFFLINE = "cannot-create-when-offline",
|
|
7
|
+
FAIL_TO_DELETE = "fail-to-delete"
|
|
6
8
|
}
|
|
9
|
+
type FlagConfig = {
|
|
10
|
+
id: FLAG_ID;
|
|
11
|
+
onDismissed?: (tr: Transaction) => Transaction | void;
|
|
12
|
+
onRetry?: () => void;
|
|
13
|
+
};
|
|
14
|
+
export type BodiedSyncBlockDeletionStatus = 'none' | 'processing' | 'completed';
|
|
15
|
+
export type ActiveFlag = FlagConfig | false;
|
|
7
16
|
export type SyncedBlockSharedState = {
|
|
8
17
|
/**
|
|
9
18
|
* Whether to show a flag (usually for errors, e.g. fail to delete)
|
|
10
19
|
*/
|
|
11
|
-
|
|
20
|
+
activeFlag: ActiveFlag;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the plugin is currently saving bodiedSyncBlock deletion to backend
|
|
23
|
+
*/
|
|
24
|
+
bodiedSyncBlockDeletionStatus?: BodiedSyncBlockDeletionStatus;
|
|
12
25
|
/**
|
|
13
26
|
* The current sync block store manager, used to manage fetching and updating sync block data
|
|
14
27
|
*/
|
|
15
28
|
syncBlockStore: SyncBlockStoreManager;
|
|
16
29
|
};
|
|
30
|
+
export type SyncBlockAttrs = {
|
|
31
|
+
localId: string;
|
|
32
|
+
resourceId: string;
|
|
33
|
+
};
|
|
34
|
+
export type SyncBlockInfo = {
|
|
35
|
+
attrs: SyncBlockAttrs;
|
|
36
|
+
from?: number;
|
|
37
|
+
to?: number;
|
|
38
|
+
};
|
|
39
|
+
export type SyncBlockMap = {
|
|
40
|
+
[key: string]: SyncBlockInfo;
|
|
41
|
+
};
|
|
42
|
+
export {};
|
|
@@ -4,5 +4,5 @@ import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
|
|
|
4
4
|
type CreateSyncedBlockButtonProps = {
|
|
5
5
|
api?: ExtractInjectionAPI<SyncedBlockPlugin>;
|
|
6
6
|
};
|
|
7
|
-
export declare const CreateSyncedBlockButton: ({ api }: CreateSyncedBlockButtonProps) => React.JSX.Element;
|
|
7
|
+
export declare const CreateSyncedBlockButton: ({ api, }: CreateSyncedBlockButtonProps) => React.JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -2,5 +2,5 @@ import React from 'react';
|
|
|
2
2
|
type OverflowMenuSectionProps = {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
};
|
|
5
|
-
export declare const OverflowMenuSection: ({ children }: OverflowMenuSectionProps) => React.JSX.Element | null;
|
|
5
|
+
export declare const OverflowMenuSection: ({ children, }: OverflowMenuSectionProps) => React.JSX.Element | null;
|
|
6
6
|
export {};
|
|
@@ -8,8 +8,8 @@ type createSyncedBlockProps = {
|
|
|
8
8
|
typeAheadInsert?: TypeAheadInsert;
|
|
9
9
|
};
|
|
10
10
|
export declare const createSyncedBlock: ({ tr, syncBlockStore, typeAheadInsert, }: createSyncedBlockProps) => false | Transaction;
|
|
11
|
-
export declare const copySyncedBlockReferenceToClipboardEditorCommand: EditorCommand;
|
|
12
|
-
export declare const copySyncedBlockReferenceToClipboard: Command;
|
|
11
|
+
export declare const copySyncedBlockReferenceToClipboardEditorCommand: (syncBlockStore: SyncBlockStoreManager) => EditorCommand;
|
|
12
|
+
export declare const copySyncedBlockReferenceToClipboard: (syncBlockStore: SyncBlockStoreManager) => Command;
|
|
13
13
|
export declare const editSyncedBlockSource: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
14
14
|
export declare const removeSyncedBlock: (api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
15
15
|
export {};
|
|
@@ -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 {
|
|
7
|
+
import { type ActiveFlag, type BodiedSyncBlockDeletionStatus } from '../types';
|
|
8
8
|
export declare const syncedBlockPluginKey: PluginKey<any>;
|
|
9
9
|
type SyncedBlockPluginState = {
|
|
10
|
+
activeFlag: ActiveFlag;
|
|
11
|
+
bodiedSyncBlockDeletionStatus?: BodiedSyncBlockDeletionStatus;
|
|
10
12
|
selectionDecorationSet: DecorationSet;
|
|
11
|
-
showFlag: FLAG_ID | false;
|
|
12
13
|
syncBlockStore: SyncBlockStoreManager;
|
|
13
14
|
};
|
|
14
15
|
export declare const createPlugin: (options: SyncedBlockPluginOptions | undefined, pmPluginFactoryParams: PMPluginFactoryParams, syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => SafePlugin<SyncedBlockPluginState>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
4
|
+
import type { SyncedBlockPlugin } from '../../syncedBlockPluginType';
|
|
5
|
+
import { type SyncBlockInfo } from '../../types';
|
|
6
|
+
export type ConfirmationTransactionRef = {
|
|
7
|
+
current: Transaction | undefined;
|
|
8
|
+
};
|
|
9
|
+
export declare const handleBodiedSyncBlockRemoval: (tr: Transaction, bodiedSyncBlockRemoved: SyncBlockInfo[], syncBlockStore: SyncBlockStoreManager, api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined, confirmationTransactionRef: ConfirmationTransactionRef) => boolean;
|
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type { SyncBlockAttrs } from '../../syncedBlockPluginType';
|
|
4
3
|
export declare const trackSyncBlocks: (predicate: (node: PMNode) => boolean, tr: Transaction, state: EditorState) => {
|
|
5
|
-
removed:
|
|
6
|
-
|
|
7
|
-
from?: number;
|
|
8
|
-
to?: number;
|
|
9
|
-
}[];
|
|
10
|
-
added: {
|
|
11
|
-
attrs: SyncBlockAttrs;
|
|
12
|
-
from?: number;
|
|
13
|
-
to?: number;
|
|
14
|
-
}[];
|
|
4
|
+
removed: import("../../types").SyncBlockInfo[];
|
|
5
|
+
added: import("../../types").SyncBlockInfo[];
|
|
15
6
|
};
|
|
16
7
|
/**
|
|
17
8
|
*
|
|
@@ -71,7 +71,3 @@ export type SyncedBlockPlugin = NextEditorPlugin<'syncedBlock', {
|
|
|
71
71
|
pluginConfiguration: SyncedBlockPluginOptions | undefined;
|
|
72
72
|
sharedState: SyncedBlockSharedState | undefined;
|
|
73
73
|
}>;
|
|
74
|
-
export type SyncBlockAttrs = {
|
|
75
|
-
localId: string;
|
|
76
|
-
resourceId: string;
|
|
77
|
-
};
|
|
@@ -1,16 +1,42 @@
|
|
|
1
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
1
2
|
import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
2
3
|
export declare enum FLAG_ID {
|
|
3
4
|
CANNOT_DELETE_WHEN_OFFLINE = "cannot-delete-when-offline",
|
|
4
5
|
CANNOT_EDIT_WHEN_OFFLINE = "cannot-edit-when-offline",
|
|
5
|
-
CANNOT_CREATE_WHEN_OFFLINE = "cannot-create-when-offline"
|
|
6
|
+
CANNOT_CREATE_WHEN_OFFLINE = "cannot-create-when-offline",
|
|
7
|
+
FAIL_TO_DELETE = "fail-to-delete"
|
|
6
8
|
}
|
|
9
|
+
type FlagConfig = {
|
|
10
|
+
id: FLAG_ID;
|
|
11
|
+
onDismissed?: (tr: Transaction) => Transaction | void;
|
|
12
|
+
onRetry?: () => void;
|
|
13
|
+
};
|
|
14
|
+
export type BodiedSyncBlockDeletionStatus = 'none' | 'processing' | 'completed';
|
|
15
|
+
export type ActiveFlag = FlagConfig | false;
|
|
7
16
|
export type SyncedBlockSharedState = {
|
|
8
17
|
/**
|
|
9
18
|
* Whether to show a flag (usually for errors, e.g. fail to delete)
|
|
10
19
|
*/
|
|
11
|
-
|
|
20
|
+
activeFlag: ActiveFlag;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the plugin is currently saving bodiedSyncBlock deletion to backend
|
|
23
|
+
*/
|
|
24
|
+
bodiedSyncBlockDeletionStatus?: BodiedSyncBlockDeletionStatus;
|
|
12
25
|
/**
|
|
13
26
|
* The current sync block store manager, used to manage fetching and updating sync block data
|
|
14
27
|
*/
|
|
15
28
|
syncBlockStore: SyncBlockStoreManager;
|
|
16
29
|
};
|
|
30
|
+
export type SyncBlockAttrs = {
|
|
31
|
+
localId: string;
|
|
32
|
+
resourceId: string;
|
|
33
|
+
};
|
|
34
|
+
export type SyncBlockInfo = {
|
|
35
|
+
attrs: SyncBlockAttrs;
|
|
36
|
+
from?: number;
|
|
37
|
+
to?: number;
|
|
38
|
+
};
|
|
39
|
+
export type SyncBlockMap = {
|
|
40
|
+
[key: string]: SyncBlockInfo;
|
|
41
|
+
};
|
|
42
|
+
export {};
|
|
@@ -4,5 +4,5 @@ import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
|
|
|
4
4
|
type CreateSyncedBlockButtonProps = {
|
|
5
5
|
api?: ExtractInjectionAPI<SyncedBlockPlugin>;
|
|
6
6
|
};
|
|
7
|
-
export declare const CreateSyncedBlockButton: ({ api }: CreateSyncedBlockButtonProps) => React.JSX.Element;
|
|
7
|
+
export declare const CreateSyncedBlockButton: ({ api, }: CreateSyncedBlockButtonProps) => React.JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -2,5 +2,5 @@ import React from 'react';
|
|
|
2
2
|
type OverflowMenuSectionProps = {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
};
|
|
5
|
-
export declare const OverflowMenuSection: ({ children }: OverflowMenuSectionProps) => React.JSX.Element | null;
|
|
5
|
+
export declare const OverflowMenuSection: ({ children, }: OverflowMenuSectionProps) => React.JSX.Element | null;
|
|
6
6
|
export {};
|