@atlaskit/editor-plugin-user-preferences 0.2.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,57 @@
1
1
  # @atlaskit/editor-plugin-user-preferences
2
2
 
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#181024](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/181024)
8
+ [`8e80c487ca307`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8e80c487ca307) - ##
9
+ Make `@atlaskit/editor-common` a peer dependency
10
+
11
+ **WHAT:** `@atlaskit/editor-common` has been moved from `dependencies` to `peerDependencies` in
12
+ all editor plugin packages.
13
+
14
+ **WHY:** This change ensures that only a single version of `@atlaskit/editor-common` is used in
15
+ consuming applications, preventing issues caused by multiple versions of singleton libraries (such
16
+ as context mismatches or duplicated state). This is especially important for packages that rely on
17
+ shared context or singletons.
18
+
19
+ **HOW TO ADJUST:**
20
+
21
+ - Consumers must now explicitly install `@atlaskit/editor-common` in their own project if they use
22
+ any of these editor plugins.
23
+ - Ensure the version you install matches the version required by the plugins.
24
+ - You can use the
25
+ [`check-peer-dependencies`](https://www.npmjs.com/package/check-peer-dependencies) package to
26
+ verify that all required peer dependencies are installed and compatible.
27
+ - Example install command:
28
+ ```
29
+ npm install @atlaskit/editor-common
30
+ ```
31
+ or
32
+ ```
33
+ yarn add @atlaskit/editor-common
34
+ ```
35
+
36
+ **Note:** This is a breaking change. If `@atlaskit/editor-common` is not installed at the
37
+ application level, you may see errors or unexpected behavior.
38
+
39
+ ### Patch Changes
40
+
41
+ - Updated dependencies
42
+
43
+ ## 0.3.0
44
+
45
+ ### Minor Changes
46
+
47
+ - [#177157](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/177157)
48
+ [`6bcf8912217df`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6bcf8912217df) -
49
+ ED-27284 additional integration with user preference plugin
50
+
51
+ ### Patch Changes
52
+
53
+ - Updated dependencies
54
+
3
55
  ## 0.2.2
4
56
 
5
57
  ### Patch Changes
@@ -17,9 +17,6 @@
17
17
  "../src/**/examples.*"
18
18
  ],
19
19
  "references": [
20
- {
21
- "path": "../../editor-common/afm-cc/tsconfig.json"
22
- },
23
20
  {
24
21
  "path": "../../editor-plugin-analytics/afm-cc/tsconfig.json"
25
22
  },
@@ -28,6 +25,9 @@
28
25
  },
29
26
  {
30
27
  "path": "../../tmp-editor-statsig/afm-cc/tsconfig.json"
28
+ },
29
+ {
30
+ "path": "../../editor-common/afm-cc/tsconfig.json"
31
31
  }
32
32
  ]
33
33
  }
@@ -17,9 +17,6 @@
17
17
  "../src/**/examples.*"
18
18
  ],
19
19
  "references": [
20
- {
21
- "path": "../../editor-common/afm-jira/tsconfig.json"
22
- },
23
20
  {
24
21
  "path": "../../editor-plugin-analytics/afm-jira/tsconfig.json"
25
22
  },
@@ -28,6 +25,9 @@
28
25
  },
29
26
  {
30
27
  "path": "../../tmp-editor-statsig/afm-jira/tsconfig.json"
28
+ },
29
+ {
30
+ "path": "../../editor-common/afm-jira/tsconfig.json"
31
31
  }
32
32
  ]
33
33
  }
@@ -17,9 +17,6 @@
17
17
  "../src/**/examples.*"
18
18
  ],
19
19
  "references": [
20
- {
21
- "path": "../../editor-common/afm-post-office/tsconfig.json"
22
- },
23
20
  {
24
21
  "path": "../../editor-plugin-analytics/afm-post-office/tsconfig.json"
25
22
  },
@@ -28,6 +25,9 @@
28
25
  },
29
26
  {
30
27
  "path": "../../tmp-editor-statsig/afm-post-office/tsconfig.json"
28
+ },
29
+ {
30
+ "path": "../../editor-common/afm-post-office/tsconfig.json"
31
31
  }
32
32
  ]
33
33
  }
@@ -0,0 +1,33 @@
1
+ {
2
+ "extends": "../../../../tsconfig.entry-points.volt.json",
3
+ "compilerOptions": {
4
+ "target": "es5",
5
+ "outDir": "../../../../../volt/tsDist/@atlaskit__editor-plugin-user-preferences/app",
6
+ "rootDir": "../",
7
+ "composite": true
8
+ },
9
+ "include": [
10
+ "../src/**/*.ts",
11
+ "../src/**/*.tsx"
12
+ ],
13
+ "exclude": [
14
+ "../src/**/__tests__/*",
15
+ "../src/**/*.test.*",
16
+ "../src/**/test.*",
17
+ "../src/**/examples.*"
18
+ ],
19
+ "references": [
20
+ {
21
+ "path": "../../editor-common/afm-volt/tsconfig.json"
22
+ },
23
+ {
24
+ "path": "../../editor-plugin-analytics/afm-volt/tsconfig.json"
25
+ },
26
+ {
27
+ "path": "../../../platform/feature-flags/afm-volt/tsconfig.json"
28
+ },
29
+ {
30
+ "path": "../../tmp-editor-statsig/afm-volt/tsconfig.json"
31
+ }
32
+ ]
33
+ }
@@ -7,7 +7,6 @@ exports.userPreferencesPlugin = void 0;
7
7
  var _userPreferences = require("@atlaskit/editor-common/user-preferences");
8
8
  var _commands = require("./pm-plugins/commands");
9
9
  var _main = require("./pm-plugins/main");
10
- var _useDocumentVisibilityWatcher = require("./ui/useDocumentVisibilityWatcher");
11
10
  var _useUserPreferencesInitListener = require("./ui/useUserPreferencesInitListener");
12
11
  var _useUserPreferencesUpdateListener = require("./ui/useUserPreferencesUpdateListener");
13
12
  var userPreferencesPlugin = exports.userPreferencesPlugin = function userPreferencesPlugin(_ref) {
@@ -46,7 +45,6 @@ var userPreferencesPlugin = exports.userPreferencesPlugin = function userPrefere
46
45
  var _useResolvedUserPrefe = (0, _userPreferences.useResolvedUserPreferences)(userPreferencesProvider),
47
46
  resolvedUserPreferences = _useResolvedUserPrefe.resolvedUserPreferences;
48
47
  (0, _useUserPreferencesUpdateListener.useUserPreferencesUpdateListener)(editorView, resolvedUserPreferences);
49
- (0, _useDocumentVisibilityWatcher.useDocumentVisibilityWatcher)(userPreferencesProvider);
50
48
  (0, _useUserPreferencesInitListener.useUserPreferencesInitListener)(Boolean(userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.isInitialized), resolvedUserPreferences, api);
51
49
  }
52
50
  };
@@ -1,7 +1,6 @@
1
1
  import { useResolvedUserPreferences } from '@atlaskit/editor-common/user-preferences';
2
2
  import { updateUserPreference } from './pm-plugins/commands';
3
3
  import { createPlugin, userPreferencesPluginKey } from './pm-plugins/main';
4
- import { useDocumentVisibilityWatcher } from './ui/useDocumentVisibilityWatcher';
5
4
  import { useUserPreferencesInitListener } from './ui/useUserPreferencesInitListener';
6
5
  import { useUserPreferencesUpdateListener } from './ui/useUserPreferencesUpdateListener';
7
6
  export const userPreferencesPlugin = ({
@@ -43,7 +42,6 @@ export const userPreferencesPlugin = ({
43
42
  resolvedUserPreferences
44
43
  } = useResolvedUserPreferences(userPreferencesProvider);
45
44
  useUserPreferencesUpdateListener(editorView, resolvedUserPreferences);
46
- useDocumentVisibilityWatcher(userPreferencesProvider);
47
45
  useUserPreferencesInitListener(Boolean(userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.isInitialized), resolvedUserPreferences, api);
48
46
  }
49
47
  };
@@ -1,7 +1,6 @@
1
1
  import { useResolvedUserPreferences } from '@atlaskit/editor-common/user-preferences';
2
2
  import { updateUserPreference as _updateUserPreference } from './pm-plugins/commands';
3
3
  import { createPlugin, userPreferencesPluginKey } from './pm-plugins/main';
4
- import { useDocumentVisibilityWatcher } from './ui/useDocumentVisibilityWatcher';
5
4
  import { useUserPreferencesInitListener } from './ui/useUserPreferencesInitListener';
6
5
  import { useUserPreferencesUpdateListener } from './ui/useUserPreferencesUpdateListener';
7
6
  export var userPreferencesPlugin = function userPreferencesPlugin(_ref) {
@@ -40,7 +39,6 @@ export var userPreferencesPlugin = function userPreferencesPlugin(_ref) {
40
39
  var _useResolvedUserPrefe = useResolvedUserPreferences(userPreferencesProvider),
41
40
  resolvedUserPreferences = _useResolvedUserPrefe.resolvedUserPreferences;
42
41
  useUserPreferencesUpdateListener(editorView, resolvedUserPreferences);
43
- useDocumentVisibilityWatcher(userPreferencesProvider);
44
42
  useUserPreferencesInitListener(Boolean(userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.isInitialized), resolvedUserPreferences, api);
45
43
  }
46
44
  };
@@ -1,6 +1,6 @@
1
1
  import { type EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
2
  import type { EditorCommand } from '@atlaskit/editor-common/types';
3
- import { type ResolvedUserPreferences, type UserPreferences, UserPreferencesProvider } from '@atlaskit/editor-common/user-preferences';
3
+ import { type ResolvedUserPreferences, type UserPreferences, type UserPreferencesProvider } from '@atlaskit/editor-common/user-preferences';
4
4
  export declare const updateUserPreference: ({ key, value, userPreferencesProvider, editorAnalyticsApi, }: {
5
5
  key: keyof UserPreferences;
6
6
  value: "top" | "none";
@@ -1,4 +1,4 @@
1
- import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
- import { ResolvedUserPreferences } from '@atlaskit/editor-common/user-preferences';
3
- import { UserPreferencesPlugin } from '../userPreferencesPluginType';
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { ResolvedUserPreferences } from '@atlaskit/editor-common/user-preferences';
3
+ import type { UserPreferencesPlugin } from '../userPreferencesPluginType';
4
4
  export declare const useUserPreferencesInitListener: (isInitialized: boolean, resolvedUserPreferences: ResolvedUserPreferences | null, api?: ExtractInjectionAPI<UserPreferencesPlugin>) => void;
@@ -1,3 +1,3 @@
1
- import { ResolvedUserPreferences } from '@atlaskit/editor-common/user-preferences';
2
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
1
+ import type { ResolvedUserPreferences } from '@atlaskit/editor-common/user-preferences';
2
+ import { type EditorView } from '@atlaskit/editor-prosemirror/view';
3
3
  export declare const useUserPreferencesUpdateListener: (editorView: EditorView, resolvedUserPreferences: ResolvedUserPreferences | null) => void;
@@ -1,6 +1,6 @@
1
1
  import { type EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
2
  import type { EditorCommand } from '@atlaskit/editor-common/types';
3
- import { type ResolvedUserPreferences, type UserPreferences, UserPreferencesProvider } from '@atlaskit/editor-common/user-preferences';
3
+ import { type ResolvedUserPreferences, type UserPreferences, type UserPreferencesProvider } from '@atlaskit/editor-common/user-preferences';
4
4
  export declare const updateUserPreference: ({ key, value, userPreferencesProvider, editorAnalyticsApi, }: {
5
5
  key: keyof UserPreferences;
6
6
  value: "top" | "none";
@@ -1,4 +1,4 @@
1
- import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
- import { ResolvedUserPreferences } from '@atlaskit/editor-common/user-preferences';
3
- import { UserPreferencesPlugin } from '../userPreferencesPluginType';
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { ResolvedUserPreferences } from '@atlaskit/editor-common/user-preferences';
3
+ import type { UserPreferencesPlugin } from '../userPreferencesPluginType';
4
4
  export declare const useUserPreferencesInitListener: (isInitialized: boolean, resolvedUserPreferences: ResolvedUserPreferences | null, api?: ExtractInjectionAPI<UserPreferencesPlugin>) => void;
@@ -1,3 +1,3 @@
1
- import { ResolvedUserPreferences } from '@atlaskit/editor-common/user-preferences';
2
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
1
+ import type { ResolvedUserPreferences } from '@atlaskit/editor-common/user-preferences';
2
+ import { type EditorView } from '@atlaskit/editor-prosemirror/view';
3
3
  export declare const useUserPreferencesUpdateListener: (editorView: EditorView, resolvedUserPreferences: ResolvedUserPreferences | null) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-user-preferences",
3
- "version": "0.2.2",
3
+ "version": "1.0.0",
4
4
  "description": "UserPreferences plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -10,8 +10,7 @@
10
10
  "atlassian": {
11
11
  "team": "Editor: Lego",
12
12
  "releaseModel": "continuous",
13
- "singleton": true,
14
- "runReact18": true
13
+ "singleton": true
15
14
  },
16
15
  "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
17
16
  "main": "dist/cjs/index.js",
@@ -32,15 +31,15 @@
32
31
  ".": "./src/index.ts"
33
32
  },
34
33
  "dependencies": {
35
- "@atlaskit/editor-common": "^107.0.0",
36
- "@atlaskit/editor-plugin-analytics": "^2.3.0",
34
+ "@atlaskit/editor-plugin-analytics": "^3.0.0",
37
35
  "@atlaskit/editor-prosemirror": "7.0.0",
38
36
  "@atlaskit/platform-feature-flags": "^1.1.0",
39
- "@atlaskit/tmp-editor-statsig": "^8.0.0",
37
+ "@atlaskit/tmp-editor-statsig": "^8.7.0",
40
38
  "@babel/runtime": "^7.0.0",
41
39
  "bind-event-listener": "^3.0.0"
42
40
  },
43
41
  "peerDependencies": {
42
+ "@atlaskit/editor-common": "^107.6.0",
44
43
  "react": "^18.2.0"
45
44
  },
46
45
  "devDependencies": {
@@ -1,53 +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.useDocumentVisibilityWatcher = void 0;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
- var _react = require("react");
11
- var _bindEventListener = require("bind-event-listener");
12
- var _monitoring = require("@atlaskit/editor-common/monitoring");
13
- var useDocumentVisibilityWatcher = exports.useDocumentVisibilityWatcher = function useDocumentVisibilityWatcher(userPreferencesProvider) {
14
- (0, _react.useEffect)(function () {
15
- if (userPreferencesProvider) {
16
- var refreshPreferences = /*#__PURE__*/function () {
17
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
18
- return _regenerator.default.wrap(function _callee$(_context) {
19
- while (1) switch (_context.prev = _context.next) {
20
- case 0:
21
- if (!(document.visibilityState === 'visible')) {
22
- _context.next = 9;
23
- break;
24
- }
25
- _context.prev = 1;
26
- _context.next = 4;
27
- return userPreferencesProvider.loadPreferences();
28
- case 4:
29
- _context.next = 9;
30
- break;
31
- case 6:
32
- _context.prev = 6;
33
- _context.t0 = _context["catch"](1);
34
- (0, _monitoring.logException)(_context.t0, {
35
- location: 'editor-plugin-user-preferences/userPreferencesPlugin'
36
- });
37
- case 9:
38
- case "end":
39
- return _context.stop();
40
- }
41
- }, _callee, null, [[1, 6]]);
42
- }));
43
- return function refreshPreferences() {
44
- return _ref.apply(this, arguments);
45
- };
46
- }();
47
- return (0, _bindEventListener.bind)(document, {
48
- type: 'visibilitychange',
49
- listener: refreshPreferences
50
- });
51
- }
52
- }, [userPreferencesProvider]);
53
- };
@@ -1,24 +0,0 @@
1
- import { useEffect } from 'react';
2
- import { bind } from 'bind-event-listener';
3
- import { logException } from '@atlaskit/editor-common/monitoring';
4
- export const useDocumentVisibilityWatcher = userPreferencesProvider => {
5
- useEffect(() => {
6
- if (userPreferencesProvider) {
7
- const refreshPreferences = async () => {
8
- if (document.visibilityState === 'visible') {
9
- try {
10
- await userPreferencesProvider.loadPreferences();
11
- } catch (error) {
12
- logException(error, {
13
- location: 'editor-plugin-user-preferences/userPreferencesPlugin'
14
- });
15
- }
16
- }
17
- };
18
- return bind(document, {
19
- type: 'visibilitychange',
20
- listener: refreshPreferences
21
- });
22
- }
23
- }, [userPreferencesProvider]);
24
- };
@@ -1,46 +0,0 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
- import _regeneratorRuntime from "@babel/runtime/regenerator";
3
- import { useEffect } from 'react';
4
- import { bind } from 'bind-event-listener';
5
- import { logException } from '@atlaskit/editor-common/monitoring';
6
- export var useDocumentVisibilityWatcher = function useDocumentVisibilityWatcher(userPreferencesProvider) {
7
- useEffect(function () {
8
- if (userPreferencesProvider) {
9
- var refreshPreferences = /*#__PURE__*/function () {
10
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
11
- return _regeneratorRuntime.wrap(function _callee$(_context) {
12
- while (1) switch (_context.prev = _context.next) {
13
- case 0:
14
- if (!(document.visibilityState === 'visible')) {
15
- _context.next = 9;
16
- break;
17
- }
18
- _context.prev = 1;
19
- _context.next = 4;
20
- return userPreferencesProvider.loadPreferences();
21
- case 4:
22
- _context.next = 9;
23
- break;
24
- case 6:
25
- _context.prev = 6;
26
- _context.t0 = _context["catch"](1);
27
- logException(_context.t0, {
28
- location: 'editor-plugin-user-preferences/userPreferencesPlugin'
29
- });
30
- case 9:
31
- case "end":
32
- return _context.stop();
33
- }
34
- }, _callee, null, [[1, 6]]);
35
- }));
36
- return function refreshPreferences() {
37
- return _ref.apply(this, arguments);
38
- };
39
- }();
40
- return bind(document, {
41
- type: 'visibilitychange',
42
- listener: refreshPreferences
43
- });
44
- }
45
- }, [userPreferencesProvider]);
46
- };
@@ -1,2 +0,0 @@
1
- import { UserPreferencesProvider } from '@atlaskit/editor-common/user-preferences';
2
- export declare const useDocumentVisibilityWatcher: (userPreferencesProvider?: UserPreferencesProvider) => void;
@@ -1,2 +0,0 @@
1
- import { UserPreferencesProvider } from '@atlaskit/editor-common/user-preferences';
2
- export declare const useDocumentVisibilityWatcher: (userPreferencesProvider?: UserPreferencesProvider) => void;