@atlaskit/editor-plugin-synced-block 12.0.5 → 12.0.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 +14 -0
- package/dist/cjs/editor-commands/index.js +8 -18
- package/dist/cjs/nodeviews/bodiedSyncedBlock.js +3 -7
- package/dist/cjs/nodeviews/syncedBlock.js +9 -15
- package/dist/cjs/pm-plugins/main.js +14 -42
- package/dist/cjs/pm-plugins/utils/handle-bodied-sync-block-removal.js +36 -54
- package/dist/cjs/syncedBlockPlugin.js +1 -4
- package/dist/cjs/ui/CreateSyncedBlockButton.js +23 -35
- package/dist/cjs/ui/CreateSyncedBlockDropdownItem.js +36 -47
- package/dist/cjs/ui/SyncBlockLabel.js +2 -13
- package/dist/cjs/ui/SyncBlockRendererWrapper.js +7 -9
- package/dist/cjs/ui/SyncedLocationDropdown.js +53 -116
- package/dist/cjs/ui/floating-toolbar.js +1 -2
- package/dist/es2019/editor-commands/index.js +8 -18
- package/dist/es2019/nodeviews/bodiedSyncedBlock.js +3 -7
- package/dist/es2019/nodeviews/syncedBlock.js +9 -15
- package/dist/es2019/pm-plugins/main.js +16 -41
- package/dist/es2019/pm-plugins/utils/handle-bodied-sync-block-removal.js +33 -51
- package/dist/es2019/syncedBlockPlugin.js +1 -4
- package/dist/es2019/ui/CreateSyncedBlockButton.js +25 -36
- package/dist/es2019/ui/CreateSyncedBlockDropdownItem.js +36 -47
- package/dist/es2019/ui/SyncBlockLabel.js +2 -13
- package/dist/es2019/ui/SyncBlockRendererWrapper.js +7 -9
- package/dist/es2019/ui/SyncedLocationDropdown.js +1 -58
- package/dist/es2019/ui/floating-toolbar.js +1 -2
- package/dist/esm/editor-commands/index.js +8 -18
- package/dist/esm/nodeviews/bodiedSyncedBlock.js +3 -7
- package/dist/esm/nodeviews/syncedBlock.js +9 -15
- package/dist/esm/pm-plugins/main.js +15 -43
- package/dist/esm/pm-plugins/utils/handle-bodied-sync-block-removal.js +36 -54
- package/dist/esm/syncedBlockPlugin.js +1 -4
- package/dist/esm/ui/CreateSyncedBlockButton.js +23 -35
- package/dist/esm/ui/CreateSyncedBlockDropdownItem.js +36 -47
- package/dist/esm/ui/SyncBlockLabel.js +2 -13
- package/dist/esm/ui/SyncBlockRendererWrapper.js +7 -9
- package/dist/esm/ui/SyncedLocationDropdown.js +53 -116
- package/dist/esm/ui/floating-toolbar.js +1 -2
- package/dist/types/pm-plugins/main.d.ts +2 -4
- package/package.json +5 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 12.0.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 12.0.6
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`0b4753c0a8c07`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0b4753c0a8c07) -
|
|
14
|
+
Clean up feature gates from completed rollout
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 12.0.5
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -13,7 +13,6 @@ var _model = require("@atlaskit/editor-prosemirror/model");
|
|
|
13
13
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
14
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
15
15
|
var _utils2 = require("@atlaskit/editor-synced-block-provider/utils");
|
|
16
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
16
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
18
17
|
var _main = require("../pm-plugins/main");
|
|
19
18
|
var _utils3 = require("../pm-plugins/utils/utils");
|
|
@@ -115,9 +114,7 @@ var createSyncedBlock = exports.createSyncedBlock = function createSyncedBlock(_
|
|
|
115
114
|
// safeInsert does not move the selection into the new block, so place the
|
|
116
115
|
// caret inside the block's empty paragraph so typing continues inside the
|
|
117
116
|
// synced block (EDITOR-7949).
|
|
118
|
-
|
|
119
|
-
tr = placeCaretInsideBodiedSyncBlock(tr, newBodiedSyncBlockNode.attrs.localId);
|
|
120
|
-
}
|
|
117
|
+
tr = placeCaretInsideBodiedSyncBlock(tr, newBodiedSyncBlockNode.attrs.localId);
|
|
121
118
|
}
|
|
122
119
|
} else {
|
|
123
120
|
var conversionInfo = (0, _utils3.canBeConvertedToSyncBlock)(tr.selection);
|
|
@@ -148,14 +145,10 @@ var createSyncedBlock = exports.createSyncedBlock = function createSyncedBlock(_
|
|
|
148
145
|
return false;
|
|
149
146
|
}
|
|
150
147
|
tr.replaceWith(conversionInfo.from, conversionInfo.to, _newBodiedSyncBlockNode).scrollIntoView();
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
} else {
|
|
156
|
-
// set selection to the start of the previous selection for the position taken up by the start of the new synced block
|
|
157
|
-
tr.setSelection(_state.TextSelection.create(tr.doc, conversionInfo.from));
|
|
158
|
-
}
|
|
148
|
+
|
|
149
|
+
// Place the caret on the first editable position inside the converted
|
|
150
|
+
// content so typing continues inside the synced block (EDITOR-7949).
|
|
151
|
+
tr = placeCaretInsideBodiedSyncBlock(tr, _newBodiedSyncBlockNode.attrs.localId);
|
|
159
152
|
}
|
|
160
153
|
|
|
161
154
|
// Stash creation-type signals on the final transaction (after any typeahead
|
|
@@ -259,7 +252,7 @@ var copySyncedBlockReferenceToClipboardInternal = function copySyncedBlockRefere
|
|
|
259
252
|
attributes: _objectSpread({
|
|
260
253
|
resourceId: referenceSyncBlockNode.attrs.resourceId,
|
|
261
254
|
inputMethod: inputMethod
|
|
262
|
-
}, sourceJoinKey &&
|
|
255
|
+
}, sourceJoinKey && {
|
|
263
256
|
blockInstanceId: sourceJoinKey
|
|
264
257
|
})
|
|
265
258
|
});
|
|
@@ -340,11 +333,8 @@ var removeSyncedBlock = exports.removeSyncedBlock = function removeSyncedBlock(a
|
|
|
340
333
|
}
|
|
341
334
|
|
|
342
335
|
// Tag the transaction so analytics can report this as `deleteButton` rather
|
|
343
|
-
// than a keyboard delete (both produce a plain ReplaceStep).
|
|
344
|
-
|
|
345
|
-
if ((0, _platformFeatureFlags.fg)('platform_editor_blocks_patch_4')) {
|
|
346
|
-
removeTr.setMeta(_main.deleteMechanismMetaKey, 'deleteButton');
|
|
347
|
-
}
|
|
336
|
+
// than a keyboard delete (both produce a plain ReplaceStep).
|
|
337
|
+
removeTr.setMeta(_main.deleteMechanismMetaKey, 'deleteButton');
|
|
348
338
|
dispatch(removeTr);
|
|
349
339
|
api === null || api === void 0 || api.core.actions.focus();
|
|
350
340
|
return true;
|
|
@@ -14,7 +14,6 @@ var _errorBoundary = require("@atlaskit/editor-common/error-boundary");
|
|
|
14
14
|
var _syncBlock = require("@atlaskit/editor-common/sync-block");
|
|
15
15
|
var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
|
|
16
16
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
17
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
18
17
|
var _SyncBlockLabel = require("../ui/SyncBlockLabel");
|
|
19
18
|
var _isEmptySourceSyncBlock = require("./isEmptySourceSyncBlock");
|
|
20
19
|
var toDOM = function toDOM(node) {
|
|
@@ -51,15 +50,12 @@ var BodiedSyncBlock = exports.BodiedSyncBlock = /*#__PURE__*/function () {
|
|
|
51
50
|
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage -- NodeView DOM must be created against active runtime document
|
|
52
51
|
labelContainer = document.createElement('div');
|
|
53
52
|
this.dom.appendChild(labelContainer);
|
|
54
|
-
} else
|
|
55
|
-
// Render the label into a separate container
|
|
56
|
-
//
|
|
57
|
-
// the ProseMirror contentDOM.
|
|
53
|
+
} else {
|
|
54
|
+
// Render the label into a separate container so portal implementations
|
|
55
|
+
// that write directly into the target do not clobber contentDOM.
|
|
58
56
|
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage -- NodeView DOM must be created against active runtime document
|
|
59
57
|
labelContainer = document.createElement('div');
|
|
60
58
|
this.dom.appendChild(labelContainer);
|
|
61
|
-
} else {
|
|
62
|
-
labelContainer = this.dom;
|
|
63
59
|
}
|
|
64
60
|
this.labelKey = crypto.randomUUID();
|
|
65
61
|
this.nodeViewPortalProviderAPI.render(function () {
|
|
@@ -18,7 +18,6 @@ var _errorBoundary = require("@atlaskit/editor-common/error-boundary");
|
|
|
18
18
|
var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
|
|
19
19
|
var _syncBlock = require("@atlaskit/editor-common/sync-block");
|
|
20
20
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
21
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
22
21
|
var _editorCommands = require("../editor-commands");
|
|
23
22
|
var _SyncBlockRendererWrapper = require("../ui/SyncBlockRendererWrapper");
|
|
24
23
|
var _SyncBlockSSRReactContextsProvider = require("../ui/SyncBlockSSRReactContextsProvider");
|
|
@@ -68,17 +67,15 @@ var SyncBlock = exports.SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
68
67
|
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage -- NodeView DOM must be created against active runtime document
|
|
69
68
|
var domRef = document.createElement('div');
|
|
70
69
|
domRef.classList.add(_syncBlock.SyncBlockSharedCssClassName.prefix);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
domRef.addEventListener('dragstart', this.dragStartHandler);
|
|
81
|
-
}
|
|
70
|
+
// Prevent native browser drag on the contentEditable="false" wrapper.
|
|
71
|
+
// Without this, clicking in empty space (outside the contentEditable
|
|
72
|
+
// renderer but inside the domRef) initiates a native element drag.
|
|
73
|
+
domRef.draggable = false;
|
|
74
|
+
this.dragStartHandler = function (e) {
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
};
|
|
77
|
+
// eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop, @repo/internal/dom-events/no-unsafe-event-listeners
|
|
78
|
+
domRef.addEventListener('dragstart', this.dragStartHandler);
|
|
82
79
|
return domRef;
|
|
83
80
|
}
|
|
84
81
|
|
|
@@ -111,9 +108,6 @@ var SyncBlock = exports.SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
111
108
|
}, {
|
|
112
109
|
key: "stopEvent",
|
|
113
110
|
value: function stopEvent(event) {
|
|
114
|
-
if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_14')) {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
111
|
var target = event.target;
|
|
118
112
|
if (!(target instanceof Element)) {
|
|
119
113
|
return false;
|
|
@@ -22,7 +22,6 @@ var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
|
22
22
|
var _view2 = require("@atlaskit/editor-prosemirror/view");
|
|
23
23
|
var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
|
|
24
24
|
var _utils2 = require("@atlaskit/editor-synced-block-provider/utils");
|
|
25
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
26
25
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
27
26
|
var _bodiedSyncedBlock = require("../nodeviews/bodiedSyncedBlock");
|
|
28
27
|
var _syncedBlock = require("../nodeviews/syncedBlock");
|
|
@@ -48,8 +47,7 @@ var syncedBlockPluginKey = exports.syncedBlockPluginKey = new _state.PluginKey('
|
|
|
48
47
|
* `deleteButton` (otherwise indistinguishable from a keyboard delete — both are
|
|
49
48
|
* plain ReplaceSteps). A separate key (rather than `syncedBlockPluginKey`, which
|
|
50
49
|
* carries plugin-state transitions read in `apply()`, or a bare string) keeps
|
|
51
|
-
* this transient signal uniquely namespaced and isolated.
|
|
52
|
-
* `platform_editor_blocks_patch_4`.
|
|
50
|
+
* this transient signal uniquely namespaced and isolated.
|
|
53
51
|
*/
|
|
54
52
|
var deleteMechanismMetaKey = exports.deleteMechanismMetaKey = new _state.PluginKey('syncedBlockDeleteMechanism');
|
|
55
53
|
var syncedBlockPromptedFeedbackMetaKey = new _state.PluginKey('syncedBlockPromptedFeedback');
|
|
@@ -58,8 +56,7 @@ var syncedBlockPromptedFeedbackMetaKey = new _state.PluginKey('syncedBlockPrompt
|
|
|
58
56
|
* Creation-type signals set by {@link createSyncedBlock} on the creating
|
|
59
57
|
* transaction. The async creation handler forwards them to the store manager,
|
|
60
58
|
* which attaches them to the `syncedBlockCreate` event. A dedicated key keeps
|
|
61
|
-
* this transient signal isolated from plugin state.
|
|
62
|
-
* `platform_editor_blocks_patch_4`.
|
|
59
|
+
* this transient signal isolated from plugin state.
|
|
63
60
|
*/
|
|
64
61
|
|
|
65
62
|
var creationMetaKey = exports.creationMetaKey = new _state.PluginKey('syncedBlockCreationMeta');
|
|
@@ -315,17 +312,9 @@ var filterTransactionOnline = function filterTransactionOnline(_ref3) {
|
|
|
315
312
|
});
|
|
316
313
|
});
|
|
317
314
|
if (bodiedSyncBlockRemoved.length > 0) {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
// platform_editor_blocks_patch_4 is on we instead recompute the delete fresh
|
|
322
|
-
// from the live document on confirm (see handleBodiedSyncBlockRemoval), so
|
|
323
|
-
// there is no need to stash the transaction here. See EDITOR-7889.
|
|
324
|
-
// eslint-disable-next-line no-param-reassign
|
|
325
|
-
confirmationTransactionRef.current = tr;
|
|
326
|
-
}
|
|
327
|
-
// Only derive the mechanism behind the gate — discarded gate-off.
|
|
328
|
-
var mechanism = (0, _platformFeatureFlags.fg)('platform_editor_blocks_patch_4') ? getDeleteMechanism(tr, state) : undefined;
|
|
315
|
+
// Recompute the delete fresh from the live document on confirm
|
|
316
|
+
// (see handleBodiedSyncBlockRemoval). See EDITOR-7889.
|
|
317
|
+
var mechanism = getDeleteMechanism(tr, state);
|
|
329
318
|
var feedbackContext = entryPoint && getDeleteReason(tr) !== 'source-block-unsynced' ? {
|
|
330
319
|
blockType: 'source',
|
|
331
320
|
entryPoint: entryPoint
|
|
@@ -363,7 +352,7 @@ var filterTransactionOnline = function filterTransactionOnline(_ref3) {
|
|
|
363
352
|
// be wrong. The bodiedSyncBlock content will still be inserted but will
|
|
364
353
|
// not be registered as a source block in Block Service, which is safer
|
|
365
354
|
// than creating a zombie block under the wrong ARI.
|
|
366
|
-
if (isPasteOrDrop
|
|
355
|
+
if (isPasteOrDrop) {
|
|
367
356
|
return true;
|
|
368
357
|
}
|
|
369
358
|
|
|
@@ -697,8 +686,8 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
697
686
|
var syncBlockNodes = instance.doc.children.filter(syncBlockStore.referenceManager.isReferenceBlock);
|
|
698
687
|
syncBlockStore.referenceManager.fetchSyncBlocksData((0, _editorSyncedBlockProvider.convertPMNodesToSyncBlockNodes)(syncBlockNodes));
|
|
699
688
|
|
|
700
|
-
// Populate source sync block cache from initial document
|
|
701
|
-
//
|
|
689
|
+
// Populate source sync block cache from initial document.
|
|
690
|
+
// This replaces the constructor call in the nodeview.
|
|
702
691
|
instance.doc.forEach(function (node) {
|
|
703
692
|
if (syncBlockStore.sourceManager.isSourceBlock(node)) {
|
|
704
693
|
syncBlockStore.sourceManager.updateSyncBlockData(node, false);
|
|
@@ -930,18 +919,12 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
930
919
|
return false;
|
|
931
920
|
},
|
|
932
921
|
cut: function cut() {
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
ctx.markCutEvent();
|
|
936
|
-
}
|
|
922
|
+
ctx.consumeCutEvent();
|
|
923
|
+
ctx.markCutEvent();
|
|
937
924
|
return false;
|
|
938
925
|
}
|
|
939
926
|
},
|
|
940
927
|
transformPasted: function transformPasted(slice, _view) {
|
|
941
|
-
if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_13')) {
|
|
942
|
-
return slice;
|
|
943
|
-
}
|
|
944
|
-
|
|
945
928
|
// Defense against bodiedSyncBlock nodes arriving via paste
|
|
946
929
|
// (e.g. drag-and-drop, cut-paste, or browser-level clipboard
|
|
947
930
|
// operations that bypass the transformCopied handler).
|
|
@@ -967,9 +950,8 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
967
950
|
var syncBlockStore = pluginState === null || pluginState === void 0 ? void 0 : pluginState.syncBlockStore;
|
|
968
951
|
var schema = state.schema;
|
|
969
952
|
var isCopy = ctx.consumeCopyEvent();
|
|
970
|
-
var isSyncedBlockPatch13Enabled = (0, _platformFeatureFlags.fg)('platform_synced_block_patch_13');
|
|
971
953
|
var wasCut = ctx.consumeCutEvent();
|
|
972
|
-
var isCut =
|
|
954
|
+
var isCut = wasCut;
|
|
973
955
|
var isPromptedFeedbackCut = Boolean(syncBlockStore && (options === null || options === void 0 ? void 0 : options.onGiveFeedback) && wasCut) && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_sync_block_activation', 'isEnabled', true);
|
|
974
956
|
if (!syncBlockStore || !isCopy && !isCut && !isPromptedFeedbackCut) {
|
|
975
957
|
return slice;
|
|
@@ -1007,7 +989,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
1007
989
|
if (!(0, _utils3.sliceFullyContainsNode)(slice, node)) {
|
|
1008
990
|
return node.content;
|
|
1009
991
|
}
|
|
1010
|
-
if (
|
|
992
|
+
if (isCut) {
|
|
1011
993
|
return node;
|
|
1012
994
|
}
|
|
1013
995
|
var newResourceId = syncBlockStore.referenceManager.generateResourceIdForReference(node.attrs.resourceId);
|
|
@@ -1164,18 +1146,8 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
1164
1146
|
});
|
|
1165
1147
|
}
|
|
1166
1148
|
|
|
1167
|
-
//
|
|
1168
|
-
//
|
|
1169
|
-
// no stashed transaction to rebase here. See EDITOR-7889.
|
|
1170
|
-
if (!(0, _platformFeatureFlags.fg)('platform_editor_blocks_patch_4')) {
|
|
1171
|
-
trs.filter(function (tr) {
|
|
1172
|
-
return tr.docChanged;
|
|
1173
|
-
}).forEach(function (tr) {
|
|
1174
|
-
if (confirmationTransactionRef.current) {
|
|
1175
|
-
confirmationTransactionRef.current = (0, _editorSyncedBlockProvider.rebaseTransaction)(confirmationTransactionRef.current, tr, newState);
|
|
1176
|
-
}
|
|
1177
|
-
});
|
|
1178
|
-
}
|
|
1149
|
+
// Delete is recomputed fresh from the live document on confirm.
|
|
1150
|
+
// See EDITOR-7889.
|
|
1179
1151
|
var _iterator2 = _createForOfIteratorHelper(trs),
|
|
1180
1152
|
_step2;
|
|
1181
1153
|
try {
|
|
@@ -45,67 +45,49 @@ var handleBodiedSyncBlockRemoval = exports.handleBodiedSyncBlockRemoval = functi
|
|
|
45
45
|
syncBlockStore.sourceManager.deleteSyncBlocksWithConfirmation(bodiedSyncBlockRemoved.map(function (node) {
|
|
46
46
|
return node.attrs;
|
|
47
47
|
}), deletionReason, function () {
|
|
48
|
-
var _api$
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return node.attrs;
|
|
69
|
-
}));
|
|
48
|
+
var _api$core2;
|
|
49
|
+
// Recompute the delete fresh from the live document instead of
|
|
50
|
+
// replaying a stashed-and-rebased transaction. The stash/rebase
|
|
51
|
+
// approach produced stale, schema-invalid transactions when the
|
|
52
|
+
// document changed shape (local edits or remote collab) while the
|
|
53
|
+
// confirmation modal was open — the dominant signature being
|
|
54
|
+
// "Invalid content for node bodiedSyncBlock: <>". See EDITOR-7889.
|
|
55
|
+
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref2) {
|
|
56
|
+
var tr = _ref2.tr;
|
|
57
|
+
// EDITOR-8230: unsync must remove only the sync wrapper and keep the block's
|
|
58
|
+
// content inline, whereas delete removes the whole block. Before this branch,
|
|
59
|
+
// the confirm path always recomputed a full delete, so unsyncing a source block
|
|
60
|
+
// silently deleted its content. When the deletion was actually triggered by
|
|
61
|
+
// unsync, recompute an unwrap (replaceWith content) instead of a delete.
|
|
62
|
+
var isUnsync = (0, _platformFeatureFlags.fg)('platform_editor_blocks_patch_6') && deletionReason === 'source-block-unsynced';
|
|
63
|
+
var recomputedTr = isUnsync ? (0, _recomputeDeleteTransaction.recomputeUnsyncTransaction)(tr, syncBlockStore.sourceManager.isSourceBlock, bodiedSyncBlockRemoved.map(function (node) {
|
|
64
|
+
return node.attrs;
|
|
65
|
+
})) : (0, _recomputeDeleteTransaction.recomputeDeleteTransaction)(tr, syncBlockStore.sourceManager.isSourceBlock, bodiedSyncBlockRemoved.map(function (node) {
|
|
66
|
+
return node.attrs;
|
|
67
|
+
}));
|
|
70
68
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
// bodiedSyncBlock deletion is expected to be permanent (cannot undo)
|
|
84
|
-
// For a normal deletion (not triggered by undo), remove it from history so that it cannot be undone
|
|
85
|
-
recomputedTr.setMeta('addToHistory', false);
|
|
86
|
-
}
|
|
87
|
-
return recomputedTr;
|
|
88
|
-
});
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
var confirmationTransaction = confirmationTransactionRef.current;
|
|
92
|
-
if (!confirmationTransaction) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function () {
|
|
96
|
-
var trToDispatch = confirmationTransaction.setMeta('isConfirmedSyncBlockDeletion', true);
|
|
97
|
-
feedbackCallbacks === null || feedbackCallbacks === void 0 || feedbackCallbacks.onDeleteTransaction(trToDispatch);
|
|
98
|
-
if (!trToDispatch.getMeta(_utils.pmHistoryPluginKey)) {
|
|
69
|
+
// The target node(s) no longer exist in the live document (e.g.
|
|
70
|
+
// a remote collaborator already removed them). There is nothing
|
|
71
|
+
// to delete locally, so return `null` to skip the dispatch
|
|
72
|
+
// entirely — dispatching the untouched transaction would be a
|
|
73
|
+
// no-op that still runs the plugin's filter/append hooks. The
|
|
74
|
+
// backend deletion has already been issued by the store manager.
|
|
75
|
+
if (!recomputedTr) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
recomputedTr.setMeta('isConfirmedSyncBlockDeletion', true);
|
|
79
|
+
feedbackCallbacks === null || feedbackCallbacks === void 0 || feedbackCallbacks.onDeleteTransaction(recomputedTr);
|
|
80
|
+
if (!recomputedTr.getMeta(_utils.pmHistoryPluginKey)) {
|
|
99
81
|
// bodiedSyncBlock deletion is expected to be permanent (cannot undo)
|
|
100
82
|
// For a normal deletion (not triggered by undo), remove it from history so that it cannot be undone
|
|
101
|
-
|
|
83
|
+
recomputedTr.setMeta('addToHistory', false);
|
|
102
84
|
}
|
|
103
|
-
return
|
|
85
|
+
return recomputedTr;
|
|
104
86
|
});
|
|
105
87
|
}, function (success) {
|
|
106
|
-
var _api$
|
|
88
|
+
var _api$core3;
|
|
107
89
|
feedbackCallbacks === null || feedbackCallbacks === void 0 || feedbackCallbacks.onDeleteCompleted(success);
|
|
108
|
-
api === null || api === void 0 || (_api$
|
|
90
|
+
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref3) {
|
|
109
91
|
var tr = _ref3.tr;
|
|
110
92
|
var newState;
|
|
111
93
|
if (!success) {
|
|
@@ -9,7 +9,6 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
10
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
11
11
|
var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
|
|
12
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
12
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
14
13
|
var _editorActions = require("./editor-actions");
|
|
15
14
|
var _editorCommands = require("./editor-commands");
|
|
@@ -195,9 +194,7 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
|
|
|
195
194
|
// Destroy the SyncBlockStoreManager on editor unmount to cancel
|
|
196
195
|
// pending timers, subscriptions, and in-flight fetches.
|
|
197
196
|
destroy: function destroy() {
|
|
198
|
-
|
|
199
|
-
syncBlockStore.destroy();
|
|
200
|
-
}
|
|
197
|
+
syncBlockStore.destroy();
|
|
201
198
|
}
|
|
202
199
|
};
|
|
203
200
|
};
|
|
@@ -14,7 +14,6 @@ var _messages = require("@atlaskit/editor-common/messages");
|
|
|
14
14
|
var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
|
|
15
15
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
16
16
|
var _blockSynced = _interopRequireDefault(require("@atlaskit/icon-lab/core/block-synced"));
|
|
17
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
18
17
|
var _utils = require("../pm-plugins/utils/utils");
|
|
19
18
|
var _types = require("../types");
|
|
20
19
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
@@ -37,45 +36,34 @@ var CreateSyncedBlockButton = exports.CreateSyncedBlockButton = function CreateS
|
|
|
37
36
|
var canInsertEmptyBlock = Boolean(selection === null || selection === void 0 ? void 0 : selection.empty);
|
|
38
37
|
var isDisabled = Boolean((0, _editorPluginConnectivity.isOfflineMode)(mode) || !canBeConverted && !canInsertEmptyBlock);
|
|
39
38
|
var onClick = (0, _react.useCallback)(function () {
|
|
40
|
-
var _api$
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var result = api === null || api === void 0 ? void 0 : api.syncedBlock.commands.insertSyncedBlock(_analytics.INPUT_METHOD.SYNCED_BLOCK_TB)({
|
|
56
|
-
tr: tr
|
|
57
|
-
});
|
|
58
|
-
if (!result) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.commands) === null || _api$blockControls === void 0 || _api$blockControls.stopPreservingSelection()({
|
|
62
|
-
tr: tr
|
|
63
|
-
});
|
|
64
|
-
return tr;
|
|
39
|
+
var _api$core;
|
|
40
|
+
// Insert the synced block and stop preserving the selection in a single
|
|
41
|
+
// transaction so the caret that insertSyncedBlock places inside the new
|
|
42
|
+
// block survives (EDITOR-7949). The toolbar is not normally opened via the
|
|
43
|
+
// block menu, but stopping preservation is defensive and keeps behaviour
|
|
44
|
+
// consistent with the block-menu create item should preservation ever be
|
|
45
|
+
// active (e.g. a block is selected via block-controls). Then re-focus so
|
|
46
|
+
// the caret is active, but only when the transaction was actually
|
|
47
|
+
// dispatched — otherwise a failed insertion would still steal DOM focus
|
|
48
|
+
// into the editor (mirrors CreateSyncedBlockDropdownItem).
|
|
49
|
+
var dispatched = api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(function (_ref2) {
|
|
50
|
+
var _api$blockControls;
|
|
51
|
+
var tr = _ref2.tr;
|
|
52
|
+
var result = api === null || api === void 0 ? void 0 : api.syncedBlock.commands.insertSyncedBlock(_analytics.INPUT_METHOD.SYNCED_BLOCK_TB)({
|
|
53
|
+
tr: tr
|
|
65
54
|
});
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.focus();
|
|
55
|
+
if (!result) {
|
|
56
|
+
return null;
|
|
69
57
|
}
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref3) {
|
|
73
|
-
var tr = _ref3.tr;
|
|
74
|
-
return api === null || api === void 0 ? void 0 : api.syncedBlock.commands.insertSyncedBlock(_analytics.INPUT_METHOD.SYNCED_BLOCK_TB)({
|
|
58
|
+
api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.commands) === null || _api$blockControls === void 0 || _api$blockControls.stopPreservingSelection()({
|
|
75
59
|
tr: tr
|
|
76
60
|
});
|
|
61
|
+
return tr;
|
|
77
62
|
});
|
|
78
|
-
|
|
63
|
+
if (dispatched) {
|
|
64
|
+
var _api$core2;
|
|
65
|
+
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.focus();
|
|
66
|
+
}
|
|
79
67
|
}, [api]);
|
|
80
68
|
var message = intl.formatMessage(_messages.syncBlockMessages.syncBlockLabel);
|
|
81
69
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarTooltip, {
|
|
@@ -48,53 +48,42 @@ var CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownItem(_ref2
|
|
|
48
48
|
return null;
|
|
49
49
|
}
|
|
50
50
|
var onClick = function onClick() {
|
|
51
|
-
var _api$
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
var
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
var result = api === null || api === void 0 ? void 0 : api.syncedBlock.commands.insertSyncedBlock(_analytics.INPUT_METHOD.BLOCK_MENU)({
|
|
70
|
-
tr: tr
|
|
71
|
-
});
|
|
72
|
-
if (!result) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.commands) === null || _api$blockControls === void 0 || _api$blockControls.toggleBlockMenu({
|
|
76
|
-
closeMenu: true
|
|
77
|
-
})({
|
|
78
|
-
tr: tr
|
|
79
|
-
});
|
|
80
|
-
api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 || _api$blockControls2.stopPreservingSelection()({
|
|
81
|
-
tr: tr
|
|
82
|
-
});
|
|
83
|
-
return tr;
|
|
51
|
+
var _api$core;
|
|
52
|
+
// Insert the synced block, close the block menu, and stop preserving the
|
|
53
|
+
// selection — all in a single transaction, mirroring the block-menu delete
|
|
54
|
+
// item. Stopping preservation is required so the caret that
|
|
55
|
+
// insertSyncedBlock places inside the new block survives; otherwise
|
|
56
|
+
// block-controls restores a whole-node NodeSelection over it, hiding the
|
|
57
|
+
// caret (EDITOR-7949). Then re-focus the editor so the caret is active,
|
|
58
|
+
// but only when the transaction was actually dispatched — otherwise a
|
|
59
|
+
// failed insertion would still steal DOM focus into the editor.
|
|
60
|
+
var dispatched = api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(function (_ref3) {
|
|
61
|
+
var _api$blockControls, _api$blockControls2;
|
|
62
|
+
var tr = _ref3.tr;
|
|
63
|
+
// If the insertion fails, bail out without closing the menu or
|
|
64
|
+
// stopping selection preservation — otherwise we would dispatch an
|
|
65
|
+
// effectively-empty transaction and close the menu despite nothing
|
|
66
|
+
// having been inserted.
|
|
67
|
+
var result = api === null || api === void 0 ? void 0 : api.syncedBlock.commands.insertSyncedBlock(_analytics.INPUT_METHOD.BLOCK_MENU)({
|
|
68
|
+
tr: tr
|
|
84
69
|
});
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.focus();
|
|
70
|
+
if (!result) {
|
|
71
|
+
return null;
|
|
88
72
|
}
|
|
89
|
-
|
|
73
|
+
api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.commands) === null || _api$blockControls === void 0 || _api$blockControls.toggleBlockMenu({
|
|
74
|
+
closeMenu: true
|
|
75
|
+
})({
|
|
76
|
+
tr: tr
|
|
77
|
+
});
|
|
78
|
+
api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 || _api$blockControls2.stopPreservingSelection()({
|
|
79
|
+
tr: tr
|
|
80
|
+
});
|
|
81
|
+
return tr;
|
|
82
|
+
});
|
|
83
|
+
if (dispatched) {
|
|
84
|
+
var _api$core2;
|
|
85
|
+
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.focus();
|
|
90
86
|
}
|
|
91
|
-
|
|
92
|
-
// Legacy behaviour: insert then close the block menu as two separate executes
|
|
93
|
-
// (batching them caused selection collisions — EDITOR-2751).
|
|
94
|
-
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(api === null || api === void 0 ? void 0 : api.syncedBlock.commands.insertSyncedBlock(_analytics.INPUT_METHOD.BLOCK_MENU));
|
|
95
|
-
api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 || (_api$blockControls3 = _api$blockControls3.commands) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.toggleBlockMenu({
|
|
96
|
-
closeMenu: true
|
|
97
|
-
}));
|
|
98
87
|
};
|
|
99
88
|
var isOffline = (0, _editorPluginConnectivity.isOfflineMode)(mode);
|
|
100
89
|
var lozenge = /*#__PURE__*/_react.default.createElement(SyncedBlockNewLozenge, {
|
|
@@ -123,9 +112,9 @@ var CopySyncedBlockDropdownItem = function CopySyncedBlockDropdownItem(_ref4) {
|
|
|
123
112
|
}),
|
|
124
113
|
mode = _useSharedPluginState2.mode;
|
|
125
114
|
var onClick = function onClick() {
|
|
126
|
-
var _api$
|
|
127
|
-
api === null || api === void 0 || (_api$
|
|
128
|
-
api === null || api === void 0 || (_api$
|
|
115
|
+
var _api$core3, _api$core4, _api$blockControls3;
|
|
116
|
+
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(api === null || api === void 0 ? void 0 : api.syncedBlock.commands.copySyncedBlockReferenceToClipboard(_analytics.INPUT_METHOD.BLOCK_MENU));
|
|
117
|
+
api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 || (_api$blockControls3 = _api$blockControls3.commands) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.toggleBlockMenu({
|
|
129
118
|
closeMenu: true
|
|
130
119
|
}));
|
|
131
120
|
};
|