@atlaskit/editor-plugin-synced-block 3.7.1 → 3.8.0

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 CHANGED
@@ -1,5 +1,26 @@
1
1
  # @atlaskit/editor-plugin-synced-block
2
2
 
3
+ ## 3.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`7ef8ad00e2b1f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7ef8ad00e2b1f) -
8
+ EDITOR-2430 Update the sync-blocker-tracker to work properly for bodied-sync-block
9
+
10
+ ### Patch Changes
11
+
12
+ - [`23b21c4b4ffe5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/23b21c4b4ffe5) -
13
+ [ux] EDITOR-2505 Fix deletion of source sync block from floating toolbar
14
+ - [`c28cd65d12c24`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c28cd65d12c24) -
15
+ EDITOR-2447 Bump adf-schema to 51.3.1
16
+ - Updated dependencies
17
+
18
+ ## 3.7.2
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies
23
+
3
24
  ## 3.7.1
4
25
 
5
26
  ### 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 _state$selection = state.selection,
114
- from = _state$selection.$from.pos,
115
- to = _state$selection.$to.pos,
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(from, to);
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
- state.doc.nodesBetween(step.from, step.to, function (node) {
31
- if (storeManager.isSourceBlock(node)) {
32
- if (sourceSyncBlockAdded[node.attrs.localId]) {
33
- // If a source block added and then removed in the same transaction,
34
- // we treat it as no-op.
35
- delete sourceSyncBlockAdded[node.attrs.localId];
36
- } else {
37
- sourceSyncBlockRemoved[node.attrs.localId] = node.attrs;
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 && hasMultipleReplaceSteps) {
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
- selection: {
116
- $from: {
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(from, to);
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
- state.doc.nodesBetween(step.from, step.to, node => {
25
- if (storeManager.isSourceBlock(node)) {
26
- if (sourceSyncBlockAdded[node.attrs.localId]) {
27
- // If a source block added and then removed in the same transaction,
28
- // we treat it as no-op.
29
- delete sourceSyncBlockAdded[node.attrs.localId];
30
- } else {
31
- sourceSyncBlockRemoved[node.attrs.localId] = node.attrs;
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 && hasMultipleReplaceSteps) {
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 _state$selection = state.selection,
107
- from = _state$selection.$from.pos,
108
- to = _state$selection.$to.pos,
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(from, to);
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
- state.doc.nodesBetween(step.from, step.to, function (node) {
25
- if (storeManager.isSourceBlock(node)) {
26
- if (sourceSyncBlockAdded[node.attrs.localId]) {
27
- // If a source block added and then removed in the same transaction,
28
- // we treat it as no-op.
29
- delete sourceSyncBlockAdded[node.attrs.localId];
30
- } else {
31
- sourceSyncBlockRemoved[node.attrs.localId] = node.attrs;
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 && hasMultipleReplaceSteps) {
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.7.1",
3
+ "version": "3.8.0",
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.0",
31
+ "@atlaskit/adf-schema": "^51.3.1",
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,16 +38,16 @@
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.0.0",
41
+ "@atlaskit/editor-synced-block-provider": "^2.1.0",
42
42
  "@atlaskit/editor-tables": "^2.9.0",
43
- "@atlaskit/editor-toolbar": "^0.15.0",
43
+ "@atlaskit/editor-toolbar": "^0.16.0",
44
44
  "@atlaskit/icon": "28.5.3",
45
45
  "@atlaskit/modal-dialog": "^14.5.0",
46
46
  "@babel/runtime": "^7.0.0",
47
47
  "react-intl-next": "npm:react-intl@^5.18.1"
48
48
  },
49
49
  "peerDependencies": {
50
- "@atlaskit/editor-common": "^110.16.0",
50
+ "@atlaskit/editor-common": "^110.18.0",
51
51
  "react": "^18.2.0"
52
52
  },
53
53
  "devDependencies": {