@atlaskit/editor-plugin-expand 2.3.0 → 2.3.1
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 +9 -0
- package/dist/cjs/singlePlayerExpand/commands.js +27 -6
- package/dist/es2019/singlePlayerExpand/commands.js +28 -8
- package/dist/esm/singlePlayerExpand/commands.js +28 -7
- package/dist/types/singlePlayerExpand/commands.d.ts +1 -1
- package/dist/types-ts4.5/singlePlayerExpand/commands.d.ts +1 -1
- package/package.json +9 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-expand
|
|
2
2
|
|
|
3
|
+
## 2.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#128418](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/128418)
|
|
8
|
+
[`8f46a682011a7`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8f46a682011a7) -
|
|
9
|
+
[ux][ED-24536] Fix: when a single player expand is inserted via main toolbar while selection is
|
|
10
|
+
not empty, it is inserted in closed state
|
|
11
|
+
|
|
3
12
|
## 2.3.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
|
@@ -15,29 +15,50 @@ var _utils = require("@atlaskit/editor-common/utils");
|
|
|
15
15
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
16
16
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
17
17
|
var _utils3 = require("@atlaskit/editor-tables/utils");
|
|
18
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
18
19
|
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; }
|
|
19
20
|
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; }
|
|
20
21
|
// Creates either an expand or a nestedExpand node based on the current selection
|
|
21
22
|
var createExpandNode = exports.createExpandNode = function createExpandNode(state) {
|
|
23
|
+
var setExpandedState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
22
24
|
var _state$schema$nodes = state.schema.nodes,
|
|
23
25
|
expand = _state$schema$nodes.expand,
|
|
24
26
|
nestedExpand = _state$schema$nodes.nestedExpand;
|
|
25
27
|
var expandType = (0, _utils3.findTable)(state.selection) ? nestedExpand : expand;
|
|
26
28
|
var expandNode = expandType.createAndFill({});
|
|
27
|
-
|
|
29
|
+
if (setExpandedState) {
|
|
30
|
+
_expand.expandedState.set(expandNode, true);
|
|
31
|
+
}
|
|
28
32
|
return expandNode;
|
|
29
33
|
};
|
|
30
34
|
var insertExpandWithInputMethod = exports.insertExpandWithInputMethod = function insertExpandWithInputMethod(editorAnalyticsAPI) {
|
|
31
35
|
return function (inputMethod) {
|
|
32
36
|
return function (state, dispatch) {
|
|
33
|
-
var expandNode = createExpandNode(state);
|
|
37
|
+
var expandNode = (0, _platformFeatureFlags.fg)('platform_editor_single_player_expand_ed_24536') ? createExpandNode(state, false) : createExpandNode(state);
|
|
34
38
|
if (!expandNode) {
|
|
35
39
|
return false;
|
|
36
40
|
}
|
|
37
|
-
var tr
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
var tr;
|
|
42
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_single_player_expand_ed_24536')) {
|
|
43
|
+
if (state.selection.empty) {
|
|
44
|
+
tr = (0, _utils2.safeInsert)(expandNode)(state.tr).scrollIntoView();
|
|
45
|
+
_expand.expandedState.set(expandNode, true);
|
|
46
|
+
} else {
|
|
47
|
+
tr = (0, _utils.createWrapSelectionTransaction)({
|
|
48
|
+
state: state,
|
|
49
|
+
type: expandNode.type
|
|
50
|
+
});
|
|
51
|
+
var wrapperNode = (0, _utils2.findParentNodeOfType)(expandNode.type)(tr.selection);
|
|
52
|
+
if (wrapperNode) {
|
|
53
|
+
_expand.expandedState.set(wrapperNode.node, true);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
tr = state.selection.empty ? (0, _utils2.safeInsert)(expandNode)(state.tr).scrollIntoView() : (0, _utils.createWrapSelectionTransaction)({
|
|
58
|
+
state: state,
|
|
59
|
+
type: expandNode.type
|
|
60
|
+
});
|
|
61
|
+
}
|
|
41
62
|
var payload = {
|
|
42
63
|
action: _analytics.ACTION.INSERTED,
|
|
43
64
|
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
@@ -5,28 +5,48 @@ import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
|
5
5
|
import { findExpand } from '@atlaskit/editor-common/transforms';
|
|
6
6
|
import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
7
7
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
-
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
8
|
+
import { findParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
9
9
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
// Creates either an expand or a nestedExpand node based on the current selection
|
|
11
|
-
export const createExpandNode = state => {
|
|
12
|
+
export const createExpandNode = (state, setExpandedState = true) => {
|
|
12
13
|
const {
|
|
13
14
|
expand,
|
|
14
15
|
nestedExpand
|
|
15
16
|
} = state.schema.nodes;
|
|
16
17
|
const expandType = findTable(state.selection) ? nestedExpand : expand;
|
|
17
18
|
const expandNode = expandType.createAndFill({});
|
|
18
|
-
|
|
19
|
+
if (setExpandedState) {
|
|
20
|
+
expandedState.set(expandNode, true);
|
|
21
|
+
}
|
|
19
22
|
return expandNode;
|
|
20
23
|
};
|
|
21
24
|
export const insertExpandWithInputMethod = editorAnalyticsAPI => inputMethod => (state, dispatch) => {
|
|
22
|
-
const expandNode = createExpandNode(state);
|
|
25
|
+
const expandNode = fg('platform_editor_single_player_expand_ed_24536') ? createExpandNode(state, false) : createExpandNode(state);
|
|
23
26
|
if (!expandNode) {
|
|
24
27
|
return false;
|
|
25
28
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
let tr;
|
|
30
|
+
if (fg('platform_editor_single_player_expand_ed_24536')) {
|
|
31
|
+
if (state.selection.empty) {
|
|
32
|
+
tr = safeInsert(expandNode)(state.tr).scrollIntoView();
|
|
33
|
+
expandedState.set(expandNode, true);
|
|
34
|
+
} else {
|
|
35
|
+
tr = createWrapSelectionTransaction({
|
|
36
|
+
state,
|
|
37
|
+
type: expandNode.type
|
|
38
|
+
});
|
|
39
|
+
const wrapperNode = findParentNodeOfType(expandNode.type)(tr.selection);
|
|
40
|
+
if (wrapperNode) {
|
|
41
|
+
expandedState.set(wrapperNode.node, true);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
tr = state.selection.empty ? safeInsert(expandNode)(state.tr).scrollIntoView() : createWrapSelectionTransaction({
|
|
46
|
+
state,
|
|
47
|
+
type: expandNode.type
|
|
48
|
+
});
|
|
49
|
+
}
|
|
30
50
|
const payload = {
|
|
31
51
|
action: ACTION.INSERTED,
|
|
32
52
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
@@ -8,29 +8,50 @@ import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
|
8
8
|
import { findExpand } from '@atlaskit/editor-common/transforms';
|
|
9
9
|
import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
10
10
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
11
|
-
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
11
|
+
import { findParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
12
12
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
13
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
14
|
// Creates either an expand or a nestedExpand node based on the current selection
|
|
14
15
|
export var createExpandNode = function createExpandNode(state) {
|
|
16
|
+
var setExpandedState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
15
17
|
var _state$schema$nodes = state.schema.nodes,
|
|
16
18
|
expand = _state$schema$nodes.expand,
|
|
17
19
|
nestedExpand = _state$schema$nodes.nestedExpand;
|
|
18
20
|
var expandType = findTable(state.selection) ? nestedExpand : expand;
|
|
19
21
|
var expandNode = expandType.createAndFill({});
|
|
20
|
-
|
|
22
|
+
if (setExpandedState) {
|
|
23
|
+
expandedState.set(expandNode, true);
|
|
24
|
+
}
|
|
21
25
|
return expandNode;
|
|
22
26
|
};
|
|
23
27
|
export var insertExpandWithInputMethod = function insertExpandWithInputMethod(editorAnalyticsAPI) {
|
|
24
28
|
return function (inputMethod) {
|
|
25
29
|
return function (state, dispatch) {
|
|
26
|
-
var expandNode = createExpandNode(state);
|
|
30
|
+
var expandNode = fg('platform_editor_single_player_expand_ed_24536') ? createExpandNode(state, false) : createExpandNode(state);
|
|
27
31
|
if (!expandNode) {
|
|
28
32
|
return false;
|
|
29
33
|
}
|
|
30
|
-
var tr
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
var tr;
|
|
35
|
+
if (fg('platform_editor_single_player_expand_ed_24536')) {
|
|
36
|
+
if (state.selection.empty) {
|
|
37
|
+
tr = safeInsert(expandNode)(state.tr).scrollIntoView();
|
|
38
|
+
expandedState.set(expandNode, true);
|
|
39
|
+
} else {
|
|
40
|
+
tr = createWrapSelectionTransaction({
|
|
41
|
+
state: state,
|
|
42
|
+
type: expandNode.type
|
|
43
|
+
});
|
|
44
|
+
var wrapperNode = findParentNodeOfType(expandNode.type)(tr.selection);
|
|
45
|
+
if (wrapperNode) {
|
|
46
|
+
expandedState.set(wrapperNode.node, true);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
tr = state.selection.empty ? safeInsert(expandNode)(state.tr).scrollIntoView() : createWrapSelectionTransaction({
|
|
51
|
+
state: state,
|
|
52
|
+
type: expandNode.type
|
|
53
|
+
});
|
|
54
|
+
}
|
|
34
55
|
var payload = {
|
|
35
56
|
action: ACTION.INSERTED,
|
|
36
57
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
@@ -3,7 +3,7 @@ import type { Command } from '@atlaskit/editor-common/types';
|
|
|
3
3
|
import type { NodeType, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { type InsertMethod } from '../types';
|
|
6
|
-
export declare const createExpandNode: (state: EditorState) => PMNode | null;
|
|
6
|
+
export declare const createExpandNode: (state: EditorState, setExpandedState?: boolean) => PMNode | null;
|
|
7
7
|
export declare const insertExpandWithInputMethod: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod: InsertMethod) => Command;
|
|
8
8
|
export declare const insertExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
9
9
|
export declare const deleteExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
@@ -3,7 +3,7 @@ import type { Command } from '@atlaskit/editor-common/types';
|
|
|
3
3
|
import type { NodeType, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { type InsertMethod } from '../types';
|
|
6
|
-
export declare const createExpandNode: (state: EditorState) => PMNode | null;
|
|
6
|
+
export declare const createExpandNode: (state: EditorState, setExpandedState?: boolean) => PMNode | null;
|
|
7
7
|
export declare const insertExpandWithInputMethod: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod: InsertMethod) => Command;
|
|
8
8
|
export declare const insertExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
9
9
|
export declare const deleteExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-expand",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "Expand plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@atlaskit/adf-schema": "^40.8.1",
|
|
37
|
-
"@atlaskit/button": "^19.
|
|
38
|
-
"@atlaskit/editor-common": "^87.
|
|
37
|
+
"@atlaskit/button": "^19.2.0",
|
|
38
|
+
"@atlaskit/editor-common": "^87.7.0",
|
|
39
39
|
"@atlaskit/editor-plugin-analytics": "^1.7.0",
|
|
40
40
|
"@atlaskit/editor-plugin-decorations": "^1.2.0",
|
|
41
41
|
"@atlaskit/editor-plugin-editor-disabled": "^1.2.0",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"@atlaskit/editor-prosemirror": "5.0.1",
|
|
45
45
|
"@atlaskit/editor-shared-styles": "^2.13.0",
|
|
46
46
|
"@atlaskit/editor-tables": "^2.8.0",
|
|
47
|
-
"@atlaskit/icon": "^22.
|
|
47
|
+
"@atlaskit/icon": "^22.12.0",
|
|
48
48
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
49
|
-
"@atlaskit/tooltip": "^18.
|
|
49
|
+
"@atlaskit/tooltip": "^18.7.0",
|
|
50
50
|
"@babel/runtime": "^7.0.0",
|
|
51
51
|
"@emotion/react": "^11.7.1",
|
|
52
52
|
"w3c-keyname": "^2.1.8"
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@atlaskit/analytics-next": "^10.
|
|
60
|
+
"@atlaskit/analytics-next": "^10.1.0",
|
|
61
61
|
"@atlaskit/editor-plugin-content-insertion": "^1.7.0",
|
|
62
62
|
"@atlaskit/editor-plugin-guideline": "^1.2.0",
|
|
63
63
|
"@atlaskit/editor-plugin-quick-insert": "^1.2.0",
|
|
@@ -110,6 +110,9 @@
|
|
|
110
110
|
},
|
|
111
111
|
"platform.editor.live-view.disable-editing-in-view-mode_fi1rx": {
|
|
112
112
|
"type": "boolean"
|
|
113
|
+
},
|
|
114
|
+
"platform_editor_single_player_expand_ed_24536": {
|
|
115
|
+
"type": "boolean"
|
|
113
116
|
}
|
|
114
117
|
}
|
|
115
118
|
}
|