@atlaskit/editor-core 187.17.5 → 187.18.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/labs/next/presets/default.js +2 -2
- package/dist/cjs/plugins/annotation/toolbar.js +31 -8
- package/dist/cjs/plugins/base/pm-plugins/inline-cursor-target.js +7 -41
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/plugins/placeholder-text/placeholder-text-nodeview.js +0 -3
- package/dist/cjs/plugins/selection/pm-plugins/gap-cursor-main.js +27 -13
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/labs/next/presets/default.js +1 -1
- package/dist/es2019/plugins/annotation/toolbar.js +34 -9
- package/dist/es2019/plugins/base/pm-plugins/inline-cursor-target.js +9 -41
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/plugins/placeholder-text/placeholder-text-nodeview.js +0 -3
- package/dist/es2019/plugins/selection/pm-plugins/gap-cursor-main.js +27 -13
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/labs/next/presets/default.js +1 -1
- package/dist/esm/plugins/annotation/toolbar.js +30 -7
- package/dist/esm/plugins/base/pm-plugins/inline-cursor-target.js +7 -41
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/plugins/placeholder-text/placeholder-text-nodeview.js +0 -3
- package/dist/esm/plugins/selection/pm-plugins/gap-cursor-main.js +27 -13
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/extensibility.d.ts +0 -2
- package/dist/types/index.d.ts +0 -5
- package/dist/types/labs/next/presets/default.d.ts +28 -30
- package/dist/types/plugins/analytics/index.d.ts +0 -2
- package/dist/types/plugins/annotation/pm-plugins/plugin-factory.d.ts +0 -2
- package/dist/types/plugins/annotation/types.d.ts +9 -3
- package/dist/types/plugins/annotation/utils.d.ts +2 -5
- package/dist/types/plugins/base/pm-plugins/context-identifier.d.ts +1 -1
- package/dist/types/plugins/block-type/commands/block-type.d.ts +0 -2
- package/dist/types/plugins/block-type/pm-plugins/main.d.ts +6 -1
- package/dist/types/plugins/code-bidi-warning/pm-plugins/main.d.ts +1 -1
- package/dist/types/plugins/code-bidi-warning/pm-plugins/plugin-factory.d.ts +0 -2
- package/dist/types/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.d.ts +5 -1
- package/dist/types/plugins/code-block/pm-plugins/main.d.ts +2 -1
- package/dist/types/plugins/code-block/utils.d.ts +1 -1
- package/dist/types/plugins/collab-edit/utils.d.ts +1 -5
- package/dist/types/plugins/copy-button/pm-plugins/main.d.ts +10 -1
- package/dist/types/plugins/copy-button/toolbar.d.ts +0 -2
- package/dist/types/plugins/copy-button/utils.d.ts +1 -1
- package/dist/types/plugins/custom-autoformat/index.d.ts +2 -1
- package/dist/types/plugins/date/pm-plugins/main.d.ts +0 -2
- package/dist/types/plugins/expand/pm-plugins/main.d.ts +1 -1
- package/dist/types/plugins/expand/pm-plugins/plugin-factory.d.ts +0 -2
- package/dist/types/plugins/extension/plugin-factory.d.ts +0 -2
- package/dist/types/plugins/extension/utils.d.ts +1 -1
- package/dist/types/plugins/find-replace/plugin.d.ts +0 -2
- package/dist/types/plugins/find-replace/utils/index.d.ts +1 -4
- package/dist/types/plugins/floating-toolbar/pm-plugins/force-focus/index.d.ts +3 -1
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.d.ts +0 -2
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/list/pm-plugins/input-rules/wrapping-join-rule.d.ts +1 -2
- package/dist/types/plugins/media/commands/helpers.d.ts +1 -1
- package/dist/types/plugins/media/pm-plugins/alt-text/index.d.ts +1 -3
- package/dist/types/plugins/media/pm-plugins/linking/index.d.ts +0 -2
- package/dist/types/plugins/media/toolbar/utils.d.ts +1 -3
- package/dist/types/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +0 -1
- package/dist/types/plugins/media/ui/ResizableMediaSingle/index.d.ts +0 -1
- package/dist/types/plugins/mobile-dimensions/plugin-factory.d.ts +0 -2
- package/dist/types/plugins/panel/utils.d.ts +1 -1
- package/dist/types/plugins/paste/pm-plugins/main.d.ts +1 -1
- package/dist/types/plugins/paste/pm-plugins/plugin-factory.d.ts +0 -2
- package/dist/types/plugins/paste/util/index.d.ts +1 -1
- package/dist/types/plugins/selection/plugin-factory.d.ts +0 -2
- package/dist/types/plugins/selection/pm-plugins/gap-cursor-main.d.ts +1 -1
- package/dist/types/plugins/selection/pm-plugins/selection-main.d.ts +1 -1
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/helpers.d.ts +1 -2
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types/utils/action.d.ts +1 -60
- package/dist/types/utils/list-commands.d.ts +0 -1
- package/dist/types-ts4.5/extensibility.d.ts +0 -2
- package/dist/types-ts4.5/index.d.ts +0 -5
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +28 -30
- package/dist/types-ts4.5/plugins/analytics/index.d.ts +0 -2
- package/dist/types-ts4.5/plugins/annotation/pm-plugins/plugin-factory.d.ts +0 -2
- package/dist/types-ts4.5/plugins/annotation/types.d.ts +9 -3
- package/dist/types-ts4.5/plugins/annotation/utils.d.ts +2 -5
- package/dist/types-ts4.5/plugins/base/pm-plugins/context-identifier.d.ts +1 -1
- package/dist/types-ts4.5/plugins/block-type/commands/block-type.d.ts +0 -2
- package/dist/types-ts4.5/plugins/block-type/pm-plugins/main.d.ts +6 -1
- package/dist/types-ts4.5/plugins/code-bidi-warning/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/plugins/code-bidi-warning/pm-plugins/plugin-factory.d.ts +0 -2
- package/dist/types-ts4.5/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.d.ts +8 -1
- package/dist/types-ts4.5/plugins/code-block/pm-plugins/main.d.ts +2 -1
- package/dist/types-ts4.5/plugins/code-block/utils.d.ts +1 -1
- package/dist/types-ts4.5/plugins/collab-edit/utils.d.ts +1 -5
- package/dist/types-ts4.5/plugins/copy-button/pm-plugins/main.d.ts +10 -1
- package/dist/types-ts4.5/plugins/copy-button/toolbar.d.ts +0 -2
- package/dist/types-ts4.5/plugins/copy-button/utils.d.ts +1 -1
- package/dist/types-ts4.5/plugins/custom-autoformat/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/date/pm-plugins/main.d.ts +0 -2
- package/dist/types-ts4.5/plugins/expand/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/plugins/expand/pm-plugins/plugin-factory.d.ts +0 -2
- package/dist/types-ts4.5/plugins/extension/plugin-factory.d.ts +0 -2
- package/dist/types-ts4.5/plugins/extension/utils.d.ts +1 -1
- package/dist/types-ts4.5/plugins/find-replace/plugin.d.ts +0 -2
- package/dist/types-ts4.5/plugins/find-replace/utils/index.d.ts +1 -4
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/force-focus/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.d.ts +0 -2
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/list/pm-plugins/input-rules/wrapping-join-rule.d.ts +1 -2
- package/dist/types-ts4.5/plugins/media/commands/helpers.d.ts +1 -1
- package/dist/types-ts4.5/plugins/media/pm-plugins/alt-text/index.d.ts +1 -3
- package/dist/types-ts4.5/plugins/media/pm-plugins/linking/index.d.ts +0 -2
- package/dist/types-ts4.5/plugins/media/toolbar/utils.d.ts +1 -3
- package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +0 -1
- package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/mobile-dimensions/plugin-factory.d.ts +0 -2
- package/dist/types-ts4.5/plugins/panel/utils.d.ts +1 -1
- package/dist/types-ts4.5/plugins/paste/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/plugins/paste/pm-plugins/plugin-factory.d.ts +0 -2
- package/dist/types-ts4.5/plugins/paste/util/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/selection/plugin-factory.d.ts +0 -2
- package/dist/types-ts4.5/plugins/selection/pm-plugins/gap-cursor-main.d.ts +1 -1
- package/dist/types-ts4.5/plugins/selection/pm-plugins/selection-main.d.ts +1 -1
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/helpers.d.ts +1 -2
- package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types-ts4.5/utils/action.d.ts +1 -60
- package/dist/types-ts4.5/utils/list-commands.d.ts +0 -1
- package/package.json +5 -4
- package/report.api.md +1 -24
- package/tmp/api-report-tmp.d.ts +1 -21
- package/dist/cjs/plugins/text-formatting/actions.js +0 -188
- package/dist/cjs/plugins/text-formatting/commands/clear-formatting.js +0 -111
- package/dist/cjs/plugins/text-formatting/commands/text-formatting.js +0 -143
- package/dist/cjs/plugins/text-formatting/commands/transform-to-code.js +0 -68
- package/dist/cjs/plugins/text-formatting/index.js +0 -136
- package/dist/cjs/plugins/text-formatting/pm-plugins/clear-formatting-keymap.js +0 -21
- package/dist/cjs/plugins/text-formatting/pm-plugins/clear-formatting.js +0 -36
- package/dist/cjs/plugins/text-formatting/pm-plugins/cursor.js +0 -55
- package/dist/cjs/plugins/text-formatting/pm-plugins/input-rule.js +0 -276
- package/dist/cjs/plugins/text-formatting/pm-plugins/keymap.js +0 -52
- package/dist/cjs/plugins/text-formatting/pm-plugins/main.js +0 -113
- package/dist/cjs/plugins/text-formatting/pm-plugins/plugin-key.js +0 -9
- package/dist/cjs/plugins/text-formatting/pm-plugins/smart-input-rule.js +0 -176
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/constants.js +0 -19
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +0 -86
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.js +0 -53
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.js +0 -225
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/hooks/menu-state.js +0 -23
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/hooks/responsive-toolbar-buttons.js +0 -60
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/index.js +0 -201
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/more-button.js +0 -40
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/single-toolbar-buttons.js +0 -46
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/types.js +0 -17
- package/dist/cjs/plugins/text-formatting/utils/cell-selection.js +0 -12
- package/dist/cjs/plugins/text-formatting/utils.js +0 -86
- package/dist/es2019/plugins/text-formatting/actions.js +0 -161
- package/dist/es2019/plugins/text-formatting/commands/clear-formatting.js +0 -105
- package/dist/es2019/plugins/text-formatting/commands/text-formatting.js +0 -144
- package/dist/es2019/plugins/text-formatting/commands/transform-to-code.js +0 -71
- package/dist/es2019/plugins/text-formatting/index.js +0 -127
- package/dist/es2019/plugins/text-formatting/pm-plugins/clear-formatting-keymap.js +0 -10
- package/dist/es2019/plugins/text-formatting/pm-plugins/clear-formatting.js +0 -26
- package/dist/es2019/plugins/text-formatting/pm-plugins/cursor.js +0 -52
- package/dist/es2019/plugins/text-formatting/pm-plugins/input-rule.js +0 -244
- package/dist/es2019/plugins/text-formatting/pm-plugins/keymap.js +0 -43
- package/dist/es2019/plugins/text-formatting/pm-plugins/main.js +0 -109
- package/dist/es2019/plugins/text-formatting/pm-plugins/plugin-key.js +0 -2
- package/dist/es2019/plugins/text-formatting/pm-plugins/smart-input-rule.js +0 -155
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/constants.js +0 -20
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +0 -66
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.js +0 -42
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.js +0 -210
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/hooks/menu-state.js +0 -11
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/hooks/responsive-toolbar-buttons.js +0 -48
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/index.js +0 -168
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/more-button.js +0 -32
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/single-toolbar-buttons.js +0 -36
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/types.js +0 -10
- package/dist/es2019/plugins/text-formatting/utils/cell-selection.js +0 -5
- package/dist/es2019/plugins/text-formatting/utils.js +0 -74
- package/dist/esm/plugins/text-formatting/actions.js +0 -168
- package/dist/esm/plugins/text-formatting/commands/clear-formatting.js +0 -101
- package/dist/esm/plugins/text-formatting/commands/text-formatting.js +0 -134
- package/dist/esm/plugins/text-formatting/commands/transform-to-code.js +0 -61
- package/dist/esm/plugins/text-formatting/index.js +0 -128
- package/dist/esm/plugins/text-formatting/pm-plugins/clear-formatting-keymap.js +0 -10
- package/dist/esm/plugins/text-formatting/pm-plugins/clear-formatting.js +0 -28
- package/dist/esm/plugins/text-formatting/pm-plugins/cursor.js +0 -48
- package/dist/esm/plugins/text-formatting/pm-plugins/input-rule.js +0 -259
- package/dist/esm/plugins/text-formatting/pm-plugins/keymap.js +0 -43
- package/dist/esm/plugins/text-formatting/pm-plugins/main.js +0 -98
- package/dist/esm/plugins/text-formatting/pm-plugins/plugin-key.js +0 -2
- package/dist/esm/plugins/text-formatting/pm-plugins/smart-input-rule.js +0 -169
- package/dist/esm/plugins/text-formatting/ui/Toolbar/constants.js +0 -8
- package/dist/esm/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +0 -75
- package/dist/esm/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.js +0 -45
- package/dist/esm/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.js +0 -213
- package/dist/esm/plugins/text-formatting/ui/Toolbar/hooks/menu-state.js +0 -15
- package/dist/esm/plugins/text-formatting/ui/Toolbar/hooks/responsive-toolbar-buttons.js +0 -50
- package/dist/esm/plugins/text-formatting/ui/Toolbar/index.js +0 -191
- package/dist/esm/plugins/text-formatting/ui/Toolbar/more-button.js +0 -31
- package/dist/esm/plugins/text-formatting/ui/Toolbar/single-toolbar-buttons.js +0 -35
- package/dist/esm/plugins/text-formatting/ui/Toolbar/types.js +0 -10
- package/dist/esm/plugins/text-formatting/utils/cell-selection.js +0 -5
- package/dist/esm/plugins/text-formatting/utils.js +0 -75
- package/dist/types/plugins/text-formatting/actions.d.ts +0 -22
- package/dist/types/plugins/text-formatting/commands/clear-formatting.d.ts +0 -6
- package/dist/types/plugins/text-formatting/commands/text-formatting.d.ts +0 -5
- package/dist/types/plugins/text-formatting/commands/transform-to-code.d.ts +0 -2
- package/dist/types/plugins/text-formatting/index.d.ts +0 -17
- package/dist/types/plugins/text-formatting/pm-plugins/clear-formatting-keymap.d.ts +0 -4
- package/dist/types/plugins/text-formatting/pm-plugins/clear-formatting.d.ts +0 -8
- package/dist/types/plugins/text-formatting/pm-plugins/cursor.d.ts +0 -3
- package/dist/types/plugins/text-formatting/pm-plugins/input-rule.d.ts +0 -24
- package/dist/types/plugins/text-formatting/pm-plugins/keymap.d.ts +0 -4
- package/dist/types/plugins/text-formatting/pm-plugins/main.d.ts +0 -7
- package/dist/types/plugins/text-formatting/pm-plugins/plugin-key.d.ts +0 -3
- package/dist/types/plugins/text-formatting/pm-plugins/smart-input-rule.d.ts +0 -3
- package/dist/types/plugins/text-formatting/ui/Toolbar/constants.d.ts +0 -6
- package/dist/types/plugins/text-formatting/ui/Toolbar/dropdown-menu.d.ts +0 -15
- package/dist/types/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.d.ts +0 -7
- package/dist/types/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.d.ts +0 -14
- package/dist/types/plugins/text-formatting/ui/Toolbar/hooks/menu-state.d.ts +0 -1
- package/dist/types/plugins/text-formatting/ui/Toolbar/hooks/responsive-toolbar-buttons.d.ts +0 -20
- package/dist/types/plugins/text-formatting/ui/Toolbar/index.d.ts +0 -26
- package/dist/types/plugins/text-formatting/ui/Toolbar/more-button.d.ts +0 -13
- package/dist/types/plugins/text-formatting/ui/Toolbar/single-toolbar-buttons.d.ts +0 -9
- package/dist/types/plugins/text-formatting/ui/Toolbar/types.d.ts +0 -32
- package/dist/types/plugins/text-formatting/utils/cell-selection.d.ts +0 -3
- package/dist/types/plugins/text-formatting/utils.d.ts +0 -11
- package/dist/types-ts4.5/plugins/text-formatting/actions.d.ts +0 -22
- package/dist/types-ts4.5/plugins/text-formatting/commands/clear-formatting.d.ts +0 -6
- package/dist/types-ts4.5/plugins/text-formatting/commands/text-formatting.d.ts +0 -5
- package/dist/types-ts4.5/plugins/text-formatting/commands/transform-to-code.d.ts +0 -2
- package/dist/types-ts4.5/plugins/text-formatting/index.d.ts +0 -19
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/clear-formatting-keymap.d.ts +0 -4
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/clear-formatting.d.ts +0 -8
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/cursor.d.ts +0 -3
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/input-rule.d.ts +0 -24
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/keymap.d.ts +0 -4
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/main.d.ts +0 -7
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/plugin-key.d.ts +0 -3
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/smart-input-rule.d.ts +0 -3
- package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/constants.d.ts +0 -6
- package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/dropdown-menu.d.ts +0 -15
- package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.d.ts +0 -7
- package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.d.ts +0 -14
- package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/hooks/menu-state.d.ts +0 -5
- package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/hooks/responsive-toolbar-buttons.d.ts +0 -20
- package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/index.d.ts +0 -26
- package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/more-button.d.ts +0 -13
- package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/single-toolbar-buttons.d.ts +0 -9
- package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/types.d.ts +0 -32
- package/dist/types-ts4.5/plugins/text-formatting/utils/cell-selection.d.ts +0 -3
- package/dist/types-ts4.5/plugins/text-formatting/utils.d.ts +0 -11
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
2
|
-
import * as keymaps from '@atlaskit/editor-common/keymaps';
|
|
3
|
-
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import { clearFormattingWithAnalytics } from '../commands/clear-formatting';
|
|
5
|
-
export function keymapPlugin(editorAnalyticsAPI) {
|
|
6
|
-
const list = {};
|
|
7
|
-
keymaps.bindKeymapWithCommand(keymaps.clearFormatting.common, clearFormattingWithAnalytics(INPUT_METHOD.SHORTCUT, editorAnalyticsAPI), list);
|
|
8
|
-
return keymap(list);
|
|
9
|
-
}
|
|
10
|
-
export default keymapPlugin;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import { checkFormattingIsPresent } from '../utils';
|
|
4
|
-
export const pluginKey = new PluginKey('clearFormattingPlugin');
|
|
5
|
-
export const plugin = dispatch => new SafePlugin({
|
|
6
|
-
state: {
|
|
7
|
-
init(_config, state) {
|
|
8
|
-
return {
|
|
9
|
-
formattingIsPresent: checkFormattingIsPresent(state)
|
|
10
|
-
};
|
|
11
|
-
},
|
|
12
|
-
apply(_tr, pluginState, _oldState, newState) {
|
|
13
|
-
const formattingIsPresent = checkFormattingIsPresent(newState);
|
|
14
|
-
if (formattingIsPresent !== pluginState.formattingIsPresent) {
|
|
15
|
-
dispatch(pluginKey, {
|
|
16
|
-
formattingIsPresent
|
|
17
|
-
});
|
|
18
|
-
return {
|
|
19
|
-
formattingIsPresent
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
return pluginState;
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
key: pluginKey
|
|
26
|
-
});
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
export default new SafePlugin({
|
|
4
|
-
props: {
|
|
5
|
-
handleClick(view, clickPos, event) {
|
|
6
|
-
// Don't apply in Edge as per ED-4546
|
|
7
|
-
if (navigator && /Edge\/\d/.test(navigator.userAgent)) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// @see ED-6231
|
|
12
|
-
if (clickPos > view.state.doc.content.size) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
const {
|
|
16
|
-
code
|
|
17
|
-
} = view.state.schema.marks;
|
|
18
|
-
const {
|
|
19
|
-
paragraph
|
|
20
|
-
} = view.state.schema.nodes;
|
|
21
|
-
const $click = view.state.doc.resolve(clickPos);
|
|
22
|
-
const clickWasAtEdgeOfATextNode = ($click.nodeBefore ? $click.nodeBefore.isInline : $click.nodeAfter) && ($click.nodeAfter ? $click.nodeAfter.isInline : $click.nodeBefore) && $click.textOffset === 0;
|
|
23
|
-
const clickWasNearACodeMark = code && ($click.nodeBefore && code.isInSet($click.nodeBefore.marks) || $click.nodeAfter && code.isInSet($click.nodeAfter.marks));
|
|
24
|
-
|
|
25
|
-
// Find the starting position of the clicked dom-element
|
|
26
|
-
// TODO: Remove calls to private API
|
|
27
|
-
const clickedDOMElementPosition = event.target && event.target instanceof Node && view.posAtDOM(event.target);
|
|
28
|
-
const clickNode = view.state.doc.nodeAt(clickPos);
|
|
29
|
-
const clickWasAtTextNode = !!(clickNode && clickNode.isText);
|
|
30
|
-
const clickWasAtEndOfAParagraphNode = $click.parent.type === paragraph && $click.textOffset === 0 && $click.nodeAfter === null;
|
|
31
|
-
if (clickWasAtEdgeOfATextNode && clickWasNearACodeMark && clickedDOMElementPosition && (
|
|
32
|
-
// if click did not occur at a text node or end of paragraph, then
|
|
33
|
-
// it was at a directly adjacent non-text node, so we skip this manual
|
|
34
|
-
// text selection logic to preserve that non-text node's selection
|
|
35
|
-
clickWasAtTextNode || clickWasAtEndOfAParagraphNode)) {
|
|
36
|
-
const clickWasInsideNodeDOM = event.target.parentNode === view.domAtPos(clickedDOMElementPosition).node && code.isInSet(view.state.doc.resolve(clickedDOMElementPosition).nodeAfter.marks);
|
|
37
|
-
const nodeNextToClick = $click.nodeBefore && code.isInSet($click.nodeBefore.marks) ? $click.nodeAfter : $click.nodeBefore;
|
|
38
|
-
|
|
39
|
-
// Need to set the selection here to allow clicking between [code('text'),{<>},emoji()]
|
|
40
|
-
const tr = view.state.tr.setSelection(TextSelection.near($click));
|
|
41
|
-
if (clickWasInsideNodeDOM) {
|
|
42
|
-
tr.setStoredMarks([code.create()]);
|
|
43
|
-
} else {
|
|
44
|
-
tr.setStoredMarks(nodeNextToClick ? nodeNextToClick.marks : []);
|
|
45
|
-
}
|
|
46
|
-
view.dispatch(tr);
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import { createRule, createPlugin, leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
|
|
2
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import { transformSmartCharsMentionsAndEmojis } from '@atlaskit/editor-common/mark';
|
|
4
|
-
import { inputRuleWithAnalytics } from '@atlaskit/editor-common/utils';
|
|
5
|
-
var ValidAutoformatChars = /*#__PURE__*/function (ValidAutoformatChars) {
|
|
6
|
-
ValidAutoformatChars["STRONG"] = "__";
|
|
7
|
-
ValidAutoformatChars["STRIKE"] = "~~";
|
|
8
|
-
ValidAutoformatChars["STRONG_MARKDOWN"] = "**";
|
|
9
|
-
ValidAutoformatChars["ITALIC_MARKDOWN"] = "*";
|
|
10
|
-
ValidAutoformatChars["ITALIC"] = "_";
|
|
11
|
-
ValidAutoformatChars["CODE"] = "`";
|
|
12
|
-
return ValidAutoformatChars;
|
|
13
|
-
}(ValidAutoformatChars || {});
|
|
14
|
-
export const ValidCombinations = {
|
|
15
|
-
[ValidAutoformatChars.STRIKE]: [
|
|
16
|
-
// e.g: _~~lol~~_
|
|
17
|
-
ValidAutoformatChars.ITALIC,
|
|
18
|
-
// e.g: __~~lol~~__
|
|
19
|
-
ValidAutoformatChars.STRONG,
|
|
20
|
-
// e.g: **~~lol~~**
|
|
21
|
-
ValidAutoformatChars.STRONG_MARKDOWN,
|
|
22
|
-
// e.g: *~~lol~~*
|
|
23
|
-
ValidAutoformatChars.ITALIC_MARKDOWN],
|
|
24
|
-
[ValidAutoformatChars.STRONG]: [
|
|
25
|
-
// e.g: ~~__lol__~~
|
|
26
|
-
ValidAutoformatChars.STRIKE,
|
|
27
|
-
// e.g: *__lol__*
|
|
28
|
-
ValidAutoformatChars.ITALIC_MARKDOWN],
|
|
29
|
-
[ValidAutoformatChars.STRONG_MARKDOWN]: [
|
|
30
|
-
// e.g: _**lol**_
|
|
31
|
-
ValidAutoformatChars.ITALIC,
|
|
32
|
-
// e.g: ~~**lol**~~
|
|
33
|
-
ValidAutoformatChars.STRIKE],
|
|
34
|
-
[ValidAutoformatChars.ITALIC_MARKDOWN]: [
|
|
35
|
-
// e.g: ~~*lol*~~
|
|
36
|
-
ValidAutoformatChars.STRIKE,
|
|
37
|
-
// e.g: __*lol*__
|
|
38
|
-
ValidAutoformatChars.STRONG],
|
|
39
|
-
[ValidAutoformatChars.ITALIC]: [
|
|
40
|
-
// e.g: ~~_lol_~~
|
|
41
|
-
ValidAutoformatChars.STRIKE,
|
|
42
|
-
// e.g: **_lol_**
|
|
43
|
-
ValidAutoformatChars.STRONG_MARKDOWN],
|
|
44
|
-
[ValidAutoformatChars.CODE]: [
|
|
45
|
-
// e.g: loko (`some code`
|
|
46
|
-
'( ']
|
|
47
|
-
};
|
|
48
|
-
function addMark(markType, schema, char) {
|
|
49
|
-
return (state, match, start, end) => {
|
|
50
|
-
var _schema$marks, _schema$marks$code;
|
|
51
|
-
const {
|
|
52
|
-
doc,
|
|
53
|
-
schema,
|
|
54
|
-
tr
|
|
55
|
-
} = state;
|
|
56
|
-
const textPrefix = state.doc.textBetween(start, start + char.length);
|
|
57
|
-
|
|
58
|
-
// fixes the following case: my `*name` is *
|
|
59
|
-
// expected result: should ignore special characters inside "code"
|
|
60
|
-
if (textPrefix !== char || schema !== null && schema !== void 0 && (_schema$marks = schema.marks) !== null && _schema$marks !== void 0 && (_schema$marks$code = _schema$marks.code) !== null && _schema$marks$code !== void 0 && _schema$marks$code.isInSet(doc.resolve(start + 1).marks())) {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Prevent autoformatting across hardbreaks
|
|
65
|
-
let containsHardBreak;
|
|
66
|
-
doc.nodesBetween(start, end, node => {
|
|
67
|
-
if (node.type === schema.nodes.hardBreak) {
|
|
68
|
-
containsHardBreak = true;
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
return !containsHardBreak;
|
|
72
|
-
});
|
|
73
|
-
if (containsHardBreak) {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// fixes autoformatting in heading nodes: # Heading *bold*
|
|
78
|
-
// expected result: should not autoformat *bold*; <h1>Heading *bold*</h1>
|
|
79
|
-
const startPosResolved = doc.resolve(start);
|
|
80
|
-
const endPosResolved = doc.resolve(end);
|
|
81
|
-
if (startPosResolved.sameParent(endPosResolved) && !startPosResolved.parent.type.allowsMarkType(markType)) {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
if (markType.name === 'code') {
|
|
85
|
-
transformSmartCharsMentionsAndEmojis(tr.mapping.map(start), tr.mapping.map(end), tr);
|
|
86
|
-
}
|
|
87
|
-
const mappedStart = tr.mapping.map(start);
|
|
88
|
-
const mappedEnd = tr.mapping.map(end);
|
|
89
|
-
tr.addMark(mappedStart, mappedEnd, markType.create());
|
|
90
|
-
const textSuffix = tr.doc.textBetween(mappedEnd - char.length, mappedEnd);
|
|
91
|
-
if (textSuffix === char) {
|
|
92
|
-
tr.delete(mappedEnd - char.length, mappedEnd);
|
|
93
|
-
}
|
|
94
|
-
if (textPrefix === char) {
|
|
95
|
-
tr.delete(mappedStart, mappedStart + char.length);
|
|
96
|
-
}
|
|
97
|
-
return tr.removeStoredMark(markType);
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
class ReverseRegexExp extends RegExp {
|
|
101
|
-
exec(str) {
|
|
102
|
-
if (!str) {
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
const reverseStr = [...str].reverse().join('');
|
|
106
|
-
const result = super.exec(reverseStr);
|
|
107
|
-
if (!result) {
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
for (let i = 0; i < result.length; i++) {
|
|
111
|
-
if (result[i] && typeof result[i] === 'string') {
|
|
112
|
-
result[i] = [...result[i]].reverse().join('');
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
if (result.input && typeof result.input === 'string') {
|
|
116
|
-
result.input = [...result.input].reverse().join('');
|
|
117
|
-
}
|
|
118
|
-
if (result.input && result[0]) {
|
|
119
|
-
result.index = result.input.length - result[0].length;
|
|
120
|
-
}
|
|
121
|
-
return result;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
const buildRegex = char => {
|
|
125
|
-
const escapedChar = char.replace(/(\W)/g, '\\$1');
|
|
126
|
-
const combinations = ValidCombinations[char].map(c => c.replace(/(\W)/g, '\\$1')).join('|');
|
|
127
|
-
|
|
128
|
-
// Single X - https://regex101.com/r/McT3yq/14/
|
|
129
|
-
// Double X - https://regex101.com/r/pQUgjx/1/
|
|
130
|
-
const baseRegex = '^X(?=[^X\\s]).*?[^\\sX]X(?=[\\sOBJECT_REPLACEMENT_CHARACTER]COMBINATIONS|$)'.replace('OBJECT_REPLACEMENT_CHARACTER', leafNodeReplacementCharacter).replace('COMBINATIONS', combinations ? `|${combinations}` : '');
|
|
131
|
-
const replacedRegex = String.prototype.hasOwnProperty('replaceAll') ? baseRegex.replaceAll('X', escapedChar) : baseRegex.replace(/X/g, escapedChar);
|
|
132
|
-
return new ReverseRegexExp(replacedRegex);
|
|
133
|
-
};
|
|
134
|
-
export const strongRegex1 = buildRegex(ValidAutoformatChars.STRONG);
|
|
135
|
-
export const strongRegex2 = buildRegex(ValidAutoformatChars.STRONG_MARKDOWN);
|
|
136
|
-
export const italicRegex1 = buildRegex(ValidAutoformatChars.ITALIC);
|
|
137
|
-
export const italicRegex2 = buildRegex(ValidAutoformatChars.ITALIC_MARKDOWN);
|
|
138
|
-
export const strikeRegex = buildRegex(ValidAutoformatChars.STRIKE);
|
|
139
|
-
export const codeRegex = buildRegex(ValidAutoformatChars.CODE);
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Create input rules for strong mark
|
|
143
|
-
*
|
|
144
|
-
* @param {Schema} schema
|
|
145
|
-
* @returns {InputRuleWrapper[]}
|
|
146
|
-
*/
|
|
147
|
-
function getStrongInputRules(schema, editorAnalyticsAPI) {
|
|
148
|
-
const ruleWithStrongAnalytics = inputRuleWithAnalytics({
|
|
149
|
-
action: ACTION.FORMATTED,
|
|
150
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
151
|
-
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_STRONG,
|
|
152
|
-
eventType: EVENT_TYPE.TRACK,
|
|
153
|
-
attributes: {
|
|
154
|
-
inputMethod: INPUT_METHOD.FORMATTING
|
|
155
|
-
}
|
|
156
|
-
}, editorAnalyticsAPI);
|
|
157
|
-
// **string** or __strong__ should bold the text
|
|
158
|
-
const doubleUnderscoreRule = createRule(strongRegex1, addMark(schema.marks.strong, schema, ValidAutoformatChars.STRONG));
|
|
159
|
-
const doubleAsterixRule = createRule(strongRegex2, addMark(schema.marks.strong, schema, ValidAutoformatChars.STRONG_MARKDOWN));
|
|
160
|
-
return [ruleWithStrongAnalytics(doubleUnderscoreRule), ruleWithStrongAnalytics(doubleAsterixRule)];
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Create input rules for em mark
|
|
165
|
-
*
|
|
166
|
-
* @param {Schema} schema
|
|
167
|
-
* @returns {InputRuleWrapper[]}
|
|
168
|
-
*/
|
|
169
|
-
function getItalicInputRules(schema, editorAnalyticsAPI) {
|
|
170
|
-
const ruleWithItalicAnalytics = inputRuleWithAnalytics({
|
|
171
|
-
action: ACTION.FORMATTED,
|
|
172
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
173
|
-
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_ITALIC,
|
|
174
|
-
eventType: EVENT_TYPE.TRACK,
|
|
175
|
-
attributes: {
|
|
176
|
-
inputMethod: INPUT_METHOD.FORMATTING
|
|
177
|
-
}
|
|
178
|
-
}, editorAnalyticsAPI);
|
|
179
|
-
const underscoreRule = createRule(italicRegex1, addMark(schema.marks.em, schema, ValidAutoformatChars.ITALIC));
|
|
180
|
-
const asterixRule = createRule(italicRegex2, addMark(schema.marks.em, schema, ValidAutoformatChars.ITALIC_MARKDOWN));
|
|
181
|
-
return [ruleWithItalicAnalytics(underscoreRule), ruleWithItalicAnalytics(asterixRule)];
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Create input rules for strike mark
|
|
186
|
-
*
|
|
187
|
-
* @param {Schema} schema
|
|
188
|
-
* @returns {InputRuleWrapper[]}
|
|
189
|
-
*/
|
|
190
|
-
function getStrikeInputRules(schema, editorAnalyticsAPI) {
|
|
191
|
-
const ruleWithStrikeAnalytics = inputRuleWithAnalytics({
|
|
192
|
-
action: ACTION.FORMATTED,
|
|
193
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
194
|
-
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_STRIKE,
|
|
195
|
-
eventType: EVENT_TYPE.TRACK,
|
|
196
|
-
attributes: {
|
|
197
|
-
inputMethod: INPUT_METHOD.FORMATTING
|
|
198
|
-
}
|
|
199
|
-
}, editorAnalyticsAPI);
|
|
200
|
-
const doubleTildeRule = createRule(strikeRegex, addMark(schema.marks.strike, schema, ValidAutoformatChars.STRIKE));
|
|
201
|
-
return [ruleWithStrikeAnalytics(doubleTildeRule)];
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Create input rules for code mark
|
|
206
|
-
*
|
|
207
|
-
* @param {Schema} schema
|
|
208
|
-
* @returns {InputRuleWrapper[]}
|
|
209
|
-
*/
|
|
210
|
-
function getCodeInputRules(schema, editorAnalyticsAPI) {
|
|
211
|
-
const ruleWithCodeAnalytics = inputRuleWithAnalytics({
|
|
212
|
-
action: ACTION.FORMATTED,
|
|
213
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
214
|
-
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_CODE,
|
|
215
|
-
eventType: EVENT_TYPE.TRACK,
|
|
216
|
-
attributes: {
|
|
217
|
-
inputMethod: INPUT_METHOD.FORMATTING
|
|
218
|
-
}
|
|
219
|
-
}, editorAnalyticsAPI);
|
|
220
|
-
const backTickRule = createRule(codeRegex, addMark(schema.marks.code, schema, ValidAutoformatChars.CODE));
|
|
221
|
-
return [ruleWithCodeAnalytics(backTickRule)];
|
|
222
|
-
}
|
|
223
|
-
export function inputRulePlugin(schema,
|
|
224
|
-
// Don't remove the unused featureFlags, this gets used to test if we're properly passing them to the PM plugin
|
|
225
|
-
_featureFlags, editorAnalyticsAPI) {
|
|
226
|
-
const rules = [];
|
|
227
|
-
if (schema.marks.strong) {
|
|
228
|
-
rules.push(...getStrongInputRules(schema, editorAnalyticsAPI));
|
|
229
|
-
}
|
|
230
|
-
if (schema.marks.em) {
|
|
231
|
-
rules.push(...getItalicInputRules(schema, editorAnalyticsAPI));
|
|
232
|
-
}
|
|
233
|
-
if (schema.marks.strike) {
|
|
234
|
-
rules.push(...getStrikeInputRules(schema, editorAnalyticsAPI));
|
|
235
|
-
}
|
|
236
|
-
if (schema.marks.code) {
|
|
237
|
-
rules.push(...getCodeInputRules(schema, editorAnalyticsAPI));
|
|
238
|
-
}
|
|
239
|
-
if (rules.length !== 0) {
|
|
240
|
-
return createPlugin('text-formatting', rules);
|
|
241
|
-
}
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
export default inputRulePlugin;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import * as keymaps from '@atlaskit/editor-common/keymaps';
|
|
2
|
-
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
3
|
-
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import { toggleStrongWithAnalytics, toggleEmWithAnalytics, toggleCodeWithAnalytics, toggleStrikeWithAnalytics, toggleSubscriptWithAnalytics, toggleSuperscriptWithAnalytics, toggleUnderlineWithAnalytics } from '../actions';
|
|
5
|
-
export default function keymapPlugin(schema, editorAnalyticsAPI) {
|
|
6
|
-
const list = {};
|
|
7
|
-
if (schema.marks.strong) {
|
|
8
|
-
keymaps.bindKeymapWithCommand(keymaps.toggleBold.common, toggleStrongWithAnalytics(editorAnalyticsAPI)({
|
|
9
|
-
inputMethod: INPUT_METHOD.SHORTCUT
|
|
10
|
-
}), list);
|
|
11
|
-
}
|
|
12
|
-
if (schema.marks.em) {
|
|
13
|
-
keymaps.bindKeymapWithCommand(keymaps.toggleItalic.common, toggleEmWithAnalytics(editorAnalyticsAPI)({
|
|
14
|
-
inputMethod: INPUT_METHOD.SHORTCUT
|
|
15
|
-
}), list);
|
|
16
|
-
}
|
|
17
|
-
if (schema.marks.code) {
|
|
18
|
-
keymaps.bindKeymapWithCommand(keymaps.toggleCode.common, toggleCodeWithAnalytics(editorAnalyticsAPI)({
|
|
19
|
-
inputMethod: INPUT_METHOD.SHORTCUT
|
|
20
|
-
}), list);
|
|
21
|
-
}
|
|
22
|
-
if (schema.marks.strike) {
|
|
23
|
-
keymaps.bindKeymapWithCommand(keymaps.toggleStrikethrough.common, toggleStrikeWithAnalytics(editorAnalyticsAPI)({
|
|
24
|
-
inputMethod: INPUT_METHOD.SHORTCUT
|
|
25
|
-
}), list);
|
|
26
|
-
}
|
|
27
|
-
if (schema.marks.subsup) {
|
|
28
|
-
keymaps.bindKeymapWithCommand(keymaps.toggleSubscript.common, toggleSubscriptWithAnalytics(editorAnalyticsAPI)({
|
|
29
|
-
inputMethod: INPUT_METHOD.SHORTCUT
|
|
30
|
-
}), list);
|
|
31
|
-
}
|
|
32
|
-
if (schema.marks.subsup) {
|
|
33
|
-
keymaps.bindKeymapWithCommand(keymaps.toggleSuperscript.common, toggleSuperscriptWithAnalytics(editorAnalyticsAPI)({
|
|
34
|
-
inputMethod: INPUT_METHOD.SHORTCUT
|
|
35
|
-
}), list);
|
|
36
|
-
}
|
|
37
|
-
if (schema.marks.underline) {
|
|
38
|
-
keymaps.bindKeymapWithCommand(keymaps.toggleUnderline.common, toggleUnderlineWithAnalytics(editorAnalyticsAPI)({
|
|
39
|
-
inputMethod: INPUT_METHOD.SHORTCUT
|
|
40
|
-
}), list);
|
|
41
|
-
}
|
|
42
|
-
return keymap(list);
|
|
43
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
// TODO: Ideally this should use the custom toggleMark function from @atlaskit/editor-common so we also disable the options when selecting inline nodes but it disables the marks when the selection is empty at this point in time which is undesirable
|
|
2
|
-
// import { toggleMark } from '@atlaskit/editor-common/mark';
|
|
3
|
-
import { toggleMark } from '@atlaskit/editor-prosemirror/commands';
|
|
4
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
|
-
import * as keymaps from '@atlaskit/editor-common/keymaps';
|
|
6
|
-
import { shallowEqual } from '@atlaskit/editor-common/utils';
|
|
7
|
-
import { createInlineCodeFromTextInputWithAnalytics } from '../commands/text-formatting';
|
|
8
|
-
import * as commands from '../commands/text-formatting';
|
|
9
|
-
import { anyMarkActive } from '@atlaskit/editor-common/mark';
|
|
10
|
-
import { pluginKey } from './plugin-key';
|
|
11
|
-
export { pluginKey };
|
|
12
|
-
const getTextFormattingState = (editorState, editorAnalyticsAPI) => {
|
|
13
|
-
const {
|
|
14
|
-
em,
|
|
15
|
-
code,
|
|
16
|
-
strike,
|
|
17
|
-
strong,
|
|
18
|
-
subsup,
|
|
19
|
-
underline
|
|
20
|
-
} = editorState.schema.marks;
|
|
21
|
-
const state = {};
|
|
22
|
-
if (code) {
|
|
23
|
-
state.codeActive = anyMarkActive(editorState, code.create());
|
|
24
|
-
state.codeDisabled = !toggleMark(code)(editorState);
|
|
25
|
-
}
|
|
26
|
-
if (em) {
|
|
27
|
-
state.emActive = anyMarkActive(editorState, em);
|
|
28
|
-
state.emDisabled = state.codeActive ? true : !toggleMark(em)(editorState);
|
|
29
|
-
}
|
|
30
|
-
if (strike) {
|
|
31
|
-
state.strikeActive = anyMarkActive(editorState, strike);
|
|
32
|
-
state.strikeDisabled = state.codeActive ? true : !toggleMark(strike)(editorState);
|
|
33
|
-
}
|
|
34
|
-
if (strong) {
|
|
35
|
-
state.strongActive = anyMarkActive(editorState, strong);
|
|
36
|
-
state.strongDisabled = state.codeActive ? true : !toggleMark(strong)(editorState);
|
|
37
|
-
}
|
|
38
|
-
if (subsup) {
|
|
39
|
-
const subMark = subsup.create({
|
|
40
|
-
type: 'sub'
|
|
41
|
-
});
|
|
42
|
-
const supMark = subsup.create({
|
|
43
|
-
type: 'sup'
|
|
44
|
-
});
|
|
45
|
-
state.subscriptActive = anyMarkActive(editorState, subMark);
|
|
46
|
-
state.subscriptDisabled = state.codeActive ? true : !toggleMark(subsup, {
|
|
47
|
-
type: 'sub'
|
|
48
|
-
})(editorState);
|
|
49
|
-
state.superscriptActive = anyMarkActive(editorState, supMark);
|
|
50
|
-
state.superscriptDisabled = state.codeActive ? true : !toggleMark(subsup, {
|
|
51
|
-
type: 'sup'
|
|
52
|
-
})(editorState);
|
|
53
|
-
}
|
|
54
|
-
if (underline) {
|
|
55
|
-
state.underlineActive = anyMarkActive(editorState, underline);
|
|
56
|
-
state.underlineDisabled = state.codeActive ? true : !toggleMark(underline)(editorState);
|
|
57
|
-
}
|
|
58
|
-
return state;
|
|
59
|
-
};
|
|
60
|
-
export const plugin = (dispatch, editorAnalyticsAPI) => new SafePlugin({
|
|
61
|
-
state: {
|
|
62
|
-
init(_config, state) {
|
|
63
|
-
return getTextFormattingState(state, editorAnalyticsAPI);
|
|
64
|
-
},
|
|
65
|
-
apply(_tr, pluginState, _oldState, newState) {
|
|
66
|
-
const state = getTextFormattingState(newState, editorAnalyticsAPI);
|
|
67
|
-
if (!shallowEqual(pluginState, state)) {
|
|
68
|
-
dispatch(pluginKey, state);
|
|
69
|
-
return state;
|
|
70
|
-
}
|
|
71
|
-
return pluginState;
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
key: pluginKey,
|
|
75
|
-
props: {
|
|
76
|
-
handleKeyDown(view, event) {
|
|
77
|
-
const {
|
|
78
|
-
state,
|
|
79
|
-
dispatch
|
|
80
|
-
} = view;
|
|
81
|
-
if (event.key === keymaps.moveRight.common && !event.metaKey) {
|
|
82
|
-
return commands.moveRight()(state, dispatch);
|
|
83
|
-
} else if (event.key === keymaps.moveLeft.common && !event.metaKey) {
|
|
84
|
-
return commands.moveLeft()(state, dispatch);
|
|
85
|
-
}
|
|
86
|
-
return false;
|
|
87
|
-
},
|
|
88
|
-
handleTextInput(view, from, to, text) {
|
|
89
|
-
const {
|
|
90
|
-
state,
|
|
91
|
-
dispatch
|
|
92
|
-
} = view;
|
|
93
|
-
const {
|
|
94
|
-
schema,
|
|
95
|
-
selection: {
|
|
96
|
-
$from: {
|
|
97
|
-
parent: {
|
|
98
|
-
type: parentNodeType
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
} = state;
|
|
103
|
-
if (parentNodeType.allowsMarkType(schema.marks.code)) {
|
|
104
|
-
return createInlineCodeFromTextInputWithAnalytics(editorAnalyticsAPI)(from, to, text)(state, dispatch);
|
|
105
|
-
}
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
});
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import { createRule, createPlugin } from '@atlaskit/prosemirror-input-rules';
|
|
3
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, PUNC, SYMBOL } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import { inputRuleWithAnalytics } from '@atlaskit/editor-common/utils';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Creates an InputRuleHandler that will match on a regular expression of the
|
|
8
|
-
* form `(prefix, content, suffix?)`, and replace it with some given text,
|
|
9
|
-
* maintaining prefix and suffix around the replacement.
|
|
10
|
-
*
|
|
11
|
-
* @param text text to replace with
|
|
12
|
-
*/
|
|
13
|
-
function replaceTextUsingCaptureGroup(text) {
|
|
14
|
-
return (state, match, start, end) => {
|
|
15
|
-
const [, prefix,, suffix] = match;
|
|
16
|
-
const replacement = text + (suffix || '');
|
|
17
|
-
let {
|
|
18
|
-
tr,
|
|
19
|
-
selection: {
|
|
20
|
-
$to
|
|
21
|
-
}
|
|
22
|
-
} = state;
|
|
23
|
-
const startPos = start + (prefix || '').length;
|
|
24
|
-
const safePos = Math.min(
|
|
25
|
-
// I know it is almost impossible to have a negative value at this point.
|
|
26
|
-
// But, this is JS #trustnoone
|
|
27
|
-
Math.max(startPos, 0), end);
|
|
28
|
-
tr.replaceWith(safePos, end, state.schema.text(replacement, $to.marks()));
|
|
29
|
-
tr.setSelection(Selection.near(tr.doc.resolve(tr.selection.to)));
|
|
30
|
-
return tr;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
function createReplacementRule(to, from) {
|
|
34
|
-
return createRule(from, replaceTextUsingCaptureGroup(to));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Create replacement rules fiven a replacement map
|
|
39
|
-
* @param replMap - Replacement map
|
|
40
|
-
* @param trackingEventName - Analytics V2 tracking event name
|
|
41
|
-
* @param replacementRuleWithAnalytics - Analytics GAS V3 middleware for replacement and rules.
|
|
42
|
-
*/
|
|
43
|
-
function createReplacementRules(replMap, replacementRuleWithAnalytics) {
|
|
44
|
-
return Object.keys(replMap).map(replacement => {
|
|
45
|
-
const regex = replMap[replacement];
|
|
46
|
-
const rule = createReplacementRule(replacement, regex);
|
|
47
|
-
if (replacementRuleWithAnalytics) {
|
|
48
|
-
return replacementRuleWithAnalytics(replacement)(rule);
|
|
49
|
-
}
|
|
50
|
-
return rule;
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// We don't agressively upgrade single quotes to smart quotes because
|
|
55
|
-
// they may clash with an emoji. Only do that when we have a matching
|
|
56
|
-
// single quote, or a contraction.
|
|
57
|
-
function createSingleQuotesRules() {
|
|
58
|
-
return [
|
|
59
|
-
// wrapped text
|
|
60
|
-
createRule(/(\s|^)'(\S+.*\S+)'$/, (state, match, start, end) => {
|
|
61
|
-
const OPEN_SMART_QUOTE_CHAR = '‘';
|
|
62
|
-
const CLOSED_SMART_QUOTE_CHAR = '’';
|
|
63
|
-
const [, spacing, innerContent] = match;
|
|
64
|
-
// Edge case where match begins with some spacing. We need to add
|
|
65
|
-
// it back to the document
|
|
66
|
-
const openQuoteReplacement = spacing + OPEN_SMART_QUOTE_CHAR;
|
|
67
|
-
// End is not always where the closed quote is, edge case exists
|
|
68
|
-
// when there is spacing after the closed quote. We need to
|
|
69
|
-
// determine position of closed quote from the start position.
|
|
70
|
-
const positionOfClosedQuote = start + openQuoteReplacement.length + innerContent.length;
|
|
71
|
-
return state.tr.insertText(CLOSED_SMART_QUOTE_CHAR, positionOfClosedQuote, end).insertText(openQuoteReplacement, start, start + openQuoteReplacement.length);
|
|
72
|
-
}),
|
|
73
|
-
// apostrophe
|
|
74
|
-
createReplacementRule('’', /(\w+)(')(\w+)$/)];
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Get replacement rules related to product
|
|
79
|
-
*/
|
|
80
|
-
function getProductRules(editorAnalyticsAPI) {
|
|
81
|
-
const productRuleWithAnalytics = product => inputRuleWithAnalytics((_, match) => ({
|
|
82
|
-
action: ACTION.SUBSTITUTED,
|
|
83
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
84
|
-
actionSubjectId: ACTION_SUBJECT_ID.PRODUCT_NAME,
|
|
85
|
-
eventType: EVENT_TYPE.TRACK,
|
|
86
|
-
attributes: {
|
|
87
|
-
product,
|
|
88
|
-
originalSpelling: match[2]
|
|
89
|
-
}
|
|
90
|
-
}), editorAnalyticsAPI);
|
|
91
|
-
return createReplacementRules({
|
|
92
|
-
Atlassian: /(\s+|^)(atlassian)(\s)$/,
|
|
93
|
-
Jira: /(\s+|^)(jira|JIRA)(\s)$/,
|
|
94
|
-
Bitbucket: /(\s+|^)(bitbucket|BitBucket)(\s)$/,
|
|
95
|
-
Hipchat: /(\s+|^)(hipchat|HipChat)(\s)$/,
|
|
96
|
-
Trello: /(\s+|^)(trello)(\s)$/
|
|
97
|
-
}, productRuleWithAnalytics);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Get replacement rules related to symbol
|
|
102
|
-
*/
|
|
103
|
-
function getSymbolRules(editorAnalyticsAPI) {
|
|
104
|
-
const symbolToString = {
|
|
105
|
-
'→': SYMBOL.ARROW_RIGHT,
|
|
106
|
-
'←': SYMBOL.ARROW_LEFT,
|
|
107
|
-
'↔︎': SYMBOL.ARROW_DOUBLE
|
|
108
|
-
};
|
|
109
|
-
const symbolRuleWithAnalytics = symbol => inputRuleWithAnalytics({
|
|
110
|
-
action: ACTION.SUBSTITUTED,
|
|
111
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
112
|
-
actionSubjectId: ACTION_SUBJECT_ID.SYMBOL,
|
|
113
|
-
eventType: EVENT_TYPE.TRACK,
|
|
114
|
-
attributes: {
|
|
115
|
-
symbol: symbolToString[symbol]
|
|
116
|
-
}
|
|
117
|
-
}, editorAnalyticsAPI);
|
|
118
|
-
return createReplacementRules({
|
|
119
|
-
'→': /(\s+|^)(--?>)(\s)$/,
|
|
120
|
-
'←': /(\s+|^)(<--?)(\s)$/,
|
|
121
|
-
'↔︎': /(\s+|^)(<->?)(\s)$/
|
|
122
|
-
}, symbolRuleWithAnalytics);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Get replacement rules related to punctuation
|
|
127
|
-
*/
|
|
128
|
-
function getPunctuationRules(editorAnalyticsAPI) {
|
|
129
|
-
const punctuationToString = {
|
|
130
|
-
'–': PUNC.DASH,
|
|
131
|
-
'…': PUNC.ELLIPSIS,
|
|
132
|
-
'”': PUNC.QUOTE_DOUBLE,
|
|
133
|
-
[PUNC.QUOTE_SINGLE]: PUNC.QUOTE_SINGLE
|
|
134
|
-
};
|
|
135
|
-
const punctuationRuleWithAnalytics = punctuation => inputRuleWithAnalytics({
|
|
136
|
-
action: ACTION.SUBSTITUTED,
|
|
137
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
138
|
-
actionSubjectId: ACTION_SUBJECT_ID.PUNC,
|
|
139
|
-
eventType: EVENT_TYPE.TRACK,
|
|
140
|
-
attributes: {
|
|
141
|
-
punctuation: punctuationToString[punctuation]
|
|
142
|
-
}
|
|
143
|
-
}, editorAnalyticsAPI);
|
|
144
|
-
const dashEllipsisRules = createReplacementRules({
|
|
145
|
-
'–': /(\s+|^)(--)(\s)$/,
|
|
146
|
-
'…': /()(\.\.\.)$/
|
|
147
|
-
}, punctuationRuleWithAnalytics);
|
|
148
|
-
const doubleQuoteRules = createReplacementRules({
|
|
149
|
-
'“': /((?:^|[\s\{\[\(\<'"\u2018\u201C]))(")$/,
|
|
150
|
-
'”': /"$/
|
|
151
|
-
}, punctuationRuleWithAnalytics);
|
|
152
|
-
const singleQuoteRules = createSingleQuotesRules();
|
|
153
|
-
return [...dashEllipsisRules, ...doubleQuoteRules, ...singleQuoteRules.map(rule => punctuationRuleWithAnalytics(PUNC.QUOTE_SINGLE)(rule))];
|
|
154
|
-
}
|
|
155
|
-
export default (editorAnalyticsAPI => createPlugin('text-formatting:smart-input', [...getProductRules(editorAnalyticsAPI), ...getSymbolRules(editorAnalyticsAPI), ...getPunctuationRules(editorAnalyticsAPI)]));
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ToolbarSize } from '@atlaskit/editor-common/types';
|
|
2
|
-
import { IconTypes } from './types';
|
|
3
|
-
export const DefaultButtonsToolbar = [IconTypes.strong, IconTypes.em];
|
|
4
|
-
export const DefaultButtonsMenu = [IconTypes.underline, IconTypes.strike, IconTypes.code, IconTypes.subscript, IconTypes.superscript];
|
|
5
|
-
export const ResponsiveCustomButtonToolbar = {
|
|
6
|
-
[ToolbarSize.XXL]: DefaultButtonsToolbar,
|
|
7
|
-
[ToolbarSize.XL]: DefaultButtonsToolbar,
|
|
8
|
-
[ToolbarSize.L]: DefaultButtonsToolbar,
|
|
9
|
-
[ToolbarSize.M]: [],
|
|
10
|
-
[ToolbarSize.S]: [],
|
|
11
|
-
[ToolbarSize.XXXS]: []
|
|
12
|
-
};
|
|
13
|
-
export const ResponsiveCustomMenu = {
|
|
14
|
-
[ToolbarSize.XXL]: DefaultButtonsMenu,
|
|
15
|
-
[ToolbarSize.XL]: DefaultButtonsMenu,
|
|
16
|
-
[ToolbarSize.L]: DefaultButtonsMenu,
|
|
17
|
-
[ToolbarSize.M]: [IconTypes.strong, IconTypes.em, ...DefaultButtonsMenu],
|
|
18
|
-
[ToolbarSize.S]: [IconTypes.strong, IconTypes.em, ...DefaultButtonsMenu],
|
|
19
|
-
[ToolbarSize.XXXS]: [IconTypes.strong, IconTypes.em, ...DefaultButtonsMenu]
|
|
20
|
-
};
|