@atlaskit/editor-plugin-synced-block 5.3.34 → 5.3.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-plugin-synced-block
2
2
 
3
+ ## 5.3.36
4
+
5
+ ### Patch Changes
6
+
7
+ - [`432dbdcd07917`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/432dbdcd07917) -
8
+ EDITOR-5500 add hasUnsavedBodiedSyncBlocks state to synced block plugin to allow confluence to
9
+ check whether changes have been saved yet before leaving the page
10
+ - Updated dependencies
11
+
12
+ ## 5.3.35
13
+
14
+ ### Patch Changes
15
+
16
+ - [`d144f08676a16`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d144f08676a16) -
17
+ [EDITOR-5528] Remove lazy loading for bodiedSyncBlock node
18
+
3
19
  ## 5.3.34
4
20
 
5
21
  ### Patch Changes
@@ -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 = void 0;
7
+ 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"));
@@ -17,6 +17,7 @@ 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");
20
21
  var _BodiedSyncBlockWrapper = require("../ui/BodiedSyncBlockWrapper");
21
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)); }
22
23
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
@@ -26,12 +27,13 @@ var toDOM = function toDOM() {
26
27
  contenteditable: true
27
28
  }, 0];
28
29
  };
29
- var BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
30
+ var BodiedSyncBlock = exports.BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
30
31
  function BodiedSyncBlock(props) {
31
32
  var _this;
32
33
  (0, _classCallCheck2.default)(this, BodiedSyncBlock);
33
34
  _this = _callSuper(this, BodiedSyncBlock, [props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props]);
34
35
  _this.api = props.api;
36
+ _this.syncBlockStore = props.syncBlockStore;
35
37
  _this.handleConnectivityModeChange();
36
38
  _this.handleViewModeChange();
37
39
  return _this;
@@ -91,8 +93,9 @@ var BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
91
93
  }, {
92
94
  key: "render",
93
95
  value: function render(_props, forwardRef) {
94
- var _this$api5, _this$api6;
95
- var syncBlockStore = (_this$api5 = this.api) === null || _this$api5 === void 0 || (_this$api5 = _this$api5.syncedBlock.sharedState) === null || _this$api5 === void 0 || (_this$api5 = _this$api5.currentState()) === null || _this$api5 === void 0 ? void 0 : _this$api5.syncBlockStore;
96
+ var _this$api$syncedBlock, _this$api5, _this$api6;
97
+ // Use passed syncBlockStore for SSR where sharedState.currentState() is delayed
98
+ var syncBlockStore = (_this$api$syncedBlock = (_this$api5 = this.api) === null || _this$api5 === void 0 || (_this$api5 = _this$api5.syncedBlock.sharedState) === null || _this$api5 === void 0 || (_this$api5 = _this$api5.currentState()) === null || _this$api5 === void 0 ? void 0 : _this$api5.syncBlockStore) !== null && _this$api$syncedBlock !== void 0 ? _this$api$syncedBlock : this.syncBlockStore;
96
99
  if (!syncBlockStore) {
97
100
  return null;
98
101
  }
@@ -112,10 +115,12 @@ var BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
112
115
  var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, toDOM()),
113
116
  dom = _DOMSerializer$render.dom,
114
117
  contentDOM = _DOMSerializer$render.contentDOM;
115
- if (dom instanceof HTMLElement) {
118
+ // In SSR, the first check won't work, so fallback to nodeType check
119
+ if (dom instanceof HTMLElement || dom.nodeType === 1 && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5')) {
116
120
  this.updateContentEditable({
117
121
  contentDOM: contentDOM
118
122
  });
123
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
119
124
  return {
120
125
  dom: dom,
121
126
  contentDOM: contentDOM
@@ -138,7 +143,8 @@ var BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
138
143
  var bodiedSyncBlockNodeView = exports.bodiedSyncBlockNodeView = function bodiedSyncBlockNodeView(_ref4) {
139
144
  var pluginOptions = _ref4.pluginOptions,
140
145
  pmPluginFactoryParams = _ref4.pmPluginFactoryParams,
141
- api = _ref4.api;
146
+ api = _ref4.api,
147
+ syncBlockStore = _ref4.syncBlockStore;
142
148
  return function (node, view, getPos) {
143
149
  var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
144
150
  eventDispatcher = pmPluginFactoryParams.eventDispatcher;
@@ -149,7 +155,8 @@ var bodiedSyncBlockNodeView = exports.bodiedSyncBlockNodeView = function bodiedS
149
155
  view: view,
150
156
  getPos: getPos,
151
157
  portalProviderAPI: portalProviderAPI,
152
- eventDispatcher: eventDispatcher
158
+ eventDispatcher: eventDispatcher,
159
+ syncBlockStore: syncBlockStore
153
160
  }).init();
154
161
  };
155
162
  };
@@ -20,6 +20,7 @@ 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
22
  var _bodiedLazySyncedBlock = require("../nodeviews/bodiedLazySyncedBlock");
23
+ var _bodiedSyncedBlock = require("../nodeviews/bodiedSyncedBlock");
23
24
  var _syncedBlock = require("../nodeviews/syncedBlock");
24
25
  var _types = require("../types");
25
26
  var _handleBodiedSyncBlockCreation = require("./utils/handle-bodied-sync-block-creation");
@@ -294,7 +295,8 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
294
295
  selectionDecorationSet: (0, _selectionDecorations.calculateDecorations)(instance.doc, instance.selection, instance.schema),
295
296
  activeFlag: false,
296
297
  syncBlockStore: syncBlockStore,
297
- retryCreationPosMap: new Map()
298
+ retryCreationPosMap: new Map(),
299
+ hasUnsavedBodiedSyncBlockChanges: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5') ? syncBlockStore.sourceManager.hasUnsavedChanges() : undefined
298
300
  };
299
301
  },
300
302
  apply: function apply(tr, currentPluginState, oldEditorState) {
@@ -315,7 +317,8 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
315
317
  selectionDecorationSet: newDecorationSet,
316
318
  syncBlockStore: syncBlockStore,
317
319
  retryCreationPosMap: newRetryCreationPosMap,
318
- bodiedSyncBlockDeletionStatus: (_meta$bodiedSyncBlock = meta === null || meta === void 0 ? void 0 : meta.bodiedSyncBlockDeletionStatus) !== null && _meta$bodiedSyncBlock !== void 0 ? _meta$bodiedSyncBlock : bodiedSyncBlockDeletionStatus
320
+ bodiedSyncBlockDeletionStatus: (_meta$bodiedSyncBlock = meta === null || meta === void 0 ? void 0 : meta.bodiedSyncBlockDeletionStatus) !== null && _meta$bodiedSyncBlock !== void 0 ? _meta$bodiedSyncBlock : bodiedSyncBlockDeletionStatus,
321
+ hasUnsavedBodiedSyncBlockChanges: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5') ? syncBlockStore.sourceManager.hasUnsavedChanges() : undefined
319
322
  };
320
323
  }
321
324
  },
@@ -339,7 +342,12 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
339
342
  }).init()
340
343
  );
341
344
  },
342
- bodiedSyncBlock: (0, _bodiedLazySyncedBlock.lazyBodiedSyncBlockView)({
345
+ bodiedSyncBlock: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5') ? (0, _bodiedSyncedBlock.bodiedSyncBlockNodeView)({
346
+ pluginOptions: options,
347
+ pmPluginFactoryParams: pmPluginFactoryParams,
348
+ api: api,
349
+ syncBlockStore: syncBlockStore
350
+ }) : (0, _bodiedLazySyncedBlock.lazyBodiedSyncBlockView)({
343
351
  pluginOptions: options,
344
352
  pmPluginFactoryParams: pmPluginFactoryParams,
345
353
  api: api
@@ -118,12 +118,14 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
118
118
  activeFlag = _syncedBlockPluginKey.activeFlag,
119
119
  currentSyncBlockStore = _syncedBlockPluginKey.syncBlockStore,
120
120
  bodiedSyncBlockDeletionStatus = _syncedBlockPluginKey.bodiedSyncBlockDeletionStatus,
121
- retryCreationPosMap = _syncedBlockPluginKey.retryCreationPosMap;
121
+ retryCreationPosMap = _syncedBlockPluginKey.retryCreationPosMap,
122
+ hasUnsavedBodiedSyncBlockChanges = _syncedBlockPluginKey.hasUnsavedBodiedSyncBlockChanges;
122
123
  return {
123
124
  activeFlag: activeFlag,
124
125
  syncBlockStore: currentSyncBlockStore,
125
126
  bodiedSyncBlockDeletionStatus: bodiedSyncBlockDeletionStatus,
126
- retryCreationPosMap: retryCreationPosMap
127
+ retryCreationPosMap: retryCreationPosMap,
128
+ hasUnsavedBodiedSyncBlockChanges: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5') ? hasUnsavedBodiedSyncBlockChanges : undefined
127
129
  };
128
130
  }
129
131
  };
@@ -5,15 +5,17 @@ import ReactNodeView from '@atlaskit/editor-common/react-node-view';
5
5
  import { BodiedSyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
6
6
  import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
7
7
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
8
+ import { fg } from '@atlaskit/platform-feature-flags';
8
9
  import { BodiedSyncBlockWrapper } from '../ui/BodiedSyncBlockWrapper';
9
10
  const toDOM = () => ['div', {
10
11
  class: BodiedSyncBlockSharedCssClassName.content,
11
12
  contenteditable: true
12
13
  }, 0];
13
- class BodiedSyncBlock extends ReactNodeView {
14
+ export class BodiedSyncBlock extends ReactNodeView {
14
15
  constructor(props) {
15
16
  super(props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props);
16
17
  this.api = props.api;
18
+ this.syncBlockStore = props.syncBlockStore;
17
19
  this.handleConnectivityModeChange();
18
20
  this.handleViewModeChange();
19
21
  }
@@ -62,8 +64,9 @@ class BodiedSyncBlock extends ReactNodeView {
62
64
  return domRef;
63
65
  }
64
66
  render(_props, forwardRef) {
65
- var _this$api5, _this$api5$syncedBloc, _this$api5$syncedBloc2, _this$api6, _this$api6$analytics;
66
- const syncBlockStore = (_this$api5 = this.api) === null || _this$api5 === void 0 ? void 0 : (_this$api5$syncedBloc = _this$api5.syncedBlock.sharedState) === null || _this$api5$syncedBloc === void 0 ? void 0 : (_this$api5$syncedBloc2 = _this$api5$syncedBloc.currentState()) === null || _this$api5$syncedBloc2 === void 0 ? void 0 : _this$api5$syncedBloc2.syncBlockStore;
67
+ var _this$api$syncedBlock, _this$api5, _this$api5$syncedBloc, _this$api5$syncedBloc2, _this$api6, _this$api6$analytics;
68
+ // Use passed syncBlockStore for SSR where sharedState.currentState() is delayed
69
+ const syncBlockStore = (_this$api$syncedBlock = (_this$api5 = this.api) === null || _this$api5 === void 0 ? void 0 : (_this$api5$syncedBloc = _this$api5.syncedBlock.sharedState) === null || _this$api5$syncedBloc === void 0 ? void 0 : (_this$api5$syncedBloc2 = _this$api5$syncedBloc.currentState()) === null || _this$api5$syncedBloc2 === void 0 ? void 0 : _this$api5$syncedBloc2.syncBlockStore) !== null && _this$api$syncedBlock !== void 0 ? _this$api$syncedBlock : this.syncBlockStore;
67
70
  if (!syncBlockStore) {
68
71
  return null;
69
72
  }
@@ -82,12 +85,14 @@ class BodiedSyncBlock extends ReactNodeView {
82
85
  dom,
83
86
  contentDOM
84
87
  } = DOMSerializer.renderSpec(document, toDOM());
85
- if (dom instanceof HTMLElement) {
88
+ // In SSR, the first check won't work, so fallback to nodeType check
89
+ if (dom instanceof HTMLElement || dom.nodeType === 1 && fg('platform_synced_block_patch_5')) {
86
90
  this.updateContentEditable({
87
91
  contentDOM
88
92
  });
93
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
89
94
  return {
90
- dom,
95
+ dom: dom,
91
96
  contentDOM
92
97
  };
93
98
  }
@@ -105,7 +110,8 @@ class BodiedSyncBlock extends ReactNodeView {
105
110
  export const bodiedSyncBlockNodeView = ({
106
111
  pluginOptions,
107
112
  pmPluginFactoryParams,
108
- api
113
+ api,
114
+ syncBlockStore
109
115
  }) => (node, view, getPos) => {
110
116
  const {
111
117
  portalProviderAPI,
@@ -118,6 +124,7 @@ export const bodiedSyncBlockNodeView = ({
118
124
  view,
119
125
  getPos,
120
126
  portalProviderAPI,
121
- eventDispatcher
127
+ eventDispatcher,
128
+ syncBlockStore
122
129
  }).init();
123
130
  };
@@ -10,6 +10,7 @@ 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
12
  import { lazyBodiedSyncBlockView } from '../nodeviews/bodiedLazySyncedBlock';
13
+ import { bodiedSyncBlockNodeView } from '../nodeviews/bodiedSyncedBlock';
13
14
  import { SyncBlock as SyncBlockView } from '../nodeviews/syncedBlock';
14
15
  import { FLAG_ID } from '../types';
15
16
  import { handleBodiedSyncBlockCreation } from './utils/handle-bodied-sync-block-creation';
@@ -256,7 +257,8 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
256
257
  selectionDecorationSet: calculateDecorations(instance.doc, instance.selection, instance.schema),
257
258
  activeFlag: false,
258
259
  syncBlockStore: syncBlockStore,
259
- retryCreationPosMap: new Map()
260
+ retryCreationPosMap: new Map(),
261
+ hasUnsavedBodiedSyncBlockChanges: fg('platform_synced_block_patch_5') ? syncBlockStore.sourceManager.hasUnsavedChanges() : undefined
260
262
  };
261
263
  },
262
264
  apply: (tr, currentPluginState, oldEditorState) => {
@@ -279,7 +281,8 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
279
281
  selectionDecorationSet: newDecorationSet,
280
282
  syncBlockStore: syncBlockStore,
281
283
  retryCreationPosMap: newRetryCreationPosMap,
282
- bodiedSyncBlockDeletionStatus: (_meta$bodiedSyncBlock = meta === null || meta === void 0 ? void 0 : meta.bodiedSyncBlockDeletionStatus) !== null && _meta$bodiedSyncBlock !== void 0 ? _meta$bodiedSyncBlock : bodiedSyncBlockDeletionStatus
284
+ bodiedSyncBlockDeletionStatus: (_meta$bodiedSyncBlock = meta === null || meta === void 0 ? void 0 : meta.bodiedSyncBlockDeletionStatus) !== null && _meta$bodiedSyncBlock !== void 0 ? _meta$bodiedSyncBlock : bodiedSyncBlockDeletionStatus,
285
+ hasUnsavedBodiedSyncBlockChanges: fg('platform_synced_block_patch_5') ? syncBlockStore.sourceManager.hasUnsavedChanges() : undefined
283
286
  };
284
287
  }
285
288
  },
@@ -300,7 +303,12 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
300
303
  eventDispatcher: pmPluginFactoryParams.eventDispatcher,
301
304
  syncBlockStore: syncBlockStore
302
305
  }).init(),
303
- bodiedSyncBlock: lazyBodiedSyncBlockView({
306
+ bodiedSyncBlock: fg('platform_synced_block_patch_5') ? bodiedSyncBlockNodeView({
307
+ pluginOptions: options,
308
+ pmPluginFactoryParams,
309
+ api,
310
+ syncBlockStore
311
+ }) : lazyBodiedSyncBlockView({
304
312
  pluginOptions: options,
305
313
  pmPluginFactoryParams,
306
314
  api
@@ -104,13 +104,15 @@ export const syncedBlockPlugin = ({
104
104
  activeFlag,
105
105
  syncBlockStore: currentSyncBlockStore,
106
106
  bodiedSyncBlockDeletionStatus,
107
- retryCreationPosMap
107
+ retryCreationPosMap,
108
+ hasUnsavedBodiedSyncBlockChanges
108
109
  } = syncedBlockPluginKey.getState(editorState);
109
110
  return {
110
111
  activeFlag,
111
112
  syncBlockStore: currentSyncBlockStore,
112
113
  bodiedSyncBlockDeletionStatus,
113
- retryCreationPosMap
114
+ retryCreationPosMap,
115
+ hasUnsavedBodiedSyncBlockChanges: fg('platform_synced_block_patch_5') ? hasUnsavedBodiedSyncBlockChanges : undefined
114
116
  };
115
117
  }
116
118
  };
@@ -12,6 +12,7 @@ import ReactNodeView from '@atlaskit/editor-common/react-node-view';
12
12
  import { BodiedSyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
13
13
  import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
14
14
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
15
+ import { fg } from '@atlaskit/platform-feature-flags';
15
16
  import { BodiedSyncBlockWrapper } from '../ui/BodiedSyncBlockWrapper';
16
17
  var toDOM = function toDOM() {
17
18
  return ['div', {
@@ -19,12 +20,13 @@ var toDOM = function toDOM() {
19
20
  contenteditable: true
20
21
  }, 0];
21
22
  };
22
- var BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
23
+ export var BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
23
24
  function BodiedSyncBlock(props) {
24
25
  var _this;
25
26
  _classCallCheck(this, BodiedSyncBlock);
26
27
  _this = _callSuper(this, BodiedSyncBlock, [props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props]);
27
28
  _this.api = props.api;
29
+ _this.syncBlockStore = props.syncBlockStore;
28
30
  _this.handleConnectivityModeChange();
29
31
  _this.handleViewModeChange();
30
32
  return _this;
@@ -84,8 +86,9 @@ var BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
84
86
  }, {
85
87
  key: "render",
86
88
  value: function render(_props, forwardRef) {
87
- var _this$api5, _this$api6;
88
- var syncBlockStore = (_this$api5 = this.api) === null || _this$api5 === void 0 || (_this$api5 = _this$api5.syncedBlock.sharedState) === null || _this$api5 === void 0 || (_this$api5 = _this$api5.currentState()) === null || _this$api5 === void 0 ? void 0 : _this$api5.syncBlockStore;
89
+ var _this$api$syncedBlock, _this$api5, _this$api6;
90
+ // Use passed syncBlockStore for SSR where sharedState.currentState() is delayed
91
+ var syncBlockStore = (_this$api$syncedBlock = (_this$api5 = this.api) === null || _this$api5 === void 0 || (_this$api5 = _this$api5.syncedBlock.sharedState) === null || _this$api5 === void 0 || (_this$api5 = _this$api5.currentState()) === null || _this$api5 === void 0 ? void 0 : _this$api5.syncBlockStore) !== null && _this$api$syncedBlock !== void 0 ? _this$api$syncedBlock : this.syncBlockStore;
89
92
  if (!syncBlockStore) {
90
93
  return null;
91
94
  }
@@ -105,10 +108,12 @@ var BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
105
108
  var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOM()),
106
109
  dom = _DOMSerializer$render.dom,
107
110
  contentDOM = _DOMSerializer$render.contentDOM;
108
- if (dom instanceof HTMLElement) {
111
+ // In SSR, the first check won't work, so fallback to nodeType check
112
+ if (dom instanceof HTMLElement || dom.nodeType === 1 && fg('platform_synced_block_patch_5')) {
109
113
  this.updateContentEditable({
110
114
  contentDOM: contentDOM
111
115
  });
116
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
112
117
  return {
113
118
  dom: dom,
114
119
  contentDOM: contentDOM
@@ -131,7 +136,8 @@ var BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
131
136
  export var bodiedSyncBlockNodeView = function bodiedSyncBlockNodeView(_ref4) {
132
137
  var pluginOptions = _ref4.pluginOptions,
133
138
  pmPluginFactoryParams = _ref4.pmPluginFactoryParams,
134
- api = _ref4.api;
139
+ api = _ref4.api,
140
+ syncBlockStore = _ref4.syncBlockStore;
135
141
  return function (node, view, getPos) {
136
142
  var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
137
143
  eventDispatcher = pmPluginFactoryParams.eventDispatcher;
@@ -142,7 +148,8 @@ export var bodiedSyncBlockNodeView = function bodiedSyncBlockNodeView(_ref4) {
142
148
  view: view,
143
149
  getPos: getPos,
144
150
  portalProviderAPI: portalProviderAPI,
145
- eventDispatcher: eventDispatcher
151
+ eventDispatcher: eventDispatcher,
152
+ syncBlockStore: syncBlockStore
146
153
  }).init();
147
154
  };
148
155
  };
@@ -18,6 +18,7 @@ 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
20
  import { lazyBodiedSyncBlockView } from '../nodeviews/bodiedLazySyncedBlock';
21
+ import { bodiedSyncBlockNodeView } from '../nodeviews/bodiedSyncedBlock';
21
22
  import { SyncBlock as SyncBlockView } from '../nodeviews/syncedBlock';
22
23
  import { FLAG_ID } from '../types';
23
24
  import { handleBodiedSyncBlockCreation } from './utils/handle-bodied-sync-block-creation';
@@ -287,7 +288,8 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
287
288
  selectionDecorationSet: calculateDecorations(instance.doc, instance.selection, instance.schema),
288
289
  activeFlag: false,
289
290
  syncBlockStore: syncBlockStore,
290
- retryCreationPosMap: new Map()
291
+ retryCreationPosMap: new Map(),
292
+ hasUnsavedBodiedSyncBlockChanges: fg('platform_synced_block_patch_5') ? syncBlockStore.sourceManager.hasUnsavedChanges() : undefined
291
293
  };
292
294
  },
293
295
  apply: function apply(tr, currentPluginState, oldEditorState) {
@@ -308,7 +310,8 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
308
310
  selectionDecorationSet: newDecorationSet,
309
311
  syncBlockStore: syncBlockStore,
310
312
  retryCreationPosMap: newRetryCreationPosMap,
311
- bodiedSyncBlockDeletionStatus: (_meta$bodiedSyncBlock = meta === null || meta === void 0 ? void 0 : meta.bodiedSyncBlockDeletionStatus) !== null && _meta$bodiedSyncBlock !== void 0 ? _meta$bodiedSyncBlock : bodiedSyncBlockDeletionStatus
313
+ bodiedSyncBlockDeletionStatus: (_meta$bodiedSyncBlock = meta === null || meta === void 0 ? void 0 : meta.bodiedSyncBlockDeletionStatus) !== null && _meta$bodiedSyncBlock !== void 0 ? _meta$bodiedSyncBlock : bodiedSyncBlockDeletionStatus,
314
+ hasUnsavedBodiedSyncBlockChanges: fg('platform_synced_block_patch_5') ? syncBlockStore.sourceManager.hasUnsavedChanges() : undefined
312
315
  };
313
316
  }
314
317
  },
@@ -332,7 +335,12 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
332
335
  }).init()
333
336
  );
334
337
  },
335
- bodiedSyncBlock: lazyBodiedSyncBlockView({
338
+ bodiedSyncBlock: fg('platform_synced_block_patch_5') ? bodiedSyncBlockNodeView({
339
+ pluginOptions: options,
340
+ pmPluginFactoryParams: pmPluginFactoryParams,
341
+ api: api,
342
+ syncBlockStore: syncBlockStore
343
+ }) : lazyBodiedSyncBlockView({
336
344
  pluginOptions: options,
337
345
  pmPluginFactoryParams: pmPluginFactoryParams,
338
346
  api: api
@@ -111,12 +111,14 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
111
111
  activeFlag = _syncedBlockPluginKey.activeFlag,
112
112
  currentSyncBlockStore = _syncedBlockPluginKey.syncBlockStore,
113
113
  bodiedSyncBlockDeletionStatus = _syncedBlockPluginKey.bodiedSyncBlockDeletionStatus,
114
- retryCreationPosMap = _syncedBlockPluginKey.retryCreationPosMap;
114
+ retryCreationPosMap = _syncedBlockPluginKey.retryCreationPosMap,
115
+ hasUnsavedBodiedSyncBlockChanges = _syncedBlockPluginKey.hasUnsavedBodiedSyncBlockChanges;
115
116
  return {
116
117
  activeFlag: activeFlag,
117
118
  syncBlockStore: currentSyncBlockStore,
118
119
  bodiedSyncBlockDeletionStatus: bodiedSyncBlockDeletionStatus,
119
- retryCreationPosMap: retryCreationPosMap
120
+ retryCreationPosMap: retryCreationPosMap,
121
+ hasUnsavedBodiedSyncBlockChanges: fg('platform_synced_block_patch_5') ? hasUnsavedBodiedSyncBlockChanges : undefined
120
122
  };
121
123
  }
122
124
  };
@@ -1,10 +1,12 @@
1
+ import React from 'react';
1
2
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
2
3
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
3
- import type { ReactComponentProps } from '@atlaskit/editor-common/react-node-view';
4
+ import type { ForwardRef, ReactComponentProps } from '@atlaskit/editor-common/react-node-view';
4
5
  import ReactNodeView, { type getPosHandler } from '@atlaskit/editor-common/react-node-view';
5
6
  import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
6
7
  import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
7
8
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
9
+ import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
8
10
  import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlockPluginType';
9
11
  export interface BodiedSyncBlockNodeViewProps extends ReactComponentProps {
10
12
  api?: ExtractInjectionAPI<SyncedBlockPlugin>;
@@ -13,11 +15,30 @@ export interface BodiedSyncBlockNodeViewProps extends ReactComponentProps {
13
15
  node: PMNode;
14
16
  pluginOptions: SyncedBlockPluginOptions | undefined;
15
17
  portalProviderAPI: PortalProviderAPI;
18
+ syncBlockStore?: SyncBlockStoreManager;
16
19
  view: EditorView;
17
20
  }
21
+ export declare class BodiedSyncBlock extends ReactNodeView<BodiedSyncBlockNodeViewProps> {
22
+ private cleanupConnectivityModeListener?;
23
+ private cleanupViewModeListener?;
24
+ private api?;
25
+ private syncBlockStore?;
26
+ constructor(props: BodiedSyncBlockNodeViewProps);
27
+ private updateContentEditable;
28
+ private handleConnectivityModeChange;
29
+ 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;
36
+ destroy(): void;
37
+ }
18
38
  export interface BodiedSyncBlockNodeViewProperties {
19
39
  api?: ExtractInjectionAPI<SyncedBlockPlugin>;
20
40
  pluginOptions: SyncedBlockPluginOptions | undefined;
21
41
  pmPluginFactoryParams: PMPluginFactoryParams;
42
+ syncBlockStore?: SyncBlockStoreManager;
22
43
  }
23
44
  export declare const bodiedSyncBlockNodeView: (props: BodiedSyncBlockNodeViewProperties) => (node: PMNode, view: EditorView, getPos: getPosHandler) => ReactNodeView<BodiedSyncBlockNodeViewProps>;
@@ -9,6 +9,7 @@ export declare const syncedBlockPluginKey: PluginKey<any>;
9
9
  type SyncedBlockPluginState = {
10
10
  activeFlag: ActiveFlag;
11
11
  bodiedSyncBlockDeletionStatus?: BodiedSyncBlockDeletionStatus;
12
+ hasUnsavedBodiedSyncBlockChanges?: boolean;
12
13
  retryCreationPosMap: RetryCreationPosMap;
13
14
  selectionDecorationSet: DecorationSet;
14
15
  syncBlockStore: SyncBlockStoreManager;
@@ -46,6 +46,10 @@ export type SyncedBlockSharedState = {
46
46
  * The current sync block store manager, used to manage fetching and updating sync block data
47
47
  */
48
48
  syncBlockStore: SyncBlockStoreManager;
49
+ /**
50
+ * Whether there are unsaved bodiedSyncBlock changes in the cache
51
+ */
52
+ hasUnsavedBodiedSyncBlockChanges: boolean;
49
53
  };
50
54
  export type SyncBlockAttrs = {
51
55
  localId: string;
@@ -1,10 +1,12 @@
1
+ import React from 'react';
1
2
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
2
3
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
3
- import type { ReactComponentProps } from '@atlaskit/editor-common/react-node-view';
4
+ import type { ForwardRef, ReactComponentProps } from '@atlaskit/editor-common/react-node-view';
4
5
  import ReactNodeView, { type getPosHandler } from '@atlaskit/editor-common/react-node-view';
5
6
  import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
6
7
  import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
7
8
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
9
+ import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
8
10
  import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlockPluginType';
9
11
  export interface BodiedSyncBlockNodeViewProps extends ReactComponentProps {
10
12
  api?: ExtractInjectionAPI<SyncedBlockPlugin>;
@@ -13,11 +15,30 @@ export interface BodiedSyncBlockNodeViewProps extends ReactComponentProps {
13
15
  node: PMNode;
14
16
  pluginOptions: SyncedBlockPluginOptions | undefined;
15
17
  portalProviderAPI: PortalProviderAPI;
18
+ syncBlockStore?: SyncBlockStoreManager;
16
19
  view: EditorView;
17
20
  }
21
+ export declare class BodiedSyncBlock extends ReactNodeView<BodiedSyncBlockNodeViewProps> {
22
+ private cleanupConnectivityModeListener?;
23
+ private cleanupViewModeListener?;
24
+ private api?;
25
+ private syncBlockStore?;
26
+ constructor(props: BodiedSyncBlockNodeViewProps);
27
+ private updateContentEditable;
28
+ private handleConnectivityModeChange;
29
+ 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;
36
+ destroy(): void;
37
+ }
18
38
  export interface BodiedSyncBlockNodeViewProperties {
19
39
  api?: ExtractInjectionAPI<SyncedBlockPlugin>;
20
40
  pluginOptions: SyncedBlockPluginOptions | undefined;
21
41
  pmPluginFactoryParams: PMPluginFactoryParams;
42
+ syncBlockStore?: SyncBlockStoreManager;
22
43
  }
23
44
  export declare const bodiedSyncBlockNodeView: (props: BodiedSyncBlockNodeViewProperties) => (node: PMNode, view: EditorView, getPos: getPosHandler) => ReactNodeView<BodiedSyncBlockNodeViewProps>;
@@ -9,6 +9,7 @@ export declare const syncedBlockPluginKey: PluginKey<any>;
9
9
  type SyncedBlockPluginState = {
10
10
  activeFlag: ActiveFlag;
11
11
  bodiedSyncBlockDeletionStatus?: BodiedSyncBlockDeletionStatus;
12
+ hasUnsavedBodiedSyncBlockChanges?: boolean;
12
13
  retryCreationPosMap: RetryCreationPosMap;
13
14
  selectionDecorationSet: DecorationSet;
14
15
  syncBlockStore: SyncBlockStoreManager;
@@ -46,6 +46,10 @@ export type SyncedBlockSharedState = {
46
46
  * The current sync block store manager, used to manage fetching and updating sync block data
47
47
  */
48
48
  syncBlockStore: SyncBlockStoreManager;
49
+ /**
50
+ * Whether there are unsaved bodiedSyncBlock changes in the cache
51
+ */
52
+ hasUnsavedBodiedSyncBlockChanges: boolean;
49
53
  };
50
54
  export type SyncBlockAttrs = {
51
55
  localId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-synced-block",
3
- "version": "5.3.34",
3
+ "version": "5.3.36",
4
4
  "description": "SyncedBlock plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -28,7 +28,7 @@
28
28
  "sideEffects": false,
29
29
  "atlaskit:src": "src/index.ts",
30
30
  "dependencies": {
31
- "@atlaskit/adf-schema": "^52.0.0",
31
+ "@atlaskit/adf-schema": "^52.1.0",
32
32
  "@atlaskit/button": "23.9.9",
33
33
  "@atlaskit/dropdown-menu": "16.5.0",
34
34
  "@atlaskit/editor-json-transformer": "^8.31.0",
@@ -61,7 +61,7 @@
61
61
  "react-intl-next": "npm:react-intl@^5.18.1"
62
62
  },
63
63
  "peerDependencies": {
64
- "@atlaskit/editor-common": "^111.20.0",
64
+ "@atlaskit/editor-common": "^111.21.0",
65
65
  "react": "^18.2.0"
66
66
  },
67
67
  "devDependencies": {