@atlaskit/editor-synced-block-provider 3.31.1 → 3.31.2
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 +8 -0
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +16 -0
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +12 -0
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +16 -0
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +2 -0
- package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +2 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 3.31.2
|
|
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
|
+
|
|
3
11
|
## 3.31.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -10,7 +10,9 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
10
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
13
14
|
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
16
|
var _types = require("../common/types");
|
|
15
17
|
var _errorHandling = require("../utils/errorHandling");
|
|
16
18
|
var _experienceTracking = require("../utils/experienceTracking");
|
|
@@ -26,6 +28,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
26
28
|
function SourceSyncBlockStoreManager(dataProvider) {
|
|
27
29
|
var _this = this;
|
|
28
30
|
(0, _classCallCheck2.default)(this, SourceSyncBlockStoreManager);
|
|
31
|
+
(0, _defineProperty2.default)(this, "hasReceivedContentChange", false);
|
|
29
32
|
(0, _defineProperty2.default)(this, "setPendingDeletion", function (Ids, value) {
|
|
30
33
|
var syncBlock = _this.syncBlockCache.get(Ids.resourceId);
|
|
31
34
|
if (syncBlock) {
|
|
@@ -69,6 +72,12 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
69
72
|
throw new Error('Local ID or resource ID is not set');
|
|
70
73
|
}
|
|
71
74
|
var syncBlockData = (0, _utils.convertSyncBlockPMNodeToSyncBlockData)(syncBlockNode);
|
|
75
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_5')) {
|
|
76
|
+
var cachedBlock = this.syncBlockCache.get(resourceId);
|
|
77
|
+
if (cachedBlock && !(0, _isEqual.default)(syncBlockData.content, cachedBlock.content)) {
|
|
78
|
+
this.hasReceivedContentChange = true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
72
81
|
this.syncBlockCache.set(resourceId, _objectSpread(_objectSpread({}, syncBlockData), {}, {
|
|
73
82
|
isDirty: true
|
|
74
83
|
}));
|
|
@@ -197,6 +206,13 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
197
206
|
}
|
|
198
207
|
return flush;
|
|
199
208
|
}())
|
|
209
|
+
}, {
|
|
210
|
+
key: "hasUnsavedChanges",
|
|
211
|
+
value: function hasUnsavedChanges() {
|
|
212
|
+
return this.hasReceivedContentChange && Array.from(this.syncBlockCache.values()).some(function (syncBlockData) {
|
|
213
|
+
return syncBlockData.isDirty;
|
|
214
|
+
});
|
|
215
|
+
}
|
|
200
216
|
}, {
|
|
201
217
|
key: "isPendingCreation",
|
|
202
218
|
value: function isPendingCreation(resourceId) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import isEqual from 'lodash/isEqual';
|
|
2
3
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
5
|
import { SyncBlockError } from '../common/types';
|
|
4
6
|
import { updateErrorPayload, createErrorPayload, deleteErrorPayload, updateCacheErrorPayload, getSourceInfoErrorPayload, updateSuccessPayload, createSuccessPayload, deleteSuccessPayload, fetchReferencesErrorPayload } from '../utils/errorHandling';
|
|
5
7
|
import { getCreateSourceExperience, getDeleteSourceExperience, getSaveSourceExperience, getFetchSourceInfoExperience } from '../utils/experienceTracking';
|
|
@@ -11,6 +13,7 @@ import { convertSyncBlockPMNodeToSyncBlockData } from '../utils/utils';
|
|
|
11
13
|
// Ensures consistency between local and remote state, and can be used in both editor and renderer contexts.
|
|
12
14
|
export class SourceSyncBlockStoreManager {
|
|
13
15
|
constructor(dataProvider) {
|
|
16
|
+
_defineProperty(this, "hasReceivedContentChange", false);
|
|
14
17
|
_defineProperty(this, "setPendingDeletion", (Ids, value) => {
|
|
15
18
|
const syncBlock = this.syncBlockCache.get(Ids.resourceId);
|
|
16
19
|
if (syncBlock) {
|
|
@@ -49,6 +52,12 @@ export class SourceSyncBlockStoreManager {
|
|
|
49
52
|
throw new Error('Local ID or resource ID is not set');
|
|
50
53
|
}
|
|
51
54
|
const syncBlockData = convertSyncBlockPMNodeToSyncBlockData(syncBlockNode);
|
|
55
|
+
if (fg('platform_synced_block_patch_5')) {
|
|
56
|
+
const cachedBlock = this.syncBlockCache.get(resourceId);
|
|
57
|
+
if (cachedBlock && !isEqual(syncBlockData.content, cachedBlock.content)) {
|
|
58
|
+
this.hasReceivedContentChange = true;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
52
61
|
this.syncBlockCache.set(resourceId, {
|
|
53
62
|
...syncBlockData,
|
|
54
63
|
isDirty: true
|
|
@@ -146,6 +155,9 @@ export class SourceSyncBlockStoreManager {
|
|
|
146
155
|
return false;
|
|
147
156
|
}
|
|
148
157
|
}
|
|
158
|
+
hasUnsavedChanges() {
|
|
159
|
+
return this.hasReceivedContentChange && Array.from(this.syncBlockCache.values()).some(syncBlockData => syncBlockData.isDirty);
|
|
160
|
+
}
|
|
149
161
|
isPendingCreation(resourceId) {
|
|
150
162
|
return this.creationCompletionCallbacks.has(resourceId);
|
|
151
163
|
}
|
|
@@ -5,7 +5,9 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
5
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
6
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
7
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
+
import isEqual from 'lodash/isEqual';
|
|
8
9
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
11
|
import { SyncBlockError } from '../common/types';
|
|
10
12
|
import { updateErrorPayload, createErrorPayload, deleteErrorPayload, updateCacheErrorPayload, getSourceInfoErrorPayload, updateSuccessPayload, createSuccessPayload, deleteSuccessPayload, fetchReferencesErrorPayload } from '../utils/errorHandling';
|
|
11
13
|
import { getCreateSourceExperience, getDeleteSourceExperience, getSaveSourceExperience, getFetchSourceInfoExperience } from '../utils/experienceTracking';
|
|
@@ -19,6 +21,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
19
21
|
function SourceSyncBlockStoreManager(dataProvider) {
|
|
20
22
|
var _this = this;
|
|
21
23
|
_classCallCheck(this, SourceSyncBlockStoreManager);
|
|
24
|
+
_defineProperty(this, "hasReceivedContentChange", false);
|
|
22
25
|
_defineProperty(this, "setPendingDeletion", function (Ids, value) {
|
|
23
26
|
var syncBlock = _this.syncBlockCache.get(Ids.resourceId);
|
|
24
27
|
if (syncBlock) {
|
|
@@ -62,6 +65,12 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
62
65
|
throw new Error('Local ID or resource ID is not set');
|
|
63
66
|
}
|
|
64
67
|
var syncBlockData = convertSyncBlockPMNodeToSyncBlockData(syncBlockNode);
|
|
68
|
+
if (fg('platform_synced_block_patch_5')) {
|
|
69
|
+
var cachedBlock = this.syncBlockCache.get(resourceId);
|
|
70
|
+
if (cachedBlock && !isEqual(syncBlockData.content, cachedBlock.content)) {
|
|
71
|
+
this.hasReceivedContentChange = true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
65
74
|
this.syncBlockCache.set(resourceId, _objectSpread(_objectSpread({}, syncBlockData), {}, {
|
|
66
75
|
isDirty: true
|
|
67
76
|
}));
|
|
@@ -190,6 +199,13 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
190
199
|
}
|
|
191
200
|
return flush;
|
|
192
201
|
}())
|
|
202
|
+
}, {
|
|
203
|
+
key: "hasUnsavedChanges",
|
|
204
|
+
value: function hasUnsavedChanges() {
|
|
205
|
+
return this.hasReceivedContentChange && Array.from(this.syncBlockCache.values()).some(function (syncBlockData) {
|
|
206
|
+
return syncBlockData.isDirty;
|
|
207
|
+
});
|
|
208
|
+
}
|
|
193
209
|
}, {
|
|
194
210
|
key: "isPendingCreation",
|
|
195
211
|
value: function isPendingCreation(resourceId) {
|
|
@@ -10,6 +10,7 @@ export declare class SourceSyncBlockStoreManager {
|
|
|
10
10
|
private dataProvider?;
|
|
11
11
|
private fireAnalyticsEvent?;
|
|
12
12
|
private syncBlockCache;
|
|
13
|
+
private hasReceivedContentChange;
|
|
13
14
|
private confirmationCallback?;
|
|
14
15
|
private deletionRetryInfo?;
|
|
15
16
|
private creationCompletionCallbacks;
|
|
@@ -31,6 +32,7 @@ export declare class SourceSyncBlockStoreManager {
|
|
|
31
32
|
* @returns true if saving all nodes successfully, false if fail to save some/all nodes
|
|
32
33
|
*/
|
|
33
34
|
flush(): Promise<boolean>;
|
|
35
|
+
hasUnsavedChanges(): boolean;
|
|
34
36
|
isPendingCreation(resourceId: ResourceId): boolean;
|
|
35
37
|
/**
|
|
36
38
|
* Fires callback to insert node (if creation is successful) and clears pending creation data
|
|
@@ -10,6 +10,7 @@ export declare class SourceSyncBlockStoreManager {
|
|
|
10
10
|
private dataProvider?;
|
|
11
11
|
private fireAnalyticsEvent?;
|
|
12
12
|
private syncBlockCache;
|
|
13
|
+
private hasReceivedContentChange;
|
|
13
14
|
private confirmationCallback?;
|
|
14
15
|
private deletionRetryInfo?;
|
|
15
16
|
private creationCompletionCallbacks;
|
|
@@ -31,6 +32,7 @@ export declare class SourceSyncBlockStoreManager {
|
|
|
31
32
|
* @returns true if saving all nodes successfully, false if fail to save some/all nodes
|
|
32
33
|
*/
|
|
33
34
|
flush(): Promise<boolean>;
|
|
35
|
+
hasUnsavedChanges(): boolean;
|
|
34
36
|
isPendingCreation(resourceId: ResourceId): boolean;
|
|
35
37
|
/**
|
|
36
38
|
* Fires callback to insert node (if creation is successful) and clears pending creation data
|
package/package.json
CHANGED
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"uuid": "^3.1.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@atlaskit/editor-common": "^111.
|
|
41
|
+
"@atlaskit/editor-common": "^111.21.0",
|
|
42
42
|
"react": "^18.2.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
"name": "@atlaskit/editor-synced-block-provider",
|
|
84
|
-
"version": "3.31.
|
|
84
|
+
"version": "3.31.2",
|
|
85
85
|
"description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
|
|
86
86
|
"author": "Atlassian Pty Ltd",
|
|
87
87
|
"license": "Apache-2.0",
|