@atlaskit/editor-plugin-placeholder 6.5.4 → 6.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/cjs/placeholderPlugin.js +19 -568
- package/dist/cjs/pm-plugins/adf-builders.js +30 -0
- package/dist/cjs/pm-plugins/animation.js +58 -0
- package/dist/cjs/pm-plugins/constants.js +18 -0
- package/dist/cjs/pm-plugins/decorations.js +96 -0
- package/dist/cjs/pm-plugins/main.js +168 -0
- package/dist/cjs/pm-plugins/placeholderPluginLegacy.js +617 -0
- package/dist/cjs/pm-plugins/types.js +5 -0
- package/dist/cjs/pm-plugins/utils.js +243 -0
- package/dist/es2019/placeholderPlugin.js +8 -548
- package/dist/es2019/pm-plugins/adf-builders.js +22 -0
- package/dist/es2019/pm-plugins/animation.js +49 -0
- package/dist/es2019/pm-plugins/constants.js +12 -0
- package/dist/es2019/pm-plugins/decorations.js +87 -0
- package/dist/es2019/pm-plugins/main.js +162 -0
- package/dist/es2019/pm-plugins/placeholderPluginLegacy.js +598 -0
- package/dist/es2019/pm-plugins/types.js +1 -0
- package/dist/es2019/pm-plugins/utils.js +234 -0
- package/dist/esm/placeholderPlugin.js +17 -563
- package/dist/esm/pm-plugins/adf-builders.js +24 -0
- package/dist/esm/pm-plugins/animation.js +52 -0
- package/dist/esm/pm-plugins/constants.js +12 -0
- package/dist/esm/pm-plugins/decorations.js +90 -0
- package/dist/esm/pm-plugins/main.js +162 -0
- package/dist/esm/pm-plugins/placeholderPluginLegacy.js +607 -0
- package/dist/esm/pm-plugins/types.js +1 -0
- package/dist/esm/pm-plugins/utils.js +232 -0
- package/dist/types/placeholderPlugin.d.ts +0 -8
- package/dist/types/pm-plugins/adf-builders.d.ts +4 -0
- package/dist/types/pm-plugins/animation.d.ts +1 -0
- package/dist/types/pm-plugins/constants.d.ts +9 -0
- package/dist/types/pm-plugins/decorations.d.ts +4 -0
- package/dist/types/pm-plugins/main.d.ts +6 -0
- package/dist/types/pm-plugins/placeholderPluginLegacy.d.ts +13 -0
- package/dist/types/pm-plugins/types.d.ts +37 -0
- package/dist/types/pm-plugins/utils.d.ts +27 -0
- package/dist/types-ts4.5/placeholderPlugin.d.ts +0 -8
- package/dist/types-ts4.5/pm-plugins/adf-builders.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/animation.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/constants.d.ts +9 -0
- package/dist/types-ts4.5/pm-plugins/decorations.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +6 -0
- package/dist/types-ts4.5/pm-plugins/placeholderPluginLegacy.d.ts +13 -0
- package/dist/types-ts4.5/pm-plugins/types.d.ts +37 -0
- package/dist/types-ts4.5/pm-plugins/utils.d.ts +27 -0
- package/package.json +6 -9
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
import { placeholderTextMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
|
+
import { bracketTyped, hasDocAsParent, isEmptyDocument, isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
6
|
+
import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
9
|
+
import { pluginKey } from '../placeholderPlugin';
|
|
10
|
+
import { createLongEmptyNodePlaceholderADF, createShortEmptyNodePlaceholderADF } from './adf-builders';
|
|
11
|
+
import { nodeTypesWithLongPlaceholderText, nodeTypesWithShortPlaceholderText, nodeTypesWithSyncBlockPlaceholderText } from './constants';
|
|
12
|
+
export function getPlaceholderState(editorState) {
|
|
13
|
+
return pluginKey.getState(editorState);
|
|
14
|
+
}
|
|
15
|
+
export function setPlaceHolderState(_ref) {
|
|
16
|
+
var placeholderText = _ref.placeholderText,
|
|
17
|
+
pos = _ref.pos,
|
|
18
|
+
placeholderPrompts = _ref.placeholderPrompts,
|
|
19
|
+
typedAndDeleted = _ref.typedAndDeleted,
|
|
20
|
+
userHadTyped = _ref.userHadTyped,
|
|
21
|
+
canShowOnEmptyParagraph = _ref.canShowOnEmptyParagraph,
|
|
22
|
+
showOnEmptyParagraph = _ref.showOnEmptyParagraph,
|
|
23
|
+
contextPlaceholderADF = _ref.contextPlaceholderADF;
|
|
24
|
+
return {
|
|
25
|
+
hasPlaceholder: true,
|
|
26
|
+
placeholderText: placeholderText,
|
|
27
|
+
placeholderPrompts: placeholderPrompts,
|
|
28
|
+
contextPlaceholderADF: contextPlaceholderADF,
|
|
29
|
+
pos: pos ? pos : 1,
|
|
30
|
+
typedAndDeleted: typedAndDeleted,
|
|
31
|
+
userHadTyped: userHadTyped,
|
|
32
|
+
canShowOnEmptyParagraph: canShowOnEmptyParagraph,
|
|
33
|
+
showOnEmptyParagraph: showOnEmptyParagraph
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export var emptyPlaceholder = function emptyPlaceholder(_ref2) {
|
|
37
|
+
var placeholderText = _ref2.placeholderText,
|
|
38
|
+
placeholderPrompts = _ref2.placeholderPrompts,
|
|
39
|
+
userHadTyped = _ref2.userHadTyped,
|
|
40
|
+
pos = _ref2.pos,
|
|
41
|
+
canShowOnEmptyParagraph = _ref2.canShowOnEmptyParagraph,
|
|
42
|
+
showOnEmptyParagraph = _ref2.showOnEmptyParagraph;
|
|
43
|
+
return {
|
|
44
|
+
hasPlaceholder: false,
|
|
45
|
+
placeholderText: placeholderText,
|
|
46
|
+
placeholderPrompts: placeholderPrompts,
|
|
47
|
+
userHadTyped: userHadTyped,
|
|
48
|
+
typedAndDeleted: false,
|
|
49
|
+
canShowOnEmptyParagraph: canShowOnEmptyParagraph,
|
|
50
|
+
showOnEmptyParagraph: showOnEmptyParagraph,
|
|
51
|
+
pos: pos
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
export function createPlaceHolderStateFrom(_ref3) {
|
|
55
|
+
var isInitial = _ref3.isInitial,
|
|
56
|
+
isEditorFocused = _ref3.isEditorFocused,
|
|
57
|
+
editorState = _ref3.editorState,
|
|
58
|
+
isTypeAheadOpen = _ref3.isTypeAheadOpen,
|
|
59
|
+
defaultPlaceholderText = _ref3.defaultPlaceholderText,
|
|
60
|
+
intl = _ref3.intl,
|
|
61
|
+
bracketPlaceholderText = _ref3.bracketPlaceholderText,
|
|
62
|
+
emptyLinePlaceholder = _ref3.emptyLinePlaceholder,
|
|
63
|
+
placeholderADF = _ref3.placeholderADF,
|
|
64
|
+
placeholderPrompts = _ref3.placeholderPrompts,
|
|
65
|
+
typedAndDeleted = _ref3.typedAndDeleted,
|
|
66
|
+
userHadTyped = _ref3.userHadTyped,
|
|
67
|
+
isPlaceholderHidden = _ref3.isPlaceholderHidden,
|
|
68
|
+
withEmptyParagraph = _ref3.withEmptyParagraph,
|
|
69
|
+
showOnEmptyParagraph = _ref3.showOnEmptyParagraph;
|
|
70
|
+
if (isPlaceholderHidden && withEmptyParagraph) {
|
|
71
|
+
return _objectSpread(_objectSpread({}, emptyPlaceholder({
|
|
72
|
+
placeholderText: defaultPlaceholderText,
|
|
73
|
+
placeholderPrompts: placeholderPrompts,
|
|
74
|
+
userHadTyped: userHadTyped
|
|
75
|
+
})), {}, {
|
|
76
|
+
isPlaceholderHidden: isPlaceholderHidden
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (isTypeAheadOpen !== null && isTypeAheadOpen !== void 0 && isTypeAheadOpen(editorState)) {
|
|
80
|
+
return emptyPlaceholder({
|
|
81
|
+
placeholderText: defaultPlaceholderText,
|
|
82
|
+
placeholderPrompts: placeholderPrompts,
|
|
83
|
+
userHadTyped: userHadTyped
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
if ((defaultPlaceholderText || placeholderPrompts || placeholderADF) && isEmptyDocument(editorState.doc)) {
|
|
87
|
+
return setPlaceHolderState({
|
|
88
|
+
placeholderText: defaultPlaceholderText,
|
|
89
|
+
pos: 1,
|
|
90
|
+
placeholderPrompts: placeholderPrompts,
|
|
91
|
+
typedAndDeleted: typedAndDeleted,
|
|
92
|
+
userHadTyped: userHadTyped
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
if (withEmptyParagraph) {
|
|
96
|
+
var _editorState$selectio = editorState.selection,
|
|
97
|
+
from = _editorState$selectio.from,
|
|
98
|
+
to = _editorState$selectio.to,
|
|
99
|
+
$to = _editorState$selectio.$to;
|
|
100
|
+
if ((defaultPlaceholderText || placeholderADF) && withEmptyParagraph && isEditorFocused && !isInitial && !isEmptyDocument(editorState.doc) && from === to && isEmptyParagraph($to.parent) && hasDocAsParent($to)) {
|
|
101
|
+
return showOnEmptyParagraph ? setPlaceHolderState({
|
|
102
|
+
placeholderText: defaultPlaceholderText,
|
|
103
|
+
pos: to,
|
|
104
|
+
placeholderPrompts: placeholderPrompts,
|
|
105
|
+
typedAndDeleted: typedAndDeleted,
|
|
106
|
+
userHadTyped: userHadTyped,
|
|
107
|
+
canShowOnEmptyParagraph: true,
|
|
108
|
+
showOnEmptyParagraph: true
|
|
109
|
+
}) : emptyPlaceholder({
|
|
110
|
+
placeholderText: defaultPlaceholderText,
|
|
111
|
+
placeholderPrompts: placeholderPrompts,
|
|
112
|
+
userHadTyped: userHadTyped,
|
|
113
|
+
canShowOnEmptyParagraph: true,
|
|
114
|
+
showOnEmptyParagraph: false,
|
|
115
|
+
pos: to
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (isEditorFocused && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
120
|
+
var _parentNode$firstChil, _parentNode$firstChil2;
|
|
121
|
+
var _editorState$selectio2 = editorState.selection,
|
|
122
|
+
$from = _editorState$selectio2.$from,
|
|
123
|
+
_$to = _editorState$selectio2.$to;
|
|
124
|
+
if ($from.pos !== _$to.pos) {
|
|
125
|
+
return emptyPlaceholder({
|
|
126
|
+
placeholderText: defaultPlaceholderText,
|
|
127
|
+
placeholderPrompts: placeholderPrompts,
|
|
128
|
+
userHadTyped: userHadTyped
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
var parentNode = $from.node($from.depth - 1);
|
|
132
|
+
var parentType = parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name;
|
|
133
|
+
if (emptyLinePlaceholder && parentType === 'doc') {
|
|
134
|
+
var isEmptyLine = isEmptyParagraph($from.parent);
|
|
135
|
+
if (isEmptyLine) {
|
|
136
|
+
return setPlaceHolderState({
|
|
137
|
+
placeholderText: emptyLinePlaceholder,
|
|
138
|
+
pos: $from.pos,
|
|
139
|
+
placeholderPrompts: placeholderPrompts,
|
|
140
|
+
typedAndDeleted: typedAndDeleted,
|
|
141
|
+
userHadTyped: userHadTyped
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
var isEmptyNode = (parentNode === null || parentNode === void 0 ? void 0 : parentNode.childCount) === 1 && ((_parentNode$firstChil = parentNode.firstChild) === null || _parentNode$firstChil === void 0 ? void 0 : _parentNode$firstChil.content.size) === 0 && ((_parentNode$firstChil2 = parentNode.firstChild) === null || _parentNode$firstChil2 === void 0 ? void 0 : _parentNode$firstChil2.type.name) === 'paragraph';
|
|
146
|
+
if (nodeTypesWithShortPlaceholderText.includes(parentType) && isEmptyNode) {
|
|
147
|
+
var _table$node$firstChil;
|
|
148
|
+
var table = findParentNode(function (node) {
|
|
149
|
+
return node.type === editorState.schema.nodes.table;
|
|
150
|
+
})(editorState.selection);
|
|
151
|
+
if (!table) {
|
|
152
|
+
return emptyPlaceholder({
|
|
153
|
+
placeholderText: defaultPlaceholderText,
|
|
154
|
+
placeholderPrompts: placeholderPrompts,
|
|
155
|
+
userHadTyped: userHadTyped
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
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;
|
|
159
|
+
if (isFirstCell) {
|
|
160
|
+
return setPlaceHolderState({
|
|
161
|
+
placeholderText: !fg('platform_editor_ai_aifc_patch_ga') ? intl.formatMessage(messages.shortEmptyNodePlaceholderText) : undefined,
|
|
162
|
+
contextPlaceholderADF: fg('platform_editor_ai_aifc_patch_ga') ? createShortEmptyNodePlaceholderADF(intl) : undefined,
|
|
163
|
+
pos: $from.pos,
|
|
164
|
+
placeholderPrompts: placeholderPrompts,
|
|
165
|
+
typedAndDeleted: typedAndDeleted,
|
|
166
|
+
userHadTyped: userHadTyped
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (nodeTypesWithLongPlaceholderText.includes(parentType) && isEmptyNode) {
|
|
171
|
+
return setPlaceHolderState({
|
|
172
|
+
placeholderText: !fg('platform_editor_ai_aifc_patch_ga') ? intl.formatMessage(messages.longEmptyNodePlaceholderText) : undefined,
|
|
173
|
+
contextPlaceholderADF: fg('platform_editor_ai_aifc_patch_ga') ? createLongEmptyNodePlaceholderADF(intl) : undefined,
|
|
174
|
+
pos: $from.pos,
|
|
175
|
+
placeholderPrompts: placeholderPrompts,
|
|
176
|
+
typedAndDeleted: typedAndDeleted,
|
|
177
|
+
userHadTyped: userHadTyped
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
if (nodeTypesWithSyncBlockPlaceholderText.includes(parentType) && isEmptyNode && editorExperiment('platform_synced_block', true)) {
|
|
181
|
+
return setPlaceHolderState({
|
|
182
|
+
placeholderText: intl.formatMessage(messages.syncBlockPlaceholderText),
|
|
183
|
+
pos: $from.pos,
|
|
184
|
+
placeholderPrompts: placeholderPrompts,
|
|
185
|
+
typedAndDeleted: typedAndDeleted,
|
|
186
|
+
userHadTyped: userHadTyped
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
return emptyPlaceholder({
|
|
190
|
+
placeholderText: defaultPlaceholderText,
|
|
191
|
+
placeholderPrompts: placeholderPrompts,
|
|
192
|
+
userHadTyped: userHadTyped
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
if (bracketPlaceholderText && bracketTyped(editorState) && isEditorFocused) {
|
|
196
|
+
var _$from = editorState.selection.$from;
|
|
197
|
+
// Space is to account for positioning of the bracket
|
|
198
|
+
var bracketHint = ' ' + bracketPlaceholderText;
|
|
199
|
+
return setPlaceHolderState({
|
|
200
|
+
placeholderText: bracketHint,
|
|
201
|
+
pos: _$from.pos - 1,
|
|
202
|
+
placeholderPrompts: placeholderPrompts,
|
|
203
|
+
typedAndDeleted: typedAndDeleted,
|
|
204
|
+
userHadTyped: userHadTyped
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
return emptyPlaceholder({
|
|
208
|
+
placeholderText: defaultPlaceholderText,
|
|
209
|
+
placeholderPrompts: placeholderPrompts,
|
|
210
|
+
userHadTyped: userHadTyped
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
export function calculateUserInteractionState(_ref4) {
|
|
214
|
+
var placeholderState = _ref4.placeholderState,
|
|
215
|
+
oldEditorState = _ref4.oldEditorState,
|
|
216
|
+
newEditorState = _ref4.newEditorState;
|
|
217
|
+
var wasEmpty = oldEditorState ? isEmptyDocument(oldEditorState.doc) : true;
|
|
218
|
+
var isEmpty = isEmptyDocument(newEditorState.doc);
|
|
219
|
+
var hasEverTyped = Boolean(placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.userHadTyped) ||
|
|
220
|
+
// Previously typed
|
|
221
|
+
!wasEmpty ||
|
|
222
|
+
// Had content before
|
|
223
|
+
wasEmpty && !isEmpty; // Just added content
|
|
224
|
+
var justDeletedAll = hasEverTyped && isEmpty && !wasEmpty;
|
|
225
|
+
var isInTypedAndDeletedState = justDeletedAll || Boolean(placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.typedAndDeleted) && isEmpty;
|
|
226
|
+
// Only reset user interaction tracking when editor is cleanly empty
|
|
227
|
+
var shouldResetInteraction = isEmpty && !isInTypedAndDeletedState;
|
|
228
|
+
return {
|
|
229
|
+
userHadTyped: shouldResetInteraction ? false : hasEverTyped,
|
|
230
|
+
typedAndDeleted: isInTypedAndDeletedState
|
|
231
|
+
};
|
|
232
|
+
}
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
import type { IntlShape } from 'react-intl-next';
|
|
2
|
-
import type { DocNode } from '@atlaskit/adf-schema';
|
|
3
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
-
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
|
-
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
6
1
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
-
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
8
2
|
import type { PlaceholderPlugin } from './placeholderPluginType';
|
|
9
3
|
export declare const EMPTY_PARAGRAPH_TIMEOUT_DELAY = 2000;
|
|
10
4
|
export declare const pluginKey: PluginKey<any>;
|
|
11
|
-
export declare function createPlaceholderDecoration(editorState: EditorState, placeholderText: string, placeholderPrompts?: string[], activeTypewriterTimeouts?: (() => void)[], pos?: number, initialDelayWhenUserTypedAndDeleted?: number, placeholderADF?: DocNode): DecorationSet;
|
|
12
|
-
export declare function createPlugin(intl: IntlShape, defaultPlaceholderText?: string, bracketPlaceholderText?: string, emptyLinePlaceholder?: string, placeholderPrompts?: string[], withEmptyParagraph?: boolean, placeholderADF?: DocNode, api?: ExtractInjectionAPI<PlaceholderPlugin>): SafePlugin | undefined;
|
|
13
5
|
export declare const placeholderPlugin: PlaceholderPlugin;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { DocNode } from '@atlaskit/adf-schema';
|
|
3
|
+
export declare const createShortEmptyNodePlaceholderADF: ({ formatMessage }: IntlShape) => DocNode;
|
|
4
|
+
export declare const createLongEmptyNodePlaceholderADF: ({ formatMessage }: IntlShape) => DocNode;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const cycleThroughPlaceholderPrompts: (placeholderPrompts: string[], activeTypewriterTimeouts: (() => void)[] | undefined, placeholderNodeWithText: HTMLElement, initialDelayWhenUserTypedAndDeleted?: number) => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const placeholderTestId = "placeholder-test-id";
|
|
2
|
+
export declare const TYPEWRITER_TYPE_DELAY = 50;
|
|
3
|
+
export declare const TYPEWRITER_PAUSE_BEFORE_ERASE = 2000;
|
|
4
|
+
export declare const TYPEWRITER_ERASE_DELAY = 40;
|
|
5
|
+
export declare const TYPEWRITER_CYCLE_DELAY = 500;
|
|
6
|
+
export declare const TYPEWRITER_TYPED_AND_DELETED_DELAY = 1500;
|
|
7
|
+
export declare const nodeTypesWithLongPlaceholderText: string[];
|
|
8
|
+
export declare const nodeTypesWithShortPlaceholderText: string[];
|
|
9
|
+
export declare const nodeTypesWithSyncBlockPlaceholderText: string[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DocNode } from '@atlaskit/adf-schema';
|
|
2
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
export declare function createPlaceholderDecoration(editorState: EditorState, placeholderText: string, placeholderPrompts?: string[], activeTypewriterTimeouts?: (() => void)[], pos?: number, initialDelayWhenUserTypedAndDeleted?: number, placeholderADF?: DocNode): DecorationSet;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { DocNode } from '@atlaskit/adf-schema';
|
|
3
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
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, placeholderADF?: DocNode, api?: ExtractInjectionAPI<PlaceholderPlugin>): SafePlugin | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { DocNode } from '@atlaskit/adf-schema';
|
|
3
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
8
|
+
import type { PlaceholderPlugin } from '../placeholderPluginType';
|
|
9
|
+
export declare const EMPTY_PARAGRAPH_TIMEOUT_DELAY = 2000;
|
|
10
|
+
export declare const pluginKey: PluginKey<any>;
|
|
11
|
+
export declare function createPlaceholderDecoration(editorState: EditorState, placeholderText: string, placeholderPrompts?: string[], activeTypewriterTimeouts?: (() => void)[], pos?: number, initialDelayWhenUserTypedAndDeleted?: number, placeholderADF?: DocNode): DecorationSet;
|
|
12
|
+
export declare function createPlugin(intl: IntlShape, defaultPlaceholderText?: string, bracketPlaceholderText?: string, emptyLinePlaceholder?: string, placeholderPrompts?: string[], withEmptyParagraph?: boolean, placeholderADF?: DocNode, api?: ExtractInjectionAPI<PlaceholderPlugin>): SafePlugin | undefined;
|
|
13
|
+
export declare const placeholderPluginLegacy: PlaceholderPlugin;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { DocNode } from '@atlaskit/adf-schema';
|
|
3
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
export interface PlaceHolderState {
|
|
5
|
+
canShowOnEmptyParagraph?: boolean;
|
|
6
|
+
contextPlaceholderADF?: DocNode;
|
|
7
|
+
hasPlaceholder: boolean;
|
|
8
|
+
isPlaceholderHidden?: boolean;
|
|
9
|
+
placeholderPrompts?: string[];
|
|
10
|
+
placeholderText?: string;
|
|
11
|
+
pos?: number;
|
|
12
|
+
showOnEmptyParagraph?: boolean;
|
|
13
|
+
typedAndDeleted?: boolean;
|
|
14
|
+
userHadTyped?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export type CreatePlaceholderStateProps = {
|
|
17
|
+
bracketPlaceholderText?: string;
|
|
18
|
+
defaultPlaceholderText: string | undefined;
|
|
19
|
+
editorState: EditorState;
|
|
20
|
+
emptyLinePlaceholder?: string;
|
|
21
|
+
intl: IntlShape;
|
|
22
|
+
isEditorFocused: boolean;
|
|
23
|
+
isInitial?: boolean;
|
|
24
|
+
isPlaceholderHidden?: boolean;
|
|
25
|
+
isTypeAheadOpen: ((editorState: EditorState) => boolean) | undefined;
|
|
26
|
+
placeholderADF?: DocNode;
|
|
27
|
+
placeholderPrompts?: string[];
|
|
28
|
+
showOnEmptyParagraph?: boolean;
|
|
29
|
+
typedAndDeleted?: boolean;
|
|
30
|
+
userHadTyped?: boolean;
|
|
31
|
+
withEmptyParagraph?: boolean;
|
|
32
|
+
};
|
|
33
|
+
export type UserInteractionState = {
|
|
34
|
+
newEditorState: EditorState;
|
|
35
|
+
oldEditorState?: EditorState;
|
|
36
|
+
placeholderState?: PlaceHolderState;
|
|
37
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { DocNode } from '@atlaskit/adf-schema';
|
|
2
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { PlaceHolderState, CreatePlaceholderStateProps, UserInteractionState } from './types';
|
|
4
|
+
export declare function getPlaceholderState(editorState: EditorState): PlaceHolderState;
|
|
5
|
+
export declare function setPlaceHolderState({ placeholderText, pos, placeholderPrompts, typedAndDeleted, userHadTyped, canShowOnEmptyParagraph, showOnEmptyParagraph, contextPlaceholderADF, }: {
|
|
6
|
+
canShowOnEmptyParagraph?: boolean;
|
|
7
|
+
contextPlaceholderADF?: DocNode;
|
|
8
|
+
placeholderPrompts?: string[];
|
|
9
|
+
placeholderText?: string;
|
|
10
|
+
pos?: number;
|
|
11
|
+
showOnEmptyParagraph?: boolean;
|
|
12
|
+
typedAndDeleted?: boolean;
|
|
13
|
+
userHadTyped?: boolean;
|
|
14
|
+
}): PlaceHolderState;
|
|
15
|
+
export declare const emptyPlaceholder: ({ placeholderText, placeholderPrompts, userHadTyped, pos, canShowOnEmptyParagraph, showOnEmptyParagraph, }: {
|
|
16
|
+
canShowOnEmptyParagraph?: boolean;
|
|
17
|
+
placeholderPrompts?: string[];
|
|
18
|
+
placeholderText: string | undefined;
|
|
19
|
+
pos?: number;
|
|
20
|
+
showOnEmptyParagraph?: boolean;
|
|
21
|
+
userHadTyped?: boolean;
|
|
22
|
+
}) => PlaceHolderState;
|
|
23
|
+
export declare function createPlaceHolderStateFrom({ isInitial, isEditorFocused, editorState, isTypeAheadOpen, defaultPlaceholderText, intl, bracketPlaceholderText, emptyLinePlaceholder, placeholderADF, placeholderPrompts, typedAndDeleted, userHadTyped, isPlaceholderHidden, withEmptyParagraph, showOnEmptyParagraph, }: CreatePlaceholderStateProps): PlaceHolderState;
|
|
24
|
+
export declare function calculateUserInteractionState({ placeholderState, oldEditorState, newEditorState, }: UserInteractionState): {
|
|
25
|
+
typedAndDeleted: boolean;
|
|
26
|
+
userHadTyped: boolean;
|
|
27
|
+
};
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
import type { IntlShape } from 'react-intl-next';
|
|
2
|
-
import type { DocNode } from '@atlaskit/adf-schema';
|
|
3
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
-
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
|
-
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
6
1
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
-
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
8
2
|
import type { PlaceholderPlugin } from './placeholderPluginType';
|
|
9
3
|
export declare const EMPTY_PARAGRAPH_TIMEOUT_DELAY = 2000;
|
|
10
4
|
export declare const pluginKey: PluginKey<any>;
|
|
11
|
-
export declare function createPlaceholderDecoration(editorState: EditorState, placeholderText: string, placeholderPrompts?: string[], activeTypewriterTimeouts?: (() => void)[], pos?: number, initialDelayWhenUserTypedAndDeleted?: number, placeholderADF?: DocNode): DecorationSet;
|
|
12
|
-
export declare function createPlugin(intl: IntlShape, defaultPlaceholderText?: string, bracketPlaceholderText?: string, emptyLinePlaceholder?: string, placeholderPrompts?: string[], withEmptyParagraph?: boolean, placeholderADF?: DocNode, api?: ExtractInjectionAPI<PlaceholderPlugin>): SafePlugin | undefined;
|
|
13
5
|
export declare const placeholderPlugin: PlaceholderPlugin;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { DocNode } from '@atlaskit/adf-schema';
|
|
3
|
+
export declare const createShortEmptyNodePlaceholderADF: ({ formatMessage }: IntlShape) => DocNode;
|
|
4
|
+
export declare const createLongEmptyNodePlaceholderADF: ({ formatMessage }: IntlShape) => DocNode;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const cycleThroughPlaceholderPrompts: (placeholderPrompts: string[], activeTypewriterTimeouts: (() => void)[] | undefined, placeholderNodeWithText: HTMLElement, initialDelayWhenUserTypedAndDeleted?: number) => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const placeholderTestId = "placeholder-test-id";
|
|
2
|
+
export declare const TYPEWRITER_TYPE_DELAY = 50;
|
|
3
|
+
export declare const TYPEWRITER_PAUSE_BEFORE_ERASE = 2000;
|
|
4
|
+
export declare const TYPEWRITER_ERASE_DELAY = 40;
|
|
5
|
+
export declare const TYPEWRITER_CYCLE_DELAY = 500;
|
|
6
|
+
export declare const TYPEWRITER_TYPED_AND_DELETED_DELAY = 1500;
|
|
7
|
+
export declare const nodeTypesWithLongPlaceholderText: string[];
|
|
8
|
+
export declare const nodeTypesWithShortPlaceholderText: string[];
|
|
9
|
+
export declare const nodeTypesWithSyncBlockPlaceholderText: string[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DocNode } from '@atlaskit/adf-schema';
|
|
2
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
export declare function createPlaceholderDecoration(editorState: EditorState, placeholderText: string, placeholderPrompts?: string[], activeTypewriterTimeouts?: (() => void)[], pos?: number, initialDelayWhenUserTypedAndDeleted?: number, placeholderADF?: DocNode): DecorationSet;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { DocNode } from '@atlaskit/adf-schema';
|
|
3
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
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, placeholderADF?: DocNode, api?: ExtractInjectionAPI<PlaceholderPlugin>): SafePlugin | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { DocNode } from '@atlaskit/adf-schema';
|
|
3
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
8
|
+
import type { PlaceholderPlugin } from '../placeholderPluginType';
|
|
9
|
+
export declare const EMPTY_PARAGRAPH_TIMEOUT_DELAY = 2000;
|
|
10
|
+
export declare const pluginKey: PluginKey<any>;
|
|
11
|
+
export declare function createPlaceholderDecoration(editorState: EditorState, placeholderText: string, placeholderPrompts?: string[], activeTypewriterTimeouts?: (() => void)[], pos?: number, initialDelayWhenUserTypedAndDeleted?: number, placeholderADF?: DocNode): DecorationSet;
|
|
12
|
+
export declare function createPlugin(intl: IntlShape, defaultPlaceholderText?: string, bracketPlaceholderText?: string, emptyLinePlaceholder?: string, placeholderPrompts?: string[], withEmptyParagraph?: boolean, placeholderADF?: DocNode, api?: ExtractInjectionAPI<PlaceholderPlugin>): SafePlugin | undefined;
|
|
13
|
+
export declare const placeholderPluginLegacy: PlaceholderPlugin;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { DocNode } from '@atlaskit/adf-schema';
|
|
3
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
export interface PlaceHolderState {
|
|
5
|
+
canShowOnEmptyParagraph?: boolean;
|
|
6
|
+
contextPlaceholderADF?: DocNode;
|
|
7
|
+
hasPlaceholder: boolean;
|
|
8
|
+
isPlaceholderHidden?: boolean;
|
|
9
|
+
placeholderPrompts?: string[];
|
|
10
|
+
placeholderText?: string;
|
|
11
|
+
pos?: number;
|
|
12
|
+
showOnEmptyParagraph?: boolean;
|
|
13
|
+
typedAndDeleted?: boolean;
|
|
14
|
+
userHadTyped?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export type CreatePlaceholderStateProps = {
|
|
17
|
+
bracketPlaceholderText?: string;
|
|
18
|
+
defaultPlaceholderText: string | undefined;
|
|
19
|
+
editorState: EditorState;
|
|
20
|
+
emptyLinePlaceholder?: string;
|
|
21
|
+
intl: IntlShape;
|
|
22
|
+
isEditorFocused: boolean;
|
|
23
|
+
isInitial?: boolean;
|
|
24
|
+
isPlaceholderHidden?: boolean;
|
|
25
|
+
isTypeAheadOpen: ((editorState: EditorState) => boolean) | undefined;
|
|
26
|
+
placeholderADF?: DocNode;
|
|
27
|
+
placeholderPrompts?: string[];
|
|
28
|
+
showOnEmptyParagraph?: boolean;
|
|
29
|
+
typedAndDeleted?: boolean;
|
|
30
|
+
userHadTyped?: boolean;
|
|
31
|
+
withEmptyParagraph?: boolean;
|
|
32
|
+
};
|
|
33
|
+
export type UserInteractionState = {
|
|
34
|
+
newEditorState: EditorState;
|
|
35
|
+
oldEditorState?: EditorState;
|
|
36
|
+
placeholderState?: PlaceHolderState;
|
|
37
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { DocNode } from '@atlaskit/adf-schema';
|
|
2
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { PlaceHolderState, CreatePlaceholderStateProps, UserInteractionState } from './types';
|
|
4
|
+
export declare function getPlaceholderState(editorState: EditorState): PlaceHolderState;
|
|
5
|
+
export declare function setPlaceHolderState({ placeholderText, pos, placeholderPrompts, typedAndDeleted, userHadTyped, canShowOnEmptyParagraph, showOnEmptyParagraph, contextPlaceholderADF, }: {
|
|
6
|
+
canShowOnEmptyParagraph?: boolean;
|
|
7
|
+
contextPlaceholderADF?: DocNode;
|
|
8
|
+
placeholderPrompts?: string[];
|
|
9
|
+
placeholderText?: string;
|
|
10
|
+
pos?: number;
|
|
11
|
+
showOnEmptyParagraph?: boolean;
|
|
12
|
+
typedAndDeleted?: boolean;
|
|
13
|
+
userHadTyped?: boolean;
|
|
14
|
+
}): PlaceHolderState;
|
|
15
|
+
export declare const emptyPlaceholder: ({ placeholderText, placeholderPrompts, userHadTyped, pos, canShowOnEmptyParagraph, showOnEmptyParagraph, }: {
|
|
16
|
+
canShowOnEmptyParagraph?: boolean;
|
|
17
|
+
placeholderPrompts?: string[];
|
|
18
|
+
placeholderText: string | undefined;
|
|
19
|
+
pos?: number;
|
|
20
|
+
showOnEmptyParagraph?: boolean;
|
|
21
|
+
userHadTyped?: boolean;
|
|
22
|
+
}) => PlaceHolderState;
|
|
23
|
+
export declare function createPlaceHolderStateFrom({ isInitial, isEditorFocused, editorState, isTypeAheadOpen, defaultPlaceholderText, intl, bracketPlaceholderText, emptyLinePlaceholder, placeholderADF, placeholderPrompts, typedAndDeleted, userHadTyped, isPlaceholderHidden, withEmptyParagraph, showOnEmptyParagraph, }: CreatePlaceholderStateProps): PlaceHolderState;
|
|
24
|
+
export declare function calculateUserInteractionState({ placeholderState, oldEditorState, newEditorState, }: UserInteractionState): {
|
|
25
|
+
typedAndDeleted: boolean;
|
|
26
|
+
userHadTyped: boolean;
|
|
27
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-placeholder",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.6.1",
|
|
4
4
|
"description": "Placeholder plugin for @atlaskit/editor-core.",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -30,16 +30,16 @@
|
|
|
30
30
|
"@atlaskit/adf-utils": "^19.26.0",
|
|
31
31
|
"@atlaskit/editor-plugin-composition": "^5.0.0",
|
|
32
32
|
"@atlaskit/editor-plugin-focus": "^5.0.0",
|
|
33
|
-
"@atlaskit/editor-plugin-show-diff": "^3.
|
|
33
|
+
"@atlaskit/editor-plugin-show-diff": "^3.3.0",
|
|
34
34
|
"@atlaskit/editor-plugin-type-ahead": "^6.5.0",
|
|
35
35
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
36
36
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
37
|
-
"@atlaskit/tmp-editor-statsig": "^14.
|
|
37
|
+
"@atlaskit/tmp-editor-statsig": "^14.8.0",
|
|
38
38
|
"@atlaskit/tokens": "^8.4.0",
|
|
39
39
|
"@babel/runtime": "^7.0.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@atlaskit/editor-common": "^110.
|
|
42
|
+
"@atlaskit/editor-common": "^110.40.0",
|
|
43
43
|
"react": "^18.2.0",
|
|
44
44
|
"react-dom": "^18.2.0",
|
|
45
45
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
@@ -48,13 +48,10 @@
|
|
|
48
48
|
"@testing-library/react": "^13.4.0"
|
|
49
49
|
},
|
|
50
50
|
"platform-feature-flags": {
|
|
51
|
-
"
|
|
52
|
-
"type": "boolean"
|
|
53
|
-
},
|
|
54
|
-
"platform_editor_ai_aifc_patch_beta_2": {
|
|
51
|
+
"platform_editor_ai_aifc_patch_ga": {
|
|
55
52
|
"type": "boolean"
|
|
56
53
|
},
|
|
57
|
-
"
|
|
54
|
+
"platform_editor_placeholder_plugin_tidying": {
|
|
58
55
|
"type": "boolean"
|
|
59
56
|
}
|
|
60
57
|
},
|