@atlaskit/editor-plugin-expand 8.1.3 → 8.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 +12 -0
- package/dist/cjs/legacyExpand/nodeviews/index.js +16 -1
- package/dist/cjs/singlePlayerExpand/node-views/index.js +16 -0
- package/dist/cjs/singlePlayerExpand/toolbar.js +1 -1
- package/dist/cjs/singlePlayerExpand/ui/NodeView.js +2 -0
- package/dist/cjs/singlePlayerExpand/utils.js +18 -3
- package/dist/es2019/legacyExpand/nodeviews/index.js +14 -1
- package/dist/es2019/singlePlayerExpand/node-views/index.js +14 -0
- package/dist/es2019/singlePlayerExpand/toolbar.js +2 -2
- package/dist/es2019/singlePlayerExpand/ui/NodeView.js +2 -0
- package/dist/es2019/singlePlayerExpand/utils.js +17 -2
- package/dist/esm/legacyExpand/nodeviews/index.js +16 -1
- package/dist/esm/singlePlayerExpand/node-views/index.js +16 -0
- package/dist/esm/singlePlayerExpand/toolbar.js +2 -2
- package/dist/esm/singlePlayerExpand/ui/NodeView.js +2 -0
- package/dist/esm/singlePlayerExpand/utils.js +17 -2
- package/dist/types/legacyExpand/nodeviews/index.d.ts +1 -0
- package/dist/types/singlePlayerExpand/node-views/index.d.ts +1 -0
- package/dist/types/singlePlayerExpand/utils.d.ts +1 -1
- package/dist/types-ts4.5/legacyExpand/nodeviews/index.d.ts +1 -0
- package/dist/types-ts4.5/singlePlayerExpand/node-views/index.d.ts +1 -0
- package/dist/types-ts4.5/singlePlayerExpand/utils.d.ts +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-expand
|
|
2
2
|
|
|
3
|
+
## 8.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`25991b4c801ab`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/25991b4c801ab) -
|
|
8
|
+
[EDITOR-4884](https://hello.jira.atlassian.cloud/browse/EDITOR-4884) - set `display: none` for
|
|
9
|
+
collapsed Expand
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 8.1.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -64,6 +64,7 @@ var toDOM = function toDOM(node, __livePage, intl, titleReadOnly, contentEditabl
|
|
|
64
64
|
}]]], ['div', {
|
|
65
65
|
// prettier-ignore
|
|
66
66
|
class: _styles.expandClassNames.content,
|
|
67
|
+
style: (0, _expValEquals.expValEquals)('platform_editor_display_none_to_expand', 'isEnabled', true) ? "display: ".concat(__livePage ? !node.attrs.__expanded : node.attrs.__expanded ? 'flow-root' : 'none') : undefined,
|
|
67
68
|
contenteditable: contentEditable !== undefined ? contentEditable ? 'true' : 'false' : undefined
|
|
68
69
|
}, 0]];
|
|
69
70
|
};
|
|
@@ -225,7 +226,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
225
226
|
}
|
|
226
227
|
}
|
|
227
228
|
});
|
|
228
|
-
(0, _defineProperty2.default)(this, "deleteExpand", function (
|
|
229
|
+
(0, _defineProperty2.default)(this, "deleteExpand", function (_event) {
|
|
229
230
|
if (!_this.input) {
|
|
230
231
|
return;
|
|
231
232
|
}
|
|
@@ -536,6 +537,9 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
536
537
|
if (_this2.content) {
|
|
537
538
|
_this2.content.setAttribute('contenteditable', _this2.getContentEditable(_this2.node) ? 'true' : 'false');
|
|
538
539
|
}
|
|
540
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_display_none_to_expand', 'isEnabled', true)) {
|
|
541
|
+
_this2.updateDisplayStyle(_this2.node);
|
|
542
|
+
}
|
|
539
543
|
});
|
|
540
544
|
}
|
|
541
545
|
}
|
|
@@ -569,6 +573,14 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
569
573
|
});
|
|
570
574
|
}, this.icon, this.renderKey);
|
|
571
575
|
}
|
|
576
|
+
}, {
|
|
577
|
+
key: "updateDisplayStyle",
|
|
578
|
+
value: function updateDisplayStyle(node) {
|
|
579
|
+
if (this.content) {
|
|
580
|
+
var isCollapsed = this.__livePage ? node.attrs.__expanded : !node.attrs.__expanded;
|
|
581
|
+
this.content.style.display = isCollapsed ? 'none' : 'flow-root';
|
|
582
|
+
}
|
|
583
|
+
}
|
|
572
584
|
}, {
|
|
573
585
|
key: "stopEvent",
|
|
574
586
|
value: function stopEvent(event) {
|
|
@@ -610,6 +622,9 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
610
622
|
// Disallow interaction/selection inside when collapsed.
|
|
611
623
|
this.content.setAttribute('contenteditable', this.getContentEditable(node) ? 'true' : 'false');
|
|
612
624
|
}
|
|
625
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_display_none_to_expand', 'isEnabled', true)) {
|
|
626
|
+
this.updateDisplayStyle(node);
|
|
627
|
+
}
|
|
613
628
|
}
|
|
614
629
|
|
|
615
630
|
// During a collab session the title doesn't sync with other users
|
|
@@ -97,6 +97,9 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
97
97
|
node: _this.node
|
|
98
98
|
})(_this.view.state, _this.view.dispatch);
|
|
99
99
|
_this.updateExpandToggleIcon(_this.node);
|
|
100
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_display_none_to_expand', 'isEnabled', true)) {
|
|
101
|
+
_this.updateDisplayStyle(_this.node);
|
|
102
|
+
}
|
|
100
103
|
return;
|
|
101
104
|
}
|
|
102
105
|
if (target === _this.input) {
|
|
@@ -215,6 +218,9 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
215
218
|
node: _this.node
|
|
216
219
|
})(state, dispatch);
|
|
217
220
|
_this.updateExpandToggleIcon(_this.node);
|
|
221
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_display_none_to_expand', 'isEnabled', true)) {
|
|
222
|
+
_this.updateDisplayStyle(_this.node);
|
|
223
|
+
}
|
|
218
224
|
}
|
|
219
225
|
});
|
|
220
226
|
(0, _defineProperty2.default)(this, "moveToOutsideOfTitle", function (event) {
|
|
@@ -543,6 +549,9 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
543
549
|
var hasChanged = this.isExpanded !== _expand.expandedState.get(node);
|
|
544
550
|
if (hasChanged) {
|
|
545
551
|
this.updateExpandToggleIcon(node);
|
|
552
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_display_none_to_expand', 'isEnabled', true)) {
|
|
553
|
+
this.updateDisplayStyle(node);
|
|
554
|
+
}
|
|
546
555
|
}
|
|
547
556
|
} else {
|
|
548
557
|
this.node = node;
|
|
@@ -579,6 +588,13 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
579
588
|
this.isExpanded = expanded;
|
|
580
589
|
}
|
|
581
590
|
}
|
|
591
|
+
}, {
|
|
592
|
+
key: "updateDisplayStyle",
|
|
593
|
+
value: function updateDisplayStyle(node) {
|
|
594
|
+
if (this.content) {
|
|
595
|
+
this.content.style.display = (0, _expand.isExpandCollapsed)(node) ? 'none' : 'flow-root';
|
|
596
|
+
}
|
|
597
|
+
}
|
|
582
598
|
}, {
|
|
583
599
|
key: "updateExpandBodyContentEditable",
|
|
584
600
|
value: function updateExpandBodyContentEditable() {
|
|
@@ -17,7 +17,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(api)
|
|
|
17
17
|
var _ref2 = (_api$decorations$acti = api === null || api === void 0 || (_api$decorations = api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions) !== null && _api$decorations$acti !== void 0 ? _api$decorations$acti : {},
|
|
18
18
|
hoverDecoration = _ref2.hoverDecoration;
|
|
19
19
|
var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
20
|
-
var selectedExpandNode = (0, _utils2.
|
|
20
|
+
var selectedExpandNode = (0, _utils2.findSelectedParentExpandNode)(state);
|
|
21
21
|
if (selectedExpandNode) {
|
|
22
22
|
var _state$schema$nodes = state.schema.nodes,
|
|
23
23
|
nestedExpand = _state$schema$nodes.nestedExpand,
|
|
@@ -10,6 +10,7 @@ var _expand = require("@atlaskit/editor-common/expand");
|
|
|
10
10
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
11
11
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
12
12
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
13
14
|
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; }
|
|
14
15
|
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; }
|
|
15
16
|
var buildExpandClassName = exports.buildExpandClassName = function buildExpandClassName(type, expanded) {
|
|
@@ -51,6 +52,7 @@ var toDOM = exports.toDOM = function toDOM(node, __livePage, intl, titleReadOnly
|
|
|
51
52
|
}]]], ['div', {
|
|
52
53
|
// prettier-ignore
|
|
53
54
|
class: _styles.expandClassNames.content,
|
|
55
|
+
style: (0, _expValEquals.expValEquals)('platform_editor_display_none_to_expand', 'isEnabled', true) ? "display: ".concat(_expand.expandedState.get(node) ? 'flow-root' : 'none') : undefined,
|
|
54
56
|
contenteditable: contentEditable !== undefined ? contentEditable ? 'true' : 'false' : undefined
|
|
55
57
|
}, 0]];
|
|
56
58
|
};
|
|
@@ -3,13 +3,28 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.findSelectedParentExpandNode = exports.findReplaceExpandDecorations = void 0;
|
|
7
|
+
var _expand = require("@atlaskit/editor-common/expand");
|
|
7
8
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
9
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
8
10
|
// from platform/packages/editor/editor-plugin-find-replace/src/ui/styles.ts
|
|
9
11
|
var darkModeSearchMatchClass = 'search-match-dark';
|
|
10
12
|
var searchMatchExpandTitleClass = 'search-match-expand-title';
|
|
11
13
|
var selectedSearchMatchClass = 'selected-search-match';
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
+
var findSelectedParentExpandNode = exports.findSelectedParentExpandNode = function findSelectedParentExpandNode(state) {
|
|
15
|
+
var nestedOrParentExpand = (0, _utils.findParentNodeOfType)(state.schema.nodes.nestedExpand)(state.selection) || (0, _utils.findParentNodeOfType)(state.schema.nodes.expand)(state.selection);
|
|
16
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_display_none_to_expand', 'isEnabled', true)) {
|
|
17
|
+
// If it's nested expand, we should check if its parent expand is collapsed.
|
|
18
|
+
// If the parent expand is collapsed, the nested expand is not visible,
|
|
19
|
+
// so it could not be selected.
|
|
20
|
+
// In this case, we return the parent expand node instead of the nested expand node.
|
|
21
|
+
if ((nestedOrParentExpand === null || nestedOrParentExpand === void 0 ? void 0 : nestedOrParentExpand.node.type) === state.schema.nodes.nestedExpand) {
|
|
22
|
+
var parentExpand = (0, _utils.findParentNodeOfType)(state.schema.nodes.expand)(state.selection);
|
|
23
|
+
if (parentExpand && (0, _expand.isExpandCollapsed)(parentExpand.node)) {
|
|
24
|
+
return parentExpand;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return nestedOrParentExpand;
|
|
14
29
|
};
|
|
15
30
|
var findReplaceExpandDecorations = exports.findReplaceExpandDecorations = [darkModeSearchMatchClass, searchMatchExpandTitleClass, selectedSearchMatchClass];
|
|
@@ -53,6 +53,7 @@ const toDOM = (node, __livePage, intl, titleReadOnly, contentEditable) => ['div'
|
|
|
53
53
|
}]]], ['div', {
|
|
54
54
|
// prettier-ignore
|
|
55
55
|
class: expandClassNames.content,
|
|
56
|
+
style: expValEquals('platform_editor_display_none_to_expand', 'isEnabled', true) ? `display: ${__livePage ? !node.attrs.__expanded : node.attrs.__expanded ? 'flow-root' : 'none'}` : undefined,
|
|
56
57
|
contenteditable: contentEditable !== undefined ? contentEditable ? 'true' : 'false' : undefined
|
|
57
58
|
}, 0]];
|
|
58
59
|
export class ExpandNodeView {
|
|
@@ -211,7 +212,7 @@ export class ExpandNodeView {
|
|
|
211
212
|
}
|
|
212
213
|
}
|
|
213
214
|
});
|
|
214
|
-
_defineProperty(this, "deleteExpand",
|
|
215
|
+
_defineProperty(this, "deleteExpand", _event => {
|
|
215
216
|
if (!this.input) {
|
|
216
217
|
return;
|
|
217
218
|
}
|
|
@@ -537,6 +538,9 @@ export class ExpandNodeView {
|
|
|
537
538
|
if (this.content) {
|
|
538
539
|
this.content.setAttribute('contenteditable', this.getContentEditable(this.node) ? 'true' : 'false');
|
|
539
540
|
}
|
|
541
|
+
if (expValEquals('platform_editor_display_none_to_expand', 'isEnabled', true)) {
|
|
542
|
+
this.updateDisplayStyle(this.node);
|
|
543
|
+
}
|
|
540
544
|
});
|
|
541
545
|
}
|
|
542
546
|
}
|
|
@@ -566,6 +570,12 @@ export class ExpandNodeView {
|
|
|
566
570
|
expanded: this.__livePage ? !__expanded : __expanded
|
|
567
571
|
}), this.icon, this.renderKey);
|
|
568
572
|
}
|
|
573
|
+
updateDisplayStyle(node) {
|
|
574
|
+
if (this.content) {
|
|
575
|
+
const isCollapsed = this.__livePage ? node.attrs.__expanded : !node.attrs.__expanded;
|
|
576
|
+
this.content.style.display = isCollapsed ? 'none' : 'flow-root';
|
|
577
|
+
}
|
|
578
|
+
}
|
|
569
579
|
stopEvent(event) {
|
|
570
580
|
// Ignored via go/ees005
|
|
571
581
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
@@ -600,6 +610,9 @@ export class ExpandNodeView {
|
|
|
600
610
|
// Disallow interaction/selection inside when collapsed.
|
|
601
611
|
this.content.setAttribute('contenteditable', this.getContentEditable(node) ? 'true' : 'false');
|
|
602
612
|
}
|
|
613
|
+
if (expValEquals('platform_editor_display_none_to_expand', 'isEnabled', true)) {
|
|
614
|
+
this.updateDisplayStyle(node);
|
|
615
|
+
}
|
|
603
616
|
}
|
|
604
617
|
|
|
605
618
|
// During a collab session the title doesn't sync with other users
|
|
@@ -81,6 +81,9 @@ export class ExpandNodeView {
|
|
|
81
81
|
node: this.node
|
|
82
82
|
})(this.view.state, this.view.dispatch);
|
|
83
83
|
this.updateExpandToggleIcon(this.node);
|
|
84
|
+
if (expValEquals('platform_editor_display_none_to_expand', 'isEnabled', true)) {
|
|
85
|
+
this.updateDisplayStyle(this.node);
|
|
86
|
+
}
|
|
84
87
|
return;
|
|
85
88
|
}
|
|
86
89
|
if (target === this.input) {
|
|
@@ -204,6 +207,9 @@ export class ExpandNodeView {
|
|
|
204
207
|
node: this.node
|
|
205
208
|
})(state, dispatch);
|
|
206
209
|
this.updateExpandToggleIcon(this.node);
|
|
210
|
+
if (expValEquals('platform_editor_display_none_to_expand', 'isEnabled', true)) {
|
|
211
|
+
this.updateDisplayStyle(this.node);
|
|
212
|
+
}
|
|
207
213
|
}
|
|
208
214
|
});
|
|
209
215
|
_defineProperty(this, "moveToOutsideOfTitle", event => {
|
|
@@ -537,6 +543,9 @@ export class ExpandNodeView {
|
|
|
537
543
|
const hasChanged = this.isExpanded !== expandedState.get(node);
|
|
538
544
|
if (hasChanged) {
|
|
539
545
|
this.updateExpandToggleIcon(node);
|
|
546
|
+
if (expValEquals('platform_editor_display_none_to_expand', 'isEnabled', true)) {
|
|
547
|
+
this.updateDisplayStyle(node);
|
|
548
|
+
}
|
|
540
549
|
}
|
|
541
550
|
} else {
|
|
542
551
|
this.node = node;
|
|
@@ -569,6 +578,11 @@ export class ExpandNodeView {
|
|
|
569
578
|
this.isExpanded = expanded;
|
|
570
579
|
}
|
|
571
580
|
}
|
|
581
|
+
updateDisplayStyle(node) {
|
|
582
|
+
if (this.content) {
|
|
583
|
+
this.content.style.display = isExpandCollapsed(node) ? 'none' : 'flow-root';
|
|
584
|
+
}
|
|
585
|
+
}
|
|
572
586
|
updateExpandBodyContentEditable() {
|
|
573
587
|
// Disallow interaction/selection inside expand body when collapsed.
|
|
574
588
|
if (this.content) {
|
|
@@ -2,7 +2,7 @@ import commonMessages from '@atlaskit/editor-common/messages';
|
|
|
2
2
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
3
3
|
import DeleteIcon from '@atlaskit/icon/core/delete';
|
|
4
4
|
import { deleteExpand } from './commands';
|
|
5
|
-
import {
|
|
5
|
+
import { findSelectedParentExpandNode } from './utils';
|
|
6
6
|
export const getToolbarConfig = api => (state, {
|
|
7
7
|
formatMessage
|
|
8
8
|
}) => {
|
|
@@ -11,7 +11,7 @@ export const getToolbarConfig = api => (state, {
|
|
|
11
11
|
hoverDecoration
|
|
12
12
|
} = (_api$decorations$acti = api === null || api === void 0 ? void 0 : (_api$decorations = api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions) !== null && _api$decorations$acti !== void 0 ? _api$decorations$acti : {};
|
|
13
13
|
const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
14
|
-
const selectedExpandNode =
|
|
14
|
+
const selectedExpandNode = findSelectedParentExpandNode(state);
|
|
15
15
|
if (selectedExpandNode) {
|
|
16
16
|
const {
|
|
17
17
|
nestedExpand,
|
|
@@ -2,6 +2,7 @@ import { expandedState } from '@atlaskit/editor-common/expand';
|
|
|
2
2
|
import { expandClassNames } from '@atlaskit/editor-common/styles';
|
|
3
3
|
import { expandMessages } from '@atlaskit/editor-common/ui';
|
|
4
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
6
|
export const buildExpandClassName = (type, expanded) => {
|
|
6
7
|
return `${expandClassNames.prefix} ${expandClassNames.type(type)} ${expanded ? expandClassNames.expanded : ''}`;
|
|
7
8
|
};
|
|
@@ -42,6 +43,7 @@ export const toDOM = (node, __livePage, intl, titleReadOnly, contentEditable) =>
|
|
|
42
43
|
}]]], ['div', {
|
|
43
44
|
// prettier-ignore
|
|
44
45
|
class: expandClassNames.content,
|
|
46
|
+
style: expValEquals('platform_editor_display_none_to_expand', 'isEnabled', true) ? `display: ${expandedState.get(node) ? 'flow-root' : 'none'}` : undefined,
|
|
45
47
|
contenteditable: contentEditable !== undefined ? contentEditable ? 'true' : 'false' : undefined
|
|
46
48
|
}, 0]];
|
|
47
49
|
};
|
|
@@ -1,10 +1,25 @@
|
|
|
1
|
+
import { isExpandCollapsed } from '@atlaskit/editor-common/expand';
|
|
1
2
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
2
4
|
|
|
3
5
|
// from platform/packages/editor/editor-plugin-find-replace/src/ui/styles.ts
|
|
4
6
|
const darkModeSearchMatchClass = 'search-match-dark';
|
|
5
7
|
const searchMatchExpandTitleClass = 'search-match-expand-title';
|
|
6
8
|
const selectedSearchMatchClass = 'selected-search-match';
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
+
export const findSelectedParentExpandNode = state => {
|
|
10
|
+
const nestedOrParentExpand = findParentNodeOfType(state.schema.nodes.nestedExpand)(state.selection) || findParentNodeOfType(state.schema.nodes.expand)(state.selection);
|
|
11
|
+
if (expValEquals('platform_editor_display_none_to_expand', 'isEnabled', true)) {
|
|
12
|
+
// If it's nested expand, we should check if its parent expand is collapsed.
|
|
13
|
+
// If the parent expand is collapsed, the nested expand is not visible,
|
|
14
|
+
// so it could not be selected.
|
|
15
|
+
// In this case, we return the parent expand node instead of the nested expand node.
|
|
16
|
+
if ((nestedOrParentExpand === null || nestedOrParentExpand === void 0 ? void 0 : nestedOrParentExpand.node.type) === state.schema.nodes.nestedExpand) {
|
|
17
|
+
const parentExpand = findParentNodeOfType(state.schema.nodes.expand)(state.selection);
|
|
18
|
+
if (parentExpand && isExpandCollapsed(parentExpand.node)) {
|
|
19
|
+
return parentExpand;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return nestedOrParentExpand;
|
|
9
24
|
};
|
|
10
25
|
export const findReplaceExpandDecorations = [darkModeSearchMatchClass, searchMatchExpandTitleClass, selectedSearchMatchClass];
|
|
@@ -57,6 +57,7 @@ var toDOM = function toDOM(node, __livePage, intl, titleReadOnly, contentEditabl
|
|
|
57
57
|
}]]], ['div', {
|
|
58
58
|
// prettier-ignore
|
|
59
59
|
class: expandClassNames.content,
|
|
60
|
+
style: expValEquals('platform_editor_display_none_to_expand', 'isEnabled', true) ? "display: ".concat(__livePage ? !node.attrs.__expanded : node.attrs.__expanded ? 'flow-root' : 'none') : undefined,
|
|
60
61
|
contenteditable: contentEditable !== undefined ? contentEditable ? 'true' : 'false' : undefined
|
|
61
62
|
}, 0]];
|
|
62
63
|
};
|
|
@@ -218,7 +219,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
218
219
|
}
|
|
219
220
|
}
|
|
220
221
|
});
|
|
221
|
-
_defineProperty(this, "deleteExpand", function (
|
|
222
|
+
_defineProperty(this, "deleteExpand", function (_event) {
|
|
222
223
|
if (!_this.input) {
|
|
223
224
|
return;
|
|
224
225
|
}
|
|
@@ -529,6 +530,9 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
529
530
|
if (_this2.content) {
|
|
530
531
|
_this2.content.setAttribute('contenteditable', _this2.getContentEditable(_this2.node) ? 'true' : 'false');
|
|
531
532
|
}
|
|
533
|
+
if (expValEquals('platform_editor_display_none_to_expand', 'isEnabled', true)) {
|
|
534
|
+
_this2.updateDisplayStyle(_this2.node);
|
|
535
|
+
}
|
|
532
536
|
});
|
|
533
537
|
}
|
|
534
538
|
}
|
|
@@ -562,6 +566,14 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
562
566
|
});
|
|
563
567
|
}, this.icon, this.renderKey);
|
|
564
568
|
}
|
|
569
|
+
}, {
|
|
570
|
+
key: "updateDisplayStyle",
|
|
571
|
+
value: function updateDisplayStyle(node) {
|
|
572
|
+
if (this.content) {
|
|
573
|
+
var isCollapsed = this.__livePage ? node.attrs.__expanded : !node.attrs.__expanded;
|
|
574
|
+
this.content.style.display = isCollapsed ? 'none' : 'flow-root';
|
|
575
|
+
}
|
|
576
|
+
}
|
|
565
577
|
}, {
|
|
566
578
|
key: "stopEvent",
|
|
567
579
|
value: function stopEvent(event) {
|
|
@@ -603,6 +615,9 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
603
615
|
// Disallow interaction/selection inside when collapsed.
|
|
604
616
|
this.content.setAttribute('contenteditable', this.getContentEditable(node) ? 'true' : 'false');
|
|
605
617
|
}
|
|
618
|
+
if (expValEquals('platform_editor_display_none_to_expand', 'isEnabled', true)) {
|
|
619
|
+
this.updateDisplayStyle(node);
|
|
620
|
+
}
|
|
606
621
|
}
|
|
607
622
|
|
|
608
623
|
// During a collab session the title doesn't sync with other users
|
|
@@ -89,6 +89,9 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
89
89
|
node: _this.node
|
|
90
90
|
})(_this.view.state, _this.view.dispatch);
|
|
91
91
|
_this.updateExpandToggleIcon(_this.node);
|
|
92
|
+
if (expValEquals('platform_editor_display_none_to_expand', 'isEnabled', true)) {
|
|
93
|
+
_this.updateDisplayStyle(_this.node);
|
|
94
|
+
}
|
|
92
95
|
return;
|
|
93
96
|
}
|
|
94
97
|
if (target === _this.input) {
|
|
@@ -207,6 +210,9 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
207
210
|
node: _this.node
|
|
208
211
|
})(state, dispatch);
|
|
209
212
|
_this.updateExpandToggleIcon(_this.node);
|
|
213
|
+
if (expValEquals('platform_editor_display_none_to_expand', 'isEnabled', true)) {
|
|
214
|
+
_this.updateDisplayStyle(_this.node);
|
|
215
|
+
}
|
|
210
216
|
}
|
|
211
217
|
});
|
|
212
218
|
_defineProperty(this, "moveToOutsideOfTitle", function (event) {
|
|
@@ -535,6 +541,9 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
535
541
|
var hasChanged = this.isExpanded !== expandedState.get(node);
|
|
536
542
|
if (hasChanged) {
|
|
537
543
|
this.updateExpandToggleIcon(node);
|
|
544
|
+
if (expValEquals('platform_editor_display_none_to_expand', 'isEnabled', true)) {
|
|
545
|
+
this.updateDisplayStyle(node);
|
|
546
|
+
}
|
|
538
547
|
}
|
|
539
548
|
} else {
|
|
540
549
|
this.node = node;
|
|
@@ -571,6 +580,13 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
571
580
|
this.isExpanded = expanded;
|
|
572
581
|
}
|
|
573
582
|
}
|
|
583
|
+
}, {
|
|
584
|
+
key: "updateDisplayStyle",
|
|
585
|
+
value: function updateDisplayStyle(node) {
|
|
586
|
+
if (this.content) {
|
|
587
|
+
this.content.style.display = isExpandCollapsed(node) ? 'none' : 'flow-root';
|
|
588
|
+
}
|
|
589
|
+
}
|
|
574
590
|
}, {
|
|
575
591
|
key: "updateExpandBodyContentEditable",
|
|
576
592
|
value: function updateExpandBodyContentEditable() {
|
|
@@ -2,7 +2,7 @@ import commonMessages from '@atlaskit/editor-common/messages';
|
|
|
2
2
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
3
3
|
import DeleteIcon from '@atlaskit/icon/core/delete';
|
|
4
4
|
import { deleteExpand } from './commands';
|
|
5
|
-
import {
|
|
5
|
+
import { findSelectedParentExpandNode } from './utils';
|
|
6
6
|
export var getToolbarConfig = function getToolbarConfig(api) {
|
|
7
7
|
return function (state, _ref) {
|
|
8
8
|
var _api$decorations$acti, _api$decorations, _api$analytics;
|
|
@@ -10,7 +10,7 @@ export var getToolbarConfig = function getToolbarConfig(api) {
|
|
|
10
10
|
var _ref2 = (_api$decorations$acti = api === null || api === void 0 || (_api$decorations = api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions) !== null && _api$decorations$acti !== void 0 ? _api$decorations$acti : {},
|
|
11
11
|
hoverDecoration = _ref2.hoverDecoration;
|
|
12
12
|
var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
13
|
-
var selectedExpandNode =
|
|
13
|
+
var selectedExpandNode = findSelectedParentExpandNode(state);
|
|
14
14
|
if (selectedExpandNode) {
|
|
15
15
|
var _state$schema$nodes = state.schema.nodes,
|
|
16
16
|
nestedExpand = _state$schema$nodes.nestedExpand,
|
|
@@ -5,6 +5,7 @@ import { expandedState } from '@atlaskit/editor-common/expand';
|
|
|
5
5
|
import { expandClassNames } from '@atlaskit/editor-common/styles';
|
|
6
6
|
import { expandMessages } from '@atlaskit/editor-common/ui';
|
|
7
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
8
9
|
export var buildExpandClassName = function buildExpandClassName(type, expanded) {
|
|
9
10
|
return "".concat(expandClassNames.prefix, " ").concat(expandClassNames.type(type), " ").concat(expanded ? expandClassNames.expanded : '');
|
|
10
11
|
};
|
|
@@ -44,6 +45,7 @@ export var toDOM = function toDOM(node, __livePage, intl, titleReadOnly, content
|
|
|
44
45
|
}]]], ['div', {
|
|
45
46
|
// prettier-ignore
|
|
46
47
|
class: expandClassNames.content,
|
|
48
|
+
style: expValEquals('platform_editor_display_none_to_expand', 'isEnabled', true) ? "display: ".concat(expandedState.get(node) ? 'flow-root' : 'none') : undefined,
|
|
47
49
|
contenteditable: contentEditable !== undefined ? contentEditable ? 'true' : 'false' : undefined
|
|
48
50
|
}, 0]];
|
|
49
51
|
};
|
|
@@ -1,10 +1,25 @@
|
|
|
1
|
+
import { isExpandCollapsed } from '@atlaskit/editor-common/expand';
|
|
1
2
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
2
4
|
|
|
3
5
|
// from platform/packages/editor/editor-plugin-find-replace/src/ui/styles.ts
|
|
4
6
|
var darkModeSearchMatchClass = 'search-match-dark';
|
|
5
7
|
var searchMatchExpandTitleClass = 'search-match-expand-title';
|
|
6
8
|
var selectedSearchMatchClass = 'selected-search-match';
|
|
7
|
-
export var
|
|
8
|
-
|
|
9
|
+
export var findSelectedParentExpandNode = function findSelectedParentExpandNode(state) {
|
|
10
|
+
var nestedOrParentExpand = findParentNodeOfType(state.schema.nodes.nestedExpand)(state.selection) || findParentNodeOfType(state.schema.nodes.expand)(state.selection);
|
|
11
|
+
if (expValEquals('platform_editor_display_none_to_expand', 'isEnabled', true)) {
|
|
12
|
+
// If it's nested expand, we should check if its parent expand is collapsed.
|
|
13
|
+
// If the parent expand is collapsed, the nested expand is not visible,
|
|
14
|
+
// so it could not be selected.
|
|
15
|
+
// In this case, we return the parent expand node instead of the nested expand node.
|
|
16
|
+
if ((nestedOrParentExpand === null || nestedOrParentExpand === void 0 ? void 0 : nestedOrParentExpand.node.type) === state.schema.nodes.nestedExpand) {
|
|
17
|
+
var parentExpand = findParentNodeOfType(state.schema.nodes.expand)(state.selection);
|
|
18
|
+
if (parentExpand && isExpandCollapsed(parentExpand.node)) {
|
|
19
|
+
return parentExpand;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return nestedOrParentExpand;
|
|
9
24
|
};
|
|
10
25
|
export var findReplaceExpandDecorations = [darkModeSearchMatchClass, searchMatchExpandTitleClass, selectedSearchMatchClass];
|
|
@@ -49,6 +49,7 @@ export declare class ExpandNodeView implements NodeView {
|
|
|
49
49
|
private handleUndoFromTitle;
|
|
50
50
|
private handleRedoFromTitle;
|
|
51
51
|
private getContentEditable;
|
|
52
|
+
private updateDisplayStyle;
|
|
52
53
|
stopEvent(event: Event): boolean;
|
|
53
54
|
ignoreMutation(mutationRecord: MutationRecord | {
|
|
54
55
|
target: Node;
|
|
@@ -54,6 +54,7 @@ export declare class ExpandNodeView implements NodeView {
|
|
|
54
54
|
}): boolean;
|
|
55
55
|
update(node: PmNode, _decorations: readonly Decoration[]): boolean;
|
|
56
56
|
updateExpandToggleIcon(node: PmNode): void;
|
|
57
|
+
private updateDisplayStyle;
|
|
57
58
|
updateExpandBodyContentEditable(): void;
|
|
58
59
|
private renderNativeIcon;
|
|
59
60
|
renderIcon: (icon: HTMLElement | null, expanded: boolean) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const findSelectedParentExpandNode: (state: EditorState) => ReturnType<ReturnType<typeof findParentNodeOfType>>;
|
|
4
4
|
export declare const findReplaceExpandDecorations: string[];
|
|
@@ -49,6 +49,7 @@ export declare class ExpandNodeView implements NodeView {
|
|
|
49
49
|
private handleUndoFromTitle;
|
|
50
50
|
private handleRedoFromTitle;
|
|
51
51
|
private getContentEditable;
|
|
52
|
+
private updateDisplayStyle;
|
|
52
53
|
stopEvent(event: Event): boolean;
|
|
53
54
|
ignoreMutation(mutationRecord: MutationRecord | {
|
|
54
55
|
target: Node;
|
|
@@ -54,6 +54,7 @@ export declare class ExpandNodeView implements NodeView {
|
|
|
54
54
|
}): boolean;
|
|
55
55
|
update(node: PmNode, _decorations: readonly Decoration[]): boolean;
|
|
56
56
|
updateExpandToggleIcon(node: PmNode): void;
|
|
57
|
+
private updateDisplayStyle;
|
|
57
58
|
updateExpandBodyContentEditable(): void;
|
|
58
59
|
private renderNativeIcon;
|
|
59
60
|
renderIcon: (icon: HTMLElement | null, expanded: boolean) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const findSelectedParentExpandNode: (state: EditorState) => ReturnType<ReturnType<typeof findParentNodeOfType>>;
|
|
4
4
|
export declare const findReplaceExpandDecorations: string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-expand",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.2.0",
|
|
4
4
|
"description": "Expand plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"@atlaskit/icon-lab": "^5.15.0",
|
|
49
49
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
50
50
|
"@atlaskit/prosemirror-history": "^0.2.0",
|
|
51
|
-
"@atlaskit/tmp-editor-statsig": "^17.
|
|
52
|
-
"@atlaskit/tokens": "^
|
|
51
|
+
"@atlaskit/tmp-editor-statsig": "^17.10.0",
|
|
52
|
+
"@atlaskit/tokens": "^11.0.0",
|
|
53
53
|
"@atlaskit/tooltip": "^20.14.0",
|
|
54
54
|
"@babel/runtime": "^7.0.0",
|
|
55
55
|
"@emotion/react": "^11.7.1",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"w3c-keyname": "^2.1.8"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@atlaskit/editor-common": "^111.
|
|
60
|
+
"@atlaskit/editor-common": "^111.11.0",
|
|
61
61
|
"react": "^18.2.0",
|
|
62
62
|
"react-dom": "^18.2.0",
|
|
63
63
|
"react-intl-next": "npm:react-intl@^5.18.1"
|