@atlaskit/editor-plugin-synced-block 6.0.13 → 6.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -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 +10 -10
- package/package.json +5 -8
- 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,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 6.0.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`7428d9bf3aa13`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7428d9bf3aa13) -
|
|
8
|
+
Clean up platform_synced_block_patch_5 feature gate
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 6.0.13
|
|
4
12
|
|
|
5
13
|
### 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
|
});
|