@atlaskit/editor-plugin-expand 2.5.4 → 2.6.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 +9 -0
- package/dist/cjs/legacyExpand/commands.js +22 -1
- package/dist/cjs/legacyExpand/pm-plugins/keymap.js +14 -16
- package/dist/cjs/singlePlayerExpand/commands.js +22 -1
- package/dist/cjs/singlePlayerExpand/pm-plugins/keymap.js +26 -5
- package/dist/es2019/legacyExpand/commands.js +22 -1
- package/dist/es2019/legacyExpand/pm-plugins/keymap.js +15 -19
- package/dist/es2019/singlePlayerExpand/commands.js +22 -1
- package/dist/es2019/singlePlayerExpand/pm-plugins/keymap.js +26 -3
- package/dist/esm/legacyExpand/commands.js +22 -1
- package/dist/esm/legacyExpand/pm-plugins/keymap.js +15 -17
- package/dist/esm/singlePlayerExpand/commands.js +22 -1
- package/dist/esm/singlePlayerExpand/pm-plugins/keymap.js +24 -3
- package/dist/types/legacyExpand/commands.d.ts +1 -0
- package/dist/types/singlePlayerExpand/commands.d.ts +1 -0
- package/dist/types-ts4.5/legacyExpand/commands.d.ts +1 -0
- package/dist/types-ts4.5/singlePlayerExpand/commands.d.ts +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-expand
|
|
2
2
|
|
|
3
|
+
## 2.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#134731](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/134731)
|
|
8
|
+
[`07dc34f5168a0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/07dc34f5168a0) -
|
|
9
|
+
[ux] ED-23190 This change allows users to navigate using Tab when there are multiple expands on
|
|
10
|
+
the page. Previously, users could only navigate around the 1st expand on the page with Tab.
|
|
11
|
+
|
|
3
12
|
## 2.5.4
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -4,11 +4,12 @@ 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.insertExpandWithInputMethod = 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.focusIcon = 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");
|
|
11
11
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
12
|
+
var _styles = require("@atlaskit/editor-common/styles");
|
|
12
13
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
13
14
|
var _state2 = require("@atlaskit/editor-prosemirror/state");
|
|
14
15
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
@@ -195,6 +196,26 @@ var focusTitle = exports.focusTitle = function focusTitle(pos) {
|
|
|
195
196
|
return false;
|
|
196
197
|
};
|
|
197
198
|
};
|
|
199
|
+
var focusIcon = exports.focusIcon = function focusIcon(expand) {
|
|
200
|
+
return function (state, dispatch, editorView) {
|
|
201
|
+
if (!expand || !(expand instanceof HTMLElement)) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
var iconContainer = expand.querySelector(".".concat(_styles.expandClassNames.iconContainer));
|
|
205
|
+
if (iconContainer && iconContainer.focus) {
|
|
206
|
+
var tr = state.tr;
|
|
207
|
+
var pos = state.selection.from;
|
|
208
|
+
tr.setSelection(new _state2.TextSelection(tr.doc.resolve(pos)));
|
|
209
|
+
if (dispatch) {
|
|
210
|
+
dispatch(tr);
|
|
211
|
+
}
|
|
212
|
+
editorView === null || editorView === void 0 || editorView.dom.blur();
|
|
213
|
+
iconContainer.focus();
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
return false;
|
|
217
|
+
};
|
|
218
|
+
};
|
|
198
219
|
|
|
199
220
|
// Used to clear any node or cell selection when expand title is focused
|
|
200
221
|
var setSelectionInsideExpand = exports.setSelectionInsideExpand = function setSelectionInsideExpand(expandPos) {
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.expandKeymap = expandKeymap;
|
|
7
7
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
8
8
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
9
|
-
var _styles = require("@atlaskit/editor-common/styles");
|
|
10
9
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
11
10
|
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
12
11
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
@@ -48,24 +47,23 @@ function expandKeymap(api, options) {
|
|
|
48
47
|
return false;
|
|
49
48
|
}, list);
|
|
50
49
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.tab.common, function (state, dispatch, editorView) {
|
|
51
|
-
if (
|
|
50
|
+
if (editorView && editorView.dom instanceof HTMLElement) {
|
|
52
51
|
var from = state.selection.from;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
var
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
52
|
+
if (isExpandSelected(state.selection)) {
|
|
53
|
+
var expand = editorView.nodeDOM(from);
|
|
54
|
+
if (!expand || !(expand instanceof HTMLElement)) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return (0, _commands.focusIcon)(expand)(state, dispatch, editorView);
|
|
58
|
+
} else if (state.selection instanceof _state.TextSelection) {
|
|
59
|
+
var _dom$node$parentEleme;
|
|
60
|
+
var dom = editorView.domAtPos(from);
|
|
61
|
+
var _expand = (_dom$node$parentEleme = dom.node.parentElement) === null || _dom$node$parentEleme === void 0 ? void 0 : _dom$node$parentEleme.parentElement;
|
|
62
|
+
if (!_expand || !(_expand instanceof HTMLElement)) {
|
|
63
|
+
return false;
|
|
64
64
|
}
|
|
65
|
-
|
|
66
|
-
iconContainer.focus();
|
|
65
|
+
return (0, _commands.focusIcon)(_expand)(state, dispatch, editorView);
|
|
67
66
|
}
|
|
68
|
-
return true;
|
|
69
67
|
}
|
|
70
68
|
return false;
|
|
71
69
|
}, list);
|
|
@@ -4,12 +4,13 @@ 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.insertExpandWithInputMethod = 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.focusIcon = 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");
|
|
11
11
|
var _expand = require("@atlaskit/editor-common/expand");
|
|
12
12
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
13
|
+
var _styles = require("@atlaskit/editor-common/styles");
|
|
13
14
|
var _transforms = require("@atlaskit/editor-common/transforms");
|
|
14
15
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
15
16
|
var _state2 = require("@atlaskit/editor-prosemirror/state");
|
|
@@ -204,4 +205,24 @@ var focusTitle = exports.focusTitle = function focusTitle(pos) {
|
|
|
204
205
|
}
|
|
205
206
|
return false;
|
|
206
207
|
};
|
|
208
|
+
};
|
|
209
|
+
var focusIcon = exports.focusIcon = function focusIcon(expand) {
|
|
210
|
+
return function (state, dispatch, editorView) {
|
|
211
|
+
if (!expand || !(expand instanceof HTMLElement)) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
var iconContainer = expand.querySelector(".".concat(_styles.expandClassNames.iconContainer));
|
|
215
|
+
if (iconContainer && iconContainer.focus) {
|
|
216
|
+
var tr = state.tr;
|
|
217
|
+
var pos = state.selection.from;
|
|
218
|
+
tr.setSelection(new _state2.TextSelection(tr.doc.resolve(pos)));
|
|
219
|
+
if (dispatch) {
|
|
220
|
+
dispatch(tr);
|
|
221
|
+
}
|
|
222
|
+
editorView === null || editorView === void 0 || editorView.dom.blur();
|
|
223
|
+
iconContainer.focus();
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
return false;
|
|
227
|
+
};
|
|
207
228
|
};
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.expandKeymap = expandKeymap;
|
|
7
|
-
var
|
|
7
|
+
var _expand2 = require("@atlaskit/editor-common/expand");
|
|
8
8
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
9
9
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
10
10
|
var _transforms = require("@atlaskit/editor-common/transforms");
|
|
@@ -46,6 +46,27 @@ function expandKeymap(api, options) {
|
|
|
46
46
|
}
|
|
47
47
|
return false;
|
|
48
48
|
}, list);
|
|
49
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.tab.common, function (state, dispatch, editorView) {
|
|
50
|
+
if (editorView && editorView.dom instanceof HTMLElement) {
|
|
51
|
+
var from = state.selection.from;
|
|
52
|
+
if (isExpandSelected(state.selection)) {
|
|
53
|
+
var expand = editorView.nodeDOM(from);
|
|
54
|
+
if (!expand || !(expand instanceof HTMLElement)) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return (0, _commands.focusIcon)(expand)(state, dispatch, editorView);
|
|
58
|
+
} else if (state.selection instanceof _state.TextSelection) {
|
|
59
|
+
var _dom$node$parentEleme;
|
|
60
|
+
var dom = editorView.domAtPos(from);
|
|
61
|
+
var _expand = (_dom$node$parentEleme = dom.node.parentElement) === null || _dom$node$parentEleme === void 0 ? void 0 : _dom$node$parentEleme.parentElement;
|
|
62
|
+
if (!_expand || !(_expand instanceof HTMLElement)) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return (0, _commands.focusIcon)(_expand)(state, dispatch, editorView);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
}, list);
|
|
49
70
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveUp.common, function (state, dispatch, editorView) {
|
|
50
71
|
if (!editorView) {
|
|
51
72
|
return false;
|
|
@@ -53,7 +74,7 @@ function expandKeymap(api, options) {
|
|
|
53
74
|
var selection = state.selection,
|
|
54
75
|
schema = state.schema;
|
|
55
76
|
var nodeBefore = selection.$from.nodeBefore;
|
|
56
|
-
if (selection instanceof _selection.GapCursorSelection && selection.side === _selection.Side.RIGHT && nodeBefore && (nodeBefore.type === schema.nodes.expand || nodeBefore.type === schema.nodes.nestedExpand) && (0,
|
|
77
|
+
if (selection instanceof _selection.GapCursorSelection && selection.side === _selection.Side.RIGHT && nodeBefore && (nodeBefore.type === schema.nodes.expand || nodeBefore.type === schema.nodes.nestedExpand) && (0, _expand2.isExpandCollapsed)(nodeBefore)) {
|
|
57
78
|
var _$from = selection.$from;
|
|
58
79
|
return (0, _commands.focusTitle)(Math.max(_$from.pos - 1, 0))(state, dispatch, editorView);
|
|
59
80
|
}
|
|
@@ -77,7 +98,7 @@ function expandKeymap(api, options) {
|
|
|
77
98
|
var expandBefore = (0, _transforms.findExpand)(state, sel);
|
|
78
99
|
if (sel && expandBefore) {
|
|
79
100
|
// moving cursor from outside of an expand to the title when it is collapsed
|
|
80
|
-
if ((0,
|
|
101
|
+
if ((0, _expand2.isExpandCollapsed)(expandBefore.node)) {
|
|
81
102
|
return (0, _commands.focusTitle)(expandBefore.start)(state, dispatch, editorView);
|
|
82
103
|
}
|
|
83
104
|
// moving cursor from outside of an expand to the content when it is expanded
|
|
@@ -98,7 +119,7 @@ function expandKeymap(api, options) {
|
|
|
98
119
|
nestedExpand = _state$schema$nodes.nestedExpand;
|
|
99
120
|
var selection = state.selection;
|
|
100
121
|
var nodeAfter = selection.$from.nodeAfter;
|
|
101
|
-
if (selection instanceof _selection.GapCursorSelection && selection.side === _selection.Side.LEFT && nodeAfter && (nodeAfter.type === expand || nodeAfter.type === nestedExpand) && (0,
|
|
122
|
+
if (selection instanceof _selection.GapCursorSelection && selection.side === _selection.Side.LEFT && nodeAfter && (nodeAfter.type === expand || nodeAfter.type === nestedExpand) && (0, _expand2.isExpandCollapsed)(nodeAfter)) {
|
|
102
123
|
var $from = selection.$from;
|
|
103
124
|
return (0, _commands.focusTitle)($from.pos + 1)(state, dispatch, editorView);
|
|
104
125
|
}
|
|
@@ -128,7 +149,7 @@ function expandKeymap(api, options) {
|
|
|
128
149
|
// @see ED-7977
|
|
129
150
|
var sel = _state.Selection.findFrom(state.doc.resolve(Math.max(selection.$from.pos - 1, 0)), -1);
|
|
130
151
|
var expandBefore = (0, _transforms.findExpand)(state, sel);
|
|
131
|
-
if (expandBefore && (expandBefore.node.type === expand || expandBefore.node.type === nestedExpand) && (0,
|
|
152
|
+
if (expandBefore && (expandBefore.node.type === expand || expandBefore.node.type === nestedExpand) && (0, _expand2.isExpandCollapsed)(expandBefore.node)) {
|
|
132
153
|
return (0, _commands.focusTitle)(expandBefore.start)(state, dispatch, editorView);
|
|
133
154
|
}
|
|
134
155
|
return false;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
2
2
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, MODE, PLATFORMS } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
4
|
+
import { expandClassNames } from '@atlaskit/editor-common/styles';
|
|
4
5
|
import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
5
|
-
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
7
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
7
8
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
8
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -176,6 +177,26 @@ export const focusTitle = pos => (state, dispatch, editorView) => {
|
|
|
176
177
|
}
|
|
177
178
|
return false;
|
|
178
179
|
};
|
|
180
|
+
export const focusIcon = expand => (state, dispatch, editorView) => {
|
|
181
|
+
if (!expand || !(expand instanceof HTMLElement)) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
const iconContainer = expand.querySelector(`.${expandClassNames.iconContainer}`);
|
|
185
|
+
if (iconContainer && iconContainer.focus) {
|
|
186
|
+
const {
|
|
187
|
+
tr
|
|
188
|
+
} = state;
|
|
189
|
+
const pos = state.selection.from;
|
|
190
|
+
tr.setSelection(new TextSelection(tr.doc.resolve(pos)));
|
|
191
|
+
if (dispatch) {
|
|
192
|
+
dispatch(tr);
|
|
193
|
+
}
|
|
194
|
+
editorView === null || editorView === void 0 ? void 0 : editorView.dom.blur();
|
|
195
|
+
iconContainer.focus();
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
return false;
|
|
199
|
+
};
|
|
179
200
|
|
|
180
201
|
// Used to clear any node or cell selection when expand title is focused
|
|
181
202
|
export const setSelectionInsideExpand = expandPos => (_state, dispatch, editorView) => {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { backspace, bindKeymapWithCommand, moveDown, moveLeft, moveRight, moveUp, tab } from '@atlaskit/editor-common/keymaps';
|
|
2
2
|
import { GapCursorSelection, RelativeSelectionPos, Side } from '@atlaskit/editor-common/selection';
|
|
3
|
-
import { expandClassNames } from '@atlaskit/editor-common/styles';
|
|
4
3
|
import { isEmptyNode, isPositionNearTableRow } from '@atlaskit/editor-common/utils';
|
|
5
4
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
6
5
|
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
|
-
import { deleteExpand, focusTitle } from '../commands';
|
|
7
|
+
import { deleteExpand, focusIcon, focusTitle } from '../commands';
|
|
9
8
|
import { findExpand } from '../utils';
|
|
10
9
|
const isExpandNode = node => {
|
|
11
10
|
return (node === null || node === void 0 ? void 0 : node.type.name) === 'expand' || (node === null || node === void 0 ? void 0 : node.type.name) === 'nestedExpand';
|
|
@@ -48,28 +47,25 @@ export function expandKeymap(api, options) {
|
|
|
48
47
|
return false;
|
|
49
48
|
}, list);
|
|
50
49
|
bindKeymapWithCommand(tab.common, (state, dispatch, editorView) => {
|
|
51
|
-
if (
|
|
50
|
+
if (editorView && editorView.dom instanceof HTMLElement) {
|
|
52
51
|
const {
|
|
53
52
|
from
|
|
54
53
|
} = state.selection;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
dispatch(tr);
|
|
54
|
+
if (isExpandSelected(state.selection)) {
|
|
55
|
+
const expand = editorView.nodeDOM(from);
|
|
56
|
+
if (!expand || !(expand instanceof HTMLElement)) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
return focusIcon(expand)(state, dispatch, editorView);
|
|
60
|
+
} else if (state.selection instanceof TextSelection) {
|
|
61
|
+
var _dom$node$parentEleme;
|
|
62
|
+
const dom = editorView.domAtPos(from);
|
|
63
|
+
const expand = (_dom$node$parentEleme = dom.node.parentElement) === null || _dom$node$parentEleme === void 0 ? void 0 : _dom$node$parentEleme.parentElement;
|
|
64
|
+
if (!expand || !(expand instanceof HTMLElement)) {
|
|
65
|
+
return false;
|
|
68
66
|
}
|
|
69
|
-
|
|
70
|
-
iconContainer.focus();
|
|
67
|
+
return focusIcon(expand)(state, dispatch, editorView);
|
|
71
68
|
}
|
|
72
|
-
return true;
|
|
73
69
|
}
|
|
74
70
|
return false;
|
|
75
71
|
}, list);
|
|
@@ -2,9 +2,10 @@ import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
|
2
2
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, MODE, PLATFORMS } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { expandedState } from '@atlaskit/editor-common/expand';
|
|
4
4
|
import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
5
|
+
import { expandClassNames } from '@atlaskit/editor-common/styles';
|
|
5
6
|
import { findExpand } from '@atlaskit/editor-common/transforms';
|
|
6
7
|
import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
7
|
-
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
+
import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
9
|
import { findParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
9
10
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
10
11
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -183,4 +184,24 @@ export const focusTitle = pos => (state, dispatch, editorView) => {
|
|
|
183
184
|
}
|
|
184
185
|
}
|
|
185
186
|
return false;
|
|
187
|
+
};
|
|
188
|
+
export const focusIcon = expand => (state, dispatch, editorView) => {
|
|
189
|
+
if (!expand || !(expand instanceof HTMLElement)) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
const iconContainer = expand.querySelector(`.${expandClassNames.iconContainer}`);
|
|
193
|
+
if (iconContainer && iconContainer.focus) {
|
|
194
|
+
const {
|
|
195
|
+
tr
|
|
196
|
+
} = state;
|
|
197
|
+
const pos = state.selection.from;
|
|
198
|
+
tr.setSelection(new TextSelection(tr.doc.resolve(pos)));
|
|
199
|
+
if (dispatch) {
|
|
200
|
+
dispatch(tr);
|
|
201
|
+
}
|
|
202
|
+
editorView === null || editorView === void 0 ? void 0 : editorView.dom.blur();
|
|
203
|
+
iconContainer.focus();
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
return false;
|
|
186
207
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { isExpandCollapsed } from '@atlaskit/editor-common/expand';
|
|
2
|
-
import { backspace, bindKeymapWithCommand, moveDown, moveLeft, moveRight, moveUp } from '@atlaskit/editor-common/keymaps';
|
|
2
|
+
import { backspace, bindKeymapWithCommand, moveDown, moveLeft, moveRight, moveUp, tab } from '@atlaskit/editor-common/keymaps';
|
|
3
3
|
import { GapCursorSelection, RelativeSelectionPos, Side } from '@atlaskit/editor-common/selection';
|
|
4
4
|
import { findExpand } from '@atlaskit/editor-common/transforms';
|
|
5
5
|
import { isEmptyNode, isPositionNearTableRow } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
7
|
-
import { NodeSelection, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
-
import { deleteExpand, focusTitle } from '../commands';
|
|
7
|
+
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
+
import { deleteExpand, focusIcon, focusTitle } from '../commands';
|
|
9
9
|
const isExpandNode = node => {
|
|
10
10
|
return (node === null || node === void 0 ? void 0 : node.type.name) === 'expand' || (node === null || node === void 0 ? void 0 : node.type.name) === 'nestedExpand';
|
|
11
11
|
};
|
|
@@ -46,6 +46,29 @@ export function expandKeymap(api, options) {
|
|
|
46
46
|
}
|
|
47
47
|
return false;
|
|
48
48
|
}, list);
|
|
49
|
+
bindKeymapWithCommand(tab.common, (state, dispatch, editorView) => {
|
|
50
|
+
if (editorView && editorView.dom instanceof HTMLElement) {
|
|
51
|
+
const {
|
|
52
|
+
from
|
|
53
|
+
} = state.selection;
|
|
54
|
+
if (isExpandSelected(state.selection)) {
|
|
55
|
+
const expand = editorView.nodeDOM(from);
|
|
56
|
+
if (!expand || !(expand instanceof HTMLElement)) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
return focusIcon(expand)(state, dispatch, editorView);
|
|
60
|
+
} else if (state.selection instanceof TextSelection) {
|
|
61
|
+
var _dom$node$parentEleme;
|
|
62
|
+
const dom = editorView.domAtPos(from);
|
|
63
|
+
const expand = (_dom$node$parentEleme = dom.node.parentElement) === null || _dom$node$parentEleme === void 0 ? void 0 : _dom$node$parentEleme.parentElement;
|
|
64
|
+
if (!expand || !(expand instanceof HTMLElement)) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
return focusIcon(expand)(state, dispatch, editorView);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
}, list);
|
|
49
72
|
bindKeymapWithCommand(moveUp.common, (state, dispatch, editorView) => {
|
|
50
73
|
if (!editorView) {
|
|
51
74
|
return false;
|
|
@@ -4,8 +4,9 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
5
5
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, MODE, PLATFORMS } from '@atlaskit/editor-common/analytics';
|
|
6
6
|
import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
7
|
+
import { expandClassNames } from '@atlaskit/editor-common/styles';
|
|
7
8
|
import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
8
|
-
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
9
|
+
import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
9
10
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
10
11
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
11
12
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -188,6 +189,26 @@ export var focusTitle = function focusTitle(pos) {
|
|
|
188
189
|
return false;
|
|
189
190
|
};
|
|
190
191
|
};
|
|
192
|
+
export var focusIcon = function focusIcon(expand) {
|
|
193
|
+
return function (state, dispatch, editorView) {
|
|
194
|
+
if (!expand || !(expand instanceof HTMLElement)) {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
var iconContainer = expand.querySelector(".".concat(expandClassNames.iconContainer));
|
|
198
|
+
if (iconContainer && iconContainer.focus) {
|
|
199
|
+
var tr = state.tr;
|
|
200
|
+
var pos = state.selection.from;
|
|
201
|
+
tr.setSelection(new TextSelection(tr.doc.resolve(pos)));
|
|
202
|
+
if (dispatch) {
|
|
203
|
+
dispatch(tr);
|
|
204
|
+
}
|
|
205
|
+
editorView === null || editorView === void 0 || editorView.dom.blur();
|
|
206
|
+
iconContainer.focus();
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
return false;
|
|
210
|
+
};
|
|
211
|
+
};
|
|
191
212
|
|
|
192
213
|
// Used to clear any node or cell selection when expand title is focused
|
|
193
214
|
export var setSelectionInsideExpand = function setSelectionInsideExpand(expandPos) {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { backspace, bindKeymapWithCommand, moveDown, moveLeft, moveRight, moveUp, tab } from '@atlaskit/editor-common/keymaps';
|
|
2
2
|
import { GapCursorSelection, RelativeSelectionPos, Side } from '@atlaskit/editor-common/selection';
|
|
3
|
-
import { expandClassNames } from '@atlaskit/editor-common/styles';
|
|
4
3
|
import { isEmptyNode, isPositionNearTableRow } from '@atlaskit/editor-common/utils';
|
|
5
4
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
6
5
|
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
|
-
import { deleteExpand, focusTitle } from '../commands';
|
|
7
|
+
import { deleteExpand, focusIcon, focusTitle } from '../commands';
|
|
9
8
|
import { findExpand } from '../utils';
|
|
10
9
|
var isExpandNode = function isExpandNode(node) {
|
|
11
10
|
return (node === null || node === void 0 ? void 0 : node.type.name) === 'expand' || (node === null || node === void 0 ? void 0 : node.type.name) === 'nestedExpand';
|
|
@@ -42,24 +41,23 @@ export function expandKeymap(api, options) {
|
|
|
42
41
|
return false;
|
|
43
42
|
}, list);
|
|
44
43
|
bindKeymapWithCommand(tab.common, function (state, dispatch, editorView) {
|
|
45
|
-
if (
|
|
44
|
+
if (editorView && editorView.dom instanceof HTMLElement) {
|
|
46
45
|
var from = state.selection.from;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
if (isExpandSelected(state.selection)) {
|
|
47
|
+
var expand = editorView.nodeDOM(from);
|
|
48
|
+
if (!expand || !(expand instanceof HTMLElement)) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return focusIcon(expand)(state, dispatch, editorView);
|
|
52
|
+
} else if (state.selection instanceof TextSelection) {
|
|
53
|
+
var _dom$node$parentEleme;
|
|
54
|
+
var dom = editorView.domAtPos(from);
|
|
55
|
+
var _expand = (_dom$node$parentEleme = dom.node.parentElement) === null || _dom$node$parentEleme === void 0 ? void 0 : _dom$node$parentEleme.parentElement;
|
|
56
|
+
if (!_expand || !(_expand instanceof HTMLElement)) {
|
|
57
|
+
return false;
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
iconContainer.focus();
|
|
59
|
+
return focusIcon(_expand)(state, dispatch, editorView);
|
|
61
60
|
}
|
|
62
|
-
return true;
|
|
63
61
|
}
|
|
64
62
|
return false;
|
|
65
63
|
}, list);
|
|
@@ -5,9 +5,10 @@ import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
|
5
5
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, MODE, PLATFORMS } from '@atlaskit/editor-common/analytics';
|
|
6
6
|
import { expandedState } from '@atlaskit/editor-common/expand';
|
|
7
7
|
import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
8
|
+
import { expandClassNames } from '@atlaskit/editor-common/styles';
|
|
8
9
|
import { findExpand } from '@atlaskit/editor-common/transforms';
|
|
9
10
|
import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
10
|
-
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
11
|
+
import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
11
12
|
import { findParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
12
13
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
13
14
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -198,4 +199,24 @@ export var focusTitle = function focusTitle(pos) {
|
|
|
198
199
|
}
|
|
199
200
|
return false;
|
|
200
201
|
};
|
|
202
|
+
};
|
|
203
|
+
export var focusIcon = function focusIcon(expand) {
|
|
204
|
+
return function (state, dispatch, editorView) {
|
|
205
|
+
if (!expand || !(expand instanceof HTMLElement)) {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
var iconContainer = expand.querySelector(".".concat(expandClassNames.iconContainer));
|
|
209
|
+
if (iconContainer && iconContainer.focus) {
|
|
210
|
+
var tr = state.tr;
|
|
211
|
+
var pos = state.selection.from;
|
|
212
|
+
tr.setSelection(new TextSelection(tr.doc.resolve(pos)));
|
|
213
|
+
if (dispatch) {
|
|
214
|
+
dispatch(tr);
|
|
215
|
+
}
|
|
216
|
+
editorView === null || editorView === void 0 || editorView.dom.blur();
|
|
217
|
+
iconContainer.focus();
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
return false;
|
|
221
|
+
};
|
|
201
222
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { isExpandCollapsed } from '@atlaskit/editor-common/expand';
|
|
2
|
-
import { backspace, bindKeymapWithCommand, moveDown, moveLeft, moveRight, moveUp } from '@atlaskit/editor-common/keymaps';
|
|
2
|
+
import { backspace, bindKeymapWithCommand, moveDown, moveLeft, moveRight, moveUp, tab } from '@atlaskit/editor-common/keymaps';
|
|
3
3
|
import { GapCursorSelection, RelativeSelectionPos, Side } from '@atlaskit/editor-common/selection';
|
|
4
4
|
import { findExpand } from '@atlaskit/editor-common/transforms';
|
|
5
5
|
import { isEmptyNode, isPositionNearTableRow } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
7
|
-
import { NodeSelection, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
-
import { deleteExpand, focusTitle } from '../commands';
|
|
7
|
+
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
+
import { deleteExpand, focusIcon, focusTitle } from '../commands';
|
|
9
9
|
var isExpandNode = function isExpandNode(node) {
|
|
10
10
|
return (node === null || node === void 0 ? void 0 : node.type.name) === 'expand' || (node === null || node === void 0 ? void 0 : node.type.name) === 'nestedExpand';
|
|
11
11
|
};
|
|
@@ -40,6 +40,27 @@ export function expandKeymap(api, options) {
|
|
|
40
40
|
}
|
|
41
41
|
return false;
|
|
42
42
|
}, list);
|
|
43
|
+
bindKeymapWithCommand(tab.common, function (state, dispatch, editorView) {
|
|
44
|
+
if (editorView && editorView.dom instanceof HTMLElement) {
|
|
45
|
+
var from = state.selection.from;
|
|
46
|
+
if (isExpandSelected(state.selection)) {
|
|
47
|
+
var expand = editorView.nodeDOM(from);
|
|
48
|
+
if (!expand || !(expand instanceof HTMLElement)) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return focusIcon(expand)(state, dispatch, editorView);
|
|
52
|
+
} else if (state.selection instanceof TextSelection) {
|
|
53
|
+
var _dom$node$parentEleme;
|
|
54
|
+
var dom = editorView.domAtPos(from);
|
|
55
|
+
var _expand = (_dom$node$parentEleme = dom.node.parentElement) === null || _dom$node$parentEleme === void 0 ? void 0 : _dom$node$parentEleme.parentElement;
|
|
56
|
+
if (!_expand || !(_expand instanceof HTMLElement)) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
return focusIcon(_expand)(state, dispatch, editorView);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}, list);
|
|
43
64
|
bindKeymapWithCommand(moveUp.common, function (state, dispatch, editorView) {
|
|
44
65
|
if (!editorView) {
|
|
45
66
|
return false;
|
|
@@ -22,4 +22,5 @@ export declare const createExpandNode: (state: EditorState, isNestingExpandsSupp
|
|
|
22
22
|
export declare const insertExpandWithInputMethod: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, isNestingExpandsSupported?: boolean) => (inputMethod: InsertMethod) => Command;
|
|
23
23
|
export declare const insertExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, isNestingExpandsSupported?: boolean) => Command;
|
|
24
24
|
export declare const focusTitle: (pos: number) => Command;
|
|
25
|
+
export declare const focusIcon: (expand: Node) => Command;
|
|
25
26
|
export declare const setSelectionInsideExpand: (expandPos: number) => Command;
|
|
@@ -22,4 +22,5 @@ export declare const createExpandNode: (state: EditorState, isNestingExpandsSupp
|
|
|
22
22
|
export declare const insertExpandWithInputMethod: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, isNestingExpandsSupported?: boolean) => (inputMethod: InsertMethod) => Command;
|
|
23
23
|
export declare const insertExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, isNestingExpandsSupported?: boolean) => Command;
|
|
24
24
|
export declare const focusTitle: (pos: number) => Command;
|
|
25
|
+
export declare const focusIcon: (expand: Node) => Command;
|
|
25
26
|
export declare const setSelectionInsideExpand: (expandPos: number) => Command;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-expand",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "Expand plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@atlaskit/adf-schema": "^40.9.0",
|
|
37
37
|
"@atlaskit/button": "^20.1.0",
|
|
38
|
-
"@atlaskit/editor-common": "^88.
|
|
38
|
+
"@atlaskit/editor-common": "^88.3.0",
|
|
39
39
|
"@atlaskit/editor-plugin-analytics": "^1.8.0",
|
|
40
40
|
"@atlaskit/editor-plugin-decorations": "^1.3.0",
|
|
41
41
|
"@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
|