@atlaskit/editor-plugin-synced-block 5.4.3 → 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 +16 -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 +27 -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 +28 -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 +28 -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 +5 -1
  34. package/dist/types-ts4.5/nodeviews/bodiedSyncedBlock.d.ts +27 -21
  35. package/dist/types-ts4.5/syncedBlockPluginType.d.ts +5 -1
  36. package/package.json +8 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-plugin-synced-block
2
2
 
3
+ ## 5.4.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [`1a05924d64777`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1a05924d64777) -
8
+ [EDITOR-5528] Fix bodiedSyncBlock mutation
9
+ - Updated dependencies
10
+
11
+ ## 5.4.4
12
+
13
+ ### Patch Changes
14
+
15
+ - [`29d9d25ebe53a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/29d9d25ebe53a) -
16
+ [ux] EDITOR-5009 show sync block border when dragging
17
+ - Updated dependencies
18
+
3
19
  ## 5.4.3
4
20
 
5
21
  ### Patch Changes
@@ -44,15 +44,24 @@
44
44
  {
45
45
  "path": "../../editor-plugin-connectivity/afm-cc/tsconfig.json"
46
46
  },
47
+ {
48
+ "path": "../../editor-plugin-content-format/afm-cc/tsconfig.json"
49
+ },
47
50
  {
48
51
  "path": "../../editor-plugin-decorations/afm-cc/tsconfig.json"
49
52
  },
50
53
  {
51
54
  "path": "../../editor-plugin-floating-toolbar/afm-cc/tsconfig.json"
52
55
  },
56
+ {
57
+ "path": "../../editor-plugin-focus/afm-cc/tsconfig.json"
58
+ },
53
59
  {
54
60
  "path": "../../editor-plugin-selection/afm-cc/tsconfig.json"
55
61
  },
62
+ {
63
+ "path": "../../editor-plugin-user-intent/afm-cc/tsconfig.json"
64
+ },
56
65
  {
57
66
  "path": "../../editor-prosemirror/afm-cc/tsconfig.json"
58
67
  },
@@ -92,6 +101,9 @@
92
101
  {
93
102
  "path": "../../../design-system/spinner/afm-cc/tsconfig.json"
94
103
  },
104
+ {
105
+ "path": "../../tmp-editor-statsig/afm-cc/tsconfig.json"
106
+ },
95
107
  {
96
108
  "path": "../../../design-system/tokens/afm-cc/tsconfig.json"
97
109
  },
@@ -44,15 +44,24 @@
44
44
  {
45
45
  "path": "../../editor-plugin-connectivity/afm-jira/tsconfig.json"
46
46
  },
47
+ {
48
+ "path": "../../editor-plugin-content-format/afm-jira/tsconfig.json"
49
+ },
47
50
  {
48
51
  "path": "../../editor-plugin-decorations/afm-jira/tsconfig.json"
49
52
  },
50
53
  {
51
54
  "path": "../../editor-plugin-floating-toolbar/afm-jira/tsconfig.json"
52
55
  },
56
+ {
57
+ "path": "../../editor-plugin-focus/afm-jira/tsconfig.json"
58
+ },
53
59
  {
54
60
  "path": "../../editor-plugin-selection/afm-jira/tsconfig.json"
55
61
  },
62
+ {
63
+ "path": "../../editor-plugin-user-intent/afm-jira/tsconfig.json"
64
+ },
56
65
  {
57
66
  "path": "../../editor-prosemirror/afm-jira/tsconfig.json"
58
67
  },
@@ -92,6 +101,9 @@
92
101
  {
93
102
  "path": "../../../design-system/spinner/afm-jira/tsconfig.json"
94
103
  },
104
+ {
105
+ "path": "../../tmp-editor-statsig/afm-jira/tsconfig.json"
106
+ },
95
107
  {
96
108
  "path": "../../../design-system/tokens/afm-jira/tsconfig.json"
97
109
  },
@@ -44,15 +44,24 @@
44
44
  {
45
45
  "path": "../../editor-plugin-connectivity/afm-products/tsconfig.json"
46
46
  },
47
+ {
48
+ "path": "../../editor-plugin-content-format/afm-products/tsconfig.json"
49
+ },
47
50
  {
48
51
  "path": "../../editor-plugin-decorations/afm-products/tsconfig.json"
49
52
  },
50
53
  {
51
54
  "path": "../../editor-plugin-floating-toolbar/afm-products/tsconfig.json"
52
55
  },
56
+ {
57
+ "path": "../../editor-plugin-focus/afm-products/tsconfig.json"
58
+ },
53
59
  {
54
60
  "path": "../../editor-plugin-selection/afm-products/tsconfig.json"
55
61
  },
62
+ {
63
+ "path": "../../editor-plugin-user-intent/afm-products/tsconfig.json"
64
+ },
56
65
  {
57
66
  "path": "../../editor-prosemirror/afm-products/tsconfig.json"
58
67
  },
@@ -92,6 +101,9 @@
92
101
  {
93
102
  "path": "../../../design-system/spinner/afm-products/tsconfig.json"
94
103
  },
104
+ {
105
+ "path": "../../tmp-editor-statsig/afm-products/tsconfig.json"
106
+ },
95
107
  {
96
108
  "path": "../../../design-system/tokens/afm-products/tsconfig.json"
97
109
  },
@@ -8,6 +8,7 @@ exports.lazyBodiedSyncBlockView = void 0;
8
8
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
9
9
  var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
10
10
  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" != (0, _typeof2.default)(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); }
11
+ // Delete this file when cleaning up platform_synced_block_patch_5
11
12
  var lazyBodiedSyncBlockView = exports.lazyBodiedSyncBlockView = function lazyBodiedSyncBlockView(props) {
12
13
  return (0, _lazyNodeView.withLazyLoading)({
13
14
  nodeName: 'bodiedSyncBlock',
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.bodiedSyncBlockNodeView = exports.BodiedSyncBlock = void 0;
7
+ exports.bodiedSyncBlockNodeViewOld = exports.bodiedSyncBlockNodeView = exports.BodiedSyncBlock = void 0;
8
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
10
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
@@ -19,27 +19,28 @@ var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
19
19
  var _model = require("@atlaskit/editor-prosemirror/model");
20
20
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
21
21
  var _BodiedSyncBlockWrapper = require("../ui/BodiedSyncBlockWrapper");
22
+ var _SyncBlockLabel = require("../ui/SyncBlockLabel");
22
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)); }
23
24
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
24
- var toDOM = function toDOM() {
25
+ var toDOMOld = function toDOMOld() {
25
26
  return ['div', {
26
27
  class: _syncBlock.BodiedSyncBlockSharedCssClassName.content,
27
28
  contenteditable: true
28
29
  }, 0];
29
30
  };
30
- var BodiedSyncBlock = exports.BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
31
- function BodiedSyncBlock(props) {
31
+ var BodiedSyncBlockOld = /*#__PURE__*/function (_ReactNodeView) {
32
+ function BodiedSyncBlockOld(props) {
32
33
  var _this;
33
- (0, _classCallCheck2.default)(this, BodiedSyncBlock);
34
- _this = _callSuper(this, BodiedSyncBlock, [props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props]);
34
+ (0, _classCallCheck2.default)(this, BodiedSyncBlockOld);
35
+ _this = _callSuper(this, BodiedSyncBlockOld, [props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props]);
35
36
  _this.api = props.api;
36
37
  _this.syncBlockStore = props.syncBlockStore;
37
38
  _this.handleConnectivityModeChange();
38
39
  _this.handleViewModeChange();
39
40
  return _this;
40
41
  }
41
- (0, _inherits2.default)(BodiedSyncBlock, _ReactNodeView);
42
- return (0, _createClass2.default)(BodiedSyncBlock, [{
42
+ (0, _inherits2.default)(BodiedSyncBlockOld, _ReactNodeView);
43
+ return (0, _createClass2.default)(BodiedSyncBlockOld, [{
43
44
  key: "updateContentEditable",
44
45
  value: function updateContentEditable(_ref) {
45
46
  var _this$api, _this$api2;
@@ -112,7 +113,7 @@ var BodiedSyncBlock = exports.BodiedSyncBlock = /*#__PURE__*/function (_ReactNod
112
113
  }, {
113
114
  key: "getContentDOM",
114
115
  value: function getContentDOM() {
115
- var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, toDOM()),
116
+ var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, toDOMOld()),
116
117
  dom = _DOMSerializer$render.dom,
117
118
  contentDOM = _DOMSerializer$render.contentDOM;
118
119
  // In SSR, the first check won't work, so fallback to nodeType check
@@ -140,7 +141,7 @@ var BodiedSyncBlock = exports.BodiedSyncBlock = /*#__PURE__*/function (_ReactNod
140
141
  }
141
142
  }]);
142
143
  }(_reactNodeView.default);
143
- var bodiedSyncBlockNodeView = exports.bodiedSyncBlockNodeView = function bodiedSyncBlockNodeView(_ref4) {
144
+ var bodiedSyncBlockNodeViewOld = exports.bodiedSyncBlockNodeViewOld = function bodiedSyncBlockNodeViewOld(_ref4) {
144
145
  var pluginOptions = _ref4.pluginOptions,
145
146
  pmPluginFactoryParams = _ref4.pmPluginFactoryParams,
146
147
  api = _ref4.api,
@@ -148,7 +149,7 @@ var bodiedSyncBlockNodeView = exports.bodiedSyncBlockNodeView = function bodiedS
148
149
  return function (node, view, getPos) {
149
150
  var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
150
151
  eventDispatcher = pmPluginFactoryParams.eventDispatcher;
151
- return new BodiedSyncBlock({
152
+ return new BodiedSyncBlockOld({
152
153
  api: api,
153
154
  pluginOptions: pluginOptions,
154
155
  node: node,
@@ -159,4 +160,129 @@ var bodiedSyncBlockNodeView = exports.bodiedSyncBlockNodeView = function bodiedS
159
160
  syncBlockStore: syncBlockStore
160
161
  }).init();
161
162
  };
163
+ };
164
+ var toDOM = function toDOM(node) {
165
+ return ['div', {
166
+ class: "".concat(_syncBlock.BodiedSyncBlockSharedCssClassName.prefix, " bodiedSyncBlockView-content-wrap"),
167
+ localid: node.attrs.localId,
168
+ resourceid: node.attrs.resourceId
169
+ }, ['div', {
170
+ class: _syncBlock.BodiedSyncBlockSharedCssClassName.content,
171
+ contenteditable: 'true'
172
+ }, 0]];
173
+ };
174
+ var BodiedSyncBlock = exports.BodiedSyncBlock = /*#__PURE__*/function () {
175
+ function BodiedSyncBlock(node, view, getPos, api, nodeViewPortalProviderAPI, syncBlockStore) {
176
+ var _this4 = this;
177
+ (0, _classCallCheck2.default)(this, BodiedSyncBlock);
178
+ this.node = node;
179
+ this.view = view;
180
+ this.getPos = getPos;
181
+ this.api = api;
182
+ this.syncBlockStore = syncBlockStore;
183
+ this.nodeViewPortalProviderAPI = nodeViewPortalProviderAPI;
184
+ var _DOMSerializer$render2 = _model.DOMSerializer.renderSpec(document, toDOM(this.node)),
185
+ dom = _DOMSerializer$render2.dom,
186
+ contentDOM = _DOMSerializer$render2.contentDOM;
187
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
188
+ this.dom = dom;
189
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
190
+ this.contentDOM = contentDOM;
191
+ this.labelKey = crypto.randomUUID();
192
+ this.nodeViewPortalProviderAPI.render(function () {
193
+ var _this4$api;
194
+ return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
195
+ component: _analytics.ACTION_SUBJECT.SYNCED_BLOCK,
196
+ componentId: _analytics.ACTION_SUBJECT_ID.SYNCED_BLOCK_LABEL,
197
+ 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,
198
+ fallbackComponent: null
199
+ }, /*#__PURE__*/_react.default.createElement(_SyncBlockLabel.SyncBlockLabel, {
200
+ isSource: true,
201
+ localId: node.attrs.localId
202
+ }));
203
+ }, this.dom, this.labelKey);
204
+ this.updateContentEditable({});
205
+ this.handleConnectivityModeChange();
206
+ this.handleViewModeChange();
207
+ }
208
+ return (0, _createClass2.default)(BodiedSyncBlock, [{
209
+ key: "updateContentEditable",
210
+ value: function updateContentEditable(_ref5) {
211
+ var _this$api7, _this$api8;
212
+ var nextConnectivityMode = _ref5.nextConnectivityMode,
213
+ nextViewMode = _ref5.nextViewMode;
214
+ 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;
215
+ 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;
216
+ var isOnline = !(0, _editorPluginConnectivity.isOfflineMode)(connectivityMode);
217
+ var isEditMode = viewMode !== 'view';
218
+ var shouldBeEditable = isOnline && isEditMode;
219
+ this.contentDOM.setAttribute('contenteditable', shouldBeEditable ? 'true' : 'false');
220
+ }
221
+ }, {
222
+ key: "handleConnectivityModeChange",
223
+ value: function handleConnectivityModeChange() {
224
+ var _this$api9,
225
+ _this5 = this;
226
+ if ((_this$api9 = this.api) !== null && _this$api9 !== void 0 && _this$api9.connectivity) {
227
+ this.cleanupConnectivityModeListener = this.api.connectivity.sharedState.onChange(function (_ref6) {
228
+ var nextSharedState = _ref6.nextSharedState;
229
+ _this5.updateContentEditable({
230
+ nextConnectivityMode: nextSharedState.mode
231
+ });
232
+ });
233
+ }
234
+ }
235
+ }, {
236
+ key: "handleViewModeChange",
237
+ value: function handleViewModeChange() {
238
+ var _this$api0,
239
+ _this6 = this;
240
+ if ((_this$api0 = this.api) !== null && _this$api0 !== void 0 && _this$api0.editorViewMode) {
241
+ this.cleanupViewModeListener = this.api.editorViewMode.sharedState.onChange(function (_ref7) {
242
+ var nextSharedState = _ref7.nextSharedState;
243
+ _this6.updateContentEditable({
244
+ nextViewMode: nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.mode
245
+ });
246
+ });
247
+ }
248
+ }
249
+ }, {
250
+ key: "update",
251
+ value: function update(node) {
252
+ if (this.node.type !== node.type) {
253
+ return false;
254
+ }
255
+ if (node !== this.node) {
256
+ var _this$api$syncedBlock2, _this$api1;
257
+ 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;
258
+ syncBlockStore === null || syncBlockStore === void 0 || syncBlockStore.sourceManager.updateSyncBlockData(node);
259
+ }
260
+ this.node = node;
261
+ return true;
262
+ }
263
+ }, {
264
+ key: "ignoreMutation",
265
+ value: function ignoreMutation(mutation) {
266
+ if (mutation.type === 'selection') {
267
+ return false;
268
+ }
269
+ return true;
270
+ }
271
+ }, {
272
+ key: "destroy",
273
+ value: function destroy() {
274
+ var _this$cleanupConnecti, _this$cleanupViewMode;
275
+ (_this$cleanupConnecti = this.cleanupConnectivityModeListener) === null || _this$cleanupConnecti === void 0 || _this$cleanupConnecti.call(this);
276
+ (_this$cleanupViewMode = this.cleanupViewModeListener) === null || _this$cleanupViewMode === void 0 || _this$cleanupViewMode.call(this);
277
+ this.nodeViewPortalProviderAPI.remove(this.labelKey);
278
+ }
279
+ }]);
280
+ }();
281
+ var bodiedSyncBlockNodeView = exports.bodiedSyncBlockNodeView = function bodiedSyncBlockNodeView(props) {
282
+ var api = props.api,
283
+ syncBlockStore = props.syncBlockStore,
284
+ nodeViewPortalProviderAPI = props.pmPluginFactoryParams.nodeViewPortalProviderAPI;
285
+ return function (node, view, getPos) {
286
+ return new BodiedSyncBlock(node, view, getPos, api, nodeViewPortalProviderAPI, syncBlockStore);
287
+ };
162
288
  };
@@ -19,6 +19,7 @@ var _state = require("@atlaskit/editor-prosemirror/state");
19
19
  var _view = require("@atlaskit/editor-prosemirror/view");
20
20
  var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
21
21
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
22
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
22
23
  var _bodiedLazySyncedBlock = require("../nodeviews/bodiedLazySyncedBlock");
23
24
  var _bodiedSyncedBlock = require("../nodeviews/bodiedSyncedBlock");
24
25
  var _syncedBlock = require("../nodeviews/syncedBlock");
@@ -353,7 +354,14 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
353
354
  }).init()
354
355
  );
355
356
  },
356
- bodiedSyncBlock: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5') ? (0, _bodiedSyncedBlock.bodiedSyncBlockNodeView)({
357
+ bodiedSyncBlock: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5') ? (0, _experiments.editorExperiment)('platform_synced_block_use_new_source_nodeview', true, {
358
+ exposure: true
359
+ }) ? (0, _bodiedSyncedBlock.bodiedSyncBlockNodeView)({
360
+ pluginOptions: options,
361
+ pmPluginFactoryParams: pmPluginFactoryParams,
362
+ api: api,
363
+ syncBlockStore: syncBlockStore
364
+ }) : (0, _bodiedSyncedBlock.bodiedSyncBlockNodeViewOld)({
357
365
  pluginOptions: options,
358
366
  pmPluginFactoryParams: pmPluginFactoryParams,
359
367
  api: api,
@@ -365,16 +373,18 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
365
373
  })
366
374
  },
367
375
  decorations: function decorations(state) {
368
- var _currentPluginState$s, _api$connectivity2, _api$editorViewMode;
376
+ var _currentPluginState$s, _api$connectivity2, _api$editorViewMode, _api$userIntent, _api$focus;
369
377
  var currentPluginState = syncedBlockPluginKey.getState(state);
370
378
  var selectionDecorationSet = (_currentPluginState$s = currentPluginState === null || currentPluginState === void 0 ? void 0 : currentPluginState.selectionDecorationSet) !== null && _currentPluginState$s !== void 0 ? _currentPluginState$s : _view.DecorationSet.empty;
371
379
  var syncBlockStore = currentPluginState === null || currentPluginState === void 0 ? void 0 : currentPluginState.syncBlockStore;
372
380
  var doc = state.doc;
373
381
  var isOffline = (0, _editorPluginConnectivity.isOfflineMode)(api === null || api === void 0 || (_api$connectivity2 = api.connectivity) === null || _api$connectivity2 === void 0 || (_api$connectivity2 = _api$connectivity2.sharedState.currentState()) === null || _api$connectivity2 === void 0 ? void 0 : _api$connectivity2.mode);
374
382
  var isViewMode = (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'view';
383
+ var isDragging = (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5') ? (api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || (_api$userIntent = _api$userIntent.sharedState.currentState()) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.currentUserIntent) === 'dragging' : undefined;
375
384
  var offlineDecorations = [];
376
385
  var viewModeDecorations = [];
377
386
  var loadingDecorations = [];
387
+ var dragDecorations = [];
378
388
  state.doc.descendants(function (node, pos) {
379
389
  if (node.type.name === 'bodiedSyncBlock' && isOffline) {
380
390
  offlineDecorations.push(_view.Decoration.node(pos, pos + node.nodeSize, {
@@ -391,8 +401,22 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
391
401
  class: _syncBlock.SyncBlockStateCssClassName.creationLoadingClassName
392
402
  }));
393
403
  }
404
+
405
+ // Show sync block border while the user is dragging
406
+ if (isDragging && (node.type.name === 'bodiedSyncBlock' || node.type.name === 'syncBlock') && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5')) {
407
+ dragDecorations.push(_view.Decoration.node(pos, pos + node.nodeSize, {
408
+ class: _syncBlock.SyncBlockStateCssClassName.draggingClassName
409
+ }));
410
+ }
394
411
  });
395
- return selectionDecorationSet.add(doc, offlineDecorations).add(doc, viewModeDecorations).add(doc, loadingDecorations);
412
+ 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 || !(0, _experiments.editorExperiment)('platform_synced_block_patch_6', true, {
413
+ exposure: true
414
+ })) {
415
+ // Don't show decorations if the editor is not focused
416
+ return selectionDecorationSet.add(doc, offlineDecorations).add(doc, viewModeDecorations).add(doc, loadingDecorations).add(doc, dragDecorations);
417
+ } else {
418
+ return _view.DecorationSet.empty.add(doc, offlineDecorations).add(doc, viewModeDecorations).add(doc, loadingDecorations).add(doc, dragDecorations);
419
+ }
396
420
  },
397
421
  handleClickOn: (0, _selection.createSelectionClickHandler)(['bodiedSyncBlock'], function (target) {
398
422
  return !!target.closest(".".concat(_syncBlock.BodiedSyncBlockSharedCssClassName.prefix));
@@ -9,6 +9,7 @@ var _react = _interopRequireDefault(require("react"));
9
9
  var _adfSchema = require("@atlaskit/adf-schema");
10
10
  var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
11
11
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
12
13
  var _editorActions = require("./editor-actions");
13
14
  var _editorCommands = require("./editor-commands");
14
15
  var _bodiedSyncBlockNodeWithToDOMFixed = require("./nodeviews/bodiedSyncBlockNodeWithToDOMFixed");
@@ -38,7 +39,13 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
38
39
  node: _adfSchema.syncBlock
39
40
  }, {
40
41
  name: 'bodiedSyncBlock',
41
- node: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') ? (0, _bodiedSyncBlockNodeWithToDOMFixed.bodiedSyncBlockNodeWithToDOMFixed)() : _adfSchema.bodiedSyncBlock
42
+ node:
43
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
44
+ (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') && !(0, _experiments.editorExperiment)('platform_synced_block_patch_6', true, {
45
+ exposure: true
46
+ }) ?
47
+ // delete bodiedSyncBlockNodeWithToDOMFixed when cleaning up platform_synced_block_patch_6
48
+ (0, _bodiedSyncBlockNodeWithToDOMFixed.bodiedSyncBlockNodeWithToDOMFixed)() : _adfSchema.bodiedSyncBlock
42
49
  }];
43
50
  },
44
51
  pmPlugins: function pmPlugins() {
@@ -8,6 +8,7 @@ exports.BodiedSyncBlockWrapper = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
10
10
  var _SyncBlockLabel = require("./SyncBlockLabel");
11
+ // Delete this file when cleaning up platform_synced_block_use_new_source_nodeview
11
12
  var BodiedSyncBlockWrapper = exports.BodiedSyncBlockWrapper = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
12
13
  var node = _ref.node,
13
14
  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
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -13,6 +13,7 @@ var _messages = require("@atlaskit/editor-common/messages");
13
13
  var _syncBlock = require("@atlaskit/editor-common/sync-block");
14
14
  var _blockSynced = _interopRequireDefault(require("@atlaskit/icon-lab/core/block-synced"));
15
15
  var _compiled = require("@atlaskit/primitives/compiled");
16
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
16
17
  var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
17
18
  var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
18
19
  var _time = require("./utils/time");
@@ -79,7 +80,9 @@ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
79
80
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
80
81
  ,
81
82
  className: _syncBlock.SyncBlockLabelSharedCssClassName.labelClassName,
82
- "aria-describedby": ariaDescribedById
83
+ "aria-describedby": (isSource || isUnsyncedBlock) && (0, _experiments.editorExperiment)('platform_synced_block_patch_6', true, {
84
+ exposure: true
85
+ }) ? undefined : ariaDescribedById
83
86
  }, /*#__PURE__*/_react.default.createElement(_blockSynced.default, {
84
87
  color: "var(--ds-icon-subtle, #505258)",
85
88
  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
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -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
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -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 const lazyBodiedSyncBlockView = props => {
3
4
  return withLazyLoading({
4
5
  nodeName: 'bodiedSyncBlock',
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
2
+ import { ACTION_SUBJECT, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
3
3
  import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
4
4
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
5
5
  import { BodiedSyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
@@ -7,11 +7,12 @@ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
7
7
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
8
8
  import { fg } from '@atlaskit/platform-feature-flags';
9
9
  import { BodiedSyncBlockWrapper } from '../ui/BodiedSyncBlockWrapper';
10
- const toDOM = () => ['div', {
10
+ import { SyncBlockLabel } from '../ui/SyncBlockLabel';
11
+ const toDOMOld = () => ['div', {
11
12
  class: BodiedSyncBlockSharedCssClassName.content,
12
13
  contenteditable: true
13
14
  }, 0];
14
- export class BodiedSyncBlock extends ReactNodeView {
15
+ class BodiedSyncBlockOld extends ReactNodeView {
15
16
  constructor(props) {
16
17
  super(props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props);
17
18
  this.api = props.api;
@@ -84,7 +85,7 @@ export class BodiedSyncBlock extends ReactNodeView {
84
85
  const {
85
86
  dom,
86
87
  contentDOM
87
- } = DOMSerializer.renderSpec(document, toDOM());
88
+ } = DOMSerializer.renderSpec(document, toDOMOld());
88
89
  // In SSR, the first check won't work, so fallback to nodeType check
89
90
  if (dom instanceof HTMLElement || dom.nodeType === 1 && fg('platform_synced_block_patch_5')) {
90
91
  this.updateContentEditable({
@@ -107,7 +108,7 @@ export class BodiedSyncBlock extends ReactNodeView {
107
108
  }
108
109
  }
109
110
  }
110
- export const bodiedSyncBlockNodeView = ({
111
+ export const bodiedSyncBlockNodeViewOld = ({
111
112
  pluginOptions,
112
113
  pmPluginFactoryParams,
113
114
  api,
@@ -117,7 +118,7 @@ export const bodiedSyncBlockNodeView = ({
117
118
  portalProviderAPI,
118
119
  eventDispatcher
119
120
  } = pmPluginFactoryParams;
120
- return new BodiedSyncBlock({
121
+ return new BodiedSyncBlockOld({
121
122
  api,
122
123
  pluginOptions,
123
124
  node,
@@ -127,4 +128,118 @@ export const bodiedSyncBlockNodeView = ({
127
128
  eventDispatcher,
128
129
  syncBlockStore
129
130
  }).init();
131
+ };
132
+ const toDOM = node => ['div', {
133
+ class: `${BodiedSyncBlockSharedCssClassName.prefix} bodiedSyncBlockView-content-wrap`,
134
+ localid: node.attrs.localId,
135
+ resourceid: node.attrs.resourceId
136
+ }, ['div', {
137
+ class: BodiedSyncBlockSharedCssClassName.content,
138
+ contenteditable: 'true'
139
+ }, 0]];
140
+ export class BodiedSyncBlock {
141
+ constructor(node, view, getPos, api, nodeViewPortalProviderAPI, syncBlockStore) {
142
+ this.node = node;
143
+ this.view = view;
144
+ this.getPos = getPos;
145
+ this.api = api;
146
+ this.syncBlockStore = syncBlockStore;
147
+ this.nodeViewPortalProviderAPI = nodeViewPortalProviderAPI;
148
+ const {
149
+ dom,
150
+ contentDOM
151
+ } = DOMSerializer.renderSpec(document, toDOM(this.node));
152
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
153
+ this.dom = dom;
154
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
155
+ this.contentDOM = contentDOM;
156
+ this.labelKey = crypto.randomUUID();
157
+ this.nodeViewPortalProviderAPI.render(() => {
158
+ var _this$api7, _this$api7$analytics;
159
+ return /*#__PURE__*/React.createElement(ErrorBoundary, {
160
+ component: ACTION_SUBJECT.SYNCED_BLOCK,
161
+ componentId: ACTION_SUBJECT_ID.SYNCED_BLOCK_LABEL,
162
+ dispatchAnalyticsEvent: (_this$api7 = this.api) === null || _this$api7 === void 0 ? void 0 : (_this$api7$analytics = _this$api7.analytics) === null || _this$api7$analytics === void 0 ? void 0 : _this$api7$analytics.actions.fireAnalyticsEvent,
163
+ fallbackComponent: null
164
+ }, /*#__PURE__*/React.createElement(SyncBlockLabel, {
165
+ isSource: true,
166
+ localId: node.attrs.localId
167
+ }));
168
+ }, this.dom, this.labelKey);
169
+ this.updateContentEditable({});
170
+ this.handleConnectivityModeChange();
171
+ this.handleViewModeChange();
172
+ }
173
+ updateContentEditable({
174
+ nextConnectivityMode,
175
+ nextViewMode
176
+ }) {
177
+ var _this$api8, _this$api8$connectivi, _this$api8$connectivi2, _this$api8$connectivi3, _this$api9, _this$api9$editorView, _this$api9$editorView2, _this$api9$editorView3;
178
+ const connectivityMode = nextConnectivityMode !== null && nextConnectivityMode !== void 0 ? nextConnectivityMode : (_this$api8 = this.api) === null || _this$api8 === void 0 ? void 0 : (_this$api8$connectivi = _this$api8.connectivity) === null || _this$api8$connectivi === void 0 ? void 0 : (_this$api8$connectivi2 = _this$api8$connectivi.sharedState) === null || _this$api8$connectivi2 === void 0 ? void 0 : (_this$api8$connectivi3 = _this$api8$connectivi2.currentState()) === null || _this$api8$connectivi3 === void 0 ? void 0 : _this$api8$connectivi3.mode;
179
+ const viewMode = nextViewMode !== null && nextViewMode !== void 0 ? nextViewMode : (_this$api9 = this.api) === null || _this$api9 === void 0 ? void 0 : (_this$api9$editorView = _this$api9.editorViewMode) === null || _this$api9$editorView === void 0 ? void 0 : (_this$api9$editorView2 = _this$api9$editorView.sharedState) === null || _this$api9$editorView2 === void 0 ? void 0 : (_this$api9$editorView3 = _this$api9$editorView2.currentState()) === null || _this$api9$editorView3 === void 0 ? void 0 : _this$api9$editorView3.mode;
180
+ const isOnline = !isOfflineMode(connectivityMode);
181
+ const isEditMode = viewMode !== 'view';
182
+ const shouldBeEditable = isOnline && isEditMode;
183
+ this.contentDOM.setAttribute('contenteditable', shouldBeEditable ? 'true' : 'false');
184
+ }
185
+ handleConnectivityModeChange() {
186
+ var _this$api0;
187
+ if ((_this$api0 = this.api) !== null && _this$api0 !== void 0 && _this$api0.connectivity) {
188
+ this.cleanupConnectivityModeListener = this.api.connectivity.sharedState.onChange(({
189
+ nextSharedState
190
+ }) => {
191
+ this.updateContentEditable({
192
+ nextConnectivityMode: nextSharedState.mode
193
+ });
194
+ });
195
+ }
196
+ }
197
+ handleViewModeChange() {
198
+ var _this$api1;
199
+ if ((_this$api1 = this.api) !== null && _this$api1 !== void 0 && _this$api1.editorViewMode) {
200
+ this.cleanupViewModeListener = this.api.editorViewMode.sharedState.onChange(({
201
+ nextSharedState
202
+ }) => {
203
+ this.updateContentEditable({
204
+ nextViewMode: nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.mode
205
+ });
206
+ });
207
+ }
208
+ }
209
+ update(node) {
210
+ if (this.node.type !== node.type) {
211
+ return false;
212
+ }
213
+ if (node !== this.node) {
214
+ var _this$api$syncedBlock2, _this$api10, _this$api10$syncedBlo, _this$api10$syncedBlo2;
215
+ const syncBlockStore = (_this$api$syncedBlock2 = (_this$api10 = this.api) === null || _this$api10 === void 0 ? void 0 : (_this$api10$syncedBlo = _this$api10.syncedBlock.sharedState) === null || _this$api10$syncedBlo === void 0 ? void 0 : (_this$api10$syncedBlo2 = _this$api10$syncedBlo.currentState()) === null || _this$api10$syncedBlo2 === void 0 ? void 0 : _this$api10$syncedBlo2.syncBlockStore) !== null && _this$api$syncedBlock2 !== void 0 ? _this$api$syncedBlock2 : this.syncBlockStore;
216
+ syncBlockStore === null || syncBlockStore === void 0 ? void 0 : syncBlockStore.sourceManager.updateSyncBlockData(node);
217
+ }
218
+ this.node = node;
219
+ return true;
220
+ }
221
+ ignoreMutation(mutation) {
222
+ if (mutation.type === 'selection') {
223
+ return false;
224
+ }
225
+ return true;
226
+ }
227
+ destroy() {
228
+ var _this$cleanupConnecti, _this$cleanupViewMode;
229
+ (_this$cleanupConnecti = this.cleanupConnectivityModeListener) === null || _this$cleanupConnecti === void 0 ? void 0 : _this$cleanupConnecti.call(this);
230
+ (_this$cleanupViewMode = this.cleanupViewModeListener) === null || _this$cleanupViewMode === void 0 ? void 0 : _this$cleanupViewMode.call(this);
231
+ this.nodeViewPortalProviderAPI.remove(this.labelKey);
232
+ }
233
+ }
234
+ export const bodiedSyncBlockNodeView = props => {
235
+ const {
236
+ api,
237
+ syncBlockStore,
238
+ pmPluginFactoryParams: {
239
+ nodeViewPortalProviderAPI
240
+ }
241
+ } = props;
242
+ return (node, view, getPos) => {
243
+ return new BodiedSyncBlock(node, view, getPos, api, nodeViewPortalProviderAPI, syncBlockStore);
244
+ };
130
245
  };