@atlaskit/editor-common 105.1.0 → 105.2.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 (36) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/monitoring/error.js +1 -1
  3. package/dist/cjs/ui/DropList/index.js +1 -1
  4. package/dist/cjs/user-preferences/hooks.js +23 -0
  5. package/dist/cjs/user-preferences/index.js +26 -0
  6. package/dist/cjs/user-preferences/persistence-api.js +5 -0
  7. package/dist/cjs/user-preferences/user-preferences-provider.js +215 -0
  8. package/dist/cjs/user-preferences/user-preferences.js +7 -0
  9. package/dist/es2019/monitoring/error.js +1 -1
  10. package/dist/es2019/ui/DropList/index.js +1 -1
  11. package/dist/es2019/user-preferences/hooks.js +12 -0
  12. package/dist/es2019/user-preferences/index.js +5 -0
  13. package/dist/es2019/user-preferences/persistence-api.js +1 -0
  14. package/dist/es2019/user-preferences/user-preferences-provider.js +134 -0
  15. package/dist/es2019/user-preferences/user-preferences.js +1 -0
  16. package/dist/esm/monitoring/error.js +1 -1
  17. package/dist/esm/ui/DropList/index.js +1 -1
  18. package/dist/esm/user-preferences/hooks.js +16 -0
  19. package/dist/esm/user-preferences/index.js +5 -0
  20. package/dist/esm/user-preferences/persistence-api.js +1 -0
  21. package/dist/esm/user-preferences/user-preferences-provider.js +208 -0
  22. package/dist/esm/user-preferences/user-preferences.js +1 -0
  23. package/dist/types/analytics/types/ai-definitions-events.d.ts +3 -1
  24. package/dist/types/user-preferences/hooks.d.ts +4 -0
  25. package/dist/types/user-preferences/index.d.ts +5 -0
  26. package/dist/types/user-preferences/persistence-api.d.ts +23 -0
  27. package/dist/types/user-preferences/user-preferences-provider.d.ts +64 -0
  28. package/dist/types/user-preferences/user-preferences.d.ts +10 -0
  29. package/dist/types-ts4.5/analytics/types/ai-definitions-events.d.ts +3 -1
  30. package/dist/types-ts4.5/user-preferences/hooks.d.ts +4 -0
  31. package/dist/types-ts4.5/user-preferences/index.d.ts +5 -0
  32. package/dist/types-ts4.5/user-preferences/persistence-api.d.ts +23 -0
  33. package/dist/types-ts4.5/user-preferences/user-preferences-provider.d.ts +64 -0
  34. package/dist/types-ts4.5/user-preferences/user-preferences.d.ts +13 -0
  35. package/package.json +4 -3
  36. package/user-preferences/package.json +17 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 105.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#153475](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/153475)
8
+ [`b9a03a01ca8da`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b9a03a01ca8da) -
9
+ EDITOR-737: Add word count attribute to define button analytics.
10
+ - [#150264](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/150264)
11
+ [`f714a99eb7641`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f714a99eb7641) -
12
+ ED-27284 add user-preferences plugin
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+
3
18
  ## 105.1.0
4
19
 
5
20
  ### Minor Changes
@@ -17,7 +17,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
17
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
18
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
19
19
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
20
- var packageVersion = "105.1.0";
20
+ var packageVersion = "105.2.0";
21
21
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
22
22
  // Remove URL as it has UGC
23
23
  // Ignored via go/ees007
@@ -23,7 +23,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
23
23
  * @jsx jsx
24
24
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
25
25
  var packageName = "@atlaskit/editor-common";
26
- var packageVersion = "105.1.0";
26
+ var packageVersion = "105.2.0";
27
27
  var halfFocusRing = 1;
28
28
  var dropOffset = '0, 8';
29
29
  // Ignored via go/ees005
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useResolvedUserPreferences = useResolvedUserPreferences;
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
+ var _react = require("react");
10
+ function useResolvedUserPreferences(userPreferencesProvider) {
11
+ var _useState = (0, _react.useState)(userPreferencesProvider.getPreferences()),
12
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
13
+ resolvedUserPreferences = _useState2[0],
14
+ setResolvedUserPreferences = _useState2[1];
15
+ (0, _react.useEffect)(function () {
16
+ return userPreferencesProvider.onUpdate(function () {
17
+ setResolvedUserPreferences(userPreferencesProvider.getPreferences());
18
+ });
19
+ }, [userPreferencesProvider]);
20
+ return {
21
+ resolvedUserPreferences: resolvedUserPreferences
22
+ };
23
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "TOOLBAR_DOCKING_POSITIONS", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _userPreferences.TOOLBAR_DOCKING_POSITIONS;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "UserPreferencesProvider", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _userPreferencesProvider.UserPreferencesProvider;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "useResolvedUserPreferences", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _hooks.useResolvedUserPreferences;
22
+ }
23
+ });
24
+ var _userPreferencesProvider = require("./user-preferences-provider");
25
+ var _userPreferences = require("./user-preferences");
26
+ var _hooks = require("./hooks");
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,215 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.UserPreferencesProvider = void 0;
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
+ var UserPreferencesProvider = exports.UserPreferencesProvider = /*#__PURE__*/function () {
17
+ /**
18
+ * @param persistenceAPI - The persistence API to use for loading and updating user preferences
19
+ * @param defaultPreferences - The default user preferences to use
20
+ * @param initialUserPreferences - The initial user preferences to use (optional)
21
+ */
22
+ function UserPreferencesProvider(persistenceAPI, defaultPreferences) {
23
+ var _this$persistenceAPI$, _this$persistenceAPI;
24
+ (0, _classCallCheck2.default)(this, UserPreferencesProvider);
25
+ (0, _defineProperty2.default)(this, "callbacks", []);
26
+ (0, _defineProperty2.default)(this, "userPreferences", {});
27
+ (0, _defineProperty2.default)(this, "initialized", false);
28
+ this.persistenceAPI = persistenceAPI;
29
+ this.defaultPreferences = defaultPreferences;
30
+ this.resolvedUserPreferences = defaultPreferences;
31
+ var initialUserPreferences = (_this$persistenceAPI$ = (_this$persistenceAPI = this.persistenceAPI).getInitialUserPreferences) === null || _this$persistenceAPI$ === void 0 ? void 0 : _this$persistenceAPI$.call(_this$persistenceAPI);
32
+ if (initialUserPreferences) {
33
+ this.setUserPreferences(initialUserPreferences);
34
+ } else {
35
+ this.loadPreferences();
36
+ }
37
+ }
38
+ return (0, _createClass2.default)(UserPreferencesProvider, [{
39
+ key: "isInitialized",
40
+ get: function get() {
41
+ return this.initialized;
42
+ }
43
+
44
+ /**
45
+ * This method fetches the latest user preferences
46
+ * @returns a promise that resolves with the user preferences, or rejects if error occurs
47
+ * @throws Error if there is an error loading user preferences
48
+ */
49
+ }, {
50
+ key: "loadPreferences",
51
+ value: (function () {
52
+ var _loadPreferences = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
53
+ var userPreferences;
54
+ return _regenerator.default.wrap(function _callee$(_context) {
55
+ while (1) switch (_context.prev = _context.next) {
56
+ case 0:
57
+ _context.next = 2;
58
+ return this.persistenceAPI.loadUserPreferences();
59
+ case 2:
60
+ userPreferences = _context.sent;
61
+ this.setUserPreferences(userPreferences);
62
+ case 4:
63
+ case "end":
64
+ return _context.stop();
65
+ }
66
+ }, _callee, this);
67
+ }));
68
+ function loadPreferences() {
69
+ return _loadPreferences.apply(this, arguments);
70
+ }
71
+ return loadPreferences;
72
+ }()
73
+ /**
74
+ * This method updates a user preference
75
+ * @param key
76
+ * @param value
77
+ * @returns a promise that resolves when the user preference is updated
78
+ * @throws Error if there is an error updating user preferences
79
+ */
80
+ )
81
+ }, {
82
+ key: "updatePreference",
83
+ value: (function () {
84
+ var _updatePreference = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(key, value) {
85
+ var userPreferences;
86
+ return _regenerator.default.wrap(function _callee2$(_context2) {
87
+ while (1) switch (_context2.prev = _context2.next) {
88
+ case 0:
89
+ _context2.next = 2;
90
+ return this.persistenceAPI.updateUserPreference(key, value);
91
+ case 2:
92
+ userPreferences = _context2.sent;
93
+ this.setUserPreferences(userPreferences);
94
+ case 4:
95
+ case "end":
96
+ return _context2.stop();
97
+ }
98
+ }, _callee2, this);
99
+ }));
100
+ function updatePreference(_x, _x2) {
101
+ return _updatePreference.apply(this, arguments);
102
+ }
103
+ return updatePreference;
104
+ }()
105
+ /**
106
+ * get a user preference, Note that this function is a not async function,
107
+ * meaning that consumers should prefetch the user preference and make it available initially
108
+ * @param key
109
+ */
110
+ )
111
+ }, {
112
+ key: "getPreference",
113
+ value: function getPreference(key) {
114
+ return this.resolvedUserPreferences[key];
115
+ }
116
+
117
+ /**
118
+ * get all user preferences
119
+ */
120
+ }, {
121
+ key: "getPreferences",
122
+ value: function getPreferences() {
123
+ return this.resolvedUserPreferences;
124
+ }
125
+
126
+ /**
127
+ * This method fetches the latest user preferences
128
+ * @returns a function to unsubscribe from the updates
129
+ */
130
+ }, {
131
+ key: "onUpdate",
132
+ value: function onUpdate(_onUpdate) {
133
+ var _this = this;
134
+ this.callbacks.push(_onUpdate);
135
+
136
+ // Return the cleanup function to unsubscribe from the updates
137
+ return function () {
138
+ _this.callbacks = _this.callbacks.filter(function (callback) {
139
+ return callback !== _onUpdate;
140
+ });
141
+ };
142
+ }
143
+
144
+ /**
145
+ * This method is used to set the default user preferences,
146
+ * setting the default user preferences will also trigger an update
147
+ * This is useful when the default user preferences dynamically based on the context
148
+ * @param preferences
149
+ */
150
+ }, {
151
+ key: "setDefaultPreferences",
152
+ value: function setDefaultPreferences(preferences) {
153
+ this.defaultPreferences = preferences;
154
+ var hasUpdated = this.resolveUserPreferences();
155
+ if (hasUpdated) {
156
+ this.notifyUserPreferencesUpdated();
157
+ }
158
+ }
159
+ }, {
160
+ key: "setUserPreferences",
161
+ value: function setUserPreferences(userPreferences) {
162
+ this.userPreferences = userPreferences;
163
+ var hasUpdated = this.resolveUserPreferences();
164
+ if (hasUpdated || !this.initialized) {
165
+ this.notifyUserPreferencesUpdated();
166
+ }
167
+ if (!this.initialized) {
168
+ this.initialized = true;
169
+ }
170
+ }
171
+ }, {
172
+ key: "notifyUserPreferencesUpdated",
173
+ value: function notifyUserPreferencesUpdated() {
174
+ var _this2 = this;
175
+ this.callbacks.forEach(function (callback) {
176
+ callback(_this2.resolvedUserPreferences);
177
+ });
178
+ }
179
+
180
+ /**
181
+ * This method resolves the user preferences by merging the default preferences
182
+ * with the user preferences and filtering out any undefined or null values
183
+ * to avoid overwriting default preferences with null values
184
+ * @returns true if the user preferences were updated, false otherwise
185
+ */
186
+ }, {
187
+ key: "resolveUserPreferences",
188
+ value: function resolveUserPreferences() {
189
+ var _this3 = this;
190
+ // Merge default preferences with user preferences
191
+ // and filter out any undefined or null values
192
+ // to avoid overwriting default preferences with null values
193
+ var newResolvedUserPreferences = _objectSpread(_objectSpread({}, this.defaultPreferences), Object.fromEntries(Object.entries(this.userPreferences).filter(function (_ref) {
194
+ var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
195
+ v = _ref2[1];
196
+ return v !== undefined && v !== null;
197
+ })));
198
+
199
+ // if the user preferences is NOT initialized, we need to update and notify
200
+ // the user preferences
201
+ // if the user preferences is initialized, we need to check if the new user preferences
202
+ // is different from the old user preferences
203
+ var needUpdate = Object.entries(newResolvedUserPreferences).some(function (_ref3) {
204
+ var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
205
+ key = _ref4[0],
206
+ value = _ref4[1];
207
+ return value !== _this3.resolvedUserPreferences[key];
208
+ });
209
+ if (needUpdate) {
210
+ this.resolvedUserPreferences = newResolvedUserPreferences;
211
+ }
212
+ return needUpdate;
213
+ }
214
+ }]);
215
+ }();
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TOOLBAR_DOCKING_POSITIONS = void 0;
7
+ var TOOLBAR_DOCKING_POSITIONS = exports.TOOLBAR_DOCKING_POSITIONS = ['top', 'none'];
@@ -1,7 +1,7 @@
1
1
  import { isFedRamp } from './environment';
2
2
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
3
3
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
4
- const packageVersion = "105.1.0";
4
+ const packageVersion = "105.2.0";
5
5
  const sanitiseSentryEvents = (data, _hint) => {
6
6
  // Remove URL as it has UGC
7
7
  // Ignored via go/ees007
@@ -13,7 +13,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
13
13
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
14
14
  import Layer from '../Layer';
15
15
  const packageName = "@atlaskit/editor-common";
16
- const packageVersion = "105.1.0";
16
+ const packageVersion = "105.2.0";
17
17
  const halfFocusRing = 1;
18
18
  const dropOffset = '0, 8';
19
19
  // Ignored via go/ees005
@@ -0,0 +1,12 @@
1
+ import { useEffect, useState } from 'react';
2
+ export function useResolvedUserPreferences(userPreferencesProvider) {
3
+ const [resolvedUserPreferences, setResolvedUserPreferences] = useState(userPreferencesProvider.getPreferences());
4
+ useEffect(() => {
5
+ return userPreferencesProvider.onUpdate(() => {
6
+ setResolvedUserPreferences(userPreferencesProvider.getPreferences());
7
+ });
8
+ }, [userPreferencesProvider]);
9
+ return {
10
+ resolvedUserPreferences
11
+ };
12
+ }
@@ -0,0 +1,5 @@
1
+ // Disable no-re-export rule for entry point files
2
+ /* eslint-disable @atlaskit/editor/no-re-export */
3
+ export { UserPreferencesProvider } from './user-preferences-provider';
4
+ export { TOOLBAR_DOCKING_POSITIONS } from './user-preferences';
5
+ export { useResolvedUserPreferences } from './hooks';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,134 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ export class UserPreferencesProvider {
3
+ /**
4
+ * @param persistenceAPI - The persistence API to use for loading and updating user preferences
5
+ * @param defaultPreferences - The default user preferences to use
6
+ * @param initialUserPreferences - The initial user preferences to use (optional)
7
+ */
8
+ constructor(persistenceAPI, defaultPreferences) {
9
+ var _this$persistenceAPI$, _this$persistenceAPI;
10
+ _defineProperty(this, "callbacks", []);
11
+ _defineProperty(this, "userPreferences", {});
12
+ _defineProperty(this, "initialized", false);
13
+ this.persistenceAPI = persistenceAPI;
14
+ this.defaultPreferences = defaultPreferences;
15
+ this.resolvedUserPreferences = defaultPreferences;
16
+ const initialUserPreferences = (_this$persistenceAPI$ = (_this$persistenceAPI = this.persistenceAPI).getInitialUserPreferences) === null || _this$persistenceAPI$ === void 0 ? void 0 : _this$persistenceAPI$.call(_this$persistenceAPI);
17
+ if (initialUserPreferences) {
18
+ this.setUserPreferences(initialUserPreferences);
19
+ } else {
20
+ this.loadPreferences();
21
+ }
22
+ }
23
+ get isInitialized() {
24
+ return this.initialized;
25
+ }
26
+
27
+ /**
28
+ * This method fetches the latest user preferences
29
+ * @returns a promise that resolves with the user preferences, or rejects if error occurs
30
+ * @throws Error if there is an error loading user preferences
31
+ */
32
+ async loadPreferences() {
33
+ const userPreferences = await this.persistenceAPI.loadUserPreferences();
34
+ this.setUserPreferences(userPreferences);
35
+ }
36
+
37
+ /**
38
+ * This method updates a user preference
39
+ * @param key
40
+ * @param value
41
+ * @returns a promise that resolves when the user preference is updated
42
+ * @throws Error if there is an error updating user preferences
43
+ */
44
+ async updatePreference(key, value) {
45
+ const userPreferences = await this.persistenceAPI.updateUserPreference(key, value);
46
+ this.setUserPreferences(userPreferences);
47
+ }
48
+
49
+ /**
50
+ * get a user preference, Note that this function is a not async function,
51
+ * meaning that consumers should prefetch the user preference and make it available initially
52
+ * @param key
53
+ */
54
+ getPreference(key) {
55
+ return this.resolvedUserPreferences[key];
56
+ }
57
+
58
+ /**
59
+ * get all user preferences
60
+ */
61
+ getPreferences() {
62
+ return this.resolvedUserPreferences;
63
+ }
64
+
65
+ /**
66
+ * This method fetches the latest user preferences
67
+ * @returns a function to unsubscribe from the updates
68
+ */
69
+ onUpdate(onUpdate) {
70
+ this.callbacks.push(onUpdate);
71
+
72
+ // Return the cleanup function to unsubscribe from the updates
73
+ return () => {
74
+ this.callbacks = this.callbacks.filter(callback => callback !== onUpdate);
75
+ };
76
+ }
77
+
78
+ /**
79
+ * This method is used to set the default user preferences,
80
+ * setting the default user preferences will also trigger an update
81
+ * This is useful when the default user preferences dynamically based on the context
82
+ * @param preferences
83
+ */
84
+ setDefaultPreferences(preferences) {
85
+ this.defaultPreferences = preferences;
86
+ const hasUpdated = this.resolveUserPreferences();
87
+ if (hasUpdated) {
88
+ this.notifyUserPreferencesUpdated();
89
+ }
90
+ }
91
+ setUserPreferences(userPreferences) {
92
+ this.userPreferences = userPreferences;
93
+ const hasUpdated = this.resolveUserPreferences();
94
+ if (hasUpdated || !this.initialized) {
95
+ this.notifyUserPreferencesUpdated();
96
+ }
97
+ if (!this.initialized) {
98
+ this.initialized = true;
99
+ }
100
+ }
101
+ notifyUserPreferencesUpdated() {
102
+ this.callbacks.forEach(callback => {
103
+ callback(this.resolvedUserPreferences);
104
+ });
105
+ }
106
+
107
+ /**
108
+ * This method resolves the user preferences by merging the default preferences
109
+ * with the user preferences and filtering out any undefined or null values
110
+ * to avoid overwriting default preferences with null values
111
+ * @returns true if the user preferences were updated, false otherwise
112
+ */
113
+ resolveUserPreferences() {
114
+ // Merge default preferences with user preferences
115
+ // and filter out any undefined or null values
116
+ // to avoid overwriting default preferences with null values
117
+ const newResolvedUserPreferences = {
118
+ ...this.defaultPreferences,
119
+ ...Object.fromEntries(Object.entries(this.userPreferences).filter(([, v]) => v !== undefined && v !== null))
120
+ };
121
+
122
+ // if the user preferences is NOT initialized, we need to update and notify
123
+ // the user preferences
124
+ // if the user preferences is initialized, we need to check if the new user preferences
125
+ // is different from the old user preferences
126
+ const needUpdate = Object.entries(newResolvedUserPreferences).some(([key, value]) => {
127
+ return value !== this.resolvedUserPreferences[key];
128
+ });
129
+ if (needUpdate) {
130
+ this.resolvedUserPreferences = newResolvedUserPreferences;
131
+ }
132
+ return needUpdate;
133
+ }
134
+ }
@@ -0,0 +1 @@
1
+ export const TOOLBAR_DOCKING_POSITIONS = ['top', 'none'];
@@ -7,7 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
7
7
  import { isFedRamp } from './environment';
8
8
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
9
9
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
10
- var packageVersion = "105.1.0";
10
+ var packageVersion = "105.2.0";
11
11
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
12
12
  // Remove URL as it has UGC
13
13
  // Ignored via go/ees007
@@ -20,7 +20,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
20
20
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
21
21
  import Layer from '../Layer';
22
22
  var packageName = "@atlaskit/editor-common";
23
- var packageVersion = "105.1.0";
23
+ var packageVersion = "105.2.0";
24
24
  var halfFocusRing = 1;
25
25
  var dropOffset = '0, 8';
26
26
  // Ignored via go/ees005
@@ -0,0 +1,16 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import { useEffect, useState } from 'react';
3
+ export function useResolvedUserPreferences(userPreferencesProvider) {
4
+ var _useState = useState(userPreferencesProvider.getPreferences()),
5
+ _useState2 = _slicedToArray(_useState, 2),
6
+ resolvedUserPreferences = _useState2[0],
7
+ setResolvedUserPreferences = _useState2[1];
8
+ useEffect(function () {
9
+ return userPreferencesProvider.onUpdate(function () {
10
+ setResolvedUserPreferences(userPreferencesProvider.getPreferences());
11
+ });
12
+ }, [userPreferencesProvider]);
13
+ return {
14
+ resolvedUserPreferences: resolvedUserPreferences
15
+ };
16
+ }
@@ -0,0 +1,5 @@
1
+ // Disable no-re-export rule for entry point files
2
+ /* eslint-disable @atlaskit/editor/no-re-export */
3
+ export { UserPreferencesProvider } from './user-preferences-provider';
4
+ export { TOOLBAR_DOCKING_POSITIONS } from './user-preferences';
5
+ export { useResolvedUserPreferences } from './hooks';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,208 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
+ import _createClass from "@babel/runtime/helpers/createClass";
5
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
9
+ export var UserPreferencesProvider = /*#__PURE__*/function () {
10
+ /**
11
+ * @param persistenceAPI - The persistence API to use for loading and updating user preferences
12
+ * @param defaultPreferences - The default user preferences to use
13
+ * @param initialUserPreferences - The initial user preferences to use (optional)
14
+ */
15
+ function UserPreferencesProvider(persistenceAPI, defaultPreferences) {
16
+ var _this$persistenceAPI$, _this$persistenceAPI;
17
+ _classCallCheck(this, UserPreferencesProvider);
18
+ _defineProperty(this, "callbacks", []);
19
+ _defineProperty(this, "userPreferences", {});
20
+ _defineProperty(this, "initialized", false);
21
+ this.persistenceAPI = persistenceAPI;
22
+ this.defaultPreferences = defaultPreferences;
23
+ this.resolvedUserPreferences = defaultPreferences;
24
+ var initialUserPreferences = (_this$persistenceAPI$ = (_this$persistenceAPI = this.persistenceAPI).getInitialUserPreferences) === null || _this$persistenceAPI$ === void 0 ? void 0 : _this$persistenceAPI$.call(_this$persistenceAPI);
25
+ if (initialUserPreferences) {
26
+ this.setUserPreferences(initialUserPreferences);
27
+ } else {
28
+ this.loadPreferences();
29
+ }
30
+ }
31
+ return _createClass(UserPreferencesProvider, [{
32
+ key: "isInitialized",
33
+ get: function get() {
34
+ return this.initialized;
35
+ }
36
+
37
+ /**
38
+ * This method fetches the latest user preferences
39
+ * @returns a promise that resolves with the user preferences, or rejects if error occurs
40
+ * @throws Error if there is an error loading user preferences
41
+ */
42
+ }, {
43
+ key: "loadPreferences",
44
+ value: (function () {
45
+ var _loadPreferences = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
46
+ var userPreferences;
47
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
48
+ while (1) switch (_context.prev = _context.next) {
49
+ case 0:
50
+ _context.next = 2;
51
+ return this.persistenceAPI.loadUserPreferences();
52
+ case 2:
53
+ userPreferences = _context.sent;
54
+ this.setUserPreferences(userPreferences);
55
+ case 4:
56
+ case "end":
57
+ return _context.stop();
58
+ }
59
+ }, _callee, this);
60
+ }));
61
+ function loadPreferences() {
62
+ return _loadPreferences.apply(this, arguments);
63
+ }
64
+ return loadPreferences;
65
+ }()
66
+ /**
67
+ * This method updates a user preference
68
+ * @param key
69
+ * @param value
70
+ * @returns a promise that resolves when the user preference is updated
71
+ * @throws Error if there is an error updating user preferences
72
+ */
73
+ )
74
+ }, {
75
+ key: "updatePreference",
76
+ value: (function () {
77
+ var _updatePreference = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(key, value) {
78
+ var userPreferences;
79
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
80
+ while (1) switch (_context2.prev = _context2.next) {
81
+ case 0:
82
+ _context2.next = 2;
83
+ return this.persistenceAPI.updateUserPreference(key, value);
84
+ case 2:
85
+ userPreferences = _context2.sent;
86
+ this.setUserPreferences(userPreferences);
87
+ case 4:
88
+ case "end":
89
+ return _context2.stop();
90
+ }
91
+ }, _callee2, this);
92
+ }));
93
+ function updatePreference(_x, _x2) {
94
+ return _updatePreference.apply(this, arguments);
95
+ }
96
+ return updatePreference;
97
+ }()
98
+ /**
99
+ * get a user preference, Note that this function is a not async function,
100
+ * meaning that consumers should prefetch the user preference and make it available initially
101
+ * @param key
102
+ */
103
+ )
104
+ }, {
105
+ key: "getPreference",
106
+ value: function getPreference(key) {
107
+ return this.resolvedUserPreferences[key];
108
+ }
109
+
110
+ /**
111
+ * get all user preferences
112
+ */
113
+ }, {
114
+ key: "getPreferences",
115
+ value: function getPreferences() {
116
+ return this.resolvedUserPreferences;
117
+ }
118
+
119
+ /**
120
+ * This method fetches the latest user preferences
121
+ * @returns a function to unsubscribe from the updates
122
+ */
123
+ }, {
124
+ key: "onUpdate",
125
+ value: function onUpdate(_onUpdate) {
126
+ var _this = this;
127
+ this.callbacks.push(_onUpdate);
128
+
129
+ // Return the cleanup function to unsubscribe from the updates
130
+ return function () {
131
+ _this.callbacks = _this.callbacks.filter(function (callback) {
132
+ return callback !== _onUpdate;
133
+ });
134
+ };
135
+ }
136
+
137
+ /**
138
+ * This method is used to set the default user preferences,
139
+ * setting the default user preferences will also trigger an update
140
+ * This is useful when the default user preferences dynamically based on the context
141
+ * @param preferences
142
+ */
143
+ }, {
144
+ key: "setDefaultPreferences",
145
+ value: function setDefaultPreferences(preferences) {
146
+ this.defaultPreferences = preferences;
147
+ var hasUpdated = this.resolveUserPreferences();
148
+ if (hasUpdated) {
149
+ this.notifyUserPreferencesUpdated();
150
+ }
151
+ }
152
+ }, {
153
+ key: "setUserPreferences",
154
+ value: function setUserPreferences(userPreferences) {
155
+ this.userPreferences = userPreferences;
156
+ var hasUpdated = this.resolveUserPreferences();
157
+ if (hasUpdated || !this.initialized) {
158
+ this.notifyUserPreferencesUpdated();
159
+ }
160
+ if (!this.initialized) {
161
+ this.initialized = true;
162
+ }
163
+ }
164
+ }, {
165
+ key: "notifyUserPreferencesUpdated",
166
+ value: function notifyUserPreferencesUpdated() {
167
+ var _this2 = this;
168
+ this.callbacks.forEach(function (callback) {
169
+ callback(_this2.resolvedUserPreferences);
170
+ });
171
+ }
172
+
173
+ /**
174
+ * This method resolves the user preferences by merging the default preferences
175
+ * with the user preferences and filtering out any undefined or null values
176
+ * to avoid overwriting default preferences with null values
177
+ * @returns true if the user preferences were updated, false otherwise
178
+ */
179
+ }, {
180
+ key: "resolveUserPreferences",
181
+ value: function resolveUserPreferences() {
182
+ var _this3 = this;
183
+ // Merge default preferences with user preferences
184
+ // and filter out any undefined or null values
185
+ // to avoid overwriting default preferences with null values
186
+ var newResolvedUserPreferences = _objectSpread(_objectSpread({}, this.defaultPreferences), Object.fromEntries(Object.entries(this.userPreferences).filter(function (_ref) {
187
+ var _ref2 = _slicedToArray(_ref, 2),
188
+ v = _ref2[1];
189
+ return v !== undefined && v !== null;
190
+ })));
191
+
192
+ // if the user preferences is NOT initialized, we need to update and notify
193
+ // the user preferences
194
+ // if the user preferences is initialized, we need to check if the new user preferences
195
+ // is different from the old user preferences
196
+ var needUpdate = Object.entries(newResolvedUserPreferences).some(function (_ref3) {
197
+ var _ref4 = _slicedToArray(_ref3, 2),
198
+ key = _ref4[0],
199
+ value = _ref4[1];
200
+ return value !== _this3.resolvedUserPreferences[key];
201
+ });
202
+ if (needUpdate) {
203
+ this.resolvedUserPreferences = newResolvedUserPreferences;
204
+ }
205
+ return needUpdate;
206
+ }
207
+ }]);
208
+ }();
@@ -0,0 +1 @@
1
+ export var TOOLBAR_DOCKING_POSITIONS = ['top', 'none'];
@@ -3,7 +3,9 @@ import { type OperationalAEP, type UIAEP } from './utils';
3
3
  type CommonAttributes = {
4
4
  readingAidsSessionId: string;
5
5
  };
6
- type DefineButtonClickedAEP = UIAEP<ACTION.CLICKED, ACTION_SUBJECT.BUTTON, ACTION_SUBJECT_ID.AI_DEFINITIONS_DEFINE_BUTTON, CommonAttributes, undefined>;
6
+ type DefineButtonClickedAEP = UIAEP<ACTION.CLICKED, ACTION_SUBJECT.BUTTON, ACTION_SUBJECT_ID.AI_DEFINITIONS_DEFINE_BUTTON, CommonAttributes & {
7
+ wordCount: number;
8
+ }, undefined>;
7
9
  type AutoHighlightClickedAEP = UIAEP<ACTION.CLICKED, ACTION_SUBJECT.DECORATION, ACTION_SUBJECT_ID.AI_DEFINITIONS_AUTO_HIGHLIGHT, CommonAttributes, undefined>;
8
10
  type AIDefinitionsErrorAEP = OperationalAEP<ACTION.ERRORED, ACTION_SUBJECT.AI_DEFINITIONS, ACTION_SUBJECT_ID, {
9
11
  errorMessage?: string;
@@ -0,0 +1,4 @@
1
+ import { UserPreferencesProvider } from './user-preferences-provider';
2
+ export declare function useResolvedUserPreferences(userPreferencesProvider: UserPreferencesProvider): {
3
+ resolvedUserPreferences: import("./user-preferences").ResolvedUserPreferences<import("./user-preferences").UserPreferences>;
4
+ };
@@ -0,0 +1,5 @@
1
+ export { UserPreferencesProvider } from './user-preferences-provider';
2
+ export type { UserPreferences, ResolvedUserPreferences, ToolbarDocking } from './user-preferences';
3
+ export type { PersistenceAPI } from './persistence-api';
4
+ export { TOOLBAR_DOCKING_POSITIONS } from './user-preferences';
5
+ export { useResolvedUserPreferences } from './hooks';
@@ -0,0 +1,23 @@
1
+ import { UserPreferences } from './user-preferences';
2
+ export type PersistenceAPI = {
3
+ /**
4
+ * Loads the user preferences
5
+ * @returns
6
+ */
7
+ loadUserPreferences: () => Promise<UserPreferences>;
8
+ /**
9
+ * Update a single user preference
10
+ * @param key
11
+ * @param value
12
+ * @returns
13
+ */
14
+ updateUserPreference: <K extends keyof UserPreferences>(key: K, value: UserPreferences[K]) => Promise<UserPreferences>;
15
+ /**
16
+ * Get the initial user preferences synchronously
17
+ * This function is called on initialization
18
+ * If not provided, loadUserPreferences will be called instead
19
+ * @param userPreferences
20
+ * @returns
21
+ */
22
+ getInitialUserPreferences?: () => UserPreferences | undefined;
23
+ };
@@ -0,0 +1,64 @@
1
+ import { PersistenceAPI } from './persistence-api';
2
+ import { ResolvedUserPreferences, UserPreferences } from './user-preferences';
3
+ type UpdateCallback = (userPreferences: UserPreferences) => void;
4
+ export declare class UserPreferencesProvider {
5
+ private callbacks;
6
+ private userPreferences;
7
+ private defaultPreferences;
8
+ private resolvedUserPreferences;
9
+ private initialized;
10
+ private persistenceAPI;
11
+ /**
12
+ * @param persistenceAPI - The persistence API to use for loading and updating user preferences
13
+ * @param defaultPreferences - The default user preferences to use
14
+ * @param initialUserPreferences - The initial user preferences to use (optional)
15
+ */
16
+ constructor(persistenceAPI: PersistenceAPI, defaultPreferences: ResolvedUserPreferences);
17
+ get isInitialized(): boolean;
18
+ /**
19
+ * This method fetches the latest user preferences
20
+ * @returns a promise that resolves with the user preferences, or rejects if error occurs
21
+ * @throws Error if there is an error loading user preferences
22
+ */
23
+ loadPreferences(): Promise<void>;
24
+ /**
25
+ * This method updates a user preference
26
+ * @param key
27
+ * @param value
28
+ * @returns a promise that resolves when the user preference is updated
29
+ * @throws Error if there is an error updating user preferences
30
+ */
31
+ updatePreference<K extends keyof UserPreferences>(key: K, value: UserPreferences[K]): Promise<void>;
32
+ /**
33
+ * get a user preference, Note that this function is a not async function,
34
+ * meaning that consumers should prefetch the user preference and make it available initially
35
+ * @param key
36
+ */
37
+ getPreference<K extends keyof ResolvedUserPreferences>(key: K): ResolvedUserPreferences[K];
38
+ /**
39
+ * get all user preferences
40
+ */
41
+ getPreferences(): ResolvedUserPreferences;
42
+ /**
43
+ * This method fetches the latest user preferences
44
+ * @returns a function to unsubscribe from the updates
45
+ */
46
+ onUpdate(onUpdate: UpdateCallback): () => void;
47
+ /**
48
+ * This method is used to set the default user preferences,
49
+ * setting the default user preferences will also trigger an update
50
+ * This is useful when the default user preferences dynamically based on the context
51
+ * @param preferences
52
+ */
53
+ setDefaultPreferences(preferences: ResolvedUserPreferences): void;
54
+ private setUserPreferences;
55
+ notifyUserPreferencesUpdated(): void;
56
+ /**
57
+ * This method resolves the user preferences by merging the default preferences
58
+ * with the user preferences and filtering out any undefined or null values
59
+ * to avoid overwriting default preferences with null values
60
+ * @returns true if the user preferences were updated, false otherwise
61
+ */
62
+ private resolveUserPreferences;
63
+ }
64
+ export {};
@@ -0,0 +1,10 @@
1
+ export declare const TOOLBAR_DOCKING_POSITIONS: readonly ["top", "none"];
2
+ export type ToolbarDocking = (typeof TOOLBAR_DOCKING_POSITIONS)[number];
3
+ export type UserPreferences = {
4
+ toolbarDockingPosition?: ToolbarDocking;
5
+ };
6
+ type Must<T> = {
7
+ [P in keyof T]-?: NonNullable<T[P]>;
8
+ };
9
+ export type ResolvedUserPreferences = Must<UserPreferences>;
10
+ export {};
@@ -3,7 +3,9 @@ import { type OperationalAEP, type UIAEP } from './utils';
3
3
  type CommonAttributes = {
4
4
  readingAidsSessionId: string;
5
5
  };
6
- type DefineButtonClickedAEP = UIAEP<ACTION.CLICKED, ACTION_SUBJECT.BUTTON, ACTION_SUBJECT_ID.AI_DEFINITIONS_DEFINE_BUTTON, CommonAttributes, undefined>;
6
+ type DefineButtonClickedAEP = UIAEP<ACTION.CLICKED, ACTION_SUBJECT.BUTTON, ACTION_SUBJECT_ID.AI_DEFINITIONS_DEFINE_BUTTON, CommonAttributes & {
7
+ wordCount: number;
8
+ }, undefined>;
7
9
  type AutoHighlightClickedAEP = UIAEP<ACTION.CLICKED, ACTION_SUBJECT.DECORATION, ACTION_SUBJECT_ID.AI_DEFINITIONS_AUTO_HIGHLIGHT, CommonAttributes, undefined>;
8
10
  type AIDefinitionsErrorAEP = OperationalAEP<ACTION.ERRORED, ACTION_SUBJECT.AI_DEFINITIONS, ACTION_SUBJECT_ID, {
9
11
  errorMessage?: string;
@@ -0,0 +1,4 @@
1
+ import { UserPreferencesProvider } from './user-preferences-provider';
2
+ export declare function useResolvedUserPreferences(userPreferencesProvider: UserPreferencesProvider): {
3
+ resolvedUserPreferences: import("./user-preferences").ResolvedUserPreferences<import("./user-preferences").UserPreferences>;
4
+ };
@@ -0,0 +1,5 @@
1
+ export { UserPreferencesProvider } from './user-preferences-provider';
2
+ export type { UserPreferences, ResolvedUserPreferences, ToolbarDocking } from './user-preferences';
3
+ export type { PersistenceAPI } from './persistence-api';
4
+ export { TOOLBAR_DOCKING_POSITIONS } from './user-preferences';
5
+ export { useResolvedUserPreferences } from './hooks';
@@ -0,0 +1,23 @@
1
+ import { UserPreferences } from './user-preferences';
2
+ export type PersistenceAPI = {
3
+ /**
4
+ * Loads the user preferences
5
+ * @returns
6
+ */
7
+ loadUserPreferences: () => Promise<UserPreferences>;
8
+ /**
9
+ * Update a single user preference
10
+ * @param key
11
+ * @param value
12
+ * @returns
13
+ */
14
+ updateUserPreference: <K extends keyof UserPreferences>(key: K, value: UserPreferences[K]) => Promise<UserPreferences>;
15
+ /**
16
+ * Get the initial user preferences synchronously
17
+ * This function is called on initialization
18
+ * If not provided, loadUserPreferences will be called instead
19
+ * @param userPreferences
20
+ * @returns
21
+ */
22
+ getInitialUserPreferences?: () => UserPreferences | undefined;
23
+ };
@@ -0,0 +1,64 @@
1
+ import { PersistenceAPI } from './persistence-api';
2
+ import { ResolvedUserPreferences, UserPreferences } from './user-preferences';
3
+ type UpdateCallback = (userPreferences: UserPreferences) => void;
4
+ export declare class UserPreferencesProvider {
5
+ private callbacks;
6
+ private userPreferences;
7
+ private defaultPreferences;
8
+ private resolvedUserPreferences;
9
+ private initialized;
10
+ private persistenceAPI;
11
+ /**
12
+ * @param persistenceAPI - The persistence API to use for loading and updating user preferences
13
+ * @param defaultPreferences - The default user preferences to use
14
+ * @param initialUserPreferences - The initial user preferences to use (optional)
15
+ */
16
+ constructor(persistenceAPI: PersistenceAPI, defaultPreferences: ResolvedUserPreferences);
17
+ get isInitialized(): boolean;
18
+ /**
19
+ * This method fetches the latest user preferences
20
+ * @returns a promise that resolves with the user preferences, or rejects if error occurs
21
+ * @throws Error if there is an error loading user preferences
22
+ */
23
+ loadPreferences(): Promise<void>;
24
+ /**
25
+ * This method updates a user preference
26
+ * @param key
27
+ * @param value
28
+ * @returns a promise that resolves when the user preference is updated
29
+ * @throws Error if there is an error updating user preferences
30
+ */
31
+ updatePreference<K extends keyof UserPreferences>(key: K, value: UserPreferences[K]): Promise<void>;
32
+ /**
33
+ * get a user preference, Note that this function is a not async function,
34
+ * meaning that consumers should prefetch the user preference and make it available initially
35
+ * @param key
36
+ */
37
+ getPreference<K extends keyof ResolvedUserPreferences>(key: K): ResolvedUserPreferences[K];
38
+ /**
39
+ * get all user preferences
40
+ */
41
+ getPreferences(): ResolvedUserPreferences;
42
+ /**
43
+ * This method fetches the latest user preferences
44
+ * @returns a function to unsubscribe from the updates
45
+ */
46
+ onUpdate(onUpdate: UpdateCallback): () => void;
47
+ /**
48
+ * This method is used to set the default user preferences,
49
+ * setting the default user preferences will also trigger an update
50
+ * This is useful when the default user preferences dynamically based on the context
51
+ * @param preferences
52
+ */
53
+ setDefaultPreferences(preferences: ResolvedUserPreferences): void;
54
+ private setUserPreferences;
55
+ notifyUserPreferencesUpdated(): void;
56
+ /**
57
+ * This method resolves the user preferences by merging the default preferences
58
+ * with the user preferences and filtering out any undefined or null values
59
+ * to avoid overwriting default preferences with null values
60
+ * @returns true if the user preferences were updated, false otherwise
61
+ */
62
+ private resolveUserPreferences;
63
+ }
64
+ export {};
@@ -0,0 +1,13 @@
1
+ export declare const TOOLBAR_DOCKING_POSITIONS: readonly [
2
+ "top",
3
+ "none"
4
+ ];
5
+ export type ToolbarDocking = (typeof TOOLBAR_DOCKING_POSITIONS)[number];
6
+ export type UserPreferences = {
7
+ toolbarDockingPosition?: ToolbarDocking;
8
+ };
9
+ type Must<T> = {
10
+ [P in keyof T]-?: NonNullable<T[P]>;
11
+ };
12
+ export type ResolvedUserPreferences = Must<UserPreferences>;
13
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "105.1.0",
3
+ "version": "105.2.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/"
@@ -109,6 +109,7 @@
109
109
  "./intl-error-boundary": "./src/ui/IntlErrorBoundary/index.tsx",
110
110
  "./code-block": "./src/code-block/index.ts",
111
111
  "./table": "./src/table/index.ts",
112
+ "./user-preferences": "./src/user-preferences/index.ts",
112
113
  "./use-plugin-state-effect": "./src/hooks/usePluginStateEffect.ts",
113
114
  "./use-shared-plugin-state-selector": "./src/hooks/useSharedPluginStateSelector/index.ts",
114
115
  "./lazy-node-view": "./src/lazy-node-view/index.ts",
@@ -160,13 +161,13 @@
160
161
  "@atlaskit/profilecard": "^23.11.0",
161
162
  "@atlaskit/react-ufo": "^3.11.0",
162
163
  "@atlaskit/section-message": "^8.2.0",
163
- "@atlaskit/smart-card": "^37.1.0",
164
+ "@atlaskit/smart-card": "^38.0.0",
164
165
  "@atlaskit/smart-user-picker": "^8.0.0",
165
166
  "@atlaskit/spinner": "^18.0.0",
166
167
  "@atlaskit/task-decision": "^19.2.0",
167
168
  "@atlaskit/textfield": "^8.0.0",
168
169
  "@atlaskit/theme": "^18.0.0",
169
- "@atlaskit/tmp-editor-statsig": "^4.20.0",
170
+ "@atlaskit/tmp-editor-statsig": "^4.21.0",
170
171
  "@atlaskit/tokens": "^4.8.0",
171
172
  "@atlaskit/tooltip": "^20.0.0",
172
173
  "@atlaskit/width-detector": "^5.0.0",
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@atlaskit/editor-common/user-preferences",
3
+ "main": "../dist/cjs/user-preferences/index.js",
4
+ "module": "../dist/esm/user-preferences/index.js",
5
+ "module:es2019": "../dist/es2019/user-preferences/index.js",
6
+ "sideEffects": [
7
+ "**/*.compiled.css"
8
+ ],
9
+ "types": "../dist/types/user-preferences/index.d.ts",
10
+ "typesVersions": {
11
+ ">=4.5 <5.4": {
12
+ "*": [
13
+ "../dist/types-ts4.5/user-preferences/index.d.ts"
14
+ ]
15
+ }
16
+ }
17
+ }