@atlaskit/editor-plugin-synced-block 5.4.5 → 5.4.7
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 +18 -0
- package/dist/cjs/nodeviews/syncedBlock.js +15 -0
- package/dist/cjs/pm-plugins/main.js +38 -67
- package/dist/cjs/pm-plugins/utils/track-sync-blocks.js +24 -66
- package/dist/cjs/pm-plugins/utils/utils.js +20 -10
- package/dist/cjs/syncedBlockPlugin.js +1 -3
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/ui/Flag.js +5 -1
- package/dist/cjs/ui/SyncedLocationDropdown.js +11 -20
- package/dist/es2019/nodeviews/syncedBlock.js +11 -0
- package/dist/es2019/pm-plugins/main.js +39 -68
- package/dist/es2019/pm-plugins/utils/track-sync-blocks.js +25 -58
- package/dist/es2019/pm-plugins/utils/utils.js +18 -8
- package/dist/es2019/syncedBlockPlugin.js +2 -4
- package/dist/es2019/types/index.js +1 -0
- package/dist/es2019/ui/Flag.js +5 -0
- package/dist/es2019/ui/SyncedLocationDropdown.js +12 -21
- package/dist/esm/nodeviews/syncedBlock.js +15 -0
- package/dist/esm/pm-plugins/main.js +39 -68
- package/dist/esm/pm-plugins/utils/track-sync-blocks.js +24 -66
- package/dist/esm/pm-plugins/utils/utils.js +19 -9
- package/dist/esm/syncedBlockPlugin.js +2 -4
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/ui/Flag.js +5 -1
- package/dist/esm/ui/SyncedLocationDropdown.js +11 -20
- package/dist/types/nodeviews/syncedBlock.d.ts +3 -1
- package/dist/types/pm-plugins/utils/utils.d.ts +1 -1
- package/dist/types/types/index.d.ts +6 -5
- package/dist/types-ts4.5/nodeviews/syncedBlock.d.ts +3 -1
- package/dist/types-ts4.5/pm-plugins/utils/utils.d.ts +1 -1
- package/dist/types-ts4.5/types/index.d.ts +6 -5
- package/package.json +3 -6
|
@@ -27,7 +27,7 @@ import { handleBodiedSyncBlockRemoval } from './utils/handle-bodied-sync-block-r
|
|
|
27
27
|
import { shouldIgnoreDomEvent } from './utils/ignore-dom-event';
|
|
28
28
|
import { calculateDecorations } from './utils/selection-decorations';
|
|
29
29
|
import { hasEditInSyncBlock, trackSyncBlocks } from './utils/track-sync-blocks';
|
|
30
|
-
import { deferDispatch,
|
|
30
|
+
import { deferDispatch, wasExtensionInsertedInBodiedSyncBlock, sliceFullyContainsNode } from './utils/utils';
|
|
31
31
|
export var syncedBlockPluginKey = new PluginKey('syncedBlockPlugin');
|
|
32
32
|
var mapRetryCreationPosMap = function mapRetryCreationPosMap(oldMap, newRetryCreationPos, mapPos) {
|
|
33
33
|
var resourceId = newRetryCreationPos === null || newRetryCreationPos === void 0 ? void 0 : newRetryCreationPos.resourceId;
|
|
@@ -74,24 +74,23 @@ var showCopiedFlag = function showCopiedFlag(api) {
|
|
|
74
74
|
});
|
|
75
75
|
});
|
|
76
76
|
};
|
|
77
|
-
var
|
|
77
|
+
var showExtensionInSyncBlockWarningIfNeeded = function showExtensionInSyncBlockWarningIfNeeded(tr, state, api, extensionFlagShown) {
|
|
78
78
|
var _api$connectivity;
|
|
79
|
-
if (!fg('platform_synced_block_patch_3')) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
79
|
if (!tr.docChanged || tr.getMeta('isRemote') || Boolean(tr.getMeta(pmHistoryPluginKey)) || isOfflineMode(api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode)) {
|
|
83
80
|
return;
|
|
84
81
|
}
|
|
85
|
-
var resourceId =
|
|
82
|
+
var resourceId = wasExtensionInsertedInBodiedSyncBlock(tr, state);
|
|
86
83
|
// Only show the flag on the first instance per sync block (same as UNPUBLISHED_SYNC_BLOCK_PASTED)
|
|
87
|
-
if (resourceId && !
|
|
88
|
-
|
|
84
|
+
if (resourceId && !extensionFlagShown.has(resourceId)) {
|
|
85
|
+
extensionFlagShown.add(resourceId);
|
|
89
86
|
deferDispatch(function () {
|
|
90
87
|
api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
|
|
91
88
|
var tr = _ref2.tr;
|
|
92
89
|
return tr.setMeta(syncedBlockPluginKey, {
|
|
93
90
|
activeFlag: {
|
|
94
|
-
id:
|
|
91
|
+
id: editorExperiment('platform_synced_block_patch_6', true, {
|
|
92
|
+
exposure: true
|
|
93
|
+
}) ? FLAG_ID.EXTENSION_IN_SYNC_BLOCK : FLAG_ID.INLINE_EXTENSION_IN_SYNC_BLOCK
|
|
95
94
|
}
|
|
96
95
|
});
|
|
97
96
|
});
|
|
@@ -113,7 +112,7 @@ var filterTransactionOnline = function filterTransactionOnline(_ref3) {
|
|
|
113
112
|
confirmationTransactionRef = _ref3.confirmationTransactionRef,
|
|
114
113
|
bodiedSyncBlockRemoved = _ref3.bodiedSyncBlockRemoved,
|
|
115
114
|
bodiedSyncBlockAdded = _ref3.bodiedSyncBlockAdded,
|
|
116
|
-
|
|
115
|
+
extensionFlagShown = _ref3.extensionFlagShown;
|
|
117
116
|
var _trackSyncBlocks = trackSyncBlocks(function (node) {
|
|
118
117
|
return node.type.name === 'syncBlock';
|
|
119
118
|
}, tr, state),
|
|
@@ -133,31 +132,17 @@ var filterTransactionOnline = function filterTransactionOnline(_ref3) {
|
|
|
133
132
|
});
|
|
134
133
|
});
|
|
135
134
|
syncBlockAdded.forEach(function (syncBlock) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
});
|
|
148
|
-
} else {
|
|
149
|
-
var _api$analytics3;
|
|
150
|
-
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({
|
|
151
|
-
action: ACTION.INSERTED,
|
|
152
|
-
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
153
|
-
actionSubjectId: ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_CREATE,
|
|
154
|
-
attributes: {
|
|
155
|
-
resourceId: syncBlock.attrs.resourceId,
|
|
156
|
-
blockInstanceId: syncBlock.attrs.localId
|
|
157
|
-
},
|
|
158
|
-
eventType: EVENT_TYPE.OPERATIONAL
|
|
159
|
-
});
|
|
160
|
-
}
|
|
135
|
+
var _api$analytics2;
|
|
136
|
+
api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || (_api$analytics2 = _api$analytics2.actions) === null || _api$analytics2 === void 0 || _api$analytics2.fireAnalyticsEvent({
|
|
137
|
+
action: ACTION.INSERTED,
|
|
138
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
139
|
+
actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK,
|
|
140
|
+
attributes: {
|
|
141
|
+
resourceId: syncBlock.attrs.resourceId,
|
|
142
|
+
blockInstanceId: syncBlock.attrs.localId
|
|
143
|
+
},
|
|
144
|
+
eventType: EVENT_TYPE.TRACK
|
|
145
|
+
});
|
|
161
146
|
});
|
|
162
147
|
if (bodiedSyncBlockRemoved.length > 0) {
|
|
163
148
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -174,7 +159,7 @@ var filterTransactionOnline = function filterTransactionOnline(_ref3) {
|
|
|
174
159
|
handleBodiedSyncBlockCreation(bodiedSyncBlockAdded, state, api);
|
|
175
160
|
return true;
|
|
176
161
|
}
|
|
177
|
-
|
|
162
|
+
showExtensionInSyncBlockWarningIfNeeded(tr, state, api, extensionFlagShown);
|
|
178
163
|
return true;
|
|
179
164
|
};
|
|
180
165
|
var filterTransactionOffline = function filterTransactionOffline(_ref4) {
|
|
@@ -226,7 +211,7 @@ var SyncedBlockPluginContext = /*#__PURE__*/function () {
|
|
|
226
211
|
});
|
|
227
212
|
_defineProperty(this, "_isCopyEvent", false);
|
|
228
213
|
_defineProperty(this, "unpublishedFlagShown", new Set());
|
|
229
|
-
_defineProperty(this, "
|
|
214
|
+
_defineProperty(this, "extensionFlagShown", new Set());
|
|
230
215
|
}
|
|
231
216
|
return _createClass(SyncedBlockPluginContext, [{
|
|
232
217
|
key: "isCopyEvent",
|
|
@@ -248,7 +233,7 @@ var SyncedBlockPluginContext = /*#__PURE__*/function () {
|
|
|
248
233
|
}]);
|
|
249
234
|
}();
|
|
250
235
|
export var createPlugin = function createPlugin(options, pmPluginFactoryParams, syncBlockStore, api) {
|
|
251
|
-
var _ctx$confirmationTran, _ctx$unpublishedFlagS, _ctx$
|
|
236
|
+
var _ctx$confirmationTran, _ctx$unpublishedFlagS, _ctx$extensionFlagSho;
|
|
252
237
|
var _ref6 = options || {},
|
|
253
238
|
_ref6$useLongPressSel = _ref6.useLongPressSelection,
|
|
254
239
|
useLongPressSelection = _ref6$useLongPressSel === void 0 ? false : _ref6$useLongPressSel;
|
|
@@ -258,7 +243,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
258
243
|
};
|
|
259
244
|
var isCopyEvent = false;
|
|
260
245
|
var unpublishedFlagShown = (_ctx$unpublishedFlagS = ctx === null || ctx === void 0 ? void 0 : ctx.unpublishedFlagShown) !== null && _ctx$unpublishedFlagS !== void 0 ? _ctx$unpublishedFlagS : new Set();
|
|
261
|
-
var
|
|
246
|
+
var extensionFlagShown = (_ctx$extensionFlagSho = ctx === null || ctx === void 0 ? void 0 : ctx.extensionFlagShown) !== null && _ctx$extensionFlagSho !== void 0 ? _ctx$extensionFlagSho : new Set();
|
|
262
247
|
|
|
263
248
|
// Set up callback to detect unpublished sync blocks when they're fetched
|
|
264
249
|
syncBlockStore.referenceManager.setOnUnpublishedSyncBlockDetected(function (resourceId) {
|
|
@@ -512,7 +497,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
512
497
|
confirmationTransactionRef: confirmationTransactionRef,
|
|
513
498
|
bodiedSyncBlockRemoved: bodiedSyncBlockRemoved,
|
|
514
499
|
bodiedSyncBlockAdded: bodiedSyncBlockAdded,
|
|
515
|
-
|
|
500
|
+
extensionFlagShown: extensionFlagShown
|
|
516
501
|
});
|
|
517
502
|
}
|
|
518
503
|
if (!isOffline) {
|
|
@@ -522,8 +507,8 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
522
507
|
_syncBlockRemoved = _trackSyncBlocks5.removed,
|
|
523
508
|
_syncBlockAdded = _trackSyncBlocks5.added;
|
|
524
509
|
_syncBlockRemoved.forEach(function (syncBlock) {
|
|
525
|
-
var _api$
|
|
526
|
-
api === null || api === void 0 || (_api$
|
|
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({
|
|
527
512
|
action: ACTION.DELETED,
|
|
528
513
|
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
529
514
|
actionSubjectId: ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_DELETE,
|
|
@@ -535,31 +520,17 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
535
520
|
});
|
|
536
521
|
});
|
|
537
522
|
_syncBlockAdded.forEach(function (syncBlock) {
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
});
|
|
550
|
-
} else {
|
|
551
|
-
var _api$analytics6;
|
|
552
|
-
api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 || (_api$analytics6 = _api$analytics6.actions) === null || _api$analytics6 === void 0 || _api$analytics6.fireAnalyticsEvent({
|
|
553
|
-
action: ACTION.INSERTED,
|
|
554
|
-
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
555
|
-
actionSubjectId: ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_CREATE,
|
|
556
|
-
attributes: {
|
|
557
|
-
resourceId: syncBlock.attrs.resourceId,
|
|
558
|
-
blockInstanceId: syncBlock.attrs.localId
|
|
559
|
-
},
|
|
560
|
-
eventType: EVENT_TYPE.OPERATIONAL
|
|
561
|
-
});
|
|
562
|
-
}
|
|
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
|
+
});
|
|
563
534
|
});
|
|
564
535
|
if (bodiedSyncBlockRemoved.length > 0) {
|
|
565
536
|
confirmationTransactionRef.current = tr;
|
|
@@ -575,7 +546,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
575
546
|
handleBodiedSyncBlockCreation(bodiedSyncBlockAdded, state, api);
|
|
576
547
|
return true;
|
|
577
548
|
}
|
|
578
|
-
|
|
549
|
+
showExtensionInSyncBlockWarningIfNeeded(tr, state, api, extensionFlagShown);
|
|
579
550
|
return true;
|
|
580
551
|
}
|
|
581
552
|
var _trackSyncBlocks6 = trackSyncBlocks(function (node) {
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
2
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
3
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
4
1
|
import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
5
2
|
import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
6
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
3
|
export var trackSyncBlocks = function trackSyncBlocks(predicate, tr, state) {
|
|
8
4
|
var removed = {};
|
|
9
5
|
var added = {};
|
|
@@ -20,10 +16,10 @@ export var trackSyncBlocks = function trackSyncBlocks(predicate, tr, state) {
|
|
|
20
16
|
});
|
|
21
17
|
|
|
22
18
|
// this is a quick check to see if any insertion/deletion of bodiedSyncBlock happened
|
|
23
|
-
var hasBodiedSyncBlockChanges = replaceSteps.some(function (step
|
|
19
|
+
var hasBodiedSyncBlockChanges = replaceSteps.some(function (step) {
|
|
24
20
|
var from = step.from,
|
|
25
21
|
to = step.to;
|
|
26
|
-
var docAtStep =
|
|
22
|
+
var docAtStep = tr.docs[tr.steps.indexOf(step)];
|
|
27
23
|
var hasChange = false;
|
|
28
24
|
if (from !== to) {
|
|
29
25
|
step.getMap().forEach(function (oldStart, oldEnd) {
|
|
@@ -103,70 +99,32 @@ export var trackSyncBlocks = function trackSyncBlocks(predicate, tr, state) {
|
|
|
103
99
|
*/
|
|
104
100
|
export var hasEditInSyncBlock = function hasEditInSyncBlock(tr, state) {
|
|
105
101
|
var bodiedSyncBlock = state.schema.nodes.bodiedSyncBlock;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
var positions = [];
|
|
102
|
+
for (var i = 0; i < tr.steps.length; i++) {
|
|
103
|
+
var _tr$docs;
|
|
104
|
+
var step = tr.steps[i];
|
|
105
|
+
var map = step.getMap();
|
|
106
|
+
var docAfterStep = (_tr$docs = tr.docs[i + 1]) !== null && _tr$docs !== void 0 ? _tr$docs : tr.doc;
|
|
107
|
+
var positions = [];
|
|
113
108
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
for (var _i = 0, _positions = positions; _i < _positions.length; _i++) {
|
|
126
|
-
var _pos = _positions[_i];
|
|
127
|
-
var newPos = map.map(_pos);
|
|
128
|
-
if (newPos >= 0 && newPos <= docAfterStep.content.size) {
|
|
129
|
-
if (findParentNodeOfTypeClosestToPos(docAfterStep.resolve(newPos), bodiedSyncBlock)) {
|
|
130
|
-
return true;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
109
|
+
// Extract positions from steps dynamically based on applicable properties
|
|
110
|
+
if ('from' in step && typeof step.from === 'number' && 'to' in step && typeof step.to === 'number') {
|
|
111
|
+
var _ref = step,
|
|
112
|
+
from = _ref.from,
|
|
113
|
+
to = _ref.to;
|
|
114
|
+
positions.push(from, to);
|
|
115
|
+
} else if ('pos' in step && typeof step.pos === 'number') {
|
|
116
|
+
var _ref2 = step,
|
|
117
|
+
pos = _ref2.pos;
|
|
118
|
+
positions.push(pos);
|
|
134
119
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
var _map = _step2.getMap();
|
|
142
|
-
var doc = tr.doc;
|
|
143
|
-
var _positions2 = [];
|
|
144
|
-
|
|
145
|
-
// Extract positions from steps dynamically based on applicable properties
|
|
146
|
-
if ('from' in _step2 && typeof _step2.from === 'number' && 'to' in _step2 && typeof _step2.to === 'number') {
|
|
147
|
-
var _ref3 = _step2,
|
|
148
|
-
_from = _ref3.from,
|
|
149
|
-
_to = _ref3.to;
|
|
150
|
-
_positions2.push(_from, _to);
|
|
151
|
-
} else if ('pos' in _step2 && typeof _step2.pos === 'number') {
|
|
152
|
-
var _ref4 = _step2,
|
|
153
|
-
_pos2 = _ref4.pos;
|
|
154
|
-
_positions2.push(_pos2);
|
|
155
|
-
}
|
|
156
|
-
for (var _i2 = 0, _positions3 = _positions2; _i2 < _positions3.length; _i2++) {
|
|
157
|
-
var _pos3 = _positions3[_i2];
|
|
158
|
-
var _newPos = _map.map(_pos3);
|
|
159
|
-
if (_newPos >= 0 && _newPos <= doc.content.size) {
|
|
160
|
-
if (findParentNodeOfTypeClosestToPos(doc.resolve(_newPos), bodiedSyncBlock)) {
|
|
161
|
-
return true;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
120
|
+
for (var _i = 0, _positions = positions; _i < _positions.length; _i++) {
|
|
121
|
+
var _pos = _positions[_i];
|
|
122
|
+
var newPos = map.map(_pos);
|
|
123
|
+
if (newPos >= 0 && newPos <= docAfterStep.content.size) {
|
|
124
|
+
if (findParentNodeOfTypeClosestToPos(docAfterStep.resolve(newPos), bodiedSyncBlock)) {
|
|
125
|
+
return true;
|
|
164
126
|
}
|
|
165
127
|
}
|
|
166
|
-
} catch (err) {
|
|
167
|
-
_iterator.e(err);
|
|
168
|
-
} finally {
|
|
169
|
-
_iterator.f();
|
|
170
128
|
}
|
|
171
129
|
}
|
|
172
130
|
return false;
|
|
@@ -3,6 +3,7 @@ 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
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Defers a callback to the next microtask (when gated) or next macrotask via setTimeout(0).
|
|
@@ -92,31 +93,36 @@ export var sliceFullyContainsNode = function sliceFullyContainsNode(slice, node)
|
|
|
92
93
|
}
|
|
93
94
|
return true;
|
|
94
95
|
};
|
|
95
|
-
|
|
96
|
+
|
|
97
|
+
// even though extension and bodiedExtension are explicitly not allowed by the schema, they can still be inserted nested inside other nodes e.g. layouts
|
|
98
|
+
var EXTENSION_NODES = new Set(['inlineExtension', 'extension', 'bodiedExtension']);
|
|
99
|
+
var _fragmentContainsExtension = function fragmentContainsExtension(fragment) {
|
|
96
100
|
var found = false;
|
|
97
101
|
fragment.forEach(function (node) {
|
|
98
102
|
if (found) {
|
|
99
103
|
return;
|
|
100
104
|
}
|
|
101
|
-
if (
|
|
105
|
+
if (editorExperiment('platform_synced_block_patch_6', true, {
|
|
106
|
+
exposure: true
|
|
107
|
+
}) ? EXTENSION_NODES.has(node.type.name) : node.type.name === 'inlineExtension') {
|
|
102
108
|
found = true;
|
|
103
109
|
} else if (node.content.size) {
|
|
104
|
-
if (
|
|
110
|
+
if (_fragmentContainsExtension(node.content)) {
|
|
105
111
|
found = true;
|
|
106
112
|
}
|
|
107
113
|
}
|
|
108
114
|
});
|
|
109
115
|
return found;
|
|
110
116
|
};
|
|
111
|
-
var
|
|
112
|
-
return
|
|
117
|
+
var sliceContainsExtension = function sliceContainsExtension(slice) {
|
|
118
|
+
return _fragmentContainsExtension(slice.content);
|
|
113
119
|
};
|
|
114
120
|
|
|
115
121
|
/**
|
|
116
122
|
* Returns the resourceId of the bodied sync block where an inline extension was inserted, or undefined.
|
|
117
123
|
* Used to show a warning flag only on the first instance per sync block.
|
|
118
124
|
*/
|
|
119
|
-
export var
|
|
125
|
+
export var wasExtensionInsertedInBodiedSyncBlock = function wasExtensionInsertedInBodiedSyncBlock(tr, state) {
|
|
120
126
|
if (!tr.docChanged || tr.getMeta('isRemote')) {
|
|
121
127
|
return undefined;
|
|
122
128
|
}
|
|
@@ -136,7 +142,7 @@ export var wasInlineExtensionInsertedInBodiedSyncBlock = function wasInlineExten
|
|
|
136
142
|
continue;
|
|
137
143
|
}
|
|
138
144
|
var replaceStep = step;
|
|
139
|
-
if (!
|
|
145
|
+
if (!sliceContainsExtension(replaceStep.slice)) {
|
|
140
146
|
continue;
|
|
141
147
|
}
|
|
142
148
|
var docAfterStep = (_docs = docs[i + 1]) !== null && _docs !== void 0 ? _docs : tr.doc;
|
|
@@ -159,13 +165,17 @@ export var wasInlineExtensionInsertedInBodiedSyncBlock = function wasInlineExten
|
|
|
159
165
|
if (resourceId !== undefined) {
|
|
160
166
|
return false;
|
|
161
167
|
}
|
|
162
|
-
if (
|
|
168
|
+
if (editorExperiment('platform_synced_block_patch_6', true, {
|
|
169
|
+
exposure: true
|
|
170
|
+
}) ? EXTENSION_NODES.has(node.type.name) : node.type.name === 'inlineExtension') {
|
|
163
171
|
var _$pos = tr.doc.resolve(pos);
|
|
164
172
|
var _parent = findParentNodeOfTypeClosestToPos(_$pos, bodiedSyncBlock);
|
|
165
173
|
if (_parent !== null && _parent !== void 0 && _parent.node.attrs.resourceId) {
|
|
166
174
|
var mappedPos = tr.mapping.invert().map(pos);
|
|
167
175
|
var nodeBefore = state.doc.nodeAt(mappedPos);
|
|
168
|
-
if (!nodeBefore ||
|
|
176
|
+
if (!nodeBefore || (editorExperiment('platform_synced_block_patch_6', true, {
|
|
177
|
+
exposure: true
|
|
178
|
+
}) ? EXTENSION_NODES.has(nodeBefore.type.name) : nodeBefore.type.name !== 'inlineExtension')) {
|
|
169
179
|
resourceId = _parent.node.attrs.resourceId;
|
|
170
180
|
return false;
|
|
171
181
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { syncBlock, bodiedSyncBlock } from '@atlaskit/adf-schema';
|
|
3
3
|
import { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
4
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
5
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
@@ -32,9 +32,7 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
|
|
|
32
32
|
node: syncBlock
|
|
33
33
|
}, {
|
|
34
34
|
name: 'bodiedSyncBlock',
|
|
35
|
-
node:
|
|
36
|
-
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
37
|
-
fg('platform_synced_block_patch_3') && !editorExperiment('platform_synced_block_patch_6', true, {
|
|
35
|
+
node: !editorExperiment('platform_synced_block_patch_6', true, {
|
|
38
36
|
exposure: true
|
|
39
37
|
}) ?
|
|
40
38
|
// delete bodiedSyncBlockNodeWithToDOMFixed when cleaning up platform_synced_block_patch_6
|
package/dist/esm/types/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export var FLAG_ID = /*#__PURE__*/function (FLAG_ID) {
|
|
|
7
7
|
FLAG_ID["UNPUBLISHED_SYNC_BLOCK_PASTED"] = "unpublished-sync-block-pasted";
|
|
8
8
|
FLAG_ID["CANNOT_CREATE_SYNC_BLOCK"] = "cannot-create-sync-block";
|
|
9
9
|
FLAG_ID["INLINE_EXTENSION_IN_SYNC_BLOCK"] = "inline-extension-in-sync-block";
|
|
10
|
+
FLAG_ID["EXTENSION_IN_SYNC_BLOCK"] = "extension-in-sync-block";
|
|
10
11
|
return FLAG_ID;
|
|
11
12
|
}({});
|
|
12
13
|
export var SYNCED_BLOCK_BUTTON_TEST_ID = {
|
package/dist/esm/ui/Flag.js
CHANGED
|
@@ -12,7 +12,7 @@ import StatusSuccessIcon from '@atlaskit/icon/core/status-success';
|
|
|
12
12
|
import StatusWarningIcon from '@atlaskit/icon/core/status-warning';
|
|
13
13
|
import { syncedBlockPluginKey } from '../pm-plugins/main';
|
|
14
14
|
import { FLAG_ID } from '../types';
|
|
15
|
-
var flagMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE, {
|
|
15
|
+
var flagMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE, {
|
|
16
16
|
title: messages.failToDeleteTitle,
|
|
17
17
|
description: messages.failToDeleteWhenOfflineDescription,
|
|
18
18
|
type: 'error'
|
|
@@ -39,6 +39,10 @@ var flagMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_d
|
|
|
39
39
|
title: messages.cannotCreateSyncBlockTitle,
|
|
40
40
|
description: messages.CannotCreateSyncBlockDescription,
|
|
41
41
|
type: 'error'
|
|
42
|
+
}), FLAG_ID.EXTENSION_IN_SYNC_BLOCK, {
|
|
43
|
+
title: messages.extensionInSyncBlockTitle,
|
|
44
|
+
description: messages.extensionInSyncBlockDescription,
|
|
45
|
+
type: 'error'
|
|
42
46
|
}), FLAG_ID.INLINE_EXTENSION_IN_SYNC_BLOCK, {
|
|
43
47
|
title: messages.inlineExtensionInSyncBlockTitle,
|
|
44
48
|
description: messages.inlineExtensionInSyncBlockDescription,
|
|
@@ -27,7 +27,6 @@ import QuotationMarkIcon from '@atlaskit/icon/core/quotation-mark';
|
|
|
27
27
|
import StatusErrorIcon from '@atlaskit/icon/core/status-error';
|
|
28
28
|
import { ConfluenceIcon, JiraIcon, AtlassianIcon } from '@atlaskit/logo';
|
|
29
29
|
import Lozenge from '@atlaskit/lozenge';
|
|
30
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
31
30
|
import { Box, Text, Inline, Anchor, Stack } from '@atlaskit/primitives/compiled';
|
|
32
31
|
import Spinner from '@atlaskit/spinner';
|
|
33
32
|
import Tooltip from '@atlaskit/tooltip';
|
|
@@ -80,31 +79,23 @@ var productIconMap = {
|
|
|
80
79
|
'jira-work-item': JiraIcon
|
|
81
80
|
};
|
|
82
81
|
var subTypeIconMap = {
|
|
83
|
-
live: PageLiveDocIcon,
|
|
84
|
-
page: PageIcon,
|
|
85
|
-
blogpost: QuotationMarkIcon
|
|
86
|
-
};
|
|
87
|
-
var subTypeIconMapNew = {
|
|
88
82
|
live: PageLiveDocIcon,
|
|
89
83
|
page: PageIcon
|
|
90
84
|
};
|
|
91
85
|
var getConfluenceSubTypeIcon = function getConfluenceSubTypeIcon(sourceAri, subType) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return subType && subType in subTypeIconMapNew ? subTypeIconMapNew[subType] : PageIcon;
|
|
102
|
-
}
|
|
103
|
-
} catch (_unused) {
|
|
104
|
-
return PageIcon;
|
|
86
|
+
try {
|
|
87
|
+
var _getPageIdAndTypeFrom = getPageIdAndTypeFromConfluencePageAri({
|
|
88
|
+
ari: sourceAri
|
|
89
|
+
}),
|
|
90
|
+
pageType = _getPageIdAndTypeFrom.type;
|
|
91
|
+
if (pageType === 'blogpost') {
|
|
92
|
+
return QuotationMarkIcon;
|
|
93
|
+
} else {
|
|
94
|
+
return subType && subType in subTypeIconMap ? subTypeIconMap[subType] : PageIcon;
|
|
105
95
|
}
|
|
96
|
+
} catch (_unused) {
|
|
97
|
+
return PageIcon;
|
|
106
98
|
}
|
|
107
|
-
return subType && subType in subTypeIconMap ? subTypeIconMap[subType] : PageIcon;
|
|
108
99
|
};
|
|
109
100
|
var ProductIcon = function ProductIcon(_ref2) {
|
|
110
101
|
var _productIconMap$produ;
|
|
@@ -5,7 +5,7 @@ import ReactNodeView, { type getPosHandler } from '@atlaskit/editor-common/react
|
|
|
5
5
|
import type { ReactComponentProps } from '@atlaskit/editor-common/react-node-view';
|
|
6
6
|
import type { ExtractInjectionAPI, getPosHandlerNode, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
|
|
7
7
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
8
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
|
+
import type { EditorView, Decoration, DecorationSource } from '@atlaskit/editor-prosemirror/view';
|
|
9
9
|
import { type SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
10
10
|
import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlockPluginType';
|
|
11
11
|
export interface SyncBlockNodeViewProps extends ReactComponentProps {
|
|
@@ -26,6 +26,8 @@ export declare class SyncBlock extends ReactNodeView<SyncBlockNodeViewProps> {
|
|
|
26
26
|
constructor(props: SyncBlockNodeViewProps);
|
|
27
27
|
unsubscribe: (() => void) | undefined;
|
|
28
28
|
createDomRef(): HTMLElement;
|
|
29
|
+
validUpdate(currentNode: PMNode, newNode: PMNode): boolean;
|
|
30
|
+
update(node: PMNode, decorations: ReadonlyArray<Decoration>, innerDecorations?: DecorationSource): boolean;
|
|
29
31
|
render({ getPos }: SyncBlockNodeViewProps): React.JSX.Element | null;
|
|
30
32
|
destroy(): void;
|
|
31
33
|
}
|
|
@@ -30,4 +30,4 @@ export declare const sliceFullyContainsNode: (slice: Slice, node: PMNode) => boo
|
|
|
30
30
|
* Returns the resourceId of the bodied sync block where an inline extension was inserted, or undefined.
|
|
31
31
|
* Used to show a warning flag only on the first instance per sync block.
|
|
32
32
|
*/
|
|
33
|
-
export declare const
|
|
33
|
+
export declare const wasExtensionInsertedInBodiedSyncBlock: (tr: Transaction, state: EditorState) => string | undefined;
|
|
@@ -9,7 +9,8 @@ export declare enum FLAG_ID {
|
|
|
9
9
|
SYNC_BLOCK_COPIED = "sync-block-copied",
|
|
10
10
|
UNPUBLISHED_SYNC_BLOCK_PASTED = "unpublished-sync-block-pasted",
|
|
11
11
|
CANNOT_CREATE_SYNC_BLOCK = "cannot-create-sync-block",
|
|
12
|
-
INLINE_EXTENSION_IN_SYNC_BLOCK = "inline-extension-in-sync-block"
|
|
12
|
+
INLINE_EXTENSION_IN_SYNC_BLOCK = "inline-extension-in-sync-block",
|
|
13
|
+
EXTENSION_IN_SYNC_BLOCK = "extension-in-sync-block"
|
|
13
14
|
}
|
|
14
15
|
type FlagConfig = {
|
|
15
16
|
id: FLAG_ID;
|
|
@@ -36,6 +37,10 @@ export type SyncedBlockSharedState = {
|
|
|
36
37
|
* Whether the plugin is currently saving bodiedSyncBlock deletion to backend
|
|
37
38
|
*/
|
|
38
39
|
bodiedSyncBlockDeletionStatus?: BodiedSyncBlockDeletionStatus;
|
|
40
|
+
/**
|
|
41
|
+
* Whether there are unsaved bodiedSyncBlock changes in the cache
|
|
42
|
+
*/
|
|
43
|
+
hasUnsavedBodiedSyncBlockChanges: boolean;
|
|
39
44
|
/**
|
|
40
45
|
* Positions of pending creations keyed by resourceId, used for retry/revert flow.
|
|
41
46
|
* When a new bodiedSyncBlock is added, a new entry is added to map for mapping. The entry is removed when creation succeeds or retry option is dismissed.
|
|
@@ -46,10 +51,6 @@ export type SyncedBlockSharedState = {
|
|
|
46
51
|
* The current sync block store manager, used to manage fetching and updating sync block data
|
|
47
52
|
*/
|
|
48
53
|
syncBlockStore: SyncBlockStoreManager;
|
|
49
|
-
/**
|
|
50
|
-
* Whether there are unsaved bodiedSyncBlock changes in the cache
|
|
51
|
-
*/
|
|
52
|
-
hasUnsavedBodiedSyncBlockChanges: boolean;
|
|
53
54
|
};
|
|
54
55
|
export type SyncBlockAttrs = {
|
|
55
56
|
localId: string;
|
|
@@ -5,7 +5,7 @@ import ReactNodeView, { type getPosHandler } from '@atlaskit/editor-common/react
|
|
|
5
5
|
import type { ReactComponentProps } from '@atlaskit/editor-common/react-node-view';
|
|
6
6
|
import type { ExtractInjectionAPI, getPosHandlerNode, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
|
|
7
7
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
8
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
|
+
import type { EditorView, Decoration, DecorationSource } from '@atlaskit/editor-prosemirror/view';
|
|
9
9
|
import { type SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
10
10
|
import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlockPluginType';
|
|
11
11
|
export interface SyncBlockNodeViewProps extends ReactComponentProps {
|
|
@@ -26,6 +26,8 @@ export declare class SyncBlock extends ReactNodeView<SyncBlockNodeViewProps> {
|
|
|
26
26
|
constructor(props: SyncBlockNodeViewProps);
|
|
27
27
|
unsubscribe: (() => void) | undefined;
|
|
28
28
|
createDomRef(): HTMLElement;
|
|
29
|
+
validUpdate(currentNode: PMNode, newNode: PMNode): boolean;
|
|
30
|
+
update(node: PMNode, decorations: ReadonlyArray<Decoration>, innerDecorations?: DecorationSource): boolean;
|
|
29
31
|
render({ getPos }: SyncBlockNodeViewProps): React.JSX.Element | null;
|
|
30
32
|
destroy(): void;
|
|
31
33
|
}
|
|
@@ -30,4 +30,4 @@ export declare const sliceFullyContainsNode: (slice: Slice, node: PMNode) => boo
|
|
|
30
30
|
* Returns the resourceId of the bodied sync block where an inline extension was inserted, or undefined.
|
|
31
31
|
* Used to show a warning flag only on the first instance per sync block.
|
|
32
32
|
*/
|
|
33
|
-
export declare const
|
|
33
|
+
export declare const wasExtensionInsertedInBodiedSyncBlock: (tr: Transaction, state: EditorState) => string | undefined;
|
|
@@ -9,7 +9,8 @@ export declare enum FLAG_ID {
|
|
|
9
9
|
SYNC_BLOCK_COPIED = "sync-block-copied",
|
|
10
10
|
UNPUBLISHED_SYNC_BLOCK_PASTED = "unpublished-sync-block-pasted",
|
|
11
11
|
CANNOT_CREATE_SYNC_BLOCK = "cannot-create-sync-block",
|
|
12
|
-
INLINE_EXTENSION_IN_SYNC_BLOCK = "inline-extension-in-sync-block"
|
|
12
|
+
INLINE_EXTENSION_IN_SYNC_BLOCK = "inline-extension-in-sync-block",
|
|
13
|
+
EXTENSION_IN_SYNC_BLOCK = "extension-in-sync-block"
|
|
13
14
|
}
|
|
14
15
|
type FlagConfig = {
|
|
15
16
|
id: FLAG_ID;
|
|
@@ -36,6 +37,10 @@ export type SyncedBlockSharedState = {
|
|
|
36
37
|
* Whether the plugin is currently saving bodiedSyncBlock deletion to backend
|
|
37
38
|
*/
|
|
38
39
|
bodiedSyncBlockDeletionStatus?: BodiedSyncBlockDeletionStatus;
|
|
40
|
+
/**
|
|
41
|
+
* Whether there are unsaved bodiedSyncBlock changes in the cache
|
|
42
|
+
*/
|
|
43
|
+
hasUnsavedBodiedSyncBlockChanges: boolean;
|
|
39
44
|
/**
|
|
40
45
|
* Positions of pending creations keyed by resourceId, used for retry/revert flow.
|
|
41
46
|
* When a new bodiedSyncBlock is added, a new entry is added to map for mapping. The entry is removed when creation succeeds or retry option is dismissed.
|
|
@@ -46,10 +51,6 @@ export type SyncedBlockSharedState = {
|
|
|
46
51
|
* The current sync block store manager, used to manage fetching and updating sync block data
|
|
47
52
|
*/
|
|
48
53
|
syncBlockStore: SyncBlockStoreManager;
|
|
49
|
-
/**
|
|
50
|
-
* Whether there are unsaved bodiedSyncBlock changes in the cache
|
|
51
|
-
*/
|
|
52
|
-
hasUnsavedBodiedSyncBlockChanges: boolean;
|
|
53
54
|
};
|
|
54
55
|
export type SyncBlockAttrs = {
|
|
55
56
|
localId: string;
|