@atlaskit/editor-synced-block-provider 2.4.0 → 2.5.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 +11 -0
- package/dist/cjs/hooks/useFetchSyncBlockData.js +5 -5
- package/dist/cjs/index.js +8 -1
- package/dist/cjs/providers/types.js +5 -0
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +68 -176
- package/dist/cjs/store-manager/syncBlockStoreManager.js +14 -14
- package/dist/cjs/utils/createSyncBlock.js +15 -0
- package/dist/cjs/utils/{mergeFetchSyncBlockDataResult.js → resolveSyncBlockInstance.js} +6 -6
- package/dist/es2019/hooks/useFetchSyncBlockData.js +4 -4
- package/dist/es2019/index.js +2 -1
- package/dist/es2019/providers/types.js +7 -0
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +13 -63
- package/dist/es2019/store-manager/syncBlockStoreManager.js +13 -13
- package/dist/es2019/utils/createSyncBlock.js +9 -0
- package/dist/es2019/utils/{mergeFetchSyncBlockDataResult.js → resolveSyncBlockInstance.js} +5 -5
- package/dist/esm/hooks/useFetchSyncBlockData.js +5 -5
- package/dist/esm/index.js +2 -1
- package/dist/esm/providers/types.js +7 -0
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +67 -175
- package/dist/esm/store-manager/syncBlockStoreManager.js +14 -14
- package/dist/esm/utils/createSyncBlock.js +9 -0
- package/dist/esm/utils/{mergeFetchSyncBlockDataResult.js → resolveSyncBlockInstance.js} +5 -5
- package/dist/types/hooks/useFetchSyncBlockData.d.ts +2 -2
- package/dist/types/index.d.ts +2 -1
- package/dist/types/providers/confluence/confluenceContentAPI.d.ts +2 -2
- package/dist/types/providers/syncBlockProvider.d.ts +2 -2
- package/dist/types/providers/types.d.ts +10 -5
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +2 -12
- package/dist/types/store-manager/syncBlockStoreManager.d.ts +5 -5
- package/dist/types/utils/createSyncBlock.d.ts +2 -0
- package/dist/types/utils/resolveSyncBlockInstance.d.ts +12 -0
- package/dist/types-ts4.5/hooks/useFetchSyncBlockData.d.ts +2 -2
- package/dist/types-ts4.5/index.d.ts +2 -1
- package/dist/types-ts4.5/providers/confluence/confluenceContentAPI.d.ts +2 -2
- package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +2 -2
- package/dist/types-ts4.5/providers/types.d.ts +10 -5
- package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +2 -12
- package/dist/types-ts4.5/store-manager/syncBlockStoreManager.d.ts +5 -5
- package/dist/types-ts4.5/utils/createSyncBlock.d.ts +2 -0
- package/dist/types-ts4.5/utils/resolveSyncBlockInstance.d.ts +12 -0
- package/package.json +3 -3
- package/dist/types/utils/mergeFetchSyncBlockDataResult.d.ts +0 -12
- package/dist/types-ts4.5/utils/mergeFetchSyncBlockDataResult.d.ts +0 -12
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import { createSyncBlockNode } from '../utils/createSyncBlock';
|
|
3
4
|
import { ReferenceSyncBlockStoreManager } from './referenceSyncBlockStoreManager';
|
|
4
5
|
import { SourceSyncBlockStoreManager } from './sourceSyncBlockStoreManager';
|
|
5
6
|
|
|
@@ -16,20 +17,22 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
|
-
* Fetch sync block data for a given sync block
|
|
20
|
-
* @param
|
|
21
|
-
* @returns The fetched sync block data
|
|
20
|
+
* Fetch sync block data for a given array of sync block nodes.
|
|
21
|
+
* @param nodes - The array of sync block nodes to fetch data for
|
|
22
|
+
* @returns The fetched sync block data results
|
|
22
23
|
*/
|
|
23
24
|
return _createClass(SyncBlockStoreManager, [{
|
|
24
|
-
key: "
|
|
25
|
-
value: function
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
key: "fetchSyncBlocksData",
|
|
26
|
+
value: function fetchSyncBlocksData(nodes) {
|
|
27
|
+
var syncBlockNodes = nodes.filter(function (node) {
|
|
28
|
+
return node.type.name === 'syncBlock' && node.attrs.resourceId && node.attrs.localId;
|
|
29
|
+
}).map(function (node) {
|
|
30
|
+
return createSyncBlockNode(node.attrs.localId, node.attrs.resourceId);
|
|
31
|
+
}) || [];
|
|
32
|
+
if (syncBlockNodes.length === 0) {
|
|
33
|
+
return Promise.resolve([]);
|
|
28
34
|
}
|
|
29
|
-
|
|
30
|
-
return Promise.reject(new Error('Invalid sync block node type provided for fetchSyncBlockData'));
|
|
31
|
-
}
|
|
32
|
-
return this.referenceSyncBlockStoreManager.fetchSyncBlockData(syncBlockNode);
|
|
35
|
+
return this.referenceSyncBlockStoreManager.fetchSyncBlocksData(syncBlockNodes);
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
/**
|
|
@@ -73,9 +76,6 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
73
76
|
key: "setEditorView",
|
|
74
77
|
value: function setEditorView(editorView) {
|
|
75
78
|
this.sourceSyncBlockStoreManager.setEditorView(editorView);
|
|
76
|
-
if (editorView) {
|
|
77
|
-
this.referenceSyncBlockStoreManager.init(editorView);
|
|
78
|
-
}
|
|
79
79
|
}
|
|
80
80
|
}, {
|
|
81
81
|
key: "isSourceBlock",
|
|
@@ -2,16 +2,16 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
/**
|
|
5
|
-
* Merges two
|
|
5
|
+
* Merges two SyncBlockInstance objects,
|
|
6
6
|
* currently it only preserves the sourceURL from the old result,
|
|
7
7
|
* but this can be extended in the future to preserve other fields and resolve conflicts as needed.
|
|
8
8
|
* e.g. compare timestamps or version numbers to determine which data is more recent.
|
|
9
9
|
*
|
|
10
|
-
* @param oldResult - The existing
|
|
11
|
-
* @param newResult - The new
|
|
12
|
-
* @returns A merged
|
|
10
|
+
* @param oldResult - The existing SyncBlockInstance object.
|
|
11
|
+
* @param newResult - The new SyncBlockInstance object to merge.
|
|
12
|
+
* @returns A merged SyncBlockInstance object.
|
|
13
13
|
*/
|
|
14
|
-
export var
|
|
14
|
+
export var resolveSyncBlockInstance = function resolveSyncBlockInstance(oldResult, newResult) {
|
|
15
15
|
var _newResult$data, _oldResult$data;
|
|
16
16
|
// if the old result has no data, we simple return the new result
|
|
17
17
|
if (!oldResult.data) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SyncBlockInstance } from '../providers/types';
|
|
3
3
|
import type { SyncBlockStoreManager } from '../store-manager/syncBlockStoreManager';
|
|
4
4
|
export declare const SYNC_BLOCK_FETCH_INTERVAL = 3000;
|
|
5
|
-
export declare const useFetchSyncBlockData: (manager: SyncBlockStoreManager, syncBlockNode: PMNode) =>
|
|
5
|
+
export declare const useFetchSyncBlockData: (manager: SyncBlockStoreManager, syncBlockNode: PMNode) => SyncBlockInstance | null;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,10 +3,11 @@ export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
|
|
|
3
3
|
export { useFetchSyncBlockData } from './hooks/useFetchSyncBlockData';
|
|
4
4
|
export { useHandleContentChanges } from './hooks/useHandleContentChanges';
|
|
5
5
|
export type { SyncBlockData, SyncBlockNode } from './common/types';
|
|
6
|
-
export type { SyncBlockDataProvider, ADFFetchProvider, ADFWriteProvider,
|
|
6
|
+
export type { SyncBlockDataProvider, ADFFetchProvider, ADFWriteProvider, SyncBlockInstance, } from './providers/types';
|
|
7
7
|
export { SyncBlockError } from './common/types';
|
|
8
8
|
export { getDefaultSyncBlockSchema } from './common/schema';
|
|
9
9
|
export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluence/confluenceContentAPI';
|
|
10
10
|
export { getConfluencePageAri } from './utils/ari';
|
|
11
11
|
export { convertSyncBlockPMNodeToSyncBlockData } from './utils/utils';
|
|
12
12
|
export { rebaseTransaction } from './common/rebase-transaction';
|
|
13
|
+
export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type SyncBlockData } from '../../common/types';
|
|
2
|
-
import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult,
|
|
2
|
+
import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Configuration for Content API providers
|
|
5
5
|
*/
|
|
@@ -13,7 +13,7 @@ interface ContentAPIConfig {
|
|
|
13
13
|
declare class ConfluenceADFFetchProvider implements ADFFetchProvider {
|
|
14
14
|
private config;
|
|
15
15
|
constructor(config: ContentAPIConfig);
|
|
16
|
-
fetchData(resourceId: string): Promise<
|
|
16
|
+
fetchData(resourceId: string): Promise<SyncBlockInstance>;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* 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
|
|
3
|
+
import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance } from '../providers/types';
|
|
4
4
|
export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
5
5
|
name: string;
|
|
6
6
|
private fetchProvider;
|
|
@@ -9,7 +9,7 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
9
9
|
constructor(fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string);
|
|
10
10
|
isNodeSupported(node: JSONNode): node is SyncBlockNode;
|
|
11
11
|
nodeDataKey(node: SyncBlockNode): string;
|
|
12
|
-
fetchNodesData(nodes: SyncBlockNode[]): Promise<
|
|
12
|
+
fetchNodesData(nodes: SyncBlockNode[]): Promise<SyncBlockInstance[]>;
|
|
13
13
|
/**
|
|
14
14
|
*
|
|
15
15
|
* @param nodes
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { NodeDataProvider } from '@atlaskit/node-data-provider';
|
|
2
2
|
import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode } from '../common/types';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* The instance of a sync block, containing its data and metadata.
|
|
5
|
+
* Mainly used for representing the state of a sync block after fetching from a data provider.
|
|
6
|
+
* This will be used in both data processing and rendering contexts.
|
|
7
|
+
*/
|
|
8
|
+
export type SyncBlockInstance = {
|
|
4
9
|
data?: SyncBlockData;
|
|
5
10
|
error?: SyncBlockError;
|
|
6
|
-
resourceId
|
|
11
|
+
resourceId: string;
|
|
7
12
|
};
|
|
8
13
|
export type DeleteSyncBlockResult = {
|
|
9
14
|
error?: string;
|
|
@@ -11,16 +16,16 @@ export type DeleteSyncBlockResult = {
|
|
|
11
16
|
success: boolean;
|
|
12
17
|
};
|
|
13
18
|
export interface ADFFetchProvider {
|
|
14
|
-
fetchData: (resourceId: ResourceId) => Promise<
|
|
19
|
+
fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
|
|
15
20
|
}
|
|
16
21
|
export interface ADFWriteProvider {
|
|
17
22
|
deleteData: (resourceId: string) => Promise<DeleteSyncBlockResult>;
|
|
18
23
|
writeData: (data: SyncBlockData) => Promise<string>;
|
|
19
24
|
}
|
|
20
|
-
export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode,
|
|
25
|
+
export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode, SyncBlockInstance> {
|
|
21
26
|
abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<ResourceId | undefined>>;
|
|
22
27
|
abstract deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
23
28
|
abstract getSourceId(): ResourceId;
|
|
24
29
|
abstract retrieveSyncBlockSourceUrl(node: SyncBlockNode): Promise<string | undefined>;
|
|
25
30
|
}
|
|
26
|
-
export type SubscriptionCallback = (data:
|
|
31
|
+
export type SubscriptionCallback = (data: SyncBlockInstance) => void;
|
|
@@ -1,30 +1,20 @@
|
|
|
1
1
|
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
2
|
import type { ResourceId, SyncBlockNode } from '../common/types';
|
|
4
|
-
import type {
|
|
3
|
+
import type { SyncBlockInstance, SubscriptionCallback, SyncBlockDataProvider } from '../providers/types';
|
|
5
4
|
export declare class ReferenceSyncBlockStoreManager {
|
|
6
5
|
private dataProvider?;
|
|
7
6
|
private syncBlockCache;
|
|
8
7
|
private subscriptions;
|
|
9
8
|
private syncBlockURLRequests;
|
|
10
|
-
private editorView?;
|
|
11
|
-
private isInitialized;
|
|
12
9
|
private isRefreshingSubscriptions;
|
|
13
10
|
constructor(dataProvider?: SyncBlockDataProvider);
|
|
14
|
-
init(editorView: EditorView): Promise<void>;
|
|
15
11
|
/**
|
|
16
12
|
* Refreshes the subscriptions for all sync blocks.
|
|
17
13
|
* @returns {Promise<void>}
|
|
18
14
|
*/
|
|
19
15
|
refreshSubscriptions(): Promise<void>;
|
|
20
16
|
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
|
-
*/
|
|
26
|
-
fetchSyncBlockData(syncBlockNode: PMNode): Promise<FetchSyncBlockDataResult>;
|
|
27
|
-
fetchSyncBlocksData(syncBlockNodes: SyncBlockNode[]): Promise<FetchSyncBlockDataResult[]>;
|
|
17
|
+
fetchSyncBlocksData(syncBlockNodes: SyncBlockNode[]): Promise<SyncBlockInstance[]>;
|
|
28
18
|
private updateCache;
|
|
29
19
|
private getFromCache;
|
|
30
20
|
private deleteFromCache;
|
|
@@ -2,18 +2,18 @@ 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 {
|
|
5
|
+
import type { SubscriptionCallback, SyncBlockDataProvider, SyncBlockInstance } 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
11
|
/**
|
|
12
|
-
* Fetch sync block data for a given sync block
|
|
13
|
-
* @param
|
|
14
|
-
* @returns The fetched sync block data
|
|
12
|
+
* Fetch sync block data for a given array of sync block nodes.
|
|
13
|
+
* @param nodes - The array of sync block nodes to fetch data for
|
|
14
|
+
* @returns The fetched sync block data results
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
fetchSyncBlocksData(nodes: PMNode[]): Promise<SyncBlockInstance[]>;
|
|
17
17
|
/**
|
|
18
18
|
* Add/update a sync block node to/from the local cache
|
|
19
19
|
* @param syncBlockNode - The sync block node to update
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SyncBlockInstance } from '../providers/types';
|
|
2
|
+
/**
|
|
3
|
+
* Merges two SyncBlockInstance 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 SyncBlockInstance object.
|
|
9
|
+
* @param newResult - The new SyncBlockInstance object to merge.
|
|
10
|
+
* @returns A merged SyncBlockInstance object.
|
|
11
|
+
*/
|
|
12
|
+
export declare const resolveSyncBlockInstance: (oldResult: SyncBlockInstance, newResult: SyncBlockInstance) => SyncBlockInstance;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SyncBlockInstance } from '../providers/types';
|
|
3
3
|
import type { SyncBlockStoreManager } from '../store-manager/syncBlockStoreManager';
|
|
4
4
|
export declare const SYNC_BLOCK_FETCH_INTERVAL = 3000;
|
|
5
|
-
export declare const useFetchSyncBlockData: (manager: SyncBlockStoreManager, syncBlockNode: PMNode) =>
|
|
5
|
+
export declare const useFetchSyncBlockData: (manager: SyncBlockStoreManager, syncBlockNode: PMNode) => SyncBlockInstance | null;
|
|
@@ -3,10 +3,11 @@ export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
|
|
|
3
3
|
export { useFetchSyncBlockData } from './hooks/useFetchSyncBlockData';
|
|
4
4
|
export { useHandleContentChanges } from './hooks/useHandleContentChanges';
|
|
5
5
|
export type { SyncBlockData, SyncBlockNode } from './common/types';
|
|
6
|
-
export type { SyncBlockDataProvider, ADFFetchProvider, ADFWriteProvider,
|
|
6
|
+
export type { SyncBlockDataProvider, ADFFetchProvider, ADFWriteProvider, SyncBlockInstance, } from './providers/types';
|
|
7
7
|
export { SyncBlockError } from './common/types';
|
|
8
8
|
export { getDefaultSyncBlockSchema } from './common/schema';
|
|
9
9
|
export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluence/confluenceContentAPI';
|
|
10
10
|
export { getConfluencePageAri } from './utils/ari';
|
|
11
11
|
export { convertSyncBlockPMNodeToSyncBlockData } from './utils/utils';
|
|
12
12
|
export { rebaseTransaction } from './common/rebase-transaction';
|
|
13
|
+
export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type SyncBlockData } from '../../common/types';
|
|
2
|
-
import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult,
|
|
2
|
+
import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Configuration for Content API providers
|
|
5
5
|
*/
|
|
@@ -13,7 +13,7 @@ interface ContentAPIConfig {
|
|
|
13
13
|
declare class ConfluenceADFFetchProvider implements ADFFetchProvider {
|
|
14
14
|
private config;
|
|
15
15
|
constructor(config: ContentAPIConfig);
|
|
16
|
-
fetchData(resourceId: string): Promise<
|
|
16
|
+
fetchData(resourceId: string): Promise<SyncBlockInstance>;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* 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
|
|
3
|
+
import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance } from '../providers/types';
|
|
4
4
|
export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
5
5
|
name: string;
|
|
6
6
|
private fetchProvider;
|
|
@@ -9,7 +9,7 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
9
9
|
constructor(fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string);
|
|
10
10
|
isNodeSupported(node: JSONNode): node is SyncBlockNode;
|
|
11
11
|
nodeDataKey(node: SyncBlockNode): string;
|
|
12
|
-
fetchNodesData(nodes: SyncBlockNode[]): Promise<
|
|
12
|
+
fetchNodesData(nodes: SyncBlockNode[]): Promise<SyncBlockInstance[]>;
|
|
13
13
|
/**
|
|
14
14
|
*
|
|
15
15
|
* @param nodes
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { NodeDataProvider } from '@atlaskit/node-data-provider';
|
|
2
2
|
import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode } from '../common/types';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* The instance of a sync block, containing its data and metadata.
|
|
5
|
+
* Mainly used for representing the state of a sync block after fetching from a data provider.
|
|
6
|
+
* This will be used in both data processing and rendering contexts.
|
|
7
|
+
*/
|
|
8
|
+
export type SyncBlockInstance = {
|
|
4
9
|
data?: SyncBlockData;
|
|
5
10
|
error?: SyncBlockError;
|
|
6
|
-
resourceId
|
|
11
|
+
resourceId: string;
|
|
7
12
|
};
|
|
8
13
|
export type DeleteSyncBlockResult = {
|
|
9
14
|
error?: string;
|
|
@@ -11,16 +16,16 @@ export type DeleteSyncBlockResult = {
|
|
|
11
16
|
success: boolean;
|
|
12
17
|
};
|
|
13
18
|
export interface ADFFetchProvider {
|
|
14
|
-
fetchData: (resourceId: ResourceId) => Promise<
|
|
19
|
+
fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
|
|
15
20
|
}
|
|
16
21
|
export interface ADFWriteProvider {
|
|
17
22
|
deleteData: (resourceId: string) => Promise<DeleteSyncBlockResult>;
|
|
18
23
|
writeData: (data: SyncBlockData) => Promise<string>;
|
|
19
24
|
}
|
|
20
|
-
export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode,
|
|
25
|
+
export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode, SyncBlockInstance> {
|
|
21
26
|
abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<ResourceId | undefined>>;
|
|
22
27
|
abstract deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
23
28
|
abstract getSourceId(): ResourceId;
|
|
24
29
|
abstract retrieveSyncBlockSourceUrl(node: SyncBlockNode): Promise<string | undefined>;
|
|
25
30
|
}
|
|
26
|
-
export type SubscriptionCallback = (data:
|
|
31
|
+
export type SubscriptionCallback = (data: SyncBlockInstance) => void;
|
|
@@ -1,30 +1,20 @@
|
|
|
1
1
|
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
2
|
import type { ResourceId, SyncBlockNode } from '../common/types';
|
|
4
|
-
import type {
|
|
3
|
+
import type { SyncBlockInstance, SubscriptionCallback, SyncBlockDataProvider } from '../providers/types';
|
|
5
4
|
export declare class ReferenceSyncBlockStoreManager {
|
|
6
5
|
private dataProvider?;
|
|
7
6
|
private syncBlockCache;
|
|
8
7
|
private subscriptions;
|
|
9
8
|
private syncBlockURLRequests;
|
|
10
|
-
private editorView?;
|
|
11
|
-
private isInitialized;
|
|
12
9
|
private isRefreshingSubscriptions;
|
|
13
10
|
constructor(dataProvider?: SyncBlockDataProvider);
|
|
14
|
-
init(editorView: EditorView): Promise<void>;
|
|
15
11
|
/**
|
|
16
12
|
* Refreshes the subscriptions for all sync blocks.
|
|
17
13
|
* @returns {Promise<void>}
|
|
18
14
|
*/
|
|
19
15
|
refreshSubscriptions(): Promise<void>;
|
|
20
16
|
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
|
-
*/
|
|
26
|
-
fetchSyncBlockData(syncBlockNode: PMNode): Promise<FetchSyncBlockDataResult>;
|
|
27
|
-
fetchSyncBlocksData(syncBlockNodes: SyncBlockNode[]): Promise<FetchSyncBlockDataResult[]>;
|
|
17
|
+
fetchSyncBlocksData(syncBlockNodes: SyncBlockNode[]): Promise<SyncBlockInstance[]>;
|
|
28
18
|
private updateCache;
|
|
29
19
|
private getFromCache;
|
|
30
20
|
private deleteFromCache;
|
|
@@ -2,18 +2,18 @@ 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 {
|
|
5
|
+
import type { SubscriptionCallback, SyncBlockDataProvider, SyncBlockInstance } 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
11
|
/**
|
|
12
|
-
* Fetch sync block data for a given sync block
|
|
13
|
-
* @param
|
|
14
|
-
* @returns The fetched sync block data
|
|
12
|
+
* Fetch sync block data for a given array of sync block nodes.
|
|
13
|
+
* @param nodes - The array of sync block nodes to fetch data for
|
|
14
|
+
* @returns The fetched sync block data results
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
fetchSyncBlocksData(nodes: PMNode[]): Promise<SyncBlockInstance[]>;
|
|
17
17
|
/**
|
|
18
18
|
* Add/update a sync block node to/from the local cache
|
|
19
19
|
* @param syncBlockNode - The sync block node to update
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SyncBlockInstance } from '../providers/types';
|
|
2
|
+
/**
|
|
3
|
+
* Merges two SyncBlockInstance 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 SyncBlockInstance object.
|
|
9
|
+
* @param newResult - The new SyncBlockInstance object to merge.
|
|
10
|
+
* @returns A merged SyncBlockInstance object.
|
|
11
|
+
*/
|
|
12
|
+
export declare const resolveSyncBlockInstance: (oldResult: SyncBlockInstance, newResult: SyncBlockInstance) => SyncBlockInstance;
|
package/package.json
CHANGED
|
@@ -29,9 +29,9 @@
|
|
|
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.
|
|
32
|
+
"@atlaskit/node-data-provider": "^7.4.0",
|
|
33
33
|
"@atlaskit/primitives": "^16.1.0",
|
|
34
|
-
"@atlaskit/tokens": "^7.
|
|
34
|
+
"@atlaskit/tokens": "^7.1.0",
|
|
35
35
|
"@babel/runtime": "^7.0.0",
|
|
36
36
|
"@compiled/react": "^0.18.6",
|
|
37
37
|
"uuid": "^3.1.0"
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
}
|
|
83
83
|
},
|
|
84
84
|
"name": "@atlaskit/editor-synced-block-provider",
|
|
85
|
-
"version": "2.
|
|
85
|
+
"version": "2.5.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,12 +0,0 @@
|
|
|
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;
|
|
@@ -1,12 +0,0 @@
|
|
|
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;
|