@atlaskit/editor-plugin-placeholder 2.0.7 → 2.0.9

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,21 @@
1
1
  # @atlaskit/editor-plugin-placeholder
2
2
 
3
+ ## 2.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [#131399](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/131399)
8
+ [`3e2bb97c408f7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3e2bb97c408f7) -
9
+ Add className to nested nodes for placeholder text to selectively apply truncation on long text
10
+
11
+ ## 2.0.8
12
+
13
+ ### Patch Changes
14
+
15
+ - [#129904](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/129904)
16
+ [`7a5c1784af47f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7a5c1784af47f) -
17
+ [ux] ED-27141 Adding a check so that only empty paragraphs will show empty node placeholder
18
+
3
19
  ## 2.0.7
4
20
 
5
21
  ### Patch Changes
@@ -49,6 +49,13 @@ function createPlaceholderDecoration(editorState, placeholderText) {
49
49
  buffNode.textContent = ' ';
50
50
  placeholderDecoration.appendChild(buffNode);
51
51
  }
52
+ var isTargetNested = editorState.doc.resolve(pos).depth > 1;
53
+
54
+ // only truncate text for nested nodes, otherwise applying 'overflow: hidden;' to top level nodes
55
+ // creates issues with quick insert button
56
+ if (isTargetNested && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
57
+ placeholderDecoration.classList.add('placeholder-decoration-hide-overflow');
58
+ }
52
59
  return _view.DecorationSet.create(editorState.doc, [_view.Decoration.widget(pos, placeholderDecoration, {
53
60
  side: 0,
54
61
  key: "placeholder ".concat(placeholderText)
@@ -75,7 +82,7 @@ function createPlaceHolderStateFrom(isEditorFocused, editorState, isTypeAheadOpe
75
82
  return setPlaceHolderState(defaultPlaceholderText);
76
83
  }
77
84
  if (isEditorFocused && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
78
- var _parentNode$firstChil;
85
+ var _parentNode$firstChil, _parentNode$firstChil2;
79
86
  var _editorState$selectio = editorState.selection,
80
87
  $from = _editorState$selectio.$from,
81
88
  $to = _editorState$selectio.$to;
@@ -90,7 +97,7 @@ function createPlaceHolderStateFrom(isEditorFocused, editorState, isTypeAheadOpe
90
97
  return setPlaceHolderState(emptyLinePlaceholder, $from.pos);
91
98
  }
92
99
  }
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;
100
+ 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';
94
101
  if (nodeTypesWithShortPlaceholderText.includes(parentType) && isEmptyNode) {
95
102
  return setPlaceHolderState(SHORT_NODE_PLACEHOLDER_TEXT, $from.pos);
96
103
  }
@@ -40,6 +40,13 @@ export function createPlaceholderDecoration(editorState, placeholderText, pos =
40
40
  buffNode.textContent = ' ';
41
41
  placeholderDecoration.appendChild(buffNode);
42
42
  }
43
+ const isTargetNested = editorState.doc.resolve(pos).depth > 1;
44
+
45
+ // only truncate text for nested nodes, otherwise applying 'overflow: hidden;' to top level nodes
46
+ // creates issues with quick insert button
47
+ if (isTargetNested && editorExperiment('platform_editor_controls', 'variant1')) {
48
+ placeholderDecoration.classList.add('placeholder-decoration-hide-overflow');
49
+ }
43
50
  return DecorationSet.create(editorState.doc, [Decoration.widget(pos, placeholderDecoration, {
44
51
  side: 0,
45
52
  key: `placeholder ${placeholderText}`
@@ -64,7 +71,7 @@ function createPlaceHolderStateFrom(isEditorFocused, editorState, isTypeAheadOpe
64
71
  return setPlaceHolderState(defaultPlaceholderText);
65
72
  }
66
73
  if (isEditorFocused && editorExperiment('platform_editor_controls', 'variant1')) {
67
- var _parentNode$firstChil;
74
+ var _parentNode$firstChil, _parentNode$firstChil2;
68
75
  const {
69
76
  $from,
70
77
  $to
@@ -80,7 +87,7 @@ function createPlaceHolderStateFrom(isEditorFocused, editorState, isTypeAheadOpe
80
87
  return setPlaceHolderState(emptyLinePlaceholder, $from.pos);
81
88
  }
82
89
  }
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;
90
+ 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';
84
91
  if (nodeTypesWithShortPlaceholderText.includes(parentType) && isEmptyNode) {
85
92
  return setPlaceHolderState(SHORT_NODE_PLACEHOLDER_TEXT, $from.pos);
86
93
  }
@@ -41,6 +41,13 @@ export function createPlaceholderDecoration(editorState, placeholderText) {
41
41
  buffNode.textContent = ' ';
42
42
  placeholderDecoration.appendChild(buffNode);
43
43
  }
44
+ var isTargetNested = editorState.doc.resolve(pos).depth > 1;
45
+
46
+ // only truncate text for nested nodes, otherwise applying 'overflow: hidden;' to top level nodes
47
+ // creates issues with quick insert button
48
+ if (isTargetNested && editorExperiment('platform_editor_controls', 'variant1')) {
49
+ placeholderDecoration.classList.add('placeholder-decoration-hide-overflow');
50
+ }
44
51
  return DecorationSet.create(editorState.doc, [Decoration.widget(pos, placeholderDecoration, {
45
52
  side: 0,
46
53
  key: "placeholder ".concat(placeholderText)
@@ -67,7 +74,7 @@ function createPlaceHolderStateFrom(isEditorFocused, editorState, isTypeAheadOpe
67
74
  return setPlaceHolderState(defaultPlaceholderText);
68
75
  }
69
76
  if (isEditorFocused && editorExperiment('platform_editor_controls', 'variant1')) {
70
- var _parentNode$firstChil;
77
+ var _parentNode$firstChil, _parentNode$firstChil2;
71
78
  var _editorState$selectio = editorState.selection,
72
79
  $from = _editorState$selectio.$from,
73
80
  $to = _editorState$selectio.$to;
@@ -82,7 +89,7 @@ function createPlaceHolderStateFrom(isEditorFocused, editorState, isTypeAheadOpe
82
89
  return setPlaceHolderState(emptyLinePlaceholder, $from.pos);
83
90
  }
84
91
  }
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;
92
+ 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';
86
93
  if (nodeTypesWithShortPlaceholderText.includes(parentType) && isEmptyNode) {
87
94
  return setPlaceHolderState(SHORT_NODE_PLACEHOLDER_TEXT, $from.pos);
88
95
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-placeholder",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
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.10.0",
34
+ "@atlaskit/editor-common": "^102.13.0",
35
35
  "@atlaskit/editor-plugin-composition": "^1.3.0",
36
36
  "@atlaskit/editor-plugin-focus": "^1.5.0",
37
- "@atlaskit/editor-plugin-type-ahead": "^2.1.0",
37
+ "@atlaskit/editor-plugin-type-ahead": "^2.2.0",
38
38
  "@atlaskit/editor-prosemirror": "7.0.0",
39
- "@atlaskit/tmp-editor-statsig": "^4.1.0",
39
+ "@atlaskit/tmp-editor-statsig": "^4.4.0",
40
40
  "@babel/runtime": "^7.0.0"
41
41
  },
42
42
  "peerDependencies": {