@atlaskit/editor-synced-block-provider 2.7.3 → 2.8.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 +14 -0
- package/dist/cjs/index.js +7 -7
- package/dist/cjs/providers/block-service/blockServiceAPI.js +232 -0
- package/dist/cjs/utils/blockService.js +168 -0
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/providers/block-service/blockServiceAPI.js +144 -0
- package/dist/es2019/utils/blockService.js +71 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/providers/block-service/blockServiceAPI.js +225 -0
- package/dist/esm/utils/blockService.js +161 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/providers/block-service/blockServiceAPI.d.ts +20 -0
- package/dist/types/utils/blockService.d.ts +39 -0
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +20 -0
- package/dist/types-ts4.5/utils/blockService.d.ts +39 -0
- package/package.json +2 -2
- package/dist/cjs/common/schema.js +0 -18
- package/dist/es2019/common/schema.js +0 -13
- package/dist/esm/common/schema.js +0 -13
- package/dist/types/common/schema.d.ts +0 -6
- package/dist/types-ts4.5/common/schema.d.ts +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 2.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`ec416ddf3747c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ec416ddf3747c) -
|
|
8
|
+
Add a block service API provider
|
|
9
|
+
|
|
10
|
+
## 2.7.4
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [`3432c4a4a074c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3432c4a4a074c) -
|
|
15
|
+
[ux] EDITOR-2525 update block menu convert to sync block to support all fishfooding node types
|
|
16
|
+
|
|
3
17
|
## 2.7.3
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -57,12 +57,6 @@ Object.defineProperty(exports, "getConfluencePageAri", {
|
|
|
57
57
|
return _ari.getConfluencePageAri;
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
|
-
Object.defineProperty(exports, "getDefaultSyncBlockSchema", {
|
|
61
|
-
enumerable: true,
|
|
62
|
-
get: function get() {
|
|
63
|
-
return _schema.getDefaultSyncBlockSchema;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
60
|
Object.defineProperty(exports, "getPageIdAndTypeFromAri", {
|
|
67
61
|
enumerable: true,
|
|
68
62
|
get: function get() {
|
|
@@ -99,6 +93,12 @@ Object.defineProperty(exports, "useHandleContentChanges", {
|
|
|
99
93
|
return _useHandleContentChanges.useHandleContentChanges;
|
|
100
94
|
}
|
|
101
95
|
});
|
|
96
|
+
Object.defineProperty(exports, "useMemoizedBlockServiceAPIProviders", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function get() {
|
|
99
|
+
return _blockServiceAPI.useMemoizedBlockServiceAPIProviders;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
102
|
Object.defineProperty(exports, "useMemoizedContentAPIProviders", {
|
|
103
103
|
enumerable: true,
|
|
104
104
|
get: function get() {
|
|
@@ -112,11 +112,11 @@ Object.defineProperty(exports, "useMemoizedSyncedBlockProvider", {
|
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
114
|
var _rebaseTransaction = require("./common/rebase-transaction");
|
|
115
|
-
var _schema = require("./common/schema");
|
|
116
115
|
var _types = require("./common/types");
|
|
117
116
|
var _useFetchSyncBlockData = require("./hooks/useFetchSyncBlockData");
|
|
118
117
|
var _useFetchSyncBlockTitle = require("./hooks/useFetchSyncBlockTitle");
|
|
119
118
|
var _useHandleContentChanges = require("./hooks/useHandleContentChanges");
|
|
119
|
+
var _blockServiceAPI = require("./providers/block-service/blockServiceAPI");
|
|
120
120
|
var _confluenceContentAPI = require("./providers/confluence/confluenceContentAPI");
|
|
121
121
|
var _syncBlockProvider = require("./providers/syncBlockProvider");
|
|
122
122
|
var _referenceSyncBlockStoreManager = require("./store-manager/referenceSyncBlockStoreManager");
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useMemoizedBlockServiceAPIProviders = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
|
+
var _react = require("react");
|
|
13
|
+
var _types = require("../../common/types");
|
|
14
|
+
var _ari = require("../../utils/ari");
|
|
15
|
+
var _blockService = require("../../utils/blockService");
|
|
16
|
+
var _errorHandling = require("../../utils/errorHandling");
|
|
17
|
+
var mapBlockError = function mapBlockError(error) {
|
|
18
|
+
switch (error.status) {
|
|
19
|
+
case 403:
|
|
20
|
+
return _types.SyncBlockError.Forbidden;
|
|
21
|
+
case 404:
|
|
22
|
+
return _types.SyncBlockError.NotFound;
|
|
23
|
+
}
|
|
24
|
+
return _types.SyncBlockError.Errored;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* ADFFetchProvider implementation that fetches synced block data from Block Service API
|
|
29
|
+
*/
|
|
30
|
+
var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
31
|
+
function BlockServiceADFFetchProvider() {
|
|
32
|
+
(0, _classCallCheck2.default)(this, BlockServiceADFFetchProvider);
|
|
33
|
+
}
|
|
34
|
+
return (0, _createClass2.default)(BlockServiceADFFetchProvider, [{
|
|
35
|
+
key: "fetchData",
|
|
36
|
+
value: // resourceId is the ARI of the block. E.G ari:cloud:blocks:site-123:synced-block/uuid-456
|
|
37
|
+
function () {
|
|
38
|
+
var _fetchData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(resourceId) {
|
|
39
|
+
var localId, contentProperty, value, syncedBlockData;
|
|
40
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
41
|
+
while (1) switch (_context.prev = _context.next) {
|
|
42
|
+
case 0:
|
|
43
|
+
localId = (0, _ari.getLocalIdFromAri)(resourceId);
|
|
44
|
+
_context.prev = 1;
|
|
45
|
+
_context.next = 4;
|
|
46
|
+
return (0, _blockService.getSyncedBlockContent)({
|
|
47
|
+
blockAri: resourceId
|
|
48
|
+
});
|
|
49
|
+
case 4:
|
|
50
|
+
contentProperty = _context.sent;
|
|
51
|
+
value = contentProperty.content;
|
|
52
|
+
if (value) {
|
|
53
|
+
_context.next = 8;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
return _context.abrupt("return", {
|
|
57
|
+
error: _types.SyncBlockError.NotFound,
|
|
58
|
+
resourceId: resourceId
|
|
59
|
+
});
|
|
60
|
+
case 8:
|
|
61
|
+
// Parse the synced block content from the property value
|
|
62
|
+
syncedBlockData = JSON.parse(value);
|
|
63
|
+
return _context.abrupt("return", {
|
|
64
|
+
data: {
|
|
65
|
+
content: syncedBlockData,
|
|
66
|
+
resourceId: resourceId,
|
|
67
|
+
blockInstanceId: localId
|
|
68
|
+
},
|
|
69
|
+
resourceId: resourceId
|
|
70
|
+
});
|
|
71
|
+
case 12:
|
|
72
|
+
_context.prev = 12;
|
|
73
|
+
_context.t0 = _context["catch"](1);
|
|
74
|
+
if (!(_context.t0 instanceof _blockService.BlockError)) {
|
|
75
|
+
_context.next = 16;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
return _context.abrupt("return", {
|
|
79
|
+
error: mapBlockError(_context.t0),
|
|
80
|
+
resourceId: resourceId
|
|
81
|
+
});
|
|
82
|
+
case 16:
|
|
83
|
+
return _context.abrupt("return", {
|
|
84
|
+
error: _types.SyncBlockError.Errored,
|
|
85
|
+
resourceId: resourceId
|
|
86
|
+
});
|
|
87
|
+
case 17:
|
|
88
|
+
case "end":
|
|
89
|
+
return _context.stop();
|
|
90
|
+
}
|
|
91
|
+
}, _callee, null, [[1, 12]]);
|
|
92
|
+
}));
|
|
93
|
+
function fetchData(_x) {
|
|
94
|
+
return _fetchData.apply(this, arguments);
|
|
95
|
+
}
|
|
96
|
+
return fetchData;
|
|
97
|
+
}()
|
|
98
|
+
}]);
|
|
99
|
+
}();
|
|
100
|
+
/**
|
|
101
|
+
* ADFWriteProvider implementation that writes synced block data to Block Service API
|
|
102
|
+
*/
|
|
103
|
+
var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
104
|
+
function BlockServiceADFWriteProvider() {
|
|
105
|
+
(0, _classCallCheck2.default)(this, BlockServiceADFWriteProvider);
|
|
106
|
+
}
|
|
107
|
+
return (0, _createClass2.default)(BlockServiceADFWriteProvider, [{
|
|
108
|
+
key: "writeData",
|
|
109
|
+
value: // it will first try to update and if it can't (404) then it will try to create
|
|
110
|
+
function () {
|
|
111
|
+
var _writeData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(data) {
|
|
112
|
+
var resourceId;
|
|
113
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
114
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
115
|
+
case 0:
|
|
116
|
+
resourceId = data.resourceId;
|
|
117
|
+
_context2.prev = 1;
|
|
118
|
+
_context2.next = 4;
|
|
119
|
+
return (0, _blockService.updateSyncedBlock)({
|
|
120
|
+
blockAri: resourceId,
|
|
121
|
+
content: JSON.stringify(data.content)
|
|
122
|
+
});
|
|
123
|
+
case 4:
|
|
124
|
+
return _context2.abrupt("return", {
|
|
125
|
+
resourceId: resourceId
|
|
126
|
+
});
|
|
127
|
+
case 7:
|
|
128
|
+
_context2.prev = 7;
|
|
129
|
+
_context2.t0 = _context2["catch"](1);
|
|
130
|
+
if (!(_context2.t0 instanceof _blockService.BlockError)) {
|
|
131
|
+
_context2.next = 16;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
if (!(_context2.t0.status === 404)) {
|
|
135
|
+
_context2.next = 15;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
_context2.next = 13;
|
|
139
|
+
return (0, _blockService.createSyncedBlock)({
|
|
140
|
+
blockAri: (0, _ari.resourceIdFromSourceAndLocalId)(resourceId, data.blockInstanceId),
|
|
141
|
+
blockInstanceId: data.blockInstanceId,
|
|
142
|
+
sourceAri: resourceId,
|
|
143
|
+
product: 'confluence-page',
|
|
144
|
+
content: JSON.stringify(data.content)
|
|
145
|
+
});
|
|
146
|
+
case 13:
|
|
147
|
+
_context2.next = 16;
|
|
148
|
+
break;
|
|
149
|
+
case 15:
|
|
150
|
+
return _context2.abrupt("return", {
|
|
151
|
+
error: mapBlockError(_context2.t0),
|
|
152
|
+
resourceId: resourceId
|
|
153
|
+
});
|
|
154
|
+
case 16:
|
|
155
|
+
return _context2.abrupt("return", {
|
|
156
|
+
error: (0, _errorHandling.stringifyError)(_context2.t0),
|
|
157
|
+
resourceId: resourceId
|
|
158
|
+
});
|
|
159
|
+
case 17:
|
|
160
|
+
case "end":
|
|
161
|
+
return _context2.stop();
|
|
162
|
+
}
|
|
163
|
+
}, _callee2, null, [[1, 7]]);
|
|
164
|
+
}));
|
|
165
|
+
function writeData(_x2) {
|
|
166
|
+
return _writeData.apply(this, arguments);
|
|
167
|
+
}
|
|
168
|
+
return writeData;
|
|
169
|
+
}() // soft deletes the source synced block
|
|
170
|
+
}, {
|
|
171
|
+
key: "deleteData",
|
|
172
|
+
value: function () {
|
|
173
|
+
var _deleteData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(resourceId) {
|
|
174
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
175
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
176
|
+
case 0:
|
|
177
|
+
_context3.prev = 0;
|
|
178
|
+
_context3.next = 3;
|
|
179
|
+
return (0, _blockService.deleteSyncedBlock)({
|
|
180
|
+
blockAri: resourceId
|
|
181
|
+
});
|
|
182
|
+
case 3:
|
|
183
|
+
return _context3.abrupt("return", {
|
|
184
|
+
resourceId: resourceId,
|
|
185
|
+
success: true,
|
|
186
|
+
error: undefined
|
|
187
|
+
});
|
|
188
|
+
case 6:
|
|
189
|
+
_context3.prev = 6;
|
|
190
|
+
_context3.t0 = _context3["catch"](0);
|
|
191
|
+
if (!(_context3.t0 instanceof _blockService.BlockError)) {
|
|
192
|
+
_context3.next = 10;
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
return _context3.abrupt("return", {
|
|
196
|
+
resourceId: resourceId,
|
|
197
|
+
success: false,
|
|
198
|
+
error: mapBlockError(_context3.t0)
|
|
199
|
+
});
|
|
200
|
+
case 10:
|
|
201
|
+
return _context3.abrupt("return", {
|
|
202
|
+
resourceId: resourceId,
|
|
203
|
+
success: false,
|
|
204
|
+
error: (0, _errorHandling.stringifyError)(_context3.t0)
|
|
205
|
+
});
|
|
206
|
+
case 11:
|
|
207
|
+
case "end":
|
|
208
|
+
return _context3.stop();
|
|
209
|
+
}
|
|
210
|
+
}, _callee3, null, [[0, 6]]);
|
|
211
|
+
}));
|
|
212
|
+
function deleteData(_x3) {
|
|
213
|
+
return _deleteData.apply(this, arguments);
|
|
214
|
+
}
|
|
215
|
+
return deleteData;
|
|
216
|
+
}()
|
|
217
|
+
}]);
|
|
218
|
+
}();
|
|
219
|
+
/**
|
|
220
|
+
* Factory function to create both providers with shared configuration
|
|
221
|
+
*/
|
|
222
|
+
var createBlockServiceAPIProviders = function createBlockServiceAPIProviders() {
|
|
223
|
+
var fetchProvider = new BlockServiceADFFetchProvider();
|
|
224
|
+
var writeProvider = new BlockServiceADFWriteProvider();
|
|
225
|
+
return {
|
|
226
|
+
fetchProvider: fetchProvider,
|
|
227
|
+
writeProvider: writeProvider
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
var useMemoizedBlockServiceAPIProviders = exports.useMemoizedBlockServiceAPIProviders = function useMemoizedBlockServiceAPIProviders() {
|
|
231
|
+
return (0, _react.useMemo)(createBlockServiceAPIProviders, []);
|
|
232
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.updateSyncedBlock = exports.getSyncedBlockContent = exports.deleteSyncedBlock = exports.createSyncedBlock = exports.BlockError = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
14
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
|
+
var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
|
|
16
|
+
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
17
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
18
|
+
var COMMON_HEADERS = {
|
|
19
|
+
'Content-Type': 'application/json',
|
|
20
|
+
Accept: 'application/json'
|
|
21
|
+
};
|
|
22
|
+
var BLOCK_SERVICE_API_URL = '/gateway/api/blocks/v1';
|
|
23
|
+
var BlockError = exports.BlockError = /*#__PURE__*/function (_Error) {
|
|
24
|
+
function BlockError(status) {
|
|
25
|
+
var _this;
|
|
26
|
+
(0, _classCallCheck2.default)(this, BlockError);
|
|
27
|
+
_this = _callSuper(this, BlockError, ["Block error"]);
|
|
28
|
+
_this.status = status;
|
|
29
|
+
return _this;
|
|
30
|
+
}
|
|
31
|
+
(0, _inherits2.default)(BlockError, _Error);
|
|
32
|
+
return (0, _createClass2.default)(BlockError);
|
|
33
|
+
}( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
|
|
34
|
+
var getSyncedBlockContent = exports.getSyncedBlockContent = /*#__PURE__*/function () {
|
|
35
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref) {
|
|
36
|
+
var blockAri, response;
|
|
37
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
38
|
+
while (1) switch (_context.prev = _context.next) {
|
|
39
|
+
case 0:
|
|
40
|
+
blockAri = _ref.blockAri;
|
|
41
|
+
_context.next = 3;
|
|
42
|
+
return fetch("".concat(BLOCK_SERVICE_API_URL, "/block/").concat(blockAri), {
|
|
43
|
+
method: 'GET',
|
|
44
|
+
headers: COMMON_HEADERS
|
|
45
|
+
});
|
|
46
|
+
case 3:
|
|
47
|
+
response = _context.sent;
|
|
48
|
+
if (response.ok) {
|
|
49
|
+
_context.next = 6;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
throw new BlockError(response.status);
|
|
53
|
+
case 6:
|
|
54
|
+
_context.next = 8;
|
|
55
|
+
return response.json();
|
|
56
|
+
case 8:
|
|
57
|
+
return _context.abrupt("return", _context.sent);
|
|
58
|
+
case 9:
|
|
59
|
+
case "end":
|
|
60
|
+
return _context.stop();
|
|
61
|
+
}
|
|
62
|
+
}, _callee);
|
|
63
|
+
}));
|
|
64
|
+
return function getSyncedBlockContent(_x) {
|
|
65
|
+
return _ref2.apply(this, arguments);
|
|
66
|
+
};
|
|
67
|
+
}();
|
|
68
|
+
var deleteSyncedBlock = exports.deleteSyncedBlock = /*#__PURE__*/function () {
|
|
69
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_ref3) {
|
|
70
|
+
var blockAri, response;
|
|
71
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
72
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
73
|
+
case 0:
|
|
74
|
+
blockAri = _ref3.blockAri;
|
|
75
|
+
_context2.next = 3;
|
|
76
|
+
return fetch("".concat(BLOCK_SERVICE_API_URL, "/block/").concat(blockAri), {
|
|
77
|
+
method: 'DELETE',
|
|
78
|
+
headers: COMMON_HEADERS
|
|
79
|
+
});
|
|
80
|
+
case 3:
|
|
81
|
+
response = _context2.sent;
|
|
82
|
+
if (response.ok) {
|
|
83
|
+
_context2.next = 6;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
throw new BlockError(response.status);
|
|
87
|
+
case 6:
|
|
88
|
+
case "end":
|
|
89
|
+
return _context2.stop();
|
|
90
|
+
}
|
|
91
|
+
}, _callee2);
|
|
92
|
+
}));
|
|
93
|
+
return function deleteSyncedBlock(_x2) {
|
|
94
|
+
return _ref4.apply(this, arguments);
|
|
95
|
+
};
|
|
96
|
+
}();
|
|
97
|
+
var updateSyncedBlock = exports.updateSyncedBlock = /*#__PURE__*/function () {
|
|
98
|
+
var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(_ref5) {
|
|
99
|
+
var blockAri, content, response;
|
|
100
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
101
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
102
|
+
case 0:
|
|
103
|
+
blockAri = _ref5.blockAri, content = _ref5.content;
|
|
104
|
+
_context3.next = 3;
|
|
105
|
+
return fetch("".concat(BLOCK_SERVICE_API_URL, "/block/").concat(blockAri), {
|
|
106
|
+
method: 'PUT',
|
|
107
|
+
headers: COMMON_HEADERS,
|
|
108
|
+
body: JSON.stringify({
|
|
109
|
+
content: content
|
|
110
|
+
})
|
|
111
|
+
});
|
|
112
|
+
case 3:
|
|
113
|
+
response = _context3.sent;
|
|
114
|
+
if (response.ok) {
|
|
115
|
+
_context3.next = 6;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
throw new BlockError(response.status);
|
|
119
|
+
case 6:
|
|
120
|
+
case "end":
|
|
121
|
+
return _context3.stop();
|
|
122
|
+
}
|
|
123
|
+
}, _callee3);
|
|
124
|
+
}));
|
|
125
|
+
return function updateSyncedBlock(_x3) {
|
|
126
|
+
return _ref6.apply(this, arguments);
|
|
127
|
+
};
|
|
128
|
+
}();
|
|
129
|
+
var createSyncedBlock = exports.createSyncedBlock = /*#__PURE__*/function () {
|
|
130
|
+
var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(_ref7) {
|
|
131
|
+
var blockAri, blockInstanceId, sourceAri, product, content, response;
|
|
132
|
+
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
133
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
134
|
+
case 0:
|
|
135
|
+
blockAri = _ref7.blockAri, blockInstanceId = _ref7.blockInstanceId, sourceAri = _ref7.sourceAri, product = _ref7.product, content = _ref7.content;
|
|
136
|
+
_context4.next = 3;
|
|
137
|
+
return fetch("".concat(BLOCK_SERVICE_API_URL, "/block/").concat(blockAri), {
|
|
138
|
+
method: 'POST',
|
|
139
|
+
headers: COMMON_HEADERS,
|
|
140
|
+
body: JSON.stringify({
|
|
141
|
+
blockInstanceId: blockInstanceId,
|
|
142
|
+
sourceAri: sourceAri,
|
|
143
|
+
product: product,
|
|
144
|
+
content: content
|
|
145
|
+
})
|
|
146
|
+
});
|
|
147
|
+
case 3:
|
|
148
|
+
response = _context4.sent;
|
|
149
|
+
if (response.ok) {
|
|
150
|
+
_context4.next = 6;
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
throw new BlockError(response.status);
|
|
154
|
+
case 6:
|
|
155
|
+
_context4.next = 8;
|
|
156
|
+
return response.json();
|
|
157
|
+
case 8:
|
|
158
|
+
return _context4.abrupt("return", _context4.sent);
|
|
159
|
+
case 9:
|
|
160
|
+
case "end":
|
|
161
|
+
return _context4.stop();
|
|
162
|
+
}
|
|
163
|
+
}, _callee4);
|
|
164
|
+
}));
|
|
165
|
+
return function createSyncedBlock(_x4) {
|
|
166
|
+
return _ref8.apply(this, arguments);
|
|
167
|
+
};
|
|
168
|
+
}();
|
package/dist/es2019/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
2
2
|
|
|
3
3
|
export { rebaseTransaction } from './common/rebase-transaction';
|
|
4
|
-
export { getDefaultSyncBlockSchema } from './common/schema';
|
|
5
4
|
export { SyncBlockError } from './common/types';
|
|
6
5
|
export { useFetchSyncBlockData } from './hooks/useFetchSyncBlockData';
|
|
7
6
|
export { useFetchSyncBlockTitle } from './hooks/useFetchSyncBlockTitle';
|
|
8
7
|
export { useHandleContentChanges } from './hooks/useHandleContentChanges';
|
|
8
|
+
export { useMemoizedBlockServiceAPIProviders } from './providers/block-service/blockServiceAPI';
|
|
9
9
|
export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders } from './providers/confluence/confluenceContentAPI';
|
|
10
10
|
export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider } from './providers/syncBlockProvider';
|
|
11
11
|
export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { SyncBlockError } from '../../common/types';
|
|
3
|
+
import { getLocalIdFromAri, resourceIdFromSourceAndLocalId } from '../../utils/ari';
|
|
4
|
+
import { BlockError, createSyncedBlock, deleteSyncedBlock, getSyncedBlockContent, updateSyncedBlock } from '../../utils/blockService';
|
|
5
|
+
import { stringifyError } from '../../utils/errorHandling';
|
|
6
|
+
const mapBlockError = error => {
|
|
7
|
+
switch (error.status) {
|
|
8
|
+
case 403:
|
|
9
|
+
return SyncBlockError.Forbidden;
|
|
10
|
+
case 404:
|
|
11
|
+
return SyncBlockError.NotFound;
|
|
12
|
+
}
|
|
13
|
+
return SyncBlockError.Errored;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* ADFFetchProvider implementation that fetches synced block data from Block Service API
|
|
18
|
+
*/
|
|
19
|
+
class BlockServiceADFFetchProvider {
|
|
20
|
+
// resourceId is the ARI of the block. E.G ari:cloud:blocks:site-123:synced-block/uuid-456
|
|
21
|
+
async fetchData(resourceId) {
|
|
22
|
+
const localId = getLocalIdFromAri(resourceId);
|
|
23
|
+
try {
|
|
24
|
+
const contentProperty = await getSyncedBlockContent({
|
|
25
|
+
blockAri: resourceId
|
|
26
|
+
});
|
|
27
|
+
const value = contentProperty.content;
|
|
28
|
+
if (!value) {
|
|
29
|
+
return {
|
|
30
|
+
error: SyncBlockError.NotFound,
|
|
31
|
+
resourceId
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Parse the synced block content from the property value
|
|
36
|
+
const syncedBlockData = JSON.parse(value);
|
|
37
|
+
return {
|
|
38
|
+
data: {
|
|
39
|
+
content: syncedBlockData,
|
|
40
|
+
resourceId,
|
|
41
|
+
blockInstanceId: localId
|
|
42
|
+
},
|
|
43
|
+
resourceId
|
|
44
|
+
};
|
|
45
|
+
} catch (error) {
|
|
46
|
+
if (error instanceof BlockError) {
|
|
47
|
+
return {
|
|
48
|
+
error: mapBlockError(error),
|
|
49
|
+
resourceId
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
error: SyncBlockError.Errored,
|
|
54
|
+
resourceId
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* ADFWriteProvider implementation that writes synced block data to Block Service API
|
|
62
|
+
*/
|
|
63
|
+
class BlockServiceADFWriteProvider {
|
|
64
|
+
// it will first try to update and if it can't (404) then it will try to create
|
|
65
|
+
async writeData(data) {
|
|
66
|
+
const {
|
|
67
|
+
resourceId
|
|
68
|
+
} = data;
|
|
69
|
+
try {
|
|
70
|
+
// Try update existing block's content
|
|
71
|
+
await updateSyncedBlock({
|
|
72
|
+
blockAri: resourceId,
|
|
73
|
+
content: JSON.stringify(data.content)
|
|
74
|
+
});
|
|
75
|
+
return {
|
|
76
|
+
resourceId
|
|
77
|
+
};
|
|
78
|
+
} catch (error) {
|
|
79
|
+
if (error instanceof BlockError) {
|
|
80
|
+
if (error.status === 404) {
|
|
81
|
+
// Create the block
|
|
82
|
+
await createSyncedBlock({
|
|
83
|
+
blockAri: resourceIdFromSourceAndLocalId(resourceId, data.blockInstanceId),
|
|
84
|
+
blockInstanceId: data.blockInstanceId,
|
|
85
|
+
sourceAri: resourceId,
|
|
86
|
+
product: 'confluence-page',
|
|
87
|
+
content: JSON.stringify(data.content)
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
return {
|
|
91
|
+
error: mapBlockError(error),
|
|
92
|
+
resourceId
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
error: stringifyError(error),
|
|
98
|
+
resourceId
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// soft deletes the source synced block
|
|
104
|
+
async deleteData(resourceId) {
|
|
105
|
+
try {
|
|
106
|
+
await deleteSyncedBlock({
|
|
107
|
+
blockAri: resourceId
|
|
108
|
+
});
|
|
109
|
+
return {
|
|
110
|
+
resourceId,
|
|
111
|
+
success: true,
|
|
112
|
+
error: undefined
|
|
113
|
+
};
|
|
114
|
+
} catch (error) {
|
|
115
|
+
if (error instanceof BlockError) {
|
|
116
|
+
return {
|
|
117
|
+
resourceId,
|
|
118
|
+
success: false,
|
|
119
|
+
error: mapBlockError(error)
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
resourceId,
|
|
124
|
+
success: false,
|
|
125
|
+
error: stringifyError(error)
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Factory function to create both providers with shared configuration
|
|
133
|
+
*/
|
|
134
|
+
const createBlockServiceAPIProviders = () => {
|
|
135
|
+
const fetchProvider = new BlockServiceADFFetchProvider();
|
|
136
|
+
const writeProvider = new BlockServiceADFWriteProvider();
|
|
137
|
+
return {
|
|
138
|
+
fetchProvider,
|
|
139
|
+
writeProvider
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
export const useMemoizedBlockServiceAPIProviders = () => {
|
|
143
|
+
return useMemo(createBlockServiceAPIProviders, []);
|
|
144
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const COMMON_HEADERS = {
|
|
2
|
+
'Content-Type': 'application/json',
|
|
3
|
+
Accept: 'application/json'
|
|
4
|
+
};
|
|
5
|
+
const BLOCK_SERVICE_API_URL = '/gateway/api/blocks/v1';
|
|
6
|
+
export class BlockError extends Error {
|
|
7
|
+
constructor(status) {
|
|
8
|
+
super(`Block error`);
|
|
9
|
+
this.status = status;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export const getSyncedBlockContent = async ({
|
|
13
|
+
blockAri
|
|
14
|
+
}) => {
|
|
15
|
+
const response = await fetch(`${BLOCK_SERVICE_API_URL}/block/${blockAri}`, {
|
|
16
|
+
method: 'GET',
|
|
17
|
+
headers: COMMON_HEADERS
|
|
18
|
+
});
|
|
19
|
+
if (!response.ok) {
|
|
20
|
+
throw new BlockError(response.status);
|
|
21
|
+
}
|
|
22
|
+
return await response.json();
|
|
23
|
+
};
|
|
24
|
+
export const deleteSyncedBlock = async ({
|
|
25
|
+
blockAri
|
|
26
|
+
}) => {
|
|
27
|
+
const response = await fetch(`${BLOCK_SERVICE_API_URL}/block/${blockAri}`, {
|
|
28
|
+
method: 'DELETE',
|
|
29
|
+
headers: COMMON_HEADERS
|
|
30
|
+
});
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
throw new BlockError(response.status);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
export const updateSyncedBlock = async ({
|
|
36
|
+
blockAri,
|
|
37
|
+
content
|
|
38
|
+
}) => {
|
|
39
|
+
const response = await fetch(`${BLOCK_SERVICE_API_URL}/block/${blockAri}`, {
|
|
40
|
+
method: 'PUT',
|
|
41
|
+
headers: COMMON_HEADERS,
|
|
42
|
+
body: JSON.stringify({
|
|
43
|
+
content
|
|
44
|
+
})
|
|
45
|
+
});
|
|
46
|
+
if (!response.ok) {
|
|
47
|
+
throw new BlockError(response.status);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
export const createSyncedBlock = async ({
|
|
51
|
+
blockAri,
|
|
52
|
+
blockInstanceId,
|
|
53
|
+
sourceAri,
|
|
54
|
+
product,
|
|
55
|
+
content
|
|
56
|
+
}) => {
|
|
57
|
+
const response = await fetch(`${BLOCK_SERVICE_API_URL}/block/${blockAri}`, {
|
|
58
|
+
method: 'POST',
|
|
59
|
+
headers: COMMON_HEADERS,
|
|
60
|
+
body: JSON.stringify({
|
|
61
|
+
blockInstanceId,
|
|
62
|
+
sourceAri,
|
|
63
|
+
product,
|
|
64
|
+
content
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
if (!response.ok) {
|
|
68
|
+
throw new BlockError(response.status);
|
|
69
|
+
}
|
|
70
|
+
return await response.json();
|
|
71
|
+
};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
2
2
|
|
|
3
3
|
export { rebaseTransaction } from './common/rebase-transaction';
|
|
4
|
-
export { getDefaultSyncBlockSchema } from './common/schema';
|
|
5
4
|
export { SyncBlockError } from './common/types';
|
|
6
5
|
export { useFetchSyncBlockData } from './hooks/useFetchSyncBlockData';
|
|
7
6
|
export { useFetchSyncBlockTitle } from './hooks/useFetchSyncBlockTitle';
|
|
8
7
|
export { useHandleContentChanges } from './hooks/useHandleContentChanges';
|
|
8
|
+
export { useMemoizedBlockServiceAPIProviders } from './providers/block-service/blockServiceAPI';
|
|
9
9
|
export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders } from './providers/confluence/confluenceContentAPI';
|
|
10
10
|
export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider } from './providers/syncBlockProvider';
|
|
11
11
|
export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
import { SyncBlockError } from '../../common/types';
|
|
7
|
+
import { getLocalIdFromAri, resourceIdFromSourceAndLocalId } from '../../utils/ari';
|
|
8
|
+
import { BlockError, createSyncedBlock, deleteSyncedBlock, getSyncedBlockContent, updateSyncedBlock } from '../../utils/blockService';
|
|
9
|
+
import { stringifyError } from '../../utils/errorHandling';
|
|
10
|
+
var mapBlockError = function mapBlockError(error) {
|
|
11
|
+
switch (error.status) {
|
|
12
|
+
case 403:
|
|
13
|
+
return SyncBlockError.Forbidden;
|
|
14
|
+
case 404:
|
|
15
|
+
return SyncBlockError.NotFound;
|
|
16
|
+
}
|
|
17
|
+
return SyncBlockError.Errored;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* ADFFetchProvider implementation that fetches synced block data from Block Service API
|
|
22
|
+
*/
|
|
23
|
+
var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
24
|
+
function BlockServiceADFFetchProvider() {
|
|
25
|
+
_classCallCheck(this, BlockServiceADFFetchProvider);
|
|
26
|
+
}
|
|
27
|
+
return _createClass(BlockServiceADFFetchProvider, [{
|
|
28
|
+
key: "fetchData",
|
|
29
|
+
value: // resourceId is the ARI of the block. E.G ari:cloud:blocks:site-123:synced-block/uuid-456
|
|
30
|
+
function () {
|
|
31
|
+
var _fetchData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resourceId) {
|
|
32
|
+
var localId, contentProperty, value, syncedBlockData;
|
|
33
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
34
|
+
while (1) switch (_context.prev = _context.next) {
|
|
35
|
+
case 0:
|
|
36
|
+
localId = getLocalIdFromAri(resourceId);
|
|
37
|
+
_context.prev = 1;
|
|
38
|
+
_context.next = 4;
|
|
39
|
+
return getSyncedBlockContent({
|
|
40
|
+
blockAri: resourceId
|
|
41
|
+
});
|
|
42
|
+
case 4:
|
|
43
|
+
contentProperty = _context.sent;
|
|
44
|
+
value = contentProperty.content;
|
|
45
|
+
if (value) {
|
|
46
|
+
_context.next = 8;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
return _context.abrupt("return", {
|
|
50
|
+
error: SyncBlockError.NotFound,
|
|
51
|
+
resourceId: resourceId
|
|
52
|
+
});
|
|
53
|
+
case 8:
|
|
54
|
+
// Parse the synced block content from the property value
|
|
55
|
+
syncedBlockData = JSON.parse(value);
|
|
56
|
+
return _context.abrupt("return", {
|
|
57
|
+
data: {
|
|
58
|
+
content: syncedBlockData,
|
|
59
|
+
resourceId: resourceId,
|
|
60
|
+
blockInstanceId: localId
|
|
61
|
+
},
|
|
62
|
+
resourceId: resourceId
|
|
63
|
+
});
|
|
64
|
+
case 12:
|
|
65
|
+
_context.prev = 12;
|
|
66
|
+
_context.t0 = _context["catch"](1);
|
|
67
|
+
if (!(_context.t0 instanceof BlockError)) {
|
|
68
|
+
_context.next = 16;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
return _context.abrupt("return", {
|
|
72
|
+
error: mapBlockError(_context.t0),
|
|
73
|
+
resourceId: resourceId
|
|
74
|
+
});
|
|
75
|
+
case 16:
|
|
76
|
+
return _context.abrupt("return", {
|
|
77
|
+
error: SyncBlockError.Errored,
|
|
78
|
+
resourceId: resourceId
|
|
79
|
+
});
|
|
80
|
+
case 17:
|
|
81
|
+
case "end":
|
|
82
|
+
return _context.stop();
|
|
83
|
+
}
|
|
84
|
+
}, _callee, null, [[1, 12]]);
|
|
85
|
+
}));
|
|
86
|
+
function fetchData(_x) {
|
|
87
|
+
return _fetchData.apply(this, arguments);
|
|
88
|
+
}
|
|
89
|
+
return fetchData;
|
|
90
|
+
}()
|
|
91
|
+
}]);
|
|
92
|
+
}();
|
|
93
|
+
/**
|
|
94
|
+
* ADFWriteProvider implementation that writes synced block data to Block Service API
|
|
95
|
+
*/
|
|
96
|
+
var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
97
|
+
function BlockServiceADFWriteProvider() {
|
|
98
|
+
_classCallCheck(this, BlockServiceADFWriteProvider);
|
|
99
|
+
}
|
|
100
|
+
return _createClass(BlockServiceADFWriteProvider, [{
|
|
101
|
+
key: "writeData",
|
|
102
|
+
value: // it will first try to update and if it can't (404) then it will try to create
|
|
103
|
+
function () {
|
|
104
|
+
var _writeData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data) {
|
|
105
|
+
var resourceId;
|
|
106
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
107
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
108
|
+
case 0:
|
|
109
|
+
resourceId = data.resourceId;
|
|
110
|
+
_context2.prev = 1;
|
|
111
|
+
_context2.next = 4;
|
|
112
|
+
return updateSyncedBlock({
|
|
113
|
+
blockAri: resourceId,
|
|
114
|
+
content: JSON.stringify(data.content)
|
|
115
|
+
});
|
|
116
|
+
case 4:
|
|
117
|
+
return _context2.abrupt("return", {
|
|
118
|
+
resourceId: resourceId
|
|
119
|
+
});
|
|
120
|
+
case 7:
|
|
121
|
+
_context2.prev = 7;
|
|
122
|
+
_context2.t0 = _context2["catch"](1);
|
|
123
|
+
if (!(_context2.t0 instanceof BlockError)) {
|
|
124
|
+
_context2.next = 16;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
if (!(_context2.t0.status === 404)) {
|
|
128
|
+
_context2.next = 15;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
_context2.next = 13;
|
|
132
|
+
return createSyncedBlock({
|
|
133
|
+
blockAri: resourceIdFromSourceAndLocalId(resourceId, data.blockInstanceId),
|
|
134
|
+
blockInstanceId: data.blockInstanceId,
|
|
135
|
+
sourceAri: resourceId,
|
|
136
|
+
product: 'confluence-page',
|
|
137
|
+
content: JSON.stringify(data.content)
|
|
138
|
+
});
|
|
139
|
+
case 13:
|
|
140
|
+
_context2.next = 16;
|
|
141
|
+
break;
|
|
142
|
+
case 15:
|
|
143
|
+
return _context2.abrupt("return", {
|
|
144
|
+
error: mapBlockError(_context2.t0),
|
|
145
|
+
resourceId: resourceId
|
|
146
|
+
});
|
|
147
|
+
case 16:
|
|
148
|
+
return _context2.abrupt("return", {
|
|
149
|
+
error: stringifyError(_context2.t0),
|
|
150
|
+
resourceId: resourceId
|
|
151
|
+
});
|
|
152
|
+
case 17:
|
|
153
|
+
case "end":
|
|
154
|
+
return _context2.stop();
|
|
155
|
+
}
|
|
156
|
+
}, _callee2, null, [[1, 7]]);
|
|
157
|
+
}));
|
|
158
|
+
function writeData(_x2) {
|
|
159
|
+
return _writeData.apply(this, arguments);
|
|
160
|
+
}
|
|
161
|
+
return writeData;
|
|
162
|
+
}() // soft deletes the source synced block
|
|
163
|
+
}, {
|
|
164
|
+
key: "deleteData",
|
|
165
|
+
value: function () {
|
|
166
|
+
var _deleteData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(resourceId) {
|
|
167
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
168
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
169
|
+
case 0:
|
|
170
|
+
_context3.prev = 0;
|
|
171
|
+
_context3.next = 3;
|
|
172
|
+
return deleteSyncedBlock({
|
|
173
|
+
blockAri: resourceId
|
|
174
|
+
});
|
|
175
|
+
case 3:
|
|
176
|
+
return _context3.abrupt("return", {
|
|
177
|
+
resourceId: resourceId,
|
|
178
|
+
success: true,
|
|
179
|
+
error: undefined
|
|
180
|
+
});
|
|
181
|
+
case 6:
|
|
182
|
+
_context3.prev = 6;
|
|
183
|
+
_context3.t0 = _context3["catch"](0);
|
|
184
|
+
if (!(_context3.t0 instanceof BlockError)) {
|
|
185
|
+
_context3.next = 10;
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
return _context3.abrupt("return", {
|
|
189
|
+
resourceId: resourceId,
|
|
190
|
+
success: false,
|
|
191
|
+
error: mapBlockError(_context3.t0)
|
|
192
|
+
});
|
|
193
|
+
case 10:
|
|
194
|
+
return _context3.abrupt("return", {
|
|
195
|
+
resourceId: resourceId,
|
|
196
|
+
success: false,
|
|
197
|
+
error: stringifyError(_context3.t0)
|
|
198
|
+
});
|
|
199
|
+
case 11:
|
|
200
|
+
case "end":
|
|
201
|
+
return _context3.stop();
|
|
202
|
+
}
|
|
203
|
+
}, _callee3, null, [[0, 6]]);
|
|
204
|
+
}));
|
|
205
|
+
function deleteData(_x3) {
|
|
206
|
+
return _deleteData.apply(this, arguments);
|
|
207
|
+
}
|
|
208
|
+
return deleteData;
|
|
209
|
+
}()
|
|
210
|
+
}]);
|
|
211
|
+
}();
|
|
212
|
+
/**
|
|
213
|
+
* Factory function to create both providers with shared configuration
|
|
214
|
+
*/
|
|
215
|
+
var createBlockServiceAPIProviders = function createBlockServiceAPIProviders() {
|
|
216
|
+
var fetchProvider = new BlockServiceADFFetchProvider();
|
|
217
|
+
var writeProvider = new BlockServiceADFWriteProvider();
|
|
218
|
+
return {
|
|
219
|
+
fetchProvider: fetchProvider,
|
|
220
|
+
writeProvider: writeProvider
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
export var useMemoizedBlockServiceAPIProviders = function useMemoizedBlockServiceAPIProviders() {
|
|
224
|
+
return useMemo(createBlockServiceAPIProviders, []);
|
|
225
|
+
};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
+
import _wrapNativeSuper from "@babel/runtime/helpers/wrapNativeSuper";
|
|
8
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
9
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
10
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
11
|
+
var COMMON_HEADERS = {
|
|
12
|
+
'Content-Type': 'application/json',
|
|
13
|
+
Accept: 'application/json'
|
|
14
|
+
};
|
|
15
|
+
var BLOCK_SERVICE_API_URL = '/gateway/api/blocks/v1';
|
|
16
|
+
export var BlockError = /*#__PURE__*/function (_Error) {
|
|
17
|
+
function BlockError(status) {
|
|
18
|
+
var _this;
|
|
19
|
+
_classCallCheck(this, BlockError);
|
|
20
|
+
_this = _callSuper(this, BlockError, ["Block error"]);
|
|
21
|
+
_this.status = status;
|
|
22
|
+
return _this;
|
|
23
|
+
}
|
|
24
|
+
_inherits(BlockError, _Error);
|
|
25
|
+
return _createClass(BlockError);
|
|
26
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
27
|
+
export var getSyncedBlockContent = /*#__PURE__*/function () {
|
|
28
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
29
|
+
var blockAri, response;
|
|
30
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
31
|
+
while (1) switch (_context.prev = _context.next) {
|
|
32
|
+
case 0:
|
|
33
|
+
blockAri = _ref.blockAri;
|
|
34
|
+
_context.next = 3;
|
|
35
|
+
return fetch("".concat(BLOCK_SERVICE_API_URL, "/block/").concat(blockAri), {
|
|
36
|
+
method: 'GET',
|
|
37
|
+
headers: COMMON_HEADERS
|
|
38
|
+
});
|
|
39
|
+
case 3:
|
|
40
|
+
response = _context.sent;
|
|
41
|
+
if (response.ok) {
|
|
42
|
+
_context.next = 6;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
throw new BlockError(response.status);
|
|
46
|
+
case 6:
|
|
47
|
+
_context.next = 8;
|
|
48
|
+
return response.json();
|
|
49
|
+
case 8:
|
|
50
|
+
return _context.abrupt("return", _context.sent);
|
|
51
|
+
case 9:
|
|
52
|
+
case "end":
|
|
53
|
+
return _context.stop();
|
|
54
|
+
}
|
|
55
|
+
}, _callee);
|
|
56
|
+
}));
|
|
57
|
+
return function getSyncedBlockContent(_x) {
|
|
58
|
+
return _ref2.apply(this, arguments);
|
|
59
|
+
};
|
|
60
|
+
}();
|
|
61
|
+
export var deleteSyncedBlock = /*#__PURE__*/function () {
|
|
62
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
|
|
63
|
+
var blockAri, response;
|
|
64
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
65
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
66
|
+
case 0:
|
|
67
|
+
blockAri = _ref3.blockAri;
|
|
68
|
+
_context2.next = 3;
|
|
69
|
+
return fetch("".concat(BLOCK_SERVICE_API_URL, "/block/").concat(blockAri), {
|
|
70
|
+
method: 'DELETE',
|
|
71
|
+
headers: COMMON_HEADERS
|
|
72
|
+
});
|
|
73
|
+
case 3:
|
|
74
|
+
response = _context2.sent;
|
|
75
|
+
if (response.ok) {
|
|
76
|
+
_context2.next = 6;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
throw new BlockError(response.status);
|
|
80
|
+
case 6:
|
|
81
|
+
case "end":
|
|
82
|
+
return _context2.stop();
|
|
83
|
+
}
|
|
84
|
+
}, _callee2);
|
|
85
|
+
}));
|
|
86
|
+
return function deleteSyncedBlock(_x2) {
|
|
87
|
+
return _ref4.apply(this, arguments);
|
|
88
|
+
};
|
|
89
|
+
}();
|
|
90
|
+
export var updateSyncedBlock = /*#__PURE__*/function () {
|
|
91
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref5) {
|
|
92
|
+
var blockAri, content, response;
|
|
93
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
94
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
95
|
+
case 0:
|
|
96
|
+
blockAri = _ref5.blockAri, content = _ref5.content;
|
|
97
|
+
_context3.next = 3;
|
|
98
|
+
return fetch("".concat(BLOCK_SERVICE_API_URL, "/block/").concat(blockAri), {
|
|
99
|
+
method: 'PUT',
|
|
100
|
+
headers: COMMON_HEADERS,
|
|
101
|
+
body: JSON.stringify({
|
|
102
|
+
content: content
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
case 3:
|
|
106
|
+
response = _context3.sent;
|
|
107
|
+
if (response.ok) {
|
|
108
|
+
_context3.next = 6;
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
throw new BlockError(response.status);
|
|
112
|
+
case 6:
|
|
113
|
+
case "end":
|
|
114
|
+
return _context3.stop();
|
|
115
|
+
}
|
|
116
|
+
}, _callee3);
|
|
117
|
+
}));
|
|
118
|
+
return function updateSyncedBlock(_x3) {
|
|
119
|
+
return _ref6.apply(this, arguments);
|
|
120
|
+
};
|
|
121
|
+
}();
|
|
122
|
+
export var createSyncedBlock = /*#__PURE__*/function () {
|
|
123
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref7) {
|
|
124
|
+
var blockAri, blockInstanceId, sourceAri, product, content, response;
|
|
125
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
126
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
127
|
+
case 0:
|
|
128
|
+
blockAri = _ref7.blockAri, blockInstanceId = _ref7.blockInstanceId, sourceAri = _ref7.sourceAri, product = _ref7.product, content = _ref7.content;
|
|
129
|
+
_context4.next = 3;
|
|
130
|
+
return fetch("".concat(BLOCK_SERVICE_API_URL, "/block/").concat(blockAri), {
|
|
131
|
+
method: 'POST',
|
|
132
|
+
headers: COMMON_HEADERS,
|
|
133
|
+
body: JSON.stringify({
|
|
134
|
+
blockInstanceId: blockInstanceId,
|
|
135
|
+
sourceAri: sourceAri,
|
|
136
|
+
product: product,
|
|
137
|
+
content: content
|
|
138
|
+
})
|
|
139
|
+
});
|
|
140
|
+
case 3:
|
|
141
|
+
response = _context4.sent;
|
|
142
|
+
if (response.ok) {
|
|
143
|
+
_context4.next = 6;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
throw new BlockError(response.status);
|
|
147
|
+
case 6:
|
|
148
|
+
_context4.next = 8;
|
|
149
|
+
return response.json();
|
|
150
|
+
case 8:
|
|
151
|
+
return _context4.abrupt("return", _context4.sent);
|
|
152
|
+
case 9:
|
|
153
|
+
case "end":
|
|
154
|
+
return _context4.stop();
|
|
155
|
+
}
|
|
156
|
+
}, _callee4);
|
|
157
|
+
}));
|
|
158
|
+
return function createSyncedBlock(_x4) {
|
|
159
|
+
return _ref8.apply(this, arguments);
|
|
160
|
+
};
|
|
161
|
+
}();
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { rebaseTransaction } from './common/rebase-transaction';
|
|
2
|
-
export { getDefaultSyncBlockSchema } from './common/schema';
|
|
3
2
|
export { SyncBlockError } from './common/types';
|
|
4
3
|
export type { SyncBlockData, SyncBlockNode } from './common/types';
|
|
5
4
|
export { useFetchSyncBlockData, type UseFetchSyncBlockDataResult, } from './hooks/useFetchSyncBlockData';
|
|
6
5
|
export { useFetchSyncBlockTitle } from './hooks/useFetchSyncBlockTitle';
|
|
7
6
|
export { useHandleContentChanges } from './hooks/useHandleContentChanges';
|
|
7
|
+
export { useMemoizedBlockServiceAPIProviders } from './providers/block-service/blockServiceAPI';
|
|
8
8
|
export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluence/confluenceContentAPI';
|
|
9
9
|
export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
|
|
10
10
|
export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, } from './providers/types';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type SyncBlockData } from '../../common/types';
|
|
2
|
+
import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, WriteSyncBlockResult } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* ADFFetchProvider implementation that fetches synced block data from Block Service API
|
|
5
|
+
*/
|
|
6
|
+
declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
|
|
7
|
+
fetchData(resourceId: string): Promise<SyncBlockInstance>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* ADFWriteProvider implementation that writes synced block data to Block Service API
|
|
11
|
+
*/
|
|
12
|
+
declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
|
|
13
|
+
writeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
14
|
+
deleteData(resourceId: string): Promise<DeleteSyncBlockResult>;
|
|
15
|
+
}
|
|
16
|
+
export declare const useMemoizedBlockServiceAPIProviders: () => {
|
|
17
|
+
fetchProvider: BlockServiceADFFetchProvider;
|
|
18
|
+
writeProvider: BlockServiceADFWriteProvider;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type BlockProduct = 'confluence-page' | 'jira-work-item';
|
|
2
|
+
export type BlockContentResponse = {
|
|
3
|
+
blockAri: string;
|
|
4
|
+
blockInstanceId: string;
|
|
5
|
+
content: string;
|
|
6
|
+
contentUpdatedAt: number;
|
|
7
|
+
createdAt: number;
|
|
8
|
+
createdBy: string;
|
|
9
|
+
isSynced: boolean;
|
|
10
|
+
product: BlockProduct;
|
|
11
|
+
sourceAri: string;
|
|
12
|
+
status: 'active' | 'deleted';
|
|
13
|
+
version: number;
|
|
14
|
+
};
|
|
15
|
+
export type GetSyncedBlockContentRequest = {
|
|
16
|
+
blockAri: string;
|
|
17
|
+
};
|
|
18
|
+
export type DeleteSyncedBlockRequest = {
|
|
19
|
+
blockAri: string;
|
|
20
|
+
};
|
|
21
|
+
export type UpdateSyncedBlockRequest = {
|
|
22
|
+
blockAri: string;
|
|
23
|
+
content: string;
|
|
24
|
+
};
|
|
25
|
+
export type CreateSyncedBlockRequest = {
|
|
26
|
+
blockAri: string;
|
|
27
|
+
blockInstanceId: string;
|
|
28
|
+
content: string;
|
|
29
|
+
product: string;
|
|
30
|
+
sourceAri: string;
|
|
31
|
+
};
|
|
32
|
+
export declare class BlockError extends Error {
|
|
33
|
+
readonly status: number;
|
|
34
|
+
constructor(status: number);
|
|
35
|
+
}
|
|
36
|
+
export declare const getSyncedBlockContent: ({ blockAri, }: GetSyncedBlockContentRequest) => Promise<BlockContentResponse>;
|
|
37
|
+
export declare const deleteSyncedBlock: ({ blockAri, }: DeleteSyncedBlockRequest) => Promise<void>;
|
|
38
|
+
export declare const updateSyncedBlock: ({ blockAri, content, }: UpdateSyncedBlockRequest) => Promise<void>;
|
|
39
|
+
export declare const createSyncedBlock: ({ blockAri, blockInstanceId, sourceAri, product, content, }: CreateSyncedBlockRequest) => Promise<BlockContentResponse>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { rebaseTransaction } from './common/rebase-transaction';
|
|
2
|
-
export { getDefaultSyncBlockSchema } from './common/schema';
|
|
3
2
|
export { SyncBlockError } from './common/types';
|
|
4
3
|
export type { SyncBlockData, SyncBlockNode } from './common/types';
|
|
5
4
|
export { useFetchSyncBlockData, type UseFetchSyncBlockDataResult, } from './hooks/useFetchSyncBlockData';
|
|
6
5
|
export { useFetchSyncBlockTitle } from './hooks/useFetchSyncBlockTitle';
|
|
7
6
|
export { useHandleContentChanges } from './hooks/useHandleContentChanges';
|
|
7
|
+
export { useMemoizedBlockServiceAPIProviders } from './providers/block-service/blockServiceAPI';
|
|
8
8
|
export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluence/confluenceContentAPI';
|
|
9
9
|
export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
|
|
10
10
|
export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, } from './providers/types';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type SyncBlockData } from '../../common/types';
|
|
2
|
+
import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, WriteSyncBlockResult } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* ADFFetchProvider implementation that fetches synced block data from Block Service API
|
|
5
|
+
*/
|
|
6
|
+
declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
|
|
7
|
+
fetchData(resourceId: string): Promise<SyncBlockInstance>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* ADFWriteProvider implementation that writes synced block data to Block Service API
|
|
11
|
+
*/
|
|
12
|
+
declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
|
|
13
|
+
writeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
14
|
+
deleteData(resourceId: string): Promise<DeleteSyncBlockResult>;
|
|
15
|
+
}
|
|
16
|
+
export declare const useMemoizedBlockServiceAPIProviders: () => {
|
|
17
|
+
fetchProvider: BlockServiceADFFetchProvider;
|
|
18
|
+
writeProvider: BlockServiceADFWriteProvider;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type BlockProduct = 'confluence-page' | 'jira-work-item';
|
|
2
|
+
export type BlockContentResponse = {
|
|
3
|
+
blockAri: string;
|
|
4
|
+
blockInstanceId: string;
|
|
5
|
+
content: string;
|
|
6
|
+
contentUpdatedAt: number;
|
|
7
|
+
createdAt: number;
|
|
8
|
+
createdBy: string;
|
|
9
|
+
isSynced: boolean;
|
|
10
|
+
product: BlockProduct;
|
|
11
|
+
sourceAri: string;
|
|
12
|
+
status: 'active' | 'deleted';
|
|
13
|
+
version: number;
|
|
14
|
+
};
|
|
15
|
+
export type GetSyncedBlockContentRequest = {
|
|
16
|
+
blockAri: string;
|
|
17
|
+
};
|
|
18
|
+
export type DeleteSyncedBlockRequest = {
|
|
19
|
+
blockAri: string;
|
|
20
|
+
};
|
|
21
|
+
export type UpdateSyncedBlockRequest = {
|
|
22
|
+
blockAri: string;
|
|
23
|
+
content: string;
|
|
24
|
+
};
|
|
25
|
+
export type CreateSyncedBlockRequest = {
|
|
26
|
+
blockAri: string;
|
|
27
|
+
blockInstanceId: string;
|
|
28
|
+
content: string;
|
|
29
|
+
product: string;
|
|
30
|
+
sourceAri: string;
|
|
31
|
+
};
|
|
32
|
+
export declare class BlockError extends Error {
|
|
33
|
+
readonly status: number;
|
|
34
|
+
constructor(status: number);
|
|
35
|
+
}
|
|
36
|
+
export declare const getSyncedBlockContent: ({ blockAri, }: GetSyncedBlockContentRequest) => Promise<BlockContentResponse>;
|
|
37
|
+
export declare const deleteSyncedBlock: ({ blockAri, }: DeleteSyncedBlockRequest) => Promise<void>;
|
|
38
|
+
export declare const updateSyncedBlock: ({ blockAri, content, }: UpdateSyncedBlockRequest) => Promise<void>;
|
|
39
|
+
export declare const createSyncedBlock: ({ blockAri, blockInstanceId, sourceAri, product, content, }: CreateSyncedBlockRequest) => Promise<BlockContentResponse>;
|
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"atlaskit:src": "src/index.ts",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@atlaskit/adf-schema": "^51.3.2",
|
|
28
|
-
"@atlaskit/adf-utils": "^19.
|
|
28
|
+
"@atlaskit/adf-utils": "^19.26.0",
|
|
29
29
|
"@atlaskit/css": "^0.15.0",
|
|
30
30
|
"@atlaskit/editor-json-transformer": "^8.31.0",
|
|
31
31
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
}
|
|
83
83
|
},
|
|
84
84
|
"name": "@atlaskit/editor-synced-block-provider",
|
|
85
|
-
"version": "2.
|
|
85
|
+
"version": "2.8.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,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getDefaultSyncBlockSchema = void 0;
|
|
7
|
-
var _adfSchema = require("@atlaskit/adf-schema");
|
|
8
|
-
/**
|
|
9
|
-
* We currently do not need any of the new features, like nested tables
|
|
10
|
-
* Otherwise we could import defaultSchemaConfig from '@atlaskit/adf-schema/schema-default';
|
|
11
|
-
* @returns
|
|
12
|
-
*/
|
|
13
|
-
var getDefaultSyncBlockSchema = exports.getDefaultSyncBlockSchema = function getDefaultSyncBlockSchema() {
|
|
14
|
-
return (0, _adfSchema.createSchema)({
|
|
15
|
-
nodes: ['doc', 'paragraph', 'text', 'bulletList', 'orderedList', 'listItem', 'heading', 'blockquote', 'codeBlock', 'panel', 'rule', 'expand', 'nestedExpand', 'table', 'tableCell', 'tableHeader', 'tableRow', 'date', 'status', 'layoutSection', 'layoutColumn', 'unsupportedBlock', 'unsupportedInline'],
|
|
16
|
-
marks: ['link', 'em', 'strong', 'strike', 'subsup', 'underline', 'code', 'textColor', 'backgroundColor', 'alignment', 'indentation', 'border', 'unsupportedMark', 'unsupportedNodeAttribute', 'typeAheadQuery']
|
|
17
|
-
});
|
|
18
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createSchema } from '@atlaskit/adf-schema';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* We currently do not need any of the new features, like nested tables
|
|
5
|
-
* Otherwise we could import defaultSchemaConfig from '@atlaskit/adf-schema/schema-default';
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
export const getDefaultSyncBlockSchema = () => {
|
|
9
|
-
return createSchema({
|
|
10
|
-
nodes: ['doc', 'paragraph', 'text', 'bulletList', 'orderedList', 'listItem', 'heading', 'blockquote', 'codeBlock', 'panel', 'rule', 'expand', 'nestedExpand', 'table', 'tableCell', 'tableHeader', 'tableRow', 'date', 'status', 'layoutSection', 'layoutColumn', 'unsupportedBlock', 'unsupportedInline'],
|
|
11
|
-
marks: ['link', 'em', 'strong', 'strike', 'subsup', 'underline', 'code', 'textColor', 'backgroundColor', 'alignment', 'indentation', 'border', 'unsupportedMark', 'unsupportedNodeAttribute', 'typeAheadQuery']
|
|
12
|
-
});
|
|
13
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createSchema } from '@atlaskit/adf-schema';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* We currently do not need any of the new features, like nested tables
|
|
5
|
-
* Otherwise we could import defaultSchemaConfig from '@atlaskit/adf-schema/schema-default';
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
export var getDefaultSyncBlockSchema = function getDefaultSyncBlockSchema() {
|
|
9
|
-
return createSchema({
|
|
10
|
-
nodes: ['doc', 'paragraph', 'text', 'bulletList', 'orderedList', 'listItem', 'heading', 'blockquote', 'codeBlock', 'panel', 'rule', 'expand', 'nestedExpand', 'table', 'tableCell', 'tableHeader', 'tableRow', 'date', 'status', 'layoutSection', 'layoutColumn', 'unsupportedBlock', 'unsupportedInline'],
|
|
11
|
-
marks: ['link', 'em', 'strong', 'strike', 'subsup', 'underline', 'code', 'textColor', 'backgroundColor', 'alignment', 'indentation', 'border', 'unsupportedMark', 'unsupportedNodeAttribute', 'typeAheadQuery']
|
|
12
|
-
});
|
|
13
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* We currently do not need any of the new features, like nested tables
|
|
3
|
-
* Otherwise we could import defaultSchemaConfig from '@atlaskit/adf-schema/schema-default';
|
|
4
|
-
* @returns
|
|
5
|
-
*/
|
|
6
|
-
export declare const getDefaultSyncBlockSchema: () => import("prosemirror-model").Schema<"doc" | "paragraph" | "text" | "bulletList" | "orderedList" | "listItem" | "heading" | "blockquote" | "codeBlock" | "panel" | "rule" | "expand" | "nestedExpand" | "table" | "tableCell" | "tableHeader" | "tableRow" | "date" | "status" | "layoutSection" | "layoutColumn" | "unsupportedBlock" | "unsupportedInline", "link" | "em" | "strong" | "strike" | "subsup" | "underline" | "code" | "textColor" | "backgroundColor" | "alignment" | "indentation" | "border" | "unsupportedMark" | "unsupportedNodeAttribute" | "typeAheadQuery">;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* We currently do not need any of the new features, like nested tables
|
|
3
|
-
* Otherwise we could import defaultSchemaConfig from '@atlaskit/adf-schema/schema-default';
|
|
4
|
-
* @returns
|
|
5
|
-
*/
|
|
6
|
-
export declare const getDefaultSyncBlockSchema: () => import("prosemirror-model").Schema<"doc" | "paragraph" | "text" | "bulletList" | "orderedList" | "listItem" | "heading" | "blockquote" | "codeBlock" | "panel" | "rule" | "expand" | "nestedExpand" | "table" | "tableCell" | "tableHeader" | "tableRow" | "date" | "status" | "layoutSection" | "layoutColumn" | "unsupportedBlock" | "unsupportedInline", "link" | "em" | "strong" | "strike" | "subsup" | "underline" | "code" | "textColor" | "backgroundColor" | "alignment" | "indentation" | "border" | "unsupportedMark" | "unsupportedNodeAttribute" | "typeAheadQuery">;
|