@atlaskit/editor-plugin-placeholder 6.5.4 → 6.6.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 +7 -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 +167 -0
- package/dist/cjs/pm-plugins/placeholderPluginLegacy.js +616 -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 +161 -0
- package/dist/es2019/pm-plugins/placeholderPluginLegacy.js +597 -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 +161 -0
- package/dist/esm/pm-plugins/placeholderPluginLegacy.js +606 -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 +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-placeholder
|
|
2
2
|
|
|
3
|
+
## 6.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`a3a576969a12c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a3a576969a12c) -
|
|
8
|
+
[No-issue] placeholder plugin tidying
|
|
9
|
+
|
|
3
10
|
## 6.5.4
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -4,579 +4,30 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.EMPTY_PARAGRAPH_TIMEOUT_DELAY = void 0;
|
|
8
|
-
exports.createPlaceholderDecoration = createPlaceholderDecoration;
|
|
9
|
-
exports.createPlugin = createPlugin;
|
|
10
|
-
exports.pluginKey = exports.placeholderPlugin = void 0;
|
|
11
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
-
var _builders = require("@atlaskit/adf-utils/builders");
|
|
13
|
-
var _messages = require("@atlaskit/editor-common/messages");
|
|
14
|
-
var _processRawValue = require("@atlaskit/editor-common/process-raw-value");
|
|
15
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
16
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
17
|
-
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
7
|
+
exports.pluginKey = exports.placeholderPlugin = exports.EMPTY_PARAGRAPH_TIMEOUT_DELAY = void 0;
|
|
18
8
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
19
|
-
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
20
|
-
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
21
9
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
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; }
|
|
25
|
-
// Typewriter animation timing constants
|
|
26
|
-
var TYPEWRITER_TYPE_DELAY = 50; // Delay between typing each character
|
|
27
|
-
var TYPEWRITER_PAUSE_BEFORE_ERASE = 2000; // Pause before starting to erase text
|
|
28
|
-
var TYPEWRITER_ERASE_DELAY = 40; // Delay between erasing each character
|
|
29
|
-
var TYPEWRITER_CYCLE_DELAY = 500; // Delay before starting next cycle
|
|
30
|
-
var TYPEWRITER_TYPED_AND_DELETED_DELAY = 1500; // Delay before starting animation after user typed and deleted
|
|
31
|
-
|
|
10
|
+
var _main = _interopRequireDefault(require("./pm-plugins/main"));
|
|
11
|
+
var _placeholderPluginLegacy = require("./pm-plugins/placeholderPluginLegacy");
|
|
32
12
|
var EMPTY_PARAGRAPH_TIMEOUT_DELAY = exports.EMPTY_PARAGRAPH_TIMEOUT_DELAY = 2000; // Delay before showing placeholder on empty paragraph
|
|
33
13
|
|
|
34
14
|
var pluginKey = exports.pluginKey = new _state.PluginKey('placeholderPlugin');
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var createShortEmptyNodePlaceholderADF = function createShortEmptyNodePlaceholderADF(_ref) {
|
|
43
|
-
var formatMessage = _ref.formatMessage;
|
|
44
|
-
return {
|
|
45
|
-
version: 1,
|
|
46
|
-
type: 'doc',
|
|
47
|
-
content: [{
|
|
48
|
-
type: 'paragraph',
|
|
49
|
-
content: [(0, _builders.code)(formatMessage(_messages.placeholderTextMessages.shortEmptyNodePlaceholderADFSlashShortcut)), (0, _builders.text)(' '), (0, _builders.text)(formatMessage(_messages.placeholderTextMessages.shortEmptyNodePlaceholderADFSuffix))]
|
|
50
|
-
}]
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
var createLongEmptyNodePlaceholderADF = function createLongEmptyNodePlaceholderADF(_ref2) {
|
|
54
|
-
var formatMessage = _ref2.formatMessage;
|
|
55
|
-
return {
|
|
56
|
-
version: 1,
|
|
57
|
-
type: 'doc',
|
|
58
|
-
content: [{
|
|
59
|
-
type: 'paragraph',
|
|
60
|
-
content: [(0, _builders.text)(formatMessage(_messages.placeholderTextMessages.longEmptyNodePlaceholderADFPrefix)), (0, _builders.text)(' '), (0, _builders.code)(formatMessage(_messages.placeholderTextMessages.longEmptyNodePlaceholderADFSlashShortcut)), (0, _builders.text)(' '), (0, _builders.text)(formatMessage(_messages.placeholderTextMessages.longEmptyNodePlaceholderADFSuffix))]
|
|
61
|
-
}]
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
var cycleThroughPlaceholderPrompts = function cycleThroughPlaceholderPrompts(placeholderPrompts, activeTypewriterTimeouts, placeholderNodeWithText) {
|
|
65
|
-
var initialDelayWhenUserTypedAndDeleted = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
66
|
-
var currentPromptIndex = 0;
|
|
67
|
-
var displayedText = '';
|
|
68
|
-
var animationTimeouts = [];
|
|
69
|
-
var clearAllTimeouts = function clearAllTimeouts() {
|
|
70
|
-
animationTimeouts.forEach(function (timeoutId) {
|
|
71
|
-
return clearTimeout(timeoutId);
|
|
72
|
-
});
|
|
73
|
-
animationTimeouts = [];
|
|
74
|
-
};
|
|
75
|
-
var scheduleTimeout = function scheduleTimeout(callback, delay) {
|
|
76
|
-
var timeoutId = setTimeout(callback, delay);
|
|
77
|
-
animationTimeouts.push(timeoutId);
|
|
78
|
-
return timeoutId;
|
|
79
|
-
};
|
|
80
|
-
var _startAnimationCycle = function startAnimationCycle() {
|
|
81
|
-
var currentPrompt = placeholderPrompts[currentPromptIndex];
|
|
82
|
-
var characterIndex = 0;
|
|
83
|
-
var _typeNextCharacter = function typeNextCharacter() {
|
|
84
|
-
if (characterIndex < currentPrompt.length) {
|
|
85
|
-
displayedText = currentPrompt.substring(0, characterIndex + 1);
|
|
86
|
-
placeholderNodeWithText.textContent = displayedText;
|
|
87
|
-
characterIndex++;
|
|
88
|
-
scheduleTimeout(_typeNextCharacter, TYPEWRITER_TYPE_DELAY);
|
|
89
|
-
} else {
|
|
90
|
-
scheduleTimeout(_eraseLastCharacter, TYPEWRITER_PAUSE_BEFORE_ERASE);
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
var _eraseLastCharacter = function eraseLastCharacter() {
|
|
94
|
-
if (displayedText.length > 1) {
|
|
95
|
-
displayedText = displayedText.substring(0, displayedText.length - 1);
|
|
96
|
-
placeholderNodeWithText.textContent = displayedText;
|
|
97
|
-
scheduleTimeout(_eraseLastCharacter, TYPEWRITER_ERASE_DELAY);
|
|
98
|
-
} else {
|
|
99
|
-
displayedText = ' ';
|
|
100
|
-
placeholderNodeWithText.textContent = displayedText;
|
|
101
|
-
currentPromptIndex = (currentPromptIndex + 1) % placeholderPrompts.length;
|
|
102
|
-
scheduleTimeout(_startAnimationCycle, TYPEWRITER_CYCLE_DELAY);
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
_typeNextCharacter();
|
|
106
|
-
};
|
|
107
|
-
activeTypewriterTimeouts === null || activeTypewriterTimeouts === void 0 || activeTypewriterTimeouts.push(clearAllTimeouts);
|
|
108
|
-
if (initialDelayWhenUserTypedAndDeleted > 0) {
|
|
109
|
-
placeholderNodeWithText.textContent = ' ';
|
|
110
|
-
scheduleTimeout(_startAnimationCycle, initialDelayWhenUserTypedAndDeleted);
|
|
111
|
-
} else {
|
|
112
|
-
_startAnimationCycle();
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
function createPlaceholderDecoration(editorState, placeholderText, placeholderPrompts, activeTypewriterTimeouts) {
|
|
116
|
-
var pos = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
|
|
117
|
-
var initialDelayWhenUserTypedAndDeleted = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
|
118
|
-
var placeholderADF = arguments.length > 6 ? arguments[6] : undefined;
|
|
119
|
-
var placeholderDecoration = document.createElement('span');
|
|
120
|
-
var placeholderNodeWithText = placeholderDecoration;
|
|
121
|
-
placeholderDecoration.setAttribute('data-testid', placeholderTestId);
|
|
122
|
-
placeholderDecoration.className = 'placeholder-decoration';
|
|
123
|
-
placeholderDecoration.setAttribute('aria-hidden', 'true');
|
|
124
|
-
|
|
125
|
-
// PM sets contenteditable to false on Decorations so Firefox doesn't display the flashing cursor
|
|
126
|
-
// So adding an extra span which will contain the placeholder text
|
|
127
|
-
if (_utils.browser.gecko) {
|
|
128
|
-
var placeholderNode = document.createElement('span');
|
|
129
|
-
placeholderNode.setAttribute('contenteditable', 'true'); // explicitly overriding the default Decoration behaviour
|
|
130
|
-
placeholderDecoration.appendChild(placeholderNode);
|
|
131
|
-
placeholderNodeWithText = placeholderNode;
|
|
132
|
-
}
|
|
133
|
-
if (placeholderText) {
|
|
134
|
-
placeholderNodeWithText.textContent = placeholderText || ' ';
|
|
135
|
-
} else if (placeholderADF) {
|
|
136
|
-
var serializer = _model.DOMSerializer.fromSchema(editorState.schema);
|
|
137
|
-
// Get a PMNode from docnode
|
|
138
|
-
var docNode = (0, _processRawValue.processRawValue)(editorState.schema, placeholderADF);
|
|
139
|
-
if (docNode) {
|
|
140
|
-
// Extract only the inline content from paragraphs, avoiding block-level elements
|
|
141
|
-
// that can interfere with cursor rendering
|
|
142
|
-
docNode.children.forEach(function (node) {
|
|
143
|
-
// For paragraph nodes, serialize their content (inline elements) directly
|
|
144
|
-
// without the wrapping <p> tag
|
|
145
|
-
if (node.type.name === 'paragraph') {
|
|
146
|
-
node.content.forEach(function (inlineNode) {
|
|
147
|
-
var inlineDOM = serializer.serializeNode(inlineNode);
|
|
148
|
-
placeholderNodeWithText.append(inlineDOM);
|
|
149
|
-
});
|
|
150
|
-
} else {
|
|
151
|
-
// For non-paragraph nodes, serialize normally
|
|
152
|
-
var nodeDOM = serializer.serializeNode(node);
|
|
153
|
-
placeholderNodeWithText.append(nodeDOM);
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
var markElements = placeholderNodeWithText.querySelectorAll('[data-prosemirror-content-type="mark"]');
|
|
157
|
-
markElements.forEach(function (markEl) {
|
|
158
|
-
if (markEl instanceof HTMLElement) {
|
|
159
|
-
markEl.style.setProperty('color', "var(--ds-text-subtlest, #6B6E76)");
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
// Ensure all child elements don't block pointer events or cursor
|
|
163
|
-
var allElements = placeholderNodeWithText.querySelectorAll('*');
|
|
164
|
-
allElements.forEach(function (el) {
|
|
165
|
-
if (el instanceof HTMLElement) {
|
|
166
|
-
el.style.pointerEvents = 'none';
|
|
167
|
-
el.style.userSelect = 'none';
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
} else if (placeholderPrompts) {
|
|
172
|
-
cycleThroughPlaceholderPrompts(placeholderPrompts, activeTypewriterTimeouts, placeholderNodeWithText, initialDelayWhenUserTypedAndDeleted);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// ME-2289 Tapping on backspace in empty editor hides and displays the keyboard
|
|
176
|
-
// Add a editable buff node as the cursor moving forward is inevitable
|
|
177
|
-
// when backspace in GBoard composition
|
|
178
|
-
if (_utils.browser.android && _utils.browser.chrome) {
|
|
179
|
-
var buffNode = document.createElement('span');
|
|
180
|
-
buffNode.setAttribute('class', 'placeholder-android');
|
|
181
|
-
buffNode.setAttribute('contenteditable', 'true');
|
|
182
|
-
buffNode.textContent = ' ';
|
|
183
|
-
placeholderDecoration.appendChild(buffNode);
|
|
184
|
-
}
|
|
185
|
-
var isTargetNested = editorState.doc.resolve(pos).depth > 1;
|
|
186
|
-
|
|
187
|
-
// only truncate text for nested nodes, otherwise applying 'overflow: hidden;' to top level nodes
|
|
188
|
-
// creates issues with quick insert button
|
|
189
|
-
if (isTargetNested && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
190
|
-
placeholderDecoration.classList.add('placeholder-decoration-hide-overflow');
|
|
191
|
-
}
|
|
192
|
-
return _view.DecorationSet.create(editorState.doc, [_view.Decoration.widget(pos, placeholderDecoration, {
|
|
193
|
-
side: 0,
|
|
194
|
-
key: "placeholder ".concat(placeholderText)
|
|
195
|
-
})]);
|
|
196
|
-
}
|
|
197
|
-
function setPlaceHolderState(_ref3) {
|
|
198
|
-
var placeholderText = _ref3.placeholderText,
|
|
199
|
-
pos = _ref3.pos,
|
|
200
|
-
placeholderPrompts = _ref3.placeholderPrompts,
|
|
201
|
-
typedAndDeleted = _ref3.typedAndDeleted,
|
|
202
|
-
userHadTyped = _ref3.userHadTyped,
|
|
203
|
-
canShowOnEmptyParagraph = _ref3.canShowOnEmptyParagraph,
|
|
204
|
-
showOnEmptyParagraph = _ref3.showOnEmptyParagraph,
|
|
205
|
-
contextPlaceholderADF = _ref3.contextPlaceholderADF;
|
|
206
|
-
return {
|
|
207
|
-
hasPlaceholder: true,
|
|
208
|
-
placeholderText: placeholderText,
|
|
209
|
-
placeholderPrompts: placeholderPrompts,
|
|
210
|
-
contextPlaceholderADF: contextPlaceholderADF,
|
|
211
|
-
pos: pos ? pos : 1,
|
|
212
|
-
typedAndDeleted: typedAndDeleted,
|
|
213
|
-
userHadTyped: userHadTyped,
|
|
214
|
-
canShowOnEmptyParagraph: canShowOnEmptyParagraph,
|
|
215
|
-
showOnEmptyParagraph: showOnEmptyParagraph
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
var emptyPlaceholder = function emptyPlaceholder(_ref4) {
|
|
219
|
-
var placeholderText = _ref4.placeholderText,
|
|
220
|
-
placeholderPrompts = _ref4.placeholderPrompts,
|
|
221
|
-
userHadTyped = _ref4.userHadTyped,
|
|
222
|
-
pos = _ref4.pos,
|
|
223
|
-
canShowOnEmptyParagraph = _ref4.canShowOnEmptyParagraph,
|
|
224
|
-
showOnEmptyParagraph = _ref4.showOnEmptyParagraph;
|
|
225
|
-
return {
|
|
226
|
-
hasPlaceholder: false,
|
|
227
|
-
placeholderText: placeholderText,
|
|
228
|
-
placeholderPrompts: placeholderPrompts,
|
|
229
|
-
userHadTyped: userHadTyped,
|
|
230
|
-
typedAndDeleted: false,
|
|
231
|
-
canShowOnEmptyParagraph: canShowOnEmptyParagraph,
|
|
232
|
-
showOnEmptyParagraph: showOnEmptyParagraph,
|
|
233
|
-
pos: pos
|
|
234
|
-
};
|
|
235
|
-
};
|
|
236
|
-
function createPlaceHolderStateFrom(_ref5) {
|
|
237
|
-
var isInitial = _ref5.isInitial,
|
|
238
|
-
isEditorFocused = _ref5.isEditorFocused,
|
|
239
|
-
editorState = _ref5.editorState,
|
|
240
|
-
isTypeAheadOpen = _ref5.isTypeAheadOpen,
|
|
241
|
-
defaultPlaceholderText = _ref5.defaultPlaceholderText,
|
|
242
|
-
intl = _ref5.intl,
|
|
243
|
-
bracketPlaceholderText = _ref5.bracketPlaceholderText,
|
|
244
|
-
emptyLinePlaceholder = _ref5.emptyLinePlaceholder,
|
|
245
|
-
placeholderADF = _ref5.placeholderADF,
|
|
246
|
-
placeholderPrompts = _ref5.placeholderPrompts,
|
|
247
|
-
typedAndDeleted = _ref5.typedAndDeleted,
|
|
248
|
-
userHadTyped = _ref5.userHadTyped,
|
|
249
|
-
isPlaceholderHidden = _ref5.isPlaceholderHidden,
|
|
250
|
-
withEmptyParagraph = _ref5.withEmptyParagraph,
|
|
251
|
-
showOnEmptyParagraph = _ref5.showOnEmptyParagraph;
|
|
252
|
-
if (isPlaceholderHidden && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_beta')) {
|
|
253
|
-
return _objectSpread(_objectSpread({}, emptyPlaceholder({
|
|
254
|
-
placeholderText: defaultPlaceholderText,
|
|
255
|
-
placeholderPrompts: placeholderPrompts,
|
|
256
|
-
userHadTyped: userHadTyped
|
|
257
|
-
})), {}, {
|
|
258
|
-
isPlaceholderHidden: isPlaceholderHidden
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
if (isTypeAheadOpen !== null && isTypeAheadOpen !== void 0 && isTypeAheadOpen(editorState)) {
|
|
262
|
-
return emptyPlaceholder({
|
|
263
|
-
placeholderText: defaultPlaceholderText,
|
|
264
|
-
placeholderPrompts: placeholderPrompts,
|
|
265
|
-
userHadTyped: userHadTyped
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
if ((defaultPlaceholderText || placeholderPrompts || placeholderADF) && (0, _utils.isEmptyDocument)(editorState.doc)) {
|
|
269
|
-
return setPlaceHolderState({
|
|
270
|
-
placeholderText: defaultPlaceholderText,
|
|
271
|
-
pos: 1,
|
|
272
|
-
placeholderPrompts: placeholderPrompts,
|
|
273
|
-
typedAndDeleted: typedAndDeleted,
|
|
274
|
-
userHadTyped: userHadTyped
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
if ((0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_beta_2') || (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga')) {
|
|
278
|
-
var _editorState$selectio = editorState.selection,
|
|
279
|
-
from = _editorState$selectio.from,
|
|
280
|
-
to = _editorState$selectio.to,
|
|
281
|
-
$to = _editorState$selectio.$to;
|
|
282
|
-
if ((defaultPlaceholderText || placeholderADF) && withEmptyParagraph && isEditorFocused && !isInitial && !(0, _utils.isEmptyDocument)(editorState.doc) && from === to && (0, _utils.isEmptyParagraph)($to.parent) && (0, _utils.hasDocAsParent)($to)) {
|
|
283
|
-
return showOnEmptyParagraph ? setPlaceHolderState({
|
|
284
|
-
placeholderText: defaultPlaceholderText,
|
|
285
|
-
pos: to,
|
|
286
|
-
placeholderPrompts: placeholderPrompts,
|
|
287
|
-
typedAndDeleted: typedAndDeleted,
|
|
288
|
-
userHadTyped: userHadTyped,
|
|
289
|
-
canShowOnEmptyParagraph: true,
|
|
290
|
-
showOnEmptyParagraph: true
|
|
291
|
-
}) : emptyPlaceholder({
|
|
292
|
-
placeholderText: defaultPlaceholderText,
|
|
293
|
-
placeholderPrompts: placeholderPrompts,
|
|
294
|
-
userHadTyped: userHadTyped,
|
|
295
|
-
canShowOnEmptyParagraph: true,
|
|
296
|
-
showOnEmptyParagraph: false,
|
|
297
|
-
pos: to
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
if (isEditorFocused && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
302
|
-
var _parentNode$firstChil, _parentNode$firstChil2;
|
|
303
|
-
var _editorState$selectio2 = editorState.selection,
|
|
304
|
-
$from = _editorState$selectio2.$from,
|
|
305
|
-
_$to = _editorState$selectio2.$to;
|
|
306
|
-
if ($from.pos !== _$to.pos) {
|
|
307
|
-
return emptyPlaceholder({
|
|
308
|
-
placeholderText: defaultPlaceholderText,
|
|
309
|
-
placeholderPrompts: placeholderPrompts,
|
|
310
|
-
userHadTyped: userHadTyped
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
var parentNode = $from.node($from.depth - 1);
|
|
314
|
-
var parentType = parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name;
|
|
315
|
-
if (emptyLinePlaceholder && parentType === 'doc') {
|
|
316
|
-
var isEmptyLine = (0, _utils.isEmptyParagraph)($from.parent);
|
|
317
|
-
if (isEmptyLine) {
|
|
318
|
-
return setPlaceHolderState({
|
|
319
|
-
placeholderText: emptyLinePlaceholder,
|
|
320
|
-
pos: $from.pos,
|
|
321
|
-
placeholderPrompts: placeholderPrompts,
|
|
322
|
-
typedAndDeleted: typedAndDeleted,
|
|
323
|
-
userHadTyped: userHadTyped
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
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';
|
|
328
|
-
if (nodeTypesWithShortPlaceholderText.includes(parentType) && isEmptyNode) {
|
|
329
|
-
var _table$node$firstChil;
|
|
330
|
-
var table = (0, _utils2.findParentNode)(function (node) {
|
|
331
|
-
return node.type === editorState.schema.nodes.table;
|
|
332
|
-
})(editorState.selection);
|
|
333
|
-
if (!table) {
|
|
334
|
-
return emptyPlaceholder({
|
|
335
|
-
placeholderText: defaultPlaceholderText,
|
|
336
|
-
placeholderPrompts: placeholderPrompts,
|
|
337
|
-
userHadTyped: userHadTyped
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
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;
|
|
341
|
-
if (isFirstCell) {
|
|
342
|
-
return setPlaceHolderState({
|
|
343
|
-
placeholderText: !(0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga') ? intl.formatMessage(_messages.placeholderTextMessages.shortEmptyNodePlaceholderText) : undefined,
|
|
344
|
-
contextPlaceholderADF: (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga') ? createShortEmptyNodePlaceholderADF(intl) : undefined,
|
|
345
|
-
pos: $from.pos,
|
|
346
|
-
placeholderPrompts: placeholderPrompts,
|
|
347
|
-
typedAndDeleted: typedAndDeleted,
|
|
348
|
-
userHadTyped: userHadTyped
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
if (nodeTypesWithLongPlaceholderText.includes(parentType) && isEmptyNode) {
|
|
353
|
-
return setPlaceHolderState({
|
|
354
|
-
placeholderText: !(0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga') ? intl.formatMessage(_messages.placeholderTextMessages.longEmptyNodePlaceholderText) : undefined,
|
|
355
|
-
contextPlaceholderADF: (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga') ? createLongEmptyNodePlaceholderADF(intl) : undefined,
|
|
356
|
-
pos: $from.pos,
|
|
357
|
-
placeholderPrompts: placeholderPrompts,
|
|
358
|
-
typedAndDeleted: typedAndDeleted,
|
|
359
|
-
userHadTyped: userHadTyped
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
if (nodeTypesWithSyncBlockPlaceholderText.includes(parentType) && isEmptyNode && (0, _experiments.editorExperiment)('platform_synced_block', true)) {
|
|
363
|
-
return setPlaceHolderState({
|
|
364
|
-
placeholderText: intl.formatMessage(_messages.placeholderTextMessages.syncBlockPlaceholderText),
|
|
365
|
-
pos: $from.pos,
|
|
366
|
-
placeholderPrompts: placeholderPrompts,
|
|
367
|
-
typedAndDeleted: typedAndDeleted,
|
|
368
|
-
userHadTyped: userHadTyped
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
return emptyPlaceholder({
|
|
372
|
-
placeholderText: defaultPlaceholderText,
|
|
373
|
-
placeholderPrompts: placeholderPrompts,
|
|
374
|
-
userHadTyped: userHadTyped
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
if (bracketPlaceholderText && (0, _utils.bracketTyped)(editorState) && isEditorFocused) {
|
|
378
|
-
var _$from = editorState.selection.$from;
|
|
379
|
-
// Space is to account for positioning of the bracket
|
|
380
|
-
var bracketHint = ' ' + bracketPlaceholderText;
|
|
381
|
-
return setPlaceHolderState({
|
|
382
|
-
placeholderText: bracketHint,
|
|
383
|
-
pos: _$from.pos - 1,
|
|
384
|
-
placeholderPrompts: placeholderPrompts,
|
|
385
|
-
typedAndDeleted: typedAndDeleted,
|
|
386
|
-
userHadTyped: userHadTyped
|
|
15
|
+
var placeholderPlugin = exports.placeholderPlugin = function placeholderPlugin(_ref) {
|
|
16
|
+
var options = _ref.config,
|
|
17
|
+
api = _ref.api;
|
|
18
|
+
if (!(0, _platformFeatureFlags.fg)('platform_editor_placeholder_plugin_tidying')) {
|
|
19
|
+
return (0, _placeholderPluginLegacy.placeholderPluginLegacy)({
|
|
20
|
+
config: options,
|
|
21
|
+
api: api
|
|
387
22
|
});
|
|
388
23
|
}
|
|
389
|
-
return emptyPlaceholder({
|
|
390
|
-
placeholderText: defaultPlaceholderText,
|
|
391
|
-
placeholderPrompts: placeholderPrompts,
|
|
392
|
-
userHadTyped: userHadTyped
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
function calculateUserInteractionState(_ref6) {
|
|
396
|
-
var placeholderState = _ref6.placeholderState,
|
|
397
|
-
oldEditorState = _ref6.oldEditorState,
|
|
398
|
-
newEditorState = _ref6.newEditorState;
|
|
399
|
-
var wasEmpty = oldEditorState ? (0, _utils.isEmptyDocument)(oldEditorState.doc) : true;
|
|
400
|
-
var isEmpty = (0, _utils.isEmptyDocument)(newEditorState.doc);
|
|
401
|
-
var hasEverTyped = Boolean(placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.userHadTyped) ||
|
|
402
|
-
// Previously typed
|
|
403
|
-
!wasEmpty ||
|
|
404
|
-
// Had content before
|
|
405
|
-
wasEmpty && !isEmpty; // Just added content
|
|
406
|
-
var justDeletedAll = hasEverTyped && isEmpty && !wasEmpty;
|
|
407
|
-
var isInTypedAndDeletedState = justDeletedAll || Boolean(placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.typedAndDeleted) && isEmpty;
|
|
408
|
-
// Only reset user interaction tracking when editor is cleanly empty
|
|
409
|
-
var shouldResetInteraction = isEmpty && !isInTypedAndDeletedState;
|
|
410
|
-
return {
|
|
411
|
-
userHadTyped: shouldResetInteraction ? false : hasEverTyped,
|
|
412
|
-
typedAndDeleted: isInTypedAndDeletedState
|
|
413
|
-
};
|
|
414
|
-
}
|
|
415
|
-
function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder, placeholderPrompts, withEmptyParagraph, placeholderADF, api) {
|
|
416
|
-
if (!defaultPlaceholderText && !placeholderPrompts && !bracketPlaceholderText && !placeholderADF) {
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
var isDestroyed = false;
|
|
420
|
-
var activeTypewriterTimeouts = [];
|
|
421
|
-
var clearAllTypewriterTimeouts = function clearAllTypewriterTimeouts() {
|
|
422
|
-
activeTypewriterTimeouts.forEach(function (clearFn) {
|
|
423
|
-
return clearFn();
|
|
424
|
-
});
|
|
425
|
-
activeTypewriterTimeouts = [];
|
|
426
|
-
};
|
|
427
|
-
return new _safePlugin.SafePlugin({
|
|
428
|
-
key: pluginKey,
|
|
429
|
-
state: {
|
|
430
|
-
init: function init(_, state) {
|
|
431
|
-
var _api$focus, _api$typeAhead;
|
|
432
|
-
return createPlaceHolderStateFrom({
|
|
433
|
-
isInitial: true,
|
|
434
|
-
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),
|
|
435
|
-
editorState: state,
|
|
436
|
-
isTypeAheadOpen: api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 ? void 0 : _api$typeAhead.actions.isOpen,
|
|
437
|
-
defaultPlaceholderText: defaultPlaceholderText,
|
|
438
|
-
bracketPlaceholderText: bracketPlaceholderText,
|
|
439
|
-
emptyLinePlaceholder: emptyLinePlaceholder,
|
|
440
|
-
placeholderADF: placeholderADF,
|
|
441
|
-
placeholderPrompts: placeholderPrompts,
|
|
442
|
-
typedAndDeleted: false,
|
|
443
|
-
userHadTyped: false,
|
|
444
|
-
intl: intl
|
|
445
|
-
});
|
|
446
|
-
},
|
|
447
|
-
apply: function apply(tr, placeholderState, _oldEditorState, newEditorState) {
|
|
448
|
-
var _api$focus2, _placeholderState$isP, _api$typeAhead2, _ref7, _meta$placeholderText, _ref8, _meta$placeholderProm, _meta$showOnEmptyPara;
|
|
449
|
-
var meta = tr.getMeta(pluginKey);
|
|
450
|
-
var isEditorFocused = Boolean(api === null || api === void 0 || (_api$focus2 = api.focus) === null || _api$focus2 === void 0 || (_api$focus2 = _api$focus2.sharedState.currentState()) === null || _api$focus2 === void 0 ? void 0 : _api$focus2.hasFocus);
|
|
451
|
-
var _calculateUserInterac = calculateUserInteractionState({
|
|
452
|
-
placeholderState: placeholderState,
|
|
453
|
-
oldEditorState: _oldEditorState,
|
|
454
|
-
newEditorState: newEditorState
|
|
455
|
-
}),
|
|
456
|
-
userHadTyped = _calculateUserInterac.userHadTyped,
|
|
457
|
-
typedAndDeleted = _calculateUserInterac.typedAndDeleted;
|
|
458
|
-
var isPlaceholderHidden = (_placeholderState$isP = placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.isPlaceholderHidden) !== null && _placeholderState$isP !== void 0 ? _placeholderState$isP : false;
|
|
459
|
-
if ((meta === null || meta === void 0 ? void 0 : meta.isPlaceholderHidden) !== undefined && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_beta')) {
|
|
460
|
-
isPlaceholderHidden = meta.isPlaceholderHidden;
|
|
461
|
-
}
|
|
462
|
-
if ((meta === null || meta === void 0 ? void 0 : meta.placeholderText) !== undefined && ((0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_beta_2') || (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga'))) {
|
|
463
|
-
// Only update defaultPlaceholderText from meta if we're not using ADF placeholder
|
|
464
|
-
if (!((0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga') && placeholderADF)) {
|
|
465
|
-
defaultPlaceholderText = meta.placeholderText;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
var newPlaceholderState = createPlaceHolderStateFrom({
|
|
469
|
-
isEditorFocused: isEditorFocused,
|
|
470
|
-
editorState: newEditorState,
|
|
471
|
-
isTypeAheadOpen: api === null || api === void 0 || (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 ? void 0 : _api$typeAhead2.actions.isOpen,
|
|
472
|
-
defaultPlaceholderText: (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_beta_2') || (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga') ? defaultPlaceholderText : (_ref7 = (_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 && _ref7 !== void 0 ? _ref7 : defaultPlaceholderText,
|
|
473
|
-
bracketPlaceholderText: bracketPlaceholderText,
|
|
474
|
-
emptyLinePlaceholder: emptyLinePlaceholder,
|
|
475
|
-
placeholderADF: placeholderADF,
|
|
476
|
-
placeholderPrompts: (_ref8 = (_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 && _ref8 !== void 0 ? _ref8 : placeholderPrompts,
|
|
477
|
-
typedAndDeleted: typedAndDeleted,
|
|
478
|
-
userHadTyped: userHadTyped,
|
|
479
|
-
intl: intl,
|
|
480
|
-
isPlaceholderHidden: isPlaceholderHidden,
|
|
481
|
-
withEmptyParagraph: withEmptyParagraph,
|
|
482
|
-
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
|
|
483
|
-
});
|
|
484
|
-
|
|
485
|
-
// Clear timeouts when hasPlaceholder becomes false
|
|
486
|
-
if (!newPlaceholderState.hasPlaceholder) {
|
|
487
|
-
clearAllTypewriterTimeouts();
|
|
488
|
-
}
|
|
489
|
-
return newPlaceholderState;
|
|
490
|
-
}
|
|
491
|
-
},
|
|
492
|
-
props: {
|
|
493
|
-
decorations: function decorations(editorState) {
|
|
494
|
-
var _api$composition, _api$showDiff;
|
|
495
|
-
var _getPlaceholderState = getPlaceholderState(editorState),
|
|
496
|
-
hasPlaceholder = _getPlaceholderState.hasPlaceholder,
|
|
497
|
-
placeholderText = _getPlaceholderState.placeholderText,
|
|
498
|
-
pos = _getPlaceholderState.pos,
|
|
499
|
-
typedAndDeleted = _getPlaceholderState.typedAndDeleted,
|
|
500
|
-
contextPlaceholderADF = _getPlaceholderState.contextPlaceholderADF;
|
|
501
|
-
|
|
502
|
-
// Decorations is still called after plugin is destroyed
|
|
503
|
-
// So we need to make sure decorations is not called if plugin has been destroyed to prevent the placeholder animations' setTimeouts called infinitely
|
|
504
|
-
if (isDestroyed) {
|
|
505
|
-
return;
|
|
506
|
-
}
|
|
507
|
-
var compositionPluginState = api === null || api === void 0 || (_api$composition = api.composition) === null || _api$composition === void 0 ? void 0 : _api$composition.sharedState.currentState();
|
|
508
|
-
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);
|
|
509
|
-
if (hasPlaceholder && ((placeholderText !== null && placeholderText !== void 0 ? placeholderText : '') || placeholderPrompts || placeholderADF || contextPlaceholderADF) && pos !== undefined && !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing) && !isShowingDiff) {
|
|
510
|
-
var initialDelayWhenUserTypedAndDeleted = typedAndDeleted ? TYPEWRITER_TYPED_AND_DELETED_DELAY : 0;
|
|
511
|
-
// contextPlaceholderADF takes precedence over the global placeholderADF
|
|
512
|
-
var placeholderAdfToUse = contextPlaceholderADF || placeholderADF;
|
|
513
|
-
return createPlaceholderDecoration(editorState, placeholderText !== null && placeholderText !== void 0 ? placeholderText : '', placeholderPrompts, activeTypewriterTimeouts, pos, initialDelayWhenUserTypedAndDeleted, placeholderAdfToUse);
|
|
514
|
-
}
|
|
515
|
-
return;
|
|
516
|
-
}
|
|
517
|
-
},
|
|
518
|
-
view: function view() {
|
|
519
|
-
var timeoutId;
|
|
520
|
-
function startEmptyParagraphTimeout(editorView) {
|
|
521
|
-
if (timeoutId) {
|
|
522
|
-
return;
|
|
523
|
-
}
|
|
524
|
-
timeoutId = setTimeout(function () {
|
|
525
|
-
timeoutId = undefined;
|
|
526
|
-
editorView.dispatch(editorView.state.tr.setMeta(pluginKey, {
|
|
527
|
-
showOnEmptyParagraph: true
|
|
528
|
-
}));
|
|
529
|
-
}, EMPTY_PARAGRAPH_TIMEOUT_DELAY);
|
|
530
|
-
}
|
|
531
|
-
function destroyEmptyParagraphTimeout() {
|
|
532
|
-
if (timeoutId) {
|
|
533
|
-
clearTimeout(timeoutId);
|
|
534
|
-
timeoutId = undefined;
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
return {
|
|
538
|
-
update: function update(editorView, prevState) {
|
|
539
|
-
if ((0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_beta_2') || (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga')) {
|
|
540
|
-
var prevPluginState = getPlaceholderState(prevState);
|
|
541
|
-
var newPluginState = getPlaceholderState(editorView.state);
|
|
542
|
-
|
|
543
|
-
// user start typing after move to an empty paragraph, clear timeout
|
|
544
|
-
if (!newPluginState.canShowOnEmptyParagraph && timeoutId) {
|
|
545
|
-
destroyEmptyParagraphTimeout();
|
|
546
|
-
}
|
|
547
|
-
// user move to an empty paragraph again, reset state to hide placeholder, and restart timeout
|
|
548
|
-
else if (prevPluginState.canShowOnEmptyParagraph && newPluginState.canShowOnEmptyParagraph && newPluginState.pos !== prevPluginState.pos) {
|
|
549
|
-
editorView.dispatch(editorView.state.tr.setMeta(pluginKey, {
|
|
550
|
-
showOnEmptyParagraph: false
|
|
551
|
-
}));
|
|
552
|
-
destroyEmptyParagraphTimeout();
|
|
553
|
-
startEmptyParagraphTimeout(editorView);
|
|
554
|
-
}
|
|
555
|
-
// user move to an empty paragraph (by click enter or move to an empty paragraph), start timeout
|
|
556
|
-
else if (!prevPluginState.canShowOnEmptyParagraph && newPluginState.canShowOnEmptyParagraph && !newPluginState.showOnEmptyParagraph && !timeoutId) {
|
|
557
|
-
startEmptyParagraphTimeout(editorView);
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
},
|
|
561
|
-
destroy: function destroy() {
|
|
562
|
-
clearAllTypewriterTimeouts();
|
|
563
|
-
destroyEmptyParagraphTimeout();
|
|
564
|
-
isDestroyed = true;
|
|
565
|
-
}
|
|
566
|
-
};
|
|
567
|
-
}
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
|
-
var placeholderPlugin = exports.placeholderPlugin = function placeholderPlugin(_ref9) {
|
|
571
|
-
var options = _ref9.config,
|
|
572
|
-
api = _ref9.api;
|
|
573
24
|
var currentPlaceholder = options === null || options === void 0 ? void 0 : options.placeholder;
|
|
574
25
|
return {
|
|
575
26
|
name: 'placeholder',
|
|
576
27
|
commands: {
|
|
577
28
|
setPlaceholder: function setPlaceholder(placeholderText) {
|
|
578
|
-
return function (
|
|
579
|
-
var tr =
|
|
29
|
+
return function (_ref2) {
|
|
30
|
+
var tr = _ref2.tr;
|
|
580
31
|
if (currentPlaceholder !== placeholderText) {
|
|
581
32
|
currentPlaceholder = placeholderText;
|
|
582
33
|
return tr.setMeta(pluginKey, {
|
|
@@ -587,16 +38,16 @@ var placeholderPlugin = exports.placeholderPlugin = function placeholderPlugin(_
|
|
|
587
38
|
};
|
|
588
39
|
},
|
|
589
40
|
setAnimatingPlaceholderPrompts: function setAnimatingPlaceholderPrompts(placeholderPrompts) {
|
|
590
|
-
return function (
|
|
591
|
-
var tr =
|
|
41
|
+
return function (_ref3) {
|
|
42
|
+
var tr = _ref3.tr;
|
|
592
43
|
return tr.setMeta(pluginKey, {
|
|
593
44
|
placeholderPrompts: placeholderPrompts
|
|
594
45
|
});
|
|
595
46
|
};
|
|
596
47
|
},
|
|
597
48
|
setPlaceholderHidden: function setPlaceholderHidden(isPlaceholderHidden) {
|
|
598
|
-
return function (
|
|
599
|
-
var tr =
|
|
49
|
+
return function (_ref4) {
|
|
50
|
+
var tr = _ref4.tr;
|
|
600
51
|
return tr.setMeta(pluginKey, {
|
|
601
52
|
isPlaceholderHidden: isPlaceholderHidden
|
|
602
53
|
});
|
|
@@ -606,9 +57,9 @@ var placeholderPlugin = exports.placeholderPlugin = function placeholderPlugin(_
|
|
|
606
57
|
pmPlugins: function pmPlugins() {
|
|
607
58
|
return [{
|
|
608
59
|
name: 'placeholder',
|
|
609
|
-
plugin: function plugin(
|
|
610
|
-
var getIntl =
|
|
611
|
-
return
|
|
60
|
+
plugin: function plugin(_ref5) {
|
|
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 && options.placeholderADF, api);
|
|
612
63
|
}
|
|
613
64
|
}];
|
|
614
65
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createShortEmptyNodePlaceholderADF = exports.createLongEmptyNodePlaceholderADF = void 0;
|
|
7
|
+
var _builders = require("@atlaskit/adf-utils/builders");
|
|
8
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
9
|
+
var createShortEmptyNodePlaceholderADF = exports.createShortEmptyNodePlaceholderADF = function createShortEmptyNodePlaceholderADF(_ref) {
|
|
10
|
+
var formatMessage = _ref.formatMessage;
|
|
11
|
+
return {
|
|
12
|
+
version: 1,
|
|
13
|
+
type: 'doc',
|
|
14
|
+
content: [{
|
|
15
|
+
type: 'paragraph',
|
|
16
|
+
content: [(0, _builders.code)(formatMessage(_messages.placeholderTextMessages.shortEmptyNodePlaceholderADFSlashShortcut)), (0, _builders.text)(' '), (0, _builders.text)(formatMessage(_messages.placeholderTextMessages.shortEmptyNodePlaceholderADFSuffix))]
|
|
17
|
+
}]
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
var createLongEmptyNodePlaceholderADF = exports.createLongEmptyNodePlaceholderADF = function createLongEmptyNodePlaceholderADF(_ref2) {
|
|
21
|
+
var formatMessage = _ref2.formatMessage;
|
|
22
|
+
return {
|
|
23
|
+
version: 1,
|
|
24
|
+
type: 'doc',
|
|
25
|
+
content: [{
|
|
26
|
+
type: 'paragraph',
|
|
27
|
+
content: [(0, _builders.text)(formatMessage(_messages.placeholderTextMessages.longEmptyNodePlaceholderADFPrefix)), (0, _builders.text)(' '), (0, _builders.code)(formatMessage(_messages.placeholderTextMessages.longEmptyNodePlaceholderADFSlashShortcut)), (0, _builders.text)(' '), (0, _builders.text)(formatMessage(_messages.placeholderTextMessages.longEmptyNodePlaceholderADFSuffix))]
|
|
28
|
+
}]
|
|
29
|
+
};
|
|
30
|
+
};
|