@atlaskit/editor-synced-block-provider 2.14.1 → 2.15.0
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 +14 -0
- package/dist/cjs/common/types.js +3 -1
- package/dist/cjs/providers/block-service/blockServiceAPI.js +8 -12
- package/dist/es2019/common/types.js +3 -1
- package/dist/es2019/providers/block-service/blockServiceAPI.js +7 -11
- package/dist/esm/common/types.js +3 -1
- package/dist/esm/providers/block-service/blockServiceAPI.js +8 -12
- package/dist/types/common/types.d.ts +2 -1
- package/dist/types/providers/block-service/blockServiceAPI.d.ts +3 -2
- package/dist/types-ts4.5/common/types.d.ts +2 -1
- package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +3 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 2.15.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`4daaa6358e6fb`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4daaa6358e6fb) -
|
|
8
|
+
Update resourceId generation for create reference from browser copy + pasting source block
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- [`dcc6a3e73f414`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/dcc6a3e73f414) -
|
|
13
|
+
[ux] EDITOR-3304 add offline error state for sync blocks and update other error UI to match new
|
|
14
|
+
designs
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 2.14.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/cjs/common/types.js
CHANGED
|
@@ -13,6 +13,8 @@ var SyncBlockError = exports.SyncBlockError = /*#__PURE__*/function (SyncBlockEr
|
|
|
13
13
|
SyncBlockError["Conflict"] = "conflict";
|
|
14
14
|
// attempt to create block that already exists
|
|
15
15
|
SyncBlockError["ServerError"] = "server_error";
|
|
16
|
-
SyncBlockError["InvalidContent"] = "invalid_content";
|
|
16
|
+
SyncBlockError["InvalidContent"] = "invalid_content";
|
|
17
|
+
// content is not a valid JSON
|
|
18
|
+
SyncBlockError["Offline"] = "offline";
|
|
17
19
|
return SyncBlockError;
|
|
18
20
|
}({});
|
|
@@ -196,10 +196,11 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
196
196
|
* ADFWriteProvider implementation that writes synced block data to Block Service API
|
|
197
197
|
*/
|
|
198
198
|
var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
199
|
-
function BlockServiceADFWriteProvider(sourceAri, product) {
|
|
199
|
+
function BlockServiceADFWriteProvider(sourceAri, product, sourceDocumentId) {
|
|
200
200
|
(0, _classCallCheck2.default)(this, BlockServiceADFWriteProvider);
|
|
201
201
|
this.sourceAri = sourceAri;
|
|
202
202
|
this.product = product;
|
|
203
|
+
this.sourceDocumentId = sourceDocumentId;
|
|
203
204
|
}
|
|
204
205
|
|
|
205
206
|
// it will first try to update and if it can't (404) then it will try to create
|
|
@@ -352,12 +353,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
352
353
|
}, {
|
|
353
354
|
key: "generateResourceIdForReference",
|
|
354
355
|
value: function generateResourceIdForReference(sourceId) {
|
|
355
|
-
|
|
356
|
-
if (!(match !== null && match !== void 0 && match[1])) {
|
|
357
|
-
throw new Error("Invalid source ARI: ".concat(this.sourceAri));
|
|
358
|
-
}
|
|
359
|
-
var pageId = match[3];
|
|
360
|
-
return "".concat(this.product, "/").concat(pageId, "/").concat(sourceId);
|
|
356
|
+
return "".concat(this.product, "/").concat(this.sourceDocumentId, "/").concat(sourceId);
|
|
361
357
|
}
|
|
362
358
|
}, {
|
|
363
359
|
key: "generateResourceId",
|
|
@@ -369,16 +365,16 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
369
365
|
/**
|
|
370
366
|
* Factory function to create both providers with shared configuration
|
|
371
367
|
*/
|
|
372
|
-
var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(sourceAri, product) {
|
|
368
|
+
var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(sourceAri, product, sourceDocumentId) {
|
|
373
369
|
var fetchProvider = new BlockServiceADFFetchProvider(sourceAri);
|
|
374
|
-
var writeProvider = new BlockServiceADFWriteProvider(sourceAri, product);
|
|
370
|
+
var writeProvider = new BlockServiceADFWriteProvider(sourceAri, product, sourceDocumentId);
|
|
375
371
|
return {
|
|
376
372
|
fetchProvider: fetchProvider,
|
|
377
373
|
writeProvider: writeProvider
|
|
378
374
|
};
|
|
379
375
|
};
|
|
380
|
-
var useMemoizedBlockServiceAPIProviders = exports.useMemoizedBlockServiceAPIProviders = function useMemoizedBlockServiceAPIProviders(sourceAri, product) {
|
|
376
|
+
var useMemoizedBlockServiceAPIProviders = exports.useMemoizedBlockServiceAPIProviders = function useMemoizedBlockServiceAPIProviders(sourceAri, product, sourceDocumentId) {
|
|
381
377
|
return (0, _react.useMemo)(function () {
|
|
382
|
-
return createBlockServiceAPIProviders(sourceAri, product);
|
|
383
|
-
}, [sourceAri, product]);
|
|
378
|
+
return createBlockServiceAPIProviders(sourceAri, product, sourceDocumentId);
|
|
379
|
+
}, [sourceAri, product, sourceDocumentId]);
|
|
384
380
|
};
|
|
@@ -7,6 +7,8 @@ export let SyncBlockError = /*#__PURE__*/function (SyncBlockError) {
|
|
|
7
7
|
SyncBlockError["Conflict"] = "conflict";
|
|
8
8
|
// attempt to create block that already exists
|
|
9
9
|
SyncBlockError["ServerError"] = "server_error";
|
|
10
|
-
SyncBlockError["InvalidContent"] = "invalid_content";
|
|
10
|
+
SyncBlockError["InvalidContent"] = "invalid_content";
|
|
11
|
+
// content is not a valid JSON
|
|
12
|
+
SyncBlockError["Offline"] = "offline";
|
|
11
13
|
return SyncBlockError;
|
|
12
14
|
}({});
|
|
@@ -134,9 +134,10 @@ class BlockServiceADFFetchProvider {
|
|
|
134
134
|
* ADFWriteProvider implementation that writes synced block data to Block Service API
|
|
135
135
|
*/
|
|
136
136
|
class BlockServiceADFWriteProvider {
|
|
137
|
-
constructor(sourceAri, product) {
|
|
137
|
+
constructor(sourceAri, product, sourceDocumentId) {
|
|
138
138
|
this.sourceAri = sourceAri;
|
|
139
139
|
this.product = product;
|
|
140
|
+
this.sourceDocumentId = sourceDocumentId;
|
|
140
141
|
}
|
|
141
142
|
|
|
142
143
|
// it will first try to update and if it can't (404) then it will try to create
|
|
@@ -227,12 +228,7 @@ class BlockServiceADFWriteProvider {
|
|
|
227
228
|
|
|
228
229
|
// the sourceId is the resourceId of the source synced block.
|
|
229
230
|
generateResourceIdForReference(sourceId) {
|
|
230
|
-
|
|
231
|
-
if (!(match !== null && match !== void 0 && match[1])) {
|
|
232
|
-
throw new Error(`Invalid source ARI: ${this.sourceAri}`);
|
|
233
|
-
}
|
|
234
|
-
const pageId = match[3];
|
|
235
|
-
return `${this.product}/${pageId}/${sourceId}`;
|
|
231
|
+
return `${this.product}/${this.sourceDocumentId}/${sourceId}`;
|
|
236
232
|
}
|
|
237
233
|
generateResourceId() {
|
|
238
234
|
return crypto.randomUUID();
|
|
@@ -242,14 +238,14 @@ class BlockServiceADFWriteProvider {
|
|
|
242
238
|
/**
|
|
243
239
|
* Factory function to create both providers with shared configuration
|
|
244
240
|
*/
|
|
245
|
-
const createBlockServiceAPIProviders = (sourceAri, product) => {
|
|
241
|
+
const createBlockServiceAPIProviders = (sourceAri, product, sourceDocumentId) => {
|
|
246
242
|
const fetchProvider = new BlockServiceADFFetchProvider(sourceAri);
|
|
247
|
-
const writeProvider = new BlockServiceADFWriteProvider(sourceAri, product);
|
|
243
|
+
const writeProvider = new BlockServiceADFWriteProvider(sourceAri, product, sourceDocumentId);
|
|
248
244
|
return {
|
|
249
245
|
fetchProvider,
|
|
250
246
|
writeProvider
|
|
251
247
|
};
|
|
252
248
|
};
|
|
253
|
-
export const useMemoizedBlockServiceAPIProviders = (sourceAri, product) => {
|
|
254
|
-
return useMemo(() => createBlockServiceAPIProviders(sourceAri, product), [sourceAri, product]);
|
|
249
|
+
export const useMemoizedBlockServiceAPIProviders = (sourceAri, product, sourceDocumentId) => {
|
|
250
|
+
return useMemo(() => createBlockServiceAPIProviders(sourceAri, product, sourceDocumentId), [sourceAri, product, sourceDocumentId]);
|
|
255
251
|
};
|
package/dist/esm/common/types.js
CHANGED
|
@@ -7,6 +7,8 @@ export var SyncBlockError = /*#__PURE__*/function (SyncBlockError) {
|
|
|
7
7
|
SyncBlockError["Conflict"] = "conflict";
|
|
8
8
|
// attempt to create block that already exists
|
|
9
9
|
SyncBlockError["ServerError"] = "server_error";
|
|
10
|
-
SyncBlockError["InvalidContent"] = "invalid_content";
|
|
10
|
+
SyncBlockError["InvalidContent"] = "invalid_content";
|
|
11
|
+
// content is not a valid JSON
|
|
12
|
+
SyncBlockError["Offline"] = "offline";
|
|
11
13
|
return SyncBlockError;
|
|
12
14
|
}({});
|
|
@@ -188,10 +188,11 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
188
188
|
* ADFWriteProvider implementation that writes synced block data to Block Service API
|
|
189
189
|
*/
|
|
190
190
|
var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
191
|
-
function BlockServiceADFWriteProvider(sourceAri, product) {
|
|
191
|
+
function BlockServiceADFWriteProvider(sourceAri, product, sourceDocumentId) {
|
|
192
192
|
_classCallCheck(this, BlockServiceADFWriteProvider);
|
|
193
193
|
this.sourceAri = sourceAri;
|
|
194
194
|
this.product = product;
|
|
195
|
+
this.sourceDocumentId = sourceDocumentId;
|
|
195
196
|
}
|
|
196
197
|
|
|
197
198
|
// it will first try to update and if it can't (404) then it will try to create
|
|
@@ -344,12 +345,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
344
345
|
}, {
|
|
345
346
|
key: "generateResourceIdForReference",
|
|
346
347
|
value: function generateResourceIdForReference(sourceId) {
|
|
347
|
-
|
|
348
|
-
if (!(match !== null && match !== void 0 && match[1])) {
|
|
349
|
-
throw new Error("Invalid source ARI: ".concat(this.sourceAri));
|
|
350
|
-
}
|
|
351
|
-
var pageId = match[3];
|
|
352
|
-
return "".concat(this.product, "/").concat(pageId, "/").concat(sourceId);
|
|
348
|
+
return "".concat(this.product, "/").concat(this.sourceDocumentId, "/").concat(sourceId);
|
|
353
349
|
}
|
|
354
350
|
}, {
|
|
355
351
|
key: "generateResourceId",
|
|
@@ -361,16 +357,16 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
361
357
|
/**
|
|
362
358
|
* Factory function to create both providers with shared configuration
|
|
363
359
|
*/
|
|
364
|
-
var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(sourceAri, product) {
|
|
360
|
+
var createBlockServiceAPIProviders = function createBlockServiceAPIProviders(sourceAri, product, sourceDocumentId) {
|
|
365
361
|
var fetchProvider = new BlockServiceADFFetchProvider(sourceAri);
|
|
366
|
-
var writeProvider = new BlockServiceADFWriteProvider(sourceAri, product);
|
|
362
|
+
var writeProvider = new BlockServiceADFWriteProvider(sourceAri, product, sourceDocumentId);
|
|
367
363
|
return {
|
|
368
364
|
fetchProvider: fetchProvider,
|
|
369
365
|
writeProvider: writeProvider
|
|
370
366
|
};
|
|
371
367
|
};
|
|
372
|
-
export var useMemoizedBlockServiceAPIProviders = function useMemoizedBlockServiceAPIProviders(sourceAri, product) {
|
|
368
|
+
export var useMemoizedBlockServiceAPIProviders = function useMemoizedBlockServiceAPIProviders(sourceAri, product, sourceDocumentId) {
|
|
373
369
|
return useMemo(function () {
|
|
374
|
-
return createBlockServiceAPIProviders(sourceAri, product);
|
|
375
|
-
}, [sourceAri, product]);
|
|
370
|
+
return createBlockServiceAPIProviders(sourceAri, product, sourceDocumentId);
|
|
371
|
+
}, [sourceAri, product, sourceDocumentId]);
|
|
376
372
|
};
|
|
@@ -20,7 +20,8 @@ export declare enum SyncBlockError {
|
|
|
20
20
|
RateLimited = "rate_limited",
|
|
21
21
|
Conflict = "conflict",// attempt to create block that already exists
|
|
22
22
|
ServerError = "server_error",
|
|
23
|
-
InvalidContent = "invalid_content"
|
|
23
|
+
InvalidContent = "invalid_content",// content is not a valid JSON
|
|
24
|
+
Offline = "offline"
|
|
24
25
|
}
|
|
25
26
|
export interface SyncBlockData {
|
|
26
27
|
blockInstanceId: BlockInstanceId;
|
|
@@ -14,15 +14,16 @@ declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
|
|
|
14
14
|
*/
|
|
15
15
|
declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
|
|
16
16
|
private sourceAri;
|
|
17
|
+
private sourceDocumentId;
|
|
17
18
|
product: SyncBlockProduct;
|
|
18
|
-
constructor(sourceAri: string, product: SyncBlockProduct);
|
|
19
|
+
constructor(sourceAri: string, product: SyncBlockProduct, sourceDocumentId: string);
|
|
19
20
|
writeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
20
21
|
createData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
21
22
|
deleteData(resourceId: string): Promise<DeleteSyncBlockResult>;
|
|
22
23
|
generateResourceIdForReference(sourceId: ResourceId): ResourceId;
|
|
23
24
|
generateResourceId(): ResourceId;
|
|
24
25
|
}
|
|
25
|
-
export declare const useMemoizedBlockServiceAPIProviders: (sourceAri: string, product: SyncBlockProduct) => {
|
|
26
|
+
export declare const useMemoizedBlockServiceAPIProviders: (sourceAri: string, product: SyncBlockProduct, sourceDocumentId: string) => {
|
|
26
27
|
fetchProvider: BlockServiceADFFetchProvider;
|
|
27
28
|
writeProvider: BlockServiceADFWriteProvider;
|
|
28
29
|
};
|
|
@@ -20,7 +20,8 @@ export declare enum SyncBlockError {
|
|
|
20
20
|
RateLimited = "rate_limited",
|
|
21
21
|
Conflict = "conflict",// attempt to create block that already exists
|
|
22
22
|
ServerError = "server_error",
|
|
23
|
-
InvalidContent = "invalid_content"
|
|
23
|
+
InvalidContent = "invalid_content",// content is not a valid JSON
|
|
24
|
+
Offline = "offline"
|
|
24
25
|
}
|
|
25
26
|
export interface SyncBlockData {
|
|
26
27
|
blockInstanceId: BlockInstanceId;
|
|
@@ -14,15 +14,16 @@ declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
|
|
|
14
14
|
*/
|
|
15
15
|
declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
|
|
16
16
|
private sourceAri;
|
|
17
|
+
private sourceDocumentId;
|
|
17
18
|
product: SyncBlockProduct;
|
|
18
|
-
constructor(sourceAri: string, product: SyncBlockProduct);
|
|
19
|
+
constructor(sourceAri: string, product: SyncBlockProduct, sourceDocumentId: string);
|
|
19
20
|
writeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
20
21
|
createData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
21
22
|
deleteData(resourceId: string): Promise<DeleteSyncBlockResult>;
|
|
22
23
|
generateResourceIdForReference(sourceId: ResourceId): ResourceId;
|
|
23
24
|
generateResourceId(): ResourceId;
|
|
24
25
|
}
|
|
25
|
-
export declare const useMemoizedBlockServiceAPIProviders: (sourceAri: string, product: SyncBlockProduct) => {
|
|
26
|
+
export declare const useMemoizedBlockServiceAPIProviders: (sourceAri: string, product: SyncBlockProduct, sourceDocumentId: string) => {
|
|
26
27
|
fetchProvider: BlockServiceADFFetchProvider;
|
|
27
28
|
writeProvider: BlockServiceADFWriteProvider;
|
|
28
29
|
};
|
package/package.json
CHANGED