@atlaskit/editor-plugin-placeholder 6.3.0 → 6.4.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 +45 -6
- package/dist/es2019/placeholderPlugin.js +45 -7
- package/dist/esm/placeholderPlugin.js +45 -6
- package/dist/types/placeholderPlugin.d.ts +3 -2
- package/dist/types/placeholderPluginType.d.ts +2 -0
- package/dist/types-ts4.5/placeholderPlugin.d.ts +3 -2
- package/dist/types-ts4.5/placeholderPluginType.d.ts +2 -0
- package/package.json +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-placeholder
|
|
2
2
|
|
|
3
|
+
## 6.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`f34c6075cc3a4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f34c6075cc3a4) -
|
|
8
|
+
[ux] [EDITOR-2327] added support to add marks on placeholder plugin texts
|
|
9
|
+
|
|
3
10
|
## 6.3.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
|
@@ -10,8 +10,10 @@ exports.createPlugin = createPlugin;
|
|
|
10
10
|
exports.pluginKey = exports.placeholderPlugin = void 0;
|
|
11
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
12
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
13
|
+
var _processRawValue = require("@atlaskit/editor-common/process-raw-value");
|
|
13
14
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
14
15
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
16
|
+
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
15
17
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
16
18
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
17
19
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
@@ -91,6 +93,7 @@ var cycleThroughPlaceholderPrompts = function cycleThroughPlaceholderPrompts(pla
|
|
|
91
93
|
function createPlaceholderDecoration(editorState, placeholderText, placeholderPrompts, activeTypewriterTimeouts) {
|
|
92
94
|
var pos = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
|
|
93
95
|
var initialDelayWhenUserTypedAndDeleted = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
|
96
|
+
var placeholderADF = arguments.length > 6 ? arguments[6] : undefined;
|
|
94
97
|
var placeholderDecoration = document.createElement('span');
|
|
95
98
|
var placeholderNodeWithText = placeholderDecoration;
|
|
96
99
|
placeholderDecoration.setAttribute('data-testid', placeholderTestId);
|
|
@@ -104,7 +107,43 @@ function createPlaceholderDecoration(editorState, placeholderText, placeholderPr
|
|
|
104
107
|
placeholderDecoration.appendChild(placeholderNode);
|
|
105
108
|
placeholderNodeWithText = placeholderNode;
|
|
106
109
|
}
|
|
107
|
-
if (
|
|
110
|
+
if (placeholderADF) {
|
|
111
|
+
var serializer = _model.DOMSerializer.fromSchema(editorState.schema);
|
|
112
|
+
// Get a PMNode from docnode
|
|
113
|
+
var docNode = (0, _processRawValue.processRawValue)(editorState.schema, placeholderADF);
|
|
114
|
+
if (docNode) {
|
|
115
|
+
// Extract only the inline content from paragraphs, avoiding block-level elements
|
|
116
|
+
// that can interfere with cursor rendering
|
|
117
|
+
docNode.children.forEach(function (node) {
|
|
118
|
+
// For paragraph nodes, serialize their content (inline elements) directly
|
|
119
|
+
// without the wrapping <p> tag
|
|
120
|
+
if (node.type.name === 'paragraph') {
|
|
121
|
+
node.content.forEach(function (inlineNode) {
|
|
122
|
+
var inlineDOM = serializer.serializeNode(inlineNode);
|
|
123
|
+
placeholderNodeWithText.append(inlineDOM);
|
|
124
|
+
});
|
|
125
|
+
} else {
|
|
126
|
+
// For non-paragraph nodes, serialize normally
|
|
127
|
+
var nodeDOM = serializer.serializeNode(node);
|
|
128
|
+
placeholderNodeWithText.append(nodeDOM);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
var markElements = placeholderNodeWithText.querySelectorAll('[data-prosemirror-content-type="mark"]');
|
|
132
|
+
markElements.forEach(function (markEl) {
|
|
133
|
+
if (markEl instanceof HTMLElement) {
|
|
134
|
+
markEl.style.setProperty('color', "var(--ds-text-subtlest, #6B6E76)");
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
// Ensure all child elements don't block pointer events or cursor
|
|
138
|
+
var allElements = placeholderNodeWithText.querySelectorAll('*');
|
|
139
|
+
allElements.forEach(function (el) {
|
|
140
|
+
if (el instanceof HTMLElement) {
|
|
141
|
+
el.style.pointerEvents = 'none';
|
|
142
|
+
el.style.userSelect = 'none';
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
} else if (placeholderText) {
|
|
108
147
|
placeholderNodeWithText.textContent = placeholderText || ' ';
|
|
109
148
|
} else if (placeholderPrompts) {
|
|
110
149
|
cycleThroughPlaceholderPrompts(placeholderPrompts, activeTypewriterTimeouts, placeholderNodeWithText, initialDelayWhenUserTypedAndDeleted);
|
|
@@ -345,8 +384,8 @@ function calculateUserInteractionState(_ref4) {
|
|
|
345
384
|
typedAndDeleted: isInTypedAndDeletedState
|
|
346
385
|
};
|
|
347
386
|
}
|
|
348
|
-
function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder, placeholderPrompts, withEmptyParagraph, api) {
|
|
349
|
-
if (!defaultPlaceholderText && !placeholderPrompts && !bracketPlaceholderText) {
|
|
387
|
+
function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder, placeholderPrompts, withEmptyParagraph, placeholderADF, api) {
|
|
388
|
+
if (!defaultPlaceholderText && !placeholderPrompts && !bracketPlaceholderText && !placeholderADF) {
|
|
350
389
|
return;
|
|
351
390
|
}
|
|
352
391
|
var isDestroyed = false;
|
|
@@ -433,9 +472,9 @@ function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, empt
|
|
|
433
472
|
}
|
|
434
473
|
var compositionPluginState = api === null || api === void 0 || (_api$composition = api.composition) === null || _api$composition === void 0 ? void 0 : _api$composition.sharedState.currentState();
|
|
435
474
|
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);
|
|
436
|
-
if (hasPlaceholder && ((placeholderText !== null && placeholderText !== void 0 ? placeholderText : '') || placeholderPrompts) && pos !== undefined && !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing) && !isShowingDiff) {
|
|
475
|
+
if (hasPlaceholder && ((placeholderText !== null && placeholderText !== void 0 ? placeholderText : '') || placeholderPrompts || placeholderADF) && pos !== undefined && !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing) && !isShowingDiff) {
|
|
437
476
|
var initialDelayWhenUserTypedAndDeleted = typedAndDeleted ? TYPEWRITER_TYPED_AND_DELETED_DELAY : 0;
|
|
438
|
-
return createPlaceholderDecoration(editorState, placeholderText !== null && placeholderText !== void 0 ? placeholderText : '', placeholderPrompts, activeTypewriterTimeouts, pos, initialDelayWhenUserTypedAndDeleted);
|
|
477
|
+
return createPlaceholderDecoration(editorState, placeholderText !== null && placeholderText !== void 0 ? placeholderText : '', placeholderPrompts, activeTypewriterTimeouts, pos, initialDelayWhenUserTypedAndDeleted, placeholderADF);
|
|
439
478
|
}
|
|
440
479
|
return;
|
|
441
480
|
}
|
|
@@ -533,7 +572,7 @@ var placeholderPlugin = exports.placeholderPlugin = function placeholderPlugin(_
|
|
|
533
572
|
name: 'placeholder',
|
|
534
573
|
plugin: function plugin(_ref1) {
|
|
535
574
|
var getIntl = _ref1.getIntl;
|
|
536
|
-
return createPlugin(getIntl(), options && options.placeholder, options && options.placeholderBracketHint, options && options.emptyLinePlaceholder, options && options.placeholderPrompts, options === null || options === void 0 ? void 0 : options.withEmptyParagraph, api);
|
|
575
|
+
return createPlugin(getIntl(), options && options.placeholder, options && options.placeholderBracketHint, options && options.emptyLinePlaceholder, options && options.placeholderPrompts, options === null || options === void 0 ? void 0 : options.withEmptyParagraph, options && options.placeholderADF, api);
|
|
537
576
|
}
|
|
538
577
|
}];
|
|
539
578
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { placeholderTextMessages as messages } from '@atlaskit/editor-common/messages';
|
|
2
|
+
import { processRawValue } from '@atlaskit/editor-common/process-raw-value';
|
|
2
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
4
|
import { bracketTyped, browser, hasDocAsParent, isEmptyDocument, isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
5
|
+
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
4
6
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
5
7
|
import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
6
8
|
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
@@ -72,7 +74,7 @@ const cycleThroughPlaceholderPrompts = (placeholderPrompts, activeTypewriterTime
|
|
|
72
74
|
startAnimationCycle();
|
|
73
75
|
}
|
|
74
76
|
};
|
|
75
|
-
export function createPlaceholderDecoration(editorState, placeholderText, placeholderPrompts, activeTypewriterTimeouts, pos = 1, initialDelayWhenUserTypedAndDeleted = 0) {
|
|
77
|
+
export function createPlaceholderDecoration(editorState, placeholderText, placeholderPrompts, activeTypewriterTimeouts, pos = 1, initialDelayWhenUserTypedAndDeleted = 0, placeholderADF) {
|
|
76
78
|
const placeholderDecoration = document.createElement('span');
|
|
77
79
|
let placeholderNodeWithText = placeholderDecoration;
|
|
78
80
|
placeholderDecoration.setAttribute('data-testid', placeholderTestId);
|
|
@@ -86,7 +88,43 @@ export function createPlaceholderDecoration(editorState, placeholderText, placeh
|
|
|
86
88
|
placeholderDecoration.appendChild(placeholderNode);
|
|
87
89
|
placeholderNodeWithText = placeholderNode;
|
|
88
90
|
}
|
|
89
|
-
if (
|
|
91
|
+
if (placeholderADF) {
|
|
92
|
+
const serializer = DOMSerializer.fromSchema(editorState.schema);
|
|
93
|
+
// Get a PMNode from docnode
|
|
94
|
+
const docNode = processRawValue(editorState.schema, placeholderADF);
|
|
95
|
+
if (docNode) {
|
|
96
|
+
// Extract only the inline content from paragraphs, avoiding block-level elements
|
|
97
|
+
// that can interfere with cursor rendering
|
|
98
|
+
docNode.children.forEach(node => {
|
|
99
|
+
// For paragraph nodes, serialize their content (inline elements) directly
|
|
100
|
+
// without the wrapping <p> tag
|
|
101
|
+
if (node.type.name === 'paragraph') {
|
|
102
|
+
node.content.forEach(inlineNode => {
|
|
103
|
+
const inlineDOM = serializer.serializeNode(inlineNode);
|
|
104
|
+
placeholderNodeWithText.append(inlineDOM);
|
|
105
|
+
});
|
|
106
|
+
} else {
|
|
107
|
+
// For non-paragraph nodes, serialize normally
|
|
108
|
+
const nodeDOM = serializer.serializeNode(node);
|
|
109
|
+
placeholderNodeWithText.append(nodeDOM);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
const markElements = placeholderNodeWithText.querySelectorAll('[data-prosemirror-content-type="mark"]');
|
|
113
|
+
markElements.forEach(markEl => {
|
|
114
|
+
if (markEl instanceof HTMLElement) {
|
|
115
|
+
markEl.style.setProperty('color', "var(--ds-text-subtlest, #6B6E76)");
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
// Ensure all child elements don't block pointer events or cursor
|
|
119
|
+
const allElements = placeholderNodeWithText.querySelectorAll('*');
|
|
120
|
+
allElements.forEach(el => {
|
|
121
|
+
if (el instanceof HTMLElement) {
|
|
122
|
+
el.style.pointerEvents = 'none';
|
|
123
|
+
el.style.userSelect = 'none';
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
} else if (placeholderText) {
|
|
90
128
|
placeholderNodeWithText.textContent = placeholderText || ' ';
|
|
91
129
|
} else if (placeholderPrompts) {
|
|
92
130
|
cycleThroughPlaceholderPrompts(placeholderPrompts, activeTypewriterTimeouts, placeholderNodeWithText, initialDelayWhenUserTypedAndDeleted);
|
|
@@ -332,8 +370,8 @@ function calculateUserInteractionState({
|
|
|
332
370
|
typedAndDeleted: isInTypedAndDeletedState
|
|
333
371
|
};
|
|
334
372
|
}
|
|
335
|
-
export function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder, placeholderPrompts, withEmptyParagraph, api) {
|
|
336
|
-
if (!defaultPlaceholderText && !placeholderPrompts && !bracketPlaceholderText) {
|
|
373
|
+
export function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder, placeholderPrompts, withEmptyParagraph, placeholderADF, api) {
|
|
374
|
+
if (!defaultPlaceholderText && !placeholderPrompts && !bracketPlaceholderText && !placeholderADF) {
|
|
337
375
|
return;
|
|
338
376
|
}
|
|
339
377
|
let isDestroyed = false;
|
|
@@ -420,9 +458,9 @@ export function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderTex
|
|
|
420
458
|
}
|
|
421
459
|
const compositionPluginState = api === null || api === void 0 ? void 0 : (_api$composition = api.composition) === null || _api$composition === void 0 ? void 0 : _api$composition.sharedState.currentState();
|
|
422
460
|
const isShowingDiff = Boolean(api === null || api === void 0 ? void 0 : (_api$showDiff = api.showDiff) === null || _api$showDiff === void 0 ? void 0 : (_api$showDiff$sharedS = _api$showDiff.sharedState.currentState()) === null || _api$showDiff$sharedS === void 0 ? void 0 : _api$showDiff$sharedS.isDisplayingChanges);
|
|
423
|
-
if (hasPlaceholder && ((placeholderText !== null && placeholderText !== void 0 ? placeholderText : '') || placeholderPrompts) && pos !== undefined && !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing) && !isShowingDiff) {
|
|
461
|
+
if (hasPlaceholder && ((placeholderText !== null && placeholderText !== void 0 ? placeholderText : '') || placeholderPrompts || placeholderADF) && pos !== undefined && !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing) && !isShowingDiff) {
|
|
424
462
|
const initialDelayWhenUserTypedAndDeleted = typedAndDeleted ? TYPEWRITER_TYPED_AND_DELETED_DELAY : 0;
|
|
425
|
-
return createPlaceholderDecoration(editorState, placeholderText !== null && placeholderText !== void 0 ? placeholderText : '', placeholderPrompts, activeTypewriterTimeouts, pos, initialDelayWhenUserTypedAndDeleted);
|
|
463
|
+
return createPlaceholderDecoration(editorState, placeholderText !== null && placeholderText !== void 0 ? placeholderText : '', placeholderPrompts, activeTypewriterTimeouts, pos, initialDelayWhenUserTypedAndDeleted, placeholderADF);
|
|
426
464
|
}
|
|
427
465
|
return;
|
|
428
466
|
}
|
|
@@ -518,7 +556,7 @@ export const placeholderPlugin = ({
|
|
|
518
556
|
name: 'placeholder',
|
|
519
557
|
plugin: ({
|
|
520
558
|
getIntl
|
|
521
|
-
}) => createPlugin(getIntl(), options && options.placeholder, options && options.placeholderBracketHint, options && options.emptyLinePlaceholder, options && options.placeholderPrompts, options === null || options === void 0 ? void 0 : options.withEmptyParagraph, api)
|
|
559
|
+
}) => createPlugin(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)
|
|
522
560
|
}];
|
|
523
561
|
}
|
|
524
562
|
};
|
|
@@ -2,8 +2,10 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
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
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
4
|
import { placeholderTextMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
|
+
import { processRawValue } from '@atlaskit/editor-common/process-raw-value';
|
|
5
6
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
7
|
import { bracketTyped, browser, hasDocAsParent, isEmptyDocument, isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
8
|
+
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
7
9
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
8
10
|
import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
9
11
|
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
@@ -81,6 +83,7 @@ var cycleThroughPlaceholderPrompts = function cycleThroughPlaceholderPrompts(pla
|
|
|
81
83
|
export function createPlaceholderDecoration(editorState, placeholderText, placeholderPrompts, activeTypewriterTimeouts) {
|
|
82
84
|
var pos = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
|
|
83
85
|
var initialDelayWhenUserTypedAndDeleted = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
|
86
|
+
var placeholderADF = arguments.length > 6 ? arguments[6] : undefined;
|
|
84
87
|
var placeholderDecoration = document.createElement('span');
|
|
85
88
|
var placeholderNodeWithText = placeholderDecoration;
|
|
86
89
|
placeholderDecoration.setAttribute('data-testid', placeholderTestId);
|
|
@@ -94,7 +97,43 @@ export function createPlaceholderDecoration(editorState, placeholderText, placeh
|
|
|
94
97
|
placeholderDecoration.appendChild(placeholderNode);
|
|
95
98
|
placeholderNodeWithText = placeholderNode;
|
|
96
99
|
}
|
|
97
|
-
if (
|
|
100
|
+
if (placeholderADF) {
|
|
101
|
+
var serializer = DOMSerializer.fromSchema(editorState.schema);
|
|
102
|
+
// Get a PMNode from docnode
|
|
103
|
+
var docNode = processRawValue(editorState.schema, placeholderADF);
|
|
104
|
+
if (docNode) {
|
|
105
|
+
// Extract only the inline content from paragraphs, avoiding block-level elements
|
|
106
|
+
// that can interfere with cursor rendering
|
|
107
|
+
docNode.children.forEach(function (node) {
|
|
108
|
+
// For paragraph nodes, serialize their content (inline elements) directly
|
|
109
|
+
// without the wrapping <p> tag
|
|
110
|
+
if (node.type.name === 'paragraph') {
|
|
111
|
+
node.content.forEach(function (inlineNode) {
|
|
112
|
+
var inlineDOM = serializer.serializeNode(inlineNode);
|
|
113
|
+
placeholderNodeWithText.append(inlineDOM);
|
|
114
|
+
});
|
|
115
|
+
} else {
|
|
116
|
+
// For non-paragraph nodes, serialize normally
|
|
117
|
+
var nodeDOM = serializer.serializeNode(node);
|
|
118
|
+
placeholderNodeWithText.append(nodeDOM);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
var markElements = placeholderNodeWithText.querySelectorAll('[data-prosemirror-content-type="mark"]');
|
|
122
|
+
markElements.forEach(function (markEl) {
|
|
123
|
+
if (markEl instanceof HTMLElement) {
|
|
124
|
+
markEl.style.setProperty('color', "var(--ds-text-subtlest, #6B6E76)");
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
// Ensure all child elements don't block pointer events or cursor
|
|
128
|
+
var allElements = placeholderNodeWithText.querySelectorAll('*');
|
|
129
|
+
allElements.forEach(function (el) {
|
|
130
|
+
if (el instanceof HTMLElement) {
|
|
131
|
+
el.style.pointerEvents = 'none';
|
|
132
|
+
el.style.userSelect = 'none';
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
} else if (placeholderText) {
|
|
98
137
|
placeholderNodeWithText.textContent = placeholderText || ' ';
|
|
99
138
|
} else if (placeholderPrompts) {
|
|
100
139
|
cycleThroughPlaceholderPrompts(placeholderPrompts, activeTypewriterTimeouts, placeholderNodeWithText, initialDelayWhenUserTypedAndDeleted);
|
|
@@ -335,8 +374,8 @@ function calculateUserInteractionState(_ref4) {
|
|
|
335
374
|
typedAndDeleted: isInTypedAndDeletedState
|
|
336
375
|
};
|
|
337
376
|
}
|
|
338
|
-
export function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder, placeholderPrompts, withEmptyParagraph, api) {
|
|
339
|
-
if (!defaultPlaceholderText && !placeholderPrompts && !bracketPlaceholderText) {
|
|
377
|
+
export function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder, placeholderPrompts, withEmptyParagraph, placeholderADF, api) {
|
|
378
|
+
if (!defaultPlaceholderText && !placeholderPrompts && !bracketPlaceholderText && !placeholderADF) {
|
|
340
379
|
return;
|
|
341
380
|
}
|
|
342
381
|
var isDestroyed = false;
|
|
@@ -423,9 +462,9 @@ export function createPlugin(intl, defaultPlaceholderText, bracketPlaceholderTex
|
|
|
423
462
|
}
|
|
424
463
|
var compositionPluginState = api === null || api === void 0 || (_api$composition = api.composition) === null || _api$composition === void 0 ? void 0 : _api$composition.sharedState.currentState();
|
|
425
464
|
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);
|
|
426
|
-
if (hasPlaceholder && ((placeholderText !== null && placeholderText !== void 0 ? placeholderText : '') || placeholderPrompts) && pos !== undefined && !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing) && !isShowingDiff) {
|
|
465
|
+
if (hasPlaceholder && ((placeholderText !== null && placeholderText !== void 0 ? placeholderText : '') || placeholderPrompts || placeholderADF) && pos !== undefined && !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing) && !isShowingDiff) {
|
|
427
466
|
var initialDelayWhenUserTypedAndDeleted = typedAndDeleted ? TYPEWRITER_TYPED_AND_DELETED_DELAY : 0;
|
|
428
|
-
return createPlaceholderDecoration(editorState, placeholderText !== null && placeholderText !== void 0 ? placeholderText : '', placeholderPrompts, activeTypewriterTimeouts, pos, initialDelayWhenUserTypedAndDeleted);
|
|
467
|
+
return createPlaceholderDecoration(editorState, placeholderText !== null && placeholderText !== void 0 ? placeholderText : '', placeholderPrompts, activeTypewriterTimeouts, pos, initialDelayWhenUserTypedAndDeleted, placeholderADF);
|
|
429
468
|
}
|
|
430
469
|
return;
|
|
431
470
|
}
|
|
@@ -523,7 +562,7 @@ export var placeholderPlugin = function placeholderPlugin(_ref7) {
|
|
|
523
562
|
name: 'placeholder',
|
|
524
563
|
plugin: function plugin(_ref1) {
|
|
525
564
|
var getIntl = _ref1.getIntl;
|
|
526
|
-
return createPlugin(getIntl(), options && options.placeholder, options && options.placeholderBracketHint, options && options.emptyLinePlaceholder, options && options.placeholderPrompts, options === null || options === void 0 ? void 0 : options.withEmptyParagraph, api);
|
|
565
|
+
return createPlugin(getIntl(), options && options.placeholder, options && options.placeholderBracketHint, options && options.emptyLinePlaceholder, options && options.placeholderPrompts, options === null || options === void 0 ? void 0 : options.withEmptyParagraph, options && options.placeholderADF, api);
|
|
527
566
|
}
|
|
528
567
|
}];
|
|
529
568
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { DocNode } from '@atlaskit/adf-schema';
|
|
2
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
4
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
5
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -7,6 +8,6 @@ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
|
7
8
|
import type { PlaceholderPlugin } from './placeholderPluginType';
|
|
8
9
|
export declare const EMPTY_PARAGRAPH_TIMEOUT_DELAY = 2000;
|
|
9
10
|
export declare const pluginKey: PluginKey<any>;
|
|
10
|
-
export declare function createPlaceholderDecoration(editorState: EditorState, placeholderText: string, placeholderPrompts?: string[], activeTypewriterTimeouts?: (() => void)[], pos?: number, initialDelayWhenUserTypedAndDeleted?: number): DecorationSet;
|
|
11
|
-
export declare function createPlugin(intl: IntlShape, defaultPlaceholderText?: string, bracketPlaceholderText?: string, emptyLinePlaceholder?: string, placeholderPrompts?: string[], withEmptyParagraph?: boolean, api?: ExtractInjectionAPI<PlaceholderPlugin>): SafePlugin | undefined;
|
|
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;
|
|
12
13
|
export declare const placeholderPlugin: PlaceholderPlugin;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DocNode } from '@atlaskit/adf-schema';
|
|
1
2
|
import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { CompositionPlugin } from '@atlaskit/editor-plugin-composition';
|
|
3
4
|
import type { FocusPlugin } from '@atlaskit/editor-plugin-focus';
|
|
@@ -6,6 +7,7 @@ import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
|
|
|
6
7
|
export interface PlaceholderPluginOptions {
|
|
7
8
|
emptyLinePlaceholder?: string;
|
|
8
9
|
placeholder?: string;
|
|
10
|
+
placeholderADF?: DocNode;
|
|
9
11
|
placeholderBracketHint?: string;
|
|
10
12
|
placeholderPrompts?: string[];
|
|
11
13
|
withEmptyParagraph?: boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { DocNode } from '@atlaskit/adf-schema';
|
|
2
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
4
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
5
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -7,6 +8,6 @@ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
|
7
8
|
import type { PlaceholderPlugin } from './placeholderPluginType';
|
|
8
9
|
export declare const EMPTY_PARAGRAPH_TIMEOUT_DELAY = 2000;
|
|
9
10
|
export declare const pluginKey: PluginKey<any>;
|
|
10
|
-
export declare function createPlaceholderDecoration(editorState: EditorState, placeholderText: string, placeholderPrompts?: string[], activeTypewriterTimeouts?: (() => void)[], pos?: number, initialDelayWhenUserTypedAndDeleted?: number): DecorationSet;
|
|
11
|
-
export declare function createPlugin(intl: IntlShape, defaultPlaceholderText?: string, bracketPlaceholderText?: string, emptyLinePlaceholder?: string, placeholderPrompts?: string[], withEmptyParagraph?: boolean, api?: ExtractInjectionAPI<PlaceholderPlugin>): SafePlugin | undefined;
|
|
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;
|
|
12
13
|
export declare const placeholderPlugin: PlaceholderPlugin;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DocNode } from '@atlaskit/adf-schema';
|
|
1
2
|
import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { CompositionPlugin } from '@atlaskit/editor-plugin-composition';
|
|
3
4
|
import type { FocusPlugin } from '@atlaskit/editor-plugin-focus';
|
|
@@ -6,6 +7,7 @@ import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
|
|
|
6
7
|
export interface PlaceholderPluginOptions {
|
|
7
8
|
emptyLinePlaceholder?: string;
|
|
8
9
|
placeholder?: string;
|
|
10
|
+
placeholderADF?: DocNode;
|
|
9
11
|
placeholderBracketHint?: string;
|
|
10
12
|
placeholderPrompts?: string[];
|
|
11
13
|
withEmptyParagraph?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-placeholder",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.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,16 @@
|
|
|
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.
|
|
32
|
+
"@atlaskit/editor-plugin-show-diff": "^3.2.0",
|
|
33
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": "^13.
|
|
36
|
+
"@atlaskit/tmp-editor-statsig": "^13.38.0",
|
|
37
|
+
"@atlaskit/tokens": "^8.0.0",
|
|
37
38
|
"@babel/runtime": "^7.0.0"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
|
-
"@atlaskit/editor-common": "^110.
|
|
41
|
+
"@atlaskit/editor-common": "^110.31.0",
|
|
41
42
|
"react": "^18.2.0",
|
|
42
43
|
"react-dom": "^18.2.0",
|
|
43
44
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
@@ -51,6 +52,9 @@
|
|
|
51
52
|
},
|
|
52
53
|
"platform_editor_ai_aifc_patch_beta_2": {
|
|
53
54
|
"type": "boolean"
|
|
55
|
+
},
|
|
56
|
+
"platform_editor_ai_aifc_patch_ga": {
|
|
57
|
+
"type": "boolean"
|
|
54
58
|
}
|
|
55
59
|
},
|
|
56
60
|
"techstack": {
|