@atlaskit/editor-plugin-placeholder 7.1.1 → 7.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @atlaskit/editor-plugin-placeholder
2
2
 
3
+ ## 7.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`5c6dee8d82e9e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5c6dee8d82e9e) -
8
+ Updated adf placeholder to inject zero-width-space character at the start of the placeholder
9
+ decoration. This is needed to stop the browser caret from getting confused when its placed between
10
+ and editable and non-editable element
11
+ - Updated dependencies
12
+
13
+ ## 7.2.0
14
+
15
+ ### Minor Changes
16
+
17
+ - [`333b858014e54`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/333b858014e54) -
18
+ Move content placeholder behind title_on_transition flag
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies
23
+
3
24
  ## 7.1.1
4
25
 
5
26
  ### 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}
@@ -1,3 +1,4 @@
1
+ /* placeholderPlugin.tsx generated by @compiled/babel-plugin v0.38.1 */
1
2
  "use strict";
2
3
 
3
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -5,8 +6,14 @@ Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.pluginKey = exports.placeholderPlugin = exports.EMPTY_PARAGRAPH_TIMEOUT_DELAY = void 0;
9
+ require("./placeholderPlugin.compiled.css");
10
+ var _runtime = require("@compiled/react/runtime");
11
+ var _react = _interopRequireDefault(require("react"));
8
12
  var _state = require("@atlaskit/editor-prosemirror/state");
9
13
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
+ var _compiled = require("@atlaskit/primitives/compiled");
15
+ var _spinner = _interopRequireDefault(require("@atlaskit/spinner/spinner"));
16
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
10
17
  var _main = _interopRequireDefault(require("./pm-plugins/main"));
11
18
  var _placeholderPluginLegacy = require("./pm-plugins/placeholderPluginLegacy");
12
19
  var EMPTY_PARAGRAPH_TIMEOUT_DELAY = exports.EMPTY_PARAGRAPH_TIMEOUT_DELAY = 2000; // Delay before showing placeholder on empty paragraph
@@ -62,6 +69,23 @@ var placeholderPlugin = exports.placeholderPlugin = function placeholderPlugin(_
62
69
  return (0, _main.default)(getIntl(), options && options.placeholder, options && options.placeholderBracketHint, options && options.emptyLinePlaceholder, options && options.placeholderPrompts, options === null || options === void 0 ? void 0 : options.withEmptyParagraph, options && options.placeholderADF, api);
63
70
  }
64
71
  }];
65
- }
72
+ },
73
+ contentComponent: (0, _expValEquals.expValEquals)('confluence_load_editor_title_on_transition', 'contentPlaceholder', true) ? function (params) {
74
+ var _params$editorView;
75
+ // @ts-ignore fix which needs follow up to use standard apis
76
+ var collabEditPluginState = (_params$editorView = params.editorView) === null || _params$editorView === void 0 || (_params$editorView = _params$editorView.state) === null || _params$editorView === void 0 ? void 0 : _params$editorView.collabEditPlugin$;
77
+ if (collabEditPluginState && collabEditPluginState.isReady !== true) {
78
+ return /*#__PURE__*/_react.default.createElement(_compiled.Box, {
79
+ xcss: spinnerContainerStyles.spinnerContainer
80
+ }, /*#__PURE__*/_react.default.createElement(_spinner.default, {
81
+ interactionName: "live-pages-loading-spinner",
82
+ size: "medium"
83
+ }));
84
+ }
85
+ return null;
86
+ } : undefined
66
87
  };
88
+ };
89
+ var spinnerContainerStyles = {
90
+ spinnerContainer: "_1e0c1txw _2lx21bp4 _1bah1h6o _4cvr1h6o _1bsb1osq"
67
91
  };
@@ -92,6 +92,18 @@ function createPlaceholderDecoration(editorState, placeholderText, placeholderPr
92
92
  if (isTargetNested && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
93
93
  placeholderDecoration.classList.add('placeholder-decoration-hide-overflow');
94
94
  }
95
+ if (placeholderADF && _utils.browser.chrome && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_adf_placeholder')) {
96
+ var fragment = document.createDocumentFragment();
97
+ // An issue occurs with the caret where it gets bigger when it's next to a non-editable element like a decoration.
98
+ // See: https://discuss.prosemirror.net/t/chrome-caret-cursor-larger-than-the-text-with-inlined-items/5946/2
99
+ // Adding a zero-width space seems to fix this issue.
100
+ fragment.appendChild(document.createTextNode(_utils.ZERO_WIDTH_SPACE));
101
+ fragment.appendChild(placeholderDecoration);
102
+ return _view.DecorationSet.create(editorState.doc, [_view.Decoration.widget(pos, fragment, {
103
+ side: 0,
104
+ key: "placeholder ".concat(placeholderText)
105
+ })]);
106
+ }
95
107
  return _view.DecorationSet.create(editorState.doc, [_view.Decoration.widget(pos, placeholderDecoration, {
96
108
  side: 0,
97
109
  key: "placeholder ".concat(placeholderText)
@@ -93,7 +93,7 @@ function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, empt
93
93
  props: {
94
94
  decorations: function decorations(editorState) {
95
95
  var _api$composition, _api$showDiff;
96
- if ((0, _expValEquals.expValEquals)('cc_editor_placeholder_collab_wait', 'isEnabled', true)) {
96
+ if ((0, _expValEquals.expValEquals)('confluence_load_editor_title_on_transition', 'contentPlaceholder', true)) {
97
97
  // @ts-ignore quick fix which needs follow up to use standard apis
98
98
  if (editorState.collabEditPlugin$ && editorState.collabEditPlugin$.isReady !== true) {
99
99
  return;
@@ -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}
@@ -1,5 +1,12 @@
1
+ /* placeholderPlugin.tsx generated by @compiled/babel-plugin v0.38.1 */
2
+ import "./placeholderPlugin.compiled.css";
3
+ import { ax, ix } from "@compiled/react/runtime";
4
+ import React from 'react';
1
5
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
6
  import { fg } from '@atlaskit/platform-feature-flags';
7
+ import { Box } from '@atlaskit/primitives/compiled';
8
+ import Spinner from '@atlaskit/spinner/spinner';
9
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
10
  import createPlugin from './pm-plugins/main';
4
11
  import { placeholderPluginLegacy } from './pm-plugins/placeholderPluginLegacy';
5
12
  export const EMPTY_PARAGRAPH_TIMEOUT_DELAY = 2000; // Delay before showing placeholder on empty paragraph
@@ -52,6 +59,23 @@ export const placeholderPlugin = ({
52
59
  getIntl
53
60
  }) => createPlugin(getIntl(), options && options.placeholder, options && options.placeholderBracketHint, options && options.emptyLinePlaceholder, options && options.placeholderPrompts, options === null || options === void 0 ? void 0 : options.withEmptyParagraph, options && options.placeholderADF, api)
54
61
  }];
55
- }
62
+ },
63
+ contentComponent: expValEquals('confluence_load_editor_title_on_transition', 'contentPlaceholder', true) ? params => {
64
+ var _params$editorView, _params$editorView$st;
65
+ // @ts-ignore fix which needs follow up to use standard apis
66
+ const collabEditPluginState = (_params$editorView = params.editorView) === null || _params$editorView === void 0 ? void 0 : (_params$editorView$st = _params$editorView.state) === null || _params$editorView$st === void 0 ? void 0 : _params$editorView$st.collabEditPlugin$;
67
+ if (collabEditPluginState && collabEditPluginState.isReady !== true) {
68
+ return /*#__PURE__*/React.createElement(Box, {
69
+ xcss: spinnerContainerStyles.spinnerContainer
70
+ }, /*#__PURE__*/React.createElement(Spinner, {
71
+ interactionName: "live-pages-loading-spinner",
72
+ size: "medium"
73
+ }));
74
+ }
75
+ return null;
76
+ } : undefined
56
77
  };
78
+ };
79
+ const spinnerContainerStyles = {
80
+ spinnerContainer: "_1e0c1txw _2lx21bp4 _1bah1h6o _4cvr1h6o _1bsb1osq"
57
81
  };
@@ -1,5 +1,5 @@
1
1
  import { processRawValue } from '@atlaskit/editor-common/process-raw-value';
2
- import { browser } from '@atlaskit/editor-common/utils';
2
+ import { browser, ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/utils';
3
3
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
4
4
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
5
5
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -82,6 +82,18 @@ export function createPlaceholderDecoration(editorState, placeholderText, placeh
82
82
  if (isTargetNested && editorExperiment('platform_editor_controls', 'variant1')) {
83
83
  placeholderDecoration.classList.add('placeholder-decoration-hide-overflow');
84
84
  }
85
+ if (placeholderADF && browser.chrome && fg('platform_editor_ai_aifc_adf_placeholder')) {
86
+ const fragment = document.createDocumentFragment();
87
+ // An issue occurs with the caret where it gets bigger when it's next to a non-editable element like a decoration.
88
+ // See: https://discuss.prosemirror.net/t/chrome-caret-cursor-larger-than-the-text-with-inlined-items/5946/2
89
+ // Adding a zero-width space seems to fix this issue.
90
+ fragment.appendChild(document.createTextNode(ZERO_WIDTH_SPACE));
91
+ fragment.appendChild(placeholderDecoration);
92
+ return DecorationSet.create(editorState.doc, [Decoration.widget(pos, fragment, {
93
+ side: 0,
94
+ key: `placeholder ${placeholderText}`
95
+ })]);
96
+ }
85
97
  return DecorationSet.create(editorState.doc, [Decoration.widget(pos, placeholderDecoration, {
86
98
  side: 0,
87
99
  key: `placeholder ${placeholderText}`
@@ -86,7 +86,7 @@ export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceh
86
86
  props: {
87
87
  decorations(editorState) {
88
88
  var _api$composition, _api$showDiff, _api$showDiff$sharedS;
89
- if (expValEquals('cc_editor_placeholder_collab_wait', 'isEnabled', true)) {
89
+ if (expValEquals('confluence_load_editor_title_on_transition', 'contentPlaceholder', true)) {
90
90
  // @ts-ignore quick fix which needs follow up to use standard apis
91
91
  if (editorState.collabEditPlugin$ && editorState.collabEditPlugin$.isReady !== true) {
92
92
  return;
@@ -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}
@@ -1,5 +1,12 @@
1
+ /* placeholderPlugin.tsx generated by @compiled/babel-plugin v0.38.1 */
2
+ import "./placeholderPlugin.compiled.css";
3
+ import { ax, ix } from "@compiled/react/runtime";
4
+ import React from 'react';
1
5
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
6
  import { fg } from '@atlaskit/platform-feature-flags';
7
+ import { Box } from '@atlaskit/primitives/compiled';
8
+ import Spinner from '@atlaskit/spinner/spinner';
9
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
10
  import createPlugin from './pm-plugins/main';
4
11
  import { placeholderPluginLegacy } from './pm-plugins/placeholderPluginLegacy';
5
12
  export var EMPTY_PARAGRAPH_TIMEOUT_DELAY = 2000; // Delay before showing placeholder on empty paragraph
@@ -55,6 +62,23 @@ export var placeholderPlugin = function placeholderPlugin(_ref) {
55
62
  return createPlugin(getIntl(), options && options.placeholder, options && options.placeholderBracketHint, options && options.emptyLinePlaceholder, options && options.placeholderPrompts, options === null || options === void 0 ? void 0 : options.withEmptyParagraph, options && options.placeholderADF, api);
56
63
  }
57
64
  }];
58
- }
65
+ },
66
+ contentComponent: expValEquals('confluence_load_editor_title_on_transition', 'contentPlaceholder', true) ? function (params) {
67
+ var _params$editorView;
68
+ // @ts-ignore fix which needs follow up to use standard apis
69
+ var collabEditPluginState = (_params$editorView = params.editorView) === null || _params$editorView === void 0 || (_params$editorView = _params$editorView.state) === null || _params$editorView === void 0 ? void 0 : _params$editorView.collabEditPlugin$;
70
+ if (collabEditPluginState && collabEditPluginState.isReady !== true) {
71
+ return /*#__PURE__*/React.createElement(Box, {
72
+ xcss: spinnerContainerStyles.spinnerContainer
73
+ }, /*#__PURE__*/React.createElement(Spinner, {
74
+ interactionName: "live-pages-loading-spinner",
75
+ size: "medium"
76
+ }));
77
+ }
78
+ return null;
79
+ } : undefined
59
80
  };
81
+ };
82
+ var spinnerContainerStyles = {
83
+ spinnerContainer: "_1e0c1txw _2lx21bp4 _1bah1h6o _4cvr1h6o _1bsb1osq"
60
84
  };
@@ -1,5 +1,5 @@
1
1
  import { processRawValue } from '@atlaskit/editor-common/process-raw-value';
2
- import { browser } from '@atlaskit/editor-common/utils';
2
+ import { browser, ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/utils';
3
3
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
4
4
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
5
5
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -86,6 +86,18 @@ export function createPlaceholderDecoration(editorState, placeholderText, placeh
86
86
  if (isTargetNested && editorExperiment('platform_editor_controls', 'variant1')) {
87
87
  placeholderDecoration.classList.add('placeholder-decoration-hide-overflow');
88
88
  }
89
+ if (placeholderADF && browser.chrome && fg('platform_editor_ai_aifc_adf_placeholder')) {
90
+ var fragment = document.createDocumentFragment();
91
+ // An issue occurs with the caret where it gets bigger when it's next to a non-editable element like a decoration.
92
+ // See: https://discuss.prosemirror.net/t/chrome-caret-cursor-larger-than-the-text-with-inlined-items/5946/2
93
+ // Adding a zero-width space seems to fix this issue.
94
+ fragment.appendChild(document.createTextNode(ZERO_WIDTH_SPACE));
95
+ fragment.appendChild(placeholderDecoration);
96
+ return DecorationSet.create(editorState.doc, [Decoration.widget(pos, fragment, {
97
+ side: 0,
98
+ key: "placeholder ".concat(placeholderText)
99
+ })]);
100
+ }
89
101
  return DecorationSet.create(editorState.doc, [Decoration.widget(pos, placeholderDecoration, {
90
102
  side: 0,
91
103
  key: "placeholder ".concat(placeholderText)
@@ -87,7 +87,7 @@ export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceh
87
87
  props: {
88
88
  decorations: function decorations(editorState) {
89
89
  var _api$composition, _api$showDiff;
90
- if (expValEquals('cc_editor_placeholder_collab_wait', 'isEnabled', true)) {
90
+ if (expValEquals('confluence_load_editor_title_on_transition', 'contentPlaceholder', true)) {
91
91
  // @ts-ignore quick fix which needs follow up to use standard apis
92
92
  if (editorState.collabEditPlugin$ && editorState.collabEditPlugin$.isReady !== true) {
93
93
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-placeholder",
3
- "version": "7.1.1",
3
+ "version": "7.2.1",
4
4
  "description": "Placeholder plugin for @atlaskit/editor-core.",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -28,18 +28,21 @@
28
28
  "atlaskit:src": "src/index.ts",
29
29
  "dependencies": {
30
30
  "@atlaskit/adf-utils": "^19.26.0",
31
+ "@atlaskit/css": "^0.19.0",
31
32
  "@atlaskit/editor-plugin-composition": "^6.0.0",
32
33
  "@atlaskit/editor-plugin-focus": "^6.0.0",
33
34
  "@atlaskit/editor-plugin-show-diff": "^4.0.0",
34
35
  "@atlaskit/editor-plugin-type-ahead": "^7.0.0",
35
36
  "@atlaskit/editor-prosemirror": "^7.2.0",
36
37
  "@atlaskit/platform-feature-flags": "^1.1.0",
37
- "@atlaskit/tmp-editor-statsig": "^16.15.0",
38
+ "@atlaskit/primitives": "^17.1.0",
39
+ "@atlaskit/spinner": "^19.0.0",
40
+ "@atlaskit/tmp-editor-statsig": "^16.23.0",
38
41
  "@atlaskit/tokens": "^9.1.0",
39
42
  "@babel/runtime": "^7.0.0"
40
43
  },
41
44
  "peerDependencies": {
42
- "@atlaskit/editor-common": "^111.7.0",
45
+ "@atlaskit/editor-common": "^111.8.0",
43
46
  "react": "^18.2.0",
44
47
  "react-dom": "^18.2.0",
45
48
  "react-intl-next": "npm:react-intl@^5.18.1"
@@ -56,6 +59,9 @@
56
59
  },
57
60
  "platform_editor_placeholder_plugin_tidying": {
58
61
  "type": "boolean"
62
+ },
63
+ "platform_editor_ai_aifc_adf_placeholder": {
64
+ "type": "boolean"
59
65
  }
60
66
  },
61
67
  "techstack": {