@atlaskit/editor-plugin-placeholder 22.0.0 → 22.1.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,18 @@
1
1
  # @atlaskit/editor-plugin-placeholder
2
2
 
3
+ ## 22.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`eb1c9f7924470`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/eb1c9f7924470) -
8
+ [ux] Subscribe the empty-document loading spinner to collab-edit initialization state using a
9
+ selector behind platform_editor_placeholder_collab_spinner so it clears when collaboration
10
+ initializes without requiring an unrelated editor render.
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+
3
16
  ## 22.0.0
4
17
 
5
18
  ### Patch Changes
@@ -0,0 +1,5 @@
1
+ ._1bah1h6o{justify-content:center}
2
+ ._1bsb1osq{width:100%}
3
+ ._1e0c1txw{display:flex}
4
+ ._2lx21bp4{flex-direction:column}
5
+ ._4cvr1h6o{align-items:center}
@@ -0,0 +1,41 @@
1
+ /* PlaceholderLoadingSpinner.tsx generated by @compiled/babel-plugin v3.0.2 */
2
+ "use strict";
3
+
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.PlaceholderLoadingSpinner = void 0;
9
+ require("./PlaceholderLoadingSpinner.compiled.css");
10
+ var _runtime = require("@compiled/react/runtime");
11
+ var _react = _interopRequireDefault(require("react"));
12
+ var _hooks = require("@atlaskit/editor-common/hooks");
13
+ var _document = require("@atlaskit/editor-common/utils/document");
14
+ var _box = require("@atlaskit/primitives/compiled/box");
15
+ var _spinner = _interopRequireDefault(require("@atlaskit/spinner/spinner"));
16
+ var PlaceholderLoadingSpinner = exports.PlaceholderLoadingSpinner = function PlaceholderLoadingSpinner(_ref) {
17
+ var api = _ref.api,
18
+ editorView = _ref.editorView;
19
+ var isCollabInitializing = (0, _hooks.useSharedPluginStateWithSelector)(api, ['collabEdit'], function (_ref2) {
20
+ var collabEditState = _ref2.collabEditState;
21
+ return !!collabEditState && !collabEditState.initialised.collabInitialisedAt;
22
+ });
23
+ var doc = editorView === null || editorView === void 0 ? void 0 : editorView.state.doc;
24
+ if (!editorView || !isCollabInitializing || doc && !(0, _document.isEmptyDocument)(doc)) {
25
+ return null;
26
+ }
27
+
28
+ // In this scenario
29
+ // - the collab plugin exists - but we don't have a "initial/placeholder" document
30
+ // - and the collab plugin is not yet ready
31
+ // So we show a placeholder spinner to indicate the content is still loading
32
+ return /*#__PURE__*/_react.default.createElement(_box.Box, {
33
+ xcss: spinnerContainerStyles.spinnerContainer
34
+ }, /*#__PURE__*/_react.default.createElement(_spinner.default, {
35
+ interactionName: "live-pages-loading-spinner",
36
+ size: "medium"
37
+ }));
38
+ };
39
+ var spinnerContainerStyles = {
40
+ spinnerContainer: "_1e0c1txw _2lx21bp4 _1bah1h6o _4cvr1h6o _1bsb1osq"
41
+ };
@@ -12,8 +12,10 @@ var _react = _interopRequireDefault(require("react"));
12
12
  var _coreUtils = require("@atlaskit/editor-common/core-utils");
13
13
  var _document = require("@atlaskit/editor-common/utils/document");
14
14
  var _state = require("@atlaskit/editor-prosemirror/state");
15
+ var _fg = require("@atlaskit/platform-feature-flags/fg");
15
16
  var _compiled = require("@atlaskit/primitives/compiled");
16
17
  var _spinner = _interopRequireDefault(require("@atlaskit/spinner/spinner"));
18
+ var _PlaceholderLoadingSpinner = require("./PlaceholderLoadingSpinner");
17
19
  var _main = _interopRequireDefault(require("./pm-plugins/main"));
18
20
  var EMPTY_PARAGRAPH_TIMEOUT_DELAY = exports.EMPTY_PARAGRAPH_TIMEOUT_DELAY = 2000; // Delay before showing placeholder on empty paragraph
19
21
 
@@ -73,20 +75,20 @@ var placeholderPlugin = exports.placeholderPlugin = function placeholderPlugin(_
73
75
  if ((options === null || options === void 0 ? void 0 : options.enableLoadingSpinner) === false) {
74
76
  return null;
75
77
  }
78
+ if ((0, _fg.fg)('platform_editor_placeholder_collab_spinner')) {
79
+ return /*#__PURE__*/_react.default.createElement(_PlaceholderLoadingSpinner.PlaceholderLoadingSpinner, {
80
+ api: api,
81
+ editorView: params.editorView
82
+ });
83
+ }
76
84
  var doc = (_params$editorView = params.editorView) === null || _params$editorView === void 0 ? void 0 : _params$editorView.state.doc;
77
85
 
78
86
  // @ts-ignore fix which needs follow up to use standard apis
79
87
  var collabEditPluginState = (_params$editorView2 = params.editorView) === null || _params$editorView2 === void 0 || (_params$editorView2 = _params$editorView2.state) === null || _params$editorView2 === void 0 ? void 0 : _params$editorView2.collabEditPlugin$;
80
88
  if (collabEditPluginState && collabEditPluginState.isReady !== true) {
81
89
  if (doc && !(0, _document.isEmptyDocument)(doc)) {
82
- // If we have a document, and it's not empty - we should not show a loading component
83
90
  return null;
84
91
  }
85
-
86
- // In this scenario
87
- // - the collab plugin exists - but we don't have a "initial/placeholder" document
88
- // - and the collab plugin is not yet ready
89
- // So we show a placeholder spinner to indicate the content is still loading
90
92
  return /*#__PURE__*/_react.default.createElement(_compiled.Box, {
91
93
  xcss: spinnerContainerStyles.spinnerContainer
92
94
  }, /*#__PURE__*/_react.default.createElement(_spinner.default, {
@@ -0,0 +1,5 @@
1
+ ._1bah1h6o{justify-content:center}
2
+ ._1bsb1osq{width:100%}
3
+ ._1e0c1txw{display:flex}
4
+ ._2lx21bp4{flex-direction:column}
5
+ ._4cvr1h6o{align-items:center}
@@ -0,0 +1,34 @@
1
+ /* PlaceholderLoadingSpinner.tsx generated by @compiled/babel-plugin v3.0.2 */
2
+ import "./PlaceholderLoadingSpinner.compiled.css";
3
+ import { ax, ix } from "@compiled/react/runtime";
4
+ import React from 'react';
5
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
6
+ import { isEmptyDocument } from '@atlaskit/editor-common/utils/document';
7
+ import { Box } from '@atlaskit/primitives/compiled/box';
8
+ import Spinner from '@atlaskit/spinner/spinner';
9
+ export const PlaceholderLoadingSpinner = ({
10
+ api,
11
+ editorView
12
+ }) => {
13
+ const isCollabInitializing = useSharedPluginStateWithSelector(api, ['collabEdit'], ({
14
+ collabEditState
15
+ }) => !!collabEditState && !collabEditState.initialised.collabInitialisedAt);
16
+ const doc = editorView === null || editorView === void 0 ? void 0 : editorView.state.doc;
17
+ if (!editorView || !isCollabInitializing || doc && !isEmptyDocument(doc)) {
18
+ return null;
19
+ }
20
+
21
+ // In this scenario
22
+ // - the collab plugin exists - but we don't have a "initial/placeholder" document
23
+ // - and the collab plugin is not yet ready
24
+ // So we show a placeholder spinner to indicate the content is still loading
25
+ return /*#__PURE__*/React.createElement(Box, {
26
+ xcss: spinnerContainerStyles.spinnerContainer
27
+ }, /*#__PURE__*/React.createElement(Spinner, {
28
+ interactionName: "live-pages-loading-spinner",
29
+ size: "medium"
30
+ }));
31
+ };
32
+ const spinnerContainerStyles = {
33
+ spinnerContainer: "_1e0c1txw _2lx21bp4 _1bah1h6o _4cvr1h6o _1bsb1osq"
34
+ };
@@ -5,8 +5,10 @@ import React from 'react';
5
5
  import { isSSR } from '@atlaskit/editor-common/core-utils';
6
6
  import { isEmptyDocument } from '@atlaskit/editor-common/utils/document';
7
7
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
8
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
8
9
  import { Box } from '@atlaskit/primitives/compiled';
9
10
  import Spinner from '@atlaskit/spinner/spinner';
11
+ import { PlaceholderLoadingSpinner } from './PlaceholderLoadingSpinner';
10
12
  import createPlugin from './pm-plugins/main';
11
13
  export const EMPTY_PARAGRAPH_TIMEOUT_DELAY = 2000; // Delay before showing placeholder on empty paragraph
12
14
 
@@ -63,20 +65,20 @@ export const placeholderPlugin = ({
63
65
  if ((options === null || options === void 0 ? void 0 : options.enableLoadingSpinner) === false) {
64
66
  return null;
65
67
  }
68
+ if (fg('platform_editor_placeholder_collab_spinner')) {
69
+ return /*#__PURE__*/React.createElement(PlaceholderLoadingSpinner, {
70
+ api: api,
71
+ editorView: params.editorView
72
+ });
73
+ }
66
74
  const doc = (_params$editorView = params.editorView) === null || _params$editorView === void 0 ? void 0 : _params$editorView.state.doc;
67
75
 
68
76
  // @ts-ignore fix which needs follow up to use standard apis
69
77
  const collabEditPluginState = (_params$editorView2 = params.editorView) === null || _params$editorView2 === void 0 ? void 0 : (_params$editorView2$s = _params$editorView2.state) === null || _params$editorView2$s === void 0 ? void 0 : _params$editorView2$s.collabEditPlugin$;
70
78
  if (collabEditPluginState && collabEditPluginState.isReady !== true) {
71
79
  if (doc && !isEmptyDocument(doc)) {
72
- // If we have a document, and it's not empty - we should not show a loading component
73
80
  return null;
74
81
  }
75
-
76
- // In this scenario
77
- // - the collab plugin exists - but we don't have a "initial/placeholder" document
78
- // - and the collab plugin is not yet ready
79
- // So we show a placeholder spinner to indicate the content is still loading
80
82
  return /*#__PURE__*/React.createElement(Box, {
81
83
  xcss: spinnerContainerStyles.spinnerContainer
82
84
  }, /*#__PURE__*/React.createElement(Spinner, {
@@ -0,0 +1,5 @@
1
+ ._1bah1h6o{justify-content:center}
2
+ ._1bsb1osq{width:100%}
3
+ ._1e0c1txw{display:flex}
4
+ ._2lx21bp4{flex-direction:column}
5
+ ._4cvr1h6o{align-items:center}
@@ -0,0 +1,34 @@
1
+ /* PlaceholderLoadingSpinner.tsx generated by @compiled/babel-plugin v3.0.2 */
2
+ import "./PlaceholderLoadingSpinner.compiled.css";
3
+ import { ax, ix } from "@compiled/react/runtime";
4
+ import React from 'react';
5
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
6
+ import { isEmptyDocument } from '@atlaskit/editor-common/utils/document';
7
+ import { Box } from '@atlaskit/primitives/compiled/box';
8
+ import Spinner from '@atlaskit/spinner/spinner';
9
+ export var PlaceholderLoadingSpinner = function PlaceholderLoadingSpinner(_ref) {
10
+ var api = _ref.api,
11
+ editorView = _ref.editorView;
12
+ var isCollabInitializing = useSharedPluginStateWithSelector(api, ['collabEdit'], function (_ref2) {
13
+ var collabEditState = _ref2.collabEditState;
14
+ return !!collabEditState && !collabEditState.initialised.collabInitialisedAt;
15
+ });
16
+ var doc = editorView === null || editorView === void 0 ? void 0 : editorView.state.doc;
17
+ if (!editorView || !isCollabInitializing || doc && !isEmptyDocument(doc)) {
18
+ return null;
19
+ }
20
+
21
+ // In this scenario
22
+ // - the collab plugin exists - but we don't have a "initial/placeholder" document
23
+ // - and the collab plugin is not yet ready
24
+ // So we show a placeholder spinner to indicate the content is still loading
25
+ return /*#__PURE__*/React.createElement(Box, {
26
+ xcss: spinnerContainerStyles.spinnerContainer
27
+ }, /*#__PURE__*/React.createElement(Spinner, {
28
+ interactionName: "live-pages-loading-spinner",
29
+ size: "medium"
30
+ }));
31
+ };
32
+ var spinnerContainerStyles = {
33
+ spinnerContainer: "_1e0c1txw _2lx21bp4 _1bah1h6o _4cvr1h6o _1bsb1osq"
34
+ };
@@ -5,8 +5,10 @@ import React from 'react';
5
5
  import { isSSR } from '@atlaskit/editor-common/core-utils';
6
6
  import { isEmptyDocument } from '@atlaskit/editor-common/utils/document';
7
7
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
8
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
8
9
  import { Box } from '@atlaskit/primitives/compiled';
9
10
  import Spinner from '@atlaskit/spinner/spinner';
11
+ import { PlaceholderLoadingSpinner } from './PlaceholderLoadingSpinner';
10
12
  import createPlugin from './pm-plugins/main';
11
13
  export var EMPTY_PARAGRAPH_TIMEOUT_DELAY = 2000; // Delay before showing placeholder on empty paragraph
12
14
 
@@ -66,20 +68,20 @@ export var placeholderPlugin = function placeholderPlugin(_ref) {
66
68
  if ((options === null || options === void 0 ? void 0 : options.enableLoadingSpinner) === false) {
67
69
  return null;
68
70
  }
71
+ if (fg('platform_editor_placeholder_collab_spinner')) {
72
+ return /*#__PURE__*/React.createElement(PlaceholderLoadingSpinner, {
73
+ api: api,
74
+ editorView: params.editorView
75
+ });
76
+ }
69
77
  var doc = (_params$editorView = params.editorView) === null || _params$editorView === void 0 ? void 0 : _params$editorView.state.doc;
70
78
 
71
79
  // @ts-ignore fix which needs follow up to use standard apis
72
80
  var collabEditPluginState = (_params$editorView2 = params.editorView) === null || _params$editorView2 === void 0 || (_params$editorView2 = _params$editorView2.state) === null || _params$editorView2 === void 0 ? void 0 : _params$editorView2.collabEditPlugin$;
73
81
  if (collabEditPluginState && collabEditPluginState.isReady !== true) {
74
82
  if (doc && !isEmptyDocument(doc)) {
75
- // If we have a document, and it's not empty - we should not show a loading component
76
83
  return null;
77
84
  }
78
-
79
- // In this scenario
80
- // - the collab plugin exists - but we don't have a "initial/placeholder" document
81
- // - and the collab plugin is not yet ready
82
- // So we show a placeholder spinner to indicate the content is still loading
83
85
  return /*#__PURE__*/React.createElement(Box, {
84
86
  xcss: spinnerContainerStyles.spinnerContainer
85
87
  }, /*#__PURE__*/React.createElement(Spinner, {
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { PlaceholderPlugin } from './placeholderPluginType';
5
+ export declare const PlaceholderLoadingSpinner: ({ api, editorView, }: {
6
+ api: ExtractInjectionAPI<PlaceholderPlugin> | undefined;
7
+ editorView?: EditorView;
8
+ }) => React.JSX.Element | null;
@@ -1,5 +1,6 @@
1
1
  import type { DocNode } from '@atlaskit/adf-schema/doc';
2
2
  import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
3
+ import type { CollabEditPlugin } from '@atlaskit/editor-plugin-collab-edit/collabEditPluginType';
3
4
  import type { CompositionPlugin } from '@atlaskit/editor-plugin-composition';
4
5
  import type { FocusPlugin } from '@atlaskit/editor-plugin-focus';
5
6
  import type { ShowDiffPlugin } from '@atlaskit/editor-plugin-show-diff';
@@ -23,6 +24,12 @@ export type PlaceholderPlugin = NextEditorPlugin<'placeholder', {
23
24
  setPlaceholder: (placeholder: string) => EditorCommand;
24
25
  setPlaceholderHidden: (isPlaceholderHidden: boolean) => EditorCommand;
25
26
  };
26
- dependencies: [FocusPlugin, CompositionPlugin, TypeAheadPlugin, OptionalPlugin<ShowDiffPlugin>];
27
+ dependencies: [
28
+ FocusPlugin,
29
+ CompositionPlugin,
30
+ TypeAheadPlugin,
31
+ OptionalPlugin<ShowDiffPlugin>,
32
+ OptionalPlugin<CollabEditPlugin>
33
+ ];
27
34
  pluginConfiguration: PlaceholderPluginOptions | undefined;
28
35
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-placeholder",
3
- "version": "22.0.0",
3
+ "version": "22.1.0",
4
4
  "description": "Placeholder plugin for @atlaskit/editor-core.",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -22,6 +22,7 @@
22
22
  "@atlaskit/adf-schema": "^57.6.0",
23
23
  "@atlaskit/adf-utils": "^20.9.0",
24
24
  "@atlaskit/css": "^1.1.0",
25
+ "@atlaskit/editor-plugin-collab-edit": "^23.0.0",
25
26
  "@atlaskit/editor-plugin-composition": "^21.0.0",
26
27
  "@atlaskit/editor-plugin-focus": "^21.0.0",
27
28
  "@atlaskit/editor-plugin-show-diff": "^20.0.0",
@@ -30,12 +31,12 @@
30
31
  "@atlaskit/platform-feature-flags": "^2.2.0",
31
32
  "@atlaskit/primitives": "^22.5.0",
32
33
  "@atlaskit/spinner": "^20.4.0",
33
- "@atlaskit/tmp-editor-statsig": "^209.0.0",
34
- "@atlaskit/tokens": "^20.0.0",
34
+ "@atlaskit/tmp-editor-statsig": "^210.0.0",
35
+ "@atlaskit/tokens": "^20.1.0",
35
36
  "@babel/runtime": "^7.0.0"
36
37
  },
37
38
  "peerDependencies": {
38
- "@atlaskit/editor-common": "^126.0.0",
39
+ "@atlaskit/editor-common": "^126.1.0",
39
40
  "react": "^18.2.0 || ^19.2.0",
40
41
  "react-dom": "^18.2.0 || ^19.2.0",
41
42
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
@@ -45,5 +46,10 @@
45
46
  "react": "^19.2.0",
46
47
  "react-dom": "^19.2.0",
47
48
  "react-intl": "^7.0.0"
49
+ },
50
+ "platform-feature-flags": {
51
+ "platform_editor_placeholder_collab_spinner": {
52
+ "type": "boolean"
53
+ }
48
54
  }
49
55
  }