@atlaskit/editor-common 109.15.0 → 109.16.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/cjs/copy-button/index.js +4 -2
  3. package/dist/cjs/keymaps/index.js +11 -6
  4. package/dist/cjs/link/LinkPicker/HyperlinkAddToolbar/HyperlinkAddToolbar.js +3 -1
  5. package/dist/cjs/monitoring/error.js +1 -1
  6. package/dist/cjs/resizer/BreakoutResizer.js +6 -4
  7. package/dist/cjs/styles/shared/table.js +3 -3
  8. package/dist/cjs/sync-block.js +1 -8
  9. package/dist/cjs/ui/DropList/index.js +1 -1
  10. package/dist/cjs/ui/PanelTextInput/index.js +7 -4
  11. package/dist/cjs/utils/browser.js +43 -9
  12. package/dist/cjs/utils/commands.js +13 -3
  13. package/dist/cjs/utils/validator.js +13 -0
  14. package/dist/es2019/copy-button/index.js +3 -1
  15. package/dist/es2019/keymaps/index.js +6 -1
  16. package/dist/es2019/link/LinkPicker/HyperlinkAddToolbar/HyperlinkAddToolbar.js +3 -1
  17. package/dist/es2019/monitoring/error.js +1 -1
  18. package/dist/es2019/resizer/BreakoutResizer.js +5 -3
  19. package/dist/es2019/styles/shared/table.js +107 -105
  20. package/dist/es2019/sync-block.js +1 -2
  21. package/dist/es2019/ui/DropList/index.js +1 -1
  22. package/dist/es2019/ui/PanelTextInput/index.js +4 -1
  23. package/dist/es2019/utils/browser.js +43 -9
  24. package/dist/es2019/utils/commands.js +13 -3
  25. package/dist/es2019/utils/validator.js +13 -0
  26. package/dist/esm/copy-button/index.js +3 -1
  27. package/dist/esm/keymaps/index.js +6 -1
  28. package/dist/esm/link/LinkPicker/HyperlinkAddToolbar/HyperlinkAddToolbar.js +3 -1
  29. package/dist/esm/monitoring/error.js +1 -1
  30. package/dist/esm/resizer/BreakoutResizer.js +5 -3
  31. package/dist/esm/styles/shared/table.js +4 -4
  32. package/dist/esm/sync-block.js +1 -2
  33. package/dist/esm/ui/DropList/index.js +1 -1
  34. package/dist/esm/ui/PanelTextInput/index.js +4 -1
  35. package/dist/esm/utils/browser.js +43 -9
  36. package/dist/esm/utils/commands.js +13 -3
  37. package/dist/esm/utils/validator.js +13 -0
  38. package/dist/types/analytics/types/ai-streaming.d.ts +3 -0
  39. package/dist/types/sync-block.d.ts +0 -1
  40. package/dist/types-ts4.5/analytics/types/ai-streaming.d.ts +3 -0
  41. package/dist/types-ts4.5/sync-block.d.ts +0 -1
  42. package/package.json +9 -9
  43. package/dist/cjs/sync-block/index.js +0 -12
  44. package/dist/cjs/sync-block/sync-block-store-manager.js +0 -94
  45. package/dist/cjs/sync-block/types.js +0 -1
  46. package/dist/es2019/sync-block/index.js +0 -3
  47. package/dist/es2019/sync-block/sync-block-store-manager.js +0 -51
  48. package/dist/es2019/sync-block/types.js +0 -0
  49. package/dist/esm/sync-block/index.js +0 -3
  50. package/dist/esm/sync-block/sync-block-store-manager.js +0 -88
  51. package/dist/esm/sync-block/types.js +0 -0
  52. package/dist/types/sync-block/index.d.ts +0 -2
  53. package/dist/types/sync-block/sync-block-store-manager.d.ts +0 -33
  54. package/dist/types/sync-block/types.d.ts +0 -2
  55. package/dist/types-ts4.5/sync-block/index.d.ts +0 -2
  56. package/dist/types-ts4.5/sync-block/sync-block-store-manager.d.ts +0 -33
  57. package/dist/types-ts4.5/sync-block/types.d.ts +0 -2
@@ -21,7 +21,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
21
21
  import { fg } from '@atlaskit/platform-feature-flags';
22
22
  import Layer from '../Layer';
23
23
  var packageName = "@atlaskit/editor-common";
24
- var packageVersion = "109.14.1";
24
+ var packageVersion = "109.15.1";
25
25
  var halfFocusRing = 1;
26
26
  var dropOffset = '0, 8';
27
27
  var fadeIn = keyframes({
@@ -16,7 +16,8 @@ import { PureComponent } from 'react';
16
16
 
17
17
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
18
18
  import { jsx } from '@emotion/react';
19
- import { browser } from '../../utils';
19
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
20
+ import { browser as browserLegacy, getBrowserInfo } from '../../utils/browser';
20
21
  import { panelTextInput, panelTextInputWithCustomWidth } from './styles';
21
22
  var KeyZCode = 90;
22
23
  var KeyYCode = 89;
@@ -170,6 +171,7 @@ var PanelTextInput = /*#__PURE__*/function (_PureComponent) {
170
171
  // Ignored via go/ees005
171
172
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
172
173
  function isUndoEvent(event) {
174
+ var browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
173
175
  return event.keyCode === KeyZCode && (
174
176
  // cmd + z for mac
175
177
  browser.mac && event.metaKey && !event.shiftKey ||
@@ -182,6 +184,7 @@ var PanelTextInput = /*#__PURE__*/function (_PureComponent) {
182
184
  }, {
183
185
  key: "isRedoEvent",
184
186
  value: function isRedoEvent(event) {
187
+ var browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
185
188
  return (
186
189
  // ctrl + y for non-mac
187
190
  !browser.mac && event.ctrlKey && event.keyCode === KeyYCode || browser.mac && event.metaKey && event.shiftKey && event.keyCode === KeyZCode || event.ctrlKey && event.shiftKey && event.keyCode === KeyZCode
@@ -98,6 +98,42 @@ var getSecondMatch = function getSecondMatch(regexp, ua) {
98
98
  return match && match.length > 0 && match[2] || '';
99
99
  };
100
100
 
101
+ // Helper functions to safely access browser properties
102
+ var getSafeUserAgent = function getSafeUserAgent() {
103
+ var _window$navigator;
104
+ if (typeof window === 'undefined') {
105
+ return undefined;
106
+ }
107
+
108
+ // Check for SSR user agent first
109
+ if (process.env.REACT_SSR) {
110
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
111
+ var ssrUserAgent = window.__SSR_USER_AGENT__;
112
+ if (ssrUserAgent) {
113
+ return ssrUserAgent;
114
+ }
115
+ }
116
+
117
+ // Fallback to navigator.userAgent with proper null checking
118
+ return (_window$navigator = window.navigator) === null || _window$navigator === void 0 ? void 0 : _window$navigator.userAgent;
119
+ };
120
+ var getSafePlatform = function getSafePlatform() {
121
+ var _window$navigator2;
122
+ if (typeof window === 'undefined') {
123
+ return undefined;
124
+ }
125
+ return (_window$navigator2 = window.navigator) === null || _window$navigator2 === void 0 ? void 0 : _window$navigator2.platform;
126
+ };
127
+ var hasIntersectionObserver = function hasIntersectionObserver() {
128
+ return typeof window !== 'undefined' && 'IntersectionObserver' in window && 'IntersectionObserverEntry' in window &&
129
+ // Ignored via go/ees005
130
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
131
+ 'intersectionRatio' in window.IntersectionObserverEntry.prototype;
132
+ };
133
+ var hasResizeObserver = function hasResizeObserver() {
134
+ return typeof window !== 'undefined' && 'ResizeObserver' in window && 'ResizeObserverEntry' in window;
135
+ };
136
+
101
137
  // New API to get the browser info on demand
102
138
  export var getBrowserInfo = memorizeOne(function () {
103
139
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -118,9 +154,8 @@ export var getBrowserInfo = memorizeOne(function () {
118
154
  supportsIntersectionObserver: false,
119
155
  supportsResizeObserver: false
120
156
  };
121
- var userAgent = process.env.REACT_SSR ?
122
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
123
- window.__SSR_USER_AGENT__ : navigator.userAgent;
157
+ var userAgent = getSafeUserAgent();
158
+ var platform = getSafePlatform();
124
159
  if (userAgent) {
125
160
  // inspired from https://github.com/bowser-js/bowser/blob/master/src/parser-browsers.js
126
161
  // Ignored via go/ees005
@@ -131,9 +166,11 @@ export var getBrowserInfo = memorizeOne(function () {
131
166
  // eslint-disable-next-line require-unicode-regexp
132
167
  var internetExplorer = /msie|trident/i.test(userAgent);
133
168
 
169
+ // Ideally we should use userAgent instead of platform, but we have lots of keymap tests failure when we change it
170
+ // So leave it as is for now.
134
171
  // Ignored via go/ees005
135
172
  // eslint-disable-next-line require-unicode-regexp
136
- result.mac = /macintosh/i.test(userAgent);
173
+ result.mac = platform && /Mac/.test(platform);
137
174
 
138
175
  // Previously relied on navigator.userAgentData?.platform and userAgent, now used only userAgent
139
176
  result.windows =
@@ -188,11 +225,8 @@ export var getBrowserInfo = memorizeOne(function () {
188
225
  // Previously we relied on documentElement.style.WebkitAppearance, now changed to userAgent
189
226
  // eslint-disable-next-line require-unicode-regexp
190
227
  result.webkit = /(apple)?webkit/i.test(userAgent);
191
- result.supportsIntersectionObserver = typeof window !== 'undefined' && 'IntersectionObserver' in window && 'IntersectionObserverEntry' in window &&
192
- // Ignored via go/ees005
193
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
194
- 'intersectionRatio' in window.IntersectionObserverEntry.prototype;
195
- result.supportsResizeObserver = typeof window !== 'undefined' && 'ResizeObserver' in window && 'ResizeObserverEntry' in window;
228
+ result.supportsIntersectionObserver = hasIntersectionObserver();
229
+ result.supportsResizeObserver = hasResizeObserver();
196
230
  }
197
231
  return result;
198
232
  });
@@ -296,9 +296,19 @@ export var isEmptySelectionAtStart = function isEmptySelectionAtStart(state) {
296
296
  // Else, check if the parent is a blockTaskItem
297
297
  else if ($from.parent.type === blockTaskItem) {
298
298
  // Check if the selection is at the start of the blockTaskItem
299
- var blockTaskItemDepth = $from.depth - 1;
300
- var DISTANCE_FROM_PARENT_FOR_GAP_CURSOR = 1;
301
- var firstPosInBlockTaskItem = $from.start(blockTaskItemDepth) + DISTANCE_FROM_PARENT_FOR_GAP_CURSOR;
299
+ var firstPosInBlockTaskItem = 0;
300
+ if (fg('platform_editor_blocktaskitem_patch_2')) {
301
+ var blockTaskItemDepth = $from.depth;
302
+
303
+ // When cleaning up platform_editor_blocktaskitem_patch_2, set firstPosInBlockTaskItem as const
304
+ firstPosInBlockTaskItem = $from.start(blockTaskItemDepth);
305
+ } else {
306
+ var _blockTaskItemDepth = $from.depth - 1;
307
+ var DISTANCE_FROM_PARENT_FOR_GAP_CURSOR = 1;
308
+ firstPosInBlockTaskItem = $from.start(_blockTaskItemDepth) + DISTANCE_FROM_PARENT_FOR_GAP_CURSOR;
309
+ }
310
+
311
+ // Is the selection at the first possible position inside the blockTaskItem
302
312
  return $from.pos === firstPosInBlockTaskItem;
303
313
  }
304
314
  }
@@ -5,6 +5,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
5
5
  import { inlineNodes, isSafeUrl, PanelType, generateUuid as uuid } from '@atlaskit/adf-schema';
6
6
  import { defaultSchema } from '@atlaskit/adf-schema/schema-default';
7
7
  import { fg } from '@atlaskit/platform-feature-flags';
8
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
9
  export var ADFStages = {
9
10
  FINAL: 'final',
10
11
  STAGE_0: 'stage0'
@@ -843,6 +844,18 @@ export var getValidNode = function getValidNode(originalNode) {
843
844
  marks: marks
844
845
  };
845
846
  }
847
+ case 'syncBlock':
848
+ {
849
+ if (adfStage === 'stage0' && expValEquals('platform_synced_block', 'isEnabled', true)) {
850
+ return {
851
+ type: type,
852
+ attrs: attrs,
853
+ marks: marks
854
+ };
855
+ } else {
856
+ return getValidUnknownNode(node);
857
+ }
858
+ }
846
859
  }
847
860
  }
848
861
  return getValidUnknownNode(node);
@@ -5,8 +5,11 @@ type AILocalIdNotFoundErrorAEP = OperationalAEP<ACTION.LOCAL_ID_NOT_FOUND, ACTIO
5
5
  localId: string;
6
6
  }>;
7
7
  type AIStreamingUpdateStreamError = OperationalAEP<ACTION.ERRORED, ACTION_SUBJECT.AI_STREAMING, ACTION_SUBJECT_ID.UPDATE_STREAM, {
8
+ docSize: number;
8
9
  errorMessage?: string;
9
10
  errorStack: string;
11
+ fragmentSize: number;
12
+ isFinalStream: boolean;
10
13
  }>;
11
14
  type AIStreamingDiscardStreamError = OperationalAEP<ACTION.ERRORED, ACTION_SUBJECT.AI_STREAMING, ACTION_SUBJECT_ID.DISCARD_STREAM, {
12
15
  errorMessage?: string;
@@ -1,2 +1 @@
1
1
  export { SyncBlockSharedCssClassName } from './styles/shared/sync-block';
2
- export { SyncBlockStoreManager, type SyncBlockDataProvider } from './sync-block/index';
@@ -5,8 +5,11 @@ type AILocalIdNotFoundErrorAEP = OperationalAEP<ACTION.LOCAL_ID_NOT_FOUND, ACTIO
5
5
  localId: string;
6
6
  }>;
7
7
  type AIStreamingUpdateStreamError = OperationalAEP<ACTION.ERRORED, ACTION_SUBJECT.AI_STREAMING, ACTION_SUBJECT_ID.UPDATE_STREAM, {
8
+ docSize: number;
8
9
  errorMessage?: string;
9
10
  errorStack: string;
11
+ fragmentSize: number;
12
+ isFinalStream: boolean;
10
13
  }>;
11
14
  type AIStreamingDiscardStreamError = OperationalAEP<ACTION.ERRORED, ACTION_SUBJECT.AI_STREAMING, ACTION_SUBJECT_ID.DISCARD_STREAM, {
12
15
  errorMessage?: string;
@@ -1,2 +1 @@
1
1
  export { SyncBlockSharedCssClassName } from './styles/shared/sync-block';
2
- export { SyncBlockStoreManager, type SyncBlockDataProvider } from './sync-block/index';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "109.15.0",
3
+ "version": "109.16.0",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -30,8 +30,8 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@atlaskit/activity-provider": "^2.5.0",
33
- "@atlaskit/adf-schema": "^51.1.2",
34
- "@atlaskit/adf-utils": "^19.23.0",
33
+ "@atlaskit/adf-schema": "^51.2.0",
34
+ "@atlaskit/adf-utils": "^19.24.0",
35
35
  "@atlaskit/afm-i18n-platform-editor-editor-common": "2.7.0",
36
36
  "@atlaskit/analytics-listeners": "^9.0.0",
37
37
  "@atlaskit/analytics-namespaced-context": "^7.0.0",
@@ -41,9 +41,9 @@
41
41
  "@atlaskit/code": "^17.2.0",
42
42
  "@atlaskit/codemod-utils": "^4.2.0",
43
43
  "@atlaskit/css": "^0.14.0",
44
- "@atlaskit/custom-steps": "^0.13.0",
44
+ "@atlaskit/custom-steps": "^0.14.0",
45
45
  "@atlaskit/dropdown-menu": "^16.3.0",
46
- "@atlaskit/editor-json-transformer": "^8.29.0",
46
+ "@atlaskit/editor-json-transformer": "^8.30.0",
47
47
  "@atlaskit/editor-palette": "^2.1.0",
48
48
  "@atlaskit/editor-prosemirror": "7.0.0",
49
49
  "@atlaskit/editor-shared-styles": "^3.6.0",
@@ -54,7 +54,7 @@
54
54
  "@atlaskit/icon": "^28.3.0",
55
55
  "@atlaskit/icon-object": "^7.2.0",
56
56
  "@atlaskit/link": "^3.2.0",
57
- "@atlaskit/link-datasource": "^4.24.0",
57
+ "@atlaskit/link-datasource": "^4.25.0",
58
58
  "@atlaskit/link-picker": "^3.11.0",
59
59
  "@atlaskit/media-card": "^79.5.0",
60
60
  "@atlaskit/media-client": "^35.3.0",
@@ -71,17 +71,17 @@
71
71
  "@atlaskit/platform-feature-flags-react": "^0.3.0",
72
72
  "@atlaskit/popper": "^7.1.0",
73
73
  "@atlaskit/primitives": "^14.15.0",
74
- "@atlaskit/profilecard": "^24.13.0",
74
+ "@atlaskit/profilecard": "^24.14.0",
75
75
  "@atlaskit/react-ufo": "^4.10.0",
76
76
  "@atlaskit/section-message": "^8.7.0",
77
77
  "@atlaskit/smart-card": "^42.2.0",
78
- "@atlaskit/smart-user-picker": "^8.2.0",
78
+ "@atlaskit/smart-user-picker": "^8.3.0",
79
79
  "@atlaskit/spinner": "^19.0.0",
80
80
  "@atlaskit/status": "^3.0.0",
81
81
  "@atlaskit/task-decision": "^19.2.0",
82
82
  "@atlaskit/textfield": "^8.0.0",
83
83
  "@atlaskit/theme": "^21.0.0",
84
- "@atlaskit/tmp-editor-statsig": "^12.29.0",
84
+ "@atlaskit/tmp-editor-statsig": "^12.30.0",
85
85
  "@atlaskit/tokens": "^6.3.0",
86
86
  "@atlaskit/tooltip": "^20.4.0",
87
87
  "@atlaskit/width-detector": "^5.0.0",
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "SyncBlockStoreManager", {
7
- enumerable: true,
8
- get: function get() {
9
- return _syncBlockStoreManager.SyncBlockStoreManager;
10
- }
11
- });
12
- var _syncBlockStoreManager = require("./sync-block-store-manager");
@@ -1,94 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.SyncBlockStoreManager = void 0;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
- // Do this typedef to make it clear that
13
- // this is a local identifier for a resource for local use
14
- // A store manager responsible for the lifecycle and state management of sync blocks in an editor instance.
15
- // Supports create, read, update, and delete operations for sync blocks.
16
- // Designed to manage local in-memory state and synchronize with an external data provider.
17
- // Handles caching, debouncing updates, and publish/subscribe for local changes.
18
- // Ensures consistency between local and remote state, and can be used in both editor and renderer contexts.
19
- var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/function () {
20
- function SyncBlockStoreManager(dataProvider) {
21
- (0, _classCallCheck2.default)(this, SyncBlockStoreManager);
22
- this.syncBlocks = new Map();
23
- this.dataProvider = dataProvider;
24
- }
25
- return (0, _createClass2.default)(SyncBlockStoreManager, [{
26
- key: "setEditorView",
27
- value: function setEditorView(editorView) {
28
- this.editorView = editorView;
29
- }
30
- }, {
31
- key: "isSourceBlock",
32
- value: function isSourceBlock(node) {
33
- var _this$syncBlocks$get;
34
- if (!this.dataProvider || node.type.name !== 'syncBlock') {
35
- return false;
36
- }
37
- var _node$attrs = node.attrs,
38
- resourceId = _node$attrs.resourceId,
39
- localId = _node$attrs.localId;
40
- return this.syncBlocks.has(resourceId) && ((_this$syncBlocks$get = this.syncBlocks.get(resourceId)) === null || _this$syncBlocks$get === void 0 ? void 0 : _this$syncBlocks$get.sourceLocalId) === localId;
41
- }
42
- }, {
43
- key: "registerConfirmationCallback",
44
- value: function registerConfirmationCallback(callback) {
45
- var _this = this;
46
- this.confirmationCallback = callback;
47
- return function () {
48
- _this.confirmationCallback = undefined;
49
- };
50
- }
51
- }, {
52
- key: "requireConfirmationBeforeDelete",
53
- value: function requireConfirmationBeforeDelete() {
54
- return !!this.confirmationCallback;
55
- }
56
- }, {
57
- key: "deleteSyncBlocksWithConfirmation",
58
- value: function () {
59
- var _deleteSyncBlocksWithConfirmation = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(tr, syncBlockIds) {
60
- var _this2 = this;
61
- var confirmed, _this$editorView;
62
- return _regenerator.default.wrap(function _callee$(_context) {
63
- while (1) switch (_context.prev = _context.next) {
64
- case 0:
65
- if (!this.confirmationCallback) {
66
- _context.next = 5;
67
- break;
68
- }
69
- _context.next = 3;
70
- return this.confirmationCallback();
71
- case 3:
72
- confirmed = _context.sent;
73
- if (confirmed) {
74
- // TODO: EDITOR-1779 - "rebase" the transaction to reflect the latest document state
75
- (_this$editorView = this.editorView) === null || _this$editorView === void 0 || _this$editorView.dispatch(tr.setMeta('isConfirmedSyncBlockDeletion', true));
76
- // Need to update the BE on deletion
77
- syncBlockIds.forEach(function (_ref) {
78
- var resourceId = _ref.resourceId;
79
- return _this2.syncBlocks.delete(resourceId);
80
- });
81
- }
82
- case 5:
83
- case "end":
84
- return _context.stop();
85
- }
86
- }, _callee, this);
87
- }));
88
- function deleteSyncBlocksWithConfirmation(_x, _x2) {
89
- return _deleteSyncBlocksWithConfirmation.apply(this, arguments);
90
- }
91
- return deleteSyncBlocksWithConfirmation;
92
- }()
93
- }]);
94
- }();
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,3 +0,0 @@
1
- // Disable no-re-export rule for entry point files
2
- /* eslint-disable @atlaskit/editor/no-re-export */
3
- export { SyncBlockStoreManager } from './sync-block-store-manager';
@@ -1,51 +0,0 @@
1
- // Do this typedef to make it clear that
2
- // this is a local identifier for a resource for local use
3
-
4
- // A store manager responsible for the lifecycle and state management of sync blocks in an editor instance.
5
- // Supports create, read, update, and delete operations for sync blocks.
6
- // Designed to manage local in-memory state and synchronize with an external data provider.
7
- // Handles caching, debouncing updates, and publish/subscribe for local changes.
8
- // Ensures consistency between local and remote state, and can be used in both editor and renderer contexts.
9
- export class SyncBlockStoreManager {
10
- constructor(dataProvider) {
11
- this.syncBlocks = new Map();
12
- this.dataProvider = dataProvider;
13
- }
14
- setEditorView(editorView) {
15
- this.editorView = editorView;
16
- }
17
- isSourceBlock(node) {
18
- var _this$syncBlocks$get;
19
- if (!this.dataProvider || node.type.name !== 'syncBlock') {
20
- return false;
21
- }
22
- const {
23
- resourceId,
24
- localId
25
- } = node.attrs;
26
- return this.syncBlocks.has(resourceId) && ((_this$syncBlocks$get = this.syncBlocks.get(resourceId)) === null || _this$syncBlocks$get === void 0 ? void 0 : _this$syncBlocks$get.sourceLocalId) === localId;
27
- }
28
- registerConfirmationCallback(callback) {
29
- this.confirmationCallback = callback;
30
- return () => {
31
- this.confirmationCallback = undefined;
32
- };
33
- }
34
- requireConfirmationBeforeDelete() {
35
- return !!this.confirmationCallback;
36
- }
37
- async deleteSyncBlocksWithConfirmation(tr, syncBlockIds) {
38
- if (this.confirmationCallback) {
39
- const confirmed = await this.confirmationCallback();
40
- if (confirmed) {
41
- var _this$editorView;
42
- // TODO: EDITOR-1779 - "rebase" the transaction to reflect the latest document state
43
- (_this$editorView = this.editorView) === null || _this$editorView === void 0 ? void 0 : _this$editorView.dispatch(tr.setMeta('isConfirmedSyncBlockDeletion', true));
44
- // Need to update the BE on deletion
45
- syncBlockIds.forEach(({
46
- resourceId
47
- }) => this.syncBlocks.delete(resourceId));
48
- }
49
- }
50
- }
51
- }
File without changes
@@ -1,3 +0,0 @@
1
- // Disable no-re-export rule for entry point files
2
- /* eslint-disable @atlaskit/editor/no-re-export */
3
- export { SyncBlockStoreManager } from './sync-block-store-manager';
@@ -1,88 +0,0 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/createClass";
4
- import _regeneratorRuntime from "@babel/runtime/regenerator";
5
- // Do this typedef to make it clear that
6
- // this is a local identifier for a resource for local use
7
-
8
- // A store manager responsible for the lifecycle and state management of sync blocks in an editor instance.
9
- // Supports create, read, update, and delete operations for sync blocks.
10
- // Designed to manage local in-memory state and synchronize with an external data provider.
11
- // Handles caching, debouncing updates, and publish/subscribe for local changes.
12
- // Ensures consistency between local and remote state, and can be used in both editor and renderer contexts.
13
- export var SyncBlockStoreManager = /*#__PURE__*/function () {
14
- function SyncBlockStoreManager(dataProvider) {
15
- _classCallCheck(this, SyncBlockStoreManager);
16
- this.syncBlocks = new Map();
17
- this.dataProvider = dataProvider;
18
- }
19
- return _createClass(SyncBlockStoreManager, [{
20
- key: "setEditorView",
21
- value: function setEditorView(editorView) {
22
- this.editorView = editorView;
23
- }
24
- }, {
25
- key: "isSourceBlock",
26
- value: function isSourceBlock(node) {
27
- var _this$syncBlocks$get;
28
- if (!this.dataProvider || node.type.name !== 'syncBlock') {
29
- return false;
30
- }
31
- var _node$attrs = node.attrs,
32
- resourceId = _node$attrs.resourceId,
33
- localId = _node$attrs.localId;
34
- return this.syncBlocks.has(resourceId) && ((_this$syncBlocks$get = this.syncBlocks.get(resourceId)) === null || _this$syncBlocks$get === void 0 ? void 0 : _this$syncBlocks$get.sourceLocalId) === localId;
35
- }
36
- }, {
37
- key: "registerConfirmationCallback",
38
- value: function registerConfirmationCallback(callback) {
39
- var _this = this;
40
- this.confirmationCallback = callback;
41
- return function () {
42
- _this.confirmationCallback = undefined;
43
- };
44
- }
45
- }, {
46
- key: "requireConfirmationBeforeDelete",
47
- value: function requireConfirmationBeforeDelete() {
48
- return !!this.confirmationCallback;
49
- }
50
- }, {
51
- key: "deleteSyncBlocksWithConfirmation",
52
- value: function () {
53
- var _deleteSyncBlocksWithConfirmation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(tr, syncBlockIds) {
54
- var _this2 = this;
55
- var confirmed, _this$editorView;
56
- return _regeneratorRuntime.wrap(function _callee$(_context) {
57
- while (1) switch (_context.prev = _context.next) {
58
- case 0:
59
- if (!this.confirmationCallback) {
60
- _context.next = 5;
61
- break;
62
- }
63
- _context.next = 3;
64
- return this.confirmationCallback();
65
- case 3:
66
- confirmed = _context.sent;
67
- if (confirmed) {
68
- // TODO: EDITOR-1779 - "rebase" the transaction to reflect the latest document state
69
- (_this$editorView = this.editorView) === null || _this$editorView === void 0 || _this$editorView.dispatch(tr.setMeta('isConfirmedSyncBlockDeletion', true));
70
- // Need to update the BE on deletion
71
- syncBlockIds.forEach(function (_ref) {
72
- var resourceId = _ref.resourceId;
73
- return _this2.syncBlocks.delete(resourceId);
74
- });
75
- }
76
- case 5:
77
- case "end":
78
- return _context.stop();
79
- }
80
- }, _callee, this);
81
- }));
82
- function deleteSyncBlocksWithConfirmation(_x, _x2) {
83
- return _deleteSyncBlocksWithConfirmation.apply(this, arguments);
84
- }
85
- return deleteSyncBlocksWithConfirmation;
86
- }()
87
- }]);
88
- }();
File without changes
@@ -1,2 +0,0 @@
1
- export { SyncBlockStoreManager } from './sync-block-store-manager';
2
- export type { SyncBlockDataProvider } from './types';
@@ -1,33 +0,0 @@
1
- import type { ADFEntity } from '@atlaskit/adf-utils/types';
2
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
- import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
- import type { SyncBlockDataProvider } from './types';
6
- type ResourceId = string;
7
- export interface SyncBlock {
8
- /**
9
- * The local content of the block,
10
- * this might or might not be synced with the server
11
- */
12
- content?: ADFEntity;
13
- resourceId: string;
14
- sourceLocalId: string;
15
- }
16
- type SyncBlockAttrs = {
17
- localId: string;
18
- resourceId: ResourceId;
19
- };
20
- type ConfirmationCallback = () => Promise<boolean>;
21
- export declare class SyncBlockStoreManager {
22
- private syncBlocks;
23
- private dataProvider?;
24
- private confirmationCallback?;
25
- private editorView?;
26
- constructor(dataProvider?: SyncBlockDataProvider);
27
- setEditorView(editorView: EditorView | undefined): void;
28
- isSourceBlock(node: PMNode): boolean;
29
- registerConfirmationCallback(callback: ConfirmationCallback): () => void;
30
- requireConfirmationBeforeDelete(): boolean;
31
- deleteSyncBlocksWithConfirmation(tr: Transaction, syncBlockIds: SyncBlockAttrs[]): Promise<void>;
32
- }
33
- export {};
@@ -1,2 +0,0 @@
1
- export interface SyncBlockDataProvider {
2
- }
@@ -1,2 +0,0 @@
1
- export { SyncBlockStoreManager } from './sync-block-store-manager';
2
- export type { SyncBlockDataProvider } from './types';
@@ -1,33 +0,0 @@
1
- import type { ADFEntity } from '@atlaskit/adf-utils/types';
2
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
- import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
- import type { SyncBlockDataProvider } from './types';
6
- type ResourceId = string;
7
- export interface SyncBlock {
8
- /**
9
- * The local content of the block,
10
- * this might or might not be synced with the server
11
- */
12
- content?: ADFEntity;
13
- resourceId: string;
14
- sourceLocalId: string;
15
- }
16
- type SyncBlockAttrs = {
17
- localId: string;
18
- resourceId: ResourceId;
19
- };
20
- type ConfirmationCallback = () => Promise<boolean>;
21
- export declare class SyncBlockStoreManager {
22
- private syncBlocks;
23
- private dataProvider?;
24
- private confirmationCallback?;
25
- private editorView?;
26
- constructor(dataProvider?: SyncBlockDataProvider);
27
- setEditorView(editorView: EditorView | undefined): void;
28
- isSourceBlock(node: PMNode): boolean;
29
- registerConfirmationCallback(callback: ConfirmationCallback): () => void;
30
- requireConfirmationBeforeDelete(): boolean;
31
- deleteSyncBlocksWithConfirmation(tr: Transaction, syncBlockIds: SyncBlockAttrs[]): Promise<void>;
32
- }
33
- export {};
@@ -1,2 +0,0 @@
1
- export interface SyncBlockDataProvider {
2
- }