@atlaskit/editor-plugin-synced-block 6.0.13 → 6.0.15
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 +14 -0
- package/dist/cjs/nodeviews/bodiedSyncedBlock.js +1 -2
- package/dist/cjs/pm-plugins/main.js +39 -136
- package/dist/cjs/pm-plugins/utils/utils.js +1 -6
- package/dist/cjs/syncedBlockPlugin.js +1 -2
- package/dist/cjs/ui/SyncBlockRefresher.js +1 -17
- package/dist/es2019/nodeviews/bodiedSyncedBlock.js +1 -2
- package/dist/es2019/pm-plugins/main.js +31 -125
- package/dist/es2019/pm-plugins/utils/utils.js +1 -6
- package/dist/es2019/syncedBlockPlugin.js +1 -2
- package/dist/es2019/ui/SyncBlockRefresher.js +0 -16
- package/dist/esm/nodeviews/bodiedSyncedBlock.js +1 -2
- package/dist/esm/pm-plugins/main.js +33 -130
- package/dist/esm/pm-plugins/utils/utils.js +1 -6
- package/dist/esm/syncedBlockPlugin.js +1 -2
- package/dist/esm/ui/SyncBlockRefresher.js +0 -16
- package/dist/types/ui/SyncBlockRefresher.d.ts +0 -1
- package/dist/types-ts4.5/ui/SyncBlockRefresher.d.ts +0 -1
- package/docs/0-intro.tsx +3 -1
- package/package.json +6 -9
- package/dist/cjs/nodeviews/bodiedLazySyncedBlock.js +0 -27
- package/dist/es2019/nodeviews/bodiedLazySyncedBlock.js +0 -17
- package/dist/esm/nodeviews/bodiedLazySyncedBlock.js +0 -16
- package/dist/types/nodeviews/bodiedLazySyncedBlock.d.ts +0 -3
- package/dist/types-ts4.5/nodeviews/bodiedLazySyncedBlock.d.ts +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 6.0.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 6.0.14
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`7428d9bf3aa13`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7428d9bf3aa13) -
|
|
14
|
+
Clean up platform_synced_block_patch_5 feature gate
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 6.0.13
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -17,7 +17,6 @@ var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/rea
|
|
|
17
17
|
var _syncBlock = require("@atlaskit/editor-common/sync-block");
|
|
18
18
|
var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
|
|
19
19
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
20
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
21
20
|
var _BodiedSyncBlockWrapper = require("../ui/BodiedSyncBlockWrapper");
|
|
22
21
|
var _SyncBlockLabel = require("../ui/SyncBlockLabel");
|
|
23
22
|
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)); }
|
|
@@ -117,7 +116,7 @@ var BodiedSyncBlockOld = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
117
116
|
dom = _DOMSerializer$render.dom,
|
|
118
117
|
contentDOM = _DOMSerializer$render.contentDOM;
|
|
119
118
|
// In SSR, the first check won't work, so fallback to nodeType check
|
|
120
|
-
if (dom instanceof HTMLElement || dom.nodeType === 1
|
|
119
|
+
if (dom instanceof HTMLElement || dom.nodeType === 1) {
|
|
121
120
|
this.updateContentEditable({
|
|
122
121
|
contentDOM: contentDOM
|
|
123
122
|
});
|
|
@@ -18,9 +18,7 @@ var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
|
|
|
18
18
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
19
19
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
20
20
|
var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
|
|
21
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
22
21
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
23
|
-
var _bodiedLazySyncedBlock = require("../nodeviews/bodiedLazySyncedBlock");
|
|
24
22
|
var _bodiedSyncedBlock = require("../nodeviews/bodiedSyncedBlock");
|
|
25
23
|
var _syncedBlock = require("../nodeviews/syncedBlock");
|
|
26
24
|
var _types = require("../types");
|
|
@@ -28,7 +26,7 @@ var _handleBodiedSyncBlockCreation = require("./utils/handle-bodied-sync-block-c
|
|
|
28
26
|
var _handleBodiedSyncBlockRemoval = require("./utils/handle-bodied-sync-block-removal");
|
|
29
27
|
var _ignoreDomEvent = require("./utils/ignore-dom-event");
|
|
30
28
|
var _selectionDecorations = require("./utils/selection-decorations");
|
|
31
|
-
var
|
|
29
|
+
var _trackSyncBlocks6 = require("./utils/track-sync-blocks");
|
|
32
30
|
var _utils2 = require("./utils/utils");
|
|
33
31
|
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; }
|
|
34
32
|
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; }
|
|
@@ -120,7 +118,7 @@ var filterTransactionOnline = function filterTransactionOnline(_ref3) {
|
|
|
120
118
|
bodiedSyncBlockRemoved = _ref3.bodiedSyncBlockRemoved,
|
|
121
119
|
bodiedSyncBlockAdded = _ref3.bodiedSyncBlockAdded,
|
|
122
120
|
extensionFlagShown = _ref3.extensionFlagShown;
|
|
123
|
-
var _trackSyncBlocks = (0,
|
|
121
|
+
var _trackSyncBlocks = (0, _trackSyncBlocks6.trackSyncBlocks)(function (node) {
|
|
124
122
|
return node.type.name === 'syncBlock';
|
|
125
123
|
}, tr, state),
|
|
126
124
|
syncBlockRemoved = _trackSyncBlocks.removed,
|
|
@@ -176,7 +174,7 @@ var filterTransactionOffline = function filterTransactionOffline(_ref4) {
|
|
|
176
174
|
isConfirmedSyncBlockDeletion = _ref4.isConfirmedSyncBlockDeletion,
|
|
177
175
|
bodiedSyncBlockRemoved = _ref4.bodiedSyncBlockRemoved,
|
|
178
176
|
bodiedSyncBlockAdded = _ref4.bodiedSyncBlockAdded;
|
|
179
|
-
var _trackSyncBlocks2 = (0,
|
|
177
|
+
var _trackSyncBlocks2 = (0, _trackSyncBlocks6.trackSyncBlocks)(function (node) {
|
|
180
178
|
return node.type.name === 'syncBlock';
|
|
181
179
|
}, tr, state),
|
|
182
180
|
syncBlockRemoved = _trackSyncBlocks2.removed,
|
|
@@ -186,7 +184,7 @@ var filterTransactionOffline = function filterTransactionOffline(_ref4) {
|
|
|
186
184
|
errorFlag = _types.FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE;
|
|
187
185
|
} else if (bodiedSyncBlockAdded.length > 0 || syncBlockAdded.length > 0) {
|
|
188
186
|
errorFlag = _types.FLAG_ID.CANNOT_CREATE_WHEN_OFFLINE;
|
|
189
|
-
} else if ((0,
|
|
187
|
+
} else if ((0, _trackSyncBlocks6.hasEditInSyncBlock)(tr, state)) {
|
|
190
188
|
errorFlag = _types.FLAG_ID.CANNOT_EDIT_WHEN_OFFLINE;
|
|
191
189
|
}
|
|
192
190
|
if (errorFlag) {
|
|
@@ -240,17 +238,13 @@ var SyncedBlockPluginContext = /*#__PURE__*/function () {
|
|
|
240
238
|
}]);
|
|
241
239
|
}();
|
|
242
240
|
var createPlugin = exports.createPlugin = function createPlugin(options, pmPluginFactoryParams, syncBlockStore, api) {
|
|
243
|
-
var _ctx$confirmationTran, _ctx$unpublishedFlagS, _ctx$extensionFlagSho;
|
|
244
241
|
var _ref6 = options || {},
|
|
245
242
|
_ref6$useLongPressSel = _ref6.useLongPressSelection,
|
|
246
243
|
useLongPressSelection = _ref6$useLongPressSel === void 0 ? false : _ref6$useLongPressSel;
|
|
247
|
-
var ctx =
|
|
248
|
-
var confirmationTransactionRef =
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
var isCopyEvent = false;
|
|
252
|
-
var unpublishedFlagShown = (_ctx$unpublishedFlagS = ctx === null || ctx === void 0 ? void 0 : ctx.unpublishedFlagShown) !== null && _ctx$unpublishedFlagS !== void 0 ? _ctx$unpublishedFlagS : new Set();
|
|
253
|
-
var extensionFlagShown = (_ctx$extensionFlagSho = ctx === null || ctx === void 0 ? void 0 : ctx.extensionFlagShown) !== null && _ctx$extensionFlagSho !== void 0 ? _ctx$extensionFlagSho : new Set();
|
|
244
|
+
var ctx = new SyncedBlockPluginContext();
|
|
245
|
+
var confirmationTransactionRef = ctx.confirmationTransactionRef;
|
|
246
|
+
var unpublishedFlagShown = ctx.unpublishedFlagShown;
|
|
247
|
+
var extensionFlagShown = ctx.extensionFlagShown;
|
|
254
248
|
|
|
255
249
|
// Set up callback to detect unpublished sync blocks when they're fetched
|
|
256
250
|
syncBlockStore.referenceManager.setOnUnpublishedSyncBlockDetected(function (resourceId) {
|
|
@@ -282,7 +276,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
282
276
|
activeFlag: false,
|
|
283
277
|
syncBlockStore: syncBlockStore,
|
|
284
278
|
retryCreationPosMap: new Map(),
|
|
285
|
-
hasUnsavedBodiedSyncBlockChanges:
|
|
279
|
+
hasUnsavedBodiedSyncBlockChanges: syncBlockStore.sourceManager.hasUnsavedChanges()
|
|
286
280
|
};
|
|
287
281
|
},
|
|
288
282
|
apply: function apply(tr, currentPluginState, oldEditorState) {
|
|
@@ -292,11 +286,11 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
292
286
|
selectionDecorationSet = currentPluginState.selectionDecorationSet,
|
|
293
287
|
bodiedSyncBlockDeletionStatus = currentPluginState.bodiedSyncBlockDeletionStatus,
|
|
294
288
|
retryCreationPosMap = currentPluginState.retryCreationPosMap;
|
|
295
|
-
var newDecorationSet =
|
|
296
|
-
: selectionDecorationSet
|
|
289
|
+
var newDecorationSet = tr.docChanged ? selectionDecorationSet.map(tr.mapping, tr.doc) // only map if document changed
|
|
290
|
+
: selectionDecorationSet;
|
|
297
291
|
if (!tr.selection.eq(oldEditorState.selection)) {
|
|
298
292
|
newDecorationSet = (0, _selectionDecorations.calculateDecorations)(tr.doc, tr.selection, tr.doc.type.schema);
|
|
299
|
-
} else if (tr.docChanged
|
|
293
|
+
} else if (tr.docChanged) {
|
|
300
294
|
var existingDecorationsLength = selectionDecorationSet.find().length;
|
|
301
295
|
var newDecorationsLength = newDecorationSet.find().length;
|
|
302
296
|
|
|
@@ -315,7 +309,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
315
309
|
syncBlockStore: syncBlockStore,
|
|
316
310
|
retryCreationPosMap: newRetryCreationPosMap,
|
|
317
311
|
bodiedSyncBlockDeletionStatus: (_meta$bodiedSyncBlock = meta === null || meta === void 0 ? void 0 : meta.bodiedSyncBlockDeletionStatus) !== null && _meta$bodiedSyncBlock !== void 0 ? _meta$bodiedSyncBlock : bodiedSyncBlockDeletionStatus,
|
|
318
|
-
hasUnsavedBodiedSyncBlockChanges:
|
|
312
|
+
hasUnsavedBodiedSyncBlockChanges: syncBlockStore.sourceManager.hasUnsavedChanges()
|
|
319
313
|
};
|
|
320
314
|
}
|
|
321
315
|
},
|
|
@@ -339,7 +333,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
339
333
|
}).init()
|
|
340
334
|
);
|
|
341
335
|
},
|
|
342
|
-
bodiedSyncBlock: (0,
|
|
336
|
+
bodiedSyncBlock: (0, _experiments.editorExperiment)('platform_synced_block_use_new_source_nodeview', true, {
|
|
343
337
|
exposure: true
|
|
344
338
|
}) ? (0, _bodiedSyncedBlock.bodiedSyncBlockNodeView)({
|
|
345
339
|
pluginOptions: options,
|
|
@@ -351,10 +345,6 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
351
345
|
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
352
346
|
api: api,
|
|
353
347
|
syncBlockStore: syncBlockStore
|
|
354
|
-
}) : (0, _bodiedLazySyncedBlock.lazyBodiedSyncBlockView)({
|
|
355
|
-
pluginOptions: options,
|
|
356
|
-
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
357
|
-
api: api
|
|
358
348
|
})
|
|
359
349
|
},
|
|
360
350
|
decorations: function decorations(state) {
|
|
@@ -365,7 +355,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
365
355
|
var doc = state.doc;
|
|
366
356
|
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);
|
|
367
357
|
var isViewMode = (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'view';
|
|
368
|
-
var isDragging = (
|
|
358
|
+
var isDragging = (api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || (_api$userIntent = _api$userIntent.sharedState.currentState()) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.currentUserIntent) === 'dragging';
|
|
369
359
|
var offlineDecorations = [];
|
|
370
360
|
var viewModeDecorations = [];
|
|
371
361
|
var loadingDecorations = [];
|
|
@@ -388,7 +378,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
388
378
|
}
|
|
389
379
|
|
|
390
380
|
// Show sync block border while the user is dragging
|
|
391
|
-
if (isDragging && (node.type.name === 'bodiedSyncBlock' || node.type.name === 'syncBlock')
|
|
381
|
+
if (isDragging && (node.type.name === 'bodiedSyncBlock' || node.type.name === 'syncBlock')) {
|
|
392
382
|
dragDecorations.push(_view.Decoration.node(pos, pos + node.nodeSize, {
|
|
393
383
|
class: _syncBlock.SyncBlockStateCssClassName.draggingClassName
|
|
394
384
|
}));
|
|
@@ -416,11 +406,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
416
406
|
return (0, _ignoreDomEvent.shouldIgnoreDomEvent)(view, event, api);
|
|
417
407
|
},
|
|
418
408
|
copy: function copy() {
|
|
419
|
-
|
|
420
|
-
ctx.markCopyEvent();
|
|
421
|
-
} else {
|
|
422
|
-
isCopyEvent = true;
|
|
423
|
-
}
|
|
409
|
+
ctx.markCopyEvent();
|
|
424
410
|
return false;
|
|
425
411
|
}
|
|
426
412
|
},
|
|
@@ -429,10 +415,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
429
415
|
var pluginState = syncedBlockPluginKey.getState(state);
|
|
430
416
|
var syncBlockStore = pluginState === null || pluginState === void 0 ? void 0 : pluginState.syncBlockStore;
|
|
431
417
|
var schema = state.schema;
|
|
432
|
-
var isCopy = ctx
|
|
433
|
-
if (!ctx) {
|
|
434
|
-
isCopyEvent = false;
|
|
435
|
-
}
|
|
418
|
+
var isCopy = ctx.consumeCopyEvent();
|
|
436
419
|
if (!syncBlockStore || !isCopy) {
|
|
437
420
|
return slice;
|
|
438
421
|
}
|
|
@@ -471,7 +454,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
471
454
|
|
|
472
455
|
// Track newly added reference sync blocks before processing the transaction
|
|
473
456
|
if (tr.docChanged && !tr.getMeta('isRemote')) {
|
|
474
|
-
var _trackSyncBlocks3 = (0,
|
|
457
|
+
var _trackSyncBlocks3 = (0, _trackSyncBlocks6.trackSyncBlocks)(function (node) {
|
|
475
458
|
return node.type.name === 'syncBlock';
|
|
476
459
|
}, tr, state),
|
|
477
460
|
added = _trackSyncBlocks3.added;
|
|
@@ -485,106 +468,26 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
485
468
|
if (!tr.docChanged || Boolean(tr.getMeta('isRemote')) || !isOffline && isConfirmedSyncBlockDeletion) {
|
|
486
469
|
return true;
|
|
487
470
|
}
|
|
488
|
-
var _trackSyncBlocks4 = (0,
|
|
471
|
+
var _trackSyncBlocks4 = (0, _trackSyncBlocks6.trackSyncBlocks)(syncBlockStore.sourceManager.isSourceBlock, tr, state),
|
|
489
472
|
bodiedSyncBlockRemoved = _trackSyncBlocks4.removed,
|
|
490
473
|
bodiedSyncBlockAdded = _trackSyncBlocks4.added;
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
});
|
|
509
|
-
}
|
|
510
|
-
if (!isOffline) {
|
|
511
|
-
var _trackSyncBlocks5 = (0, _trackSyncBlocks8.trackSyncBlocks)(function (node) {
|
|
512
|
-
return node.type.name === 'syncBlock';
|
|
513
|
-
}, tr, state),
|
|
514
|
-
_syncBlockRemoved = _trackSyncBlocks5.removed,
|
|
515
|
-
_syncBlockAdded = _trackSyncBlocks5.added;
|
|
516
|
-
_syncBlockRemoved.forEach(function (syncBlock) {
|
|
517
|
-
var _api$analytics3;
|
|
518
|
-
api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 || (_api$analytics3 = _api$analytics3.actions) === null || _api$analytics3 === void 0 || _api$analytics3.fireAnalyticsEvent({
|
|
519
|
-
action: _analytics.ACTION.DELETED,
|
|
520
|
-
actionSubject: _analytics.ACTION_SUBJECT.SYNCED_BLOCK,
|
|
521
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_DELETE,
|
|
522
|
-
attributes: {
|
|
523
|
-
resourceId: syncBlock.attrs.resourceId,
|
|
524
|
-
blockInstanceId: syncBlock.attrs.localId
|
|
525
|
-
},
|
|
526
|
-
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
527
|
-
});
|
|
528
|
-
});
|
|
529
|
-
_syncBlockAdded.forEach(function (syncBlock) {
|
|
530
|
-
var _api$analytics4;
|
|
531
|
-
api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 || (_api$analytics4 = _api$analytics4.actions) === null || _api$analytics4 === void 0 || _api$analytics4.fireAnalyticsEvent({
|
|
532
|
-
action: _analytics.ACTION.INSERTED,
|
|
533
|
-
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
534
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.SYNCED_BLOCK,
|
|
535
|
-
attributes: {
|
|
536
|
-
resourceId: syncBlock.attrs.resourceId,
|
|
537
|
-
blockInstanceId: syncBlock.attrs.localId
|
|
538
|
-
},
|
|
539
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
540
|
-
});
|
|
541
|
-
});
|
|
542
|
-
if (bodiedSyncBlockRemoved.length > 0) {
|
|
543
|
-
confirmationTransactionRef.current = tr;
|
|
544
|
-
return (0, _handleBodiedSyncBlockRemoval.handleBodiedSyncBlockRemoval)(bodiedSyncBlockRemoved, syncBlockStore, api, confirmationTransactionRef, getDeleteReason(tr));
|
|
545
|
-
}
|
|
546
|
-
if (bodiedSyncBlockAdded.length > 0) {
|
|
547
|
-
if (tr.getMeta(_utils.pmHistoryPluginKey)) {
|
|
548
|
-
// We don't allow bodiedSyncBlock creation via redo, however, we need to return true here to let transaction through so history can be updated properly.
|
|
549
|
-
// If we simply returns false, creation from redo is blocked as desired, but this results in editor showing redo as possible even though it's not.
|
|
550
|
-
// After true is returned here and the node is created, we delete the node in the filterTransaction immediately, which cancels out the creation
|
|
551
|
-
return true;
|
|
552
|
-
}
|
|
553
|
-
(0, _handleBodiedSyncBlockCreation.handleBodiedSyncBlockCreation)(bodiedSyncBlockAdded, state, api);
|
|
554
|
-
return true;
|
|
555
|
-
}
|
|
556
|
-
showExtensionInSyncBlockWarningIfNeeded(tr, state, api, extensionFlagShown);
|
|
557
|
-
return true;
|
|
558
|
-
}
|
|
559
|
-
var _trackSyncBlocks6 = (0, _trackSyncBlocks8.trackSyncBlocks)(function (node) {
|
|
560
|
-
return node.type.name === 'syncBlock';
|
|
561
|
-
}, tr, state),
|
|
562
|
-
syncBlockRemoved = _trackSyncBlocks6.removed,
|
|
563
|
-
syncBlockAdded = _trackSyncBlocks6.added;
|
|
564
|
-
var errorFlag = false;
|
|
565
|
-
|
|
566
|
-
// Disable (bodied)syncBlock node deletion/creation/edition in offline mode and trigger an error flag instead
|
|
567
|
-
if (isConfirmedSyncBlockDeletion || bodiedSyncBlockRemoved.length > 0 || syncBlockRemoved.length > 0) {
|
|
568
|
-
errorFlag = _types.FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE;
|
|
569
|
-
} else if (bodiedSyncBlockAdded.length > 0 || syncBlockAdded.length > 0) {
|
|
570
|
-
errorFlag = _types.FLAG_ID.CANNOT_CREATE_WHEN_OFFLINE;
|
|
571
|
-
} else if ((0, _trackSyncBlocks8.hasEditInSyncBlock)(tr, state)) {
|
|
572
|
-
errorFlag = _types.FLAG_ID.CANNOT_EDIT_WHEN_OFFLINE;
|
|
573
|
-
}
|
|
574
|
-
if (errorFlag) {
|
|
575
|
-
(0, _utils2.deferDispatch)(function () {
|
|
576
|
-
api === null || api === void 0 || api.core.actions.execute(function (_ref9) {
|
|
577
|
-
var tr = _ref9.tr;
|
|
578
|
-
return tr.setMeta(syncedBlockPluginKey, {
|
|
579
|
-
activeFlag: {
|
|
580
|
-
id: errorFlag
|
|
581
|
-
}
|
|
582
|
-
});
|
|
583
|
-
});
|
|
584
|
-
});
|
|
585
|
-
return false;
|
|
586
|
-
}
|
|
587
|
-
return true;
|
|
474
|
+
return isOffline ? filterTransactionOffline({
|
|
475
|
+
tr: tr,
|
|
476
|
+
state: state,
|
|
477
|
+
api: api,
|
|
478
|
+
isConfirmedSyncBlockDeletion: isConfirmedSyncBlockDeletion,
|
|
479
|
+
bodiedSyncBlockRemoved: bodiedSyncBlockRemoved,
|
|
480
|
+
bodiedSyncBlockAdded: bodiedSyncBlockAdded
|
|
481
|
+
}) : filterTransactionOnline({
|
|
482
|
+
tr: tr,
|
|
483
|
+
state: state,
|
|
484
|
+
syncBlockStore: syncBlockStore,
|
|
485
|
+
api: api,
|
|
486
|
+
confirmationTransactionRef: confirmationTransactionRef,
|
|
487
|
+
bodiedSyncBlockRemoved: bodiedSyncBlockRemoved,
|
|
488
|
+
bodiedSyncBlockAdded: bodiedSyncBlockAdded,
|
|
489
|
+
extensionFlagShown: extensionFlagShown
|
|
490
|
+
});
|
|
588
491
|
},
|
|
589
492
|
appendTransaction: function appendTransaction(trs, oldState, newState) {
|
|
590
493
|
trs.filter(function (tr) {
|
|
@@ -600,8 +503,8 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
600
503
|
var _loop = function _loop() {
|
|
601
504
|
var tr = _step2.value;
|
|
602
505
|
if (tr.getMeta(_utils.pmHistoryPluginKey)) {
|
|
603
|
-
var
|
|
604
|
-
added =
|
|
506
|
+
var _trackSyncBlocks5 = (0, _trackSyncBlocks6.trackSyncBlocks)(syncBlockStore.sourceManager.isSourceBlock, tr, oldState),
|
|
507
|
+
added = _trackSyncBlocks5.added;
|
|
605
508
|
if (added.length > 0) {
|
|
606
509
|
// Delete bodiedSyncBlock if it's originated from history, i.e. redo creation
|
|
607
510
|
// See filterTransaction above for more details
|
|
@@ -8,18 +8,13 @@ var _selection = require("@atlaskit/editor-common/selection");
|
|
|
8
8
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
9
9
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
10
10
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
11
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
11
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
13
12
|
/**
|
|
14
13
|
* Defers a callback to the next microtask (when gated) or next macrotask via setTimeout(0).
|
|
15
14
|
* Used to avoid re-entrant ProseMirror dispatch cycles.
|
|
16
15
|
*/
|
|
17
16
|
var deferDispatch = exports.deferDispatch = function deferDispatch(fn) {
|
|
18
|
-
|
|
19
|
-
queueMicrotask(fn);
|
|
20
|
-
} else {
|
|
21
|
-
setTimeout(fn, 0);
|
|
22
|
-
}
|
|
17
|
+
queueMicrotask(fn);
|
|
23
18
|
};
|
|
24
19
|
var findSyncBlock = exports.findSyncBlock = function findSyncBlock(schema, selection) {
|
|
25
20
|
var syncBlock = schema.nodes.syncBlock;
|
|
@@ -8,7 +8,6 @@ exports.syncedBlockPlugin = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
10
|
var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
|
|
11
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
11
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
13
12
|
var _editorActions = require("./editor-actions");
|
|
14
13
|
var _editorCommands = require("./editor-commands");
|
|
@@ -130,7 +129,7 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
|
|
|
130
129
|
syncBlockStore: currentSyncBlockStore,
|
|
131
130
|
bodiedSyncBlockDeletionStatus: bodiedSyncBlockDeletionStatus,
|
|
132
131
|
retryCreationPosMap: retryCreationPosMap,
|
|
133
|
-
hasUnsavedBodiedSyncBlockChanges:
|
|
132
|
+
hasUnsavedBodiedSyncBlockChanges: hasUnsavedBodiedSyncBlockChanges
|
|
134
133
|
};
|
|
135
134
|
}
|
|
136
135
|
};
|
|
@@ -3,12 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.SyncBlockRefresher =
|
|
6
|
+
exports.SyncBlockRefresher = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
9
9
|
var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
|
|
10
|
-
var SYNC_BLOCK_FETCH_INTERVAL = exports.SYNC_BLOCK_FETCH_INTERVAL = 3000;
|
|
11
|
-
|
|
12
10
|
// Component that manages synced block data synchronization.
|
|
13
11
|
// Uses provider-based GraphQL subscriptions for updates when online.
|
|
14
12
|
// Falls back to polling at regular intervals when offline.
|
|
@@ -27,19 +25,5 @@ var SyncBlockRefresher = exports.SyncBlockRefresher = function SyncBlockRefreshe
|
|
|
27
25
|
var useRealTimeSubscriptions = isOnline;
|
|
28
26
|
syncBlockStoreManager.referenceManager.setRealTimeSubscriptionsEnabled(useRealTimeSubscriptions);
|
|
29
27
|
}, [syncBlockStoreManager, isOnline]);
|
|
30
|
-
(0, _react.useEffect)(function () {
|
|
31
|
-
if (isOnline) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
var interval = window.setInterval(function () {
|
|
35
|
-
var _document;
|
|
36
|
-
if (((_document = document) === null || _document === void 0 ? void 0 : _document.visibilityState) === 'visible') {
|
|
37
|
-
syncBlockStoreManager.referenceManager.refreshSubscriptions();
|
|
38
|
-
}
|
|
39
|
-
}, SYNC_BLOCK_FETCH_INTERVAL);
|
|
40
|
-
return function () {
|
|
41
|
-
window.clearInterval(interval);
|
|
42
|
-
};
|
|
43
|
-
}, [syncBlockStoreManager, isOnline]);
|
|
44
28
|
return null;
|
|
45
29
|
};
|
|
@@ -5,7 +5,6 @@ import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
|
5
5
|
import { BodiedSyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
|
|
6
6
|
import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
7
7
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
8
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
8
|
import { BodiedSyncBlockWrapper } from '../ui/BodiedSyncBlockWrapper';
|
|
10
9
|
import { SyncBlockLabel } from '../ui/SyncBlockLabel';
|
|
11
10
|
const toDOMOld = () => ['div', {
|
|
@@ -87,7 +86,7 @@ class BodiedSyncBlockOld extends ReactNodeView {
|
|
|
87
86
|
contentDOM
|
|
88
87
|
} = DOMSerializer.renderSpec(document, toDOMOld());
|
|
89
88
|
// In SSR, the first check won't work, so fallback to nodeType check
|
|
90
|
-
if (dom instanceof HTMLElement || dom.nodeType === 1
|
|
89
|
+
if (dom instanceof HTMLElement || dom.nodeType === 1) {
|
|
91
90
|
this.updateContentEditable({
|
|
92
91
|
contentDOM
|
|
93
92
|
});
|
|
@@ -8,9 +8,7 @@ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
|
8
8
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
9
9
|
import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
10
10
|
import { convertPMNodesToSyncBlockNodes, rebaseTransaction } from '@atlaskit/editor-synced-block-provider';
|
|
11
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
11
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
13
|
-
import { lazyBodiedSyncBlockView } from '../nodeviews/bodiedLazySyncedBlock';
|
|
14
12
|
import { bodiedSyncBlockNodeView, bodiedSyncBlockNodeViewOld } from '../nodeviews/bodiedSyncedBlock';
|
|
15
13
|
import { SyncBlock as SyncBlockView } from '../nodeviews/syncedBlock';
|
|
16
14
|
import { FLAG_ID } from '../types';
|
|
@@ -205,17 +203,13 @@ class SyncedBlockPluginContext {
|
|
|
205
203
|
}
|
|
206
204
|
}
|
|
207
205
|
export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api) => {
|
|
208
|
-
var _ctx$confirmationTran, _ctx$unpublishedFlagS, _ctx$extensionFlagSho;
|
|
209
206
|
const {
|
|
210
207
|
useLongPressSelection = false
|
|
211
208
|
} = options || {};
|
|
212
|
-
const ctx =
|
|
213
|
-
const confirmationTransactionRef =
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
let isCopyEvent = false;
|
|
217
|
-
const unpublishedFlagShown = (_ctx$unpublishedFlagS = ctx === null || ctx === void 0 ? void 0 : ctx.unpublishedFlagShown) !== null && _ctx$unpublishedFlagS !== void 0 ? _ctx$unpublishedFlagS : new Set();
|
|
218
|
-
const extensionFlagShown = (_ctx$extensionFlagSho = ctx === null || ctx === void 0 ? void 0 : ctx.extensionFlagShown) !== null && _ctx$extensionFlagSho !== void 0 ? _ctx$extensionFlagSho : new Set();
|
|
209
|
+
const ctx = new SyncedBlockPluginContext();
|
|
210
|
+
const confirmationTransactionRef = ctx.confirmationTransactionRef;
|
|
211
|
+
const unpublishedFlagShown = ctx.unpublishedFlagShown;
|
|
212
|
+
const extensionFlagShown = ctx.extensionFlagShown;
|
|
219
213
|
|
|
220
214
|
// Set up callback to detect unpublished sync blocks when they're fetched
|
|
221
215
|
syncBlockStore.referenceManager.setOnUnpublishedSyncBlockDetected(resourceId => {
|
|
@@ -244,7 +238,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
244
238
|
activeFlag: false,
|
|
245
239
|
syncBlockStore: syncBlockStore,
|
|
246
240
|
retryCreationPosMap: new Map(),
|
|
247
|
-
hasUnsavedBodiedSyncBlockChanges:
|
|
241
|
+
hasUnsavedBodiedSyncBlockChanges: syncBlockStore.sourceManager.hasUnsavedChanges()
|
|
248
242
|
};
|
|
249
243
|
},
|
|
250
244
|
apply: (tr, currentPluginState, oldEditorState) => {
|
|
@@ -256,11 +250,11 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
256
250
|
bodiedSyncBlockDeletionStatus,
|
|
257
251
|
retryCreationPosMap
|
|
258
252
|
} = currentPluginState;
|
|
259
|
-
let newDecorationSet =
|
|
260
|
-
: selectionDecorationSet
|
|
253
|
+
let newDecorationSet = tr.docChanged ? selectionDecorationSet.map(tr.mapping, tr.doc) // only map if document changed
|
|
254
|
+
: selectionDecorationSet;
|
|
261
255
|
if (!tr.selection.eq(oldEditorState.selection)) {
|
|
262
256
|
newDecorationSet = calculateDecorations(tr.doc, tr.selection, tr.doc.type.schema);
|
|
263
|
-
} else if (tr.docChanged
|
|
257
|
+
} else if (tr.docChanged) {
|
|
264
258
|
const existingDecorationsLength = selectionDecorationSet.find().length;
|
|
265
259
|
const newDecorationsLength = newDecorationSet.find().length;
|
|
266
260
|
|
|
@@ -279,7 +273,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
279
273
|
syncBlockStore: syncBlockStore,
|
|
280
274
|
retryCreationPosMap: newRetryCreationPosMap,
|
|
281
275
|
bodiedSyncBlockDeletionStatus: (_meta$bodiedSyncBlock = meta === null || meta === void 0 ? void 0 : meta.bodiedSyncBlockDeletionStatus) !== null && _meta$bodiedSyncBlock !== void 0 ? _meta$bodiedSyncBlock : bodiedSyncBlockDeletionStatus,
|
|
282
|
-
hasUnsavedBodiedSyncBlockChanges:
|
|
276
|
+
hasUnsavedBodiedSyncBlockChanges: syncBlockStore.sourceManager.hasUnsavedChanges()
|
|
283
277
|
};
|
|
284
278
|
}
|
|
285
279
|
},
|
|
@@ -300,7 +294,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
300
294
|
eventDispatcher: pmPluginFactoryParams.eventDispatcher,
|
|
301
295
|
syncBlockStore: syncBlockStore
|
|
302
296
|
}).init(),
|
|
303
|
-
bodiedSyncBlock:
|
|
297
|
+
bodiedSyncBlock: editorExperiment('platform_synced_block_use_new_source_nodeview', true, {
|
|
304
298
|
exposure: true
|
|
305
299
|
}) ? bodiedSyncBlockNodeView({
|
|
306
300
|
pluginOptions: options,
|
|
@@ -312,10 +306,6 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
312
306
|
pmPluginFactoryParams,
|
|
313
307
|
api,
|
|
314
308
|
syncBlockStore
|
|
315
|
-
}) : lazyBodiedSyncBlockView({
|
|
316
|
-
pluginOptions: options,
|
|
317
|
-
pmPluginFactoryParams,
|
|
318
|
-
api
|
|
319
309
|
})
|
|
320
310
|
},
|
|
321
311
|
decorations: state => {
|
|
@@ -328,7 +318,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
328
318
|
} = state;
|
|
329
319
|
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);
|
|
330
320
|
const isViewMode = (api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : (_api$editorViewMode$s = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode$s === void 0 ? void 0 : _api$editorViewMode$s.mode) === 'view';
|
|
331
|
-
const isDragging =
|
|
321
|
+
const isDragging = (api === null || api === void 0 ? void 0 : (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : (_api$userIntent$share = _api$userIntent.sharedState.currentState()) === null || _api$userIntent$share === void 0 ? void 0 : _api$userIntent$share.currentUserIntent) === 'dragging';
|
|
332
322
|
const offlineDecorations = [];
|
|
333
323
|
const viewModeDecorations = [];
|
|
334
324
|
const loadingDecorations = [];
|
|
@@ -351,7 +341,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
351
341
|
}
|
|
352
342
|
|
|
353
343
|
// Show sync block border while the user is dragging
|
|
354
|
-
if (isDragging && (node.type.name === 'bodiedSyncBlock' || node.type.name === 'syncBlock')
|
|
344
|
+
if (isDragging && (node.type.name === 'bodiedSyncBlock' || node.type.name === 'syncBlock')) {
|
|
355
345
|
dragDecorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
356
346
|
class: SyncBlockStateCssClassName.draggingClassName
|
|
357
347
|
}));
|
|
@@ -377,11 +367,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
377
367
|
return shouldIgnoreDomEvent(view, event, api);
|
|
378
368
|
},
|
|
379
369
|
copy: () => {
|
|
380
|
-
|
|
381
|
-
ctx.markCopyEvent();
|
|
382
|
-
} else {
|
|
383
|
-
isCopyEvent = true;
|
|
384
|
-
}
|
|
370
|
+
ctx.markCopyEvent();
|
|
385
371
|
return false;
|
|
386
372
|
}
|
|
387
373
|
},
|
|
@@ -393,10 +379,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
393
379
|
const {
|
|
394
380
|
schema
|
|
395
381
|
} = state;
|
|
396
|
-
const isCopy = ctx
|
|
397
|
-
if (!ctx) {
|
|
398
|
-
isCopyEvent = false;
|
|
399
|
-
}
|
|
382
|
+
const isCopy = ctx.consumeCopyEvent();
|
|
400
383
|
if (!syncBlockStore || !isCopy) {
|
|
401
384
|
return slice;
|
|
402
385
|
}
|
|
@@ -453,100 +436,23 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
453
436
|
removed: bodiedSyncBlockRemoved,
|
|
454
437
|
added: bodiedSyncBlockAdded
|
|
455
438
|
} = trackSyncBlocks(syncBlockStore.sourceManager.isSourceBlock, tr, state);
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
});
|
|
474
|
-
}
|
|
475
|
-
if (!isOffline) {
|
|
476
|
-
const {
|
|
477
|
-
removed: syncBlockRemoved,
|
|
478
|
-
added: syncBlockAdded
|
|
479
|
-
} = trackSyncBlocks(node => node.type.name === 'syncBlock', tr, state);
|
|
480
|
-
syncBlockRemoved.forEach(syncBlock => {
|
|
481
|
-
var _api$analytics3, _api$analytics3$actio;
|
|
482
|
-
api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : (_api$analytics3$actio = _api$analytics3.actions) === null || _api$analytics3$actio === void 0 ? void 0 : _api$analytics3$actio.fireAnalyticsEvent({
|
|
483
|
-
action: ACTION.DELETED,
|
|
484
|
-
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
485
|
-
actionSubjectId: ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_DELETE,
|
|
486
|
-
attributes: {
|
|
487
|
-
resourceId: syncBlock.attrs.resourceId,
|
|
488
|
-
blockInstanceId: syncBlock.attrs.localId
|
|
489
|
-
},
|
|
490
|
-
eventType: EVENT_TYPE.OPERATIONAL
|
|
491
|
-
});
|
|
492
|
-
});
|
|
493
|
-
syncBlockAdded.forEach(syncBlock => {
|
|
494
|
-
var _api$analytics4, _api$analytics4$actio;
|
|
495
|
-
api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : (_api$analytics4$actio = _api$analytics4.actions) === null || _api$analytics4$actio === void 0 ? void 0 : _api$analytics4$actio.fireAnalyticsEvent({
|
|
496
|
-
action: ACTION.INSERTED,
|
|
497
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
498
|
-
actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK,
|
|
499
|
-
attributes: {
|
|
500
|
-
resourceId: syncBlock.attrs.resourceId,
|
|
501
|
-
blockInstanceId: syncBlock.attrs.localId
|
|
502
|
-
},
|
|
503
|
-
eventType: EVENT_TYPE.TRACK
|
|
504
|
-
});
|
|
505
|
-
});
|
|
506
|
-
if (bodiedSyncBlockRemoved.length > 0) {
|
|
507
|
-
confirmationTransactionRef.current = tr;
|
|
508
|
-
return handleBodiedSyncBlockRemoval(bodiedSyncBlockRemoved, syncBlockStore, api, confirmationTransactionRef, getDeleteReason(tr));
|
|
509
|
-
}
|
|
510
|
-
if (bodiedSyncBlockAdded.length > 0) {
|
|
511
|
-
if (tr.getMeta(pmHistoryPluginKey)) {
|
|
512
|
-
// We don't allow bodiedSyncBlock creation via redo, however, we need to return true here to let transaction through so history can be updated properly.
|
|
513
|
-
// If we simply returns false, creation from redo is blocked as desired, but this results in editor showing redo as possible even though it's not.
|
|
514
|
-
// After true is returned here and the node is created, we delete the node in the filterTransaction immediately, which cancels out the creation
|
|
515
|
-
return true;
|
|
516
|
-
}
|
|
517
|
-
handleBodiedSyncBlockCreation(bodiedSyncBlockAdded, state, api);
|
|
518
|
-
return true;
|
|
519
|
-
}
|
|
520
|
-
showExtensionInSyncBlockWarningIfNeeded(tr, state, api, extensionFlagShown);
|
|
521
|
-
return true;
|
|
522
|
-
}
|
|
523
|
-
const {
|
|
524
|
-
removed: syncBlockRemoved,
|
|
525
|
-
added: syncBlockAdded
|
|
526
|
-
} = trackSyncBlocks(node => node.type.name === 'syncBlock', tr, state);
|
|
527
|
-
let errorFlag = false;
|
|
528
|
-
|
|
529
|
-
// Disable (bodied)syncBlock node deletion/creation/edition in offline mode and trigger an error flag instead
|
|
530
|
-
if (isConfirmedSyncBlockDeletion || bodiedSyncBlockRemoved.length > 0 || syncBlockRemoved.length > 0) {
|
|
531
|
-
errorFlag = FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE;
|
|
532
|
-
} else if (bodiedSyncBlockAdded.length > 0 || syncBlockAdded.length > 0) {
|
|
533
|
-
errorFlag = FLAG_ID.CANNOT_CREATE_WHEN_OFFLINE;
|
|
534
|
-
} else if (hasEditInSyncBlock(tr, state)) {
|
|
535
|
-
errorFlag = FLAG_ID.CANNOT_EDIT_WHEN_OFFLINE;
|
|
536
|
-
}
|
|
537
|
-
if (errorFlag) {
|
|
538
|
-
deferDispatch(() => {
|
|
539
|
-
api === null || api === void 0 ? void 0 : api.core.actions.execute(({
|
|
540
|
-
tr
|
|
541
|
-
}) => tr.setMeta(syncedBlockPluginKey, {
|
|
542
|
-
activeFlag: {
|
|
543
|
-
id: errorFlag
|
|
544
|
-
}
|
|
545
|
-
}));
|
|
546
|
-
});
|
|
547
|
-
return false;
|
|
548
|
-
}
|
|
549
|
-
return true;
|
|
439
|
+
return isOffline ? filterTransactionOffline({
|
|
440
|
+
tr,
|
|
441
|
+
state,
|
|
442
|
+
api,
|
|
443
|
+
isConfirmedSyncBlockDeletion,
|
|
444
|
+
bodiedSyncBlockRemoved,
|
|
445
|
+
bodiedSyncBlockAdded
|
|
446
|
+
}) : filterTransactionOnline({
|
|
447
|
+
tr,
|
|
448
|
+
state,
|
|
449
|
+
syncBlockStore,
|
|
450
|
+
api,
|
|
451
|
+
confirmationTransactionRef,
|
|
452
|
+
bodiedSyncBlockRemoved,
|
|
453
|
+
bodiedSyncBlockAdded,
|
|
454
|
+
extensionFlagShown
|
|
455
|
+
});
|
|
550
456
|
},
|
|
551
457
|
appendTransaction: (trs, oldState, newState) => {
|
|
552
458
|
trs.filter(tr => tr.docChanged).forEach(tr => {
|
|
@@ -2,7 +2,6 @@ import { expandSelectionToBlockRange } from '@atlaskit/editor-common/selection';
|
|
|
2
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
4
4
|
import { findParentNodeOfType, findParentNodeOfTypeClosestToPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -10,11 +9,7 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
|
10
9
|
* Used to avoid re-entrant ProseMirror dispatch cycles.
|
|
11
10
|
*/
|
|
12
11
|
export const deferDispatch = fn => {
|
|
13
|
-
|
|
14
|
-
queueMicrotask(fn);
|
|
15
|
-
} else {
|
|
16
|
-
setTimeout(fn, 0);
|
|
17
|
-
}
|
|
12
|
+
queueMicrotask(fn);
|
|
18
13
|
};
|
|
19
14
|
export const findSyncBlock = (schema, selection) => {
|
|
20
15
|
const {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { syncBlock, bodiedSyncBlock } from '@atlaskit/adf-schema';
|
|
3
3
|
import { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
6
5
|
import { flushBodiedSyncBlocks, flushSyncBlocks } from './editor-actions';
|
|
7
6
|
import { copySyncedBlockReferenceToClipboardEditorCommand, createSyncedBlock } from './editor-commands';
|
|
@@ -117,7 +116,7 @@ export const syncedBlockPlugin = ({
|
|
|
117
116
|
syncBlockStore: currentSyncBlockStore,
|
|
118
117
|
bodiedSyncBlockDeletionStatus,
|
|
119
118
|
retryCreationPosMap,
|
|
120
|
-
hasUnsavedBodiedSyncBlockChanges
|
|
119
|
+
hasUnsavedBodiedSyncBlockChanges
|
|
121
120
|
};
|
|
122
121
|
}
|
|
123
122
|
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
3
3
|
import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
4
|
-
export const SYNC_BLOCK_FETCH_INTERVAL = 3000;
|
|
5
|
-
|
|
6
4
|
// Component that manages synced block data synchronization.
|
|
7
5
|
// Uses provider-based GraphQL subscriptions for updates when online.
|
|
8
6
|
// Falls back to polling at regular intervals when offline.
|
|
@@ -23,19 +21,5 @@ export const SyncBlockRefresher = ({
|
|
|
23
21
|
const useRealTimeSubscriptions = isOnline;
|
|
24
22
|
syncBlockStoreManager.referenceManager.setRealTimeSubscriptionsEnabled(useRealTimeSubscriptions);
|
|
25
23
|
}, [syncBlockStoreManager, isOnline]);
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
if (isOnline) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
const interval = window.setInterval(() => {
|
|
31
|
-
var _document;
|
|
32
|
-
if (((_document = document) === null || _document === void 0 ? void 0 : _document.visibilityState) === 'visible') {
|
|
33
|
-
syncBlockStoreManager.referenceManager.refreshSubscriptions();
|
|
34
|
-
}
|
|
35
|
-
}, SYNC_BLOCK_FETCH_INTERVAL);
|
|
36
|
-
return () => {
|
|
37
|
-
window.clearInterval(interval);
|
|
38
|
-
};
|
|
39
|
-
}, [syncBlockStoreManager, isOnline]);
|
|
40
24
|
return null;
|
|
41
25
|
};
|
|
@@ -12,7 +12,6 @@ import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
|
12
12
|
import { BodiedSyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
|
|
13
13
|
import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
14
14
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
15
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
15
|
import { BodiedSyncBlockWrapper } from '../ui/BodiedSyncBlockWrapper';
|
|
17
16
|
import { SyncBlockLabel } from '../ui/SyncBlockLabel';
|
|
18
17
|
var toDOMOld = function toDOMOld() {
|
|
@@ -110,7 +109,7 @@ var BodiedSyncBlockOld = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
110
109
|
dom = _DOMSerializer$render.dom,
|
|
111
110
|
contentDOM = _DOMSerializer$render.contentDOM;
|
|
112
111
|
// In SSR, the first check won't work, so fallback to nodeType check
|
|
113
|
-
if (dom instanceof HTMLElement || dom.nodeType === 1
|
|
112
|
+
if (dom instanceof HTMLElement || dom.nodeType === 1) {
|
|
114
113
|
this.updateContentEditable({
|
|
115
114
|
contentDOM: contentDOM
|
|
116
115
|
});
|
|
@@ -16,9 +16,7 @@ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
|
16
16
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
17
17
|
import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
18
18
|
import { convertPMNodesToSyncBlockNodes, rebaseTransaction } from '@atlaskit/editor-synced-block-provider';
|
|
19
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
20
19
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
21
|
-
import { lazyBodiedSyncBlockView } from '../nodeviews/bodiedLazySyncedBlock';
|
|
22
20
|
import { bodiedSyncBlockNodeView, bodiedSyncBlockNodeViewOld } from '../nodeviews/bodiedSyncedBlock';
|
|
23
21
|
import { SyncBlock as SyncBlockView } from '../nodeviews/syncedBlock';
|
|
24
22
|
import { FLAG_ID } from '../types';
|
|
@@ -233,17 +231,13 @@ var SyncedBlockPluginContext = /*#__PURE__*/function () {
|
|
|
233
231
|
}]);
|
|
234
232
|
}();
|
|
235
233
|
export var createPlugin = function createPlugin(options, pmPluginFactoryParams, syncBlockStore, api) {
|
|
236
|
-
var _ctx$confirmationTran, _ctx$unpublishedFlagS, _ctx$extensionFlagSho;
|
|
237
234
|
var _ref6 = options || {},
|
|
238
235
|
_ref6$useLongPressSel = _ref6.useLongPressSelection,
|
|
239
236
|
useLongPressSelection = _ref6$useLongPressSel === void 0 ? false : _ref6$useLongPressSel;
|
|
240
|
-
var ctx =
|
|
241
|
-
var confirmationTransactionRef =
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
var isCopyEvent = false;
|
|
245
|
-
var unpublishedFlagShown = (_ctx$unpublishedFlagS = ctx === null || ctx === void 0 ? void 0 : ctx.unpublishedFlagShown) !== null && _ctx$unpublishedFlagS !== void 0 ? _ctx$unpublishedFlagS : new Set();
|
|
246
|
-
var extensionFlagShown = (_ctx$extensionFlagSho = ctx === null || ctx === void 0 ? void 0 : ctx.extensionFlagShown) !== null && _ctx$extensionFlagSho !== void 0 ? _ctx$extensionFlagSho : new Set();
|
|
237
|
+
var ctx = new SyncedBlockPluginContext();
|
|
238
|
+
var confirmationTransactionRef = ctx.confirmationTransactionRef;
|
|
239
|
+
var unpublishedFlagShown = ctx.unpublishedFlagShown;
|
|
240
|
+
var extensionFlagShown = ctx.extensionFlagShown;
|
|
247
241
|
|
|
248
242
|
// Set up callback to detect unpublished sync blocks when they're fetched
|
|
249
243
|
syncBlockStore.referenceManager.setOnUnpublishedSyncBlockDetected(function (resourceId) {
|
|
@@ -275,7 +269,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
275
269
|
activeFlag: false,
|
|
276
270
|
syncBlockStore: syncBlockStore,
|
|
277
271
|
retryCreationPosMap: new Map(),
|
|
278
|
-
hasUnsavedBodiedSyncBlockChanges:
|
|
272
|
+
hasUnsavedBodiedSyncBlockChanges: syncBlockStore.sourceManager.hasUnsavedChanges()
|
|
279
273
|
};
|
|
280
274
|
},
|
|
281
275
|
apply: function apply(tr, currentPluginState, oldEditorState) {
|
|
@@ -285,11 +279,11 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
285
279
|
selectionDecorationSet = currentPluginState.selectionDecorationSet,
|
|
286
280
|
bodiedSyncBlockDeletionStatus = currentPluginState.bodiedSyncBlockDeletionStatus,
|
|
287
281
|
retryCreationPosMap = currentPluginState.retryCreationPosMap;
|
|
288
|
-
var newDecorationSet =
|
|
289
|
-
: selectionDecorationSet
|
|
282
|
+
var newDecorationSet = tr.docChanged ? selectionDecorationSet.map(tr.mapping, tr.doc) // only map if document changed
|
|
283
|
+
: selectionDecorationSet;
|
|
290
284
|
if (!tr.selection.eq(oldEditorState.selection)) {
|
|
291
285
|
newDecorationSet = calculateDecorations(tr.doc, tr.selection, tr.doc.type.schema);
|
|
292
|
-
} else if (tr.docChanged
|
|
286
|
+
} else if (tr.docChanged) {
|
|
293
287
|
var existingDecorationsLength = selectionDecorationSet.find().length;
|
|
294
288
|
var newDecorationsLength = newDecorationSet.find().length;
|
|
295
289
|
|
|
@@ -308,7 +302,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
308
302
|
syncBlockStore: syncBlockStore,
|
|
309
303
|
retryCreationPosMap: newRetryCreationPosMap,
|
|
310
304
|
bodiedSyncBlockDeletionStatus: (_meta$bodiedSyncBlock = meta === null || meta === void 0 ? void 0 : meta.bodiedSyncBlockDeletionStatus) !== null && _meta$bodiedSyncBlock !== void 0 ? _meta$bodiedSyncBlock : bodiedSyncBlockDeletionStatus,
|
|
311
|
-
hasUnsavedBodiedSyncBlockChanges:
|
|
305
|
+
hasUnsavedBodiedSyncBlockChanges: syncBlockStore.sourceManager.hasUnsavedChanges()
|
|
312
306
|
};
|
|
313
307
|
}
|
|
314
308
|
},
|
|
@@ -332,7 +326,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
332
326
|
}).init()
|
|
333
327
|
);
|
|
334
328
|
},
|
|
335
|
-
bodiedSyncBlock:
|
|
329
|
+
bodiedSyncBlock: editorExperiment('platform_synced_block_use_new_source_nodeview', true, {
|
|
336
330
|
exposure: true
|
|
337
331
|
}) ? bodiedSyncBlockNodeView({
|
|
338
332
|
pluginOptions: options,
|
|
@@ -344,10 +338,6 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
344
338
|
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
345
339
|
api: api,
|
|
346
340
|
syncBlockStore: syncBlockStore
|
|
347
|
-
}) : lazyBodiedSyncBlockView({
|
|
348
|
-
pluginOptions: options,
|
|
349
|
-
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
350
|
-
api: api
|
|
351
341
|
})
|
|
352
342
|
},
|
|
353
343
|
decorations: function decorations(state) {
|
|
@@ -358,7 +348,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
358
348
|
var doc = state.doc;
|
|
359
349
|
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);
|
|
360
350
|
var isViewMode = (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'view';
|
|
361
|
-
var isDragging =
|
|
351
|
+
var isDragging = (api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || (_api$userIntent = _api$userIntent.sharedState.currentState()) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.currentUserIntent) === 'dragging';
|
|
362
352
|
var offlineDecorations = [];
|
|
363
353
|
var viewModeDecorations = [];
|
|
364
354
|
var loadingDecorations = [];
|
|
@@ -381,7 +371,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
381
371
|
}
|
|
382
372
|
|
|
383
373
|
// Show sync block border while the user is dragging
|
|
384
|
-
if (isDragging && (node.type.name === 'bodiedSyncBlock' || node.type.name === 'syncBlock')
|
|
374
|
+
if (isDragging && (node.type.name === 'bodiedSyncBlock' || node.type.name === 'syncBlock')) {
|
|
385
375
|
dragDecorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
386
376
|
class: SyncBlockStateCssClassName.draggingClassName
|
|
387
377
|
}));
|
|
@@ -409,11 +399,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
409
399
|
return shouldIgnoreDomEvent(view, event, api);
|
|
410
400
|
},
|
|
411
401
|
copy: function copy() {
|
|
412
|
-
|
|
413
|
-
ctx.markCopyEvent();
|
|
414
|
-
} else {
|
|
415
|
-
isCopyEvent = true;
|
|
416
|
-
}
|
|
402
|
+
ctx.markCopyEvent();
|
|
417
403
|
return false;
|
|
418
404
|
}
|
|
419
405
|
},
|
|
@@ -422,10 +408,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
422
408
|
var pluginState = syncedBlockPluginKey.getState(state);
|
|
423
409
|
var syncBlockStore = pluginState === null || pluginState === void 0 ? void 0 : pluginState.syncBlockStore;
|
|
424
410
|
var schema = state.schema;
|
|
425
|
-
var isCopy = ctx
|
|
426
|
-
if (!ctx) {
|
|
427
|
-
isCopyEvent = false;
|
|
428
|
-
}
|
|
411
|
+
var isCopy = ctx.consumeCopyEvent();
|
|
429
412
|
if (!syncBlockStore || !isCopy) {
|
|
430
413
|
return slice;
|
|
431
414
|
}
|
|
@@ -481,103 +464,23 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
481
464
|
var _trackSyncBlocks4 = trackSyncBlocks(syncBlockStore.sourceManager.isSourceBlock, tr, state),
|
|
482
465
|
bodiedSyncBlockRemoved = _trackSyncBlocks4.removed,
|
|
483
466
|
bodiedSyncBlockAdded = _trackSyncBlocks4.added;
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
});
|
|
502
|
-
}
|
|
503
|
-
if (!isOffline) {
|
|
504
|
-
var _trackSyncBlocks5 = trackSyncBlocks(function (node) {
|
|
505
|
-
return node.type.name === 'syncBlock';
|
|
506
|
-
}, tr, state),
|
|
507
|
-
_syncBlockRemoved = _trackSyncBlocks5.removed,
|
|
508
|
-
_syncBlockAdded = _trackSyncBlocks5.added;
|
|
509
|
-
_syncBlockRemoved.forEach(function (syncBlock) {
|
|
510
|
-
var _api$analytics3;
|
|
511
|
-
api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 || (_api$analytics3 = _api$analytics3.actions) === null || _api$analytics3 === void 0 || _api$analytics3.fireAnalyticsEvent({
|
|
512
|
-
action: ACTION.DELETED,
|
|
513
|
-
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
514
|
-
actionSubjectId: ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_DELETE,
|
|
515
|
-
attributes: {
|
|
516
|
-
resourceId: syncBlock.attrs.resourceId,
|
|
517
|
-
blockInstanceId: syncBlock.attrs.localId
|
|
518
|
-
},
|
|
519
|
-
eventType: EVENT_TYPE.OPERATIONAL
|
|
520
|
-
});
|
|
521
|
-
});
|
|
522
|
-
_syncBlockAdded.forEach(function (syncBlock) {
|
|
523
|
-
var _api$analytics4;
|
|
524
|
-
api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 || (_api$analytics4 = _api$analytics4.actions) === null || _api$analytics4 === void 0 || _api$analytics4.fireAnalyticsEvent({
|
|
525
|
-
action: ACTION.INSERTED,
|
|
526
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
527
|
-
actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK,
|
|
528
|
-
attributes: {
|
|
529
|
-
resourceId: syncBlock.attrs.resourceId,
|
|
530
|
-
blockInstanceId: syncBlock.attrs.localId
|
|
531
|
-
},
|
|
532
|
-
eventType: EVENT_TYPE.TRACK
|
|
533
|
-
});
|
|
534
|
-
});
|
|
535
|
-
if (bodiedSyncBlockRemoved.length > 0) {
|
|
536
|
-
confirmationTransactionRef.current = tr;
|
|
537
|
-
return handleBodiedSyncBlockRemoval(bodiedSyncBlockRemoved, syncBlockStore, api, confirmationTransactionRef, getDeleteReason(tr));
|
|
538
|
-
}
|
|
539
|
-
if (bodiedSyncBlockAdded.length > 0) {
|
|
540
|
-
if (tr.getMeta(pmHistoryPluginKey)) {
|
|
541
|
-
// We don't allow bodiedSyncBlock creation via redo, however, we need to return true here to let transaction through so history can be updated properly.
|
|
542
|
-
// If we simply returns false, creation from redo is blocked as desired, but this results in editor showing redo as possible even though it's not.
|
|
543
|
-
// After true is returned here and the node is created, we delete the node in the filterTransaction immediately, which cancels out the creation
|
|
544
|
-
return true;
|
|
545
|
-
}
|
|
546
|
-
handleBodiedSyncBlockCreation(bodiedSyncBlockAdded, state, api);
|
|
547
|
-
return true;
|
|
548
|
-
}
|
|
549
|
-
showExtensionInSyncBlockWarningIfNeeded(tr, state, api, extensionFlagShown);
|
|
550
|
-
return true;
|
|
551
|
-
}
|
|
552
|
-
var _trackSyncBlocks6 = trackSyncBlocks(function (node) {
|
|
553
|
-
return node.type.name === 'syncBlock';
|
|
554
|
-
}, tr, state),
|
|
555
|
-
syncBlockRemoved = _trackSyncBlocks6.removed,
|
|
556
|
-
syncBlockAdded = _trackSyncBlocks6.added;
|
|
557
|
-
var errorFlag = false;
|
|
558
|
-
|
|
559
|
-
// Disable (bodied)syncBlock node deletion/creation/edition in offline mode and trigger an error flag instead
|
|
560
|
-
if (isConfirmedSyncBlockDeletion || bodiedSyncBlockRemoved.length > 0 || syncBlockRemoved.length > 0) {
|
|
561
|
-
errorFlag = FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE;
|
|
562
|
-
} else if (bodiedSyncBlockAdded.length > 0 || syncBlockAdded.length > 0) {
|
|
563
|
-
errorFlag = FLAG_ID.CANNOT_CREATE_WHEN_OFFLINE;
|
|
564
|
-
} else if (hasEditInSyncBlock(tr, state)) {
|
|
565
|
-
errorFlag = FLAG_ID.CANNOT_EDIT_WHEN_OFFLINE;
|
|
566
|
-
}
|
|
567
|
-
if (errorFlag) {
|
|
568
|
-
deferDispatch(function () {
|
|
569
|
-
api === null || api === void 0 || api.core.actions.execute(function (_ref9) {
|
|
570
|
-
var tr = _ref9.tr;
|
|
571
|
-
return tr.setMeta(syncedBlockPluginKey, {
|
|
572
|
-
activeFlag: {
|
|
573
|
-
id: errorFlag
|
|
574
|
-
}
|
|
575
|
-
});
|
|
576
|
-
});
|
|
577
|
-
});
|
|
578
|
-
return false;
|
|
579
|
-
}
|
|
580
|
-
return true;
|
|
467
|
+
return isOffline ? filterTransactionOffline({
|
|
468
|
+
tr: tr,
|
|
469
|
+
state: state,
|
|
470
|
+
api: api,
|
|
471
|
+
isConfirmedSyncBlockDeletion: isConfirmedSyncBlockDeletion,
|
|
472
|
+
bodiedSyncBlockRemoved: bodiedSyncBlockRemoved,
|
|
473
|
+
bodiedSyncBlockAdded: bodiedSyncBlockAdded
|
|
474
|
+
}) : filterTransactionOnline({
|
|
475
|
+
tr: tr,
|
|
476
|
+
state: state,
|
|
477
|
+
syncBlockStore: syncBlockStore,
|
|
478
|
+
api: api,
|
|
479
|
+
confirmationTransactionRef: confirmationTransactionRef,
|
|
480
|
+
bodiedSyncBlockRemoved: bodiedSyncBlockRemoved,
|
|
481
|
+
bodiedSyncBlockAdded: bodiedSyncBlockAdded,
|
|
482
|
+
extensionFlagShown: extensionFlagShown
|
|
483
|
+
});
|
|
581
484
|
},
|
|
582
485
|
appendTransaction: function appendTransaction(trs, oldState, newState) {
|
|
583
486
|
trs.filter(function (tr) {
|
|
@@ -593,8 +496,8 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
593
496
|
var _loop = function _loop() {
|
|
594
497
|
var tr = _step2.value;
|
|
595
498
|
if (tr.getMeta(pmHistoryPluginKey)) {
|
|
596
|
-
var
|
|
597
|
-
added =
|
|
499
|
+
var _trackSyncBlocks5 = trackSyncBlocks(syncBlockStore.sourceManager.isSourceBlock, tr, oldState),
|
|
500
|
+
added = _trackSyncBlocks5.added;
|
|
598
501
|
if (added.length > 0) {
|
|
599
502
|
// Delete bodiedSyncBlock if it's originated from history, i.e. redo creation
|
|
600
503
|
// See filterTransaction above for more details
|
|
@@ -2,7 +2,6 @@ import { expandSelectionToBlockRange } from '@atlaskit/editor-common/selection';
|
|
|
2
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
4
4
|
import { findParentNodeOfType, findParentNodeOfTypeClosestToPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -10,11 +9,7 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
|
10
9
|
* Used to avoid re-entrant ProseMirror dispatch cycles.
|
|
11
10
|
*/
|
|
12
11
|
export var deferDispatch = function deferDispatch(fn) {
|
|
13
|
-
|
|
14
|
-
queueMicrotask(fn);
|
|
15
|
-
} else {
|
|
16
|
-
setTimeout(fn, 0);
|
|
17
|
-
}
|
|
12
|
+
queueMicrotask(fn);
|
|
18
13
|
};
|
|
19
14
|
export var findSyncBlock = function findSyncBlock(schema, selection) {
|
|
20
15
|
var syncBlock = schema.nodes.syncBlock;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { syncBlock, bodiedSyncBlock } from '@atlaskit/adf-schema';
|
|
3
3
|
import { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
6
5
|
import { flushBodiedSyncBlocks as _flushBodiedSyncBlocks, flushSyncBlocks } from './editor-actions';
|
|
7
6
|
import { copySyncedBlockReferenceToClipboardEditorCommand, createSyncedBlock } from './editor-commands';
|
|
@@ -123,7 +122,7 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
|
|
|
123
122
|
syncBlockStore: currentSyncBlockStore,
|
|
124
123
|
bodiedSyncBlockDeletionStatus: bodiedSyncBlockDeletionStatus,
|
|
125
124
|
retryCreationPosMap: retryCreationPosMap,
|
|
126
|
-
hasUnsavedBodiedSyncBlockChanges:
|
|
125
|
+
hasUnsavedBodiedSyncBlockChanges: hasUnsavedBodiedSyncBlockChanges
|
|
127
126
|
};
|
|
128
127
|
}
|
|
129
128
|
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
3
3
|
import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
4
|
-
export var SYNC_BLOCK_FETCH_INTERVAL = 3000;
|
|
5
|
-
|
|
6
4
|
// Component that manages synced block data synchronization.
|
|
7
5
|
// Uses provider-based GraphQL subscriptions for updates when online.
|
|
8
6
|
// Falls back to polling at regular intervals when offline.
|
|
@@ -21,19 +19,5 @@ export var SyncBlockRefresher = function SyncBlockRefresher(_ref) {
|
|
|
21
19
|
var useRealTimeSubscriptions = isOnline;
|
|
22
20
|
syncBlockStoreManager.referenceManager.setRealTimeSubscriptionsEnabled(useRealTimeSubscriptions);
|
|
23
21
|
}, [syncBlockStoreManager, isOnline]);
|
|
24
|
-
useEffect(function () {
|
|
25
|
-
if (isOnline) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
var interval = window.setInterval(function () {
|
|
29
|
-
var _document;
|
|
30
|
-
if (((_document = document) === null || _document === void 0 ? void 0 : _document.visibilityState) === 'visible') {
|
|
31
|
-
syncBlockStoreManager.referenceManager.refreshSubscriptions();
|
|
32
|
-
}
|
|
33
|
-
}, SYNC_BLOCK_FETCH_INTERVAL);
|
|
34
|
-
return function () {
|
|
35
|
-
window.clearInterval(interval);
|
|
36
|
-
};
|
|
37
|
-
}, [syncBlockStoreManager, isOnline]);
|
|
38
22
|
return null;
|
|
39
23
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
3
3
|
import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
|
|
4
|
-
export declare const SYNC_BLOCK_FETCH_INTERVAL = 3000;
|
|
5
4
|
export declare const SyncBlockRefresher: ({ syncBlockStoreManager, api, }: {
|
|
6
5
|
api?: ExtractInjectionAPI<SyncedBlockPlugin>;
|
|
7
6
|
syncBlockStoreManager: SyncBlockStoreManager;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
3
3
|
import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
|
|
4
|
-
export declare const SYNC_BLOCK_FETCH_INTERVAL = 3000;
|
|
5
4
|
export declare const SyncBlockRefresher: ({ syncBlockStoreManager, api, }: {
|
|
6
5
|
api?: ExtractInjectionAPI<SyncedBlockPlugin>;
|
|
7
6
|
syncBlockStoreManager: SyncBlockStoreManager;
|
package/docs/0-intro.tsx
CHANGED
|
@@ -5,7 +5,8 @@ import { AtlassianInternalWarning, code, md } from '@atlaskit/docs';
|
|
|
5
5
|
import { createEditorUseOnlyNotice } from '@atlaskit/editor-common/doc-utils';
|
|
6
6
|
import { token } from '@atlaskit/tokens';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- md template from @atlaskit/docs
|
|
9
|
+
const _default_1: any = md`
|
|
9
10
|
|
|
10
11
|
${createEditorUseOnlyNotice('Editor Plugin Synced Block', [
|
|
11
12
|
{ name: 'Editor Core', link: '/packages/editor/editor-core' },
|
|
@@ -41,3 +42,4 @@ For internal Atlassian, visit the slack channel [#help-editor](https://atlassian
|
|
|
41
42
|
---
|
|
42
43
|
Please see [Atlassian Frontend - License](https://hello.atlassian.net/wiki/spaces/AF/pages/2589099144/Documentation#License) for more licensing information.
|
|
43
44
|
`;
|
|
45
|
+
export default _default_1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-synced-block",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.15",
|
|
4
4
|
"description": "SyncedBlock plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"atlaskit:src": "src/index.ts",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/adf-schema": "^52.4.0",
|
|
32
|
-
"@atlaskit/button": "23.10.
|
|
33
|
-
"@atlaskit/dropdown-menu": "16.7.
|
|
32
|
+
"@atlaskit/button": "23.10.4",
|
|
33
|
+
"@atlaskit/dropdown-menu": "16.7.2",
|
|
34
34
|
"@atlaskit/editor-json-transformer": "^8.31.0",
|
|
35
35
|
"@atlaskit/editor-plugin-analytics": "^8.0.0",
|
|
36
36
|
"@atlaskit/editor-plugin-block-menu": "^7.0.0",
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
55
55
|
"@atlaskit/primitives": "^18.0.0",
|
|
56
56
|
"@atlaskit/spinner": "19.0.11",
|
|
57
|
-
"@atlaskit/tmp-editor-statsig": "^40.
|
|
57
|
+
"@atlaskit/tmp-editor-statsig": "^40.7.0",
|
|
58
58
|
"@atlaskit/tokens": "11.1.1",
|
|
59
|
-
"@atlaskit/tooltip": "^
|
|
59
|
+
"@atlaskit/tooltip": "^21.0.0",
|
|
60
60
|
"@atlaskit/visually-hidden": "^3.0.0",
|
|
61
61
|
"@babel/runtime": "^7.0.0",
|
|
62
62
|
"@compiled/react": "^0.20.0",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"@atlaskit/editor-common": "^112.
|
|
68
|
+
"@atlaskit/editor-common": "^112.6.0",
|
|
69
69
|
"react": "^18.2.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
@@ -108,9 +108,6 @@
|
|
|
108
108
|
}
|
|
109
109
|
},
|
|
110
110
|
"platform-feature-flags": {
|
|
111
|
-
"platform_synced_block_patch_5": {
|
|
112
|
-
"type": "boolean"
|
|
113
|
-
},
|
|
114
111
|
"platform_editor_block_menu_v2_patch_3": {
|
|
115
112
|
"type": "boolean"
|
|
116
113
|
},
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.lazyBodiedSyncBlockView = void 0;
|
|
8
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
|
-
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
10
|
-
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" != (0, _typeof2.default)(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); }
|
|
11
|
-
// Delete this file when cleaning up platform_synced_block_patch_5
|
|
12
|
-
var lazyBodiedSyncBlockView = exports.lazyBodiedSyncBlockView = function lazyBodiedSyncBlockView(props) {
|
|
13
|
-
return (0, _lazyNodeView.withLazyLoading)({
|
|
14
|
-
nodeName: 'bodiedSyncBlock',
|
|
15
|
-
getNodeViewOptions: function getNodeViewOptions() {},
|
|
16
|
-
loader: function loader() {
|
|
17
|
-
var result = Promise.resolve().then(function () {
|
|
18
|
-
return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_editor-plugin-bodied-synced-block-nodeview" */
|
|
19
|
-
'./bodiedSyncedBlock'));
|
|
20
|
-
}).then(function (_ref) {
|
|
21
|
-
var bodiedSyncBlockNodeView = _ref.bodiedSyncBlockNodeView;
|
|
22
|
-
return bodiedSyncBlockNodeView(props);
|
|
23
|
-
});
|
|
24
|
-
return result;
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { withLazyLoading } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
|
-
// Delete this file when cleaning up platform_synced_block_patch_5
|
|
3
|
-
export const lazyBodiedSyncBlockView = props => {
|
|
4
|
-
return withLazyLoading({
|
|
5
|
-
nodeName: 'bodiedSyncBlock',
|
|
6
|
-
getNodeViewOptions: () => {},
|
|
7
|
-
loader: () => {
|
|
8
|
-
const result = import( /* webpackChunkName: "@atlaskit-internal_editor-plugin-bodied-synced-block-nodeview" */
|
|
9
|
-
'./bodiedSyncedBlock').then(({
|
|
10
|
-
bodiedSyncBlockNodeView
|
|
11
|
-
}) => {
|
|
12
|
-
return bodiedSyncBlockNodeView(props);
|
|
13
|
-
});
|
|
14
|
-
return result;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { withLazyLoading } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
|
-
// Delete this file when cleaning up platform_synced_block_patch_5
|
|
3
|
-
export var lazyBodiedSyncBlockView = function lazyBodiedSyncBlockView(props) {
|
|
4
|
-
return withLazyLoading({
|
|
5
|
-
nodeName: 'bodiedSyncBlock',
|
|
6
|
-
getNodeViewOptions: function getNodeViewOptions() {},
|
|
7
|
-
loader: function loader() {
|
|
8
|
-
var result = import( /* webpackChunkName: "@atlaskit-internal_editor-plugin-bodied-synced-block-nodeview" */
|
|
9
|
-
'./bodiedSyncedBlock').then(function (_ref) {
|
|
10
|
-
var bodiedSyncBlockNodeView = _ref.bodiedSyncBlockNodeView;
|
|
11
|
-
return bodiedSyncBlockNodeView(props);
|
|
12
|
-
});
|
|
13
|
-
return result;
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { NodeViewConstructor } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
|
-
import type { BodiedSyncBlockNodeViewProperties } from './bodiedSyncedBlock';
|
|
3
|
-
export declare const lazyBodiedSyncBlockView: (props: BodiedSyncBlockNodeViewProperties) => NodeViewConstructor;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { NodeViewConstructor } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
|
-
import type { BodiedSyncBlockNodeViewProperties } from './bodiedSyncedBlock';
|
|
3
|
-
export declare const lazyBodiedSyncBlockView: (props: BodiedSyncBlockNodeViewProperties) => NodeViewConstructor;
|