@atlaskit/editor-plugin-expand 2.2.1 → 2.3.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 +18 -0
- package/dist/cjs/legacyExpand/commands.js +34 -27
- package/dist/cjs/legacyExpand/plugin.js +5 -4
- package/dist/cjs/singlePlayerExpand/commands.js +30 -23
- package/dist/cjs/singlePlayerExpand/plugin.js +5 -4
- package/dist/es2019/legacyExpand/commands.js +10 -7
- package/dist/es2019/legacyExpand/plugin.js +6 -5
- package/dist/es2019/singlePlayerExpand/commands.js +5 -3
- package/dist/es2019/singlePlayerExpand/plugin.js +6 -5
- package/dist/esm/legacyExpand/commands.js +34 -27
- package/dist/esm/legacyExpand/plugin.js +6 -5
- package/dist/esm/singlePlayerExpand/commands.js +29 -23
- package/dist/esm/singlePlayerExpand/plugin.js +6 -5
- package/dist/types/index.d.ts +1 -1
- package/dist/types/legacyExpand/commands.d.ts +2 -0
- package/dist/types/singlePlayerExpand/commands.d.ts +2 -0
- package/dist/types/types.d.ts +10 -1
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/legacyExpand/commands.d.ts +2 -0
- package/dist/types-ts4.5/singlePlayerExpand/commands.d.ts +2 -0
- package/dist/types-ts4.5/types.d.ts +10 -1
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-expand
|
|
2
2
|
|
|
3
|
+
## 2.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#128347](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/128347)
|
|
8
|
+
[`e33566cebd5d1`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e33566cebd5d1) -
|
|
9
|
+
[ED-24175] bump @atlaskit/adf-schema to 40.8.1 and @atlassian/adf-schema-json to 1.22.0 to
|
|
10
|
+
promotecodeblocks & media in quotes, and nested expands in expands to full schema, and allow
|
|
11
|
+
quotes in panels and decisions in lists in stage0 schema, and a validator spec change
|
|
12
|
+
- [#128333](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/128333)
|
|
13
|
+
[`4ad86751ab1d7`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4ad86751ab1d7) -
|
|
14
|
+
[ED-24505] Implement onClick handler for Turn into dropdown options and update relevant insertion
|
|
15
|
+
analytics with inputMethod: floatingToolbar when an element is inserted via the dropdown
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 2.2.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.updateExpandTitle = exports.toggleExpandExpanded = exports.setSelectionInsideExpand = exports.setExpandRef = exports.insertExpand = exports.focusTitle = exports.deleteExpandAtPos = exports.deleteExpand = exports.createExpandNode = void 0;
|
|
7
|
+
exports.updateExpandTitle = exports.toggleExpandExpanded = exports.setSelectionInsideExpand = exports.setExpandRef = exports.insertExpandWithInputMethod = exports.insertExpand = exports.focusTitle = exports.deleteExpandAtPos = exports.deleteExpand = exports.createExpandNode = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _steps = require("@atlaskit/adf-schema/steps");
|
|
10
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
@@ -70,7 +70,7 @@ var updateExpandTitle = exports.updateExpandTitle = function updateExpandTitle(_
|
|
|
70
70
|
var node = state.doc.nodeAt(pos);
|
|
71
71
|
if (node && node.type === nodeType && dispatch) {
|
|
72
72
|
var tr = state.tr;
|
|
73
|
-
if ((0, _platformFeatureFlags.
|
|
73
|
+
if (__livePage && (0, _platformFeatureFlags.fg)('platform.editor.live-pages-expand-divergence')) {
|
|
74
74
|
tr.step(new _steps.SetAttrsStep(pos, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
75
75
|
title: title
|
|
76
76
|
})));
|
|
@@ -94,7 +94,7 @@ var toggleExpandExpanded = exports.toggleExpandExpanded = function toggleExpandE
|
|
|
94
94
|
if (node && node.type === nodeType && dispatch) {
|
|
95
95
|
var tr = state.tr;
|
|
96
96
|
var isExpandedNext = !node.attrs.__expanded;
|
|
97
|
-
if ((0, _platformFeatureFlags.
|
|
97
|
+
if (__livePage && (0, _platformFeatureFlags.fg)('platform.editor.live-pages-expand-divergence')) {
|
|
98
98
|
tr.step(new _steps.SetAttrsStep(pos, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
99
99
|
__expanded: isExpandedNext
|
|
100
100
|
})));
|
|
@@ -107,7 +107,7 @@ var toggleExpandExpanded = exports.toggleExpandExpanded = function toggleExpandE
|
|
|
107
107
|
// If we're going to collapse the expand and our cursor is currently inside
|
|
108
108
|
// Move to a right gap cursor, if the toolbar is interacted (or an API),
|
|
109
109
|
// it will insert below rather than inside (which will be invisible).
|
|
110
|
-
if ((0, _platformFeatureFlags.
|
|
110
|
+
if (__livePage && (0, _platformFeatureFlags.fg)('platform.editor.live-pages-expand-divergence') ? isExpandedNext === true : isExpandedNext === false && (0, _utils4.findExpand)(state)) {
|
|
111
111
|
tr.setSelection(new _selection.GapCursorSelection(tr.doc.resolve(pos + node.nodeSize), _selection.Side.RIGHT));
|
|
112
112
|
}
|
|
113
113
|
|
|
@@ -119,7 +119,7 @@ var toggleExpandExpanded = exports.toggleExpandExpanded = function toggleExpandE
|
|
|
119
119
|
attributes: {
|
|
120
120
|
platform: _analytics.PLATFORMS.WEB,
|
|
121
121
|
mode: _analytics.MODE.EDITOR,
|
|
122
|
-
expanded: (0, _platformFeatureFlags.
|
|
122
|
+
expanded: __livePage && (0, _platformFeatureFlags.fg)('platform.editor.live-pages-expand-divergence') ? !isExpandedNext : isExpandedNext
|
|
123
123
|
},
|
|
124
124
|
eventType: _analytics.EVENT_TYPE.TRACK
|
|
125
125
|
};
|
|
@@ -142,30 +142,37 @@ var createExpandNode = exports.createExpandNode = function createExpandNode(stat
|
|
|
142
142
|
var expandType = (0, _utils3.findTable)(state.selection) ? nestedExpand : expand;
|
|
143
143
|
return expandType.createAndFill({});
|
|
144
144
|
};
|
|
145
|
+
var insertExpandWithInputMethod = exports.insertExpandWithInputMethod = function insertExpandWithInputMethod(editorAnalyticsAPI) {
|
|
146
|
+
return function (inputMethod) {
|
|
147
|
+
return function (state, dispatch) {
|
|
148
|
+
var expandNode = createExpandNode(state);
|
|
149
|
+
if (!expandNode) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
var tr = state.selection.empty ? (0, _utils2.safeInsert)(expandNode)(state.tr).scrollIntoView() : (0, _utils.createWrapSelectionTransaction)({
|
|
153
|
+
state: state,
|
|
154
|
+
type: expandNode.type
|
|
155
|
+
});
|
|
156
|
+
var payload = {
|
|
157
|
+
action: _analytics.ACTION.INSERTED,
|
|
158
|
+
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
159
|
+
actionSubjectId: (expandNode === null || expandNode === void 0 ? void 0 : expandNode.type) === state.schema.nodes.expand ? _analytics.ACTION_SUBJECT_ID.EXPAND : _analytics.ACTION_SUBJECT_ID.NESTED_EXPAND,
|
|
160
|
+
attributes: {
|
|
161
|
+
inputMethod: inputMethod
|
|
162
|
+
},
|
|
163
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
164
|
+
};
|
|
165
|
+
if (dispatch && expandNode) {
|
|
166
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
|
|
167
|
+
dispatch(tr);
|
|
168
|
+
}
|
|
169
|
+
return true;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
};
|
|
145
173
|
var insertExpand = exports.insertExpand = function insertExpand(editorAnalyticsAPI) {
|
|
146
174
|
return function (state, dispatch) {
|
|
147
|
-
|
|
148
|
-
if (!expandNode) {
|
|
149
|
-
return false;
|
|
150
|
-
}
|
|
151
|
-
var tr = state.selection.empty ? (0, _utils2.safeInsert)(expandNode)(state.tr).scrollIntoView() : (0, _utils.createWrapSelectionTransaction)({
|
|
152
|
-
state: state,
|
|
153
|
-
type: expandNode.type
|
|
154
|
-
});
|
|
155
|
-
var payload = {
|
|
156
|
-
action: _analytics.ACTION.INSERTED,
|
|
157
|
-
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
158
|
-
actionSubjectId: (expandNode === null || expandNode === void 0 ? void 0 : expandNode.type) === state.schema.nodes.expand ? _analytics.ACTION_SUBJECT_ID.EXPAND : _analytics.ACTION_SUBJECT_ID.NESTED_EXPAND,
|
|
159
|
-
attributes: {
|
|
160
|
-
inputMethod: _analytics.INPUT_METHOD.INSERT_MENU
|
|
161
|
-
},
|
|
162
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
163
|
-
};
|
|
164
|
-
if (dispatch && expandNode) {
|
|
165
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
|
|
166
|
-
dispatch(tr);
|
|
167
|
-
}
|
|
168
|
-
return true;
|
|
175
|
+
return insertExpandWithInputMethod(editorAnalyticsAPI)(_analytics.INPUT_METHOD.INSERT_MENU)(state, dispatch);
|
|
169
176
|
};
|
|
170
177
|
};
|
|
171
178
|
var focusTitle = exports.focusTitle = function focusTitle(pos) {
|
|
@@ -23,7 +23,7 @@ var _main = require("./pm-plugins/main");
|
|
|
23
23
|
var _toolbar = require("./toolbar");
|
|
24
24
|
var _pluginFactory = require("./pm-plugins/plugin-factory");
|
|
25
25
|
var expandPlugin = exports.expandPlugin = function expandPlugin(_ref) {
|
|
26
|
-
var _api$analytics;
|
|
26
|
+
var _api$analytics, _api$analytics2;
|
|
27
27
|
var _ref$config = _ref.config,
|
|
28
28
|
options = _ref$config === void 0 ? {} : _ref$config,
|
|
29
29
|
api = _ref.api;
|
|
@@ -39,7 +39,8 @@ var expandPlugin = exports.expandPlugin = function expandPlugin(_ref) {
|
|
|
39
39
|
}];
|
|
40
40
|
},
|
|
41
41
|
actions: {
|
|
42
|
-
insertExpand: (0, _commands.insertExpand)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
|
|
42
|
+
insertExpand: (0, _commands.insertExpand)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions),
|
|
43
|
+
insertExpandWithInputMethod: (0, _commands.insertExpandWithInputMethod)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
43
44
|
},
|
|
44
45
|
pmPlugins: function pmPlugins() {
|
|
45
46
|
return [{
|
|
@@ -76,7 +77,7 @@ var expandPlugin = exports.expandPlugin = function expandPlugin(_ref) {
|
|
|
76
77
|
return /*#__PURE__*/_react.default.createElement(_quickInsert.IconExpand, null);
|
|
77
78
|
},
|
|
78
79
|
action: function action(insert, state) {
|
|
79
|
-
var _api$
|
|
80
|
+
var _api$analytics3;
|
|
80
81
|
var node = (0, _commands.createExpandNode)(state);
|
|
81
82
|
if (!node) {
|
|
82
83
|
return false;
|
|
@@ -85,7 +86,7 @@ var expandPlugin = exports.expandPlugin = function expandPlugin(_ref) {
|
|
|
85
86
|
state: state,
|
|
86
87
|
type: node.type
|
|
87
88
|
});
|
|
88
|
-
api === null || api === void 0 || (_api$
|
|
89
|
+
api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 || _api$analytics3.actions.attachAnalyticsEvent({
|
|
89
90
|
action: _analytics.ACTION.INSERTED,
|
|
90
91
|
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
91
92
|
actionSubjectId: node.type === state.schema.nodes.nestedExpand ? _analytics.ACTION_SUBJECT_ID.NESTED_EXPAND : _analytics.ACTION_SUBJECT_ID.EXPAND,
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.updateExpandTitle = exports.toggleExpandExpanded = exports.setSelectionInsideExpand = exports.insertExpand = exports.focusTitle = exports.deleteExpandAtPos = exports.deleteExpand = exports.createExpandNode = void 0;
|
|
7
|
+
exports.updateExpandTitle = exports.toggleExpandExpanded = exports.setSelectionInsideExpand = exports.insertExpandWithInputMethod = exports.insertExpand = exports.focusTitle = exports.deleteExpandAtPos = exports.deleteExpand = exports.createExpandNode = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _steps = require("@atlaskit/adf-schema/steps");
|
|
10
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
@@ -27,30 +27,37 @@ var createExpandNode = exports.createExpandNode = function createExpandNode(stat
|
|
|
27
27
|
_expand.expandedState.set(expandNode, true);
|
|
28
28
|
return expandNode;
|
|
29
29
|
};
|
|
30
|
+
var insertExpandWithInputMethod = exports.insertExpandWithInputMethod = function insertExpandWithInputMethod(editorAnalyticsAPI) {
|
|
31
|
+
return function (inputMethod) {
|
|
32
|
+
return function (state, dispatch) {
|
|
33
|
+
var expandNode = createExpandNode(state);
|
|
34
|
+
if (!expandNode) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
var tr = state.selection.empty ? (0, _utils2.safeInsert)(expandNode)(state.tr).scrollIntoView() : (0, _utils.createWrapSelectionTransaction)({
|
|
38
|
+
state: state,
|
|
39
|
+
type: expandNode.type
|
|
40
|
+
});
|
|
41
|
+
var payload = {
|
|
42
|
+
action: _analytics.ACTION.INSERTED,
|
|
43
|
+
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
44
|
+
actionSubjectId: (expandNode === null || expandNode === void 0 ? void 0 : expandNode.type) === state.schema.nodes.expand ? _analytics.ACTION_SUBJECT_ID.EXPAND : _analytics.ACTION_SUBJECT_ID.NESTED_EXPAND,
|
|
45
|
+
attributes: {
|
|
46
|
+
inputMethod: inputMethod
|
|
47
|
+
},
|
|
48
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
49
|
+
};
|
|
50
|
+
if (dispatch && expandNode) {
|
|
51
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
|
|
52
|
+
dispatch(tr);
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
};
|
|
30
58
|
var insertExpand = exports.insertExpand = function insertExpand(editorAnalyticsAPI) {
|
|
31
59
|
return function (state, dispatch) {
|
|
32
|
-
|
|
33
|
-
if (!expandNode) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
var tr = state.selection.empty ? (0, _utils2.safeInsert)(expandNode)(state.tr).scrollIntoView() : (0, _utils.createWrapSelectionTransaction)({
|
|
37
|
-
state: state,
|
|
38
|
-
type: expandNode.type
|
|
39
|
-
});
|
|
40
|
-
var payload = {
|
|
41
|
-
action: _analytics.ACTION.INSERTED,
|
|
42
|
-
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
43
|
-
actionSubjectId: (expandNode === null || expandNode === void 0 ? void 0 : expandNode.type) === state.schema.nodes.expand ? _analytics.ACTION_SUBJECT_ID.EXPAND : _analytics.ACTION_SUBJECT_ID.NESTED_EXPAND,
|
|
44
|
-
attributes: {
|
|
45
|
-
inputMethod: _analytics.INPUT_METHOD.INSERT_MENU
|
|
46
|
-
},
|
|
47
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
48
|
-
};
|
|
49
|
-
if (dispatch && expandNode) {
|
|
50
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
|
|
51
|
-
dispatch(tr);
|
|
52
|
-
}
|
|
53
|
-
return true;
|
|
60
|
+
return insertExpandWithInputMethod(editorAnalyticsAPI)(_analytics.INPUT_METHOD.INSERT_MENU)(state, dispatch);
|
|
54
61
|
};
|
|
55
62
|
};
|
|
56
63
|
var deleteExpand = exports.deleteExpand = function deleteExpand(editorAnalyticsAPI) {
|
|
@@ -16,7 +16,7 @@ var _keymap = require("./pm-plugins/keymap");
|
|
|
16
16
|
var _main = require("./pm-plugins/main");
|
|
17
17
|
var _toolbar = require("./toolbar");
|
|
18
18
|
var expandPlugin = exports.expandPlugin = function expandPlugin(_ref) {
|
|
19
|
-
var _api$analytics;
|
|
19
|
+
var _api$analytics, _api$analytics2;
|
|
20
20
|
var _ref$config = _ref.config,
|
|
21
21
|
options = _ref$config === void 0 ? {} : _ref$config,
|
|
22
22
|
api = _ref.api;
|
|
@@ -32,7 +32,8 @@ var expandPlugin = exports.expandPlugin = function expandPlugin(_ref) {
|
|
|
32
32
|
}];
|
|
33
33
|
},
|
|
34
34
|
actions: {
|
|
35
|
-
insertExpand: (0, _commands.insertExpand)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
|
|
35
|
+
insertExpand: (0, _commands.insertExpand)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions),
|
|
36
|
+
insertExpandWithInputMethod: (0, _commands.insertExpandWithInputMethod)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
36
37
|
},
|
|
37
38
|
pmPlugins: function pmPlugins() {
|
|
38
39
|
return [{
|
|
@@ -69,7 +70,7 @@ var expandPlugin = exports.expandPlugin = function expandPlugin(_ref) {
|
|
|
69
70
|
return /*#__PURE__*/_react.default.createElement(_quickInsert.IconExpand, null);
|
|
70
71
|
},
|
|
71
72
|
action: function action(insert, state) {
|
|
72
|
-
var _api$
|
|
73
|
+
var _api$analytics3;
|
|
73
74
|
var node = (0, _commands.createExpandNode)(state);
|
|
74
75
|
if (!node) {
|
|
75
76
|
return false;
|
|
@@ -78,7 +79,7 @@ var expandPlugin = exports.expandPlugin = function expandPlugin(_ref) {
|
|
|
78
79
|
state: state,
|
|
79
80
|
type: node.type
|
|
80
81
|
});
|
|
81
|
-
api === null || api === void 0 || (_api$
|
|
82
|
+
api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 || _api$analytics3.actions.attachAnalyticsEvent({
|
|
82
83
|
action: _analytics.ACTION.INSERTED,
|
|
83
84
|
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
84
85
|
actionSubjectId: node.type === state.schema.nodes.nestedExpand ? _analytics.ACTION_SUBJECT_ID.NESTED_EXPAND : _analytics.ACTION_SUBJECT_ID.EXPAND,
|
|
@@ -5,7 +5,7 @@ import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
|
5
5
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
7
7
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
8
|
-
import {
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
import { createCommand } from './pm-plugins/plugin-factory';
|
|
10
10
|
import { findExpand } from './utils';
|
|
11
11
|
export const setExpandRef = ref => createCommand({
|
|
@@ -54,7 +54,7 @@ export const updateExpandTitle = ({
|
|
|
54
54
|
const {
|
|
55
55
|
tr
|
|
56
56
|
} = state;
|
|
57
|
-
if (
|
|
57
|
+
if (__livePage && fg('platform.editor.live-pages-expand-divergence')) {
|
|
58
58
|
tr.step(new SetAttrsStep(pos, {
|
|
59
59
|
...node.attrs,
|
|
60
60
|
title
|
|
@@ -81,7 +81,7 @@ export const toggleExpandExpanded = ({
|
|
|
81
81
|
tr
|
|
82
82
|
} = state;
|
|
83
83
|
const isExpandedNext = !node.attrs.__expanded;
|
|
84
|
-
if (
|
|
84
|
+
if (__livePage && fg('platform.editor.live-pages-expand-divergence')) {
|
|
85
85
|
tr.step(new SetAttrsStep(pos, {
|
|
86
86
|
...node.attrs,
|
|
87
87
|
__expanded: isExpandedNext
|
|
@@ -96,7 +96,7 @@ export const toggleExpandExpanded = ({
|
|
|
96
96
|
// If we're going to collapse the expand and our cursor is currently inside
|
|
97
97
|
// Move to a right gap cursor, if the toolbar is interacted (or an API),
|
|
98
98
|
// it will insert below rather than inside (which will be invisible).
|
|
99
|
-
if (
|
|
99
|
+
if (__livePage && fg('platform.editor.live-pages-expand-divergence') ? isExpandedNext === true : isExpandedNext === false && findExpand(state)) {
|
|
100
100
|
tr.setSelection(new GapCursorSelection(tr.doc.resolve(pos + node.nodeSize), Side.RIGHT));
|
|
101
101
|
}
|
|
102
102
|
|
|
@@ -108,7 +108,7 @@ export const toggleExpandExpanded = ({
|
|
|
108
108
|
attributes: {
|
|
109
109
|
platform: PLATFORMS.WEB,
|
|
110
110
|
mode: MODE.EDITOR,
|
|
111
|
-
expanded:
|
|
111
|
+
expanded: __livePage && fg('platform.editor.live-pages-expand-divergence') ? !isExpandedNext : isExpandedNext
|
|
112
112
|
},
|
|
113
113
|
eventType: EVENT_TYPE.TRACK
|
|
114
114
|
};
|
|
@@ -131,7 +131,7 @@ export const createExpandNode = state => {
|
|
|
131
131
|
const expandType = findTable(state.selection) ? nestedExpand : expand;
|
|
132
132
|
return expandType.createAndFill({});
|
|
133
133
|
};
|
|
134
|
-
export const
|
|
134
|
+
export const insertExpandWithInputMethod = editorAnalyticsAPI => inputMethod => (state, dispatch) => {
|
|
135
135
|
const expandNode = createExpandNode(state);
|
|
136
136
|
if (!expandNode) {
|
|
137
137
|
return false;
|
|
@@ -145,7 +145,7 @@ export const insertExpand = editorAnalyticsAPI => (state, dispatch) => {
|
|
|
145
145
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
146
146
|
actionSubjectId: (expandNode === null || expandNode === void 0 ? void 0 : expandNode.type) === state.schema.nodes.expand ? ACTION_SUBJECT_ID.EXPAND : ACTION_SUBJECT_ID.NESTED_EXPAND,
|
|
147
147
|
attributes: {
|
|
148
|
-
inputMethod
|
|
148
|
+
inputMethod
|
|
149
149
|
},
|
|
150
150
|
eventType: EVENT_TYPE.TRACK
|
|
151
151
|
};
|
|
@@ -155,6 +155,9 @@ export const insertExpand = editorAnalyticsAPI => (state, dispatch) => {
|
|
|
155
155
|
}
|
|
156
156
|
return true;
|
|
157
157
|
};
|
|
158
|
+
export const insertExpand = editorAnalyticsAPI => (state, dispatch) => {
|
|
159
|
+
return insertExpandWithInputMethod(editorAnalyticsAPI)(INPUT_METHOD.INSERT_MENU)(state, dispatch);
|
|
160
|
+
};
|
|
158
161
|
export const focusTitle = pos => (state, dispatch, editorView) => {
|
|
159
162
|
if (editorView) {
|
|
160
163
|
const dom = editorView.domAtPos(pos);
|
|
@@ -4,7 +4,7 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } f
|
|
|
4
4
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
5
|
import { IconExpand } from '@atlaskit/editor-common/quick-insert';
|
|
6
6
|
import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
7
|
-
import { createExpandNode, insertExpand } from './commands';
|
|
7
|
+
import { createExpandNode, insertExpand, insertExpandWithInputMethod } from './commands';
|
|
8
8
|
import { expandKeymap } from './pm-plugins/keymap';
|
|
9
9
|
import { createPlugin } from './pm-plugins/main';
|
|
10
10
|
import { getToolbarConfig } from './toolbar';
|
|
@@ -13,7 +13,7 @@ export const expandPlugin = ({
|
|
|
13
13
|
config: options = {},
|
|
14
14
|
api
|
|
15
15
|
}) => {
|
|
16
|
-
var _api$analytics;
|
|
16
|
+
var _api$analytics, _api$analytics2;
|
|
17
17
|
return {
|
|
18
18
|
name: 'expand',
|
|
19
19
|
nodes() {
|
|
@@ -26,7 +26,8 @@ export const expandPlugin = ({
|
|
|
26
26
|
}];
|
|
27
27
|
},
|
|
28
28
|
actions: {
|
|
29
|
-
insertExpand: insertExpand(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
|
|
29
|
+
insertExpand: insertExpand(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions),
|
|
30
|
+
insertExpandWithInputMethod: insertExpandWithInputMethod(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
30
31
|
},
|
|
31
32
|
pmPlugins() {
|
|
32
33
|
return [{
|
|
@@ -61,7 +62,7 @@ export const expandPlugin = ({
|
|
|
61
62
|
priority: 600,
|
|
62
63
|
icon: () => /*#__PURE__*/React.createElement(IconExpand, null),
|
|
63
64
|
action(insert, state) {
|
|
64
|
-
var _api$
|
|
65
|
+
var _api$analytics3;
|
|
65
66
|
const node = createExpandNode(state);
|
|
66
67
|
if (!node) {
|
|
67
68
|
return false;
|
|
@@ -70,7 +71,7 @@ export const expandPlugin = ({
|
|
|
70
71
|
state,
|
|
71
72
|
type: node.type
|
|
72
73
|
});
|
|
73
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
74
|
+
api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions.attachAnalyticsEvent({
|
|
74
75
|
action: ACTION.INSERTED,
|
|
75
76
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
76
77
|
actionSubjectId: node.type === state.schema.nodes.nestedExpand ? ACTION_SUBJECT_ID.NESTED_EXPAND : ACTION_SUBJECT_ID.EXPAND,
|
|
@@ -7,7 +7,6 @@ import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
|
7
7
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
8
8
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
9
9
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
10
|
-
|
|
11
10
|
// Creates either an expand or a nestedExpand node based on the current selection
|
|
12
11
|
export const createExpandNode = state => {
|
|
13
12
|
const {
|
|
@@ -19,7 +18,7 @@ export const createExpandNode = state => {
|
|
|
19
18
|
expandedState.set(expandNode, true);
|
|
20
19
|
return expandNode;
|
|
21
20
|
};
|
|
22
|
-
export const
|
|
21
|
+
export const insertExpandWithInputMethod = editorAnalyticsAPI => inputMethod => (state, dispatch) => {
|
|
23
22
|
const expandNode = createExpandNode(state);
|
|
24
23
|
if (!expandNode) {
|
|
25
24
|
return false;
|
|
@@ -33,7 +32,7 @@ export const insertExpand = editorAnalyticsAPI => (state, dispatch) => {
|
|
|
33
32
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
34
33
|
actionSubjectId: (expandNode === null || expandNode === void 0 ? void 0 : expandNode.type) === state.schema.nodes.expand ? ACTION_SUBJECT_ID.EXPAND : ACTION_SUBJECT_ID.NESTED_EXPAND,
|
|
35
34
|
attributes: {
|
|
36
|
-
inputMethod
|
|
35
|
+
inputMethod
|
|
37
36
|
},
|
|
38
37
|
eventType: EVENT_TYPE.TRACK
|
|
39
38
|
};
|
|
@@ -43,6 +42,9 @@ export const insertExpand = editorAnalyticsAPI => (state, dispatch) => {
|
|
|
43
42
|
}
|
|
44
43
|
return true;
|
|
45
44
|
};
|
|
45
|
+
export const insertExpand = editorAnalyticsAPI => (state, dispatch) => {
|
|
46
|
+
return insertExpandWithInputMethod(editorAnalyticsAPI)(INPUT_METHOD.INSERT_MENU)(state, dispatch);
|
|
47
|
+
};
|
|
46
48
|
export const deleteExpand = editorAnalyticsAPI => (state, dispatch) => {
|
|
47
49
|
const expandNode = findExpand(state);
|
|
48
50
|
if (!expandNode) {
|
|
@@ -4,7 +4,7 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } f
|
|
|
4
4
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
5
|
import { IconExpand } from '@atlaskit/editor-common/quick-insert';
|
|
6
6
|
import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
7
|
-
import { createExpandNode, insertExpand } from './commands';
|
|
7
|
+
import { createExpandNode, insertExpand, insertExpandWithInputMethod } from './commands';
|
|
8
8
|
import { expandKeymap } from './pm-plugins/keymap';
|
|
9
9
|
import { createPlugin } from './pm-plugins/main';
|
|
10
10
|
import { getToolbarConfig } from './toolbar';
|
|
@@ -12,7 +12,7 @@ export const expandPlugin = ({
|
|
|
12
12
|
config: options = {},
|
|
13
13
|
api
|
|
14
14
|
}) => {
|
|
15
|
-
var _api$analytics;
|
|
15
|
+
var _api$analytics, _api$analytics2;
|
|
16
16
|
return {
|
|
17
17
|
name: 'expand',
|
|
18
18
|
nodes() {
|
|
@@ -25,7 +25,8 @@ export const expandPlugin = ({
|
|
|
25
25
|
}];
|
|
26
26
|
},
|
|
27
27
|
actions: {
|
|
28
|
-
insertExpand: insertExpand(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
|
|
28
|
+
insertExpand: insertExpand(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions),
|
|
29
|
+
insertExpandWithInputMethod: insertExpandWithInputMethod(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
29
30
|
},
|
|
30
31
|
pmPlugins() {
|
|
31
32
|
return [{
|
|
@@ -60,7 +61,7 @@ export const expandPlugin = ({
|
|
|
60
61
|
priority: 600,
|
|
61
62
|
icon: () => /*#__PURE__*/React.createElement(IconExpand, null),
|
|
62
63
|
action(insert, state) {
|
|
63
|
-
var _api$
|
|
64
|
+
var _api$analytics3;
|
|
64
65
|
const node = createExpandNode(state);
|
|
65
66
|
if (!node) {
|
|
66
67
|
return false;
|
|
@@ -69,7 +70,7 @@ export const expandPlugin = ({
|
|
|
69
70
|
state,
|
|
70
71
|
type: node.type
|
|
71
72
|
});
|
|
72
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
73
|
+
api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions.attachAnalyticsEvent({
|
|
73
74
|
action: ACTION.INSERTED,
|
|
74
75
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
75
76
|
actionSubjectId: node.type === state.schema.nodes.nestedExpand ? ACTION_SUBJECT_ID.NESTED_EXPAND : ACTION_SUBJECT_ID.EXPAND,
|
|
@@ -8,7 +8,7 @@ import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
|
8
8
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
9
9
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
10
10
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
11
|
-
import {
|
|
11
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
12
|
import { createCommand } from './pm-plugins/plugin-factory';
|
|
13
13
|
import { findExpand } from './utils';
|
|
14
14
|
export var setExpandRef = function setExpandRef(ref) {
|
|
@@ -63,7 +63,7 @@ export var updateExpandTitle = function updateExpandTitle(_ref) {
|
|
|
63
63
|
var node = state.doc.nodeAt(pos);
|
|
64
64
|
if (node && node.type === nodeType && dispatch) {
|
|
65
65
|
var tr = state.tr;
|
|
66
|
-
if (
|
|
66
|
+
if (__livePage && fg('platform.editor.live-pages-expand-divergence')) {
|
|
67
67
|
tr.step(new SetAttrsStep(pos, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
68
68
|
title: title
|
|
69
69
|
})));
|
|
@@ -87,7 +87,7 @@ export var toggleExpandExpanded = function toggleExpandExpanded(_ref2) {
|
|
|
87
87
|
if (node && node.type === nodeType && dispatch) {
|
|
88
88
|
var tr = state.tr;
|
|
89
89
|
var isExpandedNext = !node.attrs.__expanded;
|
|
90
|
-
if (
|
|
90
|
+
if (__livePage && fg('platform.editor.live-pages-expand-divergence')) {
|
|
91
91
|
tr.step(new SetAttrsStep(pos, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
92
92
|
__expanded: isExpandedNext
|
|
93
93
|
})));
|
|
@@ -100,7 +100,7 @@ export var toggleExpandExpanded = function toggleExpandExpanded(_ref2) {
|
|
|
100
100
|
// If we're going to collapse the expand and our cursor is currently inside
|
|
101
101
|
// Move to a right gap cursor, if the toolbar is interacted (or an API),
|
|
102
102
|
// it will insert below rather than inside (which will be invisible).
|
|
103
|
-
if (
|
|
103
|
+
if (__livePage && fg('platform.editor.live-pages-expand-divergence') ? isExpandedNext === true : isExpandedNext === false && findExpand(state)) {
|
|
104
104
|
tr.setSelection(new GapCursorSelection(tr.doc.resolve(pos + node.nodeSize), Side.RIGHT));
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -112,7 +112,7 @@ export var toggleExpandExpanded = function toggleExpandExpanded(_ref2) {
|
|
|
112
112
|
attributes: {
|
|
113
113
|
platform: PLATFORMS.WEB,
|
|
114
114
|
mode: MODE.EDITOR,
|
|
115
|
-
expanded:
|
|
115
|
+
expanded: __livePage && fg('platform.editor.live-pages-expand-divergence') ? !isExpandedNext : isExpandedNext
|
|
116
116
|
},
|
|
117
117
|
eventType: EVENT_TYPE.TRACK
|
|
118
118
|
};
|
|
@@ -135,30 +135,37 @@ export var createExpandNode = function createExpandNode(state) {
|
|
|
135
135
|
var expandType = findTable(state.selection) ? nestedExpand : expand;
|
|
136
136
|
return expandType.createAndFill({});
|
|
137
137
|
};
|
|
138
|
+
export var insertExpandWithInputMethod = function insertExpandWithInputMethod(editorAnalyticsAPI) {
|
|
139
|
+
return function (inputMethod) {
|
|
140
|
+
return function (state, dispatch) {
|
|
141
|
+
var expandNode = createExpandNode(state);
|
|
142
|
+
if (!expandNode) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
var tr = state.selection.empty ? safeInsert(expandNode)(state.tr).scrollIntoView() : createWrapSelectionTransaction({
|
|
146
|
+
state: state,
|
|
147
|
+
type: expandNode.type
|
|
148
|
+
});
|
|
149
|
+
var payload = {
|
|
150
|
+
action: ACTION.INSERTED,
|
|
151
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
152
|
+
actionSubjectId: (expandNode === null || expandNode === void 0 ? void 0 : expandNode.type) === state.schema.nodes.expand ? ACTION_SUBJECT_ID.EXPAND : ACTION_SUBJECT_ID.NESTED_EXPAND,
|
|
153
|
+
attributes: {
|
|
154
|
+
inputMethod: inputMethod
|
|
155
|
+
},
|
|
156
|
+
eventType: EVENT_TYPE.TRACK
|
|
157
|
+
};
|
|
158
|
+
if (dispatch && expandNode) {
|
|
159
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
|
|
160
|
+
dispatch(tr);
|
|
161
|
+
}
|
|
162
|
+
return true;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
};
|
|
138
166
|
export var insertExpand = function insertExpand(editorAnalyticsAPI) {
|
|
139
167
|
return function (state, dispatch) {
|
|
140
|
-
|
|
141
|
-
if (!expandNode) {
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
var tr = state.selection.empty ? safeInsert(expandNode)(state.tr).scrollIntoView() : createWrapSelectionTransaction({
|
|
145
|
-
state: state,
|
|
146
|
-
type: expandNode.type
|
|
147
|
-
});
|
|
148
|
-
var payload = {
|
|
149
|
-
action: ACTION.INSERTED,
|
|
150
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
151
|
-
actionSubjectId: (expandNode === null || expandNode === void 0 ? void 0 : expandNode.type) === state.schema.nodes.expand ? ACTION_SUBJECT_ID.EXPAND : ACTION_SUBJECT_ID.NESTED_EXPAND,
|
|
152
|
-
attributes: {
|
|
153
|
-
inputMethod: INPUT_METHOD.INSERT_MENU
|
|
154
|
-
},
|
|
155
|
-
eventType: EVENT_TYPE.TRACK
|
|
156
|
-
};
|
|
157
|
-
if (dispatch && expandNode) {
|
|
158
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
|
|
159
|
-
dispatch(tr);
|
|
160
|
-
}
|
|
161
|
-
return true;
|
|
168
|
+
return insertExpandWithInputMethod(editorAnalyticsAPI)(INPUT_METHOD.INSERT_MENU)(state, dispatch);
|
|
162
169
|
};
|
|
163
170
|
};
|
|
164
171
|
export var focusTitle = function focusTitle(pos) {
|
|
@@ -4,13 +4,13 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } f
|
|
|
4
4
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
5
|
import { IconExpand } from '@atlaskit/editor-common/quick-insert';
|
|
6
6
|
import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
7
|
-
import { createExpandNode, insertExpand } from './commands';
|
|
7
|
+
import { createExpandNode, insertExpand, insertExpandWithInputMethod } from './commands';
|
|
8
8
|
import { expandKeymap } from './pm-plugins/keymap';
|
|
9
9
|
import { createPlugin } from './pm-plugins/main';
|
|
10
10
|
import { getToolbarConfig } from './toolbar';
|
|
11
11
|
export { pluginKey } from './pm-plugins/plugin-factory';
|
|
12
12
|
export var expandPlugin = function expandPlugin(_ref) {
|
|
13
|
-
var _api$analytics;
|
|
13
|
+
var _api$analytics, _api$analytics2;
|
|
14
14
|
var _ref$config = _ref.config,
|
|
15
15
|
options = _ref$config === void 0 ? {} : _ref$config,
|
|
16
16
|
api = _ref.api;
|
|
@@ -26,7 +26,8 @@ export var expandPlugin = function expandPlugin(_ref) {
|
|
|
26
26
|
}];
|
|
27
27
|
},
|
|
28
28
|
actions: {
|
|
29
|
-
insertExpand: insertExpand(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
|
|
29
|
+
insertExpand: insertExpand(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions),
|
|
30
|
+
insertExpandWithInputMethod: insertExpandWithInputMethod(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
30
31
|
},
|
|
31
32
|
pmPlugins: function pmPlugins() {
|
|
32
33
|
return [{
|
|
@@ -63,7 +64,7 @@ export var expandPlugin = function expandPlugin(_ref) {
|
|
|
63
64
|
return /*#__PURE__*/React.createElement(IconExpand, null);
|
|
64
65
|
},
|
|
65
66
|
action: function action(insert, state) {
|
|
66
|
-
var _api$
|
|
67
|
+
var _api$analytics3;
|
|
67
68
|
var node = createExpandNode(state);
|
|
68
69
|
if (!node) {
|
|
69
70
|
return false;
|
|
@@ -72,7 +73,7 @@ export var expandPlugin = function expandPlugin(_ref) {
|
|
|
72
73
|
state: state,
|
|
73
74
|
type: node.type
|
|
74
75
|
});
|
|
75
|
-
api === null || api === void 0 || (_api$
|
|
76
|
+
api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 || _api$analytics3.actions.attachAnalyticsEvent({
|
|
76
77
|
action: ACTION.INSERTED,
|
|
77
78
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
78
79
|
actionSubjectId: node.type === state.schema.nodes.nestedExpand ? ACTION_SUBJECT_ID.NESTED_EXPAND : ACTION_SUBJECT_ID.EXPAND,
|
|
@@ -10,7 +10,6 @@ import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
|
10
10
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
11
11
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
12
12
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
13
|
-
|
|
14
13
|
// Creates either an expand or a nestedExpand node based on the current selection
|
|
15
14
|
export var createExpandNode = function createExpandNode(state) {
|
|
16
15
|
var _state$schema$nodes = state.schema.nodes,
|
|
@@ -21,30 +20,37 @@ export var createExpandNode = function createExpandNode(state) {
|
|
|
21
20
|
expandedState.set(expandNode, true);
|
|
22
21
|
return expandNode;
|
|
23
22
|
};
|
|
23
|
+
export var insertExpandWithInputMethod = function insertExpandWithInputMethod(editorAnalyticsAPI) {
|
|
24
|
+
return function (inputMethod) {
|
|
25
|
+
return function (state, dispatch) {
|
|
26
|
+
var expandNode = createExpandNode(state);
|
|
27
|
+
if (!expandNode) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
var tr = state.selection.empty ? safeInsert(expandNode)(state.tr).scrollIntoView() : createWrapSelectionTransaction({
|
|
31
|
+
state: state,
|
|
32
|
+
type: expandNode.type
|
|
33
|
+
});
|
|
34
|
+
var payload = {
|
|
35
|
+
action: ACTION.INSERTED,
|
|
36
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
37
|
+
actionSubjectId: (expandNode === null || expandNode === void 0 ? void 0 : expandNode.type) === state.schema.nodes.expand ? ACTION_SUBJECT_ID.EXPAND : ACTION_SUBJECT_ID.NESTED_EXPAND,
|
|
38
|
+
attributes: {
|
|
39
|
+
inputMethod: inputMethod
|
|
40
|
+
},
|
|
41
|
+
eventType: EVENT_TYPE.TRACK
|
|
42
|
+
};
|
|
43
|
+
if (dispatch && expandNode) {
|
|
44
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
|
|
45
|
+
dispatch(tr);
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
24
51
|
export var insertExpand = function insertExpand(editorAnalyticsAPI) {
|
|
25
52
|
return function (state, dispatch) {
|
|
26
|
-
|
|
27
|
-
if (!expandNode) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
var tr = state.selection.empty ? safeInsert(expandNode)(state.tr).scrollIntoView() : createWrapSelectionTransaction({
|
|
31
|
-
state: state,
|
|
32
|
-
type: expandNode.type
|
|
33
|
-
});
|
|
34
|
-
var payload = {
|
|
35
|
-
action: ACTION.INSERTED,
|
|
36
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
37
|
-
actionSubjectId: (expandNode === null || expandNode === void 0 ? void 0 : expandNode.type) === state.schema.nodes.expand ? ACTION_SUBJECT_ID.EXPAND : ACTION_SUBJECT_ID.NESTED_EXPAND,
|
|
38
|
-
attributes: {
|
|
39
|
-
inputMethod: INPUT_METHOD.INSERT_MENU
|
|
40
|
-
},
|
|
41
|
-
eventType: EVENT_TYPE.TRACK
|
|
42
|
-
};
|
|
43
|
-
if (dispatch && expandNode) {
|
|
44
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
|
|
45
|
-
dispatch(tr);
|
|
46
|
-
}
|
|
47
|
-
return true;
|
|
53
|
+
return insertExpandWithInputMethod(editorAnalyticsAPI)(INPUT_METHOD.INSERT_MENU)(state, dispatch);
|
|
48
54
|
};
|
|
49
55
|
};
|
|
50
56
|
export var deleteExpand = function deleteExpand(editorAnalyticsAPI) {
|
|
@@ -4,12 +4,12 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } f
|
|
|
4
4
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
5
|
import { IconExpand } from '@atlaskit/editor-common/quick-insert';
|
|
6
6
|
import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
7
|
-
import { createExpandNode, insertExpand } from './commands';
|
|
7
|
+
import { createExpandNode, insertExpand, insertExpandWithInputMethod } from './commands';
|
|
8
8
|
import { expandKeymap } from './pm-plugins/keymap';
|
|
9
9
|
import { createPlugin } from './pm-plugins/main';
|
|
10
10
|
import { getToolbarConfig } from './toolbar';
|
|
11
11
|
export var expandPlugin = function expandPlugin(_ref) {
|
|
12
|
-
var _api$analytics;
|
|
12
|
+
var _api$analytics, _api$analytics2;
|
|
13
13
|
var _ref$config = _ref.config,
|
|
14
14
|
options = _ref$config === void 0 ? {} : _ref$config,
|
|
15
15
|
api = _ref.api;
|
|
@@ -25,7 +25,8 @@ export var expandPlugin = function expandPlugin(_ref) {
|
|
|
25
25
|
}];
|
|
26
26
|
},
|
|
27
27
|
actions: {
|
|
28
|
-
insertExpand: insertExpand(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
|
|
28
|
+
insertExpand: insertExpand(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions),
|
|
29
|
+
insertExpandWithInputMethod: insertExpandWithInputMethod(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
29
30
|
},
|
|
30
31
|
pmPlugins: function pmPlugins() {
|
|
31
32
|
return [{
|
|
@@ -62,7 +63,7 @@ export var expandPlugin = function expandPlugin(_ref) {
|
|
|
62
63
|
return /*#__PURE__*/React.createElement(IconExpand, null);
|
|
63
64
|
},
|
|
64
65
|
action: function action(insert, state) {
|
|
65
|
-
var _api$
|
|
66
|
+
var _api$analytics3;
|
|
66
67
|
var node = createExpandNode(state);
|
|
67
68
|
if (!node) {
|
|
68
69
|
return false;
|
|
@@ -71,7 +72,7 @@ export var expandPlugin = function expandPlugin(_ref) {
|
|
|
71
72
|
state: state,
|
|
72
73
|
type: node.type
|
|
73
74
|
});
|
|
74
|
-
api === null || api === void 0 || (_api$
|
|
75
|
+
api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 || _api$analytics3.actions.attachAnalyticsEvent({
|
|
75
76
|
action: ACTION.INSERTED,
|
|
76
77
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
77
78
|
actionSubjectId: node.type === state.schema.nodes.nestedExpand ? ACTION_SUBJECT_ID.NESTED_EXPAND : ACTION_SUBJECT_ID.EXPAND,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { ExpandPlugin, ExpandPluginState, ExpandPluginOptions } from './types';
|
|
1
|
+
export type { ExpandPlugin, ExpandPluginState, ExpandPluginOptions, InsertMethod } from './types';
|
|
2
2
|
export { expandPlugin } from './plugin';
|
|
@@ -2,6 +2,7 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
|
2
2
|
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
|
+
import { type InsertMethod } from '../types';
|
|
5
6
|
export declare const setExpandRef: (ref?: HTMLDivElement | null) => Command;
|
|
6
7
|
export declare const deleteExpandAtPos: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (expandNodePos: number, expandNode: PMNode) => Command;
|
|
7
8
|
export declare const deleteExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
@@ -18,6 +19,7 @@ export declare const toggleExpandExpanded: ({ editorAnalyticsAPI, pos, nodeType,
|
|
|
18
19
|
__livePage: boolean;
|
|
19
20
|
}) => Command;
|
|
20
21
|
export declare const createExpandNode: (state: EditorState) => PMNode | null;
|
|
22
|
+
export declare const insertExpandWithInputMethod: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod: InsertMethod) => Command;
|
|
21
23
|
export declare const insertExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
22
24
|
export declare const focusTitle: (pos: number) => Command;
|
|
23
25
|
export declare const setSelectionInsideExpand: (expandPos: number) => Command;
|
|
@@ -2,7 +2,9 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
|
2
2
|
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
|
+
import { type InsertMethod } from '../types';
|
|
5
6
|
export declare const createExpandNode: (state: EditorState) => PMNode | null;
|
|
7
|
+
export declare const insertExpandWithInputMethod: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod: InsertMethod) => Command;
|
|
6
8
|
export declare const insertExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
7
9
|
export declare const deleteExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
8
10
|
export declare const deleteExpandAtPos: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (expandNodePos: number, expandNode: PMNode) => Command;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { type INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
1
2
|
import type { EditorAppearance, LongPressSelectionPluginOptions, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
4
|
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
4
5
|
import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
|
|
5
6
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
6
7
|
import type { SelectionMarkerPlugin } from '@atlaskit/editor-plugin-selection-marker';
|
|
7
|
-
import type { insertExpand } from './legacyExpand/commands';
|
|
8
|
+
import type { insertExpand, insertExpandWithInputMethod } from './legacyExpand/commands';
|
|
8
9
|
export interface ExpandPluginState {
|
|
9
10
|
expandRef?: HTMLDivElement | null;
|
|
10
11
|
}
|
|
@@ -14,6 +15,7 @@ export type ExpandPluginAction = {
|
|
|
14
15
|
ref?: HTMLDivElement | null;
|
|
15
16
|
};
|
|
16
17
|
};
|
|
18
|
+
export type InsertMethod = INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.INSERT_MENU | INPUT_METHOD.FLOATING_TB;
|
|
17
19
|
export interface ExpandPluginOptions extends LongPressSelectionPluginOptions {
|
|
18
20
|
allowInsertion?: boolean;
|
|
19
21
|
/**
|
|
@@ -44,6 +46,13 @@ export type ExpandPlugin = NextEditorPlugin<'expand', {
|
|
|
44
46
|
OptionalPlugin<EditorDisabledPlugin>
|
|
45
47
|
];
|
|
46
48
|
actions: {
|
|
49
|
+
/**
|
|
50
|
+
* Insert an expand node and dispatch event with `insertMenu` inputMethod
|
|
51
|
+
*/
|
|
47
52
|
insertExpand: ReturnType<typeof insertExpand>;
|
|
53
|
+
/**
|
|
54
|
+
* Insert an expand node and dispatch event with inputMethod specified
|
|
55
|
+
*/
|
|
56
|
+
insertExpandWithInputMethod: ReturnType<typeof insertExpandWithInputMethod>;
|
|
48
57
|
};
|
|
49
58
|
}>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { ExpandPlugin, ExpandPluginState, ExpandPluginOptions } from './types';
|
|
1
|
+
export type { ExpandPlugin, ExpandPluginState, ExpandPluginOptions, InsertMethod } from './types';
|
|
2
2
|
export { expandPlugin } from './plugin';
|
|
@@ -2,6 +2,7 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
|
2
2
|
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
|
+
import { type InsertMethod } from '../types';
|
|
5
6
|
export declare const setExpandRef: (ref?: HTMLDivElement | null) => Command;
|
|
6
7
|
export declare const deleteExpandAtPos: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (expandNodePos: number, expandNode: PMNode) => Command;
|
|
7
8
|
export declare const deleteExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
@@ -18,6 +19,7 @@ export declare const toggleExpandExpanded: ({ editorAnalyticsAPI, pos, nodeType,
|
|
|
18
19
|
__livePage: boolean;
|
|
19
20
|
}) => Command;
|
|
20
21
|
export declare const createExpandNode: (state: EditorState) => PMNode | null;
|
|
22
|
+
export declare const insertExpandWithInputMethod: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod: InsertMethod) => Command;
|
|
21
23
|
export declare const insertExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
22
24
|
export declare const focusTitle: (pos: number) => Command;
|
|
23
25
|
export declare const setSelectionInsideExpand: (expandPos: number) => Command;
|
|
@@ -2,7 +2,9 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
|
2
2
|
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
|
+
import { type InsertMethod } from '../types';
|
|
5
6
|
export declare const createExpandNode: (state: EditorState) => PMNode | null;
|
|
7
|
+
export declare const insertExpandWithInputMethod: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod: InsertMethod) => Command;
|
|
6
8
|
export declare const insertExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
7
9
|
export declare const deleteExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
8
10
|
export declare const deleteExpandAtPos: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (expandNodePos: number, expandNode: PMNode) => Command;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { type INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
1
2
|
import type { EditorAppearance, LongPressSelectionPluginOptions, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
4
|
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
4
5
|
import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
|
|
5
6
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
6
7
|
import type { SelectionMarkerPlugin } from '@atlaskit/editor-plugin-selection-marker';
|
|
7
|
-
import type { insertExpand } from './legacyExpand/commands';
|
|
8
|
+
import type { insertExpand, insertExpandWithInputMethod } from './legacyExpand/commands';
|
|
8
9
|
export interface ExpandPluginState {
|
|
9
10
|
expandRef?: HTMLDivElement | null;
|
|
10
11
|
}
|
|
@@ -14,6 +15,7 @@ export type ExpandPluginAction = {
|
|
|
14
15
|
ref?: HTMLDivElement | null;
|
|
15
16
|
};
|
|
16
17
|
};
|
|
18
|
+
export type InsertMethod = INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.INSERT_MENU | INPUT_METHOD.FLOATING_TB;
|
|
17
19
|
export interface ExpandPluginOptions extends LongPressSelectionPluginOptions {
|
|
18
20
|
allowInsertion?: boolean;
|
|
19
21
|
/**
|
|
@@ -44,6 +46,13 @@ export type ExpandPlugin = NextEditorPlugin<'expand', {
|
|
|
44
46
|
OptionalPlugin<EditorDisabledPlugin>
|
|
45
47
|
];
|
|
46
48
|
actions: {
|
|
49
|
+
/**
|
|
50
|
+
* Insert an expand node and dispatch event with `insertMenu` inputMethod
|
|
51
|
+
*/
|
|
47
52
|
insertExpand: ReturnType<typeof insertExpand>;
|
|
53
|
+
/**
|
|
54
|
+
* Insert an expand node and dispatch event with inputMethod specified
|
|
55
|
+
*/
|
|
56
|
+
insertExpandWithInputMethod: ReturnType<typeof insertExpandWithInputMethod>;
|
|
48
57
|
};
|
|
49
58
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-expand",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Expand plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
".": "./src/index.ts"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@atlaskit/adf-schema": "^40.
|
|
36
|
+
"@atlaskit/adf-schema": "^40.8.1",
|
|
37
37
|
"@atlaskit/button": "^19.1.0",
|
|
38
|
-
"@atlaskit/editor-common": "^87.
|
|
39
|
-
"@atlaskit/editor-plugin-analytics": "^1.
|
|
38
|
+
"@atlaskit/editor-common": "^87.6.0",
|
|
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",
|
|
42
42
|
"@atlaskit/editor-plugin-selection": "^1.3.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.11.0",
|
|
48
48
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
49
|
-
"@atlaskit/tooltip": "^18.
|
|
49
|
+
"@atlaskit/tooltip": "^18.6.0",
|
|
50
50
|
"@babel/runtime": "^7.0.0",
|
|
51
51
|
"@emotion/react": "^11.7.1",
|
|
52
52
|
"w3c-keyname": "^2.1.8"
|
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@atlaskit/analytics-next": "^
|
|
61
|
-
"@atlaskit/editor-plugin-content-insertion": "^1.
|
|
60
|
+
"@atlaskit/analytics-next": "^10.0.0",
|
|
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",
|
|
64
|
-
"@atlaskit/editor-plugin-table": "^7.
|
|
65
|
-
"@atlaskit/editor-plugin-type-ahead": "^1.
|
|
64
|
+
"@atlaskit/editor-plugin-table": "^7.25.0",
|
|
65
|
+
"@atlaskit/editor-plugin-type-ahead": "^1.7.0",
|
|
66
66
|
"@atlaskit/editor-plugin-width": "^1.2.0",
|
|
67
67
|
"@testing-library/react": "^12.1.5",
|
|
68
68
|
"react-test-renderer": "^16.8.0",
|