@atlaskit/editor-plugin-synced-block 5.3.6 → 5.3.8
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 +19 -0
- package/dist/cjs/editor-commands/index.js +13 -3
- package/dist/cjs/nodeviews/syncedBlock.js +19 -7
- package/dist/cjs/ui/DeleteConfirmationModal.js +68 -57
- package/dist/cjs/ui/SyncBlockLabel.js +23 -10
- package/dist/cjs/ui/SyncBlockRendererWrapper.js +5 -2
- package/dist/es2019/editor-commands/index.js +13 -2
- package/dist/es2019/nodeviews/syncedBlock.js +15 -4
- package/dist/es2019/ui/DeleteConfirmationModal.js +25 -31
- package/dist/es2019/ui/SyncBlockLabel.js +24 -11
- package/dist/es2019/ui/SyncBlockRendererWrapper.js +5 -2
- package/dist/esm/editor-commands/index.js +12 -2
- package/dist/esm/nodeviews/syncedBlock.js +20 -8
- package/dist/esm/ui/DeleteConfirmationModal.js +68 -57
- package/dist/esm/ui/SyncBlockLabel.js +24 -11
- package/dist/esm/ui/SyncBlockRendererWrapper.js +5 -2
- package/dist/types/editor-commands/index.d.ts +1 -0
- package/dist/types/nodeviews/syncedBlock.d.ts +3 -3
- package/dist/types/ui/SyncBlockLabel.d.ts +2 -1
- package/dist/types-ts4.5/editor-commands/index.d.ts +1 -0
- package/dist/types-ts4.5/nodeviews/syncedBlock.d.ts +3 -3
- package/dist/types-ts4.5/ui/SyncBlockLabel.d.ts +2 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 5.3.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`f11ff647ea458`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f11ff647ea458) -
|
|
8
|
+
[ux] [EDITOR-4521] Implement source deleted reference UI, update block deleted/unsynced reference
|
|
9
|
+
UI to add delete button, unsynced label and source title/url
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 5.3.7
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [`dac15aa628811`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/dac15aa628811) -
|
|
17
|
+
[ux] fix wrapped media/embed link is displayed out of border in synced block
|
|
18
|
+
- [`aa5302b457078`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/aa5302b457078) -
|
|
19
|
+
[ux] EDITOR-4763 Ensure initial source sync block data are always registered
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 5.3.6
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.unsync = exports.removeSyncedBlock = exports.editSyncedBlockSource = exports.createSyncedBlock = exports.copySyncedBlockReferenceToClipboardEditorCommand = exports.copySyncedBlockReferenceToClipboard = void 0;
|
|
6
|
+
exports.unsync = exports.removeSyncedBlockAtPos = exports.removeSyncedBlock = exports.editSyncedBlockSource = exports.createSyncedBlock = exports.copySyncedBlockReferenceToClipboardEditorCommand = exports.copySyncedBlockReferenceToClipboard = void 0;
|
|
7
7
|
var _schemaDefault = require("@atlaskit/adf-schema/schema-default");
|
|
8
8
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
9
9
|
var _copyButton = require("@atlaskit/editor-common/copy-button");
|
|
@@ -65,7 +65,7 @@ var createSyncedBlock = exports.createSyncedBlock = function createSyncedBlock(_
|
|
|
65
65
|
|
|
66
66
|
// Save the new node with empty content to backend
|
|
67
67
|
// This is so that the node can be copied and referenced without the source being saved/published
|
|
68
|
-
syncBlockStore.sourceManager.createBodiedSyncBlockNode(_attrs);
|
|
68
|
+
syncBlockStore.sourceManager.createBodiedSyncBlockNode(_attrs, _newBodiedSyncBlockNode);
|
|
69
69
|
tr.replaceWith(conversionInfo.from, conversionInfo.to, _newBodiedSyncBlockNode).scrollIntoView();
|
|
70
70
|
|
|
71
71
|
// set selection to the start of the previous selection for the position taken up by the start of the new synced block
|
|
@@ -178,7 +178,17 @@ var removeSyncedBlock = exports.removeSyncedBlock = function removeSyncedBlock(a
|
|
|
178
178
|
return true;
|
|
179
179
|
};
|
|
180
180
|
};
|
|
181
|
-
|
|
181
|
+
var removeSyncedBlockAtPos = exports.removeSyncedBlockAtPos = function removeSyncedBlockAtPos(api, pos) {
|
|
182
|
+
api === null || api === void 0 || api.core.actions.execute(function (_ref4) {
|
|
183
|
+
var tr = _ref4.tr;
|
|
184
|
+
var node = tr.doc.nodeAt(pos);
|
|
185
|
+
if ((node === null || node === void 0 ? void 0 : node.type.name) === 'syncBlock') {
|
|
186
|
+
var _node$nodeSize;
|
|
187
|
+
return tr.replace(pos, pos + ((_node$nodeSize = node === null || node === void 0 ? void 0 : node.nodeSize) !== null && _node$nodeSize !== void 0 ? _node$nodeSize : 0));
|
|
188
|
+
}
|
|
189
|
+
return tr;
|
|
190
|
+
});
|
|
191
|
+
};
|
|
182
192
|
/**
|
|
183
193
|
* Deletes (bodied)SyncBlock node and paste its content to the editor
|
|
184
194
|
*/
|
|
@@ -18,6 +18,7 @@ var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/rea
|
|
|
18
18
|
var _syncBlock = require("@atlaskit/editor-common/sync-block");
|
|
19
19
|
var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
|
|
20
20
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
21
|
+
var _editorCommands = require("../editor-commands");
|
|
21
22
|
var _SyncBlockRendererWrapper = require("../ui/SyncBlockRendererWrapper");
|
|
22
23
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
23
24
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
@@ -42,14 +43,15 @@ var SyncBlock = exports.SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
42
43
|
}
|
|
43
44
|
}, {
|
|
44
45
|
key: "render",
|
|
45
|
-
value: function render() {
|
|
46
|
+
value: function render(_ref) {
|
|
46
47
|
var _this$options,
|
|
47
48
|
_this$api$syncedBlock,
|
|
48
49
|
_this$api,
|
|
49
50
|
_this$api2,
|
|
50
|
-
_this$options2,
|
|
51
51
|
_this2 = this,
|
|
52
|
+
_this$options2,
|
|
52
53
|
_this$options3;
|
|
54
|
+
var getPos = _ref.getPos;
|
|
53
55
|
if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.syncedBlockRenderer)) {
|
|
54
56
|
return null;
|
|
55
57
|
}
|
|
@@ -70,6 +72,16 @@ var SyncBlock = exports.SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
70
72
|
component: _analytics.ACTION_SUBJECT.SYNCED_BLOCK,
|
|
71
73
|
dispatchAnalyticsEvent: (_this$api2 = this.api) === null || _this$api2 === void 0 || (_this$api2 = _this$api2.analytics) === null || _this$api2 === void 0 ? void 0 : _this$api2.actions.fireAnalyticsEvent,
|
|
72
74
|
fallbackComponent: null
|
|
75
|
+
}, /*#__PURE__*/_react.default.createElement(_syncBlock.SyncBlockActionsProvider, {
|
|
76
|
+
removeSyncBlock: function removeSyncBlock() {
|
|
77
|
+
var pos = getPos();
|
|
78
|
+
if (pos !== undefined) {
|
|
79
|
+
(0, _editorCommands.removeSyncedBlockAtPos)(_this2.api, pos);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
fetchSyncBlockSourceInfo: function fetchSyncBlockSourceInfo(sourceAri) {
|
|
83
|
+
return syncBlockStore.referenceManager.fetchSyncBlockSourceInfoBySourceAri(sourceAri);
|
|
84
|
+
}
|
|
73
85
|
}, /*#__PURE__*/_react.default.createElement(_SyncBlockRendererWrapper.SyncBlockRendererWrapper, {
|
|
74
86
|
localId: this.node.attrs.localId,
|
|
75
87
|
syncedBlockRenderer: (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.syncedBlockRenderer,
|
|
@@ -81,7 +93,7 @@ var SyncBlock = exports.SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
81
93
|
return (0, _editorSyncedBlockProvider.useFetchSyncBlockData)(syncBlockStore, resourceId, localId, (_this2$api = _this2.api) === null || _this2$api === void 0 || (_this2$api = _this2$api.analytics) === null || _this2$api === void 0 || (_this2$api = _this2$api.actions) === null || _this2$api === void 0 ? void 0 : _this2$api.fireAnalyticsEvent);
|
|
82
94
|
},
|
|
83
95
|
api: this.api
|
|
84
|
-
})) : /*#__PURE__*/_react.default.createElement(_SyncBlockRendererWrapper.SyncBlockRendererWrapper, {
|
|
96
|
+
}))) : /*#__PURE__*/_react.default.createElement(_SyncBlockRendererWrapper.SyncBlockRendererWrapper, {
|
|
85
97
|
localId: this.node.attrs.localId,
|
|
86
98
|
syncedBlockRenderer: (_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.syncedBlockRenderer,
|
|
87
99
|
useFetchSyncBlockTitle: function useFetchSyncBlockTitle() {
|
|
@@ -103,10 +115,10 @@ var SyncBlock = exports.SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
103
115
|
}
|
|
104
116
|
}]);
|
|
105
117
|
}(_reactNodeView.default);
|
|
106
|
-
var syncBlockNodeView = exports.syncBlockNodeView = function syncBlockNodeView(
|
|
107
|
-
var options =
|
|
108
|
-
pmPluginFactoryParams =
|
|
109
|
-
api =
|
|
118
|
+
var syncBlockNodeView = exports.syncBlockNodeView = function syncBlockNodeView(_ref2) {
|
|
119
|
+
var options = _ref2.options,
|
|
120
|
+
pmPluginFactoryParams = _ref2.pmPluginFactoryParams,
|
|
121
|
+
api = _ref2.api;
|
|
110
122
|
return function (node, view, getPos) {
|
|
111
123
|
var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
|
|
112
124
|
eventDispatcher = pmPluginFactoryParams.eventDispatcher;
|
|
@@ -26,10 +26,10 @@ var _main = require("../pm-plugins/main");
|
|
|
26
26
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
27
27
|
var modalContentMap = {
|
|
28
28
|
'source-block-deleted': {
|
|
29
|
-
titleMultiple: _messages.syncBlockMessages.
|
|
29
|
+
titleMultiple: _messages.syncBlockMessages.deleteConfirmationModalTitleMultiple,
|
|
30
30
|
titleSingle: _messages.syncBlockMessages.deleteConfirmationModalTitleSingle,
|
|
31
31
|
descriptionSingle: _messages.syncBlockMessages.deleteConfirmationModalDescriptionNoRef,
|
|
32
|
-
descriptionMultiple: _messages.syncBlockMessages.
|
|
32
|
+
descriptionMultiple: _messages.syncBlockMessages.deleteConfirmationModalDescriptionMultiple,
|
|
33
33
|
confirmButtonLabel: _messages.syncBlockMessages.deleteConfirmationModalDeleteButton
|
|
34
34
|
},
|
|
35
35
|
'source-block-unsynced': {
|
|
@@ -63,10 +63,6 @@ var DeleteConfirmationModal = exports.DeleteConfirmationModal = function DeleteC
|
|
|
63
63
|
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
64
64
|
deleteReason = _useState8[0],
|
|
65
65
|
setDeleteReason = _useState8[1];
|
|
66
|
-
var _useState9 = (0, _react.useState)('none'),
|
|
67
|
-
_useState0 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
68
|
-
fetchStatus = _useState0[0],
|
|
69
|
-
setFetchStatus = _useState0[1];
|
|
70
66
|
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['connectivity', 'syncedBlock'], function (states) {
|
|
71
67
|
var _states$connectivityS, _states$syncedBlockSt, _states$syncedBlockSt2;
|
|
72
68
|
return {
|
|
@@ -90,7 +86,6 @@ var DeleteConfirmationModal = exports.DeleteConfirmationModal = function DeleteC
|
|
|
90
86
|
}
|
|
91
87
|
if (!confirm) {
|
|
92
88
|
setIsOpen(false);
|
|
93
|
-
setFetchStatus('none');
|
|
94
89
|
setReferenceCount(undefined);
|
|
95
90
|
}
|
|
96
91
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
|
|
@@ -134,7 +129,6 @@ var DeleteConfirmationModal = exports.DeleteConfirmationModal = function DeleteC
|
|
|
134
129
|
var _api$core5;
|
|
135
130
|
// auto close modal once deletion is successful
|
|
136
131
|
setIsOpen(false);
|
|
137
|
-
setFetchStatus('none');
|
|
138
132
|
api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.execute(function (_ref4) {
|
|
139
133
|
var tr = _ref4.tr;
|
|
140
134
|
return tr.setMeta(_main.syncedBlockPluginKey, {
|
|
@@ -146,49 +140,65 @@ var DeleteConfirmationModal = exports.DeleteConfirmationModal = function DeleteC
|
|
|
146
140
|
}, [api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 ? void 0 : _api$core6.actions, bodiedSyncBlockDeletionStatus, isOpen]);
|
|
147
141
|
(0, _react.useEffect)(function () {
|
|
148
142
|
if (isOpen && syncBlockIds !== undefined && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
149
|
-
var
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
var references, _references$reference, _references$reference2;
|
|
155
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
156
|
-
while (1) switch (_context.prev = _context.next) {
|
|
143
|
+
var fetchReferences = /*#__PURE__*/function () {
|
|
144
|
+
var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
145
|
+
var references, totalCount;
|
|
146
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
147
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
157
148
|
case 0:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
149
|
+
_context2.prev = 0;
|
|
150
|
+
_context2.next = 3;
|
|
151
|
+
return Promise.all(syncBlockIds.map( /*#__PURE__*/function () {
|
|
152
|
+
var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(syncBlockId) {
|
|
153
|
+
var _references$reference, _references$reference2;
|
|
154
|
+
var references;
|
|
155
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
156
|
+
while (1) switch (_context.prev = _context.next) {
|
|
157
|
+
case 0:
|
|
158
|
+
_context.next = 2;
|
|
159
|
+
return syncBlockStoreManager.sourceManager.fetchReferences(syncBlockId.resourceId);
|
|
160
|
+
case 2:
|
|
161
|
+
references = _context.sent;
|
|
162
|
+
if (!(references !== null && references !== void 0 && references.error)) {
|
|
163
|
+
_context.next = 5;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
throw new Error();
|
|
167
|
+
case 5:
|
|
168
|
+
return _context.abrupt("return", (_references$reference = (_references$reference2 = references.references) === null || _references$reference2 === void 0 ? void 0 : _references$reference2.length) !== null && _references$reference !== void 0 ? _references$reference : 0);
|
|
169
|
+
case 6:
|
|
170
|
+
case "end":
|
|
171
|
+
return _context.stop();
|
|
172
|
+
}
|
|
173
|
+
}, _callee);
|
|
174
|
+
}));
|
|
175
|
+
return function (_x) {
|
|
176
|
+
return _ref6.apply(this, arguments);
|
|
177
|
+
};
|
|
178
|
+
}()));
|
|
179
|
+
case 3:
|
|
180
|
+
references = _context2.sent;
|
|
181
|
+
totalCount = references.reduce(function (sum, count) {
|
|
182
|
+
return sum + count;
|
|
183
|
+
}, 0);
|
|
184
|
+
setReferenceCount(totalCount);
|
|
185
|
+
_context2.next = 11;
|
|
186
|
+
break;
|
|
187
|
+
case 8:
|
|
188
|
+
_context2.prev = 8;
|
|
189
|
+
_context2.t0 = _context2["catch"](0);
|
|
190
|
+
setReferenceCount(0);
|
|
176
191
|
case 11:
|
|
177
|
-
_referenceCount += (_references$reference = (_references$reference2 = references.references) === null || _references$reference2 === void 0 ? void 0 : _references$reference2.length) !== null && _references$reference !== void 0 ? _references$reference : 0;
|
|
178
|
-
case 12:
|
|
179
192
|
case "end":
|
|
180
|
-
return
|
|
193
|
+
return _context2.stop();
|
|
181
194
|
}
|
|
182
|
-
},
|
|
195
|
+
}, _callee2, null, [[0, 8]]);
|
|
183
196
|
}));
|
|
184
|
-
return function (
|
|
197
|
+
return function fetchReferences() {
|
|
185
198
|
return _ref5.apply(this, arguments);
|
|
186
199
|
};
|
|
187
|
-
}()
|
|
188
|
-
|
|
189
|
-
setReferenceCount(_referenceCount);
|
|
190
|
-
setFetchStatus('success');
|
|
191
|
-
}
|
|
200
|
+
}();
|
|
201
|
+
fetchReferences();
|
|
192
202
|
}
|
|
193
203
|
}, [isOpen, syncBlockIds, syncBlockStoreManager.sourceManager]);
|
|
194
204
|
return /*#__PURE__*/_react.default.createElement(_modalDialog.ModalTransition, null, isOpen && /*#__PURE__*/_react.default.createElement(_modalDialog.default, {
|
|
@@ -207,7 +217,7 @@ var DeleteConfirmationModal = exports.DeleteConfirmationModal = function DeleteC
|
|
|
207
217
|
isDeleting: bodiedSyncBlockDeletionStatus === 'processing',
|
|
208
218
|
isDisabled: (0, _editorPluginConnectivity.isOfflineMode)(mode),
|
|
209
219
|
deleteReason: deleteReason,
|
|
210
|
-
|
|
220
|
+
sourceCount: (syncBlockIds === null || syncBlockIds === void 0 ? void 0 : syncBlockIds.length) || 0
|
|
211
221
|
})) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_modalDialog.ModalHeader, {
|
|
212
222
|
hasCloseButton: true
|
|
213
223
|
}, /*#__PURE__*/_react.default.createElement(_modalDialog.ModalTitle, {
|
|
@@ -225,29 +235,30 @@ var DeleteConfirmationModal = exports.DeleteConfirmationModal = function DeleteC
|
|
|
225
235
|
isLoading: bodiedSyncBlockDeletionStatus === 'processing'
|
|
226
236
|
}, formatMessage(_messages.syncBlockMessages.deleteConfirmationModalDeleteButton))))));
|
|
227
237
|
};
|
|
228
|
-
var ModalContent = function ModalContent(
|
|
229
|
-
var content =
|
|
230
|
-
referenceCount =
|
|
231
|
-
handleClick =
|
|
232
|
-
formatMessage =
|
|
233
|
-
isDeleting =
|
|
234
|
-
isDisabled =
|
|
235
|
-
deleteReason =
|
|
236
|
-
|
|
238
|
+
var ModalContent = function ModalContent(_ref7) {
|
|
239
|
+
var content = _ref7.content,
|
|
240
|
+
referenceCount = _ref7.referenceCount,
|
|
241
|
+
handleClick = _ref7.handleClick,
|
|
242
|
+
formatMessage = _ref7.formatMessage,
|
|
243
|
+
isDeleting = _ref7.isDeleting,
|
|
244
|
+
isDisabled = _ref7.isDisabled,
|
|
245
|
+
deleteReason = _ref7.deleteReason,
|
|
246
|
+
sourceCount = _ref7.sourceCount;
|
|
237
247
|
var titleMultiple = content.titleMultiple,
|
|
238
248
|
titleSingle = content.titleSingle,
|
|
239
249
|
descriptionSingle = content.descriptionSingle,
|
|
240
250
|
descriptionMultiple = content.descriptionMultiple,
|
|
241
251
|
confirmButtonLabel = content.confirmButtonLabel;
|
|
242
|
-
var hasNoReferenceOrFailToFetch = referenceCount === 0
|
|
252
|
+
var hasNoReferenceOrFailToFetch = referenceCount === 0;
|
|
253
|
+
var syncBlockCount = deleteReason === 'source-block-deleted' ? referenceCount + sourceCount : referenceCount;
|
|
243
254
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_modalDialog.ModalHeader, {
|
|
244
255
|
hasCloseButton: true
|
|
245
256
|
}, /*#__PURE__*/_react.default.createElement(_modalDialog.ModalTitle, {
|
|
246
257
|
appearance: "warning"
|
|
247
258
|
}, hasNoReferenceOrFailToFetch ? formatMessage(titleSingle) : formatMessage(titleMultiple, {
|
|
248
|
-
count:
|
|
259
|
+
count: syncBlockCount
|
|
249
260
|
}))), /*#__PURE__*/_react.default.createElement(_modalDialog.ModalBody, null, /*#__PURE__*/_react.default.createElement(_compiled.Text, null, hasNoReferenceOrFailToFetch ? formatMessage(descriptionSingle) : formatMessage(descriptionMultiple, {
|
|
250
|
-
syncBlockCount:
|
|
261
|
+
syncBlockCount: syncBlockCount
|
|
251
262
|
}))), /*#__PURE__*/_react.default.createElement(_modalDialog.ModalFooter, null, /*#__PURE__*/_react.default.createElement(_new.default, {
|
|
252
263
|
appearance: "subtle",
|
|
253
264
|
onClick: handleClick(false)
|
|
@@ -23,7 +23,8 @@ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
|
|
|
23
23
|
var contentUpdatedAt = _ref.contentUpdatedAt,
|
|
24
24
|
isSource = _ref.isSource,
|
|
25
25
|
localId = _ref.localId,
|
|
26
|
-
title = _ref.title
|
|
26
|
+
title = _ref.title,
|
|
27
|
+
isUnsyncedBlock = _ref.isUnsyncedBlock;
|
|
27
28
|
var intl = (0, _reactIntlNext.useIntl)();
|
|
28
29
|
var formatMessage = intl.formatMessage;
|
|
29
30
|
var _useState = (0, _react.useState)(formatMessage(_messages.syncBlockMessages.defaultSyncBlockTooltip)),
|
|
@@ -60,6 +61,25 @@ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
|
|
|
60
61
|
setTooltipContent(tooltipContent);
|
|
61
62
|
}, [contentUpdatedAt, formatMessage, intl, tooltipMessage]);
|
|
62
63
|
var ariaDescribedById = "sync-block-label-description-".concat(localId);
|
|
64
|
+
var getLabelContent = (0, _react.useMemo)(function () {
|
|
65
|
+
if (isUnsyncedBlock && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
66
|
+
return /*#__PURE__*/_react.default.createElement(_compiled.Text, {
|
|
67
|
+
size: "small",
|
|
68
|
+
color: "color.text.subtle"
|
|
69
|
+
}, formatMessage(_messages.syncBlockMessages.unsyncedBlockLabel));
|
|
70
|
+
}
|
|
71
|
+
if (isSource || !title) {
|
|
72
|
+
return /*#__PURE__*/_react.default.createElement(_compiled.Text, {
|
|
73
|
+
size: "small",
|
|
74
|
+
color: "color.text.subtle"
|
|
75
|
+
}, formatMessage(_messages.syncBlockMessages.syncedBlockLabel));
|
|
76
|
+
}
|
|
77
|
+
return /*#__PURE__*/_react.default.createElement(_compiled.Text, {
|
|
78
|
+
maxLines: 1,
|
|
79
|
+
size: "small",
|
|
80
|
+
color: "color.text.subtle"
|
|
81
|
+
}, title);
|
|
82
|
+
}, [formatMessage, isSource, isUnsyncedBlock, title]);
|
|
63
83
|
var label = /*#__PURE__*/_react.default.createElement("div", {
|
|
64
84
|
"data-testid": SyncBlockLabelDataId
|
|
65
85
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
@@ -70,15 +90,8 @@ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
|
|
|
70
90
|
color: "var(--ds-icon-subtle, #505258)",
|
|
71
91
|
size: "small",
|
|
72
92
|
label: ""
|
|
73
|
-
}),
|
|
74
|
-
|
|
75
|
-
color: "color.text.subtle"
|
|
76
|
-
}, formatMessage(_messages.syncBlockMessages.syncedBlockLabel)) : /*#__PURE__*/_react.default.createElement(_compiled.Text, {
|
|
77
|
-
maxLines: 1,
|
|
78
|
-
size: "small",
|
|
79
|
-
color: "color.text.subtle"
|
|
80
|
-
}, title));
|
|
81
|
-
if (isSource && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
93
|
+
}), getLabelContent);
|
|
94
|
+
if ((isSource || isUnsyncedBlock) && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
82
95
|
return label;
|
|
83
96
|
}
|
|
84
97
|
return /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
@@ -7,10 +7,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.SyncBlockRendererWrapper = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _syncBlock = require("@atlaskit/editor-common/sync-block");
|
|
10
|
+
var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
|
|
10
11
|
var _SyncBlockLabel = require("./SyncBlockLabel");
|
|
11
12
|
var SyncBlockRendererWrapperDataId = 'sync-block-plugin-renderer-wrapper';
|
|
12
13
|
var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperComponent(_ref) {
|
|
13
|
-
var _syncBlockFetchResult;
|
|
14
|
+
var _syncBlockFetchResult, _syncBlockFetchResult2;
|
|
14
15
|
var syncedBlockRenderer = _ref.syncedBlockRenderer,
|
|
15
16
|
useFetchSyncBlockData = _ref.useFetchSyncBlockData,
|
|
16
17
|
useFetchSyncBlockTitle = _ref.useFetchSyncBlockTitle,
|
|
@@ -19,6 +20,7 @@ var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperCompone
|
|
|
19
20
|
var syncBlockFetchResult = useFetchSyncBlockData();
|
|
20
21
|
var title = useFetchSyncBlockTitle === null || useFetchSyncBlockTitle === void 0 ? void 0 : useFetchSyncBlockTitle();
|
|
21
22
|
var contentUpdatedAt = syncBlockFetchResult === null || syncBlockFetchResult === void 0 || (_syncBlockFetchResult = syncBlockFetchResult.syncBlockInstance) === null || _syncBlockFetchResult === void 0 || (_syncBlockFetchResult = _syncBlockFetchResult.data) === null || _syncBlockFetchResult === void 0 ? void 0 : _syncBlockFetchResult.contentUpdatedAt;
|
|
23
|
+
var isUnsyncedBlock = (syncBlockFetchResult === null || syncBlockFetchResult === void 0 || (_syncBlockFetchResult2 = syncBlockFetchResult.syncBlockInstance) === null || _syncBlockFetchResult2 === void 0 || (_syncBlockFetchResult2 = _syncBlockFetchResult2.error) === null || _syncBlockFetchResult2 === void 0 ? void 0 : _syncBlockFetchResult2.type) === _editorSyncedBlockProvider.SyncBlockError.NotFound;
|
|
22
24
|
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
23
25
|
"data-testid": SyncBlockRendererWrapperDataId
|
|
24
26
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
@@ -31,7 +33,8 @@ var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperCompone
|
|
|
31
33
|
isSource: false,
|
|
32
34
|
title: title,
|
|
33
35
|
contentUpdatedAt: contentUpdatedAt,
|
|
34
|
-
localId: localId
|
|
36
|
+
localId: localId,
|
|
37
|
+
isUnsyncedBlock: isUnsyncedBlock
|
|
35
38
|
}));
|
|
36
39
|
};
|
|
37
40
|
var SyncBlockRendererWrapper = exports.SyncBlockRendererWrapper = /*#__PURE__*/_react.default.memo(SyncBlockRendererWrapperComponent);
|
|
@@ -65,7 +65,7 @@ export const createSyncedBlock = ({
|
|
|
65
65
|
|
|
66
66
|
// Save the new node with empty content to backend
|
|
67
67
|
// This is so that the node can be copied and referenced without the source being saved/published
|
|
68
|
-
syncBlockStore.sourceManager.createBodiedSyncBlockNode(attrs);
|
|
68
|
+
syncBlockStore.sourceManager.createBodiedSyncBlockNode(attrs, newBodiedSyncBlockNode);
|
|
69
69
|
tr.replaceWith(conversionInfo.from, conversionInfo.to, newBodiedSyncBlockNode).scrollIntoView();
|
|
70
70
|
|
|
71
71
|
// set selection to the start of the previous selection for the position taken up by the start of the new synced block
|
|
@@ -180,7 +180,18 @@ export const removeSyncedBlock = api => (state, dispatch, _view) => {
|
|
|
180
180
|
api === null || api === void 0 ? void 0 : api.core.actions.focus();
|
|
181
181
|
return true;
|
|
182
182
|
};
|
|
183
|
-
|
|
183
|
+
export const removeSyncedBlockAtPos = (api, pos) => {
|
|
184
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(({
|
|
185
|
+
tr
|
|
186
|
+
}) => {
|
|
187
|
+
const node = tr.doc.nodeAt(pos);
|
|
188
|
+
if ((node === null || node === void 0 ? void 0 : node.type.name) === 'syncBlock') {
|
|
189
|
+
var _node$nodeSize;
|
|
190
|
+
return tr.replace(pos, pos + ((_node$nodeSize = node === null || node === void 0 ? void 0 : node.nodeSize) !== null && _node$nodeSize !== void 0 ? _node$nodeSize : 0));
|
|
191
|
+
}
|
|
192
|
+
return tr;
|
|
193
|
+
});
|
|
194
|
+
};
|
|
184
195
|
/**
|
|
185
196
|
* Deletes (bodied)SyncBlock node and paste its content to the editor
|
|
186
197
|
*/
|
|
@@ -2,9 +2,10 @@ import React from 'react';
|
|
|
2
2
|
import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
4
4
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
5
|
-
import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
|
|
5
|
+
import { SyncBlockSharedCssClassName, SyncBlockActionsProvider } from '@atlaskit/editor-common/sync-block';
|
|
6
6
|
import { useFetchSyncBlockData, useFetchSyncBlockTitle } from '@atlaskit/editor-synced-block-provider';
|
|
7
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
|
+
import { removeSyncedBlockAtPos } from '../editor-commands';
|
|
8
9
|
import { SyncBlockRendererWrapper } from '../ui/SyncBlockRendererWrapper';
|
|
9
10
|
export class SyncBlock extends ReactNodeView {
|
|
10
11
|
constructor(props) {
|
|
@@ -18,7 +19,9 @@ export class SyncBlock extends ReactNodeView {
|
|
|
18
19
|
domRef.classList.add(SyncBlockSharedCssClassName.prefix);
|
|
19
20
|
return domRef;
|
|
20
21
|
}
|
|
21
|
-
render(
|
|
22
|
+
render({
|
|
23
|
+
getPos
|
|
24
|
+
}) {
|
|
22
25
|
var _this$options, _this$api$syncedBlock, _this$api, _this$api$syncedBlock2, _this$api$syncedBlock3, _this$api2, _this$api2$analytics, _this$options2, _this$options3;
|
|
23
26
|
if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.syncedBlockRenderer)) {
|
|
24
27
|
return null;
|
|
@@ -41,6 +44,14 @@ export class SyncBlock extends ReactNodeView {
|
|
|
41
44
|
component: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
42
45
|
dispatchAnalyticsEvent: (_this$api2 = this.api) === null || _this$api2 === void 0 ? void 0 : (_this$api2$analytics = _this$api2.analytics) === null || _this$api2$analytics === void 0 ? void 0 : _this$api2$analytics.actions.fireAnalyticsEvent,
|
|
43
46
|
fallbackComponent: null
|
|
47
|
+
}, /*#__PURE__*/React.createElement(SyncBlockActionsProvider, {
|
|
48
|
+
removeSyncBlock: () => {
|
|
49
|
+
const pos = getPos();
|
|
50
|
+
if (pos !== undefined) {
|
|
51
|
+
removeSyncedBlockAtPos(this.api, pos);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
fetchSyncBlockSourceInfo: sourceAri => syncBlockStore.referenceManager.fetchSyncBlockSourceInfoBySourceAri(sourceAri)
|
|
44
55
|
}, /*#__PURE__*/React.createElement(SyncBlockRendererWrapper, {
|
|
45
56
|
localId: this.node.attrs.localId,
|
|
46
57
|
syncedBlockRenderer: (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.syncedBlockRenderer,
|
|
@@ -50,7 +61,7 @@ export class SyncBlock extends ReactNodeView {
|
|
|
50
61
|
return useFetchSyncBlockData(syncBlockStore, resourceId, localId, (_this$api3 = this.api) === null || _this$api3 === void 0 ? void 0 : (_this$api3$analytics = _this$api3.analytics) === null || _this$api3$analytics === void 0 ? void 0 : (_this$api3$analytics$ = _this$api3$analytics.actions) === null || _this$api3$analytics$ === void 0 ? void 0 : _this$api3$analytics$.fireAnalyticsEvent);
|
|
51
62
|
},
|
|
52
63
|
api: this.api
|
|
53
|
-
})) : /*#__PURE__*/React.createElement(SyncBlockRendererWrapper, {
|
|
64
|
+
}))) : /*#__PURE__*/React.createElement(SyncBlockRendererWrapper, {
|
|
54
65
|
localId: this.node.attrs.localId,
|
|
55
66
|
syncedBlockRenderer: (_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.syncedBlockRenderer,
|
|
56
67
|
useFetchSyncBlockTitle: () => useFetchSyncBlockTitle(syncBlockStore, this.node),
|
|
@@ -81,7 +92,7 @@ export const syncBlockNodeView = ({
|
|
|
81
92
|
options,
|
|
82
93
|
node,
|
|
83
94
|
view,
|
|
84
|
-
getPos,
|
|
95
|
+
getPos: getPos,
|
|
85
96
|
portalProviderAPI,
|
|
86
97
|
eventDispatcher
|
|
87
98
|
}).init();
|
|
@@ -14,10 +14,10 @@ import Spinner from '@atlaskit/spinner';
|
|
|
14
14
|
import { syncedBlockPluginKey } from '../pm-plugins/main';
|
|
15
15
|
const modalContentMap = {
|
|
16
16
|
'source-block-deleted': {
|
|
17
|
-
titleMultiple: messages.
|
|
17
|
+
titleMultiple: messages.deleteConfirmationModalTitleMultiple,
|
|
18
18
|
titleSingle: messages.deleteConfirmationModalTitleSingle,
|
|
19
19
|
descriptionSingle: messages.deleteConfirmationModalDescriptionNoRef,
|
|
20
|
-
descriptionMultiple: messages.
|
|
20
|
+
descriptionMultiple: messages.deleteConfirmationModalDescriptionMultiple,
|
|
21
21
|
confirmButtonLabel: messages.deleteConfirmationModalDeleteButton
|
|
22
22
|
},
|
|
23
23
|
'source-block-unsynced': {
|
|
@@ -40,7 +40,6 @@ export const DeleteConfirmationModal = ({
|
|
|
40
40
|
const [syncBlockIds, setSyncBlockIds] = useState(undefined);
|
|
41
41
|
const [referenceCount, setReferenceCount] = useState(undefined);
|
|
42
42
|
const [deleteReason, setDeleteReason] = useState('source-block-deleted');
|
|
43
|
-
const [fetchStatus, setFetchStatus] = useState('none');
|
|
44
43
|
const {
|
|
45
44
|
mode,
|
|
46
45
|
bodiedSyncBlockDeletionStatus,
|
|
@@ -65,7 +64,6 @@ export const DeleteConfirmationModal = ({
|
|
|
65
64
|
}
|
|
66
65
|
if (!confirm) {
|
|
67
66
|
setIsOpen(false);
|
|
68
|
-
setFetchStatus('none');
|
|
69
67
|
setReferenceCount(undefined);
|
|
70
68
|
}
|
|
71
69
|
api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(({
|
|
@@ -110,7 +108,6 @@ export const DeleteConfirmationModal = ({
|
|
|
110
108
|
var _api$core5;
|
|
111
109
|
// auto close modal once deletion is successful
|
|
112
110
|
setIsOpen(false);
|
|
113
|
-
setFetchStatus('none');
|
|
114
111
|
api === null || api === void 0 ? void 0 : (_api$core5 = api.core) === null || _api$core5 === void 0 ? void 0 : _api$core5.actions.execute(({
|
|
115
112
|
tr
|
|
116
113
|
}) => {
|
|
@@ -123,28 +120,24 @@ export const DeleteConfirmationModal = ({
|
|
|
123
120
|
}, [api === null || api === void 0 ? void 0 : (_api$core6 = api.core) === null || _api$core6 === void 0 ? void 0 : _api$core6.actions, bodiedSyncBlockDeletionStatus, isOpen]);
|
|
124
121
|
useEffect(() => {
|
|
125
122
|
if (isOpen && syncBlockIds !== undefined && fg('platform_synced_block_dogfooding')) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
123
|
+
const fetchReferences = async () => {
|
|
124
|
+
try {
|
|
125
|
+
const references = await Promise.all(syncBlockIds.map(async syncBlockId => {
|
|
126
|
+
var _references$reference, _references$reference2;
|
|
127
|
+
const references = await syncBlockStoreManager.sourceManager.fetchReferences(syncBlockId.resourceId);
|
|
128
|
+
if (references !== null && references !== void 0 && references.error) {
|
|
129
|
+
// Consider fetch fails as soon as one of the fetches fails
|
|
130
|
+
throw new Error();
|
|
131
|
+
}
|
|
132
|
+
return (_references$reference = (_references$reference2 = references.references) === null || _references$reference2 === void 0 ? void 0 : _references$reference2.length) !== null && _references$reference !== void 0 ? _references$reference : 0;
|
|
133
|
+
}));
|
|
134
|
+
const totalCount = references.reduce((sum, count) => sum + count, 0);
|
|
135
|
+
setReferenceCount(totalCount);
|
|
136
|
+
} catch {
|
|
137
|
+
setReferenceCount(0);
|
|
132
138
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
// Consider fetch fails as soon as one of the fetches fails
|
|
136
|
-
setFetchStatus('error');
|
|
137
|
-
fetchFailed = true;
|
|
138
|
-
return;
|
|
139
|
-
} else {
|
|
140
|
-
var _references$reference, _references$reference2;
|
|
141
|
-
referenceCount += (_references$reference = (_references$reference2 = references.references) === null || _references$reference2 === void 0 ? void 0 : _references$reference2.length) !== null && _references$reference !== void 0 ? _references$reference : 0;
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
if (!fetchFailed) {
|
|
145
|
-
setReferenceCount(referenceCount);
|
|
146
|
-
setFetchStatus('success');
|
|
147
|
-
}
|
|
139
|
+
};
|
|
140
|
+
fetchReferences();
|
|
148
141
|
}
|
|
149
142
|
}, [isOpen, syncBlockIds, syncBlockStoreManager.sourceManager]);
|
|
150
143
|
return /*#__PURE__*/React.createElement(ModalTransition, null, isOpen && /*#__PURE__*/React.createElement(ModalDialog, {
|
|
@@ -163,7 +156,7 @@ export const DeleteConfirmationModal = ({
|
|
|
163
156
|
isDeleting: bodiedSyncBlockDeletionStatus === 'processing',
|
|
164
157
|
isDisabled: isOfflineMode(mode),
|
|
165
158
|
deleteReason: deleteReason,
|
|
166
|
-
|
|
159
|
+
sourceCount: (syncBlockIds === null || syncBlockIds === void 0 ? void 0 : syncBlockIds.length) || 0
|
|
167
160
|
})) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ModalHeader, {
|
|
168
161
|
hasCloseButton: true
|
|
169
162
|
}, /*#__PURE__*/React.createElement(ModalTitle, {
|
|
@@ -189,7 +182,7 @@ const ModalContent = ({
|
|
|
189
182
|
isDeleting,
|
|
190
183
|
isDisabled,
|
|
191
184
|
deleteReason,
|
|
192
|
-
|
|
185
|
+
sourceCount
|
|
193
186
|
}) => {
|
|
194
187
|
const {
|
|
195
188
|
titleMultiple,
|
|
@@ -198,15 +191,16 @@ const ModalContent = ({
|
|
|
198
191
|
descriptionMultiple,
|
|
199
192
|
confirmButtonLabel
|
|
200
193
|
} = content;
|
|
201
|
-
const hasNoReferenceOrFailToFetch = referenceCount === 0
|
|
194
|
+
const hasNoReferenceOrFailToFetch = referenceCount === 0;
|
|
195
|
+
const syncBlockCount = deleteReason === 'source-block-deleted' ? referenceCount + sourceCount : referenceCount;
|
|
202
196
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ModalHeader, {
|
|
203
197
|
hasCloseButton: true
|
|
204
198
|
}, /*#__PURE__*/React.createElement(ModalTitle, {
|
|
205
199
|
appearance: "warning"
|
|
206
200
|
}, hasNoReferenceOrFailToFetch ? formatMessage(titleSingle) : formatMessage(titleMultiple, {
|
|
207
|
-
count:
|
|
201
|
+
count: syncBlockCount
|
|
208
202
|
}))), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement(Text, null, hasNoReferenceOrFailToFetch ? formatMessage(descriptionSingle) : formatMessage(descriptionMultiple, {
|
|
209
|
-
syncBlockCount
|
|
203
|
+
syncBlockCount
|
|
210
204
|
}))), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
|
|
211
205
|
appearance: "subtle",
|
|
212
206
|
onClick: handleClick(false)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback, useState } from 'react';
|
|
1
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl-next';
|
|
3
3
|
import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
4
4
|
import { SyncBlockLabelSharedCssClassName } from '@atlaskit/editor-common/sync-block';
|
|
@@ -13,7 +13,8 @@ const SyncBlockLabelComponent = ({
|
|
|
13
13
|
contentUpdatedAt,
|
|
14
14
|
isSource,
|
|
15
15
|
localId,
|
|
16
|
-
title
|
|
16
|
+
title,
|
|
17
|
+
isUnsyncedBlock
|
|
17
18
|
}) => {
|
|
18
19
|
const intl = useIntl();
|
|
19
20
|
const {
|
|
@@ -50,6 +51,25 @@ const SyncBlockLabelComponent = ({
|
|
|
50
51
|
setTooltipContent(tooltipContent);
|
|
51
52
|
}, [contentUpdatedAt, formatMessage, intl, tooltipMessage]);
|
|
52
53
|
const ariaDescribedById = `sync-block-label-description-${localId}`;
|
|
54
|
+
const getLabelContent = useMemo(() => {
|
|
55
|
+
if (isUnsyncedBlock && fg('platform_synced_block_dogfooding')) {
|
|
56
|
+
return /*#__PURE__*/React.createElement(Text, {
|
|
57
|
+
size: "small",
|
|
58
|
+
color: "color.text.subtle"
|
|
59
|
+
}, formatMessage(messages.unsyncedBlockLabel));
|
|
60
|
+
}
|
|
61
|
+
if (isSource || !title) {
|
|
62
|
+
return /*#__PURE__*/React.createElement(Text, {
|
|
63
|
+
size: "small",
|
|
64
|
+
color: "color.text.subtle"
|
|
65
|
+
}, formatMessage(messages.syncedBlockLabel));
|
|
66
|
+
}
|
|
67
|
+
return /*#__PURE__*/React.createElement(Text, {
|
|
68
|
+
maxLines: 1,
|
|
69
|
+
size: "small",
|
|
70
|
+
color: "color.text.subtle"
|
|
71
|
+
}, title);
|
|
72
|
+
}, [formatMessage, isSource, isUnsyncedBlock, title]);
|
|
53
73
|
const label = /*#__PURE__*/React.createElement("div", {
|
|
54
74
|
"data-testid": SyncBlockLabelDataId
|
|
55
75
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
@@ -60,15 +80,8 @@ const SyncBlockLabelComponent = ({
|
|
|
60
80
|
color: "var(--ds-icon-subtle, #505258)",
|
|
61
81
|
size: "small",
|
|
62
82
|
label: ""
|
|
63
|
-
}),
|
|
64
|
-
|
|
65
|
-
color: "color.text.subtle"
|
|
66
|
-
}, formatMessage(messages.syncedBlockLabel)) : /*#__PURE__*/React.createElement(Text, {
|
|
67
|
-
maxLines: 1,
|
|
68
|
-
size: "small",
|
|
69
|
-
color: "color.text.subtle"
|
|
70
|
-
}, title));
|
|
71
|
-
if (isSource && fg('platform_synced_block_dogfooding')) {
|
|
83
|
+
}), getLabelContent);
|
|
84
|
+
if ((isSource || isUnsyncedBlock) && fg('platform_synced_block_dogfooding')) {
|
|
72
85
|
return label;
|
|
73
86
|
}
|
|
74
87
|
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
|
|
3
|
+
import { SyncBlockError } from '@atlaskit/editor-synced-block-provider';
|
|
3
4
|
import { SyncBlockLabel } from './SyncBlockLabel';
|
|
4
5
|
const SyncBlockRendererWrapperDataId = 'sync-block-plugin-renderer-wrapper';
|
|
5
6
|
const SyncBlockRendererWrapperComponent = ({
|
|
@@ -9,10 +10,11 @@ const SyncBlockRendererWrapperComponent = ({
|
|
|
9
10
|
localId,
|
|
10
11
|
api
|
|
11
12
|
}) => {
|
|
12
|
-
var _syncBlockFetchResult, _syncBlockFetchResult2;
|
|
13
|
+
var _syncBlockFetchResult, _syncBlockFetchResult2, _syncBlockFetchResult3, _syncBlockFetchResult4;
|
|
13
14
|
const syncBlockFetchResult = useFetchSyncBlockData();
|
|
14
15
|
const title = useFetchSyncBlockTitle === null || useFetchSyncBlockTitle === void 0 ? void 0 : useFetchSyncBlockTitle();
|
|
15
16
|
const contentUpdatedAt = syncBlockFetchResult === null || syncBlockFetchResult === void 0 ? void 0 : (_syncBlockFetchResult = syncBlockFetchResult.syncBlockInstance) === null || _syncBlockFetchResult === void 0 ? void 0 : (_syncBlockFetchResult2 = _syncBlockFetchResult.data) === null || _syncBlockFetchResult2 === void 0 ? void 0 : _syncBlockFetchResult2.contentUpdatedAt;
|
|
17
|
+
const isUnsyncedBlock = (syncBlockFetchResult === null || syncBlockFetchResult === void 0 ? void 0 : (_syncBlockFetchResult3 = syncBlockFetchResult.syncBlockInstance) === null || _syncBlockFetchResult3 === void 0 ? void 0 : (_syncBlockFetchResult4 = _syncBlockFetchResult3.error) === null || _syncBlockFetchResult4 === void 0 ? void 0 : _syncBlockFetchResult4.type) === SyncBlockError.NotFound;
|
|
16
18
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
17
19
|
"data-testid": SyncBlockRendererWrapperDataId
|
|
18
20
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
@@ -25,7 +27,8 @@ const SyncBlockRendererWrapperComponent = ({
|
|
|
25
27
|
isSource: false,
|
|
26
28
|
title: title,
|
|
27
29
|
contentUpdatedAt: contentUpdatedAt,
|
|
28
|
-
localId: localId
|
|
30
|
+
localId: localId,
|
|
31
|
+
isUnsyncedBlock: isUnsyncedBlock
|
|
29
32
|
}));
|
|
30
33
|
};
|
|
31
34
|
export const SyncBlockRendererWrapper = /*#__PURE__*/React.memo(SyncBlockRendererWrapperComponent);
|
|
@@ -59,7 +59,7 @@ export var createSyncedBlock = function createSyncedBlock(_ref) {
|
|
|
59
59
|
|
|
60
60
|
// Save the new node with empty content to backend
|
|
61
61
|
// This is so that the node can be copied and referenced without the source being saved/published
|
|
62
|
-
syncBlockStore.sourceManager.createBodiedSyncBlockNode(_attrs);
|
|
62
|
+
syncBlockStore.sourceManager.createBodiedSyncBlockNode(_attrs, _newBodiedSyncBlockNode);
|
|
63
63
|
tr.replaceWith(conversionInfo.from, conversionInfo.to, _newBodiedSyncBlockNode).scrollIntoView();
|
|
64
64
|
|
|
65
65
|
// set selection to the start of the previous selection for the position taken up by the start of the new synced block
|
|
@@ -172,7 +172,17 @@ export var removeSyncedBlock = function removeSyncedBlock(api) {
|
|
|
172
172
|
return true;
|
|
173
173
|
};
|
|
174
174
|
};
|
|
175
|
-
|
|
175
|
+
export var removeSyncedBlockAtPos = function removeSyncedBlockAtPos(api, pos) {
|
|
176
|
+
api === null || api === void 0 || api.core.actions.execute(function (_ref4) {
|
|
177
|
+
var tr = _ref4.tr;
|
|
178
|
+
var node = tr.doc.nodeAt(pos);
|
|
179
|
+
if ((node === null || node === void 0 ? void 0 : node.type.name) === 'syncBlock') {
|
|
180
|
+
var _node$nodeSize;
|
|
181
|
+
return tr.replace(pos, pos + ((_node$nodeSize = node === null || node === void 0 ? void 0 : node.nodeSize) !== null && _node$nodeSize !== void 0 ? _node$nodeSize : 0));
|
|
182
|
+
}
|
|
183
|
+
return tr;
|
|
184
|
+
});
|
|
185
|
+
};
|
|
176
186
|
/**
|
|
177
187
|
* Deletes (bodied)SyncBlock node and paste its content to the editor
|
|
178
188
|
*/
|
|
@@ -11,9 +11,10 @@ import React from 'react';
|
|
|
11
11
|
import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
|
|
12
12
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
13
13
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
14
|
-
import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
|
|
14
|
+
import { SyncBlockSharedCssClassName, SyncBlockActionsProvider } from '@atlaskit/editor-common/sync-block';
|
|
15
15
|
import { useFetchSyncBlockData as _useFetchSyncBlockData, useFetchSyncBlockTitle as _useFetchSyncBlockTitle } from '@atlaskit/editor-synced-block-provider';
|
|
16
16
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
17
|
+
import { removeSyncedBlockAtPos } from '../editor-commands';
|
|
17
18
|
import { SyncBlockRendererWrapper } from '../ui/SyncBlockRendererWrapper';
|
|
18
19
|
export var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
19
20
|
function SyncBlock(props) {
|
|
@@ -35,14 +36,15 @@ export var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
35
36
|
}
|
|
36
37
|
}, {
|
|
37
38
|
key: "render",
|
|
38
|
-
value: function render() {
|
|
39
|
+
value: function render(_ref) {
|
|
39
40
|
var _this$options,
|
|
40
41
|
_this$api$syncedBlock,
|
|
41
42
|
_this$api,
|
|
42
43
|
_this$api2,
|
|
43
|
-
_this$options2,
|
|
44
44
|
_this2 = this,
|
|
45
|
+
_this$options2,
|
|
45
46
|
_this$options3;
|
|
47
|
+
var getPos = _ref.getPos;
|
|
46
48
|
if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.syncedBlockRenderer)) {
|
|
47
49
|
return null;
|
|
48
50
|
}
|
|
@@ -63,6 +65,16 @@ export var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
63
65
|
component: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
64
66
|
dispatchAnalyticsEvent: (_this$api2 = this.api) === null || _this$api2 === void 0 || (_this$api2 = _this$api2.analytics) === null || _this$api2 === void 0 ? void 0 : _this$api2.actions.fireAnalyticsEvent,
|
|
65
67
|
fallbackComponent: null
|
|
68
|
+
}, /*#__PURE__*/React.createElement(SyncBlockActionsProvider, {
|
|
69
|
+
removeSyncBlock: function removeSyncBlock() {
|
|
70
|
+
var pos = getPos();
|
|
71
|
+
if (pos !== undefined) {
|
|
72
|
+
removeSyncedBlockAtPos(_this2.api, pos);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
fetchSyncBlockSourceInfo: function fetchSyncBlockSourceInfo(sourceAri) {
|
|
76
|
+
return syncBlockStore.referenceManager.fetchSyncBlockSourceInfoBySourceAri(sourceAri);
|
|
77
|
+
}
|
|
66
78
|
}, /*#__PURE__*/React.createElement(SyncBlockRendererWrapper, {
|
|
67
79
|
localId: this.node.attrs.localId,
|
|
68
80
|
syncedBlockRenderer: (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.syncedBlockRenderer,
|
|
@@ -74,7 +86,7 @@ export var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
74
86
|
return _useFetchSyncBlockData(syncBlockStore, resourceId, localId, (_this2$api = _this2.api) === null || _this2$api === void 0 || (_this2$api = _this2$api.analytics) === null || _this2$api === void 0 || (_this2$api = _this2$api.actions) === null || _this2$api === void 0 ? void 0 : _this2$api.fireAnalyticsEvent);
|
|
75
87
|
},
|
|
76
88
|
api: this.api
|
|
77
|
-
})) : /*#__PURE__*/React.createElement(SyncBlockRendererWrapper, {
|
|
89
|
+
}))) : /*#__PURE__*/React.createElement(SyncBlockRendererWrapper, {
|
|
78
90
|
localId: this.node.attrs.localId,
|
|
79
91
|
syncedBlockRenderer: (_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.syncedBlockRenderer,
|
|
80
92
|
useFetchSyncBlockTitle: function useFetchSyncBlockTitle() {
|
|
@@ -96,10 +108,10 @@ export var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
96
108
|
}
|
|
97
109
|
}]);
|
|
98
110
|
}(ReactNodeView);
|
|
99
|
-
export var syncBlockNodeView = function syncBlockNodeView(
|
|
100
|
-
var options =
|
|
101
|
-
pmPluginFactoryParams =
|
|
102
|
-
api =
|
|
111
|
+
export var syncBlockNodeView = function syncBlockNodeView(_ref2) {
|
|
112
|
+
var options = _ref2.options,
|
|
113
|
+
pmPluginFactoryParams = _ref2.pmPluginFactoryParams,
|
|
114
|
+
api = _ref2.api;
|
|
103
115
|
return function (node, view, getPos) {
|
|
104
116
|
var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
|
|
105
117
|
eventDispatcher = pmPluginFactoryParams.eventDispatcher;
|
|
@@ -17,10 +17,10 @@ import Spinner from '@atlaskit/spinner';
|
|
|
17
17
|
import { syncedBlockPluginKey } from '../pm-plugins/main';
|
|
18
18
|
var modalContentMap = {
|
|
19
19
|
'source-block-deleted': {
|
|
20
|
-
titleMultiple: messages.
|
|
20
|
+
titleMultiple: messages.deleteConfirmationModalTitleMultiple,
|
|
21
21
|
titleSingle: messages.deleteConfirmationModalTitleSingle,
|
|
22
22
|
descriptionSingle: messages.deleteConfirmationModalDescriptionNoRef,
|
|
23
|
-
descriptionMultiple: messages.
|
|
23
|
+
descriptionMultiple: messages.deleteConfirmationModalDescriptionMultiple,
|
|
24
24
|
confirmButtonLabel: messages.deleteConfirmationModalDeleteButton
|
|
25
25
|
},
|
|
26
26
|
'source-block-unsynced': {
|
|
@@ -54,10 +54,6 @@ export var DeleteConfirmationModal = function DeleteConfirmationModal(_ref) {
|
|
|
54
54
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
55
55
|
deleteReason = _useState8[0],
|
|
56
56
|
setDeleteReason = _useState8[1];
|
|
57
|
-
var _useState9 = useState('none'),
|
|
58
|
-
_useState0 = _slicedToArray(_useState9, 2),
|
|
59
|
-
fetchStatus = _useState0[0],
|
|
60
|
-
setFetchStatus = _useState0[1];
|
|
61
57
|
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['connectivity', 'syncedBlock'], function (states) {
|
|
62
58
|
var _states$connectivityS, _states$syncedBlockSt, _states$syncedBlockSt2;
|
|
63
59
|
return {
|
|
@@ -81,7 +77,6 @@ export var DeleteConfirmationModal = function DeleteConfirmationModal(_ref) {
|
|
|
81
77
|
}
|
|
82
78
|
if (!confirm) {
|
|
83
79
|
setIsOpen(false);
|
|
84
|
-
setFetchStatus('none');
|
|
85
80
|
setReferenceCount(undefined);
|
|
86
81
|
}
|
|
87
82
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
|
|
@@ -125,7 +120,6 @@ export var DeleteConfirmationModal = function DeleteConfirmationModal(_ref) {
|
|
|
125
120
|
var _api$core5;
|
|
126
121
|
// auto close modal once deletion is successful
|
|
127
122
|
setIsOpen(false);
|
|
128
|
-
setFetchStatus('none');
|
|
129
123
|
api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.execute(function (_ref4) {
|
|
130
124
|
var tr = _ref4.tr;
|
|
131
125
|
return tr.setMeta(syncedBlockPluginKey, {
|
|
@@ -137,49 +131,65 @@ export var DeleteConfirmationModal = function DeleteConfirmationModal(_ref) {
|
|
|
137
131
|
}, [api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 ? void 0 : _api$core6.actions, bodiedSyncBlockDeletionStatus, isOpen]);
|
|
138
132
|
useEffect(function () {
|
|
139
133
|
if (isOpen && syncBlockIds !== undefined && fg('platform_synced_block_dogfooding')) {
|
|
140
|
-
var
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
var references, _references$reference, _references$reference2;
|
|
146
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
147
|
-
while (1) switch (_context.prev = _context.next) {
|
|
134
|
+
var fetchReferences = /*#__PURE__*/function () {
|
|
135
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
136
|
+
var references, totalCount;
|
|
137
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
138
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
148
139
|
case 0:
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
140
|
+
_context2.prev = 0;
|
|
141
|
+
_context2.next = 3;
|
|
142
|
+
return Promise.all(syncBlockIds.map( /*#__PURE__*/function () {
|
|
143
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(syncBlockId) {
|
|
144
|
+
var _references$reference, _references$reference2;
|
|
145
|
+
var references;
|
|
146
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
147
|
+
while (1) switch (_context.prev = _context.next) {
|
|
148
|
+
case 0:
|
|
149
|
+
_context.next = 2;
|
|
150
|
+
return syncBlockStoreManager.sourceManager.fetchReferences(syncBlockId.resourceId);
|
|
151
|
+
case 2:
|
|
152
|
+
references = _context.sent;
|
|
153
|
+
if (!(references !== null && references !== void 0 && references.error)) {
|
|
154
|
+
_context.next = 5;
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
throw new Error();
|
|
158
|
+
case 5:
|
|
159
|
+
return _context.abrupt("return", (_references$reference = (_references$reference2 = references.references) === null || _references$reference2 === void 0 ? void 0 : _references$reference2.length) !== null && _references$reference !== void 0 ? _references$reference : 0);
|
|
160
|
+
case 6:
|
|
161
|
+
case "end":
|
|
162
|
+
return _context.stop();
|
|
163
|
+
}
|
|
164
|
+
}, _callee);
|
|
165
|
+
}));
|
|
166
|
+
return function (_x) {
|
|
167
|
+
return _ref6.apply(this, arguments);
|
|
168
|
+
};
|
|
169
|
+
}()));
|
|
170
|
+
case 3:
|
|
171
|
+
references = _context2.sent;
|
|
172
|
+
totalCount = references.reduce(function (sum, count) {
|
|
173
|
+
return sum + count;
|
|
174
|
+
}, 0);
|
|
175
|
+
setReferenceCount(totalCount);
|
|
176
|
+
_context2.next = 11;
|
|
177
|
+
break;
|
|
178
|
+
case 8:
|
|
179
|
+
_context2.prev = 8;
|
|
180
|
+
_context2.t0 = _context2["catch"](0);
|
|
181
|
+
setReferenceCount(0);
|
|
167
182
|
case 11:
|
|
168
|
-
_referenceCount += (_references$reference = (_references$reference2 = references.references) === null || _references$reference2 === void 0 ? void 0 : _references$reference2.length) !== null && _references$reference !== void 0 ? _references$reference : 0;
|
|
169
|
-
case 12:
|
|
170
183
|
case "end":
|
|
171
|
-
return
|
|
184
|
+
return _context2.stop();
|
|
172
185
|
}
|
|
173
|
-
},
|
|
186
|
+
}, _callee2, null, [[0, 8]]);
|
|
174
187
|
}));
|
|
175
|
-
return function (
|
|
188
|
+
return function fetchReferences() {
|
|
176
189
|
return _ref5.apply(this, arguments);
|
|
177
190
|
};
|
|
178
|
-
}()
|
|
179
|
-
|
|
180
|
-
setReferenceCount(_referenceCount);
|
|
181
|
-
setFetchStatus('success');
|
|
182
|
-
}
|
|
191
|
+
}();
|
|
192
|
+
fetchReferences();
|
|
183
193
|
}
|
|
184
194
|
}, [isOpen, syncBlockIds, syncBlockStoreManager.sourceManager]);
|
|
185
195
|
return /*#__PURE__*/React.createElement(ModalTransition, null, isOpen && /*#__PURE__*/React.createElement(ModalDialog, {
|
|
@@ -198,7 +208,7 @@ export var DeleteConfirmationModal = function DeleteConfirmationModal(_ref) {
|
|
|
198
208
|
isDeleting: bodiedSyncBlockDeletionStatus === 'processing',
|
|
199
209
|
isDisabled: isOfflineMode(mode),
|
|
200
210
|
deleteReason: deleteReason,
|
|
201
|
-
|
|
211
|
+
sourceCount: (syncBlockIds === null || syncBlockIds === void 0 ? void 0 : syncBlockIds.length) || 0
|
|
202
212
|
})) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ModalHeader, {
|
|
203
213
|
hasCloseButton: true
|
|
204
214
|
}, /*#__PURE__*/React.createElement(ModalTitle, {
|
|
@@ -216,29 +226,30 @@ export var DeleteConfirmationModal = function DeleteConfirmationModal(_ref) {
|
|
|
216
226
|
isLoading: bodiedSyncBlockDeletionStatus === 'processing'
|
|
217
227
|
}, formatMessage(messages.deleteConfirmationModalDeleteButton))))));
|
|
218
228
|
};
|
|
219
|
-
var ModalContent = function ModalContent(
|
|
220
|
-
var content =
|
|
221
|
-
referenceCount =
|
|
222
|
-
handleClick =
|
|
223
|
-
formatMessage =
|
|
224
|
-
isDeleting =
|
|
225
|
-
isDisabled =
|
|
226
|
-
deleteReason =
|
|
227
|
-
|
|
229
|
+
var ModalContent = function ModalContent(_ref7) {
|
|
230
|
+
var content = _ref7.content,
|
|
231
|
+
referenceCount = _ref7.referenceCount,
|
|
232
|
+
handleClick = _ref7.handleClick,
|
|
233
|
+
formatMessage = _ref7.formatMessage,
|
|
234
|
+
isDeleting = _ref7.isDeleting,
|
|
235
|
+
isDisabled = _ref7.isDisabled,
|
|
236
|
+
deleteReason = _ref7.deleteReason,
|
|
237
|
+
sourceCount = _ref7.sourceCount;
|
|
228
238
|
var titleMultiple = content.titleMultiple,
|
|
229
239
|
titleSingle = content.titleSingle,
|
|
230
240
|
descriptionSingle = content.descriptionSingle,
|
|
231
241
|
descriptionMultiple = content.descriptionMultiple,
|
|
232
242
|
confirmButtonLabel = content.confirmButtonLabel;
|
|
233
|
-
var hasNoReferenceOrFailToFetch = referenceCount === 0
|
|
243
|
+
var hasNoReferenceOrFailToFetch = referenceCount === 0;
|
|
244
|
+
var syncBlockCount = deleteReason === 'source-block-deleted' ? referenceCount + sourceCount : referenceCount;
|
|
234
245
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ModalHeader, {
|
|
235
246
|
hasCloseButton: true
|
|
236
247
|
}, /*#__PURE__*/React.createElement(ModalTitle, {
|
|
237
248
|
appearance: "warning"
|
|
238
249
|
}, hasNoReferenceOrFailToFetch ? formatMessage(titleSingle) : formatMessage(titleMultiple, {
|
|
239
|
-
count:
|
|
250
|
+
count: syncBlockCount
|
|
240
251
|
}))), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement(Text, null, hasNoReferenceOrFailToFetch ? formatMessage(descriptionSingle) : formatMessage(descriptionMultiple, {
|
|
241
|
-
syncBlockCount:
|
|
252
|
+
syncBlockCount: syncBlockCount
|
|
242
253
|
}))), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
|
|
243
254
|
appearance: "subtle",
|
|
244
255
|
onClick: handleClick(false)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import React, { useCallback, useState } from 'react';
|
|
2
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
3
3
|
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';
|
|
@@ -14,7 +14,8 @@ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
|
|
|
14
14
|
var contentUpdatedAt = _ref.contentUpdatedAt,
|
|
15
15
|
isSource = _ref.isSource,
|
|
16
16
|
localId = _ref.localId,
|
|
17
|
-
title = _ref.title
|
|
17
|
+
title = _ref.title,
|
|
18
|
+
isUnsyncedBlock = _ref.isUnsyncedBlock;
|
|
18
19
|
var intl = useIntl();
|
|
19
20
|
var formatMessage = intl.formatMessage;
|
|
20
21
|
var _useState = useState(formatMessage(messages.defaultSyncBlockTooltip)),
|
|
@@ -51,6 +52,25 @@ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
|
|
|
51
52
|
setTooltipContent(tooltipContent);
|
|
52
53
|
}, [contentUpdatedAt, formatMessage, intl, tooltipMessage]);
|
|
53
54
|
var ariaDescribedById = "sync-block-label-description-".concat(localId);
|
|
55
|
+
var getLabelContent = useMemo(function () {
|
|
56
|
+
if (isUnsyncedBlock && fg('platform_synced_block_dogfooding')) {
|
|
57
|
+
return /*#__PURE__*/React.createElement(Text, {
|
|
58
|
+
size: "small",
|
|
59
|
+
color: "color.text.subtle"
|
|
60
|
+
}, formatMessage(messages.unsyncedBlockLabel));
|
|
61
|
+
}
|
|
62
|
+
if (isSource || !title) {
|
|
63
|
+
return /*#__PURE__*/React.createElement(Text, {
|
|
64
|
+
size: "small",
|
|
65
|
+
color: "color.text.subtle"
|
|
66
|
+
}, formatMessage(messages.syncedBlockLabel));
|
|
67
|
+
}
|
|
68
|
+
return /*#__PURE__*/React.createElement(Text, {
|
|
69
|
+
maxLines: 1,
|
|
70
|
+
size: "small",
|
|
71
|
+
color: "color.text.subtle"
|
|
72
|
+
}, title);
|
|
73
|
+
}, [formatMessage, isSource, isUnsyncedBlock, title]);
|
|
54
74
|
var label = /*#__PURE__*/React.createElement("div", {
|
|
55
75
|
"data-testid": SyncBlockLabelDataId
|
|
56
76
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
@@ -61,15 +81,8 @@ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
|
|
|
61
81
|
color: "var(--ds-icon-subtle, #505258)",
|
|
62
82
|
size: "small",
|
|
63
83
|
label: ""
|
|
64
|
-
}),
|
|
65
|
-
|
|
66
|
-
color: "color.text.subtle"
|
|
67
|
-
}, formatMessage(messages.syncedBlockLabel)) : /*#__PURE__*/React.createElement(Text, {
|
|
68
|
-
maxLines: 1,
|
|
69
|
-
size: "small",
|
|
70
|
-
color: "color.text.subtle"
|
|
71
|
-
}, title));
|
|
72
|
-
if (isSource && fg('platform_synced_block_dogfooding')) {
|
|
84
|
+
}), getLabelContent);
|
|
85
|
+
if ((isSource || isUnsyncedBlock) && fg('platform_synced_block_dogfooding')) {
|
|
73
86
|
return label;
|
|
74
87
|
}
|
|
75
88
|
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
|
|
3
|
+
import { SyncBlockError } from '@atlaskit/editor-synced-block-provider';
|
|
3
4
|
import { SyncBlockLabel } from './SyncBlockLabel';
|
|
4
5
|
var SyncBlockRendererWrapperDataId = 'sync-block-plugin-renderer-wrapper';
|
|
5
6
|
var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperComponent(_ref) {
|
|
6
|
-
var _syncBlockFetchResult;
|
|
7
|
+
var _syncBlockFetchResult, _syncBlockFetchResult2;
|
|
7
8
|
var syncedBlockRenderer = _ref.syncedBlockRenderer,
|
|
8
9
|
useFetchSyncBlockData = _ref.useFetchSyncBlockData,
|
|
9
10
|
useFetchSyncBlockTitle = _ref.useFetchSyncBlockTitle,
|
|
@@ -12,6 +13,7 @@ var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperCompone
|
|
|
12
13
|
var syncBlockFetchResult = useFetchSyncBlockData();
|
|
13
14
|
var title = useFetchSyncBlockTitle === null || useFetchSyncBlockTitle === void 0 ? void 0 : useFetchSyncBlockTitle();
|
|
14
15
|
var contentUpdatedAt = syncBlockFetchResult === null || syncBlockFetchResult === void 0 || (_syncBlockFetchResult = syncBlockFetchResult.syncBlockInstance) === null || _syncBlockFetchResult === void 0 || (_syncBlockFetchResult = _syncBlockFetchResult.data) === null || _syncBlockFetchResult === void 0 ? void 0 : _syncBlockFetchResult.contentUpdatedAt;
|
|
16
|
+
var isUnsyncedBlock = (syncBlockFetchResult === null || syncBlockFetchResult === void 0 || (_syncBlockFetchResult2 = syncBlockFetchResult.syncBlockInstance) === null || _syncBlockFetchResult2 === void 0 || (_syncBlockFetchResult2 = _syncBlockFetchResult2.error) === null || _syncBlockFetchResult2 === void 0 ? void 0 : _syncBlockFetchResult2.type) === SyncBlockError.NotFound;
|
|
15
17
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
16
18
|
"data-testid": SyncBlockRendererWrapperDataId
|
|
17
19
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
@@ -24,7 +26,8 @@ var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperCompone
|
|
|
24
26
|
isSource: false,
|
|
25
27
|
title: title,
|
|
26
28
|
contentUpdatedAt: contentUpdatedAt,
|
|
27
|
-
localId: localId
|
|
29
|
+
localId: localId,
|
|
30
|
+
isUnsyncedBlock: isUnsyncedBlock
|
|
28
31
|
}));
|
|
29
32
|
};
|
|
30
33
|
export var SyncBlockRendererWrapper = /*#__PURE__*/React.memo(SyncBlockRendererWrapperComponent);
|
|
@@ -15,6 +15,7 @@ export declare const copySyncedBlockReferenceToClipboardEditorCommand: (syncBloc
|
|
|
15
15
|
export declare const copySyncedBlockReferenceToClipboard: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
16
16
|
export declare const editSyncedBlockSource: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
17
17
|
export declare const removeSyncedBlock: (api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
18
|
+
export declare const removeSyncedBlockAtPos: (api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined, pos: number) => void;
|
|
18
19
|
/**
|
|
19
20
|
* Deletes (bodied)SyncBlock node and paste its content to the editor
|
|
20
21
|
*/
|
|
@@ -3,7 +3,7 @@ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
|
3
3
|
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
|
|
4
4
|
import ReactNodeView, { type getPosHandler } from '@atlaskit/editor-common/react-node-view';
|
|
5
5
|
import type { ReactComponentProps } from '@atlaskit/editor-common/react-node-view';
|
|
6
|
-
import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
|
|
6
|
+
import type { ExtractInjectionAPI, getPosHandlerNode, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
|
|
7
7
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
8
8
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
9
9
|
import { type SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
@@ -11,7 +11,7 @@ import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlock
|
|
|
11
11
|
export interface SyncBlockNodeViewProps extends ReactComponentProps {
|
|
12
12
|
api?: ExtractInjectionAPI<SyncedBlockPlugin>;
|
|
13
13
|
eventDispatcher: EventDispatcher;
|
|
14
|
-
getPos:
|
|
14
|
+
getPos: getPosHandlerNode;
|
|
15
15
|
isNodeNested?: boolean;
|
|
16
16
|
node: PMNode;
|
|
17
17
|
options: SyncedBlockPluginOptions | undefined;
|
|
@@ -26,7 +26,7 @@ export declare class SyncBlock extends ReactNodeView<SyncBlockNodeViewProps> {
|
|
|
26
26
|
constructor(props: SyncBlockNodeViewProps);
|
|
27
27
|
unsubscribe: (() => void) | undefined;
|
|
28
28
|
createDomRef(): HTMLElement;
|
|
29
|
-
render(): React.JSX.Element | null;
|
|
29
|
+
render({ getPos }: SyncBlockNodeViewProps): React.JSX.Element | null;
|
|
30
30
|
destroy(): void;
|
|
31
31
|
}
|
|
32
32
|
export interface SyncBlockNodeViewProperties {
|
|
@@ -2,8 +2,9 @@ import React from 'react';
|
|
|
2
2
|
type SyncBlockLabelProps = {
|
|
3
3
|
contentUpdatedAt?: string;
|
|
4
4
|
isSource: boolean;
|
|
5
|
+
isUnsyncedBlock?: boolean;
|
|
5
6
|
localId: string;
|
|
6
7
|
title?: string;
|
|
7
8
|
};
|
|
8
|
-
export declare const SyncBlockLabel: React.MemoExoticComponent<({ contentUpdatedAt, isSource, localId, title, }: SyncBlockLabelProps) => React.JSX.Element>;
|
|
9
|
+
export declare const SyncBlockLabel: React.MemoExoticComponent<({ contentUpdatedAt, isSource, localId, title, isUnsyncedBlock, }: SyncBlockLabelProps) => React.JSX.Element>;
|
|
9
10
|
export {};
|
|
@@ -15,6 +15,7 @@ export declare const copySyncedBlockReferenceToClipboardEditorCommand: (syncBloc
|
|
|
15
15
|
export declare const copySyncedBlockReferenceToClipboard: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
16
16
|
export declare const editSyncedBlockSource: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
17
17
|
export declare const removeSyncedBlock: (api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
18
|
+
export declare const removeSyncedBlockAtPos: (api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined, pos: number) => void;
|
|
18
19
|
/**
|
|
19
20
|
* Deletes (bodied)SyncBlock node and paste its content to the editor
|
|
20
21
|
*/
|
|
@@ -3,7 +3,7 @@ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
|
3
3
|
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
|
|
4
4
|
import ReactNodeView, { type getPosHandler } from '@atlaskit/editor-common/react-node-view';
|
|
5
5
|
import type { ReactComponentProps } from '@atlaskit/editor-common/react-node-view';
|
|
6
|
-
import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
|
|
6
|
+
import type { ExtractInjectionAPI, getPosHandlerNode, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
|
|
7
7
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
8
8
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
9
9
|
import { type SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
@@ -11,7 +11,7 @@ import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlock
|
|
|
11
11
|
export interface SyncBlockNodeViewProps extends ReactComponentProps {
|
|
12
12
|
api?: ExtractInjectionAPI<SyncedBlockPlugin>;
|
|
13
13
|
eventDispatcher: EventDispatcher;
|
|
14
|
-
getPos:
|
|
14
|
+
getPos: getPosHandlerNode;
|
|
15
15
|
isNodeNested?: boolean;
|
|
16
16
|
node: PMNode;
|
|
17
17
|
options: SyncedBlockPluginOptions | undefined;
|
|
@@ -26,7 +26,7 @@ export declare class SyncBlock extends ReactNodeView<SyncBlockNodeViewProps> {
|
|
|
26
26
|
constructor(props: SyncBlockNodeViewProps);
|
|
27
27
|
unsubscribe: (() => void) | undefined;
|
|
28
28
|
createDomRef(): HTMLElement;
|
|
29
|
-
render(): React.JSX.Element | null;
|
|
29
|
+
render({ getPos }: SyncBlockNodeViewProps): React.JSX.Element | null;
|
|
30
30
|
destroy(): void;
|
|
31
31
|
}
|
|
32
32
|
export interface SyncBlockNodeViewProperties {
|
|
@@ -2,8 +2,9 @@ import React from 'react';
|
|
|
2
2
|
type SyncBlockLabelProps = {
|
|
3
3
|
contentUpdatedAt?: string;
|
|
4
4
|
isSource: boolean;
|
|
5
|
+
isUnsyncedBlock?: boolean;
|
|
5
6
|
localId: string;
|
|
6
7
|
title?: string;
|
|
7
8
|
};
|
|
8
|
-
export declare const SyncBlockLabel: React.MemoExoticComponent<({ contentUpdatedAt, isSource, localId, title, }: SyncBlockLabelProps) => React.JSX.Element>;
|
|
9
|
+
export declare const SyncBlockLabel: React.MemoExoticComponent<({ contentUpdatedAt, isSource, localId, title, isUnsyncedBlock, }: SyncBlockLabelProps) => React.JSX.Element>;
|
|
9
10
|
export {};
|
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.8",
|
|
4
4
|
"description": "SyncedBlock plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@atlaskit/editor-json-transformer": "^8.31.0",
|
|
35
35
|
"@atlaskit/editor-plugin-analytics": "^7.0.0",
|
|
36
36
|
"@atlaskit/editor-plugin-block-menu": "^6.0.0",
|
|
37
|
-
"@atlaskit/editor-plugin-connectivity": "7.0.
|
|
37
|
+
"@atlaskit/editor-plugin-connectivity": "7.0.1",
|
|
38
38
|
"@atlaskit/editor-plugin-decorations": "^7.0.0",
|
|
39
39
|
"@atlaskit/editor-plugin-floating-toolbar": "^9.1.0",
|
|
40
40
|
"@atlaskit/editor-plugin-selection": "^7.0.0",
|