@atlaskit/editor-synced-block-provider 2.9.0 → 2.10.1

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 (54) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/cjs/hooks/useFetchSyncBlockData.js +3 -2
  3. package/dist/cjs/index.js +7 -6
  4. package/dist/cjs/providers/block-service/ari.js +34 -0
  5. package/dist/cjs/providers/block-service/blockServiceAPI.js +15 -1
  6. package/dist/cjs/providers/confluence/confluenceContentAPI.js +15 -0
  7. package/dist/cjs/providers/syncBlockProvider.js +82 -14
  8. package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +26 -0
  9. package/dist/cjs/store-manager/syncBlockStoreManager.js +5 -0
  10. package/dist/cjs/utils/ari.js +3 -32
  11. package/dist/cjs/utils/sourceInfo.js +3 -3
  12. package/dist/es2019/hooks/useFetchSyncBlockData.js +3 -2
  13. package/dist/es2019/index.js +2 -1
  14. package/dist/es2019/providers/block-service/ari.js +28 -0
  15. package/dist/es2019/providers/block-service/blockServiceAPI.js +13 -1
  16. package/dist/es2019/providers/confluence/confluenceContentAPI.js +14 -1
  17. package/dist/es2019/providers/syncBlockProvider.js +78 -12
  18. package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +25 -0
  19. package/dist/es2019/store-manager/syncBlockStoreManager.js +3 -0
  20. package/dist/es2019/utils/ari.js +2 -31
  21. package/dist/es2019/utils/sourceInfo.js +3 -3
  22. package/dist/esm/hooks/useFetchSyncBlockData.js +3 -2
  23. package/dist/esm/index.js +2 -1
  24. package/dist/esm/providers/block-service/ari.js +28 -0
  25. package/dist/esm/providers/block-service/blockServiceAPI.js +15 -1
  26. package/dist/esm/providers/confluence/confluenceContentAPI.js +16 -1
  27. package/dist/esm/providers/syncBlockProvider.js +82 -14
  28. package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +26 -0
  29. package/dist/esm/store-manager/syncBlockStoreManager.js +5 -0
  30. package/dist/esm/utils/ari.js +2 -31
  31. package/dist/esm/utils/sourceInfo.js +3 -3
  32. package/dist/types/hooks/useFetchSyncBlockData.d.ts +2 -0
  33. package/dist/types/index.d.ts +2 -1
  34. package/dist/types/providers/block-service/ari.d.ts +13 -0
  35. package/dist/types/providers/block-service/blockServiceAPI.d.ts +3 -2
  36. package/dist/types/providers/confluence/confluenceContentAPI.d.ts +3 -2
  37. package/dist/types/providers/syncBlockProvider.d.ts +59 -3
  38. package/dist/types/providers/types.d.ts +20 -0
  39. package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +3 -0
  40. package/dist/types/store-manager/syncBlockStoreManager.d.ts +2 -0
  41. package/dist/types/utils/ari.d.ts +0 -15
  42. package/dist/types/utils/sourceInfo.d.ts +1 -1
  43. package/dist/types-ts4.5/hooks/useFetchSyncBlockData.d.ts +2 -0
  44. package/dist/types-ts4.5/index.d.ts +2 -1
  45. package/dist/types-ts4.5/providers/block-service/ari.d.ts +13 -0
  46. package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +3 -2
  47. package/dist/types-ts4.5/providers/confluence/confluenceContentAPI.d.ts +3 -2
  48. package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +59 -3
  49. package/dist/types-ts4.5/providers/types.d.ts +20 -0
  50. package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +3 -0
  51. package/dist/types-ts4.5/store-manager/syncBlockStoreManager.d.ts +2 -0
  52. package/dist/types-ts4.5/utils/ari.d.ts +0 -15
  53. package/dist/types-ts4.5/utils/sourceInfo.d.ts +1 -1
  54. package/package.json +3 -8
@@ -4,6 +4,8 @@ export var getConfluencePageAri = function getConfluencePageAri(pageId, cloudId)
4
4
  var pageType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'page';
5
5
  return "ari:cloud:confluence:".concat(cloudId, ":").concat(pageType, "/").concat(pageId);
6
6
  };
7
+
8
+ // For extracting from Page ARI and also the content property's version of resourceId
7
9
  export var getPageIdAndTypeFromAri = function getPageIdAndTypeFromAri(ari) {
8
10
  var match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/(\d+)/);
9
11
  if (match !== null && match !== void 0 && match[2]) {
@@ -30,35 +32,4 @@ export var getPageARIFromResourceId = function getPageARIFromResourceId(resource
30
32
  };
31
33
  export var resourceIdFromSourceAndLocalId = function resourceIdFromSourceAndLocalId(sourceId, localId) {
32
34
  return sourceId + '/' + localId;
33
- };
34
-
35
- /**
36
- * For the following functions, they are used for the block service API provider.
37
- * The resourceId/blockResourceId always refers to the block ARI.
38
- */
39
-
40
- /**
41
- * @param sourceId - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
42
- * @param localId - the localId of the block node. A randomly generated UUID
43
- * @returns the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
44
- */
45
- export var blockResourceIdFromSourceAndLocalId = function blockResourceIdFromSourceAndLocalId(sourceId, localId) {
46
- var match = sourceId.match(/ari:cloud:confluence:([^:]+):(page|blogpost)\/.*/);
47
- if (!(match !== null && match !== void 0 && match[1])) {
48
- throw new Error("Invalid source ARI: ".concat(sourceId));
49
- }
50
- var cloudId = match[1];
51
- return "ari:cloud:blocks:".concat(cloudId, ":synced-block/").concat(localId);
52
- };
53
-
54
- /**
55
- * @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
56
- * @returns the localId of the block node. A randomly generated UUID
57
- */
58
- export var getLocalIdFromResourceId = function getLocalIdFromResourceId(ari) {
59
- var match = ari.match(/ari:cloud:confluence:[^:]+:(page|blogpost)\/\d+\/([a-zA-Z0-9-]+)/);
60
- if (match !== null && match !== void 0 && match[2]) {
61
- return match[2];
62
- }
63
- throw new Error("Invalid page ARI: ".concat(ari));
64
35
  };
@@ -64,15 +64,15 @@ var getSourceInfo = /*#__PURE__*/function () {
64
64
  };
65
65
  }();
66
66
  export var fetchSourceInfo = /*#__PURE__*/function () {
67
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(ari, localId) {
67
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(pageAri, localId) {
68
68
  var _response$data, _contentData$space, _getPageIdAndTypeFrom, pageType, response, contentData, title, url, _ref3, base;
69
69
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
70
70
  while (1) switch (_context2.prev = _context2.next) {
71
71
  case 0:
72
72
  _context2.prev = 0;
73
- _getPageIdAndTypeFrom = getPageIdAndTypeFromAri(ari), pageType = _getPageIdAndTypeFrom.type;
73
+ _getPageIdAndTypeFrom = getPageIdAndTypeFromAri(pageAri), pageType = _getPageIdAndTypeFrom.type;
74
74
  _context2.next = 4;
75
- return getSourceInfo(ari);
75
+ return getSourceInfo(pageAri);
76
76
  case 4:
77
77
  response = _context2.sent;
78
78
  contentData = (_response$data = response.data) === null || _response$data === void 0 || (_response$data = _response$data.content) === null || _response$data === void 0 || (_response$data = _response$data.nodes) === null || _response$data === void 0 ? void 0 : _response$data[0];
@@ -1,7 +1,9 @@
1
+ import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
1
2
  import type { SyncBlockInstance } from '../providers/types';
2
3
  import type { SyncBlockStoreManager } from '../store-manager/syncBlockStoreManager';
3
4
  export interface UseFetchSyncBlockDataResult {
4
5
  isLoading: boolean;
6
+ providerFactory: ProviderFactory | undefined;
5
7
  reloadData: () => Promise<void>;
6
8
  syncBlockInstance: SyncBlockInstance | null;
7
9
  }
@@ -4,12 +4,13 @@ export type { SyncBlockData, SyncBlockNode } from './common/types';
4
4
  export { useFetchSyncBlockData, type UseFetchSyncBlockDataResult, } from './hooks/useFetchSyncBlockData';
5
5
  export { useFetchSyncBlockTitle } from './hooks/useFetchSyncBlockTitle';
6
6
  export { useHandleContentChanges } from './hooks/useHandleContentChanges';
7
+ export { blockResourceIdFromSourceAndLocalId, getLocalIdFromResourceId } from './providers/block-service/ari';
7
8
  export { useMemoizedBlockServiceAPIProviders } from './providers/block-service/blockServiceAPI';
8
9
  export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluence/confluenceContentAPI';
9
10
  export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
10
11
  export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, } from './providers/types';
11
12
  export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
12
13
  export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
13
- export { blockResourceIdFromSourceAndLocalId, getConfluencePageAri, getLocalIdFromAri, getLocalIdFromResourceId, getPageARIFromResourceId, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId, } from './utils/ari';
14
+ export { getConfluencePageAri, getLocalIdFromAri, getPageARIFromResourceId, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId, } from './utils/ari';
14
15
  export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, } from './utils/utils';
15
16
  export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Generates a unique block ARI from a source ARI and a local ID.
3
+ * @param sourceId - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
4
+ * @param localId - the localId of the block node. A randomly generated UUID
5
+ * @returns the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
6
+ */
7
+ export declare const blockResourceIdFromSourceAndLocalId: (sourceId: string, localId: string) => string;
8
+ /**
9
+ * Extracts the local ID from a block ARI.
10
+ * @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
11
+ * @returns the localId of the block node. A randomly generated UUID
12
+ */
13
+ export declare const getLocalIdFromResourceId: (ari: string) => string;
@@ -1,10 +1,11 @@
1
- import { type SyncBlockData } from '../../common/types';
2
- import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, WriteSyncBlockResult } from '../types';
1
+ import { type ResourceId, type SyncBlockData } from '../../common/types';
2
+ import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SourceInfoFetchData, SyncBlockInstance, WriteSyncBlockResult } from '../types';
3
3
  /**
4
4
  * ADFFetchProvider implementation that fetches synced block data from Block Service API
5
5
  */
6
6
  declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
7
7
  fetchData(resourceId: string): Promise<SyncBlockInstance>;
8
+ retrieveSourceInfoFetchData(resourceId: ResourceId, pageARI: string): SourceInfoFetchData;
8
9
  }
9
10
  /**
10
11
  * ADFWriteProvider implementation that writes synced block data to Block Service API
@@ -1,5 +1,5 @@
1
- import { type SyncBlockData } from '../../common/types';
2
- import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, WriteSyncBlockResult } from '../types';
1
+ import { type ResourceId, type SyncBlockData } from '../../common/types';
2
+ import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SourceInfoFetchData, SyncBlockInstance, WriteSyncBlockResult } from '../types';
3
3
  /**
4
4
  * Configuration for Content API providers
5
5
  */
@@ -14,6 +14,7 @@ declare class ConfluenceADFFetchProvider implements ADFFetchProvider {
14
14
  private config;
15
15
  constructor(config: ContentAPIConfig);
16
16
  fetchData(resourceId: string): Promise<SyncBlockInstance>;
17
+ retrieveSourceInfoFetchData(resourceId: ResourceId): SourceInfoFetchData;
17
18
  }
18
19
  /**
19
20
  * ADFWriteProvider implementation that writes synced block data to Confluence Content API
@@ -1,16 +1,47 @@
1
1
  import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
2
2
  import { type SyncBlockData, type SyncBlockNode } from '../common/types';
3
- import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockSourceInfo, type WriteSyncBlockResult } from '../providers/types';
3
+ import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockSourceInfo, type SyncedBlockRendererProviderOptions, type WriteSyncBlockResult } from '../providers/types';
4
4
  export declare class SyncBlockProvider extends SyncBlockDataProvider {
5
5
  name: string;
6
6
  private fetchProvider;
7
7
  private writeProvider;
8
8
  private sourceId;
9
- constructor(fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string);
9
+ private providerOptions;
10
+ /**
11
+ * Constructor for the SyncBlockProvider
12
+ *
13
+ * @param fetchProvider
14
+ * @param writeProvider
15
+ * @param sourceId
16
+ * @param nestedRendererDataProviders
17
+ */
18
+ constructor(fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string, providerOptions: SyncedBlockRendererProviderOptions);
19
+ /**
20
+ * Check if the node is supported by the provider
21
+ *
22
+ * @param node
23
+ *
24
+ * @returns True if the node is supported, false otherwise
25
+ */
10
26
  isNodeSupported(node: JSONNode): node is SyncBlockNode;
27
+ /**
28
+ * Get the data key for the node
29
+ *
30
+ * @param node
31
+ *
32
+ * @returns The data key
33
+ */
11
34
  nodeDataKey(node: SyncBlockNode): string;
35
+ /**
36
+ * Fetch the data from the fetch provider
37
+ *
38
+ * @param nodes
39
+ *
40
+ * @returns Array of {resourceId?: string, error?: string}.
41
+ */
12
42
  fetchNodesData(nodes: SyncBlockNode[]): Promise<SyncBlockInstance[]>;
13
43
  /**
44
+ * Write the data to the write provider
14
45
  *
15
46
  * @param nodes
16
47
  * @param data
@@ -19,9 +50,34 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
19
50
  * resourceId: resource id of the node if write successfully , error: reason for when write failed
20
51
  */
21
52
  writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
53
+ /**
54
+ * Delete the data from the write provider
55
+ *
56
+ * @param resourceIds
57
+ *
58
+ * @returns Array of {resourceId?: string, error?: string}.
59
+ */
22
60
  deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
61
+ /**
62
+ * Get the source id
63
+ *
64
+ * @returns The source id
65
+ */
23
66
  getSourceId(): string;
67
+ /**
68
+ * Retrieve the source info from the source id
69
+ *
70
+ * @param node
71
+ *
72
+ * @returns The source info
73
+ */
24
74
  retrieveSyncBlockSourceInfo(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
25
75
  generateResourceId(sourceId: string, localId: string): string;
76
+ /**
77
+ * Get the synced block renderer provider options
78
+ *
79
+ * @returns The synced block renderer provider options
80
+ */
81
+ getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
26
82
  }
27
- export declare const useMemoizedSyncedBlockProvider: (fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string) => SyncBlockProvider;
83
+ export declare const useMemoizedSyncedBlockProvider: (fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string, providerOptions: SyncedBlockRendererProviderOptions) => SyncBlockProvider;
@@ -1,3 +1,5 @@
1
+ import type { SyncedBlockRendererDataProviders, MediaProvider } from '@atlaskit/editor-common/provider-factory';
2
+ import type { EmojiProvider } from '@atlaskit/emoji';
1
3
  import { NodeDataProvider } from '@atlaskit/node-data-provider';
2
4
  import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode } from '../common/types';
3
5
  /**
@@ -23,19 +25,37 @@ export type WriteSyncBlockResult = {
23
25
  error?: string;
24
26
  resourceId?: string;
25
27
  };
28
+ export type SourceInfoFetchData = {
29
+ pageARI: string;
30
+ sourceLocalId?: string;
31
+ };
26
32
  export interface ADFFetchProvider {
27
33
  fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
34
+ retrieveSourceInfoFetchData: (resourceId: ResourceId, pageAri: string) => SourceInfoFetchData;
28
35
  }
29
36
  export interface ADFWriteProvider {
30
37
  deleteData: (resourceId: string) => Promise<DeleteSyncBlockResult>;
31
38
  generateResourceId: (sourceId: string, localId: string) => ResourceId;
32
39
  writeData: (data: SyncBlockData) => Promise<WriteSyncBlockResult>;
33
40
  }
41
+ export type MediaEmojiProviderOptions = {
42
+ contentId: string;
43
+ contentType: string;
44
+ spaceKey?: string | null;
45
+ };
46
+ export type SyncedBlockRendererProviderOptions = {
47
+ parentDataProviders?: SyncedBlockRendererDataProviders;
48
+ providerCreator?: {
49
+ createEmojiProvider: ((options: MediaEmojiProviderOptions) => Promise<EmojiProvider>) | undefined;
50
+ createMediaProvider: ((options: MediaEmojiProviderOptions) => Promise<MediaProvider>) | undefined;
51
+ };
52
+ };
34
53
  export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode, SyncBlockInstance> {
35
54
  abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
36
55
  abstract deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
37
56
  abstract getSourceId(): ResourceId;
38
57
  abstract retrieveSyncBlockSourceInfo(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
58
+ abstract getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
39
59
  /**
40
60
  * Generates a resource ID from a source ID and local ID.
41
61
  * @param sourceId - The source document ID (e.g., page ARI)
@@ -1,3 +1,4 @@
1
+ import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
1
2
  import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
3
  import { type ResourceId, type SyncBlockNode } from '../common/types';
3
4
  import type { SyncBlockInstance, SubscriptionCallback, SyncBlockDataProvider, TitleSubscriptionCallback } from '../providers/types';
@@ -6,6 +7,7 @@ export declare class ReferenceSyncBlockStoreManager {
6
7
  private syncBlockCache;
7
8
  private subscriptions;
8
9
  private titleSubscriptions;
10
+ private providerFactories;
9
11
  private syncBlockURLRequests;
10
12
  private isRefreshingSubscriptions;
11
13
  constructor(dataProvider?: SyncBlockDataProvider);
@@ -29,5 +31,6 @@ export declare class ReferenceSyncBlockStoreManager {
29
31
  * @returns
30
32
  */
31
33
  getSyncBlockURL(resourceId: ResourceId): string | undefined;
34
+ getProviderFactory(resourceId: ResourceId): ProviderFactory | undefined;
32
35
  destroy(): void;
33
36
  }
@@ -1,3 +1,4 @@
1
+ import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
1
2
  import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
2
3
  import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
4
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
@@ -60,5 +61,6 @@ export declare class SyncBlockStoreManager {
60
61
  refreshSubscriptions(): void;
61
62
  deleteSyncBlocksWithConfirmation(tr: Transaction, syncBlockIds: SyncBlockAttrs[]): Promise<void>;
62
63
  rebaseTransaction(incomingTr: Transaction, state: EditorState): void;
64
+ getReferenceSyncBlockProviderFactory(resourceId: ResourceId): ProviderFactory | undefined;
63
65
  destroy(): void;
64
66
  }
@@ -7,18 +7,3 @@ export declare const getPageIdAndTypeFromAri: (ari: string) => {
7
7
  export declare const getLocalIdFromAri: (ari: string) => string;
8
8
  export declare const getPageARIFromResourceId: (resourceId: string) => string;
9
9
  export declare const resourceIdFromSourceAndLocalId: (sourceId: string, localId: string) => string;
10
- /**
11
- * For the following functions, they are used for the block service API provider.
12
- * The resourceId/blockResourceId always refers to the block ARI.
13
- */
14
- /**
15
- * @param sourceId - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
16
- * @param localId - the localId of the block node. A randomly generated UUID
17
- * @returns the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
18
- */
19
- export declare const blockResourceIdFromSourceAndLocalId: (sourceId: string, localId: string) => string;
20
- /**
21
- * @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
22
- * @returns the localId of the block node. A randomly generated UUID
23
- */
24
- export declare const getLocalIdFromResourceId: (ari: string) => string;
@@ -1,2 +1,2 @@
1
1
  import type { SyncBlockSourceInfo } from '../providers/types';
2
- export declare const fetchSourceInfo: (ari: string, localId?: string) => Promise<SyncBlockSourceInfo | undefined>;
2
+ export declare const fetchSourceInfo: (pageAri: string, localId?: string) => Promise<SyncBlockSourceInfo | undefined>;
@@ -1,7 +1,9 @@
1
+ import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
1
2
  import type { SyncBlockInstance } from '../providers/types';
2
3
  import type { SyncBlockStoreManager } from '../store-manager/syncBlockStoreManager';
3
4
  export interface UseFetchSyncBlockDataResult {
4
5
  isLoading: boolean;
6
+ providerFactory: ProviderFactory | undefined;
5
7
  reloadData: () => Promise<void>;
6
8
  syncBlockInstance: SyncBlockInstance | null;
7
9
  }
@@ -4,12 +4,13 @@ export type { SyncBlockData, SyncBlockNode } from './common/types';
4
4
  export { useFetchSyncBlockData, type UseFetchSyncBlockDataResult, } from './hooks/useFetchSyncBlockData';
5
5
  export { useFetchSyncBlockTitle } from './hooks/useFetchSyncBlockTitle';
6
6
  export { useHandleContentChanges } from './hooks/useHandleContentChanges';
7
+ export { blockResourceIdFromSourceAndLocalId, getLocalIdFromResourceId } from './providers/block-service/ari';
7
8
  export { useMemoizedBlockServiceAPIProviders } from './providers/block-service/blockServiceAPI';
8
9
  export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluence/confluenceContentAPI';
9
10
  export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
10
11
  export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, } from './providers/types';
11
12
  export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
12
13
  export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
13
- export { blockResourceIdFromSourceAndLocalId, getConfluencePageAri, getLocalIdFromAri, getLocalIdFromResourceId, getPageARIFromResourceId, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId, } from './utils/ari';
14
+ export { getConfluencePageAri, getLocalIdFromAri, getPageARIFromResourceId, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId, } from './utils/ari';
14
15
  export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, } from './utils/utils';
15
16
  export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Generates a unique block ARI from a source ARI and a local ID.
3
+ * @param sourceId - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
4
+ * @param localId - the localId of the block node. A randomly generated UUID
5
+ * @returns the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
6
+ */
7
+ export declare const blockResourceIdFromSourceAndLocalId: (sourceId: string, localId: string) => string;
8
+ /**
9
+ * Extracts the local ID from a block ARI.
10
+ * @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
11
+ * @returns the localId of the block node. A randomly generated UUID
12
+ */
13
+ export declare const getLocalIdFromResourceId: (ari: string) => string;
@@ -1,10 +1,11 @@
1
- import { type SyncBlockData } from '../../common/types';
2
- import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, WriteSyncBlockResult } from '../types';
1
+ import { type ResourceId, type SyncBlockData } from '../../common/types';
2
+ import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SourceInfoFetchData, SyncBlockInstance, WriteSyncBlockResult } from '../types';
3
3
  /**
4
4
  * ADFFetchProvider implementation that fetches synced block data from Block Service API
5
5
  */
6
6
  declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
7
7
  fetchData(resourceId: string): Promise<SyncBlockInstance>;
8
+ retrieveSourceInfoFetchData(resourceId: ResourceId, pageARI: string): SourceInfoFetchData;
8
9
  }
9
10
  /**
10
11
  * ADFWriteProvider implementation that writes synced block data to Block Service API
@@ -1,5 +1,5 @@
1
- import { type SyncBlockData } from '../../common/types';
2
- import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, WriteSyncBlockResult } from '../types';
1
+ import { type ResourceId, type SyncBlockData } from '../../common/types';
2
+ import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SourceInfoFetchData, SyncBlockInstance, WriteSyncBlockResult } from '../types';
3
3
  /**
4
4
  * Configuration for Content API providers
5
5
  */
@@ -14,6 +14,7 @@ declare class ConfluenceADFFetchProvider implements ADFFetchProvider {
14
14
  private config;
15
15
  constructor(config: ContentAPIConfig);
16
16
  fetchData(resourceId: string): Promise<SyncBlockInstance>;
17
+ retrieveSourceInfoFetchData(resourceId: ResourceId): SourceInfoFetchData;
17
18
  }
18
19
  /**
19
20
  * ADFWriteProvider implementation that writes synced block data to Confluence Content API
@@ -1,16 +1,47 @@
1
1
  import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
2
2
  import { type SyncBlockData, type SyncBlockNode } from '../common/types';
3
- import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockSourceInfo, type WriteSyncBlockResult } from '../providers/types';
3
+ import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockSourceInfo, type SyncedBlockRendererProviderOptions, type WriteSyncBlockResult } from '../providers/types';
4
4
  export declare class SyncBlockProvider extends SyncBlockDataProvider {
5
5
  name: string;
6
6
  private fetchProvider;
7
7
  private writeProvider;
8
8
  private sourceId;
9
- constructor(fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string);
9
+ private providerOptions;
10
+ /**
11
+ * Constructor for the SyncBlockProvider
12
+ *
13
+ * @param fetchProvider
14
+ * @param writeProvider
15
+ * @param sourceId
16
+ * @param nestedRendererDataProviders
17
+ */
18
+ constructor(fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string, providerOptions: SyncedBlockRendererProviderOptions);
19
+ /**
20
+ * Check if the node is supported by the provider
21
+ *
22
+ * @param node
23
+ *
24
+ * @returns True if the node is supported, false otherwise
25
+ */
10
26
  isNodeSupported(node: JSONNode): node is SyncBlockNode;
27
+ /**
28
+ * Get the data key for the node
29
+ *
30
+ * @param node
31
+ *
32
+ * @returns The data key
33
+ */
11
34
  nodeDataKey(node: SyncBlockNode): string;
35
+ /**
36
+ * Fetch the data from the fetch provider
37
+ *
38
+ * @param nodes
39
+ *
40
+ * @returns Array of {resourceId?: string, error?: string}.
41
+ */
12
42
  fetchNodesData(nodes: SyncBlockNode[]): Promise<SyncBlockInstance[]>;
13
43
  /**
44
+ * Write the data to the write provider
14
45
  *
15
46
  * @param nodes
16
47
  * @param data
@@ -19,9 +50,34 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
19
50
  * resourceId: resource id of the node if write successfully , error: reason for when write failed
20
51
  */
21
52
  writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
53
+ /**
54
+ * Delete the data from the write provider
55
+ *
56
+ * @param resourceIds
57
+ *
58
+ * @returns Array of {resourceId?: string, error?: string}.
59
+ */
22
60
  deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
61
+ /**
62
+ * Get the source id
63
+ *
64
+ * @returns The source id
65
+ */
23
66
  getSourceId(): string;
67
+ /**
68
+ * Retrieve the source info from the source id
69
+ *
70
+ * @param node
71
+ *
72
+ * @returns The source info
73
+ */
24
74
  retrieveSyncBlockSourceInfo(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
25
75
  generateResourceId(sourceId: string, localId: string): string;
76
+ /**
77
+ * Get the synced block renderer provider options
78
+ *
79
+ * @returns The synced block renderer provider options
80
+ */
81
+ getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
26
82
  }
27
- export declare const useMemoizedSyncedBlockProvider: (fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string) => SyncBlockProvider;
83
+ export declare const useMemoizedSyncedBlockProvider: (fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string, providerOptions: SyncedBlockRendererProviderOptions) => SyncBlockProvider;
@@ -1,3 +1,5 @@
1
+ import type { SyncedBlockRendererDataProviders, MediaProvider } from '@atlaskit/editor-common/provider-factory';
2
+ import type { EmojiProvider } from '@atlaskit/emoji';
1
3
  import { NodeDataProvider } from '@atlaskit/node-data-provider';
2
4
  import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode } from '../common/types';
3
5
  /**
@@ -23,19 +25,37 @@ export type WriteSyncBlockResult = {
23
25
  error?: string;
24
26
  resourceId?: string;
25
27
  };
28
+ export type SourceInfoFetchData = {
29
+ pageARI: string;
30
+ sourceLocalId?: string;
31
+ };
26
32
  export interface ADFFetchProvider {
27
33
  fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
34
+ retrieveSourceInfoFetchData: (resourceId: ResourceId, pageAri: string) => SourceInfoFetchData;
28
35
  }
29
36
  export interface ADFWriteProvider {
30
37
  deleteData: (resourceId: string) => Promise<DeleteSyncBlockResult>;
31
38
  generateResourceId: (sourceId: string, localId: string) => ResourceId;
32
39
  writeData: (data: SyncBlockData) => Promise<WriteSyncBlockResult>;
33
40
  }
41
+ export type MediaEmojiProviderOptions = {
42
+ contentId: string;
43
+ contentType: string;
44
+ spaceKey?: string | null;
45
+ };
46
+ export type SyncedBlockRendererProviderOptions = {
47
+ parentDataProviders?: SyncedBlockRendererDataProviders;
48
+ providerCreator?: {
49
+ createEmojiProvider: ((options: MediaEmojiProviderOptions) => Promise<EmojiProvider>) | undefined;
50
+ createMediaProvider: ((options: MediaEmojiProviderOptions) => Promise<MediaProvider>) | undefined;
51
+ };
52
+ };
34
53
  export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode, SyncBlockInstance> {
35
54
  abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
36
55
  abstract deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
37
56
  abstract getSourceId(): ResourceId;
38
57
  abstract retrieveSyncBlockSourceInfo(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
58
+ abstract getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
39
59
  /**
40
60
  * Generates a resource ID from a source ID and local ID.
41
61
  * @param sourceId - The source document ID (e.g., page ARI)
@@ -1,3 +1,4 @@
1
+ import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
1
2
  import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
3
  import { type ResourceId, type SyncBlockNode } from '../common/types';
3
4
  import type { SyncBlockInstance, SubscriptionCallback, SyncBlockDataProvider, TitleSubscriptionCallback } from '../providers/types';
@@ -6,6 +7,7 @@ export declare class ReferenceSyncBlockStoreManager {
6
7
  private syncBlockCache;
7
8
  private subscriptions;
8
9
  private titleSubscriptions;
10
+ private providerFactories;
9
11
  private syncBlockURLRequests;
10
12
  private isRefreshingSubscriptions;
11
13
  constructor(dataProvider?: SyncBlockDataProvider);
@@ -29,5 +31,6 @@ export declare class ReferenceSyncBlockStoreManager {
29
31
  * @returns
30
32
  */
31
33
  getSyncBlockURL(resourceId: ResourceId): string | undefined;
34
+ getProviderFactory(resourceId: ResourceId): ProviderFactory | undefined;
32
35
  destroy(): void;
33
36
  }
@@ -1,3 +1,4 @@
1
+ import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
1
2
  import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
2
3
  import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
4
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
@@ -60,5 +61,6 @@ export declare class SyncBlockStoreManager {
60
61
  refreshSubscriptions(): void;
61
62
  deleteSyncBlocksWithConfirmation(tr: Transaction, syncBlockIds: SyncBlockAttrs[]): Promise<void>;
62
63
  rebaseTransaction(incomingTr: Transaction, state: EditorState): void;
64
+ getReferenceSyncBlockProviderFactory(resourceId: ResourceId): ProviderFactory | undefined;
63
65
  destroy(): void;
64
66
  }
@@ -7,18 +7,3 @@ export declare const getPageIdAndTypeFromAri: (ari: string) => {
7
7
  export declare const getLocalIdFromAri: (ari: string) => string;
8
8
  export declare const getPageARIFromResourceId: (resourceId: string) => string;
9
9
  export declare const resourceIdFromSourceAndLocalId: (sourceId: string, localId: string) => string;
10
- /**
11
- * For the following functions, they are used for the block service API provider.
12
- * The resourceId/blockResourceId always refers to the block ARI.
13
- */
14
- /**
15
- * @param sourceId - the ARI of the document. E.G ari:cloud:confluence:cloudId:page/pageId
16
- * @param localId - the localId of the block node. A randomly generated UUID
17
- * @returns the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
18
- */
19
- export declare const blockResourceIdFromSourceAndLocalId: (sourceId: string, localId: string) => string;
20
- /**
21
- * @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
22
- * @returns the localId of the block node. A randomly generated UUID
23
- */
24
- export declare const getLocalIdFromResourceId: (ari: string) => string;
@@ -1,2 +1,2 @@
1
1
  import type { SyncBlockSourceInfo } from '../providers/types';
2
- export declare const fetchSourceInfo: (ari: string, localId?: string) => Promise<SyncBlockSourceInfo | undefined>;
2
+ export declare const fetchSourceInfo: (pageAri: string, localId?: string) => Promise<SyncBlockSourceInfo | undefined>;
package/package.json CHANGED
@@ -24,13 +24,12 @@
24
24
  ],
25
25
  "atlaskit:src": "src/index.ts",
26
26
  "dependencies": {
27
- "@atlaskit/adf-schema": "^51.3.2",
27
+ "@atlaskit/adf-schema": "^51.4.0",
28
28
  "@atlaskit/adf-utils": "^19.26.0",
29
29
  "@atlaskit/css": "^0.15.0",
30
30
  "@atlaskit/editor-json-transformer": "^8.31.0",
31
31
  "@atlaskit/editor-prosemirror": "7.0.0",
32
32
  "@atlaskit/node-data-provider": "^7.5.0",
33
- "@atlaskit/platform-feature-flags": "^1.1.0",
34
33
  "@atlaskit/primitives": "^16.1.0",
35
34
  "@atlaskit/tokens": "^8.0.0",
36
35
  "@babel/runtime": "^7.0.0",
@@ -38,6 +37,7 @@
38
37
  "uuid": "^3.1.0"
39
38
  },
40
39
  "peerDependencies": {
40
+ "@atlaskit/editor-common": "^110.32.0",
41
41
  "react": "^18.2.0"
42
42
  },
43
43
  "devDependencies": {
@@ -83,16 +83,11 @@
83
83
  }
84
84
  },
85
85
  "name": "@atlaskit/editor-synced-block-provider",
86
- "version": "2.9.0",
86
+ "version": "2.10.1",
87
87
  "description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
88
88
  "author": "Atlassian Pty Ltd",
89
89
  "license": "Apache-2.0",
90
90
  "publishConfig": {
91
91
  "registry": "https://registry.npmjs.org/"
92
- },
93
- "platform-feature-flags": {
94
- "platform_editor_synced_block_provider_use_block_service": {
95
- "type": "boolean"
96
- }
97
92
  }
98
93
  }