@atlaskit/editor-plugin-placeholder 16.1.8 → 16.2.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 +18 -0
- package/dist/cjs/placeholderPlugin.js +1 -1
- package/dist/cjs/pm-plugins/animation.js +12 -2
- package/dist/cjs/pm-plugins/decorations.js +2 -1
- package/dist/cjs/pm-plugins/main.js +2 -2
- package/dist/es2019/placeholderPlugin.js +1 -1
- package/dist/es2019/pm-plugins/animation.js +12 -3
- package/dist/es2019/pm-plugins/decorations.js +2 -2
- package/dist/es2019/pm-plugins/main.js +2 -2
- package/dist/esm/placeholderPlugin.js +1 -1
- package/dist/esm/pm-plugins/animation.js +12 -2
- package/dist/esm/pm-plugins/decorations.js +2 -1
- package/dist/esm/pm-plugins/main.js +2 -2
- package/dist/types/placeholderPluginType.d.ts +2 -0
- package/dist/types/pm-plugins/animation.d.ts +2 -1
- package/dist/types/pm-plugins/decorations.d.ts +2 -1
- package/dist/types/pm-plugins/main.d.ts +2 -2
- package/dist/types/pm-plugins/types.d.ts +4 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-placeholder
|
|
2
2
|
|
|
3
|
+
## 16.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`f8494a7feeab9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f8494a7feeab9) -
|
|
8
|
+
Add animated full-sentence Library CTA placeholder prompts with Library-specific faster erase
|
|
9
|
+
timing, a static reduced-motion fallback, and screen-reader-safe presentation.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 16.1.9
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 16.1.8
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -59,7 +59,7 @@ var placeholderPlugin = exports.placeholderPlugin = function placeholderPlugin(_
|
|
|
59
59
|
name: 'placeholder',
|
|
60
60
|
plugin: function plugin(_ref5) {
|
|
61
61
|
var getIntl = _ref5.getIntl;
|
|
62
|
-
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 === null || options === void 0 ? void 0 : options.isPlaceholderHidden, options && options.placeholderADF, options === null || options === void 0 ? void 0 : options.isRovoLLMEnabled, api);
|
|
62
|
+
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 === null || options === void 0 ? void 0 : options.isPlaceholderHidden, options && options.placeholderADF, options && options.placeholderPromptAnimationOptions, options === null || options === void 0 ? void 0 : options.isRovoLLMEnabled, api);
|
|
63
63
|
}
|
|
64
64
|
}];
|
|
65
65
|
},
|
|
@@ -7,6 +7,13 @@ exports.cycleThroughPlaceholderPrompts = void 0;
|
|
|
7
7
|
var _constants = require("./constants");
|
|
8
8
|
var cycleThroughPlaceholderPrompts = exports.cycleThroughPlaceholderPrompts = function cycleThroughPlaceholderPrompts(placeholderPrompts, activeTypewriterTimeouts, placeholderNodeWithText) {
|
|
9
9
|
var initialDelayWhenUserTypedAndDeleted = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
10
|
+
var options = arguments.length > 4 ? arguments[4] : undefined;
|
|
11
|
+
var prefersReducedMotion = typeof window !== 'undefined' && typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
12
|
+
if (prefersReducedMotion) {
|
|
13
|
+
var _placeholderPrompts$;
|
|
14
|
+
placeholderNodeWithText.textContent = (_placeholderPrompts$ = placeholderPrompts[0]) !== null && _placeholderPrompts$ !== void 0 ? _placeholderPrompts$ : '';
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
10
17
|
var currentPromptIndex = 0;
|
|
11
18
|
var displayedText = '';
|
|
12
19
|
var animationTimeouts = [];
|
|
@@ -22,7 +29,10 @@ var cycleThroughPlaceholderPrompts = exports.cycleThroughPlaceholderPrompts = fu
|
|
|
22
29
|
return timeoutId;
|
|
23
30
|
};
|
|
24
31
|
var _startAnimationCycle = function startAnimationCycle() {
|
|
32
|
+
var _options$eraseDelay, _options$pauseBeforeE;
|
|
25
33
|
var currentPrompt = placeholderPrompts[currentPromptIndex];
|
|
34
|
+
var eraseDelay = (_options$eraseDelay = options === null || options === void 0 ? void 0 : options.eraseDelay) !== null && _options$eraseDelay !== void 0 ? _options$eraseDelay : _constants.TYPEWRITER_ERASE_DELAY;
|
|
35
|
+
var pauseBeforeErase = (_options$pauseBeforeE = options === null || options === void 0 ? void 0 : options.pauseBeforeErase) !== null && _options$pauseBeforeE !== void 0 ? _options$pauseBeforeE : _constants.TYPEWRITER_PAUSE_BEFORE_ERASE;
|
|
26
36
|
var characterIndex = 0;
|
|
27
37
|
var _typeNextCharacter = function typeNextCharacter() {
|
|
28
38
|
if (characterIndex < currentPrompt.length) {
|
|
@@ -31,14 +41,14 @@ var cycleThroughPlaceholderPrompts = exports.cycleThroughPlaceholderPrompts = fu
|
|
|
31
41
|
characterIndex++;
|
|
32
42
|
scheduleTimeout(_typeNextCharacter, _constants.TYPEWRITER_TYPE_DELAY);
|
|
33
43
|
} else {
|
|
34
|
-
scheduleTimeout(_eraseLastCharacter,
|
|
44
|
+
scheduleTimeout(_eraseLastCharacter, pauseBeforeErase);
|
|
35
45
|
}
|
|
36
46
|
};
|
|
37
47
|
var _eraseLastCharacter = function eraseLastCharacter() {
|
|
38
48
|
if (displayedText.length > 1) {
|
|
39
49
|
displayedText = displayedText.substring(0, displayedText.length - 1);
|
|
40
50
|
placeholderNodeWithText.textContent = displayedText;
|
|
41
|
-
scheduleTimeout(_eraseLastCharacter,
|
|
51
|
+
scheduleTimeout(_eraseLastCharacter, eraseDelay);
|
|
42
52
|
} else {
|
|
43
53
|
displayedText = ' ';
|
|
44
54
|
placeholderNodeWithText.textContent = displayedText;
|
|
@@ -17,6 +17,7 @@ function createPlaceholderDecoration(editorState, placeholderText, placeholderPr
|
|
|
17
17
|
var initialDelayWhenUserTypedAndDeleted = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
|
18
18
|
var placeholderADF = arguments.length > 6 ? arguments[6] : undefined;
|
|
19
19
|
var showOnEmptyParagraph = arguments.length > 7 ? arguments[7] : undefined;
|
|
20
|
+
var placeholderPromptAnimationOptions = arguments.length > 8 ? arguments[8] : undefined;
|
|
20
21
|
var browser = (0, _browser.getBrowserInfo)();
|
|
21
22
|
var placeholderDecoration = document.createElement('span');
|
|
22
23
|
var placeholderNodeWithText = placeholderDecoration;
|
|
@@ -73,7 +74,7 @@ function createPlaceholderDecoration(editorState, placeholderText, placeholderPr
|
|
|
73
74
|
});
|
|
74
75
|
}
|
|
75
76
|
} else if (placeholderPrompts) {
|
|
76
|
-
(0, _animation.cycleThroughPlaceholderPrompts)(placeholderPrompts, activeTypewriterTimeouts, placeholderNodeWithText, initialDelayWhenUserTypedAndDeleted);
|
|
77
|
+
(0, _animation.cycleThroughPlaceholderPrompts)(placeholderPrompts, activeTypewriterTimeouts, placeholderNodeWithText, initialDelayWhenUserTypedAndDeleted, placeholderPromptAnimationOptions);
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
// ME-2289 Tapping on backspace in empty editor hides and displays the keyboard
|
|
@@ -10,7 +10,7 @@ var _placeholderPlugin = require("../placeholderPlugin");
|
|
|
10
10
|
var _constants = require("./constants");
|
|
11
11
|
var _decorations = require("./decorations");
|
|
12
12
|
var _utils = require("./utils");
|
|
13
|
-
function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder, placeholderPrompts, withEmptyParagraph, initialIsPlaceholderHidden, placeholderADF, isRovoLLMEnabled, api) {
|
|
13
|
+
function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder, placeholderPrompts, withEmptyParagraph, initialIsPlaceholderHidden, placeholderADF, placeholderPromptAnimationOptions, isRovoLLMEnabled, api) {
|
|
14
14
|
if (!defaultPlaceholderText && !placeholderPrompts && !bracketPlaceholderText && !placeholderADF) {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
@@ -118,7 +118,7 @@ function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, empt
|
|
|
118
118
|
var initialDelayWhenUserTypedAndDeleted = typedAndDeleted ? _constants.TYPEWRITER_TYPED_AND_DELETED_DELAY : 0;
|
|
119
119
|
// contextPlaceholderADF takes precedence over the global placeholderADF
|
|
120
120
|
var placeholderAdfToUse = contextPlaceholderADF || placeholderADF;
|
|
121
|
-
return (0, _decorations.createPlaceholderDecoration)(editorState, placeholderText !== null && placeholderText !== void 0 ? placeholderText : '', placeholderPrompts, activeTypewriterTimeouts, pos, initialDelayWhenUserTypedAndDeleted, placeholderAdfToUse, showOnEmptyParagraph);
|
|
121
|
+
return (0, _decorations.createPlaceholderDecoration)(editorState, placeholderText !== null && placeholderText !== void 0 ? placeholderText : '', placeholderPrompts, activeTypewriterTimeouts, pos, initialDelayWhenUserTypedAndDeleted, placeholderAdfToUse, showOnEmptyParagraph, placeholderPromptAnimationOptions);
|
|
122
122
|
}
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
@@ -50,7 +50,7 @@ export const placeholderPlugin = ({
|
|
|
50
50
|
name: 'placeholder',
|
|
51
51
|
plugin: ({
|
|
52
52
|
getIntl
|
|
53
|
-
}) => createPlugin(getIntl(), options && options.placeholder, options && options.placeholderBracketHint, options && options.emptyLinePlaceholder, options && options.placeholderPrompts, options === null || options === void 0 ? void 0 : options.withEmptyParagraph, options === null || options === void 0 ? void 0 : options.isPlaceholderHidden, options && options.placeholderADF, options === null || options === void 0 ? void 0 : options.isRovoLLMEnabled, api)
|
|
53
|
+
}) => createPlugin(getIntl(), options && options.placeholder, options && options.placeholderBracketHint, options && options.emptyLinePlaceholder, options && options.placeholderPrompts, options === null || options === void 0 ? void 0 : options.withEmptyParagraph, options === null || options === void 0 ? void 0 : options.isPlaceholderHidden, options && options.placeholderADF, options && options.placeholderPromptAnimationOptions, options === null || options === void 0 ? void 0 : options.isRovoLLMEnabled, api)
|
|
54
54
|
}];
|
|
55
55
|
},
|
|
56
56
|
contentComponent: params => {
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { TYPEWRITER_CYCLE_DELAY, TYPEWRITER_ERASE_DELAY, TYPEWRITER_PAUSE_BEFORE_ERASE, TYPEWRITER_TYPE_DELAY } from './constants';
|
|
2
|
-
export const cycleThroughPlaceholderPrompts = (placeholderPrompts, activeTypewriterTimeouts, placeholderNodeWithText, initialDelayWhenUserTypedAndDeleted = 0) => {
|
|
2
|
+
export const cycleThroughPlaceholderPrompts = (placeholderPrompts, activeTypewriterTimeouts, placeholderNodeWithText, initialDelayWhenUserTypedAndDeleted = 0, options) => {
|
|
3
|
+
const prefersReducedMotion = typeof window !== 'undefined' && typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
4
|
+
if (prefersReducedMotion) {
|
|
5
|
+
var _placeholderPrompts$;
|
|
6
|
+
placeholderNodeWithText.textContent = (_placeholderPrompts$ = placeholderPrompts[0]) !== null && _placeholderPrompts$ !== void 0 ? _placeholderPrompts$ : '';
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
3
9
|
let currentPromptIndex = 0;
|
|
4
10
|
let displayedText = '';
|
|
5
11
|
let animationTimeouts = [];
|
|
@@ -13,7 +19,10 @@ export const cycleThroughPlaceholderPrompts = (placeholderPrompts, activeTypewri
|
|
|
13
19
|
return timeoutId;
|
|
14
20
|
};
|
|
15
21
|
const startAnimationCycle = () => {
|
|
22
|
+
var _options$eraseDelay, _options$pauseBeforeE;
|
|
16
23
|
const currentPrompt = placeholderPrompts[currentPromptIndex];
|
|
24
|
+
const eraseDelay = (_options$eraseDelay = options === null || options === void 0 ? void 0 : options.eraseDelay) !== null && _options$eraseDelay !== void 0 ? _options$eraseDelay : TYPEWRITER_ERASE_DELAY;
|
|
25
|
+
const pauseBeforeErase = (_options$pauseBeforeE = options === null || options === void 0 ? void 0 : options.pauseBeforeErase) !== null && _options$pauseBeforeE !== void 0 ? _options$pauseBeforeE : TYPEWRITER_PAUSE_BEFORE_ERASE;
|
|
17
26
|
let characterIndex = 0;
|
|
18
27
|
const typeNextCharacter = () => {
|
|
19
28
|
if (characterIndex < currentPrompt.length) {
|
|
@@ -22,14 +31,14 @@ export const cycleThroughPlaceholderPrompts = (placeholderPrompts, activeTypewri
|
|
|
22
31
|
characterIndex++;
|
|
23
32
|
scheduleTimeout(typeNextCharacter, TYPEWRITER_TYPE_DELAY);
|
|
24
33
|
} else {
|
|
25
|
-
scheduleTimeout(eraseLastCharacter,
|
|
34
|
+
scheduleTimeout(eraseLastCharacter, pauseBeforeErase);
|
|
26
35
|
}
|
|
27
36
|
};
|
|
28
37
|
const eraseLastCharacter = () => {
|
|
29
38
|
if (displayedText.length > 1) {
|
|
30
39
|
displayedText = displayedText.substring(0, displayedText.length - 1);
|
|
31
40
|
placeholderNodeWithText.textContent = displayedText;
|
|
32
|
-
scheduleTimeout(eraseLastCharacter,
|
|
41
|
+
scheduleTimeout(eraseLastCharacter, eraseDelay);
|
|
33
42
|
} else {
|
|
34
43
|
displayedText = ' ';
|
|
35
44
|
placeholderNodeWithText.textContent = displayedText;
|
|
@@ -6,7 +6,7 @@ import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
|
6
6
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
7
7
|
import { cycleThroughPlaceholderPrompts } from './animation';
|
|
8
8
|
import { placeholderTestId } from './constants';
|
|
9
|
-
export function createPlaceholderDecoration(editorState, placeholderText, placeholderPrompts, activeTypewriterTimeouts, pos = 1, initialDelayWhenUserTypedAndDeleted = 0, placeholderADF, showOnEmptyParagraph) {
|
|
9
|
+
export function createPlaceholderDecoration(editorState, placeholderText, placeholderPrompts, activeTypewriterTimeouts, pos = 1, initialDelayWhenUserTypedAndDeleted = 0, placeholderADF, showOnEmptyParagraph, placeholderPromptAnimationOptions) {
|
|
10
10
|
const browser = getBrowserInfo();
|
|
11
11
|
const placeholderDecoration = document.createElement('span');
|
|
12
12
|
let placeholderNodeWithText = placeholderDecoration;
|
|
@@ -63,7 +63,7 @@ export function createPlaceholderDecoration(editorState, placeholderText, placeh
|
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
} else if (placeholderPrompts) {
|
|
66
|
-
cycleThroughPlaceholderPrompts(placeholderPrompts, activeTypewriterTimeouts, placeholderNodeWithText, initialDelayWhenUserTypedAndDeleted);
|
|
66
|
+
cycleThroughPlaceholderPrompts(placeholderPrompts, activeTypewriterTimeouts, placeholderNodeWithText, initialDelayWhenUserTypedAndDeleted, placeholderPromptAnimationOptions);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
// ME-2289 Tapping on backspace in empty editor hides and displays the keyboard
|
|
@@ -4,7 +4,7 @@ import { EMPTY_PARAGRAPH_TIMEOUT_DELAY, pluginKey } from '../placeholderPlugin';
|
|
|
4
4
|
import { TYPEWRITER_TYPED_AND_DELETED_DELAY } from './constants';
|
|
5
5
|
import { createPlaceholderDecoration } from './decorations';
|
|
6
6
|
import { calculateUserInteractionState, createPlaceHolderStateFrom, getPlaceholderState } from './utils';
|
|
7
|
-
export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder, placeholderPrompts, withEmptyParagraph, initialIsPlaceholderHidden, placeholderADF, isRovoLLMEnabled, api) {
|
|
7
|
+
export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder, placeholderPrompts, withEmptyParagraph, initialIsPlaceholderHidden, placeholderADF, placeholderPromptAnimationOptions, isRovoLLMEnabled, api) {
|
|
8
8
|
if (!defaultPlaceholderText && !placeholderPrompts && !bracketPlaceholderText && !placeholderADF) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
@@ -112,7 +112,7 @@ export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceh
|
|
|
112
112
|
const initialDelayWhenUserTypedAndDeleted = typedAndDeleted ? TYPEWRITER_TYPED_AND_DELETED_DELAY : 0;
|
|
113
113
|
// contextPlaceholderADF takes precedence over the global placeholderADF
|
|
114
114
|
const placeholderAdfToUse = contextPlaceholderADF || placeholderADF;
|
|
115
|
-
return createPlaceholderDecoration(editorState, placeholderText !== null && placeholderText !== void 0 ? placeholderText : '', placeholderPrompts, activeTypewriterTimeouts, pos, initialDelayWhenUserTypedAndDeleted, placeholderAdfToUse, showOnEmptyParagraph);
|
|
115
|
+
return createPlaceholderDecoration(editorState, placeholderText !== null && placeholderText !== void 0 ? placeholderText : '', placeholderPrompts, activeTypewriterTimeouts, pos, initialDelayWhenUserTypedAndDeleted, placeholderAdfToUse, showOnEmptyParagraph, placeholderPromptAnimationOptions);
|
|
116
116
|
}
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
@@ -52,7 +52,7 @@ export var placeholderPlugin = function placeholderPlugin(_ref) {
|
|
|
52
52
|
name: 'placeholder',
|
|
53
53
|
plugin: function plugin(_ref5) {
|
|
54
54
|
var getIntl = _ref5.getIntl;
|
|
55
|
-
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 === null || options === void 0 ? void 0 : options.isPlaceholderHidden, options && options.placeholderADF, options === null || options === void 0 ? void 0 : options.isRovoLLMEnabled, api);
|
|
55
|
+
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 === null || options === void 0 ? void 0 : options.isPlaceholderHidden, options && options.placeholderADF, options && options.placeholderPromptAnimationOptions, options === null || options === void 0 ? void 0 : options.isRovoLLMEnabled, api);
|
|
56
56
|
}
|
|
57
57
|
}];
|
|
58
58
|
},
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { TYPEWRITER_CYCLE_DELAY, TYPEWRITER_ERASE_DELAY, TYPEWRITER_PAUSE_BEFORE_ERASE, TYPEWRITER_TYPE_DELAY } from './constants';
|
|
2
2
|
export var cycleThroughPlaceholderPrompts = function cycleThroughPlaceholderPrompts(placeholderPrompts, activeTypewriterTimeouts, placeholderNodeWithText) {
|
|
3
3
|
var initialDelayWhenUserTypedAndDeleted = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
4
|
+
var options = arguments.length > 4 ? arguments[4] : undefined;
|
|
5
|
+
var prefersReducedMotion = typeof window !== 'undefined' && typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
6
|
+
if (prefersReducedMotion) {
|
|
7
|
+
var _placeholderPrompts$;
|
|
8
|
+
placeholderNodeWithText.textContent = (_placeholderPrompts$ = placeholderPrompts[0]) !== null && _placeholderPrompts$ !== void 0 ? _placeholderPrompts$ : '';
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
4
11
|
var currentPromptIndex = 0;
|
|
5
12
|
var displayedText = '';
|
|
6
13
|
var animationTimeouts = [];
|
|
@@ -16,7 +23,10 @@ export var cycleThroughPlaceholderPrompts = function cycleThroughPlaceholderProm
|
|
|
16
23
|
return timeoutId;
|
|
17
24
|
};
|
|
18
25
|
var _startAnimationCycle = function startAnimationCycle() {
|
|
26
|
+
var _options$eraseDelay, _options$pauseBeforeE;
|
|
19
27
|
var currentPrompt = placeholderPrompts[currentPromptIndex];
|
|
28
|
+
var eraseDelay = (_options$eraseDelay = options === null || options === void 0 ? void 0 : options.eraseDelay) !== null && _options$eraseDelay !== void 0 ? _options$eraseDelay : TYPEWRITER_ERASE_DELAY;
|
|
29
|
+
var pauseBeforeErase = (_options$pauseBeforeE = options === null || options === void 0 ? void 0 : options.pauseBeforeErase) !== null && _options$pauseBeforeE !== void 0 ? _options$pauseBeforeE : TYPEWRITER_PAUSE_BEFORE_ERASE;
|
|
20
30
|
var characterIndex = 0;
|
|
21
31
|
var _typeNextCharacter = function typeNextCharacter() {
|
|
22
32
|
if (characterIndex < currentPrompt.length) {
|
|
@@ -25,14 +35,14 @@ export var cycleThroughPlaceholderPrompts = function cycleThroughPlaceholderProm
|
|
|
25
35
|
characterIndex++;
|
|
26
36
|
scheduleTimeout(_typeNextCharacter, TYPEWRITER_TYPE_DELAY);
|
|
27
37
|
} else {
|
|
28
|
-
scheduleTimeout(_eraseLastCharacter,
|
|
38
|
+
scheduleTimeout(_eraseLastCharacter, pauseBeforeErase);
|
|
29
39
|
}
|
|
30
40
|
};
|
|
31
41
|
var _eraseLastCharacter = function eraseLastCharacter() {
|
|
32
42
|
if (displayedText.length > 1) {
|
|
33
43
|
displayedText = displayedText.substring(0, displayedText.length - 1);
|
|
34
44
|
placeholderNodeWithText.textContent = displayedText;
|
|
35
|
-
scheduleTimeout(_eraseLastCharacter,
|
|
45
|
+
scheduleTimeout(_eraseLastCharacter, eraseDelay);
|
|
36
46
|
} else {
|
|
37
47
|
displayedText = ' ';
|
|
38
48
|
placeholderNodeWithText.textContent = displayedText;
|
|
@@ -11,6 +11,7 @@ export function createPlaceholderDecoration(editorState, placeholderText, placeh
|
|
|
11
11
|
var initialDelayWhenUserTypedAndDeleted = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
|
12
12
|
var placeholderADF = arguments.length > 6 ? arguments[6] : undefined;
|
|
13
13
|
var showOnEmptyParagraph = arguments.length > 7 ? arguments[7] : undefined;
|
|
14
|
+
var placeholderPromptAnimationOptions = arguments.length > 8 ? arguments[8] : undefined;
|
|
14
15
|
var browser = getBrowserInfo();
|
|
15
16
|
var placeholderDecoration = document.createElement('span');
|
|
16
17
|
var placeholderNodeWithText = placeholderDecoration;
|
|
@@ -67,7 +68,7 @@ export function createPlaceholderDecoration(editorState, placeholderText, placeh
|
|
|
67
68
|
});
|
|
68
69
|
}
|
|
69
70
|
} else if (placeholderPrompts) {
|
|
70
|
-
cycleThroughPlaceholderPrompts(placeholderPrompts, activeTypewriterTimeouts, placeholderNodeWithText, initialDelayWhenUserTypedAndDeleted);
|
|
71
|
+
cycleThroughPlaceholderPrompts(placeholderPrompts, activeTypewriterTimeouts, placeholderNodeWithText, initialDelayWhenUserTypedAndDeleted, placeholderPromptAnimationOptions);
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
// ME-2289 Tapping on backspace in empty editor hides and displays the keyboard
|
|
@@ -4,7 +4,7 @@ import { EMPTY_PARAGRAPH_TIMEOUT_DELAY, pluginKey } from '../placeholderPlugin';
|
|
|
4
4
|
import { TYPEWRITER_TYPED_AND_DELETED_DELAY } from './constants';
|
|
5
5
|
import { createPlaceholderDecoration } from './decorations';
|
|
6
6
|
import { calculateUserInteractionState, createPlaceHolderStateFrom, getPlaceholderState } from './utils';
|
|
7
|
-
export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder, placeholderPrompts, withEmptyParagraph, initialIsPlaceholderHidden, placeholderADF, isRovoLLMEnabled, api) {
|
|
7
|
+
export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder, placeholderPrompts, withEmptyParagraph, initialIsPlaceholderHidden, placeholderADF, placeholderPromptAnimationOptions, isRovoLLMEnabled, api) {
|
|
8
8
|
if (!defaultPlaceholderText && !placeholderPrompts && !bracketPlaceholderText && !placeholderADF) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
@@ -112,7 +112,7 @@ export default function createPlugin(intl, defaultPlaceholderText, bracketPlaceh
|
|
|
112
112
|
var initialDelayWhenUserTypedAndDeleted = typedAndDeleted ? TYPEWRITER_TYPED_AND_DELETED_DELAY : 0;
|
|
113
113
|
// contextPlaceholderADF takes precedence over the global placeholderADF
|
|
114
114
|
var placeholderAdfToUse = contextPlaceholderADF || placeholderADF;
|
|
115
|
-
return createPlaceholderDecoration(editorState, placeholderText !== null && placeholderText !== void 0 ? placeholderText : '', placeholderPrompts, activeTypewriterTimeouts, pos, initialDelayWhenUserTypedAndDeleted, placeholderAdfToUse, showOnEmptyParagraph);
|
|
115
|
+
return createPlaceholderDecoration(editorState, placeholderText !== null && placeholderText !== void 0 ? placeholderText : '', placeholderPrompts, activeTypewriterTimeouts, pos, initialDelayWhenUserTypedAndDeleted, placeholderAdfToUse, showOnEmptyParagraph, placeholderPromptAnimationOptions);
|
|
116
116
|
}
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
@@ -4,6 +4,7 @@ import type { CompositionPlugin } from '@atlaskit/editor-plugin-composition';
|
|
|
4
4
|
import type { FocusPlugin } from '@atlaskit/editor-plugin-focus';
|
|
5
5
|
import type { ShowDiffPlugin } from '@atlaskit/editor-plugin-show-diff';
|
|
6
6
|
import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
|
|
7
|
+
import type { PlaceholderPromptAnimationOptions } from './pm-plugins/types';
|
|
7
8
|
export interface PlaceholderPluginOptions {
|
|
8
9
|
emptyLinePlaceholder?: string;
|
|
9
10
|
enableLoadingSpinner?: boolean;
|
|
@@ -12,6 +13,7 @@ export interface PlaceholderPluginOptions {
|
|
|
12
13
|
placeholder?: string;
|
|
13
14
|
placeholderADF?: DocNode;
|
|
14
15
|
placeholderBracketHint?: string;
|
|
16
|
+
placeholderPromptAnimationOptions?: PlaceholderPromptAnimationOptions;
|
|
15
17
|
placeholderPrompts?: string[];
|
|
16
18
|
withEmptyParagraph?: boolean;
|
|
17
19
|
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { PlaceholderPromptAnimationOptions } from './types';
|
|
2
|
+
export declare const cycleThroughPlaceholderPrompts: (placeholderPrompts: string[], activeTypewriterTimeouts: (() => void)[] | undefined, placeholderNodeWithText: HTMLElement, initialDelayWhenUserTypedAndDeleted?: number, options?: PlaceholderPromptAnimationOptions) => void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DocNode } from '@atlaskit/adf-schema/doc';
|
|
2
2
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
-
|
|
4
|
+
import type { PlaceholderPromptAnimationOptions } from './types';
|
|
5
|
+
export declare function createPlaceholderDecoration(editorState: EditorState, placeholderText: string, placeholderPrompts?: string[], activeTypewriterTimeouts?: (() => void)[], pos?: number, initialDelayWhenUserTypedAndDeleted?: number, placeholderADF?: DocNode, showOnEmptyParagraph?: boolean, placeholderPromptAnimationOptions?: PlaceholderPromptAnimationOptions): DecorationSet;
|
|
@@ -2,5 +2,5 @@ import type { IntlShape } from 'react-intl';
|
|
|
2
2
|
import type { DocNode } from '@atlaskit/adf-schema/doc';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
4
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
|
-
import type { PlaceholderPlugin } from '../placeholderPluginType';
|
|
6
|
-
export default function createPlugin(intl: IntlShape, defaultPlaceholderText?: string, bracketPlaceholderText?: string, emptyLinePlaceholder?: string, placeholderPrompts?: string[], withEmptyParagraph?: boolean, initialIsPlaceholderHidden?: boolean, placeholderADF?: DocNode, isRovoLLMEnabled?: boolean, api?: ExtractInjectionAPI<PlaceholderPlugin>): SafePlugin | undefined;
|
|
5
|
+
import type { PlaceholderPlugin, PlaceholderPluginOptions } from '../placeholderPluginType';
|
|
6
|
+
export default function createPlugin(intl: IntlShape, defaultPlaceholderText?: string, bracketPlaceholderText?: string, emptyLinePlaceholder?: string, placeholderPrompts?: string[], withEmptyParagraph?: boolean, initialIsPlaceholderHidden?: boolean, placeholderADF?: DocNode, placeholderPromptAnimationOptions?: PlaceholderPluginOptions['placeholderPromptAnimationOptions'], isRovoLLMEnabled?: boolean, api?: ExtractInjectionAPI<PlaceholderPlugin>): SafePlugin | undefined;
|
|
@@ -30,6 +30,10 @@ export type CreatePlaceholderStateProps = {
|
|
|
30
30
|
userHadTyped?: boolean;
|
|
31
31
|
withEmptyParagraph?: boolean;
|
|
32
32
|
};
|
|
33
|
+
export type PlaceholderPromptAnimationOptions = {
|
|
34
|
+
eraseDelay?: number;
|
|
35
|
+
pauseBeforeErase?: number;
|
|
36
|
+
};
|
|
33
37
|
export type UserInteractionState = {
|
|
34
38
|
newEditorState: EditorState;
|
|
35
39
|
oldEditorState?: EditorState;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-placeholder",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.2.0",
|
|
4
4
|
"description": "Placeholder plugin for @atlaskit/editor-core.",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
"@atlaskit/css": "^1.1.0",
|
|
25
25
|
"@atlaskit/editor-plugin-composition": "^15.1.0",
|
|
26
26
|
"@atlaskit/editor-plugin-focus": "^15.1.0",
|
|
27
|
-
"@atlaskit/editor-plugin-show-diff": "^14.
|
|
27
|
+
"@atlaskit/editor-plugin-show-diff": "^14.5.0",
|
|
28
28
|
"@atlaskit/editor-plugin-type-ahead": "^17.1.0",
|
|
29
29
|
"@atlaskit/editor-prosemirror": "^8.0.0",
|
|
30
30
|
"@atlaskit/platform-feature-flags": "^2.2.0",
|
|
31
31
|
"@atlaskit/primitives": "^22.5.0",
|
|
32
32
|
"@atlaskit/spinner": "^20.4.0",
|
|
33
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
33
|
+
"@atlaskit/tmp-editor-statsig": "^177.0.0",
|
|
34
34
|
"@atlaskit/tokens": "^16.11.0",
|
|
35
35
|
"@babel/runtime": "^7.0.0"
|
|
36
36
|
},
|