@atlaskit/editor-plugin-synced-block 9.1.21 → 10.0.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 CHANGED
@@ -1,5 +1,39 @@
1
1
  # @atlaskit/editor-plugin-synced-block
2
2
 
3
+ ## 10.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`e7ba9d5fba7d0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e7ba9d5fba7d0) -
8
+ Scroll to same-page synced block source when editing source behind platform_editor_blocks_patch_2.
9
+ - Updated dependencies
10
+
11
+ ## 10.0.0
12
+
13
+ ### Major Changes
14
+
15
+ - [`f2dc9097319f0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f2dc9097319f0) - ###
16
+ Dropped support for _legacy_ Typescript 4 types. **Typescript 5 is now the new minimum**.
17
+
18
+ Removes the `typesVersions` property and `dist/types-ts4.5` directory from the dist.
19
+
20
+ Types are now exclusively via the `"types": "dist/types/index.d.ts"` property.
21
+
22
+ ```diff
23
+ - "typesVersions": {
24
+ - ">=4.5 <4.9": {
25
+ - "*": [
26
+ - "dist/types-ts4.5/*",
27
+ - "dist/types-ts4.5/index.d.ts"
28
+ - ]
29
+ - }
30
+ - },
31
+ ```
32
+
33
+ ### Patch Changes
34
+
35
+ - Updated dependencies
36
+
3
37
  ## 9.1.21
4
38
 
5
39
  ### Patch Changes
@@ -10,6 +10,7 @@ var _copyButton = require("@atlaskit/editor-common/copy-button");
10
10
  var _model = require("@atlaskit/editor-prosemirror/model");
11
11
  var _state = require("@atlaskit/editor-prosemirror/state");
12
12
  var _utils = require("@atlaskit/editor-prosemirror/utils");
13
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
14
  var _main = require("../pm-plugins/main");
14
15
  var _utils2 = require("../pm-plugins/utils/utils");
15
16
  var _types = require("../types");
@@ -178,13 +179,14 @@ var copySyncedBlockReferenceToClipboardInternal = function copySyncedBlockRefere
178
179
  };
179
180
  var editSyncedBlockSource = exports.editSyncedBlockSource = function editSyncedBlockSource(syncBlockStore, api) {
180
181
  return function (state, dispatch, _view) {
181
- var _syncBlock$node;
182
+ var _syncBlock$node, _syncBlockStore$refer;
182
183
  var syncBlock = (0, _utils2.findSyncBlock)(state.schema, state.selection);
183
184
  var resourceId = syncBlock === null || syncBlock === void 0 || (_syncBlock$node = syncBlock.node) === null || _syncBlock$node === void 0 || (_syncBlock$node = _syncBlock$node.attrs) === null || _syncBlock$node === void 0 ? void 0 : _syncBlock$node.resourceId;
184
185
  if (!resourceId) {
185
186
  return false;
186
187
  }
187
188
  var syncBlockURL = syncBlockStore.referenceManager.getSyncBlockURL(resourceId);
189
+ var syncBlockData = (_syncBlockStore$refer = syncBlockStore.referenceManager.getFromCache(resourceId)) === null || _syncBlockStore$refer === void 0 ? void 0 : _syncBlockStore$refer.data;
188
190
  if (syncBlockURL) {
189
191
  var _api$analytics5;
190
192
  api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 || _api$analytics5.actions.fireAnalyticsEvent({
@@ -196,10 +198,18 @@ var editSyncedBlockSource = exports.editSyncedBlockSource = function editSyncedB
196
198
  resourceId: resourceId
197
199
  }
198
200
  });
201
+ if (syncBlockData !== null && syncBlockData !== void 0 && syncBlockData.onSameDocument && (0, _platformFeatureFlags.fg)('platform_editor_blocks_patch_2')) {
202
+ var sourceBlock = (0, _utils3.findBodiedSyncBlockByLocalId)(state, syncBlockData.blockInstanceId);
203
+ if (sourceBlock) {
204
+ var tr = state.tr.setSelection(_state.NodeSelection.create(state.doc, sourceBlock.pos)).scrollIntoView();
205
+ dispatch === null || dispatch === void 0 || dispatch(tr);
206
+ return true;
207
+ }
208
+ }
199
209
  window.open(syncBlockURL, '_blank');
200
210
  } else {
201
211
  var _api$analytics6;
202
- var tr = state.tr;
212
+ var _tr = state.tr;
203
213
  api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 || (_api$analytics6 = _api$analytics6.actions) === null || _api$analytics6 === void 0 || _api$analytics6.attachAnalyticsEvent({
204
214
  eventType: _analytics.EVENT_TYPE.OPERATIONAL,
205
215
  action: _analytics.ACTION.ERROR,
@@ -208,8 +218,8 @@ var editSyncedBlockSource = exports.editSyncedBlockSource = function editSyncedB
208
218
  attributes: {
209
219
  error: 'No URL resolved for synced block'
210
220
  }
211
- })(tr);
212
- dispatch === null || dispatch === void 0 || dispatch(tr);
221
+ })(_tr);
222
+ dispatch === null || dispatch === void 0 || dispatch(_tr);
213
223
  }
214
224
  return true;
215
225
  };
@@ -3,7 +3,24 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.pasteSyncBlockHTMLContent = void 0;
6
+ exports.pasteSyncBlockHTMLContent = exports.findBodiedSyncBlockByLocalId = void 0;
7
+ var findBodiedSyncBlockByLocalId = exports.findBodiedSyncBlockByLocalId = function findBodiedSyncBlockByLocalId(state, localId) {
8
+ var result;
9
+ state.doc.descendants(function (node, pos) {
10
+ if (result) {
11
+ return false;
12
+ }
13
+ if (node.type === state.schema.nodes.bodiedSyncBlock && node.attrs.localId === localId) {
14
+ result = {
15
+ node: node,
16
+ pos: pos
17
+ };
18
+ return false;
19
+ }
20
+ return true;
21
+ });
22
+ return result;
23
+ };
7
24
  var pasteSyncBlockHTMLContent = exports.pasteSyncBlockHTMLContent = function pasteSyncBlockHTMLContent(contentDOM, view) {
8
25
  var tmpDiv = document.createElement('div');
9
26
  tmpDiv.appendChild(contentDOM);
@@ -2,12 +2,13 @@ import { defaultSchema } from '@atlaskit/adf-schema/schema-default';
2
2
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
3
3
  import { copyDomNode, toDOM } from '@atlaskit/editor-common/copy-button';
4
4
  import { DOMSerializer, Fragment } from '@atlaskit/editor-prosemirror/model';
5
- import { TextSelection } from '@atlaskit/editor-prosemirror/state';
5
+ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
6
  import { findSelectedNodeOfType, removeParentNodeOfType, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { syncedBlockPluginKey } from '../pm-plugins/main';
8
9
  import { canBeConvertedToSyncBlock, deferDispatch, findSyncBlock, findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from '../pm-plugins/utils/utils';
9
10
  import { FLAG_ID } from '../types';
10
- import { pasteSyncBlockHTMLContent } from './utils';
11
+ import { findBodiedSyncBlockByLocalId, pasteSyncBlockHTMLContent } from './utils';
11
12
  export const createSyncedBlock = ({
12
13
  tr,
13
14
  syncBlockStore,
@@ -177,13 +178,14 @@ const copySyncedBlockReferenceToClipboardInternal = (schema, selection, syncBloc
177
178
  return true;
178
179
  };
179
180
  export const editSyncedBlockSource = (syncBlockStore, api) => (state, dispatch, _view) => {
180
- var _syncBlock$node, _syncBlock$node$attrs;
181
+ var _syncBlock$node, _syncBlock$node$attrs, _syncBlockStore$refer;
181
182
  const syncBlock = findSyncBlock(state.schema, state.selection);
182
183
  const resourceId = syncBlock === null || syncBlock === void 0 ? void 0 : (_syncBlock$node = syncBlock.node) === null || _syncBlock$node === void 0 ? void 0 : (_syncBlock$node$attrs = _syncBlock$node.attrs) === null || _syncBlock$node$attrs === void 0 ? void 0 : _syncBlock$node$attrs.resourceId;
183
184
  if (!resourceId) {
184
185
  return false;
185
186
  }
186
187
  const syncBlockURL = syncBlockStore.referenceManager.getSyncBlockURL(resourceId);
188
+ const syncBlockData = (_syncBlockStore$refer = syncBlockStore.referenceManager.getFromCache(resourceId)) === null || _syncBlockStore$refer === void 0 ? void 0 : _syncBlockStore$refer.data;
187
189
  if (syncBlockURL) {
188
190
  var _api$analytics5;
189
191
  api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions.fireAnalyticsEvent({
@@ -195,6 +197,14 @@ export const editSyncedBlockSource = (syncBlockStore, api) => (state, dispatch,
195
197
  resourceId: resourceId
196
198
  }
197
199
  });
200
+ if (syncBlockData !== null && syncBlockData !== void 0 && syncBlockData.onSameDocument && fg('platform_editor_blocks_patch_2')) {
201
+ const sourceBlock = findBodiedSyncBlockByLocalId(state, syncBlockData.blockInstanceId);
202
+ if (sourceBlock) {
203
+ const tr = state.tr.setSelection(NodeSelection.create(state.doc, sourceBlock.pos)).scrollIntoView();
204
+ dispatch === null || dispatch === void 0 ? void 0 : dispatch(tr);
205
+ return true;
206
+ }
207
+ }
198
208
  window.open(syncBlockURL, '_blank');
199
209
  } else {
200
210
  var _api$analytics6, _api$analytics6$actio;
@@ -1,3 +1,20 @@
1
+ export const findBodiedSyncBlockByLocalId = (state, localId) => {
2
+ let result;
3
+ state.doc.descendants((node, pos) => {
4
+ if (result) {
5
+ return false;
6
+ }
7
+ if (node.type === state.schema.nodes.bodiedSyncBlock && node.attrs.localId === localId) {
8
+ result = {
9
+ node,
10
+ pos
11
+ };
12
+ return false;
13
+ }
14
+ return true;
15
+ });
16
+ return result;
17
+ };
1
18
  export const pasteSyncBlockHTMLContent = (contentDOM, view) => {
2
19
  const tmpDiv = document.createElement('div');
3
20
  tmpDiv.appendChild(contentDOM);
@@ -2,12 +2,13 @@ import { defaultSchema } from '@atlaskit/adf-schema/schema-default';
2
2
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
3
3
  import { copyDomNode, toDOM } from '@atlaskit/editor-common/copy-button';
4
4
  import { DOMSerializer, Fragment } from '@atlaskit/editor-prosemirror/model';
5
- import { TextSelection } from '@atlaskit/editor-prosemirror/state';
5
+ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
6
  import { findSelectedNodeOfType, removeParentNodeOfType, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { syncedBlockPluginKey } from '../pm-plugins/main';
8
9
  import { canBeConvertedToSyncBlock, deferDispatch, findSyncBlock, findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from '../pm-plugins/utils/utils';
9
10
  import { FLAG_ID } from '../types';
10
- import { pasteSyncBlockHTMLContent } from './utils';
11
+ import { findBodiedSyncBlockByLocalId, pasteSyncBlockHTMLContent } from './utils';
11
12
  export var createSyncedBlock = function createSyncedBlock(_ref) {
12
13
  var tr = _ref.tr,
13
14
  syncBlockStore = _ref.syncBlockStore,
@@ -172,13 +173,14 @@ var copySyncedBlockReferenceToClipboardInternal = function copySyncedBlockRefere
172
173
  };
173
174
  export var editSyncedBlockSource = function editSyncedBlockSource(syncBlockStore, api) {
174
175
  return function (state, dispatch, _view) {
175
- var _syncBlock$node;
176
+ var _syncBlock$node, _syncBlockStore$refer;
176
177
  var syncBlock = findSyncBlock(state.schema, state.selection);
177
178
  var resourceId = syncBlock === null || syncBlock === void 0 || (_syncBlock$node = syncBlock.node) === null || _syncBlock$node === void 0 || (_syncBlock$node = _syncBlock$node.attrs) === null || _syncBlock$node === void 0 ? void 0 : _syncBlock$node.resourceId;
178
179
  if (!resourceId) {
179
180
  return false;
180
181
  }
181
182
  var syncBlockURL = syncBlockStore.referenceManager.getSyncBlockURL(resourceId);
183
+ var syncBlockData = (_syncBlockStore$refer = syncBlockStore.referenceManager.getFromCache(resourceId)) === null || _syncBlockStore$refer === void 0 ? void 0 : _syncBlockStore$refer.data;
182
184
  if (syncBlockURL) {
183
185
  var _api$analytics5;
184
186
  api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 || _api$analytics5.actions.fireAnalyticsEvent({
@@ -190,10 +192,18 @@ export var editSyncedBlockSource = function editSyncedBlockSource(syncBlockStore
190
192
  resourceId: resourceId
191
193
  }
192
194
  });
195
+ if (syncBlockData !== null && syncBlockData !== void 0 && syncBlockData.onSameDocument && fg('platform_editor_blocks_patch_2')) {
196
+ var sourceBlock = findBodiedSyncBlockByLocalId(state, syncBlockData.blockInstanceId);
197
+ if (sourceBlock) {
198
+ var tr = state.tr.setSelection(NodeSelection.create(state.doc, sourceBlock.pos)).scrollIntoView();
199
+ dispatch === null || dispatch === void 0 || dispatch(tr);
200
+ return true;
201
+ }
202
+ }
193
203
  window.open(syncBlockURL, '_blank');
194
204
  } else {
195
205
  var _api$analytics6;
196
- var tr = state.tr;
206
+ var _tr = state.tr;
197
207
  api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 || (_api$analytics6 = _api$analytics6.actions) === null || _api$analytics6 === void 0 || _api$analytics6.attachAnalyticsEvent({
198
208
  eventType: EVENT_TYPE.OPERATIONAL,
199
209
  action: ACTION.ERROR,
@@ -202,8 +212,8 @@ export var editSyncedBlockSource = function editSyncedBlockSource(syncBlockStore
202
212
  attributes: {
203
213
  error: 'No URL resolved for synced block'
204
214
  }
205
- })(tr);
206
- dispatch === null || dispatch === void 0 || dispatch(tr);
215
+ })(_tr);
216
+ dispatch === null || dispatch === void 0 || dispatch(_tr);
207
217
  }
208
218
  return true;
209
219
  };
@@ -1,3 +1,20 @@
1
+ export var findBodiedSyncBlockByLocalId = function findBodiedSyncBlockByLocalId(state, localId) {
2
+ var result;
3
+ state.doc.descendants(function (node, pos) {
4
+ if (result) {
5
+ return false;
6
+ }
7
+ if (node.type === state.schema.nodes.bodiedSyncBlock && node.attrs.localId === localId) {
8
+ result = {
9
+ node: node,
10
+ pos: pos
11
+ };
12
+ return false;
13
+ }
14
+ return true;
15
+ });
16
+ return result;
17
+ };
1
18
  export var pasteSyncBlockHTMLContent = function pasteSyncBlockHTMLContent(contentDOM, view) {
2
19
  var tmpDiv = document.createElement('div');
3
20
  tmpDiv.appendChild(contentDOM);
@@ -1,2 +1,5 @@
1
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
+ import type { NodeWithPos } from '@atlaskit/editor-prosemirror/utils';
1
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ export declare const findBodiedSyncBlockByLocalId: (state: EditorState, localId: string) => NodeWithPos | undefined;
2
5
  export declare const pasteSyncBlockHTMLContent: (contentDOM: HTMLElement | DocumentFragment, view: EditorView) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-synced-block",
3
- "version": "9.1.21",
3
+ "version": "10.0.1",
4
4
  "description": "SyncedBlock plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -17,54 +17,46 @@
17
17
  "module": "dist/esm/index.js",
18
18
  "module:es2019": "dist/es2019/index.js",
19
19
  "types": "dist/types/index.d.ts",
20
- "typesVersions": {
21
- ">=4.5 <4.9": {
22
- "*": [
23
- "dist/types-ts4.5/*",
24
- "dist/types-ts4.5/index.d.ts"
25
- ]
26
- }
27
- },
28
20
  "sideEffects": false,
29
21
  "atlaskit:src": "src/index.ts",
30
22
  "dependencies": {
31
- "@atlaskit/adf-schema": "^54.0.0",
32
- "@atlaskit/button": "23.11.8",
33
- "@atlaskit/dropdown-menu": "16.10.6",
34
- "@atlaskit/editor-json-transformer": "^8.33.0",
35
- "@atlaskit/editor-plugin-analytics": "^11.0.0",
36
- "@atlaskit/editor-plugin-block-menu": "^10.1.0",
37
- "@atlaskit/editor-plugin-connectivity": "11.0.0",
38
- "@atlaskit/editor-plugin-content-format": "^5.0.0",
39
- "@atlaskit/editor-plugin-decorations": "^11.0.0",
40
- "@atlaskit/editor-plugin-floating-toolbar": "^13.0.0",
41
- "@atlaskit/editor-plugin-focus": "^10.0.0",
42
- "@atlaskit/editor-plugin-selection": "^11.0.0",
43
- "@atlaskit/editor-plugin-user-intent": "^9.1.0",
44
- "@atlaskit/editor-prosemirror": "^7.3.0",
45
- "@atlaskit/editor-shared-styles": "^3.11.0",
46
- "@atlaskit/editor-synced-block-provider": "^7.0.0",
47
- "@atlaskit/editor-toolbar": "^1.10.0",
48
- "@atlaskit/flag": "^17.13.0",
49
- "@atlaskit/icon": "35.4.0",
50
- "@atlaskit/icon-lab": "^6.14.0",
51
- "@atlaskit/logo": "^20.2.0",
52
- "@atlaskit/lozenge": "^13.9.0",
53
- "@atlaskit/modal-dialog": "^15.3.0",
54
- "@atlaskit/platform-feature-flags": "^1.1.0",
55
- "@atlaskit/primitives": "^19.0.0",
56
- "@atlaskit/spinner": "19.1.2",
57
- "@atlaskit/tmp-editor-statsig": "^103.0.0",
58
- "@atlaskit/tokens": "13.4.0",
59
- "@atlaskit/tooltip": "^22.6.0",
60
- "@atlaskit/visually-hidden": "^3.1.0",
23
+ "@atlaskit/adf-schema": "^55.0.0",
24
+ "@atlaskit/button": "24.0.0",
25
+ "@atlaskit/dropdown-menu": "17.0.0",
26
+ "@atlaskit/editor-json-transformer": "^9.0.0",
27
+ "@atlaskit/editor-plugin-analytics": "^12.0.0",
28
+ "@atlaskit/editor-plugin-block-menu": "^11.0.0",
29
+ "@atlaskit/editor-plugin-connectivity": "12.0.0",
30
+ "@atlaskit/editor-plugin-content-format": "^6.0.0",
31
+ "@atlaskit/editor-plugin-decorations": "^12.0.0",
32
+ "@atlaskit/editor-plugin-floating-toolbar": "^14.0.0",
33
+ "@atlaskit/editor-plugin-focus": "^11.0.0",
34
+ "@atlaskit/editor-plugin-selection": "^12.0.0",
35
+ "@atlaskit/editor-plugin-user-intent": "^10.0.0",
36
+ "@atlaskit/editor-prosemirror": "^8.0.0",
37
+ "@atlaskit/editor-shared-styles": "^4.0.0",
38
+ "@atlaskit/editor-synced-block-provider": "^8.0.0",
39
+ "@atlaskit/editor-toolbar": "^2.0.0",
40
+ "@atlaskit/flag": "^18.0.0",
41
+ "@atlaskit/icon": "36.0.0",
42
+ "@atlaskit/icon-lab": "^7.0.0",
43
+ "@atlaskit/logo": "^21.0.0",
44
+ "@atlaskit/lozenge": "^14.0.0",
45
+ "@atlaskit/modal-dialog": "^16.0.0",
46
+ "@atlaskit/platform-feature-flags": "^2.0.0",
47
+ "@atlaskit/primitives": "^20.0.0",
48
+ "@atlaskit/spinner": "20.0.0",
49
+ "@atlaskit/tmp-editor-statsig": "^105.0.0",
50
+ "@atlaskit/tokens": "14.0.0",
51
+ "@atlaskit/tooltip": "^23.0.0",
52
+ "@atlaskit/visually-hidden": "^4.0.0",
61
53
  "@babel/runtime": "^7.0.0",
62
54
  "@compiled/react": "^0.20.0",
63
55
  "bind-event-listener": "^3.0.0",
64
56
  "date-fns": "^2.17.0"
65
57
  },
66
58
  "peerDependencies": {
67
- "@atlaskit/editor-common": "^115.16.0",
59
+ "@atlaskit/editor-common": "^116.1.0",
68
60
  "react": "^18.2.0",
69
61
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
70
62
  },
@@ -113,6 +105,9 @@
113
105
  "confluence_fronend_labels_categorization_migration": {
114
106
  "type": "boolean"
115
107
  },
108
+ "platform_editor_blocks_patch_2": {
109
+ "type": "boolean"
110
+ },
116
111
  "platform_synced_block_patch_13": {
117
112
  "type": "boolean"
118
113
  },