@atlaskit/editor-synced-block-provider 2.10.2 → 2.10.4
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 +17 -0
- package/dist/cjs/{providers → clients}/block-service/ari.js +2 -2
- package/dist/cjs/{utils → clients/confluence}/ari.js +5 -5
- package/dist/cjs/{utils → clients/confluence}/contentProperty.js +2 -6
- package/dist/cjs/{utils → clients/confluence}/sourceInfo.js +7 -7
- package/dist/cjs/clients/confluence/utils.js +9 -0
- package/dist/cjs/hooks/useFetchSyncBlockData.js +5 -6
- package/dist/cjs/hooks/useFetchSyncBlockTitle.js +1 -1
- package/dist/cjs/hooks/useHandleContentChanges.js +1 -1
- package/dist/cjs/index.js +27 -14
- package/dist/cjs/providers/block-service/blockServiceAPI.js +4 -4
- package/dist/cjs/providers/confluence/confluenceContentAPI.js +28 -18
- package/dist/cjs/providers/syncBlockProvider.js +14 -9
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +35 -9
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +52 -10
- package/dist/cjs/store-manager/syncBlockStoreManager.js +14 -158
- package/dist/cjs/utils/utils.js +8 -4
- package/dist/es2019/{providers → clients}/block-service/ari.js +1 -1
- package/dist/es2019/{utils → clients/confluence}/ari.js +4 -4
- package/dist/es2019/{utils → clients/confluence}/contentProperty.js +2 -6
- package/dist/es2019/{utils → clients/confluence}/sourceInfo.js +5 -5
- package/dist/es2019/clients/confluence/utils.js +3 -0
- package/dist/es2019/hooks/useFetchSyncBlockData.js +5 -6
- package/dist/es2019/hooks/useFetchSyncBlockTitle.js +1 -1
- package/dist/es2019/hooks/useHandleContentChanges.js +1 -1
- package/dist/es2019/index.js +14 -4
- package/dist/es2019/providers/block-service/blockServiceAPI.js +4 -4
- package/dist/es2019/providers/confluence/confluenceContentAPI.js +28 -18
- package/dist/es2019/providers/syncBlockProvider.js +14 -9
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +24 -0
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +39 -1
- package/dist/es2019/store-manager/syncBlockStoreManager.js +12 -119
- package/dist/es2019/utils/utils.js +3 -3
- package/dist/esm/{providers → clients}/block-service/ari.js +1 -1
- package/dist/esm/{utils → clients/confluence}/ari.js +4 -4
- package/dist/esm/{utils → clients/confluence}/contentProperty.js +2 -6
- package/dist/esm/{utils → clients/confluence}/sourceInfo.js +7 -7
- package/dist/esm/clients/confluence/utils.js +3 -0
- package/dist/esm/hooks/useFetchSyncBlockData.js +5 -6
- package/dist/esm/hooks/useFetchSyncBlockTitle.js +1 -1
- package/dist/esm/hooks/useHandleContentChanges.js +1 -1
- package/dist/esm/index.js +14 -4
- package/dist/esm/providers/block-service/blockServiceAPI.js +4 -4
- package/dist/esm/providers/confluence/confluenceContentAPI.js +28 -18
- package/dist/esm/providers/syncBlockProvider.js +14 -9
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +36 -9
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +52 -10
- package/dist/esm/store-manager/syncBlockStoreManager.js +14 -159
- package/dist/esm/utils/utils.js +7 -3
- package/dist/types/{providers → clients}/block-service/ari.d.ts +1 -1
- package/dist/types/{utils → clients/block-service}/blockService.d.ts +1 -1
- package/dist/types/clients/confluence/ari.d.ts +9 -0
- package/dist/types/{utils → clients/confluence}/contentProperty.d.ts +1 -1
- package/dist/types/clients/confluence/sourceInfo.d.ts +2 -0
- package/dist/types/clients/confluence/utils.d.ts +2 -0
- package/dist/types/index.d.ts +4 -3
- package/dist/types/providers/confluence/confluenceContentAPI.d.ts +1 -1
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +5 -0
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +17 -1
- package/dist/types/store-manager/syncBlockStoreManager.d.ts +4 -59
- package/dist/types/utils/utils.d.ts +1 -2
- package/dist/types-ts4.5/{providers → clients}/block-service/ari.d.ts +1 -1
- package/dist/types-ts4.5/{utils → clients/block-service}/blockService.d.ts +1 -1
- package/dist/types-ts4.5/clients/confluence/ari.d.ts +9 -0
- package/dist/types-ts4.5/{utils → clients/confluence}/contentProperty.d.ts +1 -1
- package/dist/types-ts4.5/clients/confluence/sourceInfo.d.ts +2 -0
- package/dist/types-ts4.5/clients/confluence/utils.d.ts +2 -0
- package/dist/types-ts4.5/index.d.ts +4 -3
- package/dist/types-ts4.5/providers/confluence/confluenceContentAPI.d.ts +1 -1
- package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +5 -0
- package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +17 -1
- package/dist/types-ts4.5/store-manager/syncBlockStoreManager.d.ts +4 -59
- package/dist/types-ts4.5/utils/utils.d.ts +1 -2
- package/package.json +3 -3
- package/dist/types/utils/ari.d.ts +0 -9
- package/dist/types/utils/sourceInfo.d.ts +0 -2
- package/dist/types-ts4.5/utils/ari.d.ts +0 -9
- package/dist/types-ts4.5/utils/sourceInfo.d.ts +0 -2
- /package/dist/cjs/{utils → clients/block-service}/blockService.js +0 -0
- /package/dist/es2019/{utils → clients/block-service}/blockService.js +0 -0
- /package/dist/esm/{utils → clients/block-service}/blockService.js +0 -0
|
@@ -1,181 +1,36 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
// eslint-disable-next-line no-restricted-imports
|
|
4
|
-
|
|
5
|
-
import { convertPMNodeToSyncBlockNode } from '../utils/utils';
|
|
6
3
|
import { ReferenceSyncBlockStoreManager } from './referenceSyncBlockStoreManager';
|
|
7
4
|
import { SourceSyncBlockStoreManager } from './sourceSyncBlockStoreManager';
|
|
8
5
|
|
|
9
|
-
// A store manager responsible for the lifecycle and state management of sync blocks in an editor instance.
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
6
|
+
// A parent store manager responsible for the lifecycle and state management of sync blocks in an editor instance.
|
|
7
|
+
// Contains two child store managers: ReferenceSyncBlockStoreManager and SourceSyncBlockStoreManager.
|
|
8
|
+
// ReferenceSyncBlockStoreManager is responsible for the lifecycle and state management of reference sync blocks in an editor instance.
|
|
9
|
+
// SourceSyncBlockStoreManager is responsible for the lifecycle and state management of source sync blocks in an editor instance.
|
|
10
|
+
// Can be used in both editor and renderer contexts.
|
|
14
11
|
export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
15
12
|
function SyncBlockStoreManager(dataProvider) {
|
|
16
13
|
_classCallCheck(this, SyncBlockStoreManager);
|
|
17
|
-
|
|
14
|
+
// In future, if reference manager needs to reach to source manager and read it's current in memorey cache
|
|
15
|
+
// we can pass the source manager as a parameter to the reference manager constructor
|
|
18
16
|
this.sourceSyncBlockStoreManager = new SourceSyncBlockStoreManager(dataProvider);
|
|
17
|
+
this.referenceSyncBlockStoreManager = new ReferenceSyncBlockStoreManager(dataProvider);
|
|
19
18
|
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Fetch sync block data for a given array of sync block nodes.
|
|
23
|
-
* @param nodes - The array of sync block nodes to fetch data for
|
|
24
|
-
* @returns The fetched sync block data results
|
|
25
|
-
*/
|
|
26
19
|
return _createClass(SyncBlockStoreManager, [{
|
|
27
|
-
key: "
|
|
28
|
-
|
|
29
|
-
var syncBlockNodes = nodes.map(function (node) {
|
|
30
|
-
return convertPMNodeToSyncBlockNode(node);
|
|
31
|
-
}).filter(function (node) {
|
|
32
|
-
return node !== undefined;
|
|
33
|
-
}) || [];
|
|
34
|
-
if (syncBlockNodes.length === 0) {
|
|
35
|
-
return Promise.resolve([]);
|
|
36
|
-
}
|
|
37
|
-
return this.referenceSyncBlockStoreManager.fetchSyncBlocksData(syncBlockNodes);
|
|
38
|
-
}
|
|
39
|
-
}, {
|
|
40
|
-
key: "getReferenceSyncBlockStoreManager",
|
|
41
|
-
value: function getReferenceSyncBlockStoreManager() {
|
|
20
|
+
key: "referenceManager",
|
|
21
|
+
get: function get() {
|
|
42
22
|
return this.referenceSyncBlockStoreManager;
|
|
43
23
|
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Add/update a sync block node to/from the local cache
|
|
47
|
-
* @param syncBlockNode - The sync block node to update
|
|
48
|
-
*/
|
|
49
|
-
}, {
|
|
50
|
-
key: "updateSyncBlockData",
|
|
51
|
-
value: function updateSyncBlockData(syncBlockNode) {
|
|
52
|
-
if (this.isSourceBlock(syncBlockNode)) {
|
|
53
|
-
return this.sourceSyncBlockStoreManager.updateSyncBlockData(syncBlockNode);
|
|
54
|
-
} else {
|
|
55
|
-
throw new Error('Invalid sync block node type provided for updateSyncBlockData');
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Save content of bodiedSyncBlock nodes in local cache to backend
|
|
61
|
-
*
|
|
62
|
-
* @returns true if saving all nodes successfully, false if fail to save some/all nodes
|
|
63
|
-
*/
|
|
64
|
-
}, {
|
|
65
|
-
key: "flushBodiedSyncBlocks",
|
|
66
|
-
value: function flushBodiedSyncBlocks() {
|
|
67
|
-
// only applicable to source sync block, for now (will be refactored further)
|
|
68
|
-
return this.sourceSyncBlockStoreManager.flushBodiedSyncBlocks();
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Get the URL for a sync block.
|
|
73
|
-
* @param resourceId - The resource ID of the sync block to get the URL for
|
|
74
|
-
* @returns
|
|
75
|
-
*/
|
|
76
|
-
}, {
|
|
77
|
-
key: "getSyncBlockURL",
|
|
78
|
-
value: function getSyncBlockURL(resourceId) {
|
|
79
|
-
// only applicable to reference sync block, for now (will be refactored further)
|
|
80
|
-
return this.referenceSyncBlockStoreManager.getSyncBlockURL(resourceId);
|
|
81
|
-
}
|
|
82
|
-
}, {
|
|
83
|
-
key: "setEditorView",
|
|
84
|
-
value: function setEditorView(editorView) {
|
|
85
|
-
this.sourceSyncBlockStoreManager.setEditorView(editorView);
|
|
86
|
-
}
|
|
87
|
-
}, {
|
|
88
|
-
key: "isSourceBlock",
|
|
89
|
-
value: function isSourceBlock(node) {
|
|
90
|
-
return node.type.name === 'bodiedSyncBlock';
|
|
91
|
-
}
|
|
92
|
-
}, {
|
|
93
|
-
key: "registerConfirmationCallback",
|
|
94
|
-
value: function registerConfirmationCallback(callback) {
|
|
95
|
-
// only applicable to source sync block, for now (will be refactored further)
|
|
96
|
-
return this.sourceSyncBlockStoreManager.registerConfirmationCallback(callback);
|
|
97
|
-
}
|
|
98
|
-
}, {
|
|
99
|
-
key: "requireConfirmationBeforeDelete",
|
|
100
|
-
value: function requireConfirmationBeforeDelete() {
|
|
101
|
-
// only applicable to source sync block, for now (will be refactored further)
|
|
102
|
-
return this.sourceSyncBlockStoreManager.requireConfirmationBeforeDelete();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Register callback function (which inserts node, handles focus etc) to be used later when creation to backend succeed
|
|
107
|
-
*/
|
|
108
|
-
}, {
|
|
109
|
-
key: "registerCreationCallback",
|
|
110
|
-
value: function registerCreationCallback(callback) {
|
|
111
|
-
this.sourceSyncBlockStoreManager.registerCreationCallback(callback);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
*
|
|
116
|
-
* @returns true if waiting for the result of saving new bodiedSyncBlock to backend
|
|
117
|
-
*/
|
|
118
|
-
}, {
|
|
119
|
-
key: "hasPendingCreation",
|
|
120
|
-
value: function hasPendingCreation() {
|
|
121
|
-
return this.sourceSyncBlockStoreManager.hasPendingCreation();
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* @returns attributes for a new bodiedSyncBlock node
|
|
126
|
-
*/
|
|
127
|
-
}, {
|
|
128
|
-
key: "generateBodiedSyncBlockAttrs",
|
|
129
|
-
value: function generateBodiedSyncBlockAttrs() {
|
|
130
|
-
return this.sourceSyncBlockStoreManager.generateBodiedSyncBlockAttrs();
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Save bodiedSyncBlock with empty content to backend
|
|
135
|
-
* @param attrs attributes Ids of the node
|
|
136
|
-
*/
|
|
137
|
-
}, {
|
|
138
|
-
key: "createBodiedSyncBlockNode",
|
|
139
|
-
value: function createBodiedSyncBlockNode(attrs) {
|
|
140
|
-
// only applicable to source sync block, for now (will be refactored further)
|
|
141
|
-
return this.sourceSyncBlockStoreManager.createBodiedSyncBlockNode(attrs);
|
|
142
|
-
}
|
|
143
|
-
}, {
|
|
144
|
-
key: "subscribeToSyncBlockData",
|
|
145
|
-
value: function subscribeToSyncBlockData(node, callback) {
|
|
146
|
-
return this.referenceSyncBlockStoreManager.subscribe(node, callback);
|
|
147
|
-
}
|
|
148
|
-
}, {
|
|
149
|
-
key: "subscribeToSyncBlockSourceTitle",
|
|
150
|
-
value: function subscribeToSyncBlockSourceTitle(node, callback) {
|
|
151
|
-
return this.referenceSyncBlockStoreManager.subscribeToSourceTitle(node, callback);
|
|
152
|
-
}
|
|
153
|
-
}, {
|
|
154
|
-
key: "refreshSubscriptions",
|
|
155
|
-
value: function refreshSubscriptions() {
|
|
156
|
-
this.referenceSyncBlockStoreManager.refreshSubscriptions();
|
|
157
|
-
}
|
|
158
|
-
}, {
|
|
159
|
-
key: "deleteSyncBlocksWithConfirmation",
|
|
160
|
-
value: function deleteSyncBlocksWithConfirmation(tr, syncBlockIds) {
|
|
161
|
-
// only applicable to source sync block, for now (will be refactored further)
|
|
162
|
-
return this.sourceSyncBlockStoreManager.deleteSyncBlocksWithConfirmation(tr, syncBlockIds);
|
|
163
|
-
}
|
|
164
|
-
}, {
|
|
165
|
-
key: "rebaseTransaction",
|
|
166
|
-
value: function rebaseTransaction(incomingTr, state) {
|
|
167
|
-
// only applicable to source sync block, for now (will be refactored further)
|
|
168
|
-
this.sourceSyncBlockStoreManager.rebaseTransaction(incomingTr, state);
|
|
169
|
-
}
|
|
170
24
|
}, {
|
|
171
|
-
key: "
|
|
172
|
-
|
|
173
|
-
return this.
|
|
25
|
+
key: "sourceManager",
|
|
26
|
+
get: function get() {
|
|
27
|
+
return this.sourceSyncBlockStoreManager;
|
|
174
28
|
}
|
|
175
29
|
}, {
|
|
176
30
|
key: "destroy",
|
|
177
31
|
value: function destroy() {
|
|
178
32
|
this.referenceSyncBlockStoreManager.destroy();
|
|
33
|
+
this.sourceSyncBlockStoreManager.destroy();
|
|
179
34
|
}
|
|
180
35
|
}]);
|
|
181
36
|
}();
|
package/dist/esm/utils/utils.js
CHANGED
|
@@ -5,9 +5,6 @@ export var convertSyncBlockPMNodeToSyncBlockData = function convertSyncBlockPMNo
|
|
|
5
5
|
resourceId: node.attrs.resourceId
|
|
6
6
|
};
|
|
7
7
|
};
|
|
8
|
-
export var isBlogPageType = function isBlogPageType(pageType) {
|
|
9
|
-
return pageType === 'blogpost';
|
|
10
|
-
};
|
|
11
8
|
export var createSyncBlockNode = function createSyncBlockNode(localId, resourceId) {
|
|
12
9
|
return {
|
|
13
10
|
type: 'syncBlock',
|
|
@@ -38,4 +35,11 @@ export var convertPMNodeToSyncBlockNode = function convertPMNodeToSyncBlockNode(
|
|
|
38
35
|
return undefined;
|
|
39
36
|
}
|
|
40
37
|
return createSyncBlockNode(node.attrs.localId, node.attrs.resourceId);
|
|
38
|
+
};
|
|
39
|
+
export var convertPMNodesToSyncBlockNodes = function convertPMNodesToSyncBlockNodes(nodes) {
|
|
40
|
+
return nodes.map(function (node) {
|
|
41
|
+
return convertPMNodeToSyncBlockNode(node);
|
|
42
|
+
}).filter(function (node) {
|
|
43
|
+
return node !== undefined;
|
|
44
|
+
}) || [];
|
|
41
45
|
};
|
|
@@ -10,4 +10,4 @@ export declare const blockResourceIdFromSourceAndLocalId: (sourceId: string, loc
|
|
|
10
10
|
* @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
|
|
11
11
|
* @returns the localId of the block node. A randomly generated UUID
|
|
12
12
|
*/
|
|
13
|
-
export declare const
|
|
13
|
+
export declare const getLocalIdFromBlockResourceId: (ari: string) => string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type PAGE_TYPE = 'page' | 'blogpost';
|
|
2
|
+
export declare const getConfluencePageAri: (pageId: string, cloudId: string, pageType?: PAGE_TYPE) => string;
|
|
3
|
+
export declare const getPageIdAndTypeFromConfluencePageAri: (ari: string) => {
|
|
4
|
+
id: string;
|
|
5
|
+
type: PAGE_TYPE;
|
|
6
|
+
};
|
|
7
|
+
export declare const getLocalIdFromConfluencePageAri: (ari: string) => string;
|
|
8
|
+
export declare const getPageARIFromContentPropertyResourceId: (resourceId: string) => string;
|
|
9
|
+
export declare const resourceIdFromConfluencePageSourceIdAndLocalId: (sourceId: string, localId: string) => string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,13 +4,14 @@ export type { SyncBlockData, SyncBlockNode } from './common/types';
|
|
|
4
4
|
export { useFetchSyncBlockData, type UseFetchSyncBlockDataResult, } from './hooks/useFetchSyncBlockData';
|
|
5
5
|
export { useFetchSyncBlockTitle } from './hooks/useFetchSyncBlockTitle';
|
|
6
6
|
export { useHandleContentChanges } from './hooks/useHandleContentChanges';
|
|
7
|
-
export { blockResourceIdFromSourceAndLocalId,
|
|
7
|
+
export { blockResourceIdFromSourceAndLocalId, getLocalIdFromBlockResourceId, } from './clients/block-service/ari';
|
|
8
|
+
export { getConfluencePageAri, getLocalIdFromConfluencePageAri, getPageARIFromContentPropertyResourceId, getPageIdAndTypeFromConfluencePageAri, resourceIdFromConfluencePageSourceIdAndLocalId, } from './clients/confluence/ari';
|
|
8
9
|
export { useMemoizedBlockServiceAPIProviders } from './providers/block-service/blockServiceAPI';
|
|
9
10
|
export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluence/confluenceContentAPI';
|
|
11
|
+
export { fetchConfluenceSourceInfo } from './clients/confluence/sourceInfo';
|
|
10
12
|
export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
|
|
11
13
|
export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, } from './providers/types';
|
|
12
14
|
export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
|
|
13
15
|
export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
|
|
14
|
-
export { getConfluencePageAri, getLocalIdFromAri, getPageARIFromResourceId, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId, } from './utils/ari';
|
|
15
|
-
export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, } from './utils/utils';
|
|
16
16
|
export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
|
|
17
|
+
export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, convertPMNodesToSyncBlockNodes, } from './utils/utils';
|
|
@@ -23,7 +23,7 @@ declare class ConfluenceADFWriteProvider implements ADFWriteProvider {
|
|
|
23
23
|
private config;
|
|
24
24
|
constructor(config: ContentAPIConfig);
|
|
25
25
|
private createNewContentProperty;
|
|
26
|
-
writeData(
|
|
26
|
+
writeData(syncBlockData: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
27
27
|
deleteData(resourceId: string): Promise<DeleteSyncBlockResult>;
|
|
28
28
|
generateResourceId(sourceId: string, localId: string): string;
|
|
29
29
|
}
|
|
@@ -17,6 +17,11 @@ export declare class ReferenceSyncBlockStoreManager {
|
|
|
17
17
|
*/
|
|
18
18
|
refreshSubscriptions(): Promise<void>;
|
|
19
19
|
private retrieveSyncBlockSourceInfo;
|
|
20
|
+
/**
|
|
21
|
+
* Fetch sync block data for a given array of sync block nodes.
|
|
22
|
+
* @param syncBlockNodes - The array of sync block nodes to fetch data for
|
|
23
|
+
* @returns The fetched sync block data results
|
|
24
|
+
*/
|
|
20
25
|
fetchSyncBlocksData(syncBlockNodes: SyncBlockNode[]): Promise<SyncBlockInstance[]>;
|
|
21
26
|
private updateCache;
|
|
22
27
|
private updateSourceTitleSubscriptions;
|
|
@@ -14,6 +14,7 @@ export declare class SourceSyncBlockStoreManager {
|
|
|
14
14
|
private pendingResourceId?;
|
|
15
15
|
private creationCallback?;
|
|
16
16
|
constructor(dataProvider?: SyncBlockDataProvider);
|
|
17
|
+
isSourceBlock(node: PMNode): boolean;
|
|
17
18
|
/**
|
|
18
19
|
* Add/update a sync block node to/from the local cache
|
|
19
20
|
* @param syncBlockNode - The sync block node to update
|
|
@@ -24,21 +25,36 @@ export declare class SourceSyncBlockStoreManager {
|
|
|
24
25
|
*
|
|
25
26
|
* @returns true if saving all nodes successfully, false if fail to save some/all nodes
|
|
26
27
|
*/
|
|
27
|
-
|
|
28
|
+
flush(): Promise<boolean>;
|
|
28
29
|
setEditorView(editorView: EditorView | undefined): void;
|
|
29
30
|
registerPendingCreation(resourceId: ResourceId): void;
|
|
31
|
+
/**
|
|
32
|
+
* Register callback function (which inserts node, handles focus etc) to be used later when creation to backend succeed
|
|
33
|
+
*/
|
|
30
34
|
registerCreationCallback(callback: CreationCallback): void;
|
|
31
35
|
/**
|
|
32
36
|
* Fires callback to insert node (if creation is successful) and clears pending creation data
|
|
33
37
|
* @param success
|
|
34
38
|
*/
|
|
35
39
|
commitPendingCreation(success: boolean): void;
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @returns true if waiting for the result of saving new bodiedSyncBlock to backend
|
|
43
|
+
*/
|
|
36
44
|
hasPendingCreation(): boolean;
|
|
37
45
|
registerConfirmationCallback(callback: ConfirmationCallback): () => void;
|
|
38
46
|
requireConfirmationBeforeDelete(): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* @returns attributes for a new bodiedSyncBlock node
|
|
49
|
+
*/
|
|
39
50
|
generateBodiedSyncBlockAttrs(): SyncBlockAttrs;
|
|
51
|
+
/**
|
|
52
|
+
* Create a bodiedSyncBlock node with empty content to backend
|
|
53
|
+
* @param attrs attributes Ids of the node
|
|
54
|
+
*/
|
|
40
55
|
createBodiedSyncBlockNode(attrs: SyncBlockAttrs): void;
|
|
41
56
|
private setPendingDeletion;
|
|
42
57
|
deleteSyncBlocksWithConfirmation(tr: Transaction, syncBlockIds: SyncBlockAttrs[]): Promise<void>;
|
|
43
58
|
rebaseTransaction(incomingTr: Transaction, state: EditorState): void;
|
|
59
|
+
destroy(): void;
|
|
44
60
|
}
|
|
@@ -1,66 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
|
|
3
|
-
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
-
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
import type { ResourceId, SyncBlockAttrs } from '../common/types';
|
|
6
|
-
import type { SubscriptionCallback, SyncBlockDataProvider, SyncBlockInstance, TitleSubscriptionCallback } from '../providers/types';
|
|
1
|
+
import type { SyncBlockDataProvider } from '../providers/types';
|
|
7
2
|
import { ReferenceSyncBlockStoreManager } from './referenceSyncBlockStoreManager';
|
|
8
|
-
import {
|
|
3
|
+
import { SourceSyncBlockStoreManager } from './sourceSyncBlockStoreManager';
|
|
9
4
|
export declare class SyncBlockStoreManager {
|
|
10
5
|
private referenceSyncBlockStoreManager;
|
|
11
6
|
private sourceSyncBlockStoreManager;
|
|
12
7
|
constructor(dataProvider?: SyncBlockDataProvider);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* @param nodes - The array of sync block nodes to fetch data for
|
|
16
|
-
* @returns The fetched sync block data results
|
|
17
|
-
*/
|
|
18
|
-
fetchSyncBlocksData(nodes: PMNode[]): Promise<SyncBlockInstance[]>;
|
|
19
|
-
getReferenceSyncBlockStoreManager(): ReferenceSyncBlockStoreManager;
|
|
20
|
-
/**
|
|
21
|
-
* Add/update a sync block node to/from the local cache
|
|
22
|
-
* @param syncBlockNode - The sync block node to update
|
|
23
|
-
*/
|
|
24
|
-
updateSyncBlockData(syncBlockNode: PMNode): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Save content of bodiedSyncBlock nodes in local cache to backend
|
|
27
|
-
*
|
|
28
|
-
* @returns true if saving all nodes successfully, false if fail to save some/all nodes
|
|
29
|
-
*/
|
|
30
|
-
flushBodiedSyncBlocks(): Promise<boolean>;
|
|
31
|
-
/**
|
|
32
|
-
* Get the URL for a sync block.
|
|
33
|
-
* @param resourceId - The resource ID of the sync block to get the URL for
|
|
34
|
-
* @returns
|
|
35
|
-
*/
|
|
36
|
-
getSyncBlockURL(resourceId: ResourceId): string | undefined;
|
|
37
|
-
setEditorView(editorView: EditorView | undefined): void;
|
|
38
|
-
isSourceBlock(node: PMNode): boolean;
|
|
39
|
-
registerConfirmationCallback(callback: ConfirmationCallback): () => void;
|
|
40
|
-
requireConfirmationBeforeDelete(): boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Register callback function (which inserts node, handles focus etc) to be used later when creation to backend succeed
|
|
43
|
-
*/
|
|
44
|
-
registerCreationCallback(callback: CreationCallback): void;
|
|
45
|
-
/**
|
|
46
|
-
*
|
|
47
|
-
* @returns true if waiting for the result of saving new bodiedSyncBlock to backend
|
|
48
|
-
*/
|
|
49
|
-
hasPendingCreation(): boolean;
|
|
50
|
-
/**
|
|
51
|
-
* @returns attributes for a new bodiedSyncBlock node
|
|
52
|
-
*/
|
|
53
|
-
generateBodiedSyncBlockAttrs(): SyncBlockAttrs;
|
|
54
|
-
/**
|
|
55
|
-
* Save bodiedSyncBlock with empty content to backend
|
|
56
|
-
* @param attrs attributes Ids of the node
|
|
57
|
-
*/
|
|
58
|
-
createBodiedSyncBlockNode(attrs: SyncBlockAttrs): void;
|
|
59
|
-
subscribeToSyncBlockData(node: PMNode, callback: SubscriptionCallback): () => void;
|
|
60
|
-
subscribeToSyncBlockSourceTitle(node: PMNode, callback: TitleSubscriptionCallback): () => void;
|
|
61
|
-
refreshSubscriptions(): void;
|
|
62
|
-
deleteSyncBlocksWithConfirmation(tr: Transaction, syncBlockIds: SyncBlockAttrs[]): Promise<void>;
|
|
63
|
-
rebaseTransaction(incomingTr: Transaction, state: EditorState): void;
|
|
64
|
-
getReferenceSyncBlockProviderFactory(resourceId: ResourceId): ProviderFactory | undefined;
|
|
8
|
+
get referenceManager(): ReferenceSyncBlockStoreManager;
|
|
9
|
+
get sourceManager(): SourceSyncBlockStoreManager;
|
|
65
10
|
destroy(): void;
|
|
66
11
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { JSONNode } from '@atlaskit/editor-json-transformer';
|
|
2
2
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import type { SyncBlockData, BlockInstanceId, ResourceId, SyncBlockNode } from '../common/types';
|
|
4
|
-
import type { PAGE_TYPE } from './ari';
|
|
5
4
|
export declare const convertSyncBlockPMNodeToSyncBlockData: (node: PMNode) => SyncBlockData;
|
|
6
|
-
export declare const isBlogPageType: (pageType: PAGE_TYPE) => boolean;
|
|
7
5
|
export declare const createSyncBlockNode: (localId: BlockInstanceId, resourceId: ResourceId) => SyncBlockNode;
|
|
8
6
|
export declare const createBodiedSyncBlockNode: (localId: BlockInstanceId, resourceId: ResourceId) => SyncBlockNode;
|
|
9
7
|
export declare const convertSyncBlockJSONNodeToSyncBlockNode: (node: JSONNode) => SyncBlockNode | undefined;
|
|
10
8
|
export declare const convertPMNodeToSyncBlockNode: (node: PMNode) => SyncBlockNode | undefined;
|
|
9
|
+
export declare const convertPMNodesToSyncBlockNodes: (nodes: PMNode[]) => SyncBlockNode[];
|
|
@@ -10,4 +10,4 @@ export declare const blockResourceIdFromSourceAndLocalId: (sourceId: string, loc
|
|
|
10
10
|
* @param ari - the block ARI. E.G ari:cloud:blocks:cloudId:synced-block/localId
|
|
11
11
|
* @returns the localId of the block node. A randomly generated UUID
|
|
12
12
|
*/
|
|
13
|
-
export declare const
|
|
13
|
+
export declare const getLocalIdFromBlockResourceId: (ari: string) => string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type PAGE_TYPE = 'page' | 'blogpost';
|
|
2
|
+
export declare const getConfluencePageAri: (pageId: string, cloudId: string, pageType?: PAGE_TYPE) => string;
|
|
3
|
+
export declare const getPageIdAndTypeFromConfluencePageAri: (ari: string) => {
|
|
4
|
+
id: string;
|
|
5
|
+
type: PAGE_TYPE;
|
|
6
|
+
};
|
|
7
|
+
export declare const getLocalIdFromConfluencePageAri: (ari: string) => string;
|
|
8
|
+
export declare const getPageARIFromContentPropertyResourceId: (resourceId: string) => string;
|
|
9
|
+
export declare const resourceIdFromConfluencePageSourceIdAndLocalId: (sourceId: string, localId: string) => string;
|
|
@@ -4,13 +4,14 @@ export type { SyncBlockData, SyncBlockNode } from './common/types';
|
|
|
4
4
|
export { useFetchSyncBlockData, type UseFetchSyncBlockDataResult, } from './hooks/useFetchSyncBlockData';
|
|
5
5
|
export { useFetchSyncBlockTitle } from './hooks/useFetchSyncBlockTitle';
|
|
6
6
|
export { useHandleContentChanges } from './hooks/useHandleContentChanges';
|
|
7
|
-
export { blockResourceIdFromSourceAndLocalId,
|
|
7
|
+
export { blockResourceIdFromSourceAndLocalId, getLocalIdFromBlockResourceId, } from './clients/block-service/ari';
|
|
8
|
+
export { getConfluencePageAri, getLocalIdFromConfluencePageAri, getPageARIFromContentPropertyResourceId, getPageIdAndTypeFromConfluencePageAri, resourceIdFromConfluencePageSourceIdAndLocalId, } from './clients/confluence/ari';
|
|
8
9
|
export { useMemoizedBlockServiceAPIProviders } from './providers/block-service/blockServiceAPI';
|
|
9
10
|
export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluence/confluenceContentAPI';
|
|
11
|
+
export { fetchConfluenceSourceInfo } from './clients/confluence/sourceInfo';
|
|
10
12
|
export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
|
|
11
13
|
export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, } from './providers/types';
|
|
12
14
|
export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
|
|
13
15
|
export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
|
|
14
|
-
export { getConfluencePageAri, getLocalIdFromAri, getPageARIFromResourceId, getPageIdAndTypeFromAri, resourceIdFromSourceAndLocalId, } from './utils/ari';
|
|
15
|
-
export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, } from './utils/utils';
|
|
16
16
|
export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
|
|
17
|
+
export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, convertPMNodesToSyncBlockNodes, } from './utils/utils';
|
|
@@ -23,7 +23,7 @@ declare class ConfluenceADFWriteProvider implements ADFWriteProvider {
|
|
|
23
23
|
private config;
|
|
24
24
|
constructor(config: ContentAPIConfig);
|
|
25
25
|
private createNewContentProperty;
|
|
26
|
-
writeData(
|
|
26
|
+
writeData(syncBlockData: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
27
27
|
deleteData(resourceId: string): Promise<DeleteSyncBlockResult>;
|
|
28
28
|
generateResourceId(sourceId: string, localId: string): string;
|
|
29
29
|
}
|
|
@@ -17,6 +17,11 @@ export declare class ReferenceSyncBlockStoreManager {
|
|
|
17
17
|
*/
|
|
18
18
|
refreshSubscriptions(): Promise<void>;
|
|
19
19
|
private retrieveSyncBlockSourceInfo;
|
|
20
|
+
/**
|
|
21
|
+
* Fetch sync block data for a given array of sync block nodes.
|
|
22
|
+
* @param syncBlockNodes - The array of sync block nodes to fetch data for
|
|
23
|
+
* @returns The fetched sync block data results
|
|
24
|
+
*/
|
|
20
25
|
fetchSyncBlocksData(syncBlockNodes: SyncBlockNode[]): Promise<SyncBlockInstance[]>;
|
|
21
26
|
private updateCache;
|
|
22
27
|
private updateSourceTitleSubscriptions;
|
|
@@ -14,6 +14,7 @@ export declare class SourceSyncBlockStoreManager {
|
|
|
14
14
|
private pendingResourceId?;
|
|
15
15
|
private creationCallback?;
|
|
16
16
|
constructor(dataProvider?: SyncBlockDataProvider);
|
|
17
|
+
isSourceBlock(node: PMNode): boolean;
|
|
17
18
|
/**
|
|
18
19
|
* Add/update a sync block node to/from the local cache
|
|
19
20
|
* @param syncBlockNode - The sync block node to update
|
|
@@ -24,21 +25,36 @@ export declare class SourceSyncBlockStoreManager {
|
|
|
24
25
|
*
|
|
25
26
|
* @returns true if saving all nodes successfully, false if fail to save some/all nodes
|
|
26
27
|
*/
|
|
27
|
-
|
|
28
|
+
flush(): Promise<boolean>;
|
|
28
29
|
setEditorView(editorView: EditorView | undefined): void;
|
|
29
30
|
registerPendingCreation(resourceId: ResourceId): void;
|
|
31
|
+
/**
|
|
32
|
+
* Register callback function (which inserts node, handles focus etc) to be used later when creation to backend succeed
|
|
33
|
+
*/
|
|
30
34
|
registerCreationCallback(callback: CreationCallback): void;
|
|
31
35
|
/**
|
|
32
36
|
* Fires callback to insert node (if creation is successful) and clears pending creation data
|
|
33
37
|
* @param success
|
|
34
38
|
*/
|
|
35
39
|
commitPendingCreation(success: boolean): void;
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @returns true if waiting for the result of saving new bodiedSyncBlock to backend
|
|
43
|
+
*/
|
|
36
44
|
hasPendingCreation(): boolean;
|
|
37
45
|
registerConfirmationCallback(callback: ConfirmationCallback): () => void;
|
|
38
46
|
requireConfirmationBeforeDelete(): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* @returns attributes for a new bodiedSyncBlock node
|
|
49
|
+
*/
|
|
39
50
|
generateBodiedSyncBlockAttrs(): SyncBlockAttrs;
|
|
51
|
+
/**
|
|
52
|
+
* Create a bodiedSyncBlock node with empty content to backend
|
|
53
|
+
* @param attrs attributes Ids of the node
|
|
54
|
+
*/
|
|
40
55
|
createBodiedSyncBlockNode(attrs: SyncBlockAttrs): void;
|
|
41
56
|
private setPendingDeletion;
|
|
42
57
|
deleteSyncBlocksWithConfirmation(tr: Transaction, syncBlockIds: SyncBlockAttrs[]): Promise<void>;
|
|
43
58
|
rebaseTransaction(incomingTr: Transaction, state: EditorState): void;
|
|
59
|
+
destroy(): void;
|
|
44
60
|
}
|
|
@@ -1,66 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
|
|
3
|
-
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
-
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
import type { ResourceId, SyncBlockAttrs } from '../common/types';
|
|
6
|
-
import type { SubscriptionCallback, SyncBlockDataProvider, SyncBlockInstance, TitleSubscriptionCallback } from '../providers/types';
|
|
1
|
+
import type { SyncBlockDataProvider } from '../providers/types';
|
|
7
2
|
import { ReferenceSyncBlockStoreManager } from './referenceSyncBlockStoreManager';
|
|
8
|
-
import {
|
|
3
|
+
import { SourceSyncBlockStoreManager } from './sourceSyncBlockStoreManager';
|
|
9
4
|
export declare class SyncBlockStoreManager {
|
|
10
5
|
private referenceSyncBlockStoreManager;
|
|
11
6
|
private sourceSyncBlockStoreManager;
|
|
12
7
|
constructor(dataProvider?: SyncBlockDataProvider);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* @param nodes - The array of sync block nodes to fetch data for
|
|
16
|
-
* @returns The fetched sync block data results
|
|
17
|
-
*/
|
|
18
|
-
fetchSyncBlocksData(nodes: PMNode[]): Promise<SyncBlockInstance[]>;
|
|
19
|
-
getReferenceSyncBlockStoreManager(): ReferenceSyncBlockStoreManager;
|
|
20
|
-
/**
|
|
21
|
-
* Add/update a sync block node to/from the local cache
|
|
22
|
-
* @param syncBlockNode - The sync block node to update
|
|
23
|
-
*/
|
|
24
|
-
updateSyncBlockData(syncBlockNode: PMNode): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Save content of bodiedSyncBlock nodes in local cache to backend
|
|
27
|
-
*
|
|
28
|
-
* @returns true if saving all nodes successfully, false if fail to save some/all nodes
|
|
29
|
-
*/
|
|
30
|
-
flushBodiedSyncBlocks(): Promise<boolean>;
|
|
31
|
-
/**
|
|
32
|
-
* Get the URL for a sync block.
|
|
33
|
-
* @param resourceId - The resource ID of the sync block to get the URL for
|
|
34
|
-
* @returns
|
|
35
|
-
*/
|
|
36
|
-
getSyncBlockURL(resourceId: ResourceId): string | undefined;
|
|
37
|
-
setEditorView(editorView: EditorView | undefined): void;
|
|
38
|
-
isSourceBlock(node: PMNode): boolean;
|
|
39
|
-
registerConfirmationCallback(callback: ConfirmationCallback): () => void;
|
|
40
|
-
requireConfirmationBeforeDelete(): boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Register callback function (which inserts node, handles focus etc) to be used later when creation to backend succeed
|
|
43
|
-
*/
|
|
44
|
-
registerCreationCallback(callback: CreationCallback): void;
|
|
45
|
-
/**
|
|
46
|
-
*
|
|
47
|
-
* @returns true if waiting for the result of saving new bodiedSyncBlock to backend
|
|
48
|
-
*/
|
|
49
|
-
hasPendingCreation(): boolean;
|
|
50
|
-
/**
|
|
51
|
-
* @returns attributes for a new bodiedSyncBlock node
|
|
52
|
-
*/
|
|
53
|
-
generateBodiedSyncBlockAttrs(): SyncBlockAttrs;
|
|
54
|
-
/**
|
|
55
|
-
* Save bodiedSyncBlock with empty content to backend
|
|
56
|
-
* @param attrs attributes Ids of the node
|
|
57
|
-
*/
|
|
58
|
-
createBodiedSyncBlockNode(attrs: SyncBlockAttrs): void;
|
|
59
|
-
subscribeToSyncBlockData(node: PMNode, callback: SubscriptionCallback): () => void;
|
|
60
|
-
subscribeToSyncBlockSourceTitle(node: PMNode, callback: TitleSubscriptionCallback): () => void;
|
|
61
|
-
refreshSubscriptions(): void;
|
|
62
|
-
deleteSyncBlocksWithConfirmation(tr: Transaction, syncBlockIds: SyncBlockAttrs[]): Promise<void>;
|
|
63
|
-
rebaseTransaction(incomingTr: Transaction, state: EditorState): void;
|
|
64
|
-
getReferenceSyncBlockProviderFactory(resourceId: ResourceId): ProviderFactory | undefined;
|
|
8
|
+
get referenceManager(): ReferenceSyncBlockStoreManager;
|
|
9
|
+
get sourceManager(): SourceSyncBlockStoreManager;
|
|
65
10
|
destroy(): void;
|
|
66
11
|
}
|