@atlaskit/editor-plugin-text-formatting 2.2.3 → 2.2.5
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
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-text-formatting
|
|
2
2
|
|
|
3
|
+
## 2.2.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#152656](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/152656)
|
|
8
|
+
[`cd915ad2cc130`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cd915ad2cc130) -
|
|
9
|
+
Disallow keyboard formatting when selection contains text with code mark
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 2.2.4
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 2.2.3
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -8,7 +8,10 @@ var _analytics = require("@atlaskit/editor-common/analytics");
|
|
|
8
8
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
9
9
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
10
10
|
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
11
13
|
var _commands = require("./commands");
|
|
14
|
+
var _pluginKey = require("./plugin-key");
|
|
12
15
|
function keymapPlugin(schema, editorAnalyticsAPI) {
|
|
13
16
|
var list = {};
|
|
14
17
|
if (schema.marks.strong) {
|
|
@@ -53,11 +56,59 @@ function keymapPlugin(schema, editorAnalyticsAPI) {
|
|
|
53
56
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
54
57
|
_keymaps.toggleUnderline.common, (0, _commands.toggleUnderlineWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
55
58
|
}
|
|
59
|
+
var getEnabledKeylist = function getEnabledKeylist(view) {
|
|
60
|
+
var textFormattingState = _pluginKey.pluginKey.getState(view.state);
|
|
61
|
+
var list = {};
|
|
62
|
+
if (schema.marks.strong && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.strongDisabled)) {
|
|
63
|
+
(0, _keymaps.bindKeymapWithEditorCommand)(
|
|
64
|
+
// Ignored via go/ees005
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
66
|
+
_keymaps.toggleBold.common, (0, _commands.toggleStrongWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
67
|
+
}
|
|
68
|
+
if (schema.marks.em && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.emDisabled)) {
|
|
69
|
+
(0, _keymaps.bindKeymapWithEditorCommand)(
|
|
70
|
+
// Ignored via go/ees005
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
72
|
+
_keymaps.toggleItalic.common, (0, _commands.toggleEmWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
73
|
+
}
|
|
74
|
+
if (schema.marks.code && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.codeDisabled)) {
|
|
75
|
+
(0, _keymaps.bindKeymapWithEditorCommand)(
|
|
76
|
+
// Ignored via go/ees005
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
78
|
+
_keymaps.toggleCode.common, (0, _commands.toggleCodeWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
79
|
+
}
|
|
80
|
+
if (schema.marks.strike && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.strikeDisabled)) {
|
|
81
|
+
(0, _keymaps.bindKeymapWithEditorCommand)(
|
|
82
|
+
// Ignored via go/ees005
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
84
|
+
_keymaps.toggleStrikethrough.common, (0, _commands.toggleStrikeWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
85
|
+
}
|
|
86
|
+
if (schema.marks.subsup && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.subscriptDisabled)) {
|
|
87
|
+
(0, _keymaps.bindKeymapWithEditorCommand)(
|
|
88
|
+
// Ignored via go/ees005
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
90
|
+
_keymaps.toggleSubscript.common, (0, _commands.toggleSubscriptWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
91
|
+
}
|
|
92
|
+
if (schema.marks.subsup && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.superscriptDisabled)) {
|
|
93
|
+
(0, _keymaps.bindKeymapWithEditorCommand)(
|
|
94
|
+
// Ignored via go/ees005
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
96
|
+
_keymaps.toggleSuperscript.common, (0, _commands.toggleSuperscriptWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
97
|
+
}
|
|
98
|
+
if (schema.marks.underline && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.underlineDisabled)) {
|
|
99
|
+
(0, _keymaps.bindKeymapWithEditorCommand)(
|
|
100
|
+
// Ignored via go/ees005
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
102
|
+
_keymaps.toggleUnderline.common, (0, _commands.toggleUnderlineWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
103
|
+
}
|
|
104
|
+
return list;
|
|
105
|
+
};
|
|
56
106
|
return new _safePlugin.SafePlugin({
|
|
57
107
|
props: {
|
|
58
108
|
handleKeyDown: function handleKeyDown(view, event) {
|
|
59
109
|
var keyboardEvent = (0, _keymaps.isCapsLockOnAndModifyKeyboardEvent)(event);
|
|
60
|
-
|
|
110
|
+
var keymapList = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_8') ? getEnabledKeylist(view) : list;
|
|
111
|
+
return (0, _keymap.keydownHandler)(keymapList)(view, keyboardEvent);
|
|
61
112
|
}
|
|
62
113
|
}
|
|
63
114
|
});
|
|
@@ -2,7 +2,10 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
2
2
|
import { bindKeymapWithEditorCommand, isCapsLockOnAndModifyKeyboardEvent, toggleBold, toggleCode, toggleItalic, toggleStrikethrough, toggleSubscript, toggleSuperscript, toggleUnderline } from '@atlaskit/editor-common/keymaps';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
4
|
import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
7
|
import { toggleCodeWithAnalytics, toggleEmWithAnalytics, toggleStrikeWithAnalytics, toggleStrongWithAnalytics, toggleSubscriptWithAnalytics, toggleSuperscriptWithAnalytics, toggleUnderlineWithAnalytics } from './commands';
|
|
8
|
+
import { pluginKey } from './plugin-key';
|
|
6
9
|
export default function keymapPlugin(schema, editorAnalyticsAPI) {
|
|
7
10
|
const list = {};
|
|
8
11
|
if (schema.marks.strong) {
|
|
@@ -47,11 +50,59 @@ export default function keymapPlugin(schema, editorAnalyticsAPI) {
|
|
|
47
50
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
48
51
|
toggleUnderline.common, toggleUnderlineWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
49
52
|
}
|
|
53
|
+
const getEnabledKeylist = view => {
|
|
54
|
+
const textFormattingState = pluginKey.getState(view.state);
|
|
55
|
+
const list = {};
|
|
56
|
+
if (schema.marks.strong && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.strongDisabled)) {
|
|
57
|
+
bindKeymapWithEditorCommand(
|
|
58
|
+
// Ignored via go/ees005
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
60
|
+
toggleBold.common, toggleStrongWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
61
|
+
}
|
|
62
|
+
if (schema.marks.em && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.emDisabled)) {
|
|
63
|
+
bindKeymapWithEditorCommand(
|
|
64
|
+
// Ignored via go/ees005
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
66
|
+
toggleItalic.common, toggleEmWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
67
|
+
}
|
|
68
|
+
if (schema.marks.code && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.codeDisabled)) {
|
|
69
|
+
bindKeymapWithEditorCommand(
|
|
70
|
+
// Ignored via go/ees005
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
72
|
+
toggleCode.common, toggleCodeWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
73
|
+
}
|
|
74
|
+
if (schema.marks.strike && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.strikeDisabled)) {
|
|
75
|
+
bindKeymapWithEditorCommand(
|
|
76
|
+
// Ignored via go/ees005
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
78
|
+
toggleStrikethrough.common, toggleStrikeWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
79
|
+
}
|
|
80
|
+
if (schema.marks.subsup && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.subscriptDisabled)) {
|
|
81
|
+
bindKeymapWithEditorCommand(
|
|
82
|
+
// Ignored via go/ees005
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
84
|
+
toggleSubscript.common, toggleSubscriptWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
85
|
+
}
|
|
86
|
+
if (schema.marks.subsup && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.superscriptDisabled)) {
|
|
87
|
+
bindKeymapWithEditorCommand(
|
|
88
|
+
// Ignored via go/ees005
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
90
|
+
toggleSuperscript.common, toggleSuperscriptWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
91
|
+
}
|
|
92
|
+
if (schema.marks.underline && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.underlineDisabled)) {
|
|
93
|
+
bindKeymapWithEditorCommand(
|
|
94
|
+
// Ignored via go/ees005
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
96
|
+
toggleUnderline.common, toggleUnderlineWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
97
|
+
}
|
|
98
|
+
return list;
|
|
99
|
+
};
|
|
50
100
|
return new SafePlugin({
|
|
51
101
|
props: {
|
|
52
102
|
handleKeyDown(view, event) {
|
|
53
103
|
const keyboardEvent = isCapsLockOnAndModifyKeyboardEvent(event);
|
|
54
|
-
|
|
104
|
+
const keymapList = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_8') ? getEnabledKeylist(view) : list;
|
|
105
|
+
return keydownHandler(keymapList)(view, keyboardEvent);
|
|
55
106
|
}
|
|
56
107
|
}
|
|
57
108
|
});
|
|
@@ -2,7 +2,10 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
2
2
|
import { bindKeymapWithEditorCommand, isCapsLockOnAndModifyKeyboardEvent, toggleBold, toggleCode, toggleItalic, toggleStrikethrough, toggleSubscript, toggleSuperscript, toggleUnderline } from '@atlaskit/editor-common/keymaps';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
4
|
import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
7
|
import { toggleCodeWithAnalytics, toggleEmWithAnalytics, toggleStrikeWithAnalytics, toggleStrongWithAnalytics, toggleSubscriptWithAnalytics, toggleSuperscriptWithAnalytics, toggleUnderlineWithAnalytics } from './commands';
|
|
8
|
+
import { pluginKey } from './plugin-key';
|
|
6
9
|
export default function keymapPlugin(schema, editorAnalyticsAPI) {
|
|
7
10
|
var list = {};
|
|
8
11
|
if (schema.marks.strong) {
|
|
@@ -47,11 +50,59 @@ export default function keymapPlugin(schema, editorAnalyticsAPI) {
|
|
|
47
50
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
48
51
|
toggleUnderline.common, toggleUnderlineWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
49
52
|
}
|
|
53
|
+
var getEnabledKeylist = function getEnabledKeylist(view) {
|
|
54
|
+
var textFormattingState = pluginKey.getState(view.state);
|
|
55
|
+
var list = {};
|
|
56
|
+
if (schema.marks.strong && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.strongDisabled)) {
|
|
57
|
+
bindKeymapWithEditorCommand(
|
|
58
|
+
// Ignored via go/ees005
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
60
|
+
toggleBold.common, toggleStrongWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
61
|
+
}
|
|
62
|
+
if (schema.marks.em && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.emDisabled)) {
|
|
63
|
+
bindKeymapWithEditorCommand(
|
|
64
|
+
// Ignored via go/ees005
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
66
|
+
toggleItalic.common, toggleEmWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
67
|
+
}
|
|
68
|
+
if (schema.marks.code && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.codeDisabled)) {
|
|
69
|
+
bindKeymapWithEditorCommand(
|
|
70
|
+
// Ignored via go/ees005
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
72
|
+
toggleCode.common, toggleCodeWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
73
|
+
}
|
|
74
|
+
if (schema.marks.strike && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.strikeDisabled)) {
|
|
75
|
+
bindKeymapWithEditorCommand(
|
|
76
|
+
// Ignored via go/ees005
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
78
|
+
toggleStrikethrough.common, toggleStrikeWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
79
|
+
}
|
|
80
|
+
if (schema.marks.subsup && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.subscriptDisabled)) {
|
|
81
|
+
bindKeymapWithEditorCommand(
|
|
82
|
+
// Ignored via go/ees005
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
84
|
+
toggleSubscript.common, toggleSubscriptWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
85
|
+
}
|
|
86
|
+
if (schema.marks.subsup && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.superscriptDisabled)) {
|
|
87
|
+
bindKeymapWithEditorCommand(
|
|
88
|
+
// Ignored via go/ees005
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
90
|
+
toggleSuperscript.common, toggleSuperscriptWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
91
|
+
}
|
|
92
|
+
if (schema.marks.underline && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.underlineDisabled)) {
|
|
93
|
+
bindKeymapWithEditorCommand(
|
|
94
|
+
// Ignored via go/ees005
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
96
|
+
toggleUnderline.common, toggleUnderlineWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
97
|
+
}
|
|
98
|
+
return list;
|
|
99
|
+
};
|
|
50
100
|
return new SafePlugin({
|
|
51
101
|
props: {
|
|
52
102
|
handleKeyDown: function handleKeyDown(view, event) {
|
|
53
103
|
var keyboardEvent = isCapsLockOnAndModifyKeyboardEvent(event);
|
|
54
|
-
|
|
104
|
+
var keymapList = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_8') ? getEnabledKeylist(view) : list;
|
|
105
|
+
return keydownHandler(keymapList)(view, keyboardEvent);
|
|
55
106
|
}
|
|
56
107
|
}
|
|
57
108
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-text-formatting",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.5",
|
|
4
4
|
"description": "Text-formatting plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,18 +34,18 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
37
|
-
"@atlaskit/editor-common": "^
|
|
37
|
+
"@atlaskit/editor-common": "^105.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-analytics": "^2.2.0",
|
|
39
|
-
"@atlaskit/editor-plugin-base": "^
|
|
39
|
+
"@atlaskit/editor-plugin-base": "^3.0.0",
|
|
40
40
|
"@atlaskit/editor-plugin-primary-toolbar": "^3.2.0",
|
|
41
|
-
"@atlaskit/editor-plugin-selection-toolbar": "^3.
|
|
41
|
+
"@atlaskit/editor-plugin-selection-toolbar": "^3.6.0",
|
|
42
42
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
43
43
|
"@atlaskit/editor-shared-styles": "^3.4.0",
|
|
44
44
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
45
|
-
"@atlaskit/icon": "^
|
|
45
|
+
"@atlaskit/icon": "^26.0.0",
|
|
46
46
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
47
47
|
"@atlaskit/prosemirror-input-rules": "^3.3.0",
|
|
48
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
|
48
|
+
"@atlaskit/tmp-editor-statsig": "^4.19.0",
|
|
49
49
|
"@atlaskit/tokens": "^4.8.0",
|
|
50
50
|
"@babel/runtime": "^7.0.0",
|
|
51
51
|
"@emotion/react": "^11.7.1",
|