@atlaskit/editor-synced-block-provider 2.5.1 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/hooks/useFetchSyncBlockData.js +60 -6
- package/dist/cjs/hooks/useFetchSyncBlockTitle.js +24 -0
- package/dist/cjs/index.js +28 -7
- package/dist/cjs/providers/syncBlockProvider.js +12 -15
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +75 -21
- package/dist/cjs/store-manager/syncBlockStoreManager.js +10 -0
- package/dist/cjs/utils/resolveSyncBlockInstance.js +4 -3
- package/dist/es2019/hooks/useFetchSyncBlockData.js +35 -6
- package/dist/es2019/hooks/useFetchSyncBlockTitle.js +13 -0
- package/dist/es2019/index.js +10 -7
- package/dist/es2019/providers/syncBlockProvider.js +10 -8
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +71 -20
- package/dist/es2019/store-manager/syncBlockStoreManager.js +6 -0
- package/dist/es2019/utils/resolveSyncBlockInstance.js +4 -3
- package/dist/esm/hooks/useFetchSyncBlockData.js +60 -6
- package/dist/esm/hooks/useFetchSyncBlockTitle.js +17 -0
- package/dist/esm/index.js +10 -7
- package/dist/esm/providers/syncBlockProvider.js +12 -15
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +75 -21
- package/dist/esm/store-manager/syncBlockStoreManager.js +10 -0
- package/dist/esm/utils/resolveSyncBlockInstance.js +4 -3
- package/dist/types/common/schema.d.ts +1 -1
- package/dist/types/common/types.d.ts +1 -0
- package/dist/types/hooks/useFetchSyncBlockData.d.ts +6 -3
- package/dist/types/hooks/useFetchSyncBlockTitle.d.ts +3 -0
- package/dist/types/index.d.ts +12 -9
- package/dist/types/providers/syncBlockProvider.d.ts +2 -2
- package/dist/types/providers/types.d.ts +6 -1
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +6 -2
- package/dist/types/store-manager/syncBlockStoreManager.d.ts +4 -1
- package/dist/types-ts4.5/common/schema.d.ts +1 -1
- package/dist/types-ts4.5/common/types.d.ts +1 -0
- package/dist/types-ts4.5/hooks/useFetchSyncBlockData.d.ts +6 -3
- package/dist/types-ts4.5/hooks/useFetchSyncBlockTitle.d.ts +3 -0
- package/dist/types-ts4.5/index.d.ts +12 -9
- package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +2 -2
- package/dist/types-ts4.5/providers/types.d.ts +6 -1
- package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +6 -2
- package/dist/types-ts4.5/store-manager/syncBlockStoreManager.d.ts +4 -1
- package/package.json +1 -1
|
@@ -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 } from '../providers/types';
|
|
3
|
+
import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockSourceInfo } from '../providers/types';
|
|
4
4
|
export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
5
5
|
name: string;
|
|
6
6
|
private fetchProvider;
|
|
@@ -20,6 +20,6 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
20
20
|
writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<string | undefined>>;
|
|
21
21
|
deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
22
22
|
getSourceId(): string;
|
|
23
|
-
|
|
23
|
+
retrieveSyncBlockSourceUrlAndTitle(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
|
|
24
24
|
}
|
|
25
25
|
export declare const useMemoizedSyncedBlockProvider: (fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string) => SyncBlockProvider;
|
|
@@ -15,6 +15,10 @@ export type DeleteSyncBlockResult = {
|
|
|
15
15
|
resourceId: string;
|
|
16
16
|
success: boolean;
|
|
17
17
|
};
|
|
18
|
+
export type SyncBlockSourceInfo = {
|
|
19
|
+
title?: string;
|
|
20
|
+
url?: string;
|
|
21
|
+
};
|
|
18
22
|
export interface ADFFetchProvider {
|
|
19
23
|
fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
|
|
20
24
|
}
|
|
@@ -26,6 +30,7 @@ export declare abstract class SyncBlockDataProvider extends NodeDataProvider<Syn
|
|
|
26
30
|
abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<ResourceId | undefined>>;
|
|
27
31
|
abstract deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
28
32
|
abstract getSourceId(): ResourceId;
|
|
29
|
-
abstract
|
|
33
|
+
abstract retrieveSyncBlockSourceUrlAndTitle(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
|
|
30
34
|
}
|
|
31
35
|
export type SubscriptionCallback = (data: SyncBlockInstance) => void;
|
|
36
|
+
export type TitleSubscriptionCallback = (title: string) => void;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { ResourceId, SyncBlockNode } from '../common/types';
|
|
3
|
-
import type { SyncBlockInstance, SubscriptionCallback, SyncBlockDataProvider } from '../providers/types';
|
|
3
|
+
import type { SyncBlockInstance, SubscriptionCallback, SyncBlockDataProvider, TitleSubscriptionCallback } from '../providers/types';
|
|
4
4
|
export declare class ReferenceSyncBlockStoreManager {
|
|
5
5
|
private dataProvider?;
|
|
6
6
|
private syncBlockCache;
|
|
7
7
|
private subscriptions;
|
|
8
|
+
private titleSubscriptions;
|
|
8
9
|
private syncBlockURLRequests;
|
|
9
10
|
private isRefreshingSubscriptions;
|
|
10
11
|
constructor(dataProvider?: SyncBlockDataProvider);
|
|
@@ -13,11 +14,14 @@ export declare class ReferenceSyncBlockStoreManager {
|
|
|
13
14
|
* @returns {Promise<void>}
|
|
14
15
|
*/
|
|
15
16
|
refreshSubscriptions(): Promise<void>;
|
|
16
|
-
private
|
|
17
|
+
private fetchSyncBlockSourceURLAndTitle;
|
|
17
18
|
fetchSyncBlocksData(syncBlockNodes: SyncBlockNode[]): Promise<SyncBlockInstance[]>;
|
|
18
19
|
private updateCache;
|
|
20
|
+
private updateSourceTitleSubscriptions;
|
|
19
21
|
private getFromCache;
|
|
20
22
|
private deleteFromCache;
|
|
23
|
+
subscribeToSyncBlock(resourceId: string, localId: string, callback: SubscriptionCallback): () => void;
|
|
24
|
+
subscribeToSourceTitle(node: PMNode, callback: TitleSubscriptionCallback): () => void;
|
|
21
25
|
subscribe(node: PMNode, callback: SubscriptionCallback): () => void;
|
|
22
26
|
/**
|
|
23
27
|
* Get the URL for a sync block.
|
|
@@ -2,7 +2,8 @@ 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
4
|
import type { ResourceId, SyncBlockAttrs, SyncBlockNode } from '../common/types';
|
|
5
|
-
import type { SubscriptionCallback, SyncBlockDataProvider, SyncBlockInstance } from '../providers/types';
|
|
5
|
+
import type { SubscriptionCallback, SyncBlockDataProvider, SyncBlockInstance, TitleSubscriptionCallback } from '../providers/types';
|
|
6
|
+
import { ReferenceSyncBlockStoreManager } from './referenceSyncBlockStoreManager';
|
|
6
7
|
import { type ConfirmationCallback } from './sourceSyncBlockStoreManager';
|
|
7
8
|
export declare class SyncBlockStoreManager {
|
|
8
9
|
private referenceSyncBlockStoreManager;
|
|
@@ -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
|
|
@@ -37,6 +39,7 @@ export declare class SyncBlockStoreManager {
|
|
|
37
39
|
requireConfirmationBeforeDelete(): boolean;
|
|
38
40
|
createSyncBlockNode(): SyncBlockNode;
|
|
39
41
|
subscribeToSyncBlockData(node: PMNode, callback: SubscriptionCallback): () => void;
|
|
42
|
+
subscribeToSyncBlockSourceTitle(node: PMNode, callback: TitleSubscriptionCallback): () => void;
|
|
40
43
|
refreshSubscriptions(): void;
|
|
41
44
|
deleteSyncBlocksWithConfirmation(tr: Transaction, syncBlockIds: SyncBlockAttrs[]): Promise<void>;
|
|
42
45
|
rebaseTransaction(incomingTr: Transaction, state: EditorState): void;
|
|
@@ -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<"
|
|
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
|
|
5
|
-
|
|
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;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { SyncBlockStoreManager } from '../store-manager/syncBlockStoreManager';
|
|
3
|
+
export declare const useFetchSyncBlockTitle: (manager: SyncBlockStoreManager, syncBlockNode: PMNode) => string | undefined;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
|
|
3
|
-
export { useFetchSyncBlockData } from './hooks/useFetchSyncBlockData';
|
|
4
|
-
export { useHandleContentChanges } from './hooks/useHandleContentChanges';
|
|
5
|
-
export type { SyncBlockData, SyncBlockNode } from './common/types';
|
|
6
|
-
export type { SyncBlockDataProvider, ADFFetchProvider, ADFWriteProvider, SyncBlockInstance, } from './providers/types';
|
|
7
|
-
export { SyncBlockError } from './common/types';
|
|
1
|
+
export { rebaseTransaction } from './common/rebase-transaction';
|
|
8
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';
|
|
6
|
+
export { useFetchSyncBlockTitle } from './hooks/useFetchSyncBlockTitle';
|
|
7
|
+
export { useHandleContentChanges } from './hooks/useHandleContentChanges';
|
|
9
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';
|
|
10
13
|
export { getConfluencePageAri, getPageIdAndTypeFromAri } from './utils/ari';
|
|
11
|
-
export {
|
|
12
|
-
export { rebaseTransaction } from './common/rebase-transaction';
|
|
14
|
+
export { createSyncBlockNode } from './utils/createSyncBlock';
|
|
13
15
|
export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
|
|
16
|
+
export { convertSyncBlockPMNodeToSyncBlockData } from './utils/utils';
|
|
@@ -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 } from '../providers/types';
|
|
3
|
+
import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockSourceInfo } from '../providers/types';
|
|
4
4
|
export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
5
5
|
name: string;
|
|
6
6
|
private fetchProvider;
|
|
@@ -20,6 +20,6 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
20
20
|
writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<string | undefined>>;
|
|
21
21
|
deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
22
22
|
getSourceId(): string;
|
|
23
|
-
|
|
23
|
+
retrieveSyncBlockSourceUrlAndTitle(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
|
|
24
24
|
}
|
|
25
25
|
export declare const useMemoizedSyncedBlockProvider: (fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string) => SyncBlockProvider;
|
|
@@ -15,6 +15,10 @@ export type DeleteSyncBlockResult = {
|
|
|
15
15
|
resourceId: string;
|
|
16
16
|
success: boolean;
|
|
17
17
|
};
|
|
18
|
+
export type SyncBlockSourceInfo = {
|
|
19
|
+
title?: string;
|
|
20
|
+
url?: string;
|
|
21
|
+
};
|
|
18
22
|
export interface ADFFetchProvider {
|
|
19
23
|
fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
|
|
20
24
|
}
|
|
@@ -26,6 +30,7 @@ export declare abstract class SyncBlockDataProvider extends NodeDataProvider<Syn
|
|
|
26
30
|
abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<ResourceId | undefined>>;
|
|
27
31
|
abstract deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
28
32
|
abstract getSourceId(): ResourceId;
|
|
29
|
-
abstract
|
|
33
|
+
abstract retrieveSyncBlockSourceUrlAndTitle(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
|
|
30
34
|
}
|
|
31
35
|
export type SubscriptionCallback = (data: SyncBlockInstance) => void;
|
|
36
|
+
export type TitleSubscriptionCallback = (title: string) => void;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { ResourceId, SyncBlockNode } from '../common/types';
|
|
3
|
-
import type { SyncBlockInstance, SubscriptionCallback, SyncBlockDataProvider } from '../providers/types';
|
|
3
|
+
import type { SyncBlockInstance, SubscriptionCallback, SyncBlockDataProvider, TitleSubscriptionCallback } from '../providers/types';
|
|
4
4
|
export declare class ReferenceSyncBlockStoreManager {
|
|
5
5
|
private dataProvider?;
|
|
6
6
|
private syncBlockCache;
|
|
7
7
|
private subscriptions;
|
|
8
|
+
private titleSubscriptions;
|
|
8
9
|
private syncBlockURLRequests;
|
|
9
10
|
private isRefreshingSubscriptions;
|
|
10
11
|
constructor(dataProvider?: SyncBlockDataProvider);
|
|
@@ -13,11 +14,14 @@ export declare class ReferenceSyncBlockStoreManager {
|
|
|
13
14
|
* @returns {Promise<void>}
|
|
14
15
|
*/
|
|
15
16
|
refreshSubscriptions(): Promise<void>;
|
|
16
|
-
private
|
|
17
|
+
private fetchSyncBlockSourceURLAndTitle;
|
|
17
18
|
fetchSyncBlocksData(syncBlockNodes: SyncBlockNode[]): Promise<SyncBlockInstance[]>;
|
|
18
19
|
private updateCache;
|
|
20
|
+
private updateSourceTitleSubscriptions;
|
|
19
21
|
private getFromCache;
|
|
20
22
|
private deleteFromCache;
|
|
23
|
+
subscribeToSyncBlock(resourceId: string, localId: string, callback: SubscriptionCallback): () => void;
|
|
24
|
+
subscribeToSourceTitle(node: PMNode, callback: TitleSubscriptionCallback): () => void;
|
|
21
25
|
subscribe(node: PMNode, callback: SubscriptionCallback): () => void;
|
|
22
26
|
/**
|
|
23
27
|
* Get the URL for a sync block.
|
|
@@ -2,7 +2,8 @@ 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
4
|
import type { ResourceId, SyncBlockAttrs, SyncBlockNode } from '../common/types';
|
|
5
|
-
import type { SubscriptionCallback, SyncBlockDataProvider, SyncBlockInstance } from '../providers/types';
|
|
5
|
+
import type { SubscriptionCallback, SyncBlockDataProvider, SyncBlockInstance, TitleSubscriptionCallback } from '../providers/types';
|
|
6
|
+
import { ReferenceSyncBlockStoreManager } from './referenceSyncBlockStoreManager';
|
|
6
7
|
import { type ConfirmationCallback } from './sourceSyncBlockStoreManager';
|
|
7
8
|
export declare class SyncBlockStoreManager {
|
|
8
9
|
private referenceSyncBlockStoreManager;
|
|
@@ -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
|
|
@@ -37,6 +39,7 @@ export declare class SyncBlockStoreManager {
|
|
|
37
39
|
requireConfirmationBeforeDelete(): boolean;
|
|
38
40
|
createSyncBlockNode(): SyncBlockNode;
|
|
39
41
|
subscribeToSyncBlockData(node: PMNode, callback: SubscriptionCallback): () => void;
|
|
42
|
+
subscribeToSyncBlockSourceTitle(node: PMNode, callback: TitleSubscriptionCallback): () => void;
|
|
40
43
|
refreshSubscriptions(): void;
|
|
41
44
|
deleteSyncBlocksWithConfirmation(tr: Transaction, syncBlockIds: SyncBlockAttrs[]): Promise<void>;
|
|
42
45
|
rebaseTransaction(incomingTr: Transaction, state: EditorState): void;
|
package/package.json
CHANGED