@atlaskit/editor-synced-block-provider 2.5.2 → 2.7.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/hooks/useFetchSyncBlockData.js +60 -6
  3. package/dist/cjs/index.js +24 -5
  4. package/dist/cjs/providers/confluence/confluenceContentAPI.js +86 -73
  5. package/dist/cjs/providers/syncBlockProvider.js +60 -36
  6. package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +24 -20
  7. package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +78 -17
  8. package/dist/cjs/store-manager/syncBlockStoreManager.js +46 -8
  9. package/dist/cjs/utils/errorHandling.js +13 -0
  10. package/dist/cjs/utils/utils.js +32 -1
  11. package/dist/es2019/hooks/useFetchSyncBlockData.js +35 -6
  12. package/dist/es2019/index.js +7 -6
  13. package/dist/es2019/providers/confluence/confluenceContentAPI.js +62 -40
  14. package/dist/es2019/providers/syncBlockProvider.js +15 -9
  15. package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +16 -14
  16. package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +64 -12
  17. package/dist/es2019/store-manager/syncBlockStoreManager.js +34 -8
  18. package/dist/es2019/utils/errorHandling.js +7 -0
  19. package/dist/es2019/utils/utils.js +31 -0
  20. package/dist/esm/hooks/useFetchSyncBlockData.js +60 -6
  21. package/dist/esm/index.js +7 -6
  22. package/dist/esm/providers/confluence/confluenceContentAPI.js +79 -66
  23. package/dist/esm/providers/syncBlockProvider.js +60 -36
  24. package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +21 -17
  25. package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +79 -18
  26. package/dist/esm/store-manager/syncBlockStoreManager.js +46 -8
  27. package/dist/esm/utils/errorHandling.js +7 -0
  28. package/dist/esm/utils/utils.js +31 -0
  29. package/dist/types/common/schema.d.ts +1 -1
  30. package/dist/types/hooks/useFetchSyncBlockData.d.ts +6 -3
  31. package/dist/types/index.d.ts +10 -9
  32. package/dist/types/providers/confluence/confluenceContentAPI.d.ts +2 -2
  33. package/dist/types/providers/syncBlockProvider.d.ts +4 -3
  34. package/dist/types/providers/types.d.ts +6 -2
  35. package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +2 -1
  36. package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +15 -3
  37. package/dist/types/store-manager/syncBlockStoreManager.d.ts +22 -3
  38. package/dist/types/utils/errorHandling.d.ts +1 -0
  39. package/dist/types/utils/utils.d.ts +6 -1
  40. package/dist/types-ts4.5/common/schema.d.ts +1 -1
  41. package/dist/types-ts4.5/hooks/useFetchSyncBlockData.d.ts +6 -3
  42. package/dist/types-ts4.5/index.d.ts +10 -9
  43. package/dist/types-ts4.5/providers/confluence/confluenceContentAPI.d.ts +2 -2
  44. package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +4 -3
  45. package/dist/types-ts4.5/providers/types.d.ts +6 -2
  46. package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +2 -1
  47. package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +15 -3
  48. package/dist/types-ts4.5/store-manager/syncBlockStoreManager.d.ts +22 -3
  49. package/dist/types-ts4.5/utils/errorHandling.d.ts +1 -0
  50. package/dist/types-ts4.5/utils/utils.d.ts +6 -1
  51. package/package.json +2 -2
  52. package/dist/cjs/utils/createSyncBlock.js +0 -15
  53. package/dist/es2019/utils/createSyncBlock.js +0 -9
  54. package/dist/esm/utils/createSyncBlock.js +0 -9
  55. package/dist/types/utils/createSyncBlock.d.ts +0 -2
  56. package/dist/types-ts4.5/utils/createSyncBlock.d.ts +0 -2
@@ -1,15 +1,18 @@
1
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
1
+ import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
- import type { SyncBlockAttrs, SyncBlockNode } from '../common/types';
4
+ import type { ResourceId, SyncBlockAttrs } from '../common/types';
5
5
  import type { SyncBlockDataProvider } from '../providers/types';
6
6
  export type ConfirmationCallback = () => Promise<boolean>;
7
+ export type CreationCallback = () => void;
7
8
  export declare class SourceSyncBlockStoreManager {
8
9
  private dataProvider?;
9
10
  private editorView?;
10
11
  private syncBlockCache;
11
12
  private confirmationCallback?;
12
13
  private confirmationTransaction?;
14
+ private pendingResourceId?;
15
+ private creationCallback?;
13
16
  constructor(dataProvider?: SyncBlockDataProvider);
14
17
  /**
15
18
  * Add/update a sync block node to/from the local cache
@@ -23,9 +26,18 @@ export declare class SourceSyncBlockStoreManager {
23
26
  */
24
27
  flushBodiedSyncBlocks(): Promise<boolean>;
25
28
  setEditorView(editorView: EditorView | undefined): void;
29
+ registerPendingCreation(resourceId: ResourceId): void;
30
+ registerCreationCallback(callback: CreationCallback): void;
31
+ /**
32
+ * Fires callback to insert node (if creation is successful) and clears pending creation data
33
+ * @param success
34
+ */
35
+ commitPendingCreation(success: boolean): void;
36
+ hasPendingCreation(): boolean;
26
37
  registerConfirmationCallback(callback: ConfirmationCallback): () => void;
27
38
  requireConfirmationBeforeDelete(): boolean;
28
- createSyncBlockNode(): SyncBlockNode;
39
+ generateBodiedSyncBlockAttrs(): SyncBlockAttrs;
40
+ createBodiedSyncBlockNode(attrs: SyncBlockAttrs): void;
29
41
  deleteSyncBlocksWithConfirmation(tr: Transaction, syncBlockIds: SyncBlockAttrs[]): Promise<void>;
30
42
  rebaseTransaction(incomingTr: Transaction, state: EditorState): void;
31
43
  }
@@ -1,9 +1,10 @@
1
1
  import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
2
2
  import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
3
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
4
- import type { ResourceId, SyncBlockAttrs, SyncBlockNode } from '../common/types';
4
+ import type { ResourceId, SyncBlockAttrs } from '../common/types';
5
5
  import type { SubscriptionCallback, SyncBlockDataProvider, SyncBlockInstance, TitleSubscriptionCallback } from '../providers/types';
6
- import { type ConfirmationCallback } from './sourceSyncBlockStoreManager';
6
+ import { ReferenceSyncBlockStoreManager } from './referenceSyncBlockStoreManager';
7
+ import { type ConfirmationCallback, type CreationCallback } from './sourceSyncBlockStoreManager';
7
8
  export declare class SyncBlockStoreManager {
8
9
  private referenceSyncBlockStoreManager;
9
10
  private sourceSyncBlockStoreManager;
@@ -14,6 +15,7 @@ export declare class SyncBlockStoreManager {
14
15
  * @returns The fetched sync block data results
15
16
  */
16
17
  fetchSyncBlocksData(nodes: PMNode[]): Promise<SyncBlockInstance[]>;
18
+ getReferenceSyncBlockStoreManager(): ReferenceSyncBlockStoreManager;
17
19
  /**
18
20
  * Add/update a sync block node to/from the local cache
19
21
  * @param syncBlockNode - The sync block node to update
@@ -35,7 +37,24 @@ export declare class SyncBlockStoreManager {
35
37
  isSourceBlock(node: PMNode): boolean;
36
38
  registerConfirmationCallback(callback: ConfirmationCallback): () => void;
37
39
  requireConfirmationBeforeDelete(): boolean;
38
- createSyncBlockNode(): SyncBlockNode;
40
+ /**
41
+ * Register callback function (which inserts node, handles focus etc) to be used later when creation to backend succeed
42
+ */
43
+ registerCreationCallback(callback: CreationCallback): void;
44
+ /**
45
+ *
46
+ * @returns true if waiting for the result of saving new bodiedSyncBlock to backend
47
+ */
48
+ hasPendingCreation(): boolean;
49
+ /**
50
+ * @returns attributes for a new bodiedSyncBlock node
51
+ */
52
+ generateBodiedSyncBlockAttrs(): SyncBlockAttrs;
53
+ /**
54
+ * Save bodiedSyncBlock with empty content to backend
55
+ * @param attrs attributes Ids of the node
56
+ */
57
+ createBodiedSyncBlockNode(attrs: SyncBlockAttrs): void;
39
58
  subscribeToSyncBlockData(node: PMNode, callback: SubscriptionCallback): () => void;
40
59
  subscribeToSyncBlockSourceTitle(node: PMNode, callback: TitleSubscriptionCallback): () => void;
41
60
  refreshSubscriptions(): void;
@@ -0,0 +1 @@
1
+ export declare const stringifyError: (error: unknown) => string | undefined;
@@ -1,5 +1,10 @@
1
+ import type { JSONNode } from '@atlaskit/editor-json-transformer';
1
2
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
- import type { SyncBlockData } from '../common/types';
3
+ import type { SyncBlockData, BlockInstanceId, ResourceId, SyncBlockNode } from '../common/types';
3
4
  import type { PAGE_TYPE } from './ari';
4
5
  export declare const convertSyncBlockPMNodeToSyncBlockData: (node: PMNode) => SyncBlockData;
5
6
  export declare const isBlogPageType: (pageType: PAGE_TYPE) => boolean;
7
+ export declare const createSyncBlockNode: (localId: BlockInstanceId, resourceId: ResourceId) => SyncBlockNode;
8
+ export declare const createBodiedSyncBlockNode: (localId: BlockInstanceId, resourceId: ResourceId) => SyncBlockNode;
9
+ export declare const convertSyncBlockJSONNodeToSyncBlockNode: (node: JSONNode) => SyncBlockNode | undefined;
10
+ export declare const convertPMNodeToSyncBlockNode: (node: PMNode) => SyncBlockNode | undefined;
@@ -3,4 +3,4 @@
3
3
  * Otherwise we could import defaultSchemaConfig from '@atlaskit/adf-schema/schema-default';
4
4
  * @returns
5
5
  */
6
- export declare const getDefaultSyncBlockSchema: () => import("prosemirror-model").Schema<"status" | "doc" | "paragraph" | "text" | "bulletList" | "orderedList" | "listItem" | "heading" | "blockquote" | "codeBlock" | "panel" | "rule" | "expand" | "nestedExpand" | "table" | "tableCell" | "tableHeader" | "tableRow" | "date" | "layoutSection" | "layoutColumn" | "unsupportedBlock" | "unsupportedInline", "link" | "em" | "strong" | "strike" | "subsup" | "underline" | "code" | "textColor" | "backgroundColor" | "alignment" | "indentation" | "border" | "unsupportedMark" | "unsupportedNodeAttribute" | "typeAheadQuery">;
6
+ export declare const getDefaultSyncBlockSchema: () => import("prosemirror-model").Schema<"doc" | "paragraph" | "text" | "bulletList" | "orderedList" | "listItem" | "heading" | "blockquote" | "codeBlock" | "panel" | "rule" | "expand" | "nestedExpand" | "table" | "tableCell" | "tableHeader" | "tableRow" | "date" | "status" | "layoutSection" | "layoutColumn" | "unsupportedBlock" | "unsupportedInline", "link" | "em" | "strong" | "strike" | "subsup" | "underline" | "code" | "textColor" | "backgroundColor" | "alignment" | "indentation" | "border" | "unsupportedMark" | "unsupportedNodeAttribute" | "typeAheadQuery">;
@@ -1,5 +1,8 @@
1
- import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
1
  import type { SyncBlockInstance } from '../providers/types';
3
2
  import type { SyncBlockStoreManager } from '../store-manager/syncBlockStoreManager';
4
- export declare const SYNC_BLOCK_FETCH_INTERVAL = 3000;
5
- export declare const useFetchSyncBlockData: (manager: SyncBlockStoreManager, syncBlockNode: PMNode) => SyncBlockInstance | null;
3
+ export interface UseFetchSyncBlockDataResult {
4
+ isLoading: boolean;
5
+ reloadData: () => Promise<void>;
6
+ syncBlockInstance: SyncBlockInstance | null;
7
+ }
8
+ export declare const useFetchSyncBlockData: (manager: SyncBlockStoreManager, resourceId?: string, localId?: string) => UseFetchSyncBlockDataResult;
@@ -1,14 +1,15 @@
1
- export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
2
- export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
3
- export { useFetchSyncBlockData } from './hooks/useFetchSyncBlockData';
1
+ export { rebaseTransaction } from './common/rebase-transaction';
2
+ export { getDefaultSyncBlockSchema } from './common/schema';
3
+ export { SyncBlockError } from './common/types';
4
+ export type { SyncBlockData, SyncBlockNode } from './common/types';
5
+ export { useFetchSyncBlockData, type UseFetchSyncBlockDataResult, } from './hooks/useFetchSyncBlockData';
4
6
  export { useFetchSyncBlockTitle } from './hooks/useFetchSyncBlockTitle';
5
7
  export { useHandleContentChanges } from './hooks/useHandleContentChanges';
6
- export type { SyncBlockData, SyncBlockNode } from './common/types';
7
- export type { SyncBlockDataProvider, ADFFetchProvider, ADFWriteProvider, SyncBlockInstance, } from './providers/types';
8
- export { SyncBlockError } from './common/types';
9
- export { getDefaultSyncBlockSchema } from './common/schema';
10
8
  export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluence/confluenceContentAPI';
9
+ export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
10
+ export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, } from './providers/types';
11
+ export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
12
+ export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
11
13
  export { getConfluencePageAri, getPageIdAndTypeFromAri } from './utils/ari';
12
- export { convertSyncBlockPMNodeToSyncBlockData } from './utils/utils';
13
- export { rebaseTransaction } from './common/rebase-transaction';
14
+ export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, } from './utils/utils';
14
15
  export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
@@ -1,5 +1,5 @@
1
1
  import { type SyncBlockData } from '../../common/types';
2
- import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance } from '../types';
2
+ import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, WriteSyncBlockResult } from '../types';
3
3
  /**
4
4
  * Configuration for Content API providers
5
5
  */
@@ -22,7 +22,7 @@ declare class ConfluenceADFWriteProvider implements ADFWriteProvider {
22
22
  private config;
23
23
  constructor(config: ContentAPIConfig);
24
24
  private createNewContentProperty;
25
- writeData(data: SyncBlockData): Promise<string>;
25
+ writeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
26
26
  deleteData(resourceId: string): Promise<DeleteSyncBlockResult>;
27
27
  }
28
28
  /**
@@ -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 } from '../providers/types';
3
+ import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockSourceInfo, type WriteSyncBlockResult } from '../providers/types';
4
4
  export declare class SyncBlockProvider extends SyncBlockDataProvider {
5
5
  name: string;
6
6
  private fetchProvider;
@@ -15,9 +15,10 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
15
15
  * @param nodes
16
16
  * @param data
17
17
  *
18
- * @returns the resource ids of the nodes that were written
18
+ * @returns Array of {resourceId?: string, error?: string}.
19
+ * resourceId: resource id of the node if write successfully , error: reason for when write failed
19
20
  */
20
- writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<string | undefined>>;
21
+ writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
21
22
  deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
22
23
  getSourceId(): string;
23
24
  retrieveSyncBlockSourceUrlAndTitle(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
@@ -19,15 +19,19 @@ export type SyncBlockSourceInfo = {
19
19
  title?: string;
20
20
  url?: string;
21
21
  };
22
+ export type WriteSyncBlockResult = {
23
+ error?: string;
24
+ resourceId?: string;
25
+ };
22
26
  export interface ADFFetchProvider {
23
27
  fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
24
28
  }
25
29
  export interface ADFWriteProvider {
26
30
  deleteData: (resourceId: string) => Promise<DeleteSyncBlockResult>;
27
- writeData: (data: SyncBlockData) => Promise<string>;
31
+ writeData: (data: SyncBlockData) => Promise<WriteSyncBlockResult>;
28
32
  }
29
33
  export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode, SyncBlockInstance> {
30
- abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<ResourceId | undefined>>;
34
+ abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
31
35
  abstract deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
32
36
  abstract getSourceId(): ResourceId;
33
37
  abstract retrieveSyncBlockSourceUrlAndTitle(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
@@ -20,8 +20,9 @@ export declare class ReferenceSyncBlockStoreManager {
20
20
  private updateSourceTitleSubscriptions;
21
21
  private getFromCache;
22
22
  private deleteFromCache;
23
- subscribe(node: PMNode, callback: SubscriptionCallback): () => void;
23
+ subscribeToSyncBlock(resourceId: string, localId: string, callback: SubscriptionCallback): () => void;
24
24
  subscribeToSourceTitle(node: PMNode, callback: TitleSubscriptionCallback): () => void;
25
+ subscribe(node: PMNode, callback: SubscriptionCallback): () => void;
25
26
  /**
26
27
  * Get the URL for a sync block.
27
28
  * @param resourceId - The resource ID of the sync block
@@ -1,15 +1,18 @@
1
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
1
+ import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
- import type { SyncBlockAttrs, SyncBlockNode } from '../common/types';
4
+ import type { ResourceId, SyncBlockAttrs } from '../common/types';
5
5
  import type { SyncBlockDataProvider } from '../providers/types';
6
6
  export type ConfirmationCallback = () => Promise<boolean>;
7
+ export type CreationCallback = () => void;
7
8
  export declare class SourceSyncBlockStoreManager {
8
9
  private dataProvider?;
9
10
  private editorView?;
10
11
  private syncBlockCache;
11
12
  private confirmationCallback?;
12
13
  private confirmationTransaction?;
14
+ private pendingResourceId?;
15
+ private creationCallback?;
13
16
  constructor(dataProvider?: SyncBlockDataProvider);
14
17
  /**
15
18
  * Add/update a sync block node to/from the local cache
@@ -23,9 +26,18 @@ export declare class SourceSyncBlockStoreManager {
23
26
  */
24
27
  flushBodiedSyncBlocks(): Promise<boolean>;
25
28
  setEditorView(editorView: EditorView | undefined): void;
29
+ registerPendingCreation(resourceId: ResourceId): void;
30
+ registerCreationCallback(callback: CreationCallback): void;
31
+ /**
32
+ * Fires callback to insert node (if creation is successful) and clears pending creation data
33
+ * @param success
34
+ */
35
+ commitPendingCreation(success: boolean): void;
36
+ hasPendingCreation(): boolean;
26
37
  registerConfirmationCallback(callback: ConfirmationCallback): () => void;
27
38
  requireConfirmationBeforeDelete(): boolean;
28
- createSyncBlockNode(): SyncBlockNode;
39
+ generateBodiedSyncBlockAttrs(): SyncBlockAttrs;
40
+ createBodiedSyncBlockNode(attrs: SyncBlockAttrs): void;
29
41
  deleteSyncBlocksWithConfirmation(tr: Transaction, syncBlockIds: SyncBlockAttrs[]): Promise<void>;
30
42
  rebaseTransaction(incomingTr: Transaction, state: EditorState): void;
31
43
  }
@@ -1,9 +1,10 @@
1
1
  import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
2
2
  import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
3
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
4
- import type { ResourceId, SyncBlockAttrs, SyncBlockNode } from '../common/types';
4
+ import type { ResourceId, SyncBlockAttrs } from '../common/types';
5
5
  import type { SubscriptionCallback, SyncBlockDataProvider, SyncBlockInstance, TitleSubscriptionCallback } from '../providers/types';
6
- import { type ConfirmationCallback } from './sourceSyncBlockStoreManager';
6
+ import { ReferenceSyncBlockStoreManager } from './referenceSyncBlockStoreManager';
7
+ import { type ConfirmationCallback, type CreationCallback } from './sourceSyncBlockStoreManager';
7
8
  export declare class SyncBlockStoreManager {
8
9
  private referenceSyncBlockStoreManager;
9
10
  private sourceSyncBlockStoreManager;
@@ -14,6 +15,7 @@ export declare class SyncBlockStoreManager {
14
15
  * @returns The fetched sync block data results
15
16
  */
16
17
  fetchSyncBlocksData(nodes: PMNode[]): Promise<SyncBlockInstance[]>;
18
+ getReferenceSyncBlockStoreManager(): ReferenceSyncBlockStoreManager;
17
19
  /**
18
20
  * Add/update a sync block node to/from the local cache
19
21
  * @param syncBlockNode - The sync block node to update
@@ -35,7 +37,24 @@ export declare class SyncBlockStoreManager {
35
37
  isSourceBlock(node: PMNode): boolean;
36
38
  registerConfirmationCallback(callback: ConfirmationCallback): () => void;
37
39
  requireConfirmationBeforeDelete(): boolean;
38
- createSyncBlockNode(): SyncBlockNode;
40
+ /**
41
+ * Register callback function (which inserts node, handles focus etc) to be used later when creation to backend succeed
42
+ */
43
+ registerCreationCallback(callback: CreationCallback): void;
44
+ /**
45
+ *
46
+ * @returns true if waiting for the result of saving new bodiedSyncBlock to backend
47
+ */
48
+ hasPendingCreation(): boolean;
49
+ /**
50
+ * @returns attributes for a new bodiedSyncBlock node
51
+ */
52
+ generateBodiedSyncBlockAttrs(): SyncBlockAttrs;
53
+ /**
54
+ * Save bodiedSyncBlock with empty content to backend
55
+ * @param attrs attributes Ids of the node
56
+ */
57
+ createBodiedSyncBlockNode(attrs: SyncBlockAttrs): void;
39
58
  subscribeToSyncBlockData(node: PMNode, callback: SubscriptionCallback): () => void;
40
59
  subscribeToSyncBlockSourceTitle(node: PMNode, callback: TitleSubscriptionCallback): () => void;
41
60
  refreshSubscriptions(): void;
@@ -0,0 +1 @@
1
+ export declare const stringifyError: (error: unknown) => string | undefined;
@@ -1,5 +1,10 @@
1
+ import type { JSONNode } from '@atlaskit/editor-json-transformer';
1
2
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
- import type { SyncBlockData } from '../common/types';
3
+ import type { SyncBlockData, BlockInstanceId, ResourceId, SyncBlockNode } from '../common/types';
3
4
  import type { PAGE_TYPE } from './ari';
4
5
  export declare const convertSyncBlockPMNodeToSyncBlockData: (node: PMNode) => SyncBlockData;
5
6
  export declare const isBlogPageType: (pageType: PAGE_TYPE) => boolean;
7
+ export declare const createSyncBlockNode: (localId: BlockInstanceId, resourceId: ResourceId) => SyncBlockNode;
8
+ export declare const createBodiedSyncBlockNode: (localId: BlockInstanceId, resourceId: ResourceId) => SyncBlockNode;
9
+ export declare const convertSyncBlockJSONNodeToSyncBlockNode: (node: JSONNode) => SyncBlockNode | undefined;
10
+ export declare const convertPMNodeToSyncBlockNode: (node: PMNode) => SyncBlockNode | undefined;
package/package.json CHANGED
@@ -29,7 +29,7 @@
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
- "@atlaskit/node-data-provider": "^7.4.0",
32
+ "@atlaskit/node-data-provider": "^7.5.0",
33
33
  "@atlaskit/primitives": "^16.1.0",
34
34
  "@atlaskit/tokens": "^7.1.0",
35
35
  "@babel/runtime": "^7.0.0",
@@ -82,7 +82,7 @@
82
82
  }
83
83
  },
84
84
  "name": "@atlaskit/editor-synced-block-provider",
85
- "version": "2.5.2",
85
+ "version": "2.7.0",
86
86
  "description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
87
87
  "author": "Atlassian Pty Ltd",
88
88
  "license": "Apache-2.0",
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createSyncBlockNode = void 0;
7
- var createSyncBlockNode = exports.createSyncBlockNode = function createSyncBlockNode(localId, resourceId) {
8
- return {
9
- type: 'syncBlock',
10
- attrs: {
11
- localId: localId,
12
- resourceId: resourceId
13
- }
14
- };
15
- };
@@ -1,9 +0,0 @@
1
- export const createSyncBlockNode = (localId, resourceId) => {
2
- return {
3
- type: 'syncBlock',
4
- attrs: {
5
- localId,
6
- resourceId
7
- }
8
- };
9
- };
@@ -1,9 +0,0 @@
1
- export var createSyncBlockNode = function createSyncBlockNode(localId, resourceId) {
2
- return {
3
- type: 'syncBlock',
4
- attrs: {
5
- localId: localId,
6
- resourceId: resourceId
7
- }
8
- };
9
- };
@@ -1,2 +0,0 @@
1
- import type { BlockInstanceId, ResourceId, SyncBlockNode } from '../common/types';
2
- export declare const createSyncBlockNode: (localId: BlockInstanceId, resourceId: ResourceId) => SyncBlockNode;
@@ -1,2 +0,0 @@
1
- import type { BlockInstanceId, ResourceId, SyncBlockNode } from '../common/types';
2
- export declare const createSyncBlockNode: (localId: BlockInstanceId, resourceId: ResourceId) => SyncBlockNode;