@atlaskit/editor-synced-block-provider 0.1.1 → 0.1.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.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/common/syncBlockProvider.js +1 -1
- package/dist/cjs/common/syncBlockStoreManager.js +25 -3
- package/dist/cjs/index.js +8 -2
- package/dist/cjs/utils/utils.js +13 -2
- package/dist/es2019/common/syncBlockProvider.js +2 -2
- package/dist/es2019/common/syncBlockStoreManager.js +24 -3
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/utils/utils.js +13 -1
- package/dist/esm/common/syncBlockProvider.js +2 -2
- package/dist/esm/common/syncBlockStoreManager.js +26 -3
- package/dist/esm/index.js +1 -1
- package/dist/esm/utils/utils.js +12 -1
- package/dist/types/common/syncBlockStoreManager.d.ts +3 -8
- package/dist/types/common/types.d.ts +5 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils/utils.d.ts +2 -1
- package/dist/types-ts4.5/common/syncBlockStoreManager.d.ts +3 -8
- package/dist/types-ts4.5/common/types.d.ts +5 -4
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/utils/utils.d.ts +2 -1
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 0.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`dd19fd49edc58`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/dd19fd49edc58) -
|
|
8
|
+
Added sync block quick insert
|
|
9
|
+
|
|
10
|
+
## 0.1.2
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [`6e2b6f72d4bc2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6e2b6f72d4bc2) -
|
|
15
|
+
Added floating toolbar for sync block
|
|
16
|
+
|
|
3
17
|
## 0.1.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -73,7 +73,7 @@ var useFetchDocNode = exports.useFetchDocNode = function useFetchDocNode(editorV
|
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
75
|
var interval = window.setInterval(function () {
|
|
76
|
-
var nodes = [(0, _utils.
|
|
76
|
+
var nodes = [(0, _utils.convertSyncBlockPMNodeToSyncBlockData)(node, false)];
|
|
77
77
|
provider === null || provider === void 0 || provider.fetchNodesData(nodes).then(function (data) {
|
|
78
78
|
var _data$;
|
|
79
79
|
if (data && (_data$ = data[0]) !== null && _data$ !== void 0 && _data$.content) {
|
|
@@ -9,6 +9,7 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
|
+
var _uuid = _interopRequireDefault(require("uuid"));
|
|
12
13
|
// Do this typedef to make it clear that
|
|
13
14
|
// this is a local identifier for a resource for local use
|
|
14
15
|
// A store manager responsible for the lifecycle and state management of sync blocks in an editor instance.
|
|
@@ -17,10 +18,9 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
17
18
|
// Handles caching, debouncing updates, and publish/subscribe for local changes.
|
|
18
19
|
// Ensures consistency between local and remote state, and can be used in both editor and renderer contexts.
|
|
19
20
|
var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
20
|
-
function SyncBlockStoreManager(
|
|
21
|
+
function SyncBlockStoreManager(_dataProvider) {
|
|
21
22
|
(0, _classCallCheck2.default)(this, SyncBlockStoreManager);
|
|
22
23
|
this.syncBlocks = new Map();
|
|
23
|
-
this.dataProvider = dataProvider;
|
|
24
24
|
}
|
|
25
25
|
return (0, _createClass2.default)(SyncBlockStoreManager, [{
|
|
26
26
|
key: "setEditorView",
|
|
@@ -31,7 +31,7 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
31
31
|
key: "isSourceBlock",
|
|
32
32
|
value: function isSourceBlock(node) {
|
|
33
33
|
var _this$syncBlocks$get;
|
|
34
|
-
if (
|
|
34
|
+
if (node.type.name !== 'syncBlock') {
|
|
35
35
|
return false;
|
|
36
36
|
}
|
|
37
37
|
var _node$attrs = node.attrs,
|
|
@@ -53,6 +53,28 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
53
53
|
value: function requireConfirmationBeforeDelete() {
|
|
54
54
|
return !!this.confirmationCallback;
|
|
55
55
|
}
|
|
56
|
+
}, {
|
|
57
|
+
key: "createSyncBlockNode",
|
|
58
|
+
value: function createSyncBlockNode() {
|
|
59
|
+
// TODO: EDITOR-1644 - properly implement creation of the synced block
|
|
60
|
+
// below is a temporary implementation for the creation of the synced block
|
|
61
|
+
// the resource id needs to have pageId and content property key in it
|
|
62
|
+
|
|
63
|
+
var blockInstanceId = (0, _uuid.default)();
|
|
64
|
+
var localId = (0, _uuid.default)();
|
|
65
|
+
var syncBlockNode = {
|
|
66
|
+
attrs: {
|
|
67
|
+
resourceId: "ari:cloud:confluence:fake_cloud_id:page/fake_page_id/".concat(blockInstanceId),
|
|
68
|
+
localId: localId
|
|
69
|
+
},
|
|
70
|
+
type: 'syncBlock'
|
|
71
|
+
};
|
|
72
|
+
this.syncBlocks.set(syncBlockNode.attrs.resourceId, {
|
|
73
|
+
resourceId: syncBlockNode.attrs.resourceId,
|
|
74
|
+
sourceLocalId: syncBlockNode.attrs.localId
|
|
75
|
+
});
|
|
76
|
+
return syncBlockNode;
|
|
77
|
+
}
|
|
56
78
|
}, {
|
|
57
79
|
key: "deleteSyncBlocksWithConfirmation",
|
|
58
80
|
value: function () {
|
package/dist/cjs/index.js
CHANGED
|
@@ -15,10 +15,16 @@ Object.defineProperty(exports, "SyncedBlockProvider", {
|
|
|
15
15
|
return _syncBlockProvider.SyncBlockProvider;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
Object.defineProperty(exports, "
|
|
18
|
+
Object.defineProperty(exports, "convertSyncBlockPMNodeToSyncBlockData", {
|
|
19
19
|
enumerable: true,
|
|
20
20
|
get: function get() {
|
|
21
|
-
return _utils.
|
|
21
|
+
return _utils.convertSyncBlockPMNodeToSyncBlockData;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "generateSyncBlockSourceUrl", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _utils.generateSyncBlockSourceUrl;
|
|
22
28
|
}
|
|
23
29
|
});
|
|
24
30
|
Object.defineProperty(exports, "inMemoryFetchProvider", {
|
package/dist/cjs/utils/utils.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.generateSyncBlockSourceUrl = exports.convertSyncBlockPMNodeToSyncBlockData = void 0;
|
|
7
7
|
var _editorJsonTransformer = require("@atlaskit/editor-json-transformer");
|
|
8
|
-
var
|
|
8
|
+
var convertSyncBlockPMNodeToSyncBlockData = exports.convertSyncBlockPMNodeToSyncBlockData = function convertSyncBlockPMNodeToSyncBlockData(node) {
|
|
9
9
|
var includeContent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
10
10
|
var transformer = new _editorJsonTransformer.JSONTransformer();
|
|
11
11
|
var toJSON = function toJSON(node) {
|
|
@@ -19,4 +19,15 @@ var createSyncBlockNode = exports.createSyncBlockNode = function createSyncBlock
|
|
|
19
19
|
},
|
|
20
20
|
content: includeContent ? node.content.content.map(toJSON) : undefined
|
|
21
21
|
};
|
|
22
|
+
};
|
|
23
|
+
var generateSyncBlockSourceUrl = exports.generateSyncBlockSourceUrl = function generateSyncBlockSourceUrl(node) {
|
|
24
|
+
var _node$attrs = node.attrs,
|
|
25
|
+
localId = _node$attrs.localId,
|
|
26
|
+
resourceId = _node$attrs.resourceId;
|
|
27
|
+
// TODO: EDITOR-1644 - To be implemented under EDITOR-1644
|
|
28
|
+
// below is a temporary implementation for the url generation
|
|
29
|
+
var url = new URL(location.origin + location.pathname);
|
|
30
|
+
url.searchParams.set('localId', localId);
|
|
31
|
+
url.searchParams.set('resourceId', resourceId);
|
|
32
|
+
return url.toString();
|
|
22
33
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { convertSyncBlockPMNodeToSyncBlockData } from '../utils/utils';
|
|
4
4
|
import { SyncBlockDataProvider } from './types';
|
|
5
5
|
export class SyncBlockProvider extends SyncBlockDataProvider {
|
|
6
6
|
constructor(fetchProvider, writeProvider, sourceId) {
|
|
@@ -44,7 +44,7 @@ export const useFetchDocNode = (editorView, node, defaultDocNode, provider) => {
|
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
46
|
const interval = window.setInterval(() => {
|
|
47
|
-
const nodes = [
|
|
47
|
+
const nodes = [convertSyncBlockPMNodeToSyncBlockData(node, false)];
|
|
48
48
|
provider === null || provider === void 0 ? void 0 : provider.fetchNodesData(nodes).then(data => {
|
|
49
49
|
var _data$;
|
|
50
50
|
if (data && (_data$ = data[0]) !== null && _data$ !== void 0 && _data$.content) {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import uuid from 'uuid';
|
|
2
|
+
|
|
1
3
|
// Do this typedef to make it clear that
|
|
2
4
|
// this is a local identifier for a resource for local use
|
|
3
5
|
|
|
@@ -7,16 +9,15 @@
|
|
|
7
9
|
// Handles caching, debouncing updates, and publish/subscribe for local changes.
|
|
8
10
|
// Ensures consistency between local and remote state, and can be used in both editor and renderer contexts.
|
|
9
11
|
export class SyncBlockStoreManager {
|
|
10
|
-
constructor(
|
|
12
|
+
constructor(_dataProvider) {
|
|
11
13
|
this.syncBlocks = new Map();
|
|
12
|
-
this.dataProvider = dataProvider;
|
|
13
14
|
}
|
|
14
15
|
setEditorView(editorView) {
|
|
15
16
|
this.editorView = editorView;
|
|
16
17
|
}
|
|
17
18
|
isSourceBlock(node) {
|
|
18
19
|
var _this$syncBlocks$get;
|
|
19
|
-
if (
|
|
20
|
+
if (node.type.name !== 'syncBlock') {
|
|
20
21
|
return false;
|
|
21
22
|
}
|
|
22
23
|
const {
|
|
@@ -34,6 +35,26 @@ export class SyncBlockStoreManager {
|
|
|
34
35
|
requireConfirmationBeforeDelete() {
|
|
35
36
|
return !!this.confirmationCallback;
|
|
36
37
|
}
|
|
38
|
+
createSyncBlockNode() {
|
|
39
|
+
// TODO: EDITOR-1644 - properly implement creation of the synced block
|
|
40
|
+
// below is a temporary implementation for the creation of the synced block
|
|
41
|
+
// the resource id needs to have pageId and content property key in it
|
|
42
|
+
|
|
43
|
+
const blockInstanceId = uuid();
|
|
44
|
+
const localId = uuid();
|
|
45
|
+
const syncBlockNode = {
|
|
46
|
+
attrs: {
|
|
47
|
+
resourceId: `ari:cloud:confluence:fake_cloud_id:page/fake_page_id/${blockInstanceId}`,
|
|
48
|
+
localId
|
|
49
|
+
},
|
|
50
|
+
type: 'syncBlock'
|
|
51
|
+
};
|
|
52
|
+
this.syncBlocks.set(syncBlockNode.attrs.resourceId, {
|
|
53
|
+
resourceId: syncBlockNode.attrs.resourceId,
|
|
54
|
+
sourceLocalId: syncBlockNode.attrs.localId
|
|
55
|
+
});
|
|
56
|
+
return syncBlockNode;
|
|
57
|
+
}
|
|
37
58
|
async deleteSyncBlocksWithConfirmation(tr, syncBlockIds) {
|
|
38
59
|
if (this.confirmationCallback) {
|
|
39
60
|
const confirmed = await this.confirmationCallback();
|
package/dist/es2019/index.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
export { SyncBlockProvider as SyncedBlockProvider, useFetchDocNode } from './common/syncBlockProvider';
|
|
4
4
|
export { SyncBlockStoreManager } from './common/syncBlockStoreManager';
|
|
5
5
|
export { inMemoryFetchProvider, inMemoryWriteProvider } from './providers/inMemory';
|
|
6
|
-
export {
|
|
6
|
+
export { convertSyncBlockPMNodeToSyncBlockData, generateSyncBlockSourceUrl } from './utils/utils';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JSONTransformer } from '@atlaskit/editor-json-transformer';
|
|
2
|
-
export const
|
|
2
|
+
export const convertSyncBlockPMNodeToSyncBlockData = (node, includeContent = false) => {
|
|
3
3
|
const transformer = new JSONTransformer();
|
|
4
4
|
const toJSON = node => transformer.encodeNode(node);
|
|
5
5
|
return {
|
|
@@ -10,4 +10,16 @@ export const createSyncBlockNode = (node, includeContent = false) => {
|
|
|
10
10
|
},
|
|
11
11
|
content: includeContent ? node.content.content.map(toJSON) : undefined
|
|
12
12
|
};
|
|
13
|
+
};
|
|
14
|
+
export const generateSyncBlockSourceUrl = node => {
|
|
15
|
+
const {
|
|
16
|
+
localId,
|
|
17
|
+
resourceId
|
|
18
|
+
} = node.attrs;
|
|
19
|
+
// TODO: EDITOR-1644 - To be implemented under EDITOR-1644
|
|
20
|
+
// below is a temporary implementation for the url generation
|
|
21
|
+
const url = new URL(location.origin + location.pathname);
|
|
22
|
+
url.searchParams.set('localId', localId);
|
|
23
|
+
url.searchParams.set('resourceId', resourceId);
|
|
24
|
+
return url.toString();
|
|
13
25
|
};
|
|
@@ -10,7 +10,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
10
10
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
11
11
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
12
12
|
import { useEffect, useState } from 'react';
|
|
13
|
-
import {
|
|
13
|
+
import { convertSyncBlockPMNodeToSyncBlockData } from '../utils/utils';
|
|
14
14
|
import { SyncBlockDataProvider } from './types';
|
|
15
15
|
export var SyncBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
16
16
|
function SyncBlockProvider(fetchProvider, writeProvider, sourceId) {
|
|
@@ -66,7 +66,7 @@ export var useFetchDocNode = function useFetchDocNode(editorView, node, defaultD
|
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
var interval = window.setInterval(function () {
|
|
69
|
-
var nodes = [
|
|
69
|
+
var nodes = [convertSyncBlockPMNodeToSyncBlockData(node, false)];
|
|
70
70
|
provider === null || provider === void 0 || provider.fetchNodesData(nodes).then(function (data) {
|
|
71
71
|
var _data$;
|
|
72
72
|
if (data && (_data$ = data[0]) !== null && _data$ !== void 0 && _data$.content) {
|
|
@@ -2,6 +2,8 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
+
import uuid from 'uuid';
|
|
6
|
+
|
|
5
7
|
// Do this typedef to make it clear that
|
|
6
8
|
// this is a local identifier for a resource for local use
|
|
7
9
|
|
|
@@ -11,10 +13,9 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
11
13
|
// Handles caching, debouncing updates, and publish/subscribe for local changes.
|
|
12
14
|
// Ensures consistency between local and remote state, and can be used in both editor and renderer contexts.
|
|
13
15
|
export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
14
|
-
function SyncBlockStoreManager(
|
|
16
|
+
function SyncBlockStoreManager(_dataProvider) {
|
|
15
17
|
_classCallCheck(this, SyncBlockStoreManager);
|
|
16
18
|
this.syncBlocks = new Map();
|
|
17
|
-
this.dataProvider = dataProvider;
|
|
18
19
|
}
|
|
19
20
|
return _createClass(SyncBlockStoreManager, [{
|
|
20
21
|
key: "setEditorView",
|
|
@@ -25,7 +26,7 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
25
26
|
key: "isSourceBlock",
|
|
26
27
|
value: function isSourceBlock(node) {
|
|
27
28
|
var _this$syncBlocks$get;
|
|
28
|
-
if (
|
|
29
|
+
if (node.type.name !== 'syncBlock') {
|
|
29
30
|
return false;
|
|
30
31
|
}
|
|
31
32
|
var _node$attrs = node.attrs,
|
|
@@ -47,6 +48,28 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
47
48
|
value: function requireConfirmationBeforeDelete() {
|
|
48
49
|
return !!this.confirmationCallback;
|
|
49
50
|
}
|
|
51
|
+
}, {
|
|
52
|
+
key: "createSyncBlockNode",
|
|
53
|
+
value: function createSyncBlockNode() {
|
|
54
|
+
// TODO: EDITOR-1644 - properly implement creation of the synced block
|
|
55
|
+
// below is a temporary implementation for the creation of the synced block
|
|
56
|
+
// the resource id needs to have pageId and content property key in it
|
|
57
|
+
|
|
58
|
+
var blockInstanceId = uuid();
|
|
59
|
+
var localId = uuid();
|
|
60
|
+
var syncBlockNode = {
|
|
61
|
+
attrs: {
|
|
62
|
+
resourceId: "ari:cloud:confluence:fake_cloud_id:page/fake_page_id/".concat(blockInstanceId),
|
|
63
|
+
localId: localId
|
|
64
|
+
},
|
|
65
|
+
type: 'syncBlock'
|
|
66
|
+
};
|
|
67
|
+
this.syncBlocks.set(syncBlockNode.attrs.resourceId, {
|
|
68
|
+
resourceId: syncBlockNode.attrs.resourceId,
|
|
69
|
+
sourceLocalId: syncBlockNode.attrs.localId
|
|
70
|
+
});
|
|
71
|
+
return syncBlockNode;
|
|
72
|
+
}
|
|
50
73
|
}, {
|
|
51
74
|
key: "deleteSyncBlocksWithConfirmation",
|
|
52
75
|
value: function () {
|
package/dist/esm/index.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
export { SyncBlockProvider as SyncedBlockProvider, useFetchDocNode } from './common/syncBlockProvider';
|
|
4
4
|
export { SyncBlockStoreManager } from './common/syncBlockStoreManager';
|
|
5
5
|
export { inMemoryFetchProvider, inMemoryWriteProvider } from './providers/inMemory';
|
|
6
|
-
export {
|
|
6
|
+
export { convertSyncBlockPMNodeToSyncBlockData, generateSyncBlockSourceUrl } from './utils/utils';
|
package/dist/esm/utils/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JSONTransformer } from '@atlaskit/editor-json-transformer';
|
|
2
|
-
export var
|
|
2
|
+
export var convertSyncBlockPMNodeToSyncBlockData = function convertSyncBlockPMNodeToSyncBlockData(node) {
|
|
3
3
|
var includeContent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
4
4
|
var transformer = new JSONTransformer();
|
|
5
5
|
var toJSON = function toJSON(node) {
|
|
@@ -13,4 +13,15 @@ export var createSyncBlockNode = function createSyncBlockNode(node) {
|
|
|
13
13
|
},
|
|
14
14
|
content: includeContent ? node.content.content.map(toJSON) : undefined
|
|
15
15
|
};
|
|
16
|
+
};
|
|
17
|
+
export var generateSyncBlockSourceUrl = function generateSyncBlockSourceUrl(node) {
|
|
18
|
+
var _node$attrs = node.attrs,
|
|
19
|
+
localId = _node$attrs.localId,
|
|
20
|
+
resourceId = _node$attrs.resourceId;
|
|
21
|
+
// TODO: EDITOR-1644 - To be implemented under EDITOR-1644
|
|
22
|
+
// below is a temporary implementation for the url generation
|
|
23
|
+
var url = new URL(location.origin + location.pathname);
|
|
24
|
+
url.searchParams.set('localId', localId);
|
|
25
|
+
url.searchParams.set('resourceId', resourceId);
|
|
26
|
+
return url.toString();
|
|
16
27
|
};
|
|
@@ -2,8 +2,7 @@ import type { ADFEntity } from '@atlaskit/adf-utils/types';
|
|
|
2
2
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
-
import type { SyncBlockDataProvider } from './types';
|
|
6
|
-
type ResourceId = string;
|
|
5
|
+
import type { SyncBlockAttrs, SyncBlockDataProvider, SyncBlockNode } from './types';
|
|
7
6
|
export interface SyncBlock {
|
|
8
7
|
/**
|
|
9
8
|
* The local content of the block,
|
|
@@ -13,21 +12,17 @@ export interface SyncBlock {
|
|
|
13
12
|
resourceId: string;
|
|
14
13
|
sourceLocalId: string;
|
|
15
14
|
}
|
|
16
|
-
type SyncBlockAttrs = {
|
|
17
|
-
localId: string;
|
|
18
|
-
resourceId: ResourceId;
|
|
19
|
-
};
|
|
20
15
|
type ConfirmationCallback = () => Promise<boolean>;
|
|
21
16
|
export declare class SyncBlockStoreManager {
|
|
22
17
|
private syncBlocks;
|
|
23
|
-
private dataProvider?;
|
|
24
18
|
private confirmationCallback?;
|
|
25
19
|
private editorView?;
|
|
26
|
-
constructor(
|
|
20
|
+
constructor(_dataProvider?: SyncBlockDataProvider);
|
|
27
21
|
setEditorView(editorView: EditorView | undefined): void;
|
|
28
22
|
isSourceBlock(node: PMNode): boolean;
|
|
29
23
|
registerConfirmationCallback(callback: ConfirmationCallback): () => void;
|
|
30
24
|
requireConfirmationBeforeDelete(): boolean;
|
|
25
|
+
createSyncBlockNode(): SyncBlockNode;
|
|
31
26
|
deleteSyncBlocksWithConfirmation(tr: Transaction, syncBlockIds: SyncBlockAttrs[]): Promise<void>;
|
|
32
27
|
}
|
|
33
28
|
export {};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { ADFEntity } from '@atlaskit/adf-utils/types';
|
|
2
2
|
import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
|
|
3
3
|
import { NodeDataProvider } from '@atlaskit/node-data-provider';
|
|
4
|
+
export type SyncBlockAttrs = {
|
|
5
|
+
localId: string;
|
|
6
|
+
resourceId: string;
|
|
7
|
+
};
|
|
4
8
|
export type SyncBlockNode = {
|
|
5
|
-
attrs:
|
|
6
|
-
localId: string;
|
|
7
|
-
resourceId: string;
|
|
8
|
-
};
|
|
9
|
+
attrs: SyncBlockAttrs;
|
|
9
10
|
content?: Array<JSONNode>;
|
|
10
11
|
type: 'syncBlock';
|
|
11
12
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export { SyncBlockProvider as SyncedBlockProvider, useFetchDocNode, } from './co
|
|
|
2
2
|
export { SyncBlockStoreManager } from './common/syncBlockStoreManager';
|
|
3
3
|
export type { SyncBlockDataProvider, ADFFetchProvider, ADFWriteProvider, SyncBlockData, SyncBlockNode, } from './common/types';
|
|
4
4
|
export { inMemoryFetchProvider, inMemoryWriteProvider } from './providers/inMemory';
|
|
5
|
-
export {
|
|
5
|
+
export { convertSyncBlockPMNodeToSyncBlockData, generateSyncBlockSourceUrl } from './utils/utils';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { SyncBlockNode } from '../common/types';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const convertSyncBlockPMNodeToSyncBlockData: (node: PMNode, includeContent?: boolean) => SyncBlockNode;
|
|
4
|
+
export declare const generateSyncBlockSourceUrl: (node: PMNode) => string;
|
|
@@ -2,8 +2,7 @@ import type { ADFEntity } from '@atlaskit/adf-utils/types';
|
|
|
2
2
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
-
import type { SyncBlockDataProvider } from './types';
|
|
6
|
-
type ResourceId = string;
|
|
5
|
+
import type { SyncBlockAttrs, SyncBlockDataProvider, SyncBlockNode } from './types';
|
|
7
6
|
export interface SyncBlock {
|
|
8
7
|
/**
|
|
9
8
|
* The local content of the block,
|
|
@@ -13,21 +12,17 @@ export interface SyncBlock {
|
|
|
13
12
|
resourceId: string;
|
|
14
13
|
sourceLocalId: string;
|
|
15
14
|
}
|
|
16
|
-
type SyncBlockAttrs = {
|
|
17
|
-
localId: string;
|
|
18
|
-
resourceId: ResourceId;
|
|
19
|
-
};
|
|
20
15
|
type ConfirmationCallback = () => Promise<boolean>;
|
|
21
16
|
export declare class SyncBlockStoreManager {
|
|
22
17
|
private syncBlocks;
|
|
23
|
-
private dataProvider?;
|
|
24
18
|
private confirmationCallback?;
|
|
25
19
|
private editorView?;
|
|
26
|
-
constructor(
|
|
20
|
+
constructor(_dataProvider?: SyncBlockDataProvider);
|
|
27
21
|
setEditorView(editorView: EditorView | undefined): void;
|
|
28
22
|
isSourceBlock(node: PMNode): boolean;
|
|
29
23
|
registerConfirmationCallback(callback: ConfirmationCallback): () => void;
|
|
30
24
|
requireConfirmationBeforeDelete(): boolean;
|
|
25
|
+
createSyncBlockNode(): SyncBlockNode;
|
|
31
26
|
deleteSyncBlocksWithConfirmation(tr: Transaction, syncBlockIds: SyncBlockAttrs[]): Promise<void>;
|
|
32
27
|
}
|
|
33
28
|
export {};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { ADFEntity } from '@atlaskit/adf-utils/types';
|
|
2
2
|
import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
|
|
3
3
|
import { NodeDataProvider } from '@atlaskit/node-data-provider';
|
|
4
|
+
export type SyncBlockAttrs = {
|
|
5
|
+
localId: string;
|
|
6
|
+
resourceId: string;
|
|
7
|
+
};
|
|
4
8
|
export type SyncBlockNode = {
|
|
5
|
-
attrs:
|
|
6
|
-
localId: string;
|
|
7
|
-
resourceId: string;
|
|
8
|
-
};
|
|
9
|
+
attrs: SyncBlockAttrs;
|
|
9
10
|
content?: Array<JSONNode>;
|
|
10
11
|
type: 'syncBlock';
|
|
11
12
|
};
|
|
@@ -2,4 +2,4 @@ export { SyncBlockProvider as SyncedBlockProvider, useFetchDocNode, } from './co
|
|
|
2
2
|
export { SyncBlockStoreManager } from './common/syncBlockStoreManager';
|
|
3
3
|
export type { SyncBlockDataProvider, ADFFetchProvider, ADFWriteProvider, SyncBlockData, SyncBlockNode, } from './common/types';
|
|
4
4
|
export { inMemoryFetchProvider, inMemoryWriteProvider } from './providers/inMemory';
|
|
5
|
-
export {
|
|
5
|
+
export { convertSyncBlockPMNodeToSyncBlockData, generateSyncBlockSourceUrl } from './utils/utils';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { SyncBlockNode } from '../common/types';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const convertSyncBlockPMNodeToSyncBlockData: (node: PMNode, includeContent?: boolean) => SyncBlockNode;
|
|
4
|
+
export declare const generateSyncBlockSourceUrl: (node: PMNode) => string;
|
package/package.json
CHANGED
|
@@ -31,9 +31,10 @@
|
|
|
31
31
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
32
32
|
"@atlaskit/node-data-provider": "^7.0.0",
|
|
33
33
|
"@atlaskit/primitives": "^14.15.0",
|
|
34
|
-
"@atlaskit/tokens": "^6.
|
|
34
|
+
"@atlaskit/tokens": "^6.4.0",
|
|
35
35
|
"@babel/runtime": "^7.0.0",
|
|
36
|
-
"@compiled/react": "^0.18.3"
|
|
36
|
+
"@compiled/react": "^0.18.3",
|
|
37
|
+
"uuid": "^3.1.0"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
39
40
|
"react": "^18.2.0"
|
|
@@ -81,7 +82,7 @@
|
|
|
81
82
|
}
|
|
82
83
|
},
|
|
83
84
|
"name": "@atlaskit/editor-synced-block-provider",
|
|
84
|
-
"version": "0.1.
|
|
85
|
+
"version": "0.1.3",
|
|
85
86
|
"description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
|
|
86
87
|
"author": "Atlassian Pty Ltd",
|
|
87
88
|
"license": "Apache-2.0",
|