@atlaskit/editor-core 187.17.6 → 187.18.1
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/help-dialog/ui/index.js +26 -27
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/plugins/list/index.js +5 -5
- package/dist/cjs/plugins/list/transforms.js +1 -223
- package/dist/cjs/plugins/paste/commands.js +224 -2
- package/dist/cjs/plugins/paste/pm-plugins/main.js +3 -3
- package/dist/cjs/plugins/toolbar-lists-indentation/ui/Toolbar.js +3 -3
- package/dist/cjs/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +4 -4
- 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/help-dialog/ui/index.js +1 -2
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/plugins/list/index.js +1 -1
- package/dist/es2019/plugins/list/transforms.js +2 -210
- package/dist/es2019/plugins/paste/commands.js +210 -2
- package/dist/es2019/plugins/paste/pm-plugins/main.js +1 -1
- package/dist/es2019/plugins/toolbar-lists-indentation/ui/Toolbar.js +1 -1
- package/dist/es2019/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +1 -1
- 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/help-dialog/ui/index.js +1 -2
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/plugins/list/index.js +1 -1
- package/dist/esm/plugins/list/transforms.js +2 -219
- package/dist/esm/plugins/paste/commands.js +218 -1
- package/dist/esm/plugins/paste/pm-plugins/main.js +1 -1
- package/dist/esm/plugins/toolbar-lists-indentation/ui/Toolbar.js +1 -1
- package/dist/esm/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +1 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/index.d.ts +0 -5
- package/dist/types/labs/next/presets/default.d.ts +28 -28
- package/dist/types/plugins/annotation/types.d.ts +9 -3
- 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/list/transforms.d.ts +0 -13
- package/dist/types/plugins/paste/commands.d.ts +14 -0
- package/dist/types/plugins/paste/index.d.ts +2 -0
- package/dist/types-ts4.5/index.d.ts +0 -5
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +28 -28
- package/dist/types-ts4.5/plugins/annotation/types.d.ts +9 -3
- 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/list/transforms.d.ts +0 -13
- package/dist/types-ts4.5/plugins/paste/commands.d.ts +14 -0
- package/dist/types-ts4.5/plugins/paste/index.d.ts +2 -0
- package/package.json +3 -2
- 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,3 +1,6 @@
|
|
|
1
|
+
import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
import type { Mark } from '@atlaskit/editor-prosemirror/model';
|
|
1
4
|
/**
|
|
2
5
|
* Use this to register macro link positions during a paste operation, that you
|
|
3
6
|
* want to track in a document over time, through any document changes.
|
|
@@ -14,3 +17,14 @@ export declare const startTrackingPastedMacroPositions: (pastedMacroPositions: {
|
|
|
14
17
|
[key: string]: number;
|
|
15
18
|
}) => import("@atlaskit/editor-common/types").Command;
|
|
16
19
|
export declare const stopTrackingPastedMacroPositions: (pastedMacroPositionKeys: string[]) => import("@atlaskit/editor-common/types").Command;
|
|
20
|
+
export declare const upgradeTextToLists: (slice: Slice, schema: Schema) => Slice;
|
|
21
|
+
export declare const splitParagraphs: (slice: Slice, schema: Schema) => Slice;
|
|
22
|
+
/**
|
|
23
|
+
* Walks the slice, creating paragraphs that were previously separated by hardbreaks.
|
|
24
|
+
* Returns the original paragraph node (as a fragment), or a fragment containing multiple nodes.
|
|
25
|
+
*/
|
|
26
|
+
export declare const splitIntoParagraphs: ({ fragment, blockMarks, schema, }: {
|
|
27
|
+
fragment: Fragment;
|
|
28
|
+
blockMarks?: readonly Mark[] | undefined;
|
|
29
|
+
schema: Schema;
|
|
30
|
+
}) => Fragment;
|
|
@@ -3,6 +3,7 @@ import type { CardOptions } from '@atlaskit/editor-common/card';
|
|
|
3
3
|
import type featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
|
|
4
4
|
import type { cardPlugin } from '@atlaskit/editor-plugin-card';
|
|
5
5
|
import type betterTypeHistoryPlugin from '../better-type-history';
|
|
6
|
+
import type listPlugin from '../list';
|
|
6
7
|
export type PastePluginOptions = {
|
|
7
8
|
cardOptions?: CardOptions;
|
|
8
9
|
sanitizePrivateContent?: boolean;
|
|
@@ -11,6 +12,7 @@ declare const pastePlugin: NextEditorPlugin<'paste', {
|
|
|
11
12
|
pluginConfiguration: PastePluginOptions;
|
|
12
13
|
dependencies: [
|
|
13
14
|
typeof featureFlagsPlugin,
|
|
15
|
+
OptionalPlugin<typeof listPlugin>,
|
|
14
16
|
typeof betterTypeHistoryPlugin,
|
|
15
17
|
OptionalPlugin<typeof cardPlugin>
|
|
16
18
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-core",
|
|
3
|
-
"version": "187.
|
|
3
|
+
"version": "187.18.1",
|
|
4
4
|
"description": "A package contains Atlassian editor core functionality",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@atlaskit/code": "^14.6.0",
|
|
56
56
|
"@atlaskit/date": "^0.10.0",
|
|
57
57
|
"@atlaskit/datetime-picker": "^12.7.0",
|
|
58
|
-
"@atlaskit/editor-common": "^74.
|
|
58
|
+
"@atlaskit/editor-common": "^74.43.0",
|
|
59
59
|
"@atlaskit/editor-json-transformer": "^8.10.0",
|
|
60
60
|
"@atlaskit/editor-markdown-transformer": "^5.2.5",
|
|
61
61
|
"@atlaskit/editor-palette": "1.5.1",
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
"@atlaskit/editor-plugin-guideline": "^0.3.4",
|
|
73
73
|
"@atlaskit/editor-plugin-hyperlink": "^0.3.0",
|
|
74
74
|
"@atlaskit/editor-plugin-table": "^2.8.0",
|
|
75
|
+
"@atlaskit/editor-plugin-text-formatting": "^0.1.0",
|
|
75
76
|
"@atlaskit/editor-plugin-width": "^0.1.0",
|
|
76
77
|
"@atlaskit/editor-prosemirror": "1.1.0",
|
|
77
78
|
"@atlaskit/editor-shared-styles": "^2.6.0",
|
package/report.api.md
CHANGED
|
@@ -28,7 +28,7 @@ import type { AllowedBlockTypes } from '@atlaskit/editor-common/types';
|
|
|
28
28
|
import { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
29
29
|
import type { AnalyticsEventPayload as AnalyticsEventPayload_2 } from '@atlaskit/analytics-next/AnalyticsEvent';
|
|
30
30
|
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
31
|
-
import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
31
|
+
import type { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
32
32
|
import { BrowserFreezetracking } from '@atlaskit/editor-common/types';
|
|
33
33
|
import type { CardOptions } from '@atlaskit/editor-common/card';
|
|
34
34
|
import { CardProvider } from '@atlaskit/editor-common/provider-factory';
|
|
@@ -2090,24 +2090,6 @@ export { TextFormattingInputMethodBasic };
|
|
|
2090
2090
|
|
|
2091
2091
|
export { TextFormattingInputMethodToolbar };
|
|
2092
2092
|
|
|
2093
|
-
// @public (undocumented)
|
|
2094
|
-
export const textFormattingPlugin: NextEditorPlugin<
|
|
2095
|
-
'textFormatting',
|
|
2096
|
-
{
|
|
2097
|
-
pluginConfiguration: TextFormattingOptions | undefined;
|
|
2098
|
-
dependencies: [OptionalPlugin<typeof analyticsPlugin>];
|
|
2099
|
-
actions: {
|
|
2100
|
-
toggleSuperscript: ToggleMarkWithAnalyticsCommand;
|
|
2101
|
-
toggleSubscript: ToggleMarkWithAnalyticsCommand;
|
|
2102
|
-
toggleStrike: ToggleMarkWithAnalyticsCommand;
|
|
2103
|
-
toggleCode: ToggleMarkWithAnalyticsCommand;
|
|
2104
|
-
toggleUnderline: ToggleMarkWithAnalyticsCommand;
|
|
2105
|
-
toggleEm: ToggleMarkWithAnalyticsCommand;
|
|
2106
|
-
toggleStrong: ToggleMarkWithAnalyticsCommand;
|
|
2107
|
-
};
|
|
2108
|
-
}
|
|
2109
|
-
>;
|
|
2110
|
-
|
|
2111
2093
|
// @public (undocumented)
|
|
2112
2094
|
interface TextSelectionData {
|
|
2113
2095
|
// (undocumented)
|
|
@@ -2118,11 +2100,6 @@ interface TextSelectionData {
|
|
|
2118
2100
|
type: 'text';
|
|
2119
2101
|
}
|
|
2120
2102
|
|
|
2121
|
-
// @public (undocumented)
|
|
2122
|
-
type ToggleMarkWithAnalyticsCommand = (analyticsMetadata: {
|
|
2123
|
-
inputMethod: TextFormattingInputMethodBasic;
|
|
2124
|
-
}) => Command_2;
|
|
2125
|
-
|
|
2126
2103
|
// @public (undocumented)
|
|
2127
2104
|
export class ToolbarFeedback extends PureComponent<Props_3, State_2> {
|
|
2128
2105
|
constructor(props: Props_3);
|
package/tmp/api-report-tmp.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ import type { AllowedBlockTypes } from '@atlaskit/editor-common/types';
|
|
|
17
17
|
import { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
18
18
|
import type { AnalyticsEventPayload as AnalyticsEventPayload_2 } from '@atlaskit/analytics-next/AnalyticsEvent';
|
|
19
19
|
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
20
|
-
import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
20
|
+
import type { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
21
21
|
import { BrowserFreezetracking } from '@atlaskit/editor-common/types';
|
|
22
22
|
import type { CardOptions } from '@atlaskit/editor-common/card';
|
|
23
23
|
import { CardProvider } from '@atlaskit/editor-common/provider-factory';
|
|
@@ -1859,21 +1859,6 @@ export { TextFormattingInputMethodBasic }
|
|
|
1859
1859
|
|
|
1860
1860
|
export { TextFormattingInputMethodToolbar }
|
|
1861
1861
|
|
|
1862
|
-
// @public (undocumented)
|
|
1863
|
-
export const textFormattingPlugin: NextEditorPlugin<'textFormatting', {
|
|
1864
|
-
pluginConfiguration: TextFormattingOptions | undefined;
|
|
1865
|
-
dependencies: [OptionalPlugin<typeof analyticsPlugin>];
|
|
1866
|
-
actions: {
|
|
1867
|
-
toggleSuperscript: ToggleMarkWithAnalyticsCommand;
|
|
1868
|
-
toggleSubscript: ToggleMarkWithAnalyticsCommand;
|
|
1869
|
-
toggleStrike: ToggleMarkWithAnalyticsCommand;
|
|
1870
|
-
toggleCode: ToggleMarkWithAnalyticsCommand;
|
|
1871
|
-
toggleUnderline: ToggleMarkWithAnalyticsCommand;
|
|
1872
|
-
toggleEm: ToggleMarkWithAnalyticsCommand;
|
|
1873
|
-
toggleStrong: ToggleMarkWithAnalyticsCommand;
|
|
1874
|
-
};
|
|
1875
|
-
}>;
|
|
1876
|
-
|
|
1877
1862
|
// @public (undocumented)
|
|
1878
1863
|
interface TextSelectionData {
|
|
1879
1864
|
// (undocumented)
|
|
@@ -1884,11 +1869,6 @@ interface TextSelectionData {
|
|
|
1884
1869
|
type: 'text';
|
|
1885
1870
|
}
|
|
1886
1871
|
|
|
1887
|
-
// @public (undocumented)
|
|
1888
|
-
type ToggleMarkWithAnalyticsCommand = (analyticsMetadata: {
|
|
1889
|
-
inputMethod: TextFormattingInputMethodBasic;
|
|
1890
|
-
}) => Command_2;
|
|
1891
|
-
|
|
1892
1872
|
// @public (undocumented)
|
|
1893
1873
|
export class ToolbarFeedback extends PureComponent<Props_3, State_2> {
|
|
1894
1874
|
constructor(props: Props_3);
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.toggleUnderlineWithAnalytics = exports.toggleUnderline = exports.toggleSuperscriptWithAnalytics = exports.toggleSuperscript = exports.toggleSubscriptWithAnalytics = exports.toggleSubscript = exports.toggleStrongWithAnalytics = exports.toggleStrong = exports.toggleStrikeWithAnalytics = exports.toggleStrike = exports.toggleEmWithAnalytics = exports.toggleEm = exports.toggleCodeWithAnalytics = exports.toggleCode = void 0;
|
|
7
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
-
var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
|
|
9
|
-
var _mark = require("@atlaskit/editor-common/mark");
|
|
10
|
-
var toggleEm = function toggleEm() {
|
|
11
|
-
return function (state, dispatch) {
|
|
12
|
-
var em = state.schema.marks.em;
|
|
13
|
-
if (em) {
|
|
14
|
-
return (0, _mark.toggleMark)(em)(state, dispatch);
|
|
15
|
-
}
|
|
16
|
-
return false;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
exports.toggleEm = toggleEm;
|
|
20
|
-
var toggleEmWithAnalytics = function toggleEmWithAnalytics(editorAnalyticsAPI) {
|
|
21
|
-
return function (_ref) {
|
|
22
|
-
var inputMethod = _ref.inputMethod;
|
|
23
|
-
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
|
|
24
|
-
action: _analytics.ACTION.FORMATTED,
|
|
25
|
-
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
26
|
-
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
27
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_ITALIC,
|
|
28
|
-
attributes: {
|
|
29
|
-
inputMethod: inputMethod
|
|
30
|
-
}
|
|
31
|
-
})(toggleEm());
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
exports.toggleEmWithAnalytics = toggleEmWithAnalytics;
|
|
35
|
-
var toggleStrike = function toggleStrike() {
|
|
36
|
-
return function (state, dispatch) {
|
|
37
|
-
var strike = state.schema.marks.strike;
|
|
38
|
-
if (strike) {
|
|
39
|
-
return (0, _mark.toggleMark)(strike)(state, dispatch);
|
|
40
|
-
}
|
|
41
|
-
return false;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
exports.toggleStrike = toggleStrike;
|
|
45
|
-
var toggleStrikeWithAnalytics = function toggleStrikeWithAnalytics(editorAnalyticsAPI) {
|
|
46
|
-
return function (_ref2) {
|
|
47
|
-
var inputMethod = _ref2.inputMethod;
|
|
48
|
-
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
|
|
49
|
-
action: _analytics.ACTION.FORMATTED,
|
|
50
|
-
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
51
|
-
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
52
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_STRIKE,
|
|
53
|
-
attributes: {
|
|
54
|
-
inputMethod: inputMethod
|
|
55
|
-
}
|
|
56
|
-
})(toggleStrike());
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
exports.toggleStrikeWithAnalytics = toggleStrikeWithAnalytics;
|
|
60
|
-
var toggleStrong = function toggleStrong() {
|
|
61
|
-
return function (state, dispatch) {
|
|
62
|
-
var strong = state.schema.marks.strong;
|
|
63
|
-
if (strong) {
|
|
64
|
-
return (0, _mark.toggleMark)(strong)(state, dispatch);
|
|
65
|
-
}
|
|
66
|
-
return false;
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
exports.toggleStrong = toggleStrong;
|
|
70
|
-
var toggleStrongWithAnalytics = function toggleStrongWithAnalytics(editorAnalyticsAPI) {
|
|
71
|
-
return function (_ref3) {
|
|
72
|
-
var inputMethod = _ref3.inputMethod;
|
|
73
|
-
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
|
|
74
|
-
action: _analytics.ACTION.FORMATTED,
|
|
75
|
-
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
76
|
-
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
77
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_STRONG,
|
|
78
|
-
attributes: {
|
|
79
|
-
inputMethod: inputMethod
|
|
80
|
-
}
|
|
81
|
-
})(toggleStrong());
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
exports.toggleStrongWithAnalytics = toggleStrongWithAnalytics;
|
|
85
|
-
var toggleUnderline = function toggleUnderline() {
|
|
86
|
-
return function (state, dispatch) {
|
|
87
|
-
var underline = state.schema.marks.underline;
|
|
88
|
-
if (underline) {
|
|
89
|
-
return (0, _mark.toggleMark)(underline)(state, dispatch);
|
|
90
|
-
}
|
|
91
|
-
return false;
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
exports.toggleUnderline = toggleUnderline;
|
|
95
|
-
var toggleUnderlineWithAnalytics = function toggleUnderlineWithAnalytics(editorAnalyticsAPI) {
|
|
96
|
-
return function (_ref4) {
|
|
97
|
-
var inputMethod = _ref4.inputMethod;
|
|
98
|
-
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
|
|
99
|
-
action: _analytics.ACTION.FORMATTED,
|
|
100
|
-
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
101
|
-
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
102
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_UNDERLINE,
|
|
103
|
-
attributes: {
|
|
104
|
-
inputMethod: inputMethod
|
|
105
|
-
}
|
|
106
|
-
})(toggleUnderline());
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
exports.toggleUnderlineWithAnalytics = toggleUnderlineWithAnalytics;
|
|
110
|
-
var toggleSuperscript = function toggleSuperscript() {
|
|
111
|
-
return function (state, dispatch) {
|
|
112
|
-
var subsup = state.schema.marks.subsup;
|
|
113
|
-
if (subsup) {
|
|
114
|
-
return (0, _mark.toggleMark)(subsup, {
|
|
115
|
-
type: 'sup'
|
|
116
|
-
})(state, dispatch);
|
|
117
|
-
}
|
|
118
|
-
return false;
|
|
119
|
-
};
|
|
120
|
-
};
|
|
121
|
-
exports.toggleSuperscript = toggleSuperscript;
|
|
122
|
-
var toggleSuperscriptWithAnalytics = function toggleSuperscriptWithAnalytics(editorAnalyticsAPI) {
|
|
123
|
-
return function (_ref5) {
|
|
124
|
-
var inputMethod = _ref5.inputMethod;
|
|
125
|
-
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
|
|
126
|
-
action: _analytics.ACTION.FORMATTED,
|
|
127
|
-
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
128
|
-
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
129
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_SUPER,
|
|
130
|
-
attributes: {
|
|
131
|
-
inputMethod: inputMethod
|
|
132
|
-
}
|
|
133
|
-
})(toggleSuperscript());
|
|
134
|
-
};
|
|
135
|
-
};
|
|
136
|
-
exports.toggleSuperscriptWithAnalytics = toggleSuperscriptWithAnalytics;
|
|
137
|
-
var toggleSubscript = function toggleSubscript() {
|
|
138
|
-
return function (state, dispatch) {
|
|
139
|
-
var subsup = state.schema.marks.subsup;
|
|
140
|
-
if (subsup) {
|
|
141
|
-
return (0, _mark.toggleMark)(subsup, {
|
|
142
|
-
type: 'sub'
|
|
143
|
-
})(state, dispatch);
|
|
144
|
-
}
|
|
145
|
-
return false;
|
|
146
|
-
};
|
|
147
|
-
};
|
|
148
|
-
exports.toggleSubscript = toggleSubscript;
|
|
149
|
-
var toggleSubscriptWithAnalytics = function toggleSubscriptWithAnalytics(editorAnalyticsAPI) {
|
|
150
|
-
return function (_ref6) {
|
|
151
|
-
var inputMethod = _ref6.inputMethod;
|
|
152
|
-
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
|
|
153
|
-
action: _analytics.ACTION.FORMATTED,
|
|
154
|
-
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
155
|
-
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
156
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_SUB,
|
|
157
|
-
attributes: {
|
|
158
|
-
inputMethod: inputMethod
|
|
159
|
-
}
|
|
160
|
-
})(toggleSubscript());
|
|
161
|
-
};
|
|
162
|
-
};
|
|
163
|
-
exports.toggleSubscriptWithAnalytics = toggleSubscriptWithAnalytics;
|
|
164
|
-
var toggleCode = function toggleCode() {
|
|
165
|
-
return function (state, dispatch) {
|
|
166
|
-
var code = state.schema.marks.code;
|
|
167
|
-
if (code) {
|
|
168
|
-
return (0, _mark.toggleMark)(code)(state, dispatch);
|
|
169
|
-
}
|
|
170
|
-
return false;
|
|
171
|
-
};
|
|
172
|
-
};
|
|
173
|
-
exports.toggleCode = toggleCode;
|
|
174
|
-
var toggleCodeWithAnalytics = function toggleCodeWithAnalytics(editorAnalyticsAPI) {
|
|
175
|
-
return function (_ref7) {
|
|
176
|
-
var inputMethod = _ref7.inputMethod;
|
|
177
|
-
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
|
|
178
|
-
action: _analytics.ACTION.FORMATTED,
|
|
179
|
-
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
180
|
-
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
181
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_CODE,
|
|
182
|
-
attributes: {
|
|
183
|
-
inputMethod: inputMethod
|
|
184
|
-
}
|
|
185
|
-
})(toggleCode());
|
|
186
|
-
};
|
|
187
|
-
};
|
|
188
|
-
exports.toggleCodeWithAnalytics = toggleCodeWithAnalytics;
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.FORMATTING_NODE_TYPES = exports.FORMATTING_MARK_TYPES = void 0;
|
|
7
|
-
exports.clearFormatting = clearFormatting;
|
|
8
|
-
exports.clearFormattingWithAnalytics = clearFormattingWithAnalytics;
|
|
9
|
-
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
10
|
-
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
11
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
|
-
var _cellSelection2 = require("../utils/cell-selection");
|
|
13
|
-
var FORMATTING_NODE_TYPES = ['heading', 'blockquote'];
|
|
14
|
-
exports.FORMATTING_NODE_TYPES = FORMATTING_NODE_TYPES;
|
|
15
|
-
var FORMATTING_MARK_TYPES = ['em', 'code', 'strike', 'strong', 'underline', 'textColor', 'subsup'];
|
|
16
|
-
exports.FORMATTING_MARK_TYPES = FORMATTING_MARK_TYPES;
|
|
17
|
-
var formatTypes = {
|
|
18
|
-
em: _analytics.ACTION_SUBJECT_ID.FORMAT_ITALIC,
|
|
19
|
-
code: _analytics.ACTION_SUBJECT_ID.FORMAT_CODE,
|
|
20
|
-
strike: _analytics.ACTION_SUBJECT_ID.FORMAT_STRIKE,
|
|
21
|
-
strong: _analytics.ACTION_SUBJECT_ID.FORMAT_STRONG,
|
|
22
|
-
underline: _analytics.ACTION_SUBJECT_ID.FORMAT_UNDERLINE,
|
|
23
|
-
textColor: _analytics.ACTION_SUBJECT_ID.FORMAT_COLOR,
|
|
24
|
-
subsup: 'subsup'
|
|
25
|
-
};
|
|
26
|
-
function clearFormattingWithAnalytics(inputMethod, editorAnalyticsAPI) {
|
|
27
|
-
return clearFormatting(inputMethod, editorAnalyticsAPI);
|
|
28
|
-
}
|
|
29
|
-
function clearNodeFormattingOnSelection(state, tr, formattedNodeType, nodeName, formattingCleared) {
|
|
30
|
-
return function (node, pos) {
|
|
31
|
-
if (node.type === formattedNodeType) {
|
|
32
|
-
if (formattedNodeType.isTextblock) {
|
|
33
|
-
tr.setNodeMarkup(pos, state.schema.nodes.paragraph);
|
|
34
|
-
formattingCleared.push(nodeName);
|
|
35
|
-
return false;
|
|
36
|
-
} else {
|
|
37
|
-
// In case of panel or blockquote
|
|
38
|
-
var fromPos = tr.doc.resolve(pos + 1);
|
|
39
|
-
var toPos = tr.doc.resolve(pos + node.nodeSize - 1);
|
|
40
|
-
var nodeRange = fromPos.blockRange(toPos);
|
|
41
|
-
if (nodeRange) {
|
|
42
|
-
var targetLiftDepth = (0, _transform.liftTarget)(nodeRange);
|
|
43
|
-
if (targetLiftDepth || targetLiftDepth === 0) {
|
|
44
|
-
formattingCleared.push(nodeName);
|
|
45
|
-
tr.lift(nodeRange, targetLiftDepth);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return true;
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function clearFormatting(inputMethod, editorAnalyticsAPI) {
|
|
54
|
-
return function (state, dispatch) {
|
|
55
|
-
var tr = state.tr;
|
|
56
|
-
var formattingCleared = [];
|
|
57
|
-
FORMATTING_MARK_TYPES.forEach(function (mark) {
|
|
58
|
-
var _tr$selection = tr.selection,
|
|
59
|
-
from = _tr$selection.from,
|
|
60
|
-
to = _tr$selection.to;
|
|
61
|
-
var markType = state.schema.marks[mark];
|
|
62
|
-
if (!markType) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (tr.selection instanceof _cellSelection.CellSelection) {
|
|
66
|
-
(0, _cellSelection2.cellSelectionNodesBetween)(tr.selection, tr.doc, function (node, pos) {
|
|
67
|
-
var isTableCell = node.type === state.schema.nodes.tableCell || node.type === state.schema.nodes.tableHeader;
|
|
68
|
-
if (!isTableCell) {
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
if (tr.doc.rangeHasMark(pos, pos + node.nodeSize, markType)) {
|
|
72
|
-
formattingCleared.push(formatTypes[mark]);
|
|
73
|
-
tr.removeMark(pos, pos + node.nodeSize, markType);
|
|
74
|
-
}
|
|
75
|
-
return false;
|
|
76
|
-
});
|
|
77
|
-
} else if (tr.doc.rangeHasMark(from, to, markType)) {
|
|
78
|
-
formattingCleared.push(formatTypes[mark]);
|
|
79
|
-
tr.removeMark(from, to, markType);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
FORMATTING_NODE_TYPES.forEach(function (nodeName) {
|
|
83
|
-
var formattedNodeType = state.schema.nodes[nodeName];
|
|
84
|
-
var _tr$selection2 = tr.selection,
|
|
85
|
-
$from = _tr$selection2.$from,
|
|
86
|
-
$to = _tr$selection2.$to;
|
|
87
|
-
if (tr.selection instanceof _cellSelection.CellSelection) {
|
|
88
|
-
(0, _cellSelection2.cellSelectionNodesBetween)(tr.selection, tr.doc, clearNodeFormattingOnSelection(state, tr, formattedNodeType, nodeName, formattingCleared));
|
|
89
|
-
} else {
|
|
90
|
-
tr.doc.nodesBetween($from.pos, $to.pos, clearNodeFormattingOnSelection(state, tr, formattedNodeType, nodeName, formattingCleared));
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
tr.setStoredMarks([]);
|
|
94
|
-
if (formattingCleared.length && inputMethod) {
|
|
95
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
96
|
-
action: _analytics.ACTION.FORMATTED,
|
|
97
|
-
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
98
|
-
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
99
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_CLEAR,
|
|
100
|
-
attributes: {
|
|
101
|
-
inputMethod: inputMethod,
|
|
102
|
-
formattingCleared: formattingCleared
|
|
103
|
-
}
|
|
104
|
-
})(tr);
|
|
105
|
-
}
|
|
106
|
-
if (dispatch) {
|
|
107
|
-
dispatch(tr);
|
|
108
|
-
}
|
|
109
|
-
return true;
|
|
110
|
-
};
|
|
111
|
-
}
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.moveRight = exports.moveLeft = exports.createInlineCodeFromTextInputWithAnalytics = void 0;
|
|
7
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
-
var _mark = require("@atlaskit/editor-common/mark");
|
|
9
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
|
-
var _utils = require("../utils");
|
|
11
|
-
var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
|
|
12
|
-
var moveRight = function moveRight() {
|
|
13
|
-
return function (state, dispatch) {
|
|
14
|
-
var code = state.schema.marks.code;
|
|
15
|
-
var _ref = state.selection,
|
|
16
|
-
empty = _ref.empty,
|
|
17
|
-
$cursor = _ref.$cursor;
|
|
18
|
-
if (!empty || !$cursor) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
var storedMarks = state.tr.storedMarks;
|
|
22
|
-
if (code) {
|
|
23
|
-
var insideCode = (0, _utils.markActive)(state, code.create());
|
|
24
|
-
var currentPosHasCode = state.doc.rangeHasMark($cursor.pos, $cursor.pos, code);
|
|
25
|
-
var nextPosHasCode = state.doc.rangeHasMark($cursor.pos, $cursor.pos + 1, code);
|
|
26
|
-
var exitingCode = !currentPosHasCode && !nextPosHasCode && (!storedMarks || !!storedMarks.length);
|
|
27
|
-
var enteringCode = !currentPosHasCode && nextPosHasCode && (!storedMarks || !storedMarks.length);
|
|
28
|
-
|
|
29
|
-
// entering code mark (from the left edge): don't move the cursor, just add the mark
|
|
30
|
-
if (!insideCode && enteringCode) {
|
|
31
|
-
if (dispatch) {
|
|
32
|
-
dispatch(state.tr.addStoredMark(code.create()));
|
|
33
|
-
}
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// exiting code mark: don't move the cursor, just remove the mark
|
|
38
|
-
if (insideCode && exitingCode) {
|
|
39
|
-
if (dispatch) {
|
|
40
|
-
dispatch(state.tr.removeStoredMark(code));
|
|
41
|
-
}
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return false;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
exports.moveRight = moveRight;
|
|
49
|
-
var moveLeft = function moveLeft() {
|
|
50
|
-
return function (state, dispatch) {
|
|
51
|
-
var code = state.schema.marks.code;
|
|
52
|
-
var _ref2 = state.selection,
|
|
53
|
-
empty = _ref2.empty,
|
|
54
|
-
$cursor = _ref2.$cursor;
|
|
55
|
-
if (!empty || !$cursor) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
var storedMarks = state.tr.storedMarks;
|
|
59
|
-
if (code) {
|
|
60
|
-
var insideCode = code && (0, _utils.markActive)(state, code.create());
|
|
61
|
-
var currentPosHasCode = (0, _utils.hasCode)(state, $cursor.pos);
|
|
62
|
-
var nextPosHasCode = (0, _utils.hasCode)(state, $cursor.pos - 1);
|
|
63
|
-
var nextNextPosHasCode = (0, _utils.hasCode)(state, $cursor.pos - 2);
|
|
64
|
-
var exitingCode = currentPosHasCode && !nextPosHasCode && Array.isArray(storedMarks);
|
|
65
|
-
var atLeftEdge = nextPosHasCode && !nextNextPosHasCode && (storedMarks === null || Array.isArray(storedMarks) && !!storedMarks.length);
|
|
66
|
-
var atRightEdge = (exitingCode && Array.isArray(storedMarks) && !storedMarks.length || !exitingCode && storedMarks === null) && !nextPosHasCode && nextNextPosHasCode;
|
|
67
|
-
var enteringCode = !currentPosHasCode && nextPosHasCode && Array.isArray(storedMarks) && !storedMarks.length;
|
|
68
|
-
|
|
69
|
-
// at the right edge: remove code mark and move the cursor to the left
|
|
70
|
-
if (!insideCode && atRightEdge) {
|
|
71
|
-
var tr = state.tr.setSelection(_state.Selection.near(state.doc.resolve($cursor.pos - 1)));
|
|
72
|
-
if (dispatch) {
|
|
73
|
-
dispatch(tr.removeStoredMark(code));
|
|
74
|
-
}
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// entering code mark (from right edge): don't move the cursor, just add the mark
|
|
79
|
-
if (!insideCode && enteringCode) {
|
|
80
|
-
if (dispatch) {
|
|
81
|
-
dispatch(state.tr.addStoredMark(code.create()));
|
|
82
|
-
}
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// at the left edge: add code mark and move the cursor to the left
|
|
87
|
-
if (insideCode && atLeftEdge) {
|
|
88
|
-
var _tr = state.tr.setSelection(_state.Selection.near(state.doc.resolve($cursor.pos - 1)));
|
|
89
|
-
if (dispatch) {
|
|
90
|
-
dispatch(_tr.addStoredMark(code.create()));
|
|
91
|
-
}
|
|
92
|
-
return true;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// exiting code mark (or at the beginning of the line): don't move the cursor, just remove the mark
|
|
96
|
-
var isFirstChild = $cursor.index($cursor.depth - 1) === 0;
|
|
97
|
-
if (insideCode && (exitingCode || !$cursor.nodeBefore && isFirstChild)) {
|
|
98
|
-
if (dispatch) {
|
|
99
|
-
dispatch(state.tr.removeStoredMark(code));
|
|
100
|
-
}
|
|
101
|
-
return true;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return false;
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
exports.moveLeft = moveLeft;
|
|
108
|
-
var createInlineCodeFromTextInput = function createInlineCodeFromTextInput(from, to, text) {
|
|
109
|
-
return function (state, dispatch) {
|
|
110
|
-
if (state.selection.empty) {
|
|
111
|
-
var _state$doc$resolve = state.doc.resolve(from),
|
|
112
|
-
before = _state$doc$resolve.nodeBefore;
|
|
113
|
-
var _state$doc$resolve2 = state.doc.resolve(to),
|
|
114
|
-
after = _state$doc$resolve2.nodeAfter;
|
|
115
|
-
var hasTickBefore = before && before.text && before.text.endsWith('`');
|
|
116
|
-
var hasTickAfter = after && after.text && after.text.startsWith('`');
|
|
117
|
-
if (hasTickBefore && hasTickAfter) {
|
|
118
|
-
var tr = state.tr.replaceRangeWith(from - 1, to + 1, state.schema.text(text));
|
|
119
|
-
if (dispatch) {
|
|
120
|
-
var codeMark = state.schema.marks.code.create();
|
|
121
|
-
tr = (0, _mark.applyMarkOnRange)(tr.mapping.map(from - 1), tr.mapping.map(to + 1), false, codeMark, tr).setStoredMarks([codeMark]);
|
|
122
|
-
dispatch(tr);
|
|
123
|
-
}
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return false;
|
|
128
|
-
};
|
|
129
|
-
};
|
|
130
|
-
var createInlineCodeFromTextInputWithAnalytics = function createInlineCodeFromTextInputWithAnalytics(editorAnalyticsAPI) {
|
|
131
|
-
return function (from, to, text) {
|
|
132
|
-
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
|
|
133
|
-
action: _analytics.ACTION.FORMATTED,
|
|
134
|
-
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
135
|
-
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
136
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_CODE,
|
|
137
|
-
attributes: {
|
|
138
|
-
inputMethod: _analytics.INPUT_METHOD.FORMATTING
|
|
139
|
-
}
|
|
140
|
-
})(createInlineCodeFromTextInput(from, to, text));
|
|
141
|
-
};
|
|
142
|
-
};
|
|
143
|
-
exports.createInlineCodeFromTextInputWithAnalytics = createInlineCodeFromTextInputWithAnalytics;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.transformSmartCharsMentionsAndEmojis = void 0;
|
|
7
|
-
var _mark = require("@atlaskit/editor-common/mark");
|
|
8
|
-
var SMART_TO_ASCII = {
|
|
9
|
-
'…': '...',
|
|
10
|
-
'→': '->',
|
|
11
|
-
'←': '<-',
|
|
12
|
-
'–': '--',
|
|
13
|
-
'“': '"',
|
|
14
|
-
'”': '"',
|
|
15
|
-
'‘': "'",
|
|
16
|
-
'’': "'"
|
|
17
|
-
};
|
|
18
|
-
var FIND_SMART_CHAR = new RegExp("[".concat(Object.keys(SMART_TO_ASCII).join(''), "]"), 'g');
|
|
19
|
-
var replaceMentionOrEmojiForTextContent = function replaceMentionOrEmojiForTextContent(position, nodeSize, textContent, tr) {
|
|
20
|
-
var currentPos = tr.mapping.map(position);
|
|
21
|
-
var schema = tr.doc.type.schema;
|
|
22
|
-
tr.replaceWith(currentPos, currentPos + nodeSize, schema.text(textContent));
|
|
23
|
-
};
|
|
24
|
-
var replaceSmartCharsToAscii = function replaceSmartCharsToAscii(position, textContent, tr) {
|
|
25
|
-
var schema = tr.doc.type.schema;
|
|
26
|
-
var match;
|
|
27
|
-
while (match = FIND_SMART_CHAR.exec(textContent)) {
|
|
28
|
-
var _match = match,
|
|
29
|
-
smartChar = _match[0],
|
|
30
|
-
offset = _match.index;
|
|
31
|
-
var replacePos = tr.mapping.map(position + offset);
|
|
32
|
-
var replacementText = schema.text(SMART_TO_ASCII[smartChar]);
|
|
33
|
-
tr.replaceWith(replacePos, replacePos + smartChar.length, replacementText);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var isNodeTextBlock = function isNodeTextBlock(schema) {
|
|
37
|
-
var _schema$nodes = schema.nodes,
|
|
38
|
-
mention = _schema$nodes.mention,
|
|
39
|
-
text = _schema$nodes.text,
|
|
40
|
-
emoji = _schema$nodes.emoji;
|
|
41
|
-
return function (node, _, parent) {
|
|
42
|
-
if (node.type === mention || node.type === emoji || node.type === text) {
|
|
43
|
-
return parent === null || parent === void 0 ? void 0 : parent.isTextblock;
|
|
44
|
-
}
|
|
45
|
-
return;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
var transformSmartCharsMentionsAndEmojis = function transformSmartCharsMentionsAndEmojis(from, to, tr) {
|
|
49
|
-
var schema = tr.doc.type.schema;
|
|
50
|
-
var _schema$nodes2 = schema.nodes,
|
|
51
|
-
mention = _schema$nodes2.mention,
|
|
52
|
-
text = _schema$nodes2.text,
|
|
53
|
-
emoji = _schema$nodes2.emoji;
|
|
54
|
-
// Traverse through all the nodes within the range and replace them with their plaintext counterpart
|
|
55
|
-
var children = (0, _mark.filterChildrenBetween)(tr.doc, from, to, isNodeTextBlock(schema));
|
|
56
|
-
children.forEach(function (_ref) {
|
|
57
|
-
var node = _ref.node,
|
|
58
|
-
pos = _ref.pos;
|
|
59
|
-
if (node.type === mention || node.type === emoji) {
|
|
60
|
-
replaceMentionOrEmojiForTextContent(pos, node.nodeSize, node.attrs.text, tr);
|
|
61
|
-
} else if (node.type === text && node.text) {
|
|
62
|
-
var replacePosition = pos > from ? pos : from;
|
|
63
|
-
var textToReplace = pos > from ? node.text : node.text.substr(from - pos);
|
|
64
|
-
replaceSmartCharsToAscii(replacePosition, textToReplace, tr);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
exports.transformSmartCharsMentionsAndEmojis = transformSmartCharsMentionsAndEmojis;
|