@atlaskit/editor-synced-block-provider 2.2.0 → 2.2.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.
- package/CHANGELOG.md +15 -0
- package/dist/cjs/common/types.js +7 -24
- package/dist/cjs/hooks/useFetchSyncBlockData.js +49 -0
- package/dist/cjs/hooks/useHandleContentChanges.js +13 -0
- package/dist/cjs/index.js +11 -9
- package/dist/cjs/providers/{confluenceContentAPI.js → confluence/confluenceContentAPI.js} +19 -16
- package/dist/cjs/providers/{inMemory.js → in-memory/inMemory.js} +4 -1
- package/dist/cjs/{common → providers}/syncBlockProvider.js +1 -1
- package/dist/cjs/providers/types.js +23 -0
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +123 -0
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +191 -0
- package/dist/cjs/store-manager/syncBlockStoreManager.js +111 -0
- package/dist/cjs/utils/utils.js +1 -17
- package/dist/es2019/common/types.js +6 -8
- package/dist/es2019/hooks/useFetchSyncBlockData.js +38 -0
- package/dist/es2019/hooks/useHandleContentChanges.js +7 -0
- package/dist/es2019/index.js +8 -6
- package/dist/es2019/providers/{confluenceContentAPI.js → confluence/confluenceContentAPI.js} +19 -16
- package/dist/es2019/providers/{inMemory.js → in-memory/inMemory.js} +4 -1
- package/dist/es2019/{common → providers}/syncBlockProvider.js +1 -1
- package/dist/es2019/providers/types.js +2 -0
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +83 -0
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +115 -0
- package/dist/es2019/store-manager/syncBlockStoreManager.js +79 -0
- package/dist/es2019/utils/utils.js +0 -13
- package/dist/esm/common/types.js +6 -22
- package/dist/esm/hooks/useFetchSyncBlockData.js +42 -0
- package/dist/esm/hooks/useHandleContentChanges.js +7 -0
- package/dist/esm/index.js +8 -6
- package/dist/esm/providers/{confluenceContentAPI.js → confluence/confluenceContentAPI.js} +19 -16
- package/dist/esm/providers/{inMemory.js → in-memory/inMemory.js} +4 -1
- package/dist/esm/{common → providers}/syncBlockProvider.js +1 -1
- package/dist/esm/providers/types.js +16 -0
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +116 -0
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +184 -0
- package/dist/esm/store-manager/syncBlockStoreManager.js +105 -0
- package/dist/esm/utils/utils.js +0 -16
- package/dist/types/common/schema.d.ts +1 -1
- package/dist/types/common/types.d.ts +13 -26
- package/dist/types/hooks/useFetchSyncBlockData.d.ts +4 -0
- package/dist/types/hooks/useHandleContentChanges.d.ts +3 -0
- package/dist/types/index.d.ts +10 -7
- package/dist/{types-ts4.5/providers → types/providers/confluence}/confluenceContentAPI.d.ts +2 -1
- package/dist/types/providers/{inMemory.d.ts → in-memory/inMemory.d.ts} +1 -1
- package/dist/types/{common → providers}/syncBlockProvider.d.ts +2 -1
- package/dist/types/providers/types.d.ts +18 -0
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +23 -0
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +31 -0
- package/dist/types/{common → store-manager}/syncBlockStoreManager.d.ts +7 -25
- package/dist/types/utils/utils.d.ts +1 -2
- package/dist/types-ts4.5/common/schema.d.ts +1 -1
- package/dist/types-ts4.5/common/types.d.ts +13 -26
- package/dist/types-ts4.5/hooks/useFetchSyncBlockData.d.ts +4 -0
- package/dist/types-ts4.5/hooks/useHandleContentChanges.d.ts +3 -0
- package/dist/types-ts4.5/index.d.ts +10 -7
- package/dist/{types/providers → types-ts4.5/providers/confluence}/confluenceContentAPI.d.ts +2 -1
- package/dist/types-ts4.5/providers/{inMemory.d.ts → in-memory/inMemory.d.ts} +1 -1
- package/dist/types-ts4.5/{common → providers}/syncBlockProvider.d.ts +2 -1
- package/dist/types-ts4.5/providers/types.d.ts +18 -0
- package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +23 -0
- package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +31 -0
- package/dist/types-ts4.5/{common → store-manager}/syncBlockStoreManager.d.ts +7 -25
- package/dist/types-ts4.5/utils/utils.d.ts +1 -2
- package/package.json +2 -2
- package/dist/cjs/common/syncBlockStoreManager.js +0 -377
- package/dist/es2019/common/syncBlockStoreManager.js +0 -265
- package/dist/esm/common/syncBlockStoreManager.js +0 -370
|
@@ -1,42 +1,29 @@
|
|
|
1
1
|
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
|
+
export type ResourceId = string;
|
|
4
5
|
export type SyncBlockAttrs = {
|
|
5
|
-
localId:
|
|
6
|
-
resourceId:
|
|
6
|
+
localId: BlockInstanceId;
|
|
7
|
+
resourceId: ResourceId;
|
|
7
8
|
};
|
|
8
|
-
export
|
|
9
|
+
export interface SyncBlockNode extends JSONNode {
|
|
9
10
|
attrs: SyncBlockAttrs;
|
|
10
|
-
content?: Array<JSONNode>;
|
|
11
|
+
content?: Array<JSONNode | undefined>;
|
|
11
12
|
type: 'syncBlock' | 'bodiedSyncBlock';
|
|
12
|
-
}
|
|
13
|
-
export declare enum
|
|
13
|
+
}
|
|
14
|
+
export declare enum SyncBlockError {
|
|
14
15
|
Errored = "errored",
|
|
15
16
|
NotFound = "not_found",
|
|
16
|
-
|
|
17
|
+
Forbidden = "forbidden"
|
|
17
18
|
}
|
|
18
|
-
export
|
|
19
|
-
blockInstanceId:
|
|
19
|
+
export interface SyncBlockData {
|
|
20
|
+
blockInstanceId: BlockInstanceId;
|
|
20
21
|
content: Array<ADFEntity>;
|
|
21
22
|
createdAt?: string;
|
|
22
23
|
createdBy?: string;
|
|
23
24
|
isSynced?: boolean;
|
|
24
|
-
resourceId:
|
|
25
|
+
resourceId: ResourceId;
|
|
25
26
|
sourceDocumentAri?: string;
|
|
27
|
+
sourceURL?: string;
|
|
26
28
|
updatedAt?: string;
|
|
27
|
-
};
|
|
28
|
-
export type FetchSyncBlockDataResult = SyncBlockData | {
|
|
29
|
-
resourceId?: string;
|
|
30
|
-
status: SyncBlockStatus;
|
|
31
|
-
};
|
|
32
|
-
export interface ADFFetchProvider {
|
|
33
|
-
fetchData: (resourceId: string) => Promise<FetchSyncBlockDataResult>;
|
|
34
|
-
}
|
|
35
|
-
export interface ADFWriteProvider {
|
|
36
|
-
writeData: (data: SyncBlockData) => Promise<string>;
|
|
37
|
-
}
|
|
38
|
-
export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode, FetchSyncBlockDataResult> {
|
|
39
|
-
abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<string | undefined>>;
|
|
40
|
-
abstract getSourceId(): string;
|
|
41
|
-
abstract retrieveSyncBlockSourceUrl(node: SyncBlockNode): Promise<string | undefined>;
|
|
42
29
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { FetchSyncBlockDataResult } from '../providers/types';
|
|
3
|
+
import type { SyncBlockStoreManager } from '../store-manager/syncBlockStoreManager';
|
|
4
|
+
export declare const useFetchSyncBlockData: (manager: SyncBlockStoreManager, syncBlockNode: PMNode) => FetchSyncBlockDataResult | null;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './
|
|
2
|
-
export { SyncBlockStoreManager
|
|
3
|
-
export
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
1
|
+
export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
|
|
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, FetchSyncBlockDataResult, } from './providers/types';
|
|
7
|
+
export { SyncBlockError } from './common/types';
|
|
8
|
+
export { inMemoryFetchProvider, inMemoryWriteProvider } from './providers/in-memory/inMemory';
|
|
6
9
|
export { getDefaultSyncBlockSchema } from './common/schema';
|
|
7
|
-
export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluenceContentAPI';
|
|
10
|
+
export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluence/confluenceContentAPI';
|
|
8
11
|
export { getConfluencePageAri } from './utils/ari';
|
|
9
|
-
export {
|
|
12
|
+
export { convertSyncBlockPMNodeToSyncBlockData } from './utils/utils';
|
|
10
13
|
export { rebaseTransaction } from './common/rebase-transaction';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type SyncBlockData } from '../../common/types';
|
|
2
|
+
import type { ADFFetchProvider, ADFWriteProvider, FetchSyncBlockDataResult } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* Configuration for Content API providers
|
|
4
5
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
|
|
2
|
-
import
|
|
2
|
+
import type { SyncBlockData, SyncBlockNode } from '../common/types';
|
|
3
|
+
import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type FetchSyncBlockDataResult } from '../providers/types';
|
|
3
4
|
export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
4
5
|
name: string;
|
|
5
6
|
private fetchProvider;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { NodeDataProvider } from '@atlaskit/node-data-provider';
|
|
2
|
+
import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode } from '../common/types';
|
|
3
|
+
export type FetchSyncBlockDataResult = {
|
|
4
|
+
data?: SyncBlockData;
|
|
5
|
+
error?: SyncBlockError;
|
|
6
|
+
resourceId?: string;
|
|
7
|
+
};
|
|
8
|
+
export interface ADFFetchProvider {
|
|
9
|
+
fetchData: (resourceId: ResourceId) => Promise<FetchSyncBlockDataResult>;
|
|
10
|
+
}
|
|
11
|
+
export interface ADFWriteProvider {
|
|
12
|
+
writeData: (data: SyncBlockData) => Promise<string>;
|
|
13
|
+
}
|
|
14
|
+
export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode, FetchSyncBlockDataResult> {
|
|
15
|
+
abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<ResourceId | undefined>>;
|
|
16
|
+
abstract getSourceId(): ResourceId;
|
|
17
|
+
abstract retrieveSyncBlockSourceUrl(node: SyncBlockNode): Promise<string | undefined>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { BlockInstanceId } from '../common/types';
|
|
3
|
+
import type { FetchSyncBlockDataResult, SyncBlockDataProvider } from '../providers/types';
|
|
4
|
+
export declare class ReferenceSyncBlockStoreManager {
|
|
5
|
+
private dataProvider?;
|
|
6
|
+
private syncBlockCache;
|
|
7
|
+
private syncBlockURLRequests;
|
|
8
|
+
constructor(dataProvider?: SyncBlockDataProvider);
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param localId - The local ID of the sync block to get the source URL for
|
|
12
|
+
* @param resourceId - The resource ID of the sync block to get the source URL for
|
|
13
|
+
* Fetches source URl for a sync block and updates sync block data with the source URL asynchronously.
|
|
14
|
+
*/
|
|
15
|
+
private fetchSyncBlockSourceURL;
|
|
16
|
+
fetchSyncBlockData(syncBlockNode: PMNode): Promise<FetchSyncBlockDataResult>;
|
|
17
|
+
/**
|
|
18
|
+
* Get the URL for a sync block.
|
|
19
|
+
* @param localId - The local ID of the sync block to get the URL for
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
getSyncBlockURL(localId: BlockInstanceId): string | undefined;
|
|
23
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import type { SyncBlockAttrs, SyncBlockNode } from '../common/types';
|
|
5
|
+
import type { SyncBlockDataProvider } from '../providers/types';
|
|
6
|
+
export type ConfirmationCallback = () => Promise<boolean>;
|
|
7
|
+
export declare class SourceSyncBlockStoreManager {
|
|
8
|
+
private dataProvider?;
|
|
9
|
+
private editorView?;
|
|
10
|
+
private syncBlockCache;
|
|
11
|
+
private confirmationCallback?;
|
|
12
|
+
private confirmationTransaction?;
|
|
13
|
+
constructor(dataProvider?: SyncBlockDataProvider);
|
|
14
|
+
/**
|
|
15
|
+
* Add/update a sync block node to/from the local cache
|
|
16
|
+
* @param syncBlockNode - The sync block node to update
|
|
17
|
+
*/
|
|
18
|
+
updateSyncBlockData(syncBlockNode: PMNode): void;
|
|
19
|
+
/**
|
|
20
|
+
* Save content of bodiedSyncBlock nodes in local cache to backend
|
|
21
|
+
*
|
|
22
|
+
* @returns true if saving all nodes successfully, false if fail to save some/all nodes
|
|
23
|
+
*/
|
|
24
|
+
flushBodiedSyncBlocks(): Promise<boolean>;
|
|
25
|
+
setEditorView(editorView: EditorView | undefined): void;
|
|
26
|
+
registerConfirmationCallback(callback: ConfirmationCallback): () => void;
|
|
27
|
+
requireConfirmationBeforeDelete(): boolean;
|
|
28
|
+
createSyncBlockNode(): SyncBlockNode;
|
|
29
|
+
deleteSyncBlocksWithConfirmation(tr: Transaction, syncBlockIds: SyncBlockAttrs[]): Promise<void>;
|
|
30
|
+
rebaseTransaction(incomingTr: Transaction, state: EditorState): void;
|
|
31
|
+
}
|
|
@@ -1,29 +1,14 @@
|
|
|
1
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
|
|
1
2
|
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
3
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type {
|
|
4
|
-
import type { FetchSyncBlockDataResult,
|
|
5
|
-
type
|
|
6
|
-
export interface SyncBlock {
|
|
7
|
-
sourceURL?: string;
|
|
8
|
-
syncBlockData: SyncBlockData;
|
|
9
|
-
syncNode: SyncBlockNode;
|
|
10
|
-
}
|
|
11
|
-
type ConfirmationCallback = () => Promise<boolean>;
|
|
4
|
+
import type { BlockInstanceId, SyncBlockAttrs, SyncBlockNode } from '../common/types';
|
|
5
|
+
import type { FetchSyncBlockDataResult, SyncBlockDataProvider } from '../providers/types';
|
|
6
|
+
import { type ConfirmationCallback } from './sourceSyncBlockStoreManager';
|
|
12
7
|
export declare class SyncBlockStoreManager {
|
|
13
|
-
private
|
|
14
|
-
private
|
|
15
|
-
private confirmationCallback?;
|
|
16
|
-
private editorView?;
|
|
17
|
-
private dataProvider?;
|
|
18
|
-
private confirmationTransaction?;
|
|
8
|
+
private referenceSyncBlockStoreManager;
|
|
9
|
+
private sourceSyncBlockStoreManager;
|
|
19
10
|
constructor(dataProvider?: SyncBlockDataProvider);
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
* @param node - The sync block node to get the source URL for
|
|
23
|
-
* @returns The source URL for the sync block node if it exists. Otherwise trigger fetch and return undefined, syncBlock will update with URL asynchronously.
|
|
24
|
-
*/
|
|
25
|
-
private getSyncBlockSourceURL;
|
|
26
|
-
fetchSyncBlockData(syncBlockNode: PMNode): Promise<FetchSyncBlockDataResult>;
|
|
11
|
+
fetchSyncBlockData(syncBlockNode: PMNode): Promise<FetchSyncBlockDataResult | undefined>;
|
|
27
12
|
/**
|
|
28
13
|
* Add/update a sync block node to/from the local cache
|
|
29
14
|
* @param syncBlockNode - The sync block node to update
|
|
@@ -49,6 +34,3 @@ export declare class SyncBlockStoreManager {
|
|
|
49
34
|
deleteSyncBlocksWithConfirmation(tr: Transaction, syncBlockIds: SyncBlockAttrs[]): Promise<void>;
|
|
50
35
|
rebaseTransaction(incomingTr: Transaction, state: EditorState): void;
|
|
51
36
|
}
|
|
52
|
-
export declare function useFetchSyncBlockData(manager: SyncBlockStoreManager, syncBlockNode: PMNode): FetchSyncBlockDataResult | null;
|
|
53
|
-
export declare function useHandleContentChanges(manager: SyncBlockStoreManager, syncBlockNode: PMNode): void;
|
|
54
|
-
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
import type { SyncBlockData
|
|
2
|
+
import type { SyncBlockData } from '../common/types';
|
|
3
3
|
import type { PAGE_TYPE } from './ari';
|
|
4
|
-
export declare const convertSyncBlockPMNodeToSyncBlockNode: (node: PMNode, includeContent?: boolean) => SyncBlockNode;
|
|
5
4
|
export declare const convertSyncBlockPMNodeToSyncBlockData: (node: PMNode) => SyncBlockData;
|
|
6
5
|
export declare const isBlogPageType: (pageType: PAGE_TYPE) => boolean;
|
|
@@ -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,42 +1,29 @@
|
|
|
1
1
|
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
|
+
export type ResourceId = string;
|
|
4
5
|
export type SyncBlockAttrs = {
|
|
5
|
-
localId:
|
|
6
|
-
resourceId:
|
|
6
|
+
localId: BlockInstanceId;
|
|
7
|
+
resourceId: ResourceId;
|
|
7
8
|
};
|
|
8
|
-
export
|
|
9
|
+
export interface SyncBlockNode extends JSONNode {
|
|
9
10
|
attrs: SyncBlockAttrs;
|
|
10
|
-
content?: Array<JSONNode>;
|
|
11
|
+
content?: Array<JSONNode | undefined>;
|
|
11
12
|
type: 'syncBlock' | 'bodiedSyncBlock';
|
|
12
|
-
}
|
|
13
|
-
export declare enum
|
|
13
|
+
}
|
|
14
|
+
export declare enum SyncBlockError {
|
|
14
15
|
Errored = "errored",
|
|
15
16
|
NotFound = "not_found",
|
|
16
|
-
|
|
17
|
+
Forbidden = "forbidden"
|
|
17
18
|
}
|
|
18
|
-
export
|
|
19
|
-
blockInstanceId:
|
|
19
|
+
export interface SyncBlockData {
|
|
20
|
+
blockInstanceId: BlockInstanceId;
|
|
20
21
|
content: Array<ADFEntity>;
|
|
21
22
|
createdAt?: string;
|
|
22
23
|
createdBy?: string;
|
|
23
24
|
isSynced?: boolean;
|
|
24
|
-
resourceId:
|
|
25
|
+
resourceId: ResourceId;
|
|
25
26
|
sourceDocumentAri?: string;
|
|
27
|
+
sourceURL?: string;
|
|
26
28
|
updatedAt?: string;
|
|
27
|
-
};
|
|
28
|
-
export type FetchSyncBlockDataResult = SyncBlockData | {
|
|
29
|
-
resourceId?: string;
|
|
30
|
-
status: SyncBlockStatus;
|
|
31
|
-
};
|
|
32
|
-
export interface ADFFetchProvider {
|
|
33
|
-
fetchData: (resourceId: string) => Promise<FetchSyncBlockDataResult>;
|
|
34
|
-
}
|
|
35
|
-
export interface ADFWriteProvider {
|
|
36
|
-
writeData: (data: SyncBlockData) => Promise<string>;
|
|
37
|
-
}
|
|
38
|
-
export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode, FetchSyncBlockDataResult> {
|
|
39
|
-
abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<string | undefined>>;
|
|
40
|
-
abstract getSourceId(): string;
|
|
41
|
-
abstract retrieveSyncBlockSourceUrl(node: SyncBlockNode): Promise<string | undefined>;
|
|
42
29
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { FetchSyncBlockDataResult } from '../providers/types';
|
|
3
|
+
import type { SyncBlockStoreManager } from '../store-manager/syncBlockStoreManager';
|
|
4
|
+
export declare const useFetchSyncBlockData: (manager: SyncBlockStoreManager, syncBlockNode: PMNode) => FetchSyncBlockDataResult | null;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './
|
|
2
|
-
export { SyncBlockStoreManager
|
|
3
|
-
export
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
1
|
+
export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
|
|
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, FetchSyncBlockDataResult, } from './providers/types';
|
|
7
|
+
export { SyncBlockError } from './common/types';
|
|
8
|
+
export { inMemoryFetchProvider, inMemoryWriteProvider } from './providers/in-memory/inMemory';
|
|
6
9
|
export { getDefaultSyncBlockSchema } from './common/schema';
|
|
7
|
-
export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluenceContentAPI';
|
|
10
|
+
export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluence/confluenceContentAPI';
|
|
8
11
|
export { getConfluencePageAri } from './utils/ari';
|
|
9
|
-
export {
|
|
12
|
+
export { convertSyncBlockPMNodeToSyncBlockData } from './utils/utils';
|
|
10
13
|
export { rebaseTransaction } from './common/rebase-transaction';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type SyncBlockData } from '../../common/types';
|
|
2
|
+
import type { ADFFetchProvider, ADFWriteProvider, FetchSyncBlockDataResult } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* Configuration for Content API providers
|
|
4
5
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
|
|
2
|
-
import
|
|
2
|
+
import type { SyncBlockData, SyncBlockNode } from '../common/types';
|
|
3
|
+
import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type FetchSyncBlockDataResult } from '../providers/types';
|
|
3
4
|
export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
4
5
|
name: string;
|
|
5
6
|
private fetchProvider;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { NodeDataProvider } from '@atlaskit/node-data-provider';
|
|
2
|
+
import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode } from '../common/types';
|
|
3
|
+
export type FetchSyncBlockDataResult = {
|
|
4
|
+
data?: SyncBlockData;
|
|
5
|
+
error?: SyncBlockError;
|
|
6
|
+
resourceId?: string;
|
|
7
|
+
};
|
|
8
|
+
export interface ADFFetchProvider {
|
|
9
|
+
fetchData: (resourceId: ResourceId) => Promise<FetchSyncBlockDataResult>;
|
|
10
|
+
}
|
|
11
|
+
export interface ADFWriteProvider {
|
|
12
|
+
writeData: (data: SyncBlockData) => Promise<string>;
|
|
13
|
+
}
|
|
14
|
+
export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode, FetchSyncBlockDataResult> {
|
|
15
|
+
abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<ResourceId | undefined>>;
|
|
16
|
+
abstract getSourceId(): ResourceId;
|
|
17
|
+
abstract retrieveSyncBlockSourceUrl(node: SyncBlockNode): Promise<string | undefined>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { BlockInstanceId } from '../common/types';
|
|
3
|
+
import type { FetchSyncBlockDataResult, SyncBlockDataProvider } from '../providers/types';
|
|
4
|
+
export declare class ReferenceSyncBlockStoreManager {
|
|
5
|
+
private dataProvider?;
|
|
6
|
+
private syncBlockCache;
|
|
7
|
+
private syncBlockURLRequests;
|
|
8
|
+
constructor(dataProvider?: SyncBlockDataProvider);
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param localId - The local ID of the sync block to get the source URL for
|
|
12
|
+
* @param resourceId - The resource ID of the sync block to get the source URL for
|
|
13
|
+
* Fetches source URl for a sync block and updates sync block data with the source URL asynchronously.
|
|
14
|
+
*/
|
|
15
|
+
private fetchSyncBlockSourceURL;
|
|
16
|
+
fetchSyncBlockData(syncBlockNode: PMNode): Promise<FetchSyncBlockDataResult>;
|
|
17
|
+
/**
|
|
18
|
+
* Get the URL for a sync block.
|
|
19
|
+
* @param localId - The local ID of the sync block to get the URL for
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
getSyncBlockURL(localId: BlockInstanceId): string | undefined;
|
|
23
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import type { SyncBlockAttrs, SyncBlockNode } from '../common/types';
|
|
5
|
+
import type { SyncBlockDataProvider } from '../providers/types';
|
|
6
|
+
export type ConfirmationCallback = () => Promise<boolean>;
|
|
7
|
+
export declare class SourceSyncBlockStoreManager {
|
|
8
|
+
private dataProvider?;
|
|
9
|
+
private editorView?;
|
|
10
|
+
private syncBlockCache;
|
|
11
|
+
private confirmationCallback?;
|
|
12
|
+
private confirmationTransaction?;
|
|
13
|
+
constructor(dataProvider?: SyncBlockDataProvider);
|
|
14
|
+
/**
|
|
15
|
+
* Add/update a sync block node to/from the local cache
|
|
16
|
+
* @param syncBlockNode - The sync block node to update
|
|
17
|
+
*/
|
|
18
|
+
updateSyncBlockData(syncBlockNode: PMNode): void;
|
|
19
|
+
/**
|
|
20
|
+
* Save content of bodiedSyncBlock nodes in local cache to backend
|
|
21
|
+
*
|
|
22
|
+
* @returns true if saving all nodes successfully, false if fail to save some/all nodes
|
|
23
|
+
*/
|
|
24
|
+
flushBodiedSyncBlocks(): Promise<boolean>;
|
|
25
|
+
setEditorView(editorView: EditorView | undefined): void;
|
|
26
|
+
registerConfirmationCallback(callback: ConfirmationCallback): () => void;
|
|
27
|
+
requireConfirmationBeforeDelete(): boolean;
|
|
28
|
+
createSyncBlockNode(): SyncBlockNode;
|
|
29
|
+
deleteSyncBlocksWithConfirmation(tr: Transaction, syncBlockIds: SyncBlockAttrs[]): Promise<void>;
|
|
30
|
+
rebaseTransaction(incomingTr: Transaction, state: EditorState): void;
|
|
31
|
+
}
|
|
@@ -1,29 +1,14 @@
|
|
|
1
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
|
|
1
2
|
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
3
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type {
|
|
4
|
-
import type { FetchSyncBlockDataResult,
|
|
5
|
-
type
|
|
6
|
-
export interface SyncBlock {
|
|
7
|
-
sourceURL?: string;
|
|
8
|
-
syncBlockData: SyncBlockData;
|
|
9
|
-
syncNode: SyncBlockNode;
|
|
10
|
-
}
|
|
11
|
-
type ConfirmationCallback = () => Promise<boolean>;
|
|
4
|
+
import type { BlockInstanceId, SyncBlockAttrs, SyncBlockNode } from '../common/types';
|
|
5
|
+
import type { FetchSyncBlockDataResult, SyncBlockDataProvider } from '../providers/types';
|
|
6
|
+
import { type ConfirmationCallback } from './sourceSyncBlockStoreManager';
|
|
12
7
|
export declare class SyncBlockStoreManager {
|
|
13
|
-
private
|
|
14
|
-
private
|
|
15
|
-
private confirmationCallback?;
|
|
16
|
-
private editorView?;
|
|
17
|
-
private dataProvider?;
|
|
18
|
-
private confirmationTransaction?;
|
|
8
|
+
private referenceSyncBlockStoreManager;
|
|
9
|
+
private sourceSyncBlockStoreManager;
|
|
19
10
|
constructor(dataProvider?: SyncBlockDataProvider);
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
* @param node - The sync block node to get the source URL for
|
|
23
|
-
* @returns The source URL for the sync block node if it exists. Otherwise trigger fetch and return undefined, syncBlock will update with URL asynchronously.
|
|
24
|
-
*/
|
|
25
|
-
private getSyncBlockSourceURL;
|
|
26
|
-
fetchSyncBlockData(syncBlockNode: PMNode): Promise<FetchSyncBlockDataResult>;
|
|
11
|
+
fetchSyncBlockData(syncBlockNode: PMNode): Promise<FetchSyncBlockDataResult | undefined>;
|
|
27
12
|
/**
|
|
28
13
|
* Add/update a sync block node to/from the local cache
|
|
29
14
|
* @param syncBlockNode - The sync block node to update
|
|
@@ -49,6 +34,3 @@ export declare class SyncBlockStoreManager {
|
|
|
49
34
|
deleteSyncBlocksWithConfirmation(tr: Transaction, syncBlockIds: SyncBlockAttrs[]): Promise<void>;
|
|
50
35
|
rebaseTransaction(incomingTr: Transaction, state: EditorState): void;
|
|
51
36
|
}
|
|
52
|
-
export declare function useFetchSyncBlockData(manager: SyncBlockStoreManager, syncBlockNode: PMNode): FetchSyncBlockDataResult | null;
|
|
53
|
-
export declare function useHandleContentChanges(manager: SyncBlockStoreManager, syncBlockNode: PMNode): void;
|
|
54
|
-
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
import type { SyncBlockData
|
|
2
|
+
import type { SyncBlockData } from '../common/types';
|
|
3
3
|
import type { PAGE_TYPE } from './ari';
|
|
4
|
-
export declare const convertSyncBlockPMNodeToSyncBlockNode: (node: PMNode, includeContent?: boolean) => SyncBlockNode;
|
|
5
4
|
export declare const convertSyncBlockPMNodeToSyncBlockData: (node: PMNode) => SyncBlockData;
|
|
6
5
|
export declare const isBlogPageType: (pageType: PAGE_TYPE) => boolean;
|
package/package.json
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@atlaskit/editor-json-transformer": "^8.31.0",
|
|
31
31
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
32
32
|
"@atlaskit/node-data-provider": "^7.3.0",
|
|
33
|
-
"@atlaskit/primitives": "^16.
|
|
33
|
+
"@atlaskit/primitives": "^16.1.0",
|
|
34
34
|
"@atlaskit/tokens": "^7.0.0",
|
|
35
35
|
"@babel/runtime": "^7.0.0",
|
|
36
36
|
"@compiled/react": "^0.18.6",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
}
|
|
83
83
|
},
|
|
84
84
|
"name": "@atlaskit/editor-synced-block-provider",
|
|
85
|
-
"version": "2.2.
|
|
85
|
+
"version": "2.2.2",
|
|
86
86
|
"description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
|
|
87
87
|
"author": "Atlassian Pty Ltd",
|
|
88
88
|
"license": "Apache-2.0",
|