@atlaskit/editor-plugin-synced-block 4.3.10 → 4.3.12
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 +16 -0
- package/dist/cjs/pm-plugins/main.js +24 -28
- package/dist/es2019/pm-plugins/main.js +23 -27
- package/dist/esm/pm-plugins/main.js +25 -29
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 4.3.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`48a3dd84c602b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/48a3dd84c602b) -
|
|
8
|
+
[EDITOR-3394] Decouple editorView from source manager
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 4.3.11
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`55920a92e882a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/55920a92e882a) -
|
|
16
|
+
tsignores added for help-center local consumpton removed
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 4.3.10
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -25,10 +25,10 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
25
25
|
var _ref = options || {},
|
|
26
26
|
_ref$useLongPressSele = _ref.useLongPressSelection,
|
|
27
27
|
useLongPressSelection = _ref$useLongPressSele === void 0 ? false : _ref$useLongPressSele;
|
|
28
|
+
var confirmationTransaction;
|
|
28
29
|
return new _safePlugin.SafePlugin({
|
|
29
30
|
key: syncedBlockPluginKey,
|
|
30
31
|
state: {
|
|
31
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
32
32
|
init: function init(_, instance) {
|
|
33
33
|
var syncBlockNodes = instance.doc.children.filter(function (node) {
|
|
34
34
|
return node.type.name === 'syncBlock';
|
|
@@ -40,7 +40,6 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
40
40
|
syncBlockStore: syncBlockStore
|
|
41
41
|
};
|
|
42
42
|
},
|
|
43
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
44
43
|
apply: function apply(tr, currentPluginState, oldEditorState) {
|
|
45
44
|
var _meta$showFlag;
|
|
46
45
|
var meta = tr.getMeta(syncedBlockPluginKey);
|
|
@@ -70,7 +69,6 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
70
69
|
api: api
|
|
71
70
|
})
|
|
72
71
|
},
|
|
73
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
74
72
|
decorations: function decorations(state) {
|
|
75
73
|
var _syncedBlockPluginKey, _syncedBlockPluginKey2, _api$connectivity, _api$editorViewMode;
|
|
76
74
|
var selectionDecorationSet = (_syncedBlockPluginKey = (_syncedBlockPluginKey2 = syncedBlockPluginKey.getState(state)) === null || _syncedBlockPluginKey2 === void 0 ? void 0 : _syncedBlockPluginKey2.selectionDecorationSet) !== null && _syncedBlockPluginKey !== void 0 ? _syncedBlockPluginKey : _view.DecorationSet.empty;
|
|
@@ -79,8 +77,6 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
79
77
|
var isViewMode = (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'view';
|
|
80
78
|
var offlineDecorations = [];
|
|
81
79
|
var viewModeDecorations = [];
|
|
82
|
-
|
|
83
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
84
80
|
state.doc.descendants(function (node, pos) {
|
|
85
81
|
if (node.type.name === 'bodiedSyncBlock' && isOffline) {
|
|
86
82
|
offlineDecorations.push(_view.Decoration.node(pos, pos + node.nodeSize, {
|
|
@@ -101,25 +97,14 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
101
97
|
useLongPressSelection: useLongPressSelection
|
|
102
98
|
}),
|
|
103
99
|
handleDOMEvents: {
|
|
104
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
105
100
|
mouseover: function mouseover(view, event) {
|
|
106
101
|
return (0, _ignoreDomEvent.shouldIgnoreDomEvent)(view, event, api);
|
|
107
102
|
},
|
|
108
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
109
103
|
mousedown: function mousedown(view, event) {
|
|
110
104
|
return (0, _ignoreDomEvent.shouldIgnoreDomEvent)(view, event, api);
|
|
111
105
|
}
|
|
112
106
|
}
|
|
113
107
|
},
|
|
114
|
-
view: function view(editorView) {
|
|
115
|
-
syncBlockStore.sourceManager.setEditorView(editorView);
|
|
116
|
-
return {
|
|
117
|
-
destroy: function destroy() {
|
|
118
|
-
syncBlockStore.sourceManager.setEditorView(undefined);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
},
|
|
122
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
123
108
|
filterTransaction: function filterTransaction(tr, state) {
|
|
124
109
|
var _api$connectivity2;
|
|
125
110
|
var isOffline = (api === null || api === void 0 || (_api$connectivity2 = api.connectivity) === null || _api$connectivity2 === void 0 || (_api$connectivity2 = _api$connectivity2.sharedState.currentState()) === null || _api$connectivity2 === void 0 ? void 0 : _api$connectivity2.mode) === 'offline';
|
|
@@ -140,9 +125,23 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
140
125
|
// we block the transaction here, and wait for user confirmation to proceed with deletion.
|
|
141
126
|
// See editor-common/src/sync-block/sync-block-store-manager.ts for how we handle user confirmation and
|
|
142
127
|
// proceed with deletion.
|
|
143
|
-
|
|
128
|
+
confirmationTransaction = tr;
|
|
129
|
+
syncBlockStore.sourceManager.deleteSyncBlocksWithConfirmation(bodiedSyncBlockRemoved.map(function (node) {
|
|
144
130
|
return node.attrs;
|
|
145
|
-
}))
|
|
131
|
+
}), function () {
|
|
132
|
+
var _api$core;
|
|
133
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function () {
|
|
134
|
+
var trToDispatch = tr.setMeta('isConfirmedSyncBlockDeletion', true);
|
|
135
|
+
if (!trToDispatch.getMeta(_utils.pmHistoryPluginKey)) {
|
|
136
|
+
// bodiedSyncBlock deletion is expected to be permanent (cannot undo)
|
|
137
|
+
// For a normal deletion (not triggered by undo), remove it from history so that it cannot be undone
|
|
138
|
+
trToDispatch.setMeta('addToHistory', false);
|
|
139
|
+
}
|
|
140
|
+
return trToDispatch;
|
|
141
|
+
});
|
|
142
|
+
}).finally(function () {
|
|
143
|
+
confirmationTransaction = undefined;
|
|
144
|
+
});
|
|
146
145
|
return false;
|
|
147
146
|
}
|
|
148
147
|
if (bodiedSyncBlockAdded.length > 0) {
|
|
@@ -157,8 +156,8 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
157
156
|
// 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
|
|
158
157
|
// The callback will be evoked by in SourceSyncBlockStoreManager.commitPendingCreation
|
|
159
158
|
syncBlockStore.sourceManager.registerCreationCallback(function () {
|
|
160
|
-
var _api$
|
|
161
|
-
api === null || api === void 0 || (_api$
|
|
159
|
+
var _api$core2;
|
|
160
|
+
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function () {
|
|
162
161
|
return tr.setMeta('isCommitSyncBlockCreation', true);
|
|
163
162
|
});
|
|
164
163
|
api === null || api === void 0 || api.core.actions.focus();
|
|
@@ -196,16 +195,13 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
196
195
|
}
|
|
197
196
|
return true;
|
|
198
197
|
},
|
|
199
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
200
198
|
appendTransaction: function appendTransaction(trs, oldState, newState) {
|
|
201
|
-
trs
|
|
202
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
203
|
-
.filter(function (tr) {
|
|
199
|
+
trs.filter(function (tr) {
|
|
204
200
|
return tr.docChanged;
|
|
205
|
-
})
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
201
|
+
}).forEach(function (tr) {
|
|
202
|
+
if (confirmationTransaction) {
|
|
203
|
+
confirmationTransaction = (0, _editorSyncedBlockProvider.rebaseTransaction)(confirmationTransaction, tr, newState);
|
|
204
|
+
}
|
|
209
205
|
});
|
|
210
206
|
var _iterator = _createForOfIteratorHelper(trs),
|
|
211
207
|
_step;
|
|
@@ -4,7 +4,7 @@ import { BodiedSyncBlockSharedCssClassName, SyncBlockStateCssClassName } from '@
|
|
|
4
4
|
import { pmHistoryPluginKey } from '@atlaskit/editor-common/utils';
|
|
5
5
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
7
|
-
import { convertPMNodesToSyncBlockNodes } from '@atlaskit/editor-synced-block-provider';
|
|
7
|
+
import { convertPMNodesToSyncBlockNodes, rebaseTransaction } from '@atlaskit/editor-synced-block-provider';
|
|
8
8
|
import { lazyBodiedSyncBlockView } from '../nodeviews/bodiedLazySyncedBlock';
|
|
9
9
|
import { lazySyncBlockView } from '../nodeviews/lazySyncedBlock';
|
|
10
10
|
import { FLAG_ID } from '../types';
|
|
@@ -16,10 +16,10 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
16
16
|
const {
|
|
17
17
|
useLongPressSelection = false
|
|
18
18
|
} = options || {};
|
|
19
|
+
let confirmationTransaction;
|
|
19
20
|
return new SafePlugin({
|
|
20
21
|
key: syncedBlockPluginKey,
|
|
21
22
|
state: {
|
|
22
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
23
23
|
init(_, instance) {
|
|
24
24
|
const syncBlockNodes = instance.doc.children.filter(node => node.type.name === 'syncBlock');
|
|
25
25
|
syncBlockStore.referenceManager.fetchSyncBlocksData(convertPMNodesToSyncBlockNodes(syncBlockNodes));
|
|
@@ -29,7 +29,6 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
29
29
|
syncBlockStore: syncBlockStore
|
|
30
30
|
};
|
|
31
31
|
},
|
|
32
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
33
32
|
apply: (tr, currentPluginState, oldEditorState) => {
|
|
34
33
|
var _meta$showFlag;
|
|
35
34
|
const meta = tr.getMeta(syncedBlockPluginKey);
|
|
@@ -61,7 +60,6 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
61
60
|
api
|
|
62
61
|
})
|
|
63
62
|
},
|
|
64
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
65
63
|
decorations: state => {
|
|
66
64
|
var _syncedBlockPluginKey, _syncedBlockPluginKey2, _api$connectivity, _api$connectivity$sha, _api$editorViewMode, _api$editorViewMode$s;
|
|
67
65
|
const selectionDecorationSet = (_syncedBlockPluginKey = (_syncedBlockPluginKey2 = syncedBlockPluginKey.getState(state)) === null || _syncedBlockPluginKey2 === void 0 ? void 0 : _syncedBlockPluginKey2.selectionDecorationSet) !== null && _syncedBlockPluginKey !== void 0 ? _syncedBlockPluginKey : DecorationSet.empty;
|
|
@@ -72,8 +70,6 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
72
70
|
const isViewMode = (api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : (_api$editorViewMode$s = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode$s === void 0 ? void 0 : _api$editorViewMode$s.mode) === 'view';
|
|
73
71
|
const offlineDecorations = [];
|
|
74
72
|
const viewModeDecorations = [];
|
|
75
|
-
|
|
76
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
77
73
|
state.doc.descendants((node, pos) => {
|
|
78
74
|
if (node.type.name === 'bodiedSyncBlock' && isOffline) {
|
|
79
75
|
offlineDecorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
@@ -92,25 +88,14 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
92
88
|
useLongPressSelection
|
|
93
89
|
}),
|
|
94
90
|
handleDOMEvents: {
|
|
95
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
96
91
|
mouseover(view, event) {
|
|
97
92
|
return shouldIgnoreDomEvent(view, event, api);
|
|
98
93
|
},
|
|
99
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
100
94
|
mousedown(view, event) {
|
|
101
95
|
return shouldIgnoreDomEvent(view, event, api);
|
|
102
96
|
}
|
|
103
97
|
}
|
|
104
98
|
},
|
|
105
|
-
view: editorView => {
|
|
106
|
-
syncBlockStore.sourceManager.setEditorView(editorView);
|
|
107
|
-
return {
|
|
108
|
-
destroy() {
|
|
109
|
-
syncBlockStore.sourceManager.setEditorView(undefined);
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
},
|
|
113
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
114
99
|
filterTransaction: (tr, state) => {
|
|
115
100
|
var _api$connectivity2, _api$connectivity2$sh;
|
|
116
101
|
const isOffline = (api === null || api === void 0 ? void 0 : (_api$connectivity2 = api.connectivity) === null || _api$connectivity2 === void 0 ? void 0 : (_api$connectivity2$sh = _api$connectivity2.sharedState.currentState()) === null || _api$connectivity2$sh === void 0 ? void 0 : _api$connectivity2$sh.mode) === 'offline';
|
|
@@ -132,7 +117,21 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
132
117
|
// we block the transaction here, and wait for user confirmation to proceed with deletion.
|
|
133
118
|
// See editor-common/src/sync-block/sync-block-store-manager.ts for how we handle user confirmation and
|
|
134
119
|
// proceed with deletion.
|
|
135
|
-
|
|
120
|
+
confirmationTransaction = tr;
|
|
121
|
+
syncBlockStore.sourceManager.deleteSyncBlocksWithConfirmation(bodiedSyncBlockRemoved.map(node => node.attrs), () => {
|
|
122
|
+
var _api$core;
|
|
123
|
+
api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(() => {
|
|
124
|
+
const trToDispatch = tr.setMeta('isConfirmedSyncBlockDeletion', true);
|
|
125
|
+
if (!trToDispatch.getMeta(pmHistoryPluginKey)) {
|
|
126
|
+
// bodiedSyncBlock deletion is expected to be permanent (cannot undo)
|
|
127
|
+
// For a normal deletion (not triggered by undo), remove it from history so that it cannot be undone
|
|
128
|
+
trToDispatch.setMeta('addToHistory', false);
|
|
129
|
+
}
|
|
130
|
+
return trToDispatch;
|
|
131
|
+
});
|
|
132
|
+
}).finally(() => {
|
|
133
|
+
confirmationTransaction = undefined;
|
|
134
|
+
});
|
|
136
135
|
return false;
|
|
137
136
|
}
|
|
138
137
|
if (bodiedSyncBlockAdded.length > 0) {
|
|
@@ -147,8 +146,8 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
147
146
|
// 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
|
|
148
147
|
// The callback will be evoked by in SourceSyncBlockStoreManager.commitPendingCreation
|
|
149
148
|
syncBlockStore.sourceManager.registerCreationCallback(() => {
|
|
150
|
-
var _api$
|
|
151
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
149
|
+
var _api$core2;
|
|
150
|
+
api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(() => {
|
|
152
151
|
return tr.setMeta('isCommitSyncBlockCreation', true);
|
|
153
152
|
});
|
|
154
153
|
api === null || api === void 0 ? void 0 : api.core.actions.focus();
|
|
@@ -186,14 +185,11 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
186
185
|
}
|
|
187
186
|
return true;
|
|
188
187
|
},
|
|
189
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
190
188
|
appendTransaction: (trs, oldState, newState) => {
|
|
191
|
-
trs
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
.forEach(tr => {
|
|
196
|
-
syncBlockStore === null || syncBlockStore === void 0 ? void 0 : syncBlockStore.sourceManager.rebaseTransaction(tr, newState);
|
|
189
|
+
trs.filter(tr => tr.docChanged).forEach(tr => {
|
|
190
|
+
if (confirmationTransaction) {
|
|
191
|
+
confirmationTransaction = rebaseTransaction(confirmationTransaction, tr, newState);
|
|
192
|
+
}
|
|
197
193
|
});
|
|
198
194
|
for (const tr of trs) {
|
|
199
195
|
if (!tr.getMeta(pmHistoryPluginKey)) {
|
|
@@ -7,7 +7,7 @@ import { BodiedSyncBlockSharedCssClassName, SyncBlockStateCssClassName } from '@
|
|
|
7
7
|
import { pmHistoryPluginKey } from '@atlaskit/editor-common/utils';
|
|
8
8
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
9
9
|
import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
10
|
-
import { convertPMNodesToSyncBlockNodes } from '@atlaskit/editor-synced-block-provider';
|
|
10
|
+
import { convertPMNodesToSyncBlockNodes, rebaseTransaction } from '@atlaskit/editor-synced-block-provider';
|
|
11
11
|
import { lazyBodiedSyncBlockView } from '../nodeviews/bodiedLazySyncedBlock';
|
|
12
12
|
import { lazySyncBlockView } from '../nodeviews/lazySyncedBlock';
|
|
13
13
|
import { FLAG_ID } from '../types';
|
|
@@ -19,10 +19,10 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
19
19
|
var _ref = options || {},
|
|
20
20
|
_ref$useLongPressSele = _ref.useLongPressSelection,
|
|
21
21
|
useLongPressSelection = _ref$useLongPressSele === void 0 ? false : _ref$useLongPressSele;
|
|
22
|
+
var confirmationTransaction;
|
|
22
23
|
return new SafePlugin({
|
|
23
24
|
key: syncedBlockPluginKey,
|
|
24
25
|
state: {
|
|
25
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
26
26
|
init: function init(_, instance) {
|
|
27
27
|
var syncBlockNodes = instance.doc.children.filter(function (node) {
|
|
28
28
|
return node.type.name === 'syncBlock';
|
|
@@ -34,7 +34,6 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
34
34
|
syncBlockStore: syncBlockStore
|
|
35
35
|
};
|
|
36
36
|
},
|
|
37
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
38
37
|
apply: function apply(tr, currentPluginState, oldEditorState) {
|
|
39
38
|
var _meta$showFlag;
|
|
40
39
|
var meta = tr.getMeta(syncedBlockPluginKey);
|
|
@@ -64,7 +63,6 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
64
63
|
api: api
|
|
65
64
|
})
|
|
66
65
|
},
|
|
67
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
68
66
|
decorations: function decorations(state) {
|
|
69
67
|
var _syncedBlockPluginKey, _syncedBlockPluginKey2, _api$connectivity, _api$editorViewMode;
|
|
70
68
|
var selectionDecorationSet = (_syncedBlockPluginKey = (_syncedBlockPluginKey2 = syncedBlockPluginKey.getState(state)) === null || _syncedBlockPluginKey2 === void 0 ? void 0 : _syncedBlockPluginKey2.selectionDecorationSet) !== null && _syncedBlockPluginKey !== void 0 ? _syncedBlockPluginKey : DecorationSet.empty;
|
|
@@ -73,8 +71,6 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
73
71
|
var isViewMode = (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'view';
|
|
74
72
|
var offlineDecorations = [];
|
|
75
73
|
var viewModeDecorations = [];
|
|
76
|
-
|
|
77
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
78
74
|
state.doc.descendants(function (node, pos) {
|
|
79
75
|
if (node.type.name === 'bodiedSyncBlock' && isOffline) {
|
|
80
76
|
offlineDecorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
@@ -95,25 +91,14 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
95
91
|
useLongPressSelection: useLongPressSelection
|
|
96
92
|
}),
|
|
97
93
|
handleDOMEvents: {
|
|
98
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
99
94
|
mouseover: function mouseover(view, event) {
|
|
100
95
|
return shouldIgnoreDomEvent(view, event, api);
|
|
101
96
|
},
|
|
102
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
103
97
|
mousedown: function mousedown(view, event) {
|
|
104
98
|
return shouldIgnoreDomEvent(view, event, api);
|
|
105
99
|
}
|
|
106
100
|
}
|
|
107
101
|
},
|
|
108
|
-
view: function view(editorView) {
|
|
109
|
-
syncBlockStore.sourceManager.setEditorView(editorView);
|
|
110
|
-
return {
|
|
111
|
-
destroy: function destroy() {
|
|
112
|
-
syncBlockStore.sourceManager.setEditorView(undefined);
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
},
|
|
116
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
117
102
|
filterTransaction: function filterTransaction(tr, state) {
|
|
118
103
|
var _api$connectivity2;
|
|
119
104
|
var isOffline = (api === null || api === void 0 || (_api$connectivity2 = api.connectivity) === null || _api$connectivity2 === void 0 || (_api$connectivity2 = _api$connectivity2.sharedState.currentState()) === null || _api$connectivity2 === void 0 ? void 0 : _api$connectivity2.mode) === 'offline';
|
|
@@ -134,9 +119,23 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
134
119
|
// we block the transaction here, and wait for user confirmation to proceed with deletion.
|
|
135
120
|
// See editor-common/src/sync-block/sync-block-store-manager.ts for how we handle user confirmation and
|
|
136
121
|
// proceed with deletion.
|
|
137
|
-
|
|
122
|
+
confirmationTransaction = tr;
|
|
123
|
+
syncBlockStore.sourceManager.deleteSyncBlocksWithConfirmation(bodiedSyncBlockRemoved.map(function (node) {
|
|
138
124
|
return node.attrs;
|
|
139
|
-
}))
|
|
125
|
+
}), function () {
|
|
126
|
+
var _api$core;
|
|
127
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function () {
|
|
128
|
+
var trToDispatch = tr.setMeta('isConfirmedSyncBlockDeletion', true);
|
|
129
|
+
if (!trToDispatch.getMeta(pmHistoryPluginKey)) {
|
|
130
|
+
// bodiedSyncBlock deletion is expected to be permanent (cannot undo)
|
|
131
|
+
// For a normal deletion (not triggered by undo), remove it from history so that it cannot be undone
|
|
132
|
+
trToDispatch.setMeta('addToHistory', false);
|
|
133
|
+
}
|
|
134
|
+
return trToDispatch;
|
|
135
|
+
});
|
|
136
|
+
}).finally(function () {
|
|
137
|
+
confirmationTransaction = undefined;
|
|
138
|
+
});
|
|
140
139
|
return false;
|
|
141
140
|
}
|
|
142
141
|
if (bodiedSyncBlockAdded.length > 0) {
|
|
@@ -151,8 +150,8 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
151
150
|
// 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
|
|
152
151
|
// The callback will be evoked by in SourceSyncBlockStoreManager.commitPendingCreation
|
|
153
152
|
syncBlockStore.sourceManager.registerCreationCallback(function () {
|
|
154
|
-
var _api$
|
|
155
|
-
api === null || api === void 0 || (_api$
|
|
153
|
+
var _api$core2;
|
|
154
|
+
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function () {
|
|
156
155
|
return tr.setMeta('isCommitSyncBlockCreation', true);
|
|
157
156
|
});
|
|
158
157
|
api === null || api === void 0 || api.core.actions.focus();
|
|
@@ -190,16 +189,13 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
190
189
|
}
|
|
191
190
|
return true;
|
|
192
191
|
},
|
|
193
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
194
192
|
appendTransaction: function appendTransaction(trs, oldState, newState) {
|
|
195
|
-
trs
|
|
196
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
197
|
-
.filter(function (tr) {
|
|
193
|
+
trs.filter(function (tr) {
|
|
198
194
|
return tr.docChanged;
|
|
199
|
-
})
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
195
|
+
}).forEach(function (tr) {
|
|
196
|
+
if (confirmationTransaction) {
|
|
197
|
+
confirmationTransaction = rebaseTransaction(confirmationTransaction, tr, newState);
|
|
198
|
+
}
|
|
203
199
|
});
|
|
204
200
|
var _iterator = _createForOfIteratorHelper(trs),
|
|
205
201
|
_step;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-synced-block",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.12",
|
|
4
4
|
"description": "SyncedBlock plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@atlaskit/button": "23.6.3",
|
|
33
33
|
"@atlaskit/editor-json-transformer": "^8.31.0",
|
|
34
34
|
"@atlaskit/editor-plugin-analytics": "^6.2.0",
|
|
35
|
-
"@atlaskit/editor-plugin-block-menu": "^5.
|
|
35
|
+
"@atlaskit/editor-plugin-block-menu": "^5.1.0",
|
|
36
36
|
"@atlaskit/editor-plugin-connectivity": "6.0.0",
|
|
37
37
|
"@atlaskit/editor-plugin-decorations": "^6.1.0",
|
|
38
38
|
"@atlaskit/editor-plugin-floating-toolbar": "^8.2.0",
|