@atlaskit/editor-plugin-placeholder 12.0.33 → 12.0.35

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,21 @@
1
1
  # @atlaskit/editor-plugin-placeholder
2
2
 
3
+ ## 12.0.35
4
+
5
+ ### Patch Changes
6
+
7
+ - [`67ae1e14e8090`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/67ae1e14e8090) -
8
+ Revert persistent placeholder decorations for empty source synced blocks while retaining the sync
9
+ block activation experiment setup.
10
+
11
+ ## 12.0.34
12
+
13
+ ### Patch Changes
14
+
15
+ - [`c5a6973a90849`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c5a6973a90849) -
16
+ Revert the multi-bodied extension empty frame placeholder.
17
+ - Updated dependencies
18
+
3
19
  ## 12.0.33
4
20
 
5
21
  ### Patch Changes
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.placeholderTestId = exports.nodeTypesWithSyncBlockPlaceholderText = exports.nodeTypesWithShortPlaceholderText = exports.nodeTypesWithMultiBodiedExtensionPlaceholderText = exports.nodeTypesWithLongPlaceholderText = exports.TYPEWRITER_TYPE_DELAY = exports.TYPEWRITER_TYPED_AND_DELETED_DELAY = exports.TYPEWRITER_PAUSE_BEFORE_ERASE = exports.TYPEWRITER_ERASE_DELAY = exports.TYPEWRITER_CYCLE_DELAY = void 0;
6
+ exports.placeholderTestId = exports.nodeTypesWithSyncBlockPlaceholderText = exports.nodeTypesWithShortPlaceholderText = exports.nodeTypesWithLongPlaceholderText = exports.TYPEWRITER_TYPE_DELAY = exports.TYPEWRITER_TYPED_AND_DELETED_DELAY = exports.TYPEWRITER_PAUSE_BEFORE_ERASE = exports.TYPEWRITER_ERASE_DELAY = exports.TYPEWRITER_CYCLE_DELAY = void 0;
7
7
  var placeholderTestId = exports.placeholderTestId = 'placeholder-test-id';
8
8
 
9
9
  // Typewriter animation timing constants
@@ -15,5 +15,4 @@ var TYPEWRITER_TYPED_AND_DELETED_DELAY = exports.TYPEWRITER_TYPED_AND_DELETED_DE
15
15
 
16
16
  var nodeTypesWithLongPlaceholderText = exports.nodeTypesWithLongPlaceholderText = ['expand', 'panel'];
17
17
  var nodeTypesWithShortPlaceholderText = exports.nodeTypesWithShortPlaceholderText = ['tableCell', 'tableHeader'];
18
- var nodeTypesWithSyncBlockPlaceholderText = exports.nodeTypesWithSyncBlockPlaceholderText = ['bodiedSyncBlock'];
19
- var nodeTypesWithMultiBodiedExtensionPlaceholderText = exports.nodeTypesWithMultiBodiedExtensionPlaceholderText = ['extensionFrame'];
18
+ var nodeTypesWithSyncBlockPlaceholderText = exports.nodeTypesWithSyncBlockPlaceholderText = ['bodiedSyncBlock'];
@@ -1,23 +1,15 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.default = createPlugin;
8
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
7
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
11
- var _view = require("@atlaskit/editor-prosemirror/view");
12
8
  var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
13
9
  var _placeholderPlugin = require("../placeholderPlugin");
14
10
  var _constants = require("./constants");
15
11
  var _decorations = require("./decorations");
16
- var _multiBodiedExtensionPlaceholderDecorations = require("./multi-bodied-extension-placeholder-decorations");
17
- var _sourceSyncBlockPlaceholderDecorations = require("./source-sync-block-placeholder-decorations");
18
12
  var _utils = require("./utils");
19
- 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; }
20
- 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; }
21
13
  function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder, placeholderPrompts, withEmptyParagraph, initialIsPlaceholderHidden, placeholderADF, isRovoLLMEnabled, api) {
22
14
  if (!defaultPlaceholderText && !placeholderPrompts && !bracketPlaceholderText && !placeholderADF) {
23
15
  return;
@@ -35,7 +27,7 @@ function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, empt
35
27
  state: {
36
28
  init: function init(_, state) {
37
29
  var _api$focus, _api$typeAhead;
38
- return _objectSpread(_objectSpread({}, (0, _utils.createPlaceHolderStateFrom)({
30
+ return (0, _utils.createPlaceHolderStateFrom)({
39
31
  isInitial: true,
40
32
  isEditorFocused: Boolean(api === null || api === void 0 || (_api$focus = api.focus) === null || _api$focus === void 0 || (_api$focus = _api$focus.sharedState.currentState()) === null || _api$focus === void 0 ? void 0 : _api$focus.hasFocus),
41
33
  editorState: state,
@@ -50,9 +42,6 @@ function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, empt
50
42
  intl: intl,
51
43
  withEmptyParagraph: withEmptyParagraph,
52
44
  isPlaceholderHidden: initialIsPlaceholderHidden
53
- })), {}, {
54
- sourceSyncBlockPlaceholderDecorations: (0, _sourceSyncBlockPlaceholderDecorations.createSourceSyncBlockPlaceholderDecorations)(state, intl),
55
- multiBodiedExtensionPlaceholderDecorations: (0, _multiBodiedExtensionPlaceholderDecorations.createMultiBodiedExtensionPlaceholderDecorations)(state, intl)
56
45
  });
57
46
  },
58
47
  apply: function apply(tr, placeholderState, _oldEditorState, newEditorState) {
@@ -79,7 +68,7 @@ function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, empt
79
68
  defaultPlaceholderText = meta.placeholderText;
80
69
  }
81
70
  }
82
- var newPlaceholderState = _objectSpread(_objectSpread({}, (0, _utils.createPlaceHolderStateFrom)({
71
+ var newPlaceholderState = (0, _utils.createPlaceHolderStateFrom)({
83
72
  isEditorFocused: isEditorFocused,
84
73
  editorState: newEditorState,
85
74
  isTypeAheadOpen: api === null || api === void 0 || (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 ? void 0 : _api$typeAhead2.actions.isOpen,
@@ -94,20 +83,6 @@ function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, empt
94
83
  isPlaceholderHidden: isPlaceholderHidden,
95
84
  withEmptyParagraph: withEmptyParagraph,
96
85
  showOnEmptyParagraph: (_meta$showOnEmptyPara = meta === null || meta === void 0 ? void 0 : meta.showOnEmptyParagraph) !== null && _meta$showOnEmptyPara !== void 0 ? _meta$showOnEmptyPara : placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.showOnEmptyParagraph
97
- })), {}, {
98
- sourceSyncBlockPlaceholderDecorations: (0, _sourceSyncBlockPlaceholderDecorations.updateSourceSyncBlockPlaceholderDecorations)({
99
- currentDecorationSet: placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.sourceSyncBlockPlaceholderDecorations,
100
- intl: intl,
101
- newEditorState: newEditorState,
102
- oldEditorState: _oldEditorState,
103
- tr: tr
104
- }),
105
- multiBodiedExtensionPlaceholderDecorations: (0, _multiBodiedExtensionPlaceholderDecorations.updateMultiBodiedExtensionPlaceholderDecorations)({
106
- currentDecorationSet: placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.multiBodiedExtensionPlaceholderDecorations,
107
- intl: intl,
108
- newEditorState: newEditorState,
109
- tr: tr
110
- })
111
86
  });
112
87
 
113
88
  // Clear timeouts when hasPlaceholder becomes false
@@ -119,7 +94,7 @@ function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, empt
119
94
  },
120
95
  props: {
121
96
  decorations: function decorations(editorState) {
122
- var _api$composition, _api$showDiff, _syncBlockPlaceholder, _multiBodiedExtension;
97
+ var _api$composition, _api$showDiff;
123
98
  // @ts-ignore quick fix which needs follow up to use standard apis
124
99
  if (editorState.collabEditPlugin$ && editorState.collabEditPlugin$.isReady !== true) {
125
100
  return;
@@ -130,9 +105,7 @@ function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, empt
130
105
  pos = _getPlaceholderState.pos,
131
106
  typedAndDeleted = _getPlaceholderState.typedAndDeleted,
132
107
  contextPlaceholderADF = _getPlaceholderState.contextPlaceholderADF,
133
- showOnEmptyParagraph = _getPlaceholderState.showOnEmptyParagraph,
134
- sourceSyncBlockPlaceholderDecorations = _getPlaceholderState.sourceSyncBlockPlaceholderDecorations,
135
- multiBodiedExtensionPlaceholderDecorations = _getPlaceholderState.multiBodiedExtensionPlaceholderDecorations;
108
+ showOnEmptyParagraph = _getPlaceholderState.showOnEmptyParagraph;
136
109
 
137
110
  // Decorations is still called after plugin is destroyed
138
111
  // So we need to make sure decorations is not called if plugin has been destroyed to prevent the placeholder animations' setTimeouts called infinitely
@@ -141,26 +114,13 @@ function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, empt
141
114
  }
142
115
  var compositionPluginState = api === null || api === void 0 || (_api$composition = api.composition) === null || _api$composition === void 0 ? void 0 : _api$composition.sharedState.currentState();
143
116
  var isShowingDiff = Boolean(api === null || api === void 0 || (_api$showDiff = api.showDiff) === null || _api$showDiff === void 0 || (_api$showDiff = _api$showDiff.sharedState.currentState()) === null || _api$showDiff === void 0 ? void 0 : _api$showDiff.isDisplayingChanges);
144
- var syncBlockPlaceholderDecorations = !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing) && !isShowingDiff ? sourceSyncBlockPlaceholderDecorations : undefined;
145
- var multiBodiedExtensionDecorations = !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing) && !isShowingDiff ? multiBodiedExtensionPlaceholderDecorations : undefined;
146
- var syncBlockDecorationItems = (_syncBlockPlaceholder = syncBlockPlaceholderDecorations === null || syncBlockPlaceholderDecorations === void 0 ? void 0 : syncBlockPlaceholderDecorations.find()) !== null && _syncBlockPlaceholder !== void 0 ? _syncBlockPlaceholder : [];
147
- var multiBodiedExtensionDecorationItems = (_multiBodiedExtension = multiBodiedExtensionDecorations === null || multiBodiedExtensionDecorations === void 0 ? void 0 : multiBodiedExtensionDecorations.find()) !== null && _multiBodiedExtension !== void 0 ? _multiBodiedExtension : [];
148
117
  if (hasPlaceholder && ((placeholderText !== null && placeholderText !== void 0 ? placeholderText : '') || placeholderPrompts || placeholderADF || contextPlaceholderADF) && pos !== undefined && !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing) && !isShowingDiff) {
149
118
  var initialDelayWhenUserTypedAndDeleted = typedAndDeleted ? _constants.TYPEWRITER_TYPED_AND_DELETED_DELAY : 0;
150
119
  // contextPlaceholderADF takes precedence over the global placeholderADF
151
120
  var placeholderAdfToUse = contextPlaceholderADF || placeholderADF;
152
- return (0, _decorations.createPlaceholderDecoration)(editorState, placeholderText !== null && placeholderText !== void 0 ? placeholderText : '', placeholderPrompts, activeTypewriterTimeouts, pos, initialDelayWhenUserTypedAndDeleted, placeholderAdfToUse, showOnEmptyParagraph).add(editorState.doc, [].concat((0, _toConsumableArray2.default)(syncBlockDecorationItems), (0, _toConsumableArray2.default)(multiBodiedExtensionDecorationItems)));
153
- }
154
- // These sets are already mapped in plugin state. Return a single
155
- // active set directly, and only rebuild when multiple sets must be merged.
156
- if (syncBlockDecorationItems.length > 0 && multiBodiedExtensionDecorationItems.length === 0) {
157
- return syncBlockPlaceholderDecorations;
158
- }
159
- if (multiBodiedExtensionDecorationItems.length > 0 && syncBlockDecorationItems.length === 0) {
160
- return multiBodiedExtensionDecorations;
121
+ return (0, _decorations.createPlaceholderDecoration)(editorState, placeholderText !== null && placeholderText !== void 0 ? placeholderText : '', placeholderPrompts, activeTypewriterTimeouts, pos, initialDelayWhenUserTypedAndDeleted, placeholderAdfToUse, showOnEmptyParagraph);
161
122
  }
162
- var additionalDecorations = [].concat((0, _toConsumableArray2.default)(syncBlockDecorationItems), (0, _toConsumableArray2.default)(multiBodiedExtensionDecorationItems));
163
- return additionalDecorations.length > 0 ? _view.DecorationSet.create(editorState.doc, additionalDecorations) : undefined;
123
+ return;
164
124
  }
165
125
  },
166
126
  view: function view() {
@@ -199,7 +199,7 @@ function createPlaceHolderStateFrom(_ref3) {
199
199
  userHadTyped: userHadTyped
200
200
  });
201
201
  }
202
- if (_constants.nodeTypesWithSyncBlockPlaceholderText.includes(parentType) && isEmptyNode && (0, _experiments.editorExperiment)('platform_synced_block', true) && !(0, _expValEquals.expValEquals)('platform_editor_sync_block_activation', 'isEnabled', true)) {
202
+ if (_constants.nodeTypesWithSyncBlockPlaceholderText.includes(parentType) && isEmptyNode && (0, _experiments.editorExperiment)('platform_synced_block', true)) {
203
203
  return setPlaceHolderState({
204
204
  placeholderText: intl.formatMessage(_messages.placeholderTextMessages.sourceSyncBlockPlaceholderText),
205
205
  pos: $from.pos,
@@ -9,5 +9,4 @@ export const TYPEWRITER_TYPED_AND_DELETED_DELAY = 1500; // Delay before starting
9
9
 
10
10
  export const nodeTypesWithLongPlaceholderText = ['expand', 'panel'];
11
11
  export const nodeTypesWithShortPlaceholderText = ['tableCell', 'tableHeader'];
12
- export const nodeTypesWithSyncBlockPlaceholderText = ['bodiedSyncBlock'];
13
- export const nodeTypesWithMultiBodiedExtensionPlaceholderText = ['extensionFrame'];
12
+ export const nodeTypesWithSyncBlockPlaceholderText = ['bodiedSyncBlock'];
@@ -1,11 +1,8 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
2
  import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
4
3
  import { EMPTY_PARAGRAPH_TIMEOUT_DELAY, pluginKey } from '../placeholderPlugin';
5
4
  import { TYPEWRITER_TYPED_AND_DELETED_DELAY } from './constants';
6
5
  import { createPlaceholderDecoration } from './decorations';
7
- import { createMultiBodiedExtensionPlaceholderDecorations, updateMultiBodiedExtensionPlaceholderDecorations } from './multi-bodied-extension-placeholder-decorations';
8
- import { createSourceSyncBlockPlaceholderDecorations, updateSourceSyncBlockPlaceholderDecorations } from './source-sync-block-placeholder-decorations';
9
6
  import { calculateUserInteractionState, createPlaceHolderStateFrom, getPlaceholderState } from './utils';
10
7
  export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder, placeholderPrompts, withEmptyParagraph, initialIsPlaceholderHidden, placeholderADF, isRovoLLMEnabled, api) {
11
8
  if (!defaultPlaceholderText && !placeholderPrompts && !bracketPlaceholderText && !placeholderADF) {
@@ -22,26 +19,22 @@ export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceh
22
19
  state: {
23
20
  init: (_, state) => {
24
21
  var _api$focus, _api$focus$sharedStat, _api$typeAhead;
25
- return {
26
- ...createPlaceHolderStateFrom({
27
- isInitial: true,
28
- isEditorFocused: Boolean(api === null || api === void 0 ? void 0 : (_api$focus = api.focus) === null || _api$focus === void 0 ? void 0 : (_api$focus$sharedStat = _api$focus.sharedState.currentState()) === null || _api$focus$sharedStat === void 0 ? void 0 : _api$focus$sharedStat.hasFocus),
29
- editorState: state,
30
- isTypeAheadOpen: api === null || api === void 0 ? void 0 : (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 ? void 0 : _api$typeAhead.actions.isOpen,
31
- defaultPlaceholderText,
32
- bracketPlaceholderText,
33
- emptyLinePlaceholder,
34
- placeholderADF,
35
- placeholderPrompts,
36
- typedAndDeleted: false,
37
- userHadTyped: false,
38
- intl,
39
- withEmptyParagraph,
40
- isPlaceholderHidden: initialIsPlaceholderHidden
41
- }),
42
- sourceSyncBlockPlaceholderDecorations: createSourceSyncBlockPlaceholderDecorations(state, intl),
43
- multiBodiedExtensionPlaceholderDecorations: createMultiBodiedExtensionPlaceholderDecorations(state, intl)
44
- };
22
+ return createPlaceHolderStateFrom({
23
+ isInitial: true,
24
+ isEditorFocused: Boolean(api === null || api === void 0 ? void 0 : (_api$focus = api.focus) === null || _api$focus === void 0 ? void 0 : (_api$focus$sharedStat = _api$focus.sharedState.currentState()) === null || _api$focus$sharedStat === void 0 ? void 0 : _api$focus$sharedStat.hasFocus),
25
+ editorState: state,
26
+ isTypeAheadOpen: api === null || api === void 0 ? void 0 : (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 ? void 0 : _api$typeAhead.actions.isOpen,
27
+ defaultPlaceholderText,
28
+ bracketPlaceholderText,
29
+ emptyLinePlaceholder,
30
+ placeholderADF,
31
+ placeholderPrompts,
32
+ typedAndDeleted: false,
33
+ userHadTyped: false,
34
+ intl,
35
+ withEmptyParagraph,
36
+ isPlaceholderHidden: initialIsPlaceholderHidden
37
+ });
45
38
  },
46
39
  apply: (tr, placeholderState, _oldEditorState, newEditorState) => {
47
40
  var _api$focus2, _api$focus2$sharedSta, _placeholderState$isP, _api$typeAhead2, _ref, _meta$placeholderText, _ref2, _meta$placeholderProm, _meta$showOnEmptyPara;
@@ -68,37 +61,22 @@ export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceh
68
61
  defaultPlaceholderText = meta.placeholderText;
69
62
  }
70
63
  }
71
- const newPlaceholderState = {
72
- ...createPlaceHolderStateFrom({
73
- isEditorFocused,
74
- editorState: newEditorState,
75
- isTypeAheadOpen: api === null || api === void 0 ? void 0 : (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 ? void 0 : _api$typeAhead2.actions.isOpen,
76
- defaultPlaceholderText: withEmptyParagraph ? defaultPlaceholderText : (_ref = (_meta$placeholderText = meta === null || meta === void 0 ? void 0 : meta.placeholderText) !== null && _meta$placeholderText !== void 0 ? _meta$placeholderText : placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.placeholderText) !== null && _ref !== void 0 ? _ref : defaultPlaceholderText,
77
- bracketPlaceholderText,
78
- emptyLinePlaceholder,
79
- placeholderADF,
80
- placeholderPrompts: (_ref2 = (_meta$placeholderProm = meta === null || meta === void 0 ? void 0 : meta.placeholderPrompts) !== null && _meta$placeholderProm !== void 0 ? _meta$placeholderProm : placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.placeholderPrompts) !== null && _ref2 !== void 0 ? _ref2 : placeholderPrompts,
81
- typedAndDeleted,
82
- userHadTyped,
83
- intl,
84
- isPlaceholderHidden,
85
- withEmptyParagraph,
86
- showOnEmptyParagraph: (_meta$showOnEmptyPara = meta === null || meta === void 0 ? void 0 : meta.showOnEmptyParagraph) !== null && _meta$showOnEmptyPara !== void 0 ? _meta$showOnEmptyPara : placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.showOnEmptyParagraph
87
- }),
88
- sourceSyncBlockPlaceholderDecorations: updateSourceSyncBlockPlaceholderDecorations({
89
- currentDecorationSet: placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.sourceSyncBlockPlaceholderDecorations,
90
- intl,
91
- newEditorState,
92
- oldEditorState: _oldEditorState,
93
- tr
94
- }),
95
- multiBodiedExtensionPlaceholderDecorations: updateMultiBodiedExtensionPlaceholderDecorations({
96
- currentDecorationSet: placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.multiBodiedExtensionPlaceholderDecorations,
97
- intl,
98
- newEditorState,
99
- tr
100
- })
101
- };
64
+ const newPlaceholderState = createPlaceHolderStateFrom({
65
+ isEditorFocused,
66
+ editorState: newEditorState,
67
+ isTypeAheadOpen: api === null || api === void 0 ? void 0 : (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 ? void 0 : _api$typeAhead2.actions.isOpen,
68
+ defaultPlaceholderText: withEmptyParagraph ? defaultPlaceholderText : (_ref = (_meta$placeholderText = meta === null || meta === void 0 ? void 0 : meta.placeholderText) !== null && _meta$placeholderText !== void 0 ? _meta$placeholderText : placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.placeholderText) !== null && _ref !== void 0 ? _ref : defaultPlaceholderText,
69
+ bracketPlaceholderText,
70
+ emptyLinePlaceholder,
71
+ placeholderADF,
72
+ placeholderPrompts: (_ref2 = (_meta$placeholderProm = meta === null || meta === void 0 ? void 0 : meta.placeholderPrompts) !== null && _meta$placeholderProm !== void 0 ? _meta$placeholderProm : placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.placeholderPrompts) !== null && _ref2 !== void 0 ? _ref2 : placeholderPrompts,
73
+ typedAndDeleted,
74
+ userHadTyped,
75
+ intl,
76
+ isPlaceholderHidden,
77
+ withEmptyParagraph,
78
+ showOnEmptyParagraph: (_meta$showOnEmptyPara = meta === null || meta === void 0 ? void 0 : meta.showOnEmptyParagraph) !== null && _meta$showOnEmptyPara !== void 0 ? _meta$showOnEmptyPara : placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.showOnEmptyParagraph
79
+ });
102
80
 
103
81
  // Clear timeouts when hasPlaceholder becomes false
104
82
  if (!newPlaceholderState.hasPlaceholder) {
@@ -109,7 +87,7 @@ export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceh
109
87
  },
110
88
  props: {
111
89
  decorations(editorState) {
112
- var _api$composition, _api$showDiff, _api$showDiff$sharedS, _syncBlockPlaceholder, _multiBodiedExtension;
90
+ var _api$composition, _api$showDiff, _api$showDiff$sharedS;
113
91
  // @ts-ignore quick fix which needs follow up to use standard apis
114
92
  if (editorState.collabEditPlugin$ && editorState.collabEditPlugin$.isReady !== true) {
115
93
  return;
@@ -120,9 +98,7 @@ export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceh
120
98
  pos,
121
99
  typedAndDeleted,
122
100
  contextPlaceholderADF,
123
- showOnEmptyParagraph,
124
- sourceSyncBlockPlaceholderDecorations,
125
- multiBodiedExtensionPlaceholderDecorations
101
+ showOnEmptyParagraph
126
102
  } = getPlaceholderState(editorState);
127
103
 
128
104
  // Decorations is still called after plugin is destroyed
@@ -132,26 +108,13 @@ export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceh
132
108
  }
133
109
  const compositionPluginState = api === null || api === void 0 ? void 0 : (_api$composition = api.composition) === null || _api$composition === void 0 ? void 0 : _api$composition.sharedState.currentState();
134
110
  const isShowingDiff = Boolean(api === null || api === void 0 ? void 0 : (_api$showDiff = api.showDiff) === null || _api$showDiff === void 0 ? void 0 : (_api$showDiff$sharedS = _api$showDiff.sharedState.currentState()) === null || _api$showDiff$sharedS === void 0 ? void 0 : _api$showDiff$sharedS.isDisplayingChanges);
135
- const syncBlockPlaceholderDecorations = !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing) && !isShowingDiff ? sourceSyncBlockPlaceholderDecorations : undefined;
136
- const multiBodiedExtensionDecorations = !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing) && !isShowingDiff ? multiBodiedExtensionPlaceholderDecorations : undefined;
137
- const syncBlockDecorationItems = (_syncBlockPlaceholder = syncBlockPlaceholderDecorations === null || syncBlockPlaceholderDecorations === void 0 ? void 0 : syncBlockPlaceholderDecorations.find()) !== null && _syncBlockPlaceholder !== void 0 ? _syncBlockPlaceholder : [];
138
- const multiBodiedExtensionDecorationItems = (_multiBodiedExtension = multiBodiedExtensionDecorations === null || multiBodiedExtensionDecorations === void 0 ? void 0 : multiBodiedExtensionDecorations.find()) !== null && _multiBodiedExtension !== void 0 ? _multiBodiedExtension : [];
139
111
  if (hasPlaceholder && ((placeholderText !== null && placeholderText !== void 0 ? placeholderText : '') || placeholderPrompts || placeholderADF || contextPlaceholderADF) && pos !== undefined && !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing) && !isShowingDiff) {
140
112
  const initialDelayWhenUserTypedAndDeleted = typedAndDeleted ? TYPEWRITER_TYPED_AND_DELETED_DELAY : 0;
141
113
  // contextPlaceholderADF takes precedence over the global placeholderADF
142
114
  const placeholderAdfToUse = contextPlaceholderADF || placeholderADF;
143
- return createPlaceholderDecoration(editorState, placeholderText !== null && placeholderText !== void 0 ? placeholderText : '', placeholderPrompts, activeTypewriterTimeouts, pos, initialDelayWhenUserTypedAndDeleted, placeholderAdfToUse, showOnEmptyParagraph).add(editorState.doc, [...syncBlockDecorationItems, ...multiBodiedExtensionDecorationItems]);
144
- }
145
- // These sets are already mapped in plugin state. Return a single
146
- // active set directly, and only rebuild when multiple sets must be merged.
147
- if (syncBlockDecorationItems.length > 0 && multiBodiedExtensionDecorationItems.length === 0) {
148
- return syncBlockPlaceholderDecorations;
149
- }
150
- if (multiBodiedExtensionDecorationItems.length > 0 && syncBlockDecorationItems.length === 0) {
151
- return multiBodiedExtensionDecorations;
115
+ return createPlaceholderDecoration(editorState, placeholderText !== null && placeholderText !== void 0 ? placeholderText : '', placeholderPrompts, activeTypewriterTimeouts, pos, initialDelayWhenUserTypedAndDeleted, placeholderAdfToUse, showOnEmptyParagraph);
152
116
  }
153
- const additionalDecorations = [...syncBlockDecorationItems, ...multiBodiedExtensionDecorationItems];
154
- return additionalDecorations.length > 0 ? DecorationSet.create(editorState.doc, additionalDecorations) : undefined;
117
+ return;
155
118
  }
156
119
  },
157
120
  view() {
@@ -187,7 +187,7 @@ export function createPlaceHolderStateFrom({
187
187
  userHadTyped
188
188
  });
189
189
  }
190
- if (nodeTypesWithSyncBlockPlaceholderText.includes(parentType) && isEmptyNode && editorExperiment('platform_synced_block', true) && !expValEquals('platform_editor_sync_block_activation', 'isEnabled', true)) {
190
+ if (nodeTypesWithSyncBlockPlaceholderText.includes(parentType) && isEmptyNode && editorExperiment('platform_synced_block', true)) {
191
191
  return setPlaceHolderState({
192
192
  placeholderText: intl.formatMessage(messages.sourceSyncBlockPlaceholderText),
193
193
  pos: $from.pos,
@@ -9,5 +9,4 @@ export var TYPEWRITER_TYPED_AND_DELETED_DELAY = 1500; // Delay before starting a
9
9
 
10
10
  export var nodeTypesWithLongPlaceholderText = ['expand', 'panel'];
11
11
  export var nodeTypesWithShortPlaceholderText = ['tableCell', 'tableHeader'];
12
- export var nodeTypesWithSyncBlockPlaceholderText = ['bodiedSyncBlock'];
13
- export var nodeTypesWithMultiBodiedExtensionPlaceholderText = ['extensionFrame'];
12
+ export var nodeTypesWithSyncBlockPlaceholderText = ['bodiedSyncBlock'];
@@ -1,15 +1,8 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- 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; }
4
- 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; }
5
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
- import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
7
2
  import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
8
3
  import { EMPTY_PARAGRAPH_TIMEOUT_DELAY, pluginKey } from '../placeholderPlugin';
9
4
  import { TYPEWRITER_TYPED_AND_DELETED_DELAY } from './constants';
10
5
  import { createPlaceholderDecoration } from './decorations';
11
- import { createMultiBodiedExtensionPlaceholderDecorations, updateMultiBodiedExtensionPlaceholderDecorations } from './multi-bodied-extension-placeholder-decorations';
12
- import { createSourceSyncBlockPlaceholderDecorations, updateSourceSyncBlockPlaceholderDecorations } from './source-sync-block-placeholder-decorations';
13
6
  import { calculateUserInteractionState, createPlaceHolderStateFrom, getPlaceholderState } from './utils';
14
7
  export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder, placeholderPrompts, withEmptyParagraph, initialIsPlaceholderHidden, placeholderADF, isRovoLLMEnabled, api) {
15
8
  if (!defaultPlaceholderText && !placeholderPrompts && !bracketPlaceholderText && !placeholderADF) {
@@ -28,7 +21,7 @@ export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceh
28
21
  state: {
29
22
  init: function init(_, state) {
30
23
  var _api$focus, _api$typeAhead;
31
- return _objectSpread(_objectSpread({}, createPlaceHolderStateFrom({
24
+ return createPlaceHolderStateFrom({
32
25
  isInitial: true,
33
26
  isEditorFocused: Boolean(api === null || api === void 0 || (_api$focus = api.focus) === null || _api$focus === void 0 || (_api$focus = _api$focus.sharedState.currentState()) === null || _api$focus === void 0 ? void 0 : _api$focus.hasFocus),
34
27
  editorState: state,
@@ -43,9 +36,6 @@ export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceh
43
36
  intl: intl,
44
37
  withEmptyParagraph: withEmptyParagraph,
45
38
  isPlaceholderHidden: initialIsPlaceholderHidden
46
- })), {}, {
47
- sourceSyncBlockPlaceholderDecorations: createSourceSyncBlockPlaceholderDecorations(state, intl),
48
- multiBodiedExtensionPlaceholderDecorations: createMultiBodiedExtensionPlaceholderDecorations(state, intl)
49
39
  });
50
40
  },
51
41
  apply: function apply(tr, placeholderState, _oldEditorState, newEditorState) {
@@ -72,7 +62,7 @@ export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceh
72
62
  defaultPlaceholderText = meta.placeholderText;
73
63
  }
74
64
  }
75
- var newPlaceholderState = _objectSpread(_objectSpread({}, createPlaceHolderStateFrom({
65
+ var newPlaceholderState = createPlaceHolderStateFrom({
76
66
  isEditorFocused: isEditorFocused,
77
67
  editorState: newEditorState,
78
68
  isTypeAheadOpen: api === null || api === void 0 || (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 ? void 0 : _api$typeAhead2.actions.isOpen,
@@ -87,20 +77,6 @@ export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceh
87
77
  isPlaceholderHidden: isPlaceholderHidden,
88
78
  withEmptyParagraph: withEmptyParagraph,
89
79
  showOnEmptyParagraph: (_meta$showOnEmptyPara = meta === null || meta === void 0 ? void 0 : meta.showOnEmptyParagraph) !== null && _meta$showOnEmptyPara !== void 0 ? _meta$showOnEmptyPara : placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.showOnEmptyParagraph
90
- })), {}, {
91
- sourceSyncBlockPlaceholderDecorations: updateSourceSyncBlockPlaceholderDecorations({
92
- currentDecorationSet: placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.sourceSyncBlockPlaceholderDecorations,
93
- intl: intl,
94
- newEditorState: newEditorState,
95
- oldEditorState: _oldEditorState,
96
- tr: tr
97
- }),
98
- multiBodiedExtensionPlaceholderDecorations: updateMultiBodiedExtensionPlaceholderDecorations({
99
- currentDecorationSet: placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.multiBodiedExtensionPlaceholderDecorations,
100
- intl: intl,
101
- newEditorState: newEditorState,
102
- tr: tr
103
- })
104
80
  });
105
81
 
106
82
  // Clear timeouts when hasPlaceholder becomes false
@@ -112,7 +88,7 @@ export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceh
112
88
  },
113
89
  props: {
114
90
  decorations: function decorations(editorState) {
115
- var _api$composition, _api$showDiff, _syncBlockPlaceholder, _multiBodiedExtension;
91
+ var _api$composition, _api$showDiff;
116
92
  // @ts-ignore quick fix which needs follow up to use standard apis
117
93
  if (editorState.collabEditPlugin$ && editorState.collabEditPlugin$.isReady !== true) {
118
94
  return;
@@ -123,9 +99,7 @@ export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceh
123
99
  pos = _getPlaceholderState.pos,
124
100
  typedAndDeleted = _getPlaceholderState.typedAndDeleted,
125
101
  contextPlaceholderADF = _getPlaceholderState.contextPlaceholderADF,
126
- showOnEmptyParagraph = _getPlaceholderState.showOnEmptyParagraph,
127
- sourceSyncBlockPlaceholderDecorations = _getPlaceholderState.sourceSyncBlockPlaceholderDecorations,
128
- multiBodiedExtensionPlaceholderDecorations = _getPlaceholderState.multiBodiedExtensionPlaceholderDecorations;
102
+ showOnEmptyParagraph = _getPlaceholderState.showOnEmptyParagraph;
129
103
 
130
104
  // Decorations is still called after plugin is destroyed
131
105
  // So we need to make sure decorations is not called if plugin has been destroyed to prevent the placeholder animations' setTimeouts called infinitely
@@ -134,26 +108,13 @@ export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceh
134
108
  }
135
109
  var compositionPluginState = api === null || api === void 0 || (_api$composition = api.composition) === null || _api$composition === void 0 ? void 0 : _api$composition.sharedState.currentState();
136
110
  var isShowingDiff = Boolean(api === null || api === void 0 || (_api$showDiff = api.showDiff) === null || _api$showDiff === void 0 || (_api$showDiff = _api$showDiff.sharedState.currentState()) === null || _api$showDiff === void 0 ? void 0 : _api$showDiff.isDisplayingChanges);
137
- var syncBlockPlaceholderDecorations = !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing) && !isShowingDiff ? sourceSyncBlockPlaceholderDecorations : undefined;
138
- var multiBodiedExtensionDecorations = !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing) && !isShowingDiff ? multiBodiedExtensionPlaceholderDecorations : undefined;
139
- var syncBlockDecorationItems = (_syncBlockPlaceholder = syncBlockPlaceholderDecorations === null || syncBlockPlaceholderDecorations === void 0 ? void 0 : syncBlockPlaceholderDecorations.find()) !== null && _syncBlockPlaceholder !== void 0 ? _syncBlockPlaceholder : [];
140
- var multiBodiedExtensionDecorationItems = (_multiBodiedExtension = multiBodiedExtensionDecorations === null || multiBodiedExtensionDecorations === void 0 ? void 0 : multiBodiedExtensionDecorations.find()) !== null && _multiBodiedExtension !== void 0 ? _multiBodiedExtension : [];
141
111
  if (hasPlaceholder && ((placeholderText !== null && placeholderText !== void 0 ? placeholderText : '') || placeholderPrompts || placeholderADF || contextPlaceholderADF) && pos !== undefined && !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing) && !isShowingDiff) {
142
112
  var initialDelayWhenUserTypedAndDeleted = typedAndDeleted ? TYPEWRITER_TYPED_AND_DELETED_DELAY : 0;
143
113
  // contextPlaceholderADF takes precedence over the global placeholderADF
144
114
  var placeholderAdfToUse = contextPlaceholderADF || placeholderADF;
145
- return createPlaceholderDecoration(editorState, placeholderText !== null && placeholderText !== void 0 ? placeholderText : '', placeholderPrompts, activeTypewriterTimeouts, pos, initialDelayWhenUserTypedAndDeleted, placeholderAdfToUse, showOnEmptyParagraph).add(editorState.doc, [].concat(_toConsumableArray(syncBlockDecorationItems), _toConsumableArray(multiBodiedExtensionDecorationItems)));
146
- }
147
- // These sets are already mapped in plugin state. Return a single
148
- // active set directly, and only rebuild when multiple sets must be merged.
149
- if (syncBlockDecorationItems.length > 0 && multiBodiedExtensionDecorationItems.length === 0) {
150
- return syncBlockPlaceholderDecorations;
151
- }
152
- if (multiBodiedExtensionDecorationItems.length > 0 && syncBlockDecorationItems.length === 0) {
153
- return multiBodiedExtensionDecorations;
115
+ return createPlaceholderDecoration(editorState, placeholderText !== null && placeholderText !== void 0 ? placeholderText : '', placeholderPrompts, activeTypewriterTimeouts, pos, initialDelayWhenUserTypedAndDeleted, placeholderAdfToUse, showOnEmptyParagraph);
154
116
  }
155
- var additionalDecorations = [].concat(_toConsumableArray(syncBlockDecorationItems), _toConsumableArray(multiBodiedExtensionDecorationItems));
156
- return additionalDecorations.length > 0 ? DecorationSet.create(editorState.doc, additionalDecorations) : undefined;
117
+ return;
157
118
  }
158
119
  },
159
120
  view: function view() {
@@ -188,7 +188,7 @@ export function createPlaceHolderStateFrom(_ref3) {
188
188
  userHadTyped: userHadTyped
189
189
  });
190
190
  }
191
- if (nodeTypesWithSyncBlockPlaceholderText.includes(parentType) && isEmptyNode && editorExperiment('platform_synced_block', true) && !expValEquals('platform_editor_sync_block_activation', 'isEnabled', true)) {
191
+ if (nodeTypesWithSyncBlockPlaceholderText.includes(parentType) && isEmptyNode && editorExperiment('platform_synced_block', true)) {
192
192
  return setPlaceHolderState({
193
193
  placeholderText: intl.formatMessage(messages.sourceSyncBlockPlaceholderText),
194
194
  pos: $from.pos,
@@ -7,4 +7,3 @@ export declare const TYPEWRITER_TYPED_AND_DELETED_DELAY = 1500;
7
7
  export declare const nodeTypesWithLongPlaceholderText: string[];
8
8
  export declare const nodeTypesWithShortPlaceholderText: string[];
9
9
  export declare const nodeTypesWithSyncBlockPlaceholderText: string[];
10
- export declare const nodeTypesWithMultiBodiedExtensionPlaceholderText: string[];
@@ -1,18 +1,15 @@
1
1
  import type { IntlShape } from 'react-intl';
2
2
  import type { DocNode } from '@atlaskit/adf-schema';
3
3
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
- import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
5
4
  export interface PlaceHolderState {
6
5
  canShowOnEmptyParagraph?: boolean;
7
6
  contextPlaceholderADF?: DocNode;
8
7
  hasPlaceholder: boolean;
9
8
  isPlaceholderHidden?: boolean;
10
- multiBodiedExtensionPlaceholderDecorations?: DecorationSet;
11
9
  placeholderPrompts?: string[];
12
10
  placeholderText?: string;
13
11
  pos?: number;
14
12
  showOnEmptyParagraph?: boolean;
15
- sourceSyncBlockPlaceholderDecorations?: DecorationSet;
16
13
  typedAndDeleted?: boolean;
17
14
  userHadTyped?: boolean;
18
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-placeholder",
3
- "version": "12.0.33",
3
+ "version": "12.0.35",
4
4
  "description": "Placeholder plugin for @atlaskit/editor-core.",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -23,18 +23,18 @@
23
23
  "@atlaskit/css": "^1.0.0",
24
24
  "@atlaskit/editor-plugin-composition": "^11.0.0",
25
25
  "@atlaskit/editor-plugin-focus": "^11.0.0",
26
- "@atlaskit/editor-plugin-show-diff": "^10.5.0",
26
+ "@atlaskit/editor-plugin-show-diff": "^10.6.0",
27
27
  "@atlaskit/editor-plugin-type-ahead": "^13.0.0",
28
28
  "@atlaskit/editor-prosemirror": "^8.0.0",
29
29
  "@atlaskit/platform-feature-flags": "^2.1.0",
30
- "@atlaskit/primitives": "^22.1.0",
30
+ "@atlaskit/primitives": "^22.2.0",
31
31
  "@atlaskit/spinner": "^20.1.0",
32
- "@atlaskit/tmp-editor-statsig": "^132.0.0",
33
- "@atlaskit/tokens": "^16.2.0",
32
+ "@atlaskit/tmp-editor-statsig": "^132.6.0",
33
+ "@atlaskit/tokens": "^16.3.0",
34
34
  "@babel/runtime": "^7.0.0"
35
35
  },
36
36
  "peerDependencies": {
37
- "@atlaskit/editor-common": "^116.35.0",
37
+ "@atlaskit/editor-common": "^116.38.0",
38
38
  "react": "^18.2.0",
39
39
  "react-dom": "^18.2.0",
40
40
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"