@atlaskit/editor-plugin-indentation 3.1.2 → 3.1.3
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 +7 -0
- package/dist/cjs/indentationPlugin.js +1 -0
- package/dist/cjs/pm-plugins/keymap.js +14 -2
- package/dist/es2019/indentationPlugin.js +1 -0
- package/dist/es2019/pm-plugins/keymap.js +18 -2
- package/dist/esm/indentationPlugin.js +1 -0
- package/dist/esm/pm-plugins/keymap.js +14 -2
- package/package.json +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-indentation
|
|
2
2
|
|
|
3
|
+
## 3.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`af3ebe7fda754`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/af3ebe7fda754) -
|
|
8
|
+
[EDITOR-1153] Handle when user presses "Tab" in a blockTaskItem
|
|
9
|
+
|
|
3
10
|
## 3.1.2
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -36,6 +36,7 @@ var indentationPlugin = exports.indentationPlugin = function indentationPlugin(_
|
|
|
36
36
|
});
|
|
37
37
|
return {
|
|
38
38
|
isIndentationAllowed: (0, _editorCommands.isIndentationAllowed)(editorState.schema, node),
|
|
39
|
+
// @ts-ignore - TS2869 TypeScript 5.9.2 upgrade
|
|
39
40
|
indentDisabled: (_ref2 = (indentationMark === null || indentationMark === void 0 ? void 0 : indentationMark.attrs.level) >= _indentation.MAX_INDENTATION_LEVEL) !== null && _ref2 !== void 0 ? _ref2 : false,
|
|
40
41
|
outdentDisabled: !indentationMark
|
|
41
42
|
};
|
|
@@ -9,13 +9,22 @@ var _analytics = require("@atlaskit/editor-common/analytics");
|
|
|
9
9
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
10
10
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
11
11
|
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
12
|
+
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
12
13
|
var _editorCommands = require("../editor-commands");
|
|
13
14
|
function keymapPlugin(editorAnalyticsAPI) {
|
|
14
15
|
var list = {};
|
|
15
16
|
(0, _keymaps.bindKeymapWithCommand)(
|
|
16
17
|
// Ignored via go/ees005
|
|
17
18
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
18
|
-
(0, _keymaps.findShortcutByKeymap)(_keymaps.indent), (
|
|
19
|
+
(0, _keymaps.findShortcutByKeymap)(_keymaps.indent), function (state, dispatch) {
|
|
20
|
+
var blockTaskItem = state.schema.nodes.blockTaskItem;
|
|
21
|
+
|
|
22
|
+
// Let `editor-plugin-tasks-and-decisions` handle indentation inside blockTaskItems
|
|
23
|
+
if ((0, _utils2.hasParentNodeOfType)([blockTaskItem])(state.selection)) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return (0, _editorCommands.getIndentCommand)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.KEYBOARD)(state, dispatch);
|
|
27
|
+
}, list);
|
|
19
28
|
(0, _keymaps.bindKeymapWithCommand)(
|
|
20
29
|
// Ignored via go/ees005
|
|
21
30
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -25,7 +34,10 @@ function keymapPlugin(editorAnalyticsAPI) {
|
|
|
25
34
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
26
35
|
(0, _keymaps.findShortcutByKeymap)(_keymaps.backspace), function (state, dispatch) {
|
|
27
36
|
var selection = state.selection;
|
|
28
|
-
|
|
37
|
+
var blockTaskItem = state.schema.nodes.blockTaskItem;
|
|
38
|
+
|
|
39
|
+
// Let `editor-plugin-tasks-and-decisions` handle indentation inside blockTaskItems
|
|
40
|
+
if ((0, _utils.isTextSelection)(selection) && selection.$cursor && selection.$cursor.parentOffset === 0 && !(0, _utils2.hasParentNodeOfType)([blockTaskItem])(selection)) {
|
|
29
41
|
return dispatch ? (0, _editorCommands.getOutdentCommand)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.KEYBOARD)(state, dispatch) : false;
|
|
30
42
|
}
|
|
31
43
|
return false;
|
|
@@ -37,6 +37,7 @@ export const indentationPlugin = ({
|
|
|
37
37
|
const indentationMark = node.marks.find(mark => mark.type === indentation);
|
|
38
38
|
return {
|
|
39
39
|
isIndentationAllowed: isIndentationAllowed(editorState.schema, node),
|
|
40
|
+
// @ts-ignore - TS2869 TypeScript 5.9.2 upgrade
|
|
40
41
|
indentDisabled: (_ref = (indentationMark === null || indentationMark === void 0 ? void 0 : indentationMark.attrs.level) >= MAX_INDENTATION_LEVEL) !== null && _ref !== void 0 ? _ref : false,
|
|
41
42
|
outdentDisabled: !indentationMark
|
|
42
43
|
};
|
|
@@ -2,13 +2,24 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
2
2
|
import { backspace, bindKeymapWithCommand, findShortcutByKeymap, indent, outdent } from '@atlaskit/editor-common/keymaps';
|
|
3
3
|
import { isTextSelection } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
5
|
+
import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
6
|
import { getIndentCommand, getOutdentCommand } from '../editor-commands';
|
|
6
7
|
export function keymapPlugin(editorAnalyticsAPI) {
|
|
7
8
|
const list = {};
|
|
8
9
|
bindKeymapWithCommand(
|
|
9
10
|
// Ignored via go/ees005
|
|
10
11
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
11
|
-
findShortcutByKeymap(indent),
|
|
12
|
+
findShortcutByKeymap(indent), (state, dispatch) => {
|
|
13
|
+
const {
|
|
14
|
+
blockTaskItem
|
|
15
|
+
} = state.schema.nodes;
|
|
16
|
+
|
|
17
|
+
// Let `editor-plugin-tasks-and-decisions` handle indentation inside blockTaskItems
|
|
18
|
+
if (hasParentNodeOfType([blockTaskItem])(state.selection)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return getIndentCommand(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD)(state, dispatch);
|
|
22
|
+
}, list);
|
|
12
23
|
bindKeymapWithCommand(
|
|
13
24
|
// Ignored via go/ees005
|
|
14
25
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -20,7 +31,12 @@ export function keymapPlugin(editorAnalyticsAPI) {
|
|
|
20
31
|
const {
|
|
21
32
|
selection
|
|
22
33
|
} = state;
|
|
23
|
-
|
|
34
|
+
const {
|
|
35
|
+
blockTaskItem
|
|
36
|
+
} = state.schema.nodes;
|
|
37
|
+
|
|
38
|
+
// Let `editor-plugin-tasks-and-decisions` handle indentation inside blockTaskItems
|
|
39
|
+
if (isTextSelection(selection) && selection.$cursor && selection.$cursor.parentOffset === 0 && !hasParentNodeOfType([blockTaskItem])(selection)) {
|
|
24
40
|
return dispatch ? getOutdentCommand(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD)(state, dispatch) : false;
|
|
25
41
|
}
|
|
26
42
|
return false;
|
|
@@ -30,6 +30,7 @@ export var indentationPlugin = function indentationPlugin(_ref) {
|
|
|
30
30
|
});
|
|
31
31
|
return {
|
|
32
32
|
isIndentationAllowed: isIndentationAllowed(editorState.schema, node),
|
|
33
|
+
// @ts-ignore - TS2869 TypeScript 5.9.2 upgrade
|
|
33
34
|
indentDisabled: (_ref2 = (indentationMark === null || indentationMark === void 0 ? void 0 : indentationMark.attrs.level) >= MAX_INDENTATION_LEVEL) !== null && _ref2 !== void 0 ? _ref2 : false,
|
|
34
35
|
outdentDisabled: !indentationMark
|
|
35
36
|
};
|
|
@@ -2,13 +2,22 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
2
2
|
import { backspace, bindKeymapWithCommand, findShortcutByKeymap, indent, outdent } from '@atlaskit/editor-common/keymaps';
|
|
3
3
|
import { isTextSelection } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
5
|
+
import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
6
|
import { getIndentCommand, getOutdentCommand } from '../editor-commands';
|
|
6
7
|
export function keymapPlugin(editorAnalyticsAPI) {
|
|
7
8
|
var list = {};
|
|
8
9
|
bindKeymapWithCommand(
|
|
9
10
|
// Ignored via go/ees005
|
|
10
11
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
11
|
-
findShortcutByKeymap(indent),
|
|
12
|
+
findShortcutByKeymap(indent), function (state, dispatch) {
|
|
13
|
+
var blockTaskItem = state.schema.nodes.blockTaskItem;
|
|
14
|
+
|
|
15
|
+
// Let `editor-plugin-tasks-and-decisions` handle indentation inside blockTaskItems
|
|
16
|
+
if (hasParentNodeOfType([blockTaskItem])(state.selection)) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return getIndentCommand(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD)(state, dispatch);
|
|
20
|
+
}, list);
|
|
12
21
|
bindKeymapWithCommand(
|
|
13
22
|
// Ignored via go/ees005
|
|
14
23
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -18,7 +27,10 @@ export function keymapPlugin(editorAnalyticsAPI) {
|
|
|
18
27
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
19
28
|
findShortcutByKeymap(backspace), function (state, dispatch) {
|
|
20
29
|
var selection = state.selection;
|
|
21
|
-
|
|
30
|
+
var blockTaskItem = state.schema.nodes.blockTaskItem;
|
|
31
|
+
|
|
32
|
+
// Let `editor-plugin-tasks-and-decisions` handle indentation inside blockTaskItems
|
|
33
|
+
if (isTextSelection(selection) && selection.$cursor && selection.$cursor.parentOffset === 0 && !hasParentNodeOfType([blockTaskItem])(selection)) {
|
|
22
34
|
return dispatch ? getOutdentCommand(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD)(state, dispatch) : false;
|
|
23
35
|
}
|
|
24
36
|
return false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-indentation",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"description": "Indentation plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@babel/runtime": "^7.0.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@atlaskit/editor-common": "^107.
|
|
39
|
+
"@atlaskit/editor-common": "^107.23.0",
|
|
40
40
|
"react": "^18.2.0",
|
|
41
41
|
"react-dom": "^18.2.0"
|
|
42
42
|
},
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
"@atlaskit/ssr": "workspace:^",
|
|
47
47
|
"@atlaskit/visual-regression": "workspace:^",
|
|
48
48
|
"@testing-library/react": "^13.4.0",
|
|
49
|
-
"typescript": "~5.4.2",
|
|
50
49
|
"wait-for-expect": "^1.2.0"
|
|
51
50
|
},
|
|
52
51
|
"techstack": {
|