@atlaskit/editor-plugin-synced-block 4.2.13 → 4.2.14
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 +8 -0
- package/dist/cjs/editor-actions/index.js +1 -1
- package/dist/cjs/editor-commands/index.js +5 -5
- package/dist/cjs/pm-plugins/main.js +9 -8
- package/dist/cjs/ui/DeleteConfirmationModal.js +1 -1
- package/dist/cjs/ui/SyncBlockRefresher.js +1 -1
- package/dist/cjs/ui/floating-toolbar.js +1 -1
- package/dist/es2019/editor-actions/index.js +1 -1
- package/dist/es2019/editor-commands/index.js +5 -5
- package/dist/es2019/pm-plugins/main.js +9 -8
- package/dist/es2019/ui/DeleteConfirmationModal.js +1 -1
- package/dist/es2019/ui/SyncBlockRefresher.js +1 -1
- package/dist/es2019/ui/floating-toolbar.js +1 -1
- package/dist/esm/editor-actions/index.js +1 -1
- package/dist/esm/editor-commands/index.js +5 -5
- package/dist/esm/pm-plugins/main.js +9 -8
- package/dist/esm/ui/DeleteConfirmationModal.js +1 -1
- package/dist/esm/ui/SyncBlockRefresher.js +1 -1
- package/dist/esm/ui/floating-toolbar.js +1 -1
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 4.2.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`964b980644f9d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/964b980644f9d) -
|
|
8
|
+
EDITOR-3348 Refactor Synced Block Store Manager
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 4.2.13
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -5,5 +5,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.flushBodiedSyncBlocks = void 0;
|
|
7
7
|
var flushBodiedSyncBlocks = exports.flushBodiedSyncBlocks = function flushBodiedSyncBlocks(syncBlockStore) {
|
|
8
|
-
return syncBlockStore.
|
|
8
|
+
return syncBlockStore.sourceManager.flush();
|
|
9
9
|
};
|
|
@@ -19,7 +19,7 @@ var createSyncedBlock = exports.createSyncedBlock = function createSyncedBlock(_
|
|
|
19
19
|
|
|
20
20
|
// If the selection is empty, we want to insert the sync block on a new line
|
|
21
21
|
if (tr.selection.empty) {
|
|
22
|
-
var attrs = syncBlockStore.generateBodiedSyncBlockAttrs();
|
|
22
|
+
var attrs = syncBlockStore.sourceManager.generateBodiedSyncBlockAttrs();
|
|
23
23
|
var paragraphNode = paragraph.createAndFill({});
|
|
24
24
|
var newBodiedSyncBlockNode = bodiedSyncBlock.createAndFill(attrs, paragraphNode ? [paragraphNode] : []);
|
|
25
25
|
if (!newBodiedSyncBlockNode) {
|
|
@@ -28,7 +28,7 @@ var createSyncedBlock = exports.createSyncedBlock = function createSyncedBlock(_
|
|
|
28
28
|
|
|
29
29
|
// Save the new node with empty content to backend
|
|
30
30
|
// This is so that the node can be copied and referenced without the source being saved/published
|
|
31
|
-
syncBlockStore.createBodiedSyncBlockNode(attrs);
|
|
31
|
+
syncBlockStore.sourceManager.createBodiedSyncBlockNode(attrs);
|
|
32
32
|
if (typeAheadInsert) {
|
|
33
33
|
tr = typeAheadInsert(newBodiedSyncBlockNode);
|
|
34
34
|
} else {
|
|
@@ -40,7 +40,7 @@ var createSyncedBlock = exports.createSyncedBlock = function createSyncedBlock(_
|
|
|
40
40
|
// TODO: EDITOR-1665 - Raise an error analytics event
|
|
41
41
|
return false;
|
|
42
42
|
}
|
|
43
|
-
var _attrs = syncBlockStore.generateBodiedSyncBlockAttrs();
|
|
43
|
+
var _attrs = syncBlockStore.sourceManager.generateBodiedSyncBlockAttrs();
|
|
44
44
|
var _newBodiedSyncBlockNode = bodiedSyncBlock.createAndFill(_attrs, conversionInfo.contentToInclude);
|
|
45
45
|
if (!_newBodiedSyncBlockNode) {
|
|
46
46
|
return false;
|
|
@@ -48,7 +48,7 @@ var createSyncedBlock = exports.createSyncedBlock = function createSyncedBlock(_
|
|
|
48
48
|
|
|
49
49
|
// Save the new node with empty content to backend
|
|
50
50
|
// This is so that the node can be copied and referenced without the source being saved/published
|
|
51
|
-
syncBlockStore.createBodiedSyncBlockNode(_attrs);
|
|
51
|
+
syncBlockStore.sourceManager.createBodiedSyncBlockNode(_attrs);
|
|
52
52
|
tr.replaceWith(conversionInfo.from > 0 ? conversionInfo.from - 1 : 0, conversionInfo.to, _newBodiedSyncBlockNode).scrollIntoView();
|
|
53
53
|
|
|
54
54
|
// set selection to the end of the previous selection + 1 for the position taken up by the start of the new synced block
|
|
@@ -104,7 +104,7 @@ var editSyncedBlockSource = exports.editSyncedBlockSource = function editSyncedB
|
|
|
104
104
|
if (!resourceId) {
|
|
105
105
|
return false;
|
|
106
106
|
}
|
|
107
|
-
var syncBlockURL = syncBlockStore.getSyncBlockURL(resourceId);
|
|
107
|
+
var syncBlockURL = syncBlockStore.referenceManager.getSyncBlockURL(resourceId);
|
|
108
108
|
if (syncBlockURL) {
|
|
109
109
|
window.open(syncBlockURL, '_blank');
|
|
110
110
|
} else {
|
|
@@ -9,6 +9,7 @@ var _selection = require("@atlaskit/editor-common/selection");
|
|
|
9
9
|
var _syncBlock = require("@atlaskit/editor-common/sync-block");
|
|
10
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
11
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
12
|
+
var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
|
|
12
13
|
var _bodiedLazySyncedBlock = require("../nodeviews/bodiedLazySyncedBlock");
|
|
13
14
|
var _lazySyncedBlock = require("../nodeviews/lazySyncedBlock");
|
|
14
15
|
var _types = require("../types");
|
|
@@ -27,7 +28,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
27
28
|
var syncBlockNodes = instance.doc.children.filter(function (node) {
|
|
28
29
|
return node.type.name === 'syncBlock';
|
|
29
30
|
});
|
|
30
|
-
syncBlockStore.fetchSyncBlocksData(syncBlockNodes);
|
|
31
|
+
syncBlockStore.referenceManager.fetchSyncBlocksData((0, _editorSyncedBlockProvider.convertPMNodesToSyncBlockNodes)(syncBlockNodes));
|
|
31
32
|
return {
|
|
32
33
|
selectionDecorationSet: (0, _selectionDecorations.calculateDecorations)(instance.doc, instance.selection, instance.schema),
|
|
33
34
|
showFlag: false
|
|
@@ -100,10 +101,10 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
100
101
|
}
|
|
101
102
|
},
|
|
102
103
|
view: function view(editorView) {
|
|
103
|
-
syncBlockStore.setEditorView(editorView);
|
|
104
|
+
syncBlockStore.sourceManager.setEditorView(editorView);
|
|
104
105
|
return {
|
|
105
106
|
destroy: function destroy() {
|
|
106
|
-
syncBlockStore.setEditorView(undefined);
|
|
107
|
+
syncBlockStore.sourceManager.setEditorView(undefined);
|
|
107
108
|
}
|
|
108
109
|
};
|
|
109
110
|
},
|
|
@@ -115,10 +116,10 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
115
116
|
// or are from remote (collab) or already confirmed sync block deletion
|
|
116
117
|
// We only care about local changes that change the document
|
|
117
118
|
// and are not yet confirmed for sync block deletion
|
|
118
|
-
if (!tr.docChanged || !(syncBlockStore !== null && syncBlockStore !== void 0 && syncBlockStore.requireConfirmationBeforeDelete()) && !syncBlockStore.hasPendingCreation() || Boolean(tr.getMeta('isRemote')) || Boolean(tr.getMeta('isCommitSyncBlockCreation')) || !isOffline && isConfirmedSyncBlockDeletion) {
|
|
119
|
+
if (!tr.docChanged || !(syncBlockStore !== null && syncBlockStore !== void 0 && syncBlockStore.sourceManager.requireConfirmationBeforeDelete()) && !syncBlockStore.sourceManager.hasPendingCreation() || Boolean(tr.getMeta('isRemote')) || Boolean(tr.getMeta('isCommitSyncBlockCreation')) || !isOffline && isConfirmedSyncBlockDeletion) {
|
|
119
120
|
return true;
|
|
120
121
|
}
|
|
121
|
-
var _trackSyncBlocks = (0, _trackSyncBlocks3.trackSyncBlocks)(syncBlockStore.isSourceBlock, tr, state),
|
|
122
|
+
var _trackSyncBlocks = (0, _trackSyncBlocks3.trackSyncBlocks)(syncBlockStore.sourceManager.isSourceBlock, tr, state),
|
|
122
123
|
bodiedSyncBlockRemoved = _trackSyncBlocks.removed,
|
|
123
124
|
bodiedSyncBlockAdded = _trackSyncBlocks.added;
|
|
124
125
|
if (!isOffline) {
|
|
@@ -127,14 +128,14 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
127
128
|
// we block the transaction here, and wait for user confirmation to proceed with deletion.
|
|
128
129
|
// See editor-common/src/sync-block/sync-block-store-manager.ts for how we handle user confirmation and
|
|
129
130
|
// proceed with deletion.
|
|
130
|
-
syncBlockStore.deleteSyncBlocksWithConfirmation(tr, bodiedSyncBlockRemoved);
|
|
131
|
+
syncBlockStore.sourceManager.deleteSyncBlocksWithConfirmation(tr, bodiedSyncBlockRemoved);
|
|
131
132
|
return false;
|
|
132
133
|
}
|
|
133
134
|
if (bodiedSyncBlockAdded.length > 0) {
|
|
134
135
|
// If there is bodiedSyncBlock node addition and it's waiting for the result of saving the node to backend (syncBlockStore.hasPendingCreation()),
|
|
135
136
|
// we need to intercept the transaction and save it in insert callback so that we only insert it to the document when backend call if backend call is successful
|
|
136
137
|
// The callback will be evoked by in SourceSyncBlockStoreManager.commitPendingCreation
|
|
137
|
-
syncBlockStore.registerCreationCallback(function () {
|
|
138
|
+
syncBlockStore.sourceManager.registerCreationCallback(function () {
|
|
138
139
|
var _api$core;
|
|
139
140
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function () {
|
|
140
141
|
return tr.setMeta('isCommitSyncBlockCreation', true);
|
|
@@ -177,7 +178,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
177
178
|
trs.filter(function (tr) {
|
|
178
179
|
return tr.docChanged;
|
|
179
180
|
}).forEach(function (tr) {
|
|
180
|
-
syncBlockStore === null || syncBlockStore === void 0 || syncBlockStore.rebaseTransaction(tr, newState);
|
|
181
|
+
syncBlockStore === null || syncBlockStore === void 0 || syncBlockStore.sourceManager.rebaseTransaction(tr, newState);
|
|
181
182
|
});
|
|
182
183
|
return null;
|
|
183
184
|
}
|
|
@@ -54,7 +54,7 @@ var DeleteConfirmationModal = exports.DeleteConfirmationModal = function DeleteC
|
|
|
54
54
|
return confirmedPromise;
|
|
55
55
|
}, []);
|
|
56
56
|
(0, _react.useEffect)(function () {
|
|
57
|
-
var unregister = syncBlockStoreManager.registerConfirmationCallback(confirmationCallback);
|
|
57
|
+
var unregister = syncBlockStoreManager.sourceManager.registerConfirmationCallback(confirmationCallback);
|
|
58
58
|
return function () {
|
|
59
59
|
unregister();
|
|
60
60
|
};
|
|
@@ -27,7 +27,7 @@ var SyncBlockRefresher = exports.SyncBlockRefresher = function SyncBlockRefreshe
|
|
|
27
27
|
var _document;
|
|
28
28
|
// check if document is visible to avoid unnecessary refreshes
|
|
29
29
|
if (((_document = document) === null || _document === void 0 ? void 0 : _document.visibilityState) === 'visible') {
|
|
30
|
-
syncBlockStoreManager.refreshSubscriptions();
|
|
30
|
+
syncBlockStoreManager.referenceManager.refreshSubscriptions();
|
|
31
31
|
}
|
|
32
32
|
}, SYNC_BLOCK_FETCH_INTERVAL);
|
|
33
33
|
} else if (interval !== -1) {
|
|
@@ -50,7 +50,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
|
|
|
50
50
|
onClick: _editorCommands.copySyncedBlockReferenceToClipboard
|
|
51
51
|
}, hoverDecorationProps(nodeType, _consts.akEditorSelectedNodeClassName));
|
|
52
52
|
items.push(copyButton);
|
|
53
|
-
var disabled = !syncBlockStore.getSyncBlockURL(syncBlockObject.node.attrs.resourceId);
|
|
53
|
+
var disabled = !syncBlockStore.referenceManager.getSyncBlockURL(syncBlockObject.node.attrs.resourceId);
|
|
54
54
|
if (!isBodiedSyncBlock) {
|
|
55
55
|
var editSourceButton = _objectSpread({
|
|
56
56
|
id: 'editor.syncedBlock.editSource',
|
|
@@ -19,7 +19,7 @@ export const createSyncedBlock = ({
|
|
|
19
19
|
|
|
20
20
|
// If the selection is empty, we want to insert the sync block on a new line
|
|
21
21
|
if (tr.selection.empty) {
|
|
22
|
-
const attrs = syncBlockStore.generateBodiedSyncBlockAttrs();
|
|
22
|
+
const attrs = syncBlockStore.sourceManager.generateBodiedSyncBlockAttrs();
|
|
23
23
|
const paragraphNode = paragraph.createAndFill({});
|
|
24
24
|
const newBodiedSyncBlockNode = bodiedSyncBlock.createAndFill(attrs, paragraphNode ? [paragraphNode] : []);
|
|
25
25
|
if (!newBodiedSyncBlockNode) {
|
|
@@ -28,7 +28,7 @@ export const createSyncedBlock = ({
|
|
|
28
28
|
|
|
29
29
|
// Save the new node with empty content to backend
|
|
30
30
|
// This is so that the node can be copied and referenced without the source being saved/published
|
|
31
|
-
syncBlockStore.createBodiedSyncBlockNode(attrs);
|
|
31
|
+
syncBlockStore.sourceManager.createBodiedSyncBlockNode(attrs);
|
|
32
32
|
if (typeAheadInsert) {
|
|
33
33
|
tr = typeAheadInsert(newBodiedSyncBlockNode);
|
|
34
34
|
} else {
|
|
@@ -40,7 +40,7 @@ export const createSyncedBlock = ({
|
|
|
40
40
|
// TODO: EDITOR-1665 - Raise an error analytics event
|
|
41
41
|
return false;
|
|
42
42
|
}
|
|
43
|
-
const attrs = syncBlockStore.generateBodiedSyncBlockAttrs();
|
|
43
|
+
const attrs = syncBlockStore.sourceManager.generateBodiedSyncBlockAttrs();
|
|
44
44
|
const newBodiedSyncBlockNode = bodiedSyncBlock.createAndFill(attrs, conversionInfo.contentToInclude);
|
|
45
45
|
if (!newBodiedSyncBlockNode) {
|
|
46
46
|
return false;
|
|
@@ -48,7 +48,7 @@ export const createSyncedBlock = ({
|
|
|
48
48
|
|
|
49
49
|
// Save the new node with empty content to backend
|
|
50
50
|
// This is so that the node can be copied and referenced without the source being saved/published
|
|
51
|
-
syncBlockStore.createBodiedSyncBlockNode(attrs);
|
|
51
|
+
syncBlockStore.sourceManager.createBodiedSyncBlockNode(attrs);
|
|
52
52
|
tr.replaceWith(conversionInfo.from > 0 ? conversionInfo.from - 1 : 0, conversionInfo.to, newBodiedSyncBlockNode).scrollIntoView();
|
|
53
53
|
|
|
54
54
|
// set selection to the end of the previous selection + 1 for the position taken up by the start of the new synced block
|
|
@@ -108,7 +108,7 @@ export const editSyncedBlockSource = (syncBlockStore, api) => (state, dispatch,
|
|
|
108
108
|
if (!resourceId) {
|
|
109
109
|
return false;
|
|
110
110
|
}
|
|
111
|
-
const syncBlockURL = syncBlockStore.getSyncBlockURL(resourceId);
|
|
111
|
+
const syncBlockURL = syncBlockStore.referenceManager.getSyncBlockURL(resourceId);
|
|
112
112
|
if (syncBlockURL) {
|
|
113
113
|
window.open(syncBlockURL, '_blank');
|
|
114
114
|
} else {
|
|
@@ -3,6 +3,7 @@ import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
|
|
|
3
3
|
import { BodiedSyncBlockSharedCssClassName, SyncBlockStateCssClassName } from '@atlaskit/editor-common/sync-block';
|
|
4
4
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
+
import { convertPMNodesToSyncBlockNodes } from '@atlaskit/editor-synced-block-provider';
|
|
6
7
|
import { lazyBodiedSyncBlockView } from '../nodeviews/bodiedLazySyncedBlock';
|
|
7
8
|
import { lazySyncBlockView } from '../nodeviews/lazySyncedBlock';
|
|
8
9
|
import { FLAG_ID } from '../types';
|
|
@@ -19,7 +20,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
19
20
|
state: {
|
|
20
21
|
init(_, instance) {
|
|
21
22
|
const syncBlockNodes = instance.doc.children.filter(node => node.type.name === 'syncBlock');
|
|
22
|
-
syncBlockStore.fetchSyncBlocksData(syncBlockNodes);
|
|
23
|
+
syncBlockStore.referenceManager.fetchSyncBlocksData(convertPMNodesToSyncBlockNodes(syncBlockNodes));
|
|
23
24
|
return {
|
|
24
25
|
selectionDecorationSet: calculateDecorations(instance.doc, instance.selection, instance.schema),
|
|
25
26
|
showFlag: false
|
|
@@ -94,10 +95,10 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
94
95
|
}
|
|
95
96
|
},
|
|
96
97
|
view: editorView => {
|
|
97
|
-
syncBlockStore.setEditorView(editorView);
|
|
98
|
+
syncBlockStore.sourceManager.setEditorView(editorView);
|
|
98
99
|
return {
|
|
99
100
|
destroy() {
|
|
100
|
-
syncBlockStore.setEditorView(undefined);
|
|
101
|
+
syncBlockStore.sourceManager.setEditorView(undefined);
|
|
101
102
|
}
|
|
102
103
|
};
|
|
103
104
|
},
|
|
@@ -109,27 +110,27 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
109
110
|
// or are from remote (collab) or already confirmed sync block deletion
|
|
110
111
|
// We only care about local changes that change the document
|
|
111
112
|
// and are not yet confirmed for sync block deletion
|
|
112
|
-
if (!tr.docChanged || !(syncBlockStore !== null && syncBlockStore !== void 0 && syncBlockStore.requireConfirmationBeforeDelete()) && !syncBlockStore.hasPendingCreation() || Boolean(tr.getMeta('isRemote')) || Boolean(tr.getMeta('isCommitSyncBlockCreation')) || !isOffline && isConfirmedSyncBlockDeletion) {
|
|
113
|
+
if (!tr.docChanged || !(syncBlockStore !== null && syncBlockStore !== void 0 && syncBlockStore.sourceManager.requireConfirmationBeforeDelete()) && !syncBlockStore.sourceManager.hasPendingCreation() || Boolean(tr.getMeta('isRemote')) || Boolean(tr.getMeta('isCommitSyncBlockCreation')) || !isOffline && isConfirmedSyncBlockDeletion) {
|
|
113
114
|
return true;
|
|
114
115
|
}
|
|
115
116
|
const {
|
|
116
117
|
removed: bodiedSyncBlockRemoved,
|
|
117
118
|
added: bodiedSyncBlockAdded
|
|
118
|
-
} = trackSyncBlocks(syncBlockStore.isSourceBlock, tr, state);
|
|
119
|
+
} = trackSyncBlocks(syncBlockStore.sourceManager.isSourceBlock, tr, state);
|
|
119
120
|
if (!isOffline) {
|
|
120
121
|
if (bodiedSyncBlockRemoved.length > 0) {
|
|
121
122
|
// If there are source sync blocks being removed, and we need to confirm with user before deleting,
|
|
122
123
|
// we block the transaction here, and wait for user confirmation to proceed with deletion.
|
|
123
124
|
// See editor-common/src/sync-block/sync-block-store-manager.ts for how we handle user confirmation and
|
|
124
125
|
// proceed with deletion.
|
|
125
|
-
syncBlockStore.deleteSyncBlocksWithConfirmation(tr, bodiedSyncBlockRemoved);
|
|
126
|
+
syncBlockStore.sourceManager.deleteSyncBlocksWithConfirmation(tr, bodiedSyncBlockRemoved);
|
|
126
127
|
return false;
|
|
127
128
|
}
|
|
128
129
|
if (bodiedSyncBlockAdded.length > 0) {
|
|
129
130
|
// If there is bodiedSyncBlock node addition and it's waiting for the result of saving the node to backend (syncBlockStore.hasPendingCreation()),
|
|
130
131
|
// we need to intercept the transaction and save it in insert callback so that we only insert it to the document when backend call if backend call is successful
|
|
131
132
|
// The callback will be evoked by in SourceSyncBlockStoreManager.commitPendingCreation
|
|
132
|
-
syncBlockStore.registerCreationCallback(() => {
|
|
133
|
+
syncBlockStore.sourceManager.registerCreationCallback(() => {
|
|
133
134
|
var _api$core;
|
|
134
135
|
api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(() => {
|
|
135
136
|
return tr.setMeta('isCommitSyncBlockCreation', true);
|
|
@@ -170,7 +171,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
170
171
|
},
|
|
171
172
|
appendTransaction: (trs, _oldState, newState) => {
|
|
172
173
|
trs.filter(tr => tr.docChanged).forEach(tr => {
|
|
173
|
-
syncBlockStore === null || syncBlockStore === void 0 ? void 0 : syncBlockStore.rebaseTransaction(tr, newState);
|
|
174
|
+
syncBlockStore === null || syncBlockStore === void 0 ? void 0 : syncBlockStore.sourceManager.rebaseTransaction(tr, newState);
|
|
174
175
|
});
|
|
175
176
|
return null;
|
|
176
177
|
}
|
|
@@ -39,7 +39,7 @@ export const DeleteConfirmationModal = ({
|
|
|
39
39
|
return confirmedPromise;
|
|
40
40
|
}, []);
|
|
41
41
|
useEffect(() => {
|
|
42
|
-
const unregister = syncBlockStoreManager.registerConfirmationCallback(confirmationCallback);
|
|
42
|
+
const unregister = syncBlockStoreManager.sourceManager.registerConfirmationCallback(confirmationCallback);
|
|
43
43
|
return () => {
|
|
44
44
|
unregister();
|
|
45
45
|
};
|
|
@@ -23,7 +23,7 @@ export const SyncBlockRefresher = ({
|
|
|
23
23
|
var _document;
|
|
24
24
|
// check if document is visible to avoid unnecessary refreshes
|
|
25
25
|
if (((_document = document) === null || _document === void 0 ? void 0 : _document.visibilityState) === 'visible') {
|
|
26
|
-
syncBlockStoreManager.refreshSubscriptions();
|
|
26
|
+
syncBlockStoreManager.referenceManager.refreshSubscriptions();
|
|
27
27
|
}
|
|
28
28
|
}, SYNC_BLOCK_FETCH_INTERVAL);
|
|
29
29
|
} else if (interval !== -1) {
|
|
@@ -45,7 +45,7 @@ export const getToolbarConfig = (state, intl, api, syncBlockStore) => {
|
|
|
45
45
|
...hoverDecorationProps(nodeType, akEditorSelectedNodeClassName)
|
|
46
46
|
};
|
|
47
47
|
items.push(copyButton);
|
|
48
|
-
const disabled = !syncBlockStore.getSyncBlockURL(syncBlockObject.node.attrs.resourceId);
|
|
48
|
+
const disabled = !syncBlockStore.referenceManager.getSyncBlockURL(syncBlockObject.node.attrs.resourceId);
|
|
49
49
|
if (!isBodiedSyncBlock) {
|
|
50
50
|
const editSourceButton = {
|
|
51
51
|
id: 'editor.syncedBlock.editSource',
|
|
@@ -13,7 +13,7 @@ export var createSyncedBlock = function createSyncedBlock(_ref) {
|
|
|
13
13
|
|
|
14
14
|
// If the selection is empty, we want to insert the sync block on a new line
|
|
15
15
|
if (tr.selection.empty) {
|
|
16
|
-
var attrs = syncBlockStore.generateBodiedSyncBlockAttrs();
|
|
16
|
+
var attrs = syncBlockStore.sourceManager.generateBodiedSyncBlockAttrs();
|
|
17
17
|
var paragraphNode = paragraph.createAndFill({});
|
|
18
18
|
var newBodiedSyncBlockNode = bodiedSyncBlock.createAndFill(attrs, paragraphNode ? [paragraphNode] : []);
|
|
19
19
|
if (!newBodiedSyncBlockNode) {
|
|
@@ -22,7 +22,7 @@ export var createSyncedBlock = function createSyncedBlock(_ref) {
|
|
|
22
22
|
|
|
23
23
|
// Save the new node with empty content to backend
|
|
24
24
|
// This is so that the node can be copied and referenced without the source being saved/published
|
|
25
|
-
syncBlockStore.createBodiedSyncBlockNode(attrs);
|
|
25
|
+
syncBlockStore.sourceManager.createBodiedSyncBlockNode(attrs);
|
|
26
26
|
if (typeAheadInsert) {
|
|
27
27
|
tr = typeAheadInsert(newBodiedSyncBlockNode);
|
|
28
28
|
} else {
|
|
@@ -34,7 +34,7 @@ export var createSyncedBlock = function createSyncedBlock(_ref) {
|
|
|
34
34
|
// TODO: EDITOR-1665 - Raise an error analytics event
|
|
35
35
|
return false;
|
|
36
36
|
}
|
|
37
|
-
var _attrs = syncBlockStore.generateBodiedSyncBlockAttrs();
|
|
37
|
+
var _attrs = syncBlockStore.sourceManager.generateBodiedSyncBlockAttrs();
|
|
38
38
|
var _newBodiedSyncBlockNode = bodiedSyncBlock.createAndFill(_attrs, conversionInfo.contentToInclude);
|
|
39
39
|
if (!_newBodiedSyncBlockNode) {
|
|
40
40
|
return false;
|
|
@@ -42,7 +42,7 @@ export var createSyncedBlock = function createSyncedBlock(_ref) {
|
|
|
42
42
|
|
|
43
43
|
// Save the new node with empty content to backend
|
|
44
44
|
// This is so that the node can be copied and referenced without the source being saved/published
|
|
45
|
-
syncBlockStore.createBodiedSyncBlockNode(_attrs);
|
|
45
|
+
syncBlockStore.sourceManager.createBodiedSyncBlockNode(_attrs);
|
|
46
46
|
tr.replaceWith(conversionInfo.from > 0 ? conversionInfo.from - 1 : 0, conversionInfo.to, _newBodiedSyncBlockNode).scrollIntoView();
|
|
47
47
|
|
|
48
48
|
// set selection to the end of the previous selection + 1 for the position taken up by the start of the new synced block
|
|
@@ -98,7 +98,7 @@ export var editSyncedBlockSource = function editSyncedBlockSource(syncBlockStore
|
|
|
98
98
|
if (!resourceId) {
|
|
99
99
|
return false;
|
|
100
100
|
}
|
|
101
|
-
var syncBlockURL = syncBlockStore.getSyncBlockURL(resourceId);
|
|
101
|
+
var syncBlockURL = syncBlockStore.referenceManager.getSyncBlockURL(resourceId);
|
|
102
102
|
if (syncBlockURL) {
|
|
103
103
|
window.open(syncBlockURL, '_blank');
|
|
104
104
|
} else {
|
|
@@ -3,6 +3,7 @@ import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
|
|
|
3
3
|
import { BodiedSyncBlockSharedCssClassName, SyncBlockStateCssClassName } from '@atlaskit/editor-common/sync-block';
|
|
4
4
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
+
import { convertPMNodesToSyncBlockNodes } from '@atlaskit/editor-synced-block-provider';
|
|
6
7
|
import { lazyBodiedSyncBlockView } from '../nodeviews/bodiedLazySyncedBlock';
|
|
7
8
|
import { lazySyncBlockView } from '../nodeviews/lazySyncedBlock';
|
|
8
9
|
import { FLAG_ID } from '../types';
|
|
@@ -21,7 +22,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
21
22
|
var syncBlockNodes = instance.doc.children.filter(function (node) {
|
|
22
23
|
return node.type.name === 'syncBlock';
|
|
23
24
|
});
|
|
24
|
-
syncBlockStore.fetchSyncBlocksData(syncBlockNodes);
|
|
25
|
+
syncBlockStore.referenceManager.fetchSyncBlocksData(convertPMNodesToSyncBlockNodes(syncBlockNodes));
|
|
25
26
|
return {
|
|
26
27
|
selectionDecorationSet: calculateDecorations(instance.doc, instance.selection, instance.schema),
|
|
27
28
|
showFlag: false
|
|
@@ -94,10 +95,10 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
94
95
|
}
|
|
95
96
|
},
|
|
96
97
|
view: function view(editorView) {
|
|
97
|
-
syncBlockStore.setEditorView(editorView);
|
|
98
|
+
syncBlockStore.sourceManager.setEditorView(editorView);
|
|
98
99
|
return {
|
|
99
100
|
destroy: function destroy() {
|
|
100
|
-
syncBlockStore.setEditorView(undefined);
|
|
101
|
+
syncBlockStore.sourceManager.setEditorView(undefined);
|
|
101
102
|
}
|
|
102
103
|
};
|
|
103
104
|
},
|
|
@@ -109,10 +110,10 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
109
110
|
// or are from remote (collab) or already confirmed sync block deletion
|
|
110
111
|
// We only care about local changes that change the document
|
|
111
112
|
// and are not yet confirmed for sync block deletion
|
|
112
|
-
if (!tr.docChanged || !(syncBlockStore !== null && syncBlockStore !== void 0 && syncBlockStore.requireConfirmationBeforeDelete()) && !syncBlockStore.hasPendingCreation() || Boolean(tr.getMeta('isRemote')) || Boolean(tr.getMeta('isCommitSyncBlockCreation')) || !isOffline && isConfirmedSyncBlockDeletion) {
|
|
113
|
+
if (!tr.docChanged || !(syncBlockStore !== null && syncBlockStore !== void 0 && syncBlockStore.sourceManager.requireConfirmationBeforeDelete()) && !syncBlockStore.sourceManager.hasPendingCreation() || Boolean(tr.getMeta('isRemote')) || Boolean(tr.getMeta('isCommitSyncBlockCreation')) || !isOffline && isConfirmedSyncBlockDeletion) {
|
|
113
114
|
return true;
|
|
114
115
|
}
|
|
115
|
-
var _trackSyncBlocks = trackSyncBlocks(syncBlockStore.isSourceBlock, tr, state),
|
|
116
|
+
var _trackSyncBlocks = trackSyncBlocks(syncBlockStore.sourceManager.isSourceBlock, tr, state),
|
|
116
117
|
bodiedSyncBlockRemoved = _trackSyncBlocks.removed,
|
|
117
118
|
bodiedSyncBlockAdded = _trackSyncBlocks.added;
|
|
118
119
|
if (!isOffline) {
|
|
@@ -121,14 +122,14 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
121
122
|
// we block the transaction here, and wait for user confirmation to proceed with deletion.
|
|
122
123
|
// See editor-common/src/sync-block/sync-block-store-manager.ts for how we handle user confirmation and
|
|
123
124
|
// proceed with deletion.
|
|
124
|
-
syncBlockStore.deleteSyncBlocksWithConfirmation(tr, bodiedSyncBlockRemoved);
|
|
125
|
+
syncBlockStore.sourceManager.deleteSyncBlocksWithConfirmation(tr, bodiedSyncBlockRemoved);
|
|
125
126
|
return false;
|
|
126
127
|
}
|
|
127
128
|
if (bodiedSyncBlockAdded.length > 0) {
|
|
128
129
|
// If there is bodiedSyncBlock node addition and it's waiting for the result of saving the node to backend (syncBlockStore.hasPendingCreation()),
|
|
129
130
|
// we need to intercept the transaction and save it in insert callback so that we only insert it to the document when backend call if backend call is successful
|
|
130
131
|
// The callback will be evoked by in SourceSyncBlockStoreManager.commitPendingCreation
|
|
131
|
-
syncBlockStore.registerCreationCallback(function () {
|
|
132
|
+
syncBlockStore.sourceManager.registerCreationCallback(function () {
|
|
132
133
|
var _api$core;
|
|
133
134
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function () {
|
|
134
135
|
return tr.setMeta('isCommitSyncBlockCreation', true);
|
|
@@ -171,7 +172,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
171
172
|
trs.filter(function (tr) {
|
|
172
173
|
return tr.docChanged;
|
|
173
174
|
}).forEach(function (tr) {
|
|
174
|
-
syncBlockStore === null || syncBlockStore === void 0 || syncBlockStore.rebaseTransaction(tr, newState);
|
|
175
|
+
syncBlockStore === null || syncBlockStore === void 0 || syncBlockStore.sourceManager.rebaseTransaction(tr, newState);
|
|
175
176
|
});
|
|
176
177
|
return null;
|
|
177
178
|
}
|
|
@@ -45,7 +45,7 @@ export var DeleteConfirmationModal = function DeleteConfirmationModal(_ref) {
|
|
|
45
45
|
return confirmedPromise;
|
|
46
46
|
}, []);
|
|
47
47
|
useEffect(function () {
|
|
48
|
-
var unregister = syncBlockStoreManager.registerConfirmationCallback(confirmationCallback);
|
|
48
|
+
var unregister = syncBlockStoreManager.sourceManager.registerConfirmationCallback(confirmationCallback);
|
|
49
49
|
return function () {
|
|
50
50
|
unregister();
|
|
51
51
|
};
|
|
@@ -21,7 +21,7 @@ export var SyncBlockRefresher = function SyncBlockRefresher(_ref) {
|
|
|
21
21
|
var _document;
|
|
22
22
|
// check if document is visible to avoid unnecessary refreshes
|
|
23
23
|
if (((_document = document) === null || _document === void 0 ? void 0 : _document.visibilityState) === 'visible') {
|
|
24
|
-
syncBlockStoreManager.refreshSubscriptions();
|
|
24
|
+
syncBlockStoreManager.referenceManager.refreshSubscriptions();
|
|
25
25
|
}
|
|
26
26
|
}, SYNC_BLOCK_FETCH_INTERVAL);
|
|
27
27
|
} else if (interval !== -1) {
|
|
@@ -41,7 +41,7 @@ export var getToolbarConfig = function getToolbarConfig(state, intl, api, syncBl
|
|
|
41
41
|
onClick: copySyncedBlockReferenceToClipboard
|
|
42
42
|
}, hoverDecorationProps(nodeType, akEditorSelectedNodeClassName));
|
|
43
43
|
items.push(copyButton);
|
|
44
|
-
var disabled = !syncBlockStore.getSyncBlockURL(syncBlockObject.node.attrs.resourceId);
|
|
44
|
+
var disabled = !syncBlockStore.referenceManager.getSyncBlockURL(syncBlockObject.node.attrs.resourceId);
|
|
45
45
|
if (!isBodiedSyncBlock) {
|
|
46
46
|
var editSourceButton = _objectSpread({
|
|
47
47
|
id: 'editor.syncedBlock.editSource',
|
|
@@ -2,7 +2,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
2
2
|
import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
|
|
3
3
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
-
import type
|
|
5
|
+
import { type SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
6
6
|
import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlockPluginType';
|
|
7
7
|
import { FLAG_ID } from '../types';
|
|
8
8
|
export declare const syncedBlockPluginKey: PluginKey<any>;
|
|
@@ -2,7 +2,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
2
2
|
import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
|
|
3
3
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
-
import type
|
|
5
|
+
import { type SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
6
6
|
import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlockPluginType';
|
|
7
7
|
import { FLAG_ID } from '../types';
|
|
8
8
|
export declare const syncedBlockPluginKey: PluginKey<any>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-synced-block",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.14",
|
|
4
4
|
"description": "SyncedBlock plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@atlaskit/editor-common": "^110.
|
|
59
|
+
"@atlaskit/editor-common": "^110.33.0",
|
|
60
60
|
"react": "^18.2.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|