@atlaskit/editor-plugin-synced-block 5.3.3 → 5.3.5
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 +25 -0
- package/afm-cc/tsconfig.json +0 -3
- package/afm-jira/tsconfig.json +0 -3
- package/afm-products/tsconfig.json +0 -3
- package/dist/cjs/editor-commands/index.js +1 -1
- package/dist/cjs/pm-plugins/main.js +88 -16
- package/dist/cjs/pm-plugins/menu-and-toolbar-experiences.js +4 -4
- package/dist/cjs/pm-plugins/utils/track-sync-blocks.js +4 -2
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/ui/Flag.js +5 -1
- package/dist/cjs/ui/SyncBlockLabel.js +35 -37
- package/dist/cjs/ui/toolbar-components.js +2 -3
- package/dist/es2019/editor-commands/index.js +1 -1
- package/dist/es2019/pm-plugins/main.js +71 -0
- package/dist/es2019/pm-plugins/menu-and-toolbar-experiences.js +4 -4
- package/dist/es2019/pm-plugins/utils/track-sync-blocks.js +4 -2
- package/dist/es2019/types/index.js +1 -0
- package/dist/es2019/ui/Flag.js +5 -0
- package/dist/es2019/ui/SyncBlockLabel.js +9 -7
- package/dist/es2019/ui/toolbar-components.js +2 -3
- package/dist/esm/editor-commands/index.js +1 -1
- package/dist/esm/pm-plugins/main.js +86 -14
- package/dist/esm/pm-plugins/menu-and-toolbar-experiences.js +4 -4
- package/dist/esm/pm-plugins/utils/track-sync-blocks.js +4 -2
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/ui/Flag.js +5 -1
- package/dist/esm/ui/SyncBlockLabel.js +35 -37
- package/dist/esm/ui/toolbar-components.js +2 -3
- package/dist/types/types/index.d.ts +2 -1
- package/dist/types-ts4.5/types/index.d.ts +2 -1
- package/package.json +3 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 5.3.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`81230b670d02c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/81230b670d02c) -
|
|
8
|
+
ED-29744 camel case experience attributes
|
|
9
|
+
- [`7702ea47c5329`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7702ea47c5329) -
|
|
10
|
+
[ux] Show editor flag when unpublished sync block is pasted
|
|
11
|
+
- [`515026ad93e46`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/515026ad93e46) -
|
|
12
|
+
[ux] EDITOR-4772 fix synced block label tooltip not showing
|
|
13
|
+
- [`acc0b8da50cdc`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/acc0b8da50cdc) -
|
|
14
|
+
[ux] EDITOR-4708 fix sync block step tracking to consider doc at that step rather than previous
|
|
15
|
+
doc step
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
18
|
+
## 5.3.4
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- [`2d1d47b369e5a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2d1d47b369e5a) -
|
|
23
|
+
[ux] EDITOR-4766 Use correct selection when transforming to synced block
|
|
24
|
+
- [`3d0b3f8b4d802`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3d0b3f8b4d802) -
|
|
25
|
+
Remove platform_editor_toolbar_aifc_responsive experiment
|
|
26
|
+
- Updated dependencies
|
|
27
|
+
|
|
3
28
|
## 5.3.3
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
package/afm-jira/tsconfig.json
CHANGED
|
@@ -66,7 +66,7 @@ var createSyncedBlock = exports.createSyncedBlock = function createSyncedBlock(_
|
|
|
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
68
|
syncBlockStore.sourceManager.createBodiedSyncBlockNode(_attrs);
|
|
69
|
-
tr.replaceWith(conversionInfo.from
|
|
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
|
|
72
72
|
tr.setSelection(_state.TextSelection.create(tr.doc, conversionInfo.from));
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.syncedBlockPluginKey = exports.createPlugin = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
9
10
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
10
11
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
11
12
|
var _syncBlock = require("@atlaskit/editor-common/sync-block");
|
|
@@ -22,7 +23,7 @@ var _types = require("../types");
|
|
|
22
23
|
var _handleBodiedSyncBlockRemoval = require("./utils/handle-bodied-sync-block-removal");
|
|
23
24
|
var _ignoreDomEvent = require("./utils/ignore-dom-event");
|
|
24
25
|
var _selectionDecorations = require("./utils/selection-decorations");
|
|
25
|
-
var
|
|
26
|
+
var _trackSyncBlocks6 = require("./utils/track-sync-blocks");
|
|
26
27
|
var _utils2 = require("./utils/utils");
|
|
27
28
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
28
29
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
@@ -59,6 +60,27 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
59
60
|
};
|
|
60
61
|
// Track if a copy event occurred to distinguish copy from drag and drop
|
|
61
62
|
var isCopyEvent = false;
|
|
63
|
+
// Track which sync blocks have already triggered the unpublished flag
|
|
64
|
+
var unpublishedFlagShown = new Set();
|
|
65
|
+
|
|
66
|
+
// Set up callback to detect unpublished sync blocks when they're fetched
|
|
67
|
+
(0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding') && syncBlockStore.referenceManager.setOnUnpublishedSyncBlockDetected(function (resourceId) {
|
|
68
|
+
// Only show the flag once per sync block
|
|
69
|
+
if (!unpublishedFlagShown.has(resourceId)) {
|
|
70
|
+
unpublishedFlagShown.add(resourceId);
|
|
71
|
+
// Use setTimeout to dispatch transaction in next tick and avoid re-entrant dispatch
|
|
72
|
+
setTimeout(function () {
|
|
73
|
+
api === null || api === void 0 || api.core.actions.execute(function (_ref3) {
|
|
74
|
+
var tr = _ref3.tr;
|
|
75
|
+
return tr.setMeta(syncedBlockPluginKey, {
|
|
76
|
+
activeFlag: {
|
|
77
|
+
id: _types.FLAG_ID.UNPUBLISHED_SYNC_BLOCK_PASTED
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}, 0);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
62
84
|
return new _safePlugin.SafePlugin({
|
|
63
85
|
key: syncedBlockPluginKey,
|
|
64
86
|
state: {
|
|
@@ -158,8 +180,8 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
158
180
|
return false;
|
|
159
181
|
}
|
|
160
182
|
},
|
|
161
|
-
transformCopied: function transformCopied(slice,
|
|
162
|
-
var state =
|
|
183
|
+
transformCopied: function transformCopied(slice, _ref4) {
|
|
184
|
+
var state = _ref4.state;
|
|
163
185
|
var pluginState = syncedBlockPluginKey.getState(state);
|
|
164
186
|
var syncBlockStore = pluginState === null || pluginState === void 0 ? void 0 : pluginState.syncBlockStore;
|
|
165
187
|
var schema = state.schema;
|
|
@@ -200,6 +222,22 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
200
222
|
var _api$connectivity2;
|
|
201
223
|
var isOffline = (0, _editorPluginConnectivity.isOfflineMode)(api === null || api === void 0 || (_api$connectivity2 = api.connectivity) === null || _api$connectivity2 === void 0 || (_api$connectivity2 = _api$connectivity2.sharedState.currentState()) === null || _api$connectivity2 === void 0 ? void 0 : _api$connectivity2.mode);
|
|
202
224
|
var isConfirmedSyncBlockDeletion = Boolean(tr.getMeta('isConfirmedSyncBlockDeletion'));
|
|
225
|
+
|
|
226
|
+
// Track newly added reference sync blocks before processing the transaction
|
|
227
|
+
if (tr.docChanged && !tr.getMeta('isRemote') && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
228
|
+
var _trackSyncBlocks = (0, _trackSyncBlocks6.trackSyncBlocks)(function (node) {
|
|
229
|
+
return node.type.name === 'syncBlock';
|
|
230
|
+
}, tr, state),
|
|
231
|
+
added = _trackSyncBlocks.added;
|
|
232
|
+
// Mark newly added sync blocks so we can detect unpublished status when data is fetched
|
|
233
|
+
added.forEach(function (nodeInfo) {
|
|
234
|
+
var _nodeInfo$attrs;
|
|
235
|
+
if ((_nodeInfo$attrs = nodeInfo.attrs) !== null && _nodeInfo$attrs !== void 0 && _nodeInfo$attrs.resourceId) {
|
|
236
|
+
syncBlockStore.referenceManager.markAsNewlyAdded(nodeInfo.attrs.resourceId);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
|
|
203
241
|
// Ignore transactions that don't change the document
|
|
204
242
|
// or are from remote (collab) or already confirmed sync block deletion
|
|
205
243
|
// We only care about local changes that change the document
|
|
@@ -207,10 +245,44 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
207
245
|
if (!tr.docChanged || !(syncBlockStore !== null && syncBlockStore !== void 0 && syncBlockStore.sourceManager.requireConfirmationBeforeDelete()) && !syncBlockStore.sourceManager.hasPendingCreation() || Boolean(tr.getMeta('isRemote')) || Boolean(tr.getMeta('isCommitSyncBlockCreation')) || !isOffline && isConfirmedSyncBlockDeletion) {
|
|
208
246
|
return true;
|
|
209
247
|
}
|
|
210
|
-
var
|
|
211
|
-
bodiedSyncBlockRemoved =
|
|
212
|
-
bodiedSyncBlockAdded =
|
|
248
|
+
var _trackSyncBlocks2 = (0, _trackSyncBlocks6.trackSyncBlocks)(syncBlockStore.sourceManager.isSourceBlock, tr, state),
|
|
249
|
+
bodiedSyncBlockRemoved = _trackSyncBlocks2.removed,
|
|
250
|
+
bodiedSyncBlockAdded = _trackSyncBlocks2.added;
|
|
213
251
|
if (!isOffline) {
|
|
252
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
253
|
+
var _trackSyncBlocks3 = (0, _trackSyncBlocks6.trackSyncBlocks)(function (node) {
|
|
254
|
+
return node.type.name === 'syncBlock';
|
|
255
|
+
}, tr, state),
|
|
256
|
+
syncBlockRemoved = _trackSyncBlocks3.removed,
|
|
257
|
+
syncBlockAdded = _trackSyncBlocks3.added;
|
|
258
|
+
syncBlockRemoved.forEach(function (syncBlock) {
|
|
259
|
+
var _api$analytics;
|
|
260
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.fireAnalyticsEvent({
|
|
261
|
+
action: _analytics.ACTION.DELETED,
|
|
262
|
+
actionSubject: _analytics.ACTION_SUBJECT.SYNCED_BLOCK,
|
|
263
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_DELETE,
|
|
264
|
+
attributes: {
|
|
265
|
+
resourceId: syncBlock.attrs.resourceId,
|
|
266
|
+
blockInstanceId: syncBlock.attrs.localId
|
|
267
|
+
},
|
|
268
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
syncBlockAdded.forEach(function (syncBlock) {
|
|
272
|
+
var _api$analytics2;
|
|
273
|
+
api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || (_api$analytics2 = _api$analytics2.actions) === null || _api$analytics2 === void 0 || _api$analytics2.fireAnalyticsEvent({
|
|
274
|
+
action: _analytics.ACTION.INSERTED,
|
|
275
|
+
actionSubject: _analytics.ACTION_SUBJECT.SYNCED_BLOCK,
|
|
276
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_CREATE,
|
|
277
|
+
attributes: {
|
|
278
|
+
resourceId: syncBlock.attrs.resourceId,
|
|
279
|
+
blockInstanceId: syncBlock.attrs.localId
|
|
280
|
+
},
|
|
281
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
;
|
|
214
286
|
if (bodiedSyncBlockRemoved.length > 0) {
|
|
215
287
|
confirmationTransactionRef.current = tr;
|
|
216
288
|
return (0, _handleBodiedSyncBlockRemoval.handleBodiedSyncBlockRemoval)(bodiedSyncBlockRemoved, syncBlockStore, api, confirmationTransactionRef, (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding') ? getDeleteReason(tr) : undefined);
|
|
@@ -236,26 +308,26 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
236
308
|
return false;
|
|
237
309
|
}
|
|
238
310
|
} else {
|
|
239
|
-
var
|
|
311
|
+
var _trackSyncBlocks4 = (0, _trackSyncBlocks6.trackSyncBlocks)(function (node) {
|
|
240
312
|
return node.type.name === 'syncBlock';
|
|
241
313
|
}, tr, state),
|
|
242
|
-
|
|
243
|
-
|
|
314
|
+
_syncBlockRemoved = _trackSyncBlocks4.removed,
|
|
315
|
+
_syncBlockAdded = _trackSyncBlocks4.added;
|
|
244
316
|
var errorFlag = false;
|
|
245
317
|
|
|
246
318
|
// Disable (bodied)syncBlock node deletion/creation/edition in offline mode and trigger an error flag instead
|
|
247
|
-
if (isConfirmedSyncBlockDeletion || bodiedSyncBlockRemoved.length > 0 ||
|
|
319
|
+
if (isConfirmedSyncBlockDeletion || bodiedSyncBlockRemoved.length > 0 || _syncBlockRemoved.length > 0) {
|
|
248
320
|
errorFlag = _types.FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE;
|
|
249
|
-
} else if (bodiedSyncBlockAdded.length > 0 ||
|
|
321
|
+
} else if (bodiedSyncBlockAdded.length > 0 || _syncBlockAdded.length > 0) {
|
|
250
322
|
errorFlag = _types.FLAG_ID.CANNOT_CREATE_WHEN_OFFLINE;
|
|
251
|
-
} else if ((0,
|
|
323
|
+
} else if ((0, _trackSyncBlocks6.hasEditInSyncBlock)(tr, state)) {
|
|
252
324
|
errorFlag = _types.FLAG_ID.CANNOT_EDIT_WHEN_OFFLINE;
|
|
253
325
|
}
|
|
254
326
|
if (errorFlag) {
|
|
255
327
|
// Use setTimeout to dispatch transaction in next tick and avoid re-entrant dispatch
|
|
256
328
|
setTimeout(function () {
|
|
257
|
-
api === null || api === void 0 || api.core.actions.execute(function (
|
|
258
|
-
var tr =
|
|
329
|
+
api === null || api === void 0 || api.core.actions.execute(function (_ref5) {
|
|
330
|
+
var tr = _ref5.tr;
|
|
259
331
|
return tr.setMeta(syncedBlockPluginKey, {
|
|
260
332
|
activeFlag: {
|
|
261
333
|
id: errorFlag
|
|
@@ -284,8 +356,8 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
284
356
|
if (!tr.getMeta(_utils.pmHistoryPluginKey)) {
|
|
285
357
|
return 0; // continue
|
|
286
358
|
}
|
|
287
|
-
var
|
|
288
|
-
added =
|
|
359
|
+
var _trackSyncBlocks5 = (0, _trackSyncBlocks6.trackSyncBlocks)(syncBlockStore.sourceManager.isSourceBlock, tr, oldState),
|
|
360
|
+
added = _trackSyncBlocks5.added;
|
|
289
361
|
if (added.length > 0) {
|
|
290
362
|
// Delete bodiedSyncBlock if it's originated from history, i.e. redo creation
|
|
291
363
|
// See filterTransaction above for more details
|
|
@@ -97,16 +97,16 @@ var getMenuAndToolbarExperiencesPlugin = exports.getMenuAndToolbarExperiencesPlu
|
|
|
97
97
|
return {
|
|
98
98
|
destroy: function destroy() {
|
|
99
99
|
createSourcePrimaryToolbarExperience.abort({
|
|
100
|
-
reason: '
|
|
100
|
+
reason: 'editorDestroyed'
|
|
101
101
|
});
|
|
102
102
|
createSourceBlockMenuExperience.abort({
|
|
103
|
-
reason: '
|
|
103
|
+
reason: 'editorDestroyed'
|
|
104
104
|
});
|
|
105
105
|
createSourceQuickInsertMenuExperience.abort({
|
|
106
|
-
reason: '
|
|
106
|
+
reason: 'editorDestroyed'
|
|
107
107
|
});
|
|
108
108
|
deleteReferenceSyncedBlockExperience.abort({
|
|
109
|
-
reason: '
|
|
109
|
+
reason: 'editorDestroyed'
|
|
110
110
|
});
|
|
111
111
|
unbindClickListener();
|
|
112
112
|
unbindKeydownListener();
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.trackSyncBlocks = exports.hasEditInSyncBlock = void 0;
|
|
7
7
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
8
8
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
9
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
9
10
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
10
11
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
11
12
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
@@ -25,14 +26,15 @@ var trackSyncBlocks = exports.trackSyncBlocks = function trackSyncBlocks(predica
|
|
|
25
26
|
});
|
|
26
27
|
|
|
27
28
|
// this is a quick check to see if any insertion/deletion of bodiedSyncBlock happened
|
|
28
|
-
var hasBodiedSyncBlockChanges = replaceSteps.some(function (step) {
|
|
29
|
+
var hasBodiedSyncBlockChanges = replaceSteps.some(function (step, idx) {
|
|
29
30
|
var from = step.from,
|
|
30
31
|
to = step.to;
|
|
32
|
+
var docAtStep = (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding') ? tr.docs[idx] : state.doc;
|
|
31
33
|
var hasChange = false;
|
|
32
34
|
if (from !== to) {
|
|
33
35
|
step.getMap().forEach(function (oldStart, oldEnd) {
|
|
34
36
|
if (oldStart !== oldEnd && !hasChange) {
|
|
35
|
-
var deletedSlice =
|
|
37
|
+
var deletedSlice = docAtStep.slice(Math.max(0, oldStart), Math.min(docAtStep.content.size, oldEnd));
|
|
36
38
|
deletedSlice.content.forEach(function (node) {
|
|
37
39
|
if (hasChange) {
|
|
38
40
|
return;
|
package/dist/cjs/types/index.js
CHANGED
|
@@ -10,6 +10,7 @@ var FLAG_ID = exports.FLAG_ID = /*#__PURE__*/function (FLAG_ID) {
|
|
|
10
10
|
FLAG_ID["CANNOT_CREATE_WHEN_OFFLINE"] = "cannot-create-when-offline";
|
|
11
11
|
FLAG_ID["FAIL_TO_DELETE"] = "fail-to-delete";
|
|
12
12
|
FLAG_ID["SYNC_BLOCK_COPIED"] = "sync-block-copied";
|
|
13
|
+
FLAG_ID["UNPUBLISHED_SYNC_BLOCK_PASTED"] = "unpublished-sync-block-pasted";
|
|
13
14
|
return FLAG_ID;
|
|
14
15
|
}({});
|
|
15
16
|
var SYNCED_BLOCK_BUTTON_TEST_ID = exports.SYNCED_BLOCK_BUTTON_TEST_ID = {
|
package/dist/cjs/ui/Flag.js
CHANGED
|
@@ -20,7 +20,7 @@ var _types = require("../types");
|
|
|
20
20
|
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); }
|
|
21
21
|
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; }
|
|
22
22
|
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) { (0, _defineProperty2.default)(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; }
|
|
23
|
-
var flagMap = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _types.FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE, {
|
|
23
|
+
var flagMap = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _types.FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE, {
|
|
24
24
|
title: _messages.syncBlockMessages.failToDeleteTitle,
|
|
25
25
|
description: _messages.syncBlockMessages.failToDeleteWhenOfflineDescription,
|
|
26
26
|
type: 'error'
|
|
@@ -39,6 +39,10 @@ var flagMap = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _d
|
|
|
39
39
|
}), _types.FLAG_ID.SYNC_BLOCK_COPIED, {
|
|
40
40
|
title: _messages.syncBlockMessages.syncBlockCopiedTitle,
|
|
41
41
|
type: 'info'
|
|
42
|
+
}), _types.FLAG_ID.UNPUBLISHED_SYNC_BLOCK_PASTED, {
|
|
43
|
+
title: _messages.syncBlockMessages.unpublishedSyncBlockPastedTitle,
|
|
44
|
+
description: _messages.syncBlockMessages.unpublishedSyncBlockPastedDescription,
|
|
45
|
+
type: 'info'
|
|
42
46
|
});
|
|
43
47
|
var Flag = exports.Flag = function Flag(_ref) {
|
|
44
48
|
var api = _ref.api;
|
|
@@ -60,42 +60,40 @@ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
|
|
|
60
60
|
setTooltipContent(tooltipContent);
|
|
61
61
|
}, [contentUpdatedAt, formatMessage, intl, tooltipMessage]);
|
|
62
62
|
var ariaDescribedById = "sync-block-label-description-".concat(localId);
|
|
63
|
-
var
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
};
|
|
99
|
-
return (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding') ? isSource ? /*#__PURE__*/_react.default.createElement(LabelComponent, null) : /*#__PURE__*/_react.default.createElement(LabelWithTooltip, null) : /*#__PURE__*/_react.default.createElement(LabelWithTooltip, null);
|
|
63
|
+
var label = /*#__PURE__*/_react.default.createElement("div", {
|
|
64
|
+
"data-testid": SyncBlockLabelDataId
|
|
65
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
66
|
+
,
|
|
67
|
+
className: _syncBlock.SyncBlockLabelSharedCssClassName.labelClassName,
|
|
68
|
+
"aria-describedby": ariaDescribedById
|
|
69
|
+
}, /*#__PURE__*/_react.default.createElement(_blockSynced.default, {
|
|
70
|
+
color: "var(--ds-icon-subtle, #505258)",
|
|
71
|
+
size: "small",
|
|
72
|
+
label: ""
|
|
73
|
+
}), isSource || !title ? /*#__PURE__*/_react.default.createElement(_compiled.Text, {
|
|
74
|
+
size: "small",
|
|
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')) {
|
|
82
|
+
return label;
|
|
83
|
+
}
|
|
84
|
+
return /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
85
|
+
position: "top",
|
|
86
|
+
content: (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding') ? tooltipContent : tooltipMessage
|
|
87
|
+
// workaround because tooltip adds aria-describedby with a new id every time the tooltip is opened
|
|
88
|
+
// this causes an infinite rerender loop because of the forwardRef from the node view we are inside in bodiedSyncBlock
|
|
89
|
+
// tooltip content is available for screen readers in visually hidden content after the label
|
|
90
|
+
,
|
|
91
|
+
isScreenReaderAnnouncementDisabled: true
|
|
92
|
+
// using this to ensure that the 'last edited' time is updated when the tooltip is opened
|
|
93
|
+
,
|
|
94
|
+
onShow: updateTooltipContent
|
|
95
|
+
}, label, /*#__PURE__*/_react.default.createElement(_visuallyHidden.default, {
|
|
96
|
+
id: ariaDescribedById
|
|
97
|
+
}, tooltipContent));
|
|
100
98
|
};
|
|
101
99
|
var SyncBlockLabel = exports.SyncBlockLabel = /*#__PURE__*/_react.default.memo(SyncBlockLabelComponent);
|
|
@@ -8,17 +8,16 @@ exports.getToolbarComponents = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
10
10
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
11
|
-
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
12
11
|
var _CreateSyncedBlockButton = require("./CreateSyncedBlockButton");
|
|
13
12
|
var SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP = {
|
|
14
13
|
type: _toolbar.SYNCED_BLOCK_GROUP.type,
|
|
15
14
|
key: _toolbar.SYNCED_BLOCK_GROUP.key,
|
|
16
|
-
component:
|
|
15
|
+
component: function component(_ref) {
|
|
17
16
|
var children = _ref.children;
|
|
18
17
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.Show, {
|
|
19
18
|
above: "md"
|
|
20
19
|
}, /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarButtonGroup, null, children));
|
|
21
|
-
}
|
|
20
|
+
},
|
|
22
21
|
parents: [{
|
|
23
22
|
type: _toolbar.INSERT_BLOCK_SECTION.type,
|
|
24
23
|
key: _toolbar.INSERT_BLOCK_SECTION.key,
|
|
@@ -66,7 +66,7 @@ export const createSyncedBlock = ({
|
|
|
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
68
|
syncBlockStore.sourceManager.createBodiedSyncBlockNode(attrs);
|
|
69
|
-
tr.replaceWith(conversionInfo.from
|
|
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
|
|
72
72
|
tr.setSelection(TextSelection.create(tr.doc, conversionInfo.from));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
1
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
3
|
import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
|
|
3
4
|
import { BodiedSyncBlockSharedCssClassName, SyncBlockStateCssClassName } from '@atlaskit/editor-common/sync-block';
|
|
@@ -47,6 +48,28 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
47
48
|
};
|
|
48
49
|
// Track if a copy event occurred to distinguish copy from drag and drop
|
|
49
50
|
let isCopyEvent = false;
|
|
51
|
+
// Track which sync blocks have already triggered the unpublished flag
|
|
52
|
+
const unpublishedFlagShown = new Set();
|
|
53
|
+
|
|
54
|
+
// Set up callback to detect unpublished sync blocks when they're fetched
|
|
55
|
+
fg('platform_synced_block_dogfooding') && syncBlockStore.referenceManager.setOnUnpublishedSyncBlockDetected(resourceId => {
|
|
56
|
+
// Only show the flag once per sync block
|
|
57
|
+
if (!unpublishedFlagShown.has(resourceId)) {
|
|
58
|
+
unpublishedFlagShown.add(resourceId);
|
|
59
|
+
// Use setTimeout to dispatch transaction in next tick and avoid re-entrant dispatch
|
|
60
|
+
setTimeout(() => {
|
|
61
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(({
|
|
62
|
+
tr
|
|
63
|
+
}) => {
|
|
64
|
+
return tr.setMeta(syncedBlockPluginKey, {
|
|
65
|
+
activeFlag: {
|
|
66
|
+
id: FLAG_ID.UNPUBLISHED_SYNC_BLOCK_PASTED
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}, 0);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
50
73
|
return new SafePlugin({
|
|
51
74
|
key: syncedBlockPluginKey,
|
|
52
75
|
state: {
|
|
@@ -192,6 +215,21 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
192
215
|
var _api$connectivity2, _api$connectivity2$sh;
|
|
193
216
|
const isOffline = isOfflineMode(api === null || api === void 0 ? void 0 : (_api$connectivity2 = api.connectivity) === null || _api$connectivity2 === void 0 ? void 0 : (_api$connectivity2$sh = _api$connectivity2.sharedState.currentState()) === null || _api$connectivity2$sh === void 0 ? void 0 : _api$connectivity2$sh.mode);
|
|
194
217
|
const isConfirmedSyncBlockDeletion = Boolean(tr.getMeta('isConfirmedSyncBlockDeletion'));
|
|
218
|
+
|
|
219
|
+
// Track newly added reference sync blocks before processing the transaction
|
|
220
|
+
if (tr.docChanged && !tr.getMeta('isRemote') && fg('platform_synced_block_dogfooding')) {
|
|
221
|
+
const {
|
|
222
|
+
added
|
|
223
|
+
} = trackSyncBlocks(node => node.type.name === 'syncBlock', tr, state);
|
|
224
|
+
// Mark newly added sync blocks so we can detect unpublished status when data is fetched
|
|
225
|
+
added.forEach(nodeInfo => {
|
|
226
|
+
var _nodeInfo$attrs;
|
|
227
|
+
if ((_nodeInfo$attrs = nodeInfo.attrs) !== null && _nodeInfo$attrs !== void 0 && _nodeInfo$attrs.resourceId) {
|
|
228
|
+
syncBlockStore.referenceManager.markAsNewlyAdded(nodeInfo.attrs.resourceId);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
195
233
|
// Ignore transactions that don't change the document
|
|
196
234
|
// or are from remote (collab) or already confirmed sync block deletion
|
|
197
235
|
// We only care about local changes that change the document
|
|
@@ -204,6 +242,39 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
204
242
|
added: bodiedSyncBlockAdded
|
|
205
243
|
} = trackSyncBlocks(syncBlockStore.sourceManager.isSourceBlock, tr, state);
|
|
206
244
|
if (!isOffline) {
|
|
245
|
+
if (fg('platform_synced_block_dogfooding')) {
|
|
246
|
+
const {
|
|
247
|
+
removed: syncBlockRemoved,
|
|
248
|
+
added: syncBlockAdded
|
|
249
|
+
} = trackSyncBlocks(node => node.type.name === 'syncBlock', tr, state);
|
|
250
|
+
syncBlockRemoved.forEach(syncBlock => {
|
|
251
|
+
var _api$analytics, _api$analytics$action;
|
|
252
|
+
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : (_api$analytics$action = _api$analytics.actions) === null || _api$analytics$action === void 0 ? void 0 : _api$analytics$action.fireAnalyticsEvent({
|
|
253
|
+
action: ACTION.DELETED,
|
|
254
|
+
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
255
|
+
actionSubjectId: ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_DELETE,
|
|
256
|
+
attributes: {
|
|
257
|
+
resourceId: syncBlock.attrs.resourceId,
|
|
258
|
+
blockInstanceId: syncBlock.attrs.localId
|
|
259
|
+
},
|
|
260
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
syncBlockAdded.forEach(syncBlock => {
|
|
264
|
+
var _api$analytics2, _api$analytics2$actio;
|
|
265
|
+
api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : (_api$analytics2$actio = _api$analytics2.actions) === null || _api$analytics2$actio === void 0 ? void 0 : _api$analytics2$actio.fireAnalyticsEvent({
|
|
266
|
+
action: ACTION.INSERTED,
|
|
267
|
+
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
268
|
+
actionSubjectId: ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_CREATE,
|
|
269
|
+
attributes: {
|
|
270
|
+
resourceId: syncBlock.attrs.resourceId,
|
|
271
|
+
blockInstanceId: syncBlock.attrs.localId
|
|
272
|
+
},
|
|
273
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
;
|
|
207
278
|
if (bodiedSyncBlockRemoved.length > 0) {
|
|
208
279
|
confirmationTransactionRef.current = tr;
|
|
209
280
|
return handleBodiedSyncBlockRemoval(bodiedSyncBlockRemoved, syncBlockStore, api, confirmationTransactionRef, fg('platform_synced_block_dogfooding') ? getDeleteReason(tr) : undefined);
|
|
@@ -90,16 +90,16 @@ export const getMenuAndToolbarExperiencesPlugin = ({
|
|
|
90
90
|
return {
|
|
91
91
|
destroy: () => {
|
|
92
92
|
createSourcePrimaryToolbarExperience.abort({
|
|
93
|
-
reason: '
|
|
93
|
+
reason: 'editorDestroyed'
|
|
94
94
|
});
|
|
95
95
|
createSourceBlockMenuExperience.abort({
|
|
96
|
-
reason: '
|
|
96
|
+
reason: 'editorDestroyed'
|
|
97
97
|
});
|
|
98
98
|
createSourceQuickInsertMenuExperience.abort({
|
|
99
|
-
reason: '
|
|
99
|
+
reason: 'editorDestroyed'
|
|
100
100
|
});
|
|
101
101
|
deleteReferenceSyncedBlockExperience.abort({
|
|
102
|
-
reason: '
|
|
102
|
+
reason: 'editorDestroyed'
|
|
103
103
|
});
|
|
104
104
|
unbindClickListener();
|
|
105
105
|
unbindKeydownListener();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
2
2
|
import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
export const trackSyncBlocks = (predicate, tr, state) => {
|
|
4
5
|
const removed = {};
|
|
5
6
|
const added = {};
|
|
@@ -14,16 +15,17 @@ export const trackSyncBlocks = (predicate, tr, state) => {
|
|
|
14
15
|
const replaceSteps = tr.steps.filter(step => step instanceof ReplaceStep || step instanceof ReplaceAroundStep);
|
|
15
16
|
|
|
16
17
|
// this is a quick check to see if any insertion/deletion of bodiedSyncBlock happened
|
|
17
|
-
const hasBodiedSyncBlockChanges = replaceSteps.some(step => {
|
|
18
|
+
const hasBodiedSyncBlockChanges = replaceSteps.some((step, idx) => {
|
|
18
19
|
const {
|
|
19
20
|
from,
|
|
20
21
|
to
|
|
21
22
|
} = step;
|
|
23
|
+
const docAtStep = fg('platform_synced_block_dogfooding') ? tr.docs[idx] : state.doc;
|
|
22
24
|
let hasChange = false;
|
|
23
25
|
if (from !== to) {
|
|
24
26
|
step.getMap().forEach((oldStart, oldEnd) => {
|
|
25
27
|
if (oldStart !== oldEnd && !hasChange) {
|
|
26
|
-
const deletedSlice =
|
|
28
|
+
const deletedSlice = docAtStep.slice(Math.max(0, oldStart), Math.min(docAtStep.content.size, oldEnd));
|
|
27
29
|
deletedSlice.content.forEach(node => {
|
|
28
30
|
if (hasChange) {
|
|
29
31
|
return;
|
|
@@ -4,6 +4,7 @@ export let FLAG_ID = /*#__PURE__*/function (FLAG_ID) {
|
|
|
4
4
|
FLAG_ID["CANNOT_CREATE_WHEN_OFFLINE"] = "cannot-create-when-offline";
|
|
5
5
|
FLAG_ID["FAIL_TO_DELETE"] = "fail-to-delete";
|
|
6
6
|
FLAG_ID["SYNC_BLOCK_COPIED"] = "sync-block-copied";
|
|
7
|
+
FLAG_ID["UNPUBLISHED_SYNC_BLOCK_PASTED"] = "unpublished-sync-block-pasted";
|
|
7
8
|
return FLAG_ID;
|
|
8
9
|
}({});
|
|
9
10
|
export const SYNCED_BLOCK_BUTTON_TEST_ID = {
|
package/dist/es2019/ui/Flag.js
CHANGED
|
@@ -32,6 +32,11 @@ const flagMap = {
|
|
|
32
32
|
[FLAG_ID.SYNC_BLOCK_COPIED]: {
|
|
33
33
|
title: messages.syncBlockCopiedTitle,
|
|
34
34
|
type: 'info'
|
|
35
|
+
},
|
|
36
|
+
[FLAG_ID.UNPUBLISHED_SYNC_BLOCK_PASTED]: {
|
|
37
|
+
title: messages.unpublishedSyncBlockPastedTitle,
|
|
38
|
+
description: messages.unpublishedSyncBlockPastedDescription,
|
|
39
|
+
type: 'info'
|
|
35
40
|
}
|
|
36
41
|
};
|
|
37
42
|
export const Flag = ({
|
|
@@ -50,7 +50,7 @@ const SyncBlockLabelComponent = ({
|
|
|
50
50
|
setTooltipContent(tooltipContent);
|
|
51
51
|
}, [contentUpdatedAt, formatMessage, intl, tooltipMessage]);
|
|
52
52
|
const ariaDescribedById = `sync-block-label-description-${localId}`;
|
|
53
|
-
const
|
|
53
|
+
const label = /*#__PURE__*/React.createElement("div", {
|
|
54
54
|
"data-testid": SyncBlockLabelDataId
|
|
55
55
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
56
56
|
,
|
|
@@ -67,10 +67,11 @@ const SyncBlockLabelComponent = ({
|
|
|
67
67
|
maxLines: 1,
|
|
68
68
|
size: "small",
|
|
69
69
|
color: "color.text.subtle"
|
|
70
|
-
}, title))
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
}, title));
|
|
71
|
+
if (isSource && fg('platform_synced_block_dogfooding')) {
|
|
72
|
+
return label;
|
|
73
|
+
}
|
|
74
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
74
75
|
position: "top",
|
|
75
76
|
content: fg('platform_synced_block_dogfooding') ? tooltipContent : tooltipMessage
|
|
76
77
|
// workaround because tooltip adds aria-describedby with a new id every time the tooltip is opened
|
|
@@ -81,7 +82,8 @@ const SyncBlockLabelComponent = ({
|
|
|
81
82
|
// using this to ensure that the 'last edited' time is updated when the tooltip is opened
|
|
82
83
|
,
|
|
83
84
|
onShow: updateTooltipContent
|
|
84
|
-
}, /*#__PURE__*/React.createElement(
|
|
85
|
-
|
|
85
|
+
}, label, /*#__PURE__*/React.createElement(VisuallyHidden, {
|
|
86
|
+
id: ariaDescribedById
|
|
87
|
+
}, tooltipContent));
|
|
86
88
|
};
|
|
87
89
|
export const SyncBlockLabel = /*#__PURE__*/React.memo(SyncBlockLabelComponent);
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { INSERT_BLOCK_SECTION, INSERT_BLOCK_SECTION_RANK, SYNCED_BLOCK_BUTTON, SYNCED_BLOCK_GROUP, SYNCED_BLOCK_SECTION_RANK } from '@atlaskit/editor-common/toolbar';
|
|
3
3
|
import { Show, ToolbarButtonGroup } from '@atlaskit/editor-toolbar';
|
|
4
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
4
|
import { CreateSyncedBlockButton } from './CreateSyncedBlockButton';
|
|
6
5
|
const SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP = {
|
|
7
6
|
type: SYNCED_BLOCK_GROUP.type,
|
|
8
7
|
key: SYNCED_BLOCK_GROUP.key,
|
|
9
|
-
component:
|
|
8
|
+
component: ({
|
|
10
9
|
children
|
|
11
10
|
}) => /*#__PURE__*/React.createElement(Show, {
|
|
12
11
|
above: "md"
|
|
13
|
-
}, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children))
|
|
12
|
+
}, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children)),
|
|
14
13
|
parents: [{
|
|
15
14
|
type: INSERT_BLOCK_SECTION.type,
|
|
16
15
|
key: INSERT_BLOCK_SECTION.key,
|
|
@@ -60,7 +60,7 @@ export var createSyncedBlock = function createSyncedBlock(_ref) {
|
|
|
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
62
|
syncBlockStore.sourceManager.createBodiedSyncBlockNode(_attrs);
|
|
63
|
-
tr.replaceWith(conversionInfo.from
|
|
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
|
|
66
66
|
tr.setSelection(TextSelection.create(tr.doc, conversionInfo.from));
|
|
@@ -4,6 +4,7 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
4
4
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
5
|
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; }
|
|
6
6
|
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; }
|
|
7
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
7
8
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
8
9
|
import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
|
|
9
10
|
import { BodiedSyncBlockSharedCssClassName, SyncBlockStateCssClassName } from '@atlaskit/editor-common/sync-block';
|
|
@@ -52,6 +53,27 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
52
53
|
};
|
|
53
54
|
// Track if a copy event occurred to distinguish copy from drag and drop
|
|
54
55
|
var isCopyEvent = false;
|
|
56
|
+
// Track which sync blocks have already triggered the unpublished flag
|
|
57
|
+
var unpublishedFlagShown = new Set();
|
|
58
|
+
|
|
59
|
+
// Set up callback to detect unpublished sync blocks when they're fetched
|
|
60
|
+
fg('platform_synced_block_dogfooding') && syncBlockStore.referenceManager.setOnUnpublishedSyncBlockDetected(function (resourceId) {
|
|
61
|
+
// Only show the flag once per sync block
|
|
62
|
+
if (!unpublishedFlagShown.has(resourceId)) {
|
|
63
|
+
unpublishedFlagShown.add(resourceId);
|
|
64
|
+
// Use setTimeout to dispatch transaction in next tick and avoid re-entrant dispatch
|
|
65
|
+
setTimeout(function () {
|
|
66
|
+
api === null || api === void 0 || api.core.actions.execute(function (_ref3) {
|
|
67
|
+
var tr = _ref3.tr;
|
|
68
|
+
return tr.setMeta(syncedBlockPluginKey, {
|
|
69
|
+
activeFlag: {
|
|
70
|
+
id: FLAG_ID.UNPUBLISHED_SYNC_BLOCK_PASTED
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}, 0);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
55
77
|
return new SafePlugin({
|
|
56
78
|
key: syncedBlockPluginKey,
|
|
57
79
|
state: {
|
|
@@ -151,8 +173,8 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
151
173
|
return false;
|
|
152
174
|
}
|
|
153
175
|
},
|
|
154
|
-
transformCopied: function transformCopied(slice,
|
|
155
|
-
var state =
|
|
176
|
+
transformCopied: function transformCopied(slice, _ref4) {
|
|
177
|
+
var state = _ref4.state;
|
|
156
178
|
var pluginState = syncedBlockPluginKey.getState(state);
|
|
157
179
|
var syncBlockStore = pluginState === null || pluginState === void 0 ? void 0 : pluginState.syncBlockStore;
|
|
158
180
|
var schema = state.schema;
|
|
@@ -193,6 +215,22 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
193
215
|
var _api$connectivity2;
|
|
194
216
|
var isOffline = isOfflineMode(api === null || api === void 0 || (_api$connectivity2 = api.connectivity) === null || _api$connectivity2 === void 0 || (_api$connectivity2 = _api$connectivity2.sharedState.currentState()) === null || _api$connectivity2 === void 0 ? void 0 : _api$connectivity2.mode);
|
|
195
217
|
var isConfirmedSyncBlockDeletion = Boolean(tr.getMeta('isConfirmedSyncBlockDeletion'));
|
|
218
|
+
|
|
219
|
+
// Track newly added reference sync blocks before processing the transaction
|
|
220
|
+
if (tr.docChanged && !tr.getMeta('isRemote') && fg('platform_synced_block_dogfooding')) {
|
|
221
|
+
var _trackSyncBlocks = trackSyncBlocks(function (node) {
|
|
222
|
+
return node.type.name === 'syncBlock';
|
|
223
|
+
}, tr, state),
|
|
224
|
+
added = _trackSyncBlocks.added;
|
|
225
|
+
// Mark newly added sync blocks so we can detect unpublished status when data is fetched
|
|
226
|
+
added.forEach(function (nodeInfo) {
|
|
227
|
+
var _nodeInfo$attrs;
|
|
228
|
+
if ((_nodeInfo$attrs = nodeInfo.attrs) !== null && _nodeInfo$attrs !== void 0 && _nodeInfo$attrs.resourceId) {
|
|
229
|
+
syncBlockStore.referenceManager.markAsNewlyAdded(nodeInfo.attrs.resourceId);
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
|
|
196
234
|
// Ignore transactions that don't change the document
|
|
197
235
|
// or are from remote (collab) or already confirmed sync block deletion
|
|
198
236
|
// We only care about local changes that change the document
|
|
@@ -200,10 +238,44 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
200
238
|
if (!tr.docChanged || !(syncBlockStore !== null && syncBlockStore !== void 0 && syncBlockStore.sourceManager.requireConfirmationBeforeDelete()) && !syncBlockStore.sourceManager.hasPendingCreation() || Boolean(tr.getMeta('isRemote')) || Boolean(tr.getMeta('isCommitSyncBlockCreation')) || !isOffline && isConfirmedSyncBlockDeletion) {
|
|
201
239
|
return true;
|
|
202
240
|
}
|
|
203
|
-
var
|
|
204
|
-
bodiedSyncBlockRemoved =
|
|
205
|
-
bodiedSyncBlockAdded =
|
|
241
|
+
var _trackSyncBlocks2 = trackSyncBlocks(syncBlockStore.sourceManager.isSourceBlock, tr, state),
|
|
242
|
+
bodiedSyncBlockRemoved = _trackSyncBlocks2.removed,
|
|
243
|
+
bodiedSyncBlockAdded = _trackSyncBlocks2.added;
|
|
206
244
|
if (!isOffline) {
|
|
245
|
+
if (fg('platform_synced_block_dogfooding')) {
|
|
246
|
+
var _trackSyncBlocks3 = trackSyncBlocks(function (node) {
|
|
247
|
+
return node.type.name === 'syncBlock';
|
|
248
|
+
}, tr, state),
|
|
249
|
+
syncBlockRemoved = _trackSyncBlocks3.removed,
|
|
250
|
+
syncBlockAdded = _trackSyncBlocks3.added;
|
|
251
|
+
syncBlockRemoved.forEach(function (syncBlock) {
|
|
252
|
+
var _api$analytics;
|
|
253
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.fireAnalyticsEvent({
|
|
254
|
+
action: ACTION.DELETED,
|
|
255
|
+
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
256
|
+
actionSubjectId: ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_DELETE,
|
|
257
|
+
attributes: {
|
|
258
|
+
resourceId: syncBlock.attrs.resourceId,
|
|
259
|
+
blockInstanceId: syncBlock.attrs.localId
|
|
260
|
+
},
|
|
261
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
syncBlockAdded.forEach(function (syncBlock) {
|
|
265
|
+
var _api$analytics2;
|
|
266
|
+
api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || (_api$analytics2 = _api$analytics2.actions) === null || _api$analytics2 === void 0 || _api$analytics2.fireAnalyticsEvent({
|
|
267
|
+
action: ACTION.INSERTED,
|
|
268
|
+
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
269
|
+
actionSubjectId: ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_CREATE,
|
|
270
|
+
attributes: {
|
|
271
|
+
resourceId: syncBlock.attrs.resourceId,
|
|
272
|
+
blockInstanceId: syncBlock.attrs.localId
|
|
273
|
+
},
|
|
274
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
;
|
|
207
279
|
if (bodiedSyncBlockRemoved.length > 0) {
|
|
208
280
|
confirmationTransactionRef.current = tr;
|
|
209
281
|
return handleBodiedSyncBlockRemoval(bodiedSyncBlockRemoved, syncBlockStore, api, confirmationTransactionRef, fg('platform_synced_block_dogfooding') ? getDeleteReason(tr) : undefined);
|
|
@@ -229,17 +301,17 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
229
301
|
return false;
|
|
230
302
|
}
|
|
231
303
|
} else {
|
|
232
|
-
var
|
|
304
|
+
var _trackSyncBlocks4 = trackSyncBlocks(function (node) {
|
|
233
305
|
return node.type.name === 'syncBlock';
|
|
234
306
|
}, tr, state),
|
|
235
|
-
|
|
236
|
-
|
|
307
|
+
_syncBlockRemoved = _trackSyncBlocks4.removed,
|
|
308
|
+
_syncBlockAdded = _trackSyncBlocks4.added;
|
|
237
309
|
var errorFlag = false;
|
|
238
310
|
|
|
239
311
|
// Disable (bodied)syncBlock node deletion/creation/edition in offline mode and trigger an error flag instead
|
|
240
|
-
if (isConfirmedSyncBlockDeletion || bodiedSyncBlockRemoved.length > 0 ||
|
|
312
|
+
if (isConfirmedSyncBlockDeletion || bodiedSyncBlockRemoved.length > 0 || _syncBlockRemoved.length > 0) {
|
|
241
313
|
errorFlag = FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE;
|
|
242
|
-
} else if (bodiedSyncBlockAdded.length > 0 ||
|
|
314
|
+
} else if (bodiedSyncBlockAdded.length > 0 || _syncBlockAdded.length > 0) {
|
|
243
315
|
errorFlag = FLAG_ID.CANNOT_CREATE_WHEN_OFFLINE;
|
|
244
316
|
} else if (hasEditInSyncBlock(tr, state)) {
|
|
245
317
|
errorFlag = FLAG_ID.CANNOT_EDIT_WHEN_OFFLINE;
|
|
@@ -247,8 +319,8 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
247
319
|
if (errorFlag) {
|
|
248
320
|
// Use setTimeout to dispatch transaction in next tick and avoid re-entrant dispatch
|
|
249
321
|
setTimeout(function () {
|
|
250
|
-
api === null || api === void 0 || api.core.actions.execute(function (
|
|
251
|
-
var tr =
|
|
322
|
+
api === null || api === void 0 || api.core.actions.execute(function (_ref5) {
|
|
323
|
+
var tr = _ref5.tr;
|
|
252
324
|
return tr.setMeta(syncedBlockPluginKey, {
|
|
253
325
|
activeFlag: {
|
|
254
326
|
id: errorFlag
|
|
@@ -277,8 +349,8 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
277
349
|
if (!tr.getMeta(pmHistoryPluginKey)) {
|
|
278
350
|
return 0; // continue
|
|
279
351
|
}
|
|
280
|
-
var
|
|
281
|
-
added =
|
|
352
|
+
var _trackSyncBlocks5 = trackSyncBlocks(syncBlockStore.sourceManager.isSourceBlock, tr, oldState),
|
|
353
|
+
added = _trackSyncBlocks5.added;
|
|
282
354
|
if (added.length > 0) {
|
|
283
355
|
// Delete bodiedSyncBlock if it's originated from history, i.e. redo creation
|
|
284
356
|
// See filterTransaction above for more details
|
|
@@ -90,16 +90,16 @@ export var getMenuAndToolbarExperiencesPlugin = function getMenuAndToolbarExperi
|
|
|
90
90
|
return {
|
|
91
91
|
destroy: function destroy() {
|
|
92
92
|
createSourcePrimaryToolbarExperience.abort({
|
|
93
|
-
reason: '
|
|
93
|
+
reason: 'editorDestroyed'
|
|
94
94
|
});
|
|
95
95
|
createSourceBlockMenuExperience.abort({
|
|
96
|
-
reason: '
|
|
96
|
+
reason: 'editorDestroyed'
|
|
97
97
|
});
|
|
98
98
|
createSourceQuickInsertMenuExperience.abort({
|
|
99
|
-
reason: '
|
|
99
|
+
reason: 'editorDestroyed'
|
|
100
100
|
});
|
|
101
101
|
deleteReferenceSyncedBlockExperience.abort({
|
|
102
|
-
reason: '
|
|
102
|
+
reason: 'editorDestroyed'
|
|
103
103
|
});
|
|
104
104
|
unbindClickListener();
|
|
105
105
|
unbindKeydownListener();
|
|
@@ -3,6 +3,7 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
3
3
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
4
4
|
import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
5
5
|
import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
export var trackSyncBlocks = function trackSyncBlocks(predicate, tr, state) {
|
|
7
8
|
var removed = {};
|
|
8
9
|
var added = {};
|
|
@@ -19,14 +20,15 @@ export var trackSyncBlocks = function trackSyncBlocks(predicate, tr, state) {
|
|
|
19
20
|
});
|
|
20
21
|
|
|
21
22
|
// this is a quick check to see if any insertion/deletion of bodiedSyncBlock happened
|
|
22
|
-
var hasBodiedSyncBlockChanges = replaceSteps.some(function (step) {
|
|
23
|
+
var hasBodiedSyncBlockChanges = replaceSteps.some(function (step, idx) {
|
|
23
24
|
var from = step.from,
|
|
24
25
|
to = step.to;
|
|
26
|
+
var docAtStep = fg('platform_synced_block_dogfooding') ? tr.docs[idx] : state.doc;
|
|
25
27
|
var hasChange = false;
|
|
26
28
|
if (from !== to) {
|
|
27
29
|
step.getMap().forEach(function (oldStart, oldEnd) {
|
|
28
30
|
if (oldStart !== oldEnd && !hasChange) {
|
|
29
|
-
var deletedSlice =
|
|
31
|
+
var deletedSlice = docAtStep.slice(Math.max(0, oldStart), Math.min(docAtStep.content.size, oldEnd));
|
|
30
32
|
deletedSlice.content.forEach(function (node) {
|
|
31
33
|
if (hasChange) {
|
|
32
34
|
return;
|
package/dist/esm/types/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export var FLAG_ID = /*#__PURE__*/function (FLAG_ID) {
|
|
|
4
4
|
FLAG_ID["CANNOT_CREATE_WHEN_OFFLINE"] = "cannot-create-when-offline";
|
|
5
5
|
FLAG_ID["FAIL_TO_DELETE"] = "fail-to-delete";
|
|
6
6
|
FLAG_ID["SYNC_BLOCK_COPIED"] = "sync-block-copied";
|
|
7
|
+
FLAG_ID["UNPUBLISHED_SYNC_BLOCK_PASTED"] = "unpublished-sync-block-pasted";
|
|
7
8
|
return FLAG_ID;
|
|
8
9
|
}({});
|
|
9
10
|
export var SYNCED_BLOCK_BUTTON_TEST_ID = {
|
package/dist/esm/ui/Flag.js
CHANGED
|
@@ -11,7 +11,7 @@ import StatusSuccessIcon from '@atlaskit/icon/core/status-success';
|
|
|
11
11
|
import StatusWarningIcon from '@atlaskit/icon/core/status-warning';
|
|
12
12
|
import { syncedBlockPluginKey } from '../pm-plugins/main';
|
|
13
13
|
import { FLAG_ID } from '../types';
|
|
14
|
-
var flagMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE, {
|
|
14
|
+
var flagMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE, {
|
|
15
15
|
title: messages.failToDeleteTitle,
|
|
16
16
|
description: messages.failToDeleteWhenOfflineDescription,
|
|
17
17
|
type: 'error'
|
|
@@ -30,6 +30,10 @@ var flagMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_d
|
|
|
30
30
|
}), FLAG_ID.SYNC_BLOCK_COPIED, {
|
|
31
31
|
title: messages.syncBlockCopiedTitle,
|
|
32
32
|
type: 'info'
|
|
33
|
+
}), FLAG_ID.UNPUBLISHED_SYNC_BLOCK_PASTED, {
|
|
34
|
+
title: messages.unpublishedSyncBlockPastedTitle,
|
|
35
|
+
description: messages.unpublishedSyncBlockPastedDescription,
|
|
36
|
+
type: 'info'
|
|
33
37
|
});
|
|
34
38
|
export var Flag = function Flag(_ref) {
|
|
35
39
|
var api = _ref.api;
|
|
@@ -51,42 +51,40 @@ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
|
|
|
51
51
|
setTooltipContent(tooltipContent);
|
|
52
52
|
}, [contentUpdatedAt, formatMessage, intl, tooltipMessage]);
|
|
53
53
|
var ariaDescribedById = "sync-block-label-description-".concat(localId);
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
};
|
|
90
|
-
return fg('platform_synced_block_dogfooding') ? isSource ? /*#__PURE__*/React.createElement(LabelComponent, null) : /*#__PURE__*/React.createElement(LabelWithTooltip, null) : /*#__PURE__*/React.createElement(LabelWithTooltip, null);
|
|
54
|
+
var label = /*#__PURE__*/React.createElement("div", {
|
|
55
|
+
"data-testid": SyncBlockLabelDataId
|
|
56
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
57
|
+
,
|
|
58
|
+
className: SyncBlockLabelSharedCssClassName.labelClassName,
|
|
59
|
+
"aria-describedby": ariaDescribedById
|
|
60
|
+
}, /*#__PURE__*/React.createElement(BlockSyncedIcon, {
|
|
61
|
+
color: "var(--ds-icon-subtle, #505258)",
|
|
62
|
+
size: "small",
|
|
63
|
+
label: ""
|
|
64
|
+
}), isSource || !title ? /*#__PURE__*/React.createElement(Text, {
|
|
65
|
+
size: "small",
|
|
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')) {
|
|
73
|
+
return label;
|
|
74
|
+
}
|
|
75
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
76
|
+
position: "top",
|
|
77
|
+
content: fg('platform_synced_block_dogfooding') ? tooltipContent : tooltipMessage
|
|
78
|
+
// workaround because tooltip adds aria-describedby with a new id every time the tooltip is opened
|
|
79
|
+
// this causes an infinite rerender loop because of the forwardRef from the node view we are inside in bodiedSyncBlock
|
|
80
|
+
// tooltip content is available for screen readers in visually hidden content after the label
|
|
81
|
+
,
|
|
82
|
+
isScreenReaderAnnouncementDisabled: true
|
|
83
|
+
// using this to ensure that the 'last edited' time is updated when the tooltip is opened
|
|
84
|
+
,
|
|
85
|
+
onShow: updateTooltipContent
|
|
86
|
+
}, label, /*#__PURE__*/React.createElement(VisuallyHidden, {
|
|
87
|
+
id: ariaDescribedById
|
|
88
|
+
}, tooltipContent));
|
|
91
89
|
};
|
|
92
90
|
export var SyncBlockLabel = /*#__PURE__*/React.memo(SyncBlockLabelComponent);
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { INSERT_BLOCK_SECTION, INSERT_BLOCK_SECTION_RANK, SYNCED_BLOCK_BUTTON, SYNCED_BLOCK_GROUP, SYNCED_BLOCK_SECTION_RANK } from '@atlaskit/editor-common/toolbar';
|
|
3
3
|
import { Show, ToolbarButtonGroup } from '@atlaskit/editor-toolbar';
|
|
4
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
4
|
import { CreateSyncedBlockButton } from './CreateSyncedBlockButton';
|
|
6
5
|
var SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP = {
|
|
7
6
|
type: SYNCED_BLOCK_GROUP.type,
|
|
8
7
|
key: SYNCED_BLOCK_GROUP.key,
|
|
9
|
-
component:
|
|
8
|
+
component: function component(_ref) {
|
|
10
9
|
var children = _ref.children;
|
|
11
10
|
return /*#__PURE__*/React.createElement(Show, {
|
|
12
11
|
above: "md"
|
|
13
12
|
}, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children));
|
|
14
|
-
}
|
|
13
|
+
},
|
|
15
14
|
parents: [{
|
|
16
15
|
type: INSERT_BLOCK_SECTION.type,
|
|
17
16
|
key: INSERT_BLOCK_SECTION.key,
|
|
@@ -5,7 +5,8 @@ export declare enum FLAG_ID {
|
|
|
5
5
|
CANNOT_EDIT_WHEN_OFFLINE = "cannot-edit-when-offline",
|
|
6
6
|
CANNOT_CREATE_WHEN_OFFLINE = "cannot-create-when-offline",
|
|
7
7
|
FAIL_TO_DELETE = "fail-to-delete",
|
|
8
|
-
SYNC_BLOCK_COPIED = "sync-block-copied"
|
|
8
|
+
SYNC_BLOCK_COPIED = "sync-block-copied",
|
|
9
|
+
UNPUBLISHED_SYNC_BLOCK_PASTED = "unpublished-sync-block-pasted"
|
|
9
10
|
}
|
|
10
11
|
type FlagConfig = {
|
|
11
12
|
id: FLAG_ID;
|
|
@@ -5,7 +5,8 @@ export declare enum FLAG_ID {
|
|
|
5
5
|
CANNOT_EDIT_WHEN_OFFLINE = "cannot-edit-when-offline",
|
|
6
6
|
CANNOT_CREATE_WHEN_OFFLINE = "cannot-create-when-offline",
|
|
7
7
|
FAIL_TO_DELETE = "fail-to-delete",
|
|
8
|
-
SYNC_BLOCK_COPIED = "sync-block-copied"
|
|
8
|
+
SYNC_BLOCK_COPIED = "sync-block-copied",
|
|
9
|
+
UNPUBLISHED_SYNC_BLOCK_PASTED = "unpublished-sync-block-pasted"
|
|
9
10
|
}
|
|
10
11
|
type FlagConfig = {
|
|
11
12
|
id: FLAG_ID;
|
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.5",
|
|
4
4
|
"description": "SyncedBlock plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -45,14 +45,13 @@
|
|
|
45
45
|
"@atlaskit/editor-toolbar": "^0.19.0",
|
|
46
46
|
"@atlaskit/flag": "^17.8.0",
|
|
47
47
|
"@atlaskit/icon": "30.0.0",
|
|
48
|
-
"@atlaskit/icon-lab": "^5.
|
|
48
|
+
"@atlaskit/icon-lab": "^5.15.0",
|
|
49
49
|
"@atlaskit/logo": "^19.10.0",
|
|
50
50
|
"@atlaskit/lozenge": "^13.3.0",
|
|
51
51
|
"@atlaskit/modal-dialog": "^14.10.0",
|
|
52
52
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
53
53
|
"@atlaskit/primitives": "^17.1.0",
|
|
54
54
|
"@atlaskit/spinner": "19.0.9",
|
|
55
|
-
"@atlaskit/tmp-editor-statsig": "^16.32.0",
|
|
56
55
|
"@atlaskit/tokens": "10.1.0",
|
|
57
56
|
"@atlaskit/tooltip": "^20.14.0",
|
|
58
57
|
"@atlaskit/visually-hidden": "^3.0.0",
|
|
@@ -63,7 +62,7 @@
|
|
|
63
62
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
64
63
|
},
|
|
65
64
|
"peerDependencies": {
|
|
66
|
-
"@atlaskit/editor-common": "^111.
|
|
65
|
+
"@atlaskit/editor-common": "^111.9.0",
|
|
67
66
|
"react": "^18.2.0"
|
|
68
67
|
},
|
|
69
68
|
"devDependencies": {
|