@atlaskit/editor-synced-block-provider 2.10.1 → 2.10.3

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.
Files changed (85) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/{providers → clients}/block-service/ari.js +2 -2
  3. package/dist/cjs/{utils → clients/confluence}/ari.js +6 -6
  4. package/dist/cjs/{utils → clients/confluence}/sourceInfo.js +7 -7
  5. package/dist/cjs/clients/confluence/utils.js +9 -0
  6. package/dist/cjs/hooks/useFetchSyncBlockData.js +5 -6
  7. package/dist/cjs/hooks/useFetchSyncBlockTitle.js +1 -1
  8. package/dist/cjs/hooks/useHandleContentChanges.js +1 -1
  9. package/dist/cjs/index.js +27 -14
  10. package/dist/cjs/providers/block-service/blockServiceAPI.js +4 -4
  11. package/dist/cjs/providers/confluence/confluenceContentAPI.js +33 -26
  12. package/dist/cjs/providers/syncBlockProvider.js +38 -3
  13. package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +86 -19
  14. package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +52 -10
  15. package/dist/cjs/store-manager/syncBlockStoreManager.js +14 -157
  16. package/dist/cjs/utils/utils.js +8 -4
  17. package/dist/es2019/{providers → clients}/block-service/ari.js +1 -1
  18. package/dist/es2019/{utils → clients/confluence}/ari.js +5 -5
  19. package/dist/es2019/{utils → clients/confluence}/sourceInfo.js +5 -5
  20. package/dist/es2019/clients/confluence/utils.js +3 -0
  21. package/dist/es2019/hooks/useFetchSyncBlockData.js +5 -6
  22. package/dist/es2019/hooks/useFetchSyncBlockTitle.js +1 -1
  23. package/dist/es2019/hooks/useHandleContentChanges.js +1 -1
  24. package/dist/es2019/index.js +14 -4
  25. package/dist/es2019/providers/block-service/blockServiceAPI.js +4 -4
  26. package/dist/es2019/providers/confluence/confluenceContentAPI.js +19 -13
  27. package/dist/es2019/providers/syncBlockProvider.js +38 -3
  28. package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +75 -10
  29. package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +39 -1
  30. package/dist/es2019/store-manager/syncBlockStoreManager.js +12 -117
  31. package/dist/es2019/utils/utils.js +3 -3
  32. package/dist/esm/{providers → clients}/block-service/ari.js +1 -1
  33. package/dist/esm/{utils → clients/confluence}/ari.js +5 -5
  34. package/dist/esm/{utils → clients/confluence}/sourceInfo.js +7 -7
  35. package/dist/esm/clients/confluence/utils.js +3 -0
  36. package/dist/esm/hooks/useFetchSyncBlockData.js +5 -6
  37. package/dist/esm/hooks/useFetchSyncBlockTitle.js +1 -1
  38. package/dist/esm/hooks/useHandleContentChanges.js +1 -1
  39. package/dist/esm/index.js +14 -4
  40. package/dist/esm/providers/block-service/blockServiceAPI.js +4 -4
  41. package/dist/esm/providers/confluence/confluenceContentAPI.js +33 -26
  42. package/dist/esm/providers/syncBlockProvider.js +38 -3
  43. package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +87 -19
  44. package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +52 -10
  45. package/dist/esm/store-manager/syncBlockStoreManager.js +14 -157
  46. package/dist/esm/utils/utils.js +7 -3
  47. package/dist/types/{providers → clients}/block-service/ari.d.ts +1 -1
  48. package/dist/types/{utils → clients/block-service}/blockService.d.ts +3 -3
  49. package/dist/types/clients/confluence/ari.d.ts +9 -0
  50. package/dist/types/{utils → clients/confluence}/contentProperty.d.ts +1 -1
  51. package/dist/types/clients/confluence/sourceInfo.d.ts +2 -0
  52. package/dist/types/clients/confluence/utils.d.ts +2 -0
  53. package/dist/types/common/types.d.ts +3 -1
  54. package/dist/types/index.d.ts +5 -4
  55. package/dist/types/providers/syncBlockProvider.d.ts +10 -1
  56. package/dist/types/providers/types.d.ts +20 -8
  57. package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +6 -0
  58. package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +17 -1
  59. package/dist/types/store-manager/syncBlockStoreManager.d.ts +4 -59
  60. package/dist/types/utils/utils.d.ts +1 -2
  61. package/dist/types-ts4.5/{providers → clients}/block-service/ari.d.ts +1 -1
  62. package/dist/types-ts4.5/{utils → clients/block-service}/blockService.d.ts +3 -3
  63. package/dist/types-ts4.5/clients/confluence/ari.d.ts +9 -0
  64. package/dist/types-ts4.5/{utils → clients/confluence}/contentProperty.d.ts +1 -1
  65. package/dist/types-ts4.5/clients/confluence/sourceInfo.d.ts +2 -0
  66. package/dist/types-ts4.5/clients/confluence/utils.d.ts +2 -0
  67. package/dist/types-ts4.5/common/types.d.ts +3 -1
  68. package/dist/types-ts4.5/index.d.ts +5 -4
  69. package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +10 -1
  70. package/dist/types-ts4.5/providers/types.d.ts +20 -8
  71. package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +6 -0
  72. package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +17 -1
  73. package/dist/types-ts4.5/store-manager/syncBlockStoreManager.d.ts +4 -59
  74. package/dist/types-ts4.5/utils/utils.d.ts +1 -2
  75. package/package.json +5 -5
  76. package/dist/types/utils/ari.d.ts +0 -9
  77. package/dist/types/utils/sourceInfo.d.ts +0 -2
  78. package/dist/types-ts4.5/utils/ari.d.ts +0 -9
  79. package/dist/types-ts4.5/utils/sourceInfo.d.ts +0 -2
  80. /package/dist/cjs/{utils → clients/block-service}/blockService.js +0 -0
  81. /package/dist/cjs/{utils → clients/confluence}/contentProperty.js +0 -0
  82. /package/dist/es2019/{utils → clients/block-service}/blockService.js +0 -0
  83. /package/dist/es2019/{utils → clients/confluence}/contentProperty.js +0 -0
  84. /package/dist/esm/{utils → clients/block-service}/blockService.js +0 -0
  85. /package/dist/esm/{utils → clients/confluence}/contentProperty.js +0 -0
@@ -7,6 +7,11 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
7
7
  import uuid from 'uuid';
8
8
  import { rebaseTransaction as _rebaseTransaction } from '../common/rebase-transaction';
9
9
  import { convertSyncBlockPMNodeToSyncBlockData, createBodiedSyncBlockNode as _createBodiedSyncBlockNode } from '../utils/utils';
10
+ // A store manager responsible for the lifecycle and state management of source sync blocks in an editor instance.
11
+ // Designed to manage local in-memory state and synchronize with an external data provider.
12
+ // Supports create, flush, and delete operations for source sync blocks.
13
+ // Handles caching, debouncing updates, and publish/subscribe for local changes.
14
+ // Ensures consistency between local and remote state, and can be used in both editor and renderer contexts.
10
15
  export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
11
16
  function SourceSyncBlockStoreManager(dataProvider) {
12
17
  var _this = this;
@@ -20,14 +25,22 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
20
25
  this.dataProvider = dataProvider;
21
26
  this.syncBlockCache = new Map();
22
27
  }
23
-
24
- /**
25
- * Add/update a sync block node to/from the local cache
26
- * @param syncBlockNode - The sync block node to update
27
- */
28
28
  return _createClass(SourceSyncBlockStoreManager, [{
29
+ key: "isSourceBlock",
30
+ value: function isSourceBlock(node) {
31
+ return node.type.name === 'bodiedSyncBlock';
32
+ }
33
+
34
+ /**
35
+ * Add/update a sync block node to/from the local cache
36
+ * @param syncBlockNode - The sync block node to update
37
+ */
38
+ }, {
29
39
  key: "updateSyncBlockData",
30
40
  value: function updateSyncBlockData(syncBlockNode) {
41
+ if (!this.isSourceBlock(syncBlockNode)) {
42
+ throw new Error('Invalid sync block node type provided for updateSyncBlockData');
43
+ }
31
44
  var _syncBlockNode$attrs = syncBlockNode.attrs,
32
45
  localId = _syncBlockNode$attrs.localId,
33
46
  resourceId = _syncBlockNode$attrs.resourceId;
@@ -45,9 +58,9 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
45
58
  * @returns true if saving all nodes successfully, false if fail to save some/all nodes
46
59
  */
47
60
  }, {
48
- key: "flushBodiedSyncBlocks",
61
+ key: "flush",
49
62
  value: (function () {
50
- var _flushBodiedSyncBlocks = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
63
+ var _flush = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
51
64
  var bodiedSyncBlockNodes, bodiedSyncBlockData, writeResults;
52
65
  return _regeneratorRuntime.wrap(function _callee$(_context) {
53
66
  while (1) switch (_context.prev = _context.next) {
@@ -97,10 +110,10 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
97
110
  }
98
111
  }, _callee, this, [[0, 14]]);
99
112
  }));
100
- function flushBodiedSyncBlocks() {
101
- return _flushBodiedSyncBlocks.apply(this, arguments);
113
+ function flush() {
114
+ return _flush.apply(this, arguments);
102
115
  }
103
- return flushBodiedSyncBlocks;
116
+ return flush;
104
117
  }())
105
118
  }, {
106
119
  key: "setEditorView",
@@ -112,6 +125,10 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
112
125
  value: function registerPendingCreation(resourceId) {
113
126
  this.pendingResourceId = resourceId;
114
127
  }
128
+
129
+ /**
130
+ * Register callback function (which inserts node, handles focus etc) to be used later when creation to backend succeed
131
+ */
115
132
  }, {
116
133
  key: "registerCreationCallback",
117
134
  value: function registerCreationCallback(callback) {
@@ -131,6 +148,11 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
131
148
  this.pendingResourceId = undefined;
132
149
  this.creationCallback = undefined;
133
150
  }
151
+
152
+ /**
153
+ *
154
+ * @returns true if waiting for the result of saving new bodiedSyncBlock to backend
155
+ */
134
156
  }, {
135
157
  key: "hasPendingCreation",
136
158
  value: function hasPendingCreation() {
@@ -150,6 +172,10 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
150
172
  value: function requireConfirmationBeforeDelete() {
151
173
  return !!this.confirmationCallback;
152
174
  }
175
+
176
+ /**
177
+ * @returns attributes for a new bodiedSyncBlock node
178
+ */
153
179
  }, {
154
180
  key: "generateBodiedSyncBlockAttrs",
155
181
  value: function generateBodiedSyncBlockAttrs() {
@@ -166,6 +192,11 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
166
192
  localId: localId
167
193
  };
168
194
  }
195
+
196
+ /**
197
+ * Create a bodiedSyncBlock node with empty content to backend
198
+ * @param attrs attributes Ids of the node
199
+ */
169
200
  }, {
170
201
  key: "createBodiedSyncBlockNode",
171
202
  value: function createBodiedSyncBlockNode(attrs) {
@@ -284,5 +315,16 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
284
315
  }
285
316
  this.confirmationTransaction = _rebaseTransaction(this.confirmationTransaction, incomingTr, state);
286
317
  }
318
+ }, {
319
+ key: "destroy",
320
+ value: function destroy() {
321
+ this.syncBlockCache.clear();
322
+ this.confirmationCallback = undefined;
323
+ this.confirmationTransaction = undefined;
324
+ this.pendingResourceId = undefined;
325
+ this.creationCallback = undefined;
326
+ this.dataProvider = undefined;
327
+ this.editorView = undefined;
328
+ }
287
329
  }]);
288
330
  }();
@@ -1,179 +1,36 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
- import { convertPMNodeToSyncBlockNode } from '../utils/utils';
4
3
  import { ReferenceSyncBlockStoreManager } from './referenceSyncBlockStoreManager';
5
4
  import { SourceSyncBlockStoreManager } from './sourceSyncBlockStoreManager';
6
5
 
7
- // A store manager responsible for the lifecycle and state management of sync blocks in an editor instance.
8
- // Supports create, read, update, and delete operations for sync blocks.
9
- // Designed to manage local in-memory state and synchronize with an external data provider.
10
- // Handles caching, debouncing updates, and publish/subscribe for local changes.
11
- // Ensures consistency between local and remote state, and can be used in both editor and renderer contexts.
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.
12
11
  export var SyncBlockStoreManager = /*#__PURE__*/function () {
13
12
  function SyncBlockStoreManager(dataProvider) {
14
13
  _classCallCheck(this, SyncBlockStoreManager);
15
- this.referenceSyncBlockStoreManager = new ReferenceSyncBlockStoreManager(dataProvider);
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
16
16
  this.sourceSyncBlockStoreManager = new SourceSyncBlockStoreManager(dataProvider);
17
+ this.referenceSyncBlockStoreManager = new ReferenceSyncBlockStoreManager(dataProvider);
17
18
  }
18
-
19
- /**
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
23
- */
24
19
  return _createClass(SyncBlockStoreManager, [{
25
- key: "fetchSyncBlocksData",
26
- value: function fetchSyncBlocksData(nodes) {
27
- var syncBlockNodes = nodes.map(function (node) {
28
- return convertPMNodeToSyncBlockNode(node);
29
- }).filter(function (node) {
30
- return node !== undefined;
31
- }) || [];
32
- if (syncBlockNodes.length === 0) {
33
- return Promise.resolve([]);
34
- }
35
- return this.referenceSyncBlockStoreManager.fetchSyncBlocksData(syncBlockNodes);
36
- }
37
- }, {
38
- key: "getReferenceSyncBlockStoreManager",
39
- value: function getReferenceSyncBlockStoreManager() {
20
+ key: "referenceManager",
21
+ get: function get() {
40
22
  return this.referenceSyncBlockStoreManager;
41
23
  }
42
-
43
- /**
44
- * Add/update a sync block node to/from the local cache
45
- * @param syncBlockNode - The sync block node to update
46
- */
47
- }, {
48
- key: "updateSyncBlockData",
49
- value: function updateSyncBlockData(syncBlockNode) {
50
- if (this.isSourceBlock(syncBlockNode)) {
51
- return this.sourceSyncBlockStoreManager.updateSyncBlockData(syncBlockNode);
52
- } else {
53
- throw new Error('Invalid sync block node type provided for updateSyncBlockData');
54
- }
55
- }
56
-
57
- /**
58
- * Save content of bodiedSyncBlock nodes in local cache to backend
59
- *
60
- * @returns true if saving all nodes successfully, false if fail to save some/all nodes
61
- */
62
- }, {
63
- key: "flushBodiedSyncBlocks",
64
- value: function flushBodiedSyncBlocks() {
65
- // only applicable to source sync block, for now (will be refactored further)
66
- return this.sourceSyncBlockStoreManager.flushBodiedSyncBlocks();
67
- }
68
-
69
- /**
70
- * Get the URL for a sync block.
71
- * @param resourceId - The resource ID of the sync block to get the URL for
72
- * @returns
73
- */
74
- }, {
75
- key: "getSyncBlockURL",
76
- value: function getSyncBlockURL(resourceId) {
77
- // only applicable to reference sync block, for now (will be refactored further)
78
- return this.referenceSyncBlockStoreManager.getSyncBlockURL(resourceId);
79
- }
80
- }, {
81
- key: "setEditorView",
82
- value: function setEditorView(editorView) {
83
- this.sourceSyncBlockStoreManager.setEditorView(editorView);
84
- }
85
- }, {
86
- key: "isSourceBlock",
87
- value: function isSourceBlock(node) {
88
- return node.type.name === 'bodiedSyncBlock';
89
- }
90
- }, {
91
- key: "registerConfirmationCallback",
92
- value: function registerConfirmationCallback(callback) {
93
- // only applicable to source sync block, for now (will be refactored further)
94
- return this.sourceSyncBlockStoreManager.registerConfirmationCallback(callback);
95
- }
96
- }, {
97
- key: "requireConfirmationBeforeDelete",
98
- value: function requireConfirmationBeforeDelete() {
99
- // only applicable to source sync block, for now (will be refactored further)
100
- return this.sourceSyncBlockStoreManager.requireConfirmationBeforeDelete();
101
- }
102
-
103
- /**
104
- * Register callback function (which inserts node, handles focus etc) to be used later when creation to backend succeed
105
- */
106
- }, {
107
- key: "registerCreationCallback",
108
- value: function registerCreationCallback(callback) {
109
- this.sourceSyncBlockStoreManager.registerCreationCallback(callback);
110
- }
111
-
112
- /**
113
- *
114
- * @returns true if waiting for the result of saving new bodiedSyncBlock to backend
115
- */
116
- }, {
117
- key: "hasPendingCreation",
118
- value: function hasPendingCreation() {
119
- return this.sourceSyncBlockStoreManager.hasPendingCreation();
120
- }
121
-
122
- /**
123
- * @returns attributes for a new bodiedSyncBlock node
124
- */
125
- }, {
126
- key: "generateBodiedSyncBlockAttrs",
127
- value: function generateBodiedSyncBlockAttrs() {
128
- return this.sourceSyncBlockStoreManager.generateBodiedSyncBlockAttrs();
129
- }
130
-
131
- /**
132
- * Save bodiedSyncBlock with empty content to backend
133
- * @param attrs attributes Ids of the node
134
- */
135
- }, {
136
- key: "createBodiedSyncBlockNode",
137
- value: function createBodiedSyncBlockNode(attrs) {
138
- // only applicable to source sync block, for now (will be refactored further)
139
- return this.sourceSyncBlockStoreManager.createBodiedSyncBlockNode(attrs);
140
- }
141
- }, {
142
- key: "subscribeToSyncBlockData",
143
- value: function subscribeToSyncBlockData(node, callback) {
144
- return this.referenceSyncBlockStoreManager.subscribe(node, callback);
145
- }
146
- }, {
147
- key: "subscribeToSyncBlockSourceTitle",
148
- value: function subscribeToSyncBlockSourceTitle(node, callback) {
149
- return this.referenceSyncBlockStoreManager.subscribeToSourceTitle(node, callback);
150
- }
151
- }, {
152
- key: "refreshSubscriptions",
153
- value: function refreshSubscriptions() {
154
- this.referenceSyncBlockStoreManager.refreshSubscriptions();
155
- }
156
- }, {
157
- key: "deleteSyncBlocksWithConfirmation",
158
- value: function deleteSyncBlocksWithConfirmation(tr, syncBlockIds) {
159
- // only applicable to source sync block, for now (will be refactored further)
160
- return this.sourceSyncBlockStoreManager.deleteSyncBlocksWithConfirmation(tr, syncBlockIds);
161
- }
162
- }, {
163
- key: "rebaseTransaction",
164
- value: function rebaseTransaction(incomingTr, state) {
165
- // only applicable to source sync block, for now (will be refactored further)
166
- this.sourceSyncBlockStoreManager.rebaseTransaction(incomingTr, state);
167
- }
168
24
  }, {
169
- key: "getReferenceSyncBlockProviderFactory",
170
- value: function getReferenceSyncBlockProviderFactory(resourceId) {
171
- return this.referenceSyncBlockStoreManager.getProviderFactory(resourceId);
25
+ key: "sourceManager",
26
+ get: function get() {
27
+ return this.sourceSyncBlockStoreManager;
172
28
  }
173
29
  }, {
174
30
  key: "destroy",
175
31
  value: function destroy() {
176
32
  this.referenceSyncBlockStoreManager.destroy();
33
+ this.sourceSyncBlockStoreManager.destroy();
177
34
  }
178
35
  }]);
179
36
  }();
@@ -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 getLocalIdFromResourceId: (ari: string) => string;
13
+ export declare const getLocalIdFromBlockResourceId: (ari: string) => string;
@@ -1,4 +1,4 @@
1
- export type BlockProduct = 'confluence-page' | 'jira-work-item';
1
+ import type { SyncBlockProduct } from '../../common/types';
2
2
  export type BlockContentResponse = {
3
3
  blockAri: string;
4
4
  blockInstanceId: string;
@@ -7,7 +7,7 @@ export type BlockContentResponse = {
7
7
  createdAt: number;
8
8
  createdBy: string;
9
9
  isSynced: boolean;
10
- product: BlockProduct;
10
+ product: SyncBlockProduct;
11
11
  sourceAri: string;
12
12
  status: 'active' | 'deleted';
13
13
  version: number;
@@ -26,7 +26,7 @@ export type CreateSyncedBlockRequest = {
26
26
  blockAri: string;
27
27
  blockInstanceId: string;
28
28
  content: string;
29
- product: string;
29
+ product: SyncBlockProduct;
30
30
  sourceAri: string;
31
31
  };
32
32
  export declare class BlockError extends Error {
@@ -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;
@@ -1,4 +1,4 @@
1
- import type { SyncBlockData } from '../common/types';
1
+ import type { SyncBlockData } from '../../common/types';
2
2
  import { type PAGE_TYPE } from './ari';
3
3
  type GetContentPropertyOptions = {
4
4
  cloudId: string;
@@ -0,0 +1,2 @@
1
+ import type { SyncBlockSourceInfo } from '../../providers/types';
2
+ export declare const fetchConfluenceSourceInfo: (pageAri: string, localId?: string) => Promise<SyncBlockSourceInfo | undefined>;
@@ -0,0 +1,2 @@
1
+ import type { PAGE_TYPE } from './ari';
2
+ export declare const isBlogPageType: (pageType: PAGE_TYPE) => boolean;
@@ -2,6 +2,7 @@ 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
4
  export type ResourceId = string;
5
+ export type SyncBlockProduct = 'confluence-page' | 'jira-work-item';
5
6
  export type SyncBlockAttrs = {
6
7
  localId: BlockInstanceId;
7
8
  resourceId: ResourceId;
@@ -22,8 +23,9 @@ export interface SyncBlockData {
22
23
  createdAt?: string;
23
24
  createdBy?: string;
24
25
  isSynced?: boolean;
26
+ product?: SyncBlockProduct;
25
27
  resourceId: ResourceId;
26
- sourceDocumentAri?: string;
28
+ sourceAri?: string;
27
29
  sourceTitle?: string;
28
30
  sourceURL?: string;
29
31
  updatedAt?: 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, getLocalIdFromResourceId } from './providers/block-service/ari';
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
- export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, } from './providers/types';
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';
@@ -1,6 +1,6 @@
1
1
  import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
2
2
  import { type SyncBlockData, type SyncBlockNode } from '../common/types';
3
- import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockSourceInfo, type SyncedBlockRendererProviderOptions, type WriteSyncBlockResult } from '../providers/types';
3
+ import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockParentInfo, type SyncBlockSourceInfo, type SyncedBlockRendererProviderOptions, type WriteSyncBlockResult } from '../providers/types';
4
4
  export declare class SyncBlockProvider extends SyncBlockDataProvider {
5
5
  name: string;
6
6
  private fetchProvider;
@@ -79,5 +79,14 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
79
79
  * @returns The synced block renderer provider options
80
80
  */
81
81
  getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
82
+ /**
83
+ * Retrieve the parent info for the sync block
84
+ *
85
+ * @param resourceId
86
+ * @param syncBlockInstance
87
+ *
88
+ * @returns The parent info for the sync block
89
+ */
90
+ retrieveSyncBlockParentInfo(syncBlockInstance: SyncBlockInstance | undefined): SyncBlockParentInfo | undefined;
82
91
  }
83
92
  export declare const useMemoizedSyncedBlockProvider: (fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string, providerOptions: SyncedBlockRendererProviderOptions) => SyncBlockProvider;
@@ -1,7 +1,9 @@
1
- import type { SyncedBlockRendererDataProviders, MediaProvider } from '@atlaskit/editor-common/provider-factory';
1
+ import type { MediaProvider, ProfilecardProvider } from '@atlaskit/editor-common/provider-factory';
2
2
  import type { EmojiProvider } from '@atlaskit/emoji';
3
+ import type { MentionProvider } from '@atlaskit/mention/types';
3
4
  import { NodeDataProvider } from '@atlaskit/node-data-provider';
4
- import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode } from '../common/types';
5
+ import type { TaskDecisionProvider } from '@atlaskit/task-decision/types';
6
+ import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode, SyncBlockProduct } from '../common/types';
5
7
  /**
6
8
  * The instance of a sync block, containing its data and metadata.
7
9
  * Mainly used for representing the state of a sync block after fetching from a data provider.
@@ -21,6 +23,10 @@ export type SyncBlockSourceInfo = {
21
23
  title?: string;
22
24
  url?: string;
23
25
  };
26
+ export type SyncBlockParentInfo = {
27
+ contentId: string;
28
+ contentProduct: SyncBlockProduct;
29
+ };
24
30
  export type WriteSyncBlockResult = {
25
31
  error?: string;
26
32
  resourceId?: string;
@@ -40,15 +46,20 @@ export interface ADFWriteProvider {
40
46
  }
41
47
  export type MediaEmojiProviderOptions = {
42
48
  contentId: string;
43
- contentType: string;
44
- spaceKey?: string | null;
49
+ contentProduct: SyncBlockProduct;
50
+ };
51
+ export type SyncedBlockRendererDataProviders = {
52
+ mentionProvider?: Promise<MentionProvider>;
53
+ profilecardProvider?: Promise<ProfilecardProvider>;
54
+ taskDecisionProvider?: Promise<TaskDecisionProvider>;
55
+ };
56
+ export type SyncBlockRendererProviderCreator = {
57
+ createEmojiProvider: ((options: MediaEmojiProviderOptions) => Promise<EmojiProvider>) | undefined;
58
+ createMediaProvider: ((options: MediaEmojiProviderOptions) => Promise<MediaProvider>) | undefined;
45
59
  };
46
60
  export type SyncedBlockRendererProviderOptions = {
47
61
  parentDataProviders?: SyncedBlockRendererDataProviders;
48
- providerCreator?: {
49
- createEmojiProvider: ((options: MediaEmojiProviderOptions) => Promise<EmojiProvider>) | undefined;
50
- createMediaProvider: ((options: MediaEmojiProviderOptions) => Promise<MediaProvider>) | undefined;
51
- };
62
+ providerCreator?: SyncBlockRendererProviderCreator;
52
63
  };
53
64
  export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode, SyncBlockInstance> {
54
65
  abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
@@ -56,6 +67,7 @@ export declare abstract class SyncBlockDataProvider extends NodeDataProvider<Syn
56
67
  abstract getSourceId(): ResourceId;
57
68
  abstract retrieveSyncBlockSourceInfo(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
58
69
  abstract getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
70
+ abstract retrieveSyncBlockParentInfo(syncBlockInstance: SyncBlockInstance | undefined): SyncBlockParentInfo | undefined;
59
71
  /**
60
72
  * Generates a resource ID from a source ID and local ID.
61
73
  * @param sourceId - The source document ID (e.g., page ARI)
@@ -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;
@@ -32,5 +37,6 @@ export declare class ReferenceSyncBlockStoreManager {
32
37
  */
33
38
  getSyncBlockURL(resourceId: ResourceId): string | undefined;
34
39
  getProviderFactory(resourceId: ResourceId): ProviderFactory | undefined;
40
+ private retrieveDynamicProviders;
35
41
  destroy(): void;
36
42
  }
@@ -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
- flushBodiedSyncBlocks(): Promise<boolean>;
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 { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
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 { type ConfirmationCallback, type CreationCallback } from './sourceSyncBlockStoreManager';
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
- * Fetch sync block data for a given array of sync block nodes.
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
  }