@atlaskit/editor-plugin-synced-block 3.7.2 → 3.8.1
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 +23 -0
- package/afm-products/tsconfig.json +68 -0
- package/dist/cjs/pm-plugins/actions.js +5 -11
- package/dist/cjs/pm-plugins/utils/track-sync-blocks.js +18 -21
- package/dist/es2019/pm-plugins/actions.js +5 -18
- package/dist/es2019/pm-plugins/utils/track-sync-blocks.js +18 -21
- package/dist/esm/pm-plugins/actions.js +5 -11
- package/dist/esm/pm-plugins/utils/track-sync-blocks.js +18 -21
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 3.8.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`21fe79119fe74`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/21fe79119fe74) -
|
|
8
|
+
EDITOR-2447 Bump adf-schema to 51.3.2
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 3.8.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [`7ef8ad00e2b1f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7ef8ad00e2b1f) -
|
|
16
|
+
EDITOR-2430 Update the sync-blocker-tracker to work properly for bodied-sync-block
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- [`23b21c4b4ffe5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/23b21c4b4ffe5) -
|
|
21
|
+
[ux] EDITOR-2505 Fix deletion of source sync block from floating toolbar
|
|
22
|
+
- [`c28cd65d12c24`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c28cd65d12c24) -
|
|
23
|
+
EDITOR-2447 Bump adf-schema to 51.3.1
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
|
|
3
26
|
## 3.7.2
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../../tsconfig.entry-points.products.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "es5",
|
|
5
|
+
"outDir": "../../../../../tsDist/@atlaskit__editor-plugin-synced-block/app",
|
|
6
|
+
"rootDir": "../",
|
|
7
|
+
"composite": true
|
|
8
|
+
},
|
|
9
|
+
"include": [
|
|
10
|
+
"../src/**/*.ts",
|
|
11
|
+
"../src/**/*.tsx"
|
|
12
|
+
],
|
|
13
|
+
"exclude": [
|
|
14
|
+
"../src/**/__tests__/*",
|
|
15
|
+
"../src/**/*.test.*",
|
|
16
|
+
"../src/**/test.*",
|
|
17
|
+
"../src/**/examples.*",
|
|
18
|
+
"../src/**/examples/*",
|
|
19
|
+
"../src/**/examples/**/*",
|
|
20
|
+
"../src/**/*.stories.*",
|
|
21
|
+
"../src/**/stories/*",
|
|
22
|
+
"../src/**/stories/**/*"
|
|
23
|
+
],
|
|
24
|
+
"references": [
|
|
25
|
+
{
|
|
26
|
+
"path": "../../../design-system/button/afm-products/tsconfig.json"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"path": "../../editor-json-transformer/afm-products/tsconfig.json"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"path": "../../editor-plugin-analytics/afm-products/tsconfig.json"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"path": "../../editor-plugin-block-menu/afm-products/tsconfig.json"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"path": "../../editor-plugin-decorations/afm-products/tsconfig.json"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"path": "../../editor-plugin-floating-toolbar/afm-products/tsconfig.json"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"path": "../../editor-plugin-selection/afm-products/tsconfig.json"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"path": "../../editor-shared-styles/afm-products/tsconfig.json"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"path": "../../editor-synced-block-provider/afm-products/tsconfig.json"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"path": "../../editor-tables/afm-products/tsconfig.json"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"path": "../../editor-toolbar/afm-products/tsconfig.json"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"path": "../../../design-system/icon/afm-products/tsconfig.json"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"path": "../../../design-system/modal-dialog/afm-products/tsconfig.json"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"path": "../../editor-common/afm-products/tsconfig.json"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
@@ -110,22 +110,16 @@ var editSyncedBlockSource = exports.editSyncedBlockSource = function editSyncedB
|
|
|
110
110
|
};
|
|
111
111
|
var removeSyncedBlock = exports.removeSyncedBlock = function removeSyncedBlock(api) {
|
|
112
112
|
return function (state, dispatch, _view) {
|
|
113
|
-
var
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
tr = state.tr;
|
|
117
|
-
var syncBlock = (0, _utils.findSyncBlockOrBodiedSyncBlock)(state);
|
|
118
|
-
if (!syncBlock) {
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
if (!dispatch) {
|
|
113
|
+
var tr = state.tr;
|
|
114
|
+
var syncBlockFindResult = (0, _utils.findSyncBlockOrBodiedSyncBlock)(state);
|
|
115
|
+
if (!syncBlockFindResult) {
|
|
122
116
|
return false;
|
|
123
117
|
}
|
|
124
|
-
var newTr = tr.deleteRange(
|
|
118
|
+
var newTr = tr.deleteRange(syncBlockFindResult.pos, syncBlockFindResult.pos + syncBlockFindResult.node.nodeSize);
|
|
125
119
|
if (!newTr) {
|
|
126
120
|
return false;
|
|
127
121
|
}
|
|
128
|
-
dispatch(newTr);
|
|
122
|
+
dispatch === null || dispatch === void 0 || dispatch(newTr);
|
|
129
123
|
api === null || api === void 0 || api.core.actions.focus();
|
|
130
124
|
return true;
|
|
131
125
|
};
|
|
@@ -6,14 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.trackSyncBlocks = void 0;
|
|
7
7
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
8
8
|
var trackSyncBlocks = exports.trackSyncBlocks = function trackSyncBlocks(storeManager, tr, state) {
|
|
9
|
-
// TODO: EDITOR-2430 - Disable tracking for now, it will be updated to handle the new bodied sync block
|
|
10
|
-
var dontTrack = true;
|
|
11
|
-
if (dontTrack) {
|
|
12
|
-
return {
|
|
13
|
-
removed: [],
|
|
14
|
-
added: []
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
9
|
var sourceSyncBlockRemoved = {};
|
|
18
10
|
var sourceSyncBlockAdded = {};
|
|
19
11
|
|
|
@@ -21,30 +13,35 @@ var trackSyncBlocks = exports.trackSyncBlocks = function trackSyncBlocks(storeMa
|
|
|
21
13
|
var replaceSteps = tr.steps.filter(function (step) {
|
|
22
14
|
return step instanceof _transform.ReplaceStep || step instanceof _transform.ReplaceAroundStep;
|
|
23
15
|
});
|
|
24
|
-
var hasMultipleReplaceSteps = replaceSteps.length > 1;
|
|
25
16
|
replaceSteps.forEach(function (step) {
|
|
26
17
|
var from = step.from,
|
|
27
18
|
to = step.to;
|
|
28
19
|
// replaced a range, check for deleted syncBlock
|
|
20
|
+
|
|
29
21
|
if (from !== to) {
|
|
30
|
-
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
22
|
+
step.getMap().forEach(function (oldStart, oldEnd) {
|
|
23
|
+
if (oldStart !== oldEnd) {
|
|
24
|
+
var deletedSlice = state.doc.slice(oldStart, oldEnd);
|
|
25
|
+
deletedSlice.content.nodesBetween(0, deletedSlice.content.size, function (node) {
|
|
26
|
+
if (storeManager.isSourceBlock(node)) {
|
|
27
|
+
if (sourceSyncBlockAdded[node.attrs.localId]) {
|
|
28
|
+
// If a source block added and then removed in the same transaction,
|
|
29
|
+
// we treat it as no-op.
|
|
30
|
+
delete sourceSyncBlockAdded[node.attrs.localId];
|
|
31
|
+
} else {
|
|
32
|
+
sourceSyncBlockRemoved[node.attrs.localId] = node.attrs;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// we don't need to go deeper
|
|
36
|
+
return false;
|
|
37
|
+
});
|
|
39
38
|
}
|
|
40
|
-
// we don't need to go deeper
|
|
41
|
-
return false;
|
|
42
39
|
});
|
|
43
40
|
}
|
|
44
41
|
|
|
45
42
|
// replaced content, check for inserted syncBlock
|
|
46
43
|
// if only one replace step, we have already checked the entire replaced range above
|
|
47
|
-
if (step.slice.content.size > 0
|
|
44
|
+
if (step.slice.content.size > 0) {
|
|
48
45
|
step.slice.content.nodesBetween(0, step.slice.content.size, function (node) {
|
|
49
46
|
if (storeManager.isSourceBlock(node)) {
|
|
50
47
|
if (sourceSyncBlockRemoved[node.attrs.localId]) {
|
|
@@ -111,29 +111,16 @@ export const editSyncedBlockSource = (syncBlockStore, api) => (state, dispatch,
|
|
|
111
111
|
return true;
|
|
112
112
|
};
|
|
113
113
|
export const removeSyncedBlock = api => (state, dispatch, _view) => {
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
pos: from
|
|
118
|
-
},
|
|
119
|
-
$to: {
|
|
120
|
-
pos: to
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
tr
|
|
124
|
-
} = state;
|
|
125
|
-
const syncBlock = findSyncBlockOrBodiedSyncBlock(state);
|
|
126
|
-
if (!syncBlock) {
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
if (!dispatch) {
|
|
114
|
+
const tr = state.tr;
|
|
115
|
+
const syncBlockFindResult = findSyncBlockOrBodiedSyncBlock(state);
|
|
116
|
+
if (!syncBlockFindResult) {
|
|
130
117
|
return false;
|
|
131
118
|
}
|
|
132
|
-
const newTr = tr.deleteRange(
|
|
119
|
+
const newTr = tr.deleteRange(syncBlockFindResult.pos, syncBlockFindResult.pos + syncBlockFindResult.node.nodeSize);
|
|
133
120
|
if (!newTr) {
|
|
134
121
|
return false;
|
|
135
122
|
}
|
|
136
|
-
dispatch(newTr);
|
|
123
|
+
dispatch === null || dispatch === void 0 ? void 0 : dispatch(newTr);
|
|
137
124
|
api === null || api === void 0 ? void 0 : api.core.actions.focus();
|
|
138
125
|
return true;
|
|
139
126
|
};
|
|
@@ -1,44 +1,41 @@
|
|
|
1
1
|
import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
2
2
|
export const trackSyncBlocks = (storeManager, tr, state) => {
|
|
3
|
-
// TODO: EDITOR-2430 - Disable tracking for now, it will be updated to handle the new bodied sync block
|
|
4
|
-
const dontTrack = true;
|
|
5
|
-
if (dontTrack) {
|
|
6
|
-
return {
|
|
7
|
-
removed: [],
|
|
8
|
-
added: []
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
3
|
const sourceSyncBlockRemoved = {};
|
|
12
4
|
const sourceSyncBlockAdded = {};
|
|
13
5
|
|
|
14
6
|
// and cast to specific step types
|
|
15
7
|
const replaceSteps = tr.steps.filter(step => step instanceof ReplaceStep || step instanceof ReplaceAroundStep);
|
|
16
|
-
const hasMultipleReplaceSteps = replaceSteps.length > 1;
|
|
17
8
|
replaceSteps.forEach(step => {
|
|
18
9
|
const {
|
|
19
10
|
from,
|
|
20
11
|
to
|
|
21
12
|
} = step;
|
|
22
13
|
// replaced a range, check for deleted syncBlock
|
|
14
|
+
|
|
23
15
|
if (from !== to) {
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
16
|
+
step.getMap().forEach((oldStart, oldEnd) => {
|
|
17
|
+
if (oldStart !== oldEnd) {
|
|
18
|
+
const deletedSlice = state.doc.slice(oldStart, oldEnd);
|
|
19
|
+
deletedSlice.content.nodesBetween(0, deletedSlice.content.size, node => {
|
|
20
|
+
if (storeManager.isSourceBlock(node)) {
|
|
21
|
+
if (sourceSyncBlockAdded[node.attrs.localId]) {
|
|
22
|
+
// If a source block added and then removed in the same transaction,
|
|
23
|
+
// we treat it as no-op.
|
|
24
|
+
delete sourceSyncBlockAdded[node.attrs.localId];
|
|
25
|
+
} else {
|
|
26
|
+
sourceSyncBlockRemoved[node.attrs.localId] = node.attrs;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// we don't need to go deeper
|
|
30
|
+
return false;
|
|
31
|
+
});
|
|
33
32
|
}
|
|
34
|
-
// we don't need to go deeper
|
|
35
|
-
return false;
|
|
36
33
|
});
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
// replaced content, check for inserted syncBlock
|
|
40
37
|
// if only one replace step, we have already checked the entire replaced range above
|
|
41
|
-
if (step.slice.content.size > 0
|
|
38
|
+
if (step.slice.content.size > 0) {
|
|
42
39
|
step.slice.content.nodesBetween(0, step.slice.content.size, node => {
|
|
43
40
|
if (storeManager.isSourceBlock(node)) {
|
|
44
41
|
if (sourceSyncBlockRemoved[node.attrs.localId]) {
|
|
@@ -103,22 +103,16 @@ export var editSyncedBlockSource = function editSyncedBlockSource(syncBlockStore
|
|
|
103
103
|
};
|
|
104
104
|
export var removeSyncedBlock = function removeSyncedBlock(api) {
|
|
105
105
|
return function (state, dispatch, _view) {
|
|
106
|
-
var
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
tr = state.tr;
|
|
110
|
-
var syncBlock = findSyncBlockOrBodiedSyncBlock(state);
|
|
111
|
-
if (!syncBlock) {
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
if (!dispatch) {
|
|
106
|
+
var tr = state.tr;
|
|
107
|
+
var syncBlockFindResult = findSyncBlockOrBodiedSyncBlock(state);
|
|
108
|
+
if (!syncBlockFindResult) {
|
|
115
109
|
return false;
|
|
116
110
|
}
|
|
117
|
-
var newTr = tr.deleteRange(
|
|
111
|
+
var newTr = tr.deleteRange(syncBlockFindResult.pos, syncBlockFindResult.pos + syncBlockFindResult.node.nodeSize);
|
|
118
112
|
if (!newTr) {
|
|
119
113
|
return false;
|
|
120
114
|
}
|
|
121
|
-
dispatch(newTr);
|
|
115
|
+
dispatch === null || dispatch === void 0 || dispatch(newTr);
|
|
122
116
|
api === null || api === void 0 || api.core.actions.focus();
|
|
123
117
|
return true;
|
|
124
118
|
};
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
2
2
|
export var trackSyncBlocks = function trackSyncBlocks(storeManager, tr, state) {
|
|
3
|
-
// TODO: EDITOR-2430 - Disable tracking for now, it will be updated to handle the new bodied sync block
|
|
4
|
-
var dontTrack = true;
|
|
5
|
-
if (dontTrack) {
|
|
6
|
-
return {
|
|
7
|
-
removed: [],
|
|
8
|
-
added: []
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
3
|
var sourceSyncBlockRemoved = {};
|
|
12
4
|
var sourceSyncBlockAdded = {};
|
|
13
5
|
|
|
@@ -15,30 +7,35 @@ export var trackSyncBlocks = function trackSyncBlocks(storeManager, tr, state) {
|
|
|
15
7
|
var replaceSteps = tr.steps.filter(function (step) {
|
|
16
8
|
return step instanceof ReplaceStep || step instanceof ReplaceAroundStep;
|
|
17
9
|
});
|
|
18
|
-
var hasMultipleReplaceSteps = replaceSteps.length > 1;
|
|
19
10
|
replaceSteps.forEach(function (step) {
|
|
20
11
|
var from = step.from,
|
|
21
12
|
to = step.to;
|
|
22
13
|
// replaced a range, check for deleted syncBlock
|
|
14
|
+
|
|
23
15
|
if (from !== to) {
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
16
|
+
step.getMap().forEach(function (oldStart, oldEnd) {
|
|
17
|
+
if (oldStart !== oldEnd) {
|
|
18
|
+
var deletedSlice = state.doc.slice(oldStart, oldEnd);
|
|
19
|
+
deletedSlice.content.nodesBetween(0, deletedSlice.content.size, function (node) {
|
|
20
|
+
if (storeManager.isSourceBlock(node)) {
|
|
21
|
+
if (sourceSyncBlockAdded[node.attrs.localId]) {
|
|
22
|
+
// If a source block added and then removed in the same transaction,
|
|
23
|
+
// we treat it as no-op.
|
|
24
|
+
delete sourceSyncBlockAdded[node.attrs.localId];
|
|
25
|
+
} else {
|
|
26
|
+
sourceSyncBlockRemoved[node.attrs.localId] = node.attrs;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// we don't need to go deeper
|
|
30
|
+
return false;
|
|
31
|
+
});
|
|
33
32
|
}
|
|
34
|
-
// we don't need to go deeper
|
|
35
|
-
return false;
|
|
36
33
|
});
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
// replaced content, check for inserted syncBlock
|
|
40
37
|
// if only one replace step, we have already checked the entire replaced range above
|
|
41
|
-
if (step.slice.content.size > 0
|
|
38
|
+
if (step.slice.content.size > 0) {
|
|
42
39
|
step.slice.content.nodesBetween(0, step.slice.content.size, function (node) {
|
|
43
40
|
if (storeManager.isSourceBlock(node)) {
|
|
44
41
|
if (sourceSyncBlockRemoved[node.attrs.localId]) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-synced-block",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.1",
|
|
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.3.
|
|
31
|
+
"@atlaskit/adf-schema": "^51.3.2",
|
|
32
32
|
"@atlaskit/button": "23.5.3",
|
|
33
33
|
"@atlaskit/editor-json-transformer": "^8.31.0",
|
|
34
34
|
"@atlaskit/editor-plugin-analytics": "^6.2.0",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@atlaskit/editor-plugin-selection": "^6.1.0",
|
|
39
39
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
40
40
|
"@atlaskit/editor-shared-styles": "^3.8.0",
|
|
41
|
-
"@atlaskit/editor-synced-block-provider": "^2.
|
|
41
|
+
"@atlaskit/editor-synced-block-provider": "^2.1.0",
|
|
42
42
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
43
43
|
"@atlaskit/editor-toolbar": "^0.16.0",
|
|
44
44
|
"@atlaskit/icon": "28.5.3",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@atlaskit/editor-common": "^110.
|
|
50
|
+
"@atlaskit/editor-common": "^110.18.0",
|
|
51
51
|
"react": "^18.2.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|