@atlaskit/editor-synced-block-provider 2.9.1 → 2.10.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/cjs/index.js +7 -6
  3. package/dist/cjs/providers/block-service/ari.js +34 -0
  4. package/dist/cjs/providers/block-service/blockServiceAPI.js +15 -1
  5. package/dist/cjs/providers/confluence/confluenceContentAPI.js +36 -14
  6. package/dist/cjs/providers/syncBlockProvider.js +37 -6
  7. package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +51 -10
  8. package/dist/cjs/store-manager/syncBlockStoreManager.js +1 -0
  9. package/dist/cjs/utils/ari.js +3 -32
  10. package/dist/cjs/utils/sourceInfo.js +3 -3
  11. package/dist/es2019/index.js +2 -1
  12. package/dist/es2019/providers/block-service/ari.js +28 -0
  13. package/dist/es2019/providers/block-service/blockServiceAPI.js +13 -1
  14. package/dist/es2019/providers/confluence/confluenceContentAPI.js +21 -2
  15. package/dist/es2019/providers/syncBlockProvider.js +38 -7
  16. package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +51 -10
  17. package/dist/es2019/store-manager/syncBlockStoreManager.js +2 -0
  18. package/dist/es2019/utils/ari.js +2 -31
  19. package/dist/es2019/utils/sourceInfo.js +3 -3
  20. package/dist/esm/index.js +2 -1
  21. package/dist/esm/providers/block-service/ari.js +28 -0
  22. package/dist/esm/providers/block-service/blockServiceAPI.js +15 -1
  23. package/dist/esm/providers/confluence/confluenceContentAPI.js +37 -15
  24. package/dist/esm/providers/syncBlockProvider.js +38 -7
  25. package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +51 -10
  26. package/dist/esm/store-manager/syncBlockStoreManager.js +2 -0
  27. package/dist/esm/utils/ari.js +2 -31
  28. package/dist/esm/utils/sourceInfo.js +3 -3
  29. package/dist/types/common/types.d.ts +3 -1
  30. package/dist/types/index.d.ts +3 -2
  31. package/dist/types/providers/block-service/ari.d.ts +13 -0
  32. package/dist/types/providers/block-service/blockServiceAPI.d.ts +3 -2
  33. package/dist/types/providers/confluence/confluenceContentAPI.d.ts +3 -2
  34. package/dist/types/providers/syncBlockProvider.d.ts +10 -1
  35. package/dist/types/providers/types.d.ts +25 -8
  36. package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +1 -0
  37. package/dist/types/utils/ari.d.ts +0 -15
  38. package/dist/types/utils/blockService.d.ts +3 -3
  39. package/dist/types/utils/sourceInfo.d.ts +1 -1
  40. package/dist/types-ts4.5/common/types.d.ts +3 -1
  41. package/dist/types-ts4.5/index.d.ts +3 -2
  42. package/dist/types-ts4.5/providers/block-service/ari.d.ts +13 -0
  43. package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +3 -2
  44. package/dist/types-ts4.5/providers/confluence/confluenceContentAPI.d.ts +3 -2
  45. package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +10 -1
  46. package/dist/types-ts4.5/providers/types.d.ts +25 -8
  47. package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +1 -0
  48. package/dist/types-ts4.5/utils/ari.d.ts +0 -15
  49. package/dist/types-ts4.5/utils/blockService.d.ts +3 -3
  50. package/dist/types-ts4.5/utils/sourceInfo.d.ts +1 -1
  51. package/package.json +6 -12
@@ -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
- export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, } from './providers/types';
11
+ export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, } 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,6 +1,6 @@
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 SyncedBlockRendererProviderOptions, type WriteSyncBlockResult } from '../providers/types';
3
+ import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockParentInfo, 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;
@@ -79,5 +79,14 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
79
79
  * @returns The synced block renderer provider options
80
80
  */
81
81
  getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
82
+ /**
83
+ * Retrieve the parent info for the sync block
84
+ *
85
+ * @param resourceId
86
+ * @param syncBlockInstance
87
+ *
88
+ * @returns The parent info for the sync block
89
+ */
90
+ retrieveSyncBlockParentInfo(syncBlockInstance: SyncBlockInstance | undefined): SyncBlockParentInfo | undefined;
82
91
  }
83
92
  export declare const useMemoizedSyncedBlockProvider: (fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string, providerOptions: SyncedBlockRendererProviderOptions) => SyncBlockProvider;
@@ -1,7 +1,9 @@
1
- import type { SyncedBlockRendererDataProviders, MediaProvider } from '@atlaskit/editor-common/provider-factory';
1
+ import type { MediaProvider, ProfilecardProvider } from '@atlaskit/editor-common/provider-factory';
2
2
  import type { EmojiProvider } from '@atlaskit/emoji';
3
+ import type { MentionProvider } from '@atlaskit/mention/types';
3
4
  import { NodeDataProvider } from '@atlaskit/node-data-provider';
4
- import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode } from '../common/types';
5
+ import type { TaskDecisionProvider } from '@atlaskit/task-decision/types';
6
+ import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode, SyncBlockProduct } from '../common/types';
5
7
  /**
6
8
  * The instance of a sync block, containing its data and metadata.
7
9
  * Mainly used for representing the state of a sync block after fetching from a data provider.
@@ -21,12 +23,21 @@ export type SyncBlockSourceInfo = {
21
23
  title?: string;
22
24
  url?: string;
23
25
  };
26
+ export type SyncBlockParentInfo = {
27
+ contentId: string;
28
+ contentProduct: SyncBlockProduct;
29
+ };
24
30
  export type WriteSyncBlockResult = {
25
31
  error?: string;
26
32
  resourceId?: string;
27
33
  };
34
+ export type SourceInfoFetchData = {
35
+ pageARI: string;
36
+ sourceLocalId?: string;
37
+ };
28
38
  export interface ADFFetchProvider {
29
39
  fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
40
+ retrieveSourceInfoFetchData: (resourceId: ResourceId, pageAri: string) => SourceInfoFetchData;
30
41
  }
31
42
  export interface ADFWriteProvider {
32
43
  deleteData: (resourceId: string) => Promise<DeleteSyncBlockResult>;
@@ -35,15 +46,20 @@ export interface ADFWriteProvider {
35
46
  }
36
47
  export type MediaEmojiProviderOptions = {
37
48
  contentId: string;
38
- contentType: string;
39
- spaceKey?: string | null;
49
+ contentProduct: SyncBlockProduct;
50
+ };
51
+ export type SyncedBlockRendererDataProviders = {
52
+ mentionProvider?: Promise<MentionProvider>;
53
+ profilecardProvider?: Promise<ProfilecardProvider>;
54
+ taskDecisionProvider?: Promise<TaskDecisionProvider>;
55
+ };
56
+ export type SyncBlockRendererProviderCreator = {
57
+ createEmojiProvider: ((options: MediaEmojiProviderOptions) => Promise<EmojiProvider>) | undefined;
58
+ createMediaProvider: ((options: MediaEmojiProviderOptions) => Promise<MediaProvider>) | undefined;
40
59
  };
41
60
  export type SyncedBlockRendererProviderOptions = {
42
61
  parentDataProviders?: SyncedBlockRendererDataProviders;
43
- providerCreator?: {
44
- createEmojiProvider: ((options: MediaEmojiProviderOptions) => Promise<EmojiProvider>) | undefined;
45
- createMediaProvider: ((options: MediaEmojiProviderOptions) => Promise<MediaProvider>) | undefined;
46
- };
62
+ providerCreator?: SyncBlockRendererProviderCreator;
47
63
  };
48
64
  export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode, SyncBlockInstance> {
49
65
  abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
@@ -51,6 +67,7 @@ export declare abstract class SyncBlockDataProvider extends NodeDataProvider<Syn
51
67
  abstract getSourceId(): ResourceId;
52
68
  abstract retrieveSyncBlockSourceInfo(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
53
69
  abstract getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
70
+ abstract retrieveSyncBlockParentInfo(syncBlockInstance: SyncBlockInstance | undefined): SyncBlockParentInfo | undefined;
54
71
  /**
55
72
  * Generates a resource ID from a source ID and local ID.
56
73
  * @param sourceId - The source document ID (e.g., page ARI)
@@ -32,5 +32,6 @@ export declare class ReferenceSyncBlockStoreManager {
32
32
  */
33
33
  getSyncBlockURL(resourceId: ResourceId): string | undefined;
34
34
  getProviderFactory(resourceId: ResourceId): ProviderFactory | undefined;
35
+ private retrieveDynamicProviders;
35
36
  destroy(): void;
36
37
  }
@@ -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,4 +1,4 @@
1
- export type BlockProduct = 'confluence-page' | 'jira-work-item';
1
+ import type { SyncBlockProduct } from '../common/types';
2
2
  export type BlockContentResponse = {
3
3
  blockAri: string;
4
4
  blockInstanceId: string;
@@ -7,7 +7,7 @@ export type BlockContentResponse = {
7
7
  createdAt: number;
8
8
  createdBy: string;
9
9
  isSynced: boolean;
10
- product: BlockProduct;
10
+ product: SyncBlockProduct;
11
11
  sourceAri: string;
12
12
  status: 'active' | 'deleted';
13
13
  version: number;
@@ -26,7 +26,7 @@ export type CreateSyncedBlockRequest = {
26
26
  blockAri: string;
27
27
  blockInstanceId: string;
28
28
  content: string;
29
- product: string;
29
+ product: SyncBlockProduct;
30
30
  sourceAri: string;
31
31
  };
32
32
  export declare class BlockError extends Error {
@@ -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>;
@@ -2,6 +2,7 @@ import type { ADFEntity } from '@atlaskit/adf-utils/types';
2
2
  import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
3
3
  export type BlockInstanceId = string;
4
4
  export type ResourceId = string;
5
+ export type SyncBlockProduct = 'confluence-page' | 'jira-work-item';
5
6
  export type SyncBlockAttrs = {
6
7
  localId: BlockInstanceId;
7
8
  resourceId: ResourceId;
@@ -22,8 +23,9 @@ export interface SyncBlockData {
22
23
  createdAt?: string;
23
24
  createdBy?: string;
24
25
  isSynced?: boolean;
26
+ product?: SyncBlockProduct;
25
27
  resourceId: ResourceId;
26
- sourceDocumentAri?: string;
28
+ sourceAri?: string;
27
29
  sourceTitle?: string;
28
30
  sourceURL?: string;
29
31
  updatedAt?: string;
@@ -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
- export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, } from './providers/types';
11
+ export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, } 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,6 +1,6 @@
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 SyncedBlockRendererProviderOptions, type WriteSyncBlockResult } from '../providers/types';
3
+ import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockParentInfo, 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;
@@ -79,5 +79,14 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
79
79
  * @returns The synced block renderer provider options
80
80
  */
81
81
  getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
82
+ /**
83
+ * Retrieve the parent info for the sync block
84
+ *
85
+ * @param resourceId
86
+ * @param syncBlockInstance
87
+ *
88
+ * @returns The parent info for the sync block
89
+ */
90
+ retrieveSyncBlockParentInfo(syncBlockInstance: SyncBlockInstance | undefined): SyncBlockParentInfo | undefined;
82
91
  }
83
92
  export declare const useMemoizedSyncedBlockProvider: (fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string, providerOptions: SyncedBlockRendererProviderOptions) => SyncBlockProvider;
@@ -1,7 +1,9 @@
1
- import type { SyncedBlockRendererDataProviders, MediaProvider } from '@atlaskit/editor-common/provider-factory';
1
+ import type { MediaProvider, ProfilecardProvider } from '@atlaskit/editor-common/provider-factory';
2
2
  import type { EmojiProvider } from '@atlaskit/emoji';
3
+ import type { MentionProvider } from '@atlaskit/mention/types';
3
4
  import { NodeDataProvider } from '@atlaskit/node-data-provider';
4
- import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode } from '../common/types';
5
+ import type { TaskDecisionProvider } from '@atlaskit/task-decision/types';
6
+ import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode, SyncBlockProduct } from '../common/types';
5
7
  /**
6
8
  * The instance of a sync block, containing its data and metadata.
7
9
  * Mainly used for representing the state of a sync block after fetching from a data provider.
@@ -21,12 +23,21 @@ export type SyncBlockSourceInfo = {
21
23
  title?: string;
22
24
  url?: string;
23
25
  };
26
+ export type SyncBlockParentInfo = {
27
+ contentId: string;
28
+ contentProduct: SyncBlockProduct;
29
+ };
24
30
  export type WriteSyncBlockResult = {
25
31
  error?: string;
26
32
  resourceId?: string;
27
33
  };
34
+ export type SourceInfoFetchData = {
35
+ pageARI: string;
36
+ sourceLocalId?: string;
37
+ };
28
38
  export interface ADFFetchProvider {
29
39
  fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
40
+ retrieveSourceInfoFetchData: (resourceId: ResourceId, pageAri: string) => SourceInfoFetchData;
30
41
  }
31
42
  export interface ADFWriteProvider {
32
43
  deleteData: (resourceId: string) => Promise<DeleteSyncBlockResult>;
@@ -35,15 +46,20 @@ export interface ADFWriteProvider {
35
46
  }
36
47
  export type MediaEmojiProviderOptions = {
37
48
  contentId: string;
38
- contentType: string;
39
- spaceKey?: string | null;
49
+ contentProduct: SyncBlockProduct;
50
+ };
51
+ export type SyncedBlockRendererDataProviders = {
52
+ mentionProvider?: Promise<MentionProvider>;
53
+ profilecardProvider?: Promise<ProfilecardProvider>;
54
+ taskDecisionProvider?: Promise<TaskDecisionProvider>;
55
+ };
56
+ export type SyncBlockRendererProviderCreator = {
57
+ createEmojiProvider: ((options: MediaEmojiProviderOptions) => Promise<EmojiProvider>) | undefined;
58
+ createMediaProvider: ((options: MediaEmojiProviderOptions) => Promise<MediaProvider>) | undefined;
40
59
  };
41
60
  export type SyncedBlockRendererProviderOptions = {
42
61
  parentDataProviders?: SyncedBlockRendererDataProviders;
43
- providerCreator?: {
44
- createEmojiProvider: ((options: MediaEmojiProviderOptions) => Promise<EmojiProvider>) | undefined;
45
- createMediaProvider: ((options: MediaEmojiProviderOptions) => Promise<MediaProvider>) | undefined;
46
- };
62
+ providerCreator?: SyncBlockRendererProviderCreator;
47
63
  };
48
64
  export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode, SyncBlockInstance> {
49
65
  abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
@@ -51,6 +67,7 @@ export declare abstract class SyncBlockDataProvider extends NodeDataProvider<Syn
51
67
  abstract getSourceId(): ResourceId;
52
68
  abstract retrieveSyncBlockSourceInfo(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
53
69
  abstract getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
70
+ abstract retrieveSyncBlockParentInfo(syncBlockInstance: SyncBlockInstance | undefined): SyncBlockParentInfo | undefined;
54
71
  /**
55
72
  * Generates a resource ID from a source ID and local ID.
56
73
  * @param sourceId - The source document ID (e.g., page ARI)
@@ -32,5 +32,6 @@ export declare class ReferenceSyncBlockStoreManager {
32
32
  */
33
33
  getSyncBlockURL(resourceId: ResourceId): string | undefined;
34
34
  getProviderFactory(resourceId: ResourceId): ProviderFactory | undefined;
35
+ private retrieveDynamicProviders;
35
36
  destroy(): void;
36
37
  }
@@ -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,4 +1,4 @@
1
- export type BlockProduct = 'confluence-page' | 'jira-work-item';
1
+ import type { SyncBlockProduct } from '../common/types';
2
2
  export type BlockContentResponse = {
3
3
  blockAri: string;
4
4
  blockInstanceId: string;
@@ -7,7 +7,7 @@ export type BlockContentResponse = {
7
7
  createdAt: number;
8
8
  createdBy: string;
9
9
  isSynced: boolean;
10
- product: BlockProduct;
10
+ product: SyncBlockProduct;
11
11
  sourceAri: string;
12
12
  status: 'active' | 'deleted';
13
13
  version: number;
@@ -26,7 +26,7 @@ export type CreateSyncedBlockRequest = {
26
26
  blockAri: string;
27
27
  blockInstanceId: string;
28
28
  content: string;
29
- product: string;
29
+ product: SyncBlockProduct;
30
30
  sourceAri: string;
31
31
  };
32
32
  export declare class BlockError extends Error {
@@ -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,21 +24,20 @@
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
- "@atlaskit/css": "^0.15.0",
29
+ "@atlaskit/css": "^0.16.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
- "@atlaskit/primitives": "^16.1.0",
35
- "@atlaskit/tokens": "^8.0.0",
33
+ "@atlaskit/primitives": "^16.2.0",
34
+ "@atlaskit/tokens": "^8.1.0",
36
35
  "@babel/runtime": "^7.0.0",
37
36
  "@compiled/react": "^0.18.6",
38
37
  "uuid": "^3.1.0"
39
38
  },
40
39
  "peerDependencies": {
41
- "@atlaskit/editor-common": "^110.30.0",
40
+ "@atlaskit/editor-common": "^110.32.0",
42
41
  "react": "^18.2.0"
43
42
  },
44
43
  "devDependencies": {
@@ -84,16 +83,11 @@
84
83
  }
85
84
  },
86
85
  "name": "@atlaskit/editor-synced-block-provider",
87
- "version": "2.9.1",
86
+ "version": "2.10.2",
88
87
  "description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
89
88
  "author": "Atlassian Pty Ltd",
90
89
  "license": "Apache-2.0",
91
90
  "publishConfig": {
92
91
  "registry": "https://registry.npmjs.org/"
93
- },
94
- "platform-feature-flags": {
95
- "platform_editor_synced_block_provider_use_block_service": {
96
- "type": "boolean"
97
- }
98
92
  }
99
93
  }