@atlaskit/editor-plugin-placeholder 7.4.2 → 7.4.4
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 +16 -0
- package/dist/cjs/pm-plugins/decorations.js +1 -1
- package/dist/cjs/pm-plugins/main.js +2 -3
- package/dist/cjs/pm-plugins/utils.js +14 -35
- package/dist/es2019/pm-plugins/decorations.js +1 -1
- package/dist/es2019/pm-plugins/main.js +3 -4
- package/dist/es2019/pm-plugins/utils.js +14 -35
- package/dist/esm/pm-plugins/decorations.js +1 -1
- package/dist/esm/pm-plugins/main.js +3 -4
- package/dist/esm/pm-plugins/utils.js +14 -35
- package/dist/types/pm-plugins/utils.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/utils.d.ts +1 -1
- package/package.json +4 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-placeholder
|
|
2
2
|
|
|
3
|
+
## 7.4.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`db37927f35395`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/db37927f35395) -
|
|
8
|
+
Cleanup platform_editor_ai_aifc_patch_ga_blockers flag.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 7.4.3
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`1fd2b267eb592`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1fd2b267eb592) -
|
|
16
|
+
Cleanup `platform_editor_ai_aifc_patch_ga` flag
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 7.4.2
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -20,7 +20,7 @@ function createPlaceholderDecoration(editorState, placeholderText, placeholderPr
|
|
|
20
20
|
var placeholderDecoration = document.createElement('span');
|
|
21
21
|
var placeholderNodeWithText = placeholderDecoration;
|
|
22
22
|
placeholderDecoration.setAttribute('data-testid', _constants.placeholderTestId);
|
|
23
|
-
var shouldFadeIn = showOnEmptyParagraph
|
|
23
|
+
var shouldFadeIn = showOnEmptyParagraph;
|
|
24
24
|
placeholderDecoration.className = shouldFadeIn ? 'placeholder-decoration placeholder-decoration-fade-in' : 'placeholder-decoration';
|
|
25
25
|
placeholderDecoration.setAttribute('aria-hidden', 'true');
|
|
26
26
|
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = createPlugin;
|
|
7
7
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
8
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
9
8
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
10
9
|
var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
|
|
11
10
|
var _placeholderPlugin = require("../placeholderPlugin");
|
|
@@ -58,7 +57,7 @@ function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, empt
|
|
|
58
57
|
userHadTyped = _calculateUserInterac.userHadTyped,
|
|
59
58
|
typedAndDeleted = _calculateUserInterac.typedAndDeleted;
|
|
60
59
|
var isPlaceholderHidden = (_placeholderState$isP = placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.isPlaceholderHidden) !== null && _placeholderState$isP !== void 0 ? _placeholderState$isP : false;
|
|
61
|
-
var shouldUpdatePlaceholderHidden = (
|
|
60
|
+
var shouldUpdatePlaceholderHidden = (meta === null || meta === void 0 ? void 0 : meta.isPlaceholderHidden) !== undefined;
|
|
62
61
|
if (shouldUpdatePlaceholderHidden) {
|
|
63
62
|
isPlaceholderHidden = meta.isPlaceholderHidden;
|
|
64
63
|
}
|
|
@@ -66,7 +65,7 @@ function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, empt
|
|
|
66
65
|
var isCreateWithRovoOverride = !!meta.placeholderText && (0, _expVal.expVal)('cwr_blank_object_experiment', 'isEnabled', false);
|
|
67
66
|
// Only update defaultPlaceholderText from meta if we're not using ADF placeholder
|
|
68
67
|
// OR when the create-with-rovo experiment is active to allow intentional non-empty placeholder overrides
|
|
69
|
-
if (!
|
|
68
|
+
if (!placeholderADF || isCreateWithRovoOverride) {
|
|
70
69
|
defaultPlaceholderText = meta.placeholderText;
|
|
71
70
|
}
|
|
72
71
|
}
|
|
@@ -13,7 +13,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
13
13
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
14
14
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
15
15
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
16
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
16
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
18
17
|
var _placeholderPlugin = require("../placeholderPlugin");
|
|
19
18
|
var _adfBuilders = require("./adf-builders");
|
|
@@ -78,7 +77,7 @@ function createPlaceHolderStateFrom(_ref3) {
|
|
|
78
77
|
isPlaceholderHidden = _ref3.isPlaceholderHidden,
|
|
79
78
|
withEmptyParagraph = _ref3.withEmptyParagraph,
|
|
80
79
|
showOnEmptyParagraph = _ref3.showOnEmptyParagraph;
|
|
81
|
-
var shouldHidePlaceholder =
|
|
80
|
+
var shouldHidePlaceholder = isPlaceholderHidden;
|
|
82
81
|
if (shouldHidePlaceholder) {
|
|
83
82
|
return _objectSpread(_objectSpread({}, emptyPlaceholder({
|
|
84
83
|
placeholderText: defaultPlaceholderText,
|
|
@@ -111,34 +110,10 @@ function createPlaceHolderStateFrom(_ref3) {
|
|
|
111
110
|
$to = _editorState$selectio.$to;
|
|
112
111
|
var isOnEmptyParagraphInNonEmptyDoc = (defaultPlaceholderText || placeholderADF) && withEmptyParagraph && !isInitial && !(0, _utils.isEmptyDocument)(editorState.doc) && from === to && (0, _utils.isEmptyParagraph)($to.parent) && (0, _utils.hasDocAsParent)($to);
|
|
113
112
|
if (isOnEmptyParagraphInNonEmptyDoc) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return setPlaceHolderState({
|
|
119
|
-
placeholderText: defaultPlaceholderText,
|
|
120
|
-
pos: to,
|
|
121
|
-
placeholderPrompts: placeholderPrompts,
|
|
122
|
-
typedAndDeleted: typedAndDeleted,
|
|
123
|
-
userHadTyped: userHadTyped,
|
|
124
|
-
canShowOnEmptyParagraph: true,
|
|
125
|
-
showOnEmptyParagraph: true
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
// Focus is required to start the timeout for showing placeholder
|
|
129
|
-
if (isEditorFocused) {
|
|
130
|
-
return emptyPlaceholder({
|
|
131
|
-
placeholderText: defaultPlaceholderText,
|
|
132
|
-
placeholderPrompts: placeholderPrompts,
|
|
133
|
-
userHadTyped: userHadTyped,
|
|
134
|
-
canShowOnEmptyParagraph: true,
|
|
135
|
-
showOnEmptyParagraph: false,
|
|
136
|
-
pos: to
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
} else if (isEditorFocused) {
|
|
140
|
-
// Original behavior: focus is required for both showing and keeping placeholder visible
|
|
141
|
-
return showOnEmptyParagraph ? setPlaceHolderState({
|
|
113
|
+
// If placeholder was already shown, keep it visible even without focus
|
|
114
|
+
// This prevents the placeholder from disappearing when switching browser tabs
|
|
115
|
+
if (showOnEmptyParagraph) {
|
|
116
|
+
return setPlaceHolderState({
|
|
142
117
|
placeholderText: defaultPlaceholderText,
|
|
143
118
|
pos: to,
|
|
144
119
|
placeholderPrompts: placeholderPrompts,
|
|
@@ -146,7 +121,11 @@ function createPlaceHolderStateFrom(_ref3) {
|
|
|
146
121
|
userHadTyped: userHadTyped,
|
|
147
122
|
canShowOnEmptyParagraph: true,
|
|
148
123
|
showOnEmptyParagraph: true
|
|
149
|
-
})
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
// Focus is required to start the timeout for showing placeholder
|
|
127
|
+
if (isEditorFocused) {
|
|
128
|
+
return emptyPlaceholder({
|
|
150
129
|
placeholderText: defaultPlaceholderText,
|
|
151
130
|
placeholderPrompts: placeholderPrompts,
|
|
152
131
|
userHadTyped: userHadTyped,
|
|
@@ -199,8 +178,8 @@ function createPlaceHolderStateFrom(_ref3) {
|
|
|
199
178
|
var isFirstCell = (table === null || table === void 0 || (_table$node$firstChil = table.node.firstChild) === null || _table$node$firstChil === void 0 ? void 0 : _table$node$firstChil.content.firstChild) === parentNode;
|
|
200
179
|
if (isFirstCell) {
|
|
201
180
|
return setPlaceHolderState({
|
|
202
|
-
placeholderText:
|
|
203
|
-
contextPlaceholderADF: (0,
|
|
181
|
+
placeholderText: undefined,
|
|
182
|
+
contextPlaceholderADF: (0, _adfBuilders.createShortEmptyNodePlaceholderADF)(intl),
|
|
204
183
|
pos: $from.pos,
|
|
205
184
|
placeholderPrompts: placeholderPrompts,
|
|
206
185
|
typedAndDeleted: typedAndDeleted,
|
|
@@ -210,8 +189,8 @@ function createPlaceHolderStateFrom(_ref3) {
|
|
|
210
189
|
}
|
|
211
190
|
if (_constants.nodeTypesWithLongPlaceholderText.includes(parentType) && isEmptyNode) {
|
|
212
191
|
return setPlaceHolderState({
|
|
213
|
-
placeholderText:
|
|
214
|
-
contextPlaceholderADF: (0,
|
|
192
|
+
placeholderText: undefined,
|
|
193
|
+
contextPlaceholderADF: (0, _adfBuilders.createLongEmptyNodePlaceholderADF)(intl),
|
|
215
194
|
pos: $from.pos,
|
|
216
195
|
placeholderPrompts: placeholderPrompts,
|
|
217
196
|
typedAndDeleted: typedAndDeleted,
|
|
@@ -10,7 +10,7 @@ export function createPlaceholderDecoration(editorState, placeholderText, placeh
|
|
|
10
10
|
const placeholderDecoration = document.createElement('span');
|
|
11
11
|
let placeholderNodeWithText = placeholderDecoration;
|
|
12
12
|
placeholderDecoration.setAttribute('data-testid', placeholderTestId);
|
|
13
|
-
const shouldFadeIn = showOnEmptyParagraph
|
|
13
|
+
const shouldFadeIn = showOnEmptyParagraph;
|
|
14
14
|
placeholderDecoration.className = shouldFadeIn ? 'placeholder-decoration placeholder-decoration-fade-in' : 'placeholder-decoration';
|
|
15
15
|
placeholderDecoration.setAttribute('aria-hidden', 'true');
|
|
16
16
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
2
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
3
|
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
5
|
-
import {
|
|
4
|
+
import { EMPTY_PARAGRAPH_TIMEOUT_DELAY, pluginKey } from '../placeholderPlugin';
|
|
6
5
|
import { TYPEWRITER_TYPED_AND_DELETED_DELAY } from './constants';
|
|
7
6
|
import { createPlaceholderDecoration } from './decorations';
|
|
8
7
|
import { calculateUserInteractionState, createPlaceHolderStateFrom, getPlaceholderState } from './utils';
|
|
@@ -51,7 +50,7 @@ export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceh
|
|
|
51
50
|
newEditorState
|
|
52
51
|
});
|
|
53
52
|
let isPlaceholderHidden = (_placeholderState$isP = placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.isPlaceholderHidden) !== null && _placeholderState$isP !== void 0 ? _placeholderState$isP : false;
|
|
54
|
-
const shouldUpdatePlaceholderHidden =
|
|
53
|
+
const shouldUpdatePlaceholderHidden = (meta === null || meta === void 0 ? void 0 : meta.isPlaceholderHidden) !== undefined;
|
|
55
54
|
if (shouldUpdatePlaceholderHidden) {
|
|
56
55
|
isPlaceholderHidden = meta.isPlaceholderHidden;
|
|
57
56
|
}
|
|
@@ -59,7 +58,7 @@ export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceh
|
|
|
59
58
|
const isCreateWithRovoOverride = !!meta.placeholderText && expVal('cwr_blank_object_experiment', 'isEnabled', false);
|
|
60
59
|
// Only update defaultPlaceholderText from meta if we're not using ADF placeholder
|
|
61
60
|
// OR when the create-with-rovo experiment is active to allow intentional non-empty placeholder overrides
|
|
62
|
-
if (!
|
|
61
|
+
if (!placeholderADF || isCreateWithRovoOverride) {
|
|
63
62
|
defaultPlaceholderText = meta.placeholderText;
|
|
64
63
|
}
|
|
65
64
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { placeholderTextMessages as messages } from '@atlaskit/editor-common/messages';
|
|
2
2
|
import { bracketTyped, hasDocAsParent, isEmptyDocument, isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
6
5
|
import { pluginKey } from '../placeholderPlugin';
|
|
7
6
|
import { createLongEmptyNodePlaceholderADF, createShortEmptyNodePlaceholderADF } from './adf-builders';
|
|
@@ -65,7 +64,7 @@ export function createPlaceHolderStateFrom({
|
|
|
65
64
|
withEmptyParagraph,
|
|
66
65
|
showOnEmptyParagraph
|
|
67
66
|
}) {
|
|
68
|
-
const shouldHidePlaceholder =
|
|
67
|
+
const shouldHidePlaceholder = isPlaceholderHidden;
|
|
69
68
|
if (shouldHidePlaceholder) {
|
|
70
69
|
return {
|
|
71
70
|
...emptyPlaceholder({
|
|
@@ -100,34 +99,10 @@ export function createPlaceHolderStateFrom({
|
|
|
100
99
|
} = editorState.selection;
|
|
101
100
|
const isOnEmptyParagraphInNonEmptyDoc = (defaultPlaceholderText || placeholderADF) && withEmptyParagraph && !isInitial && !isEmptyDocument(editorState.doc) && from === to && isEmptyParagraph($to.parent) && hasDocAsParent($to);
|
|
102
101
|
if (isOnEmptyParagraphInNonEmptyDoc) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return setPlaceHolderState({
|
|
108
|
-
placeholderText: defaultPlaceholderText,
|
|
109
|
-
pos: to,
|
|
110
|
-
placeholderPrompts,
|
|
111
|
-
typedAndDeleted,
|
|
112
|
-
userHadTyped,
|
|
113
|
-
canShowOnEmptyParagraph: true,
|
|
114
|
-
showOnEmptyParagraph: true
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
// Focus is required to start the timeout for showing placeholder
|
|
118
|
-
if (isEditorFocused) {
|
|
119
|
-
return emptyPlaceholder({
|
|
120
|
-
placeholderText: defaultPlaceholderText,
|
|
121
|
-
placeholderPrompts,
|
|
122
|
-
userHadTyped,
|
|
123
|
-
canShowOnEmptyParagraph: true,
|
|
124
|
-
showOnEmptyParagraph: false,
|
|
125
|
-
pos: to
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
} else if (isEditorFocused) {
|
|
129
|
-
// Original behavior: focus is required for both showing and keeping placeholder visible
|
|
130
|
-
return showOnEmptyParagraph ? setPlaceHolderState({
|
|
102
|
+
// If placeholder was already shown, keep it visible even without focus
|
|
103
|
+
// This prevents the placeholder from disappearing when switching browser tabs
|
|
104
|
+
if (showOnEmptyParagraph) {
|
|
105
|
+
return setPlaceHolderState({
|
|
131
106
|
placeholderText: defaultPlaceholderText,
|
|
132
107
|
pos: to,
|
|
133
108
|
placeholderPrompts,
|
|
@@ -135,7 +110,11 @@ export function createPlaceHolderStateFrom({
|
|
|
135
110
|
userHadTyped,
|
|
136
111
|
canShowOnEmptyParagraph: true,
|
|
137
112
|
showOnEmptyParagraph: true
|
|
138
|
-
})
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
// Focus is required to start the timeout for showing placeholder
|
|
116
|
+
if (isEditorFocused) {
|
|
117
|
+
return emptyPlaceholder({
|
|
139
118
|
placeholderText: defaultPlaceholderText,
|
|
140
119
|
placeholderPrompts,
|
|
141
120
|
userHadTyped,
|
|
@@ -187,8 +166,8 @@ export function createPlaceHolderStateFrom({
|
|
|
187
166
|
const isFirstCell = (table === null || table === void 0 ? void 0 : (_table$node$firstChil = table.node.firstChild) === null || _table$node$firstChil === void 0 ? void 0 : _table$node$firstChil.content.firstChild) === parentNode;
|
|
188
167
|
if (isFirstCell) {
|
|
189
168
|
return setPlaceHolderState({
|
|
190
|
-
placeholderText:
|
|
191
|
-
contextPlaceholderADF:
|
|
169
|
+
placeholderText: undefined,
|
|
170
|
+
contextPlaceholderADF: createShortEmptyNodePlaceholderADF(intl),
|
|
192
171
|
pos: $from.pos,
|
|
193
172
|
placeholderPrompts,
|
|
194
173
|
typedAndDeleted,
|
|
@@ -198,8 +177,8 @@ export function createPlaceHolderStateFrom({
|
|
|
198
177
|
}
|
|
199
178
|
if (nodeTypesWithLongPlaceholderText.includes(parentType) && isEmptyNode) {
|
|
200
179
|
return setPlaceHolderState({
|
|
201
|
-
placeholderText:
|
|
202
|
-
contextPlaceholderADF:
|
|
180
|
+
placeholderText: undefined,
|
|
181
|
+
contextPlaceholderADF: createLongEmptyNodePlaceholderADF(intl),
|
|
203
182
|
pos: $from.pos,
|
|
204
183
|
placeholderPrompts,
|
|
205
184
|
typedAndDeleted,
|
|
@@ -14,7 +14,7 @@ export function createPlaceholderDecoration(editorState, placeholderText, placeh
|
|
|
14
14
|
var placeholderDecoration = document.createElement('span');
|
|
15
15
|
var placeholderNodeWithText = placeholderDecoration;
|
|
16
16
|
placeholderDecoration.setAttribute('data-testid', placeholderTestId);
|
|
17
|
-
var shouldFadeIn = showOnEmptyParagraph
|
|
17
|
+
var shouldFadeIn = showOnEmptyParagraph;
|
|
18
18
|
placeholderDecoration.className = shouldFadeIn ? 'placeholder-decoration placeholder-decoration-fade-in' : 'placeholder-decoration';
|
|
19
19
|
placeholderDecoration.setAttribute('aria-hidden', 'true');
|
|
20
20
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
2
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
3
|
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
5
|
-
import {
|
|
4
|
+
import { EMPTY_PARAGRAPH_TIMEOUT_DELAY, pluginKey } from '../placeholderPlugin';
|
|
6
5
|
import { TYPEWRITER_TYPED_AND_DELETED_DELAY } from './constants';
|
|
7
6
|
import { createPlaceholderDecoration } from './decorations';
|
|
8
7
|
import { calculateUserInteractionState, createPlaceHolderStateFrom, getPlaceholderState } from './utils';
|
|
@@ -52,7 +51,7 @@ export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceh
|
|
|
52
51
|
userHadTyped = _calculateUserInterac.userHadTyped,
|
|
53
52
|
typedAndDeleted = _calculateUserInterac.typedAndDeleted;
|
|
54
53
|
var isPlaceholderHidden = (_placeholderState$isP = placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.isPlaceholderHidden) !== null && _placeholderState$isP !== void 0 ? _placeholderState$isP : false;
|
|
55
|
-
var shouldUpdatePlaceholderHidden =
|
|
54
|
+
var shouldUpdatePlaceholderHidden = (meta === null || meta === void 0 ? void 0 : meta.isPlaceholderHidden) !== undefined;
|
|
56
55
|
if (shouldUpdatePlaceholderHidden) {
|
|
57
56
|
isPlaceholderHidden = meta.isPlaceholderHidden;
|
|
58
57
|
}
|
|
@@ -60,7 +59,7 @@ export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceh
|
|
|
60
59
|
var isCreateWithRovoOverride = !!meta.placeholderText && expVal('cwr_blank_object_experiment', 'isEnabled', false);
|
|
61
60
|
// Only update defaultPlaceholderText from meta if we're not using ADF placeholder
|
|
62
61
|
// OR when the create-with-rovo experiment is active to allow intentional non-empty placeholder overrides
|
|
63
|
-
if (!
|
|
62
|
+
if (!placeholderADF || isCreateWithRovoOverride) {
|
|
64
63
|
defaultPlaceholderText = meta.placeholderText;
|
|
65
64
|
}
|
|
66
65
|
}
|
|
@@ -4,7 +4,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import { placeholderTextMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
5
|
import { bracketTyped, hasDocAsParent, isEmptyDocument, isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
7
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
7
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
9
8
|
import { pluginKey } from '../placeholderPlugin';
|
|
10
9
|
import { createLongEmptyNodePlaceholderADF, createShortEmptyNodePlaceholderADF } from './adf-builders';
|
|
@@ -67,7 +66,7 @@ export function createPlaceHolderStateFrom(_ref3) {
|
|
|
67
66
|
isPlaceholderHidden = _ref3.isPlaceholderHidden,
|
|
68
67
|
withEmptyParagraph = _ref3.withEmptyParagraph,
|
|
69
68
|
showOnEmptyParagraph = _ref3.showOnEmptyParagraph;
|
|
70
|
-
var shouldHidePlaceholder =
|
|
69
|
+
var shouldHidePlaceholder = isPlaceholderHidden;
|
|
71
70
|
if (shouldHidePlaceholder) {
|
|
72
71
|
return _objectSpread(_objectSpread({}, emptyPlaceholder({
|
|
73
72
|
placeholderText: defaultPlaceholderText,
|
|
@@ -100,34 +99,10 @@ export function createPlaceHolderStateFrom(_ref3) {
|
|
|
100
99
|
$to = _editorState$selectio.$to;
|
|
101
100
|
var isOnEmptyParagraphInNonEmptyDoc = (defaultPlaceholderText || placeholderADF) && withEmptyParagraph && !isInitial && !isEmptyDocument(editorState.doc) && from === to && isEmptyParagraph($to.parent) && hasDocAsParent($to);
|
|
102
101
|
if (isOnEmptyParagraphInNonEmptyDoc) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return setPlaceHolderState({
|
|
108
|
-
placeholderText: defaultPlaceholderText,
|
|
109
|
-
pos: to,
|
|
110
|
-
placeholderPrompts: placeholderPrompts,
|
|
111
|
-
typedAndDeleted: typedAndDeleted,
|
|
112
|
-
userHadTyped: userHadTyped,
|
|
113
|
-
canShowOnEmptyParagraph: true,
|
|
114
|
-
showOnEmptyParagraph: true
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
// Focus is required to start the timeout for showing placeholder
|
|
118
|
-
if (isEditorFocused) {
|
|
119
|
-
return emptyPlaceholder({
|
|
120
|
-
placeholderText: defaultPlaceholderText,
|
|
121
|
-
placeholderPrompts: placeholderPrompts,
|
|
122
|
-
userHadTyped: userHadTyped,
|
|
123
|
-
canShowOnEmptyParagraph: true,
|
|
124
|
-
showOnEmptyParagraph: false,
|
|
125
|
-
pos: to
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
} else if (isEditorFocused) {
|
|
129
|
-
// Original behavior: focus is required for both showing and keeping placeholder visible
|
|
130
|
-
return showOnEmptyParagraph ? setPlaceHolderState({
|
|
102
|
+
// If placeholder was already shown, keep it visible even without focus
|
|
103
|
+
// This prevents the placeholder from disappearing when switching browser tabs
|
|
104
|
+
if (showOnEmptyParagraph) {
|
|
105
|
+
return setPlaceHolderState({
|
|
131
106
|
placeholderText: defaultPlaceholderText,
|
|
132
107
|
pos: to,
|
|
133
108
|
placeholderPrompts: placeholderPrompts,
|
|
@@ -135,7 +110,11 @@ export function createPlaceHolderStateFrom(_ref3) {
|
|
|
135
110
|
userHadTyped: userHadTyped,
|
|
136
111
|
canShowOnEmptyParagraph: true,
|
|
137
112
|
showOnEmptyParagraph: true
|
|
138
|
-
})
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
// Focus is required to start the timeout for showing placeholder
|
|
116
|
+
if (isEditorFocused) {
|
|
117
|
+
return emptyPlaceholder({
|
|
139
118
|
placeholderText: defaultPlaceholderText,
|
|
140
119
|
placeholderPrompts: placeholderPrompts,
|
|
141
120
|
userHadTyped: userHadTyped,
|
|
@@ -188,8 +167,8 @@ export function createPlaceHolderStateFrom(_ref3) {
|
|
|
188
167
|
var isFirstCell = (table === null || table === void 0 || (_table$node$firstChil = table.node.firstChild) === null || _table$node$firstChil === void 0 ? void 0 : _table$node$firstChil.content.firstChild) === parentNode;
|
|
189
168
|
if (isFirstCell) {
|
|
190
169
|
return setPlaceHolderState({
|
|
191
|
-
placeholderText:
|
|
192
|
-
contextPlaceholderADF:
|
|
170
|
+
placeholderText: undefined,
|
|
171
|
+
contextPlaceholderADF: createShortEmptyNodePlaceholderADF(intl),
|
|
193
172
|
pos: $from.pos,
|
|
194
173
|
placeholderPrompts: placeholderPrompts,
|
|
195
174
|
typedAndDeleted: typedAndDeleted,
|
|
@@ -199,8 +178,8 @@ export function createPlaceHolderStateFrom(_ref3) {
|
|
|
199
178
|
}
|
|
200
179
|
if (nodeTypesWithLongPlaceholderText.includes(parentType) && isEmptyNode) {
|
|
201
180
|
return setPlaceHolderState({
|
|
202
|
-
placeholderText:
|
|
203
|
-
contextPlaceholderADF:
|
|
181
|
+
placeholderText: undefined,
|
|
182
|
+
contextPlaceholderADF: createLongEmptyNodePlaceholderADF(intl),
|
|
204
183
|
pos: $from.pos,
|
|
205
184
|
placeholderPrompts: placeholderPrompts,
|
|
206
185
|
typedAndDeleted: typedAndDeleted,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DocNode } from '@atlaskit/adf-schema';
|
|
2
2
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type {
|
|
3
|
+
import type { CreatePlaceholderStateProps, PlaceHolderState, UserInteractionState } from './types';
|
|
4
4
|
export declare function getPlaceholderState(editorState: EditorState): PlaceHolderState;
|
|
5
5
|
export declare function setPlaceHolderState({ placeholderText, pos, placeholderPrompts, typedAndDeleted, userHadTyped, canShowOnEmptyParagraph, showOnEmptyParagraph, contextPlaceholderADF, }: {
|
|
6
6
|
canShowOnEmptyParagraph?: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DocNode } from '@atlaskit/adf-schema';
|
|
2
2
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type {
|
|
3
|
+
import type { CreatePlaceholderStateProps, PlaceHolderState, UserInteractionState } from './types';
|
|
4
4
|
export declare function getPlaceholderState(editorState: EditorState): PlaceHolderState;
|
|
5
5
|
export declare function setPlaceHolderState({ placeholderText, pos, placeholderPrompts, typedAndDeleted, userHadTyped, canShowOnEmptyParagraph, showOnEmptyParagraph, contextPlaceholderADF, }: {
|
|
6
6
|
canShowOnEmptyParagraph?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-placeholder",
|
|
3
|
-
"version": "7.4.
|
|
3
|
+
"version": "7.4.4",
|
|
4
4
|
"description": "Placeholder plugin for @atlaskit/editor-core.",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
38
38
|
"@atlaskit/primitives": "^18.0.0",
|
|
39
39
|
"@atlaskit/spinner": "^19.0.0",
|
|
40
|
-
"@atlaskit/tmp-editor-statsig": "^35.
|
|
41
|
-
"@atlaskit/tokens": "^11.
|
|
40
|
+
"@atlaskit/tmp-editor-statsig": "^35.6.0",
|
|
41
|
+
"@atlaskit/tokens": "^11.1.0",
|
|
42
42
|
"@babel/runtime": "^7.0.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@atlaskit/editor-common": "^111.
|
|
45
|
+
"@atlaskit/editor-common": "^111.33.0",
|
|
46
46
|
"react": "^18.2.0",
|
|
47
47
|
"react-dom": "^18.2.0",
|
|
48
48
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
@@ -51,12 +51,6 @@
|
|
|
51
51
|
"@testing-library/react": "^16.3.0"
|
|
52
52
|
},
|
|
53
53
|
"platform-feature-flags": {
|
|
54
|
-
"platform_editor_ai_aifc_patch_ga": {
|
|
55
|
-
"type": "boolean"
|
|
56
|
-
},
|
|
57
|
-
"platform_editor_ai_aifc_patch_ga_blockers": {
|
|
58
|
-
"type": "boolean"
|
|
59
|
-
},
|
|
60
54
|
"platform_editor_ai_aifc_adf_placeholder": {
|
|
61
55
|
"type": "boolean"
|
|
62
56
|
}
|