@atlaskit/editor-plugin-synced-block 5.4.4 → 5.4.5

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/afm-cc/tsconfig.json +12 -0
  3. package/afm-jira/tsconfig.json +12 -0
  4. package/afm-products/tsconfig.json +12 -0
  5. package/dist/cjs/nodeviews/bodiedLazySyncedBlock.js +1 -0
  6. package/dist/cjs/nodeviews/bodiedSyncedBlock.js +137 -11
  7. package/dist/cjs/pm-plugins/main.js +18 -3
  8. package/dist/cjs/syncedBlockPlugin.js +8 -1
  9. package/dist/cjs/ui/BodiedSyncBlockWrapper.js +1 -0
  10. package/dist/cjs/ui/DeleteConfirmationModal.js +1 -1
  11. package/dist/cjs/ui/SyncBlockLabel.js +4 -1
  12. package/dist/cjs/ui/SyncedLocationDropdown.js +1 -1
  13. package/dist/cjs/ui/quick-insert.js +1 -1
  14. package/dist/es2019/nodeviews/bodiedLazySyncedBlock.js +1 -0
  15. package/dist/es2019/nodeviews/bodiedSyncedBlock.js +121 -6
  16. package/dist/es2019/pm-plugins/main.js +19 -4
  17. package/dist/es2019/syncedBlockPlugin.js +8 -1
  18. package/dist/es2019/ui/BodiedSyncBlockWrapper.js +1 -0
  19. package/dist/es2019/ui/DeleteConfirmationModal.js +1 -1
  20. package/dist/es2019/ui/SyncBlockLabel.js +4 -1
  21. package/dist/es2019/ui/SyncedLocationDropdown.js +1 -1
  22. package/dist/es2019/ui/quick-insert.js +1 -1
  23. package/dist/esm/nodeviews/bodiedLazySyncedBlock.js +1 -0
  24. package/dist/esm/nodeviews/bodiedSyncedBlock.js +137 -11
  25. package/dist/esm/pm-plugins/main.js +19 -4
  26. package/dist/esm/syncedBlockPlugin.js +8 -1
  27. package/dist/esm/ui/BodiedSyncBlockWrapper.js +1 -0
  28. package/dist/esm/ui/DeleteConfirmationModal.js +1 -1
  29. package/dist/esm/ui/SyncBlockLabel.js +4 -1
  30. package/dist/esm/ui/SyncedLocationDropdown.js +1 -1
  31. package/dist/esm/ui/quick-insert.js +1 -1
  32. package/dist/types/nodeviews/bodiedSyncedBlock.d.ts +27 -21
  33. package/dist/types/syncedBlockPluginType.d.ts +3 -1
  34. package/dist/types-ts4.5/nodeviews/bodiedSyncedBlock.d.ts +27 -21
  35. package/dist/types-ts4.5/syncedBlockPluginType.d.ts +3 -1
  36. package/package.json +7 -3
@@ -9,8 +9,9 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
9
9
  import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
10
10
  import { convertPMNodesToSyncBlockNodes, rebaseTransaction } from '@atlaskit/editor-synced-block-provider';
11
11
  import { fg } from '@atlaskit/platform-feature-flags';
12
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
12
13
  import { lazyBodiedSyncBlockView } from '../nodeviews/bodiedLazySyncedBlock';
13
- import { bodiedSyncBlockNodeView } from '../nodeviews/bodiedSyncedBlock';
14
+ import { bodiedSyncBlockNodeView, bodiedSyncBlockNodeViewOld } from '../nodeviews/bodiedSyncedBlock';
14
15
  import { SyncBlock as SyncBlockView } from '../nodeviews/syncedBlock';
15
16
  import { FLAG_ID } from '../types';
16
17
  import { handleBodiedSyncBlockCreation } from './utils/handle-bodied-sync-block-creation';
@@ -314,7 +315,14 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
314
315
  eventDispatcher: pmPluginFactoryParams.eventDispatcher,
315
316
  syncBlockStore: syncBlockStore
316
317
  }).init(),
317
- bodiedSyncBlock: fg('platform_synced_block_patch_5') ? bodiedSyncBlockNodeView({
318
+ bodiedSyncBlock: fg('platform_synced_block_patch_5') ? editorExperiment('platform_synced_block_use_new_source_nodeview', true, {
319
+ exposure: true
320
+ }) ? bodiedSyncBlockNodeView({
321
+ pluginOptions: options,
322
+ pmPluginFactoryParams,
323
+ api,
324
+ syncBlockStore
325
+ }) : bodiedSyncBlockNodeViewOld({
318
326
  pluginOptions: options,
319
327
  pmPluginFactoryParams,
320
328
  api,
@@ -326,7 +334,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
326
334
  })
327
335
  },
328
336
  decorations: state => {
329
- var _currentPluginState$s, _api$connectivity2, _api$connectivity2$sh, _api$editorViewMode, _api$editorViewMode$s, _api$userIntent, _api$userIntent$share;
337
+ var _currentPluginState$s, _api$connectivity2, _api$connectivity2$sh, _api$editorViewMode, _api$editorViewMode$s, _api$userIntent, _api$userIntent$share, _api$focus, _api$focus$sharedStat, _api$focus$sharedStat2;
330
338
  const currentPluginState = syncedBlockPluginKey.getState(state);
331
339
  const selectionDecorationSet = (_currentPluginState$s = currentPluginState === null || currentPluginState === void 0 ? void 0 : currentPluginState.selectionDecorationSet) !== null && _currentPluginState$s !== void 0 ? _currentPluginState$s : DecorationSet.empty;
332
340
  const syncBlockStore = currentPluginState === null || currentPluginState === void 0 ? void 0 : currentPluginState.syncBlockStore;
@@ -364,7 +372,14 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
364
372
  }));
365
373
  }
366
374
  });
367
- return selectionDecorationSet.add(doc, offlineDecorations).add(doc, viewModeDecorations).add(doc, loadingDecorations).add(doc, dragDecorations);
375
+ if (api !== null && api !== void 0 && (_api$focus = api.focus) !== null && _api$focus !== void 0 && (_api$focus$sharedStat = _api$focus.sharedState) !== null && _api$focus$sharedStat !== void 0 && (_api$focus$sharedStat2 = _api$focus$sharedStat.currentState()) !== null && _api$focus$sharedStat2 !== void 0 && _api$focus$sharedStat2.hasFocus || !editorExperiment('platform_synced_block_patch_6', true, {
376
+ exposure: true
377
+ })) {
378
+ // Don't show decorations if the editor is not focused
379
+ return selectionDecorationSet.add(doc, offlineDecorations).add(doc, viewModeDecorations).add(doc, loadingDecorations).add(doc, dragDecorations);
380
+ } else {
381
+ return DecorationSet.empty.add(doc, offlineDecorations).add(doc, viewModeDecorations).add(doc, loadingDecorations).add(doc, dragDecorations);
382
+ }
368
383
  },
369
384
  handleClickOn: createSelectionClickHandler(['bodiedSyncBlock'], target => !!target.closest(`.${BodiedSyncBlockSharedCssClassName.prefix}`), {
370
385
  useLongPressSelection
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { bodiedSyncBlock, syncBlock } from '@atlaskit/adf-schema';
3
3
  import { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
4
4
  import { fg } from '@atlaskit/platform-feature-flags';
5
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
6
  import { flushBodiedSyncBlocks, flushSyncBlocks } from './editor-actions';
6
7
  import { copySyncedBlockReferenceToClipboardEditorCommand, createSyncedBlock } from './editor-commands';
7
8
  import { bodiedSyncBlockNodeWithToDOMFixed } from './nodeviews/bodiedSyncBlockNodeWithToDOMFixed';
@@ -32,7 +33,13 @@ export const syncedBlockPlugin = ({
32
33
  node: syncBlock
33
34
  }, {
34
35
  name: 'bodiedSyncBlock',
35
- node: fg('platform_synced_block_patch_3') ? bodiedSyncBlockNodeWithToDOMFixed() : bodiedSyncBlock
36
+ node:
37
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
38
+ fg('platform_synced_block_patch_3') && !editorExperiment('platform_synced_block_patch_6', true, {
39
+ exposure: true
40
+ }) ?
41
+ // delete bodiedSyncBlockNodeWithToDOMFixed when cleaning up platform_synced_block_patch_6
42
+ bodiedSyncBlockNodeWithToDOMFixed() : bodiedSyncBlock
36
43
  }];
37
44
  },
38
45
  pmPlugins() {
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { useHandleContentChanges } from '@atlaskit/editor-synced-block-provider';
3
3
  import { SyncBlockLabel } from './SyncBlockLabel';
4
+ // Delete this file when cleaning up platform_synced_block_use_new_source_nodeview
4
5
  export const BodiedSyncBlockWrapper = /*#__PURE__*/React.forwardRef(({
5
6
  node,
6
7
  syncBlockStore
@@ -1,4 +1,4 @@
1
- /* DeleteConfirmationModal.tsx generated by @compiled/babel-plugin v0.38.1 */
1
+ /* DeleteConfirmationModal.tsx generated by @compiled/babel-plugin v0.39.1 */
2
2
  import "./DeleteConfirmationModal.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React, { useCallback, useEffect, useState } from 'react';
@@ -4,6 +4,7 @@ import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages'
4
4
  import { SyncBlockLabelSharedCssClassName } from '@atlaskit/editor-common/sync-block';
5
5
  import BlockSyncedIcon from '@atlaskit/icon-lab/core/block-synced';
6
6
  import { Text } from '@atlaskit/primitives/compiled';
7
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
8
  import Tooltip from '@atlaskit/tooltip';
8
9
  import VisuallyHidden from '@atlaskit/visually-hidden';
9
10
  import { formatElapsedTime } from './utils/time';
@@ -69,7 +70,9 @@ const SyncBlockLabelComponent = ({
69
70
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
70
71
  ,
71
72
  className: SyncBlockLabelSharedCssClassName.labelClassName,
72
- "aria-describedby": ariaDescribedById
73
+ "aria-describedby": (isSource || isUnsyncedBlock) && editorExperiment('platform_synced_block_patch_6', true, {
74
+ exposure: true
75
+ }) ? undefined : ariaDescribedById
73
76
  }, /*#__PURE__*/React.createElement(BlockSyncedIcon, {
74
77
  color: "var(--ds-icon-subtle, #505258)",
75
78
  size: "small",
@@ -1,4 +1,4 @@
1
- /* SyncedLocationDropdown.tsx generated by @compiled/babel-plugin v0.38.1 */
1
+ /* SyncedLocationDropdown.tsx generated by @compiled/babel-plugin v0.39.1 */
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import "./SyncedLocationDropdown.compiled.css";
4
4
  import * as React from 'react';
@@ -1,4 +1,4 @@
1
- /* quick-insert.tsx generated by @compiled/babel-plugin v0.38.1 */
1
+ /* quick-insert.tsx generated by @compiled/babel-plugin v0.39.1 */
2
2
  import "./quick-insert.compiled.css";
3
3
  import * as React from 'react';
4
4
  import { ax, ix } from "@compiled/react/runtime";
@@ -1,4 +1,5 @@
1
1
  import { withLazyLoading } from '@atlaskit/editor-common/lazy-node-view';
2
+ // Delete this file when cleaning up platform_synced_block_patch_5
2
3
  export var lazyBodiedSyncBlockView = function lazyBodiedSyncBlockView(props) {
3
4
  return withLazyLoading({
4
5
  nodeName: 'bodiedSyncBlock',
@@ -6,7 +6,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
6
6
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
7
7
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
8
8
  import React from 'react';
9
- import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
9
+ import { ACTION_SUBJECT, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
10
10
  import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
11
11
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
12
12
  import { BodiedSyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
@@ -14,25 +14,26 @@ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
14
14
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
15
15
  import { fg } from '@atlaskit/platform-feature-flags';
16
16
  import { BodiedSyncBlockWrapper } from '../ui/BodiedSyncBlockWrapper';
17
- var toDOM = function toDOM() {
17
+ import { SyncBlockLabel } from '../ui/SyncBlockLabel';
18
+ var toDOMOld = function toDOMOld() {
18
19
  return ['div', {
19
20
  class: BodiedSyncBlockSharedCssClassName.content,
20
21
  contenteditable: true
21
22
  }, 0];
22
23
  };
23
- export var BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
24
- function BodiedSyncBlock(props) {
24
+ var BodiedSyncBlockOld = /*#__PURE__*/function (_ReactNodeView) {
25
+ function BodiedSyncBlockOld(props) {
25
26
  var _this;
26
- _classCallCheck(this, BodiedSyncBlock);
27
- _this = _callSuper(this, BodiedSyncBlock, [props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props]);
27
+ _classCallCheck(this, BodiedSyncBlockOld);
28
+ _this = _callSuper(this, BodiedSyncBlockOld, [props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props]);
28
29
  _this.api = props.api;
29
30
  _this.syncBlockStore = props.syncBlockStore;
30
31
  _this.handleConnectivityModeChange();
31
32
  _this.handleViewModeChange();
32
33
  return _this;
33
34
  }
34
- _inherits(BodiedSyncBlock, _ReactNodeView);
35
- return _createClass(BodiedSyncBlock, [{
35
+ _inherits(BodiedSyncBlockOld, _ReactNodeView);
36
+ return _createClass(BodiedSyncBlockOld, [{
36
37
  key: "updateContentEditable",
37
38
  value: function updateContentEditable(_ref) {
38
39
  var _this$api, _this$api2;
@@ -105,7 +106,7 @@ export var BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
105
106
  }, {
106
107
  key: "getContentDOM",
107
108
  value: function getContentDOM() {
108
- var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOM()),
109
+ var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOMOld()),
109
110
  dom = _DOMSerializer$render.dom,
110
111
  contentDOM = _DOMSerializer$render.contentDOM;
111
112
  // In SSR, the first check won't work, so fallback to nodeType check
@@ -133,7 +134,7 @@ export var BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
133
134
  }
134
135
  }]);
135
136
  }(ReactNodeView);
136
- export var bodiedSyncBlockNodeView = function bodiedSyncBlockNodeView(_ref4) {
137
+ export var bodiedSyncBlockNodeViewOld = function bodiedSyncBlockNodeViewOld(_ref4) {
137
138
  var pluginOptions = _ref4.pluginOptions,
138
139
  pmPluginFactoryParams = _ref4.pmPluginFactoryParams,
139
140
  api = _ref4.api,
@@ -141,7 +142,7 @@ export var bodiedSyncBlockNodeView = function bodiedSyncBlockNodeView(_ref4) {
141
142
  return function (node, view, getPos) {
142
143
  var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
143
144
  eventDispatcher = pmPluginFactoryParams.eventDispatcher;
144
- return new BodiedSyncBlock({
145
+ return new BodiedSyncBlockOld({
145
146
  api: api,
146
147
  pluginOptions: pluginOptions,
147
148
  node: node,
@@ -152,4 +153,129 @@ export var bodiedSyncBlockNodeView = function bodiedSyncBlockNodeView(_ref4) {
152
153
  syncBlockStore: syncBlockStore
153
154
  }).init();
154
155
  };
156
+ };
157
+ var toDOM = function toDOM(node) {
158
+ return ['div', {
159
+ class: "".concat(BodiedSyncBlockSharedCssClassName.prefix, " bodiedSyncBlockView-content-wrap"),
160
+ localid: node.attrs.localId,
161
+ resourceid: node.attrs.resourceId
162
+ }, ['div', {
163
+ class: BodiedSyncBlockSharedCssClassName.content,
164
+ contenteditable: 'true'
165
+ }, 0]];
166
+ };
167
+ export var BodiedSyncBlock = /*#__PURE__*/function () {
168
+ function BodiedSyncBlock(node, view, getPos, api, nodeViewPortalProviderAPI, syncBlockStore) {
169
+ var _this4 = this;
170
+ _classCallCheck(this, BodiedSyncBlock);
171
+ this.node = node;
172
+ this.view = view;
173
+ this.getPos = getPos;
174
+ this.api = api;
175
+ this.syncBlockStore = syncBlockStore;
176
+ this.nodeViewPortalProviderAPI = nodeViewPortalProviderAPI;
177
+ var _DOMSerializer$render2 = DOMSerializer.renderSpec(document, toDOM(this.node)),
178
+ dom = _DOMSerializer$render2.dom,
179
+ contentDOM = _DOMSerializer$render2.contentDOM;
180
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
181
+ this.dom = dom;
182
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
183
+ this.contentDOM = contentDOM;
184
+ this.labelKey = crypto.randomUUID();
185
+ this.nodeViewPortalProviderAPI.render(function () {
186
+ var _this4$api;
187
+ return /*#__PURE__*/React.createElement(ErrorBoundary, {
188
+ component: ACTION_SUBJECT.SYNCED_BLOCK,
189
+ componentId: ACTION_SUBJECT_ID.SYNCED_BLOCK_LABEL,
190
+ dispatchAnalyticsEvent: (_this4$api = _this4.api) === null || _this4$api === void 0 || (_this4$api = _this4$api.analytics) === null || _this4$api === void 0 ? void 0 : _this4$api.actions.fireAnalyticsEvent,
191
+ fallbackComponent: null
192
+ }, /*#__PURE__*/React.createElement(SyncBlockLabel, {
193
+ isSource: true,
194
+ localId: node.attrs.localId
195
+ }));
196
+ }, this.dom, this.labelKey);
197
+ this.updateContentEditable({});
198
+ this.handleConnectivityModeChange();
199
+ this.handleViewModeChange();
200
+ }
201
+ return _createClass(BodiedSyncBlock, [{
202
+ key: "updateContentEditable",
203
+ value: function updateContentEditable(_ref5) {
204
+ var _this$api7, _this$api8;
205
+ var nextConnectivityMode = _ref5.nextConnectivityMode,
206
+ nextViewMode = _ref5.nextViewMode;
207
+ var connectivityMode = nextConnectivityMode !== null && nextConnectivityMode !== void 0 ? nextConnectivityMode : (_this$api7 = this.api) === null || _this$api7 === void 0 || (_this$api7 = _this$api7.connectivity) === null || _this$api7 === void 0 || (_this$api7 = _this$api7.sharedState) === null || _this$api7 === void 0 || (_this$api7 = _this$api7.currentState()) === null || _this$api7 === void 0 ? void 0 : _this$api7.mode;
208
+ var viewMode = nextViewMode !== null && nextViewMode !== void 0 ? nextViewMode : (_this$api8 = this.api) === null || _this$api8 === void 0 || (_this$api8 = _this$api8.editorViewMode) === null || _this$api8 === void 0 || (_this$api8 = _this$api8.sharedState) === null || _this$api8 === void 0 || (_this$api8 = _this$api8.currentState()) === null || _this$api8 === void 0 ? void 0 : _this$api8.mode;
209
+ var isOnline = !isOfflineMode(connectivityMode);
210
+ var isEditMode = viewMode !== 'view';
211
+ var shouldBeEditable = isOnline && isEditMode;
212
+ this.contentDOM.setAttribute('contenteditable', shouldBeEditable ? 'true' : 'false');
213
+ }
214
+ }, {
215
+ key: "handleConnectivityModeChange",
216
+ value: function handleConnectivityModeChange() {
217
+ var _this$api9,
218
+ _this5 = this;
219
+ if ((_this$api9 = this.api) !== null && _this$api9 !== void 0 && _this$api9.connectivity) {
220
+ this.cleanupConnectivityModeListener = this.api.connectivity.sharedState.onChange(function (_ref6) {
221
+ var nextSharedState = _ref6.nextSharedState;
222
+ _this5.updateContentEditable({
223
+ nextConnectivityMode: nextSharedState.mode
224
+ });
225
+ });
226
+ }
227
+ }
228
+ }, {
229
+ key: "handleViewModeChange",
230
+ value: function handleViewModeChange() {
231
+ var _this$api0,
232
+ _this6 = this;
233
+ if ((_this$api0 = this.api) !== null && _this$api0 !== void 0 && _this$api0.editorViewMode) {
234
+ this.cleanupViewModeListener = this.api.editorViewMode.sharedState.onChange(function (_ref7) {
235
+ var nextSharedState = _ref7.nextSharedState;
236
+ _this6.updateContentEditable({
237
+ nextViewMode: nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.mode
238
+ });
239
+ });
240
+ }
241
+ }
242
+ }, {
243
+ key: "update",
244
+ value: function update(node) {
245
+ if (this.node.type !== node.type) {
246
+ return false;
247
+ }
248
+ if (node !== this.node) {
249
+ var _this$api$syncedBlock2, _this$api1;
250
+ var syncBlockStore = (_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;
251
+ syncBlockStore === null || syncBlockStore === void 0 || syncBlockStore.sourceManager.updateSyncBlockData(node);
252
+ }
253
+ this.node = node;
254
+ return true;
255
+ }
256
+ }, {
257
+ key: "ignoreMutation",
258
+ value: function ignoreMutation(mutation) {
259
+ if (mutation.type === 'selection') {
260
+ return false;
261
+ }
262
+ return true;
263
+ }
264
+ }, {
265
+ key: "destroy",
266
+ value: function destroy() {
267
+ var _this$cleanupConnecti, _this$cleanupViewMode;
268
+ (_this$cleanupConnecti = this.cleanupConnectivityModeListener) === null || _this$cleanupConnecti === void 0 || _this$cleanupConnecti.call(this);
269
+ (_this$cleanupViewMode = this.cleanupViewModeListener) === null || _this$cleanupViewMode === void 0 || _this$cleanupViewMode.call(this);
270
+ this.nodeViewPortalProviderAPI.remove(this.labelKey);
271
+ }
272
+ }]);
273
+ }();
274
+ export var bodiedSyncBlockNodeView = function bodiedSyncBlockNodeView(props) {
275
+ var api = props.api,
276
+ syncBlockStore = props.syncBlockStore,
277
+ nodeViewPortalProviderAPI = props.pmPluginFactoryParams.nodeViewPortalProviderAPI;
278
+ return function (node, view, getPos) {
279
+ return new BodiedSyncBlock(node, view, getPos, api, nodeViewPortalProviderAPI, syncBlockStore);
280
+ };
155
281
  };
@@ -17,8 +17,9 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
17
17
  import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
18
18
  import { convertPMNodesToSyncBlockNodes, rebaseTransaction } from '@atlaskit/editor-synced-block-provider';
19
19
  import { fg } from '@atlaskit/platform-feature-flags';
20
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
20
21
  import { lazyBodiedSyncBlockView } from '../nodeviews/bodiedLazySyncedBlock';
21
- import { bodiedSyncBlockNodeView } from '../nodeviews/bodiedSyncedBlock';
22
+ import { bodiedSyncBlockNodeView, bodiedSyncBlockNodeViewOld } from '../nodeviews/bodiedSyncedBlock';
22
23
  import { SyncBlock as SyncBlockView } from '../nodeviews/syncedBlock';
23
24
  import { FLAG_ID } from '../types';
24
25
  import { handleBodiedSyncBlockCreation } from './utils/handle-bodied-sync-block-creation';
@@ -346,7 +347,14 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
346
347
  }).init()
347
348
  );
348
349
  },
349
- bodiedSyncBlock: fg('platform_synced_block_patch_5') ? bodiedSyncBlockNodeView({
350
+ bodiedSyncBlock: fg('platform_synced_block_patch_5') ? editorExperiment('platform_synced_block_use_new_source_nodeview', true, {
351
+ exposure: true
352
+ }) ? bodiedSyncBlockNodeView({
353
+ pluginOptions: options,
354
+ pmPluginFactoryParams: pmPluginFactoryParams,
355
+ api: api,
356
+ syncBlockStore: syncBlockStore
357
+ }) : bodiedSyncBlockNodeViewOld({
350
358
  pluginOptions: options,
351
359
  pmPluginFactoryParams: pmPluginFactoryParams,
352
360
  api: api,
@@ -358,7 +366,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
358
366
  })
359
367
  },
360
368
  decorations: function decorations(state) {
361
- var _currentPluginState$s, _api$connectivity2, _api$editorViewMode, _api$userIntent;
369
+ var _currentPluginState$s, _api$connectivity2, _api$editorViewMode, _api$userIntent, _api$focus;
362
370
  var currentPluginState = syncedBlockPluginKey.getState(state);
363
371
  var selectionDecorationSet = (_currentPluginState$s = currentPluginState === null || currentPluginState === void 0 ? void 0 : currentPluginState.selectionDecorationSet) !== null && _currentPluginState$s !== void 0 ? _currentPluginState$s : DecorationSet.empty;
364
372
  var syncBlockStore = currentPluginState === null || currentPluginState === void 0 ? void 0 : currentPluginState.syncBlockStore;
@@ -394,7 +402,14 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
394
402
  }));
395
403
  }
396
404
  });
397
- return selectionDecorationSet.add(doc, offlineDecorations).add(doc, viewModeDecorations).add(doc, loadingDecorations).add(doc, dragDecorations);
405
+ if (api !== null && api !== void 0 && (_api$focus = api.focus) !== null && _api$focus !== void 0 && (_api$focus = _api$focus.sharedState) !== null && _api$focus !== void 0 && (_api$focus = _api$focus.currentState()) !== null && _api$focus !== void 0 && _api$focus.hasFocus || !editorExperiment('platform_synced_block_patch_6', true, {
406
+ exposure: true
407
+ })) {
408
+ // Don't show decorations if the editor is not focused
409
+ return selectionDecorationSet.add(doc, offlineDecorations).add(doc, viewModeDecorations).add(doc, loadingDecorations).add(doc, dragDecorations);
410
+ } else {
411
+ return DecorationSet.empty.add(doc, offlineDecorations).add(doc, viewModeDecorations).add(doc, loadingDecorations).add(doc, dragDecorations);
412
+ }
398
413
  },
399
414
  handleClickOn: createSelectionClickHandler(['bodiedSyncBlock'], function (target) {
400
415
  return !!target.closest(".".concat(BodiedSyncBlockSharedCssClassName.prefix));
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { bodiedSyncBlock, syncBlock } from '@atlaskit/adf-schema';
3
3
  import { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
4
4
  import { fg } from '@atlaskit/platform-feature-flags';
5
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
6
  import { flushBodiedSyncBlocks as _flushBodiedSyncBlocks, flushSyncBlocks } from './editor-actions';
6
7
  import { copySyncedBlockReferenceToClipboardEditorCommand, createSyncedBlock } from './editor-commands';
7
8
  import { bodiedSyncBlockNodeWithToDOMFixed } from './nodeviews/bodiedSyncBlockNodeWithToDOMFixed';
@@ -31,7 +32,13 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
31
32
  node: syncBlock
32
33
  }, {
33
34
  name: 'bodiedSyncBlock',
34
- node: fg('platform_synced_block_patch_3') ? bodiedSyncBlockNodeWithToDOMFixed() : 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, {
38
+ exposure: true
39
+ }) ?
40
+ // delete bodiedSyncBlockNodeWithToDOMFixed when cleaning up platform_synced_block_patch_6
41
+ bodiedSyncBlockNodeWithToDOMFixed() : bodiedSyncBlock
35
42
  }];
36
43
  },
37
44
  pmPlugins: function pmPlugins() {
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { useHandleContentChanges } from '@atlaskit/editor-synced-block-provider';
3
3
  import { SyncBlockLabel } from './SyncBlockLabel';
4
+ // Delete this file when cleaning up platform_synced_block_use_new_source_nodeview
4
5
  export var BodiedSyncBlockWrapper = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
5
6
  var node = _ref.node,
6
7
  syncBlockStore = _ref.syncBlockStore;
@@ -1,4 +1,4 @@
1
- /* DeleteConfirmationModal.tsx generated by @compiled/babel-plugin v0.38.1 */
1
+ /* DeleteConfirmationModal.tsx generated by @compiled/babel-plugin v0.39.1 */
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import "./DeleteConfirmationModal.compiled.css";
@@ -5,6 +5,7 @@ import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages'
5
5
  import { SyncBlockLabelSharedCssClassName } from '@atlaskit/editor-common/sync-block';
6
6
  import BlockSyncedIcon from '@atlaskit/icon-lab/core/block-synced';
7
7
  import { Text } from '@atlaskit/primitives/compiled';
8
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
9
  import Tooltip from '@atlaskit/tooltip';
9
10
  import VisuallyHidden from '@atlaskit/visually-hidden';
10
11
  import { formatElapsedTime } from './utils/time';
@@ -70,7 +71,9 @@ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
70
71
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
71
72
  ,
72
73
  className: SyncBlockLabelSharedCssClassName.labelClassName,
73
- "aria-describedby": ariaDescribedById
74
+ "aria-describedby": (isSource || isUnsyncedBlock) && editorExperiment('platform_synced_block_patch_6', true, {
75
+ exposure: true
76
+ }) ? undefined : ariaDescribedById
74
77
  }, /*#__PURE__*/React.createElement(BlockSyncedIcon, {
75
78
  color: "var(--ds-icon-subtle, #505258)",
76
79
  size: "small",
@@ -1,4 +1,4 @@
1
- /* SyncedLocationDropdown.tsx generated by @compiled/babel-plugin v0.38.1 */
1
+ /* SyncedLocationDropdown.tsx generated by @compiled/babel-plugin v0.39.1 */
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _extends from "@babel/runtime/helpers/extends";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
@@ -1,4 +1,4 @@
1
- /* quick-insert.tsx generated by @compiled/babel-plugin v0.38.1 */
1
+ /* quick-insert.tsx generated by @compiled/babel-plugin v0.39.1 */
2
2
  import "./quick-insert.compiled.css";
3
3
  import * as React from 'react';
4
4
  import { ax, ix } from "@compiled/react/runtime";
@@ -1,11 +1,10 @@
1
- import React from 'react';
2
1
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
3
2
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
4
- import type { ForwardRef, ReactComponentProps } from '@atlaskit/editor-common/react-node-view';
3
+ import type { ReactComponentProps } from '@atlaskit/editor-common/react-node-view';
5
4
  import ReactNodeView, { type getPosHandler } from '@atlaskit/editor-common/react-node-view';
6
- import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
5
+ import type { ExtractInjectionAPI, getPosHandlerNode, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
7
6
  import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
8
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
7
+ import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
9
8
  import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
10
9
  import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlockPluginType';
11
10
  export interface BodiedSyncBlockNodeViewProps extends ReactComponentProps {
@@ -18,27 +17,34 @@ export interface BodiedSyncBlockNodeViewProps extends ReactComponentProps {
18
17
  syncBlockStore?: SyncBlockStoreManager;
19
18
  view: EditorView;
20
19
  }
21
- export declare class BodiedSyncBlock extends ReactNodeView<BodiedSyncBlockNodeViewProps> {
22
- private cleanupConnectivityModeListener?;
23
- private cleanupViewModeListener?;
20
+ export interface BodiedSyncBlockNodeViewProperties {
21
+ api?: ExtractInjectionAPI<SyncedBlockPlugin>;
22
+ pluginOptions: SyncedBlockPluginOptions | undefined;
23
+ pmPluginFactoryParams: PMPluginFactoryParams;
24
+ syncBlockStore?: SyncBlockStoreManager;
25
+ }
26
+ export declare const bodiedSyncBlockNodeViewOld: (props: BodiedSyncBlockNodeViewProperties) => (node: PMNode, view: EditorView, getPos: getPosHandler) => ReactNodeView<BodiedSyncBlockNodeViewProps>;
27
+ export declare class BodiedSyncBlock implements NodeView {
28
+ dom: HTMLElement;
29
+ contentDOM: HTMLElement;
30
+ node: PMNode;
31
+ view: EditorView;
32
+ getPos: getPosHandlerNode;
33
+ nodeViewPortalProviderAPI: PortalProviderAPI;
24
34
  private api?;
25
35
  private syncBlockStore?;
26
- constructor(props: BodiedSyncBlockNodeViewProps);
36
+ private cleanupConnectivityModeListener?;
37
+ private cleanupViewModeListener?;
38
+ private labelKey;
39
+ constructor(node: PMNode, view: EditorView, getPos: getPosHandlerNode, api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined, nodeViewPortalProviderAPI: PortalProviderAPI, syncBlockStore?: SyncBlockStoreManager);
27
40
  private updateContentEditable;
28
41
  private handleConnectivityModeChange;
29
42
  private handleViewModeChange;
30
- createDomRef(): HTMLElement;
31
- render(_props: never, forwardRef: ForwardRef): React.JSX.Element | null;
32
- getContentDOM(): {
33
- dom: HTMLElement;
34
- contentDOM: HTMLElement | undefined;
35
- } | undefined;
43
+ update(node: PMNode): boolean;
44
+ ignoreMutation(mutation: MutationRecord | {
45
+ target: Node;
46
+ type: 'selection';
47
+ }): boolean;
36
48
  destroy(): void;
37
49
  }
38
- export interface BodiedSyncBlockNodeViewProperties {
39
- api?: ExtractInjectionAPI<SyncedBlockPlugin>;
40
- pluginOptions: SyncedBlockPluginOptions | undefined;
41
- pmPluginFactoryParams: PMPluginFactoryParams;
42
- syncBlockStore?: SyncBlockStoreManager;
43
- }
44
- export declare const bodiedSyncBlockNodeView: (props: BodiedSyncBlockNodeViewProperties) => (node: PMNode, view: EditorView, getPos: getPosHandler) => ReactNodeView<BodiedSyncBlockNodeViewProps>;
50
+ export declare const bodiedSyncBlockNodeView: (props: BodiedSyncBlockNodeViewProperties) => ((node: PMNode, view: EditorView, getPos: getPosHandler) => NodeView);
@@ -10,6 +10,7 @@ import type { ContentFormatPlugin } from '@atlaskit/editor-plugin-content-format
10
10
  import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
11
11
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
12
12
  import type { FloatingToolbarPlugin } from '@atlaskit/editor-plugin-floating-toolbar';
13
+ import type { FocusPlugin } from '@atlaskit/editor-plugin-focus';
13
14
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
14
15
  import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
15
16
  import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
@@ -81,7 +82,8 @@ export type SyncedBlockPlugin = NextEditorPlugin<'syncedBlock', {
81
82
  OptionalPlugin<ConnectivityPlugin>,
82
83
  OptionalPlugin<EditorViewModePlugin>,
83
84
  OptionalPlugin<ContentFormatPlugin>,
84
- OptionalPlugin<UserIntentPlugin>
85
+ OptionalPlugin<UserIntentPlugin>,
86
+ OptionalPlugin<FocusPlugin>
85
87
  ];
86
88
  pluginConfiguration: SyncedBlockPluginOptions | undefined;
87
89
  sharedState: SyncedBlockSharedState | undefined;
@@ -1,11 +1,10 @@
1
- import React from 'react';
2
1
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
3
2
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
4
- import type { ForwardRef, ReactComponentProps } from '@atlaskit/editor-common/react-node-view';
3
+ import type { ReactComponentProps } from '@atlaskit/editor-common/react-node-view';
5
4
  import ReactNodeView, { type getPosHandler } from '@atlaskit/editor-common/react-node-view';
6
- import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
5
+ import type { ExtractInjectionAPI, getPosHandlerNode, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
7
6
  import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
8
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
7
+ import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
9
8
  import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
10
9
  import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlockPluginType';
11
10
  export interface BodiedSyncBlockNodeViewProps extends ReactComponentProps {
@@ -18,27 +17,34 @@ export interface BodiedSyncBlockNodeViewProps extends ReactComponentProps {
18
17
  syncBlockStore?: SyncBlockStoreManager;
19
18
  view: EditorView;
20
19
  }
21
- export declare class BodiedSyncBlock extends ReactNodeView<BodiedSyncBlockNodeViewProps> {
22
- private cleanupConnectivityModeListener?;
23
- private cleanupViewModeListener?;
20
+ export interface BodiedSyncBlockNodeViewProperties {
21
+ api?: ExtractInjectionAPI<SyncedBlockPlugin>;
22
+ pluginOptions: SyncedBlockPluginOptions | undefined;
23
+ pmPluginFactoryParams: PMPluginFactoryParams;
24
+ syncBlockStore?: SyncBlockStoreManager;
25
+ }
26
+ export declare const bodiedSyncBlockNodeViewOld: (props: BodiedSyncBlockNodeViewProperties) => (node: PMNode, view: EditorView, getPos: getPosHandler) => ReactNodeView<BodiedSyncBlockNodeViewProps>;
27
+ export declare class BodiedSyncBlock implements NodeView {
28
+ dom: HTMLElement;
29
+ contentDOM: HTMLElement;
30
+ node: PMNode;
31
+ view: EditorView;
32
+ getPos: getPosHandlerNode;
33
+ nodeViewPortalProviderAPI: PortalProviderAPI;
24
34
  private api?;
25
35
  private syncBlockStore?;
26
- constructor(props: BodiedSyncBlockNodeViewProps);
36
+ private cleanupConnectivityModeListener?;
37
+ private cleanupViewModeListener?;
38
+ private labelKey;
39
+ constructor(node: PMNode, view: EditorView, getPos: getPosHandlerNode, api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined, nodeViewPortalProviderAPI: PortalProviderAPI, syncBlockStore?: SyncBlockStoreManager);
27
40
  private updateContentEditable;
28
41
  private handleConnectivityModeChange;
29
42
  private handleViewModeChange;
30
- createDomRef(): HTMLElement;
31
- render(_props: never, forwardRef: ForwardRef): React.JSX.Element | null;
32
- getContentDOM(): {
33
- dom: HTMLElement;
34
- contentDOM: HTMLElement | undefined;
35
- } | undefined;
43
+ update(node: PMNode): boolean;
44
+ ignoreMutation(mutation: MutationRecord | {
45
+ target: Node;
46
+ type: 'selection';
47
+ }): boolean;
36
48
  destroy(): void;
37
49
  }
38
- export interface BodiedSyncBlockNodeViewProperties {
39
- api?: ExtractInjectionAPI<SyncedBlockPlugin>;
40
- pluginOptions: SyncedBlockPluginOptions | undefined;
41
- pmPluginFactoryParams: PMPluginFactoryParams;
42
- syncBlockStore?: SyncBlockStoreManager;
43
- }
44
- export declare const bodiedSyncBlockNodeView: (props: BodiedSyncBlockNodeViewProperties) => (node: PMNode, view: EditorView, getPos: getPosHandler) => ReactNodeView<BodiedSyncBlockNodeViewProps>;
50
+ export declare const bodiedSyncBlockNodeView: (props: BodiedSyncBlockNodeViewProperties) => ((node: PMNode, view: EditorView, getPos: getPosHandler) => NodeView);
@@ -10,6 +10,7 @@ import type { ContentFormatPlugin } from '@atlaskit/editor-plugin-content-format
10
10
  import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
11
11
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
12
12
  import type { FloatingToolbarPlugin } from '@atlaskit/editor-plugin-floating-toolbar';
13
+ import type { FocusPlugin } from '@atlaskit/editor-plugin-focus';
13
14
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
14
15
  import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
15
16
  import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
@@ -81,7 +82,8 @@ export type SyncedBlockPlugin = NextEditorPlugin<'syncedBlock', {
81
82
  OptionalPlugin<ConnectivityPlugin>,
82
83
  OptionalPlugin<EditorViewModePlugin>,
83
84
  OptionalPlugin<ContentFormatPlugin>,
84
- OptionalPlugin<UserIntentPlugin>
85
+ OptionalPlugin<UserIntentPlugin>,
86
+ OptionalPlugin<FocusPlugin>
85
87
  ];
86
88
  pluginConfiguration: SyncedBlockPluginOptions | undefined;
87
89
  sharedState: SyncedBlockSharedState | undefined;