@atlaskit/editor-plugin-placeholder 6.1.0 → 6.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 +17 -1
- package/dist/cjs/placeholderPlugin.js +34 -5
- package/dist/es2019/placeholderPlugin.js +28 -3
- package/dist/esm/placeholderPlugin.js +33 -5
- package/dist/types/placeholderPluginType.d.ts +1 -0
- package/dist/types-ts4.5/placeholderPluginType.d.ts +1 -0
- package/package.json +10 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-placeholder
|
|
2
2
|
|
|
3
|
+
## 6.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`10882b2fab738`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/10882b2fab738) -
|
|
8
|
+
[ux] Introduced bodiedSyncBlock nodeview
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
14
|
+
## 6.1.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 6.1.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
|
@@ -108,7 +125,6 @@
|
|
|
108
125
|
shared context or singletons.
|
|
109
126
|
|
|
110
127
|
**HOW TO ADJUST:**
|
|
111
|
-
|
|
112
128
|
- Consumers must now explicitly install `@atlaskit/editor-common` in their own project if they use
|
|
113
129
|
any of these editor plugins.
|
|
114
130
|
- Ensure the version you install matches the version required by the plugins.
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.createPlaceholderDecoration = createPlaceholderDecoration;
|
|
7
8
|
exports.createPlugin = createPlugin;
|
|
8
9
|
exports.pluginKey = exports.placeholderPlugin = void 0;
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
11
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
10
12
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
11
13
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
12
14
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
15
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
14
16
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
17
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
18
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
15
19
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
20
|
+
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; }
|
|
21
|
+
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; }
|
|
16
22
|
// Typewriter animation timing constants
|
|
17
23
|
var TYPEWRITER_TYPE_DELAY = 50; // Delay between typing each character
|
|
18
24
|
var TYPEWRITER_PAUSE_BEFORE_ERASE = 2000; // Pause before starting to erase text
|
|
@@ -27,6 +33,7 @@ function getPlaceholderState(editorState) {
|
|
|
27
33
|
}
|
|
28
34
|
var nodeTypesWithLongPlaceholderText = ['expand', 'panel'];
|
|
29
35
|
var nodeTypesWithShortPlaceholderText = ['tableCell', 'tableHeader'];
|
|
36
|
+
var nodeTypesWithSyncBlockPlaceholderText = ['bodiedSyncBlock'];
|
|
30
37
|
var cycleThroughPlaceholderPrompts = function cycleThroughPlaceholderPrompts(placeholderPrompts, activeTypewriterTimeouts, placeholderNodeWithText) {
|
|
31
38
|
var initialDelayWhenUserTypedAndDeleted = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
32
39
|
var currentPromptIndex = 0;
|
|
@@ -151,7 +158,13 @@ function createPlaceHolderStateFrom(_ref) {
|
|
|
151
158
|
emptyLinePlaceholder = _ref.emptyLinePlaceholder,
|
|
152
159
|
placeholderPrompts = _ref.placeholderPrompts,
|
|
153
160
|
typedAndDeleted = _ref.typedAndDeleted,
|
|
154
|
-
userHadTyped = _ref.userHadTyped
|
|
161
|
+
userHadTyped = _ref.userHadTyped,
|
|
162
|
+
isPlaceholderHidden = _ref.isPlaceholderHidden;
|
|
163
|
+
if (isPlaceholderHidden && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_beta')) {
|
|
164
|
+
return _objectSpread(_objectSpread({}, emptyPlaceholder(defaultPlaceholderText, placeholderPrompts, userHadTyped)), {}, {
|
|
165
|
+
isPlaceholderHidden: isPlaceholderHidden
|
|
166
|
+
});
|
|
167
|
+
}
|
|
155
168
|
if (isTypeAheadOpen !== null && isTypeAheadOpen !== void 0 && isTypeAheadOpen(editorState)) {
|
|
156
169
|
return emptyPlaceholder(defaultPlaceholderText, placeholderPrompts, userHadTyped);
|
|
157
170
|
}
|
|
@@ -191,6 +204,9 @@ function createPlaceHolderStateFrom(_ref) {
|
|
|
191
204
|
if (nodeTypesWithLongPlaceholderText.includes(parentType) && isEmptyNode) {
|
|
192
205
|
return setPlaceHolderState(intl.formatMessage(_messages.placeholderTextMessages.longEmptyNodePlaceholderText), $from.pos, placeholderPrompts, typedAndDeleted, userHadTyped);
|
|
193
206
|
}
|
|
207
|
+
if (nodeTypesWithSyncBlockPlaceholderText.includes(parentType) && isEmptyNode && (0, _expValEquals.expValEquals)('platform_synced_block', 'isEnabled', true)) {
|
|
208
|
+
return setPlaceHolderState(intl.formatMessage(_messages.placeholderTextMessages.syncBlockPlaceholderText), $from.pos, placeholderPrompts, typedAndDeleted, userHadTyped);
|
|
209
|
+
}
|
|
194
210
|
return emptyPlaceholder(defaultPlaceholderText, placeholderPrompts, userHadTyped);
|
|
195
211
|
}
|
|
196
212
|
if (bracketPlaceholderText && (0, _utils.bracketTyped)(editorState) && isEditorFocused) {
|
|
@@ -252,7 +268,7 @@ function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, empt
|
|
|
252
268
|
});
|
|
253
269
|
},
|
|
254
270
|
apply: function apply(tr, placeholderState, _oldEditorState, newEditorState) {
|
|
255
|
-
var _api$focus2, _api$typeAhead2, _ref3, _meta$placeholderText, _ref4, _meta$placeholderProm;
|
|
271
|
+
var _api$focus2, _placeholderState$isP, _api$typeAhead2, _ref3, _meta$placeholderText, _ref4, _meta$placeholderProm;
|
|
256
272
|
var meta = tr.getMeta(pluginKey);
|
|
257
273
|
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);
|
|
258
274
|
var _calculateUserInterac = calculateUserInteractionState({
|
|
@@ -262,6 +278,10 @@ function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, empt
|
|
|
262
278
|
}),
|
|
263
279
|
userHadTyped = _calculateUserInterac.userHadTyped,
|
|
264
280
|
typedAndDeleted = _calculateUserInterac.typedAndDeleted;
|
|
281
|
+
var isPlaceholderHidden = (_placeholderState$isP = placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.isPlaceholderHidden) !== null && _placeholderState$isP !== void 0 ? _placeholderState$isP : false;
|
|
282
|
+
if ((meta === null || meta === void 0 ? void 0 : meta.isPlaceholderHidden) !== undefined && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_beta')) {
|
|
283
|
+
isPlaceholderHidden = meta.isPlaceholderHidden;
|
|
284
|
+
}
|
|
265
285
|
var newPlaceholderState = createPlaceHolderStateFrom({
|
|
266
286
|
isEditorFocused: isEditorFocused,
|
|
267
287
|
editorState: newEditorState,
|
|
@@ -272,7 +292,8 @@ function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, empt
|
|
|
272
292
|
placeholderPrompts: (_ref4 = (_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 && _ref4 !== void 0 ? _ref4 : placeholderPrompts,
|
|
273
293
|
typedAndDeleted: typedAndDeleted,
|
|
274
294
|
userHadTyped: userHadTyped,
|
|
275
|
-
intl: intl
|
|
295
|
+
intl: intl,
|
|
296
|
+
isPlaceholderHidden: isPlaceholderHidden
|
|
276
297
|
});
|
|
277
298
|
|
|
278
299
|
// Clear timeouts when hasPlaceholder becomes false
|
|
@@ -341,13 +362,21 @@ var placeholderPlugin = exports.placeholderPlugin = function placeholderPlugin(_
|
|
|
341
362
|
placeholderPrompts: placeholderPrompts
|
|
342
363
|
});
|
|
343
364
|
};
|
|
365
|
+
},
|
|
366
|
+
setPlaceholderHidden: function setPlaceholderHidden(isPlaceholderHidden) {
|
|
367
|
+
return function (_ref8) {
|
|
368
|
+
var tr = _ref8.tr;
|
|
369
|
+
return tr.setMeta(pluginKey, {
|
|
370
|
+
isPlaceholderHidden: isPlaceholderHidden
|
|
371
|
+
});
|
|
372
|
+
};
|
|
344
373
|
}
|
|
345
374
|
},
|
|
346
375
|
pmPlugins: function pmPlugins() {
|
|
347
376
|
return [{
|
|
348
377
|
name: 'placeholder',
|
|
349
|
-
plugin: function plugin(
|
|
350
|
-
var getIntl =
|
|
378
|
+
plugin: function plugin(_ref9) {
|
|
379
|
+
var getIntl = _ref9.getIntl;
|
|
351
380
|
return createPlugin(getIntl(), options && options.placeholder, options && options.placeholderBracketHint, options && options.emptyLinePlaceholder, options && options.placeholderPrompts, api);
|
|
352
381
|
}
|
|
353
382
|
}];
|
|
@@ -4,6 +4,8 @@ import { bracketTyped, browser, isEmptyDocument, isEmptyParagraph } from '@atlas
|
|
|
4
4
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
6
6
|
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
9
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
10
|
// Typewriter animation timing constants
|
|
9
11
|
const TYPEWRITER_TYPE_DELAY = 50; // Delay between typing each character
|
|
@@ -19,6 +21,7 @@ function getPlaceholderState(editorState) {
|
|
|
19
21
|
}
|
|
20
22
|
const nodeTypesWithLongPlaceholderText = ['expand', 'panel'];
|
|
21
23
|
const nodeTypesWithShortPlaceholderText = ['tableCell', 'tableHeader'];
|
|
24
|
+
const nodeTypesWithSyncBlockPlaceholderText = ['bodiedSyncBlock'];
|
|
22
25
|
const cycleThroughPlaceholderPrompts = (placeholderPrompts, activeTypewriterTimeouts, placeholderNodeWithText, initialDelayWhenUserTypedAndDeleted = 0) => {
|
|
23
26
|
let currentPromptIndex = 0;
|
|
24
27
|
let displayedText = '';
|
|
@@ -136,8 +139,15 @@ function createPlaceHolderStateFrom({
|
|
|
136
139
|
emptyLinePlaceholder,
|
|
137
140
|
placeholderPrompts,
|
|
138
141
|
typedAndDeleted,
|
|
139
|
-
userHadTyped
|
|
142
|
+
userHadTyped,
|
|
143
|
+
isPlaceholderHidden
|
|
140
144
|
}) {
|
|
145
|
+
if (isPlaceholderHidden && fg('platform_editor_ai_aifc_patch_beta')) {
|
|
146
|
+
return {
|
|
147
|
+
...emptyPlaceholder(defaultPlaceholderText, placeholderPrompts, userHadTyped),
|
|
148
|
+
isPlaceholderHidden
|
|
149
|
+
};
|
|
150
|
+
}
|
|
141
151
|
if (isTypeAheadOpen !== null && isTypeAheadOpen !== void 0 && isTypeAheadOpen(editorState)) {
|
|
142
152
|
return emptyPlaceholder(defaultPlaceholderText, placeholderPrompts, userHadTyped);
|
|
143
153
|
}
|
|
@@ -176,6 +186,9 @@ function createPlaceHolderStateFrom({
|
|
|
176
186
|
if (nodeTypesWithLongPlaceholderText.includes(parentType) && isEmptyNode) {
|
|
177
187
|
return setPlaceHolderState(intl.formatMessage(messages.longEmptyNodePlaceholderText), $from.pos, placeholderPrompts, typedAndDeleted, userHadTyped);
|
|
178
188
|
}
|
|
189
|
+
if (nodeTypesWithSyncBlockPlaceholderText.includes(parentType) && isEmptyNode && expValEquals('platform_synced_block', 'isEnabled', true)) {
|
|
190
|
+
return setPlaceHolderState(intl.formatMessage(messages.syncBlockPlaceholderText), $from.pos, placeholderPrompts, typedAndDeleted, userHadTyped);
|
|
191
|
+
}
|
|
179
192
|
return emptyPlaceholder(defaultPlaceholderText, placeholderPrompts, userHadTyped);
|
|
180
193
|
}
|
|
181
194
|
if (bracketPlaceholderText && bracketTyped(editorState) && isEditorFocused) {
|
|
@@ -238,7 +251,7 @@ export function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderTex
|
|
|
238
251
|
});
|
|
239
252
|
},
|
|
240
253
|
apply: (tr, placeholderState, _oldEditorState, newEditorState) => {
|
|
241
|
-
var _api$focus2, _api$focus2$sharedSta, _api$typeAhead2, _ref, _meta$placeholderText, _ref2, _meta$placeholderProm;
|
|
254
|
+
var _api$focus2, _api$focus2$sharedSta, _placeholderState$isP, _api$typeAhead2, _ref, _meta$placeholderText, _ref2, _meta$placeholderProm;
|
|
242
255
|
const meta = tr.getMeta(pluginKey);
|
|
243
256
|
const isEditorFocused = Boolean(api === null || api === void 0 ? void 0 : (_api$focus2 = api.focus) === null || _api$focus2 === void 0 ? void 0 : (_api$focus2$sharedSta = _api$focus2.sharedState.currentState()) === null || _api$focus2$sharedSta === void 0 ? void 0 : _api$focus2$sharedSta.hasFocus);
|
|
244
257
|
const {
|
|
@@ -249,6 +262,10 @@ export function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderTex
|
|
|
249
262
|
oldEditorState: _oldEditorState,
|
|
250
263
|
newEditorState
|
|
251
264
|
});
|
|
265
|
+
let isPlaceholderHidden = (_placeholderState$isP = placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.isPlaceholderHidden) !== null && _placeholderState$isP !== void 0 ? _placeholderState$isP : false;
|
|
266
|
+
if ((meta === null || meta === void 0 ? void 0 : meta.isPlaceholderHidden) !== undefined && fg('platform_editor_ai_aifc_patch_beta')) {
|
|
267
|
+
isPlaceholderHidden = meta.isPlaceholderHidden;
|
|
268
|
+
}
|
|
252
269
|
const newPlaceholderState = createPlaceHolderStateFrom({
|
|
253
270
|
isEditorFocused,
|
|
254
271
|
editorState: newEditorState,
|
|
@@ -259,7 +276,8 @@ export function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderTex
|
|
|
259
276
|
placeholderPrompts: (_ref2 = (_meta$placeholderProm = meta === null || meta === void 0 ? void 0 : meta.placeholderPrompts) !== null && _meta$placeholderProm !== void 0 ? _meta$placeholderProm : placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.placeholderPrompts) !== null && _ref2 !== void 0 ? _ref2 : placeholderPrompts,
|
|
260
277
|
typedAndDeleted,
|
|
261
278
|
userHadTyped,
|
|
262
|
-
intl
|
|
279
|
+
intl,
|
|
280
|
+
isPlaceholderHidden
|
|
263
281
|
});
|
|
264
282
|
|
|
265
283
|
// Clear timeouts when hasPlaceholder becomes false
|
|
@@ -328,6 +346,13 @@ export const placeholderPlugin = ({
|
|
|
328
346
|
return tr.setMeta(pluginKey, {
|
|
329
347
|
placeholderPrompts: placeholderPrompts
|
|
330
348
|
});
|
|
349
|
+
},
|
|
350
|
+
setPlaceholderHidden: isPlaceholderHidden => ({
|
|
351
|
+
tr
|
|
352
|
+
}) => {
|
|
353
|
+
return tr.setMeta(pluginKey, {
|
|
354
|
+
isPlaceholderHidden
|
|
355
|
+
});
|
|
331
356
|
}
|
|
332
357
|
},
|
|
333
358
|
pmPlugins() {
|
|
@@ -1,9 +1,14 @@
|
|
|
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; }
|
|
1
4
|
import { placeholderTextMessages as messages } from '@atlaskit/editor-common/messages';
|
|
2
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
6
|
import { bracketTyped, browser, isEmptyDocument, isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
4
7
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
5
8
|
import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
6
9
|
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
12
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
13
|
// Typewriter animation timing constants
|
|
9
14
|
var TYPEWRITER_TYPE_DELAY = 50; // Delay between typing each character
|
|
@@ -19,6 +24,7 @@ function getPlaceholderState(editorState) {
|
|
|
19
24
|
}
|
|
20
25
|
var nodeTypesWithLongPlaceholderText = ['expand', 'panel'];
|
|
21
26
|
var nodeTypesWithShortPlaceholderText = ['tableCell', 'tableHeader'];
|
|
27
|
+
var nodeTypesWithSyncBlockPlaceholderText = ['bodiedSyncBlock'];
|
|
22
28
|
var cycleThroughPlaceholderPrompts = function cycleThroughPlaceholderPrompts(placeholderPrompts, activeTypewriterTimeouts, placeholderNodeWithText) {
|
|
23
29
|
var initialDelayWhenUserTypedAndDeleted = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
24
30
|
var currentPromptIndex = 0;
|
|
@@ -143,7 +149,13 @@ function createPlaceHolderStateFrom(_ref) {
|
|
|
143
149
|
emptyLinePlaceholder = _ref.emptyLinePlaceholder,
|
|
144
150
|
placeholderPrompts = _ref.placeholderPrompts,
|
|
145
151
|
typedAndDeleted = _ref.typedAndDeleted,
|
|
146
|
-
userHadTyped = _ref.userHadTyped
|
|
152
|
+
userHadTyped = _ref.userHadTyped,
|
|
153
|
+
isPlaceholderHidden = _ref.isPlaceholderHidden;
|
|
154
|
+
if (isPlaceholderHidden && fg('platform_editor_ai_aifc_patch_beta')) {
|
|
155
|
+
return _objectSpread(_objectSpread({}, emptyPlaceholder(defaultPlaceholderText, placeholderPrompts, userHadTyped)), {}, {
|
|
156
|
+
isPlaceholderHidden: isPlaceholderHidden
|
|
157
|
+
});
|
|
158
|
+
}
|
|
147
159
|
if (isTypeAheadOpen !== null && isTypeAheadOpen !== void 0 && isTypeAheadOpen(editorState)) {
|
|
148
160
|
return emptyPlaceholder(defaultPlaceholderText, placeholderPrompts, userHadTyped);
|
|
149
161
|
}
|
|
@@ -183,6 +195,9 @@ function createPlaceHolderStateFrom(_ref) {
|
|
|
183
195
|
if (nodeTypesWithLongPlaceholderText.includes(parentType) && isEmptyNode) {
|
|
184
196
|
return setPlaceHolderState(intl.formatMessage(messages.longEmptyNodePlaceholderText), $from.pos, placeholderPrompts, typedAndDeleted, userHadTyped);
|
|
185
197
|
}
|
|
198
|
+
if (nodeTypesWithSyncBlockPlaceholderText.includes(parentType) && isEmptyNode && expValEquals('platform_synced_block', 'isEnabled', true)) {
|
|
199
|
+
return setPlaceHolderState(intl.formatMessage(messages.syncBlockPlaceholderText), $from.pos, placeholderPrompts, typedAndDeleted, userHadTyped);
|
|
200
|
+
}
|
|
186
201
|
return emptyPlaceholder(defaultPlaceholderText, placeholderPrompts, userHadTyped);
|
|
187
202
|
}
|
|
188
203
|
if (bracketPlaceholderText && bracketTyped(editorState) && isEditorFocused) {
|
|
@@ -244,7 +259,7 @@ export function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderTex
|
|
|
244
259
|
});
|
|
245
260
|
},
|
|
246
261
|
apply: function apply(tr, placeholderState, _oldEditorState, newEditorState) {
|
|
247
|
-
var _api$focus2, _api$typeAhead2, _ref3, _meta$placeholderText, _ref4, _meta$placeholderProm;
|
|
262
|
+
var _api$focus2, _placeholderState$isP, _api$typeAhead2, _ref3, _meta$placeholderText, _ref4, _meta$placeholderProm;
|
|
248
263
|
var meta = tr.getMeta(pluginKey);
|
|
249
264
|
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);
|
|
250
265
|
var _calculateUserInterac = calculateUserInteractionState({
|
|
@@ -254,6 +269,10 @@ export function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderTex
|
|
|
254
269
|
}),
|
|
255
270
|
userHadTyped = _calculateUserInterac.userHadTyped,
|
|
256
271
|
typedAndDeleted = _calculateUserInterac.typedAndDeleted;
|
|
272
|
+
var isPlaceholderHidden = (_placeholderState$isP = placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.isPlaceholderHidden) !== null && _placeholderState$isP !== void 0 ? _placeholderState$isP : false;
|
|
273
|
+
if ((meta === null || meta === void 0 ? void 0 : meta.isPlaceholderHidden) !== undefined && fg('platform_editor_ai_aifc_patch_beta')) {
|
|
274
|
+
isPlaceholderHidden = meta.isPlaceholderHidden;
|
|
275
|
+
}
|
|
257
276
|
var newPlaceholderState = createPlaceHolderStateFrom({
|
|
258
277
|
isEditorFocused: isEditorFocused,
|
|
259
278
|
editorState: newEditorState,
|
|
@@ -264,7 +283,8 @@ export function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderTex
|
|
|
264
283
|
placeholderPrompts: (_ref4 = (_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 && _ref4 !== void 0 ? _ref4 : placeholderPrompts,
|
|
265
284
|
typedAndDeleted: typedAndDeleted,
|
|
266
285
|
userHadTyped: userHadTyped,
|
|
267
|
-
intl: intl
|
|
286
|
+
intl: intl,
|
|
287
|
+
isPlaceholderHidden: isPlaceholderHidden
|
|
268
288
|
});
|
|
269
289
|
|
|
270
290
|
// Clear timeouts when hasPlaceholder becomes false
|
|
@@ -333,13 +353,21 @@ export var placeholderPlugin = function placeholderPlugin(_ref5) {
|
|
|
333
353
|
placeholderPrompts: placeholderPrompts
|
|
334
354
|
});
|
|
335
355
|
};
|
|
356
|
+
},
|
|
357
|
+
setPlaceholderHidden: function setPlaceholderHidden(isPlaceholderHidden) {
|
|
358
|
+
return function (_ref8) {
|
|
359
|
+
var tr = _ref8.tr;
|
|
360
|
+
return tr.setMeta(pluginKey, {
|
|
361
|
+
isPlaceholderHidden: isPlaceholderHidden
|
|
362
|
+
});
|
|
363
|
+
};
|
|
336
364
|
}
|
|
337
365
|
},
|
|
338
366
|
pmPlugins: function pmPlugins() {
|
|
339
367
|
return [{
|
|
340
368
|
name: 'placeholder',
|
|
341
|
-
plugin: function plugin(
|
|
342
|
-
var getIntl =
|
|
369
|
+
plugin: function plugin(_ref9) {
|
|
370
|
+
var getIntl = _ref9.getIntl;
|
|
343
371
|
return createPlugin(getIntl(), options && options.placeholder, options && options.placeholderBracketHint, options && options.emptyLinePlaceholder, options && options.placeholderPrompts, api);
|
|
344
372
|
}
|
|
345
373
|
}];
|
|
@@ -13,6 +13,7 @@ export type PlaceholderPlugin = NextEditorPlugin<'placeholder', {
|
|
|
13
13
|
commands: {
|
|
14
14
|
setAnimatingPlaceholderPrompts: (placeholderPrompts: string[]) => EditorCommand;
|
|
15
15
|
setPlaceholder: (placeholder: string) => EditorCommand;
|
|
16
|
+
setPlaceholderHidden: (isPlaceholderHidden: boolean) => EditorCommand;
|
|
16
17
|
};
|
|
17
18
|
dependencies: [FocusPlugin, CompositionPlugin, TypeAheadPlugin, OptionalPlugin<ShowDiffPlugin>];
|
|
18
19
|
pluginConfiguration: PlaceholderPluginOptions | undefined;
|
|
@@ -13,6 +13,7 @@ export type PlaceholderPlugin = NextEditorPlugin<'placeholder', {
|
|
|
13
13
|
commands: {
|
|
14
14
|
setAnimatingPlaceholderPrompts: (placeholderPrompts: string[]) => EditorCommand;
|
|
15
15
|
setPlaceholder: (placeholder: string) => EditorCommand;
|
|
16
|
+
setPlaceholderHidden: (isPlaceholderHidden: boolean) => EditorCommand;
|
|
16
17
|
};
|
|
17
18
|
dependencies: [
|
|
18
19
|
FocusPlugin,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-placeholder",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "Placeholder plugin for @atlaskit/editor-core.",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,15 +29,15 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@atlaskit/editor-plugin-composition": "^5.0.0",
|
|
31
31
|
"@atlaskit/editor-plugin-focus": "^5.0.0",
|
|
32
|
-
"@atlaskit/editor-plugin-show-diff": "^3.
|
|
33
|
-
"@atlaskit/editor-plugin-type-ahead": "^6.
|
|
32
|
+
"@atlaskit/editor-plugin-show-diff": "^3.1.0",
|
|
33
|
+
"@atlaskit/editor-plugin-type-ahead": "^6.5.0",
|
|
34
34
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
35
35
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
36
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
36
|
+
"@atlaskit/tmp-editor-statsig": "^13.13.0",
|
|
37
37
|
"@babel/runtime": "^7.0.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@atlaskit/editor-common": "^110.
|
|
40
|
+
"@atlaskit/editor-common": "^110.14.0",
|
|
41
41
|
"react": "^18.2.0",
|
|
42
42
|
"react-dom": "^18.2.0",
|
|
43
43
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
@@ -45,6 +45,11 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@testing-library/react": "^13.4.0"
|
|
47
47
|
},
|
|
48
|
+
"platform-feature-flags": {
|
|
49
|
+
"platform_editor_ai_aifc_patch_beta": {
|
|
50
|
+
"type": "boolean"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
48
53
|
"techstack": {
|
|
49
54
|
"@atlassian/frontend": {
|
|
50
55
|
"import-structure": [
|