@atlaskit/editor-plugin-synced-block 4.3.11 → 4.3.13
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 +22 -13
- package/dist/es2019/pm-plugins/main.js +22 -13
- package/dist/esm/pm-plugins/main.js +23 -14
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 4.3.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`e3779b75fdeca`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e3779b75fdeca) -
|
|
8
|
+
EDITOR-1643 Promote syncBlock and bodiedSyncBlock to full schema
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 4.3.12
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`48a3dd84c602b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/48a3dd84c602b) -
|
|
16
|
+
[EDITOR-3394] Decouple editorView from source manager
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 4.3.11
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -25,6 +25,7 @@ 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: {
|
|
@@ -104,14 +105,6 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
},
|
|
107
|
-
view: function view(editorView) {
|
|
108
|
-
syncBlockStore.sourceManager.setEditorView(editorView);
|
|
109
|
-
return {
|
|
110
|
-
destroy: function destroy() {
|
|
111
|
-
syncBlockStore.sourceManager.setEditorView(undefined);
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
},
|
|
115
108
|
filterTransaction: function filterTransaction(tr, state) {
|
|
116
109
|
var _api$connectivity2;
|
|
117
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';
|
|
@@ -132,9 +125,23 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
132
125
|
// we block the transaction here, and wait for user confirmation to proceed with deletion.
|
|
133
126
|
// See editor-common/src/sync-block/sync-block-store-manager.ts for how we handle user confirmation and
|
|
134
127
|
// proceed with deletion.
|
|
135
|
-
|
|
128
|
+
confirmationTransaction = tr;
|
|
129
|
+
syncBlockStore.sourceManager.deleteSyncBlocksWithConfirmation(bodiedSyncBlockRemoved.map(function (node) {
|
|
136
130
|
return node.attrs;
|
|
137
|
-
}))
|
|
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
|
+
});
|
|
138
145
|
return false;
|
|
139
146
|
}
|
|
140
147
|
if (bodiedSyncBlockAdded.length > 0) {
|
|
@@ -149,8 +156,8 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
149
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
|
|
150
157
|
// The callback will be evoked by in SourceSyncBlockStoreManager.commitPendingCreation
|
|
151
158
|
syncBlockStore.sourceManager.registerCreationCallback(function () {
|
|
152
|
-
var _api$
|
|
153
|
-
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 () {
|
|
154
161
|
return tr.setMeta('isCommitSyncBlockCreation', true);
|
|
155
162
|
});
|
|
156
163
|
api === null || api === void 0 || api.core.actions.focus();
|
|
@@ -192,7 +199,9 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
192
199
|
trs.filter(function (tr) {
|
|
193
200
|
return tr.docChanged;
|
|
194
201
|
}).forEach(function (tr) {
|
|
195
|
-
|
|
202
|
+
if (confirmationTransaction) {
|
|
203
|
+
confirmationTransaction = (0, _editorSyncedBlockProvider.rebaseTransaction)(confirmationTransaction, tr, newState);
|
|
204
|
+
}
|
|
196
205
|
});
|
|
197
206
|
var _iterator = _createForOfIteratorHelper(trs),
|
|
198
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,6 +16,7 @@ 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: {
|
|
@@ -95,14 +96,6 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
},
|
|
98
|
-
view: editorView => {
|
|
99
|
-
syncBlockStore.sourceManager.setEditorView(editorView);
|
|
100
|
-
return {
|
|
101
|
-
destroy() {
|
|
102
|
-
syncBlockStore.sourceManager.setEditorView(undefined);
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
},
|
|
106
99
|
filterTransaction: (tr, state) => {
|
|
107
100
|
var _api$connectivity2, _api$connectivity2$sh;
|
|
108
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';
|
|
@@ -124,7 +117,21 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
124
117
|
// we block the transaction here, and wait for user confirmation to proceed with deletion.
|
|
125
118
|
// See editor-common/src/sync-block/sync-block-store-manager.ts for how we handle user confirmation and
|
|
126
119
|
// proceed with deletion.
|
|
127
|
-
|
|
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
|
+
});
|
|
128
135
|
return false;
|
|
129
136
|
}
|
|
130
137
|
if (bodiedSyncBlockAdded.length > 0) {
|
|
@@ -139,8 +146,8 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
139
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
|
|
140
147
|
// The callback will be evoked by in SourceSyncBlockStoreManager.commitPendingCreation
|
|
141
148
|
syncBlockStore.sourceManager.registerCreationCallback(() => {
|
|
142
|
-
var _api$
|
|
143
|
-
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(() => {
|
|
144
151
|
return tr.setMeta('isCommitSyncBlockCreation', true);
|
|
145
152
|
});
|
|
146
153
|
api === null || api === void 0 ? void 0 : api.core.actions.focus();
|
|
@@ -180,7 +187,9 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
180
187
|
},
|
|
181
188
|
appendTransaction: (trs, oldState, newState) => {
|
|
182
189
|
trs.filter(tr => tr.docChanged).forEach(tr => {
|
|
183
|
-
|
|
190
|
+
if (confirmationTransaction) {
|
|
191
|
+
confirmationTransaction = rebaseTransaction(confirmationTransaction, tr, newState);
|
|
192
|
+
}
|
|
184
193
|
});
|
|
185
194
|
for (const tr of trs) {
|
|
186
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,6 +19,7 @@ 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: {
|
|
@@ -98,14 +99,6 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
},
|
|
101
|
-
view: function view(editorView) {
|
|
102
|
-
syncBlockStore.sourceManager.setEditorView(editorView);
|
|
103
|
-
return {
|
|
104
|
-
destroy: function destroy() {
|
|
105
|
-
syncBlockStore.sourceManager.setEditorView(undefined);
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
},
|
|
109
102
|
filterTransaction: function filterTransaction(tr, state) {
|
|
110
103
|
var _api$connectivity2;
|
|
111
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';
|
|
@@ -126,9 +119,23 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
126
119
|
// we block the transaction here, and wait for user confirmation to proceed with deletion.
|
|
127
120
|
// See editor-common/src/sync-block/sync-block-store-manager.ts for how we handle user confirmation and
|
|
128
121
|
// proceed with deletion.
|
|
129
|
-
|
|
122
|
+
confirmationTransaction = tr;
|
|
123
|
+
syncBlockStore.sourceManager.deleteSyncBlocksWithConfirmation(bodiedSyncBlockRemoved.map(function (node) {
|
|
130
124
|
return node.attrs;
|
|
131
|
-
}))
|
|
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
|
+
});
|
|
132
139
|
return false;
|
|
133
140
|
}
|
|
134
141
|
if (bodiedSyncBlockAdded.length > 0) {
|
|
@@ -143,8 +150,8 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
143
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
|
|
144
151
|
// The callback will be evoked by in SourceSyncBlockStoreManager.commitPendingCreation
|
|
145
152
|
syncBlockStore.sourceManager.registerCreationCallback(function () {
|
|
146
|
-
var _api$
|
|
147
|
-
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 () {
|
|
148
155
|
return tr.setMeta('isCommitSyncBlockCreation', true);
|
|
149
156
|
});
|
|
150
157
|
api === null || api === void 0 || api.core.actions.focus();
|
|
@@ -186,7 +193,9 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
186
193
|
trs.filter(function (tr) {
|
|
187
194
|
return tr.docChanged;
|
|
188
195
|
}).forEach(function (tr) {
|
|
189
|
-
|
|
196
|
+
if (confirmationTransaction) {
|
|
197
|
+
confirmationTransaction = rebaseTransaction(confirmationTransaction, tr, newState);
|
|
198
|
+
}
|
|
190
199
|
});
|
|
191
200
|
var _iterator = _createForOfIteratorHelper(trs),
|
|
192
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.13",
|
|
4
4
|
"description": "SyncedBlock plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"atlaskit:src": "src/index.ts",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@atlaskit/adf-schema": "^51.
|
|
31
|
+
"@atlaskit/adf-schema": "^51.5.1",
|
|
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",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@atlaskit/editor-plugin-selection": "^6.1.0",
|
|
40
40
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
41
41
|
"@atlaskit/editor-shared-styles": "^3.10.0",
|
|
42
|
-
"@atlaskit/editor-synced-block-provider": "^2.
|
|
42
|
+
"@atlaskit/editor-synced-block-provider": "^2.12.0",
|
|
43
43
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
44
44
|
"@atlaskit/editor-toolbar": "^0.18.0",
|
|
45
45
|
"@atlaskit/flag": "^17.5.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.38.0",
|
|
60
60
|
"react": "^18.2.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|