@atlaskit/editor-synced-block-provider 2.2.3 → 2.3.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 +7 -0
- package/dist/cjs/hooks/useFetchSyncBlockData.js +5 -30
- package/dist/cjs/providers/syncBlockProvider.js +23 -4
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +319 -63
- package/dist/cjs/store-manager/syncBlockStoreManager.js +27 -4
- package/dist/cjs/utils/mergeFetchSyncBlockDataResult.js +38 -0
- package/dist/es2019/hooks/useFetchSyncBlockData.js +6 -31
- package/dist/es2019/providers/syncBlockProvider.js +17 -3
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +172 -44
- package/dist/es2019/store-manager/syncBlockStoreManager.js +21 -4
- package/dist/es2019/utils/mergeFetchSyncBlockDataResult.js +30 -0
- package/dist/esm/hooks/useFetchSyncBlockData.js +6 -31
- package/dist/esm/providers/syncBlockProvider.js +21 -2
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +320 -64
- package/dist/esm/store-manager/syncBlockStoreManager.js +27 -4
- package/dist/esm/utils/mergeFetchSyncBlockDataResult.js +31 -0
- package/dist/types/common/schema.d.ts +1 -1
- package/dist/types/providers/syncBlockProvider.d.ts +1 -1
- package/dist/types/providers/types.d.ts +1 -0
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +24 -8
- package/dist/types/store-manager/syncBlockStoreManager.d.ts +12 -4
- package/dist/types/utils/mergeFetchSyncBlockDataResult.d.ts +12 -0
- package/dist/types-ts4.5/common/schema.d.ts +1 -1
- package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +1 -1
- package/dist/types-ts4.5/providers/types.d.ts +1 -0
- package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +24 -8
- package/dist/types-ts4.5/store-manager/syncBlockStoreManager.d.ts +12 -4
- package/dist/types-ts4.5/utils/mergeFetchSyncBlockDataResult.d.ts +12 -0
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FetchSyncBlockDataResult } from '../providers/types';
|
|
2
|
+
/**
|
|
3
|
+
* Merges two FetchSyncBlockDataResult objects,
|
|
4
|
+
* currently it only preserves the sourceURL from the old result,
|
|
5
|
+
* but this can be extended in the future to preserve other fields and resolve conflicts as needed.
|
|
6
|
+
* e.g. compare timestamps or version numbers to determine which data is more recent.
|
|
7
|
+
*
|
|
8
|
+
* @param oldResult - The existing FetchSyncBlockDataResult object.
|
|
9
|
+
* @param newResult - The new FetchSyncBlockDataResult object to merge.
|
|
10
|
+
* @returns A merged FetchSyncBlockDataResult object.
|
|
11
|
+
*/
|
|
12
|
+
export declare const resolveFetchSyncBlockDataResult: (oldResult: FetchSyncBlockDataResult, newResult: FetchSyncBlockDataResult) => FetchSyncBlockDataResult;
|
|
@@ -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<"doc" | "paragraph" | "text" | "bulletList" | "orderedList" | "listItem" | "heading" | "blockquote" | "codeBlock" | "panel" | "rule" | "expand" | "nestedExpand" | "table" | "tableCell" | "tableHeader" | "tableRow" | "date" | "
|
|
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">;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
|
|
2
|
-
import type
|
|
2
|
+
import { type SyncBlockData, type SyncBlockNode } from '../common/types';
|
|
3
3
|
import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type FetchSyncBlockDataResult } from '../providers/types';
|
|
4
4
|
export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
5
5
|
name: string;
|
|
@@ -16,3 +16,4 @@ export declare abstract class SyncBlockDataProvider extends NodeDataProvider<Syn
|
|
|
16
16
|
abstract getSourceId(): ResourceId;
|
|
17
17
|
abstract retrieveSyncBlockSourceUrl(node: SyncBlockNode): Promise<string | undefined>;
|
|
18
18
|
}
|
|
19
|
+
export type SubscriptionCallback = (data: FetchSyncBlockDataResult) => void;
|
|
@@ -1,23 +1,39 @@
|
|
|
1
1
|
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
import type { ResourceId, SyncBlockNode } from '../common/types';
|
|
4
|
+
import type { FetchSyncBlockDataResult, SubscriptionCallback, SyncBlockDataProvider } from '../providers/types';
|
|
4
5
|
export declare class ReferenceSyncBlockStoreManager {
|
|
5
6
|
private dataProvider?;
|
|
6
7
|
private syncBlockCache;
|
|
8
|
+
private subscriptions;
|
|
7
9
|
private syncBlockURLRequests;
|
|
10
|
+
private editorView?;
|
|
11
|
+
private isInitialized;
|
|
12
|
+
private isRefreshingSubscriptions;
|
|
8
13
|
constructor(dataProvider?: SyncBlockDataProvider);
|
|
14
|
+
init(editorView: EditorView): Promise<void>;
|
|
9
15
|
/**
|
|
10
|
-
*
|
|
11
|
-
* @
|
|
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.
|
|
16
|
+
* Refreshes the subscriptions for all sync blocks.
|
|
17
|
+
* @returns {Promise<void>}
|
|
14
18
|
*/
|
|
19
|
+
refreshSubscriptions(): Promise<void>;
|
|
15
20
|
private fetchSyncBlockSourceURL;
|
|
21
|
+
/**
|
|
22
|
+
* Fetch sync block data for a given sync block node.
|
|
23
|
+
* @param syncBlockNode - The sync block node to fetch data for
|
|
24
|
+
* @returns The fetched sync block data result
|
|
25
|
+
*/
|
|
16
26
|
fetchSyncBlockData(syncBlockNode: PMNode): Promise<FetchSyncBlockDataResult>;
|
|
27
|
+
fetchSyncBlocksData(syncBlockNodes: SyncBlockNode[]): Promise<FetchSyncBlockDataResult[]>;
|
|
28
|
+
private updateCache;
|
|
29
|
+
private getFromCache;
|
|
30
|
+
private deleteFromCache;
|
|
31
|
+
subscribe(node: PMNode, callback: SubscriptionCallback): () => void;
|
|
17
32
|
/**
|
|
18
33
|
* Get the URL for a sync block.
|
|
19
|
-
* @param
|
|
34
|
+
* @param resourceId - The resource ID of the sync block
|
|
20
35
|
* @returns
|
|
21
36
|
*/
|
|
22
|
-
getSyncBlockURL(
|
|
37
|
+
getSyncBlockURL(resourceId: ResourceId): string | undefined;
|
|
38
|
+
destroy(): void;
|
|
23
39
|
}
|
|
@@ -1,13 +1,18 @@
|
|
|
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 {
|
|
5
|
-
import type { FetchSyncBlockDataResult, SyncBlockDataProvider } from '../providers/types';
|
|
4
|
+
import type { ResourceId, SyncBlockAttrs, SyncBlockNode } from '../common/types';
|
|
5
|
+
import type { FetchSyncBlockDataResult, SubscriptionCallback, SyncBlockDataProvider } from '../providers/types';
|
|
6
6
|
import { type ConfirmationCallback } from './sourceSyncBlockStoreManager';
|
|
7
7
|
export declare class SyncBlockStoreManager {
|
|
8
8
|
private referenceSyncBlockStoreManager;
|
|
9
9
|
private sourceSyncBlockStoreManager;
|
|
10
10
|
constructor(dataProvider?: SyncBlockDataProvider);
|
|
11
|
+
/**
|
|
12
|
+
* Fetch sync block data for a given sync block node.
|
|
13
|
+
* @param syncBlockNode - The sync block node to fetch data for
|
|
14
|
+
* @returns The fetched sync block data result
|
|
15
|
+
*/
|
|
11
16
|
fetchSyncBlockData(syncBlockNode: PMNode): Promise<FetchSyncBlockDataResult | undefined>;
|
|
12
17
|
/**
|
|
13
18
|
* Add/update a sync block node to/from the local cache
|
|
@@ -22,15 +27,18 @@ export declare class SyncBlockStoreManager {
|
|
|
22
27
|
flushBodiedSyncBlocks(): Promise<boolean>;
|
|
23
28
|
/**
|
|
24
29
|
* Get the URL for a sync block.
|
|
25
|
-
* @param
|
|
30
|
+
* @param resourceId - The resource ID of the sync block to get the URL for
|
|
26
31
|
* @returns
|
|
27
32
|
*/
|
|
28
|
-
getSyncBlockURL(
|
|
33
|
+
getSyncBlockURL(resourceId: ResourceId): string | undefined;
|
|
29
34
|
setEditorView(editorView: EditorView | undefined): void;
|
|
30
35
|
isSourceBlock(node: PMNode): boolean;
|
|
31
36
|
registerConfirmationCallback(callback: ConfirmationCallback): () => void;
|
|
32
37
|
requireConfirmationBeforeDelete(): boolean;
|
|
33
38
|
createSyncBlockNode(): SyncBlockNode;
|
|
39
|
+
subscribeToSyncBlockData(node: PMNode, callback: SubscriptionCallback): () => void;
|
|
40
|
+
refreshSubscriptions(): void;
|
|
34
41
|
deleteSyncBlocksWithConfirmation(tr: Transaction, syncBlockIds: SyncBlockAttrs[]): Promise<void>;
|
|
35
42
|
rebaseTransaction(incomingTr: Transaction, state: EditorState): void;
|
|
43
|
+
destroy(): void;
|
|
36
44
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FetchSyncBlockDataResult } from '../providers/types';
|
|
2
|
+
/**
|
|
3
|
+
* Merges two FetchSyncBlockDataResult objects,
|
|
4
|
+
* currently it only preserves the sourceURL from the old result,
|
|
5
|
+
* but this can be extended in the future to preserve other fields and resolve conflicts as needed.
|
|
6
|
+
* e.g. compare timestamps or version numbers to determine which data is more recent.
|
|
7
|
+
*
|
|
8
|
+
* @param oldResult - The existing FetchSyncBlockDataResult object.
|
|
9
|
+
* @param newResult - The new FetchSyncBlockDataResult object to merge.
|
|
10
|
+
* @returns A merged FetchSyncBlockDataResult object.
|
|
11
|
+
*/
|
|
12
|
+
export declare const resolveFetchSyncBlockDataResult: (oldResult: FetchSyncBlockDataResult, newResult: FetchSyncBlockDataResult) => FetchSyncBlockDataResult;
|
package/package.json
CHANGED