@atlaskit/editor-plugin-synced-block 8.3.2 → 8.3.4
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/AGENTS.md +1 -2
- package/CHANGELOG.md +26 -0
- package/dist/cjs/nodeviews/bodiedSyncedBlock.js +7 -25
- package/dist/cjs/nodeviews/syncedBlock.js +1 -4
- package/dist/cjs/pm-plugins/main.js +54 -60
- package/dist/cjs/pm-plugins/menu-and-toolbar-experiences.js +10 -19
- package/dist/cjs/pm-plugins/utils/utils.js +3 -10
- package/dist/cjs/syncedBlockPlugin.js +1 -7
- package/dist/cjs/ui/CreateSyncedBlockDropdownItem.js +23 -13
- package/dist/cjs/ui/DeleteConfirmationModal.js +29 -93
- package/dist/cjs/ui/SyncBlockLabel.js +1 -4
- package/dist/cjs/ui/SyncedLocationDropdown.js +2 -2
- package/dist/cjs/ui/floating-toolbar.js +1 -2
- package/dist/cjs/ui/quick-insert.js +2 -3
- package/dist/es2019/nodeviews/bodiedSyncedBlock.js +7 -23
- package/dist/es2019/nodeviews/syncedBlock.js +1 -4
- package/dist/es2019/pm-plugins/main.js +42 -48
- package/dist/es2019/pm-plugins/menu-and-toolbar-experiences.js +7 -19
- package/dist/es2019/pm-plugins/utils/utils.js +3 -11
- package/dist/es2019/syncedBlockPlugin.js +1 -7
- package/dist/es2019/ui/CreateSyncedBlockDropdownItem.js +15 -6
- package/dist/es2019/ui/DeleteConfirmationModal.js +36 -77
- package/dist/es2019/ui/SyncBlockLabel.js +1 -4
- package/dist/es2019/ui/SyncedLocationDropdown.js +2 -2
- package/dist/es2019/ui/floating-toolbar.js +1 -2
- package/dist/es2019/ui/quick-insert.js +2 -2
- package/dist/esm/nodeviews/bodiedSyncedBlock.js +7 -25
- package/dist/esm/nodeviews/syncedBlock.js +1 -4
- package/dist/esm/pm-plugins/main.js +54 -60
- package/dist/esm/pm-plugins/menu-and-toolbar-experiences.js +10 -19
- package/dist/esm/pm-plugins/utils/utils.js +3 -11
- package/dist/esm/syncedBlockPlugin.js +1 -7
- package/dist/esm/ui/CreateSyncedBlockDropdownItem.js +23 -13
- package/dist/esm/ui/DeleteConfirmationModal.js +29 -93
- package/dist/esm/ui/SyncBlockLabel.js +1 -4
- package/dist/esm/ui/SyncedLocationDropdown.js +2 -2
- package/dist/esm/ui/floating-toolbar.js +1 -2
- package/dist/esm/ui/quick-insert.js +2 -3
- package/dist/types/nodeviews/bodiedSyncedBlock.d.ts +1 -3
- package/dist/types-ts4.5/nodeviews/bodiedSyncedBlock.d.ts +1 -3
- package/docs/0-intro.tsx +1 -1
- package/package.json +8 -20
- package/dist/cjs/nodeviews/bodiedSyncBlockNodeWithToDOMFixed.js +0 -35
- package/dist/es2019/nodeviews/bodiedSyncBlockNodeWithToDOMFixed.js +0 -27
- package/dist/esm/nodeviews/bodiedSyncBlockNodeWithToDOMFixed.js +0 -28
- package/dist/types/nodeviews/bodiedSyncBlockNodeWithToDOMFixed.d.ts +0 -6
- package/dist/types-ts4.5/nodeviews/bodiedSyncBlockNodeWithToDOMFixed.d.ts +0 -6
package/AGENTS.md
CHANGED
|
@@ -35,8 +35,7 @@ src/
|
|
|
35
35
|
├── nodeviews/
|
|
36
36
|
│ ├── syncedBlock.tsx # NodeView for reference (syncBlock) — read-only, fetches from BE
|
|
37
37
|
│ ├── lazySyncedBlock.tsx # Lazy-loaded wrapper for syncedBlock (EDITOR-6928)
|
|
38
|
-
│
|
|
39
|
-
│ └── bodiedSyncBlockNodeWithToDOMFixed.ts # DOM serialization fix variant (experiment-gated)
|
|
38
|
+
│ └── bodiedSyncedBlock.tsx # NodeView for source (bodiedSyncBlock) — nested editor with content
|
|
40
39
|
├── pm-plugins/
|
|
41
40
|
│ ├── main.ts # Core state machine: lifecycle, creation, deletion, cache,
|
|
42
41
|
│ │ status decoration apply path (gated by editor_synced_block_perf)
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 8.3.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`4c459a2718b67`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4c459a2718b67) -
|
|
8
|
+
Clean up synced block feature gates
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 8.3.3
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`434b508cc2368`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/434b508cc2368) -
|
|
16
|
+
EDITOR-7104: Add `featured-section` placement to block menu selection extension API
|
|
17
|
+
- Add `featured-section` to `BlockMenuPlacement` type which registers a top-level section with a
|
|
18
|
+
separator
|
|
19
|
+
- Add `BLOCK_ACTIONS_TEMPLATE_SECTION` and `BLOCK_ACTIONS_FEATURED_EXTENSION_SECTION_KEYS`
|
|
20
|
+
constants to `editor-common`
|
|
21
|
+
- Render lozenge inline next to label text (not pushed to far right) for dropdown and nested
|
|
22
|
+
dropdown items
|
|
23
|
+
- Move "New" lozenge next to label for synced block dropdown items
|
|
24
|
+
- Block template/menu behaviour gated behind `platform_editor_block_menu_v2_patch_2`; synced-block
|
|
25
|
+
lozenge placement behaviour gated behind `platform_synced_block_patch_12`
|
|
26
|
+
|
|
27
|
+
- Updated dependencies
|
|
28
|
+
|
|
3
29
|
## 8.3.2
|
|
4
30
|
|
|
5
31
|
### 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)); }
|
|
@@ -172,14 +171,13 @@ var toDOM = function toDOM(node) {
|
|
|
172
171
|
}, 0]];
|
|
173
172
|
};
|
|
174
173
|
var BodiedSyncBlock = exports.BodiedSyncBlock = /*#__PURE__*/function () {
|
|
175
|
-
function BodiedSyncBlock(node, view, getPos, api, nodeViewPortalProviderAPI
|
|
174
|
+
function BodiedSyncBlock(node, view, getPos, api, nodeViewPortalProviderAPI) {
|
|
176
175
|
var _this4 = this;
|
|
177
176
|
(0, _classCallCheck2.default)(this, BodiedSyncBlock);
|
|
178
177
|
this.node = node;
|
|
179
178
|
this.view = view;
|
|
180
179
|
this.getPos = getPos;
|
|
181
180
|
this.api = api;
|
|
182
|
-
this.syncBlockStore = syncBlockStore;
|
|
183
181
|
this.nodeViewPortalProviderAPI = nodeViewPortalProviderAPI;
|
|
184
182
|
var _DOMSerializer$render2 = _model.DOMSerializer.renderSpec(document, toDOM(this.node)),
|
|
185
183
|
dom = _DOMSerializer$render2.dom,
|
|
@@ -205,12 +203,8 @@ var BodiedSyncBlock = exports.BodiedSyncBlock = /*#__PURE__*/function () {
|
|
|
205
203
|
this.handleConnectivityModeChange();
|
|
206
204
|
this.handleViewModeChange();
|
|
207
205
|
|
|
208
|
-
//
|
|
209
|
-
//
|
|
210
|
-
if (!(0, _platformFeatureFlags.fg)('platform_synced_block_update_refactor')) {
|
|
211
|
-
var _this$syncedBlockStor;
|
|
212
|
-
(_this$syncedBlockStor = this.syncedBlockStore) === null || _this$syncedBlockStor === void 0 || _this$syncedBlockStor.sourceManager.updateSyncBlockData(node, false);
|
|
213
|
-
}
|
|
206
|
+
// Cache is populated in state.init() and updated in appendTransaction,
|
|
207
|
+
// so no additional updateSyncBlockData call is needed here.
|
|
214
208
|
}
|
|
215
209
|
return (0, _createClass2.default)(BodiedSyncBlock, [{
|
|
216
210
|
key: "updateContentEditable",
|
|
@@ -253,26 +247,15 @@ var BodiedSyncBlock = exports.BodiedSyncBlock = /*#__PURE__*/function () {
|
|
|
253
247
|
});
|
|
254
248
|
}
|
|
255
249
|
}
|
|
256
|
-
}, {
|
|
257
|
-
key: "syncedBlockStore",
|
|
258
|
-
get: function get() {
|
|
259
|
-
var _this$api$syncedBlock2, _this$api1;
|
|
260
|
-
return (_this$api$syncedBlock2 = (_this$api1 = this.api) === null || _this$api1 === void 0 || (_this$api1 = _this$api1.syncedBlock.sharedState) === null || _this$api1 === void 0 || (_this$api1 = _this$api1.currentState()) === null || _this$api1 === void 0 ? void 0 : _this$api1.syncBlockStore) !== null && _this$api$syncedBlock2 !== void 0 ? _this$api$syncedBlock2 : this.syncBlockStore;
|
|
261
|
-
}
|
|
262
250
|
}, {
|
|
263
251
|
key: "update",
|
|
264
252
|
value: function update(node) {
|
|
265
253
|
if (this.node.type !== node.type) {
|
|
266
254
|
return false;
|
|
267
255
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
if (!(0, _platformFeatureFlags.fg)('platform_synced_block_update_refactor')) {
|
|
272
|
-
var _this$syncedBlockStor2;
|
|
273
|
-
(_this$syncedBlockStor2 = this.syncedBlockStore) === null || _this$syncedBlockStor2 === void 0 || _this$syncedBlockStor2.sourceManager.updateSyncBlockData(node, false);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
256
|
+
|
|
257
|
+
// Cache updates are handled in appendTransaction where we can
|
|
258
|
+
// filter out non-user changes (remote collab, table auto-scale, etc.)
|
|
276
259
|
this.node = node;
|
|
277
260
|
return true;
|
|
278
261
|
}
|
|
@@ -296,9 +279,8 @@ var BodiedSyncBlock = exports.BodiedSyncBlock = /*#__PURE__*/function () {
|
|
|
296
279
|
}();
|
|
297
280
|
var bodiedSyncBlockNodeView = exports.bodiedSyncBlockNodeView = function bodiedSyncBlockNodeView(props) {
|
|
298
281
|
var api = props.api,
|
|
299
|
-
syncBlockStore = props.syncBlockStore,
|
|
300
282
|
nodeViewPortalProviderAPI = props.pmPluginFactoryParams.nodeViewPortalProviderAPI;
|
|
301
283
|
return function (node, view, getPos) {
|
|
302
|
-
return new BodiedSyncBlock(node, view, getPos, api, nodeViewPortalProviderAPI
|
|
284
|
+
return new BodiedSyncBlock(node, view, getPos, api, nodeViewPortalProviderAPI);
|
|
303
285
|
};
|
|
304
286
|
};
|
|
@@ -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 _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
21
|
-
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
22
21
|
var _editorCommands = require("../editor-commands");
|
|
23
22
|
var _SyncBlockRendererWrapper = require("../ui/SyncBlockRendererWrapper");
|
|
24
23
|
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)); }
|
|
@@ -68,9 +67,7 @@ var SyncBlock = exports.SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
68
67
|
}, {
|
|
69
68
|
key: "update",
|
|
70
69
|
value: function update(node, decorations, innerDecorations) {
|
|
71
|
-
return _superPropGet(SyncBlock, "update", this, 3)([node, decorations, innerDecorations,
|
|
72
|
-
exposure: true
|
|
73
|
-
}) ? this.validUpdate : undefined]);
|
|
70
|
+
return _superPropGet(SyncBlock, "update", this, 3)([node, decorations, innerDecorations, this.validUpdate]);
|
|
74
71
|
}
|
|
75
72
|
}, {
|
|
76
73
|
key: "render",
|
|
@@ -369,18 +369,14 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
369
369
|
|
|
370
370
|
// Populate source sync block cache from initial document
|
|
371
371
|
// When fg is ON, this replaces the constructor call in the nodeview
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
syncBlockStore.sourceManager.updateSyncBlockData(node, false);
|
|
376
|
-
}
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
// Fetch statuses from the backend so we can identify unpublished blocks on cancel
|
|
380
|
-
if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_10')) {
|
|
381
|
-
syncBlockStore.sourceManager.fetchAndCacheStatuses();
|
|
372
|
+
instance.doc.forEach(function (node) {
|
|
373
|
+
if (syncBlockStore.sourceManager.isSourceBlock(node)) {
|
|
374
|
+
syncBlockStore.sourceManager.updateSyncBlockData(node, false);
|
|
382
375
|
}
|
|
383
|
-
}
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
// Fetch statuses from the backend so we can identify unpublished blocks on cancel
|
|
379
|
+
syncBlockStore.sourceManager.fetchAndCacheStatuses();
|
|
384
380
|
}
|
|
385
381
|
|
|
386
382
|
// Read initial shared-state signals for status decorations
|
|
@@ -693,7 +689,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
693
689
|
}
|
|
694
690
|
}
|
|
695
691
|
var viewMode = api === null || api === void 0 || (_api$editorViewMode4 = api.editorViewMode) === null || _api$editorViewMode4 === void 0 || (_api$editorViewMode4 = _api$editorViewMode4.sharedState.currentState()) === null || _api$editorViewMode4 === void 0 ? void 0 : _api$editorViewMode4.mode;
|
|
696
|
-
if (viewMode === 'view'
|
|
692
|
+
if (viewMode === 'view') {
|
|
697
693
|
return true;
|
|
698
694
|
}
|
|
699
695
|
var isOffline = (0, _editorPluginConnectivity.isOfflineMode)(api === null || api === void 0 || (_api$connectivity5 = api.connectivity) === null || _api$connectivity5 === void 0 || (_api$connectivity5 = _api$connectivity5.sharedState.currentState()) === null || _api$connectivity5 === void 0 ? void 0 : _api$connectivity5.mode);
|
|
@@ -710,40 +706,39 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
710
706
|
}
|
|
711
707
|
});
|
|
712
708
|
}
|
|
713
|
-
if ((0, _platformFeatureFlags.fg)('platform_synced_block_update_refactor')) {
|
|
714
|
-
// if doc changed and it's a remote transaction, check if any synced block were added,
|
|
715
|
-
// and if so, for source synced blocks, ensure we update the cache with them
|
|
716
|
-
// and for reference synced blocks, ensure we fetch the data from the server
|
|
717
|
-
if (tr.docChanged && tr.getMeta('isRemote')) {
|
|
718
|
-
var _trackSyncBlocks4 = (0, _trackSyncBlocks7.trackSyncBlocks)(function (node) {
|
|
719
|
-
return syncBlockStore.isSyncBlock(node);
|
|
720
|
-
}, tr, state),
|
|
721
|
-
_added = _trackSyncBlocks4.added;
|
|
722
|
-
var sourceSyncBlockNodes = _added.filter(function (nodeInfo) {
|
|
723
|
-
return nodeInfo.node && syncBlockStore.sourceManager.isSourceBlock(nodeInfo.node);
|
|
724
|
-
});
|
|
725
|
-
var referenceSyncBlockNodes = _added.filter(function (nodeInfo) {
|
|
726
|
-
return nodeInfo.node && syncBlockStore.referenceManager.isReferenceBlock(nodeInfo.node);
|
|
727
|
-
});
|
|
728
|
-
sourceSyncBlockNodes.forEach(function (nodeInfo) {
|
|
729
|
-
var _nodeInfo$attrs2;
|
|
730
|
-
if ((_nodeInfo$attrs2 = nodeInfo.attrs) !== null && _nodeInfo$attrs2 !== void 0 && _nodeInfo$attrs2.resourceId && nodeInfo.node) {
|
|
731
|
-
syncBlockStore.sourceManager.updateSyncBlockData(nodeInfo.node, tr.getMeta('isRemote'));
|
|
732
|
-
}
|
|
733
|
-
});
|
|
734
709
|
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
710
|
+
// if doc changed and it's a remote transaction, check if any synced block were added,
|
|
711
|
+
// and if so, for source synced blocks, ensure we update the cache with them
|
|
712
|
+
// and for reference synced blocks, ensure we fetch the data from the server
|
|
713
|
+
if (tr.docChanged && tr.getMeta('isRemote')) {
|
|
714
|
+
var _trackSyncBlocks4 = (0, _trackSyncBlocks7.trackSyncBlocks)(function (node) {
|
|
715
|
+
return syncBlockStore.isSyncBlock(node);
|
|
716
|
+
}, tr, state),
|
|
717
|
+
_added = _trackSyncBlocks4.added;
|
|
718
|
+
var sourceSyncBlockNodes = _added.filter(function (nodeInfo) {
|
|
719
|
+
return nodeInfo.node && syncBlockStore.sourceManager.isSourceBlock(nodeInfo.node);
|
|
720
|
+
});
|
|
721
|
+
var referenceSyncBlockNodes = _added.filter(function (nodeInfo) {
|
|
722
|
+
return nodeInfo.node && syncBlockStore.referenceManager.isReferenceBlock(nodeInfo.node);
|
|
723
|
+
});
|
|
724
|
+
sourceSyncBlockNodes.forEach(function (nodeInfo) {
|
|
725
|
+
var _nodeInfo$attrs2;
|
|
726
|
+
if ((_nodeInfo$attrs2 = nodeInfo.attrs) !== null && _nodeInfo$attrs2 !== void 0 && _nodeInfo$attrs2.resourceId && nodeInfo.node) {
|
|
727
|
+
syncBlockStore.sourceManager.updateSyncBlockData(nodeInfo.node, tr.getMeta('isRemote'));
|
|
739
728
|
}
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
syncBlockStore.
|
|
729
|
+
});
|
|
730
|
+
|
|
731
|
+
// Fetch statuses for remotely-added source sync blocks
|
|
732
|
+
// so we can identify unpublished blocks on cancel
|
|
733
|
+
if (sourceSyncBlockNodes.length > 0) {
|
|
734
|
+
syncBlockStore.sourceManager.fetchAndCacheStatuses();
|
|
746
735
|
}
|
|
736
|
+
var syncBlockNodes = referenceSyncBlockNodes.map(function (nodeInfo) {
|
|
737
|
+
return nodeInfo.node;
|
|
738
|
+
}).filter(function (node) {
|
|
739
|
+
return node !== undefined;
|
|
740
|
+
});
|
|
741
|
+
syncBlockStore.referenceManager.fetchSyncBlocksData((0, _editorSyncedBlockProvider.convertPMNodesToSyncBlockNodes)(syncBlockNodes));
|
|
747
742
|
}
|
|
748
743
|
if (!tr.docChanged || Boolean(tr.getMeta('isRemote')) || !isOffline && isConfirmedSyncBlockDeletion) {
|
|
749
744
|
return true;
|
|
@@ -785,26 +780,25 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
785
780
|
}
|
|
786
781
|
}
|
|
787
782
|
var viewMode = api === null || api === void 0 || (_api$editorViewMode5 = api.editorViewMode) === null || _api$editorViewMode5 === void 0 || (_api$editorViewMode5 = _api$editorViewMode5.sharedState.currentState()) === null || _api$editorViewMode5 === void 0 ? void 0 : _api$editorViewMode5.mode;
|
|
788
|
-
if (viewMode === 'view'
|
|
783
|
+
if (viewMode === 'view') {
|
|
789
784
|
return null;
|
|
790
785
|
}
|
|
791
786
|
|
|
792
|
-
// Update source sync block cache for user-initiated changes only
|
|
793
|
-
//
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
787
|
+
// Update source sync block cache for user-initiated changes only.
|
|
788
|
+
// Cache updates are handled here instead of in the nodeview update() so we
|
|
789
|
+
// can filter out non-user changes (remote collab, dirty programmatic txns).
|
|
790
|
+
var isUserChange = function isUserChange(tr) {
|
|
791
|
+
return tr.docChanged && !(0, _collab.isDirtyTransaction)(tr) && !tr.getMeta('isRemote');
|
|
792
|
+
};
|
|
793
|
+
var hasSourceBlockEdit = trs.some(function (tr) {
|
|
794
|
+
return isUserChange(tr) && (0, _trackSyncBlocks7.hasEditInSyncBlock)(tr, oldState);
|
|
795
|
+
});
|
|
796
|
+
if (hasSourceBlockEdit) {
|
|
797
|
+
newState.doc.forEach(function (node) {
|
|
798
|
+
if (syncBlockStore.sourceManager.isSourceBlock(node)) {
|
|
799
|
+
syncBlockStore.sourceManager.updateSyncBlockData(node, false);
|
|
800
|
+
}
|
|
800
801
|
});
|
|
801
|
-
if (hasSourceBlockEdit) {
|
|
802
|
-
newState.doc.forEach(function (node) {
|
|
803
|
-
if (syncBlockStore.sourceManager.isSourceBlock(node)) {
|
|
804
|
-
syncBlockStore.sourceManager.updateSyncBlockData(node, false);
|
|
805
|
-
}
|
|
806
|
-
});
|
|
807
|
-
}
|
|
808
802
|
}
|
|
809
803
|
trs.filter(function (tr) {
|
|
810
804
|
return tr.docChanged;
|
|
@@ -855,7 +849,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
855
849
|
}
|
|
856
850
|
if (trs.some(function (tr) {
|
|
857
851
|
return tr.docChanged && !tr.getMeta('isRemote');
|
|
858
|
-
})
|
|
852
|
+
})) {
|
|
859
853
|
// Quick check: only walk the full document when at least one
|
|
860
854
|
// transaction inserted a source synced block. This avoids an
|
|
861
855
|
// expensive descendants() traversal on every local edit.
|
|
@@ -11,7 +11,6 @@ var _analytics = require("@atlaskit/editor-common/analytics");
|
|
|
11
11
|
var _experiences = require("@atlaskit/editor-common/experiences");
|
|
12
12
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
13
13
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
14
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
16
15
|
var _types = require("../types");
|
|
17
16
|
var _main = require("./main");
|
|
@@ -19,7 +18,6 @@ var TIMEOUT_DURATION = 30000;
|
|
|
19
18
|
var pluginKey = new _state.PluginKey('syncedBlockMenuAndToolbarExperience');
|
|
20
19
|
var SYNCED_BLOCK_BUTTON_TEST_IDS = Object.values(_types.SYNCED_BLOCK_BUTTON_TEST_ID);
|
|
21
20
|
var syncedBlockButtonIds = new Set(SYNCED_BLOCK_BUTTON_TEST_IDS);
|
|
22
|
-
var targetEl;
|
|
23
21
|
var getMenuAndToolbarExperiencesPlugin = exports.getMenuAndToolbarExperiencesPlugin = function getMenuAndToolbarExperiencesPlugin(_ref) {
|
|
24
22
|
var refs = _ref.refs,
|
|
25
23
|
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent;
|
|
@@ -146,7 +144,7 @@ var getMenuAndToolbarExperiencesPlugin = exports.getMenuAndToolbarExperiencesPlu
|
|
|
146
144
|
if (!typeaheadPopup || !(typeaheadPopup instanceof HTMLElement)) {
|
|
147
145
|
return;
|
|
148
146
|
}
|
|
149
|
-
var targetElement =
|
|
147
|
+
var targetElement = typeaheadPopup.querySelector('[role="option"][aria-selected="true"]');
|
|
150
148
|
if (!targetElement || !(targetElement instanceof HTMLElement)) {
|
|
151
149
|
return;
|
|
152
150
|
}
|
|
@@ -303,16 +301,6 @@ var handleButtonClick = function handleButtonClick(_ref2) {
|
|
|
303
301
|
var isEnterKey = function isEnterKey(key) {
|
|
304
302
|
return key === 'Enter';
|
|
305
303
|
};
|
|
306
|
-
var getTarget = function getTarget(containerElement) {
|
|
307
|
-
if (!targetEl) {
|
|
308
|
-
var element = containerElement === null || containerElement === void 0 ? void 0 : containerElement.querySelector('.ProseMirror');
|
|
309
|
-
if (!element || !(element instanceof HTMLElement)) {
|
|
310
|
-
return null;
|
|
311
|
-
}
|
|
312
|
-
targetEl = element;
|
|
313
|
-
}
|
|
314
|
-
return targetEl;
|
|
315
|
-
};
|
|
316
304
|
var syncedBlockAddedToDomCheck = function syncedBlockAddedToDomCheck(refs, editorViewRef) {
|
|
317
305
|
return new _experiences.ExperienceCheckDomMutation({
|
|
318
306
|
onDomMutation: function onDomMutation(_ref3) {
|
|
@@ -327,17 +315,20 @@ var syncedBlockAddedToDomCheck = function syncedBlockAddedToDomCheck(refs, edito
|
|
|
327
315
|
observeConfig: function observeConfig() {
|
|
328
316
|
var _editorViewRef$curren2;
|
|
329
317
|
return [{
|
|
330
|
-
target:
|
|
318
|
+
target: editorViewRef === null || editorViewRef === void 0 || (_editorViewRef$curren2 = editorViewRef.current) === null || _editorViewRef$curren2 === void 0 ? void 0 : _editorViewRef$curren2.dom,
|
|
331
319
|
options: {
|
|
332
320
|
childList: true
|
|
333
321
|
}
|
|
334
|
-
}
|
|
322
|
+
},
|
|
323
|
+
// When wrapping a node with breakout mark with sync block, breakout dom is reused
|
|
324
|
+
// hence we need to observe subtree to catch sync block mutation
|
|
325
|
+
{
|
|
335
326
|
target: (0, _experiences.getSelectionAncestorDOM)(editorViewRef === null || editorViewRef === void 0 ? void 0 : editorViewRef.current),
|
|
336
327
|
options: {
|
|
337
328
|
childList: true,
|
|
338
329
|
subtree: true
|
|
339
330
|
}
|
|
340
|
-
}]
|
|
331
|
+
}];
|
|
341
332
|
}
|
|
342
333
|
});
|
|
343
334
|
};
|
|
@@ -363,17 +354,17 @@ var referenceSyncBlockRemovedFromDomCheck = function referenceSyncBlockRemovedFr
|
|
|
363
354
|
observeConfig: function observeConfig() {
|
|
364
355
|
var _editorViewRef$curren3;
|
|
365
356
|
return [{
|
|
366
|
-
target:
|
|
357
|
+
target: editorViewRef === null || editorViewRef === void 0 || (_editorViewRef$curren3 = editorViewRef.current) === null || _editorViewRef$curren3 === void 0 ? void 0 : _editorViewRef$curren3.dom,
|
|
367
358
|
options: {
|
|
368
359
|
childList: true
|
|
369
360
|
}
|
|
370
|
-
}
|
|
361
|
+
}, {
|
|
371
362
|
target: (0, _experiences.getSelectionAncestorDOM)(editorViewRef === null || editorViewRef === void 0 ? void 0 : editorViewRef.current),
|
|
372
363
|
options: {
|
|
373
364
|
childList: true,
|
|
374
365
|
subtree: true
|
|
375
366
|
}
|
|
376
|
-
}]
|
|
367
|
+
}];
|
|
377
368
|
}
|
|
378
369
|
});
|
|
379
370
|
};
|
|
@@ -8,7 +8,6 @@ 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 _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
11
|
/**
|
|
13
12
|
* Defers a callback to the next microtask (when gated) or next macrotask via setTimeout(0).
|
|
14
13
|
* Used to avoid re-entrant ProseMirror dispatch cycles.
|
|
@@ -102,9 +101,7 @@ var _fragmentContainsExtension = function fragmentContainsExtension(fragment) {
|
|
|
102
101
|
if (found) {
|
|
103
102
|
return;
|
|
104
103
|
}
|
|
105
|
-
if ((
|
|
106
|
-
exposure: true
|
|
107
|
-
}) ? EXTENSION_NODES.has(node.type.name) : node.type.name === 'inlineExtension') {
|
|
104
|
+
if (EXTENSION_NODES.has(node.type.name)) {
|
|
108
105
|
found = true;
|
|
109
106
|
} else if (node.content.size) {
|
|
110
107
|
if (_fragmentContainsExtension(node.content)) {
|
|
@@ -165,17 +162,13 @@ var wasExtensionInsertedInBodiedSyncBlock = exports.wasExtensionInsertedInBodied
|
|
|
165
162
|
if (resourceId !== undefined) {
|
|
166
163
|
return false;
|
|
167
164
|
}
|
|
168
|
-
if ((
|
|
169
|
-
exposure: true
|
|
170
|
-
}) ? EXTENSION_NODES.has(node.type.name) : node.type.name === 'inlineExtension') {
|
|
165
|
+
if (EXTENSION_NODES.has(node.type.name)) {
|
|
171
166
|
var _$pos = tr.doc.resolve(pos);
|
|
172
167
|
var _parent = (0, _utils.findParentNodeOfTypeClosestToPos)(_$pos, bodiedSyncBlock);
|
|
173
168
|
if (_parent !== null && _parent !== void 0 && _parent.node.attrs.resourceId) {
|
|
174
169
|
var mappedPos = tr.mapping.invert().map(pos);
|
|
175
170
|
var nodeBefore = state.doc.nodeAt(mappedPos);
|
|
176
|
-
if (!nodeBefore || (
|
|
177
|
-
exposure: true
|
|
178
|
-
}) ? EXTENSION_NODES.has(nodeBefore.type.name) : nodeBefore.type.name !== 'inlineExtension')) {
|
|
171
|
+
if (!nodeBefore || EXTENSION_NODES.has(nodeBefore.type.name)) {
|
|
179
172
|
resourceId = _parent.node.attrs.resourceId;
|
|
180
173
|
return false;
|
|
181
174
|
}
|
|
@@ -11,10 +11,8 @@ var _hooks = require("@atlaskit/editor-common/hooks");
|
|
|
11
11
|
var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
|
|
12
12
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
13
13
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
14
|
-
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
15
14
|
var _editorActions = require("./editor-actions");
|
|
16
15
|
var _editorCommands = require("./editor-commands");
|
|
17
|
-
var _bodiedSyncBlockNodeWithToDOMFixed = require("./nodeviews/bodiedSyncBlockNodeWithToDOMFixed");
|
|
18
16
|
var _main = require("./pm-plugins/main");
|
|
19
17
|
var _menuAndToolbarExperiences = require("./pm-plugins/menu-and-toolbar-experiences");
|
|
20
18
|
var _blockMenuComponents = require("./ui/block-menu-components");
|
|
@@ -82,11 +80,7 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
|
|
|
82
80
|
node: _adfSchema.syncBlock
|
|
83
81
|
}, {
|
|
84
82
|
name: 'bodiedSyncBlock',
|
|
85
|
-
node:
|
|
86
|
-
exposure: true
|
|
87
|
-
}) ?
|
|
88
|
-
// delete bodiedSyncBlockNodeWithToDOMFixed when cleaning up platform_synced_block_patch_6
|
|
89
|
-
(0, _bodiedSyncBlockNodeWithToDOMFixed.bodiedSyncBlockNodeWithToDOMFixed)() : _adfSchema.bodiedSyncBlock
|
|
83
|
+
node: _adfSchema.bodiedSyncBlock
|
|
90
84
|
}];
|
|
91
85
|
},
|
|
92
86
|
pmPlugins: function pmPlugins() {
|
|
@@ -18,8 +18,14 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
|
18
18
|
var _utils = require("../pm-plugins/utils/utils");
|
|
19
19
|
var _types = require("../types");
|
|
20
20
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
21
|
-
var
|
|
22
|
-
var
|
|
21
|
+
var SyncedBlockNewLozenge = function SyncedBlockNewLozenge(_ref) {
|
|
22
|
+
var label = _ref.label;
|
|
23
|
+
return /*#__PURE__*/_react.default.createElement(_lozenge.default, {
|
|
24
|
+
appearance: (0, _platformFeatureFlags.fg)('confluence_fronend_labels_categorization_migration') ? 'discovery' : 'new'
|
|
25
|
+
}, label);
|
|
26
|
+
};
|
|
27
|
+
var CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownItem(_ref2) {
|
|
28
|
+
var api = _ref2.api;
|
|
23
29
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
24
30
|
formatMessage = _useIntl.formatMessage;
|
|
25
31
|
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['selection', 'blockControls', 'connectivity'], function (states) {
|
|
@@ -48,6 +54,9 @@ var CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownItem(_ref)
|
|
|
48
54
|
}));
|
|
49
55
|
};
|
|
50
56
|
var isOffline = (0, _editorPluginConnectivity.isOfflineMode)(mode);
|
|
57
|
+
var lozenge = /*#__PURE__*/_react.default.createElement(SyncedBlockNewLozenge, {
|
|
58
|
+
label: formatMessage(_messages.blockMenuMessages.newLozenge)
|
|
59
|
+
});
|
|
51
60
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
52
61
|
elemBefore: /*#__PURE__*/_react.default.createElement(_editorToolbar.SyncBlocksIcon, {
|
|
53
62
|
label: "",
|
|
@@ -56,13 +65,12 @@ var CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownItem(_ref)
|
|
|
56
65
|
onClick: onClick,
|
|
57
66
|
isDisabled: isOffline,
|
|
58
67
|
testId: _types.SYNCED_BLOCK_BUTTON_TEST_ID.blockMenuCreate,
|
|
59
|
-
elemAfter:
|
|
60
|
-
|
|
61
|
-
}, formatMessage(_messages.blockMenuMessages.newLozenge))
|
|
68
|
+
elemAfter: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_12') ? undefined : lozenge,
|
|
69
|
+
elemAfterText: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_12') ? lozenge : undefined
|
|
62
70
|
}, formatMessage(_messages.blockMenuMessages.syncBlock));
|
|
63
71
|
};
|
|
64
|
-
var CopySyncedBlockDropdownItem = function CopySyncedBlockDropdownItem(
|
|
65
|
-
var api =
|
|
72
|
+
var CopySyncedBlockDropdownItem = function CopySyncedBlockDropdownItem(_ref3) {
|
|
73
|
+
var api = _ref3.api;
|
|
66
74
|
var _useIntl2 = (0, _reactIntl.useIntl)(),
|
|
67
75
|
formatMessage = _useIntl2.formatMessage;
|
|
68
76
|
var _useSharedPluginState2 = (0, _hooks.useSharedPluginStateWithSelector)(api, ['connectivity'], function (states) {
|
|
@@ -79,6 +87,9 @@ var CopySyncedBlockDropdownItem = function CopySyncedBlockDropdownItem(_ref2) {
|
|
|
79
87
|
closeMenu: true
|
|
80
88
|
}));
|
|
81
89
|
};
|
|
90
|
+
var lozenge = /*#__PURE__*/_react.default.createElement(SyncedBlockNewLozenge, {
|
|
91
|
+
label: formatMessage(_messages.blockMenuMessages.newLozenge)
|
|
92
|
+
});
|
|
82
93
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
83
94
|
elemBefore: /*#__PURE__*/_react.default.createElement(_editorToolbar.SyncBlocksIcon, {
|
|
84
95
|
label: "",
|
|
@@ -86,14 +97,13 @@ var CopySyncedBlockDropdownItem = function CopySyncedBlockDropdownItem(_ref2) {
|
|
|
86
97
|
}),
|
|
87
98
|
onClick: onClick,
|
|
88
99
|
isDisabled: (0, _editorPluginConnectivity.isOfflineMode)(mode),
|
|
89
|
-
elemAfter:
|
|
90
|
-
|
|
91
|
-
}, formatMessage(_messages.blockMenuMessages.newLozenge))
|
|
100
|
+
elemAfter: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_12') ? undefined : lozenge,
|
|
101
|
+
elemAfterText: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_12') ? lozenge : undefined
|
|
92
102
|
}, formatMessage(_messages.blockMenuMessages.copySyncedBlock));
|
|
93
103
|
};
|
|
94
|
-
var CreateOrCopySyncedBlockDropdownItem = exports.CreateOrCopySyncedBlockDropdownItem = function CreateOrCopySyncedBlockDropdownItem(
|
|
95
|
-
var api =
|
|
96
|
-
enableSourceSyncedBlockCreation =
|
|
104
|
+
var CreateOrCopySyncedBlockDropdownItem = exports.CreateOrCopySyncedBlockDropdownItem = function CreateOrCopySyncedBlockDropdownItem(_ref4) {
|
|
105
|
+
var api = _ref4.api,
|
|
106
|
+
enableSourceSyncedBlockCreation = _ref4.enableSourceSyncedBlockCreation;
|
|
97
107
|
var _useSharedPluginState3 = (0, _hooks.useSharedPluginStateWithSelector)(api, ['blockControls'], function (states) {
|
|
98
108
|
var _states$blockControls3, _states$blockControls4;
|
|
99
109
|
return {
|