@atlaskit/editor-plugin-placeholder 2.0.4 → 2.0.6
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 +15 -0
- package/dist/cjs/placeholderPlugin.js +17 -17
- package/dist/es2019/placeholderPlugin.js +16 -15
- package/dist/esm/placeholderPlugin.js +16 -15
- package/dist/types/placeholderPlugin.d.ts +1 -6
- package/dist/types/placeholderPluginType.d.ts +1 -0
- package/dist/types-ts4.5/placeholderPlugin.d.ts +1 -6
- package/dist/types-ts4.5/placeholderPluginType.d.ts +1 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-placeholder
|
|
2
2
|
|
|
3
|
+
## 2.0.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 2.0.5
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#124288](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/124288)
|
|
14
|
+
[`b847c8d4907ed`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b847c8d4907ed) -
|
|
15
|
+
[ux] ED-26946 Add prop to only enable empty line placeholders when the plugin option is passed in
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 2.0.4
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.SHORT_NODE_PLACEHOLDER_TEXT = exports.NODE_PLACEHOLDER_TEXT = exports.EMPTY_LINE_PLACEHOLDER_TEXT = void 0;
|
|
7
6
|
exports.createPlaceholderDecoration = createPlaceholderDecoration;
|
|
8
7
|
exports.createPlugin = createPlugin;
|
|
9
|
-
exports.pluginKey = exports.placeholderTestId = exports.placeholderPlugin =
|
|
8
|
+
exports.pluginKey = exports.placeholderTestId = exports.placeholderPlugin = void 0;
|
|
10
9
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
11
10
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
12
11
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
@@ -18,12 +17,11 @@ function getPlaceholderState(editorState) {
|
|
|
18
17
|
}
|
|
19
18
|
var placeholderTestId = exports.placeholderTestId = 'placeholder-test-id';
|
|
20
19
|
|
|
21
|
-
// TODO: Use i18n for new placeholders
|
|
22
|
-
var SHORT_NODE_PLACEHOLDER_TEXT =
|
|
23
|
-
var NODE_PLACEHOLDER_TEXT =
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var nodeTypesWithShortPlaceholderText = exports.nodeTypesWithShortPlaceholderText = ['tableCell', 'tableHeader'];
|
|
20
|
+
// TODO: ED-26962 - Use i18n for new placeholders
|
|
21
|
+
var SHORT_NODE_PLACEHOLDER_TEXT = '/ to insert';
|
|
22
|
+
var NODE_PLACEHOLDER_TEXT = 'Type / to insert elements';
|
|
23
|
+
var nodeTypesWithLongPlaceholderText = ['expand', 'panel'];
|
|
24
|
+
var nodeTypesWithShortPlaceholderText = ['tableCell', 'tableHeader'];
|
|
27
25
|
function createPlaceholderDecoration(editorState, placeholderText) {
|
|
28
26
|
var pos = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
29
27
|
var placeholderDecoration = document.createElement('span');
|
|
@@ -69,7 +67,7 @@ var emptyPlaceholder = function emptyPlaceholder(placeholderText) {
|
|
|
69
67
|
placeholderText: placeholderText
|
|
70
68
|
};
|
|
71
69
|
};
|
|
72
|
-
function createPlaceHolderStateFrom(isEditorFocused, editorState, isTypeAheadOpen, defaultPlaceholderText, bracketPlaceholderText) {
|
|
70
|
+
function createPlaceHolderStateFrom(isEditorFocused, editorState, isTypeAheadOpen, defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder) {
|
|
73
71
|
if (isTypeAheadOpen !== null && isTypeAheadOpen !== void 0 && isTypeAheadOpen(editorState)) {
|
|
74
72
|
return emptyPlaceholder(defaultPlaceholderText);
|
|
75
73
|
}
|
|
@@ -84,11 +82,13 @@ function createPlaceHolderStateFrom(isEditorFocused, editorState, isTypeAheadOpe
|
|
|
84
82
|
if ($from.pos !== $to.pos) {
|
|
85
83
|
return emptyPlaceholder(defaultPlaceholderText);
|
|
86
84
|
}
|
|
87
|
-
var isEmptyLine = (0, _utils.isEmptyParagraph)($from.parent);
|
|
88
85
|
var parentNode = $from.node($from.depth - 1);
|
|
89
86
|
var parentType = parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name;
|
|
90
|
-
if (parentType === 'doc'
|
|
91
|
-
|
|
87
|
+
if (emptyLinePlaceholder && parentType === 'doc') {
|
|
88
|
+
var isEmptyLine = (0, _utils.isEmptyParagraph)($from.parent);
|
|
89
|
+
if (isEmptyLine) {
|
|
90
|
+
return setPlaceHolderState(emptyLinePlaceholder, $from.pos);
|
|
91
|
+
}
|
|
92
92
|
}
|
|
93
93
|
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;
|
|
94
94
|
if (nodeTypesWithShortPlaceholderText.includes(parentType) && isEmptyNode) {
|
|
@@ -107,7 +107,7 @@ function createPlaceHolderStateFrom(isEditorFocused, editorState, isTypeAheadOpe
|
|
|
107
107
|
}
|
|
108
108
|
return emptyPlaceholder(defaultPlaceholderText);
|
|
109
109
|
}
|
|
110
|
-
function createPlugin(defaultPlaceholderText, bracketPlaceholderText, api) {
|
|
110
|
+
function createPlugin(defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder, api) {
|
|
111
111
|
if (!defaultPlaceholderText && !bracketPlaceholderText) {
|
|
112
112
|
return;
|
|
113
113
|
}
|
|
@@ -116,7 +116,7 @@ function createPlugin(defaultPlaceholderText, bracketPlaceholderText, api) {
|
|
|
116
116
|
state: {
|
|
117
117
|
init: function init(_, state) {
|
|
118
118
|
var _api$focus, _api$typeAhead;
|
|
119
|
-
return createPlaceHolderStateFrom(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), state, api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 ? void 0 : _api$typeAhead.actions.isOpen, defaultPlaceholderText, bracketPlaceholderText);
|
|
119
|
+
return createPlaceHolderStateFrom(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), state, api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 ? void 0 : _api$typeAhead.actions.isOpen, defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder);
|
|
120
120
|
},
|
|
121
121
|
apply: function apply(tr, placeholderState, _oldEditorState, newEditorState) {
|
|
122
122
|
var _api$focus2, _api$typeAhead3, _placeholderState$pla;
|
|
@@ -124,9 +124,9 @@ function createPlugin(defaultPlaceholderText, bracketPlaceholderText, api) {
|
|
|
124
124
|
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);
|
|
125
125
|
if ((meta === null || meta === void 0 ? void 0 : meta.placeholderText) !== undefined) {
|
|
126
126
|
var _api$typeAhead2;
|
|
127
|
-
return createPlaceHolderStateFrom(isEditorFocused, newEditorState, api === null || api === void 0 || (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 ? void 0 : _api$typeAhead2.actions.isOpen, meta.placeholderText, bracketPlaceholderText);
|
|
127
|
+
return createPlaceHolderStateFrom(isEditorFocused, newEditorState, api === null || api === void 0 || (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 ? void 0 : _api$typeAhead2.actions.isOpen, meta.placeholderText, bracketPlaceholderText, emptyLinePlaceholder);
|
|
128
128
|
}
|
|
129
|
-
return createPlaceHolderStateFrom(isEditorFocused, newEditorState, api === null || api === void 0 || (_api$typeAhead3 = api.typeAhead) === null || _api$typeAhead3 === void 0 ? void 0 : _api$typeAhead3.actions.isOpen, (_placeholderState$pla = placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.placeholderText) !== null && _placeholderState$pla !== void 0 ? _placeholderState$pla : defaultPlaceholderText, bracketPlaceholderText);
|
|
129
|
+
return createPlaceHolderStateFrom(isEditorFocused, newEditorState, api === null || api === void 0 || (_api$typeAhead3 = api.typeAhead) === null || _api$typeAhead3 === void 0 ? void 0 : _api$typeAhead3.actions.isOpen, (_placeholderState$pla = placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.placeholderText) !== null && _placeholderState$pla !== void 0 ? _placeholderState$pla : defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder);
|
|
130
130
|
}
|
|
131
131
|
},
|
|
132
132
|
props: {
|
|
@@ -169,7 +169,7 @@ var placeholderPlugin = exports.placeholderPlugin = function placeholderPlugin(_
|
|
|
169
169
|
return [{
|
|
170
170
|
name: 'placeholder',
|
|
171
171
|
plugin: function plugin() {
|
|
172
|
-
return createPlugin(options && options.placeholder, options && options.placeholderBracketHint, api);
|
|
172
|
+
return createPlugin(options && options.placeholder, options && options.placeholderBracketHint, options && options.emptyLinePlaceholder, api);
|
|
173
173
|
}
|
|
174
174
|
}];
|
|
175
175
|
}
|
|
@@ -9,12 +9,11 @@ function getPlaceholderState(editorState) {
|
|
|
9
9
|
}
|
|
10
10
|
export const placeholderTestId = 'placeholder-test-id';
|
|
11
11
|
|
|
12
|
-
// TODO: Use i18n for new placeholders
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export const nodeTypesWithShortPlaceholderText = ['tableCell', 'tableHeader'];
|
|
12
|
+
// TODO: ED-26962 - Use i18n for new placeholders
|
|
13
|
+
const SHORT_NODE_PLACEHOLDER_TEXT = '/ to insert';
|
|
14
|
+
const NODE_PLACEHOLDER_TEXT = 'Type / to insert elements';
|
|
15
|
+
const nodeTypesWithLongPlaceholderText = ['expand', 'panel'];
|
|
16
|
+
const nodeTypesWithShortPlaceholderText = ['tableCell', 'tableHeader'];
|
|
18
17
|
export function createPlaceholderDecoration(editorState, placeholderText, pos = 1) {
|
|
19
18
|
const placeholderDecoration = document.createElement('span');
|
|
20
19
|
let placeholderNodeWithText = placeholderDecoration;
|
|
@@ -57,7 +56,7 @@ const emptyPlaceholder = placeholderText => ({
|
|
|
57
56
|
hasPlaceholder: false,
|
|
58
57
|
placeholderText
|
|
59
58
|
});
|
|
60
|
-
function createPlaceHolderStateFrom(isEditorFocused, editorState, isTypeAheadOpen, defaultPlaceholderText, bracketPlaceholderText) {
|
|
59
|
+
function createPlaceHolderStateFrom(isEditorFocused, editorState, isTypeAheadOpen, defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder) {
|
|
61
60
|
if (isTypeAheadOpen !== null && isTypeAheadOpen !== void 0 && isTypeAheadOpen(editorState)) {
|
|
62
61
|
return emptyPlaceholder(defaultPlaceholderText);
|
|
63
62
|
}
|
|
@@ -73,11 +72,13 @@ function createPlaceHolderStateFrom(isEditorFocused, editorState, isTypeAheadOpe
|
|
|
73
72
|
if ($from.pos !== $to.pos) {
|
|
74
73
|
return emptyPlaceholder(defaultPlaceholderText);
|
|
75
74
|
}
|
|
76
|
-
const isEmptyLine = isEmptyParagraph($from.parent);
|
|
77
75
|
const parentNode = $from.node($from.depth - 1);
|
|
78
76
|
const parentType = parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name;
|
|
79
|
-
if (parentType === 'doc'
|
|
80
|
-
|
|
77
|
+
if (emptyLinePlaceholder && parentType === 'doc') {
|
|
78
|
+
const isEmptyLine = isEmptyParagraph($from.parent);
|
|
79
|
+
if (isEmptyLine) {
|
|
80
|
+
return setPlaceHolderState(emptyLinePlaceholder, $from.pos);
|
|
81
|
+
}
|
|
81
82
|
}
|
|
82
83
|
const 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;
|
|
83
84
|
if (nodeTypesWithShortPlaceholderText.includes(parentType) && isEmptyNode) {
|
|
@@ -98,7 +99,7 @@ function createPlaceHolderStateFrom(isEditorFocused, editorState, isTypeAheadOpe
|
|
|
98
99
|
}
|
|
99
100
|
return emptyPlaceholder(defaultPlaceholderText);
|
|
100
101
|
}
|
|
101
|
-
export function createPlugin(defaultPlaceholderText, bracketPlaceholderText, api) {
|
|
102
|
+
export function createPlugin(defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder, api) {
|
|
102
103
|
if (!defaultPlaceholderText && !bracketPlaceholderText) {
|
|
103
104
|
return;
|
|
104
105
|
}
|
|
@@ -107,7 +108,7 @@ export function createPlugin(defaultPlaceholderText, bracketPlaceholderText, api
|
|
|
107
108
|
state: {
|
|
108
109
|
init: (_, state) => {
|
|
109
110
|
var _api$focus, _api$focus$sharedStat, _api$typeAhead;
|
|
110
|
-
return createPlaceHolderStateFrom(Boolean(api === null || api === void 0 ? void 0 : (_api$focus = api.focus) === null || _api$focus === void 0 ? void 0 : (_api$focus$sharedStat = _api$focus.sharedState.currentState()) === null || _api$focus$sharedStat === void 0 ? void 0 : _api$focus$sharedStat.hasFocus), state, api === null || api === void 0 ? void 0 : (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 ? void 0 : _api$typeAhead.actions.isOpen, defaultPlaceholderText, bracketPlaceholderText);
|
|
111
|
+
return createPlaceHolderStateFrom(Boolean(api === null || api === void 0 ? void 0 : (_api$focus = api.focus) === null || _api$focus === void 0 ? void 0 : (_api$focus$sharedStat = _api$focus.sharedState.currentState()) === null || _api$focus$sharedStat === void 0 ? void 0 : _api$focus$sharedStat.hasFocus), state, api === null || api === void 0 ? void 0 : (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 ? void 0 : _api$typeAhead.actions.isOpen, defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder);
|
|
111
112
|
},
|
|
112
113
|
apply: (tr, placeholderState, _oldEditorState, newEditorState) => {
|
|
113
114
|
var _api$focus2, _api$focus2$sharedSta, _api$typeAhead3, _placeholderState$pla;
|
|
@@ -115,9 +116,9 @@ export function createPlugin(defaultPlaceholderText, bracketPlaceholderText, api
|
|
|
115
116
|
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);
|
|
116
117
|
if ((meta === null || meta === void 0 ? void 0 : meta.placeholderText) !== undefined) {
|
|
117
118
|
var _api$typeAhead2;
|
|
118
|
-
return createPlaceHolderStateFrom(isEditorFocused, newEditorState, api === null || api === void 0 ? void 0 : (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 ? void 0 : _api$typeAhead2.actions.isOpen, meta.placeholderText, bracketPlaceholderText);
|
|
119
|
+
return createPlaceHolderStateFrom(isEditorFocused, newEditorState, api === null || api === void 0 ? void 0 : (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 ? void 0 : _api$typeAhead2.actions.isOpen, meta.placeholderText, bracketPlaceholderText, emptyLinePlaceholder);
|
|
119
120
|
}
|
|
120
|
-
return createPlaceHolderStateFrom(isEditorFocused, newEditorState, api === null || api === void 0 ? void 0 : (_api$typeAhead3 = api.typeAhead) === null || _api$typeAhead3 === void 0 ? void 0 : _api$typeAhead3.actions.isOpen, (_placeholderState$pla = placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.placeholderText) !== null && _placeholderState$pla !== void 0 ? _placeholderState$pla : defaultPlaceholderText, bracketPlaceholderText);
|
|
121
|
+
return createPlaceHolderStateFrom(isEditorFocused, newEditorState, api === null || api === void 0 ? void 0 : (_api$typeAhead3 = api.typeAhead) === null || _api$typeAhead3 === void 0 ? void 0 : _api$typeAhead3.actions.isOpen, (_placeholderState$pla = placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.placeholderText) !== null && _placeholderState$pla !== void 0 ? _placeholderState$pla : defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder);
|
|
121
122
|
}
|
|
122
123
|
},
|
|
123
124
|
props: {
|
|
@@ -160,7 +161,7 @@ export const placeholderPlugin = ({
|
|
|
160
161
|
pmPlugins() {
|
|
161
162
|
return [{
|
|
162
163
|
name: 'placeholder',
|
|
163
|
-
plugin: () => createPlugin(options && options.placeholder, options && options.placeholderBracketHint, api)
|
|
164
|
+
plugin: () => createPlugin(options && options.placeholder, options && options.placeholderBracketHint, options && options.emptyLinePlaceholder, api)
|
|
164
165
|
}];
|
|
165
166
|
}
|
|
166
167
|
};
|
|
@@ -9,12 +9,11 @@ function getPlaceholderState(editorState) {
|
|
|
9
9
|
}
|
|
10
10
|
export var placeholderTestId = 'placeholder-test-id';
|
|
11
11
|
|
|
12
|
-
// TODO: Use i18n for new placeholders
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export var nodeTypesWithShortPlaceholderText = ['tableCell', 'tableHeader'];
|
|
12
|
+
// TODO: ED-26962 - Use i18n for new placeholders
|
|
13
|
+
var SHORT_NODE_PLACEHOLDER_TEXT = '/ to insert';
|
|
14
|
+
var NODE_PLACEHOLDER_TEXT = 'Type / to insert elements';
|
|
15
|
+
var nodeTypesWithLongPlaceholderText = ['expand', 'panel'];
|
|
16
|
+
var nodeTypesWithShortPlaceholderText = ['tableCell', 'tableHeader'];
|
|
18
17
|
export function createPlaceholderDecoration(editorState, placeholderText) {
|
|
19
18
|
var pos = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
20
19
|
var placeholderDecoration = document.createElement('span');
|
|
@@ -60,7 +59,7 @@ var emptyPlaceholder = function emptyPlaceholder(placeholderText) {
|
|
|
60
59
|
placeholderText: placeholderText
|
|
61
60
|
};
|
|
62
61
|
};
|
|
63
|
-
function createPlaceHolderStateFrom(isEditorFocused, editorState, isTypeAheadOpen, defaultPlaceholderText, bracketPlaceholderText) {
|
|
62
|
+
function createPlaceHolderStateFrom(isEditorFocused, editorState, isTypeAheadOpen, defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder) {
|
|
64
63
|
if (isTypeAheadOpen !== null && isTypeAheadOpen !== void 0 && isTypeAheadOpen(editorState)) {
|
|
65
64
|
return emptyPlaceholder(defaultPlaceholderText);
|
|
66
65
|
}
|
|
@@ -75,11 +74,13 @@ function createPlaceHolderStateFrom(isEditorFocused, editorState, isTypeAheadOpe
|
|
|
75
74
|
if ($from.pos !== $to.pos) {
|
|
76
75
|
return emptyPlaceholder(defaultPlaceholderText);
|
|
77
76
|
}
|
|
78
|
-
var isEmptyLine = isEmptyParagraph($from.parent);
|
|
79
77
|
var parentNode = $from.node($from.depth - 1);
|
|
80
78
|
var parentType = parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name;
|
|
81
|
-
if (parentType === 'doc'
|
|
82
|
-
|
|
79
|
+
if (emptyLinePlaceholder && parentType === 'doc') {
|
|
80
|
+
var isEmptyLine = isEmptyParagraph($from.parent);
|
|
81
|
+
if (isEmptyLine) {
|
|
82
|
+
return setPlaceHolderState(emptyLinePlaceholder, $from.pos);
|
|
83
|
+
}
|
|
83
84
|
}
|
|
84
85
|
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;
|
|
85
86
|
if (nodeTypesWithShortPlaceholderText.includes(parentType) && isEmptyNode) {
|
|
@@ -98,7 +99,7 @@ function createPlaceHolderStateFrom(isEditorFocused, editorState, isTypeAheadOpe
|
|
|
98
99
|
}
|
|
99
100
|
return emptyPlaceholder(defaultPlaceholderText);
|
|
100
101
|
}
|
|
101
|
-
export function createPlugin(defaultPlaceholderText, bracketPlaceholderText, api) {
|
|
102
|
+
export function createPlugin(defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder, api) {
|
|
102
103
|
if (!defaultPlaceholderText && !bracketPlaceholderText) {
|
|
103
104
|
return;
|
|
104
105
|
}
|
|
@@ -107,7 +108,7 @@ export function createPlugin(defaultPlaceholderText, bracketPlaceholderText, api
|
|
|
107
108
|
state: {
|
|
108
109
|
init: function init(_, state) {
|
|
109
110
|
var _api$focus, _api$typeAhead;
|
|
110
|
-
return createPlaceHolderStateFrom(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), state, api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 ? void 0 : _api$typeAhead.actions.isOpen, defaultPlaceholderText, bracketPlaceholderText);
|
|
111
|
+
return createPlaceHolderStateFrom(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), state, api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 ? void 0 : _api$typeAhead.actions.isOpen, defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder);
|
|
111
112
|
},
|
|
112
113
|
apply: function apply(tr, placeholderState, _oldEditorState, newEditorState) {
|
|
113
114
|
var _api$focus2, _api$typeAhead3, _placeholderState$pla;
|
|
@@ -115,9 +116,9 @@ export function createPlugin(defaultPlaceholderText, bracketPlaceholderText, api
|
|
|
115
116
|
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);
|
|
116
117
|
if ((meta === null || meta === void 0 ? void 0 : meta.placeholderText) !== undefined) {
|
|
117
118
|
var _api$typeAhead2;
|
|
118
|
-
return createPlaceHolderStateFrom(isEditorFocused, newEditorState, api === null || api === void 0 || (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 ? void 0 : _api$typeAhead2.actions.isOpen, meta.placeholderText, bracketPlaceholderText);
|
|
119
|
+
return createPlaceHolderStateFrom(isEditorFocused, newEditorState, api === null || api === void 0 || (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 ? void 0 : _api$typeAhead2.actions.isOpen, meta.placeholderText, bracketPlaceholderText, emptyLinePlaceholder);
|
|
119
120
|
}
|
|
120
|
-
return createPlaceHolderStateFrom(isEditorFocused, newEditorState, api === null || api === void 0 || (_api$typeAhead3 = api.typeAhead) === null || _api$typeAhead3 === void 0 ? void 0 : _api$typeAhead3.actions.isOpen, (_placeholderState$pla = placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.placeholderText) !== null && _placeholderState$pla !== void 0 ? _placeholderState$pla : defaultPlaceholderText, bracketPlaceholderText);
|
|
121
|
+
return createPlaceHolderStateFrom(isEditorFocused, newEditorState, api === null || api === void 0 || (_api$typeAhead3 = api.typeAhead) === null || _api$typeAhead3 === void 0 ? void 0 : _api$typeAhead3.actions.isOpen, (_placeholderState$pla = placeholderState === null || placeholderState === void 0 ? void 0 : placeholderState.placeholderText) !== null && _placeholderState$pla !== void 0 ? _placeholderState$pla : defaultPlaceholderText, bracketPlaceholderText, emptyLinePlaceholder);
|
|
121
122
|
}
|
|
122
123
|
},
|
|
123
124
|
props: {
|
|
@@ -160,7 +161,7 @@ export var placeholderPlugin = function placeholderPlugin(_ref) {
|
|
|
160
161
|
return [{
|
|
161
162
|
name: 'placeholder',
|
|
162
163
|
plugin: function plugin() {
|
|
163
|
-
return createPlugin(options && options.placeholder, options && options.placeholderBracketHint, api);
|
|
164
|
+
return createPlugin(options && options.placeholder, options && options.placeholderBracketHint, options && options.emptyLinePlaceholder, api);
|
|
164
165
|
}
|
|
165
166
|
}];
|
|
166
167
|
}
|
|
@@ -6,11 +6,6 @@ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
|
6
6
|
import type { PlaceholderPlugin } from './placeholderPluginType';
|
|
7
7
|
export declare const pluginKey: PluginKey<any>;
|
|
8
8
|
export declare const placeholderTestId = "placeholder-test-id";
|
|
9
|
-
export declare const SHORT_NODE_PLACEHOLDER_TEXT = "/ to insert";
|
|
10
|
-
export declare const NODE_PLACEHOLDER_TEXT = "Type / to insert elements";
|
|
11
|
-
export declare const EMPTY_LINE_PLACEHOLDER_TEXT = "Select + or type / to insert elements";
|
|
12
|
-
export declare const nodeTypesWithLongPlaceholderText: string[];
|
|
13
|
-
export declare const nodeTypesWithShortPlaceholderText: string[];
|
|
14
9
|
export declare function createPlaceholderDecoration(editorState: EditorState, placeholderText: string, pos?: number): DecorationSet;
|
|
15
|
-
export declare function createPlugin(defaultPlaceholderText?: string, bracketPlaceholderText?: string, api?: ExtractInjectionAPI<PlaceholderPlugin>): SafePlugin | undefined;
|
|
10
|
+
export declare function createPlugin(defaultPlaceholderText?: string, bracketPlaceholderText?: string, emptyLinePlaceholder?: string, api?: ExtractInjectionAPI<PlaceholderPlugin>): SafePlugin | undefined;
|
|
16
11
|
export declare const placeholderPlugin: PlaceholderPlugin;
|
|
@@ -5,6 +5,7 @@ import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
|
|
|
5
5
|
export interface PlaceholderPluginOptions {
|
|
6
6
|
placeholder?: string;
|
|
7
7
|
placeholderBracketHint?: string;
|
|
8
|
+
emptyLinePlaceholder?: string;
|
|
8
9
|
}
|
|
9
10
|
export type PlaceholderPlugin = NextEditorPlugin<'placeholder', {
|
|
10
11
|
pluginConfiguration: PlaceholderPluginOptions | undefined;
|
|
@@ -6,11 +6,6 @@ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
|
6
6
|
import type { PlaceholderPlugin } from './placeholderPluginType';
|
|
7
7
|
export declare const pluginKey: PluginKey<any>;
|
|
8
8
|
export declare const placeholderTestId = "placeholder-test-id";
|
|
9
|
-
export declare const SHORT_NODE_PLACEHOLDER_TEXT = "/ to insert";
|
|
10
|
-
export declare const NODE_PLACEHOLDER_TEXT = "Type / to insert elements";
|
|
11
|
-
export declare const EMPTY_LINE_PLACEHOLDER_TEXT = "Select + or type / to insert elements";
|
|
12
|
-
export declare const nodeTypesWithLongPlaceholderText: string[];
|
|
13
|
-
export declare const nodeTypesWithShortPlaceholderText: string[];
|
|
14
9
|
export declare function createPlaceholderDecoration(editorState: EditorState, placeholderText: string, pos?: number): DecorationSet;
|
|
15
|
-
export declare function createPlugin(defaultPlaceholderText?: string, bracketPlaceholderText?: string, api?: ExtractInjectionAPI<PlaceholderPlugin>): SafePlugin | undefined;
|
|
10
|
+
export declare function createPlugin(defaultPlaceholderText?: string, bracketPlaceholderText?: string, emptyLinePlaceholder?: string, api?: ExtractInjectionAPI<PlaceholderPlugin>): SafePlugin | undefined;
|
|
16
11
|
export declare const placeholderPlugin: PlaceholderPlugin;
|
|
@@ -5,6 +5,7 @@ import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
|
|
|
5
5
|
export interface PlaceholderPluginOptions {
|
|
6
6
|
placeholder?: string;
|
|
7
7
|
placeholderBracketHint?: string;
|
|
8
|
+
emptyLinePlaceholder?: string;
|
|
8
9
|
}
|
|
9
10
|
export type PlaceholderPlugin = NextEditorPlugin<'placeholder', {
|
|
10
11
|
pluginConfiguration: PlaceholderPluginOptions | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-placeholder",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "Placeholder plugin for @atlaskit/editor-core.",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
".": "./src/index.ts"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@atlaskit/editor-common": "^102.
|
|
34
|
+
"@atlaskit/editor-common": "^102.8.0",
|
|
35
35
|
"@atlaskit/editor-plugin-composition": "^1.3.0",
|
|
36
36
|
"@atlaskit/editor-plugin-focus": "^1.5.0",
|
|
37
37
|
"@atlaskit/editor-plugin-type-ahead": "^2.1.0",
|
|
38
38
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
39
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
39
|
+
"@atlaskit/tmp-editor-statsig": "^4.0.0",
|
|
40
40
|
"@babel/runtime": "^7.0.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|