@atlaskit/editor-plugin-placeholder 2.0.10 → 2.0.12
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
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-placeholder
|
|
2
2
|
|
|
3
|
+
## 2.0.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 2.0.11
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#136973](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/136973)
|
|
14
|
+
[`d24797988a39c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d24797988a39c) -
|
|
15
|
+
[ux] ED-27349 Remove empty line placeholder and only show empty node placeholder in first table
|
|
16
|
+
cell when it is empty
|
|
17
|
+
|
|
3
18
|
## 2.0.10
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -10,7 +10,9 @@ var _messages = require("@atlaskit/editor-common/messages");
|
|
|
10
10
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
11
11
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
12
12
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
|
+
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
13
14
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
16
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
15
17
|
var pluginKey = exports.pluginKey = new _state.PluginKey('placeholderPlugin');
|
|
16
18
|
function getPlaceholderState(editorState) {
|
|
@@ -103,7 +105,20 @@ function createPlaceHolderStateFrom(_ref) {
|
|
|
103
105
|
}
|
|
104
106
|
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';
|
|
105
107
|
if (nodeTypesWithShortPlaceholderText.includes(parentType) && isEmptyNode) {
|
|
106
|
-
|
|
108
|
+
var _table$node$firstChil;
|
|
109
|
+
if (!(0, _platformFeatureFlags.fg)('platform_editor_controls_patch_3')) {
|
|
110
|
+
return setPlaceHolderState(intl.formatMessage(_messages.placeholderTextMessages.shortEmptyNodePlaceholderText), $from.pos);
|
|
111
|
+
}
|
|
112
|
+
var table = (0, _utils2.findParentNode)(function (node) {
|
|
113
|
+
return node.type === editorState.schema.nodes.table;
|
|
114
|
+
})(editorState.selection);
|
|
115
|
+
if (!table) {
|
|
116
|
+
return emptyPlaceholder(defaultPlaceholderText);
|
|
117
|
+
}
|
|
118
|
+
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;
|
|
119
|
+
if (isFirstCell) {
|
|
120
|
+
return setPlaceHolderState(intl.formatMessage(_messages.placeholderTextMessages.shortEmptyNodePlaceholderText), $from.pos);
|
|
121
|
+
}
|
|
107
122
|
}
|
|
108
123
|
if (nodeTypesWithLongPlaceholderText.includes(parentType) && isEmptyNode) {
|
|
109
124
|
return setPlaceHolderState(intl.formatMessage(_messages.placeholderTextMessages.longEmptyNodePlaceholderText), $from.pos);
|
|
@@ -2,7 +2,9 @@ import { placeholderTextMessages as messages } from '@atlaskit/editor-common/mes
|
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import { bracketTyped, browser, isEmptyDocument, isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
5
6
|
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
8
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
9
|
export const pluginKey = new PluginKey('placeholderPlugin');
|
|
8
10
|
function getPlaceholderState(editorState) {
|
|
@@ -94,7 +96,18 @@ function createPlaceHolderStateFrom({
|
|
|
94
96
|
}
|
|
95
97
|
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 && ((_parentNode$firstChil2 = parentNode.firstChild) === null || _parentNode$firstChil2 === void 0 ? void 0 : _parentNode$firstChil2.type.name) === 'paragraph';
|
|
96
98
|
if (nodeTypesWithShortPlaceholderText.includes(parentType) && isEmptyNode) {
|
|
97
|
-
|
|
99
|
+
var _table$node$firstChil;
|
|
100
|
+
if (!fg('platform_editor_controls_patch_3')) {
|
|
101
|
+
return setPlaceHolderState(intl.formatMessage(messages.shortEmptyNodePlaceholderText), $from.pos);
|
|
102
|
+
}
|
|
103
|
+
const table = findParentNode(node => node.type === editorState.schema.nodes.table)(editorState.selection);
|
|
104
|
+
if (!table) {
|
|
105
|
+
return emptyPlaceholder(defaultPlaceholderText);
|
|
106
|
+
}
|
|
107
|
+
const isFirstCell = (table === null || table === void 0 ? void 0 : (_table$node$firstChil = table.node.firstChild) === null || _table$node$firstChil === void 0 ? void 0 : _table$node$firstChil.content.firstChild) === parentNode;
|
|
108
|
+
if (isFirstCell) {
|
|
109
|
+
return setPlaceHolderState(intl.formatMessage(messages.shortEmptyNodePlaceholderText), $from.pos);
|
|
110
|
+
}
|
|
98
111
|
}
|
|
99
112
|
if (nodeTypesWithLongPlaceholderText.includes(parentType) && isEmptyNode) {
|
|
100
113
|
return setPlaceHolderState(intl.formatMessage(messages.longEmptyNodePlaceholderText), $from.pos);
|
|
@@ -2,7 +2,9 @@ import { placeholderTextMessages as messages } from '@atlaskit/editor-common/mes
|
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import { bracketTyped, browser, isEmptyDocument, isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
5
6
|
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
8
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
9
|
export var pluginKey = new PluginKey('placeholderPlugin');
|
|
8
10
|
function getPlaceholderState(editorState) {
|
|
@@ -95,7 +97,20 @@ function createPlaceHolderStateFrom(_ref) {
|
|
|
95
97
|
}
|
|
96
98
|
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';
|
|
97
99
|
if (nodeTypesWithShortPlaceholderText.includes(parentType) && isEmptyNode) {
|
|
98
|
-
|
|
100
|
+
var _table$node$firstChil;
|
|
101
|
+
if (!fg('platform_editor_controls_patch_3')) {
|
|
102
|
+
return setPlaceHolderState(intl.formatMessage(messages.shortEmptyNodePlaceholderText), $from.pos);
|
|
103
|
+
}
|
|
104
|
+
var table = findParentNode(function (node) {
|
|
105
|
+
return node.type === editorState.schema.nodes.table;
|
|
106
|
+
})(editorState.selection);
|
|
107
|
+
if (!table) {
|
|
108
|
+
return emptyPlaceholder(defaultPlaceholderText);
|
|
109
|
+
}
|
|
110
|
+
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;
|
|
111
|
+
if (isFirstCell) {
|
|
112
|
+
return setPlaceHolderState(intl.formatMessage(messages.shortEmptyNodePlaceholderText), $from.pos);
|
|
113
|
+
}
|
|
99
114
|
}
|
|
100
115
|
if (nodeTypesWithLongPlaceholderText.includes(parentType) && isEmptyNode) {
|
|
101
116
|
return setPlaceHolderState(intl.formatMessage(messages.longEmptyNodePlaceholderText), $from.pos);
|
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.12",
|
|
4
4
|
"description": "Placeholder plugin for @atlaskit/editor-core.",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,11 +31,12 @@
|
|
|
31
31
|
".": "./src/index.ts"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@atlaskit/editor-common": "^
|
|
34
|
+
"@atlaskit/editor-common": "^103.0.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.3.0",
|
|
38
38
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
39
|
+
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
39
40
|
"@atlaskit/tmp-editor-statsig": "^4.6.0",
|
|
40
41
|
"@babel/runtime": "^7.0.0"
|
|
41
42
|
},
|
|
@@ -83,5 +84,10 @@
|
|
|
83
84
|
"import-no-extraneous-disable-for-examples-and-docs"
|
|
84
85
|
]
|
|
85
86
|
}
|
|
87
|
+
},
|
|
88
|
+
"platform-feature-flags": {
|
|
89
|
+
"platform_editor_controls_patch_3": {
|
|
90
|
+
"type": "boolean"
|
|
91
|
+
}
|
|
86
92
|
}
|
|
87
93
|
}
|